UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

1 lines 28.5 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[19260],{44439:function(t,e,i){i.a(t,async function(t,e){try{var o=i(86518),s=(i(49255),i(74423),i(44114),i(72712),i(18111),i(81148),i(22489),i(20116),i(7588),i(61701),i(18237),i(13579),i(3362),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(62953),i(40445)),a=i(88696),n=i(35211),r=i(6116),l=i(5124),d=i(67576),h=i(6412),c=i(89784),p=i(44537),u=i(90433),g=i(32172),v=i(1087),m=i(71769),y=i(12587),_=i(22792),x=i(41570),f=(i(34296),i(26300)),b=i(29961),w=i(34218),C=i(57243),k=t([f,a,b]);[f,a,b]=k.then?(await k)():k;let P,L,A,D,T,Z,O,S=t=>t;const z=["formatter"],M="M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M10 17L5 12L6.41 10.59L10 14.17L17.59 6.58L19 8L10 17Z",V="M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z",$="M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z",j="M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z",F="M12,4C14.1,4 16.1,4.8 17.6,6.3C20.7,9.4 20.7,14.5 17.6,17.6C15.8,19.5 13.3,20.2 10.9,19.9L11.4,17.9C13.1,18.1 14.9,17.5 16.2,16.2C18.5,13.9 18.5,10.1 16.2,7.7C15.1,6.6 13.5,6 12,6V10.6L7,5.6L12,0.6V4M6.3,17.6C3.7,15 3.3,11 5.1,7.9L6.6,9.4C5.5,11.6 5.9,14.4 7.8,16.2C8.3,16.7 8.9,17.1 9.6,17.4L9,19.4C8,19 7.1,18.4 6.3,17.6Z",R=10,I=6,E=300,B=t=>t,W=t=>{const{formatter:e}=t,i=(0,o.A)(t,z),s=Object.assign({},i);return"function"==typeof e?s.formatter=B((0,C.V)(e)):void 0!==e&&(s.formatter=e),s},H=t=>t.tooltip&&"function"==typeof t.tooltip.formatter?Object.assign(Object.assign({},t),{},{tooltip:W(t.tooltip)}):t;class q extends l.WF{disconnectedCallback(){var t;for(super.disconnectedCallback(),this._legendPointerCancel(),this._pendingSetup=!1;this._listeners.length;)this._listeners.pop()();null===(t=this.chart)||void 0===t||t.dispose(),this.chart=void 0,this._originalZrFlush=void 0}connectedCallback(){var t;if(super.connectedCallback(),this.hasUpdated&&(this._pendingSetup=!0,(0,y.m)(()=>{this.isConnected&&this._pendingSetup&&(this._pendingSetup=!1,this._setupChart())})),this._listeners.push((0,m.m)("(prefers-reduced-motion)",t=>{this._reducedMotion!==t&&(this._reducedMotion=t,this._setChartOptions({animation:!this._reducedMotion}))})),null===(t=this.options)||void 0===t||!t.dataZoom){const t=t=>{var e,i;!this._modifierPressed&&(x.c&&"Meta"===t.key||!x.c&&"Control"===t.key)&&(this._modifierPressed=!0,null!==(e=this.options)&&void 0!==e&&e.dataZoom||this._setChartOptions({dataZoom:this._getDataZoomConfig()}),this._updateSankeyRoam(),null===(i=this.chart)||void 0===i||i.dispatchAction({type:"takeGlobalCursor",key:"dataZoomSelect",dataZoomSelectActive:!0}))},e=t=>{var e,i;this._modifierPressed&&(x.c&&"Meta"===t.key||!x.c&&"Control"===t.key)&&(this._modifierPressed=!1,null!==(e=this.options)&&void 0!==e&&e.dataZoom||this._setChartOptions({dataZoom:this._getDataZoomConfig()}),this._updateSankeyRoam(),null===(i=this.chart)||void 0===i||i.dispatchAction({type:"takeGlobalCursor",key:"dataZoomSelect",dataZoomSelectActive:!1}))};window.addEventListener("keydown",t),window.addEventListener("keyup",e),this._listeners.push(()=>window.removeEventListener("keydown",t),()=>window.removeEventListener("keyup",e))}const e=t=>{var e;const i=t;this._layoutTransitionActive=Boolean(null===(e=i.detail)||void 0===e?void 0:e.active),this.toggleAttribute("layout-transition-active",this._layoutTransitionActive),this._suspendResize=this._layoutTransitionActive,this._suspendResize||this._resizeChartIfNeeded()};window.addEventListener("hass-layout-transition",e),this._listeners.push(()=>window.removeEventListener("hass-layout-transition",e))}firstUpdated(){this.isConnected&&this._setupChart()}willUpdate(t){if(!this.chart)return;if(t.has("_themes")&&this.hasUpdated)return void this._setupChart();let e={};t.has("options")&&this._updateHiddenStatsFromOptions(this.options),(t.has("data")||t.has("_hiddenDatasets"))&&(e.series=this._getSeries()),t.has("options")?(e=Object.assign(Object.assign({},e),this._createOptions()),this._compareCustomLegendOptions(t.get("options"),this.options)&&(this._shouldResizeChart=!0,this._resizeAnimationDuration=250)):this._isTouchDevice&&t.has("_isZoomed")&&(e.dataZoom=this._getDataZoomConfig()),Object.keys(e).length>0&&(this._setChartOptions(e),e.series&&this._updateSankeyRoam())}render(){return(0,l.qy)(P||(P=S` <div class="container ${0}" style="${0}"> <div class="chart-container" style="${0}"> <div class="chart"></div> </div> ${0} <div class="top-controls ${0}"> <slot name="search"></slot> <div class="chart-controls ${0}"> ${0} <slot name="button"></slot> </div> </div> </div> `),(0,h.H)({"has-height":!!this.height}),(0,c.W)({height:this.height}),(0,c.W)({height:this.height?void 0:`${this._getDefaultHeight()}px`}),this._renderLegend(),(0,h.H)({small:this.smallControls}),(0,h.H)({small:this.smallControls}),this._isZoomed&&!this.hideResetButton?(0,l.qy)(L||(L=S`<ha-icon-button class="zoom-reset" .path="${0}" @click="${0}" title="${0}"></ha-icon-button>`),F,this._handleZoomReset,this.hass.localize("ui.components.history_charts.zoom_reset")):l.s6)}_getLegendItems(){var t;if(null===(t=this.options)||void 0===t||!t.legend||!this.data)return;const e=(0,p.e)(this.options.legend).find(t=>t.show&&"custom"===t.type);if(!e)return;const i=(0,p.e)(this.data);return e.data||i.filter(t=>{var e;return(null===(e=t.data)||void 0===e?void 0:e.length)&&(t.id||t.name)}).map(t=>({id:t.id,name:t.name}))}_renderLegend(){const t=this._getLegendItems();if(!t)return l.s6;const e=(0,p.e)(this.data),i=window.matchMedia("all and (max-width: 450px), all and (max-height: 500px)").matches?I:R;return(0,l.qy)(A||(A=S`<div class="${0}"> <ul> ${0} ${0} </ul> </div>`),(0,h.H)({"chart-legend":!0,"multiple-items":t.length>1}),t.map((t,o)=>{var s,a,n;if(!this.expandLegend&&o>=i)return l.s6;let r={},d="",p="",u=!1;const g="string"==typeof t?t:null!==(s=t.name)&&void 0!==s?s:"";var v,m,y,_;"string"==typeof t?d=t:(d=null!==(v=t.id)&&void 0!==v?v:g,p=null!==(m=t.value)&&void 0!==m?m:"",r=null!==(y=t.itemStyle)&&void 0!==y?y:{},u=null!==(_=t.noLabelClick)&&void 0!==_&&_);const x=this.clickLabelForMoreInfo&&!u,f=null!==(a=e.find(t=>t.id===d))&&void 0!==a?a:e.find(t=>t.name===d);r=Object.assign(Object.assign({color:null==f?void 0:f.color},null==f?void 0:f.itemStyle),r);const b=null===(n=r)||void 0===n?void 0:n.color;return(0,l.qy)(D||(D=S`<li .id="${0}" @pointerdown="${0}" @pointerup="${0}" @pointerleave="${0}" @pointercancel="${0}" @contextmenu="${0}" class="${0}"> <button type="button" class="legend-toggle" data-id="${0}" aria-pressed="${0}" .title="${0}" @click="${0}"> <ha-svg-icon .path="${0}" style="${0}"></ha-svg-icon> </button> <button type="button" class="${0}" data-id="${0}" .title="${0}" @click="${0}"> ${0} </button> ${0} </li>`),d,this._legendPointerDown,this._legendPointerCancel,this._legendPointerCancel,this._legendPointerCancel,this._legendContextMenu,(0,h.H)({hidden:this._hiddenDatasets.has(d)}),d,!this._hiddenDatasets.has(d),this.hass.localize("ui.components.history_charts.toggle_visibility"),this._toggleDataset,this._hiddenDatasets.has(d)?j:M,(0,c.W)({color:this._hiddenDatasets.has(d)?void 0:b}),(0,h.H)({label:!0,clickable:x}),d,g,this._labelClick,g,p?(0,l.qy)(T||(T=S`<div class="value">${0}</div>`),p):l.s6)}),t.length>i?(0,l.qy)(Z||(Z=S`<li> <ha-assist-chip @click="${0}" filled label="${0}"> <ha-svg-icon slot="trailing-icon" .path="${0}"></ha-svg-icon> </ha-assist-chip> </li>`),this._toggleExpandedLegend,this.expandLegend?this.hass.localize("ui.components.history_charts.collapse_legend"):`${this.hass.localize("ui.components.history_charts.expand_legend")} (${t.length-i})`,this.expandLegend?$:V):l.s6)}async _setupChart(){if(!this._loading){this._loading=!0;try{var t,e;this.chart&&this.chart.dispose();const o=(await Promise.all([i.e(72850),i.e(37552),i.e(77072),i.e(53771),i.e(1872),i.e(9970),i.e(24060),i.e(81593)]).then(i.bind(i,79144))).default;null!==(t=this.extraComponents)&&void 0!==t&&t.length&&o.use(this.extraComponents);const s=getComputedStyle(this);if(o.registerTheme("custom",this._createTheme(s)),this.chart=o.init(this._chartContainer,"custom"),this.chart.on("datazoom",t=>{this._handleDataZoomEvent(t)}),this.chart.on("click",t=>{(0,v.r)(this,"chart-click",t)}),this.chart.on("sankeyroam",()=>{const t=this.chart.getOption().series,e=null==t?void 0:t.find(t=>"sankey"===t.type),i=1!==e.zoom;this._isZoomed=i,i||this.chart.setOption({series:[{id:e.id,center:null}]}),(0,v.r)(this,"chart-sankeyroam",{zoom:e.zoom}),this.chart.dispatchAction({type:"downplay"})}),null!==(e=this.options)&&void 0!==e&&e.dataZoom||this.chart.getZr().on("dblclick",this._handleClickZoom),this.chart.on("finished",this._handleChartRenderFinished),this._isTouchDevice){this.chart.getZr().on("click",t=>{t.zrByTouch&&(this._lastTapTime&&Date.now()-this._lastTapTime<E?this._handleClickZoom(t):this._lastTapTime=Date.now())});let t,e,i=!1;this.chart.on("showTip",i=>{var o,a,n;t=i.x,e=i.y,null===(o=this.chart)||void 0===o||o.setOption({xAxis:(0,p.e)(null!==(a=null===(n=this.chart)||void 0===n?void 0:n.getOption().xAxis)&&void 0!==a?a:[]).map(t=>{var e;return t.show?Object.assign(Object.assign({},t),{},{axisPointer:Object.assign(Object.assign({},t.axisPointer),{},{status:"show",handle:Object.assign(Object.assign({color:s.getPropertyValue("--primary-color"),margin:0,size:20},null===(e=t.axisPointer)||void 0===e?void 0:e.handle),{},{show:!0}),label:{show:!1}})}):t})})}),this.chart.on("hideTip",o=>{if(o.from){var s,a,n,r;if(i)return void(i=!1);null===(s=this.chart)||void 0===s||s.setOption({xAxis:(0,p.e)(null!==(a=null===(n=this.chart)||void 0===n?void 0:n.getOption().xAxis)&&void 0!==a?a:[]).map(t=>{var e;return t.show?Object.assign(Object.assign({},t),{},{axisPointer:Object.assign(Object.assign({},t.axisPointer),{},{handle:Object.assign(Object.assign({},null===(e=t.axisPointer)||void 0===e?void 0:e.handle),{},{show:!1}),status:"hide"})}):t})}),null===(r=this.chart)||void 0===r||r.dispatchAction({type:"downplay"})}else if(null!=t&&null!=e){var l;i=!0,null===(l=this.chart)||void 0===l||l.dispatchAction({type:"showTip",x:t,y:e})}})}this._updateHiddenStatsFromOptions(this.options),this.chart.setOption(Object.assign(Object.assign({},this._createOptions()),{},{series:this._getSeries()})),this._updateSankeyRoam()}finally{this._loading=!1}}}_getAllIdsFromLegend(t,e){var i,o;if(!t)return[e];const s=(0,p.e)((null===(i=this.options)||void 0===i?void 0:i.legend)||[])[0];let a;var n;"custom"===(null==s?void 0:s.type)&&(a=null===(n=s.data)||void 0===n?void 0:n.find(t=>"object"==typeof t&&t.id===e));return[e,...(null===(o=a)||void 0===o?void 0:o.secondaryIds)||[]]}_updateHiddenStatsFromOptions(t){var e;if(!t)return;const i=(0,p.e)((null===(e=this.options)||void 0===e?void 0:e.legend)||[])[0];Object.entries((null==i?void 0:i.selected)||{}).forEach(([e,i])=>{!1===i&&this._getAllIdsFromLegend(t,e).forEach(t=>this._hiddenDatasets.add(t))}),this.requestUpdate("_hiddenDatasets")}_getDataZoomConfig(){var t,e,i,o,s,a;const n=null!==(t=null===(e=this.options)||void 0===e||null===(e=e.xAxis)||void 0===e?void 0:e[0])&&void 0!==t?t:null===(i=this.options)||void 0===i?void 0:i.xAxis,r=null!==(o=null===(s=this.options)||void 0===s||null===(s=s.yAxis)||void 0===s?void 0:s[0])&&void 0!==o?o:null===(a=this.options)||void 0===a?void 0:a.yAxis;if("value"!==(null==n?void 0:n.type)||"category"!==(null==r?void 0:r.type))return{id:"dataZoom",type:"inside",orient:"horizontal",filterMode:this._getDataZoomFilterMode(),xAxisIndex:0,moveOnMouseMove:!this._isTouchDevice||this._isZoomed,preventDefaultMouseMove:!this._isTouchDevice||this._isZoomed,zoomLock:!this._isTouchDevice&&!this._modifierPressed}}_getDataZoomFilterMode(){const t=(0,p.e)(this.data);return t.every(t=>"line"===t.type)?"boundaryFilter":t.some(t=>"bar"===t.type)?"filter":"weakFilter"}_createOptions(){var t,e,i;let o=null===(t=this.options)||void 0===t?void 0:t.xAxis;o&&(o=Array.isArray(o)?o:[o],o=o.map(t=>{var e;if("time"!==t.type||!1===t.show)return t;t.min&&(this._minutesDifference=(0,r.o)(t.max||new Date,t.min));const i=this._minutesDifference/60/24;let o;return i&&(o=i>=89?24192e5:i>2?864e5:void 0),Object.assign(Object.assign({axisLine:{show:!1},splitLine:{show:!0}},t),{},{axisLabel:Object.assign({formatter:this._formatTimeLabel,rich:{bold:{fontWeight:"bold"}},hideOverlap:!0},t.axisLabel),minInterval:null!==(e=t.minInterval)&&void 0!==e?e:o})}));let s=null===(e=this.options)||void 0===e?void 0:e.legend;s&&(s=(0,p.e)(s).map(t=>"custom"===t.type?{show:!1}:t));const a=Object.assign(Object.assign({animation:!this._reducedMotion,animationDuration:500,darkMode:null!==(i=this._themes.darkMode)&&void 0!==i&&i,aria:{show:!0},dataZoom:this._getDataZoomConfig(),toolbox:{top:Number.MAX_SAFE_INTEGER,left:Number.MAX_SAFE_INTEGER,feature:{dataZoom:{show:!0,yAxisIndex:!1,filterMode:"none",showTitle:!1}},iconStyle:{opacity:0}}},this.options),{},{legend:s,xAxis:o});if(a.tooltip){const t=window.matchMedia("all and (max-width: 450px), all and (max-height: 500px)").matches,e=e=>{const i=W(e);return t&&(i.confine=!0,i.appendTo=void 0,i.triggerOn="click"),i},i=a.tooltip,o=Array.isArray(i)?i.map(e):e(i);return Object.assign(Object.assign({},a),{},{tooltip:o})}return a}_createTheme(t){const e=t.getPropertyValue("--ha-card-background")||t.getPropertyValue("--card-background-color");return{color:(0,u.ux)(t),backgroundColor:"transparent",textStyle:{color:t.getPropertyValue("--primary-text-color"),fontFamily:"Roboto, Noto, sans-serif"},title:{textStyle:{color:t.getPropertyValue("--primary-text-color")},subtextStyle:{color:t.getPropertyValue("--secondary-text-color")}},line:{lineStyle:{width:1.5},symbolSize:1,symbol:"circle",smooth:!1},bar:{itemStyle:{barBorderWidth:1.5}},graph:{label:{color:t.getPropertyValue("--primary-text-color"),textBorderColor:e,textBorderWidth:2}},pie:{label:{color:t.getPropertyValue("--primary-text-color"),textBorderColor:e,textBorderWidth:2}},sankey:{label:{color:t.getPropertyValue("--primary-text-color"),textBorderColor:e,textBorderWidth:2}},categoryAxis:{axisLine:{show:!1},axisTick:{show:!1},axisLabel:{show:!0,color:t.getPropertyValue("--primary-text-color")},splitLine:{show:!1,lineStyle:{color:t.getPropertyValue("--divider-color")}},splitArea:{show:!1,areaStyle:{color:[t.getPropertyValue("--divider-color")+"3F",t.getPropertyValue("--divider-color")+"7F"]}}},valueAxis:{axisLine:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},axisTick:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},axisLabel:{show:!0,color:t.getPropertyValue("--primary-text-color")},splitLine:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},splitArea:{show:!1,areaStyle:{color:[t.getPropertyValue("--divider-color")+"3F",t.getPropertyValue("--divider-color")+"7F"]}}},logAxis:{axisLine:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},axisTick:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},axisLabel:{show:!0,color:t.getPropertyValue("--primary-text-color")},splitLine:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},splitArea:{show:!1,areaStyle:{color:[t.getPropertyValue("--divider-color")+"3F",t.getPropertyValue("--divider-color")+"7F"]}}},timeAxis:{axisLine:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},axisTick:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},axisLabel:{show:!0,color:t.getPropertyValue("--primary-text-color")},splitLine:{show:!0,lineStyle:{color:t.getPropertyValue("--divider-color")}},splitArea:{show:!1,areaStyle:{color:[t.getPropertyValue("--divider-color")+"3F",t.getPropertyValue("--divider-color")+"7F"]}}},legend:{textStyle:{color:t.getPropertyValue("--primary-text-color")},inactiveColor:t.getPropertyValue("--disabled-text-color"),pageIconColor:t.getPropertyValue("--primary-text-color"),pageIconInactiveColor:t.getPropertyValue("--disabled-text-color"),pageTextStyle:{color:t.getPropertyValue("--secondary-text-color")}},tooltip:{backgroundColor:t.getPropertyValue("--card-background-color"),borderColor:t.getPropertyValue("--divider-color"),textStyle:{color:t.getPropertyValue("--primary-text-color"),fontSize:12},axisPointer:{lineStyle:{color:t.getPropertyValue("--info-color")},crossStyle:{color:t.getPropertyValue("--info-color")}},extraCssText:"direction:"+t.getPropertyValue("--direction")+";margin-inline-start:3px;margin-inline-end:8px;"},timeline:{}}}_getSeries(){var t,e,i;const o=null!==(t=null===(e=this.options)||void 0===e||null===(e=e.xAxis)||void 0===e?void 0:e[0])&&void 0!==t?t:null===(i=this.options)||void 0===i?void 0:i.xAxis;return(0,p.e)(this.data).map(t=>{var e;const i=this._hiddenDatasets.has(String(null!==(e=t.id)&&void 0!==e?e:t.name))?void 0:t.data;let s=Object.assign(Object.assign({},t),{},{data:i});if(i&&"line"===t.type&&"minmax"===t.sampling){const t=null!=o&&o.min?o.min instanceof Date?o.min.getTime():"number"==typeof o.min?o.min:void 0:void 0,e=null!=o&&o.max?o.max instanceof Date?o.max.getTime():"number"==typeof o.max?o.max:void 0:void 0;s=Object.assign(Object.assign({},s),{},{sampling:void 0,data:(0,w.P)(i,this.clientWidth*window.devicePixelRatio,t,e)})}return H(s)})}_getDefaultHeight(){return Math.max(this.clientWidth/2,200)}_setChartOptions(t){if(!this.chart)return;if(!this._originalZrFlush){if((0,p.e)(this.data).reduce((t,e)=>t+(e.data||[]).length,0)>1e4){const t=this.chart.getZr();this._originalZrFlush=t.flush,t.flush=()=>{setTimeout(()=>{var e;null===(e=this._originalZrFlush)||void 0===e||e.call(t)},5)}}}const e=t.series?["series"]:[];this.chart.setOption(t,{replaceMerge:e})}zoom(t,e,i=!1){var o;null===(o=this.chart)||void 0===o||o.dispatchAction({type:"dataZoom",start:t,end:e,silent:i})}_handleZoomReset(){var t,e,i;null===(t=this.chart)||void 0===t||t.dispatchAction({type:"dataZoom",start:0,end:100});const o=null===(e=this.chart)||void 0===e?void 0:e.getOption(),s=null==o||null===(i=o.series)||void 0===i?void 0:i.filter(t=>"sankey"===t.type);var a;null!=s&&s.length&&(null===(a=this.chart)||void 0===a||a.setOption({series:s.map(t=>({id:t.id,zoom:1,center:null}))}),this._isZoomed=!1,(0,v.r)(this,"chart-sankeyroam",{zoom:1}))}_updateSankeyRoam(){var t,e;const i=null===(t=this.chart)||void 0===t?void 0:t.getOption(),o=null==i||null===(e=i.series)||void 0===e?void 0:e.filter(t=>null!=t&&"sankey"===t.type);var s;null!=o&&o.length&&(null===(s=this.chart)||void 0===s||s.setOption({series:o.map(t=>({id:t.id,roam:!(!this._modifierPressed&&!this._isTouchDevice)||"move"}))}))}_handleDataZoomEvent(t){var e,i;const o=null!==(e=null===(i=t.batch)||void 0===i?void 0:i[0])&&void 0!==e?e:t;let s="number"==typeof o.start?o.start:0,a="number"==typeof o.end?o.end:100;if(0===s&&100===a&&void 0!==o.startValue&&void 0!==o.endValue){var n,r;const t=this.chart.getOption(),e=null!==(n=null===(r=t.xAxis)||void 0===r?void 0:r[0])&&void 0!==n?n:t.xAxis;if(null!=e&&e.min&&null!=e&&e.max){const t=new Date(e.min).getTime(),i=new Date(e.max).getTime()-t;s=Math.max(0,Math.min(100,(o.startValue-t)/i*100)),a=Math.max(0,Math.min(100,(o.endValue-t)/i*100))}}var l;(this._isZoomed=0!==s||100!==a,this._zoomRatio=(a-s)/100,this._isTouchDevice)&&(null===(l=this.chart)||void 0===l||l.dispatchAction({type:"hideTip",from:"datazoom"}));(0,v.r)(this,"chart-zoom",{start:s,end:a})}_legendPointerDown(t){var e;if("mouse"===t.pointerType)return;const i=null===(e=t.currentTarget)||void 0===e?void 0:e.id;i&&(this._longPressTriggered=!1,this._longPressTimer=setTimeout(()=>{this._longPressTriggered=!0,this._longPressTimer=void 0,this._soloLegend(i)},500))}_legendPointerCancel(){this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=void 0)}_legendContextMenu(t){(this._longPressTimer||this._longPressTriggered)&&t.preventDefault()}_toggleDataset(t){if(t.stopPropagation(),!this.chart)return;if(this._longPressTriggered)return void(this._longPressTriggered=!1);const e=t.currentTarget.dataset.id;if(!e)return;(x.c?t.metaKey:t.ctrlKey)?this._soloLegend(e):this._handleDatasetToggle(e)}_labelClick(t){if(t.stopPropagation(),!this.chart)return;if(this._longPressTriggered)return void(this._longPressTriggered=!1);const e=t.currentTarget,i=e.dataset.id;if(!i)return;(x.c?t.metaKey:t.ctrlKey)?this._soloLegend(i):e.classList.contains("clickable")?(0,v.r)(this,"legend-label-click",{id:i}):this._handleDatasetToggle(i)}_handleDatasetToggle(t){this._hiddenDatasets.has(t)?(this._getAllIdsFromLegend(this.options,t).forEach(t=>this._hiddenDatasets.delete(t)),(0,v.r)(this,"dataset-unhidden",{id:t})):(this._getAllIdsFromLegend(this.options,t).forEach(t=>this._hiddenDatasets.add(t)),(0,v.r)(this,"dataset-hidden",{id:t})),this.requestUpdate("_hiddenDatasets")}_soloLegend(t){const e=this._getAllLegendIds(),i=this._getAllIdsFromLegend(this.options,t),o=e.filter(t=>!i.includes(t));if(i.every(t=>!this._hiddenDatasets.has(t))&&o.every(t=>this._hiddenDatasets.has(t)))for(const s of[...this._hiddenDatasets])this._hiddenDatasets.delete(s),(0,v.r)(this,"dataset-unhidden",{id:s});else{for(const t of o)this._hiddenDatasets.has(t)||(this._hiddenDatasets.add(t),(0,v.r)(this,"dataset-hidden",{id:t}));for(const t of i)this._hiddenDatasets.has(t)&&(this._hiddenDatasets.delete(t),(0,v.r)(this,"dataset-unhidden",{id:t}))}this.requestUpdate("_hiddenDatasets")}_getAllLegendIds(){const t=this._getLegendItems();if(!t)return[];const e=new Set;for(const s of t){var i,o;const t="string"==typeof s?s:null!==(i=null!==(o=s.id)&&void 0!==o?o:s.name)&&void 0!==i?i:"";for(const i of this._getAllIdsFromLegend(this.options,t))e.add(i)}return[...e]}_toggleExpandedLegend(){this.expandLegend=!this.expandLegend,setTimeout(()=>{var t;null===(t=this.chart)||void 0===t||t.resize()})}_resizeChartIfNeeded(){this.chart&&this._shouldResizeChart&&(this._suspendResize||this.chart.getZr().animation.isFinished()&&(this.chart.resize({animation:this._reducedMotion||"number"!=typeof this._resizeAnimationDuration?void 0:{duration:this._resizeAnimationDuration}}),this._shouldResizeChart=!1,this._resizeAnimationDuration=void 0))}_compareCustomLegendOptions(t,e){const i=(0,p.e)((null==t?void 0:t.legend)||[]),o=(0,p.e)((null==e?void 0:e.legend)||[]);return i.some(t=>t.show&&"custom"===t.type)!==o.some(t=>t.show&&"custom"===t.type)}constructor(...t){super(...t),this.data=[],this.clickLabelForMoreInfo=!1,this._isZoomed=!1,this._zoomRatio=1,this._minutesDifference=1440,this._hiddenDatasets=new Set,this._modifierPressed=!1,this._isTouchDevice="ontouchstart"in window,this._longPressTriggered=!1,this._shouldResizeChart=!1,this._suspendResize=!1,this._layoutTransitionActive=!1,this._resizeController=new a.P(this,{callback:()=>{if(this.chart){if(this._suspendResize)return void(this._shouldResizeChart=!0);this.chart.getZr().animation.isFinished()?this.chart.resize():this._shouldResizeChart=!0}}}),this._loading=!1,this._reducedMotion=!1,this._listeners=[],this._pendingSetup=!1,this._formatTimeLabel=t=>(0,b.n)(t,this.hass.locale,this.hass.config,this._minutesDifference*this._zoomRatio),this._handleClickZoom=t=>{if(!this.chart)return;const e=this.chart.getOption().series,i=null==e?void 0:e.filter(t=>"sankey"===t.type);if(null!=i&&i.length&&(this._isZoomed?this._handleZoomReset():(this.chart.setOption({series:i.map(t=>({id:t.id,zoom:2}))}),this._isZoomed=!0),i.length===(null==e?void 0:e.length)))return;const o=this._isZoomed?[0,100]:[t.offsetX/this.chart.getWidth()*100-15,t.offsetX/this.chart.getWidth()*100+15];this.chart.dispatchAction({type:"dataZoom",start:o[0],end:o[1]})},this._handleChartRenderFinished=()=>{this._resizeChartIfNeeded()}}}q.styles=(0,l.AH)(O||(O=S`:host{display:block;position:relative;letter-spacing:normal;overflow:visible}:host([layout-transition-active]),:host([layout-transition-active]) .chart-container,:host([layout-transition-active]) .container{overflow:hidden}.container{display:flex;flex-direction:column;position:relative;overflow:visible}.container.has-height{max-height:var(--chart-max-height,350px)}.chart-container{width:100%;max-height:var(--chart-max-height,350px);overflow:visible}.has-height .chart-container{flex:1}.chart{height:100%;width:100%}.top-controls{position:absolute;top:var(--ha-space-4);inset-inline-start:var(--ha-space-4);inset-inline-end:var(--ha-space-1);display:flex;align-items:flex-start;gap:var(--ha-space-2);z-index:1;pointer-events:none}::slotted([slot=search]){flex:1 1 250px;min-width:0;max-width:250px;pointer-events:auto}.chart-controls{display:flex;flex-direction:column;gap:var(--ha-space-1);margin-inline-start:auto;flex-shrink:0;pointer-events:auto}.top-controls.small{top:0}.chart-controls.small{flex-direction:row}.chart-controls ::slotted(ha-icon-button),.chart-controls ha-icon-button{background:var(--card-background-color);border-radius:var(--ha-border-radius-sm);--ha-icon-button-size:32px;color:var(--primary-color);border:1px solid var(--divider-color)}.chart-controls.small ::slotted(ha-icon-button),.chart-controls.small ha-icon-button{--ha-icon-button-size:22px;--mdc-icon-size:16px}.chart-controls ::slotted(ha-icon-button.inactive),.chart-controls ha-icon-button.inactive{color:var(--state-inactive-color)}.chart-legend{max-height:60%;overflow-y:auto;padding:12px 0 0;font-size:var(--ha-font-size-s);color:var(--primary-text-color)}.chart-legend ul{margin:0;padding:0;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:var(--ha-space-2)}.chart-legend li{height:24px;display:inline-flex;align-items:center;padding:0 2px;box-sizing:border-box;overflow:hidden}.chart-legend.multiple-items li{max-width:220px}.chart-legend.multiple-items li:has(.value){max-width:300px}.chart-legend .hidden{color:var(--secondary-text-color)}.chart-legend .label{background:0 0;border:none;padding:0;margin:0;font:inherit;color:inherit;cursor:pointer;text-align:start;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;line-height:1}@media (hover:hover){.chart-legend .label.clickable:hover{text-decoration:underline}.chart-legend .legend-toggle:hover{opacity:.5}}.chart-legend .value{color:var(--secondary-text-color);margin-inline-start:var(--ha-space-1);flex-shrink:0;white-space:nowrap;line-height:1}.chart-legend .legend-toggle{background:0 0;border:none;color:inherit;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;padding:4px;margin:-4px;margin-inline-end:0}.chart-legend .label:focus-visible,.chart-legend .legend-toggle:focus-visible{outline:2px solid var(--primary-color);outline-offset:2px;border-radius:var(--ha-border-radius-small,4px)}.chart-legend .legend-toggle ha-svg-icon{--mdc-icon-size:18px}@media (pointer:coarse){.chart-legend ul{row-gap:0}.chart-legend li:has(.legend-toggle){height:40px;padding:0}.chart-legend .legend-toggle{padding:11px;padding-inline-end:4px;margin:0}}ha-assist-chip{height:100%;--_label-text-weight:500;--_leading-space:8px;--_trailing-space:8px;--_icon-label-space:4px}`)),(0,s.Cg)([(0,d.MZ)({attribute:!1})],q.prototype,"hass",void 0),(0,s.Cg)([(0,d.MZ)({attribute:!1})],q.prototype,"data",void 0),(0,s.Cg)([(0,d.MZ)({attribute:!1})],q.prototype,"options",void 0),(0,s.Cg)([(0,d.MZ)({type:String})],q.prototype,"height",void 0),(0,s.Cg)([(0,d.MZ)({attribute:"expand-legend",type:Boolean})],q.prototype,"expandLegend",void 0),(0,s.Cg)([(0,d.MZ)({attribute:"small-controls",type:Boolean})],q.prototype,"smallControls",void 0),(0,s.Cg)([(0,d.MZ)({attribute:"hide-reset-button",type:Boolean})],q.prototype,"hideResetButton",void 0),(0,s.Cg)([(0,d.wk)(),(0,n.Fg)({context:_.EK,subscribe:!0}),(0,g.p)({transformer:({themes:t})=>t})],q.prototype,"_themes",void 0),(0,s.Cg)([(0,d.MZ)({attribute:"click-label-for-more-info",type:Boolean})],q.prototype,"clickLabelForMoreInfo",void 0),(0,s.Cg)([(0,d.wk)()],q.prototype,"_isZoomed",void 0),(0,s.Cg)([(0,d.wk)()],q.prototype,"_zoomRatio",void 0),(0,s.Cg)([(0,d.wk)()],q.prototype,"_minutesDifference",void 0),(0,s.Cg)([(0,d.wk)()],q.prototype,"_hiddenDatasets",void 0),(0,s.Cg)([(0,d.P)(".chart")],q.prototype,"_chartContainer",void 0),q=(0,s.Cg)([(0,d.EM)("ha-chart-base")],q),e()}catch(P){e(P)}})},57243:function(t,e,i){i.d(e,{V:function(){return a}});i(88454),i(29452),i(62953);var o=i(5124);const s=new WeakMap,a=t=>{const e=s.get(t);if(e)return e;const i=document.createElement("div");i.style.display="contents";const a=(e,s)=>{const a=t(e,s);return null==a||a===o.s6?null:((0,o.XX)(a,i),i)};return s.set(t,a),s.set(a,a),a}},41570:function(t,e,i){i.d(e,{c:function(){return o}});i(27495);const o=/Mac/i.test(navigator.userAgent)}}]);