"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[1897,3459],{3459:function(e,t,n){n.r(t),n.d(t,{default:function(){return f}});var l=n(6252),o=n(3577),i=n(3540),a={key:0,src:i,class:"loading"},u={key:1,class:"fas fa-circle-exclamation error"};function r(e,t,n,i,r,s){var c=(0,l.up)("Icon");return(0,l.wg)(),(0,l.iD)("div",{class:(0,o.C_)(["entity-icon-container",{"with-color-fill":!!s.colorFill}]),style:(0,o.j5)(s.colorFillStyle)},[n.loading?((0,l.wg)(),(0,l.iD)("img",a)):n.error?((0,l.wg)(),(0,l.iD)("i",u)):((0,l.wg)(),(0,l.j4)(c,(0,o.vs)((0,l.dG)({key:2},s.computedIconNormalized)),null,16))],6)}var s=n(4648),c=(n(7941),n(7042),n(1478)),d={name:"EntityIcon",components:{Icon:c.Z},props:{loading:{type:Boolean,default:!1},error:{type:Boolean,default:!1},entity:{type:Object,required:!0},icon:{type:Object,default:function(){}},hasColorFill:{type:Boolean,default:!1}},data:function(){return{component:null,modalVisible:!1}},computed:{computedIcon:function(){var e,t,n=(0,s.Z)({},(null===(e=this.entity)||void 0===e||null===(t=e.meta)||void 0===t?void 0:t.icon)||{});return Object.keys(this.icon||{}).length&&(n=this.icon),(0,s.Z)({},n)},colorFill:function(){return this.hasColorFill&&this.computedIcon.color},colorFillStyle:function(){return this.colorFill&&!this.error?{background:this.colorFill}:{}},computedIconNormalized:function(){var e=(0,s.Z)({},this.computedIcon);return this.colorFill&&delete e.color,e},type:function(){var e=this.entity.type||"";return e.charAt(0).toUpperCase()+e.slice(1)}}},v=n(3744);const p=(0,v.Z)(d,[["render",r],["__scopeId","data-v-4fad24e6"]]);var f=p},1897:function(e,t,n){n.r(t),n.d(t,{default:function(){return x}});n(8309),n(1539),n(3948);var l=n(6252),o=n(3577),i=n(9963),a={class:"entity switch-container"},u={class:"col-1 icon"},r={class:"col-s-8 col-m-9 label"},s=["textContent"],c={class:"col-s-3 col-m-2 buttons pull-right"},d=["textContent"],v={class:"row"},p={class:"input"},f=["disabled"],h={key:0,value:"",selected:""},y=["value","selected","textContent"];function g(e,t,n,g,m,w){var k,_=(0,l.up)("EntityIcon");return(0,l.wg)(),(0,l.iD)("div",a,[(0,l._)("div",{class:(0,o.C_)(["head",{collapsed:e.collapsed}])},[(0,l._)("div",u,[(0,l.Wm)(_,{entity:e.value,loading:e.loading,error:e.error},null,8,["entity","loading","error"])]),(0,l._)("div",r,[(0,l._)("div",{class:"name",textContent:(0,o.zw)(e.value.name)},null,8,s)]),(0,l._)("div",c,[w.hasValues?((0,l.wg)(),(0,l.iD)("button",{key:0,onClick:t[0]||(t[0]=(0,i.iM)((function(t){return e.collapsed=!e.collapsed}),["stop"]))},[(0,l._)("i",{class:(0,o.C_)(["fas",{"fa-angle-up":!e.collapsed,"fa-angle-down":e.collapsed}])},null,2)])):(0,l.kq)("",!0),null!=(null===(k=e.value)||void 0===k?void 0:k.value)?((0,l.wg)(),(0,l.iD)("span",{key:1,class:"value",textContent:(0,o.zw)(e.value.values[e.value.value]||e.value.value)},null,8,d)):(0,l.kq)("",!0)])],2),e.collapsed?(0,l.kq)("",!0):((0,l.wg)(),(0,l.iD)("div",{key:0,class:"body",onClick:t[2]||(t[2]=(0,i.iM)((function(){return w.prevent&&w.prevent.apply(w,arguments)}),["stop"]))},[(0,l._)("div",v,[(0,l._)("div",p,[(0,l._)("select",{onInput:t[1]||(t[1]=function(){return w.setValue&&w.setValue.apply(w,arguments)}),ref:"values",disabled:e.loading},[e.value.is_write_only?((0,l.wg)(),(0,l.iD)("option",h,"--")):(0,l.kq)("",!0),((0,l.wg)(!0),(0,l.iD)(l.HY,null,(0,l.Ko)(w.displayValues,(function(t,n){return(0,l.wg)(),(0,l.iD)("option",{value:n,selected:n==e.value.value,key:n,textContent:(0,o.zw)(t)},null,8,y)})),128))],40,f)])])]))])}var m=n(8534),w=(n(5666),n(2479),n(7909)),k=n(3459),_={name:"EnumSwitch",components:{EntityIcon:k["default"]},mixins:[w["default"]],computed:{hasValues:function(){var e;return!!Object.values((null===this||void 0===this||null===(e=this.value)||void 0===e?void 0:e.values)||{}).length},displayValues:function(){var e,t;return(null===(e=this.value)||void 0===e?void 0:e.values)instanceof Array?this.value.values.reduce((function(e,t){return e[t]=t,e}),{}):(null===(t=this.value)||void 0===t?void 0:t.values)||{}}},methods:{prevent:function(e){return e.stopPropagation(),!1},setValue:function(e){var t=this;return(0,m.Z)(regeneratorRuntime.mark((function n(){var l,o;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:if(null!==(l=e.target.value)&&void 0!==l&&l.length){n.next=2;break}return n.abrupt("return");case 2:return t.$emit("loading",!0),t.value.is_write_only&&(o=t,setTimeout((function(){o.$refs.values.value=""}),1e3)),n.prev=4,n.next=7,t.request("entities.execute",{id:t.value.id,action:"set_value",data:e.target.value});case 7:return n.prev=7,t.$emit("loading",!1),n.finish(7);case 10:case"end":return n.stop()}}),n,null,[[4,,7,10]])})))()}}},b=n(3744);const C=(0,b.Z)(_,[["render",g],["__scopeId","data-v-3404ecf7"]]);var x=C},3540:function(e,t,n){e.exports=n.p+"static/img/spinner.c0bee445.gif"}}]);
//# sourceMappingURL=1897-legacy.657985da.js.map