platypush/platypush/backend/http/dist/static/js/chunk-3d60f62e.907e4050.js

2 lines
36 KiB
JavaScript

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-3d60f62e"],{"084e":function(e,t,n){"use strict";n("1015")},1015:function(e,t,n){},"160f":function(e,t,n){},1804:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));n("99af"),n("d81d"),n("b680"),n("b64b");var i=n("2909");function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function c(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}var a=function(){function e(t){if(o(this,e),this.ranges={hue:[0,360],sat:[0,100],bri:[0,100],ct:[154,500]},t)for(var n=0,i=Object.keys(this.ranges);n<i.length;n++){var r=i[n];t[r]&&(this.ranges[r]=t[r])}}return c(e,[{key:"normalize",value:function(e,t,n){return n[0]+(e-t[0])*(n[1]-n[0])/(t[1]-t[0])}},{key:"hslToRgb",value:function(e,t,n){var i=[this.normalize(e,this.ranges.hue,[0,360]),this.normalize(t,this.ranges.sat,[0,100]),this.normalize(n,this.ranges.bri,[0,100])];e=i[0],t=i[1],n=i[2],n/=100;var o=t*Math.min(n,1-n)/100,r=function(t){var i=(t+e/30)%12,r=n-o*Math.max(Math.min(i-3,9-i,1),-1);return Math.round(255*r)};return[r(0),r(8),r(4)]}},{key:"rgbToHsl",value:function(e,t,n){e/=255,t/=255,n/=255;var i,o,r=Math.max(e,t,n),c=Math.min(e,t,n),a=(r+c)/2;if(r===c)i=o=0;else{var s=r-c;switch(o=a>.5?s/(2-r-c):s/(r+c),r){case e:i=(t-n)/s+(t<n?6:0);break;case t:i=(n-e)/s+2;break;case n:i=(e-t)/s+4;break}i/=6}return[parseInt(this.normalize(i,[0,1],this.ranges.hue)),parseInt(this.normalize(o,[0,1],this.ranges.sat)),parseInt(this.normalize(a,[0,1],this.ranges.bri))]}},{key:"xyToRgb",value:function(e,t,n){null==n&&(n=this.ranges.bri[1]);var i=1-e-t,o=(n/(this.ranges.bri[1]-1)).toFixed(2),r=o/t*e,c=o/t*i,a=1.656492*r-.354851*o-.255038*c,s=.707196*-r+1.655397*o+.036152*c,l=.051713*r-.121364*o+1.01153*c;return a>l&&a>s&&a>1?(s/=a,l/=a,a=1):s>l&&s>a&&s>1?(a/=s,l/=s,s=1):l>a&&l>s&&l>1&&(a/=l,s/=l,l=1),a=a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055,s=s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055,l=l<=.0031308?12.92*l:1.055*Math.pow(l,1/2.4)-.055,a=Math.round(255*a),s=Math.round(255*s),l=Math.round(255*l),isNaN(a)&&(a=0),isNaN(s)&&(s=0),isNaN(l)&&(l=0),[a,s,l].map((function(e){return Math.min(Math.max(0,e),255)}))}},{key:"rgbToXY",value:function(e,t,n){e>1&&(e/=255),t>1&&(t/=255),n>1&&(n/=255),e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var i=.664511*e+.154324*t+.162028*n,o=.283881*e+.668433*t+.047685*n,r=88e-6*e+.07231*t+.986039*n,c=parseFloat((i/(i+o+r)).toFixed(4)),a=parseFloat((o/(i+o+r)).toFixed(4));return isNaN(c)&&(c=0),isNaN(a)&&(a=0),[c,a]}},{key:"rgbToBri",value:function(e,t,n){return Math.min(2*this.rgbToHsl(e,t,n)[2],this.ranges.bri[1])}},{key:"getRGB",value:function(e){return null!=e.red&&null!=e.green&&null!=e.blue?[e.red,e.green,e.blue]:null!=e.r&&null!=e.g&&null!=e.b?[e.r,e.g,e.b]:e.rgb?e.rgb:void 0}},{key:"getXY",value:function(e){return null!=e.x&&null!=e.y?[e.x,e.y]:e.xy?e.xy:void 0}},{key:"toRGB",value:function(e){var t=this.getRGB(e);if(t)return t;var n=this.getXY(e);return n&&e.bri?this.xyToRgb.apply(this,Object(i["a"])(n).concat([e.bri])):e.hue&&e.sat&&e.bri?this.hslToRgb(e.hue,e.sat,e.bri):(console.debug("Could not determine color space"),void console.debug(e))}},{key:"toXY",value:function(e){var t=this.getXY(e);if(t&&e.bri)return[t[0],t[1],e.bri];var n=this.getRGB(e);if(n)return this.rgbToXY.apply(this,Object(i["a"])(n));if(e.hue&&e.sat&&e.bri){var o=this.hslToRgb(e.hue,e.sat,e.bri);return this.rgbToXY.apply(this,Object(i["a"])(o))}console.debug("Could not determine color space"),console.debug(e)}},{key:"toHSL",value:function(e){if(e.hue&&e.sat&&e.bri)return[e.hue,e.sat,e.bri];var t=this.getRGB(e);if(t)return this.rgbToHsl.apply(this,Object(i["a"])(t));var n=this.getXY(e);if(n&&e.bri){var o=this.xyToRgb.apply(this,Object(i["a"])(n).concat([e.bri]));return this.rgbToHsl.apply(this,Object(i["a"])(o))}console.debug("Could not determine color space"),console.debug(e)}}]),e}()},"1ed6":function(e,t,n){},3401:function(e,t,n){"use strict";n("7e56")},"4de4":function(e,t,n){"use strict";var i=n("23e7"),o=n("b727").filter,r=n("1dde"),c=n("ae40"),a=r("filter"),s=c("filter");i({target:"Array",proto:!0,forced:!a||!s},{filter:function(e){return o(this,e,arguments.length>1?arguments[1]:void 0)}})},"520c":function(e,t,n){},5530:function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));n("a4d3"),n("4de4"),n("4160"),n("e439"),n("dbb4"),n("b64b"),n("159b");function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}},"5b0a":function(e,t,n){"use strict";n("7ef9")},"5d62":function(e,t,n){},6055:function(e,t,n){},"7e56":function(e,t,n){},"7e57":function(e,t,n){"use strict";n("e3f0")},"7ef9":function(e,t,n){},"8dcb":function(e,t,n){"use strict";n("d28c")},"93d8":function(e,t,n){"use strict";n("6055")},9840:function(e,t,n){"use strict";n("5d62")},b347:function(e,t,n){"use strict";n("160f")},bf6b:function(e,t,n){"use strict";n("fda1")},cf99:function(e,t,n){"use strict";n.r(t);n("b64b");var i=n("7a23"),o=Object(i["K"])("data-v-0378547e");Object(i["u"])("data-v-0378547e");var r={class:"plugin lights-plugin"},c={key:0,class:"panel"},a={key:1,class:"panel"};Object(i["s"])();var s=o((function(e,t,n,o,s,l){var u=Object(i["z"])("Groups"),b=Object(i["z"])("Group");return Object(i["r"])(),Object(i["e"])("div",r,[null==s.selectedGroup&&n.groups&&Object.keys(n.groups).length?(Object(i["r"])(),Object(i["e"])("div",c,[Object(i["h"])(u,{groups:n.groups,"loading-groups":n.loadingGroups,"color-converter":n.colorConverter,onSelect:t[1]||(t[1]=function(e){return s.selectedGroup=e}),onToggle:t[2]||(t[2]=function(t){return e.$emit("group-toggle",t)})},null,8,["groups","loading-groups","color-converter"])])):(Object(i["r"])(),Object(i["e"])("div",a,[Object(i["h"])(b,{group:n.groups[s.selectedGroup],lights:l.displayedLights,scenes:l.scenesByGroup[s.selectedGroup],"color-converter":n.colorConverter,animations:l.animationsByGroup[s.selectedGroup],onClose:t[3]||(t[3]=function(e){return s.selectedGroup=null}),onLightToggle:t[4]||(t[4]=function(t){return e.$emit("light-toggle",t)}),onGroupToggle:t[5]||(t[5]=function(t){return e.$emit("group-toggle",t)}),onSetLight:t[6]||(t[6]=function(t){return e.$emit("set-light",t)}),onSetGroup:t[7]||(t[7]=function(t){return e.$emit("set-group",{groupId:s.selectedGroup,value:t})}),onSelectScene:t[8]||(t[8]=function(t){return e.$emit("select-scene",{groupId:s.selectedGroup,sceneId:t})}),onStartAnimation:t[9]||(t[9]=function(t){return e.$emit("start-animation",t)}),onStopAnimation:t[10]||(t[10]=function(t){return e.$emit("stop-animation",t)})},null,8,["group","lights","scenes","color-converter","animations"])]))])})),l=(n("4160"),n("13d5"),n("a9e3"),n("4fad"),n("07ac"),n("159b"),n("5530")),u=n("3835"),b=n("3e54"),d={name:"Panel",emits:["mounted"],props:{config:{type:Object,default:function(){}},pluginName:{type:String,required:!0}},data:function(){return{loading:!1}},mounted:function(){this.$emit("mounted",this)}},g=d,h=(n("b0c0"),Object(i["K"])("data-v-42318a2b"));Object(i["u"])("data-v-42318a2b");var p={class:"panel-row header"},f=Object(i["h"])("div",{class:"col-3"},[Object(i["h"])("i",{class:"icon fas fa-home"})],-1),O=Object(i["h"])("div",{class:"col-6 name"}," Rooms ",-1),j={class:"col-3 pull-right"},v={class:"name col-9"},m={class:"controls col-3 pull-right"};Object(i["s"])();var y=h((function(e,t,n,o,r,c){var a=Object(i["z"])("ToggleSwitch"),s=Object(i["z"])("MenuPanel");return Object(i["r"])(),Object(i["e"])(s,null,{default:h((function(){return[Object(i["h"])("div",p,[f,O,Object(i["h"])("div",j,[Object(i["h"])(a,{value:c.anyLightsOn,onInput:t[1]||(t[1]=function(t){return e.$emit("toggle")})},null,8,["value"])])]),(Object(i["r"])(!0),Object(i["e"])(i["a"],null,Object(i["x"])(c.groupsSorted,(function(t){return Object(i["r"])(),Object(i["e"])("div",{class:"panel-row row group",key:t.id,onClick:function(n){return e.$emit("select",t.id)}},[Object(i["h"])("span",v,Object(i["C"])(t.name||"[Group ".concat(t.id,"]")),1),Object(i["h"])("span",m,[Object(i["h"])(a,{value:t.state.any_on,disabled:t.id in(n.loadingGroups||{}),onInput:function(n){return e.$emit("toggle",t)}},null,8,["value","disabled","onInput"])])],8,["onClick"])})),128))]})),_:1})})),w=(n("d81d"),{class:"menu-panel"}),C={class:"content"};function k(e,t,n,o,r,c){return Object(i["r"])(),Object(i["e"])("div",w,[Object(i["h"])("div",C,[Object(i["y"])(e.$slots,"default")])])}var _={name:"MenuPanel"};n("3401");_.render=k;var S=_,L=Object(i["K"])("data-v-8fae7678");Object(i["u"])("data-v-8fae7678");var G=Object(i["h"])("div",{class:"switch"},[Object(i["h"])("div",{class:"dot"})],-1),$={class:"label"};Object(i["s"])();var x=L((function(e,t,n,o,r,c){return Object(i["r"])(),Object(i["e"])("div",{class:["power-switch",{disabled:n.disabled}],onClick:t[1]||(t[1]=function(){return c.onInput.apply(c,arguments)})},[Object(i["h"])("input",{type:"checkbox",checked:n.value},null,8,["checked"]),Object(i["h"])("label",null,[G,Object(i["h"])("span",$,[Object(i["y"])(e.$slots,"default")])])],2)})),A={name:"ToggleSwitch",emits:["input"],props:{value:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},methods:{onInput:function(e){if(e.stopPropagation(),this.disabled)return!1;this.$emit("input",e)}}};n("5b0a");A.render=x,A.__scopeId="data-v-8fae7678";var I=A,T=n("1804"),M={name:"Groups",components:{ToggleSwitch:I,MenuPanel:S},emits:["select","toggle"],props:{groups:{type:Object,default:function(){}},loadingGroups:{type:Object,default:function(){}},colorConverter:{type:Object,default:function(){return new T["a"]}}},computed:{groupsSorted:function(){return Object.entries(this.groups).sort((function(e,t){return e[1].name.localeCompare(t[1].name)})).map((function(e){var t=Object(u["a"])(e,2),n=t[0],i=t[1];return Object(l["a"])(Object(l["a"])({},i),{},{id:n})}))},anyLightsOn:function(){for(var e=0,t=Object.values(this.groups);e<t.length;e++){var n,i=t[e];if(null===i||void 0===i||null===(n=i.state)||void 0===n?void 0:n.any_on)return!0}return!1}}};n("8dcb");M.render=y,M.__scopeId="data-v-42318a2b";var z=M,B={class:"light-group-container"},P={class:"panel-row header"},R={key:0,class:"col-3"},N=Object(i["h"])("i",{class:"fas fa-chevron-left"},null,-1),E={key:1,class:"col-3 pull-right"},V={key:0,class:"no-lights"},F={key:1,class:"lights-view"},H={class:"row view-selector"},X=Object(i["h"])("i",{class:"icon fas fa-lightbulb"},null,-1),Y=Object(i["h"])("i",{class:"icon far fa-image"},null,-1),D=Object(i["h"])("i",{class:"icon fas fa-video"},null,-1),K={key:0,class:"view fade-in"},J={key:1,class:"view fade-in"},U={key:2,class:"view group-controls fade-in"},q={key:3,class:"view group-controls fade-in"};function Q(e,t,n,o,r,c){var a=Object(i["z"])("ToggleSwitch"),s=Object(i["z"])("Light"),l=Object(i["z"])("Scene"),u=Object(i["z"])("Controls"),b=Object(i["z"])("Animate"),d=Object(i["z"])("MenuPanel");return Object(i["r"])(),Object(i["e"])("div",B,[Object(i["h"])(d,null,{default:Object(i["H"])((function(){return[Object(i["h"])("div",P,[n.group?(Object(i["r"])(),Object(i["e"])("div",R,[Object(i["h"])("button",{class:"back-btn",title:"Back",onClick:t[1]||(t[1]=function(){return c.close.apply(c,arguments)})},[N])])):Object(i["f"])("",!0),Object(i["h"])("div",{class:["col-6 name",{selected:"group"===r.selectedView}],textContent:Object(i["C"])(c.groupName),onClick:t[2]||(t[2]=function(e){return r.selectedView="group"===r.selectedView?null:"group"})},null,10,["textContent"]),n.group?(Object(i["r"])(),Object(i["e"])("div",E,[Object(i["h"])(a,{value:n.group.state.any_on,onInput:t[3]||(t[3]=function(t){return e.$emit("group-toggle",n.group)})},null,8,["value"])])):Object(i["f"])("",!0)]),n.lights&&Object.keys(n.lights).length?(Object(i["r"])(),Object(i["e"])("div",F,[Object(i["h"])("div",H,[Object(i["h"])("button",{class:{selected:"lights"===r.selectedView},title:"Lights",onClick:t[4]||(t[4]=function(e){return r.selectedView="lights"})},[X],2),Object(i["h"])("button",{class:{selected:"scenes"===r.selectedView},title:"Scenes",onClick:t[5]||(t[5]=function(e){return r.selectedView="scenes"})},[Y],2),Object(i["h"])("button",{class:{selected:"animate"===r.selectedView},title:"Animate",onClick:t[6]||(t[6]=function(e){return r.selectedView="animate"})},[D],2)]),"lights"===r.selectedView?(Object(i["r"])(),Object(i["e"])("div",K,[(Object(i["r"])(),Object(i["e"])(i["b"],null,[(Object(i["r"])(!0),Object(i["e"])(i["a"],null,Object(i["x"])(c.lightsSorted,(function(t,o){return Object(i["r"])(),Object(i["e"])("div",{class:["panel-row row",{expanded:t.id===r.selectedLight}],key:o,onClick:function(e){return r.selectedLight=r.selectedLight===t.id?null:t.id}},[Object(i["h"])(s,{light:t,group:n.group,collapsed:t.id!==r.selectedLight,"color-converter":n.colorConverter,onToggle:function(n){return e.$emit("light-toggle",t)},onSetLight:function(n){return e.$emit("set-light",{light:t,value:n})}},null,8,["light","group","collapsed","color-converter","onToggle","onSetLight"])],10,["onClick"])})),128))],1024))])):"scenes"===r.selectedView?(Object(i["r"])(),Object(i["e"])("div",J,[(Object(i["r"])(),Object(i["e"])(i["b"],null,[(Object(i["r"])(!0),Object(i["e"])(i["a"],null,Object(i["x"])(c.scenesSorted,(function(e,t){return Object(i["r"])(),Object(i["e"])("div",{class:["panel-row row",{selected:e.id===r.selectedScene}],key:t,onClick:function(t){return c.onSceneSelected(e.id)}},[Object(i["h"])(l,{scene:e,group:n.group},null,8,["scene","group"])],10,["onClick"])})),128))],1024))])):"group"===r.selectedView?(Object(i["r"])(),Object(i["e"])("div",U,[(Object(i["r"])(),Object(i["e"])(i["b"],null,[Object(i["h"])(u,{group:n.group,lights:n.lights,"color-converter":n.colorConverter,onSetGroup:t[7]||(t[7]=function(t){return e.$emit("set-group",t)})},null,8,["group","lights","color-converter"])],1024))])):"animate"===r.selectedView?(Object(i["r"])(),Object(i["e"])("div",q,[(Object(i["r"])(),Object(i["e"])(i["b"],null,[Object(i["h"])(b,{group:n.group,lights:n.lights,"color-converter":n.colorConverter,"running-animations":n.animations,onStart:t[8]||(t[8]=function(t){return e.$emit("start-animation",t)}),onStop:t[9]||(t[9]=function(t){return e.$emit("stop-animation",t)})},null,8,["group","lights","color-converter","running-animations"])],1024))])):Object(i["f"])("",!0)])):(Object(i["r"])(),Object(i["e"])("div",V," No lights found "))]})),_:1})])}var W=Object(i["K"])("data-v-52168252");Object(i["u"])("data-v-52168252");var Z={class:"row"},ee={class:"toggle col-3 pull-right"},te={key:0,class:"row fade-in"};Object(i["s"])();var ne=W((function(e,t,n,o,r,c){var a=Object(i["z"])("ToggleSwitch"),s=Object(i["z"])("Controls");return Object(i["r"])(),Object(i["e"])("div",{class:["light",{expanded:!n.collapsed}],ref:"element"},[Object(i["h"])("div",Z,[Object(i["h"])("span",{class:"name col-9",onClick:t[1]||(t[1]=function(){return c.expandToggle.apply(c,arguments)})},Object(i["C"])(n.light.name||"[Light ".concat(n.light.id,"]")),1),Object(i["h"])("span",ee,[Object(i["h"])(a,{value:n.light.state.on,disabled:n.loading,onInput:t[2]||(t[2]=function(t){return e.$emit("toggle",n.light)})},null,8,["value","disabled"])])]),n.collapsed?Object(i["f"])("",!0):(Object(i["r"])(),Object(i["e"])("div",te,[Object(i["h"])(s,{light:n.light,loading:n.loading,"color-converter":n.colorConverter,onSetLight:t[3]||(t[3]=function(t){return e.$emit("set-light",t)})},null,8,["light","loading","color-converter"])]))],2)})),ie=Object(i["K"])("data-v-e2726892");Object(i["u"])("data-v-e2726892");var oe={key:1,class:"row"},re=Object(i["h"])("div",{class:"col-1 icon"},[Object(i["h"])("i",{class:"fas fa-sun"})],-1),ce={class:"col-11 control"},ae={key:2,class:"row"},se=Object(i["h"])("div",{class:"col-1 icon"},[Object(i["h"])("i",{class:"fas fa-thermometer-half"})],-1),le={class:"col-11 control"},ue={key:3,class:"row"},be=Object(i["h"])("span",{class:"col-1 icon"},[Object(i["h"])("i",{class:"fas fa-palette"})],-1),de={class:"col-11 control"};Object(i["s"])();var ge=ie((function(e,t,n,o,r,c){var a=Object(i["z"])("Loading"),s=Object(i["z"])("Slider");return Object(i["r"])(),Object(i["e"])("div",{class:"controls light-controls",onClick:t[4]||(t[4]=function(e){return e.stopPropagation()})},[n.loading?(Object(i["r"])(),Object(i["e"])(a,{key:0})):Object(i["f"])("",!0),null!=c.state.bri?(Object(i["r"])(),Object(i["e"])("div",oe,[re,Object(i["h"])("div",ce,[Object(i["h"])(s,{range:n.colorConverter.ranges.bri,disabled:n.loading,value:c.state.bri,onMouseup:t[1]||(t[1]=Object(i["J"])((function(t){return e.$emit(n.light?"set-light":"set-group",{brightness:parseInt(t.target.value)})}),["stop"]))},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),null!=c.state.ct?(Object(i["r"])(),Object(i["e"])("div",ae,[se,Object(i["h"])("div",le,[Object(i["h"])(s,{range:n.colorConverter.ranges.ct,disabled:n.loading,value:c.state.ct,onMouseup:t[2]||(t[2]=Object(i["J"])((function(t){return e.$emit(n.light?"set-light":"set-group",{temperature:parseInt(t.target.value)})}),["stop"]))},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),c.rgbColor?(Object(i["r"])(),Object(i["e"])("label",ue,[be,Object(i["h"])("span",de,[Object(i["h"])("input",{type:"color",value:c.rgbColor,onChange:t[3]||(t[3]=Object(i["J"])((function(){return c.onColorSelect.apply(c,arguments)}),["stop"]))},null,40,["value"])])])):Object(i["f"])("",!0)])})),he=(n("99af"),n("a15b"),n("fb6a"),n("d3b7"),n("ac1f"),n("25f0"),n("1276"),n("ddb0"),n("2909")),pe=n("8285"),fe=n("3a5e"),Oe={name:"Controls",components:{Loading:fe["a"],Slider:pe["a"]},emits:["set-light","set-group"],props:{light:{type:Object},lights:{type:Object},group:{type:Object},loading:{type:Boolean,default:!1},colorConverter:{type:Object,default:function(){return new T["a"]}}},computed:{state:function(){var e,t;if(null===(e=this.light)||void 0===e?void 0:e.state)return this.light.state;var n=(null===(t=this.group)||void 0===t?void 0:t.state)||{};if(!this.lights)return n;var i=function e(t){return t&&t.length?t[0]instanceof Array?Object(he["a"])(t[0].keys()).map((function(n){return e(t.map((function(e){return e[n]})))})):t.reduce((function(e,t){return e+t}),0)/t.length:0};return Object(l["a"])(Object(l["a"])({},n),Object.entries(Object.values(this.lights).reduce((function(e,t){return["bri","hue","sat","rgb","xy","red","green","blue","ct"].forEach((function(n){var i;null!=(null===(i=t.state)||void 0===i?void 0:i[n])&&(e[n]=[].concat(Object(he["a"])(e[n]||[]),[t.state[n]]))})),e}),{})).reduce((function(e,t){var n=Object(u["a"])(t,2),o=n[0],r=n[1];return e[o]=i(r),e}),{}))},color:function(){return this.getColor(this.state)},rgbColor:function(){var e=this.colorConverter.toRGB(this.state);return e?"#"+e.map((function(e){var t=e.toString(16);return t.length<2&&(t="0"+t),t})).join(""):null}},methods:{onColorSelect:function(e){var t,n,i,o=e.target.value.slice(1).split(/(?=(?:..)*$)/).map((function(e){return parseInt("0x".concat(e))}));this.$emit(this.light?"set-light":"set-group",{rgb:o,xy:(t=this.colorConverter).rgbToXY.apply(t,Object(he["a"])(o)),hsl:(n=this.colorConverter).rgbToHsl.apply(n,Object(he["a"])(o)),brightness:(i=this.colorConverter).rgbToBri.apply(i,Object(he["a"])(o))})},getColor:function(e){return{rgb:this.colorConverter.toRGB(e),xy:this.colorConverter.toXY(e),hsl:this.colorConverter.toHSL(e)}}}};n("bf6b"),n("e239");Oe.render=ge,Oe.__scopeId="data-v-e2726892";var je=Oe,ve={name:"Light",components:{Controls:je,ToggleSwitch:I},emits:["toggle","set-light","collapsed","expanded"],props:{light:{type:Object,default:function(){}},group:{type:Object,default:function(){}},loading:{type:Boolean,default:!1},collapsed:{type:Boolean,default:!0},colorConverter:{type:Object,default:function(){return new T["a"]}}},methods:{expandToggle:function(){this.$emit(this.collapsed?"expanded":"collapsed")}}};n("93d8");ve.render=ne,ve.__scopeId="data-v-52168252";var me=ve;function ye(e,t,n,o,r,c){var a=Object(i["z"])("Loading");return Object(i["r"])(),Object(i["e"])(i["a"],null,[n.loading?(Object(i["r"])(),Object(i["e"])(a,{key:0})):Object(i["f"])("",!0),Object(i["h"])("div",{class:"scene row name",onClick:t[1]||(t[1]=function(){return c.onSelect.apply(c,arguments)})},Object(i["C"])(n.scene.name||"[Scene ".concat(n.scene.id,"]")),1)],64)}var we={name:"Light",emits:["select"],props:{scene:{type:Object,default:function(){}},group:{type:Object,default:function(){}},loading:{type:Boolean,default:!1}},methods:{onSelect:function(){if(this.loading)return!1;this.$emit("select")}}};we.render=ye;var Ce=we,ke=(n("4de4"),Object(i["K"])("data-v-1739aaba"));Object(i["u"])("data-v-1739aaba");var _e={class:"animation-container"},Se={class:"animation-header"},Le={class:"row"},Ge=Object(i["h"])("div",{class:"col-3"}," Run Animation ",-1),$e={class:"col-9"},xe={class:"row"},Ae=Object(i["h"])("div",{class:"col-3"},"Animation",-1),Ie={class:"col-9"},Te=Object(i["h"])("option",{value:"color_transition"},"Color transition",-1),Me=Object(i["h"])("option",{value:"blink"},"Blink",-1),ze={class:"animation"},Be={key:0,class:"row"},Pe=Object(i["h"])("div",{class:"col-3"}," Hue range ",-1),Re={class:"col-9"},Ne={key:1,class:"row"},Ee=Object(i["h"])("div",{class:"col-3"}," Sat range ",-1),Ve={class:"col-9"},Fe={key:2,class:"row"},He=Object(i["h"])("div",{class:"col-3"}," Bri range ",-1),Xe={class:"col-9"},Ye={key:3,class:"row"},De=Object(i["h"])("div",{class:"col-3"}," Hue step ",-1),Ke={class:"col-9"},Je={key:4,class:"row"},Ue=Object(i["h"])("div",{class:"col-3"}," Sat step ",-1),qe={class:"col-9"},Qe={key:5,class:"row"},We=Object(i["h"])("div",{class:"col-3"}," Bri step ",-1),Ze={class:"col-9"},et={class:"row"},tt=Object(i["h"])("div",{class:"col-3"}," Refresh seconds ",-1),nt={class:"col-9"},it={class:"row"},ot=Object(i["h"])("div",{class:"col-3"}," Duration (seconds) ",-1),rt={class:"col-9"},ct={class:"lights"},at={class:"row"},st=Object(i["g"])(" Select all lights ");Object(i["s"])();var lt=ke((function(e,t,n,o,r,c){var a=Object(i["z"])("Loading"),s=Object(i["z"])("ToggleSwitch"),l=Object(i["z"])("RangeSlider"),u=Object(i["z"])("Slider");return Object(i["r"])(),Object(i["e"])("div",{class:"controls animation-controls",onClick:t[11]||(t[11]=function(e){return e.stopPropagation()})},[n.loading?(Object(i["r"])(),Object(i["e"])(a,{key:0})):Object(i["f"])("",!0),Object(i["h"])("div",_e,[Object(i["h"])("div",Se,[Object(i["h"])("div",Le,[Ge,Object(i["h"])("div",$e,[Object(i["h"])(s,{value:c.animationRunning,onInput:c.toggleAnimation},null,8,["value","onInput"])])]),Object(i["h"])("div",xe,[Ae,Object(i["h"])("div",Ie,[Object(i["h"])("label",null,[Object(i["h"])("select",{class:"selector",onClick:t[1]||(t[1]=function(e){return r.selectedAnimation=e.target.value})},[Te,Me])])])])]),Object(i["h"])("div",ze,["color_transition"===r.selectedAnimation?(Object(i["r"])(),Object(i["e"])("div",Be,[Pe,Object(i["h"])("div",Re,[Object(i["h"])(l,{range:n.colorConverter.ranges.hue,disabled:n.loading,value:r.animations.color_transition.hue_range,onMouseup:t[2]||(t[2]=function(e){return r.animations.color_transition.hue_range=e.target.value})},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),"color_transition"===r.selectedAnimation?(Object(i["r"])(),Object(i["e"])("div",Ne,[Ee,Object(i["h"])("div",Ve,[Object(i["h"])(l,{range:n.colorConverter.ranges.sat,disabled:n.loading,value:r.animations.color_transition.sat_range,onMouseup:t[3]||(t[3]=function(e){return r.animations.color_transition.sat_range=e.target.value})},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),"color_transition"===r.selectedAnimation?(Object(i["r"])(),Object(i["e"])("div",Fe,[He,Object(i["h"])("div",Xe,[Object(i["h"])(l,{range:n.colorConverter.ranges.sat,disabled:n.loading,value:r.animations.color_transition.bri_range,onMouseup:t[4]||(t[4]=function(e){return r.animations.color_transition.bri_range=e.target.value})},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),"color_transition"===r.selectedAnimation?(Object(i["r"])(),Object(i["e"])("div",Ye,[De,Object(i["h"])("div",Ke,[Object(i["h"])(u,{range:n.colorConverter.ranges.hue,disabled:n.loading,value:r.animations.color_transition.hue_step,onMouseup:t[5]||(t[5]=function(e){return r.animations.color_transition.hue_step=parseFloat(e.target.value)})},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),"color_transition"===r.selectedAnimation?(Object(i["r"])(),Object(i["e"])("div",Je,[Ue,Object(i["h"])("div",qe,[Object(i["h"])(u,{range:n.colorConverter.ranges.sat,disabled:n.loading,value:r.animations.color_transition.sat_step,onMouseup:t[6]||(t[6]=function(e){return r.animations.color_transition.sat_step=parseFloat(e.target.value)})},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),"color_transition"===r.selectedAnimation?(Object(i["r"])(),Object(i["e"])("div",Qe,[We,Object(i["h"])("div",Ze,[Object(i["h"])(u,{range:n.colorConverter.ranges.bri,disabled:n.loading,value:r.animations.color_transition.bri_step,onMouseup:t[7]||(t[7]=function(e){return r.animations.color_transition.bri_step=parseFloat(e.target.value)})},null,8,["range","disabled","value"])])])):Object(i["f"])("",!0),Object(i["h"])("div",et,[tt,Object(i["h"])("div",nt,[Object(i["h"])("label",null,[Object(i["h"])("input",{type:"number",value:r.animations[r.selectedAnimation].transition_seconds,step:"0.1",onInput:t[8]||(t[8]=function(e){return r.animations[r.selectedAnimation].transition_seconds=parseFloat(e.target.value)})},null,40,["value"])])])]),Object(i["h"])("div",it,[ot,Object(i["h"])("div",rt,[Object(i["h"])("label",null,[Object(i["h"])("input",{type:"number",value:r.animations[r.selectedAnimation].duration,step:"5",onInput:t[9]||(t[9]=function(e){var t;return r.animations[r.selectedAnimation].duration=(null===(t=e.target.value)||void 0===t?void 0:t.length)?parseFloat(e.target.value):null})},null,40,["value"])])])])])]),Object(i["h"])("div",ct,[Object(i["h"])("div",at,[Object(i["h"])("label",null,[Object(i["h"])("input",{type:"checkbox",checked:Object.keys(n.lights).length===Object.values(r.selectedLights).filter((function(e){return e})).length,onClick:t[10]||(t[10]=function(){return c.toggleSelectAll.apply(c,arguments)})},null,8,["checked"]),st])]),(Object(i["r"])(!0),Object(i["e"])(i["a"],null,Object(i["x"])(n.lights,(function(e,t){return Object(i["r"])(),Object(i["e"])("div",{class:"row",key:t},[Object(i["h"])("label",null,[Object(i["I"])(Object(i["h"])("input",{type:"checkbox","onUpdate:modelValue":function(e){return r.selectedLights[t]=e},onInput:function(e){return r.selectedLights[t]=!r.selectedLights[t]}},null,40,["onUpdate:modelValue","onInput"]),[[i["E"],r.selectedLights[t]]]),Object(i["g"])(" "+Object(i["C"])(e.name),1)])])})),128))])])})),ut=Object(i["K"])("data-v-0e677180");Object(i["u"])("data-v-0e677180");var bt={class:"range-slider"};Object(i["s"])();var dt=ut((function(e,t,n,o,r,c){return Object(i["r"])(),Object(i["e"])("div",bt,[Object(i["h"])("label",null,[(Object(i["r"])(!0),Object(i["e"])(i["a"],null,Object(i["x"])(n.value,(function(e,o){return Object(i["r"])(),Object(i["e"])("input",{class:"slider",type:"range",value:e,min:n.range[0],max:n.range[1],disabled:n.disabled,onInput:t[1]||(t[1]=function(){return c.input.apply(c,arguments)}),onChange:t[2]||(t[2]=function(){return c.changed.apply(c,arguments)}),onMouseup:t[3]||(t[3]=function(){return c.mouseup.apply(c,arguments)}),onMousedown:t[4]||(t[4]=function(){return c.mousedown.apply(c,arguments)}),onTouchstart:t[5]||(t[5]=function(){return c.mouseup.apply(c,arguments)}),onTouchend:t[6]||(t[6]=function(){return c.mousedown.apply(c,arguments)}),ref:"input_".concat(o),key:o},null,40,["value","min","max","disabled"])})),128))])])})),gt={name:"RangeSlider",emits:["input","change","mouseup","mousedown"],props:{disabled:{type:Boolean,default:!1},range:{type:Array,default:function(){return[0,100]}},value:{type:Array,default:function(){return[0,100]}}},methods:{getEvent:function(e){return Object(l["a"])(Object(l["a"])({},e),{},{target:Object(l["a"])(Object(l["a"])({},e.target),{},{value:Object.values(this.$refs).map((function(e){return parseFloat(e.value)})).sort()})})},input:function(e){this.$emit("input",this.getEvent(e))},changed:function(e){this.$emit("change",this.getEvent(e))},mouseup:function(e){this.$emit("mouseup",this.getEvent(e))},mousedown:function(e){this.$emit("mousedown",this.getEvent(e))}},mounted:function(){if(this.value){var e=this;this.value.forEach((function(t,n){e.$refs["input_".concat(n)].value=t}))}}};n("084e");gt.render=dt,gt.__scopeId="data-v-0e677180";var ht=gt,pt={name:"Animate",mixins:[b["a"]],components:{ToggleSwitch:I,Slider:pe["a"],RangeSlider:ht,Loading:fe["a"]},emits:["start","stop"],props:{lights:{type:Object},group:{type:Object},loading:{type:Boolean,default:!1},colorConverter:{type:Object,default:function(){return new T["a"]}},runningAnimations:{type:Object,default:function(){}}},data:function(){return{selectedAnimation:"color_transition",animation:{},selectedLights:Object.keys(this.lights).reduce((function(e,t){return e[t]=!0,e}),{}),animations:{color_transition:{hue_range:this.colorConverter.ranges.hue,sat_range:[parseInt((this.colorConverter.ranges.sat[1]-this.colorConverter.ranges.sat[0])/2),this.colorConverter.ranges.sat[1]],bri_range:[parseInt(.75*(this.colorConverter.ranges.bri[1]-this.colorConverter.ranges.bri[0])),this.colorConverter.ranges.bri[1]],hue_step:parseInt((this.colorConverter.ranges.hue[1]-this.colorConverter.ranges.hue[0])/25),sat_step:parseInt((this.colorConverter.ranges.sat[1]-this.colorConverter.ranges.sat[0])/50),bri_step:parseInt((this.colorConverter.ranges.bri[1]-this.colorConverter.ranges.bri[0])/50),transition_seconds:1,duration:null},blink:{transition_seconds:1,duration:null}}}},computed:{animationRunning:function(){return Object.keys(this.runningAnimations).length>0}},methods:{toggleSelectAll:function(){var e=this,t=Object.values(this.selectedLights).filter((function(e){return e})).length<Object.keys(this.lights).length;Object.keys(this.lights).forEach((function(n){e.selectedLights[n]=t}))},toggleAnimation:function(){var e=this.animationRunning?"stop":"start",t=Object.entries(this.selectedLights).filter((function(e){return e[1]})).map((function(e){return e[0]}));t.length?this.$emit(e,{lights:t,animation:Object(l["a"])(Object(l["a"])({},this.animations[this.selectedAnimation]),{},{animation:this.selectedAnimation})}):this.warn("No lights have been selected")}}};n("7e57");pt.render=lt,pt.__scopeId="data-v-1739aaba";var ft=pt,Ot={name:"Group",emits:["close","group-toggle","light-toggle","set-light","select-scene","start-animation","stop-animation"],components:{Animate:ft,ToggleSwitch:I,MenuPanel:S,Light:me,Scene:Ce,Controls:je},props:{lights:{type:Object},group:{type:Object},scenes:{type:Object},animations:{type:Object,default:function(){}},colorConverter:{type:Object,default:function(){return new T["a"]}}},data:function(){return{selectedLight:null,selectedScene:null,selectedView:"lights"}},computed:{lightsSorted:function(){return this.lights?Object.entries(this.lights).sort((function(e,t){return e[1].name.localeCompare(t[1].name)})).map((function(e){var t=Object(u["a"])(e,2),n=t[0],i=t[1];return Object(l["a"])(Object(l["a"])({},i),{},{id:n})})):[]},scenesSorted:function(){return this.scenes?Object.entries(this.scenes).sort((function(e,t){return e[1].name.localeCompare(t[1].name)})).map((function(e){var t=Object(u["a"])(e,2),n=t[0],i=t[1];return Object(l["a"])(Object(l["a"])({},i),{},{id:n})})):[]},groupName:function(){var e,t;return(null===(e=this.group)||void 0===e?void 0:e.name)?this.group.name:null!=(null===(t=this.group)||void 0===t?void 0:t.id)?"[Group ".concat(this.group.id,"]"):"Lights"}},methods:{close:function(e){e.stopPropagation(),this.$emit("close")},onSceneSelected:function(e){this.selectedScene=e,this.$emit("select-scene",e)}}};n("fe49"),n("d4ec");Ot.render=Q;var jt=Ot,vt={name:"Light",components:{Group:jt,Groups:z},mixins:[b["a"],g],emits:["group-toggle","light-toggle","set-light","set-group","select-scene","start-animation","stop-animation","refresh","light-changed"],props:{lights:{type:Object},groups:{type:Object},scenes:{type:Object},animations:{type:Object},colorConverter:{type:Object,default:function(){return new T["a"]}},loadingLights:{type:Object,default:function(){}},loadingGroups:{type:Object,default:function(){}},pluginName:{type:String},initialGroup:{type:[Number,String]}},data:function(){return{selectedGroup:null,initialized:!1}},computed:{displayedLights:function(){var e=this,t=this.selectedGroup||this.initialGroup;return null==t?this.lights:this.groups[t].lights.reduce((function(t,n){return t[n]=e.lights[n],t}),{})},groupsByLight:function(){return this.groups?Object.entries(this.groups).reduce((function(e,t){var n=Object(u["a"])(t,2),i=n[0],o=n[1];return o.lights.forEach((function(t){e[t]||(e[t]={}),e[t][i]=o})),e}),{}):{}},scenesByGroup:function(){if(!this.scenes)return{};var e=this;return Object.entries(this.scenes).reduce((function(t,n){var i=Object(u["a"])(n,2),o=i[0],r=i[1];return r.lights.forEach((function(n){Object.keys(e.groupsByLight[n]).forEach((function(e){t[e]||(t[e]={}),t[e][o]=r}))})),t}),{})},animationsByGroup:function(){var e,t,n=this,i=Object.entries((null===(e=this.animations)||void 0===e?void 0:e.groups)||{}).reduce((function(e,t){var n=Object(u["a"])(t,2),i=n[0],o=n[1];return e[i]={},o&&(e[i][null]=o),e}),{});return Object(l["a"])(Object(l["a"])({},i),Object.entries((null===(t=this.animations)||void 0===t?void 0:t.lights)||{}).reduce((function(e,t){var i,o=Object(u["a"])(t,2),r=o[0],c=o[1],a=null===(i=Object.values(n.groupsByLight[r]))||void 0===i?void 0:i[0];return a&&c&&null!=a.id&&(e[a.id]||(e[a.id]={}),e[a.id][r]=c),e}),{}))}},methods:{initSelectedGroup:function(){var e=this,t=this.$watch((function(){return e.initialGroup}),(function(n){e.initialized||(e.initialized=!0,t(),null==e.selectedGroup&&null!=n&&(e.selectedGroup=e.initialGroup))}))},refresh:function(){this.$emit("refresh")},onLightChange:function(e){if(e.plugin_name===this.pluginName)if(this.lights[e.light_id]){var t=Object(l["a"])({},e),n=t.light_id;delete t.light_id,delete t.type,delete t.plugin_name,this.$emit("light-changed",{id:n,state:t})}else this.refresh()},onAnimationChange:function(e){e.plugin_name===this.pluginName&&this.refresh()}},mounted:function(){this.subscribe(this.onLightChange,"on-light-change","platypush.message.event.light.LightStatusChangeEvent"),this.subscribe(this.onAnimationChange,"on-animation-change","platypush.message.event.light.LightAnimationStartedEvent","platypush.message.event.light.LightAnimationStoppedEvent"),this.initSelectedGroup()},unmounted:function(){this.unsubscribe("on-light-change"),this.unsubscribe("on-animation-change")}};n("b347"),n("9840");vt.render=s,vt.__scopeId="data-v-0378547e";t["default"]=vt},d28c:function(e,t,n){},d4ec:function(e,t,n){"use strict";n("1ed6")},dbb4:function(e,t,n){var i=n("23e7"),o=n("83ab"),r=n("56ef"),c=n("fc6a"),a=n("06cf"),s=n("8418");i({target:"Object",stat:!0,sham:!o},{getOwnPropertyDescriptors:function(e){var t,n,i=c(e),o=a.f,l=r(i),u={},b=0;while(l.length>b)n=o(i,t=l[b++]),void 0!==n&&s(u,t,n);return u}})},e239:function(e,t,n){"use strict";n("fb61")},e3f0:function(e,t,n){},e439:function(e,t,n){var i=n("23e7"),o=n("d039"),r=n("fc6a"),c=n("06cf").f,a=n("83ab"),s=o((function(){c(1)})),l=!a||s;i({target:"Object",stat:!0,forced:l,sham:!a},{getOwnPropertyDescriptor:function(e,t){return c(r(e),t)}})},fb61:function(e,t,n){},fda1:function(e,t,n){},fe49:function(e,t,n){"use strict";n("520c")}}]);
//# sourceMappingURL=chunk-3d60f62e.907e4050.js.map