iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
295 lines (280 loc) • 37.7 kB
JavaScript
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[6016],{31811:(e,t,r)=>{"use strict";var i=r(15652),o=r(41181),s=r(29821);function n(){n=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(i){t.forEach((function(t){var o=t.placement;if(t.kind===i&&("static"===o||"prototype"===o)){var s="static"===o?e:r;this.defineClassElement(s,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var i=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===i?void 0:i.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],i=[],o={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,o)}),this),e.forEach((function(e){if(!c(e))return r.push(e);var t=this.decorateElement(e,o);r.push(t.element),r.push.apply(r,t.extras),i.push.apply(i,t.finishers)}),this),!t)return{elements:r,finishers:i};var s=this.decorateConstructor(r,t);return i.push.apply(i,s.finishers),s.finishers=i,s},addElementPlacement:function(e,t,r){var i=t[e.placement];if(!r&&-1!==i.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");i.push(e.key)},decorateElement:function(e,t){for(var r=[],i=[],o=e.decorators,s=o.length-1;s>=0;s--){var n=t[e.placement];n.splice(n.indexOf(e.key),1);var a=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,o[s])(a)||a);e=l.element,this.addElementPlacement(e,t),l.finisher&&i.push(l.finisher);var c=l.extras;if(c){for(var d=0;d<c.length;d++)this.addElementPlacement(c[d],t);r.push.apply(r,c)}}return{element:e,finishers:i,extras:r}},decorateConstructor:function(e,t){for(var r=[],i=t.length-1;i>=0;i--){var o=this.fromClassDescriptor(e),s=this.toClassDescriptor((0,t[i])(o)||o);if(void 0!==s.finisher&&r.push(s.finisher),void 0!==s.elements){e=s.elements;for(var n=0;n<e.length-1;n++)for(var a=n+1;a<e.length;a++)if(e[n].key===e[a].key&&e[n].placement===e[a].placement)throw new TypeError("Duplicated element ("+e[n].key+")")}}return{elements:e,finishers:r}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return p(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var r=u(e.key),i=String(e.placement);if("static"!==i&&"prototype"!==i&&"own"!==i)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+i+'"');var o=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var s={kind:t,key:r,placement:i,descriptor:Object.assign({},o)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(o,"get","The property descriptor of a field descriptor"),this.disallowProperty(o,"set","The property descriptor of a field descriptor"),this.disallowProperty(o,"value","The property descriptor of a field descriptor"),s.initializer=e.initializer),s},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:h(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var r=h(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var i=(0,t[r])(e);if(void 0!==i){if("function"!=typeof i)throw new TypeError("Finishers must return a constructor.");e=i}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function a(e){var t,r=u(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var i={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(i.decorators=e.decorators),"field"===e.kind&&(i.initializer=e.value),i}function l(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function c(e){return e.decorators&&e.decorators.length}function d(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function h(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function u(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function p(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}let m;!function(e,t,r,i){var o=n();if(i)for(var s=0;s<i.length;s++)o=i[s](o);var h=t((function(e){o.initializeInstanceElements(e,u.elements)}),r),u=o.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===s.key&&e.placement===s.placement},i=0;i<e.length;i++){var o,s=e[i];if("method"===s.kind&&(o=t.find(r)))if(d(s.descriptor)||d(o.descriptor)){if(c(s)||c(o))throw new ReferenceError("Duplicated methods ("+s.key+") can't be decorated.");o.descriptor=s.descriptor}else{if(c(s)){if(c(o))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+s.key+").");o.decorators=s.decorators}l(s,o)}else t.push(s)}return t}(h.d.map(a)),e);o.initializeClassElements(h.F,u.elements),o.runClassFinishers(h.F,u.finishers)}([(0,i.Mo)("ha-attributes")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,i.Cb)()],key:"stateObj",value:void 0},{kind:"field",decorators:[(0,i.Cb)({attribute:"extra-filters"})],key:"extraFilters",value:void 0},{kind:"method",key:"render",value:function(){return this.stateObj?i.dy`
<div>
${this.computeDisplayAttributes(Object.keys(s.Z.LOGIC_STATE_ATTRIBUTES).concat(this.extraFilters?this.extraFilters.split(","):[])).map((e=>i.dy`
<div class="data-entry">
<div class="key">
${e.replace(/_/g," ").replace(/\bid\b/g,"ID")}
</div>
<div class="value">
${this.formatAttribute(e)}
</div>
</div>
`))}
${this.stateObj.attributes.attribution?i.dy`
<div class="attribution">
${this.stateObj.attributes.attribution}
</div>
`:""}
</div>
`:i.dy``}},{kind:"get",static:!0,key:"styles",value:function(){return i.iv`
.data-entry {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.data-entry .value {
max-width: 200px;
overflow-wrap: break-word;
}
.key:first-letter {
text-transform: capitalize;
}
.attribution {
color: var(--secondary-text-color);
text-align: right;
}
pre {
font-family: inherit;
font-size: inherit;
}
`}},{kind:"method",key:"computeDisplayAttributes",value:function(e){return this.stateObj?Object.keys(this.stateObj.attributes).filter((t=>-1===e.indexOf(t))):[]}},{kind:"method",key:"formatAttribute",value:function(e){if(!this.stateObj)return"-";const t=this.stateObj.attributes[e];return this.formatAttributeValue(t)}},{kind:"method",key:"formatAttributeValue",value:function(e){if(null===e)return"-";if(Array.isArray(e)&&e.some((e=>e instanceof Object))||!Array.isArray(e)&&e instanceof Object){m||(m=Promise.all([r.e(9033),r.e(1572)]).then(r.t.bind(r,50947,7)));const t=m.then((t=>t.safeDump(e)));return i.dy` <pre>${(0,o.C)(t,"")}</pre> `}return Array.isArray(e)?e.join(", "):e}}]}}),i.oi)},73139:(e,t,r)=>{"use strict";var i=r(50856),o=r(28426);r(16509),r(46998);class s extends o.H3{static get template(){return i.d`
<style>
:host {
display: block;
border-radius: 4px;
}
.title {
margin-bottom: 8px;
color: var(--primary-text-color);
}
.slider-container {
display: flex;
}
ha-icon {
margin-top: 4px;
color: var(--secondary-text-color);
}
ha-slider {
flex-grow: 1;
background-image: var(--ha-slider-background);
}
</style>
<div class="title">[[caption]]</div>
<div class="extra-container"><slot name="extra"></slot></div>
<div class="slider-container">
<ha-icon icon="[[icon]]" hidden$="[[!icon]]"></ha-icon>
<ha-slider
min="[[min]]"
max="[[max]]"
step="[[step]]"
pin="[[pin]]"
disabled="[[disabled]]"
value="{{value}}"
></ha-slider>
</div>
`}static get properties(){return{caption:String,disabled:Boolean,min:Number,max:Number,pin:Boolean,step:Number,extra:{type:Boolean,value:!1},ignoreBarTouch:{type:Boolean,value:!0},icon:{type:String,value:""},value:{type:Number,notify:!0}}}}customElements.define("ha-labeled-slider",s)},81303:(e,t,r)=>{"use strict";r(8878);const i=customElements.get("paper-dropdown-menu");customElements.define("ha-paper-dropdown-menu",class extends i{ready(){super.ready(),setTimeout((()=>{"rtl"===window.getComputedStyle(this).direction&&(this.style.textAlign="right")}),100)}})},21668:(e,t,r)=>{"use strict";r.d(t,{LU:()=>i,un:()=>o,rs:()=>s,nm:()=>n,zT:()=>a});const i=1,o=2,s=4,n=16,a=128},36016:(e,t,r)=>{"use strict";r.r(t);r(53973),r(51095);var i=r(15652),o=r(81471),s=r(40095),n=(r(31811),r(50856)),a=r(28426),l=r(11052);class c extends((0,l.I)(a.H3)){static get template(){return n.d`
<style>
:host {
user-select: none;
-webkit-user-select: none;
}
#canvas {
position: relative;
width: 100%;
max-width: 330px;
}
#canvas > * {
display: block;
}
#interactionLayer {
color: white;
position: absolute;
cursor: crosshair;
width: 100%;
height: 100%;
overflow: visible;
}
#backgroundLayer {
width: 100%;
overflow: visible;
--wheel-bordercolor: var(--ha-color-picker-wheel-bordercolor, white);
--wheel-borderwidth: var(--ha-color-picker-wheel-borderwidth, 3);
--wheel-shadow: var(
--ha-color-picker-wheel-shadow,
rgb(15, 15, 15) 10px 5px 5px 0px
);
}
#marker {
fill: currentColor;
stroke: var(--ha-color-picker-marker-bordercolor, white);
stroke-width: var(--ha-color-picker-marker-borderwidth, 3);
filter: url(#marker-shadow);
}
.dragging #marker {
}
#colorTooltip {
display: none;
fill: currentColor;
stroke: var(--ha-color-picker-tooltip-bordercolor, white);
stroke-width: var(--ha-color-picker-tooltip-borderwidth, 3);
}
.touch.dragging #colorTooltip {
display: inherit;
}
</style>
<div id="canvas">
<svg id="interactionLayer">
<defs>
<filter
id="marker-shadow"
x="-50%"
y="-50%"
width="200%"
height="200%"
filterUnits="objectBoundingBox"
>
<feOffset
result="offOut"
in="SourceAlpha"
dx="2"
dy="2"
></feOffset>
<feGaussianBlur
result="blurOut"
in="offOut"
stdDeviation="2"
></feGaussianBlur>
<feComponentTransfer in="blurOut" result="alphaOut">
<feFuncA type="linear" slope="0.3"></feFuncA>
</feComponentTransfer>
<feBlend
in="SourceGraphic"
in2="alphaOut"
mode="normal"
></feBlend>
</filter>
</defs>
</svg>
<canvas id="backgroundLayer"></canvas>
</div>
`}static get properties(){return{hsColor:{type:Object},desiredHsColor:{type:Object,observer:"applyHsColor"},width:{type:Number,value:500},height:{type:Number,value:500},radius:{type:Number,value:225},hueSegments:{type:Number,value:0,observer:"segmentationChange"},saturationSegments:{type:Number,value:0,observer:"segmentationChange"},ignoreSegments:{type:Boolean,value:!1},throttle:{type:Number,value:500}}}ready(){super.ready(),this.setupLayers(),this.drawColorWheel(),this.drawMarker(),this.desiredHsColor&&(this.setMarkerOnColor(this.desiredHsColor),this.applyColorToCanvas(this.desiredHsColor)),this.interactionLayer.addEventListener("mousedown",(e=>this.onMouseDown(e))),this.interactionLayer.addEventListener("touchstart",(e=>this.onTouchStart(e)))}convertToCanvasCoordinates(e,t){const r=this.interactionLayer.createSVGPoint();r.x=e,r.y=t;const i=r.matrixTransform(this.interactionLayer.getScreenCTM().inverse());return{x:i.x,y:i.y}}onMouseDown(e){const t=this.convertToCanvasCoordinates(e.clientX,e.clientY);this.isInWheel(t.x,t.y)&&(this.onMouseSelect(e),this.canvas.classList.add("mouse","dragging"),this.addEventListener("mousemove",this.onMouseSelect),this.addEventListener("mouseup",this.onMouseUp))}onMouseUp(){this.canvas.classList.remove("mouse","dragging"),this.removeEventListener("mousemove",this.onMouseSelect)}onMouseSelect(e){requestAnimationFrame((()=>this.processUserSelect(e)))}onTouchStart(e){const t=e.changedTouches[0],r=this.convertToCanvasCoordinates(t.clientX,t.clientY);if(this.isInWheel(r.x,r.y)){if(e.target===this.marker)return e.preventDefault(),this.canvas.classList.add("touch","dragging"),this.addEventListener("touchmove",this.onTouchSelect),void this.addEventListener("touchend",this.onTouchEnd);this.tapBecameScroll=!1,this.addEventListener("touchend",this.onTap),this.addEventListener("touchmove",(()=>{this.tapBecameScroll=!0}),{passive:!0})}}onTap(e){this.tapBecameScroll||(e.preventDefault(),this.onTouchSelect(e))}onTouchEnd(){this.canvas.classList.remove("touch","dragging"),this.removeEventListener("touchmove",this.onTouchSelect)}onTouchSelect(e){requestAnimationFrame((()=>this.processUserSelect(e.changedTouches[0])))}processUserSelect(e){const t=this.convertToCanvasCoordinates(e.clientX,e.clientY),r=this.getColor(t.x,t.y);this.onColorSelect(r)}onColorSelect(e){if(this.setMarkerOnColor(e),this.ignoreSegments||(e=this.applySegmentFilter(e)),this.applyColorToCanvas(e),this.colorSelectIsThrottled)return clearTimeout(this.ensureFinalSelect),void(this.ensureFinalSelect=setTimeout((()=>{this.fireColorSelected(e)}),this.throttle));this.fireColorSelected(e),this.colorSelectIsThrottled=!0,setTimeout((()=>{this.colorSelectIsThrottled=!1}),this.throttle)}fireColorSelected(e){this.hsColor=e,this.fire("colorselected",{hs:{h:e.h,s:e.s}})}setMarkerOnColor(e){if(!this.marker||!this.tooltip)return;const t=e.s*this.radius,r=(e.h-180)/180*Math.PI,i=`translate(${-t*Math.cos(r)},${-t*Math.sin(r)})`;this.marker.setAttribute("transform",i),this.tooltip.setAttribute("transform",i)}applyColorToCanvas(e){this.interactionLayer&&(this.interactionLayer.style.color=`hsl(${e.h}, 100%, ${100-50*e.s}%)`)}applyHsColor(e){this.hsColor&&this.hsColor.h===e.h&&this.hsColor.s===e.s||(this.setMarkerOnColor(e),this.ignoreSegments||(e=this.applySegmentFilter(e)),this.hsColor=e,this.applyColorToCanvas(e))}getAngle(e,t){return Math.atan2(-t,-e)/Math.PI*180+180}isInWheel(e,t){return this.getDistance(e,t)<=1}getDistance(e,t){return Math.sqrt(e*e+t*t)/this.radius}getColor(e,t){const r=this.getAngle(e,t),i=this.getDistance(e,t);return{h:r,s:Math.min(i,1)}}applySegmentFilter(e){if(this.hueSegments){const t=360/this.hueSegments,r=t/2;e.h-=r,e.h<0&&(e.h+=360);const i=e.h%t;e.h-=i-t}if(this.saturationSegments)if(1===this.saturationSegments)e.s=1;else{const t=1/this.saturationSegments,r=1/(this.saturationSegments-1),i=Math.floor(e.s/t)*r;e.s=Math.min(i,1)}return e}setupLayers(){this.canvas=this.$.canvas,this.backgroundLayer=this.$.backgroundLayer,this.interactionLayer=this.$.interactionLayer,this.originX=this.width/2,this.originY=this.originX,this.backgroundLayer.width=this.width,this.backgroundLayer.height=this.height,this.interactionLayer.setAttribute("viewBox",`${-this.originX} ${-this.originY} ${this.width} ${this.height}`)}drawColorWheel(){let e,t,r,i;const o=this.backgroundLayer.getContext("2d"),s=this.originX,n=this.originY,a=this.radius,l=window.getComputedStyle(this.backgroundLayer,null),c=parseInt(l.getPropertyValue("--wheel-borderwidth"),10),d=l.getPropertyValue("--wheel-bordercolor").trim(),h=l.getPropertyValue("--wheel-shadow").trim();if("none"!==h){const o=h.split("px ");e=o.pop(),t=parseInt(o[0],10),r=parseInt(o[1],10),i=parseInt(o[2],10)||0}const u=a+c/2,p=a,m=a+c;"none"!==l.shadow&&(o.save(),o.beginPath(),o.arc(s,n,m,0,2*Math.PI,!1),o.shadowColor=e,o.shadowOffsetX=t,o.shadowOffsetY=r,o.shadowBlur=i,o.fillStyle="white",o.fill(),o.restore()),function(e,t){const r=360/(e=e||360),i=r/2;for(let a=0;a<=360;a+=r){const e=(a-i)*(Math.PI/180),r=(a+i+1)*(Math.PI/180);o.beginPath(),o.moveTo(s,n),o.arc(s,n,p,e,r,false),o.closePath();const l=o.createRadialGradient(s,n,0,s,n,p);let c=100;if(l.addColorStop(0,`hsl(${a}, 100%, ${c}%)`),t>0){const e=1/t;let r=0;for(let i=1;i<t;i+=1){const t=c;r=i*e,c=100-50*r,l.addColorStop(r,`hsl(${a}, 100%, ${t}%)`),l.addColorStop(r,`hsl(${a}, 100%, ${c}%)`)}l.addColorStop(r,`hsl(${a}, 100%, 50%)`)}l.addColorStop(1,`hsl(${a}, 100%, 50%)`),o.fillStyle=l,o.fill()}}(this.hueSegments,this.saturationSegments),c>0&&(o.beginPath(),o.arc(s,n,u,0,2*Math.PI,!1),o.lineWidth=c,o.strokeStyle=d,o.stroke())}drawMarker(){const e=this.interactionLayer,t=.08*this.radius,r=.15*this.radius,i=-3*r;e.marker=document.createElementNS("http://www.w3.org/2000/svg","circle"),e.marker.setAttribute("id","marker"),e.marker.setAttribute("r",t),this.marker=e.marker,e.appendChild(e.marker),e.tooltip=document.createElementNS("http://www.w3.org/2000/svg","circle"),e.tooltip.setAttribute("id","colorTooltip"),e.tooltip.setAttribute("r",r),e.tooltip.setAttribute("cx",0),e.tooltip.setAttribute("cy",i),this.tooltip=e.tooltip,e.appendChild(e.tooltip)}segmentationChange(){this.backgroundLayer&&this.drawColorWheel()}}customElements.define("ha-color-picker",c);r(10983),r(73139),r(81303);var d=r(21668);function h(){h=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(i){t.forEach((function(t){var o=t.placement;if(t.kind===i&&("static"===o||"prototype"===o)){var s="static"===o?e:r;this.defineClassElement(s,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var i=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===i?void 0:i.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],i=[],o={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,o)}),this),e.forEach((function(e){if(!m(e))return r.push(e);var t=this.decorateElement(e,o);r.push(t.element),r.push.apply(r,t.extras),i.push.apply(i,t.finishers)}),this),!t)return{elements:r,finishers:i};var s=this.decorateConstructor(r,t);return i.push.apply(i,s.finishers),s.finishers=i,s},addElementPlacement:function(e,t,r){var i=t[e.placement];if(!r&&-1!==i.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");i.push(e.key)},decorateElement:function(e,t){for(var r=[],i=[],o=e.decorators,s=o.length-1;s>=0;s--){var n=t[e.placement];n.splice(n.indexOf(e.key),1);var a=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,o[s])(a)||a);e=l.element,this.addElementPlacement(e,t),l.finisher&&i.push(l.finisher);var c=l.extras;if(c){for(var d=0;d<c.length;d++)this.addElementPlacement(c[d],t);r.push.apply(r,c)}}return{element:e,finishers:i,extras:r}},decorateConstructor:function(e,t){for(var r=[],i=t.length-1;i>=0;i--){var o=this.fromClassDescriptor(e),s=this.toClassDescriptor((0,t[i])(o)||o);if(void 0!==s.finisher&&r.push(s.finisher),void 0!==s.elements){e=s.elements;for(var n=0;n<e.length-1;n++)for(var a=n+1;a<e.length;a++)if(e[n].key===e[a].key&&e[n].placement===e[a].placement)throw new TypeError("Duplicated element ("+e[n].key+")")}}return{elements:e,finishers:r}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(t)||function(e,t){if(e){if("string"==typeof e)return b(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,t):void 0}}(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var r=v(e.key),i=String(e.placement);if("static"!==i&&"prototype"!==i&&"own"!==i)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+i+'"');var o=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var s={kind:t,key:r,placement:i,descriptor:Object.assign({},o)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(o,"get","The property descriptor of a field descriptor"),this.disallowProperty(o,"set","The property descriptor of a field descriptor"),this.disallowProperty(o,"value","The property descriptor of a field descriptor"),s.initializer=e.initializer),s},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:y(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var r=y(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var i=(0,t[r])(e);if(void 0!==i){if("function"!=typeof i)throw new TypeError("Finishers must return a constructor.");e=i}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function u(e){var t,r=v(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var i={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(i.decorators=e.decorators),"field"===e.kind&&(i.initializer=e.value),i}function p(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function m(e){return e.decorators&&e.decorators.length}function f(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function y(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function v(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}!function(e,t,r,i){var o=h();if(i)for(var s=0;s<i.length;s++)o=i[s](o);var n=t((function(e){o.initializeInstanceElements(e,a.elements)}),r),a=o.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===s.key&&e.placement===s.placement},i=0;i<e.length;i++){var o,s=e[i];if("method"===s.kind&&(o=t.find(r)))if(f(s.descriptor)||f(o.descriptor)){if(m(s)||m(o))throw new ReferenceError("Duplicated methods ("+s.key+") can't be decorated.");o.descriptor=s.descriptor}else{if(m(s)){if(m(o))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+s.key+").");o.decorators=s.decorators}p(s,o)}else t.push(s)}return t}(n.d.map(u)),e);o.initializeClassElements(n.F,a.elements),o.runClassFinishers(n.F,a.finishers)}([(0,i.Mo)("more-info-light")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,i.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,i.Cb)({attribute:!1})],key:"stateObj",value:void 0},{kind:"field",decorators:[(0,i.sz)()],key:"_brightnessSliderValue",value:()=>0},{kind:"field",decorators:[(0,i.sz)()],key:"_ctSliderValue",value:()=>0},{kind:"field",decorators:[(0,i.sz)()],key:"_wvSliderValue",value:()=>0},{kind:"field",decorators:[(0,i.sz)()],key:"_hueSegments",value:()=>24},{kind:"field",decorators:[(0,i.sz)()],key:"_saturationSegments",value:()=>8},{kind:"field",decorators:[(0,i.sz)()],key:"_colorPickerColor",value:void 0},{kind:"method",key:"render",value:function(){var e;return this.hass&&this.stateObj?i.dy`
<div
class="content ${(0,o.$)({"is-on":"on"===this.stateObj.state})}"
>
${(0,s.e)(this.stateObj,d.LU)?i.dy`
<ha-labeled-slider
caption=${this.hass.localize("ui.card.light.brightness")}
icon="hass:brightness-5"
min="1"
max="100"
value=${this._brightnessSliderValue}
=${this._brightnessSliderChanged}
pin
></ha-labeled-slider>
`:""}
${"on"===this.stateObj.state?i.dy`
${(0,s.e)(this.stateObj,d.un)?i.dy`
<ha-labeled-slider
class="color_temp"
caption=${this.hass.localize("ui.card.light.color_temperature")}
icon="hass:thermometer"
.min=${this.stateObj.attributes.min_mireds}
.max=${this.stateObj.attributes.max_mireds}
.value=${this._ctSliderValue}
=${this._ctSliderChanged}
pin
></ha-labeled-slider>
`:""}
${(0,s.e)(this.stateObj,d.zT)?i.dy`
<ha-labeled-slider
caption=${this.hass.localize("ui.card.light.white_value")}
icon="hass:file-word-box"
max="255"
.value=${this._wvSliderValue}
=${this._wvSliderChanged}
pin
></ha-labeled-slider>
`:""}
${(0,s.e)(this.stateObj,d.nm)?i.dy`
<div class="segmentationContainer">
<ha-color-picker
class="color"
=${this._colorPicked}
.desiredHsColor=${this._colorPickerColor}
throttle="500"
.hueSegments=${this._hueSegments}
.saturationSegments=${this._saturationSegments}
>
</ha-color-picker>
<ha-icon-button
icon="hass:palette"
=${this._segmentClick}
class="segmentationButton"
></ha-icon-button>
</div>
`:""}
${(0,s.e)(this.stateObj,d.rs)&&(null===(e=this.stateObj.attributes.effect_list)||void 0===e?void 0:e.length)?i.dy`
<ha-paper-dropdown-menu
.label=${this.hass.localize("ui.card.light.effect")}
>
<paper-listbox
slot="dropdown-content"
.selected=${this.stateObj.attributes.effect||""}
-select=${this._effectChanged}
attr-for-selected="item-name"
>${this.stateObj.attributes.effect_list.map((e=>i.dy`
<paper-item .itemName=${e}
>${e}</paper-item
>
`))}
</paper-listbox>
</ha-paper-dropdown-menu>
`:""}
`:""}
<ha-attributes
.stateObj=${this.stateObj}
extra-filters="brightness,color_temp,white_value,effect_list,effect,hs_color,rgb_color,xy_color,min_mireds,max_mireds,entity_id"
></ha-attributes>
</div>
`:i.dy``}},{kind:"method",key:"updated",value:function(e){const t=this.stateObj;e.has("stateObj")&&("on"===t.state?(this._brightnessSliderValue=Math.round(100*t.attributes.brightness/255),this._ctSliderValue=t.attributes.color_temp,this._wvSliderValue=t.attributes.white_value,t.attributes.hs_color&&(this._colorPickerColor={h:t.attributes.hs_color[0],s:t.attributes.hs_color[1]/100})):this._brightnessSliderValue=0)}},{kind:"method",key:"_effectChanged",value:function(e){const t=e.detail.item.itemName;t&&this.stateObj.attributes.effect!==t&&this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,effect:t})}},{kind:"method",key:"_brightnessSliderChanged",value:function(e){const t=parseInt(e.target.value,10);isNaN(t)||this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,brightness_pct:t})}},{kind:"method",key:"_ctSliderChanged",value:function(e){const t=parseInt(e.target.value,10);isNaN(t)||this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,color_temp:t})}},{kind:"method",key:"_wvSliderChanged",value:function(e){const t=parseInt(e.target.value,10);isNaN(t)||this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,white_value:t})}},{kind:"method",key:"_segmentClick",value:function(){24===this._hueSegments&&8===this._saturationSegments?(this._hueSegments=0,this._saturationSegments=0):(this._hueSegments=24,this._saturationSegments=8)}},{kind:"method",key:"_colorPicked",value:function(e){this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,hs_color:[e.detail.hs.h,100*e.detail.hs.s]})}},{kind:"get",static:!0,key:"styles",value:function(){return i.iv`
.content {
display: flex;
flex-direction: column;
align-items: center;
}
.content > * {
width: 100%;
max-height: 84px;
overflow: hidden;
}
.color_temp {
--ha-slider-background: -webkit-linear-gradient(
right,
rgb(255, 160, 0) 0%,
white 50%,
rgb(166, 209, 255) 100%
);
/* The color temp minimum value shouldn't be rendered differently. It's not "off". */
--paper-slider-knob-start-border-color: var(--primary-color);
}
.segmentationContainer {
position: relative;
max-height: 500px;
}
ha-color-picker {
--ha-color-picker-wheel-borderwidth: 5;
--ha-color-picker-wheel-bordercolor: white;
--ha-color-picker-wheel-shadow: none;
--ha-color-picker-marker-borderwidth: 2;
--ha-color-picker-marker-bordercolor: white;
}
.segmentationButton {
position: absolute;
top: 5%;
color: var(--secondary-text-color);
}
paper-item {
cursor: pointer;
}
`}}]}}),i.oi)},11052:(e,t,r)=>{"use strict";r.d(t,{I:()=>s});var i=r(76389),o=r(47181);const s=(0,i.o)((e=>class extends e{fire(e,t,r){return r=r||{},(0,o.B)(r.node||this,e,t,r)}}))},29821:(e,t,r)=>{"use strict";r.d(t,{Z:()=>o});const i={DOMAIN_DEVICE_CLASS:{binary_sensor:["battery","cold","connectivity","door","garage_door","gas","heat","light","lock","moisture","motion","moving","occupancy","opening","plug","power","presence","problem","safety","smoke","sound","vibration","window"],cover:["awning","blind","curtain","damper","door","garage","shade","shutter","window"],humidifier:["dehumidifier","humidifier"],sensor:["battery","humidity","illuminance","temperature","pressure","power","signal_strength","timestamp"],switch:["switch","outlet"]},UNKNOWN_TYPE:"json",ADD_TYPE:"key-value",TYPE_TO_TAG:{string:"ha-customize-string",json:"ha-customize-string",icon:"ha-customize-icon",boolean:"ha-customize-boolean",array:"ha-customize-array","key-value":"ha-customize-key-value"}};i.LOGIC_STATE_ATTRIBUTES=i.LOGIC_STATE_ATTRIBUTES||{entity_picture:void 0,friendly_name:{type:"string",description:"Name"},icon:{type:"icon"},emulated_hue:{type:"boolean",domains:["emulated_hue"]},emulated_hue_name:{type:"string",domains:["emulated_hue"]},haaska_hidden:void 0,haaska_name:void 0,supported_features:void 0,attribution:void 0,restored:void 0,custom_ui_more_info:{type:"string"},custom_ui_state_card:{type:"string"},device_class:{type:"array",options:i.DOMAIN_DEVICE_CLASS,description:"Device class",domains:["binary_sensor","cover","humidifier","sensor","switch"]},assumed_state:{type:"boolean",domains:["switch","light","cover","climate","fan","humidifier","group","water_heater"]},initial_state:{type:"string",domains:["automation"]},unit_of_measurement:{type:"string"}};const o=i}}]);
//# sourceMappingURL=chunk.7da676d085ae4a893e23.js.map