"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[3368],{3368:function(e,l,t){t.r(l),t.d(l,{default:function(){return b}});var a=t(6252),s=t(3577),n=t(9963);const i={class:"entity switch-container"},u={class:"icon"},o={class:"label"},c=["textContent"],v={class:"value-container"},d=["textContent"],r={class:"row"},p={class:"input"},h=["disabled"],y={key:0,value:"",selected:""},g=["value","selected","textContent"];function w(e,l,t,w,f,_){const k=(0,a.up)("EntityIcon");return(0,a.wg)(),(0,a.iD)("div",i,[(0,a._)("div",{class:(0,s.C_)(["head",{collapsed:e.collapsed}])},[(0,a._)("div",u,[(0,a.Wm)(k,{entity:e.value,loading:e.loading,error:e.error},null,8,["entity","loading","error"])]),(0,a._)("div",o,[(0,a._)("div",{class:"name",textContent:(0,s.zw)(e.value.name)},null,8,c)]),(0,a._)("div",v,[null!=e.value?.value?((0,a.wg)(),(0,a.iD)("span",{key:0,class:"value",textContent:(0,s.zw)(e.value.values[e.value.value]||e.value.value)},null,8,d)):(0,a.kq)("",!0),_.hasValues?((0,a.wg)(),(0,a.iD)("button",{key:1,onClick:l[0]||(l[0]=(0,n.iM)((l=>e.collapsed=!e.collapsed),["stop"]))},[(0,a._)("i",{class:(0,s.C_)(["fas",{"fa-angle-up":!e.collapsed,"fa-angle-down":e.collapsed}])},null,2)])):(0,a.kq)("",!0)])],2),e.collapsed?(0,a.kq)("",!0):((0,a.wg)(),(0,a.iD)("div",{key:0,class:"body",onClick:l[2]||(l[2]=(0,n.iM)(((...e)=>_.prevent&&_.prevent(...e)),["stop"]))},[(0,a._)("div",r,[(0,a._)("div",p,[(0,a._)("select",{onInput:l[1]||(l[1]=(...e)=>_.setValue&&_.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)(_.displayValues,((l,t)=>((0,a.wg)(),(0,a.iD)("option",{value:t,selected:t==e.value.value,key:t,textContent:(0,s.zw)(l)},null,8,g)))),128))],40,h)])])]))])}var f=t(847),_=t(4967),k={name:"EnumSwitch",components:{EntityIcon:_["default"]},mixins:[f["default"]],computed:{hasValues(){return!!Object.values(this?.value?.values||{}).length},displayValues(){return this.value?.values instanceof Array?this.value.values.reduce(((e,l)=>(e[l]=l,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:e.target.value})}finally{this.$emit("loading",!1)}}}}},m=t(3744);const C=(0,m.Z)(k,[["render",w],["__scopeId","data-v-043593ec"]]);var b=C}}]);
//# sourceMappingURL=3368.8c968129.js.map