fix: support Symcon numeric dimmers and independent blind slat controls

This commit is contained in:
jhartworks committed 2026-11-09 15:24:59 +01:00
1 parent 6050bb7c88
commit d7d7435e96
7 files changed
+443 -337

No files matched your search

+1 -1
View File
@@ -4296,7 +4296,7 @@ vNfTile = tile;`,xR=`#ifdef USE_MAP
vec4 sampledDiffuseColor = textureGrad(map, nfUv, dFdx(vMapUv) / vec2(3.0, 2.0), dFdy(vMapUv) / vec2(3.0, 2.0));
diffuseColor *= sampledDiffuseColor;
#endif`;function bR(i){let e=new Ke({map:i,transparent:!0,blending:Ft,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-2});return e.onBeforeCompile=t=>{t.vertexShader=t.vertexShader.replace("#include <common>",mR).replace("#include <begin_vertex>",gR),t.fragmentShader=t.fragmentShader.replace("#include <common>",`#include <common>
varying vec2 vNfTile;`).replace("#include <map_fragment>",xR)},e.customProgramCacheKey=()=>"nf-pattern",e}var qu=(i={})=>new Ke({vertexColors:!0,transparent:!0,blending:Ft,depthWrite:!1,...i});function Ty({mask:i,look:e,theme:t,textures:n}){let r=(o={})=>new Ke({vertexColors:!0,...o}),s=(o,a)=>My(o,i,a);return{floor:Zn(r(),e),pattern:bR(n.pattern),wall:Zn(s(r(),"solid"),e),glassWall:s(r({transparent:!0,depthWrite:!1}),"glass"),shadow:r({blending:za,premultipliedAlpha:!0,transparent:!0,depthWrite:!1,side:ut,polygonOffset:!0,polygonOffsetFactor:-1}),lines:Zn(s(new Lt({vertexColors:!0,transparent:!0,blending:xl(t),depthWrite:!1})),e,!0),glow:s(qu({side:ut,polygonOffset:!0,polygonOffsetFactor:-3}),"solid"),frames:Zn(s(r({side:ut})),e),glass:s(qu({side:ut})),blinds:Zn(s(r({map:n.blinds,side:ut})),e),lamps:Zn(r(),e),halos:new cn({map:n.halo,size:.9,sizeAttenuation:!0,vertexColors:!0,transparent:!0,blending:Ft,depthWrite:!1}),cones:qu({side:ut}),screens:qu({side:ut}),ghosts:[]}}var $u=i=>Object.assign(document.createElement("span"),{className:i});function Ay(i,e){let t=Object.assign(document.createElement("button"),{className:"nf-dev"});t.dataset.entity=i,t.append($u("nf-dev-icon"),$u("nf-dev-text"),$u("nf-dev-watt"),$u("nf-dev-name"));let n,r=!1,s=a=>{let{x:l,y:c}=e.centre(t);a(i,l,c)},o=()=>clearTimeout(n);t.addEventListener("pointerdown",a=>{if(e.furnishing())return e.pressedWhileFurnishing(i);a.stopPropagation(),r=!1,o(),n=setTimeout(()=>{r=!0,s(e.hold)},500)});for(let a of["pointerleave","pointercancel","pointerup"])t.addEventListener(a,o);return t.addEventListener("contextmenu",a=>a.preventDefault()),t.addEventListener("click",a=>{if(a.stopPropagation(),e.furnishing())return e.selectWhileFurnishing(i);r||s(e.tap)}),t.addEventListener("keydown",a=>{(a.key==="Enter"&&a.shiftKey||a.key==="ContextMenu")&&(a.preventDefault(),s(e.hold))}),t}function Ey(i,e=10,t="NextFloor"){let n=[];for(let{positions:o,lift:a}of i)for(let l=0;l+8<o.length;l+=9){let c=[0,3,6].map(x=>[o[l+x]*e,-o[l+x+2]*e,(o[l+x+1]+a)*e]),[u,h,f]=c,d=[(h[1]-u[1])*(f[2]-u[2])-(h[2]-u[2])*(f[1]-u[1]),(h[2]-u[2])*(f[0]-u[0])-(h[0]-u[0])*(f[2]-u[2]),(h[0]-u[0])*(f[1]-u[1])-(h[1]-u[1])*(f[0]-u[0])],p=Math.hypot(d[0],d[1],d[2]);p<1e-9||n.push([d[0]/p,d[1]/p,d[2]/p,...u,...h,...f])}let r=new Uint8Array(84+n.length*50),s=new DataView(r.buffer);return r.set(new TextEncoder().encode(`${t} STL`.slice(0,79)),0),s.setUint32(80,n.length,!0),n.forEach((o,a)=>{let l=84+a*50;o.forEach((c,u)=>s.setFloat32(l+u*4,c,!0))}),r}var Rs=Math.PI/180;function Ry(i,e,t){let n=i.getTime()/864e5-10957.5,r=(357.529+.98560028*n)*Rs,o=(280.459+.98564736*n+1.915*Math.sin(r)+.02*Math.sin(2*r))*Rs,a=(23.439-36e-8*n)*Rs,l=Math.atan2(Math.cos(a)*Math.sin(o),Math.cos(o)),c=Math.asin(Math.sin(a)*Math.sin(o)),h=(((18.697374558+24.06570982441908*n)%24+24)%24*15+t)*Rs-l,f=e*Rs,d=Math.asin(Math.sin(f)*Math.sin(c)+Math.cos(f)*Math.cos(c)*Math.cos(h)),p=Math.atan2(Math.sin(h),Math.cos(h)*Math.sin(f)-Math.tan(c)*Math.cos(f))/Rs+180;return{elevation:d/Rs,azimuth:(p%360+360)%360}}function fp(i,e){let t=Object.fromEntries(new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}).formatToParts(new Date(i)).map(n=>[n.type,Number(n.value)]));return Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second)}function Cy(i,e,t=new Date){let[n,r]=[Math.floor(i),Math.round(i%1*60)];if(e)try{let o=new Date(fp(t.getTime(),e)),a=Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),n,r),l=a-(fp(a,e)-a);return l=a-(fp(l,e)-l),new Date(l)}catch{}let s=new Date(t);return s.setHours(n,r,0,0),s}function yR(i,e=new Date){let t=[];for(let n=0;n<=24;n+=.25){let r=Ry(Cy(Math.min(n,23.99),i.zone,e),i.latitude,i.longitude);r.elevation<0||t.push(Py(i,r))}return t}function Py(i,e){let[t,n]=Lo(e.azimuth,i.north),r=Math.max(0,e.elevation)*Math.PI/180;return[i.centre[0]+t*i.radius*Math.cos(r),Math.sin(r)*i.radius*.9,i.centre[1]+n*i.radius*Math.cos(r)]}function _R(i,e){let t=document.createElement("canvas");t.width=t.height=64;let n=t.getContext("2d");n&&(n.font="bold 44px system-ui, sans-serif",n.fillStyle=e,n.textAlign="center",n.textBaseline="middle",n.fillText(i,32,34));let r=new ji(new vi({map:new zt(t),transparent:!0,depthWrite:!1,depthTest:!1}));return r.renderOrder=20,r}var Ku=class{group=new ct;key="";constructor(){this.group.visible=!1,this.group.renderOrder=15}update(e,t,n){let r=e?`${e.centre},${e.radius.toFixed(1)},${e.north},${e.latitude.toFixed(2)},${e.longitude.toFixed(2)},${new Date().toDateString()},${n},${t?`${t.elevation.toFixed(0)},${t.azimuth.toFixed(0)}`:"-"}`:"off";if(r===this.key)return;if(this.key=r,this.clear(),!e){this.group.visible=!1;return}this.group.visible=!0;let s=n+.05,o=[];for(let h=0;h<=96;h++){let f=h/96*Math.PI*2;o.push(e.centre[0]+Math.cos(f)*e.radius,s,e.centre[1]+Math.sin(f)*e.radius)}let a=new Fe;a.setAttribute("position",new ke(o,3)),this.group.add(new Pn(a,new Lt({color:7311304,tra Line truncated
varying vec2 vNfTile;`).replace("#include <map_fragment>",xR)},e.customProgramCacheKey=()=>"nf-pattern",e}var qu=(i={})=>new Ke({vertexColors:!0,transparent:!0,blending:Ft,depthWrite:!1,...i});function Ty({mask:i,look:e,theme:t,textures:n}){let r=(o={})=>new Ke({vertexColors:!0,...o}),s=(o,a)=>My(o,i,a);return{floor:Zn(r(),e),pattern:bR(n.pattern),wall:Zn(s(r(),"solid"),e),glassWall:s(r({transparent:!0,depthWrite:!1}),"glass"),shadow:r({blending:za,premultipliedAlpha:!0,transparent:!0,depthWrite:!1,side:ut,polygonOffset:!0,polygonOffsetFactor:-1}),lines:Zn(s(new Lt({vertexColors:!0,transparent:!0,blending:xl(t),depthWrite:!1})),e,!0),glow:s(qu({side:ut,polygonOffset:!0,polygonOffsetFactor:-3}),"solid"),frames:Zn(s(r({side:ut})),e),glass:s(qu({side:ut})),blinds:Zn(s(r({map:n.blinds,side:ut})),e),lamps:Zn(r(),e),halos:new cn({map:n.halo,size:.9,sizeAttenuation:!0,vertexColors:!0,transparent:!0,blending:Ft,depthWrite:!1}),cones:qu({side:ut}),screens:qu({side:ut}),ghosts:[]}}var $u=i=>Object.assign(document.createElement("span"),{className:i});function Ay(i,e){let t=Object.assign(document.createElement("button"),{className:"nf-dev"});t.dataset.entity=i,t.append($u("nf-dev-icon"),$u("nf-dev-text"),$u("nf-dev-watt"),$u("nf-dev-name"));let n,r=!1,s=a=>{let{x:l,y:c}=e.centre(t);a(i,l,c)},o=()=>clearTimeout(n);t.addEventListener("pointerdown",a=>{if(e.furnishing())return e.pressedWhileFurnishing(i);a.stopPropagation(),r=!1,o(),n=setTimeout(()=>{r=!0,s(e.hold)},500)});for(let a of["pointerleave","pointercancel","pointerup"])t.addEventListener(a,o);return t.addEventListener("contextmenu",a=>a.preventDefault()),t.addEventListener("click",a=>{if(a.stopPropagation(),e.furnishing())return e.selectWhileFurnishing(i);r||s(e.tap)}),t.addEventListener("keydown",a=>{(a.key==="Enter"&&a.shiftKey||a.key==="ContextMenu")&&(a.preventDefault(),s(e.hold))}),t}function Ey(i,e=10,t="NextFloor"){let n=[];for(let{positions:o,lift:a}of i)for(let l=0;l+8<o.length;l+=9){let c=[0,3,6].map(x=>[o[l+x]*e,-o[l+x+2]*e,(o[l+x+1]+a)*e]),[u,h,f]=c,d=[(h[1]-u[1])*(f[2]-u[2])-(h[2]-u[2])*(f[1]-u[1]),(h[2]-u[2])*(f[0]-u[0])-(h[0]-u[0])*(f[2]-u[2]),(h[0]-u[0])*(f[1]-u[1])-(h[1]-u[1])*(f[0]-u[0])],p=Math.hypot(d[0],d[1],d[2]);p<1e-9||n.push([d[0]/p,d[1]/p,d[2]/p,...u,...h,...f])}let r=new Uint8Array(84+n.length*50),s=new DataView(r.buffer);return r.set(new TextEncoder().encode(`${t} STL`.slice(0,79)),0),s.setUint32(80,n.length,!0),n.forEach((o,a)=>{let l=84+a*50;o.forEach((c,u)=>s.setFloat32(l+u*4,c,!0))}),r}var Rs=Math.PI/180;function Ry(i,e,t){let n=i.getTime()/864e5-10957.5,r=(357.529+.98560028*n)*Rs,o=(280.459+.98564736*n+1.915*Math.sin(r)+.02*Math.sin(2*r))*Rs,a=(23.439-36e-8*n)*Rs,l=Math.atan2(Math.cos(a)*Math.sin(o),Math.cos(o)),c=Math.asin(Math.sin(a)*Math.sin(o)),h=(((18.697374558+24.06570982441908*n)%24+24)%24*15+t)*Rs-l,f=e*Rs,d=Math.asin(Math.sin(f)*Math.sin(c)+Math.cos(f)*Math.cos(c)*Math.cos(h)),p=Math.atan2(Math.sin(h),Math.cos(h)*Math.sin(f)-Math.tan(c)*Math.cos(f))/Rs+180;return{elevation:d/Rs,azimuth:(p%360+360)%360}}function fp(i,e){let t=Object.fromEntries(new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}).formatToParts(new Date(i)).map(n=>[n.type,Number(n.value)]));return Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second)}function Cy(i,e,t=new Date){let[n,r]=[Math.floor(i),Math.round(i%1*60)];if(e)try{let o=new Date(fp(t.getTime(),e)),a=Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),n,r),l=a-(fp(a,e)-a);return l=a-(fp(l,e)-l),new Date(l)}catch{}let s=new Date(t);return s.setHours(n,r,0,0),s}function yR(i,e=new Date){let t=[];for(let n=0;n<=24;n+=.25){let r=Ry(Cy(Math.min(n,23.99),i.zone,e),i.latitude,i.longitude);r.elevation<0||t.push(Py(i,r))}return t}function Py(i,e){let[t,n]=Lo(e.azimuth,i.north),r=Math.max(0,e.elevation)*Math.PI/180;return[i.centre[0]+t*i.radius*Math.cos(r),Math.sin(r)*i.radius*.9,i.centre[1]+n*i.radius*Math.cos(r)]}function _R(i,e){let t=document.createElement("canvas");t.width=t.height=64;let n=t.getContext("2d");n&&(n.font="bold 44px system-ui, sans-serif",n.fillStyle=e,n.textAlign="center",n.textBaseline="middle",n.fillText(i,32,34));let r=new ji(new vi({map:new zt(t),transparent:!0,depthWrite:!1,depthTest:!1}));return r.renderOrder=20,r}var Ku=class{group=new ct;key="";constructor(){this.group.visible=!1,this.group.renderOrder=15}update(e,t,n){let r=e?`${e.centre},${e.radius.toFixed(1)},${e.north},${e.latitude.toFixed(2)},${e.longitude.toFixed(2)},${new Date().toDateString()},${n},${t?`${t.elevation.toFixed(0)},${t.azimuth.toFixed(0)}`:"-"}`:"off";if(r===this.key)return;if(this.key=r,this.clear(),!e){this.group.visible=!1;return}this.group.visible=!0;let s=n+.05,o=[];for(let h=0;h<=96;h++){let f=h/96*Math.PI*2;o.push(e.centre[0]+Math.cos(f)*e.radius,s,e.centre[1]+Math.sin(f)*e.radius)}let a=new Fe;a.setAttribute("position",new ke(o,3)),this.group.add(new Pn(a,new Lt({color:7311304,tra Line truncated
/*! Bundled license information:
three/build/three.core.js:
+155 -154
View File
@@ -1,13 +1,13 @@
/*! NextFloor, MIT licence. Includes three.js (MIT) and Lit (BSD-3-Clause); see LICENSE and THIRD_PARTY_NOTICES.md */
var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",fr:"6312d0f61ebf",hu:"27ba348531dc",it:"1b705e76dd00",nb:"c5ea24fb9ef6",nl:"b64142c67c2e",pl:"8527a4930402",pt:"31857a2d2277",ro:"e3cb5f449f0f",sk:"320611594db0",sl:"8071691ceda3",sv:"711b911ec8da",tr:"7c83ce1c3372",zh:"50518d9f494e"};Array.prototype.at||Object.defineProperty(Array.prototype,"at",{configurable:!0,writable:!0,value:function(e){let t=Math.trunc(e)||0;return this[t<0?this.length+t:t]}});typeof globalThis.structuredClone!="function"&&(globalThis.structuredClone=r=>r===void 0?r:JSON.parse(JSON.stringify(r)));var kn=globalThis,xn=kn.ShadowRoot&&(kn.ShadyCSS===void 0||kn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Hr=Symbol(),vi=new WeakMap,Ht=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==Hr)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(xn&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=vi.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&vi.set(t,e))}return e}toString(){return this.cssText}},yi=r=>new Ht(typeof r=="string"?r:r+"",void 0,Hr),te=(r,...e)=>{let t=r.length===1?r[0]:e.reduce((n,o,i)=>n+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+r[i+1],r[0]);return new Ht(t,r,Hr)},ki=(r,e)=>{if(xn)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let n=document.createElement("style"),o=kn.litNonce;o!==void 0&&n.setAttribute("nonce",o),n.textContent=t.cssText,r.appendChild(n)}},Ir=xn?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(let n of e.cssRules)t+=n.cssText;return yi(t)})(r):r;var{is:Yc,defineProperty:Jc,getOwnPropertyDescriptor:Qc,getOwnPropertyNames:Xc,getOwnPropertySymbols:eu,getPrototypeOf:tu}=Object,Sn=globalThis,xi=Sn.trustedTypes,nu=xi?xi.emptyScript:"",ru=Sn.reactiveElementPolyfillSupport,It=(r,e)=>r,Cr={toAttribute(r,e){switch(e){case Boolean:r=r?nu:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},Mi=(r,e)=>!Yc(r,e),Si={attribute:!0,type:String,converter:Cr,reflect:!1,useDefault:!1,hasChanged:Mi};Symbol.metadata??=Symbol("metadata"),Sn.litPropertyMetadata??=new WeakMap;var $e=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Si){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),o=this.getPropertyDescriptor(e,n,t);o!==void 0&&Jc(this.prototype,e,o)}}static getPropertyDescriptor(e,t,n){let{get:o,set:i}=Qc(this.prototype,e)??{get(){return this[t]},set(s){this[t]=s}};return{get:o,set(s){let a=o?.call(this);i?.call(this,s),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Si}static _$Ei(){if(this.hasOwnProperty(It("elementProperties")))return;let e=tu(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(It("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(It("properties"))){let t=this.properties,n=[...Xc(t),...eu(t)];for(let o of n)this.createProperty(o,t[o])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[n,o]of t)this.elementProperties.set(n,o)}this._$Eh=new Map;for(let[t,n]of this.elementProperties){let o=this._$Eu(t,n);o!==void 0&&this._$Eh.set(o,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let o of n)t.unshift(Ir(o))}else e!==void 0&&t.push(Ir(e));return t}static _$Eu(e,t){let n=t.attribute;return n===!1?void 0:typeof n=="string"?n:typeof e=="string"?e.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(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shaLine truncated
\f\r]`,Ct=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ei=/-->/g,Ri=/>/g,qe=RegExp(`>|${Nr}(?:([^\\s"'>=/]+)(${Nr}*=${Nr}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`,"g"),zi=/'/g,Ti=/"/g,Hi=/^(?:script|style|textarea|title)$/i,Ur=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),m=Ur(1),J=Ur(2),Nm=Ur(3),Je=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),Fi=new WeakMap,Ze=Ye.createTreeWalker(Ye,129);function Ii(r,e){if(!Gr(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ai!==void 0?Ai.createHTML(e):e}var su=(r,e)=>{let t=r.length-1,n=[],o,i=e===2?"<svg>":e===3?"<math>":"",s=Ct;for(let a=0;a<t;a++){let l=r[a],c,u,d=-1,p=0;for(;p<l.length&&(s.lastIndex=p,u=s.exec(l),u!==null);)p=s.lastIndex,s===Ct?u[1]==="!--"?s=Ei:u[1]!==void 0?s=Ri:u[2]!==void 0?(Hi.test(u[2])&&(o=RegExp("</"+u[2],"g")),s=qe):u[3]!==void 0&&(s=qe):s===qe?u[0]===">"?(s=o??Ct,d=-1):u[1]===void 0?d=-2:(d=s.lastIndex-u[2].length,c=u[1],s=u[3]===void 0?qe:u[3]==='"'?Ti:zi):s===Ti||s===zi?s=qe:s===Ei||s===Ri?s=Ct:(s=qe,o=void 0);let h=s===qe&&r[a+1].startsWith("/>")?" ":"";i+=s===Ct?l+ou:d>=0?(n.push(c),l.slice(0,d)+Di+l.slice(d)+Oe+h):l+Oe+(d===-2?a:h)}return[Ii(r,i+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),n]},Wt=class r{constructor({strings:e,_$litType$:t},n){let o;this.parts=[];let i=0,s=0,a=e.length-1,l=this.parts,[c,u]=su(e,t);if(this.el=r.createElement(c,n),Ze.currentNode=this.el.content,t===2||t===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(o=Ze.nextNode())!==null&&l.length<a;){if(o.nodeType===1){if(o.hasAttributes())for(let d of o.getAttributeNames())if(d.endsWith(Di)){let p=u[s++],h=o.getAttribute(d).split(Oe),w=/([.?@])?(.*)/.exec(p);l.push({type:1,index:i,name:w[2],strings:h,ctor:w[1]==="."?Wr:w[1]==="?"?Lr:w[1]==="@"?Br:ut}),o.removeAttribute(d)}else d.startsWith(Oe)&&(l.push({type:6,index:i}),o.removeAttribute(d));if(Hi.test(o.tagName)){let d=o.textContent.split(Oe),p=d.length-1;if(p>0){o.textContent=Mn?Mn.emptyScript:"";for(let h=0;h<p;h++)o.append(d[h],Nt()),Ze.nextNode(),l.push({type:2,index:++i});o.append(d[p],Nt())}}}else if(o.nodeType===8)if(o.data===Pi)l.push({type:2,index:i});else{let d=-1;for(;(d=o.data.indexOf(Oe,d+1))!==-1;)l.push({type:7,index:i}),d+=Oe.length-1}i++}}static createElement(e,t){let n=Ye.createElement("template");return n.innerHTML=e,n}};function ct(r,e,t=r,n){if(e===Je)return e;let o=n!==void 0?t._$Co?.[n]:t._$Cl,i=Ot(e)?void 0:e._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),i===void 0?o=void 0:(o=new i(r),o._$AT(r,t,n)),n!==void 0?(t._$Co??=[])[n]=o:t._$Cl=o),o!==void 0&&(e=ct(r,o._$AS(r,e.values),o,n)),e}var Or=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,o=(e?.creationScope??Ye).importNode(t,!0);Ze.currentNode=o;let i=Ze.nextNode(),s=0,a=0,l=n[0];for(;l!==void 0;){if(s===l.index){let c;l.type===2?c=new Lt(i,i.nextSibling,this,e):l.type===1?c=new l.ctor(i,l.name,l.strings,this,e):l.type===6&&(c=new Vr(i,this,e)),this._$AV.push(c),l=n[++a]}s!==l?.index&&(i=Ze.nextNode(),s++)}return Ze.currentNode=Ye,o}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}},Lt=class r{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,o){this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=o,this._$Cv=o?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=ct(this,e,t),Ot(e)?e===f||e==null||e===""?(this._$AH!==f&&this._$AR(),this._$AH=f):e!==this._$AH&&e!==Je&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):iu(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==f&&Ot(this._$AH)?this._$AA.nextSibling.data=e:this.T(Ye.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,o=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=Wt.createElement(Ii(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===o)this._$AH.p(t);else{let i=new Or(o,this),s=i.u(this.options);i.p(t),this.T(s),this._$AH=i}}_$AC(e){let t=Fi.get(e.strings);return t===void 0&&Fi.set(e.strings,t=new Wt(e)),t}k(e){Gr(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,n,o=0;for(let i of e)o===t.length?t.push(n=new r(this.O(Nt()),this.O(Nt()),this,this.options)):n=t[o],n._$AI(i),o++;o<t.length&&(this._$AR(n&&n._$AB.nextSibling,o),t.length=o)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let n=$i(e).nextSibling;$i(e).remove(),e=n}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},ut=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,o,i){this.type=1,this._$AH=f,this._$AN=void 0,this.element=e,this.name=t,this._$AM=o,this.options=i,n.length>2||n[0]!==""||n[1]!==""?(this._Line truncated
var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",fr:"6312d0f61ebf",hu:"27ba348531dc",it:"1b705e76dd00",nb:"c5ea24fb9ef6",nl:"b64142c67c2e",pl:"8527a4930402",pt:"31857a2d2277",ro:"e3cb5f449f0f",sk:"320611594db0",sl:"8071691ceda3",sv:"711b911ec8da",tr:"7c83ce1c3372",zh:"50518d9f494e"};Array.prototype.at||Object.defineProperty(Array.prototype,"at",{configurable:!0,writable:!0,value:function(e){let t=Math.trunc(e)||0;return this[t<0?this.length+t:t]}});typeof globalThis.structuredClone!="function"&&(globalThis.structuredClone=r=>r===void 0?r:JSON.parse(JSON.stringify(r)));var xn=globalThis,kn=xn.ShadowRoot&&(xn.ShadyCSS===void 0||xn.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Cr=Symbol(),xi=new WeakMap,It=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==Cr)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(kn&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=xi.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&xi.set(t,e))}return e}toString(){return this.cssText}},ki=r=>new It(typeof r=="string"?r:r+"",void 0,Cr),te=(r,...e)=>{let t=r.length===1?r[0]:e.reduce((n,o,i)=>n+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+r[i+1],r[0]);return new It(t,r,Cr)},Si=(r,e)=>{if(kn)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let n=document.createElement("style"),o=xn.litNonce;o!==void 0&&n.setAttribute("nonce",o),n.textContent=t.cssText,r.appendChild(n)}},Nr=kn?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(let n of e.cssRules)t+=n.cssText;return ki(t)})(r):r;var{is:Xc,defineProperty:eu,getOwnPropertyDescriptor:tu,getOwnPropertyNames:nu,getOwnPropertySymbols:ru,getPrototypeOf:ou}=Object,Sn=globalThis,Mi=Sn.trustedTypes,iu=Mi?Mi.emptyScript:"",su=Sn.reactiveElementPolyfillSupport,Ct=(r,e)=>r,Or={toAttribute(r,e){switch(e){case Boolean:r=r?iu:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},Ai=(r,e)=>!Xc(r,e),$i={attribute:!0,type:String,converter:Or,reflect:!1,useDefault:!1,hasChanged:Ai};Symbol.metadata??=Symbol("metadata"),Sn.litPropertyMetadata??=new WeakMap;var $e=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=$i){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),o=this.getPropertyDescriptor(e,n,t);o!==void 0&&eu(this.prototype,e,o)}}static getPropertyDescriptor(e,t,n){let{get:o,set:i}=tu(this.prototype,e)??{get(){return this[t]},set(s){this[t]=s}};return{get:o,set(s){let a=o?.call(this);i?.call(this,s),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??$i}static _$Ei(){if(this.hasOwnProperty(Ct("elementProperties")))return;let e=ou(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Ct("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ct("properties"))){let t=this.properties,n=[...nu(t),...ru(t)];for(let o of n)this.createProperty(o,t[o])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[n,o]of t)this.elementProperties.set(n,o)}this._$Eh=new Map;for(let[t,n]of this.elementProperties){let o=this._$Eu(t,n);o!==void 0&&this._$Eh.set(o,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let o of n)t.unshift(Nr(o))}else e!==void 0&&t.push(Nr(e));return t}static _$Eu(e,t){let n=t.attribute;return n===!1?void 0:typeof n=="string"?n:typeof e=="string"?e.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(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shaLine truncated
\f\r]`,Nt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,zi=/-->/g,Ti=/>/g,Ze=RegExp(`>|${Wr}(?:([^\\s"'>=/]+)(${Wr}*=${Wr}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`,"g"),Fi=/'/g,Di=/"/g,Ci=/^(?:script|style|textarea|title)$/i,qr=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),m=qr(1),J=qr(2),Bm=qr(3),Qe=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),Pi=new WeakMap,Ye=Je.createTreeWalker(Je,129);function Ni(r,e){if(!jr(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ri!==void 0?Ri.createHTML(e):e}var cu=(r,e)=>{let t=r.length-1,n=[],o,i=e===2?"<svg>":e===3?"<math>":"",s=Nt;for(let a=0;a<t;a++){let l=r[a],c,u,d=-1,p=0;for(;p<l.length&&(s.lastIndex=p,u=s.exec(l),u!==null);)p=s.lastIndex,s===Nt?u[1]==="!--"?s=zi:u[1]!==void 0?s=Ti:u[2]!==void 0?(Ci.test(u[2])&&(o=RegExp("</"+u[2],"g")),s=Ze):u[3]!==void 0&&(s=Ze):s===Ze?u[0]===">"?(s=o??Nt,d=-1):u[1]===void 0?d=-2:(d=s.lastIndex-u[2].length,c=u[1],s=u[3]===void 0?Ze:u[3]==='"'?Di:Fi):s===Di||s===Fi?s=Ze:s===zi||s===Ti?s=Nt:(s=Ze,o=void 0);let h=s===Ze&&r[a+1].startsWith("/>")?" ":"";i+=s===Nt?l+au:d>=0?(n.push(c),l.slice(0,d)+Hi+l.slice(d)+Oe+h):l+Oe+(d===-2?a:h)}return[Ni(r,i+(r[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),n]},Lt=class r{constructor({strings:e,_$litType$:t},n){let o;this.parts=[];let i=0,s=0,a=e.length-1,l=this.parts,[c,u]=cu(e,t);if(this.el=r.createElement(c,n),Ye.currentNode=this.el.content,t===2||t===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(o=Ye.nextNode())!==null&&l.length<a;){if(o.nodeType===1){if(o.hasAttributes())for(let d of o.getAttributeNames())if(d.endsWith(Hi)){let p=u[s++],h=o.getAttribute(d).split(Oe),g=/([.?@])?(.*)/.exec(p);l.push({type:1,index:i,name:g[2],strings:h,ctor:g[1]==="."?Br:g[1]==="?"?Vr:g[1]==="@"?Kr:ht}),o.removeAttribute(d)}else d.startsWith(Oe)&&(l.push({type:6,index:i}),o.removeAttribute(d));if(Ci.test(o.tagName)){let d=o.textContent.split(Oe),p=d.length-1;if(p>0){o.textContent=Mn?Mn.emptyScript:"";for(let h=0;h<p;h++)o.append(d[h],Ot()),Ye.nextNode(),l.push({type:2,index:++i});o.append(d[p],Ot())}}}else if(o.nodeType===8)if(o.data===Ii)l.push({type:2,index:i});else{let d=-1;for(;(d=o.data.indexOf(Oe,d+1))!==-1;)l.push({type:7,index:i}),d+=Oe.length-1}i++}}static createElement(e,t){let n=Je.createElement("template");return n.innerHTML=e,n}};function dt(r,e,t=r,n){if(e===Qe)return e;let o=n!==void 0?t._$Co?.[n]:t._$Cl,i=Wt(e)?void 0:e._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),i===void 0?o=void 0:(o=new i(r),o._$AT(r,t,n)),n!==void 0?(t._$Co??=[])[n]=o:t._$Cl=o),o!==void 0&&(e=dt(r,o._$AS(r,e.values),o,n)),e}var Lr=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,o=(e?.creationScope??Je).importNode(t,!0);Ye.currentNode=o;let i=Ye.nextNode(),s=0,a=0,l=n[0];for(;l!==void 0;){if(s===l.index){let c;l.type===2?c=new Bt(i,i.nextSibling,this,e):l.type===1?c=new l.ctor(i,l.name,l.strings,this,e):l.type===6&&(c=new Gr(i,this,e)),this._$AV.push(c),l=n[++a]}s!==l?.index&&(i=Ye.nextNode(),s++)}return Ye.currentNode=Je,o}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}},Bt=class r{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,o){this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=o,this._$Cv=o?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=dt(this,e,t),Wt(e)?e===f||e==null||e===""?(this._$AH!==f&&this._$AR(),this._$AH=f):e!==this._$AH&&e!==Qe&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):lu(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==f&&Wt(this._$AH)?this._$AA.nextSibling.data=e:this.T(Je.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,o=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=Lt.createElement(Ni(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===o)this._$AH.p(t);else{let i=new Lr(o,this),s=i.u(this.options);i.p(t),this.T(s),this._$AH=i}}_$AC(e){let t=Pi.get(e.strings);return t===void 0&&Pi.set(e.strings,t=new Lt(e)),t}k(e){jr(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,n,o=0;for(let i of e)o===t.length?t.push(n=new r(this.O(Ot()),this.O(Ot()),this,this.options)):n=t[o],n._$AI(i),o++;o<t.length&&(this._$AR(n&&n._$AB.nextSibling,o),t.length=o)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let n=Ei(e).nextSibling;Ei(e).remove(),e=n}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},ht=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,o,i){this.type=1,this._$AH=f,this._$AN=void 0,this.element=e,this.name=t,this._$AM=o,this.options=i,n.length>2||n[0]!==""||n[1]!==""?(this._Line truncated
Ein Plugin l\xE4uft mit denselben Rechten wie NextFloor in deinem Browser. Die Datei wurde gepr\xFCft, ihr Inhalt ist festgelegt:
{url}`,manual:"Anleitung",manual_more:"Mehr erfahren",feature_text_energy:"Energieteilchen fliegen in B\xF6gen von den Solarfeldern zum Wechselrichter, zwischen Haus, Akku, Netz und Verbrauchern \u2013 schneller und dichter, je mehr Strom flie\xDFt. Die Module funkeln mit ihrer Produktion, eine Glaskarte \xFCber dem Dach zeigt die Bilanz und wie autark das Haus gerade ist.",live_autarky:"autark",live_fold:"Karte verkleinern",live_unfold:"Karte aufklappen",live_day_hint:"Die letzten 24 Stunden: Solar (Fl\xE4che) und Verbrauch (Linie)",live_week_hint:"Die letzten 7 Tage: Sonne {solar} kWh, Verbrauch {use} kWh (gelb: Sonne, hell: Verbrauch)",live_days:"Tage",live_car_away:"Unterwegs",live_car_charging:"L\xE4dt",live_car_plugged:"Eingesteckt",live_car_lock:"Verriegeln",live_car_unlock:"Entriegeln",live_car_unlock_confirm:"{name} wirklich entriegeln?",live_car_climate:"Klimatisierung",live_car_charge:"Laden starten/stoppen",live_media_prev:"Zur\xFCck",live_media_playpause:"Abspielen/Pause",live_media_next:"Weiter",live_media_volume:"Lautst\xE4rke",live_car_device:"Auto (eine Entit\xE4t des Autos)",live_car_device_hint:"Ladestand, Reichweite, Laden, Stecker, Schloss und Klima findet NextFloor selbst am Ger\xE4t des Autos. Ohne Angabe nimmt es den Anwesenheitssensor des Stellplatzes.",live_car_departure_entity:"Abfahrtszeit (optional)",live_car_departure:"Abfahrt {time}",live_car_open:"Offen: {parts}",printer_printing:"druckt",printer_done:"fertig",printer_paused:"pausiert",printer_error:"Fehler",printer_idle:"bereit",printer_done_at:"fertig um {time}",printer_layer:"Schicht",printer_nozzle:"D\xFCse",printer_bed:"Bett",heatpump_heating:"heizt",heatpump_water:"macht Warmwasser",heatpump_cooling:"k\xFChlt",heatpump_defrost:"taut ab",heatpump_idle:"in Ruhe",heatpump_flow_return:"Vor- \u2192 R\xFCcklauf",heatpump_heat:"W\xE4rme",heatpump_power:"Strom",heatpump_outside:"au\xDFen",pack_missing_item:"M\xF6bel aus entferntem Pack",back_to_room:"Zur\xFCck zu {room}",back_to_floor:"Zur\xFCck zur Etage",hint_furniture:"Raum antippen, dann rechts ein M\xF6belst\xFCck w\xE4hlen \xB7 M\xF6bel ziehen, an den Ecken die Gr\xF6\xDFe \xE4ndern",furniture_into:"Neue M\xF6bel kommen in die Mitte von \u201E{room}\u201C.",furniture_pick_room:"Tipp: Erst einen Raum antippen \u2013 dann landen neue M\xF6bel in seiner Mitte.",flows:"Stromfluss",flows_hint:"Energieb\xF6gen zwischen Solarfeldern, Wechselrichter, Akku, Netz und Verbrauchern ein- oder ausblenden",chk_title:"Einrichtung",chk_hint:"Was der Energiefluss braucht. Antippen springt an die Stelle.",chk_solar:"Solarfeld angelegt",chk_solar_add:"Ein Solarfeld aufs Dach legen",chk_meter:"Stromz\xE4hler mit Netzsensor",chk_meter_sensor:"Stromz\xE4hler: Netzsensor (W) fehlt",chk_meter_add:"Stromz\xE4hler anlegen",chk_inverter:"Wechselrichter mit Leistungssensor",chk_inverter_sensor:"Wechselrichter: Leistungssensor fehlt",chk_inverter_add:"Wechselrichter anlegen",chk_battery:"Stromspeicher mit Leistung und Ladestand",chk_battery_sensor:"Stromspeicher: Leistung oder Ladestand fehlt",chk_battery_opt:"Stromspeicher (optional)",chk_grid:"Netzanschluss gesetzt",chk_grid_opt:"Netzanschluss (optional, sonst automatisch)",energy_sign_grid:"Das Haus zeigt Einspeisung, obwohl die Sonne nichts liefert. Der Netzsensor hat wahrscheinlich das umgekehrte Vorzeichen.",energy_sign_battery:"Der Speicher l\xE4dt ohne Sonne und ohne Netzbezug. Sein Sensor hat wahrscheinlich das umgekehrte Vorzeichen.",energy_sign_flip:"Vorzeichen umkehren",help_title:"Hilfe und R\xFCckmeldung",help_hint:"Fehler bitte als Issue auf GitHub, W\xFCnsche als Diskussion \u2013 so geht nichts verloren, und alle sehen den Stand.",help_issue:"Problem melden",help_idea:"Idee vorschlagen",furn_name:"Name (optional)",furn_mirror:"Spiegeln",furn_mirror_hint:"Links und rechts vertauschen \u2013 das L-Sofa andersherum, der Schrank mit der T\xFCr auf der anderen Seite, die K\xFCchenzeile gespiegelt.",hint_opening:"Auf eine Wand tippen, um eine T\xFCr oder ein Fenster einzusetzen \u2013 die Art w\xE4hlst du danach rechts",preset_door:"T\xFCr",preset_door_double:"Doppelt\xFCr",preset_window:"Fenster",preset_window_double:"Fenster 2-fl\xFCgelig",preset_terrace:"Terrassent\xFCr",preset_terrace_double:"Terrassent\xFCr 2-fl\xFCgelig",preset_lift_slide:"Hebe-Schiebet\xFCr",preset_garage:"Garagentor",preset_front:"Haust\xFCr",opening_style:"Stil",sidelight_auto:"automatisch",sidelight_hinge:"Seitenteil an der Anschlagseite",sidelight_hinge_hint:"Das Seitenteil sitzt sonst gegen\xFCber dem Anschlag; mit Haken neben den B\xE4ndern.",sidelight_width:"Breite Seitenteil (m)",sidelight_width_left:"Seitenteil links (m)",sidelight_width_right:"Seitenteil rechts (m)",style_auto:"Automatisch ({style})",style_interior:"Zimmert\xFCr",style_front:"Haust\xFCr",style_front_glass:"Haust\xFCr mit Glasausschnitt",style_sidelight:"Haust\xFCr mit Seitenteil",style_sidelights:"Haust\xFCr mit 2 Seitenteilen",style_glass:"Glast\xFCr",style_sliding:"Schiebet\xFCr",style_p Line truncated
{url}`,manual:"Anleitung",manual_more:"Mehr erfahren",feature_text_energy:"Energieteilchen fliegen in B\xF6gen von den Solarfeldern zum Wechselrichter, zwischen Haus, Akku, Netz und Verbrauchern \u2013 schneller und dichter, je mehr Strom flie\xDFt. Die Module funkeln mit ihrer Produktion, eine Glaskarte \xFCber dem Dach zeigt die Bilanz und wie autark das Haus gerade ist.",live_autarky:"autark",live_fold:"Karte verkleinern",live_unfold:"Karte aufklappen",live_day_hint:"Die letzten 24 Stunden: Solar (Fl\xE4che) und Verbrauch (Linie)",live_week_hint:"Die letzten 7 Tage: Sonne {solar} kWh, Verbrauch {use} kWh (gelb: Sonne, hell: Verbrauch)",live_days:"Tage",live_car_away:"Unterwegs",live_car_charging:"L\xE4dt",live_car_plugged:"Eingesteckt",live_car_lock:"Verriegeln",live_car_unlock:"Entriegeln",live_car_unlock_confirm:"{name} wirklich entriegeln?",live_car_climate:"Klimatisierung",live_car_charge:"Laden starten/stoppen",live_media_prev:"Zur\xFCck",live_media_playpause:"Abspielen/Pause",live_media_next:"Weiter",live_media_volume:"Lautst\xE4rke",live_car_device:"Auto (eine Entit\xE4t des Autos)",live_car_device_hint:"Ladestand, Reichweite, Laden, Stecker, Schloss und Klima findet NextFloor selbst am Ger\xE4t des Autos. Ohne Angabe nimmt es den Anwesenheitssensor des Stellplatzes.",live_car_departure_entity:"Abfahrtszeit (optional)",live_car_departure:"Abfahrt {time}",live_car_open:"Offen: {parts}",printer_printing:"druckt",printer_done:"fertig",printer_paused:"pausiert",printer_error:"Fehler",printer_idle:"bereit",printer_done_at:"fertig um {time}",printer_layer:"Schicht",printer_nozzle:"D\xFCse",printer_bed:"Bett",heatpump_heating:"heizt",heatpump_water:"macht Warmwasser",heatpump_cooling:"k\xFChlt",heatpump_defrost:"taut ab",heatpump_idle:"in Ruhe",heatpump_flow_return:"Vor- \u2192 R\xFCcklauf",heatpump_heat:"W\xE4rme",heatpump_power:"Strom",heatpump_outside:"au\xDFen",pack_missing_item:"M\xF6bel aus entferntem Pack",back_to_room:"Zur\xFCck zu {room}",back_to_floor:"Zur\xFCck zur Etage",hint_furniture:"Raum antippen, dann rechts ein M\xF6belst\xFCck w\xE4hlen \xB7 M\xF6bel ziehen, an den Ecken die Gr\xF6\xDFe \xE4ndern",furniture_into:"Neue M\xF6bel kommen in die Mitte von \u201E{room}\u201C.",furniture_pick_room:"Tipp: Erst einen Raum antippen \u2013 dann landen neue M\xF6bel in seiner Mitte.",flows:"Stromfluss",flows_hint:"Energieb\xF6gen zwischen Solarfeldern, Wechselrichter, Akku, Netz und Verbrauchern ein- oder ausblenden",chk_title:"Einrichtung",chk_hint:"Was der Energiefluss braucht. Antippen springt an die Stelle.",chk_solar:"Solarfeld angelegt",chk_solar_add:"Ein Solarfeld aufs Dach legen",chk_meter:"Stromz\xE4hler mit Netzsensor",chk_meter_sensor:"Stromz\xE4hler: Netzsensor (W) fehlt",chk_meter_add:"Stromz\xE4hler anlegen",chk_inverter:"Wechselrichter mit Leistungssensor",chk_inverter_sensor:"Wechselrichter: Leistungssensor fehlt",chk_inverter_add:"Wechselrichter anlegen",chk_battery:"Stromspeicher mit Leistung und Ladestand",chk_battery_sensor:"Stromspeicher: Leistung oder Ladestand fehlt",chk_battery_opt:"Stromspeicher (optional)",chk_grid:"Netzanschluss gesetzt",chk_grid_opt:"Netzanschluss (optional, sonst automatisch)",energy_sign_grid:"Das Haus zeigt Einspeisung, obwohl die Sonne nichts liefert. Der Netzsensor hat wahrscheinlich das umgekehrte Vorzeichen.",energy_sign_battery:"Der Speicher l\xE4dt ohne Sonne und ohne Netzbezug. Sein Sensor hat wahrscheinlich das umgekehrte Vorzeichen.",energy_sign_flip:"Vorzeichen umkehren",help_title:"Hilfe und R\xFCckmeldung",help_hint:"Fehler bitte als Issue auf GitHub, W\xFCnsche als Diskussion \u2013 so geht nichts verloren, und alle sehen den Stand.",help_issue:"Problem melden",help_idea:"Idee vorschlagen",furn_name:"Name (optional)",furn_mirror:"Spiegeln",furn_mirror_hint:"Links und rechts vertauschen \u2013 das L-Sofa andersherum, der Schrank mit der T\xFCr auf der anderen Seite, die K\xFCchenzeile gespiegelt.",hint_opening:"Auf eine Wand tippen, um eine T\xFCr oder ein Fenster einzusetzen \u2013 die Art w\xE4hlst du danach rechts",preset_door:"T\xFCr",preset_door_double:"Doppelt\xFCr",preset_window:"Fenster",preset_window_double:"Fenster 2-fl\xFCgelig",preset_terrace:"Terrassent\xFCr",preset_terrace_double:"Terrassent\xFCr 2-fl\xFCgelig",preset_lift_slide:"Hebe-Schiebet\xFCr",preset_garage:"Garagentor",preset_front:"Haust\xFCr",opening_style:"Stil",sidelight_auto:"automatisch",sidelight_hinge:"Seitenteil an der Anschlagseite",sidelight_hinge_hint:"Das Seitenteil sitzt sonst gegen\xFCber dem Anschlag; mit Haken neben den B\xE4ndern.",sidelight_width:"Breite Seitenteil (m)",sidelight_width_left:"Seitenteil links (m)",sidelight_width_right:"Seitenteil rechts (m)",style_auto:"Automatisch ({style})",style_interior:"Zimmert\xFCr",style_front:"Haust\xFCr",style_front_glass:"Haust\xFCr mit Glasausschnitt",style_sidelight:"Haust\xFCr mit Seitenteil",style_sidelights:"Haust\xFCr mit 2 Seitenteilen",style_glass:"Glast\xFCr",style_sliding:"Schiebet\xFCr",style_p Line truncated
A plugin runs with the same rights as NextFloor in your browser. The file has been reviewed and its content is fixed:
{url}`,manual:"Manual",manual_more:"Learn more",feature_text_energy:"Energy particles fly in arcs from the solar fields to the inverter, between house, battery, grid and consumers \u2013 faster and denser the more power flows. The modules sparkle with their production, a glass card over the roof shows the balance and how self-sufficient the house is right now.",live_autarky:"self-sufficient",live_fold:"Make the card small",live_unfold:"Open the card",live_day_hint:"The last 24 hours: solar (area) and consumption (line)",live_week_hint:"The last 7 days: sun {solar} kWh, use {use} kWh (yellow: sun, light: use)",live_days:"days",live_car_away:"On the road",live_car_charging:"Charging",live_car_plugged:"Plugged in",live_car_lock:"Lock",live_car_unlock:"Unlock",live_car_unlock_confirm:"Really unlock {name}?",live_car_climate:"Climate",live_car_charge:"Start/stop charging",live_media_prev:"Previous",live_media_playpause:"Play/pause",live_media_next:"Next",live_media_volume:"Volume",live_car_device:"Car (any entity of the car)",live_car_device_hint:"Charge, range, charging, plug, lock and climate are found by NextFloor on the car's device. Without one it takes the spot's presence sensor.",live_car_departure_entity:"Departure time (optional)",live_car_departure:"Departs {time}",live_car_open:"Open: {parts}",printer_printing:"printing",printer_done:"done",printer_paused:"paused",printer_error:"error",printer_idle:"idle",printer_done_at:"done at {time}",printer_layer:"Layer",printer_nozzle:"Nozzle",printer_bed:"Bed",heatpump_heating:"heating",heatpump_water:"making hot water",heatpump_cooling:"cooling",heatpump_defrost:"defrosting",heatpump_idle:"resting",heatpump_flow_return:"Flow \u2192 return",heatpump_heat:"Heat",heatpump_power:"Power",heatpump_outside:"outside",pack_missing_item:"Furniture of a removed pack",back_to_room:"Back to {room}",back_to_floor:"Back to the floor",hint_furniture:"Tap a room, then pick an item on the right \xB7 drag items, resize them by their corners",furniture_into:"New items go into the middle of \u201C{room}\u201D.",furniture_pick_room:"Tip: tap a room first \u2013 new items then land in its middle.",flows:"Power flow",flows_hint:"Show or hide the energy arcs between solar fields, inverter, battery, grid and consumers",chk_title:"Setup",chk_hint:"What the energy flow needs. Tap a row to jump there.",chk_solar:"Solar field in place",chk_solar_add:"Put a solar field on the roof",chk_meter:"Meter with grid sensor",chk_meter_sensor:"Meter: grid sensor (W) missing",chk_meter_add:"Add the meter",chk_inverter:"Inverter with power sensor",chk_inverter_sensor:"Inverter: power sensor missing",chk_inverter_add:"Add an inverter",chk_battery:"Home battery with power and charge",chk_battery_sensor:"Home battery: power or charge missing",chk_battery_opt:"Home battery (optional)",chk_grid:"Grid connection set",chk_grid_opt:"Grid connection (optional, else automatic)",energy_sign_grid:"The house shows export while the sun produces nothing. The grid sensor probably has its sign reversed.",energy_sign_battery:"The battery charges with no sun and no grid draw. Its sensor probably has its sign reversed.",energy_sign_flip:"Flip the sign",help_title:"Help and feedback",help_hint:"Please report problems as a GitHub issue and wishes as a discussion \u2013 nothing gets lost, and everyone sees the state.",help_issue:"Report a problem",help_idea:"Propose an idea",furn_name:"Name (optional)",furn_mirror:"Mirror",furn_mirror_hint:"Swap left and right \u2013 the L-sofa the other way round, the cabinet with its door on the other side, the kitchen run mirrored.",hint_opening:"Tap a wall to add a door or window \u2013 choose its kind on the right afterwards",preset_door:"Door",preset_door_double:"Double door",preset_window:"Window",preset_window_double:"Double window",preset_terrace:"Terrace door",preset_terrace_double:"French doors",preset_lift_slide:"Lift-and-slide door",preset_garage:"Garage door",preset_front:"Front door",opening_style:"Style",sidelight_auto:"automatic",sidelight_hinge:"Sidelight on the hinge side",sidelight_hinge_hint:"The sidelight sits opposite the hinge otherwise; ticked, it sits next to the hinges.",sidelight_width:"Sidelight width (m)",sidelight_width_left:"Left sidelight (m)",sidelight_width_right:"Right sidelight (m)",style_auto:"Automatic ({style})",style_interior:"Room door",style_front:"Front door",style_front_glass:"Front door with glass",style_sidelight:"Front door with sidelight",style_sidelights:"Front door with two sidelights",style_glass:"Glass door",style_sliding:"Sliding door",style_passage:"Opening (no door)",style_standard:"Standard",style_bars:"With glazing bars",style_glass_wall:"Glass wall (fixed)",preset_glass_wall:"Glass wall",glass_panes:"Panes",glass_panes_auto:"automatic (about 0.9 m)",glass_panes_hint:"0 = one single pane without mullions, empty = about every 0.9 m",flip_hinge:"Swap hinge side",flip_main_leaf:"Swap main leaf",flip_hinge_hint:"Hinges to the other side" Line truncated
{url}`,manual:"Manual",manual_more:"Learn more",feature_text_energy:"Energy particles fly in arcs from the solar fields to the inverter, between house, battery, grid and consumers \u2013 faster and denser the more power flows. The modules sparkle with their production, a glass card over the roof shows the balance and how self-sufficient the house is right now.",live_autarky:"self-sufficient",live_fold:"Make the card small",live_unfold:"Open the card",live_day_hint:"The last 24 hours: solar (area) and consumption (line)",live_week_hint:"The last 7 days: sun {solar} kWh, use {use} kWh (yellow: sun, light: use)",live_days:"days",live_car_away:"On the road",live_car_charging:"Charging",live_car_plugged:"Plugged in",live_car_lock:"Lock",live_car_unlock:"Unlock",live_car_unlock_confirm:"Really unlock {name}?",live_car_climate:"Climate",live_car_charge:"Start/stop charging",live_media_prev:"Previous",live_media_playpause:"Play/pause",live_media_next:"Next",live_media_volume:"Volume",live_car_device:"Car (any entity of the car)",live_car_device_hint:"Charge, range, charging, plug, lock and climate are found by NextFloor on the car's device. Without one it takes the spot's presence sensor.",live_car_departure_entity:"Departure time (optional)",live_car_departure:"Departs {time}",live_car_open:"Open: {parts}",printer_printing:"printing",printer_done:"done",printer_paused:"paused",printer_error:"error",printer_idle:"idle",printer_done_at:"done at {time}",printer_layer:"Layer",printer_nozzle:"Nozzle",printer_bed:"Bed",heatpump_heating:"heating",heatpump_water:"making hot water",heatpump_cooling:"cooling",heatpump_defrost:"defrosting",heatpump_idle:"resting",heatpump_flow_return:"Flow \u2192 return",heatpump_heat:"Heat",heatpump_power:"Power",heatpump_outside:"outside",pack_missing_item:"Furniture of a removed pack",back_to_room:"Back to {room}",back_to_floor:"Back to the floor",hint_furniture:"Tap a room, then pick an item on the right \xB7 drag items, resize them by their corners",furniture_into:"New items go into the middle of \u201C{room}\u201D.",furniture_pick_room:"Tip: tap a room first \u2013 new items then land in its middle.",flows:"Power flow",flows_hint:"Show or hide the energy arcs between solar fields, inverter, battery, grid and consumers",chk_title:"Setup",chk_hint:"What the energy flow needs. Tap a row to jump there.",chk_solar:"Solar field in place",chk_solar_add:"Put a solar field on the roof",chk_meter:"Meter with grid sensor",chk_meter_sensor:"Meter: grid sensor (W) missing",chk_meter_add:"Add the meter",chk_inverter:"Inverter with power sensor",chk_inverter_sensor:"Inverter: power sensor missing",chk_inverter_add:"Add an inverter",chk_battery:"Home battery with power and charge",chk_battery_sensor:"Home battery: power or charge missing",chk_battery_opt:"Home battery (optional)",chk_grid:"Grid connection set",chk_grid_opt:"Grid connection (optional, else automatic)",energy_sign_grid:"The house shows export while the sun produces nothing. The grid sensor probably has its sign reversed.",energy_sign_battery:"The battery charges with no sun and no grid draw. Its sensor probably has its sign reversed.",energy_sign_flip:"Flip the sign",help_title:"Help and feedback",help_hint:"Please report problems as a GitHub issue and wishes as a discussion \u2013 nothing gets lost, and everyone sees the state.",help_issue:"Report a problem",help_idea:"Propose an idea",furn_name:"Name (optional)",furn_mirror:"Mirror",furn_mirror_hint:"Swap left and right \u2013 the L-sofa the other way round, the cabinet with its door on the other side, the kitchen run mirrored.",hint_opening:"Tap a wall to add a door or window \u2013 choose its kind on the right afterwards",preset_door:"Door",preset_door_double:"Double door",preset_window:"Window",preset_window_double:"Double window",preset_terrace:"Terrace door",preset_terrace_double:"French doors",preset_lift_slide:"Lift-and-slide door",preset_garage:"Garage door",preset_front:"Front door",opening_style:"Style",sidelight_auto:"automatic",sidelight_hinge:"Sidelight on the hinge side",sidelight_hinge_hint:"The sidelight sits opposite the hinge otherwise; ticked, it sits next to the hinges.",sidelight_width:"Sidelight width (m)",sidelight_width_left:"Left sidelight (m)",sidelight_width_right:"Right sidelight (m)",style_auto:"Automatic ({style})",style_interior:"Room door",style_front:"Front door",style_front_glass:"Front door with glass",style_sidelight:"Front door with sidelight",style_sidelights:"Front door with two sidelights",style_glass:"Glass door",style_sliding:"Sliding door",style_passage:"Opening (no door)",style_standard:"Standard",style_bars:"With glazing bars",style_glass_wall:"Glass wall (fixed)",preset_glass_wall:"Glass wall",glass_panes:"Panes",glass_panes_auto:"automatic (about 0.9 m)",glass_panes_hint:"0 = one single pane without mullions, empty = about every 0.9 m",flip_hinge:"Swap hinge side",flip_main_leaf:"Swap main leaf",flip_hinge_hint:"Hinges to the other side" Line truncated
:host {
--nf-text: var(--primary-text-color, #e1e1e1);
--nf-muted: var(--secondary-text-color, #9b9b9b);
@@ -35,7 +35,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
font-family: var(--nf-font);
color: var(--nf-text);
}
`,dr=te`
`,pr=te`
:host([readable]) {
--secondary-text-color: var(--primary-text-color, #e1e1e1);
--divider-color: color-mix(in srgb, var(--primary-text-color, #e1e1e1) 40%, transparent);
@@ -46,7 +46,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
:host([readable]) .nf-overlay {
zoom: 1.2;
}
`,Ve=te`
`,Ke=te`
/* a group of switches: one rounded pill, the active one tinted with the accent */
.nf-seg {
display: inline-flex;
@@ -209,12 +209,12 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
min-height: 40px;
}
}
`;function hr(r){return r?.themes?.darkMode===!1?"light":"dark"}var zh=4,Th=8,Fh=[[255,181,71],[255,236,210],[55,224,255],[91,124,255],[255,95,210],[120,255,150]],$t=r=>m`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d=${tr(r)} />
</svg>`,pr={previous:"M6 6h2v12H6zM20 6v12l-10-6z",play:"M8 5v14l11-7z",pause:"M7 5h4v14H7zM13 5h4v14h-4z",next:"M16 6h2v12h-2zM4 6v12l10-6z"},Do=r=>m`<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d=${r} /></svg>`,Dh=24,Ph=10,Po=class extends re{static properties={hass:{attribute:!1},room:{attribute:!1},floor:{attribute:!1},confirmEntities:{attribute:!1},phrases:{attribute:!1},outside:{attribute:!1},_showAll:{state:!0},_said:{state:!0},_folded:{state:!0},_curve:{state:!0},_moodName:{state:!0},_undo:{state:!0},_energy:{state:!0},_sunYear:{state:!0},rooms:{attribute:!1},building:{attribute:!1}};saidTimer;memo=null;curveFor="";undoTimer;constructor(){super(),this.room=null,this.floor=null,this.phrases=null,this.outside=null,this._said=null,this._showAll=!1,this._folded=!1,this._curve=null,this._moodName=null,this._undo=null,this._energy=null,this._sunYear=!1,this.rooms=null,this.building=null}fireMoods(e,t){this.dispatchEvent(new CustomEvent("mood-change",{detail:{roomId:e.id,moods:t},bubbles:!0,composed:!0}))}runMood(e){for(let t of ur(e))this.call("light",t.service,t.data)}renderMoods(e,t){let n=e.moods??[],o=!!this.rooms&&!!this.hass.user?.is_admin;if(!n.length&&!o)return f;let i=(this.rooms??[]).filter(l=>l.id!==e.id&&l.area_id),s=l=>K(this.hass,l).filter(c=>c.startsWith("light.")),a=()=>{let l=(this._moodName??"").trim()||this.t("mood_new");this.fireMoods(e,[...n,{id:`mood_${Date.now().toString(36)}`,name:l,lights:t.map(cr)}]),this._moodName=null};return m`<div class="nf-rp-moods">
`;function mr(r){return r?.themes?.darkMode===!1?"light":"dark"}var Dh=4,Ph=8,Hh=[[255,181,71],[255,236,210],[55,224,255],[91,124,255],[255,95,210],[120,255,150]],At=r=>m`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d=${rr(r)} />
</svg>`,fr={previous:"M6 6h2v12H6zM20 6v12l-10-6z",play:"M8 5v14l11-7z",pause:"M7 5h4v14H7zM13 5h4v14h-4z",next:"M16 6h2v12h-2zM4 6v12l10-6z"},Ho=r=>m`<svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor" aria-hidden="true"><path d=${r} /></svg>`,Ih=24,Ch=10,Io=class extends re{static properties={hass:{attribute:!1},room:{attribute:!1},floor:{attribute:!1},confirmEntities:{attribute:!1},phrases:{attribute:!1},outside:{attribute:!1},_showAll:{state:!0},_said:{state:!0},_folded:{state:!0},_curve:{state:!0},_moodName:{state:!0},_undo:{state:!0},_energy:{state:!0},_sunYear:{state:!0},rooms:{attribute:!1},building:{attribute:!1}};saidTimer;memo=null;curveFor="";undoTimer;constructor(){super(),this.room=null,this.floor=null,this.phrases=null,this.outside=null,this._said=null,this._showAll=!1,this._folded=!1,this._curve=null,this._moodName=null,this._undo=null,this._energy=null,this._sunYear=!1,this.rooms=null,this.building=null}fireMoods(e,t){this.dispatchEvent(new CustomEvent("mood-change",{detail:{roomId:e.id,moods:t},bubbles:!0,composed:!0}))}runMood(e){for(let t of hr(e))this.call("light",t.service,t.data)}renderMoods(e,t){let n=e.moods??[],o=!!this.rooms&&!!this.hass.user?.is_admin;if(!n.length&&!o)return f;let i=(this.rooms??[]).filter(l=>l.id!==e.id&&l.area_id),s=l=>K(this.hass,l).filter(c=>c.startsWith("light.")),a=()=>{let l=(this._moodName??"").trim()||this.t("mood_new");this.fireMoods(e,[...n,{id:`mood_${Date.now().toString(36)}`,name:l,lights:t.map(dr)}]),this._moodName=null};return m`<div class="nf-rp-moods">
${n.map(l=>m`<span class="nf-rp-mood">
<button class="nf-btn" title=${this.t("mood_set")} @click=${()=>this.runMood(l.lights)}>✨ ${l.name}</button>
${i.length?m`<select class="nf-rp-mood-to" aria-label=${this.t("mood_carry")} title=${this.t("mood_carry")} @change=${c=>{let u=c.target,d=i.find(p=>p.id===u.value);u.value="",d&&this.runMood(el(l,s(d)))}}>
${i.length?m`<select class="nf-rp-mood-to" aria-label=${this.t("mood_carry")} title=${this.t("mood_carry")} @change=${c=>{let u=c.target,d=i.find(p=>p.id===u.value);u.value="",d&&this.runMood(nl(l,s(d)))}}>
<option value="">→</option>
${i.map(c=>m`<option value=${c.id}>${c.name}</option>`)}
</select>`:f}
@@ -224,21 +224,21 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
><input type="text" maxlength="40" placeholder=${this.t("mood_new")} .value=${this._moodName} @input=${l=>this._moodName=l.target.value} @keydown=${l=>l.key==="Enter"&&a()} />
<button class="nf-btn" @click=${a}>${this.t("mood_save")}</button></span
>`:f}
</div>`}async loadCurve(e){let t=Zn(this.hass,this.floor,e,"temperature"),n=t.length?t:K(this.hass,e).filter(s=>s.startsWith("climate."));if(!n.length)return;let o=Date.now(),i=o-24*36e5;try{let s=await on(this.hass,n,i,o,!!t.length);if(this.room?.id!==e.id)return;let a=[];for(let l=1;l<=96;l++){let c=Mt(this.hass,s,i+(o-i)*l/96),u=n.map(d=>d.startsWith("climate.")?Number(c.states[d]?.attributes.current_temperature):Number(c.states[d]?.state)).filter(Number.isFinite);a.push(u.length?u.reduce((d,p)=>d+p,0)/u.length:null)}this._curve=a.some(l=>l!==null)?a:null}catch{this._curve=null}}async loadEnergy(e){if(!this.floor||!this.building)return;let t=To(this.hass,this.building,this.floor,e);try{let n=await Ga(this.hass,t);this.room?.id===e.id&&(this._energy=n)}catch{this._energy=null}}renderEmptyLights(e,t){if(!t.length||!this.room)return f;let n=K(this.hass,e).map(s=>this.hass.states[s]).filter(s=>!!s&&s.entity_id.startsWith("binary_sensor.")&&["motion","occupancy","presence"].includes(String(s.attributes.device_class)));if(!n.length||n.some(s=>s.state!=="off"))return f;let o=Math.max(...n.map(s=>Date.parse(String(s.last_changed??""))||0)),i=Math.floor((Date.now()-o)/6e4);return!o||i<Ph?f:m`<div class="nf-rp-shade">
</div>`}async loadCurve(e){let t=Zn(this.hass,this.floor,e,"temperature"),n=t.length?t:K(this.hass,e).filter(s=>s.startsWith("climate."));if(!n.length)return;let o=Date.now(),i=o-24*36e5;try{let s=await on(this.hass,n,i,o,!!t.length);if(this.room?.id!==e.id)return;let a=[];for(let l=1;l<=96;l++){let c=$t(this.hass,s,i+(o-i)*l/96),u=n.map(d=>d.startsWith("climate.")?Number(c.states[d]?.attributes.current_temperature):Number(c.states[d]?.state)).filter(Number.isFinite);a.push(u.length?u.reduce((d,p)=>d+p,0)/u.length:null)}this._curve=a.some(l=>l!==null)?a:null}catch{this._curve=null}}async loadEnergy(e){if(!this.floor||!this.building)return;let t=Do(this.hass,this.building,this.floor,e);try{let n=await ja(this.hass,t);this.room?.id===e.id&&(this._energy=n)}catch{this._energy=null}}renderEmptyLights(e,t){if(!t.length||!this.room)return f;let n=K(this.hass,e).map(s=>this.hass.states[s]).filter(s=>!!s&&s.entity_id.startsWith("binary_sensor.")&&["motion","occupancy","presence"].includes(String(s.attributes.device_class)));if(!n.length||n.some(s=>s.state!=="off"))return f;let o=Math.max(...n.map(s=>Date.parse(String(s.last_changed??""))||0)),i=Math.floor((Date.now()-o)/6e4);return!o||i<Ch?f:m`<div class="nf-rp-shade">
<span>💡 ${this.t("empty_lights_hint",{n:t.length,min:i})}</span>
<button class="nf-btn nf-rp-small" @click=${()=>this.call("light","turn_off",{entity_id:t.map(s=>s.entity_id)})}>${this.t("empty_lights_off")}</button>
</div>`}renderOpenWhileHeating(e){let t=this.room;if(!t||!this.floor)return f;let n=e.filter(a=>a.attributes.hvac_action==="heating"||a.state==="heat"&&a.attributes.hvac_action===void 0);if(!n.length)return f;let o=a=>!!a&&a!=="none"&&this.hass.states[a]?.state==="on",i=this.floor.openings.filter(a=>a.room_id===t.id&&[a.contact,a.contact2,a.tilt,a.tilt2].some(o));if(!i.length)return f;let s=()=>{for(let a of n)(a.attributes.hvac_modes??[]).includes("off")?this.call("climate","set_hvac_mode",{entity_id:a.entity_id,hvac_mode:"off"}):typeof a.attributes.min_temp=="number"&&this.call("climate","set_temperature",{entity_id:a.entity_id,temperature:a.attributes.min_temp})};return m`<div class="nf-rp-shade nf-rp-open-heat">
<span>🪟 ${this.t("open_heating_hint",{n:i.length})}</span>
<button class="nf-btn nf-rp-small" @click=${s}>${this.t("open_heating_off")}</button>
</div>`}renderShade(){let e=this.room,{latitude:t,longitude:n}=this.hass.config??{};if(!e||!this.floor||!this.building||t===void 0||n===void 0)return f;let o=Y(this.hass,this.floor,e,"temperature");if(o===null||o<Dh)return f;let i=a=>{let l=a&&a!=="none"?this.hass.states[a]:void 0;if(!l||I(l))return!1;let c=l.attributes.current_position;return typeof c=="number"?c>30:l.state==="open"},s=[...new Set(Na(this.building,this.floor,e,{latitude:t,longitude:n}).flatMap(a=>[a.cover,a.cover2].filter(i)))];return s.length?m`<div class="nf-rp-shade">
</div>`}renderShade(){let e=this.room,{latitude:t,longitude:n}=this.hass.config??{};if(!e||!this.floor||!this.building||t===void 0||n===void 0)return f;let o=Y(this.hass,this.floor,e,"temperature");if(o===null||o<Ih)return f;let i=a=>{let l=a&&a!=="none"?this.hass.states[a]:void 0;if(!l||I(l))return!1;let c=l.attributes.current_position;return typeof c=="number"?c>30:l.state==="open"},s=[...new Set(Wa(this.building,this.floor,e,{latitude:t,longitude:n}).flatMap(a=>[a.cover,a.cover2].filter(i)))];return s.length?m`<div class="nf-rp-shade">
<span>☀ ${this.t("shade_hint",{n:s.length,temp:`${O(this.hass,ue(this.hass,o),1)} ${ne(this.hass)}`})}</span>
<button class="nf-btn nf-rp-small" @click=${()=>this.call("cover","close_cover",{entity_id:s})}>${this.t("shade_close")}</button>
</div>`:f}renderSunYear(){let e=this.room,{latitude:t,longitude:n}=this.hass.config??{};if(!e||!this.floor||!this.building||t===void 0||n===void 0)return f;let o={latitude:t,longitude:n};if(!xt(this.building,this.floor,e,{...o,zone:this.hass.config?.time_zone}).facing.length)return f;let s=m`<button class="nf-rp-sun-year" aria-expanded=${this._sunYear} title=${this.t("room_sun_year_hint")} @click=${()=>this._sunYear=!this._sunYear}>
</div>`:f}renderSunYear(){let e=this.room,{latitude:t,longitude:n}=this.hass.config??{};if(!e||!this.floor||!this.building||t===void 0||n===void 0)return f;let o={latitude:t,longitude:n};if(!St(this.building,this.floor,e,{...o,zone:this.hass.config?.time_zone}).facing.length)return f;let s=m`<button class="nf-rp-sun-year" aria-expanded=${this._sunYear} title=${this.t("room_sun_year_hint")} @click=${()=>this._sunYear=!this._sunYear}>
☀ ${this.t("room_sun_year")}
</button>`;if(!this._sunYear)return s;let a=Ca(this.building,this.floor,e,o),l=Math.max(1,...a),c=Array.from({length:12},(u,d)=>new Date(2026,d,15).toLocaleDateString(this.hass.language,{month:"narrow"}));return m`${s}
</button>`;if(!this._sunYear)return s;let a=Oa(this.building,this.floor,e,o),l=Math.max(1,...a),c=Array.from({length:12},(u,d)=>new Date(2026,d,15).toLocaleDateString(this.hass.language,{month:"narrow"}));return m`${s}
<div class="nf-rp-sun-bars" role="img" aria-label=${a.map((u,d)=>`${c[d]} ${O(this.hass,u,1)} h`).join(", ")}>
${a.map((u,d)=>m`<span title=${`${O(this.hass,u,1)} h`}><i style=${`height:${Math.round(u/l*100)}%`}></i><b>${c[d]}</b></span>`)}
</div>`}renderEnergy(){let e=this._energy;if(!e||e.month<=0)return f;let t=this.building?.energy.tariff,n=t?this.hass.states[t]:void 0,o=n?{value:Number(n.state),unit:String(n.attributes.unit_of_measurement??"")}:null,i=Ua(e.month,o),s=a=>`${O(this.hass,a,a<10?2:1)} kWh`;return m`<p class="nf-rp-facts nf-rp-energy" title=${this.t("room_energy_hint")}>
</div>`}renderEnergy(){let e=this._energy;if(!e||e.month<=0)return f;let t=this.building?.energy.tariff,n=t?this.hass.states[t]:void 0,o=n?{value:Number(n.state),unit:String(n.attributes.unit_of_measurement??"")}:null,i=qa(e.month,o),s=a=>`${O(this.hass,a,a<10?2:1)} kWh`;return m`<p class="nf-rp-facts nf-rp-energy" title=${this.t("room_energy_hint")}>
⚡ ${this.t("room_energy",{today:s(e.today),month:s(e.month)})}${i?` \xB7 ${O(this.hass,i.value,2)} ${i.currency}`:""}
</p>`}renderCurve(){let e=this._curve;if(!e)return f;let t=e.filter(c=>c!==null),n=Math.min(...t),o=Math.max(...t),i=Math.max(1,o-n),s=e.map(c=>c===null?null:c-n+i*.1),a=sn(s,220,36,i*1.2),l=c=>`${O(this.hass,ue(this.hass,c),1)}\xB0`;return m`<div class="nf-rp-curve" title=${this.t("room_curve_hint")}>
<svg viewBox="0 0 220 36" preserveAspectRatio="none" aria-hidden="true">${J`<path d=${a}></path>`}</svg>
@@ -250,7 +250,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
aria-label=${this.name(e.entity_id)}
?disabled=${I(e)}
@click=${o}
></button>`}outsideRoom=null;render(){let e=!this.room&&this.outside?this.outside:null;e&&!this.outsideRoom&&(this.outsideRoom={id:"nf-outside",name:this.t("outside_area"),area_id:null,points:[],floor_material:"grass"});let t=this.room??(e?this.outsideRoom:null);if(!t||!this.hass)return f;let n=e??K(this.hass,t),o=this.memo,{shown:i,more:s}=e?{shown:e,more:[]}:o&&o.entities===this.hass.entities&&o.floor===this.floor&&o.room===t?o:this.memo={entities:this.hass.entities,floor:this.floor,room:t,...this.floor?Ws(this.hass,this.floor,t):{shown:n,more:[]}},a=ho(this.hass,s).map(k=>k.primary),l=a.length,c=this._showAll?[...i,...a]:i,u=k=>c.filter(y=>k.includes(D(y))).map(y=>this.hass.states[y]),d=u(["light"]),p=u(["cover"]),h=u(["climate"]),w=u(["media"]),b=u(["switch","fan","lock"]),g=u(["sensor","binary"]),_=u(["scene","script"]),M=this.facts(h),$=d.filter(k=>k.state==="on");return m`<section class="nf-rp" aria-label=${t.name}>
></button>`}outsideRoom=null;render(){let e=!this.room&&this.outside?this.outside:null;e&&!this.outsideRoom&&(this.outsideRoom={id:"nf-outside",name:this.t("outside_area"),area_id:null,points:[],floor_material:"grass"});let t=this.room??(e?this.outsideRoom:null);if(!t||!this.hass)return f;let n=e??K(this.hass,t),o=this.memo,{shown:i,more:s}=e?{shown:e,more:[]}:o&&o.entities===this.hass.entities&&o.floor===this.floor&&o.room===t?o:this.memo={entities:this.hass.entities,floor:this.floor,room:t,...this.floor?Bs(this.hass,this.floor,t):{shown:n,more:[]}},a=mo(this.hass,s).map(x=>x.primary),l=a.length,c=this._showAll?[...i,...a]:i,u=x=>c.filter(y=>x.includes(D(y))).map(y=>this.hass.states[y]),d=u(["light"]),p=u(["cover"]),h=u(["climate"]),g=u(["media"]),b=u(["switch","fan","lock"]),_=u(["sensor","binary"]),w=u(["scene","script"]),M=this.facts(h),$=d.filter(x=>x.state==="on");return m`<section class="nf-rp" aria-label=${t.name}>
<header class="nf-rp-head">
<div>
<h2>${t.name}</h2>
@@ -266,55 +266,55 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
</button>
</header>
<div class="nf-rp-body" ?hidden=${this._folded}>
${this.renderAllOff([...d,...w,...b])}
${this.renderAllOff([...d,...g,...b])}
${this.renderClean(t)}
${!t.area_id&&!e?m`<p class="nf-rp-note">${this.t("panel_no_area")}</p>`:c.length?f:m`<p class="nf-rp-note">${this.t("panel_empty")}</p>`}
${_.length?this.section("panel_scenes",[m`<div class="nf-rp-scenes">
${_.map(k=>m`<button
${w.length?this.section("panel_scenes",[m`<div class="nf-rp-scenes">
${w.map(x=>m`<button
class="nf-btn"
?disabled=${I(k)}
@click=${()=>this.call(D(k.entity_id)==="scene"?"scene":"script","turn_on",{entity_id:k.entity_id})}
?disabled=${I(x)}
@click=${()=>this.call(D(x.entity_id)==="scene"?"scene":"script","turn_on",{entity_id:x.entity_id})}
>
${this.name(k.entity_id)}
${this.name(x.entity_id)}
</button>`)}
</div>`]):f}
${d.length?this.section("panel_lights",[...d.map(k=>this.lightRow(k)),...t?[this.renderMoods(t,d)]:[]],m`${$.length<d.length?m`<button class="nf-btn nf-rp-small" @click=${()=>this.call("light","turn_on",{entity_id:d.filter(k=>!I(k)).map(k=>k.entity_id)})}>
${d.length?this.section("panel_lights",[...d.map(x=>this.lightRow(x)),...t?[this.renderMoods(t,d)]:[]],m`${$.length<d.length?m`<button class="nf-btn nf-rp-small" @click=${()=>this.call("light","turn_on",{entity_id:d.filter(x=>!I(x)).map(x=>x.entity_id)})}>
${this.t("panel_all_on")}
</button>`:f}${$.length?m`<button class="nf-btn nf-rp-small" @click=${()=>this.call("light","turn_off",{entity_id:$.map(k=>k.entity_id)})}>
</button>`:f}${$.length?m`<button class="nf-btn nf-rp-small" @click=${()=>this.call("light","turn_off",{entity_id:$.map(x=>x.entity_id)})}>
${this.t("panel_all_off")}
</button>`:f}`):f}
${p.length?this.section("panel_covers",p.map(k=>this.coverRow(k)),p.length>1&&Bn(p,this.confirmEntities).length?m`<button class="nf-btn nf-rp-small" @click=${()=>this.call("cover","open_cover",{entity_id:Bn(p,this.confirmEntities)})}>
${p.length?this.section("panel_covers",p.map(x=>this.coverRow(x)),p.length>1&&Bn(p,this.confirmEntities).length?m`<button class="nf-btn nf-rp-small" @click=${()=>this.call("cover","open_cover",{entity_id:Bn(p,this.confirmEntities)})}>
${this.t("panel_all_open")}</button
><button class="nf-btn nf-rp-small" @click=${()=>this.call("cover","close_cover",{entity_id:Bn(p,this.confirmEntities)})}>
${this.t("panel_all_close")}
</button>`:f):f}
${h.length?this.section("panel_climate",h.map(k=>this.climateRow(k))):f}
${w.length?this.section("panel_media",w.map(k=>this.mediaRow(k))):f}
${b.length?this.section("panel_switches",b.map(k=>this.switchRow(k))):f}
${g.length?this.section("panel_sensors",g.map(k=>this.sensorRow(k))):f}
${fa(this.hass)&&ma(this.hass,this.floor,t)?this.announceSection(t):f}
${h.length?this.section("panel_climate",h.map(x=>this.climateRow(x))):f}
${g.length?this.section("panel_media",g.map(x=>this.mediaRow(x))):f}
${b.length?this.section("panel_switches",b.map(x=>this.switchRow(x))):f}
${_.length?this.section("panel_sensors",_.map(x=>this.sensorRow(x))):f}
${_a(this.hass)&&ga(this.hass,this.floor,t)?this.announceSection(t):f}
${this.pluginSections(t,c)}
${l?m`<button class="nf-btn nf-rp-small nf-rp-more" @click=${()=>this._showAll=!this._showAll}>
${this._showAll?this.t("panel_less"):this.t("panel_more",{n:l})}
</button>`:f}
</div>
</section>`}facts(e){let t=[],n=this.room;if(!n)return t;let o=(y,F)=>{let T=Y(this.hass,this.floor,n,y);if(T===null)return null;if(y==="temperature")return`${O(this.hass,ue(this.hass,T),1)} ${ne(this.hass)}`;let C=Zn(this.hass,this.floor,n,y)[0],E=this.hass.states[C]?.attributes.unit_of_measurement??F;return`${O(this.hass,T,1)} ${E}`},i=e.find(y=>typeof y.attributes.current_temperature=="number"),s=o("temperature","\xB0C");s?t.push(s):i&&n.climate?.temperature!=="none"&&t.push(`${O(this.hass,i.attributes.current_temperature,1)} ${ne(this.hass)}`);let a=o("humidity","%");a&&t.push(a);let l=this.floor&&this.building?zo(this.hass,this.building,this.floor,n):null;l!==null&&t.push(`\u26A1 ${it(this.hass,l)}`);let c=this.floor?this.floor.openings.filter(y=>y.room_id===n.id).flatMap(y=>[y.contact,y.contact2,y.tilt,y.tilt2]).map(y=>y&&y!=="none"?this.hass.states[y]:void 0).filter(y=>y?.state==="on").map(y=>Date.parse(String(y.last_changed??""))).filter(Number.isFinite):[];c.length&&t.push(`\u{1FA9F} ${this.t("open_since",{time:Fo(Date.now()-Math.min(...c))})}`);let u=K(this.hass,n).map(y=>this.hass.states[y]).filter(y=>!!y&&y.entity_id.startsWith("binary_sensor.")&&["motion","occupancy","presence"].includes(String(y.attributes.device_class)));if(u.length)if(u.some(y=>y.state==="on"))t.push(`\u{1F6B6} ${this.t("presence_now")}`);else{let y=Math.max(...u.map(F=>Date.parse(String(F.last_changed??""))||0));y>0&&t.push(`\u{1F6B6} ${this.t("presence_last",{time:Fo(Date.now()-y)})}`)}let d=this.building?Za(this.hass,this.building).filter(y=>y.roomId===n.id&&y.level<qa):[];d.length&&t.push(`\u{1FAAB} ${this.t("battery_low_n",{n:d.length,names:d.map(y=>`${this.name(y.entity)} ${Math.round(y.level)} %`).join(", ")})}`);let p=(this.building?.settings.circuits??[]).filter(y=>y.rooms.includes(n.id)).map(y=>y.name),h=this.building?.settings.room_facts_off??[];p.length&&!h.includes("circuits")&&t.push(`\u{1F50C} ${p.join(", ")}`);let{latitude:w,longitude:b,time_zone:g}=this.hass.config??{};if(this.floor&&w!==void 0&&b!==void 0&&this.building&&!h.includes("sun")){let y=xt(this.building,this.floor,n,{latitude:w,longitude:b,zone:g});y.facing.length&&t.push(`\u2600 ${this.t("room_sun_hours",{h:O(this.hass,y.hours,1),facing:y.facing.join(", ")})}`)}let _=Y(this.hass,this.floor,n,"temperature"),M=Y(this.hass,this.floor,n,"humidity"),$=sr(Y(this.hass,this.floor,n,"co2"),M,St(_,M));$&&!h.includes("air")&&t.push(`\u{1F4A8} ${this.t(`air_${$}`)}`);let k=ar(_,M,Y(this.hass,this.floor,n,"co2"),ot(new Date,this.hass.config?.latitude));return k!==null&&(_!==null||M!==null)&&!h.includes("comfort")&&t.push(`\u{1F60A} ${this.t("comfort_n",{n:k})}`),t}announceSection(e){let t=this.phrases?.length?this.phrases:[1,2,3,4,5].map(i=>this.t(`announce_phrase_${i}`)),n=i=>{let s=i.trim();s&&(clearTimeout(this.saidTimer),this.hass.callService("nextfloor","announce",{message:s,rooms:[e.id],on_screens:!1}).then(()=>this._said={text:this.t("announce_sent",{message:s}),failed:!1},a=>this._said={text:this.t("announce_failed",{error:a?.message??String(a)}),failed:!0}),this.saidTimer=setTimeout(()=>this._said=null,6e3))},o=i=>{i.preventDefault();let s=i.currentTarget.querySelector("input");n(s.value),s.value=""};return this.section("panel_announce",[m`<div class="nf-rp-scenes">${t.map(i=>m`<button class="nf-btn" @click=${()=>n(i)}>${i}</button>`)}</div>
</section>`}facts(e){let t=[],n=this.room;if(!n)return t;let o=(y,F)=>{let T=Y(this.hass,this.floor,n,y);if(T===null)return null;if(y==="temperature")return`${O(this.hass,ue(this.hass,T),1)} ${ne(this.hass)}`;let C=Zn(this.hass,this.floor,n,y)[0],E=this.hass.states[C]?.attributes.unit_of_measurement??F;return`${O(this.hass,T,1)} ${E}`},i=e.find(y=>typeof y.attributes.current_temperature=="number"),s=o("temperature","\xB0C");s?t.push(s):i&&n.climate?.temperature!=="none"&&t.push(`${O(this.hass,i.attributes.current_temperature,1)} ${ne(this.hass)}`);let a=o("humidity","%");a&&t.push(a);let l=this.floor&&this.building?Fo(this.hass,this.building,this.floor,n):null;l!==null&&t.push(`\u26A1 ${at(this.hass,l)}`);let c=this.floor?this.floor.openings.filter(y=>y.room_id===n.id).flatMap(y=>[y.contact,y.contact2,y.tilt,y.tilt2]).map(y=>y&&y!=="none"?this.hass.states[y]:void 0).filter(y=>y?.state==="on").map(y=>Date.parse(String(y.last_changed??""))).filter(Number.isFinite):[];c.length&&t.push(`\u{1FA9F} ${this.t("open_since",{time:Po(Date.now()-Math.min(...c))})}`);let u=K(this.hass,n).map(y=>this.hass.states[y]).filter(y=>!!y&&y.entity_id.startsWith("binary_sensor.")&&["motion","occupancy","presence"].includes(String(y.attributes.device_class)));if(u.length)if(u.some(y=>y.state==="on"))t.push(`\u{1F6B6} ${this.t("presence_now")}`);else{let y=Math.max(...u.map(F=>Date.parse(String(F.last_changed??""))||0));y>0&&t.push(`\u{1F6B6} ${this.t("presence_last",{time:Po(Date.now()-y)})}`)}let d=this.building?Ja(this.hass,this.building).filter(y=>y.roomId===n.id&&y.level<Ya):[];d.length&&t.push(`\u{1FAAB} ${this.t("battery_low_n",{n:d.length,names:d.map(y=>`${this.name(y.entity)} ${Math.round(y.level)} %`).join(", ")})}`);let p=(this.building?.settings.circuits??[]).filter(y=>y.rooms.includes(n.id)).map(y=>y.name),h=this.building?.settings.room_facts_off??[];p.length&&!h.includes("circuits")&&t.push(`\u{1F50C} ${p.join(", ")}`);let{latitude:g,longitude:b,time_zone:_}=this.hass.config??{};if(this.floor&&g!==void 0&&b!==void 0&&this.building&&!h.includes("sun")){let y=St(this.building,this.floor,n,{latitude:g,longitude:b,zone:_});y.facing.length&&t.push(`\u2600 ${this.t("room_sun_hours",{h:O(this.hass,y.hours,1),facing:y.facing.join(", ")})}`)}let w=Y(this.hass,this.floor,n,"temperature"),M=Y(this.hass,this.floor,n,"humidity"),$=lr(Y(this.hass,this.floor,n,"co2"),M,Mt(w,M));$&&!h.includes("air")&&t.push(`\u{1F4A8} ${this.t(`air_${$}`)}`);let x=cr(w,M,Y(this.hass,this.floor,n,"co2"),st(new Date,this.hass.config?.latitude));return x!==null&&(w!==null||M!==null)&&!h.includes("comfort")&&t.push(`\u{1F60A} ${this.t("comfort_n",{n:x})}`),t}announceSection(e){let t=this.phrases?.length?this.phrases:[1,2,3,4,5].map(i=>this.t(`announce_phrase_${i}`)),n=i=>{let s=i.trim();s&&(clearTimeout(this.saidTimer),this.hass.callService("nextfloor","announce",{message:s,rooms:[e.id],on_screens:!1}).then(()=>this._said={text:this.t("announce_sent",{message:s}),failed:!1},a=>this._said={text:this.t("announce_failed",{error:a?.message??String(a)}),failed:!0}),this.saidTimer=setTimeout(()=>this._said=null,6e3))},o=i=>{i.preventDefault();let s=i.currentTarget.querySelector("input");n(s.value),s.value=""};return this.section("panel_announce",[m`<div class="nf-rp-scenes">${t.map(i=>m`<button class="nf-btn" @click=${()=>n(i)}>${i}</button>`)}</div>
<form class="nf-rp-say" @submit=${o}>
<input type="text" maxlength="500" placeholder=${this.t("announce_placeholder")} aria-label=${this.t("announce_placeholder")} />
<button class="nf-btn nf-primary" type="submit">${this.t("announce_send")}</button>
</form>
${this._said?m`<p class="nf-rp-note ${this._said.failed?"nf-rp-fail":""}" role="status">${this._said.text}</p>`:f}`])}pluginSections(e,t){return es({hass:this.hass,room:{id:e.id,name:e.name,area_id:e.area_id??null},entities:t}).map(o=>m`<div class="nf-rp-sec nf-rp-plugin" data-plugin=${o.key}>
${this._said?m`<p class="nf-rp-note ${this._said.failed?"nf-rp-fail":""}" role="status">${this._said.text}</p>`:f}`])}pluginSections(e,t){return ns({hass:this.hass,room:{id:e.id,name:e.name,area_id:e.area_id??null},entities:t}).map(o=>m`<div class="nf-rp-sec nf-rp-plugin" data-plugin=${o.key}>
<div class="nf-rp-sec-head"><h3>${o.title}</h3></div>
${typeof o.content=="string"?m`<p class="nf-rp-note">${o.content}</p>`:o.content}
</div>`)}section(e,t,n=f){return m`<div class="nf-rp-sec">
<div class="nf-rp-sec-head"><h3>${this.t(e)}</h3>${n}</div>
${t}
</div>`}lightRow(e){let t=e.attributes,n=e.state==="on",o=t.supported_color_modes??[],i=o.some(h=>h!=="onoff"),s=o.includes("color_temp"),a=o.some(h=>["hs","rgb","rgbw","rgbww","xy"].includes(h)),l=typeof t.brightness=="number"?Math.round(t.brightness/255*100):100,c=t.min_color_temp_kelvin??2200,u=t.max_color_temp_kelvin??6500,d=e.entity_id,p=!!this.placedAs(d)?.simple;return m`<div class="nf-rp-row">
<span class="nf-rp-icon ${n?"nf-rp-on":""}">${$t("light")}</span>
<span class="nf-rp-icon ${n?"nf-rp-on":""}">${At("light")}</span>
${this.nameButton(d)}
<span class="nf-rp-state">${this.stateOf(e)}</span>
${this.toggle(e,n,()=>this.call("light","toggle",{entity_id:d}))}
${n&&i&&!p?m`<label class="nf-rp-slider"
${i&&!p?m`<label class="nf-rp-slider"
><span>${this.t("brightness")}</span>
<input
type="range"
@@ -334,47 +334,47 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
@change=${h=>this.call("light","turn_on",{entity_id:d,color_temp_kelvin:Number(h.target.value)})}
/></label>`:f}
${n&&a&&!p?m`<div class="nf-rp-swatches" role="group" aria-label=${this.t("color")}>
${Fh.map(h=>m`<button
${Hh.map(h=>m`<button
class="nf-rp-swatch"
style="--c: rgb(${h.join(",")})"
aria-label="rgb(${h.join(", ")})"
@click=${()=>this.call("light","turn_on",{entity_id:d,rgb_color:h})}
></button>`)}
</div>`:f}
</div>`}coverRow(e){let t=e.attributes,n=t.supported_features??0,o=e.entity_id,i=I(e)&&!Gt(e);return m`<div class="nf-rp-row">
<span class="nf-rp-icon">${$t("cover")}</span>
${this.nameButton(o)}
</div>`}coverRow(e){let t=Xn(this.hass,this.building?.floors??[],e.entity_id);e=er(this.hass,e,t);let n=e.attributes,o=n.supported_features??0,i=e.entity_id,s=I(e)&&!Ut(e);return m`<div class="nf-rp-row">
<span class="nf-rp-icon">${At("cover")}</span>
${this.nameButton(i)}
<span class="nf-rp-state">${this.stateOf(e)}</span>
<div class="nf-rp-buttons">
<button class="nf-btn nf-rp-small" ?disabled=${i} @click=${()=>this.askFor(o)&&this.call("cover","open_cover",{entity_id:o})}>${this.t("cover_open")}</button>
${n&Th?m`<button class="nf-btn nf-rp-small" ?disabled=${i} @click=${()=>this.call("cover","stop_cover",{entity_id:o})}>${this.t("cover_stop")}</button>`:f}
<button class="nf-btn nf-rp-small" ?disabled=${i} @click=${()=>this.askFor(o)&&this.call("cover","close_cover",{entity_id:o})}>${this.t("cover_close")}</button>
<button class="nf-btn nf-rp-small" ?disabled=${s} @click=${()=>this.askFor(i)&&this.call("cover","open_cover",{entity_id:i})}>${this.t("cover_open")}</button>
${o&Ph?m`<button class="nf-btn nf-rp-small" ?disabled=${s} @click=${()=>this.call("cover","stop_cover",{entity_id:i})}>${this.t("cover_stop")}</button>`:f}
<button class="nf-btn nf-rp-small" ?disabled=${s} @click=${()=>this.askFor(i)&&this.call("cover","close_cover",{entity_id:i})}>${this.t("cover_close")}</button>
</div>
${n&zh&&typeof t.current_position=="number"?m`<label class="nf-rp-slider"
${o&Dh&&typeof n.current_position=="number"?m`<label class="nf-rp-slider"
><span>${this.t("position")}</span>
<input
type="range"
min="0"
max="100"
?disabled=${i}
.value=${String(t.current_position)}
@change=${s=>this.call("cover","set_cover_position",{entity_id:o,position:Number(s.target.value)})}
?disabled=${s}
.value=${String(n.current_position)}
@change=${a=>this.call("cover","set_cover_position",{entity_id:i,position:Number(a.target.value)})}
/></label>`:f}
${n&128&&typeof t.current_tilt_position=="number"?m`<label class="nf-rp-slider"
${o&128&&typeof n.current_tilt_position=="number"?m`<label class="nf-rp-slider"
><span>${this.t("cover_tilt")}</span>
<input
type="range"
min="0"
max="100"
?disabled=${i}
.value=${String(t.current_tilt_position)}
@change=${s=>this.call("cover","set_cover_tilt_position",{entity_id:o,tilt_position:Number(s.target.value)})}
/></label>`:n&48?m`<div class="nf-rp-buttons">
${n&16?m`<button class="nf-btn nf-rp-small" ?disabled=${i} @click=${()=>this.call("cover","open_cover_tilt",{entity_id:o})}>${this.t("cover_tilt_open")}</button>`:f}
${n&32?m`<button class="nf-btn nf-rp-small" ?disabled=${i} @click=${()=>this.call("cover","close_cover_tilt",{entity_id:o})}>${this.t("cover_tilt_close")}</button>`:f}
?disabled=${s}
.value=${String(n.current_tilt_position)}
@change=${a=>this.call("cover","set_cover_tilt_position",{entity_id:t??i,tilt_position:Number(a.target.value)})}
/></label>`:o&48?m`<div class="nf-rp-buttons">
${o&16?m`<button class="nf-btn nf-rp-small" ?disabled=${s} @click=${()=>this.call("cover","open_cover_tilt",{entity_id:i})}>${this.t("cover_tilt_open")}</button>`:f}
${o&32?m`<button class="nf-btn nf-rp-small" ?disabled=${s} @click=${()=>this.call("cover","close_cover_tilt",{entity_id:i})}>${this.t("cover_tilt_close")}</button>`:f}
</div>`:f}
</div>`}climateRow(e){let t=e.attributes,n=e.entity_id,o=typeof t.temperature=="number"?t.temperature:null,i=t.target_temp_step??.5,s=t.min_temp??5,a=t.max_temp??30,l=t.hvac_modes??[],c=u=>this.call("climate","set_temperature",{entity_id:n,temperature:Math.min(a,Math.max(s,Math.round(u/i)*i))});return m`<div class="nf-rp-row">
<span class="nf-rp-icon ${t.hvac_action==="heating"?"nf-rp-on":""}">${$t("climate")}</span>
<span class="nf-rp-icon ${t.hvac_action==="heating"?"nf-rp-on":""}">${At("climate")}</span>
${this.nameButton(n)}
<span class="nf-rp-state">${this.stateOf(e)}</span>
${o!==null?m`<div class="nf-rp-stepper nf-rp-wide">
@@ -392,19 +392,19 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
</button>`)}
</div>`:f}
</div>`}stateOf(e,t=ee(this.hass,e)){if(this.room?.no_state?.includes(e.entity_id))return"";let n=D(e.entity_id);return e.state==="unknown"&&n!=="sensor"&&n!=="binary"?"":t}stateLabel(e){let t=`state_${e}`,n=this.t(t);return n===t?e:n}mediaRow(e){let t=e.attributes,n=e.entity_id,o=I(e)||e.state==="off",i=[t.media_title,t.media_artist].filter(s=>typeof s=="string"&&s).join(" \xB7 ");return m`<div class="nf-rp-row">
<span class="nf-rp-icon ${e.state==="playing"?"nf-rp-on":""}">${$t("media")}</span>
<span class="nf-rp-icon ${e.state==="playing"?"nf-rp-on":""}">${At("media")}</span>
${this.nameButton(n)}
<span class="nf-rp-state">${this.stateOf(e,this.stateLabel(e.state))}</span>
${i?m`<p class="nf-rp-media nf-rp-wide">${i}</p>`:f}
<div class="nf-rp-buttons nf-rp-wide">
<button class="nf-btn nf-rp-small" aria-label=${this.t("previous")} ?disabled=${o} @click=${()=>this.call("media_player","media_previous_track",{entity_id:n})}>
${Do(pr.previous)}
${Ho(fr.previous)}
</button>
<button class="nf-btn nf-rp-small" aria-label=${this.t("play_pause")} ?disabled=${I(e)} @click=${()=>this.call("media_player","media_play_pause",{entity_id:n})}>
${Do(e.state==="playing"?pr.pause:pr.play)}
${Ho(e.state==="playing"?fr.pause:fr.play)}
</button>
<button class="nf-btn nf-rp-small" aria-label=${this.t("next")} ?disabled=${o} @click=${()=>this.call("media_player","media_next_track",{entity_id:n})}>
${Do(pr.next)}
${Ho(fr.next)}
</button>
</div>
${typeof t.volume_level=="number"?m`<label class="nf-rp-slider"
@@ -417,15 +417,15 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
@change=${s=>this.call("media_player","volume_set",{entity_id:n,volume_level:Number(s.target.value)/100})}
/></label>`:f}
</div>`}switchRow(e){let t=e.entity_id,n=D(t),o=t.slice(0,t.indexOf(".")),i=n==="lock"?e.state==="unlocked"||e.state==="open":Q(e),s=()=>n==="lock"?this.call("lock",i?"lock":"unlock",{entity_id:t}):this.call(o,"toggle",{entity_id:t});return m`<div class="nf-rp-row">
<span class="nf-rp-icon ${i?"nf-rp-on":""}">${$t(n)}</span>
<span class="nf-rp-icon ${i?"nf-rp-on":""}">${At(n)}</span>
${this.nameButton(t)}
<span class="nf-rp-state">${this.stateOf(e)}</span>
${this.toggle(e,i,s)}
</div>`}sensorRow(e){let t=D(e.entity_id),n=t==="binary"&&e.state==="on";return m`<div class="nf-rp-row">
<span class="nf-rp-icon ${n?"nf-rp-on":""}">${$t(t)}</span>
<span class="nf-rp-icon ${n?"nf-rp-on":""}">${At(t)}</span>
${this.nameButton(e.entity_id)}
<span class="nf-rp-state">${this.stateOf(e)}</span>
</div>`}fire(e){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0}))}static styles=[Se,Ve,te`
</div>`}fire(e){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0}))}static styles=[Se,Ke,te`
:host {
display: block;
}
@@ -806,10 +806,10 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
outline: 2px solid var(--nf-accent);
outline-offset: 2px;
}
`]};customElements.get("nf-room-panel")||customElements.define("nf-room-panel",Po);function sl(r){if(!r)return"";let e=Math.min(.8,Math.max(0,r.dim??.35)),t=r.image&&/^(https:\/\/|\/local\/|\/api\/)[^"'()\\\s]+$/.test(r.image)?r.image:null,n=r.color&&/^#[0-9a-f]{6}$/i.test(r.color)?r.color:null;return t?`;background:linear-gradient(rgba(0,0,0,${e}),rgba(0,0,0,${e})),center / cover no-repeat url("${t}")${n?` ${n}`:""}`:n?`;background:${n}`:""}var Hh=[[/spotify/i,[30,215,96]],[/netflix/i,[229,9,20]],[/youtube/i,[255,0,51]],[/prime|amazon/i,[0,168,225]],[/disney/i,[17,60,207]],[/apple ?music|itunes/i,[250,45,72]],[/apple ?tv/i,[200,200,210]],[/plex/i,[229,160,13]],[/tidal/i,[0,255,255]],[/deezer/i,[162,56,255]],[/radio|tunein/i,[255,140,60]]],al=[34,211,238];function Ho(r){return r?Hh.find(([e])=>e.test(r))?.[1]??al:al}function Io(r){if(r.state==="playing"||r.state==="paused")return!0;let e=t=>typeof r.attributes[t]=="string"&&r.attributes[t]!=="";return r.state==="on"&&(e("media_title")||e("media_channel")||e("source")||e("app_name"))}var Co=r=>r.state==="playing"||r.state==="on"&&Io(r);function ll(r,e){let t=[],n=new Set;for(let o of e){if(!o.entity.startsWith("media_player.")||n.has(o.entity))continue;n.add(o.entity);let i=r.states[o.entity];if(!i)continue;let s=i.attributes,a=u=>typeof s[u]=="string"?s[u]:"",l=a("app_name")||a("source")||a("app_id")||null,c=typeof s.volume_level=="number"?s.volume_level:null;t.push({entity:o.entity,name:o.name,at:o.at,playing:Co(i),title:a("media_title")||a("media_channel")||l||"",artist:a("media_artist")||a("media_album_name")||a("media_series_title"),picture:a("entity_picture")||null,volume:c,color:Ho(l),app:l,group:Array.isArray(s.group_members)?s.group_members.filter(u=>typeof u=="string"&&u!==o.entity):[],rings:o.rings??1})}return t}function cl(r){let e=new Map(r.filter(o=>o.playing).map(o=>[o.entity,o])),t=[],n=new Set;for(let o of e.values())for(let i of o.group){let s=e.get(i),a=[o.entity,i].sort().join("|");s&&!n.has(a)&&(n.add(a),t.push([o,s]))}return t}var Ih=3;function ul(r,e,t){let n=[];for(let o of e.floors)for(let i of o.furniture){if(!i.type.endsWith(":sprinkler"))continue;let s=t?.get(i.id)?.entity??null;!s||!Q(r.states[s])||n.push({id:i.id,at:{floorId:o.id,x:i.x,y:le(o,i)+i.h,z:i.z},reach:Math.min(15,Math.max(.5,i.spray??Ih))})}return n}var mr=r=>r&&r!=="none"?r:null,dl=r=>Math.min(1,Math.max(0,r));function hl(r,e){let t=new Map;for(let n of e.settings.roof?.windows??[]){let o=Ee(r,{cover:mr(n.cover),contact:mr(n.contact),tilt:mr(n.tilt)},"window"),i=mr(n.window),s=i?r.states[i]:void 0,a=o.open;if(s&&!I(s)){let l=s.attributes.current_position;a=typeof l=="number"?dl(l/100):s.state==="open"||s.state==="opening"?1:0}t.set(n.id,{open:a,tilt:o.tilt,cover:o.cover??0})}return t}function Ch(r,e){let t=o=>Math.hypot(o.x-e.x,o.z-e.z);return r.placements.filter(o=>o.entity_id.startsWith("media_player.")&&t(o)<Math.max(2,e.w)).sort((o,i)=>t(o)-t(i))[0]?.entity_id??null}var Ke=(r,e)=>typeof r[e]=="string"?r[e]:"";function pl(r,e,t){let n=[];for(let o of e.floors)for(let i of o.furniture){if(!Yn(i.type))continue;let s=t?.get(i.id)?.entity??null,a=s?.startsWith("media_player.")?s:Ch(o,i),l=a?r.states[a]:void 0;if(!l||!Io(l))continue;let c=l.attributes,u=Ke(c,"app_name")||Ke(c,"source")||null;n.push({id:i.id,furnitureId:i.id,floorId:o.id,color:Ho(u),title:Ke(c,"media_title")||Ke(c,"media_channel")||u||"",subtitle:Ke(c,"media_artist")||Ke(c,"media_series_title")||Ke(c,"media_album_name"),app:u,picture:Ke(c,"entity_picture")||null,playing:Co(l),ambilight:i.ambilight??1})}return n}function ml(r){let e=r.states["sun.sun"]?.attributes;return typeof e?.elevation=="number"&&typeof e.azimuth=="number"?{elevation:e.elevation,azimuth:e.azimuth}:null}function fl(r,e){return(r===null?0:dl((r+4)/16))*(1-.45*e)}function Ge(r,e){return e&&r.states[e]?e:Object.keys(r.states).filter(t=>t.startsWith("weather.")).sort()[0]??null}var fr=new Set(["contact_lost","unlocked_night","own"]);function Nh(r,e){let t=r.states[e.entity];if(!t||["unavailable","unknown"].includes(t.state))return!1;let n=(e.state??"on").trim(),o=/^([<>])\s*(-?\d+(?:[.,]\d+)?)$/.exec(n);if(o){let i=Number(t.state),s=Number(o[2].replace(",","."));return Number.isFinite(i)&&(o[1]==="<"?i<s:i>s)}return n.split(",").map(i=>i.trim().toLowerCase()).filter(Boolean).includes(String(t.state).toLowerCase())}var Oh=600*1e3,Wh=new Set(["rainy","pouring","lightning-rainy","hail","snowy-rainy"]),Lh=new Map([["smoke","smoke"],["gas","gas"],["carbon_monoxide","co"],["moisture","water"]]),gl=(r,e)=>{if(e.startsWith("binary_sensor."))return Lh.get(String(r.states[e]?.attributes.device_class))};function Bh(r,e){let t=new Set,n=[];for(let o of r.floors)for(let i of o.openings){let s=e.get(i.id);for(let a of s?[s.contact,s.contact2,s.tilt,s.tilt2]:[])!a||t.has(a)||(t.add(a),n.push({floorId:o.id,roomId:i.room_id,entity:a}))}return n}function _l(r,e,t,n){let o=[];for(let a of e.floors)for(let l of a.rooms){let c=K(r,l).filter(u=>gl(r,u)); Line truncated
`]};customElements.get("nf-room-panel")||customElements.define("nf-room-panel",Io);function ll(r){if(!r)return"";let e=Math.min(.8,Math.max(0,r.dim??.35)),t=r.image&&/^(https:\/\/|\/local\/|\/api\/)[^"'()\\\s]+$/.test(r.image)?r.image:null,n=r.color&&/^#[0-9a-f]{6}$/i.test(r.color)?r.color:null;return t?`;background:linear-gradient(rgba(0,0,0,${e}),rgba(0,0,0,${e})),center / cover no-repeat url("${t}")${n?` ${n}`:""}`:n?`;background:${n}`:""}var Nh=[[/spotify/i,[30,215,96]],[/netflix/i,[229,9,20]],[/youtube/i,[255,0,51]],[/prime|amazon/i,[0,168,225]],[/disney/i,[17,60,207]],[/apple ?music|itunes/i,[250,45,72]],[/apple ?tv/i,[200,200,210]],[/plex/i,[229,160,13]],[/tidal/i,[0,255,255]],[/deezer/i,[162,56,255]],[/radio|tunein/i,[255,140,60]]],cl=[34,211,238];function Co(r){return r?Nh.find(([e])=>e.test(r))?.[1]??cl:cl}function No(r){if(r.state==="playing"||r.state==="paused")return!0;let e=t=>typeof r.attributes[t]=="string"&&r.attributes[t]!=="";return r.state==="on"&&(e("media_title")||e("media_channel")||e("source")||e("app_name"))}var Oo=r=>r.state==="playing"||r.state==="on"&&No(r);function ul(r,e){let t=[],n=new Set;for(let o of e){if(!o.entity.startsWith("media_player.")||n.has(o.entity))continue;n.add(o.entity);let i=r.states[o.entity];if(!i)continue;let s=i.attributes,a=u=>typeof s[u]=="string"?s[u]:"",l=a("app_name")||a("source")||a("app_id")||null,c=typeof s.volume_level=="number"?s.volume_level:null;t.push({entity:o.entity,name:o.name,at:o.at,playing:Oo(i),title:a("media_title")||a("media_channel")||l||"",artist:a("media_artist")||a("media_album_name")||a("media_series_title"),picture:a("entity_picture")||null,volume:c,color:Co(l),app:l,group:Array.isArray(s.group_members)?s.group_members.filter(u=>typeof u=="string"&&u!==o.entity):[],rings:o.rings??1})}return t}function dl(r){let e=new Map(r.filter(o=>o.playing).map(o=>[o.entity,o])),t=[],n=new Set;for(let o of e.values())for(let i of o.group){let s=e.get(i),a=[o.entity,i].sort().join("|");s&&!n.has(a)&&(n.add(a),t.push([o,s]))}return t}var Oh=3;function hl(r,e,t){let n=[];for(let o of e.floors)for(let i of o.furniture){if(!i.type.endsWith(":sprinkler"))continue;let s=t?.get(i.id)?.entity??null;!s||!Q(r.states[s])||n.push({id:i.id,at:{floorId:o.id,x:i.x,y:le(o,i)+i.h,z:i.z},reach:Math.min(15,Math.max(.5,i.spray??Oh))})}return n}var gr=r=>r&&r!=="none"?r:null,pl=r=>Math.min(1,Math.max(0,r));function ml(r,e){let t=new Map;for(let n of e.settings.roof?.windows??[]){let o=Ee(r,{cover:gr(n.cover),contact:gr(n.contact),tilt:gr(n.tilt)},"window"),i=gr(n.window),s=i?r.states[i]:void 0,a=o.open;if(s&&!I(s)){let l=s.attributes.current_position;a=typeof l=="number"?pl(l/100):s.state==="open"||s.state==="opening"?1:0}t.set(n.id,{open:a,tilt:o.tilt,cover:o.cover??0})}return t}function Wh(r,e){let t=o=>Math.hypot(o.x-e.x,o.z-e.z);return r.placements.filter(o=>o.entity_id.startsWith("media_player.")&&t(o)<Math.max(2,e.w)).sort((o,i)=>t(o)-t(i))[0]?.entity_id??null}var Ge=(r,e)=>typeof r[e]=="string"?r[e]:"";function fl(r,e,t){let n=[];for(let o of e.floors)for(let i of o.furniture){if(!Yn(i.type))continue;let s=t?.get(i.id)?.entity??null,a=s?.startsWith("media_player.")?s:Wh(o,i),l=a?r.states[a]:void 0;if(!l||!No(l))continue;let c=l.attributes,u=Ge(c,"app_name")||Ge(c,"source")||null;n.push({id:i.id,furnitureId:i.id,floorId:o.id,color:Co(u),title:Ge(c,"media_title")||Ge(c,"media_channel")||u||"",subtitle:Ge(c,"media_artist")||Ge(c,"media_series_title")||Ge(c,"media_album_name"),app:u,picture:Ge(c,"entity_picture")||null,playing:Oo(l),ambilight:i.ambilight??1})}return n}function gl(r){let e=r.states["sun.sun"]?.attributes;return typeof e?.elevation=="number"&&typeof e.azimuth=="number"?{elevation:e.elevation,azimuth:e.azimuth}:null}function _l(r,e){return(r===null?0:pl((r+4)/16))*(1-.45*e)}function Ue(r,e){return e&&r.states[e]?e:Object.keys(r.states).filter(t=>t.startsWith("weather.")).sort()[0]??null}var _r=new Set(["contact_lost","unlocked_night","own"]);function Lh(r,e){let t=r.states[e.entity];if(!t||["unavailable","unknown"].includes(t.state))return!1;let n=(e.state??"on").trim(),o=/^([<>])\s*(-?\d+(?:[.,]\d+)?)$/.exec(n);if(o){let i=Number(t.state),s=Number(o[2].replace(",","."));return Number.isFinite(i)&&(o[1]==="<"?i<s:i>s)}return n.split(",").map(i=>i.trim().toLowerCase()).filter(Boolean).includes(String(t.state).toLowerCase())}var Bh=600*1e3,Vh=new Set(["rainy","pouring","lightning-rainy","hail","snowy-rainy"]),Kh=new Map([["smoke","smoke"],["gas","gas"],["carbon_monoxide","co"],["moisture","water"]]),bl=(r,e)=>{if(e.startsWith("binary_sensor."))return Kh.get(String(r.states[e]?.attributes.device_class))};function Gh(r,e){let t=new Set,n=[];for(let o of r.floors)for(let i of o.openings){let s=e.get(i.id);for(let a of s?[s.contact,s.contact2,s.tilt,s.tilt2]:[])!a||t.has(a)||(t.add(a),n.push({floorId:o.id,roomId:i.room_id,entity:a}))}return n}function wl(r,e,t,n){let o=[];for(let a of e.floors)for(let l of a.rooms){let c=K(r,l).filter(u=>bl(r,u)); Line truncated
${J`<circle cx="27" cy="27" r=${22} class="live-ring-bg"></circle>
<circle cx="27" cy="27" r=${22} stroke=${e} stroke-dasharray=${`${(n*Math.max(0,Math.min(1,r))).toFixed(1)} ${n.toFixed(1)}`} transform="rotate(-90 27 27)" class="live-ring-fg"></circle>`}
</svg>`}function Qp(r,e,t,n){let o=e.summary,i=c=>R(r,c),s=e.autarky,a=n?m`<button class="live-fold" title=${i(n.folded?"live_unfold":"live_fold")} aria-label=${i(n.folded?"live_unfold":"live_fold")} aria-expanded=${!n.folded} @click=${n.toggle}>${n.folded?"+":"\u2212"}</button>`:f;if(n?.folded){let c=o.solar!==null?`\u2600 ${Me(r,o.solar)}`:o.consumption!==null?`\u2302 ${Me(r,o.consumption)}`:null;return m`<div class="live-card live-card-house live-folded" data-i=${t}>
</svg>`}function tm(r,e,t,n){let o=e.summary,i=c=>R(r,c),s=e.autarky,a=n?m`<button class="live-fold" title=${i(n.folded?"live_unfold":"live_fold")} aria-label=${i(n.folded?"live_unfold":"live_fold")} aria-expanded=${!n.folded} @click=${n.toggle}>${n.folded?"+":"\u2212"}</button>`:f;if(n?.folded){let c=o.solar!==null?`\u2600 ${Me(r,o.solar)}`:o.consumption!==null?`\u2302 ${Me(r,o.consumption)}`:null;return m`<div class="live-card live-card-house live-folded" data-i=${t}>
${s!==null?m`<div class="live-own">${gn(s,s>.95?"#4ade80":s>.6?"#facc15":"#f87171")}<div class="live-own-text"><b>${Math.round(s*100)}%</b></div></div>`:f}
${c?m`<b>${c}</b>`:s===null?m`<b>⌂</b>`:f}
${a}
@@ -817,19 +817,19 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
${a}
${s!==null?m`<div class="live-own">${gn(s,s>.95?"#4ade80":s>.6?"#facc15":"#f87171")}<div class="live-own-text"><b>${Math.round(s*100)} %</b><span>${i("live_autarky")}</span></div></div>`:f}
<div class="live-rows">${l}</div>
${em(r,e.curves)} ${Xp(r,e.week)}
</div>`}function Xp(r,e){if(!e)return f;let t=[...e.solar,...e.use].filter(c=>c!==null&&c>0);if(!t.length)return f;let n=Math.max(...t)*1.1||1,[o,i]=[150,30],s=o/7,a=(c,u,d)=>c===null||c<=0?f:J`<rect x=${u.toFixed(1)} y=${(i-c/n*i).toFixed(1)} width=${(s*.36).toFixed(1)} height=${(c/n*i).toFixed(1)} class=${d}></rect>`,l=c=>c.reduce((u,d)=>u+(d??0),0);return m`<div class="live-day live-week" title=${R(r,"live_week_hint",{solar:O(r,l(e.solar),0),use:O(r,l(e.use),0)})}>
${rm(r,e.curves)} ${nm(r,e.week)}
</div>`}function nm(r,e){if(!e)return f;let t=[...e.solar,...e.use].filter(c=>c!==null&&c>0);if(!t.length)return f;let n=Math.max(...t)*1.1||1,[o,i]=[150,30],s=o/7,a=(c,u,d)=>c===null||c<=0?f:J`<rect x=${u.toFixed(1)} y=${(i-c/n*i).toFixed(1)} width=${(s*.36).toFixed(1)} height=${(c/n*i).toFixed(1)} class=${d}></rect>`,l=c=>c.reduce((u,d)=>u+(d??0),0);return m`<div class="live-day live-week" title=${R(r,"live_week_hint",{solar:O(r,l(e.solar),0),use:O(r,l(e.use),0)})}>
<svg viewBox=${`0 0 ${o} ${i}`} preserveAspectRatio="none" aria-hidden="true">
${e.days.map((c,u)=>J`${a(e.solar[u],u*s+s*.1,"live-week-solar")}${a(e.use[u],u*s+s*.5,"live-week-use")}`)}
</svg>
<span>7 ${R(r,"live_days")}</span>
</div>`}function em(r,e){if(!e)return f;let t=[...e.solar,...e.use].filter(l=>l!==null);if(t.length<4)return f;let n=Math.max(...t)*1.08||1,[o,i]=[150,34],s=sn(e.solar,o,i,n),a=sn(e.use,o,i,n);return m`<div class="live-day" title=${R(r,"live_day_hint")}>
</div>`}function rm(r,e){if(!e)return f;let t=[...e.solar,...e.use].filter(l=>l!==null);if(t.length<4)return f;let n=Math.max(...t)*1.08||1,[o,i]=[150,34],s=sn(e.solar,o,i,n),a=sn(e.use,o,i,n);return m`<div class="live-day" title=${R(r,"live_day_hint")}>
<svg viewBox=${`0 0 ${o} ${i}`} preserveAspectRatio="none" aria-hidden="true">
${s?J`<path d=${`${s}L${o},${i}L0,${i}Z`} class="live-day-solar"></path>`:f}
${a?J`<path d=${a} class="live-day-use"></path>`:f}
</svg>
<span>24 h</span>
</div>`}function tm(r,e,t,n){let o=e.car,i=(u,d)=>R(r,u,d),s=cc(o.soc),a=o.home?o.charging?`\u26A1 ${i("live_car_charging")}${o.chargingW?` \xB7 ${Me(r,o.chargingW)}`:""}`:o.plugged?`\u{1F50C} ${i("live_car_plugged")}`:"":`${i("live_car_away")}${o.where?` \xB7 ${o.where}`:""}${o.distance!==null?` \xB7 ${O(r,o.distance,o.distance<10?1:0)} km`:""}`,l=o.entities,c=(u,d,p,h)=>m`<button class="live-btn ${u?"live-on":""}" title=${d} aria-label=${d} aria-pressed=${u??!1} @click=${w=>(w.stopPropagation(),h())}>${p}</button>`;return m`<div class="live-card live-card-car ${o.charging?"live-charging":""} ${o.home?"":"live-away"}" data-i=${t} style=${`--live-soc:${s}`}>
</div>`}function om(r,e,t,n){let o=e.car,i=(u,d)=>R(r,u,d),s=dc(o.soc),a=o.home?o.charging?`\u26A1 ${i("live_car_charging")}${o.chargingW?` \xB7 ${Me(r,o.chargingW)}`:""}`:o.plugged?`\u{1F50C} ${i("live_car_plugged")}`:"":`${i("live_car_away")}${o.where?` \xB7 ${o.where}`:""}${o.distance!==null?` \xB7 ${O(r,o.distance,o.distance<10?1:0)} km`:""}`,l=o.entities,c=(u,d,p,h)=>m`<button class="live-btn ${u?"live-on":""}" title=${d} aria-label=${d} aria-pressed=${u??!1} @click=${g=>(g.stopPropagation(),h())}>${p}</button>`;return m`<div class="live-card live-card-car ${o.charging?"live-charging":""} ${o.home?"":"live-away"}" data-i=${t} style=${`--live-soc:${s}`}>
<div class="live-own">
${gn((o.soc??0)/100,s)}
<div class="live-own-text"><b>${o.soc!==null?`${Math.round(o.soc)} %`:"\u2013"}</b><span>${o.range!==null?`${Math.round(o.range)} ${o.rangeUnit}`:""}</span></div>
@@ -846,7 +846,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
${l.charge&&o.home?c(o.charging,i("live_car_charge"),"\u26A1",()=>n(l.charge.split(".")[0],"toggle",l.charge)):f}
</div>
</div>
</div>`}function nm(r,e,t,n){let o=e.media,i=l=>R(r,l),s=`rgb(${o.color.join(",")})`,a=(l,c,u)=>m`<button class="live-btn" title=${l} aria-label=${l} @click=${d=>(d.stopPropagation(),n("media_player",u,o.entity))}>${c}</button>`;return m`<div class="live-card live-card-media" data-i=${t} style=${`--live-soc:${s}`} @click=${l=>l.currentTarget.classList.toggle("live-open")}>
</div>`}function im(r,e,t,n){let o=e.media,i=l=>R(r,l),s=`rgb(${o.color.join(",")})`,a=(l,c,u)=>m`<button class="live-btn" title=${l} aria-label=${l} @click=${d=>(d.stopPropagation(),n("media_player",u,o.entity))}>${c}</button>`;return m`<div class="live-card live-card-media" data-i=${t} style=${`--live-soc:${s}`} @click=${l=>l.currentTarget.classList.toggle("live-open")}>
${o.picture?m`<img class="live-cover" src=${o.picture} alt="" loading="lazy" />`:m`<div class="live-cover live-cover-none">♪</div>`}
<div class="live-rows">
<div class="live-title" title=${o.title}>${o.title||o.name}</div>
@@ -865,7 +865,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
/>`:f}
</div>
</div>
</div>`}function uc(r){let e=[...r.querySelectorAll(".live-card")].filter(i=>i.style.visibility!=="hidden"),t=[],n=e[0]?.parentElement?.clientWidth??0,o=e.map(i=>{let[s,a]=[Number(i.dataset.x),i.offsetWidth],l=n?n>a+16?Math.min(Math.max(s,a/2+8),n-a/2-8):n/2:s;return i.style.setProperty("--live-dx",`${Math.round(s-l)}px`),{el:i,x:l,y:Number(i.dataset.y),w:a,h:i.offsetHeight}}).sort((i,s)=>s.y-i.y);for(let i of o){let s=i.y;for(let l=0;l<12;l++){let c={x0:i.x-i.w/2,x1:i.x+i.w/2,y0:s-i.h,y1:s},u=t.find(d=>c.x0<d.x1+6&&c.x1>d.x0-6&&c.y0<d.y1+6&&c.y1>d.y0-6);if(!u)break;s=u.y0-8}t.push({x0:i.x-i.w/2,x1:i.x+i.w/2,y0:s-i.h,y1:s});let a=i.y-s;i.el.style.transform=`translate(${Math.round(i.x)}px, ${Math.round(s)}px) translate(-50%, -100%)`,i.el.style.setProperty("--live-thread",`${Math.round(18+a)}px`)}}function rm(r,e,t){let n=e.printer,o=(c,u)=>R(r,c,u),i=n.progress??0,s=c=>new Intl.DateTimeFormat(r?.language??navigator.language,{hour:"2-digit",minute:"2-digit"}).format(new Date(c)),a=n.remaining!==null?n.remaining>=60?`${Math.floor(n.remaining/60)} h ${Math.round(n.remaining%60)} min`:`${Math.round(n.remaining)} min`:null,l=[n.nozzle!==null?`${o("printer_nozzle")} ${Math.round(n.nozzle)}\xB0`:null,n.bed!==null?`${o("printer_bed")} ${Math.round(n.bed)}\xB0`:null].filter(Boolean).join(" \xB7 ");return m`<div class="live-card live-card-printer ${n.printing?"live-charging":""}" data-i=${t}>
</div>`}function hc(r){let e=[...r.querySelectorAll(".live-card")].filter(i=>i.style.visibility!=="hidden"),t=[],n=e[0]?.parentElement?.clientWidth??0,o=e.map(i=>{let[s,a]=[Number(i.dataset.x),i.offsetWidth],l=n?n>a+16?Math.min(Math.max(s,a/2+8),n-a/2-8):n/2:s;return i.style.setProperty("--live-dx",`${Math.round(s-l)}px`),{el:i,x:l,y:Number(i.dataset.y),w:a,h:i.offsetHeight}}).sort((i,s)=>s.y-i.y);for(let i of o){let s=i.y;for(let l=0;l<12;l++){let c={x0:i.x-i.w/2,x1:i.x+i.w/2,y0:s-i.h,y1:s},u=t.find(d=>c.x0<d.x1+6&&c.x1>d.x0-6&&c.y0<d.y1+6&&c.y1>d.y0-6);if(!u)break;s=u.y0-8}t.push({x0:i.x-i.w/2,x1:i.x+i.w/2,y0:s-i.h,y1:s});let a=i.y-s;i.el.style.transform=`translate(${Math.round(i.x)}px, ${Math.round(s)}px) translate(-50%, -100%)`,i.el.style.setProperty("--live-thread",`${Math.round(18+a)}px`)}}function sm(r,e,t){let n=e.printer,o=(c,u)=>R(r,c,u),i=n.progress??0,s=c=>new Intl.DateTimeFormat(r?.language??navigator.language,{hour:"2-digit",minute:"2-digit"}).format(new Date(c)),a=n.remaining!==null?n.remaining>=60?`${Math.floor(n.remaining/60)} h ${Math.round(n.remaining%60)} min`:`${Math.round(n.remaining)} min`:null,l=[n.nozzle!==null?`${o("printer_nozzle")} ${Math.round(n.nozzle)}\xB0`:null,n.bed!==null?`${o("printer_bed")} ${Math.round(n.bed)}\xB0`:null].filter(Boolean).join(" \xB7 ");return m`<div class="live-card live-card-printer ${n.printing?"live-charging":""}" data-i=${t}>
<div class="live-own">
${n.picture?m`<img class="live-print-pic" src=${n.picture} alt="" />`:gn(i/100,n.printing?"#38bdf8":"#8aa0c8")}
<div class="live-own-text"><b>${n.progress!==null?`${Math.round(i)} %`:"\u2013"}</b><span>${o(`printer_${n.printing?"printing":/finish|complete|fertig/.test(n.status)?"done":/pause/.test(n.status)?"paused":/error|fail/.test(n.status)?"error":"idle"}`)}</span></div>
@@ -878,7 +878,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
${l?m`<div class="live-status">🌡 ${l}</div>`:f}
${n.filaments.length?m`<div class="live-filaments">${n.filaments.map(c=>m`<i style=${`background:${c}`}></i>`)}</div>`:f}
</div>
</div>`}function om(r,e,t){let n=e.pump,o=a=>R(r,a),i=a=>a===null?"\u2013":`${O(r,a,1)}\xB0`,s={heating:"\u{1F525}",water:"\u{1F6BF}",cooling:"\u2744",defrost:"\u{1F9CA}",idle:"\u23F8"}[n.mode];return m`<div class="live-card live-card-heatpump ${n.mode==="idle"?"":"live-charging"}" data-i=${t}>
</div>`}function am(r,e,t){let n=e.pump,o=a=>R(r,a),i=a=>a===null?"\u2013":`${O(r,a,1)}\xB0`,s={heating:"\u{1F525}",water:"\u{1F6BF}",cooling:"\u2744",defrost:"\u{1F9CA}",idle:"\u23F8"}[n.mode];return m`<div class="live-card live-card-heatpump ${n.mode==="idle"?"":"live-charging"}" data-i=${t}>
<div class="live-own">
${gn(Math.min(1,(n.cop??0)/6),(n.cop??0)>=3.5?"#4ade80":(n.cop??0)>=2.5?"#facc15":"#fb923c")}
<div class="live-own-text"><b>${n.cop!==null?O(r,n.cop,1):s}</b><span>${n.cop!==null?"COP":""}</span></div>
@@ -891,9 +891,9 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
${n.power!==null?m`<div class="live-row live-house"><span>${o("heatpump_power")}</span><b>${Me(r,n.power)}</b></div>`:f}
${n.outside!==null?m`<div class="live-status">🌡 ${o("heatpump_outside")} ${i(n.outside)}</div>`:f}
</div>
</div>`}function dc(r,e,t,n){return e.length?m`<div class="live-cards">
${e.map((o,i)=>o.kind==="house"?Qp(r,o,i,n):o.kind==="car"?tm(r,o,i,t):o.kind==="printer"?rm(r,o,i):o.kind==="heatpump"?om(r,o,i):nm(r,o,i,t))}
</div>`:f}var hc=te`
</div>`}function pc(r,e,t,n){return e.length?m`<div class="live-cards">
${e.map((o,i)=>o.kind==="house"?tm(r,o,i,n):o.kind==="car"?om(r,o,i,t):o.kind==="printer"?sm(r,o,i):o.kind==="heatpump"?am(r,o,i):im(r,o,i,t))}
</div>`:f}var mc=te`
.live-cards {
position: absolute;
inset: 0;
@@ -1199,7 +1199,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
text-transform: uppercase;
letter-spacing: 0.04em;
}
`;function Ar(r){return r.toLocaleLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),"")}var ri=r=>r.points.length>=3;function pc(r,e,t){return r.rooms.filter(ri).find(n=>H([e,t],n.points))}function im(r,e,t,n){let o=[];for(let a of e.rooms.filter(ri)){let[l,c]=We(a.points);o.push({kind:"room",name:a.name,where:n?e.name:"",floorId:e.id,roomId:a.id,entity:null,icon:null,x:l,z:c,y:0})}let i=new Set,s=(a,l,c,u)=>{if(i.has(a)||!(a in r.states))return;i.add(a);let d=pc(e,l,c),p=[d?.name,n?e.name:void 0].filter(h=>!!h).join(" \xB7 ");o.push({kind:"device",name:L(r,a),where:p,floorId:e.id,roomId:d?.id??null,entity:a,icon:D(a),x:l,z:c,y:u})};for(let a of e.placements){let l=a.y??_t(D(a.entity_id)??"sensor",me(e,a.x,a.z),a.mount);s(a.entity_id,a.x,a.z,l)}for(let a of e.furniture){let l=t.get(a.id),c=l?.entity??l?.power;if(!c)continue;let u=me(e,a.x,a.z)-.3;s(c,a.x,a.z,Math.min(u,Math.max(.5,a.h)))}for(let a of e.notes??[]){if(!a.text)continue;let l=pc(e,a.x,a.z),c=[l?.name,n?e.name:void 0].filter(u=>!!u).join(" \xB7 ");o.push({kind:"note",name:`\u270E ${a.text.length>60?`${a.text.slice(0,59)}\u2026`:a.text}`,where:c,floorId:e.id,roomId:l?.id??null,entity:null,icon:null,x:a.x,z:a.z,y:1.3})}return o}function mc(r,e){let t=nt(r,e.floors),n=e.floors.length>1,o=e.floors.flatMap(i=>im(r,i,t,n));for(let i of e.settings.circuits??[]){let s=e.floors.flatMap(d=>d.rooms.filter(p=>i.rooms.includes(p.id)&&ri(p)).map(p=>({f:d,r:p})));if(!s.length)continue;let[{f:a,r:l}]=s,[c,u]=We(l.points);o.push({kind:"circuit",name:`\u{1F50C} ${i.name}`,where:s.map(d=>d.r.name).join(", "),floorId:a.id,roomId:l.id,entity:null,icon:null,x:c,z:u,y:0})}return o}function sm(r,e){return(Ar(r.name).startsWith(e)?0:2)+(r.kind==="room"?0:1)}function fc(r,e,t=8){let n=Ar(e).split(/\s+/).filter(Boolean);if(n.length===0)return[];let o=Ar(e.trim());return r.filter(i=>{let s=Ar([i.name,i.where,i.entity].filter(Boolean).join(" "));return n.every(a=>s.includes(a))}).map(i=>({item:i,cost:sm(i,o)})).sort((i,s)=>i.cost-s.cost||i.item.name.localeCompare(s.item.name)).slice(0,t).map(i=>i.item)}var am=[[255,181,71],[255,236,210],[55,224,255],[91,124,255],[190,90,255],[255,95,210],[255,70,70],[120,255,150]],lm=[2200,2700,3200,4e3,5e3,6500],cm=["hs","rgb","rgbw","rgbww","xy"],um=4,gc=16,_c=32,dm=128;function ii(r){let e=r.attributes.supported_color_modes??[],t=e.some(n=>cm.includes(n));return{dim:e.some(n=>n!=="onoff"),color:t,temp:e.includes("color_temp")}}function si(r){return((r.attributes.supported_features??0)&um)!==0&&typeof r.attributes.current_position=="number"}var oi=class extends re{static properties={hass:{attribute:!1},entity:{attribute:!1},car:{attribute:!1},presets:{attribute:!1},confirmSwitch:{type:Boolean},myPosition:{attribute:!1},low:{type:Boolean,reflect:!0}};t(e,t){return R(this.hass,e,t)}ask(){return!this.confirmSwitch||confirm(this.t("confirm_switch",{name:L(this.hass,this.entity)}))}call(e,t,n={}){this.hass.callService(e,t,{entity_id:this.entity,...n})}close(){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}details(){fe(this,this.entity),this.close()}ring(e){let t=e.length;return e.map((n,o)=>{let i=o/t*Math.PI*2-Math.PI/2;return m`<div class="qm-at" style="left:${50+Math.cos(i)*39}%;top:${50+Math.sin(i)*39}%">${n}</div>`})}renderLight(e){let t=ii(e),n=e.state==="on",o=n&&typeof e.attributes.brightness=="number"?Math.round(e.attributes.brightness/2.55):n?100:0,i=t.color?am.map(s=>m`<button class="qm-swatch" style="background:rgb(${s.join(",")})" aria-label=${`RGB ${s.join(", ")}`} @click=${()=>this.call("light","turn_on",{rgb_color:s})}></button>`):t.temp?lm.map(s=>m`<button class="qm-swatch" style="background:${hm(s)}" aria-label=${`${s} K`} @click=${()=>this.call("light","turn_on",{color_temp_kelvin:s})}></button>`):[];return m`<div class="qm-ring ${i.length?"":"qm-ring-small"}">
`;function Rr(r){return r.toLocaleLowerCase().normalize("NFD").replace(new RegExp("\\p{M}","gu"),"")}var ii=r=>r.points.length>=3;function fc(r,e,t){return r.rooms.filter(ii).find(n=>H([e,t],n.points))}function lm(r,e,t,n){let o=[];for(let a of e.rooms.filter(ii)){let[l,c]=We(a.points);o.push({kind:"room",name:a.name,where:n?e.name:"",floorId:e.id,roomId:a.id,entity:null,icon:null,x:l,z:c,y:0})}let i=new Set,s=(a,l,c,u)=>{if(i.has(a)||!(a in r.states))return;i.add(a);let d=fc(e,l,c),p=[d?.name,n?e.name:void 0].filter(h=>!!h).join(" \xB7 ");o.push({kind:"device",name:L(r,a),where:p,floorId:e.id,roomId:d?.id??null,entity:a,icon:D(a),x:l,z:c,y:u})};for(let a of e.placements){let l=a.y??wt(D(a.entity_id)??"sensor",me(e,a.x,a.z),a.mount);s(a.entity_id,a.x,a.z,l)}for(let a of e.furniture){let l=t.get(a.id),c=l?.entity??l?.power;if(!c)continue;let u=me(e,a.x,a.z)-.3;s(c,a.x,a.z,Math.min(u,Math.max(.5,a.h)))}for(let a of e.notes??[]){if(!a.text)continue;let l=fc(e,a.x,a.z),c=[l?.name,n?e.name:void 0].filter(u=>!!u).join(" \xB7 ");o.push({kind:"note",name:`\u270E ${a.text.length>60?`${a.text.slice(0,59)}\u2026`:a.text}`,where:c,floorId:e.id,roomId:l?.id??null,entity:null,icon:null,x:a.x,z:a.z,y:1.3})}return o}function gc(r,e){let t=ot(r,e.floors),n=e.floors.length>1,o=e.floors.flatMap(i=>lm(r,i,t,n));for(let i of e.settings.circuits??[]){let s=e.floors.flatMap(d=>d.rooms.filter(p=>i.rooms.includes(p.id)&&ii(p)).map(p=>({f:d,r:p})));if(!s.length)continue;let[{f:a,r:l}]=s,[c,u]=We(l.points);o.push({kind:"circuit",name:`\u{1F50C} ${i.name}`,where:s.map(d=>d.r.name).join(", "),floorId:a.id,roomId:l.id,entity:null,icon:null,x:c,z:u,y:0})}return o}function cm(r,e){return(Rr(r.name).startsWith(e)?0:2)+(r.kind==="room"?0:1)}function _c(r,e,t=8){let n=Rr(e).split(/\s+/).filter(Boolean);if(n.length===0)return[];let o=Rr(e.trim());return r.filter(i=>{let s=Rr([i.name,i.where,i.entity].filter(Boolean).join(" "));return n.every(a=>s.includes(a))}).map(i=>({item:i,cost:cm(i,o)})).sort((i,s)=>i.cost-s.cost||i.item.name.localeCompare(s.item.name)).slice(0,t).map(i=>i.item)}var um=[[255,181,71],[255,236,210],[55,224,255],[91,124,255],[190,90,255],[255,95,210],[255,70,70],[120,255,150]],dm=[2200,2700,3200,4e3,5e3,6500],hm=["hs","rgb","rgbw","rgbww","xy"],pm=4,bc=16,wc=32,mm=128;function ai(r){let e=r.attributes.supported_color_modes??[],t=e.some(n=>hm.includes(n));return{dim:e.some(n=>n!=="onoff"),color:t,temp:e.includes("color_temp")}}function li(r){return((r.attributes.supported_features??0)&pm)!==0&&typeof r.attributes.current_position=="number"}var si=class extends re{static properties={hass:{attribute:!1},entity:{attribute:!1},car:{attribute:!1},presets:{attribute:!1},confirmSwitch:{type:Boolean},myPosition:{attribute:!1},tiltEntity:{attribute:!1},low:{type:Boolean,reflect:!0}};t(e,t){return R(this.hass,e,t)}ask(){return!this.confirmSwitch||confirm(this.t("confirm_switch",{name:L(this.hass,this.entity)}))}call(e,t,n={}){this.hass.callService(e,t,{entity_id:this.entity,...n})}close(){this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}details(){fe(this,this.entity),this.close()}ring(e){let t=e.length;return e.map((n,o)=>{let i=o/t*Math.PI*2-Math.PI/2;return m`<div class="qm-at" style="left:${50+Math.cos(i)*39}%;top:${50+Math.sin(i)*39}%">${n}</div>`})}renderLight(e){let t=ai(e),n=e.state==="on",o=n&&typeof e.attributes.brightness=="number"?Math.round(e.attributes.brightness/2.55):n?100:0,i=t.color?um.map(s=>m`<button class="qm-swatch" style="background:rgb(${s.join(",")})" aria-label=${`RGB ${s.join(", ")}`} @click=${()=>this.call("light","turn_on",{rgb_color:s})}></button>`):t.temp?dm.map(s=>m`<button class="qm-swatch" style="background:${fm(s)}" aria-label=${`${s} K`} @click=${()=>this.call("light","turn_on",{color_temp_kelvin:s})}></button>`):[];return m`<div class="qm-ring ${i.length?"":"qm-ring-small"}">
${this.ring(i)}
<button class="qm-power ${n?"qm-on":""}" aria-pressed=${n} @click=${()=>this.ask()&&this.call("light","toggle")}>
<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M12 3v8M6.3 6.8a8 8 0 1 0 11.4 0" /></svg>
@@ -1214,7 +1214,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
.value=${String(Math.max(1,o))}
aria-label=${this.t("brightness")}
@change=${s=>this.call("light","turn_on",{brightness_pct:Number(s.target.value)})}
/>`:f}`}renderCover(e){let t=typeof e.attributes.current_position=="number"?e.attributes.current_position:null,n=e.state==="opening"||e.state==="closing",o=si(e),i=(u,d,p,h=!1)=>m`<button class="qm-swatch qm-slot ${h?"qm-slot-on":""}" aria-label=${d} @click=${p}>${u}</button>`,s=u=>t!==null&&Math.abs(t-u)<3,a=[i("\u25B2",this.t("cover_open"),()=>this.ask()&&this.call("cover","open_cover"),s(100)),...o?[75,50].map(u=>i(`${u}`,`${u} %`,()=>this.ask()&&this.call("cover","set_cover_position",{position:u}),s(u))):[],i("\u25BC",this.t("cover_close"),()=>this.ask()&&this.call("cover","close_cover"),s(0)),...o?[25].map(u=>i(`${u}`,`${u} %`,()=>this.ask()&&this.call("cover","set_cover_position",{position:u}),s(u))):[],i("\u25A0",this.t("cover_stop"),()=>this.call("cover","stop_cover"),n),...this.myPosition!=null?[i("My",this.t("cover_my_go",{p:this.myPosition}),()=>this.ask()&&(o?this.call("cover","set_cover_position",{position:this.myPosition}):this.call("cover","stop_cover")),s(this.myPosition))]:[]],l=t===null?e.state==="closed"?100:0:100-t,c=t!==null||n||e.state==="open"||e.state==="closed";return m`<div class="qm-ring">
/>`:f}`}renderCover(e){e=er(this.hass,e,this.tiltEntity);let t=typeof e.attributes.current_position=="number"?e.attributes.current_position:null,n=e.state==="opening"||e.state==="closing",o=li(e),i=(u,d,p,h=!1)=>m`<button class="qm-swatch qm-slot ${h?"qm-slot-on":""}" aria-label=${d} @click=${p}>${u}</button>`,s=u=>t!==null&&Math.abs(t-u)<3,a=[i("\u25B2",this.t("cover_open"),()=>this.ask()&&this.call("cover","open_cover"),s(100)),...o?[75,50].map(u=>i(`${u}`,`${u} %`,()=>this.ask()&&this.call("cover","set_cover_position",{position:u}),s(u))):[],i("\u25BC",this.t("cover_close"),()=>this.ask()&&this.call("cover","close_cover"),s(0)),...o?[25].map(u=>i(`${u}`,`${u} %`,()=>this.ask()&&this.call("cover","set_cover_position",{position:u}),s(u))):[],...Number(e.attributes.supported_features??0)&8?[i("\u25A0",this.t("cover_stop"),()=>this.call("cover","stop_cover"),n)]:[],...this.myPosition!=null&&(o||Number(e.attributes.supported_features??0)&8)?[i("My",this.t("cover_my_go",{p:this.myPosition}),()=>this.ask()&&(o?this.call("cover","set_cover_position",{position:this.myPosition}):this.call("cover","stop_cover")),s(this.myPosition))]:[]],l=t===null?e.state==="closed"?100:0:100-t,c=t!==null||n||e.state==="open"||e.state==="closed";return m`<div class="qm-ring">
${this.ring(a)}
<button
class="qm-power qm-blind ${c&&l<100?"qm-on":""}"
@@ -1236,8 +1236,8 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
aria-label=${this.t("position")}
@change=${u=>this.call("cover","set_cover_position",{position:Number(u.target.value)})}
/>`:f}
${this.renderTilt(e)}`}renderTilt(e){let t=(e.attributes.supported_features??0)|0,n=typeof e.attributes.current_tilt_position=="number"?e.attributes.current_tilt_position:null;return t&dm&&n!==null?m`<label class="qm-tilt"
><span>${this.t("cover_tilt")} · ${n} %</span>
${this.renderTilt(e)}`}renderTilt(e){let t=(e.attributes.supported_features??0)|0,n=typeof e.attributes.current_tilt_position=="number"?e.attributes.current_tilt_position:null;return t&mm&&n!==null?m`<label class="qm-tilt"
><span>${this.t("cover_tilt")} · ${Math.round(n)} %</span>
<input
class="qm-slider"
type="range"
@@ -1245,10 +1245,10 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
max="100"
.value=${String(n)}
aria-label=${this.t("cover_tilt")}
@change=${o=>this.call("cover","set_cover_tilt_position",{tilt_position:Number(o.target.value)})}
/></label>`:t&(gc|_c)?m`<div class="qm-tilt-buttons">
${t&gc?m`<button class="qm-swatch qm-slot" @click=${()=>this.call("cover","open_cover_tilt")}>${this.t("cover_tilt_open")}</button>`:f}
${t&_c?m`<button class="qm-swatch qm-slot" @click=${()=>this.call("cover","close_cover_tilt")}>${this.t("cover_tilt_close")}</button>`:f}
@change=${o=>this.call("cover","set_cover_tilt_position",{entity_id:this.tiltEntity||this.entity,tilt_position:Number(o.target.value)})}
/></label>`:t&(bc|wc)?m`<div class="qm-tilt-buttons">
${t&bc?m`<button class="qm-swatch qm-slot" @click=${()=>this.call("cover","open_cover_tilt")}>${this.t("cover_tilt_open")}</button>`:f}
${t&wc?m`<button class="qm-swatch qm-slot" @click=${()=>this.call("cover","close_cover_tilt")}>${this.t("cover_tilt_close")}</button>`:f}
</div>`:f}renderToggle(e){let t=e.state==="on"||e.state==="unlocked"||e.state==="playing",n=e.entity_id.split(".")[0];return m`<div class="qm-ring qm-ring-small">
<button
class="qm-power ${t?"qm-on":""}"
@@ -1258,7 +1258,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M12 3v8M6.3 6.8a8 8 0 1 0 11.4 0" /></svg>
<b>${ee(this.hass,e)}</b>
</button>
</div>`}renderMedia(e){let t=!["off","standby","unavailable","unknown"].includes(e.state),n=e.state==="playing",o=e.attributes,i=typeof o.volume_level=="number"?Math.round(o.volume_level*100):null,s=Array.isArray(o.source_list)?o.source_list.slice(0,24):[],a=[o.media_title,o.media_artist].filter(d=>typeof d=="string"&&d).join(" \xB7 "),l=d=>m`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><path d=${d} /></svg>`,c=(d,p,h,w=!1)=>m`<button class="qm-swatch qm-slot ${w?"qm-slot-on":""}" aria-label=${p} title=${p} @click=${h}>${d}</button>`,u=t?[c(l(n?"M6 5h4v14H6zM14 5h4v14h-4z":"M8 5v14l11-7z"),this.t(n?"media_pause":"media_play"),()=>this.call("media_player","media_play_pause"),n),c(l("M6 6h2v12H6zm3.5 6 8.5 6V6z"),this.t("media_previous"),()=>this.call("media_player","media_previous_track")),c(l("M16 6h2v12h-2zM6 18l8.5-6L6 6z"),this.t("media_next"),()=>this.call("media_player","media_next_track"))]:[];return m`<div class="qm-ring ${u.length?"":"qm-ring-small"}">
</div>`}renderMedia(e){let t=!["off","standby","unavailable","unknown"].includes(e.state),n=e.state==="playing",o=e.attributes,i=typeof o.volume_level=="number"?Math.round(o.volume_level*100):null,s=Array.isArray(o.source_list)?o.source_list.slice(0,24):[],a=[o.media_title,o.media_artist].filter(d=>typeof d=="string"&&d).join(" \xB7 "),l=d=>m`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor"><path d=${d} /></svg>`,c=(d,p,h,g=!1)=>m`<button class="qm-swatch qm-slot ${g?"qm-slot-on":""}" aria-label=${p} title=${p} @click=${h}>${d}</button>`,u=t?[c(l(n?"M6 5h4v14H6zM14 5h4v14h-4z":"M8 5v14l11-7z"),this.t(n?"media_pause":"media_play"),()=>this.call("media_player","media_play_pause"),n),c(l("M6 6h2v12H6zm3.5 6 8.5 6V6z"),this.t("media_previous"),()=>this.call("media_player","media_previous_track")),c(l("M16 6h2v12h-2zM6 18l8.5-6L6 6z"),this.t("media_next"),()=>this.call("media_player","media_next_track"))]:[];return m`<div class="qm-ring ${u.length?"":"qm-ring-small"}">
${this.ring(u)}
<button class="qm-power ${t?"qm-on":""}" aria-pressed=${t} @click=${()=>this.ask()&&this.call("media_player",t?"turn_off":"turn_on")}>
<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M12 3v8M6.3 6.8a8 8 0 1 0 11.4 0" /></svg>
@@ -1270,7 +1270,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
${s.length?m`<div class="qm-play-head">${this.t("media_sources")}</div>
<div class="qm-play">${s.map(d=>m`<button class="qm-chip ${o.source===d?"qm-chip-on":""}" @click=${()=>this.call("media_player","select_source",{source:d})}>${d}</button>`)}</div>`:f}
${this.presets?.length?m`<div class="qm-play-head">${this.t("presets")}</div>
<div class="qm-play">${this.presets.map(d=>m`<button class="qm-chip" @click=${()=>this.call("media_player","play_media",{media_content_type:d.type,media_content_id:d.content})}>${d.label}</button>`)}</div>`:f}`}render(){let e=this.hass?.states[this.entity];if(!e)return f;let t=D(this.entity),n=I(e)&&!Gt(e)?m`<p class="qm-note">${ee(this.hass,e)}</p>`:t==="light"?this.renderLight(e):t==="cover"?this.renderCover(e):t==="media"?this.renderMedia(e):this.renderToggle(e);return m`<div class="qm" role="dialog" aria-label=${L(this.hass,this.entity)}>
<div class="qm-play">${this.presets.map(d=>m`<button class="qm-chip" @click=${()=>this.call("media_player","play_media",{media_content_type:d.type,media_content_id:d.content})}>${d.label}</button>`)}</div>`:f}`}render(){let e=this.hass?.states[this.entity];if(!e)return f;let t=D(this.entity),n=I(e)&&!Ut(e)?m`<p class="qm-note">${ee(this.hass,e)}</p>`:t==="light"?this.renderLight(e):t==="cover"?this.renderCover(e):t==="media"?this.renderMedia(e):this.renderToggle(e);return m`<div class="qm" role="dialog" aria-label=${L(this.hass,this.entity)}>
<div class="qm-title">${L(this.hass,this.entity)}</div>
${n}
<button class="qm-details" @click=${()=>this.details()}>${this.t("details")} …</button>
@@ -1517,9 +1517,9 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
.qm-note {
color: var(--nf-muted);
}
`]};function hm(r){let e=Math.min(1,Math.max(0,(r-2200)/4300)),t=(n,o)=>Math.round(n+(o-n)*e);return`rgb(${t(255,200)},${t(170,225)},${t(80,255)})`}customElements.get("nf-quick-menu")||customElements.define("nf-quick-menu",oi);var pm=new URL(import.meta.url),mm=new URL("./nextfloor-3d.js?v=473b84f8bac7",pm).href,bc;function wc(){return bc??=import(mm),bc}function vc(r){if(!r||r.state!=="on")return 0;let e=typeof r.attributes.percentage=="number"?r.attributes.percentage:60;return e<=0?0:.2+.6*Math.min(100,e)/100}var fm=new Set(["on","home","open","true","active","playing","heat","heating"]);function Er(r,e){let t=e.show_when;if(!t?.entity||!r)return!0;let n=r.states[t.entity];if(!n||I(n))return!0;let o=String(n.state).toLowerCase(),i=(t.state??"").split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),s=i.length?i.includes(o):fm.has(o)||Number.isFinite(Number(o))&&Number(o)>0;return t.invert?!s:s}function ai(r,e){let t=[];for(let n of e.floors)for(let o of n.furniture)Er(r,o)||t.push(o.id);return t.sort()}function yc(r,e){if(!e.length)return r;let t=new Set(e);return{...r,floors:r.floors.map(n=>n.furniture.some(o=>t.has(o.id))?{...n,furniture:n.furniture.filter(o=>!t.has(o.id))}:n)}}var kc="image:";function li(r,e,t){let n=(e??"").trim();if(!n)return null;if(n.startsWith(kc))return t(n.slice(kc.length));if(/^(https?:\/\/|\/)/.test(n))return n;if(/^[a-z_]+\.[a-z0-9_]+$/.test(n)){let o=r?.states[n]?.attributes.entity_picture;return typeof o=="string"&&o?o:null}return null}var _n=r=>Number(r);function wn(r){if(Array.isArray(r)){let[i,s]=[_n(r[0]),_n(r[1])];return Number.isFinite(i)&&Number.isFinite(s)?[i,s]:null}if(!r||typeof r!="object")return null;let{x:e,y:t}=r,[n,o]=[_n(e),_n(t)];return Number.isFinite(n)&&Number.isFinite(o)?[n,o]:null}function xc(r){return r?wn(r.charger)??wn(r.charger_position):null}function Sc(r){for(let[e,t]of Object.entries(r.states))if(e.startsWith("camera.")&&(wn(t.attributes?.vacuum_position)??xc(t.attributes)))return e;return null}var gm=r=>Array.isArray(r)?typeof r[0]=="number":!!r&&typeof r=="object",bn=(r,e)=>e?[r[0],-r[1]]:r;function _m(r){if(!r)return null;let e=r.mirror===!0,[t,n]=bn(r.ga,e),[o,i]=bn(r.gb,e),[s,a]=r.a,[l,c]=r.b,[u,d]=[o-t,i-n],[p,h]=[l-s,c-a],w=Math.hypot(u,d),b=Math.hypot(p,h);if(!(w>1e-6)||!(b>1e-6))return null;let g=b/w,_=Math.atan2(h,p)-Math.atan2(d,u),[M,$]=[Math.cos(_),Math.sin(_)];return k=>{let y=bn(k,e),[F,T]=[y[0]-t,y[1]-n];return[s+g*(F*M-T*$),a+g*(F*$+T*M)]}}function bm(r){if(!r)return null;let e=r.mirror===!0,[t,n]=bn(r.ga,e),[o,i]=bn(r.gb,e),s=Math.atan2(r.b[1]-r.a[1],r.b[0]-r.a[0])-Math.atan2(i-n,o-t);return Number.isFinite(s)?s:null}function Mc(r,e,t){if(!e)return null;let n=r.states[e]?.attributes;if(!n)return null;let o=_m(t)??(w=>w),i=bm(t)??0,s=t?.mirror===!0?-1:1,a=n.vacuum_position,l=wn(a),c=l?(()=>{let[w,b]=o(l),g=_n(a?.a)*s;if(!Number.isFinite(g))return{x:w,z:b,heading:0};let _=g*Math.PI/180+i;return{x:w,z:b,heading:Math.atan2(Math.cos(_),Math.sin(_))}})():null,u=xc(n),d=Array.isArray(n.path)?n.path:[],p=d.length>0&&gm(d[0])?[d]:d,h=[];for(let w of p){let b=[];for(let g of Array.isArray(w)?w:[]){let _=wn(g);_&&b.push(o(_))}b.length>1&&h.push(b)}return!c&&!u&&!h.length?null:{pose:c,charger:u?o(u):null,path:h}}var $c="nextfloor.lock3d",Ac=520,ui=class extends re{static properties={hass:{attribute:!1},building:{attribute:!1},floorId:{attribute:!1},roomId:{attribute:!1},wallMode:{attribute:!1},solidWalls:{attribute:!1},glassWalls:{attribute:!1},explode:{type:Boolean},keepRoof:{attribute:!1},markerMode:{attribute:!1},markerNames:{attribute:!1},markersOutside:{attribute:!1},tapInRoom:{type:Boolean},roomDoubleTap:{attribute:!1},heatMode:{attribute:!1},theme:{attribute:!1},accent:{attribute:!1},furnitureColors:{attribute:!1},packs:{attribute:!1},showEnergy:{attribute:!1},flows:{attribute:!1},holograms:{attribute:!1},furnish:{type:Boolean},surfaceGrab:{attribute:!1},furnishTypes:{attribute:!1},weather:{type:Boolean},weatherEntityId:{attribute:!1},weatherDensity:{attribute:!1},timeOfDay:{attribute:!1},selectedFurniture:{attribute:!1},selectedDevice:{attribute:!1},_sky:{state:!0},quality:{attribute:!1},showStats:{type:Boolean},_stats:{state:!0},_error:{state:!0},_energy:{state:!0},_flows:{state:!0},_liveEnergy:{state:!0},_liveCards:{state:!0},_liveCardOn:{state:!0},_houseFolded:{state:!0},_swipe:{state:!0},_menu:{state:!0},_pluginWindow:{state:!0},_plate:{state:!0},_blend:{state:!0},_wallBig:{state:!0},_find:{state:!0},_central:{state:!0},_thumbsCompact:{state:!0},_armed:{state:!0},central:{attribute:!1},centralOpen:{attribute:!1},keepCamera:{attribute:!1},plain:{attribute:!1},rightBack:{attribute:!1},templateName:{attribute:!1},readable:{type:Boolean,reflect:!0},today:{attribute:!1},_todayOpen:{state:!0},_todayItems:{state:!0},_forecast:{state:!0},zoom:{attribute:!1},buttons:{attribute:!1},_thumbs:{state:!0},floorThumbs:{attribute:!1},clean:{attribute:!1},cleanButton:{attribute:!1},clock:{attribute:!1},lockButton:{attribute:!1},walkButto Line truncated
`]};function fm(r){let e=Math.min(1,Math.max(0,(r-2200)/4300)),t=(n,o)=>Math.round(n+(o-n)*e);return`rgb(${t(255,200)},${t(170,225)},${t(80,255)})`}customElements.get("nf-quick-menu")||customElements.define("nf-quick-menu",si);var gm=new URL(import.meta.url),_m=new URL("./nextfloor-3d.js?v=74227cd20cc3",gm).href,vc;function yc(){return vc??=import(_m),vc}function xc(r){if(!r||r.state!=="on")return 0;let e=typeof r.attributes.percentage=="number"?r.attributes.percentage:60;return e<=0?0:.2+.6*Math.min(100,e)/100}var bm=new Set(["on","home","open","true","active","playing","heat","heating"]);function zr(r,e){let t=e.show_when;if(!t?.entity||!r)return!0;let n=r.states[t.entity];if(!n||I(n))return!0;let o=String(n.state).toLowerCase(),i=(t.state??"").split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),s=i.length?i.includes(o):bm.has(o)||Number.isFinite(Number(o))&&Number(o)>0;return t.invert?!s:s}function ci(r,e){let t=[];for(let n of e.floors)for(let o of n.furniture)zr(r,o)||t.push(o.id);return t.sort()}function kc(r,e){if(!e.length)return r;let t=new Set(e);return{...r,floors:r.floors.map(n=>n.furniture.some(o=>t.has(o.id))?{...n,furniture:n.furniture.filter(o=>!t.has(o.id))}:n)}}var Sc="image:";function ui(r,e,t){let n=(e??"").trim();if(!n)return null;if(n.startsWith(Sc))return t(n.slice(Sc.length));if(/^(https?:\/\/|\/)/.test(n))return n;if(/^[a-z_]+\.[a-z0-9_]+$/.test(n)){let o=r?.states[n]?.attributes.entity_picture;return typeof o=="string"&&o?o:null}return null}var _n=r=>Number(r);function wn(r){if(Array.isArray(r)){let[i,s]=[_n(r[0]),_n(r[1])];return Number.isFinite(i)&&Number.isFinite(s)?[i,s]:null}if(!r||typeof r!="object")return null;let{x:e,y:t}=r,[n,o]=[_n(e),_n(t)];return Number.isFinite(n)&&Number.isFinite(o)?[n,o]:null}function Mc(r){return r?wn(r.charger)??wn(r.charger_position):null}function $c(r){for(let[e,t]of Object.entries(r.states))if(e.startsWith("camera.")&&(wn(t.attributes?.vacuum_position)??Mc(t.attributes)))return e;return null}var wm=r=>Array.isArray(r)?typeof r[0]=="number":!!r&&typeof r=="object",bn=(r,e)=>e?[r[0],-r[1]]:r;function vm(r){if(!r)return null;let e=r.mirror===!0,[t,n]=bn(r.ga,e),[o,i]=bn(r.gb,e),[s,a]=r.a,[l,c]=r.b,[u,d]=[o-t,i-n],[p,h]=[l-s,c-a],g=Math.hypot(u,d),b=Math.hypot(p,h);if(!(g>1e-6)||!(b>1e-6))return null;let _=b/g,w=Math.atan2(h,p)-Math.atan2(d,u),[M,$]=[Math.cos(w),Math.sin(w)];return x=>{let y=bn(x,e),[F,T]=[y[0]-t,y[1]-n];return[s+_*(F*M-T*$),a+_*(F*$+T*M)]}}function ym(r){if(!r)return null;let e=r.mirror===!0,[t,n]=bn(r.ga,e),[o,i]=bn(r.gb,e),s=Math.atan2(r.b[1]-r.a[1],r.b[0]-r.a[0])-Math.atan2(i-n,o-t);return Number.isFinite(s)?s:null}function Ac(r,e,t){if(!e)return null;let n=r.states[e]?.attributes;if(!n)return null;let o=vm(t)??(g=>g),i=ym(t)??0,s=t?.mirror===!0?-1:1,a=n.vacuum_position,l=wn(a),c=l?(()=>{let[g,b]=o(l),_=_n(a?.a)*s;if(!Number.isFinite(_))return{x:g,z:b,heading:0};let w=_*Math.PI/180+i;return{x:g,z:b,heading:Math.atan2(Math.cos(w),Math.sin(w))}})():null,u=Mc(n),d=Array.isArray(n.path)?n.path:[],p=d.length>0&&wm(d[0])?[d]:d,h=[];for(let g of p){let b=[];for(let _ of Array.isArray(g)?g:[]){let w=wn(_);w&&b.push(o(w))}b.length>1&&h.push(b)}return!c&&!u&&!h.length?null:{pose:c,charger:u?o(u):null,path:h}}var Ec="nextfloor.lock3d",Rc=520,hi=class extends re{static properties={hass:{attribute:!1},building:{attribute:!1},floorId:{attribute:!1},roomId:{attribute:!1},wallMode:{attribute:!1},solidWalls:{attribute:!1},glassWalls:{attribute:!1},explode:{type:Boolean},keepRoof:{attribute:!1},markerMode:{attribute:!1},markerNames:{attribute:!1},markersOutside:{attribute:!1},tapInRoom:{type:Boolean},roomDoubleTap:{attribute:!1},heatMode:{attribute:!1},theme:{attribute:!1},accent:{attribute:!1},furnitureColors:{attribute:!1},packs:{attribute:!1},showEnergy:{attribute:!1},flows:{attribute:!1},holograms:{attribute:!1},furnish:{type:Boolean},surfaceGrab:{attribute:!1},furnishTypes:{attribute:!1},weather:{type:Boolean},weatherEntityId:{attribute:!1},weatherDensity:{attribute:!1},timeOfDay:{attribute:!1},selectedFurniture:{attribute:!1},selectedDevice:{attribute:!1},_sky:{state:!0},quality:{attribute:!1},showStats:{type:Boolean},_stats:{state:!0},_error:{state:!0},_energy:{state:!0},_flows:{state:!0},_liveEnergy:{state:!0},_liveCards:{state:!0},_liveCardOn:{state:!0},_houseFolded:{state:!0},_swipe:{state:!0},_menu:{state:!0},_pluginWindow:{state:!0},_plate:{state:!0},_blend:{state:!0},_wallBig:{state:!0},_find:{state:!0},_central:{state:!0},_thumbsCompact:{state:!0},_armed:{state:!0},central:{attribute:!1},centralOpen:{attribute:!1},keepCamera:{attribute:!1},plain:{attribute:!1},rightBack:{attribute:!1},templateName:{attribute:!1},readable:{type:Boolean,reflect:!0},today:{attribute:!1},_todayOpen:{state:!0},_todayItems:{state:!0},_forecast:{state:!0},zoom:{attribute:!1},buttons:{attribute:!1},_thumbs:{state:!0},floorThumbs:{attribute:!1},clean:{attribute:!1},cleanButton:{attribute:!1},clock:{attribute:!1},lockButton:{attribute:!1},walkButto Line truncated
${e.map(t=>m`<button class="nf-chip" aria-pressed=${!this.hiddenLayers.has(t.id)} @click=${()=>this.toggleLayer(t.id)}>${this.hiddenLayers.has(t.id)?"\u25CC":"\u{1F441}"} ${t.name}</button>`)}
</div>`}syncDevices(e){let t=this.viewer,n=this.building;if(!t||!n||!this.hass)return;let o=this._travel,i=o&&!o.loading?Mt(this.hass,o.history,o.t):this.hass;if((e||!this.openingLinks||this.linkedRegistry!==i.entities)&&(this.openingLinks=jt(i,n.floors),this.furnitureLinks=nt(i,n.floors),this.linkedRegistry=i.entities,this.findIndex=null,this.alertSrc=this.alerts?_l(i,n,this.weatherEntityId,this.openingLinks):null,this.watched=Sl({hass:i,building:n,openingLinks:this.openingLinks,furnitureLinks:this.furnitureLinks,needsRoomSensors:this.heatMode!=="none"||this.roomLabels,alertSources:this.alertSrc,weatherEntityId:this.weatherEntityId}),e=!0),!(e||this.watched.some(v=>this.shownStates.get(v)!==i.states[v])))return;ai(i,n).join(",")!==this.shownFor?.key&&t.setBuilding(this.shownBuilding(i)),this.shownStates=new Map(this.watched.map(v=>[v,i.states[v]])),this.refreshToday(n),this.refreshForecast(n);let a=en(i,n),l=oa(i,n.floors.some(v=>v.layer&&this.hiddenLayers.has(v.id))?this.shownBuilding(i):n);this.placementInfo=new Map(l.map(v=>[v.id,{floorId:v.floorId,roomId:v.roomId,x:v.x,z:v.z,y:v.y,rotation:v.rotation??0}]));let c=this.furnitureMarkers(i,n,new Set(l.map(v=>v.id)),new Set(a.map(v=>v.powerEntity)));a.push(...c.consumers);let u=tn(i,n,a,Fe(n,v=>this.furnitureLinks?.get(v.id)?.power??null)),d=new Map(a.filter(v=>v.id!==v.powerEntity).map(v=>[v.id,v.power]));this.confirmSet=rt(i,n.floors);let p=new Set(this.liveCardsOn?this._liveCards.flatMap(v=>v.kind==="media"?[v.media.entity]:v.kind==="car"?[v.spot]:[]):[]);for(let v of n.floors)for(let x of v.outdoor??[]){if(!x.area_id&&!x.temp_entity&&!x.pump_entity)continue;let B=x.temp_entity?i.states[x.temp_entity]:void 0,z=x.pump_entity?i.states[x.pump_entity]:void 0,[W,de]=We(x.points),je=B&&Number.isFinite(Number(B.state))?`${O(i,ue(i,Kn(Number(B.state),B.attributes.unit_of_measurement)),1)} ${ne(i)}`:"",lt=!!z&&Q(z);l.push({id:x.area_id?`outdoor:${x.id}`:x.pump_entity??x.temp_entity,floorId:v.id,roomId:null,x:W,z:de,y:Nn(v,x,W,de)+.7,icon:ke(x.type==="pool"?"pool":x.type==="terrace"?"table-chair":"tree-outline"),name:x.area_id&&i.areas?.[x.area_id]?.name||R(i,`out_${x.type}`),text:[je,lt?R(i,"pool_pump_on"):""].filter(Boolean).join(" \xB7 "),active:lt,unavailable:!1,glow:null,show:"always"})}let h=new Map;for(let v of n.floors){for(let x of v.placements)x.pin_offset&&h.set(`${v.id}:${x.entity_id}`,x.pin_offset);for(let x of v.furniture)x.pin_offset&&h.set(`f:${x.id}`,x.pin_offset)}let w=v=>{let x=v.lamp?void 0:(v.furnitureId?h.get(`f:${v.furnitureId}`):void 0)??h.get(`${v.floorId}:${v.id}`);return x?{...v,x:v.x+(x.x??0),z:v.z+(x.z??0),y:v.y+(x.y??0)}:v};t.setDevices([...[...l,...c.markers].map(w).map(v=>{let x=v.show==="no_power"||"energyDevice"in v&&v.energyDevice?null:d.get(v.id)??null,B={...v,power:x,powerText:x===null?void 0:se(i,x),effect:this.dimmed?void 0:v.effect,text:this.subMeterText(i,n,u,v.furnitureId)??v.text},z=v.ownName&&(v.showName||this.markerNames)?v.ownName:"",W=p.has(v.id)||!!v.furnitureId&&p.has(v.furnitureId);return{...B,pin:this.showPin(B)&&!W,full:v.show==="always",caption:z}})]),t.setPickTargets(c.targets,this.openingTargets(),this.secondBlinds()),t.setScreens(c.screens),t.setFridgeDoors(Os(i,n.floors)),t.setCovers(Ys(i,n)),t.setRobots(this.robotInfos(i,n));let b=new Map;for(let v of n.floors)for(let x of v.furniture)!q(x.type)?.pet||!x.room_sensor||x.room_sensor==="none"||b.set(x.id,fo(i,v.rooms.filter(B=>B.points.length>=3),null,x.room_sensor)?.id??null);b.size&&t.setPetRooms(b),t.setRoofWindows(hl(i,n)),t.setParked(Lo(i,n)),t.setGateStates(zl(i,n));let g=new Map(n.floors.flatMap(v=>v.openings.map(x=>[x.id,x.type]))),_=new Map([...this.openingLinks].map(([v,x])=>[v,Ee(i,x,g.get(v))]));t.setOpeningStates(_),this.setAlerts(this.alertSrc?No(i,n,this.alertSrc,this.openingLinks):[]),this.watchLostContacts(i);let M=[...l,...c.markers].map(v=>`${v.id}:${v.glow?`${v.glow.level.toFixed(1)}/${v.glow.color.map(x=>x.toFixed(1)).join("/")}`:0}`).join(";")+"|"+[..._].map(([v,x])=>`${v}:${x.open}:${x.cover===null?"-":x.cover.toFixed(1)}`).join(";");if(M!==this.thumbSig){let v=this.thumbSig==="";this.thumbSig=M,v||this.scheduleThumbs(1500)}let $=Gl(i,n,a,n.energy.advanced?v=>this.furnitureLinks?.get(v.id)?.power??null:void 0),k=this.liveCars(i,n);for(let v of k){if(!v.car.home||!v.car.charging&&!v.car.plugged)continue;let x=n.floors.flatMap(W=>W.furniture.filter(de=>de.type==="wallbox").map(de=>({floorId:W.id,x:de.x,z:de.z,y:1}))).sort((W,de)=>Math.hypot(W.x-v.at.x,W.z-v.at.z)-Math.hypot(de.x-v.at.x,de.z-v.at.z))[0],B=x&&x.floorId===v.at.floorId&&Math.hypot(x.x-v.at.x,x.z-v.at.z)<9,z=x??pn(n);!z||!v.car.charging&&!B||$.arcs.push({key:`car:${v.spot}`,from:z,to:{...v.at,y:.8},power:v.car.charging?v.car.chargingW??7e3:0,color:[80,175,255],...B?{via:[{...z,y:.35},{floorId:v.at.floorId,x:(z.x+v.at.x)/2,z:(z.z+v.at.z)/2,y:.08},{...v.at,y:.5}],cable:!0}:{}})}let y=pn(n);for(let v of this.liveHeatPumps(n)){let x=v.pump.heat??(v.pump.mode==="heating"||v.puLine truncated
</div>`}syncDevices(e){let t=this.viewer,n=this.building;if(!t||!n||!this.hass)return;let o=this._travel,i=o&&!o.loading?$t(this.hass,o.history,o.t):this.hass;if((e||!this.openingLinks||this.linkedRegistry!==i.entities)&&(this.openingLinks=rt(i,n.floors),this.furnitureLinks=ot(i,n.floors),this.linkedRegistry=i.entities,this.findIndex=null,this.alertSrc=this.alerts?wl(i,n,this.weatherEntityId,this.openingLinks):null,this.watched=$l({hass:i,building:n,openingLinks:this.openingLinks,furnitureLinks:this.furnitureLinks,needsRoomSensors:this.heatMode!=="none"||this.roomLabels,alertSources:this.alertSrc,weatherEntityId:this.weatherEntityId}),e=!0),!(e||this.watched.some(v=>this.shownStates.get(v)!==i.states[v])))return;ci(i,n).join(",")!==this.shownFor?.key&&t.setBuilding(this.shownBuilding(i)),this.shownStates=new Map(this.watched.map(v=>[v,i.states[v]])),this.refreshToday(n),this.refreshForecast(n);let a=en(i,n),l=sa(i,n.floors.some(v=>v.layer&&this.hiddenLayers.has(v.id))?this.shownBuilding(i):n);this.placementInfo=new Map(l.map(v=>[v.id,{floorId:v.floorId,roomId:v.roomId,x:v.x,z:v.z,y:v.y,rotation:v.rotation??0}]));let c=this.furnitureMarkers(i,n,new Set(l.map(v=>v.id)),new Set(a.map(v=>v.powerEntity)));a.push(...c.consumers);let u=tn(i,n,a,Fe(n,v=>this.furnitureLinks?.get(v.id)?.power??null)),d=new Map(a.filter(v=>v.id!==v.powerEntity).map(v=>[v.id,v.power]));this.confirmSet=it(i,n.floors);let p=new Set(this.liveCardsOn?this._liveCards.flatMap(v=>v.kind==="media"?[v.media.entity]:v.kind==="car"?[v.spot]:[]):[]);for(let v of n.floors)for(let k of v.outdoor??[]){if(!k.area_id&&!k.temp_entity&&!k.pump_entity)continue;let B=k.temp_entity?i.states[k.temp_entity]:void 0,z=k.pump_entity?i.states[k.pump_entity]:void 0,[W,de]=We(k.points),qe=B&&Number.isFinite(Number(B.state))?`${O(i,ue(i,Kn(Number(B.state),B.attributes.unit_of_measurement)),1)} ${ne(i)}`:"",ut=!!z&&Q(z);l.push({id:k.area_id?`outdoor:${k.id}`:k.pump_entity??k.temp_entity,floorId:v.id,roomId:null,x:W,z:de,y:Nn(v,k,W,de)+.7,icon:xe(k.type==="pool"?"pool":k.type==="terrace"?"table-chair":"tree-outline"),name:k.area_id&&i.areas?.[k.area_id]?.name||R(i,`out_${k.type}`),text:[qe,ut?R(i,"pool_pump_on"):""].filter(Boolean).join(" \xB7 "),active:ut,unavailable:!1,glow:null,show:"always"})}let h=new Map;for(let v of n.floors){for(let k of v.placements)k.pin_offset&&h.set(`${v.id}:${k.entity_id}`,k.pin_offset);for(let k of v.furniture)k.pin_offset&&h.set(`f:${k.id}`,k.pin_offset)}let g=v=>{let k=v.lamp?void 0:(v.furnitureId?h.get(`f:${v.furnitureId}`):void 0)??h.get(`${v.floorId}:${v.id}`);return k?{...v,x:v.x+(k.x??0),z:v.z+(k.z??0),y:v.y+(k.y??0)}:v};t.setDevices([...[...l,...c.markers].map(g).map(v=>{let k=v.show==="no_power"||"energyDevice"in v&&v.energyDevice?null:d.get(v.id)??null,B={...v,power:k,powerText:k===null?void 0:se(i,k),effect:this.dimmed?void 0:v.effect,text:this.subMeterText(i,n,u,v.furnitureId)??v.text},z=v.ownName&&(v.showName||this.markerNames)?v.ownName:"",W=p.has(v.id)||!!v.furnitureId&&p.has(v.furnitureId);return{...B,pin:this.showPin(B)&&!W,full:v.show==="always",caption:z}})]),t.setPickTargets(c.targets,this.openingTargets(),this.secondBlinds()),t.setScreens(c.screens),t.setFridgeDoors(Ls(i,n.floors)),t.setCovers(Qs(i,n)),t.setRobots(this.robotInfos(i,n));let b=new Map;for(let v of n.floors)for(let k of v.furniture)!q(k.type)?.pet||!k.room_sensor||k.room_sensor==="none"||b.set(k.id,_o(i,v.rooms.filter(B=>B.points.length>=3),null,k.room_sensor)?.id??null);b.size&&t.setPetRooms(b),t.setRoofWindows(ml(i,n)),t.setParked(Vo(i,n)),t.setGateStates(Fl(i,n));let _=new Map(n.floors.flatMap(v=>v.openings.map(k=>[k.id,k.type]))),w=new Map([...this.openingLinks].map(([v,k])=>[v,Ee(i,k,_.get(v))]));t.setOpeningStates(w),this.setAlerts(this.alertSrc?Wo(i,n,this.alertSrc,this.openingLinks):[]),this.watchLostContacts(i);let M=[...l,...c.markers].map(v=>`${v.id}:${v.glow?`${v.glow.level.toFixed(1)}/${v.glow.color.map(k=>k.toFixed(1)).join("/")}`:0}`).join(";")+"|"+[...w].map(([v,k])=>`${v}:${k.open}:${k.cover===null?"-":k.cover.toFixed(1)}`).join(";");if(M!==this.thumbSig){let v=this.thumbSig==="";this.thumbSig=M,v||this.scheduleThumbs(1500)}let $=jl(i,n,a,n.energy.advanced?v=>this.furnitureLinks?.get(v.id)?.power??null:void 0),x=this.liveCars(i,n);for(let v of x){if(!v.car.home||!v.car.charging&&!v.car.plugged)continue;let k=n.floors.flatMap(W=>W.furniture.filter(de=>de.type==="wallbox").map(de=>({floorId:W.id,x:de.x,z:de.z,y:1}))).sort((W,de)=>Math.hypot(W.x-v.at.x,W.z-v.at.z)-Math.hypot(de.x-v.at.x,de.z-v.at.z))[0],B=k&&k.floorId===v.at.floorId&&Math.hypot(k.x-v.at.x,k.z-v.at.z)<9,z=k??pn(n);!z||!v.car.charging&&!B||$.arcs.push({key:`car:${v.spot}`,from:z,to:{...v.at,y:.8},power:v.car.charging?v.car.chargingW??7e3:0,color:[80,175,255],...B?{via:[{...z,y:.35},{floorId:v.at.floorId,x:(z.x+v.at.x)/2,z:(z.z+v.at.z)/2,y:.08},{...v.at,y:.5}],cable:!0}:{}})}let y=pn(n);for(let v of this.liveHeatPumps(n)){let k=v.pump.heat??(v.pump.mode==="heating"||v.puLine truncated
<button class="nf-thumbs-fold" title=${R(this.hass,n?"thumbs_show":"thumbs_fold")} aria-label=${R(this.hass,n?"thumbs_show":"thumbs_fold")} @click=${o}>${n?"\u25B8":"\u25C2"}</button>
<button class="nf-thumb nf-thumb-house" aria-pressed=${this.floorId===null} @click=${()=>this.fire("floor-tap",{floorId:null})}>
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"><path d="M3 11l9-7 9 7M5 10v10h14V10" /></svg>
@@ -1529,16 +1529,16 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
${n?f:m`<img src=${i.url} alt="" />`}
<span>${e.get(i.floorId)??""}</span>
</button>`)}
</nav>`}onDeviceHold(e,t,n){let o=D(e);o==="light"||o==="cover"||o==="switch"||o==="fan"||o==="lock"?this._menu={entity:e,x:t,y:n}:fe(this,e)}onDeviceSwipe(e,t,n,o,i){let s=this.hass?.states[e];if(t==="start"){if(!s||I(s)||this.confirmSet.has(e))return!1;let l=D(e);if(l==="light"&&ii(s).dim){let c=s.state==="on"?typeof s.attributes.brightness=="number"?Math.round(s.attributes.brightness/2.55):100:0;return this._swipe={entity:e,kind:"light",start:c,value:c,x:o,y:i},!0}if(l==="fan"&&typeof s.attributes.percentage_step=="number"){let c=s.state==="on"&&typeof s.attributes.percentage=="number"?s.attributes.percentage:0;return this._swipe={entity:e,kind:"fan",start:c,value:c,x:o,y:i},!0}if(l==="cover"&&si(s)){let c=s.attributes.current_position;return this._swipe={entity:e,kind:"cover",start:c,value:c,x:o,y:i},!0}return!1}let a=this._swipe;if(!a||a.entity!==e)return!1;if(t==="move"){let l=Math.round(Math.min(100,Math.max(0,a.start-n/220*100)));l!==a.value&&(this._swipe={...a,value:l});let c=performance.now();c-this.swipeSent>350&&(this.swipeSent=c,this.applySwipe())}else this.applySwipe(),clearTimeout(this.swipeTimer),this.swipeTimer=setTimeout(()=>this._swipe=null,700);return!0}applySwipe(){let e=this._swipe;!e||!this.hass||(e.kind==="light"?e.value<=0?this.hass.callService("light","turn_off",{entity_id:e.entity}):this.hass.callService("light","turn_on",{entity_id:e.entity,brightness_pct:e.value}):e.kind==="fan"?e.value<=0?this.hass.callService("fan","turn_off",{entity_id:e.entity}):this.hass.callService("fan","set_percentage",{entity_id:e.entity,percentage:e.value}):this.hass.callService("cover","set_cover_position",{entity_id:e.entity,position:e.value}))}openRoom(e,t){this.floorId===e&&this.roomId===t||(this.floorId!==e?(this.fire("floor-tap",{floorId:e}),setTimeout(()=>this.fire("room-tap",{floorId:e,roomId:t}),60)):this.fire("room-tap",{floorId:e,roomId:t}))}goTo(e){if(this._find=null,e.kind==="room"||e.kind==="circuit"){e.roomId&&this.openRoom(e.floorId,e.roomId);return}this.floorId!==e.floorId&&this.fire("floor-tap",{floorId:e.floorId}),setTimeout(()=>this.viewer?.focus(e.floorId,e.x,e.z,e.y,e.entity),120)}listenToAnnouncements(e){if(!e){this.stopAnnouncements?.(),this.stopAnnouncements=null,clearTimeout(this.announceTimer);return}if(this.stopAnnouncements)return;let t=!1;this.stopAnnouncements=()=>t=!0,pa(this.hass,n=>this.announce(n)).then(n=>{t?n():this.stopAnnouncements=n})}announce(e){let t=e;if(t?.reload===!0){(!t.template||t.template===this.templateName)&&setTimeout(()=>location.reload(),500+Math.random()*6e3);return}if(typeof e?.message!="string"||!e.message.trim()||!ca(e,this.screenName)||!ua(e))return;let n=da(e.message);this._announcement={message:e.message,until:Date.now()+n},clearTimeout(this.announceTimer),this.announceTimer=setTimeout(()=>this._announcement=null,n),ha(this.hass,e)}renderAnnouncement(){let e=this._announcement;return e?m`<button class="nf-announcement" role="alert" title=${R(this.hass,"close")} @click=${()=>this._announcement=null}>
</nav>`}onDeviceHold(e,t,n){let o=D(e);o==="light"||o==="cover"||o==="switch"||o==="fan"||o==="lock"?this._menu={entity:e,x:t,y:n}:fe(this,e)}onDeviceSwipe(e,t,n,o,i){let s=this.hass?.states[e];if(t==="start"){if(!s||I(s)||this.confirmSet.has(e))return!1;let l=D(e);if(l==="light"&&ai(s).dim){let c=s.state==="on"?typeof s.attributes.brightness=="number"?Math.round(s.attributes.brightness/2.55):100:0;return this._swipe={entity:e,kind:"light",start:c,value:c,x:o,y:i},!0}if(l==="fan"&&typeof s.attributes.percentage_step=="number"){let c=s.state==="on"&&typeof s.attributes.percentage=="number"?s.attributes.percentage:0;return this._swipe={entity:e,kind:"fan",start:c,value:c,x:o,y:i},!0}if(l==="cover"&&li(s)){let c=s.attributes.current_position;return this._swipe={entity:e,kind:"cover",start:c,value:c,x:o,y:i},!0}return!1}let a=this._swipe;if(!a||a.entity!==e)return!1;if(t==="move"){let l=Math.round(Math.min(100,Math.max(0,a.start-n/220*100)));l!==a.value&&(this._swipe={...a,value:l});let c=performance.now();c-this.swipeSent>350&&(this.swipeSent=c,this.applySwipe())}else this.applySwipe(),clearTimeout(this.swipeTimer),this.swipeTimer=setTimeout(()=>this._swipe=null,700);return!0}applySwipe(){let e=this._swipe;!e||!this.hass||(e.kind==="light"?e.value<=0?this.hass.callService("light","turn_off",{entity_id:e.entity}):this.hass.callService("light","turn_on",{entity_id:e.entity,brightness_pct:e.value}):e.kind==="fan"?e.value<=0?this.hass.callService("fan","turn_off",{entity_id:e.entity}):this.hass.callService("fan","set_percentage",{entity_id:e.entity,percentage:e.value}):this.hass.callService("cover","set_cover_position",{entity_id:e.entity,position:e.value}))}openRoom(e,t){this.floorId===e&&this.roomId===t||(this.floorId!==e?(this.fire("floor-tap",{floorId:e}),setTimeout(()=>this.fire("room-tap",{floorId:e,roomId:t}),60)):this.fire("room-tap",{floorId:e,roomId:t}))}goTo(e){if(this._find=null,e.kind==="room"||e.kind==="circuit"){e.roomId&&this.openRoom(e.floorId,e.roomId);return}this.floorId!==e.floorId&&this.fire("floor-tap",{floorId:e.floorId}),setTimeout(()=>this.viewer?.focus(e.floorId,e.x,e.z,e.y,e.entity),120)}listenToAnnouncements(e){if(!e){this.stopAnnouncements?.(),this.stopAnnouncements=null,clearTimeout(this.announceTimer);return}if(this.stopAnnouncements)return;let t=!1;this.stopAnnouncements=()=>t=!0,fa(this.hass,n=>this.announce(n)).then(n=>{t?n():this.stopAnnouncements=n})}announce(e){let t=e;if(t?.reload===!0){(!t.template||t.template===this.templateName)&&setTimeout(()=>location.reload(),500+Math.random()*6e3);return}if(typeof e?.message!="string"||!e.message.trim()||!da(e,this.screenName)||!ha(e))return;let n=pa(e.message);this._announcement={message:e.message,until:Date.now()+n},clearTimeout(this.announceTimer),this.announceTimer=setTimeout(()=>this._announcement=null,n),ma(this.hass,e)}renderAnnouncement(){let e=this._announcement;return e?m`<button class="nf-announcement" role="alert" title=${R(this.hass,"close")} @click=${()=>this._announcement=null}>
<span class="nf-announcement-icon" aria-hidden="true">📢</span><span class="nf-announcement-text">${e.message}</span>
</button>`:f}renderAlerts(){let e=this.building;if(!this._alerts.length||!e)return f;let t=this._alerts.slice(0,3);return m`<div class="nf-alert-banner" role="alert">
${t.map(n=>m`<button class="nf-alert nf-alert-${n.kind}" style=${n.color?`border-left-color:${n.color}`:""} title=${Oo(this.hass,e,n)} @click=${()=>this.jumpTo(n)}>${Oo(this.hass,e,n)}</button>`)}
${t.map(n=>m`<button class="nf-alert nf-alert-${n.kind}" style=${n.color?`border-left-color:${n.color}`:""} title=${Lo(this.hass,e,n)} @click=${()=>this.jumpTo(n)}>${Lo(this.hass,e,n)}</button>`)}
${this._alerts.length>3?m`<span class="nf-alert-more">+${this._alerts.length-3}</span>`:f}
</div>`}renderScenes(){let e=this.building;if(!this.scenes||!this.roomId||this.panelOpen||!e||!this.hass)return f;let t=e.floors.flatMap(i=>i.rooms).find(i=>i.id===this.roomId),n=t?K(this.hass,t).filter(i=>D(i)==="scene"||D(i)==="script").slice(0,6):[];if(!n.length)return f;let o=t?.area_id?this.hass.areas?.[t.area_id]?.name:void 0;return m`<div class="nf-scenes">
${n.map(i=>m`<button class="nf-chip" aria-pressed=${this._sceneFired===i} @click=${()=>this.runScene(i)}>${L(this.hass,i,o)}</button>`)}
</div>`}renderFind(){let e=this.building;if(!e||!this.hass)return f;if(this._find===null)return m`<button class="nf-find-btn" title=${R(this.hass,"find")} aria-label=${R(this.hass,"find")} @click=${()=>this._find=""}>
<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="6.5" /><path d="M16 16l4.5 4.5" /></svg>
</button>`;let t=fc(this.findIndex??=mc(this.hass,e),this._find);return m`<div class="nf-find">
</button>`;let t=_c(this.findIndex??=gc(this.hass,e),this._find);return m`<div class="nf-find">
<input
type="search"
placeholder=${R(this.hass,"find_placeholder")}
@@ -1549,11 +1549,11 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
<button class="nf-find-close" aria-label=${R(this.hass,"close")} @click=${()=>this._find=null}>✕</button>
${this._find.trim()?m`<div class="nf-find-list">
${t.length?t.map(n=>m`<button @click=${()=>this.goTo(n)}>
<span class="nf-find-icon"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d=${n.icon?tr(n.icon):"M4 10l8-6 8 6v10H4z"} /></svg></span>
<span class="nf-find-icon"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d=${n.icon?rr(n.icon):"M4 10l8-6 8 6v10H4z"} /></svg></span>
<span><b>${n.name}</b>${n.where?m`<small>${n.where}</small>`:f}</span>
</button>`):m`<p>${R(this.hass,"find_none")}</p>`}
</div>`:f}
</div>`}renderCentral(){let e=this.building,t=this.hass;if(!e||!t||!this.central||this._find!==null)return f;let n=(g,_)=>R(t,g,_),o=m`<button
</div>`}renderCentral(){let e=this.building,t=this.hass;if(!e||!t||!this.central||this._find!==null)return f;let n=(_,w)=>R(t,_,w),o=m`<button
class="nf-central-btn ${this._central?"nf-central-on":""}"
title=${n("central")}
aria-label=${n("central")}
@@ -1561,15 +1561,15 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
@click=${()=>{this._central=!this._central,this._armed=null}}
>
<svg viewBox="0 0 24 24" width="19" height="19" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linejoin="round"><path d="M12 3.5l2.6 5.3 5.9.9-4.3 4.1 1 5.8L12 16.9l-5.2 2.7 1-5.8-4.3-4.1 5.9-.9z" /></svg>
</button>`;if(!this._central)return o;let i=this.floorId?e.floors.find(g=>g.id===this.floorId):void 0,s=i?[i]:e.floors,a=s.flatMap(g=>go(t,g).lights),l=s.flatMap(g=>go(t,g).covers),c=a.filter(g=>t.states[g]?.state==="on").length,u=!i,d=(g,_,M,$)=>{if($.length){if(u&&this._armed!==g){this._armed=g,clearTimeout(this.armTimer),this.armTimer=setTimeout(()=>this._armed=null,3500);return}this._armed=null,t.callService(_,M,{entity_id:$})}},p=(g,_,M,$,k)=>m`<button class="nf-btn ${this._armed===g?"nf-central-armed":""}" ?disabled=${!k.length} @click=${()=>d(g,M,$,k)}>
${this._armed===g?n("central_sure"):n(_)}
</button>`,h=e.settings.favorite_floors??{},w=(e.settings.favorites??[]).filter(g=>t.states[g]&&(!h[g]||!i||h[g]===i.id)),b=this.buttons??e.settings.buttons??[];return m`${o}
</button>`;if(!this._central)return o;let i=this.floorId?e.floors.find(_=>_.id===this.floorId):void 0,s=i?[i]:e.floors,a=s.flatMap(_=>bo(t,_).lights),l=s.flatMap(_=>bo(t,_).covers),c=a.filter(_=>t.states[_]?.state==="on").length,u=!i,d=(_,w,M,$)=>{if($.length){if(u&&this._armed!==_){this._armed=_,clearTimeout(this.armTimer),this.armTimer=setTimeout(()=>this._armed=null,3500);return}this._armed=null,t.callService(w,M,{entity_id:$})}},p=(_,w,M,$,x)=>m`<button class="nf-btn ${this._armed===_?"nf-central-armed":""}" ?disabled=${!x.length} @click=${()=>d(_,M,$,x)}>
${this._armed===_?n("central_sure"):n(w)}
</button>`,h=e.settings.favorite_floors??{},g=(e.settings.favorites??[]).filter(_=>t.states[_]&&(!h[_]||!i||h[_]===i.id)),b=this.buttons??e.settings.buttons??[];return m`${o}
<div class="nf-central ${this.centralOpen?"nf-central-big":""}" role="dialog" aria-label=${n("central")}>
<b>${i?i.name:n("central_house")}</b>
<div class="nf-central-row">
<span>${n("central_lights")}${a.length?m` <small>${c}/${a.length}</small>`:f}</span>
${p("lights_on","central_on","light","turn_on",a.filter(g=>t.states[g]?.state==="off"))}
${p("lights_off","central_off","light","turn_off",a.filter(g=>t.states[g]?.state==="on"))}
${p("lights_on","central_on","light","turn_on",a.filter(_=>t.states[_]?.state==="off"))}
${p("lights_off","central_off","light","turn_off",a.filter(_=>t.states[_]?.state==="on"))}
</div>
${l.length?m`<div class="nf-central-row">
<span>${n("central_covers")} <small>${l.length}</small></span>
@@ -1577,26 +1577,26 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
${p("covers_close","central_close","cover","close_cover",l)}
</div>`:f}
<b>${n("central_favorites")}</b>
${w.length?m`<div class="nf-central-favs">
${w.map(g=>{let[_,M]=Ks(g),$=t.states[g],k=_==="homeassistant"&&$?.state==="on";return m`<button
${g.length?m`<div class="nf-central-favs">
${g.map(_=>{let[w,M]=Us(_),$=t.states[_],x=w==="homeassistant"&&$?.state==="on";return m`<button
class="nf-chip"
aria-pressed=${k||this._sceneFired===g}
aria-pressed=${x||this._sceneFired===_}
?disabled=${I($)}
@click=${()=>{t.callService(_,M,{entity_id:g}),this._sceneFired=g,setTimeout(()=>this._sceneFired=null,600)}}
@click=${()=>{t.callService(w,M,{entity_id:_}),this._sceneFired=_,setTimeout(()=>this._sceneFired=null,600)}}
>
${L(t,g)}
${L(t,_)}
</button>`})}
</div>`:b.length?f:m`<p class="nf-central-hint">${n("central_no_favorites")}</p>`}
${b.length?m`<div class="nf-central-favs">
${b.map(g=>m`<button
${b.map(_=>m`<button
class="nf-chip nf-own-btn"
aria-pressed=${Gs(t,g)}
@click=${_=>{_o(t,_.currentTarget,g),g.action!=="service"&&(this._central=!1)}}
aria-pressed=${js(t,_)}
@click=${w=>{wo(t,w.currentTarget,_),_.action!=="service"&&(this._central=!1)}}
>
${g.icon?m`<ha-icon .icon=${g.icon.startsWith("mdi:")?g.icon:`mdi:${g.icon}`}></ha-icon>`:f}${g.label}
${_.icon?m`<ha-icon .icon=${_.icon.startsWith("mdi:")?_.icon:`mdi:${_.icon}`}></ha-icon>`:f}${_.label}
</button>`)}
</div>`:f}
</div>`}toggleLock(){this._locked=!this._locked;try{localStorage.setItem($c,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 o=await on(this.hass,nl(this.watched),n,t);if(!this._travel||this._travel.from!==n)return;this._travel={...this._travel,history:o,moments:rl(o,n,t),loading:!1}}catch{this._travel=null,this._error=R(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 o=n.t+250*n.speed;o>=n.to&&this.playTravel(!1),this.travelTo(o)},250)))}renderTravel(){if(!this.hass||this.clean)return f;let e=a=>R(this.hass,a),t=this._travel;if(!t)return this.travelButton?m`<button class="nf-travel-btn" title=${e("travel")} aria-label=${e("travel")} @click=${()=>{this.openTravel(24)}}>⏪</button>`:f;let n=this.hass.language??navigator.language,o=new Intl.DateTimeFormat(n,{weekday:"short",hour:"2-digit",minute:"2-digit"}).format(new Date(t.t)),i=t.to-t.from||1,s=[[60,"travel_speed_min"],[600,"travel_speed_10min"],[3600,"travel_speed_hour"]];return m`<div class="nf-travel" role="group" aria-label=${e("travel")}>
</div>`}toggleLock(){this._locked=!this._locked;try{localStorage.setItem(Ec,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 o=await on(this.hass,ol(this.watched),n,t);if(!this._travel||this._travel.from!==n)return;this._travel={...this._travel,history:o,moments:il(o,n,t),loading:!1}}catch{this._travel=null,this._error=R(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 o=n.t+250*n.speed;o>=n.to&&this.playTravel(!1),this.travelTo(o)},250)))}renderTravel(){if(!this.hass||this.clean)return f;let e=a=>R(this.hass,a),t=this._travel;if(!t)return this.travelButton?m`<button class="nf-travel-btn" title=${e("travel")} aria-label=${e("travel")} @click=${()=>{this.openTravel(24)}}>⏪</button>`:f;let n=this.hass.language??navigator.language,o=new Intl.DateTimeFormat(n,{weekday:"short",hour:"2-digit",minute:"2-digit"}).format(new Date(t.t)),i=t.to-t.from||1,s=[[60,"travel_speed_min"],[600,"travel_speed_10min"],[3600,"travel_speed_hour"]];return m`<div class="nf-travel" role="group" aria-label=${e("travel")}>
<button class="nf-travel-play" aria-label=${e(t.playing?"travel_pause":"travel_play")} ?disabled=${t.loading} @click=${()=>this.playTravel(!t.playing)}>${t.playing?"\u23F8":"\u25B6"}</button>
<b class="nf-travel-when">${t.loading?e("travel_loading"):o}</b>
<div class="nf-travel-track">
@@ -1632,7 +1632,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
<span>${L(this.hass,e.entity)}</span>
<b>${t?R(this.hass,"swipe_off"):`${e.value} %`}</b>
<i><em style="height:${e.value}%"></em></i>
</div>`}tapPlate(e,t,n){let o=this.building?.floors.flatMap(s=>s.furniture).find(s=>s.id===e),i=o?bo(o.gang_entities,q(o.type)?.gangs??0):[];if(i.length===1)return this.onDeviceTap(i[0],t,n);i.length>1&&(this._plate={ids:i,x:t,y:n})}renderPlate(){let e=this._plate;if(!e||!this.hass)return f;let t=this.hass,n=()=>this._plate=null;return m`<div class="nf-menu-backdrop" @click=${n}></div>
</div>`}tapPlate(e,t,n){let o=this.building?.floors.flatMap(s=>s.furniture).find(s=>s.id===e),i=o?vo(o.gang_entities,q(o.type)?.gangs??0):[];if(i.length===1)return this.onDeviceTap(i[0],t,n);i.length>1&&(this._plate={ids:i,x:t,y:n})}renderPlate(){let e=this._plate;if(!e||!this.hass)return f;let t=this.hass,n=()=>this._plate=null;return m`<div class="nf-menu-backdrop" @click=${n}></div>
<div class="nf-plate-menu" style="left:${Math.max(8,e.x-110)}px;top:${Math.max(8,e.y-20-e.ids.length*46)}px" role="menu">
${e.ids.map((o,i)=>{let s=t.states[o],a=Q(s)||s?.state==="on";return m`<button role="menuitem" class=${a?"on":""} @click=${()=>{n(),this.onDeviceTap(o,e.x,e.y)}}><b>${i+1}</b><span>${L(t,o)}</span><i>${s?ee(t,s):"\u2013"}</i></button>`})}
</div>`}renderMenu(){let e=this._menu;if(!e||!this.hass)return f;let t=this.renderRoot.querySelector(".nf-stage"),n=t?.clientWidth??800,o=t?.clientHeight??600,i=Math.max(8,Math.min(n-240,e.x-116)),s=Math.max(8,Math.min(o-360,e.y-170));return m`<div class="nf-menu-backdrop" @click=${()=>this._menu=null}></div>
@@ -1645,27 +1645,28 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
.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=${Xn(this.hass,this.building?.floors??[],e.entity)}
@close=${()=>this._menu=null}
></nf-quick-menu>`}myPositionOf(e){for(let t of this.building?.floors??[])for(let n of t.openings){let o=this.openingLinks?.get(n.id);if(n.my_position!=null&&(o?.cover===e||o?.cover2===e))return n.my_position}return null}onDeviceTap(e,t=0,n=0){if(e.startsWith("lamp:")||this._travel)return;let o=e.startsWith("tap:")?e.slice(4):this.tapPins.get(e);if(o){let s=this.building?.floors.flatMap(a=>a.furniture).find(a=>a.id===o);s?.tap&&_o(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??Fe(s,l=>this.furnitureLinks?.get(l.id)?.power??null).grid:null;a&&fe(this,a);return}let i=D(e);if(i==="cover"||i==="media"){this._menu={entity:e,x:t,y:n};return}if(i==="lock"){let s=po(this.hass,e),a=L(this.hass,e);confirm(R(this.hass,s?"lock_confirm_lock":"lock_confirm_unlock",{name:a}))&&this.hass.callService("lock",s?"lock":"unlock",{entity_id:e});return}if(i&&ws.has(i)){if(this.confirmSet.has(e)&&!confirm(R(this.hass,"confirm_switch",{name:L(this.hass,e)})))return;sa(this.hass,e)}else fe(this,e)}pluginTapped(e){let t=this.hass?.states[e],n=this.placementInfo.get(e);if(!t||!n)return!1;let o=this.building?.floors.find(i=>i.id===n.floorId)?.placements.find(i=>i.entity_id===e);return Xi({hass:this.hass,entityId:e,state:t},n,o?.plugin??void 0,{showWindow:(i,s)=>{i&&"hass"in i&&(i.hass=this.hass),this._pluginWindow=i?{node:i,title:s?.title??""}:null},moreInfo:i=>fe(this,i??e)})}renderPluginWindow(){let e=this._pluginWindow;return e?m`<div class="nf-plugin-window" @pointerdown=${t=>t.stopPropagation()}>
></nf-quick-menu>`}myPositionOf(e){for(let t of this.building?.floors??[])for(let n of t.openings){let o=this.openingLinks?.get(n.id);if(n.my_position!=null&&(o?.cover===e||o?.cover2===e))return n.my_position}return null}onDeviceTap(e,t=0,n=0){if(e.startsWith("lamp:")||this._travel)return;let o=e.startsWith("tap:")?e.slice(4):this.tapPins.get(e);if(o){let s=this.building?.floors.flatMap(a=>a.furniture).find(a=>a.id===o);s?.tap&&wo(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??Fe(s,l=>this.furnitureLinks?.get(l.id)?.power??null).grid:null;a&&fe(this,a);return}let i=D(e);if(i==="cover"||i==="media"){this._menu={entity:e,x:t,y:n};return}if(i==="lock"){let s=fo(this.hass,e),a=L(this.hass,e);confirm(R(this.hass,s?"lock_confirm_lock":"lock_confirm_unlock",{name:a}))&&this.hass.callService("lock",s?"lock":"unlock",{entity_id:e});return}if(i&&ys.has(i)){if(this.confirmSet.has(e)&&!confirm(R(this.hass,"confirm_switch",{name:L(this.hass,e)})))return;la(this.hass,e)}else fe(this,e)}pluginTapped(e){let t=this.hass?.states[e],n=this.placementInfo.get(e);if(!t||!n)return!1;let o=this.building?.floors.find(i=>i.id===n.floorId)?.placements.find(i=>i.entity_id===e);return ts({hass:this.hass,entityId:e,state:t},n,o?.plugin??void 0,{showWindow:(i,s)=>{i&&"hass"in i&&(i.hass=this.hass),this._pluginWindow=i?{node:i,title:s?.title??""}:null},moreInfo:i=>fe(this,i??e)})}renderPluginWindow(){let e=this._pluginWindow;return e?m`<div class="nf-plugin-window" @pointerdown=${t=>t.stopPropagation()}>
<div class="nf-pw-head"><span>${e.title}</span><button class="nf-pw-close" aria-label=${R(this.hass,"close")} @click=${()=>this._pluginWindow=null}>✕</button></div>
<div class="nf-pw-body">${e.node}</div>
</div>`: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 o of e.floors)for(let i of o.furniture){if(!rc(i.type))continue;let s=this.furnitureLinks?.get(i.id),a=nc(t,s?.entity??s?.power??null);a&&n.push({id:i.id,name:i.name||he(t,i.type),floorId:o.id,x:i.x,z:i.z,at:{floorId:o.id,x:i.x,z:i.z,y:le(o,i)+i.h+.5},pump:a})}return n}livePrinters(e){let t=this.hass,n=[];if(!t)return n;for(let o of e.floors)for(let i of o.furniture){if(!ei(i.type))continue;let s=this.furnitureLinks?.get(i.id),a=Xo(t,s?.entity??s?.power??null);!a||!a.printing&&!/pause|finish|complete|error/.test(a.status)||n.push({id:i.id,name:i.name||he(t,i.type),at:{floorId:o.id,x:i.x,z:i.z,y:le(o,i)+i.h+.5},printer:a})}return n}liveCars(e,t){let n=[];for(let o of t.floors)for(let i of o.furniture){if(i.type!=="parking")continue;let s=lc(e,i);if(!s||s.soc===null&&s.range===null&&s.locked===null&&s.climateOn===null)continue;let a=Wo(e,i),l=a?xl(i,a):null,c=i.name||(a?he(e,a):he(e,i.type));n.push({spot:i.id,name:c,at:{floorId:o.id,x:i.x,z:i.z,y:le(o,i)+(l?.h??.2)+.6},car:s})}return n}liveMedia(e,t){let n=[];for(let o of t.floors){for(let i of o.furniture){let s=this.furnitureLinks?.get(i.id)?.entity;s?.startsWith("media_player.")&&n.push({entity:s,name:i.name||he(e,i.type),at:{floorId:o.id,x:i.x,z:i.z,y:le(o,i)+i.h+.15},rings:i.sound_rings})}for(let i of o.placements)i.entity_id.startsWith("media_player.")&&n.push({entity:i.entity_id,name:i.name||L(e,i.entity_id),at:{floorId:o.id,x:i.x,z:i.z,y:(i.y??1.1)+.15},rings:i.sound_rings})}return ll(e,n)}refreshToday(e){let t=this.hass,n=e.settings.calendars??[],o=Math.max(1,Math.min(7,e.settings.today_days??1)),i=`${new Date().toDateString()}|${o}`;!t||!n.length||Date.now()-this.todayAt<9e5&&i===this.todayDay||(this.todayAt=Date.now(),this.todayDay=i,Jl(t,n,o).then(s=>this._todayItems=s))}refreshForecast(e){let t=this.hass,n=e.settings.forecast&&t?Ge(t,this.weatherEntityId??e.settings.weather_entity):null;if(!t||!n)return;let o=`${n}|${new Date().toDateString()}`;Date.now()-this.forecastAt<18e5&&o===this.forecastKey||(this.forecastAt=Date.now(),this.forecastKey=o,ec(t,n).then(i=>this._forecast=i))}renderForecast(e){let t=this.building,n=this.hass,o=t?.settings.forecast;if(!t||!n||!o||o.corner!==e||this.clean)return f;if(e==="top_right"&&(this.roomId||this.panelOpen))return f;let i=Xl(this._forecast,Math.max(1,Math.min(7,o.days)));if(!i.length)return f;let s=Ge(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"}),p=h=>h===null?"\u2013":`${Math.round(h)}\xB0`;return m`<section class="nf-forecast" aria-label=${R(n,"forecast")}>
</div>`: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 o of e.floors)for(let i of o.furniture){if(!ic(i.type))continue;let s=this.furnitureLinks?.get(i.id),a=oc(t,s?.entity??s?.power??null);a&&n.push({id:i.id,name:i.name||he(t,i.type),floorId:o.id,x:i.x,z:i.z,at:{floorId:o.id,x:i.x,z:i.z,y:le(o,i)+i.h+.5},pump:a})}return n}livePrinters(e){let t=this.hass,n=[];if(!t)return n;for(let o of e.floors)for(let i of o.furniture){if(!ni(i.type))continue;let s=this.furnitureLinks?.get(i.id),a=ti(t,s?.entity??s?.power??null);!a||!a.printing&&!/pause|finish|complete|error/.test(a.status)||n.push({id:i.id,name:i.name||he(t,i.type),at:{floorId:o.id,x:i.x,z:i.z,y:le(o,i)+i.h+.5},printer:a})}return n}liveCars(e,t){let n=[];for(let o of t.floors)for(let i of o.furniture){if(i.type!=="parking")continue;let s=uc(e,i);if(!s||s.soc===null&&s.range===null&&s.locked===null&&s.climateOn===null)continue;let a=Bo(e,i),l=a?Ml(i,a):null,c=i.name||(a?he(e,a):he(e,i.type));n.push({spot:i.id,name:c,at:{floorId:o.id,x:i.x,z:i.z,y:le(o,i)+(l?.h??.2)+.6},car:s})}return n}liveMedia(e,t){let n=[];for(let o of t.floors){for(let i of o.furniture){let s=this.furnitureLinks?.get(i.id)?.entity;s?.startsWith("media_player.")&&n.push({entity:s,name:i.name||he(e,i.type),at:{floorId:o.id,x:i.x,z:i.z,y:le(o,i)+i.h+.15},rings:i.sound_rings})}for(let i of o.placements)i.entity_id.startsWith("media_player.")&&n.push({entity:i.entity_id,name:i.name||L(e,i.entity_id),at:{floorId:o.id,x:i.x,z:i.z,y:(i.y??1.1)+.15},rings:i.sound_rings})}return ul(e,n)}refreshToday(e){let t=this.hass,n=e.settings.calendars??[],o=Math.max(1,Math.min(7,e.settings.today_days??1)),i=`${new Date().toDateString()}|${o}`;!t||!n.length||Date.now()-this.todayAt<9e5&&i===this.todayDay||(this.todayAt=Date.now(),this.todayDay=i,Xl(t,n,o).then(s=>this._todayItems=s))}refreshForecast(e){let t=this.hass,n=e.settings.forecast&&t?Ue(t,this.weatherEntityId??e.settings.weather_entity):null;if(!t||!n)return;let o=`${n}|${new Date().toDateString()}`;Date.now()-this.forecastAt<18e5&&o===this.forecastKey||(this.forecastAt=Date.now(),this.forecastKey=o,nc(t,n).then(i=>this._forecast=i))}renderForecast(e){let t=this.building,n=this.hass,o=t?.settings.forecast;if(!t||!n||!o||o.corner!==e||this.clean)return f;if(e==="top_right"&&(this.roomId||this.panelOpen))return f;let i=tc(this._forecast,Math.max(1,Math.min(7,o.days)));if(!i.length)return f;let s=Ue(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"}),p=h=>h===null?"\u2013":`${Math.round(h)}\xB0`;return m`<section class="nf-forecast" aria-label=${R(n,"forecast")}>
<ul>
${i.map((h,w)=>m`<li>
<span class="nf-fc-day">${w===0?R(n,"today"):d.format(new Date(h.day))}</span>
${i.map((h,g)=>m`<li>
<span class="nf-fc-day">${g===0?R(n,"today"):d.format(new Date(h.day))}</span>
<span class="nf-fc-icon" aria-hidden="true">${h.icon}</span>
<span class="nf-fc-temp" title=${l}><b>${p(h.high)}</b> <small>${p(h.low)}</small></span>
<span class="nf-fc-rain">${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)} %`:""}</span>
</li>`)}
</ul>
</section>`}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"),o=this.today===!1?f:this.renderTodayCard(e,t);return o===f&&n===f?f:m`<div class="nf-right-col" style=${this.clock==="top_right"?"top: 78px":""}>${o}${n}</div>`}renderTodayCard(e,t){let n=Zl(t,e,Date.now(),{today:R(t,"care_bin_today"),tomorrow:R(t,"care_bin_tomorrow")}),o=Yl([...n,...this._todayItems??[]]);if(!o.length&&!(e.settings.calendars??[]).length)return f;let i=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 R(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=o.flatMap((u,d)=>[(u.day??0)>0&&(o[d-1]?.day??0)!==u.day?m`<li class="nf-today-day">${l(u.day??0)}</li>`:f,m`<li class=${u.past?"nf-today-past":""}><time>${u.kind==="bin"?"\u{1F5D1}":u.time||"\u25CF"}</time><span>${u.title}<small>${u.source}</small></span></li>`]);return m`<section class="nf-today ${i?"":"nf-today-folded"}" aria-label=${R(t,"today")}>
</section>`}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"),o=this.today===!1?f:this.renderTodayCard(e,t);return o===f&&n===f?f:m`<div class="nf-right-col" style=${this.clock==="top_right"?"top: 78px":""}>${o}${n}</div>`}renderTodayCard(e,t){let n=Jl(t,e,Date.now(),{today:R(t,"care_bin_today"),tomorrow:R(t,"care_bin_tomorrow")}),o=Ql([...n,...this._todayItems??[]]);if(!o.length&&!(e.settings.calendars??[]).length)return f;let i=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 R(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=o.flatMap((u,d)=>[(u.day??0)>0&&(o[d-1]?.day??0)!==u.day?m`<li class="nf-today-day">${l(u.day??0)}</li>`:f,m`<li class=${u.past?"nf-today-past":""}><time>${u.kind==="bin"?"\u{1F5D1}":u.time||"\u25CF"}</time><span>${u.title}<small>${u.source}</small></span></li>`]);return m`<section class="nf-today ${i?"":"nf-today-folded"}" aria-label=${R(t,"today")}>
<button class="nf-today-head" aria-expanded=${i} @click=${()=>this._todayOpen=!i}>
<b>📅 ${R(t,"today")}</b><span>${s}</span>
</button>
${i?o.length?m`<ul>
${c}
</ul>`:m`<p class="nf-today-none">${R(t,"today_none")}</p>`:f}
</section>`}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=Fe(e,s=>this.furnitureLinks?.get(s.id)?.power??null),o=e.energy,i={solar:o.solar?[o.solar]:n.solar,grid:o.grid??n.grid,gridInvert:!!o.grid_invert,battery:o.battery?[o.battery]:n.battery,batteryInvert:!!o.battery_invert,consumption:o.consumption};Va(t,i).then(s=>{this.week=s,this.syncDevices(!0)}).catch(()=>this.week=null)}meterRows(e,t=null){let n=this.hass,o=[],i=this.floorId?e.floors.find(a=>a.id===this.floorId):void 0,s=i?.power_entity?j(n?.states[i.power_entity]):null;if(i&&s!==null){let a=t&&t>0?` \xB7 ${R(n,"floor_power_share",{n:Math.round(Math.max(0,s)/t*100)})}`:"";o.push({icon:"\u26A1",label:i.name,value:`${it(n,s)}${a}`})}for(let[a,l,c]of[["gas","\u{1F525}","energy_gas_short"],["water","\u{1F4A7}","energy_water_short"]]){let u=e.energy[a],d=u?n?.states[u]:void 0;d&&!I(d)&&o.push({icon:l,label:R(n,c),value:ee(n,d)})}return o}refreshDayCurves(e){let t=this.hass;if(!t||this._travel||Date.now()-this.curvesAt<6e5)return;this.curvesAt=Date.now();let n=a=>tn(a,e,en(a,e),Fe(e,l=>this.furnitureLinks?.get(l.id)?.power??null)),o=ol(t,n),i=Date.now(),s=i-24*36e5;on(t,o,s,i,!0).then(a=>{this.dayCurves=il(t,a,s,i,n),this.syncDevices(!0)}).catch(()=>this.dayCurves=null)}syncLhCards(e,t,n,o,i){let s=[],a=n.summary,l=a.solar!==null||a.grid!==null||a.battery!==null||a.consumption!==null,c=pn(t),u=(this.floorId?t.floors.find(d=>d.id===this.floorId):void 0)??[...t.floors].sort((d,p)=>p.elevation-d.elevation)[0];if(this.liveCardsOn&&!this.dimmed&&!this.roomId&&l&&c&&u){let d=0,p=0,h=0;for(let w of u.rooms)for(let[b,g]of w.points)d+=b,p+=g,h++;s.push({kind:"house",at:{floorId:u.id,x:h?d/h:c.x,z:h?p/h:c.z,y:u.height+(this.floorId?1.2:3.2)},summary:a,autarky:n.autarky,curves:this.dayCurves??void 0,week:this.week??void 0,meters:this.meterRows(t,a.consumption)}),this.refreshDayCurves(t),this.refreshWeek(t)}if(this.liveCardsOn&&!this.dimmed&&!this.roomId){for(let d of o)s.push({kind:"car",at:d.at,spot:d.spot,name:d.name,car:d.car});for(let d of this.livePrinters(t))s.push({kind:"printer",at:d.at,name:d.name,printer:d.printer});for(let d of this.liveHeatPumps(t))s.push({kind:"heatpump",at:d.at,name:d.name,pump:d.pump});for(let d of i)s.push({kind:"media",at:{...d.at,y:d.at.y+.5},media:d})}JSON.stringify(s)!==JSON.stringify(this._liveCards)&&(this._liveCards=s),e.setLiveAnchors(s.map(d=>d.at),s.length?(d,p,h,w)=>this.placeLhCard(d,p,h,w):null)}placeLhCard(e,t,n,o){let i=this.renderRoot.querySelector(`.live-card[data-i="${e}"]`);i&&(i.dataset.x=String(t),i.dataset.y=String(n),i.style.visibility=o?"visible":"hidden",e===this._liveCards.length-1&&uc(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:m`<div class="nf-topleft">${this.clock==="top_left"?this.renderClock(!0):f}${e}${t}</div>`}renderLhEnergy(){let e=this.ownSensors(),t=this._liveEnergy?.summary;if(!(!!t&&!this.roomId&&this.showEnergy&&!!this.hass&&!(t.consumption===null&&t.grid===null&&t.solar===null&&t.battery===null)))return e.length?m`<div class="nf-energy" aria-live="off">${e}</div>`:f;let o=s=>R(this.hass,s),i=[];if(t.solar!==null&&i.push({cls:"solar",label:o("energy_solar"),value:se(this.hass,t.solar)}),t.consumption!==null&&i.push({cls:"total",label:o("energy_consumption"),value:se(this.hass,t.consumption)}),t.rest!==void 0&&t.rest!==null&&i.push({cls:"total",label:o("energy_rest"),value:se(this.hass,t.rest)}),t.battery!==null||t.soc!==null){let s=[t.battery!==null?se(this.hass,Math.abs(t.battery)):null,t.soc!==null?`${Math.round(t.soc)} %`:null].filter(Boolean);i.push({cls:"battery",label:o("energy_battery"),value:s.join(" \xB7 ")})}if(t.grid!==null){let s=t.grid<0;i.push({cls:s?"export":"grid",label:o(s?"energy_grid_export":"energy_grid_import"),value:se(this.hass,Math.abs(t.grid))})}if(t.tariff&&i.push({cls:"tariff",label:o("energy_tariff"),value:`${O(this.hass,t.tariff.value,3)} ${t.tariff.unit}`.trim()}),this.building)for(let s of this.meterRows(this.building))i.push({cls:"meter",label:`${s.icon} ${s.label}`,value:s.value});return m`<div class="nf-energy" aria-live="off">
</section>`}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=Fe(e,s=>this.furnitureLinks?.get(s.id)?.power??null),o=e.energy,i={solar:o.solar?[o.solar]:n.solar,grid:o.grid??n.grid,gridInvert:!!o.grid_invert,battery:o.battery?[o.battery]:n.battery,batteryInvert:!!o.battery_invert,consumption:o.consumption};Ga(t,i).then(s=>{this.week=s,this.syncDevices(!0)}).catch(()=>this.week=null)}meterRows(e,t=null){let n=this.hass,o=[],i=this.floorId?e.floors.find(a=>a.id===this.floorId):void 0,s=i?.power_entity?j(n?.states[i.power_entity]):null;if(i&&s!==null){let a=t&&t>0?` \xB7 ${R(n,"floor_power_share",{n:Math.round(Math.max(0,s)/t*100)})}`:"";o.push({icon:"\u26A1",label:i.name,value:`${at(n,s)}${a}`})}for(let[a,l,c]of[["gas","\u{1F525}","energy_gas_short"],["water","\u{1F4A7}","energy_water_short"]]){let u=e.energy[a],d=u?n?.states[u]:void 0;d&&!I(d)&&o.push({icon:l,label:R(n,c),value:ee(n,d)})}return o}refreshDayCurves(e){let t=this.hass;if(!t||this._travel||Date.now()-this.curvesAt<6e5)return;this.curvesAt=Date.now();let n=a=>tn(a,e,en(a,e),Fe(e,l=>this.furnitureLinks?.get(l.id)?.power??null)),o=sl(t,n),i=Date.now(),s=i-24*36e5;on(t,o,s,i,!0).then(a=>{this.dayCurves=al(t,a,s,i,n),this.syncDevices(!0)}).catch(()=>this.dayCurves=null)}syncLhCards(e,t,n,o,i){let s=[],a=n.summary,l=a.solar!==null||a.grid!==null||a.battery!==null||a.consumption!==null,c=pn(t),u=(this.floorId?t.floors.find(d=>d.id===this.floorId):void 0)??[...t.floors].sort((d,p)=>p.elevation-d.elevation)[0];if(this.liveCardsOn&&!this.dimmed&&!this.roomId&&l&&c&&u){let d=0,p=0,h=0;for(let g of u.rooms)for(let[b,_]of g.points)d+=b,p+=_,h++;s.push({kind:"house",at:{floorId:u.id,x:h?d/h:c.x,z:h?p/h:c.z,y:u.height+(this.floorId?1.2:3.2)},summary:a,autarky:n.autarky,curves:this.dayCurves??void 0,week:this.week??void 0,meters:this.meterRows(t,a.consumption)}),this.refreshDayCurves(t),this.refreshWeek(t)}if(this.liveCardsOn&&!this.dimmed&&!this.roomId){for(let d of o)s.push({kind:"car",at:d.at,spot:d.spot,name:d.name,car:d.car});for(let d of this.livePrinters(t))s.push({kind:"printer",at:d.at,name:d.name,printer:d.printer});for(let d of this.liveHeatPumps(t))s.push({kind:"heatpump",at:d.at,name:d.name,pump:d.pump});for(let d of i)s.push({kind:"media",at:{...d.at,y:d.at.y+.5},media:d})}JSON.stringify(s)!==JSON.stringify(this._liveCards)&&(this._liveCards=s),e.setLiveAnchors(s.map(d=>d.at),s.length?(d,p,h,g)=>this.placeLhCard(d,p,h,g):null)}placeLhCard(e,t,n,o){let i=this.renderRoot.querySelector(`.live-card[data-i="${e}"]`);i&&(i.dataset.x=String(t),i.dataset.y=String(n),i.style.visibility=o?"visible":"hidden",e===this._liveCards.length-1&&hc(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:m`<div class="nf-topleft">${this.clock==="top_left"?this.renderClock(!0):f}${e}${t}</div>`}renderLhEnergy(){let e=this.ownSensors(),t=this._liveEnergy?.summary;if(!(!!t&&!this.roomId&&this.showEnergy&&!!this.hass&&!(t.consumption===null&&t.grid===null&&t.solar===null&&t.battery===null)))return e.length?m`<div class="nf-energy" aria-live="off">${e}</div>`:f;let o=s=>R(this.hass,s),i=[];if(t.solar!==null&&i.push({cls:"solar",label:o("energy_solar"),value:se(this.hass,t.solar)}),t.consumption!==null&&i.push({cls:"total",label:o("energy_consumption"),value:se(this.hass,t.consumption)}),t.rest!==void 0&&t.rest!==null&&i.push({cls:"total",label:o("energy_rest"),value:se(this.hass,t.rest)}),t.battery!==null||t.soc!==null){let s=[t.battery!==null?se(this.hass,Math.abs(t.battery)):null,t.soc!==null?`${Math.round(t.soc)} %`:null].filter(Boolean);i.push({cls:"battery",label:o("energy_battery"),value:s.join(" \xB7 ")})}if(t.grid!==null){let s=t.grid<0;i.push({cls:s?"export":"grid",label:o(s?"energy_grid_export":"energy_grid_import"),value:se(this.hass,Math.abs(t.grid))})}if(t.tariff&&i.push({cls:"tariff",label:o("energy_tariff"),value:`${O(this.hass,t.tariff.value,3)} ${t.tariff.unit}`.trim()}),this.building)for(let s of this.meterRows(this.building))i.push({cls:"meter",label:`${s.icon} ${s.label}`,value:s.value});return m`<div class="nf-energy" aria-live="off">
${this.liveCardsOn&&this._liveCards.some(s=>s.kind==="house")?f:i.map(s=>m`<div class="nf-energy-item nf-energy-${s.cls}"><span>${s.label}</span><b>${s.value}</b></div>`)}
${this.flows!==null?f:m`<button class="nf-energy-item nf-flow-toggle" aria-pressed=${this._flows} title=${o("flows_hint")} aria-label=${o("flows")} @click=${()=>this.toggleFlows()}>
<span>${o("flows")}</span><b>⚡</b>
@@ -1676,22 +1677,22 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
${e}
</div>`}ownSensors(){return(this.sensorBar&&this.hass?this.building?.settings.status_entities??[]:[]).filter(t=>this.hass.states[t]).map(t=>m`<button class="nf-energy-item nf-own-sensor" title=${L(this.hass,t)} @click=${()=>fe(this,t)}>
<span>${L(this.hass,t)}</span><b>${ee(this.hass,this.hass.states[t])}</b>
</button>`)}renderMapCredit(){let e=this.building?.settings.map;return Rl(e)?m`<a class="nf-map-credit" href=${Vo(e).href} target="_blank" rel="noopener">${Vo(e).text}</a>`:f}renderLegend(){if(this.heatMode==="wifi")return this.renderWifiLegend();if(this.heatMode==="none"||this.heatMode==="values")return f;let e=ot(new Date,this.hass?.config?.latitude??50),t=lr(this.heatMode,e),n=this.heatMode==="temperature",o=n?ue(this.hass,t.stops[0][0]):t.stops[0][0],i=n?ue(this.hass,t.stops[t.stops.length-1][0]):t.stops[t.stops.length-1][0],s=n?ne(this.hass):t.unit,a=l=>R(this.hass,l);return m`<div class="nf-legend">
</button>`)}renderMapCredit(){let e=this.building?.settings.map;return Tl(e)?m`<a class="nf-map-credit" href=${Go(e).href} target="_blank" rel="noopener">${Go(e).text}</a>`:f}renderLegend(){if(this.heatMode==="wifi")return this.renderWifiLegend();if(this.heatMode==="none"||this.heatMode==="values")return f;let e=st(new Date,this.hass?.config?.latitude??50),t=ur(this.heatMode,e),n=this.heatMode==="temperature",o=n?ue(this.hass,t.stops[0][0]):t.stops[0][0],i=n?ue(this.hass,t.stops[t.stops.length-1][0]):t.stops[t.stops.length-1][0],s=n?ne(this.hass):t.unit,a=l=>R(this.hass,l);return m`<div class="nf-legend">
<b>${a(`heat_${this.heatMode}`)}${this.heatMode==="temperature"?m` <small>${a(e?"heat_summer":"heat_winter")}</small>`:f}</b>
<span class="nf-legend-bar" style="background:${Ba(this.heatMode,e)}"></span>
<span class="nf-legend-bar" style="background:${Ka(this.heatMode,e)}"></span>
<span class="nf-legend-range"><span>${O(this.hass,o,0)} ${s}</span><span>${O(this.hass,i,0)} ${s}</span></span>
${this.heatValues.size?f:m`<span class="nf-legend-none">${a("heat_none_found")}</span>`}
</div>`}renderWifiLegend(){let e=this.hass,t=this.building;if(!e||!t)return f;let n=(c,u)=>R(e,c,u),o=t.floors.flatMap(c=>c.furniture.filter(u=>ti(u.type)).map(u=>ni(e,this.furnitureLinks?.get(u.id)?.entity??this.furnitureLinks?.get(u.id)?.power??null))),s=o.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=sc(a);return m`<div class="nf-legend">
</div>`}renderWifiLegend(){let e=this.hass,t=this.building;if(!e||!t)return f;let n=(c,u)=>R(e,c,u),o=t.floors.flatMap(c=>c.furniture.filter(u=>ri(u.type)).map(u=>oi(e,this.furnitureLinks?.get(u.id)?.entity??this.furnitureLinks?.get(u.id)?.power??null))),s=o.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=lc(a);return m`<div class="nf-legend">
<b>📶 ${n("heat_wifi")}</b>
<span>${n("wifi_aps",{n:o.length,clients:s})}</span>
${l.online+l.offline.length?m`<span>${n("wifi_network",{online:l.online,offline:l.offline.length})}</span>`:f}
${l.offline.length?m`<span class="nf-legend-none">${l.offline.slice(0,4).join(", ")}</span>`:f}
${o.length?f:m`<span class="nf-legend-none">${n("wifi_none")}</span>`}
</div>`}skyColor(){let e=an[this.theme]??an.neon,t=this._sky;return e.night[0].map((n,o)=>Math.round(n+(e.day[0][o]-n)*t))}render(){let e=this._sky,t=(i,s)=>`rgb(${i.map((a,l)=>Math.round(a+(s[l]-a)*e)).join(",")})`,n=an[this.theme]??an.neon,o=`--nf-sky:${t(n.night[0],n.day[0])};--nf-ground:${t(n.night[1],n.day[1])}`+sl(this.building?.settings.backdrop);return m`<div
</div>`}skyColor(){let e=an[this.theme]??an.neon,t=this._sky;return e.night[0].map((n,o)=>Math.round(n+(e.day[0][o]-n)*t))}render(){let e=this._sky,t=(i,s)=>`rgb(${i.map((a,l)=>Math.round(a+(s[l]-a)*e)).join(",")})`,n=an[this.theme]??an.neon,o=`--nf-sky:${t(n.night[0],n.day[0])};--nf-ground:${t(n.night[1],n.day[1])}`+ll(this.building?.settings.backdrop);return m`<div
class="nf-stage ${this.roomLabels?"":"nf-no-room-names"} ${this._low?"nf-low":""} ${this.panelOpen?"nf-panel-open":""} ${this._alerts.length?"nf-has-alerts":""} ${this._narrowStage?"nf-narrow":""}"
style=${o}
>
${this._error?m`<p class="nf-error">${this._error}</p>`:f} ${this.renderTopLeft()} ${dc(this.hass,this.roomId||this.panelOpen?[]:this._liveCards,(i,s,a,l)=>this.hass?.callService(i,s,{entity_id:a,...l}),{folded:this._houseFolded,toggle:()=>this.toggleHouseFold()})} ${this.clean?f:this.renderLegend()} ${this.renderMapCredit()}
${this._error?m`<p class="nf-error">${this._error}</p>`:f} ${this.renderTopLeft()} ${pc(this.hass,this.roomId||this.panelOpen?[]:this._liveCards,(i,s,a,l)=>this.hass?.callService(i,s,{entity_id:a,...l}),{folded:this._houseFolded,toggle:()=>this.toggleHouseFold()})} ${this.clean?f:this.renderLegend()} ${this.renderMapCredit()}
${this.renderAlerts()} ${this.renderAnnouncement()} ${this.clean?f:m`${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.showStats&&this._stats?m`<span class="nf-stats"
@@ -1700,7 +1701,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
${R(this.hass,"stats",{calls:this._stats.calls,tris:this._stats.triangles.toLocaleString()})} ·
${R(this.hass,this._stats.low?"stats_low":"stats_full",{r:O(this.hass,this._stats.pixelRatio,2)})}</span
>`:f}
</div>`}static styles=[Se,Ve,hc,te`
</div>`}static styles=[Se,Ke,mc,te`
:host {
display: block;
position: relative;
@@ -3278,26 +3279,26 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
inset: auto 16px 16px;
color: var(--nf-danger);
}
`]};customElements.get("nf-view3d")||customElements.define("nf-view3d",ui);function se(r,e){return Math.abs(e)>=1e3?`${O(r,e/1e3,1)} kW`:`${Math.round(e)} W`}function ci(r){return r.type==="tv_board"?r.h+.9:r.type==="tv_wall"||r.type==="kitchen_wall"?r.h+.25:r.h+.35}function vm(r,e){let t=e.attributes.percentage;return e.state==="on"&&typeof t=="number"?`${Math.round(t)} %`:ee(r,e)}var Ec;function Rc(){let r=new URL("./nextfloor-editor.js?v=d84483285eb6",new URL(import.meta.url)).href;return Ec??=import(r),Ec}var ym=.25,zc=r=>Math.round(r*1e3)/1e3,Tc=(r,e,t)=>r.rooms.find(n=>n.points.length>=3&&H([e,t],n.points));function hi(r,e,t,n,o){let i=Tc(r,e,t);if(!i)return[n,o];let s=(a,l)=>H([a,l],i.points);return s(n,o)?[n,o]:s(n,t)?[n,t]:s(e,o)?[e,o]:[e,t]}function km(r,e,t,n){return r.rooms.some(o=>o.id!==e.id&&o.points.some((i,s)=>{let a=o.points[(s+1)%o.points.length];return Math.abs(oe(Z(i,t),n))<.02&&Math.abs(oe(Z(a,t),n))<.02}))}var di=(r,e)=>Math.abs((r-e+540)%360-180);function Fc(r,e,t,n=ym){let o=Tc(r,e.x,e.z);if(!o)return null;let i=o.points,s=et(i)>=0?1:-1,a=null;return i.forEach((l,c)=>{let u=i[(c+1)%i.length],d=Te(Z(u,l));if(d<.3)return;let p=[(u[0]-l[0])/d,(u[1]-l[1])/d],h=[-p[1]*s,p[0]*s],w=oe(Z([e.x,e.z],l),p);if(w<0||w>d)return;let b=km(r,o,l,h)?t/2:0,g=oe(Z([e.x,e.z],l),h)-b,_=Math.atan2(-h[0],h[1])*180/Math.PI,$=[{rotation:_,extent:e.d/2},{rotation:_+90,extent:e.w/2},{rotation:_-90,extent:e.w/2}].reduce((y,F)=>di(e.rotation,F.rotation)<di(e.rotation,y.rotation)?F:y);if(di(e.rotation,$.rotation)>50)return;let k=g-$.extent;Math.abs(k)>n||a&&Math.abs(k)>=Math.abs(a.gap)||(a={x:zc(e.x-h[0]*k),z:zc(e.z-h[1]*k),rotation:(Math.round($.rotation)%360+360)%360,gap:k})}),a&&{x:a.x,z:a.z,rotation:a.rotation}}function Rr(r,e,t){let n=structuredClone(r);for(let o of n.floors){let i=o.furniture.find(s=>s.id===e);i&&t(i,o)}return n}function zr(r,e,t){let n=structuredClone(r);for(let o of n.floors){let i=o.placements.find(s=>s.entity_id===e);i&&t(i,o)}return n}function Dc(r,e){let t=structuredClone(r);for(let n of t.floors)n.furniture=n.furniture.filter(o=>o.id!==e);return t}function Pc(r,e){let t=structuredClone(r);for(let n of t.floors)n.placements=n.placements.filter(o=>o.entity_id!==e);return t}function Hc(r,e,t,n){return zr(r,e,(o,i)=>{[o.x,o.z]=hi(i,o.x,o.z,t,n)})}function Ic(r,e,t,n){let o=r.settings.wall_interior??.12;return Rr(r,e,(i,s)=>{[i.x,i.z]=hi(s,i.x,i.z,t,n);let a=Fc(s,i,o);a&&Object.assign(i,a)})}var pi=(r,e)=>((r+e)%360+360)%360,Cc=r=>Number.parseFloat(r.replace(",",".")),vn=(r,e)=>Math.round(r*10**e)/10**e;function mi(r){let{min:e,max:t,accepts:n=()=>!0}=r,o=i=>{let s=Cc(i.target.value);!Number.isFinite(s)||!n(s)||r.apply(t===void 0?s:Math.min(t,Math.max(e,s)))};return m`<label class="nf-size" title=${r.title}
`]};customElements.get("nf-view3d")||customElements.define("nf-view3d",hi);function se(r,e){return Math.abs(e)>=1e3?`${O(r,e/1e3,1)} kW`:`${Math.round(e)} W`}function di(r){return r.type==="tv_board"?r.h+.9:r.type==="tv_wall"||r.type==="kitchen_wall"?r.h+.25:r.h+.35}function km(r,e){let t=e.attributes.percentage;return e.state==="on"&&typeof t=="number"?`${Math.round(t)} %`:ee(r,e)}var zc;function Tc(){let r=new URL("./nextfloor-editor.js?v=a29c3d0b177c",new URL(import.meta.url)).href;return zc??=import(r),zc}var Sm=.25,Fc=r=>Math.round(r*1e3)/1e3,Dc=(r,e,t)=>r.rooms.find(n=>n.points.length>=3&&H([e,t],n.points));function mi(r,e,t,n,o){let i=Dc(r,e,t);if(!i)return[n,o];let s=(a,l)=>H([a,l],i.points);return s(n,o)?[n,o]:s(n,t)?[n,t]:s(e,o)?[e,o]:[e,t]}function Mm(r,e,t,n){return r.rooms.some(o=>o.id!==e.id&&o.points.some((i,s)=>{let a=o.points[(s+1)%o.points.length];return Math.abs(oe(Z(i,t),n))<.02&&Math.abs(oe(Z(a,t),n))<.02}))}var pi=(r,e)=>Math.abs((r-e+540)%360-180);function Pc(r,e,t,n=Sm){let o=Dc(r,e.x,e.z);if(!o)return null;let i=o.points,s=tt(i)>=0?1:-1,a=null;return i.forEach((l,c)=>{let u=i[(c+1)%i.length],d=Te(Z(u,l));if(d<.3)return;let p=[(u[0]-l[0])/d,(u[1]-l[1])/d],h=[-p[1]*s,p[0]*s],g=oe(Z([e.x,e.z],l),p);if(g<0||g>d)return;let b=Mm(r,o,l,h)?t/2:0,_=oe(Z([e.x,e.z],l),h)-b,w=Math.atan2(-h[0],h[1])*180/Math.PI,$=[{rotation:w,extent:e.d/2},{rotation:w+90,extent:e.w/2},{rotation:w-90,extent:e.w/2}].reduce((y,F)=>pi(e.rotation,F.rotation)<pi(e.rotation,y.rotation)?F:y);if(pi(e.rotation,$.rotation)>50)return;let x=_-$.extent;Math.abs(x)>n||a&&Math.abs(x)>=Math.abs(a.gap)||(a={x:Fc(e.x-h[0]*x),z:Fc(e.z-h[1]*x),rotation:(Math.round($.rotation)%360+360)%360,gap:x})}),a&&{x:a.x,z:a.z,rotation:a.rotation}}function Tr(r,e,t){let n=structuredClone(r);for(let o of n.floors){let i=o.furniture.find(s=>s.id===e);i&&t(i,o)}return n}function Fr(r,e,t){let n=structuredClone(r);for(let o of n.floors){let i=o.placements.find(s=>s.entity_id===e);i&&t(i,o)}return n}function Hc(r,e){let t=structuredClone(r);for(let n of t.floors)n.furniture=n.furniture.filter(o=>o.id!==e);return t}function Ic(r,e){let t=structuredClone(r);for(let n of t.floors)n.placements=n.placements.filter(o=>o.entity_id!==e);return t}function Cc(r,e,t,n){return Fr(r,e,(o,i)=>{[o.x,o.z]=mi(i,o.x,o.z,t,n)})}function Nc(r,e,t,n){let o=r.settings.wall_interior??.12;return Tr(r,e,(i,s)=>{[i.x,i.z]=mi(s,i.x,i.z,t,n);let a=Pc(s,i,o);a&&Object.assign(i,a)})}var fi=(r,e)=>((r+e)%360+360)%360,Oc=r=>Number.parseFloat(r.replace(",",".")),vn=(r,e)=>Math.round(r*10**e)/10**e;function gi(r){let{min:e,max:t,accepts:n=()=>!0}=r,o=i=>{let s=Oc(i.target.value);!Number.isFinite(s)||!n(s)||r.apply(t===void 0?s:Math.min(t,Math.max(e,s)))};return m`<label class="nf-size" title=${r.title}
>${r.label}
<input type="number" inputmode="decimal" step=${r.step} min=${e} max=${t??f} .value=${String(vn(r.value,2))} @change=${o} />
</label>`}var Oc=(r,e)=>m`<button class="nf-chip" @click=${e}>${r.t("height_auto")}</button>`,Nc=(r,e)=>m`<button class="nf-chip" @click=${()=>e(-r)}>↺ ${r}°</button><button class="nf-chip" @click=${()=>e(r)}>↻ ${r}°</button>`;function xm(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 o=(s,a)=>mi({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]=vn(l,3))}),i=fs(n)?m`${mi({label:"\u2195",title:r.t("mount_height"),value:n.mount_y??le(t,n),step:.05,min:0,accepts:s=>s>=0,apply:s=>r.editFurniture(e,a=>a.mount_y=vn(s,3))})}
${n.mount_y!=null?Oc(r,()=>r.editFurniture(e,s=>s.mount_y=null)):f}`:f;return m`${o("w","size_short_w")}${o("d","size_short_d")}${o("h","size_short_h")} ${i}`}function Sm(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 o=D(e),i=(l,c,u)=>m`<select class="nf-size-select" title=${r.t(l)} @change=${d=>r.editDevice(e,p=>Object.assign(p,{mount:d.target.value,y:null}))}>
</label>`}var Lc=(r,e)=>m`<button class="nf-chip" @click=${e}>${r.t("height_auto")}</button>`,Wc=(r,e)=>m`<button class="nf-chip" @click=${()=>e(-r)}>↺ ${r}°</button><button class="nf-chip" @click=${()=>e(r)}>↻ ${r}°</button>`;function $m(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 o=(s,a)=>gi({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]=vn(l,3))}),i=_s(n)?m`${gi({label:"\u2195",title:r.t("mount_height"),value:n.mount_y??le(t,n),step:.05,min:0,accepts:s=>s>=0,apply:s=>r.editFurniture(e,a=>a.mount_y=vn(s,3))})}
${n.mount_y!=null?Lc(r,()=>r.editFurniture(e,s=>s.mount_y=null)):f}`:f;return m`${o("w","size_short_w")}${o("d","size_short_d")}${o("h","size_short_h")} ${i}`}function Am(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 o=D(e),i=(l,c,u)=>m`<select class="nf-size-select" title=${r.t(l)} @change=${d=>r.editDevice(e,p=>Object.assign(p,{mount:d.target.value,y:null}))}>
${c.map(([d,p])=>m`<option value=${d} ?selected=${d===u}>${p}</option>`)}
</select>`,s=["ceiling","floor","table","wall"].map(l=>[l,r.t(`lamp_${l}`)]),a=o?_t(o,me(t,n.x,n.z),o==="light"?n.mount??"ceiling":null):1;return m`${o==="light"?i("lamp_mount",s,n.mount??"ceiling"):f}
${mi({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=vn(l,3))})}
${n.y!==null?Oc(r,()=>r.editDevice(e,l=>l.y=null)):f}`}function Wc(r,e,t){let n=r.t,o;if(e){let i=r.building.floors.flatMap(s=>s.furniture).find(s=>s.id===e)?.type;o=m`<span>${i?he(r.hass,i):""}</span>
${xm(r,e)} ${Nc(45,s=>r.turnFurniture(e,s))}
</select>`,s=["ceiling","floor","table","wall"].map(l=>[l,r.t(`lamp_${l}`)]),a=o?wt(o,me(t,n.x,n.z),o==="light"?n.mount??"ceiling":null):1;return m`${o==="light"?i("lamp_mount",s,n.mount??"ceiling"):f}
${gi({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=vn(l,3))})}
${n.y!==null?Lc(r,()=>r.editDevice(e,l=>l.y=null)):f}`}function Bc(r,e,t){let n=r.t,o;if(e){let i=r.building.floors.flatMap(s=>s.furniture).find(s=>s.id===e)?.type;o=m`<span>${i?he(r.hass,i):""}</span>
${$m(r,e)} ${Wc(45,s=>r.turnFurniture(e,s))}
<button class="nf-chip" title=${n("furn_mirror_hint")} @click=${()=>r.editFurniture(e,s=>s.mirror=!s.mirror)}>⇋ ${n("furn_mirror")}</button>
<button class="nf-chip nf-danger-chip" @click=${()=>r.removeFurniture(e)}>${n("delete")}</button>`}else t?o=m`<span>${L(r.hass,t)}</span>
${Sm(r,t)} ${Nc(45,i=>r.turnDevice(t,i))}
<button class="nf-chip nf-danger-chip" @click=${()=>r.removeDevice(t)}>${n("delete")}</button>`:o=m`<span>${n("furnish_hint")}</span>`;return m`<div class="nf-furnish-bar">${o}<button class="nf-chip nf-chip-on" @click=${()=>r.finish()}>${n("done")}</button></div>`}var Lc=J`<svg class="nf-mark" viewBox="60 40 392 420" aria-hidden="true">
${Am(r,t)} ${Wc(45,i=>r.turnDevice(t,i))}
<button class="nf-chip nf-danger-chip" @click=${()=>r.removeDevice(t)}>${n("delete")}</button>`:o=m`<span>${n("furnish_hint")}</span>`;return m`<div class="nf-furnish-bar">${o}<button class="nf-chip nf-chip-on" @click=${()=>r.finish()}>${n("done")}</button></div>`}var Vc=J`<svg class="nf-mark" viewBox="60 40 392 420" aria-hidden="true">
<polygon points="106,150 256,66 406,150 256,234" fill="none" stroke="currentColor" stroke-opacity=".55" stroke-width="12" stroke-dasharray="6 22" stroke-linecap="round"/>
<polygon points="106,382 256,466 256,488 106,404" fill="#34507d"/><polygon points="406,382 256,466 256,488 406,404" fill="#2a4068"/><polygon points="106,382 256,298 406,382 256,466" fill="#5f7fb6"/>
<polygon points="106,310 256,394 256,416 106,332" fill="#4a72b8"/><polygon points="406,310 256,394 256,416 406,332" fill="#3b5c98"/><polygon points="106,310 256,226 406,310 256,394" fill="#8ab6f5"/>
<polygon points="106,238 256,322 256,344 106,260" fill="#2a74d8"/><polygon points="406,238 256,322 256,344 406,260" fill="#2161b8"/><polygon points="106,238 256,154 406,238 256,322" fill="#4fb6ff"/>
<circle cx="256" cy="236" r="16" fill="#ffe08a"/>
</svg>`;var ae=(r,e)=>({name:r,fallback:e,read:t=>e?t!=="0":t==="1",write:t=>t?"1":"0"}),Ft=(r,e,t)=>({name:r,fallback:t,read:n=>e.find(o=>o===n)??t,write:n=>n}),fi={explode:ae("explode",!0),keepRoof:ae("roof",!1),solidWalls:ae("solid_walls",!1),quality:Ft("quality",["auto","low","high"],"auto"),stats:ae("stats",!1),markers:Ft("markers",["none","important","all"],"important"),heat:Ft("heat",["none","temperature","humidity","co2","mould","comfort","power","sun","values","wifi"],"none"),theme:Ft("theme",_r,"neon"),clock:Ft("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:Ft("floor_stack",["dim","stacked","single"],"dim"),roomNames:ae("room_names",!0),clean:ae("clean",!1),navWrap:ae("nav_wrap",!1),weather:ae("weather",!0),timeSlider:ae("time_slider",!1),menuOpen:ae("menu_open",!1),keepCamera:ae("keep_camera",!1),readable:ae("readable",!1),plain:ae("plain",!1),rightBack:ae("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:ae("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 Bc(r=Fr()){try{return r?.getItem("nextfloor.screen_name")?.trim()||null}catch{return null}}function Vc(r=Fr()){try{return r?.getItem("nextfloor.announce_muted")==="1"}catch{return!1}}function Fr(){try{return localStorage}catch{return null}}var Tr=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(fi)){let o=fi[n],i=this.raw(o.name);t[n]=i===null?o.fallback:o.read(i)}return new URLSearchParams(e).has("nf_stats")&&(t.stats=!0),t}save(e,t){let n=fi[e];try{this.storage?.setItem(`nextfloor.${n.name}`,n.write(t))}catch{}}};var Kc=te`
</svg>`;var ae=(r,e)=>({name:r,fallback:e,read:t=>e?t!=="0":t==="1",write:t=>t?"1":"0"}),Dt=(r,e,t)=>({name:r,fallback:t,read:n=>e.find(o=>o===n)??t,write:n=>n}),_i={explode:ae("explode",!0),keepRoof:ae("roof",!1),solidWalls:ae("solid_walls",!1),quality:Dt("quality",["auto","low","high"],"auto"),stats:ae("stats",!1),markers:Dt("markers",["none","important","all"],"important"),heat:Dt("heat",["none","temperature","humidity","co2","mould","comfort","power","sun","values","wifi"],"none"),theme:Dt("theme",wr,"neon"),clock:Dt("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:Dt("floor_stack",["dim","stacked","single"],"dim"),roomNames:ae("room_names",!0),clean:ae("clean",!1),navWrap:ae("nav_wrap",!1),weather:ae("weather",!0),timeSlider:ae("time_slider",!1),menuOpen:ae("menu_open",!1),keepCamera:ae("keep_camera",!1),readable:ae("readable",!1),plain:ae("plain",!1),rightBack:ae("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:ae("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 Kc(r=Pr()){try{return r?.getItem("nextfloor.screen_name")?.trim()||null}catch{return null}}function Gc(r=Pr()){try{return r?.getItem("nextfloor.announce_muted")==="1"}catch{return!1}}function Pr(){try{return localStorage}catch{return null}}var Dr=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(_i)){let o=_i[n],i=this.raw(o.name);t[n]=i===null?o.fallback:o.read(i)}return new URLSearchParams(e).has("nf_stats")&&(t.stats=!0),t}save(e,t){let n=_i[e];try{this.storage?.setItem(`nextfloor.${n.name}`,n.write(t))}catch{}}};var Uc=te`
.nf-dot {
display: inline-block;
width: 8px;
@@ -3782,11 +3783,11 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
gap: 12px;
margin: auto;
}
`;var gi=class extends re{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 gt(this);store=new Tr(Fr());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:Xe(dt(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=i=>`${String(Math.floor(i)).padStart(2,"0")}:${String(Math.round(i%1*60)).padStart(2,"0")}`,o=()=>{let i=new Date;return Math.round((i.getHours()+i.getMinutes()/60)*4)/4};return m`<button class="nf-chip" aria-pressed=${t!==null} title=${e("time_of_day_hint")} @click=${()=>(this._timeDrag=null,this._timeOfDay=t===null?o():null)}>☀ ${t===null?e("time_of_day"):n(t)}</button>
`;var bi=class extends re{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 bt(this);store=new Dr(Pr());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:et(pt(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=i=>`${String(Math.floor(i)).padStart(2,"0")}:${String(Math.round(i%1*60)).padStart(2,"0")}`,o=()=>{let i=new Date;return Math.round((i.getHours()+i.getMinutes()/60)*4)/4};return m`<button class="nf-chip" aria-pressed=${t!==null} title=${e("time_of_day_hint")} @click=${()=>(this._timeDrag=null,this._timeOfDay=t===null?o():null)}>☀ ${t===null?e("time_of_day"):n(t)}</button>
${t!==null?m`<label class="nf-chip nf-time-slider"
><input type="range" min="0" max="23.75" step="0.25" .value=${String(t)} aria-label=${e("time_of_day")} @input=${i=>this._timeDrag=Number(i.target.value)}
@change=${i=>(this._timeDrag=null,this._timeOfDay=Number(i.target.value))}
/></label>`:f}`}t=(e,t)=>R(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=hr(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=Zt(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=>Rr(n,e,t)),editDevice:(e,t)=>this.applyEdit(n=>zr(n,e,t)),turnFurniture:(e,t)=>this.applyEdit(n=>Rr(n,e,o=>o.rotation=pi(o.rotation,t))),turnDevice:(e,t)=>this.applyEdit(n=>zr(n,e,o=>o.rotation=pi(o.rotation??0,t))),removeFurniture:e=>{this.applyEdit(t=>Dc(t,e)),this._selFurniture=null},removeDevice:e=>{this.applyEdit(t=>Pc(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(o=>({...o,rooms:o.rooms.map(i=>i.id===e?{...i,moods:t.length?t:void 0}:i)}))}))}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&&er(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)),m`<div class="nf-app ${t?"nf-clean":""}" style=${this._prefs.accent?`--nf-accent:${this._prefs.accent}`:""}>
/></label>`:f}`}t=(e,t)=>R(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=mr(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=Zt(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=>Tr(n,e,t)),editDevice:(e,t)=>this.applyEdit(n=>Fr(n,e,t)),turnFurniture:(e,t)=>this.applyEdit(n=>Tr(n,e,o=>o.rotation=fi(o.rotation,t))),turnDevice:(e,t)=>this.applyEdit(n=>Fr(n,e,o=>o.rotation=fi(o.rotation??0,t))),removeFurniture:e=>{this.applyEdit(t=>Hc(t,e)),this._selFurniture=null},removeDevice:e=>{this.applyEdit(t=>Ic(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(o=>({...o,rooms:o.rooms.map(i=>i.id===e?{...i,moods:t.length?t:void 0}:i)}))}))}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&&nr(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)),m`<div class="nf-app ${t?"nf-clean":""}" style=${this._prefs.accent?`--nf-accent:${this._prefs.accent}`:""}>
${t?f:m`${this.renderHeader(e)}${this.renderNotices()}`}
${this.data.error&&!e?m`<p class="nf-message">${this.t("load_error")}: ${this.data.error}</p>`:f}
${!e&&!this.data.error?m`<p class="nf-message">${this.t("loading")}</p>`:f}
@@ -3799,7 +3800,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
</label>`}renderViewOptions(){let e=this._prefs;return m`<button class="nf-opts-btn" aria-expanded=${this._optsOpen} title=${this.t("view_options")} aria-label=${this.t("view_options")} @click=${()=>this._optsOpen=!this._optsOpen}>⚙</button>
<div class="nf-view-opts ${this._optsOpen?"nf-opts-open":""}">
${this.choiceRow("quality",["auto","low","high"],e.quality,t=>this.t(`quality_${t}`),t=>this.setPref("quality",t))}
${this.choiceRow("theme",_r,e.theme,t=>this.t(`theme_${t}`),t=>this.setPref("theme",t),this.accentPicker())}
${this.choiceRow("theme",wr,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))}
<label class="nf-seg nf-clock-pick" title=${this.t("clock")}
>🕒
@@ -3838,7 +3839,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
</div>
</div>`}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.data.saveState,n=(i,s,a="")=>m`<button role="tab" class=${a} aria-pressed=${this._mode===i} @click=${()=>this.setMode(i)}>${s}</button>`,o=t==="saving"?"saving":t==="saved"?"saved":"save_error";return m`<header class="nf-header">
<ha-menu-button .hass=${this.hass} .narrow=${this.narrow}></ha-menu-button>
<h1>${Lc}NextFloor</h1>
<h1>${Vc}NextFloor</h1>
${this.isAdmin?m`<div class="nf-seg" role="tablist">${n("view",this.t("view"))}${n("editor",this.t("editor"))}${n("extensions",`\u2726 ${this.t("ext_tab")}`,"nf-tab-ext")}</div>`:f}
<span class="nf-grow"></span>
${this.isAdmin&&this.hass.symconRefresh?m`<button class="nf-btn nf-reload-variables" ?disabled=${this._variablesLoading} aria-busy=${this._variablesLoading} @click=${()=>{this.reloadVariables()}}>↻ ${this.t(this._variablesLoading?"symcon_variables_loading":"symcon_variables_reload")}</button>`:f}
@@ -3852,7 +3853,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
<span>${this.t("draft_found",{time:n})}</span>
<button class="nf-btn nf-primary" @click=${()=>e.restoreDraft()}>${this.t("draft_restore")}</button>
<button class="nf-btn" @click=${()=>e.discardDraft()}>${this.t("draft_discard")}</button>
</div>`)}return t.length>0?m`<div class="nf-notices">${t}</div>`:f}whenEditorLoaded(e){return this._editorReady?e():(Rc().then(()=>this._editorReady=!0,t=>this.data.error=String(t)),m`<div class="nf-empty"><p>${this.t("loading")}</p></div>`)}renderExtensions(){return this.whenEditorLoaded(()=>m`<nf-extensions class="nf-body" .hass=${this.hass} .packs=${this.data.packs} .plugins=${this.data.building?.settings.plugins??[]}
</div>`)}return t.length>0?m`<div class="nf-notices">${t}</div>`:f}whenEditorLoaded(e){return this._editorReady?e():(Tc().then(()=>this._editorReady=!0,t=>this.data.error=String(t)),m`<div class="nf-empty"><p>${this.t("loading")}</p></div>`)}renderExtensions(){return this.whenEditorLoaded(()=>m`<nf-extensions class="nf-body" .hass=${this.hass} .packs=${this.data.packs} .plugins=${this.data.building?.settings.plugins??[]}
@packs-changed=${()=>{this.data.reloadPacks()}}
@plugins-changed=${e=>this.applyEdit(t=>({...t,settings:{...t.settings,plugins:e.detail}}))}></nf-extensions>`)}renderEditor(e){return this.whenEditorLoaded(()=>m`<nf-editor
class="nf-body"
@@ -3863,7 +3864,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
.loadCardEditor=${$n}
@packs-changed=${()=>{this.data.reloadPacks()}}
@building-changed=${t=>this.data.edit(t.detail.building)}
></nf-editor>`)}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(o=>o.id===this._floorId):e.floors.length===1?e.floors[0]:void 0;if(!t||!this.hass)return f;if(this._floorUndo){let o=this._floorUndo;return m`<button class="nf-chip" aria-pressed="true" @click=${()=>{for(let i of o)this.hass.callService(i.domain,i.service,i.data);this._floorUndo=null,clearTimeout(this.floorUndoTimer)}}>↶ ${this.t("all_off_undo")}</button>`}let n=rn(tl(t).map(o=>this.hass.states[o]));return n.count<2?f:m`<button class="nf-chip" title=${this.t("all_off_floor",{floor:t.name,n:n.count})} @click=${()=>{for(let o of n.off)this.hass.callService(o.domain,o.service,o.data);this._floorUndo=n.undo,clearTimeout(this.floorUndoTimer),this.floorUndoTimer=setTimeout(()=>this._floorUndo=null,1e4)}}>⏻ ${n.count}</button>`}renderNav(e){let t=e.floors.filter(c=>!this._floorId||c.id===this._floorId),n=e.floors.length>1,o=this._prefs.navWrap,i=this.outsideIds(e).length?m`<button class="nf-chip" aria-pressed=${this._outside} title=${this.t("outside_area_hint")} @click=${()=>this.openOutside()}>🌳 ${this.t("outside_area")}</button>`:f,s=n?m`<button class="nf-chip" aria-pressed=${this._floorId===null} @click=${()=>this.openFloor(null)}>${this.t("all_floors")}</button>
></nf-editor>`)}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(o=>o.id===this._floorId):e.floors.length===1?e.floors[0]:void 0;if(!t||!this.hass)return f;if(this._floorUndo){let o=this._floorUndo;return m`<button class="nf-chip" aria-pressed="true" @click=${()=>{for(let i of o)this.hass.callService(i.domain,i.service,i.data);this._floorUndo=null,clearTimeout(this.floorUndoTimer)}}>↶ ${this.t("all_off_undo")}</button>`}let n=rn(rl(t).map(o=>this.hass.states[o]));return n.count<2?f:m`<button class="nf-chip" title=${this.t("all_off_floor",{floor:t.name,n:n.count})} @click=${()=>{for(let o of n.off)this.hass.callService(o.domain,o.service,o.data);this._floorUndo=n.undo,clearTimeout(this.floorUndoTimer),this.floorUndoTimer=setTimeout(()=>this._floorUndo=null,1e4)}}>⏻ ${n.count}</button>`}renderNav(e){let t=e.floors.filter(c=>!this._floorId||c.id===this._floorId),n=e.floors.length>1,o=this._prefs.navWrap,i=this.outsideIds(e).length?m`<button class="nf-chip" aria-pressed=${this._outside} title=${this.t("outside_area_hint")} @click=${()=>this.openOutside()}>🌳 ${this.t("outside_area")}</button>`:f,s=n?m`<button class="nf-chip" aria-pressed=${this._floorId===null} @click=${()=>this.openFloor(null)}>${this.t("all_floors")}</button>
${[...e.floors].reverse().map(c=>m`<button class="nf-chip" aria-pressed=${c.id===this._floorId} @click=${()=>this.openFloor(c.id)}>${c.name}</button>`)}
${i} ${this.allOffChip(e)}
<span class="nf-sep"></span>`:m`${i} ${this.allOffChip(e)}`,a=t.flatMap(c=>[t.length>1&&c.rooms.length?m`<span class="nf-nav-floor">${c.name}</span>`:f,...c.rooms.map(u=>m`<button
@@ -3875,7 +3876,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
</button>`)]),l=this.t(o?"nav_row":"nav_wrap");return m`<nav class="nf-nav ${o?"nf-nav-wrap":""}" @wheel=${this.onNavWheel}>
${s}${a}
<button class="nf-chip nf-nav-toggle" title=${l} aria-label=${l} aria-pressed=${o} @click=${()=>this.setPref("navWrap",!o)}>${o?"\u2194":"\u2261"}</button>
</nav>`}toggleChip(e,t,n){return m`<button class="nf-chip" aria-pressed=${this._prefs[e]} title=${n?this.t(n):f} @click=${()=>this.setPref(e,!this._prefs[e])}>${this.t(t)}</button>`}renderOverlay(e){let t=this._prefs,n=this.t,o=(u,d)=>m`<div class="nf-seg">${[u,d].map(([p,h,w])=>m`<button aria-pressed=${p} @click=${h}>${w}</button>`)}</div>`,i=["none","temperature","humidity","co2","mould","comfort","power","sun","values","wifi"],s=["dim","stacked","single"],a=e.floors.length>1,l=this._roomId||this._floorId&&a?m`<button class="nf-chip" @click=${()=>this.back()}>${n("back")}</button>`:f,c=m`<button class="nf-chip" aria-haspopup="true" aria-expanded=${this._switchesOpen} @click=${()=>this._switchesOpen=!this._switchesOpen}>☰ ${n("bars_unfold")} <span class="nf-caret">${this._switchesOpen?"\u25BE":"\u25B4"}</span></button>`;return this._switchesOpen?m`<div class="nf-overlay">
</nav>`}toggleChip(e,t,n){return m`<button class="nf-chip" aria-pressed=${this._prefs[e]} title=${n?this.t(n):f} @click=${()=>this.setPref(e,!this._prefs[e])}>${this.t(t)}</button>`}renderOverlay(e){let t=this._prefs,n=this.t,o=(u,d)=>m`<div class="nf-seg">${[u,d].map(([p,h,g])=>m`<button aria-pressed=${p} @click=${h}>${g}</button>`)}</div>`,i=["none","temperature","humidity","co2","mould","comfort","power","sun","values","wifi"],s=["dim","stacked","single"],a=e.floors.length>1,l=this._roomId||this._floorId&&a?m`<button class="nf-chip" @click=${()=>this.back()}>${n("back")}</button>`:f,c=m`<button class="nf-chip" aria-haspopup="true" aria-expanded=${this._switchesOpen} @click=${()=>this._switchesOpen=!this._switchesOpen}>☰ ${n("bars_unfold")} <span class="nf-caret">${this._switchesOpen?"\u25BE":"\u25B4"}</span></button>`;return this._switchesOpen?m`<div class="nf-overlay">
<div class="nf-switches-veil" @click=${()=>this._switchesOpen=!1}></div>
<div class="nf-switches" role="group" aria-label=${n("bars_unfold")} @keydown=${u=>u.key==="Escape"&&(this._switchesOpen=!1)}>
<div class="nf-seg">
@@ -3923,7 +3924,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
.keepRoof=${t.keepRoof}
.markerMode=${t.markers}
.heatMode=${t.heat}
.theme=${br(t.theme,this.sunState())}
.theme=${vr(t.theme,this.sunState())}
.timeOfDay=${this._timeOfDay}
.clock=${t.clock==="none"?null:t.clock}
.announcements=${!t.announceMuted}
@@ -3942,9 +3943,9 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
?furnish=${this._furnish}
.selectedFurniture=${this._selFurniture}
@furniture-select=${o=>this._selFurniture=o.detail.id}
@furniture-move=${o=>this.applyEdit(i=>Ic(i,o.detail.id,o.detail.x,o.detail.z))}
@furniture-move=${o=>this.applyEdit(i=>Nc(i,o.detail.id,o.detail.x,o.detail.z))}
@device-select=${o=>this._selDevice=o.detail.id}
@device-move=${o=>this.applyEdit(i=>Hc(i,o.detail.id,o.detail.x,o.detail.z))}
@device-move=${o=>this.applyEdit(i=>Cc(i,o.detail.id,o.detail.x,o.detail.z))}
.quality=${t.quality}
?showStats=${t.stats}
@room-tap=${this.onRoomTap}
@@ -3957,7 +3958,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
.hass=${this.hass}
.room=${n}
.floor=${e.floors.find(o=>o.rooms.some(i=>i.id===this._roomId))??null}
.confirmEntities=${rt(this.hass,e.floors)}
.confirmEntities=${it(this.hass,e.floors)}
.phrases=${e.settings.announce_phrases??null}
.rooms=${e.floors.flatMap(o=>o.rooms)}
@mood-change=${o=>this.saveMoods(o.detail.roomId,o.detail.moods)}
@@ -3968,14 +3969,14 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
.hass=${this.hass}
.room=${null}
.outside=${this.outsideIds(e)}
.confirmEntities=${rt(this.hass,e.floors)}
.confirmEntities=${it(this.hass,e.floors)}
.phrases=${e.settings.announce_phrases??null}
@close=${()=>this._outside=!1}
></nf-room-panel>`:f}
${t.clean?f:this.renderOverlay(e)}
${this._furnish?Wc(this.furnishHost,this._selFurniture,this._selDevice):f}
${this._furnish?Bc(this.furnishHost,this._selFurniture,this._selDevice):f}
</div>
`}static styles=[Se,Ve,Kc,dr]};customElements.get("nextfloor-panel")||customElements.define("nextfloor-panel",gi);var Mm=/^(\d{1,2}):(\d{2})\s*-\s*(\d{1,2}):(\d{2})$/,Gc=(r,e)=>Number(r)*60+Number(e);function yn(r,e,t=new Date){if(!r||r==="off")return!1;if(r==="sun")return e?.states["sun.sun"]?.state==="below_horizon";let n=Mm.exec(r.trim());if(!n)return!1;let o=Gc(n[1],n[2]),i=Gc(n[3],n[4]),s=t.getHours()*60+t.getMinutes();return o>i?s>=o||s<i:s>=o&&s<i}var Dr=class{host;cleanTimer;idleTimer;nightTimer;constructor(e){this.host=e}armClean(e=!1){clearTimeout(this.cleanTimer);let t=this.host.config()?.controls_hide_after??0;t>0&&(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(yn(this.host.config()?.night,this.host.hass())),6e4)}stop(){clearTimeout(this.cleanTimer),clearTimeout(this.idleTimer),clearInterval(this.nightTimer)}};function Uc(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 jc=te`
`}static styles=[Se,Ke,Uc,pr]};customElements.get("nextfloor-panel")||customElements.define("nextfloor-panel",bi);var Em=/^(\d{1,2}):(\d{2})\s*-\s*(\d{1,2}):(\d{2})$/,jc=(r,e)=>Number(r)*60+Number(e);function yn(r,e,t=new Date){if(!r||r==="off")return!1;if(r==="sun")return e?.states["sun.sun"]?.state==="below_horizon";let n=Em.exec(r.trim());if(!n)return!1;let o=jc(n[1],n[2]),i=jc(n[3],n[4]),s=t.getHours()*60+t.getMinutes();return o>i?s>=o||s<i:s>=o&&s<i}var Hr=class{host;cleanTimer;idleTimer;nightTimer;constructor(e){this.host=e}armClean(e=!1){clearTimeout(this.cleanTimer);let t=this.host.config()?.controls_hide_after??0;t>0&&(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(yn(this.host.config()?.night,this.host.hass())),6e4)}stop(){clearTimeout(this.cleanTimer),clearTimeout(this.idleTimer),clearInterval(this.nightTimer)}};function qc(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 Zc=te`
ha-card {
overflow: hidden;
background: var(--nf-bg);
@@ -4099,14 +4100,14 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
justify-content: flex-end;
}
}
`;function _i(r,e){let t=r.template,n=t?e?.[t]:void 0;if(!n)return r;let{type:o,template:i,...s}=n;return{...s,...r}}function qc(r,e){let t=new Set(e),n=[];for(let i of r.floors){let s=i.rooms.filter(c=>t.has(c.id));if(!s.length)continue;let a=(c,u)=>s.some(d=>d.points.length>=3&&H([c,u],d.points)),l=new Set(s.map(c=>c.id));n.push({...i,rooms:s,openings:i.openings.filter(c=>l.has(c.room_id)),furniture:i.furniture.filter(c=>a(c.x,c.z)),placements:i.placements.filter(c=>a(c.x,c.z)),walls:(i.walls??[]).filter(c=>a((c.a[0]+c.b[0])/2,(c.a[1]+c.b[1])/2)),outdoor:[]})}let o={...r.settings.roof,type:"none",sections:[],solar:[]};return{...r,floors:n,settings:{...r.settings,roof:o}}}var Dt="nf-outside",bi=class extends re{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}};_own=null;templatesSeen;roomApplied=!1;data=new gt(this);kiosk=new Dr({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}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 $n(),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._own=e,this._config=_i(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=yn(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=_i(this._own,t)),this.toggleAttribute("readable",this._config?.readable===!0),e.has("hass")&&(this.style.colorScheme=hr(this.hass)),!e.has("hass")||!this.hass)return;this.data.setHass(this.hass);let n=yn(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:qc(e,t)}),this.roomsMemo.result}t=e=>R(this.hass,e);stage(){let e=this.plan(),t=this._config,n=this._floorId===void 0?t?.floor??null:this._floorId,o=e&&e.floors.length===1?e.floors[0].id:e?.floors.some(a=>a.id===n)?n:null,i=!!this._roomId&&t?.room_panel!==!1,s=!!this._roomId&&t?.room_panel===!1||!this.thumbs&&this.canSwitch&&!this._roomId&&!!o&&(e?.floors.length??0)>1;return{floorId:o,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&&!i)}}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,o=["temperature","humidity","co2"].filter(s=>this.shows(s)),i=(s,a)=>m`<div class="nf-seg" role=${s?"group":f} aria-label=${s??f}>${a.map(([l,c,u])=>m`<button aria-pressed=${l} @click=${c}>${u}</button>`)}</div>`;return m`<div class="nf-card-controls">
`;function wi(r,e){let t=r.template,n=t?e?.[t]:void 0;if(!n)return r;let{type:o,template:i,...s}=n;return{...s,...r}}function Yc(r,e){let t=new Set(e),n=[];for(let i of r.floors){let s=i.rooms.filter(c=>t.has(c.id));if(!s.length)continue;let a=(c,u)=>s.some(d=>d.points.length>=3&&H([c,u],d.points)),l=new Set(s.map(c=>c.id));n.push({...i,rooms:s,openings:i.openings.filter(c=>l.has(c.room_id)),furniture:i.furniture.filter(c=>a(c.x,c.z)),placements:i.placements.filter(c=>a(c.x,c.z)),walls:(i.walls??[]).filter(c=>a((c.a[0]+c.b[0])/2,(c.a[1]+c.b[1])/2)),outdoor:[]})}let o={...r.settings.roof,type:"none",sections:[],solar:[]};return{...r,floors:n,settings:{...r.settings,roof:o}}}var Pt="nf-outside",vi=class extends re{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}};_own=null;templatesSeen;roomApplied=!1;data=new bt(this);kiosk=new Hr({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}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 $n(),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._own=e,this._config=wi(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=yn(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=wi(this._own,t)),this.toggleAttribute("readable",this._config?.readable===!0),e.has("hass")&&(this.style.colorScheme=mr(this.hass)),!e.has("hass")||!this.hass)return;this.data.setHass(this.hass);let n=yn(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:Yc(e,t)}),this.roomsMemo.result}t=e=>R(this.hass,e);stage(){let e=this.plan(),t=this._config,n=this._floorId===void 0?t?.floor??null:this._floorId,o=e&&e.floors.length===1?e.floors[0].id:e?.floors.some(a=>a.id===n)?n:null,i=!!this._roomId&&t?.room_panel!==!1,s=!!this._roomId&&t?.room_panel===!1||!this.thumbs&&this.canSwitch&&!this._roomId&&!!o&&(e?.floors.length??0)>1;return{floorId:o,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&&!i)}}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,o=["temperature","humidity","co2"].filter(s=>this.shows(s)),i=(s,a)=>m`<div class="nf-seg" role=${s?"group":f} aria-label=${s??f}>${a.map(([l,c,u])=>m`<button aria-pressed=${l} @click=${c}>${u}</button>`)}</div>`;return m`<div class="nf-card-controls">
${e.canGoBack?m`<button class="nf-chip" @click=${()=>this.back()}>${n("back")}</button>`:f}
${this.shows("walls")?i(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?i(void 0,[[e.explode,()=>this._explode=!0,n("floors_apart")],[!e.explode,()=>this._explode=!1,n("floors_stacked")]]):f}
${o.length>0?i(n("heatmap"),["none",...o].map(s=>[e.heat===s,()=>this._heat=s,n(s==="none"?"heat_off":`heat_short_${s}`)])):f}
</div>`}renderRoomButtons(e){let t=this.plan();if(!this._config?.room_buttons||!t||this._clean)return f;let n=Uc(t,e.floorId);if(!n.length)return f;let o=n.length>1,i=(l,c)=>{this.canSwitch&&l!==e.floorId&&(this._floorId=l),this._roomId=c===this._roomId?null:c},s=Zt(this.hass,t.floors).length>0,a=()=>{this.canSwitch&&(this._floorId=null),this._roomId=this._roomId===Dt?null:Dt};return m`<div class="nf-card-rooms ${this._roomId&&this._config?.room_panel!==!1?"nf-card-rooms-beside":""}" role="group" aria-label=${this.t("card_room_buttons")}>
</div>`}renderRoomButtons(e){let t=this.plan();if(!this._config?.room_buttons||!t||this._clean)return f;let n=qc(t,e.floorId);if(!n.length)return f;let o=n.length>1,i=(l,c)=>{this.canSwitch&&l!==e.floorId&&(this._floorId=l),this._roomId=c===this._roomId?null:c},s=Zt(this.hass,t.floors).length>0,a=()=>{this.canSwitch&&(this._floorId=null),this._roomId=this._roomId===Pt?null:Pt};return m`<div class="nf-card-rooms ${this._roomId&&this._config?.room_panel!==!1?"nf-card-rooms-beside":""}" role="group" aria-label=${this.t("card_room_buttons")}>
${n.map(l=>m`${o?m`<span class="nf-card-rooms-floor">${l.floorName}</span>`:f}${l.rooms.map(c=>m`<button class="nf-chip" aria-pressed=${c.id===this._roomId} @click=${()=>i(l.floorId,c.id)}>${c.name}</button>`)}`)}
${s?m`<button class="nf-chip" aria-pressed=${this._roomId===Dt} title=${this.t("outside_area_hint")} @click=${a}>🌳 ${this.t("outside_area")}</button>`:f}
${s?m`<button class="nf-chip" aria-pressed=${this._roomId===Pt} title=${this.t("outside_area_hint")} @click=${a}>🌳 ${this.t("outside_area")}</button>`:f}
</div>`}renderCorners(){let e=this._config,t=this.t,n=this._clean||!!this._roomId&&e?.room_panel!==!1;return m`${e?.fullscreen_button&&!n?m`<button class="nf-card-full" title=${t(this._fullscreen?"fullscreen_exit":"fullscreen")} aria-label=${t(this._fullscreen?"fullscreen_exit":"fullscreen")} @click=${()=>this.toggleFullscreen()}>
${this._fullscreen?"\u2715":"\u26F6"}
</button>`:f}
@@ -4117,8 +4118,8 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
.building=${t}
.packs=${this.data.packs}
.floorId=${e.floorId}
.roomId=${this._roomId===Dt?null:this._roomId}
.outsideOpen=${this._roomId===Dt}
.roomId=${this._roomId===Pt?null:this._roomId}
.outsideOpen=${this._roomId===Pt}
.wallMode=${e.walls}
.solidWalls=${n?.solid_walls===!0}
.explode=${e.explode}
@@ -4141,7 +4142,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
.zoom=${typeof n?.zoom=="number"?n.zoom:1}
.buttons=${n?.buttons?.map((s,a)=>({id:`card_${a}`,...s}))??null}
.heatMode=${e.heat}
.theme=${br(n?.theme,this.hass?.states["sun.sun"]?.state)}
.theme=${vr(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}
@@ -4157,10 +4158,10 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
.panelOpen=${!!this._roomId&&n?.room_panel!==!1}
.alerts=${n?.alerts!==!1}
.alertJump=${!!n?.alert_jump}
.announcements=${n?.announcements!==!1&&!Vc()}
.announcements=${n?.announcements!==!1&&!Gc()}
.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??Bc()}
.screenName=${n?.screen_name??Kc()}
.scenes=${n?.scenes!==!1}
.clean=${this._clean}
.cleanButton=${i}
@@ -4181,11 +4182,11 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
.hass=${this.hass}
.room=${e.floors.flatMap(t=>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===Dt?Zt(this.hass,e.floors):null}
.confirmEntities=${rt(this.hass,e.floors)}
.outside=${this._roomId===Pt?Zt(this.hass,e.floors):null}
.confirmEntities=${it(this.hass,e.floors)}
.phrases=${e.settings.announce_phrases??null}
@close=${()=>this._roomId=null}
></nf-room-panel>`}render(){if(this.hass&&er(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(),o=this._fullscreen?"100vh":t?.fill?"calc(100vh - var(--header-height, 56px) - 16px)":`${t?.height??420}px`,i=/^#[0-9a-f]{6}$/i.test(t?.accent??"")?t.accent:null,s=()=>this.kiosk.touched();return m`<ha-card class=${this._night?"nf-night":""} style=${i?`--nf-accent:${i}`:""} @pointerdown=${s} @keydown=${s} @wheel=${s}>
></nf-room-panel>`}render(){if(this.hass&&nr(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(),o=this._fullscreen?"100vh":t?.fill?"calc(100vh - var(--header-height, 56px) - 16px)":`${t?.height??420}px`,i=/^#[0-9a-f]{6}$/i.test(t?.accent??"")?t.accent:null,s=()=>this.kiosk.touched();return m`<ha-card class=${this._night?"nf-night":""} style=${i?`--nf-accent:${i}`:""} @pointerdown=${s} @keydown=${s} @wheel=${s}>
<div class="nf-card-body" style="height:${o}">
${e&&e.floors.some(a=>a.rooms.length)?this.renderStage(n):m`<p class="nf-card-msg">${this.data.error??(e?R(this.hass,"no_building"):R(this.hass,"loading"))}</p>`}
${this._roomId&&e&&t?.room_panel!==!1?this.renderRoomPanel():f}
@@ -4193,7 +4194,7 @@ A plugin runs with the same rights as NextFloor in your browser. The file has be
${n.showBar&&e?this.renderBar(n):f}
${this.renderCorners()}
</div>
</ha-card>`}static styles=[Se,Ve,jc,dr]};if(!customElements.get("nextfloor-card")){customElements.define("nextfloor-card",bi);let r=window;r.customCards=r.customCards??[],r.customCards.push({type:"nextfloor-card",name:R(void 0,"card_name"),description:R(void 0,"card_description"),preview:!1})}Xr();var $m="nextfloor-chunks-v1";async function wi(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:$m})}),o=await n.text(),i;try{i=JSON.parse(o)}catch{throw/Output-Buffer exceeds Limit/i.test(o)?new Error("Symcon hat die Antwort wegen seiner Ausgabebegrenzung abgebrochen. Bitte das NextFloor-Modul aktualisieren und den Designer neu laden."):new Error(`Symcon liefert ${o.trim()?"kein g\xFCltiges JSON":"eine leere Antwort"} f\xFCr \u201E${e}\u201C (HTTP ${n.status}).`)}if(!n.ok||!i||typeof i!="object"||"error"in i){let s=i&&typeof i=="object"&&"error"in i?i.error:`HTTP ${n.status}`;throw new Error(String(s))}return i}async function Pt(r,e,t={}){let n=await wi(r,e,t);if(!("_nextfloor_transfer"in n))return n;let o=n._nextfloor_transfer;if(!o||!/^[a-f0-9]{32}$/.test(o.id)||!Number.isSafeInteger(o.bytes)||o.bytes<=0||o.bytes>67108864||!Number.isSafeInteger(o.chunk_bytes)||o.chunk_bytes<=0||o.chunk_bytes>128*1024||o.chunks!==Math.ceil(o.bytes/o.chunk_bytes)||o.chunks>512)throw new Error("Symcon hat eine ung\xFCltige Daten\xFCbertragung angek\xFCndigt.");try{let i=new TextDecoder("utf-8",{fatal:!0}),s=[];for(let a=0;a<o.chunks;a++){let l=await wi(r,"transport/read",{transfer_id:o.id,index:a});if(l.index!==a||typeof l.data!="string")throw new Error("Ein Symcon-Datenpaket fehlt oder ist ung\xFCltig.");let c=Uint8Array.from(atob(l.data),u=>u.charCodeAt(0));if(c.length!==Math.min(o.chunk_bytes,o.bytes-a*o.chunk_bytes))throw new Error("Ein Symcon-Datenpaket wurde unvollst\xE4ndig \xFCbertragen.");s.push(i.decode(c,{stream:!0}))}return s.push(i.decode()),JSON.parse(s.join(""))}finally{await wi(r,"transport/release",{transfer_id:o.id}).catch(()=>{})}}function Am(){let r=window.__NEXTFLOOR_SYMCON__;if(!r?.endpoint||!r.token)throw new Error("NextFloor Symcon host configuration is missing");return r}var Pr=class{settings=Am();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:[],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=o=>e({revision:o});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 Pt(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 Pt(this.settings,"bootstrap"):await Pt(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){if(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}])),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.Line truncated
</ha-card>`}static styles=[Se,Ke,Zc,pr]};if(!customElements.get("nextfloor-card")){customElements.define("nextfloor-card",vi);let r=window;r.customCards=r.customCards??[],r.customCards.push({type:"nextfloor-card",name:R(void 0,"card_name"),description:R(void 0,"card_description"),preview:!1})}to();var Rm="nextfloor-chunks-v1";async function yi(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:Rm})}),o=await n.text(),i;try{i=JSON.parse(o)}catch{throw/Output-Buffer exceeds Limit/i.test(o)?new Error("Symcon hat die Antwort wegen seiner Ausgabebegrenzung abgebrochen. Bitte das NextFloor-Modul aktualisieren und den Designer neu laden."):new Error(`Symcon liefert ${o.trim()?"kein g\xFCltiges JSON":"eine leere Antwort"} f\xFCr \u201E${e}\u201C (HTTP ${n.status}).`)}if(!n.ok||!i||typeof i!="object"||"error"in i){let s=i&&typeof i=="object"&&"error"in i?i.error:`HTTP ${n.status}`;throw new Error(String(s))}return i}async function Ht(r,e,t={}){let n=await yi(r,e,t);if(!("_nextfloor_transfer"in n))return n;let o=n._nextfloor_transfer;if(!o||!/^[a-f0-9]{32}$/.test(o.id)||!Number.isSafeInteger(o.bytes)||o.bytes<=0||o.bytes>67108864||!Number.isSafeInteger(o.chunk_bytes)||o.chunk_bytes<=0||o.chunk_bytes>128*1024||o.chunks!==Math.ceil(o.bytes/o.chunk_bytes)||o.chunks>512)throw new Error("Symcon hat eine ung\xFCltige Daten\xFCbertragung angek\xFCndigt.");try{let i=new TextDecoder("utf-8",{fatal:!0}),s=[];for(let a=0;a<o.chunks;a++){let l=await yi(r,"transport/read",{transfer_id:o.id,index:a});if(l.index!==a||typeof l.data!="string")throw new Error("Ein Symcon-Datenpaket fehlt oder ist ung\xFCltig.");let c=Uint8Array.from(atob(l.data),u=>u.charCodeAt(0));if(c.length!==Math.min(o.chunk_bytes,o.bytes-a*o.chunk_bytes))throw new Error("Ein Symcon-Datenpaket wurde unvollst\xE4ndig \xFCbertragen.");s.push(i.decode(c,{stream:!0}))}return s.push(i.decode()),JSON.parse(s.join(""))}finally{await yi(r,"transport/release",{transfer_id:o.id}).catch(()=>{})}}function zm(r){let e=r.attributes;if(typeof e.symcon_numeric_value!="number")return null;let t=typeof e.symcon_min=="number"?e.symcon_min:0,n=typeof e.symcon_max=="number"&&e.symcon_max>t?e.symcon_max:100;return Math.max(0,Math.min(100,(e.symcon_numeric_value-t)/(n-t)*100))}function Jc(r,e){let t=zm(r),n=r.attributes.symcon_id;return t===null||typeof n!="number"?null:{...r,entity_id:`${e}.${n}`,state:e==="light"?t>0?"on":"off":t>0?"open":"closed",attributes:{...r.attributes,...e==="light"?{brightness:Math.round(t*2.55),color_mode:"brightness",supported_color_modes:["brightness"]}:{current_position:t,supported_features:4},...r.entity_id!==`${e}.${n}`?{symcon_source_entity:r.entity_id}:{}}}}function Tm(){let r=window.__NEXTFLOOR_SYMCON__;if(!r?.endpoint||!r.token)throw new Error("NextFloor Symcon host configuration is missing");return r}var Ir=class{settings=Tm();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:[],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=o=>e({revision:o});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 Ht(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 Ht(this.settings,"bootstrap"):await Ht(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.changeListenerLine truncated
/*! Bundled license information:
@lit/reactive-element/css-tag.js:
+168 -165
View File
@@ -1,7 +1,7 @@
/*! NextFloor, MIT licence. Includes three.js (MIT) and Lit (BSD-3-Clause); see LICENSE and THIRD_PARTY_NOTICES.md */
var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",fr:"6312d0f61ebf",hu:"27ba348531dc",it:"1b705e76dd00",nb:"c5ea24fb9ef6",nl:"b64142c67c2e",pl:"8527a4930402",pt:"31857a2d2277",ro:"e3cb5f449f0f",sk:"320611594db0",sl:"8071691ceda3",sv:"711b911ec8da",tr:"7c83ce1c3372",zh:"50518d9f494e"};var bo=globalThis,yo=bo.ShadowRoot&&(bo.ShadyCSS===void 0||bo.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,qi=Symbol(),Ll=new WeakMap,lr=class{constructor(e,n,r){if(this._$cssResult$=!0,r!==qi)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=n}get styleSheet(){let e=this.o,n=this.t;if(yo&&e===void 0){let r=n!==void 0&&n.length===1;r&&(e=Ll.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Ll.set(n,e))}return e}toString(){return this.cssText}},Cl=t=>new lr(typeof t=="string"?t:t+"",void 0,qi),se=(t,...e)=>{let n=t.length===1?t[0]:e.reduce((r,o,i)=>r+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+t[i+1],t[0]);return new lr(n,t,qi)},Nl=(t,e)=>{if(yo)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let r=document.createElement("style"),o=bo.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=n.cssText,t.appendChild(r)}},Yi=yo?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let r of e.cssRules)n+=r.cssText;return Cl(n)})(t):t;var{is:Xg,defineProperty:Qg,getOwnPropertyDescriptor:Jg,getOwnPropertyNames:e_,getOwnPropertySymbols:t_,getPrototypeOf:n_}=Object,wo=globalThis,Bl=wo.trustedTypes,r_=Bl?Bl.emptyScript:"",o_=wo.reactiveElementPolyfillSupport,cr=(t,e)=>t,Xi={toAttribute(t,e){switch(e){case Boolean:t=t?r_:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=t!==null;break;case Number:n=t===null?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch{n=null}}return n}},Vl=(t,e)=>!Xg(t,e),Wl={attribute:!0,type:String,converter:Xi,reflect:!1,useDefault:!1,hasChanged:Vl};Symbol.metadata??=Symbol("metadata"),wo.litPropertyMetadata??=new WeakMap;var ft=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,n=Wl){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(e,n),!n.noAccessor){let r=Symbol(),o=this.getPropertyDescriptor(e,r,n);o!==void 0&&Qg(this.prototype,e,o)}}static getPropertyDescriptor(e,n,r){let{get:o,set:i}=Jg(this.prototype,e)??{get(){return this[n]},set(s){this[n]=s}};return{get:o,set(s){let l=o?.call(this);i?.call(this,s),this.requestUpdate(e,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Wl}static _$Ei(){if(this.hasOwnProperty(cr("elementProperties")))return;let e=n_(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(cr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(cr("properties"))){let n=this.properties,r=[...e_(n),...t_(n)];for(let o of r)this.createProperty(o,n[o])}let e=this[Symbol.metadata];if(e!==null){let n=litPropertyMetadata.get(e);if(n!==void 0)for(let[r,o]of n)this.elementProperties.set(r,o)}this._$Eh=new Map;for(let[n,r]of this.elementProperties){let o=this._$Eu(n,r);o!==void 0&&this._$Eh.set(o,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let n=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let o of r)n.unshift(Yi(o))}else e!==void 0&&n.push(Yi(e));return n}static _$Eu(e,n){let r=n.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.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(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,n=this.constructor.elementProperties;for(let r of n.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Nl(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.Line truncated
\f\r]`,dr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,jl=/-->/g,Ul=/>/g,Kt=RegExp(`>|${Qi}(?:([^\\s"'>=/]+)(${Qi}*=${Qi}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`,"g"),Zl=/'/g,ql=/"/g,Ql=/^(?:script|style|textarea|title)$/i,rs=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),m=rs(1),R=rs(2),Ak=rs(3),Qe=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),Yl=new WeakMap,Gt=jt.createTreeWalker(jt,129);function Jl(t,e){if(!ns(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Gl!==void 0?Gl.createHTML(e):e}var ec=(t,e)=>{let n=t.length-1,r=[],o,i=e===2?"<svg>":e===3?"<math>":"",s=dr;for(let l=0;l<n;l++){let a=t[l],c,d,u=-1,p=0;for(;p<a.length&&(s.lastIndex=p,d=s.exec(a),d!==null);)p=s.lastIndex,s===dr?d[1]==="!--"?s=jl:d[1]!==void 0?s=Ul:d[2]!==void 0?(Ql.test(d[2])&&(o=RegExp("</"+d[2],"g")),s=Kt):d[3]!==void 0&&(s=Kt):s===Kt?d[0]===">"?(s=o??dr,u=-1):d[1]===void 0?u=-2:(u=s.lastIndex-d[2].length,c=d[1],s=d[3]===void 0?Kt:d[3]==='"'?ql:Zl):s===ql||s===Zl?s=Kt:s===jl||s===Ul?s=dr:(s=Kt,o=void 0);let h=s===Kt&&t[l+1].startsWith("/>")?" ":"";i+=s===dr?a+i_:u>=0?(r.push(c),a.slice(0,u)+es+a.slice(u)+mt+h):a+mt+(u===-2?l:h)}return[Jl(t,i+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]},pr=class t{constructor({strings:e,_$litType$:n},r){let o;this.parts=[];let i=0,s=0,l=e.length-1,a=this.parts,[c,d]=ec(e,n);if(this.el=t.createElement(c,r),Gt.currentNode=this.el.content,n===2||n===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(o=Gt.nextNode())!==null&&a.length<l;){if(o.nodeType===1){if(o.hasAttributes())for(let u of o.getAttributeNames())if(u.endsWith(es)){let p=d[s++],h=o.getAttribute(u).split(mt),f=/([.?@])?(.*)/.exec(p);a.push({type:1,index:i,name:f[2],strings:h,ctor:f[1]==="."?xo:f[1]==="?"?$o:f[1]==="@"?So:Zt}),o.removeAttribute(u)}else u.startsWith(mt)&&(a.push({type:6,index:i}),o.removeAttribute(u));if(Ql.test(o.tagName)){let u=o.textContent.split(mt),p=u.length-1;if(p>0){o.textContent=vo?vo.emptyScript:"";for(let h=0;h<p;h++)o.append(u[h],ur()),Gt.nextNode(),a.push({type:2,index:++i});o.append(u[p],ur())}}}else if(o.nodeType===8)if(o.data===ts)a.push({type:2,index:i});else{let u=-1;for(;(u=o.data.indexOf(mt,u+1))!==-1;)a.push({type:7,index:i}),u+=mt.length-1}i++}}static createElement(e,n){let r=jt.createElement("template");return r.innerHTML=e,r}};function Ut(t,e,n=t,r){if(e===Qe)return e;let o=r!==void 0?n._$Co?.[r]:n._$Cl,i=hr(e)?void 0:e._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),i===void 0?o=void 0:(o=new i(t),o._$AT(t,n,r)),r!==void 0?(n._$Co??=[])[r]=o:n._$Cl=o),o!==void 0&&(e=Ut(t,o._$AS(t,e.values),o,r)),e}var ko=class{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:n},parts:r}=this._$AD,o=(e?.creationScope??jt).importNode(n,!0);Gt.currentNode=o;let i=Gt.nextNode(),s=0,l=0,a=r[0];for(;a!==void 0;){if(s===a.index){let c;a.type===2?c=new bn(i,i.nextSibling,this,e):a.type===1?c=new a.ctor(i,a.name,a.strings,this,e):a.type===6&&(c=new Mo(i,this,e)),this._$AV.push(c),a=r[++l]}s!==a?.index&&(i=Gt.nextNode(),s++)}return Gt.currentNode=jt,o}p(e){let n=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,n),n+=r.strings.length-2):r._$AI(e[n])),n++}},bn=class t{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,n,r,o){this.type=2,this._$AH=_,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=o,this._$Cv=o?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,n=this._$AM;return n!==void 0&&e?.nodeType===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=Ut(this,e,n),hr(e)?e===_||e==null||e===""?(this._$AH!==_&&this._$AR(),this._$AH=_):e!==this._$AH&&e!==Qe&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Xl(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==_&&hr(this._$AH)?this._$AA.nextSibling.data=e:this.T(jt.createTextNode(e)),this._$AH=e}$(e){let{values:n,_$litType$:r}=e,o=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=pr.createElement(Jl(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===o)this._$AH.p(n);else{let i=new ko(o,this),s=i.u(this.options);i.p(n),this.T(s),this._$AH=i}}_$AC(e){let n=Yl.get(e.strings);return n===void 0&&Yl.set(e.strings,n=new pr(e)),n}k(e){ns(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,o=0;for(let i of e)o===n.length?n.push(r=new t(this.O(ur()),this.O(ur()),this,this.options)):r=n[o],r._$AI(i),o++;o<n.length&&(this._$AR(r&&r._$AB.nextSibling,o),n.length=o)}_$AR(e=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);e!==this._$AB;){let r=Kl(e).nextSibling;Kl(e).remove(),e=r}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},Zt=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,r,o,i){this.type=1,this._$AH=_,this._$AN=void 0,this.element=e,this.name=n,this._$AM=o,this.options=i,r.length>2||r[0]!==""||r[1]!==""?(this._Line truncated
var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",fr:"6312d0f61ebf",hu:"27ba348531dc",it:"1b705e76dd00",nb:"c5ea24fb9ef6",nl:"b64142c67c2e",pl:"8527a4930402",pt:"31857a2d2277",ro:"e3cb5f449f0f",sk:"320611594db0",sl:"8071691ceda3",sv:"711b911ec8da",tr:"7c83ce1c3372",zh:"50518d9f494e"};var bo=globalThis,yo=bo.ShadowRoot&&(bo.ShadyCSS===void 0||bo.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,qi=Symbol(),Ll=new WeakMap,cr=class{constructor(e,n,r){if(this._$cssResult$=!0,r!==qi)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=n}get styleSheet(){let e=this.o,n=this.t;if(yo&&e===void 0){let r=n!==void 0&&n.length===1;r&&(e=Ll.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Ll.set(n,e))}return e}toString(){return this.cssText}},Cl=t=>new cr(typeof t=="string"?t:t+"",void 0,qi),se=(t,...e)=>{let n=t.length===1?t[0]:e.reduce((r,o,i)=>r+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+t[i+1],t[0]);return new cr(n,t,qi)},Nl=(t,e)=>{if(yo)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let r=document.createElement("style"),o=bo.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=n.cssText,t.appendChild(r)}},Yi=yo?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let r of e.cssRules)n+=r.cssText;return Cl(n)})(t):t;var{is:Xg,defineProperty:Qg,getOwnPropertyDescriptor:Jg,getOwnPropertyNames:e_,getOwnPropertySymbols:t_,getPrototypeOf:n_}=Object,wo=globalThis,Bl=wo.trustedTypes,r_=Bl?Bl.emptyScript:"",o_=wo.reactiveElementPolyfillSupport,dr=(t,e)=>t,Xi={toAttribute(t,e){switch(e){case Boolean:t=t?r_:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=t!==null;break;case Number:n=t===null?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch{n=null}}return n}},Vl=(t,e)=>!Xg(t,e),Wl={attribute:!0,type:String,converter:Xi,reflect:!1,useDefault:!1,hasChanged:Vl};Symbol.metadata??=Symbol("metadata"),wo.litPropertyMetadata??=new WeakMap;var mt=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,n=Wl){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(e,n),!n.noAccessor){let r=Symbol(),o=this.getPropertyDescriptor(e,r,n);o!==void 0&&Qg(this.prototype,e,o)}}static getPropertyDescriptor(e,n,r){let{get:o,set:i}=Jg(this.prototype,e)??{get(){return this[n]},set(s){this[n]=s}};return{get:o,set(s){let l=o?.call(this);i?.call(this,s),this.requestUpdate(e,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Wl}static _$Ei(){if(this.hasOwnProperty(dr("elementProperties")))return;let e=n_(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(dr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(dr("properties"))){let n=this.properties,r=[...e_(n),...t_(n)];for(let o of r)this.createProperty(o,n[o])}let e=this[Symbol.metadata];if(e!==null){let n=litPropertyMetadata.get(e);if(n!==void 0)for(let[r,o]of n)this.elementProperties.set(r,o)}this._$Eh=new Map;for(let[n,r]of this.elementProperties){let o=this._$Eu(n,r);o!==void 0&&this._$Eh.set(o,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let n=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let o of r)n.unshift(Yi(o))}else e!==void 0&&n.push(Yi(e));return n}static _$Eu(e,n){let r=n.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.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(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,n=this.constructor.elementProperties;for(let r of n.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Nl(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.Line truncated
\f\r]`,ur=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,jl=/-->/g,Ul=/>/g,Gt=RegExp(`>|${Qi}(?:([^\\s"'>=/]+)(${Qi}*=${Qi}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`,"g"),Zl=/'/g,ql=/"/g,Ql=/^(?:script|style|textarea|title)$/i,rs=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),m=rs(1),R=rs(2),Ak=rs(3),Qe=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),Yl=new WeakMap,jt=Ut.createTreeWalker(Ut,129);function Jl(t,e){if(!ns(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Gl!==void 0?Gl.createHTML(e):e}var ec=(t,e)=>{let n=t.length-1,r=[],o,i=e===2?"<svg>":e===3?"<math>":"",s=ur;for(let l=0;l<n;l++){let a=t[l],c,d,u=-1,p=0;for(;p<a.length&&(s.lastIndex=p,d=s.exec(a),d!==null);)p=s.lastIndex,s===ur?d[1]==="!--"?s=jl:d[1]!==void 0?s=Ul:d[2]!==void 0?(Ql.test(d[2])&&(o=RegExp("</"+d[2],"g")),s=Gt):d[3]!==void 0&&(s=Gt):s===Gt?d[0]===">"?(s=o??ur,u=-1):d[1]===void 0?u=-2:(u=s.lastIndex-d[2].length,c=d[1],s=d[3]===void 0?Gt:d[3]==='"'?ql:Zl):s===ql||s===Zl?s=Gt:s===jl||s===Ul?s=ur:(s=Gt,o=void 0);let h=s===Gt&&t[l+1].startsWith("/>")?" ":"";i+=s===ur?a+i_:u>=0?(r.push(c),a.slice(0,u)+es+a.slice(u)+gt+h):a+gt+(u===-2?l:h)}return[Jl(t,i+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]},fr=class t{constructor({strings:e,_$litType$:n},r){let o;this.parts=[];let i=0,s=0,l=e.length-1,a=this.parts,[c,d]=ec(e,n);if(this.el=t.createElement(c,r),jt.currentNode=this.el.content,n===2||n===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(o=jt.nextNode())!==null&&a.length<l;){if(o.nodeType===1){if(o.hasAttributes())for(let u of o.getAttributeNames())if(u.endsWith(es)){let p=d[s++],h=o.getAttribute(u).split(gt),f=/([.?@])?(.*)/.exec(p);a.push({type:1,index:i,name:f[2],strings:h,ctor:f[1]==="."?xo:f[1]==="?"?$o:f[1]==="@"?So:qt}),o.removeAttribute(u)}else u.startsWith(gt)&&(a.push({type:6,index:i}),o.removeAttribute(u));if(Ql.test(o.tagName)){let u=o.textContent.split(gt),p=u.length-1;if(p>0){o.textContent=vo?vo.emptyScript:"";for(let h=0;h<p;h++)o.append(u[h],hr()),jt.nextNode(),a.push({type:2,index:++i});o.append(u[p],hr())}}}else if(o.nodeType===8)if(o.data===ts)a.push({type:2,index:i});else{let u=-1;for(;(u=o.data.indexOf(gt,u+1))!==-1;)a.push({type:7,index:i}),u+=gt.length-1}i++}}static createElement(e,n){let r=Ut.createElement("template");return r.innerHTML=e,r}};function Zt(t,e,n=t,r){if(e===Qe)return e;let o=r!==void 0?n._$Co?.[r]:n._$Cl,i=pr(e)?void 0:e._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),i===void 0?o=void 0:(o=new i(t),o._$AT(t,n,r)),r!==void 0?(n._$Co??=[])[r]=o:n._$Cl=o),o!==void 0&&(e=Zt(t,o._$AS(t,e.values),o,r)),e}var ko=class{constructor(e,n){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=n}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:n},parts:r}=this._$AD,o=(e?.creationScope??Ut).importNode(n,!0);jt.currentNode=o;let i=jt.nextNode(),s=0,l=0,a=r[0];for(;a!==void 0;){if(s===a.index){let c;a.type===2?c=new yn(i,i.nextSibling,this,e):a.type===1?c=new a.ctor(i,a.name,a.strings,this,e):a.type===6&&(c=new Mo(i,this,e)),this._$AV.push(c),a=r[++l]}s!==a?.index&&(i=jt.nextNode(),s++)}return jt.currentNode=Ut,o}p(e){let n=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,n),n+=r.strings.length-2):r._$AI(e[n])),n++}},yn=class t{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,n,r,o){this.type=2,this._$AH=_,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=o,this._$Cv=o?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,n=this._$AM;return n!==void 0&&e?.nodeType===11&&(e=n.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,n=this){e=Zt(this,e,n),pr(e)?e===_||e==null||e===""?(this._$AH!==_&&this._$AR(),this._$AH=_):e!==this._$AH&&e!==Qe&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Xl(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==_&&pr(this._$AH)?this._$AA.nextSibling.data=e:this.T(Ut.createTextNode(e)),this._$AH=e}$(e){let{values:n,_$litType$:r}=e,o=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=fr.createElement(Jl(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===o)this._$AH.p(n);else{let i=new ko(o,this),s=i.u(this.options);i.p(n),this.T(s),this._$AH=i}}_$AC(e){let n=Yl.get(e.strings);return n===void 0&&Yl.set(e.strings,n=new fr(e)),n}k(e){ns(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,o=0;for(let i of e)o===n.length?n.push(r=new t(this.O(hr()),this.O(hr()),this,this.options)):r=n[o],r._$AI(i),o++;o<n.length&&(this._$AR(r&&r._$AB.nextSibling,o),n.length=o)}_$AR(e=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);e!==this._$AB;){let r=Kl(e).nextSibling;Kl(e).remove(),e=r}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},qt=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,r,o,i){this.type=1,this._$AH=_,this._$AN=void 0,this.element=e,this.name=n,this._$AM=o,this.options=i,r.length>2||r[0]!==""||r[1]!==""?(this._Line truncated
:host {
--nf-text: var(--primary-text-color, #e1e1e1);
--nf-muted: var(--secondary-text-color, #9b9b9b);
@@ -29,7 +29,7 @@ var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
font-family: var(--nf-font);
color: var(--nf-text);
}
`,H$=se`
`,L$=se`
: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 S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
:host([readable]) .nf-overlay {
zoom: 1.2;
}
`,ut=se`
`,ht=se`
/* a group of switches: one rounded pill, the active one tinted with the accent */
.nf-seg {
display: inline-flex;
@@ -203,23 +203,23 @@ var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
min-height: 40px;
}
}
`;var me=t=>/^(sensor|input_number|number)\./.test(t),ii=t=>/^(binary_sensor|input_boolean)\./.test(t);function On(t,e){if(!me(e))return!1;let n=t?.states[e]?.attributes;return n?.device_class==="power"||n?.unit_of_measurement==="W"||n?.unit_of_measurement==="kW"}function Sb(t,e){let n=t?.entities?.[e],r=n?.area_id??(n?.device_id?t?.devices?.[n.device_id]?.area_id:null);return r?t?.areas?.[r]?.name:void 0}function L(t,e){return Object.keys(t?.states??{}).filter(e).map(n=>{let r=Sb(t,n),o=t?.states[n],i=typeof o?.attributes.symcon_path=="string"?o.attributes.symcon_path:void 0,s={id:n,label:r?`${W(t,n)} \xB7 ${r}`:W(t,n)};return i&&(s.detail=`Objektbaum: ${i}`),s}).sort((n,r)=>n.label.localeCompare(r.label))}function si(t,e){return t.power&&t.power!=="none"?t.power:e.get(t.id)?.power??null}var Hn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},on=t=>(...e)=>({_$litDirective$:t,values:e}),Dt=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}};var Gr=class extends Dt{constructor(e){if(super(e),this.it=_,e.type!==Hn.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===_||e==null)return this._t=void 0,this.it=e;if(e===Qe)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};Gr.directiveName="unsafeHTML",Gr.resultType=1;var ru=on(Gr);var{I:Mb}=tc,ou=t=>t;var su=t=>t.strings===void 0,iu=()=>document.createComment(""),Ln=(t,e,n)=>{let r=t._$AA.parentNode,o=e===void 0?t._$AB:e._$AA;if(n===void 0){let i=r.insertBefore(iu(),o),s=r.insertBefore(iu(),o);n=new Mb(i,s,t,t.options)}else{let i=n._$AB.nextSibling,s=n._$AM,l=s!==t;if(l){let a;n._$AQ?.(t),n._$AM=t,n._$AP!==void 0&&(a=t._$AU)!==s._$AU&&n._$AP(a)}if(i!==o||l){let a=n._$AA;for(;a!==i;){let c=ou(a).nextSibling;ou(r).insertBefore(a,o),a=c}}}return n},Ot=(t,e,n=t)=>(t._$AI(e,n),t),Rb={},au=(t,e=Rb)=>t._$AH=e,lu=t=>t._$AH,ai=t=>{t._$AR(),t._$AA.remove()};var cu=(t,e,n)=>{let r=new Map;for(let o=e;o<=n;o++)r.set(t[o],o);return r},du=on(class extends Dt{constructor(t){if(super(t),t.type!==Hn.CHILD)throw Error("repeat() can only be used in text expressions")}dt(t,e,n){let r;n===void 0?n=e:e!==void 0&&(r=e);let o=[],i=[],s=0;for(let l of t)o[s]=r?r(l,s):s,i[s]=n(l,s),s++;return{values:i,keys:o}}render(t,e,n){return this.dt(t,e,n).values}update(t,[e,n,r]){let o=lu(t),{values:i,keys:s}=this.dt(e,n,r);if(!Array.isArray(o))return this.ut=s,i;let l=this.ut??=[],a=[],c,d,u=0,p=o.length-1,h=0,f=i.length-1;for(;u<=p&&h<=f;)if(o[u]===null)u++;else if(o[p]===null)p--;else if(l[u]===s[h])a[h]=Ot(o[u],i[h]),u++,h++;else if(l[p]===s[f])a[f]=Ot(o[p],i[f]),p--,f--;else if(l[u]===s[f])a[f]=Ot(o[u],i[f]),Ln(t,a[f+1],o[u]),u++,f--;else if(l[p]===s[h])a[h]=Ot(o[p],i[h]),Ln(t,o[u],o[p]),p--,h++;else if(c===void 0&&(c=cu(s,h,f),d=cu(l,u,p)),c.has(l[u]))if(c.has(l[p])){let g=d.get(s[h]),y=g!==void 0?o[g]:null;if(y===null){let b=Ln(t,o[u]);Ot(b,i[h]),a[h]=b}else a[h]=Ot(y,i[h]),Ln(t,o[u],y),o[g]=null;h++}else ai(o[p]),p--;else ai(o[u]),u++;for(;h<=f;){let g=Ln(t,a[f+1]);Ot(g,i[h]),a[h++]=g}for(;u<=p;){let g=o[u++];g!==null&&ai(g)}return this.ut=s,au(t,a),Qe}});var Eb=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),sa=-1,hu=[{type:1,name:"I/O"},{type:2,name:"Splitter"},{type:0,name:"Kerninstanzen"},{type:4,name:"Konfiguratoren"},{type:5,name:"Discovery"},{type:6,name:"Visualisierungen"}],uu=t=>t.object_type===1&&hu.some(e=>e.type===t.module_type);function Ab(t){let e=new Map(t.map(a=>[a.object_id,a])),n=t.filter(a=>{if(!uu(a))return!1;let c=new Set([a.object_id]),d=e.get(a.parent_id);for(;d&&!c.has(d.object_id);){if(uu(d))return!1;c.add(d.object_id),d=e.get(d.parent_id)}return!0});if(!n.length)return t;let r=new Map(e),o=new Map;for(let a of t){let c=o.get(a.parent_id)??[];c.push(a),o.set(a.parent_id,c)}let i=(a,c,d,u,p)=>({object_id:a,parent_id:c,name:d,path:u,position:p,object_type:0,hidden:!1,icon:"",virtual:!0});r.set(sa,i(sa,0,"System","System",Number.MAX_SAFE_INTEGER));let s=new Set,l=(a,c,d)=>{if(s.has(a.object_id))return;s.add(a.object_id);let u={...a,parent_id:c,path:`${d} / ${a.name}`};r.set(a.object_id,u);for(let p of o.get(a.object_id)??[])l(p,a.object_id,u.path)};return hu.forEach((a,c)=>{let d=n.filter(h=>h.module_type===a.type);if(!d.length)return;let u=-10-a.type,p=`System / ${a.name}`;r.set(u,i(u,sa,a.name,p,c));for(let h of d)l(h,u,p)}),[...r.values()]}function aa(t){let e=Ab(t),n=new Map(e.map(o=>[o.object_id,o])),r=new Map;for(let o of e){let i=n.has(o.parent_id)?o.parent_id:0,s=r.get(i)??[];s.push(o),r.set(i,s)}for(let o of r.values())o.sort((i,s)=>i.position-s.position||i.object_type-s.object_type||Eb.compare(i.name,s.name));return{nodes:n,children:r}}function la(t,e){let n=[], Line truncated
`;var me=t=>/^(sensor|input_number|number)\./.test(t),ii=t=>/^(binary_sensor|input_boolean)\./.test(t);function Hn(t,e){if(!me(e))return!1;let n=t?.states[e]?.attributes;return n?.device_class==="power"||n?.unit_of_measurement==="W"||n?.unit_of_measurement==="kW"}function Sb(t,e){let n=t?.entities?.[e],r=n?.area_id??(n?.device_id?t?.devices?.[n.device_id]?.area_id:null);return r?t?.areas?.[r]?.name:void 0}function L(t,e){return Object.keys(t?.states??{}).filter(e).map(n=>{let r=Sb(t,n),o=t?.states[n],i=typeof o?.attributes.symcon_path=="string"?o.attributes.symcon_path:void 0,s={id:n,label:r?`${W(t,n)} \xB7 ${r}`:W(t,n)};return i&&(s.detail=`Objektbaum: ${i}`),typeof o?.attributes.symcon_source_entity=="string"&&(s.sourceEntity=o.attributes.symcon_source_entity),s}).sort((n,r)=>n.label.localeCompare(r.label))}function si(t,e){return t.power&&t.power!=="none"?t.power:e.get(t.id)?.power??null}var Ln={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},sn=t=>(...e)=>({_$litDirective$:t,values:e}),Ot=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}};var Gr=class extends Ot{constructor(e){if(super(e),this.it=_,e.type!==Ln.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===_||e==null)return this._t=void 0,this.it=e;if(e===Qe)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};Gr.directiveName="unsafeHTML",Gr.resultType=1;var ru=sn(Gr);var{I:Mb}=tc,ou=t=>t;var su=t=>t.strings===void 0,iu=()=>document.createComment(""),Cn=(t,e,n)=>{let r=t._$AA.parentNode,o=e===void 0?t._$AB:e._$AA;if(n===void 0){let i=r.insertBefore(iu(),o),s=r.insertBefore(iu(),o);n=new Mb(i,s,t,t.options)}else{let i=n._$AB.nextSibling,s=n._$AM,l=s!==t;if(l){let a;n._$AQ?.(t),n._$AM=t,n._$AP!==void 0&&(a=t._$AU)!==s._$AU&&n._$AP(a)}if(i!==o||l){let a=n._$AA;for(;a!==i;){let c=ou(a).nextSibling;ou(r).insertBefore(a,o),a=c}}}return n},Ht=(t,e,n=t)=>(t._$AI(e,n),t),Rb={},au=(t,e=Rb)=>t._$AH=e,lu=t=>t._$AH,ai=t=>{t._$AR(),t._$AA.remove()};var cu=(t,e,n)=>{let r=new Map;for(let o=e;o<=n;o++)r.set(t[o],o);return r},du=sn(class extends Ot{constructor(t){if(super(t),t.type!==Ln.CHILD)throw Error("repeat() can only be used in text expressions")}dt(t,e,n){let r;n===void 0?n=e:e!==void 0&&(r=e);let o=[],i=[],s=0;for(let l of t)o[s]=r?r(l,s):s,i[s]=n(l,s),s++;return{values:i,keys:o}}render(t,e,n){return this.dt(t,e,n).values}update(t,[e,n,r]){let o=lu(t),{values:i,keys:s}=this.dt(e,n,r);if(!Array.isArray(o))return this.ut=s,i;let l=this.ut??=[],a=[],c,d,u=0,p=o.length-1,h=0,f=i.length-1;for(;u<=p&&h<=f;)if(o[u]===null)u++;else if(o[p]===null)p--;else if(l[u]===s[h])a[h]=Ht(o[u],i[h]),u++,h++;else if(l[p]===s[f])a[f]=Ht(o[p],i[f]),p--,f--;else if(l[u]===s[f])a[f]=Ht(o[u],i[f]),Cn(t,a[f+1],o[u]),u++,f--;else if(l[p]===s[h])a[h]=Ht(o[p],i[h]),Cn(t,o[u],o[p]),p--,h++;else if(c===void 0&&(c=cu(s,h,f),d=cu(l,u,p)),c.has(l[u]))if(c.has(l[p])){let g=d.get(s[h]),y=g!==void 0?o[g]:null;if(y===null){let b=Cn(t,o[u]);Ht(b,i[h]),a[h]=b}else a[h]=Ht(y,i[h]),Cn(t,o[u],y),o[g]=null;h++}else ai(o[p]),p--;else ai(o[u]),u++;for(;h<=f;){let g=Cn(t,a[f+1]);Ht(g,i[h]),a[h++]=g}for(;u<=p;){let g=o[u++];g!==null&&ai(g)}return this.ut=s,au(t,a),Qe}});var Eb=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),sa=-1,hu=[{type:1,name:"I/O"},{type:2,name:"Splitter"},{type:0,name:"Kerninstanzen"},{type:4,name:"Konfiguratoren"},{type:5,name:"Discovery"},{type:6,name:"Visualisierungen"}],uu=t=>t.object_type===1&&hu.some(e=>e.type===t.module_type);function Ab(t){let e=new Map(t.map(a=>[a.object_id,a])),n=t.filter(a=>{if(!uu(a))return!1;let c=new Set([a.object_id]),d=e.get(a.parent_id);for(;d&&!c.has(d.object_id);){if(uu(d))return!1;c.add(d.object_id),d=e.get(d.parent_id)}return!0});if(!n.length)return t;let r=new Map(e),o=new Map;for(let a of t){let c=o.get(a.parent_id)??[];c.push(a),o.set(a.parent_id,c)}let i=(a,c,d,u,p)=>({object_id:a,parent_id:c,name:d,path:u,position:p,object_type:0,hidden:!1,icon:"",virtual:!0});r.set(sa,i(sa,0,"System","System",Number.MAX_SAFE_INTEGER));let s=new Set,l=(a,c,d)=>{if(s.has(a.object_id))return;s.add(a.object_id);let u={...a,parent_id:c,path:`${d} / ${a.name}`};r.set(a.object_id,u);for(let p of o.get(a.object_id)??[])l(p,a.object_id,u.path)};return hu.forEach((a,c)=>{let d=n.filter(h=>h.module_type===a.type);if(!d.length)return;let u=-10-a.type,p=`System / ${a.name}`;r.set(u,i(u,sa,a.name,p,c));for(let h of d)l(h,u,p)}),[...r.values()]}function aa(t){let e=Ab(t),n=new Map(e.map(o=>[o.object_id,o])),r=new Map;for(let o of e){let i=n.has(o.parent_id)?o.parent_id:0,s=r.get(i)??[];s.push(o),r.set(i,s)}for(let o of r.values())o.sort((i,s)=>i.position-s.position||i.obj Line truncated
aria-level=${e.depth+1} aria-posinset=${e.index} aria-setsize=${e.siblings}
aria-expanded=${e.hasChildren?String(e.expanded):_}
aria-selected=${r?String(n.object_id===this._selected&&n.entity_id===this._pending):_}
aria-disabled=${n.entity_id&&!r?"true":_}
class="node ${r?"selectable":""} ${n.hidden?"hidden-object":""} ${this._active===n.object_id?"active":""}"
aria-selected=${o?String(n.object_id===this._selected&&r===this._pending):_}
aria-disabled=${n.entity_id&&!o?"true":_}
class="node ${o?"selectable":""} ${n.hidden?"hidden-object":""} ${this._active===n.object_id?"active":""}"
style=${`--depth:${e.depth}`} title=${n.path}
@click=${()=>{this.select(n),this.renderRoot.querySelector(".tree")?.focus()}}
@dblclick=${()=>{r?(this.select(n),this.commit()):e.hasChildren&&this.toggle(n.object_id)}}>
@dblclick=${()=>{o?(this.select(n),this.commit()):e.hasChildren&&this.toggle(n.object_id)}}>
<button class="twisty" type="button" tabindex="-1" aria-label=${e.expanded?"Zuklappen":"Aufklappen"}
?disabled=${!e.hasChildren} @click=${o=>{o.stopPropagation(),this._active=n.object_id,this.toggle(n.object_id)}}>
?disabled=${!e.hasChildren} @click=${i=>{i.stopPropagation(),this._active=n.object_id,this.toggle(n.object_id)}}>
${e.hasChildren?e.expanded?"\u25BE":"\u25B8":_}
</button>
${this.icon(n.object_type)}<span class="node-name">${n.name||"(Ohne Namen)"}</span>
<small>${n.virtual?"Systembereich":Fb[n.object_type]??"Objekt"}${n.hidden?" \xB7 ausgeblendet":""}</small>
${r&&n.object_id===this._selected&&n.entity_id===this._pending?m`<span class="selected-mark" aria-hidden="true">✓</span>`:_}
</div>`}render(){let e=this.allowed.get(this.value??""),n=this.variableNode(this.value),r=this.allowed.get(this._pending??""),o=this._selected===null?void 0:this.tree.nodes.get(this._selected),i=(o?.entity_id===this._pending?o:void 0)??this.variableNode(this._pending),s=ca(this.tree,this._expanded,this._query),l=s.find(a=>a.node.object_id===this._active);return m`<button type="button" class="trigger" ?disabled=${this.disabled} aria-haspopup="dialog" @click=${this.open}>
${o&&n.object_id===this._selected&&r===this._pending?m`<span class="selected-mark" aria-hidden="true">✓</span>`:_}
</div>`}render(){let e=this.allowed.get(this.value??""),n=this.variableNode(this.value),r=this.allowed.get(this._pending??""),o=this._selected===null?void 0:this.tree.nodes.get(this._selected),i=(o&&this.entityFor(o)===this._pending?o:void 0)??this.variableNode(this._pending),s=ca(this.tree,this._expanded,this._query),l=s.find(a=>a.node.object_id===this._active);return m`<button type="button" class="trigger" ?disabled=${this.disabled} aria-haspopup="dialog" @click=${this.open}>
<span><strong>${n?.name??e?.label??"Datenpunkt ausw\xE4hlen"}</strong>
${n?m`<small>${n.path}</small>`:_}</span><span aria-hidden="true">⌘</span>
</button>
@@ -384,7 +384,7 @@ var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
color: var(--nf-muted);
cursor: default;
}
`]};customElements.get("nf-entity-picker")||customElements.define("nf-entity-picker",ua);var sn=t=>t.target.value,ha=t=>Number.parseFloat(t.replace(",",".")),ie=t=>Math.round(t*1e3)/1e3,fu=t=>t.wide?"nf-field nf-wide":"nf-field";function E(t,e,n,r,o=.01,i){return m`<label class="nf-field"
`]};customElements.get("nf-entity-picker")||customElements.define("nf-entity-picker",ua);var an=t=>t.target.value,ha=t=>Number.parseFloat(t.replace(",",".")),ie=t=>Math.round(t*1e3)/1e3,fu=t=>t.wide?"nf-field nf-wide":"nf-field";function E(t,e,n,r,o=.01,i){return m`<label class="nf-field"
>${e}
<input
type="number"
@@ -393,14 +393,14 @@ var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
min=${i??_}
.value=${String(ie(n))}
?disabled=${!t.admin}
@change=${s=>{let l=ha(sn(s));Number.isFinite(l)&&r(l)}}
@change=${s=>{let l=ha(an(s));Number.isFinite(l)&&r(l)}}
/>
</label>`}function Z(t,e,n,r,o={}){return m`<label class=${fu(o)} title=${o.title??_}
>${e}
<input type="text" .value=${n} placeholder=${o.placeholder??_} maxlength=${o.maxlength??_} ?disabled=${!t.admin} @change=${i=>r(sn(i).trim())} />
<input type="text" .value=${n} placeholder=${o.placeholder??_} maxlength=${o.maxlength??_} ?disabled=${!t.admin} @change=${i=>r(an(i).trim())} />
</label>`}function O(t,e,n,r,o,i={}){return m`<label class=${fu(i)} title=${i.title??_}
>${e}
<select ?disabled=${!t.admin} @change=${s=>o(sn(s))}>
<select ?disabled=${!t.admin} @change=${s=>o(an(s))}>
${r.map(([s,l])=>m`<option value=${s} ?selected=${s===n}>${l}</option>`)}
</select>
</label>`}function H(t,e,n,r,o={}){return m`<label class="nf-check ${o.wide===!1?"":"nf-wide"}" title=${o.title??_}
@@ -423,26 +423,26 @@ var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
?disabled=${!t.admin}
@change=${c=>{c.stopPropagation(),i(c.detail.value==="__auto"?null:c.detail.value)}}
></nf-entity-picker>
</label>`}function Cn(t,e,n){return n?(n.startsWith("mdi:")?n:`mdi:${n}`).replace(/[^a-z0-9:-]/gi,""):t.hass?id(t.hass,e):null}function Ht(t,e,n){let r=e?(e.startsWith("mdi:")?e:`mdi:${e}`).replace(/[^a-z0-9:-]/gi,""):"";return m`<label class="nf-field nf-wide" title=${t.t("marker_icon_hint")}
</label>`}function Nn(t,e,n){return n?(n.startsWith("mdi:")?n:`mdi:${n}`).replace(/[^a-z0-9:-]/gi,""):t.hass?id(t.hass,e):null}function Lt(t,e,n){let r=e?(e.startsWith("mdi:")?e:`mdi:${e}`).replace(/[^a-z0-9:-]/gi,""):"";return m`<label class="nf-field nf-wide" title=${t.t("marker_icon_hint")}
>${t.t("marker_icon")}
<span class="nf-icon-row">
<input type="text" placeholder="mdi:thermometer" .value=${e??""} ?disabled=${!t.admin} @change=${o=>n(sn(o).trim().replace(/^mdi:/,"")||null)} />
<input type="text" placeholder="mdi:thermometer" .value=${e??""} ?disabled=${!t.admin} @change=${o=>n(an(o).trim().replace(/^mdi:/,"")||null)} />
${r?ru(`<ha-icon icon="${r}"></ha-icon>`):_}
</span>
</label>`}function Nn(t,e,n){return m`<label class="nf-field nf-wide" title=${t.t("marker_show_hint")}
</label>`}function Bn(t,e,n){return m`<label class="nf-field nf-wide" title=${t.t("marker_show_hint")}
>${t.t("marker_show")}
<select ?disabled=${!t.admin} @change=${r=>n(sn(r)||null)}>
<select ?disabled=${!t.admin} @change=${r=>n(an(r)||null)}>
<option value="" ?selected=${!e}>${t.t("marker_show_auto")}</option>
${Tc.map(r=>m`<option value=${r} ?selected=${r===e}>${t.t(`marker_show_${r}`)}</option>`)}
</select>
</label>`}function Bn(t,e,n){let r=e??{},o=i=>s=>{let l={...r,[i]:Math.round(Math.max(-5,Math.min(5,s))*100)/100};n(l.x||l.z||l.y?l:null)};return m`<details class="nf-wide nf-pin-shift" ?open=${!!e}>
</label>`}function Wn(t,e,n){let r=e??{},o=i=>s=>{let l={...r,[i]:Math.round(Math.max(-5,Math.min(5,s))*100)/100};n(l.x||l.z||l.y?l:null)};return m`<details class="nf-wide nf-pin-shift" ?open=${!!e}>
<summary>${t.t("pin_shift")}</summary>
<div class="nf-form">
${E(t,"\u2194 x",r.x??0,o("x"),.05)} ${E(t,"\u2195 z",r.z??0,o("z"),.05)} ${E(t,t.t("pin_shift_up"),r.y??0,o("y"),.05)}
${e?m`<button class="nf-btn nf-field-btn" ?disabled=${!t.admin} @click=${()=>n(null)}>${t.t("height_auto")}</button>`:_}
<p class="nf-sub nf-wide">${t.t("pin_shift_hint")}</p>
</div>
</details>`}var Y=(...t)=>m`<div class="nf-actions">${t}</div>`,M=(t,e="")=>m`<p class="nf-sub ${e}">${t}</p>`;function an(t,e,n,r={}){let o=r.lowest??10;return m`<label class="nf-field" title=${t.t(r.hint??"glow_scale_hint")}
</details>`}var Y=(...t)=>m`<div class="nf-actions">${t}</div>`,M=(t,e="")=>m`<p class="nf-sub ${e}">${t}</p>`;function ln(t,e,n,r={}){let o=r.lowest??10;return m`<label class="nf-field" title=${t.t(r.hint??"glow_scale_hint")}
>${t.t(r.label??"glow_scale")}
<input
type="number"
@@ -451,9 +451,9 @@ var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
step="5"
.value=${String(Math.round((e??1)*100))}
?disabled=${!t.admin}
@change=${i=>{let s=Number(sn(i)),l=Math.min(150,Math.max(o,sn(i).trim()===""||Number.isNaN(s)?100:s))/100;n(Math.abs(l-1)<.001?null:l)}}
@change=${i=>{let s=Number(an(i)),l=Math.min(150,Math.max(o,an(i).trim()===""||Number.isNaN(s)?100:s))/100;n(Math.abs(l-1)<.001?null:l)}}
/>
</label>`}function mu(t,e,n){let r=t.find(a=>a.person===e),o="sensor"in n?n.sensor&&n.sensor!=="none"?n.sensor:null:r?.sensor??null,i="room"in n?n.room||null:r?.room??null,s=t.filter(a=>a.person!==e);if(!o&&!i)return s;let l=i?{person:e,sensor:o,room:i}:{person:e,sensor:o};return r?t.map(a=>a.person===e?l:a):[...s,l]}function gu(t,e){let n=e.slice(e.indexOf(".")+1),r=o=>o.id.includes(n)&&/(area|room|raum|bermuda|espresense)/.test(o.id);return[...t.filter(r),...t.filter(o=>!r(o))]}function _u(t){let e=t.target?`, target: { x: ${t.target.x}, y: ${t.target.y}, z: ${t.target.z} }`:"";return`start_view: { theta: ${t.theta}, phi: ${t.phi}, radius: ${t.radius}${e} }`}function bu(t){let e=t.trim();if(!e)return{ok:!0,value:null};try{let n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}function li(t,e,n){let r=[...t],[o]=r.splice(e,1);return r.splice(Math.max(0,Math.min(r.length,e+n)),0,o),r}var Lt=(t,e)=>t.filter((n,r)=>r!==e),jr=(t,e,n)=>t.map((r,o)=>o===e?{...r,...n}:r),ht=t=>t.length>0?t:void 0;var Tb=["scene","script","automation","button","input_button","switch","input_boolean","light","fan","cover","lock"],zb=40,Pb=20,Ib=30,Db=["music","url","playlist","SPOTIFY","AMAZON_MUSIC","TUNEIN","APPLE_MUSIC"],pa={navigate:"/lovelace/rollos",more_info:"cover.wohnzimmer",service:"script.turn_on",fire_dom_event:""},Ur=(t,e,n,r=!1)=>m`<button class="nf-pin" title=${t} ?disabled=${r} @click=${n}>${e}</button>`;function Ob(t){let e=t.doc.settings.favorites??[],n=l=>t.change(a=>a.settings.favorites=ht(l)),r=t.doc.floors,o=t.doc.settings.favorite_floors??{},i=L(t.hass,l=>Tb.includes(l.split(".")[0])&&!e.includes(l)),s=(l,a)=>m`<div class="nf-row nf-dev-row">
</label>`}function mu(t,e,n){let r=t.find(a=>a.person===e),o="sensor"in n?n.sensor&&n.sensor!=="none"?n.sensor:null:r?.sensor??null,i="room"in n?n.room||null:r?.room??null,s=t.filter(a=>a.person!==e);if(!o&&!i)return s;let l=i?{person:e,sensor:o,room:i}:{person:e,sensor:o};return r?t.map(a=>a.person===e?l:a):[...s,l]}function gu(t,e){let n=e.slice(e.indexOf(".")+1),r=o=>o.id.includes(n)&&/(area|room|raum|bermuda|espresense)/.test(o.id);return[...t.filter(r),...t.filter(o=>!r(o))]}function _u(t){let e=t.target?`, target: { x: ${t.target.x}, y: ${t.target.y}, z: ${t.target.z} }`:"";return`start_view: { theta: ${t.theta}, phi: ${t.phi}, radius: ${t.radius}${e} }`}function bu(t){let e=t.trim();if(!e)return{ok:!0,value:null};try{let n=JSON.parse(e);return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}function li(t,e,n){let r=[...t],[o]=r.splice(e,1);return r.splice(Math.max(0,Math.min(r.length,e+n)),0,o),r}var Ct=(t,e)=>t.filter((n,r)=>r!==e),jr=(t,e,n)=>t.map((r,o)=>o===e?{...r,...n}:r),pt=t=>t.length>0?t:void 0;var Tb=["scene","script","automation","button","input_button","switch","input_boolean","light","fan","cover","lock"],zb=40,Pb=20,Ib=30,Db=["music","url","playlist","SPOTIFY","AMAZON_MUSIC","TUNEIN","APPLE_MUSIC"],pa={navigate:"/lovelace/rollos",more_info:"cover.wohnzimmer",service:"script.turn_on",fire_dom_event:""},Ur=(t,e,n,r=!1)=>m`<button class="nf-pin" title=${t} ?disabled=${r} @click=${n}>${e}</button>`;function Ob(t){let e=t.doc.settings.favorites??[],n=l=>t.change(a=>a.settings.favorites=pt(l)),r=t.doc.floors,o=t.doc.settings.favorite_floors??{},i=L(t.hass,l=>Tb.includes(l.split(".")[0])&&!e.includes(l)),s=(l,a)=>m`<div class="nf-row nf-dev-row">
<span class="nf-dev-name"><span>${W(t.hass,l)}</span></span>
${r.length>1?m`<select title=${t.t("favorite_floor")} .value=${o[l]??""} @change=${c=>{let d=c.target.value,u={...o};d?u[l]=d:delete u[l],t.change(p=>p.settings.favorite_floors=Object.keys(u).length?u:void 0)}}>
<option value="">${t.t("favorite_all_floors")}</option>
@@ -461,34 +461,34 @@ var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
</select>`:_}
${Ur(t.t("move_up"),"\u2191",()=>n(li(e,a,-1)),a===0)}
${Ur(t.t("move_down"),"\u2193",()=>n(li(e,a,1)),a===e.length-1)}
${Ur(t.t("delete"),"\u2715",()=>n(Lt(e,a)))}
${Ur(t.t("delete"),"\u2715",()=>n(Ct(e,a)))}
</div>`;return m`<summary>${t.t("favorites")}${e.length>0?m` <span class="nf-lib-count">${e.length}</span>`:_}</summary>
${M(t.t("favorites_hint"))} ${e.map(s)}
${e.length<zb?m`<div class="nf-form">${P(t,t.t("favorites_add"),null,void 0,i,l=>l&&l!=="none"&&!e.includes(l)&&n([...e,l]))}</div>`:_}`}function Hb(t,e){let n=t.doc.settings.outside_hidden??[],r=s=>t.change(l=>l.settings.outside_hidden=ht(s)),o=new Set(t.hass?vd(t.hass,t.doc.floors):[]),i=L(t.hass,s=>!n.includes(s)&&o.has(s));return m`${e?Lb(t,e):_}
${e.length<zb?m`<div class="nf-form">${P(t,t.t("favorites_add"),null,void 0,i,l=>l&&l!=="none"&&!e.includes(l)&&n([...e,l]))}</div>`:_}`}function Hb(t,e){let n=t.doc.settings.outside_hidden??[],r=s=>t.change(l=>l.settings.outside_hidden=pt(s)),o=new Set(t.hass?vd(t.hass,t.doc.floors):[]),i=L(t.hass,s=>!n.includes(s)&&o.has(s));return m`${e?Lb(t,e):_}
<h4>${t.t("outside_hidden")}${n.length>0?m` <span class="nf-lib-count">${n.length}</span>`:_}</h4>
${M(t.t("outside_hidden_hint"))}
${n.map((s,l)=>m`<div class="nf-row nf-dev-row"><span class="nf-dev-name"><span>${W(t.hass,s)}</span></span>${Ur(t.t("delete"),"\u2715",()=>r(Lt(n,l)))}</div>`)}
${n.map((s,l)=>m`<div class="nf-row nf-dev-row"><span class="nf-dev-name"><span>${W(t.hass,s)}</span></span>${Ur(t.t("delete"),"\u2715",()=>r(Ct(n,l)))}</div>`)}
<div class="nf-form">${P(t,t.t("outside_hidden_add"),null,void 0,i,s=>s&&s!=="none"&&!n.includes(s)&&r([...n,s]))}</div>`}function Lb(t,e){let n=t.doc.settings.outside_view??null,r=()=>{let o=e();o&&t.change(i=>i.settings.outside_view=o)};return m`${M(t.t("outside_view_hint"))}
${Y(m`<button class="nf-btn" @click=${r}>${t.t("outside_view_set")}</button>`,n?m`<button class="nf-btn" @click=${()=>t.change(o=>o.settings.outside_view=null)}>${t.t("outside_view_reset")}</button>`:_)}`}function Cb(t){let e=t.doc.settings.own_alerts??[],n=s=>t.change(l=>l.settings.own_alerts=ht(s)),r=(s,l)=>n(jr(e,s,l)),o=[["",t.t("own_alert_house")],...t.doc.floors.flatMap(s=>s.rooms.map(l=>[l.id,`${l.name} \xB7 ${s.name}`]))],i=(s,l)=>m`<div class="nf-form nf-own-button">
${Y(m`<button class="nf-btn" @click=${r}>${t.t("outside_view_set")}</button>`,n?m`<button class="nf-btn" @click=${()=>t.change(o=>o.settings.outside_view=null)}>${t.t("outside_view_reset")}</button>`:_)}`}function Cb(t){let e=t.doc.settings.own_alerts??[],n=s=>t.change(l=>l.settings.own_alerts=pt(s)),r=(s,l)=>n(jr(e,s,l)),o=[["",t.t("own_alert_house")],...t.doc.floors.flatMap(s=>s.rooms.map(l=>[l.id,`${l.name} \xB7 ${s.name}`]))],i=(s,l)=>m`<div class="nf-form nf-own-button">
${P(t,t.t("own_alert_entity"),s.entity||null,void 0,L(t.hass,()=>!0),a=>r(l,{entity:a&&a!=="none"?a:""}))}
${Z(t,t.t("own_alert_state"),s.state??"",a=>r(l,{state:a||null}),{placeholder:t.hass?.states[s.entity]?.state??"on \xB7 <20 \xB7 >80"})}
${Z(t,t.t("own_alert_text"),s.text,a=>r(l,{text:a||t.t("own_alert_new")}),{wide:!0,maxlength:120})}
${O(t,t.t("room"),s.room_id??"",o,a=>r(l,{room_id:a||null}),{wide:!0})}
${Ue(t,t.t("own_alert_color"),s.color??null,"#ffb547",a=>r(l,{color:a}))}
${O(t,t.t("own_alert_tap"),s.tap??"",[["",t.t("own_alert_tap_info")],["toggle",t.t("own_alert_tap_toggle")],["room",t.t("own_alert_tap_room")]],a=>r(l,{tap:a||null}))}
<div class="nf-actions nf-wide"><button class="nf-btn nf-danger" @click=${()=>n(Lt(e,l))}>${t.t("delete")}</button></div>
<div class="nf-actions nf-wide"><button class="nf-btn nf-danger" @click=${()=>n(Ct(e,l))}>${t.t("delete")}</button></div>
</div>`;return m`<h4>⚠ ${t.t("own_alerts")}</h4>
${M(t.t("own_alerts_hint"))} ${e.map(i)}
${e.length<40?Y(m`<button class="nf-btn" @click=${()=>n([...e,{id:D("alert"),entity:"",state:null,text:t.t("own_alert_new")}])}>+ ${t.t("own_alert_add")}</button>`):_}`}function Nb(t){let e=t.doc.settings.circuits??[],n=l=>t.change(a=>a.settings.circuits=ht(l)),r=(l,a)=>n(jr(e,l,a)),o=t.doc.floors.flatMap(l=>l.rooms.map(a=>({id:a.id,label:t.doc.floors.length>1?`${a.name} \xB7 ${l.name}`:a.name}))),i=l=>o.find(a=>a.id===l)?.label??l,s=(l,a)=>m`<div class="nf-form nf-own-button">
${e.length<40?Y(m`<button class="nf-btn" @click=${()=>n([...e,{id:D("alert"),entity:"",state:null,text:t.t("own_alert_new")}])}>+ ${t.t("own_alert_add")}</button>`):_}`}function Nb(t){let e=t.doc.settings.circuits??[],n=l=>t.change(a=>a.settings.circuits=pt(l)),r=(l,a)=>n(jr(e,l,a)),o=t.doc.floors.flatMap(l=>l.rooms.map(a=>({id:a.id,label:t.doc.floors.length>1?`${a.name} \xB7 ${l.name}`:a.name}))),i=l=>o.find(a=>a.id===l)?.label??l,s=(l,a)=>m`<div class="nf-form nf-own-button">
${Z(t,t.t("circuit_name"),l.name,c=>r(a,{name:c||t.t("circuit_new")}),{wide:!0,maxlength:80})}
<div class="nf-wide">${l.rooms.map(c=>m`<span class="nf-chip">${i(c)} <button class="nf-btn nf-field-btn" title=${t.t("delete")} @click=${()=>r(a,{rooms:l.rooms.filter(d=>d!==c)})}>✕</button></span>`)}</div>
${O(t,t.t("circuit_add_room"),"",[["","\u2013"],...o.filter(c=>!l.rooms.includes(c.id)).map(c=>[c.id,c.label])],c=>c&&r(a,{rooms:[...l.rooms,c]}),{wide:!0})}
<div class="nf-actions nf-wide"><button class="nf-btn nf-danger" @click=${()=>n(Lt(e,a))}>${t.t("delete")}</button></div>
<div class="nf-actions nf-wide"><button class="nf-btn nf-danger" @click=${()=>n(Ct(e,a))}>${t.t("delete")}</button></div>
</div>`;return m`<h4>🔌 ${t.t("circuits")}</h4>
${M(t.t("circuits_hint"))} ${e.map(s)}
${e.length<120?Y(m`<button class="nf-btn" @click=${()=>n([...e,{id:D("circuit"),name:t.t("circuit_new"),rooms:[]}])}>+ ${t.t("circuit_add")}</button>`):_}`}function Bb(t){let e=t.doc.settings.calendars??[],n=l=>t.change(a=>a.settings.calendars=ht(l)),r=L(t.hass,l=>l.startsWith("calendar.")&&!e.includes(l)),o=(l,a)=>m`<div class="nf-row nf-dev-row">
${e.length<120?Y(m`<button class="nf-btn" @click=${()=>n([...e,{id:D("circuit"),name:t.t("circuit_new"),rooms:[]}])}>+ ${t.t("circuit_add")}</button>`):_}`}function Bb(t){let e=t.doc.settings.calendars??[],n=l=>t.change(a=>a.settings.calendars=pt(l)),r=L(t.hass,l=>l.startsWith("calendar.")&&!e.includes(l)),o=(l,a)=>m`<div class="nf-row nf-dev-row">
<span class="nf-dev-name"><span>${W(t.hass,l)}</span></span>
${Ur(t.t("delete"),"\u2715",()=>n(Lt(e,a)))}
${Ur(t.t("delete"),"\u2715",()=>n(Ct(e,a)))}
</div>`,i=t.t,s=t.doc.settings.today_days??1;return m`<h4>📅 ${i("today_calendars")}</h4>
${M(i("today_calendars_hint"))} ${e.map(o)}
${e.length<12?m`<div class="nf-form">${P(t,i("favorites_add"),null,void 0,r,l=>l&&l!=="none"&&!e.includes(l)&&n([...e,l]))}</div>`:_}
@@ -500,13 +500,13 @@ var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
<div class="nf-form">
${O(t,e("forecast_days"),n?String(n.days):"0",[0,3,5,7].map(o=>[String(o),o?e("today_days_n",{n:o}):e("forecast_off")]),o=>r(Number(o)>0?{days:Number(o),corner:n?.corner??"top_right"}:null))}
${n?O(t,e("forecast_corner"),n.corner,[["top_right",e("clock_top_right")],["top_left",e("clock_top_left")]],o=>r({...n,corner:o==="top_left"?"top_left":"top_right"})):_}
</div>`}function Vb(t){let e=t.doc.settings.media_presets??[],n=s=>t.change(l=>l.settings.media_presets=ht(s)),r=(s,l)=>n(jr(e,s,l)),o=[...new Set(t.doc.floors.flatMap(s=>[...s.placements.map(l=>l.entity_id),...s.furniture.map(l=>l.entity??"")]).filter(s=>s.startsWith("media_player.")))],i=(s,l)=>m`<div class="nf-form nf-own-button">
</div>`}function Vb(t){let e=t.doc.settings.media_presets??[],n=s=>t.change(l=>l.settings.media_presets=pt(s)),r=(s,l)=>n(jr(e,s,l)),o=[...new Set(t.doc.floors.flatMap(s=>[...s.placements.map(l=>l.entity_id),...s.furniture.map(l=>l.entity??"")]).filter(s=>s.startsWith("media_player.")))],i=(s,l)=>m`<div class="nf-form nf-own-button">
${Z(t,t.t("own_button_label"),s.label,a=>r(l,{label:a||"Radio"}),{maxlength:60})}
${Z(t,t.t("preset_type"),s.type,a=>r(l,{type:a||"music"}),{title:t.t("preset_type_hint")})}
${Z(t,t.t("preset_content"),s.content,a=>r(l,{content:a}),{wide:!0,title:t.t("preset_content_hint"),placeholder:"https://\u2026 \xB7 spotify:playlist:\u2026 \xB7 Rock Antenne"})}
${o.length>1?m`<div class="nf-sub nf-wide">${t.t("preset_speakers")}</div>
${o.map(a=>H(t,W(t.hass,a),!!s.speakers?.includes(a),c=>r(l,{speakers:ht(c?[...s.speakers??[],a]:(s.speakers??[]).filter(d=>d!==a))}),{wide:!1}))}`:_}
<div class="nf-actions nf-wide"><button class="nf-btn nf-danger" @click=${()=>n(Lt(e,l))}>${t.t("delete")}</button></div>
${o.map(a=>H(t,W(t.hass,a),!!s.speakers?.includes(a),c=>r(l,{speakers:pt(c?[...s.speakers??[],a]:(s.speakers??[]).filter(d=>d!==a))}),{wide:!1}))}`:_}
<div class="nf-actions nf-wide"><button class="nf-btn nf-danger" @click=${()=>n(Ct(e,l))}>${t.t("delete")}</button></div>
</div>`;return m`<h4>${t.t("presets")}</h4>
${M(t.t("presets_hint"))}
<datalist id="nf-preset-types">${Db.map(s=>m`<option value=${s}></option>`)}</datalist>
@@ -514,19 +514,19 @@ var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
${e.length<Ib?Y(m`<button class="nf-btn" @click=${()=>n([...e,{id:D("preset"),label:"Radio",type:"music",content:""}])}>+ ${t.t("preset_add")}</button>`):_}`}function fa(t,e,n){let r=e.action==="fire_dom_event"?'{"browser_mod": {"service": "browser_mod.popup", "data": {"title": "Rollos", "content": {"type": "custom:my-cover-card"}}}}':'{"entity_id": "script.party"}',o=i=>{let s=i.target;s.setCustomValidity("");let l=bu(s.value);if(l.ok)return n(l.value);s.setCustomValidity(t.t("own_data_bad")),s.reportValidity()};return m`<label class="nf-field nf-wide" title=${t.t("own_data_hint")}
>${t.t("own_data")}
<textarea rows="4" spellcheck="false" placeholder=${r} .value=${e.data?JSON.stringify(e.data,null,1):""} @change=${o}></textarea>
</label>`}function Kb(t){let e=t.doc.settings.buttons??[],n=s=>t.change(l=>l.settings.buttons=ht(s)),r=(s,l)=>n(jr(e,s,l)),o=zo.map(s=>[s,t.t(`own_action_${s}`)]),i=(s,l)=>m`<div class="nf-form nf-own-button">
</label>`}function Kb(t){let e=t.doc.settings.buttons??[],n=s=>t.change(l=>l.settings.buttons=pt(s)),r=(s,l)=>n(jr(e,s,l)),o=zo.map(s=>[s,t.t(`own_action_${s}`)]),i=(s,l)=>m`<div class="nf-form nf-own-button">
${Z(t,t.t("own_button_label"),s.label,a=>r(l,{label:a||t.t("own_button_new")}),{maxlength:60})}
${O(t,t.t("own_button_action"),s.action,o,a=>r(l,{action:a}))} ${Ht(t,s.icon??null,a=>r(l,{icon:a}))}
${O(t,t.t("own_button_action"),s.action,o,a=>r(l,{action:a}))} ${Lt(t,s.icon??null,a=>r(l,{icon:a}))}
${s.action!=="fire_dom_event"?Z(t,t.t(`own_target_${s.action}`),s.target??"",a=>r(l,{target:a||null}),{wide:!0,placeholder:pa[s.action]}):_}
${s.action==="service"||s.action==="fire_dom_event"?fa(t,s,a=>r(l,{data:a})):_}
${P(t,t.t("own_button_state"),s.state_entity??null,void 0,L(t.hass,a=>/^(switch|light|input_boolean|binary_sensor|fan|cover|media_player|climate|lock|person|device_tracker)\./.test(a)),a=>r(l,{state_entity:a&&a!=="none"?a:null}))}
<div class="nf-actions nf-wide">
<button class="nf-btn" ?disabled=${l===0} @click=${()=>n(li(e,l,-1))}>↑</button>
<button class="nf-btn nf-danger" @click=${()=>n(Lt(e,l))}>${t.t("delete")}</button>
<button class="nf-btn nf-danger" @click=${()=>n(Ct(e,l))}>${t.t("delete")}</button>
</div>
</div>`;return m`<h4>${t.t("own_buttons")}</h4>
${M(t.t("own_buttons_hint"))} ${e.map(i)}
${e.length<Pb?Y(m`<button class="nf-btn" @click=${()=>n([...e,{id:D("btn"),label:t.t("own_button_new"),action:"navigate",target:null}])}>+ ${t.t("own_button_add")}</button>`):_}`}function Gb(t){let e=t.doc.settings.room_facts_off??[],n=["sun","comfort","air","circuits"].map(r=>H(t,t.t(`room_fact_${r}`),!e.includes(r),o=>t.change(i=>i.settings.room_facts_off=ht(o?e.filter(s=>s!==r):[...e,r]))));return m`<h4>${t.t("room_facts")}</h4><div class="nf-form">${n}</div>`}function yu(t){return m`<details class="nf-section">${Ob(t)} ${Kb(t)} ${Cb(t)} ${Nb(t)} ${Bb(t)} ${Vb(t)} ${Gb(t)}</details>`}function wu(t,e){return m`<details class="nf-section">
${e.length<Pb?Y(m`<button class="nf-btn" @click=${()=>n([...e,{id:D("btn"),label:t.t("own_button_new"),action:"navigate",target:null}])}>+ ${t.t("own_button_add")}</button>`):_}`}function Gb(t){let e=t.doc.settings.room_facts_off??[],n=["sun","comfort","air","circuits"].map(r=>H(t,t.t(`room_fact_${r}`),!e.includes(r),o=>t.change(i=>i.settings.room_facts_off=pt(o?e.filter(s=>s!==r):[...e,r]))));return m`<h4>${t.t("room_facts")}</h4><div class="nf-form">${n}</div>`}function yu(t){return m`<details class="nf-section">${Ob(t)} ${Kb(t)} ${Cb(t)} ${Nb(t)} ${Bb(t)} ${Vb(t)} ${Gb(t)}</details>`}function wu(t,e){return m`<details class="nf-section">
<summary>🌳 ${t.t("outside_area")}</summary>
${Hb(t,e)}
</details>`}function vu(t,e){let n=t.doc.settings.start_view??null,r=()=>{let o=e();o&&t.change(i=>i.settings.start_view=o)};return m`<details class="nf-section">
@@ -550,7 +550,7 @@ var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
<summary>${t.t("ble")}</summary>
${M(t.t("ble_hint"))}
<nf-ble-locate .host=${t} .doc=${e}></nf-ble-locate>
</details>`}var Zr=(t,e)=>{let n=t._$AN;if(n===void 0)return!1;for(let r of n)r._$AO?.(e,!1),Zr(r,e);return!0},ci=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while(n?.size===0)},$u=t=>{for(let e;e=t._$AM;t=e){let n=e._$AN;if(n===void 0)e._$AN=n=new Set;else if(n.has(t))break;n.add(t),Zb(e)}};function jb(t){this._$AN!==void 0?(ci(this),this._$AM=t,$u(this)):this._$AM=t}function Ub(t,e=!1,n=0){let r=this._$AH,o=this._$AN;if(o!==void 0&&o.size!==0)if(e)if(Array.isArray(r))for(let i=n;i<r.length;i++)Zr(r[i],!1),ci(r[i]);else r!=null&&(Zr(r,!1),ci(r));else Zr(this,t)}var Zb=t=>{t.type==Hn.CHILD&&(t._$AP??=Ub,t._$AQ??=jb)},di=class extends Dt{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),$u(this),this.isConnected=e._$AU}_$AO(e,n=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),n&&(Zr(this,e),ci(this))}setValue(e){if(su(this._$Ct))this._$Ct._$AI(e,this);else{let n=[...this._$Ct._$AH];n[this._$Ci]=e,this._$Ct._$AI(n,this,0)}}disconnected(){}reconnected(){}};var ma=new WeakMap,Su=on(class extends di{render(t){return _}update(t,[e]){let n=e!==this.G;return n&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=e,this.ht=t.options?.host,this.rt(this.ct=t.element)),_}rt(t){if(this.G!==void 0)if(this.isConnected||(t=void 0),typeof this.G=="function"){let e=this.ht??globalThis,n=ma.get(e);n===void 0&&(n=new WeakMap,ma.set(e,n)),n.get(this.G)!==void 0&&this.G.call(this.ht,void 0),n.set(this.G,t),t!==void 0&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){return typeof this.G=="function"?ma.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Mu=t=>t.trim().toLowerCase().replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/ß/g,"ss").replace(/[^a-z0-9_-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,40);function Ru(t){let e=t.t,n=t.doc.settings.card_templates??{},r=Object.keys(n),o=l=>t.change(a=>{a.settings.card_templates=Object.keys(l).length?l:void 0});t.loadCardEditor?.();let i=l=>{t.hass?.callService("nextfloor","reload_screens",l?{template:l}:{})},s=l=>{let a=Mu(l.value);!a||a in n||r.length>=20||(l.value="",o({...n,[a]:{}}))};return m`<details class="nf-section">
</details>`}var Zr=(t,e)=>{let n=t._$AN;if(n===void 0)return!1;for(let r of n)r._$AO?.(e,!1),Zr(r,e);return!0},ci=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while(n?.size===0)},$u=t=>{for(let e;e=t._$AM;t=e){let n=e._$AN;if(n===void 0)e._$AN=n=new Set;else if(n.has(t))break;n.add(t),Zb(e)}};function jb(t){this._$AN!==void 0?(ci(this),this._$AM=t,$u(this)):this._$AM=t}function Ub(t,e=!1,n=0){let r=this._$AH,o=this._$AN;if(o!==void 0&&o.size!==0)if(e)if(Array.isArray(r))for(let i=n;i<r.length;i++)Zr(r[i],!1),ci(r[i]);else r!=null&&(Zr(r,!1),ci(r));else Zr(this,t)}var Zb=t=>{t.type==Ln.CHILD&&(t._$AP??=Ub,t._$AQ??=jb)},di=class extends Ot{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),$u(this),this.isConnected=e._$AU}_$AO(e,n=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),n&&(Zr(this,e),ci(this))}setValue(e){if(su(this._$Ct))this._$Ct._$AI(e,this);else{let n=[...this._$Ct._$AH];n[this._$Ci]=e,this._$Ct._$AI(n,this,0)}}disconnected(){}reconnected(){}};var ma=new WeakMap,Su=sn(class extends di{render(t){return _}update(t,[e]){let n=e!==this.G;return n&&this.rt(void 0),(n||this.lt!==this.ct)&&(this.G=e,this.ht=t.options?.host,this.rt(this.ct=t.element)),_}rt(t){if(this.G!==void 0)if(this.isConnected||(t=void 0),typeof this.G=="function"){let e=this.ht??globalThis,n=ma.get(e);n===void 0&&(n=new WeakMap,ma.set(e,n)),n.get(this.G)!==void 0&&this.G.call(this.ht,void 0),n.set(this.G,t),t!==void 0&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){return typeof this.G=="function"?ma.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var Mu=t=>t.trim().toLowerCase().replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/ß/g,"ss").replace(/[^a-z0-9_-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,40);function Ru(t){let e=t.t,n=t.doc.settings.card_templates??{},r=Object.keys(n),o=l=>t.change(a=>{a.settings.card_templates=Object.keys(l).length?l:void 0});t.loadCardEditor?.();let i=l=>{t.hass?.callService("nextfloor","reload_screens",l?{template:l}:{})},s=l=>{let a=Mu(l.value);!a||a in n||r.length>=20||(l.value="",o({...n,[a]:{}}))};return m`<details class="nf-section">
<summary>${e("card_templates")}${r.length?m` <span class="nf-lib-count">${r.length}</span>`:_}</summary>
${M(e("card_templates_hint"))}
${r.map(l=>m`<details class="nf-section">
@@ -573,7 +573,7 @@ var S={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
<button class="nf-btn" @click=${l=>s(l.target.closest("details")?.querySelector("input[type=text]")??document.createElement("input"))}>${e("template_add")}</button>
<button class="nf-btn" @click=${()=>i()}>${e("template_reload_all")}</button>
</div>`:_}
</details>`}var ui=.05,qb=(t,e)=>t.length===e.length&&t.every((n,r)=>Math.abs(n[0]-e[r][0])<.001&&Math.abs(n[1]-e[r][1])<.001),ln=t=>new Map(t.map(e=>[e.id,e]));function Yb(t,e,n,r){let o=e.name,[i,s]=[ln(t.rooms),ln(e.rooms)];for(let h of e.rooms){let f=i.get(h.id);f?(f.name!==h.name&&n.push({kind:"room_renamed",floor:o,name:h.name,detail:f.name}),qb(f.points,h.points)||n.push({kind:"room_reshaped",floor:o,name:h.name,detail:Math.round((we(h.points)-we(f.points))*10)/10})):n.push({kind:"room_added",floor:o,name:h.name})}for(let h of t.rooms)s.has(h.id)||n.push({kind:"room_removed",floor:o,name:h.name});let[l,a]=[ln(t.openings),ln(e.openings)];for(let h of e.openings)l.has(h.id)||n.push({kind:"opening_added",floor:o,name:h.type,detail:r(h.room_id)});for(let h of t.openings)a.has(h.id)||n.push({kind:"opening_removed",floor:o,name:h.type,detail:r(h.room_id)});let[c,d]=[ln(t.furniture),ln(e.furniture)];for(let h of e.furniture){let f=c.get(h.id);f?(Math.hypot(h.x-f.x,h.z-f.z)>ui||Math.abs(h.rotation-f.rotation)>1||Math.abs(h.w-f.w)>ui||Math.abs(h.d-f.d)>ui)&&n.push({kind:"furniture_moved",floor:o,name:h.name||h.type}):n.push({kind:"furniture_added",floor:o,name:h.name||h.type})}for(let h of t.furniture)d.has(h.id)||n.push({kind:"furniture_removed",floor:o,name:h.name||h.type});let[u,p]=[new Map(t.placements.map(h=>[h.entity_id,h])),new Map(e.placements.map(h=>[h.entity_id,h]))];for(let h of e.placements){let f=u.get(h.entity_id);f?Math.hypot(h.x-f.x,h.z-f.z)>ui&&n.push({kind:"device_moved",floor:o,name:h.entity_id}):n.push({kind:"device_added",floor:o,name:h.entity_id})}for(let h of t.placements)p.has(h.entity_id)||n.push({kind:"device_removed",floor:o,name:h.entity_id})}function Eu(t,e){let n=[],r=ln(t.floors),o=new Map([...t.floors,...e.floors].flatMap(l=>l.rooms.map(a=>[a.id,a.name]))),i=l=>o.get(l)??"";for(let l of e.floors){let a=r.get(l.id);a?Yb(a,l,n,i):n.push({kind:"floor_added",floor:l.name,name:l.name})}let s=new Set(e.floors.map(l=>l.id));for(let l of t.floors)s.has(l.id)||n.push({kind:"floor_removed",floor:l.name,name:l.name});return n}var cn=(t,e)=>t.getUint16(e,!0),qr=(t,e)=>t.getUint32(e,!0);function Au(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=-1;for(let l=t.length-22;l>=Math.max(0,t.length-65557);l--)if(qr(e,l)===101010256){n=l;break}if(n<0)throw new Error("not_zip");let r=cn(e,n+10),o=qr(e,n+16),i=[],s=new TextDecoder;for(let l=0;l<r;l++){if(qr(e,o)!==33639248)throw new Error("not_zip");let a=cn(e,o+10),c=qr(e,o+20),d=cn(e,o+28),u=cn(e,o+30),p=cn(e,o+32),h=qr(e,o+42),f=s.decode(t.subarray(o+46,o+46+d)),g=h+30+cn(e,h+26)+cn(e,h+28);i.push({name:f,method:a,compressedSize:c,offset:g}),o+=46+d+u+p}return i}async function Fu(t,e){let n=t.subarray(e.offset,e.offset+e.compressedSize);if(e.method===0)return n;if(e.method!==8)throw new Error("zip_method");let r=new Blob([n.slice()]).stream().pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(r).arrayBuffer())}var Xb={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"},Qb=t=>t.replace(/&(#x?[0-9a-f]+|\w+);/gi,(e,n)=>n[0]==="#"?String.fromCodePoint(Number.parseInt(n.slice(n[1]==="x"?2:1),n[1]==="x"?16:10)):Xb[n]??e);function Jb(t){let e={};for(let n of t.matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))e[n[1]]=Qb(n[2]??n[3]);return e}function ey(t){let e=[],n=null;for(let r of t.matchAll(/<(\/?)(level|room|point|wall|doorOrWindow|pieceOfFurniture)\b([^>]*?)(\/?)>/g)){let[,o,i,s,l]=r;if(o){i==="room"&&(n=null);continue}let a=Jb(s);if(i==="point"){n&&n.points.push([Number(a.x)/100,Number(a.y)/100]);continue}let c={name:i,attrs:a,...i==="room"?{points:[]}:{}};e.push(c),i==="room"&&!l&&(n=c)}return e}var re=(t,e,n)=>Number.isFinite(Number(t[e]))&&t[e]!==void 0?Number(t[e]):n,Re=t=>Math.round(t*1e3)/1e3;function Tu(t,e,n){let[r,o]=[n[0]-e[0],n[1]-e[1]],i=Math.hypot(r,o)||1e-9,s=Math.max(0,Math.min(i,((t[0]-e[0])*r+(t[1]-e[1])*o)/i)),l=[e[0]+r*s/i,e[1]+o*s/i];return{dist:Math.hypot(t[0]-l[0],t[1]-l[1]),along:s,length:i}}function ty(t){let e=`${t.name??""} ${t.catalogId??""}`.toLowerCase();return/garage|sectional|rolltor/.test(e)?"garage":/door|tür|tuer|porte|puerta|deur|haustür/.test(e)&&!/window|fenster/.test(e)?"door":"window"}function ny(t,e){let n=t.length,r=t.map((o,i)=>{let s=t[(i+1)%n],[l,a]=[s[0]-o[0],s[1]-o[1]],c=Math.hypot(l,a)||1e-9,d=[l/c,a/c],u=[(o[0]+s[0])/2,(o[1]+s[1])/2],p=[0,0];for(let h of e){let[f,g]=[h.b[0]-h.a[0],h.b[1]-h.a[1]],y=Math.hypot(f,g)||1e-9;if(Math.abs((d[0]*g-d[1]*f)/y)>.05)continue;let b=(h.a[0]-u[0])*-d[1]+(h.a[1]-u[1])*d[0],v=((u[0]-h.a[0])*f+(u[1]-h.a[1])*g)/y;if(!(Math.abs(b)>h.thickness/2+.06||v<-.05||v>y+.05)){p=[-d[1]*b,d[0]*b];break}}return{p:[o[0]+p[0],o[1]+p[1]],dir:d}});return r.map((o,i)=>{let s=r[(i-1+n)%n],l=s.dir[0]*o.dir[1]-s.dir[1]*o.dir[0];if(Math.abs(l)<1e-6)return o.p;let a=((o.p[0]-s.p[0])*o.dir[1]-(o.p[1]-s.p[1])*o.dir[0])/l;return[s.p[0]+s.dir[0]*a,s.p[1]+s.dir[1]*a]})}function ry(t){let e=Ft(),n={floors:0,rooms:0,openings:0,walls:0,furniture:0}Line truncated
</details>`}var ui=.05,qb=(t,e)=>t.length===e.length&&t.every((n,r)=>Math.abs(n[0]-e[r][0])<.001&&Math.abs(n[1]-e[r][1])<.001),cn=t=>new Map(t.map(e=>[e.id,e]));function Yb(t,e,n,r){let o=e.name,[i,s]=[cn(t.rooms),cn(e.rooms)];for(let h of e.rooms){let f=i.get(h.id);f?(f.name!==h.name&&n.push({kind:"room_renamed",floor:o,name:h.name,detail:f.name}),qb(f.points,h.points)||n.push({kind:"room_reshaped",floor:o,name:h.name,detail:Math.round((we(h.points)-we(f.points))*10)/10})):n.push({kind:"room_added",floor:o,name:h.name})}for(let h of t.rooms)s.has(h.id)||n.push({kind:"room_removed",floor:o,name:h.name});let[l,a]=[cn(t.openings),cn(e.openings)];for(let h of e.openings)l.has(h.id)||n.push({kind:"opening_added",floor:o,name:h.type,detail:r(h.room_id)});for(let h of t.openings)a.has(h.id)||n.push({kind:"opening_removed",floor:o,name:h.type,detail:r(h.room_id)});let[c,d]=[cn(t.furniture),cn(e.furniture)];for(let h of e.furniture){let f=c.get(h.id);f?(Math.hypot(h.x-f.x,h.z-f.z)>ui||Math.abs(h.rotation-f.rotation)>1||Math.abs(h.w-f.w)>ui||Math.abs(h.d-f.d)>ui)&&n.push({kind:"furniture_moved",floor:o,name:h.name||h.type}):n.push({kind:"furniture_added",floor:o,name:h.name||h.type})}for(let h of t.furniture)d.has(h.id)||n.push({kind:"furniture_removed",floor:o,name:h.name||h.type});let[u,p]=[new Map(t.placements.map(h=>[h.entity_id,h])),new Map(e.placements.map(h=>[h.entity_id,h]))];for(let h of e.placements){let f=u.get(h.entity_id);f?Math.hypot(h.x-f.x,h.z-f.z)>ui&&n.push({kind:"device_moved",floor:o,name:h.entity_id}):n.push({kind:"device_added",floor:o,name:h.entity_id})}for(let h of t.placements)p.has(h.entity_id)||n.push({kind:"device_removed",floor:o,name:h.entity_id})}function Eu(t,e){let n=[],r=cn(t.floors),o=new Map([...t.floors,...e.floors].flatMap(l=>l.rooms.map(a=>[a.id,a.name]))),i=l=>o.get(l)??"";for(let l of e.floors){let a=r.get(l.id);a?Yb(a,l,n,i):n.push({kind:"floor_added",floor:l.name,name:l.name})}let s=new Set(e.floors.map(l=>l.id));for(let l of t.floors)s.has(l.id)||n.push({kind:"floor_removed",floor:l.name,name:l.name});return n}var dn=(t,e)=>t.getUint16(e,!0),qr=(t,e)=>t.getUint32(e,!0);function Au(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=-1;for(let l=t.length-22;l>=Math.max(0,t.length-65557);l--)if(qr(e,l)===101010256){n=l;break}if(n<0)throw new Error("not_zip");let r=dn(e,n+10),o=qr(e,n+16),i=[],s=new TextDecoder;for(let l=0;l<r;l++){if(qr(e,o)!==33639248)throw new Error("not_zip");let a=dn(e,o+10),c=qr(e,o+20),d=dn(e,o+28),u=dn(e,o+30),p=dn(e,o+32),h=qr(e,o+42),f=s.decode(t.subarray(o+46,o+46+d)),g=h+30+dn(e,h+26)+dn(e,h+28);i.push({name:f,method:a,compressedSize:c,offset:g}),o+=46+d+u+p}return i}async function Fu(t,e){let n=t.subarray(e.offset,e.offset+e.compressedSize);if(e.method===0)return n;if(e.method!==8)throw new Error("zip_method");let r=new Blob([n.slice()]).stream().pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(r).arrayBuffer())}var Xb={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"},Qb=t=>t.replace(/&(#x?[0-9a-f]+|\w+);/gi,(e,n)=>n[0]==="#"?String.fromCodePoint(Number.parseInt(n.slice(n[1]==="x"?2:1),n[1]==="x"?16:10)):Xb[n]??e);function Jb(t){let e={};for(let n of t.matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))e[n[1]]=Qb(n[2]??n[3]);return e}function ey(t){let e=[],n=null;for(let r of t.matchAll(/<(\/?)(level|room|point|wall|doorOrWindow|pieceOfFurniture)\b([^>]*?)(\/?)>/g)){let[,o,i,s,l]=r;if(o){i==="room"&&(n=null);continue}let a=Jb(s);if(i==="point"){n&&n.points.push([Number(a.x)/100,Number(a.y)/100]);continue}let c={name:i,attrs:a,...i==="room"?{points:[]}:{}};e.push(c),i==="room"&&!l&&(n=c)}return e}var re=(t,e,n)=>Number.isFinite(Number(t[e]))&&t[e]!==void 0?Number(t[e]):n,Re=t=>Math.round(t*1e3)/1e3;function Tu(t,e,n){let[r,o]=[n[0]-e[0],n[1]-e[1]],i=Math.hypot(r,o)||1e-9,s=Math.max(0,Math.min(i,((t[0]-e[0])*r+(t[1]-e[1])*o)/i)),l=[e[0]+r*s/i,e[1]+o*s/i];return{dist:Math.hypot(t[0]-l[0],t[1]-l[1]),along:s,length:i}}function ty(t){let e=`${t.name??""} ${t.catalogId??""}`.toLowerCase();return/garage|sectional|rolltor/.test(e)?"garage":/door|tür|tuer|porte|puerta|deur|haustür/.test(e)&&!/window|fenster/.test(e)?"door":"window"}function ny(t,e){let n=t.length,r=t.map((o,i)=>{let s=t[(i+1)%n],[l,a]=[s[0]-o[0],s[1]-o[1]],c=Math.hypot(l,a)||1e-9,d=[l/c,a/c],u=[(o[0]+s[0])/2,(o[1]+s[1])/2],p=[0,0];for(let h of e){let[f,g]=[h.b[0]-h.a[0],h.b[1]-h.a[1]],y=Math.hypot(f,g)||1e-9;if(Math.abs((d[0]*g-d[1]*f)/y)>.05)continue;let b=(h.a[0]-u[0])*-d[1]+(h.a[1]-u[1])*d[0],v=((u[0]-h.a[0])*f+(u[1]-h.a[1])*g)/y;if(!(Math.abs(b)>h.thickness/2+.06||v<-.05||v>y+.05)){p=[-d[1]*b,d[0]*b];break}}return{p:[o[0]+p[0],o[1]+p[1]],dir:d}});return r.map((o,i)=>{let s=r[(i-1+n)%n],l=s.dir[0]*o.dir[1]-s.dir[1]*o.dir[0];if(Math.abs(l)<1e-6)return o.p;let a=((o.p[0]-s.p[0])*o.dir[1]-(o.p[1]-s.p[1])*o.dir[0])/l;return[s.p[0]+s.dir[0]*a,s.p[1]+s.dir[1]*a]})}function ry(t){let e=Ft(),n={floors:0,rooms:0,openings:0,walls:0,furniture:0}Line truncated
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${a(n)}</title>
<style>html,body{margin:0;height:100%;background:#111;color:#ddd;font-family:system-ui,sans-serif}iframe{border:0;width:100%;height:100%;display:block}noscript p{padding:2em}</style></head>
<body><iframe id="nf" src="${a(o)}" allow="fullscreen" title="${a(n)}"></iframe>
@@ -586,7 +586,7 @@ addEventListener("message", (e) => {
if (e.source === frame.contentWindow && e.data && e.data.type === "nextfloor-share-ready") frame.contentWindow.postMessage({ type: "nextfloor-share", building: data.building, packs: data.packs }, "*");
});
<\/script></body></html>
`}function ju(t){let e;try{e=JSON.parse(t)}catch{throw new Error("not_json")}let n=e,r=n?.format===Wu?n.building:e;if(!vy(r))throw new Error("not_plan");return r.floors.forEach(o=>o.background=null),ze(r)}var xy=t=>!/^https?:\/\//.test(t)&&!t.startsWith("camera:");function Uu(t){let e=new Set;for(let n of t.floors){n.background?.image_id&&e.add(n.background.image_id);let r=n.furniture.flatMap(o=>o.pictures??[]);for(let{image:o}of r)o&&xy(o)&&e.add(o)}return[...e]}function Zu(t,e,n="application/json"){let r=document.createElement("a"),o=URL.createObjectURL(new Blob([e],{type:n}));Object.assign(r,{href:o,download:t}),r.click(),setTimeout(()=>URL.revokeObjectURL(o),1e3)}var $y={api:{listHistory:rc,restoreSnapshot:ac,takeSnapshot:oc,getSnapshot:ic,deleteSnapshot:sc,fetchBackup:cc,restoreBackup:dc,fetchImage:Ro,storeImage:St},alert:t=>alert(t),confirm:t=>confirm(t),prompt:t=>prompt(t),download:Zu,today:()=>new Date().toISOString().slice(0,10)},Sy=t=>String(t?.message??t),hi=class{host;deps;history=null;busy=!1;compare=null;constructor(e,n=$y){this.host=e,this.deps=n}async loadHistory(){let{hass:e}=this.host;e&&(this.history=await this.deps.api.listHistory(e).catch(()=>[]),this.host.refresh())}timeOf(e){return new Date(e.saved_at*1e3).toLocaleString(this.host.hass?.language,{dateStyle:"short",timeStyle:"short"})}async restorePoint(e){let{hass:n,t:r}=this.host;!n||!this.deps.confirm(r("backup_restore_confirm",{time:this.timeOf(e)}))||(await this.deps.api.restoreSnapshot(n,e.id),this.host.say(r("backup_restored")),await this.loadHistory())}async saveVersion(){let{hass:e,t:n}=this.host,r=e?this.deps.prompt?.(n("version_name_prompt"))?.trim():null;!e||!r||(await this.deps.api.takeSnapshot(e,r.slice(0,60)),this.host.say(n("version_saved",{name:r})),await this.loadHistory())}async compareWith(e){let{hass:n}=this.host,r=this.deps.api.getSnapshot;if(!n||!r)return;if(this.compare?.snapshot.id===e.id)return this.compare=null,this.host.refresh();let o=ze(await r(n,e.id));this.compare={snapshot:e,entries:Eu(o,this.host.doc)},this.host.refresh()}async deleteVersion(e){let{hass:n,t:r}=this.host,o=this.deps.api.deleteSnapshot;!n||!o||!this.deps.confirm(r("version_delete_confirm",{name:e.name??this.timeOf(e)}))||(await o(n,e.id),this.compare?.snapshot.id===e.id&&(this.compare=null),await this.loadHistory())}exportShareView(){let e=this.host.t,n=Gu(this.host.doc,gr(),e("share_view_title"),e("share_view_needs_js"));this.deps.download(`nextfloor-${e("share_view_file")}-${this.deps.today()}.html`,n,"text/html"),this.host.say(e("share_view_done"))}exportPlan(e){let n=this.host.t(e?"export_name_template":"export_name_backup");this.deps.download(`nextfloor-${n}-${this.deps.today()}.json`,JSON.stringify(Ku(this.host.doc,e),null,2))}async importPlan(e){let{hass:n,t:r}=this.host;if(!e||!n)return;let o,i=r("backup_import_confirm");try{if(/\.sh3d$/i.test(e.name)){let s=await zu(new Uint8Array(await e.arrayBuffer()));o=s.building,i=`${r("import_sh3d_found",{...s.report})}
`}function ju(t){let e;try{e=JSON.parse(t)}catch{throw new Error("not_json")}let n=e,r=n?.format===Wu?n.building:e;if(!vy(r))throw new Error("not_plan");return r.floors.forEach(o=>o.background=null),ze(r)}var xy=t=>!/^https?:\/\//.test(t)&&!t.startsWith("camera:");function Uu(t){let e=new Set;for(let n of t.floors){n.background?.image_id&&e.add(n.background.image_id);let r=n.furniture.flatMap(o=>o.pictures??[]);for(let{image:o}of r)o&&xy(o)&&e.add(o)}return[...e]}function Zu(t,e,n="application/json"){let r=document.createElement("a"),o=URL.createObjectURL(new Blob([e],{type:n}));Object.assign(r,{href:o,download:t}),r.click(),setTimeout(()=>URL.revokeObjectURL(o),1e3)}var $y={api:{listHistory:rc,restoreSnapshot:ac,takeSnapshot:oc,getSnapshot:ic,deleteSnapshot:sc,fetchBackup:cc,restoreBackup:dc,fetchImage:Ro,storeImage:St},alert:t=>alert(t),confirm:t=>confirm(t),prompt:t=>prompt(t),download:Zu,today:()=>new Date().toISOString().slice(0,10)},Sy=t=>String(t?.message??t),hi=class{host;deps;history=null;busy=!1;compare=null;constructor(e,n=$y){this.host=e,this.deps=n}async loadHistory(){let{hass:e}=this.host;e&&(this.history=await this.deps.api.listHistory(e).catch(()=>[]),this.host.refresh())}timeOf(e){return new Date(e.saved_at*1e3).toLocaleString(this.host.hass?.language,{dateStyle:"short",timeStyle:"short"})}async restorePoint(e){let{hass:n,t:r}=this.host;!n||!this.deps.confirm(r("backup_restore_confirm",{time:this.timeOf(e)}))||(await this.deps.api.restoreSnapshot(n,e.id),this.host.say(r("backup_restored")),await this.loadHistory())}async saveVersion(){let{hass:e,t:n}=this.host,r=e?this.deps.prompt?.(n("version_name_prompt"))?.trim():null;!e||!r||(await this.deps.api.takeSnapshot(e,r.slice(0,60)),this.host.say(n("version_saved",{name:r})),await this.loadHistory())}async compareWith(e){let{hass:n}=this.host,r=this.deps.api.getSnapshot;if(!n||!r)return;if(this.compare?.snapshot.id===e.id)return this.compare=null,this.host.refresh();let o=ze(await r(n,e.id));this.compare={snapshot:e,entries:Eu(o,this.host.doc)},this.host.refresh()}async deleteVersion(e){let{hass:n,t:r}=this.host,o=this.deps.api.deleteSnapshot;!n||!o||!this.deps.confirm(r("version_delete_confirm",{name:e.name??this.timeOf(e)}))||(await o(n,e.id),this.compare?.snapshot.id===e.id&&(this.compare=null),await this.loadHistory())}exportShareView(){let e=this.host.t,n=Gu(this.host.doc,_r(),e("share_view_title"),e("share_view_needs_js"));this.deps.download(`nextfloor-${e("share_view_file")}-${this.deps.today()}.html`,n,"text/html"),this.host.say(e("share_view_done"))}exportPlan(e){let n=this.host.t(e?"export_name_template":"export_name_backup");this.deps.download(`nextfloor-${n}-${this.deps.today()}.json`,JSON.stringify(Ku(this.host.doc,e),null,2))}async importPlan(e){let{hass:n,t:r}=this.host;if(!e||!n)return;let o,i=r("backup_import_confirm");try{if(/\.sh3d$/i.test(e.name)){let s=await zu(new Uint8Array(await e.arrayBuffer()));o=s.building,i=`${r("import_sh3d_found",{...s.report})}
${i}`}else if(/\.ifc$/i.test(e.name)){let s=Nu(await e.text());o=s.building,i=`${r("import_ifc_found",{floors:s.report.floors,rooms:s.report.rooms})}
@@ -594,7 +594,7 @@ ${i}`}else if(/\.dxf$/i.test(e.name)){let s=Iu(await e.text());o=s.building,i=`$
${i}`}else{let s=await e.text(),l=null;try{l=JSON.parse(s)}catch{}if(Ou(l)){let a=Hu(l);o=a.building,i=`${r("import_roomplan_found",{rooms:a.report.rooms,openings:a.report.openings,skipped:a.report.furniture})}
${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json",not_plan:"import_error_not_plan",not_zip:"import_error_sh3d",sh3d_no_xml:"import_error_sh3d",sh3d_empty:"import_error_sh3d_empty",dxf_empty:"import_error_dxf_empty",ifc_empty:"import_error_ifc_empty",roomplan_empty:"import_error_roomplan_empty"};this.deps.alert(a[l]?r(a[l]):r("backup_import_error",{error:l}));return}this.deps.confirm(i)&&(await this.deps.api.takeSnapshot(n).catch(()=>{}),this.host.adopt(o),this.host.say(r("backup_imported")))}async exportFull(){let{hass:e,t:n}=this.host;if(e){this.busy=!0,this.host.refresh();try{let r=await this.deps.api.fetchBackup(e),o={};for(let i of Uu(r.building))await this.deps.api.fetchImage(e,i).then(s=>o[i]=s,()=>{});this.deps.download(`nextfloor-${n("export_name_full")}-${this.deps.today()}.json`,JSON.stringify({...r,exported_at:new Date().toISOString(),images:o}))}catch(r){this.deps.alert(n("backup_import_error",{error:Sy(r)}))}finally{this.busy=!1,this.host.refresh()}}}async importFull(e){let{hass:n,t:r}=this.host;if(!e||!n)return;let o;try{o=JSON.parse(await e.text())}catch{this.deps.alert(r("import_error_not_json"));return}if(o?.format!=="nextfloor-backup"||!o.building){this.deps.alert(r("backup_full_not_backup"));return}if(this.deps.confirm(r("backup_full_confirm"))){this.busy=!0,this.host.refresh();try{let i=await this.deps.api.restoreBackup(n,o.building,o.packs??[]),s=0;for(let[a,c]of Object.entries(o.images??{}))await this.deps.api.storeImage(n,a,c).then(()=>s++,()=>{});this.host.adopt(ze(i.building)),this.host.packsChanged();let l=i.skipped.length>0?` ${r("backup_full_skipped",{packs:i.skipped.map(a=>a.id).join(", ")})}`:"";this.host.say(r("backup_full_restored",{packs:i.packs,pictures:s})+l)}catch(i){let{code:s,message:l}=i??{};this.deps.alert(r("backup_import_error",{error:l??s??String(i)}))}finally{this.busy=!1,this.host.refresh()}}}};function qe(t,e){if(!gt(e))return xe(t,`furn_${e}`);let n=G(e);return n?Ye(n,e,t?.language??navigator.language):xe(t,"pack_missing_item")}function Ye(t,e,n){return t.name[n.split("-")[0]]??oi(n,e)??xc(t,n)}function Oe(t,e){return oi(e,`packname:${t.id}`)??$c(t,e)}function qu(t,e){return t.name[e.split("-")[0]]??oi(e,`color:${t.id}`)??t.name.en??Object.values(t.name)[0]}var Yu=(t,e,n="application/json,.json")=>m`<label class="nf-btn nf-upload"
${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json",not_plan:"import_error_not_plan",not_zip:"import_error_sh3d",sh3d_no_xml:"import_error_sh3d",sh3d_empty:"import_error_sh3d_empty",dxf_empty:"import_error_dxf_empty",ifc_empty:"import_error_ifc_empty",roomplan_empty:"import_error_roomplan_empty"};this.deps.alert(a[l]?r(a[l]):r("backup_import_error",{error:l}));return}this.deps.confirm(i)&&(await this.deps.api.takeSnapshot(n).catch(()=>{}),this.host.adopt(o),this.host.say(r("backup_imported")))}async exportFull(){let{hass:e,t:n}=this.host;if(e){this.busy=!0,this.host.refresh();try{let r=await this.deps.api.fetchBackup(e),o={};for(let i of Uu(r.building))await this.deps.api.fetchImage(e,i).then(s=>o[i]=s,()=>{});this.deps.download(`nextfloor-${n("export_name_full")}-${this.deps.today()}.json`,JSON.stringify({...r,exported_at:new Date().toISOString(),images:o}))}catch(r){this.deps.alert(n("backup_import_error",{error:Sy(r)}))}finally{this.busy=!1,this.host.refresh()}}}async importFull(e){let{hass:n,t:r}=this.host;if(!e||!n)return;let o;try{o=JSON.parse(await e.text())}catch{this.deps.alert(r("import_error_not_json"));return}if(o?.format!=="nextfloor-backup"||!o.building){this.deps.alert(r("backup_full_not_backup"));return}if(this.deps.confirm(r("backup_full_confirm"))){this.busy=!0,this.host.refresh();try{let i=await this.deps.api.restoreBackup(n,o.building,o.packs??[]),s=0;for(let[a,c]of Object.entries(o.images??{}))await this.deps.api.storeImage(n,a,c).then(()=>s++,()=>{});this.host.adopt(ze(i.building)),this.host.packsChanged();let l=i.skipped.length>0?` ${r("backup_full_skipped",{packs:i.skipped.map(a=>a.id).join(", ")})}`:"";this.host.say(r("backup_full_restored",{packs:i.packs,pictures:s})+l)}catch(i){let{code:s,message:l}=i??{};this.deps.alert(r("backup_import_error",{error:l??s??String(i)}))}finally{this.busy=!1,this.host.refresh()}}}};function qe(t,e){if(!_t(e))return xe(t,`furn_${e}`);let n=G(e);return n?Ye(n,e,t?.language??navigator.language):xe(t,"pack_missing_item")}function Ye(t,e,n){return t.name[n.split("-")[0]]??oi(n,e)??xc(t,n)}function Oe(t,e){return oi(e,`packname:${t.id}`)??$c(t,e)}function qu(t,e){return t.name[e.split("-")[0]]??oi(e,`color:${t.id}`)??t.name.en??Object.values(t.name)[0]}var Yu=(t,e,n="application/json,.json")=>m`<label class="nf-btn nf-upload"
>${t}<input
type="file"
accept=${n}
@@ -627,7 +627,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<h4 class="nf-lib-head">${n("backup_full")}</h4>
${Y(m`<button class="nf-btn" ?disabled=${e.busy} @click=${()=>e.exportFull()}>${e.busy?"\u2026":n("backup_full_export")}</button>`,Yu(n("backup_full_import"),i=>{e.importFull(i)}))}
${M(n("backup_full_hint"))}
</details>`}function Qu(t,e){return e&&t.states[e]?e:Object.keys(t.states).filter(n=>n.startsWith("weather.")).sort()[0]??null}var Ju=["body","wood","fabric","white","metal","dark"],eh={body:"#172238",wood:"#19233c",fabric:"#1a2644",white:"#1d2946",metal:"#2a3a60",dark:"#0b111f"};var dn=(t,e,n)=>Math.min(n,Math.max(e,t)),Ey=t=>(Math.round(t)%360+360)%360,_a=(t,e)=>Ey(t+e);function th(t,e,n){return n?[...new Set([...t,e])]:t.filter(r=>r!==e)}function nh(t,e,n){let r=t.t,o=s=>()=>n(_a(e,s)),i=R`<svg class="nf-compass-dial" viewBox="-50 -50 100 100" role="img" aria-label=${r("compass_title")}>
</details>`}function Qu(t,e){return e&&t.states[e]?e:Object.keys(t.states).filter(n=>n.startsWith("weather.")).sort()[0]??null}var Ju=["body","wood","fabric","white","metal","dark"],eh={body:"#172238",wood:"#19233c",fabric:"#1a2644",white:"#1d2946",metal:"#2a3a60",dark:"#0b111f"};var un=(t,e,n)=>Math.min(n,Math.max(e,t)),Ey=t=>(Math.round(t)%360+360)%360,_a=(t,e)=>Ey(t+e);function th(t,e,n){return n?[...new Set([...t,e])]:t.filter(r=>r!==e)}function nh(t,e,n){let r=t.t,o=s=>()=>n(_a(e,s)),i=R`<svg class="nf-compass-dial" viewBox="-50 -50 100 100" role="img" aria-label=${r("compass_title")}>
<circle r="46" class="nf-compass-ring" />
<path d="M0 -50l3 6h-6z" class="nf-compass-up" />
<g transform="rotate(${e})">
@@ -675,7 +675,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
>${r("backdrop_color")}
<input type="color" .value=${e?.color??"#101828"} ?disabled=${!t.admin} @change=${s=>i({color:s.target.value})}
/></label>
${E(t,r("backdrop_dim"),Math.round((e?.dim??.35)*100),s=>i({dim:dn(s,0,80)/100}),5,0)}
${E(t,r("backdrop_dim"),Math.round((e?.dim??.35)*100),s=>i({dim:un(s,0,80)/100}),5,0)}
${Z(t,r("backdrop_image"),e?.image??"",s=>i({image:s||null}),{wide:!0,placeholder:"/local/hintergrund.jpg"})}
${M(r("backdrop_hint"),"nf-wide")}`:_}`}function Cy(t,e,n){let r=t.t,o=L(t.hass,i=>!e.includes(i)&&/^(sensor|binary_sensor|alarm_control_panel|weather|input_|counter|lock|climate|person|sun)\b/.test(i));return m`<div class="nf-sub nf-wide">${r("status_entities")}</div>
${e.length?m`<div class="nf-chips nf-wide">
@@ -687,21 +687,21 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${M(r("status_entities_hint"),"nf-wide")}`}function uh(t,e){let n=t.t,r=t.doc.settings,o=c=>t.replace({...structuredClone(t.doc),settings:{...structuredClone(t.doc.settings),...c}}),i=c=>o({roof:{...r.roof,...c}}),s=Hy.map(c=>[c,n(`roof_${c}`)]),l=r.weather_effects??Oc,a=r.roof.type==="gable";return m`<details class="nf-section">
<summary>${n("settings")}</summary>
<div class="nf-form">
${E(t,n("wall_exterior"),r.wall_exterior,c=>o({wall_exterior:dn(c,.02,1)}),.01,.02)}
${E(t,n("wall_interior"),r.wall_interior,c=>o({wall_interior:dn(c,.02,1)}),.01,.02)}
${E(t,n("wall_exterior"),r.wall_exterior,c=>o({wall_exterior:un(c,.02,1)}),.01,.02)}
${E(t,n("wall_interior"),r.wall_interior,c=>o({wall_interior:un(c,.02,1)}),.01,.02)}
${Ue(t,n("wall_paint_outside"),r.wall_paint_outside,Io,c=>o({wall_paint_outside:c}))}
${Ue(t,n("wall_paint_inside"),r.wall_paint_inside,Do,c=>o({wall_paint_inside:c}))}
${M(n("wall_paint_hint"),"nf-wide")}
${Ju.map(c=>Ue(t,n(`furn_color_${c}`),r.furniture_colors?.[c],eh[c],d=>{let u={...r.furniture_colors,[c]:d};d||delete u[c],o({furniture_colors:Object.keys(u).length?u:null})}))}
${M(n("furn_color_hint"),"nf-wide")}
${E(t,n("grid"),r.grid,c=>o({grid:dn(c,.01,1)}),.01,.01)}
${E(t,n("grid"),r.grid,c=>o({grid:un(c,.01,1)}),.01,.01)}
${O(t,n("units"),r.units==="imperial"?"imperial":"metric",[["metric",n("units_metric")],["imperial",n("units_imperial")]],c=>o({units:c==="imperial"?"imperial":null}),{title:n("units_hint")})}
${nh(t,r.north,c=>o({north:c}))}
${dh(t,t.doc,c=>o({map:c}))}
${O(t,n("roof"),r.roof.type,s,c=>c==="custom"?e.useRoofSections():i({type:c}),{wide:!0})}
${a?O(t,n("roof_ridge"),r.roof.ridge==="short"?"short":"long",[["long",n("roof_ridge_long")],["short",n("roof_ridge_short")]],c=>i({ridge:c==="short"?"short":null}),{wide:!0}):_}
${a?E(t,n("roof_pitch"),r.roof.pitch,c=>i({pitch:dn(c,5,60)}),1,5):_}
${r.roof.type!=="none"?E(t,n("roof_overhang"),r.roof.overhang,c=>i({overhang:dn(c,0,2)}),.05,0):_}
${a?E(t,n("roof_pitch"),r.roof.pitch,c=>i({pitch:un(c,5,60)}),1,5):_}
${r.roof.type!=="none"?E(t,n("roof_overhang"),r.roof.overhang,c=>i({overhang:un(c,0,2)}),.05,0):_}
${t.hass?P(t,n("weather_entity"),r.weather_entity??null,Qu(t.hass,null),L(t.hass,c=>c.startsWith("weather.")),c=>o({weather_entity:c})):_}
<div class="nf-sub nf-wide">${n("weather_effects")}</div>
${Dc.map(c=>H(t,n(`weather_effect_${c}`),l.includes(c),d=>o({weather_effects:th(l,c,d)}),{wide:!1}))}
@@ -735,7 +735,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${Ly(t,r.backdrop??null,c=>o({backdrop:c}))}
</div>
${M(`${n("north_hint")} ${n("weather_entity_hint")}`)}
</details>`}var Jr=t=>t&&t!=="none"?t:null,eo=(t,e)=>{e&&!t.includes(e)&&t.push(e)},ya=t=>new Map(t.floors.flatMap(e=>e.furniture.filter(n=>n.type==="meter").map(n=>[n.id,n])));function un(t,e){if(!t.energy.advanced||e.type!=="meter"||!e.parent_meter)return null;let n=ya(t),r=new Set([e.id]);for(let o=n.get(e.parent_meter);o;o=n.get(o.parent_meter??"")){if(r.has(o.id))return null;r.add(o.id)}return n.has(e.parent_meter)?e.parent_meter:null}function Vn(t){return new Set([...ya(t).values()].filter(e=>un(t,e)).map(e=>e.id))}function to(t,e){return!t.energy.advanced||!e.parent_meter?null:Vn(t).has(e.parent_meter)?e.parent_meter:null}function hh(t,e,n){if(n.type!=="meter"||n.id===e.id)return!1;let r=ya(t),o=new Set;for(let i=n;i&&!o.has(i.id);i=r.get(i.parent_meter??"")){if(i.id===e.id)return!1;o.add(i.id)}return!0}function gi(t,e=n=>Jr(n.power)){let n={grid:null,gridExport:null,solar:[],battery:[],charge:[],batteries:[],soc:[]};for(let r of t.floors.flatMap(o=>o.furniture)){let o=e(r),i=r.type==="meter"?un(t,r):null;if(i)(n.subMeters??=[]).push({id:r.id,parent:i,power:o,invert:!!r.meter_invert,floors:r.meter_floors??[],solar:[],batteries:[]});else if(r.type==="meter")n.grid??=o,n.gridExport??=Jr(r.export);else if(r.type==="inverter")eo(n.solar,o);else if(r.type==="home_battery"){let s=Jr(r.charge);eo(n.battery,o),eo(n.charge,s),eo(n.soc,Jr(r.soc)),(o||s)&&n.batteries.push({power:o,charge:s})}}for(let r of n.subMeters?t.floors.flatMap(o=>o.furniture):[]){let o=r.type==="inverter"||r.type==="home_battery"?n.subMeters?.find(l=>l.id===to(t,r)):void 0,i=o?e(r):null;o&&r.type==="inverter"&&eo(o.solar,i);let s=Jr(r.charge);o&&r.type==="home_battery"&&(i||s)&&o.batteries.push({power:i,charge:s})}return n}function Ny(t){for(let e of t.floors){let n=e.furniture.find(r=>r.type==="meter"&&!un(t,r));if(n)return{floor_id:e.id,x:n.x,z:n.z}}return t.energy.meter}var By=/(phase|_l[123]\b|_[abc]$|today|daily|heute)/,Wy=/_?(energy|energie|total|today|daily|kwh|import|export|consumption|production)/g;function mi(t,e,n="power"){let r=e?t.entities?.[e]?.device_id:void 0;if(!e||!r)return null;let o=Object.keys(t.states).filter(l=>l.startsWith("sensor.")&&t.entities?.[l]?.device_id===r&&t.states[l]?.attributes.device_class===n);if(o.length<=1)return o[0]??null;let i=o.filter(l=>!By.test(l)),s=e.replace(/^sensor\./,"").replace(Wy,"");return i.find(l=>s&&l.includes(s))??i[0]??o[0]}function ph(t,e){let n={},r=(o,i)=>{i&&!n[o]&&(n[o]=i)};for(let o of e.energy_sources??[])if(o.type==="grid")r("grid",mi(t,o.flow_from?.[0]?.stat_energy_from??o.flow_to?.[0]?.stat_energy_to));else if(o.type==="solar")r("solar",mi(t,o.stat_energy_from));else if(o.type==="battery"){let i=o.stat_energy_from??o.stat_energy_to;r("battery",mi(t,i)),r("battery_soc",mi(t,i,"battery"))}return n}function Ee(t,e=!1){let n=t?Number(t.state):NaN;if(!Number.isFinite(n))return null;let r={kW:1e3,MW:1e6}[String(t.attributes.unit_of_measurement??"W")]??1;return e?-n*r:n*r}var Vy=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power";function fh(t,e){if(Vy(t,e))return e;let n=t.entities?.[e]?.device_id;if(!n)return null;let r=Ss(t,n),o=r?Tt(t,e):null,i=jo(t,n).filter(s=>s!==e);return(r?i.find(s=>o!==null&&Tt(t,s)===o):i[0])??null}var mh=t=>{let e=t.filter(n=>n!==null);return e.length?e.reduce((n,r)=>n+r,0):null};function Ky(t,e,n){let r=e.grid??n.grid,o=r?Ee(t.states[r],e.grid_invert):null;if(!e.grid&&n.gridExport){let i=Math.max(0,Ee(t.states[n.gridExport])??0);return Math.max(0,o??0)-i}return o}function Gy(t,e,n){return e.solar?Ee(t.states[e.solar]):n.solar.length?mh(n.solar.map(r=>Ee(t.states[r]))):null}function wa(t,e,n){return e.charge?(e.power?Math.max(0,Ee(t.states[e.power])??0):0)-Math.max(0,Ee(t.states[e.charge])??0):e.power?Ee(t.states[e.power],n):null}function jy(t,e,n){return e.battery?Ee(t.states[e.battery],e.battery_invert):mh(n.batteries.map(r=>wa(t,r,e.battery_invert)))}function va(t,e,n,r=gi(e)){let o=e.energy,i=Ky(t,o,r),s=Gy(t,o,r),l=jy(t,o,r),a=(o.battery_soc?[o.battery_soc]:r.soc).map(f=>Number(t.states[f]?.state)).filter(Number.isFinite),c=a.length?a.reduce((f,g)=>f+g,0)/a.length:null,d=o.tariff?t.states[o.tariff]:void 0,u=Number(d?.state),p=o.consumption?Ee(t.states[o.consumption]):null;p===null&&(i!==null||s!==null||l!==null)&&(p=(i??0)+Math.max(0,s??0)+(l??0)),p===null&&n.length>0&&(p=n.reduce((f,g)=>f+g.power,0));let h={grid:i,solar:s===null?null:Math.max(0,s),battery:l,soc:c,tariff:d&&Number.isFinite(u)?{value:u,unit:String(d.attributes.unit_of_measurement??"")}:null,consumption:p===null?null:Math.max(0,p)};return r.subMeters?{...h,...Uy(t,r,h.consumption,o.battery_invert,n)}:h}function Uy(t,e,n,r,o){let i=e.subMeters??[],s=new Map;for(let p of i)for(let h of p.floors)s.has(h)||s.set(h,p.id);let l=new Set([e.grid,e.gridExport,...e.solar,...e.battery,...e.charge,...i.flatMap(p=>[p.power,...p.solar,...p.batteries.flatMap(h=>[h.power,h.charge])])]),a=p=>o.filter(h=>s.get(h.floorId)===p&&!l.has(h.powerEntity)).reduce((h,f)=>h+f.Line truncated
</details>`}var Jr=t=>t&&t!=="none"?t:null,eo=(t,e)=>{e&&!t.includes(e)&&t.push(e)},ya=t=>new Map(t.floors.flatMap(e=>e.furniture.filter(n=>n.type==="meter").map(n=>[n.id,n])));function hn(t,e){if(!t.energy.advanced||e.type!=="meter"||!e.parent_meter)return null;let n=ya(t),r=new Set([e.id]);for(let o=n.get(e.parent_meter);o;o=n.get(o.parent_meter??"")){if(r.has(o.id))return null;r.add(o.id)}return n.has(e.parent_meter)?e.parent_meter:null}function Kn(t){return new Set([...ya(t).values()].filter(e=>hn(t,e)).map(e=>e.id))}function to(t,e){return!t.energy.advanced||!e.parent_meter?null:Kn(t).has(e.parent_meter)?e.parent_meter:null}function hh(t,e,n){if(n.type!=="meter"||n.id===e.id)return!1;let r=ya(t),o=new Set;for(let i=n;i&&!o.has(i.id);i=r.get(i.parent_meter??"")){if(i.id===e.id)return!1;o.add(i.id)}return!0}function gi(t,e=n=>Jr(n.power)){let n={grid:null,gridExport:null,solar:[],battery:[],charge:[],batteries:[],soc:[]};for(let r of t.floors.flatMap(o=>o.furniture)){let o=e(r),i=r.type==="meter"?hn(t,r):null;if(i)(n.subMeters??=[]).push({id:r.id,parent:i,power:o,invert:!!r.meter_invert,floors:r.meter_floors??[],solar:[],batteries:[]});else if(r.type==="meter")n.grid??=o,n.gridExport??=Jr(r.export);else if(r.type==="inverter")eo(n.solar,o);else if(r.type==="home_battery"){let s=Jr(r.charge);eo(n.battery,o),eo(n.charge,s),eo(n.soc,Jr(r.soc)),(o||s)&&n.batteries.push({power:o,charge:s})}}for(let r of n.subMeters?t.floors.flatMap(o=>o.furniture):[]){let o=r.type==="inverter"||r.type==="home_battery"?n.subMeters?.find(l=>l.id===to(t,r)):void 0,i=o?e(r):null;o&&r.type==="inverter"&&eo(o.solar,i);let s=Jr(r.charge);o&&r.type==="home_battery"&&(i||s)&&o.batteries.push({power:i,charge:s})}return n}function Ny(t){for(let e of t.floors){let n=e.furniture.find(r=>r.type==="meter"&&!hn(t,r));if(n)return{floor_id:e.id,x:n.x,z:n.z}}return t.energy.meter}var By=/(phase|_l[123]\b|_[abc]$|today|daily|heute)/,Wy=/_?(energy|energie|total|today|daily|kwh|import|export|consumption|production)/g;function mi(t,e,n="power"){let r=e?t.entities?.[e]?.device_id:void 0;if(!e||!r)return null;let o=Object.keys(t.states).filter(l=>l.startsWith("sensor.")&&t.entities?.[l]?.device_id===r&&t.states[l]?.attributes.device_class===n);if(o.length<=1)return o[0]??null;let i=o.filter(l=>!By.test(l)),s=e.replace(/^sensor\./,"").replace(Wy,"");return i.find(l=>s&&l.includes(s))??i[0]??o[0]}function ph(t,e){let n={},r=(o,i)=>{i&&!n[o]&&(n[o]=i)};for(let o of e.energy_sources??[])if(o.type==="grid")r("grid",mi(t,o.flow_from?.[0]?.stat_energy_from??o.flow_to?.[0]?.stat_energy_to));else if(o.type==="solar")r("solar",mi(t,o.stat_energy_from));else if(o.type==="battery"){let i=o.stat_energy_from??o.stat_energy_to;r("battery",mi(t,i)),r("battery_soc",mi(t,i,"battery"))}return n}function Ee(t,e=!1){let n=t?Number(t.state):NaN;if(!Number.isFinite(n))return null;let r={kW:1e3,MW:1e6}[String(t.attributes.unit_of_measurement??"W")]??1;return e?-n*r:n*r}var Vy=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power";function fh(t,e){if(Vy(t,e))return e;let n=t.entities?.[e]?.device_id;if(!n)return null;let r=Ss(t,n),o=r?Tt(t,e):null,i=jo(t,n).filter(s=>s!==e);return(r?i.find(s=>o!==null&&Tt(t,s)===o):i[0])??null}var mh=t=>{let e=t.filter(n=>n!==null);return e.length?e.reduce((n,r)=>n+r,0):null};function Ky(t,e,n){let r=e.grid??n.grid,o=r?Ee(t.states[r],e.grid_invert):null;if(!e.grid&&n.gridExport){let i=Math.max(0,Ee(t.states[n.gridExport])??0);return Math.max(0,o??0)-i}return o}function Gy(t,e,n){return e.solar?Ee(t.states[e.solar]):n.solar.length?mh(n.solar.map(r=>Ee(t.states[r]))):null}function wa(t,e,n){return e.charge?(e.power?Math.max(0,Ee(t.states[e.power])??0):0)-Math.max(0,Ee(t.states[e.charge])??0):e.power?Ee(t.states[e.power],n):null}function jy(t,e,n){return e.battery?Ee(t.states[e.battery],e.battery_invert):mh(n.batteries.map(r=>wa(t,r,e.battery_invert)))}function va(t,e,n,r=gi(e)){let o=e.energy,i=Ky(t,o,r),s=Gy(t,o,r),l=jy(t,o,r),a=(o.battery_soc?[o.battery_soc]:r.soc).map(f=>Number(t.states[f]?.state)).filter(Number.isFinite),c=a.length?a.reduce((f,g)=>f+g,0)/a.length:null,d=o.tariff?t.states[o.tariff]:void 0,u=Number(d?.state),p=o.consumption?Ee(t.states[o.consumption]):null;p===null&&(i!==null||s!==null||l!==null)&&(p=(i??0)+Math.max(0,s??0)+(l??0)),p===null&&n.length>0&&(p=n.reduce((f,g)=>f+g.power,0));let h={grid:i,solar:s===null?null:Math.max(0,s),battery:l,soc:c,tariff:d&&Number.isFinite(u)?{value:u,unit:String(d.attributes.unit_of_measurement??"")}:null,consumption:p===null?null:Math.max(0,p)};return r.subMeters?{...h,...Uy(t,r,h.consumption,o.battery_invert,n)}:h}function Uy(t,e,n,r,o){let i=e.subMeters??[],s=new Map;for(let p of i)for(let h of p.floors)s.has(h)||s.set(h,p.id);let l=new Set([e.grid,e.gridExport,...e.solar,...e.battery,...e.charge,...i.flatMap(p=>[p.power,...p.solar,...p.batteries.flatMap(h=>[h.power,h.charge])])]),a=p=>o.filter(h=>s.get(h.floorId)===p&&!l.has(h.powerEntity)).reduce((h,f)=>h+f.Line truncated
<h3>☑ ${t.t("chk_title")} <span class="nf-sub">${r}/${n.length}</span></h3>
${M(t.t("chk_hint"))}
${n.map(o=>m`<button class="nf-chk nf-chk-${o.state}" ?disabled=${!t.admin&&o.state!=="ok"} @click=${()=>e.follow(o.target)}>
@@ -752,7 +752,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<div class="nf-actions">
${Ce.map(r=>m`<button class="nf-btn" ?disabled=${!t.admin||!t.floor} @click=${()=>e.addDevice(r)}>+ ${t.t(`furn_${r}`)}</button>`)}
</div>
</section>`}var wh=(t,e,n)=>m`<p class="nf-sub nf-pack-error">${t.t(e)} <button class="nf-btn" ?disabled=${!t.admin} @click=${n}>${t.t("energy_sign_flip")}</button></p>`;function Sh(t,e){let{energy:n}=t.doc,r=(b,v)=>t.hass?.states[b]?.attributes[v],o=L(t.hass,b=>On(t.hass,b)),i=L(t.hass,b=>me(b)&&r(b,"device_class")==="battery"),s=L(t.hass,b=>me(b)&&(r(b,"device_class")==="monetary"||/\/(kWh|MWh)$/.test(r(b,"unit_of_measurement")??""))),l=vh(t),a=gi(t.doc,b=>si(b,l)),c=b=>t.replace({...structuredClone(t.doc),energy:{...t.doc.energy,...b}}),d=L(t.hass,b=>me(b)&&["gas","water","volume_flow_rate"].includes(r(b,"device_class")??"")),u=b=>v=>c({[b]:v==="none"?null:v}),p=t.hass?va(t.hass,t.doc,[],a):null,h=!!p&&(p.solar??0)<20,f=h&&p.grid!==null&&p.grid<-50,g=h&&p.battery!==null&&p.battery<-50&&(p.grid??0)<=0,y=(b,v)=>H(t,t.t("energy_invert"),b,w=>c(v(w)));return m`<section>
</section>`}var wh=(t,e,n)=>m`<p class="nf-sub nf-pack-error">${t.t(e)} <button class="nf-btn" ?disabled=${!t.admin} @click=${n}>${t.t("energy_sign_flip")}</button></p>`;function Sh(t,e){let{energy:n}=t.doc,r=(b,v)=>t.hass?.states[b]?.attributes[v],o=L(t.hass,b=>Hn(t.hass,b)),i=L(t.hass,b=>me(b)&&r(b,"device_class")==="battery"),s=L(t.hass,b=>me(b)&&(r(b,"device_class")==="monetary"||/\/(kWh|MWh)$/.test(r(b,"unit_of_measurement")??""))),l=vh(t),a=gi(t.doc,b=>si(b,l)),c=b=>t.replace({...structuredClone(t.doc),energy:{...t.doc.energy,...b}}),d=L(t.hass,b=>me(b)&&["gas","water","volume_flow_rate"].includes(r(b,"device_class")??"")),u=b=>v=>c({[b]:v==="none"?null:v}),p=t.hass?va(t.hass,t.doc,[],a):null,h=!!p&&(p.solar??0)<20,f=h&&p.grid!==null&&p.grid<-50,g=h&&p.battery!==null&&p.battery<-50&&(p.grid??0)<=0,y=(b,v)=>H(t,t.t("energy_invert"),b,w=>c(v(w)));return m`<section>
<h3>⚖ ${t.t("energy_balance")}</h3>
${M(t.t("energy_balance_hint"))}
${f?wh(t,"energy_sign_grid",()=>c({grid_invert:!n.grid_invert})):_}
@@ -806,7 +806,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${s?H(t,r("route_cable"),!!s.cable,a=>e.setCable(i.key,a),{title:r("route_cable_hint")}):_}`}
</div>`})}
</div>
</section>`}var it=(t,e)=>e.map(n=>t.toScreen(n).join(",")).join(" ");function _i(t,e,n,r,o,i){let[[s,l],[a,c]]=[t.toScreen(e),t.toScreen(n)];if(Math.hypot(a-s,c-l)<=36)return _;let[d,u]=[(s+a)/2,(l+c)/2];return R`<g data-plus=${`${r}:${o}:${i}`} class="nf-mid"><circle cx=${d} cy=${u} r="14" class="nf-hit" /><circle cx=${d} cy=${u} r="6" /><path d="M${d-3} ${u}h6M${d} ${u-3}v6" /></g>`}var Ah=(t,e)=>R`<circle cx=${t} cy=${e} r="16" class="nf-hit" /><circle cx=${t} cy=${e} r="6" />`,t0=(t,e,n)=>R`<g class="nf-vertex" data-roof-vertex=${n}>${Ah(...t.toScreen(e))}</g>`,n0=(t,e,n)=>R`<g class="nf-vertex" data-roof-corner=${n}>${Ah(...t.toScreen(e))}</g>`;function r0(t,e,n,r){let{t:o,hass:i}=t.host,s=n.dormer?o("roof_dormer"):n.open?o("roof_open_short"):o(`roof_shape_${n.shape}`);return`${e.isFixed(n)?"\u{1F512} ":""}${r+1} \xB7 ${s} \xB7 ${j(i,Yt(n),1)} m`}function ka(t,e){let n=t.host.doc.settings.roof,r=n.type==="custom"?n.sections??[]:[],o=t.host.admin,i=(s,l)=>{let a=s.id===e.sectionId,c=ve(s),d=(s.shape==="flat"||s.shape==="parapet")&&s.points&&s.points.length>=3?s.points:null,u=Yo(r,s),p=u?ve(Hs(u,s)):c,h=d??[p.at(p.u0,0),p.at(p.u1,0),p.at(p.u1,p.w),p.at(p.u0,p.w)],g=((s.shape==="flat"||s.shape==="parapet"?null:Xt(s,{u0:0,u1:0,a:0,b:0}))?.ridges??[]).map(([C,B])=>{let[q,ye]=t.toScreen(c.at(C[0],C[1])),[$t,V]=t.toScreen(c.at(B[0],B[1]));return R`<line x1=${q} y1=${ye} x2=${$t} y2=${V} />`}),[y,b]=t.toScreen(c.at((c.u0+c.u1)/2,c.w/2)),v=a&&o&&!e.isFixed(s),w=[[0,0],[1,0],[1,1],[0,1]],x=s.shape==="flat"||s.shape==="parapet",[k,$,A,F]=[Math.min(s.x0,s.x1),Math.max(s.x0,s.x1),Math.min(s.z0,s.z1),Math.max(s.z0,s.z1)],T=d??(s.rotation?$r(s):[[k,A],[$,A],[$,F],[k,F]]),I=v&&x?T.map((C,B)=>_i(t,C,T[(B+1)%T.length],"roof",s.id,B)):_,z=v?R`${I}${d?d.map((C,B)=>t0(t,C,`${s.id}:${B}`)):w.map(([C,B])=>n0(t,[C?$:k,B?F:A],`${s.id}:${C}:${B}`))}`:_;return R`<g data-roof=${s.id} class=${`nf-roof-sec${a?" nf-roof-sel":""}`}>
</section>`}var it=(t,e)=>e.map(n=>t.toScreen(n).join(",")).join(" ");function _i(t,e,n,r,o,i){let[[s,l],[a,c]]=[t.toScreen(e),t.toScreen(n)];if(Math.hypot(a-s,c-l)<=36)return _;let[d,u]=[(s+a)/2,(l+c)/2];return R`<g data-plus=${`${r}:${o}:${i}`} class="nf-mid"><circle cx=${d} cy=${u} r="14" class="nf-hit" /><circle cx=${d} cy=${u} r="6" /><path d="M${d-3} ${u}h6M${d} ${u-3}v6" /></g>`}var Ah=(t,e)=>R`<circle cx=${t} cy=${e} r="16" class="nf-hit" /><circle cx=${t} cy=${e} r="6" />`,t0=(t,e,n)=>R`<g class="nf-vertex" data-roof-vertex=${n}>${Ah(...t.toScreen(e))}</g>`,n0=(t,e,n)=>R`<g class="nf-vertex" data-roof-corner=${n}>${Ah(...t.toScreen(e))}</g>`;function r0(t,e,n,r){let{t:o,hass:i}=t.host,s=n.dormer?o("roof_dormer"):n.open?o("roof_open_short"):o(`roof_shape_${n.shape}`);return`${e.isFixed(n)?"\u{1F512} ":""}${r+1} \xB7 ${s} \xB7 ${j(i,Xt(n),1)} m`}function ka(t,e){let n=t.host.doc.settings.roof,r=n.type==="custom"?n.sections??[]:[],o=t.host.admin,i=(s,l)=>{let a=s.id===e.sectionId,c=ve(s),d=(s.shape==="flat"||s.shape==="parapet")&&s.points&&s.points.length>=3?s.points:null,u=Yo(r,s),p=u?ve(Hs(u,s)):c,h=d??[p.at(p.u0,0),p.at(p.u1,0),p.at(p.u1,p.w),p.at(p.u0,p.w)],g=((s.shape==="flat"||s.shape==="parapet"?null:Qt(s,{u0:0,u1:0,a:0,b:0}))?.ridges??[]).map(([C,B])=>{let[q,ye]=t.toScreen(c.at(C[0],C[1])),[$t,V]=t.toScreen(c.at(B[0],B[1]));return R`<line x1=${q} y1=${ye} x2=${$t} y2=${V} />`}),[y,b]=t.toScreen(c.at((c.u0+c.u1)/2,c.w/2)),v=a&&o&&!e.isFixed(s),w=[[0,0],[1,0],[1,1],[0,1]],x=s.shape==="flat"||s.shape==="parapet",[k,$,A,F]=[Math.min(s.x0,s.x1),Math.max(s.x0,s.x1),Math.min(s.z0,s.z1),Math.max(s.z0,s.z1)],T=d??(s.rotation?$r(s):[[k,A],[$,A],[$,F],[k,F]]),I=v&&x?T.map((C,B)=>_i(t,C,T[(B+1)%T.length],"roof",s.id,B)):_,z=v?R`${I}${d?d.map((C,B)=>t0(t,C,`${s.id}:${B}`)):w.map(([C,B])=>n0(t,[C?$:k,B?F:A],`${s.id}:${C}:${B}`))}`:_;return R`<g data-roof=${s.id} class=${`nf-roof-sec${a?" nf-roof-sel":""}`}>
<polygon points=${it(t,h)} />
<g class="nf-roof-ridge">${g}</g>
<text x=${y} y=${b-14}>${r0(t,e,s,l)}</text>
@@ -821,7 +821,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${a?R`<text x=${s} y=${l+32} class="nf-energy-name">${c}</text>`:_}
<title>${c}</title>
</g>`};return R`<g class="nf-energy-markers">${r.map(o)}</g>`}function Ph(t,e){let{doc:n,hass:r}=t.host;if(!(n.settings.roof.sections??[]).some(s=>Cs(s,e.elevation+e.height)))return _;let i=[1.5,2].flatMap(s=>Ns({settings:n.settings},e.elevation,s).map(([l,a])=>{let[c,d]=t.toScreen(l),[u,p]=t.toScreen(a);return R`<line class="nf-headroom" x1=${c} y1=${d} x2=${u} y2=${p} />
<text class="nf-headroom-label" x=${(c+u)/2} y=${(d+p)/2-4}>${j(r,s,1)} m</text>`}));return R`${i}`}function Ih(t,e,n,r){if(!e)return _;let o=(i,s)=>{let l=[];return i.forEach((a,c)=>{if(a.floor_id!==e.id)return;let[d,u]=t.toScreen([a.x,a.z]),p=i[c+1];if(p?.floor_id===e.id){let[f,g]=t.toScreen([p.x,p.z]);l.push(R`<line x1=${d} y1=${u} x2=${f} y2=${g} />`)}let h=p&&p.floor_id!==e.id||c>0&&i[c-1].floor_id!==e.id;l.push(R`<circle cx=${d} cy=${u} r=${h?7:4} class=${h?"nf-route-riser":""} />`),s&&l.push(R`<text x=${d+8} y=${u-8}>${c+1}</text>`)}),R`<g class=${`nf-route${s?" nf-route-drawing":""}`}>${l}</g>`};return R`<g class="nf-routes">${n.filter(i=>i.key!==r?.key).map(i=>o(i.points,!1))}${r?o(r.points,!0):_}</g>`}function Dh(t,e){let n=t.host.doc.settings.roof.chimneys??[];if(n.length===0)return _;let r=new Map(U(t.host.doc).map(i=>[i.key,i])),o=i=>{let s=r.get(i.face);if(!s)return _;let{shape:l,w:a,d:c}=rn(i),{center:d,along:u,across:p}=Us(s,i),h=l==="round"||l==="steel"?Array.from({length:16},(f,g)=>[d[0]+Math.cos(g/16*2*Math.PI)*Math.min(a,c)/2,d[1]+Math.sin(g/16*2*Math.PI)*Math.min(a,c)/2]):[[-1,-1],[1,-1],[1,1],[-1,1]].map(([f,g])=>[d[0]+u[0]*a*f/2+p[0]*c*g/2,d[1]+u[1]*a*f/2+p[1]*c*g/2]);return R`<g data-chimney=${i.id} class=${`nf-chimney${i.id===e.chimneyId?" nf-roofwin-sel":""}`}><polygon points=${it(t,h)} /></g>`};return R`<g class="nf-roofwin-layer">${n.map(o)}</g>`}function s0(t,e,n){let[r,o]=[t+n/2,e-30];return R`<g class="nf-rotate" data-bg-rotate="1">
<text class="nf-headroom-label" x=${(c+u)/2} y=${(d+p)/2-4}>${j(r,s,1)} m</text>`}));return R`${i}`}function Ih(t,e,n,r){if(!e)return _;let o=(i,s)=>{let l=[];return i.forEach((a,c)=>{if(a.floor_id!==e.id)return;let[d,u]=t.toScreen([a.x,a.z]),p=i[c+1];if(p?.floor_id===e.id){let[f,g]=t.toScreen([p.x,p.z]);l.push(R`<line x1=${d} y1=${u} x2=${f} y2=${g} />`)}let h=p&&p.floor_id!==e.id||c>0&&i[c-1].floor_id!==e.id;l.push(R`<circle cx=${d} cy=${u} r=${h?7:4} class=${h?"nf-route-riser":""} />`),s&&l.push(R`<text x=${d+8} y=${u-8}>${c+1}</text>`)}),R`<g class=${`nf-route${s?" nf-route-drawing":""}`}>${l}</g>`};return R`<g class="nf-routes">${n.filter(i=>i.key!==r?.key).map(i=>o(i.points,!1))}${r?o(r.points,!0):_}</g>`}function Dh(t,e){let n=t.host.doc.settings.roof.chimneys??[];if(n.length===0)return _;let r=new Map(U(t.host.doc).map(i=>[i.key,i])),o=i=>{let s=r.get(i.face);if(!s)return _;let{shape:l,w:a,d:c}=on(i),{center:d,along:u,across:p}=Us(s,i),h=l==="round"||l==="steel"?Array.from({length:16},(f,g)=>[d[0]+Math.cos(g/16*2*Math.PI)*Math.min(a,c)/2,d[1]+Math.sin(g/16*2*Math.PI)*Math.min(a,c)/2]):[[-1,-1],[1,-1],[1,1],[-1,1]].map(([f,g])=>[d[0]+u[0]*a*f/2+p[0]*c*g/2,d[1]+u[1]*a*f/2+p[1]*c*g/2]);return R`<g data-chimney=${i.id} class=${`nf-chimney${i.id===e.chimneyId?" nf-roofwin-sel":""}`}><polygon points=${it(t,h)} /></g>`};return R`<g class="nf-roofwin-layer">${n.map(o)}</g>`}function s0(t,e,n){let[r,o]=[t+n/2,e-30];return R`<g class="nf-rotate" data-bg-rotate="1">
<line x1=${r} y1=${e} x2=${r} y2=${o} />
<circle cx=${r} cy=${o} r="16" class="nf-hit" />
<circle cx=${r} cy=${o} r="8" />
@@ -836,7 +836,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${s0(i,s,l)}`:_}
</g>${a0(t,e)}`}var l0="strict-origin-when-cross-origin",xa=new Map,Hh=new Map,bi=new Map;function c0(t){let e=xa.get(t);return e||(e=fetch(t,{referrerPolicy:l0,mode:"cors",credentials:"omit"}).then(async n=>n.ok&&(n.headers.get("content-type")??"").startsWith("image/")?await n.blob():null).catch(()=>null).then(n=>(n||setTimeout(()=>xa.delete(t),6e4),n)),xa.set(t,e)),e}function Lh(t,e){let n=Hh.get(t);if(n)return n;let r=bi.get(t);return r||(r=new Set,bi.set(t,r),c0(t).then(o=>{o&&Hh.set(t,URL.createObjectURL(o));let i=bi.get(t)??new Set;if(bi.delete(t),o)for(let s of i)s()})),r.add(e),null}function Ch(t,e){let n=e.map;if(!pi(n))return _;let r=sh(n),o=ih(n),[i,s]=t.toScreen([r.x,r.z]),l=t.scale;return R`<g class="nf-map" opacity=${r.opacity} pointer-events="none" transform="translate(${i} ${s}) rotate(${e.north??0})">
${rh(n.lat,n.lon,r.zoom).map(a=>({tile:a,href:Lh(oh(o,a),t.redraw)})).filter(a=>a.href).map(({tile:a,href:c})=>R`<image href=${c} x=${a.east*l} y=${-a.north*l} width=${a.size*l+.6} height=${a.size*l+.6} preserveAspectRatio="none" />`)}
</g>`}var $a=t=>Math.round(t*1e3)/1e3,Sa=(t,e)=>t.width*e,Kn=(t,e)=>[t.x+t.width/2,t.z+Sa(t,e)/2];function Nh(t,e,n){let[r,o]=[t[0]-e[0],t[1]-e[1]];return[e[0]+r*Math.cos(n)-o*Math.sin(n),e[1]+r*Math.sin(n)+o*Math.cos(n)]}var Bh=t=>((t+180)%360+360)%360-180;function Wh(t,e,n){return{x:$a(t[0]-e/2),z:$a(t[1]-n/2)}}function Vh(t,e,n,r){if(Math.hypot(r[0]-n[0],r[1]-n[1])<.05)return null;let o=Math.atan2(r[1]-n[1],r[0]-n[0]),i=Math.round(o/(Math.PI/2))*(Math.PI/2)-o;if(Math.abs(i)<1e-4)return null;let s=Nh(Kn(t,e),n,i),l=Math.round(Bh((t.rotation??0)+i*180/Math.PI)*100)/100;return{...t,rotation:l,...Wh(s,t.width,Sa(t,e))}}function Kh(t,e,n,r,o){let i=Math.hypot(r[0]-n[0],r[1]-n[1]);if(!(o>0)||i<1e-4)return null;let s=o/i,[l,a]=Kn(t,e),c=[n[0]+s*(l-n[0]),n[1]+s*(a-n[1])],d=t.width*s;return{...t,width:$a(d),...Wh(c,d,Sa(t,e)*s)}}function Gh(t,e,n){let r=Nh(n,Kn(t,e),-(t.rotation??0)*Math.PI/180);return[r[0]-t.x,r[1]-t.z]}function jh(t,e,n,r){let o=t+(n-e)*180/Math.PI;return Bh(r?Math.round(o/15)*15:Math.round(o*10)/10)}var d0=2048;async function Gn(t){let e=await createImageBitmap(t),n=Math.min(1,d0/Math.max(e.width,e.height)),r=document.createElement("canvas");return r.width=Math.round(e.width*n),r.height=Math.round(e.height*n),r.getContext("2d").drawImage(e,0,0,r.width,r.height),{data:r.toDataURL("image/jpeg",.85),aspect:r.height/r.width}}var yi=class{deps;editMode=!1;levelPoints=null;rulerPoints=null;rulerMetres=0;sectionOpen=!1;pictures={};loading=new Set;constructor(e){this.deps=e}get edit(){return this.editMode}set edit(e){this.editMode=e,this.deps.refresh()}get level(){return this.levelPoints}set level(e){this.levelPoints=e,this.deps.refresh()}get ruler(){return this.rulerPoints}set ruler(e){this.rulerPoints=e,this.deps.refresh()}get rulerLength(){return this.rulerMetres}set rulerLength(e){this.rulerMetres=e,this.deps.refresh()}get open(){return this.sectionOpen}set open(e){this.sectionOpen=e,this.deps.refresh()}get handlesShown(){let{host:e}=this.deps;return!!e.floor?.background&&e.admin&&this.deps.currentTool()==="select"&&this.editMode}picture(e){return e?this.pictures[e]:void 0}ensureLoaded(e){!this.pictures[e]&&!this.loading.has(e)&&this.load(e)}async load(e){let{host:n,api:r}=this.deps;if(n.hass){this.loading.add(e);try{let o=await r.fetchImage(n.hass,e),i=await this.aspectOf(o);this.pictures={...this.pictures,[e]:{url:o,aspect:i}},this.deps.refresh()}catch{}}}async aspectOf(e){let n=new Image;return n.src=e,await n.decode(),n.naturalHeight/n.naturalWidth}async upload(e){let{host:n,api:r}=this.deps;if(!e||!n.hass)return;let{data:o,aspect:i}=await this.deps.readPicture(e),s=D("img");await r.storeImage(n.hass,s,o),this.pictures={...this.pictures,[s]:{url:o,aspect:i}};let l=n.floor?.rooms??[],a=l.length>0?de(l.flatMap(d=>d.points)):null,c={image_id:s,x:a?a.x0:0,z:a?a.z0:0,width:a?Math.max(4,Math.round((a.x1-a.x0)*1e3)/1e3):12,opacity:.5};this.setBackground(c)}setBackground(e){this.deps.host.change((n,r)=>Object.assign(r,{background:e}))}toggleLevel(){this.levelPoints=this.levelPoints?null:[],this.rulerPoints=null,this.editMode=!1,this.deps.refresh()}toggleRuler(){this.rulerPoints=this.rulerPoints?null:[],this.levelPoints=null,this.editMode=!1,this.deps.refresh()}toggleEdit(){this.edit=!this.editMode,this.editMode&&this.deps.useSelectTool()}tapLevel(e){let n=[...this.levelPoints??[],e];if(n.length<2){this.level=n;return}this.level=null,this.straighten(n[0],n[1])}tapRuler(e){this.rulerPoints&&this.rulerPoints.length<2&&(this.ruler=[...this.rulerPoints,e])}straighten(e,n){let r=this.deps.host.floor?.background,o=this.picture(r?.image_id),i=r&&o?Vh(r,o.aspect,e,n):null;i&&this.setBackground(i)}applyRuler(){let e=this.deps.host.floor?.background,n=this.picture(e?.image_id),r=this.rulerPoints;if(!e||!n||!r||r.length<2)return;let o=Kh(e,n.aspect,r[0],r[1],this.rulerMetres);o&&(this.setBackground(o),this.rulerPoints=null,this.rulerMetres=0,this.deps.refresh())}};var Uh=.1,Ma=(t,e,n)=>m`<button class="nf-btn nf-wide ${t?"nf-primary":""}" aria-pressed=${t} @click=${n}>${e}</button>`;function u0(t,e){let n=e.ruler;if(!n)return _;if(n.length<2)return M(t.t(n.length>0?"bg_ruler_second":"bg_ruler_first"),"nf-wide");let r=Math.hypot(n[1][0]-n[0][0],n[1][1]-n[0][1]),o=()=>e.applyRuler();return m`${M(t.t("bg_ruler_length_hint",{m:j(t.hass,r,2)}),"nf-wide")}
</g>`}var $a=t=>Math.round(t*1e3)/1e3,Sa=(t,e)=>t.width*e,Gn=(t,e)=>[t.x+t.width/2,t.z+Sa(t,e)/2];function Nh(t,e,n){let[r,o]=[t[0]-e[0],t[1]-e[1]];return[e[0]+r*Math.cos(n)-o*Math.sin(n),e[1]+r*Math.sin(n)+o*Math.cos(n)]}var Bh=t=>((t+180)%360+360)%360-180;function Wh(t,e,n){return{x:$a(t[0]-e/2),z:$a(t[1]-n/2)}}function Vh(t,e,n,r){if(Math.hypot(r[0]-n[0],r[1]-n[1])<.05)return null;let o=Math.atan2(r[1]-n[1],r[0]-n[0]),i=Math.round(o/(Math.PI/2))*(Math.PI/2)-o;if(Math.abs(i)<1e-4)return null;let s=Nh(Gn(t,e),n,i),l=Math.round(Bh((t.rotation??0)+i*180/Math.PI)*100)/100;return{...t,rotation:l,...Wh(s,t.width,Sa(t,e))}}function Kh(t,e,n,r,o){let i=Math.hypot(r[0]-n[0],r[1]-n[1]);if(!(o>0)||i<1e-4)return null;let s=o/i,[l,a]=Gn(t,e),c=[n[0]+s*(l-n[0]),n[1]+s*(a-n[1])],d=t.width*s;return{...t,width:$a(d),...Wh(c,d,Sa(t,e)*s)}}function Gh(t,e,n){let r=Nh(n,Gn(t,e),-(t.rotation??0)*Math.PI/180);return[r[0]-t.x,r[1]-t.z]}function jh(t,e,n,r){let o=t+(n-e)*180/Math.PI;return Bh(r?Math.round(o/15)*15:Math.round(o*10)/10)}var d0=2048;async function jn(t){let e=await createImageBitmap(t),n=Math.min(1,d0/Math.max(e.width,e.height)),r=document.createElement("canvas");return r.width=Math.round(e.width*n),r.height=Math.round(e.height*n),r.getContext("2d").drawImage(e,0,0,r.width,r.height),{data:r.toDataURL("image/jpeg",.85),aspect:r.height/r.width}}var yi=class{deps;editMode=!1;levelPoints=null;rulerPoints=null;rulerMetres=0;sectionOpen=!1;pictures={};loading=new Set;constructor(e){this.deps=e}get edit(){return this.editMode}set edit(e){this.editMode=e,this.deps.refresh()}get level(){return this.levelPoints}set level(e){this.levelPoints=e,this.deps.refresh()}get ruler(){return this.rulerPoints}set ruler(e){this.rulerPoints=e,this.deps.refresh()}get rulerLength(){return this.rulerMetres}set rulerLength(e){this.rulerMetres=e,this.deps.refresh()}get open(){return this.sectionOpen}set open(e){this.sectionOpen=e,this.deps.refresh()}get handlesShown(){let{host:e}=this.deps;return!!e.floor?.background&&e.admin&&this.deps.currentTool()==="select"&&this.editMode}picture(e){return e?this.pictures[e]:void 0}ensureLoaded(e){!this.pictures[e]&&!this.loading.has(e)&&this.load(e)}async load(e){let{host:n,api:r}=this.deps;if(n.hass){this.loading.add(e);try{let o=await r.fetchImage(n.hass,e),i=await this.aspectOf(o);this.pictures={...this.pictures,[e]:{url:o,aspect:i}},this.deps.refresh()}catch{}}}async aspectOf(e){let n=new Image;return n.src=e,await n.decode(),n.naturalHeight/n.naturalWidth}async upload(e){let{host:n,api:r}=this.deps;if(!e||!n.hass)return;let{data:o,aspect:i}=await this.deps.readPicture(e),s=D("img");await r.storeImage(n.hass,s,o),this.pictures={...this.pictures,[s]:{url:o,aspect:i}};let l=n.floor?.rooms??[],a=l.length>0?de(l.flatMap(d=>d.points)):null,c={image_id:s,x:a?a.x0:0,z:a?a.z0:0,width:a?Math.max(4,Math.round((a.x1-a.x0)*1e3)/1e3):12,opacity:.5};this.setBackground(c)}setBackground(e){this.deps.host.change((n,r)=>Object.assign(r,{background:e}))}toggleLevel(){this.levelPoints=this.levelPoints?null:[],this.rulerPoints=null,this.editMode=!1,this.deps.refresh()}toggleRuler(){this.rulerPoints=this.rulerPoints?null:[],this.levelPoints=null,this.editMode=!1,this.deps.refresh()}toggleEdit(){this.edit=!this.editMode,this.editMode&&this.deps.useSelectTool()}tapLevel(e){let n=[...this.levelPoints??[],e];if(n.length<2){this.level=n;return}this.level=null,this.straighten(n[0],n[1])}tapRuler(e){this.rulerPoints&&this.rulerPoints.length<2&&(this.ruler=[...this.rulerPoints,e])}straighten(e,n){let r=this.deps.host.floor?.background,o=this.picture(r?.image_id),i=r&&o?Vh(r,o.aspect,e,n):null;i&&this.setBackground(i)}applyRuler(){let e=this.deps.host.floor?.background,n=this.picture(e?.image_id),r=this.rulerPoints;if(!e||!n||!r||r.length<2)return;let o=Kh(e,n.aspect,r[0],r[1],this.rulerMetres);o&&(this.setBackground(o),this.rulerPoints=null,this.rulerMetres=0,this.deps.refresh())}};var Uh=.1,Ma=(t,e,n)=>m`<button class="nf-btn nf-wide ${t?"nf-primary":""}" aria-pressed=${t} @click=${n}>${e}</button>`;function u0(t,e){let n=e.ruler;if(!n)return _;if(n.length<2)return M(t.t(n.length>0?"bg_ruler_second":"bg_ruler_first"),"nf-wide");let r=Math.hypot(n[1][0]-n[0][0],n[1][1]-n[0][1]),o=()=>e.applyRuler();return m`${M(t.t("bg_ruler_length_hint",{m:j(t.hass,r,2)}),"nf-wide")}
<label class="nf-field"
>${t.t("bg_ruler_length")}
<input
@@ -873,7 +873,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</label>
<button class="nf-btn nf-danger nf-wide" @click=${()=>e.setBackground(null)}>${o("background_remove")}</button>`:_}
</div>
</details>`}var p0=t=>t.map((e,n)=>[e,t[(n+1)%t.length]]);function f0(t,e,n){let r=K(n,e),o=Q(r,r),i=o?Math.max(0,Math.min(1,Q(K(t,e),r)/o)):0;return fe(K(t,[e[0]+r[0]*i,e[1]+r[1]*i]))}function qh(t,e,n=.03){return t.every(r=>N(r,e)||p0(e).some(([o,i])=>f0(r,o,i)<=n))}var Ra=["straight","quarter","l","half","u","spiral"],Ea=["solid","stringer","mono","cantilever"],Aa=["none","left","right","both"],Fa=["headroom","full","none"],pt={shape:"straight",turn:"right",build:"solid",risers:!0,steps:null,run_width:null,down:!1,rail:"none",opening:"headroom",landing_after:null},Ta={straight:[1,3.2],quarter:[2.2,2.6],l:[2.2,2.8],half:[2,2.6],u:[2.2,2.6],spiral:[1.6,1.6]},ep=2,tp=40;var wi=(t,e)=>typeof e=="string"&&t.includes(e);function so(t){let e=t.stair??{},n=typeof e.steps=="number"&&Number.isFinite(e.steps)?Math.round(Math.min(tp,Math.max(ep,e.steps))):null,r=typeof e.run_width=="number"&&Number.isFinite(e.run_width)&&e.run_width>.2?e.run_width:null;return{shape:wi(Ra,e.shape)?e.shape:pt.shape,turn:e.turn==="left"?"left":"right",build:wi(Ea,e.build)?e.build:pt.build,risers:e.risers!==!1,steps:n,run_width:r,down:e.down===!0,rail:wi(Aa,e.rail)?e.rail:pt.rail,opening:wi(Fa,e.opening)?e.opening:pt.opening,landing_after:typeof e.landing_after=="number"&&Number.isFinite(e.landing_after)?Math.max(1,Math.round(e.landing_after)):null}}var oo=(t,e,n)=>[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n],Yh=(t,e)=>Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6;function np(t){let e=[];for(let n of t)(!e.length||!Yh(e[e.length-1],n))&&e.push(n);for(;e.length>1&&Yh(e[0],e[e.length-1]);)e.pop();return e}function io(t,e,n=!1){return{poly:np([...t,...[...e].reverse()]),landing:n,left:t,right:e}}function ro(t,e,n,r,o){let i=[];for(let s=0;s<o;s++){let[l,a]=[s/o,(s+1)/o];i.push(io([oo(t,n,l),oo(t,n,a)],[oo(e,r,l),oo(e,r,a)]))}return i}function Xh(t,e){let n=e;for(let r=0;r+1<t.length;r++){let o=Math.hypot(t[r+1][0]-t[r][0],t[r+1][1]-t[r][1]);if(n<=o||r+2===t.length)return oo(t[r],t[r+1],o?Math.min(1,n/o):0);n-=o}return t[t.length-1]}function m0(t,e,n){let r=[Xh(t,e)],o=0;for(let i=0;i+1<t.length;i++)o+=Math.hypot(t[i+1][0]-t[i][0],t[i+1][1]-t[i][1]),o>e+1e-6&&o<n-1e-6&&r.push(t[i+1]);return r.push(Xh(t,n)),r}var g0=t=>t.reduce((e,n,r)=>r?e+Math.hypot(n[0]-t[r-1][0],n[1]-t[r-1][1]):e,0);function Qh(t,e,n,r,o){let i=g0(t),s=[];for(let l=0;l<o;l++){let a=np([...l===0?[e]:[],n,...l===o-1?[r]:[]]);s.push(io(m0(t,i*l/o,i*(l+1)/o),a.length?a:[n]))}return s}function vi(t,e,n){if(t<=0)return[0,0];if(e<=.001)return[0,t];if(n<=.001)return[t,0];let r=Math.min(t,Math.max(0,Math.round(t*e/(e+n))));return[r,t-r]}function Jh(t,e){if(t.landing_after==null)return null;let n=Math.min(e-1,Math.max(1,Math.round(t.landing_after)))-1;return[n,e-1-n]}function _0(t,e,n,r){let[o,i,s,l]=[-e/2,e/2,-n/2,n/2];switch(t.shape){case"quarter":case"l":{let a=Math.min(t.run_width??Math.min(1,Math.min(e,n)/2),Math.min(e,n)-.05),c=[o+a,s+a],d=[[o,s+a],[o,s],[o+a,s]],u=t.shape==="l"?1:Math.min(r,r>=8?3:2),[p,h]=t.shape==="l"?Jh(t,r)??vi(r-u,n-a,e-a):vi(r-u,n-a,e-a),f=ro([o,l],[o+a,l],[o,s+a],c,p),g=t.shape==="l"?[io(d,[c],!0)]:Qh(d,c,c,c,u),y=ro([o+a,s],c,[i,s],[i,s+a],h);return{treads:[...f,...g,...y],flight:a,column:0}}case"half":case"u":{let a=Math.min(t.run_width??Math.min(1.1,(e-.1)/2),(e-.02)/2),c=s+a,d=[[o,c],[o,s],[i,s],[i,c]],[u,p]=[[o+a,c],[i-a,c]],h=t.shape==="u"?1:Math.min(r,r>=12?6:r>=8?4:2),[f,g]=t.shape==="u"?Jh(t,r)??vi(r-h,n-a,n-a):vi(r-h,n-a,n-a),y=ro([o,l],[o+a,l],[o,c],u,f),b=t.shape==="u"?[io(d,[u,p],!0)]:Qh(d,u,[0,c],p,h),v=ro([i,c],p,[i,l],[i-a,l],g);return{treads:[...y,...b,...v],flight:a,column:0}}case"spiral":{let a=Math.min(e,n)/2,c=Math.min(.08,a*.12),d=Math.min(.75,Math.max(.3,.22/(a*.6))),u=(h,f)=>[Math.cos(f)*h,Math.sin(f)*h],p=[];for(let h=0;h<r;h++){let[f,g]=[Math.PI+d*h,Math.PI+d*(h+1)],y=[0,.5,1].map(b=>u(a,f+(g-f)*b));p.push(io(y,[u(c,f),u(c,g)]))}return{treads:p,flight:a-c,column:c}}default:return{treads:ro([o,l],[i,l],[o,s],[i,s],r),flight:e,column:0}}}var b0=(t,e)=>t.steps??Math.min(tp,Math.max(ep,Math.round(Math.abs(e)/.18)));function hn(t,e,n,r){let o=b0(t,r),i=Math.abs(r)/o,s=_0(t,Math.max(.3,e),Math.max(.3,n),o),l=c=>[-c[0],c[1]];return{treads:s.treads.map((c,d)=>{let u=t.down?-i*(d+1):i*(d+1);return t.turn==="right"?{...c,top:u}:{poly:c.poly.map(l).reverse(),top:u,landing:c.landing,left:c.right.map(l),right:c.left.map(l)}}),rise:i,steps:o,column:s.column,flight:s.flight}}function ki(t){let e=t.poly.reduce((n,r)=>[n[0]+r[0],n[1]+r[1]],[0,0]);return[e[0]/t.poly.length,e[1]/t.poly.length]}var J=t=>Math.round(t*1e3)/1e3,y0=(t,e)=>((t+e)%360+360)%360;function rp(t,e){return{id:D("wall"),a:[J(t[0]),J(t[1])],b:[J(e[0]),J(e[1])],thickness:null}}function op(t,e){let n=Math.hypot(t.b[0]-t.a[0],t.b[1]-t.a[1])||1,r=Math.max(.1,e)/n;return[J(t.a[0]+(t.b[0]-t.a[0])*r),J(t.a[1]+(t.b[1]-t.a[1])*r)]}var ip=(t,e)=>({height:t>=e-.005?null:Math.max(.05,t)});function sp(t,e){return{id:D("hole"),type:"stairwell",x:J((t[0]+e[0])/2),z:J((t[1]+e[1])/2),w:J(Line truncated
</details>`}var p0=t=>t.map((e,n)=>[e,t[(n+1)%t.length]]);function f0(t,e,n){let r=K(n,e),o=Q(r,r),i=o?Math.max(0,Math.min(1,Q(K(t,e),r)/o)):0;return fe(K(t,[e[0]+r[0]*i,e[1]+r[1]*i]))}function qh(t,e,n=.03){return t.every(r=>N(r,e)||p0(e).some(([o,i])=>f0(r,o,i)<=n))}var Ra=["straight","quarter","l","half","u","spiral"],Ea=["solid","stringer","mono","cantilever"],Aa=["none","left","right","both"],Fa=["headroom","full","none"],ft={shape:"straight",turn:"right",build:"solid",risers:!0,steps:null,run_width:null,down:!1,rail:"none",opening:"headroom",landing_after:null},Ta={straight:[1,3.2],quarter:[2.2,2.6],l:[2.2,2.8],half:[2,2.6],u:[2.2,2.6],spiral:[1.6,1.6]},ep=2,tp=40;var wi=(t,e)=>typeof e=="string"&&t.includes(e);function so(t){let e=t.stair??{},n=typeof e.steps=="number"&&Number.isFinite(e.steps)?Math.round(Math.min(tp,Math.max(ep,e.steps))):null,r=typeof e.run_width=="number"&&Number.isFinite(e.run_width)&&e.run_width>.2?e.run_width:null;return{shape:wi(Ra,e.shape)?e.shape:ft.shape,turn:e.turn==="left"?"left":"right",build:wi(Ea,e.build)?e.build:ft.build,risers:e.risers!==!1,steps:n,run_width:r,down:e.down===!0,rail:wi(Aa,e.rail)?e.rail:ft.rail,opening:wi(Fa,e.opening)?e.opening:ft.opening,landing_after:typeof e.landing_after=="number"&&Number.isFinite(e.landing_after)?Math.max(1,Math.round(e.landing_after)):null}}var oo=(t,e,n)=>[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n],Yh=(t,e)=>Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6;function np(t){let e=[];for(let n of t)(!e.length||!Yh(e[e.length-1],n))&&e.push(n);for(;e.length>1&&Yh(e[0],e[e.length-1]);)e.pop();return e}function io(t,e,n=!1){return{poly:np([...t,...[...e].reverse()]),landing:n,left:t,right:e}}function ro(t,e,n,r,o){let i=[];for(let s=0;s<o;s++){let[l,a]=[s/o,(s+1)/o];i.push(io([oo(t,n,l),oo(t,n,a)],[oo(e,r,l),oo(e,r,a)]))}return i}function Xh(t,e){let n=e;for(let r=0;r+1<t.length;r++){let o=Math.hypot(t[r+1][0]-t[r][0],t[r+1][1]-t[r][1]);if(n<=o||r+2===t.length)return oo(t[r],t[r+1],o?Math.min(1,n/o):0);n-=o}return t[t.length-1]}function m0(t,e,n){let r=[Xh(t,e)],o=0;for(let i=0;i+1<t.length;i++)o+=Math.hypot(t[i+1][0]-t[i][0],t[i+1][1]-t[i][1]),o>e+1e-6&&o<n-1e-6&&r.push(t[i+1]);return r.push(Xh(t,n)),r}var g0=t=>t.reduce((e,n,r)=>r?e+Math.hypot(n[0]-t[r-1][0],n[1]-t[r-1][1]):e,0);function Qh(t,e,n,r,o){let i=g0(t),s=[];for(let l=0;l<o;l++){let a=np([...l===0?[e]:[],n,...l===o-1?[r]:[]]);s.push(io(m0(t,i*l/o,i*(l+1)/o),a.length?a:[n]))}return s}function vi(t,e,n){if(t<=0)return[0,0];if(e<=.001)return[0,t];if(n<=.001)return[t,0];let r=Math.min(t,Math.max(0,Math.round(t*e/(e+n))));return[r,t-r]}function Jh(t,e){if(t.landing_after==null)return null;let n=Math.min(e-1,Math.max(1,Math.round(t.landing_after)))-1;return[n,e-1-n]}function _0(t,e,n,r){let[o,i,s,l]=[-e/2,e/2,-n/2,n/2];switch(t.shape){case"quarter":case"l":{let a=Math.min(t.run_width??Math.min(1,Math.min(e,n)/2),Math.min(e,n)-.05),c=[o+a,s+a],d=[[o,s+a],[o,s],[o+a,s]],u=t.shape==="l"?1:Math.min(r,r>=8?3:2),[p,h]=t.shape==="l"?Jh(t,r)??vi(r-u,n-a,e-a):vi(r-u,n-a,e-a),f=ro([o,l],[o+a,l],[o,s+a],c,p),g=t.shape==="l"?[io(d,[c],!0)]:Qh(d,c,c,c,u),y=ro([o+a,s],c,[i,s],[i,s+a],h);return{treads:[...f,...g,...y],flight:a,column:0}}case"half":case"u":{let a=Math.min(t.run_width??Math.min(1.1,(e-.1)/2),(e-.02)/2),c=s+a,d=[[o,c],[o,s],[i,s],[i,c]],[u,p]=[[o+a,c],[i-a,c]],h=t.shape==="u"?1:Math.min(r,r>=12?6:r>=8?4:2),[f,g]=t.shape==="u"?Jh(t,r)??vi(r-h,n-a,n-a):vi(r-h,n-a,n-a),y=ro([o,l],[o+a,l],[o,c],u,f),b=t.shape==="u"?[io(d,[u,p],!0)]:Qh(d,u,[0,c],p,h),v=ro([i,c],p,[i,l],[i-a,l],g);return{treads:[...y,...b,...v],flight:a,column:0}}case"spiral":{let a=Math.min(e,n)/2,c=Math.min(.08,a*.12),d=Math.min(.75,Math.max(.3,.22/(a*.6))),u=(h,f)=>[Math.cos(f)*h,Math.sin(f)*h],p=[];for(let h=0;h<r;h++){let[f,g]=[Math.PI+d*h,Math.PI+d*(h+1)],y=[0,.5,1].map(b=>u(a,f+(g-f)*b));p.push(io(y,[u(c,f),u(c,g)]))}return{treads:p,flight:a-c,column:c}}default:return{treads:ro([o,l],[i,l],[o,s],[i,s],r),flight:e,column:0}}}var b0=(t,e)=>t.steps??Math.min(tp,Math.max(ep,Math.round(Math.abs(e)/.18)));function pn(t,e,n,r){let o=b0(t,r),i=Math.abs(r)/o,s=_0(t,Math.max(.3,e),Math.max(.3,n),o),l=c=>[-c[0],c[1]];return{treads:s.treads.map((c,d)=>{let u=t.down?-i*(d+1):i*(d+1);return t.turn==="right"?{...c,top:u}:{poly:c.poly.map(l).reverse(),top:u,landing:c.landing,left:c.right.map(l),right:c.left.map(l)}}),rise:i,steps:o,column:s.column,flight:s.flight}}function ki(t){let e=t.poly.reduce((n,r)=>[n[0]+r[0],n[1]+r[1]],[0,0]);return[e[0]/t.poly.length,e[1]/t.poly.length]}var J=t=>Math.round(t*1e3)/1e3,y0=(t,e)=>((t+e)%360+360)%360;function rp(t,e){return{id:D("wall"),a:[J(t[0]),J(t[1])],b:[J(e[0]),J(e[1])],thickness:null}}function op(t,e){let n=Math.hypot(t.b[0]-t.a[0],t.b[1]-t.a[1])||1,r=Math.max(.1,e)/n;return[J(t.a[0]+(t.b[0]-t.a[0])*r),J(t.a[1]+(t.b[1]-t.a[1])*r)]}var ip=(t,e)=>({height:t>=e-.005?null:Math.max(.05,t)});function sp(t,e){return{id:D("hole"),type:"stairwell",x:J((t[0]+e[0])/2),z:J((t[1]+e[1])/2),w:J(Line truncated
◠ ${t.t("arc")}
</button>`}function $i(t,e,n){let r=n.edit;if(!t.admin||r?.key!==e)return _;let o=t.t;return m`<span class="nf-wide nf-split-row" title=${o("arc_bulge_hint")}
>${E(t,o("arc_bulge"),r.bulge,i=>n.setEdit({...r,bulge:i,error:null}),.05)}
@@ -886,7 +886,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${O(t,r("area"),e.area_id??"",[["",r("no_area")],...Object.values(t.hass?.areas??{}).sort((a,c)=>a.name.localeCompare(c.name)).map(a=>[a.area_id,a.name])],a=>o({area_id:a||null}),{wide:!0,title:r("outdoor_area_hint")})}
${e.type==="pool"||e.type==="wild"||e.type==="bed"?m`${P(t,r("pool_temp"),e.temp_entity??null,void 0,L(t.hass,a=>a.startsWith("sensor.")&&t.hass?.states[a]?.attributes.device_class==="temperature"),a=>o({temp_entity:a&&a!=="none"?a:null}))}
${P(t,r("pool_pump"),e.pump_entity??null,void 0,L(t.hass,a=>/^(switch|fan|valve|input_boolean|binary_sensor)\./.test(a)),a=>o({pump_entity:a&&a!=="none"?a:null}))}`:_}
${xn(e.points)?m`${E(t,r("x"),i.x0,a=>n.setRectangle("x",a))} ${E(t,r("z"),i.z0,a=>n.setRectangle("z",a))}
${$n(e.points)?m`${E(t,r("x"),i.x0,a=>n.setRectangle("x",a))} ${E(t,r("z"),i.z0,a=>n.setRectangle("z",a))}
${E(t,r("width"),i.x1-i.x0,a=>n.setRectangle("w",a),.01,.1)} ${E(t,r("depth"),i.z1-i.z0,a=>n.setRectangle("d",a),.01,.1)}`:_}
${hs(e.type)?E(t,r("outdoor_height"),e.height??us[e.type],a=>o({height:Si(.1,6,a)}),.05,.1):_}
${E(t,r("outdoor_offset"),e.offset??0,a=>o({offset:Si(-10,10,a)||null}),.05)}
@@ -951,22 +951,22 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${t.admin?m`<div class="nf-actions">${xi(t,`wall:${e.id}`,n.arc)}<button class="nf-btn nf-danger" @click=${()=>n.remove()}>${r("delete")}</button></div>`:_}
<div class="nf-form">${$i(t,`wall:${e.id}`,n.arc)}</div>
${M(r("free_wall_hint"))}
</section>`}var Ct=t=>Math.round(t*1e3)/1e3,x0=2.4;function xp(t,e,n){let r=Bs(t,e[0],e[1],n[0],n[1]),o=r===null,i=Math.min(...t.floors.map(a=>a.elevation)),s=Ct(r??i+x0),l=o?6:t.settings.roof.pitch||35;return{id:D("roof"),x0:Ct(e[0]),z0:Ct(e[1]),x1:Ct(n[0]),z1:Ct(n[1]),shape:o?"pent":"gable",axis:n[0]-e[0]>=n[1]-e[1]?"x":"z",eave_a:s,eave_b:s,pitch_a:l,pitch_b:l,base:s,overhang:o?.15:null,...o?{open:!0}:{}}}function $p(t){let e=n=>Ct(n+1);return{...structuredClone(t),id:D("roof"),x0:e(t.x0),x1:e(t.x1),z0:e(t.z0),z1:e(t.z1)}}var Sp=(t,e)=>t.findIndex(n=>n.id===e)+1;function Oa(t){return t.points&&t.points.length>=3?t.points.map(([e,n])=>[e,n]):t.rotation?$r(t):[[t.x0,t.z0],[t.x1,t.z0],[t.x1,t.z1],[t.x0,t.z1]]}function Mp(t,e,n){let r=Oa(t);r.splice(e+1,0,[Ct(n[0]),Ct(n[1])]),t.points=r,Object.assign(t,Pt(r))}function Rp(t,e){return!t.points||t.points.length<=3||e<0||e>=t.points.length?!1:(t.points.splice(e,1),Object.assign(t,Pt(t.points)),!0)}var $0={light:"M8.5 17.5h7M9.5 20.5h5M12 2.5a6.5 6.5 0 0 0-3.5 12v1.5h7V14.5A6.5 6.5 0 0 0 12 2.5z",switch:"M6 5h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zM12 7.5v9M9 12h6",fan:"M12 11.5c-1-3.5 0-7 2.5-7s2 4-2.5 7zm.5.5c3.5-1 7 0 7 2.5s-4 2-7-2.5zm-.5.5c1 3.5 0 7-2.5 7s-2-4 2.5-7zm-.5-.5c-3.5 1-7 0-7-2.5s4-2 7 2.5z",cover:"M3.5 3.5h17v3h-17zM6 6.5v12M18 6.5v12M8.5 9.5h7M8.5 12.5h7M8.5 15.5h7",climate:"M12 15V5.5a2.5 2.5 0 0 0-5 0V15a4.5 4.5 0 1 0 5 0zM9.5 9v7M15 5.5h5M15 9.5h4",media:"M3.5 5.5h17v11h-17zM8 20.5h8M12 16.5v4M10 8.5v5l4.5-2.5z",lock:"M5.5 10.5h13v9.5h-13zM8 10.5V7.5a4 4 0 0 1 8 0v3M12 14v3",sensor:"M12 3.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17zM12 7.5v4.5l3.5 2",binary:"M5.5 20.5v-17h10v17M3.5 20.5h14M9 20.5v-13h4.5v13M12.5 14h.01",scene:"M5.5 18.5l8-8M14 3.5l1 2.5 2.5 1-2.5 1-1 2.5-1-2.5-2.5-1 2.5-1zM18.5 12l.7 1.8 1.8.7-1.8.7-.7 1.8-.7-1.8-1.8-.7 1.8-.7z",script:"M8.5 3.5h8.5a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2H7.5a2 2 0 0 1-2-2v-2h9M8.5 3.5a2 2 0 0 0-2 2v10M9.5 8.5h6M9.5 11.5h4"},Nt=t=>$0[t];function Mi(t,e){let n=new Set;for(let r of t?.placements??[])N([r.x,r.z],e.points)&&n.add(r.entity_id);for(let r of t?.furniture??[])ce(r.type)&&r.entity&&N([r.x,r.z],e.points)&&n.add(r.entity);return n}function Ep(t,e){let n=new Map;for(let r of t.floors){let o=[...r.placements.map(i=>[i.entity_id,i.x,i.z]),...r.furniture.filter(i=>ce(i.type)&&i.entity).map(i=>[i.entity,i.x,i.z])];for(let[i,s,l]of o){let a=r.rooms.find(c=>N([s,l],c.points));a&&a.id!==e.id&&n.set(i,a.name)}}return n}var Ap=(t,e)=>(t??[]).includes(e)?(t??[]).filter(n=>n!==e):[...t??[],e];function Ri(t,...e){let n=t.trim().toLowerCase();return!n||e.some(r=>(r??"").toLowerCase().includes(n))}function Fp(t,e){return t.map(n=>({o:n,r:e(n.id)})).sort((n,r)=>n.r-r.r).map(({o:n})=>n)}function Tp(t,e){let n=e,r=0;return{taken:t.map(i=>{let s=i.ids.slice(0,Math.max(0,n));return n-=s.length,r+=i.ids.length-s.length,[...s]}),left:r}}var Ha=50;function La(t,e,n,r,o,i,s){let l=e.includes(n);return m`<button class="nf-pin ${l?"nf-pin-on":""}" aria-pressed=${l} title=${t.t(l?i[0]:i[1])} @click=${()=>s.patchRoom({[r]:Ap(e,n)})}>${l?o[0]:o[1]}</button>`}function S0(t,e,n,r,o,i){let[s,l,a]=[e.hidden??[],e.no_state??[],e.panel??[]];return(c,d=!1,u=o)=>{let p=n.has(c),h=p?void 0:r.get(c),f=s.includes(c),g=Cn(t,c);return m`<div class="nf-row nf-dev-row ${d?"nf-dev-extra":""} ${f?"nf-dev-hidden":""}">
</section>`}var Nt=t=>Math.round(t*1e3)/1e3,x0=2.4;function xp(t,e,n){let r=Bs(t,e[0],e[1],n[0],n[1]),o=r===null,i=Math.min(...t.floors.map(a=>a.elevation)),s=Nt(r??i+x0),l=o?6:t.settings.roof.pitch||35;return{id:D("roof"),x0:Nt(e[0]),z0:Nt(e[1]),x1:Nt(n[0]),z1:Nt(n[1]),shape:o?"pent":"gable",axis:n[0]-e[0]>=n[1]-e[1]?"x":"z",eave_a:s,eave_b:s,pitch_a:l,pitch_b:l,base:s,overhang:o?.15:null,...o?{open:!0}:{}}}function $p(t){let e=n=>Nt(n+1);return{...structuredClone(t),id:D("roof"),x0:e(t.x0),x1:e(t.x1),z0:e(t.z0),z1:e(t.z1)}}var Sp=(t,e)=>t.findIndex(n=>n.id===e)+1;function Oa(t){return t.points&&t.points.length>=3?t.points.map(([e,n])=>[e,n]):t.rotation?$r(t):[[t.x0,t.z0],[t.x1,t.z0],[t.x1,t.z1],[t.x0,t.z1]]}function Mp(t,e,n){let r=Oa(t);r.splice(e+1,0,[Nt(n[0]),Nt(n[1])]),t.points=r,Object.assign(t,It(r))}function Rp(t,e){return!t.points||t.points.length<=3||e<0||e>=t.points.length?!1:(t.points.splice(e,1),Object.assign(t,It(t.points)),!0)}var $0={light:"M8.5 17.5h7M9.5 20.5h5M12 2.5a6.5 6.5 0 0 0-3.5 12v1.5h7V14.5A6.5 6.5 0 0 0 12 2.5z",switch:"M6 5h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2zM12 7.5v9M9 12h6",fan:"M12 11.5c-1-3.5 0-7 2.5-7s2 4-2.5 7zm.5.5c3.5-1 7 0 7 2.5s-4 2-7-2.5zm-.5.5c1 3.5 0 7-2.5 7s-2-4 2.5-7zm-.5-.5c-3.5 1-7 0-7-2.5s4-2 7 2.5z",cover:"M3.5 3.5h17v3h-17zM6 6.5v12M18 6.5v12M8.5 9.5h7M8.5 12.5h7M8.5 15.5h7",climate:"M12 15V5.5a2.5 2.5 0 0 0-5 0V15a4.5 4.5 0 1 0 5 0zM9.5 9v7M15 5.5h5M15 9.5h4",media:"M3.5 5.5h17v11h-17zM8 20.5h8M12 16.5v4M10 8.5v5l4.5-2.5z",lock:"M5.5 10.5h13v9.5h-13zM8 10.5V7.5a4 4 0 0 1 8 0v3M12 14v3",sensor:"M12 3.5a8.5 8.5 0 1 0 0 17 8.5 8.5 0 0 0 0-17zM12 7.5v4.5l3.5 2",binary:"M5.5 20.5v-17h10v17M3.5 20.5h14M9 20.5v-13h4.5v13M12.5 14h.01",scene:"M5.5 18.5l8-8M14 3.5l1 2.5 2.5 1-2.5 1-1 2.5-1-2.5-2.5-1 2.5-1zM18.5 12l.7 1.8 1.8.7-1.8.7-.7 1.8-.7-1.8-1.8-.7 1.8-.7z",script:"M8.5 3.5h8.5a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2H7.5a2 2 0 0 1-2-2v-2h9M8.5 3.5a2 2 0 0 0-2 2v10M9.5 8.5h6M9.5 11.5h4"},Bt=t=>$0[t];function Mi(t,e){let n=new Set;for(let r of t?.placements??[])N([r.x,r.z],e.points)&&n.add(r.entity_id);for(let r of t?.furniture??[])ce(r.type)&&r.entity&&N([r.x,r.z],e.points)&&n.add(r.entity);return n}function Ep(t,e){let n=new Map;for(let r of t.floors){let o=[...r.placements.map(i=>[i.entity_id,i.x,i.z]),...r.furniture.filter(i=>ce(i.type)&&i.entity).map(i=>[i.entity,i.x,i.z])];for(let[i,s,l]of o){let a=r.rooms.find(c=>N([s,l],c.points));a&&a.id!==e.id&&n.set(i,a.name)}}return n}var Ap=(t,e)=>(t??[]).includes(e)?(t??[]).filter(n=>n!==e):[...t??[],e];function Ri(t,...e){let n=t.trim().toLowerCase();return!n||e.some(r=>(r??"").toLowerCase().includes(n))}function Fp(t,e){return t.map(n=>({o:n,r:e(n.id)})).sort((n,r)=>n.r-r.r).map(({o:n})=>n)}function Tp(t,e){let n=e,r=0;return{taken:t.map(i=>{let s=i.ids.slice(0,Math.max(0,n));return n-=s.length,r+=i.ids.length-s.length,[...s]}),left:r}}var Ha=50;function La(t,e,n,r,o,i,s){let l=e.includes(n);return m`<button class="nf-pin ${l?"nf-pin-on":""}" aria-pressed=${l} title=${t.t(l?i[0]:i[1])} @click=${()=>s.patchRoom({[r]:Ap(e,n)})}>${l?o[0]:o[1]}</button>`}function S0(t,e,n,r,o,i){let[s,l,a]=[e.hidden??[],e.no_state??[],e.panel??[]];return(c,d=!1,u=o)=>{let p=n.has(c),h=p?void 0:r.get(c),f=s.includes(c),g=Nn(t,c);return m`<div class="nf-row nf-dev-row ${d?"nf-dev-extra":""} ${f?"nf-dev-hidden":""}">
<button class="nf-dev-name ${p?"":"nf-muted"}" ?disabled=${!p} @click=${()=>i.select(c)}>
${g?m`<ha-icon class="nf-dev-icon" style="--mdc-icon-size:16px" .icon=${g}></ha-icon>`:m`<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d=${Nt((t.hass?Ne(t.hass,c):X(c))??"sensor")} /></svg>`}
${g?m`<ha-icon class="nf-dev-icon" style="--mdc-icon-size:16px" .icon=${g}></ha-icon>`:m`<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d=${Bt((t.hass?Ne(t.hass,c):X(c))??"sensor")} /></svg>`}
<span>${W(t.hass,c,u)}${h?m`<small class="nf-muted"> · ${t.t("devices_placed_in",{room:h})}</small>`:_}</span>
</button>
${t.admin?La(t,s,c,"hidden",["\u{1F648}","\u{1F441}"],["panel_unhide","panel_hide"],i):_}
${t.admin&&!f?La(t,l,c,"no_state",["\u2205","Aa"],["panel_state_show","panel_state_hide"],i):_}
${t.admin&&!p?La(t,a,c,"panel",["\u2605","\u2606"],["panel_unpin","panel_pin"],i):_}
${t.admin?p?m`<button class="nf-link" @click=${()=>i.remove(c)}>${t.t("devices_remove")}</button>`:m`<button class="nf-link" @click=${()=>i.place([c])}>${t.t("devices_place")}</button>`:_}
</div>`}}function M0(t,e,n,r,o){let{hass:i}=t;if(!i)return m``;let s=d=>d>0?M(t.t("devices_narrow",{n:d})):_,l=M(t.t("devices_none")),a=e.deviceQuery;if(o==="other"){let d=ud(i,n.area_id).map(f=>({...f,ids:f.ids.filter(g=>Ri(a,`${W(i,g,f.name)} ${g} ${f.name}`))})),{taken:u,left:p}=Tp(d,Ha),h=d.map((f,g)=>u[g].length>0?m`<div class="nf-dev-area">${f.name}</div>${u[g].map(y=>r(y,!1,f.name))}`:_);return u.some(f=>f.length>0)?m`<div class="nf-room-list">${h}</div>${s(p)}`:l}let c=hd(i).filter(d=>Ri(a,`${W(i,d)} ${d} `));return c.length>0?m`<div class="nf-room-list">${c.slice(0,Ha).map(d=>r(d))}</div>${s(c.length-Math.min(c.length,Ha))}`:l}function R0(t,e,n,r,o,i,s){let{hass:l}=t,a=l?be(l,n).filter(b=>Mt(Ne(l,b))):[];if(!n.area_id)return M(t.t("devices_none_area"));if(a.length===0)return M(t.t("devices_none"));let c=l?Sn(l,a):[],d=c.map(b=>b.primary).filter(b=>!o.has(b)),u=e.deviceQuery,p=(t.floor?.placements??[]).filter(b=>X(b.entity_id)==="light"&&(b.mount??"ceiling")==="ceiling"&&N([b.x,b.z],n.points)).length,h=m`<input class="nf-search" type="search" placeholder=${t.t("devices_search")} .value=${u} @input=${b=>e.deviceQuery=b.target.value} />`,f=b=>Ri(u,W(l,b,i),b),g=b=>{let v=b.others.filter(f),w=e.isUnfolded(b.primary)||!!u.trim()&&v.length>0;return!f(b.primary)&&v.length===0?_:m`${r(b.primary)}
</div>`}}function M0(t,e,n,r,o){let{hass:i}=t;if(!i)return m``;let s=d=>d>0?M(t.t("devices_narrow",{n:d})):_,l=M(t.t("devices_none")),a=e.deviceQuery;if(o==="other"){let d=ud(i,n.area_id).map(f=>({...f,ids:f.ids.filter(g=>Ri(a,`${W(i,g,f.name)} ${g} ${f.name}`))})),{taken:u,left:p}=Tp(d,Ha),h=d.map((f,g)=>u[g].length>0?m`<div class="nf-dev-area">${f.name}</div>${u[g].map(y=>r(y,!1,f.name))}`:_);return u.some(f=>f.length>0)?m`<div class="nf-room-list">${h}</div>${s(p)}`:l}let c=hd(i).filter(d=>Ri(a,`${W(i,d)} ${d} `));return c.length>0?m`<div class="nf-room-list">${c.slice(0,Ha).map(d=>r(d))}</div>${s(c.length-Math.min(c.length,Ha))}`:l}function R0(t,e,n,r,o,i,s){let{hass:l}=t,a=l?be(l,n).filter(b=>Mt(Ne(l,b))):[];if(!n.area_id)return M(t.t("devices_none_area"));if(a.length===0)return M(t.t("devices_none"));let c=l?Mn(l,a):[],d=c.map(b=>b.primary).filter(b=>!o.has(b)),u=e.deviceQuery,p=(t.floor?.placements??[]).filter(b=>X(b.entity_id)==="light"&&(b.mount??"ceiling")==="ceiling"&&N([b.x,b.z],n.points)).length,h=m`<input class="nf-search" type="search" placeholder=${t.t("devices_search")} .value=${u} @input=${b=>e.deviceQuery=b.target.value} />`,f=b=>Ri(u,W(l,b,i),b),g=b=>{let v=b.others.filter(f),w=e.isUnfolded(b.primary)||!!u.trim()&&v.length>0;return!f(b.primary)&&v.length===0?_:m`${r(b.primary)}
${b.others.length>0?m`<button class="nf-more" @click=${()=>e.toggleUnfolded(b.primary)}>${w?t.t("devices_less"):t.t("devices_more",{n:b.others.length})}</button>`:_}
${w?(u.trim()?v:b.others).map(x=>r(x,!0)):_}`},y=()=>s.confirm(t.t("devices_place_all_confirm",{n:d.length}))&&s.place(d);return m`${t.admin&&p>=2?m`<button class="nf-btn nf-wide-btn" @click=${()=>s.spreadLights(n)}>${t.t("lights_spread")}</button>`:_}
${a.length>8?h:_}
<div class="nf-room-list">${c.map(g)}</div>
${t.admin&&d.length>1?m`<button class="nf-link nf-place-all" @click=${y}>${t.t("devices_place_all_n",{n:d.length})}</button>`:_}
${M(t.t("devices_hint"))}`}function Ca(t,e,n,r){let{hass:o}=t,i=n.area_id?o?.areas?.[n.area_id]?.name:void 0,s=Mi(t.floor,n),l=S0(t,n,s,Ep(t.doc,n),i,r),a=t.admin?e.deviceSource:"area",c=o?Sn(o,be(o,n).filter(p=>Mt(Ne(o,p)))).length:0,d=[["area",`${t.t("devices_src_area")}${c>0?` (${c})`:""}`],["other",t.t("devices_src_other")],["none",t.t("devices_src_none")]],u=m`<input class="nf-search" type="search" placeholder=${t.t("devices_search")} .value=${e.deviceQuery} @input=${p=>e.deviceQuery=p.target.value} />`;return m`<section>
${M(t.t("devices_hint"))}`}function Ca(t,e,n,r){let{hass:o}=t,i=n.area_id?o?.areas?.[n.area_id]?.name:void 0,s=Mi(t.floor,n),l=S0(t,n,s,Ep(t.doc,n),i,r),a=t.admin?e.deviceSource:"area",c=o?Mn(o,be(o,n).filter(p=>Mt(Ne(o,p)))).length:0,d=[["area",`${t.t("devices_src_area")}${c>0?` (${c})`:""}`],["other",t.t("devices_src_other")],["none",t.t("devices_src_none")]],u=m`<input class="nf-search" type="search" placeholder=${t.t("devices_search")} .value=${e.deviceQuery} @input=${p=>e.deviceQuery=p.target.value} />`;return m`<section>
<h3>${t.t("devices")}</h3>
${M(t.t("devices_panel_hint"))}
${t.admin?m`<div class="nf-seg nf-dev-source">${d.map(([p,h])=>m`<button aria-pressed=${a===p} @click=${()=>e.deviceSource=p}>${h}</button>`)}</div>`:_}
@@ -975,7 +975,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<summary>${t.t("climate")}</summary>
<div class="nf-form">${s("temperature",t.t("climate_temperature"))} ${s("humidity",t.t("climate_humidity"))} ${s("co2",t.t("climate_co2"))}</div>
${M(t.t("climate_hint"))}
</details>`}var Na="metric",Ip=t=>{Na=t==="imperial"?"imperial":"metric"};var Pp=.3048;function he(t,e,n=2,r=Na){if(r==="metric")return`${j(t,e,n)} m`;let o=e<0?"\u2212":"",i=Math.round(Math.abs(e)/.0254*2),s=Math.floor(i/24),l=i-s*24,a=`${Math.floor(l/2)}${l%2?"\xBD":""}`;return s?`${o}${s}\u2032 ${a}\u2033`:`${o}${a}\u2033`}function Ae(t,e,n=Na){return n==="metric"?`${j(t,e,1)} m\xB2`:`${j(t,e/(Pp*Pp),0)} ft\xB2`}var E0=.15,A0=(t,e)=>Math.abs((t-e+540)%360-180);function F0(t,e,n,r){return t.rooms.some(o=>o.id!==e.id&&o.points.some((i,s)=>{let l=o.points[(s+1)%o.points.length];return Math.abs(Q(K(i,n),r))<.02&&Math.abs(Q(K(l,n),r))<.02}))}function Wa(t,e,n,r){let o=e.points,[i,s]=[o[n],o[(n+1)%o.length]],l=fe(K(s,i)),a=ge(o)>=0?1:-1,c=[(s[0]-i[0])/l,(s[1]-i[1])/l],d=[-c[1]*a||0,c[0]*a||0],u=c[0]*d[1]-c[1]*d[0]>0,p=e.wall_heights?.[n],h=e.ceiling??t.height,f=typeof p=="number"?p:Array.isArray(p)?Math.max(...p.map(b=>b??h)):h,g=e.wall_slopes?.[n],y=typeof g=="number"&&typeof p=="number"?g:f;return{origin:u?i:s,along:u?c:[-c[0],-c[1]],normal:d,length:l,face:F0(t,e,i,d)?r/2:0,heightLeft:u?f:y,heightRight:u?y:f}}function Ba(t,e){let n=K(e,t.origin);return{u:Q(n,t.along),depth:Q(n,t.normal)-t.face}}function T0(t,e){let n=t.rooms.find(s=>s.id===e.room_id);if(!n||e.wall)return null;let[r,o]=[n.points[e.edge],n.points[(e.edge+1)%n.points.length]];if(!r||!o)return null;let i=fe(K(o,r))||1;return[r[0]+(o[0]-r[0])*e.offset/i,r[1]+(o[1]-r[1])*e.offset/i]}var Dp=t=>G(t.type)?.mount==="wall"||t.type==="lamp_wall"||t.mount_y!=null;function Op(t,e,n){let r=[];for(let i of t.openings){let s=T0(t,i);if(!s)continue;let{u:l,depth:a}=Ba(n,s);Math.abs(a+n.face)>.3||l<-.01||l>n.length+.01||r.push({id:i.id,kind:"opening",type:i.type,x0:l-i.width/2,x1:l+i.width/2,y0:i.sill,y1:i.sill+i.height,lifts:i.type==="window"})}let o=Math.atan2(-n.normal[0],n.normal[1])*180/Math.PI;for(let i of t.furniture){if(!N([i.x,i.z],e.points)||A0(i.rotation,o)>20)continue;let{u:s,depth:l}=Ba(n,[i.x,i.z]);if(l-i.d/2>E0||s<0||s>n.length)continue;let a=At(t,i);r.push({id:i.id,kind:"furniture",type:i.type,x0:s-i.w/2,x1:s+i.w/2,y0:a,y1:a+i.h,lifts:Dp(i)})}return r.sort((i,s)=>+(i.kind==="furniture")-+(s.kind==="furniture")||i.x0-s.x0)}var ao=t=>Math.round(t*1e3)/1e3;function Hp(t,e,n,r){let o=Ba(t,[e.x,e.z]).depth,i=Math.min(t.length-e.w/2,Math.max(e.w/2,n+e.w/2)),s=[t.origin[0]+t.along[0]*i+t.normal[0]*(o+t.face),t.origin[1]+t.along[1]*i+t.normal[1]*(o+t.face)];return{x:ao(s[0]),z:ao(s[1]),...r!==null&&Dp(e)?{mount_y:ao(Math.max(0,r))}:{}}}function Lp(t,e,n,r,o){let[i]=[e.points[n.edge]],s=Math.min(t.length-n.width/2,Math.max(n.width/2,r+n.width/2)),l=fe(K(i,t.origin))<1e-6?s:t.length-s;return{offset:ao(l),...o!==null&&n.type==="window"?{sill:ao(Math.max(0,o))}:{}}}var Cp=.01,Np=t=>Math.round(t/Cp)*Cp,Va=class extends ne{static properties={host:{attribute:!1},doc:{attribute:!1},roomId:{},edge:{type:Number},_sel:{state:!0},_drag:{state:!0}};constructor(){super(),this._sel=null,this._drag=null}get room(){return this.host.floor?.rooms.find(e=>e.id===this.roomId)}frame(){let e=this.room;return e&&this.host.floor?Wa(this.host.floor,e,this.edge,this.host.doc.settings.wall_interior):null}boxes(){let e=this.room,n=this.frame();return e&&n&&this.host.floor?Op(this.host.floor,e,n):[]}place(e,n,r){let o=this.room,i=this.frame();!o||!i||this.host.change((s,l)=>{if(e.kind==="furniture"){let a=l.furniture.find(c=>c.id===e.id);a&&Object.assign(a,Hp(i,a,n,e.lifts?r:null))}else{let a=l.openings.find(d=>d.id===e.id),c=l.rooms.find(d=>d.id===a?.room_id);a&&c&&Object.assign(a,Lp(c.id===o.id?i:Wa(l,c,a.edge,this.host.doc.settings.wall_interior),c,a,n,e.lifts?r:null))}})}toWall(e){let r=this.renderRoot.querySelector("svg").getScreenCTM()?.inverse();if(!r)return[0,0];let o=new DOMPoint(e.clientX,e.clientY).matrixTransform(r);return[o.x,-o.y]}down(e,n){if(this._sel=n.id,!this.host.admin)return;e.currentTarget.setPointerCapture(e.pointerId);let[r,o]=this.toWall(e);this._drag={id:n.id,x0:n.x0,y0:n.y0,startU:r,startY:o,fromX:n.x0,fromY:n.y0}}move(e,n){let r=this._drag;if(!r||r.id!==n.id)return;let[o,i]=this.toWall(e),s=this.frame(),l=n.x1-n.x0,a=Math.min((s?.length??0)-l,Math.max(0,Np(r.fromX+o-r.startU))),c=n.lifts?Math.max(0,Np(r.fromY+i-r.startY)):r.fromY;this._drag={...r,x0:a,y0:c}}up(e){let n=this._drag;this._drag=null,!(!n||n.id!==e.id||Math.abs(n.x0-n.fromX)<1e-6&&Math.abs(n.y0-n.fromY)<1e-6)&&this.place(e,n.x0,n.y0)}nameOf(e){if(e.kind==="furniture")return this.host.floor?.furniture.find(o=>o.id===e.id)?.name||qe(this.host.hass,e.type);let n=this.host.floor?.openings.find(r=>r.id===e.id);return n?this.host.t(`preset_${kn(n)}`):e.type}updated(e){(e.has("edge")||e.has("roomId"))&&(this._sel=null)}render(){let e=this.host.t,n=this.room,r=this.frame();if(!n||!r)return _;let o=n.points.length,i=h=>he(this.host.hass,h),s=this.boxes().map(h=>this._drag?.id===h.id?{...h,x1:this._drag.x0+(h.x1-h.x0),y1:this._drag.y0+(h.y1-h.y0),x0:this._drag.x0,y0:this._drag.y0}:h),l=Math.max(r.heLine truncated
</details>`}var Na="metric",Ip=t=>{Na=t==="imperial"?"imperial":"metric"};var Pp=.3048;function he(t,e,n=2,r=Na){if(r==="metric")return`${j(t,e,n)} m`;let o=e<0?"\u2212":"",i=Math.round(Math.abs(e)/.0254*2),s=Math.floor(i/24),l=i-s*24,a=`${Math.floor(l/2)}${l%2?"\xBD":""}`;return s?`${o}${s}\u2032 ${a}\u2033`:`${o}${a}\u2033`}function Ae(t,e,n=Na){return n==="metric"?`${j(t,e,1)} m\xB2`:`${j(t,e/(Pp*Pp),0)} ft\xB2`}var E0=.15,A0=(t,e)=>Math.abs((t-e+540)%360-180);function F0(t,e,n,r){return t.rooms.some(o=>o.id!==e.id&&o.points.some((i,s)=>{let l=o.points[(s+1)%o.points.length];return Math.abs(Q(K(i,n),r))<.02&&Math.abs(Q(K(l,n),r))<.02}))}function Wa(t,e,n,r){let o=e.points,[i,s]=[o[n],o[(n+1)%o.length]],l=fe(K(s,i)),a=ge(o)>=0?1:-1,c=[(s[0]-i[0])/l,(s[1]-i[1])/l],d=[-c[1]*a||0,c[0]*a||0],u=c[0]*d[1]-c[1]*d[0]>0,p=e.wall_heights?.[n],h=e.ceiling??t.height,f=typeof p=="number"?p:Array.isArray(p)?Math.max(...p.map(b=>b??h)):h,g=e.wall_slopes?.[n],y=typeof g=="number"&&typeof p=="number"?g:f;return{origin:u?i:s,along:u?c:[-c[0],-c[1]],normal:d,length:l,face:F0(t,e,i,d)?r/2:0,heightLeft:u?f:y,heightRight:u?y:f}}function Ba(t,e){let n=K(e,t.origin);return{u:Q(n,t.along),depth:Q(n,t.normal)-t.face}}function T0(t,e){let n=t.rooms.find(s=>s.id===e.room_id);if(!n||e.wall)return null;let[r,o]=[n.points[e.edge],n.points[(e.edge+1)%n.points.length]];if(!r||!o)return null;let i=fe(K(o,r))||1;return[r[0]+(o[0]-r[0])*e.offset/i,r[1]+(o[1]-r[1])*e.offset/i]}var Dp=t=>G(t.type)?.mount==="wall"||t.type==="lamp_wall"||t.mount_y!=null;function Op(t,e,n){let r=[];for(let i of t.openings){let s=T0(t,i);if(!s)continue;let{u:l,depth:a}=Ba(n,s);Math.abs(a+n.face)>.3||l<-.01||l>n.length+.01||r.push({id:i.id,kind:"opening",type:i.type,x0:l-i.width/2,x1:l+i.width/2,y0:i.sill,y1:i.sill+i.height,lifts:i.type==="window"})}let o=Math.atan2(-n.normal[0],n.normal[1])*180/Math.PI;for(let i of t.furniture){if(!N([i.x,i.z],e.points)||A0(i.rotation,o)>20)continue;let{u:s,depth:l}=Ba(n,[i.x,i.z]);if(l-i.d/2>E0||s<0||s>n.length)continue;let a=At(t,i);r.push({id:i.id,kind:"furniture",type:i.type,x0:s-i.w/2,x1:s+i.w/2,y0:a,y1:a+i.h,lifts:Dp(i)})}return r.sort((i,s)=>+(i.kind==="furniture")-+(s.kind==="furniture")||i.x0-s.x0)}var ao=t=>Math.round(t*1e3)/1e3;function Hp(t,e,n,r){let o=Ba(t,[e.x,e.z]).depth,i=Math.min(t.length-e.w/2,Math.max(e.w/2,n+e.w/2)),s=[t.origin[0]+t.along[0]*i+t.normal[0]*(o+t.face),t.origin[1]+t.along[1]*i+t.normal[1]*(o+t.face)];return{x:ao(s[0]),z:ao(s[1]),...r!==null&&Dp(e)?{mount_y:ao(Math.max(0,r))}:{}}}function Lp(t,e,n,r,o){let[i]=[e.points[n.edge]],s=Math.min(t.length-n.width/2,Math.max(n.width/2,r+n.width/2)),l=fe(K(i,t.origin))<1e-6?s:t.length-s;return{offset:ao(l),...o!==null&&n.type==="window"?{sill:ao(Math.max(0,o))}:{}}}var Cp=.01,Np=t=>Math.round(t/Cp)*Cp,Va=class extends ne{static properties={host:{attribute:!1},doc:{attribute:!1},roomId:{},edge:{type:Number},_sel:{state:!0},_drag:{state:!0}};constructor(){super(),this._sel=null,this._drag=null}get room(){return this.host.floor?.rooms.find(e=>e.id===this.roomId)}frame(){let e=this.room;return e&&this.host.floor?Wa(this.host.floor,e,this.edge,this.host.doc.settings.wall_interior):null}boxes(){let e=this.room,n=this.frame();return e&&n&&this.host.floor?Op(this.host.floor,e,n):[]}place(e,n,r){let o=this.room,i=this.frame();!o||!i||this.host.change((s,l)=>{if(e.kind==="furniture"){let a=l.furniture.find(c=>c.id===e.id);a&&Object.assign(a,Hp(i,a,n,e.lifts?r:null))}else{let a=l.openings.find(d=>d.id===e.id),c=l.rooms.find(d=>d.id===a?.room_id);a&&c&&Object.assign(a,Lp(c.id===o.id?i:Wa(l,c,a.edge,this.host.doc.settings.wall_interior),c,a,n,e.lifts?r:null))}})}toWall(e){let r=this.renderRoot.querySelector("svg").getScreenCTM()?.inverse();if(!r)return[0,0];let o=new DOMPoint(e.clientX,e.clientY).matrixTransform(r);return[o.x,-o.y]}down(e,n){if(this._sel=n.id,!this.host.admin)return;e.currentTarget.setPointerCapture(e.pointerId);let[r,o]=this.toWall(e);this._drag={id:n.id,x0:n.x0,y0:n.y0,startU:r,startY:o,fromX:n.x0,fromY:n.y0}}move(e,n){let r=this._drag;if(!r||r.id!==n.id)return;let[o,i]=this.toWall(e),s=this.frame(),l=n.x1-n.x0,a=Math.min((s?.length??0)-l,Math.max(0,Np(r.fromX+o-r.startU))),c=n.lifts?Math.max(0,Np(r.fromY+i-r.startY)):r.fromY;this._drag={...r,x0:a,y0:c}}up(e){let n=this._drag;this._drag=null,!(!n||n.id!==e.id||Math.abs(n.x0-n.fromX)<1e-6&&Math.abs(n.y0-n.fromY)<1e-6)&&this.place(e,n.x0,n.y0)}nameOf(e){if(e.kind==="furniture")return this.host.floor?.furniture.find(o=>o.id===e.id)?.name||qe(this.host.hass,e.type);let n=this.host.floor?.openings.find(r=>r.id===e.id);return n?this.host.t(`preset_${xn(n)}`):e.type}updated(e){(e.has("edge")||e.has("roomId"))&&(this._sel=null)}render(){let e=this.host.t,n=this.room,r=this.frame();if(!n||!r)return _;let o=n.points.length,i=h=>he(this.host.hass,h),s=this.boxes().map(h=>this._drag?.id===h.id?{...h,x1:this._drag.x0+(h.x1-h.x0),y1:this._drag.y0+(h.y1-h.y0),x0:this._drag.x0,y0:this._drag.y0}:h),l=Math.max(r.heLine truncated
<line x1="0" x2=${d.x0} y1=${-(d.y0+d.y1)/2} y2=${-(d.y0+d.y1)/2} />
<text x=${d.x0/2} y=${-(d.y0+d.y1)/2-.06} text-anchor="middle" font-size="0.11">${i(d.x0)}</text>
<line x1=${d.x1} x2=${r.length} y1=${-(d.y0+d.y1)/2} y2=${-(d.y0+d.y1)/2} />
@@ -1171,7 +1171,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<div class="nf-actions">
<button class="nf-btn" @click=${()=>{this.loadDevices()}}>${e("ble_refresh")}</button>
<button class="nf-btn nf-primary" ?disabled=${!this._pick||n.length>=10} @click=${()=>this.addTag()}>${e("ble_add_button")}</button>
</div>`}};customElements.get("nf-ble-locate")||customElements.define("nf-ble-locate",Ga);var O0=new URL(import.meta.url),H0=new URL("./nextfloor-3d.js?v=473b84f8bac7",O0).href,Gp;function pn(){return Gp??=import(H0),Gp}var jp=["lights","seating","tables","storage","beds","kitchen","appliances","bath","media","office","tech","climate","energy","garden","plants","kids","fitness","pets","workshop","music","season","pictures","vehicles","building","decor"],L0={sofa:"seating",armchair:"seating",stool:"seating",chair:"seating",bench:"seating",corner_bench:"seating",bar_stool:"seating",office_chair:"office",coffee_table:"tables",table:"tables",table_round:"tables",desk:"office",worktop:"kitchen",tv_board:"media",tv_wall:"media",sideboard:"storage",shelf:"storage",tall_cabinet:"storage",wardrobe:"storage",dresser:"storage",nightstand:"beds",coat_rack:"storage",plant:"plants",rug:"decor",kitchen:"kitchen",kitchen_wall:"kitchen",kitchen_tall:"kitchen",island:"kitchen",sink:"kitchen",stove:"kitchen",dishwasher:"appliances",fridge:"appliances",washer:"appliances",dryer:"appliances",robot_vacuum:"appliances",bed:"beds",bunk_bed:"beds",bathtub:"bath",shower:"bath",wc:"bath",washbasin:"bath",radiator:"climate",stairs:"building",parking:"vehicles",ceiling_fan:"lights"},C0=[[/xmas|advent|window_star|candle_arch|reindeer|pumpkin|easter|snowman|gift_pile|lights_outdoor/,"season"],[/^frame_|^canvas$|^poster$|picture_ledge/,"pictures"],[/piano|drum_kit|guitar|synth|mic_stand|vinyl|easel|studio_monitor|mixing_desk/,"music"],[/lamp|pendant|light_pillar|light_bars|mood_spot|ceiling_panel|garden_spots|wall_light|light_cove|niche_led|shelf_led|monitor_light|workshop_light|painting_light|cabinet_light|moon_light|torch|lantern|ceiling_fan_light/,"lights"],[/cat_|dog_|pet_|litter|scratch|hamster|rabbit|bird_cage|small_animal|aquarium|terrarium/,"pets"],[/stairs|steps|landing|rail_|column|pilaster|beam|chimney|glass_wall|sliding_wall|half_wall|platform|niche_shelf|window_seat|divider_slats|gallery/,"building"],[/tree|shrub|conifer|hedge|brush|monstera|plant|herb_garden|herb_planter|flower|raised_bed|greenhouse|ficus|cactus|bonsai|living_wall|vertical_garden/,"plants"],[/kids|toy|teepee|(^|_)play_|rocking_horse|ball_pit|house_bed|cot\b|^cot|crib|changing_table|baby|loft_bed|star_projector|moon_light/,"kids"],[/treadmill|fitness|power_rack|rowing|rower|spin_bike|dumbbell|punching|yoga|elliptical|gym|exercise|wall_bars|bike_trainer|kettlebell|weight_bench|massage_chair/,"fitness"],[/heat_pump|boiler|buffer_tank|manifold|ventilation|radiator|towel_heater|thermostat|air_purifier|humidifier|dehumidifier|tower_fan|ceiling_fan|hot_water|water_softener|water_pump|fireplace|wood_stove|patio_heater|sauna|oil_|expansion_vessel|water_tank|infrared|cold_bath/,"climate"],[/wallbox|inverter|battery|solar|meter|fuse_box|grid/,"energy"],[/workbench|tool_|compressor|drill|tyre|paint_cabinet|heavy_shelf|shelf_rack|garage_opener|workshop|bike_stand|bike_holder|bike_rack|lawn_mower|mower|welder|ev_bike_charger|tool_chest|parts_cabinet/,"workshop"],[/speaker|subwoofer|soundbar|receiver|turntable|record|game_console|multiroom|hifi|cinema|acoustic|bass_trap|popcorn|projector|projection|screen|display_|smart_display|media|tv|arcade|star_ceiling|av_/,"media"],[/desk|office|filing|whiteboard|monitor|bookcase|phone_booth|sim_cockpit|chair_gaming|gaming/,"office"],[/server|nas|router|wifi|access_point|network|printer|filament|tower_pc|smoke_detector|siren|baby_monitor|sunrise_clock|light_switch|socket|co_detector|presence_|water_leak|air_quality|doorbell/,"tech"],[/grill|lounge|lounger|parasol|pergola|hot_tub|fire_bowl|torch|lantern|play_tower|garden|trampoline|sprinkler|valve|rain_barrel|outdoor|hammock|(^|_)pool|swing|bin_box|^bin_|mailbox|rotary_line|kamado|pizza_oven|fire_pit|sandbox|wood_pile|bird_house|cistern|pond|water_feature|beach_chair/,"garden"],[/vanity_\d|vanity_double|double_vanity|basin|bath|shower|toilet|bidet|towel|mirror_cabinet|mirror_round|mirror_80|mirror_led|whirlpool|washer_under|laundry|urinal|wt_\d|handtuch|seife|wc/,"bath"],[/fridge|freezer|dishwasher|washer|dryer|microwave|coffee_machine|kettle|toaster|mixer|oven|steam|vacuum|ironing|drying_rack|trash|water_cooler|drip_tray|espresso|air_fryer|water_bar|thermo_cooker/,"appliances"],[/base_|drawer_|sink|hob|cooker|hood|pantry|kitchen|island|breakfast_bar|wall_\d|wall_glass|wall_corner|row_|spice|cabinet_light|trolley|bar_cart|utility_sink/,"kitchen"],[/bed|boxspring|futon|nightstand|canopy|mattress/,"beds"],[/sofa|chair|armchair|stool|bench|pouf|bean_bag|recliner|wingback|chaise|seat|ektorp|poang|cosy_corner|swing_bench|hanging_chair|nook|floor_cushion|tatami/,"seating"],[/table|dining|coffee_|side_round|lack_|^console$|bekant|alex/,"tables"],[/wardrobe|closet|clothes_rail|chest|dresser|shelf|cabinet|sideboard|lowboard|highboard|kallax|billy|ivar|pax|besta|cube_|coat_stand|shoe_bench|divider|display_cabinet|wall_unit|malm_chest|locker/,"storage"]];function N0(t){if(t.vehicle)return"vLine truncated
</div>`}};customElements.get("nf-ble-locate")||customElements.define("nf-ble-locate",Ga);var O0=new URL(import.meta.url),H0=new URL("./nextfloor-3d.js?v=74227cd20cc3",O0).href,Gp;function fn(){return Gp??=import(H0),Gp}var jp=["lights","seating","tables","storage","beds","kitchen","appliances","bath","media","office","tech","climate","energy","garden","plants","kids","fitness","pets","workshop","music","season","pictures","vehicles","building","decor"],L0={sofa:"seating",armchair:"seating",stool:"seating",chair:"seating",bench:"seating",corner_bench:"seating",bar_stool:"seating",office_chair:"office",coffee_table:"tables",table:"tables",table_round:"tables",desk:"office",worktop:"kitchen",tv_board:"media",tv_wall:"media",sideboard:"storage",shelf:"storage",tall_cabinet:"storage",wardrobe:"storage",dresser:"storage",nightstand:"beds",coat_rack:"storage",plant:"plants",rug:"decor",kitchen:"kitchen",kitchen_wall:"kitchen",kitchen_tall:"kitchen",island:"kitchen",sink:"kitchen",stove:"kitchen",dishwasher:"appliances",fridge:"appliances",washer:"appliances",dryer:"appliances",robot_vacuum:"appliances",bed:"beds",bunk_bed:"beds",bathtub:"bath",shower:"bath",wc:"bath",washbasin:"bath",radiator:"climate",stairs:"building",parking:"vehicles",ceiling_fan:"lights"},C0=[[/xmas|advent|window_star|candle_arch|reindeer|pumpkin|easter|snowman|gift_pile|lights_outdoor/,"season"],[/^frame_|^canvas$|^poster$|picture_ledge/,"pictures"],[/piano|drum_kit|guitar|synth|mic_stand|vinyl|easel|studio_monitor|mixing_desk/,"music"],[/lamp|pendant|light_pillar|light_bars|mood_spot|ceiling_panel|garden_spots|wall_light|light_cove|niche_led|shelf_led|monitor_light|workshop_light|painting_light|cabinet_light|moon_light|torch|lantern|ceiling_fan_light/,"lights"],[/cat_|dog_|pet_|litter|scratch|hamster|rabbit|bird_cage|small_animal|aquarium|terrarium/,"pets"],[/stairs|steps|landing|rail_|column|pilaster|beam|chimney|glass_wall|sliding_wall|half_wall|platform|niche_shelf|window_seat|divider_slats|gallery/,"building"],[/tree|shrub|conifer|hedge|brush|monstera|plant|herb_garden|herb_planter|flower|raised_bed|greenhouse|ficus|cactus|bonsai|living_wall|vertical_garden/,"plants"],[/kids|toy|teepee|(^|_)play_|rocking_horse|ball_pit|house_bed|cot\b|^cot|crib|changing_table|baby|loft_bed|star_projector|moon_light/,"kids"],[/treadmill|fitness|power_rack|rowing|rower|spin_bike|dumbbell|punching|yoga|elliptical|gym|exercise|wall_bars|bike_trainer|kettlebell|weight_bench|massage_chair/,"fitness"],[/heat_pump|boiler|buffer_tank|manifold|ventilation|radiator|towel_heater|thermostat|air_purifier|humidifier|dehumidifier|tower_fan|ceiling_fan|hot_water|water_softener|water_pump|fireplace|wood_stove|patio_heater|sauna|oil_|expansion_vessel|water_tank|infrared|cold_bath/,"climate"],[/wallbox|inverter|battery|solar|meter|fuse_box|grid/,"energy"],[/workbench|tool_|compressor|drill|tyre|paint_cabinet|heavy_shelf|shelf_rack|garage_opener|workshop|bike_stand|bike_holder|bike_rack|lawn_mower|mower|welder|ev_bike_charger|tool_chest|parts_cabinet/,"workshop"],[/speaker|subwoofer|soundbar|receiver|turntable|record|game_console|multiroom|hifi|cinema|acoustic|bass_trap|popcorn|projector|projection|screen|display_|smart_display|media|tv|arcade|star_ceiling|av_/,"media"],[/desk|office|filing|whiteboard|monitor|bookcase|phone_booth|sim_cockpit|chair_gaming|gaming/,"office"],[/server|nas|router|wifi|access_point|network|printer|filament|tower_pc|smoke_detector|siren|baby_monitor|sunrise_clock|light_switch|socket|co_detector|presence_|water_leak|air_quality|doorbell/,"tech"],[/grill|lounge|lounger|parasol|pergola|hot_tub|fire_bowl|torch|lantern|play_tower|garden|trampoline|sprinkler|valve|rain_barrel|outdoor|hammock|(^|_)pool|swing|bin_box|^bin_|mailbox|rotary_line|kamado|pizza_oven|fire_pit|sandbox|wood_pile|bird_house|cistern|pond|water_feature|beach_chair/,"garden"],[/vanity_\d|vanity_double|double_vanity|basin|bath|shower|toilet|bidet|towel|mirror_cabinet|mirror_round|mirror_80|mirror_led|whirlpool|washer_under|laundry|urinal|wt_\d|handtuch|seife|wc/,"bath"],[/fridge|freezer|dishwasher|washer|dryer|microwave|coffee_machine|kettle|toaster|mixer|oven|steam|vacuum|ironing|drying_rack|trash|water_cooler|drip_tray|espresso|air_fryer|water_bar|thermo_cooker/,"appliances"],[/base_|drawer_|sink|hob|cooker|hood|pantry|kitchen|island|breakfast_bar|wall_\d|wall_glass|wall_corner|row_|spice|cabinet_light|trolley|bar_cart|utility_sink/,"kitchen"],[/bed|boxspring|futon|nightstand|canopy|mattress/,"beds"],[/sofa|chair|armchair|stool|bench|pouf|bean_bag|recliner|wingback|chaise|seat|ektorp|poang|cosy_corner|swing_bench|hanging_chair|nook|floor_cushion|tatami/,"seating"],[/table|dining|coffee_|side_round|lack_|^console$|bekant|alex/,"tables"],[/wardrobe|closet|clothes_rail|chest|dresser|shelf|cabinet|sideboard|lowboard|highboard|kallax|billy|ivar|pax|besta|cube_|coat_stand|shoe_bench|divider|display_cabinet|wall_unit|malm_chest|locker/,"storage"]];function N0(t){if(t.vehicle)return"vLine truncated
:host {
display: block;
aspect-ratio: 4 / 3;
@@ -1185,7 +1185,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
height: 100%;
object-fit: contain;
}
`;constructor(){super(),this.type="",this._url=null}connectedCallback(){super.connectedCallback(),Bt.enabled&&(this._url=Bt.cached(this.type)??null,!this._url&&(lo??=new IntersectionObserver(K0,{rootMargin:"120px"}),lo.observe(this)))}disconnectedCallback(){super.disconnectedCallback(),lo?.unobserve(this)}updated(e){e.has("type")&&e.get("type")!==void 0&&(this._url=Bt.cached(this.type)??null,!this._url&&Bt.enabled&&lo?.observe(this))}visible(){lo?.unobserve(this);let e=this.type;Bt.get(e).then(n=>{this.type===e&&(this._url=n)})}render(){return this._url?m`<img src=${this._url} alt="" />`:_}};customElements.get("nf-thumb")||customElements.define("nf-thumb",Ya);var of="nextfloor.library2",G0={language:"en"},Ei=class{onChange;text="";saved;shown=null;picked=new Map;constructor(e){this.onChange=e,this.saved={folded:{},favourites:[],recent:[],flags:["room"]};try{let n=localStorage.getItem(of);n&&(this.saved={...this.saved,...JSON.parse(n)})}catch{}}store(e){this.saved={...this.saved,...e},this.onChange();try{localStorage.setItem(of,JSON.stringify(this.saved))}catch{}}get query(){return this.text}set query(e){this.text=e,this.onChange()}isOpen(e,n){return this.saved.folded[e]??n}toggle(e,n){this.store({folded:{...this.saved.folded,[e]:!this.isOpen(e,n)}})}has(e){return this.saved.flags.includes(e)}flip(e){this.store({flags:this.has(e)?this.saved.flags.filter(n=>n!==e):[...this.saved.flags,e]})}get favourites(){return this.saved.favourites}isFavourite(e){return this.saved.favourites.includes(e)}toggleFavourite(e){this.store({favourites:this.isFavourite(e)?this.saved.favourites.filter(n=>n!==e):[e,...this.saved.favourites]})}get recent(){return this.saved.recent}used(e){this.store({recent:Qp(this.saved.recent,e)})}pickedOf(e){let n=this.picked.get(e.key);return e.entries.find(r=>r.type===n)??e.entries[0]}pick(e,n){this.picked.set(e.key,n),this.onChange()}get preview(){return this.shown}hidePreview(){this.shown=null,this.onChange()}async showPreview(e,n,r){let o=n.getBoundingClientRect(),i={left:Math.max(8,o.left-196),top:Math.max(8,Math.min(window.innerHeight-200,o.top+o.height/2-95))};this.shown={type:e,url:null,...i},this.onChange();try{let[s,l,a]=at(e),c=(await pn()).furniturePreview({type:e,w:s,d:l,h:a,variant:null,lamp:Co[e]??null},180,[...r]);this.shown?.type===e&&(this.shown={type:e,url:c,...i})}catch{this.shown=null}this.onChange()}};function j0(t,e){let n=t.hass?.language??"en",o=[...[...new Set(Object.values(Yc).flat())].map(l=>({type:l,source:"builtin",id:l,size:et[l],lamp:ce(l),electric:Et(l)})),...e.flatMap(l=>l.items.map(a=>({type:ue(l.id,a.id),source:l.id,id:a.id,size:a.size,lamp:!!a.light,electric:!!a.electric,vehicle:!!a.vehicle,climate:!!a.climate})))],i=new Map(e.map(l=>[l.id,Oe(l,n)])),s=new Map(e.flatMap(l=>l.items.map(a=>[ue(l.id,a.id),a])));return Yp(o).map(l=>{let a=l.entries[0],c=s.get(a.type),d=c?Ye(c,a.type,n):t.t(`furn_${a.type}`),u=l.entries.length>1&&d.replace(/\s*\(?\d+([.,]\d+)?\s*(cm|x\s*\d+|×\s*\d+)?\)?\s*$/i,"").trim()||d,p=l.entries.map(h=>{let f=s.get(h.type);return f?[...Object.values(f.name),Ye(f,h.type,n)].join(" "):xe(G0,`furn_${h.type}`)}).join(" ");return{card:l,label:u,search:`${p} ${t.t(`lib_cat_${l.category}`)}`,from:i.get(a.source)??"NextFloor"}})}var U0=(t,e)=>tf(e,`${t.label} ${t.search} ${t.from} ${t.card.entries.map(n=>n.id.replace(/_/g," ")).join(" ")}`),Z0=t=>t.lamp?"light":t.electric?"switch":null;function q0(t,e,n,r){let o=t.t,i=e.pickedOf(n.card),[s,l]=i.size,a=Z0(i),c=p=>{e.showPreview(i.type,p.currentTarget,r.packs)},d=()=>{e.used(i.type),r.add(i.type)},u=e.isFavourite(i.type);return m`<div class="nf-card">
`;constructor(){super(),this.type="",this._url=null}connectedCallback(){super.connectedCallback(),Wt.enabled&&(this._url=Wt.cached(this.type)??null,!this._url&&(lo??=new IntersectionObserver(K0,{rootMargin:"120px"}),lo.observe(this)))}disconnectedCallback(){super.disconnectedCallback(),lo?.unobserve(this)}updated(e){e.has("type")&&e.get("type")!==void 0&&(this._url=Wt.cached(this.type)??null,!this._url&&Wt.enabled&&lo?.observe(this))}visible(){lo?.unobserve(this);let e=this.type;Wt.get(e).then(n=>{this.type===e&&(this._url=n)})}render(){return this._url?m`<img src=${this._url} alt="" />`:_}};customElements.get("nf-thumb")||customElements.define("nf-thumb",Ya);var of="nextfloor.library2",G0={language:"en"},Ei=class{onChange;text="";saved;shown=null;picked=new Map;constructor(e){this.onChange=e,this.saved={folded:{},favourites:[],recent:[],flags:["room"]};try{let n=localStorage.getItem(of);n&&(this.saved={...this.saved,...JSON.parse(n)})}catch{}}store(e){this.saved={...this.saved,...e},this.onChange();try{localStorage.setItem(of,JSON.stringify(this.saved))}catch{}}get query(){return this.text}set query(e){this.text=e,this.onChange()}isOpen(e,n){return this.saved.folded[e]??n}toggle(e,n){this.store({folded:{...this.saved.folded,[e]:!this.isOpen(e,n)}})}has(e){return this.saved.flags.includes(e)}flip(e){this.store({flags:this.has(e)?this.saved.flags.filter(n=>n!==e):[...this.saved.flags,e]})}get favourites(){return this.saved.favourites}isFavourite(e){return this.saved.favourites.includes(e)}toggleFavourite(e){this.store({favourites:this.isFavourite(e)?this.saved.favourites.filter(n=>n!==e):[e,...this.saved.favourites]})}get recent(){return this.saved.recent}used(e){this.store({recent:Qp(this.saved.recent,e)})}pickedOf(e){let n=this.picked.get(e.key);return e.entries.find(r=>r.type===n)??e.entries[0]}pick(e,n){this.picked.set(e.key,n),this.onChange()}get preview(){return this.shown}hidePreview(){this.shown=null,this.onChange()}async showPreview(e,n,r){let o=n.getBoundingClientRect(),i={left:Math.max(8,o.left-196),top:Math.max(8,Math.min(window.innerHeight-200,o.top+o.height/2-95))};this.shown={type:e,url:null,...i},this.onChange();try{let[s,l,a]=lt(e),c=(await fn()).furniturePreview({type:e,w:s,d:l,h:a,variant:null,lamp:Co[e]??null},180,[...r]);this.shown?.type===e&&(this.shown={type:e,url:c,...i})}catch{this.shown=null}this.onChange()}};function j0(t,e){let n=t.hass?.language??"en",o=[...[...new Set(Object.values(Yc).flat())].map(l=>({type:l,source:"builtin",id:l,size:et[l],lamp:ce(l),electric:Et(l)})),...e.flatMap(l=>l.items.map(a=>({type:ue(l.id,a.id),source:l.id,id:a.id,size:a.size,lamp:!!a.light,electric:!!a.electric,vehicle:!!a.vehicle,climate:!!a.climate})))],i=new Map(e.map(l=>[l.id,Oe(l,n)])),s=new Map(e.flatMap(l=>l.items.map(a=>[ue(l.id,a.id),a])));return Yp(o).map(l=>{let a=l.entries[0],c=s.get(a.type),d=c?Ye(c,a.type,n):t.t(`furn_${a.type}`),u=l.entries.length>1&&d.replace(/\s*\(?\d+([.,]\d+)?\s*(cm|x\s*\d+|×\s*\d+)?\)?\s*$/i,"").trim()||d,p=l.entries.map(h=>{let f=s.get(h.type);return f?[...Object.values(f.name),Ye(f,h.type,n)].join(" "):xe(G0,`furn_${h.type}`)}).join(" ");return{card:l,label:u,search:`${p} ${t.t(`lib_cat_${l.category}`)}`,from:i.get(a.source)??"NextFloor"}})}var U0=(t,e)=>tf(e,`${t.label} ${t.search} ${t.from} ${t.card.entries.map(n=>n.id.replace(/_/g," ")).join(" ")}`),Z0=t=>t.lamp?"light":t.electric?"switch":null;function q0(t,e,n,r){let o=t.t,i=e.pickedOf(n.card),[s,l]=i.size,a=Z0(i),c=p=>{e.showPreview(i.type,p.currentTarget,r.packs)},d=()=>{e.used(i.type),r.add(i.type)},u=e.isFavourite(i.type);return m`<div class="nf-card">
<button
class="nf-card-main"
title=${a?o(a==="light"?"lib_badge_light":"lib_badge_electric"):n.label}
@@ -1195,9 +1195,9 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
@mouseleave=${()=>e.hidePreview()}
@blur=${()=>e.hidePreview()}
>
${Bt.enabled?m`<nf-thumb .type=${i.type}></nf-thumb>`:_}
${Wt.enabled?m`<nf-thumb .type=${i.type}></nf-thumb>`:_}
<span class="nf-card-name"
>${n.label}${a?m`<svg class="nf-lib-badge" viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d=${Nt(a)} /></svg>`:_}</span
>${n.label}${a?m`<svg class="nf-lib-badge" viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d=${Bt(a)} /></svg>`:_}</span
>
<span class="nf-card-meta">${Math.round(s*100)} × ${Math.round(l*100)} cm · ${n.from}</span>
</button>
@@ -1208,7 +1208,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</div>`}function af(t,e,n,r){return m`<div class="nf-cards">${n.map(o=>q0(t,e,o,r))}</div>`}function Xa(t,e,n,r,o,i,s){if(o.length===0)return _;let l=e.isOpen(n,s);return m`<button class="nf-lib-head nf-lib-toggle" aria-expanded=${l} @click=${()=>e.toggle(n,s)}>
<span class="nf-lib-caret">${l?"\u25BE":"\u25B8"}</span>${r} <span class="nf-lib-count">${o.length}</span>
</button>
${l?af(t,e,o,i):_}`}function sf(t,e){return t.flatMap(n=>{let r=e.find(o=>o.card.entries.some(i=>i.type===n));return r?[{...r,card:{...r.card,key:`one:${n}`,entries:r.card.entries.filter(o=>o.type===n)}}]:[]})}function Y0(t){let e=Ua(t),n=ja(t),r=o=>o===e?0:n?.has(o)?1:2;return[...jp].sort((o,i)=>r(o)-r(i))}function lf(t,e,n,r){let o=t.t;Bt.packs=r.packs;let i=j0(t,r.packs),s=ef(e.query),l=ja(n),a=!!l&&e.has("room")&&s.length===0,c=i.filter(p=>{let h=p.card.entries[0];return a&&!l.has(p.card.category)||e.has("linkable")&&!h.lamp&&!h.electric||e.has("lit")&&!h.lamp||e.has("outdoor")&&!Zp(p.card.category)?!1:s.length===0||U0(p,s)}),d=(p,h)=>m`<button class="nf-chip nf-lib-chip" aria-pressed=${e.has(p)} @click=${()=>e.flip(p)}>${h}</button>`,u=s.length>0;return m`<section>
${l?af(t,e,o,i):_}`}function sf(t,e){return t.flatMap(n=>{let r=e.find(o=>o.card.entries.some(i=>i.type===n));return r?[{...r,card:{...r.card,key:`one:${n}`,entries:r.card.entries.filter(o=>o.type===n)}}]:[]})}function Y0(t){let e=Ua(t),n=ja(t),r=o=>o===e?0:n?.has(o)?1:2;return[...jp].sort((o,i)=>r(o)-r(i))}function lf(t,e,n,r){let o=t.t;Wt.packs=r.packs;let i=j0(t,r.packs),s=ef(e.query),l=ja(n),a=!!l&&e.has("room")&&s.length===0,c=i.filter(p=>{let h=p.card.entries[0];return a&&!l.has(p.card.category)||e.has("linkable")&&!h.lamp&&!h.electric||e.has("lit")&&!h.lamp||e.has("outdoor")&&!Zp(p.card.category)?!1:s.length===0||U0(p,s)}),d=(p,h)=>m`<button class="nf-chip nf-lib-chip" aria-pressed=${e.has(p)} @click=${()=>e.flip(p)}>${h}</button>`,u=s.length>0;return m`<section>
<h3>${o("furniture_add")}</h3>
<p class="nf-sub">${n?o("furniture_into",{room:n}):o("furniture_pick_room")}</p>
<button class="nf-btn nf-lib-studio" title=${o("studio_hint")} @click=${()=>r.studio()}>🛠️ ${o("studio_new")}</button>
@@ -1232,7 +1232,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</section>`}function cf(t,e){return e?m`<div class="nf-preview" style="left:${e.left}px;top:${e.top}px" aria-hidden="true">
${e.url?m`<img src=${e.url} alt="" />`:m`<span class="nf-preview-wait"></span>`}
<b>${qe(t.hass,e.type)}</b>
</div>`:_}function Qa(t,e,n,r=24){let o=Math.hypot(e[0]-t[0],e[1]-t[1]);if(o<1e-6||Math.abs(n)<1e-4)return[];let i=Math.max(-o*2,Math.min(o*2,n)),s=[(e[0]-t[0])/o,(e[1]-t[1])/o],l=[s[1],-s[0]],a=o*o/4/(2*Math.abs(i))+Math.abs(i)/2,c=2*Math.atan(2*Math.abs(i)/o),d=Math.max(2,Math.min(r,Math.ceil(2*c/Math.PI*180/11.25))),u=[l[0]*Math.sign(i),l[1]*Math.sign(i)],p=[(t[0]+e[0])/2,(t[1]+e[1])/2],h=[p[0]-u[0]*(a-Math.abs(i)),p[1]-u[1]*(a-Math.abs(i))],f=[];for(let g=1;g<d;g++){let y=-c+2*c*g/d;f.push([h[0]+a*(u[0]*Math.cos(y)+s[0]*Math.sin(y)),h[1]+a*(u[1]*Math.cos(y)+s[1]*Math.sin(y))])}return f}var Ja=t=>t.reduce((e,n,r)=>r?e+Math.hypot(n[0]-t[r-1][0],n[1]-t[r-1][1]):e,0);function el(t,e){let n=Math.max(0,e);for(let r=0;r+1<t.length;r++){let o=Math.hypot(t[r+1][0]-t[r][0],t[r+1][1]-t[r][1]);if(n<=o||r+2===t.length)return{piece:r,offset:Math.min(n,o)};n-=o}return{piece:0,offset:0}}var Fe=t=>Math.round(t*1e3)/1e3,tl=t=>t.map(([e,n])=>[Fe(e),Fe(n)]);function df(t,e){return{id:D("room"),name:e,area_id:null,points:tl(t),floor_material:"wood"}}function uf(t){return{...structuredClone(t),id:D("room"),points:tl(t.points.map(([e,n])=>[e+.5,n+.5]))}}function hf(t,e){let n=t.rooms.find(r=>r.id===e);t.rooms=t.rooms.filter(r=>r.id!==e),t.openings=t.openings.filter(r=>r.room_id!==e||r.wall),n&&(t.placements=t.placements.filter(r=>!N([r.x,r.z],n.points)))}function pf(t,e,n){let r=t.rooms.find(s=>s.id===e);if(!r||r.points.length<=3)return!1;let o=(n-1+r.points.length)%r.points.length;r.points.splice(n,1),r.wall_heights?.splice(n,1),r.wall_slopes?.splice(n,1),r.wall_thickness?.splice(n,1);let i=s=>s.room_id===e&&!s.wall;return t.openings=t.openings.filter(s=>!(i(s)&&(s.edge===n||s.edge===o))).map(s=>i(s)&&s.edge>n?{...s,edge:s.edge-1}:s),!0}function ff(t,e,n){if(!Number.isFinite(n))return null;let r=de(t.points),{x0:o,z0:i,x1:s,z1:l}=r;return e==="x"?[o,s]=[n,n+(s-o)]:e==="z"?[i,l]=[n,n+(l-i)]:n>.05&&(e==="w"?s=o+n:l=i+n),tl([[o,i],[s,i],[s,l],[o,l]])}function mf(t,e,n,r){return!Number.isFinite(r)||e<0||e>=t.points.length?null:t.points.map((o,i)=>i===e?n===0?[Fe(r),o[1]]:[o[0],Fe(r)]:[o[0],o[1]])}var X0=/^(Raum|Room) \d+$/;function nl(t,e,n){let r=e?n[e]:void 0,o=!t.name||X0.test(t.name)||Object.values(n).some(i=>i.name===t.name);return{area_id:e||null,...r&&o?{name:r.name}:{}}}function gf(t,e){let n=e.filter(a=>X(a.entity_id)==="light"&&(a.mount??"ceiling")==="ceiling"&&N([a.x,a.z],t.points));if(n.length<2)return[];let r=de(t.points),[o,i]=[r.x1-r.x0,r.z1-r.z0],s=Math.max(1,Math.round(Math.sqrt(n.length*o/Math.max(.1,i)))),l=Math.ceil(n.length/s);return n.map((a,c)=>{let d=Math.floor(c/s),u=d===l-1?n.length-s*(l-1):s,p=c-d*s;return{entityId:a.entity_id,x:Fe(r.x0+o/u*(p+.5)),z:Fe(r.z0+i/l*(d+.5))}})}function rl(t,e,n,r){let o=t.rooms.find(d=>d.id===e);if(!o)return;let i=o.points[n],s=o.points[(n+1)%o.points.length];o.points.splice(n+1,0,r);let[l,a]=[o.wall_heights?.[n],o.wall_slopes?.[n]];if(typeof l=="number"&&typeof a=="number"&&o.wall_slopes){let d=Math.hypot(s[0]-i[0],s[1]-i[1]),u=Fe(l+(a-l)*Math.min(1,Math.hypot(r[0]-i[0],r[1]-i[1])/(d||1)));o.wall_slopes.splice(n,1,u,a),o.wall_heights.splice(n+1,0,u)}else o.wall_heights?.splice(n+1,0,o.wall_heights[n]??null),o.wall_slopes?.splice(n+1,0,null);o.wall_thickness?.splice(n+1,0,o.wall_thickness[n]??null);let c=Math.hypot(r[0]-i[0],r[1]-i[1]);for(let d of t.openings)d.room_id!==e||d.wall||(d.edge>n?d.edge+=1:d.edge===n&&d.offset>c&&(d.edge=n+1,d.offset=Fe(d.offset-c)))}var Q0=22.5;function _f(t,e,n){let r=Math.min(Math.abs(e),t*2),o=t*(1+8/3*(r/Math.max(1e-6,t))**2),i=4*Math.atan(2*r/Math.max(1e-6,t))*180/Math.PI,s=Math.max(2,Math.ceil(i/Q0));if(n<=0)return 24;let l=Math.floor(o/(n+.1));return l>=s?l:0}function J0(t,e,n,r){let o=Ja(n);t.forEach((i,s)=>{let{piece:l,offset:a}=el(n,e[s]*o),c=Math.hypot(n[l+1][0]-n[l][0],n[l+1][1]-n[l][1]);i.edge=r+l,i.offset=Fe(c>i.width?Math.min(c-i.width/2,Math.max(i.width/2,a)):c/2)})}function bf(t,e,n,r){let o=t.rooms.find(v=>v.id===e);if(!o||n<0||n>=o.points.length||Math.abs(r)<.01)return!1;let i=o.points[n],s=o.points[(n+1)%o.points.length],l=Math.hypot(s[0]-i[0],s[1]-i[1]);if(l<.2)return!1;let[a,c]=[(s[0]-i[0])/l,(s[1]-i[1])/l],d=[(i[0]+s[0])/2+c*.02,(i[1]+s[1])/2-a*.02],p=N(d,o.points)?-r:r,h=(v,w)=>t.openings.filter(x=>x.room_id===v.id&&!x.wall&&x.edge===w),f=t.rooms.flatMap(v=>v.points.map((w,x)=>{let k=v.points[(x+1)%v.points.length],$=(A,F)=>Math.abs(A[0]-F[0])<.001&&Math.abs(A[1]-F[1])<.001;return $(w,i)&&$(k,s)?[v,x,!1]:$(w,s)&&$(k,i)?[v,x,!0]:null}).filter(w=>!!w)),g=Math.max(0,...f.flatMap(([v,w])=>h(v,w).map(x=>x.width))),y=_f(l,r,g);if(!y)return!1;let b=Qa(i,s,p,y).map(([v,w])=>[Fe(v),Fe(w)]);if(!b.length)return!1;for(let[v,w,x]of f){let k=x?[...b].reverse():b,$=h(v,w),A=v.points[w],F=$.map(T=>Math.min(1,Math.max(0,T.offset/l)));for(let T of $)T.edge=-1;k.forEach((T,I)=>rl(t,v.id,w+I,T)),v.wall_splits?.splice(w+1,0,...k.map(()=>null)),v.wall_splits?.[w]&&(v.wall_splits[w]=null),J0($,F,[A,...k,v.points[(w+k.length+1)%v.points.lenLine truncated
</div>`:_}function Qa(t,e,n,r=24){let o=Math.hypot(e[0]-t[0],e[1]-t[1]);if(o<1e-6||Math.abs(n)<1e-4)return[];let i=Math.max(-o*2,Math.min(o*2,n)),s=[(e[0]-t[0])/o,(e[1]-t[1])/o],l=[s[1],-s[0]],a=o*o/4/(2*Math.abs(i))+Math.abs(i)/2,c=2*Math.atan(2*Math.abs(i)/o),d=Math.max(2,Math.min(r,Math.ceil(2*c/Math.PI*180/11.25))),u=[l[0]*Math.sign(i),l[1]*Math.sign(i)],p=[(t[0]+e[0])/2,(t[1]+e[1])/2],h=[p[0]-u[0]*(a-Math.abs(i)),p[1]-u[1]*(a-Math.abs(i))],f=[];for(let g=1;g<d;g++){let y=-c+2*c*g/d;f.push([h[0]+a*(u[0]*Math.cos(y)+s[0]*Math.sin(y)),h[1]+a*(u[1]*Math.cos(y)+s[1]*Math.sin(y))])}return f}var Ja=t=>t.reduce((e,n,r)=>r?e+Math.hypot(n[0]-t[r-1][0],n[1]-t[r-1][1]):e,0);function el(t,e){let n=Math.max(0,e);for(let r=0;r+1<t.length;r++){let o=Math.hypot(t[r+1][0]-t[r][0],t[r+1][1]-t[r][1]);if(n<=o||r+2===t.length)return{piece:r,offset:Math.min(n,o)};n-=o}return{piece:0,offset:0}}var Fe=t=>Math.round(t*1e3)/1e3,tl=t=>t.map(([e,n])=>[Fe(e),Fe(n)]);function df(t,e){return{id:D("room"),name:e,area_id:null,points:tl(t),floor_material:"wood"}}function uf(t){return{...structuredClone(t),id:D("room"),points:tl(t.points.map(([e,n])=>[e+.5,n+.5]))}}function hf(t,e){let n=t.rooms.find(r=>r.id===e);t.rooms=t.rooms.filter(r=>r.id!==e),t.openings=t.openings.filter(r=>r.room_id!==e||r.wall),n&&(t.placements=t.placements.filter(r=>!N([r.x,r.z],n.points)))}function pf(t,e,n){let r=t.rooms.find(s=>s.id===e);if(!r||r.points.length<=3)return!1;let o=(n-1+r.points.length)%r.points.length;r.points.splice(n,1),r.wall_heights?.splice(n,1),r.wall_slopes?.splice(n,1),r.wall_thickness?.splice(n,1);let i=s=>s.room_id===e&&!s.wall;return t.openings=t.openings.filter(s=>!(i(s)&&(s.edge===n||s.edge===o))).map(s=>i(s)&&s.edge>n?{...s,edge:s.edge-1}:s),!0}function ff(t,e,n){if(!Number.isFinite(n))return null;let r=de(t.points),{x0:o,z0:i,x1:s,z1:l}=r;return e==="x"?[o,s]=[n,n+(s-o)]:e==="z"?[i,l]=[n,n+(l-i)]:n>.05&&(e==="w"?s=o+n:l=i+n),tl([[o,i],[s,i],[s,l],[o,l]])}function mf(t,e,n,r){return!Number.isFinite(r)||e<0||e>=t.points.length?null:t.points.map((o,i)=>i===e?n===0?[Fe(r),o[1]]:[o[0],Fe(r)]:[o[0],o[1]])}var X0=/^(Raum|Room) \d+$/;function nl(t,e,n){let r=e?n[e]:void 0,o=!t.name||X0.test(t.name)||Object.values(n).some(i=>i.name===t.name);return{area_id:e||null,...r&&o?{name:r.name}:{}}}function gf(t,e){let n=e.filter(a=>X(a.entity_id)==="light"&&(a.mount??"ceiling")==="ceiling"&&N([a.x,a.z],t.points));if(n.length<2)return[];let r=de(t.points),[o,i]=[r.x1-r.x0,r.z1-r.z0],s=Math.max(1,Math.round(Math.sqrt(n.length*o/Math.max(.1,i)))),l=Math.ceil(n.length/s);return n.map((a,c)=>{let d=Math.floor(c/s),u=d===l-1?n.length-s*(l-1):s,p=c-d*s;return{entityId:a.entity_id,x:Fe(r.x0+o/u*(p+.5)),z:Fe(r.z0+i/l*(d+.5))}})}function rl(t,e,n,r){let o=t.rooms.find(d=>d.id===e);if(!o)return;let i=o.points[n],s=o.points[(n+1)%o.points.length];o.points.splice(n+1,0,r);let[l,a]=[o.wall_heights?.[n],o.wall_slopes?.[n]];if(typeof l=="number"&&typeof a=="number"&&o.wall_slopes){let d=Math.hypot(s[0]-i[0],s[1]-i[1]),u=Fe(l+(a-l)*Math.min(1,Math.hypot(r[0]-i[0],r[1]-i[1])/(d||1)));o.wall_slopes.splice(n,1,u,a),o.wall_heights.splice(n+1,0,u)}else o.wall_heights?.splice(n+1,0,o.wall_heights[n]??null),o.wall_slopes?.splice(n+1,0,null);o.wall_thickness?.splice(n+1,0,o.wall_thickness[n]??null);let c=Math.hypot(r[0]-i[0],r[1]-i[1]);for(let d of t.openings)d.room_id!==e||d.wall||(d.edge>n?d.edge+=1:d.edge===n&&d.offset>c&&(d.edge=n+1,d.offset=Fe(d.offset-c)))}var Q0=22.5;function _f(t,e,n){let r=Math.min(Math.abs(e),t*2),o=t*(1+8/3*(r/Math.max(1e-6,t))**2),i=4*Math.atan(2*r/Math.max(1e-6,t))*180/Math.PI,s=Math.max(2,Math.ceil(i/Q0));if(n<=0)return 24;let l=Math.floor(o/(n+.1));return l>=s?l:0}function J0(t,e,n,r){let o=Ja(n);t.forEach((i,s)=>{let{piece:l,offset:a}=el(n,e[s]*o),c=Math.hypot(n[l+1][0]-n[l][0],n[l+1][1]-n[l][1]);i.edge=r+l,i.offset=Fe(c>i.width?Math.min(c-i.width/2,Math.max(i.width/2,a)):c/2)})}function bf(t,e,n,r){let o=t.rooms.find(v=>v.id===e);if(!o||n<0||n>=o.points.length||Math.abs(r)<.01)return!1;let i=o.points[n],s=o.points[(n+1)%o.points.length],l=Math.hypot(s[0]-i[0],s[1]-i[1]);if(l<.2)return!1;let[a,c]=[(s[0]-i[0])/l,(s[1]-i[1])/l],d=[(i[0]+s[0])/2+c*.02,(i[1]+s[1])/2-a*.02],p=N(d,o.points)?-r:r,h=(v,w)=>t.openings.filter(x=>x.room_id===v.id&&!x.wall&&x.edge===w),f=t.rooms.flatMap(v=>v.points.map((w,x)=>{let k=v.points[(x+1)%v.points.length],$=(A,F)=>Math.abs(A[0]-F[0])<.001&&Math.abs(A[1]-F[1])<.001;return $(w,i)&&$(k,s)?[v,x,!1]:$(w,s)&&$(k,i)?[v,x,!0]:null}).filter(w=>!!w)),g=Math.max(0,...f.flatMap(([v,w])=>h(v,w).map(x=>x.width))),y=_f(l,r,g);if(!y)return!1;let b=Qa(i,s,p,y).map(([v,w])=>[Fe(v),Fe(w)]);if(!b.length)return!1;for(let[v,w,x]of f){let k=x?[...b].reverse():b,$=h(v,w),A=v.points[w],F=$.map(T=>Math.min(1,Math.max(0,T.offset/l)));for(let T of $)T.edge=-1;k.forEach((T,I)=>rl(t,v.id,w+I,T)),v.wall_splits?.splice(w+1,0,...k.map(()=>null)),v.wall_splits?.[w]&&(v.wall_splits[w]=null),J0($,F,[A,...k,v.points[(w+k.length+1)%v.points.lenLine truncated
<line class="nf-draft nf-draft-wall" x1=${n[0]} y1=${n[1]} x2=${r[0]} y2=${r[1]} />
<text class="nf-dim" x=${(n[0]+r[0])/2} y=${(n[1]+r[1])/2-10}>${Ti(t,s)}</text>
</g>`}let[o,i]=[Math.abs(e.end[0]-e.start[0]),Math.abs(e.end[1]-e.start[1])];return R`<g pointer-events="none">
@@ -1246,7 +1246,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${r!==null?R`<line class="nf-guide" x1=${r} y1="0" x2=${r} y2=${n.h} />`:_}
${o!==null?R`<line class="nf-guide" x1="0" y1=${o} x2=${n.w} y2=${o} />`:_}
${e.point?R`<circle class="nf-snap" cx=${i} cy=${s} r="9" />`:_}
</g>`}function Mf(t,e,n,r,o){return e?rw(t,e):n!=="polygon"&&n!=="measure"?_:ow(t,r,o,n==="measure")}var ae=(t,e,n,r,o="")=>R`<rect class=${o} x=${Math.min(t,n)} y=${Math.min(e,r)} width=${Math.abs(n-t)} height=${Math.abs(r-e)} />`,te=(t,e,n,r,o="")=>R`<line class=${o} x1=${t} y1=${e} x2=${n} y2=${r} />`,Ef=(t,e="")=>R`<polygon class=${e} points=${t.map(n=>n.join(",")).join(" ")} />`,oe=(t,e,n,r="")=>R`<circle class=${r} cx=${t} cy=${e} r=${n} />`,sl=(t,e,n,r,o="")=>R`<ellipse class=${o} cx=${t} cy=${e} rx=${n} ry=${r} />`;function al(t,e,n){let r=[];for(let o=1;o<n;o++){let i=-t/2+t/n*o;r.push(te(i,e/2,i,e/2-Math.min(.12,e*.3)))}return r}function Rf(t,e,n,r){let o=Math.min(.24,e*.28),i=r?Math.min(.2,t*.12):0,s=[ae(-t/2,-e/2,t/2,-e/2+o,"nf-sym-fill")];r&&s.push(ae(-t/2,-e/2,-t/2+i,e/2,"nf-sym-fill"),ae(t/2-i,-e/2,t/2,e/2,"nf-sym-fill"));let l=t-2*i;for(let a=1;a<n;a++){let c=-t/2+i+l/n*a;s.push(te(c,-e/2+o,c,e/2-.02))}return s}function Af(t,e,n,r){if(t==="stairs"&&r?.stair)return iw(r,e,n);switch(t){case"sofa":return Rf(e,n,Math.max(1,Math.round((e-.4)/.62)),!0);case"armchair":return Rf(e,n,1,!0);case"bench":return[ae(-e/2,-n/2,e/2,-n/2+.08,"nf-sym-fill")];case"corner_bench":{let o=Math.min(.5,n*.4);return[ae(-e/2,-n/2,e/2,-n/2+.08,"nf-sym-fill"),ae(-e/2,-n/2,-e/2+.08,n/2,"nf-sym-fill"),te(-e/2+o,-n/2+o,e/2,-n/2+o),te(-e/2+o,-n/2+o,-e/2+o,n/2)]}case"chair":return[ae(-e/2,-n/2,e/2,-n/2+.06,"nf-sym-fill")];case"office_chair":return[oe(0,.03,Math.min(e,n)*.36),ae(-e*.35,-n/2+.02,e*.35,-n/2+.1,"nf-sym-fill")];case"bar_stool":case"table_round":return[oe(0,0,Math.min(e,n)*.42)];case"stool":return[ae(-e/2+.04,-n/2+.04,e/2-.04,n/2-.04)];case"table":case"coffee_table":case"desk":{let o=[ae(-e/2+.05,-n/2+.05,e/2-.05,n/2-.05)];return t==="desk"&&o.push(te(-.3,-n/2+.1,.3,-n/2+.1,"nf-sym-strong")),o}case"bed":case"bunk_bed":{let o=e>1.2?2:1,i=(e-.2)/o,s=[ae(-e/2,-n/2,e/2,-n/2+.07,"nf-sym-fill"),te(-e/2,-n/2+(n-.1)*.36,e/2,-n/2+(n-.1)*.36)];for(let l=0;l<o;l++)s.push(ae(-e/2+.13+i*l,-n/2+.12,-e/2+.07+i*(l+1),-n/2+.12+Math.min(.4,n*.18)));return s}case"nightstand":case"wardrobe":case"dresser":case"sideboard":case"tall_cabinet":case"kitchen":case"kitchen_wall":case"kitchen_tall":case"shelf":return al(e,n,t==="nightstand"||t==="tall_cabinet"||t==="kitchen_tall"?1:Math.max(2,Math.round(e/.5)));case"coat_rack":return[ae(-e/2,-n/2,e/2,-n/2+.03,"nf-sym-fill"),...al(e,n,Math.max(2,Math.round(e/.5)))];case"island":return[te(-e/2,n/2-.3,e/2,n/2-.3)];case"fridge":return[te(-e/2+.06,n/2-.04,e/2-.06,n/2-.04,"nf-sym-strong")];case"stove":{let o=Math.min(e,n)*.14;return[oe(-e*.22,-n*.2,o),oe(e*.22,-n*.2,o*.8),oe(-e*.22,n*.2,o*.8),oe(e*.22,n*.2,o)]}case"sink":{let o=Math.min(.5,e-.2);return[ae(-o/2,-n/2+.1,o/2,n/2-.08),oe(0,-n/2+.06,.025,"nf-sym-fill")]}case"dishwasher":return[te(-e/2+.08,n/2-.05,e/2-.08,n/2-.05,"nf-sym-strong")];case"washer":case"dryer":return[oe(0,.05,Math.min(e,n)*.3),te(-e/2,-n/2+.1,e/2,-n/2+.1)];case"bathtub":return[ae(-e/2+.07,-n/2+.07,e/2-.07,n/2-.07),oe(-e/2+.14,0,.03,"nf-sym-fill")];case"shower":return[te(-e/2,-n/2,e/2,n/2),te(e/2,-n/2,-e/2,n/2),oe(0,0,.04)];case"wc":return[ae(-e/2,-n/2,e/2,-n/2+Math.min(.18,n*.3),"nf-sym-fill"),sl(0,n*.1,e*.36,n*.3)];case"washbasin":return[sl(0,.03,e*.34,n*.3)];case"tv_board":return[te(-Math.min(e*.4,.72),-n/2+.14,Math.min(e*.4,.72),-n/2+.14,"nf-sym-strong"),...al(e,n,Math.max(2,Math.round(e/.6)))];case"tv_wall":return[te(-e/2,0,e/2,0,"nf-sym-strong")];case"lamp_downlight":case"lamp_spot":return[oe(0,0,Math.min(e,n)*.45,"nf-sym-fill"),oe(0,0,Math.min(e,n)*1.4)];case"lamp_bollard":case"lamp_garden":return[oe(0,0,Math.min(e,n)*.5,"nf-sym-fill"),oe(0,0,Math.min(e,n)*1.6)];case"parking":return[ae(-e/2+.08,-n/2+.08,e/2-.08,n/2-.08),te(-e*.15,n/2-.5,0,n/2-.22,"nf-sym-strong"),te(0,n/2-.22,e*.15,n/2-.5,"nf-sym-strong")];case"robot_vacuum":return[ae(-e*.45,-n/2,e*.45,-n/2+n*.3,"nf-sym-fill"),oe(0,n*.14,Math.min(e,n)*.47)];case"radiator":{let o=[],i=Math.max(3,Math.round(e/.1));for(let s=1;s<i;s++)o.push(te(-e/2+e/i*s,-n/2,-e/2+e/i*s,n/2));return o}case"lamp_panel":return[ae(-e/2+.03,-n/2+.03,e/2-.03,n/2-.03,"nf-sym-fill")];case"lamp_uplight":case"lamp_ceiling":case"lamp_pendant":case"lamp_floor":case"lamp_table":{let o=Math.min(e,n)/2,i=[oe(0,0,o*.9,"nf-sym-fill"),oe(0,0,o*.3)];if(t==="lamp_ceiling"||t==="lamp_pendant")for(let s=0;s<8;s++){let l=s/8*Math.PI*2;i.push(te(Math.cos(l)*o*1.05,Math.sin(l)*o*1.05,Math.cos(l)*o*1.35,Math.sin(l)*o*1.35))}return i}case"ceiling_fan":{let o=Math.min(e,n)/2,i=[oe(0,0,.11,"nf-sym-fill")];for(let s=0;s<5;s++){let l=s/5*Math.PI*2;i.push(te(Math.cos(l)*.12,Math.sin(l)*.12,Math.cos(l)*o*.97,Math.sin(l)*o*.97,"nf-sym-strong"))}return[...i,oe(0,0,o)]}case"lamp_wall":return[ae(-e/2,-n/2,e/2,-n/2+.03,"nf-sym-fill"),sl(0,.01,e*.4,n*.4)];case"led_strip":return[te(-e/2,0,e/2,0,"nf-sym-strong")];case"plant":return[oe(0,0,Math.min(e,n)*.46),oe(0,0,Math.min(e,n)*.25)];case"rug":return[ae(-e/2+.1,-n/2+.1,e/2-.1,n/2-.1)];case"stairs":{let o=Math.max(3,Math.roun Line truncated
</g>`}function Mf(t,e,n,r,o){return e?rw(t,e):n!=="polygon"&&n!=="measure"?_:ow(t,r,o,n==="measure")}var ae=(t,e,n,r,o="")=>R`<rect class=${o} x=${Math.min(t,n)} y=${Math.min(e,r)} width=${Math.abs(n-t)} height=${Math.abs(r-e)} />`,te=(t,e,n,r,o="")=>R`<line class=${o} x1=${t} y1=${e} x2=${n} y2=${r} />`,Ef=(t,e="")=>R`<polygon class=${e} points=${t.map(n=>n.join(",")).join(" ")} />`,oe=(t,e,n,r="")=>R`<circle class=${r} cx=${t} cy=${e} r=${n} />`,sl=(t,e,n,r,o="")=>R`<ellipse class=${o} cx=${t} cy=${e} rx=${n} ry=${r} />`;function al(t,e,n){let r=[];for(let o=1;o<n;o++){let i=-t/2+t/n*o;r.push(te(i,e/2,i,e/2-Math.min(.12,e*.3)))}return r}function Rf(t,e,n,r){let o=Math.min(.24,e*.28),i=r?Math.min(.2,t*.12):0,s=[ae(-t/2,-e/2,t/2,-e/2+o,"nf-sym-fill")];r&&s.push(ae(-t/2,-e/2,-t/2+i,e/2,"nf-sym-fill"),ae(t/2-i,-e/2,t/2,e/2,"nf-sym-fill"));let l=t-2*i;for(let a=1;a<n;a++){let c=-t/2+i+l/n*a;s.push(te(c,-e/2+o,c,e/2-.02))}return s}function Af(t,e,n,r){if(t==="stairs"&&r?.stair)return iw(r,e,n);switch(t){case"sofa":return Rf(e,n,Math.max(1,Math.round((e-.4)/.62)),!0);case"armchair":return Rf(e,n,1,!0);case"bench":return[ae(-e/2,-n/2,e/2,-n/2+.08,"nf-sym-fill")];case"corner_bench":{let o=Math.min(.5,n*.4);return[ae(-e/2,-n/2,e/2,-n/2+.08,"nf-sym-fill"),ae(-e/2,-n/2,-e/2+.08,n/2,"nf-sym-fill"),te(-e/2+o,-n/2+o,e/2,-n/2+o),te(-e/2+o,-n/2+o,-e/2+o,n/2)]}case"chair":return[ae(-e/2,-n/2,e/2,-n/2+.06,"nf-sym-fill")];case"office_chair":return[oe(0,.03,Math.min(e,n)*.36),ae(-e*.35,-n/2+.02,e*.35,-n/2+.1,"nf-sym-fill")];case"bar_stool":case"table_round":return[oe(0,0,Math.min(e,n)*.42)];case"stool":return[ae(-e/2+.04,-n/2+.04,e/2-.04,n/2-.04)];case"table":case"coffee_table":case"desk":{let o=[ae(-e/2+.05,-n/2+.05,e/2-.05,n/2-.05)];return t==="desk"&&o.push(te(-.3,-n/2+.1,.3,-n/2+.1,"nf-sym-strong")),o}case"bed":case"bunk_bed":{let o=e>1.2?2:1,i=(e-.2)/o,s=[ae(-e/2,-n/2,e/2,-n/2+.07,"nf-sym-fill"),te(-e/2,-n/2+(n-.1)*.36,e/2,-n/2+(n-.1)*.36)];for(let l=0;l<o;l++)s.push(ae(-e/2+.13+i*l,-n/2+.12,-e/2+.07+i*(l+1),-n/2+.12+Math.min(.4,n*.18)));return s}case"nightstand":case"wardrobe":case"dresser":case"sideboard":case"tall_cabinet":case"kitchen":case"kitchen_wall":case"kitchen_tall":case"shelf":return al(e,n,t==="nightstand"||t==="tall_cabinet"||t==="kitchen_tall"?1:Math.max(2,Math.round(e/.5)));case"coat_rack":return[ae(-e/2,-n/2,e/2,-n/2+.03,"nf-sym-fill"),...al(e,n,Math.max(2,Math.round(e/.5)))];case"island":return[te(-e/2,n/2-.3,e/2,n/2-.3)];case"fridge":return[te(-e/2+.06,n/2-.04,e/2-.06,n/2-.04,"nf-sym-strong")];case"stove":{let o=Math.min(e,n)*.14;return[oe(-e*.22,-n*.2,o),oe(e*.22,-n*.2,o*.8),oe(-e*.22,n*.2,o*.8),oe(e*.22,n*.2,o)]}case"sink":{let o=Math.min(.5,e-.2);return[ae(-o/2,-n/2+.1,o/2,n/2-.08),oe(0,-n/2+.06,.025,"nf-sym-fill")]}case"dishwasher":return[te(-e/2+.08,n/2-.05,e/2-.08,n/2-.05,"nf-sym-strong")];case"washer":case"dryer":return[oe(0,.05,Math.min(e,n)*.3),te(-e/2,-n/2+.1,e/2,-n/2+.1)];case"bathtub":return[ae(-e/2+.07,-n/2+.07,e/2-.07,n/2-.07),oe(-e/2+.14,0,.03,"nf-sym-fill")];case"shower":return[te(-e/2,-n/2,e/2,n/2),te(e/2,-n/2,-e/2,n/2),oe(0,0,.04)];case"wc":return[ae(-e/2,-n/2,e/2,-n/2+Math.min(.18,n*.3),"nf-sym-fill"),sl(0,n*.1,e*.36,n*.3)];case"washbasin":return[sl(0,.03,e*.34,n*.3)];case"tv_board":return[te(-Math.min(e*.4,.72),-n/2+.14,Math.min(e*.4,.72),-n/2+.14,"nf-sym-strong"),...al(e,n,Math.max(2,Math.round(e/.6)))];case"tv_wall":return[te(-e/2,0,e/2,0,"nf-sym-strong")];case"lamp_downlight":case"lamp_spot":return[oe(0,0,Math.min(e,n)*.45,"nf-sym-fill"),oe(0,0,Math.min(e,n)*1.4)];case"lamp_bollard":case"lamp_garden":return[oe(0,0,Math.min(e,n)*.5,"nf-sym-fill"),oe(0,0,Math.min(e,n)*1.6)];case"parking":return[ae(-e/2+.08,-n/2+.08,e/2-.08,n/2-.08),te(-e*.15,n/2-.5,0,n/2-.22,"nf-sym-strong"),te(0,n/2-.22,e*.15,n/2-.5,"nf-sym-strong")];case"robot_vacuum":return[ae(-e*.45,-n/2,e*.45,-n/2+n*.3,"nf-sym-fill"),oe(0,n*.14,Math.min(e,n)*.47)];case"radiator":{let o=[],i=Math.max(3,Math.round(e/.1));for(let s=1;s<i;s++)o.push(te(-e/2+e/i*s,-n/2,-e/2+e/i*s,n/2));return o}case"lamp_panel":return[ae(-e/2+.03,-n/2+.03,e/2-.03,n/2-.03,"nf-sym-fill")];case"lamp_uplight":case"lamp_ceiling":case"lamp_pendant":case"lamp_floor":case"lamp_table":{let o=Math.min(e,n)/2,i=[oe(0,0,o*.9,"nf-sym-fill"),oe(0,0,o*.3)];if(t==="lamp_ceiling"||t==="lamp_pendant")for(let s=0;s<8;s++){let l=s/8*Math.PI*2;i.push(te(Math.cos(l)*o*1.05,Math.sin(l)*o*1.05,Math.cos(l)*o*1.35,Math.sin(l)*o*1.35))}return i}case"ceiling_fan":{let o=Math.min(e,n)/2,i=[oe(0,0,.11,"nf-sym-fill")];for(let s=0;s<5;s++){let l=s/5*Math.PI*2;i.push(te(Math.cos(l)*.12,Math.sin(l)*.12,Math.cos(l)*o*.97,Math.sin(l)*o*.97,"nf-sym-strong"))}return[...i,oe(0,0,o)]}case"lamp_wall":return[ae(-e/2,-n/2,e/2,-n/2+.03,"nf-sym-fill"),sl(0,.01,e*.4,n*.4)];case"led_strip":return[te(-e/2,0,e/2,0,"nf-sym-strong")];case"plant":return[oe(0,0,Math.min(e,n)*.46),oe(0,0,Math.min(e,n)*.25)];case"rug":return[ae(-e/2+.1,-n/2+.1,e/2-.1,n/2-.1)];case"stairs":{let o=Math.max(3,Math.roun Line truncated
<g transform="translate(${c} ${d}) rotate(${s.rotation}) scale(${s.mirror?-o:o} ${o})">
<rect class="nf-furn-body" x=${-s.w/2} y=${-s.d/2} width=${s.w} height=${s.d} />
<g class="nf-furn-sym">${Af(s.type,s.w,s.d,s)}</g>
@@ -1257,10 +1257,10 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${a?aw(t,s):_}
${l?R`<text class="nf-dim" x=${w} y=${x+4}>${he(r.hass,s.w)} × ${he(r.hass,s.d)}</text>`:_}
${l&&s.locked?R`<text class="nf-lock" x=${b[0]} y=${b[1]+5}>🔒</text>`:_}
${a?Tf("data-rotate",s.id,v,b):_}`};return R`<g>${vp(e).map(i)}</g>`}function Pf(t,e,n){let{host:r}=t,o=i=>{let s=X(i.entity_id)??(r.hass?Ne(r.hass,i.entity_id):null);if(!s)return _;let[l,a]=t.toScreen([i.x,i.z]),c=r.hass?.states[i.entity_id]?.state==="on",d=i.entity_id===n,u=(i.rotation??0)*ll,p=d&&r.admin&&!i.locked&&ld(i.entity_id,r.hass?.states[i.entity_id]),h=[l-Math.sin(u)*46,a+Math.cos(u)*46],f=Cn(r,i.entity_id,i.icon);return R`${p?Tf("data-aim",i.entity_id,[l,a],h):_}<g data-device=${i.entity_id} class=${`nf-device${c?" nf-device-on":""}${d?" nf-device-sel":""}`} transform="translate(${l} ${a})">
${a?Tf("data-rotate",s.id,v,b):_}`};return R`<g>${vp(e).map(i)}</g>`}function Pf(t,e,n){let{host:r}=t,o=i=>{let s=X(i.entity_id)??(r.hass?Ne(r.hass,i.entity_id):null);if(!s)return _;let[l,a]=t.toScreen([i.x,i.z]),c=r.hass?.states[i.entity_id]?.state==="on",d=i.entity_id===n,u=(i.rotation??0)*ll,p=d&&r.admin&&!i.locked&&ld(i.entity_id,r.hass?.states[i.entity_id]),h=[l-Math.sin(u)*46,a+Math.cos(u)*46],f=Nn(r,i.entity_id,i.icon);return R`${p?Tf("data-aim",i.entity_id,[l,a],h):_}<g data-device=${i.entity_id} class=${`nf-device${c?" nf-device-on":""}${d?" nf-device-sel":""}`} transform="translate(${l} ${a})">
<title>${W(r.hass,i.entity_id)}</title>
<circle r="18" class="nf-hit" /><circle r="12" />
${f?R`<foreignObject class="nf-device-icon" x="-8" y="-8" width="16" height="16"><ha-icon icon=${f}></ha-icon></foreignObject>`:R`<path d=${Nt(s)} transform="translate(-7.2 -7.2) scale(0.6)" />`}
${f?R`<foreignObject class="nf-device-icon" x="-8" y="-8" width="16" height="16"><ha-icon icon=${f}></ha-icon></foreignObject>`:R`<path d=${Bt(s)} transform="translate(-7.2 -7.2) scale(0.6)" />`}
</g>
${d&&i.locked?R`<text class="nf-lock" x=${l+16} y=${a-12}>🔒</text>`:_}`};return R`<g>${e.placements.map(o)}</g>`}function If(t,e,n){return R`${(e.notes??[]).map(r=>{let[o,i]=t.toScreen([r.x,r.z]);return R`<g data-note=${r.id} class=${`nf-note${To(r)?" nf-note-due":""}${r.id===n?" nf-note-sel":""}`} transform="translate(${o} ${i})">
<title>${r.text}</title>
@@ -1297,9 +1297,9 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${dw(t,e,n)}
</div>
${Y(m`<button class="nf-btn nf-danger" ?disabled=${!t.admin} @click=${()=>n.remove()}>${r("delete")}</button>`)}
</section>`}function dw(t,e,n){let r=t.t,o=!!e.photo?.startsWith("image:"),i=async s=>{let l=s.target,a=l.files?.[0];if(l.value="",!a||!t.hass)return;let{data:c}=await Gn(a),d=D("img");await St(t.hass,d,c),n.patch({photo:`image:${d}`})};return m`${t.admin?m`<label class="nf-btn nf-wide nf-upload">📷 ${r(o?"picture_replace":"note_photo_upload")}<input type="file" accept="image/*" hidden @change=${i} /></label>`:_}
</section>`}function dw(t,e,n){let r=t.t,o=!!e.photo?.startsWith("image:"),i=async s=>{let l=s.target,a=l.files?.[0];if(l.value="",!a||!t.hass)return;let{data:c}=await jn(a),d=D("img");await St(t.hass,d,c),n.patch({photo:`image:${d}`})};return m`${t.admin?m`<label class="nf-btn nf-wide nf-upload">📷 ${r(o?"picture_replace":"note_photo_upload")}<input type="file" accept="image/*" hidden @change=${i} /></label>`:_}
${o?m`<p class="nf-sub nf-wide">${r("picture_stored")} <button class="nf-btn nf-field-btn" ?disabled=${!t.admin} @click=${()=>n.patch({photo:null})}>${r("delete")}</button></p>`:Z(t,r("picture_url"),e.photo??"",s=>n.patch({photo:s.trim()||null}),{wide:!0,placeholder:"/local/valve.jpg"})}
${M(r("note_photo_hint"),"nf-wide")}`}function uw(t,e,n,r){let o=Ie(e,n.rooms,n.walls??[]);if(!o)return null;let{room:i,edge:s}=o,l=zt(r,e,o),a=An(i,s,e.offset-e.width/2),c=An(i,s,e.offset+e.width/2),d=[(c[0]-a[0])/(e.width||1),(c[1]-a[1])/(e.width||1)],u=ge(i.points)>=0?1:-1,p=[-d[1]*u,d[0]*u],h=[.06,.06];return l&&(h=l.wall.free||l.wall.roomLeft===i.id?[l.wall.left,l.wall.right]:[l.wall.right,l.wall.left]),{room:i,edge:s,p0:a,p1:c,inward:p,direction:u,across:h,exterior:l?.wall.exterior??!1,at:(f,g)=>t.toScreen([f[0]+p[0]*g,f[1]+p[1]*g])}}var wt=(t,e,n="")=>R`<line class=${n} x1=${t[0]} y1=${t[1]} x2=${e[0]} y2=${e[1]} />`;function hw(t,e){let n=t.across[0]-.04,r=t.across[0]+Math.min(2,e.height),[o,i,s,l]=[t.at(t.p0,n),t.at(t.p1,n),t.at(t.p0,r),t.at(t.p1,r)];return R`${wt(o,i)}<path class="nf-open-track" d="M${o[0]} ${o[1]}L${s[0]} ${s[1]}M${i[0]} ${i[1]}L${l[0]} ${l[1]}" />`}function pw(t,e,n){let r=n.swing==="out",o=r?-e.across[1]:e.across[0],i=(e.across[0]-e.across[1])/2,s=n.hinge==="left"==e.direction>0,l=qt(n,e.exterior),a=n.leaves===2,[c,d]=[e.p0,e.p1],u=[],p=ed(n.width,l,s,n);if(p){let v=w=>w<=.02?e.p0:w>=n.width-.02?e.p1:An(e.room,e.edge,n.offset-n.width/2+w);[c,d]=[v(p.x0),v(p.x1)],u=p.panels.map(([w,x])=>[v(w),v(x)])}let h=[(c[0]+d[0])/2,(c[1]+d[1])/2],f=(a?.5:1)*Math.hypot(d[0]-c[0],d[1]-c[1]),g=u.map(([v,w])=>R`${wt(e.at(v,i+.035),e.at(w,i+.035),"nf-open-pane")}${wt(e.at(v,i-.035),e.at(w,i-.035),"nf-open-pane")}`),y=(v,w)=>{let[x,k]=e.at(v,o),[$,A]=e.at(w,o),F=e.at(v,o+(r?-f:f)),T=f*t.scale,I=(F[0]-x)*(A-k)-(F[1]-k)*($-x)>0?1:0;return R`<path d="M${x} ${k}L${F[0]} ${F[1]}A${T} ${T} 0 0 ${I} ${$} ${A}" />`},b;return l==="passage"?b=wt(e.at(e.p0,i),e.at(e.p1,i),"nf-open-passage"):l==="sliding"?b=wt(e.at(c,o),e.at(d,o)):a?b=R`${y(c,h)}${y(d,h)}`:b=s?y(c,d):y(d,c),R`${g}${b}`}function fw(t,e){let n=(t.across[0]-t.across[1])/2;if(e.opens==="slide"){let o=e.leaves===2?4:2,i=l=>[t.p0[0]+(t.p1[0]-t.p0[0])*l,t.p0[1]+(t.p1[1]-t.p0[1])*l],s=Array.from({length:o},(l,a)=>{let c=e.leaves===2?a===1||a===2?.035:-.035:a===0?.035:-.035;return wt(t.at(i(Math.max(0,a/o-.03)),n+c),t.at(i(Math.min(1,(a+1)/o+.03)),n+c))});return R`${s}`}let r=e.leaves===2?wt(t.at([(t.p0[0]+t.p1[0])/2,(t.p0[1]+t.p1[1])/2],t.across[0]),t.at([(t.p0[0]+t.p1[0])/2,(t.p0[1]+t.p1[1])/2],-t.across[1])):_;return R`${wt(t.at(t.p0,n+.035),t.at(t.p1,n+.035))}${wt(t.at(t.p0,n-.035),t.at(t.p1,n-.035))}${r}`}function Uf(t,e,n,r){let o=e.openings.find(s=>s.id===r)?.front??null,i=s=>{let l=uw(t,s,e,n);if(!l)return _;let a=[l.at(l.p0,l.across[0]+.01),l.at(l.p1,l.across[0]+.01),l.at(l.p1,-l.across[1]-.01),l.at(l.p0,-l.across[1]-.01)],c=s.type==="door"&&_s(qt(s,l.exterior)),d=s.id===r||!!s.front&&s.front===o,u=`nf-open nf-open-${s.type}${c?" nf-open-front":""}${d?" nf-open-sel":""}`,p=s.type==="garage"?hw(l,s):s.type==="door"?pw(t,l,s):fw(l,s);return R`<g data-opening=${s.id} class=${u}><polygon class="nf-open-gap" points=${a.map(h=>h.join(",")).join(" ")} />${p}</g>`};return R`<g>${e.openings.map(i)}</g>`}var Zf=t=>Math.round(t*1e3)/1e3,qf=t=>Math.round(t*100)/100;function Zn(t,e){let n=[...t??[]].slice(0,e);for(;n.length<e;)n.push(null);return n}var Pi=t=>t.every(e=>e===null);function co(t,e){let[n,r]=[t.points[e],t.points[(e+1)%t.points.length]];return Math.hypot(r[0]-n[0],r[1]-n[1])}function cl(t,e,n){let r=Zn(t.wall_heights,t.points.length);r[e]=n,t.wall_heights=Pi(r)?void 0:r,Ii(t,e,null)}function Ii(t,e,n){if(n===null&&!t.wall_slopes)return;let r=Zn(t.wall_slopes,t.points.length);r[e]=n,t.wall_slopes=Pi(r)?void 0:r}function Yf(t,e,n,r){let[o,i]=[n,r].map(l=>Math.min(30,Math.max(.05,Zf(l)))),s=Zn(t.wall_heights,t.points.length);s[e]=o,t.wall_heights=s,Ii(t,e,i)}function Xf(t,e,n){let r=t.wall_heights?.[e];Ii(t,e,null),typeof r=="number"&&r>=n-.005&&cl(t,e,null)}function Qf(t,e,n,r,o){let i=Zn(t.wall_heights,t.points.length),s=i[e],l=Array.isArray(s)?[...s]:new Array(o).fill(typeof s=="number"?s:null);for(;l.length<o;)l.push(null);l[n]=r,i[e]=l.every(a=>a===l[0])?l[0]:l,t.wall_heights=Pi(i)?void 0:i,Ii(t,e,null)}function Jf(t,e,n,r){let o=co(t,e),i=n===void 0?0:r[n],s=n===void 0?o:r[n+1]??o;if(s-i<.4)return!1;let l=qf((i+s)/2),a=Zn(t.wall_splits,t.points.length);a[e]=[...a[e]??[],l].sort((d,u)=>d-u),t.wall_splits=a;let c=t.wall_heights?.[e];return Array.isArray(c)&&c.splice((n??0)+1,0,c[n??0]??null),!0}function em(t,e,n,r,o){let i=co(t,e),s=o.filter(d=>Math.abs(d-n)>.001&&d>0),l=Math.max(.1,Math.min(i-.1,qf(r)));s.some(d=>Math.abs(d-l)<.1)&&(l=n);let a=t.wall_splits?.[e];if(!a)return;let c=a.findIndex(d=>Math.abs(d-n)<.001);c>=0&&(a[c]=l),a.sort((d,u)=>d-u)}function tm(t,e,n,r){let o=t.wall_splits;if(!o?.[e])return;let i=o[e].filter(l=>Math.abs(l-n)>.001);o[e]=i.length>0?i:null,o.every(l=>!l)&&(t.wall_splits=void 0);let s=t.wall_heights?.[e];Array.isArray(s)&&(s.splice(r,1),s.every(l=>l===s[0])&&(t.wall_heights[e]=s[0]??null))}function nm(t,e,n,r,o=1){let i=Zn(t.wall_thickness,t.points.length);if(r===void 0||o<2)i[e]=n;else{let s=i[e],l=Array. Line truncated
${M(r("note_photo_hint"),"nf-wide")}`}function uw(t,e,n,r){let o=Ie(e,n.rooms,n.walls??[]);if(!o)return null;let{room:i,edge:s}=o,l=Pt(r,e,o),a=Fn(i,s,e.offset-e.width/2),c=Fn(i,s,e.offset+e.width/2),d=[(c[0]-a[0])/(e.width||1),(c[1]-a[1])/(e.width||1)],u=ge(i.points)>=0?1:-1,p=[-d[1]*u,d[0]*u],h=[.06,.06];return l&&(h=l.wall.free||l.wall.roomLeft===i.id?[l.wall.left,l.wall.right]:[l.wall.right,l.wall.left]),{room:i,edge:s,p0:a,p1:c,inward:p,direction:u,across:h,exterior:l?.wall.exterior??!1,at:(f,g)=>t.toScreen([f[0]+p[0]*g,f[1]+p[1]*g])}}var vt=(t,e,n="")=>R`<line class=${n} x1=${t[0]} y1=${t[1]} x2=${e[0]} y2=${e[1]} />`;function hw(t,e){let n=t.across[0]-.04,r=t.across[0]+Math.min(2,e.height),[o,i,s,l]=[t.at(t.p0,n),t.at(t.p1,n),t.at(t.p0,r),t.at(t.p1,r)];return R`${vt(o,i)}<path class="nf-open-track" d="M${o[0]} ${o[1]}L${s[0]} ${s[1]}M${i[0]} ${i[1]}L${l[0]} ${l[1]}" />`}function pw(t,e,n){let r=n.swing==="out",o=r?-e.across[1]:e.across[0],i=(e.across[0]-e.across[1])/2,s=n.hinge==="left"==e.direction>0,l=Yt(n,e.exterior),a=n.leaves===2,[c,d]=[e.p0,e.p1],u=[],p=ed(n.width,l,s,n);if(p){let v=w=>w<=.02?e.p0:w>=n.width-.02?e.p1:Fn(e.room,e.edge,n.offset-n.width/2+w);[c,d]=[v(p.x0),v(p.x1)],u=p.panels.map(([w,x])=>[v(w),v(x)])}let h=[(c[0]+d[0])/2,(c[1]+d[1])/2],f=(a?.5:1)*Math.hypot(d[0]-c[0],d[1]-c[1]),g=u.map(([v,w])=>R`${vt(e.at(v,i+.035),e.at(w,i+.035),"nf-open-pane")}${vt(e.at(v,i-.035),e.at(w,i-.035),"nf-open-pane")}`),y=(v,w)=>{let[x,k]=e.at(v,o),[$,A]=e.at(w,o),F=e.at(v,o+(r?-f:f)),T=f*t.scale,I=(F[0]-x)*(A-k)-(F[1]-k)*($-x)>0?1:0;return R`<path d="M${x} ${k}L${F[0]} ${F[1]}A${T} ${T} 0 0 ${I} ${$} ${A}" />`},b;return l==="passage"?b=vt(e.at(e.p0,i),e.at(e.p1,i),"nf-open-passage"):l==="sliding"?b=vt(e.at(c,o),e.at(d,o)):a?b=R`${y(c,h)}${y(d,h)}`:b=s?y(c,d):y(d,c),R`${g}${b}`}function fw(t,e){let n=(t.across[0]-t.across[1])/2;if(e.opens==="slide"){let o=e.leaves===2?4:2,i=l=>[t.p0[0]+(t.p1[0]-t.p0[0])*l,t.p0[1]+(t.p1[1]-t.p0[1])*l],s=Array.from({length:o},(l,a)=>{let c=e.leaves===2?a===1||a===2?.035:-.035:a===0?.035:-.035;return vt(t.at(i(Math.max(0,a/o-.03)),n+c),t.at(i(Math.min(1,(a+1)/o+.03)),n+c))});return R`${s}`}let r=e.leaves===2?vt(t.at([(t.p0[0]+t.p1[0])/2,(t.p0[1]+t.p1[1])/2],t.across[0]),t.at([(t.p0[0]+t.p1[0])/2,(t.p0[1]+t.p1[1])/2],-t.across[1])):_;return R`${vt(t.at(t.p0,n+.035),t.at(t.p1,n+.035))}${vt(t.at(t.p0,n-.035),t.at(t.p1,n-.035))}${r}`}function Uf(t,e,n,r){let o=e.openings.find(s=>s.id===r)?.front??null,i=s=>{let l=uw(t,s,e,n);if(!l)return _;let a=[l.at(l.p0,l.across[0]+.01),l.at(l.p1,l.across[0]+.01),l.at(l.p1,-l.across[1]-.01),l.at(l.p0,-l.across[1]-.01)],c=s.type==="door"&&_s(Yt(s,l.exterior)),d=s.id===r||!!s.front&&s.front===o,u=`nf-open nf-open-${s.type}${c?" nf-open-front":""}${d?" nf-open-sel":""}`,p=s.type==="garage"?hw(l,s):s.type==="door"?pw(t,l,s):fw(l,s);return R`<g data-opening=${s.id} class=${u}><polygon class="nf-open-gap" points=${a.map(h=>h.join(",")).join(" ")} />${p}</g>`};return R`<g>${e.openings.map(i)}</g>`}var Zf=t=>Math.round(t*1e3)/1e3,qf=t=>Math.round(t*100)/100;function qn(t,e){let n=[...t??[]].slice(0,e);for(;n.length<e;)n.push(null);return n}var Pi=t=>t.every(e=>e===null);function co(t,e){let[n,r]=[t.points[e],t.points[(e+1)%t.points.length]];return Math.hypot(r[0]-n[0],r[1]-n[1])}function cl(t,e,n){let r=qn(t.wall_heights,t.points.length);r[e]=n,t.wall_heights=Pi(r)?void 0:r,Ii(t,e,null)}function Ii(t,e,n){if(n===null&&!t.wall_slopes)return;let r=qn(t.wall_slopes,t.points.length);r[e]=n,t.wall_slopes=Pi(r)?void 0:r}function Yf(t,e,n,r){let[o,i]=[n,r].map(l=>Math.min(30,Math.max(.05,Zf(l)))),s=qn(t.wall_heights,t.points.length);s[e]=o,t.wall_heights=s,Ii(t,e,i)}function Xf(t,e,n){let r=t.wall_heights?.[e];Ii(t,e,null),typeof r=="number"&&r>=n-.005&&cl(t,e,null)}function Qf(t,e,n,r,o){let i=qn(t.wall_heights,t.points.length),s=i[e],l=Array.isArray(s)?[...s]:new Array(o).fill(typeof s=="number"?s:null);for(;l.length<o;)l.push(null);l[n]=r,i[e]=l.every(a=>a===l[0])?l[0]:l,t.wall_heights=Pi(i)?void 0:i,Ii(t,e,null)}function Jf(t,e,n,r){let o=co(t,e),i=n===void 0?0:r[n],s=n===void 0?o:r[n+1]??o;if(s-i<.4)return!1;let l=qf((i+s)/2),a=qn(t.wall_splits,t.points.length);a[e]=[...a[e]??[],l].sort((d,u)=>d-u),t.wall_splits=a;let c=t.wall_heights?.[e];return Array.isArray(c)&&c.splice((n??0)+1,0,c[n??0]??null),!0}function em(t,e,n,r,o){let i=co(t,e),s=o.filter(d=>Math.abs(d-n)>.001&&d>0),l=Math.max(.1,Math.min(i-.1,qf(r)));s.some(d=>Math.abs(d-l)<.1)&&(l=n);let a=t.wall_splits?.[e];if(!a)return;let c=a.findIndex(d=>Math.abs(d-n)<.001);c>=0&&(a[c]=l),a.sort((d,u)=>d-u)}function tm(t,e,n,r){let o=t.wall_splits;if(!o?.[e])return;let i=o[e].filter(l=>Math.abs(l-n)>.001);o[e]=i.length>0?i:null,o.every(l=>!l)&&(t.wall_splits=void 0);let s=t.wall_heights?.[e];Array.isArray(s)&&(s.splice(r,1),s.every(l=>l===s[0])&&(t.wall_heights[e]=s[0]??null))}function nm(t,e,n,r,o=1){let i=qn(t.wall_thickness,t.points.length);if(r===void 0||o<2)i[e]=n;else{let s=i[e],l=Array. Line truncated
<span><b>${x}</b><br /><span class="nf-muted">${he(t.hass,b)}</span></span>
${f===0?m`<span class="nf-muted">${r("wall_none")}</span>`:A?m`<span class="nf-wide nf-split-row" title=${r("wall_slope_hint")}
>${E(t,r("wall_slope_start"),d,z=>n.setSlope(e,c,z,$),.05,.05)}
@@ -1340,33 +1340,34 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
@input=${c=>c.target.setCustomValidity("")}
@change=${c=>{let d=c.target;a(d.value,"none",d,!0)&&(d.value="")}} /></label>
<p class="nf-sub" data-effect-feedback role="status" aria-live="polite">${t.t("light_effect_name_limit")} ${t.t("light_effect_count_limit")}</p>
</details>`}var mw=/speaker|sound|subwoofer|receiver|smart_|display|tv|media|turntable|projector|console/;function gw(t,e,n){let r=X(e),o=t.hass?.language??"en",i=[...Oo.map(l=>({type:l,label:t.t(`furn_${l}`)})),...n.flatMap(l=>l.items.map(a=>({type:ue(l.id,a.id),label:`${Ye(a,ue(l.id,a.id),o)} \xB7 ${Oe(l,o)}`})))],s=l=>r==="light"?ce(l):r==="climate"?l==="radiator"||yn(l):e.startsWith("vacuum.")?l==="robot_vacuum"||gt(l)&&l.endsWith(":robot_vacuum"):r==="media"?wr(l)||Et(l)&&mw.test(l):Et(l)&&!ce(l);return i.filter(l=>s(l.type)).sort((l,a)=>l.label.localeCompare(a.label))}function _w(t,e,n){if(!t.admin)return _;let r=gw(t,e.entity_id,n.packs);return r.length===0?_:m`<label class="nf-field nf-wide" title=${t.t("as_furniture_hint")}
</details>`}var mw=/speaker|sound|subwoofer|receiver|smart_|display|tv|media|turntable|projector|console/;function gw(t,e,n){let r=X(e),o=t.hass?.language??"en",i=[...Oo.map(l=>({type:l,label:t.t(`furn_${l}`)})),...n.flatMap(l=>l.items.map(a=>({type:ue(l.id,a.id),label:`${Ye(a,ue(l.id,a.id),o)} \xB7 ${Oe(l,o)}`})))],s=l=>r==="light"?ce(l):r==="climate"?l==="radiator"||wn(l):e.startsWith("vacuum.")?l==="robot_vacuum"||_t(l)&&l.endsWith(":robot_vacuum"):r==="media"?wr(l)||Et(l)&&mw.test(l):Et(l)&&!ce(l);return i.filter(l=>s(l.type)).sort((l,a)=>l.label.localeCompare(a.label))}function _w(t,e,n){if(!t.admin)return _;let r=gw(t,e.entity_id,n.packs);return r.length===0?_:m`<label class="nf-field nf-wide" title=${t.t("as_furniture_hint")}
>${t.t("as_furniture")}
<select @change=${o=>o.target.value&&n.asFurniture(e,o.target.value)}>
<option value="" selected>${t.t("as_furniture_pick")}</option>
${r.map(o=>m`<option value=${o.type}>${o.label}</option>`)}
</select>
</label>`}function bw(t,e,n){let r=t.hass?.language??"en";return sd(e.entity_id,t.hass?.states[e.entity_id]).map(({pluginId:o,name:i,settings:s})=>{let l=ad(s,e.plugin?.[o]),a=(d,u)=>n({plugin:{...e.plugin??{},[o]:{...e.plugin?.[o]??{},[d]:u}}}),c=s.map(d=>{let u=Vo(d.label,r),p=d.hint?Vo(d.hint,r):void 0;if(d.type==="boolean")return H(t,u,l[d.key]===!0,f=>a(d.key,f),{title:p});if(d.type==="select"){let f=(d.options??[]).map(([g,y])=>[g,Vo(y,r)]);return O(t,u,String(l[d.key]),f,g=>a(d.key,g),{wide:!0,title:p})}let h=f=>Math.min(d.max??1/0,Math.max(d.min??-1/0,f));return E(t,u,Number(l[d.key]),f=>a(d.key,h(f)),d.step??1,d.min)});return m`<h4 class="nf-lib-head nf-wide">🔌 ${i}</h4>${c}`})}function ul(t,e,n){let r=t.t,o=X(e.entity_id)??(t.hass?Ne(t.hass,e.entity_id):null),i=o==="light",s=e.mount??"ceiling",l=o?Eo(o,t.floor?lt(t.floor,e.x,e.z):2.5,i?s:null):1,a=p=>n.update(p),c=Cn(t,e.entity_id,e.icon),d=p=>a({mount:p,y:null}),u=["ceiling","floor","table","wall"].map(p=>[p,r(`lamp_${p}`)]);return m`<section>
</label>`}function bw(t,e,n){let r=t.hass?.language??"en";return sd(e.entity_id,t.hass?.states[e.entity_id]).map(({pluginId:o,name:i,settings:s})=>{let l=ad(s,e.plugin?.[o]),a=(d,u)=>n({plugin:{...e.plugin??{},[o]:{...e.plugin?.[o]??{},[d]:u}}}),c=s.map(d=>{let u=Vo(d.label,r),p=d.hint?Vo(d.hint,r):void 0;if(d.type==="boolean")return H(t,u,l[d.key]===!0,f=>a(d.key,f),{title:p});if(d.type==="select"){let f=(d.options??[]).map(([g,y])=>[g,Vo(y,r)]);return O(t,u,String(l[d.key]),f,g=>a(d.key,g),{wide:!0,title:p})}let h=f=>Math.min(d.max??1/0,Math.max(d.min??-1/0,f));return E(t,u,Number(l[d.key]),f=>a(d.key,h(f)),d.step??1,d.min)});return m`<h4 class="nf-lib-head nf-wide">🔌 ${i}</h4>${c}`})}function ul(t,e,n){let r=t.t,o=X(e.entity_id)??(t.hass?Ne(t.hass,e.entity_id):null),i=o==="light",s=e.mount??"ceiling",l=o?Eo(o,t.floor?ct(t.floor,e.x,e.z):2.5,i?s:null):1,a=p=>n.update(p),c=Nn(t,e.entity_id,e.icon),d=p=>a({mount:p,y:null}),u=["ceiling","floor","table","wall"].map(p=>[p,r(`lamp_${p}`)]);return m`<section>
<div class="nf-h3row"><h3>${r("device")}</h3>${n.lockButton}</div>
<p class="nf-dev-title">
${c?m`<ha-icon class="nf-dev-icon" .icon=${c}></ha-icon>`:m`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d=${o?Nt(o):""} /></svg>`}
${c?m`<ha-icon class="nf-dev-icon" .icon=${c}></ha-icon>`:m`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d=${o?Bt(o):""} /></svg>`}
${W(t.hass,e.entity_id)}
</p>
<div class="nf-form">
${i?m`${O(t,r("lamp_mount"),s,u,d,{wide:!0})}${an(t,e.glow_scale,p=>a({glow_scale:p}))}`:_}
${o==="cover"?P(t,r("cover_tilt_entity"),e.cover_tilt??null,void 0,L(t.hass,p=>p.startsWith("cover.")),p=>a({cover_tilt:p&&p!=="none"?p:null})):_}
${i?m`${O(t,r("lamp_mount"),s,u,d,{wide:!0})}${ln(t,e.glow_scale,p=>a({glow_scale:p}))}`:_}
${i?Di(t,e,t.hass?.states[e.entity_id]?.attributes.effect_list,a):_}
${e.entity_id.startsWith("media_player.")?an(t,e.sound_rings,p=>a({sound_rings:p}),{label:"sound_rings",hint:"sound_rings_hint",lowest:0}):_}
${e.entity_id.startsWith("media_player.")?ln(t,e.sound_rings,p=>a({sound_rings:p}),{label:"sound_rings",hint:"sound_rings_hint",lowest:0}):_}
${E(t,r("x"),e.x,p=>a({x:p}))} ${E(t,r("z"),e.z,p=>a({z:p}))}
${E(t,r("marker_height"),e.y??l,p=>a({y:Math.max(0,p)}),.05,0)}
${E(t,r("rotation"),e.rotation??0,p=>a({rotation:(p%360+360)%360}),1)}
${i?H(t,r("device_simple"),!!e.simple,p=>a({simple:p||void 0}),{title:r("device_simple_hint")}):_}
${o&&uc.has(o)?H(t,r("device_confirm"),!!e.confirm,p=>a({confirm:p}),{title:r("device_confirm_hint")}):_}
${H(t,r("device_outside"),!!e.outside,p=>a({outside:p||void 0}),{title:r("device_outside_hint")})}
${Nn(t,e.marker??null,p=>a({marker:p}))}
${Bn(t,e.pin_offset,p=>a({pin_offset:p}))}
${Bn(t,e.marker??null,p=>a({marker:p}))}
${Wn(t,e.pin_offset,p=>a({pin_offset:p}))}
${Z(t,r("device_name"),e.name??"",p=>a({name:p||null}),{wide:!0,maxlength:60,title:r("device_name_hint"),placeholder:W(t.hass,e.entity_id)})}
${e.name?H(t,r("show_name"),!!e.show_name,p=>a({show_name:p||void 0})):_}
${Ht(t,e.icon,p=>a({icon:p}))}
${Lt(t,e.icon,p=>a({icon:p}))}
${bw(t,e,a)}
</div>
${t.admin?m`<div class="nf-actions">
@@ -1375,34 +1376,34 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${_w(t,e,n)}
<button class="nf-btn nf-danger" @click=${()=>n.remove()}>${r("devices_remove")}</button>
</div>`:_}
</section>`}var uo=t=>Number(t);function Oi(t){if(Array.isArray(t)){let[i,s]=[uo(t[0]),uo(t[1])];return Number.isFinite(i)&&Number.isFinite(s)?[i,s]:null}if(!t||typeof t!="object")return null;let{x:e,y:n}=t,[r,o]=[uo(e),uo(n)];return Number.isFinite(r)&&Number.isFinite(o)?[r,o]:null}function dm(t){return t?Oi(t.charger)??Oi(t.charger_position):null}function Hi(t){for(let[e,n]of Object.entries(t.states))if(e.startsWith("camera.")&&(Oi(n.attributes?.vacuum_position)??dm(n.attributes)))return e;return null}var hl=(t,e)=>e?[t[0],-t[1]]:t;var um=5e-4,hm=2,yw=1.5;function pl(t,e){let n=e?t.states[e]?.attributes:void 0;return{at:n?Oi(n.vacuum_position):null,dock:dm(n)}}function pm(t,e,n=!1){let r=Math.hypot(e.plan[0]-t.plan[0],e.plan[1]-t.plan[1]),o=Math.hypot(e.grid[0]-t.grid[0],e.grid[1]-t.grid[1]);if(!(o>1e-6)||!(r>=yw))return{cal:null,reason:"close"};let i=r/o;return i>=um&&i<=hm?{cal:{a:t.plan,ga:t.grid,b:e.plan,gb:e.grid,mirror:n}}:{cal:null,reason:"scale"}}function fm(t,e){let n=e?t.states[e]?.attributes?.rooms:void 0;if(!n||typeof n!="object")return[];let r=[];for(let o of Object.values(n)){if(!o||typeof o!="object")continue;let i=o,s=typeof i.name=="string"?i.name.trim():"",l=[i.x0,i.y0,i.x1,i.y1].map(uo);!s||!l.every(Number.isFinite)||r.push({name:s,center:[(l[0]+l[2])/2,(l[1]+l[3])/2]})}return r}var lm=t=>t.toLocaleLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^\p{L}\p{N}]+/gu,"");function ww(t){let e=t.length,[n,r]=t.reduce((h,f)=>[h[0]+f.seen[0]/e,h[1]+f.seen[1]/e],[0,0]),[o,i]=t.reduce((h,f)=>[h[0]+f.plan[0]/e,h[1]+f.plan[1]/e],[0,0]),[s,l,a]=[0,0,0];for(let h of t){let[f,g]=[h.seen[0]-n,h.seen[1]-r],[y,b]=[h.plan[0]-o,h.plan[1]-i];s+=f*y+g*b,l+=f*b-g*y,a+=f*f+g*g}if(!(a>1e-9))return null;let[c,d]=[s/a,l/a],u=h=>{let[f,g]=[h[0]-n,h[1]-r];return[o+c*f-d*g,i+d*f+c*g]},p=Math.sqrt(t.reduce((h,f)=>h+Math.hypot(u(f.seen)[0]-f.plan[0],u(f.seen)[1]-f.plan[1])**2,0)/e);return{map:u,scale:Math.hypot(c,d),rms:p}}function mm(t,e,n=!1){let r=new Map(e.map(g=>[lm(g.name),g])),o=[],i=new Set;for(let g of t){let y=lm(g.name),b=r.get(y);if(!b||i.has(y)||g.points.length<3)continue;i.add(y);let v=g.points.map(x=>x[0]),w=g.points.map(x=>x[1]);o.push({name:g.name,plan:[(Math.min(...v)+Math.max(...v))/2,(Math.min(...w)+Math.max(...w))/2],grid:b.center})}let s=o.map(g=>g.name);if(o.length<2)return{cal:null,reason:"rooms",matched:s};let a=(o.length>=3?[!1,!0]:[n]).flatMap(g=>{let y=ww(o.map(b=>({plan:b.plan,seen:hl(b.grid,g)})));return y?[{mirror:g,...y}]:[]}).sort((g,y)=>g.rms-y.rms)[0];if(!a)return{cal:null,reason:"rooms",matched:s};if(!(a.scale>=um&&a.scale<=hm))return{cal:null,reason:"scale",matched:s};let c=Math.max(...o.map(g=>Math.hypot(g.plan[0]-o[0].plan[0],g.plan[1]-o[0].plan[1])));if(!(a.rms<=Math.max(1,c/4)))return{cal:null,reason:"fit",matched:s};let[d,u,p]=[0,1,-1];for(let g=0;g<o.length;g++)for(let y=g+1;y<o.length;y++){let b=Math.hypot(o[g].grid[0]-o[y].grid[0],o[g].grid[1]-o[y].grid[1]);b>p&&([d,u,p]=[g,y,b])}let[h,f]=[o[d].grid,o[u].grid];return{cal:{a:a.map(hl(h,a.mirror)),ga:h,b:a.map(hl(f,a.mirror)),gb:f,mirror:a.mirror},matched:s,rms:a.rms}}function gm(t,e){let[n,r]=[(t.a[0]+t.b[0])/2,(t.a[1]+t.b[1])/2],o=(e.turn??0)*Math.PI/180,[i,s,l]=[Math.cos(o),Math.sin(o),e.grow??1],[a,c]=e.move??[0,0],d=u=>{let[p,h]=[(u[0]-n)*l,(u[1]-r)*l];return[cm(n+p*i-h*s+a),cm(r+p*s+h*i+c)]};return{...t,a:d(t.a),b:d(t.b)}}var cm=t=>Math.round(t*1e3)/1e3;var vw=/^(binary_sensor|switch|input_boolean|light|fan|person|device_tracker|sensor)\./,vt=t=>t==="none"?null:t;function fl(t,e,n){let r=t.t,o=L(t.hass,a=>vw.test(a)),i=!!e.state_entity&&e.state_entity!=="none",s=i&&!!e.state_entity2&&e.state_entity2!=="none",l=[["left_right",r("furn_state_left_right")],["top_bottom",r("furn_state_top_bottom")]];return m`${P(t,r("furn_state_entity"),e.state_entity??null,void 0,o,a=>n.update({state_entity:vt(a)}))}
${i?P(t,r("furn_state_entity2"),e.state_entity2??null,void 0,o,a=>n.update({state_entity2:vt(a)})):_}
</section>`}var uo=t=>Number(t);function Oi(t){if(Array.isArray(t)){let[i,s]=[uo(t[0]),uo(t[1])];return Number.isFinite(i)&&Number.isFinite(s)?[i,s]:null}if(!t||typeof t!="object")return null;let{x:e,y:n}=t,[r,o]=[uo(e),uo(n)];return Number.isFinite(r)&&Number.isFinite(o)?[r,o]:null}function dm(t){return t?Oi(t.charger)??Oi(t.charger_position):null}function Hi(t){for(let[e,n]of Object.entries(t.states))if(e.startsWith("camera.")&&(Oi(n.attributes?.vacuum_position)??dm(n.attributes)))return e;return null}var hl=(t,e)=>e?[t[0],-t[1]]:t;var um=5e-4,hm=2,yw=1.5;function pl(t,e){let n=e?t.states[e]?.attributes:void 0;return{at:n?Oi(n.vacuum_position):null,dock:dm(n)}}function pm(t,e,n=!1){let r=Math.hypot(e.plan[0]-t.plan[0],e.plan[1]-t.plan[1]),o=Math.hypot(e.grid[0]-t.grid[0],e.grid[1]-t.grid[1]);if(!(o>1e-6)||!(r>=yw))return{cal:null,reason:"close"};let i=r/o;return i>=um&&i<=hm?{cal:{a:t.plan,ga:t.grid,b:e.plan,gb:e.grid,mirror:n}}:{cal:null,reason:"scale"}}function fm(t,e){let n=e?t.states[e]?.attributes?.rooms:void 0;if(!n||typeof n!="object")return[];let r=[];for(let o of Object.values(n)){if(!o||typeof o!="object")continue;let i=o,s=typeof i.name=="string"?i.name.trim():"",l=[i.x0,i.y0,i.x1,i.y1].map(uo);!s||!l.every(Number.isFinite)||r.push({name:s,center:[(l[0]+l[2])/2,(l[1]+l[3])/2]})}return r}var lm=t=>t.toLocaleLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^\p{L}\p{N}]+/gu,"");function ww(t){let e=t.length,[n,r]=t.reduce((h,f)=>[h[0]+f.seen[0]/e,h[1]+f.seen[1]/e],[0,0]),[o,i]=t.reduce((h,f)=>[h[0]+f.plan[0]/e,h[1]+f.plan[1]/e],[0,0]),[s,l,a]=[0,0,0];for(let h of t){let[f,g]=[h.seen[0]-n,h.seen[1]-r],[y,b]=[h.plan[0]-o,h.plan[1]-i];s+=f*y+g*b,l+=f*b-g*y,a+=f*f+g*g}if(!(a>1e-9))return null;let[c,d]=[s/a,l/a],u=h=>{let[f,g]=[h[0]-n,h[1]-r];return[o+c*f-d*g,i+d*f+c*g]},p=Math.sqrt(t.reduce((h,f)=>h+Math.hypot(u(f.seen)[0]-f.plan[0],u(f.seen)[1]-f.plan[1])**2,0)/e);return{map:u,scale:Math.hypot(c,d),rms:p}}function mm(t,e,n=!1){let r=new Map(e.map(g=>[lm(g.name),g])),o=[],i=new Set;for(let g of t){let y=lm(g.name),b=r.get(y);if(!b||i.has(y)||g.points.length<3)continue;i.add(y);let v=g.points.map(x=>x[0]),w=g.points.map(x=>x[1]);o.push({name:g.name,plan:[(Math.min(...v)+Math.max(...v))/2,(Math.min(...w)+Math.max(...w))/2],grid:b.center})}let s=o.map(g=>g.name);if(o.length<2)return{cal:null,reason:"rooms",matched:s};let a=(o.length>=3?[!1,!0]:[n]).flatMap(g=>{let y=ww(o.map(b=>({plan:b.plan,seen:hl(b.grid,g)})));return y?[{mirror:g,...y}]:[]}).sort((g,y)=>g.rms-y.rms)[0];if(!a)return{cal:null,reason:"rooms",matched:s};if(!(a.scale>=um&&a.scale<=hm))return{cal:null,reason:"scale",matched:s};let c=Math.max(...o.map(g=>Math.hypot(g.plan[0]-o[0].plan[0],g.plan[1]-o[0].plan[1])));if(!(a.rms<=Math.max(1,c/4)))return{cal:null,reason:"fit",matched:s};let[d,u,p]=[0,1,-1];for(let g=0;g<o.length;g++)for(let y=g+1;y<o.length;y++){let b=Math.hypot(o[g].grid[0]-o[y].grid[0],o[g].grid[1]-o[y].grid[1]);b>p&&([d,u,p]=[g,y,b])}let[h,f]=[o[d].grid,o[u].grid];return{cal:{a:a.map(hl(h,a.mirror)),ga:h,b:a.map(hl(f,a.mirror)),gb:f,mirror:a.mirror},matched:s,rms:a.rms}}function gm(t,e){let[n,r]=[(t.a[0]+t.b[0])/2,(t.a[1]+t.b[1])/2],o=(e.turn??0)*Math.PI/180,[i,s,l]=[Math.cos(o),Math.sin(o),e.grow??1],[a,c]=e.move??[0,0],d=u=>{let[p,h]=[(u[0]-n)*l,(u[1]-r)*l];return[cm(n+p*i-h*s+a),cm(r+p*s+h*i+c)]};return{...t,a:d(t.a),b:d(t.b)}}var cm=t=>Math.round(t*1e3)/1e3;var vw=/^(binary_sensor|switch|input_boolean|light|fan|person|device_tracker|sensor)\./,kt=t=>t==="none"?null:t;function fl(t,e,n){let r=t.t,o=L(t.hass,a=>vw.test(a)),i=!!e.state_entity&&e.state_entity!=="none",s=i&&!!e.state_entity2&&e.state_entity2!=="none",l=[["left_right",r("furn_state_left_right")],["top_bottom",r("furn_state_top_bottom")]];return m`${P(t,r("furn_state_entity"),e.state_entity??null,void 0,o,a=>n.update({state_entity:kt(a)}))}
${i?P(t,r("furn_state_entity2"),e.state_entity2??null,void 0,o,a=>n.update({state_entity2:kt(a)})):_}
${s?O(t,r("furn_state_split"),e.state_split==="top_bottom"?"top_bottom":"left_right",l,a=>n.update({state_split:a})):_}
${M(r("furn_state_hint"),"nf-wide")}`}function kw(t,e){let r=Rn(t.type)&&(!gt(t.type)||vc(t.type));return ce(t.type)?{accept:o=>/^(light|switch|input_boolean)\./.test(o),label:"furn_entity_light"}:t.type==="radiator"||yn(t.type)?{accept:o=>o.startsWith("climate."),label:"furn_entity_climate"}:r?{accept:o=>/^(media_player|switch|input_boolean|light)\./.test(o),label:"furn_entity_tv"}:t.type==="robot_vacuum"?{accept:o=>o.startsWith("vacuum."),label:"furn_entity_vacuum"}:/:(robot_mower|mower_dock)$/.test(t.type)?{accept:o=>o.startsWith("lawn_mower."),label:"furn_entity_mower"}:/:(sprinkler|valve_box)$/.test(t.type)?{accept:o=>/^(valve|switch|input_boolean)\./.test(o),label:"furn_entity_water"}:{accept:o=>/^(switch|media_player|fan|input_boolean|climate|vacuum|cover|valve)\./.test(o)||hc(e?.states[o]),label:"furn_entity"}}function Li(t,e,n){if(!t.hass)return null;let r=structuredClone(t.doc.floors);for(let o of r)for(let i of o.furniture)i.id===e.id&&(i[n==="fan"?"fan_entity":n]=null);return Be(t.hass,r).get(e.id)?.[n]??null}var xw=t=>t==="meter"?"energy_grid":t==="inverter"?"energy_solar_sensor":t==="home_battery"?"energy_battery_sensor":"furn_power",st=(...t)=>m`<div class="nf-form nf-links">${t}</div>`;async function $w(t){let e=t.hass?Hi(t.hass):null;if(!t.hass||!e)return{at:null,dock:null};let n=()=>{let o=t.hass?.states[e]?.attributes??{};return`${String(o.render_count??"")}|${JSON.stringify(o.vacuum_position??null)}`},r=n();try{await t.hass.fetchWithAuth?.(`/api/camera_proxy/${e}`)}catch{}for(let o=0;o<8&&n()===r;o++)await new Promise(i=>setTimeout(i,100));return pl(t.hass,e)}function Sw(t,e){let n=t.t,r=a=>t.change(c=>{c.settings.vacuum_map=gm(e,a)}),o=(a,c,d)=>m`<button class="nf-btn" title=${c} aria-label=${c} ?disabled=${!t.admin} @click=${()=>r(d)}>${a}</button>`,[i,s,l]=[n("robot_cal_nudge_move"),n("robot_cal_nudge_turn"),n("robot_cal_nudge_grow")];return m`${M(n("robot_cal_nudge"),"nf-wide")}
${M(r("furn_state_hint"),"nf-wide")}`}function kw(t,e){let r=En(t.type)&&(!_t(t.type)||vc(t.type));return ce(t.type)?{accept:o=>/^(light|switch|input_boolean)\./.test(o),label:"furn_entity_light"}:t.type==="radiator"||wn(t.type)?{accept:o=>o.startsWith("climate."),label:"furn_entity_climate"}:r?{accept:o=>/^(media_player|switch|input_boolean|light)\./.test(o),label:"furn_entity_tv"}:t.type==="robot_vacuum"?{accept:o=>o.startsWith("vacuum."),label:"furn_entity_vacuum"}:/:(robot_mower|mower_dock)$/.test(t.type)?{accept:o=>o.startsWith("lawn_mower."),label:"furn_entity_mower"}:/:(sprinkler|valve_box)$/.test(t.type)?{accept:o=>/^(valve|switch|input_boolean)\./.test(o),label:"furn_entity_water"}:{accept:o=>/^(switch|media_player|fan|input_boolean|climate|vacuum|cover|valve)\./.test(o)||hc(e?.states[o]),label:"furn_entity"}}function Li(t,e,n){if(!t.hass)return null;let r=structuredClone(t.doc.floors);for(let o of r)for(let i of o.furniture)i.id===e.id&&(i[n==="fan"?"fan_entity":n]=null);return Be(t.hass,r).get(e.id)?.[n]??null}var xw=t=>t==="meter"?"energy_grid":t==="inverter"?"energy_solar_sensor":t==="home_battery"?"energy_battery_sensor":"furn_power",st=(...t)=>m`<div class="nf-form nf-links">${t}</div>`;async function $w(t){let e=t.hass?Hi(t.hass):null;if(!t.hass||!e)return{at:null,dock:null};let n=()=>{let o=t.hass?.states[e]?.attributes??{};return`${String(o.render_count??"")}|${JSON.stringify(o.vacuum_position??null)}`},r=n();try{await t.hass.fetchWithAuth?.(`/api/camera_proxy/${e}`)}catch{}for(let o=0;o<8&&n()===r;o++)await new Promise(i=>setTimeout(i,100));return pl(t.hass,e)}function Sw(t,e){let n=t.t,r=a=>t.change(c=>{c.settings.vacuum_map=gm(e,a)}),o=(a,c,d)=>m`<button class="nf-btn" title=${c} aria-label=${c} ?disabled=${!t.admin} @click=${()=>r(d)}>${a}</button>`,[i,s,l]=[n("robot_cal_nudge_move"),n("robot_cal_nudge_turn"),n("robot_cal_nudge_grow")];return m`${M(n("robot_cal_nudge"),"nf-wide")}
<div class="nf-wide" style="display:flex;flex-wrap:wrap;gap:6px">
${o("\u2190",i,{move:[-.1,0]})}${o("\u2192",i,{move:[.1,0]})}${o("\u2191",i,{move:[0,-.1]})}${o("\u2193",i,{move:[0,.1]})}
${o("\u27F2",s,{turn:-1})}${o("\u27F3",s,{turn:1})}${o("\u2212",l,{grow:.99})}${o("+",l,{grow:1.01})}
</div>`}function Mw(t,e){let n=t.t,r=t.doc.settings.vacuum_map??null,o=t.hass?pl(t.hass,Hi(t.hass)):{at:null,dock:null},i=r?Math.hypot(r.gb[0]-r.ga[0],r.gb[1]-r.ga[1]):0,s=r&&i>0?Math.hypot(r.b[0]-r.a[0],r.b[1]-r.a[1])/i:0,l=()=>{t.pickPoint(p=>{p&&$w(t).then(h=>{if(!h.at||!h.dock)return;let f={plan:[e.x,e.z],grid:h.dock},g=pm(f,{plan:p,grid:h.at},r?.mirror??!1);g.cal&&t.change(y=>{y.settings.vacuum_map=g.cal})})})},a=t.hass?Hi(t.hass):null,c=t.hass?fm(t.hass,a):[],d=t.doc.floors.find(p=>p.furniture.some(h=>h.id===e.id)),u=()=>{if(!d)return;let p=mm(d.rooms,c,r?.mirror??!1);if(p.cal){let h=p.cal;t.change(f=>{f.settings.vacuum_map=h})}else alert(n(p.reason==="rooms"?"robot_cal_rooms_none":"robot_cal_rooms_bad",{n:p.matched.length}))};return st(M(o.at&&o.dock?r?n("robot_cal_done",{m:s.toFixed(2)}):n("robot_cal_none"):n("robot_cal_need"),"nf-wide"),c.length>=2?m`<button class="nf-btn nf-wide" ?disabled=${!t.admin||!d} @click=${u}>${n("robot_cal_rooms",{n:c.length})}</button>`:_,m`<button class="nf-btn nf-wide" ?disabled=${!t.admin||!o.at||!o.dock} @click=${l}>${n("robot_cal_do")}</button>`,r?H(t,n("robot_cal_mirror"),!!r.mirror,p=>t.change(h=>{h.settings.vacuum_map={...r,mirror:p}})):_,r?Sw(t,r):_,r?m`<button class="nf-btn nf-wide" ?disabled=${!t.admin} @click=${()=>t.change(p=>{p.settings.vacuum_map=null})}>${n("robot_cal_forget")}</button>`:_,M(n("robot_cal_hint"),"nf-wide"))}function Rw(t,e,n){let r=t.t,o=t.doc;if(!o.energy.advanced)return _;let i=Vn(o),s=o.floors.flatMap(l=>l.furniture.filter(a=>i.has(a.id)).map(a=>[a.id,`${a.name||r("furn_meter")} \xB7 ${l.name}`]));return st(O(t,r("meter_parent"),to(o,e)??"",[["",r("meter_main")],...s],l=>n.update({parent_meter:l||null}),{wide:!0}),M(r("meter_device_hint"),"nf-wide"))}function Ew(t,e,n){let r=t.t,o=t.doc;if(!o.energy.advanced)return _;let i=o.floors.flatMap(c=>c.furniture.filter(d=>hh(o,e,d)).map(d=>[d.id,`${d.name||r("furn_meter")} \xB7 ${c.name}`])),s=!!un(o,e),l=e.meter_floors??[],a=(c,d)=>n.update({meter_floors:d?[...l.filter(u=>u!==c),c]:l.filter(u=>u!==c)});return st(O(t,r("meter_parent"),s?e.parent_meter:"",[["",r("meter_parent_none")],...i],c=>n.update({parent_meter:c||null}),{wide:!0}),s?H(t,r("energy_invert"),!!e.meter_invert,c=>n.update({meter_invert:c})):_,s?m`<div class="nf-sub nf-wide">${r("meter_floors")}</div>${o.floors.map(c=>H(t,c.name,l.includes(c.id),d=>a(c.id,d)))}`:_,M(r("meter_sub_hint"),"nf-wide"))}function _m(t,e,n,r){let o=t.t,i=n==="mail"?s=>/^(binary_sensor|sensor|input_boolean)\./.test(s):s=>/^(sensor|binary_sensor|calendar)\./.test(s);return m`<div class="nf-form nf-links">
${P(t,o(`care_entity_${n}`),e.care_entity??null,void 0,L(t.hass,i),s=>r.update({care_entity:vt(s)}))}
</div>`}function Mw(t,e){let n=t.t,r=t.doc.settings.vacuum_map??null,o=t.hass?pl(t.hass,Hi(t.hass)):{at:null,dock:null},i=r?Math.hypot(r.gb[0]-r.ga[0],r.gb[1]-r.ga[1]):0,s=r&&i>0?Math.hypot(r.b[0]-r.a[0],r.b[1]-r.a[1])/i:0,l=()=>{t.pickPoint(p=>{p&&$w(t).then(h=>{if(!h.at||!h.dock)return;let f={plan:[e.x,e.z],grid:h.dock},g=pm(f,{plan:p,grid:h.at},r?.mirror??!1);g.cal&&t.change(y=>{y.settings.vacuum_map=g.cal})})})},a=t.hass?Hi(t.hass):null,c=t.hass?fm(t.hass,a):[],d=t.doc.floors.find(p=>p.furniture.some(h=>h.id===e.id)),u=()=>{if(!d)return;let p=mm(d.rooms,c,r?.mirror??!1);if(p.cal){let h=p.cal;t.change(f=>{f.settings.vacuum_map=h})}else alert(n(p.reason==="rooms"?"robot_cal_rooms_none":"robot_cal_rooms_bad",{n:p.matched.length}))};return st(M(o.at&&o.dock?r?n("robot_cal_done",{m:s.toFixed(2)}):n("robot_cal_none"):n("robot_cal_need"),"nf-wide"),c.length>=2?m`<button class="nf-btn nf-wide" ?disabled=${!t.admin||!d} @click=${u}>${n("robot_cal_rooms",{n:c.length})}</button>`:_,m`<button class="nf-btn nf-wide" ?disabled=${!t.admin||!o.at||!o.dock} @click=${l}>${n("robot_cal_do")}</button>`,r?H(t,n("robot_cal_mirror"),!!r.mirror,p=>t.change(h=>{h.settings.vacuum_map={...r,mirror:p}})):_,r?Sw(t,r):_,r?m`<button class="nf-btn nf-wide" ?disabled=${!t.admin} @click=${()=>t.change(p=>{p.settings.vacuum_map=null})}>${n("robot_cal_forget")}</button>`:_,M(n("robot_cal_hint"),"nf-wide"))}function Rw(t,e,n){let r=t.t,o=t.doc;if(!o.energy.advanced)return _;let i=Kn(o),s=o.floors.flatMap(l=>l.furniture.filter(a=>i.has(a.id)).map(a=>[a.id,`${a.name||r("furn_meter")} \xB7 ${l.name}`]));return st(O(t,r("meter_parent"),to(o,e)??"",[["",r("meter_main")],...s],l=>n.update({parent_meter:l||null}),{wide:!0}),M(r("meter_device_hint"),"nf-wide"))}function Ew(t,e,n){let r=t.t,o=t.doc;if(!o.energy.advanced)return _;let i=o.floors.flatMap(c=>c.furniture.filter(d=>hh(o,e,d)).map(d=>[d.id,`${d.name||r("furn_meter")} \xB7 ${c.name}`])),s=!!hn(o,e),l=e.meter_floors??[],a=(c,d)=>n.update({meter_floors:d?[...l.filter(u=>u!==c),c]:l.filter(u=>u!==c)});return st(O(t,r("meter_parent"),s?e.parent_meter:"",[["",r("meter_parent_none")],...i],c=>n.update({parent_meter:c||null}),{wide:!0}),s?H(t,r("energy_invert"),!!e.meter_invert,c=>n.update({meter_invert:c})):_,s?m`<div class="nf-sub nf-wide">${r("meter_floors")}</div>${o.floors.map(c=>H(t,c.name,l.includes(c.id),d=>a(c.id,d)))}`:_,M(r("meter_sub_hint"),"nf-wide"))}function _m(t,e,n,r){let o=t.t,i=n==="mail"?s=>/^(binary_sensor|sensor|input_boolean)\./.test(s):s=>/^(sensor|binary_sensor|calendar)\./.test(s);return m`<div class="nf-form nf-links">
${P(t,o(`care_entity_${n}`),e.care_entity??null,void 0,L(t.hass,i),s=>r.update({care_entity:kt(s)}))}
${n==="plant"?E(t,o("care_thirsty_below"),e.thirsty_below??20,s=>r.update({thirsty_below:Math.min(90,Math.max(1,Math.round(s)))}),1,1):_}
${M(o(`care_hint_${n}`),"nf-wide")}
</div>`}function bm(t,e,n){let r=t.t;return m`<div class="nf-form nf-links">
${P(t,r("furn_cover_entity"),e.cover_entity??null,void 0,L(t.hass,o=>o.startsWith("cover.")),o=>n.update({cover_entity:vt(o)}))}
${P(t,r("furn_cover_entity"),e.cover_entity??null,void 0,L(t.hass,o=>o.startsWith("cover.")),o=>n.update({cover_entity:kt(o)}))}
${H(t,r("furn_cover_inverted"),!!e.cover_inverted,o=>n.update({cover_inverted:o||void 0}),{title:r("furn_cover_inverted_hint")})}
${M(r("furn_cover_hint"),"nf-wide")}
</div>`}function ym(t,e,n,r){let o=t.t,i=/socket/.test(e.type),s=L(t.hass,c=>/^(light|switch|input_boolean|fan)\./.test(c)),l=e.gang_entities??[],a=c=>d=>{let u=Array.from({length:n},(p,h)=>l[h]??null);u[c]=vt(d),r.update({gang_entities:u})};return m`<div class="nf-form nf-links">
</div>`}function ym(t,e,n,r){let o=t.t,i=/socket/.test(e.type),s=L(t.hass,c=>/^(light|switch|input_boolean|fan)\./.test(c)),l=e.gang_entities??[],a=c=>d=>{let u=Array.from({length:n},(p,h)=>l[h]??null);u[c]=kt(d),r.update({gang_entities:u})};return m`<div class="nf-form nf-links">
${Array.from({length:n},(c,d)=>P(t,n===1?o(i?"gang_socket_one":"gang_switch_one"):o(i?"gang_socket":"gang_switch",{n:d+1}),l[d]??null,void 0,s,a(d)))}
${M(o(i?"gang_socket_hint":"gang_switch_hint"),"nf-wide")}
</div>`}function Aw(t,e,n){let r=t.t,o=L(t.hass,i=>{let s=t.hass?.states[i]?.attributes;return i.startsWith("sensor.")&&(s?.device_class==="temperature"||s?.unit_of_measurement==="\xB0C"||s?.unit_of_measurement==="\xB0F")});return st(P(t,r("fridge_temp"),e.temp_entity??null,void 0,o,i=>n.update({temp_entity:vt(i)})),P(t,r("freezer_temp"),e.temp_entity2??null,void 0,o,i=>n.update({temp_entity2:vt(i)})),M(r("fridge_temp_hint"),"nf-wide"))}function Fw(t,e,n){let r=t.t,o=L(t.hass,i=>{let s=t.hass?.states[i]?.attributes;return i.startsWith("sensor.")&&(s?.device_class==="temperature"||s?.unit_of_measurement==="\xB0C"||s?.unit_of_measurement==="\xB0F")});return st(P(t,r("device_temp"),e.temp_entity??null,void 0,o,i=>n.update({temp_entity:vt(i)})),M(r("device_temp_hint"),"nf-wide"))}function Tw(t,e,n){let r=t.t,o=e.extra_lights??[],i=L(t.hass,a=>a.startsWith("light.")&&a!==e.entity&&a!==e.color_entity),s=a=>c=>{let d=[...o];c&&c!=="none"?d[a]=c:d.splice(a,1),n.update({extra_lights:d.filter(Boolean).length?d.filter(Boolean):void 0})},l=Math.min(4,o.length+1);return m`${Array.from({length:l},(a,c)=>P(t,r("lamp_extra_light",{n:c+2}),o[c]??null,void 0,i,s(c)))}${M(r("lamp_extra_hint"),"nf-wide")}`}function wm(t,e,n){let{hass:r}=t;if(!r)return _;let o=t.t,i=ce(e.type),s=kw(e,r),l=L(r,f=>On(r,f)),a=f=>g=>n.update({[f]:vt(g)}),c=f=>L(r,f),d=(t.doc.settings.roof.strings??[]).filter(f=>f.inverter===e.id).map(f=>f.name),u=!!e.entity&&e.entity!=="none",p=e.type==="fridge_smart"?c(f=>f.startsWith("binary_sensor.")):[],h=e.type==="ceiling_fan"?"fan_hint":i?e.type==="lamp_pendant"?"lamp_hint_pendant":"lamp_hint":Rn(e.type)?"furn_links_hint_tv":e.type==="robot_vacuum"?"robot_hint":"furn_links_hint";return m`${st(e.type==="grid_point"?M(o("grid_point_hint"),"nf-wide"):P(t,o(s.label),e.entity??null,Li(t,e,"entity"),c(s.accept),f=>n.update({entity:f})),e.type==="ceiling_fan"?P(t,o("furn_fan_entity"),e.fan_entity??null,Li(t,e,"fan"),c(f=>f.startsWith("fan.")),f=>n.update({fan_entity:f})):_,!i&&!Ce.includes(e.type)&&!wr(e.type)?fl(t,e,n):_,i&&u?m`${P(t,o("furn_color_entity"),e.color_entity??null,void 0,c(f=>f.startsWith("light.")&&f!==e.entity),a("color_entity"))}${M(o("furn_color_entity_hint"),"nf-wide")}`:_,i&&u?Tw(t,e,n):_,i?an(t,e.glow_scale,f=>n.update({glow_scale:f})):_,i?Di(t,e,am(r,e,e.entity&&e.entity!=="none"?e.entity:Li(t,e,"entity"))?.attributes.effect_list,n.update):_,wr(e.type)?an(t,e.ambilight,f=>n.update({ambilight:f}),{label:"ambilight",hint:"ambilight_hint",lowest:0}):_,Rn(e.type)||Zo(e.type)?an(t,e.sound_rings,f=>n.update({sound_rings:f}),{label:"sound_rings",hint:"sound_rings_hint",lowest:0}):_,e.type==="grid_point"?_:P(t,o(un(t.doc,e)?"meter_sub_power":xw(e.type)),e.power??null,Li(t,e,"power"),l,f=>n.update({power:f})))}
</div>`}function Aw(t,e,n){let r=t.t,o=L(t.hass,i=>{let s=t.hass?.states[i]?.attributes;return i.startsWith("sensor.")&&(s?.device_class==="temperature"||s?.unit_of_measurement==="\xB0C"||s?.unit_of_measurement==="\xB0F")});return st(P(t,r("fridge_temp"),e.temp_entity??null,void 0,o,i=>n.update({temp_entity:kt(i)})),P(t,r("freezer_temp"),e.temp_entity2??null,void 0,o,i=>n.update({temp_entity2:kt(i)})),M(r("fridge_temp_hint"),"nf-wide"))}function Fw(t,e,n){let r=t.t,o=L(t.hass,i=>{let s=t.hass?.states[i]?.attributes;return i.startsWith("sensor.")&&(s?.device_class==="temperature"||s?.unit_of_measurement==="\xB0C"||s?.unit_of_measurement==="\xB0F")});return st(P(t,r("device_temp"),e.temp_entity??null,void 0,o,i=>n.update({temp_entity:kt(i)})),M(r("device_temp_hint"),"nf-wide"))}function Tw(t,e,n){let r=t.t,o=e.extra_lights??[],i=L(t.hass,a=>a.startsWith("light.")&&a!==e.entity&&a!==e.color_entity),s=a=>c=>{let d=[...o];c&&c!=="none"?d[a]=c:d.splice(a,1),n.update({extra_lights:d.filter(Boolean).length?d.filter(Boolean):void 0})},l=Math.min(4,o.length+1);return m`${Array.from({length:l},(a,c)=>P(t,r("lamp_extra_light",{n:c+2}),o[c]??null,void 0,i,s(c)))}${M(r("lamp_extra_hint"),"nf-wide")}`}function wm(t,e,n){let{hass:r}=t;if(!r)return _;let o=t.t,i=ce(e.type),s=kw(e,r),l=L(r,f=>Hn(r,f)),a=f=>g=>n.update({[f]:kt(g)}),c=f=>L(r,f),d=(t.doc.settings.roof.strings??[]).filter(f=>f.inverter===e.id).map(f=>f.name),u=!!e.entity&&e.entity!=="none",p=e.type==="fridge_smart"?c(f=>f.startsWith("binary_sensor.")):[],h=e.type==="ceiling_fan"?"fan_hint":i?e.type==="lamp_pendant"?"lamp_hint_pendant":"lamp_hint":En(e.type)?"furn_links_hint_tv":e.type==="robot_vacuum"?"robot_hint":"furn_links_hint";return m`${st(e.type==="grid_point"?M(o("grid_point_hint"),"nf-wide"):P(t,o(s.label),e.entity??null,Li(t,e,"entity"),c(s.accept),f=>n.update({entity:f})),e.type==="ceiling_fan"?P(t,o("furn_fan_entity"),e.fan_entity??null,Li(t,e,"fan"),c(f=>f.startsWith("fan.")),f=>n.update({fan_entity:f})):_,!i&&!Ce.includes(e.type)&&!wr(e.type)?fl(t,e,n):_,i&&u?m`${P(t,o("furn_color_entity"),e.color_entity??null,void 0,c(f=>f.startsWith("light.")&&f!==e.entity),a("color_entity"))}${M(o("furn_color_entity_hint"),"nf-wide")}`:_,i&&u?Tw(t,e,n):_,i?ln(t,e.glow_scale,f=>n.update({glow_scale:f})):_,i?Di(t,e,am(r,e,e.entity&&e.entity!=="none"?e.entity:Li(t,e,"entity"))?.attributes.effect_list,n.update):_,wr(e.type)?ln(t,e.ambilight,f=>n.update({ambilight:f}),{label:"ambilight",hint:"ambilight_hint",lowest:0}):_,En(e.type)||Zo(e.type)?ln(t,e.sound_rings,f=>n.update({sound_rings:f}),{label:"sound_rings",hint:"sound_rings_hint",lowest:0}):_,e.type==="grid_point"?_:P(t,o(hn(t.doc,e)?"meter_sub_power":xw(e.type)),e.power??null,Li(t,e,"power"),l,f=>n.update({power:f})))}
${wd(e.type)?Aw(t,e,n):i||e.type==="grid_point"?_:Fw(t,e,n)}
${e.type==="meter"?Ew(t,e,n):_}
${e.type==="inverter"||e.type==="home_battery"?Rw(t,e,n):_}
${e.type==="meter"&&!un(t.doc,e)?st(P(t,o("furn_export"),e.export??null,void 0,l,a("export")),M(o("furn_export_hint"),"nf-wide")):_}
${e.type==="meter"&&!hn(t.doc,e)?st(P(t,o("furn_export"),e.export??null,void 0,l,a("export")),M(o("furn_export_hint"),"nf-wide")):_}
${e.type==="inverter"&&(t.doc.settings.roof.solar??[]).length>0?M(d.length>0?o("inverter_strings",{names:d.join(", ")}):o("inverter_strings_none"),"nf-wide"):_}
${e.type==="home_battery"?st(P(t,o("furn_soc"),e.soc??null,void 0,c(f=>me(f)&&(r.states[f]?.attributes.device_class==="battery"||r.states[f]?.attributes.unit_of_measurement==="%")),a("soc")),P(t,o("furn_charge"),e.charge??null,void 0,l,a("charge")),M(o("furn_charge_hint"),"nf-wide")):_}
${e.type==="wallbox"?st(P(t,o("furn_wallbox_status"),e.status??null,void 0,c(f=>ii(f)||me(f)),a("status"))):_}
${!i||e.entity?m`${H(t,o("device_confirm"),!!e.confirm,f=>n.update({confirm:f}),{title:o("device_confirm_hint")})}
<div class="nf-form">${Nn(t,e.marker??null,f=>n.update({marker:f}))}${Ht(t,e.icon,f=>n.update({icon:f}))}${i?_:Bn(t,e.pin_offset,f=>n.update({pin_offset:f}))}</div>`:_}
<div class="nf-form">${Bn(t,e.marker??null,f=>n.update({marker:f}))}${Lt(t,e.icon,f=>n.update({icon:f}))}${i?_:Wn(t,e.pin_offset,f=>n.update({pin_offset:f}))}</div>`:_}
${e.type==="robot_vacuum"?st(P(t,o("furn_robot_room"),e.room_sensor??null,$d(r,Be(r,t.doc.floors).get(e.id)?.entity??null,null),c(me),f=>n.update({room_sensor:f}))):_}
${e.type==="robot_vacuum"&&u?Mw(t,e):_}
${e.type==="fridge_smart"?m`${st(P(t,o("furn_door_left"),e.door_left??null,void 0,p,f=>n.update({door_left:f})),P(t,o("furn_door_right"),e.door_right??null,void 0,p,f=>n.update({door_right:f})))}
@@ -1431,7 +1432,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${M(o("parking_hint"))}
${t.hass?m`${P(t,o("live_car_device"),a.device??null,null,L(t.hass,f=>Iw.test(f)),f=>r.update({car:{...a,device:f}}))}
${M(o("live_car_device_hint"),"nf-wide")}
${P(t,o("live_car_departure_entity"),a.departure??null,void 0,L(t.hass,f=>/^(sensor|input_datetime|time|datetime)\./.test(f)),f=>r.update({car:{...a,departure:f==="none"?null:f}}))}`:_}`}function $m(t,e){let r=hn(t,e.w,e.d,e.h).treads.findIndex(o=>o.landing);return r>=0?r+1:1}function Hw(t){let e=hn(so(t),t.w,t.d,t.h),n=e.treads.map(ki),r=0;for(let i=1;i<n.length;i++)r+=Math.hypot(n[i][0]-n[i-1][0],n[i][1]-n[i-1][1]);let o=n.length>1?r/(n.length-1):0;return{rise:e.rise,going:o,measure:2*e.rise+o,steps:e.steps}}function Lw(t){let[e,n]=Ta[t],r=hn({...pt,shape:t},e,n,2.8),o=26/Math.max(e,n);return m`<svg viewBox="-14 -14 28 28" width="28" height="28" aria-hidden="true">
${P(t,o("live_car_departure_entity"),a.departure??null,void 0,L(t.hass,f=>/^(sensor|input_datetime|time|datetime)\./.test(f)),f=>r.update({car:{...a,departure:f==="none"?null:f}}))}`:_}`}function $m(t,e){let r=pn(t,e.w,e.d,e.h).treads.findIndex(o=>o.landing);return r>=0?r+1:1}function Hw(t){let e=pn(so(t),t.w,t.d,t.h),n=e.treads.map(ki),r=0;for(let i=1;i<n.length;i++)r+=Math.hypot(n[i][0]-n[i-1][0],n[i][1]-n[i-1][1]);let o=n.length>1?r/(n.length-1):0;return{rise:e.rise,going:o,measure:2*e.rise+o,steps:e.steps}}function Lw(t){let[e,n]=Ta[t],r=pn({...ft,shape:t},e,n,2.8),o=26/Math.max(e,n);return m`<svg viewBox="-14 -14 28 28" width="28" height="28" aria-hidden="true">
${r.treads.map(i=>R`<polygon points=${i.poly.map(([s,l])=>`${s*o},${l*o}`).join(" ")} fill=${i.landing?"currentColor":"none"} fill-opacity="0.25" stroke="currentColor" stroke-width="0.8" />`)}
</svg>`}function Sm(t,e,n){let r=t.t,o=so(e),i=f=>n.update({stair:{...o,...f}}),s=o.shape!=="straight",l=f=>{let[g,y]=Ta[f];n.update({stair:{...o,shape:f,run_width:null},w:g,d:y})},a=t.floor?t.doc.floors.filter(f=>f.elevation<t.floor.elevation).sort((f,g)=>g.elevation-f.elevation)[0]:void 0,c=t.floor?t.doc.floors.filter(f=>f.elevation>t.floor.elevation).sort((f,g)=>f.elevation-g.elevation)[0]:void 0,d=f=>{let g=f?a&&t.floor?t.floor.elevation-a.elevation:null:c&&t.floor?c.elevation-t.floor.elevation:null;n.update({stair:{...o,down:f},...g?{h:Math.round(g*1e3)/1e3}:{}})},u=Hw(e),p=f=>j(t.hass,f*100,1),h=u.measure>=.59&&u.measure<=.65&&u.rise<=.21;return m`<div class="nf-form">
<div class="nf-field nf-wide">
@@ -1447,7 +1448,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${o.build!=="solid"?H(t,r("stair_risers"),o.risers,f=>i({risers:f}),{wide:!1}):""}
${E(t,r("stair_steps"),o.steps??u.steps,f=>i({steps:Math.round(Math.min(40,Math.max(2,f)))}),1,2)}
${o.steps!=null?m`<button class="nf-btn nf-field-btn" ?disabled=${!t.admin} @click=${()=>i({steps:null})}>${r("height_auto")}</button>`:""}
${s&&o.shape!=="spiral"?m`${E(t,r("stair_run_width"),o.run_width??hn(o,e.w,e.d,e.h).flight,f=>i({run_width:Math.max(.4,f)}),.01,.4)}
${s&&o.shape!=="spiral"?m`${E(t,r("stair_run_width"),o.run_width??pn(o,e.w,e.d,e.h).flight,f=>i({run_width:Math.max(.4,f)}),.01,.4)}
${o.run_width!=null?m`<button class="nf-btn nf-field-btn" ?disabled=${!t.admin} @click=${()=>i({run_width:null})}>${r("height_auto")}</button>`:""}`:""}
${o.shape==="l"||o.shape==="u"?m`${E(t,r("stair_landing_after"),o.landing_after??$m(o,e),f=>i({landing_after:Math.round(Math.min(u.steps-1,Math.max(1,f)))}),1,1)}
${o.landing_after!=null?m`<button class="nf-btn nf-field-btn" ?disabled=${!t.admin} @click=${()=>i({landing_after:null})}>${r("height_auto")}</button>`:""}
@@ -1491,10 +1492,10 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${H(t,r("strip_upright"),!!e.upright,s=>o({upright:s}),{wide:!1,title:r("strip_upright_hint")})}`:_}
${Ho(e)&&i?m`${E(t,r("mount_height"),e.mount_y??At(i,e),s=>o({mount_y:Math.max(0,s)}),.01,0)}
${e.mount_y!=null?m`<button class="nf-btn nf-field-btn" ?disabled=${!t.admin} @click=${()=>o({mount_y:null})}>${r("height_auto")}</button>`:_}`:_}
${jw(e)&&i?m`${E(t,r("ceiling_here"),Fo(i,e),s=>o({ceiling_y:Math.abs(s-lt(i,e.x,e.z))<.005?null:Math.max(.5,s)}),.01,.5)}
${jw(e)&&i?m`${E(t,r("ceiling_here"),Fo(i,e),s=>o({ceiling_y:Math.abs(s-ct(i,e.x,e.z))<.005?null:Math.max(.5,s)}),.01,.5)}
${e.ceiling_y!=null?m`<button class="nf-btn nf-field-btn" ?disabled=${!t.admin} @click=${()=>o({ceiling_y:null})}>${r("height_auto")}</button>`:_}
${Mm(t,e)!==null?m`<button class="nf-btn nf-field-btn" ?disabled=${!t.admin} title=${r("ceiling_slope_hint")} @click=${()=>o({ceiling_y:Mm(t,e)})}>📐 ${r("ceiling_slope")}</button>`:_}
${M(r("ceiling_here_hint"),"nf-wide")}`:_}`}function Mm(t,e){let n=t.floor;if(!n)return null;let r=Ar(t.doc,e.x,e.z);if(r===null)return null;let o=Math.round((r-n.elevation)*1e3)/1e3;return o>.5&&o<lt(n,e.x,e.z)-.02?o:null}var jw=t=>ps.has(t.type)||G(t.type)?.mount==="ceiling";function Uw(t,e,n){if(e.type==="stairs"&&e.stair)return _;if(e.type==="stairs")return m`${M(t.t("stairs_hint"))}${t.admin?m`<div class="nf-actions"><button class="nf-btn nf-primary" title=${t.t("stair_upgrade_hint")} @click=${()=>n.update({stair:{...pt}})}>${t.t("stair_upgrade")}</button></div>`:_}`;if(e.type!=="stairwell")return _;let r=t.floor&&!t.floor.rooms.some(o=>o.points.length>=3&&qh(bs(e),o.points));return m`${M(t.t("stairwell_hint"))}${r?m`<p class="nf-sub nf-pack-error">${t.t("stairwell_outside")}</p>`:_}`}function Zw(t,e,n){if(!t.admin)return _;let r=t.t,o=!!e.entity&&e.entity!=="none"&&e.type!=="parking",i=t.doc.floors.filter(s=>s.id!==t.floor?.id);return m`<div class="nf-actions">
${M(r("ceiling_here_hint"),"nf-wide")}`:_}`}function Mm(t,e){let n=t.floor;if(!n)return null;let r=Ar(t.doc,e.x,e.z);if(r===null)return null;let o=Math.round((r-n.elevation)*1e3)/1e3;return o>.5&&o<ct(n,e.x,e.z)-.02?o:null}var jw=t=>ps.has(t.type)||G(t.type)?.mount==="ceiling";function Uw(t,e,n){if(e.type==="stairs"&&e.stair)return _;if(e.type==="stairs")return m`${M(t.t("stairs_hint"))}${t.admin?m`<div class="nf-actions"><button class="nf-btn nf-primary" title=${t.t("stair_upgrade_hint")} @click=${()=>n.update({stair:{...ft}})}>${t.t("stair_upgrade")}</button></div>`:_}`;if(e.type!=="stairwell")return _;let r=t.floor&&!t.floor.rooms.some(o=>o.points.length>=3&&qh(bs(e),o.points));return m`${M(t.t("stairwell_hint"))}${r?m`<p class="nf-sub nf-pack-error">${t.t("stairwell_outside")}</p>`:_}`}function Zw(t,e,n){if(!t.admin)return _;let r=t.t,o=!!e.entity&&e.entity!=="none"&&e.type!=="parking",i=t.doc.floors.filter(s=>s.id!==t.floor?.id);return m`<div class="nf-actions">
<button class="nf-btn" @click=${()=>n.rotate(-90)}>${r("rotate_left")}</button>
<button class="nf-btn" @click=${()=>n.rotate(90)}>${r("rotate_right")}</button>
${o?m`<button class="nf-btn" title=${r("as_device_hint")} @click=${()=>n.toDevice(e)}>${r("as_device")}</button>`:_}
@@ -1505,8 +1506,8 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${O(t,t.t("furn_tap"),r?.action??"",o,s=>s?i({action:s}):n.update({tap:null}),{wide:!0,title:t.t("furn_tap_hint")})}
${r&&r.action!=="fire_dom_event"?Z(t,t.t(`own_target_${r.action}`),r.target??"",s=>i({target:s||null}),{wide:!0,placeholder:pa[r.action]}):_}
${r&&(r.action==="service"||r.action==="fire_dom_event")?fa(t,r,s=>i({data:s})):_}
${r&&!Et(e.type)&&!G(e.type)?.gangs?m`${Nn(t,e.marker??null,s=>n.update({marker:s}))}${Ht(t,e.icon,s=>n.update({icon:s}))}${Bn(t,e.pin_offset,s=>n.update({pin_offset:s}))}`:_}
</div>`}function Yw(t,e,n){let r=t.t,o=e.picture??"",i=o.startsWith("image:"),s=async a=>{let c=a.target,d=c.files?.[0];if(c.value="",!d||!t.hass)return;let{data:u}=await Gn(d),p=D("img");await St(t.hass,p,u),n.update({picture:`image:${p}`})},l=L(t.hass,a=>/^(image|camera|media_player)\./.test(a));return m`<div class="nf-form nf-links">
${r&&!Et(e.type)&&!G(e.type)?.gangs?m`${Bn(t,e.marker??null,s=>n.update({marker:s}))}${Lt(t,e.icon,s=>n.update({icon:s}))}${Wn(t,e.pin_offset,s=>n.update({pin_offset:s}))}`:_}
</div>`}function Yw(t,e,n){let r=t.t,o=e.picture??"",i=o.startsWith("image:"),s=async a=>{let c=a.target,d=c.files?.[0];if(c.value="",!d||!t.hass)return;let{data:u}=await jn(d),p=D("img");await St(t.hass,p,u),n.update({picture:`image:${p}`})},l=L(t.hass,a=>/^(image|camera|media_player)\./.test(a));return m`<div class="nf-form nf-links">
${t.admin?m`<label class="nf-btn nf-wide nf-upload">📷 ${r(i?"picture_replace":"picture_upload")}<input type="file" accept="image/*" hidden @change=${s} /></label>`:_}
${i?m`<p class="nf-sub nf-wide">${r("picture_stored")} <button class="nf-btn nf-field-btn" ?disabled=${!t.admin} @click=${()=>n.update({picture:null})}>${r("delete")}</button></p>`:m`${Z(t,r("picture_url"),/^[a-z_]+\.[a-z0-9_]+$/.test(o)?"":o,a=>n.update({picture:a||null}),{wide:!0,placeholder:"/local/holiday.jpg"})}
${P(t,r("picture_entity"),/^[a-z_]+\.[a-z0-9_]+$/.test(o)?o:null,void 0,l,a=>n.update({picture:a&&a!=="none"?a:null}))}`}
@@ -1528,7 +1529,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${ds(e.type)?_m(t,e,ds(e.type),n):_} ${cs(G(e.type))?bm(t,e,n):_} ${e.type==="parking"?xm(t,e,n.packs,n):_}
${e.type.startsWith("pack:nextfloor.fahrzeuge:")&&t.admin?m`<section>${M(t.t("vehicle_to_spot_hint"))}<div class="nf-actions"><button class="nf-btn nf-primary" @click=${()=>n.toSpot(e)}>🅿 ${t.t("vehicle_to_spot")}</button></div></section>`:_}
${t.admin?qw(t,e,n):_} ${Qw(t,e,n)} ${Zw(t,e,n)}
</section>`}var Jw=["door","window","opening","garage_door"],ev=/griff|handle|fenster|window|drehgriff/i;function tv(t){let e=[null,15,30,45,60,90,120,180];return t&&!e.includes(t)&&e.push(t),e.sort((n,r)=>(n??0)-(r??0))}function nv(t){let{hass:e}=t,n=i=>e?.states[i],r=i=>n(i)?.attributes.device_class,o=i=>i.startsWith("binary_sensor.")&&Jw.includes(r(i)??"");return{covers:L(e,i=>i.startsWith("cover.")),positions:L(e,i=>/^(sensor|number|input_number)\./.test(i)&&Number.isFinite(Number(n(i)?.state))),contacts:L(e,i=>o(i)||me(i)&&Es(n(i))!==null),plainContacts:L(e,o),handles:L(e,i=>i.startsWith("binary_sensor.")?typeof n(i)?.attributes.window_state=="string":me(i)&&(Es(n(i))!==null||ev.test(`${i} ${W(e,i)}`))),numbers:L(e,me),locks:L(e,i=>i.startsWith("lock."))}}function gl(t,e,n){if(!t.hass)return null;let r=structuredClone(t.doc.floors);for(let o of r)for(let i of o.openings)i.id===e.id&&(i[n]=null);return br(t.hass,r).get(e.id)?.[n]??null}var kt=t=>t==="none"?null:t;function rv(t,e,n){let r=e.type==="door"?ms:gs,o=qt({type:e.type,style:null},n.isExterior(e)),i=e.style&&r.includes(e.style)?e.style:"",s=[["",t.t("style_auto",{style:t.t(`style_${o}`)})],...r.map(l=>[l,t.t(`style_${l}`)])];return O(t,t.t("opening_style"),i,s,l=>n.update({style:l||null}),{wide:!0})}function ml(t,e,n,r,o){return m`<label class="nf-field"
</section>`}var Jw=["door","window","opening","garage_door"],ev=/griff|handle|fenster|window|drehgriff/i;function tv(t){let e=[null,15,30,45,60,90,120,180];return t&&!e.includes(t)&&e.push(t),e.sort((n,r)=>(n??0)-(r??0))}function nv(t){let{hass:e}=t,n=i=>e?.states[i],r=i=>n(i)?.attributes.device_class,o=i=>i.startsWith("binary_sensor.")&&Jw.includes(r(i)??"");return{covers:L(e,i=>i.startsWith("cover.")),positions:L(e,i=>/^(sensor|number|input_number)\./.test(i)&&Number.isFinite(Number(n(i)?.state))),contacts:L(e,i=>o(i)||me(i)&&Es(n(i))!==null),plainContacts:L(e,o),handles:L(e,i=>i.startsWith("binary_sensor.")?typeof n(i)?.attributes.window_state=="string":me(i)&&(Es(n(i))!==null||ev.test(`${i} ${W(e,i)}`))),numbers:L(e,me),locks:L(e,i=>i.startsWith("lock."))}}function gl(t,e,n){if(!t.hass)return null;let r=structuredClone(t.doc.floors);for(let o of r)for(let i of o.openings)i.id===e.id&&(i[n]=null);return Rn(t.hass,r).get(e.id)?.[n]??null}var at=t=>t==="none"?null:t;function rv(t,e,n){let r=e.type==="door"?ms:gs,o=Yt({type:e.type,style:null},n.isExterior(e)),i=e.style&&r.includes(e.style)?e.style:"",s=[["",t.t("style_auto",{style:t.t(`style_${o}`)})],...r.map(l=>[l,t.t(`style_${l}`)])];return O(t,t.t("opening_style"),i,s,l=>n.update({style:l||null}),{wide:!0})}function ml(t,e,n,r,o){return m`<label class="nf-field"
>${t.t(r)}
<input
type="number"
@@ -1540,8 +1541,8 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
?disabled=${!t.admin}
@change=${i=>{let s=Number(i.target.value);o.update({[n]:Number.isFinite(s)&&s>0?Math.min(3,Math.max(.1,Math.round(s*100)/100)):null})}}
/>
</label>`}function ov(t,e,n){if(e.type!=="door")return _;let r=qt(e,n.isExterior(e));return r==="sidelight"?m`${H(t,t.t("sidelight_hinge"),!!e.sidelight_hinge,o=>n.update({sidelight_hinge:o}),{wide:!1,title:t.t("sidelight_hinge_hint")})}
${ml(t,e,"sidelight_width","sidelight_width",n)}`:r==="sidelights"?m`${ml(t,e,"sidelight_width","sidelight_width_left",n)} ${ml(t,e,"sidelight_width2","sidelight_width_right",n)}`:_}function iv(t,e,n){return e.type!=="window"||qt(e,n.isExterior(e))!=="glass_wall"?_:m`<label class="nf-field"
</label>`}function ov(t,e,n){if(e.type!=="door")return _;let r=Yt(e,n.isExterior(e));return r==="sidelight"?m`${H(t,t.t("sidelight_hinge"),!!e.sidelight_hinge,o=>n.update({sidelight_hinge:o}),{wide:!1,title:t.t("sidelight_hinge_hint")})}
${ml(t,e,"sidelight_width","sidelight_width",n)}`:r==="sidelights"?m`${ml(t,e,"sidelight_width","sidelight_width_left",n)} ${ml(t,e,"sidelight_width2","sidelight_width_right",n)}`:_}function iv(t,e,n){return e.type!=="window"||Yt(e,n.isExterior(e))!=="glass_wall"?_:m`<label class="nf-field"
>${t.t("glass_panes")}
<input
type="number"
@@ -1554,25 +1555,27 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
@change=${r=>{let o=r.target.value.trim(),i=Number(o);n.update({panes:o===""||!Number.isFinite(i)?null:Math.min(40,Math.max(0,Math.round(i)))})}}
/>
</label>
${M(t.t("glass_panes_hint"),"nf-wide")}`}function Rm(t,e,n,r,o){let i=n===1,s=t.t,l=i?e.tilt:e.tilt2??null,a=i?e.contact:e.contact2,c=(i?e.sensor:e.sensor2)??(l&&l!=="none"?"contact_tilt":"contact"),d=["contact","handle","contact_tilt"].map(f=>[f,s(`sensor_kind_${f}`)]),u=f=>{let g=f==="contact_tilt"?{}:i?{tilt:null}:{tilt2:null};r.update({...i?{sensor:f}:{sensor2:f},...g})},p=f=>r.update(i?{contact:f}:{contact2:kt(f)}),h=e.tilt_angle&&e.tilt_angle!=="none";return m`${O(t,s("sensor_kind"),c,d,u,{wide:!0})}
${M(t.t("glass_panes_hint"),"nf-wide")}`}function Rm(t,e,n,r,o){let i=n===1,s=t.t,l=i?e.tilt:e.tilt2??null,a=i?e.contact:e.contact2,c=(i?e.sensor:e.sensor2)??(l&&l!=="none"?"contact_tilt":"contact"),d=["contact","handle","contact_tilt"].map(f=>[f,s(`sensor_kind_${f}`)]),u=f=>{let g=f==="contact_tilt"?{}:i?{tilt:null}:{tilt2:null};r.update({...i?{sensor:f}:{sensor2:f},...g})},p=f=>r.update(i?{contact:f}:{contact2:at(f)}),h=e.tilt_angle&&e.tilt_angle!=="none";return m`${O(t,s("sensor_kind"),c,d,u,{wide:!0})}
${c==="handle"?P(t,s("handle_entity"),a,void 0,o.handles,f=>p(f==="none"?i?"none":null:f)):P(t,s("contact_entity"),a,i?gl(t,e,"contact"):void 0,o.plainContacts,p)}
${c==="contact_tilt"?P(t,s("tilt_entity"),l,void 0,o.contacts,f=>r.update(i?{tilt:kt(f)}:{tilt2:kt(f)})):_}
${i?m`${P(t,s("tilt_angle_entity"),e.tilt_angle??null,void 0,o.numbers,f=>r.update({tilt_angle:kt(f)}))}
${c==="contact_tilt"?P(t,s("tilt_entity"),l,void 0,o.contacts,f=>r.update(i?{tilt:at(f)}:{tilt2:at(f)})):_}
${i?m`${P(t,s("tilt_angle_entity"),e.tilt_angle??null,void 0,o.numbers,f=>r.update({tilt_angle:at(f)}))}
${h?m`${E(t,s("tilt_angle_max"),e.tilt_max??15,f=>r.update({tilt_max:Math.min(90,Math.max(1,f))}),1,1)}
${E(t,s("tilt_angle_offset"),e.tilt_offset??0,f=>r.update({tilt_offset:f}),.5)}
${H(t,s("tilt_angle_invert"),!!e.tilt_invert,f=>r.update({tilt_invert:f}))}`:_}`:_}`}function sv(t,e,n,r){let o=t.t,i=e.type==="window",s=gl(t,e,"cover"),l=e.cover!=="none"&&(e.cover||s);return m`${P(t,o(i?"cover_entity":"door_cover"),e.cover,s,r.covers,a=>n.update({cover:a}))}
${l?m`${P(t,o("cover_position_entity"),e.position??null,void 0,r.positions,a=>n.update({position:kt(a)}))}
${e.position?H(t,o("cover_position_invert"),!!e.position_inverted,a=>n.update({position_inverted:a})):_}
${H(t,o("device_confirm"),!!e.confirm,a=>n.update({confirm:a}),{title:o("cover_confirm_hint")})}
${i?m`${O(t,o("blind_kind"),e.blind??"roller",[["roller",o("blind_roller")],["venetian",o("blind_venetian")],["inside",o("blind_inside")]],a=>n.update({blind:a==="roller"?null:a}))}
${P(t,o("cover2_entity"),e.cover2??null,void 0,r.covers,a=>n.update({cover2:kt(a)}))}`:_}
${!i&&e.type!=="garage"?P(t,o("cover2_entity"),e.cover2??null,void 0,r.covers,a=>n.update({cover2:kt(a)})):_}
${E(t,o("cover_my"),e.my_position??0,a=>n.update({my_position:a>0?Math.min(100,Math.round(a)):null}),5,0)}
${H(t,s("tilt_angle_invert"),!!e.tilt_invert,f=>r.update({tilt_invert:f}))}`:_}`:_}`}function sv(t,e,n,r){let o=t.t,i=e.type==="window",s=gl(t,e,"cover"),l=e.cover!=="none"&&(e.cover||s),a=t.hass?.symconObjects!==void 0;return m`${P(t,o(a?"symcon_cover_position":i?"cover_entity":"door_cover"),e.cover,s,r.covers,c=>n.update({cover:c}))}
${a||l&&e.blind==="venetian"?P(t,o("cover_tilt_entity"),e.cover_tilt??null,void 0,r.covers,c=>n.update({cover_tilt:at(c)})):_}
${l?m`${P(t,o("cover_position_entity"),e.position??null,void 0,r.positions,c=>n.update({position:at(c)}))}
${e.position?H(t,o("cover_position_invert"),!!e.position_inverted,c=>n.update({position_inverted:c})):_}
${H(t,o("device_confirm"),!!e.confirm,c=>n.update({confirm:c}),{title:o("cover_confirm_hint")})}
${i?m`${O(t,o("blind_kind"),e.blind??"roller",[["roller",o("blind_roller")],["venetian",o("blind_venetian")],["inside",o("blind_inside")]],c=>n.update({blind:c==="roller"?null:c}))}
${P(t,o("cover2_entity"),e.cover2??null,void 0,r.covers,c=>n.update({cover2:at(c)}))}`:_}
${!i&&e.type!=="garage"?P(t,o("cover2_entity"),e.cover2??null,void 0,r.covers,c=>n.update({cover2:at(c)})):_}
${e.cover2&&e.cover2!=="none"?P(t,o("cover2_tilt_entity"),e.cover2_tilt??null,void 0,r.covers,c=>n.update({cover2_tilt:at(c)})):_}
${E(t,o("cover_my"),e.my_position??0,c=>n.update({my_position:c>0?Math.min(100,Math.round(c)):null}),5,0)}
${M(o("blind_hint"),"nf-wide")}`:_}`}function av(t,e,n,r){let o=t.t,i=e.leaves===2;return m`${P(t,o(i?"contact_main":"contact_entity"),e.contact,gl(t,e,"contact"),r.contacts,s=>n.update({contact:s}))}
${i&&e.type!=="garage"?P(t,o("contact_second"),e.contact2,void 0,r.contacts,s=>n.update({contact2:kt(s)})):_}
${i&&e.type!=="garage"?P(t,o("contact_second"),e.contact2,void 0,r.contacts,s=>n.update({contact2:at(s)})):_}
${e.type==="door"?H(t,o("door_shut"),!!e.shut,s=>n.update({shut:s}),{title:o("door_shut_hint")}):_}
${e.type==="door"&&e.style!=="sliding"&&e.style!=="passage"?O(t,o("door_angle"),String(e.open_angle??""),tv(e.open_angle).map(s=>[String(s??""),s?`${s}\xB0`:o("door_angle_default")]),s=>n.update({open_angle:s?Number(s):null}),{title:o("door_angle_hint")}):_}
${e.type==="door"?m`${P(t,o("opening_lock"),e.lock??null,void 0,r.locks,s=>n.update({lock:kt(s)}))}${M(o("opening_lock_hint"),"nf-wide")}`:_}`}function _l(t,e,n){let r=t.t,o=nv(t),i=kn(e),[s,l,a]=[e.type==="window",e.type==="garage",e.type==="door"],c=h=>n.update(h),d=Object.keys(vn).map(h=>m`<button class="nf-chip" aria-pressed=${h===i} @click=${()=>n.setPreset(e,h)}>${r(`preset_${h}`)}</button>`),u=[["left",r("hinge_left")],["right",r("hinge_right")]],p=[["",r("opening_mark_open")],["closed",r("opening_mark_closed")]];return m`<section>
${e.type==="door"?m`${P(t,o("opening_lock"),e.lock??null,void 0,r.locks,s=>n.update({lock:at(s)}))}${M(o("opening_lock_hint"),"nf-wide")}`:_}`}function _l(t,e,n){let r=t.t,o=nv(t),i=xn(e),[s,l,a]=[e.type==="window",e.type==="garage",e.type==="door"],c=h=>n.update(h),d=Object.keys(kn).map(h=>m`<button class="nf-chip" aria-pressed=${h===i} @click=${()=>n.setPreset(e,h)}>${r(`preset_${h}`)}</button>`),u=[["left",r("hinge_left")],["right",r("hinge_right")]],p=[["",r("opening_mark_open")],["closed",r("opening_mark_closed")]];return m`<section>
<div class="nf-h3row"><h3>${r(`preset_${i}`)}</h3>${n.lockButton}</div>
${t.admin?m`<div class="nf-presets" role="group" aria-label=${r("opening_type")}>${d}</div>`:_}
${t.admin&&!l?m`<div class="nf-actions">
@@ -1597,13 +1600,13 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</div>
${M(r(s?"opening_hint":l?"garage_hint":"door_hint"))}
${t.admin?m`<div class="nf-actions"><button class="nf-btn nf-danger" @click=${()=>n.remove()}>${r("delete")}</button></div>`:_}
</section>`}function qn(t){let e=t.roof.floorsTopDown();return e.length<2?_:m`<div class="nf-seg nf-dev-source">${e.map(n=>m`<button aria-pressed=${n.id===t.floorId} @click=${()=>t.setFloorId(n.id)}>${n.name}</button>`)}</div>`}function Yn(t,e,n){return t.admin?m`<button class="nf-btn nf-fix" aria-pressed=${e} title=${t.t("fix_hint")} @click=${n}>${e?`\u{1F512} ${t.t("unfix")}`:`\u{1F513} ${t.t("fix")}`}</button>`:_}function Xn(t,e,n,r){return m`<div class="nf-seg nf-dev-source">${e.map(([o,i])=>m`<button aria-pressed=${o===n} ?disabled=${!t.admin} @click=${()=>r(o)}>${i}</button>`)}</div>`}function xt(t,e){let{t:n,doc:r,hass:o}=t,i=n(`compass_${Js(e,r.settings.north??0)}`);if(e.key===De)return n("solar_ground");if(e.wall){let a=r.floors.find(c=>c.id===e.wall.floorId);return`${n("solar_wall")} ${a?.name??""} \xB7 ${i} \xB7 ${j(o,e.lu,1)} m`}let s=r.settings.roof.sections??[],l=e.section?n("solar_section",{n:s.findIndex(a=>a.id===e.section)+1}):n("solar_main");return e.flat?`${l} \xB7 ${n("solar_flat")}`:`${l} \xB7 ${i} \xB7 ${Math.round(e.pitch)}\xB0`}var bl=(t,e)=>m`<div class="nf-h3row"><h3>${t}</h3>${e}</div>`,yl=(t,e)=>m`<button class="nf-btn nf-back" @click=${e}>‹ ${t}</button>`,mn=(t,e)=>n=>Math.max(t,Math.min(e,ie(n)));function lv(t,e){let{host:n,roof:r}=t,o=n.t,i=w=>r.patchSection(w),s=e.shape==="flat"||e.shape==="parapet",l=e.shape==="pent",a=e.axis==="x"?[o("roof_side_top"),o("roof_side_bottom")]:[o("roof_side_left"),o("roof_side_right")],[c,d]=e.flip?[a[1],a[0]]:a,u=!!n.doc.settings.lock_plan,p=(w,x,k,$=.05,A=0)=>E(n,w,x,F=>k(Math.max(A,ie(F))),$,A),h=[...n.doc.floors].filter(w=>w.rooms.length>0).sort((w,x)=>x.elevation-w.elevation),f=Ws(n.doc,e)?.id,g=w=>{let x=n.doc.floors.find(A=>A.id===w);if(!x)return;let k=ie(x.elevation+x.height),$=k-e.base;i({base:k,eave_a:ie(e.eave_a+$),eave_b:ie(e.eave_b+$)})},y=u?m`<button class="nf-btn nf-fix" aria-pressed="true" title=${o("lock_plan_hint")} @click=${()=>t.toggleLockPlan()}>🔒 ${o("plan_locked")}</button>`:Yn(n,!!e.locked,()=>i({locked:!e.locked})),b=Pc.map(w=>[w,o(`roof_shape_${w}`)]),v=(w,x)=>m`<button class="nf-btn" title=${o("roof_dormer_hint")} @click=${()=>r.addDormer(w)}>+ ${o("roof_dormer")} ${x}</button>`;return m`${yl(o("roof_sections"),()=>r.sectionId=null)}
</section>`}function Yn(t){let e=t.roof.floorsTopDown();return e.length<2?_:m`<div class="nf-seg nf-dev-source">${e.map(n=>m`<button aria-pressed=${n.id===t.floorId} @click=${()=>t.setFloorId(n.id)}>${n.name}</button>`)}</div>`}function Xn(t,e,n){return t.admin?m`<button class="nf-btn nf-fix" aria-pressed=${e} title=${t.t("fix_hint")} @click=${n}>${e?`\u{1F512} ${t.t("unfix")}`:`\u{1F513} ${t.t("fix")}`}</button>`:_}function Qn(t,e,n,r){return m`<div class="nf-seg nf-dev-source">${e.map(([o,i])=>m`<button aria-pressed=${o===n} ?disabled=${!t.admin} @click=${()=>r(o)}>${i}</button>`)}</div>`}function xt(t,e){let{t:n,doc:r,hass:o}=t,i=n(`compass_${Js(e,r.settings.north??0)}`);if(e.key===De)return n("solar_ground");if(e.wall){let a=r.floors.find(c=>c.id===e.wall.floorId);return`${n("solar_wall")} ${a?.name??""} \xB7 ${i} \xB7 ${j(o,e.lu,1)} m`}let s=r.settings.roof.sections??[],l=e.section?n("solar_section",{n:s.findIndex(a=>a.id===e.section)+1}):n("solar_main");return e.flat?`${l} \xB7 ${n("solar_flat")}`:`${l} \xB7 ${i} \xB7 ${Math.round(e.pitch)}\xB0`}var bl=(t,e)=>m`<div class="nf-h3row"><h3>${t}</h3>${e}</div>`,yl=(t,e)=>m`<button class="nf-btn nf-back" @click=${e}>‹ ${t}</button>`,gn=(t,e)=>n=>Math.max(t,Math.min(e,ie(n)));function lv(t,e){let{host:n,roof:r}=t,o=n.t,i=w=>r.patchSection(w),s=e.shape==="flat"||e.shape==="parapet",l=e.shape==="pent",a=e.axis==="x"?[o("roof_side_top"),o("roof_side_bottom")]:[o("roof_side_left"),o("roof_side_right")],[c,d]=e.flip?[a[1],a[0]]:a,u=!!n.doc.settings.lock_plan,p=(w,x,k,$=.05,A=0)=>E(n,w,x,F=>k(Math.max(A,ie(F))),$,A),h=[...n.doc.floors].filter(w=>w.rooms.length>0).sort((w,x)=>x.elevation-w.elevation),f=Ws(n.doc,e)?.id,g=w=>{let x=n.doc.floors.find(A=>A.id===w);if(!x)return;let k=ie(x.elevation+x.height),$=k-e.base;i({base:k,eave_a:ie(e.eave_a+$),eave_b:ie(e.eave_b+$)})},y=u?m`<button class="nf-btn nf-fix" aria-pressed="true" title=${o("lock_plan_hint")} @click=${()=>t.toggleLockPlan()}>🔒 ${o("plan_locked")}</button>`:Xn(n,!!e.locked,()=>i({locked:!e.locked})),b=Pc.map(w=>[w,o(`roof_shape_${w}`)]),v=(w,x)=>m`<button class="nf-btn" title=${o("roof_dormer_hint")} @click=${()=>r.addDormer(w)}>+ ${o("roof_dormer")} ${x}</button>`;return m`${yl(o("roof_sections"),()=>r.sectionId=null)}
<section>
${qn(t)}
${Yn(t)}
${bl(`${e.dormer?o("roof_dormer"):o("roof_section")} ${Sp(n.doc.settings.roof.sections??[],e.id)}`,n.admin?y:_)}
${O(n,o("roof_shape"),e.shape,b,w=>i({shape:w,...w==="gable"||w==="hip"||w==="halfhip"?{}:{ends:null}}),{wide:!0})}
${e.shape==="gable"||e.shape==="hip"||e.shape==="halfhip"?pv(n,e,i):_}
${s?_:Xn(n,[["x",o("roof_axis_x")],["z",o("roof_axis_z")]],e.axis,w=>i({axis:w}))}
${s?_:Qn(n,[["x",o("roof_axis_x")],["z",o("roof_axis_z")]],e.axis,w=>i({axis:w}))}
${H(n,o("roof_open"),!!e.open,w=>i({open:w}),{title:o("roof_open_hint")})}
<div class="nf-form">
${s?p(o("roof_height"),e.eave_a,w=>i({eave_a:w,eave_b:w})):m`${p(`${o("roof_eave")} ${l?"":c}`,e.eave_a,w=>i({eave_a:w}))}
@@ -1627,15 +1630,15 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${s&&n.admin?m`${Y(m`<button class="nf-btn" title=${o("roof_outline_hint")} @click=${()=>r.takeOutline()}>${o("roof_outline")}</button>`,e.points?m`<button class="nf-btn" @click=${()=>i({points:null})}>${o("roof_rect")}</button>`:_)}
${e.points?Y(...e.points.map((w,x)=>m`<button class="nf-chip" title=${o("delete_point")} ?disabled=${(e.points?.length??0)<=3} @click=${()=>r.removeCorner(x)}>${x+1} ×</button>`)):_}
${M(o(e.points?"roof_points_hint":"roof_outline_hint"))}`:_}
${M(`${o("roof_ridge_height")}: ${he(n.hass,Yt(e))} \xB7 ${o("roof_section_hint")}`)}
${M(`${o("roof_ridge_height")}: ${he(n.hass,Xt(e))} \xB7 ${o("roof_section_hint")}`)}
${n.admin?Y(s?_:m`<button class="nf-btn" title=${o("roof_swap_hint")} @click=${()=>i({flip:!e.flip})}>⇅ ${o("roof_swap")}</button>`,!s&&!e.dormer&&!e.open?m`${v("a",c)}${l?_:v("b",d)}`:_,m`<button class="nf-btn" @click=${()=>r.duplicateSection()}>${o("duplicate")}</button>`,m`<button class="nf-btn nf-danger" @click=${()=>r.removeSection()}>${o("delete")}</button>`):_}
</section>`}function cv(t,e){let{host:n,roof:r}=t,o=n.t,i=U(n.doc),s=p=>r.patchWindow(p),l=L(n.hass,p=>p.startsWith("cover.")),a=L(n.hass,p=>ii(p)||me(p)),c=(p,h,f,g)=>P(n,o(p),h??null,void 0,f,y=>s({[g]:y==="none"?null:y})),d=p=>{let h=i.find(f=>f.key===p);h&&s({...Nr(h,e.id),w:e.w,h:e.h,cover:e.cover,contact:e.contact,tilt:e.tilt,window:e.window,name:e.name})},u=(n.doc.settings.roof.windows??[]).findIndex(p=>p.id===e.id)+1;return m`${yl(o("roof_sections"),()=>r.windowId=null)}
<section>
${bl(`\u{1FA9F} ${o("roof_window")} ${u}`,Yn(n,!!e.locked,()=>s({locked:!e.locked})))}
${bl(`\u{1FA9F} ${o("roof_window")} ${u}`,Xn(n,!!e.locked,()=>s({locked:!e.locked})))}
<div class="nf-form">
${O(n,o("solar_face"),e.face,i.map(p=>[p.key,xt(n,p)]),d,{wide:!0})}
${E(n,o("width"),e.w??.78,p=>s({w:mn(.3,4)(p)}),.01,.3)}
${E(n,o("height_m"),e.h??1.18,p=>s({h:mn(.3,4)(p)}),.01,.3)}
${E(n,o("width"),e.w??.78,p=>s({w:gn(.3,4)(p)}),.01,.3)}
${E(n,o("height_m"),e.h??1.18,p=>s({h:gn(.3,4)(p)}),.01,.3)}
${E(n,o("solar_u"),e.u,p=>s({u:ie(p)}),.05)} ${E(n,o("solar_v"),e.v,p=>s({v:ie(p)}),.05)}
${c("cover_entity",e.cover,l,"cover")} ${c("contact_entity",e.contact,a,"contact")}
${c("roof_window_tilt",e.tilt,a,"tilt")} ${c("roof_window_motor",e.window,l,"window")}
@@ -1650,14 +1653,14 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${r.map((s,l)=>{let a=o.get(s.face);return m`<div class="nf-row"><button class="nf-dev-name" @click=${()=>i(s.id)}><span>${e.t("roof_window")} ${l+1} · ${a?xt(e,a):e.t("solar_face_gone")}</span></button></div>`})}
</div>`:_}
${Y(m`<button class="nf-btn" ?disabled=${!e.admin||o.size===0} @click=${()=>n.addWindow()}>+ ${e.t("roof_window")}</button>`)}
</section>`}function uv(t,e){let{host:n,roof:r}=t,o=n.t,i=U(n.doc),s=u=>r.patchChimney(u),l=rn(e),a=u=>{let p=i.find(h=>h.key===u);p&&s({...Br(p,e.id),shape:e.shape,w:e.w,d:e.d,h:e.h,name:e.name})},c=l.shape==="round"||l.shape==="steel",d=(n.doc.settings.roof.chimneys??[]).findIndex(u=>u.id===e.id)+1;return m`${yl(o("roof_sections"),()=>r.chimneyId=null)}
</section>`}function uv(t,e){let{host:n,roof:r}=t,o=n.t,i=U(n.doc),s=u=>r.patchChimney(u),l=on(e),a=u=>{let p=i.find(h=>h.key===u);p&&s({...Br(p,e.id),shape:e.shape,w:e.w,d:e.d,h:e.h,name:e.name})},c=l.shape==="round"||l.shape==="steel",d=(n.doc.settings.roof.chimneys??[]).findIndex(u=>u.id===e.id)+1;return m`${yl(o("roof_sections"),()=>r.chimneyId=null)}
<section>
${bl(`\u{1F9F1} ${o("chimney")} ${d}`,Yn(n,!!e.locked,()=>s({locked:!e.locked})))}
${bl(`\u{1F9F1} ${o("chimney")} ${d}`,Xn(n,!!e.locked,()=>s({locked:!e.locked})))}
<div class="nf-form">
${O(n,o("chimney_shape"),l.shape,Ic.map(u=>[u,o(`chimney_${u}`)]),u=>s({shape:u,w:null,d:null,h:null}),{wide:!0})}
${O(n,o("solar_face"),e.face,i.map(u=>[u.key,xt(n,u)]),a,{wide:!0})}
${c?E(n,o("chimney_diameter"),l.w,u=>s({w:mn(.1,3)(u),d:mn(.1,3)(u)}),.01,.1):m`${E(n,o("width"),l.w,u=>s({w:mn(.1,3)(u)}),.01,.1)} ${E(n,o("chimney_depth"),l.d,u=>s({d:mn(.1,3)(u)}),.01,.1)}`}
${E(n,o("chimney_height"),l.h,u=>s({h:mn(.2,5)(u)}),.05,.2)}
${c?E(n,o("chimney_diameter"),l.w,u=>s({w:gn(.1,3)(u),d:gn(.1,3)(u)}),.01,.1):m`${E(n,o("width"),l.w,u=>s({w:gn(.1,3)(u)}),.01,.1)} ${E(n,o("chimney_depth"),l.d,u=>s({d:gn(.1,3)(u)}),.01,.1)}`}
${E(n,o("chimney_height"),l.h,u=>s({h:gn(.2,5)(u)}),.05,.2)}
${E(n,o("solar_u"),e.u,u=>s({u:ie(u)}),.05)} ${E(n,o("solar_v"),e.v,u=>s({v:ie(u)}),.05)}
${Z(n,o("roof_window_name"),e.name??"",u=>s({name:u||null}),{wide:!0,maxlength:64})}
</div>
@@ -1667,7 +1670,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<h3>🧱 ${e.t("chimneys")}</h3>
${o.size>0?_:M(e.t("solar_no_roof"))}
${r.length>0?m`<div class="nf-room-list">
${r.map((s,l)=>{let a=o.get(s.face);return m`<div class="nf-row"><button class="nf-dev-name" @click=${()=>i(s.id)}><span>${e.t("chimney")} ${l+1} · ${e.t(`chimney_${rn(s).shape}`)} · ${a?xt(e,a):e.t("solar_face_gone")}</span></button></div>`})}
${r.map((s,l)=>{let a=o.get(s.face);return m`<div class="nf-row"><button class="nf-dev-name" @click=${()=>i(s.id)}><span>${e.t("chimney")} ${l+1} · ${e.t(`chimney_${on(s).shape}`)} · ${a?xt(e,a):e.t("solar_face_gone")}</span></button></div>`})}
</div>`:_}
${Y(m`<button class="nf-btn" ?disabled=${!e.admin||o.size===0} @click=${()=>n.addChimney()}>+ ${e.t("chimney")}</button>`)}
</section>`}function pv(t,e,n){let r=t.t,o=e.shape,[i,s]=e.ends??[o,o],l=["gable","hip","halfhip"].map(d=>[d,r(`roof_shape_${d}`)]),a=d=>n({ends:d[0]===o&&d[1]===o?null:d}),c=i==="halfhip"||s==="halfhip";return m`<div class="nf-form">
@@ -1677,8 +1680,8 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
>${r("roof_halfhip")} · ${Math.round((e.halfhip??.55)*100)} %
<input type="range" min="20" max="90" step="5" .value=${String(Math.round((e.halfhip??.55)*100))} ?disabled=${!t.admin} @change=${d=>n({halfhip:Number(d.target.value)/100})} />
</label>`:_}
</div>`}function Em(t){let{host:e,roof:n}=t,r=e.doc.settings.roof,o=r.type==="custom";if(n.window)return cv(t,n.window);if(n.chimney)return uv(t,n.chimney);if(o&&n.section)return lv(t,n.section);let i=o?r.sections??[]:[],s=e.t,l=(a,c)=>`${c+1} \xB7 ${a.dormer?s("roof_dormer"):s(`roof_shape_${a.shape}`)} \xB7 ${j(e.hass,Math.abs(a.x1-a.x0),1)} \xD7 ${j(e.hass,Math.abs(a.z1-a.z0),1)} m \xB7 ${s("roof_ridge_height")} ${j(e.hass,Yt(a),1)} m`;return m`<section>
${qn(t)}
</div>`}function Em(t){let{host:e,roof:n}=t,r=e.doc.settings.roof,o=r.type==="custom";if(n.window)return cv(t,n.window);if(n.chimney)return uv(t,n.chimney);if(o&&n.section)return lv(t,n.section);let i=o?r.sections??[]:[],s=e.t,l=(a,c)=>`${c+1} \xB7 ${a.dormer?s("roof_dormer"):s(`roof_shape_${a.shape}`)} \xB7 ${j(e.hass,Math.abs(a.x1-a.x0),1)} \xD7 ${j(e.hass,Math.abs(a.z1-a.z0),1)} m \xB7 ${s("roof_ridge_height")} ${j(e.hass,Xt(a),1)} m`;return m`<section>
${Yn(t)}
<h3>${s("roof_sections")}</h3>
${M(s("roof_sections_hint"))}
${o?m`<div class="nf-room-list">${i.map((a,c)=>m`<div class="nf-row"><button class="nf-dev-name" @click=${()=>n.sectionId=a.id}><span>${l(a,c)}</span></button></div>`)}</div>
@@ -1689,21 +1692,21 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<span>${d.name||`${r("solar_field")} ${u+1}`} · ${p?xt(e,p):r("solar_face_gone")} · ${f}</span>
</button>
</div>`},c=d=>{let u=o.filter(g=>g.string===d.id),p=u.map(g=>kl(l.get(g.id),g)),h=p.reduce((g,y)=>g+y.modules,0),f=p.reduce((g,y)=>g+y.kwp,0);return m`<p class="nf-sub">🔗 <b>${d.name}</b> · ${r("solar_string_sum",{fields:u.length,n:h,kwp:j(e.hass,f,1)})}</p>`};return m`<section>
${qn(t)}
${Yn(t)}
<h3>☀ ${r("solar_fields")}</h3>
${M(r(s.length>0?"solar_hint":"solar_no_roof"))}
${o.length>0?m`<div class="nf-room-list">${o.map(a)}</div>`:_}
${Y(m`<button class="nf-btn nf-primary" ?disabled=${!e.admin||s.length===0} @click=${()=>n.addField()}>+ ${r("solar_add")}</button>`,m`<button class="nf-btn" ?disabled=${!e.admin} @click=${()=>n.addGroundField()}>+ ${r("solar_add_ground")}</button>`,m`<button class="nf-btn" ?disabled=${!e.admin||!t.floorId} @click=${()=>n.addWallField()}>+ ${r("solar_add_wall")}</button>`)}
${i.length>0?m`<h4 class="nf-lib-head">${r("solar_strings")}</h4>${i.map(c)}`:_}
</section>`}function gv(t,e){let{host:n,roof:r}=t,o=n.t,i=L(n.hass,p=>On(n.hass,p)),s=n.doc.settings.roof.strings??[],l=s.find(p=>p.id===e.string),a=[["",o("solar_string_none")],...s.map(p=>[p.id,p.name]),["new",`+ ${o("solar_string_new")}`]],c=O(n,o("solar_string"),e.string??"",a,p=>r.setString(p===""?null:p),{wide:!0});if(!l)return m`${c}${P(n,o("solar_entity"),e.entity??null,void 0,i,p=>r.patchField({entity:p==="none"?null:p}))}`;let d=n.hass?Be(n.hass,n.doc.floors):null,u=n.doc.floors.flatMap(p=>p.furniture.filter(h=>h.type==="inverter").map(h=>({item:h,floor:p}))).map(({item:p,floor:h},f)=>{let g=d?.get(p.id)?.entity,y=p.name?.trim()||(g?W(n.hass,g):"");return[p.id,`${y||`${o("furn_inverter")} ${f+1}`} \xB7 ${h.name}`]});return m`${c}
</section>`}function gv(t,e){let{host:n,roof:r}=t,o=n.t,i=L(n.hass,p=>Hn(n.hass,p)),s=n.doc.settings.roof.strings??[],l=s.find(p=>p.id===e.string),a=[["",o("solar_string_none")],...s.map(p=>[p.id,p.name]),["new",`+ ${o("solar_string_new")}`]],c=O(n,o("solar_string"),e.string??"",a,p=>r.setString(p===""?null:p),{wide:!0});if(!l)return m`${c}${P(n,o("solar_entity"),e.entity??null,void 0,i,p=>r.patchField({entity:p==="none"?null:p}))}`;let d=n.hass?Be(n.hass,n.doc.floors):null,u=n.doc.floors.flatMap(p=>p.furniture.filter(h=>h.type==="inverter").map(h=>({item:h,floor:p}))).map(({item:p,floor:h},f)=>{let g=d?.get(p.id)?.entity,y=p.name?.trim()||(g?W(n.hass,g):"");return[p.id,`${y||`${o("furn_inverter")} ${f+1}`} \xB7 ${h.name}`]});return m`${c}
${Z(n,o("solar_string_name"),l.name,p=>r.patchString({name:p||l.name}),{wide:!0})}
${P(n,o("solar_string_entity"),l.entity??null,void 0,i,p=>r.patchString({entity:p==="none"?null:p}))}
${O(n,o("solar_string_inverter"),l.inverter??"",[["",o(u.length>0?"solar_string_inverter_none":"solar_string_inverter_missing")],...u],p=>r.patchString({inverter:p||null}),{wide:!0})}`}function Lm(t,e){let{host:n,roof:r}=t,o=n.t,i=k=>r.patchField(k),s=U(n.doc),l=ke(n.doc,e,s),a=e.face===De,c=Pr(e),d=kl(l,e),u=c.reduce((k,$)=>k+$,0)-(e.skip?.length??0),p=(n.doc.settings.roof.solar??[]).findIndex(k=>k.id===e.id)+1,h=[...l?[]:[["",o("solar_face_gone")]],...s.map(k=>[k.key,xt(n,k)]),[De,o("solar_ground")],...Ke(n.doc).map(k=>[k.key,xt(n,k)])],f=k=>{let $=Dm(n.doc,e,k);$&&i($)},g=(k,$,A=ie)=>F=>Math.max(k,Math.min($,A(F))),y=k=>i(Cr(n.doc,e,k)),b=k=>i({rotation:(Math.round(k)%360+360)%360||null}),v=l?.wall?"solar_flip_wall":"solar_flip",w=(k,$,A)=>E(n,o($),e[k]??A,F=>i({[k]:g(.3,3)(F)}),.01,.3),x=!!e.layout?.length&&new Set(e.layout).size>1;return m`<button class="nf-btn nf-back" @click=${()=>r.solarId=null}>‹ ${o("solar_fields")}</button>
<section>
${qn(t)}
${Yn(t)}
<div class="nf-h3row">
<h3>☀ ${e.name||`${o("solar_field")} ${p}`}</h3>
${Yn(n,!!e.locked,()=>i({locked:!e.locked}))}
${Xn(n,!!e.locked,()=>i({locked:!e.locked}))}
</div>
<div class="nf-form">
${Z(n,o("solar_name"),e.name??"",k=>i({name:k||null}),{wide:!0,placeholder:o("solar_name_hint")})}
@@ -1721,9 +1724,9 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</label>
</div>
${M(`${l&&!l.unbounded?`${o("solar_face_size",{w:j(n.hass,l.lu,1),h:j(n.hass,l.ls,1)})} \xB7 `:""}${o("solar_cols_hint")}`)}
${x?Xn(n,["left","center","right"].map(k=>[k,o(`solar_align_${k}`)]),e.align??"left",k=>i({align:k})):_}
${Xn(n,[[!0,o("solar_portrait")],[!1,o("solar_landscape")]],e.portrait!==!1,k=>i({portrait:k}))}
${Xn(n,[["black",o("solar_look_black")],["blue",o("solar_look_blue")]],e.look==="blue"?"blue":"black",k=>i({look:k}))}
${x?Qn(n,["left","center","right"].map(k=>[k,o(`solar_align_${k}`)]),e.align??"left",k=>i({align:k})):_}
${Qn(n,[[!0,o("solar_portrait")],[!1,o("solar_landscape")]],e.portrait!==!1,k=>i({portrait:k}))}
${Qn(n,[["black",o("solar_look_black")],["blue",o("solar_look_blue")]],e.look==="blue"?"blue":"black",k=>i({look:k}))}
<div class="nf-form">
${w("module_w","solar_module_w",1.13)} ${w("module_h","solar_module_h",1.72)}
${E(n,o("solar_wp"),e.wp??Om,k=>i({wp:g(50,1500,Math.round)(k)}),5,50)}
@@ -1748,8 +1751,8 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<h4 class="nf-lib-head">🔗 ${o("solar_string")}</h4>
<div class="nf-form">${gv(t,e)}</div>
${M(o("solar_string_hint"))} ${M(o("solar_form_hint"))}
${n.admin?Y(m`<button class="nf-btn" ?disabled=${!l} @click=${()=>l&&i({...zn(l,e.id),portrait:e.portrait})}>${o("solar_fit")}</button>`,m`<button class="nf-btn nf-danger" @click=${()=>r.removeField()}>${o("delete")}</button>`):_}
</section>`}var Cm=t=>Math.round(t*1e3)/1e3,Ci=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=Vs(r,()=>D("roof")))}),this.sectionId=null)}addSection(e,n){if(!this.admin)return;let r=xp(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=Ds(e.rooms,e.walls??[],n,r);if(!o)return;let i=o.map(([s,l])=>[Cm(s),Cm(l)]);this.patchSection({shape:"flat",points:i,...Pt(i)})}addDormer(e){let n=this.section;if(!n||!this.admin)return;let r=Os(n,e,D("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&&Rp(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=$p(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=Wr(U(this.doc).filter(o=>!o.flat),e)??U(this.doc)[0];if(!n)return;let r=Nr(n,D("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=U(r).find(s=>s.key===o.face);i&&Object.assign(o,dt(i,nn(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=U(this.doc),n=e.find(o=>!o.flat)??e[0];if(!n)return;let r=Br(n,D("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=U(r).find(s=>s.key===o.face);i&&Object.assign(o,dt(i,yt(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=U(this.doc),n=new Set((this.settings.solar??[]).map(i=>i.face)),r=this.doc.settings.north??0,o=Wr(e.filter(i=>!n.has(i.key)),r)??Wr(e,r);o&&(this.appendField(zn(o,D("pv"))),this.sectionSel=null)}addWallField(){let e=this.ctx.floorId()??this.doc.floors[0]?.id,n=this.admin&&e?qs(this.doc,D("pv"),e):null;n&&this.appendField(n)}addGroundField(){this.admin&&this.appendField(Lr(this.doc,D("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=ke(r,n);o&&Object.assign(n,dt(o,n))})}toggleCellLine truncated
${n.admin?Y(m`<button class="nf-btn" ?disabled=${!l} @click=${()=>l&&i({...Pn(l,e.id),portrait:e.portrait})}>${o("solar_fit")}</button>`,m`<button class="nf-btn nf-danger" @click=${()=>r.removeField()}>${o("delete")}</button>`):_}
</section>`}var Cm=t=>Math.round(t*1e3)/1e3,Ci=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=Vs(r,()=>D("roof")))}),this.sectionId=null)}addSection(e,n){if(!this.admin)return;let r=xp(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=Ds(e.rooms,e.walls??[],n,r);if(!o)return;let i=o.map(([s,l])=>[Cm(s),Cm(l)]);this.patchSection({shape:"flat",points:i,...It(i)})}addDormer(e){let n=this.section;if(!n||!this.admin)return;let r=Os(n,e,D("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&&Rp(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=$p(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=Wr(U(this.doc).filter(o=>!o.flat),e)??U(this.doc)[0];if(!n)return;let r=Nr(n,D("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=U(r).find(s=>s.key===o.face);i&&Object.assign(o,ut(i,rn(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=U(this.doc),n=e.find(o=>!o.flat)??e[0];if(!n)return;let r=Br(n,D("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=U(r).find(s=>s.key===o.face);i&&Object.assign(o,ut(i,wt(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=U(this.doc),n=new Set((this.settings.solar??[]).map(i=>i.face)),r=this.doc.settings.north??0,o=Wr(e.filter(i=>!n.has(i.key)),r)??Wr(e,r);o&&(this.appendField(Pn(o,D("pv"))),this.sectionSel=null)}addWallField(){let e=this.ctx.floorId()??this.doc.floors[0]?.id,n=this.admin&&e?qs(this.doc,D("pv"),e):null;n&&this.appendField(n)}addGroundField(){this.admin&&this.appendField(Lr(this.doc,D("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=ke(r,n);o&&Object.assign(n,ut(o,n))})}toggleCellLine truncated
${r(t.doc.floors.length>1?"living_area_floor_house":"living_area_floor",{floor:Ae(t.hass,o),house:Ae(t.hass,i)})}
</p>
<div class="nf-actions nf-wide"><button class="nf-btn" title=${r("print_plan_hint")} @click=${()=>n.print()}>🖨️ ${r("print_plan")}</button></div>`}function Pv(t,e,n,r){let o=Jm(t.doc,t.hass?.floors),i=()=>o.length>0?e.floorMenu=!e.floorMenu:n.addFloor(null);return m`<div class="nf-floor-list">
@@ -1780,7 +1783,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<button class="nf-btn nf-primary" @click=${()=>n.duplicateFloor(r)}>${o("floor_copy_make")}</button>
<button class="nf-btn" @click=${()=>e.floorCopy=null}>${o("cancel")}</button>
</div>
</div>`}function Ov(t,e,n,r){let o=t.t,i=c=>t.change((d,u)=>Object.assign(u,c)),s=eg(t.doc,r,t.hass?.floors),l=tr(t.doc,r,t.hass?.areas),a=[["",o("no_ha_floor")],...s.map(c=>[c.floor_id,c.name])];return m`<div class="nf-form">
</div>`}function Ov(t,e,n,r){let o=t.t,i=c=>t.change((d,u)=>Object.assign(u,c)),s=eg(t.doc,r,t.hass?.floors),l=nr(t.doc,r,t.hass?.areas),a=[["",o("no_ha_floor")],...s.map(c=>[c.floor_id,c.name])];return m`<div class="nf-form">
${Z(t,o("floor_name"),r.name,c=>i({name:c}),{wide:!0})}
${E(t,o("elevation"),r.elevation,c=>i({elevation:c}))}
${t.admin?Iv(t,e,n,r):_}
@@ -1843,7 +1846,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${l?m`<button class="nf-btn nf-field-btn" ?disabled=${!t.admin} @click=${()=>r.patch({announce_quiet:null})}>×</button>`:_}
</span>
</div>
${M(o("room_announce_hint"),"nf-wide")}`}function El(t,e,n,r){let o=t.t,i=xn(n.points),s=de(n.points),l=Object.values(t.hass?.areas??{}).sort((h,f)=>h.name.localeCompare(f.name)),a=[["",o("no_area")],...l.map(h=>[h.area_id,h.name])],c=t.floor?pe(t.floor.rooms,{exterior:t.doc.settings.wall_exterior,interior:t.doc.settings.wall_interior},t.floor.walls??[]).walls:[],d=t.floor?Ld(n,c):null,u=Kc.map(h=>[h,o(`mat_${h}`)]),p=h=>m`<button class="nf-btn" @click=${()=>r.applyPackage(h)}><b>${o(`pkg_${h}`)}</b><span>${o(`pkg_${h}_desc`)}</span></button>`;return m`<section>
${M(o("room_announce_hint"),"nf-wide")}`}function El(t,e,n,r){let o=t.t,i=$n(n.points),s=de(n.points),l=Object.values(t.hass?.areas??{}).sort((h,f)=>h.name.localeCompare(f.name)),a=[["",o("no_area")],...l.map(h=>[h.area_id,h.name])],c=t.floor?pe(t.floor.rooms,{exterior:t.doc.settings.wall_exterior,interior:t.doc.settings.wall_interior},t.floor.walls??[]).walls:[],d=t.floor?Ld(n,c):null,u=Kc.map(h=>[h,o(`mat_${h}`)]),p=h=>m`<button class="nf-btn" @click=${()=>r.applyPackage(h)}><b>${o(`pkg_${h}`)}</b><span>${o(`pkg_${h}_desc`)}</span></button>`;return m`<section>
<div class="nf-h3row"><h3>${o("room")}</h3>${r.lockButton}</div>
<div class="nf-form">
${Z(t,o("room_name"),n.name,h=>r.patch({name:h}),{wide:!0})}
@@ -3879,7 +3882,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
font-size: 12.5px;
color: var(--nf-warm);
}
`;var ug=["cabinet","shelf","lamp","device"],gn="own_studio";var Kv={cabinet:{w:120,d:45,h:80,doors:2,drawers:1,shelves:2,base:"plinth",handle:"bar",back:!0,lamp:"floor",display:!1,mount:"floor",body:"white",front:"wood"},shelf:{w:80,d:35,h:180,doors:0,drawers:0,shelves:4,base:"none",handle:"none",back:!0,lamp:"floor",display:!1,mount:"floor",body:"wood",front:"wood"},lamp:{w:40,d:40,h:160,doors:0,drawers:0,shelves:0,base:"none",handle:"none",back:!1,lamp:"floor",display:!1,mount:"floor",body:"metal",front:"white"},device:{w:60,d:60,h:85,doors:0,drawers:0,shelves:0,base:"none",handle:"none",back:!1,lamp:"floor",display:!0,mount:"floor",body:"white",front:"dark"}},Al=(t,e)=>({kind:t,name:e,...Kv[t]}),hg=(t,e)=>({...Al(e,t.name),body:t.body,front:t.front}),nr=(t,e,n)=>Math.min(n,Math.max(e,Number.isFinite(t)?t:e)),rr=t=>Math.round(t*1e4)/1e4;function Fl(t){return{...t,name:t.name.trim().slice(0,60),w:nr(Math.round(t.w),5,400),d:nr(Math.round(t.d),2,200),h:nr(Math.round(t.h),2,300),doors:nr(Math.round(t.doors),0,6),drawers:nr(Math.round(t.drawers),0,6),shelves:nr(Math.round(t.shelves),0,12)}}function le(t,e,n,r,o,i,s,l,a={}){let[c,d,u]=t,p=(x,k,$)=>{let A=Math.max(-$,x-k/2),F=Math.min($,x+k/2);return F-A<1e-4?[Math.max(-$,Math.min($,x)),.001*$*2]:[(A+F)/2,F-A]},[h,f]=p(e,r,c/2),[g,y]=p(n,o,d/2),b=Math.max(0,Math.min(u*.999,i)),v=Math.max(u*.001,Math.min(u-b,s)),w=x=>rr(Math.max(.001,Math.min(1,x)));return{shape:"box",x:rr(h/c),z:rr(g/d),w:w(f/c),d:w(y/d),y:rr(b/u),h:w(v/u),color:l,...a}}function pg(t,e,n){let[r,o,i]=t;if(e==="legs"){let s=Math.min(.1,i*.25),l=Math.min(.04,r/6,o/6);for(let[a,c]of[[-1,-1],[1,-1],[-1,1],[1,1]])n.push(le(t,a*(r/2-l),c*(o/2-l),l,l,0,s,"metal"));return s}if(e==="plinth"){let s=Math.min(.08,i*.2);return n.push(le(t,0,-.02,r-.02,o-.04,0,s,"dark")),s}return 0}function Gv(t,e){let[n,r,o]=e,i=[],s=pg(e,t.base,i),l=t.doors+t.drawers>0,a=t.handle==="none"||!l?0:Math.min(.025,r*.08),c=l?Math.min(.02,r*.1):0,d=r-c-a,u=-r/2+d/2,p=o-s;if(!l){let v=Math.min(.018,n/10,p/10);i.push(le(e,-n/2+v/2,0,v,r,s,p,t.body,{edges:!0})),i.push(le(e,n/2-v/2,0,v,r,s,p,t.body,{edges:!0})),i.push(le(e,0,-r/2+.005,n-2*v,.01,s,p,t.body));for(let w=0;w<=t.shelves+1;w++)i.push(le(e,0,.005,n-2*v,r-.01,s+(p-v)*w/(t.shelves+1),v,t.front,{edges:"faint"}));return i}i.push(le(e,0,u,n,d,s,p,t.body,{edges:!0}));let h=.004,f=-r/2+d+c/2,g=t.doors>0?Math.min(.18,Math.max(.08,(p-.3)/Math.max(1,t.drawers))):p/t.drawers,y=s+(t.drawers>0?g*t.drawers:0),b=(v,w,x)=>{if(t.handle==="none")return;let k=r/2-a/2;t.handle==="knob"?i.push(le(e,v,k,.025,a,w-.0125,.025,"metal")):x?i.push(le(e,v,k,.015,a,w-.08,.16,"metal")):i.push(le(e,v,k,Math.min(.16,n*.4),a,w-.0075,.015,"metal"))};for(let v=0;v<t.drawers;v++){let w=s+g*v;i.push(le(e,0,f,n-2*h,c,w+h,g-2*h,t.front,{edges:"faint"})),b(0,w+g*(t.drawers===1&&t.doors===0?.5:.7),!1)}if(t.doors>0){let v=n/t.doors,w=o-y;for(let x=0;x<t.doors;x++){let k=-n/2+v*(x+.5);i.push(le(e,k,f,v-2*h,c,y+h,w-2*h,t.front,{edges:"faint"}));let $=t.doors===1||x%2===0?1:-1,A=y+w*(o>1.2?.45:.8);b(k+$*(v/2-.04),Math.min(A,o-.1),!0)}}return i}function jv(t,e){let[n,r,o]=e,i=Math.min(.02,n/10,o/10),s=[le(e,-n/2+i/2,0,i,r,0,o,t.body,{edges:!0}),le(e,n/2-i/2,0,i,r,0,o,t.body,{edges:!0})];t.back&&s.push(le(e,0,-r/2+.005,n-2*i,.01,0,o,t.body));let l=t.shelves+2;for(let a=0;a<l;a++)s.push(le(e,0,t.back?.005:0,n-2*i,t.back?r-.01:r,(o-i)*a/(l-1),i,t.front,{edges:!0}));return s}function Uv(t,e){let[n,r,o]=e,i=Math.min(n,r),s=(a,c,d,u,p,h,f={})=>({...le(e,a,c,d,d,u,p,h,f),shape:"cyl"}),l=(a,c,d)=>({...le(e,0,0,i,i,a,c,t.front,{glow:!0,edges:"faint"}),shape:"loft",tw:rr(Math.min(1,i*d/n)),td:rr(Math.min(1,i*d/r))});switch(t.lamp){case"pendant":{let a=Math.min(.3,o*.4);return[s(0,0,Math.min(.12,i),o-.03,.03,t.body),s(0,0,Math.min(.01,i/4),a,o-a-.03,"dark"),l(0,a,.35)]}case"wall":{let a=Math.min(.02,r*.2);return[le(e,0,-r/2+a/2,Math.min(.1,n),a,o*.3,o*.4,t.body),le(e,0,0,Math.min(.02,n),r-a,o*.45,Math.min(.02,o*.1),t.body),l(o*.15,o*.7,.7)]}default:{let a=Math.min(t.lamp==="table"?.25:.35,o*.4);return[s(0,0,i*.6,0,Math.min(.03,o*.05),t.body,{edges:!0}),s(0,0,Math.min(.03,i/6),.02,o-a-.02,t.body),l(o-a,a,.7)]}}}function Zv(t,e){let[n,r,o]=e,i=[],s=t.mount==="floor"?pg(e,t.base,i):0,l=t.display?Math.min(.01,r*.1):0;if(i.push(le(e,0,-l/2,n,r-l,s,o-s,t.body,{edges:!0})),t.display){let a=Math.min(.02,n*.08,(o-s)*.08);i.push(le(e,0,r/2-l/2,n-2*a,l,s+a,o-s-2*a,t.front,{screen:!0}))}return i}function ji(t,e,n){let r=Fl(t),o=[r.w/100,r.d/100,r.h/100],i=r.name||e,s=n==="en"?{en:i}:{[n.slice(0,5)]:i,en:i},l={id:e,name:s,size:o,parts:[],recipe:r};switch(r.kind){case"cabinet":l.parts=Gv(r,o),l.surface=!0;break;case"shelf":l.parts=jv(r,o);break;case"lamp":l.parts=Uv(r,o),l.light=r.lamp,l.mount=r.lamp==="pendant"?"ceiling":r.lamp==="wall"?"wall":r.lamp==="table"?"surface":"floor",r.lamp==="wall"&&(l.wall_y=1.6);break;case"device":l.parts=Zv(r,o),l.electric=!0,l.mount=r.mount,r.mount==="wall"&&(l.wall_y=1.2);break}return l}function fg(t,e){let n Line truncated
`;var ug=["cabinet","shelf","lamp","device"],_n="own_studio";var Kv={cabinet:{w:120,d:45,h:80,doors:2,drawers:1,shelves:2,base:"plinth",handle:"bar",back:!0,lamp:"floor",display:!1,mount:"floor",body:"white",front:"wood"},shelf:{w:80,d:35,h:180,doors:0,drawers:0,shelves:4,base:"none",handle:"none",back:!0,lamp:"floor",display:!1,mount:"floor",body:"wood",front:"wood"},lamp:{w:40,d:40,h:160,doors:0,drawers:0,shelves:0,base:"none",handle:"none",back:!1,lamp:"floor",display:!1,mount:"floor",body:"metal",front:"white"},device:{w:60,d:60,h:85,doors:0,drawers:0,shelves:0,base:"none",handle:"none",back:!1,lamp:"floor",display:!0,mount:"floor",body:"white",front:"dark"}},Al=(t,e)=>({kind:t,name:e,...Kv[t]}),hg=(t,e)=>({...Al(e,t.name),body:t.body,front:t.front}),rr=(t,e,n)=>Math.min(n,Math.max(e,Number.isFinite(t)?t:e)),or=t=>Math.round(t*1e4)/1e4;function Fl(t){return{...t,name:t.name.trim().slice(0,60),w:rr(Math.round(t.w),5,400),d:rr(Math.round(t.d),2,200),h:rr(Math.round(t.h),2,300),doors:rr(Math.round(t.doors),0,6),drawers:rr(Math.round(t.drawers),0,6),shelves:rr(Math.round(t.shelves),0,12)}}function le(t,e,n,r,o,i,s,l,a={}){let[c,d,u]=t,p=(x,k,$)=>{let A=Math.max(-$,x-k/2),F=Math.min($,x+k/2);return F-A<1e-4?[Math.max(-$,Math.min($,x)),.001*$*2]:[(A+F)/2,F-A]},[h,f]=p(e,r,c/2),[g,y]=p(n,o,d/2),b=Math.max(0,Math.min(u*.999,i)),v=Math.max(u*.001,Math.min(u-b,s)),w=x=>or(Math.max(.001,Math.min(1,x)));return{shape:"box",x:or(h/c),z:or(g/d),w:w(f/c),d:w(y/d),y:or(b/u),h:w(v/u),color:l,...a}}function pg(t,e,n){let[r,o,i]=t;if(e==="legs"){let s=Math.min(.1,i*.25),l=Math.min(.04,r/6,o/6);for(let[a,c]of[[-1,-1],[1,-1],[-1,1],[1,1]])n.push(le(t,a*(r/2-l),c*(o/2-l),l,l,0,s,"metal"));return s}if(e==="plinth"){let s=Math.min(.08,i*.2);return n.push(le(t,0,-.02,r-.02,o-.04,0,s,"dark")),s}return 0}function Gv(t,e){let[n,r,o]=e,i=[],s=pg(e,t.base,i),l=t.doors+t.drawers>0,a=t.handle==="none"||!l?0:Math.min(.025,r*.08),c=l?Math.min(.02,r*.1):0,d=r-c-a,u=-r/2+d/2,p=o-s;if(!l){let v=Math.min(.018,n/10,p/10);i.push(le(e,-n/2+v/2,0,v,r,s,p,t.body,{edges:!0})),i.push(le(e,n/2-v/2,0,v,r,s,p,t.body,{edges:!0})),i.push(le(e,0,-r/2+.005,n-2*v,.01,s,p,t.body));for(let w=0;w<=t.shelves+1;w++)i.push(le(e,0,.005,n-2*v,r-.01,s+(p-v)*w/(t.shelves+1),v,t.front,{edges:"faint"}));return i}i.push(le(e,0,u,n,d,s,p,t.body,{edges:!0}));let h=.004,f=-r/2+d+c/2,g=t.doors>0?Math.min(.18,Math.max(.08,(p-.3)/Math.max(1,t.drawers))):p/t.drawers,y=s+(t.drawers>0?g*t.drawers:0),b=(v,w,x)=>{if(t.handle==="none")return;let k=r/2-a/2;t.handle==="knob"?i.push(le(e,v,k,.025,a,w-.0125,.025,"metal")):x?i.push(le(e,v,k,.015,a,w-.08,.16,"metal")):i.push(le(e,v,k,Math.min(.16,n*.4),a,w-.0075,.015,"metal"))};for(let v=0;v<t.drawers;v++){let w=s+g*v;i.push(le(e,0,f,n-2*h,c,w+h,g-2*h,t.front,{edges:"faint"})),b(0,w+g*(t.drawers===1&&t.doors===0?.5:.7),!1)}if(t.doors>0){let v=n/t.doors,w=o-y;for(let x=0;x<t.doors;x++){let k=-n/2+v*(x+.5);i.push(le(e,k,f,v-2*h,c,y+h,w-2*h,t.front,{edges:"faint"}));let $=t.doors===1||x%2===0?1:-1,A=y+w*(o>1.2?.45:.8);b(k+$*(v/2-.04),Math.min(A,o-.1),!0)}}return i}function jv(t,e){let[n,r,o]=e,i=Math.min(.02,n/10,o/10),s=[le(e,-n/2+i/2,0,i,r,0,o,t.body,{edges:!0}),le(e,n/2-i/2,0,i,r,0,o,t.body,{edges:!0})];t.back&&s.push(le(e,0,-r/2+.005,n-2*i,.01,0,o,t.body));let l=t.shelves+2;for(let a=0;a<l;a++)s.push(le(e,0,t.back?.005:0,n-2*i,t.back?r-.01:r,(o-i)*a/(l-1),i,t.front,{edges:!0}));return s}function Uv(t,e){let[n,r,o]=e,i=Math.min(n,r),s=(a,c,d,u,p,h,f={})=>({...le(e,a,c,d,d,u,p,h,f),shape:"cyl"}),l=(a,c,d)=>({...le(e,0,0,i,i,a,c,t.front,{glow:!0,edges:"faint"}),shape:"loft",tw:or(Math.min(1,i*d/n)),td:or(Math.min(1,i*d/r))});switch(t.lamp){case"pendant":{let a=Math.min(.3,o*.4);return[s(0,0,Math.min(.12,i),o-.03,.03,t.body),s(0,0,Math.min(.01,i/4),a,o-a-.03,"dark"),l(0,a,.35)]}case"wall":{let a=Math.min(.02,r*.2);return[le(e,0,-r/2+a/2,Math.min(.1,n),a,o*.3,o*.4,t.body),le(e,0,0,Math.min(.02,n),r-a,o*.45,Math.min(.02,o*.1),t.body),l(o*.15,o*.7,.7)]}default:{let a=Math.min(t.lamp==="table"?.25:.35,o*.4);return[s(0,0,i*.6,0,Math.min(.03,o*.05),t.body,{edges:!0}),s(0,0,Math.min(.03,i/6),.02,o-a-.02,t.body),l(o-a,a,.7)]}}}function Zv(t,e){let[n,r,o]=e,i=[],s=t.mount==="floor"?pg(e,t.base,i):0,l=t.display?Math.min(.01,r*.1):0;if(i.push(le(e,0,-l/2,n,r-l,s,o-s,t.body,{edges:!0})),t.display){let a=Math.min(.02,n*.08,(o-s)*.08);i.push(le(e,0,r/2-l/2,n-2*a,l,s+a,o-s-2*a,t.front,{screen:!0}))}return i}function ji(t,e,n){let r=Fl(t),o=[r.w/100,r.d/100,r.h/100],i=r.name||e,s=n==="en"?{en:i}:{[n.slice(0,5)]:i,en:i},l={id:e,name:s,size:o,parts:[],recipe:r};switch(r.kind){case"cabinet":l.parts=Gv(r,o),l.surface=!0;break;case"shelf":l.parts=jv(r,o);break;case"lamp":l.parts=Uv(r,o),l.light=r.lamp,l.mount=r.lamp==="pendant"?"ceiling":r.lamp==="wall"?"wall":r.lamp==="table"?"surface":"floor",r.lamp==="wall"&&(l.wall_y=1.6);break;case"device":l.parts=Zv(r,o),l.electric=!0,l.mount=r.mount,r.mount==="wall"&&(l.wall_y=1.2);break}return l}function fg(t,e){let n Line truncated
${l.map(a=>{let c=a.w*i,d=a.h*s,u=(a.x+.5)*i-c/2,p=s-(a.y+a.h)*s,h=a.shape==="cyl"?Math.min(c,d)/2:a.shape==="loft"?3:1;return R`<rect x=${u} y=${p} width=${Math.max(.6,c)} height=${Math.max(.6,d)} rx=${h} fill=${a.screen?"#0b1020":_g(a.color)} stroke="rgba(10,16,32,0.55)" stroke-width="0.8" class=${a.glow?"nf-studio-glow":""} />`})}
</svg>`}function gg(t,e,n,r){let o=t.t,i=!mg.includes(n),s=[...mg.map(l=>[l,o(l==="body"?"studio_color_plan":`studio_color_${l}`)]),["own",o("studio_color_own")]];return m`${O(t,e,i?"own":n,s,l=>r(l==="own"?_g(n):l))}
${i?Ue(t,o("studio_color_own"),n,"#8a6a4a",l=>r(l??"wood")):_}`}function bg(t,e,n){let r=t.t,o=e.recipe,i=c=>n.change(Fl({...o,...c})),s=(c,d,u)=>E(t,r(c),d,p=>i({[u]:p}),1,1),l=(c,d,u)=>E(t,r(c),d,p=>i({[u]:p}),1,0),a=()=>{switch(o.kind){case"cabinet":return m`${l("studio_doors",o.doors,"doors")} ${l("studio_drawers",o.drawers,"drawers")}
@@ -3921,7 +3924,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<button class="nf-btn" ?disabled=${!t.admin} @click=${()=>n.ignore([o])}>${r("check_fix_ignore")}</button></li>`)}
</ul>
<button class="nf-btn" ?disabled=${!t.admin} @click=${()=>n.ignore(e)}>${r("check_ignore_all",{n:e.length})}</button>
</details>`}var wg=(t,e)=>m`<button class="nf-btn nf-check-open" title=${t.t("check_open_hint")} @click=${e}>✓ ${t.t("check_open")}</button>`;function vg(t,e){if(!e||!Number.isFinite(e.value))return null;let n=/^\s*([^/\s]+)\s*\/\s*kWh\s*$/i.exec(e.unit);if(!n)return null;let r=/^(ct|cent|cents|c)$/i.test(n[1]),o=r||/^eur$/i.test(n[1])?"\u20AC":n[1];return{value:Math.round(t*e.value*(r?1:100))/100,currency:o}}var xg=20,kg=new WeakMap;function tk(t){let e=t.entities??{},n=kg.get(e);if(!n){n=new Map;for(let[r,o]of Object.entries(e))o.device_id&&r.startsWith("sensor.")&&t.states[r]?.attributes.device_class==="battery"&&!n.has(o.device_id)&&n.set(o.device_id,r);kg.set(e,n)}return n}function nk(t,e){let n=t.entities?.[e]?.device_id,r=n?tk(t).get(n):void 0;if(r){let s=Number(t.states[r]?.state);if(Number.isFinite(s))return s}let o=t.states[e]?.attributes;if(!o||o.battery_level===void 0&&o.battery===void 0)return null;let i=Number(o.battery_level??o.battery);return Number.isFinite(i)?i:null}function rk(t){let e=[],n=r=>typeof r=="string"&&/^[a-z_]+\.[a-z0-9_]+$/.test(r);for(let r of t.placements)e.push({entity:r.entity_id,x:r.x,z:r.z,room:null});for(let r of t.furniture)for(let o of[r.entity,r.power])n(o)&&e.push({entity:o,x:r.x,z:r.z,room:null});for(let r of t.openings)for(let o of[r.contact,r.contact2,r.tilt,r.tilt2,r.cover,r.cover2,r.lock])n(o)&&e.push({entity:o,x:NaN,z:NaN,room:r.room_id});return e}var ok=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&N([e,n],r.points));function $g(t,e){let n=new Set,r=[];for(let o of e.floors)for(let i of rk(o)){let s=t.entities?.[i.entity]?.device_id??i.entity;if(n.has(s))continue;let l=nk(t,i.entity);l!==null&&(n.add(s),r.push({entity:i.entity,level:l,floorId:o.id,roomId:i.room??ok(o,i.x,i.z)?.id??null}))}return r.sort((o,i)=>o.level-i.level)}var or=.08;function Sg(t,e){let n=1/0;for(let r=0;r<e.length;r++){let o=e[r],i=e[(r+1)%e.length],[s,l]=[i[0]-o[0],i[1]-o[1]],a=s*s+l*l,c=a>0?Math.max(0,Math.min(1,((t[0]-o[0])*s+(t[1]-o[1])*l)/a)):0;n=Math.min(n,Math.hypot(t[0]-(o[0]+s*c),t[1]-(o[1]+l*c)))}return n}var Mg=t=>({x0:Math.min(...t.map(e=>e[0])),x1:Math.max(...t.map(e=>e[0])),z0:Math.min(...t.map(e=>e[1])),z1:Math.max(...t.map(e=>e[1]))});function ik(t,e,n=.2){if(t.points.length<3||e.points.length<3)return!1;let[r,o]=[Mg(t.points),Mg(e.points)],i=Math.max(r.x0,o.x0)+or,s=Math.min(r.x1,o.x1)-or,l=Math.max(r.z0,o.z0)+or,a=Math.min(r.z1,o.z1)-or;if(s<=i||a<=l)return!1;for(let c=i;c<=s+1e-9;c+=Math.min(n,s-i||n))for(let d=l;d<=a+1e-9;d+=Math.min(n,a-l||n)){let u=[c,d];if(N(u,t.points)&&N(u,e.points)&&Sg(u,t.points)>or&&Sg(u,e.points)>or)return!0}return!1}function Eg(t){let e=new Set(["id","type","variant","name","icon","picture","vehicle","room_id","wall"]),n=r=>typeof r=="string"&&/^[a-z_]+\.[a-z0-9_]+$/.test(r);return Object.entries(t).flatMap(([r,o])=>e.has(r)?[]:Array.isArray(o)?o.filter(n):n(o)?[o]:[])}var Rg=t=>Eg(t),sk=3,ak=new Set(["off","standby","idle"]);function lk(t,e,n,r){let o=e.energy.tariff,i=o?t.states[o]:void 0,s=i?{value:Number(i.state),unit:String(i.attributes.unit_of_measurement??"")}:null,l=new Set,a=(c,d)=>{if(!c||c==="none"||l.has(c))return;l.add(c);let u=t.states[c]?.state;if(!u||!ak.has(u)||c.startsWith("light."))return;let p=fh(t,c),h=p?Ee(t.states[p]):null;if(h===null||h<=sk)return;let f=vg(h*24*365/1e3,s);r.push({kind:"standby",floorId:n.id,vars:{name:W(t,c),w:Math.round(h),cost:f?`${f.value.toFixed(0)} ${f.currency}`:`${Math.round(h*24*365/1e3)} kWh`},fix:d,changes:!1})};for(let c of n.furniture)a(c.entity,{do:"show_furniture",furnitureId:c.id});for(let c of n.placements){let d=n.rooms.find(u=>u.points.length>=3&&N([c.x,c.z],u.points));d&&a(c.entity_id,{do:"show_room",roomId:d.id})}}function Ag(t,e){let n=[],r=e?.areas,o=new Set(t.settings.check_ignore??[]),i=new Set(t.floors.flatMap(s=>s.rooms.map(l=>l.area_id)).filter(s=>!!s));for(let s of t.floors){if(s.layer)continue;for(let a of s.rooms){if(a.area_id)continue;let c=Object.values(r??{}).find(d=>d.name.trim().toLowerCase()===a.name.trim().toLowerCase()&&!i.has(d.area_id));n.push(c?{kind:"room_no_area",floorId:s.id,vars:{room:a.name,area:c.name},fix:{do:"set_area",roomId:a.id,areaId:c.area_id},changes:!0}:{kind:"room_no_area",floorId:s.id,vars:{room:a.name,area:""},fix:{do:"show_room",roomId:a.id},changes:!1})}let l=tr(t,s,r);if(l.length&&n.push({kind:"areas_unplaced",floorId:s.id,vars:{n:l.length,names:l.map(a=>a.name).join(", ")},fix:{do:"add_area_rooms"},changes:!0}),e){let a=Be(e,[s]),c=br(e,[s]);for(let d of s.rooms){if(!d.area_id)continue;let u=Mi(s,d);for(let f of s.furniture)if(N([f.x,f.z],d.points))for(let g of Rg(f))u.add(g);for(let f of s.openings)if(f.room_id===d.id){for(let g of Eg(f))u.add(g);for(let g of Object.values(c.get(f.id)??{}))typeof g=="string"&&u.add(g)}for(let f of s.furniture){let g=a.get(f.id);if(g&&N([f.x,f.z],d.points))for(let y of[g.entity,g.power])typeof y=="string"&&u.add(y)}let p=be(e,d).filter(f=>Mt(Ne(e,f))),h=Sn(e,p).map(f=>f.primary).filter(f=>!u.has(f)&&!Line truncated
</details>`}var wg=(t,e)=>m`<button class="nf-btn nf-check-open" title=${t.t("check_open_hint")} @click=${e}>✓ ${t.t("check_open")}</button>`;function vg(t,e){if(!e||!Number.isFinite(e.value))return null;let n=/^\s*([^/\s]+)\s*\/\s*kWh\s*$/i.exec(e.unit);if(!n)return null;let r=/^(ct|cent|cents|c)$/i.test(n[1]),o=r||/^eur$/i.test(n[1])?"\u20AC":n[1];return{value:Math.round(t*e.value*(r?1:100))/100,currency:o}}var xg=20,kg=new WeakMap;function tk(t){let e=t.entities??{},n=kg.get(e);if(!n){n=new Map;for(let[r,o]of Object.entries(e))o.device_id&&r.startsWith("sensor.")&&t.states[r]?.attributes.device_class==="battery"&&!n.has(o.device_id)&&n.set(o.device_id,r);kg.set(e,n)}return n}function nk(t,e){let n=t.entities?.[e]?.device_id,r=n?tk(t).get(n):void 0;if(r){let s=Number(t.states[r]?.state);if(Number.isFinite(s))return s}let o=t.states[e]?.attributes;if(!o||o.battery_level===void 0&&o.battery===void 0)return null;let i=Number(o.battery_level??o.battery);return Number.isFinite(i)?i:null}function rk(t){let e=[],n=r=>typeof r=="string"&&/^[a-z_]+\.[a-z0-9_]+$/.test(r);for(let r of t.placements)e.push({entity:r.entity_id,x:r.x,z:r.z,room:null});for(let r of t.furniture)for(let o of[r.entity,r.power])n(o)&&e.push({entity:o,x:r.x,z:r.z,room:null});for(let r of t.openings)for(let o of[r.contact,r.contact2,r.tilt,r.tilt2,r.cover,r.cover2,r.lock])n(o)&&e.push({entity:o,x:NaN,z:NaN,room:r.room_id});return e}var ok=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&N([e,n],r.points));function $g(t,e){let n=new Set,r=[];for(let o of e.floors)for(let i of rk(o)){let s=t.entities?.[i.entity]?.device_id??i.entity;if(n.has(s))continue;let l=nk(t,i.entity);l!==null&&(n.add(s),r.push({entity:i.entity,level:l,floorId:o.id,roomId:i.room??ok(o,i.x,i.z)?.id??null}))}return r.sort((o,i)=>o.level-i.level)}var ir=.08;function Sg(t,e){let n=1/0;for(let r=0;r<e.length;r++){let o=e[r],i=e[(r+1)%e.length],[s,l]=[i[0]-o[0],i[1]-o[1]],a=s*s+l*l,c=a>0?Math.max(0,Math.min(1,((t[0]-o[0])*s+(t[1]-o[1])*l)/a)):0;n=Math.min(n,Math.hypot(t[0]-(o[0]+s*c),t[1]-(o[1]+l*c)))}return n}var Mg=t=>({x0:Math.min(...t.map(e=>e[0])),x1:Math.max(...t.map(e=>e[0])),z0:Math.min(...t.map(e=>e[1])),z1:Math.max(...t.map(e=>e[1]))});function ik(t,e,n=.2){if(t.points.length<3||e.points.length<3)return!1;let[r,o]=[Mg(t.points),Mg(e.points)],i=Math.max(r.x0,o.x0)+ir,s=Math.min(r.x1,o.x1)-ir,l=Math.max(r.z0,o.z0)+ir,a=Math.min(r.z1,o.z1)-ir;if(s<=i||a<=l)return!1;for(let c=i;c<=s+1e-9;c+=Math.min(n,s-i||n))for(let d=l;d<=a+1e-9;d+=Math.min(n,a-l||n)){let u=[c,d];if(N(u,t.points)&&N(u,e.points)&&Sg(u,t.points)>ir&&Sg(u,e.points)>ir)return!0}return!1}function Eg(t){let e=new Set(["id","type","variant","name","icon","picture","vehicle","room_id","wall"]),n=r=>typeof r=="string"&&/^[a-z_]+\.[a-z0-9_]+$/.test(r);return Object.entries(t).flatMap(([r,o])=>e.has(r)?[]:Array.isArray(o)?o.filter(n):n(o)?[o]:[])}var Rg=t=>Eg(t),sk=3,ak=new Set(["off","standby","idle"]);function lk(t,e,n,r){let o=e.energy.tariff,i=o?t.states[o]:void 0,s=i?{value:Number(i.state),unit:String(i.attributes.unit_of_measurement??"")}:null,l=new Set,a=(c,d)=>{if(!c||c==="none"||l.has(c))return;l.add(c);let u=t.states[c]?.state;if(!u||!ak.has(u)||c.startsWith("light."))return;let p=fh(t,c),h=p?Ee(t.states[p]):null;if(h===null||h<=sk)return;let f=vg(h*24*365/1e3,s);r.push({kind:"standby",floorId:n.id,vars:{name:W(t,c),w:Math.round(h),cost:f?`${f.value.toFixed(0)} ${f.currency}`:`${Math.round(h*24*365/1e3)} kWh`},fix:d,changes:!1})};for(let c of n.furniture)a(c.entity,{do:"show_furniture",furnitureId:c.id});for(let c of n.placements){let d=n.rooms.find(u=>u.points.length>=3&&N([c.x,c.z],u.points));d&&a(c.entity_id,{do:"show_room",roomId:d.id})}}function Ag(t,e){let n=[],r=e?.areas,o=new Set(t.settings.check_ignore??[]),i=new Set(t.floors.flatMap(s=>s.rooms.map(l=>l.area_id)).filter(s=>!!s));for(let s of t.floors){if(s.layer)continue;for(let a of s.rooms){if(a.area_id)continue;let c=Object.values(r??{}).find(d=>d.name.trim().toLowerCase()===a.name.trim().toLowerCase()&&!i.has(d.area_id));n.push(c?{kind:"room_no_area",floorId:s.id,vars:{room:a.name,area:c.name},fix:{do:"set_area",roomId:a.id,areaId:c.area_id},changes:!0}:{kind:"room_no_area",floorId:s.id,vars:{room:a.name,area:""},fix:{do:"show_room",roomId:a.id},changes:!1})}let l=nr(t,s,r);if(l.length&&n.push({kind:"areas_unplaced",floorId:s.id,vars:{n:l.length,names:l.map(a=>a.name).join(", ")},fix:{do:"add_area_rooms"},changes:!0}),e){let a=Be(e,[s]),c=Rn(e,[s]);for(let d of s.rooms){if(!d.area_id)continue;let u=Mi(s,d);for(let f of s.furniture)if(N([f.x,f.z],d.points))for(let g of Rg(f))u.add(g);for(let f of s.openings)if(f.room_id===d.id){for(let g of Eg(f))u.add(g);for(let g of Object.values(c.get(f.id)??{}))typeof g=="string"&&u.add(g)}for(let f of s.furniture){let g=a.get(f.id);if(g&&N([f.x,f.z],d.points))for(let y of[g.entity,g.power])typeof y=="string"&&u.add(y)}let p=be(e,d).filter(f=>Mt(Ne(e,f))),h=Mn(e,p).map(f=>f.primary).filter(f=>!u.has(f)&&!Line truncated
body { font-family: system-ui, sans-serif; color: #111; margin: 0; background: #fff; }
.page { page-break-after: always; padding: 12mm; }
.page:last-child { page-break-after: auto; }
@@ -3952,7 +3955,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<button class="nf-btn nf-primary" @click=${()=>n(i?null:e+1)}>${t(i?"tour_done":"tour_next")}</button>
${i?_:m`<button class="nf-link" @click=${()=>n(null)}>${t("tour_skip")}</button>`}
</div>
</div>`}var Wt="https://github.com/therealMRBK/NextFloor";var mo=t=>`/api/nextfloor/mesh/${encodeURIComponent(t)}`,ir=12*1024*1024;function Og(t,e){let n=new Map;for(let r of t)for(let o of r.items){if(!o.mesh)continue;let i=n.get(o.mesh)??[];n.set(o.mesh,[...i,`${Ye(o,ue(r.id,o.id),e)} \xB7 ${Oe(r,e)}`])}return[...n].map(([r,o])=>({id:r,items:o})).sort((r,o)=>r.items[0].localeCompare(o.items[0]))}function sr(t){return t<1024*1024?`${Math.max(1,Math.round(t/1024))} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Tl(t){return t===201||t===200||t===204?null:t===401||t===403?"forbidden":t===413?"too_large":t===400?"not_glb":t===404?"bad_id":"other"}var hk=40,pk=(t=ir)=>Math.floor(t*.8/hk),zl=[{key:"light",triangles:3e4},{key:"normal",triangles:8e4},{key:"fine",triangles:15e4}];function Hg(t){return Math.min(zl.find(e=>e.key===t).triangles,pk())}var Pl=class extends ne{static properties={hass:{attribute:!1},packs:{attribute:!1},_present:{state:!0},_draft:{state:!0},_busy:{state:!0},_message:{state:!0}};checked=new Set;run=0;constructor(){super(),this._present={},this._draft=null,this._busy=!1,this._message=null}t(e,n){return xe(this.hass,e,n)}get slots(){return Og(this.packs??[],this.hass?.language??"en")}willUpdate(){for(let e of this.slots)this.checked.has(e.id)||!this.hass?.fetchWithAuth||(this.checked.add(e.id),this.askPresence(e.id))}async askPresence(e){let n=await this.hass.fetchWithAuth(mo(e),{method:"HEAD"}).catch(()=>null),r=n&&n.status!==405?n.ok:await this.hass.fetchWithAuth(mo(e)).then(o=>o.ok,()=>!1);this._present={...this._present,[e]:r?"yes":"no"}}async choose(e,n){if(n){this._message=null,this._busy=!0;try{let r=await n.arrayBuffer(),i=await(await pn()).inspectModel(r);this._draft={slot:e,fileName:n.name,data:r,info:i,turns:0,paint:i.paint,detail:"normal",colour:"#1d5bd6",result:null},await this.refresh()}catch(r){this._draft=null,this._message={ok:!1,text:this.readError(r)}}finally{this._busy=!1}}}readError(e){let r=`model_error_${e?.reason}`,o=this.t(r);return o===r?this.t("model_error_unreadable",{detail:String(e?.message??e)}):o}async refresh(){let e=this._draft;if(!e)return;let n=++this.run;this._busy=!0;try{let r=await pn(),{glb:o,triangles:i}=await r.prepareModel(e.data,{turns:e.turns,paint:e.paint,maxTriangles:Hg(e.detail)}),s=await r.previewModel(o,e.colour);n===this.run&&this._draft===e&&(this._draft={...e,result:{glb:o,triangles:i,picture:s}})}catch(r){n===this.run&&(this._message={ok:!1,text:this.readError(r)})}finally{n===this.run&&(this._busy=!1)}}change(e){this._draft&&(this._draft={...this._draft,...e},this.refresh())}turn(e){this._draft&&this.change({turns:(this._draft.turns+e+4)%4})}togglePaint(e,n){if(!this._draft)return;let r=this._draft.paint.filter(o=>o!==e);this.change({paint:n?[...r,e]:r})}async upload(){let e=this._draft;if(!(!e?.result||!this.hass?.fetchWithAuth)){if(e.result.glb.byteLength>ir){this._message={ok:!1,text:this.t("model_error_too_large",{max:sr(ir)})};return}this._busy=!0;try{let n=await this.hass.fetchWithAuth(mo(e.slot.id),{method:"POST",body:e.result.glb}),r=Tl(n.status);if(r){this._message={ok:!1,text:this.t(`model_upload_${r}`,{max:sr(ir)})};return}this._present={...this._present,[e.slot.id]:"yes"},this._message={ok:!0,text:this.t("model_uploaded",{id:e.slot.id,size:sr(e.result.glb.byteLength)})},this._draft=null}catch(n){this._message={ok:!1,text:this.t("model_upload_other",{detail:String(n?.message??n)})}}finally{this._busy=!1}}}async removeModel(e){if(!this.hass?.fetchWithAuth||!confirm(this.t("model_remove_confirm",{id:e.id})))return;let n=await this.hass.fetchWithAuth(mo(e.id),{method:"DELETE"}),r=Tl(n.status);this._present={...this._present,[e.id]:r?this._present[e.id]:"no"},this._message=r?{ok:!1,text:this.t(`model_upload_${r}`,{max:sr(ir)})}:{ok:!0,text:this.t("model_removed",{id:e.id})}}row(e){let n=this._present[e.id]??"unknown",r=n==="yes"?this.t("model_present"):n==="no"?this.t("model_missing"):"\u2026";return m`<div class="nf-model">
</div>`}var Vt="https://github.com/therealMRBK/NextFloor";var mo=t=>`/api/nextfloor/mesh/${encodeURIComponent(t)}`,sr=12*1024*1024;function Og(t,e){let n=new Map;for(let r of t)for(let o of r.items){if(!o.mesh)continue;let i=n.get(o.mesh)??[];n.set(o.mesh,[...i,`${Ye(o,ue(r.id,o.id),e)} \xB7 ${Oe(r,e)}`])}return[...n].map(([r,o])=>({id:r,items:o})).sort((r,o)=>r.items[0].localeCompare(o.items[0]))}function ar(t){return t<1024*1024?`${Math.max(1,Math.round(t/1024))} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Tl(t){return t===201||t===200||t===204?null:t===401||t===403?"forbidden":t===413?"too_large":t===400?"not_glb":t===404?"bad_id":"other"}var hk=40,pk=(t=sr)=>Math.floor(t*.8/hk),zl=[{key:"light",triangles:3e4},{key:"normal",triangles:8e4},{key:"fine",triangles:15e4}];function Hg(t){return Math.min(zl.find(e=>e.key===t).triangles,pk())}var Pl=class extends ne{static properties={hass:{attribute:!1},packs:{attribute:!1},_present:{state:!0},_draft:{state:!0},_busy:{state:!0},_message:{state:!0}};checked=new Set;run=0;constructor(){super(),this._present={},this._draft=null,this._busy=!1,this._message=null}t(e,n){return xe(this.hass,e,n)}get slots(){return Og(this.packs??[],this.hass?.language??"en")}willUpdate(){for(let e of this.slots)this.checked.has(e.id)||!this.hass?.fetchWithAuth||(this.checked.add(e.id),this.askPresence(e.id))}async askPresence(e){let n=await this.hass.fetchWithAuth(mo(e),{method:"HEAD"}).catch(()=>null),r=n&&n.status!==405?n.ok:await this.hass.fetchWithAuth(mo(e)).then(o=>o.ok,()=>!1);this._present={...this._present,[e]:r?"yes":"no"}}async choose(e,n){if(n){this._message=null,this._busy=!0;try{let r=await n.arrayBuffer(),i=await(await fn()).inspectModel(r);this._draft={slot:e,fileName:n.name,data:r,info:i,turns:0,paint:i.paint,detail:"normal",colour:"#1d5bd6",result:null},await this.refresh()}catch(r){this._draft=null,this._message={ok:!1,text:this.readError(r)}}finally{this._busy=!1}}}readError(e){let r=`model_error_${e?.reason}`,o=this.t(r);return o===r?this.t("model_error_unreadable",{detail:String(e?.message??e)}):o}async refresh(){let e=this._draft;if(!e)return;let n=++this.run;this._busy=!0;try{let r=await fn(),{glb:o,triangles:i}=await r.prepareModel(e.data,{turns:e.turns,paint:e.paint,maxTriangles:Hg(e.detail)}),s=await r.previewModel(o,e.colour);n===this.run&&this._draft===e&&(this._draft={...e,result:{glb:o,triangles:i,picture:s}})}catch(r){n===this.run&&(this._message={ok:!1,text:this.readError(r)})}finally{n===this.run&&(this._busy=!1)}}change(e){this._draft&&(this._draft={...this._draft,...e},this.refresh())}turn(e){this._draft&&this.change({turns:(this._draft.turns+e+4)%4})}togglePaint(e,n){if(!this._draft)return;let r=this._draft.paint.filter(o=>o!==e);this.change({paint:n?[...r,e]:r})}async upload(){let e=this._draft;if(!(!e?.result||!this.hass?.fetchWithAuth)){if(e.result.glb.byteLength>sr){this._message={ok:!1,text:this.t("model_error_too_large",{max:ar(sr)})};return}this._busy=!0;try{let n=await this.hass.fetchWithAuth(mo(e.slot.id),{method:"POST",body:e.result.glb}),r=Tl(n.status);if(r){this._message={ok:!1,text:this.t(`model_upload_${r}`,{max:ar(sr)})};return}this._present={...this._present,[e.slot.id]:"yes"},this._message={ok:!0,text:this.t("model_uploaded",{id:e.slot.id,size:ar(e.result.glb.byteLength)})},this._draft=null}catch(n){this._message={ok:!1,text:this.t("model_upload_other",{detail:String(n?.message??n)})}}finally{this._busy=!1}}}async removeModel(e){if(!this.hass?.fetchWithAuth||!confirm(this.t("model_remove_confirm",{id:e.id})))return;let n=await this.hass.fetchWithAuth(mo(e.id),{method:"DELETE"}),r=Tl(n.status);this._present={...this._present,[e.id]:r?this._present[e.id]:"no"},this._message=r?{ok:!1,text:this.t(`model_upload_${r}`,{max:ar(sr)})}:{ok:!0,text:this.t("model_removed",{id:e.id})}}row(e){let n=this._present[e.id]??"unknown",r=n==="yes"?this.t("model_present"):n==="no"?this.t("model_missing"):"\u2026";return m`<div class="nf-model">
<div>
<b>${e.items[0]}</b>${e.items.length>1?m` <span class="nf-sub">+${e.items.length-1}</span>`:_}
<span class="nf-sub">${e.id}.glb · <span class="nf-model-${n}">${r}</span></span>
@@ -3986,7 +3989,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<div class="nf-field">
<span>${this.t("model_detail")}</span>
<div class="nf-seg">${zl.map(i=>m`<button aria-pressed=${e.detail===i.key} @click=${()=>this.change({detail:i.key})}>${this.t(`model_detail_${i.key}`)}</button>`)}</div>
${r?m`<small class="nf-sub">${this.t("model_result",{triangles:r.triangles.toLocaleString(this.hass?.language),size:sr(r.glb.byteLength)})}</small>`:_}
${r?m`<small class="nf-sub">${this.t("model_result",{triangles:r.triangles.toLocaleString(this.hass?.language),size:ar(r.glb.byteLength)})}</small>`:_}
</div>
</div>
</div>
@@ -4002,7 +4005,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${this._busy&&!this._draft?m`<p class="nf-sub">${this.t("loading")}</p>`:_}
${this._message?m`<p class="nf-sub ${this._message.ok?"nf-notice":"nf-pack-error"}">${this._message.text}</p>`:_}
<p class="nf-sub">${this.t("models_licence")}</p>
</section>`}static styles=[Me,ut,se`
</section>`}static styles=[Me,ht,se`
:host {
display: block;
}
@@ -4063,10 +4066,10 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
display: grid;
gap: 4px;
}
`]};customElements.get("nf-model-upload")||customElements.define("nf-model-upload",Pl);var ar="therealMRBK/NextFloor-Plugins",Lg=`https://raw.githubusercontent.com/${ar}/main/index.json`,fk=t=>/^https:\/\/raw\.githubusercontent\.com\/[\w.-]+\/[\w.-]+\/[0-9a-f]{40}\/[\w./-]+\.m?js$/.test(t),Te=(t,e)=>typeof t=="string"?t.trim().slice(0,e):"";function mk(t){let e=t?.plugins;if(!Array.isArray(e))return[];let n=new Set,r=[];for(let o of e){if(!o||typeof o!="object")continue;let i=Te(o.id,64),s=Te(o.url,300),l=Te(o.sha256,64).toLowerCase(),a=Te(o.name,60),c=Te(o.version,40),d=Te(o.homepage,200);!/^[\w.-]+$/.test(i)||n.has(i)||!a||!c||!fk(s)||!/^[0-9a-f]{64}$/.test(l)||(n.add(i),r.push({id:i,name:a,description:Te(o.description,300),author:Te(o.author,60),version:c,homepage:/^https:\/\//.test(d)?d:"",url:s,sha256:l}))}return r}async function Cg(t=(...e)=>fetch(...e)){let e=await t(Lg,{cache:"no-store"});if(!e.ok)throw new Error(`HTTP ${e.status}`);return mk(await e.json())}function Ng(t,e){let n=(e??[]).find(r=>r.id===t.id);return n?n.sha256===t.sha256&&n.url===t.url?"installed":"update":"available"}function Bg(t,e){let n=t??[],r={url:e.url,enabled:!0,id:e.id,version:e.version,sha256:e.sha256},o=n.findIndex(i=>i.id===e.id);return o<0?[...n,r]:n.map((i,s)=>s===o?{...r,enabled:i.enabled}:i)}var gk=(t,e)=>t===`https://raw.githubusercontent.com/${ar}/main/packs/${e}.json`;function _k(t){let e=t?.packs;if(!Array.isArray(e))return[];let n=new Set,r=[];for(let o of e){if(!o||typeof o!="object")continue;let i=Te(o.id,40),s=Te(o.url,300),l=Te(o.sha256,64).toLowerCase(),a=Te(o.name,80);if(!/^[a-z0-9][a-z0-9_.-]{0,39}$/.test(i)||i.startsWith("nextfloor.")||n.has(i)||!a||!gk(s,i)||!/^[0-9a-f]{64}$/.test(l))continue;n.add(i);let c=(d,u)=>typeof d=="number"&&Number.isInteger(d)&&d>0?d:u;r.push({id:i,name:a,description:Te(o.description,400),author:Te(o.author,80),release:c(o.release,1),items:c(o.items,0),url:s,sha256:l})}return r.sort((o,i)=>o.name.localeCompare(i.name))}async function Wg(t=(...e)=>fetch(...e)){let e=await t(Lg,{cache:"no-store"});if(!e.ok)throw new Error(`HTTP ${e.status}`);return _k(await e.json())}function Vg(t,e){let n=e.find(r=>r.id===t.id);return n?(n.release??1)>=t.release?"installed":"update":"available"}var bk=t=>[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("");async function Kg(t,e=(...n)=>fetch(...n)){let n=await e(t.url,{cache:"no-store"});if(!n.ok)throw new Error(`HTTP ${n.status}`);let r=await n.arrayBuffer(),o=globalThis.crypto?.subtle;if(o&&bk(await o.digest("SHA-256",r))!==t.sha256)throw new Error("checksum mismatch: the file is not the one that was reviewed");return new TextDecoder().decode(r)}var yk="https://therealmrbk.github.io/NextFloor/builder/",Il=class extends ne{static properties={hass:{attribute:!1},packs:{attribute:!1},_msg:{state:!0},_busy:{state:!0},_store:{state:!0},_storeError:{state:!0}};constructor(){super(),this._msg=null,this._busy=!1,this._store=null,this._storeError=null}async loadStore(){this._store="loading",this._storeError=null;try{this._store=await Wg()}catch(e){this._store=null,this._storeError=this.t("community_failed",{detail:e?.message??String(e)})}}async installStore(e){this._busy=!0,this._msg=null;try{let n=await fr(this.hass,await Kg(e));this._msg={ok:!0,text:this.t("pack_imported",{name:n.name,publisher:n.publisher,n:n.items})},this.changed()}catch(n){this._msg={ok:!1,text:this.errorText(n)}}finally{this._busy=!1}}renderStore(){let e=this.packs??[],n=this._store;return m`<h4>${this.t("community_title")}</h4>
`]};customElements.get("nf-model-upload")||customElements.define("nf-model-upload",Pl);var lr="therealMRBK/NextFloor-Plugins",Lg=`https://raw.githubusercontent.com/${lr}/main/index.json`,fk=t=>/^https:\/\/raw\.githubusercontent\.com\/[\w.-]+\/[\w.-]+\/[0-9a-f]{40}\/[\w./-]+\.m?js$/.test(t),Te=(t,e)=>typeof t=="string"?t.trim().slice(0,e):"";function mk(t){let e=t?.plugins;if(!Array.isArray(e))return[];let n=new Set,r=[];for(let o of e){if(!o||typeof o!="object")continue;let i=Te(o.id,64),s=Te(o.url,300),l=Te(o.sha256,64).toLowerCase(),a=Te(o.name,60),c=Te(o.version,40),d=Te(o.homepage,200);!/^[\w.-]+$/.test(i)||n.has(i)||!a||!c||!fk(s)||!/^[0-9a-f]{64}$/.test(l)||(n.add(i),r.push({id:i,name:a,description:Te(o.description,300),author:Te(o.author,60),version:c,homepage:/^https:\/\//.test(d)?d:"",url:s,sha256:l}))}return r}async function Cg(t=(...e)=>fetch(...e)){let e=await t(Lg,{cache:"no-store"});if(!e.ok)throw new Error(`HTTP ${e.status}`);return mk(await e.json())}function Ng(t,e){let n=(e??[]).find(r=>r.id===t.id);return n?n.sha256===t.sha256&&n.url===t.url?"installed":"update":"available"}function Bg(t,e){let n=t??[],r={url:e.url,enabled:!0,id:e.id,version:e.version,sha256:e.sha256},o=n.findIndex(i=>i.id===e.id);return o<0?[...n,r]:n.map((i,s)=>s===o?{...r,enabled:i.enabled}:i)}var gk=(t,e)=>t===`https://raw.githubusercontent.com/${lr}/main/packs/${e}.json`;function _k(t){let e=t?.packs;if(!Array.isArray(e))return[];let n=new Set,r=[];for(let o of e){if(!o||typeof o!="object")continue;let i=Te(o.id,40),s=Te(o.url,300),l=Te(o.sha256,64).toLowerCase(),a=Te(o.name,80);if(!/^[a-z0-9][a-z0-9_.-]{0,39}$/.test(i)||i.startsWith("nextfloor.")||n.has(i)||!a||!gk(s,i)||!/^[0-9a-f]{64}$/.test(l))continue;n.add(i);let c=(d,u)=>typeof d=="number"&&Number.isInteger(d)&&d>0?d:u;r.push({id:i,name:a,description:Te(o.description,400),author:Te(o.author,80),release:c(o.release,1),items:c(o.items,0),url:s,sha256:l})}return r.sort((o,i)=>o.name.localeCompare(i.name))}async function Wg(t=(...e)=>fetch(...e)){let e=await t(Lg,{cache:"no-store"});if(!e.ok)throw new Error(`HTTP ${e.status}`);return _k(await e.json())}function Vg(t,e){let n=e.find(r=>r.id===t.id);return n?(n.release??1)>=t.release?"installed":"update":"available"}var bk=t=>[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("");async function Kg(t,e=(...n)=>fetch(...n)){let n=await e(t.url,{cache:"no-store"});if(!n.ok)throw new Error(`HTTP ${n.status}`);let r=await n.arrayBuffer(),o=globalThis.crypto?.subtle;if(o&&bk(await o.digest("SHA-256",r))!==t.sha256)throw new Error("checksum mismatch: the file is not the one that was reviewed");return new TextDecoder().decode(r)}var yk="https://therealmrbk.github.io/NextFloor/builder/",Il=class extends ne{static properties={hass:{attribute:!1},packs:{attribute:!1},_msg:{state:!0},_busy:{state:!0},_store:{state:!0},_storeError:{state:!0}};constructor(){super(),this._msg=null,this._busy=!1,this._store=null,this._storeError=null}async loadStore(){this._store="loading",this._storeError=null;try{this._store=await Wg()}catch(e){this._store=null,this._storeError=this.t("community_failed",{detail:e?.message??String(e)})}}async installStore(e){this._busy=!0,this._msg=null;try{let n=await mr(this.hass,await Kg(e));this._msg={ok:!0,text:this.t("pack_imported",{name:n.name,publisher:n.publisher,n:n.items})},this.changed()}catch(n){this._msg={ok:!1,text:this.errorText(n)}}finally{this._busy=!1}}renderStore(){let e=this.packs??[],n=this._store;return m`<h4>${this.t("community_title")}</h4>
<p class="nf-sub">
${this.t("community_intro")} <a href=${yk} target="_blank" rel="noopener">${this.t("community_builder")}</a> ·
<a href=${`https://github.com/${ar}#community-furniture`} target="_blank" rel="noopener">${this.t("community_how")}</a>
<a href=${`https://github.com/${lr}#community-furniture`} target="_blank" rel="noopener">${this.t("community_how")}</a>
</p>
${n===null?m`<div><button class="nf-btn" @click=${()=>{this.loadStore()}}>${this.t("community_load")}</button></div>`:n==="loading"?m`<p class="nf-sub">${this.t("loading")}</p>`:n.length?m`<ul>
${n.map(r=>{let o=Vg(r,e);return m`<li>
@@ -4080,9 +4083,9 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</button>
</li>`})}
</ul>`:m`<p class="nf-sub">${this.t("community_none")}</p>`}
${this._storeError?m`<p class="nf-error" role="alert">${this._storeError}</p>`:_}`}t(e,n){return xe(this.hass,e,n)}changed(){this.dispatchEvent(new CustomEvent("packs-changed",{bubbles:!0,composed:!0}))}errorText(e){let{code:n,message:r}=e??{},o=r??String(e),i=`pack_error_${n}`,s=this.t(i,{detail:o});return s===i?this.t("pack_error_other",{detail:o}):s}async importTexts(e){if(!this.hass||!e.length)return 0;this._busy=!0;let n=[],r=[];for(let{label:i,text:s}of e)try{let l=await fr(this.hass,s);n.push(this.t("pack_imported",{name:l.name,publisher:l.publisher,n:l.items}))}catch(l){r.push(i?`${i}: ${this.errorText(l)}`:this.errorText(l))}this._busy=!1,n.length&&this.changed();let o=e.length>1?[this.t("packs_imported_n",{n:n.length,total:e.length})]:[];return this._msg={ok:r.length===0,text:[...o,...n,...r].join(" \xB7 ")},n.length}async importFiles(e){let n=e.target,r=[...n.files??[]];n.value="",await this.importTexts(await Promise.all(r.map(async o=>({label:o.name,text:await o.text()}))))}async importPasted(){let e=this.renderRoot.querySelector("textarea"),n=e?.value.trim()??"";if(!e||!n)return void(this._msg={ok:!1,text:this.t("pack_paste_empty")});try{JSON.parse(n)}catch(r){return void(this._msg={ok:!1,text:this.t("pack_paste_not_json",{detail:r instanceof Error?r.message:String(r)})})}await this.importTexts([{label:"",text:n}])>0&&(e.value="")}async deletePack(e){if(!(!this.hass||!confirm(this.t("pack_remove_confirm",{name:Oe(e,this.hass.language??"de")}))))try{await lc(this.hass,e.id),this._msg=null,this.changed()}catch(n){this._msg={ok:!1,text:this.errorText(n)}}}render(){let e=(this.packs??[]).filter(o=>!o.builtin),n=(this.packs??[]).length-e.length,r=this.hass?.language??"de";return m`<section class="nf-packs">
${this._storeError?m`<p class="nf-error" role="alert">${this._storeError}</p>`:_}`}t(e,n){return xe(this.hass,e,n)}changed(){this.dispatchEvent(new CustomEvent("packs-changed",{bubbles:!0,composed:!0}))}errorText(e){let{code:n,message:r}=e??{},o=r??String(e),i=`pack_error_${n}`,s=this.t(i,{detail:o});return s===i?this.t("pack_error_other",{detail:o}):s}async importTexts(e){if(!this.hass||!e.length)return 0;this._busy=!0;let n=[],r=[];for(let{label:i,text:s}of e)try{let l=await mr(this.hass,s);n.push(this.t("pack_imported",{name:l.name,publisher:l.publisher,n:l.items}))}catch(l){r.push(i?`${i}: ${this.errorText(l)}`:this.errorText(l))}this._busy=!1,n.length&&this.changed();let o=e.length>1?[this.t("packs_imported_n",{n:n.length,total:e.length})]:[];return this._msg={ok:r.length===0,text:[...o,...n,...r].join(" \xB7 ")},n.length}async importFiles(e){let n=e.target,r=[...n.files??[]];n.value="",await this.importTexts(await Promise.all(r.map(async o=>({label:o.name,text:await o.text()}))))}async importPasted(){let e=this.renderRoot.querySelector("textarea"),n=e?.value.trim()??"";if(!e||!n)return void(this._msg={ok:!1,text:this.t("pack_paste_empty")});try{JSON.parse(n)}catch(r){return void(this._msg={ok:!1,text:this.t("pack_paste_not_json",{detail:r instanceof Error?r.message:String(r)})})}await this.importTexts([{label:"",text:n}])>0&&(e.value="")}async deletePack(e){if(!(!this.hass||!confirm(this.t("pack_remove_confirm",{name:Oe(e,this.hass.language??"de")}))))try{await lc(this.hass,e.id),this._msg=null,this.changed()}catch(n){this._msg={ok:!1,text:this.errorText(n)}}}render(){let e=(this.packs??[]).filter(o=>!o.builtin),n=(this.packs??[]).length-e.length,r=this.hass?.language??"de";return m`<section class="nf-packs">
<h3>${this.t("packs_title")}</h3>
<p class="nf-sub">${this.t("packs_intro",{n})} <a href="${Wt}/blob/main/docs/packs.md" target="_blank" rel="noopener">${this.t("packs_docs")}</a></p>
<p class="nf-sub">${this.t("packs_intro",{n})} <a href="${Vt}/blob/main/docs/packs.md" target="_blank" rel="noopener">${this.t("packs_docs")}</a></p>
${e.length?m`<ul>
${e.map(o=>m`<li>
<div class="nf-pack-main">
@@ -4103,7 +4106,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</div>
${this._msg?m`<p class=${this._msg.ok?"nf-ok":"nf-error"} role=${this._msg.ok?"status":"alert"}>${this._msg.text}</p>`:_}
${this.hass?this.renderStore():_}
</section>`}static styles=[Me,ut,se`
</section>`}static styles=[Me,ht,se`
.nf-packs {
display: grid;
gap: 10px;
@@ -4174,9 +4177,9 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
color: inherit;
font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}
`]};customElements.get("nf-pack-manager")||customElements.define("nf-pack-manager",Il);var rD=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var wk=new Map;var Gg=()=>[...wk.values()];var Dl=class extends ne{static properties={hass:{attribute:!1},plugins:{attribute:!1},_error:{state:!0},_store:{state:!0},_storeError:{state:!0},_storeOpen:{state:!0}};stop=null;constructor(){super(),this._error="",this._storeError="",this._storeOpen=!1}connectedCallback(){super.connectedCallback(),this.stop=No(()=>this.requestUpdate())}disconnectedCallback(){super.disconnectedCallback(),this.stop?.()}t(e,n){return xe(this.hass,e,n)}emit(e){this.dispatchEvent(new CustomEvent("plugins-changed",{detail:e,bubbles:!0,composed:!0}))}add(e){let n=ys(e.value),r=this.plugins??[];if(!ws(n))return void(this._error=this.t("plugins_url_invalid"));if(r.some(o=>o.url===n))return void(this._error=this.t("plugins_exists"));if(r.length>=20)return void(this._error=this.t("plugins_limit"));this._error="",e.value="",this.emit([...r,{url:n,enabled:!0}])}async toggleStore(){if(this._storeOpen=!this._storeOpen,!(!this._storeOpen||this._store)){this._storeError="";try{this._store=await Cg()}catch(e){this._storeError=this.t("store_failed",{error:e instanceof Error?e.message:String(e)})}}}install(e){let n=this.plugins??[],r=n.some(o=>o.id===e.id);if(!r&&n.length>=20)return void(this._error=this.t("plugins_limit"));if(!r&&n.some(o=>o.url===e.url))return void(this._error=this.t("plugins_exists"));window.confirm(this.t("store_confirm",{name:e.name,author:e.author||"?",url:e.url}))&&(this._error="",this.emit(Bg(n,e)))}renderStore(){return m`<div class="nf-store">
`]};customElements.get("nf-pack-manager")||customElements.define("nf-pack-manager",Il);var iD=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);var wk=new Map;var Gg=()=>[...wk.values()];var Dl=class extends ne{static properties={hass:{attribute:!1},plugins:{attribute:!1},_error:{state:!0},_store:{state:!0},_storeError:{state:!0},_storeOpen:{state:!0}};stop=null;constructor(){super(),this._error="",this._storeError="",this._storeOpen=!1}connectedCallback(){super.connectedCallback(),this.stop=No(()=>this.requestUpdate())}disconnectedCallback(){super.disconnectedCallback(),this.stop?.()}t(e,n){return xe(this.hass,e,n)}emit(e){this.dispatchEvent(new CustomEvent("plugins-changed",{detail:e,bubbles:!0,composed:!0}))}add(e){let n=ys(e.value),r=this.plugins??[];if(!ws(n))return void(this._error=this.t("plugins_url_invalid"));if(r.some(o=>o.url===n))return void(this._error=this.t("plugins_exists"));if(r.length>=20)return void(this._error=this.t("plugins_limit"));this._error="",e.value="",this.emit([...r,{url:n,enabled:!0}])}async toggleStore(){if(this._storeOpen=!this._storeOpen,!(!this._storeOpen||this._store)){this._storeError="";try{this._store=await Cg()}catch(e){this._storeError=this.t("store_failed",{error:e instanceof Error?e.message:String(e)})}}}install(e){let n=this.plugins??[],r=n.some(o=>o.id===e.id);if(!r&&n.length>=20)return void(this._error=this.t("plugins_limit"));if(!r&&n.some(o=>o.url===e.url))return void(this._error=this.t("plugins_exists"));window.confirm(this.t("store_confirm",{name:e.name,author:e.author||"?",url:e.url}))&&(this._error="",this.emit(Bg(n,e)))}renderStore(){return m`<div class="nf-store">
<button class="nf-btn" @click=${()=>this.toggleStore()}>${this._storeOpen?this.t("store_close"):this.t("store_open")}</button>
${this._storeOpen?m`<p class="nf-sub">${this.t("store_intro")} <a href="https://github.com/${ar}" target="_blank" rel="noopener">${this.t("store_submit")}</a></p>
${this._storeOpen?m`<p class="nf-sub">${this.t("store_intro")} <a href="https://github.com/${lr}" target="_blank" rel="noopener">${this.t("store_submit")}</a></p>
${this._storeError?m`<p class="nf-error" role="alert">${this._storeError}</p>`:_}
${!this._store&&!this._storeError?m`<p class="nf-sub">${this.t("plugins_loading")}</p>`:_}
${this._store&&!this._store.length?m`<p class="nf-sub">${this.t("store_empty")}</p>`:_}
@@ -4192,7 +4195,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</ul>`:_}
</div>`}stateOf(e){let n=Gg().find(i=>i.url===e),r=ks().filter(i=>i.source===e),o=[...n?.error?[n.error]:[],...r.flatMap(i=>i.errors)];if(n?.state==="error")return{label:this.t("plugins_error"),tone:"err",detail:o.join(" \xB7 ")};if(n?.state==="loading")return{label:this.t("plugins_loading"),tone:"warn",detail:""};if(n?.state==="loaded"&&!r.length)return{label:this.t("plugins_nothing_registered"),tone:"warn",detail:""};if(r.length){let i=r.map(s=>`${s.name}${s.version?` ${s.version}`:""}`).join(", ");return{label:this.t("plugins_loaded"),tone:o.length?"warn":"ok",detail:o.length?`${i} \xB7 ${o.join(" \xB7 ")}`:i}}return{label:this.t("plugins_reload_hint"),tone:"warn",detail:""}}render(){let e=this.plugins??[],n=ks().filter(r=>!r.source);return m`<section class="nf-plugins">
<h3>${this.t("plugins_title")}</h3>
<p class="nf-sub">${this.t("plugins_intro")} <a href="${Wt}/blob/main/docs/plugins.md" target="_blank" rel="noopener">${this.t("plugins_docs")}</a></p>
<p class="nf-sub">${this.t("plugins_intro")} <a href="${Vt}/blob/main/docs/plugins.md" target="_blank" rel="noopener">${this.t("plugins_docs")}</a></p>
<p class="nf-warn">⚠️ ${this.t("plugins_warning")}</p>
${e.length?m`<ul>
${e.map((r,o)=>{let i=r.enabled?this.stateOf(r.url):{label:this.t("plugins_off"),tone:"warn",detail:""};return m`<li>
@@ -4216,7 +4219,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<button class="nf-btn" @click=${r=>this.add(r.target.previousElementSibling)}>${this.t("plugins_add")}</button>
</div>
${this._error?m`<p class="nf-error" role="alert">${this._error}</p>`:_}
</section>`}static styles=[Me,ut,se`
</section>`}static styles=[Me,ht,se`
.nf-plugins {
display: grid;
gap: 10px;
@@ -4299,15 +4302,15 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<h2>${this.t("ext_title")}</h2>
<p class="nf-sub">${this.t("ext_intro")}</p>
<div class="nf-ext-actions">
<a class="nf-btn" href="${Wt}/issues/new/choose" target="_blank" rel="noopener">🐞 ${this.t("help_issue")}</a>
<a class="nf-btn" href="${Wt}/discussions" target="_blank" rel="noopener">💡 ${this.t("help_idea")}</a>
<a class="nf-btn" href="${Wt}#readme" target="_blank" rel="noopener">📖 ${this.t("manual")}</a>
<a class="nf-btn" href="${Vt}/issues/new/choose" target="_blank" rel="noopener">🐞 ${this.t("help_issue")}</a>
<a class="nf-btn" href="${Vt}/discussions" target="_blank" rel="noopener">💡 ${this.t("help_idea")}</a>
<a class="nf-btn" href="${Vt}#readme" target="_blank" rel="noopener">📖 ${this.t("manual")}</a>
</div>
</header>
<nf-pack-manager .hass=${this.hass} .packs=${this.packs}></nf-pack-manager>
<nf-model-upload .hass=${this.hass} .packs=${this.packs}></nf-model-upload>
<nf-plugin-manager .hass=${this.hass} .plugins=${this.plugins}></nf-plugin-manager>
</div>`}static styles=[Me,ut,se`
</div>`}static styles=[Me,ht,se`
:host {
display: block;
overflow: auto;
@@ -4342,7 +4345,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
color: var(--nf-soft);
font-size: 13px;
}
`]};customElements.get("nf-extensions")||customElements.define("nf-extensions",Ol);var go="handled",jg=["select","rect","polygon","wall","opening","furniture","stairs","outdoor","hole","roof","energy"],Ug=new Set(["vertex","room","device","opening","furniture","rotate","resize","outdoor","roofmove","roofcorner","roofvertex","outvertex","solarmove","solarturn","bgmove","bgscale","bgrotate"]),Zi=10,He=t=>Math.round(t*1e3)/1e3,Zg={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},Hl=class extends ne{static properties={hass:{attribute:!1},building:{attribute:!1},narrow:{type:Boolean},packs:{attribute:!1},loadCardEditor:{attribute:!1},_doc:{state:!0},_doc3d:{state:!0},_split:{state:!0},_splitRatio:{state:!0},_wall3d:{state:!0},_solid3d:{state:!0},_sidePinned:{state:!0},_studio:{state:!0},_check:{state:!0},_keys:{state:!0},_note:{state:!0},_dims:{state:!0},_tour:{state:!0},_sideOpen:{state:!0},_floorId:{state:!0},_energyNote:{state:!0},_ctx:{state:!0},_fixedHint:{state:!0},_openingPreset:{state:!0},_measureLen:{state:!0},_rectSize:{state:!0},_tool:{state:!0},_wallView:{state:!0},_draft:{state:!0},_cursor:{state:!0},_guides:{state:!0},_view:{state:!0},_size:{state:!0},_canUndo:{state:!0},_canRedo:{state:!0},_arcEdit:{state:!0},_routeDraft:{state:!0}};doc3dTimer;tourChecked=!1;_pick=null;_pickTimer;fixedPan=!1;reframe3d=!1;pressTimer=0;pressStart=null;history=new Ni(100);lib=new Ei(()=>this.requestUpdate());side=new Ki(()=>this.requestUpdate());sel=new Vi(()=>this.requestUpdate());host=this.makeHost();backup=this.makeBackup();roof=this.makeRoof();bg=this.makeBackground();settingsActions={useRoofSections:()=>{this.roof.useSections(),this._tool="roof"}};drag=null;pointers=new Map;pinch=null;fitted=!1;resizeObserver;constructor(){super(),this.narrow=!1,this._floorId=null,this._arcEdit=null,this._routeDraft=null,this.roof.sectionId=null,this.roof.solarId=null,this.roof.picking=!1,this.roof.windowId=null,this.roof.chimneyId=null,this._energyNote=null,this._openingPreset="door";let e=!1;try{e=localStorage.getItem("nextfloor.editor3d")==="1"}catch{}this._split=e,this._splitRatio=.55;try{let r=Number(localStorage.getItem("nextfloor.editorSplit"));r>=20&&r<=80&&(this._splitRatio=r/100)}catch{}this._wall3d="cut",this._solid3d=!1,this._doc3d=this._doc,this._sideOpen=!1;let n=!0;try{n=localStorage.getItem("nextfloor.sidePinned")!=="0"}catch{}this._sidePinned=n,this._studio=null,this._check=!1,this._keys=!1,this._note=null,this._dims=(()=>{try{return localStorage.getItem("nextfloor.plan_dims")==="1"}catch{return!1}})(),this._tour=null,this._measureLen=3,this._rectSize=[4,3],this._tool="select",this._wallView=null,this._draft=[],this._cursor=null,this._guides={},this._view={scale:50,ox:40,oy:40},this._size={w:800,h:600},this._canUndo=!1,this._canRedo=!1}t(e,n){return xe(this.hass,e,n)}measureState(){return{draft:this._draft,length:this._measureLen,rectSize:this._rectSize}}measureActions(){return{setLength:e=>this._measureLen=e,step:e=>this.measureStep(e),close:()=>this.closeDraft(),undo:()=>this._draft=this._draft.slice(0,-1),setRectSize:e=>this._rectSize=e,addRectangle:()=>this.rectBySize()}}arcActions(){return{edit:this._arcEdit,setEdit:e=>this._arcEdit=e,apply:e=>{if(!this.isAdmin||Math.abs(e.bulge)<.01)return;let n=this._doc,r=structuredClone(n),o=r.floors.find(c=>c.id===this._floorId);if(!o)return;let[i,s,l]=e.key.split(":");if(!(i==="wall"?yf(o,s,e.bulge).length>0:bf(o,s,Number(l),e.bulge))){this._arcEdit={...e,error:this.t("arc_too_wide")};return}this._arcEdit=null,this.setDoc(r,n)}}}freeWallActions(){return{update:e=>this.updateFreeWall(e),remove:()=>this.deleteFreeWall(),arc:this.arcActions(),lockButton:this.fixButton("wall",this.sel.wall??"")}}outdoorActions(){return{update:e=>this.updateOutdoor(e),setRectangle:(e,n)=>{let r=this.outdoorArea;r&&this.updateOutdoor({points:wp(r,e,n)})},duplicate:()=>this.duplicateOutdoor(),remove:()=>this.deleteOutdoor(),removeCorner:e=>{let n=this.sel.outdoor;n&&this.change((r,o)=>{cp(o.outdoor.find(i=>i.id===n),e)})},lockButton:this.fixButton("outdoor",this.sel.outdoor??"")}}libraryActions(){return{add:e=>this.addFurniture(e),studio:()=>this.openStudio(null),packs:this.packs??[]}}openStudio(e){let n=e?G(e):void 0,r=n?.recipe&&e?.startsWith(`pack:${gn}:`)?n.id:null;this._studio={recipe:r&&n?.recipe?{...n.recipe}:Al("cabinet",""),itemId:r,busy:!1,error:null},this._tool="furniture"}async saveStudio(){let e=this._studio;if(!e||!this.hass||!this.isAdmin)return;let n=this.hass.language??"en",r=gr().find(d=>d.id===gn),o=r?.items??[],i={...e.recipe,name:e.recipe.name||this.t(`studio_kind_${e.recipe.kind}`)},s=e.itemId??fg(i.name,o.map(d=>d.id)),l=ji(i,s,n),a={id:gn,name:r?.name??this.t("studio_pack_name"),publisher:r?.publisher??this.t("studio_pack_publisher"),release:(r?.release??0)+1,items:e.itemId?o.map(d=>d.id===s?l:d):[...o,l]};this._studio={...e,busy:!0,error:null};try{let{builtin:d,imported_at:u,...p}=a;await fr(this.hass,JSON.stringify({format:"nfpack",version:1,.. Line truncated
`]};customElements.get("nf-extensions")||customElements.define("nf-extensions",Ol);var go="handled",jg=["select","rect","polygon","wall","opening","furniture","stairs","outdoor","hole","roof","energy"],Ug=new Set(["vertex","room","device","opening","furniture","rotate","resize","outdoor","roofmove","roofcorner","roofvertex","outvertex","solarmove","solarturn","bgmove","bgscale","bgrotate"]),Zi=10,He=t=>Math.round(t*1e3)/1e3,Zg={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},Hl=class extends ne{static properties={hass:{attribute:!1},building:{attribute:!1},narrow:{type:Boolean},packs:{attribute:!1},loadCardEditor:{attribute:!1},_doc:{state:!0},_doc3d:{state:!0},_split:{state:!0},_splitRatio:{state:!0},_wall3d:{state:!0},_solid3d:{state:!0},_sidePinned:{state:!0},_studio:{state:!0},_check:{state:!0},_keys:{state:!0},_note:{state:!0},_dims:{state:!0},_tour:{state:!0},_sideOpen:{state:!0},_floorId:{state:!0},_energyNote:{state:!0},_ctx:{state:!0},_fixedHint:{state:!0},_openingPreset:{state:!0},_measureLen:{state:!0},_rectSize:{state:!0},_tool:{state:!0},_wallView:{state:!0},_draft:{state:!0},_cursor:{state:!0},_guides:{state:!0},_view:{state:!0},_size:{state:!0},_canUndo:{state:!0},_canRedo:{state:!0},_arcEdit:{state:!0},_routeDraft:{state:!0}};doc3dTimer;tourChecked=!1;_pick=null;_pickTimer;fixedPan=!1;reframe3d=!1;pressTimer=0;pressStart=null;history=new Ni(100);lib=new Ei(()=>this.requestUpdate());side=new Ki(()=>this.requestUpdate());sel=new Vi(()=>this.requestUpdate());host=this.makeHost();backup=this.makeBackup();roof=this.makeRoof();bg=this.makeBackground();settingsActions={useRoofSections:()=>{this.roof.useSections(),this._tool="roof"}};drag=null;pointers=new Map;pinch=null;fitted=!1;resizeObserver;constructor(){super(),this.narrow=!1,this._floorId=null,this._arcEdit=null,this._routeDraft=null,this.roof.sectionId=null,this.roof.solarId=null,this.roof.picking=!1,this.roof.windowId=null,this.roof.chimneyId=null,this._energyNote=null,this._openingPreset="door";let e=!1;try{e=localStorage.getItem("nextfloor.editor3d")==="1"}catch{}this._split=e,this._splitRatio=.55;try{let r=Number(localStorage.getItem("nextfloor.editorSplit"));r>=20&&r<=80&&(this._splitRatio=r/100)}catch{}this._wall3d="cut",this._solid3d=!1,this._doc3d=this._doc,this._sideOpen=!1;let n=!0;try{n=localStorage.getItem("nextfloor.sidePinned")!=="0"}catch{}this._sidePinned=n,this._studio=null,this._check=!1,this._keys=!1,this._note=null,this._dims=(()=>{try{return localStorage.getItem("nextfloor.plan_dims")==="1"}catch{return!1}})(),this._tour=null,this._measureLen=3,this._rectSize=[4,3],this._tool="select",this._wallView=null,this._draft=[],this._cursor=null,this._guides={},this._view={scale:50,ox:40,oy:40},this._size={w:800,h:600},this._canUndo=!1,this._canRedo=!1}t(e,n){return xe(this.hass,e,n)}measureState(){return{draft:this._draft,length:this._measureLen,rectSize:this._rectSize}}measureActions(){return{setLength:e=>this._measureLen=e,step:e=>this.measureStep(e),close:()=>this.closeDraft(),undo:()=>this._draft=this._draft.slice(0,-1),setRectSize:e=>this._rectSize=e,addRectangle:()=>this.rectBySize()}}arcActions(){return{edit:this._arcEdit,setEdit:e=>this._arcEdit=e,apply:e=>{if(!this.isAdmin||Math.abs(e.bulge)<.01)return;let n=this._doc,r=structuredClone(n),o=r.floors.find(c=>c.id===this._floorId);if(!o)return;let[i,s,l]=e.key.split(":");if(!(i==="wall"?yf(o,s,e.bulge).length>0:bf(o,s,Number(l),e.bulge))){this._arcEdit={...e,error:this.t("arc_too_wide")};return}this._arcEdit=null,this.setDoc(r,n)}}}freeWallActions(){return{update:e=>this.updateFreeWall(e),remove:()=>this.deleteFreeWall(),arc:this.arcActions(),lockButton:this.fixButton("wall",this.sel.wall??"")}}outdoorActions(){return{update:e=>this.updateOutdoor(e),setRectangle:(e,n)=>{let r=this.outdoorArea;r&&this.updateOutdoor({points:wp(r,e,n)})},duplicate:()=>this.duplicateOutdoor(),remove:()=>this.deleteOutdoor(),removeCorner:e=>{let n=this.sel.outdoor;n&&this.change((r,o)=>{cp(o.outdoor.find(i=>i.id===n),e)})},lockButton:this.fixButton("outdoor",this.sel.outdoor??"")}}libraryActions(){return{add:e=>this.addFurniture(e),studio:()=>this.openStudio(null),packs:this.packs??[]}}openStudio(e){let n=e?G(e):void 0,r=n?.recipe&&e?.startsWith(`pack:${_n}:`)?n.id:null;this._studio={recipe:r&&n?.recipe?{...n.recipe}:Al("cabinet",""),itemId:r,busy:!1,error:null},this._tool="furniture"}async saveStudio(){let e=this._studio;if(!e||!this.hass||!this.isAdmin)return;let n=this.hass.language??"en",r=_r().find(d=>d.id===_n),o=r?.items??[],i={...e.recipe,name:e.recipe.name||this.t(`studio_kind_${e.recipe.kind}`)},s=e.itemId??fg(i.name,o.map(d=>d.id)),l=ji(i,s,n),a={id:_n,name:r?.name??this.t("studio_pack_name"),publisher:r?.publisher??this.t("studio_pack_publisher"),release:(r?.release??0)+1,items:e.itemId?o.map(d=>d.id===s?l:d):[...o,l]};this._studio={...e,busy:!0,error:null};try{let{builtin:d,imported_at:u,...p}=a;await mr(this.hass,JSON.stringify({format:"nfpack",version:1,.. Line truncated
>${s}
<input
type="number"
@@ -4370,7 +4373,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<button class="nf-chip" @click=${()=>this.rotateFurniture(45)}>↻ 45°</button>
${this.fixButton("furniture",e.id)}
<button class="nf-chip nf-danger-chip" @click=${()=>this.deleteFurniture()}>${this.t("delete")}</button>
</div>`}if(n){let r=X(n.entity_id),o=r==="light",i=r?Eo(r,this.floor?lt(this.floor,n.x,n.z):2.5,o?n.mount??"ceiling":null):1;return m`<div class="nf-3d-bar">
</div>`}if(n){let r=X(n.entity_id),o=r==="light",i=r?Eo(r,this.floor?ct(this.floor,n.x,n.z):2.5,o?n.mount??"ceiling":null):1;return m`<div class="nf-3d-bar">
<span>${W(this.hass,n.entity_id)}</span>
${o?m`<select class="nf-3d-select" title=${this.t("lamp_mount")} @change=${s=>this.updateDevice({mount:s.target.value,y:null})}>
${["ceiling","floor","table","wall"].map(s=>m`<option value=${s} ?selected=${s===(n.mount??"ceiling")}>${this.t(`lamp_${s}`)}</option>`)}
@@ -4390,7 +4393,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<button class="nf-chip" @click=${()=>this.updateDevice({rotation:((n.rotation??0)+45)%360%360})}>↻ 45°</button>
${this.fixButton("device",n.entity_id)}
<button class="nf-chip nf-danger-chip" @click=${()=>this.deleteItem("device",n.entity_id)}>${this.t("delete")}</button>
</div>`}return _}grab3d=null;surfaceGrabber={start:e=>this.grab3dStart(e),move:e=>this.grab3dMove(e),end:()=>{let e=this.grab3d;this.grab3d=null,e?.moved&&this.pushHistory(e.base)}};fittingField(e,n,r){if(r==="field")return e.settings.roof.solar?.find(i=>i.id===n);if(r==="win"){let i=e.settings.roof.windows?.find(s=>s.id===n);return i?nn(i):void 0}let o=e.settings.roof.chimneys?.find(i=>i.id===n);return o?yt(o,U(e).find(i=>i.key===o.face)):void 0}grab3dStart(e){let n=this._doc,r=U(n),o=null,i=(l,a,c,d,u=!1,p=!1)=>{if(!c||u)return;let h=ni(c,e.o,e.d);!h||!Qs(c,d,h.u,h.s)||o&&o.t<=h.t||(o={id:l,win:a,chimney:p,t:h.t,du:h.u-d.u,ds:h.s-d.v})};if(this._tool==="energy")for(let l of n.settings.roof.solar??[])i(l.id,!1,ke(n,l,r),l,!!l.locked);if(this._tool==="roof")for(let l of n.settings.roof.windows??[])i(l.id,!0,r.find(a=>a.key===l.face)??null,nn(l),!!l.locked);if(this._tool==="roof")for(let l of n.settings.roof.chimneys??[]){let a=r.find(c=>c.key===l.face)??null;i(l.id,!1,a,yt(l,a),!!l.locked,!0)}if(!o)return!1;let s=o;return this.grab3d={id:s.id,win:s.win,chimney:s.chimney,du:s.du,ds:s.ds,base:n,moved:!1},s.chimney?this.roof.chimneyId=s.id:s.win?this.roof.windowId=s.id:this.roof.selectField(s.id),!0}grab3dMove(e){let n=this.grab3d;if(!n)return;let r=n.base,o=this.fittingField(r,n.id,n.win?"win":n.chimney?"chimney":"field");if(!o)return;let i=ke(r,o),s=i?.unbounded?[i]:n.win||n.chimney?U(r):[...U(r),...Ke(r)],l=null;for(let p of s){let h=ni(p,e.o,e.d);h&&Xs(p,h.u,h.s)&&(!l||h.t<l.t)&&(l={face:p,...h})}if(!l)return;let a=l.face,c=.05,d=p=>He(Math.round(p/c)*c),u=dt(a,{...o,face:a.key,u:d(l.u-n.du),v:d(l.s-n.ds),tilt:a.flat?o.tilt??15:o.tilt});n.moved=!0,this.change(p=>{if(n.win||n.chimney){let f=n.win?p.settings.roof.windows?.find(g=>g.id===n.id):p.settings.roof.chimneys?.find(g=>g.id===n.id);f&&Object.assign(f,{face:a.key,...u});return}let h=p.settings.roof.solar?.find(f=>f.id===n.id);h&&Object.assign(h,{face:a.key,...u},a.flat&&h.tilt==null?{tilt:15}:{})},n.base,!1)}get houseTool(){return this._tool==="roof"||this._tool==="energy"}render3d(){return m`<div class="nf-editor-3d">
</div>`}return _}grab3d=null;surfaceGrabber={start:e=>this.grab3dStart(e),move:e=>this.grab3dMove(e),end:()=>{let e=this.grab3d;this.grab3d=null,e?.moved&&this.pushHistory(e.base)}};fittingField(e,n,r){if(r==="field")return e.settings.roof.solar?.find(i=>i.id===n);if(r==="win"){let i=e.settings.roof.windows?.find(s=>s.id===n);return i?rn(i):void 0}let o=e.settings.roof.chimneys?.find(i=>i.id===n);return o?wt(o,U(e).find(i=>i.key===o.face)):void 0}grab3dStart(e){let n=this._doc,r=U(n),o=null,i=(l,a,c,d,u=!1,p=!1)=>{if(!c||u)return;let h=ni(c,e.o,e.d);!h||!Qs(c,d,h.u,h.s)||o&&o.t<=h.t||(o={id:l,win:a,chimney:p,t:h.t,du:h.u-d.u,ds:h.s-d.v})};if(this._tool==="energy")for(let l of n.settings.roof.solar??[])i(l.id,!1,ke(n,l,r),l,!!l.locked);if(this._tool==="roof")for(let l of n.settings.roof.windows??[])i(l.id,!0,r.find(a=>a.key===l.face)??null,rn(l),!!l.locked);if(this._tool==="roof")for(let l of n.settings.roof.chimneys??[]){let a=r.find(c=>c.key===l.face)??null;i(l.id,!1,a,wt(l,a),!!l.locked,!0)}if(!o)return!1;let s=o;return this.grab3d={id:s.id,win:s.win,chimney:s.chimney,du:s.du,ds:s.ds,base:n,moved:!1},s.chimney?this.roof.chimneyId=s.id:s.win?this.roof.windowId=s.id:this.roof.selectField(s.id),!0}grab3dMove(e){let n=this.grab3d;if(!n)return;let r=n.base,o=this.fittingField(r,n.id,n.win?"win":n.chimney?"chimney":"field");if(!o)return;let i=ke(r,o),s=i?.unbounded?[i]:n.win||n.chimney?U(r):[...U(r),...Ke(r)],l=null;for(let p of s){let h=ni(p,e.o,e.d);h&&Xs(p,h.u,h.s)&&(!l||h.t<l.t)&&(l={face:p,...h})}if(!l)return;let a=l.face,c=.05,d=p=>He(Math.round(p/c)*c),u=ut(a,{...o,face:a.key,u:d(l.u-n.du),v:d(l.s-n.ds),tilt:a.flat?o.tilt??15:o.tilt});n.moved=!0,this.change(p=>{if(n.win||n.chimney){let f=n.win?p.settings.roof.windows?.find(g=>g.id===n.id):p.settings.roof.chimneys?.find(g=>g.id===n.id);f&&Object.assign(f,{face:a.key,...u});return}let h=p.settings.roof.solar?.find(f=>f.id===n.id);h&&Object.assign(h,{face:a.key,...u},a.flat&&h.tilt==null?{tilt:15}:{})},n.base,!1)}get houseTool(){return this._tool==="roof"||this._tool==="energy"}render3d(){return m`<div class="nf-editor-3d">
${this.houseTool?_:m`<div class="nf-seg nf-3d-walls">
<button aria-pressed=${this._wall3d==="auto"} @click=${()=>this._wall3d="auto"}>${this.t("walls_auto")}</button>
<button aria-pressed=${this._wall3d==="cut"} @click=${()=>this._wall3d="cut"}>${this.t("walls_cut")}</button>
@@ -4433,7 +4436,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
@floor-tap=${e=>{e.detail.floorId&&(this._floorId=e.detail.floorId),this._sideOpen=!1}}
@room-tap=${e=>{e.detail.floorId&&(this._floorId=e.detail.floorId),e.detail.roomId?this.selectFrom3d("room",e.detail.roomId):this._sideOpen=!1}}
></nf-view3d>
</div>`}updated(){for(let n of this.renderRoot.querySelectorAll("select option[selected]"))n.selected||(n.selected=!0);this.reframe3d&&(this.reframe3d=!1,setTimeout(()=>this.renderRoot.querySelector("nf-view3d")?.resetView(),250));let e=this.floor?.background;if(e&&this.bg.ensureLoaded(e.image_id),this.furnitureItem?.pictures)for(let n of this.storedPictures())this.bg.ensureLoaded(n)}get floor(){return this._doc?.floors.find(e=>e.id===this._floorId)}get room(){return this.floor?.rooms.find(e=>e.id===this.sel.room)}get isAdmin(){return this.hass?.user?.is_admin??!0}setDoc(e,n=this._doc){n&&this.history.record(n),this._doc=e,this.syncHistoryButtons(),this.dispatchEvent(new CustomEvent("building-changed",{detail:{building:e},bubbles:!0,composed:!0}))}change(e,n=this._doc,r=!0){let o=structuredClone(n),i=o.floors.find(s=>s.id===this._floorId);!i&&this._floorId||(e(o,i),this.setDoc(o,r?n:null))}syncHistoryButtons(){this._canUndo=this.history.canUndo,this._canRedo=this.history.canRedo}undo(){let e=this.history.undo(this._doc);e&&this.restore(e)}redo(){let e=this.history.redo(this._doc);e&&this.restore(e)}restore(e){this._doc=e,e.floors.some(n=>n.id===this._floorId)||(this._floorId=e.floors[0]?.id??null),this.floor?.rooms.some(n=>n.id===this.sel.room)||(this.sel.room=null),this.sel.corner=null,this.syncHistoryButtons(),this.dispatchEvent(new CustomEvent("building-changed",{detail:{building:e},bubbles:!0,composed:!0}))}toScreen(e){let{scale:n,ox:r,oy:o}=this._view;return[e[0]*n+r,e[1]*n+o]}pickPoint(e){this._pick?.(null),this._pick=e,clearTimeout(this._pickTimer),this._pickTimer=window.setTimeout(()=>this.cancelPick(),6e4),this.requestUpdate()}cancelPick(){clearTimeout(this._pickTimer),this._pick&&(this._pick=null,this.requestUpdate())}toWorld(e,n){let{scale:r,ox:o,oy:i}=this._view;return[(e-o)/r,(n-i)/r]}localPoint(e){let n=this.renderRoot.querySelector("svg").getBoundingClientRect();return[e.clientX-n.left,e.clientY-n.top]}fit(){let e=this.floor?.rooms.flatMap(l=>l.points)??[],n=e.length?de(e):{x0:0,z0:0,x1:10,z1:8},r=1.5,o=n.x1-n.x0+2*r,i=n.z1-n.z0+2*r,s=Math.max(8,Math.min(400,Math.min(this._size.w/o,this._size.h/i)));this._view={scale:s,ox:this._size.w/2-(n.x0+n.x1)/2*s,oy:this._size.h/2-(n.z0+n.z1)/2*s}}showPoint(e,n){let r=Math.max(this._view.scale,70);this._view={scale:r,ox:this._size.w/2-e*r,oy:this._size.h/2-n*r}}zoomAt(e,n,r){let{scale:o,ox:i,oy:s}=this._view,l=Math.max(8,Math.min(600,o*e)),a=l/o;this._view={scale:l,ox:n-(n-i)*a,oy:r-(r-s)*a}}snap(e,n,r=!1){if(this._guides={},r)return e;let o=$f(e,{rooms:this.floor?.rooms??[],grid:this._doc.settings.grid,reach:Zi/this._view.scale,skip:n});return this._guides=o.guides,o.point}onPointerDown(e){if(this._pick){let[r,o]=this.localPoint(e),i=this._pick;this.cancelPick(),i(this.toWorld(r,o));return}this._ctx=null;let n=e.target?.closest?.("[data-note]")?.getAttribute("data-note");if(n&&this._tool==="select"){this._note=n,this._sideOpen=!0;return}if(this._note&&(this._note=null),this._fixedHint=!1,this.fixedPan=!1,this.pointerDown(e),this.pointers.size!==1){clearTimeout(this.pressTimer);return}if(this.guardFixed(this.localPoint(e)),clearTimeout(this.pressTimer),this.pressStart=null,e.pointerType==="touch"&&(this._tool==="select"||this._tool==="furniture")){let r=this.localPoint(e),o=e.target;this.pressStart=r,this.pressTimer=window.setTimeout(()=>{let i=this.drag;i&&"moved"in i&&i.moved||(this.drag=null,this.openContext(o,r))},550)}}guardFixed(e){let n=this.drag;if(!n)return;let r=null;n.kind==="vertex"||n.kind==="room"?r=["room",n.roomId]:n.kind==="device"||n.kind==="aim"?r=["device",n.entityId]:n.kind==="opening"?r=["opening",n.id]:n.kind==="furniture"||n.kind==="rotate"||n.kind==="resize"?r=["furniture",n.id]:n.kind==="wallmove"?r=["wall",n.id]:n.kind==="outdoor"&&(r=["outdoor",n.id]),!(!r||!this.isFixedItem(...r))&&("moved"in n&&n.moved&&"base"in n&&this.restoreLive(n.base),this.drag={kind:"pan",last:e},this.fixedPan=!0)}pointerDown(e){e.currentTarget.setPointerCapture(e.pointerId);let n=this.localPoint(e);if(this.pointers.set(e.pointerId,n),this.pointers.size===2){let i=this.drag;i&&Ug.has(i.kind)&&"moved"in i&&i.moved&&"base"in i&&this.restoreLive(i.base),this.drag=null,this.pinch=this.pinchState();return}if(this.pointers.size>2)return;if(e.button===1||e.button===2||!this.floor){this.drag={kind:"pan",last:n};return}let r={local:n,world:this.toWorld(...n),target:e.target,fine:e.altKey},o=this.pressRoute(r)??this.pressBackground(r)??this.pressWallTool(r)??this.pressRoofTools(r)??this.pressDrawingTool(r)??this.pressItem(r)??this.pressRoom(r);o!==go&&(this.drag=o)}pan(e){return{kind:"pan",last:e.local}}moves(e,n){return this.isAdmin?n:this.pan(e)}pressBackground(e){let{world:n,target:r}=e,o=this.floor?.background;if(this.bg.level&&this.isAdmin&&o)return this.bg.tapLevel(n),go;if(this.bg.handlesShown&&o&&r.closest("[data-bg-rotate]")){let s=Kn(o,this.bg.picture(o.image_id)?.aspect??1);return{kind:"bgrotate",base:this._doc,moved:!1,start:Math.atan2(n[1]-s[1Line truncated
</div>`}updated(){for(let n of this.renderRoot.querySelectorAll("select option[selected]"))n.selected||(n.selected=!0);this.reframe3d&&(this.reframe3d=!1,setTimeout(()=>this.renderRoot.querySelector("nf-view3d")?.resetView(),250));let e=this.floor?.background;if(e&&this.bg.ensureLoaded(e.image_id),this.furnitureItem?.pictures)for(let n of this.storedPictures())this.bg.ensureLoaded(n)}get floor(){return this._doc?.floors.find(e=>e.id===this._floorId)}get room(){return this.floor?.rooms.find(e=>e.id===this.sel.room)}get isAdmin(){return this.hass?.user?.is_admin??!0}setDoc(e,n=this._doc){n&&this.history.record(n),this._doc=e,this.syncHistoryButtons(),this.dispatchEvent(new CustomEvent("building-changed",{detail:{building:e},bubbles:!0,composed:!0}))}change(e,n=this._doc,r=!0){let o=structuredClone(n),i=o.floors.find(s=>s.id===this._floorId);!i&&this._floorId||(e(o,i),this.setDoc(o,r?n:null))}syncHistoryButtons(){this._canUndo=this.history.canUndo,this._canRedo=this.history.canRedo}undo(){let e=this.history.undo(this._doc);e&&this.restore(e)}redo(){let e=this.history.redo(this._doc);e&&this.restore(e)}restore(e){this._doc=e,e.floors.some(n=>n.id===this._floorId)||(this._floorId=e.floors[0]?.id??null),this.floor?.rooms.some(n=>n.id===this.sel.room)||(this.sel.room=null),this.sel.corner=null,this.syncHistoryButtons(),this.dispatchEvent(new CustomEvent("building-changed",{detail:{building:e},bubbles:!0,composed:!0}))}toScreen(e){let{scale:n,ox:r,oy:o}=this._view;return[e[0]*n+r,e[1]*n+o]}pickPoint(e){this._pick?.(null),this._pick=e,clearTimeout(this._pickTimer),this._pickTimer=window.setTimeout(()=>this.cancelPick(),6e4),this.requestUpdate()}cancelPick(){clearTimeout(this._pickTimer),this._pick&&(this._pick=null,this.requestUpdate())}toWorld(e,n){let{scale:r,ox:o,oy:i}=this._view;return[(e-o)/r,(n-i)/r]}localPoint(e){let n=this.renderRoot.querySelector("svg").getBoundingClientRect();return[e.clientX-n.left,e.clientY-n.top]}fit(){let e=this.floor?.rooms.flatMap(l=>l.points)??[],n=e.length?de(e):{x0:0,z0:0,x1:10,z1:8},r=1.5,o=n.x1-n.x0+2*r,i=n.z1-n.z0+2*r,s=Math.max(8,Math.min(400,Math.min(this._size.w/o,this._size.h/i)));this._view={scale:s,ox:this._size.w/2-(n.x0+n.x1)/2*s,oy:this._size.h/2-(n.z0+n.z1)/2*s}}showPoint(e,n){let r=Math.max(this._view.scale,70);this._view={scale:r,ox:this._size.w/2-e*r,oy:this._size.h/2-n*r}}zoomAt(e,n,r){let{scale:o,ox:i,oy:s}=this._view,l=Math.max(8,Math.min(600,o*e)),a=l/o;this._view={scale:l,ox:n-(n-i)*a,oy:r-(r-s)*a}}snap(e,n,r=!1){if(this._guides={},r)return e;let o=$f(e,{rooms:this.floor?.rooms??[],grid:this._doc.settings.grid,reach:Zi/this._view.scale,skip:n});return this._guides=o.guides,o.point}onPointerDown(e){if(this._pick){let[r,o]=this.localPoint(e),i=this._pick;this.cancelPick(),i(this.toWorld(r,o));return}this._ctx=null;let n=e.target?.closest?.("[data-note]")?.getAttribute("data-note");if(n&&this._tool==="select"){this._note=n,this._sideOpen=!0;return}if(this._note&&(this._note=null),this._fixedHint=!1,this.fixedPan=!1,this.pointerDown(e),this.pointers.size!==1){clearTimeout(this.pressTimer);return}if(this.guardFixed(this.localPoint(e)),clearTimeout(this.pressTimer),this.pressStart=null,e.pointerType==="touch"&&(this._tool==="select"||this._tool==="furniture")){let r=this.localPoint(e),o=e.target;this.pressStart=r,this.pressTimer=window.setTimeout(()=>{let i=this.drag;i&&"moved"in i&&i.moved||(this.drag=null,this.openContext(o,r))},550)}}guardFixed(e){let n=this.drag;if(!n)return;let r=null;n.kind==="vertex"||n.kind==="room"?r=["room",n.roomId]:n.kind==="device"||n.kind==="aim"?r=["device",n.entityId]:n.kind==="opening"?r=["opening",n.id]:n.kind==="furniture"||n.kind==="rotate"||n.kind==="resize"?r=["furniture",n.id]:n.kind==="wallmove"?r=["wall",n.id]:n.kind==="outdoor"&&(r=["outdoor",n.id]),!(!r||!this.isFixedItem(...r))&&("moved"in n&&n.moved&&"base"in n&&this.restoreLive(n.base),this.drag={kind:"pan",last:e},this.fixedPan=!0)}pointerDown(e){e.currentTarget.setPointerCapture(e.pointerId);let n=this.localPoint(e);if(this.pointers.set(e.pointerId,n),this.pointers.size===2){let i=this.drag;i&&Ug.has(i.kind)&&"moved"in i&&i.moved&&"base"in i&&this.restoreLive(i.base),this.drag=null,this.pinch=this.pinchState();return}if(this.pointers.size>2)return;if(e.button===1||e.button===2||!this.floor){this.drag={kind:"pan",last:n};return}let r={local:n,world:this.toWorld(...n),target:e.target,fine:e.altKey},o=this.pressRoute(r)??this.pressBackground(r)??this.pressWallTool(r)??this.pressRoofTools(r)??this.pressDrawingTool(r)??this.pressItem(r)??this.pressRoom(r);o!==go&&(this.drag=o)}pan(e){return{kind:"pan",last:e.local}}moves(e,n){return this.isAdmin?n:this.pan(e)}pressBackground(e){let{world:n,target:r}=e,o=this.floor?.background;if(this.bg.level&&this.isAdmin&&o)return this.bg.tapLevel(n),go;if(this.bg.handlesShown&&o&&r.closest("[data-bg-rotate]")){let s=Gn(o,this.bg.picture(o.image_id)?.aspect??1);return{kind:"bgrotate",base:this._doc,moved:!1,start:Math.atan2(n[1]-s[1Line truncated
${e?R`${Lf(r,e,this.sel.outdoor)} ${Nf(r,e,this.sel.room,this.sel.edge)} ${zf(r,e,this.sel.furniture)}
${Wf(r,e,this.sel.wall)} ${n?Uf(r,e,n,this.sel.opening):_} ${Bf(r,e)}
${this._tool==="select"?Pf(r,e,this.sel.device):_}
@@ -4444,7 +4447,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${o&&this._tool==="select"?Vf(r,o):_}
${Ph(r,e)}`:_}
${this._tool==="roof"?R`${ka(r,this.roof)}${Th(r,this.roof)}${Dh(r,this.roof)}`:this._tool==="energy"?R`${ka(r,this.roof)}${Fh(r,this.roof)}${Ih(r,this.floor,this._doc.energy.routes??[],this._routeDraft)}${zh(r,this.floor,this.sel.furniture)}`:_}
${Mf(r,s,this._tool,this._draft,this._cursor)} ${Sf(r,this._guides,this._size)}`}wallsOfFloor(){let e=this.floor,{wall_exterior:n,wall_interior:r}=this._doc.settings;return e?pe(e.rooms,{exterior:n,interior:r},e.walls??[]).walls:[]}edgeParts(e,n){let r=this.wallsOfFloor().flatMap(o=>o.sources.filter(i=>i.room_id===e.id&&i.edge===n).map(i=>i.t0));return r.length>0?[...new Set(r)].sort((o,i)=>o-i):[0]}changeRoom(e,n){this.isAdmin&&this.change((r,o)=>{let i=o.rooms.find(s=>s.id===e.id);i&&n(i)})}edgeActions(){return{openWall:(e,n)=>this._wallView={roomId:e.id,edge:n},partsOf:(e,n)=>this.edgeParts(e,n),isOuter:(e,n)=>this.wallsOfFloor().some(r=>r.exterior&&r.sources.some(o=>o.room_id===e.id&&o.edge===n)),setHeight:(e,n,r,o)=>{if(r!==void 0){let s=this.edgeParts(e,n).length;this.changeRoom(e,l=>Qf(l,n,r,o,s));return}let i=this.wallsOfFloor().filter(s=>s.sources.some(l=>l.room_id===e.id&&l.edge===n)).flatMap(s=>s.sources);i.some(s=>s.room_id===e.id&&s.edge===n)||i.push({room_id:e.id,edge:n,t0:0,t1:0}),this.isAdmin&&this.change((s,l)=>{for(let a of i){let c=l.rooms.find(d=>d.id===a.room_id);c&&cl(c,a.edge,o)}})},setSlope:(e,n,r,o)=>this.changeRoom(e,i=>Yf(i,n,r,o)),clearSlope:(e,n)=>this.changeRoom(e,r=>Xf(r,n,this.floor?.height??2.5)),setThickness:(e,n,r,o,i)=>this.changeRoom(e,s=>nm(s,n,r,o,i)),arc:this.arcActions(),cut:(e,n,r)=>{let o=this.edgeParts(e,n);this.changeRoom(e,i=>Jf(i,n,r,o))},moveCut:(e,n,r,o)=>{let i=this.edgeParts(e,n);this.changeRoom(e,s=>em(s,n,r,o,i))},join:(e,n,r,o)=>this.changeRoom(e,i=>tm(i,n,r,o)),lit:this.sel.edge,light:e=>this.sel.edge=e}}addFloor(e=null){let n=Xm(this._doc,e,{first:this.t("default_floor"),next:o=>this.t("new_floor",{n:o})}),r=structuredClone(this._doc);r.floors=Ml(r.floors,n),this.setDoc(r),this._floorId=n.id,this.sel.room=null,this.side.floorMenu=!1,this.fit()}addAreaRooms(e){let n=tr(this._doc,e,this.hass?.areas);if(n.length===0)return;let r=Zc(e,n,()=>D("room"));this.change((o,i)=>i.rooms.push(...r)),this.fit()}duplicateFloor(e){let n=this.floor;if(!n||!this.isAdmin)return;let r=tg(this._doc,n,this.t("floor_copy_name",{name:n.name}),e),o=structuredClone(this._doc);o.floors=Ml(o.floors,r),this.setDoc(o),this._floorId=r.id,this.sel.room=null,this.side.floorCopy=null,this.fit()}moveFloor(e){let n=this._floorId;if(!n)return;let r=Qm(this._doc.floors,n,e);if(r.every((i,s)=>i.id===this._doc.floors[s].id))return;let o=structuredClone(this._doc);o.floors=r.map(i=>o.floors.find(s=>s.id===i.id)),this.setDoc(o)}floorActions(){return{openFloor:e=>{this._floorId=e,this.sel.room=null,this.sel.corner=null,this._draft=[],this.fit()},print:()=>this.printPlan(),addFloor:e=>this.addFloor(e),moveFloor:e=>this.moveFloor(e),deleteFloor:()=>this.deleteFloor(),duplicateFloor:e=>this.duplicateFloor(e),addAreaRooms:e=>this.addAreaRooms(e),closeGaps:()=>this.closeFloorGaps(),shift:()=>this.shiftFloor(this.side.shiftX,this.side.shiftZ),turn:()=>this.turnFloor(),rememberView:()=>this.rememberFloorView()}}roomActions(e){return{select:n=>this.selectItem("room",n),patch:n=>this.updateRoom(n),setArea:n=>this.setArea(n),setRect:(n,r)=>this.setRect(n,r),setCorner:(n,r,o)=>this.setPoint(n,r,o),removeCorner:n=>this.deleteVertex(n),duplicate:()=>this.duplicateRoom(),remove:()=>this.deleteRoom(),rememberView:()=>this.rememberRoomView(),applyPackage:n=>this.applyPackage(e,n),openSpots:()=>{let n=this.hass?be(this.hass,e).filter(r=>r.startsWith("light.")):[];this.side.spots=ig(e,n)},placeSpots:()=>this.placeSpots(e),lockButton:this.fixButton("room",e.id),wallHeights:sm(this.host,e,this.edgeActions()),climate:zp(this.host,e,n=>this.updateRoom(n)),corner:this.sel.corner}}applyPackage(e,n){if(!this.isAdmin)return;let r=eu(e,n,()=>D("furniture"));this.change((o,i)=>i.furniture.push(...r)),this.side.packages=!1,this.side.notice=this.t("pkg_done",{n:r.length})}placeSpots(e){let n=this.side.spots;if(!n||!this.isAdmin)return;let r=Gi(e,n);this.change((o,i)=>i.furniture.push(...r)),this.side.spots=null,this.side.notice=this.t("spots_placed",{n:r.length})}viewCentre(){return this.toWorld(this._size.w/2,this._size.h/2)}addFreeWall(e,n){if(!this.floor)return;let r=rp(e,n);this.change((o,i)=>i.walls=[...i.walls??[],r]),this.selectItem("wall",r.id)}addHole(e,n){if(!this.floor)return;let r=sp(e,n);this.change((o,i)=>i.furniture.push(r)),this.selectItem("furniture",r.id),this._tool="select"}addStairs(e,n){let r=this.floor;if(!r)return;let[o,i]=[n[0]-e[0],n[1]-e[1]],s=za("stairs",this._doc,r,[(e[0]+n[0])/2,(e[1]+n[1])/2]),l=o>i*1.2;Object.assign(s,{w:Math.round((l?i:o)*1e3)/1e3,d:Math.round((l?o:i)*1e3)/1e3,rotation:l?90:0}),this.change((a,c)=>c.furniture.push(s)),this.selectItem("furniture",s.id),this._tool="select"}addOutdoor(e){if(!this.floor)return;let n=ap(e);this.change((r,o)=>o.outdoor.push(n)),this.selectItem("outdoor",n.id),this._tool="select"}duplicateOutdoor(){let e=this.outdoorArea;if(!e||!this.isAdmin)return;let n=dp(e);this.change((r,o)=>o.outdoor.push(n)),this.selectItem("outdoor",n.id)}addRoom(e){if(! Line truncated
${Mf(r,s,this._tool,this._draft,this._cursor)} ${Sf(r,this._guides,this._size)}`}wallsOfFloor(){let e=this.floor,{wall_exterior:n,wall_interior:r}=this._doc.settings;return e?pe(e.rooms,{exterior:n,interior:r},e.walls??[]).walls:[]}edgeParts(e,n){let r=this.wallsOfFloor().flatMap(o=>o.sources.filter(i=>i.room_id===e.id&&i.edge===n).map(i=>i.t0));return r.length>0?[...new Set(r)].sort((o,i)=>o-i):[0]}changeRoom(e,n){this.isAdmin&&this.change((r,o)=>{let i=o.rooms.find(s=>s.id===e.id);i&&n(i)})}edgeActions(){return{openWall:(e,n)=>this._wallView={roomId:e.id,edge:n},partsOf:(e,n)=>this.edgeParts(e,n),isOuter:(e,n)=>this.wallsOfFloor().some(r=>r.exterior&&r.sources.some(o=>o.room_id===e.id&&o.edge===n)),setHeight:(e,n,r,o)=>{if(r!==void 0){let s=this.edgeParts(e,n).length;this.changeRoom(e,l=>Qf(l,n,r,o,s));return}let i=this.wallsOfFloor().filter(s=>s.sources.some(l=>l.room_id===e.id&&l.edge===n)).flatMap(s=>s.sources);i.some(s=>s.room_id===e.id&&s.edge===n)||i.push({room_id:e.id,edge:n,t0:0,t1:0}),this.isAdmin&&this.change((s,l)=>{for(let a of i){let c=l.rooms.find(d=>d.id===a.room_id);c&&cl(c,a.edge,o)}})},setSlope:(e,n,r,o)=>this.changeRoom(e,i=>Yf(i,n,r,o)),clearSlope:(e,n)=>this.changeRoom(e,r=>Xf(r,n,this.floor?.height??2.5)),setThickness:(e,n,r,o,i)=>this.changeRoom(e,s=>nm(s,n,r,o,i)),arc:this.arcActions(),cut:(e,n,r)=>{let o=this.edgeParts(e,n);this.changeRoom(e,i=>Jf(i,n,r,o))},moveCut:(e,n,r,o)=>{let i=this.edgeParts(e,n);this.changeRoom(e,s=>em(s,n,r,o,i))},join:(e,n,r,o)=>this.changeRoom(e,i=>tm(i,n,r,o)),lit:this.sel.edge,light:e=>this.sel.edge=e}}addFloor(e=null){let n=Xm(this._doc,e,{first:this.t("default_floor"),next:o=>this.t("new_floor",{n:o})}),r=structuredClone(this._doc);r.floors=Ml(r.floors,n),this.setDoc(r),this._floorId=n.id,this.sel.room=null,this.side.floorMenu=!1,this.fit()}addAreaRooms(e){let n=nr(this._doc,e,this.hass?.areas);if(n.length===0)return;let r=Zc(e,n,()=>D("room"));this.change((o,i)=>i.rooms.push(...r)),this.fit()}duplicateFloor(e){let n=this.floor;if(!n||!this.isAdmin)return;let r=tg(this._doc,n,this.t("floor_copy_name",{name:n.name}),e),o=structuredClone(this._doc);o.floors=Ml(o.floors,r),this.setDoc(o),this._floorId=r.id,this.sel.room=null,this.side.floorCopy=null,this.fit()}moveFloor(e){let n=this._floorId;if(!n)return;let r=Qm(this._doc.floors,n,e);if(r.every((i,s)=>i.id===this._doc.floors[s].id))return;let o=structuredClone(this._doc);o.floors=r.map(i=>o.floors.find(s=>s.id===i.id)),this.setDoc(o)}floorActions(){return{openFloor:e=>{this._floorId=e,this.sel.room=null,this.sel.corner=null,this._draft=[],this.fit()},print:()=>this.printPlan(),addFloor:e=>this.addFloor(e),moveFloor:e=>this.moveFloor(e),deleteFloor:()=>this.deleteFloor(),duplicateFloor:e=>this.duplicateFloor(e),addAreaRooms:e=>this.addAreaRooms(e),closeGaps:()=>this.closeFloorGaps(),shift:()=>this.shiftFloor(this.side.shiftX,this.side.shiftZ),turn:()=>this.turnFloor(),rememberView:()=>this.rememberFloorView()}}roomActions(e){return{select:n=>this.selectItem("room",n),patch:n=>this.updateRoom(n),setArea:n=>this.setArea(n),setRect:(n,r)=>this.setRect(n,r),setCorner:(n,r,o)=>this.setPoint(n,r,o),removeCorner:n=>this.deleteVertex(n),duplicate:()=>this.duplicateRoom(),remove:()=>this.deleteRoom(),rememberView:()=>this.rememberRoomView(),applyPackage:n=>this.applyPackage(e,n),openSpots:()=>{let n=this.hass?be(this.hass,e).filter(r=>r.startsWith("light.")):[];this.side.spots=ig(e,n)},placeSpots:()=>this.placeSpots(e),lockButton:this.fixButton("room",e.id),wallHeights:sm(this.host,e,this.edgeActions()),climate:zp(this.host,e,n=>this.updateRoom(n)),corner:this.sel.corner}}applyPackage(e,n){if(!this.isAdmin)return;let r=eu(e,n,()=>D("furniture"));this.change((o,i)=>i.furniture.push(...r)),this.side.packages=!1,this.side.notice=this.t("pkg_done",{n:r.length})}placeSpots(e){let n=this.side.spots;if(!n||!this.isAdmin)return;let r=Gi(e,n);this.change((o,i)=>i.furniture.push(...r)),this.side.spots=null,this.side.notice=this.t("spots_placed",{n:r.length})}viewCentre(){return this.toWorld(this._size.w/2,this._size.h/2)}addFreeWall(e,n){if(!this.floor)return;let r=rp(e,n);this.change((o,i)=>i.walls=[...i.walls??[],r]),this.selectItem("wall",r.id)}addHole(e,n){if(!this.floor)return;let r=sp(e,n);this.change((o,i)=>i.furniture.push(r)),this.selectItem("furniture",r.id),this._tool="select"}addStairs(e,n){let r=this.floor;if(!r)return;let[o,i]=[n[0]-e[0],n[1]-e[1]],s=za("stairs",this._doc,r,[(e[0]+n[0])/2,(e[1]+n[1])/2]),l=o>i*1.2;Object.assign(s,{w:Math.round((l?i:o)*1e3)/1e3,d:Math.round((l?o:i)*1e3)/1e3,rotation:l?90:0}),this.change((a,c)=>c.furniture.push(s)),this.selectItem("furniture",s.id),this._tool="select"}addOutdoor(e){if(!this.floor)return;let n=ap(e);this.change((r,o)=>o.outdoor.push(n)),this.selectItem("outdoor",n.id),this._tool="select"}duplicateOutdoor(){let e=this.outdoorArea;if(!e||!this.isAdmin)return;let n=dp(e);this.change((r,o)=>o.outdoor.push(n)),this.selectItem("outdoor",n.id)}addRoom(e){if(! Line truncated
${ho(this.host,n,this.furnitureActions())}`;let r=this.energyActions();return m`${xh(this.host,r)}${Hm(this.roofDeps())}${$h(this.host,r)}${Eh(this.host,this.routeActions())}${Sh(this.host,r)}${Mh(this.host)}`}fixItem(e,n,r){if(e)switch(n){case"room":return e.rooms.find(o=>o.id===r);case"opening":return e.openings.find(o=>o.id===r);case"furniture":return e.furniture.find(o=>o.id===r);case"device":return e.placements.find(o=>o.entity_id===r);case"wall":return(e.walls??[]).find(o=>o.id===r);case"outdoor":return e.outdoor.find(o=>o.id===r)}}isFixedItem(e,n){return Po(this.fixItem(this.floor,e,n),e!=="furniture"&&e!=="device",this._doc.settings)}toggleFixed(e,n){if(!this.isAdmin||e!=="furniture"&&e!=="device")return;let r=!this.isFixedItem(e,n);this.change((o,i)=>{let s=this.fixItem(i,e,n);s&&(s.locked=r)})}toggleLockPlan(){this.isAdmin&&this.change(e=>e.settings.lock_plan=!e.settings.lock_plan)}confirmFixedDelete(e,n){return!this.isFixedItem(e,n)||confirm(this.t("fixed_delete_confirm"))}onContextMenu(e){e.preventDefault(),!(this._tool!=="select"&&this._tool!=="furniture")&&(this.drag=null,this.openContext(e.target,this.localPoint(e)))}openContext(e,n){if(!this.isAdmin||!this.floor)return;let r=this.toWorld(...n),o=f=>e.closest(`[${f}]`)?.getAttribute(f)??null,i=null,s=o("data-device"),l=o("data-opening"),a=e.closest("[data-vertex], [data-mid]")?null:o("data-furniture"),c=o("data-free-wall"),d=o("data-outdoor"),u=o("data-room")??this.roomAt(r);if(s?i=["device",s]:l?i=["opening",l]:a?i=["furniture",a]:c?i=["wall",c]:d&&!u?i=["outdoor",d]:u&&(i=["room",u]),!i){this._ctx=null;return}let[p,h]=i;this.selectItem(p,h),(p==="opening"||p==="furniture")&&(this.sel.room=this.sel.room??u),this._ctx={x:n[0],y:n[1],kind:p,id:h,at:r}}deleteItem(e,n){if(e==="device"){if(!this.confirmFixedDelete(e,n))return;this.removeDevice(n),this.sel.device=null;return}e==="room"?this.deleteRoom():e==="opening"?this.deleteOpening():e==="furniture"?this.deleteFurniture():e==="wall"?this.deleteFreeWall():this.deleteOutdoor()}renderContext(){let e=this._ctx;if(!e)return _;let n=this.isFixedItem(e.kind,e.id),r=this.renderRoot.querySelector(".nf-canvas-wrap"),o=Math.max(4,Math.min(e.x,(r?.clientWidth??800)-190)),i=Math.max(4,Math.min(e.y,(r?.clientHeight??600)-190)),s=l=>()=>{this._ctx=null,l()};return m`<div class="nf-ctx" style=${`left:${o}px;top:${i}px`} @pointerdown=${l=>l.stopPropagation()} @contextmenu=${l=>l.preventDefault()}>
${e.kind==="furniture"||e.kind==="device"?m`<button title=${this.t("fix_hint")} @click=${s(()=>this.toggleFixed(e.kind,e.id))}>${n?`\u{1F513} ${this.t("unfix")}`:`\u{1F512} ${this.t("fix")}`}</button>`:m`<button title=${this.t("lock_plan_hint")} @click=${s(()=>this.toggleLockPlan())}>${this._doc.settings.lock_plan?`\u{1F513} ${this.t("plan_unlock")}`:`\u{1F512} ${this.t("plan_lock")}`}</button>`}
${e.kind==="room"?m`<button @click=${s(()=>this.duplicateRoom())}>⧉ ${this.t("duplicate")}</button>`:_}
@@ -4457,7 +4460,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
🔒 ${this.t("plan_locked")}
</button>`:_;let r=this.isFixedItem(e,n);return m`<button class="nf-btn nf-fix" aria-pressed=${r} title=${this.t("fix_hint")} @click=${()=>this.toggleFixed(e,n)}>
${r?`\u{1F512} ${this.t("unfix")}`:`\u{1F513} ${this.t("fix")}`}
</button>`}dropOffset(e,n,r,o,i){let s=e.points[n],l=e.points[(n+1)%e.points.length],a=Math.hypot(l[0]-s[0],l[1]-s[1])||1,c=((r[0]-s[0])*(l[0]-s[0])+(r[1]-s[1])*(l[1]-s[1]))/a;return bp(a,c,o,i?.01:this._doc.settings.grid)}selectItem(e,n){this.side.notice=null,n&&(this._sideOpen=!0),this.sel.select(e,n,{roomOfDevice:r=>{let o=this.floor?.placements.find(i=>i.entity_id===r);return(o&&this.roomAt([o.x,o.z]))??null},roomOfOpening:r=>this.floor?.openings.find(o=>o.id===r)?.room_id??null})}get opening(){let e=this.sel.opening?this.floor?.openings.find(o=>o.id===this.sel.opening):void 0;if(!e?.front||!this.floor)return e;let n=this.floor.rooms.find(o=>o.id===e.room_id),r=n?Dn(n,It(this.floor.openings,e)):null;return r?{...e,width:r.width}:e}get furnitureItem(){return this.sel.furniture?this.floor?.furniture.find(e=>e.id===this.sel.furniture):void 0}placeOpening(e,n){let r=this.floor;if(!r||!this.isAdmin)return!1;let o=null;for(let g of r.walls??[]){let y=Ie({room_id:"",edge:0,wall:g.id},r.rooms,r.walls??[]);if(!y)continue;let[b,v]=this.toScreen(g.a),[w,x]=this.toScreen(g.b),k=(w-b)**2+(x-v)**2||1,$=Math.min(1,Math.max(0,((n[0]-b)*(w-b)+(n[1]-v)*(x-v))/k)),A=Math.hypot(n[0]-b-(w-b)*$,n[1]-v-(x-v)*$),F=[(g.a[0]+g.b[0])/2,(g.a[1]+g.b[1])/2],T=r.rooms.find(I=>I.points.length>=3&&N(F,I.points));A<Zi*2.2&&(!o||A-1<o.d)&&(o={room:y.room,edge:0,d:A-1,wall:g.id,roomId:T?.id??g.id})}for(let g of r.rooms)for(let y=0;y<g.points.length;y++){let[b,v]=this.toScreen(g.points[y]),[w,x]=this.toScreen(g.points[(y+1)%g.points.length]),k=(w-b)**2+(x-v)**2||1,$=Math.min(1,Math.max(0,((n[0]-b)*(w-b)+(n[1]-v)*(x-v))/k)),A=Math.hypot(n[0]-b-(w-b)*$,n[1]-v-(x-v)*$),F=A-(g.id===this.sel.room?.5:0);A<Zi*2.2&&(!o||F<o.d)&&(o={room:g,edge:y,d:F})}if(!o)return!1;let{room:i,edge:s,wall:l}=o,a=i.points[s],c=i.points[(s+1)%i.points.length],d=Math.hypot(c[0]-a[0],c[1]-a[1]),u=vn[e],p=u.type;if(u.style==="glass_wall"&&!l){let g=na(i,this.toWorld(...n)),y=ta(i,g-u.width/2,u.width);if(y&&y.length>1){let b=D("front"),v=y.map(w=>({id:D("opening"),room_id:o.roomId??i.id,edge:w.edge,offset:w.offset,width:w.width,front:b,type:p,sill:u.sill,height:u.height,hinge:"left",leaves:u.leaves,swing:"in",...Lo.has(u.style)?{}:{style:u.style},...u.opens?{opens:u.opens}:{},cover:null,contact:null,contact2:null,tilt:null}));return this.change((w,x)=>x.openings.push(...v)),this._tool="select",this.selectItem("opening",v[0].id),!0}}let h=He(Math.min(u.width,Math.max(.3,d-.1))),f={id:D("opening"),room_id:o.roomId??i.id,edge:s,...l?{wall:l}:{},offset:this.dropOffset(i,s,this.toWorld(...n),h,!1),width:h,type:p,sill:u.sill,height:u.height,hinge:"left",leaves:u.leaves,swing:"in",...u.style&&!Lo.has(u.style)?{style:u.style}:{},...u.opens?{opens:u.opens}:{},cover:null,contact:null,contact2:null,tilt:null};return this.change((g,y)=>y.openings.push(f)),this._tool="select",this.selectItem("opening",f.id),!0}updateOpening(e){let n=this.sel.opening;this.change((r,o)=>{let i=o.openings.find(d=>d.id===n);if(!i)return;let s=It(o.openings,i),l=i.wall?null:o.rooms.find(d=>d.id===i.room_id),a=l&&i.type==="window"&&i.style==="glass_wall"&&(e.width!=null||e.offset!=null),c=a&&l?Dn(l,s):null;if(a&&l&&c){let d=Math.max(.3,e.width??c.width),u=c.from;e.width!=null&&(u+=(c.width-d)/2),e.offset!=null&&(u+=e.offset-i.offset),u=Math.max(0,Math.min(Vr(l)-d,u));let p=Kr(o.openings,l,{...i,...e},u,d,()=>D("opening"));p&&(o.openings=p);return}for(let d of s)Object.assign(d,e)})}deleteOpening(){let e=this.sel.opening;!e||!this.isAdmin||!this.confirmFixedDelete("opening",e)||(this.change((n,r)=>{let o=r.openings.find(s=>s.id===e),i=new Set((o?It(r.openings,o):[o]).map(s=>s?.id));r.openings=r.openings.filter(s=>!i.has(s.id))}),this.sel.opening=null)}snapToWall(e){return this.floor?vr(this.floor,e,this._doc.settings.wall_interior):null}updateFurniture(e){let n=this.sel.furniture;this.change((r,o)=>Object.assign(o.furniture.find(i=>i.id===n),e))}mirrorFurniture(){let e=this.furnitureItem;!e||!this.isAdmin||this.updateFurniture({mirror:!e.mirror})}deleteFurniture(){let e=this.sel.furniture;!e||!this.isAdmin||!this.confirmFixedDelete("furniture",e)||(this.change((n,r)=>r.furniture=r.furniture.filter(o=>o.id!==e)),this.sel.furniture=null)}get device(){return this.sel.device?this.floor?.placements.find(e=>e.entity_id===this.sel.device):void 0}updateDevice(e){let n=this.sel.device;this.change((r,o)=>Object.assign(o.placements.find(i=>i.entity_id===n),e))}closeFloorGaps(){let e=this.floor;if(!e||!this.isAdmin)return;let{rooms:n,gaps:r}=Sd(e.rooms);if(!r.length){this.side.notice=this.t("gaps_none");return}let o=Md(r);this.change((i,s)=>{s.rooms=n,o&&(i.settings.wall_interior=o)}),this.side.notice=o?this.t("gaps_closed_wall",{n:r.length,t:j(this.hass,o,2)}):this.t("gaps_closed",{n:r.length})}updateFloor(e){this.change((n,r)=>Object.assign(r,e))}updateRoom(e){let n=this.sel.room;this.change((r,o)=>Object.assign(o.rooms.find(i=>i.id===n),e))}render(){Ip(this._doc.settings.units);let e=this.floor,n=e?pe(e.rooms,Line truncated
</button>`}dropOffset(e,n,r,o,i){let s=e.points[n],l=e.points[(n+1)%e.points.length],a=Math.hypot(l[0]-s[0],l[1]-s[1])||1,c=((r[0]-s[0])*(l[0]-s[0])+(r[1]-s[1])*(l[1]-s[1]))/a;return bp(a,c,o,i?.01:this._doc.settings.grid)}selectItem(e,n){this.side.notice=null,n&&(this._sideOpen=!0),this.sel.select(e,n,{roomOfDevice:r=>{let o=this.floor?.placements.find(i=>i.entity_id===r);return(o&&this.roomAt([o.x,o.z]))??null},roomOfOpening:r=>this.floor?.openings.find(o=>o.id===r)?.room_id??null})}get opening(){let e=this.sel.opening?this.floor?.openings.find(o=>o.id===this.sel.opening):void 0;if(!e?.front||!this.floor)return e;let n=this.floor.rooms.find(o=>o.id===e.room_id),r=n?On(n,Dt(this.floor.openings,e)):null;return r?{...e,width:r.width}:e}get furnitureItem(){return this.sel.furniture?this.floor?.furniture.find(e=>e.id===this.sel.furniture):void 0}placeOpening(e,n){let r=this.floor;if(!r||!this.isAdmin)return!1;let o=null;for(let g of r.walls??[]){let y=Ie({room_id:"",edge:0,wall:g.id},r.rooms,r.walls??[]);if(!y)continue;let[b,v]=this.toScreen(g.a),[w,x]=this.toScreen(g.b),k=(w-b)**2+(x-v)**2||1,$=Math.min(1,Math.max(0,((n[0]-b)*(w-b)+(n[1]-v)*(x-v))/k)),A=Math.hypot(n[0]-b-(w-b)*$,n[1]-v-(x-v)*$),F=[(g.a[0]+g.b[0])/2,(g.a[1]+g.b[1])/2],T=r.rooms.find(I=>I.points.length>=3&&N(F,I.points));A<Zi*2.2&&(!o||A-1<o.d)&&(o={room:y.room,edge:0,d:A-1,wall:g.id,roomId:T?.id??g.id})}for(let g of r.rooms)for(let y=0;y<g.points.length;y++){let[b,v]=this.toScreen(g.points[y]),[w,x]=this.toScreen(g.points[(y+1)%g.points.length]),k=(w-b)**2+(x-v)**2||1,$=Math.min(1,Math.max(0,((n[0]-b)*(w-b)+(n[1]-v)*(x-v))/k)),A=Math.hypot(n[0]-b-(w-b)*$,n[1]-v-(x-v)*$),F=A-(g.id===this.sel.room?.5:0);A<Zi*2.2&&(!o||F<o.d)&&(o={room:g,edge:y,d:F})}if(!o)return!1;let{room:i,edge:s,wall:l}=o,a=i.points[s],c=i.points[(s+1)%i.points.length],d=Math.hypot(c[0]-a[0],c[1]-a[1]),u=kn[e],p=u.type;if(u.style==="glass_wall"&&!l){let g=na(i,this.toWorld(...n)),y=ta(i,g-u.width/2,u.width);if(y&&y.length>1){let b=D("front"),v=y.map(w=>({id:D("opening"),room_id:o.roomId??i.id,edge:w.edge,offset:w.offset,width:w.width,front:b,type:p,sill:u.sill,height:u.height,hinge:"left",leaves:u.leaves,swing:"in",...Lo.has(u.style)?{}:{style:u.style},...u.opens?{opens:u.opens}:{},cover:null,contact:null,contact2:null,tilt:null}));return this.change((w,x)=>x.openings.push(...v)),this._tool="select",this.selectItem("opening",v[0].id),!0}}let h=He(Math.min(u.width,Math.max(.3,d-.1))),f={id:D("opening"),room_id:o.roomId??i.id,edge:s,...l?{wall:l}:{},offset:this.dropOffset(i,s,this.toWorld(...n),h,!1),width:h,type:p,sill:u.sill,height:u.height,hinge:"left",leaves:u.leaves,swing:"in",...u.style&&!Lo.has(u.style)?{style:u.style}:{},...u.opens?{opens:u.opens}:{},cover:null,contact:null,contact2:null,tilt:null};return this.change((g,y)=>y.openings.push(f)),this._tool="select",this.selectItem("opening",f.id),!0}updateOpening(e){let n=this.sel.opening;this.change((r,o)=>{let i=o.openings.find(d=>d.id===n);if(!i)return;let s=Dt(o.openings,i),l=i.wall?null:o.rooms.find(d=>d.id===i.room_id),a=l&&i.type==="window"&&i.style==="glass_wall"&&(e.width!=null||e.offset!=null),c=a&&l?On(l,s):null;if(a&&l&&c){let d=Math.max(.3,e.width??c.width),u=c.from;e.width!=null&&(u+=(c.width-d)/2),e.offset!=null&&(u+=e.offset-i.offset),u=Math.max(0,Math.min(Vr(l)-d,u));let p=Kr(o.openings,l,{...i,...e},u,d,()=>D("opening"));p&&(o.openings=p);return}for(let d of s)Object.assign(d,e)})}deleteOpening(){let e=this.sel.opening;!e||!this.isAdmin||!this.confirmFixedDelete("opening",e)||(this.change((n,r)=>{let o=r.openings.find(s=>s.id===e),i=new Set((o?Dt(r.openings,o):[o]).map(s=>s?.id));r.openings=r.openings.filter(s=>!i.has(s.id))}),this.sel.opening=null)}snapToWall(e){return this.floor?vr(this.floor,e,this._doc.settings.wall_interior):null}updateFurniture(e){let n=this.sel.furniture;this.change((r,o)=>Object.assign(o.furniture.find(i=>i.id===n),e))}mirrorFurniture(){let e=this.furnitureItem;!e||!this.isAdmin||this.updateFurniture({mirror:!e.mirror})}deleteFurniture(){let e=this.sel.furniture;!e||!this.isAdmin||!this.confirmFixedDelete("furniture",e)||(this.change((n,r)=>r.furniture=r.furniture.filter(o=>o.id!==e)),this.sel.furniture=null)}get device(){return this.sel.device?this.floor?.placements.find(e=>e.entity_id===this.sel.device):void 0}updateDevice(e){let n=this.sel.device;this.change((r,o)=>Object.assign(o.placements.find(i=>i.entity_id===n),e))}closeFloorGaps(){let e=this.floor;if(!e||!this.isAdmin)return;let{rooms:n,gaps:r}=Sd(e.rooms);if(!r.length){this.side.notice=this.t("gaps_none");return}let o=Md(r);this.change((i,s)=>{s.rooms=n,o&&(i.settings.wall_interior=o)}),this.side.notice=o?this.t("gaps_closed_wall",{n:r.length,t:j(this.hass,o,2)}):this.t("gaps_closed",{n:r.length})}updateFloor(e){this.change((n,r)=>Object.assign(r,e))}updateRoom(e){let n=this.sel.room;this.change((r,o)=>Object.assign(o.rooms.find(i=>i.id===n),e))}render(){Ip(this._doc.settings.units);let e=this.floor,n=e?pe(e.rooms,Line truncated
${cf(this.host,this.lib.preview)}
${this._wallView?m`<nf-wall-view .host=${this.host} .doc=${this._doc} .roomId=${this._wallView.roomId} .edge=${this._wallView.edge} @close=${()=>this._wallView=null}></nf-wall-view>`:_}
<div class="nf-editor ${this.narrow?"nf-narrow":""}">
@@ -4540,7 +4543,7 @@ ${i}`}else o=ju(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${r&&!0?ku(this.host):_} ${r?xu(this.host,this._doc):_} ${r?Ru(this.host):_}
${e&&r?Zh(this.host,this.bg,e):_} ${r?uh(this.host,this.settingsActions):_}
${r?Xu(this.host,this.backup):_}
`}openingIsExterior(e){let n=this.floor,r=n?Ie(e,n.rooms,n.walls??[]):null;if(!n||!r)return!1;let o=pe(n.rooms,{exterior:this._doc.settings.wall_exterior,interior:this._doc.settings.wall_interior},n.walls??[]);return zt(o.walls,e,r)?.wall.exterior??!1}groundView(){let e=this.paneView();if(!e)return alert(this.t("floor_start_view_need_pane")),null;let n=this.floor?.elevation??0;return e.target?{...e,target:{...e.target,y:He(e.target.y+n)}}:e}paneView(){let n=this.renderRoot.querySelector("nf-view3d")?.currentView();if(!n)return null;let r=n.target;return{theta:He(n.theta),phi:He(n.phi),radius:He(n.radius),...r?{target:{x:He(r.x),y:He(r.y),z:He(r.z)}}:{}}}rememberFloorView(){let e=this.paneView();if(!e){alert(this.t("floor_start_view_need_pane"));return}this.updateFloor({start_view:e})}rememberRoomView(){let e=this.paneView();if(!e){alert(this.t("room_start_view_need_pane"));return}this.updateRoom({start_view:e})}storedPictures(){let e=[];for(let n of this._doc.floors)for(let r of n.furniture)for(let o of r.pictures??[])o.image&&!/^https?:\/\//.test(o.image)&&!o.image.startsWith("camera:")&&!e.includes(o.image)&&e.push(o.image);return e}static styles=[Me,ut,dg]};customElements.get("nf-editor")||customElements.define("nf-editor",Hl);export{Hl as NfEditor};
`}openingIsExterior(e){let n=this.floor,r=n?Ie(e,n.rooms,n.walls??[]):null;if(!n||!r)return!1;let o=pe(n.rooms,{exterior:this._doc.settings.wall_exterior,interior:this._doc.settings.wall_interior},n.walls??[]);return Pt(o.walls,e,r)?.wall.exterior??!1}groundView(){let e=this.paneView();if(!e)return alert(this.t("floor_start_view_need_pane")),null;let n=this.floor?.elevation??0;return e.target?{...e,target:{...e.target,y:He(e.target.y+n)}}:e}paneView(){let n=this.renderRoot.querySelector("nf-view3d")?.currentView();if(!n)return null;let r=n.target;return{theta:He(n.theta),phi:He(n.phi),radius:He(n.radius),...r?{target:{x:He(r.x),y:He(r.y),z:He(r.z)}}:{}}}rememberFloorView(){let e=this.paneView();if(!e){alert(this.t("floor_start_view_need_pane"));return}this.updateFloor({start_view:e})}rememberRoomView(){let e=this.paneView();if(!e){alert(this.t("room_start_view_need_pane"));return}this.updateRoom({start_view:e})}storedPictures(){let e=[];for(let n of this._doc.floors)for(let r of n.furniture)for(let o of r.pictures??[])o.image&&!/^https?:\/\//.test(o.image)&&!o.image.startsWith("camera:")&&!e.includes(o.image)&&e.push(o.image);return e}static styles=[Me,ht,dg]};customElements.get("nf-editor")||customElements.define("nf-editor",Hl);export{Hl as NfEditor};
/*! Bundled license information:
@lit/reactive-element/css-tag.js:
+64 -9
View File
@@ -417,12 +417,9 @@ class NextFloor extends IPSModuleStrict
private function describeVariable(int $variableID, string $name, string $path, ?int $categoryID): array
{
$variable = IPS_GetVariable($variableID);
$profile = (string) (($variable['VariableCustomProfile'] ?? '') ?: ($variable['VariableProfile'] ?? ''));
// Symcon 9 presentations can carry a unit without any legacy variable profile.
$presentation = IPS_GetVariablePresentation($variableID);
$profile = (string) ($presentation['PROFILE'] ?? $profile);
$profileData = $profile !== '' && IPS_VariableProfileExists($profile) ? IPS_GetVariableProfile($profile) : [];
$unit = trim((string) ($presentation['SUFFIX'] ?? $profileData['Suffix'] ?? ''));
$meta = $this->variableMetadata($variableID, $variable);
$profile = $meta['profile'];
$unit = $meta['unit'];
$value = GetValue($variableID);
$kind = $this->kindFor($variable, $profile, $name . ' ' . $path);
$attributes = [
@@ -441,14 +438,17 @@ class NextFloor extends IPSModuleStrict
// Keep the actual numeric reading even when legacy name heuristics chose an actuator domain.
// Existing synthetic entity IDs stay stable so saved plan mappings keep working.
$attributes['symcon_numeric_value'] = $value;
$attributes['symcon_min'] = $meta['min'];
$attributes['symcon_max'] = $meta['max'];
$attributes['symcon_step'] = $meta['step'];
}
if ($kind === 'light' && is_numeric($value)) {
$attributes['brightness'] = (int) round(max(0, min(100, (float) $value)) * 2.55);
$attributes['brightness'] = (int) round($this->valuePercent((float) $value, $meta) * 2.55);
$attributes['color_mode'] = 'brightness';
$attributes['supported_color_modes'] = ['brightness'];
}
if ($kind === 'cover' && is_numeric($value)) {
$attributes['current_position'] = max(0, min(100, (int) round((float) $value)));
$attributes['current_position'] = $this->valuePercent((float) $value, $meta);
$attributes['supported_features'] = 4;
}
if ($kind === 'climate' && is_numeric($value)) {
@@ -459,17 +459,55 @@ class NextFloor extends IPSModuleStrict
$attributes['hvac_modes'] = ['off', 'heat'];
$attributes['hvac_action'] = (float) $value > 0 ? 'heating' : 'idle';
}
$state = $this->stateFor($kind, $value);
if (in_array($kind, ['light', 'cover'], true) && is_numeric($value)) {
$on = $this->valuePercent((float) $value, $meta) > 0;
$state = $kind === 'light' ? ($on ? 'on' : 'off') : ($on ? 'open' : 'closed');
}
return [
'entity_id' => $kind . '.' . $variableID,
'name' => $name,
'path' => $path,
'state' => $this->stateFor($kind, $value),
'state' => $state,
'attributes' => $attributes,
'area_id' => $categoryID === null ? null : 'symcon-category-' . $categoryID,
'device_id' => 'symcon-variable-' . $variableID
];
}
/** The effective Symcon 9 presentation takes precedence over an old profile's range and unit. */
private function variableMetadata(int $variableID, array $variable): array
{
$presentation = IPS_GetVariablePresentation($variableID);
$profile = (string) ($presentation['PROFILE'] ?? (($variable['VariableCustomProfile'] ?? '') ?: ($variable['VariableProfile'] ?? '')));
$legacy = $profile !== '' && IPS_VariableProfileExists($profile) ? IPS_GetVariableProfile($profile) : [];
$min = (float) ($presentation['MIN'] ?? $legacy['MinValue'] ?? 0);
$max = (float) ($presentation['MAX'] ?? $legacy['MaxValue'] ?? 100);
if (!is_finite($min) || !is_finite($max) || $max <= $min) {
[$min, $max] = [0.0, 100.0];
}
$step = (float) ($presentation['STEP_SIZE'] ?? $legacy['StepSize'] ?? 0);
return ['profile' => $profile, 'unit' => trim((string) ($presentation['SUFFIX'] ?? $legacy['Suffix'] ?? '')),
'min' => $min, 'max' => $max, 'step' => is_finite($step) && $step > 0 ? $step : 0.0];
}
private function valuePercent(float $value, array $meta): float
{
return max(0, min(100, ($value - $meta['min']) / ($meta['max'] - $meta['min']) * 100));
}
private function percentValue(mixed $percent, array $meta): float
{
if (!is_numeric($percent) || !is_finite((float) $percent)) {
throw new InvalidArgumentException('invalid_control_percentage');
}
$value = $meta['min'] + max(0, min(100, (float) $percent)) / 100 * ($meta['max'] - $meta['min']);
if ($meta['step'] > 0) {
$value = $meta['min'] + round(($value - $meta['min']) / $meta['step']) * $meta['step'];
}
return max($meta['min'], min($meta['max'], $value));
}
private function kindFor(array $variable, string $profile, string $haystack): string
{
$text = mb_strtolower($profile . ' ' . $haystack);
@@ -770,6 +808,23 @@ class NextFloor extends IPSModuleStrict
{
$variable = IPS_GetVariable($variableID);
$current = GetValue($variableID);
if ($domain === 'cover' && $service === 'stop_cover') {
throw new InvalidArgumentException('cover_stop_not_supported');
}
if (in_array($domain, ['light', 'cover'], true) && in_array((int) $variable['VariableType'], [1, 2], true)) {
$meta = $this->variableMetadata($variableID, $variable);
$percent = match ($service) {
'toggle' => (float) $current > $meta['min'] ? 0 : 100,
'turn_off', 'close_cover', 'close_cover_tilt' => 0,
'set_cover_position' => $data['position'] ?? null,
'set_cover_tilt_position' => $data['tilt_position'] ?? null,
'turn_on' => $data['brightness_pct'] ?? (isset($data['brightness']) ? (float) $data['brightness'] / 2.55 : 100),
'open_cover', 'open_cover_tilt' => 100,
default => throw new InvalidArgumentException('unsupported_control_service')
};
$this->setVariable($variableID, $variable, $this->percentValue($percent, $meta));
return;
}
$value = match ($service) {
'toggle', 'media_play_pause' => is_bool($current) ? !$current : (is_numeric($current) ? ((float) $current > 0 ? 0 : 100) : true),
'turn_on', 'open_cover', 'lock' => $this->onValue($variable, $data),
+23 -1
View File
@@ -16,7 +16,7 @@ In **Kerninstanzen → Modules** wird dieses Repository verwendet:
Im Zahnrad des Eintrags den Branch **`symcon`** wählen und auf Aktualisierungen prüfen.
`main` enthält die Quellen für die Entwicklung, `symcon` die installierbare Bibliothek.
Nach der Aktualisierung auf **0.2.4 / Build 7** die Konsole neu laden. Unter
Nach der Aktualisierung auf **0.2.5 / Build 8** die Konsole neu laden. Unter
**Instanz hinzufügen → Hersteller NextFloor** erscheint **„NextFloor Designer und 3D-Kachel“**.
### Für die Entwicklung
@@ -46,6 +46,28 @@ Die Dateien unter `NextFloor/assets/` und `NextFloor/packs/` werden durch
Der Build prüft anschließend die Modulmetadaten und die installierbare Verzeichnisstruktur.
Dieselbe Prüfung lässt sich separat mit `node symcon/tests/validate-package.mjs` ausführen.
## Änderungen in 0.2.5
- Numerische Variablen lassen sich im Objektbaum ausdrücklich als Licht-Dimmer oder
Behangposition auswählen, auch wenn der automatisch vermutete Gerätetyp nicht passt.
Integer und Float werden unterstützt; zusätzliche Rollen erzeugen keine doppelten
Objekte im Baum oder Geräte in automatisch gefüllten Raumlisten.
- Helligkeitsregler bleiben auch bei ausgeschaltetem Licht sichtbar. Echte Boolean-Schalter
erhalten keinen Dimmer. Die bewusste Einstellung „Im Raumfenster nur schalten“ bleibt wirksam.
- Wertebereiche und Schrittweiten kommen aus der aktuellen Symcon-Darstellung bzw. dem
Legacy-Profil. 0–255 und 0–1 werden bei Anzeige und Steuerbefehlen in Prozent umgerechnet.
- Im Fenster-/Jalousieformular sind **Position (Behang)** und **Lamellenposition** getrennt
über den Objektbaum verknüpfbar. Auch ein zweiter Behang kann eine eigene Lamellenvariable
erhalten. Die Auswahl steuert die richtigen Variablen im Raumfenster und im Schnellmenü;
die 3D-Lamellen folgen ihrer eigenen Position.
Auch einzeln platzierte Jalousie-Geräte bieten eine eigene Auswahl für die Lamellenposition.
- Ohne unterstützten Stoppbefehl wird kein Stoppknopf angeboten. Ein unbekannter Stoppbefehl
wird abgewiesen, statt versehentlich die Position zu verändern.
Nach dem Update den Designer neu laden. War der Dimmer bisher falsch zugeordnet, dessen
Datenpunkt im Licht-Feld erneut über den Objektbaum auswählen. Bei Jalousien die Position
im Feld **Position (Behang)** und den zweiten Datenpunkt unter **Lamellenposition** wählen.
## Änderungen in 0.2.4
- Das Wandmenü in der rechten Raumleiste lässt sich über die Überschrift auf- und zuklappen.
+2 -2
View File
@@ -6,7 +6,7 @@
"compatibility": {
"version": "9.0"
},
"version": "0.2.4",
"build": 7,
"version": "0.2.5",
"build": 8,
"date": 1794211200
}
+30 -5
View File
@@ -9,15 +9,25 @@ $variables = [
2 => ['VariableType' => 2, 'VariableAction' => 99],
3 => ['VariableType' => 2, 'VariableProfile' => '~Temperature'],
4 => ['VariableType' => 2, 'VariableProfile' => '~Temperature'],
5 => ['VariableType' => 0, 'VariableAction' => 0]
5 => ['VariableType' => 0, 'VariableAction' => 0],
6 => ['VariableType' => 1, 'VariableAction' => 99],
7 => ['VariableType' => 2, 'VariableProfile' => '~Intensity.1', 'VariableAction' => 99],
8 => ['VariableType' => 1, 'VariableAction' => 99],
9 => ['VariableType' => 1, 'VariableAction' => 99]
];
$presentations = [1 => ['SUFFIX' => ' °C'], 2 => ['SUFFIX' => "\u{00A0}°C"], 3 => ['PROFILE' => '~Temperature'], 4 => ['SUFFIX' => ' W']];
$presentations[6] = ['MIN' => 0, 'MAX' => 255, 'STEP_SIZE' => 1, 'USAGE_TYPE' => 2, 'SUFFIX' => '%'];
$presentations[8] = ['MIN' => 0, 'MAX' => 100, 'STEP_SIZE' => 1];
$presentations[9] = ['MIN' => 0, 'MAX' => 255, 'STEP_SIZE' => 1];
function IPS_GetVariable(int $id): array { global $variables; return $variables[$id] + ['VariableProfile' => '', 'VariableCustomProfile' => '', 'VariableAction' => 0, 'VariableCustomAction' => 0]; }
function IPS_GetVariablePresentation(int $id): array { global $presentations; return $presentations[$id] ?? []; }
function IPS_VariableProfileExists(string $profile): bool { return $profile === '~Temperature'; }
function IPS_GetVariableProfile(string $profile): array { return ['Suffix' => ' °C']; }
function GetValue(int $id): float|bool { return $id === 5 ? true : 21.75; }
function IPS_VariableProfileExists(string $profile): bool { return in_array($profile, ['~Temperature', '~Intensity.1'], true); }
function IPS_GetVariableProfile(string $profile): array { return $profile === '~Intensity.1' ? ['MinValue' => 0, 'MaxValue' => 1, 'StepSize' => 0.01, 'Suffix' => ' %'] : ['Suffix' => ' °C']; }
function GetValue(int $id): float|int|bool { return match ($id) { 5 => true, 6, 9 => 128, 7 => 0.4, 8 => 40, default => 21.75 }; }
function GetValueFormatted(int $id): string { return $id === 5 ? 'An' : '21,75'; }
$writes = [];
function RequestAction(int $id, mixed $value): void { global $writes; $writes[] = [$id, $value]; }
function SetValue(int $id, mixed $value): void { global $writes; $writes[] = [$id, $value]; }
require __DIR__ . '/../NextFloor/module.php';
$module = new NextFloor();
@@ -36,4 +46,19 @@ $override = $describe->invoke($module, 4, 'Temperatur', 'Haus / Temperatur', 10)
check($override['attributes']['unit_of_measurement'] === 'W' && $override['attributes']['device_class'] === 'power', 'The effective presentation overrides a stale legacy profile and ancestor names');
$boolean = $describe->invoke($module, 5, 'Kontakt', 'Haus / Kontakt', 10);
check(!isset($boolean['attributes']['symcon_numeric_value']), 'Boolean values are not advertised as numeric readings');
echo "OK: Symcon 9 presentation units, KNX float readings, stable mappings and legacy profiles\n";
$dimmer = $describe->invoke($module, 6, 'Dimmer', 'Haus / Dimmer', 10);
check($dimmer['attributes']['brightness'] === 128, 'An integer dimmer uses its real 0-255 range');
$floatDimmer = $describe->invoke($module, 7, 'Wert', 'Haus / Wert', 10);
check($floatDimmer['attributes']['brightness'] === 102, 'A normalized float dimmer uses its legacy 0-1 profile range');
$write = new ReflectionMethod($module, 'writeAction');
$write->invoke($module, 6, 'light', 'turn_on', ['brightness_pct' => 50]);
$write->invoke($module, 7, 'light', 'turn_on', ['brightness_pct' => 30]);
$write->invoke($module, 8, 'cover', 'set_cover_position', ['position' => 60]);
$write->invoke($module, 9, 'cover', 'set_cover_tilt_position', ['tilt_position' => 25]);
$write->invoke($module, 6, 'light', 'turn_on', ['brightness' => 200]);
check($writes === [[6, 128], [7, 0.3], [8, 60], [9, 64], [6, 200]], 'Light, position and slat commands target the right variables, scale and cast to the native type');
$count = count($writes);
try { $write->invoke($module, 8, 'cover', 'stop_cover', []); throw new RuntimeException('Unsupported stop was accepted'); } catch (InvalidArgumentException) {}
try { $write->invoke($module, 8, 'cover', 'set_cover_position', ['position' => 'invalid']); throw new RuntimeException('Invalid percentage was accepted'); } catch (InvalidArgumentException) {}
check(count($writes) === $count, 'Invalid values and unsupported stop never move an actuator');
echo "OK: Symcon 9 units, KNX float readings, integer/float dimmers, separate blind actions, range scaling and legacy profiles\n";