iobroker.aura 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/io-package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "aura",
4
- "version": "0.1.5",
4
+ "version": "0.1.6",
5
5
  "title": "Aura Visualisierung",
6
6
  "titleLang": {
7
7
  "en": "Aura Visualisation",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.aura",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Modern visualization dashboard for ioBroker",
5
5
  "main": "lib/main.js",
6
6
  "license": "MIT",
@@ -600,13 +600,13 @@ yyyy`);var n=ys(t),a=r?"getUTC":"get",i=n[a+"FullYear"](),o=n[a+"Month"]()+1,s=n
600
600
  `)){var m=new Sw;m.newline=!0,u.add(m);return}var b=a.getSeriesByName(y)[0];if(!c.get(y))if(b){var w=b.getData(),_=w.getVisual("legendLineStyle")||{},S=w.getVisual("legendIcon"),C=w.getVisual("style"),T=this._createItem(b,y,v,p,n,r,_,C,S,f,i);T.on("click",oh(YY,y,null,i,h)).on("mouseover",oh(LI,b.name,null,i,h)).on("mouseout",oh(II,b.name,null,i,h)),a.ssr&&T.eachChild(function(A){var k=Ee(A);k.seriesIndex=b.seriesIndex,k.dataIndex=v,k.ssrType="legend"}),d&&T.eachChild(function(A){g.packEventData(A,n,b,v,y)}),c.set(y,!0)}else a.eachRawSeries(function(A){var k=this;if(!c.get(y)&&A.legendVisualProvider){var P=A.legendVisualProvider;if(!P.containName(y))return;var M=P.indexOfName(y),D=P.getItemVisual(M,"style"),E=P.getItemVisual(M,"legendIcon"),L=Bn(D.fill);L&&L[3]===0&&(L[3]=.2,D=J(J({},D),{fill:yi(L,"rgba")}));var N=this._createItem(A,y,v,p,n,r,{},D,E,f,i);N.on("click",oh(YY,null,y,i,h)).on("mouseover",oh(LI,null,y,i,h)).on("mouseout",oh(II,null,y,i,h)),a.ssr&&N.eachChild(function(j){var R=Ee(j);R.seriesIndex=A.seriesIndex,R.dataIndex=v,R.ssrType="legend"}),d&&N.eachChild(function(j){k.packEventData(j,n,A,v,y)}),c.set(y,!0)}},this)},this),o&&this._createSelector(o,n,i,s,l)},t.prototype.packEventData=function(r,n,a,i,o){var s={componentType:"legend",componentIndex:n.componentIndex,dataIndex:i,value:o,seriesIndex:a.seriesIndex};Ee(r).eventData=s},t.prototype._createSelector=function(r,n,a,i,o){var s=this.getSelectorGroup();OI(r,function(u){var c=u.type,f=new at({style:{x:0,y:0,align:"center",verticalAlign:"middle"},onclick:function(){a.dispatchAction({type:c==="all"?"legendAllSelect":"legendInverseSelect",legendId:n.id})}});s.add(f);var d=n.getModel("selectorLabel"),h=n.getModel(["emphasis","selectorLabel"]);Ur(f,{normal:d,emphasis:h},{defaultText:u.title}),Du(f)})},t.prototype._createItem=function(r,n,a,i,o,s,l,u,c,f,d){var h=r.visualDrawType,p=o.get("itemWidth"),v=o.get("itemHeight"),g=o.isSelected(n),y=i.get("symbolRotate"),m=i.get("symbolKeepAspect"),b=i.get("icon");c=b||c||"roundRect";var w=yut(c,i,l,u,h,g,d),_=new Sw,S=i.getModel("textStyle");if(xe(r.getLegendIcon)&&(!b||b==="inherit"))_.add(r.getLegendIcon({itemWidth:p,itemHeight:v,icon:c,iconRotate:y,itemStyle:w.itemStyle,lineStyle:w.lineStyle,symbolKeepAspect:m}));else{var C=b==="inherit"&&r.getData().getVisual("symbol")?y==="inherit"?r.getData().getVisual("symbolRotate"):y:0;_.add(mut({itemWidth:p,itemHeight:v,icon:c,iconRotate:C,itemStyle:w.itemStyle,symbolKeepAspect:m}))}var T=s==="left"?p+5:-5,A=s,k=o.get("formatter"),P=n;se(k)&&k?P=k.replace("{name}",n??""):xe(k)&&(P=k(n));var M=g?S.getTextColor():i.get("inactiveColor");_.add(new at({style:Pt(S,{text:P,x:T,y:v/2,fill:M,align:A,verticalAlign:"middle"},{inheritColor:M})}));var D=new Ge({shape:_.getBoundingRect(),style:{fill:"transparent"}}),E=i.getModel("tooltip");return E.get("show")&&kl({el:D,componentModel:o,itemName:n,itemTooltipOption:E.option}),_.add(D),_.eachChild(function(L){L.silent=!0}),D.silent=!f,this.getContentGroup().add(_),Du(_),_.__legendDataIndex=a,_},t.prototype.layoutInner=function(r,n,a,i,o,s){var l=this.getContentGroup(),u=this.getSelectorGroup();If(r.get("orient"),l,r.get("itemGap"),a.width,a.height);var c=l.getBoundingRect(),f=[-c.x,-c.y];if(u.markRedraw(),l.markRedraw(),o){If("horizontal",u,r.get("selectorItemGap",!0));var d=u.getBoundingRect(),h=[-d.x,-d.y],p=r.get("selectorButtonGap",!0),v=r.getOrient().index,g=v===0?"width":"height",y=v===0?"height":"width",m=v===0?"y":"x";s==="end"?h[v]+=c[g]+p:f[v]+=d[g]+p,h[1-v]+=c[y]/2-d[y]/2,u.x=h[0],u.y=h[1],l.x=f[0],l.y=f[1];var b={x:0,y:0};return b[g]=c[g]+p+d[g],b[y]=Math.max(c[y],d[y]),b[m]=Math.min(0,d[m]+h[1-v]),b}else return l.x=f[0],l.y=f[1],this.group.getBoundingRect()},t.prototype.remove=function(){this.getContentGroup().removeAll(),this._isFirstRender=!0},t.type="legend.plain",t}(Et);function yut(e,t,r,n,a,i,o){function s(g,y){g.lineWidth==="auto"&&(g.lineWidth=y.lineWidth>0?2:0),OI(g,function(m,b){g[b]==="inherit"&&(g[b]=y[b])})}var l=t.getModel("itemStyle"),u=l.getItemStyle(),c=e.lastIndexOf("empty",0)===0?"fill":"stroke",f=l.getShallow("decal");u.decal=!f||f==="inherit"?n.decal:nv(f,o),u.fill==="inherit"&&(u.fill=n[a]),u.stroke==="inherit"&&(u.stroke=n[c]),u.opacity==="inherit"&&(u.opacity=(a==="fill"?n:r).opacity),s(u,n);var d=t.getModel("lineStyle"),h=d.getLineStyle();if(s(h,r),u.fill==="auto"&&(u.fill=n.fill),u.stroke==="auto"&&(u.stroke=n.fill),h.stroke==="auto"&&(h.stroke=n.fill),!i){var p=t.get("inactiveBorderWidth"),v=u[c];u.lineWidth=p==="auto"?n.lineWidth>0&&v?2:0:u.lineWidth,u.fill=t.get("inactiveColor"),u.stroke=t.get("inactiveBorderColor"),h.stroke=d.get("inactiveColor"),h.lineWidth=d.get("inactiveWidth")}return{itemStyle:u,lineStyle:h}}function mut(e){var t=e.icon||"roundRect",r=xr(t,0,0,e.itemWidth,e.itemHeight,e.itemStyle.fill,e.symbolKeepAspect);return r.setStyle(e.itemStyle),r.rotation=(e.iconRotate||0)*Math.PI/180,r.setOrigin([e.itemWidth/2,e.itemHeight/2]),t.indexOf("empty")>-1&&(r.style.stroke=r.style.fill,r.style.fill=Y.color.neutral00,r.style.lineWidth=2),r}function YY(e,t,r,n){II(e,t,r,n),r.dispatchAction({type:"legendToggleSelect",name:e??t}),LI(e,t,r,n)}function vce(e){for(var t=e.getZr().storage.getDisplayList(),r,n=0,a=t.length;n<a&&!(r=t[n].states.emphasis);)n++;return r&&r.hoverLayer}function LI(e,t,r,n){vce(r)||r.dispatchAction({type:"highlight",seriesName:e,name:t,excludeSeriesId:n})}function II(e,t,r,n){vce(r)||r.dispatchAction({type:"downplay",seriesName:e,name:t,excludeSeriesId:n})}function xut(e){var t=e.findComponents({mainType:"legend"});t&&t.length&&e.filterSeries(function(r){for(var n=0;n<t.length;n++)if(!t[n].isSelected(r.name))return!1;return!0})}function uy(e,t,r){var n=e==="allSelect"||e==="inverseSelect",a={},i=[];r.eachComponent({mainType:"legend",query:t},function(s){n?s[e]():s[e](t.name),XY(s,a),i.push(s.componentIndex)});var o={};return r.eachComponent("legend",function(s){O(a,function(l,u){s[l?"select":"unSelect"](u)}),XY(s,o)}),n?{selected:o,legendIndex:i}:{name:t.name,selected:o}}function XY(e,t){var r=t||{};return O(e.getData(),function(n){var a=n.get("name");if(!(a===`
601
601
  `||a==="")){var i=e.isSelected(a);he(r,a)?r[a]=r[a]&&i:r[a]=i}}),r}function but(e){e.registerAction("legendToggleSelect","legendselectchanged",Re(uy,"toggleSelected")),e.registerAction("legendAllSelect","legendselectall",Re(uy,"allSelect")),e.registerAction("legendInverseSelect","legendinverseselect",Re(uy,"inverseSelect")),e.registerAction("legendSelect","legendselected",Re(uy,"select")),e.registerAction("legendUnSelect","legendunselected",Re(uy,"unSelect"))}function gce(e){e.registerComponentModel(NI),e.registerComponentView(pce),e.registerProcessor(e.PRIORITY.PROCESSOR.SERIES_FILTER,xut),e.registerSubTypeDefaulter("legend",function(){return"plain"}),but(e)}var wut=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r}return t.prototype.setScrollDataIndex=function(r){this.option.scrollDataIndex=r},t.prototype.init=function(r,n,a){var i=wd(r);e.prototype.init.call(this,r,n,a),qY(this,r,i)},t.prototype.mergeOption=function(r,n){e.prototype.mergeOption.call(this,r,n),qY(this,this.option,r)},t.type="legend.scroll",t.defaultOption=ac(NI.defaultOption,{scrollDataIndex:0,pageButtonItemGap:5,pageButtonGap:null,pageButtonPosition:"end",pageFormatter:"{current}/{total}",pageIcons:{horizontal:["M0,0L12,-10L12,10z","M0,0L-12,-10L-12,10z"],vertical:["M0,0L20,0L10,-20z","M0,0L20,0L10,20z"]},pageIconColor:Y.color.accent50,pageIconInactiveColor:Y.color.accent10,pageIconSize:15,pageTextStyle:{color:Y.color.tertiary},animationDurationUpdate:800}),t}(NI);function qY(e,t,r){var n=e.getOrient(),a=[1,1];a[n.index]=0,os(t,r,{type:"box",ignoreSize:!!a})}var KY=we,yD=["width","height"],mD=["x","y"],_ut=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r.newlineDisabled=!0,r._currentIndex=0,r}return t.prototype.init=function(){e.prototype.init.call(this),this.group.add(this._containerGroup=new KY),this._containerGroup.add(this.getContentGroup()),this.group.add(this._controllerGroup=new KY)},t.prototype.resetInner=function(){e.prototype.resetInner.call(this),this._controllerGroup.removeAll(),this._containerGroup.removeClipPath(),this._containerGroup.__rectSize=null},t.prototype.renderInner=function(r,n,a,i,o,s,l){var u=this;e.prototype.renderInner.call(this,r,n,a,i,o,s,l);var c=this._controllerGroup,f=n.get("pageIconSize",!0),d=te(f)?f:[f,f];p("pagePrev",0);var h=n.getModel("pageTextStyle");c.add(new at({name:"pageText",style:{text:"xx/xx",fill:h.getTextColor(),font:h.getFont(),verticalAlign:"middle",align:"center"},silent:!0})),p("pageNext",1);function p(v,g){var y=v+"DataIndex",m=Xv(n.get("pageIcons",!0)[n.getOrient().name][g],{onclick:ue(u._pageGo,u,y,n,i)},{x:-d[0]/2,y:-d[1]/2,width:d[0],height:d[1]});m.name=v,c.add(m)}},t.prototype.layoutInner=function(r,n,a,i,o,s){var l=this.getSelectorGroup(),u=r.getOrient().index,c=yD[u],f=mD[u],d=yD[1-u],h=mD[1-u];o&&If("horizontal",l,r.get("selectorItemGap",!0));var p=r.get("selectorButtonGap",!0),v=l.getBoundingRect(),g=[-v.x,-v.y],y=be(a);o&&(y[c]=a[c]-v[c]-p);var m=this._layoutContentAndController(r,i,y,u,c,d,h,f);if(o){if(s==="end")g[u]+=m[c]+p;else{var b=v[c]+p;g[u]-=b,m[f]-=b}m[c]+=v[c]+p,g[1-u]+=m[h]+m[d]/2-v[d]/2,m[d]=Math.max(m[d],v[d]),m[h]=Math.min(m[h],v[h]+g[1-u]),l.x=g[0],l.y=g[1],l.markRedraw()}return m},t.prototype._layoutContentAndController=function(r,n,a,i,o,s,l,u){var c=this.getContentGroup(),f=this._containerGroup,d=this._controllerGroup;If(r.get("orient"),c,r.get("itemGap"),i?a.width:null,i?null:a.height),If("horizontal",d,r.get("pageButtonItemGap",!0));var h=c.getBoundingRect(),p=d.getBoundingRect(),v=this._showController=h[o]>a[o],g=[-h.x,-h.y];n||(g[i]=c[u]);var y=[0,0],m=[-p.x,-p.y],b=ge(r.get("pageButtonGap",!0),r.get("itemGap",!0));if(v){var w=r.get("pageButtonPosition",!0);w==="end"?m[i]+=a[o]-p[o]:y[i]+=p[o]+b}m[1-i]+=h[s]/2-p[s]/2,c.setPosition(g),f.setPosition(y),d.setPosition(m);var _={x:0,y:0};if(_[o]=v?a[o]:h[o],_[s]=Math.max(h[s],p[s]),_[l]=Math.min(0,p[l]+m[1-i]),f.__rectSize=a[o],v){var S={x:0,y:0};S[o]=Math.max(a[o]-p[o]-b,0),S[s]=_[s],f.setClipPath(new Ge({shape:S})),f.__rectSize=S[o]}else d.eachChild(function(T){T.attr({invisible:!0,silent:!0})});var C=this._getPageInfo(r);return C.pageIndex!=null&&ot(c,{x:C.contentPosition[0],y:C.contentPosition[1]},v?r:null),this._updatePageInfoView(r,C),_},t.prototype._pageGo=function(r,n,a){var i=this._getPageInfo(n)[r];i!=null&&a.dispatchAction({type:"legendScroll",scrollDataIndex:i,legendId:n.id})},t.prototype._updatePageInfoView=function(r,n){var a=this._controllerGroup;O(["pagePrev","pageNext"],function(c){var f=c+"DataIndex",d=n[f]!=null,h=a.childOfName(c);h&&(h.setStyle("fill",d?r.get("pageIconColor",!0):r.get("pageIconInactiveColor",!0)),h.cursor=d?"pointer":"default")});var i=a.childOfName("pageText"),o=r.get("pageFormatter"),s=n.pageIndex,l=s!=null?s+1:0,u=n.pageCount;i&&o&&i.setStyle("text",se(o)?o.replace("{current}",l==null?"":l+"").replace("{total}",u==null?"":u+""):o({current:l,total:u}))},t.prototype._getPageInfo=function(r){var n=r.get("scrollDataIndex",!0),a=this.getContentGroup(),i=this._containerGroup.__rectSize,o=r.getOrient().index,s=yD[o],l=mD[o],u=this._findTargetItemIndex(n),c=a.children(),f=c[u],d=c.length,h=d?1:0,p={contentPosition:[a.x,a.y],pageCount:h,pageIndex:h-1,pagePrevDataIndex:null,pageNextDataIndex:null};if(!f)return p;var v=w(f);p.contentPosition[o]=-v.s;for(var g=u+1,y=v,m=v,b=null;g<=d;++g)b=w(c[g]),(!b&&m.e>y.s+i||b&&!_(b,y.s))&&(m.i>y.i?y=m:y=b,y&&(p.pageNextDataIndex==null&&(p.pageNextDataIndex=y.i),++p.pageCount)),m=b;for(var g=u-1,y=v,m=v,b=null;g>=-1;--g)b=w(c[g]),(!b||!_(m,b.s))&&y.i<m.i&&(m=y,p.pagePrevDataIndex==null&&(p.pagePrevDataIndex=y.i),++p.pageCount,++p.pageIndex),y=b;return p;function w(S){if(S){var C=S.getBoundingRect(),T=C[l]+S[l];return{s:T,e:T+C[s],i:S.__legendDataIndex}}}function _(S,C){return S.e>=C&&S.s<=C+i}},t.prototype._findTargetItemIndex=function(r){if(!this._showController)return 0;var n,a=this.getContentGroup(),i;return a.eachChild(function(o,s){var l=o.__legendDataIndex;i==null&&l!=null&&(i=s),l===r&&(n=s)}),n??i},t.type="legend.scroll",t}(pce);function Sut(e){e.registerAction("legendScroll","legendscroll",function(t,r){var n=t.scrollDataIndex;n!=null&&r.eachComponent({mainType:"legend",subType:"scroll",query:t},function(a){a.setScrollDataIndex(n)})})}function Cut(e){We(gce),e.registerComponentModel(wut),e.registerComponentView(_ut),Sut(e)}function Tut(e){We(gce),We(Cut)}var Aut=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r}return t.type="dataZoom.inside",t.defaultOption=ac(vx.defaultOption,{disabled:!1,zoomLock:!1,zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!1,preventDefaultMouseMove:!0}),t}(vx),gB=Xe();function kut(e,t,r){gB(e).coordSysRecordMap.each(function(n){var a=n.dataZoomInfoMap.get(t.uid);a&&(a.getRange=r)})}function Mut(e,t){for(var r=gB(e).coordSysRecordMap,n=r.keys(),a=0;a<n.length;a++){var i=n[a],o=r.get(i),s=o.dataZoomInfoMap;if(s){var l=t.uid,u=s.get(l);u&&(s.removeKey(l),s.keys().length||yce(r,o))}}}function yce(e,t){if(t){e.removeKey(t.model.uid);var r=t.controller;r&&r.dispose()}}function Put(e,t){var r={model:t,containsPoint:Re(Eut,t),dispatchAction:Re(Dut,e),dataZoomInfoMap:null,controller:null},n=r.controller=new Td(e.getZr());return O(["pan","zoom","scrollMove"],function(a){n.on(a,function(i){var o=[];r.dataZoomInfoMap.each(function(s){if(i.isAvailableBehavior(s.model.option)){var l=(s.getRange||{})[a],u=l&&l(s.dzReferCoordSysInfo,r.model.mainType,r.controller,i);!s.model.get("disabled",!0)&&u&&o.push({dataZoomId:s.model.id,start:u[0],end:u[1]})}}),o.length&&r.dispatchAction(o)})}),r}function Dut(e,t){e.isDisposed()||e.dispatchAction({type:"dataZoom",animation:{easing:"cubicOut",duration:100},batch:t})}function Eut(e,t,r,n){return e.coordinateSystem.containPoint([r,n])}function Nut(e,t,r){var n,a="type_",i={type_true:2,type_move:1,type_false:0,type_undefined:-1},o=!0;return e.each(function(s){var l=s.model,u=l.get("disabled",!0)?!1:l.get("zoomLock",!0)?"move":!0;i[a+u]>i[a+n]&&(n=u),o=o&&l.get("preventDefaultMouseMove",!0)}),{controlType:n,opt:{zoomOnMouseWheel:!0,moveOnMouseMove:!0,moveOnMouseWheel:!0,preventDefaultMouseMove:!!o,api:r,zInfo:{component:t.model},triggerInfo:{roamTrigger:null,isInSelf:t.containsPoint}}}}function Out(e){e.registerProcessor(e.PRIORITY.PROCESSOR.FILTER,function(t,r){var n=gB(r),a=n.coordSysRecordMap||(n.coordSysRecordMap=pe());a.each(function(i){i.dataZoomInfoMap=null}),t.eachComponent({mainType:"dataZoom",subType:"inside"},function(i){var o=Que(i);O(o.infoList,function(s){var l=s.model.uid,u=a.get(l)||a.set(l,Put(r,s.model)),c=u.dataZoomInfoMap||(u.dataZoomInfoMap=pe());c.set(i.uid,{dzReferCoordSysInfo:s,model:i,getRange:null})})}),a.each(function(i){var o=i.controller,s,l=i.dataZoomInfoMap;if(l){var u=l.keys()[0];u!=null&&(s=l.get(u))}if(!s){yce(a,i);return}var c=Nut(l,i,r);o.enable(c.controlType,c.opt),eg(i,"dispatchAction",s.model.get("throttle",!0),"fixRate")})})}var Lut=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type="dataZoom.inside",r}return t.prototype.render=function(r,n,a){if(e.prototype.render.apply(this,arguments),r.noTarget()){this._clear();return}this.range=r.getPercentRange(),kut(a,r,{pan:ue(xD.pan,this),zoom:ue(xD.zoom,this),scrollMove:ue(xD.scrollMove,this)})},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){Mut(this.api,this.dataZoomModel),this.range=null},t.type="dataZoom.inside",t}(lB),xD={zoom:function(e,t,r,n){var a=this.range,i=a.slice(),o=e.axisModels[0];if(o){var s=bD[t](null,[n.originX,n.originY],o,r,e),l=(s.signal>0?s.pixelStart+s.pixelLength-s.pixel:s.pixel-s.pixelStart)/s.pixelLength*(i[1]-i[0])+i[0],u=Math.max(1/n.scale,0);i[0]=(i[0]-l)*u+l,i[1]=(i[1]-l)*u+l;var c=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();if(Vu(0,i,[0,100],0,c.minSpan,c.maxSpan),this.range=i,a[0]!==i[0]||a[1]!==i[1])return i}},pan:ZY(function(e,t,r,n,a,i){var o=bD[n]([i.oldX,i.oldY],[i.newX,i.newY],t,a,r);return o.signal*(e[1]-e[0])*o.pixel/o.pixelLength}),scrollMove:ZY(function(e,t,r,n,a,i){var o=bD[n]([0,0],[i.scrollDelta,i.scrollDelta],t,a,r);return o.signal*(e[1]-e[0])*i.scrollDelta})};function ZY(e){return function(t,r,n,a){var i=this.range,o=i.slice(),s=t.axisModels[0];if(s){var l=e(o,s,t,r,n,a);if(Vu(l,o,[0,100],"all"),this.range=o,i[0]!==o[0]||i[1]!==o[1])return o}}}var bD={grid:function(e,t,r,n,a){var i=r.axis,o={},s=a.model.coordinateSystem.getRect();return e=e||[0,0],i.dim==="x"?(o.pixel=t[0]-e[0],o.pixelLength=s.width,o.pixelStart=s.x,o.signal=i.inverse?1:-1):(o.pixel=t[1]-e[1],o.pixelLength=s.height,o.pixelStart=s.y,o.signal=i.inverse?-1:1),o},polar:function(e,t,r,n,a){var i=r.axis,o={},s=a.model.coordinateSystem,l=s.getRadiusAxis().getExtent(),u=s.getAngleAxis().getExtent();return e=e?s.pointToCoord(e):[0,0],t=s.pointToCoord(t),r.mainType==="radiusAxis"?(o.pixel=t[0]-e[0],o.pixelLength=l[1]-l[0],o.pixelStart=l[0],o.signal=i.inverse?1:-1):(o.pixel=t[1]-e[1],o.pixelLength=u[1]-u[0],o.pixelStart=u[0],o.signal=i.inverse?-1:1),o},singleAxis:function(e,t,r,n,a){var i=r.axis,o=a.model.coordinateSystem.getRect(),s={};return e=e||[0,0],i.orient==="horizontal"?(s.pixel=t[0]-e[0],s.pixelLength=o.width,s.pixelStart=o.x,s.signal=i.inverse?1:-1):(s.pixel=t[1]-e[1],s.pixelLength=o.height,s.pixelStart=o.y,s.signal=i.inverse?-1:1),s}};function mce(e){uB(e),e.registerComponentModel(Aut),e.registerComponentView(Lut),Out(e)}var Iut=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r}return t.type="dataZoom.slider",t.layoutMode="box",t.defaultOption=ac(vx.defaultOption,{show:!0,right:"ph",top:"ph",width:"ph",height:"ph",left:null,bottom:null,borderColor:Y.color.accent10,borderRadius:0,backgroundColor:Y.color.transparent,dataBackground:{lineStyle:{color:Y.color.accent30,width:.5},areaStyle:{color:Y.color.accent20,opacity:.2}},selectedDataBackground:{lineStyle:{color:Y.color.accent40,width:.5},areaStyle:{color:Y.color.accent20,opacity:.3}},fillerColor:"rgba(135,175,274,0.2)",handleIcon:"path://M-9.35,34.56V42m0-40V9.5m-2,0h4a2,2,0,0,1,2,2v21a2,2,0,0,1-2,2h-4a2,2,0,0,1-2-2v-21A2,2,0,0,1-11.35,9.5Z",handleSize:"100%",handleStyle:{color:Y.color.neutral00,borderColor:Y.color.accent20},moveHandleSize:7,moveHandleIcon:"path://M-320.9-50L-320.9-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-348-41-339-50-320.9-50z M-212.3-50L-212.3-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-239.4-41-230.4-50-212.3-50z M-103.7-50L-103.7-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-130.9-41-121.8-50-103.7-50z",moveHandleStyle:{color:Y.color.accent40,opacity:.5},showDetail:!0,showDataShadow:"auto",realtime:!0,zoomLock:!1,textStyle:{color:Y.color.tertiary},brushSelect:!0,brushStyle:{color:Y.color.accent30,opacity:.3},emphasis:{handleLabel:{show:!0},handleStyle:{borderColor:Y.color.accent40},moveHandleStyle:{opacity:.8}},defaultLocationEdgeGap:15}),t}(vx),cy=Ge,jut=1,wD=30,Rut=7,fy="horizontal",JY="vertical",zut=5,But=["line","bar","candlestick","scatter"],$ut={easing:"cubicOut",duration:100,delay:0},Fut=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r._displayables={},r}return t.prototype.init=function(r,n){this.api=n,this._onBrush=ue(this._onBrush,this),this._onBrushEnd=ue(this._onBrushEnd,this)},t.prototype.render=function(r,n,a,i){if(e.prototype.render.apply(this,arguments),eg(this,"_dispatchZoomAction",r.get("throttle"),"fixRate"),this._orient=r.getOrient(),r.get("show")===!1){this.group.removeAll();return}if(r.noTarget()){this._clear(),this.group.removeAll();return}(!i||i.type!=="dataZoom"||i.from!==this.uid)&&this._buildView(),this._updateView()},t.prototype.dispose=function(){this._clear(),e.prototype.dispose.apply(this,arguments)},t.prototype._clear=function(){ex(this,"_dispatchZoomAction");var r=this.api.getZr();r.off("mousemove",this._onBrush),r.off("mouseup",this._onBrushEnd)},t.prototype._buildView=function(){var r=this.group;r.removeAll(),this._brushing=!1,this._displayables.brushRect=null,this._resetLocation(),this._resetInterval();var n=this._displayables.sliderGroup=new we;this._renderBackground(),this._renderHandle(),this._renderDataShadow(),r.add(n),this._positionGroup()},t.prototype._resetLocation=function(){var r=this.dataZoomModel,n=this.api,a=r.get("brushSelect"),i=a?Rut:0,o=Lr(r,n).refContainer,s=this._findCoordRect(),l=r.get("defaultLocationEdgeGap",!0)||0,u=this._orient===fy?{right:o.width-s.x-s.width,top:o.height-wD-l-i,width:s.width,height:wD}:{right:l,top:s.y,width:wD,height:s.height},c=wd(r.option);O(["right","top","width","height"],function(d){c[d]==="ph"&&(c[d]=u[d])});var f=Ft(c,o);this._location={x:f.x,y:f.y},this._size=[f.width,f.height],this._orient===JY&&this._size.reverse()},t.prototype._positionGroup=function(){var r=this.group,n=this._location,a=this._orient,i=this.dataZoomModel.getFirstTargetAxisModel(),o=i&&i.get("inverse"),s=this._displayables.sliderGroup,l=(this._dataShadowInfo||{}).otherAxisInverse;s.attr(a===fy&&!o?{scaleY:l?1:-1,scaleX:1}:a===fy&&o?{scaleY:l?1:-1,scaleX:-1}:a===JY&&!o?{scaleY:l?-1:1,scaleX:1,rotation:Math.PI/2}:{scaleY:l?-1:1,scaleX:-1,rotation:Math.PI/2});var u=r.getBoundingRect([s]);r.x=n.x-u.x,r.y=n.y-u.y,r.markRedraw()},t.prototype._getViewExtent=function(){return[0,this._size[0]]},t.prototype._renderBackground=function(){var r=this.dataZoomModel,n=this._size,a=this._displayables.sliderGroup,i=r.get("brushSelect");a.add(new cy({silent:!0,shape:{x:0,y:0,width:n[0],height:n[1]},style:{fill:r.get("backgroundColor")},z2:-40}));var o=new cy({shape:{x:0,y:0,width:n[0],height:n[1]},style:{fill:"transparent"},z2:0,onclick:ue(this._onClickPanel,this)}),s=this.api.getZr();i?(o.on("mousedown",this._onBrushStart,this),o.cursor="crosshair",s.on("mousemove",this._onBrush),s.on("mouseup",this._onBrushEnd)):(s.off("mousemove",this._onBrush),s.off("mouseup",this._onBrushEnd)),a.add(o)},t.prototype._renderDataShadow=function(){var r=this._dataShadowInfo=this._prepareDataShadowInfo();if(this._displayables.dataShadowSegs=[],!r)return;var n=this._size,a=this._shadowSize||[],i=r.series,o=i.getRawData(),s=i.getShadowDim&&i.getShadowDim(),l=s&&o.getDimensionInfo(s)?i.getShadowDim():r.otherDim;if(l==null)return;var u=this._shadowPolygonPts,c=this._shadowPolylinePts;if(o!==this._shadowData||l!==this._shadowDim||n[0]!==a[0]||n[1]!==a[1]){var f=o.getDataExtent(r.thisDim),d=o.getDataExtent(l),h=(d[1]-d[0])*.3;d=[d[0]-h,d[1]+h];var p=[0,n[1]],v=[0,n[0]],g=[[n[0],0],[0,0]],y=[],m=v[1]/Math.max(1,o.count()-1),b=n[0]/(f[1]-f[0]),w=r.thisAxis.type==="time",_=-m,S=Math.round(o.count()/n[0]),C;o.each([r.thisDim,l],function(M,D,E){if(S>0&&E%S){w||(_+=m);return}_=w?(+M-f[0])*b:_+m;var L=D==null||isNaN(D)||D==="",N=L?0:vt(D,d,p,!0);L&&!C&&E?(g.push([g[g.length-1][0],0]),y.push([y[y.length-1][0],0])):!L&&C&&(g.push([_,0]),y.push([_,0])),L||(g.push([_,N]),y.push([_,N])),C=L}),u=this._shadowPolygonPts=g,c=this._shadowPolylinePts=y}this._shadowData=o,this._shadowDim=l,this._shadowSize=[n[0],n[1]];var T=this.dataZoomModel;function A(M){var D=T.getModel(M?"selectedDataBackground":"dataBackground"),E=new we,L=new _n({shape:{points:u},segmentIgnoreThreshold:1,style:D.getModel("areaStyle").getAreaStyle(),silent:!0,z2:-20}),N=new nn({shape:{points:c},segmentIgnoreThreshold:1,style:D.getModel("lineStyle").getLineStyle(),silent:!0,z2:-19});return E.add(L),E.add(N),E}for(var k=0;k<3;k++){var P=A(k===1);this._displayables.sliderGroup.add(P),this._displayables.dataShadowSegs.push(P)}},t.prototype._prepareDataShadowInfo=function(){var r=this.dataZoomModel,n=r.get("showDataShadow");if(n!==!1){var a,i=this.ecModel;return r.eachTargetAxis(function(o,s){var l=r.getAxisProxy(o,s).getTargetSeriesModels();O(l,function(u){if(!a&&!(n!==!0&&$e(But,u.get("type"))<0)){var c=i.getComponent(vu(o),s).axis,f=Vut(o),d,h=u.coordinateSystem;f!=null&&h.getOtherAxis&&(d=h.getOtherAxis(c).inverse),f=u.getData().mapDimension(f);var p=u.getData().mapDimension(o);a={thisAxis:c,series:u,thisDim:p,otherDim:f,otherAxisInverse:d}}},this)},this),a}},t.prototype._renderHandle=function(){var r=this.group,n=this._displayables,a=n.handles=[null,null],i=n.handleLabels=[null,null],o=this._displayables.sliderGroup,s=this._size,l=this.dataZoomModel,u=this.api,c=l.get("borderRadius")||0,f=l.get("brushSelect"),d=n.filler=new cy({silent:f,style:{fill:l.get("fillerColor")},textConfig:{position:"inside"}});o.add(d),o.add(new cy({silent:!0,subPixelOptimize:!0,shape:{x:0,y:0,width:s[0],height:s[1],r:c},style:{stroke:l.get("dataBackgroundColor")||l.get("borderColor"),lineWidth:jut,fill:Y.color.transparent}})),O([0,1],function(b){var w=l.get("handleIcon");!CC[w]&&w.indexOf("path://")<0&&w.indexOf("image://")<0&&(w="path://"+w);var _=xr(w,-1,0,2,2,null,!0);_.attr({cursor:Wut(this._orient),draggable:!0,drift:ue(this._onDragMove,this,b),ondragend:ue(this._onDragEnd,this),onmouseover:ue(this._showDataInfo,this,!0),onmouseout:ue(this._showDataInfo,this,!1),z2:5});var S=_.getBoundingRect(),C=l.get("handleSize");this._handleHeight=oe(C,this._size[1]),this._handleWidth=S.width/S.height*this._handleHeight,_.setStyle(l.getModel("handleStyle").getItemStyle()),_.style.strokeNoScale=!0,_.rectHover=!0,_.ensureState("emphasis").style=l.getModel(["emphasis","handleStyle"]).getItemStyle(),Du(_);var T=l.get("handleColor");T!=null&&(_.style.fill=T),o.add(a[b]=_);var A=l.getModel("textStyle"),k=l.get("handleLabel")||{},P=k.show||!1;r.add(i[b]=new at({silent:!0,invisible:!P,style:Pt(A,{x:0,y:0,text:"",verticalAlign:"middle",align:"center",fill:A.getTextColor(),font:A.getFont()}),z2:10}))},this);var h=d;if(f){var p=oe(l.get("moveHandleSize"),s[1]),v=n.moveHandle=new Ge({style:l.getModel("moveHandleStyle").getItemStyle(),silent:!0,shape:{r:[0,0,2,2],y:s[1]-.5,height:p}}),g=p*.8,y=n.moveHandleIcon=xr(l.get("moveHandleIcon"),-g/2,-g/2,g,g,Y.color.neutral00,!0);y.silent=!0,y.y=s[1]+p/2-.5,v.ensureState("emphasis").style=l.getModel(["emphasis","moveHandleStyle"]).getItemStyle();var m=Math.min(s[1]/2,Math.max(p,10));h=n.moveZone=new Ge({invisible:!0,shape:{y:s[1]-m,height:p+m}}),h.on("mouseover",function(){u.enterEmphasis(v)}).on("mouseout",function(){u.leaveEmphasis(v)}),o.add(v),o.add(y),o.add(h)}h.attr({draggable:!0,cursor:"default",drift:ue(this._onDragMove,this,"all"),ondragstart:ue(this._showDataInfo,this,!0),ondragend:ue(this._onDragEnd,this),onmouseover:ue(this._showDataInfo,this,!0),onmouseout:ue(this._showDataInfo,this,!1)})},t.prototype._resetInterval=function(){var r=this._range=this.dataZoomModel.getPercentRange(),n=this._getViewExtent();this._handleEnds=[vt(r[0],[0,100],n,!0),vt(r[1],[0,100],n,!0)]},t.prototype._updateInterval=function(r,n){var a=this.dataZoomModel,i=this._handleEnds,o=this._getViewExtent(),s=a.findRepresentativeAxisProxy().getMinMaxSpan(),l=[0,100];Vu(n,i,o,a.get("zoomLock")?"all":r,s.minSpan!=null?vt(s.minSpan,l,o,!0):null,s.maxSpan!=null?vt(s.maxSpan,l,o,!0):null);var u=this._range,c=this._range=Ia([vt(i[0],o,l,!0),vt(i[1],o,l,!0)]);return!u||u[0]!==c[0]||u[1]!==c[1]},t.prototype._updateView=function(r){var n=this._displayables,a=this._handleEnds,i=Ia(a.slice()),o=this._size;O([0,1],function(h){var p=n.handles[h],v=this._handleHeight;p.attr({scaleX:v/2,scaleY:v/2,x:a[h]+(h?-1:1),y:o[1]/2-v/2})},this),n.filler.setShape({x:i[0],y:0,width:i[1]-i[0],height:o[1]});var s={x:i[0],width:i[1]-i[0]};n.moveHandle&&(n.moveHandle.setShape(s),n.moveZone.setShape(s),n.moveZone.getBoundingRect(),n.moveHandleIcon&&n.moveHandleIcon.attr("x",s.x+s.width/2));for(var l=n.dataShadowSegs,u=[0,i[0],i[1],o[0]],c=0;c<l.length;c++){var f=l[c],d=f.getClipPath();d||(d=new Ge,f.setClipPath(d)),d.setShape({x:u[c],y:0,width:u[c+1]-u[c],height:o[1]})}this._updateDataInfo(r)},t.prototype._updateDataInfo=function(r){var n=this.dataZoomModel,a=this._displayables,i=a.handleLabels,o=this._orient,s=["",""];if(n.get("showDetail")){var l=n.findRepresentativeAxisProxy();if(l){var u=l.getAxisModel().axis,c=this._range,f=r?l.calculateDataWindow({start:c[0],end:c[1]}).valueWindow:l.getDataValueWindow();s=[this._formatLabel(f[0],u),this._formatLabel(f[1],u)]}}var d=Ia(this._handleEnds.slice());h.call(this,0),h.call(this,1);function h(p){var v=Eu(a.handles[p].parent,this.group),g=nA(p===0?"right":"left",v),y=this._handleWidth/2+zut,m=so([d[p]+(p===0?-y:y),this._size[1]/2],v);i[p].setStyle({x:m[0],y:m[1],verticalAlign:o===fy?"middle":g,align:o===fy?g:"center",text:s[p]})}},t.prototype._formatLabel=function(r,n){var a=this.dataZoomModel,i=a.get("labelFormatter"),o=a.get("labelPrecision");(o==null||o==="auto")&&(o=n.getPixelPrecision());var s=r==null||isNaN(r)?"":n.type==="category"||n.type==="time"?n.scale.getLabel({value:Math.round(r)}):r.toFixed(Math.min(o,20));return xe(i)?i(r,s):se(i)?i.replace("{value}",s):s},t.prototype._showDataInfo=function(r){var n=this.dataZoomModel.get("handleLabel")||{},a=n.show||!1,i=this.dataZoomModel.getModel(["emphasis","handleLabel"]),o=i.get("show")||!1,s=r||this._dragging?o:a,l=this._displayables,u=l.handleLabels;u[0].attr("invisible",!s),u[1].attr("invisible",!s),l.moveHandle&&this.api[s?"enterEmphasis":"leaveEmphasis"](l.moveHandle,1)},t.prototype._onDragMove=function(r,n,a,i){this._dragging=!0,hl(i.event);var o=this._displayables.sliderGroup.getLocalTransform(),s=so([n,a],o,!0),l=this._updateInterval(r,s[0]),u=this.dataZoomModel.get("realtime");this._updateView(!u),l&&u&&this._dispatchZoomAction(!0)},t.prototype._onDragEnd=function(){this._dragging=!1,this._showDataInfo(!1);var r=this.dataZoomModel.get("realtime");!r&&this._dispatchZoomAction(!1)},t.prototype._onClickPanel=function(r){var n=this._size,a=this._displayables.sliderGroup.transformCoordToLocal(r.offsetX,r.offsetY);if(!(a[0]<0||a[0]>n[0]||a[1]<0||a[1]>n[1])){var i=this._handleEnds,o=(i[0]+i[1])/2,s=this._updateInterval("all",a[0]-o);this._updateView(),s&&this._dispatchZoomAction(!1)}},t.prototype._onBrushStart=function(r){var n=r.offsetX,a=r.offsetY;this._brushStart=new ke(n,a),this._brushing=!0,this._brushStartTime=+new Date},t.prototype._onBrushEnd=function(r){if(this._brushing){var n=this._displayables.brushRect;if(this._brushing=!1,!!n){n.attr("ignore",!0);var a=n.shape,i=+new Date;if(!(i-this._brushStartTime<200&&Math.abs(a.width)<5)){var o=this._getViewExtent(),s=[0,100],l=this._handleEnds=[a.x,a.x+a.width],u=this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();Vu(0,l,o,0,u.minSpan!=null?vt(u.minSpan,s,o,!0):null,u.maxSpan!=null?vt(u.maxSpan,s,o,!0):null),this._range=Ia([vt(l[0],o,s,!0),vt(l[1],o,s,!0)]),this._updateView(),this._dispatchZoomAction(!1)}}}},t.prototype._onBrush=function(r){this._brushing&&(hl(r.event),this._updateBrushRect(r.offsetX,r.offsetY))},t.prototype._updateBrushRect=function(r,n){var a=this._displayables,i=this.dataZoomModel,o=a.brushRect;o||(o=a.brushRect=new cy({silent:!0,style:i.getModel("brushStyle").getItemStyle()}),a.sliderGroup.add(o)),o.attr("ignore",!1);var s=this._brushStart,l=this._displayables.sliderGroup,u=l.transformCoordToLocal(r,n),c=l.transformCoordToLocal(s.x,s.y),f=this._size;u[0]=Math.max(Math.min(f[0],u[0]),0),o.setShape({x:c[0],y:0,width:u[0]-c[0],height:f[1]})},t.prototype._dispatchZoomAction=function(r){var n=this._range;this.api.dispatchAction({type:"dataZoom",from:this.uid,dataZoomId:this.dataZoomModel.id,animation:r?$ut:null,start:n[0],end:n[1]})},t.prototype._findCoordRect=function(){var r,n=Que(this.dataZoomModel).infoList;if(!r&&n.length){var a=n[0].model.coordinateSystem;r=a.getRect&&a.getRect()}if(!r){var i=this.api.getWidth(),o=this.api.getHeight();r={x:i*.2,y:o*.2,width:i*.6,height:o*.6}}return r},t.type="dataZoom.slider",t}(lB);function Vut(e){var t={x:"y",y:"x",radius:"angle",angle:"radius"};return t[e]}function Wut(e){return e==="vertical"?"ns-resize":"ew-resize"}function xce(e){e.registerComponentModel(Iut),e.registerComponentView(Fut),uB(e)}function Hut(e){We(mce),We(xce)}var bce={get:function(e,t,r){var n=be((Gut[e]||{})[t]);return r&&te(n)?n[n.length-1]:n}},Gut={color:{active:["#006edd","#e0ffff"],inactive:[Y.color.transparent]},colorHue:{active:[0,360],inactive:[0,0]},colorSaturation:{active:[.3,1],inactive:[0,0]},colorLightness:{active:[.9,.5],inactive:[0,0]},colorAlpha:{active:[.3,1],inactive:[0,0]},opacity:{active:[.3,1],inactive:[0,0]},symbol:{active:["circle","roundRect","diamond"],inactive:["none"]},symbolSize:{active:[10,50],inactive:[0,0]}},QY=Gr.mapVisual,Uut=Gr.eachVisual,Yut=te,eX=O,Xut=Ia,qut=vt,iT=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r.stateList=["inRange","outOfRange"],r.replacableOptionKeys=["inRange","outOfRange","target","controller","color"],r.layoutMode={type:"box",ignoreSize:!0},r.dataBound=[-1/0,1/0],r.targetVisuals={},r.controllerVisuals={},r}return t.prototype.init=function(r,n,a){this.mergeDefaultAndTheme(r,a)},t.prototype.optionUpdated=function(r,n){var a=this.option;!n&&uce(a,r,this.replacableOptionKeys),this.textStyleModel=this.getModel("textStyle"),this.resetItemSize(),this.completeVisualOption()},t.prototype.resetVisual=function(r){var n=this.stateList;r=ue(r,this),this.controllerVisuals=PI(this.option.controller,n,r),this.targetVisuals=PI(this.option.target,n,r)},t.prototype.getItemSymbol=function(){return null},t.prototype.getTargetSeriesIndices=function(){var r=this.option.seriesId,n=this.option.seriesIndex;n==null&&r==null&&(n="all");var a=Wv(this.ecModel,"series",{index:n,id:r},{useDefault:!1,enableAll:!0,enableNone:!1}).models;return ne(a,function(i){return i.componentIndex})},t.prototype.eachTargetSeries=function(r,n){O(this.getTargetSeriesIndices(),function(a){var i=this.ecModel.getSeriesByIndex(a);i&&r.call(n,i)},this)},t.prototype.isTargetSeries=function(r){var n=!1;return this.eachTargetSeries(function(a){a===r&&(n=!0)}),n},t.prototype.formatValueText=function(r,n,a){var i=this.option,o=i.precision,s=this.dataBound,l=i.formatter,u;a=a||["<",">"],te(r)&&(r=r.slice(),u=!0);var c=n?r:u?[f(r[0]),f(r[1])]:f(r);if(se(l))return l.replace("{value}",u?c[0]:c).replace("{value2}",u?c[1]:c);if(xe(l))return u?l(r[0],r[1]):l(r);if(u)return r[0]===s[0]?a[0]+" "+c[1]:r[1]===s[1]?a[1]+" "+c[0]:c[0]+" - "+c[1];return c;function f(d){return d===s[0]?"min":d===s[1]?"max":(+d).toFixed(Math.min(o,20))}},t.prototype.resetExtent=function(){var r=this.option,n=Xut([r.min,r.max]);this._dataExtent=n},t.prototype.getDataDimensionIndex=function(r){var n=this.option.dimension;if(n!=null)return r.getDimensionIndex(n);for(var a=r.dimensions,i=a.length-1;i>=0;i--){var o=a[i],s=r.getDimensionInfo(o);if(!s.isCalculationCoord)return s.storeDimIndex}},t.prototype.getExtent=function(){return this._dataExtent.slice()},t.prototype.completeVisualOption=function(){var r=this.ecModel,n=this.option,a={inRange:n.inRange,outOfRange:n.outOfRange},i=n.target||(n.target={}),o=n.controller||(n.controller={});Fe(i,a),Fe(o,a);var s=this.isCategory();l.call(this,i),l.call(this,o),u.call(this,i,"inRange","outOfRange"),c.call(this,o);function l(f){Yut(n.color)&&!f.inRange&&(f.inRange={color:n.color.slice().reverse()}),f.inRange=f.inRange||{color:r.get("gradientColor")}}function u(f,d,h){var p=f[d],v=f[h];p&&!v&&(v=f[h]={},eX(p,function(g,y){if(Gr.isValidType(y)){var m=bce.get(y,"inactive",s);m!=null&&(v[y]=m,y==="color"&&!v.hasOwnProperty("opacity")&&!v.hasOwnProperty("colorAlpha")&&(v.opacity=[0,0]))}}))}function c(f){var d=(f.inRange||{}).symbol||(f.outOfRange||{}).symbol,h=(f.inRange||{}).symbolSize||(f.outOfRange||{}).symbolSize,p=this.get("inactiveColor"),v=this.getItemSymbol(),g=v||"roundRect";eX(this.stateList,function(y){var m=this.itemSize,b=f[y];b||(b=f[y]={color:s?p:[p]}),b.symbol==null&&(b.symbol=d&&be(d)||(s?g:[g])),b.symbolSize==null&&(b.symbolSize=h&&be(h)||(s?m[0]:[m[0],m[0]])),b.symbol=QY(b.symbol,function(S){return S==="none"?g:S});var w=b.symbolSize;if(w!=null){var _=-1/0;Uut(w,function(S){S>_&&(_=S)}),b.symbolSize=QY(w,function(S){return qut(S,[0,_],[0,m[0]],!0)})}},this)}},t.prototype.resetItemSize=function(){this.itemSize=[parseFloat(this.get("itemWidth")),parseFloat(this.get("itemHeight"))]},t.prototype.isCategory=function(){return!!this.option.categories},t.prototype.setSelected=function(r){},t.prototype.getSelected=function(){return null},t.prototype.getValueState=function(r){return null},t.prototype.getVisualMeta=function(r){return null},t.type="visualMap",t.dependencies=["series"],t.defaultOption={show:!0,z:4,min:0,max:200,left:0,right:null,top:null,bottom:0,itemWidth:null,itemHeight:null,inverse:!1,orient:"vertical",backgroundColor:Y.color.transparent,borderColor:Y.color.borderTint,contentColor:Y.color.theme[0],inactiveColor:Y.color.disabled,borderWidth:0,padding:Y.size.m,textGap:10,precision:0,textStyle:{color:Y.color.secondary}},t}(Ye),tX=[20,140],Kut=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r}return t.prototype.optionUpdated=function(r,n){e.prototype.optionUpdated.apply(this,arguments),this.resetExtent(),this.resetVisual(function(a){a.mappingMethod="linear",a.dataExtent=this.getExtent()}),this._resetRange()},t.prototype.resetItemSize=function(){e.prototype.resetItemSize.apply(this,arguments);var r=this.itemSize;(r[0]==null||isNaN(r[0]))&&(r[0]=tX[0]),(r[1]==null||isNaN(r[1]))&&(r[1]=tX[1])},t.prototype._resetRange=function(){var r=this.getExtent(),n=this.option.range;!n||n.auto?(r.auto=1,this.option.range=r):te(n)&&(n[0]>n[1]&&n.reverse(),n[0]=Math.max(n[0],r[0]),n[1]=Math.min(n[1],r[1]))},t.prototype.completeVisualOption=function(){e.prototype.completeVisualOption.apply(this,arguments),O(this.stateList,function(r){var n=this.option.controller[r].symbolSize;n&&n[0]!==n[1]&&(n[0]=n[1]/3)},this)},t.prototype.setSelected=function(r){this.option.range=r.slice(),this._resetRange()},t.prototype.getSelected=function(){var r=this.getExtent(),n=Ia((this.get("range")||[]).slice());return n[0]>r[1]&&(n[0]=r[1]),n[1]>r[1]&&(n[1]=r[1]),n[0]<r[0]&&(n[0]=r[0]),n[1]<r[0]&&(n[1]=r[0]),n},t.prototype.getValueState=function(r){var n=this.option.range,a=this.getExtent(),i=ge(this.option.unboundedRange,!0);return(i&&n[0]<=a[0]||n[0]<=r)&&(i&&n[1]>=a[1]||r<=n[1])?"inRange":"outOfRange"},t.prototype.findTargetDataIndices=function(r){var n=[];return this.eachTargetSeries(function(a){var i=[],o=a.getData();o.each(this.getDataDimensionIndex(o),function(s,l){r[0]<=s&&s<=r[1]&&i.push(l)},this),n.push({seriesId:a.id,dataIndex:i})},this),n},t.prototype.getVisualMeta=function(r){var n=rX(this,"outOfRange",this.getExtent()),a=rX(this,"inRange",this.option.range.slice()),i=[];function o(h,p){i.push({value:h,color:r(h,p)})}for(var s=0,l=0,u=a.length,c=n.length;l<c&&(!a.length||n[l]<=a[0]);l++)n[l]<a[s]&&o(n[l],"outOfRange");for(var f=1;s<u;s++,f=0)f&&i.length&&o(a[s],"outOfRange"),o(a[s],"inRange");for(var f=1;l<c;l++)(!a.length||a[a.length-1]<n[l])&&(f&&(i.length&&o(i[i.length-1].value,"outOfRange"),f=0),o(n[l],"outOfRange"));var d=i.length;return{stops:i,outerColors:[d?i[0].color:"transparent",d?i[d-1].color:"transparent"]}},t.type="visualMap.continuous",t.defaultOption=ac(iT.defaultOption,{align:"auto",calculable:!1,hoverLink:!0,realtime:!0,handleIcon:"path://M-11.39,9.77h0a3.5,3.5,0,0,1-3.5,3.5h-22a3.5,3.5,0,0,1-3.5-3.5h0a3.5,3.5,0,0,1,3.5-3.5h22A3.5,3.5,0,0,1-11.39,9.77Z",handleSize:"120%",handleStyle:{borderColor:Y.color.neutral00,borderWidth:1},indicatorIcon:"circle",indicatorSize:"50%",indicatorStyle:{borderColor:Y.color.neutral00,borderWidth:2,shadowBlur:2,shadowOffsetX:1,shadowOffsetY:1,shadowColor:Y.color.shadow}}),t}(iT);function rX(e,t,r){if(r[0]===r[1])return r.slice();for(var n=200,a=(r[1]-r[0])/n,i=r[0],o=[],s=0;s<=n&&i<r[1];s++)o.push(i),i+=a;return o.push(r[1]),o}var wce=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r.autoPositionValues={left:1,right:1,top:1,bottom:1},r}return t.prototype.init=function(r,n){this.ecModel=r,this.api=n},t.prototype.render=function(r,n,a,i){if(this.visualMapModel=r,r.get("show")===!1){this.group.removeAll();return}this.doRender(r,n,a,i)},t.prototype.renderBackground=function(r){var n=this.visualMapModel,a=Zv(n.get("padding")||0),i=r.getBoundingRect();r.add(new Ge({z2:-1,silent:!0,shape:{x:i.x-a[3],y:i.y-a[0],width:i.width+a[3]+a[1],height:i.height+a[0]+a[2]},style:{fill:n.get("backgroundColor"),stroke:n.get("borderColor"),lineWidth:n.get("borderWidth")}}))},t.prototype.getControllerVisual=function(r,n,a){a=a||{};var i=a.forceState,o=this.visualMapModel,s={};if(n==="color"){var l=o.get("contentColor");s.color=l}function u(h){return s[h]}function c(h,p){s[h]=p}var f=o.controllerVisuals[i||o.getValueState(r)],d=Gr.prepareVisualTypes(f);return O(d,function(h){var p=f[h];a.convertOpacityToAlpha&&h==="opacity"&&(h="colorAlpha",p=f.__alphaForOpacity),Gr.dependsOn(h,n)&&p&&p.applyVisual(r,u,c)}),s[n]},t.prototype.positionGroup=function(r){var n=this.visualMapModel,a=this.api,i=Lr(n,a).refContainer;oA(r,n.getBoxLayoutParams(),i)},t.prototype.doRender=function(r,n,a,i){},t.type="visualMap",t}(Et),nX=[["left","right","width"],["top","bottom","height"]];function _ce(e,t,r){var n=e.option,a=n.align;if(a!=null&&a!=="auto")return a;for(var i={width:t.getWidth(),height:t.getHeight()},o=n.orient==="horizontal"?1:0,s=nX[o],l=[0,null,10],u={},c=0;c<3;c++)u[nX[1-o][c]]=l[c],u[s[c]]=c===2?r[0]:n[s[c]];var f=[["x","width",3],["y","height",0]][o],d=Ft(u,i,n.padding);return s[(d.margin[f[2]]||0)+d[f[0]]+d[f[1]]*.5<i[f[1]]*.5?0:1]}function f_(e,t){return O(e||[],function(r){r.dataIndex!=null&&(r.dataIndexInside=r.dataIndex,r.dataIndex=null),r.highlightKey="visualMap"+(t?t.componentIndex:"")}),e}var Do=vt,Zut=O,aX=Math.min,_D=Math.max,Jut=12,Qut=6,ect=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r._shapes={},r._dataInterval=[],r._handleEnds=[],r._hoverLinkDataIndices=[],r}return t.prototype.init=function(r,n){e.prototype.init.call(this,r,n),this._hoverLinkFromSeriesMouseOver=ue(this._hoverLinkFromSeriesMouseOver,this),this._hideIndicator=ue(this._hideIndicator,this)},t.prototype.doRender=function(r,n,a,i){(!i||i.type!=="selectDataRange"||i.from!==this.uid)&&this._buildView()},t.prototype._buildView=function(){this.group.removeAll();var r=this.visualMapModel,n=this.group;this._orient=r.get("orient"),this._useHandle=r.get("calculable"),this._resetInterval(),this._renderBar(n);var a=r.get("text");this._renderEndsText(n,a,0),this._renderEndsText(n,a,1),this._updateView(!0),this.renderBackground(n),this._updateView(),this._enableHoverLinkToSeries(),this._enableHoverLinkFromSeries(),this.positionGroup(n)},t.prototype._renderEndsText=function(r,n,a){if(n){var i=n[1-a];i=i!=null?i+"":"";var o=this.visualMapModel,s=o.get("textGap"),l=o.itemSize,u=this._shapes.mainGroup,c=this._applyTransform([l[0]/2,a===0?-s:l[1]+s],u),f=this._applyTransform(a===0?"bottom":"top",u),d=this._orient,h=this.visualMapModel.textStyleModel;this.group.add(new at({style:Pt(h,{x:c[0],y:c[1],verticalAlign:h.get("verticalAlign")||(d==="horizontal"?"middle":f),align:h.get("align")||(d==="horizontal"?f:"center"),text:i})}))}},t.prototype._renderBar=function(r){var n=this.visualMapModel,a=this._shapes,i=n.itemSize,o=this._orient,s=this._useHandle,l=_ce(n,this.api,i),u=a.mainGroup=this._createBarGroup(l),c=new we;u.add(c),c.add(a.outOfRange=iX()),c.add(a.inRange=iX(null,s?sX(this._orient):null,ue(this._dragHandle,this,"all",!1),ue(this._dragHandle,this,"all",!0))),c.setClipPath(new Ge({shape:{x:0,y:0,width:i[0],height:i[1],r:3}}));var f=n.textStyleModel.getTextRect("国"),d=_D(f.width,f.height);s&&(a.handleThumbs=[],a.handleLabels=[],a.handleLabelPoints=[],this._createHandle(n,u,0,i,d,o),this._createHandle(n,u,1,i,d,o)),this._createIndicator(n,u,i,d,o),r.add(u)},t.prototype._createHandle=function(r,n,a,i,o,s){var l=ue(this._dragHandle,this,a,!1),u=ue(this._dragHandle,this,a,!0),c=ho(r.get("handleSize"),i[0]),f=xr(r.get("handleIcon"),-c/2,-c/2,c,c,null,!0),d=sX(this._orient);f.attr({cursor:d,draggable:!0,drift:l,ondragend:u,onmousemove:function(y){hl(y.event)}}),f.x=i[0]/2,f.useStyle(r.getModel("handleStyle").getItemStyle()),f.setStyle({strokeNoScale:!0,strokeFirst:!0}),f.style.lineWidth*=2,f.ensureState("emphasis").style=r.getModel(["emphasis","handleStyle"]).getItemStyle(),mf(f,!0),n.add(f);var h=this.visualMapModel.textStyleModel,p=new at({cursor:d,draggable:!0,drift:l,onmousemove:function(y){hl(y.event)},ondragend:u,style:Pt(h,{x:0,y:0,text:""})});p.ensureState("blur").style={opacity:.1},p.stateTransition={duration:200},this.group.add(p);var v=[c,0],g=this._shapes;g.handleThumbs[a]=f,g.handleLabelPoints[a]=v,g.handleLabels[a]=p},t.prototype._createIndicator=function(r,n,a,i,o){var s=ho(r.get("indicatorSize"),a[0]),l=xr(r.get("indicatorIcon"),-s/2,-s/2,s,s,null,!0);l.attr({cursor:"move",invisible:!0,silent:!0,x:a[0]/2});var u=r.getModel("indicatorStyle").getItemStyle();if(l instanceof Xr){var c=l.style;l.useStyle(J({image:c.image,x:c.x,y:c.y,width:c.width,height:c.height},u))}else l.useStyle(u);n.add(l);var f=this.visualMapModel.textStyleModel,d=new at({silent:!0,invisible:!0,style:Pt(f,{x:0,y:0,text:""})});this.group.add(d);var h=[(o==="horizontal"?i/2:Qut)+a[0]/2,0],p=this._shapes;p.indicator=l,p.indicatorLabel=d,p.indicatorLabelPoint=h,this._firstShowIndicator=!0},t.prototype._dragHandle=function(r,n,a,i){if(this._useHandle){if(this._dragging=!n,!n){var o=this._applyTransform([a,i],this._shapes.mainGroup,!0);this._updateInterval(r,o[1]),this._hideIndicator(),this._updateView()}n===!this.visualMapModel.get("realtime")&&this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:this._dataInterval.slice()}),n?!this._hovering&&this._clearHoverLinkToSeries():oX(this.visualMapModel)&&this._doHoverLinkToSeries(this._handleEnds[r],!1)}},t.prototype._resetInterval=function(){var r=this.visualMapModel,n=this._dataInterval=r.getSelected(),a=r.getExtent(),i=[0,r.itemSize[1]];this._handleEnds=[Do(n[0],a,i,!0),Do(n[1],a,i,!0)]},t.prototype._updateInterval=function(r,n){n=n||0;var a=this.visualMapModel,i=this._handleEnds,o=[0,a.itemSize[1]];Vu(n,i,o,r,0);var s=a.getExtent();this._dataInterval=[Do(i[0],o,s,!0),Do(i[1],o,s,!0)]},t.prototype._updateView=function(r){var n=this.visualMapModel,a=n.getExtent(),i=this._shapes,o=[0,n.itemSize[1]],s=r?o:this._handleEnds,l=this._createBarVisual(this._dataInterval,a,s,"inRange"),u=this._createBarVisual(a,a,o,"outOfRange");i.inRange.setStyle({fill:l.barColor}).setShape("points",l.barPoints),i.outOfRange.setStyle({fill:u.barColor}).setShape("points",u.barPoints),this._updateHandle(s,l)},t.prototype._createBarVisual=function(r,n,a,i){var o={forceState:i,convertOpacityToAlpha:!0},s=this._makeColorGradient(r,o),l=[this.getControllerVisual(r[0],"symbolSize",o),this.getControllerVisual(r[1],"symbolSize",o)],u=this._createBarPoints(a,l);return{barColor:new xd(0,0,0,1,s),barPoints:u,handlesColor:[s[0].color,s[s.length-1].color]}},t.prototype._makeColorGradient=function(r,n){var a=100,i=[],o=(r[1]-r[0])/a;i.push({color:this.getControllerVisual(r[0],"color",n),offset:0});for(var s=1;s<a;s++){var l=r[0]+o*s;if(l>r[1])break;i.push({color:this.getControllerVisual(l,"color",n),offset:s/a})}return i.push({color:this.getControllerVisual(r[1],"color",n),offset:1}),i},t.prototype._createBarPoints=function(r,n){var a=this.visualMapModel.itemSize;return[[a[0]-n[0],r[0]],[a[0],r[0]],[a[0],r[1]],[a[0]-n[1],r[1]]]},t.prototype._createBarGroup=function(r){var n=this._orient,a=this.visualMapModel.get("inverse");return new we(n==="horizontal"&&!a?{scaleX:r==="bottom"?1:-1,rotation:Math.PI/2}:n==="horizontal"&&a?{scaleX:r==="bottom"?-1:1,rotation:-Math.PI/2}:n==="vertical"&&!a?{scaleX:r==="left"?1:-1,scaleY:-1}:{scaleX:r==="left"?1:-1})},t.prototype._updateHandle=function(r,n){if(this._useHandle){var a=this._shapes,i=this.visualMapModel,o=a.handleThumbs,s=a.handleLabels,l=i.itemSize,u=i.getExtent(),c=this._applyTransform("left",a.mainGroup);Zut([0,1],function(f){var d=o[f];d.setStyle("fill",n.handlesColor[f]),d.y=r[f];var h=Do(r[f],[0,l[1]],u,!0),p=this.getControllerVisual(h,"symbolSize");d.scaleX=d.scaleY=p/l[0],d.x=l[0]-p/2;var v=so(a.handleLabelPoints[f],Eu(d,this.group));if(this._orient==="horizontal"){var g=c==="left"||c==="top"?(l[0]-p)/2:(l[0]-p)/-2;v[1]+=g}s[f].setStyle({x:v[0],y:v[1],text:i.formatValueText(this._dataInterval[f]),verticalAlign:"middle",align:this._orient==="vertical"?this._applyTransform("left",a.mainGroup):"center"})},this)}},t.prototype._showIndicator=function(r,n,a,i){var o=this.visualMapModel,s=o.getExtent(),l=o.itemSize,u=[0,l[1]],c=this._shapes,f=c.indicator;if(f){f.attr("invisible",!1);var d={convertOpacityToAlpha:!0},h=this.getControllerVisual(r,"color",d),p=this.getControllerVisual(r,"symbolSize"),v=Do(r,s,u,!0),g=l[0]-p/2,y={x:f.x,y:f.y};f.y=v,f.x=g;var m=so(c.indicatorLabelPoint,Eu(f,this.group)),b=c.indicatorLabel;b.attr("invisible",!1);var w=this._applyTransform("left",c.mainGroup),_=this._orient,S=_==="horizontal";b.setStyle({text:(a||"")+o.formatValueText(n),verticalAlign:S?w:"middle",align:S?"center":w});var C={x:g,y:v,style:{fill:h}},T={style:{x:m[0],y:m[1]}};if(o.ecModel.isAnimationEnabled()&&!this._firstShowIndicator){var A={duration:100,easing:"cubicInOut",additive:!0};f.x=y.x,f.y=y.y,f.animateTo(C,A),b.animateTo(T,A)}else f.attr(C),b.attr(T);this._firstShowIndicator=!1;var k=this._shapes.handleLabels;if(k)for(var P=0;P<k.length;P++)this.api.enterBlur(k[P])}},t.prototype._enableHoverLinkToSeries=function(){var r=this;this._shapes.mainGroup.on("mousemove",function(n){if(r._hovering=!0,!r._dragging){var a=r.visualMapModel.itemSize,i=r._applyTransform([n.offsetX,n.offsetY],r._shapes.mainGroup,!0,!0);i[1]=aX(_D(0,i[1]),a[1]),r._doHoverLinkToSeries(i[1],0<=i[0]&&i[0]<=a[0])}}).on("mouseout",function(){r._hovering=!1,!r._dragging&&r._clearHoverLinkToSeries()})},t.prototype._enableHoverLinkFromSeries=function(){var r=this.api.getZr();this.visualMapModel.option.hoverLink?(r.on("mouseover",this._hoverLinkFromSeriesMouseOver,this),r.on("mouseout",this._hideIndicator,this)):this._clearHoverLinkFromSeries()},t.prototype._doHoverLinkToSeries=function(r,n){var a=this.visualMapModel,i=a.itemSize;if(a.option.hoverLink){var o=[0,i[1]],s=a.getExtent();r=aX(_D(o[0],r),o[1]);var l=tct(a,s,o),u=[r-l,r+l],c=Do(r,o,s,!0),f=[Do(u[0],o,s,!0),Do(u[1],o,s,!0)];u[0]<o[0]&&(f[0]=-1/0),u[1]>o[1]&&(f[1]=1/0),n&&(f[0]===-1/0?this._showIndicator(c,f[1],"< ",l):f[1]===1/0?this._showIndicator(c,f[0],"> ",l):this._showIndicator(c,c,"≈ ",l));var d=this._hoverLinkDataIndices,h=[];(n||oX(a))&&(h=this._hoverLinkDataIndices=a.findTargetDataIndices(f));var p=NGe(d,h);this._dispatchHighDown("downplay",f_(p[0],a)),this._dispatchHighDown("highlight",f_(p[1],a))}},t.prototype._hoverLinkFromSeriesMouseOver=function(r){var n;if(bf(r.target,function(l){var u=Ee(l);if(u.dataIndex!=null)return n=u,!0},!0),!!n){var a=this.ecModel.getSeriesByIndex(n.seriesIndex),i=this.visualMapModel;if(i.isTargetSeries(a)){var o=a.getData(n.dataType),s=o.getStore().get(i.getDataDimensionIndex(o),n.dataIndex);isNaN(s)||this._showIndicator(s,s)}}},t.prototype._hideIndicator=function(){var r=this._shapes;r.indicator&&r.indicator.attr("invisible",!0),r.indicatorLabel&&r.indicatorLabel.attr("invisible",!0);var n=this._shapes.handleLabels;if(n)for(var a=0;a<n.length;a++)this.api.leaveBlur(n[a])},t.prototype._clearHoverLinkToSeries=function(){this._hideIndicator();var r=this._hoverLinkDataIndices;this._dispatchHighDown("downplay",f_(r,this.visualMapModel)),r.length=0},t.prototype._clearHoverLinkFromSeries=function(){this._hideIndicator();var r=this.api.getZr();r.off("mouseover",this._hoverLinkFromSeriesMouseOver),r.off("mouseout",this._hideIndicator)},t.prototype._applyTransform=function(r,n,a,i){var o=Eu(n,i?null:this.group);return te(r)?so(r,o,a):nA(r,o,a)},t.prototype._dispatchHighDown=function(r,n){n&&n.length&&this.api.dispatchAction({type:r,batch:n})},t.prototype.dispose=function(){this._clearHoverLinkFromSeries(),this._clearHoverLinkToSeries()},t.type="visualMap.continuous",t}(wce);function iX(e,t,r,n){return new _n({shape:{points:e},draggable:!!r,cursor:t,drift:r,onmousemove:function(a){hl(a.event)},ondragend:n})}function tct(e,t,r){var n=Jut/2,a=e.get("hoverLinkDataSize");return a&&(n=Do(a,t,r,!0)/2),n}function oX(e){var t=e.get("hoverLinkOnHandle");return!!(t??e.get("realtime"))}function sX(e){return e==="vertical"?"ns-resize":"ew-resize"}var rct={type:"selectDataRange",event:"dataRangeSelected",update:"update"},nct=function(e,t){t.eachComponent({mainType:"visualMap",query:e},function(r){r.setSelected(e.selected)})},act=[{createOnAllSeries:!0,reset:function(e,t){var r=[];return t.eachComponent("visualMap",function(n){var a=e.pipelineContext;!n.isTargetSeries(e)||a&&a.large||r.push(Tlt(n.stateList,n.targetVisuals,ue(n.getValueState,n),n.getDataDimensionIndex(e.getData())))}),r}},{createOnAllSeries:!0,reset:function(e,t){var r=e.getData(),n=[];t.eachComponent("visualMap",function(a){if(a.isTargetSeries(e)){var i=a.getVisualMeta(ue(ict,null,e,a))||{stops:[],outerColors:[]},o=a.getDataDimensionIndex(r);o>=0&&(i.dimension=o,n.push(i))}}),e.getData().setVisual("visualMeta",n)}}];function ict(e,t,r,n){for(var a=t.targetVisuals[n],i=Gr.prepareVisualTypes(a),o={color:tb(e.getData(),"color")},s=0,l=i.length;s<l;s++){var u=i[s],c=a[u==="opacity"?"__alphaForOpacity":u];c&&c.applyVisual(r,f,d)}return o.color;function f(h){return o[h]}function d(h,p){o[h]=p}}var lX=O;function oct(e){var t=e&&e.visualMap;te(t)||(t=t?[t]:[]),lX(t,function(r){if(r){sh(r,"splitList")&&!sh(r,"pieces")&&(r.pieces=r.splitList,delete r.splitList);var n=r.pieces;n&&te(n)&&lX(n,function(a){Ce(a)&&(sh(a,"start")&&!sh(a,"min")&&(a.min=a.start),sh(a,"end")&&!sh(a,"max")&&(a.max=a.end))})}})}function sh(e,t){return e&&e.hasOwnProperty&&e.hasOwnProperty(t)}var uX=!1;function Sce(e){uX||(uX=!0,e.registerSubTypeDefaulter("visualMap",function(t){return!t.categories&&(!(t.pieces?t.pieces.length>0:t.splitNumber>0)||t.calculable)?"continuous":"piecewise"}),e.registerAction(rct,nct),O(act,function(t){e.registerVisual(e.PRIORITY.VISUAL.COMPONENT,t)}),e.registerPreprocessor(oct))}function Cce(e){e.registerComponentModel(Kut),e.registerComponentView(ect),Sce(e)}var sct=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r._pieceList=[],r}return t.prototype.optionUpdated=function(r,n){e.prototype.optionUpdated.apply(this,arguments),this.resetExtent();var a=this._mode=this._determineMode();this._pieceList=[],lct[this._mode].call(this,this._pieceList),this._resetSelected(r,n);var i=this.option.categories;this.resetVisual(function(o,s){a==="categories"?(o.mappingMethod="category",o.categories=be(i)):(o.dataExtent=this.getExtent(),o.mappingMethod="piecewise",o.pieceList=ne(this._pieceList,function(l){return l=be(l),s!=="inRange"&&(l.visual=null),l}))})},t.prototype.completeVisualOption=function(){var r=this.option,n={},a=Gr.listVisualTypes(),i=this.isCategory();O(r.pieces,function(s){O(a,function(l){s.hasOwnProperty(l)&&(n[l]=1)})}),O(n,function(s,l){var u=!1;O(this.stateList,function(c){u=u||o(r,c,l)||o(r.target,c,l)},this),!u&&O(this.stateList,function(c){(r[c]||(r[c]={}))[l]=bce.get(l,c==="inRange"?"active":"inactive",i)})},this);function o(s,l,u){return s&&s[l]&&s[l].hasOwnProperty(u)}e.prototype.completeVisualOption.apply(this,arguments)},t.prototype._resetSelected=function(r,n){var a=this.option,i=this._pieceList,o=(n?a:r).selected||{};if(a.selected=o,O(i,function(l,u){var c=this.getSelectedMapKey(l);o.hasOwnProperty(c)||(o[c]=!0)},this),a.selectedMode==="single"){var s=!1;O(i,function(l,u){var c=this.getSelectedMapKey(l);o[c]&&(s?o[c]=!1:s=!0)},this)}},t.prototype.getItemSymbol=function(){return this.get("itemSymbol")},t.prototype.getSelectedMapKey=function(r){return this._mode==="categories"?r.value+"":r.index+""},t.prototype.getPieceList=function(){return this._pieceList},t.prototype._determineMode=function(){var r=this.option;return r.pieces&&r.pieces.length>0?"pieces":this.option.categories?"categories":"splitNumber"},t.prototype.setSelected=function(r){this.option.selected=be(r)},t.prototype.getValueState=function(r){var n=Gr.findPieceIndex(r,this._pieceList);return n!=null&&this.option.selected[this.getSelectedMapKey(this._pieceList[n])]?"inRange":"outOfRange"},t.prototype.findTargetDataIndices=function(r){var n=[],a=this._pieceList;return this.eachTargetSeries(function(i){var o=[],s=i.getData();s.each(this.getDataDimensionIndex(s),function(l,u){var c=Gr.findPieceIndex(l,a);c===r&&o.push(u)},this),n.push({seriesId:i.id,dataIndex:o})},this),n},t.prototype.getRepresentValue=function(r){var n;if(this.isCategory())n=r.value;else if(r.value!=null)n=r.value;else{var a=r.interval||[];n=a[0]===-1/0&&a[1]===1/0?0:(a[0]+a[1])/2}return n},t.prototype.getVisualMeta=function(r){if(this.isCategory())return;var n=[],a=["",""],i=this;function o(c,f){var d=i.getRepresentValue({interval:c});f||(f=i.getValueState(d));var h=r(d,f);c[0]===-1/0?a[0]=h:c[1]===1/0?a[1]=h:n.push({value:c[0],color:h},{value:c[1],color:h})}var s=this._pieceList.slice();if(!s.length)s.push({interval:[-1/0,1/0]});else{var l=s[0].interval[0];l!==-1/0&&s.unshift({interval:[-1/0,l]}),l=s[s.length-1].interval[1],l!==1/0&&s.push({interval:[l,1/0]})}var u=-1/0;return O(s,function(c){var f=c.interval;f&&(f[0]>u&&o([u,f[0]],"outOfRange"),o(f.slice()),u=f[1])},this),{stops:n,outerColors:a}},t.type="visualMap.piecewise",t.defaultOption=ac(iT.defaultOption,{selected:null,minOpen:!1,maxOpen:!1,align:"auto",itemWidth:20,itemHeight:14,itemSymbol:"roundRect",pieces:null,categories:null,splitNumber:5,selectedMode:"multiple",itemGap:10,hoverLink:!0}),t}(iT),lct={splitNumber:function(e){var t=this.option,r=Math.min(t.precision,20),n=this.getExtent(),a=t.splitNumber;a=Math.max(parseInt(a,10),1),t.splitNumber=a;for(var i=(n[1]-n[0])/a;+i.toFixed(r)!==i&&r<5;)r++;t.precision=r,i=+i.toFixed(r),t.minOpen&&e.push({interval:[-1/0,n[0]],close:[0,0]});for(var o=0,s=n[0];o<a;s+=i,o++){var l=o===a-1?n[1]:s+i;e.push({interval:[s,l],close:[1,1]})}t.maxOpen&&e.push({interval:[n[1],1/0],close:[0,0]}),eL(e),O(e,function(u,c){u.index=c,u.text=this.formatValueText(u.interval)},this)},categories:function(e){var t=this.option;O(t.categories,function(r){e.push({text:this.formatValueText(r,!0),value:r})},this),cX(t,e)},pieces:function(e){var t=this.option;O(t.pieces,function(r,n){Ce(r)||(r={value:r});var a={text:"",index:n};if(r.label!=null&&(a.text=r.label),r.hasOwnProperty("value")){var i=a.value=r.value;a.interval=[i,i],a.close=[1,1]}else{for(var o=a.interval=[],s=a.close=[0,0],l=[1,0,1],u=[-1/0,1/0],c=[],f=0;f<2;f++){for(var d=[["gte","gt","min"],["lte","lt","max"]][f],h=0;h<3&&o[f]==null;h++)o[f]=r[d[h]],s[f]=l[h],c[f]=h===2;o[f]==null&&(o[f]=u[f])}c[0]&&o[1]===1/0&&(s[0]=0),c[1]&&o[0]===-1/0&&(s[1]=0),o[0]===o[1]&&s[0]&&s[1]&&(a.value=o[0])}a.visual=Gr.retrieveVisuals(r),e.push(a)},this),cX(t,e),eL(e),O(e,function(r){var n=r.close,a=[["<","≤"][n[1]],[">","≥"][n[0]]];r.text=r.text||this.formatValueText(r.value!=null?r.value:r.interval,!1,a)},this)}};function cX(e,t){var r=e.inverse;(e.orient==="vertical"?!r:r)&&t.reverse()}var uct=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r}return t.prototype.doRender=function(){var r=this.group;r.removeAll();var n=this.visualMapModel,a=n.get("textGap"),i=n.textStyleModel,o=this._getItemAlign(),s=n.itemSize,l=this._getViewData(),u=l.endsText,c=tn(n.get("showLabel",!0),!u),f=!n.get("selectedMode");u&&this._renderEndsText(r,u[0],s,c,o),O(l.viewPieceList,function(d){var h=d.piece,p=new we;p.onclick=ue(this._onItemClick,this,h),this._enableHoverLink(p,d.indexInModelPieceList);var v=n.getRepresentValue(h);if(this._createItemSymbol(p,v,[0,0,s[0],s[1]],f),c){var g=this.visualMapModel.getValueState(v),y=i.get("align")||o;p.add(new at({style:Pt(i,{x:y==="right"?-a:s[0]+a,y:s[1]/2,text:h.text,verticalAlign:i.get("verticalAlign")||"middle",align:y,opacity:ge(i.get("opacity"),g==="outOfRange"?.5:1)}),silent:f}))}r.add(p)},this),u&&this._renderEndsText(r,u[1],s,c,o),If(n.get("orient"),r,n.get("itemGap")),this.renderBackground(r),this.positionGroup(r)},t.prototype._enableHoverLink=function(r,n){var a=this;r.on("mouseover",function(){return i("highlight")}).on("mouseout",function(){return i("downplay")});var i=function(o){var s=a.visualMapModel;s.option.hoverLink&&a.api.dispatchAction({type:o,batch:f_(s.findTargetDataIndices(n),s)})}},t.prototype._getItemAlign=function(){var r=this.visualMapModel,n=r.option;if(n.orient==="vertical")return _ce(r,this.api,r.itemSize);var a=n.align;return(!a||a==="auto")&&(a="left"),a},t.prototype._renderEndsText=function(r,n,a,i,o){if(n){var s=new we,l=this.visualMapModel.textStyleModel;s.add(new at({style:Pt(l,{x:i?o==="right"?a[0]:0:a[0]/2,y:a[1]/2,verticalAlign:"middle",align:i?o:"center",text:n})})),r.add(s)}},t.prototype._getViewData=function(){var r=this.visualMapModel,n=ne(r.getPieceList(),function(s,l){return{piece:s,indexInModelPieceList:l}}),a=r.get("text"),i=r.get("orient"),o=r.get("inverse");return(i==="horizontal"?o:!o)?n.reverse():a&&(a=a.slice().reverse()),{viewPieceList:n,endsText:a}},t.prototype._createItemSymbol=function(r,n,a,i){var o=xr(this.getControllerVisual(n,"symbol"),a[0],a[1],a[2],a[3],this.getControllerVisual(n,"color"));o.silent=i,r.add(o)},t.prototype._onItemClick=function(r){var n=this.visualMapModel,a=n.option,i=a.selectedMode;if(i){var o=be(a.selected),s=n.getSelectedMapKey(r);i==="single"||i===!0?(o[s]=!0,O(o,function(l,u){o[u]=u===s})):o[s]=!o[s],this.api.dispatchAction({type:"selectDataRange",from:this.uid,visualMapId:this.visualMapModel.id,selected:o})}},t.type="visualMap.piecewise",t}(wce);function Tce(e){e.registerComponentModel(sct),e.registerComponentView(uct),Sce(e)}function cct(e){We(Cce),We(Tce)}var fct=function(){function e(t){this._thumbnailModel=t}return e.prototype.reset=function(t){this._renderVersion=t.getMainProcessVersion()},e.prototype.renderContent=function(t){var r=t.api.getViewOfComponentModel(this._thumbnailModel);r&&(t.group.silent=!0,r.renderContent({group:t.group,targetTrans:t.targetTrans,z2Range:qae(t.group),roamType:t.roamType,viewportRect:t.viewportRect,renderVersion:this._renderVersion}))},e.prototype.updateWindow=function(t,r){var n=r.getViewOfComponentModel(this._thumbnailModel);n&&n.updateWindow({targetTrans:t,renderVersion:this._renderVersion})},e}(),dct=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r.preventAutoZ=!0,r}return t.prototype.optionUpdated=function(r,n){this._updateBridge()},t.prototype._updateBridge=function(){var r=this._birdge=this._birdge||new fct(this);if(this._target=null,this.ecModel.eachSeries(function(a){I9(a,null)}),this.shouldShow()){var n=this.getTarget();I9(n.baseMapProvider,r)}},t.prototype.shouldShow=function(){return this.getShallow("show",!0)},t.prototype.getBridge=function(){return this._birdge},t.prototype.getTarget=function(){if(this._target)return this._target;var r=this.getReferringComponents("series",{useDefault:!1,enableAll:!1,enableNone:!1}).models[0];return r?r.subType!=="graph"&&(r=null):r=this.ecModel.queryComponents({mainType:"series",subType:"graph"})[0],this._target={baseMapProvider:r},this._target},t.type="thumbnail",t.layoutMode="box",t.dependencies=["series","geo"],t.defaultOption={show:!0,right:1,bottom:1,height:"25%",width:"25%",itemStyle:{borderColor:Y.color.border,borderWidth:2},windowStyle:{borderWidth:1,color:Y.color.neutral30,borderColor:Y.color.neutral40,opacity:.3},z:10},t}(Ye),hct=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type=t.type,r}return t.prototype.render=function(r,n,a){if(this._api=a,this._model=r,this._coordSys||(this._coordSys=new Ad),!this._isEnabled()){this._clear();return}this._renderVersion=a.getMainProcessVersion();var i=this.group;i.removeAll();var o=r.getModel("itemStyle"),s=o.getItemStyle();s.fill==null&&(s.fill=n.get("backgroundColor")||Y.color.neutral00);var l=Lr(r,a).refContainer,u=Ft(vie(r,!0),l),c=s.lineWidth||0,f=this._contentRect=ed(u.clone(),c/2,!0,!0),d=new we;i.add(d),d.setClipPath(new Ge({shape:f.plain()}));var h=this._targetGroup=new we;d.add(h);var p=u.plain();p.r=o.getShallow("borderRadius",!0),i.add(this._bgRect=new Ge({style:s,shape:p,silent:!1,cursor:"grab"}));var v=r.getModel("windowStyle"),g=v.getShallow("borderRadius",!0);d.add(this._windowRect=new Ge({shape:{x:0,y:0,width:0,height:0,r:g},style:v.getItemStyle(),silent:!1,cursor:"grab"})),this._dealRenderContent(),this._dealUpdateWindow(),dX(r,this)},t.prototype.renderContent=function(r){this._bridgeRendered=r,this._isEnabled()&&(this._dealRenderContent(),this._dealUpdateWindow(),dX(this._model,this))},t.prototype._dealRenderContent=function(){var r=this._bridgeRendered;if(!(!r||r.renderVersion!==this._renderVersion)){var n=this._targetGroup,a=this._coordSys,i=this._contentRect;if(n.removeAll(),!!r){var o=r.group,s=o.getBoundingRect();n.add(o),this._bgRect.z2=r.z2Range.min-10,a.setBoundingRect(s.x,s.y,s.width,s.height);var l=Ft({left:"center",top:"center",aspect:s.width/s.height},i);a.setViewRect(l.x,l.y,l.width,l.height),o.attr(a.getTransformInfo().raw),this._windowRect.z2=r.z2Range.max+10,this._resetRoamController(r.roamType)}}},t.prototype.updateWindow=function(r){var n=this._bridgeRendered;n&&n.renderVersion===r.renderVersion&&(n.targetTrans=r.targetTrans),this._isEnabled()&&this._dealUpdateWindow()},t.prototype._dealUpdateWindow=function(){var r=this._bridgeRendered;if(!(!r||r.renderVersion!==this._renderVersion)){var n=Ti([],r.targetTrans),a=io([],this._coordSys.transform,n);this._transThisToTarget=Ti([],a);var i=r.viewportRect;i?i=i.clone():i=new Me(0,0,this._api.getWidth(),this._api.getHeight()),i.applyTransform(a);var o=this._windowRect,s=o.shape.r;o.setShape(Se({r:s},i))}},t.prototype._resetRoamController=function(r){var n=this,a=this._api,i=this._roamController;if(i||(i=this._roamController=new Td(a.getZr())),!r||!this._isEnabled()){i.disable();return}i.enable(r,{api:a,zInfo:{component:this._model},triggerInfo:{roamTrigger:null,isInSelf:function(o,s,l){return n._contentRect.contain(s,l)}}}),i.off("pan").off("zoom").on("pan",ue(this._onPan,this)).on("zoom",ue(this._onZoom,this))},t.prototype._onPan=function(r){var n=this._transThisToTarget;if(!(!this._isEnabled()||!n)){var a=sr([],[r.oldX,r.oldY],n),i=sr([],[r.oldX-r.dx,r.oldY-r.dy],n);this._api.dispatchAction(fX(this._model.getTarget().baseMapProvider,{dx:i[0]-a[0],dy:i[1]-a[1]}))}},t.prototype._onZoom=function(r){var n=this._transThisToTarget;if(!(!this._isEnabled()||!n)){var a=sr([],[r.originX,r.originY],n);this._api.dispatchAction(fX(this._model.getTarget().baseMapProvider,{zoom:1/r.scale,originX:a[0],originY:a[1]}))}},t.prototype._isEnabled=function(){var r=this._model;if(!r||!r.shouldShow())return!1;var n=r.getTarget().baseMapProvider;return!!n},t.prototype._clear=function(){this.group.removeAll(),this._bridgeRendered=null,this._roamController&&this._roamController.disable()},t.prototype.remove=function(){this._clear()},t.prototype.dispose=function(){this._clear()},t.type="thumbnail",t}(Et);function fX(e,t){var r=e.mainType==="series"?e.subType+"Roam":e.mainType+"Roam",n={type:r};return n[e.mainType+"Id"]=e.id,J(n,t),n}function dX(e,t){var r=td(e);aA(t.group,r.z,r.zlevel)}function pct(e){e.registerComponentModel(dct),e.registerComponentView(hct)}var vct={label:{enabled:!0},decal:{show:!1}},hX=Xe(),gct={};function yct(e,t){var r=e.getModel("aria");if(!r.get("enabled"))return;var n=be(vct);Fe(n.label,e.getLocaleModel().get("aria"),!1),Fe(r.option,n,!1),a(),i();function a(){var u=r.getModel("decal"),c=u.get("show");if(c){var f=pe();e.eachSeries(function(d){if(!d.isColorBySeries()){var h=f.get(d.type);h||(h={},f.set(d.type,h)),hX(d).scope=h}}),e.eachRawSeries(function(d){if(e.isSeriesFiltered(d))return;if(xe(d.enableAriaDecal)){d.enableAriaDecal();return}var h=d.getData();if(d.isColorBySeries()){var m=wL(d.ecModel,d.name,gct,e.getSeriesCount()),b=h.getVisual("decal");h.setVisual("decal",w(b,m))}else{var p=d.getRawData(),v={},g=hX(d).scope;h.each(function(_){var S=h.getRawIndex(_);v[S]=_});var y=p.count();p.each(function(_){var S=v[_],C=p.getName(_)||_+"",T=wL(d.ecModel,C,g,y),A=h.getItemVisual(S,"decal");h.setItemVisual(S,"decal",w(A,T))})}function w(_,S){var C=_?J(J({},S),_):S;return C.dirty=!0,C}})}}function i(){var u=t.getZr().dom;if(u){var c=e.getLocaleModel().get("aria"),f=r.getModel("label");if(f.option=Se(f.option,c),!!f.get("enabled")){if(u.setAttribute("role","img"),f.get("description")){u.setAttribute("aria-label",f.get("description"));return}var d=e.getSeriesCount(),h=f.get(["data","maxCount"])||10,p=f.get(["series","maxCount"])||10,v=Math.min(d,p),g;if(!(d<1)){var y=s();if(y){var m=f.get(["general","withTitle"]);g=o(m,{title:y})}else g=f.get(["general","withoutTitle"]);var b=[],w=d>1?f.get(["series","multiple","prefix"]):f.get(["series","single","prefix"]);g+=o(w,{seriesCount:d}),e.eachSeries(function(T,A){if(A<v){var k=void 0,P=T.get("name"),M=P?"withName":"withoutName";k=d>1?f.get(["series","multiple",M]):f.get(["series","single",M]),k=o(k,{seriesId:T.seriesIndex,seriesName:T.get("name"),seriesType:l(T.subType)});var D=T.getData();if(D.count()>h){var E=f.get(["data","partialData"]);k+=o(E,{displayCnt:h})}else k+=f.get(["data","allData"]);for(var L=f.get(["data","separator","middle"]),N=f.get(["data","separator","end"]),j=f.get(["data","excludeDimensionId"]),R=[],z=0;z<D.count();z++)if(z<h){var B=D.getName(z),V=j?dt(D.getValues(z),function(K,re){return $e(j,re)===-1}):D.getValues(z),$=f.get(["data",B?"withName":"withoutName"]);R.push(o($,{name:B,value:V.join(L)}))}k+=R.join(L)+N,b.push(k)}});var _=f.getModel(["series","multiple","separator"]),S=_.get("middle"),C=_.get("end");g+=b.join(S)+C,u.setAttribute("aria-label",g)}}}}function o(u,c){if(!se(u))return u;var f=u;return O(c,function(d,h){f=f.replace(new RegExp("\\{\\s*"+h+"\\s*\\}","g"),d)}),f}function s(){var u=e.get("title");return u&&u.length&&(u=u[0]),u&&u.text}function l(u){var c=e.getLocaleModel().get(["series","typeNames"]);return c[u]||c.chart}}function mct(e){if(!(!e||!e.aria)){var t=e.aria;t.show!=null&&(t.enabled=t.show),t.label=t.label||{},O(["description","general","series","data"],function(r){t[r]!=null&&(t.label[r]=t[r])})}}function xct(e){e.registerPreprocessor(mct),e.registerVisual(e.PRIORITY.VISUAL.ARIA,yct)}var pX={value:"eq","<":"lt","<=":"lte",">":"gt",">=":"gte","=":"eq","!=":"ne","<>":"ne"},bct=function(){function e(t){var r=this._condVal=se(t)?new RegExp(t):xne(t)?t:null;if(r==null){var n="";gt(n)}}return e.prototype.evaluate=function(t){var r=typeof t;return se(r)?this._condVal.test(t):it(r)?this._condVal.test(t+""):!1},e}(),wct=function(){function e(){}return e.prototype.evaluate=function(){return this.value},e}(),_ct=function(){function e(){}return e.prototype.evaluate=function(){for(var t=this.children,r=0;r<t.length;r++)if(!t[r].evaluate())return!1;return!0},e}(),Sct=function(){function e(){}return e.prototype.evaluate=function(){for(var t=this.children,r=0;r<t.length;r++)if(t[r].evaluate())return!0;return!1},e}(),Cct=function(){function e(){}return e.prototype.evaluate=function(){return!this.child.evaluate()},e}(),Tct=function(){function e(){}return e.prototype.evaluate=function(){for(var t=!!this.valueParser,r=this.getValue,n=r(this.valueGetterParam),a=t?this.valueParser(n):null,i=0;i<this.subCondList.length;i++)if(!this.subCondList[i].evaluate(t?a:n))return!1;return!0},e}();function yB(e,t){if(e===!0||e===!1){var r=new wct;return r.value=e,r}var n="";return Ace(e)||gt(n),e.and?vX("and",e,t):e.or?vX("or",e,t):e.not?Act(e,t):kct(e,t)}function vX(e,t,r){var n=t[e],a="";te(n)||gt(a),n.length||gt(a);var i=e==="and"?new _ct:new Sct;return i.children=ne(n,function(o){return yB(o,r)}),i.children.length||gt(a),i}function Act(e,t){var r=e.not,n="";Ace(r)||gt(n);var a=new Cct;return a.child=yB(r,t),a.child||gt(n),a}function kct(e,t){for(var r="",n=t.prepareGetValue(e),a=[],i=rt(e),o=e.parser,s=o?Rie(o):null,l=0;l<i.length;l++){var u=i[l];if(!(u==="parser"||t.valueGetterAttrMap.get(u))){var c=he(pX,u)?pX[u]:u,f=e[u],d=s?s(f):f,h=G7e(c,d)||c==="reg"&&new bct(d);h||gt(r),a.push(h)}}a.length||gt(r);var p=new Tct;return p.valueGetterParam=n,p.valueParser=s,p.getValue=t.getValue,p.subCondList=a,p}function Ace(e){return Ce(e)&&!xn(e)}var Mct=function(){function e(t,r){this._cond=yB(t,r)}return e.prototype.evaluate=function(){return this._cond.evaluate()},e}();function Pct(e,t){return new Mct(e,t)}var Dct={type:"echarts:filter",transform:function(e){for(var t=e.upstream,r,n=Pct(e.config,{valueGetterAttrMap:pe({dimension:!0}),prepareGetValue:function(s){var l="",u=s.dimension;he(s,"dimension")||gt(l);var c=t.getDimensionInfo(u);return c||gt(l),{dimIdx:c.index}},getValue:function(s){return t.retrieveValueFromItem(r,s.dimIdx)}}),a=[],i=0,o=t.count();i<o;i++)r=t.getRawDataItem(i),n.evaluate()&&a.push(r);return{data:a}}},Ect={type:"echarts:sort",transform:function(e){var t=e.upstream,r=e.config,n="",a=Dt(r);a.length||gt(n);var i=[];O(a,function(c){var f=c.dimension,d=c.order,h=c.parser,p=c.incomparable;if(f==null&&gt(n),d!=="asc"&&d!=="desc"&&gt(n),p&&p!=="min"&&p!=="max"){var v="";gt(v)}if(d!=="asc"&&d!=="desc"){var g="";gt(g)}var y=t.getDimensionInfo(f);y||gt(n);var m=h?Rie(h):null;h&&!m&&gt(n),i.push({dimIdx:y.index,parser:m,comparator:new Bie(d,p)})});var o=t.sourceFormat;o!==an&&o!==Ya&&gt(n);for(var s=[],l=0,u=t.count();l<u;l++)s.push(t.getRawDataItem(l));return s.sort(function(c,f){for(var d=0;d<i.length;d++){var h=i[d],p=t.retrieveValueFromItem(c,h.dimIdx),v=t.retrieveValueFromItem(f,h.dimIdx);h.parser&&(p=h.parser(p),v=h.parser(v));var g=h.comparator.evaluate(p,v);if(g!==0)return g}return 0}),{data:s}}};function Nct(e){e.registerTransform(Dct),e.registerTransform(Ect)}var Oct=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type="dataset",r}return t.prototype.init=function(r,n,a){e.prototype.init.call(this,r,n,a),this._sourceManager=new Wie(this),YH(this)},t.prototype.mergeOption=function(r,n){e.prototype.mergeOption.call(this,r,n),YH(this)},t.prototype.optionUpdated=function(){this._sourceManager.dirty()},t.prototype.getSourceManager=function(){return this._sourceManager},t.type="dataset",t.defaultOption={seriesLayoutBy:lo},t}(Ye),Lct=function(e){G(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r.type="dataset",r}return t.type="dataset",t}(Et);function Ict(e){e.registerComponentModel(Oct),e.registerComponentView(Lct)}var Mo=is.CMD;function Vh(e,t){return Math.abs(e-t)<1e-5}function jI(e){var t=e.data,r=e.len(),n=[],a,i=0,o=0,s=0,l=0;function u(D,E){a&&a.length>2&&n.push(a),a=[D,E]}function c(D,E,L,N){Vh(D,L)&&Vh(E,N)||a.push(D,E,L,N,L,N)}function f(D,E,L,N,j,R){var z=Math.abs(E-D),B=Math.tan(z/4)*4/3,V=E<D?-1:1,$=Math.cos(D),K=Math.sin(D),re=Math.cos(E),ie=Math.sin(E),ye=$*j+L,je=K*R+N,F=re*j+L,W=ie*R+N,ee=j*B*V,Z=R*B*V;a.push(ye-ee*K,je+Z*$,F+ee*ie,W-Z*re,F,W)}for(var d,h,p,v,g=0;g<r;){var y=t[g++],m=g===1;switch(m&&(i=t[g],o=t[g+1],s=i,l=o,(y===Mo.L||y===Mo.C||y===Mo.Q)&&(a=[s,l])),y){case Mo.M:i=s=t[g++],o=l=t[g++],u(s,l);break;case Mo.L:d=t[g++],h=t[g++],c(i,o,d,h),i=d,o=h;break;case Mo.C:a.push(t[g++],t[g++],t[g++],t[g++],i=t[g++],o=t[g++]);break;case Mo.Q:d=t[g++],h=t[g++],p=t[g++],v=t[g++],a.push(i+2/3*(d-i),o+2/3*(h-o),p+2/3*(d-p),v+2/3*(h-v),p,v),i=p,o=v;break;case Mo.A:var b=t[g++],w=t[g++],_=t[g++],S=t[g++],C=t[g++],T=t[g++]+C;g+=1;var A=!t[g++];d=Math.cos(C)*_+b,h=Math.sin(C)*S+w,m?(s=d,l=h,u(s,l)):c(i,o,d,h),i=Math.cos(T)*_+b,o=Math.sin(T)*S+w;for(var k=(A?-1:1)*Math.PI/2,P=C;A?P>T:P<T;P+=k){var M=A?Math.max(P+k,T):Math.min(P+k,T);f(P,M,b,w,_,S)}break;case Mo.R:s=i=t[g++],l=o=t[g++],d=s+t[g++],h=l+t[g++],u(d,l),c(d,l,d,h),c(d,h,s,h),c(s,h,s,l),c(s,l,d,l);break;case Mo.Z:a&&c(i,o,s,l),i=s,o=l;break}}return a&&a.length>2&&n.push(a),n}function RI(e,t,r,n,a,i,o,s,l,u){if(Vh(e,r)&&Vh(t,n)&&Vh(a,o)&&Vh(i,s)){l.push(o,s);return}var c=2/u,f=c*c,d=o-e,h=s-t,p=Math.sqrt(d*d+h*h);d/=p,h/=p;var v=r-e,g=n-t,y=a-o,m=i-s,b=v*v+g*g,w=y*y+m*m;if(b<f&&w<f){l.push(o,s);return}var _=d*v+h*g,S=-d*y-h*m,C=b-_*_,T=w-S*S;if(C<f&&_>=0&&T<f&&S>=0){l.push(o,s);return}var A=[],k=[];Bu(e,r,a,o,.5,A),Bu(t,n,i,s,.5,k),RI(A[0],k[0],A[1],k[1],A[2],k[2],A[3],k[3],l,u),RI(A[4],k[4],A[5],k[5],A[6],k[6],A[7],k[7],l,u)}function jct(e,t){var r=jI(e),n=[];t=t||1;for(var a=0;a<r.length;a++){var i=r[a],o=[],s=i[0],l=i[1];o.push(s,l);for(var u=2;u<i.length;){var c=i[u++],f=i[u++],d=i[u++],h=i[u++],p=i[u++],v=i[u++];RI(s,l,c,f,d,h,p,v,o,t),s=p,l=v}n.push(o)}return n}function kce(e,t,r){var n=e[t],a=e[1-t],i=Math.abs(n/a),o=Math.ceil(Math.sqrt(i*r)),s=Math.floor(r/o);s===0&&(s=1,o=r);for(var l=[],u=0;u<o;u++)l.push(s);var c=o*s,f=r-c;if(f>0)for(var u=0;u<f;u++)l[u%o]+=1;return l}function gX(e,t,r){for(var n=e.r0,a=e.r,i=e.startAngle,o=e.endAngle,s=Math.abs(o-i),l=s*a,u=a-n,c=l>Math.abs(u),f=kce([l,u],c?0:1,t),d=(c?s:u)/f.length,h=0;h<f.length;h++)for(var p=(c?u:s)/f[h],v=0;v<f[h];v++){var g={};c?(g.startAngle=i+d*h,g.endAngle=i+d*(h+1),g.r0=n+p*v,g.r=n+p*(v+1)):(g.startAngle=i+p*v,g.endAngle=i+p*(v+1),g.r0=n+d*h,g.r=n+d*(h+1)),g.clockwise=e.clockwise,g.cx=e.cx,g.cy=e.cy,r.push(g)}}function Rct(e,t,r){for(var n=e.width,a=e.height,i=n>a,o=kce([n,a],i?0:1,t),s=i?"width":"height",l=i?"height":"width",u=i?"x":"y",c=i?"y":"x",f=e[s]/o.length,d=0;d<o.length;d++)for(var h=e[l]/o[d],p=0;p<o[d];p++){var v={};v[u]=d*f,v[c]=p*h,v[s]=f,v[l]=h,v.x+=e.x,v.y+=e.y,r.push(v)}}function yX(e,t,r,n){return e*n-r*t}function zct(e,t,r,n,a,i,o,s){var l=r-e,u=n-t,c=o-a,f=s-i,d=yX(c,f,l,u);if(Math.abs(d)<1e-6)return null;var h=e-a,p=t-i,v=yX(h,p,c,f)/d;return v<0||v>1?null:new ke(v*l+e,v*u+t)}function Bct(e,t,r){var n=new ke;ke.sub(n,r,t),n.normalize();var a=new ke;ke.sub(a,e,t);var i=a.dot(n);return i}function lh(e,t){var r=e[e.length-1];r&&r[0]===t[0]&&r[1]===t[1]||e.push(t)}function $ct(e,t,r){for(var n=e.length,a=[],i=0;i<n;i++){var o=e[i],s=e[(i+1)%n],l=zct(o[0],o[1],s[0],s[1],t.x,t.y,r.x,r.y);l&&a.push({projPt:Bct(l,t,r),pt:l,idx:i})}if(a.length<2)return[{points:e},{points:e}];a.sort(function(g,y){return g.projPt-y.projPt});var u=a[0],c=a[a.length-1];if(c.idx<u.idx){var f=u;u=c,c=f}for(var d=[u.pt.x,u.pt.y],h=[c.pt.x,c.pt.y],p=[d],v=[h],i=u.idx+1;i<=c.idx;i++)lh(p,e[i].slice());lh(p,h),lh(p,d);for(var i=c.idx+1;i<=u.idx+n;i++)lh(v,e[i%n].slice());return lh(v,d),lh(v,h),[{points:p},{points:v}]}function mX(e){var t=e.points,r=[],n=[];J2(t,r,n);var a=new Me(r[0],r[1],n[0]-r[0],n[1]-r[1]),i=a.width,o=a.height,s=a.x,l=a.y,u=new ke,c=new ke;return i>o?(u.x=c.x=s+i/2,u.y=l,c.y=l+o):(u.y=c.y=l+o/2,u.x=s,c.x=s+i),$ct(t,u,c)}function oT(e,t,r,n){if(r===1)n.push(t);else{var a=Math.floor(r/2),i=e(t);oT(e,i[0],a,n),oT(e,i[1],r-a,n)}return n}function Fct(e,t){for(var r=[],n=0;n<t;n++)r.push(dz(e));return r}function Vct(e,t){t.setStyle(e.style),t.z=e.z,t.z2=e.z2,t.zlevel=e.zlevel}function Wct(e){for(var t=[],r=0;r<e.length;)t.push([e[r++],e[r++]]);return t}function Hct(e,t){var r=[],n=e.shape,a;switch(e.type){case"rect":Rct(n,t,r),a=Ge;break;case"sector":gX(n,t,r),a=wn;break;case"circle":gX({r0:0,r:n.r,startAngle:0,endAngle:Math.PI*2,cx:n.cx,cy:n.cy},t,r),a=wn;break;default:var i=e.getComputedTransform(),o=i?Math.sqrt(Math.max(i[0]*i[0]+i[1]*i[1],i[2]*i[2]+i[3]*i[3])):1,s=ne(jct(e.getUpdatedPathProxy(),o),function(y){return Wct(y)}),l=s.length;if(l===0)oT(mX,{points:s[0]},t,r);else if(l===t)for(var u=0;u<l;u++)r.push({points:s[u]});else{var c=0,f=ne(s,function(y){var m=[],b=[];J2(y,m,b);var w=(b[1]-m[1])*(b[0]-m[0]);return c+=w,{poly:y,area:w}});f.sort(function(y,m){return m.area-y.area});for(var d=t,u=0;u<l;u++){var h=f[u];if(d<=0)break;var p=u===l-1?d:Math.ceil(h.area/c*t);p<0||(oT(mX,{points:h.poly},p,r),d-=p)}}a=_n;break}if(!a)return Fct(e,t);for(var v=[],u=0;u<r.length;u++){var g=new a;g.setShape(r[u]),Vct(e,g),v.push(g)}return v}function Gct(e,t){var r=e.length,n=t.length;if(r===n)return[e,t];for(var a=[],i=[],o=r<n?e:t,s=Math.min(r,n),l=Math.abs(n-r)/6,u=(s-2)/6,c=Math.ceil(l/u)+1,f=[o[0],o[1]],d=l,h=2;h<s;){var p=o[h-2],v=o[h-1],g=o[h++],y=o[h++],m=o[h++],b=o[h++],w=o[h++],_=o[h++];if(d<=0){f.push(g,y,m,b,w,_);continue}for(var S=Math.min(d,c-1)+1,C=1;C<=S;C++){var T=C/S;Bu(p,g,m,w,T,a),Bu(v,y,b,_,T,i),p=a[3],v=i[3],f.push(a[1],i[1],a[2],i[2],p,v),g=a[5],y=i[5],m=a[6],b=i[6]}d-=S-1}return o===e?[f,t]:[e,f]}function xX(e,t){for(var r=e.length,n=e[r-2],a=e[r-1],i=[],o=0;o<t.length;)i[o++]=n,i[o++]=a;return i}function Uct(e,t){for(var r,n,a,i=[],o=[],s=0;s<Math.max(e.length,t.length);s++){var l=e[s],u=t[s],c=void 0,f=void 0;l?u?(r=Gct(l,u),c=r[0],f=r[1],n=c,a=f):(f=xX(a||l,l),c=l):(c=xX(n||u,u),f=u),i.push(c),o.push(f)}return[i,o]}function bX(e){for(var t=0,r=0,n=0,a=e.length,i=0,o=a-2;i<a;o=i,i+=2){var s=e[o],l=e[o+1],u=e[i],c=e[i+1],f=s*c-u*l;t+=f,r+=(s+u)*f,n+=(l+c)*f}return t===0?[e[0]||0,e[1]||0]:[r/t/3,n/t/3,t]}function Yct(e,t,r,n){for(var a=(e.length-2)/6,i=1/0,o=0,s=e.length,l=s-2,u=0;u<a;u++){for(var c=u*6,f=0,d=0;d<s;d+=2){var h=d===0?c:(c+d-2)%l+2,p=e[h]-r[0],v=e[h+1]-r[1],g=t[d]-n[0],y=t[d+1]-n[1],m=g-p,b=y-v;f+=m*m+b*b}f<i&&(i=f,o=u)}return o}function Xct(e){for(var t=[],r=e.length,n=0;n<r;n+=2)t[n]=e[r-n-2],t[n+1]=e[r-n-1];return t}function qct(e,t,r,n){for(var a=[],i,o=0;o<e.length;o++){var s=e[o],l=t[o],u=bX(s),c=bX(l);i==null&&(i=u[2]<0!=c[2]<0);var f=[],d=[],h=0,p=1/0,v=[],g=s.length;i&&(s=Xct(s));for(var y=Yct(s,l,u,c)*6,m=g-2,b=0;b<m;b+=2){var w=(y+b)%m+2;f[b+2]=s[w]-u[0],f[b+3]=s[w+1]-u[1]}f[0]=s[y]-u[0],f[1]=s[y+1]-u[1];for(var _=n/r,S=-n/2;S<=n/2;S+=_){for(var C=Math.sin(S),T=Math.cos(S),A=0,b=0;b<s.length;b+=2){var k=f[b],P=f[b+1],M=l[b]-c[0],D=l[b+1]-c[1],E=M*T-D*C,L=M*C+D*T;v[b]=E,v[b+1]=L;var N=E-k,j=L-P;A+=N*N+j*j}if(A<p){p=A,h=S;for(var R=0;R<v.length;R++)d[R]=v[R]}}a.push({from:f,to:d,fromCp:u,toCp:c,rotation:-h})}return a}function sT(e){return e.__isCombineMorphing}var Mce="__mOriginal_";function lT(e,t,r){var n=Mce+t,a=e[n]||e[t];e[n]||(e[n]=e[t]);var i=r.replace,o=r.after,s=r.before;e[t]=function(){var l=arguments,u;return s&&s.apply(this,l),i?u=i.apply(this,l):u=a.apply(this,l),o&&o.apply(this,l),u}}function xm(e,t){var r=Mce+t;e[r]&&(e[t]=e[r],e[r]=null)}function wX(e,t){for(var r=0;r<e.length;r++)for(var n=e[r],a=0;a<n.length;){var i=n[a],o=n[a+1];n[a++]=t[0]*i+t[2]*o+t[4],n[a++]=t[1]*i+t[3]*o+t[5]}}function Pce(e,t){var r=e.getUpdatedPathProxy(),n=t.getUpdatedPathProxy(),a=Uct(jI(r),jI(n)),i=a[0],o=a[1],s=e.getComputedTransform(),l=t.getComputedTransform();function u(){this.transform=null}s&&wX(i,s),l&&wX(o,l),lT(t,"updateTransform",{replace:u}),t.transform=null;var c=qct(i,o,10,Math.PI),f=[];lT(t,"buildPath",{replace:function(d){for(var h=t.__morphT,p=1-h,v=[],g=0;g<c.length;g++){var y=c[g],m=y.from,b=y.to,w=y.rotation*h,_=y.fromCp,S=y.toCp,C=Math.sin(w),T=Math.cos(w);sm(v,_,S,h);for(var A=0;A<m.length;A+=2){var k=m[A],P=m[A+1],M=b[A],D=b[A+1],E=k*p+M*h,L=P*p+D*h;f[A]=E*T-L*C+v[0],f[A+1]=E*C+L*T+v[1]}var N=f[0],j=f[1];d.moveTo(N,j);for(var A=2;A<m.length;){var M=f[A++],D=f[A++],R=f[A++],z=f[A++],B=f[A++],V=f[A++];N===M&&j===D&&R===B&&z===V?d.lineTo(B,V):d.bezierCurveTo(M,D,R,z,B,V),N=B,j=V}}}})}function mB(e,t,r){if(!e||!t)return t;var n=r.done,a=r.during;Pce(e,t),t.__morphT=0;function i(){xm(t,"buildPath"),xm(t,"updateTransform"),t.__morphT=-1,t.createPathProxy(),t.dirtyShape()}return t.animateTo({__morphT:1},Se({during:function(o){t.dirtyShape(),a&&a(o)},done:function(){i(),n&&n()}},r)),t}function Kct(e,t,r,n,a,i){var o=16;e=a===r?0:Math.round(32767*(e-r)/(a-r)),t=i===n?0:Math.round(32767*(t-n)/(i-n));for(var s=0,l,u=(1<<o)/2;u>0;u/=2){var c=0,f=0;(e&u)>0&&(c=1),(t&u)>0&&(f=1),s+=u*u*(3*c^f),f===0&&(c===1&&(e=u-1-e,t=u-1-t),l=e,e=t,t=l)}return s}function uT(e){var t=1/0,r=1/0,n=-1/0,a=-1/0,i=ne(e,function(s){var l=s.getBoundingRect(),u=s.getComputedTransform(),c=l.x+l.width/2+(u?u[4]:0),f=l.y+l.height/2+(u?u[5]:0);return t=Math.min(c,t),r=Math.min(f,r),n=Math.max(c,n),a=Math.max(f,a),[c,f]}),o=ne(i,function(s,l){return{cp:s,z:Kct(s[0],s[1],t,r,n,a),path:e[l]}});return o.sort(function(s,l){return s.z-l.z}).map(function(s){return s.path})}function Dce(e){return Hct(e.path,e.count)}function zI(){return{fromIndividuals:[],toIndividuals:[],count:0}}function Zct(e,t,r){var n=[];function a(_){for(var S=0;S<_.length;S++){var C=_[S];sT(C)?a(C.childrenRef()):C instanceof Je&&n.push(C)}}a(e);var i=n.length;if(!i)return zI();var o=r.dividePath||Dce,s=o({path:t,count:i});if(s.length!==i)return console.error("Invalid morphing: unmatched splitted path"),zI();n=uT(n),s=uT(s);for(var l=r.done,u=r.during,c=r.individualDelay,f=new Ws,d=0;d<i;d++){var h=n[d],p=s[d];p.parent=t,p.copyTransform(f),c||Pce(h,p)}t.__isCombineMorphing=!0,t.childrenRef=function(){return s};function v(_){for(var S=0;S<s.length;S++)s[S].addSelfToZr(_)}lT(t,"addSelfToZr",{after:function(_){v(_)}}),lT(t,"removeSelfFromZr",{after:function(_){for(var S=0;S<s.length;S++)s[S].removeSelfFromZr(_)}});function g(){t.__isCombineMorphing=!1,t.__morphT=-1,t.childrenRef=null,xm(t,"addSelfToZr"),xm(t,"removeSelfFromZr")}var y=s.length;if(c)for(var m=y,b=function(){m--,m===0&&(g(),l&&l())},d=0;d<y;d++){var w=c?Se({delay:(r.delay||0)+c(d,y,n[d],s[d]),done:b},r):r;mB(n[d],s[d],w)}else t.__morphT=0,t.animateTo({__morphT:1},Se({during:function(_){for(var S=0;S<y;S++){var C=s[S];C.__morphT=t.__morphT,C.dirtyShape()}u&&u(_)},done:function(){g();for(var _=0;_<e.length;_++)xm(e[_],"updateTransform");l&&l()}},r));return t.__zr&&v(t.__zr),{fromIndividuals:n,toIndividuals:s,count:y}}function Jct(e,t,r){var n=t.length,a=[],i=r.dividePath||Dce;function o(h){for(var p=0;p<h.length;p++){var v=h[p];sT(v)?o(v.childrenRef()):v instanceof Je&&a.push(v)}}if(sT(e)){o(e.childrenRef());var s=a.length;if(s<n)for(var l=0,u=s;u<n;u++)a.push(dz(a[l++%s]));a.length=n}else{a=i({path:e,count:n});for(var c=e.getComputedTransform(),u=0;u<a.length;u++)a[u].setLocalTransform(c);if(a.length!==n)return console.error("Invalid morphing: unmatched splitted path"),zI()}a=uT(a),t=uT(t);for(var f=r.individualDelay,u=0;u<n;u++){var d=f?Se({delay:(r.delay||0)+f(u,n,a[u],t[u])},r):r;mB(a[u],t[u],d)}return{fromIndividuals:a,toIndividuals:t,count:t.length}}function _X(e){return te(e[0])}function SX(e,t){for(var r=[],n=e.length,a=0;a<n;a++)r.push({one:e[a],many:[]});for(var a=0;a<t.length;a++){var i=t[a].length,o=void 0;for(o=0;o<i;o++)r[o%n].many.push(t[a][o])}for(var s=0,a=n-1;a>=0;a--)if(!r[a].many.length){var l=r[s].many;if(l.length<=1)if(s)s=0;else return r;var i=l.length,u=Math.ceil(i/2);r[a].many=l.slice(u,i),r[s].many=l.slice(0,u),s++}return r}var Qct={clone:function(e){for(var t=[],r=1-Math.pow(1-e.path.style.opacity,1/e.count),n=0;n<e.count;n++){var a=dz(e.path);a.setStyle("opacity",r),t.push(a)}return t},split:null};function SD(e,t,r,n,a,i){if(!e.length||!t.length)return;var o=Yv("update",n,a);if(!(o&&o.duration>0))return;var s=n.getModel("universalTransition").get("delay"),l=Object.assign({setToFinal:!0},o),u,c;_X(e)&&(u=e,c=t),_X(t)&&(u=t,c=e);function f(y,m,b,w,_){var S=y.many,C=y.one;if(S.length===1&&!_){var T=m?S[0]:C,A=m?C:S[0];if(sT(T))f({many:[T],one:A},!0,b,w,!0);else{var k=s?Se({delay:s(b,w)},l):l;mB(T,A,k),i(T,A,T,A,k)}}else for(var P=Se({dividePath:Qct[r],individualDelay:s&&function(j,R,z,B){return s(j+b,w)}},l),M=m?Zct(S,C,P):Jct(C,S,P),D=M.fromIndividuals,E=M.toIndividuals,L=D.length,N=0;N<L;N++){var k=s?Se({delay:s(N,L)},l):l;i(D[N],E[N],m?S[N]:y.one,m?y.one:S[N],k)}}for(var d=u?u===e:e.length>t.length,h=u?SX(c,u):SX(d?t:e,[d?e:t]),p=0,v=0;v<h.length;v++)p+=h[v].many.length;for(var g=0,v=0;v<h.length;v++)f(h[v],d,g,p),g+=h[v].many.length}function Kc(e){if(!e)return[];if(te(e)){for(var t=[],r=0;r<e.length;r++)t.push(Kc(e[r]));return t}var n=[];return e.traverse(function(a){a instanceof Je&&!a.disableMorphing&&!a.invisible&&!a.ignore&&n.push(a)}),n}var Ece=1e4,eft=0,CX=1,TX=2,tft=Xe();function rft(e,t){for(var r=e.dimensions,n=0;n<r.length;n++){var a=e.getDimensionInfo(r[n]);if(a&&a.otherDims[t]===0)return r[n]}}function nft(e,t,r){var n=e.getDimensionInfo(r),a=n&&n.ordinalMeta;if(n){var i=e.get(n.name,t);return a&&a.categories[i]||i+""}}function AX(e,t,r,n){var a=n?"itemChildGroupId":"itemGroupId",i=rft(e,a);if(i){var o=nft(e,t,i);return o}var s=e.getRawDataItem(t),l=n?"childGroupId":"groupId";if(s&&s[l])return s[l]+"";if(!n)return r||e.getId(t)}function kX(e){var t=[];return O(e,function(r){var n=r.data,a=r.dataGroupId;if(!(n.count()>Ece))for(var i=n.getIndices(),o=0;o<i.length;o++)t.push({data:n,groupId:AX(n,o,a,!1),childGroupId:AX(n,o,a,!0),divide:r.divide,dataIndex:o})}),t}function CD(e,t,r){e.traverse(function(n){n instanceof Je&&Rt(n,{style:{opacity:0}},t,{dataIndex:r,isFrom:!0})})}function TD(e){if(e.parent){var t=e.getComputedTransform();e.setLocalTransform(t),e.parent.remove(e)}}function uh(e){e.stopAnimation(),e.isGroup&&e.traverse(function(t){t.stopAnimation()})}function aft(e,t,r){var n=Yv("update",r,t);n&&e.traverse(function(a){if(a instanceof Ai){var i=x9e(a);i&&a.animateFrom({style:i},n)}})}function ift(e,t){var r=e.length;if(r!==t.length)return!1;for(var n=0;n<r;n++){var a=e[n],i=t[n];if(a.data.getId(a.dataIndex)!==i.data.getId(i.dataIndex))return!1}return!0}function Nce(e,t,r){var n=kX(e),a=kX(t);function i(b,w,_,S,C){(_||b)&&w.animateFrom({style:_&&_!==b?J(J({},_.style),b.style):b.style},C)}var o=!1,s=eft,l=pe(),u=pe();n.forEach(function(b){b.groupId&&l.set(b.groupId,!0),b.childGroupId&&u.set(b.childGroupId,!0)});for(var c=0;c<a.length;c++){var f=a[c].groupId;if(u.get(f)){s=CX;break}var d=a[c].childGroupId;if(d&&l.get(d)){s=TX;break}}function h(b,w){return function(_){var S=_.data,C=_.dataIndex;return w?S.getId(C):b?s===CX?_.childGroupId:_.groupId:s===TX?_.childGroupId:_.groupId}}var p=ift(n,a),v={};if(!p)for(var c=0;c<a.length;c++){var g=a[c],y=g.data.getItemGraphicEl(g.dataIndex);y&&(v[y.id]=!0)}function m(b,w){var _=n[w],S=a[b],C=S.data.hostModel,T=_.data.getItemGraphicEl(_.dataIndex),A=S.data.getItemGraphicEl(S.dataIndex);if(T===A){A&&aft(A,S.dataIndex,C);return}T&&v[T.id]||A&&(uh(A),T?(uh(T),TD(T),o=!0,SD(Kc(T),Kc(A),S.divide,C,b,i)):CD(A,C,b))}new gl(n,a,h(!0,p),h(!1,p),null,"multiple").update(m).updateManyToOne(function(b,w){var _=a[b],S=_.data,C=S.hostModel,T=S.getItemGraphicEl(_.dataIndex),A=dt(ne(w,function(k){return n[k].data.getItemGraphicEl(n[k].dataIndex)}),function(k){return k&&k!==T&&!v[k.id]});T&&(uh(T),A.length?(O(A,function(k){uh(k),TD(k)}),o=!0,SD(Kc(A),Kc(T),_.divide,C,b,i)):CD(T,C,_.dataIndex))}).updateOneToMany(function(b,w){var _=n[w],S=_.data.getItemGraphicEl(_.dataIndex);if(!(S&&v[S.id])){var C=dt(ne(b,function(A){return a[A].data.getItemGraphicEl(a[A].dataIndex)}),function(A){return A&&A!==S}),T=a[b[0]].data.hostModel;C.length&&(O(C,function(A){return uh(A)}),S?(uh(S),TD(S),o=!0,SD(Kc(S),Kc(C),_.divide,T,b[0],i)):O(C,function(A){return CD(A,T,b[0])}))}}).updateManyToMany(function(b,w){new gl(w,b,function(_){return n[_].data.getId(n[_].dataIndex)},function(_){return a[_].data.getId(a[_].dataIndex)}).update(function(_,S){m(b[_],w[S])}).execute()}).execute(),o&&O(t,function(b){var w=b.data,_=w.hostModel,S=_&&r.getViewOfSeriesModel(_),C=Yv("update",_,0);S&&_.isAnimationEnabled()&&C&&C.duration>0&&S.group.traverse(function(T){T instanceof Je&&!T.animators.length&&T.animateFrom({style:{opacity:0}},C)})})}function MX(e){var t=e.getModel("universalTransition").get("seriesKey");return t||e.id}function PX(e){return te(e)?e.sort().join(","):e}function ql(e){if(e.hostModel)return e.hostModel.getModel("universalTransition").get("divideShape")}function oft(e,t){var r=pe(),n=pe(),a=pe();return O(e.oldSeries,function(i,o){var s=e.oldDataGroupIds[o],l=e.oldData[o],u=MX(i),c=PX(u);n.set(c,{dataGroupId:s,data:l}),te(u)&&O(u,function(f){a.set(f,{key:c,dataGroupId:s,data:l})})}),O(t.updatedSeries,function(i){if(i.isUniversalTransitionEnabled()&&i.isAnimationEnabled()){var o=i.get("dataGroupId"),s=i.getData(),l=MX(i),u=PX(l),c=n.get(u);if(c)r.set(u,{oldSeries:[{dataGroupId:c.dataGroupId,divide:ql(c.data),data:c.data}],newSeries:[{dataGroupId:o,divide:ql(s),data:s}]});else if(te(l)){var f=[];O(l,function(p){var v=n.get(p);v.data&&f.push({dataGroupId:v.dataGroupId,divide:ql(v.data),data:v.data})}),f.length&&r.set(u,{oldSeries:f,newSeries:[{dataGroupId:o,data:s,divide:ql(s)}]})}else{var d=a.get(l);if(d){var h=r.get(d.key);h||(h={oldSeries:[{dataGroupId:d.dataGroupId,data:d.data,divide:ql(d.data)}],newSeries:[]},r.set(d.key,h)),h.newSeries.push({dataGroupId:o,data:s,divide:ql(s)})}}}}),r}function DX(e,t){for(var r=0;r<e.length;r++){var n=t.seriesIndex!=null&&t.seriesIndex===e[r].seriesIndex||t.seriesId!=null&&t.seriesId===e[r].id;if(n)return r}}function sft(e,t,r,n){var a=[],i=[];O(Dt(e.from),function(o){var s=DX(t.oldSeries,o);s>=0&&a.push({dataGroupId:t.oldDataGroupIds[s],data:t.oldData[s],divide:ql(t.oldData[s]),groupIdDim:o.dimension})}),O(Dt(e.to),function(o){var s=DX(r.updatedSeries,o);if(s>=0){var l=r.updatedSeries[s].getData();i.push({dataGroupId:t.oldDataGroupIds[s],data:l,divide:ql(l),groupIdDim:o.dimension})}}),a.length>0&&i.length>0&&Nce(a,i,n)}function lft(e){e.registerUpdateLifecycle("series:beforeupdate",function(t,r,n){O(Dt(n.seriesTransition),function(a){O(Dt(a.to),function(i){for(var o=n.updatedSeries,s=0;s<o.length;s++)(i.seriesIndex!=null&&i.seriesIndex===o[s].seriesIndex||i.seriesId!=null&&i.seriesId===o[s].id)&&(o[s][a_]=!0)})})}),e.registerUpdateLifecycle("series:transition",function(t,r,n){var a=tft(r);if(a.oldSeries&&n.updatedSeries&&n.optionChanged){var i=n.seriesTransition;if(i)O(Dt(i),function(h){sft(h,a,n,r)});else{var o=oft(a,n);O(o.keys(),function(h){var p=o.get(h);Nce(p.oldSeries,p.newSeries,r)})}O(n.updatedSeries,function(h){h[a_]&&(h[a_]=!1)})}for(var s=t.getSeries(),l=a.oldSeries=[],u=a.oldDataGroupIds=[],c=a.oldData=[],f=0;f<s.length;f++){var d=s[f].getData();d.count()<Ece&&(l.push(s[f]),u.push(s[f].get("dataGroupId")),c.push(d))}})}var uft=function(){function e(){this.breaks=[],this._elapsedExtent=[1/0,-1/0]}return e.prototype.setBreaks=function(t){this.breaks=t.breaks},e.prototype.update=function(t){fft(this,t);var r=this._elapsedExtent;r[0]=this.elapse(t[0]),r[1]=this.elapse(t[1])},e.prototype.hasBreaks=function(){return!!this.breaks.length},e.prototype.calcNiceTickMultiple=function(t,r){for(var n=0;n<this.breaks.length;n++){var a=this.breaks[n];if(a.vmin<t&&t<a.vmax){var i=r(t,a.vmax);return i}}return 0},e.prototype.getExtentSpan=function(){return this._elapsedExtent[1]-this._elapsedExtent[0]},e.prototype.normalize=function(t){var r=this._elapsedExtent[1]-this._elapsedExtent[0];return r===0?.5:(this.elapse(t)-this._elapsedExtent[0])/r},e.prototype.scale=function(t){return this.unelapse(t*(this._elapsedExtent[1]-this._elapsedExtent[0])+this._elapsedExtent[0])},e.prototype.elapse=function(t){for(var r=EX,n=NX,a=!0,i=0;i<this.breaks.length;i++){var o=this.breaks[i];if(t<=o.vmax){t>o.vmin?r+=o.vmin-n+(t-o.vmin)/(o.vmax-o.vmin)*o.gapReal:r+=t-n,n=o.vmax,a=!1;break}r+=o.vmin-n+o.gapReal,n=o.vmax}return a&&(r+=t-n),r},e.prototype.unelapse=function(t){for(var r=EX,n=NX,a=!0,i=0,o=0;o<this.breaks.length;o++){var s=this.breaks[o],l=r+s.vmin-n,u=l+s.gapReal;if(t<=u){t>l?i=s.vmin+(t-l)/(u-l)*(s.vmax-s.vmin):i=n+t-r,n=s.vmax,a=!1;break}r=u,n=s.vmax}return a&&(i=n+t-r),i},e}();function cft(){return new uft}var EX=0,NX=0;function fft(e,t){var r=0,n={tpAbs:{span:0,val:0},tpPrct:{span:0,val:0}},a=function(){return{has:!1,span:NaN,inExtFrac:NaN,val:NaN}},i={S:{tpAbs:a(),tpPrct:a()},E:{tpAbs:a(),tpPrct:a()}};O(e.breaks,function(s){var l=s.gapParsed;l.type==="tpPrct"&&(r+=l.val);var u=xB(s,t);if(u){var c=u.vmin!==s.vmin,f=u.vmax!==s.vmax,d=u.vmax-u.vmin;if(!(c&&f))if(c||f){var h=c?"S":"E";i[h][l.type].has=!0,i[h][l.type].span=d,i[h][l.type].inExtFrac=d/(s.vmax-s.vmin),i[h][l.type].val=l.val}else n[l.type].span+=d,n[l.type].val+=l.val}});var o=r*(0+(t[1]-t[0])+(n.tpAbs.val-n.tpAbs.span)+(i.S.tpAbs.has?(i.S.tpAbs.val-i.S.tpAbs.span)*i.S.tpAbs.inExtFrac:0)+(i.E.tpAbs.has?(i.E.tpAbs.val-i.E.tpAbs.span)*i.E.tpAbs.inExtFrac:0)-n.tpPrct.span-(i.S.tpPrct.has?i.S.tpPrct.span*i.S.tpPrct.inExtFrac:0)-(i.E.tpPrct.has?i.E.tpPrct.span*i.E.tpPrct.inExtFrac:0))/(1-n.tpPrct.val-(i.S.tpPrct.has?i.S.tpPrct.val*i.S.tpPrct.inExtFrac:0)-(i.E.tpPrct.has?i.E.tpPrct.val*i.E.tpPrct.inExtFrac:0));O(e.breaks,function(s){var l=s.gapParsed;l.type==="tpPrct"&&(s.gapReal=r!==0?Math.max(o,0)*l.val/r:0),l.type==="tpAbs"&&(s.gapReal=l.val),s.gapReal==null&&(s.gapReal=0)})}function dft(e,t,r,n,a,i){e!=="no"&&O(r,function(o){var s=xB(o,i);if(s)for(var l=t.length-1;l>=0;l--){var u=t[l],c=n(u),f=a*3/4;c>s.vmin-f&&c<s.vmax+f&&(e!=="preserve_extent_bound"||c!==i[0]&&c!==i[1])&&t.splice(l,1)}})}function hft(e,t,r,n){O(t,function(a){var i=xB(a,r);i&&(e.push({value:i.vmin,break:{type:"vmin",parsedBreak:i},time:n?n(i):void 0}),e.push({value:i.vmax,break:{type:"vmax",parsedBreak:i},time:n?n(i):void 0}))}),t.length&&e.sort(function(a,i){return a.value-i.value})}function xB(e,t){var r=Math.max(e.vmin,t[0]),n=Math.min(e.vmax,t[1]);return r<n||r===n&&r>t[0]&&r<t[1]?{vmin:r,vmax:n,breakOption:e.breakOption,gapParsed:e.gapParsed,gapReal:e.gapReal}:null}function BI(e,t,r){var n=[];if(!e)return{breaks:n};function a(o,s){return o>=0&&o<1-1e-5}O(e,function(o){if(!(!o||o.start==null||o.end==null)&&!o.isExpanded){var s={breakOption:be(o),vmin:t(o.start),vmax:t(o.end),gapParsed:{type:"tpAbs",val:0},gapReal:null};if(o.gap!=null){var l=!1;if(se(o.gap)){var u=La(o.gap);if(u.match(/%$/)){var c=parseFloat(u)/100;a(c)||(c=0),s.gapParsed.type="tpPrct",s.gapParsed.val=c,l=!0}}if(!l){var f=t(o.gap);(!isFinite(f)||f<0)&&(f=0),s.gapParsed.type="tpAbs",s.gapParsed.val=f}}if(s.vmin===s.vmax&&(s.gapParsed.type="tpAbs",s.gapParsed.val=0),r&&r.noNegative&&O(["vmin","vmax"],function(h){s[h]<0&&(s[h]=0)}),s.vmin>s.vmax){var d=s.vmax;s.vmax=s.vmin,s.vmin=d}n.push(s)}}),n.sort(function(o,s){return o.vmin-s.vmin});var i=-1/0;return O(n,function(o,s){i>o.vmin&&(n[s]=null),i=o.vmax}),{breaks:n.filter(function(o){return!!o})}}function bB(e,t){return $I(t)===$I(e)}function $I(e){return e.start+"_\0_"+e.end}function pft(e,t,r){var n=[];O(e,function(i,o){var s=t(i);s&&s.type==="vmin"&&n.push([o])}),O(e,function(i,o){var s=t(i);if(s&&s.type==="vmax"){var l=tc(n,function(u){return bB(t(e[u[0]]).parsedBreak.breakOption,s.parsedBreak.breakOption)});l&&l.push(o)}});var a=[];return O(n,function(i){i.length===2&&a.push(r?i:[e[i[0]],e[i[1]]])}),a}function vft(e,t,r,n){var a,i;if(e.break){var o=e.break.parsedBreak,s=tc(r,function(f){return bB(f.breakOption,e.break.parsedBreak.breakOption)}),l=n(Math.pow(t,o.vmin),s.vmin),u=n(Math.pow(t,o.vmax),s.vmax),c={type:o.gapParsed.type,val:o.gapParsed.type==="tpAbs"?gr(Math.pow(t,o.vmin+o.gapParsed.val))-l:o.gapParsed.val};a={type:e.break.type,parsedBreak:{breakOption:o.breakOption,vmin:l,vmax:u,gapParsed:c,gapReal:o.gapReal}},i=s[e.break.type]}return{brkRoundingCriterion:i,vBreak:a}}function gft(e,t,r){var n={noNegative:!0},a=BI(e,r,n),i=BI(e,r,n),o=Math.log(t);return i.breaks=ne(i.breaks,function(s){var l=Math.log(s.vmin)/o,u=Math.log(s.vmax)/o,c={type:s.gapParsed.type,val:s.gapParsed.type==="tpAbs"?Math.log(s.vmin+s.gapParsed.val)/o-l:s.gapParsed.val};return{vmin:l,vmax:u,gapParsed:c,gapReal:s.gapReal,breakOption:s.breakOption}}),{parsedOriginal:a,parsedLogged:i}}var yft={vmin:"start",vmax:"end"};function mft(e,t){return t&&(e=e||{},e.break={type:yft[t.type],start:t.parsedBreak.vmin,end:t.parsedBreak.vmax}),e}function xft(){B9e({createScaleBreakContext:cft,pruneTicksByBreak:dft,addBreaksToTicks:hft,parseAxisBreakOption:BI,identifyAxisBreak:bB,serializeAxisBreakIdentifier:$I,retrieveAxisBreakPairs:pft,getTicksLogTransformBreak:vft,logarithmicParseBreaksFromOption:gft,makeAxisLabelFormatterParamBreak:mft})}var OX=Xe();function bft(e,t){var r=tc(e,function(n){return Sr().identifyAxisBreak(n.parsedBreak.breakOption,t.breakOption)});return r||e.push(r={zigzagRandomList:[],parsedBreak:t,shouldRemove:!1}),r}function wft(e){O(e,function(t){return t.shouldRemove=!0})}function _ft(e){for(var t=e.length-1;t>=0;t--)e[t].shouldRemove&&e.splice(t,1)}function Sft(e,t,r,n,a){var i=r.axis;if(i.scale.isBlank()||!Sr())return;var o=Sr().retrieveAxisBreakPairs(i.scale.getTicks({breakTicks:"only_break"}),function(A){return A.break},!1);if(!o.length)return;var s=r.getModel("breakArea"),l=s.get("zigzagAmplitude"),u=s.get("zigzagMinSpan"),c=s.get("zigzagMaxSpan");u=Math.max(2,u||0),c=Math.max(u,c||0);var f=s.get("expandOnClick"),d=s.get("zigzagZ"),h=s.getModel("itemStyle"),p=h.getItemStyle(),v=p.stroke,g=p.lineWidth,y=p.lineDash,m=p.fill,b=new we({ignoreModelZ:!0}),w=i.isHorizontal(),_=OX(t).visualList||(OX(t).visualList=[]);wft(_);for(var S=function(A){var k=o[A][0].break.parsedBreak,P=[];P[0]=i.toGlobalCoord(i.dataToCoord(k.vmin,!0)),P[1]=i.toGlobalCoord(i.dataToCoord(k.vmax,!0)),P[1]<P[0]&&P.reverse();var M=bft(_,k);M.shouldRemove=!1;var D=new we;T(M.zigzagRandomList,D,P[0],P[1],w,k),f&&D.on("click",function(){var E={type:vA,breaks:[{start:k.breakOption.start,end:k.breakOption.end}]};E[i.dim+"AxisIndex"]=r.componentIndex,a.dispatchAction(E)}),D.silent=!f,b.add(D)},C=0;C<o.length;C++)S(C);e.add(b),_ft(_);function T(A,k,P,M,D,E){var L={stroke:v,lineWidth:g,lineDash:y,fill:"none"},N=D?0:1,j=1-N,R=n[Le[j]]+n[Cr[j]];function z(fe){var le=[],Pe=[];le[N]=Pe[N]=fe,le[j]=n[Le[j]],Pe[j]=R;var _e={x1:le[0],y1:le[1],x2:Pe[0],y2:Pe[1]};return eA(_e,_e,{lineWidth:1}),le[0]=_e.x1,le[1]=_e.y1,le[N]}P=z(P),M=z(M);for(var B=[],V=[],$=!0,K=n[Le[j]],re=0;;re++){var ie=K===n[Le[j]],ye=K>=R;ye&&(K=R);var je=[],F=[];je[N]=P,F[N]=M,!ie&&!ye&&(je[N]+=$?-l:l,F[N]-=$?l:-l),je[j]=K,F[j]=K,B.push(je),V.push(F);var W=void 0;if(re<A.length?W=A[re]:(W=Math.random(),A.push(W)),K+=W*(c-u)+u,$=!$,ye)break}var ee=Sr().serializeAxisBreakIdentifier(E.breakOption);if(k.add(new nn({anid:"break_a_"+ee,shape:{points:B},style:L,z:d})),E.gapReal!==0){k.add(new nn({anid:"break_b_"+ee,shape:{points:V},style:L,z:d}));var Z=V.slice();Z.reverse();var U=B.concat(Z);k.add(new _n({anid:"break_c_"+ee,shape:{points:U},style:{fill:m,opacity:p.opacity},z:d}))}}}function Cft(e,t,r,n){var a=e.axis,i=r.transform;bn(n.style);var o=a.getExtent();a.inverse&&(o=o.slice(),o.reverse());var s=Sr().retrieveAxisBreakPairs(a.scale.getTicks({breakTicks:"only_break"}),function(g){return g.break},!1),l=ne(s,function(g){var y=g[0].break.parsedBreak,m=[a.dataToCoord(y.vmin,!0),a.dataToCoord(y.vmax,!0)];return m[0]>m[1]&&m.reverse(),{coordPair:m,brkId:Sr().serializeAxisBreakIdentifier(y.breakOption)}});l.sort(function(g,y){return g.coordPair[0]-y.coordPair[0]});for(var u=o[0],c=null,f=0;f<l.length;f++){var d=l[f],h=Math.max(d.coordPair[0],o[0]),p=Math.min(d.coordPair[1],o[1]);u<=h&&v(u,h,c,d),u=p,c=d}u<=o[1]&&v(u,o[1],c,null);function v(g,y,m,b){function w(P,M){i&&(sr(P,P,i),sr(M,M,i))}function _(P,M){var D={x1:P[0],y1:P[1],x2:M[0],y2:M[1]};eA(D,D,n.style),P[0]=D.x1,P[1]=D.y1,M[0]=D.x2,M[1]=D.y2}var S=[g,0],C=[y,0],T=[g,5],A=[y,5];w(S,T),_(S,T),w(C,A),_(C,A),_(S,C);var k=new yr(J({shape:{x1:S[0],y1:S[1],x2:C[0],y2:C[1]}},n));t.add(k),k.anid="breakLine_"+(m?m.brkId:"\0")+"_\0_"+(b?b.brkId:"\0")}}function Tft(e,t,r){if(tc(r,function(m){return!m}))return;var n=new ke;if(!hA(r[0],r[1],n,{direction:-(e?t+Math.PI:t),touchThreshold:0,bidirectional:!1}))return;var a=Hr();Tl(a,a,-t);var i=ne(r,function(m){return m.transform?io(Hr(),a,m.transform):a});function o(m){var b=r[0].localRect,w=new ke(b[Cr[m]]*i[0][0],b[Cr[m]]*i[0][1]);return Math.abs(w.y)<1e-5}var s=.5;if(o(0)||o(1)){var l=ne(r,function(m,b){var w=m.localRect.clone();return w.applyTransform(i[b]),w}),u=new ke;u.copy(r[0].label).add(r[1].label).scale(.5),u.transform(a);var c=n.clone().transform(a),f=l[0].x+l[1].x+(c.x>=0?l[0].width:l[1].width),d=(f+c.x)/2-u.x,h=Math.min(d,d-c.x),p=Math.max(d,d-c.x),v=p<0?p:h>0?h:0;s=(d-v)/c.x}var g=new ke,y=new ke;ke.scale(g,n,-s),ke.scale(y,n,1-s),FL(r[0],g),FL(r[1],y)}function Aft(e,t){var r={breaks:[]};return O(t.breaks,function(n){if(n){var a=tc(e.get("breaks",!0),function(s){return Sr().identifyAxisBreak(s,n)});if(a){var i=t.type,o={isExpanded:!!a.isExpanded};a.isExpanded=i===vA?!0:i===Qse?!1:i===ele?!a.isExpanded:a.isExpanded,r.breaks.push({start:a.start,end:a.end,isExpanded:!!a.isExpanded,old:o})}}}),r}function kft(){bJe({adjustBreakLabelPair:Tft,buildAxisBreakLine:Cft,rectCoordBuildBreakAxis:Sft,updateModelAxisBreak:Aft})}function Mft(e){AJe(e),xft(),kft()}function Pft(){YJe(Dft)}function Dft(e,t){O(e,function(r){if(!r.model.get(["axisLabel","inside"])){var n=Eft(r);if(n){var a=r.isHorizontal()?"height":"width",i=r.model.get(["axisLabel","margin"]);t[a]-=n[a]+i,r.position==="top"?t.y+=n.height+i:r.position==="left"&&(t.x+=n.width+i)}}})}function Eft(e){var t=e.model,r=e.scale;if(!t.get(["axisLabel","show"])||r.isBlank())return;var n,a,i=r.getExtent();r instanceof av?a=r.count():(n=r.getTicks(),a=n.length);var o=e.getLabelModel(),s=ng(e),l,u=1;a>40&&(u=Math.ceil(a/40));for(var c=0;c<a;c+=u){var f=n?n[c]:{value:i[0]+c},d=s(f,c),h=o.getTextRect(d),p=v(h,o.get("rotate")||0);l?l.union(p):l=p}return l;function v(g,y){var m=y*Math.PI/180,b=g.width,w=g.height,_=b*Math.abs(Math.cos(m))+Math.abs(w*Math.sin(m)),S=b*Math.abs(Math.sin(m))+Math.abs(w*Math.cos(m)),C=new Me(g.x,g.y,_,S);return C}}We([mZe]);We([hZe]);We([zZe,QZe,uJe,dQe,SQe,het,Fet,Ctt,Gtt,Jtt,art,drt,int,Pnt,$nt,rat,oat,gat,Sat,Lat,$at,Kat,Lit]);We(Qit);We(Cot);We(Ale);We(jot);We(due);We($ot);We(ost);We(vst);We(tlt);We(blt);We(lb);We(jlt);We(Blt);We(qlt);We(nut);We(uut);We(vut);We(Tut);We(Hut);We(mce);We(xce);We(cct);We(Cce);We(Tce);We(pct);We(xct);We(Nct);We(Ict);We(lft);We(OKe);We(Mft);We(Pft);We(hQe);const Nft=Object.freeze(Object.defineProperty({__proto__:null,Axis:Oi,ChartView:wt,ComponentModel:Ye,ComponentView:Et,List:$n,Model:Ze,PRIORITY:boe,SeriesModel:Tt,color:EHe,connect:jXe,dataTool:HXe,dependencies:mXe,disConnect:RXe,disconnect:Moe,dispose:zXe,env:et,extendChartView:mKe,extendComponentModel:vKe,extendComponentView:gKe,extendSeriesModel:yKe,format:eKe,getCoordinateSystemDimensions:$Xe,getInstanceByDom:Kz,getInstanceById:BXe,getMap:WXe,graphic:Qqe,helper:Gqe,init:IXe,innerDrawElementOnCanvas:Uz,matrix:oHe,number:Zqe,parseGeoJSON:BL,parseGeoJson:BL,registerAction:mo,registerCoordinateSystem:Eoe,registerCustomSeries:FXe,registerLayout:Noe,registerLoading:t5,registerLocale:Sz,registerMap:Ooe,registerPostInit:Poe,registerPostUpdate:Doe,registerPreprocessor:Jz,registerProcessor:Qz,registerTheme:Zz,registerTransform:Loe,registerUpdateLifecycle:dA,registerVisual:ic,setCanvasCreator:VXe,setPlatformAPI:vne,throttle:cA,time:Jqe,use:We,util:tKe,vector:GWe,version:yXe,zrUtil:zWe,zrender:hGe},Symbol.toStringTag,{value:"Module"}));var Bf={},Iu={},Oce={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=1;e.default=function(){return"".concat(t++)}})(Oce);var CA={},TA={},wB={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:60,a=null;return function(){for(var i=this,o=arguments.length,s=new Array(o),l=0;l<o;l++)s[l]=arguments[l];clearTimeout(a),a=setTimeout(function(){r.apply(i,s)},n)}}})(wB);var Qo={};Object.defineProperty(Qo,"__esModule",{value:!0});Qo.SizeSensorId=Qo.SensorTabIndex=Qo.SensorClassName=void 0;Qo.SizeSensorId="size-sensor-id";Qo.SensorClassName="size-sensor-object";Qo.SensorTabIndex="-1";Object.defineProperty(TA,"__esModule",{value:!0});TA.createSensor=void 0;var Oft=Lft(wB),AD=Qo;function Lft(e){return e&&e.__esModule?e:{default:e}}TA.createSensor=function(t,r){var n=void 0,a=[],i=function(){getComputedStyle(t).position==="static"&&(t.style.position="relative");var f=document.createElement("object");return f.onload=function(){f.contentDocument.defaultView.addEventListener("resize",o),o()},f.style.display="block",f.style.position="absolute",f.style.top="0",f.style.left="0",f.style.height="100%",f.style.width="100%",f.style.overflow="hidden",f.style.pointerEvents="none",f.style.zIndex="-1",f.style.opacity="0",f.setAttribute("class",AD.SensorClassName),f.setAttribute("tabindex",AD.SensorTabIndex),f.type="text/html",t.appendChild(f),f.data="about:blank",f},o=(0,Oft.default)(function(){a.forEach(function(c){c(t)})}),s=function(f){n||(n=i()),a.indexOf(f)===-1&&a.push(f)},l=function(){n&&n.parentNode&&(n.contentDocument&&n.contentDocument.defaultView.removeEventListener("resize",o),n.parentNode.removeChild(n),t.removeAttribute(AD.SizeSensorId),n=void 0,a=[],r&&r())},u=function(f){var d=a.indexOf(f);d!==-1&&a.splice(d,1),a.length===0&&n&&l()};return{element:t,bind:s,destroy:l,unbind:u}};var AA={};Object.defineProperty(AA,"__esModule",{value:!0});AA.createSensor=void 0;var Ift=Qo,jft=Rft(wB);function Rft(e){return e&&e.__esModule?e:{default:e}}AA.createSensor=function(t,r){var n=void 0,a=[],i=(0,jft.default)(function(){a.forEach(function(c){c(t)})}),o=function(){var f=new ResizeObserver(i);return f.observe(t),i(),f},s=function(f){n||(n=o()),a.indexOf(f)===-1&&a.push(f)},l=function(){n&&n.disconnect(),a=[],n=void 0,t.removeAttribute(Ift.SizeSensorId),r&&r()},u=function(f){var d=a.indexOf(f);d!==-1&&a.splice(d,1),a.length===0&&n&&l()};return{element:t,bind:s,destroy:l,unbind:u}};Object.defineProperty(CA,"__esModule",{value:!0});CA.createSensor=void 0;var zft=TA,Bft=AA;CA.createSensor=typeof ResizeObserver<"u"?Bft.createSensor:zft.createSensor;Object.defineProperty(Iu,"__esModule",{value:!0});Iu.removeSensor=Iu.getSensor=Iu.Sensors=void 0;var $ft=Vft(Oce),Fft=CA,FI=Qo;function Vft(e){return e&&e.__esModule?e:{default:e}}var bm=Iu.Sensors={};function Lce(e){e&&bm[e]&&delete bm[e]}Iu.getSensor=function(t){var r=t.getAttribute(FI.SizeSensorId);if(r&&bm[r])return bm[r];var n=(0,$ft.default)();t.setAttribute(FI.SizeSensorId,n);var a=(0,Fft.createSensor)(t,function(){return Lce(n)});return bm[n]=a,a};Iu.removeSensor=function(t){var r=t.element.getAttribute(FI.SizeSensorId);t.destroy(),Lce(r)};var _B,SB;Object.defineProperty(Bf,"__esModule",{value:!0});Bf.ver=SB=Bf.clear=_B=Bf.bind=void 0;var VI=Iu;_B=Bf.bind=function(t,r){var n=(0,VI.getSensor)(t);return n.bind(r),function(){n.unbind(r)}};SB=Bf.clear=function(t){var r=(0,VI.getSensor)(t);(0,VI.removeSensor)(r)};Bf.ver="1.0.3";function LX(e,t){var r={};return t.forEach(function(n){r[n]=e[n]}),r}function kD(e){return typeof e=="function"}function Wft(e){return typeof e=="string"}var Hft=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,a,i;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(a=n;a--!==0;)if(!e(t[a],r[a]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(i=Object.keys(t),n=i.length,n!==Object.keys(r).length)return!1;for(a=n;a--!==0;)if(!Object.prototype.hasOwnProperty.call(r,i[a]))return!1;for(a=n;a--!==0;){var o=i[a];if(!e(t[o],r[o]))return!1}return!0}return t!==t&&r!==r};const ch=Nt(Hft);var Gft=function(e){G(t,e);function t(r){var n=e.call(this,r)||this;return n.echarts=r.echarts,n.ele=null,n.isInitialResize=!0,n.eventHandlerRefs={},n}return t.prototype.componentDidMount=function(){this.renderNewEcharts()},t.prototype.componentDidUpdate=function(r){var n=this.props.shouldSetOption;if(!(kD(n)&&!n(r,this.props))){if(!ch(r.theme,this.props.theme)||!ch(r.opts,this.props.opts)){this.dispose(),this.renderNewEcharts();return}var a=this.getEchartsInstance();ch(r.onEvents,this.props.onEvents)||(this.unbindEvents(a),this.bindEvents(a,this.props.onEvents));var i=["option","notMerge","replaceMerge","lazyUpdate","showLoading","loadingOption"];ch(LX(this.props,i),LX(r,i))||this.updateEChartsOption(),(!ch(r.style,this.props.style)||!ch(r.className,this.props.className))&&this.resize()}},t.prototype.componentWillUnmount=function(){this.dispose()},t.prototype.initEchartsInstance=function(){return nW(this,void 0,void 0,function(){var r=this;return aW(this,function(n){return[2,new Promise(function(a){r.echarts.init(r.ele,r.props.theme,r.props.opts);var i=r.getEchartsInstance();i.on("finished",function(){var o=r.ele.clientWidth,s=r.ele.clientHeight;r.echarts.dispose(r.ele);var l=am({width:o,height:s},r.props.opts);a(r.echarts.init(r.ele,r.props.theme,l))})})]})})},t.prototype.getEchartsInstance=function(){return this.echarts.getInstanceByDom(this.ele)},t.prototype.dispose=function(){if(this.ele){try{SB(this.ele)}catch(r){console.warn(r)}this.echarts.dispose(this.ele)}},t.prototype.renderNewEcharts=function(){return nW(this,void 0,void 0,function(){var r,n,a,i,o,s,l=this;return aW(this,function(u){switch(u.label){case 0:return r=this.props,n=r.onEvents,a=r.onChartReady,i=r.autoResize,o=i===void 0?!0:i,[4,this.initEchartsInstance()];case 1:return u.sent(),s=this.updateEChartsOption(),this.bindEvents(s,n||{}),kD(a)&&a(s),this.ele&&o&&_B(this.ele,function(){l.resize()}),[2]}})})},t.prototype.bindEvents=function(r,n){var a=this,i=function(s,l){if(Wft(s)&&kD(l)){var u=function(c){l(c,r)};r.on(s,u),a.eventHandlerRefs[s]=u}};for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&i(o,n[o])},t.prototype.unbindEvents=function(r){for(var n=0,a=Object.entries(this.eventHandlerRefs);n<a.length;n++){var i=a[n],o=i[0],s=i[1];r.off(o,s)}this.eventHandlerRefs={}},t.prototype.updateEChartsOption=function(){var r=this.props,n=r.option,a=r.notMerge,i=a===void 0?!1:a,o=r.replaceMerge,s=o===void 0?null:o,l=r.lazyUpdate,u=l===void 0?!1:l,c=r.showLoading,f=r.loadingOption,d=f===void 0?null:f,h=this.getEchartsInstance();return h.setOption(n,{notMerge:i,replaceMerge:s,lazyUpdate:u}),c?h.showLoading(d):h.hideLoading(),h},t.prototype.resize=function(){var r=this.getEchartsInstance();if(!this.isInitialResize)try{r.resize({width:"auto",height:"auto"})}catch(n){console.warn(n)}this.isInitialResize=!1},t.prototype.render=function(){var r=this,n=this.props,a=n.style,i=n.className,o=i===void 0?"":i;n.echarts,n.option,n.theme,n.notMerge,n.replaceMerge,n.lazyUpdate,n.showLoading,n.loadingOption,n.opts,n.onChartReady,n.onEvents,n.shouldSetOption,n.autoResize;var s=bWe(n,["style","className","echarts","option","theme","notMerge","replaceMerge","lazyUpdate","showLoading","loadingOption","opts","onChartReady","onEvents","shouldSetOption","autoResize"]),l=am({height:300},a);return X.createElement("div",am({ref:function(u){r.ele=u},style:l,className:"echarts-for-react ".concat(o)},s))},t}(I.PureComponent),IX=function(e){G(t,e);function t(r){var n=e.call(this,r)||this;return n.echarts=Nft,n}return t}(Gft);const jX={"1h":36e5,"6h":216e5,"24h":864e5,"7d":6048e5,"30d":2592e6},Uft={"1h":void 0,"6h":3e5,"24h":9e5,"7d":36e5,"30d":216e5};function Yft(e,t,r){const[n,a]=I.useState(new Map),i=I.useRef(!0);I.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const o=JSON.stringify(e.map(s=>[s.id,s.datapointId,s.historyInstance,s.historyRange]));return I.useEffect(()=>{!t||e.length===0||(a(s=>{const l=new Map(s);for(const u of e){const c=l.get(u.id);l.set(u.id,{data:(c==null?void 0:c.data)??[],current:(c==null?void 0:c.current)??null,loading:!0})}return l}),e.forEach(s=>{if(!s.datapointId||!s.historyInstance){a(d=>{const h=new Map(d),p=h.get(s.id);return h.set(s.id,{data:(p==null?void 0:p.data)??[],current:(p==null?void 0:p.current)??null,loading:!1}),h});return}const l=s.historyRange??"24h",u=Date.now(),c=u-jX[l],f=Uft[l];zJ(s.datapointId,{instance:s.historyInstance,start:c,end:u,step:f,aggregate:f?"average":"none",count:1e3}).then(d=>{if(!i.current)return;const h=d.filter(v=>typeof v.val=="number").map(v=>[v.ts,v.val]).sort((v,g)=>v[0]-g[0]),p=h.length>0?h[h.length-1][1]:null;a(v=>{const g=new Map(v);return g.set(s.id,{data:h,current:p,loading:!1}),g})}).catch(()=>{i.current&&a(d=>{const h=new Map(d),p=h.get(s.id);return h.set(s.id,{data:(p==null?void 0:p.data)??[],current:(p==null?void 0:p.current)??null,loading:!1}),h})})}))},[o,t]),I.useEffect(()=>{if(!t||e.length===0)return;const s=e.filter(l=>!!l.datapointId).map(l=>{const u=l.historyRange??"24h",c=jX[u];return r(l.datapointId,f=>{if(typeof f.val!="number")return;const d=f.val;a(h=>{const p=new Map(h),v=p.get(l.id);let g;if(l.historyInstance&&v){const y=Date.now()-c,m=v.data.filter(b=>b[0]>=y);m.length>0&&m[m.length-1][0]===f.ts?g=m:g=[...m,[f.ts,d]]}else g=[...(v==null?void 0:v.data)??[],[f.ts,d]].slice(-120);return p.set(l.id,{data:g,current:d,loading:!1}),p})})});return()=>{s.forEach(l=>l())}},[o,t,r]),n}const MD=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#06b6d4"];function WI(e,t){const r={...e};for(const n of Object.keys(t))t[n]&&typeof t[n]=="object"&&!Array.isArray(t[n])&&r[n]&&typeof r[n]=="object"&&!Array.isArray(r[n])?r[n]=WI(r[n],t[n]):r[n]=t[n];return r}function Xft({config:e,editMode:t}){const{subscribe:r,connected:n}=Vn(),a=e.options??{},i=a.echartSeries??[],o=a.echartShowLegend??!0,s=a.echartLeftUnit??"",l=a.echartRightUnit??"",u=a.echartLeftMin,c=a.echartLeftMax,f=a.echartRightMin,d=a.echartRightMax,h=a.echartJsonExtra??"",p=e.layout==="gauge",v=Yft(i,n,r),g=i.length>0&&i.every(T=>{var A;return(A=v.get(T.id))==null?void 0:A.loading}),y=i.some(T=>{var A;return(((A=v.get(T.id))==null?void 0:A.data.length)??0)>0});if(g)return x.jsx("div",{className:"flex items-center justify-center h-full",style:{color:"var(--text-secondary)"},children:x.jsx(z_,{size:20,className:"animate-spin"})});if(i.length===0||!y)return x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2",style:{color:"var(--text-secondary)"},children:[x.jsx(Cu,{size:28,strokeWidth:1.5}),x.jsx("span",{className:"text-xs",children:"Keine Daten"}),t&&e.title&&x.jsx("span",{className:"absolute top-1 left-2 text-[10px] font-medium",style:{color:"var(--text-secondary)"},children:e.title})]});if(p){const T=i[0],A=v.get((T==null?void 0:T.id)??""),k=(A==null?void 0:A.current)??0,P=(T==null?void 0:T.color)??MD[0],M={backgroundColor:"transparent",series:[{type:"gauge",radius:"85%",progress:{show:!0,width:12},axisLine:{lineStyle:{width:12,color:[[1,"#333"]]}},axisTick:{show:!1},splitLine:{length:8,lineStyle:{color:"#555",width:1}},axisLabel:{color:"#888",fontSize:10},pointer:{show:!0,length:"60%",width:4},itemStyle:{color:P},detail:{formatter:`{value}${s?" "+s:""}`,color:"var(--text-primary)",fontSize:16,offsetCenter:[0,"70%"]},title:{color:"#888",fontSize:11},data:[{value:k,name:(T==null?void 0:T.name)??""}]}]};let D=M;if(h)try{const E=JSON.parse(h);D=WI(M,E)}catch{}return x.jsxs("div",{className:"relative w-full h-full",children:[t&&e.title&&x.jsx("span",{className:"absolute top-1 left-2 text-[10px] font-medium z-10",style:{color:"var(--text-secondary)"},children:e.title}),x.jsx(IX,{option:D,style:{width:"100%",height:"100%"},opts:{renderer:"canvas"}})]})}const m=i.some(T=>(T.yAxisIndex??0)===1),b={type:"value",axisLabel:{color:"#888",fontSize:10,formatter:s?`{value} ${s}`:"{value}"},axisLine:{lineStyle:{color:"#444"}},splitLine:{lineStyle:{color:"#333"}},...u!==void 0?{min:u}:{},...c!==void 0?{max:c}:{}},w=m?{type:"value",axisLabel:{color:"#888",fontSize:10,formatter:l?`{value} ${l}`:"{value}"},axisLine:{lineStyle:{color:"#444"}},splitLine:{show:!1},...f!==void 0?{min:f}:{},...d!==void 0?{max:d}:{}}:{show:!1},_=i.map((T,A)=>{var P;const k=((P=v.get(T.id))==null?void 0:P.data)??[];return{name:T.name,type:T.chartType==="area"?"line":T.chartType,areaStyle:T.chartType==="area"?{opacity:.2}:void 0,smooth:T.smooth??(T.chartType==="line"||T.chartType==="area"),lineStyle:{width:T.lineWidth??2},itemStyle:{color:T.color??MD[A%MD.length]},data:k,yAxisIndex:T.yAxisIndex??0,showSymbol:!1}}),S={backgroundColor:"transparent",tooltip:{trigger:"axis",backgroundColor:"var(--app-surface, #1e1e1e)",borderColor:"var(--app-border, #333)",textStyle:{color:"var(--text-primary, #ccc)",fontSize:11},formatter:T=>{const A=T;if(!(A!=null&&A.length))return"";const k=A[0].axisValue,M=new Date(k).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"}),D=A.map(E=>`${E.marker} ${E.seriesName}: <b>${E.value[1]}</b>`);return`${M}<br/>${D.join("<br/>")}`}},legend:o?{show:!0,textStyle:{color:"#888",fontSize:11},top:4}:{show:!1},grid:{left:60,right:m?60:20,top:o?30:16,bottom:40,containLabel:!1},xAxis:{type:"time",axisLabel:{color:"#888",fontSize:10},axisLine:{lineStyle:{color:"#444"}},splitLine:{show:!1}},yAxis:[b,w],series:_};let C=S;if(h)try{const T=JSON.parse(h);C=WI(S,T)}catch{}return x.jsxs("div",{className:"relative w-full h-full",children:[t&&e.title&&x.jsx("span",{className:"absolute top-1 left-2 text-[10px] font-medium z-10",style:{color:"var(--text-secondary)"},children:e.title}),x.jsx(IX,{option:C,style:{width:"100%",height:"100%"},opts:{renderer:"canvas"}})]})}const qft=["1h","6h","24h","7d","30d"],RX=[{id:"line",label:"Linie"},{id:"area",label:"Fläche"},{id:"bar",label:"Balken"},{id:"scatter",label:"Punkte"}];function Kft(){return Math.random().toString(36).slice(2,9)}const $l="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",Ri={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};function Zft({config:e,onConfigChange:t}){var P;const r=e.options??{},n=r.echartSeries??[],a=r.echartShowLegend??!0,i=r.echartLeftUnit??"",o=r.echartRightUnit??"",s=r.echartLeftMin??"",l=r.echartLeftMax??"",u=r.echartRightMin??"",c=r.echartRightMax??"",f=r.echartJsonExtra??"",[d,h]=I.useState(null),[p,v]=I.useState(null),[g,y]=I.useState({}),[m,b]=I.useState(!1),w=M=>t({...e,options:{...r,...M}}),_=M=>w({echartSeries:M}),S=(M,D)=>{_(n.map(E=>E.id===M?{...E,...D}:E))},C=()=>{const M=Kft(),D={id:M,name:`Serie ${n.length+1}`,datapointId:"",chartType:"line",color:["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#06b6d4"][n.length%6],historyRange:"24h",smooth:!0,yAxisIndex:0,lineWidth:2};_([...n,D]),h(M)},T=M=>{_(n.filter(D=>D.id!==M)),d===M&&h(null)},A=(M,D)=>{const E=n.findIndex(j=>j.id===M);if(E<0)return;const L=[...n],N=E+D;N<0||N>=L.length||([L[E],L[N]]=[L[N],L[E]],_(L))};I.useEffect(()=>{for(const M of n)!M.datapointId||g[M.id]||(y(E=>({...E,[M.id]:{adapters:[],checking:!0}})),W_(M.datapointId).then(E=>{var j;const L=(j=E==null?void 0:E.common)==null?void 0:j.custom,N=L?q_(L):[];y(R=>({...R,[M.id]:{adapters:N,checking:!1}}))}).catch(()=>{y(E=>({...E,[M.id]:{adapters:[],checking:!1}}))}))},[n.map(M=>M.datapointId).join(",")]);const k=(M,D)=>{D&&(y(E=>({...E,[M]:{adapters:[],checking:!0}})),W_(D).then(E=>{var j;const L=(j=E==null?void 0:E.common)==null?void 0:j.custom,N=L?q_(L):[];y(R=>({...R,[M]:{adapters:N,checking:!1}}))}).catch(()=>{y(E=>({...E,[M]:{adapters:[],checking:!1}}))}))};return x.jsxs("div",{className:"flex flex-col gap-0 overflow-y-auto",style:{maxHeight:"80vh"},children:[x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center justify-between mb-2",children:[x.jsx("p",{className:"text-[11px] font-semibold",style:{color:"var(--text-secondary)"},children:"Serien"}),x.jsxs("button",{onClick:C,className:"flex items-center gap-1 text-[11px] px-2 py-1 rounded-md hover:opacity-80 transition-opacity",style:{background:"var(--accent)",color:"#fff"},children:[x.jsx(cs,{size:11}),"Serie hinzufügen"]})]}),n.length===0&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:'Noch keine Serien. Klicke "Serie hinzufügen".'}),x.jsx("div",{className:"flex flex-col gap-1.5",children:n.map((M,D)=>{var N;const E=d===M.id,L=g[M.id];return x.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 cursor-pointer select-none",style:{background:"var(--app-bg)"},onClick:()=>h(E?null:M.id),children:[x.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{background:M.color??"#3b82f6"}}),x.jsx("span",{className:"flex-1 text-xs truncate",style:{color:"var(--text-primary)"},children:M.name||`Serie ${D+1}`}),x.jsx("span",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:((N=RX.find(j=>j.id===M.chartType))==null?void 0:N.label)??M.chartType}),x.jsxs("div",{className:"flex items-center gap-0.5",onClick:j=>j.stopPropagation(),children:[x.jsx("button",{onClick:()=>A(M.id,-1),disabled:D===0,className:"p-0.5 rounded hover:opacity-80 disabled:opacity-30",style:{color:"var(--text-secondary)"},title:"Nach oben",children:x.jsx(Sge,{size:11})}),x.jsx("button",{onClick:()=>A(M.id,1),disabled:D===n.length-1,className:"p-0.5 rounded hover:opacity-80 disabled:opacity-30",style:{color:"var(--text-secondary)"},title:"Nach unten",children:x.jsx(Us,{size:11})}),x.jsx("button",{onClick:()=>T(M.id),className:"p-0.5 rounded hover:opacity-80",style:{color:"var(--accent-red, #ef4444)"},title:"Serie löschen",children:x.jsx(fs,{size:11})})]}),x.jsx(Us,{size:12,style:{color:"var(--text-secondary)",transform:E?"rotate(180deg)":"none",transition:"transform 0.15s"}})]}),E&&x.jsxs("div",{className:"px-2.5 pb-2.5 pt-1.5 flex flex-col gap-2",style:{borderTop:"1px solid var(--app-border)"},children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Name"}),x.jsx("input",{type:"text",value:M.name,onChange:j=>S(M.id,{name:j.target.value}),className:$l,style:Ri})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Datenpunkt"}),x.jsxs("div",{className:"flex gap-1",children:[x.jsx("input",{type:"text",value:M.datapointId,onChange:j=>{S(M.id,{datapointId:j.target.value}),j.target.value&&y(R=>{const z={...R};return delete z[M.id],z})},placeholder:"z.B. hm-rpc.0....",className:"flex-1 text-xs rounded-lg px-2.5 py-2 font-mono focus:outline-none min-w-0",style:Ri}),x.jsx("button",{onClick:()=>v(M.id),className:"px-2 rounded-lg hover:opacity-80 shrink-0",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},title:"Aus ioBroker wählen",children:x.jsx(sl,{size:13})})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Diagrammtyp"}),x.jsx("div",{className:"flex gap-1",children:RX.map(j=>x.jsx("button",{onClick:()=>S(M.id,{chartType:j.id}),className:"flex-1 text-[11px] py-1 rounded-md hover:opacity-80 transition-opacity",style:{background:M.chartType===j.id?"var(--accent)":"var(--app-bg)",color:M.chartType===j.id?"#fff":"var(--text-secondary)",border:`1px solid ${M.chartType===j.id?"var(--accent)":"var(--app-border)"}`},children:j.label},j.id))})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Farbe"}),x.jsxs("div",{className:"flex gap-1.5 items-center",children:[x.jsx("input",{type:"color",value:M.color??"#3b82f6",onChange:j=>S(M.id,{color:j.target.value}),className:"w-8 h-8 rounded cursor-pointer border-0 bg-transparent"}),x.jsx("input",{type:"text",value:M.color??"#3b82f6",onChange:j=>S(M.id,{color:j.target.value}),className:"flex-1 text-xs rounded-lg px-2.5 py-2 font-mono focus:outline-none",style:Ri,placeholder:"#3b82f6"})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Y-Achse"}),x.jsx("div",{className:"flex gap-1",children:[0,1].map(j=>x.jsx("button",{onClick:()=>S(M.id,{yAxisIndex:j}),className:"flex-1 text-[11px] py-1 rounded-md hover:opacity-80 transition-opacity",style:{background:(M.yAxisIndex??0)===j?"var(--accent)":"var(--app-bg)",color:(M.yAxisIndex??0)===j?"#fff":"var(--text-secondary)",border:`1px solid ${(M.yAxisIndex??0)===j?"var(--accent)":"var(--app-border)"}`},children:j===0?"Links":"Rechts"},j))})]}),(M.chartType==="line"||M.chartType==="area")&&x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Glatt"}),x.jsx("button",{onClick:()=>S(M.id,{smooth:!(M.smooth??!0)}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:M.smooth??!0?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:M.smooth??!0?"18px":"2px"}})})]}),(M.chartType==="line"||M.chartType==="area")&&x.jsxs("div",{children:[x.jsxs("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:["Linienstärke: ",M.lineWidth??2,"px"]}),x.jsx("input",{type:"range",min:1,max:4,step:1,value:M.lineWidth??2,onChange:j=>S(M.id,{lineWidth:Number(j.target.value)}),className:"w-full accent-[var(--accent)]"})]}),x.jsxs("div",{children:[x.jsx("div",{className:"h-px my-1",style:{background:"var(--app-border)"}}),x.jsx("p",{className:"text-[11px] font-semibold mb-1.5",style:{color:"var(--text-secondary)"},children:"Verlaufsdaten"}),!M.datapointId&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Erst Datenpunkt wählen."}),M.datapointId&&(L==null?void 0:L.checking)&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Prüfe Adapter…"}),M.datapointId&&!(L!=null&&L.checking)&&!L&&x.jsx("button",{onClick:()=>k(M.id,M.datapointId),className:"text-[11px] hover:opacity-80",style:{color:"var(--accent)"},children:"Adapter erkennen"}),M.datapointId&&L&&!L.checking&&L.adapters.length===0&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Kein History-Adapter aktiv."}),M.datapointId&&L&&!L.checking&&L.adapters.length>0&&x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Adapter-Instanz"}),x.jsxs("select",{value:M.historyInstance??"",onChange:j=>S(M.id,{historyInstance:j.target.value||void 0}),className:$l,style:Ri,children:[x.jsx("option",{value:"",children:"– Live-Daten –"}),L.adapters.map(j=>x.jsx("option",{value:j.instance,children:j.label},j.instance))]})]}),M.historyInstance&&x.jsxs("div",{className:"mt-1.5",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Zeitraum"}),x.jsx("div",{className:"flex gap-1 flex-wrap",children:qft.map(j=>x.jsx("button",{onClick:()=>S(M.id,{historyRange:j}),className:"flex-1 text-[11px] py-1 rounded-md hover:opacity-80 transition-opacity",style:{background:(M.historyRange??"24h")===j?"var(--accent)":"var(--app-bg)",color:(M.historyRange??"24h")===j?"#fff":"var(--text-secondary)",border:`1px solid ${(M.historyRange??"24h")===j?"var(--accent)":"var(--app-border)"}`,minWidth:36},children:jR[j]},j))})]})]})]})]},M.id)})})]}),x.jsxs("div",{className:"mt-3",children:[x.jsx("div",{className:"h-px mb-2",style:{background:"var(--app-border)"}}),x.jsx("p",{className:"text-[11px] font-semibold mb-2",style:{color:"var(--text-secondary)"},children:"Globale Einstellungen"}),x.jsxs("div",{className:"flex items-center justify-between mb-2",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Legende anzeigen"}),x.jsx("button",{onClick:()=>w({echartShowLegend:!a}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:a?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:a?"18px":"2px"}})})]}),x.jsxs("div",{className:"mb-2",children:[x.jsx("p",{className:"text-[11px] mb-1 font-medium",style:{color:"var(--text-secondary)"},children:"Y-Achse links"}),x.jsx("div",{className:"flex gap-1.5 mb-1",children:x.jsx("input",{type:"text",value:i,onChange:M=>w({echartLeftUnit:M.target.value||void 0}),placeholder:"Einheit (z.B. °C)",className:$l+" flex-1",style:Ri})}),x.jsxs("div",{className:"flex gap-1.5",children:[x.jsx("input",{type:"number",value:s,onChange:M=>w({echartLeftMin:M.target.value!==""?Number(M.target.value):void 0}),placeholder:"Min",className:$l+" flex-1",style:Ri}),x.jsx("input",{type:"number",value:l,onChange:M=>w({echartLeftMax:M.target.value!==""?Number(M.target.value):void 0}),placeholder:"Max",className:$l+" flex-1",style:Ri})]})]}),x.jsxs("div",{className:"mb-2",children:[x.jsx("p",{className:"text-[11px] mb-1 font-medium",style:{color:"var(--text-secondary)"},children:"Y-Achse rechts"}),x.jsx("div",{className:"flex gap-1.5 mb-1",children:x.jsx("input",{type:"text",value:o,onChange:M=>w({echartRightUnit:M.target.value||void 0}),placeholder:"Einheit (z.B. %)",className:$l+" flex-1",style:Ri})}),x.jsxs("div",{className:"flex gap-1.5",children:[x.jsx("input",{type:"number",value:u,onChange:M=>w({echartRightMin:M.target.value!==""?Number(M.target.value):void 0}),placeholder:"Min",className:$l+" flex-1",style:Ri}),x.jsx("input",{type:"number",value:c,onChange:M=>w({echartRightMax:M.target.value!==""?Number(M.target.value):void 0}),placeholder:"Max",className:$l+" flex-1",style:Ri})]})]})]}),x.jsxs("div",{className:"mt-1",children:[x.jsx("div",{className:"h-px mb-2",style:{background:"var(--app-border)"}}),x.jsxs("button",{onClick:()=>b(M=>!M),className:"flex items-center gap-1.5 w-full text-[11px] font-semibold mb-1 hover:opacity-80 text-left",style:{color:"var(--text-secondary)"},children:[x.jsx(Us,{size:12,style:{transform:m?"rotate(180deg)":"none",transition:"transform 0.15s"}}),"JSON-Override",f&&x.jsx("span",{className:"ml-auto text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--accent)22",color:"var(--accent)"},children:"aktiv"})]}),m&&x.jsxs(x.Fragment,{children:[x.jsx("p",{className:"text-[10px] mb-1 leading-tight",style:{color:"var(--text-secondary)"},children:"Wird mit der auto-generierten ECharts-Option zusammengeführt (deep merge). Arrays werden ersetzt."}),x.jsx("textarea",{value:f,onChange:M=>w({echartJsonExtra:M.target.value||void 0}),placeholder:`{
602
602
  "series": [...]
603
- }`,rows:6,className:"w-full text-xs rounded-lg px-2.5 py-2 font-mono focus:outline-none resize-y",style:Ri})]})]}),p&&x.jsx(Av,{currentValue:((P=n.find(M=>M.id===p))==null?void 0:P.datapointId)??"",onSelect:M=>{S(p,{datapointId:M}),y(D=>{const E={...D};return delete E[p],E}),v(null)},onClose:()=>v(null)})]})}function Os(e){return(e/1e3).toFixed(1)+" kW"}function Jft(e){const t=Math.floor(e/1e9),r=Math.floor(t/3600),n=Math.floor(t%3600/60);return r>0?`${r}:${String(n).padStart(2,"0")} h`:`${n}:${String(t%60).padStart(2,"0")} min`}function Wh(e){return Math.round(e)+"%"}const Qft={off:0,pv:1,minpv:2,now:3},zX=[{key:"off",label:"AUS",activeColor:"#6b7280"},{key:"pv",label:"PV",activeColor:"#f59e0b"},{key:"minpv",label:"MIN+PV",activeColor:"#f97316"},{key:"now",label:"SOFORT",activeColor:"#ef4444"}],edt={pvPower:0,gridPower:0,homePower:0,batteryPower:0,batterySoc:0,batteryMode:"",greenShareHome:0,greenShareLoadpoints:0,tariffGrid:0},tdt={chargePower:0,chargedEnergy:0,charging:!1,connected:!1,mode:"off",vehicleTitle:"",vehicleSoc:0,vehicleRange:0,effectiveLimitSoc:80,sessionSolarPercentage:0,sessionPrice:0,planActive:!1,effectivePlanTime:"",chargeDuration:0,phasesActive:0,title:""};function rdt(e,t){const{subscribe:r,getState:n}=Vn(),[a,i]=I.useState({...edt}),[o,s]=I.useState(Array.from({length:t},()=>({...tdt}))),l=I.useCallback((c,f)=>{i(d=>({...d,[c]:f??d[c]}))},[]),u=I.useCallback((c,f,d)=>{s(h=>{const p=[...h];return p[c]={...p[c],[f]:d??p[c][f]},p})},[]);return I.useEffect(()=>{const c=[],f=[["pvPower","pvPower"],["gridPower","gridPower"],["homePower","homePower"],["batteryPower","batteryPower"],["batterySoc","batterySoc"],["batteryMode","batteryMode"],["greenShareHome","greenShareHome"],["greenShareLoadpoints","greenShareLoadpoints"],["tariffGrid","tariffGrid"]];for(const[d,h]of f){const p=`${e}.status.${d}`,v=g=>l(h,g.val);c.push(r(p,v)),n(p).then(g=>{g&&l(h,g.val)})}for(let d=1;d<=t;d++){const h=d-1,p=`${e}.loadpoint.${d}.status`,v=[["chargePower","chargePower"],["chargedEnergy","chargedEnergy"],["charging","charging"],["connected","connected"],["mode","mode"],["vehicleTitle","vehicleTitle"],["vehicleSoc","vehicleSoc"],["vehicleRange","vehicleRange"],["effectiveLimitSoc","effectiveLimitSoc"],["sessionSolarPercentage","sessionSolarPercentage"],["sessionPrice","sessionPrice"],["planActive","planActive"],["effectivePlanTime","effectivePlanTime"],["chargeDuration","chargeDuration"],["phasesActive","phasesActive"],["title","title"]];for(const[g,y]of v){const m=`${p}.${g}`,b=w=>u(h,y,w.val);c.push(r(m,b)),n(m).then(w=>{w&&u(h,y,w.val)})}}return()=>c.forEach(d=>d())},[e,t,r,n,l,u]),{site:a,loadpoints:o}}function BX({site:e,showBattery:t,compact:r}){const n=e.gridPower>0,a=e.gridPower<0,i=n?"#ef4444":a?"#10b981":"var(--text-secondary)",o=e.batteryPower<0,s=o?"#3b82f6":"#f59e0b";return r?x.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[x.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium",children:[x.jsx(Wm,{size:13,color:"#f59e0b"}),x.jsx("span",{style:{color:"#f59e0b"},children:Os(e.pvPower)})]}),x.jsx("span",{style:{color:"var(--text-secondary)",fontSize:10},children:"·"}),x.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium",children:[x.jsx(DE,{size:13,color:"var(--text-secondary)"}),x.jsx("span",{style:{color:"var(--text-primary)"},children:Os(e.homePower)})]}),x.jsx("span",{style:{color:"var(--text-secondary)",fontSize:10},children:"·"}),x.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium",children:[x.jsx(ll,{size:13,color:i}),x.jsx("span",{style:{color:i},children:Os(Math.abs(e.gridPower))})]}),t&&e.batterySoc>0&&x.jsxs(x.Fragment,{children:[x.jsx("span",{style:{color:"var(--text-secondary)",fontSize:10},children:"·"}),x.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium",children:[x.jsx(w4,{size:13,color:s}),x.jsx("span",{style:{color:s},children:Wh(e.batterySoc)})]})]})]}):x.jsxs("div",{className:"space-y-1.5",children:[x.jsxs("div",{className:"flex items-center justify-between gap-1",children:[x.jsxs("div",{className:"flex flex-col items-center gap-0.5 min-w-0",children:[x.jsx(Wm,{size:18,color:"#f59e0b"}),x.jsx("span",{className:"text-xs font-semibold whitespace-nowrap",style:{color:"#f59e0b"},children:Os(e.pvPower)}),x.jsx("span",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:"Solar"})]}),x.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[x.jsx("div",{className:"h-px flex-1",style:{background:"#f59e0b",opacity:.5}}),x.jsx("span",{style:{color:"#f59e0b",fontSize:10},children:"▶"})]}),x.jsxs("div",{className:"flex flex-col items-center gap-0.5 min-w-0",children:[x.jsx(DE,{size:18,color:"var(--text-secondary)"}),x.jsx("span",{className:"text-xs font-semibold whitespace-nowrap",style:{color:"var(--text-primary)"},children:Os(e.homePower)}),x.jsx("span",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:"Haus"})]}),x.jsx("div",{className:"flex-1 flex items-center justify-center",children:n?x.jsxs(x.Fragment,{children:[x.jsx("span",{style:{color:i,fontSize:10},children:"◀"}),x.jsx("div",{className:"h-px flex-1",style:{background:i,opacity:.5}})]}):x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"h-px flex-1",style:{background:i,opacity:.5}}),x.jsx("span",{style:{color:i,fontSize:10},children:"▶"})]})}),x.jsxs("div",{className:"flex flex-col items-center gap-0.5 min-w-0",children:[x.jsx(ll,{size:18,color:i}),x.jsx("span",{className:"text-xs font-semibold whitespace-nowrap",style:{color:i},children:Os(Math.abs(e.gridPower))}),x.jsx("span",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:n?"Bezug":a?"Einspsg.":"Netz"})]})]}),t&&e.batterySoc>0&&x.jsx("div",{className:"flex items-center justify-center gap-2 pt-0.5",children:x.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-lg",style:{background:"var(--app-bg)"},children:[o?x.jsx("span",{style:{color:s,fontSize:10},children:"▼"}):x.jsx("span",{style:{color:s,fontSize:10},children:"▲"}),x.jsx(w4,{size:14,color:s}),x.jsx("span",{className:"text-xs font-semibold",style:{color:s},children:Wh(e.batterySoc)}),e.batteryPower!==0&&x.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:["· ",Os(Math.abs(e.batteryPower))]}),e.batteryMode&&e.batteryMode!=="normal"&&e.batteryMode!=="unknown"&&x.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:["· ",e.batteryMode]})]})})]})}function ndt({current:e,target:t,color:r}){return x.jsxs("div",{className:"relative h-2 rounded-full overflow-hidden",style:{background:"var(--app-border)"},children:[x.jsx("div",{className:"absolute left-0 top-0 h-full rounded-full transition-all duration-500",style:{width:`${Math.min(100,e)}%`,background:r}}),t>0&&t<100&&x.jsx("div",{className:"absolute top-0 h-full w-0.5",style:{left:`${t}%`,background:"var(--text-primary)",opacity:.6}})]})}function $X({lp:e,idx:t,prefix:r,compact:n}){var u;const{setState:a}=Vn(),i=c=>{a(`${r}.loadpoint.${t+1}.control.pvControl`,Qft[c])},o=c=>{a(`${r}.loadpoint.${t+1}.control.limitSoc`,c)},s=e.title||`Ladepunkt ${t+1}`,l=e.vehicleTitle||"Fahrzeug";return n?x.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-xs",children:[e.connected?x.jsx(C4,{size:13,color:"#6366f1"}):x.jsx(T4,{size:13,color:"var(--text-secondary)"}),x.jsx("span",{style:{color:e.connected?"var(--text-primary)":"var(--text-secondary)"},children:e.connected?l:s}),e.vehicleSoc>0&&x.jsxs("span",{style:{color:"#6366f1"},children:[Wh(e.vehicleSoc),"→",Wh(e.effectiveLimitSoc)]}),e.charging&&x.jsxs("span",{className:"flex items-center gap-1",style:{color:"#6366f1"},children:[x.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full animate-pulse",style:{background:"#6366f1"}}),Os(e.chargePower)]}),x.jsx("span",{className:"ml-auto font-medium",style:{color:"var(--text-secondary)"},children:((u=zX.find(c=>c.key===e.mode))==null?void 0:u.label)??e.mode})]}):x.jsxs("div",{className:"space-y-2 pt-2 border-t",style:{borderColor:"var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center gap-2",children:[e.connected?x.jsx(C4,{size:16,color:"#6366f1"}):x.jsx(T4,{size:16,color:"var(--text-secondary)"}),x.jsx("span",{className:"text-sm font-semibold flex-1 truncate",style:{color:"var(--text-primary)"},children:e.connected?l:s}),e.charging&&x.jsxs("span",{className:"flex items-center gap-1 text-xs",style:{color:"#6366f1"},children:[x.jsx("span",{className:"inline-block w-2 h-2 rounded-full animate-pulse",style:{background:"#6366f1"}}),"Laden"]}),e.chargePower>0&&x.jsx("span",{className:"text-xs font-bold",style:{color:"#6366f1"},children:Os(e.chargePower)})]}),e.connected&&e.vehicleSoc>0&&x.jsxs("div",{className:"space-y-1",children:[x.jsxs("div",{className:"flex items-center justify-between text-[11px]",style:{color:"var(--text-secondary)"},children:[x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx(vge,{size:11}),x.jsx("span",{children:Wh(e.vehicleSoc)}),e.vehicleRange>0&&x.jsxs("span",{children:["· ",Math.round(e.vehicleRange)," km"]})]}),x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx("span",{children:"Ziel:"}),x.jsx("button",{className:"font-semibold hover:opacity-80 transition-opacity",style:{color:"#6366f1"},onClick:()=>o(Math.min(100,e.effectiveLimitSoc+10)),title:"Ziel-SoC anpassen",children:Wh(e.effectiveLimitSoc)}),e.sessionSolarPercentage>0&&x.jsxs("span",{style:{color:"#10b981"},children:["· 🌿 ",Math.round(e.sessionSolarPercentage),"%"]})]})]}),x.jsx(ndt,{current:e.vehicleSoc,target:e.effectiveLimitSoc,color:"#6366f1"})]}),e.charging&&x.jsxs("div",{className:"flex items-center gap-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[e.chargeDuration>0&&x.jsx("span",{children:Jft(e.chargeDuration)}),e.chargedEnergy>0&&x.jsxs("span",{children:[(e.chargedEnergy/1e3).toFixed(2)," kWh"]}),e.sessionPrice>0&&x.jsxs("span",{children:[e.sessionPrice.toFixed(2)," €"]}),e.phasesActive>0&&x.jsxs("span",{children:[e.phasesActive,"ϕ"]}),e.planActive&&e.effectivePlanTime&&x.jsxs("span",{style:{color:"#f59e0b"},children:["📅 ",new Date(e.effectivePlanTime).toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})]})]}),x.jsx("div",{className:"flex gap-1",children:zX.map(c=>{const f=e.mode===c.key;return x.jsx("button",{onClick:()=>i(c.key),className:"flex-1 text-[11px] font-medium rounded-md transition-all duration-150 hover:opacity-90 active:scale-95",style:{minHeight:28,background:f?c.activeColor:"var(--app-bg)",color:f?"#fff":"var(--text-secondary)",border:`1px solid ${f?c.activeColor:"var(--app-border)"}`},children:c.label},c.key)})})]})}function adt({config:e}){const{connected:t}=Vn(),r=e.options??{},n=r.evccPrefix??"evcc.0",a=Math.max(1,Math.min(4,r.loadpointCount??1)),i=r.showBattery??!0,o=e.layout??"default",s=o==="compact"||o==="minimal",{site:l,loadpoints:u}=rdt(n,a);return t?s?x.jsxs("div",{className:"flex flex-col gap-1.5 h-full justify-center px-1",children:[x.jsx(BX,{site:l,showBattery:i,compact:!0}),u.map((c,f)=>x.jsx($X,{lp:c,idx:f,prefix:n,compact:!0},f))]}):x.jsxs("div",{className:"flex flex-col gap-3 h-full overflow-auto",children:[x.jsx(BX,{site:l,showBattery:i,compact:!1}),u.map((c,f)=>x.jsx($X,{lp:c,idx:f,prefix:n,compact:!1},f)),l.tariffGrid>0&&x.jsxs("div",{className:"text-[10px] text-right",style:{color:"var(--text-secondary)"},children:[l.tariffGrid.toFixed(4)," €/kWh"]})]}):x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2",style:{color:"var(--text-secondary)"},children:[x.jsx(ll,{size:24,strokeWidth:1.5}),x.jsx("span",{className:"text-xs",children:"Keine Verbindung"})]})}function idt({config:e,onConfigChange:t}){const r=e.options??{},n=u=>t({...e,options:{...r,...u}}),a=r.evccPrefix??"evcc.0",i=r.loadpointCount??1,o=r.showBattery??!0,s="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",l={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};return x.jsxs(x.Fragment,{children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"evcc Präfix"}),x.jsx("input",{type:"text",value:a,onChange:u=>n({evccPrefix:u.target.value||"evcc.0"}),placeholder:"evcc.0",className:s+" font-mono",style:l})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Ladepunkte"}),x.jsx("div",{className:"flex gap-1",children:[1,2,3,4].map(u=>x.jsx("button",{onClick:()=>n({loadpointCount:u}),className:"flex-1 text-xs py-1.5 rounded-lg transition-all",style:{background:i===u?"var(--accent)":"var(--app-bg)",color:i===u?"#fff":"var(--text-secondary)",border:`1px solid ${i===u?"var(--accent)":"var(--app-border)"}`},children:u},u))})]}),x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Batterie anzeigen"}),x.jsx("button",{onClick:()=>n({showBattery:!o}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:o?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:o?"18px":"2px"}})})]})]})}function FX(e){return e===0?{desc:"Sonnig",emoji:"☀️"}:e===1?{desc:"Leicht bewölkt",emoji:"🌤️"}:e===2?{desc:"Bewölkt",emoji:"⛅"}:e===3?{desc:"Bedeckt",emoji:"☁️"}:e===45||e===48?{desc:"Nebel",emoji:"🌫️"}:e>=51&&e<=55?{desc:"Nieselregen",emoji:"🌦️"}:e>=61&&e<=65?{desc:"Regen",emoji:"🌧️"}:e>=71&&e<=75?{desc:"Schnee",emoji:"❄️"}:e>=80&&e<=82?{desc:"Schauer",emoji:"🌦️"}:e===95?{desc:"Gewitter",emoji:"⛈️"}:{desc:"Unbekannt",emoji:"🌡️"}}function odt(e,t=!0){return new Date(e).toLocaleDateString("de-DE",{weekday:t?"short":"long"})}function sdt({config:e}){const t=e.options??{},r=t.latitude??48.1,n=t.longitude??11.6,a=t.locationName??"",i=t.refreshMinutes??30,o=t.showForecast??!0,s=t.forecastDays??6,l=e.layout??"default",[u,c]=I.useState(null),[f,d]=I.useState(!0),[h,p]=I.useState(!1);if(I.useEffect(()=>{let k=!1;const P=async()=>{try{const D=Math.min(Math.max(s+1,4),8),E=`https://api.open-meteo.com/v1/forecast?latitude=${r}&longitude=${n}&current=temperature_2m,relative_humidity_2m,weather_code,wind_speed_10m,apparent_temperature&daily=weather_code,temperature_2m_max,temperature_2m_min&timezone=auto&forecast_days=${D}&wind_speed_unit=kmh`,L=await fetch(E);if(!L.ok)throw new Error("HTTP error");const N=await L.json();k||(c(N),p(!1),d(!1))}catch{k||(p(!0),d(!1))}};d(!0),P();const M=setInterval(P,i*6e4);return()=>{k=!0,clearInterval(M)}},[r,n,i,s]),f&&!u)return x.jsx("div",{className:"flex items-center justify-center h-full",children:x.jsx(z_,{size:24,className:"animate-spin",style:{color:"var(--text-secondary)"}})});if(!u)return x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2",style:{color:"var(--text-secondary)"},children:[x.jsx("span",{className:"text-2xl",children:"🌡️"}),x.jsx("span",{className:"text-xs",children:"Wetterdaten nicht verfügbar"})]});const v=u.current,g=FX(v.weather_code),y=`${Math.round(v.temperature_2m)}°C`,m=`${Math.round(v.apparent_temperature)}°`;if(l==="minimal")return x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[x.jsx("span",{style:{fontSize:"2.5rem",lineHeight:1},children:g.emoji}),x.jsxs("span",{className:"text-3xl font-black",style:{color:"var(--text-primary)"},children:[Math.round(v.temperature_2m),"°"]})]});if(l==="compact")return x.jsxs("div",{className:"flex items-center gap-2.5 h-full",children:[x.jsx("span",{style:{fontSize:"1.8rem",lineHeight:1},children:g.emoji}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsxs("div",{className:"flex items-baseline gap-1.5",children:[x.jsx("span",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:y}),x.jsx("span",{className:"text-xs truncate",style:{color:"var(--text-secondary)"},children:g.desc})]}),x.jsxs("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:["💧 ",v.relative_humidity_2m,"% · 💨 ",Math.round(v.wind_speed_10m)," km/h",a?` · ${a}`:""]})]})]});const b=Math.min(s,u.daily.time.length-1),w=Array.from({length:b},(k,P)=>P+1).map(k=>({day:odt(u.daily.time[k]),info:FX(u.daily.weather_code[k]),max:Math.round(u.daily.temperature_2m_max[k]),min:Math.round(u.daily.temperature_2m_min[k])})),_=w.map(k=>k.min),S=w.map(k=>k.max),C=Math.min(..._),A=Math.max(...S)-C||1;return x.jsxs("div",{className:"flex flex-col h-full gap-2",children:[x.jsxs("div",{className:"flex items-start gap-3 shrink-0",children:[x.jsx("span",{style:{fontSize:l==="card"?"2.8rem":"2.2rem",lineHeight:1},children:g.emoji}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("div",{className:"flex items-baseline gap-2 flex-wrap",children:x.jsxs("span",{className:"font-bold",style:{color:"var(--text-secondary)",fontSize:"0.85rem"},children:[g.desc,", ",y]})}),x.jsxs("div",{className:"text-xs",style:{color:"var(--text-secondary)"},children:["💧 ",v.relative_humidity_2m,"% Luftfeuchtigkeit"]}),x.jsxs("div",{className:"text-xs",style:{color:"var(--text-secondary)"},children:["Gefühlt ",m," · 💨 ",Math.round(v.wind_speed_10m)," km/h",a?` · ${a}`:"",h&&x.jsx("span",{className:"ml-1",style:{color:"var(--accent-red, #ef4444)"},children:"!"})]})]})]}),o&&w.length>0&&x.jsx("div",{className:"flex flex-col gap-1.5 flex-1 min-h-0 justify-around",children:w.map(k=>{const P=(k.min-C)/A*100,M=(k.max-k.min)/A*100;return x.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[x.jsx("span",{className:"text-xs font-semibold shrink-0 w-7",style:{color:"var(--text-secondary)"},children:k.day}),x.jsxs("span",{className:"text-xs shrink-0 w-7 text-right tabular-nums",style:{color:"var(--text-secondary)"},children:[k.min,"°"]}),x.jsxs("div",{className:"flex-1 relative h-4 min-w-0",children:[x.jsx("div",{className:"absolute inset-y-0 left-0 right-0 rounded-full opacity-15",style:{background:"var(--text-secondary)"}}),x.jsx("div",{className:"absolute inset-y-0 rounded-full",style:{left:`${P}%`,width:`${Math.max(M,4)}%`,background:"linear-gradient(to right, #06b6d4, #3b82f6)"}})]}),x.jsxs("span",{className:"text-xs font-semibold shrink-0 w-7 tabular-nums",style:{color:"var(--text-primary)"},children:[k.max,"°"]})]},k.day)})})]})}function wm(e,t,r,n){const a=n*Math.PI/180;return{x:e+r*Math.cos(a),y:t+r*Math.sin(a)}}function fh(e,t,r,n,a){const i=wm(e,t,r,n),o=wm(e,t,r,a),s=a-n>180?1:0;return`M ${i.x} ${i.y} A ${r} ${r} 0 ${s} 1 ${o.x} ${o.y}`}function PD(e,t,r){return-180+(Math.max(t,Math.min(r,e))-t)/(r-t)*180}function DD({value:e,min:t,max:r,unit:n,decimals:a,colorZones:i,greenMax:o,yellowMax:s,showMinMax:l,scale:u=1}){const p=PD(o,t,r),v=PD(s,t,r),g=PD(e,t,r);let y="var(--accent)";i&&(e<=o?y="#10b981":e<=s?y="#f59e0b":y="#ef4444");const b=wm(100,100,72,g),w=isNaN(e)?"–":a===0?String(Math.round(e)):e.toFixed(a);return x.jsxs("svg",{viewBox:"0 0 200 120",style:{width:200*u,height:120*u,display:"block"},children:[x.jsx("path",{d:fh(100,100,80,-180,0),fill:"none",stroke:"var(--app-border)",strokeWidth:12,strokeLinecap:"round"}),i?x.jsxs(x.Fragment,{children:[x.jsx("path",{d:fh(100,100,80,-180,p),fill:"none",stroke:"#10b981",strokeWidth:12,strokeLinecap:"round"}),x.jsx("path",{d:fh(100,100,80,p,v),fill:"none",stroke:"#f59e0b",strokeWidth:12,strokeLinecap:"round"}),x.jsx("path",{d:fh(100,100,80,v,0),fill:"none",stroke:"#ef4444",strokeWidth:12,strokeLinecap:"round"}),x.jsx("path",{d:fh(100,100,80,-180,g),fill:"none",stroke:y,strokeWidth:14,strokeLinecap:"round",opacity:"0.4"})]}):x.jsx("path",{d:fh(100,100,80,-180,g),fill:"none",stroke:"var(--accent)",strokeWidth:12,strokeLinecap:"round"}),x.jsx("line",{x1:100,y1:100,x2:b.x,y2:b.y,stroke:y,strokeWidth:2.5,strokeLinecap:"round"}),x.jsx("circle",{cx:100,cy:100,r:5,fill:y}),x.jsxs("text",{x:100,y:118,textAnchor:"middle",fontSize:22,fontWeight:"bold",fill:"var(--text-primary)",children:[w,n&&x.jsx("tspan",{fontSize:13,fill:"var(--text-secondary)",dx:2,children:n})]}),l&&(()=>{const _=wm(100,100,94,-180),S=wm(100,100,94,0);return x.jsxs(x.Fragment,{children:[x.jsx("text",{x:_.x+2,y:_.y+4,fontSize:9,fill:"var(--text-secondary)",textAnchor:"start",children:t}),x.jsx("text",{x:S.x-2,y:S.y+4,fontSize:9,fill:"var(--text-secondary)",textAnchor:"end",children:r})]})})()]})}function ldt({config:e}){const{value:t}=zu(e.datapoint),r=e.options??{},n=e.layout??"default",a=r.minValue??0,i=r.maxValue??100,o=r.unit??"",s=r.decimals??1,l=r.colorZones??!1,u=i-a,c=r.greenMax??a+u*.33,f=r.yellowMax??a+u*.66,d=r.showMinMax??!0,h=typeof t=="number"?t:parseFloat(String(t??0)),p={value:isNaN(h)?a:h,min:a,max:i,unit:o,decimals:s,colorZones:l,greenMax:c,yellowMax:f,showMinMax:d};return n==="minimal"?x.jsx("div",{className:"flex items-center justify-center h-full",children:x.jsx(DD,{...p,scale:.85})}):n==="compact"?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[x.jsx(DD,{...p,scale:.7}),e.title&&x.jsx("p",{className:"text-[11px] truncate text-center",style:{color:"var(--text-secondary)"},children:e.title})]}):x.jsxs("div",{className:"flex flex-col h-full",children:[e.title&&x.jsx("p",{className:"text-xs mb-1 truncate",style:{color:"var(--text-secondary)"},children:e.title}),x.jsx("div",{className:"flex-1 flex items-center justify-center",children:x.jsx(DD,{...p,scale:n==="card"?1:.95})})]})}function udt({config:e,editMode:t}){const r=e.options??{},n=r.streamUrl??"",a=r.refreshInterval??5,i=r.fitMode??"cover",o=r.showTimestamp??!0,s=e.layout??"default",[l,u]=I.useState(""),[c,f]=I.useState(!1),[d,h]=I.useState(null),p=I.useRef(null),v=m=>m?a===0?m:m.includes("?")?`${m}&_t=${Date.now()}`:`${m}?_t=${Date.now()}`:"";I.useEffect(()=>{if(n)return f(!1),u(v(n)),h(new Date),a>0&&(p.current=setInterval(()=>{u(v(n)),h(new Date)},a*1e3)),()=>{p.current&&clearInterval(p.current)}},[n,a]);const g=(s==="default"||s==="card")&&e.title,y=t;return n?x.jsxs("div",{className:"relative h-full w-full overflow-hidden rounded-[inherit]",children:[x.jsx("img",{src:l,alt:e.title||"Kamera",onError:()=>f(!0),onLoad:()=>f(!1),style:{width:"100%",height:"100%",objectFit:i,display:"block"}}),c&&x.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2",style:{background:"rgba(0,0,0,0.6)"},children:[x.jsx(R_,{size:28,style:{color:"#ef4444"}}),x.jsx("p",{className:"text-xs text-white opacity-80",children:"Verbindungsfehler"})]}),g&&!c&&x.jsx("div",{className:"absolute bottom-0 left-0 right-0 px-2 py-1.5",style:{background:"rgba(0,0,0,0.55)"},children:x.jsx("p",{className:"text-xs font-medium text-white truncate",children:e.title})}),o&&d&&!c&&x.jsx("div",{className:"absolute bottom-1 right-1 px-1.5 py-0.5 rounded text-[9px] font-mono",style:{background:"rgba(0,0,0,0.5)",color:"rgba(255,255,255,0.8)"},children:d.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),y&&x.jsx("div",{className:"absolute top-1 left-1 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase",style:{background:a===0?"#ef4444":"rgba(0,0,0,0.6)",color:"#fff"},children:a===0?"LIVE":"CAM"})]}):x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2",style:{background:"var(--app-bg)",borderRadius:"var(--widget-radius)"},children:[x.jsx(R_,{size:32,style:{color:"var(--text-secondary)"}}),x.jsxs("p",{className:"text-xs text-center",style:{color:"var(--text-secondary)"},children:[e.title||"Kamera",x.jsx("br",{}),x.jsx("span",{className:"text-[10px] opacity-60",children:"Keine URL konfiguriert"})]})]})}const cdt=[];function fdt(){return{switch:Lwe,value:Iwe,dimmer:jwe,thermostat:Rwe,chart:rWe,list:nWe,clock:sWe,calendar:pWe,header:vWe,group:xWe,echart:Xft,evcc:adt,weather:sdt,gauge:ldt,camera:udt}}const Ice=[{id:"default",label:"Standard"},{id:"card",label:"Karte"},{id:"compact",label:"Kompakt"},{id:"minimal",label:"Minimal"}],ddt=[...Ice,{id:"agenda",label:"Agenda"}],hdt=[{label:"5 Min",value:5},{label:"15 Min",value:15},{label:"30 Min",value:30},{label:"1 Std",value:60},{label:"6 Std",value:360},{label:"24 Std",value:1440}],dy="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",dh={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};function pdt({config:e,onConfigChange:t}){const r=e.options??{},n=MO(r),[a,i]=I.useState(!1),[o,s]=I.useState(""),[l,u]=I.useState(""),[c,f]=I.useState(Ay[n.length%Ay.length]),d=g=>t({...e,options:{...r,...g}}),h=(g,y)=>d({calendars:n.map(m=>m.id===g?{...m,...y}:m)}),p=g=>d({calendars:n.filter(y=>y.id!==g)}),v=()=>{if(!o.trim())return;const g={id:Date.now().toString(),url:o.trim(),name:l.trim()||"Kalender",color:c,showName:!0};d({calendars:[...n,g]}),s(""),u(""),f(Ay[(n.length+1)%Ay.length]),i(!1)};return x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"space-y-1.5",children:n.map(g=>x.jsxs("div",{className:"rounded-lg p-2 space-y-1.5",style:{background:"var(--app-bg)",border:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("input",{type:"color",value:g.color,onChange:y=>h(g.id,{color:y.target.value}),className:"w-5 h-5 rounded cursor-pointer border-0 p-0 shrink-0",title:"Farbe ändern"}),x.jsx("input",{type:"text",value:g.name,onChange:y=>h(g.id,{name:y.target.value}),className:"flex-1 text-xs rounded px-2 py-1 focus:outline-none min-w-0",style:dh,placeholder:"Kalender-Name"}),x.jsx("button",{onClick:()=>h(g.id,{showName:!g.showName}),className:"relative w-7 h-4 rounded-full transition-colors shrink-0",style:{background:g.showName?g.color:"var(--app-border)"},title:"Name anzeigen",children:x.jsx("span",{className:"absolute top-0.5 w-3 h-3 bg-white rounded-full shadow transition-transform",style:{left:g.showName?"14px":"2px"}})}),x.jsx("button",{onClick:()=>p(g.id),className:"hover:opacity-70 shrink-0",style:{color:"var(--accent-red)"},children:x.jsx(fs,{size:12})})]}),x.jsx("p",{className:"text-[9px] font-mono truncate",style:{color:"var(--text-secondary)"},children:g.url})]},g.id))}),a?x.jsxs("div",{className:"rounded-lg p-2 space-y-1.5",style:{background:"var(--app-bg)",border:"1px solid var(--app-border)"},children:[x.jsx("input",{type:"url",value:o,onChange:g=>s(g.target.value),placeholder:"iCal-URL…",autoFocus:!0,className:dy+" font-mono",style:dh}),x.jsxs("div",{className:"flex gap-1.5",children:[x.jsx("input",{type:"color",value:c,onChange:g=>f(g.target.value),className:"w-8 h-8 rounded cursor-pointer border-0 p-0 shrink-0"}),x.jsx("input",{type:"text",value:l,onChange:g=>u(g.target.value),placeholder:"Name (optional)",className:dy,style:dh})]}),x.jsxs("div",{className:"flex gap-1.5",children:[x.jsx("button",{onClick:v,disabled:!o.trim(),className:"flex-1 py-1.5 text-xs rounded-lg text-white hover:opacity-80 disabled:opacity-30",style:{background:"var(--accent)"},children:"Hinzufügen"}),x.jsx("button",{onClick:()=>{i(!1),s(""),u("")},className:"px-3 py-1.5 text-xs rounded-lg hover:opacity-80",style:{background:"var(--app-surface)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"✕"})]})]}):x.jsxs("button",{onClick:()=>i(!0),className:"w-full flex items-center justify-center gap-1.5 py-2 text-xs rounded-lg hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px dashed var(--app-border)"},children:[x.jsx(cs,{size:12})," Kalender hinzufügen"]}),x.jsx("div",{className:"h-px",style:{background:"var(--app-border)"}}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Aktualisierungsintervall"}),x.jsx("select",{value:r.refreshInterval??30,onChange:g=>d({refreshInterval:Number(g.target.value)}),className:dy,style:dh,children:hdt.map(g=>x.jsx("option",{value:g.value,children:g.label},g.value))})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Tage im Voraus"}),x.jsx("input",{type:"number",min:1,max:365,value:r.daysAhead??14,onChange:g=>d({daysAhead:Number(g.target.value)}),className:dy,style:dh})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Max. Einträge"}),x.jsx("input",{type:"number",min:1,max:20,value:r.maxEvents??5,onChange:g=>d({maxEvents:Number(g.target.value)}),className:dy,style:dh})]})]})}const vdt=[{key:"bg",label:"Hintergrund",type:"color"},{key:"accent",label:"Akzentfarbe",type:"color"},{key:"textPrimary",label:"Text",type:"color"},{key:"textSecondary",label:"Text sekundär",type:"color"},{key:"radius",label:"Eckenradius",type:"text"}],gdt=["1h","6h","24h","7d","30d"];function ydt({config:e,onConfigChange:t}){const[r,n]=I.useState([]),[a,i]=I.useState(!1),o=e.datapoint,s=e.options??{},l=f=>t({...e,options:{...s,...f}});I.useEffect(()=>{if(!o){n([]);return}i(!0),W_(o).then(f=>{var h;const d=(h=f==null?void 0:f.common)==null?void 0:h.custom;n(d?q_(d):[]),i(!1)}).catch(()=>i(!1))},[o]);const u=s.historyInstance,c=s.historyRange??"24h";return x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"h-px my-1",style:{background:"var(--app-border)"}}),x.jsx("p",{className:"text-[11px] font-semibold mb-1.5",style:{color:"var(--text-secondary)"},children:"Verlaufsdaten"}),a&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Prüfe Adapter…"}),!a&&r.length===0&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Kein History-Adapter aktiv für diesen Datenpunkt."}),!a&&r.length>0&&x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Adapter-Instanz"}),x.jsxs("select",{value:u??"",onChange:f=>l({historyInstance:f.target.value||void 0}),className:"w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"},children:[x.jsx("option",{value:"",children:"– Live-Daten (kein Verlauf) –"}),r.map(f=>x.jsx("option",{value:f.instance,children:f.label},f.instance))]})]}),u&&x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Zeitraum"}),x.jsx("div",{className:"flex gap-1 flex-wrap",children:gdt.map(f=>x.jsx("button",{onClick:()=>l({historyRange:f}),className:"flex-1 text-[11px] py-1 rounded-md transition-opacity hover:opacity-80",style:{background:c===f?"var(--accent)":"var(--app-bg)",color:c===f?"#fff":"var(--text-secondary)",border:`1px solid ${c===f?"var(--accent)":"var(--app-border)"}`,minWidth:36},children:jR[f]},f))})]})]})}const Oo={id:null,close:null};function mdt(e,t){var r;Oo.id&&Oo.id!==e&&((r=Oo.close)==null||r.call(Oo)),Oo.id=e,Oo.close=t}function VX(e){Oo.id===e&&(Oo.id=null,Oo.close=null)}function hy({anchorRef:e,onClose:t,children:r}){const n=I.useRef(null),[a,i]=I.useState(null);return I.useEffect(()=>{if(e.current){const o=e.current.getBoundingClientRect();i({top:o.bottom+4,left:o.right})}},[e]),I.useEffect(()=>{if(!a||!n.current||!e.current)return;const o=n.current.getBoundingClientRect(),s=e.current.getBoundingClientRect(),l=window.innerWidth,u=window.innerHeight,c=4;let f=s.right-o.width;f<c&&(f=c),f+o.width>l-c&&(f=l-c-o.width);let d=s.bottom+c;d+o.height>u-c&&(d=s.top-o.height-c),d<c&&(d=c),i({top:d,left:f})},[a==null?void 0:a.top,a==null?void 0:a.left]),I.useEffect(()=>{const o=s=>{e.current&&!e.current.contains(s.target)&&t()};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[e,t]),Xu.createPortal(x.jsx("div",{ref:n,className:"fixed z-[9999] rounded-lg shadow-2xl",style:{top:(a==null?void 0:a.top)??-9999,left:(a==null?void 0:a.left)??-9999,background:"var(--app-surface)",border:"1px solid var(--app-border)",visibility:a?"visible":"hidden"},onMouseDown:o=>o.stopPropagation(),children:r}),document.body)}function $y({config:e,editMode:t,onRemove:r,onConfigChange:n}){var _,S,C,T;const[a,i]=I.useState(null),[o,s]=I.useState(!1),l=((_=e.options)==null?void 0:_.conditions)??cdt,u=Nwe(l);I.useEffect(()=>()=>{VX(e.id),Dwe(e.id)},[e.id]),I.useLayoutEffect(()=>{Pwe(e.id,!t&&u.hidden,u.reflow)},[e.id,t,u.hidden,u.reflow]);const c=A=>{A===null?(i(null),VX(e.id)):(mdt(e.id,()=>i(null)),i(A))},[f,d]=I.useState(null),h=I.useRef(null),p=fdt()[e.type],v=e.layout??"default",g=(S=e.options)==null?void 0:S.styleOverride,y=Object.fromEntries(Object.entries({"--widget-bg":g==null?void 0:g.bg,"--widget-border":g==null?void 0:g.border,"--widget-radius":g==null?void 0:g.radius,"--text-primary":g==null?void 0:g.textPrimary,"--text-secondary":g==null?void 0:g.textSecondary,"--accent":g==null?void 0:g.accent,...u.cssVars}).filter(([,A])=>A!==void 0&&A!=="")),m=A=>A.stopPropagation(),b=e.type==="header",w=e.type==="group";return x.jsxs("div",{style:b?{background:"transparent",borderRadius:0,boxShadow:"none",borderWidth:0,...y,...!t&&u.hidden&&!u.reflow?{visibility:"hidden",pointerEvents:"none"}:{}}:{background:"var(--widget-bg)",borderRadius:"var(--widget-radius)",boxShadow:"var(--widget-shadow)",borderWidth:"var(--widget-border-width)",borderStyle:"solid",borderColor:"var(--widget-border)",...y,...!t&&u.hidden&&!u.reflow?{visibility:"hidden",pointerEvents:"none"}:{}},className:`relative h-full transition-all overflow-visible ${b?"px-2 py-0":w?"p-0":"p-4"} ${t?"ring-2 ring-accent/40 rounded-xl":""} ${!t&&u.effect==="pulse"?"animate-pulse":""} ${!t&&u.effect==="blink"?"animate-[blink_1s_step-end_infinite]":""}`,children:[t&&u.hidden&&x.jsx("div",{className:"nodrag absolute inset-0 z-20 rounded-[inherit] flex items-start justify-end pointer-events-none p-1.5",children:x.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded-md text-[11px] font-medium opacity-70",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:[x.jsx(Jj,{size:11}),"Versteckt"]})}),t&&x.jsx("div",{className:"nodrag absolute top-1.5 right-1.5 z-10",onMouseDown:m,onPointerDown:m,children:x.jsxs("button",{ref:h,onClick:()=>{c(a==="menu"?null:"menu"),s(!1)},className:"w-7 h-7 flex items-center justify-center rounded-lg transition-opacity hover:opacity-80 relative",style:{background:a?"var(--accent)":"var(--app-bg)",color:a?"#fff":"var(--text-secondary)",border:"1px solid var(--app-border)"},title:"Widget-Optionen",children:[x.jsx(Us,{size:13}),l.length>0&&!a&&x.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 rounded-full",style:{background:"var(--accent)"}})]})}),t&&v!=="default"&&x.jsx("div",{className:"nodrag absolute bottom-1.5 left-2 text-[10px] pointer-events-none opacity-40",style:{color:"var(--text-secondary)"},children:v}),x.jsx(p,{config:e,editMode:t,onConfigChange:n}),a==="menu"&&h.current&&x.jsx(hy,{anchorRef:h,onClose:()=>c(null),children:x.jsxs("div",{className:"p-1 flex flex-col gap-0.5 min-w-[170px]",onMouseLeave:()=>c(null),children:[x.jsxs("button",{onClick:()=>{c("edit"),s(!1)},className:"flex items-center gap-2.5 px-3 py-2 text-sm rounded-md text-left hover:opacity-80 transition-opacity",style:{color:"var(--text-primary)"},children:[x.jsx(Tf,{size:13,style:{color:"var(--text-secondary)",flexShrink:0}}),"Bearbeiten"]}),!w&&x.jsxs("button",{onClick:()=>{c("layout"),s(!1)},className:"flex items-center gap-2.5 px-3 py-2 text-sm rounded-md text-left hover:opacity-80 transition-opacity",style:{color:"var(--text-primary)"},children:[x.jsx(Kge,{size:13,style:{color:"var(--text-secondary)",flexShrink:0}}),"Layout",v!=="default"&&x.jsx("span",{className:"ml-auto text-[11px] capitalize",style:{color:"var(--accent)"},children:v})]}),x.jsxs("button",{onClick:()=>{c("style"),s(!1)},className:"flex items-center gap-2.5 px-3 py-2 text-sm rounded-md text-left hover:opacity-80 transition-opacity",style:{color:"var(--text-primary)"},children:[x.jsx(lJ,{size:13,style:{color:"var(--text-secondary)",flexShrink:0}}),"Stil",g&&Object.keys(g).length>0&&x.jsx("span",{className:"ml-auto text-[11px]",style:{color:"var(--accent)"},children:"angepasst"})]}),x.jsxs("button",{onClick:()=>{c("conditions"),s(!1)},className:"flex items-center gap-2.5 px-3 py-2 text-sm rounded-md text-left hover:opacity-80 transition-opacity",style:{color:"var(--text-primary)"},children:[x.jsx(Eye,{size:13,style:{color:l.length>0?"var(--accent)":"var(--text-secondary)",flexShrink:0}}),"Bedingungen",l.length>0&&x.jsx("span",{className:"ml-auto text-[11px] px-1.5 py-0.5 rounded-full",style:{background:"var(--accent)22",color:"var(--accent)"},children:l.length})]}),x.jsx("div",{className:"h-px my-0.5 mx-1",style:{background:"var(--app-border)"}}),o?x.jsxs("div",{className:"flex gap-1 px-1 pb-1",children:[x.jsx("button",{onClick:()=>r(e.id),className:"flex-1 text-xs py-1.5 rounded-md text-white hover:opacity-80",style:{background:"var(--accent-red)"},children:"Bestätigen"}),x.jsx("button",{onClick:()=>s(!1),className:"px-2 text-xs py-1.5 rounded-md hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"✕"})]}):x.jsxs("button",{onClick:()=>s(!0),className:"flex items-center gap-2.5 px-3 py-2 text-sm rounded-md text-left hover:opacity-80 transition-opacity",style:{color:"var(--accent-red, #ef4444)"},children:[x.jsx(gn,{size:13,style:{flexShrink:0}}),"Löschen"]})]})}),a==="layout"&&h.current&&x.jsx(hy,{anchorRef:h,onClose:()=>c(null),children:x.jsxs("div",{className:"p-1.5 flex flex-col gap-0.5 min-w-[120px]",children:[(e.type==="calendar"?ddt:Ice).map(A=>x.jsxs("button",{onClick:()=>{n({...e,layout:A.id}),c(null)},className:"px-3 py-2 text-sm text-left rounded-md transition-opacity hover:opacity-80 flex items-center justify-between gap-4",style:{background:v===A.id?"var(--accent)22":"transparent",color:v===A.id?"var(--accent)":"var(--text-primary)"},children:[A.label,v===A.id&&x.jsx("span",{children:"✓"})]},A.id)),v==="default"&&(()=>{var D,E;const A=["tl","tc","tr","cl","cc","cr","bl","bc","br"],k=(D=e.options)==null?void 0:D.contentPosition,P=(E=e.options)==null?void 0:E.titlePosition;function M({value:L,onChange:N}){return x.jsx("div",{className:"grid grid-cols-3 gap-1 px-2 pb-2",children:A.map(j=>{const R=L===j;return x.jsx("button",{onClick:z=>{z.stopPropagation(),N(R?void 0:j)},className:"w-6 h-6 rounded transition-opacity hover:opacity-80",style:{background:R?"var(--accent)":"var(--app-bg)",border:`1px solid ${R?"var(--accent)":"var(--app-border)"}`},title:j},j)})})}return x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"h-px my-1 mx-1",style:{background:"var(--app-border)"}}),x.jsx("p",{className:"px-3 text-[11px] pb-1",style:{color:"var(--text-secondary)"},children:"Inhalt-Position"}),x.jsx(M,{value:k,onChange:L=>n({...e,options:{...e.options,contentPosition:L}})}),x.jsx("div",{className:"h-px my-1 mx-1",style:{background:"var(--app-border)"}}),x.jsx("p",{className:"px-3 text-[11px] pb-1",style:{color:"var(--text-secondary)"},children:"Titel-Position"}),x.jsx(M,{value:P,onChange:L=>n({...e,options:{...e.options,titlePosition:L}})})]})})()]})}),a==="edit"&&h.current&&x.jsx(hy,{anchorRef:h,onClose:()=>c(null),children:x.jsxs("div",{className:`p-3 ${e.type==="calendar"?"w-80":e.type==="thermostat"?"w-72":e.type==="echart"?"w-[560px]":e.type==="evcc"?"w-80":e.type==="gauge"||e.type==="weather"||e.type==="camera"?"w-72":"w-64"}`,onMouseDown:A=>A.stopPropagation(),children:[x.jsx("p",{className:"text-xs font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Widget bearbeiten"}),x.jsxs("div",{className:"space-y-2.5",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Widget-Typ"}),x.jsxs("select",{value:e.type,onChange:A=>n({...e,type:A.target.value}),className:"w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"},children:[x.jsx("option",{value:"switch",children:"Schalter"}),x.jsx("option",{value:"value",children:"Wert-Anzeige"}),x.jsx("option",{value:"dimmer",children:"Dimmer"}),x.jsx("option",{value:"thermostat",children:"Thermostat"}),x.jsx("option",{value:"chart",children:"Diagramm"}),x.jsx("option",{value:"list",children:"Gruppenliste"}),x.jsx("option",{value:"calendar",children:"Kalender"}),x.jsx("option",{value:"header",children:"Abschnittstitel"}),x.jsx("option",{value:"group",children:"Gruppe"}),x.jsx("option",{value:"echart",children:"EChart"}),x.jsx("option",{value:"evcc",children:"evcc"}),x.jsx("option",{value:"weather",children:"Wetter"}),x.jsx("option",{value:"gauge",children:"Gauge"}),x.jsx("option",{value:"camera",children:"Kamera"})]})]}),e.type==="header"&&(()=>{const A=e.options??{},k=P=>n({...e,options:{...A,...P}});return x.jsxs(x.Fragment,{children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Untertitel (optional)"}),x.jsx("input",{type:"text",value:A.subtitle??"",onChange:P=>k({subtitle:P.target.value||void 0}),placeholder:"z.B. Erdgeschoss",className:"w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Stil"}),x.jsxs("select",{value:e.layout??"default",onChange:P=>n({...e,layout:P.target.value}),className:"w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"},children:[x.jsx("option",{value:"default",children:"Standard (Akzentlinie + Titel)"}),x.jsx("option",{value:"compact",children:"Kompakt (Linie links)"}),x.jsx("option",{value:"minimal",children:"Minimal (Trennlinie + Text)"})]})]})]})})(),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Name"}),x.jsx("input",{type:"text",value:e.title,onChange:A=>n({...e,title:A.target.value}),className:"w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]}),e.type==="clock"&&(()=>{const A=e.options??{},k=E=>n({...e,options:{...A,...E}}),P=A.display??"time",M="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",D={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};return x.jsxs(x.Fragment,{children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Anzeige"}),x.jsxs("select",{value:P,onChange:E=>k({display:E.target.value}),className:M,style:D,children:[x.jsx("option",{value:"time",children:"Nur Uhrzeit"}),x.jsx("option",{value:"datetime",children:"Uhrzeit + Datum"}),x.jsx("option",{value:"date",children:"Nur Datum"})]})]}),P!=="date"&&x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Sekunden anzeigen"}),x.jsx("button",{onClick:()=>k({showSeconds:!A.showSeconds}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:A.showSeconds?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:A.showSeconds?"18px":"2px"}})})]}),P!=="time"&&x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Datumsformat"}),x.jsxs("select",{value:A.dateLength??"short",onChange:E=>k({dateLength:E.target.value}),className:M,style:D,children:[x.jsx("option",{value:"short",children:"Kurz (07.04.2026)"}),x.jsx("option",{value:"long",children:"Lang (Montag, 7. April 2026)"})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Eigenes Format"}),x.jsx("input",{type:"text",value:A.customFormat??"",onChange:E=>k({customFormat:E.target.value||void 0}),placeholder:"z.B. dd.MM.yyyy HH:mm",className:M+" font-mono",style:D}),x.jsx("p",{className:"text-[10px] mt-1 leading-tight",style:{color:"var(--text-secondary)"},children:"Tokens: HH mm ss dd MM yyyy EEEE MMMM"})]})]})})(),e.type==="calendar"&&x.jsx(pdt,{config:e,onConfigChange:n}),e.type!=="list"&&e.type!=="clock"&&e.type!=="calendar"&&e.type!=="header"&&e.type!=="group"&&e.type!=="evcc"&&e.type!=="echart"&&e.type!=="weather"&&e.type!=="camera"&&x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Datenpunkt-ID"}),x.jsxs("div",{className:"flex gap-1",children:[x.jsx("input",{type:"text",value:e.datapoint,onChange:A=>n({...e,datapoint:A.target.value}),className:"flex-1 text-xs rounded-lg px-2.5 py-2 font-mono focus:outline-none min-w-0",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),x.jsx("button",{onClick:()=>d("datapoint"),className:"px-2 rounded-lg hover:opacity-80 shrink-0",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},title:"Aus ioBroker wählen",children:x.jsx(sl,{size:13})})]})]}),(e.type==="value"||e.type==="chart")&&x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Einheit"}),x.jsx("input",{type:"text",value:((C=e.options)==null?void 0:C.unit)??"",onChange:A=>n({...e,options:{...e.options,unit:A.target.value||void 0}}),placeholder:"z.B. °C, %, W",className:"w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]}),e.type==="chart"&&x.jsx(ydt,{config:e,onConfigChange:n}),e.type==="echart"&&x.jsx(Zft,{config:e,onConfigChange:n}),e.type==="evcc"&&x.jsx(idt,{config:e,onConfigChange:n}),e.type==="gauge"&&(()=>{const A=e.options??{},k=j=>n({...e,options:{...A,...j}}),P=A.minValue??0,M=A.maxValue??100,D=A.colorZones??!1,E=M-P,L="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",N={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"flex gap-2",children:[x.jsxs("div",{className:"flex-1",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Min"}),x.jsx("input",{type:"number",value:P,onChange:j=>k({minValue:Number(j.target.value)}),className:L,style:N})]}),x.jsxs("div",{className:"flex-1",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Max"}),x.jsx("input",{type:"number",value:M,onChange:j=>k({maxValue:Number(j.target.value)}),className:L,style:N})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Einheit"}),x.jsx("input",{type:"text",value:A.unit??"",onChange:j=>k({unit:j.target.value||void 0}),placeholder:"z.B. °C, %, W",className:L,style:N})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Dezimalstellen"}),x.jsx("input",{type:"number",min:0,max:4,value:A.decimals??1,onChange:j=>k({decimals:Number(j.target.value)}),className:L,style:N})]}),x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Farbzonen"}),x.jsx("button",{onClick:()=>k({colorZones:!D}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:D?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:D?"18px":"2px"}})})]}),D&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Grün bis"}),x.jsx("input",{type:"number",value:A.greenMax??P+E*.33,onChange:j=>k({greenMax:Number(j.target.value)}),className:L,style:N})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Gelb bis"}),x.jsx("input",{type:"number",value:A.yellowMax??P+E*.66,onChange:j=>k({yellowMax:Number(j.target.value)}),className:L,style:N})]})]}),x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Min/Max anzeigen"}),x.jsx("button",{onClick:()=>k({showMinMax:!(A.showMinMax??!0)}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:A.showMinMax??!0?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:A.showMinMax??!0?"18px":"2px"}})})]})]})})(),e.type==="weather"&&(()=>{const A=e.options??{},k=D=>n({...e,options:{...A,...D}}),P="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",M={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"flex gap-2",children:[x.jsxs("div",{className:"flex-1",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Breitengrad"}),x.jsx("input",{type:"number",step:.01,value:A.latitude??48.1,onChange:D=>k({latitude:Number(D.target.value)}),className:P,style:M})]}),x.jsxs("div",{className:"flex-1",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Längengrad"}),x.jsx("input",{type:"number",step:.01,value:A.longitude??11.6,onChange:D=>k({longitude:Number(D.target.value)}),className:P,style:M})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Standortname"}),x.jsx("input",{type:"text",value:A.locationName??"",onChange:D=>k({locationName:D.target.value||void 0}),placeholder:"z.B. München",className:P,style:M})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Aktualisierung (Min.)"}),x.jsx("input",{type:"number",min:5,max:1440,value:A.refreshMinutes??30,onChange:D=>k({refreshMinutes:Number(D.target.value)}),className:P,style:M})]}),x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Vorhersage anzeigen"}),x.jsx("button",{onClick:()=>k({showForecast:!(A.showForecast??!0)}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:A.showForecast??!0?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:A.showForecast??!0?"18px":"2px"}})})]})]})})(),e.type==="camera"&&(()=>{const A=e.options??{},k=E=>n({...e,options:{...A,...E}}),P="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",M={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"},D=A.fitMode??"cover";return x.jsxs(x.Fragment,{children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Stream-URL"}),x.jsx("input",{type:"url",value:A.streamUrl??"",onChange:E=>k({streamUrl:E.target.value||void 0}),placeholder:"http://…/stream.mjpg",className:P+" font-mono",style:M})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Aktualisierung (Sek., 0 = MJPEG)"}),x.jsx("input",{type:"number",min:0,value:A.refreshInterval??5,onChange:E=>k({refreshInterval:Number(E.target.value)}),className:P,style:M})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Bildanpassung"}),x.jsxs("select",{value:D,onChange:E=>k({fitMode:E.target.value}),className:P,style:M,children:[x.jsx("option",{value:"cover",children:"Cover (ausfüllen)"}),x.jsx("option",{value:"contain",children:"Contain (einpassen)"})]})]}),x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Zeitstempel anzeigen"}),x.jsx("button",{onClick:()=>k({showTimestamp:!(A.showTimestamp??!0)}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:A.showTimestamp??!0?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:A.showTimestamp??!0?"18px":"2px"}})})]})]})})(),e.type==="thermostat"&&(()=>{const A=e.options??{},k=D=>n({...e,options:{...A,...D}}),P="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",M={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Anklickbar (Detail-Popup)"}),x.jsx("button",{onClick:()=>k({clickable:!(A.clickable??!0)}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:A.clickable??!0?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:A.clickable??!0?"18px":"2px"}})})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Ist-Temperatur Datenpunkt"}),x.jsxs("div",{className:"flex gap-1",children:[x.jsx("input",{type:"text",value:A.actualDatapoint??"",onChange:D=>k({actualDatapoint:D.target.value||void 0}),placeholder:"optional",className:"flex-1 text-xs rounded-lg px-2.5 py-2 font-mono focus:outline-none min-w-0",style:M}),x.jsx("button",{onClick:()=>d("actualDatapoint"),className:"px-2 rounded-lg hover:opacity-80 shrink-0",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},title:"Aus ioBroker wählen",children:x.jsx(sl,{size:13})})]})]}),x.jsxs("div",{className:"flex gap-2",children:[x.jsxs("div",{className:"flex-1",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Min °C"}),x.jsx("input",{type:"number",min:0,max:30,step:1,value:A.minTemp??10,onChange:D=>k({minTemp:Number(D.target.value)}),className:P,style:M})]}),x.jsxs("div",{className:"flex-1",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Max °C"}),x.jsx("input",{type:"number",min:10,max:40,step:1,value:A.maxTemp??30,onChange:D=>k({maxTemp:Number(D.target.value)}),className:P,style:M})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Schrittweite"}),x.jsxs("select",{value:A.step??.5,onChange:D=>k({step:Number(D.target.value)}),className:P,style:M,children:[x.jsx("option",{value:.5,children:"0,5 °C"}),x.jsx("option",{value:1,children:"1 °C"}),x.jsx("option",{value:.1,children:"0,1 °C"})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Schnellwahl (kommagetrennt)"}),x.jsx("input",{type:"text",value:(A.presets??[18,20,22,24]).join(", "),onChange:D=>{const E=D.target.value.split(",").map(L=>parseFloat(L.trim())).filter(L=>!isNaN(L));k({presets:E.length?E:void 0})},placeholder:"18, 20, 22, 24",className:P,style:M})]})]})})()]})]})}),f&&x.jsx(Av,{currentValue:f==="datapoint"?e.datapoint:((T=e.options)==null?void 0:T.actualDatapoint)??"",onSelect:A=>{n(f==="datapoint"?{...e,datapoint:A}:{...e,options:{...e.options,actualDatapoint:A}})},onClose:()=>d(null)}),a==="style"&&h.current&&x.jsx(hy,{anchorRef:h,onClose:()=>c(null),children:x.jsxs("div",{className:"p-3 w-72",onMouseDown:A=>A.stopPropagation(),children:[x.jsx("p",{className:"text-xs font-semibold mb-2.5",style:{color:"var(--text-primary)"},children:"Widget-Stil"}),x.jsx("div",{className:"space-y-2",children:vdt.map(({key:A,label:k,type:P})=>x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("label",{className:"text-xs w-24 shrink-0",style:{color:"var(--text-secondary)"},children:k}),P==="color"?x.jsxs("div",{className:"flex gap-1 flex-1",children:[x.jsx("input",{type:"color",value:(g==null?void 0:g[A])??"#3b82f6",onChange:M=>n({...e,options:{...e.options,styleOverride:{...g,[A]:M.target.value}}}),className:"w-7 h-6 rounded cursor-pointer border-0 p-0 shrink-0"}),x.jsx("input",{type:"text",value:(g==null?void 0:g[A])??"",onChange:M=>{const D=M.target.value,E={...g,[A]:D};D||delete E[A],n({...e,options:{...e.options,styleOverride:Object.keys(E).length?E:void 0}})},placeholder:"auto",className:"flex-1 text-xs rounded px-1.5 py-1 min-w-0 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]}):x.jsx("input",{type:"text",value:(g==null?void 0:g[A])??"",onChange:M=>{const D=M.target.value,E={...g,[A]:D};D||delete E[A],n({...e,options:{...e.options,styleOverride:Object.keys(E).length?E:void 0}})},placeholder:"auto",className:"flex-1 text-xs rounded px-1.5 py-1 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]},A))}),g&&Object.keys(g).length>0&&x.jsx("button",{onClick:()=>{const{styleOverride:A,...k}=e.options??{};n({...e,options:k})},className:"w-full mt-3 py-1.5 text-xs rounded-md hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"Zurücksetzen"})]})}),a==="conditions"&&h.current&&x.jsx(hy,{anchorRef:h,onClose:()=>c(null),children:x.jsx(Swe,{conditions:l,onChange:A=>n({...e,options:{...e.options,conditions:A}})})})]})}const py=10;function jce({readonly:e=!1,editMode:t=!1,onLayoutChange:r,viewTabs:n,viewActiveTabId:a}){const i=Cv(),{updateWidget:o,updateLayouts:s,removeWidget:l}=Ga(),u=co(N=>N.frontend.gridRowHeight??80),c=co(N=>N.frontend.mobileBreakpoint??600),f=n??i.tabs,d=a??i.activeTabId,h=f.find(N=>N.id===d),p=(h==null?void 0:h.widgets)??[],v=Ewe(),g=I.useRef(null),[y,m]=I.useState(0);I.useEffect(()=>{const N=g.current;if(!N)return;m(N.clientWidth);const j=new ResizeObserver(([R])=>{m(Math.floor(R.contentRect.width))});return j.observe(N),()=>j.disconnect()},[]);const[b,w]=I.useState(0);I.useEffect(()=>{t&&y>0&&w(N=>Math.max(N,y)),t||w(0)},[t,y]);const _=t&&b>0?b:y,S=_>0?Math.max(2,Math.floor((_-py)/(u+py))):12,C=I.useRef(null),T=I.useRef(u),A=I.useRef(p);A.current=p;const k=I.useRef(s);k.current=s,I.useEffect(()=>{if(C.current===null){C.current=S,T.current=u;return}const N=C.current,j=T.current;if(!e&&j!==u&&N>0){const R=A.current;if(R.length>0){const z=R.map(B=>({...B,gridPos:{...B.gridPos,x:Math.min(Math.round(B.gridPos.x*S/N),S-1),w:Math.max(1,Math.round(B.gridPos.w*S/N))}}));k.current(z)}}C.current=S,T.current=u},[S,u]);const P=p.filter(N=>!v.has(N.id)),M=P.map(N=>({i:N.id,x:Math.min(N.gridPos.x,S-1),y:N.gridPos.y,w:Math.min(N.gridPos.w,S),h:N.gridPos.h})),D=I.useCallback(N=>p.map(j=>{if(v.has(j.id))return j;const R=N.find(z=>z.i===j.id);return R?{...j,gridPos:{x:R.x,y:R.y,w:R.w,h:R.h}}:j}),[p,v]),E=I.useCallback(N=>{r==null||r(D(N))},[D,r]),L=I.useCallback(N=>{e||s(D(N))},[e,D,s]);if(y>0&&y<c){const N=[...p].filter(j=>!v.has(j.id)).sort((j,R)=>{const z=j.mobileOrder??j.gridPos.y*1e3+j.gridPos.x,B=R.mobileOrder??R.gridPos.y*1e3+R.gridPos.x;return z-B});return x.jsxs("div",{ref:g,className:"flex-1 overflow-auto p-2",children:[x.jsx("div",{style:{position:"fixed",top:-9999,left:-9999,width:1,height:1,overflow:"hidden",pointerEvents:"none",opacity:0},children:p.filter(j=>v.has(j.id)).map(j=>x.jsx($y,{config:j,editMode:!1,onRemove:l,onConfigChange:R=>o(R.id,R)},j.id))}),x.jsx("div",{className:"flex flex-col gap-2.5",children:N.map(j=>x.jsx("div",{style:{height:j.gridPos.h*u+(j.gridPos.h-1)*py},children:x.jsx($y,{config:j,editMode:!1,onRemove:l,onConfigChange:R=>o(R.id,R)})},j.id))})]})}return p.length===0?x.jsx("div",{className:"flex flex-col items-center justify-center flex-1 h-64 space-y-2",style:{color:"var(--text-secondary)"},children:x.jsx("p",{children:e?"Keine Widgets konfiguriert.":'Noch keine Widgets – über "+ Geräte" hinzufügen.'})}):x.jsx("div",{ref:g,className:"flex-1 overflow-auto p-2 sm:p-4",style:t&&_>y?{overflowX:"auto"}:void 0,children:_>0&&x.jsxs(x.Fragment,{children:[x.jsx("div",{style:{position:"fixed",top:-9999,left:-9999,width:1,height:1,overflow:"hidden",pointerEvents:"none",opacity:0},children:p.filter(N=>v.has(N.id)).map(N=>x.jsx($y,{config:N,editMode:!1,onRemove:l,onConfigChange:j=>o(j.id,j)},N.id))}),x.jsx(EQ,{className:"layout",layout:M,cols:S,rowHeight:u,width:_,isDraggable:t,isResizable:t,draggableCancel:".nodrag",onLayoutChange:E,onDragStop:L,onResizeStop:L,margin:[py,py],containerPadding:[0,0],children:P.map(N=>x.jsx("div",{children:x.jsx($y,{config:N,editMode:t,onRemove:l,onConfigChange:j=>o(j.id,j)})},N.id))})]})})}function xdt({readonly:e=!1,viewTabs:t,viewActiveTabId:r,onViewTabClick:n,layoutUrlBase:a=""}){const i=Cv(),{setActiveTab:o,addTab:s,removeTab:l,renameTab:u}=Ga(),c=t??i.tabs,f=r??i.activeTabId,[d,h]=I.useState(null),[p,v]=I.useState(""),g=I.useRef(null),y=gv();I.useEffect(()=>{d&&g.current&&(g.current.focus(),g.current.select())},[d]);const m=()=>{d&&p.trim()&&u(d,p.trim()),h(null)},b=w=>{if(e){const _=c.find(S=>S.id===w);if(!_)return;n?n(_):y(`${a}/tab/${_.slug??_.id}`)}else o(w)};return c.length<=1&&e?null:x.jsxs("div",{className:"flex items-center gap-1 px-4 overflow-x-auto shrink-0",style:{background:"var(--app-surface)",borderBottom:"1px solid var(--app-border)"},children:[c.map(w=>{const _=w.id===f;return x.jsxs("div",{className:"group flex items-center gap-1.5 px-3 py-2.5 text-sm cursor-pointer border-b-2 transition-colors whitespace-nowrap",style:{borderBottomColor:_?"var(--accent)":"transparent",color:_?"var(--accent)":"var(--text-secondary)"},onClick:()=>b(w.id),children:[!e&&d===w.id?x.jsx("input",{ref:g,value:p,onChange:S=>v(S.target.value),onBlur:m,onKeyDown:S=>{S.key==="Enter"&&m(),S.key==="Escape"&&h(null)},onClick:S=>S.stopPropagation(),className:"w-24 text-sm rounded px-1.5 py-0.5 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--accent)"}}):x.jsx("span",{onDoubleClick:S=>{e||(S.stopPropagation(),h(w.id),v(w.name))},children:w.name}),!e&&c.length>1&&x.jsx("button",{onClick:S=>{S.stopPropagation(),l(w.id)},className:"opacity-0 group-hover:opacity-100 w-4 h-4 flex items-center justify-center rounded-full text-xs transition-all hover:opacity-80",style:{background:"var(--accent-red)",color:"#fff"},children:"✕"})]},w.id)}),!e&&x.jsx("button",{onClick:()=>s(`Tab ${c.length+1}`),className:"px-3 py-2.5 text-sm transition-colors whitespace-nowrap hover:opacity-80",style:{color:"var(--text-secondary)"},children:"+ Tab"})]})}const WX={"aura-dashboard":()=>Ga.persist.rehydrate(),"aura-theme":()=>Tv.persist.rehydrate(),"aura-groups":()=>qu.persist.rehydrate(),"aura-config":()=>co.persist.rehydrate()};function bdt(){const{connected:e}=Vn();return x.jsxs("div",{className:"flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium",style:{background:e?"var(--accent-green)22":"var(--accent-red)22",color:e?"var(--accent-green)":"var(--accent-red)"},children:[x.jsx("span",{className:`w-2 h-2 rounded-full ${e?"animate-pulse":""}`,style:{background:e?"var(--accent-green)":"var(--accent-red)"}}),e?"Verbunden":"Getrennt"]})}function Cw(){const{tabSlug:e,layoutSlug:t}=qpe(),r=gv(),{frontend:n}=co(),{themeId:a,setTheme:i}=Tv(),o=zT(a),{subscribe:s,setState:l}=Vn(),u=I.useRef(null),c=Nxe(t),f=(c==null?void 0:c.tabs)??[],[d,h]=I.useState(()=>{var v;return(c==null?void 0:c.activeTabId)??((v=f[0])==null?void 0:v.id)??""});I.useEffect(()=>{var v;h((c==null?void 0:c.activeTabId)??((v=c==null?void 0:c.tabs[0])==null?void 0:v.id)??"")},[c==null?void 0:c.id]),I.useEffect(()=>{const v=g=>{g.key&&WX[g.key]&&WX[g.key]()};return window.addEventListener("storage",v),()=>window.removeEventListener("storage",v)},[]),I.useEffect(()=>{u.current||(u.current=document.createElement("style"),u.current.id="aura-custom-css",document.head.appendChild(u.current)),u.current.textContent=n.customCSS},[n.customCSS]),I.useEffect(()=>{if(!e||!f.length)return;const v=f.find(g=>(g.slug??g.id)===e);v&&v.id!==d&&h(v.id)},[e,c==null?void 0:c.id]),I.useEffect(()=>s("aura.0.navigate.url",v=>{const g=String(v.val??"").trim();if(g){if(g.startsWith("http://")||g.startsWith("https://")||g.startsWith("//"))window.location.href=g;else{const y=f.find(m=>(m.slug??m.id)===g);y&&h(y.id)}l("aura.0.navigate.url","")}}),[s,l,c==null?void 0:c.id]);const p=t?`/view/${t}`:"";return x.jsxs("div",{"data-aura-app":"frontend",className:"min-h-screen flex flex-col",style:{background:"var(--app-bg)",color:"var(--text-primary)"},children:[n.showHeader&&x.jsxs("header",{className:"flex items-center justify-between px-4 sm:px-6 py-4 shrink-0",style:{background:"var(--app-surface)",borderBottom:"1px solid var(--app-border)"},children:[x.jsx("h1",{className:"text-xl font-bold tracking-tight",children:n.headerTitle||"Aura"}),x.jsxs("div",{className:"flex items-center gap-3",children:[n.showConnectionBadge&&x.jsx(bdt,{}),x.jsx("button",{onClick:()=>i(o.dark?"light":"dark"),className:"w-8 h-8 flex items-center justify-center rounded-full hover:opacity-80 transition-opacity",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},title:o.dark?"Hell-Modus":"Dunkel-Modus",children:o.dark?x.jsx(Wm,{size:15}):x.jsx(sJ,{size:15})})]})]}),x.jsx(xdt,{readonly:!0,viewTabs:f,viewActiveTabId:d,onViewTabClick:v=>{const g=v.slug??v.id;r(t?`/view/${t}/tab/${g}`:`/tab/${g}`)},layoutUrlBase:p}),x.jsx(jce,{readonly:!0,viewTabs:f,viewActiveTabId:d})]})}function wdt({children:e}){const{themeId:t,customVars:r}=Tv(),n=co(i=>i.frontend.fontScale??1),a=zT(t);return I.useEffect(()=>{const i=document.documentElement,o={...a.vars,...r};Object.entries(o).forEach(([s,l])=>{l&&i.style.setProperty(s,l)}),i.style.setProperty("--font-scale",String(n)),i.classList.toggle("dark",a.dark)},[a,r,n]),x.jsx(x.Fragment,{children:e})}async function Rce(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}const od=_v()(Sv(e=>({pinHash:null,sessionActive:!1,setPinHash:t=>e({pinHash:t}),setSession:t=>e({sessionActive:t})}),{name:"aura-auth",partialize:e=>({pinHash:e.pinHash,sessionActive:e.sessionActive})}));async function _dt(e){const{pinHash:t,setSession:r}=od.getState();return t&&await Rce(e)===t?(r(!0),!0):!1}async function zce(e){const t=await Rce(e);od.getState().setPinHash(t),od.getState().setSession(!0)}function Sdt(){od.getState().setSession(!1)}function Cdt(){const[e,t]=I.useState(V4);return I.useEffect(()=>Axe(()=>t(V4())),[]),{dirty:e,save:()=>kxe(),revert:()=>Mxe([()=>Ga.persist.rehydrate(),()=>Tv.persist.rehydrate(),()=>qu.persist.rehydrate(),()=>co.persist.rehydrate()])}}const Tdt=[{to:"/admin",label:"Übersicht",icon:nJ,end:!0},{to:"/admin/editor",label:"Dashboard-Editor",icon:Oye},{to:"/admin/layouts",label:"Layouts",icon:Qj},{to:"/admin/widgets",label:"Widgets",icon:eR},{to:"/admin/theme",label:"Theme & CSS",icon:lJ},{to:"/admin/settings",label:"Einstellungen",icon:Sye}];function Adt(){var i;const e=Cv(),{layouts:t}=Ga(),r=((i=t[0])==null?void 0:i.id)===e.id,n=e.tabs.find(o=>o.id===e.activeTabId)??e.tabs[0],a=(n==null?void 0:n.slug)??(n==null?void 0:n.id)??"";return r?a&&e.tabs.length>1?`#/tab/${a}`:"#/":a&&e.tabs.length>1?`#/view/${e.slug}/tab/${a}`:`#/view/${e.slug}`}function kdt(){const{sessionActive:e}=od(),{dirty:t,save:r,revert:n}=Cdt(),{adminThemeId:a,setAdminTheme:i}=Tv(),o=Adt(),s=a==="dark"?Lxe:zT(a),l=Object.fromEntries(Object.entries(s.vars).map(([u,c])=>[u,c]));return e?x.jsxs("div",{className:"min-h-screen flex",style:{...l,colorScheme:s.dark?"dark":"light",background:s.vars["--app-bg"],color:s.vars["--text-primary"]},children:[x.jsxs("aside",{className:"w-56 shrink-0 flex flex-col h-screen sticky top-0 overflow-y-auto",style:{background:"var(--app-surface)",borderRight:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"px-5 py-5 border-b shrink-0 flex items-center justify-between",style:{borderColor:"var(--app-border)"},children:[x.jsxs("div",{title:"Adaptive Unified Room Automation",children:[x.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest mb-0.5",style:{color:"var(--text-secondary)"},children:"Aura"}),x.jsx("p",{className:"font-bold text-lg",style:{color:"var(--text-primary)"},children:"Admin"})]}),x.jsx("button",{onClick:()=>i(s.dark?"light":"dark"),className:"w-8 h-8 flex items-center justify-center rounded-lg hover:opacity-80 transition-opacity",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},title:s.dark?"Hell-Modus":"Dunkel-Modus",children:s.dark?x.jsx(Wm,{size:15}):x.jsx(sJ,{size:15})})]}),x.jsx("nav",{className:"flex-1 p-3 space-y-1",children:Tdt.map(({to:u,label:c,icon:f,end:d})=>x.jsxs(XZ,{to:u,end:d,className:({isActive:h})=>`flex items-center gap-3 px-3 py-2.5 rounded-xl text-sm font-medium transition-opacity hover:opacity-80 ${h?"opacity-100":"opacity-60"}`,style:({isActive:h})=>({background:h?"var(--accent)22":"transparent",color:h?"var(--accent)":"var(--text-primary)"}),children:[x.jsx(f,{size:17}),c]},u))}),x.jsxs("div",{className:"p-3 space-y-1 border-t",style:{borderColor:"var(--app-border)"},children:[x.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 px-3 py-2.5 rounded-xl text-sm font-medium opacity-60 hover:opacity-100 transition-opacity",style:{color:"var(--text-primary)"},children:[x.jsx(JZ,{size:17})," Frontend öffnen"]}),x.jsxs("button",{onClick:Sdt,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-sm font-medium opacity-60 hover:opacity-100 transition-opacity",style:{color:"var(--accent-red)"},children:[x.jsx(aye,{size:17})," Abmelden"]})]})]}),x.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",style:{background:"var(--app-bg)"},children:[x.jsx("div",{className:"shrink-0 flex items-center justify-end gap-2 px-4 py-2 transition-all",style:{background:t?"var(--accent)11":"var(--app-surface)",borderBottom:`1px solid ${t?"var(--accent)44":"var(--app-border)"}`,minHeight:"44px"},children:t?x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"text-xs mr-auto",style:{color:"var(--accent)"},children:"Ungespeicherte Änderungen"}),x.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium hover:opacity-80 transition-opacity",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:[x.jsx(Hye,{size:13})," Rückgängig"]}),x.jsxs("button",{onClick:r,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-white hover:opacity-80 transition-opacity",style:{background:"var(--accent)"},children:[x.jsx(bye,{size:13})," Speichern"]})]}):x.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:"Alle Änderungen gespeichert"})}),x.jsx("main",{className:"flex-1 overflow-auto",children:x.jsx(mve,{})})]})]}):x.jsx(yve,{to:"/admin/login",replace:!0})}function Mdt(){const{pinHash:e}=od(),t=!e,[r,n]=I.useState(""),[a,i]=I.useState(""),[o,s]=I.useState(!1),[l,u]=I.useState(""),[c,f]=I.useState(!1),d=gv(),h=async p=>{if(p.preventDefault(),u(""),r.length<4){u("Mindestens 4 Zeichen");return}if(f(!0),t){if(r!==a){u("PINs stimmen nicht überein"),f(!1);return}await zce(r),d("/admin")}else await _dt(r)?d("/admin"):(u("Falscher PIN"),f(!1))};return x.jsx("div",{className:"min-h-screen flex items-center justify-center p-4",style:{background:"var(--app-bg)"},children:x.jsx("div",{className:"w-full max-w-sm",children:x.jsxs("div",{className:"rounded-2xl p-8 shadow-2xl",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex flex-col items-center mb-8",children:[x.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mb-4",style:{background:"var(--accent)22"},children:x.jsx(oJ,{size:28,style:{color:"var(--accent)"}})}),x.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:t?"Admin einrichten":"Admin-Bereich"}),x.jsx("p",{className:"text-sm mt-1 text-center",style:{color:"var(--text-secondary)"},children:t?"Lege einen PIN für den Admin-Bereich fest":"PIN eingeben um fortzufahren"})]}),x.jsxs("form",{onSubmit:h,className:"space-y-4",children:[x.jsxs("div",{className:"relative",children:[x.jsx("input",{type:o?"text":"password",value:r,onChange:p=>n(p.target.value),placeholder:t?"Neuer PIN (min. 4 Zeichen)":"PIN",autoFocus:!0,className:"w-full rounded-xl px-4 py-3 pr-10 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),x.jsx("button",{type:"button",onClick:()=>s(p=>!p),className:"absolute right-3 top-1/2 -translate-y-1/2",style:{color:"var(--text-secondary)"},children:o?x.jsx(Jj,{size:16}):x.jsx(QZ,{size:16})})]}),t&&x.jsx("input",{type:o?"text":"password",value:a,onChange:p=>i(p.target.value),placeholder:"PIN bestätigen",className:"w-full rounded-xl px-4 py-3 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),l&&x.jsx("p",{className:"text-sm",style:{color:"var(--accent-red)"},children:l}),x.jsx("button",{type:"submit",disabled:c,className:"w-full py-3 rounded-xl text-sm font-semibold text-white transition-opacity hover:opacity-80 disabled:opacity-50",style:{background:"var(--accent)"},children:c?"…":t?"PIN setzen & einloggen":"Einloggen"})]}),x.jsx("div",{className:"mt-6 text-center",children:x.jsx("a",{href:"/",className:"text-xs hover:opacity-80",style:{color:"var(--text-secondary)"},children:"← Zurück zum Dashboard"})})]})})})}function Tw({label:e,value:t,icon:r,color:n}){return x.jsxs("div",{className:"rounded-xl p-5",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center justify-between mb-3",children:[x.jsx("span",{className:"text-sm",style:{color:"var(--text-secondary)"},children:e}),x.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:n+"22"},children:x.jsx(r,{size:16,style:{color:n}})})]}),x.jsx("p",{className:"text-3xl font-bold",style:{color:"var(--text-primary)"},children:t})]})}function HX({text:e}){const[t,r]=I.useState(!1),n=()=>{navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)};return x.jsx("button",{onClick:n,className:"hover:opacity-70 shrink-0",title:"Kopieren",children:t?x.jsx(Tu,{size:12,style:{color:"var(--accent-green)"}}):x.jsx(Zj,{size:12,style:{color:"var(--text-secondary)"}})})}function Pdt(){var o;const{layouts:e}=Ga(),r=Cv().tabs,n=e.reduce((s,l)=>s+l.tabs.length,0),a=e.reduce((s,l)=>s+l.tabs.reduce((u,c)=>u+c.widgets.length,0),0),{connected:i}=Vn();return x.jsxs("div",{className:"p-8 space-y-8",children:[x.jsxs("div",{children:[x.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:"Übersicht"}),x.jsx("p",{className:"text-sm mt-1",style:{color:"var(--text-secondary)"},children:"Status und Statistiken"})]}),x.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[x.jsx(Tw,{label:"Layouts",value:e.length,icon:eR,color:"var(--accent)"}),x.jsx(Tw,{label:"Tabs gesamt",value:n,icon:fye,color:"var(--accent-green)"}),x.jsx(Tw,{label:"Widgets gesamt",value:a,icon:tJ,color:"var(--accent-yellow)"}),x.jsx(Tw,{label:"ioBroker",value:i?"Verbunden":"Getrennt",icon:i?qye:Yye,color:i?"var(--accent-green)":"var(--accent-red)"})]}),x.jsxs("div",{className:"rounded-xl p-6",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsx("h2",{className:"font-semibold text-lg mb-4",style:{color:"var(--text-primary)"},children:"Tabs & Widgets"}),x.jsx("div",{className:"space-y-2",children:r.map(s=>x.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-lg",style:{background:"var(--app-bg)"},children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-primary)"},children:s.name}),x.jsxs("p",{className:"text-xs font-mono mt-0.5",style:{color:"var(--text-secondary)"},children:["#/tab/",s.slug??s.id]})]}),x.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"var(--accent)22",color:"var(--accent)"},children:[s.widgets.length," Widgets"]})]},s.id))})]}),x.jsxs("div",{className:"rounded-xl p-5",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest mb-3",style:{color:"var(--text-secondary)"},children:"Was bedeutet AURA?"}),x.jsx("div",{className:"flex flex-col gap-1.5",children:[["A","daptive","Passt sich flexibel an Geräte, Räume und Layouts an"],["U","nified","Alle Datenpunkte und Räume in einer einheitlichen Oberfläche"],["R","oom","Raumbasierte Organisation – jedes Tablet sein eigenes Layout"],["A","utomation","ioBroker-Automatisierungen live steuern und visualisieren"]].map(([s,l,u])=>x.jsxs("div",{className:"flex items-baseline gap-2",children:[x.jsx("span",{className:"text-lg font-bold w-4 shrink-0",style:{color:"var(--accent)"},children:s}),x.jsx("span",{className:"text-sm font-medium w-24 shrink-0",style:{color:"var(--text-primary)"},children:l}),x.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:u})]},s+l))})]}),x.jsxs("div",{className:"rounded-xl p-6 space-y-4",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(lye,{size:18,style:{color:"var(--accent)"}}),x.jsx("h2",{className:"font-semibold text-lg",style:{color:"var(--text-primary)"},children:"Tablet-Navigation via ioBroker"})]}),x.jsx("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:"Setze den folgenden Datenpunkt aus einem ioBroker-Skript oder einer Automatisierung, um das Tablet auf einen bestimmten Tab oder eine externe URL zu navigieren. Der Datenpunkt wird nach der Navigation automatisch zurückgesetzt."}),x.jsxs("div",{className:"rounded-lg px-4 py-3",style:{background:"var(--app-bg)",border:"1px solid var(--app-border)"},children:[x.jsx("p",{className:"text-xs mb-1",style:{color:"var(--text-secondary)"},children:"Datenpunkt"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("code",{className:"text-sm font-mono flex-1",style:{color:"var(--accent)"},children:"aura.0.navigate.url"}),x.jsx(HX,{text:"aura.0.navigate.url"})]})]}),x.jsxs("div",{children:[x.jsx("p",{className:"text-xs font-medium mb-2",style:{color:"var(--text-secondary)"},children:"Tab-Slugs (Wert für den Datenpunkt)"}),x.jsx("div",{className:"space-y-1.5",children:r.map(s=>{const l=s.slug??s.id;return x.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg",style:{background:"var(--app-bg)"},children:[x.jsx("span",{className:"text-sm flex-1",style:{color:"var(--text-primary)"},children:s.name}),x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("code",{className:"text-xs font-mono",style:{color:"var(--text-secondary)"},children:l}),x.jsx(HX,{text:l})]})]},s.id)})})]}),x.jsxs("div",{className:"rounded-lg px-4 py-3 space-y-1",style:{background:"var(--app-bg)",border:"1px solid var(--app-border)"},children:[x.jsx("p",{className:"text-xs font-medium",style:{color:"var(--text-secondary)"},children:"Beispiel (JavaScript-Skript)"}),x.jsx("pre",{className:"text-xs font-mono overflow-x-auto",style:{color:"var(--text-primary)"},children:`setState('aura.0.navigate.url', '${((o=r[0])==null?void 0:o.slug)??"dashboard"}');`}),x.jsx("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:"Für externe URLs die vollständige URL angeben (https://…)."})]})]})]})}const GX=[{label:"Wert / Uhr",cls:"text-3xl",rem:1.875},{label:"Überschrift",cls:"text-xl",rem:1.25},{label:"Subheading",cls:"text-lg",rem:1.125},{label:"Fließtext",cls:"text-sm",rem:.875},{label:"Klein / Label",cls:"text-xs",rem:.75}],Ddt=[{label:"XS",value:.8},{label:"S",value:.9},{label:"M",value:1},{label:"L",value:1.15},{label:"XL",value:1.3},{label:"XXL",value:1.5}],Edt=[{label:"App",keys:["--app-bg","--app-surface","--app-border"]},{label:"Widget-Karte",keys:["--widget-bg","--widget-border","--widget-border-width","--widget-radius","--widget-shadow"]},{label:"Text",keys:["--text-primary","--text-secondary"]},{label:"Farben",keys:["--accent","--accent-green","--accent-yellow","--accent-red"]}],Ndt={"--app-bg":"Hintergrund","--app-surface":"Oberfläche","--app-border":"Rahmen","--widget-bg":"Hintergrund","--widget-border":"Rahmen","--widget-border-width":"Rahmenbreite","--widget-radius":"Eckenradius","--widget-shadow":"Schatten","--text-primary":"Primär","--text-secondary":"Sekundär","--accent":"Akzent","--accent-green":"Grün","--accent-yellow":"Gelb","--accent-red":"Rot"};function Odt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function Ldt(){const{themeId:e,customVars:t,setTheme:r,setCustomVar:n,resetCustom:a}=Tv(),{frontend:i,updateFrontend:o}=co(),s=zT(e),l=i.fontScale??1;return x.jsxs("div",{className:"p-8 space-y-8",children:[x.jsxs("div",{children:[x.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:"Theme & CSS"}),x.jsx("p",{className:"text-sm mt-1",style:{color:"var(--text-secondary)"},children:"Globales Design für Frontend und Admin"})]}),x.jsxs("div",{className:"rounded-xl p-6",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsx("h2",{className:"font-semibold mb-4",style:{color:"var(--text-primary)"},children:"Theme-Preset"}),x.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:UE.map(u=>x.jsxs("button",{onClick:()=>{r(u.id),a()},className:"rounded-xl p-4 text-left transition-opacity hover:opacity-80 space-y-3",style:{background:u.vars["--app-surface"],border:`2px solid ${e===u.id?"var(--accent)":u.vars["--app-border"]}`},children:[x.jsx("div",{className:"flex gap-1.5",children:["--widget-bg","--accent","--accent-green","--accent-yellow"].map(c=>x.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:u.vars[c],border:`1px solid ${u.vars["--app-border"]}`}},c))}),x.jsxs("div",{children:[x.jsx("p",{className:"text-sm font-semibold",style:{color:u.vars["--text-primary"]},children:u.name}),e===u.id&&x.jsx("p",{className:"text-xs mt-0.5",style:{color:u.vars["--accent"]},children:"Aktiv ✓"})]})]},u.id))})]}),x.jsxs("div",{className:"rounded-xl p-6",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center justify-between mb-4",children:[x.jsx("h2",{className:"font-semibold",style:{color:"var(--text-primary)"},children:"CSS-Variablen anpassen"}),Object.keys(t).length>0&&x.jsx("button",{onClick:a,className:"text-xs px-3 py-1.5 rounded-lg hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--accent-red)",border:"1px solid var(--app-border)"},children:"Alle zurücksetzen"})]}),x.jsx("div",{className:"space-y-6",children:Edt.map(({label:u,keys:c})=>x.jsxs("div",{children:[x.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest mb-3",style:{color:"var(--text-secondary)"},children:u}),x.jsx("div",{className:"space-y-3",children:c.map(f=>{const d=s.vars[f],h=t[f],p=h??d;return x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx("label",{className:"text-xs w-32 shrink-0",style:{color:"var(--text-secondary)"},children:Ndt[f]??f}),x.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Odt(p)&&x.jsx("input",{type:"color",value:p.startsWith("#")?p:"#000000",onChange:v=>n(f,v.target.value),className:"w-8 h-8 rounded-lg cursor-pointer border-0 p-0.5 shrink-0",style:{background:"var(--app-bg)",border:"1px solid var(--app-border)"}}),x.jsx("input",{type:"text",value:h??"",placeholder:d,onChange:v=>{v.target.value?n(f,v.target.value):a()},className:"flex-1 text-xs rounded-lg px-3 py-2 focus:outline-none font-mono",style:{background:"var(--app-bg)",color:h?"var(--text-primary)":"var(--text-secondary)",border:`1px solid ${h?"var(--accent)":"var(--app-border)"}`}}),h&&x.jsx("button",{onClick:()=>{const v={...t};delete v[f],a(),Object.entries(v).forEach(([g,y])=>n(g,y))},className:"text-xs hover:opacity-70 shrink-0",style:{color:"var(--text-secondary)"},children:"✕"})]})]},f)})})]},u))})]}),x.jsxs("div",{className:"rounded-xl p-6 space-y-5",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsxs("div",{children:[x.jsx("h2",{className:"font-semibold text-lg",style:{color:"var(--text-primary)"},children:"Typografie"}),x.jsx("p",{className:"text-xs mt-1",style:{color:"var(--text-secondary)"},children:"Skaliert alle Textgrößen im Frontend proportional. Die Admin-Oberfläche bleibt unverändert."})]}),x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center justify-between mb-2",children:[x.jsx("p",{className:"text-sm font-medium",style:{color:"var(--text-primary)"},children:"Schriftgröße"}),x.jsxs("span",{className:"text-sm font-mono font-bold px-2.5 py-1 rounded-lg",style:{background:"var(--app-bg)",color:"var(--accent)",border:"1px solid var(--app-border)"},children:[Math.round(l*100)," %"]})]}),x.jsx("input",{type:"range",min:.7,max:1.6,step:.05,value:l,onChange:u=>o({fontScale:Number(u.target.value)}),className:"w-full accent-[var(--accent)] mb-3"}),x.jsx("div",{className:"flex gap-2 flex-wrap",children:Ddt.map(({label:u,value:c})=>{const f=Math.abs(l-c)<.01;return x.jsxs("button",{onClick:()=>o({fontScale:c}),className:"px-3 py-1.5 rounded-lg text-xs font-medium hover:opacity-80",style:{background:f?"var(--accent)":"var(--app-bg)",color:f?"#fff":"var(--text-secondary)",border:`1px solid ${f?"var(--accent)":"var(--app-border)"}`},children:[u," · ",Math.round(c*100),"%"]},c)})})]}),x.jsxs("div",{children:[x.jsxs("p",{className:"text-xs font-semibold uppercase tracking-widest mb-2",style:{color:"var(--text-secondary)"},children:["Größen-Referenz bei ",Math.round(l*100)," %"]}),x.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--app-border)"},children:GX.map(({label:u,cls:c,rem:f},d)=>{const h=Math.round(f*l*16),p=(f*l).toFixed(3).replace(/\.?0+$/,"");return x.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5",style:{background:d%2===0?"var(--app-bg)":"var(--app-surface)",borderBottom:d<GX.length-1?"1px solid var(--app-border)":void 0},children:[x.jsx("span",{className:"w-32 shrink-0 text-xs font-mono",style:{color:"var(--text-secondary)"},children:c}),x.jsx("span",{className:"w-28 shrink-0 text-xs",style:{color:"var(--text-secondary)"},children:u}),x.jsxs("span",{className:"w-28 shrink-0 text-xs font-mono",style:{color:"var(--accent)"},children:[p,"rem · ",h,"px"]}),x.jsx("span",{style:{fontSize:`${f*l}rem`,color:"var(--text-primary)",lineHeight:1.2},children:"Beispiel"})]},c)})})]}),l!==1&&x.jsx("button",{onClick:()=>o({fontScale:1}),className:"text-xs hover:opacity-70",style:{color:"var(--text-secondary)"},children:"Zurücksetzen (100 %)"})]}),x.jsxs("div",{className:"rounded-xl p-6",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsx("h2",{className:"font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Globales CSS"}),x.jsx("p",{className:"text-xs mb-4",style:{color:"var(--text-secondary)"},children:"Wird direkt auf das Frontend angewendet. CSS-Variablen, Animationen, Font-Overrides etc."}),x.jsx("textarea",{value:i.customCSS,onChange:u=>o({customCSS:u.target.value}),rows:12,spellCheck:!1,placeholder:`/* Beispiele */
603
+ }`,rows:6,className:"w-full text-xs rounded-lg px-2.5 py-2 font-mono focus:outline-none resize-y",style:Ri})]})]}),p&&x.jsx(Av,{currentValue:((P=n.find(M=>M.id===p))==null?void 0:P.datapointId)??"",onSelect:M=>{S(p,{datapointId:M}),y(D=>{const E={...D};return delete E[p],E}),v(null)},onClose:()=>v(null)})]})}function Os(e){return(e/1e3).toFixed(1)+" kW"}function Jft(e){const t=Math.floor(e/1e9),r=Math.floor(t/3600),n=Math.floor(t%3600/60);return r>0?`${r}:${String(n).padStart(2,"0")} h`:`${n}:${String(t%60).padStart(2,"0")} min`}function Wh(e){return Math.round(e)+"%"}const Qft={off:0,pv:1,minpv:2,now:3},zX=[{key:"off",label:"AUS",activeColor:"#6b7280"},{key:"pv",label:"PV",activeColor:"#f59e0b"},{key:"minpv",label:"MIN+PV",activeColor:"#f97316"},{key:"now",label:"SOFORT",activeColor:"#ef4444"}],edt={pvPower:0,gridPower:0,homePower:0,batteryPower:0,batterySoc:0,batteryMode:"",greenShareHome:0,greenShareLoadpoints:0,tariffGrid:0},tdt={chargePower:0,chargedEnergy:0,charging:!1,connected:!1,mode:"off",vehicleTitle:"",vehicleSoc:0,vehicleRange:0,effectiveLimitSoc:80,sessionSolarPercentage:0,sessionPrice:0,planActive:!1,effectivePlanTime:"",chargeDuration:0,phasesActive:0,title:""};function rdt(e,t){const{subscribe:r,getState:n}=Vn(),[a,i]=I.useState({...edt}),[o,s]=I.useState(Array.from({length:t},()=>({...tdt}))),l=I.useCallback((c,f)=>{i(d=>({...d,[c]:f??d[c]}))},[]),u=I.useCallback((c,f,d)=>{s(h=>{const p=[...h];return p[c]={...p[c],[f]:d??p[c][f]},p})},[]);return I.useEffect(()=>{const c=[],f=[["pvPower","pvPower"],["gridPower","gridPower"],["homePower","homePower"],["batteryPower","batteryPower"],["batterySoc","batterySoc"],["batteryMode","batteryMode"],["greenShareHome","greenShareHome"],["greenShareLoadpoints","greenShareLoadpoints"],["tariffGrid","tariffGrid"]];for(const[d,h]of f){const p=`${e}.status.${d}`,v=g=>l(h,g.val);c.push(r(p,v)),n(p).then(g=>{g&&l(h,g.val)})}for(let d=1;d<=t;d++){const h=d-1,p=`${e}.loadpoint.${d}.status`,v=[["chargePower","chargePower"],["chargedEnergy","chargedEnergy"],["charging","charging"],["connected","connected"],["mode","mode"],["vehicleTitle","vehicleTitle"],["vehicleSoc","vehicleSoc"],["vehicleRange","vehicleRange"],["effectiveLimitSoc","effectiveLimitSoc"],["sessionSolarPercentage","sessionSolarPercentage"],["sessionPrice","sessionPrice"],["planActive","planActive"],["effectivePlanTime","effectivePlanTime"],["chargeDuration","chargeDuration"],["phasesActive","phasesActive"],["title","title"]];for(const[g,y]of v){const m=`${p}.${g}`,b=w=>u(h,y,w.val);c.push(r(m,b)),n(m).then(w=>{w&&u(h,y,w.val)})}}return()=>c.forEach(d=>d())},[e,t,r,n,l,u]),{site:a,loadpoints:o}}function BX({site:e,showBattery:t,compact:r}){const n=e.gridPower>0,a=e.gridPower<0,i=n?"#ef4444":a?"#10b981":"var(--text-secondary)",o=e.batteryPower<0,s=o?"#3b82f6":"#f59e0b";return r?x.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[x.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium",children:[x.jsx(Wm,{size:13,color:"#f59e0b"}),x.jsx("span",{style:{color:"#f59e0b"},children:Os(e.pvPower)})]}),x.jsx("span",{style:{color:"var(--text-secondary)",fontSize:10},children:"·"}),x.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium",children:[x.jsx(DE,{size:13,color:"var(--text-secondary)"}),x.jsx("span",{style:{color:"var(--text-primary)"},children:Os(e.homePower)})]}),x.jsx("span",{style:{color:"var(--text-secondary)",fontSize:10},children:"·"}),x.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium",children:[x.jsx(ll,{size:13,color:i}),x.jsx("span",{style:{color:i},children:Os(Math.abs(e.gridPower))})]}),t&&e.batterySoc>0&&x.jsxs(x.Fragment,{children:[x.jsx("span",{style:{color:"var(--text-secondary)",fontSize:10},children:"·"}),x.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium",children:[x.jsx(w4,{size:13,color:s}),x.jsx("span",{style:{color:s},children:Wh(e.batterySoc)})]})]})]}):x.jsxs("div",{className:"space-y-1.5",children:[x.jsxs("div",{className:"flex items-center justify-between gap-1",children:[x.jsxs("div",{className:"flex flex-col items-center gap-0.5 min-w-0",children:[x.jsx(Wm,{size:18,color:"#f59e0b"}),x.jsx("span",{className:"text-xs font-semibold whitespace-nowrap",style:{color:"#f59e0b"},children:Os(e.pvPower)}),x.jsx("span",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:"Solar"})]}),x.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[x.jsx("div",{className:"h-px flex-1",style:{background:"#f59e0b",opacity:.5}}),x.jsx("span",{style:{color:"#f59e0b",fontSize:10},children:"▶"})]}),x.jsxs("div",{className:"flex flex-col items-center gap-0.5 min-w-0",children:[x.jsx(DE,{size:18,color:"var(--text-secondary)"}),x.jsx("span",{className:"text-xs font-semibold whitespace-nowrap",style:{color:"var(--text-primary)"},children:Os(e.homePower)}),x.jsx("span",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:"Haus"})]}),x.jsx("div",{className:"flex-1 flex items-center justify-center",children:n?x.jsxs(x.Fragment,{children:[x.jsx("span",{style:{color:i,fontSize:10},children:"◀"}),x.jsx("div",{className:"h-px flex-1",style:{background:i,opacity:.5}})]}):x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"h-px flex-1",style:{background:i,opacity:.5}}),x.jsx("span",{style:{color:i,fontSize:10},children:"▶"})]})}),x.jsxs("div",{className:"flex flex-col items-center gap-0.5 min-w-0",children:[x.jsx(ll,{size:18,color:i}),x.jsx("span",{className:"text-xs font-semibold whitespace-nowrap",style:{color:i},children:Os(Math.abs(e.gridPower))}),x.jsx("span",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:n?"Bezug":a?"Einspsg.":"Netz"})]})]}),t&&e.batterySoc>0&&x.jsx("div",{className:"flex items-center justify-center gap-2 pt-0.5",children:x.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-lg",style:{background:"var(--app-bg)"},children:[o?x.jsx("span",{style:{color:s,fontSize:10},children:"▼"}):x.jsx("span",{style:{color:s,fontSize:10},children:"▲"}),x.jsx(w4,{size:14,color:s}),x.jsx("span",{className:"text-xs font-semibold",style:{color:s},children:Wh(e.batterySoc)}),e.batteryPower!==0&&x.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:["· ",Os(Math.abs(e.batteryPower))]}),e.batteryMode&&e.batteryMode!=="normal"&&e.batteryMode!=="unknown"&&x.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:["· ",e.batteryMode]})]})})]})}function ndt({current:e,target:t,color:r}){return x.jsxs("div",{className:"relative h-2 rounded-full overflow-hidden",style:{background:"var(--app-border)"},children:[x.jsx("div",{className:"absolute left-0 top-0 h-full rounded-full transition-all duration-500",style:{width:`${Math.min(100,e)}%`,background:r}}),t>0&&t<100&&x.jsx("div",{className:"absolute top-0 h-full w-0.5",style:{left:`${t}%`,background:"var(--text-primary)",opacity:.6}})]})}function $X({lp:e,idx:t,prefix:r,compact:n}){var u;const{setState:a}=Vn(),i=c=>{a(`${r}.loadpoint.${t+1}.control.pvControl`,Qft[c])},o=c=>{a(`${r}.loadpoint.${t+1}.control.limitSoc`,c)},s=e.title||`Ladepunkt ${t+1}`,l=e.vehicleTitle||"Fahrzeug";return n?x.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-xs",children:[e.connected?x.jsx(C4,{size:13,color:"#6366f1"}):x.jsx(T4,{size:13,color:"var(--text-secondary)"}),x.jsx("span",{style:{color:e.connected?"var(--text-primary)":"var(--text-secondary)"},children:e.connected?l:s}),e.vehicleSoc>0&&x.jsxs("span",{style:{color:"#6366f1"},children:[Wh(e.vehicleSoc),"→",Wh(e.effectiveLimitSoc)]}),e.charging&&x.jsxs("span",{className:"flex items-center gap-1",style:{color:"#6366f1"},children:[x.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full animate-pulse",style:{background:"#6366f1"}}),Os(e.chargePower)]}),x.jsx("span",{className:"ml-auto font-medium",style:{color:"var(--text-secondary)"},children:((u=zX.find(c=>c.key===e.mode))==null?void 0:u.label)??e.mode})]}):x.jsxs("div",{className:"space-y-2 pt-2 border-t",style:{borderColor:"var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center gap-2",children:[e.connected?x.jsx(C4,{size:16,color:"#6366f1"}):x.jsx(T4,{size:16,color:"var(--text-secondary)"}),x.jsx("span",{className:"text-sm font-semibold flex-1 truncate",style:{color:"var(--text-primary)"},children:e.connected?l:s}),e.charging&&x.jsxs("span",{className:"flex items-center gap-1 text-xs",style:{color:"#6366f1"},children:[x.jsx("span",{className:"inline-block w-2 h-2 rounded-full animate-pulse",style:{background:"#6366f1"}}),"Laden"]}),e.chargePower>0&&x.jsx("span",{className:"text-xs font-bold",style:{color:"#6366f1"},children:Os(e.chargePower)})]}),e.connected&&e.vehicleSoc>0&&x.jsxs("div",{className:"space-y-1",children:[x.jsxs("div",{className:"flex items-center justify-between text-[11px]",style:{color:"var(--text-secondary)"},children:[x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx(vge,{size:11}),x.jsx("span",{children:Wh(e.vehicleSoc)}),e.vehicleRange>0&&x.jsxs("span",{children:["· ",Math.round(e.vehicleRange)," km"]})]}),x.jsxs("div",{className:"flex items-center gap-1",children:[x.jsx("span",{children:"Ziel:"}),x.jsx("button",{className:"font-semibold hover:opacity-80 transition-opacity",style:{color:"#6366f1"},onClick:()=>o(Math.min(100,e.effectiveLimitSoc+10)),title:"Ziel-SoC anpassen",children:Wh(e.effectiveLimitSoc)}),e.sessionSolarPercentage>0&&x.jsxs("span",{style:{color:"#10b981"},children:["· 🌿 ",Math.round(e.sessionSolarPercentage),"%"]})]})]}),x.jsx(ndt,{current:e.vehicleSoc,target:e.effectiveLimitSoc,color:"#6366f1"})]}),e.charging&&x.jsxs("div",{className:"flex items-center gap-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[e.chargeDuration>0&&x.jsx("span",{children:Jft(e.chargeDuration)}),e.chargedEnergy>0&&x.jsxs("span",{children:[(e.chargedEnergy/1e3).toFixed(2)," kWh"]}),e.sessionPrice>0&&x.jsxs("span",{children:[e.sessionPrice.toFixed(2)," €"]}),e.phasesActive>0&&x.jsxs("span",{children:[e.phasesActive,"ϕ"]}),e.planActive&&e.effectivePlanTime&&x.jsxs("span",{style:{color:"#f59e0b"},children:["📅 ",new Date(e.effectivePlanTime).toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"})]})]}),x.jsx("div",{className:"flex gap-1",children:zX.map(c=>{const f=e.mode===c.key;return x.jsx("button",{onClick:()=>i(c.key),className:"flex-1 text-[11px] font-medium rounded-md transition-all duration-150 hover:opacity-90 active:scale-95",style:{minHeight:28,background:f?c.activeColor:"var(--app-bg)",color:f?"#fff":"var(--text-secondary)",border:`1px solid ${f?c.activeColor:"var(--app-border)"}`},children:c.label},c.key)})})]})}function adt({config:e}){const{connected:t}=Vn(),r=e.options??{},n=r.evccPrefix??"evcc.0",a=Math.max(1,Math.min(4,r.loadpointCount??1)),i=r.showBattery??!0,o=e.layout??"default",s=o==="compact"||o==="minimal",{site:l,loadpoints:u}=rdt(n,a);return t?s?x.jsxs("div",{className:"flex flex-col gap-1.5 h-full justify-center px-1",children:[x.jsx(BX,{site:l,showBattery:i,compact:!0}),u.map((c,f)=>x.jsx($X,{lp:c,idx:f,prefix:n,compact:!0},f))]}):x.jsxs("div",{className:"flex flex-col gap-3 h-full overflow-auto",children:[x.jsx(BX,{site:l,showBattery:i,compact:!1}),u.map((c,f)=>x.jsx($X,{lp:c,idx:f,prefix:n,compact:!1},f)),l.tariffGrid>0&&x.jsxs("div",{className:"text-[10px] text-right",style:{color:"var(--text-secondary)"},children:[l.tariffGrid.toFixed(4)," €/kWh"]})]}):x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2",style:{color:"var(--text-secondary)"},children:[x.jsx(ll,{size:24,strokeWidth:1.5}),x.jsx("span",{className:"text-xs",children:"Keine Verbindung"})]})}function idt({config:e,onConfigChange:t}){const r=e.options??{},n=u=>t({...e,options:{...r,...u}}),a=r.evccPrefix??"evcc.0",i=r.loadpointCount??1,o=r.showBattery??!0,s="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",l={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};return x.jsxs(x.Fragment,{children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"evcc Präfix"}),x.jsx("input",{type:"text",value:a,onChange:u=>n({evccPrefix:u.target.value||"evcc.0"}),placeholder:"evcc.0",className:s+" font-mono",style:l})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Ladepunkte"}),x.jsx("div",{className:"flex gap-1",children:[1,2,3,4].map(u=>x.jsx("button",{onClick:()=>n({loadpointCount:u}),className:"flex-1 text-xs py-1.5 rounded-lg transition-all",style:{background:i===u?"var(--accent)":"var(--app-bg)",color:i===u?"#fff":"var(--text-secondary)",border:`1px solid ${i===u?"var(--accent)":"var(--app-border)"}`},children:u},u))})]}),x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Batterie anzeigen"}),x.jsx("button",{onClick:()=>n({showBattery:!o}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:o?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:o?"18px":"2px"}})})]})]})}function FX(e){return e===0?{desc:"Sonnig",emoji:"☀️"}:e===1?{desc:"Leicht bewölkt",emoji:"🌤️"}:e===2?{desc:"Bewölkt",emoji:"⛅"}:e===3?{desc:"Bedeckt",emoji:"☁️"}:e===45||e===48?{desc:"Nebel",emoji:"🌫️"}:e>=51&&e<=55?{desc:"Nieselregen",emoji:"🌦️"}:e>=61&&e<=65?{desc:"Regen",emoji:"🌧️"}:e>=71&&e<=75?{desc:"Schnee",emoji:"❄️"}:e>=80&&e<=82?{desc:"Schauer",emoji:"🌦️"}:e===95?{desc:"Gewitter",emoji:"⛈️"}:{desc:"Unbekannt",emoji:"🌡️"}}function odt(e,t=!0){return new Date(e).toLocaleDateString("de-DE",{weekday:t?"short":"long"})}function sdt({config:e}){const t=e.options??{},r=t.latitude??48.1,n=t.longitude??11.6,a=t.locationName??"",i=t.refreshMinutes??30,o=t.showForecast??!0,s=t.forecastDays??6,l=e.layout??"default",[u,c]=I.useState(null),[f,d]=I.useState(!0),[h,p]=I.useState(!1);if(I.useEffect(()=>{let k=!1;const P=async()=>{try{const D=Math.min(Math.max(s+1,4),8),E=`https://api.open-meteo.com/v1/forecast?latitude=${r}&longitude=${n}&current=temperature_2m,relative_humidity_2m,weather_code,wind_speed_10m,apparent_temperature&daily=weather_code,temperature_2m_max,temperature_2m_min&timezone=auto&forecast_days=${D}&wind_speed_unit=kmh`,L=await fetch(E);if(!L.ok)throw new Error("HTTP error");const N=await L.json();k||(c(N),p(!1),d(!1))}catch{k||(p(!0),d(!1))}};d(!0),P();const M=setInterval(P,i*6e4);return()=>{k=!0,clearInterval(M)}},[r,n,i,s]),f&&!u)return x.jsx("div",{className:"flex items-center justify-center h-full",children:x.jsx(z_,{size:24,className:"animate-spin",style:{color:"var(--text-secondary)"}})});if(!u)return x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2",style:{color:"var(--text-secondary)"},children:[x.jsx("span",{className:"text-2xl",children:"🌡️"}),x.jsx("span",{className:"text-xs",children:"Wetterdaten nicht verfügbar"})]});const v=u.current,g=FX(v.weather_code),y=`${Math.round(v.temperature_2m)}°C`,m=`${Math.round(v.apparent_temperature)}°`;if(l==="minimal")return x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[x.jsx("span",{style:{fontSize:"2.5rem",lineHeight:1},children:g.emoji}),x.jsxs("span",{className:"text-3xl font-black",style:{color:"var(--text-primary)"},children:[Math.round(v.temperature_2m),"°"]})]});if(l==="compact")return x.jsxs("div",{className:"flex items-center gap-2.5 h-full",children:[x.jsx("span",{style:{fontSize:"1.8rem",lineHeight:1},children:g.emoji}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsxs("div",{className:"flex items-baseline gap-1.5",children:[x.jsx("span",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:y}),x.jsx("span",{className:"text-xs truncate",style:{color:"var(--text-secondary)"},children:g.desc})]}),x.jsxs("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:["💧 ",v.relative_humidity_2m,"% · 💨 ",Math.round(v.wind_speed_10m)," km/h",a?` · ${a}`:""]})]})]});const b=Math.min(s,u.daily.time.length-1),w=Array.from({length:b},(k,P)=>P+1).map(k=>({day:odt(u.daily.time[k]),info:FX(u.daily.weather_code[k]),max:Math.round(u.daily.temperature_2m_max[k]),min:Math.round(u.daily.temperature_2m_min[k])})),_=w.map(k=>k.min),S=w.map(k=>k.max),C=Math.min(..._),A=Math.max(...S)-C||1;return x.jsxs("div",{className:"flex flex-col h-full gap-2",children:[x.jsxs("div",{className:"flex items-start gap-3 shrink-0",children:[x.jsx("span",{style:{fontSize:l==="card"?"2.8rem":"2.2rem",lineHeight:1},children:g.emoji}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("div",{className:"flex items-baseline gap-2 flex-wrap",children:x.jsxs("span",{className:"font-bold",style:{color:"var(--text-secondary)",fontSize:"0.85rem"},children:[g.desc,", ",y]})}),x.jsxs("div",{className:"text-xs",style:{color:"var(--text-secondary)"},children:["💧 ",v.relative_humidity_2m,"% Luftfeuchtigkeit"]}),x.jsxs("div",{className:"text-xs",style:{color:"var(--text-secondary)"},children:["Gefühlt ",m," · 💨 ",Math.round(v.wind_speed_10m)," km/h",a?` · ${a}`:"",h&&x.jsx("span",{className:"ml-1",style:{color:"var(--accent-red, #ef4444)"},children:"!"})]})]})]}),o&&w.length>0&&x.jsx("div",{className:"flex flex-col gap-1.5 flex-1 min-h-0 justify-around",children:w.map(k=>{const P=(k.min-C)/A*100,M=(k.max-k.min)/A*100;return x.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[x.jsx("span",{className:"text-xs font-semibold shrink-0 w-7",style:{color:"var(--text-secondary)"},children:k.day}),x.jsxs("span",{className:"text-xs shrink-0 w-7 text-right tabular-nums",style:{color:"var(--text-secondary)"},children:[k.min,"°"]}),x.jsxs("div",{className:"flex-1 relative h-4 min-w-0",children:[x.jsx("div",{className:"absolute inset-y-0 left-0 right-0 rounded-full opacity-15",style:{background:"var(--text-secondary)"}}),x.jsx("div",{className:"absolute inset-y-0 rounded-full",style:{left:`${P}%`,width:`${Math.max(M,4)}%`,background:"linear-gradient(to right, #06b6d4, #3b82f6)"}})]}),x.jsxs("span",{className:"text-xs font-semibold shrink-0 w-7 tabular-nums",style:{color:"var(--text-primary)"},children:[k.max,"°"]})]},k.day)})})]})}function wm(e,t,r,n){const a=n*Math.PI/180;return{x:e+r*Math.cos(a),y:t+r*Math.sin(a)}}function fh(e,t,r,n,a){const i=wm(e,t,r,n),o=wm(e,t,r,a),s=a-n>180?1:0;return`M ${i.x} ${i.y} A ${r} ${r} 0 ${s} 1 ${o.x} ${o.y}`}function PD(e,t,r){return-180+(Math.max(t,Math.min(r,e))-t)/(r-t)*180}function DD({value:e,min:t,max:r,unit:n,decimals:a,colorZones:i,greenMax:o,yellowMax:s,showMinMax:l,scale:u=1}){const p=PD(o,t,r),v=PD(s,t,r),g=PD(e,t,r);let y="var(--accent)";i&&(e<=o?y="#10b981":e<=s?y="#f59e0b":y="#ef4444");const b=wm(100,100,72,g),w=isNaN(e)?"–":a===0?String(Math.round(e)):e.toFixed(a);return x.jsxs("svg",{viewBox:"0 0 200 120",style:{width:200*u,height:120*u,display:"block"},children:[x.jsx("path",{d:fh(100,100,80,-180,0),fill:"none",stroke:"var(--app-border)",strokeWidth:12,strokeLinecap:"round"}),i?x.jsxs(x.Fragment,{children:[x.jsx("path",{d:fh(100,100,80,-180,p),fill:"none",stroke:"#10b981",strokeWidth:12,strokeLinecap:"round"}),x.jsx("path",{d:fh(100,100,80,p,v),fill:"none",stroke:"#f59e0b",strokeWidth:12,strokeLinecap:"round"}),x.jsx("path",{d:fh(100,100,80,v,0),fill:"none",stroke:"#ef4444",strokeWidth:12,strokeLinecap:"round"}),x.jsx("path",{d:fh(100,100,80,-180,g),fill:"none",stroke:y,strokeWidth:14,strokeLinecap:"round",opacity:"0.4"})]}):x.jsx("path",{d:fh(100,100,80,-180,g),fill:"none",stroke:"var(--accent)",strokeWidth:12,strokeLinecap:"round"}),x.jsx("line",{x1:100,y1:100,x2:b.x,y2:b.y,stroke:y,strokeWidth:2.5,strokeLinecap:"round"}),x.jsx("circle",{cx:100,cy:100,r:5,fill:y}),x.jsxs("text",{x:100,y:118,textAnchor:"middle",fontSize:22,fontWeight:"bold",fill:"var(--text-primary)",children:[w,n&&x.jsx("tspan",{fontSize:13,fill:"var(--text-secondary)",dx:2,children:n})]}),l&&(()=>{const _=wm(100,100,94,-180),S=wm(100,100,94,0);return x.jsxs(x.Fragment,{children:[x.jsx("text",{x:_.x+2,y:_.y+4,fontSize:9,fill:"var(--text-secondary)",textAnchor:"start",children:t}),x.jsx("text",{x:S.x-2,y:S.y+4,fontSize:9,fill:"var(--text-secondary)",textAnchor:"end",children:r})]})})()]})}function ldt({config:e}){const{value:t}=zu(e.datapoint),r=e.options??{},n=e.layout??"default",a=r.minValue??0,i=r.maxValue??100,o=r.unit??"",s=r.decimals??1,l=r.colorZones??!1,u=i-a,c=r.greenMax??a+u*.33,f=r.yellowMax??a+u*.66,d=r.showMinMax??!0,h=typeof t=="number"?t:parseFloat(String(t??0)),p={value:isNaN(h)?a:h,min:a,max:i,unit:o,decimals:s,colorZones:l,greenMax:c,yellowMax:f,showMinMax:d};return n==="minimal"?x.jsx("div",{className:"flex items-center justify-center h-full",children:x.jsx(DD,{...p,scale:.85})}):n==="compact"?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[x.jsx(DD,{...p,scale:.7}),e.title&&x.jsx("p",{className:"text-[11px] truncate text-center",style:{color:"var(--text-secondary)"},children:e.title})]}):x.jsxs("div",{className:"flex flex-col h-full",children:[e.title&&x.jsx("p",{className:"text-xs mb-1 truncate",style:{color:"var(--text-secondary)"},children:e.title}),x.jsx("div",{className:"flex-1 flex items-center justify-center",children:x.jsx(DD,{...p,scale:n==="card"?1:.95})})]})}function udt({config:e,editMode:t}){const r=e.options??{},n=r.streamUrl??"",a=r.refreshInterval??5,i=r.fitMode??"cover",o=r.showTimestamp??!0,s=e.layout??"default",[l,u]=I.useState(""),[c,f]=I.useState(!1),[d,h]=I.useState(null),p=I.useRef(null),v=m=>m?a===0?m:m.includes("?")?`${m}&_t=${Date.now()}`:`${m}?_t=${Date.now()}`:"";I.useEffect(()=>{if(n)return f(!1),u(v(n)),h(new Date),a>0&&(p.current=setInterval(()=>{u(v(n)),h(new Date)},a*1e3)),()=>{p.current&&clearInterval(p.current)}},[n,a]);const g=(s==="default"||s==="card")&&e.title,y=t;return n?x.jsxs("div",{className:"relative h-full w-full overflow-hidden rounded-[inherit]",children:[x.jsx("img",{src:l,alt:e.title||"Kamera",onError:()=>f(!0),onLoad:()=>f(!1),style:{width:"100%",height:"100%",objectFit:i,display:"block"}}),c&&x.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2",style:{background:"rgba(0,0,0,0.6)"},children:[x.jsx(R_,{size:28,style:{color:"#ef4444"}}),x.jsx("p",{className:"text-xs text-white opacity-80",children:"Verbindungsfehler"})]}),g&&!c&&x.jsx("div",{className:"absolute bottom-0 left-0 right-0 px-2 py-1.5",style:{background:"rgba(0,0,0,0.55)"},children:x.jsx("p",{className:"text-xs font-medium text-white truncate",children:e.title})}),o&&d&&!c&&x.jsx("div",{className:"absolute bottom-1 right-1 px-1.5 py-0.5 rounded text-[9px] font-mono",style:{background:"rgba(0,0,0,0.5)",color:"rgba(255,255,255,0.8)"},children:d.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit",second:"2-digit"})}),y&&x.jsx("div",{className:"absolute top-1 left-1 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase",style:{background:a===0?"#ef4444":"rgba(0,0,0,0.6)",color:"#fff"},children:a===0?"LIVE":"CAM"})]}):x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2",style:{background:"var(--app-bg)",borderRadius:"var(--widget-radius)"},children:[x.jsx(R_,{size:32,style:{color:"var(--text-secondary)"}}),x.jsxs("p",{className:"text-xs text-center",style:{color:"var(--text-secondary)"},children:[e.title||"Kamera",x.jsx("br",{}),x.jsx("span",{className:"text-[10px] opacity-60",children:"Keine URL konfiguriert"})]})]})}const cdt=[];function fdt(){return{switch:Lwe,value:Iwe,dimmer:jwe,thermostat:Rwe,chart:rWe,list:nWe,clock:sWe,calendar:pWe,header:vWe,group:xWe,echart:Xft,evcc:adt,weather:sdt,gauge:ldt,camera:udt}}const Ice=[{id:"default",label:"Standard"},{id:"card",label:"Karte"},{id:"compact",label:"Kompakt"},{id:"minimal",label:"Minimal"}],ddt=[...Ice,{id:"agenda",label:"Agenda"}],hdt=[{label:"5 Min",value:5},{label:"15 Min",value:15},{label:"30 Min",value:30},{label:"1 Std",value:60},{label:"6 Std",value:360},{label:"24 Std",value:1440}],dy="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",dh={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};function pdt({config:e,onConfigChange:t}){const r=e.options??{},n=MO(r),[a,i]=I.useState(!1),[o,s]=I.useState(""),[l,u]=I.useState(""),[c,f]=I.useState(Ay[n.length%Ay.length]),d=g=>t({...e,options:{...r,...g}}),h=(g,y)=>d({calendars:n.map(m=>m.id===g?{...m,...y}:m)}),p=g=>d({calendars:n.filter(y=>y.id!==g)}),v=()=>{if(!o.trim())return;const g={id:Date.now().toString(),url:o.trim(),name:l.trim()||"Kalender",color:c,showName:!0};d({calendars:[...n,g]}),s(""),u(""),f(Ay[(n.length+1)%Ay.length]),i(!1)};return x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"space-y-1.5",children:n.map(g=>x.jsxs("div",{className:"rounded-lg p-2 space-y-1.5",style:{background:"var(--app-bg)",border:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("input",{type:"color",value:g.color,onChange:y=>h(g.id,{color:y.target.value}),className:"w-5 h-5 rounded cursor-pointer border-0 p-0 shrink-0",title:"Farbe ändern"}),x.jsx("input",{type:"text",value:g.name,onChange:y=>h(g.id,{name:y.target.value}),className:"flex-1 text-xs rounded px-2 py-1 focus:outline-none min-w-0",style:dh,placeholder:"Kalender-Name"}),x.jsx("button",{onClick:()=>h(g.id,{showName:!g.showName}),className:"relative w-7 h-4 rounded-full transition-colors shrink-0",style:{background:g.showName?g.color:"var(--app-border)"},title:"Name anzeigen",children:x.jsx("span",{className:"absolute top-0.5 w-3 h-3 bg-white rounded-full shadow transition-transform",style:{left:g.showName?"14px":"2px"}})}),x.jsx("button",{onClick:()=>p(g.id),className:"hover:opacity-70 shrink-0",style:{color:"var(--accent-red)"},children:x.jsx(fs,{size:12})})]}),x.jsx("p",{className:"text-[9px] font-mono truncate",style:{color:"var(--text-secondary)"},children:g.url})]},g.id))}),a?x.jsxs("div",{className:"rounded-lg p-2 space-y-1.5",style:{background:"var(--app-bg)",border:"1px solid var(--app-border)"},children:[x.jsx("input",{type:"url",value:o,onChange:g=>s(g.target.value),placeholder:"iCal-URL…",autoFocus:!0,className:dy+" font-mono",style:dh}),x.jsxs("div",{className:"flex gap-1.5",children:[x.jsx("input",{type:"color",value:c,onChange:g=>f(g.target.value),className:"w-8 h-8 rounded cursor-pointer border-0 p-0 shrink-0"}),x.jsx("input",{type:"text",value:l,onChange:g=>u(g.target.value),placeholder:"Name (optional)",className:dy,style:dh})]}),x.jsxs("div",{className:"flex gap-1.5",children:[x.jsx("button",{onClick:v,disabled:!o.trim(),className:"flex-1 py-1.5 text-xs rounded-lg text-white hover:opacity-80 disabled:opacity-30",style:{background:"var(--accent)"},children:"Hinzufügen"}),x.jsx("button",{onClick:()=>{i(!1),s(""),u("")},className:"px-3 py-1.5 text-xs rounded-lg hover:opacity-80",style:{background:"var(--app-surface)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"✕"})]})]}):x.jsxs("button",{onClick:()=>i(!0),className:"w-full flex items-center justify-center gap-1.5 py-2 text-xs rounded-lg hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px dashed var(--app-border)"},children:[x.jsx(cs,{size:12})," Kalender hinzufügen"]}),x.jsx("div",{className:"h-px",style:{background:"var(--app-border)"}}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Aktualisierungsintervall"}),x.jsx("select",{value:r.refreshInterval??30,onChange:g=>d({refreshInterval:Number(g.target.value)}),className:dy,style:dh,children:hdt.map(g=>x.jsx("option",{value:g.value,children:g.label},g.value))})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Tage im Voraus"}),x.jsx("input",{type:"number",min:1,max:365,value:r.daysAhead??14,onChange:g=>d({daysAhead:Number(g.target.value)}),className:dy,style:dh})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Max. Einträge"}),x.jsx("input",{type:"number",min:1,max:20,value:r.maxEvents??5,onChange:g=>d({maxEvents:Number(g.target.value)}),className:dy,style:dh})]})]})}const vdt=[{key:"bg",label:"Hintergrund",type:"color"},{key:"accent",label:"Akzentfarbe",type:"color"},{key:"textPrimary",label:"Text",type:"color"},{key:"textSecondary",label:"Text sekundär",type:"color"},{key:"radius",label:"Eckenradius",type:"text"}],gdt=["1h","6h","24h","7d","30d"];function ydt({config:e,onConfigChange:t}){const[r,n]=I.useState([]),[a,i]=I.useState(!1),o=e.datapoint,s=e.options??{},l=f=>t({...e,options:{...s,...f}});I.useEffect(()=>{if(!o){n([]);return}i(!0),W_(o).then(f=>{var h;const d=(h=f==null?void 0:f.common)==null?void 0:h.custom;n(d?q_(d):[]),i(!1)}).catch(()=>i(!1))},[o]);const u=s.historyInstance,c=s.historyRange??"24h";return x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"h-px my-1",style:{background:"var(--app-border)"}}),x.jsx("p",{className:"text-[11px] font-semibold mb-1.5",style:{color:"var(--text-secondary)"},children:"Verlaufsdaten"}),a&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Prüfe Adapter…"}),!a&&r.length===0&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Kein History-Adapter aktiv für diesen Datenpunkt."}),!a&&r.length>0&&x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Adapter-Instanz"}),x.jsxs("select",{value:u??"",onChange:f=>l({historyInstance:f.target.value||void 0}),className:"w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"},children:[x.jsx("option",{value:"",children:"– Live-Daten (kein Verlauf) –"}),r.map(f=>x.jsx("option",{value:f.instance,children:f.label},f.instance))]})]}),u&&x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Zeitraum"}),x.jsx("div",{className:"flex gap-1 flex-wrap",children:gdt.map(f=>x.jsx("button",{onClick:()=>l({historyRange:f}),className:"flex-1 text-[11px] py-1 rounded-md transition-opacity hover:opacity-80",style:{background:c===f?"var(--accent)":"var(--app-bg)",color:c===f?"#fff":"var(--text-secondary)",border:`1px solid ${c===f?"var(--accent)":"var(--app-border)"}`,minWidth:36},children:jR[f]},f))})]})]})}const Oo={id:null,close:null};function mdt(e,t){var r;Oo.id&&Oo.id!==e&&((r=Oo.close)==null||r.call(Oo)),Oo.id=e,Oo.close=t}function VX(e){Oo.id===e&&(Oo.id=null,Oo.close=null)}function hy({anchorRef:e,onClose:t,children:r}){const n=I.useRef(null),[a,i]=I.useState(null);return I.useEffect(()=>{if(e.current){const o=e.current.getBoundingClientRect();i({top:o.bottom+4,left:o.right})}},[e]),I.useEffect(()=>{if(!a||!n.current||!e.current)return;const o=n.current.getBoundingClientRect(),s=e.current.getBoundingClientRect(),l=window.innerWidth,u=window.innerHeight,c=4;let f=s.right-o.width;f<c&&(f=c),f+o.width>l-c&&(f=l-c-o.width);let d=s.bottom+c;d+o.height>u-c&&(d=s.top-o.height-c),d<c&&(d=c),i({top:d,left:f})},[a==null?void 0:a.top,a==null?void 0:a.left]),I.useEffect(()=>{const o=s=>{e.current&&!e.current.contains(s.target)&&t()};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[e,t]),Xu.createPortal(x.jsx("div",{ref:n,className:"fixed z-[9999] rounded-lg shadow-2xl",style:{top:(a==null?void 0:a.top)??-9999,left:(a==null?void 0:a.left)??-9999,background:"var(--app-surface)",border:"1px solid var(--app-border)",visibility:a?"visible":"hidden"},onMouseDown:o=>o.stopPropagation(),children:r}),document.body)}function $y({config:e,editMode:t,onRemove:r,onConfigChange:n}){var _,S,C,T;const[a,i]=I.useState(null),[o,s]=I.useState(!1),l=((_=e.options)==null?void 0:_.conditions)??cdt,u=Nwe(l);I.useEffect(()=>()=>{VX(e.id),Dwe(e.id)},[e.id]),I.useLayoutEffect(()=>{Pwe(e.id,!t&&u.hidden,u.reflow)},[e.id,t,u.hidden,u.reflow]);const c=A=>{A===null?(i(null),VX(e.id)):(mdt(e.id,()=>i(null)),i(A))},[f,d]=I.useState(null),h=I.useRef(null),p=fdt()[e.type],v=e.layout??"default",g=(S=e.options)==null?void 0:S.styleOverride,y=Object.fromEntries(Object.entries({"--widget-bg":g==null?void 0:g.bg,"--widget-border":g==null?void 0:g.border,"--widget-radius":g==null?void 0:g.radius,"--text-primary":g==null?void 0:g.textPrimary,"--text-secondary":g==null?void 0:g.textSecondary,"--accent":g==null?void 0:g.accent,...u.cssVars}).filter(([,A])=>A!==void 0&&A!=="")),m=A=>A.stopPropagation(),b=e.type==="header",w=e.type==="group";return x.jsxs("div",{style:b?{background:"transparent",borderRadius:0,boxShadow:"none",borderWidth:0,...y,...!t&&u.hidden&&!u.reflow?{visibility:"hidden",pointerEvents:"none"}:{}}:{background:"var(--widget-bg)",borderRadius:"var(--widget-radius)",boxShadow:"var(--widget-shadow)",borderWidth:"var(--widget-border-width)",borderStyle:"solid",borderColor:"var(--widget-border)",...y,...!t&&u.hidden&&!u.reflow?{visibility:"hidden",pointerEvents:"none"}:{}},className:`relative h-full transition-all overflow-visible ${b?"px-2 py-0":w?"p-0":"p-4"} ${t?"ring-2 ring-accent/40 rounded-xl":""} ${!t&&u.effect==="pulse"?"animate-pulse":""} ${!t&&u.effect==="blink"?"animate-[blink_1s_step-end_infinite]":""}`,children:[t&&u.hidden&&x.jsx("div",{className:"nodrag absolute inset-0 z-20 rounded-[inherit] flex items-start justify-end pointer-events-none p-1.5",children:x.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded-md text-[11px] font-medium opacity-70",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:[x.jsx(Jj,{size:11}),"Versteckt"]})}),t&&x.jsx("div",{className:"nodrag absolute top-1.5 right-1.5 z-10",onMouseDown:m,onPointerDown:m,children:x.jsxs("button",{ref:h,onClick:()=>{c(a==="menu"?null:"menu"),s(!1)},className:"w-7 h-7 flex items-center justify-center rounded-lg transition-opacity hover:opacity-80 relative",style:{background:a?"var(--accent)":"var(--app-bg)",color:a?"#fff":"var(--text-secondary)",border:"1px solid var(--app-border)"},title:"Widget-Optionen",children:[x.jsx(Us,{size:13}),l.length>0&&!a&&x.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 rounded-full",style:{background:"var(--accent)"}})]})}),t&&v!=="default"&&x.jsx("div",{className:"nodrag absolute bottom-1.5 left-2 text-[10px] pointer-events-none opacity-40",style:{color:"var(--text-secondary)"},children:v}),x.jsx(p,{config:e,editMode:t,onConfigChange:n}),a==="menu"&&h.current&&x.jsx(hy,{anchorRef:h,onClose:()=>c(null),children:x.jsxs("div",{className:"p-1 flex flex-col gap-0.5 min-w-[170px]",onMouseLeave:()=>c(null),children:[x.jsxs("button",{onClick:()=>{c("edit"),s(!1)},className:"flex items-center gap-2.5 px-3 py-2 text-sm rounded-md text-left hover:opacity-80 transition-opacity",style:{color:"var(--text-primary)"},children:[x.jsx(Tf,{size:13,style:{color:"var(--text-secondary)",flexShrink:0}}),"Bearbeiten"]}),!w&&x.jsxs("button",{onClick:()=>{c("layout"),s(!1)},className:"flex items-center gap-2.5 px-3 py-2 text-sm rounded-md text-left hover:opacity-80 transition-opacity",style:{color:"var(--text-primary)"},children:[x.jsx(Kge,{size:13,style:{color:"var(--text-secondary)",flexShrink:0}}),"Layout",v!=="default"&&x.jsx("span",{className:"ml-auto text-[11px] capitalize",style:{color:"var(--accent)"},children:v})]}),x.jsxs("button",{onClick:()=>{c("style"),s(!1)},className:"flex items-center gap-2.5 px-3 py-2 text-sm rounded-md text-left hover:opacity-80 transition-opacity",style:{color:"var(--text-primary)"},children:[x.jsx(lJ,{size:13,style:{color:"var(--text-secondary)",flexShrink:0}}),"Stil",g&&Object.keys(g).length>0&&x.jsx("span",{className:"ml-auto text-[11px]",style:{color:"var(--accent)"},children:"angepasst"})]}),x.jsxs("button",{onClick:()=>{c("conditions"),s(!1)},className:"flex items-center gap-2.5 px-3 py-2 text-sm rounded-md text-left hover:opacity-80 transition-opacity",style:{color:"var(--text-primary)"},children:[x.jsx(Eye,{size:13,style:{color:l.length>0?"var(--accent)":"var(--text-secondary)",flexShrink:0}}),"Bedingungen",l.length>0&&x.jsx("span",{className:"ml-auto text-[11px] px-1.5 py-0.5 rounded-full",style:{background:"var(--accent)22",color:"var(--accent)"},children:l.length})]}),x.jsx("div",{className:"h-px my-0.5 mx-1",style:{background:"var(--app-border)"}}),o?x.jsxs("div",{className:"flex gap-1 px-1 pb-1",children:[x.jsx("button",{onClick:()=>r(e.id),className:"flex-1 text-xs py-1.5 rounded-md text-white hover:opacity-80",style:{background:"var(--accent-red)"},children:"Bestätigen"}),x.jsx("button",{onClick:()=>s(!1),className:"px-2 text-xs py-1.5 rounded-md hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"✕"})]}):x.jsxs("button",{onClick:()=>s(!0),className:"flex items-center gap-2.5 px-3 py-2 text-sm rounded-md text-left hover:opacity-80 transition-opacity",style:{color:"var(--accent-red, #ef4444)"},children:[x.jsx(gn,{size:13,style:{flexShrink:0}}),"Löschen"]})]})}),a==="layout"&&h.current&&x.jsx(hy,{anchorRef:h,onClose:()=>c(null),children:x.jsxs("div",{className:"p-1.5 flex flex-col gap-0.5 min-w-[120px]",children:[(e.type==="calendar"?ddt:Ice).map(A=>x.jsxs("button",{onClick:()=>{n({...e,layout:A.id}),c(null)},className:"px-3 py-2 text-sm text-left rounded-md transition-opacity hover:opacity-80 flex items-center justify-between gap-4",style:{background:v===A.id?"var(--accent)22":"transparent",color:v===A.id?"var(--accent)":"var(--text-primary)"},children:[A.label,v===A.id&&x.jsx("span",{children:"✓"})]},A.id)),v==="default"&&(()=>{var D,E;const A=["tl","tc","tr","cl","cc","cr","bl","bc","br"],k=(D=e.options)==null?void 0:D.contentPosition,P=(E=e.options)==null?void 0:E.titlePosition;function M({value:L,onChange:N}){return x.jsx("div",{className:"grid grid-cols-3 gap-1 px-2 pb-2",children:A.map(j=>{const R=L===j;return x.jsx("button",{onClick:z=>{z.stopPropagation(),N(R?void 0:j)},className:"w-6 h-6 rounded transition-opacity hover:opacity-80",style:{background:R?"var(--accent)":"var(--app-bg)",border:`1px solid ${R?"var(--accent)":"var(--app-border)"}`},title:j},j)})})}return x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"h-px my-1 mx-1",style:{background:"var(--app-border)"}}),x.jsx("p",{className:"px-3 text-[11px] pb-1",style:{color:"var(--text-secondary)"},children:"Inhalt-Position"}),x.jsx(M,{value:k,onChange:L=>n({...e,options:{...e.options,contentPosition:L}})}),x.jsx("div",{className:"h-px my-1 mx-1",style:{background:"var(--app-border)"}}),x.jsx("p",{className:"px-3 text-[11px] pb-1",style:{color:"var(--text-secondary)"},children:"Titel-Position"}),x.jsx(M,{value:P,onChange:L=>n({...e,options:{...e.options,titlePosition:L}})})]})})()]})}),a==="edit"&&h.current&&x.jsx(hy,{anchorRef:h,onClose:()=>c(null),children:x.jsxs("div",{className:`p-3 ${e.type==="calendar"?"w-80":e.type==="thermostat"?"w-72":e.type==="echart"?"w-[560px]":e.type==="evcc"?"w-80":e.type==="gauge"||e.type==="weather"||e.type==="camera"?"w-72":"w-64"}`,onMouseDown:A=>A.stopPropagation(),children:[x.jsx("p",{className:"text-xs font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Widget bearbeiten"}),x.jsxs("div",{className:"space-y-2.5",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Widget-Typ"}),x.jsxs("select",{value:e.type,onChange:A=>n({...e,type:A.target.value}),className:"w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"},children:[x.jsx("option",{value:"switch",children:"Schalter"}),x.jsx("option",{value:"value",children:"Wert-Anzeige"}),x.jsx("option",{value:"dimmer",children:"Dimmer"}),x.jsx("option",{value:"thermostat",children:"Thermostat"}),x.jsx("option",{value:"chart",children:"Diagramm"}),x.jsx("option",{value:"list",children:"Gruppenliste"}),x.jsx("option",{value:"calendar",children:"Kalender"}),x.jsx("option",{value:"header",children:"Abschnittstitel"}),x.jsx("option",{value:"group",children:"Gruppe"}),x.jsx("option",{value:"echart",children:"EChart"}),x.jsx("option",{value:"evcc",children:"evcc"}),x.jsx("option",{value:"weather",children:"Wetter"}),x.jsx("option",{value:"gauge",children:"Gauge"}),x.jsx("option",{value:"camera",children:"Kamera"})]})]}),e.type==="header"&&(()=>{const A=e.options??{},k=P=>n({...e,options:{...A,...P}});return x.jsxs(x.Fragment,{children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Untertitel (optional)"}),x.jsx("input",{type:"text",value:A.subtitle??"",onChange:P=>k({subtitle:P.target.value||void 0}),placeholder:"z.B. Erdgeschoss",className:"w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Stil"}),x.jsxs("select",{value:e.layout??"default",onChange:P=>n({...e,layout:P.target.value}),className:"w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"},children:[x.jsx("option",{value:"default",children:"Standard (Akzentlinie + Titel)"}),x.jsx("option",{value:"compact",children:"Kompakt (Linie links)"}),x.jsx("option",{value:"minimal",children:"Minimal (Trennlinie + Text)"})]})]})]})})(),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Name"}),x.jsx("input",{type:"text",value:e.title,onChange:A=>n({...e,title:A.target.value}),className:"w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]}),e.type==="clock"&&(()=>{const A=e.options??{},k=E=>n({...e,options:{...A,...E}}),P=A.display??"time",M="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",D={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};return x.jsxs(x.Fragment,{children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Anzeige"}),x.jsxs("select",{value:P,onChange:E=>k({display:E.target.value}),className:M,style:D,children:[x.jsx("option",{value:"time",children:"Nur Uhrzeit"}),x.jsx("option",{value:"datetime",children:"Uhrzeit + Datum"}),x.jsx("option",{value:"date",children:"Nur Datum"})]})]}),P!=="date"&&x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Sekunden anzeigen"}),x.jsx("button",{onClick:()=>k({showSeconds:!A.showSeconds}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:A.showSeconds?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:A.showSeconds?"18px":"2px"}})})]}),P!=="time"&&x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Datumsformat"}),x.jsxs("select",{value:A.dateLength??"short",onChange:E=>k({dateLength:E.target.value}),className:M,style:D,children:[x.jsx("option",{value:"short",children:"Kurz (07.04.2026)"}),x.jsx("option",{value:"long",children:"Lang (Montag, 7. April 2026)"})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Eigenes Format"}),x.jsx("input",{type:"text",value:A.customFormat??"",onChange:E=>k({customFormat:E.target.value||void 0}),placeholder:"z.B. dd.MM.yyyy HH:mm",className:M+" font-mono",style:D}),x.jsx("p",{className:"text-[10px] mt-1 leading-tight",style:{color:"var(--text-secondary)"},children:"Tokens: HH mm ss dd MM yyyy EEEE MMMM"})]})]})})(),e.type==="calendar"&&x.jsx(pdt,{config:e,onConfigChange:n}),e.type!=="list"&&e.type!=="clock"&&e.type!=="calendar"&&e.type!=="header"&&e.type!=="group"&&e.type!=="evcc"&&e.type!=="echart"&&e.type!=="weather"&&e.type!=="camera"&&x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Datenpunkt-ID"}),x.jsxs("div",{className:"flex gap-1",children:[x.jsx("input",{type:"text",value:e.datapoint,onChange:A=>n({...e,datapoint:A.target.value}),className:"flex-1 text-xs rounded-lg px-2.5 py-2 font-mono focus:outline-none min-w-0",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),x.jsx("button",{onClick:()=>d("datapoint"),className:"px-2 rounded-lg hover:opacity-80 shrink-0",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},title:"Aus ioBroker wählen",children:x.jsx(sl,{size:13})})]})]}),(e.type==="value"||e.type==="chart")&&x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Einheit"}),x.jsx("input",{type:"text",value:((C=e.options)==null?void 0:C.unit)??"",onChange:A=>n({...e,options:{...e.options,unit:A.target.value||void 0}}),placeholder:"z.B. °C, %, W",className:"w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]}),e.type==="chart"&&x.jsx(ydt,{config:e,onConfigChange:n}),e.type==="echart"&&x.jsx(Zft,{config:e,onConfigChange:n}),e.type==="evcc"&&x.jsx(idt,{config:e,onConfigChange:n}),e.type==="gauge"&&(()=>{const A=e.options??{},k=j=>n({...e,options:{...A,...j}}),P=A.minValue??0,M=A.maxValue??100,D=A.colorZones??!1,E=M-P,L="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",N={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"flex gap-2",children:[x.jsxs("div",{className:"flex-1",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Min"}),x.jsx("input",{type:"number",value:P,onChange:j=>k({minValue:Number(j.target.value)}),className:L,style:N})]}),x.jsxs("div",{className:"flex-1",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Max"}),x.jsx("input",{type:"number",value:M,onChange:j=>k({maxValue:Number(j.target.value)}),className:L,style:N})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Einheit"}),x.jsx("input",{type:"text",value:A.unit??"",onChange:j=>k({unit:j.target.value||void 0}),placeholder:"z.B. °C, %, W",className:L,style:N})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Dezimalstellen"}),x.jsx("input",{type:"number",min:0,max:4,value:A.decimals??1,onChange:j=>k({decimals:Number(j.target.value)}),className:L,style:N})]}),x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Farbzonen"}),x.jsx("button",{onClick:()=>k({colorZones:!D}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:D?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:D?"18px":"2px"}})})]}),D&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Grün bis"}),x.jsx("input",{type:"number",value:A.greenMax??P+E*.33,onChange:j=>k({greenMax:Number(j.target.value)}),className:L,style:N})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Gelb bis"}),x.jsx("input",{type:"number",value:A.yellowMax??P+E*.66,onChange:j=>k({yellowMax:Number(j.target.value)}),className:L,style:N})]})]}),x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Min/Max anzeigen"}),x.jsx("button",{onClick:()=>k({showMinMax:!(A.showMinMax??!0)}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:A.showMinMax??!0?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:A.showMinMax??!0?"18px":"2px"}})})]})]})})(),e.type==="weather"&&(()=>{const A=e.options??{},k=D=>n({...e,options:{...A,...D}}),P="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",M={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"flex gap-2",children:[x.jsxs("div",{className:"flex-1",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Breitengrad"}),x.jsx("input",{type:"number",step:.01,value:A.latitude??48.1,onChange:D=>k({latitude:Number(D.target.value)}),className:P,style:M})]}),x.jsxs("div",{className:"flex-1",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Längengrad"}),x.jsx("input",{type:"number",step:.01,value:A.longitude??11.6,onChange:D=>k({longitude:Number(D.target.value)}),className:P,style:M})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Standortname"}),x.jsx("input",{type:"text",value:A.locationName??"",onChange:D=>k({locationName:D.target.value||void 0}),placeholder:"z.B. München",className:P,style:M})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Aktualisierung (Min.)"}),x.jsx("input",{type:"number",min:5,max:1440,value:A.refreshMinutes??30,onChange:D=>k({refreshMinutes:Number(D.target.value)}),className:P,style:M})]}),x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Vorhersage anzeigen"}),x.jsx("button",{onClick:()=>k({showForecast:!(A.showForecast??!0)}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:A.showForecast??!0?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:A.showForecast??!0?"18px":"2px"}})})]})]})})(),e.type==="camera"&&(()=>{const A=e.options??{},k=E=>n({...e,options:{...A,...E}}),P="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",M={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"},D=A.fitMode??"cover";return x.jsxs(x.Fragment,{children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Stream-URL"}),x.jsx("input",{type:"url",value:A.streamUrl??"",onChange:E=>k({streamUrl:E.target.value||void 0}),placeholder:"http://…/stream.mjpg",className:P+" font-mono",style:M})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Aktualisierung (Sek., 0 = MJPEG)"}),x.jsx("input",{type:"number",min:0,value:A.refreshInterval??5,onChange:E=>k({refreshInterval:Number(E.target.value)}),className:P,style:M})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Bildanpassung"}),x.jsxs("select",{value:D,onChange:E=>k({fitMode:E.target.value}),className:P,style:M,children:[x.jsx("option",{value:"cover",children:"Cover (ausfüllen)"}),x.jsx("option",{value:"contain",children:"Contain (einpassen)"})]})]}),x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Zeitstempel anzeigen"}),x.jsx("button",{onClick:()=>k({showTimestamp:!(A.showTimestamp??!0)}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:A.showTimestamp??!0?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:A.showTimestamp??!0?"18px":"2px"}})})]})]})})(),e.type==="thermostat"&&(()=>{const A=e.options??{},k=D=>n({...e,options:{...A,...D}}),P="w-full text-xs rounded-lg px-2.5 py-2 focus:outline-none",M={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};return x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("label",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Anklickbar (Detail-Popup)"}),x.jsx("button",{onClick:()=>k({clickable:!(A.clickable??!0)}),className:"relative w-9 h-5 rounded-full transition-colors",style:{background:A.clickable??!0?"var(--accent)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform",style:{left:A.clickable??!0?"18px":"2px"}})})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Ist-Temperatur Datenpunkt"}),x.jsxs("div",{className:"flex gap-1",children:[x.jsx("input",{type:"text",value:A.actualDatapoint??"",onChange:D=>k({actualDatapoint:D.target.value||void 0}),placeholder:"optional",className:"flex-1 text-xs rounded-lg px-2.5 py-2 font-mono focus:outline-none min-w-0",style:M}),x.jsx("button",{onClick:()=>d("actualDatapoint"),className:"px-2 rounded-lg hover:opacity-80 shrink-0",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},title:"Aus ioBroker wählen",children:x.jsx(sl,{size:13})})]})]}),x.jsxs("div",{className:"flex gap-2",children:[x.jsxs("div",{className:"flex-1",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Min °C"}),x.jsx("input",{type:"number",min:0,max:30,step:1,value:A.minTemp??10,onChange:D=>k({minTemp:Number(D.target.value)}),className:P,style:M})]}),x.jsxs("div",{className:"flex-1",children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Max °C"}),x.jsx("input",{type:"number",min:10,max:40,step:1,value:A.maxTemp??30,onChange:D=>k({maxTemp:Number(D.target.value)}),className:P,style:M})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Schrittweite"}),x.jsxs("select",{value:A.step??.5,onChange:D=>k({step:Number(D.target.value)}),className:P,style:M,children:[x.jsx("option",{value:.5,children:"0,5 °C"}),x.jsx("option",{value:1,children:"1 °C"}),x.jsx("option",{value:.1,children:"0,1 °C"})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Schnellwahl (kommagetrennt)"}),x.jsx("input",{type:"text",value:(A.presets??[18,20,22,24]).join(", "),onChange:D=>{const E=D.target.value.split(",").map(L=>parseFloat(L.trim())).filter(L=>!isNaN(L));k({presets:E.length?E:void 0})},placeholder:"18, 20, 22, 24",className:P,style:M})]})]})})()]})]})}),f&&x.jsx(Av,{currentValue:f==="datapoint"?e.datapoint:((T=e.options)==null?void 0:T.actualDatapoint)??"",onSelect:A=>{n(f==="datapoint"?{...e,datapoint:A}:{...e,options:{...e.options,actualDatapoint:A}})},onClose:()=>d(null)}),a==="style"&&h.current&&x.jsx(hy,{anchorRef:h,onClose:()=>c(null),children:x.jsxs("div",{className:"p-3 w-72",onMouseDown:A=>A.stopPropagation(),children:[x.jsx("p",{className:"text-xs font-semibold mb-2.5",style:{color:"var(--text-primary)"},children:"Widget-Stil"}),x.jsx("div",{className:"space-y-2",children:vdt.map(({key:A,label:k,type:P})=>x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("label",{className:"text-xs w-24 shrink-0",style:{color:"var(--text-secondary)"},children:k}),P==="color"?x.jsxs("div",{className:"flex gap-1 flex-1",children:[x.jsx("input",{type:"color",value:(g==null?void 0:g[A])??"#3b82f6",onChange:M=>n({...e,options:{...e.options,styleOverride:{...g,[A]:M.target.value}}}),className:"w-7 h-6 rounded cursor-pointer border-0 p-0 shrink-0"}),x.jsx("input",{type:"text",value:(g==null?void 0:g[A])??"",onChange:M=>{const D=M.target.value,E={...g,[A]:D};D||delete E[A],n({...e,options:{...e.options,styleOverride:Object.keys(E).length?E:void 0}})},placeholder:"auto",className:"flex-1 text-xs rounded px-1.5 py-1 min-w-0 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]}):x.jsx("input",{type:"text",value:(g==null?void 0:g[A])??"",onChange:M=>{const D=M.target.value,E={...g,[A]:D};D||delete E[A],n({...e,options:{...e.options,styleOverride:Object.keys(E).length?E:void 0}})},placeholder:"auto",className:"flex-1 text-xs rounded px-1.5 py-1 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]},A))}),g&&Object.keys(g).length>0&&x.jsx("button",{onClick:()=>{const{styleOverride:A,...k}=e.options??{};n({...e,options:k})},className:"w-full mt-3 py-1.5 text-xs rounded-md hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"Zurücksetzen"})]})}),a==="conditions"&&h.current&&x.jsx(hy,{anchorRef:h,onClose:()=>c(null),children:x.jsx(Swe,{conditions:l,onChange:A=>n({...e,options:{...e.options,conditions:A}})})})]})}const py=10;function jce({readonly:e=!1,editMode:t=!1,onLayoutChange:r,viewTabs:n,viewActiveTabId:a}){const i=Cv(),{updateWidget:o,updateLayouts:s,removeWidget:l}=Ga(),u=co(N=>N.frontend.gridRowHeight??80),c=co(N=>N.frontend.mobileBreakpoint??600),f=n??i.tabs,d=a??i.activeTabId,h=f.find(N=>N.id===d),p=(h==null?void 0:h.widgets)??[],v=Ewe(),g=I.useRef(null),[y,m]=I.useState(0);I.useEffect(()=>{const N=g.current;if(!N)return;m(N.clientWidth);const j=new ResizeObserver(([R])=>{m(Math.floor(R.contentRect.width))});return j.observe(N),()=>j.disconnect()},[]);const[b,w]=I.useState(0);I.useEffect(()=>{t&&y>0&&w(N=>Math.max(N,y)),t||w(0)},[t,y]);const _=t&&b>0?b:y,S=_>0?Math.max(2,Math.floor((_-py)/(u+py))):12,C=I.useRef(null),T=I.useRef(u),A=I.useRef(p);A.current=p;const k=I.useRef(s);k.current=s,I.useEffect(()=>{if(C.current===null){C.current=S,T.current=u;return}const N=C.current,j=T.current;if(!e&&j!==u&&N>0){const R=A.current;if(R.length>0){const z=R.map(B=>({...B,gridPos:{...B.gridPos,x:Math.min(Math.round(B.gridPos.x*S/N),S-1),w:Math.max(1,Math.round(B.gridPos.w*S/N))}}));k.current(z)}}C.current=S,T.current=u},[S,u]);const P=p.filter(N=>!v.has(N.id)),M=P.map(N=>({i:N.id,x:Math.min(N.gridPos.x,S-1),y:N.gridPos.y,w:Math.min(N.gridPos.w,S),h:N.gridPos.h})),D=I.useCallback(N=>p.map(j=>{if(v.has(j.id))return j;const R=N.find(z=>z.i===j.id);return R?{...j,gridPos:{x:R.x,y:R.y,w:R.w,h:R.h}}:j}),[p,v]),E=I.useCallback(N=>{r==null||r(D(N))},[D,r]),L=I.useCallback(N=>{e||s(D(N))},[e,D,s]);if(y>0&&y<c){const N=[...p].filter(j=>!v.has(j.id)).sort((j,R)=>{const z=j.mobileOrder??j.gridPos.y*1e3+j.gridPos.x,B=R.mobileOrder??R.gridPos.y*1e3+R.gridPos.x;return z-B});return x.jsxs("div",{ref:g,className:"flex-1 overflow-auto p-2",children:[x.jsx("div",{style:{position:"fixed",top:-9999,left:-9999,width:1,height:1,overflow:"hidden",pointerEvents:"none",opacity:0},children:p.filter(j=>v.has(j.id)).map(j=>x.jsx($y,{config:j,editMode:!1,onRemove:l,onConfigChange:R=>o(R.id,R)},j.id))}),x.jsx("div",{className:"flex flex-col gap-2.5",children:N.map(j=>x.jsx("div",{style:{height:j.gridPos.h*u+(j.gridPos.h-1)*py},children:x.jsx($y,{config:j,editMode:!1,onRemove:l,onConfigChange:R=>o(R.id,R)})},j.id))})]})}return p.length===0?x.jsx("div",{className:"flex flex-col items-center justify-center flex-1 h-64 space-y-2",style:{color:"var(--text-secondary)"},children:x.jsx("p",{children:e?"Keine Widgets konfiguriert.":'Noch keine Widgets – über "+ Geräte" hinzufügen.'})}):x.jsx("div",{ref:g,className:"flex-1 overflow-auto p-2 sm:p-4",style:t&&_>y?{overflowX:"auto"}:void 0,children:_>0&&x.jsxs(x.Fragment,{children:[x.jsx("div",{style:{position:"fixed",top:-9999,left:-9999,width:1,height:1,overflow:"hidden",pointerEvents:"none",opacity:0},children:p.filter(N=>v.has(N.id)).map(N=>x.jsx($y,{config:N,editMode:!1,onRemove:l,onConfigChange:j=>o(j.id,j)},N.id))}),x.jsx(EQ,{className:"layout",layout:M,cols:S,rowHeight:u,width:_,isDraggable:t,isResizable:t,draggableCancel:".nodrag",onLayoutChange:E,onDragStop:L,onResizeStop:L,margin:[py,py],containerPadding:[0,0],children:P.map(N=>x.jsx("div",{children:x.jsx($y,{config:N,editMode:t,onRemove:l,onConfigChange:j=>o(j.id,j)})},N.id))})]})})}function xdt({readonly:e=!1,viewTabs:t,viewActiveTabId:r,onViewTabClick:n,layoutUrlBase:a=""}){const i=Cv(),{setActiveTab:o,addTab:s,removeTab:l,renameTab:u}=Ga(),c=t??i.tabs,f=r??i.activeTabId,[d,h]=I.useState(null),[p,v]=I.useState(""),g=I.useRef(null),y=gv();I.useEffect(()=>{d&&g.current&&(g.current.focus(),g.current.select())},[d]);const m=()=>{d&&p.trim()&&u(d,p.trim()),h(null)},b=w=>{if(e){const _=c.find(S=>S.id===w);if(!_)return;n?n(_):y(`${a}/tab/${_.slug??_.id}`)}else o(w)};return c.length<=1&&e?null:x.jsxs("div",{className:"flex items-center gap-1 px-4 overflow-x-auto shrink-0",style:{background:"var(--app-surface)",borderBottom:"1px solid var(--app-border)"},children:[c.map(w=>{const _=w.id===f;return x.jsxs("div",{className:"group flex items-center gap-1.5 px-3 py-2.5 text-sm cursor-pointer border-b-2 transition-colors whitespace-nowrap",style:{borderBottomColor:_?"var(--accent)":"transparent",color:_?"var(--accent)":"var(--text-secondary)"},onClick:()=>b(w.id),children:[!e&&d===w.id?x.jsx("input",{ref:g,value:p,onChange:S=>v(S.target.value),onBlur:m,onKeyDown:S=>{S.key==="Enter"&&m(),S.key==="Escape"&&h(null)},onClick:S=>S.stopPropagation(),className:"w-24 text-sm rounded px-1.5 py-0.5 focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--accent)"}}):x.jsx("span",{onDoubleClick:S=>{e||(S.stopPropagation(),h(w.id),v(w.name))},children:w.name}),!e&&c.length>1&&x.jsx("button",{onClick:S=>{S.stopPropagation(),l(w.id)},className:"opacity-0 group-hover:opacity-100 w-4 h-4 flex items-center justify-center rounded-full text-xs transition-all hover:opacity-80",style:{background:"var(--accent-red)",color:"#fff"},children:"✕"})]},w.id)}),!e&&x.jsx("button",{onClick:()=>s(`Tab ${c.length+1}`),className:"px-3 py-2.5 text-sm transition-colors whitespace-nowrap hover:opacity-80",style:{color:"var(--text-secondary)"},children:"+ Tab"})]})}const WX={"aura-dashboard":()=>Ga.persist.rehydrate(),"aura-theme":()=>Tv.persist.rehydrate(),"aura-groups":()=>qu.persist.rehydrate(),"aura-config":()=>co.persist.rehydrate()};function bdt(){const{connected:e}=Vn();return x.jsxs("div",{className:"flex items-center gap-2 px-3 py-1 rounded-full text-sm font-medium",style:{background:e?"var(--accent-green)22":"var(--accent-red)22",color:e?"var(--accent-green)":"var(--accent-red)"},children:[x.jsx("span",{className:`w-2 h-2 rounded-full ${e?"animate-pulse":""}`,style:{background:e?"var(--accent-green)":"var(--accent-red)"}}),e?"Verbunden":"Getrennt"]})}function Cw(){const{tabSlug:e,layoutSlug:t}=qpe(),r=gv(),{frontend:n}=co(),{themeId:a,setTheme:i}=Tv(),o=zT(a),{subscribe:s,setState:l}=Vn(),u=I.useRef(null),c=Nxe(t),f=(c==null?void 0:c.tabs)??[],[d,h]=I.useState(()=>{var v;return(c==null?void 0:c.activeTabId)??((v=f[0])==null?void 0:v.id)??""});I.useEffect(()=>{var v;h((c==null?void 0:c.activeTabId)??((v=c==null?void 0:c.tabs[0])==null?void 0:v.id)??"")},[c==null?void 0:c.id]),I.useEffect(()=>{const v=g=>{g.key&&WX[g.key]&&WX[g.key]()};return window.addEventListener("storage",v),()=>window.removeEventListener("storage",v)},[]),I.useEffect(()=>{u.current||(u.current=document.createElement("style"),u.current.id="aura-custom-css",document.head.appendChild(u.current)),u.current.textContent=n.customCSS},[n.customCSS]),I.useEffect(()=>{if(!e||!f.length)return;const v=f.find(g=>(g.slug??g.id)===e);v&&v.id!==d&&h(v.id)},[e,c==null?void 0:c.id]),I.useEffect(()=>s("aura.0.navigate.url",v=>{const g=String(v.val??"").trim();if(g){if(g.startsWith("http://")||g.startsWith("https://")||g.startsWith("//"))window.location.href=g;else{const y=f.find(m=>(m.slug??m.id)===g);y&&h(y.id)}l("aura.0.navigate.url","")}}),[s,l,c==null?void 0:c.id]);const p=t?`/view/${t}`:"";return x.jsxs("div",{"data-aura-app":"frontend",className:"min-h-screen flex flex-col",style:{background:"var(--app-bg)",color:"var(--text-primary)"},children:[n.showHeader&&x.jsxs("header",{className:"flex items-center justify-between px-4 sm:px-6 py-4 shrink-0",style:{background:"var(--app-surface)",borderBottom:"1px solid var(--app-border)"},children:[x.jsx("h1",{className:"text-xl font-bold tracking-tight",children:n.headerTitle||"Aura"}),x.jsxs("div",{className:"flex items-center gap-3",children:[n.showConnectionBadge&&x.jsx(bdt,{}),x.jsx("button",{onClick:()=>i(o.dark?"light":"dark"),className:"w-8 h-8 flex items-center justify-center rounded-full hover:opacity-80 transition-opacity",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},title:o.dark?"Hell-Modus":"Dunkel-Modus",children:o.dark?x.jsx(Wm,{size:15}):x.jsx(sJ,{size:15})})]})]}),x.jsx(xdt,{readonly:!0,viewTabs:f,viewActiveTabId:d,onViewTabClick:v=>{const g=v.slug??v.id;r(t?`/view/${t}/tab/${g}`:`/tab/${g}`)},layoutUrlBase:p}),x.jsx(jce,{readonly:!0,viewTabs:f,viewActiveTabId:d})]})}function wdt({children:e}){const{themeId:t,customVars:r}=Tv(),n=co(i=>i.frontend.fontScale??1),a=zT(t);return I.useEffect(()=>{const i=document.documentElement,o={...a.vars,...r};Object.entries(o).forEach(([s,l])=>{l&&i.style.setProperty(s,l)}),i.style.setProperty("--font-scale",String(n)),i.classList.toggle("dark",a.dark)},[a,r,n]),x.jsx(x.Fragment,{children:e})}function Rce(e){let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=t*16777619>>>0;return t.toString(16).padStart(8,"0")}const od=_v()(Sv(e=>({pinHash:null,sessionActive:!1,setPinHash:t=>e({pinHash:t}),setSession:t=>e({sessionActive:t})}),{name:"aura-auth",partialize:e=>({pinHash:e.pinHash,sessionActive:e.sessionActive})}));function _dt(e){const{pinHash:t,setSession:r}=od.getState();return t&&Rce(e)===t?(r(!0),!0):!1}function zce(e){od.getState().setPinHash(Rce(e)),od.getState().setSession(!0)}function Sdt(){od.getState().setSession(!1)}function Cdt(){const[e,t]=I.useState(V4);return I.useEffect(()=>Axe(()=>t(V4())),[]),{dirty:e,save:()=>kxe(),revert:()=>Mxe([()=>Ga.persist.rehydrate(),()=>Tv.persist.rehydrate(),()=>qu.persist.rehydrate(),()=>co.persist.rehydrate()])}}const Tdt=[{to:"/admin",label:"Übersicht",icon:nJ,end:!0},{to:"/admin/editor",label:"Dashboard-Editor",icon:Oye},{to:"/admin/layouts",label:"Layouts",icon:Qj},{to:"/admin/widgets",label:"Widgets",icon:eR},{to:"/admin/theme",label:"Theme & CSS",icon:lJ},{to:"/admin/settings",label:"Einstellungen",icon:Sye}];function Adt(){var i;const e=Cv(),{layouts:t}=Ga(),r=((i=t[0])==null?void 0:i.id)===e.id,n=e.tabs.find(o=>o.id===e.activeTabId)??e.tabs[0],a=(n==null?void 0:n.slug)??(n==null?void 0:n.id)??"";return r?a&&e.tabs.length>1?`#/tab/${a}`:"#/":a&&e.tabs.length>1?`#/view/${e.slug}/tab/${a}`:`#/view/${e.slug}`}function kdt(){const{sessionActive:e}=od(),{dirty:t,save:r,revert:n}=Cdt(),{adminThemeId:a,setAdminTheme:i}=Tv(),o=Adt(),s=a==="dark"?Lxe:zT(a),l=Object.fromEntries(Object.entries(s.vars).map(([u,c])=>[u,c]));return e?x.jsxs("div",{className:"min-h-screen flex",style:{...l,colorScheme:s.dark?"dark":"light",background:s.vars["--app-bg"],color:s.vars["--text-primary"]},children:[x.jsxs("aside",{className:"w-56 shrink-0 flex flex-col h-screen sticky top-0 overflow-y-auto",style:{background:"var(--app-surface)",borderRight:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"px-5 py-5 border-b shrink-0 flex items-center justify-between",style:{borderColor:"var(--app-border)"},children:[x.jsxs("div",{title:"Adaptive Unified Room Automation",children:[x.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest mb-0.5",style:{color:"var(--text-secondary)"},children:"Aura"}),x.jsx("p",{className:"font-bold text-lg",style:{color:"var(--text-primary)"},children:"Admin"})]}),x.jsx("button",{onClick:()=>i(s.dark?"light":"dark"),className:"w-8 h-8 flex items-center justify-center rounded-lg hover:opacity-80 transition-opacity",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},title:s.dark?"Hell-Modus":"Dunkel-Modus",children:s.dark?x.jsx(Wm,{size:15}):x.jsx(sJ,{size:15})})]}),x.jsx("nav",{className:"flex-1 p-3 space-y-1",children:Tdt.map(({to:u,label:c,icon:f,end:d})=>x.jsxs(XZ,{to:u,end:d,className:({isActive:h})=>`flex items-center gap-3 px-3 py-2.5 rounded-xl text-sm font-medium transition-opacity hover:opacity-80 ${h?"opacity-100":"opacity-60"}`,style:({isActive:h})=>({background:h?"var(--accent)22":"transparent",color:h?"var(--accent)":"var(--text-primary)"}),children:[x.jsx(f,{size:17}),c]},u))}),x.jsxs("div",{className:"p-3 space-y-1 border-t",style:{borderColor:"var(--app-border)"},children:[x.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-3 px-3 py-2.5 rounded-xl text-sm font-medium opacity-60 hover:opacity-100 transition-opacity",style:{color:"var(--text-primary)"},children:[x.jsx(JZ,{size:17})," Frontend öffnen"]}),x.jsxs("button",{onClick:Sdt,className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-sm font-medium opacity-60 hover:opacity-100 transition-opacity",style:{color:"var(--accent-red)"},children:[x.jsx(aye,{size:17})," Abmelden"]})]})]}),x.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",style:{background:"var(--app-bg)"},children:[x.jsx("div",{className:"shrink-0 flex items-center justify-end gap-2 px-4 py-2 transition-all",style:{background:t?"var(--accent)11":"var(--app-surface)",borderBottom:`1px solid ${t?"var(--accent)44":"var(--app-border)"}`,minHeight:"44px"},children:t?x.jsxs(x.Fragment,{children:[x.jsx("span",{className:"text-xs mr-auto",style:{color:"var(--accent)"},children:"Ungespeicherte Änderungen"}),x.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium hover:opacity-80 transition-opacity",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:[x.jsx(Hye,{size:13})," Rückgängig"]}),x.jsxs("button",{onClick:r,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-white hover:opacity-80 transition-opacity",style:{background:"var(--accent)"},children:[x.jsx(bye,{size:13})," Speichern"]})]}):x.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:"Alle Änderungen gespeichert"})}),x.jsx("main",{className:"flex-1 overflow-auto",children:x.jsx(mve,{})})]})]}):x.jsx(yve,{to:"/admin/login",replace:!0})}function Mdt(){const{pinHash:e}=od(),t=!e,[r,n]=I.useState(""),[a,i]=I.useState(""),[o,s]=I.useState(!1),[l,u]=I.useState(""),[c,f]=I.useState(!1),d=gv(),h=async p=>{if(p.preventDefault(),u(""),r.length<4){u("Mindestens 4 Zeichen");return}if(f(!0),t){if(r!==a){u("PINs stimmen nicht überein"),f(!1);return}zce(r),d("/admin")}else _dt(r)?d("/admin"):(u("Falscher PIN"),f(!1))};return x.jsx("div",{className:"min-h-screen flex items-center justify-center p-4",style:{background:"var(--app-bg)"},children:x.jsx("div",{className:"w-full max-w-sm",children:x.jsxs("div",{className:"rounded-2xl p-8 shadow-2xl",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex flex-col items-center mb-8",children:[x.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mb-4",style:{background:"var(--accent)22"},children:x.jsx(oJ,{size:28,style:{color:"var(--accent)"}})}),x.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:t?"Admin einrichten":"Admin-Bereich"}),x.jsx("p",{className:"text-sm mt-1 text-center",style:{color:"var(--text-secondary)"},children:t?"Lege einen PIN für den Admin-Bereich fest":"PIN eingeben um fortzufahren"})]}),x.jsxs("form",{onSubmit:h,className:"space-y-4",children:[x.jsxs("div",{className:"relative",children:[x.jsx("input",{type:o?"text":"password",value:r,onChange:p=>n(p.target.value),placeholder:t?"Neuer PIN (min. 4 Zeichen)":"PIN",autoFocus:!0,className:"w-full rounded-xl px-4 py-3 pr-10 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),x.jsx("button",{type:"button",onClick:()=>s(p=>!p),className:"absolute right-3 top-1/2 -translate-y-1/2",style:{color:"var(--text-secondary)"},children:o?x.jsx(Jj,{size:16}):x.jsx(QZ,{size:16})})]}),t&&x.jsx("input",{type:o?"text":"password",value:a,onChange:p=>i(p.target.value),placeholder:"PIN bestätigen",className:"w-full rounded-xl px-4 py-3 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),l&&x.jsx("p",{className:"text-sm",style:{color:"var(--accent-red)"},children:l}),x.jsx("button",{type:"submit",disabled:c,className:"w-full py-3 rounded-xl text-sm font-semibold text-white transition-opacity hover:opacity-80 disabled:opacity-50",style:{background:"var(--accent)"},children:c?"…":t?"PIN setzen & einloggen":"Einloggen"})]}),x.jsx("div",{className:"mt-6 text-center",children:x.jsx("a",{href:"/",className:"text-xs hover:opacity-80",style:{color:"var(--text-secondary)"},children:"← Zurück zum Dashboard"})})]})})})}function Tw({label:e,value:t,icon:r,color:n}){return x.jsxs("div",{className:"rounded-xl p-5",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center justify-between mb-3",children:[x.jsx("span",{className:"text-sm",style:{color:"var(--text-secondary)"},children:e}),x.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:n+"22"},children:x.jsx(r,{size:16,style:{color:n}})})]}),x.jsx("p",{className:"text-3xl font-bold",style:{color:"var(--text-primary)"},children:t})]})}function HX({text:e}){const[t,r]=I.useState(!1),n=()=>{navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),1500)};return x.jsx("button",{onClick:n,className:"hover:opacity-70 shrink-0",title:"Kopieren",children:t?x.jsx(Tu,{size:12,style:{color:"var(--accent-green)"}}):x.jsx(Zj,{size:12,style:{color:"var(--text-secondary)"}})})}function Pdt(){var o;const{layouts:e}=Ga(),r=Cv().tabs,n=e.reduce((s,l)=>s+l.tabs.length,0),a=e.reduce((s,l)=>s+l.tabs.reduce((u,c)=>u+c.widgets.length,0),0),{connected:i}=Vn();return x.jsxs("div",{className:"p-8 space-y-8",children:[x.jsxs("div",{children:[x.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:"Übersicht"}),x.jsx("p",{className:"text-sm mt-1",style:{color:"var(--text-secondary)"},children:"Status und Statistiken"})]}),x.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[x.jsx(Tw,{label:"Layouts",value:e.length,icon:eR,color:"var(--accent)"}),x.jsx(Tw,{label:"Tabs gesamt",value:n,icon:fye,color:"var(--accent-green)"}),x.jsx(Tw,{label:"Widgets gesamt",value:a,icon:tJ,color:"var(--accent-yellow)"}),x.jsx(Tw,{label:"ioBroker",value:i?"Verbunden":"Getrennt",icon:i?qye:Yye,color:i?"var(--accent-green)":"var(--accent-red)"})]}),x.jsxs("div",{className:"rounded-xl p-6",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsx("h2",{className:"font-semibold text-lg mb-4",style:{color:"var(--text-primary)"},children:"Tabs & Widgets"}),x.jsx("div",{className:"space-y-2",children:r.map(s=>x.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-lg",style:{background:"var(--app-bg)"},children:[x.jsxs("div",{children:[x.jsx("span",{className:"text-sm font-medium",style:{color:"var(--text-primary)"},children:s.name}),x.jsxs("p",{className:"text-xs font-mono mt-0.5",style:{color:"var(--text-secondary)"},children:["#/tab/",s.slug??s.id]})]}),x.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{background:"var(--accent)22",color:"var(--accent)"},children:[s.widgets.length," Widgets"]})]},s.id))})]}),x.jsxs("div",{className:"rounded-xl p-5",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest mb-3",style:{color:"var(--text-secondary)"},children:"Was bedeutet AURA?"}),x.jsx("div",{className:"flex flex-col gap-1.5",children:[["A","daptive","Passt sich flexibel an Geräte, Räume und Layouts an"],["U","nified","Alle Datenpunkte und Räume in einer einheitlichen Oberfläche"],["R","oom","Raumbasierte Organisation – jedes Tablet sein eigenes Layout"],["A","utomation","ioBroker-Automatisierungen live steuern und visualisieren"]].map(([s,l,u])=>x.jsxs("div",{className:"flex items-baseline gap-2",children:[x.jsx("span",{className:"text-lg font-bold w-4 shrink-0",style:{color:"var(--accent)"},children:s}),x.jsx("span",{className:"text-sm font-medium w-24 shrink-0",style:{color:"var(--text-primary)"},children:l}),x.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:u})]},s+l))})]}),x.jsxs("div",{className:"rounded-xl p-6 space-y-4",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(lye,{size:18,style:{color:"var(--accent)"}}),x.jsx("h2",{className:"font-semibold text-lg",style:{color:"var(--text-primary)"},children:"Tablet-Navigation via ioBroker"})]}),x.jsx("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:"Setze den folgenden Datenpunkt aus einem ioBroker-Skript oder einer Automatisierung, um das Tablet auf einen bestimmten Tab oder eine externe URL zu navigieren. Der Datenpunkt wird nach der Navigation automatisch zurückgesetzt."}),x.jsxs("div",{className:"rounded-lg px-4 py-3",style:{background:"var(--app-bg)",border:"1px solid var(--app-border)"},children:[x.jsx("p",{className:"text-xs mb-1",style:{color:"var(--text-secondary)"},children:"Datenpunkt"}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("code",{className:"text-sm font-mono flex-1",style:{color:"var(--accent)"},children:"aura.0.navigate.url"}),x.jsx(HX,{text:"aura.0.navigate.url"})]})]}),x.jsxs("div",{children:[x.jsx("p",{className:"text-xs font-medium mb-2",style:{color:"var(--text-secondary)"},children:"Tab-Slugs (Wert für den Datenpunkt)"}),x.jsx("div",{className:"space-y-1.5",children:r.map(s=>{const l=s.slug??s.id;return x.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg",style:{background:"var(--app-bg)"},children:[x.jsx("span",{className:"text-sm flex-1",style:{color:"var(--text-primary)"},children:s.name}),x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("code",{className:"text-xs font-mono",style:{color:"var(--text-secondary)"},children:l}),x.jsx(HX,{text:l})]})]},s.id)})})]}),x.jsxs("div",{className:"rounded-lg px-4 py-3 space-y-1",style:{background:"var(--app-bg)",border:"1px solid var(--app-border)"},children:[x.jsx("p",{className:"text-xs font-medium",style:{color:"var(--text-secondary)"},children:"Beispiel (JavaScript-Skript)"}),x.jsx("pre",{className:"text-xs font-mono overflow-x-auto",style:{color:"var(--text-primary)"},children:`setState('aura.0.navigate.url', '${((o=r[0])==null?void 0:o.slug)??"dashboard"}');`}),x.jsx("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:"Für externe URLs die vollständige URL angeben (https://…)."})]})]})]})}const GX=[{label:"Wert / Uhr",cls:"text-3xl",rem:1.875},{label:"Überschrift",cls:"text-xl",rem:1.25},{label:"Subheading",cls:"text-lg",rem:1.125},{label:"Fließtext",cls:"text-sm",rem:.875},{label:"Klein / Label",cls:"text-xs",rem:.75}],Ddt=[{label:"XS",value:.8},{label:"S",value:.9},{label:"M",value:1},{label:"L",value:1.15},{label:"XL",value:1.3},{label:"XXL",value:1.5}],Edt=[{label:"App",keys:["--app-bg","--app-surface","--app-border"]},{label:"Widget-Karte",keys:["--widget-bg","--widget-border","--widget-border-width","--widget-radius","--widget-shadow"]},{label:"Text",keys:["--text-primary","--text-secondary"]},{label:"Farben",keys:["--accent","--accent-green","--accent-yellow","--accent-red"]}],Ndt={"--app-bg":"Hintergrund","--app-surface":"Oberfläche","--app-border":"Rahmen","--widget-bg":"Hintergrund","--widget-border":"Rahmen","--widget-border-width":"Rahmenbreite","--widget-radius":"Eckenradius","--widget-shadow":"Schatten","--text-primary":"Primär","--text-secondary":"Sekundär","--accent":"Akzent","--accent-green":"Grün","--accent-yellow":"Gelb","--accent-red":"Rot"};function Odt(e){return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")}function Ldt(){const{themeId:e,customVars:t,setTheme:r,setCustomVar:n,resetCustom:a}=Tv(),{frontend:i,updateFrontend:o}=co(),s=zT(e),l=i.fontScale??1;return x.jsxs("div",{className:"p-8 space-y-8",children:[x.jsxs("div",{children:[x.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:"Theme & CSS"}),x.jsx("p",{className:"text-sm mt-1",style:{color:"var(--text-secondary)"},children:"Globales Design für Frontend und Admin"})]}),x.jsxs("div",{className:"rounded-xl p-6",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsx("h2",{className:"font-semibold mb-4",style:{color:"var(--text-primary)"},children:"Theme-Preset"}),x.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3",children:UE.map(u=>x.jsxs("button",{onClick:()=>{r(u.id),a()},className:"rounded-xl p-4 text-left transition-opacity hover:opacity-80 space-y-3",style:{background:u.vars["--app-surface"],border:`2px solid ${e===u.id?"var(--accent)":u.vars["--app-border"]}`},children:[x.jsx("div",{className:"flex gap-1.5",children:["--widget-bg","--accent","--accent-green","--accent-yellow"].map(c=>x.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:u.vars[c],border:`1px solid ${u.vars["--app-border"]}`}},c))}),x.jsxs("div",{children:[x.jsx("p",{className:"text-sm font-semibold",style:{color:u.vars["--text-primary"]},children:u.name}),e===u.id&&x.jsx("p",{className:"text-xs mt-0.5",style:{color:u.vars["--accent"]},children:"Aktiv ✓"})]})]},u.id))})]}),x.jsxs("div",{className:"rounded-xl p-6",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center justify-between mb-4",children:[x.jsx("h2",{className:"font-semibold",style:{color:"var(--text-primary)"},children:"CSS-Variablen anpassen"}),Object.keys(t).length>0&&x.jsx("button",{onClick:a,className:"text-xs px-3 py-1.5 rounded-lg hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--accent-red)",border:"1px solid var(--app-border)"},children:"Alle zurücksetzen"})]}),x.jsx("div",{className:"space-y-6",children:Edt.map(({label:u,keys:c})=>x.jsxs("div",{children:[x.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest mb-3",style:{color:"var(--text-secondary)"},children:u}),x.jsx("div",{className:"space-y-3",children:c.map(f=>{const d=s.vars[f],h=t[f],p=h??d;return x.jsxs("div",{className:"flex items-center gap-3",children:[x.jsx("label",{className:"text-xs w-32 shrink-0",style:{color:"var(--text-secondary)"},children:Ndt[f]??f}),x.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[Odt(p)&&x.jsx("input",{type:"color",value:p.startsWith("#")?p:"#000000",onChange:v=>n(f,v.target.value),className:"w-8 h-8 rounded-lg cursor-pointer border-0 p-0.5 shrink-0",style:{background:"var(--app-bg)",border:"1px solid var(--app-border)"}}),x.jsx("input",{type:"text",value:h??"",placeholder:d,onChange:v=>{v.target.value?n(f,v.target.value):a()},className:"flex-1 text-xs rounded-lg px-3 py-2 focus:outline-none font-mono",style:{background:"var(--app-bg)",color:h?"var(--text-primary)":"var(--text-secondary)",border:`1px solid ${h?"var(--accent)":"var(--app-border)"}`}}),h&&x.jsx("button",{onClick:()=>{const v={...t};delete v[f],a(),Object.entries(v).forEach(([g,y])=>n(g,y))},className:"text-xs hover:opacity-70 shrink-0",style:{color:"var(--text-secondary)"},children:"✕"})]})]},f)})})]},u))})]}),x.jsxs("div",{className:"rounded-xl p-6 space-y-5",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsxs("div",{children:[x.jsx("h2",{className:"font-semibold text-lg",style:{color:"var(--text-primary)"},children:"Typografie"}),x.jsx("p",{className:"text-xs mt-1",style:{color:"var(--text-secondary)"},children:"Skaliert alle Textgrößen im Frontend proportional. Die Admin-Oberfläche bleibt unverändert."})]}),x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center justify-between mb-2",children:[x.jsx("p",{className:"text-sm font-medium",style:{color:"var(--text-primary)"},children:"Schriftgröße"}),x.jsxs("span",{className:"text-sm font-mono font-bold px-2.5 py-1 rounded-lg",style:{background:"var(--app-bg)",color:"var(--accent)",border:"1px solid var(--app-border)"},children:[Math.round(l*100)," %"]})]}),x.jsx("input",{type:"range",min:.7,max:1.6,step:.05,value:l,onChange:u=>o({fontScale:Number(u.target.value)}),className:"w-full accent-[var(--accent)] mb-3"}),x.jsx("div",{className:"flex gap-2 flex-wrap",children:Ddt.map(({label:u,value:c})=>{const f=Math.abs(l-c)<.01;return x.jsxs("button",{onClick:()=>o({fontScale:c}),className:"px-3 py-1.5 rounded-lg text-xs font-medium hover:opacity-80",style:{background:f?"var(--accent)":"var(--app-bg)",color:f?"#fff":"var(--text-secondary)",border:`1px solid ${f?"var(--accent)":"var(--app-border)"}`},children:[u," · ",Math.round(c*100),"%"]},c)})})]}),x.jsxs("div",{children:[x.jsxs("p",{className:"text-xs font-semibold uppercase tracking-widest mb-2",style:{color:"var(--text-secondary)"},children:["Größen-Referenz bei ",Math.round(l*100)," %"]}),x.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--app-border)"},children:GX.map(({label:u,cls:c,rem:f},d)=>{const h=Math.round(f*l*16),p=(f*l).toFixed(3).replace(/\.?0+$/,"");return x.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5",style:{background:d%2===0?"var(--app-bg)":"var(--app-surface)",borderBottom:d<GX.length-1?"1px solid var(--app-border)":void 0},children:[x.jsx("span",{className:"w-32 shrink-0 text-xs font-mono",style:{color:"var(--text-secondary)"},children:c}),x.jsx("span",{className:"w-28 shrink-0 text-xs",style:{color:"var(--text-secondary)"},children:u}),x.jsxs("span",{className:"w-28 shrink-0 text-xs font-mono",style:{color:"var(--accent)"},children:[p,"rem · ",h,"px"]}),x.jsx("span",{style:{fontSize:`${f*l}rem`,color:"var(--text-primary)",lineHeight:1.2},children:"Beispiel"})]},c)})})]}),l!==1&&x.jsx("button",{onClick:()=>o({fontScale:1}),className:"text-xs hover:opacity-70",style:{color:"var(--text-secondary)"},children:"Zurücksetzen (100 %)"})]}),x.jsxs("div",{className:"rounded-xl p-6",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsx("h2",{className:"font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Globales CSS"}),x.jsx("p",{className:"text-xs mb-4",style:{color:"var(--text-secondary)"},children:"Wird direkt auf das Frontend angewendet. CSS-Variablen, Animationen, Font-Overrides etc."}),x.jsx("textarea",{value:i.customCSS,onChange:u=>o({customCSS:u.target.value}),rows:12,spellCheck:!1,placeholder:`/* Beispiele */
604
604
  :root { --widget-radius: 0.5rem; }
605
605
  .widget-card { transition: transform 0.2s; }
606
606
  .widget-card:hover { transform: scale(1.02); }
607
607
  @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');
608
608
  body { font-family: 'Inter', sans-serif; }`,className:"w-full rounded-xl px-4 py-3 text-xs font-mono focus:outline-none resize-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)",lineHeight:1.7}}),x.jsx("p",{className:"text-xs mt-2",style:{color:"var(--text-secondary)"},children:i.customCSS.trim()?`${i.customCSS.split(`
609
- `).length} Zeilen`:"Kein Custom CSS"})]})]})}const Idt=`${window.location.protocol}//${window.location.hostname}:8084`,jdt=_v()(Sv(e=>({ioBrokerUrl:Idt,setIoBrokerUrl:t=>{vwe(),RJ(t),e({ioBrokerUrl:t})}}),{name:"aura-connection"}));async function Rdt(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}function zdt({value:e,onChange:t}){return x.jsx("button",{onClick:()=>t(!e),className:"relative w-9 h-5 rounded-full transition-colors duration-200 focus:outline-none shrink-0",style:{background:e?"var(--accent-green)":"var(--app-border)"},children:x.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ${e?"translate-x-4":"translate-x-0"}`})})}function UX({label:e,value:t,onChange:r}){return x.jsxs("div",{className:"flex items-center justify-between py-2 border-b last:border-b-0",style:{borderColor:"var(--app-border)"},children:[x.jsx("p",{className:"text-sm",style:{color:"var(--text-primary)"},children:e}),x.jsx(zdt,{value:t,onChange:r})]})}function Fy({title:e,children:t}){return x.jsxs("div",{className:"rounded-xl p-4 space-y-3",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest",style:{color:"var(--text-secondary)"},children:e}),t]})}function ED({label:e,value:t,min:r,max:n,step:a,unit:i="",onChange:o,presets:s}){return x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center justify-between mb-1",children:[x.jsx("p",{className:"text-sm",style:{color:"var(--text-primary)"},children:e}),x.jsxs("span",{className:"text-xs font-mono font-bold px-2 py-0.5 rounded-md",style:{background:"var(--app-bg)",color:"var(--accent)",border:"1px solid var(--app-border)"},children:[t,i]})]}),x.jsx("input",{type:"range",min:r,max:n,step:a,value:t,onChange:l=>o(Number(l.target.value)),className:"w-full accent-[var(--accent)] mb-2"}),x.jsx("div",{className:"flex gap-1.5 flex-wrap",children:s.map(l=>{const u=t===l.value;return x.jsx("button",{onClick:()=>o(l.value),className:"px-2.5 py-1 rounded-lg text-xs font-medium hover:opacity-80",style:{background:u?"var(--accent)":"var(--app-bg)",color:u?"#fff":"var(--text-secondary)",border:`1px solid ${u?"var(--accent)":"var(--app-border)"}`},children:l.label},l.value)})})]})}function Bdt(){const{pinHash:e}=od(),{ioBrokerUrl:t,setIoBrokerUrl:r}=jdt(),[n,a]=I.useState(!1),[i,o]=I.useState(""),[s,l]=I.useState(""),[u,c]=I.useState(t),[f,d]=I.useState(!1),h=async v=>{v.preventDefault(),await Rdt(i)===e?(a(!0),l(""),o("")):l("Falscher PIN")},p=async()=>{const v=u.trim();v&&(r(v),await RJ(v),d(!0),setTimeout(()=>d(!1),2500))};return x.jsxs(Fy,{title:"Experten",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[n?x.jsx(tye,{size:14,style:{color:"var(--accent-yellow)"}}):x.jsx(oJ,{size:14,style:{color:"var(--text-secondary)"}}),x.jsx("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:n?"Entsperrt":"Zugang mit Admin-PIN"})]}),n?x.jsxs("div",{className:"space-y-3",children:[x.jsxs("div",{children:[x.jsx("p",{className:"text-xs mb-1",style:{color:"var(--text-secondary)"},children:"ioBroker Web-Adapter URL"}),x.jsxs("div",{className:"flex gap-2",children:[x.jsx("input",{type:"text",value:u,onChange:v=>{c(v.target.value),d(!1)},className:"flex-1 rounded-lg px-3 py-2 text-sm font-mono focus:outline-none min-w-0",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),x.jsxs("button",{onClick:p,disabled:u.trim()===t&&!f,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80 disabled:opacity-40 shrink-0",style:{background:f?"var(--accent-green)":"var(--accent)"},children:[x.jsx(tR,{size:12}),f?"OK":"Verbinden"]})]})]}),x.jsx("button",{onClick:()=>a(!1),className:"text-xs hover:opacity-70",style:{color:"var(--text-secondary)"},children:"Sperren"})]}):x.jsxs("form",{onSubmit:h,className:"flex gap-2",children:[x.jsx("input",{type:"password",value:i,onChange:v=>{o(v.target.value),l("")},placeholder:"Admin-PIN",className:"flex-1 rounded-lg px-3 py-2 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:`1px solid ${s?"var(--accent-red)":"var(--app-border)"}`}}),x.jsx("button",{type:"submit",className:"px-3 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80",style:{background:"var(--accent)"},children:"Entsperren"})]})]})}function $dt(){const e=Cv().tabs,{frontend:t,updateFrontend:r}=co(),[n,a]=I.useState(""),[i,o]=I.useState(""),[s,l]=I.useState(!1),[u,c]=I.useState(""),[f,d]=I.useState(!1),h=async g=>{if(g.preventDefault(),n.length<4){c("Mindestens 4 Zeichen");return}if(n!==i){c("PINs stimmen nicht überein");return}await zce(n),c("PIN erfolgreich geändert"),a(""),o(""),setTimeout(()=>c(""),3e3)},p=()=>{const g={dashboard:JSON.parse(localStorage.getItem("aura-dashboard")??"{}"),theme:JSON.parse(localStorage.getItem("aura-theme")??"{}"),config:JSON.parse(localStorage.getItem("aura-config")??"{}"),exported:new Date().toISOString()},y=new Blob([JSON.stringify(g,null,2)],{type:"application/json"}),m=URL.createObjectURL(y),b=document.createElement("a");b.href=m,b.download=`aura-backup-${Date.now()}.json`,b.click(),URL.revokeObjectURL(m)},v=g=>{var b;const y=(b=g.target.files)==null?void 0:b[0];if(!y)return;const m=new FileReader;m.onload=w=>{var _;try{const S=JSON.parse((_=w.target)==null?void 0:_.result);S.dashboard&&localStorage.setItem("aura-dashboard",JSON.stringify(S.dashboard)),S.theme&&localStorage.setItem("aura-theme",JSON.stringify(S.theme)),S.config&&localStorage.setItem("aura-config",JSON.stringify(S.config)),window.location.reload()}catch{alert("Ungültige Backup-Datei")}},m.readAsText(y)};return x.jsxs("div",{className:"p-5 max-w-3xl space-y-4",children:[x.jsxs("div",{children:[x.jsx("h1",{className:"text-lg font-bold",style:{color:"var(--text-primary)"},children:"Einstellungen"}),x.jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--text-secondary)"},children:"Frontend, Grid, Sicherheit und Backup"})]}),x.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[x.jsxs(Fy,{title:"Frontend",children:[x.jsx(UX,{label:"Header anzeigen",value:t.showHeader,onChange:g=>r({showHeader:g})}),t.showHeader&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"py-2 border-b",style:{borderColor:"var(--app-border)"},children:[x.jsx("p",{className:"text-xs mb-1",style:{color:"var(--text-secondary)"},children:"Dashboard-Titel"}),x.jsx("input",{value:t.headerTitle,onChange:g=>r({headerTitle:g.target.value}),className:"w-full rounded-lg px-3 py-2 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]}),x.jsx(UX,{label:"Verbindungsstatus",value:t.showConnectionBadge,onChange:g=>r({showConnectionBadge:g})})]})]}),x.jsxs(Fy,{title:"Grid & Mobil",children:[x.jsx(ED,{label:"Zeilenhöhe",value:t.gridRowHeight??80,min:30,max:160,step:10,unit:" px",onChange:g=>r({gridRowHeight:g}),presets:[{label:"XS·40",value:40},{label:"S·60",value:60},{label:"M·80",value:80},{label:"L·100",value:100},{label:"XL·120",value:120}]}),x.jsx("div",{className:"border-t pt-3",style:{borderColor:"var(--app-border)"},children:x.jsx(ED,{label:"Mobile-Breakpoint",value:t.mobileBreakpoint??600,min:0,max:1024,step:10,unit:" px",onChange:g=>r({mobileBreakpoint:g}),presets:[{label:"480",value:480},{label:"600",value:600},{label:"768",value:768},{label:"Aus",value:0}]})}),x.jsx("div",{className:"border-t pt-3",style:{borderColor:"var(--app-border)"},children:x.jsx(ED,{label:"Wizard Max-Datenpunkte",value:t.wizardMaxDatapoints??500,min:100,max:5e3,step:100,onChange:g=>r({wizardMaxDatapoints:g}),presets:[{label:"200",value:200},{label:"500",value:500},{label:"1k",value:1e3},{label:"2k",value:2e3},{label:"5k",value:5e3}]})})]})]}),x.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[x.jsx(Fy,{title:"Admin-PIN",children:x.jsxs("form",{onSubmit:h,className:"space-y-2",children:[x.jsxs("div",{className:"relative",children:[x.jsx("input",{type:s?"text":"password",value:n,onChange:g=>a(g.target.value),placeholder:"Neuer PIN (min. 4 Zeichen)",className:"w-full rounded-lg px-3 py-2 pr-9 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),x.jsx("button",{type:"button",onClick:()=>l(g=>!g),className:"absolute right-3 top-1/2 -translate-y-1/2",style:{color:"var(--text-secondary)"},children:s?x.jsx(Jj,{size:13}):x.jsx(QZ,{size:13})})]}),x.jsx("input",{type:s?"text":"password",value:i,onChange:g=>o(g.target.value),placeholder:"PIN bestätigen",className:"w-full rounded-lg px-3 py-2 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),u&&x.jsx("p",{className:"text-xs",style:{color:u.includes("erfolgreich")?"var(--accent-green)":"var(--accent-red)"},children:u}),x.jsx("button",{type:"submit",className:"px-4 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80",style:{background:"var(--accent)"},children:"PIN speichern"})]})}),x.jsxs(Fy,{title:"Backup & Restore",children:[x.jsxs("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:["Dashboard (",e.length," Tab",e.length!==1?"s":"","), Theme und Config als JSON."]}),x.jsxs("div",{className:"flex flex-col gap-2",children:[x.jsx("button",{onClick:p,className:"px-4 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80",style:{background:"var(--accent)"},children:"Download Backup"}),x.jsxs("label",{className:"px-4 py-2 rounded-lg text-sm font-medium text-center cursor-pointer hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"},children:["Backup importieren",x.jsx("input",{type:"file",accept:".json",onChange:v,className:"hidden"})]})]})]})]}),x.jsx(Bdt,{}),x.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--app-surface)",border:"1px solid var(--accent-red)44"},children:[x.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.jsx(Vye,{size:15,style:{color:"var(--accent-red)"}}),x.jsx("p",{className:"text-sm font-semibold",style:{color:"var(--accent-red)"},children:"Alles zurücksetzen"})]}),x.jsx("p",{className:"text-xs mb-3",style:{color:"var(--text-secondary)"},children:"Löscht alle Dashboards, Widgets, Themes und Einstellungen. Nicht rückgängig."}),f?x.jsxs("div",{className:"flex gap-2",children:[x.jsx("button",{onClick:()=>{["aura-dashboard","aura-theme","aura-config"].forEach(g=>localStorage.removeItem(g)),window.location.href="/"},className:"px-3 py-1.5 rounded-lg text-xs font-medium text-white hover:opacity-80",style:{background:"var(--accent-red)"},children:"Ja, alles löschen"}),x.jsx("button",{onClick:()=>d(!1),className:"px-3 py-1.5 rounded-lg text-xs font-medium hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"Abbruch"})]}):x.jsx("button",{onClick:()=>d(!0),className:"px-3 py-1.5 rounded-lg text-xs font-medium hover:opacity-80",style:{background:"var(--accent-red)22",color:"var(--accent-red)",border:"1px solid var(--accent-red)44"},children:"Zurücksetzen…"})]})]})}function Fdt(e,t){if(!e)return t==="boolean"?"switch":"value";const r=e.toLowerCase();return r==="switch"||r==="button"||r.startsWith("switch.")||r==="indicator"?"switch":r.includes("dimmer")||r.includes("brightness")||r==="level"||r.startsWith("level.")?"dimmer":r.includes("temperature")&&r.includes("level")?"thermostat":r.includes("temperature")?"value":t==="boolean"?"switch":"value"}function YX(e){const t=e.common.name;return t?typeof t=="string"?t:t.de??t.en??Object.values(t)[0]??e._id:e._id.split(".").pop()??e._id}function XX(e){const t=e.split(".");return t.length>=2?`${t[0]}.${t[1]}`:t[0]}function Bce(){const{getObjectView:e}=Vn(),[t,r]=I.useState([]),[n,a]=I.useState(!1),[i,o]=I.useState(!1),s=I.useCallback(async()=>{a(!0);try{const[l,u,c]=await Promise.all([e("device"),e("channel"),e("state")]),f=new Map;for(const{value:p}of c.rows){if(!p)continue;const g=p._id.split(".").slice(0,-1).join(".");f.has(g)||f.set(g,[]),f.get(g).push({id:p._id,obj:p,suggestedWidget:Fdt(p.common.role,p.common.type),unit:p.common.unit})}const d=[];for(const{value:p}of l.rows){if(!p)continue;const v=[];for(const[g,y]of f.entries())(g===p._id||g.startsWith(p._id+"."))&&v.push(...y);v.length!==0&&d.push({id:p._id,name:YX(p),adapter:XX(p._id),states:v})}const h=new Set(d.map(p=>p.id));for(const{value:p}of u.rows){if(!p)continue;const g=p._id.split(".").slice(0,-1).join(".");if(h.has(g))continue;const y=f.get(p._id)??[];y.length!==0&&d.push({id:p._id,name:YX(p),adapter:XX(p._id),states:y})}d.sort((p,v)=>p.adapter.localeCompare(v.adapter)||p.name.localeCompare(v.name)),r(d),o(!0)}finally{a(!1)}},[e]);return{devices:t,loading:n,loaded:i,load:s}}const Vdt={switch:x.jsx(ll,{size:13}),value:x.jsx(lf,{size:13}),dimmer:x.jsx(uJ,{size:13}),thermostat:x.jsx(Af,{size:13}),chart:x.jsx(Cu,{size:13}),list:x.jsx(iJ,{size:13}),clock:x.jsx(ZZ,{size:13}),calendar:x.jsx(Vm,{size:13}),header:x.jsx(rJ,{size:13}),group:x.jsx(Qj,{size:13}),echart:x.jsx(Cu,{size:13}),evcc:x.jsx(ll,{size:13}),weather:x.jsx(Mge,{size:13}),gauge:x.jsx($ge,{size:13}),camera:x.jsx(R_,{size:13})},Wdt={switch:{t:"Wohnzimmer",v:"AN"},value:{t:"Temperatur",v:"21.5",u:"°C"},dimmer:{t:"Licht",v:"75",u:"%"},thermostat:{t:"Heizung",v:"21.0",sub:"Ist: 19.5°"},chart:{t:"Verbrauch",v:"245",u:"W"},list:{t:"Alle Geräte",v:""},clock:{t:"Uhrzeit",v:"12:34"},calendar:{t:"Kalender",v:"3"},header:{t:"Abschnitt",v:""},group:{t:"Gruppe",v:""},echart:{t:"EChart",v:""},evcc:{t:"evcc",v:""},weather:{t:"Wetter",v:"18°",sub:"⛅ Bewölkt"},gauge:{t:"Gauge",v:"72",u:"kW"},camera:{t:"Kamera",v:""}};function Aw({on:e}){return x.jsx("div",{className:"relative w-8 h-4 rounded-full shrink-0",style:{background:e!==!1?"var(--accent-green)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-3 h-3 bg-white rounded-full shadow",style:{left:e!==!1?"18px":"2px",transition:"left 0.15s"}})})}function Hdt({type:e,layout:t,title:r}){const n=Wdt[e],a=r||n.t,i=Vdt[e];if(e==="clock")return t==="minimal"||t==="card"?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-0.5",children:[x.jsx("p",{className:"text-3xl font-black tabular-nums leading-none",style:{color:"var(--accent)"},children:"12:34"}),t==="card"&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"07.04.2026"})]}):t==="compact"?x.jsxs("div",{className:"flex items-center gap-2 h-full",children:[x.jsx("p",{className:"text-xl font-bold tabular-nums",style:{color:"var(--text-primary)"},children:"12:34"}),x.jsx("span",{style:{color:"var(--app-border)"},children:"·"}),x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Mo., 7. Apr."})]}):x.jsxs("div",{className:"flex flex-col h-full justify-between",children:[x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:a}),x.jsxs("div",{children:[x.jsx("p",{className:"text-2xl font-bold tabular-nums",style:{color:"var(--text-primary)"},children:"12:34"}),x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"07.04.2026"})]})]});if(e==="calendar"){const o=[{label:"Team-Meeting",date:"Heute, 10:00",dot:"var(--accent)"},{label:"Zahnarzt",date:"Morgen, 14:30",dot:"var(--accent-green)"},{label:"Geburtstag Lisa",date:"Mi, 9. Apr",dot:"var(--accent-yellow)"}];return t==="minimal"||t==="card"?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[x.jsx("p",{className:"text-3xl font-black leading-none",style:{color:"var(--accent)"},children:"3"}),x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Termine"})]}):t==="compact"?x.jsxs("div",{className:"flex items-center gap-2 h-full",children:[x.jsx(Vm,{size:16,style:{color:"var(--accent)"}}),x.jsxs("div",{children:[x.jsx("p",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Team-Meeting"}),x.jsx("p",{className:"text-[10px]",style:{color:"var(--accent)"},children:"Heute, 10:00"})]})]}):t==="agenda"?x.jsxs("div",{className:"flex flex-col h-full gap-0.5",children:[x.jsx("p",{className:"text-[11px] font-medium mb-0.5",style:{color:"var(--text-secondary)"},children:a}),o.map((s,l)=>x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("div",{className:"w-0.5 self-stretch rounded-full shrink-0",style:{background:s.dot}}),x.jsxs("span",{className:"text-[8px] w-8 truncate shrink-0",style:{color:s.dot},children:["Cal ",l+1]}),x.jsx("p",{className:"flex-1 text-[9px] font-medium truncate",style:{color:"var(--text-primary)"},children:s.label}),x.jsx("p",{className:"text-[8px] shrink-0",style:{color:"var(--text-secondary)"},children:s.date.split(", ")[1]??s.date})]},l))]}):x.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[x.jsx("p",{className:"text-[11px] font-medium",style:{color:"var(--text-secondary)"},children:a}),o.map((s,l)=>x.jsxs("div",{className:"flex items-start gap-1.5",children:[x.jsx("div",{className:"w-1.5 h-1.5 rounded-full mt-1 shrink-0",style:{background:s.dot}}),x.jsxs("div",{children:[x.jsx("p",{className:"text-[10px] font-medium leading-tight",style:{color:"var(--text-primary)"},children:s.label}),x.jsx("p",{className:"text-[9px]",style:{color:"var(--text-secondary)"},children:s.date})]})]},l))]})}if(e==="weather")return t==="minimal"?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[x.jsx("span",{style:{fontSize:"2rem",lineHeight:1},children:"⛅"}),x.jsx("span",{className:"text-2xl font-black",style:{color:"var(--text-primary)"},children:"18°"})]}):t==="compact"?x.jsxs("div",{className:"flex items-center gap-2 h-full",children:[x.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1},children:"⛅"}),x.jsx("span",{className:"text-xl font-bold",style:{color:"var(--text-primary)"},children:"18°"}),x.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Bewölkt"})]}):x.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[x.jsxs("div",{className:"flex items-start gap-2",children:[x.jsx("span",{style:{fontSize:"1.8rem",lineHeight:1},children:"⛅"}),x.jsxs("div",{children:[x.jsx("span",{className:"text-2xl font-black",style:{color:"var(--text-primary)"},children:"18°"}),x.jsx("span",{className:"text-[11px] ml-1",style:{color:"var(--text-secondary)"},children:"Bewölkt"}),x.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:"Gefühlt 15°"})]})]}),x.jsxs("div",{className:"text-[10px] flex gap-2",style:{color:"var(--text-secondary)"},children:[x.jsx("span",{children:"💧 65%"}),x.jsx("span",{children:"💨 12 km/h"})]}),x.jsx("div",{className:"flex gap-1 pt-1",style:{borderTop:"1px solid var(--app-border)"},children:[["Mo","☁️","18°"],["Di","🌧️","15°"],["Mi","☀️","22°"]].map(([o,s,l])=>x.jsxs("div",{className:"flex-1 flex flex-col items-center",style:{fontSize:"9px",color:"var(--text-secondary)"},children:[x.jsx("span",{children:o}),x.jsx("span",{style:{fontSize:"11px"},children:s}),x.jsx("span",{style:{color:"var(--text-primary)",fontWeight:"bold"},children:l})]},o))})]});if(e==="gauge")return x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[x.jsxs("svg",{viewBox:"0 0 200 120",style:{width:120,height:72},children:[x.jsx("path",{d:"M 20 100 A 80 80 0 0 1 180 100",fill:"none",stroke:"var(--app-border)",strokeWidth:12,strokeLinecap:"round"}),x.jsx("path",{d:"M 20 100 A 80 80 0 0 1 131.13 33.57",fill:"none",stroke:"var(--accent)",strokeWidth:12,strokeLinecap:"round"}),x.jsx("text",{x:100,y:95,textAnchor:"middle",fontSize:22,fontWeight:"bold",fill:"var(--text-primary)",children:"72"}),x.jsx("text",{x:100,y:110,textAnchor:"middle",fontSize:10,fill:"var(--text-secondary)",children:n.u})]}),a&&x.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:a})]});if(e==="camera")return x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",style:{background:"var(--app-bg)",borderRadius:4},children:[x.jsx(R_,{size:20,style:{color:"var(--text-secondary)"}}),x.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:a})]});if(e==="chart"){const o=[40,60,45,75,55,80,65,90,70];return x.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[x.jsx("p",{className:"text-[11px] truncate",style:{color:"var(--text-secondary)"},children:a}),x.jsx("div",{className:"flex-1 flex items-end gap-0.5",children:o.map((s,l)=>x.jsx("div",{className:"flex-1 rounded-sm",style:{height:`${s}%`,background:l===o.length-1?"var(--accent)":"color-mix(in srgb, var(--accent) 45%, transparent)"}},l))}),x.jsxs("p",{className:"text-[11px] font-bold",style:{color:"var(--text-primary)"},children:[n.v,n.u&&x.jsxs("span",{style:{color:"var(--text-secondary)",fontWeight:400},children:[" ",n.u]})]})]})}return e==="list"?x.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[x.jsx("p",{className:"text-[11px] font-medium truncate",style:{color:"var(--text-secondary)"},children:a}),["Gerät 1","Gerät 2","Gerät 3"].map((o,s)=>x.jsxs("div",{className:"flex items-center justify-between px-1.5 py-0.5 rounded",style:{background:"var(--app-bg)"},children:[x.jsx("span",{className:"text-[10px]",style:{color:"var(--text-primary)"},children:o}),x.jsx(Aw,{on:s===0})]},s))]}):t==="card"?e==="switch"?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 rounded-md",style:{background:"color-mix(in srgb, var(--accent-green) 20%, transparent)"},children:[x.jsx(ll,{size:26,style:{color:"var(--accent-green)"}}),x.jsx("p",{className:"text-[11px] font-bold",style:{color:"var(--text-primary)"},children:a}),x.jsx("p",{className:"text-[10px]",style:{color:"var(--accent-green)"},children:"AN"})]}):x.jsxs("div",{className:"flex flex-col h-full justify-between",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("p",{className:"text-[11px] truncate",style:{color:"var(--text-secondary)"},children:a}),x.jsx("span",{style:{color:"var(--accent)"},children:i})]}),x.jsxs("div",{children:[x.jsx("p",{className:"text-3xl font-black leading-none",style:{color:"var(--accent)"},children:n.v}),n.u&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:n.u})]})]}):t==="compact"?x.jsxs("div",{className:"flex items-center gap-2 h-full",children:[x.jsx("span",{style:{color:"var(--text-secondary)",flexShrink:0},children:i}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("p",{className:"text-[10px] truncate",style:{color:"var(--text-secondary)"},children:a}),x.jsxs("p",{className:"text-base font-bold leading-tight",style:{color:"var(--text-primary)"},children:[n.v,n.u&&x.jsx("span",{className:"text-[10px] font-normal ml-0.5",style:{color:"var(--text-secondary)"},children:n.u})]})]}),e==="switch"&&x.jsx(Aw,{}),e==="thermostat"&&x.jsxs("div",{className:"flex gap-0.5 shrink-0",children:[x.jsx("span",{className:"w-5 h-5 rounded text-[10px] font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"−"}),x.jsx("span",{className:"w-5 h-5 rounded text-[10px] font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"+"})]}),e==="dimmer"&&x.jsx("div",{className:"w-14 h-2 rounded-full overflow-hidden shrink-0",style:{background:"var(--app-border)"},children:x.jsx("div",{className:"h-full rounded-full",style:{width:"75%",background:"var(--accent)"}})})]}):t==="minimal"?e==="switch"?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1.5",children:[x.jsx(Aw,{}),x.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:a})]}):x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-0.5",children:[x.jsx("p",{className:"text-3xl font-black leading-none",style:{color:"var(--accent)"},children:n.v}),n.u&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:n.u}),x.jsx("p",{className:"text-[10px] mt-1",style:{color:"var(--text-secondary)"},children:a})]}):x.jsxs("div",{className:"flex flex-col h-full justify-between",children:[x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("span",{style:{color:"var(--text-secondary)"},children:i}),x.jsx("p",{className:"text-[11px] truncate",style:{color:"var(--text-secondary)"},children:a})]}),x.jsx("div",{children:e==="switch"?x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("span",{className:"text-xl font-bold",style:{color:"var(--accent-green)"},children:"AN"}),x.jsx(Aw,{})]}):e==="thermostat"?x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsxs("p",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:[n.v,"°"]}),n.sub&&x.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:n.sub})]}),x.jsxs("div",{className:"flex flex-col gap-0.5",children:[x.jsx("span",{className:"w-6 h-6 rounded text-sm font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"+"}),x.jsx("span",{className:"w-6 h-6 rounded text-sm font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"−"})]})]}):e==="dimmer"?x.jsxs("div",{children:[x.jsxs("p",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:[n.v,x.jsx("span",{className:"text-sm ml-0.5",style:{color:"var(--text-secondary)"},children:n.u})]}),x.jsx("div",{className:"w-full h-2 mt-1 rounded-full overflow-hidden",style:{background:"var(--app-border)"},children:x.jsx("div",{className:"h-full rounded-full",style:{width:"75%",background:"var(--accent)"}})})]}):x.jsxs("div",{className:"flex items-end gap-1",children:[x.jsx("span",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:n.v}),n.u&&x.jsx("span",{className:"text-xs mb-0.5",style:{color:"var(--text-secondary)"},children:n.u})]})})]})}function mx({type:e,layout:t="default",title:r}){return x.jsx("div",{className:"rounded-lg overflow-hidden shrink-0 relative",style:{width:Math.round(200*.62),height:Math.round(140*.62),background:"var(--widget-bg)",border:"1px solid var(--app-border)"},children:x.jsx("div",{style:{position:"absolute",top:0,left:0,width:200,height:140,transform:`scale(${.62})`,transformOrigin:"top left",padding:14,boxSizing:"border-box",pointerEvents:"none"},children:x.jsx(Hdt,{type:e,layout:t,title:r??""})})})}const qX={switch:"Schalter",value:"Wert",dimmer:"Dimmer",thermostat:"Thermostat",chart:"Diagramm",list:"Gruppenliste",clock:"Uhrzeit",calendar:"Kalender",header:"Abschnittstitel",group:"Gruppe",echart:"EChart",evcc:"evcc",weather:"Wetter",gauge:"Gauge",camera:"Kamera"},vy={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};function Gdt({onAdd:e,onClose:t}){const{devices:r,loading:n,loaded:a,load:i}=Bce(),[o,s]=I.useState(""),[l,u]=I.useState(""),[c,f]=I.useState(null),[d,h]=I.useState(new Map),p=I.useMemo(()=>Array.from(new Set(r.map(b=>b.adapter))).sort(),[r]),v=I.useMemo(()=>r.filter(b=>{if(l&&b.adapter!==l)return!1;if(o){const w=o.toLowerCase();return b.name.toLowerCase().includes(w)||b.id.toLowerCase().includes(w)||b.states.some(_=>_.id.toLowerCase().includes(w))}return!0}),[r,o,l]),g=(b,w)=>{h(_=>{const S=new Map(_);return S.has(w.id)?S.delete(w.id):S.set(w.id,{state:w,device:b,widgetType:w.suggestedWidget,title:`${b.name} – ${w.obj._id.split(".").pop()}`}),S})},y=(b,w)=>h(_=>{const S=new Map(_),C=S.get(b);return C&&S.set(b,{...C,...w}),S}),m=()=>{e(Array.from(d.values()).map((b,w)=>({id:`${b.widgetType}-${Date.now()}-${w}`,type:b.widgetType,title:b.title,datapoint:b.state.id,gridPos:{x:w*2%12,y:1/0,w:b.widgetType==="chart"?4:2,h:b.widgetType==="chart"?3:2},options:{...b.state.unit?{unit:b.state.unit}:{},...b.actualDatapoint?{actualDatapoint:b.actualDatapoint}:{}}}))),t()};return x.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:t,children:x.jsxs("div",{className:"rounded-xl w-full max-w-3xl max-h-[85vh] flex flex-col shadow-2xl",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},onClick:b=>b.stopPropagation(),children:[x.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderBottom:"1px solid var(--app-border)"},children:[x.jsx("h2",{className:"font-bold text-lg",style:{color:"var(--text-primary)"},children:"Geräte aus ioBroker"}),x.jsx("button",{onClick:t,className:"hover:opacity-60",style:{color:"var(--text-secondary)"},children:"✕"})]}),a?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"flex gap-3 px-6 py-3",style:{borderBottom:"1px solid var(--app-border)"},children:[x.jsx("input",{value:o,onChange:b=>s(b.target.value),placeholder:"Suchen…",className:"flex-1 rounded-lg px-3 py-1.5 text-sm focus:outline-none",style:{...vy,outlineColor:"var(--accent)"}}),x.jsxs("select",{value:l,onChange:b=>u(b.target.value),className:"rounded-lg px-3 py-1.5 text-sm",style:vy,children:[x.jsx("option",{value:"",children:"Alle Adapter"}),p.map(b=>x.jsx("option",{value:b,children:b},b))]}),x.jsxs("span",{className:"text-sm self-center whitespace-nowrap",style:{color:"var(--text-secondary)"},children:[v.length," Geräte"]})]}),x.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-3 space-y-2",children:v.map(b=>{const w=Array.from(d.values()).filter(_=>_.device.id===b.id).length;return x.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--app-border)"},children:[x.jsxs("button",{className:"w-full flex items-center justify-between px-4 py-3 text-left hover:opacity-80 transition-opacity",style:{background:"var(--app-bg)"},onClick:()=>f(c===b.id?null:b.id),children:[x.jsxs("div",{children:[x.jsx("p",{className:"font-medium text-sm",style:{color:"var(--text-primary)"},children:b.name}),x.jsx("p",{className:"text-xs font-mono",style:{color:"var(--text-secondary)"},children:b.id})]}),x.jsxs("div",{className:"flex items-center gap-3",children:[w>0&&x.jsx("span",{className:"px-2 py-0.5 text-xs text-white rounded-full",style:{background:"var(--accent)"},children:w}),x.jsxs("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[b.states.length," DP ",c===b.id?"▲":"▼"]})]})]}),c===b.id&&b.states.map(_=>{const S=d.get(_.id);return x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 cursor-pointer transition-opacity hover:opacity-80",style:{background:S?"var(--accent)11":"var(--app-surface)",borderTop:"1px solid var(--app-border)"},onClick:()=>g(b,_),children:[x.jsx("input",{type:"checkbox",checked:!!S,readOnly:!0,style:{accentColor:"var(--accent)"},className:"w-4 h-4 shrink-0"}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("p",{className:"text-sm font-mono truncate",style:{color:"var(--text-primary)"},children:_.id.split(".").pop()}),x.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-secondary)"},children:_.id})]}),x.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[_.unit&&x.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:_.unit}),S?x.jsx("select",{value:S.widgetType,onClick:C=>C.stopPropagation(),onChange:C=>y(_.id,{widgetType:C.target.value}),className:"text-xs rounded px-2 py-1",style:vy,children:Object.entries(qX).map(([C,T])=>x.jsx("option",{value:C,children:T},C))}):x.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:qX[_.suggestedWidget]})]})]}),S&&x.jsxs("div",{className:"px-4 pb-3 pt-2 flex gap-3 items-start",style:{background:"var(--accent)08",borderTop:"1px solid var(--app-border)"},onClick:C=>C.stopPropagation(),children:[x.jsxs("div",{className:"flex-1 space-y-2 min-w-0",children:[x.jsx("input",{value:S.title,onChange:C=>y(_.id,{title:C.target.value}),placeholder:"Titel",className:"w-full text-xs rounded px-2 py-1.5 focus:outline-none",style:vy}),S.widgetType==="thermostat"&&x.jsx("input",{value:S.actualDatapoint??"",onChange:C=>y(_.id,{actualDatapoint:C.target.value}),placeholder:"Ist-Temperatur Datenpunkt (optional)",className:"w-full text-xs rounded px-2 py-1.5 focus:outline-none",style:vy})]}),x.jsx(mx,{type:S.widgetType,title:S.title})]})]},_.id)})]},b.id)})}),x.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderTop:"1px solid var(--app-border)"},children:[x.jsx("span",{className:"text-sm",style:{color:"var(--text-secondary)"},children:d.size===0?"Keine ausgewählt":`${d.size} Widget${d.size!==1?"s":""}`}),x.jsxs("div",{className:"flex gap-2",children:[x.jsx("button",{onClick:t,className:"px-4 py-2 text-sm rounded-lg hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"Abbruch"}),x.jsx("button",{onClick:m,disabled:d.size===0,className:"px-4 py-2 text-sm font-medium text-white rounded-lg hover:opacity-80 disabled:opacity-30",style:{background:"var(--accent)"},children:"Zum Dashboard hinzufügen"})]})]})]}):x.jsx("div",{className:"flex flex-col items-center justify-center flex-1 gap-4 py-12",children:n?x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"w-8 h-8 border-2 border-t-transparent rounded-full animate-spin",style:{borderColor:"var(--accent)",borderTopColor:"transparent"}}),x.jsx("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:"Lade Geräte…"})]}):x.jsxs(x.Fragment,{children:[x.jsx("p",{style:{color:"var(--text-secondary)"},children:"Alle verfügbaren Geräte und Datenpunkte laden"}),x.jsx("button",{onClick:i,className:"px-6 py-2 text-white rounded-lg font-medium hover:opacity-80",style:{background:"var(--accent)"},children:"Geräte laden"})]})})]})})}function Udt(e){const t=(e.role??"").toLowerCase(),r=e.name.toLowerCase(),n=e.unit??"";return t.includes("thermostat")||t.includes("temp.set")||r.includes("solltemp")||r.includes("setpoint")?{type:"thermostat"}:t.includes("temperature")||r.includes("temperatur")||n==="°C"?{type:"value",unit:n||"°C"}:t.includes("level.dimmer")||t.includes("level.brightness")||r.includes("dimmer")||r.includes("helligkeit")?{type:"dimmer"}:n==="W"||n==="VA"||t.includes("value.power")?{type:"value",unit:n}:n==="kWh"||t.includes("value.energy")?{type:"value",unit:n}:n==="%"&&(t.includes("level")||r.includes("rollade")||r.includes("rollo")||r.includes("jalousie")||r.includes("shutter")||r.includes("blind"))?{type:"dimmer",unit:"%"}:n==="%"&&(t.includes("humid")||r.includes("feuchte"))?{type:"value",unit:"%"}:e.type==="boolean"||t.includes("switch")||t.includes("button")?{type:"switch"}:e.type==="number"?{type:"value",unit:n||void 0}:{type:"value"}}function HI(e){return e.toLowerCase().trim()}function KX(e,t){const r=HI(t);for(const n of e){const a=HI(n);if(a===r)return 1;if(a.includes(r)||r.includes(a))return .85}return 0}const ZX={licht:["light","lamp","lampe","led","leuchte","beleuchtung","dimmer","bulb","switch"],heizung:["heiz","heat","thermostat","radiator","boiler","solltemp","setpoint"],temperatur:["temp","temperature","celsius","klima","grad"],steckdose:["socket","outlet","plug","stecker","dose"],rollade:["shutter","blind","rolladen","jalousie","vorhang","curtain","rollo","level"],energie:["energy","power","strom","verbrauch","watt","kwh","leistung"],sicherheit:["security","alarm","door","window","motion","contact","tür","fenster"],klima:["climate","ac","klimaanlage","luft","humidity","feuchte","lüftung"]};function Ydt(e,t){const r=HI(t),n=e.name.toLowerCase(),a=e.id.toLowerCase(),i=(e.role??"").toLowerCase();if(n.includes(r)||i.includes(r))return .75;if(a.split(".").some(s=>s===r))return .7;if(a.includes(r))return .6;const o=ZX[r]??[];for(const s of o)if(n.includes(s)||i.includes(s)||a.includes(s))return .65;for(const[,s]of Object.entries(ZX))if(s.includes(r)&&s.some(l=>n.includes(l)||i.includes(l)))return .5;return 0}function Xdt(e,t){const r=KX(e.funcs,t);if(r>0)return r;const n=KX(e.rooms,t);return n>0?n:Ydt(e,t)}function qdt(e){return e.name&&e.name!==e.id.split(".").pop()?e.name:e.id.split(".").slice(-2).join(" › ")}function $ce(e,t,r=500){const n=[];for(const a of e){const i=Xdt(a,t);if(i===0)continue;const{type:o,unit:s}=Udt(a);n.push({datapoint:a,type:o,title:qdt(a),unit:s,score:i})}return n.sort((a,i)=>i.score-a.score).slice(0,r)}const Kdt=[{topic:"temperatur",max:4,label:"Temperatur"},{topic:"licht",max:5,label:"Licht"},{topic:"energie",max:3,label:"Energie"},{topic:"heizung",max:3,label:"Heizung"},{topic:"klima",max:2,label:"Klima"},{topic:"rollade",max:3,label:"Rolläden"},{topic:"sicherheit",max:3,label:"Sicherheit"}];function Zdt(e){const t=new Set,r=[],n={datapoint:{id:"__clock__",name:"Uhrzeit",rooms:[],funcs:[]},type:"clock",title:"Uhrzeit",score:1};r.push({label:"Uhrzeit",widgets:[n]}),t.add("__clock__");for(const{topic:a,max:i,label:o}of Kdt){const s=$ce(e,a,i*10).filter(l=>!t.has(l.datapoint.id)).slice(0,i);s.length!==0&&(s.forEach(l=>t.add(l.datapoint.id)),r.push({label:o,widgets:s}))}return{sections:r,allWidgets:r.flatMap(a=>a.widgets)}}const Jdt={compact:{switch:[2,3],value:[3,3],dimmer:[3,4],thermostat:[4,4],chart:[6,4],list:[4,4],clock:[4,3],calendar:[6,4]},standard:{switch:[2,4],value:[3,4],dimmer:[3,5],thermostat:[4,5],chart:[6,5],list:[4,5],clock:[5,4],calendar:[6,5]},wide:{switch:[3,5],value:[4,5],dimmer:[4,6],thermostat:[5,6],chart:[8,5],list:[5,6],clock:[6,4],calendar:[8,6]}},ND={compact:"card",standard:"default",wide:"card"},Fce=12,Vce=Date.now();function OD(e,t,r,n){const a=Jdt[t];if(!n)return JX(e,a,t,r,0,0);const i=new Map,o=[];for(const c of e){const f=n(c.datapoint.id);i.has(f)||(i.set(f,[]),o.push(f)),i.get(f).push(c)}const s=[];let l=0,u=0;for(const c of o){s.push({id:`wiz-header-${u}-${Vce}`,type:"header",title:c,datapoint:"",layout:"default",gridPos:{x:0,y:l,w:Fce,h:1},options:{}}),l+=1,u+=1;const f=i.get(c),d=JX(f,a,t,r,0,l,u);s.push(...d),u+=d.length,l=d.reduce((p,v)=>Math.max(p,v.gridPos.y+v.gridPos.h),l)+1}return s}function JX(e,t,r,n,a,i,o=0){const s=[];let l=a,u=i,c=0;return e.forEach((f,d)=>{const[h,p]=t[f.type]??[3,4];l+h>Fce&&(l=0,u+=c,c=0),s.push({id:`wiz-${r}-${o+d}-${Vce}`,type:f.type,title:f.title,datapoint:f.datapoint.id==="__clock__"?"":f.datapoint.id,layout:n,gridPos:{x:l,y:u,w:h,h:p},options:f.unit?{unit:f.unit}:{}}),c=Math.max(c,p),l+=h}),s}function Qdt(e,t){return e.length===0?[]:[{id:"compact",label:"Kompakt",description:"Mehr Widgets auf einen Blick – kleinere Kacheln",widgets:OD(e,"compact",ND.compact,t)},{id:"standard",label:"Standard",description:"Ausgewogene Darstellung mit gut lesbaren Widgets",widgets:OD(e,"standard",ND.standard,t)},{id:"wide",label:"Großzügig",description:"Große Kacheln – ideal für Wandtablets",widgets:OD(e,"wide",ND.wide,t)}]}const Zc={switch:"#3b82f6",value:"#22c55e",dimmer:"#f59e0b",thermostat:"#ef4444",chart:"#8b5cf6",list:"#06b6d4",clock:"#ec4899",calendar:"#f97316",header:"#94a3b8",group:"#a78bfa",echart:"#10b981",evcc:"#6366f1",weather:"#0ea5e9",gauge:"#f97316",camera:"#6b7280"},cT=["#3b82f6","#22c55e","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#f97316","#84cc16","#a78bfa"];function eht({widgets:e,cols:t=12,groupMapper:r}){const a=240/t,i=e.reduce((l,u)=>Math.max(l,u.gridPos.y+u.gridPos.h),2),o=Math.min(i*a,140),s=I.useMemo(()=>{if(!r)return null;const l=new Map;let u=0;for(const c of e){const f=r(c.datapoint);l.has(f)||(l.set(f,cT[u%cT.length]),u++)}return l},[e,r]);return e.length===0?x.jsx("div",{className:"rounded-lg",style:{width:240,height:80,background:"var(--app-bg)"}}):x.jsx("div",{className:"rounded-lg overflow-hidden shrink-0",style:{width:240,height:o,background:"var(--app-bg)",position:"relative"},children:e.map((l,u)=>{const c=s?s.get(r(l.datapoint))??"var(--accent)":Zc[l.type]??"var(--accent)";return x.jsx("div",{style:{position:"absolute",left:l.gridPos.x*a+1,top:l.gridPos.y*a+1,width:l.gridPos.w*a-2,height:l.gridPos.h*a-2,background:c,opacity:.65,borderRadius:3}},u)})})}const tht=[{label:"Licht",icon:x.jsx(aJ,{size:14})},{label:"Heizung",icon:x.jsx(Af,{size:14})},{label:"Energie",icon:x.jsx(ll,{size:14})},{label:"Klima",icon:x.jsx(nR,{size:14})},{label:"Rolläden",icon:x.jsx(fge,{size:14})},{label:"Steckdosen",icon:x.jsx(EE,{size:14})},{label:"Sicherheit",icon:x.jsx(Tye,{size:14})}],QX={switch:"Schalter",value:"Wert",dimmer:"Dimmer",thermostat:"Thermostat",chart:"Diagramm",list:"Liste",clock:"Uhr",calendar:"Kalender",header:"Abschnitt",group:"Gruppe",echart:"EChart",evcc:"evcc",weather:"Wetter",gauge:"Gauge",camera:"Kamera"};function rht({onAdd:e,onClose:t}){const[r,n]=I.useState("mode"),[a,i]=I.useState("topic"),[o,s]=I.useState(""),[l,u]=I.useState(""),[c,f]=I.useState(new Set),[d,h]=I.useState(""),[p,v]=I.useState("standard"),[g,y]=I.useState("none"),{datapoints:m,loading:b,load:w}=NQ(),_=co(F=>F.frontend.wizardMaxDatapoints??500);I.useEffect(()=>{w(!0)},[w]);const S=I.useMemo(()=>o?$ce(m,o,_):[],[m,o,_]),{sections:C,allWidgets:T}=I.useMemo(()=>a==="homepage"?Zdt(m):{sections:[],allWidgets:[]},[a,m]);I.useEffect(()=>{const F=a==="homepage"?T:S;f(new Set(F.map(W=>W.datapoint.id)))},[S,T,a]);const A=I.useMemo(()=>{if(!d)return S;const F=d.toLowerCase();return S.filter(W=>W.datapoint.name.toLowerCase().includes(F)||W.datapoint.id.toLowerCase().includes(F))},[S,d]),P=(a==="homepage"?T:S).filter(F=>c.has(F.datapoint.id)),M=I.useMemo(()=>P.some(F=>F.datapoint.rooms.length>0),[P]),D=I.useMemo(()=>P.some(F=>F.datapoint.funcs.length>0),[P]),E=M||D;I.useEffect(()=>{g==="room"&&!M&&y("none"),g==="func"&&!D&&y("none")},[M,D,g]);const L=F=>g==="room"?F.datapoint.rooms[0]??"Sonstige":g==="func"?F.datapoint.funcs[0]??"Sonstige":"",N=I.useMemo(()=>{if(g==="none")return new Map;const F=new Map;for(const W of P){const ee=L(W);F.has(ee)||F.set(ee,[]),F.get(ee).push(W)}return F},[P,g]),j=I.useMemo(()=>{const F=new Map;return N.forEach((W,ee)=>W.forEach(Z=>F.set(Z.datapoint.id,ee))),F},[N]),R=g!=="none"&&N.size>=2?F=>j.get(F)??"Sonstige":void 0,z=I.useMemo(()=>Qdt(P,R),[P,R]),B=z.find(F=>F.id===p)??z[0],V=()=>{r==="mode"?n(a==="homepage"?"homepage-review":"topic-input"):r==="topic-input"?n("datapoints"):r==="datapoints"?n(E?"grouping":"layout"):(r==="grouping"||r==="homepage-review")&&n("layout")},$=()=>{r==="layout"?n(a==="homepage"?"homepage-review":E?"grouping":"datapoints"):r==="grouping"?n("datapoints"):r==="datapoints"?n("topic-input"):(r==="topic-input"||r==="homepage-review")&&n("mode")},K=()=>{if(!B||P.length===0)return;const F=l.trim()||(a==="homepage"?"Startseite":o),W=Date.now(),ee=B.widgets.map((Z,U)=>({...Z,id:`wiz-${W}-${U}`}));e(F,ee)},re=a==="homepage"?["mode","homepage-review","layout"]:E?["mode","topic-input","datapoints","grouping","layout"]:["mode","topic-input","datapoints","layout"],ie=re.indexOf(r),ye=r==="mode"||r==="topic-input"&&o.trim().length>0&&(b||S.length>0)||(r==="datapoints"||r==="grouping"||r==="homepage-review")&&P.length>0,je=!!B&&P.length>0;return x.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:t,children:x.jsxs("div",{className:"rounded-2xl w-full max-w-2xl shadow-2xl flex flex-col overflow-hidden",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)",maxHeight:"90vh"},onClick:F=>F.stopPropagation(),children:[x.jsxs("div",{className:"px-6 pt-5 pb-4 shrink-0",style:{borderBottom:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center justify-between mb-3",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(fJ,{size:18,style:{color:"var(--accent)"}}),x.jsx("h2",{className:"font-bold text-lg",style:{color:"var(--text-primary)"},children:"Tab-Wizard"})]}),x.jsx("button",{onClick:t,className:"hover:opacity-70",style:{color:"var(--text-secondary)"},children:x.jsx(gn,{size:18})})]}),x.jsx("div",{className:"flex items-center gap-2",children:re.map((F,W)=>x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:"w-2 h-2 rounded-full transition-colors",style:{background:W<=ie?"var(--accent)":"var(--app-border)"}}),W<re.length-1&&x.jsx("div",{className:"w-6 h-px",style:{background:"var(--app-border)"}})]},F))})]}),b&&x.jsx("div",{className:"h-0.5 shrink-0 overflow-hidden",style:{background:"var(--app-border)"},children:x.jsx("div",{className:"h-full",style:{background:"var(--accent)",animation:"wizard-loading 1.4s ease-in-out infinite"}})}),x.jsx("style",{children:`
609
+ `).length} Zeilen`:"Kein Custom CSS"})]})]})}const Idt=`${window.location.protocol}//${window.location.hostname}:8084`,jdt=_v()(Sv(e=>({ioBrokerUrl:Idt,setIoBrokerUrl:t=>{vwe(),RJ(t),e({ioBrokerUrl:t})}}),{name:"aura-connection"}));async function Rdt(e){const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e));return Array.from(new Uint8Array(t)).map(r=>r.toString(16).padStart(2,"0")).join("")}function zdt({value:e,onChange:t}){return x.jsx("button",{onClick:()=>t(!e),className:"relative w-9 h-5 rounded-full transition-colors duration-200 focus:outline-none shrink-0",style:{background:e?"var(--accent-green)":"var(--app-border)"},children:x.jsx("span",{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full shadow transition-transform duration-200 ${e?"translate-x-4":"translate-x-0"}`})})}function UX({label:e,value:t,onChange:r}){return x.jsxs("div",{className:"flex items-center justify-between py-2 border-b last:border-b-0",style:{borderColor:"var(--app-border)"},children:[x.jsx("p",{className:"text-sm",style:{color:"var(--text-primary)"},children:e}),x.jsx(zdt,{value:t,onChange:r})]})}function Fy({title:e,children:t}){return x.jsxs("div",{className:"rounded-xl p-4 space-y-3",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},children:[x.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest",style:{color:"var(--text-secondary)"},children:e}),t]})}function ED({label:e,value:t,min:r,max:n,step:a,unit:i="",onChange:o,presets:s}){return x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center justify-between mb-1",children:[x.jsx("p",{className:"text-sm",style:{color:"var(--text-primary)"},children:e}),x.jsxs("span",{className:"text-xs font-mono font-bold px-2 py-0.5 rounded-md",style:{background:"var(--app-bg)",color:"var(--accent)",border:"1px solid var(--app-border)"},children:[t,i]})]}),x.jsx("input",{type:"range",min:r,max:n,step:a,value:t,onChange:l=>o(Number(l.target.value)),className:"w-full accent-[var(--accent)] mb-2"}),x.jsx("div",{className:"flex gap-1.5 flex-wrap",children:s.map(l=>{const u=t===l.value;return x.jsx("button",{onClick:()=>o(l.value),className:"px-2.5 py-1 rounded-lg text-xs font-medium hover:opacity-80",style:{background:u?"var(--accent)":"var(--app-bg)",color:u?"#fff":"var(--text-secondary)",border:`1px solid ${u?"var(--accent)":"var(--app-border)"}`},children:l.label},l.value)})})]})}function Bdt(){const{pinHash:e}=od(),{ioBrokerUrl:t,setIoBrokerUrl:r}=jdt(),[n,a]=I.useState(!1),[i,o]=I.useState(""),[s,l]=I.useState(""),[u,c]=I.useState(t),[f,d]=I.useState(!1),h=async v=>{v.preventDefault(),await Rdt(i)===e?(a(!0),l(""),o("")):l("Falscher PIN")},p=async()=>{const v=u.trim();v&&(r(v),await RJ(v),d(!0),setTimeout(()=>d(!1),2500))};return x.jsxs(Fy,{title:"Experten",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[n?x.jsx(tye,{size:14,style:{color:"var(--accent-yellow)"}}):x.jsx(oJ,{size:14,style:{color:"var(--text-secondary)"}}),x.jsx("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:n?"Entsperrt":"Zugang mit Admin-PIN"})]}),n?x.jsxs("div",{className:"space-y-3",children:[x.jsxs("div",{children:[x.jsx("p",{className:"text-xs mb-1",style:{color:"var(--text-secondary)"},children:"ioBroker Web-Adapter URL"}),x.jsxs("div",{className:"flex gap-2",children:[x.jsx("input",{type:"text",value:u,onChange:v=>{c(v.target.value),d(!1)},className:"flex-1 rounded-lg px-3 py-2 text-sm font-mono focus:outline-none min-w-0",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),x.jsxs("button",{onClick:p,disabled:u.trim()===t&&!f,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80 disabled:opacity-40 shrink-0",style:{background:f?"var(--accent-green)":"var(--accent)"},children:[x.jsx(tR,{size:12}),f?"OK":"Verbinden"]})]})]}),x.jsx("button",{onClick:()=>a(!1),className:"text-xs hover:opacity-70",style:{color:"var(--text-secondary)"},children:"Sperren"})]}):x.jsxs("form",{onSubmit:h,className:"flex gap-2",children:[x.jsx("input",{type:"password",value:i,onChange:v=>{o(v.target.value),l("")},placeholder:"Admin-PIN",className:"flex-1 rounded-lg px-3 py-2 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:`1px solid ${s?"var(--accent-red)":"var(--app-border)"}`}}),x.jsx("button",{type:"submit",className:"px-3 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80",style:{background:"var(--accent)"},children:"Entsperren"})]})]})}function $dt(){const e=Cv().tabs,{frontend:t,updateFrontend:r}=co(),[n,a]=I.useState(""),[i,o]=I.useState(""),[s,l]=I.useState(!1),[u,c]=I.useState(""),[f,d]=I.useState(!1),h=g=>{if(g.preventDefault(),n.length<4){c("Mindestens 4 Zeichen");return}if(n!==i){c("PINs stimmen nicht überein");return}zce(n),c("PIN erfolgreich geändert"),a(""),o(""),setTimeout(()=>c(""),3e3)},p=()=>{const g={dashboard:JSON.parse(localStorage.getItem("aura-dashboard")??"{}"),theme:JSON.parse(localStorage.getItem("aura-theme")??"{}"),config:JSON.parse(localStorage.getItem("aura-config")??"{}"),exported:new Date().toISOString()},y=new Blob([JSON.stringify(g,null,2)],{type:"application/json"}),m=URL.createObjectURL(y),b=document.createElement("a");b.href=m,b.download=`aura-backup-${Date.now()}.json`,b.click(),URL.revokeObjectURL(m)},v=g=>{var b;const y=(b=g.target.files)==null?void 0:b[0];if(!y)return;const m=new FileReader;m.onload=w=>{var _;try{const S=JSON.parse((_=w.target)==null?void 0:_.result);S.dashboard&&localStorage.setItem("aura-dashboard",JSON.stringify(S.dashboard)),S.theme&&localStorage.setItem("aura-theme",JSON.stringify(S.theme)),S.config&&localStorage.setItem("aura-config",JSON.stringify(S.config)),window.location.reload()}catch{alert("Ungültige Backup-Datei")}},m.readAsText(y)};return x.jsxs("div",{className:"p-5 max-w-3xl space-y-4",children:[x.jsxs("div",{children:[x.jsx("h1",{className:"text-lg font-bold",style:{color:"var(--text-primary)"},children:"Einstellungen"}),x.jsx("p",{className:"text-xs mt-0.5",style:{color:"var(--text-secondary)"},children:"Frontend, Grid, Sicherheit und Backup"})]}),x.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[x.jsxs(Fy,{title:"Frontend",children:[x.jsx(UX,{label:"Header anzeigen",value:t.showHeader,onChange:g=>r({showHeader:g})}),t.showHeader&&x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"py-2 border-b",style:{borderColor:"var(--app-border)"},children:[x.jsx("p",{className:"text-xs mb-1",style:{color:"var(--text-secondary)"},children:"Dashboard-Titel"}),x.jsx("input",{value:t.headerTitle,onChange:g=>r({headerTitle:g.target.value}),className:"w-full rounded-lg px-3 py-2 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}})]}),x.jsx(UX,{label:"Verbindungsstatus",value:t.showConnectionBadge,onChange:g=>r({showConnectionBadge:g})})]})]}),x.jsxs(Fy,{title:"Grid & Mobil",children:[x.jsx(ED,{label:"Zeilenhöhe",value:t.gridRowHeight??80,min:30,max:160,step:10,unit:" px",onChange:g=>r({gridRowHeight:g}),presets:[{label:"XS·40",value:40},{label:"S·60",value:60},{label:"M·80",value:80},{label:"L·100",value:100},{label:"XL·120",value:120}]}),x.jsx("div",{className:"border-t pt-3",style:{borderColor:"var(--app-border)"},children:x.jsx(ED,{label:"Mobile-Breakpoint",value:t.mobileBreakpoint??600,min:0,max:1024,step:10,unit:" px",onChange:g=>r({mobileBreakpoint:g}),presets:[{label:"480",value:480},{label:"600",value:600},{label:"768",value:768},{label:"Aus",value:0}]})}),x.jsx("div",{className:"border-t pt-3",style:{borderColor:"var(--app-border)"},children:x.jsx(ED,{label:"Wizard Max-Datenpunkte",value:t.wizardMaxDatapoints??500,min:100,max:5e3,step:100,onChange:g=>r({wizardMaxDatapoints:g}),presets:[{label:"200",value:200},{label:"500",value:500},{label:"1k",value:1e3},{label:"2k",value:2e3},{label:"5k",value:5e3}]})})]})]}),x.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[x.jsx(Fy,{title:"Admin-PIN",children:x.jsxs("form",{onSubmit:h,className:"space-y-2",children:[x.jsxs("div",{className:"relative",children:[x.jsx("input",{type:s?"text":"password",value:n,onChange:g=>a(g.target.value),placeholder:"Neuer PIN (min. 4 Zeichen)",className:"w-full rounded-lg px-3 py-2 pr-9 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),x.jsx("button",{type:"button",onClick:()=>l(g=>!g),className:"absolute right-3 top-1/2 -translate-y-1/2",style:{color:"var(--text-secondary)"},children:s?x.jsx(Jj,{size:13}):x.jsx(QZ,{size:13})})]}),x.jsx("input",{type:s?"text":"password",value:i,onChange:g=>o(g.target.value),placeholder:"PIN bestätigen",className:"w-full rounded-lg px-3 py-2 text-sm focus:outline-none",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"}}),u&&x.jsx("p",{className:"text-xs",style:{color:u.includes("erfolgreich")?"var(--accent-green)":"var(--accent-red)"},children:u}),x.jsx("button",{type:"submit",className:"px-4 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80",style:{background:"var(--accent)"},children:"PIN speichern"})]})}),x.jsxs(Fy,{title:"Backup & Restore",children:[x.jsxs("p",{className:"text-xs",style:{color:"var(--text-secondary)"},children:["Dashboard (",e.length," Tab",e.length!==1?"s":"","), Theme und Config als JSON."]}),x.jsxs("div",{className:"flex flex-col gap-2",children:[x.jsx("button",{onClick:p,className:"px-4 py-2 rounded-lg text-sm font-medium text-white hover:opacity-80",style:{background:"var(--accent)"},children:"Download Backup"}),x.jsxs("label",{className:"px-4 py-2 rounded-lg text-sm font-medium text-center cursor-pointer hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"},children:["Backup importieren",x.jsx("input",{type:"file",accept:".json",onChange:v,className:"hidden"})]})]})]})]}),x.jsx(Bdt,{}),x.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--app-surface)",border:"1px solid var(--accent-red)44"},children:[x.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.jsx(Vye,{size:15,style:{color:"var(--accent-red)"}}),x.jsx("p",{className:"text-sm font-semibold",style:{color:"var(--accent-red)"},children:"Alles zurücksetzen"})]}),x.jsx("p",{className:"text-xs mb-3",style:{color:"var(--text-secondary)"},children:"Löscht alle Dashboards, Widgets, Themes und Einstellungen. Nicht rückgängig."}),f?x.jsxs("div",{className:"flex gap-2",children:[x.jsx("button",{onClick:()=>{["aura-dashboard","aura-theme","aura-config"].forEach(g=>localStorage.removeItem(g)),window.location.href="/"},className:"px-3 py-1.5 rounded-lg text-xs font-medium text-white hover:opacity-80",style:{background:"var(--accent-red)"},children:"Ja, alles löschen"}),x.jsx("button",{onClick:()=>d(!1),className:"px-3 py-1.5 rounded-lg text-xs font-medium hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"Abbruch"})]}):x.jsx("button",{onClick:()=>d(!0),className:"px-3 py-1.5 rounded-lg text-xs font-medium hover:opacity-80",style:{background:"var(--accent-red)22",color:"var(--accent-red)",border:"1px solid var(--accent-red)44"},children:"Zurücksetzen…"})]})]})}function Fdt(e,t){if(!e)return t==="boolean"?"switch":"value";const r=e.toLowerCase();return r==="switch"||r==="button"||r.startsWith("switch.")||r==="indicator"?"switch":r.includes("dimmer")||r.includes("brightness")||r==="level"||r.startsWith("level.")?"dimmer":r.includes("temperature")&&r.includes("level")?"thermostat":r.includes("temperature")?"value":t==="boolean"?"switch":"value"}function YX(e){const t=e.common.name;return t?typeof t=="string"?t:t.de??t.en??Object.values(t)[0]??e._id:e._id.split(".").pop()??e._id}function XX(e){const t=e.split(".");return t.length>=2?`${t[0]}.${t[1]}`:t[0]}function Bce(){const{getObjectView:e}=Vn(),[t,r]=I.useState([]),[n,a]=I.useState(!1),[i,o]=I.useState(!1),s=I.useCallback(async()=>{a(!0);try{const[l,u,c]=await Promise.all([e("device"),e("channel"),e("state")]),f=new Map;for(const{value:p}of c.rows){if(!p)continue;const g=p._id.split(".").slice(0,-1).join(".");f.has(g)||f.set(g,[]),f.get(g).push({id:p._id,obj:p,suggestedWidget:Fdt(p.common.role,p.common.type),unit:p.common.unit})}const d=[];for(const{value:p}of l.rows){if(!p)continue;const v=[];for(const[g,y]of f.entries())(g===p._id||g.startsWith(p._id+"."))&&v.push(...y);v.length!==0&&d.push({id:p._id,name:YX(p),adapter:XX(p._id),states:v})}const h=new Set(d.map(p=>p.id));for(const{value:p}of u.rows){if(!p)continue;const g=p._id.split(".").slice(0,-1).join(".");if(h.has(g))continue;const y=f.get(p._id)??[];y.length!==0&&d.push({id:p._id,name:YX(p),adapter:XX(p._id),states:y})}d.sort((p,v)=>p.adapter.localeCompare(v.adapter)||p.name.localeCompare(v.name)),r(d),o(!0)}finally{a(!1)}},[e]);return{devices:t,loading:n,loaded:i,load:s}}const Vdt={switch:x.jsx(ll,{size:13}),value:x.jsx(lf,{size:13}),dimmer:x.jsx(uJ,{size:13}),thermostat:x.jsx(Af,{size:13}),chart:x.jsx(Cu,{size:13}),list:x.jsx(iJ,{size:13}),clock:x.jsx(ZZ,{size:13}),calendar:x.jsx(Vm,{size:13}),header:x.jsx(rJ,{size:13}),group:x.jsx(Qj,{size:13}),echart:x.jsx(Cu,{size:13}),evcc:x.jsx(ll,{size:13}),weather:x.jsx(Mge,{size:13}),gauge:x.jsx($ge,{size:13}),camera:x.jsx(R_,{size:13})},Wdt={switch:{t:"Wohnzimmer",v:"AN"},value:{t:"Temperatur",v:"21.5",u:"°C"},dimmer:{t:"Licht",v:"75",u:"%"},thermostat:{t:"Heizung",v:"21.0",sub:"Ist: 19.5°"},chart:{t:"Verbrauch",v:"245",u:"W"},list:{t:"Alle Geräte",v:""},clock:{t:"Uhrzeit",v:"12:34"},calendar:{t:"Kalender",v:"3"},header:{t:"Abschnitt",v:""},group:{t:"Gruppe",v:""},echart:{t:"EChart",v:""},evcc:{t:"evcc",v:""},weather:{t:"Wetter",v:"18°",sub:"⛅ Bewölkt"},gauge:{t:"Gauge",v:"72",u:"kW"},camera:{t:"Kamera",v:""}};function Aw({on:e}){return x.jsx("div",{className:"relative w-8 h-4 rounded-full shrink-0",style:{background:e!==!1?"var(--accent-green)":"var(--app-border)"},children:x.jsx("span",{className:"absolute top-0.5 w-3 h-3 bg-white rounded-full shadow",style:{left:e!==!1?"18px":"2px",transition:"left 0.15s"}})})}function Hdt({type:e,layout:t,title:r}){const n=Wdt[e],a=r||n.t,i=Vdt[e];if(e==="clock")return t==="minimal"||t==="card"?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-0.5",children:[x.jsx("p",{className:"text-3xl font-black tabular-nums leading-none",style:{color:"var(--accent)"},children:"12:34"}),t==="card"&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"07.04.2026"})]}):t==="compact"?x.jsxs("div",{className:"flex items-center gap-2 h-full",children:[x.jsx("p",{className:"text-xl font-bold tabular-nums",style:{color:"var(--text-primary)"},children:"12:34"}),x.jsx("span",{style:{color:"var(--app-border)"},children:"·"}),x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Mo., 7. Apr."})]}):x.jsxs("div",{className:"flex flex-col h-full justify-between",children:[x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:a}),x.jsxs("div",{children:[x.jsx("p",{className:"text-2xl font-bold tabular-nums",style:{color:"var(--text-primary)"},children:"12:34"}),x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"07.04.2026"})]})]});if(e==="calendar"){const o=[{label:"Team-Meeting",date:"Heute, 10:00",dot:"var(--accent)"},{label:"Zahnarzt",date:"Morgen, 14:30",dot:"var(--accent-green)"},{label:"Geburtstag Lisa",date:"Mi, 9. Apr",dot:"var(--accent-yellow)"}];return t==="minimal"||t==="card"?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[x.jsx("p",{className:"text-3xl font-black leading-none",style:{color:"var(--accent)"},children:"3"}),x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Termine"})]}):t==="compact"?x.jsxs("div",{className:"flex items-center gap-2 h-full",children:[x.jsx(Vm,{size:16,style:{color:"var(--accent)"}}),x.jsxs("div",{children:[x.jsx("p",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Team-Meeting"}),x.jsx("p",{className:"text-[10px]",style:{color:"var(--accent)"},children:"Heute, 10:00"})]})]}):t==="agenda"?x.jsxs("div",{className:"flex flex-col h-full gap-0.5",children:[x.jsx("p",{className:"text-[11px] font-medium mb-0.5",style:{color:"var(--text-secondary)"},children:a}),o.map((s,l)=>x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("div",{className:"w-0.5 self-stretch rounded-full shrink-0",style:{background:s.dot}}),x.jsxs("span",{className:"text-[8px] w-8 truncate shrink-0",style:{color:s.dot},children:["Cal ",l+1]}),x.jsx("p",{className:"flex-1 text-[9px] font-medium truncate",style:{color:"var(--text-primary)"},children:s.label}),x.jsx("p",{className:"text-[8px] shrink-0",style:{color:"var(--text-secondary)"},children:s.date.split(", ")[1]??s.date})]},l))]}):x.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[x.jsx("p",{className:"text-[11px] font-medium",style:{color:"var(--text-secondary)"},children:a}),o.map((s,l)=>x.jsxs("div",{className:"flex items-start gap-1.5",children:[x.jsx("div",{className:"w-1.5 h-1.5 rounded-full mt-1 shrink-0",style:{background:s.dot}}),x.jsxs("div",{children:[x.jsx("p",{className:"text-[10px] font-medium leading-tight",style:{color:"var(--text-primary)"},children:s.label}),x.jsx("p",{className:"text-[9px]",style:{color:"var(--text-secondary)"},children:s.date})]})]},l))]})}if(e==="weather")return t==="minimal"?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[x.jsx("span",{style:{fontSize:"2rem",lineHeight:1},children:"⛅"}),x.jsx("span",{className:"text-2xl font-black",style:{color:"var(--text-primary)"},children:"18°"})]}):t==="compact"?x.jsxs("div",{className:"flex items-center gap-2 h-full",children:[x.jsx("span",{style:{fontSize:"1.4rem",lineHeight:1},children:"⛅"}),x.jsx("span",{className:"text-xl font-bold",style:{color:"var(--text-primary)"},children:"18°"}),x.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"Bewölkt"})]}):x.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[x.jsxs("div",{className:"flex items-start gap-2",children:[x.jsx("span",{style:{fontSize:"1.8rem",lineHeight:1},children:"⛅"}),x.jsxs("div",{children:[x.jsx("span",{className:"text-2xl font-black",style:{color:"var(--text-primary)"},children:"18°"}),x.jsx("span",{className:"text-[11px] ml-1",style:{color:"var(--text-secondary)"},children:"Bewölkt"}),x.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:"Gefühlt 15°"})]})]}),x.jsxs("div",{className:"text-[10px] flex gap-2",style:{color:"var(--text-secondary)"},children:[x.jsx("span",{children:"💧 65%"}),x.jsx("span",{children:"💨 12 km/h"})]}),x.jsx("div",{className:"flex gap-1 pt-1",style:{borderTop:"1px solid var(--app-border)"},children:[["Mo","☁️","18°"],["Di","🌧️","15°"],["Mi","☀️","22°"]].map(([o,s,l])=>x.jsxs("div",{className:"flex-1 flex flex-col items-center",style:{fontSize:"9px",color:"var(--text-secondary)"},children:[x.jsx("span",{children:o}),x.jsx("span",{style:{fontSize:"11px"},children:s}),x.jsx("span",{style:{color:"var(--text-primary)",fontWeight:"bold"},children:l})]},o))})]});if(e==="gauge")return x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",children:[x.jsxs("svg",{viewBox:"0 0 200 120",style:{width:120,height:72},children:[x.jsx("path",{d:"M 20 100 A 80 80 0 0 1 180 100",fill:"none",stroke:"var(--app-border)",strokeWidth:12,strokeLinecap:"round"}),x.jsx("path",{d:"M 20 100 A 80 80 0 0 1 131.13 33.57",fill:"none",stroke:"var(--accent)",strokeWidth:12,strokeLinecap:"round"}),x.jsx("text",{x:100,y:95,textAnchor:"middle",fontSize:22,fontWeight:"bold",fill:"var(--text-primary)",children:"72"}),x.jsx("text",{x:100,y:110,textAnchor:"middle",fontSize:10,fill:"var(--text-secondary)",children:n.u})]}),a&&x.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:a})]});if(e==="camera")return x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1",style:{background:"var(--app-bg)",borderRadius:4},children:[x.jsx(R_,{size:20,style:{color:"var(--text-secondary)"}}),x.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:a})]});if(e==="chart"){const o=[40,60,45,75,55,80,65,90,70];return x.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[x.jsx("p",{className:"text-[11px] truncate",style:{color:"var(--text-secondary)"},children:a}),x.jsx("div",{className:"flex-1 flex items-end gap-0.5",children:o.map((s,l)=>x.jsx("div",{className:"flex-1 rounded-sm",style:{height:`${s}%`,background:l===o.length-1?"var(--accent)":"color-mix(in srgb, var(--accent) 45%, transparent)"}},l))}),x.jsxs("p",{className:"text-[11px] font-bold",style:{color:"var(--text-primary)"},children:[n.v,n.u&&x.jsxs("span",{style:{color:"var(--text-secondary)",fontWeight:400},children:[" ",n.u]})]})]})}return e==="list"?x.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[x.jsx("p",{className:"text-[11px] font-medium truncate",style:{color:"var(--text-secondary)"},children:a}),["Gerät 1","Gerät 2","Gerät 3"].map((o,s)=>x.jsxs("div",{className:"flex items-center justify-between px-1.5 py-0.5 rounded",style:{background:"var(--app-bg)"},children:[x.jsx("span",{className:"text-[10px]",style:{color:"var(--text-primary)"},children:o}),x.jsx(Aw,{on:s===0})]},s))]}):t==="card"?e==="switch"?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 rounded-md",style:{background:"color-mix(in srgb, var(--accent-green) 20%, transparent)"},children:[x.jsx(ll,{size:26,style:{color:"var(--accent-green)"}}),x.jsx("p",{className:"text-[11px] font-bold",style:{color:"var(--text-primary)"},children:a}),x.jsx("p",{className:"text-[10px]",style:{color:"var(--accent-green)"},children:"AN"})]}):x.jsxs("div",{className:"flex flex-col h-full justify-between",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("p",{className:"text-[11px] truncate",style:{color:"var(--text-secondary)"},children:a}),x.jsx("span",{style:{color:"var(--accent)"},children:i})]}),x.jsxs("div",{children:[x.jsx("p",{className:"text-3xl font-black leading-none",style:{color:"var(--accent)"},children:n.v}),n.u&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:n.u})]})]}):t==="compact"?x.jsxs("div",{className:"flex items-center gap-2 h-full",children:[x.jsx("span",{style:{color:"var(--text-secondary)",flexShrink:0},children:i}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("p",{className:"text-[10px] truncate",style:{color:"var(--text-secondary)"},children:a}),x.jsxs("p",{className:"text-base font-bold leading-tight",style:{color:"var(--text-primary)"},children:[n.v,n.u&&x.jsx("span",{className:"text-[10px] font-normal ml-0.5",style:{color:"var(--text-secondary)"},children:n.u})]})]}),e==="switch"&&x.jsx(Aw,{}),e==="thermostat"&&x.jsxs("div",{className:"flex gap-0.5 shrink-0",children:[x.jsx("span",{className:"w-5 h-5 rounded text-[10px] font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"−"}),x.jsx("span",{className:"w-5 h-5 rounded text-[10px] font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"+"})]}),e==="dimmer"&&x.jsx("div",{className:"w-14 h-2 rounded-full overflow-hidden shrink-0",style:{background:"var(--app-border)"},children:x.jsx("div",{className:"h-full rounded-full",style:{width:"75%",background:"var(--accent)"}})})]}):t==="minimal"?e==="switch"?x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-1.5",children:[x.jsx(Aw,{}),x.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:a})]}):x.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-0.5",children:[x.jsx("p",{className:"text-3xl font-black leading-none",style:{color:"var(--accent)"},children:n.v}),n.u&&x.jsx("p",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:n.u}),x.jsx("p",{className:"text-[10px] mt-1",style:{color:"var(--text-secondary)"},children:a})]}):x.jsxs("div",{className:"flex flex-col h-full justify-between",children:[x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("span",{style:{color:"var(--text-secondary)"},children:i}),x.jsx("p",{className:"text-[11px] truncate",style:{color:"var(--text-secondary)"},children:a})]}),x.jsx("div",{children:e==="switch"?x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("span",{className:"text-xl font-bold",style:{color:"var(--accent-green)"},children:"AN"}),x.jsx(Aw,{})]}):e==="thermostat"?x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsxs("div",{children:[x.jsxs("p",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:[n.v,"°"]}),n.sub&&x.jsx("p",{className:"text-[10px]",style:{color:"var(--text-secondary)"},children:n.sub})]}),x.jsxs("div",{className:"flex flex-col gap-0.5",children:[x.jsx("span",{className:"w-6 h-6 rounded text-sm font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"+"}),x.jsx("span",{className:"w-6 h-6 rounded text-sm font-bold flex items-center justify-center",style:{background:"var(--app-border)",color:"var(--text-primary)"},children:"−"})]})]}):e==="dimmer"?x.jsxs("div",{children:[x.jsxs("p",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:[n.v,x.jsx("span",{className:"text-sm ml-0.5",style:{color:"var(--text-secondary)"},children:n.u})]}),x.jsx("div",{className:"w-full h-2 mt-1 rounded-full overflow-hidden",style:{background:"var(--app-border)"},children:x.jsx("div",{className:"h-full rounded-full",style:{width:"75%",background:"var(--accent)"}})})]}):x.jsxs("div",{className:"flex items-end gap-1",children:[x.jsx("span",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:n.v}),n.u&&x.jsx("span",{className:"text-xs mb-0.5",style:{color:"var(--text-secondary)"},children:n.u})]})})]})}function mx({type:e,layout:t="default",title:r}){return x.jsx("div",{className:"rounded-lg overflow-hidden shrink-0 relative",style:{width:Math.round(200*.62),height:Math.round(140*.62),background:"var(--widget-bg)",border:"1px solid var(--app-border)"},children:x.jsx("div",{style:{position:"absolute",top:0,left:0,width:200,height:140,transform:`scale(${.62})`,transformOrigin:"top left",padding:14,boxSizing:"border-box",pointerEvents:"none"},children:x.jsx(Hdt,{type:e,layout:t,title:r??""})})})}const qX={switch:"Schalter",value:"Wert",dimmer:"Dimmer",thermostat:"Thermostat",chart:"Diagramm",list:"Gruppenliste",clock:"Uhrzeit",calendar:"Kalender",header:"Abschnittstitel",group:"Gruppe",echart:"EChart",evcc:"evcc",weather:"Wetter",gauge:"Gauge",camera:"Kamera"},vy={background:"var(--app-bg)",color:"var(--text-primary)",border:"1px solid var(--app-border)"};function Gdt({onAdd:e,onClose:t}){const{devices:r,loading:n,loaded:a,load:i}=Bce(),[o,s]=I.useState(""),[l,u]=I.useState(""),[c,f]=I.useState(null),[d,h]=I.useState(new Map),p=I.useMemo(()=>Array.from(new Set(r.map(b=>b.adapter))).sort(),[r]),v=I.useMemo(()=>r.filter(b=>{if(l&&b.adapter!==l)return!1;if(o){const w=o.toLowerCase();return b.name.toLowerCase().includes(w)||b.id.toLowerCase().includes(w)||b.states.some(_=>_.id.toLowerCase().includes(w))}return!0}),[r,o,l]),g=(b,w)=>{h(_=>{const S=new Map(_);return S.has(w.id)?S.delete(w.id):S.set(w.id,{state:w,device:b,widgetType:w.suggestedWidget,title:`${b.name} – ${w.obj._id.split(".").pop()}`}),S})},y=(b,w)=>h(_=>{const S=new Map(_),C=S.get(b);return C&&S.set(b,{...C,...w}),S}),m=()=>{e(Array.from(d.values()).map((b,w)=>({id:`${b.widgetType}-${Date.now()}-${w}`,type:b.widgetType,title:b.title,datapoint:b.state.id,gridPos:{x:w*2%12,y:1/0,w:b.widgetType==="chart"?4:2,h:b.widgetType==="chart"?3:2},options:{...b.state.unit?{unit:b.state.unit}:{},...b.actualDatapoint?{actualDatapoint:b.actualDatapoint}:{}}}))),t()};return x.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:t,children:x.jsxs("div",{className:"rounded-xl w-full max-w-3xl max-h-[85vh] flex flex-col shadow-2xl",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)"},onClick:b=>b.stopPropagation(),children:[x.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderBottom:"1px solid var(--app-border)"},children:[x.jsx("h2",{className:"font-bold text-lg",style:{color:"var(--text-primary)"},children:"Geräte aus ioBroker"}),x.jsx("button",{onClick:t,className:"hover:opacity-60",style:{color:"var(--text-secondary)"},children:"✕"})]}),a?x.jsxs(x.Fragment,{children:[x.jsxs("div",{className:"flex gap-3 px-6 py-3",style:{borderBottom:"1px solid var(--app-border)"},children:[x.jsx("input",{value:o,onChange:b=>s(b.target.value),placeholder:"Suchen…",className:"flex-1 rounded-lg px-3 py-1.5 text-sm focus:outline-none",style:{...vy,outlineColor:"var(--accent)"}}),x.jsxs("select",{value:l,onChange:b=>u(b.target.value),className:"rounded-lg px-3 py-1.5 text-sm",style:vy,children:[x.jsx("option",{value:"",children:"Alle Adapter"}),p.map(b=>x.jsx("option",{value:b,children:b},b))]}),x.jsxs("span",{className:"text-sm self-center whitespace-nowrap",style:{color:"var(--text-secondary)"},children:[v.length," Geräte"]})]}),x.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-3 space-y-2",children:v.map(b=>{const w=Array.from(d.values()).filter(_=>_.device.id===b.id).length;return x.jsxs("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--app-border)"},children:[x.jsxs("button",{className:"w-full flex items-center justify-between px-4 py-3 text-left hover:opacity-80 transition-opacity",style:{background:"var(--app-bg)"},onClick:()=>f(c===b.id?null:b.id),children:[x.jsxs("div",{children:[x.jsx("p",{className:"font-medium text-sm",style:{color:"var(--text-primary)"},children:b.name}),x.jsx("p",{className:"text-xs font-mono",style:{color:"var(--text-secondary)"},children:b.id})]}),x.jsxs("div",{className:"flex items-center gap-3",children:[w>0&&x.jsx("span",{className:"px-2 py-0.5 text-xs text-white rounded-full",style:{background:"var(--accent)"},children:w}),x.jsxs("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:[b.states.length," DP ",c===b.id?"▲":"▼"]})]})]}),c===b.id&&b.states.map(_=>{const S=d.get(_.id);return x.jsxs("div",{children:[x.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 cursor-pointer transition-opacity hover:opacity-80",style:{background:S?"var(--accent)11":"var(--app-surface)",borderTop:"1px solid var(--app-border)"},onClick:()=>g(b,_),children:[x.jsx("input",{type:"checkbox",checked:!!S,readOnly:!0,style:{accentColor:"var(--accent)"},className:"w-4 h-4 shrink-0"}),x.jsxs("div",{className:"flex-1 min-w-0",children:[x.jsx("p",{className:"text-sm font-mono truncate",style:{color:"var(--text-primary)"},children:_.id.split(".").pop()}),x.jsx("p",{className:"text-xs truncate",style:{color:"var(--text-secondary)"},children:_.id})]}),x.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[_.unit&&x.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:_.unit}),S?x.jsx("select",{value:S.widgetType,onClick:C=>C.stopPropagation(),onChange:C=>y(_.id,{widgetType:C.target.value}),className:"text-xs rounded px-2 py-1",style:vy,children:Object.entries(qX).map(([C,T])=>x.jsx("option",{value:C,children:T},C))}):x.jsx("span",{className:"text-xs",style:{color:"var(--text-secondary)"},children:qX[_.suggestedWidget]})]})]}),S&&x.jsxs("div",{className:"px-4 pb-3 pt-2 flex gap-3 items-start",style:{background:"var(--accent)08",borderTop:"1px solid var(--app-border)"},onClick:C=>C.stopPropagation(),children:[x.jsxs("div",{className:"flex-1 space-y-2 min-w-0",children:[x.jsx("input",{value:S.title,onChange:C=>y(_.id,{title:C.target.value}),placeholder:"Titel",className:"w-full text-xs rounded px-2 py-1.5 focus:outline-none",style:vy}),S.widgetType==="thermostat"&&x.jsx("input",{value:S.actualDatapoint??"",onChange:C=>y(_.id,{actualDatapoint:C.target.value}),placeholder:"Ist-Temperatur Datenpunkt (optional)",className:"w-full text-xs rounded px-2 py-1.5 focus:outline-none",style:vy})]}),x.jsx(mx,{type:S.widgetType,title:S.title})]})]},_.id)})]},b.id)})}),x.jsxs("div",{className:"flex items-center justify-between px-6 py-4",style:{borderTop:"1px solid var(--app-border)"},children:[x.jsx("span",{className:"text-sm",style:{color:"var(--text-secondary)"},children:d.size===0?"Keine ausgewählt":`${d.size} Widget${d.size!==1?"s":""}`}),x.jsxs("div",{className:"flex gap-2",children:[x.jsx("button",{onClick:t,className:"px-4 py-2 text-sm rounded-lg hover:opacity-80",style:{background:"var(--app-bg)",color:"var(--text-secondary)",border:"1px solid var(--app-border)"},children:"Abbruch"}),x.jsx("button",{onClick:m,disabled:d.size===0,className:"px-4 py-2 text-sm font-medium text-white rounded-lg hover:opacity-80 disabled:opacity-30",style:{background:"var(--accent)"},children:"Zum Dashboard hinzufügen"})]})]})]}):x.jsx("div",{className:"flex flex-col items-center justify-center flex-1 gap-4 py-12",children:n?x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"w-8 h-8 border-2 border-t-transparent rounded-full animate-spin",style:{borderColor:"var(--accent)",borderTopColor:"transparent"}}),x.jsx("p",{className:"text-sm",style:{color:"var(--text-secondary)"},children:"Lade Geräte…"})]}):x.jsxs(x.Fragment,{children:[x.jsx("p",{style:{color:"var(--text-secondary)"},children:"Alle verfügbaren Geräte und Datenpunkte laden"}),x.jsx("button",{onClick:i,className:"px-6 py-2 text-white rounded-lg font-medium hover:opacity-80",style:{background:"var(--accent)"},children:"Geräte laden"})]})})]})})}function Udt(e){const t=(e.role??"").toLowerCase(),r=e.name.toLowerCase(),n=e.unit??"";return t.includes("thermostat")||t.includes("temp.set")||r.includes("solltemp")||r.includes("setpoint")?{type:"thermostat"}:t.includes("temperature")||r.includes("temperatur")||n==="°C"?{type:"value",unit:n||"°C"}:t.includes("level.dimmer")||t.includes("level.brightness")||r.includes("dimmer")||r.includes("helligkeit")?{type:"dimmer"}:n==="W"||n==="VA"||t.includes("value.power")?{type:"value",unit:n}:n==="kWh"||t.includes("value.energy")?{type:"value",unit:n}:n==="%"&&(t.includes("level")||r.includes("rollade")||r.includes("rollo")||r.includes("jalousie")||r.includes("shutter")||r.includes("blind"))?{type:"dimmer",unit:"%"}:n==="%"&&(t.includes("humid")||r.includes("feuchte"))?{type:"value",unit:"%"}:e.type==="boolean"||t.includes("switch")||t.includes("button")?{type:"switch"}:e.type==="number"?{type:"value",unit:n||void 0}:{type:"value"}}function HI(e){return e.toLowerCase().trim()}function KX(e,t){const r=HI(t);for(const n of e){const a=HI(n);if(a===r)return 1;if(a.includes(r)||r.includes(a))return .85}return 0}const ZX={licht:["light","lamp","lampe","led","leuchte","beleuchtung","dimmer","bulb","switch"],heizung:["heiz","heat","thermostat","radiator","boiler","solltemp","setpoint"],temperatur:["temp","temperature","celsius","klima","grad"],steckdose:["socket","outlet","plug","stecker","dose"],rollade:["shutter","blind","rolladen","jalousie","vorhang","curtain","rollo","level"],energie:["energy","power","strom","verbrauch","watt","kwh","leistung"],sicherheit:["security","alarm","door","window","motion","contact","tür","fenster"],klima:["climate","ac","klimaanlage","luft","humidity","feuchte","lüftung"]};function Ydt(e,t){const r=HI(t),n=e.name.toLowerCase(),a=e.id.toLowerCase(),i=(e.role??"").toLowerCase();if(n.includes(r)||i.includes(r))return .75;if(a.split(".").some(s=>s===r))return .7;if(a.includes(r))return .6;const o=ZX[r]??[];for(const s of o)if(n.includes(s)||i.includes(s)||a.includes(s))return .65;for(const[,s]of Object.entries(ZX))if(s.includes(r)&&s.some(l=>n.includes(l)||i.includes(l)))return .5;return 0}function Xdt(e,t){const r=KX(e.funcs,t);if(r>0)return r;const n=KX(e.rooms,t);return n>0?n:Ydt(e,t)}function qdt(e){return e.name&&e.name!==e.id.split(".").pop()?e.name:e.id.split(".").slice(-2).join(" › ")}function $ce(e,t,r=500){const n=[];for(const a of e){const i=Xdt(a,t);if(i===0)continue;const{type:o,unit:s}=Udt(a);n.push({datapoint:a,type:o,title:qdt(a),unit:s,score:i})}return n.sort((a,i)=>i.score-a.score).slice(0,r)}const Kdt=[{topic:"temperatur",max:4,label:"Temperatur"},{topic:"licht",max:5,label:"Licht"},{topic:"energie",max:3,label:"Energie"},{topic:"heizung",max:3,label:"Heizung"},{topic:"klima",max:2,label:"Klima"},{topic:"rollade",max:3,label:"Rolläden"},{topic:"sicherheit",max:3,label:"Sicherheit"}];function Zdt(e){const t=new Set,r=[],n={datapoint:{id:"__clock__",name:"Uhrzeit",rooms:[],funcs:[]},type:"clock",title:"Uhrzeit",score:1};r.push({label:"Uhrzeit",widgets:[n]}),t.add("__clock__");for(const{topic:a,max:i,label:o}of Kdt){const s=$ce(e,a,i*10).filter(l=>!t.has(l.datapoint.id)).slice(0,i);s.length!==0&&(s.forEach(l=>t.add(l.datapoint.id)),r.push({label:o,widgets:s}))}return{sections:r,allWidgets:r.flatMap(a=>a.widgets)}}const Jdt={compact:{switch:[2,3],value:[3,3],dimmer:[3,4],thermostat:[4,4],chart:[6,4],list:[4,4],clock:[4,3],calendar:[6,4]},standard:{switch:[2,4],value:[3,4],dimmer:[3,5],thermostat:[4,5],chart:[6,5],list:[4,5],clock:[5,4],calendar:[6,5]},wide:{switch:[3,5],value:[4,5],dimmer:[4,6],thermostat:[5,6],chart:[8,5],list:[5,6],clock:[6,4],calendar:[8,6]}},ND={compact:"card",standard:"default",wide:"card"},Fce=12,Vce=Date.now();function OD(e,t,r,n){const a=Jdt[t];if(!n)return JX(e,a,t,r,0,0);const i=new Map,o=[];for(const c of e){const f=n(c.datapoint.id);i.has(f)||(i.set(f,[]),o.push(f)),i.get(f).push(c)}const s=[];let l=0,u=0;for(const c of o){s.push({id:`wiz-header-${u}-${Vce}`,type:"header",title:c,datapoint:"",layout:"default",gridPos:{x:0,y:l,w:Fce,h:1},options:{}}),l+=1,u+=1;const f=i.get(c),d=JX(f,a,t,r,0,l,u);s.push(...d),u+=d.length,l=d.reduce((p,v)=>Math.max(p,v.gridPos.y+v.gridPos.h),l)+1}return s}function JX(e,t,r,n,a,i,o=0){const s=[];let l=a,u=i,c=0;return e.forEach((f,d)=>{const[h,p]=t[f.type]??[3,4];l+h>Fce&&(l=0,u+=c,c=0),s.push({id:`wiz-${r}-${o+d}-${Vce}`,type:f.type,title:f.title,datapoint:f.datapoint.id==="__clock__"?"":f.datapoint.id,layout:n,gridPos:{x:l,y:u,w:h,h:p},options:f.unit?{unit:f.unit}:{}}),c=Math.max(c,p),l+=h}),s}function Qdt(e,t){return e.length===0?[]:[{id:"compact",label:"Kompakt",description:"Mehr Widgets auf einen Blick – kleinere Kacheln",widgets:OD(e,"compact",ND.compact,t)},{id:"standard",label:"Standard",description:"Ausgewogene Darstellung mit gut lesbaren Widgets",widgets:OD(e,"standard",ND.standard,t)},{id:"wide",label:"Großzügig",description:"Große Kacheln – ideal für Wandtablets",widgets:OD(e,"wide",ND.wide,t)}]}const Zc={switch:"#3b82f6",value:"#22c55e",dimmer:"#f59e0b",thermostat:"#ef4444",chart:"#8b5cf6",list:"#06b6d4",clock:"#ec4899",calendar:"#f97316",header:"#94a3b8",group:"#a78bfa",echart:"#10b981",evcc:"#6366f1",weather:"#0ea5e9",gauge:"#f97316",camera:"#6b7280"},cT=["#3b82f6","#22c55e","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#f97316","#84cc16","#a78bfa"];function eht({widgets:e,cols:t=12,groupMapper:r}){const a=240/t,i=e.reduce((l,u)=>Math.max(l,u.gridPos.y+u.gridPos.h),2),o=Math.min(i*a,140),s=I.useMemo(()=>{if(!r)return null;const l=new Map;let u=0;for(const c of e){const f=r(c.datapoint);l.has(f)||(l.set(f,cT[u%cT.length]),u++)}return l},[e,r]);return e.length===0?x.jsx("div",{className:"rounded-lg",style:{width:240,height:80,background:"var(--app-bg)"}}):x.jsx("div",{className:"rounded-lg overflow-hidden shrink-0",style:{width:240,height:o,background:"var(--app-bg)",position:"relative"},children:e.map((l,u)=>{const c=s?s.get(r(l.datapoint))??"var(--accent)":Zc[l.type]??"var(--accent)";return x.jsx("div",{style:{position:"absolute",left:l.gridPos.x*a+1,top:l.gridPos.y*a+1,width:l.gridPos.w*a-2,height:l.gridPos.h*a-2,background:c,opacity:.65,borderRadius:3}},u)})})}const tht=[{label:"Licht",icon:x.jsx(aJ,{size:14})},{label:"Heizung",icon:x.jsx(Af,{size:14})},{label:"Energie",icon:x.jsx(ll,{size:14})},{label:"Klima",icon:x.jsx(nR,{size:14})},{label:"Rolläden",icon:x.jsx(fge,{size:14})},{label:"Steckdosen",icon:x.jsx(EE,{size:14})},{label:"Sicherheit",icon:x.jsx(Tye,{size:14})}],QX={switch:"Schalter",value:"Wert",dimmer:"Dimmer",thermostat:"Thermostat",chart:"Diagramm",list:"Liste",clock:"Uhr",calendar:"Kalender",header:"Abschnitt",group:"Gruppe",echart:"EChart",evcc:"evcc",weather:"Wetter",gauge:"Gauge",camera:"Kamera"};function rht({onAdd:e,onClose:t}){const[r,n]=I.useState("mode"),[a,i]=I.useState("topic"),[o,s]=I.useState(""),[l,u]=I.useState(""),[c,f]=I.useState(new Set),[d,h]=I.useState(""),[p,v]=I.useState("standard"),[g,y]=I.useState("none"),{datapoints:m,loading:b,load:w}=NQ(),_=co(F=>F.frontend.wizardMaxDatapoints??500);I.useEffect(()=>{w(!0)},[w]);const S=I.useMemo(()=>o?$ce(m,o,_):[],[m,o,_]),{sections:C,allWidgets:T}=I.useMemo(()=>a==="homepage"?Zdt(m):{sections:[],allWidgets:[]},[a,m]);I.useEffect(()=>{const F=a==="homepage"?T:S;f(new Set(F.map(W=>W.datapoint.id)))},[S,T,a]);const A=I.useMemo(()=>{if(!d)return S;const F=d.toLowerCase();return S.filter(W=>W.datapoint.name.toLowerCase().includes(F)||W.datapoint.id.toLowerCase().includes(F))},[S,d]),P=(a==="homepage"?T:S).filter(F=>c.has(F.datapoint.id)),M=I.useMemo(()=>P.some(F=>F.datapoint.rooms.length>0),[P]),D=I.useMemo(()=>P.some(F=>F.datapoint.funcs.length>0),[P]),E=M||D;I.useEffect(()=>{g==="room"&&!M&&y("none"),g==="func"&&!D&&y("none")},[M,D,g]);const L=F=>g==="room"?F.datapoint.rooms[0]??"Sonstige":g==="func"?F.datapoint.funcs[0]??"Sonstige":"",N=I.useMemo(()=>{if(g==="none")return new Map;const F=new Map;for(const W of P){const ee=L(W);F.has(ee)||F.set(ee,[]),F.get(ee).push(W)}return F},[P,g]),j=I.useMemo(()=>{const F=new Map;return N.forEach((W,ee)=>W.forEach(Z=>F.set(Z.datapoint.id,ee))),F},[N]),R=g!=="none"&&N.size>=2?F=>j.get(F)??"Sonstige":void 0,z=I.useMemo(()=>Qdt(P,R),[P,R]),B=z.find(F=>F.id===p)??z[0],V=()=>{r==="mode"?n(a==="homepage"?"homepage-review":"topic-input"):r==="topic-input"?n("datapoints"):r==="datapoints"?n(E?"grouping":"layout"):(r==="grouping"||r==="homepage-review")&&n("layout")},$=()=>{r==="layout"?n(a==="homepage"?"homepage-review":E?"grouping":"datapoints"):r==="grouping"?n("datapoints"):r==="datapoints"?n("topic-input"):(r==="topic-input"||r==="homepage-review")&&n("mode")},K=()=>{if(!B||P.length===0)return;const F=l.trim()||(a==="homepage"?"Startseite":o),W=Date.now(),ee=B.widgets.map((Z,U)=>({...Z,id:`wiz-${W}-${U}`}));e(F,ee)},re=a==="homepage"?["mode","homepage-review","layout"]:E?["mode","topic-input","datapoints","grouping","layout"]:["mode","topic-input","datapoints","layout"],ie=re.indexOf(r),ye=r==="mode"||r==="topic-input"&&o.trim().length>0&&(b||S.length>0)||(r==="datapoints"||r==="grouping"||r==="homepage-review")&&P.length>0,je=!!B&&P.length>0;return x.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",onClick:t,children:x.jsxs("div",{className:"rounded-2xl w-full max-w-2xl shadow-2xl flex flex-col overflow-hidden",style:{background:"var(--app-surface)",border:"1px solid var(--app-border)",maxHeight:"90vh"},onClick:F=>F.stopPropagation(),children:[x.jsxs("div",{className:"px-6 pt-5 pb-4 shrink-0",style:{borderBottom:"1px solid var(--app-border)"},children:[x.jsxs("div",{className:"flex items-center justify-between mb-3",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx(fJ,{size:18,style:{color:"var(--accent)"}}),x.jsx("h2",{className:"font-bold text-lg",style:{color:"var(--text-primary)"},children:"Tab-Wizard"})]}),x.jsx("button",{onClick:t,className:"hover:opacity-70",style:{color:"var(--text-secondary)"},children:x.jsx(gn,{size:18})})]}),x.jsx("div",{className:"flex items-center gap-2",children:re.map((F,W)=>x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("div",{className:"w-2 h-2 rounded-full transition-colors",style:{background:W<=ie?"var(--accent)":"var(--app-border)"}}),W<re.length-1&&x.jsx("div",{className:"w-6 h-px",style:{background:"var(--app-border)"}})]},F))})]}),b&&x.jsx("div",{className:"h-0.5 shrink-0 overflow-hidden",style:{background:"var(--app-border)"},children:x.jsx("div",{className:"h-full",style:{background:"var(--accent)",animation:"wizard-loading 1.4s ease-in-out infinite"}})}),x.jsx("style",{children:`
610
610
  @keyframes wizard-loading {
611
611
  0% { transform: translateX(-100%); width: 40%; }
612
612
  50% { transform: translateX(160%); width: 60%; }
package/www/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/aura/favicon.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Aura – ioBroker Dashboard</title>
8
- <script type="module" crossorigin src="/aura/assets/index-DiySRUsL.js"></script>
8
+ <script type="module" crossorigin src="/aura/assets/index-Dykheti2.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/aura/assets/index-JkH4kIOv.css">
10
10
  </head>
11
11
  <body>