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