"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[3303,3459],{6:function(t,e,o){o.d(e,{Z:function(){return v}});var l=o(6252),n=o(3577),i=o(9963);const a=t=>((0,l.dD)("data-v-a6396ae8"),t=t(),(0,l.Cn)(),t),s=["checked"],c=a((()=>(0,l._)("div",{class:"switch"},[(0,l._)("div",{class:"dot"})],-1))),r={class:"label"};function u(t,e,o,a,u,d){return(0,l.wg)(),(0,l.iD)("div",{class:(0,n.C_)(["power-switch",{disabled:o.disabled}]),onClick:e[0]||(e[0]=(0,i.iM)(((...t)=>d.onInput&&d.onInput(...t)),["stop"]))},[(0,l._)("input",{type:"checkbox",checked:o.value},null,8,s),(0,l._)("label",null,[c,(0,l._)("span",r,[(0,l.WI)(t.$slots,"default",{},void 0,!0)])])],2)}var d={name:"ToggleSwitch",emits:["input"],props:{value:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},methods:{onInput(t){if(this.disabled)return!1;this.$emit("input",t)}}},p=o(3744);const h=(0,p.Z)(d,[["render",u],["__scopeId","data-v-a6396ae8"]]);var v=h},3459:function(t,e,o){o.r(e),o.d(e,{default:function(){return h}});var l=o(6252),n=o(3577),i=o(3540);const a={key:0,src:i,class:"loading"},s={key:1,class:"fas fa-circle-exclamation error"};function c(t,e,o,i,c,r){const u=(0,l.up)("Icon");return(0,l.wg)(),(0,l.iD)("div",{class:(0,n.C_)(["entity-icon-container",{"with-color-fill":!!r.colorFill}]),style:(0,n.j5)(r.colorFillStyle)},[o.loading?((0,l.wg)(),(0,l.iD)("img",a)):o.error?((0,l.wg)(),(0,l.iD)("i",s)):((0,l.wg)(),(0,l.j4)(u,(0,n.vs)((0,l.dG)({key:2},r.computedIconNormalized)),null,16))],6)}var r=o(1478),u={name:"EntityIcon",components:{Icon:r.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 t={...this.entity?.meta?.icon||{}};return Object.keys(this.icon||{}).length&&(t=this.icon),{...t}},colorFill(){return this.hasColorFill&&this.computedIcon.color},colorFillStyle(){return this.colorFill&&!this.error?{background:this.colorFill}:{}},computedIconNormalized(){const t={...this.computedIcon};return this.colorFill&&delete t.color,t},type(){let t=this.entity.type||"";return t.charAt(0).toUpperCase()+t.slice(1)}}},d=o(3744);const p=(0,d.Z)(u,[["render",c],["__scopeId","data-v-4fad24e6"]]);var h=p},3303:function(t,e,o){o.r(e),o.d(e,{default:function(){return _}});var l=o(6252),n=o(3577),i=o(9963);const a={class:"entity switch-container"},s={class:"head"},c={class:"col-1 icon"},r={class:"col-9 label"},u=["textContent"],d={class:"col-2 switch pull-right"};function p(t,e,o,p,h,v){const y=(0,l.up)("EntityIcon"),g=(0,l.up)("ToggleSwitch");return(0,l.wg)(),(0,l.iD)("div",a,[(0,l._)("div",s,[(0,l._)("div",c,[(0,l.Wm)(y,{entity:t.value,loading:t.loading,error:t.error},null,8,["entity","loading","error"])]),(0,l._)("div",r,[(0,l._)("div",{class:"name",textContent:(0,n.zw)(t.value.name)},null,8,u)]),(0,l._)("div",d,[(0,l.Wm)(g,{value:!t.value.is_write_only&&t.value.state,disabled:t.loading||t.value.is_read_only,onInput:v.toggle,onClick:e[0]||(e[0]=(0,i.iM)((()=>{}),["stop"]))},null,8,["value","disabled","onInput"])])])])}var h=o(6),v=o(3459),y=o(7909),g={name:"Switch",components:{ToggleSwitch:h.Z,EntityIcon:v["default"]},mixins:[y["default"]],methods:{async toggle(t){t.stopPropagation(),this.$emit("loading",!0);try{if(await this.request("entities.execute",{id:this.value.id,action:"toggle"}),this.value.is_write_only){const t=this;t.value.state=!0,setTimeout((()=>t.value.state=!1),250)}}finally{this.$emit("loading",!1)}}}},f=o(3744);const m=(0,f.Z)(g,[["render",p],["__scopeId","data-v-2aaabd26"]]);var _=m},3540:function(t,e,o){t.exports=o.p+"static/img/spinner.c0bee445.gif"}}]);
//# sourceMappingURL=3303.b1e74124.js.map