"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[5466],{6:function(e,n,t){t.d(n,{Z:function(){return p}});var i=t(6252),o=t(3577),a=t(9963),r=function(e){return(0,i.dD)("data-v-a6396ae8"),e=e(),(0,i.Cn)(),e},s=["checked"],u=r((function(){return(0,i._)("div",{class:"switch"},[(0,i._)("div",{class:"dot"})],-1)})),c={class:"label"};function l(e,n,t,r,l,d){return(0,i.wg)(),(0,i.iD)("div",{class:(0,o.C_)(["power-switch",{disabled:t.disabled}]),onClick:n[0]||(n[0]=(0,a.iM)((function(){return d.onInput&&d.onInput.apply(d,arguments)}),["stop"]))},[(0,i._)("input",{type:"checkbox",checked:t.value},null,8,s),(0,i._)("label",null,[u,(0,i._)("span",c,[(0,i.WI)(e.$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:function(e){if(this.disabled)return!1;this.$emit("input",e)}}},f=t(3744);const g=(0,f.Z)(d,[["render",l],["__scopeId","data-v-a6396ae8"]]);var p=g},4004:function(e,n,t){t.d(n,{Z:function(){return s}});var i=t(8534),o=(t(1539),t(8309),t(5666),t(6813)),a={name:"SwitchesMixin",mixins:[o.Z],props:{pluginName:{type:String,required:!0},bus:{type:Object,required:!0},config:{type:Object,default:function(){return{}}},selected:{type:Boolean,default:!1}},data:function(){return{loading:!1,initialized:!1,selectedDevice:null,devices:{}}},methods:{onRefreshEvent:function(e){e===this.pluginName&&this.refresh()},toggle:function(e,n){var t=this;return(0,i.Z)(regeneratorRuntime.mark((function i(){var o;return regeneratorRuntime.wrap((function(i){while(1)switch(i.prev=i.next){case 0:return null==n&&(n=e),i.next=3,t.request("".concat(t.pluginName,".toggle"),{device:n});case 3:o=i.sent,t.devices[e].on=o.on;case 5:case"end":return i.stop()}}),i)})))()},refresh:function(){var e=this;return(0,i.Z)(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return e.loading=!0,n.prev=1,n.next=4,e.request("".concat(e.pluginName,".switch_status"));case 4:e.devices=n.sent.reduce((function(e,n){var t,i=null!==(t=n.name)&&void 0!==t&&t.length?n.name:n.id;return e[i]=n,e}),{});case 5:return n.prev=5,e.loading=!1,n.finish(5);case 8:case"end":return n.stop()}}),n,null,[[1,,5,8]])})))()}},mounted:function(){var e=this;this.$watch((function(){return e.selected}),(function(n){n&&!e.initialized&&(e.refresh(),e.initialized=!0)})),this.bus.on("refresh",this.onRefreshEvent)},unmounted:function(){this.bus.off("refresh",this.onRefreshEvent)}};const r=a;var s=r},8671:function(e,n,t){t.d(n,{Z:function(){return w}});t(8309);var i=t(6252),o=t(9963),a=t(3577),r=function(e){return(0,i.dD)("data-v-38eb9831"),e=e(),(0,i.Cn)(),e},s={class:"name col-l-10 col-m-9 col-s-8"},u=r((function(){return(0,i._)("i",{class:"fa fa-info"},null,-1)})),c=[u],l=["textContent"],d={class:"toggler col-l-2 col-m-3 col-s-4"};function f(e,n,t,r,u,f){var g=(0,i.up)("Loading"),p=(0,i.up)("ToggleSwitch");return(0,i.wg)(),(0,i.iD)("div",{class:"switch",onClick:n[1]||(n[1]=(0,o.iM)((function(){return f.onToggle&&f.onToggle.apply(f,arguments)}),["stop"]))},[t.loading?((0,i.wg)(),(0,i.j4)(g,{key:0})):(0,i.kq)("",!0),(0,i._)("div",s,[t.hasInfo?((0,i.wg)(),(0,i.iD)("button",{key:0,onClick:n[0]||(n[0]=(0,o.iM)((function(){return f.onInfo&&f.onInfo.apply(f,arguments)}),["prevent"]))},c)):(0,i.kq)("",!0),(0,i._)("span",{class:"name-content",textContent:(0,a.zw)(t.name)},null,8,l)]),(0,i._)("div",d,[(0,i.Wm)(p,{disabled:t.loading,value:t.state,onInput:f.onToggle},null,8,["disabled","value","onInput"])])])}var g=t(6),p=t(1232),h={name:"Switch",components:{Loading:p.Z,ToggleSwitch:g.Z},emits:["toggle","info"],props:{name:{type:String,required:!0},state:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},hasInfo:{type:Boolean,default:!1},id:{type:String}},methods:{onInfo:function(e){return e.stopPropagation(),this.$emit("info"),!1},onToggle:function(e){return e.stopPropagation(),this.$emit("toggle"),!1}}},v=t(3744);const m=(0,v.Z)(h,[["render",f],["__scopeId","data-v-38eb9831"]]);var w=m},5466:function(e,n,t){t.r(n),t.d(n,{default:function(){return g}});t(7941);var i=t(6252),o={class:"switches zigbee-mqtt-switches"},a={key:1,class:"no-content"};function r(e,n,t,r,s,u){var c=(0,i.up)("Loading"),l=(0,i.up)("Switch");return(0,i.wg)(),(0,i.iD)("div",o,[e.loading?((0,i.wg)(),(0,i.j4)(c,{key:0})):Object.keys(e.devices).length?(0,i.kq)("",!0):((0,i.wg)(),(0,i.iD)("div",a,"No Zigbee switches found.")),((0,i.wg)(!0),(0,i.iD)(i.HY,null,(0,i.Ko)(e.devices,(function(n,t){return(0,i.wg)(),(0,i.j4)(l,{loading:e.loading,name:t,state:n.on,onToggle:function(n){return e.toggle(t)},key:t},null,8,["loading","name","state","onToggle"])})),128))])}var s=t(1232),u=t(4004),c=t(8671),l={name:"ZigbeeMqtt",components:{Switch:c.Z,Loading:s.Z},mixins:[u.Z]},d=t(3744);const f=(0,d.Z)(l,[["render",r],["__scopeId","data-v-33812db1"]]);var g=f}}]);
//# sourceMappingURL=5466-legacy.ba464f70.js.map