this.hass.states[n]?.attributes.symcon_path||this.hass.states
${this._find.trim()?p`
${t.length?t.map(n=>p`
`):p`
${$(this.hass,"find_none")}
`}
`:f}
@@ -1630,7 +1681,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
@click=${()=>{this._central=!this._central,this._armed=null}}
>
- `;if(!this._central)return i;let o=this.floorId?e.floors.find(b=>b.id===this.floorId):void 0,s=o?[o]:e.floors,a=s.flatMap(b=>Pi(t,b).lights),l=s.flatMap(b=>Pi(t,b).covers),c=a.filter(b=>t.states[b]?.state==="on").length,u=!o,d=(b,v,S,k)=>{if(k.length){if(u&&this._armed!==b){this._armed=b,clearTimeout(this.armTimer),this.armTimer=setTimeout(()=>this._armed=null,3500);return}this._armed=null,t.callService(v,S,{entity_id:k})}},m=(b,v,S,k,M)=>p`
`;if(!this._central)return i;let o=this.floorId?e.floors.find(b=>b.id===this.floorId):void 0,s=o?[o]:e.floors,a=s.flatMap(b=>Ci(t,b).lights),l=s.flatMap(b=>Ci(t,b).covers),c=a.filter(b=>t.states[b]?.state==="on").length,u=!o,d=(b,v,S,k)=>{if(k.length){if(u&&this._armed!==b){this._armed=b,clearTimeout(this.armTimer),this.armTimer=setTimeout(()=>this._armed=null,3500);return}this._armed=null,t.callService(v,S,{entity_id:k})}},m=(b,v,S,k,M)=>p`
`,h=e.settings.favorite_floors??{},g=(e.settings.favorites??[]).filter(b=>t.states[b]&&(!h[b]||!o||h[b]===o.id)),_=this.buttons??e.settings.buttons??[];return p`${i}
@@ -1647,7 +1698,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
`:f}
${n("central_favorites")}
${g.length?p`
- ${g.map(b=>{let[v,S]=xa(b),k=t.states[b],M=v==="homeassistant"&&k?.state==="on";return p`
`}toggleLock(){this._locked=!this._locked;try{localStorage.setItem(bu,this._locked?"1":"0")}catch{}}async openTravel(e){if(clearInterval(this.travelTimer),this.travelTimer=void 0,e===null||!this.hass){this._travel=null,this.syncDevices(!0);return}let t=Date.now(),n=t-e*36e5;this._travel={history:new Map,from:n,to:t,t:n,playing:!1,speed:e>24?3600:600,hours:e,moments:[],loading:!0};try{let i=await vn(this.hass,Gl(this.watched),n,t);if(!this._travel||this._travel.from!==n)return;this._travel={...this._travel,history:i,moments:Ul(i,n,t),loading:!1}}catch{this._travel=null,this._error=$(this.hass,"travel_failed");return}this.syncDevices(!0)}travelTo(e){let t=this._travel;t&&(this._travel={...t,t:Math.min(t.to,Math.max(t.from,e))},this.syncDevices(!0))}playTravel(e){let t=this._travel;t&&(clearInterval(this.travelTimer),this.travelTimer=void 0,this._travel={...t,playing:e,t:e&&t.t>=t.to?t.from:t.t},e&&(this.travelTimer=setInterval(()=>{let n=this._travel;if(!n)return;let i=n.t+250*n.speed;i>=n.to&&this.playTravel(!1),this.travelTo(i)},250)))}renderTravel(){if(!this.hass||this.clean)return f;let e=a=>$(this.hass,a),t=this._travel;if(!t)return this.travelButton?p`
{this.openTravel(24)}}>⏪`:f;let n=this.hass.language??navigator.language,i=new Intl.DateTimeFormat(n,{weekday:"short",hour:"2-digit",minute:"2-digit"}).format(new Date(t.t)),o=t.to-t.from||1,s=[[60,"travel_speed_min"],[600,"travel_speed_10min"],[3600,"travel_speed_hour"]];return p`
+
`}toggleLock(){this._locked=!this._locked;try{localStorage.setItem(yu,this._locked?"1":"0")}catch{}}async openTravel(e){if(clearInterval(this.travelTimer),this.travelTimer=void 0,e===null||!this.hass){this._travel=null,this.syncDevices(!0);return}let t=Date.now(),n=t-e*36e5;this._travel={history:new Map,from:n,to:t,t:n,playing:!1,speed:e>24?3600:600,hours:e,moments:[],loading:!0};try{let i=await kn(this.hass,jl(this.watched),n,t);if(!this._travel||this._travel.from!==n)return;this._travel={...this._travel,history:i,moments:ql(i,n,t),loading:!1}}catch{this._travel=null,this._error=$(this.hass,"travel_failed");return}this.syncDevices(!0)}travelTo(e){let t=this._travel;t&&(this._travel={...t,t:Math.min(t.to,Math.max(t.from,e))},this.syncDevices(!0))}playTravel(e){let t=this._travel;t&&(clearInterval(this.travelTimer),this.travelTimer=void 0,this._travel={...t,playing:e,t:e&&t.t>=t.to?t.from:t.t},e&&(this.travelTimer=setInterval(()=>{let n=this._travel;if(!n)return;let i=n.t+250*n.speed;i>=n.to&&this.playTravel(!1),this.travelTo(i)},250)))}renderTravel(){if(!this.hass||this.clean)return f;let e=a=>$(this.hass,a),t=this._travel;if(!t)return this.travelButton?p`
{this.openTravel(24)}}>⏪`:f;let n=this.hass.language??navigator.language,i=new Intl.DateTimeFormat(n,{weekday:"short",hour:"2-digit",minute:"2-digit"}).format(new Date(t.t)),o=t.to-t.from||1,s=[[60,"travel_speed_min"],[600,"travel_speed_10min"],[3600,"travel_speed_hour"]];return p`
this.playTravel(!t.playing)}>${t.playing?"\u23F8":"\u25B6"}
${t.loading?e("travel_loading"):i}
@@ -1701,7 +1752,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
${L(this.hass,e.entity)}
${t?$(this.hass,"swipe_off"):`${e.value} %`}
-
`}tapPlate(e,t,n){let i=this.building?.floors.flatMap(s=>s.furniture).find(s=>s.id===e),o=i?Ni(i.gang_entities,J(i.type)?.gangs??0):[];if(o.length===1)return this.onDeviceTap(o[0],t,n);o.length>1&&(this._plate={ids:o,x:t,y:n})}renderPlate(){let e=this._plate;if(!e||!this.hass)return f;let t=this.hass,n=()=>this._plate=null;return p`
+
`}tapPlate(e,t,n){let i=this.building?.floors.flatMap(s=>s.furniture).find(s=>s.id===e),o=i?Li(i.gang_entities,X(i.type)?.gangs??0):[];if(o.length===1)return this.onDeviceTap(o[0],t,n);o.length>1&&(this._plate={ids:o,x:t,y:n})}renderPlate(){let e=this._plate;if(!e||!this.hass)return f;let t=this.hass,n=()=>this._plate=null;return p`
`}renderMenu(){let e=this._menu;if(!e||!this.hass)return f;let t=this.renderRoot.querySelector(".nf-stage"),n=t?.clientWidth??800,i=t?.clientHeight??600,o=Math.max(8,Math.min(n-240,e.x-116)),s=Math.max(8,Math.min(i-360,e.y-170));return p`
@@ -1714,12 +1765,12 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
.presets=${(this.building?.settings.media_presets??[]).filter(a=>!a.speakers?.length||a.speakers.includes(e.entity))}
?confirmSwitch=${this.confirmSet.has(e.entity)}
.myPosition=${this.myPositionOf(e.entity)}
- .tiltEntity=${hr(this.hass,this.building?.floors??[],e.entity)}
+ .tiltEntity=${gr(this.hass,this.building?.floors??[],e.entity)}
@close=${()=>this._menu=null}
- >`}myPositionOf(e){for(let t of this.building?.floors??[])for(let n of t.openings){let i=this.openingLinks?.get(n.id);if(n.my_position!=null&&(i?.cover===e||i?.cover2===e))return n.my_position}return null}onDeviceTap(e,t=0,n=0){if(e.startsWith("lamp:")||this._travel)return;let i=e.startsWith("tap:")?e.slice(4):this.tapPins.get(e);if(i){let s=this.building?.floors.flatMap(a=>a.furniture).find(a=>a.id===i);s?.tap&&Ii(this.hass,this,s.tap);return}if(this.pluginTapped(e))return;if(e.startsWith("gang:"))return this.tapPlate(e.slice(5),t,n);if(e.startsWith("outdoor:")){this.fire("room-tap",{floorId:null,roomId:"nf-outside"});return}if(e==="grid"){let s=this.building,a=s?s.energy.grid??Le(s,l=>this.furnitureLinks?.get(l.id)?.power??null).grid:null;a&&ye(this,a);return}let o=H(e);if(o==="cover"||o==="media"){this._menu={entity:e,x:t,y:n};return}if(o==="lock"){let s=Di(this.hass,e),a=L(this.hass,e);confirm($(this.hass,s?"lock_confirm_lock":"lock_confirm_unlock",{name:a}))&&this.hass.callService("lock",s?"lock":"unlock",{entity_id:e});return}if(o&&Zs.has(o)){if(this.confirmSet.has(e)&&!confirm($(this.hass,"confirm_switch",{name:L(this.hass,e)})))return;Ca(this.hass,e)}else ye(this,e)}pluginTapped(e){let t=this.hass?.states[e],n=this.placementInfo.get(e);if(!t||!n)return!1;let i=this.building?.floors.find(o=>o.id===n.floorId)?.placements.find(o=>o.entity_id===e);return Es({hass:this.hass,entityId:e,state:t},n,i?.plugin??void 0,{showWindow:(o,s)=>{o&&"hass"in o&&(o.hass=this.hass),this._pluginWindow=o?{node:o,title:s?.title??""}:null},moreInfo:o=>ye(this,o??e)})}renderPluginWindow(){let e=this._pluginWindow;return e?p`
t.stopPropagation()}>
+ >`}myPositionOf(e){for(let t of this.building?.floors??[])for(let n of t.openings){let i=this.openingLinks?.get(n.id);if(n.my_position!=null&&(i?.cover===e||i?.cover2===e))return n.my_position}return null}onDeviceTap(e,t=0,n=0){if(e.startsWith("lamp:")||this._travel)return;let i=e.startsWith("tap:")?e.slice(4):this.tapPins.get(e);if(i){let s=this.building?.floors.flatMap(a=>a.furniture).find(a=>a.id===i);s?.tap&&Oi(this.hass,this,s.tap);return}if(this.pluginTapped(e))return;if(e.startsWith("gang:"))return this.tapPlate(e.slice(5),t,n);if(e.startsWith("outdoor:")){this.fire("room-tap",{floorId:null,roomId:"nf-outside"});return}if(e==="grid"){let s=this.building,a=s?s.energy.grid??Ve(s,l=>this.furnitureLinks?.get(l.id)?.power??null).grid:null;a&&ye(this,a);return}let o=H(e);if(o==="cover"||o==="media"){this._menu={entity:e,x:t,y:n};return}if(o==="lock"){let s=Pi(this.hass,e),a=L(this.hass,e);confirm($(this.hass,s?"lock_confirm_lock":"lock_confirm_unlock",{name:a}))&&this.hass.callService("lock",s?"lock":"unlock",{entity_id:e});return}if(o&&Qs.has(o)){if(this.confirmSet.has(e)&&!confirm($(this.hass,"confirm_switch",{name:L(this.hass,e)})))return;Wa(this.hass,e)}else ye(this,e)}pluginTapped(e){let t=this.hass?.states[e],n=this.placementInfo.get(e);if(!t||!n)return!1;let i=this.building?.floors.find(o=>o.id===n.floorId)?.placements.find(o=>o.entity_id===e);return Ts({hass:this.hass,entityId:e,state:t},n,i?.plugin??void 0,{showWindow:(o,s)=>{o&&"hass"in o&&(o.hass=this.hass),this._pluginWindow=o?{node:o,title:s?.title??""}:null},moreInfo:o=>ye(this,o??e)})}renderPluginWindow(){let e=this._pluginWindow;return e?p`
t.stopPropagation()}>
${e.title}this._pluginWindow=null}>✕
${e.node}
-
`:f}startViewOf(){return this.startView??this.building?.settings.start_view??null}currentView(){return this.viewer?.currentView()??null}resetView(){this.viewer?.resetView()}fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}toggleFlows(){this._flows=!this._flows;try{localStorage.setItem("nextfloor.flows",this._flows?"1":"0")}catch{}this.syncDevices(!0)}liveHeatPumps(e){let t=this.hass;if(!t)return[];let n=[];for(let i of e.floors)for(let o of i.furniture){if(!Uc(o.type))continue;let s=this.furnitureLinks?.get(o.id),a=Gc(t,s?.entity??s?.power??null);a&&n.push({id:o.id,name:o.name||_e(t,o.type),floorId:i.id,x:o.x,z:o.z,at:{floorId:i.id,x:o.x,z:o.z,y:he(i,o)+o.h+.5},pump:a})}return n}livePrinters(e){let t=this.hass,n=[];if(!t)return n;for(let i of e.floors)for(let o of i.furniture){if(!Ro(o.type))continue;let s=this.furnitureLinks?.get(o.id),a=Eo(t,s?.entity??s?.power??null);!a||!a.printing&&!/pause|finish|complete|error/.test(a.status)||n.push({id:o.id,name:o.name||_e(t,o.type),at:{floorId:i.id,x:o.x,z:o.z,y:he(i,o)+o.h+.5},printer:a})}return n}liveCars(e,t){let n=[];for(let i of t.floors)for(let o of i.furniture){if(o.type!=="parking")continue;let s=Jc(e,o);if(!s||s.soc===null&&s.range===null&&s.locked===null&&s.climateOn===null)continue;let a=fo(e,o),l=a?hc(o,a):null,c=o.name||(a?_e(e,a):_e(e,o.type));n.push({spot:o.id,name:c,at:{floorId:i.id,x:o.x,z:o.z,y:he(i,o)+(l?.h??.2)+.6},car:s})}return n}liveMedia(e,t){let n=[];for(let i of t.floors){for(let o of i.furniture){let s=this.furnitureLinks?.get(o.id)?.entity;s?.startsWith("media_player.")&&n.push({entity:s,name:o.name||_e(e,o.type),at:{floorId:i.id,x:o.x,z:o.z,y:he(i,o)+o.h+.15},rings:o.sound_rings})}for(let o of i.placements)o.entity_id.startsWith("media_player.")&&n.push({entity:o.entity_id,name:o.name||L(e,o.entity_id),at:{floorId:i.id,x:o.x,z:o.z,y:(o.y??1.1)+.15},rings:o.sound_rings})}return Jl(e,n)}refreshToday(e){let t=this.hass,n=e.settings.calendars??[],i=Math.max(1,Math.min(7,e.settings.today_days??1)),o=`${new Date().toDateString()}|${i}`;!t||!n.length||Date.now()-this.todayAt<9e5&&o===this.todayDay||(this.todayAt=Date.now(),this.todayDay=o,Lc(t,n,i).then(s=>this._todayItems=s))}refreshForecast(e){let t=this.hass,n=e.settings.forecast&&t?tt(t,this.weatherEntityId??e.settings.weather_entity):null;if(!t||!n)return;let i=`${n}|${new Date().toDateString()}`;Date.now()-this.forecastAt<18e5&&i===this.forecastKey||(this.forecastAt=Date.now(),this.forecastKey=i,Vc(t,n).then(o=>this._forecast=o))}renderForecast(e){let t=this.building,n=this.hass,i=t?.settings.forecast;if(!t||!n||!i||i.corner!==e||this.clean)return f;if(e==="top_right"&&(this.roomId||this.panelOpen))return f;let o=Bc(this._forecast,Math.max(1,Math.min(7,i.days)));if(!o.length)return f;let s=tt(n,this.weatherEntityId??t.settings.weather_entity),a=s?n.states[s]?.attributes:void 0,l=String(a?.temperature_unit??"\xB0"),c=String(a?.precipitation_unit??"mm"),u=n.language??navigator.language,d=new Intl.DateTimeFormat(u,{weekday:"short"}),m=h=>h===null?"\u2013":`${Math.round(h)}\xB0`;return p`
`:f}startViewOf(){return this.startView??this.building?.settings.start_view??null}currentView(){return this.viewer?.currentView()??null}resetView(){this.viewer?.resetView()}fire(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}toggleFlows(){this._flows=!this._flows;try{localStorage.setItem("nextfloor.flows",this._flows?"1":"0")}catch{}this.syncDevices(!0)}liveHeatPumps(e){let t=this.hass;if(!t)return[];let n=[];for(let i of e.floors)for(let o of i.furniture){if(!qc(o.type))continue;let s=this.furnitureLinks?.get(o.id),a=jc(t,s?.entity??s?.power??null);a&&n.push({id:o.id,name:o.name||_e(t,o.type),floorId:i.id,x:o.x,z:o.z,at:{floorId:i.id,x:o.x,z:o.z,y:he(i,o)+o.h+.5},pump:a})}return n}livePrinters(e){let t=this.hass,n=[];if(!t)return n;for(let i of e.floors)for(let o of i.furniture){if(!To(o.type))continue;let s=this.furnitureLinks?.get(o.id),a=zo(t,s?.entity??s?.power??null);!a||!a.printing&&!/pause|finish|complete|error/.test(a.status)||n.push({id:o.id,name:o.name||_e(t,o.type),at:{floorId:i.id,x:o.x,z:o.z,y:he(i,o)+o.h+.5},printer:a})}return n}liveCars(e,t){let n=[];for(let i of t.floors)for(let o of i.furniture){if(o.type!=="parking")continue;let s=Xc(e,o);if(!s||s.soc===null&&s.range===null&&s.locked===null&&s.climateOn===null)continue;let a=_o(e,o),l=a?pc(o,a):null,c=o.name||(a?_e(e,a):_e(e,o.type));n.push({spot:o.id,name:c,at:{floorId:i.id,x:o.x,z:o.z,y:he(i,o)+(l?.h??.2)+.6},car:s})}return n}liveMedia(e,t){let n=[];for(let i of t.floors){for(let o of i.furniture){let s=this.furnitureLinks?.get(o.id)?.entity;s?.startsWith("media_player.")&&n.push({entity:s,name:o.name||_e(e,o.type),at:{floorId:i.id,x:o.x,z:o.z,y:he(i,o)+o.h+.15},rings:o.sound_rings})}for(let o of i.placements)o.entity_id.startsWith("media_player.")&&n.push({entity:o.entity_id,name:o.name||L(e,o.entity_id),at:{floorId:i.id,x:o.x,z:o.z,y:(o.y??1.1)+.15},rings:o.sound_rings})}return Xl(e,n)}refreshToday(e){let t=this.hass,n=e.settings.calendars??[],i=Math.max(1,Math.min(7,e.settings.today_days??1)),o=`${new Date().toDateString()}|${i}`;!t||!n.length||Date.now()-this.todayAt<9e5&&o===this.todayDay||(this.todayAt=Date.now(),this.todayDay=o,Bc(t,n,i).then(s=>this._todayItems=s))}refreshForecast(e){let t=this.hass,n=e.settings.forecast&&t?ot(t,this.weatherEntityId??e.settings.weather_entity):null;if(!t||!n)return;let i=`${n}|${new Date().toDateString()}`;Date.now()-this.forecastAt<18e5&&i===this.forecastKey||(this.forecastAt=Date.now(),this.forecastKey=i,Gc(t,n).then(o=>this._forecast=o))}renderForecast(e){let t=this.building,n=this.hass,i=t?.settings.forecast;if(!t||!n||!i||i.corner!==e||this.clean)return f;if(e==="top_right"&&(this.roomId||this.panelOpen))return f;let o=Kc(this._forecast,Math.max(1,Math.min(7,i.days)));if(!o.length)return f;let s=ot(n,this.weatherEntityId??t.settings.weather_entity),a=s?n.states[s]?.attributes:void 0,l=String(a?.temperature_unit??"\xB0"),c=String(a?.precipitation_unit??"mm"),u=n.language??navigator.language,d=new Intl.DateTimeFormat(u,{weekday:"short"}),m=h=>h===null?"\u2013":`${Math.round(h)}\xB0`;return p`
${o.map((h,g)=>p`-
${g===0?$(n,"today"):d.format(new Date(h.day))}
@@ -1728,14 +1779,14 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
${h.rain!==null&&h.rain>0?`\u{1F4A7}${h.rain.toLocaleString(u,{maximumFractionDigits:1})} ${c}`:h.chance!==null&&h.chance>0?`\u{1F4A7}${Math.round(h.chance)} %`:""}
`)}
- `}renderToday(){let e=this.building,t=this.hass;if(!e||!t||this.clean||this.roomId||this.panelOpen)return f;let n=this.renderForecast("top_right"),i=this.today===!1?f:this.renderTodayCard(e,t);return i===f&&n===f?f:p`
${i}${n}
`}renderTodayCard(e,t){let n=Cc(t,e,Date.now(),{today:$(t,"care_bin_today"),tomorrow:$(t,"care_bin_tomorrow")}),i=Wc([...n,...this._todayItems??[]]);if(!i.length&&!(e.settings.calendars??[]).length)return f;let o=this._todayOpen!==!1,s=new Intl.DateTimeFormat(t.language??navigator.language,{weekday:"long",day:"numeric",month:"long"}).format(new Date),a=t.language??navigator.language,l=u=>{if(u===1)return $(t,"tomorrow");let d=new Date;return d.setDate(d.getDate()+u),new Intl.DateTimeFormat(a,{weekday:"long",day:"numeric",month:"numeric"}).format(d)},c=i.flatMap((u,d)=>[(u.day??0)>0&&(i[d-1]?.day??0)!==u.day?p`
${l(u.day??0)}`:f,p`
${u.title}${u.source}`]);return p`
`}renderToday(e){let t=this.building,n=this.hass;if(!t||!n||this.clean||this.roomId||this.panelOpen)return f;let i=this.renderForecast("top_right"),o=this.today===!1?f:this.renderTodayCard(t,n);return o===f&&i===f&&e===f?f:p`
${e}${o}${i}
`}renderTodayCard(e,t){let n=Lc(t,e,Date.now(),{today:$(t,"care_bin_today"),tomorrow:$(t,"care_bin_tomorrow")}),i=Wc([...n,...this._todayItems??[]]);if(!i.length&&!(e.settings.calendars??[]).length)return f;let o=this._todayOpen!==!1,s=new Intl.DateTimeFormat(t.language??navigator.language,{weekday:"long",day:"numeric",month:"long"}).format(new Date),a=t.language??navigator.language,l=u=>{if(u===1)return $(t,"tomorrow");let d=new Date;return d.setDate(d.getDate()+u),new Intl.DateTimeFormat(a,{weekday:"long",day:"numeric",month:"numeric"}).format(d)},c=i.flatMap((u,d)=>[(u.day??0)>0&&(i[d-1]?.day??0)!==u.day?p`
${l(u.day??0)}`:f,p`
${u.title}${u.source}`]);return p`
this._todayOpen=!o}>
📅 ${$(t,"today")}${s}
${o?i.length?p``:p`${$(t,"today_none")}
`:f}
- `}week=null;weekAt=0;refreshWeek(e){let t=this.hass;if(!t||this._travel||Date.now()-this.weekAt<36e5)return;this.weekAt=Date.now();let n=Le(e,s=>this.furnitureLinks?.get(s.id)?.power??null),i=e.energy,o={solar:i.solar?[i.solar]:n.solar,grid:i.grid??n.grid,gridInvert:!!i.grid_invert,battery:i.battery?[i.battery]:n.battery,batteryInvert:!!i.battery_invert,consumption:i.consumption};Dl(t,o).then(s=>{this.week=s,this.syncDevices(!0)}).catch(()=>this.week=null)}meterRows(e,t=null){let n=this.hass,i=[],o=this.floorId?e.floors.find(l=>l.id===this.floorId):void 0,s=o&&G(n)?dn(n,o,e.floors.flatMap(l=>l.rooms)).find(l=>l.kind==="electricity"&&l.metric==="power"&&l.unit==="W"):void 0,a=G(n)?s?.value??null:o?.power_entity?Y(n?.states[o.power_entity]):null;if(o&&(s||a!==null)){let l=!s?.incomplete&&a!==null&&t&&t>0?` \xB7 ${$(n,"floor_power_share",{n:Math.round(Math.max(0,a)/t*100)})}`:"";i.push({icon:"\u26A1",label:o.name,value:`${s?Xe(n,s):ft(n,a)}${l}`})}for(let[l,c,u]of[["gas","\u{1F525}","energy_gas_short"],["water","\u{1F4A7}","energy_water_short"]]){let d=e.energy[l],m=d?n?.states[d]:void 0;m&&!N(m)&&i.push({icon:c,label:$(n,u),value:oe(n,m)})}return i}refreshDayCurves(e){let t=this.hass;if(!t||this._travel||Date.now()-this.curvesAt<6e5)return;this.curvesAt=Date.now();let n=a=>gn(a,e,fn(a,e),Le(e,l=>this.furnitureLinks?.get(l.id)?.power??null)),i=jl(t,n),o=Date.now(),s=o-24*36e5;vn(t,i,s,o,!0).then(a=>{this.dayCurves=ql(t,a,s,o,n),this.syncDevices(!0)}).catch(()=>this.dayCurves=null)}syncLhCards(e,t,n,i,o,s){let a=[],l=n.summary,c=l.solar!==null||l.grid!==null||l.battery!==null||l.consumption!==null,u=An(t),d=(this.floorId?t.floors.find(m=>m.id===this.floorId):void 0)??[...t.floors].sort((m,h)=>h.elevation-m.elevation)[0];if(this.liveCardsOn&&!this.dimmed&&!this.roomId&&c&&u&&d){let m=0,h=0,g=0;for(let _ of d.rooms)for(let[b,v]of _.points)m+=b,h+=v,g++;a.push({kind:"house",at:{floorId:d.id,x:g?m/g:u.x,z:g?h/g:u.z,y:d.height+(this.floorId?1.2:3.2)},summary:l,autarky:n.autarky,curves:this.dayCurves??void 0,week:this.week??void 0,meters:this.meterRows(t,l.consumption)}),this.refreshDayCurves(t),this.refreshWeek(t)}if(this.liveCardsOn&&!this.dimmed&&!this.roomId){for(let m of i)a.push({kind:"car",at:m.at,spot:m.spot,name:m.name,car:m.car});for(let m of this.livePrinters(t))a.push({kind:"printer",at:m.at,name:m.name,printer:m.printer});for(let m of this.liveHeatPumps(t))a.push({kind:"heatpump",at:m.at,name:m.name,pump:m.pump});for(let m of o)a.push({kind:"media",at:{...m.at,y:m.at.y+.5},media:m})}this.liveCardsOn&&!this.dimmed&&a.push(...Hc(s,t,this.floorId,this.roomId)),JSON.stringify(a)!==JSON.stringify(this._liveCards)&&(this._liveCards=a),e.setLiveAnchors(a.map(m=>m.at),a.length?(m,h,g,_)=>this.placeLhCard(m,h,g,_):null)}placeLhCard(e,t,n,i){let o=this.renderRoot.querySelector(`.live-card[data-i="${e}"]`);o&&(o.dataset.x=String(t),o.dataset.y=String(n),o.style.visibility=i?"visible":"hidden",e===this._liveCards.length-1&&Xc(this.renderRoot))}toggleHouseFold(){this._houseFolded=!this._houseFolded;try{localStorage.setItem("nextfloor.house_card_folded",this._houseFolded?"1":"0")}catch{}}toggleLhCards(){this._liveCardOn=!this._liveCardOn;try{localStorage.setItem("nextfloor.cards",this._liveCardOn?"1":"0")}catch{}this.syncDevices(!0)}renderTopLeft(){let e=this.clean?f:this.renderLhEnergy(),t=this.renderForecast("top_left");return this.clock!=="top_left"&&t===f||!this.hass?e:p`
${this.clock==="top_left"?this.renderClock(!0):f}${e}${t}
`}renderLhEnergy(){let e=this.ownSensors(),t=this._liveEnergy?.summary,n=!!t&&!this.roomId&&this.showEnergy&&!!this.hass&&!(t.consumption===null&&t.grid===null&&t.solar===null&&t.battery===null),o=this.building?.floors.some(c=>c.rooms.some(u=>u.climate_card))?this.renderCardToggle():f,s=this.roomNamesButton?p`
{this.roomLabels=!this.roomLabels,this.dispatchEvent(new CustomEvent("room-names-change",{detail:{value:this.roomLabels},bubbles:!0,composed:!0}))}}>${$(this.hass,"room_names_short")}Aa`:f;if(!n)return e.length||o!==f||s!==f?p`
${s}${e}${o}
`:f;let a=c=>$(this.hass,c),l=[];if(t.solar!==null&&l.push({cls:"solar",label:a("energy_solar"),value:ue(this.hass,t.solar)}),t.consumption!==null&&l.push({cls:"total",label:a("energy_consumption"),value:ue(this.hass,t.consumption)}),t.rest!==void 0&&t.rest!==null&&l.push({cls:"total",label:a("energy_rest"),value:ue(this.hass,t.rest)}),t.battery!==null||t.soc!==null){let c=[t.battery!==null?ue(this.hass,Math.abs(t.battery)):null,t.soc!==null?`${Math.round(t.soc)} %`:null].filter(Boolean);l.push({cls:"battery",label:a("energy_battery"),value:c.join(" \xB7 ")})}if(t.grid!==null){let c=t.grid<0;l.push({cls:c?"export":"grid",label:a(c?"energy_grid_export":"energy_grid_import"),value:ue(this.hass,Math.abs(t.grid))})}if(t.tariff&&l.push({cls:"tariff",label:a("energy_tariff"),value:`${W(this.hass,t.tariff.value,3)} ${t.tariff.unit}`.trim()}),this.building)for(let c of this.meterRows(this.building))l.push({cls:"meter",label:`${c.icon} ${c.label}`,value:c.value});return p`
+ `}week=null;weekAt=0;refreshWeek(e){let t=this.hass;if(!t||this._travel||Date.now()-this.weekAt<36e5)return;this.weekAt=Date.now();let n=Ve(e,s=>this.furnitureLinks?.get(s.id)?.power??null),i=e.energy,o={solar:i.solar?[i.solar]:n.solar,grid:i.grid??n.grid,gridInvert:!!i.grid_invert,battery:i.battery?[i.battery]:n.battery,batteryInvert:!!i.battery_invert,consumption:i.consumption};Hl(t,o).then(s=>{this.week=s,this.syncDevices(!0)}).catch(()=>this.week=null)}meterRows(e,t=null){let n=this.hass,i=[],o=this.floorId?e.floors.find(l=>l.id===this.floorId):void 0,s=o&&K(n)?Te(n,o,e.floors.flatMap(l=>l.rooms)).find(l=>l.kind==="electricity"&&l.metric==="power"&&l.unit==="W"):void 0,a=K(n)?s?.value??null:o?.power_entity?J(n?.states[o.power_entity]):null;if(o&&(s||a!==null)){let l=!s?.incomplete&&a!==null&&t&&t>0?` \xB7 ${$(n,"floor_power_share",{n:Math.round(Math.max(0,a)/t*100)})}`:"";i.push({icon:"\u26A1",label:o.name,value:`${s?De(n,s):vt(n,a)}${l}`})}for(let[l,c,u]of[["gas","\u{1F525}","energy_gas_short"],["water","\u{1F4A7}","energy_water_short"]]){let d=e.energy[l],m=d?n?.states[d]:void 0;m&&!N(m)&&i.push({icon:c,label:$(n,u),value:oe(n,m)})}return i}refreshDayCurves(e){let t=this.hass;if(!t||this._travel||Date.now()-this.curvesAt<6e5)return;this.curvesAt=Date.now();let n=a=>yn(a,e,vn(a,e),Ve(e,l=>this.furnitureLinks?.get(l.id)?.power??null)),i=Zl(t,n),o=Date.now(),s=o-24*36e5;kn(t,i,s,o,!0).then(a=>{this.dayCurves=Yl(t,a,s,o,n),this.syncDevices(!0)}).catch(()=>this.dayCurves=null)}syncLhCards(e,t,n,i,o,s){let a=[],l=n.summary,c=l.solar!==null||l.grid!==null||l.battery!==null||l.consumption!==null,u=Tn(t),d=(this.floorId?t.floors.find(m=>m.id===this.floorId):void 0)??[...t.floors].sort((m,h)=>h.elevation-m.elevation)[0];if(this.liveCardsOn&&!this.dimmed&&!this.roomId&&c&&u&&d){let m=0,h=0,g=0;for(let _ of d.rooms)for(let[b,v]of _.points)m+=b,h+=v,g++;a.push({kind:"house",at:{floorId:d.id,x:g?m/g:u.x,z:g?h/g:u.z,y:d.height+(this.floorId?1.2:3.2)},summary:l,autarky:n.autarky,curves:this.dayCurves??void 0,week:this.week??void 0,meters:this.meterRows(t,l.consumption)}),this.refreshDayCurves(t),this.refreshWeek(t)}if(this.liveCardsOn&&!this.dimmed&&!this.roomId){for(let m of i)a.push({kind:"car",at:m.at,spot:m.spot,name:m.name,car:m.car});for(let m of this.livePrinters(t))a.push({kind:"printer",at:m.at,name:m.name,printer:m.printer});for(let m of this.liveHeatPumps(t))a.push({kind:"heatpump",at:m.at,name:m.name,pump:m.pump});for(let m of o)a.push({kind:"media",at:{...m.at,y:m.at.y+.5},media:m})}this.liveCardsOn&&!this.dimmed&&a.push(...Ic(s,t,this.floorId,this.roomId)),JSON.stringify(a)!==JSON.stringify(this._liveCards)&&(this._liveCards=a),e.setLiveAnchors(a.map(m=>m.at),a.length?(m,h,g,_)=>this.placeLhCard(m,h,g,_):null)}placeLhCard(e,t,n,i){let o=this.renderRoot.querySelector(`.live-card[data-i="${e}"]`);o&&(o.dataset.x=String(t),o.dataset.y=String(n),o.style.visibility=i?"visible":"hidden",e===this._liveCards.length-1&&tu(this.renderRoot))}toggleHouseFold(){this._houseFolded=!this._houseFolded;try{localStorage.setItem("nextfloor.house_card_folded",this._houseFolded?"1":"0")}catch{}}toggleLhCards(){this._liveCardOn=!this._liveCardOn;try{localStorage.setItem("nextfloor.cards",this._liveCardOn?"1":"0")}catch{}this.syncDevices(!0)}renderTopLeft(){let e=this.clean?f:this.renderLhEnergy(),t=this.renderForecast("top_left");return this.clock!=="top_left"&&t===f||!this.hass?e:p`
${this.clock==="top_left"?this.renderClock(!0):f}${e}${t}
`}renderLhEnergy(){let e=this.ownSensors(),t=this._liveEnergy?.summary,n=!!t&&!this.roomId&&this.showEnergy&&!!this.hass&&!(t.consumption===null&&t.grid===null&&t.solar===null&&t.battery===null),o=this.building?.floors.some(c=>c.rooms.some(u=>u.climate_card))?this.renderCardToggle():f,s=this.roomNamesButton?p`
{this.roomLabels=!this.roomLabels,this.dispatchEvent(new CustomEvent("room-names-change",{detail:{value:this.roomLabels},bubbles:!0,composed:!0}))}}>${$(this.hass,"room_names_short")}Aa`:f;if(!n)return e.length||o!==f||s!==f?p`
${s}${e}${o}
`:f;let a=c=>$(this.hass,c),l=[];if(t.solar!==null&&l.push({cls:"solar",label:a("energy_solar"),value:ue(this.hass,t.solar)}),t.consumption!==null&&l.push({cls:"total",label:a("energy_consumption"),value:ue(this.hass,t.consumption)}),t.rest!==void 0&&t.rest!==null&&l.push({cls:"total",label:a("energy_rest"),value:ue(this.hass,t.rest)}),t.battery!==null||t.soc!==null){let c=[t.battery!==null?ue(this.hass,Math.abs(t.battery)):null,t.soc!==null?`${Math.round(t.soc)} %`:null].filter(Boolean);l.push({cls:"battery",label:a("energy_battery"),value:c.join(" \xB7 ")})}if(t.grid!==null){let c=t.grid<0;l.push({cls:c?"export":"grid",label:a(c?"energy_grid_export":"energy_grid_import"),value:ue(this.hass,Math.abs(t.grid))})}if(t.tariff&&l.push({cls:"tariff",label:a("energy_tariff"),value:`${O(this.hass,t.tariff.value,3)} ${t.tariff.unit}`.trim()}),this.building)for(let c of this.meterRows(this.building))l.push({cls:"meter",label:`${c.icon} ${c.label}`,value:c.value});return p`
${s}
${this.liveCardsOn&&this._liveCards.some(c=>c.kind==="house")?f:l.map(c=>p`
${c.label}${c.value}
`)}
${this.flows!==null?f:p`
this.toggleFlows()}>
@@ -1745,35 +1796,36 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
${e}
`}renderCardToggle(){return this.holograms!==null?f:p`
this.toggleLhCards()}>
${$(this.hass,"holos")}◫
- `}ownSensors(){let e=this.sensorBar&&this.hass?this.building?.settings.status_entities??[]:[],t=G(this.hass)?(this.building?.presence??[]).filter(a=>qa(this.hass,a.person,[0])).map(a=>p`
${a.name||L(this.hass,a.person)}${se(this.hass.states[a.person])===null?"\u2013":se(this.hass.states[a.person])?"Anwesend":"Abwesend"}${j(this.hass,[a.person],a.name||"Anwesenheit")}
`):[],n=G(this.hass)?Object.entries(this.building?.settings.weather_variables??{}).filter(a=>!!a[1]&&a[1]!=="none").map(([a,l])=>[hu[a]||a,l]):[];G(this.hass)&&this.building?.settings.rain_sensor&&this.building.settings.rain_sensor!=="none"&&n.push(["Regensensor",this.building.settings.rain_sensor]);let i=n.length?p`
this.renderRoot.querySelector(".nf-weather-dialog")?.showModal()}>Wetter⛅
-
`:f,o=G(this.hass)?(this.building?.floors??[]).filter(a=>!this.floorId||a.id===this.floorId).map(a=>({floor:a,readings:dn(this.hass,a,this.building?.floors.flatMap(l=>l.rooms))})).filter(a=>a.readings.length):[],s=o.length?p`
this.renderRoot.querySelector(".nf-utility-dialog")?.showModal()}>Stockwerkszähler⚡ 💧
-
`:f;return[...t,i,s,...e.filter(a=>this.hass.states[a]).map(a=>p`
ye(this,a)}>
- ${L(this.hass,a)}${oe(this.hass,this.hass.states[a])}
- ${j(this.hass,[a],L(this.hass,a))}`)]}renderMapCredit(){let e=this.building?.settings.map;return bc(e)?p`
${bo(e).text}`:f}renderLegend(){if(this.heatMode==="wifi")return this.renderWifiLegend();if(this.heatMode==="none"||this.heatMode==="values")return f;let e=pt(new Date,this.hass?.config?.latitude??50),t=Ar(this.heatMode,e),n=this.heatMode==="temperature",i=n?ae(this.hass,t.stops[0][0]):t.stops[0][0],o=n?ae(this.hass,t.stops[t.stops.length-1][0]):t.stops[t.stops.length-1][0],s=n?re(this.hass):t.unit,a=l=>$(this.hass,l);return p`
+ `}utilityOverview(e){let t=this.building;if(!t||!K(this.hass)||!this.showEnergy||this.clean||this.roomId||this.panelOpen||!e&&!this._utilityOverviewVisible)return f;let n=t.floors.flatMap(o=>o.rooms);return(this.floorId?t.floors.filter(o=>o.id===this.floorId):t.floors).some(o=>Te(this.hass,o,n).length)?p`
{o.stopPropagation(),o.detail.roomId?this.openRoom(o.detail.floorId,o.detail.roomId):this.fire("floor-tap",{floorId:o.detail.floorId})}}>`:f}ownSensors(){let e=this.utilityOverview(!0),t=e===f?f:p`
{this._utilityOverviewVisible=!this._utilityOverviewVisible;try{localStorage.setItem("nextfloor.utility_overview",this._utilityOverviewVisible?"1":"0")}catch{}}}>Übersicht`,n=this.sensorBar&&this.hass?this.building?.settings.status_entities??[]:[],i=K(this.hass)?(this.building?.presence??[]).filter(c=>Ja(this.hass,c.person,[0])).map(c=>p`
${c.name||L(this.hass,c.person)}${se(this.hass.states[c.person])===null?"\u2013":se(this.hass.states[c.person])?"Anwesend":"Abwesend"}${U(this.hass,[c.person],c.name||"Anwesenheit")}
`):[],o=K(this.hass)?Object.entries(this.building?.settings.weather_variables??{}).filter(c=>!!c[1]&&c[1]!=="none").map(([c,u])=>[pu[c]||c,u]):[];K(this.hass)&&this.building?.settings.rain_sensor&&this.building.settings.rain_sensor!=="none"&&o.push(["Regensensor",this.building.settings.rain_sensor]);let s=o.length?p`
this.renderRoot.querySelector(".nf-weather-dialog")?.showModal()}>Wetter⛅
+
`:f,a=K(this.hass)?(this.building?.floors??[]).filter(c=>!this.floorId||c.id===this.floorId).map(c=>({floor:c,readings:Te(this.hass,c,this.building?.floors.flatMap(u=>u.rooms))})).filter(c=>c.readings.length):[],l=a.length?p`
this.renderRoot.querySelector(".nf-utility-dialog")?.showModal()}>Stockwerkszähler⚡ 💧
+
`:f;return[t,e,...i,s,l,...n.filter(c=>this.hass.states[c]).map(c=>p`
ye(this,c)}>
+ ${L(this.hass,c)}${oe(this.hass,this.hass.states[c])}
+ ${U(this.hass,[c],L(this.hass,c))}`)]}renderMapCredit(){let e=this.building?.settings.map;return yc(e)?p`
${yo(e).text}`:f}renderLegend(){if(this.heatMode==="wifi")return this.renderWifiLegend();if(this.heatMode==="none"||this.heatMode==="values")return f;let e=bt(new Date,this.hass?.config?.latitude??50),t=zr(this.heatMode,e),n=this.heatMode==="temperature",i=n?ae(this.hass,t.stops[0][0]):t.stops[0][0],o=n?ae(this.hass,t.stops[t.stops.length-1][0]):t.stops[t.stops.length-1][0],s=n?re(this.hass):t.unit,a=l=>$(this.hass,l);return p`
${a(`heat_${this.heatMode}`)}${this.heatMode==="temperature"?p` ${a(e?"heat_summer":"heat_winter")}`:f}
-
- ${W(this.hass,i,0)} ${s}${W(this.hass,o,0)} ${s}
+
+ ${O(this.hass,i,0)} ${s}${O(this.hass,o,0)} ${s}
${this.heatValues.size?f:p`${a("heat_none_found")}`}
-
`}renderWifiLegend(){let e=this.hass,t=this.building;if(!e||!t)return f;let n=(c,u)=>$(e,c,u),i=t.floors.flatMap(c=>c.furniture.filter(u=>zo(u.type)).map(u=>To(e,this.furnitureLinks?.get(u.id)?.entity??this.furnitureLinks?.get(u.id)?.power??null))),s=i.filter(c=>!!c).reduce((c,u)=>c+(u.clients??0),0),a=t.floors.flatMap(c=>c.placements.map(u=>e.states[u.entity_id])),l=Zc(a);return p`
+
`}renderWifiLegend(){let e=this.hass,t=this.building;if(!e||!t)return f;let n=(c,u)=>$(e,c,u),i=t.floors.flatMap(c=>c.furniture.filter(u=>Do(u.type)).map(u=>Fo(e,this.furnitureLinks?.get(u.id)?.entity??this.furnitureLinks?.get(u.id)?.power??null))),s=i.filter(c=>!!c).reduce((c,u)=>c+(u.clients??0),0),a=t.floors.flatMap(c=>c.placements.map(u=>e.states[u.entity_id])),l=Jc(a);return p`
📶 ${n("heat_wifi")}
${n("wifi_aps",{n:i.length,clients:s})}
${l.online+l.offline.length?p`${n("wifi_network",{online:l.online,offline:l.offline.length})}`:f}
${l.offline.length?p`${l.offline.slice(0,4).join(", ")}`:f}
${i.length?f:p`${n("wifi_none")}`}
-
`}skyColor(){let e=wn[this.theme]??wn.neon,t=this._sky;return e.night[0].map((n,i)=>Math.round(n+(e.day[0][i]-n)*t))}render(){let e=this._sky,t=(o,s)=>`rgb(${o.map((a,l)=>Math.round(a+(s[l]-a)*e)).join(",")})`,n=wn[this.theme]??wn.neon,i=`--nf-sky:${t(n.night[0],n.day[0])};--nf-ground:${t(n.night[1],n.day[1])}`+Zl(this.building?.settings.backdrop);return p`
`}skyColor(){let e=$n[this.theme]??$n.neon,t=this._sky;return e.night[0].map((n,i)=>Math.round(n+(e.day[0][i]-n)*t))}render(){let e=this.utilityOverview(!1),t=this._sky,n=(s,a)=>`rgb(${s.map((l,c)=>Math.round(l+(a[c]-l)*t)).join(",")})`,i=$n[this.theme]??$n.neon,o=`--nf-sky:${n(i.night[0],i.day[0])};--nf-ground:${n(i.night[1],i.day[1])}`+Jl(this.building?.settings.backdrop);return p`
- ${this._error?p`
${this._error}
`:f} ${this.renderTopLeft()} ${eu(this.hass,this._liveCards,(o,s,a,l)=>this.hass?.callService(o,s,{entity_id:a,...l}),{folded:this._houseFolded,toggle:()=>this.toggleHouseFold()},!!this.roomId||this.panelOpen)} ${this.clean?f:this.renderLegend()} ${this.renderMapCredit()}
+ ${this._error?p`
${this._error}
`:f} ${this.renderTopLeft()} ${nu(this.hass,this._liveCards,(s,a,l,c)=>this.hass?.callService(s,a,{entity_id:l,...c}),{folded:this._houseFolded,toggle:()=>this.toggleHouseFold()},!!this.roomId||this.panelOpen)} ${this.clean?f:this.renderLegend()} ${this.renderMapCredit()}
${this.renderAlerts()} ${this.renderAnnouncement()} ${this.clean?f:p`${this.renderThumbs()} ${this.renderScenes()} ${this.renderFind()} ${this.renderCentral()}`} ${this.renderSwipe()}
- ${this.renderMenu()} ${this.renderPlate()} ${this.renderEye()} ${this.renderLock()} ${this.renderWalk()} ${this.renderTravel()} ${this.renderClock()} ${this.renderToday()} ${this.renderLayers()} ${this.renderPluginWindow()}
+ ${this.renderMenu()} ${this.renderPlate()} ${this.renderEye()} ${this.renderLock()} ${this.renderWalk()} ${this.renderTravel()} ${this.renderClock()} ${this.renderToday(e)} ${this.renderLayers()} ${this.renderPluginWindow()}
${this.showStats&&this._stats?p`
${this._stats.fps?$(this.hass,"stats_fps",{fps:this._stats.fps,ms:this._stats.worstMs}):$(this.hass,"stats_idle")}
- ${this._stats.busy.length?p`(${this._stats.busy.map(o=>$(this.hass,`stats_busy_${o}`)).join(", ")})`:f} ·
+ ${this._stats.busy.length?p`(${this._stats.busy.map(s=>$(this.hass,`stats_busy_${s}`)).join(", ")})`:f} ·
${$(this.hass,"stats",{calls:this._stats.calls,tris:this._stats.triangles.toLocaleString()})} ·
- ${$(this.hass,this._stats.low?"stats_low":"stats_full",{r:W(this.hass,this._stats.pixelRatio,2)})}`:f}
-
`}static styles=[ge,Re,tu,X`
+
`}static styles=[ge,Re,ru,Y`
:host {
display: block;
position: relative;
@@ -2339,6 +2391,24 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
.nf-right-col > * {
pointer-events: auto;
}
+ .nf-utility-right {
+ height: calc(100% - 140px);
+ }
+ .nf-has-utility-overview:not(.nf-narrow) > .nf-energy,
+ .nf-has-utility-overview:not(.nf-narrow) > .nf-topleft {
+ max-width: calc(100% - 316px);
+ }
+ .nf-has-utility-overview .nf-energy {
+ align-items: flex-start;
+ }
+ .nf-narrow .nf-utility-right {
+ top: auto !important;
+ bottom: 64px;
+ height: 42%;
+ max-height: 42%;
+ justify-content: flex-end;
+ width: min(280px, calc(100% - 24px));
+ }
.nf-has-alerts .nf-right-col {
top: 58px;
}
@@ -3356,26 +3426,26 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
inset: auto 16px 16px;
color: var(--nf-danger);
}
- `]};customElements.get("nf-view3d")||customElements.define("nf-view3d",Wo);function ue(r,e){return Math.abs(e)>=1e3?`${W(r,e/1e3,1)} kW`:`${Math.round(e)} W`}function Co(r){return r.type==="tv_board"?r.h+.9:r.type==="tv_wall"||r.type==="kitchen_wall"?r.h+.25:r.h+.35}function xf(r,e){let t=e.attributes.percentage;return e.state==="on"&&typeof t=="number"?`${Math.round(t)} %`:oe(r,e)}var yu;function wu(){let r=new URL("./nextfloor-editor.js?v=85e8a031f17a",new URL(import.meta.url)).href;return yu??=import(r),yu}var kf=.25,xu=r=>Math.round(r*1e3)/1e3,ku=(r,e,t)=>r.rooms.find(n=>n.points.length>=3&&I([e,t],n.points));function Oo(r,e,t,n,i){let o=ku(r,e,t);if(!o)return[n,i];let s=(a,l)=>I([a,l],o.points);return s(n,i)?[n,i]:s(n,t)?[n,t]:s(e,i)?[e,i]:[e,t]}function Sf(r,e,t,n){return r.rooms.some(i=>i.id!==e.id&&i.points.some((o,s)=>{let a=i.points[(s+1)%i.points.length];return Math.abs(le(Q(o,t),n))<.02&&Math.abs(le(Q(a,t),n))<.02}))}var Lo=(r,e)=>Math.abs((r-e+540)%360-180);function Su(r,e,t,n=kf){let i=ku(r,e.x,e.z);if(!i)return null;let o=i.points,s=ut(o)>=0?1:-1,a=null;return o.forEach((l,c)=>{let u=o[(c+1)%o.length],d=We(Q(u,l));if(d<.3)return;let m=[(u[0]-l[0])/d,(u[1]-l[1])/d],h=[-m[1]*s,m[0]*s],g=le(Q([e.x,e.z],l),m);if(g<0||g>d)return;let _=Sf(r,i,l,h)?t/2:0,b=le(Q([e.x,e.z],l),h)-_,v=Math.atan2(-h[0],h[1])*180/Math.PI,k=[{rotation:v,extent:e.d/2},{rotation:v+90,extent:e.w/2},{rotation:v-90,extent:e.w/2}].reduce((z,R)=>Lo(e.rotation,R.rotation)
50)return;let M=b-k.extent;Math.abs(M)>n||a&&Math.abs(M)>=Math.abs(a.gap)||(a={x:xu(e.x-h[0]*M),z:xu(e.z-h[1]*M),rotation:(Math.round(k.rotation)%360+360)%360,gap:M})}),a&&{x:a.x,z:a.z,rotation:a.rotation}}function qr(r,e,t){let n=structuredClone(r);for(let i of n.floors){let o=i.furniture.find(s=>s.id===e);o&&t(o,i)}return n}function Zr(r,e,t){let n=structuredClone(r);for(let i of n.floors){let o=i.placements.find(s=>s.entity_id===e);o&&t(o,i)}return n}function $u(r,e){let t=structuredClone(r);for(let n of t.floors)n.furniture=n.furniture.filter(i=>i.id!==e);return t}function Mu(r,e){let t=structuredClone(r);for(let n of t.floors)n.placements=n.placements.filter(i=>i.entity_id!==e);return t}function Au(r,e,t,n){return Zr(r,e,(i,o)=>{[i.x,i.z]=Oo(o,i.x,i.z,t,n)})}function Eu(r,e,t,n){let i=r.settings.wall_interior??.12;return qr(r,e,(o,s)=>{[o.x,o.z]=Oo(s,o.x,o.z,t,n);let a=Su(s,o,i);a&&Object.assign(o,a)})}var Bo=(r,e)=>((r+e)%360+360)%360,Ru=r=>Number.parseFloat(r.replace(",",".")),Hn=(r,e)=>Math.round(r*10**e)/10**e;function Vo(r){let{min:e,max:t,accepts:n=()=>!0}=r,i=o=>{let s=Ru(o.target.value);!Number.isFinite(s)||!n(s)||r.apply(t===void 0?s:Math.min(t,Math.max(e,s)))};return p``}var Fu=(r,e)=>p`${r.t("height_auto")}`,Du=(r,e)=>p`e(-r)}>↺ ${r}°e(r)}>↻ ${r}°`;function Af(r,e){let t=r.building.floors.find(s=>s.furniture.some(a=>a.id===e)),n=t?.furniture.find(s=>s.id===e);if(!t||!n)return f;let i=(s,a)=>Uo({label:r.t(a),title:r.t(`size_${s}`),value:n[s],step:.05,min:.05,accepts:l=>l>0,apply:l=>r.editFurniture(e,c=>c[s]=Cn(l,3))}),o=js(n)?p`${Uo({label:"\u2195",title:r.t("mount_height"),value:n.mount_y??he(t,n),step:.05,min:0,accepts:s=>s>=0,apply:s=>r.editFurniture(e,a=>a.mount_y=Cn(s,3))})}
+ ${n.mount_y!=null?Fu(r,()=>r.editFurniture(e,s=>s.mount_y=null)):f}`:f;return p`${i("w","size_short_w")}${i("d","size_short_d")}${i("h","size_short_h")} ${o}`}function Ef(r,e){let t=r.building.floors.find(l=>l.placements.some(c=>c.entity_id===e)),n=t?.placements.find(l=>l.entity_id===e);if(!t||!n)return f;let i=H(e),o=(l,c,u)=>p``,s=["ceiling","floor","table","wall"].map(l=>[l,r.t(`lamp_${l}`)]),a=i?Et(i,ve(t,n.x,n.z),i==="light"?n.mount??"ceiling":null):1;return p`${i==="light"?o("lamp_mount",s,n.mount??"ceiling"):f}
- ${Vo({label:r.t("size_short_h"),title:r.t("marker_height"),value:n.y??a,step:.05,min:0,accepts:l=>l>=0,apply:l=>r.editDevice(e,c=>c.y=Hn(l,3))})}
- ${n.y!==null?Tu(r,()=>r.editDevice(e,l=>l.y=null)):f}`}function Du(r,e,t){let n=r.t,i;if(e){let o=r.building.floors.flatMap(s=>s.furniture).find(s=>s.id===e)?.type;i=p`${o?_e(r.hass,o):""}
- ${$f(r,e)} ${zu(45,s=>r.turnFurniture(e,s))}
+ `,s=["ceiling","floor","table","wall"].map(l=>[l,r.t(`lamp_${l}`)]),a=i?Dt(i,ve(t,n.x,n.z),i==="light"?n.mount??"ceiling":null):1;return p`${i==="light"?o("lamp_mount",s,n.mount??"ceiling"):f}
+ ${Uo({label:r.t("size_short_h"),title:r.t("marker_height"),value:n.y??a,step:.05,min:0,accepts:l=>l>=0,apply:l=>r.editDevice(e,c=>c.y=Cn(l,3))})}
+ ${n.y!==null?Fu(r,()=>r.editDevice(e,l=>l.y=null)):f}`}function Hu(r,e,t){let n=r.t,i;if(e){let o=r.building.floors.flatMap(s=>s.furniture).find(s=>s.id===e)?.type;i=p`${o?_e(r.hass,o):""}
+ ${Af(r,e)} ${Du(45,s=>r.turnFurniture(e,s))}
r.editFurniture(e,s=>s.mirror=!s.mirror)}>⇋ ${n("furn_mirror")}
r.removeFurniture(e)}>${n("delete")}`}else t?i=p`${L(r.hass,t)}
- ${Mf(r,t)} ${zu(45,o=>r.turnDevice(t,o))}
- r.removeDevice(t)}>${n("delete")}`:i=p`${n("furnish_hint")}`;return p`${i}r.finish()}>${n("done")}
`}var Fu=ne``;var de=(r,e)=>({name:r,fallback:e,read:t=>e?t!=="0":t==="1",write:t=>t?"1":"0"}),qt=(r,e,t)=>({name:r,fallback:t,read:n=>e.find(i=>i===n)??t,write:n=>n}),jo={explode:de("explode",!0),keepRoof:de("roof",!1),solidWalls:de("solid_walls",!1),quality:qt("quality",["auto","low","high"],"auto"),stats:de("stats",!1),markers:qt("markers",["none","important","all"],"important"),heat:qt("heat",["none","temperature","humidity","co2","mould","comfort","power","sun","values","wifi"],"none"),theme:qt("theme",Nr,"neon"),clock:qt("clock",["none","top_left","top_right","bottom_left","bottom_right"],"none"),accent:{name:"accent",fallback:null,read:r=>/^#[0-9a-f]{6}$/i.test(r)?r:null,write:r=>r??""},floorStack:qt("floor_stack",["dim","stacked","single"],"dim"),roomNames:de("room_names",!0),clean:de("clean",!1),navWrap:de("nav_wrap",!1),weather:de("weather",!0),timeSlider:de("time_slider",!1),menuOpen:de("menu_open",!1),keepCamera:de("keep_camera",!1),readable:de("readable",!1),plain:de("plain",!1),rightBack:de("right_back",!1),zoom:{name:"zoom",fallback:100,read:r=>/^\d{2,3}$/.test(r)?Math.min(250,Math.max(60,Number(r))):100,write:r=>String(Math.round(Math.min(250,Math.max(60,r))))},screenName:{name:"screen_name",fallback:"",read:r=>r.slice(0,60),write:r=>r.trim().slice(0,60)},announceMuted:de("announce_muted",!1),glassWalls:{name:"glass_walls",fallback:20,read:r=>/^\d{1,3}$/.test(r)?Math.min(100,Number(r)):20,write:r=>String(Math.round(Math.min(100,Math.max(0,r))))}};function Iu(r=ei()){try{return r?.getItem("nextfloor.screen_name")?.trim()||null}catch{return null}}function Nu(r=ei()){try{return r?.getItem("nextfloor.announce_muted")==="1"}catch{return!1}}function ei(){try{return localStorage}catch{return null}}var Xr=class{storage;constructor(e){this.storage=e}raw(e){try{return this.storage?.getItem(`nextfloor.${e}`)??null}catch{return null}}load(e=""){let t={};for(let n of Object.keys(jo)){let i=jo[n],o=this.raw(i.name);t[n]=o===null?i.fallback:i.read(o)}return new URLSearchParams(e).has("nf_stats")&&(t.stats=!0),t}save(e,t){let n=jo[e];try{this.storage?.setItem(`nextfloor.${n.name}`,n.write(t))}catch{}}};var Cu=Y`
.nf-dot {
display: inline-block;
width: 8px;
@@ -3867,11 +3937,11 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
gap: 12px;
margin: auto;
}
-`;var Nu=new WeakMap,Cu=new WeakMap;function bt(r,e){let t=Cu.get(r)??r,n=Nu.get(t)??new WeakMap;Nu.set(t,n);let i=n.get(e);if(i)return i;let o=new Map;for(let l of e)for(let c of l.placements)c.entity_id.startsWith("cover.")&&o.set(c.entity_id,{tilt:c.cover_tilt==="none"?null:c.cover_tilt,position:c.position});for(let l of He(t,e).values())l.cover&&!o.has(l.cover)&&o.set(l.cover,{tilt:l.coverTilt,position:l.position}),l.cover2&&!o.has(l.cover2)&&o.set(l.cover2,{tilt:l.cover2Tilt});let s={...t.states};for(let[l,c]of o){let u=t.states[l];if(!u)continue;let d={...u.attributes,nf_cover_control:!0},m=Rt(t,c.position);m===null&&(m=typeof u.attributes.current_position=="number"?u.attributes.current_position:null),m!==null&&(d.current_position=m);let h=c.tilt?t.states[c.tilt]:u,g=typeof h?.attributes.current_tilt_position=="number"?h.attributes.current_tilt_position:c.tilt?Rt(t,c.tilt):null;g!==null&&(d.current_tilt_position=g,d.supported_features=Number(d.supported_features??0)|128);let _=u.state;typeof d.current_position=="number"&&_!=="unavailable"&&_!=="unknown"&&_!=="opening"&&_!=="closing"&&(_=d.current_position>0?"open":"closed"),s[l]={...u,state:_,attributes:d}}let a={...t,states:s,callService:async(l,c,u={})=>{if(l!=="cover")return t.callService(l,c,u);let d=Array.isArray(u.entity_id)?u.entity_id:[u.entity_id],m=async h=>{let g=typeof h=="string"?o.get(h):void 0;if(!g)return t.callService(l,c,{...u,entity_id:h});let _={...u,entity_id:h},b=c;(b==="toggle"||b==="toggle_cover")&&(b=s[String(h)]?.state==="closed"?"open_cover":"close_cover");let v=b.includes("tilt");v&&g.tilt&&(_.entity_id=g.tilt);let S=g.tilt?t.states[g.tilt]:void 0;return v&&g.tilt&&!S?.attributes.symcon_id&&typeof S?.attributes.current_tilt_position!="number"&&(b==="set_cover_tilt_position"?(b="set_cover_position",_.position=_.tilt_position,delete _.tilt_position):b==="open_cover_tilt"?b="open_cover":b==="close_cover_tilt"&&(b="close_cover")),t.callService(l,b,_)};return Array.isArray(u.entity_id)?Promise.all(d.map(m)):m(d[0])}};return Cu.set(a,t),n.set(e,a),a}var Go=class extends ee{static properties={hass:{attribute:!1},narrow:{type:Boolean},route:{attribute:!1},panel:{attribute:!1},_mode:{state:!0},_editorReady:{state:!0},_floorId:{state:!0},_roomId:{state:!0},_wallMode:{state:!0},_prefs:{state:!0},_furnish:{state:!0},_selFurniture:{state:!0},_selDevice:{state:!0},_optsOpen:{state:!0},_switchesOpen:{state:!0},_timeOfDay:{state:!0},_outside:{state:!0},_timeDrag:{state:!0},_floorUndo:{state:!0},_variablesLoading:{state:!0},_variablesNotice:{state:!0},_variablesError:{state:!0}};outsideMemo=null;floorUndoTimer;data=new At(this);store=new Yr(Jr());constructor(){super(),this.narrow=!1,this._mode="view",this._editorReady=!!customElements.get("nf-editor"),this._floorId=null,this._roomId=null,this._wallMode="auto",this._prefs=this.store.load(location.search),this._furnish=!1,this._selFurniture=null,this._selDevice=null,this._optsOpen=!1,this._switchesOpen=!1,this._timeOfDay=null,this._outside=!1,this._timeDrag=null,this._floorUndo=null,this._variablesLoading=!1,this._variablesNotice="",this._variablesError=!1}toggleTimeSlider(e){this.setPref("timeSlider",e),e||([this._timeOfDay,this._timeDrag]=[null,null])}sunState(){let e=this.hass?.config;return this._timeOfDay===null||e?.latitude===void 0||e.longitude===void 0?this.hass?.states["sun.sun"]?.state:ct(xt(this._timeOfDay,e.time_zone),e.latitude,e.longitude).elevation>0?"above_horizon":"below_horizon"}renderTimeOfDay(){let e=this.t;if(this.hass?.config?.latitude===void 0)return f;let t=this._timeDrag??this._timeOfDay,n=o=>`${String(Math.floor(o)).padStart(2,"0")}:${String(Math.round(o%1*60)).padStart(2,"0")}`,i=()=>{let o=new Date;return Math.round((o.getHours()+o.getMinutes()/60)*4)/4};return p`(this._timeDrag=null,this._timeOfDay=t===null?i():null)}>☀ ${t===null?e("time_of_day"):n(t)}
+`;var Ou=new WeakMap,Lu=new WeakMap;function xt(r,e){let t=Lu.get(r)??r,n=Ou.get(t)??new WeakMap;Ou.set(t,n);let i=n.get(e);if(i)return i;let o=new Map;for(let l of e)for(let c of l.placements)c.entity_id.startsWith("cover.")&&o.set(c.entity_id,{tilt:c.cover_tilt==="none"?null:c.cover_tilt,position:c.position});for(let l of Ne(t,e).values())l.cover&&!o.has(l.cover)&&o.set(l.cover,{tilt:l.coverTilt,position:l.position}),l.cover2&&!o.has(l.cover2)&&o.set(l.cover2,{tilt:l.cover2Tilt});let s={...t.states};for(let[l,c]of o){let u=t.states[l];if(!u)continue;let d={...u.attributes,nf_cover_control:!0},m=Ft(t,c.position);m===null&&(m=typeof u.attributes.current_position=="number"?u.attributes.current_position:null),m!==null&&(d.current_position=m);let h=c.tilt?t.states[c.tilt]:u,g=typeof h?.attributes.current_tilt_position=="number"?h.attributes.current_tilt_position:c.tilt?Ft(t,c.tilt):null;g!==null&&(d.current_tilt_position=g,d.supported_features=Number(d.supported_features??0)|128);let _=u.state;typeof d.current_position=="number"&&_!=="unavailable"&&_!=="unknown"&&_!=="opening"&&_!=="closing"&&(_=d.current_position>0?"open":"closed"),s[l]={...u,state:_,attributes:d}}let a={...t,states:s,callService:async(l,c,u={})=>{if(l!=="cover")return t.callService(l,c,u);let d=Array.isArray(u.entity_id)?u.entity_id:[u.entity_id],m=async h=>{let g=typeof h=="string"?o.get(h):void 0;if(!g)return t.callService(l,c,{...u,entity_id:h});let _={...u,entity_id:h},b=c;(b==="toggle"||b==="toggle_cover")&&(b=s[String(h)]?.state==="closed"?"open_cover":"close_cover");let v=b.includes("tilt");v&&g.tilt&&(_.entity_id=g.tilt);let S=g.tilt?t.states[g.tilt]:void 0;return v&&g.tilt&&!S?.attributes.symcon_id&&typeof S?.attributes.current_tilt_position!="number"&&(b==="set_cover_tilt_position"?(b="set_cover_position",_.position=_.tilt_position,delete _.tilt_position):b==="open_cover_tilt"?b="open_cover":b==="close_cover_tilt"&&(b="close_cover")),t.callService(l,b,_)};return Array.isArray(u.entity_id)?Promise.all(d.map(m)):m(d[0])}};return Lu.set(a,t),n.set(e,a),a}var qo=class extends Q{static properties={hass:{attribute:!1},narrow:{type:Boolean},route:{attribute:!1},panel:{attribute:!1},_mode:{state:!0},_editorReady:{state:!0},_floorId:{state:!0},_roomId:{state:!0},_wallMode:{state:!0},_prefs:{state:!0},_furnish:{state:!0},_selFurniture:{state:!0},_selDevice:{state:!0},_optsOpen:{state:!0},_switchesOpen:{state:!0},_timeOfDay:{state:!0},_outside:{state:!0},_timeDrag:{state:!0},_floorUndo:{state:!0},_variablesLoading:{state:!0},_variablesNotice:{state:!0},_variablesError:{state:!0}};outsideMemo=null;floorUndoTimer;data=new Tt(this);store=new Xr(ei());constructor(){super(),this.narrow=!1,this._mode="view",this._editorReady=!!customElements.get("nf-editor"),this._floorId=null,this._roomId=null,this._wallMode="auto",this._prefs=this.store.load(location.search),this._furnish=!1,this._selFurniture=null,this._selDevice=null,this._optsOpen=!1,this._switchesOpen=!1,this._timeOfDay=null,this._outside=!1,this._timeDrag=null,this._floorUndo=null,this._variablesLoading=!1,this._variablesNotice="",this._variablesError=!1}toggleTimeSlider(e){this.setPref("timeSlider",e),e||([this._timeOfDay,this._timeDrag]=[null,null])}sunState(){let e=this.hass?.config;return this._timeOfDay===null||e?.latitude===void 0||e.longitude===void 0?this.hass?.states["sun.sun"]?.state:mt(Mt(this._timeOfDay,e.time_zone),e.latitude,e.longitude).elevation>0?"above_horizon":"below_horizon"}renderTimeOfDay(){let e=this.t;if(this.hass?.config?.latitude===void 0)return f;let t=this._timeDrag??this._timeOfDay,n=o=>`${String(Math.floor(o)).padStart(2,"0")}:${String(Math.round(o%1*60)).padStart(2,"0")}`,i=()=>{let o=new Date;return Math.round((o.getHours()+o.getMinutes()/60)*4)/4};return p`(this._timeDrag=null,this._timeOfDay=t===null?i():null)}>☀ ${t===null?e("time_of_day"):n(t)}
${t!==null?p`this._timeDrag=Number(o.target.value)}
@change=${o=>(this._timeDrag=null,this._timeOfDay=Number(o.target.value))}
- />`:f}`}t=(e,t)=>$(this.hass,e,t);setPref(e,t){this._prefs={...this._prefs,[e]:t},this.store.save(e,t)}willUpdate(e){this.toggleAttribute("readable",!!this._prefs?.readable),e.has("hass")&&this.hass&&(this.style.colorScheme=wr(this.hass),this.data.setHass(this.hass));let t=this.data.building;t&&this._floorId&&!t.floors.some(n=>n.id===this._floorId)&&(this._floorId=null,this._roomId=null)}get isAdmin(){return this.hass?.user?.is_admin??!1}setMode(e){e!==this._mode&&(e==="view"&&this.data.flush(),this._mode=e)}openFloor(e){this._floorId=e,this._roomId=null,this._outside=!1}outsideIds(e){let t=this.outsideMemo;if(t&&t.building===e&&t.entities===this.hass.entities)return t.ids;let n=ln(this.hass,e.floors,e.settings.outside_hidden);return this.outsideMemo={building:e,entities:this.hass.entities,ids:n},n}openOutside(){let e=!this._outside;this.openFloor(null),this._outside=e}onRoomTap(e){let{floorId:t,roomId:n}=e.detail;if(n==="nf-outside")return this.openOutside();if((this.data.building?.floors.length??0)>1&&t&&this._floorId!==t)return this.openFloor(t);n&&(this._roomId=n===this._roomId?null:n,this._outside=!1)}furnishHost={hass:void 0,building:void 0,t:this.t,editFurniture:(e,t)=>this.applyEdit(n=>qr(n,e,t)),editDevice:(e,t)=>this.applyEdit(n=>Zr(n,e,t)),turnFurniture:(e,t)=>this.applyEdit(n=>qr(n,e,i=>i.rotation=Bo(i.rotation,t))),turnDevice:(e,t)=>this.applyEdit(n=>Zr(n,e,i=>i.rotation=Bo(i.rotation??0,t))),removeFurniture:e=>{this.applyEdit(t=>$u(t,e)),this._selFurniture=null},removeDevice:e=>{this.applyEdit(t=>Mu(t,e)),this._selDevice=null},finish:()=>{this._furnish=!1,this._selFurniture=null,this._selDevice=null}};saveMoods(e,t){this.applyEdit(n=>({...n,floors:n.floors.map(i=>({...i,rooms:i.rooms.map(o=>o.id===e?{...o,moods:t.length?t:void 0}:o)}))}))}applyEdit(e){let t=this.data.building;t&&this.data.edit(e(t))}view3d(){return this.renderRoot.querySelector("nf-view3d")}back(){this._outside?this._outside=!1:this._roomId?this._roomId=null:this._floorId&&(this.data.building?.floors.length??0)>1?this._floorId=null:this.view3d()?.resetView()}onKey=e=>{e.key!=="Escape"||this._mode!=="view"||(this._prefs.clean?this.setPref("clean",!1):this.back())};connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this.onKey)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.onKey)}render(){if(this.hass&&fr(this.hass,this))return f;let e=this.data.building,t=this._prefs.clean&&this._mode==="view",n=f;return e&&(this._mode==="editor"&&this.isAdmin?n=this.renderEditor(e):this._mode==="extensions"&&this.isAdmin?n=this.renderExtensions():n=this.renderView(e)),p`
+ />`:f}`}t=(e,t)=>$(this.hass,e,t);setPref(e,t){this._prefs={...this._prefs,[e]:t},this.store.save(e,t)}willUpdate(e){this.toggleAttribute("readable",!!this._prefs?.readable),e.has("hass")&&this.hass&&(this.style.colorScheme=$r(this.hass),this.data.setHass(this.hass));let t=this.data.building;t&&this._floorId&&!t.floors.some(n=>n.id===this._floorId)&&(this._floorId=null,this._roomId=null)}get isAdmin(){return this.hass?.user?.is_admin??!1}setMode(e){e!==this._mode&&(e==="view"&&this.data.flush(),this._mode=e)}openFloor(e){this._floorId=e,this._roomId=null,this._outside=!1}outsideIds(e){let t=this.outsideMemo;if(t&&t.building===e&&t.entities===this.hass.entities)return t.ids;let n=dn(this.hass,e.floors,e.settings.outside_hidden);return this.outsideMemo={building:e,entities:this.hass.entities,ids:n},n}openOutside(){let e=!this._outside;this.openFloor(null),this._outside=e}onRoomTap(e){let{floorId:t,roomId:n}=e.detail;if(n==="nf-outside")return this.openOutside();if((this.data.building?.floors.length??0)>1&&t&&this._floorId!==t)return this.openFloor(t);n&&(this._roomId=n===this._roomId?null:n,this._outside=!1)}furnishHost={hass:void 0,building:void 0,t:this.t,editFurniture:(e,t)=>this.applyEdit(n=>Jr(n,e,t)),editDevice:(e,t)=>this.applyEdit(n=>Qr(n,e,t)),turnFurniture:(e,t)=>this.applyEdit(n=>Jr(n,e,i=>i.rotation=Go(i.rotation,t))),turnDevice:(e,t)=>this.applyEdit(n=>Qr(n,e,i=>i.rotation=Go(i.rotation??0,t))),removeFurniture:e=>{this.applyEdit(t=>Au(t,e)),this._selFurniture=null},removeDevice:e=>{this.applyEdit(t=>Eu(t,e)),this._selDevice=null},finish:()=>{this._furnish=!1,this._selFurniture=null,this._selDevice=null}};saveMoods(e,t){this.applyEdit(n=>({...n,floors:n.floors.map(i=>({...i,rooms:i.rooms.map(o=>o.id===e?{...o,moods:t.length?t:void 0}:o)}))}))}applyEdit(e){let t=this.data.building;t&&this.data.edit(e(t))}view3d(){return this.renderRoot.querySelector("nf-view3d")}back(){this._outside?this._outside=!1:this._roomId?this._roomId=null:this._floorId&&(this.data.building?.floors.length??0)>1?this._floorId=null:this.view3d()?.resetView()}onKey=e=>{e.key!=="Escape"||this._mode!=="view"||(this._prefs.clean?this.setPref("clean",!1):this.back())};connectedCallback(){super.connectedCallback(),window.addEventListener("keydown",this.onKey)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.onKey)}render(){if(this.hass&&vr(this.hass,this))return f;let e=this.data.building,t=this._prefs.clean&&this._mode==="view",n=f;return e&&(this._mode==="editor"&&this.isAdmin?n=this.renderEditor(e):this._mode==="extensions"&&this.isAdmin?n=this.renderExtensions():n=this.renderView(e)),p`
${t?f:p`${this.renderHeader(e)}${this.renderNotices()}`}
${this.data.error&&!e?p`
${this.t("load_error")}: ${this.data.error}
`:f}
${!e&&!this.data.error?p`
${this.t("loading")}
`:f}
@@ -3884,7 +3954,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
`}renderViewOptions(){let e=this._prefs;return p`
this._optsOpen=!this._optsOpen}>⚙
${this.choiceRow("quality",["auto","low","high"],e.quality,t=>this.t(`quality_${t}`),t=>this.setPref("quality",t))}
- ${this.choiceRow("theme",Hr,e.theme,t=>this.t(`theme_${t}`),t=>this.setPref("theme",t),this.accentPicker())}
+ ${this.choiceRow("theme",Nr,e.theme,t=>this.t(`theme_${t}`),t=>this.setPref("theme",t),this.accentPicker())}
${this.choiceRow("markers",["none","important","all"],e.markers,t=>this.t(`markers_${t}`),t=>this.setPref("markers",t))}
🕒
@@ -3900,7 +3970,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
>${this.t("glass_walls")}
this.setPref("glassWalls",Number(t.target.value))} />
- ${G(this.hass)?f:p`
+ ${K(this.hass)?f:p`
${e.announceMuted?"\u{1F507}":"\u{1F4E2}"}
`}async reloadVariables(){if(!(this._variablesLoading||!this.hass.symconRefresh)){this._variablesLoading=!0,this._variablesNotice="",this._variablesError=!1;try{await this.hass.symconRefresh(),this._variablesNotice=this.t("symcon_variables_loaded")}catch(e){this._variablesError=!0,this._variablesNotice=this.t("symcon_variables_error",{error:e instanceof Error?e.message:String(e)})}finally{this._variablesLoading=!1}}}renderHeader(e){let t=this.hass?.symconTitle?.trim()||"NextFloor",n=this.data.saveState,i=(s,a,l="")=>p`
this.setMode(s)}>${a}`,o=n==="saving"?"saving":n==="saved"?"saved":"save_error";return p`
`)}return t.length>0?p`
${t}
`:f}whenEditorLoaded(e){return this._editorReady?e():(wu().then(()=>this._editorReady=!0,t=>this.data.error=String(t)),p`
`)}renderExtensions(){return this.whenEditorLoaded(()=>p`
`)}return t.length>0?p`${t}
`:f}whenEditorLoaded(e){return this._editorReady?e():(ku().then(()=>this._editorReady=!0,t=>this.data.error=String(t)),p``)}renderExtensions(){return this.whenEditorLoaded(()=>p`{this.data.reloadPacks()}}
@plugins-changed=${e=>this.applyEdit(t=>({...t,settings:{...t.settings,plugins:e.detail}}))}>`)}renderEditor(e){return this.whenEditorLoaded(()=>p`this.hass.states[n]?.attributes.symcon_path||this.hass.states
.roomLabels=${this._prefs.roomNames}
@room-names-change=${t=>this.setPref("roomNames",t.detail.value)}
.packs=${this.data.packs}
- .loadCardEditor=${Ln}
+ .loadCardEditor=${Kn}
@packs-changed=${()=>{this.data.reloadPacks()}}
@building-changed=${t=>this.data.edit(t.detail.building)}
- >`)}onNavWheel=e=>{if(this._prefs.navWrap||!e.deltaY||e.deltaX)return;let t=e.currentTarget;t.scrollWidth<=t.clientWidth||(t.scrollLeft+=e.deltaY,e.preventDefault())};allOffChip(e){let t=this._floorId?e.floors.find(i=>i.id===this._floorId):e.floors.length===1?e.floors[0]:void 0;if(!t||!this.hass)return f;if(this._floorUndo){let i=this._floorUndo;return p`{for(let o of i)this.hass.callService(o.domain,o.service,o.data);this._floorUndo=null,clearTimeout(this.floorUndoTimer)}}>↶ ${this.t("all_off_undo")}`}let n=bn(Kl(t).map(i=>this.hass.states[i]));return n.count<2?f:p`{for(let i of n.off)this.hass.callService(i.domain,i.service,i.data);this._floorUndo=n.undo,clearTimeout(this.floorUndoTimer),this.floorUndoTimer=setTimeout(()=>this._floorUndo=null,1e4)}}>⏻ ${n.count}`}renderNav(e){let t=e.floors.filter(c=>!this._floorId||c.id===this._floorId),n=e.floors.length>1,i=this._prefs.navWrap,o=this.outsideIds(e).length?p`this.openOutside()}>🌳 ${this.t("outside_area")}`:f,s=n?p`this.openFloor(null)}>${this.t("all_floors")}
+ >`)}onNavWheel=e=>{if(this._prefs.navWrap||!e.deltaY||e.deltaX)return;let t=e.currentTarget;t.scrollWidth<=t.clientWidth||(t.scrollLeft+=e.deltaY,e.preventDefault())};allOffChip(e){let t=this._floorId?e.floors.find(i=>i.id===this._floorId):e.floors.length===1?e.floors[0]:void 0;if(!t||!this.hass)return f;if(this._floorUndo){let i=this._floorUndo;return p`{for(let o of i)this.hass.callService(o.domain,o.service,o.data);this._floorUndo=null,clearTimeout(this.floorUndoTimer)}}>↶ ${this.t("all_off_undo")}`}let n=xn(Ul(t).map(i=>this.hass.states[i]));return n.count<2?f:p`{for(let i of n.off)this.hass.callService(i.domain,i.service,i.data);this._floorUndo=n.undo,clearTimeout(this.floorUndoTimer),this.floorUndoTimer=setTimeout(()=>this._floorUndo=null,1e4)}}>⏻ ${n.count}`}renderNav(e){let t=e.floors.filter(c=>!this._floorId||c.id===this._floorId),n=e.floors.length>1,i=this._prefs.navWrap,o=this.outsideIds(e).length?p`this.openOutside()}>🌳 ${this.t("outside_area")}`:f,s=n?p`this.openFloor(null)}>${this.t("all_floors")}
${[...e.floors].reverse().map(c=>p`this.openFloor(c.id)}>${c.name}`)}
${o} ${this.allOffChip(e)}
`:p`${o} ${this.allOffChip(e)}`,a=t.flatMap(c=>[t.length>1&&c.rooms.length?p`${c.name}`:f,...c.rooms.map(u=>p`this.hass.states[n]?.attributes.symcon_path||this.hass.states
this.hass.states[n]?.attributes.symcon_path||this.hass.states
.keepRoof=${t.keepRoof}
.markerMode=${t.markers}
.heatMode=${t.heat}
- .theme=${Pr(t.theme,this.sunState())}
+ .theme=${Cr(t.theme,this.sunState())}
.timeOfDay=${this._timeOfDay}
.clock=${t.clock==="none"?null:t.clock}
- .announcements=${!G(this.hass)&&!t.announceMuted}
+ .announcements=${!K(this.hass)&&!t.announceMuted}
.glassWalls=${t.glassWalls}
.screenName=${t.screenName||null}
.lockButton=${!0}
@@ -4030,9 +4100,9 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
?furnish=${this._furnish}
.selectedFurniture=${this._selFurniture}
@furniture-select=${i=>this._selFurniture=i.detail.id}
- @furniture-move=${i=>this.applyEdit(o=>Eu(o,i.detail.id,i.detail.x,i.detail.z))}
+ @furniture-move=${i=>this.applyEdit(o=>zu(o,i.detail.id,i.detail.x,i.detail.z))}
@device-select=${i=>this._selDevice=i.detail.id}
- @device-move=${i=>this.applyEdit(o=>Au(o,i.detail.id,i.detail.x,i.detail.z))}
+ @device-move=${i=>this.applyEdit(o=>Ru(o,i.detail.id,i.detail.x,i.detail.z))}
.quality=${t.quality}
?showStats=${t.stats}
@room-tap=${this.onRoomTap}
@@ -4042,10 +4112,10 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
${n?p`i.rooms.some(o=>o.id===this._roomId))??null}
- .confirmEntities=${mt(this.hass,e.floors)}
+ .confirmEntities=${_t(this.hass,e.floors)}
.phrases=${e.settings.announce_phrases??null}
.rooms=${e.floors.flatMap(i=>i.rooms)}
@mood-change=${i=>this.saveMoods(i.detail.roomId,i.detail.moods)}
@@ -4053,17 +4123,17 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
>`:this._outside?p`this._outside=!1}
>`:f}
${t.clean?f:this.renderOverlay(e)}
- ${this._furnish?Du(this.furnishHost,this._selFurniture,this._selDevice):f}
+ ${this._furnish?Hu(this.furnishHost,this._selFurniture,this._selDevice):f}
- `}static styles=[ge,Re,Iu,yr]};customElements.get("nextfloor-panel")||customElements.define("nextfloor-panel",Go);var Af=/^(\d{1,2}):(\d{2})\s*-\s*(\d{1,2}):(\d{2})$/,Wu=(r,e)=>Number(r)*60+Number(e);function Pn(r,e,t=new Date){if(!r||r==="off")return!1;if(r==="sun")return e?.states["sun.sun"]?.state==="below_horizon";let n=Af.exec(r.trim());if(!n)return!1;let i=Wu(n[1],n[2]),o=Wu(n[3],n[4]),s=t.getHours()*60+t.getMinutes();return i>o?s>=i||s=i&&s0&&(e&&this.host.isClean()&&this.host.setClean(!1),this.cleanTimer=setTimeout(()=>this.host.setClean(!0),t*1e3))}stopClean(){clearTimeout(this.cleanTimer)}armIdle(){clearTimeout(this.idleTimer);let e=this.host.config()?.idle_return??0;e>0&&(this.idleTimer=setTimeout(()=>this.host.goHome(),e*1e3))}touched(){this.host.isOrbit()&&this.host.setOrbit(!1),this.armIdle(),this.armClean(!0)}start(){this.armIdle(),this.nightTimer=setInterval(()=>this.host.setNight(Pn(this.host.config()?.night,this.host.hass())),6e4)}stop(){clearTimeout(this.cleanTimer),clearTimeout(this.idleTimer),clearInterval(this.nightTimer)}};function Lu(r,e){return r?r.floors.filter(t=>(e===null||t.id===e)&&t.rooms.length>0).map(t=>({floorId:t.id,floorName:t.name,rooms:t.rooms.map(n=>({id:n.id,name:n.name||"\u2013",floorId:t.id}))})):[]}var Ou=X`
+ `}static styles=[ge,Re,Cu,Sr]};customElements.get("nextfloor-panel")||customElements.define("nextfloor-panel",qo);var Rf=/^(\d{1,2}):(\d{2})\s*-\s*(\d{1,2}):(\d{2})$/,Wu=(r,e)=>Number(r)*60+Number(e);function On(r,e,t=new Date){if(!r||r==="off")return!1;if(r==="sun")return e?.states["sun.sun"]?.state==="below_horizon";let n=Rf.exec(r.trim());if(!n)return!1;let i=Wu(n[1],n[2]),o=Wu(n[3],n[4]),s=t.getHours()*60+t.getMinutes();return i>o?s>=i||s=i&&s0&&(e&&this.host.isClean()&&this.host.setClean(!1),this.cleanTimer=setTimeout(()=>this.host.setClean(!0),t*1e3))}stopClean(){clearTimeout(this.cleanTimer)}armIdle(){clearTimeout(this.idleTimer);let e=this.host.config()?.idle_return??0;e>0&&(this.idleTimer=setTimeout(()=>this.host.goHome(),e*1e3))}touched(){this.host.isOrbit()&&this.host.setOrbit(!1),this.armIdle(),this.armClean(!0)}start(){this.armIdle(),this.nightTimer=setInterval(()=>this.host.setNight(On(this.host.config()?.night,this.host.hass())),6e4)}stop(){clearTimeout(this.cleanTimer),clearTimeout(this.idleTimer),clearInterval(this.nightTimer)}};function Bu(r,e){return r?r.floors.filter(t=>(e===null||t.id===e)&&t.rooms.length>0).map(t=>({floorId:t.id,floorName:t.name,rooms:t.rooms.map(n=>({id:n.id,name:n.name||"\u2013",floorId:t.id}))})):[]}var Vu=Y`
ha-card {
overflow: hidden;
background: var(--nf-bg);
@@ -4187,26 +4257,26 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
justify-content: flex-end;
}
}
-`;function Uo(r,e){let t=r.template,n=t?e?.[t]:void 0;if(!n)return r;let{type:i,template:o,...s}=n;return{...s,...r}}function Bu(r,e){let t=new Set(e),n=[];for(let o of r.floors){let s=o.rooms.filter(c=>t.has(c.id));if(!s.length)continue;let a=(c,u)=>s.some(d=>d.points.length>=3&&I([c,u],d.points)),l=new Set(s.map(c=>c.id));n.push({...o,rooms:s,openings:o.openings.filter(c=>l.has(c.room_id)),furniture:o.furniture.filter(c=>a(c.x,c.z)),placements:o.placements.filter(c=>a(c.x,c.z)),walls:(o.walls??[]).filter(c=>a((c.a[0]+c.b[0])/2,(c.a[1]+c.b[1])/2)),outdoor:[]})}let i={...r.settings.roof,type:"none",sections:[],solar:[]};return{...r,floors:n,settings:{...r.settings,roof:i}}}var Gt="nf-outside",jo=class extends ee{static properties={hass:{attribute:!1},_config:{state:!0},_roomId:{state:!0},_floorId:{state:!0},_walls:{state:!0},_heat:{state:!0},_explode:{state:!0},_fullscreen:{state:!0},_clean:{state:!0},_night:{state:!0},_orbit:{state:!0},_roomNames:{state:!0}};_own=null;templatesSeen;roomApplied=!1;data=new At(this);kiosk=new Qr({config:()=>this._config,hass:()=>this.hass,setClean:e=>this._clean=e,isClean:()=>this._clean,setOrbit:e=>this._orbit=e,isOrbit:()=>this._orbit,setNight:e=>this._night=e,goHome:()=>this.returnHome()});constructor(){super(),this._roomId=null,this._floorId=void 0,this._walls=null,this._heat=null,this._explode=null,this._fullscreen=!1,this._clean=!1,this._night=!1,this._orbit=!1,this._roomNames=null}view3d(){return this.shadowRoot?.querySelector("nf-view3d")}returnHome(){this._roomId=this._config?.room??null,this._floorId=void 0,this.view3d()?.resetView(),this._config?.idle_orbit&&(this._orbit=!0)}openDashboard(e){history.pushState(null,"",e),window.dispatchEvent(new CustomEvent("location-changed",{bubbles:!0,composed:!0,detail:{replace:!1}}))}onFullscreen=()=>this._fullscreen=!!document.fullscreenElement&&this.shadowRoot?.contains(document.fullscreenElement)===!0;connectedCallback(){super.connectedCallback(),document.addEventListener("fullscreenchange",this.onFullscreen),this.kiosk.start()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("fullscreenchange",this.onFullscreen),this.kiosk.stop()}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.shadowRoot?.querySelector("ha-card")?.requestFullscreen?.()}static async getConfigElement(){return await Ln(),document.createElement("nextfloor-card-editor")}static getStubConfig(){return{type:"custom:nextfloor-card"}}setConfig(e){if(e.height!==void 0&&!(e.height>100))throw new Error("height must be a number of pixels above 100");this._roomNames=null,this._own=e,this._config=Uo(e,this.data.building?.settings.card_templates),this._floorId=void 0,this._walls=null,this._heat=null,this._explode=null,this._orbit=!1,this._night=Pn(e.night,this.hass),this._clean=e.controls_hidden===!0,this.kiosk.armClean(),this.kiosk.armIdle()}getCardSize(){return Math.ceil((this._config?.height??420)/50)}getGridOptions(){return{columns:"full",rows:this._config?.fill?12:Math.ceil((this._config?.height??420)/56),min_rows:4}}willUpdate(e){let t=this.data.building?.settings.card_templates;if(this._own?.template&&t!==this.templatesSeen&&(this.templatesSeen=t,this._config=Uo(this._own,t)),this.toggleAttribute("readable",this._config?.readable===!0),e.has("hass")&&(this.style.colorScheme=wr(this.hass)),!e.has("hass")||!this.hass)return;this.data.setHass(this.hass);let n=Pn(this._config?.night,this.hass);n!==this._night&&(this._night=n)}get canSwitch(){return!this._config?.floor||this.thumbs}get thumbs(){return this._config?.floor_thumbs??!this._config?.floor}back(){this._roomId?this._roomId=null:this.canSwitch&&(this._floorId=null)}roomsMemo=null;plan(){let e=this.data.building??null,t=this._config?.rooms;if(!e||!t?.length)return e;let n=t.join(",");return(!this.roomsMemo||this.roomsMemo.source!==e||this.roomsMemo.ids!==n)&&(this.roomsMemo={source:e,ids:n,result:Bu(e,t)}),this.roomsMemo.result}t=e=>$(this.hass,e);stage(){let e=this.plan(),t=this._config,n=this._floorId===void 0?t?.floor??null:this._floorId,i=e&&e.floors.length===1?e.floors[0].id:e?.floors.some(a=>a.id===n)?n:null,o=!!this._roomId&&t?.room_panel!==!1,s=!!this._roomId&&t?.room_panel===!1||!this.thumbs&&this.canSwitch&&!this._roomId&&!!i&&(e?.floors.length??0)>1;return{floorId:i,walls:this._walls??t?.walls??"auto",heat:this._heat??t?.heatmap??"none",explode:this._explode??t?.explode??!0,canGoBack:s,showBar:!!e&&!this._clean&&(s||!!t?.controls&&!o)}}shows(e){let t=this._config?.controls;return t===!0||Array.isArray(t)&&t.includes(e)}renderBar(e){let t=this.plan(),n=this.t,i=["temperature","humidity","co2"].filter(s=>this.shows(s)),o=(s,a)=>p`${a.map(([l,c,u])=>p`${u}`)}
`;return p`
+`;function Zo(r,e){let t=r.template,n=t?e?.[t]:void 0;if(!n)return r;let{type:i,template:o,...s}=n;return{...s,...r}}function Ku(r,e){let t=new Set(e),n=[];for(let o of r.floors){let s=o.rooms.filter(c=>t.has(c.id));if(!s.length)continue;let a=(c,u)=>s.some(d=>d.points.length>=3&&I([c,u],d.points)),l=new Set(s.map(c=>c.id));n.push({...o,rooms:s,openings:o.openings.filter(c=>l.has(c.room_id)),furniture:o.furniture.filter(c=>a(c.x,c.z)),placements:o.placements.filter(c=>a(c.x,c.z)),walls:(o.walls??[]).filter(c=>a((c.a[0]+c.b[0])/2,(c.a[1]+c.b[1])/2)),outdoor:[]})}let i={...r.settings.roof,type:"none",sections:[],solar:[]};return{...r,floors:n,settings:{...r.settings,roof:i}}}var Zt="nf-outside",Yo=class extends Q{static properties={hass:{attribute:!1},_config:{state:!0},_roomId:{state:!0},_floorId:{state:!0},_walls:{state:!0},_heat:{state:!0},_explode:{state:!0},_fullscreen:{state:!0},_clean:{state:!0},_night:{state:!0},_orbit:{state:!0},_roomNames:{state:!0}};_own=null;templatesSeen;roomApplied=!1;data=new Tt(this);kiosk=new ti({config:()=>this._config,hass:()=>this.hass,setClean:e=>this._clean=e,isClean:()=>this._clean,setOrbit:e=>this._orbit=e,isOrbit:()=>this._orbit,setNight:e=>this._night=e,goHome:()=>this.returnHome()});constructor(){super(),this._roomId=null,this._floorId=void 0,this._walls=null,this._heat=null,this._explode=null,this._fullscreen=!1,this._clean=!1,this._night=!1,this._orbit=!1,this._roomNames=null}view3d(){return this.shadowRoot?.querySelector("nf-view3d")}returnHome(){this._roomId=this._config?.room??null,this._floorId=void 0,this.view3d()?.resetView(),this._config?.idle_orbit&&(this._orbit=!0)}openDashboard(e){history.pushState(null,"",e),window.dispatchEvent(new CustomEvent("location-changed",{bubbles:!0,composed:!0,detail:{replace:!1}}))}onFullscreen=()=>this._fullscreen=!!document.fullscreenElement&&this.shadowRoot?.contains(document.fullscreenElement)===!0;connectedCallback(){super.connectedCallback(),document.addEventListener("fullscreenchange",this.onFullscreen),this.kiosk.start()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("fullscreenchange",this.onFullscreen),this.kiosk.stop()}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.shadowRoot?.querySelector("ha-card")?.requestFullscreen?.()}static async getConfigElement(){return await Kn(),document.createElement("nextfloor-card-editor")}static getStubConfig(){return{type:"custom:nextfloor-card"}}setConfig(e){if(e.height!==void 0&&!(e.height>100))throw new Error("height must be a number of pixels above 100");this._roomNames=null,this._own=e,this._config=Zo(e,this.data.building?.settings.card_templates),this._floorId=void 0,this._walls=null,this._heat=null,this._explode=null,this._orbit=!1,this._night=On(e.night,this.hass),this._clean=e.controls_hidden===!0,this.kiosk.armClean(),this.kiosk.armIdle()}getCardSize(){return Math.ceil((this._config?.height??420)/50)}getGridOptions(){return{columns:"full",rows:this._config?.fill?12:Math.ceil((this._config?.height??420)/56),min_rows:4}}willUpdate(e){let t=this.data.building?.settings.card_templates;if(this._own?.template&&t!==this.templatesSeen&&(this.templatesSeen=t,this._config=Zo(this._own,t)),this.toggleAttribute("readable",this._config?.readable===!0),e.has("hass")&&(this.style.colorScheme=$r(this.hass)),!e.has("hass")||!this.hass)return;this.data.setHass(this.hass);let n=On(this._config?.night,this.hass);n!==this._night&&(this._night=n)}get canSwitch(){return!this._config?.floor||this.thumbs}get thumbs(){return this._config?.floor_thumbs??!this._config?.floor}back(){this._roomId?this._roomId=null:this.canSwitch&&(this._floorId=null)}roomsMemo=null;plan(){let e=this.data.building??null,t=this._config?.rooms;if(!e||!t?.length)return e;let n=t.join(",");return(!this.roomsMemo||this.roomsMemo.source!==e||this.roomsMemo.ids!==n)&&(this.roomsMemo={source:e,ids:n,result:Ku(e,t)}),this.roomsMemo.result}t=e=>$(this.hass,e);stage(){let e=this.plan(),t=this._config,n=this._floorId===void 0?t?.floor??null:this._floorId,i=e&&e.floors.length===1?e.floors[0].id:e?.floors.some(a=>a.id===n)?n:null,o=!!this._roomId&&t?.room_panel!==!1,s=!!this._roomId&&t?.room_panel===!1||!this.thumbs&&this.canSwitch&&!this._roomId&&!!i&&(e?.floors.length??0)>1;return{floorId:i,walls:this._walls??t?.walls??"auto",heat:this._heat??t?.heatmap??"none",explode:this._explode??t?.explode??!0,canGoBack:s,showBar:!!e&&!this._clean&&(s||!!t?.controls&&!o)}}shows(e){let t=this._config?.controls;return t===!0||Array.isArray(t)&&t.includes(e)}renderBar(e){let t=this.plan(),n=this.t,i=["temperature","humidity","co2"].filter(s=>this.shows(s)),o=(s,a)=>p`
${a.map(([l,c,u])=>p`${u}`)}
`;return p`
${e.canGoBack?p`this.back()}>${n("back")}`:f}
${this.shows("walls")?o(void 0,[[e.walls==="auto",()=>this._walls="auto",n("walls_auto")],[e.walls==="cut",()=>this._walls="cut",n("walls_cut")],[e.walls==="slope",()=>this._walls="slope",n("walls_slope")]]):f}
${this.shows("floors")&&t.floors.length>1&&!e.floorId?o(void 0,[[e.explode,()=>this._explode=!0,n("floors_apart")],[!e.explode,()=>this._explode=!1,n("floors_stacked")]]):f}
${i.length>0?o(n("heatmap"),["none",...i].map(s=>[e.heat===s,()=>this._heat=s,n(s==="none"?"heat_off":`heat_short_${s}`)])):f}
-
`}renderRoomButtons(e){let t=this.plan();if(!this._config?.room_buttons||!t||this._clean)return f;let n=Lu(t,e.floorId);if(!n.length)return f;let i=n.length>1,o=(l,c)=>{this.canSwitch&&l!==e.floorId&&(this._floorId=l),this._roomId=c===this._roomId?null:c},s=ln(this.hass,t.floors).length>0,a=()=>{this.canSwitch&&(this._floorId=null),this._roomId=this._roomId===Gt?null:Gt};return p`
+
`}renderRoomButtons(e){let t=this.plan();if(!this._config?.room_buttons||!t||this._clean)return f;let n=Bu(t,e.floorId);if(!n.length)return f;let i=n.length>1,o=(l,c)=>{this.canSwitch&&l!==e.floorId&&(this._floorId=l),this._roomId=c===this._roomId?null:c},s=dn(this.hass,t.floors).length>0,a=()=>{this.canSwitch&&(this._floorId=null),this._roomId=this._roomId===Zt?null:Zt};return p`
${n.map(l=>p`${i?p`${l.floorName}`:f}${l.rooms.map(c=>p`o(l.floorId,c.id)}>${c.name}`)}`)}
- ${s?p`🌳 ${this.t("outside_area")}`:f}
+ ${s?p`🌳 ${this.t("outside_area")}`:f}
`}renderCorners(){let e=this._config,t=this.t,n=this._clean||!!this._roomId&&e?.room_panel!==!1;return p`${e?.fullscreen_button&&!n?p`
this.toggleFullscreen()}>
${this._fullscreen?"\u2715":"\u26F6"}
`:f}
${e?.dashboard&&!n?p`
this.openDashboard(e.dashboard)}>
${e.dashboard_label?p`${e.dashboard_label}`:"\u2302"}
`:f}`}renderStage(e){let t=this.plan(),n=this._config,i=()=>{this._clean=!this._clean,this._clean?this.kiosk.stopClean():this.kiosk.armClean()},o=n?.controls_hidden!==void 0||(n?.controls_hide_after??0)>0;return p`
this.hass.states[n]?.attributes.symcon_path||this.hass.states
.zoom=${typeof n?.zoom=="number"?n.zoom:1}
.buttons=${n?.buttons?.map((s,a)=>({id:`card_${a}`,...s}))??null}
.heatMode=${e.heat}
- .theme=${Pr(n?.theme,this.hass?.states["sun.sun"]?.state)}
+ .theme=${Cr(n?.theme,this.hass?.states["sun.sun"]?.state)}
.clock=${n?.clock&&n.clock!=="none"?n.clock:null}
.lockButton=${n?.lock_button!==!1}
.walkButton=${n?.walk_button!==!1}
@@ -4247,10 +4317,10 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
.panelOpen=${!!this._roomId&&n?.room_panel!==!1}
.alerts=${n?.alerts!==!1}
.alertJump=${!!n?.alert_jump}
- .announcements=${!G(this.hass)&&n?.announcements!==!1&&!Pu()}
+ .announcements=${!K(this.hass)&&n?.announcements!==!1&&!Nu()}
.sensorBar=${n?.sensor_bar!==!1}
.glassWalls=${typeof n?.glass_walls=="number"?Math.min(100,Math.max(0,n.glass_walls)):null}
- .screenName=${n?.screen_name??Hu()}
+ .screenName=${n?.screen_name??Iu()}
.scenes=${n?.scenes!==!1}
.clean=${this._clean}
.cleanButton=${o}
@@ -4268,14 +4338,14 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
>`}renderRoomPanel(){let e=this.plan();return p`
t.rooms).find(t=>t.id===this._roomId)??null}
.floor=${e.floors.find(t=>t.rooms.some(n=>n.id===this._roomId))??null}
- .outside=${this._roomId===Gt?ln(this.hass,e.floors):null}
- .confirmEntities=${mt(this.hass,e.floors)}
+ .outside=${this._roomId===Zt?dn(this.hass,e.floors):null}
+ .confirmEntities=${_t(this.hass,e.floors)}
.phrases=${e.settings.announce_phrases??null}
@close=${()=>this._roomId=null}
- >`}render(){if(this.hass&&fr(this.hass,this))return f;let e=this.plan(),t=this._config;!this.roomApplied&&e&&t?.room&&(this.roomApplied=!0,e.floors.some(a=>a.rooms.some(l=>l.id===t.room))&&(this._roomId=t.room));let n=this.stage(),i=this._fullscreen?"100vh":t?.fill?"calc(100vh - var(--header-height, 56px) - 16px)":`${t?.height??420}px`,o=/^#[0-9a-f]{6}$/i.test(t?.accent??"")?t.accent:null,s=()=>this.kiosk.touched();return p`
+ >`}render(){if(this.hass&&vr(this.hass,this))return f;let e=this.plan(),t=this._config;!this.roomApplied&&e&&t?.room&&(this.roomApplied=!0,e.floors.some(a=>a.rooms.some(l=>l.id===t.room))&&(this._roomId=t.room));let n=this.stage(),i=this._fullscreen?"100vh":t?.fill?"calc(100vh - var(--header-height, 56px) - 16px)":`${t?.height??420}px`,o=/^#[0-9a-f]{6}$/i.test(t?.accent??"")?t.accent:null,s=()=>this.kiosk.touched();return p`
${e&&e.floors.some(a=>a.rooms.length)?this.renderStage(n):p`
${this.data.error??(e?$(this.hass,"no_building"):$(this.hass,"loading"))}
`}
${this._roomId&&e&&t?.room_panel!==!1?this.renderRoomPanel():f}
@@ -4283,7 +4353,7 @@ ${t.sources.map(n=>this.hass.states[n]?.attributes.symcon_path||this.hass.states
${n.showBar&&e?this.renderBar(n):f}
${this.renderCorners()}
- `}static styles=[ge,Re,Ou,yr]};if(!customElements.get("nextfloor-card")){customElements.define("nextfloor-card",jo);let r=window;r.customCards=r.customCards??[],r.customCards.push({type:"nextfloor-card",name:$(void 0,"card_name"),description:$(void 0,"card_description"),preview:!1})}bi();var Ef="nextfloor-chunks-v1";async function qo(r,e,t){let n=await fetch(`${r.endpoint}/api?token=${encodeURIComponent(r.token)}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},credentials:"same-origin",body:JSON.stringify({...t,action:e,transport:Ef})}),i=await n.text(),o;try{o=JSON.parse(i)}catch{throw/Output-Buffer exceeds Limit/i.test(i)?new Error("Symcon hat die Antwort wegen seiner Ausgabebegrenzung abgebrochen. Bitte das NextFloor-Modul aktualisieren und den Designer neu laden."):new Error(`Symcon liefert ${i.trim()?"kein g\xFCltiges JSON":"eine leere Antwort"} f\xFCr \u201E${e}\u201C (HTTP ${n.status}).`)}if(!n.ok||!o||typeof o!="object"||"error"in o){let s=o&&typeof o=="object"&&"error"in o?o.error:`HTTP ${n.status}`;throw new Error(String(s))}return o}async function Ut(r,e,t={}){let n=await qo(r,e,t);if(!("_nextfloor_transfer"in n))return n;let i=n._nextfloor_transfer;if(!i||!/^[a-f0-9]{32}$/.test(i.id)||!Number.isSafeInteger(i.bytes)||i.bytes<=0||i.bytes>67108864||!Number.isSafeInteger(i.chunk_bytes)||i.chunk_bytes<=0||i.chunk_bytes>128*1024||i.chunks!==Math.ceil(i.bytes/i.chunk_bytes)||i.chunks>512)throw new Error("Symcon hat eine ung\xFCltige Daten\xFCbertragung angek\xFCndigt.");try{let o=new TextDecoder("utf-8",{fatal:!0}),s=[];for(let a=0;au.charCodeAt(0));if(c.length!==Math.min(i.chunk_bytes,i.bytes-a*i.chunk_bytes))throw new Error("Ein Symcon-Datenpaket wurde unvollst\xE4ndig \xFCbertragen.");s.push(o.decode(c,{stream:!0}))}return s.push(o.decode()),JSON.parse(s.join(""))}finally{await qo(r,"transport/release",{transfer_id:i.id}).catch(()=>{})}}function Rf(){let r=window.__NEXTFLOOR_SYMCON__;if(!r?.endpoint||!r.token)throw new Error("NextFloor Symcon host configuration is missing");return r}var Xr=class{settings=Rf();changeListeners=new Set;buildingListeners=new Set;timer;stateRevision=-1;buildingRevision=-1;objectsSignature="";refreshTask;states={};entities={};areas={};facade={language:this.settings.language||navigator.language||"de",user:{is_admin:!0,name:this.settings.title||"IP-Symcon"},states:this.states,entities:this.entities,areas:this.areas,symconObjects:[],symconTitle:this.settings.title?.trim()||"NextFloor",symconRefresh:()=>this.refresh(!0),config:{unit_system:{temperature:"\xB0C"}},themes:{darkMode:window.matchMedia?.("(prefers-color-scheme: dark)").matches??!0},services:{},connection:{subscribeMessage:async(e,t)=>{if(t.type==="nextfloor/building/subscribe"){let n=i=>e({revision:i});return this.buildingListeners.add(n),async()=>{this.buildingListeners.delete(n)}}return async()=>{}}},callWS:e=>this.callWS(e),callService:(e,t,n)=>this.callService(e,t,n),fetchWithAuth:(e,t)=>this.fetchWithToken(e,t),hassUrl:(e="")=>new URL(e,window.location.origin).href};async start(){let e=await Ut(this.settings,"bootstrap");return this.apply(e),this.stateRevision=e.state_revision,this.buildingRevision=e.building_revision,this.timer=setInterval(()=>{this.refresh().catch(()=>{})},800),this.snapshot()}stop(){this.timer&&clearInterval(this.timer),this.timer=void 0}onChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}snapshot(){return{...this.facade,states:{...this.states},entities:{...this.entities},areas:{...this.areas}}}refresh(e=!1){if(this.refreshTask)return e?this.refreshTask.catch(()=>{}).then(()=>this.refresh(!0)):this.refreshTask;let t=this.loadSnapshot(e).finally(()=>{this.refreshTask===t&&(this.refreshTask=void 0)});return this.refreshTask=t,t}async loadSnapshot(e){let t=e?await Ut(this.settings,"bootstrap"):await Ut(this.settings,"variables/snapshot",{revision:this.stateRevision});if((e||t.state_revision!==this.stateRevision)&&t.variables){this.stateRevision=t.state_revision,this.apply({variables:t.variables,areas:t.areas,objects:t.objects});for(let n of this.changeListeners)n()}if(t.building_revision!==this.buildingRevision){this.buildingRevision=t.building_revision;for(let n of this.buildingListeners)n(t.building_revision)}}apply(e){this.states=Object.fromEntries(e.variables.map(t=>[t.entity_id,{entity_id:t.entity_id,state:t.state,attributes:{...t.attributes,friendly_name:t.name,symcon_path:t.path}}])),this.entities=Object.fromEntries(e.variables.map(t=>[t.entity_id,{entity_id:t.entity_id,name:t.name,area_id:t.area_id??null,device_id:t.device_id??null}]));for(let t of Object.values(this.states))for(let n of["light","cover"]){let i=na(t,n);!i||i.entity_id===t.entity_id||this.states[i.entity_id]||(this.states[i.entity_id]=i,this.entities[i.entity_id]={...this.entities[t.entity_id],entity_id:i.entity_id,hidden:!0})}if(e.areas&&(this.areas=Object.fromEntries(e.areas.map(t=>[t.area_id,t]))),this.facade.states=this.states,this.facade.entities=this.entities,this.facade.areas=this.areas,e.objects){let t=JSON.stringify(e.objects);t!==this.objectsSignature&&(this.facade.symconObjects=e.objects,this.objectsSignature=t)}}async callWS(e){let t=String(e.type??"");if(!t.startsWith("nextfloor/"))throw new Error(`Unsupported Symcon websocket command: ${t}`);let{type:n,...i}=e;return Ut(this.settings,t.slice(10),i)}async callService(e,t,n={}){return Ut(this.settings,"variables/action",{domain:e,service:t,data:n})}fetchWithToken(e,t={}){let n=new URL(e,window.location.origin);return n.searchParams.set("token",this.settings.token),fetch(n,{...t,credentials:"same-origin"})}};function zf(){return new URLSearchParams(window.location.search).get("mode")==="tile"?"tile":"designer"}async function Tf(){let r=new Xr,e=await r.start(),t=zf()==="tile",n=t?document.createElement("nextfloor-card"):document.createElement("nextfloor-panel");n.className=t?"nf-symcon-tile":"nf-symcon-designer",n.hass=e,t?n.setConfig({type:"custom:nextfloor-card",fill:!0,room_buttons:!0,controls:!0,weather:!1,announcements:!1}):n.narrow=!1,document.body.replaceChildren(n),r.onChange(()=>{n.hass=r.snapshot()}),window.addEventListener("pagehide",()=>r.stop(),{once:!0})}Tf().catch(r=>{document.body.textContent=`NextFloor konnte nicht geladen werden: ${r instanceof Error?r.message:String(r)}`});
+ `}static styles=[ge,Re,Vu,Sr]};if(!customElements.get("nextfloor-card")){customElements.define("nextfloor-card",Yo);let r=window;r.customCards=r.customCards??[],r.customCards.push({type:"nextfloor-card",name:$(void 0,"card_name"),description:$(void 0,"card_description"),preview:!1})}wi();var zf="nextfloor-chunks-v1";async function Jo(r,e,t){let n=await fetch(`${r.endpoint}/api?token=${encodeURIComponent(r.token)}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},credentials:"same-origin",body:JSON.stringify({...t,action:e,transport:zf})}),i=await n.text(),o;try{o=JSON.parse(i)}catch{throw/Output-Buffer exceeds Limit/i.test(i)?new Error("Symcon hat die Antwort wegen seiner Ausgabebegrenzung abgebrochen. Bitte das NextFloor-Modul aktualisieren und den Designer neu laden."):new Error(`Symcon liefert ${i.trim()?"kein g\xFCltiges JSON":"eine leere Antwort"} f\xFCr \u201E${e}\u201C (HTTP ${n.status}).`)}if(!n.ok||!o||typeof o!="object"||"error"in o){let s=o&&typeof o=="object"&&"error"in o?o.error:`HTTP ${n.status}`;throw new Error(String(s))}return o}async function Yt(r,e,t={}){let n=await Jo(r,e,t);if(!("_nextfloor_transfer"in n))return n;let i=n._nextfloor_transfer;if(!i||!/^[a-f0-9]{32}$/.test(i.id)||!Number.isSafeInteger(i.bytes)||i.bytes<=0||i.bytes>67108864||!Number.isSafeInteger(i.chunk_bytes)||i.chunk_bytes<=0||i.chunk_bytes>128*1024||i.chunks!==Math.ceil(i.bytes/i.chunk_bytes)||i.chunks>512)throw new Error("Symcon hat eine ung\xFCltige Daten\xFCbertragung angek\xFCndigt.");try{let o=new TextDecoder("utf-8",{fatal:!0}),s=[];for(let a=0;a
u.charCodeAt(0));if(c.length!==Math.min(i.chunk_bytes,i.bytes-a*i.chunk_bytes))throw new Error("Ein Symcon-Datenpaket wurde unvollst\xE4ndig \xFCbertragen.");s.push(o.decode(c,{stream:!0}))}return s.push(o.decode()),JSON.parse(s.join(""))}finally{await Jo(r,"transport/release",{transfer_id:i.id}).catch(()=>{})}}function Tf(){let r=window.__NEXTFLOOR_SYMCON__;if(!r?.endpoint||!r.token)throw new Error("NextFloor Symcon host configuration is missing");return r}var ni=class{settings=Tf();changeListeners=new Set;buildingListeners=new Set;timer;stateRevision=-1;buildingRevision=-1;objectsSignature="";refreshTask;states={};entities={};areas={};facade={language:this.settings.language||navigator.language||"de",user:{is_admin:!0,name:this.settings.title||"IP-Symcon"},states:this.states,entities:this.entities,areas:this.areas,symconObjects:[],symconTitle:this.settings.title?.trim()||"NextFloor",symconRefresh:()=>this.refresh(!0),config:{unit_system:{temperature:"\xB0C"}},themes:{darkMode:window.matchMedia?.("(prefers-color-scheme: dark)").matches??!0},services:{},connection:{subscribeMessage:async(e,t)=>{if(t.type==="nextfloor/building/subscribe"){let n=i=>e({revision:i});return this.buildingListeners.add(n),async()=>{this.buildingListeners.delete(n)}}return async()=>{}}},callWS:e=>this.callWS(e),callService:(e,t,n)=>this.callService(e,t,n),fetchWithAuth:(e,t)=>this.fetchWithToken(e,t),hassUrl:(e="")=>new URL(e,window.location.origin).href};async start(){let e=await Yt(this.settings,"bootstrap");return this.apply(e),this.stateRevision=e.state_revision,this.buildingRevision=e.building_revision,this.timer=setInterval(()=>{this.refresh().catch(()=>{})},800),this.snapshot()}stop(){this.timer&&clearInterval(this.timer),this.timer=void 0}onChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}snapshot(){return{...this.facade,states:{...this.states},entities:{...this.entities},areas:{...this.areas}}}refresh(e=!1){if(this.refreshTask)return e?this.refreshTask.catch(()=>{}).then(()=>this.refresh(!0)):this.refreshTask;let t=this.loadSnapshot(e).finally(()=>{this.refreshTask===t&&(this.refreshTask=void 0)});return this.refreshTask=t,t}async loadSnapshot(e){let t=e?await Yt(this.settings,"bootstrap"):await Yt(this.settings,"variables/snapshot",{revision:this.stateRevision});if((e||t.state_revision!==this.stateRevision)&&t.variables){this.stateRevision=t.state_revision,this.apply({variables:t.variables,areas:t.areas,objects:t.objects});for(let n of this.changeListeners)n()}if(t.building_revision!==this.buildingRevision){this.buildingRevision=t.building_revision;for(let n of this.buildingListeners)n(t.building_revision)}}apply(e){this.states=Object.fromEntries(e.variables.map(t=>[t.entity_id,{entity_id:t.entity_id,state:t.state,attributes:{...t.attributes,friendly_name:t.name,symcon_path:t.path}}])),this.entities=Object.fromEntries(e.variables.map(t=>[t.entity_id,{entity_id:t.entity_id,name:t.name,area_id:t.area_id??null,device_id:t.device_id??null}]));for(let t of Object.values(this.states))for(let n of["light","cover"]){let i=oa(t,n);!i||i.entity_id===t.entity_id||this.states[i.entity_id]||(this.states[i.entity_id]=i,this.entities[i.entity_id]={...this.entities[t.entity_id],entity_id:i.entity_id,hidden:!0})}if(e.areas&&(this.areas=Object.fromEntries(e.areas.map(t=>[t.area_id,t]))),this.facade.states=this.states,this.facade.entities=this.entities,this.facade.areas=this.areas,e.objects){let t=JSON.stringify(e.objects);t!==this.objectsSignature&&(this.facade.symconObjects=e.objects,this.objectsSignature=t)}}async callWS(e){let t=String(e.type??"");if(!t.startsWith("nextfloor/"))throw new Error(`Unsupported Symcon websocket command: ${t}`);let{type:n,...i}=e;return Yt(this.settings,t.slice(10),i)}async callService(e,t,n={}){return Yt(this.settings,"variables/action",{domain:e,service:t,data:n})}fetchWithToken(e,t={}){let n=new URL(e,window.location.origin);return n.searchParams.set("token",this.settings.token),fetch(n,{...t,credentials:"same-origin"})}};function Df(){return new URLSearchParams(window.location.search).get("mode")==="tile"?"tile":"designer"}async function Ff(){let r=new ni,e=await r.start(),t=Df()==="tile",n=t?document.createElement("nextfloor-card"):document.createElement("nextfloor-panel");n.className=t?"nf-symcon-tile":"nf-symcon-designer",n.hass=e,t?n.setConfig({type:"custom:nextfloor-card",fill:!0,room_buttons:!0,controls:!0,weather:!1,announcements:!1}):n.narrow=!1,document.body.replaceChildren(n),r.onChange(()=>{n.hass=r.snapshot()}),window.addEventListener("pagehide",()=>r.stop(),{once:!0})}Ff().catch(r=>{document.body.textContent=`NextFloor konnte nicht geladen werden: ${r instanceof Error?r.message:String(r)}`});
/*! Bundled license information:
@lit/reactive-element/css-tag.js:
diff --git a/NextFloor/assets/nextfloor-editor.js b/NextFloor/assets/nextfloor-editor.js
index 56dc086..33dde7b 100644
--- a/NextFloor/assets/nextfloor-editor.js
+++ b/NextFloor/assets/nextfloor-editor.js
@@ -1816,9 +1816,9 @@ ${i}`}else o=Rh(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${lk(t,e)}
${M(o("solar_string_hint"))} ${M(o("solar_form_hint"))}
${n.admin?X(m`l&&i({...Vn(l,e.id),portrait:e.portrait})}>${o("solar_fit")}`,m`r.removeField()}>${o("delete")}`):_}
- `}var wg=t=>Math.round(t*1e3)/1e3,qi=class{ctx;sectionSel=null;windowSel=null;chimneySel=null;fieldSel=null;pickMode=!1;constructor(e){this.ctx=e}get sectionId(){return this.sectionSel}set sectionId(e){this.sectionSel=e,this.ctx.refresh()}get windowId(){return this.windowSel}set windowId(e){this.windowSel=e,this.ctx.refresh()}get chimneyId(){return this.chimneySel}set chimneyId(e){this.chimneySel=e,e&&(this.windowSel=null),this.ctx.refresh()}get solarId(){return this.fieldSel}set solarId(e){this.fieldSel=e,this.ctx.refresh()}get picking(){return this.pickMode}set picking(e){this.pickMode=e,this.ctx.refresh()}get doc(){return this.ctx.host.doc}get settings(){return this.doc.settings.roof}get admin(){return this.ctx.host.admin}get section(){return this.sectionSel?this.settings.sections?.find(e=>e.id===this.sectionSel):void 0}get window(){return this.windowSel?this.settings.windows?.find(e=>e.id===this.windowSel):void 0}get chimney(){return this.chimneySel?this.settings.chimneys?.find(e=>e.id===this.chimneySel):void 0}get field(){return this.fieldSel?this.settings.solar?.find(e=>e.id===this.fieldSel):void 0}isFixed(e){return!!e&&(!!e.locked||!!this.doc.settings.lock_plan)}useSections(e=!1){if(!this.admin)return;let n=(this.settings.sections??[]).length>0;e&&n&&!this.ctx.confirm(this.ctx.host.t("roof_regen_confirm"))||(this.ctx.host.change(r=>{r.settings.roof.type="custom",(e||!n)&&(r.settings.roof.sections=la(r,()=>I("roof")))}),this.sectionId=null)}addSection(e,n){if(!this.admin)return;let r=of(this.doc,e,n);this.ctx.host.change(o=>{o.settings.roof.type="custom",o.settings.roof.sections=[...o.settings.roof.sections??[],r]}),this.sectionId=r.id}takeOutline(){let e=this.ctx.host.floor;if(!e||!this.sectionSel||!this.admin)return;let{wall_exterior:n,wall_interior:r}=this.doc.settings,o=ea(e.rooms,e.walls??[],n,r);if(!o)return;let i=o.map(([s,l])=>[wg(s),wg(l)]);this.patchSection({shape:"flat",points:i,...Nt(i)})}addDormer(e){let n=this.section;if(!n||!this.admin)return;let r=ta(n,e,I("roof"));this.ctx.host.change(o=>{o.settings.roof.sections=[...o.settings.roof.sections??[],r]}),this.sectionId=r.id}patchSection(e){let n=this.sectionSel;!n||!this.admin||this.ctx.host.change(r=>{let o=r.settings.roof.sections?.find(i=>i.id===n);o&&Object.assign(o,e)})}removeCorner(e){let n=this.sectionSel;!n||!this.admin||this.ctx.host.change(r=>{let o=r.settings.roof.sections?.find(i=>i.id===n);o&&cf(o,e)})}removeSection(){let e=this.sectionSel;!e||!this.admin||(this.ctx.host.change(n=>n.settings.roof.sections=(n.settings.roof.sections??[]).filter(r=>r.id!==e)),this.sectionId=null)}duplicateSection(){let e=this.section;if(!e||!this.admin)return;let n=sf(e);this.ctx.host.change(r=>r.settings.roof.sections=[...r.settings.roof.sections??[],n]),this.sectionId=n.id}addWindow(){if(!this.admin)return;let e=this.doc.settings.north??0,n=Yr(Z(this.doc).filter(o=>!o.flat),e)??Z(this.doc)[0];if(!n)return;let r=Zr(n,I("rwin"));this.ctx.host.change(o=>o.settings.roof.windows=[...o.settings.roof.windows??[],r]),this.windowSel=r.id,this.sectionId=null}patchWindow(e){let n=this.windowSel;!n||!this.admin||this.ctx.host.change(r=>{let o=r.settings.roof.windows?.find(s=>s.id===n);if(!o)return;Object.assign(o,e);let i=Z(r).find(s=>s.key===o.face);i&&Object.assign(o,ft(i,dn(o)))})}removeWindow(){let e=this.windowSel;!e||!this.admin||(this.ctx.host.change(n=>n.settings.roof.windows=(n.settings.roof.windows??[]).filter(r=>r.id!==e)),this.windowId=null)}addChimney(){if(!this.admin)return;let e=Z(this.doc),n=e.find(o=>!o.flat)??e[0];if(!n)return;let r=qr(n,I("chim"));this.ctx.host.change(o=>o.settings.roof.chimneys=[...o.settings.roof.chimneys??[],r]),this.chimneySel=r.id,this.windowSel=null,this.sectionId=null}patchChimney(e){let n=this.chimneySel;!n||!this.admin||this.ctx.host.change(r=>{let o=r.settings.roof.chimneys?.find(s=>s.id===n);if(!o)return;Object.assign(o,e);let i=Z(r).find(s=>s.key===o.face);i&&Object.assign(o,ft(i,kt(o,i)))})}removeChimney(){let e=this.chimneySel;!e||!this.admin||(this.ctx.host.change(n=>n.settings.roof.chimneys=(n.settings.roof.chimneys??[]).filter(r=>r.id!==e)),this.chimneyId=null)}addField(){if(!this.admin)return;let e=Z(this.doc),n=new Set((this.settings.solar??[]).map(i=>i.face)),r=this.doc.settings.north??0,o=Yr(e.filter(i=>!n.has(i.key)),r)??Yr(e,r);o&&(this.appendField(Vn(o,I("pv"))),this.sectionSel=null)}addWallField(){let e=this.ctx.floorId()??this.doc.floors[0]?.id,n=this.admin&&e?fa(this.doc,I("pv"),e):null;n&&this.appendField(n)}addGroundField(){this.admin&&this.appendField(Gr(this.doc,I("pv")))}appendField(e){this.ctx.host.change(n=>n.settings.roof.solar=[...n.settings.roof.solar??[],e]),this.solarId=e.id}selectField(e){this.fieldSel=e,this.sectionSel=null;let n=this.settings.solar?.find(r=>r.id===e);n?.face.startsWith("wall:")&&this.ctx.setFloorId(n.face.split(":")[1]),this.ctx.refresh()}patchField(e){this.editField((n,r)=>{Object.assign(n,e);let o=$e(r,n);o&&Object.assign(n,ft(o,n))})}toggleCell(e){this.editField(n=>n.skip=pg(n.skip,e))}editField(e){let n=this.fieldSel;!n||!this.admin||this.ctx.host.change(r=>{let o=r.settings.roof.solar?.find(i=>i.id===n);o&&e(o,r)})}setString(e){let n=this.fieldSel;!n||!this.admin||this.ctx.host.change(r=>hg(r.settings.roof,n,e,{id:I("str"),name:o=>this.ctx.host.t("solar_string_n",{n:o})}))}patchString(e){let n=this.field?.string;!n||!this.admin||this.ctx.host.change(r=>{let o=r.settings.roof.strings?.find(i=>i.id===n);o&&Object.assign(o,e)})}removeField(){let e=this.fieldSel;!e||!this.admin||(this.ctx.host.change(n=>{n.settings.roof.solar=(n.settings.roof.solar??[]).filter(r=>r.id!==e),Il(n.settings.roof)}),this.solarId=null)}floorsTopDown(){return[...this.doc.floors].sort((e,n)=>n.elevation-e.elevation)}};var kg=(t,e)=>t.floors.flatMap(n=>n.furniture).find(n=>n.type===e),ck=t=>!t||t==="none";async function xg(t){let e;try{e=await t.hass.callWS({type:"energy/get_prefs"})}catch{return{kind:"failed"}}let n=Zh(t.hass,e),r=0,o=(i,s,l)=>{if(!l)return;let a=kg(t.doc(),i);!a&&t.canAdd()&&(t.addDevice(i),a=kg(t.doc(),i)),!(!a||!ck(a[s]))&&(t.setField(a.id,s,l),r++)};return o("meter","power",n.grid),o("inverter","power",n.solar),o("home_battery","power",n.battery),o("home_battery","soc",n.battery_soc),{kind:"done",filled:r}}var uk=/garage|carport/,dk=/hwr|hauswirt|technik|keller|abstell|utility|basement|boiler|heiz/,hk=/flur|diele|eingang|hall|entr|lobby/,$g=.25,or=t=>Math.round(t*1e3)/1e3;function pk(t,e,n){let r=e.rooms.filter(u=>u.points.length>=3),o=u=>r.find(d=>u.test(n.roomLabel(d).toLowerCase())),i=r.find(u=>e.furniture.some(d=>d.type==="parking"&&N([d.x,d.z],u.points))),s=o(uk)??i,l=o(dk),a=t==="wallbox"?s:t==="meter"?l??o(hk)??s:l??s,c=[...r].sort((u,d)=>Math.abs(_e(d.points))-Math.abs(_e(u.points)))[0];return a??n.selected??c}function fk(t,e){let[n,r]=be(t.points),o=t.points.some((s,l)=>!e.has(l)),i=null;return t.points.forEach((s,l)=>{if(o&&e.has(l))return;let a=t.points[(l+1)%t.points.length],c=Math.hypot(a[0]-s[0],a[1]-s[1]);if(i&&c<=i.length)return;let u=[(s[0]+a[0])/2,(s[1]+a[1])/2],d=[-(a[1]-s[1])/c+0,(a[0]-s[0])/c+0];(n-u[0])*d[0]+(r-u[1])*d[1]<0&&(d=[0-d[0],0-d[1]]),i={mid:u,inward:d,length:c}}),i}function Sg(t,e,n,r){let[o,i,s]=ut(t),l={id:I("furniture"),type:t,rotation:0,w:o,d:i,h:s,variant:null};if(t==="grid_point"){let h=Xh(e),[f,g]=h?[h.x,h.z]:r.fallback;return{...l,x:or(f),z:or(g)}}let a=pk(t,n,r),[c,u]=a?be(a.points):r.fallback;if(a){let h=new Set(n.openings.filter(g=>g.room_id===a.id).map(g=>g.edge)),f=fk(a,h);f&&([c,u]=[f.mid[0]+f.inward[0]*(i/2+$g),f.mid[1]+f.inward[1]*(i/2+$g)])}let d={...l,x:or(c),z:or(u)},p=a?Ar({...n,furniture:[...n.furniture,d]},d,e.settings.wall_interior):null;return p?{...d,x:or(p.x),z:or(p.z),rotation:p.rotation}:d}var Yi=class{limit;undoStack=[];redoStack=[];constructor(e=100){this.limit=e}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}record(e){this.undoStack.push(JSON.stringify(e)),this.undoStack.length>this.limit&&this.undoStack.shift(),this.redoStack=[]}undo(e){let n=this.undoStack.pop();return n===void 0?null:(this.redoStack.push(JSON.stringify(e)),JSON.parse(n))}redo(e){let n=this.redoStack.pop();return n===void 0?null:(this.undoStack.push(JSON.stringify(e)),JSON.parse(n))}};var Ol=t=>Math.round(t*1e3)/1e3,ir="unmovable",Xi="no change";function Mg(t,e,n,r){let o=i=>[Ol(i[0]+n),Ol(i[1]+r)];switch(e.kind){case"device":return t.placements.some(i=>i.entity_id===e.id)?{apply(i){let s=i.placements.find(l=>l.entity_id===e.id);s&&([s.x,s.z]=o([s.x,s.z]))}}:ir;case"furniture":return{apply(i){let s=i.furniture.find(l=>l.id===e.id);s&&([s.x,s.z]=o([s.x,s.z]))}};case"wall":return{apply(i){let s=(i.walls??[]).find(l=>l.id===e.id);s&&([s.a,s.b]=[o(s.a),o(s.b)])}};case"outdoor":return{apply(i){let s=i.outdoor.find(l=>l.id===e.id);s&&(s.points=s.points.map(o))}};case"opening":{let i=t.openings.find(g=>g.id===e.id),s=i?De(i,t.rooms,t.walls??[]):null;if(!i||!s)return ir;let l=s.room.points[s.edge],a=s.room.points[(s.edge+1)%s.room.points.length],c=Math.hypot(a[0]-l[0],a[1]-l[1])||1,u=(n*(a[0]-l[0])+r*(a[1]-l[1]))/c;if(Math.abs(u)<1e-9)return Xi;let d=Bt(t.openings,i),p=!i.wall&&d.length>1?Gn(s.room,d):null;if(p){let g=Math.max(0,Math.min(Xr(s.room)-p.width,p.from+u));return Math.abs(g-p.from)<1e-9?Xi:{apply(y){let b=y.openings.find(w=>w.id===e.id),v=b?Qr(y.openings,s.room,b,g,p.width):null;v&&(y.openings=v)}}}let h=Math.min(i.width,c)/2,f=Ol(Math.min(c-h,Math.max(h,i.offset+u)));return{apply(g){let y=g.openings.find(b=>b.id===e.id);y&&(y.offset=f)}}}case"room":{let i=t.rooms.find(l=>l.id===e.id);if(!i)return ir;let s=new Set(t.placements.filter(l=>N([l.x,l.z],i.points)).map(l=>l.entity_id));return{apply(l){let a=l.rooms.find(c=>c.id===e.id);if(a){if(e.corner!==null&&e.cornerMath.round(t*1e3)/1e3,Hl=t=>(t+90)%360;function Rg(t,e,n){let r=o=>[o.x,o.z]=e([o.x,o.z]);for(let o of t.rooms)o.points=o.points.map(e);for(let o of t.furniture)r(o),n&&(o.rotation=Hl(o.rotation));for(let o of t.placements)r(o),n&&(o.rotation=Hl(o.rotation??0));for(let o of t.outdoor)o.points=o.points.map(e);for(let o of t.walls??[])[o.a,o.b]=[e(o.a),e(o.b)];t.background&&(r(t.background),n&&(t.background.rotation=Hl(t.background.rotation??0)))}function mk(t,e){for(let r of t.settings.roof.sections??[]){let o=[e([r.x0,r.z0]),e([r.x1,r.z0]),e([r.x1,r.z1]),e([r.x0,r.z1])],[i,s]=[o.map(l=>l[0]),o.map(l=>l[1])];[r.x0,r.x1,r.z0,r.z1]=[Math.min(...i),Math.max(...i),Math.min(...s),Math.max(...s)],r.points&&(r.points=r.points.map(e))}let n=t.energy.meter;n&&([n.x,n.z]=e([n.x,n.z]))}function Eg(t,e,n,r){if(e.allFloors){for(let o of t.floors)Rg(o,n,r);mk(t,n)}else{let o=t.floors.find(i=>i.id===e.floorId);o&&Rg(o,n,r)}}function Ag(t,e,n,r){Eg(t,e,([o,i])=>[Qi(o+n),Qi(i+r)],!1)}function gk(t,e){let r=(e.allFloors?t.floors:t.floors.filter(s=>s.id===e.floorId)).flatMap(s=>s.rooms.flatMap(l=>l.points));if(r.length===0)return null;let[o,i]=[r.map(s=>s[0]),r.map(s=>s[1])];return[(Math.min(...o)+Math.max(...o))/2,(Math.min(...i)+Math.max(...i))/2]}function Fg(t,e){let n=gk(t,e);if(!n)return!1;let[r,o]=n;return Eg(t,e,([i,s])=>[Qi(r-(s-o)),Qi(o+(i-r))],!0),!0}var Ji=class{onChange;ids={room:null,opening:null,furniture:null,device:null,outdoor:null,wall:null};cornerSel=null;edgeSel=null;constructor(e){this.onChange=e}set(e,n){this.ids[e]=n,this.onChange()}get room(){return this.ids.room}set room(e){this.set("room",e)}get opening(){return this.ids.opening}set opening(e){this.set("opening",e)}get furniture(){return this.ids.furniture}set furniture(e){this.set("furniture",e)}get device(){return this.ids.device}set device(e){this.set("device",e)}get outdoor(){return this.ids.outdoor}set outdoor(e){this.set("outdoor",e)}get wall(){return this.ids.wall}set wall(e){this.set("wall",e)}get corner(){return this.cornerSel}set corner(e){this.cornerSel=e,this.onChange()}get edge(){return this.edgeSel}set edge(e){this.edgeSel=e,this.onChange()}select(e,n,r){let o=this.ids.room,i={room:null,opening:null,furniture:null,device:null,outdoor:null,wall:null};i[e]=n,e==="room"?i.room=n:e!=="outdoor"&&e!=="wall"&&(i.room=o),e==="device"&&n&&(i.room=r.roomOfDevice(n)??i.room),e==="opening"&&n&&(i.room=r.roomOfOpening(n)??i.room),(e!=="room"||n!==o)&&(this.cornerSel=null),this.edgeSel=null,this.ids=i,this.onChange()}get target(){for(let e of["device","opening","furniture","wall","outdoor","room"]){let n=this.ids[e];if(n)return{kind:e,id:n}}return null}};var es=class{onChange;menuOpen=!1;packagesOpen=!1;draft=null;shiftXMetres=0;shiftZMetres=0;wholeHouse=!1;line=null;query="";source="area";unfolded=new Set;copyChoice=null;constructor(e){this.onChange=e}get floorMenu(){return this.menuOpen}set floorMenu(e){this.menuOpen=e,this.onChange()}get floorCopy(){return this.copyChoice}set floorCopy(e){this.copyChoice=e,this.onChange()}get packages(){return this.packagesOpen}set packages(e){this.packagesOpen=e,this.onChange()}get spots(){return this.draft}set spots(e){this.draft=e,this.onChange()}get shiftX(){return this.shiftXMetres}set shiftX(e){this.shiftXMetres=e,this.onChange()}get shiftZ(){return this.shiftZMetres}set shiftZ(e){this.shiftZMetres=e,this.onChange()}get shiftAll(){return this.wholeHouse}set shiftAll(e){this.wholeHouse=e,this.onChange()}get notice(){return this.line}set notice(e){this.line=e,this.onChange()}get deviceQuery(){return this.query}set deviceQuery(e){this.query=e,this.onChange()}get deviceSource(){return this.source}set deviceSource(e){this.source=e,this.query="",this.onChange()}isUnfolded(e){return this.unfolded.has(e)}toggleUnfolded(e){let n=new Set(this.unfolded);n.delete(e)||n.add(e),this.unfolded=n,this.onChange()}};var sr={electricity:"Strom",water:"Wasser",gas:"Gas",heating:"Heizen",cooling:"K\xFChlen"},ts={electricity:"\u26A1",water:"\u{1F4A7}",gas:"\u{1F525}",heating:"\u2668",cooling:"\u2744"},Ll=t=>t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/ß/g,"ss").replace(/[^a-z0-9]+/g," ").trim(),_k="{485D0419-BE97-4548-AA9C-C083EB82E61E}",bk=t=>t.object_type!==0&&!(t.object_type===1&&t.module_id?.toUpperCase()===_k)?null:{elektro:"electricity",strom:"electricity","elektro strom":"electricity","strom elektro":"electricity",wasser:"water",gas:"gas",heizen:"heating",heizung:"heating",warme:"heating",waerme:"heating",kuhlen:"cooling",kuehlen:"cooling",kuhlung:"cooling",kuehlung:"cooling",kalte:"cooling",kaelte:"cooling"}[Ll(t.name)]??null,Tg=t=>/^symcon-category-(\d+)$/.exec(t??"")?.[1],Ig=t=>/\b(heute|tag|tagesverbrauch|today|daily)\b/.test(t)?"day":/monat|month/.test(t)?"month":/jahr|year/.test(t)?"year":"total",Cl=(t,e)=>String(t.states[e]?.attributes.symcon_source_entity||e);function Dg(t){let e=String(t?.attributes.unit_of_measurement??"").trim(),n=e.replace(/[³]/g,"3").replace(/[²]/g,"2").replace(/\s+/g,"").toLowerCase();return["w","kw","mw"].includes(n)?{metric:"power",unit:"W",factor:e==="mW"?.001:n==="kw"?1e3:n==="mw"?1e6:1}:["wh","kwh","mwh","j","kj","mj","gj"].includes(n)?{metric:"energy",unit:"kWh",factor:{wh:.001,kwh:1,mwh:1e3,j:1/36e5,kj:1/3600,mj:1/3.6,gj:1e3/3.6}[n]}:["m3/h","m3h","m3/min","m3/s","l/h","l/min","l/s","liter/h","liter/min"].includes(n)?{metric:"power",unit:"m\xB3/h",factor:{"m3/h":1,m3h:1,"m3/min":60,"m3/s":3600,"l/h":.001,"l/min":.06,"l/s":3.6,"liter/h":.001,"liter/min":.06}[n]}:["m3","l","liter"].includes(n)?{metric:"energy",unit:"m\xB3",factor:n==="m3"?1:.001}:null}function yk(t,e){if(!e.entity_id||e.object_type!==2&&e.object_type!==6)return null;let n=Cl(t,e.entity_id),r=t.states[n];if(!r||![1,2].includes(Number(r.attributes.symcon_variable_type)))return null;let o=Ll(e.name),i=Dg(r),s=/^(leistung|wirkleistung|gesamtleistung|aktuelle leistung|durchfluss|volumenstrom)(\b|$)/.test(o),l=/^(verbrauch|energie|energieverbrauch|gesamtverbrauch|gesamtenergie|zahlerstand|zaehlerstand|arbeit)(\b|$)/.test(o),a=i?.metric??(s?"power":l?"energy":null);if(!a)return null;let c=a==="power"?/^(leistung|wirkleistung|gesamtleistung|durchfluss|volumenstrom)$/.test(o):/^(verbrauch|energie|energieverbrauch|gesamtverbrauch|gesamtenergie|zahlerstand|zaehlerstand|arbeit)$/.test(o),u=a==="energy"?Ig(o):"total";return{metric:a,source:n,period:u,group:`${a}|${i?.unit??String(r.attributes.unit_of_measurement??"")}|${u}`,score:/^gesamt(leistung|verbrauch|energie)$/.test(o)?110:c?100:(a==="power"?s:l)?70:20}}var zg=new WeakMap,Pg=new WeakMap;function vk(t){let e=zg.get(t);if(e)return e;let n={nodes:new Map(t.map(r=>[r.object_id,r])),children:new Map};for(let r of t){let o=n.children.get(r.parent_id)??[];o.push(r),n.children.set(r.parent_id,o)}return zg.set(t,n),n}function wk(t,e,n){if(!oe(t))return[];let r=[e.area_id,...e.sub_areas??[]].map(Tg).filter(p=>!!p);if(!r.length)return[];let o=new Set(n.filter(p=>p.id!==e.id).flatMap(p=>[p.area_id,...p.sub_areas??[]]).map(Tg).filter(p=>!!p&&!r.includes(p))),i=`${r.join(",")}|${[...o].sort().join(",")}`,s=Pg.get(t)??new Map;Pg.set(t,s);let l=s.get(i);if(l)return l;let a=vk(t.symconObjects),c=[],u=new Set,d=(p,h,f)=>{if(u.has(p)||o.has(String(p)))return;u.add(p);let g=a.nodes.get(p);if(!g)return;let y=bk(g),b=y??h,v=new Set(y&&y!==h?[]:f),w=a.children.get(p)??[];if(b){let x=w.map(k=>yk(t,k)).filter(k=>k!==null);for(let k of new Set(x.map(S=>S.group))){if(v.has(k))continue;let S=x.filter(F=>F.group===k),E=Math.max(...S.map(F=>F.score)),T=S.filter(F=>F.score===E);for(let F of E>=100?T.slice(0,1):T)c.push({kind:b,metric:F.metric,id:F.source,period:F.period});v.add(k)}}for(let x of w)(x.object_type===0||x.object_type===1)&&d(x.object_id,b,v)};for(let p of r)d(Number(p),null,new Set);return s.set(i,c),c}function kk(t,e,n=!1){let r=new Map,o=new Set;for(let i of e){let s=Cl(t,i.id),l=`${i.kind}|${i.metric}|${s}`;if(o.has(l))continue;o.add(l);let a=t.states[s],c=Dg(a),u=c?.metric===i.metric?c.unit:String(a?.attributes.unit_of_measurement??"").trim(),d=`${i.kind}|${i.metric}|${u}|${i.period}`,p=r.get(d)??{kind:i.kind,metric:i.metric,unit:u,value:null,period:i.period,sources:[],manual:n,incomplete:!1},h=en(a);h===null?p.incomplete=!0:p.value=(p.value??0)+h*(c?.metric===i.metric?c.factor:1),p.sources.push(s),r.set(d,p)}return[...r.values()]}function Nl(t,e,n,r){let o=e.utility_meters?.[n],i=o&&Object.prototype.hasOwnProperty.call(o,r)?o[r]:n==="electricity"&&r==="power"?e.power_entity:null;return i&&i!=="none"?Cl(t,i):null}function Og(t,e,n=e.rooms){let r=e.rooms.flatMap(i=>wk(t,i,n)),o=[];for(let i of Sn)for(let s of["power","energy"]){let l=Nl(t,e,i,s);o.push(...kk(t,l?[{kind:i,metric:s,id:l,period:s==="energy"?Ig(Ll(String(t.states[l]?.attributes.friendly_name??""))):"total"}]:r.filter(a=>a.kind===i&&a.metric===s),!!l))}return o}function Bl(t){return t.metric==="power"?t.unit==="m\xB3/h"?"Durchfluss":"Leistung":{total:"Verbrauch",day:"Verbrauch heute",month:"Verbrauch Monat",year:"Verbrauch Jahr"}[t.period]}function Hg(t,e){let n=e.incomplete?"Err: ":"";if(e.value===null)return`${n}\u2013`;let r=e.unit==="W"&&Math.abs(e.value)>=1e3?e.value/1e3:e.value,o=e.unit==="W"&&Math.abs(e.value)>=1e3?"kW":e.unit,i=Number.isInteger(r)?0:Math.min(6,Math.max(2,1-Math.floor(Math.log10(Math.abs(r)))));return`${n}${K(t,r,i)}${o?` ${o}`:""}`}function Wl(t,e){let n=new Set;return e.flatMap(r=>{let o=String(t?.states[r]?.attributes.symcon_source_entity||r),i=t?.states[o]?.attributes,s=Number(i?.symcon_id);return!s||!i?.symcon_archive||n.has(s)?[]:(n.add(s),[o])})}var Lg,Vl=class extends Y{static properties={hass:{attribute:!1},ids:{attribute:!1},label:{attribute:!1},busy:{state:!0},error:{state:!0}};constructor(){super(),this.ids=[],this.label="",this.busy=!1,this.error=""}async open(e){e.stopPropagation(),this.busy=!0,this.error="";try{let n=new URL("./nextfloor-trend.js?v=b32d63f21bee",import.meta.url).href;await(await(Lg??=import(n).catch(o=>{throw Lg=void 0,o}))).openTrend(this.hass,this.ids,this.label)}catch(n){this.error=n instanceof Error?n.message:String(n)}finally{this.busy=!1}}render(){if(!Wl(this.hass,this.ids).length)return _;let e=this.label?`Trend anzeigen: ${this.label}`:"Trend anzeigen";return m`n.stopPropagation()} @click=${n=>{this.open(n)}}>
-
- ${this.error?m`${this.error}`:_}`}static styles=J`:host{display:inline-flex;vertical-align:middle;margin-left:4px;font-weight:normal}button{display:inline-flex;align-items:center;justify-content:center;width:25px;height:25px;padding:3px;border:1px solid currentColor;border-radius:6px;background:transparent;color:var(--nf-accent,#40c8ff);opacity:.8;cursor:pointer}button:hover,button:focus-visible{opacity:1;background:#40c8ff18}button:disabled{opacity:.4}span{font:12px system-ui;color:#ff9b9b;max-width:180px}`};customElements.get("nf-trend-button")||customElements.define("nf-trend-button",Vl);function Cg(t,e,n=""){let r=Wl(t,e);return r.length?m``:_}var Kl=class extends Y{static properties={hass:{attribute:!1},readings:{attribute:!1}};constructor(){super(),this.readings=[]}render(){return m`${Sn.filter(e=>this.readings.some(n=>n.kind===e)).map(e=>m``}var wg=t=>Math.round(t*1e3)/1e3,qi=class{ctx;sectionSel=null;windowSel=null;chimneySel=null;fieldSel=null;pickMode=!1;constructor(e){this.ctx=e}get sectionId(){return this.sectionSel}set sectionId(e){this.sectionSel=e,this.ctx.refresh()}get windowId(){return this.windowSel}set windowId(e){this.windowSel=e,this.ctx.refresh()}get chimneyId(){return this.chimneySel}set chimneyId(e){this.chimneySel=e,e&&(this.windowSel=null),this.ctx.refresh()}get solarId(){return this.fieldSel}set solarId(e){this.fieldSel=e,this.ctx.refresh()}get picking(){return this.pickMode}set picking(e){this.pickMode=e,this.ctx.refresh()}get doc(){return this.ctx.host.doc}get settings(){return this.doc.settings.roof}get admin(){return this.ctx.host.admin}get section(){return this.sectionSel?this.settings.sections?.find(e=>e.id===this.sectionSel):void 0}get window(){return this.windowSel?this.settings.windows?.find(e=>e.id===this.windowSel):void 0}get chimney(){return this.chimneySel?this.settings.chimneys?.find(e=>e.id===this.chimneySel):void 0}get field(){return this.fieldSel?this.settings.solar?.find(e=>e.id===this.fieldSel):void 0}isFixed(e){return!!e&&(!!e.locked||!!this.doc.settings.lock_plan)}useSections(e=!1){if(!this.admin)return;let n=(this.settings.sections??[]).length>0;e&&n&&!this.ctx.confirm(this.ctx.host.t("roof_regen_confirm"))||(this.ctx.host.change(r=>{r.settings.roof.type="custom",(e||!n)&&(r.settings.roof.sections=la(r,()=>I("roof")))}),this.sectionId=null)}addSection(e,n){if(!this.admin)return;let r=of(this.doc,e,n);this.ctx.host.change(o=>{o.settings.roof.type="custom",o.settings.roof.sections=[...o.settings.roof.sections??[],r]}),this.sectionId=r.id}takeOutline(){let e=this.ctx.host.floor;if(!e||!this.sectionSel||!this.admin)return;let{wall_exterior:n,wall_interior:r}=this.doc.settings,o=ea(e.rooms,e.walls??[],n,r);if(!o)return;let i=o.map(([s,l])=>[wg(s),wg(l)]);this.patchSection({shape:"flat",points:i,...Nt(i)})}addDormer(e){let n=this.section;if(!n||!this.admin)return;let r=ta(n,e,I("roof"));this.ctx.host.change(o=>{o.settings.roof.sections=[...o.settings.roof.sections??[],r]}),this.sectionId=r.id}patchSection(e){let n=this.sectionSel;!n||!this.admin||this.ctx.host.change(r=>{let o=r.settings.roof.sections?.find(i=>i.id===n);o&&Object.assign(o,e)})}removeCorner(e){let n=this.sectionSel;!n||!this.admin||this.ctx.host.change(r=>{let o=r.settings.roof.sections?.find(i=>i.id===n);o&&cf(o,e)})}removeSection(){let e=this.sectionSel;!e||!this.admin||(this.ctx.host.change(n=>n.settings.roof.sections=(n.settings.roof.sections??[]).filter(r=>r.id!==e)),this.sectionId=null)}duplicateSection(){let e=this.section;if(!e||!this.admin)return;let n=sf(e);this.ctx.host.change(r=>r.settings.roof.sections=[...r.settings.roof.sections??[],n]),this.sectionId=n.id}addWindow(){if(!this.admin)return;let e=this.doc.settings.north??0,n=Yr(Z(this.doc).filter(o=>!o.flat),e)??Z(this.doc)[0];if(!n)return;let r=Zr(n,I("rwin"));this.ctx.host.change(o=>o.settings.roof.windows=[...o.settings.roof.windows??[],r]),this.windowSel=r.id,this.sectionId=null}patchWindow(e){let n=this.windowSel;!n||!this.admin||this.ctx.host.change(r=>{let o=r.settings.roof.windows?.find(s=>s.id===n);if(!o)return;Object.assign(o,e);let i=Z(r).find(s=>s.key===o.face);i&&Object.assign(o,ft(i,dn(o)))})}removeWindow(){let e=this.windowSel;!e||!this.admin||(this.ctx.host.change(n=>n.settings.roof.windows=(n.settings.roof.windows??[]).filter(r=>r.id!==e)),this.windowId=null)}addChimney(){if(!this.admin)return;let e=Z(this.doc),n=e.find(o=>!o.flat)??e[0];if(!n)return;let r=qr(n,I("chim"));this.ctx.host.change(o=>o.settings.roof.chimneys=[...o.settings.roof.chimneys??[],r]),this.chimneySel=r.id,this.windowSel=null,this.sectionId=null}patchChimney(e){let n=this.chimneySel;!n||!this.admin||this.ctx.host.change(r=>{let o=r.settings.roof.chimneys?.find(s=>s.id===n);if(!o)return;Object.assign(o,e);let i=Z(r).find(s=>s.key===o.face);i&&Object.assign(o,ft(i,kt(o,i)))})}removeChimney(){let e=this.chimneySel;!e||!this.admin||(this.ctx.host.change(n=>n.settings.roof.chimneys=(n.settings.roof.chimneys??[]).filter(r=>r.id!==e)),this.chimneyId=null)}addField(){if(!this.admin)return;let e=Z(this.doc),n=new Set((this.settings.solar??[]).map(i=>i.face)),r=this.doc.settings.north??0,o=Yr(e.filter(i=>!n.has(i.key)),r)??Yr(e,r);o&&(this.appendField(Vn(o,I("pv"))),this.sectionSel=null)}addWallField(){let e=this.ctx.floorId()??this.doc.floors[0]?.id,n=this.admin&&e?fa(this.doc,I("pv"),e):null;n&&this.appendField(n)}addGroundField(){this.admin&&this.appendField(Gr(this.doc,I("pv")))}appendField(e){this.ctx.host.change(n=>n.settings.roof.solar=[...n.settings.roof.solar??[],e]),this.solarId=e.id}selectField(e){this.fieldSel=e,this.sectionSel=null;let n=this.settings.solar?.find(r=>r.id===e);n?.face.startsWith("wall:")&&this.ctx.setFloorId(n.face.split(":")[1]),this.ctx.refresh()}patchField(e){this.editField((n,r)=>{Object.assign(n,e);let o=$e(r,n);o&&Object.assign(n,ft(o,n))})}toggleCell(e){this.editField(n=>n.skip=pg(n.skip,e))}editField(e){let n=this.fieldSel;!n||!this.admin||this.ctx.host.change(r=>{let o=r.settings.roof.solar?.find(i=>i.id===n);o&&e(o,r)})}setString(e){let n=this.fieldSel;!n||!this.admin||this.ctx.host.change(r=>hg(r.settings.roof,n,e,{id:I("str"),name:o=>this.ctx.host.t("solar_string_n",{n:o})}))}patchString(e){let n=this.field?.string;!n||!this.admin||this.ctx.host.change(r=>{let o=r.settings.roof.strings?.find(i=>i.id===n);o&&Object.assign(o,e)})}removeField(){let e=this.fieldSel;!e||!this.admin||(this.ctx.host.change(n=>{n.settings.roof.solar=(n.settings.roof.solar??[]).filter(r=>r.id!==e),Il(n.settings.roof)}),this.solarId=null)}floorsTopDown(){return[...this.doc.floors].sort((e,n)=>n.elevation-e.elevation)}};var kg=(t,e)=>t.floors.flatMap(n=>n.furniture).find(n=>n.type===e),ck=t=>!t||t==="none";async function xg(t){let e;try{e=await t.hass.callWS({type:"energy/get_prefs"})}catch{return{kind:"failed"}}let n=Zh(t.hass,e),r=0,o=(i,s,l)=>{if(!l)return;let a=kg(t.doc(),i);!a&&t.canAdd()&&(t.addDevice(i),a=kg(t.doc(),i)),!(!a||!ck(a[s]))&&(t.setField(a.id,s,l),r++)};return o("meter","power",n.grid),o("inverter","power",n.solar),o("home_battery","power",n.battery),o("home_battery","soc",n.battery_soc),{kind:"done",filled:r}}var uk=/garage|carport/,dk=/hwr|hauswirt|technik|keller|abstell|utility|basement|boiler|heiz/,hk=/flur|diele|eingang|hall|entr|lobby/,$g=.25,or=t=>Math.round(t*1e3)/1e3;function pk(t,e,n){let r=e.rooms.filter(u=>u.points.length>=3),o=u=>r.find(d=>u.test(n.roomLabel(d).toLowerCase())),i=r.find(u=>e.furniture.some(d=>d.type==="parking"&&N([d.x,d.z],u.points))),s=o(uk)??i,l=o(dk),a=t==="wallbox"?s:t==="meter"?l??o(hk)??s:l??s,c=[...r].sort((u,d)=>Math.abs(_e(d.points))-Math.abs(_e(u.points)))[0];return a??n.selected??c}function fk(t,e){let[n,r]=be(t.points),o=t.points.some((s,l)=>!e.has(l)),i=null;return t.points.forEach((s,l)=>{if(o&&e.has(l))return;let a=t.points[(l+1)%t.points.length],c=Math.hypot(a[0]-s[0],a[1]-s[1]);if(i&&c<=i.length)return;let u=[(s[0]+a[0])/2,(s[1]+a[1])/2],d=[-(a[1]-s[1])/c+0,(a[0]-s[0])/c+0];(n-u[0])*d[0]+(r-u[1])*d[1]<0&&(d=[0-d[0],0-d[1]]),i={mid:u,inward:d,length:c}}),i}function Sg(t,e,n,r){let[o,i,s]=ut(t),l={id:I("furniture"),type:t,rotation:0,w:o,d:i,h:s,variant:null};if(t==="grid_point"){let h=Xh(e),[f,g]=h?[h.x,h.z]:r.fallback;return{...l,x:or(f),z:or(g)}}let a=pk(t,n,r),[c,u]=a?be(a.points):r.fallback;if(a){let h=new Set(n.openings.filter(g=>g.room_id===a.id).map(g=>g.edge)),f=fk(a,h);f&&([c,u]=[f.mid[0]+f.inward[0]*(i/2+$g),f.mid[1]+f.inward[1]*(i/2+$g)])}let d={...l,x:or(c),z:or(u)},p=a?Ar({...n,furniture:[...n.furniture,d]},d,e.settings.wall_interior):null;return p?{...d,x:or(p.x),z:or(p.z),rotation:p.rotation}:d}var Yi=class{limit;undoStack=[];redoStack=[];constructor(e=100){this.limit=e}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}record(e){this.undoStack.push(JSON.stringify(e)),this.undoStack.length>this.limit&&this.undoStack.shift(),this.redoStack=[]}undo(e){let n=this.undoStack.pop();return n===void 0?null:(this.redoStack.push(JSON.stringify(e)),JSON.parse(n))}redo(e){let n=this.redoStack.pop();return n===void 0?null:(this.undoStack.push(JSON.stringify(e)),JSON.parse(n))}};var Ol=t=>Math.round(t*1e3)/1e3,ir="unmovable",Xi="no change";function Mg(t,e,n,r){let o=i=>[Ol(i[0]+n),Ol(i[1]+r)];switch(e.kind){case"device":return t.placements.some(i=>i.entity_id===e.id)?{apply(i){let s=i.placements.find(l=>l.entity_id===e.id);s&&([s.x,s.z]=o([s.x,s.z]))}}:ir;case"furniture":return{apply(i){let s=i.furniture.find(l=>l.id===e.id);s&&([s.x,s.z]=o([s.x,s.z]))}};case"wall":return{apply(i){let s=(i.walls??[]).find(l=>l.id===e.id);s&&([s.a,s.b]=[o(s.a),o(s.b)])}};case"outdoor":return{apply(i){let s=i.outdoor.find(l=>l.id===e.id);s&&(s.points=s.points.map(o))}};case"opening":{let i=t.openings.find(g=>g.id===e.id),s=i?De(i,t.rooms,t.walls??[]):null;if(!i||!s)return ir;let l=s.room.points[s.edge],a=s.room.points[(s.edge+1)%s.room.points.length],c=Math.hypot(a[0]-l[0],a[1]-l[1])||1,u=(n*(a[0]-l[0])+r*(a[1]-l[1]))/c;if(Math.abs(u)<1e-9)return Xi;let d=Bt(t.openings,i),p=!i.wall&&d.length>1?Gn(s.room,d):null;if(p){let g=Math.max(0,Math.min(Xr(s.room)-p.width,p.from+u));return Math.abs(g-p.from)<1e-9?Xi:{apply(y){let b=y.openings.find(w=>w.id===e.id),v=b?Qr(y.openings,s.room,b,g,p.width):null;v&&(y.openings=v)}}}let h=Math.min(i.width,c)/2,f=Ol(Math.min(c-h,Math.max(h,i.offset+u)));return{apply(g){let y=g.openings.find(b=>b.id===e.id);y&&(y.offset=f)}}}case"room":{let i=t.rooms.find(l=>l.id===e.id);if(!i)return ir;let s=new Set(t.placements.filter(l=>N([l.x,l.z],i.points)).map(l=>l.entity_id));return{apply(l){let a=l.rooms.find(c=>c.id===e.id);if(a){if(e.corner!==null&&e.cornerMath.round(t*1e3)/1e3,Hl=t=>(t+90)%360;function Rg(t,e,n){let r=o=>[o.x,o.z]=e([o.x,o.z]);for(let o of t.rooms)o.points=o.points.map(e);for(let o of t.furniture)r(o),n&&(o.rotation=Hl(o.rotation));for(let o of t.placements)r(o),n&&(o.rotation=Hl(o.rotation??0));for(let o of t.outdoor)o.points=o.points.map(e);for(let o of t.walls??[])[o.a,o.b]=[e(o.a),e(o.b)];t.background&&(r(t.background),n&&(t.background.rotation=Hl(t.background.rotation??0)))}function mk(t,e){for(let r of t.settings.roof.sections??[]){let o=[e([r.x0,r.z0]),e([r.x1,r.z0]),e([r.x1,r.z1]),e([r.x0,r.z1])],[i,s]=[o.map(l=>l[0]),o.map(l=>l[1])];[r.x0,r.x1,r.z0,r.z1]=[Math.min(...i),Math.max(...i),Math.min(...s),Math.max(...s)],r.points&&(r.points=r.points.map(e))}let n=t.energy.meter;n&&([n.x,n.z]=e([n.x,n.z]))}function Eg(t,e,n,r){if(e.allFloors){for(let o of t.floors)Rg(o,n,r);mk(t,n)}else{let o=t.floors.find(i=>i.id===e.floorId);o&&Rg(o,n,r)}}function Ag(t,e,n,r){Eg(t,e,([o,i])=>[Qi(o+n),Qi(i+r)],!1)}function gk(t,e){let r=(e.allFloors?t.floors:t.floors.filter(s=>s.id===e.floorId)).flatMap(s=>s.rooms.flatMap(l=>l.points));if(r.length===0)return null;let[o,i]=[r.map(s=>s[0]),r.map(s=>s[1])];return[(Math.min(...o)+Math.max(...o))/2,(Math.min(...i)+Math.max(...i))/2]}function Fg(t,e){let n=gk(t,e);if(!n)return!1;let[r,o]=n;return Eg(t,e,([i,s])=>[Qi(r-(s-o)),Qi(o+(i-r))],!0),!0}var Ji=class{onChange;ids={room:null,opening:null,furniture:null,device:null,outdoor:null,wall:null};cornerSel=null;edgeSel=null;constructor(e){this.onChange=e}set(e,n){this.ids[e]=n,this.onChange()}get room(){return this.ids.room}set room(e){this.set("room",e)}get opening(){return this.ids.opening}set opening(e){this.set("opening",e)}get furniture(){return this.ids.furniture}set furniture(e){this.set("furniture",e)}get device(){return this.ids.device}set device(e){this.set("device",e)}get outdoor(){return this.ids.outdoor}set outdoor(e){this.set("outdoor",e)}get wall(){return this.ids.wall}set wall(e){this.set("wall",e)}get corner(){return this.cornerSel}set corner(e){this.cornerSel=e,this.onChange()}get edge(){return this.edgeSel}set edge(e){this.edgeSel=e,this.onChange()}select(e,n,r){let o=this.ids.room,i={room:null,opening:null,furniture:null,device:null,outdoor:null,wall:null};i[e]=n,e==="room"?i.room=n:e!=="outdoor"&&e!=="wall"&&(i.room=o),e==="device"&&n&&(i.room=r.roomOfDevice(n)??i.room),e==="opening"&&n&&(i.room=r.roomOfOpening(n)??i.room),(e!=="room"||n!==o)&&(this.cornerSel=null),this.edgeSel=null,this.ids=i,this.onChange()}get target(){for(let e of["device","opening","furniture","wall","outdoor","room"]){let n=this.ids[e];if(n)return{kind:e,id:n}}return null}};var es=class{onChange;menuOpen=!1;packagesOpen=!1;draft=null;shiftXMetres=0;shiftZMetres=0;wholeHouse=!1;line=null;query="";source="area";unfolded=new Set;copyChoice=null;constructor(e){this.onChange=e}get floorMenu(){return this.menuOpen}set floorMenu(e){this.menuOpen=e,this.onChange()}get floorCopy(){return this.copyChoice}set floorCopy(e){this.copyChoice=e,this.onChange()}get packages(){return this.packagesOpen}set packages(e){this.packagesOpen=e,this.onChange()}get spots(){return this.draft}set spots(e){this.draft=e,this.onChange()}get shiftX(){return this.shiftXMetres}set shiftX(e){this.shiftXMetres=e,this.onChange()}get shiftZ(){return this.shiftZMetres}set shiftZ(e){this.shiftZMetres=e,this.onChange()}get shiftAll(){return this.wholeHouse}set shiftAll(e){this.wholeHouse=e,this.onChange()}get notice(){return this.line}set notice(e){this.line=e,this.onChange()}get deviceQuery(){return this.query}set deviceQuery(e){this.query=e,this.onChange()}get deviceSource(){return this.source}set deviceSource(e){this.source=e,this.query="",this.onChange()}isUnfolded(e){return this.unfolded.has(e)}toggleUnfolded(e){let n=new Set(this.unfolded);n.delete(e)||n.add(e),this.unfolded=n,this.onChange()}};var sr={electricity:"Strom",water:"Wasser",gas:"Gas",heating:"Heizen",cooling:"K\xFChlen"},ts={electricity:"\u26A1",water:"\u{1F4A7}",gas:"\u{1F525}",heating:"\u2668",cooling:"\u2744"},Ll=t=>t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/ß/g,"ss").replace(/[^a-z0-9]+/g," ").trim(),_k="{485D0419-BE97-4548-AA9C-C083EB82E61E}",bk=t=>t.object_type!==0&&!(t.object_type===1&&t.module_id?.toUpperCase()===_k)?null:{elektro:"electricity",strom:"electricity","elektro strom":"electricity","strom elektro":"electricity",wasser:"water",gas:"gas",heizen:"heating",heizung:"heating",warme:"heating",waerme:"heating",kuhlen:"cooling",kuehlen:"cooling",kuhlung:"cooling",kuehlung:"cooling",kalte:"cooling",kaelte:"cooling"}[Ll(t.name)]??null,Tg=t=>/^symcon-category-(\d+)$/.exec(t??"")?.[1],Ig=t=>/\b(heute|tag|tagesverbrauch|today|daily)\b/.test(t)?"day":/monat|month/.test(t)?"month":/jahr|year/.test(t)?"year":"total",Cl=(t,e)=>String(t.states[e]?.attributes.symcon_source_entity||e);function Dg(t){let e=String(t?.attributes.unit_of_measurement??"").trim(),n=e.replace(/[³]/g,"3").replace(/[²]/g,"2").replace(/\s+/g,"").toLowerCase();return["w","kw","mw"].includes(n)?{metric:"power",unit:"W",factor:e==="mW"?.001:n==="kw"?1e3:n==="mw"?1e6:1}:["wh","kwh","mwh","j","kj","mj","gj"].includes(n)?{metric:"energy",unit:"kWh",factor:{wh:.001,kwh:1,mwh:1e3,j:1/36e5,kj:1/3600,mj:1/3.6,gj:1e3/3.6}[n]}:["m3/h","m3h","m3/min","m3/s","l/h","l/min","l/s","liter/h","liter/min"].includes(n)?{metric:"power",unit:"m\xB3/h",factor:{"m3/h":1,m3h:1,"m3/min":60,"m3/s":3600,"l/h":.001,"l/min":.06,"l/s":3.6,"liter/h":.001,"liter/min":.06}[n]}:["m3","l","liter"].includes(n)?{metric:"energy",unit:"m\xB3",factor:n==="m3"?1:.001}:null}function yk(t,e){if(!e.entity_id||e.object_type!==2&&e.object_type!==6)return null;let n=Cl(t,e.entity_id),r=t.states[n];if(!r||![1,2].includes(Number(r.attributes.symcon_variable_type)))return null;let o=Ll(e.name),i=Dg(r),s=/^(leistung|wirkleistung|gesamtleistung|aktuelle leistung|durchfluss|volumenstrom)(\b|$)/.test(o),l=/^(verbrauch|energie|energieverbrauch|gesamtverbrauch|gesamtenergie|zahlerstand|zaehlerstand|arbeit)(\b|$)/.test(o),a=i?.metric??(s?"power":l?"energy":null);if(!a)return null;let c=a==="power"?/^(leistung|wirkleistung|gesamtleistung|durchfluss|volumenstrom)$/.test(o):/^(verbrauch|energie|energieverbrauch|gesamtverbrauch|gesamtenergie|zahlerstand|zaehlerstand|arbeit)$/.test(o),u=a==="energy"?Ig(o):"total";return{metric:a,source:n,period:u,group:`${a}|${i?.unit??String(r.attributes.unit_of_measurement??"")}|${u}`,score:/^gesamt(leistung|verbrauch|energie)$/.test(o)?110:c?100:(a==="power"?s:l)?70:20}}var zg=new WeakMap,Pg=new WeakMap;function vk(t){let e=zg.get(t);if(e)return e;let n={nodes:new Map(t.map(r=>[r.object_id,r])),children:new Map};for(let r of t){let o=n.children.get(r.parent_id)??[];o.push(r),n.children.set(r.parent_id,o)}return zg.set(t,n),n}function wk(t,e,n){if(!oe(t))return[];let r=[e.area_id,...e.sub_areas??[]].map(Tg).filter(p=>!!p);if(!r.length)return[];let o=new Set(n.filter(p=>p.id!==e.id).flatMap(p=>[p.area_id,...p.sub_areas??[]]).map(Tg).filter(p=>!!p&&!r.includes(p))),i=`${r.join(",")}|${[...o].sort().join(",")}`,s=Pg.get(t)??new Map;Pg.set(t,s);let l=s.get(i);if(l)return l;let a=vk(t.symconObjects),c=[],u=new Set,d=(p,h,f)=>{if(u.has(p)||o.has(String(p)))return;u.add(p);let g=a.nodes.get(p);if(!g)return;let y=bk(g),b=y??h,v=new Set(y&&y!==h?[]:f),w=a.children.get(p)??[];if(b){let x=w.map(k=>yk(t,k)).filter(k=>k!==null);for(let k of new Set(x.map(S=>S.group))){if(v.has(k))continue;let S=x.filter(F=>F.group===k),E=Math.max(...S.map(F=>F.score)),T=S.filter(F=>F.score===E);for(let F of E>=100?T.slice(0,1):T)c.push({kind:b,metric:F.metric,id:F.source,period:F.period});v.add(k)}}for(let x of w)(x.object_type===0||x.object_type===1)&&d(x.object_id,b,v)};for(let p of r)d(Number(p),null,new Set);return s.set(i,c),c}function kk(t,e,n=!1){let r=new Map,o=new Set;for(let i of e){let s=Cl(t,i.id),l=`${i.kind}|${i.metric}|${s}`;if(o.has(l))continue;o.add(l);let a=t.states[s],c=Dg(a),u=c?.metric===i.metric?c.unit:String(a?.attributes.unit_of_measurement??"").trim(),d=`${i.kind}|${i.metric}|${u}|${i.period}`,p=r.get(d)??{kind:i.kind,metric:i.metric,unit:u,value:null,period:i.period,sources:[],manual:n,incomplete:!1},h=en(a);h===null?p.incomplete=!0:p.value=(p.value??0)+h*(c?.metric===i.metric?c.factor:1),p.sources.push(s),r.set(d,p)}return[...r.values()]}function Nl(t,e,n,r){let o=e.utility_meters?.[n],i=o&&Object.prototype.hasOwnProperty.call(o,r)?o[r]:n==="electricity"&&r==="power"?e.power_entity:null;return i&&i!=="none"?Cl(t,i):null}function Og(t,e,n=e.rooms){let r=e.rooms.flatMap(i=>wk(t,i,n)),o=[];for(let i of Sn)for(let s of["power","energy"]){let l=Nl(t,e,i,s);o.push(...kk(t,l?[{kind:i,metric:s,id:l,period:s==="energy"?Ig(Ll(String(t.states[l]?.attributes.friendly_name??""))):"total"}]:r.filter(a=>a.kind===i&&a.metric===s),!!l))}return o}function Bl(t){return t.metric==="power"?t.unit==="m\xB3/h"?"Durchfluss":"Leistung":{total:"Verbrauch",day:"Verbrauch heute",month:"Verbrauch Monat",year:"Verbrauch Jahr"}[t.period]}function Hg(t,e){let n=e.incomplete?"Err: ":"";if(e.value===null)return`${n}\u2013`;let r=e.unit==="W"&&Math.abs(e.value)>=1e3?e.value/1e3:e.value,o=e.unit==="W"&&Math.abs(e.value)>=1e3?"kW":e.unit,i=Number.isInteger(r)?0:Math.min(6,Math.max(2,1-Math.floor(Math.log10(Math.abs(r)))));return`${n}${K(t,r,i)}${o?` ${o}`:""}`}function Wl(t,e){let n=new Set;return e.flatMap(r=>{let o=String(t?.states[r]?.attributes.symcon_source_entity||r),i=t?.states[o]?.attributes,s=Number(i?.symcon_id);return!s||!i?.symcon_archive||n.has(s)?[]:(n.add(s),[o])})}var Lg,Vl=class extends Y{static properties={hass:{attribute:!1},ids:{attribute:!1},label:{attribute:!1},busy:{state:!0},error:{state:!0}};constructor(){super(),this.ids=[],this.label="",this.busy=!1,this.error=""}async open(e){e.stopPropagation(),this.busy=!0,this.error="";try{let n=new URL("./nextfloor-trend.js?v=84417e0b2573",import.meta.url).href;await(await(Lg??=import(n).catch(o=>{throw Lg=void 0,o}))).openTrend(this.hass,this.ids,this.label)}catch(n){this.error=n instanceof Error?n.message:String(n)}finally{this.busy=!1}}render(){if(!Wl(this.hass,this.ids).length)return _;let e=this.label?`Trend anzeigen: ${this.label}`:"Trend anzeigen";return m`n.stopPropagation()} @click=${n=>{this.open(n)}}>
+
+ ${this.error?m`${this.error}`:_}`}static styles=J`:host{position:relative;display:inline-flex;flex:0 0 18px;width:18px;height:18px;vertical-align:middle;margin-left:3px;font-weight:normal;line-height:0}button{display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;width:18px;height:18px;padding:2px;border:0;border-radius:3px;background:transparent;color:var(--nf-accent,#40c8ff);opacity:.8;cursor:pointer}svg{display:block;flex-shrink:0}button:hover,button:focus-visible{opacity:1;background:#40c8ff18}button:focus-visible{outline:1px solid currentColor;outline-offset:1px}button:disabled{opacity:.4}span{position:absolute;right:0;top:22px;z-index:10;box-sizing:border-box;width:200px;padding:8px;border:1px solid #ff9b9b50;border-radius:6px;background:var(--nf-chrome-solid,#1c1c1c);font:12px/1.4 system-ui;color:#ff9b9b;white-space:normal}`};customElements.get("nf-trend-button")||customElements.define("nf-trend-button",Vl);function Cg(t,e,n=""){let r=Wl(t,e);return r.length?m``:_}var Kl=class extends Y{static properties={hass:{attribute:!1},readings:{attribute:!1}};constructor(){super(),this.readings=[]}render(){return m`${Sn.filter(e=>this.readings.some(n=>n.kind===e)).map(e=>m`
${ts[e]} ${sr[e]}
${this.readings.filter(n=>n.kind===e).map(n=>m`this.hass.states[r]?.attributes.symcon_path||this.hass.states[r]?.attributes.friendly_name||r).join(`
diff --git a/NextFloor/assets/nextfloor-trend.js b/NextFloor/assets/nextfloor-trend.js
index 21163b0..8aa0213 100644
--- a/NextFloor/assets/nextfloor-trend.js
+++ b/NextFloor/assets/nextfloor-trend.js
@@ -1,7 +1,7 @@
/*! NextFloor, MIT licence. Includes three.js (MIT) and Lit (BSD-3-Clause); see LICENSE and THIRD_PARTY_NOTICES.md */
-var B=globalThis,j=B.ShadowRoot&&(B.ShadyCSS===void 0||B.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Z=Symbol(),ht=new WeakMap,H=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==Z)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(j&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=ht.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&ht.set(i,t))}return t}toString(){return this.cssText}},ct=s=>new H(typeof s=="string"?s:s+"",void 0,Z),y=(s,...t)=>{let i=s.length===1?s[0]:t.reduce((r,e,n)=>r+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(e)+s[n+1],s[0]);return new H(i,s,Z)},dt=(s,t)=>{if(j)s.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet);else for(let i of t){let r=document.createElement("style"),e=B.litNonce;e!==void 0&&r.setAttribute("nonce",e),r.textContent=i.cssText,s.appendChild(r)}},F=j?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return ct(i)})(s):s;var{is:Rt,defineProperty:Ht,getOwnPropertyDescriptor:Ot,getOwnPropertyNames:Lt,getOwnPropertySymbols:Nt,getPrototypeOf:Ut}=Object,V=globalThis,pt=V.trustedTypes,Dt=pt?pt.emptyScript:"",It=V.reactiveElementPolyfillSupport,O=(s,t)=>s,K={toAttribute(s,t){switch(t){case Boolean:s=s?Dt:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let i=s;switch(t){case Boolean:i=s!==null;break;case Number:i=s===null?null:Number(s);break;case Object:case Array:try{i=JSON.parse(s)}catch{i=null}}return i}},ft=(s,t)=>!Rt(s,t),ut={attribute:!0,type:String,converter:K,reflect:!1,useDefault:!1,hasChanged:ft};Symbol.metadata??=Symbol("metadata"),V.litPropertyMetadata??=new WeakMap;var _=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,i=ut){if(i.state&&(i.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((i=Object.create(i)).wrapped=!0),this.elementProperties.set(t,i),!i.noAccessor){let r=Symbol(),e=this.getPropertyDescriptor(t,r,i);e!==void 0&&Ht(this.prototype,t,e)}}static getPropertyDescriptor(t,i,r){let{get:e,set:n}=Ot(this.prototype,t)??{get(){return this[i]},set(o){this[i]=o}};return{get:e,set(o){let h=e?.call(this);n?.call(this,o),this.requestUpdate(t,h,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??ut}static _$Ei(){if(this.hasOwnProperty(O("elementProperties")))return;let t=Ut(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(O("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(O("properties"))){let i=this.properties,r=[...Lt(i),...Nt(i)];for(let e of r)this.createProperty(e,i[e])}let t=this[Symbol.metadata];if(t!==null){let i=litPropertyMetadata.get(t);if(i!==void 0)for(let[r,e]of i)this.elementProperties.set(r,e)}this._$Eh=new Map;for(let[i,r]of this.elementProperties){let e=this._$Eu(i,r);e!==void 0&&this._$Eh.set(e,i)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let e of r)i.unshift(F(e))}else t!==void 0&&i.push(F(t));return i}static _$Eu(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,i=this.constructor.elementProperties;for(let r of i.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return dt(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$ET(t,i){let r=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,r);if(e!==void 0&&r.reflect===!0){let n=(r.converter?.toAttribute!==void 0?r.converter:K).toAttribute(i,r.type);this._$Em=t,n==null?this.removeAttribute(e):this.setAttribute(e,n),this._$Em=null}}_$AK(t,i){let r=this.constructor,e=r._$Eh.get(t);if(e!==void 0&&this._$Em!==e){let n=r.getPropertyOptions(e),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:K;this._$Em=e;let h=o.fromAttribute(i,n.type);this[e]=h??this._$Ej?.get(e)??h,this._$Em=null}}requestUpdate(t,i,r,e=!1,n){if(t!==void 0){let o=this.constructor;if(e===!1&&(n=this[t]),r??=o.getPropertyOptions(t),!((r.hasChanged??ft)(n,i)||r.useDefault&&r.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,r))))return;this.C(t,i,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,i,{useDefault:r,reflect:e,wrapped:n},o){r&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??i??this[t]),n!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||r||(i=void 0),this._$AL.set(t,i)),e===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,n]of this._$Ep)this[e]=n;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[e,n]of r){let{wrapped:o}=n,h=this[e];o!==!0||this._$AL.has(e)||h===void 0||this.C(e,void 0,n,h)}}let t=!1,i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(i)):this._$EM()}catch(r){throw t=!1,this._$EM(),r}t&&this._$AE(i)}willUpdate(t){}_$AE(t){this._$EO?.forEach(i=>i.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(i=>this._$ET(i,this[i])),this._$EM()}updated(t){}firstUpdated(t){}};_.elementStyles=[],_.shadowRootOptions={mode:"open"},_[O("elementProperties")]=new Map,_[O("finalized")]=new Map,It?.({ReactiveElement:_}),(V.reactiveElementVersions??=[]).push("2.1.2");var et=globalThis,mt=s=>s,W=et.trustedTypes,gt=W?W.createPolicy("lit-html",{createHTML:s=>s}):void 0,_t="$lit$",S=`lit$${Math.random().toFixed(9).slice(2)}$`,wt="?"+S,Bt=`<${wt}>`,M=document,N=()=>M.createComment(""),U=s=>s===null||typeof s!="object"&&typeof s!="function",it=Array.isArray,jt=s=>it(s)||typeof s?.[Symbol.iterator]=="function",Y=`[
-\f\r]`,L=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,bt=/-->/g,vt=/>/g,E=RegExp(`>|${Y}(?:([^\\s"'>=/]+)(${Y}*=${Y}*(?:[^
-\f\r"'\`<>=]|("|')|))|$)`,"g"),$t=/'/g,xt=/"/g,St=/^(?:script|style|textarea|title)$/i,rt=s=>(t,...i)=>({_$litType$:s,strings:t,values:i}),g=rt(1),A=rt(2),Jt=rt(3),T=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),yt=new WeakMap,k=M.createTreeWalker(M,129);function At(s,t){if(!it(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return gt!==void 0?gt.createHTML(t):t}var Vt=(s,t)=>{let i=s.length-1,r=[],e,n=t===2?"
":t===3?"":t===3?"":"")),r]},D=class s{constructor({strings:t,_$litType$:i},r){let e;this.parts=[];let n=0,o=0,h=t.length-1,a=this.parts,[c,p]=Vt(t,i);if(this.el=s.createElement(c,r),k.currentNode=this.el.content,i===2||i===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(e=k.nextNode())!==null&&a.length
0){e.textContent=W?W.emptyScript:"";for(let $=0;$2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=u}_$AI(t,i=this,r,e){let n=this.strings,o=!1;if(n===void 0)t=P(this,t,i,0),o=!U(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else{let h=t,a,c;for(t=n[0],a=0;a{let r=i?.renderBefore??t,e=r._$litPart$;if(e===void 0){let n=i?.renderBefore??null;r._$litPart$=e=new I(t.insertBefore(N(),n),n,void 0,i??{})}return e._$AI(s),e};var nt=globalThis,x=class extends _{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Et(i,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return T}};x._$litElement$=!0,x.finalized=!0,nt.litElementHydrateSupport?.({LitElement:x});var qt=nt.litElementPolyfillSupport;qt?.({LitElement:x});(nt.litElementVersions??=[]).push("4.2.2");var q=y`
+var j=globalThis,B=j.ShadowRoot&&(j.ShadyCSS===void 0||j.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,K=Symbol(),ct=new WeakMap,P=class{constructor(t,i,r){if(this._$cssResult$=!0,r!==K)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=i}get styleSheet(){let t=this.o,i=this.t;if(B&&t===void 0){let r=i!==void 0&&i.length===1;r&&(t=ct.get(i)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&ct.set(i,t))}return t}toString(){return this.cssText}},pt=s=>new P(typeof s=="string"?s:s+"",void 0,K),w=(s,...t)=>{let i=s.length===1?s[0]:t.reduce((r,e,n)=>r+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(e)+s[n+1],s[0]);return new P(i,s,K)},ut=(s,t)=>{if(B)s.adoptedStyleSheets=t.map(i=>i instanceof CSSStyleSheet?i:i.styleSheet);else for(let i of t){let r=document.createElement("style"),e=j.litNonce;e!==void 0&&r.setAttribute("nonce",e),r.textContent=i.cssText,s.appendChild(r)}},Y=B?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let i="";for(let r of t.cssRules)i+=r.cssText;return pt(i)})(s):s;var{is:Lt,defineProperty:Ot,getOwnPropertyDescriptor:Dt,getOwnPropertyNames:Nt,getOwnPropertySymbols:Ut,getPrototypeOf:It}=Object,V=globalThis,ft=V.trustedTypes,jt=ft?ft.emptyScript:"",Bt=V.reactiveElementPolyfillSupport,L=(s,t)=>s,J={toAttribute(s,t){switch(t){case Boolean:s=s?jt:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let i=s;switch(t){case Boolean:i=s!==null;break;case Number:i=s===null?null:Number(s);break;case Object:case Array:try{i=JSON.parse(s)}catch{i=null}}return i}},mt=(s,t)=>!Lt(s,t),gt={attribute:!0,type:String,converter:J,reflect:!1,useDefault:!1,hasChanged:mt};Symbol.metadata??=Symbol("metadata"),V.litPropertyMetadata??=new WeakMap;var _=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,i=gt){if(i.state&&(i.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((i=Object.create(i)).wrapped=!0),this.elementProperties.set(t,i),!i.noAccessor){let r=Symbol(),e=this.getPropertyDescriptor(t,r,i);e!==void 0&&Ot(this.prototype,t,e)}}static getPropertyDescriptor(t,i,r){let{get:e,set:n}=Dt(this.prototype,t)??{get(){return this[i]},set(o){this[i]=o}};return{get:e,set(o){let d=e?.call(this);n?.call(this,o),this.requestUpdate(t,d,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??gt}static _$Ei(){if(this.hasOwnProperty(L("elementProperties")))return;let t=It(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(L("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(L("properties"))){let i=this.properties,r=[...Nt(i),...Ut(i)];for(let e of r)this.createProperty(e,i[e])}let t=this[Symbol.metadata];if(t!==null){let i=litPropertyMetadata.get(t);if(i!==void 0)for(let[r,e]of i)this.elementProperties.set(r,e)}this._$Eh=new Map;for(let[i,r]of this.elementProperties){let e=this._$Eu(i,r);e!==void 0&&this._$Eh.set(e,i)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let i=[];if(Array.isArray(t)){let r=new Set(t.flat(1/0).reverse());for(let e of r)i.unshift(Y(e))}else t!==void 0&&i.push(Y(t));return i}static _$Eu(t,i){let r=i.attribute;return r===!1?void 0:typeof r=="string"?r:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,i=this.constructor.elementProperties;for(let r of i.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ut(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,i,r){this._$AK(t,r)}_$ET(t,i){let r=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,r);if(e!==void 0&&r.reflect===!0){let n=(r.converter?.toAttribute!==void 0?r.converter:J).toAttribute(i,r.type);this._$Em=t,n==null?this.removeAttribute(e):this.setAttribute(e,n),this._$Em=null}}_$AK(t,i){let r=this.constructor,e=r._$Eh.get(t);if(e!==void 0&&this._$Em!==e){let n=r.getPropertyOptions(e),o=typeof n.converter=="function"?{fromAttribute:n.converter}:n.converter?.fromAttribute!==void 0?n.converter:J;this._$Em=e;let d=o.fromAttribute(i,n.type);this[e]=d??this._$Ej?.get(e)??d,this._$Em=null}}requestUpdate(t,i,r,e=!1,n){if(t!==void 0){let o=this.constructor;if(e===!1&&(n=this[t]),r??=o.getPropertyOptions(t),!((r.hasChanged??mt)(n,i)||r.useDefault&&r.reflect&&n===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,r))))return;this.C(t,i,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,i,{useDefault:r,reflect:e,wrapped:n},o){r&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??i??this[t]),n!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||r||(i=void 0),this._$AL.set(t,i)),e===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(i){Promise.reject(i)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,n]of this._$Ep)this[e]=n;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[e,n]of r){let{wrapped:o}=n,d=this[e];o!==!0||this._$AL.has(e)||d===void 0||this.C(e,void 0,n,d)}}let t=!1,i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(i)):this._$EM()}catch(r){throw t=!1,this._$EM(),r}t&&this._$AE(i)}willUpdate(t){}_$AE(t){this._$EO?.forEach(i=>i.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(i=>this._$ET(i,this[i])),this._$EM()}updated(t){}firstUpdated(t){}};_.elementStyles=[],_.shadowRootOptions={mode:"open"},_[L("elementProperties")]=new Map,_[L("finalized")]=new Map,Bt?.({ReactiveElement:_}),(V.reactiveElementVersions??=[]).push("2.1.2");var rt=globalThis,bt=s=>s,W=rt.trustedTypes,vt=W?W.createPolicy("lit-html",{createHTML:s=>s}):void 0,St="$lit$",S=`lit$${Math.random().toFixed(9).slice(2)}$`,At="?"+S,Vt=`<${At}>`,M=document,D=()=>M.createComment(""),N=s=>s===null||typeof s!="object"&&typeof s!="function",nt=Array.isArray,Wt=s=>nt(s)||typeof s?.[Symbol.iterator]=="function",G=`[
+\f\r]`,O=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,xt=/-->/g,$t=/>/g,E=RegExp(`>|${G}(?:([^\\s"'>=/]+)(${G}*=${G}*(?:[^
+\f\r"'\`<>=]|("|')|))|$)`,"g"),yt=/'/g,wt=/"/g,Et=/^(?:script|style|textarea|title)$/i,st=s=>(t,...i)=>({_$litType$:s,strings:t,values:i}),v=st(1),A=st(2),Xt=st(3),T=Symbol.for("lit-noChange"),u=Symbol.for("lit-nothing"),_t=new WeakMap,k=M.createTreeWalker(M,129);function kt(s,t){if(!nt(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return vt!==void 0?vt.createHTML(t):t}var qt=(s,t)=>{let i=s.length-1,r=[],e,n=t===2?"":t===3?"":t===3?"":"")),r]},U=class s{constructor({strings:t,_$litType$:i},r){let e;this.parts=[];let n=0,o=0,d=t.length-1,l=this.parts,[h,p]=qt(t,i);if(this.el=s.createElement(h,r),k.currentNode=this.el.content,i===2||i===3){let c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(e=k.nextNode())!==null&&l.length0){e.textContent=W?W.emptyScript:"";for(let m=0;m2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=u}_$AI(t,i=this,r,e){let n=this.strings,o=!1;if(n===void 0)t=H(this,t,i,0),o=!N(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else{let d=t,l,h;for(t=n[0],l=0;l{let r=i?.renderBefore??t,e=r._$litPart$;if(e===void 0){let n=i?.renderBefore??null;r._$litPart$=e=new I(t.insertBefore(D(),n),n,void 0,i??{})}return e._$AI(s),e};var ot=globalThis,$=class extends _{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Mt(i,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return T}};$._$litElement$=!0,$.finalized=!0,ot.litElementHydrateSupport?.({LitElement:$});var Ft=ot.litElementPolyfillSupport;Ft?.({LitElement:$});(ot.litElementVersions??=[]).push("4.2.2");var q=w`
:host {
--nf-text: var(--primary-text-color, #e1e1e1);
--nf-muted: var(--secondary-text-color, #9b9b9b);
@@ -29,7 +29,7 @@ var B=globalThis,j=B.ShadowRoot&&(B.ShadyCSS===void 0||B.ShadyCSS.nativeShadow)&
font-family: var(--nf-font);
color: var(--nf-text);
}
-`,ce=y`
+`,pe=w`
:host([readable]) {
--secondary-text-color: var(--primary-text-color, #e1e1e1);
--divider-color: color-mix(in srgb, var(--primary-text-color, #e1e1e1) 40%, transparent);
@@ -40,7 +40,7 @@ var B=globalThis,j=B.ShadowRoot&&(B.ShadyCSS===void 0||B.ShadyCSS.nativeShadow)&
:host([readable]) .nf-overlay {
zoom: 1.2;
}
-`,de=y`
+`,ue=w`
/* a group of switches: one rounded pill, the active one tinted with the accent */
.nf-seg {
display: inline-flex;
@@ -203,12 +203,12 @@ var B=globalThis,j=B.ShadowRoot&&(B.ShadyCSS===void 0||B.ShadyCSS.nativeShadow)&
min-height: 40px;
}
}
-`;var kt={auto:"Automatisch",raw:"Rohdaten",minute:"1 Minute","5minutes":"5 Minuten","15minutes":"15 Minuten",hour:"Stunde",day:"Tag",week:"Woche",month:"Monat",year:"Jahr"};function Mt(s,t){let i=new Set;return t.flatMap(r=>{let e=String(s?.states[r]?.attributes.symcon_source_entity||r),n=s?.states[e]?.attributes,o=Number(n?.symcon_id);return!o||!n?.symcon_archive||i.has(o)?[]:(i.add(o),[e])})}function st(s){if(!Number.isFinite(s))return"";let t=new Date(s*1e3);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function Tt(s,t,i,r){let e=c=>c.trim()&&Number.isFinite(Number(c.replace(",",".")))?Number(c.replace(",",".")):null,n=e(t),o=e(i),h=n??s.reduce((c,p)=>Math.min(c,p),r||!s.length?0:1/0),a=o??s.reduce((c,p)=>Math.max(c,p),r?0:s.length?-1/0:1);if(h===a&&(n===null&&!r&&(h-=Math.max(1,Math.abs(h)*.05)),o===null&&(a+=Math.max(1,Math.abs(a)*.05))),h>=a)throw new Error("Der untere Wertebereich muss kleiner als der obere sein.");return[h,a]}function Ct(s,t){let i=r=>{let e=String(r??"");return`"${/^[=+@\-\t\r]/.test(e)?"'":""}${e.replaceAll('"','""')}"`};return"\uFEFF"+[["Variable","Zeit","Wert","Minimum","Maximum"].join(";"),...s.flatMap(r=>r.points.map(e=>[t[r.entity_id]||r.entity_id,new Date(e.t*1e3).toISOString(),e.v,e.min??"",e.max??""].map(i).join(";")))].join(`\r
-`)}var ot=class extends x{static properties={text:{attribute:!1}};constructor(){super(),this.text=""}get dialog(){return this.renderRoot.querySelector("dialog")}render(){return g`this.dialog?.showModal()}>ⓘ
+`;var Tt={auto:"Automatisch",raw:"Rohdaten",minute:"1 Minute","5minutes":"5 Minuten","15minutes":"15 Minuten",hour:"Stunde",day:"Tag",week:"Woche",month:"Monat",year:"Jahr"};function zt(s,t){let i=new Set;return t.flatMap(r=>{let e=String(s?.states[r]?.attributes.symcon_source_entity||r),n=s?.states[e]?.attributes,o=Number(n?.symcon_id);return!o||!n?.symcon_archive||i.has(o)?[]:(i.add(o),[e])})}function at(s){if(!Number.isFinite(s))return"";let t=new Date(s*1e3);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}T${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function Ct(s,t,i,r){let e=h=>h.trim()&&Number.isFinite(Number(h.replace(",",".")))?Number(h.replace(",",".")):null,n=e(t),o=e(i),d=n??s.reduce((h,p)=>Math.min(h,p),r||!s.length?0:1/0),l=o??s.reduce((h,p)=>Math.max(h,p),r?0:s.length?-1/0:1);if(d===l&&(n===null&&!r&&(d-=Math.max(1,Math.abs(d)*.05)),o===null&&(l+=Math.max(1,Math.abs(l)*.05))),d>=l)throw new Error("Der untere Wertebereich muss kleiner als der obere sein.");return[d,l]}function Ht(s,t){let i=r=>{let e=String(r??"");return`"${/^[=+@\-\t\r]/.test(e)?"'":""}${e.replaceAll('"','""')}"`};return"\uFEFF"+[["Variable","Zeit","Wert","Minimum","Maximum"].join(";"),...s.flatMap(r=>r.points.map(e=>[t[r.entity_id]||r.entity_id,new Date(e.t*1e3).toISOString(),e.v,e.min??"",e.max??""].map(i).join(";")))].join(`\r
+`)}var lt=class extends ${static properties={text:{attribute:!1}};constructor(){super(),this.text=""}get dialog(){return this.renderRoot.querySelector("dialog")}render(){return v`this.dialog?.showModal()}>ⓘ
`}static styles=[q,y`
+ `}static styles=[q,w`
:host { display:inline-block; margin:4px 0; vertical-align:middle; }
button { font:inherit; cursor:pointer; color:var(--nf-muted); background:transparent; border:1px solid var(--nf-line); border-radius:50%; pointer-events:auto; }
.info { width:26px; height:26px; padding:0; font-size:18px; line-height:24px; }
@@ -219,45 +219,114 @@ var B=globalThis,j=B.ShadowRoot&&(B.ShadyCSS===void 0||B.ShadyCSS.nativeShadow)&
header { display:flex; align-items:center; justify-content:space-between; gap:20px; font-size:16px; }
.close { width:30px; height:30px; padding:0; font-size:23px; }
p { white-space:pre-wrap; overflow-wrap:anywhere; margin:16px 0 4px; }
- `]};customElements.get("nf-help-popup")||customElements.define("nf-help-popup",ot);var zt=["#4ec9ff","#ffbe69","#ae9bff","#72deb0","#ff87aa","#ebde72"],C=(s,t)=>String(s.states[t]?.attributes.friendly_name||t),Pt=s=>({variable_not_logged:"Die Variable wird nicht mehr geloggt.",trend_range_too_large_for_resolution:"Bitte f\xFCr diesen Zeitraum eine gr\xF6bere Aufl\xF6sung w\xE4hlen.",invalid_trend_range:"Bitte einen g\xFCltigen Zeitraum w\xE4hlen."})[String(s instanceof Error?s.message:s)]||String(s instanceof Error?s.message:s),at=class extends x{static properties={hass:{attribute:!1},ids:{attribute:!1},label:{attribute:!1},from:{state:!0},to:{state:!0},resolution:{state:!0},chartStyle:{state:!0},field:{state:!0},min:{state:!0},max:{state:!0},zero:{state:!0},band:{state:!0},live:{state:!0},series:{state:!0},hiddenSeries:{state:!0},loading:{state:!0},errors:{state:!0},hover:{state:!0},width:{state:!0},page:{state:!0}};request=0;drag=null;timer;observer;constructor(){super(),this.ids=[],this.label="",this.to=Math.floor(Date.now()/1e3),this.from=this.to-86400,this.resolution="auto",this.chartStyle="auto",this.field="v",this.min="",this.max="",this.zero=!1,this.band=!0,this.live=!1,this.series=[],this.hiddenSeries=new Set,this.loading=!1,this.errors=[],this.hover=null,this.width=900,this.page=0}async open(){await this.updateComplete,this.renderRoot.querySelector("dialog").showModal(),this.observer=new ResizeObserver(([t])=>{this.width=Math.max(280,Math.floor(t.contentRect.width))}),this.observer.observe(this.renderRoot.querySelector(".body")),this.timer=setInterval(()=>{if(this.live&&!this.loading){let t=this.to-this.from;this.to=Math.floor(Date.now()/1e3),this.from=this.to-t,this.load()}},3e4),await this.load()}disconnectedCallback(){super.disconnectedCallback(),++this.request,clearInterval(this.timer),this.observer?.disconnect()}async load(){let t=++this.request,i=this.from,r=this.to;if(this.errors=[],this.series=[],this.hover=null,this.page=0,!Number.isSafeInteger(i)||!Number.isSafeInteger(r)||i<1||r<=i){this.errors=["Das Ende muss nach dem Beginn des Zeitraums liegen."],this.loading=!1;return}this.loading=!0;let e=[],n=[];for(let o=0;othis.hass.callWS({type:"nextfloor/archive/trend",entity_id:c,start:i,end:r,aggregation:this.resolution})))).forEach((c,p)=>c.status==="fulfilled"?e.push(c.value):n.push(`${C(this.hass,h[p])}: ${Pt(c.reason)}`))}t!==this.request||!this.isConnected||(this.series=e,this.errors=n,this.loading=!1)}range(t,i){this.from=Math.max(1,Math.floor(t)),this.to=Math.max(this.from+1,Math.floor(i)),this.live=!1,this.load()}zoom(t,i=.5){let r=Math.max(60,Math.min(315576e3,(this.to-this.from)*t)),e=this.from+(this.to-this.from)*i;this.range(e-r*i,e+r*(1-i))}stamp(t){return new Date(t*1e3).toLocaleString(this.hass.language,{dateStyle:"short",timeStyle:"medium"})}number(t){return t.toLocaleString(this.hass.language,{maximumFractionDigits:Math.abs(t)<.01&&t!==0?5:2})}unit(t){return String(this.hass.states[t]?.attributes.unit_of_measurement??"")}selected(){return this.series.filter(t=>!this.hiddenSeries.has(t.entity_id))}value(t){let i=this.field==="v"?t.v:t[this.field]??t.v;return typeof i=="number"&&Number.isFinite(i)?i:null}color(t){return zt[this.ids.indexOf(t)%zt.length]}ratio(t){let i=t.currentTarget.getBoundingClientRect();return Math.max(0,Math.min(1,((t.clientX-i.left)/i.width*this.width-64)/(this.width-80)))}exportCsv(){let t=Object.fromEntries(this.ids.map(e=>[e,String(this.hass.states[e]?.attributes.symcon_path||C(this.hass,e))])),i=URL.createObjectURL(new Blob([Ct(this.selected(),t)],{type:"text/csv;charset=utf-8"})),r=document.createElement("a");r.href=i,r.download="Symcon-Trend.csv",r.click(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}plot(t,i){let r=t.flatMap(l=>l.points.flatMap(f=>{let m=this.value(f);return m===null?[]:this.band&&!l.counter?[m,f.min??m,f.max??m]:[m]}));if(!r.length)return g`Keine numerischen Archivwerte in diesem Zeitraum.
`;let e,n;try{[e,n]=Tt(r,this.min,this.max,this.zero||this.chartStyle==="bar"||t.some(l=>l.type===0)||this.chartStyle==="auto"&&t.some(l=>l.counter&&l.aggregation!=="raw"))}catch(l){return g`${Pt(l)}
`}let o=64,h=this.width-16,a=14,c=220,p=l=>o+(l-this.from)/(this.to-this.from)*(h-o),d=l=>c-(l-e)/(n-e)*(c-a),v=(l,f=this.field)=>Number(f==="v"?l.v:l[f]??l.v),$=(l,f=this.field)=>{let m=l.points.filter(z=>typeof z.v=="number"),b=this.chartStyle==="step"||this.chartStyle==="auto"&&l.type===0;return m.map((z,lt)=>`${lt?b?`H${p(z.t).toFixed(1)}V`:"L":"M"}${b&<?d(v(z,f)).toFixed(1):`${p(z.t).toFixed(1)},${d(v(z,f)).toFixed(1)}`}`).join("")+(m.length?b?`H${h}`:l.aggregation==="raw"?`L${h},${d(v(m[m.length-1],f)).toFixed(1)}`:"":"")},w=this.width<480?2:5;return g`${i||"Wert"}
{l.preventDefault(),this.zoom(l.deltaY>0?1.5:1/1.5,this.ratio(l))}}
- @pointerdown=${l=>{this.drag=this.ratio(l),l.currentTarget.setPointerCapture(l.pointerId)}}
- @pointerup=${l=>{if(this.drag===null)return;let f=this.drag,m=this.ratio(l);if(this.drag=null,Math.abs(f-m)>.02){let b=this.to-this.from;this.range(this.from+b*Math.min(f,m),this.from+b*Math.max(f,m))}}}
- @pointercancel=${()=>{this.drag=null}} @pointermove=${l=>{this.hover=this.from+(this.to-this.from)*this.ratio(l)}}>
-
- ${[0,1,2,3,4].map(l=>{let f=e+(n-e)*l/4;return A`${this.number(f)}`})}
- ${Array.from({length:w},(l,f)=>{let m=this.from+(this.to-this.from)*f/(w-1);return A`${new Date(m*1e3).toLocaleString(this.hass.language,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}`})}
- ${t.map(l=>{let f=this.chartStyle==="bar"||this.chartStyle==="auto"&&l.counter&&l.aggregation!=="raw",m=this.color(l.entity_id);return f?l.points.filter(b=>this.value(b)!==null).map(b=>A``):A`${this.band&&l.aggregation!=="raw"&&!l.counter?A``:u}${l.points.length===1?A``:u}`})}${this.hover!==null?A``:u}
- `}table(t){let i=t.flatMap(n=>n.points.map(o=>({id:n.entity_id,...o}))).sort((n,o)=>o.t-n.t),r=Math.max(1,Math.ceil(i.length/100)),e=Math.min(this.page,r-1);return g`| Zeit | Variable | Wert |
${i.slice(e*100,(e+1)*100).map(n=>g`| ${this.stamp(n.t)} | ${C(this.hass,n.id)} | ${typeof n.v=="number"?this.number(n.v):n.v} ${this.unit(n.id)} |
`)}
{this.page=e-1}}>Zurück${e+1} / ${r}=r-1} @click=${()=>{this.page=e+1}}>Weiter
`}render(){let t=this.selected(),i=t.length>0&&t.every(e=>e.type===3),r=this.hover===null?"Letzter Wert":this.stamp(this.hover);return g`