fix: rebuild hydronic circuits around correct inline pipework

This commit is contained in:
jhartworks committed 2026-11-12 15:27:17 +01:00
1 parent 59292517b7
commit e62f987563
24 files changed
+844 -586

No files matched your search

@@ -1,7 +1,7 @@
/*! NextFloor, MIT licence. Includes three.js (MIT) and Lit (BSD-3-Clause); see LICENSE and THIRD_PARTY_NOTICES.md */
var $={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 Pi=globalThis,Di=Pi.ShadowRoot&&(Pi.ShadyCSS===void 0||Pi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ys=Symbol(),wc=new WeakMap,vr=class{constructor(e,n,r){if(this._$cssResult$=!0,r!==ys)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(Di&&e===void 0){let r=n!==void 0&&n.length===1;r&&(e=wc.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&wc.set(n,e))}return e}toString(){return this.cssText}},kc=t=>new vr(typeof t=="string"?t:t+"",void 0,ys),ee=(t,...e)=>{let n=t.length===1?t[0]:e.reduce((r,i,o)=>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.")})(i)+t[o+1],t[0]);return new vr(n,t,ys)},xc=(t,e)=>{if(Di)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let r=document.createElement("style"),i=Pi.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=n.cssText,t.appendChild(r)}},vs=Di?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let r of e.cssRules)n+=r.cssText;return kc(n)})(t):t;var{is:cb,defineProperty:ub,getOwnPropertyDescriptor:db,getOwnPropertyNames:hb,getOwnPropertySymbols:pb,getPrototypeOf:fb}=Object,Ii=globalThis,$c=Ii.trustedTypes,mb=$c?$c.emptyScript:"",gb=Ii.reactiveElementPolyfillSupport,wr=(t,e)=>t,ws={toAttribute(t,e){switch(e){case Boolean:t=t?mb: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}},Mc=(t,e)=>!cb(t,e),Sc={attribute:!0,type:String,converter:ws,reflect:!1,useDefault:!1,hasChanged:Mc};Symbol.metadata??=Symbol("metadata"),Ii.litPropertyMetadata??=new WeakMap;var bt=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=Sc){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(),i=this.getPropertyDescriptor(e,r,n);i!==void 0&&ub(this.prototype,e,i)}}static getPropertyDescriptor(e,n,r){let{get:i,set:o}=db(this.prototype,e)??{get(){return this[n]},set(s){this[n]=s}};return{get:i,set(s){let l=i?.call(this);o?.call(this,s),this.requestUpdate(e,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Sc}static _$Ei(){if(this.hasOwnProperty(wr("elementProperties")))return;let e=fb(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(wr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(wr("properties"))){let n=this.properties,r=[...hb(n),...pb(n)];for(let i of r)this.createProperty(i,n[i])}let e=this[Symbol.metadata];if(e!==null){let n=litPropertyMetadata.get(e);if(n!==void 0)for(let[r,i]of n)this.elementProperties.set(r,i)}this._$Eh=new Map;for(let[n,r]of this.elementProperties){let i=this._$Eu(n,r);i!==void 0&&this._$Eh.set(i,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 i of r)n.unshift(vs(i))}else e!==void 0&&n.push(vs(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 xc(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]`,kr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ac=/-->/g,Fc=/>/g,Jt=RegExp(`>|${ks}(?:([^\\s"'>=/]+)(${ks}*=${ks}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`,"g"),Tc=/'/g,zc=/"/g,Ic=/^(?:script|style|textarea|title)$/i,Rs=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),m=Rs(1),R=Rs(2),Jx=Rs(3),tt=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),Pc=new WeakMap,Qt=en.createTreeWalker(en,129);function Oc(t,e){if(!Ms(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ec!==void 0?Ec.createHTML(e):e}var Hc=(t,e)=>{let n=t.length-1,r=[],i,o=e===2?"<svg>":e===3?"<math>":"",s=kr;for(let l=0;l<n;l++){let a=t[l],c,u,d=-1,p=0;for(;p<a.length&&(s.lastIndex=p,u=s.exec(a),u!==null);)p=s.lastIndex,s===kr?u[1]==="!--"?s=Ac:u[1]!==void 0?s=Fc:u[2]!==void 0?(Ic.test(u[2])&&(i=RegExp("</"+u[2],"g")),s=Jt):u[3]!==void 0&&(s=Jt):s===Jt?u[0]===">"?(s=i??kr,d=-1):u[1]===void 0?d=-2:(d=s.lastIndex-u[2].length,c=u[1],s=u[3]===void 0?Jt:u[3]==='"'?zc:Tc):s===zc||s===Tc?s=Jt:s===Ac||s===Fc?s=kr:(s=Jt,i=void 0);let h=s===Jt&&t[l+1].startsWith("/>")?" ":"";o+=s===kr?a+_b:d>=0?(r.push(c),a.slice(0,d)+$s+a.slice(d)+yt+h):a+yt+(d===-2?l:h)}return[Oc(t,o+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]},Sr=class t{constructor({strings:e,_$litType$:n},r){let i;this.parts=[];let o=0,s=0,l=e.length-1,a=this.parts,[c,u]=Hc(e,n);if(this.el=t.createElement(c,r),Qt.currentNode=this.el.content,n===2||n===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=Qt.nextNode())!==null&&a.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(let d of i.getAttributeNames())if(d.endsWith($s)){let p=u[s++],h=i.getAttribute(d).split(yt),f=/([.?@])?(.*)/.exec(p);a.push({type:1,index:o,name:f[2],strings:h,ctor:f[1]==="."?Li:f[1]==="?"?Ci:f[1]==="@"?Ni:nn}),i.removeAttribute(d)}else d.startsWith(yt)&&(a.push({type:6,index:o}),i.removeAttribute(d));if(Ic.test(i.tagName)){let d=i.textContent.split(yt),p=d.length-1;if(p>0){i.textContent=Oi?Oi.emptyScript:"";for(let h=0;h<p;h++)i.append(d[h],xr()),Qt.nextNode(),a.push({type:2,index:++o});i.append(d[p],xr())}}}else if(i.nodeType===8)if(i.data===Ss)a.push({type:2,index:o});else{let d=-1;for(;(d=i.data.indexOf(yt,d+1))!==-1;)a.push({type:7,index:o}),d+=yt.length-1}o++}}static createElement(e,n){let r=en.createElement("template");return r.innerHTML=e,r}};function tn(t,e,n=t,r){if(e===tt)return e;let i=r!==void 0?n._$Co?.[r]:n._$Cl,o=$r(e)?void 0:e._$litDirective$;return i?.constructor!==o&&(i?._$AO?.(!1),o===void 0?i=void 0:(i=new o(t),i._$AT(t,n,r)),r!==void 0?(n._$Co??=[])[r]=i:n._$Cl=i),i!==void 0&&(e=tn(t,i._$AS(t,e.values),i,r)),e}var Hi=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,i=(e?.creationScope??en).importNode(n,!0);Qt.currentNode=i;let o=Qt.nextNode(),s=0,l=0,a=r[0];for(;a!==void 0;){if(s===a.index){let c;a.type===2?c=new Rn(o,o.nextSibling,this,e):a.type===1?c=new a.ctor(o,a.name,a.strings,this,e):a.type===6&&(c=new Bi(o,this,e)),this._$AV.push(c),a=r[++l]}s!==a?.index&&(o=Qt.nextNode(),s++)}return Qt.currentNode=en,i}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++}},Rn=class t{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,n,r,i){this.type=2,this._$AH=_,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=i,this._$Cv=i?.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=tn(this,e,n),$r(e)?e===_||e==null||e===""?(this._$AH!==_&&this._$AR(),this._$AH=_):e!==this._$AH&&e!==tt&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Dc(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!==_&&$r(this._$AH)?this._$AA.nextSibling.data=e:this.T(en.createTextNode(e)),this._$AH=e}$(e){let{values:n,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=Sr.createElement(Oc(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===i)this._$AH.p(n);else{let o=new Hi(i,this),s=o.u(this.options);o.p(n),this.T(s),this._$AH=o}}_$AC(e){let n=Pc.get(e.strings);return n===void 0&&Pc.set(e.strings,n=new Sr(e)),n}k(e){Ms(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let o of e)i===n.length?n.push(r=new t(this.O(xr()),this.O(xr()),this,this.options)):r=n[i],r._$AI(o),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);e!==this._$AB;){let r=Rc(e).nextSibling;Rc(e).remove(),e=r}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},nn=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,r,i,o){this.type=1,this._$AH=_,this._$AN=void 0,this.element=e,this.name=n,this._$AM=i,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._Line truncated
var $={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 Pi=globalThis,Di=Pi.ShadowRoot&&(Pi.ShadyCSS===void 0||Pi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,vs=Symbol(),wc=new WeakMap,vr=class{constructor(e,n,r){if(this._$cssResult$=!0,r!==vs)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(Di&&e===void 0){let r=n!==void 0&&n.length===1;r&&(e=wc.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&wc.set(n,e))}return e}toString(){return this.cssText}},kc=t=>new vr(typeof t=="string"?t:t+"",void 0,vs),ee=(t,...e)=>{let n=t.length===1?t[0]:e.reduce((r,i,o)=>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.")})(i)+t[o+1],t[0]);return new vr(n,t,vs)},xc=(t,e)=>{if(Di)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let r=document.createElement("style"),i=Pi.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=n.cssText,t.appendChild(r)}},ws=Di?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let r of e.cssRules)n+=r.cssText;return kc(n)})(t):t;var{is:cb,defineProperty:ub,getOwnPropertyDescriptor:db,getOwnPropertyNames:hb,getOwnPropertySymbols:pb,getPrototypeOf:fb}=Object,Ii=globalThis,$c=Ii.trustedTypes,mb=$c?$c.emptyScript:"",gb=Ii.reactiveElementPolyfillSupport,wr=(t,e)=>t,ks={toAttribute(t,e){switch(e){case Boolean:t=t?mb: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}},Mc=(t,e)=>!cb(t,e),Sc={attribute:!0,type:String,converter:ks,reflect:!1,useDefault:!1,hasChanged:Mc};Symbol.metadata??=Symbol("metadata"),Ii.litPropertyMetadata??=new WeakMap;var bt=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=Sc){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(),i=this.getPropertyDescriptor(e,r,n);i!==void 0&&ub(this.prototype,e,i)}}static getPropertyDescriptor(e,n,r){let{get:i,set:o}=db(this.prototype,e)??{get(){return this[n]},set(s){this[n]=s}};return{get:i,set(s){let l=i?.call(this);o?.call(this,s),this.requestUpdate(e,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Sc}static _$Ei(){if(this.hasOwnProperty(wr("elementProperties")))return;let e=fb(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(wr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(wr("properties"))){let n=this.properties,r=[...hb(n),...pb(n)];for(let i of r)this.createProperty(i,n[i])}let e=this[Symbol.metadata];if(e!==null){let n=litPropertyMetadata.get(e);if(n!==void 0)for(let[r,i]of n)this.elementProperties.set(r,i)}this._$Eh=new Map;for(let[n,r]of this.elementProperties){let i=this._$Eu(n,r);i!==void 0&&this._$Eh.set(i,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 i of r)n.unshift(ws(i))}else e!==void 0&&n.push(ws(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 xc(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]`,kr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ac=/-->/g,Fc=/>/g,Jt=RegExp(`>|${xs}(?:([^\\s"'>=/]+)(${xs}*=${xs}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`,"g"),Tc=/'/g,zc=/"/g,Ic=/^(?:script|style|textarea|title)$/i,Es=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),m=Es(1),R=Es(2),Jx=Es(3),tt=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),Pc=new WeakMap,Qt=en.createTreeWalker(en,129);function Oc(t,e){if(!Rs(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ec!==void 0?Ec.createHTML(e):e}var Hc=(t,e)=>{let n=t.length-1,r=[],i,o=e===2?"<svg>":e===3?"<math>":"",s=kr;for(let l=0;l<n;l++){let a=t[l],c,u,d=-1,p=0;for(;p<a.length&&(s.lastIndex=p,u=s.exec(a),u!==null);)p=s.lastIndex,s===kr?u[1]==="!--"?s=Ac:u[1]!==void 0?s=Fc:u[2]!==void 0?(Ic.test(u[2])&&(i=RegExp("</"+u[2],"g")),s=Jt):u[3]!==void 0&&(s=Jt):s===Jt?u[0]===">"?(s=i??kr,d=-1):u[1]===void 0?d=-2:(d=s.lastIndex-u[2].length,c=u[1],s=u[3]===void 0?Jt:u[3]==='"'?zc:Tc):s===zc||s===Tc?s=Jt:s===Ac||s===Fc?s=kr:(s=Jt,i=void 0);let h=s===Jt&&t[l+1].startsWith("/>")?" ":"";o+=s===kr?a+_b:d>=0?(r.push(c),a.slice(0,d)+Ss+a.slice(d)+yt+h):a+yt+(d===-2?l:h)}return[Oc(t,o+(t[n]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]},Sr=class t{constructor({strings:e,_$litType$:n},r){let i;this.parts=[];let o=0,s=0,l=e.length-1,a=this.parts,[c,u]=Hc(e,n);if(this.el=t.createElement(c,r),Qt.currentNode=this.el.content,n===2||n===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=Qt.nextNode())!==null&&a.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(let d of i.getAttributeNames())if(d.endsWith(Ss)){let p=u[s++],h=i.getAttribute(d).split(yt),f=/([.?@])?(.*)/.exec(p);a.push({type:1,index:o,name:f[2],strings:h,ctor:f[1]==="."?Li:f[1]==="?"?Ci:f[1]==="@"?Ni:nn}),i.removeAttribute(d)}else d.startsWith(yt)&&(a.push({type:6,index:o}),i.removeAttribute(d));if(Ic.test(i.tagName)){let d=i.textContent.split(yt),p=d.length-1;if(p>0){i.textContent=Oi?Oi.emptyScript:"";for(let h=0;h<p;h++)i.append(d[h],xr()),Qt.nextNode(),a.push({type:2,index:++o});i.append(d[p],xr())}}}else if(i.nodeType===8)if(i.data===Ms)a.push({type:2,index:o});else{let d=-1;for(;(d=i.data.indexOf(yt,d+1))!==-1;)a.push({type:7,index:o}),d+=yt.length-1}o++}}static createElement(e,n){let r=en.createElement("template");return r.innerHTML=e,r}};function tn(t,e,n=t,r){if(e===tt)return e;let i=r!==void 0?n._$Co?.[r]:n._$Cl,o=$r(e)?void 0:e._$litDirective$;return i?.constructor!==o&&(i?._$AO?.(!1),o===void 0?i=void 0:(i=new o(t),i._$AT(t,n,r)),r!==void 0?(n._$Co??=[])[r]=i:n._$Cl=i),i!==void 0&&(e=tn(t,i._$AS(t,e.values),i,r)),e}var Hi=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,i=(e?.creationScope??en).importNode(n,!0);Qt.currentNode=i;let o=Qt.nextNode(),s=0,l=0,a=r[0];for(;a!==void 0;){if(s===a.index){let c;a.type===2?c=new Rn(o,o.nextSibling,this,e):a.type===1?c=new a.ctor(o,a.name,a.strings,this,e):a.type===6&&(c=new Bi(o,this,e)),this._$AV.push(c),a=r[++l]}s!==a?.index&&(o=Qt.nextNode(),s++)}return Qt.currentNode=en,i}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++}},Rn=class t{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,n,r,i){this.type=2,this._$AH=_,this._$AN=void 0,this._$AA=e,this._$AB=n,this._$AM=r,this.options=i,this._$Cv=i?.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=tn(this,e,n),$r(e)?e===_||e==null||e===""?(this._$AH!==_&&this._$AR(),this._$AH=_):e!==this._$AH&&e!==tt&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Dc(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!==_&&$r(this._$AH)?this._$AA.nextSibling.data=e:this.T(en.createTextNode(e)),this._$AH=e}$(e){let{values:n,_$litType$:r}=e,i=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=Sr.createElement(Oc(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===i)this._$AH.p(n);else{let o=new Hi(i,this),s=o.u(this.options);o.p(n),this.T(s),this._$AH=o}}_$AC(e){let n=Pc.get(e.strings);return n===void 0&&Pc.set(e.strings,n=new Sr(e)),n}k(e){Rs(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let o of e)i===n.length?n.push(r=new t(this.O(xr()),this.O(xr()),this,this.options)):r=n[i],r._$AI(o),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);e!==this._$AB;){let r=Rc(e).nextSibling;Rc(e).remove(),e=r}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},nn=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,n,r,i,o){this.type=1,this._$AH=_,this._$AN=void 0,this.element=e,this.name=n,this._$AM=i,this.options=o,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);
@@ -203,7 +203,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
min-height: 40px;
}
}
`;var{I:oy}=Lc,hd=t=>t;var fd=t=>t.strings===void 0,pd=()=>document.createComment(""),Ln=(t,e,n)=>{let r=t._$AA.parentNode,i=e===void 0?t._$AB:e._$AA;if(n===void 0){let o=r.insertBefore(pd(),i),s=r.insertBefore(pd(),i);n=new oy(o,s,t,t.options)}else{let o=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(o!==i||l){let a=n._$AA;for(;a!==o;){let c=hd(a).nextSibling;hd(r).insertBefore(a,i),a=c}}}return n},Ct=(t,e,n=t)=>(t._$AI(e,n),t),sy={},md=(t,e=sy)=>t._$AH=e,gd=t=>t._$AH,fo=t=>{t._$AR(),t._$AA.remove()};var _d=(t,e,n)=>{let r=new Map;for(let i=e;i<=n;i++)r.set(t[i],i);return r},Pr=sn(class extends Lt{constructor(t){if(super(t),t.type!==In.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 i=[],o=[],s=0;for(let l of t)i[s]=r?r(l,s):s,o[s]=n(l,s),s++;return{values:o,keys:i}}render(t,e,n){return this.dt(t,e,n).values}update(t,[e,n,r]){let i=gd(t),{values:o,keys:s}=this.dt(e,n,r);if(!Array.isArray(i))return this.ut=s,o;let l=this.ut??=[],a=[],c,u,d=0,p=i.length-1,h=0,f=o.length-1;for(;d<=p&&h<=f;)if(i[d]===null)d++;else if(i[p]===null)p--;else if(l[d]===s[h])a[h]=Ct(i[d],o[h]),d++,h++;else if(l[p]===s[f])a[f]=Ct(i[p],o[f]),p--,f--;else if(l[d]===s[f])a[f]=Ct(i[d],o[f]),Ln(t,a[f+1],i[d]),d++,f--;else if(l[p]===s[h])a[h]=Ct(i[p],o[h]),Ln(t,i[d],i[p]),p--,h++;else if(c===void 0&&(c=_d(s,h,f),u=_d(l,d,p)),c.has(l[d]))if(c.has(l[p])){let g=u.get(s[h]),b=g!==void 0?i[g]:null;if(b===null){let y=Ln(t,i[d]);Ct(y,o[h]),a[h]=y}else a[h]=Ct(b,o[h]),Ln(t,i[d],b),i[g]=null;h++}else fo(i[p]),p--;else fo(i[d]),d++;for(;h<=f;){let g=Ln(t,a[f+1]);Ct(g,o[h]),a[h++]=g}for(;d<=p;){let g=i[d++];g!==null&&fo(g)}return this.ut=s,md(t,a),tt}});var ay=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),ea=-1,yd=[{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"}],bd=t=>t.object_type===1&&yd.some(e=>e.type===t.module_type);function ly(t){let e=new Map(t.map(a=>[a.object_id,a])),n=t.filter(a=>{if(!bd(a))return!1;let c=new Set([a.object_id]),u=e.get(a.parent_id);for(;u&&!c.has(u.object_id);){if(bd(u))return!1;c.add(u.object_id),u=e.get(u.parent_id)}return!0});if(!n.length)return t;let r=new Map(e),i=new Map;for(let a of t){let c=i.get(a.parent_id)??[];c.push(a),i.set(a.parent_id,c)}let o=(a,c,u,d,p)=>({object_id:a,parent_id:c,name:u,path:d,position:p,object_type:0,hidden:!1,icon:"",virtual:!0});r.set(ea,o(ea,0,"System","System",Number.MAX_SAFE_INTEGER));let s=new Set,l=(a,c,u)=>{if(s.has(a.object_id))return;s.add(a.object_id);let d={...a,parent_id:c,path:`${u} / ${a.name}`};r.set(a.object_id,d);for(let p of i.get(a.object_id)??[])l(p,a.object_id,d.path)};return yd.forEach((a,c)=>{let u=n.filter(h=>h.module_type===a.type);if(!u.length)return;let d=-10-a.type,p=`System / ${a.name}`;r.set(d,o(d,ea,a.name,p,c));for(let h of u)l(h,d,p)}),[...r.values()]}function ta(t){let e=ly(t),n=new Map(e.map(i=>[i.object_id,i])),r=new Map;for(let i of e){let o=n.has(i.parent_id)?i.parent_id:0,s=r.get(o)??[];s.push(i),r.set(o,s)}for(let i of r.values())i.sort((o,s)=>o.position-s.position||o.object_type-s.object_type||ay.compare(o.name,s.name));return{nodes:n,children:r}}function na(t,e){let n=[],r=new Set([e]),i=t.nodes.get(e)?.parent_id;for(;i&&!r.has(i)&&t.nodes.has(i);)n.push(i),r.add(i),i=t.nodes.get(i)?.parent_id;return n}function ra(t,e,n=""){let r=n.trim().toLocaleLowerCase("de").split(/\s+/).filter(Boolean),i=r.length?new Set:null;if(i){for(let a of t.nodes.values())if(r.every(c=>`${a.name} ${a.path}`.toLocaleLowerCase("de").includes(c))){i.add(a.object_id);for(let c of na(t,a.object_id))i.add(c)}}let o=[],s=new Set,l=(a,c)=>{let u=(t.children.get(a)??[]).filter(d=>!i||i.has(d.object_id));u.forEach((d,p)=>{if(s.has(d.object_id))return;s.add(d.object_id);let h=(t.children.get(d.object_id)?.length??0)>0,f=h&&(!!i||e.has(d.object_id));o.push({node:d,depth:c,hasChildren:h,expanded:f,index:p+1,siblings:u.length}),f&&l(d.object_id,c+1)})};return l(0,0),o}var vd=["Boolean","Integer","Float","String"],cy={light:"Licht",cover:"Jalousie/Tor",switch:"Schalter",binary_sensor:"Bin\xE4rsensor",sensor:"Sensor",climate:"Heizung",lock:"Schloss",script:"Skript",schedule:"Schaltuhr",media_player:"Medienger\xE4t",fan:"L\xFCfter"};function wd(t,e={}){if(t.virtual||t.object_type===0)return"Das ist eine Kategorie. Klappe sie auf und w\xE4hle den Datenpunkt darunter aus.";if(t.object_type===1)return"Das ist eine Instanz. Klappe sie auf und w\xE4hle ihre Variable aus, zum Beispiel \u201EValue\u201C.";if(e.schedule&&t.object_type!==4)return"Hier wird eine klassische Symcon-Schaltuhr (Wochenplan-Ereignis) erwartet, keine Variable.";if(e.unsupported)return e.unsupported;if(!t.entity_id)return t.object_type===2?"Diese Variable wurde noch nicht geladen. Lade die Variablen oben in der Titelleiste neu und \xF6ffne die Auswahl e Line truncated
`;var{I:oy}=Lc,hd=t=>t;var fd=t=>t.strings===void 0,pd=()=>document.createComment(""),Ln=(t,e,n)=>{let r=t._$AA.parentNode,i=e===void 0?t._$AB:e._$AA;if(n===void 0){let o=r.insertBefore(pd(),i),s=r.insertBefore(pd(),i);n=new oy(o,s,t,t.options)}else{let o=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(o!==i||l){let a=n._$AA;for(;a!==o;){let c=hd(a).nextSibling;hd(r).insertBefore(a,i),a=c}}}return n},Ct=(t,e,n=t)=>(t._$AI(e,n),t),sy={},md=(t,e=sy)=>t._$AH=e,gd=t=>t._$AH,fo=t=>{t._$AR(),t._$AA.remove()};var _d=(t,e,n)=>{let r=new Map;for(let i=e;i<=n;i++)r.set(t[i],i);return r},Pr=sn(class extends Lt{constructor(t){if(super(t),t.type!==In.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 i=[],o=[],s=0;for(let l of t)i[s]=r?r(l,s):s,o[s]=n(l,s),s++;return{values:o,keys:i}}render(t,e,n){return this.dt(t,e,n).values}update(t,[e,n,r]){let i=gd(t),{values:o,keys:s}=this.dt(e,n,r);if(!Array.isArray(i))return this.ut=s,o;let l=this.ut??=[],a=[],c,u,d=0,p=i.length-1,h=0,f=o.length-1;for(;d<=p&&h<=f;)if(i[d]===null)d++;else if(i[p]===null)p--;else if(l[d]===s[h])a[h]=Ct(i[d],o[h]),d++,h++;else if(l[p]===s[f])a[f]=Ct(i[p],o[f]),p--,f--;else if(l[d]===s[f])a[f]=Ct(i[d],o[f]),Ln(t,a[f+1],i[d]),d++,f--;else if(l[p]===s[h])a[h]=Ct(i[p],o[h]),Ln(t,i[d],i[p]),p--,h++;else if(c===void 0&&(c=_d(s,h,f),u=_d(l,d,p)),c.has(l[d]))if(c.has(l[p])){let g=u.get(s[h]),b=g!==void 0?i[g]:null;if(b===null){let y=Ln(t,i[d]);Ct(y,o[h]),a[h]=y}else a[h]=Ct(b,o[h]),Ln(t,i[d],b),i[g]=null;h++}else fo(i[p]),p--;else fo(i[d]),d++;for(;h<=f;){let g=Ln(t,a[f+1]);Ct(g,o[h]),a[h++]=g}for(;d<=p;){let g=i[d++];g!==null&&fo(g)}return this.ut=s,md(t,a),tt}});var ay=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),ta=-1,yd=[{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"}],bd=t=>t.object_type===1&&yd.some(e=>e.type===t.module_type);function ly(t){let e=new Map(t.map(a=>[a.object_id,a])),n=t.filter(a=>{if(!bd(a))return!1;let c=new Set([a.object_id]),u=e.get(a.parent_id);for(;u&&!c.has(u.object_id);){if(bd(u))return!1;c.add(u.object_id),u=e.get(u.parent_id)}return!0});if(!n.length)return t;let r=new Map(e),i=new Map;for(let a of t){let c=i.get(a.parent_id)??[];c.push(a),i.set(a.parent_id,c)}let o=(a,c,u,d,p)=>({object_id:a,parent_id:c,name:u,path:d,position:p,object_type:0,hidden:!1,icon:"",virtual:!0});r.set(ta,o(ta,0,"System","System",Number.MAX_SAFE_INTEGER));let s=new Set,l=(a,c,u)=>{if(s.has(a.object_id))return;s.add(a.object_id);let d={...a,parent_id:c,path:`${u} / ${a.name}`};r.set(a.object_id,d);for(let p of i.get(a.object_id)??[])l(p,a.object_id,d.path)};return yd.forEach((a,c)=>{let u=n.filter(h=>h.module_type===a.type);if(!u.length)return;let d=-10-a.type,p=`System / ${a.name}`;r.set(d,o(d,ta,a.name,p,c));for(let h of u)l(h,d,p)}),[...r.values()]}function na(t){let e=ly(t),n=new Map(e.map(i=>[i.object_id,i])),r=new Map;for(let i of e){let o=n.has(i.parent_id)?i.parent_id:0,s=r.get(o)??[];s.push(i),r.set(o,s)}for(let i of r.values())i.sort((o,s)=>o.position-s.position||o.object_type-s.object_type||ay.compare(o.name,s.name));return{nodes:n,children:r}}function ra(t,e){let n=[],r=new Set([e]),i=t.nodes.get(e)?.parent_id;for(;i&&!r.has(i)&&t.nodes.has(i);)n.push(i),r.add(i),i=t.nodes.get(i)?.parent_id;return n}function ia(t,e,n=""){let r=n.trim().toLocaleLowerCase("de").split(/\s+/).filter(Boolean),i=r.length?new Set:null;if(i){for(let a of t.nodes.values())if(r.every(c=>`${a.name} ${a.path}`.toLocaleLowerCase("de").includes(c))){i.add(a.object_id);for(let c of ra(t,a.object_id))i.add(c)}}let o=[],s=new Set,l=(a,c)=>{let u=(t.children.get(a)??[]).filter(d=>!i||i.has(d.object_id));u.forEach((d,p)=>{if(s.has(d.object_id))return;s.add(d.object_id);let h=(t.children.get(d.object_id)?.length??0)>0,f=h&&(!!i||e.has(d.object_id));o.push({node:d,depth:c,hasChildren:h,expanded:f,index:p+1,siblings:u.length}),f&&l(d.object_id,c+1)})};return l(0,0),o}var vd=["Boolean","Integer","Float","String"],cy={light:"Licht",cover:"Jalousie/Tor",switch:"Schalter",binary_sensor:"Bin\xE4rsensor",sensor:"Sensor",climate:"Heizung",lock:"Schloss",script:"Skript",schedule:"Schaltuhr",media_player:"Medienger\xE4t",fan:"L\xFCfter"};function wd(t,e={}){if(t.virtual||t.object_type===0)return"Das ist eine Kategorie. Klappe sie auf und w\xE4hle den Datenpunkt darunter aus.";if(t.object_type===1)return"Das ist eine Instanz. Klappe sie auf und w\xE4hle ihre Variable aus, zum Beispiel \u201EValue\u201C.";if(e.schedule&&t.object_type!==4)return"Hier wird eine klassische Symcon-Schaltuhr (Wochenplan-Ereignis) erwartet, keine Variable.";if(e.unsupported)return e.unsupported;if(!t.entity_id)return t.object_type===2?"Diese Variable wurde noch nicht geladen. Lade die Variablen oben in der Titelleiste neu und \xF6ffne die Auswahl e Line truncated
aria-level=${e.depth+1} aria-posinset=${e.index} aria-setsize=${e.siblings}
aria-expanded=${e.hasChildren?String(e.expanded):_}
aria-selected=${i?String(n.object_id===this._selected&&r===this._pending):_}
@@ -219,7 +219,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
${this.icon(n.object_type)}<span class="node-name">${n.name||"(Ohne Namen)"}</span>
<small>${n.virtual?"Systembereich":uy[n.object_type]??"Objekt"}${n.hidden?" \xB7 ausgeblendet":""}</small>
${i&&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??""),i=this._selected===null?void 0:this.tree.nodes.get(this._selected),o=(i&&this.entityFor(i)===this._pending?i:void 0)??this.variableNode(this._pending),s=ra(this.tree,this._expanded,this._query),l=s.find(c=>c.node.object_id===this._active),a=!!this.value&&!this.fixed.some(c=>c.id===this.value);return m`<div class="field"><button type="button" class="trigger" ?disabled=${this.disabled} aria-haspopup="dialog" @click=${this.open}>
</div>`}render(){let e=this.allowed.get(this.value??""),n=this.variableNode(this.value),r=this.allowed.get(this._pending??""),i=this._selected===null?void 0:this.tree.nodes.get(this._selected),o=(i&&this.entityFor(i)===this._pending?i:void 0)??this.variableNode(this._pending),s=ia(this.tree,this._expanded,this._query),l=s.find(c=>c.node.object_id===this._active),a=!!this.value&&!this.fixed.some(c=>c.id===this.value);return m`<div class="field"><button type="button" class="trigger" ?disabled=${this.disabled} aria-haspopup="dialog" @click=${this.open}>
<span class="trigger-text"><strong>${n?.name??e?.label??"Datenpunkt ausw\xE4hlen"}</strong>
${n?m`<small title=${n.path}>${n.path}</small>`:_}</span><span class="picker-icon" aria-hidden="true">⌘</span>
</button>${a?m`<button class="clear" type="button" ?disabled=${this.disabled} aria-label="Verknüpfung entfernen" title="Verknüpfung entfernen" @click=${this.clear}>×</button>`:_}</div>
@@ -294,7 +294,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
.tree { margin:0 8px; } .node { gap:6px; padding-left:calc(2px + var(--depth)*18px); }
.node small { display:none; } footer { padding:12px; flex-direction:column; align-items:stretch; } .actions { justify-content:flex-end; }
}
`]};customElements.get("nf-symcon-object-picker")||customElements.define("nf-symcon-object-picker",ia);var kd=40,oa=class extends Y{static properties={options:{attribute:!1},objectTree:{attribute:!1},context:{attribute:!1},fixed:{attribute:!1},value:{attribute:!1},disabled:{type:Boolean},placeholder:{attribute:!1},_query:{state:!0},_open:{state:!0},_cursor:{state:!0}};blurTimer;constructor(){super(),this.options=[],this.objectTree=void 0,this.fixed=[],this.value=null,this.disabled=!1,this.placeholder="",this._query="",this._open=!1,this._cursor=0}get current(){return[...this.fixed,...this.options].find(e=>e.id===this.value)}get hits(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=s=>{let l=`${s.label} ${s.detail??s.id}`.toLowerCase();return n.every(a=>l.includes(a))},i=this.fixed.filter(s=>!e||r(s)),o=e?this.options.filter(r):this.options;return[...i,...o.slice(0,kd)]}get leftOut(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=e?this.options.filter(i=>n.every(o=>`${i.label} ${i.detail??i.id}`.toLowerCase().includes(o))).length:this.options.length;return Math.max(0,r-kd)}choose(e){this.value=e,this._query="",this._open=!1,this.dispatchEvent(new CustomEvent("change",{detail:{value:e},bubbles:!0,composed:!0}))}onKey(e){let n=this.hits;e.key==="ArrowDown"?(this._open=!0,this._cursor=Math.min(n.length-1,this._cursor+1),e.preventDefault()):e.key==="ArrowUp"?(this._cursor=Math.max(0,this._cursor-1),e.preventDefault()):e.key==="Enter"?(this._open&&n[this._cursor]&&this.choose(n[this._cursor].id),e.preventDefault()):e.key==="Escape"&&(this._open=!1,this._query="")}render(){if(this.objectTree!==void 0)return m`<nf-symcon-object-picker
`]};customElements.get("nf-symcon-object-picker")||customElements.define("nf-symcon-object-picker",oa);var kd=40,sa=class extends Y{static properties={options:{attribute:!1},objectTree:{attribute:!1},context:{attribute:!1},fixed:{attribute:!1},value:{attribute:!1},disabled:{type:Boolean},placeholder:{attribute:!1},_query:{state:!0},_open:{state:!0},_cursor:{state:!0}};blurTimer;constructor(){super(),this.options=[],this.objectTree=void 0,this.fixed=[],this.value=null,this.disabled=!1,this.placeholder="",this._query="",this._open=!1,this._cursor=0}get current(){return[...this.fixed,...this.options].find(e=>e.id===this.value)}get hits(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=s=>{let l=`${s.label} ${s.detail??s.id}`.toLowerCase();return n.every(a=>l.includes(a))},i=this.fixed.filter(s=>!e||r(s)),o=e?this.options.filter(r):this.options;return[...i,...o.slice(0,kd)]}get leftOut(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=e?this.options.filter(i=>n.every(o=>`${i.label} ${i.detail??i.id}`.toLowerCase().includes(o))).length:this.options.length;return Math.max(0,r-kd)}choose(e){this.value=e,this._query="",this._open=!1,this.dispatchEvent(new CustomEvent("change",{detail:{value:e},bubbles:!0,composed:!0}))}onKey(e){let n=this.hits;e.key==="ArrowDown"?(this._open=!0,this._cursor=Math.min(n.length-1,this._cursor+1),e.preventDefault()):e.key==="ArrowUp"?(this._cursor=Math.max(0,this._cursor-1),e.preventDefault()):e.key==="Enter"?(this._open&&n[this._cursor]&&this.choose(n[this._cursor].id),e.preventDefault()):e.key==="Escape"&&(this._open=!1,this._query="")}render(){if(this.objectTree!==void 0)return m`<nf-symcon-object-picker
.objects=${this.objectTree} .options=${this.options} .fixed=${this.fixed} .value=${this.value}
.context=${this.context}
.disabled=${this.disabled} .placeholder=${this.placeholder}
@@ -393,7 +393,7 @@ var $={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",oa);var sa=class extends Y{static properties={text:{attribute:!1}};constructor(){super(),this.text=""}get dialog(){return this.renderRoot.querySelector("dialog")}render(){return m`<button class="info" type="button" aria-label="Information anzeigen" aria-haspopup="dialog" title="Information" @click=${()=>this.dialog?.showModal()}>ⓘ</button>
`]};customElements.get("nf-entity-picker")||customElements.define("nf-entity-picker",sa);var aa=class extends Y{static properties={text:{attribute:!1}};constructor(){super(),this.text=""}get dialog(){return this.renderRoot.querySelector("dialog")}render(){return m`<button class="info" type="button" aria-label="Information anzeigen" aria-haspopup="dialog" title="Information" @click=${()=>this.dialog?.showModal()}>ⓘ</button>
<dialog aria-label="Information" @keydown=${e=>e.stopPropagation()} @click=${e=>{if(e.target!==e.currentTarget)return;let n=this.dialog.getBoundingClientRect();(e.clientX<n.left||e.clientX>n.right||e.clientY<n.top||e.clientY>n.bottom)&&this.dialog?.close()}}>
<header><b>Information</b><button class="close" type="button" aria-label="Schließen" @click=${()=>this.dialog?.close()}>×</button></header>
<p>${this.text}</p>
@@ -408,7 +408,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
header { display:flex; align-items:center; justify-content:space-between; gap:20px; font-size:16px; }
.close { width:30px; height:30px; padding:0; font-size:23px; }
p { white-space:pre-wrap; overflow-wrap:anywhere; margin:16px 0 4px; }
`]};customElements.get("nf-help-popup")||customElements.define("nf-help-popup",sa);var an=t=>t.target.value,aa=t=>Number.parseFloat(t.replace(",",".")),ae=t=>Math.round(t*1e3)/1e3,xd=t=>t.wide?"nf-field nf-wide":"nf-field";function E(t,e,n,r,i=.01,o){return m`<label class="nf-field"
`]};customElements.get("nf-help-popup")||customElements.define("nf-help-popup",aa);var an=t=>t.target.value,la=t=>Number.parseFloat(t.replace(",",".")),ae=t=>Math.round(t*1e3)/1e3,xd=t=>t.wide?"nf-field nf-wide":"nf-field";function E(t,e,n,r,i=.01,o){return m`<label class="nf-field"
>${e}
<input
type="number"
@@ -417,7 +417,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
min=${o??_}
.value=${String(ae(n))}
?disabled=${!t.admin}
@change=${s=>{let l=aa(an(s));Number.isFinite(l)&&r(l)}}
@change=${s=>{let l=la(an(s));Number.isFinite(l)&&r(l)}}
/>
</label>`}function V(t,e,n,r,i={}){return m`<label class=${xd(i)} title=${i.title??_}
>${e}
@@ -478,7 +478,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
?disabled=${!t.admin}
@change=${o=>{let s=Number(an(o)),l=Math.min(150,Math.max(i,an(o).trim()===""||Number.isNaN(s)?100:s))/100;n(Math.abs(l-1)<.001?null:l)}}
/>
</label>`}var rt=(t,e,n={})=>t.callWS({type:`nextfloor/${e}`,...n});async function mo(t,e){return(await rt(t,"image/get",{image_id:e})).data}async function Wt(t,e,n){await rt(t,"image/set",{image_id:e,data:n})}async function $d(t){return(await rt(t,"history/list")).snapshots}async function Sd(t,e){return(await rt(t,"history/snapshot",e?{name:e}:{})).id}async function Md(t,e){return(await rt(t,"history/get",{snapshot_id:e})).building}async function Rd(t,e){await rt(t,"history/delete",{snapshot_id:e})}async function Ed(t,e){return(await rt(t,"history/restore",{snapshot_id:e})).revision}var Dr=(t,e)=>rt(t,"packs/import",{pack:e});async function Ad(t,e){await rt(t,"packs/remove",{pack_id:e})}var Fd=t=>rt(t,"backup/export"),Td=(t,e,n)=>rt(t,"backup/import",{building:e,packs:n});var U=(t,e)=>[t[0]-e[0],t[1]-e[1]],ft=(t,e)=>[t[0]+e[0],t[1]+e[1]],it=(t,e)=>[t[0]*e,t[1]*e],te=(t,e)=>t[0]*e[0]+t[1]*e[1],Re=(t,e)=>t[0]*e[1]-t[1]*e[0],ge=t=>Math.hypot(t[0],t[1]),ot=t=>{let e=ge(t)||1;return[t[0]/e,t[1]/e]},la=t=>[-t[1],t[0]],ca=t=>[t[1],-t[0]];var dy=.05,hy=.2,py=.12;function fy(t){let e=[];return t.forEach((n,r)=>{let i=n.points;if(i.length<3)return;let o=_e(i)>=0;i.forEach((s,l)=>{let a=i[(l+1)%i.length],c=ge(U(a,s));if(c<.05)return;let u=[(a[0]-s[0])/c,(a[1]-s[1])/c],d=o?[u[1],-u[0]]:[-u[1],u[0]];(u[1]<-1e-9||Math.abs(u[1])<=1e-9&&u[0]<0)&&(u=[-u[0],-u[1]]);let p=[-u[1],u[0]],[h,f]=[te(s,u),te(a,u)];e.push({room:r,index:l,dir:u,normal:p,offset:te(s,p),outside:te(d,p)>0?1:-1,from:Math.min(h,f),to:Math.max(h,f)})})}),e}function my(t,e,n){if(t.room===e.room||Math.abs(Re(t.dir,e.dir))>dy||t.outside===e.outside)return null;let r=(e.offset-t.offset)*t.outside;return r>n||r<-py||Math.abs(r)<1e-4||Math.min(t.to,e.to)-Math.max(t.from,e.from)<hy?null:r}var ua=t=>Math.round(t*1e3)/1e3;function zd(t,e=.6){let n=fy(t),r=n.map((g,b)=>b),i=g=>r[g]===g?g:r[g]=i(r[g]),o=[],s=new Set,l=[];for(let g=0;g<n.length;g++)for(let b=g+1;b<n.length;b++){let y=my(n[g],n[b],e);y!==null&&l.push([g,b,y])}l.sort((g,b)=>Math.abs(g[2])-Math.abs(b[2]));let a=new Map(n.map((g,b)=>[b,[b]])),c=(g,b)=>g.some(y=>b.some(v=>n[y].room===n[v].room&&Math.abs(n[y].offset-n[v].offset)>=.002));for(let[g,b,y]of l){let[v,w]=[i(g),i(b)];if(v!==w){if(c(a.get(v),a.get(w)))continue;r[v]=w,a.set(w,[...a.get(w),...a.get(v)]),a.delete(v)}o.push(ua(y)),s.add(g).add(b)}let u=new Map(n.map((g,b)=>[`${g.room}:${g.index}`,b]));for(let g=s.size>0;g;)g=!1,n.forEach((b,y)=>{let v=u.get(`${b.room}:${(b.index+1)%t[b.room].points.length}`);if(v===void 0||v===y)return;let w=n[v];!(Math.abs(Re(b.dir,w.dir))<1e-6&&Math.abs(b.offset-w.offset)<.002&&b.outside===w.outside)||s.has(y)===s.has(v)||(s.add(y).add(v),g=!0)});n.forEach((g,b)=>{let y=u.get(`${g.room}:${(g.index+1)%t[g.room].points.length}`);if(y===void 0||y===b||!s.has(b)||!s.has(y))return;let v=n[y];Math.abs(Re(g.dir,v.dir))<1e-6&&Math.abs(g.offset-v.offset)<.002&&g.outside===v.outside&&(r[i(b)]=i(y))});let d=()=>t.map(g=>({...g,points:g.points.map(b=>[b[0],b[1]])}));if(o.length===0)return{rooms:d(),gaps:o};let p=new Map;for(let g of s)p.set(i(g),[...p.get(i(g))??[],g]);let h=t.map(g=>g.points.map(()=>new Map));for(let[g,b]of p){let y=new Map(b.map(w=>[`${n[w].room}:${Math.round(n[w].offset*500)}`,n[w].offset])),v=[...y.values()].reduce((w,x)=>w+x,0)/y.size;for(let w of b){let x=n[w],k=[x.normal[0]*(v-x.offset),x.normal[1]*(v-x.offset)];h[x.room][x.index].set(g,k),h[x.room][(x.index+1)%t[x.room].points.length].set(g,k)}}return{rooms:t.map((g,b)=>({...g,points:g.points.map((y,v)=>{let w=[...h[b][v].values()].reduce((x,k)=>[x[0]+k[0],x[1]+k[1]],[y[0],y[1]]);return[ua(w[0]),ua(w[1])]})})),gaps:o}}function Pd(t){let e=t.filter(n=>n>.04).sort((n,r)=>n-r);return e.length===0?null:Math.min(.5,Math.max(.08,Math.round(e[Math.floor(e.length/2)]*100)/100))}var gy=.25,Dd=t=>Math.round(t*1e3)/1e3,Id=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function ha(t,e,n,r,i){let o=Id(t,e,n);if(!o)return[r,i];let s=(l,a)=>C([l,a],o.points);return s(r,i)?[r,i]:s(r,n)?[r,n]:s(e,i)?[e,i]:[e,n]}function _y(t,e,n,r){return t.rooms.some(i=>i.id!==e.id&&i.points.some((o,s)=>{let l=i.points[(s+1)%i.points.length];return Math.abs(te(U(o,n),r))<.02&&Math.abs(te(U(l,n),r))<.02}))}var da=(t,e)=>Math.abs((t-e+540)%360-180);function Ir(t,e,n,r=gy){let i=Id(t,e.x,e.z);if(!i)return null;let o=i.points,s=_e(o)>=0?1:-1,l=null;return o.forEach((a,c)=>{let u=o[(c+1)%o.length],d=ge(U(u,a));if(d<.3)return;let p=[(u[0]-a[0])/d,(u[1]-a[1])/d],h=[-p[1]*s,p[0]*s],f=te(U([e.x,e.z],a),p);if(f<0||f>d)return;let g=_y(t,i,a,h)?n/2:0,b=te(U([e.x,e.z],a),h)-g,y=Math.atan2(-h[0],h[1])*180/Math.PI,w=[{rotation:y,extent:e.d/2},{rotation:y+90,extent:e.w/2},{rotation:y-90,extent:e.w/2}].reduce((k,M)=>da(e.rotation,M.rotation)<da(e.rotation,k.rotation)?M:k);if(da(e.rotation,w.rotation)>50)return;let x=b-w.extent;Math.abs(x)>r||l&&Math.abs(x)>=Math.abs(l.gap)||(l={x:Dd(e.x-h[0]*x),z:Dd(e.z-h[1]*x),rotation:(Math.round(w.rotation)%360+360)%360,gap:x})}),l&&{x:l.x,z:l.z, Line truncated
</label>`}var rt=(t,e,n={})=>t.callWS({type:`nextfloor/${e}`,...n});async function mo(t,e){return(await rt(t,"image/get",{image_id:e})).data}async function Wt(t,e,n){await rt(t,"image/set",{image_id:e,data:n})}async function $d(t){return(await rt(t,"history/list")).snapshots}async function Sd(t,e){return(await rt(t,"history/snapshot",e?{name:e}:{})).id}async function Md(t,e){return(await rt(t,"history/get",{snapshot_id:e})).building}async function Rd(t,e){await rt(t,"history/delete",{snapshot_id:e})}async function Ed(t,e){return(await rt(t,"history/restore",{snapshot_id:e})).revision}var Dr=(t,e)=>rt(t,"packs/import",{pack:e});async function Ad(t,e){await rt(t,"packs/remove",{pack_id:e})}var Fd=t=>rt(t,"backup/export"),Td=(t,e,n)=>rt(t,"backup/import",{building:e,packs:n});var U=(t,e)=>[t[0]-e[0],t[1]-e[1]],ft=(t,e)=>[t[0]+e[0],t[1]+e[1]],it=(t,e)=>[t[0]*e,t[1]*e],te=(t,e)=>t[0]*e[0]+t[1]*e[1],Re=(t,e)=>t[0]*e[1]-t[1]*e[0],ge=t=>Math.hypot(t[0],t[1]),ot=t=>{let e=ge(t)||1;return[t[0]/e,t[1]/e]},ca=t=>[-t[1],t[0]],ua=t=>[t[1],-t[0]];var dy=.05,hy=.2,py=.12;function fy(t){let e=[];return t.forEach((n,r)=>{let i=n.points;if(i.length<3)return;let o=_e(i)>=0;i.forEach((s,l)=>{let a=i[(l+1)%i.length],c=ge(U(a,s));if(c<.05)return;let u=[(a[0]-s[0])/c,(a[1]-s[1])/c],d=o?[u[1],-u[0]]:[-u[1],u[0]];(u[1]<-1e-9||Math.abs(u[1])<=1e-9&&u[0]<0)&&(u=[-u[0],-u[1]]);let p=[-u[1],u[0]],[h,f]=[te(s,u),te(a,u)];e.push({room:r,index:l,dir:u,normal:p,offset:te(s,p),outside:te(d,p)>0?1:-1,from:Math.min(h,f),to:Math.max(h,f)})})}),e}function my(t,e,n){if(t.room===e.room||Math.abs(Re(t.dir,e.dir))>dy||t.outside===e.outside)return null;let r=(e.offset-t.offset)*t.outside;return r>n||r<-py||Math.abs(r)<1e-4||Math.min(t.to,e.to)-Math.max(t.from,e.from)<hy?null:r}var da=t=>Math.round(t*1e3)/1e3;function zd(t,e=.6){let n=fy(t),r=n.map((g,b)=>b),i=g=>r[g]===g?g:r[g]=i(r[g]),o=[],s=new Set,l=[];for(let g=0;g<n.length;g++)for(let b=g+1;b<n.length;b++){let y=my(n[g],n[b],e);y!==null&&l.push([g,b,y])}l.sort((g,b)=>Math.abs(g[2])-Math.abs(b[2]));let a=new Map(n.map((g,b)=>[b,[b]])),c=(g,b)=>g.some(y=>b.some(v=>n[y].room===n[v].room&&Math.abs(n[y].offset-n[v].offset)>=.002));for(let[g,b,y]of l){let[v,w]=[i(g),i(b)];if(v!==w){if(c(a.get(v),a.get(w)))continue;r[v]=w,a.set(w,[...a.get(w),...a.get(v)]),a.delete(v)}o.push(da(y)),s.add(g).add(b)}let u=new Map(n.map((g,b)=>[`${g.room}:${g.index}`,b]));for(let g=s.size>0;g;)g=!1,n.forEach((b,y)=>{let v=u.get(`${b.room}:${(b.index+1)%t[b.room].points.length}`);if(v===void 0||v===y)return;let w=n[v];!(Math.abs(Re(b.dir,w.dir))<1e-6&&Math.abs(b.offset-w.offset)<.002&&b.outside===w.outside)||s.has(y)===s.has(v)||(s.add(y).add(v),g=!0)});n.forEach((g,b)=>{let y=u.get(`${g.room}:${(g.index+1)%t[g.room].points.length}`);if(y===void 0||y===b||!s.has(b)||!s.has(y))return;let v=n[y];Math.abs(Re(g.dir,v.dir))<1e-6&&Math.abs(g.offset-v.offset)<.002&&g.outside===v.outside&&(r[i(b)]=i(y))});let d=()=>t.map(g=>({...g,points:g.points.map(b=>[b[0],b[1]])}));if(o.length===0)return{rooms:d(),gaps:o};let p=new Map;for(let g of s)p.set(i(g),[...p.get(i(g))??[],g]);let h=t.map(g=>g.points.map(()=>new Map));for(let[g,b]of p){let y=new Map(b.map(w=>[`${n[w].room}:${Math.round(n[w].offset*500)}`,n[w].offset])),v=[...y.values()].reduce((w,x)=>w+x,0)/y.size;for(let w of b){let x=n[w],k=[x.normal[0]*(v-x.offset),x.normal[1]*(v-x.offset)];h[x.room][x.index].set(g,k),h[x.room][(x.index+1)%t[x.room].points.length].set(g,k)}}return{rooms:t.map((g,b)=>({...g,points:g.points.map((y,v)=>{let w=[...h[b][v].values()].reduce((x,k)=>[x[0]+k[0],x[1]+k[1]],[y[0],y[1]]);return[da(w[0]),da(w[1])]})})),gaps:o}}function Pd(t){let e=t.filter(n=>n>.04).sort((n,r)=>n-r);return e.length===0?null:Math.min(.5,Math.max(.08,Math.round(e[Math.floor(e.length/2)]*100)/100))}var gy=.25,Dd=t=>Math.round(t*1e3)/1e3,Id=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function pa(t,e,n,r,i){let o=Id(t,e,n);if(!o)return[r,i];let s=(l,a)=>C([l,a],o.points);return s(r,i)?[r,i]:s(r,n)?[r,n]:s(e,i)?[e,i]:[e,n]}function _y(t,e,n,r){return t.rooms.some(i=>i.id!==e.id&&i.points.some((o,s)=>{let l=i.points[(s+1)%i.points.length];return Math.abs(te(U(o,n),r))<.02&&Math.abs(te(U(l,n),r))<.02}))}var ha=(t,e)=>Math.abs((t-e+540)%360-180);function Ir(t,e,n,r=gy){let i=Id(t,e.x,e.z);if(!i)return null;let o=i.points,s=_e(o)>=0?1:-1,l=null;return o.forEach((a,c)=>{let u=o[(c+1)%o.length],d=ge(U(u,a));if(d<.3)return;let p=[(u[0]-a[0])/d,(u[1]-a[1])/d],h=[-p[1]*s,p[0]*s],f=te(U([e.x,e.z],a),p);if(f<0||f>d)return;let g=_y(t,i,a,h)?n/2:0,b=te(U([e.x,e.z],a),h)-g,y=Math.atan2(-h[0],h[1])*180/Math.PI,w=[{rotation:y,extent:e.d/2},{rotation:y+90,extent:e.w/2},{rotation:y-90,extent:e.w/2}].reduce((k,M)=>ha(e.rotation,M.rotation)<ha(e.rotation,k.rotation)?M:k);if(ha(e.rotation,w.rotation)>50)return;let x=b-w.extent;Math.abs(x)>r||l&&Math.abs(x)>=Math.abs(l.gap)||(l={x:Dd(e.x-h[0]*x),z:Dd(e.z-h[1]*x),rotation:(Math.round(w.rotation)%360+360)%360,gap:x})}),l&&{x:l.x,z:l.z, Line truncated
${S("Nur direkt zugewiesene Raumz\xE4hler erscheinen als einger\xFCckte Raumzeile unter dem verkn\xFCpften Bereich. Die Bereichswerte stehen einmal beim Bereich; vorhandene Bereichssummen enthalten die Raumwerte bereits. Fehlt dem Bereich ein passender Z\xE4hler, werden daf\xFCr die eigenen Raumz\xE4hler summiert.","nf-wide")}
${wt.map(i=>m`<b class="nf-wide">${Jn[i]} ${St[i]}</b>${["power","energy"].map(o=>z(t,o==="power"?"Leistung / Durchfluss":"Energie / Verbrauch",e.utility_meters?.[i]?.[o]??null,void 0,r,s=>{let l={...e.utility_meters,[i]:{...e.utility_meters?.[i],[o]:s==="none"?null:s}};Object.values(l[i]).some(a=>a&&a!=="none")||delete l[i],n({utility_meters:Object.keys(l).length?l:null})},{types:[1,2]}))}`)}
</div></details>`}function Sh(t,e,n){let r=s=>n({hvac:{...e.hvac,...s}}),i=e.hvac?.schedules??[],o=O(t.hass,s=>!!t.hass?.states[s]?.attributes.symcon_schedule);return m`
@@ -500,14 +500,14 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
</div>`)}
<div class="nf-form">${z(t,"Person hinzuf\xFCgen (Boolean)",null,void 0,o.filter(s=>!e.some(l=>l.person===s.id)),s=>s&&s!=="none"&&n([...e,{person:s,sensor:null}]),{types:[0],excluded:s=>e.some(l=>l.person===s)?"Diese Anwesenheitsvariable ist bereits mit einer Person verkn\xFCpft.":void 0})}</div>
${S("Jede Person wird mit einer beliebigen Boolean-Variable verkn\xFCpft: true bedeutet anwesend, false abwesend. Ein Raum ist optional und bestimmt die Position der Person in 3D.")}
</details>`}function Eh(t,e,n){let r=t.find(a=>a.person===e),i="sensor"in n?n.sensor&&n.sensor!=="none"?n.sensor:null:r?.sensor??null,o="room"in n?n.room||null:r?.room??null,s=t.filter(a=>a.person!==e);if(!i&&!o)return s;let l=o?{person:e,sensor:i,room:o}:{person:e,sensor:i};return r?t.map(a=>a.person===e?l:a):[...s,l]}function Ah(t,e){let n=e.slice(e.indexOf(".")+1),r=i=>i.id.includes(n)&&/(area|room|raum|bermuda|espresense)/.test(i.id);return[...t.filter(r),...t.filter(i=>!r(i))]}function Fh(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 Th(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 Do(t,e,n){let r=[...t],[i]=r.splice(e,1);return r.splice(Math.max(0,Math.min(r.length,e+n)),0,i),r}var Ut=(t,e)=>t.filter((n,r)=>r!==e),di=(t,e,n)=>t.map((r,i)=>i===e?{...r,...n}:r),gt=t=>t.length>0?t:void 0;var lv=["scene","script","automation","button","input_button","switch","input_boolean","light","fan","cover","lock"],cv=40,uv=20,dv=30,hv=["music","url","playlist","SPOTIFY","AMAZON_MUSIC","TUNEIN","APPLE_MUSIC"],qa={navigate:"/lovelace/rollos",more_info:"cover.wohnzimmer",service:"script.turn_on",fire_dom_event:""},hi=(t,e,n,r=!1)=>m`<button class="nf-pin" title=${t} ?disabled=${r} @click=${n}>${e}</button>`;function pv(t){let e=t.doc.settings.favorites??[],n=l=>t.change(a=>a.settings.favorites=gt(l)),r=t.doc.floors,i=t.doc.settings.favorite_floors??{},o=O(t.hass,l=>lv.includes(l.split(".")[0])&&!e.includes(l)),s=(l,a)=>m`<div class="nf-row nf-dev-row">
</details>`}function Eh(t,e,n){let r=t.find(a=>a.person===e),i="sensor"in n?n.sensor&&n.sensor!=="none"?n.sensor:null:r?.sensor??null,o="room"in n?n.room||null:r?.room??null,s=t.filter(a=>a.person!==e);if(!i&&!o)return s;let l=o?{person:e,sensor:i,room:o}:{person:e,sensor:i};return r?t.map(a=>a.person===e?l:a):[...s,l]}function Ah(t,e){let n=e.slice(e.indexOf(".")+1),r=i=>i.id.includes(n)&&/(area|room|raum|bermuda|espresense)/.test(i.id);return[...t.filter(r),...t.filter(i=>!r(i))]}function Fh(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 Th(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 Io(t,e,n){let r=[...t],[i]=r.splice(e,1);return r.splice(Math.max(0,Math.min(r.length,e+n)),0,i),r}var Ut=(t,e)=>t.filter((n,r)=>r!==e),di=(t,e,n)=>t.map((r,i)=>i===e?{...r,...n}:r),gt=t=>t.length>0?t:void 0;var lv=["scene","script","automation","button","input_button","switch","input_boolean","light","fan","cover","lock"],cv=40,uv=20,dv=30,hv=["music","url","playlist","SPOTIFY","AMAZON_MUSIC","TUNEIN","APPLE_MUSIC"],qa={navigate:"/lovelace/rollos",more_info:"cover.wohnzimmer",service:"script.turn_on",fire_dom_event:""},hi=(t,e,n,r=!1)=>m`<button class="nf-pin" title=${t} ?disabled=${r} @click=${n}>${e}</button>`;function pv(t){let e=t.doc.settings.favorites??[],n=l=>t.change(a=>a.settings.favorites=gt(l)),r=t.doc.floors,i=t.doc.settings.favorite_floors??{},o=O(t.hass,l=>lv.includes(l.split(".")[0])&&!e.includes(l)),s=(l,a)=>m`<div class="nf-row nf-dev-row">
<span class="nf-dev-name"><span>${B(t.hass,l)}</span></span>
${r.length>1?m`<select title=${t.t("favorite_floor")} .value=${i[l]??""} @change=${c=>{let u=c.target.value,d={...i};u?d[l]=u:delete d[l],t.change(p=>p.settings.favorite_floors=Object.keys(d).length?d:void 0)}}>
<option value="">${t.t("favorite_all_floors")}</option>
${r.map(c=>m`<option value=${c.id} ?selected=${i[l]===c.id}>${c.name}</option>`)}
</select>`:_}
${hi(t.t("move_up"),"\u2191",()=>n(Do(e,a,-1)),a===0)}
${hi(t.t("move_down"),"\u2193",()=>n(Do(e,a,1)),a===e.length-1)}
${hi(t.t("move_up"),"\u2191",()=>n(Io(e,a,-1)),a===0)}
${hi(t.t("move_down"),"\u2193",()=>n(Io(e,a,1)),a===e.length-1)}
${hi(t.t("delete"),"\u2715",()=>n(Ut(e,a)))}
</div>`;return m`<summary>${t.t("favorites")}${e.length>0?m` <span class="nf-lib-count">${e.length}</span>`:_}</summary>
${S(t.t("favorites_hint"))} ${e.map(s)}
@@ -568,7 +568,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
${s.action==="service"||s.action==="fire_dom_event"?Ya(t,s,a=>r(l,{data:a})):_}
${z(t,t.t("own_button_state"),s.state_entity??null,void 0,O(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(Do(e,l,-1))}>↑</button>
<button class="nf-btn" ?disabled=${l===0} @click=${()=>n(Io(e,l,-1))}>↑</button>
<button class="nf-btn nf-danger" @click=${()=>n(Ut(e,l))}>${t.t("delete")}</button>
</div>
</div>`;return m`<h4>${t.t("own_buttons")}</h4>
@@ -597,7 +597,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
<summary>${t.t("ble")}</summary>
${S(t.t("ble_hint"))}
<nf-ble-locate .host=${t} .doc=${e}></nf-ble-locate>
</details>`}var pi=(t,e)=>{let n=t._$AN;if(n===void 0)return!1;for(let r of n)r._$AO?.(e,!1),pi(r,e);return!0},Io=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while(n?.size===0)},Hh=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),Sv(e)}};function xv(t){this._$AN!==void 0?(Io(this),this._$AM=t,Hh(this)):this._$AM=t}function $v(t,e=!1,n=0){let r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let o=n;o<r.length;o++)pi(r[o],!1),Io(r[o]);else r!=null&&(pi(r,!1),Io(r));else pi(this,t)}var Sv=t=>{t.type==In.CHILD&&(t._$AP??=$v,t._$AQ??=xv)},Oo=class extends Lt{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),Hh(this),this.isConnected=e._$AU}_$AO(e,n=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),n&&(pi(this,e),Io(this))}setValue(e){if(fd(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 Xa=new WeakMap,Lh=sn(class extends Oo{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=Xa.get(e);n===void 0&&(n=new WeakMap,Xa.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"?Xa.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 Ch=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 Nh(t){let e=t.t,n=t.doc.settings.card_templates??{},r=Object.keys(n),i=l=>t.change(a=>{a.settings.card_templates=Object.keys(l).length?l:void 0});t.loadCardEditor?.();let o=l=>{t.hass?.callService("nextfloor","reload_screens",l?{template:l}:{})},s=l=>{let a=Ch(l.value);!a||a in n||r.length>=20||(l.value="",i({...n,[a]:{}}))};return m`<details class="nf-section">
</details>`}var pi=(t,e)=>{let n=t._$AN;if(n===void 0)return!1;for(let r of n)r._$AO?.(e,!1),pi(r,e);return!0},Oo=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while(n?.size===0)},Hh=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),Sv(e)}};function xv(t){this._$AN!==void 0?(Oo(this),this._$AM=t,Hh(this)):this._$AM=t}function $v(t,e=!1,n=0){let r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let o=n;o<r.length;o++)pi(r[o],!1),Oo(r[o]);else r!=null&&(pi(r,!1),Oo(r));else pi(this,t)}var Sv=t=>{t.type==In.CHILD&&(t._$AP??=$v,t._$AQ??=xv)},Ho=class extends Lt{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),Hh(this),this.isConnected=e._$AU}_$AO(e,n=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),n&&(pi(this,e),Oo(this))}setValue(e){if(fd(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 Xa=new WeakMap,Lh=sn(class extends Ho{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=Xa.get(e);n===void 0&&(n=new WeakMap,Xa.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"?Xa.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 Ch=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 Nh(t){let e=t.t,n=t.doc.settings.card_templates??{},r=Object.keys(n),i=l=>t.change(a=>{a.settings.card_templates=Object.keys(l).length?l:void 0});t.loadCardEditor?.();let o=l=>{t.hass?.callService("nextfloor","reload_screens",l?{template:l}:{})},s=l=>{let a=Ch(l.value);!a||a in n||r.length>=20||(l.value="",i({...n,[a]:{}}))};return m`<details class="nf-section">
<summary>${e("card_templates")}${r.length?m` <span class="nf-lib-count">${r.length}</span>`:_}</summary>
${S(e("card_templates_hint"))}
${r.map(l=>m`<details class="nf-section">
@@ -620,7 +620,7 @@ var $={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=${()=>o()}>${e("template_reload_all")}</button>
</div>`:_}
</details>`}var Ho=.05,Mv=(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),bn=t=>new Map(t.map(e=>[e.id,e]));function Rv(t,e,n,r){let i=e.name,[o,s]=[bn(t.rooms),bn(e.rooms)];for(let h of e.rooms){let f=o.get(h.id);f?(f.name!==h.name&&n.push({kind:"room_renamed",floor:i,name:h.name,detail:f.name}),Mv(f.points,h.points)||n.push({kind:"room_reshaped",floor:i,name:h.name,detail:Math.round((xe(h.points)-xe(f.points))*10)/10})):n.push({kind:"room_added",floor:i,name:h.name})}for(let h of t.rooms)s.has(h.id)||n.push({kind:"room_removed",floor:i,name:h.name});let[l,a]=[bn(t.openings),bn(e.openings)];for(let h of e.openings)l.has(h.id)||n.push({kind:"opening_added",floor:i,name:h.type,detail:r(h.room_id)});for(let h of t.openings)a.has(h.id)||n.push({kind:"opening_removed",floor:i,name:h.type,detail:r(h.room_id)});let[c,u]=[bn(t.furniture),bn(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)>Ho||Math.abs(h.rotation-f.rotation)>1||Math.abs(h.w-f.w)>Ho||Math.abs(h.d-f.d)>Ho)&&n.push({kind:"furniture_moved",floor:i,name:h.name||h.type}):n.push({kind:"furniture_added",floor:i,name:h.name||h.type})}for(let h of t.furniture)u.has(h.id)||n.push({kind:"furniture_removed",floor:i,name:h.name||h.type});let[d,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=d.get(h.entity_id);f?Math.hypot(h.x-f.x,h.z-f.z)>Ho&&n.push({kind:"device_moved",floor:i,name:h.entity_id}):n.push({kind:"device_added",floor:i,name:h.entity_id})}for(let h of t.placements)p.has(h.entity_id)||n.push({kind:"device_removed",floor:i,name:h.entity_id})}function Bh(t,e){let n=[],r=bn(t.floors),i=new Map([...t.floors,...e.floors].flatMap(l=>l.rooms.map(a=>[a.id,a.name]))),o=l=>i.get(l)??"";for(let l of e.floors){let a=r.get(l.id);a?Rv(a,l,n,o):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 yn=(t,e)=>t.getUint16(e,!0),fi=(t,e)=>t.getUint32(e,!0);function Wh(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(fi(e,l)===101010256){n=l;break}if(n<0)throw new Error("not_zip");let r=yn(e,n+10),i=fi(e,n+16),o=[],s=new TextDecoder;for(let l=0;l<r;l++){if(fi(e,i)!==33639248)throw new Error("not_zip");let a=yn(e,i+10),c=fi(e,i+20),u=yn(e,i+28),d=yn(e,i+30),p=yn(e,i+32),h=fi(e,i+42),f=s.decode(t.subarray(i+46,i+46+u)),g=h+30+yn(e,h+26)+yn(e,h+28);o.push({name:f,method:a,compressedSize:c,offset:g}),i+=46+u+d+p}return o}async function Vh(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 Ev={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"},Av=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)):Ev[n]??e);function Fv(t){let e={};for(let n of t.matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))e[n[1]]=Av(n[2]??n[3]);return e}function Tv(t){let e=[],n=null;for(let r of t.matchAll(/<(\/?)(level|room|point|wall|doorOrWindow|pieceOfFurniture)\b([^>]*?)(\/?)>/g)){let[,i,o,s,l]=r;if(i){o==="room"&&(n=null);continue}let a=Fv(s);if(o==="point"){n&&n.points.push([Number(a.x)/100,Number(a.y)/100]);continue}let c={name:o,attrs:a,...o==="room"?{points:[]}:{}};e.push(c),o==="room"&&!l&&(n=c)}return e}var oe=(t,e,n)=>Number.isFinite(Number(t[e]))&&t[e]!==void 0?Number(t[e]):n,Te=t=>Math.round(t*1e3)/1e3;function Kh(t,e,n){let[r,i]=[n[0]-e[0],n[1]-e[1]],o=Math.hypot(r,i)||1e-9,s=Math.max(0,Math.min(o,((t[0]-e[0])*r+(t[1]-e[1])*i)/o)),l=[e[0]+r*s/o,e[1]+i*s/o];return{dist:Math.hypot(t[0]-l[0],t[1]-l[1]),along:s,length:o}}function zv(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 Pv(t,e){let n=t.length,r=t.map((i,o)=>{let s=t[(o+1)%n],[l,a]=[s[0]-i[0],s[1]-i[1]],c=Math.hypot(l,a)||1e-9,u=[l/c,a/c],d=[(i[0]+s[0])/2,(i[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]],b=Math.hypot(f,g)||1e-9;if(Math.abs((u[0]*g-u[1]*f)/b)>.05)continue;let y=(h.a[0]-d[0])*-u[1]+(h.a[1]-d[1])*u[0],v=((d[0]-h.a[0])*f+(d[1]-h.a[1])*g)/b;if(!(Math.abs(y)>h.thickness/2+.06||v<-.05||v>b+.05)){p=[-u[1]*y,u[0]*y];break}}return{p:[i[0]+p[0],i[1]+p[1]],dir:u}});return r.map((i,o)=>{let s=r[(o-1+n)%n],l=s.dir[0]*i.dir[1]-s.dir[1]*i.dir[0];if(Math.abs(l)<1e-6)return i.p;let a=((i.p[0]-s.p[0])*i.dir[1]-(i.p[1]-s.p[1])*i.dir[0])/l;return[s.p[0]+s.dir[0]*a,s.p[1]+s.dir[1]*a]})}function Dv(t){let e=Pt(),n={floors:0,rooms:0,openings:0,walls:0,furniture:0}Line truncated
</details>`}var Lo=.05,Mv=(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),bn=t=>new Map(t.map(e=>[e.id,e]));function Rv(t,e,n,r){let i=e.name,[o,s]=[bn(t.rooms),bn(e.rooms)];for(let h of e.rooms){let f=o.get(h.id);f?(f.name!==h.name&&n.push({kind:"room_renamed",floor:i,name:h.name,detail:f.name}),Mv(f.points,h.points)||n.push({kind:"room_reshaped",floor:i,name:h.name,detail:Math.round((xe(h.points)-xe(f.points))*10)/10})):n.push({kind:"room_added",floor:i,name:h.name})}for(let h of t.rooms)s.has(h.id)||n.push({kind:"room_removed",floor:i,name:h.name});let[l,a]=[bn(t.openings),bn(e.openings)];for(let h of e.openings)l.has(h.id)||n.push({kind:"opening_added",floor:i,name:h.type,detail:r(h.room_id)});for(let h of t.openings)a.has(h.id)||n.push({kind:"opening_removed",floor:i,name:h.type,detail:r(h.room_id)});let[c,u]=[bn(t.furniture),bn(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)>Lo||Math.abs(h.rotation-f.rotation)>1||Math.abs(h.w-f.w)>Lo||Math.abs(h.d-f.d)>Lo)&&n.push({kind:"furniture_moved",floor:i,name:h.name||h.type}):n.push({kind:"furniture_added",floor:i,name:h.name||h.type})}for(let h of t.furniture)u.has(h.id)||n.push({kind:"furniture_removed",floor:i,name:h.name||h.type});let[d,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=d.get(h.entity_id);f?Math.hypot(h.x-f.x,h.z-f.z)>Lo&&n.push({kind:"device_moved",floor:i,name:h.entity_id}):n.push({kind:"device_added",floor:i,name:h.entity_id})}for(let h of t.placements)p.has(h.entity_id)||n.push({kind:"device_removed",floor:i,name:h.entity_id})}function Bh(t,e){let n=[],r=bn(t.floors),i=new Map([...t.floors,...e.floors].flatMap(l=>l.rooms.map(a=>[a.id,a.name]))),o=l=>i.get(l)??"";for(let l of e.floors){let a=r.get(l.id);a?Rv(a,l,n,o):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 yn=(t,e)=>t.getUint16(e,!0),fi=(t,e)=>t.getUint32(e,!0);function Wh(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(fi(e,l)===101010256){n=l;break}if(n<0)throw new Error("not_zip");let r=yn(e,n+10),i=fi(e,n+16),o=[],s=new TextDecoder;for(let l=0;l<r;l++){if(fi(e,i)!==33639248)throw new Error("not_zip");let a=yn(e,i+10),c=fi(e,i+20),u=yn(e,i+28),d=yn(e,i+30),p=yn(e,i+32),h=fi(e,i+42),f=s.decode(t.subarray(i+46,i+46+u)),g=h+30+yn(e,h+26)+yn(e,h+28);o.push({name:f,method:a,compressedSize:c,offset:g}),i+=46+u+d+p}return o}async function Vh(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 Ev={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"},Av=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)):Ev[n]??e);function Fv(t){let e={};for(let n of t.matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))e[n[1]]=Av(n[2]??n[3]);return e}function Tv(t){let e=[],n=null;for(let r of t.matchAll(/<(\/?)(level|room|point|wall|doorOrWindow|pieceOfFurniture)\b([^>]*?)(\/?)>/g)){let[,i,o,s,l]=r;if(i){o==="room"&&(n=null);continue}let a=Fv(s);if(o==="point"){n&&n.points.push([Number(a.x)/100,Number(a.y)/100]);continue}let c={name:o,attrs:a,...o==="room"?{points:[]}:{}};e.push(c),o==="room"&&!l&&(n=c)}return e}var oe=(t,e,n)=>Number.isFinite(Number(t[e]))&&t[e]!==void 0?Number(t[e]):n,Te=t=>Math.round(t*1e3)/1e3;function Kh(t,e,n){let[r,i]=[n[0]-e[0],n[1]-e[1]],o=Math.hypot(r,i)||1e-9,s=Math.max(0,Math.min(o,((t[0]-e[0])*r+(t[1]-e[1])*i)/o)),l=[e[0]+r*s/o,e[1]+i*s/o];return{dist:Math.hypot(t[0]-l[0],t[1]-l[1]),along:s,length:o}}function zv(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 Pv(t,e){let n=t.length,r=t.map((i,o)=>{let s=t[(o+1)%n],[l,a]=[s[0]-i[0],s[1]-i[1]],c=Math.hypot(l,a)||1e-9,u=[l/c,a/c],d=[(i[0]+s[0])/2,(i[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]],b=Math.hypot(f,g)||1e-9;if(Math.abs((u[0]*g-u[1]*f)/b)>.05)continue;let y=(h.a[0]-d[0])*-u[1]+(h.a[1]-d[1])*u[0],v=((d[0]-h.a[0])*f+(d[1]-h.a[1])*g)/b;if(!(Math.abs(y)>h.thickness/2+.06||v<-.05||v>b+.05)){p=[-u[1]*y,u[0]*y];break}}return{p:[i[0]+p[0],i[1]+p[1]],dir:u}});return r.map((i,o)=>{let s=r[(o-1+n)%n],l=s.dir[0]*i.dir[1]-s.dir[1]*i.dir[0];if(Math.abs(l)<1e-6)return i.p;let a=((i.p[0]-s.p[0])*i.dir[1]-(i.p[1]-s.p[1])*i.dir[0])/l;return[s.p[0]+s.dir[0]*a,s.p[1]+s.dir[1]*a]})}function Dv(t){let e=Pt(),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(i)}" allow="fullscreen" title="${a(n)}"></iframe>
@@ -633,7 +633,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 op(t){let e;try{e=JSON.parse(t)}catch{throw new Error("not_json")}let n=e,r=n?.format===tp?n.building:e;if(!Jv(r))throw new Error("not_plan");return r.floors.forEach(i=>i.background=null),Oe(r)}var ew=t=>!/^https?:\/\//.test(t)&&!t.startsWith("camera:");function sp(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(i=>i.pictures??[]);for(let{image:i}of r)i&&ew(i)&&e.add(i)}return[...e]}function ap(t,e,n="application/json"){let r=document.createElement("a"),i=URL.createObjectURL(new Blob([e],{type:n}));Object.assign(r,{href:i,download:t}),r.click(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}var tw={api:{listHistory:$d,restoreSnapshot:Ed,takeSnapshot:Sd,getSnapshot:Md,deleteSnapshot:Rd,fetchBackup:Fd,restoreBackup:Td,fetchImage:mo,storeImage:Wt},alert:t=>alert(t),confirm:t=>confirm(t),prompt:t=>prompt(t),download:ap,today:()=>new Date().toISOString().slice(0,10)},nw=t=>String(t?.message??t),Lo=class{host;deps;history=null;busy=!1;compare=null;constructor(e,n=tw){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 i=Oe(await r(n,e.id));this.compare={snapshot:e,entries:Bh(i,this.host.doc)},this.host.refresh()}async deleteVersion(e){let{hass:n,t:r}=this.host,i=this.deps.api.deleteSnapshot;!n||!i||!this.deps.confirm(r("version_delete_confirm",{name:e.name??this.timeOf(e)}))||(await i(n,e.id),this.compare?.snapshot.id===e.id&&(this.compare=null),await this.loadHistory())}exportShareView(){let e=this.host.t,n=ip(this.host.doc,Rr(),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(rp(this.host.doc,e),null,2))}async importPlan(e){let{hass:n,t:r}=this.host;if(!e||!n)return;let i,o=r("backup_import_confirm");try{if(/\.sh3d$/i.test(e.name)){let s=await jh(new Uint8Array(await e.arrayBuffer()));i=s.building,o=`${r("import_sh3d_found",{...s.report})}
`}function op(t){let e;try{e=JSON.parse(t)}catch{throw new Error("not_json")}let n=e,r=n?.format===tp?n.building:e;if(!Jv(r))throw new Error("not_plan");return r.floors.forEach(i=>i.background=null),Oe(r)}var ew=t=>!/^https?:\/\//.test(t)&&!t.startsWith("camera:");function sp(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(i=>i.pictures??[]);for(let{image:i}of r)i&&ew(i)&&e.add(i)}return[...e]}function ap(t,e,n="application/json"){let r=document.createElement("a"),i=URL.createObjectURL(new Blob([e],{type:n}));Object.assign(r,{href:i,download:t}),r.click(),setTimeout(()=>URL.revokeObjectURL(i),1e3)}var tw={api:{listHistory:$d,restoreSnapshot:Ed,takeSnapshot:Sd,getSnapshot:Md,deleteSnapshot:Rd,fetchBackup:Fd,restoreBackup:Td,fetchImage:mo,storeImage:Wt},alert:t=>alert(t),confirm:t=>confirm(t),prompt:t=>prompt(t),download:ap,today:()=>new Date().toISOString().slice(0,10)},nw=t=>String(t?.message??t),Co=class{host;deps;history=null;busy=!1;compare=null;constructor(e,n=tw){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 i=Oe(await r(n,e.id));this.compare={snapshot:e,entries:Bh(i,this.host.doc)},this.host.refresh()}async deleteVersion(e){let{hass:n,t:r}=this.host,i=this.deps.api.deleteSnapshot;!n||!i||!this.deps.confirm(r("version_delete_confirm",{name:e.name??this.timeOf(e)}))||(await i(n,e.id),this.compare?.snapshot.id===e.id&&(this.compare=null),await this.loadHistory())}exportShareView(){let e=this.host.t,n=ip(this.host.doc,Rr(),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(rp(this.host.doc,e),null,2))}async importPlan(e){let{hass:n,t:r}=this.host;if(!e||!n)return;let i,o=r("backup_import_confirm");try{if(/\.sh3d$/i.test(e.name)){let s=await jh(new Uint8Array(await e.arrayBuffer()));i=s.building,o=`${r("import_sh3d_found",{...s.report})}
${o}`}else if(/\.ifc$/i.test(e.name)){let s=Qh(await e.text());i=s.building,o=`${r("import_ifc_found",{floors:s.report.floors,rooms:s.report.rooms})}
@@ -695,7 +695,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</div>
${S(r("compass_hint"))}
</div>
</div>`}var sw="https://tile.openstreetmap.org/{z}/{x}/{y}.png";var aw=40075016686e-3,el=Math.PI/180,gi=18,_i=.5,lw=160;function cw(t,e,n){let r=2**n,i=(e+180)/360*r,o=(1-Math.log(Math.tan(t*el)+1/Math.cos(t*el))/Math.PI)/2*r;return[i,o]}var uw=(t,e)=>aw*Math.cos(t*el)/2**e;function mp(t,e,n,r=lw){let[i,o]=cw(t,e,n),s=uw(t,n),l=r/s,a=2**n-1,c=[];for(let u=Math.floor(o-l);u<=Math.floor(o+l);u++)for(let d=Math.floor(i-l);d<=Math.floor(i+l);d++){if(u<0||u>a)continue;let p=(d%(a+1)+a+1)%(a+1);c.push({x:p,y:u,z:n,east:(d-i)*s,north:-(u-o)*s,size:s})}return c}function gp(t,e){return t.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)).replace("{s}","abc"[(e.x+e.y)%3])}var _p=t=>t.url&&t.url.startsWith("https://")?t.url:sw;var Co=t=>!!t&&t.on===!0&&Number.isFinite(t.lat)&&Number.isFinite(t.lon),bp=t=>({x:t.x??0,z:t.z??0,opacity:t.opacity??_i,zoom:t.zoom??gi});function dw(t){let e=[],n=[];for(let i of t.floors){for(let o of i.rooms)for(let[s,l]of o.points)e.push(s),n.push(l);for(let o of i.outdoor??[])for(let[s,l]of o.points)e.push(s),n.push(l)}if(!e.length)return[0,0];let r=i=>Math.round((Math.min(...i)+Math.max(...i))/2*100)/100;return[r(e),r(n)]}function yp(t,e){let[n,r]=dw(t);return{on:!0,lat:e?.lat??0,lon:e?.lon??0,x:n,z:r,opacity:_i,zoom:gi,url:null}}function vp(t,e,n){let r=i=>Math.round(i*100)/100;return{...t,x:r((t.x??0)+e),z:r((t.z??0)+n)}}function wp(t){let e=t.trim();return e===""?null:/^https:\/\/\S+$/.test(e)&&["{z}","{x}","{y}"].every(n=>e.includes(n))?e:void 0}var hw=["15","16","17","18","19"],pw=["1","5","20"],No="5";function kp(t,e,n){let r=t.t,i=e.settings.map??null,o=t.hass?.config,s=Co(i),l=u=>{if(!u)return n(i?{...i,on:!1}:null);n(i?{...i,on:!0}:yp(e,{lat:o?.latitude,lon:o?.longitude}))},a=u=>i&&n({...i,...u}),c=(u,d)=>()=>i&&n(vp(i,u*Number(No),d*Number(No)));return m`<div class="nf-map-settings nf-wide">
</div>`}var sw="https://tile.openstreetmap.org/{z}/{x}/{y}.png";var aw=40075016686e-3,el=Math.PI/180,gi=18,_i=.5,lw=160;function cw(t,e,n){let r=2**n,i=(e+180)/360*r,o=(1-Math.log(Math.tan(t*el)+1/Math.cos(t*el))/Math.PI)/2*r;return[i,o]}var uw=(t,e)=>aw*Math.cos(t*el)/2**e;function mp(t,e,n,r=lw){let[i,o]=cw(t,e,n),s=uw(t,n),l=r/s,a=2**n-1,c=[];for(let u=Math.floor(o-l);u<=Math.floor(o+l);u++)for(let d=Math.floor(i-l);d<=Math.floor(i+l);d++){if(u<0||u>a)continue;let p=(d%(a+1)+a+1)%(a+1);c.push({x:p,y:u,z:n,east:(d-i)*s,north:-(u-o)*s,size:s})}return c}function gp(t,e){return t.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)).replace("{s}","abc"[(e.x+e.y)%3])}var _p=t=>t.url&&t.url.startsWith("https://")?t.url:sw;var No=t=>!!t&&t.on===!0&&Number.isFinite(t.lat)&&Number.isFinite(t.lon),bp=t=>({x:t.x??0,z:t.z??0,opacity:t.opacity??_i,zoom:t.zoom??gi});function dw(t){let e=[],n=[];for(let i of t.floors){for(let o of i.rooms)for(let[s,l]of o.points)e.push(s),n.push(l);for(let o of i.outdoor??[])for(let[s,l]of o.points)e.push(s),n.push(l)}if(!e.length)return[0,0];let r=i=>Math.round((Math.min(...i)+Math.max(...i))/2*100)/100;return[r(e),r(n)]}function yp(t,e){let[n,r]=dw(t);return{on:!0,lat:e?.lat??0,lon:e?.lon??0,x:n,z:r,opacity:_i,zoom:gi,url:null}}function vp(t,e,n){let r=i=>Math.round(i*100)/100;return{...t,x:r((t.x??0)+e),z:r((t.z??0)+n)}}function wp(t){let e=t.trim();return e===""?null:/^https:\/\/\S+$/.test(e)&&["{z}","{x}","{y}"].every(n=>e.includes(n))?e:void 0}var hw=["15","16","17","18","19"],pw=["1","5","20"],Bo="5";function kp(t,e,n){let r=t.t,i=e.settings.map??null,o=t.hass?.config,s=No(i),l=u=>{if(!u)return n(i?{...i,on:!1}:null);n(i?{...i,on:!0}:yp(e,{lat:o?.latitude,lon:o?.longitude}))},a=u=>i&&n({...i,...u}),c=(u,d)=>()=>i&&n(vp(i,u*Number(Bo),d*Number(Bo)));return m`<div class="nf-map-settings nf-wide">
${D(t,r("map_on"),s,l,{title:r("map_hint")})}
${i&&i.on?m`<div class="nf-form">
${E(t,r("map_lat"),i.lat,u=>a({lat:Math.max(-85,Math.min(85,u))}),1e-4)}
@@ -711,7 +711,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<button class="nf-btn" ?disabled=${!t.admin} title=${r("map_move")} @click=${c(1,0)}>▶</button>
<button class="nf-btn" ?disabled=${!t.admin} title=${r("map_move")} @click=${c(0,1)}>▼</button>
</div>
${H(t,r("map_step"),No,pw.map(u=>[u,`${u} m`]),u=>No=u,{wide:!1})}
${H(t,r("map_step"),Bo,pw.map(u=>[u,`${u} m`]),u=>Bo=u,{wide:!1})}
</div>
${V(t,r("map_url"),i.url??"",u=>{let d=wp(u);d!==void 0&&a({url:d})},{wide:!0,placeholder:"https://\u2026/{z}/{x}/{y}.png",maxlength:300})}
${S(r("map_hint"),"nf-wide")}
@@ -799,7 +799,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<div class="nf-actions">
${Ke.map(r=>m`<button class="nf-btn" ?disabled=${!t.admin||!t.floor} @click=${()=>e.addDevice(r)}>+ ${t.t(`furn_${r}`)}</button>`)}
</div>
</section>`}var Rp=(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 zp(t,e){let{energy:n}=t.doc,r=(y,v)=>t.hass?.states[y]?.attributes[v],i=O(t.hass,y=>Hn(t.hass,y)),o=O(t.hass,y=>me(y)&&r(y,"device_class")==="battery"),s=O(t.hass,y=>me(y)&&(r(y,"device_class")==="monetary"||/\/(kWh|MWh)$/.test(r(y,"unit_of_measurement")??""))),l=Ep(t),a=Ro(t.doc,y=>po(y,l)),c=y=>t.replace({...structuredClone(t.doc),energy:{...t.doc.energy,...y}}),u=O(t.hass,y=>me(y)&&["gas","water","volume_flow_rate"].includes(r(y,"device_class")??"")),d=y=>v=>c({[y]:v==="none"?null:v}),p=t.hass?Ba(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,b=(y,v)=>D(t,t.t("energy_invert"),y,w=>c(v(w)));return m`<section>
</section>`}var Rp=(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 zp(t,e){let{energy:n}=t.doc,r=(y,v)=>t.hass?.states[y]?.attributes[v],i=O(t.hass,y=>Hn(t.hass,y)),o=O(t.hass,y=>me(y)&&r(y,"device_class")==="battery"),s=O(t.hass,y=>me(y)&&(r(y,"device_class")==="monetary"||/\/(kWh|MWh)$/.test(r(y,"unit_of_measurement")??""))),l=Ep(t),a=Ro(t.doc,y=>po(y,l)),c=y=>t.replace({...structuredClone(t.doc),energy:{...t.doc.energy,...y}}),u=O(t.hass,y=>me(y)&&["gas","water","volume_flow_rate"].includes(r(y,"device_class")??"")),d=y=>v=>c({[y]:v==="none"?null:v}),p=t.hass?Wa(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,b=(y,v)=>D(t,t.t("energy_invert"),y,w=>c(v(w)));return m`<section>
<h3>⚖ ${t.t("energy_balance")}</h3>
${S(t.t("energy_balance_hint"))}
${f?Rp(t,"energy_sign_grid",()=>c({grid_invert:!n.grid_invert})):_}
@@ -853,7 +853,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${s?D(t,r("route_cable"),!!s.cable,a=>e.setCable(o.key,a),{title:r("route_cable_hint")}):_}`}
</div>`})}
</div>
</section>`}var lt=(t,e)=>e.map(n=>t.toScreen(n).join(",")).join(" ");function Bo(t,e,n,r,i,o){let[[s,l],[a,c]]=[t.toScreen(e),t.toScreen(n)];if(Math.hypot(a-s,c-l)<=36)return _;let[u,d]=[(s+a)/2,(l+c)/2];return R`<g data-plus=${`${r}:${i}:${o}`} class="nf-mid"><circle cx=${u} cy=${d} r="14" class="nf-hit" /><circle cx=${u} cy=${d} r="6" /><path d="M${u-3} ${d}h6M${u} ${d-3}v6" /></g>`}var Op=(t,e)=>R`<circle cx=${t} cy=${e} r="16" class="nf-hit" /><circle cx=${t} cy=${e} r="6" />`,xw=(t,e,n)=>R`<g class="nf-vertex" data-roof-vertex=${n}>${Op(...t.toScreen(e))}</g>`,$w=(t,e,n)=>R`<g class="nf-vertex" data-roof-corner=${n}>${Op(...t.toScreen(e))}</g>`;function Sw(t,e,n,r){let{t:i,hass:o}=t.host,s=n.dormer?i("roof_dormer"):n.open?i("roof_open_short"):i(`roof_shape_${n.shape}`);return`${e.isFixed(n)?"\u{1F512} ":""}${r+1} \xB7 ${s} \xB7 ${K(o,cn(n),1)} m`}function tl(t,e){let n=t.host.doc.settings.roof,r=n.type==="custom"?n.sections??[]:[],i=t.host.admin,o=(s,l)=>{let a=s.id===e.sectionId,c=$e(s),u=(s.shape==="flat"||s.shape==="parapet")&&s.points&&s.points.length>=3?s.points:null,d=_o(r,s),p=d?$e(ga(d,s)):c,h=u??[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:un(s,{u0:0,u1:0,a:0,b:0}))?.ridges??[]).map(([N,W])=>{let[q,ke]=t.toScreen(c.at(N[0],N[1])),[At,j]=t.toScreen(c.at(W[0],W[1]));return R`<line x1=${q} y1=${ke} x2=${At} y2=${j} />`}),[b,y]=t.toScreen(c.at((c.u0+c.u1)/2,c.w/2)),v=a&&i&&!e.isFixed(s),w=[[0,0],[1,0],[1,1],[0,1]],x=s.shape==="flat"||s.shape==="parapet",[k,M,A,T]=[Math.min(s.x0,s.x1),Math.max(s.x0,s.x1),Math.min(s.z0,s.z1),Math.max(s.z0,s.z1)],F=u??(s.rotation?Lr(s):[[k,A],[M,A],[M,T],[k,T]]),L=v&&x?F.map((N,W)=>Bo(t,N,F[(W+1)%F.length],"roof",s.id,W)):_,P=v?R`${L}${u?u.map((N,W)=>xw(t,N,`${s.id}:${W}`)):w.map(([N,W])=>$w(t,[N?M:k,W?T:A],`${s.id}:${N}:${W}`))}`:_;return R`<g data-roof=${s.id} class=${`nf-roof-sec${a?" nf-roof-sel":""}`}>
</section>`}var lt=(t,e)=>e.map(n=>t.toScreen(n).join(",")).join(" ");function Wo(t,e,n,r,i,o){let[[s,l],[a,c]]=[t.toScreen(e),t.toScreen(n)];if(Math.hypot(a-s,c-l)<=36)return _;let[u,d]=[(s+a)/2,(l+c)/2];return R`<g data-plus=${`${r}:${i}:${o}`} class="nf-mid"><circle cx=${u} cy=${d} r="14" class="nf-hit" /><circle cx=${u} cy=${d} r="6" /><path d="M${u-3} ${d}h6M${u} ${d-3}v6" /></g>`}var Op=(t,e)=>R`<circle cx=${t} cy=${e} r="16" class="nf-hit" /><circle cx=${t} cy=${e} r="6" />`,xw=(t,e,n)=>R`<g class="nf-vertex" data-roof-vertex=${n}>${Op(...t.toScreen(e))}</g>`,$w=(t,e,n)=>R`<g class="nf-vertex" data-roof-corner=${n}>${Op(...t.toScreen(e))}</g>`;function Sw(t,e,n,r){let{t:i,hass:o}=t.host,s=n.dormer?i("roof_dormer"):n.open?i("roof_open_short"):i(`roof_shape_${n.shape}`);return`${e.isFixed(n)?"\u{1F512} ":""}${r+1} \xB7 ${s} \xB7 ${K(o,cn(n),1)} m`}function tl(t,e){let n=t.host.doc.settings.roof,r=n.type==="custom"?n.sections??[]:[],i=t.host.admin,o=(s,l)=>{let a=s.id===e.sectionId,c=$e(s),u=(s.shape==="flat"||s.shape==="parapet")&&s.points&&s.points.length>=3?s.points:null,d=_o(r,s),p=d?$e(_a(d,s)):c,h=u??[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:un(s,{u0:0,u1:0,a:0,b:0}))?.ridges??[]).map(([N,W])=>{let[q,ke]=t.toScreen(c.at(N[0],N[1])),[At,j]=t.toScreen(c.at(W[0],W[1]));return R`<line x1=${q} y1=${ke} x2=${At} y2=${j} />`}),[b,y]=t.toScreen(c.at((c.u0+c.u1)/2,c.w/2)),v=a&&i&&!e.isFixed(s),w=[[0,0],[1,0],[1,1],[0,1]],x=s.shape==="flat"||s.shape==="parapet",[k,M,A,T]=[Math.min(s.x0,s.x1),Math.max(s.x0,s.x1),Math.min(s.z0,s.z1),Math.max(s.z0,s.z1)],F=u??(s.rotation?Lr(s):[[k,A],[M,A],[M,T],[k,T]]),L=v&&x?F.map((N,W)=>Wo(t,N,F[(W+1)%F.length],"roof",s.id,W)):_,P=v?R`${L}${u?u.map((N,W)=>xw(t,N,`${s.id}:${W}`)):w.map(([N,W])=>$w(t,[N?M:k,W?T:A],`${s.id}:${N}:${W}`))}`:_;return R`<g data-roof=${s.id} class=${`nf-roof-sec${a?" nf-roof-sel":""}`}>
<polygon points=${lt(t,h)} />
<g class="nf-roof-ridge">${g}</g>
<text x=${b} y=${y-14}>${Sw(t,e,s,l)}</text>
@@ -862,13 +862,13 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<circle cx=${a} cy=${c} r="16" class="nf-hit" />
<circle cx=${a} cy=${c} r="8" />
<path d="M${a-4} ${c-1}a4 4 0 1 1 2 3.5" />
</g>`}function Hp(t,e){let{doc:n,admin:r}=t.host,i=n.settings.roof.solar??[];if(i.length===0)return _;let o=Z(n),s=l=>{let a=Se(n,l,o);if(!a||a.wall&&a.wall.floorId!==t.floorId)return _;let c=l.id===e.solarId,u=_;if(c&&a.unbounded&&r&&!l.locked){let h=qr(a,l),f=Math.max(...Xe(a,l,!0).flatMap(g=>g.corners.map(b=>Math.hypot(b[0]-h[0],b[2]-h[1]))));u=Mw(t,l.id,h,l.rotation??0,.9+f*.5)}let d=h=>{let f;if(a.wall){let g=Math.max(.3,...h.corners.map(w=>(w[0]-a.o[0])*a.n[0]+(w[2]-a.o[2])*a.n[2])),[b,y]=[h.corners[0],h.corners[1]],v=w=>[w[0]+a.n[0]*g,w[2]+a.n[2]*g];f=[[b[0],b[2]],v(b),v(y),[y[0],y[2]]]}else f=h.corners.map(g=>[g[0],g[2]]);return R`<polygon data-cell=${h.cell} class=${h.skipped?"nf-solar-off":""} points=${lt(t,f)} />`},p=`nf-solar${c?" nf-solar-sel":""}${c&&e.picking?" nf-solar-pick":""}`;return R`<g data-solar=${l.id} class=${p}>${Xe(a,l,c).map(d)}</g>${u}`};return R`<g class="nf-solar-layer">${i.map(s)}</g>`}function Lp(t,e){let n=t.host.doc.settings.roof.windows??[];if(n.length===0)return _;let r=new Map(Z(t.host.doc).map(o=>[o.key,o])),i=o=>{let s=r.get(o.face),l=s?Sa(s,o):null;return l?R`<g data-roofwin=${o.id} class=${`nf-roofwin${o.id===e.windowId?" nf-roofwin-sel":""}`}><polygon points=${lt(t,l.map(a=>[a[0],a[2]]))} /></g>`:_};return R`<g class="nf-roofwin-layer">${n.map(i)}</g>`}var Rw={inverter:"\u26A1",home_battery:"\u{1F50B}",wallbox:"\u{1F50C}",meter:"\u{1F4DF}",grid_point:"\u{1F3C1}"};function Cp(t,e,n){if(!e)return _;let r=e.furniture.filter(o=>Ke.includes(o.type)),i=o=>{let[s,l]=t.toScreen([o.x,o.z]),a=o.id===n,c=t.host.t(`furn_${o.type}`);return R`<g data-energy-device=${o.id} class=${`nf-energy-marker${a?" nf-energy-marker-sel":""}`}>
</g>`}function Hp(t,e){let{doc:n,admin:r}=t.host,i=n.settings.roof.solar??[];if(i.length===0)return _;let o=Z(n),s=l=>{let a=Se(n,l,o);if(!a||a.wall&&a.wall.floorId!==t.floorId)return _;let c=l.id===e.solarId,u=_;if(c&&a.unbounded&&r&&!l.locked){let h=qr(a,l),f=Math.max(...Xe(a,l,!0).flatMap(g=>g.corners.map(b=>Math.hypot(b[0]-h[0],b[2]-h[1]))));u=Mw(t,l.id,h,l.rotation??0,.9+f*.5)}let d=h=>{let f;if(a.wall){let g=Math.max(.3,...h.corners.map(w=>(w[0]-a.o[0])*a.n[0]+(w[2]-a.o[2])*a.n[2])),[b,y]=[h.corners[0],h.corners[1]],v=w=>[w[0]+a.n[0]*g,w[2]+a.n[2]*g];f=[[b[0],b[2]],v(b),v(y),[y[0],y[2]]]}else f=h.corners.map(g=>[g[0],g[2]]);return R`<polygon data-cell=${h.cell} class=${h.skipped?"nf-solar-off":""} points=${lt(t,f)} />`},p=`nf-solar${c?" nf-solar-sel":""}${c&&e.picking?" nf-solar-pick":""}`;return R`<g data-solar=${l.id} class=${p}>${Xe(a,l,c).map(d)}</g>${u}`};return R`<g class="nf-solar-layer">${i.map(s)}</g>`}function Lp(t,e){let n=t.host.doc.settings.roof.windows??[];if(n.length===0)return _;let r=new Map(Z(t.host.doc).map(o=>[o.key,o])),i=o=>{let s=r.get(o.face),l=s?Ma(s,o):null;return l?R`<g data-roofwin=${o.id} class=${`nf-roofwin${o.id===e.windowId?" nf-roofwin-sel":""}`}><polygon points=${lt(t,l.map(a=>[a[0],a[2]]))} /></g>`:_};return R`<g class="nf-roofwin-layer">${n.map(i)}</g>`}var Rw={inverter:"\u26A1",home_battery:"\u{1F50B}",wallbox:"\u{1F50C}",meter:"\u{1F4DF}",grid_point:"\u{1F3C1}"};function Cp(t,e,n){if(!e)return _;let r=e.furniture.filter(o=>Ke.includes(o.type)),i=o=>{let[s,l]=t.toScreen([o.x,o.z]),a=o.id===n,c=t.host.t(`furn_${o.type}`);return R`<g data-energy-device=${o.id} class=${`nf-energy-marker${a?" nf-energy-marker-sel":""}`}>
<circle cx=${s} cy=${l} r="17" />
<text x=${s} y=${l+6} class="nf-energy-icon">${Rw[o.type]??"\u26A1"}</text>
${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(i)}</g>`}function Np(t,e){let{doc:n,hass:r}=t.host;if(!(n.settings.roof.sections??[]).some(s=>ba(s,e.elevation+e.height)))return _;let o=[1.5,2].flatMap(s=>ya({settings:n.settings},e.elevation,s).map(([l,a])=>{let[c,u]=t.toScreen(l),[d,p]=t.toScreen(a);return R`<line class="nf-headroom" x1=${c} y1=${u} x2=${d} y2=${p} />
<text class="nf-headroom-label" x=${(c+d)/2} y=${(u+p)/2-4}>${K(r,s,1)} m</text>`}));return R`${o}`}function Bp(t,e,n,r){if(!e)return _;let i=(o,s)=>{let l=[];return o.forEach((a,c)=>{if(a.floor_id!==e.id)return;let[u,d]=t.toScreen([a.x,a.z]),p=o[c+1];if(p?.floor_id===e.id){let[f,g]=t.toScreen([p.x,p.z]);l.push(R`<line x1=${u} y1=${d} x2=${f} y2=${g} />`)}let h=p&&p.floor_id!==e.id||c>0&&o[c-1].floor_id!==e.id;l.push(R`<circle cx=${u} cy=${d} r=${h?7:4} class=${h?"nf-route-riser":""} />`),s&&l.push(R`<text x=${u+8} y=${d-8}>${c+1}</text>`)}),R`<g class=${`nf-route${s?" nf-route-drawing":""}`}>${l}</g>`};return R`<g class="nf-routes">${n.filter(o=>o.key!==r?.key).map(o=>i(o.points,!1))}${r?i(r.points,!0):_}</g>`}function Wp(t,e){let n=t.host.doc.settings.roof.chimneys??[];if(n.length===0)return _;let r=new Map(Z(t.host.doc).map(o=>[o.key,o])),i=o=>{let s=r.get(o.face);if(!s)return _;let{shape:l,w:a,d:c}=gn(o),{center:u,along:d,across:p}=Ma(s,o),h=l==="round"||l==="steel"?Array.from({length:16},(f,g)=>[u[0]+Math.cos(g/16*2*Math.PI)*Math.min(a,c)/2,u[1]+Math.sin(g/16*2*Math.PI)*Math.min(a,c)/2]):[[-1,-1],[1,-1],[1,1],[-1,1]].map(([f,g])=>[u[0]+d[0]*a*f/2+p[0]*c*g/2,u[1]+d[1]*a*f/2+p[1]*c*g/2]);return R`<g data-chimney=${o.id} class=${`nf-chimney${o.id===e.chimneyId?" nf-roofwin-sel":""}`}><polygon points=${lt(t,h)} /></g>`};return R`<g class="nf-roofwin-layer">${n.map(i)}</g>`}function Ew(t,e,n){let[r,i]=[t+n/2,e-30];return R`<g class="nf-rotate" data-bg-rotate="1">
</g>`};return R`<g class="nf-energy-markers">${r.map(i)}</g>`}function Np(t,e){let{doc:n,hass:r}=t.host;if(!(n.settings.roof.sections??[]).some(s=>ya(s,e.elevation+e.height)))return _;let o=[1.5,2].flatMap(s=>va({settings:n.settings},e.elevation,s).map(([l,a])=>{let[c,u]=t.toScreen(l),[d,p]=t.toScreen(a);return R`<line class="nf-headroom" x1=${c} y1=${u} x2=${d} y2=${p} />
<text class="nf-headroom-label" x=${(c+d)/2} y=${(u+p)/2-4}>${K(r,s,1)} m</text>`}));return R`${o}`}function Bp(t,e,n,r){if(!e)return _;let i=(o,s)=>{let l=[];return o.forEach((a,c)=>{if(a.floor_id!==e.id)return;let[u,d]=t.toScreen([a.x,a.z]),p=o[c+1];if(p?.floor_id===e.id){let[f,g]=t.toScreen([p.x,p.z]);l.push(R`<line x1=${u} y1=${d} x2=${f} y2=${g} />`)}let h=p&&p.floor_id!==e.id||c>0&&o[c-1].floor_id!==e.id;l.push(R`<circle cx=${u} cy=${d} r=${h?7:4} class=${h?"nf-route-riser":""} />`),s&&l.push(R`<text x=${u+8} y=${d-8}>${c+1}</text>`)}),R`<g class=${`nf-route${s?" nf-route-drawing":""}`}>${l}</g>`};return R`<g class="nf-routes">${n.filter(o=>o.key!==r?.key).map(o=>i(o.points,!1))}${r?i(r.points,!0):_}</g>`}function Wp(t,e){let n=t.host.doc.settings.roof.chimneys??[];if(n.length===0)return _;let r=new Map(Z(t.host.doc).map(o=>[o.key,o])),i=o=>{let s=r.get(o.face);if(!s)return _;let{shape:l,w:a,d:c}=gn(o),{center:u,along:d,across:p}=Ra(s,o),h=l==="round"||l==="steel"?Array.from({length:16},(f,g)=>[u[0]+Math.cos(g/16*2*Math.PI)*Math.min(a,c)/2,u[1]+Math.sin(g/16*2*Math.PI)*Math.min(a,c)/2]):[[-1,-1],[1,-1],[1,1],[-1,1]].map(([f,g])=>[u[0]+d[0]*a*f/2+p[0]*c*g/2,u[1]+d[1]*a*f/2+p[1]*c*g/2]);return R`<g data-chimney=${o.id} class=${`nf-chimney${o.id===e.chimneyId?" nf-roofwin-sel":""}`}><polygon points=${lt(t,h)} /></g>`};return R`<g class="nf-roofwin-layer">${n.map(i)}</g>`}function Ew(t,e,n){let[r,i]=[t+n/2,e-30];return R`<g class="nf-rotate" data-bg-rotate="1">
<line x1=${r} y1=${e} x2=${r} y2=${i} />
<circle cx=${r} cy=${i} r="16" class="nf-hit" />
<circle cx=${r} cy=${i} r="8" />
@@ -881,9 +881,9 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${c?R`<rect class="nf-bg-frame" x=${o} y=${s} width=${l} height=${a} />
<circle class="nf-bg-handle" data-bg-handle="1" cx=${o+l} cy=${s+a} r="9" />
${Ew(o,s,l)}`:_}
</g>${Aw(t,e)}`}var Fw="strict-origin-when-cross-origin",nl=new Map,Kp=new Map,Wo=new Map;function Tw(t){let e=nl.get(t);return e||(e=fetch(t,{referrerPolicy:Fw,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(()=>nl.delete(t),6e4),n)),nl.set(t,e)),e}function jp(t,e){let n=Kp.get(t);if(n)return n;let r=Wo.get(t);return r||(r=new Set,Wo.set(t,r),Tw(t).then(i=>{i&&Kp.set(t,URL.createObjectURL(i));let o=Wo.get(t)??new Set;if(Wo.delete(t),i)for(let s of o)s()})),r.add(e),null}function Up(t,e){let n=e.map;if(!Co(n))return _;let r=bp(n),i=_p(n),[o,s]=t.toScreen([r.x,r.z]),l=t.scale;return R`<g class="nf-map" opacity=${r.opacity} pointer-events="none" transform="translate(${o} ${s}) rotate(${e.north??0})">
</g>${Aw(t,e)}`}var Fw="strict-origin-when-cross-origin",nl=new Map,Kp=new Map,Vo=new Map;function Tw(t){let e=nl.get(t);return e||(e=fetch(t,{referrerPolicy:Fw,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(()=>nl.delete(t),6e4),n)),nl.set(t,e)),e}function jp(t,e){let n=Kp.get(t);if(n)return n;let r=Vo.get(t);return r||(r=new Set,Vo.set(t,r),Tw(t).then(i=>{i&&Kp.set(t,URL.createObjectURL(i));let o=Vo.get(t)??new Set;if(Vo.delete(t),i)for(let s of o)s()})),r.add(e),null}function Up(t,e){let n=e.map;if(!No(n))return _;let r=bp(n),i=_p(n),[o,s]=t.toScreen([r.x,r.z]),l=t.scale;return R`<g class="nf-map" opacity=${r.opacity} pointer-events="none" transform="translate(${o} ${s}) rotate(${e.north??0})">
${mp(n.lat,n.lon,r.zoom).map(a=>({tile:a,href:jp(gp(i,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 rl=t=>Math.round(t*1e3)/1e3,il=(t,e)=>t.width*e,er=(t,e)=>[t.x+t.width/2,t.z+il(t,e)/2];function Gp(t,e,n){let[r,i]=[t[0]-e[0],t[1]-e[1]];return[e[0]+r*Math.cos(n)-i*Math.sin(n),e[1]+r*Math.sin(n)+i*Math.cos(n)]}var Zp=t=>((t+180)%360+360)%360-180;function qp(t,e,n){return{x:rl(t[0]-e/2),z:rl(t[1]-n/2)}}function Yp(t,e,n,r){if(Math.hypot(r[0]-n[0],r[1]-n[1])<.05)return null;let i=Math.atan2(r[1]-n[1],r[0]-n[0]),o=Math.round(i/(Math.PI/2))*(Math.PI/2)-i;if(Math.abs(o)<1e-4)return null;let s=Gp(er(t,e),n,o),l=Math.round(Zp((t.rotation??0)+o*180/Math.PI)*100)/100;return{...t,rotation:l,...qp(s,t.width,il(t,e))}}function Xp(t,e,n,r,i){let o=Math.hypot(r[0]-n[0],r[1]-n[1]);if(!(i>0)||o<1e-4)return null;let s=i/o,[l,a]=er(t,e),c=[n[0]+s*(l-n[0]),n[1]+s*(a-n[1])],u=t.width*s;return{...t,width:rl(u),...qp(c,u,il(t,e)*s)}}function Jp(t,e,n){let r=Gp(n,er(t,e),-(t.rotation??0)*Math.PI/180);return[r[0]-t.x,r[1]-t.z]}function Qp(t,e,n,r){let i=t+(n-e)*180/Math.PI;return Zp(r?Math.round(i/15)*15:Math.round(i*10)/10)}var zw=2048;async function tr(t){let e=await createImageBitmap(t),n=Math.min(1,zw/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 Vo=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 i=await r.fetchImage(n.hass,e),o=await this.aspectOf(i);this.pictures={...this.pictures,[e]:{url:i,aspect:o}},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:i,aspect:o}=await this.deps.readPicture(e),s=I("img");await r.storeImage(n.hass,s,i),this.pictures={...this.pictures,[s]:{url:i,aspect:o}};let l=n.floor?.rooms??[],a=l.length>0?de(l.flatMap(u=>u.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,i=this.picture(r?.image_id),o=r&&i?Yp(r,i.aspect,e,n):null;o&&this.setBackground(o)}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 i=Xp(e,n.aspect,r[0],r[1],this.rulerMetres);i&&(this.setBackground(i),this.rulerPoints=null,this.rulerMetres=0,this.deps.refresh())}};var ef=.1,ol=(t,e,n)=>m`<button class="nf-btn nf-wide ${t?"nf-primary":""}" aria-pressed=${t} @click=${n}>${e}</button>`;function Pw(t,e){let n=e.ruler;if(!n)return _;if(n.length<2)return S(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]),i=()=>e.applyRuler();return m`${S(t.t("bg_ruler_length_hint",{m:K(t.hass,r,2)}),"nf-wide")}
</g>`}var rl=t=>Math.round(t*1e3)/1e3,il=(t,e)=>t.width*e,er=(t,e)=>[t.x+t.width/2,t.z+il(t,e)/2];function Gp(t,e,n){let[r,i]=[t[0]-e[0],t[1]-e[1]];return[e[0]+r*Math.cos(n)-i*Math.sin(n),e[1]+r*Math.sin(n)+i*Math.cos(n)]}var Zp=t=>((t+180)%360+360)%360-180;function qp(t,e,n){return{x:rl(t[0]-e/2),z:rl(t[1]-n/2)}}function Yp(t,e,n,r){if(Math.hypot(r[0]-n[0],r[1]-n[1])<.05)return null;let i=Math.atan2(r[1]-n[1],r[0]-n[0]),o=Math.round(i/(Math.PI/2))*(Math.PI/2)-i;if(Math.abs(o)<1e-4)return null;let s=Gp(er(t,e),n,o),l=Math.round(Zp((t.rotation??0)+o*180/Math.PI)*100)/100;return{...t,rotation:l,...qp(s,t.width,il(t,e))}}function Xp(t,e,n,r,i){let o=Math.hypot(r[0]-n[0],r[1]-n[1]);if(!(i>0)||o<1e-4)return null;let s=i/o,[l,a]=er(t,e),c=[n[0]+s*(l-n[0]),n[1]+s*(a-n[1])],u=t.width*s;return{...t,width:rl(u),...qp(c,u,il(t,e)*s)}}function Jp(t,e,n){let r=Gp(n,er(t,e),-(t.rotation??0)*Math.PI/180);return[r[0]-t.x,r[1]-t.z]}function Qp(t,e,n,r){let i=t+(n-e)*180/Math.PI;return Zp(r?Math.round(i/15)*15:Math.round(i*10)/10)}var zw=2048;async function tr(t){let e=await createImageBitmap(t),n=Math.min(1,zw/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 Ko=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 i=await r.fetchImage(n.hass,e),o=await this.aspectOf(i);this.pictures={...this.pictures,[e]:{url:i,aspect:o}},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:i,aspect:o}=await this.deps.readPicture(e),s=I("img");await r.storeImage(n.hass,s,i),this.pictures={...this.pictures,[s]:{url:i,aspect:o}};let l=n.floor?.rooms??[],a=l.length>0?de(l.flatMap(u=>u.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,i=this.picture(r?.image_id),o=r&&i?Yp(r,i.aspect,e,n):null;o&&this.setBackground(o)}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 i=Xp(e,n.aspect,r[0],r[1],this.rulerMetres);i&&(this.setBackground(i),this.rulerPoints=null,this.rulerMetres=0,this.deps.refresh())}};var ef=.1,ol=(t,e,n)=>m`<button class="nf-btn nf-wide ${t?"nf-primary":""}" aria-pressed=${t} @click=${n}>${e}</button>`;function Pw(t,e){let n=e.ruler;if(!n)return _;if(n.length<2)return S(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]),i=()=>e.applyRuler();return m`${S(t.t("bg_ruler_length_hint",{m:K(t.hass,r,2)}),"nf-wide")}
<label class="nf-field"
>${t.t("bg_ruler_length")}
<input
@@ -891,7 +891,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
min="0.01"
step="0.01"
.value=${e.rulerLength?String(e.rulerLength):""}
@input=${o=>e.rulerLength=aa(o.target.value)||0}
@input=${o=>e.rulerLength=la(o.target.value)||0}
@keydown=${o=>o.key==="Enter"&&i()}
/>
</label>
@@ -920,13 +920,13 @@ ${o}`}else i=op(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)}>${i("background_remove")}</button>`:_}
</div>
</details>`}var Iw=t=>t.map((e,n)=>[e,t[(n+1)%t.length]]);function Ow(t,e,n){let r=U(n,e),i=te(r,r),o=i?Math.max(0,Math.min(1,te(U(t,e),r)/i)):0;return ge(U(t,[e[0]+r[0]*o,e[1]+r[1]*o]))}function nf(t,e,n=.03){return t.every(r=>C(r,e)||Iw(e).some(([i,o])=>Ow(r,i,o)<=n))}var sl=["straight","quarter","l","half","u","spiral"],al=["solid","stringer","mono","cantilever"],ll=["none","left","right","both"],cl=["headroom","full","none"],_t={shape:"straight",turn:"right",build:"solid",risers:!0,steps:null,run_width:null,down:!1,rail:"none",opening:"headroom",landing_after:null},ul={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]},lf=2,cf=40;var Ko=(t,e)=>typeof e=="string"&&t.includes(e);function ki(t){let e=t.stair??{},n=typeof e.steps=="number"&&Number.isFinite(e.steps)?Math.round(Math.min(cf,Math.max(lf,e.steps))):null,r=typeof e.run_width=="number"&&Number.isFinite(e.run_width)&&e.run_width>.2?e.run_width:null;return{shape:Ko(sl,e.shape)?e.shape:_t.shape,turn:e.turn==="left"?"left":"right",build:Ko(al,e.build)?e.build:_t.build,risers:e.risers!==!1,steps:n,run_width:r,down:e.down===!0,rail:Ko(ll,e.rail)?e.rail:_t.rail,opening:Ko(cl,e.opening)?e.opening:_t.opening,landing_after:typeof e.landing_after=="number"&&Number.isFinite(e.landing_after)?Math.max(1,Math.round(e.landing_after)):null}}var vi=(t,e,n)=>[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n],rf=(t,e)=>Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6;function uf(t){let e=[];for(let n of t)(!e.length||!rf(e[e.length-1],n))&&e.push(n);for(;e.length>1&&rf(e[0],e[e.length-1]);)e.pop();return e}function wi(t,e,n=!1){return{poly:uf([...t,...[...e].reverse()]),landing:n,left:t,right:e}}function yi(t,e,n,r,i){let o=[];for(let s=0;s<i;s++){let[l,a]=[s/i,(s+1)/i];o.push(wi([vi(t,n,l),vi(t,n,a)],[vi(e,r,l),vi(e,r,a)]))}return o}function of(t,e){let n=e;for(let r=0;r+1<t.length;r++){let i=Math.hypot(t[r+1][0]-t[r][0],t[r+1][1]-t[r][1]);if(n<=i||r+2===t.length)return vi(t[r],t[r+1],i?Math.min(1,n/i):0);n-=i}return t[t.length-1]}function Hw(t,e,n){let r=[of(t,e)],i=0;for(let o=0;o+1<t.length;o++)i+=Math.hypot(t[o+1][0]-t[o][0],t[o+1][1]-t[o][1]),i>e+1e-6&&i<n-1e-6&&r.push(t[o+1]);return r.push(of(t,n)),r}var Lw=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 sf(t,e,n,r,i){let o=Lw(t),s=[];for(let l=0;l<i;l++){let a=uf([...l===0?[e]:[],n,...l===i-1?[r]:[]]);s.push(wi(Hw(t,o*l/i,o*(l+1)/i),a.length?a:[n]))}return s}function jo(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 af(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 Cw(t,e,n,r){let[i,o,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=[i+a,s+a],u=[[i,s+a],[i,s],[i+a,s]],d=t.shape==="l"?1:Math.min(r,r>=8?3:2),[p,h]=t.shape==="l"?af(t,r)??jo(r-d,n-a,e-a):jo(r-d,n-a,e-a),f=yi([i,l],[i+a,l],[i,s+a],c,p),g=t.shape==="l"?[wi(u,[c],!0)]:sf(u,c,c,c,d),b=yi([i+a,s],c,[o,s],[o,s+a],h);return{treads:[...f,...g,...b],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,u=[[i,c],[i,s],[o,s],[o,c]],[d,p]=[[i+a,c],[o-a,c]],h=t.shape==="u"?1:Math.min(r,r>=12?6:r>=8?4:2),[f,g]=t.shape==="u"?af(t,r)??jo(r-h,n-a,n-a):jo(r-h,n-a,n-a),b=yi([i,l],[i+a,l],[i,c],d,f),y=t.shape==="u"?[wi(u,[d,p],!0)]:sf(u,d,[0,c],p,h),v=yi([o,c],p,[o,l],[o-a,l],g);return{treads:[...b,...y,...v],flight:a,column:0}}case"spiral":{let a=Math.min(e,n)/2,c=Math.min(.08,a*.12),u=Math.min(.75,Math.max(.3,.22/(a*.6))),d=(h,f)=>[Math.cos(f)*h,Math.sin(f)*h],p=[];for(let h=0;h<r;h++){let[f,g]=[Math.PI+u*h,Math.PI+u*(h+1)],b=[0,.5,1].map(y=>d(a,f+(g-f)*y));p.push(wi(b,[d(c,f),d(c,g)]))}return{treads:p,flight:a-c,column:c}}default:return{treads:yi([i,l],[o,l],[i,s],[o,s],r),flight:e,column:0}}}var Nw=(t,e)=>t.steps??Math.min(cf,Math.max(lf,Math.round(Math.abs(e)/.18)));function wn(t,e,n,r){let i=Nw(t,r),o=Math.abs(r)/i,s=Cw(t,Math.max(.3,e),Math.max(.3,n),i),l=c=>[-c[0],c[1]];return{treads:s.treads.map((c,u)=>{let d=t.down?-o*(u+1):o*(u+1);return t.turn==="right"?{...c,top:d}:{poly:c.poly.map(l).reverse(),top:d,landing:c.landing,left:c.right.map(l),right:c.left.map(l)}}),rise:o,steps:i,column:s.column,flight:s.flight}}function Uo(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 ne=t=>Math.round(t*1e3)/1e3,Bw=(t,e)=>((t+e)%360+360)%360;function df(t,e){return{id:I("wall"),a:[ne(t[0]),ne(t[1])],b:[ne(e[0]),ne(e[1])],thickness:null}}function hf(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[ne(t.a[0]+(t.b[0]-t.a[0])*r),ne(t.a[1]+(t.b[1]-t.a[1])*r)]}var pf=(t,e)=>({height:t>=e-.005?null:Math.max(.05,t)});function ff(t,e){return{id:I("hole"),type:"stairwell",x:ne((t[0]+e[0])/2),z:ne((t[1]+e[Line truncated
</details>`}var Iw=t=>t.map((e,n)=>[e,t[(n+1)%t.length]]);function Ow(t,e,n){let r=U(n,e),i=te(r,r),o=i?Math.max(0,Math.min(1,te(U(t,e),r)/i)):0;return ge(U(t,[e[0]+r[0]*o,e[1]+r[1]*o]))}function nf(t,e,n=.03){return t.every(r=>C(r,e)||Iw(e).some(([i,o])=>Ow(r,i,o)<=n))}var sl=["straight","quarter","l","half","u","spiral"],al=["solid","stringer","mono","cantilever"],ll=["none","left","right","both"],cl=["headroom","full","none"],_t={shape:"straight",turn:"right",build:"solid",risers:!0,steps:null,run_width:null,down:!1,rail:"none",opening:"headroom",landing_after:null},ul={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]},lf=2,cf=40;var jo=(t,e)=>typeof e=="string"&&t.includes(e);function ki(t){let e=t.stair??{},n=typeof e.steps=="number"&&Number.isFinite(e.steps)?Math.round(Math.min(cf,Math.max(lf,e.steps))):null,r=typeof e.run_width=="number"&&Number.isFinite(e.run_width)&&e.run_width>.2?e.run_width:null;return{shape:jo(sl,e.shape)?e.shape:_t.shape,turn:e.turn==="left"?"left":"right",build:jo(al,e.build)?e.build:_t.build,risers:e.risers!==!1,steps:n,run_width:r,down:e.down===!0,rail:jo(ll,e.rail)?e.rail:_t.rail,opening:jo(cl,e.opening)?e.opening:_t.opening,landing_after:typeof e.landing_after=="number"&&Number.isFinite(e.landing_after)?Math.max(1,Math.round(e.landing_after)):null}}var vi=(t,e,n)=>[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n],rf=(t,e)=>Math.abs(t[0]-e[0])<1e-6&&Math.abs(t[1]-e[1])<1e-6;function uf(t){let e=[];for(let n of t)(!e.length||!rf(e[e.length-1],n))&&e.push(n);for(;e.length>1&&rf(e[0],e[e.length-1]);)e.pop();return e}function wi(t,e,n=!1){return{poly:uf([...t,...[...e].reverse()]),landing:n,left:t,right:e}}function yi(t,e,n,r,i){let o=[];for(let s=0;s<i;s++){let[l,a]=[s/i,(s+1)/i];o.push(wi([vi(t,n,l),vi(t,n,a)],[vi(e,r,l),vi(e,r,a)]))}return o}function of(t,e){let n=e;for(let r=0;r+1<t.length;r++){let i=Math.hypot(t[r+1][0]-t[r][0],t[r+1][1]-t[r][1]);if(n<=i||r+2===t.length)return vi(t[r],t[r+1],i?Math.min(1,n/i):0);n-=i}return t[t.length-1]}function Hw(t,e,n){let r=[of(t,e)],i=0;for(let o=0;o+1<t.length;o++)i+=Math.hypot(t[o+1][0]-t[o][0],t[o+1][1]-t[o][1]),i>e+1e-6&&i<n-1e-6&&r.push(t[o+1]);return r.push(of(t,n)),r}var Lw=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 sf(t,e,n,r,i){let o=Lw(t),s=[];for(let l=0;l<i;l++){let a=uf([...l===0?[e]:[],n,...l===i-1?[r]:[]]);s.push(wi(Hw(t,o*l/i,o*(l+1)/i),a.length?a:[n]))}return s}function Uo(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 af(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 Cw(t,e,n,r){let[i,o,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=[i+a,s+a],u=[[i,s+a],[i,s],[i+a,s]],d=t.shape==="l"?1:Math.min(r,r>=8?3:2),[p,h]=t.shape==="l"?af(t,r)??Uo(r-d,n-a,e-a):Uo(r-d,n-a,e-a),f=yi([i,l],[i+a,l],[i,s+a],c,p),g=t.shape==="l"?[wi(u,[c],!0)]:sf(u,c,c,c,d),b=yi([i+a,s],c,[o,s],[o,s+a],h);return{treads:[...f,...g,...b],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,u=[[i,c],[i,s],[o,s],[o,c]],[d,p]=[[i+a,c],[o-a,c]],h=t.shape==="u"?1:Math.min(r,r>=12?6:r>=8?4:2),[f,g]=t.shape==="u"?af(t,r)??Uo(r-h,n-a,n-a):Uo(r-h,n-a,n-a),b=yi([i,l],[i+a,l],[i,c],d,f),y=t.shape==="u"?[wi(u,[d,p],!0)]:sf(u,d,[0,c],p,h),v=yi([o,c],p,[o,l],[o-a,l],g);return{treads:[...b,...y,...v],flight:a,column:0}}case"spiral":{let a=Math.min(e,n)/2,c=Math.min(.08,a*.12),u=Math.min(.75,Math.max(.3,.22/(a*.6))),d=(h,f)=>[Math.cos(f)*h,Math.sin(f)*h],p=[];for(let h=0;h<r;h++){let[f,g]=[Math.PI+u*h,Math.PI+u*(h+1)],b=[0,.5,1].map(y=>d(a,f+(g-f)*y));p.push(wi(b,[d(c,f),d(c,g)]))}return{treads:p,flight:a-c,column:c}}default:return{treads:yi([i,l],[o,l],[i,s],[o,s],r),flight:e,column:0}}}var Nw=(t,e)=>t.steps??Math.min(cf,Math.max(lf,Math.round(Math.abs(e)/.18)));function wn(t,e,n,r){let i=Nw(t,r),o=Math.abs(r)/i,s=Cw(t,Math.max(.3,e),Math.max(.3,n),i),l=c=>[-c[0],c[1]];return{treads:s.treads.map((c,u)=>{let d=t.down?-o*(u+1):o*(u+1);return t.turn==="right"?{...c,top:d}:{poly:c.poly.map(l).reverse(),top:d,landing:c.landing,left:c.right.map(l),right:c.left.map(l)}}),rise:o,steps:i,column:s.column,flight:s.flight}}function Go(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 ne=t=>Math.round(t*1e3)/1e3,Bw=(t,e)=>((t+e)%360+360)%360;function df(t,e){return{id:I("wall"),a:[ne(t[0]),ne(t[1])],b:[ne(e[0]),ne(e[1])],thickness:null}}function hf(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[ne(t.a[0]+(t.b[0]-t.a[0])*r),ne(t.a[1]+(t.b[1]-t.a[1])*r)]}var pf=(t,e)=>({height:t>=e-.005?null:Math.max(.05,t)});function ff(t,e){return{id:I("hole"),type:"stairwell",x:ne((t[0]+e[0])/2),z:ne((t[1]+e[Line truncated
◠ ${t.t("arc")}
</button>`}function Zo(t,e,n){let r=n.edit;if(!t.admin||r?.key!==e)return _;let i=t.t;return m`<span class="nf-wide nf-split-row" title=${i("arc_bulge_hint")}
</button>`}function qo(t,e,n){let r=n.edit;if(!t.admin||r?.key!==e)return _;let i=t.t;return m`<span class="nf-wide nf-split-row" title=${i("arc_bulge_hint")}
>${E(t,i("arc_bulge"),r.bulge,o=>n.setEdit({...r,bulge:o,error:null}),.05)}
<button class="nf-btn nf-primary" ?disabled=${Math.abs(r.bulge)<.01} @click=${()=>n.apply(r)}>${i("arc_apply")}</button></span
>
${r.error?m`<p class="nf-sub nf-wide nf-notice">${r.error}</p>`:_}`}var qo=(t,e,n)=>Math.min(e,Math.max(t,ae(n)));function pl(t,e,n){let r=t.t,i=a=>n.update(a),o=de(e.points),s=pu.map(a=>[a,r(`out_${a}`)]),l=fu.map(a=>[a,r(`slope_${a.replace("-","n")}`)]);return m`<section>
${r.error?m`<p class="nf-sub nf-wide nf-notice">${r.error}</p>`:_}`}var Yo=(t,e,n)=>Math.min(e,Math.max(t,ae(n)));function pl(t,e,n){let r=t.t,i=a=>n.update(a),o=de(e.points),s=pu.map(a=>[a,r(`out_${a}`)]),l=fu.map(a=>[a,r(`slope_${a.replace("-","n")}`)]);return m`<section>
<div class="nf-h3row"><h3>${r("outdoor")}</h3>${n.lockButton}</div>
<div class="nf-form">
${H(t,r("outdoor_type"),e.type,s,a=>i({type:a}),{wide:!0})}
@@ -935,9 +935,9 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${z(t,r("pool_pump"),e.pump_entity??null,void 0,O(t.hass,a=>/^(switch|fan|valve|input_boolean|binary_sensor)\./.test(a)),a=>i({pump_entity:a&&a!=="none"?a:null}))}`:_}
${zn(e.points)?m`${E(t,r("x"),o.x0,a=>n.setRectangle("x",a))} ${E(t,r("z"),o.z0,a=>n.setRectangle("z",a))}
${E(t,r("width"),o.x1-o.x0,a=>n.setRectangle("w",a),.01,.1)} ${E(t,r("depth"),o.z1-o.z0,a=>n.setRectangle("d",a),.01,.1)}`:_}
${Os(e.type)?E(t,r("outdoor_height"),e.height??Is[e.type],a=>i({height:qo(.1,6,a)}),.05,.1):_}
${E(t,r("outdoor_offset"),e.offset??0,a=>i({offset:qo(-10,10,a)||null}),.05)}
${e.type!=="pool"?m`${E(t,r("outdoor_slope"),e.slope??0,a=>i({slope:qo(0,20,a)||null}),.05,0)}
${Hs(e.type)?E(t,r("outdoor_height"),e.height??Os[e.type],a=>i({height:Yo(.1,6,a)}),.05,.1):_}
${E(t,r("outdoor_offset"),e.offset??0,a=>i({offset:Yo(-10,10,a)||null}),.05)}
${e.type!=="pool"?m`${E(t,r("outdoor_slope"),e.slope??0,a=>i({slope:Yo(0,20,a)||null}),.05,0)}
${H(t,r("outdoor_slope_dir"),e.slope_dir??"x",l,a=>i({slope_dir:a}))}`:_}
${E(t,r("outdoor_opacity"),Math.round((e.opacity??1)*100),a=>i({opacity:a>=100||!(a>0)?null:Math.max(10,Math.min(95,a))/100}),5,10)}
${D(t,r("outdoor_outline"),e.outline!==!1,a=>i({outline:a?void 0:!1}),{title:r("outdoor_outline_hint")})}
@@ -990,15 +990,15 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<div class="nf-h3row"><h3>${r("free_wall")}</h3>${n.lockButton}</div>
<div class="nf-form">
${E(t,r("wall_length"),o,s=>n.update({b:hf(e,s)}),.01,.1)}
${E(t,r("wall_thickness"),e.thickness??t.doc.settings.wall_interior,s=>n.update({thickness:qo(.02,1,s)}),.01,.02)}
${E(t,r("wall_thickness"),e.thickness??t.doc.settings.wall_interior,s=>n.update({thickness:Yo(.02,1,s)}),.01,.02)}
${E(t,r("wall_height"),e.height??i,s=>n.update(pf(s,i)),.05,.05)}
${D(t,r("free_wall_slope"),e.height_end!=null,s=>n.update(s?{height:e.height??i,height_end:Math.max(.2,(e.height??i)/2)}:{height_end:null}),{title:r("free_wall_slope_hint")})}
${e.height_end!=null?E(t,r("free_wall_height_end"),e.height_end,s=>n.update({height_end:Math.max(.05,s)}),.05,.05):_}
</div>
${t.admin?m`<div class="nf-actions">${Go(t,`wall:${e.id}`,n.arc)}<button class="nf-btn nf-danger" @click=${()=>n.remove()}>${r("delete")}</button></div>`:_}
<div class="nf-form">${Zo(t,`wall:${e.id}`,n.arc)}</div>
${t.admin?m`<div class="nf-actions">${Zo(t,`wall:${e.id}`,n.arc)}<button class="nf-btn nf-danger" @click=${()=>n.remove()}>${r("delete")}</button></div>`:_}
<div class="nf-form">${qo(t,`wall:${e.id}`,n.arc)}</div>
${S(r("free_wall_hint"))}
</section>`}var Gt=t=>Math.round(t*1e3)/1e3,jw=2.4;function Tf(t,e,n){let r=va(t,e[0],e[1],n[0],n[1]),i=r===null,o=Math.min(...t.floors.map(a=>a.elevation)),s=Gt(r??o+jw),l=i?6:t.settings.roof.pitch||35;return{id:I("roof"),x0:Gt(e[0]),z0:Gt(e[1]),x1:Gt(n[0]),z1:Gt(n[1]),shape:i?"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:i?.15:null,...i?{open:!0}:{}}}function zf(t){let e=n=>Gt(n+1);return{...structuredClone(t),id:I("roof"),x0:e(t.x0),x1:e(t.x1),z0:e(t.z0),z1:e(t.z1)}}var Pf=(t,e)=>t.findIndex(n=>n.id===e)+1;function ml(t){return t.points&&t.points.length>=3?t.points.map(([e,n])=>[e,n]):t.rotation?Lr(t):[[t.x0,t.z0],[t.x1,t.z0],[t.x1,t.z1],[t.x0,t.z1]]}function Df(t,e,n){let r=ml(t);r.splice(e+1,0,[Gt(n[0]),Gt(n[1])]),t.points=r,Object.assign(t,Kt(r))}function If(t,e){return!t.points||t.points.length<=3||e<0||e>=t.points.length?!1:(t.points.splice(e,1),Object.assign(t,Kt(t.points)),!0)}var Uw={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"},Zt=t=>Uw[t];function Yo(t,e){let n=new Set;for(let r of t?.placements??[])C([r.x,r.z],e.points)&&n.add(r.entity_id);for(let r of t?.furniture??[])ue(r.type)&&r.entity&&C([r.x,r.z],e.points)&&n.add(r.entity);return n}function Of(t,e){let n=new Map;for(let r of t.floors){let i=[...r.placements.map(o=>[o.entity_id,o.x,o.z]),...r.furniture.filter(o=>ue(o.type)&&o.entity).map(o=>[o.entity,o.x,o.z])];for(let[o,s,l]of i){let a=r.rooms.find(c=>C([s,l],c.points));a&&a.id!==e.id&&n.set(o,a.name)}}return n}var Hf=(t,e)=>(t??[]).includes(e)?(t??[]).filter(n=>n!==e):[...t??[],e];function Xo(t,...e){let n=t.trim().toLowerCase();return!n||e.some(r=>(r??"").toLowerCase().includes(n))}function Lf(t,e){return t.map(n=>({o:n,r:e(n.id)})).sort((n,r)=>n.r-r.r).map(({o:n})=>n)}function Cf(t,e){let n=e,r=0;return{taken:t.map(o=>{let s=o.ids.slice(0,Math.max(0,n));return n-=s.length,r+=o.ids.length-s.length,[...s]}),left:r}}var gl=50;function _l(t,e,n,r,i,o,s){let l=e.includes(n);return m`<button class="nf-pin ${l?"nf-pin-on":""}" aria-pressed=${l} title=${t.t(l?o[0]:o[1])} @click=${()=>s.patchRoom({[r]:Hf(e,n)})}>${l?i[0]:i[1]}</button>`}function Gw(t,e,n,r,i,o){let[s,l,a]=[e.hidden??[],e.no_state??[],e.panel??[]];return(c,u=!1,d=i)=>{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 ${u?"nf-dev-extra":""} ${f?"nf-dev-hidden":""}">
</section>`}var Gt=t=>Math.round(t*1e3)/1e3,jw=2.4;function Tf(t,e,n){let r=wa(t,e[0],e[1],n[0],n[1]),i=r===null,o=Math.min(...t.floors.map(a=>a.elevation)),s=Gt(r??o+jw),l=i?6:t.settings.roof.pitch||35;return{id:I("roof"),x0:Gt(e[0]),z0:Gt(e[1]),x1:Gt(n[0]),z1:Gt(n[1]),shape:i?"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:i?.15:null,...i?{open:!0}:{}}}function zf(t){let e=n=>Gt(n+1);return{...structuredClone(t),id:I("roof"),x0:e(t.x0),x1:e(t.x1),z0:e(t.z0),z1:e(t.z1)}}var Pf=(t,e)=>t.findIndex(n=>n.id===e)+1;function ml(t){return t.points&&t.points.length>=3?t.points.map(([e,n])=>[e,n]):t.rotation?Lr(t):[[t.x0,t.z0],[t.x1,t.z0],[t.x1,t.z1],[t.x0,t.z1]]}function Df(t,e,n){let r=ml(t);r.splice(e+1,0,[Gt(n[0]),Gt(n[1])]),t.points=r,Object.assign(t,Kt(r))}function If(t,e){return!t.points||t.points.length<=3||e<0||e>=t.points.length?!1:(t.points.splice(e,1),Object.assign(t,Kt(t.points)),!0)}var Uw={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"},Zt=t=>Uw[t];function Xo(t,e){let n=new Set;for(let r of t?.placements??[])C([r.x,r.z],e.points)&&n.add(r.entity_id);for(let r of t?.furniture??[])ue(r.type)&&r.entity&&C([r.x,r.z],e.points)&&n.add(r.entity);return n}function Of(t,e){let n=new Map;for(let r of t.floors){let i=[...r.placements.map(o=>[o.entity_id,o.x,o.z]),...r.furniture.filter(o=>ue(o.type)&&o.entity).map(o=>[o.entity,o.x,o.z])];for(let[o,s,l]of i){let a=r.rooms.find(c=>C([s,l],c.points));a&&a.id!==e.id&&n.set(o,a.name)}}return n}var Hf=(t,e)=>(t??[]).includes(e)?(t??[]).filter(n=>n!==e):[...t??[],e];function Jo(t,...e){let n=t.trim().toLowerCase();return!n||e.some(r=>(r??"").toLowerCase().includes(n))}function Lf(t,e){return t.map(n=>({o:n,r:e(n.id)})).sort((n,r)=>n.r-r.r).map(({o:n})=>n)}function Cf(t,e){let n=e,r=0;return{taken:t.map(o=>{let s=o.ids.slice(0,Math.max(0,n));return n-=s.length,r+=o.ids.length-s.length,[...s]}),left:r}}var gl=50;function _l(t,e,n,r,i,o,s){let l=e.includes(n);return m`<button class="nf-pin ${l?"nf-pin-on":""}" aria-pressed=${l} title=${t.t(l?o[0]:o[1])} @click=${()=>s.patchRoom({[r]:Hf(e,n)})}>${l?i[0]:i[1]}</button>`}function Gw(t,e,n,r,i,o){let[s,l,a]=[e.hidden??[],e.no_state??[],e.panel??[]];return(c,u=!1,d=i)=>{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 ${u?"nf-dev-extra":""} ${f?"nf-dev-hidden":""}">
<button class="nf-dev-name ${p?"":"nf-muted"}" ?disabled=${!p} @click=${()=>o.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=${Zt((t.hass?je(t.hass,c):Q(c))??"sensor")} /></svg>`}
<span>${B(t.hass,c,d)}${h?m`<small class="nf-muted"> · ${t.t("devices_placed_in",{room:h})}</small>`:_}</span>
@@ -1007,18 +1007,18 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${t.admin&&!f?_l(t,l,c,"no_state",["\u2205","Aa"],["panel_state_show","panel_state_hide"],o):_}
${t.admin&&!p?_l(t,a,c,"panel",["\u2605","\u2606"],["panel_unpin","panel_pin"],o):_}
${t.admin?p?m`<button class="nf-link" @click=${()=>o.remove(c)}>${t.t("devices_remove")}</button>`:m`<button class="nf-link" @click=${()=>o.place([c])}>${t.t("devices_place")}</button>`:_}
</div>`}}function Zw(t,e,n,r,i){let{hass:o}=t;if(!o)return m``;let s=u=>u>0?S(t.t("devices_narrow",{n:u})):_,l=S(t.t("devices_none")),a=e.deviceQuery;if(i==="other"){let u=Bu(o,n.area_id).map(f=>({...f,ids:f.ids.filter(g=>Xo(a,`${B(o,g,f.name)} ${g} ${f.name}`))})),{taken:d,left:p}=Cf(u,gl),h=u.map((f,g)=>d[g].length>0?m`<div class="nf-dev-area">${f.name}</div>${d[g].map(b=>r(b,!1,f.name))}`:_);return d.some(f=>f.length>0)?m`<div class="nf-room-list">${h}</div>${s(p)}`:l}let c=Wu(o).filter(u=>Xo(a,`${B(o,u)} ${u} `));return c.length>0?m`<div class="nf-room-list">${c.slice(0,gl).map(u=>r(u))}</div>${s(c.length-Math.min(c.length,gl))}`:l}function qw(t,e,n,r,i,o,s){let{hass:l}=t,a=l?ye(l,n).filter(y=>Ft(je(l,y))):[];if(!n.area_id)return S(t.t("devices_none_area"));if(a.length===0)return S(t.t("devices_none"));let c=l?Dn(l,a):[],u=c.map(y=>y.primary).filter(y=>!i.has(y)),d=e.deviceQuery,p=(t.floor?.placements??[]).filter(y=>Q(y.entity_id)==="light"&&(y.mount??"ceiling")==="ceiling"&&C([y.x,y.z],n.points)).length,h=m`<input class="nf-search" type="search" placeholder=${t.t("devices_search")} .value=${d} @input=${y=>e.deviceQuery=y.target.value} />`,f=y=>Xo(d,B(l,y,o),y),g=y=>{let v=y.others.filter(f),w=e.isUnfolded(y.primary)||!!d.trim()&&v.length>0;return!f(y.primary)&&v.length===0?_:m`${r(y.primary)}
</div>`}}function Zw(t,e,n,r,i){let{hass:o}=t;if(!o)return m``;let s=u=>u>0?S(t.t("devices_narrow",{n:u})):_,l=S(t.t("devices_none")),a=e.deviceQuery;if(i==="other"){let u=Bu(o,n.area_id).map(f=>({...f,ids:f.ids.filter(g=>Jo(a,`${B(o,g,f.name)} ${g} ${f.name}`))})),{taken:d,left:p}=Cf(u,gl),h=u.map((f,g)=>d[g].length>0?m`<div class="nf-dev-area">${f.name}</div>${d[g].map(b=>r(b,!1,f.name))}`:_);return d.some(f=>f.length>0)?m`<div class="nf-room-list">${h}</div>${s(p)}`:l}let c=Wu(o).filter(u=>Jo(a,`${B(o,u)} ${u} `));return c.length>0?m`<div class="nf-room-list">${c.slice(0,gl).map(u=>r(u))}</div>${s(c.length-Math.min(c.length,gl))}`:l}function qw(t,e,n,r,i,o,s){let{hass:l}=t,a=l?ye(l,n).filter(y=>Ft(je(l,y))):[];if(!n.area_id)return S(t.t("devices_none_area"));if(a.length===0)return S(t.t("devices_none"));let c=l?Dn(l,a):[],u=c.map(y=>y.primary).filter(y=>!i.has(y)),d=e.deviceQuery,p=(t.floor?.placements??[]).filter(y=>Q(y.entity_id)==="light"&&(y.mount??"ceiling")==="ceiling"&&C([y.x,y.z],n.points)).length,h=m`<input class="nf-search" type="search" placeholder=${t.t("devices_search")} .value=${d} @input=${y=>e.deviceQuery=y.target.value} />`,f=y=>Jo(d,B(l,y,o),y),g=y=>{let v=y.others.filter(f),w=e.isUnfolded(y.primary)||!!d.trim()&&v.length>0;return!f(y.primary)&&v.length===0?_:m`${r(y.primary)}
${y.others.length>0?m`<button class="nf-more" @click=${()=>e.toggleUnfolded(y.primary)}>${w?t.t("devices_less"):t.t("devices_more",{n:y.others.length})}</button>`:_}
${w?(d.trim()?v:y.others).map(x=>r(x,!0)):_}`},b=()=>s.confirm(t.t("devices_place_all_confirm",{n:u.length}))&&s.place(u);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&&u.length>1?m`<button class="nf-link nf-place-all" @click=${b}>${t.t("devices_place_all_n",{n:u.length})}</button>`:_}
${S(t.t("devices_hint"))}`}function bl(t,e,n,r){let{hass:i}=t,o=n.area_id?i?.areas?.[n.area_id]?.name:void 0,s=Yo(t.floor,n),l=Gw(t,n,s,Of(t.doc,n),o,r),a=t.admin?e.deviceSource:"area",c=i?Dn(i,ye(i,n).filter(p=>Ft(je(i,p)))).length:0,u=[["area",`${t.t("devices_src_area")}${c>0?` (${c})`:""}`],["other",t.t("devices_src_other")],["none",t.t("devices_src_none")]],d=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>
${S(t.t("devices_hint"))}`}function bl(t,e,n,r){let{hass:i}=t,o=n.area_id?i?.areas?.[n.area_id]?.name:void 0,s=Xo(t.floor,n),l=Gw(t,n,s,Of(t.doc,n),o,r),a=t.admin?e.deviceSource:"area",c=i?Dn(i,ye(i,n).filter(p=>Ft(je(i,p)))).length:0,u=[["area",`${t.t("devices_src_area")}${c>0?` (${c})`:""}`],["other",t.t("devices_src_other")],["none",t.t("devices_src_none")]],d=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>
${S(t.t("devices_panel_hint"))}
${t.admin?m`<div class="nf-seg nf-dev-source">${u.map(([p,h])=>m`<button aria-pressed=${a===p} @click=${()=>e.deviceSource=p}>${h}</button>`)}</div>`:_}
${a!=="area"?m`${d}${Zw(t,e,n,l,a)}`:qw(t,e,n,l,s,o,r)}
</section>`}function Nf(t,e,n){let{hass:r}=t;if(!r)return _;let i=!!e.floor_heating||!!e.hvac||!!e.climate&&Object.values(e.climate).some(l=>l!=null),o=(l,a)=>{let c={...e.climate??{},[l]:a};n({climate:Object.values(c).every(u=>u==null)?null:c})},s=(l,a)=>{let c=Vu(r,t.floor??null,{...e,climate:null},l),u=[e.climate?.[l]??null].flat(),d=O(r,b=>Ys(r,b,l,!0)&&(!r.states[b]?.attributes.symcon_source_entity||u.includes(b))),p=Lf(d,b=>(Dt(r,b)===e.area_id?0:1)+(Xs(r,b)?0:2)),h=b=>{let y=b.filter(v=>!!v&&v!=="none");o(l,y.length>1?y:y[0]??(b.includes("none")?"none":null))},g=u[0]&&u[0]!=="none"?[...u,null]:u;return g.map((b,y)=>z(t,y?t.t("climate_more"):a,b,y?void 0:c[0]??null,p,v=>h(g.map((w,x)=>x===y?v:w)),{types:[1,2]}))};return m`<details class="nf-points" ?open=${i||!!e.climate_card}>
</section>`}function Nf(t,e,n){let{hass:r}=t;if(!r)return _;let i=!!e.floor_heating||!!e.hvac||!!e.climate&&Object.values(e.climate).some(l=>l!=null),o=(l,a)=>{let c={...e.climate??{},[l]:a};n({climate:Object.values(c).every(u=>u==null)?null:c})},s=(l,a)=>{let c=Vu(r,t.floor??null,{...e,climate:null},l),u=[e.climate?.[l]??null].flat(),d=O(r,b=>Xs(r,b,l,!0)&&(!r.states[b]?.attributes.symcon_source_entity||u.includes(b))),p=Lf(d,b=>(Dt(r,b)===e.area_id?0:1)+(Js(r,b)?0:2)),h=b=>{let y=b.filter(v=>!!v&&v!=="none");o(l,y.length>1?y:y[0]??(b.includes("none")?"none":null))},g=u[0]&&u[0]!=="none"?[...u,null]:u;return g.map((b,y)=>z(t,y?t.t("climate_more"):a,b,y?void 0:c[0]??null,p,v=>h(g.map((w,x)=>x===y?v:w)),{types:[1,2]}))};return m`<details class="nf-points" ?open=${i||!!e.climate_card}>
<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"))} ${s("illuminance",t.t("climate_illuminance"))}${X(r)?Sh(t,e,n):_}</div>
${D(t,t.t("climate_card"),!!e.climate_card,l=>n({climate_card:l||void 0}))}
@@ -1220,7 +1220,7 @@ ${o}`}else i=op(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",$l);var i0=new URL(import.meta.url),o0=new URL("./nextfloor-3d.js?v=b12e75cc8bb7",i0).href,Qf;function kn(){return Qf??=import(o0),Qf}var em=["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"],s0={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"},a0=[[/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 l0(t){if(t.vehicle)return"vLine truncated
</div>`}};customElements.get("nf-ble-locate")||customElements.define("nf-ble-locate",$l);var i0=new URL(import.meta.url),o0=new URL("./nextfloor-3d.js?v=3f1d4fc7d907",i0).href,Qf;function kn(){return Qf??=import(o0),Qf}var em=["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"],s0={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"},a0=[[/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 l0(t){if(t.vehicle)return"vLine truncated
:host {
display: block;
aspect-ratio: 4 / 3;
@@ -1234,7 +1234,7 @@ ${o}`}else i=op(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(),qt.enabled&&(this._url=qt.cached(this.type)??null,!this._url&&($i??=new IntersectionObserver(h0,{rootMargin:"120px"}),$i.observe(this)))}disconnectedCallback(){super.disconnectedCallback(),$i?.unobserve(this)}updated(e){e.has("type")&&e.get("type")!==void 0&&(this._url=qt.cached(this.type)??null,!this._url&&qt.enabled&&$i?.observe(this))}visible(){$i?.unobserve(this);let e=this.type;qt.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",Al);var hm="nextfloor.library2",p0={language:"en"},Jo=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(hm);n&&(this.saved={...this.saved,...JSON.parse(n)})}catch{}}store(e){this.saved={...this.saved,...e},this.onChange();try{localStorage.setItem(hm,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:sm(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 i=n.getBoundingClientRect(),o={left:Math.max(8,i.left-196),top:Math.max(8,Math.min(window.innerHeight-200,i.top+i.height/2-95))};this.shown={type:e,url:null,...o},this.onChange();try{let[s,l,a]=dt(e),c=(await kn()).furniturePreview({type:e,w:s,d:l,h:a,variant:null,lamp:Qi[e]??null},180,[...r]);this.shown?.type===e&&(this.shown={type:e,url:c,...o})}catch{this.shown=null}this.onChange()}};function f0(t,e){let n=t.hass?.language??"en",i=[...[...new Set(Object.values(Mu).flat())].map(l=>({type:l,source:"builtin",id:l,size:nt[l],lamp:ue(l),electric:Tt(l)})),...e.flatMap(l=>l.items.map(a=>({type:he(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})))],o=new Map(e.map(l=>[l.id,Be(l,n)])),s=new Map(e.flatMap(l=>l.items.map(a=>[he(l.id,a.id),a])));return im(i).map(l=>{let a=l.entries[0],c=s.get(a.type),u=c?Je(c,a.type,n):t.t(`furn_${a.type}`),d=l.entries.length>1&&u.replace(/\s*\(?\d+([.,]\d+)?\s*(cm|x\s*\d+|×\s*\d+)?\)?\s*$/i,"").trim()||u,p=l.entries.map(h=>{let f=s.get(h.type);return f?[...Object.values(f.name),Je(f,h.type,n)].join(" "):we(p0,`furn_${h.type}`)}).join(" ");return{card:l,label:d,search:`${p} ${t.t(`lib_cat_${l.category}`)}`,from:o.get(a.source)??"NextFloor"}})}var m0=(t,e)=>cm(e,`${t.label} ${t.search} ${t.from} ${t.card.entries.map(n=>n.id.replace(/_/g," ")).join(" ")}`),g0=t=>t.lamp?"light":t.electric?"switch":null;function _0(t,e,n,r){let i=t.t,o=e.pickedOf(n.card),[s,l]=o.size,a=g0(o),c=p=>{e.showPreview(o.type,p.currentTarget,r.packs)},u=()=>{e.used(o.type),r.add(o.type)},d=e.isFavourite(o.type);return m`<div class="nf-card">
`;constructor(){super(),this.type="",this._url=null}connectedCallback(){super.connectedCallback(),qt.enabled&&(this._url=qt.cached(this.type)??null,!this._url&&($i??=new IntersectionObserver(h0,{rootMargin:"120px"}),$i.observe(this)))}disconnectedCallback(){super.disconnectedCallback(),$i?.unobserve(this)}updated(e){e.has("type")&&e.get("type")!==void 0&&(this._url=qt.cached(this.type)??null,!this._url&&qt.enabled&&$i?.observe(this))}visible(){$i?.unobserve(this);let e=this.type;qt.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",Al);var hm="nextfloor.library2",p0={language:"en"},Qo=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(hm);n&&(this.saved={...this.saved,...JSON.parse(n)})}catch{}}store(e){this.saved={...this.saved,...e},this.onChange();try{localStorage.setItem(hm,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:sm(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 i=n.getBoundingClientRect(),o={left:Math.max(8,i.left-196),top:Math.max(8,Math.min(window.innerHeight-200,i.top+i.height/2-95))};this.shown={type:e,url:null,...o},this.onChange();try{let[s,l,a]=dt(e),c=(await kn()).furniturePreview({type:e,w:s,d:l,h:a,variant:null,lamp:Qi[e]??null},180,[...r]);this.shown?.type===e&&(this.shown={type:e,url:c,...o})}catch{this.shown=null}this.onChange()}};function f0(t,e){let n=t.hass?.language??"en",i=[...[...new Set(Object.values(Mu).flat())].map(l=>({type:l,source:"builtin",id:l,size:nt[l],lamp:ue(l),electric:Tt(l)})),...e.flatMap(l=>l.items.map(a=>({type:he(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})))],o=new Map(e.map(l=>[l.id,Be(l,n)])),s=new Map(e.flatMap(l=>l.items.map(a=>[he(l.id,a.id),a])));return im(i).map(l=>{let a=l.entries[0],c=s.get(a.type),u=c?Je(c,a.type,n):t.t(`furn_${a.type}`),d=l.entries.length>1&&u.replace(/\s*\(?\d+([.,]\d+)?\s*(cm|x\s*\d+|×\s*\d+)?\)?\s*$/i,"").trim()||u,p=l.entries.map(h=>{let f=s.get(h.type);return f?[...Object.values(f.name),Je(f,h.type,n)].join(" "):we(p0,`furn_${h.type}`)}).join(" ");return{card:l,label:d,search:`${p} ${t.t(`lib_cat_${l.category}`)}`,from:o.get(a.source)??"NextFloor"}})}var m0=(t,e)=>cm(e,`${t.label} ${t.search} ${t.from} ${t.card.entries.map(n=>n.id.replace(/_/g," ")).join(" ")}`),g0=t=>t.lamp?"light":t.electric?"switch":null;function _0(t,e,n,r){let i=t.t,o=e.pickedOf(n.card),[s,l]=o.size,a=g0(o),c=p=>{e.showPreview(o.type,p.currentTarget,r.packs)},u=()=>{e.used(o.type),r.add(o.type)},d=e.isFavourite(o.type);return m`<div class="nf-card">
<button
class="nf-card-main"
title=${a?i(a==="light"?"lib_badge_light":"lib_badge_electric"):n.label}
@@ -1281,13 +1281,13 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</section>`}function gm(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>${Ae(t.hass,e.type)}</b>
</div>`:_}function Tl(t,e,n,r=24){let i=Math.hypot(e[0]-t[0],e[1]-t[1]);if(i<1e-6||Math.abs(n)<1e-4)return[];let o=Math.max(-i*2,Math.min(i*2,n)),s=[(e[0]-t[0])/i,(e[1]-t[1])/i],l=[s[1],-s[0]],a=i*i/4/(2*Math.abs(o))+Math.abs(o)/2,c=2*Math.atan(2*Math.abs(o)/i),u=Math.max(2,Math.min(r,Math.ceil(2*c/Math.PI*180/11.25))),d=[l[0]*Math.sign(o),l[1]*Math.sign(o)],p=[(t[0]+e[0])/2,(t[1]+e[1])/2],h=[p[0]-d[0]*(a-Math.abs(o)),p[1]-d[1]*(a-Math.abs(o))],f=[];for(let g=1;g<u;g++){let b=-c+2*c*g/u;f.push([h[0]+a*(d[0]*Math.cos(b)+s[0]*Math.sin(b)),h[1]+a*(d[1]*Math.cos(b)+s[1]*Math.sin(b))])}return f}var zl=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 Pl(t,e){let n=Math.max(0,e);for(let r=0;r+1<t.length;r++){let i=Math.hypot(t[r+1][0]-t[r][0],t[r+1][1]-t[r][1]);if(n<=i||r+2===t.length)return{piece:r,offset:Math.min(n,i)};n-=i}return{piece:0,offset:0}}var Pe=t=>Math.round(t*1e3)/1e3,Dl=t=>t.map(([e,n])=>[Pe(e),Pe(n)]);function _m(t,e){return{id:I("room"),name:e,area_id:null,points:Dl(t),floor_material:"wood"}}function bm(t){return{...structuredClone(t),id:I("room"),points:Dl(t.points.map(([e,n])=>[e+.5,n+.5]))}}function ym(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=>!C([r.x,r.z],n.points)))}function vm(t,e,n){let r=t.rooms.find(s=>s.id===e);if(!r||r.points.length<=3)return!1;let i=(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 o=s=>s.room_id===e&&!s.wall;return t.openings=t.openings.filter(s=>!(o(s)&&(s.edge===n||s.edge===i))).map(s=>o(s)&&s.edge>n?{...s,edge:s.edge-1}:s),!0}function wm(t,e,n){if(!Number.isFinite(n))return null;let r=de(t.points),{x0:i,z0:o,x1:s,z1:l}=r;return e==="x"?[i,s]=[n,n+(s-i)]:e==="z"?[o,l]=[n,n+(l-o)]:n>.05&&(e==="w"?s=i+n:l=o+n),Dl([[i,o],[s,o],[s,l],[i,l]])}function km(t,e,n,r){return!Number.isFinite(r)||e<0||e>=t.points.length?null:t.points.map((i,o)=>o===e?n===0?[Pe(r),i[1]]:[i[0],Pe(r)]:[i[0],i[1]])}var y0=/^(Raum|Room) \d+$/;function Il(t,e,n,r=!0){let i=e?n[e]:void 0,o=!t.name||y0.test(t.name)||Object.values(n).some(s=>s.name===t.name);return{area_id:e||null,...r&&i&&o?{name:i.name}:{}}}function Ol(t,e){let n=/^symcon-category-(\d+)$/.exec(e)?.[1];return(n?t?.symconObjects?.find(r=>r.object_id===Number(n))?.name:void 0)??t?.areas?.[e]?.name.split(" / ").at(-1)?.trim()??""}function xm(t,e){let n=e.filter(a=>Q(a.entity_id)==="light"&&(a.mount??"ceiling")==="ceiling"&&C([a.x,a.z],t.points));if(n.length<2)return[];let r=de(t.points),[i,o]=[r.x1-r.x0,r.z1-r.z0],s=Math.max(1,Math.round(Math.sqrt(n.length*i/Math.max(.1,o)))),l=Math.ceil(n.length/s);return n.map((a,c)=>{let u=Math.floor(c/s),d=u===l-1?n.length-s*(l-1):s,p=c-u*s;return{entityId:a.entity_id,x:Pe(r.x0+i/d*(p+.5)),z:Pe(r.z0+o/l*(u+.5))}})}function Hl(t,e,n,r){let i=t.rooms.find(u=>u.id===e);if(!i)return;let o=i.points[n],s=i.points[(n+1)%i.points.length];i.points.splice(n+1,0,r);let[l,a]=[i.wall_heights?.[n],i.wall_slopes?.[n]];if(typeof l=="number"&&typeof a=="number"&&i.wall_slopes){let u=Math.hypot(s[0]-o[0],s[1]-o[1]),d=Pe(l+(a-l)*Math.min(1,Math.hypot(r[0]-o[0],r[1]-o[1])/(u||1)));i.wall_slopes.splice(n,1,d,a),i.wall_heights.splice(n+1,0,d)}else i.wall_heights?.splice(n+1,0,i.wall_heights[n]??null),i.wall_slopes?.splice(n+1,0,null);i.wall_thickness?.splice(n+1,0,i.wall_thickness[n]??null);let c=Math.hypot(r[0]-o[0],r[1]-o[1]);for(let u of t.openings)u.room_id!==e||u.wall||(u.edge>n?u.edge+=1:u.edge===n&&u.offset>c&&(u.edge=n+1,u.offset=Pe(u.offset-c)))}var v0=22.5;function $m(t,e,n){let r=Math.min(Math.abs(e),t*2),i=t*(1+8/3*(r/Math.max(1e-6,t))**2),o=4*Math.atan(2*r/Math.max(1e-6,t))*180/Math.PI,s=Math.max(2,Math.ceil(o/v0));if(n<=0)return 24;let l=Math.floor(i/(n+.1));return l>=s?l:0}function w0(t,e,n,r){let i=zl(n);t.forEach((o,s)=>{let{piece:l,offset:a}=Pl(n,e[s]*i),c=Math.hypot(n[l+1][0]-n[l][0],n[l+1][1]-n[l][1]);o.edge=r+l,o.offset=Pe(c>o.width?Math.min(c-o.width/2,Math.max(o.width/2,a)):c/2)})}function Sm(t,e,n,r){let i=t.rooms.find(v=>v.id===e);if(!i||n<0||n>=i.points.length||Math.abs(r)<.01)return!1;let o=i.points[n],s=i.points[(n+1)%i.points.length],l=Math.hypot(s[0]-o[0],s[1]-o[1]);if(l<.2)return!1;let[a,c]=[(s[0]-o[0])/l,(s[1]-o[1])/l],u=[(o[0]+s[0])/2+c*.02,(o[1]+s[1])/2-a*.02],p=C(u,i.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],M=(A,T)=>Math.abs(A[0]-T[0])<.001&&Math.abs(A[1]-T[1])<.001;return M(w,o)&&M(k,s)?[v,x,!1]:M(w,s)&&M(k,o)?[v,x,!0]:null}).filter(w=>!!w)),g=Math.max(0,...f.flatMap(([v,w])=>h(v,w).map(x=>x.width))),b=$m(l,r,g);if(!b)return!1;let y=Tl(o,s,p,b).map(([v,w])=>[Pe(v),Pe(w)]);if(!y.length)return!1;for(let[v,w,x]of f){let k=x?[...y].reverse():y,M=h(v,w),A=v.points[w],T=M.map(F=>Math.min(1,Math.max(0,F.offset/l)));for(leLine truncated
</div>`:_}function Tl(t,e,n,r=24){let i=Math.hypot(e[0]-t[0],e[1]-t[1]);if(i<1e-6||Math.abs(n)<1e-4)return[];let o=Math.max(-i*2,Math.min(i*2,n)),s=[(e[0]-t[0])/i,(e[1]-t[1])/i],l=[s[1],-s[0]],a=i*i/4/(2*Math.abs(o))+Math.abs(o)/2,c=2*Math.atan(2*Math.abs(o)/i),u=Math.max(2,Math.min(r,Math.ceil(2*c/Math.PI*180/11.25))),d=[l[0]*Math.sign(o),l[1]*Math.sign(o)],p=[(t[0]+e[0])/2,(t[1]+e[1])/2],h=[p[0]-d[0]*(a-Math.abs(o)),p[1]-d[1]*(a-Math.abs(o))],f=[];for(let g=1;g<u;g++){let b=-c+2*c*g/u;f.push([h[0]+a*(d[0]*Math.cos(b)+s[0]*Math.sin(b)),h[1]+a*(d[1]*Math.cos(b)+s[1]*Math.sin(b))])}return f}var zl=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 Pl(t,e){let n=Math.max(0,e);for(let r=0;r+1<t.length;r++){let i=Math.hypot(t[r+1][0]-t[r][0],t[r+1][1]-t[r][1]);if(n<=i||r+2===t.length)return{piece:r,offset:Math.min(n,i)};n-=i}return{piece:0,offset:0}}var Pe=t=>Math.round(t*1e3)/1e3,Dl=t=>t.map(([e,n])=>[Pe(e),Pe(n)]);function _m(t,e){return{id:I("room"),name:e,area_id:null,points:Dl(t),floor_material:"wood"}}function bm(t){return{...structuredClone(t),id:I("room"),points:Dl(t.points.map(([e,n])=>[e+.5,n+.5]))}}function ym(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=>!C([r.x,r.z],n.points)))}function vm(t,e,n){let r=t.rooms.find(s=>s.id===e);if(!r||r.points.length<=3)return!1;let i=(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 o=s=>s.room_id===e&&!s.wall;return t.openings=t.openings.filter(s=>!(o(s)&&(s.edge===n||s.edge===i))).map(s=>o(s)&&s.edge>n?{...s,edge:s.edge-1}:s),!0}function wm(t,e,n){if(!Number.isFinite(n))return null;let r=de(t.points),{x0:i,z0:o,x1:s,z1:l}=r;return e==="x"?[i,s]=[n,n+(s-i)]:e==="z"?[o,l]=[n,n+(l-o)]:n>.05&&(e==="w"?s=i+n:l=o+n),Dl([[i,o],[s,o],[s,l],[i,l]])}function km(t,e,n,r){return!Number.isFinite(r)||e<0||e>=t.points.length?null:t.points.map((i,o)=>o===e?n===0?[Pe(r),i[1]]:[i[0],Pe(r)]:[i[0],i[1]])}var y0=/^(Raum|Room) \d+$/;function Il(t,e,n,r=!0){let i=e?n[e]:void 0,o=!t.name||y0.test(t.name)||Object.values(n).some(s=>s.name===t.name);return{area_id:e||null,...r&&i&&o?{name:i.name}:{}}}function Ol(t,e){let n=/^symcon-category-(\d+)$/.exec(e)?.[1];return(n?t?.symconObjects?.find(r=>r.object_id===Number(n))?.name:void 0)??t?.areas?.[e]?.name.split(" / ").at(-1)?.trim()??""}function xm(t,e){let n=e.filter(a=>Q(a.entity_id)==="light"&&(a.mount??"ceiling")==="ceiling"&&C([a.x,a.z],t.points));if(n.length<2)return[];let r=de(t.points),[i,o]=[r.x1-r.x0,r.z1-r.z0],s=Math.max(1,Math.round(Math.sqrt(n.length*i/Math.max(.1,o)))),l=Math.ceil(n.length/s);return n.map((a,c)=>{let u=Math.floor(c/s),d=u===l-1?n.length-s*(l-1):s,p=c-u*s;return{entityId:a.entity_id,x:Pe(r.x0+i/d*(p+.5)),z:Pe(r.z0+o/l*(u+.5))}})}function Hl(t,e,n,r){let i=t.rooms.find(u=>u.id===e);if(!i)return;let o=i.points[n],s=i.points[(n+1)%i.points.length];i.points.splice(n+1,0,r);let[l,a]=[i.wall_heights?.[n],i.wall_slopes?.[n]];if(typeof l=="number"&&typeof a=="number"&&i.wall_slopes){let u=Math.hypot(s[0]-o[0],s[1]-o[1]),d=Pe(l+(a-l)*Math.min(1,Math.hypot(r[0]-o[0],r[1]-o[1])/(u||1)));i.wall_slopes.splice(n,1,d,a),i.wall_heights.splice(n+1,0,d)}else i.wall_heights?.splice(n+1,0,i.wall_heights[n]??null),i.wall_slopes?.splice(n+1,0,null);i.wall_thickness?.splice(n+1,0,i.wall_thickness[n]??null);let c=Math.hypot(r[0]-o[0],r[1]-o[1]);for(let u of t.openings)u.room_id!==e||u.wall||(u.edge>n?u.edge+=1:u.edge===n&&u.offset>c&&(u.edge=n+1,u.offset=Pe(u.offset-c)))}var v0=22.5;function $m(t,e,n){let r=Math.min(Math.abs(e),t*2),i=t*(1+8/3*(r/Math.max(1e-6,t))**2),o=4*Math.atan(2*r/Math.max(1e-6,t))*180/Math.PI,s=Math.max(2,Math.ceil(o/v0));if(n<=0)return 24;let l=Math.floor(i/(n+.1));return l>=s?l:0}function w0(t,e,n,r){let i=zl(n);t.forEach((o,s)=>{let{piece:l,offset:a}=Pl(n,e[s]*i),c=Math.hypot(n[l+1][0]-n[l][0],n[l+1][1]-n[l][1]);o.edge=r+l,o.offset=Pe(c>o.width?Math.min(c-o.width/2,Math.max(o.width/2,a)):c/2)})}function Sm(t,e,n,r){let i=t.rooms.find(v=>v.id===e);if(!i||n<0||n>=i.points.length||Math.abs(r)<.01)return!1;let o=i.points[n],s=i.points[(n+1)%i.points.length],l=Math.hypot(s[0]-o[0],s[1]-o[1]);if(l<.2)return!1;let[a,c]=[(s[0]-o[0])/l,(s[1]-o[1])/l],u=[(o[0]+s[0])/2+c*.02,(o[1]+s[1])/2-a*.02],p=C(u,i.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],M=(A,T)=>Math.abs(A[0]-T[0])<.001&&Math.abs(A[1]-T[1])<.001;return M(w,o)&&M(k,s)?[v,x,!1]:M(w,s)&&M(k,o)?[v,x,!0]:null}).filter(w=>!!w)),g=Math.max(0,...f.flatMap(([v,w])=>h(v,w).map(x=>x.width))),b=$m(l,r,g);if(!b)return!1;let y=Tl(o,s,p,b).map(([v,w])=>[Pe(v),Pe(w)]);if(!y.length)return!1;for(let[v,w,x]of f){let k=x?[...y].reverse():y,M=h(v,w),A=v.points[w],T=M.map(F=>Math.min(1,Math.max(0,F.offset/l)));for(leLine 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}>${ts(t,s)}</text>
<text class="nf-dim" x=${(n[0]+r[0])/2} y=${(n[1]+r[1])/2-10}>${ns(t,s)}</text>
</g>`}let[i,o]=[Math.abs(e.end[0]-e.start[0]),Math.abs(e.end[1]-e.start[1])];return R`<g pointer-events="none">
<rect class="nf-draft" x=${Math.min(n[0],r[0])} y=${Math.min(n[1],r[1])} width=${Math.abs(r[0]-n[0])} height=${Math.abs(r[1]-n[1])} />
<text class="nf-dim" x=${(n[0]+r[0])/2} y=${Math.min(n[1],r[1])-8}>${ts(t,i)} × ${ts(t,o)}</text>
</g>`}function M0(t,e,n,r){let i=[...e,...n?[n]:[]].map(u=>t.toScreen(u)),o=e.length>=3,s=r?e.slice(1).map((u,d)=>{let[p,h]=[t.toScreen(e[d]),t.toScreen(u)];return R`<text class="nf-dim" x=${(p[0]+h[0])/2} y=${(p[1]+h[1])/2-6}>${ts(t,Math.hypot(u[0]-e[d][0],u[1]-e[d][1]))}</text>`}):_,l=e.map((u,d)=>{let[p,h]=t.toScreen(u),f=d===0&&o;return R`<circle class=${f?"nf-draft-pt nf-draft-first":"nf-draft-pt"} cx=${p} cy=${h} r=${f?9:5} />`}),[a,c]=n?t.toScreen(n):[0,0];return R`<g pointer-events="none">
<text class="nf-dim" x=${(n[0]+r[0])/2} y=${Math.min(n[1],r[1])-8}>${ns(t,i)} × ${ns(t,o)}</text>
</g>`}function M0(t,e,n,r){let i=[...e,...n?[n]:[]].map(u=>t.toScreen(u)),o=e.length>=3,s=r?e.slice(1).map((u,d)=>{let[p,h]=[t.toScreen(e[d]),t.toScreen(u)];return R`<text class="nf-dim" x=${(p[0]+h[0])/2} y=${(p[1]+h[1])/2-6}>${ns(t,Math.hypot(u[0]-e[d][0],u[1]-e[d][1]))}</text>`}):_,l=e.map((u,d)=>{let[p,h]=t.toScreen(u),f=d===0&&o;return R`<circle class=${f?"nf-draft-pt nf-draft-first":"nf-draft-pt"} cx=${p} cy=${h} r=${f?9:5} />`}),[a,c]=n?t.toScreen(n):[0,0];return R`<g pointer-events="none">
${i.length>1?R`<polyline class="nf-draft" points=${i.map(u=>u.join(",")).join(" ")} />`:_}
${s}${l}
${n?R`<circle class="nf-cursor" cx=${a} cy=${c} r="4" />`:_}
@@ -1295,7 +1295,7 @@ ${o}`}else i=op(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} />`:_}
${i!==null?R`<line class="nf-guide" x1="0" y1=${i} x2=${n.w} y2=${i} />`:_}
${e.point?R`<circle class="nf-snap" cx=${o} cy=${s} r="9" />`:_}
</g>`}function Pm(t,e,n,r,i){return e?S0(t,e):n!=="polygon"&&n!=="measure"?_:M0(t,r,i,n==="measure")}var le=(t,e,n,r,i="")=>R`<rect class=${i} x=${Math.min(t,n)} y=${Math.min(e,r)} width=${Math.abs(n-t)} height=${Math.abs(r-e)} />`,ie=(t,e,n,r,i="")=>R`<line class=${i} x1=${t} y1=${e} x2=${n} y2=${r} />`,Im=(t,e="")=>R`<polygon class=${e} points=${t.map(n=>n.join(",")).join(" ")} />`,se=(t,e,n,r="")=>R`<circle class=${r} cx=${t} cy=${e} r=${n} />`,Nl=(t,e,n,r,i="")=>R`<ellipse class=${i} cx=${t} cy=${e} rx=${n} ry=${r} />`;function Bl(t,e,n){let r=[];for(let i=1;i<n;i++){let o=-t/2+t/n*i;r.push(ie(o,e/2,o,e/2-Math.min(.12,e*.3)))}return r}function Dm(t,e,n,r){let i=Math.min(.24,e*.28),o=r?Math.min(.2,t*.12):0,s=[le(-t/2,-e/2,t/2,-e/2+i,"nf-sym-fill")];r&&s.push(le(-t/2,-e/2,-t/2+o,e/2,"nf-sym-fill"),le(t/2-o,-e/2,t/2,e/2,"nf-sym-fill"));let l=t-2*o;for(let a=1;a<n;a++){let c=-t/2+o+l/n*a;s.push(ie(c,-e/2+i,c,e/2-.02))}return s}function Om(t,e,n,r){if(t==="stairs"&&r?.stair)return R0(r,e,n);switch(t){case"sofa":return Dm(e,n,Math.max(1,Math.round((e-.4)/.62)),!0);case"armchair":return Dm(e,n,1,!0);case"bench":return[le(-e/2,-n/2,e/2,-n/2+.08,"nf-sym-fill")];case"corner_bench":{let i=Math.min(.5,n*.4);return[le(-e/2,-n/2,e/2,-n/2+.08,"nf-sym-fill"),le(-e/2,-n/2,-e/2+.08,n/2,"nf-sym-fill"),ie(-e/2+i,-n/2+i,e/2,-n/2+i),ie(-e/2+i,-n/2+i,-e/2+i,n/2)]}case"chair":return[le(-e/2,-n/2,e/2,-n/2+.06,"nf-sym-fill")];case"office_chair":return[se(0,.03,Math.min(e,n)*.36),le(-e*.35,-n/2+.02,e*.35,-n/2+.1,"nf-sym-fill")];case"bar_stool":case"table_round":return[se(0,0,Math.min(e,n)*.42)];case"stool":return[le(-e/2+.04,-n/2+.04,e/2-.04,n/2-.04)];case"table":case"coffee_table":case"desk":{let i=[le(-e/2+.05,-n/2+.05,e/2-.05,n/2-.05)];return t==="desk"&&i.push(ie(-.3,-n/2+.1,.3,-n/2+.1,"nf-sym-strong")),i}case"bed":case"bunk_bed":{let i=e>1.2?2:1,o=(e-.2)/i,s=[le(-e/2,-n/2,e/2,-n/2+.07,"nf-sym-fill"),ie(-e/2,-n/2+(n-.1)*.36,e/2,-n/2+(n-.1)*.36)];for(let l=0;l<i;l++)s.push(le(-e/2+.13+o*l,-n/2+.12,-e/2+.07+o*(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 Bl(e,n,t==="nightstand"||t==="tall_cabinet"||t==="kitchen_tall"?1:Math.max(2,Math.round(e/.5)));case"coat_rack":return[le(-e/2,-n/2,e/2,-n/2+.03,"nf-sym-fill"),...Bl(e,n,Math.max(2,Math.round(e/.5)))];case"island":return[ie(-e/2,n/2-.3,e/2,n/2-.3)];case"fridge":return[ie(-e/2+.06,n/2-.04,e/2-.06,n/2-.04,"nf-sym-strong")];case"stove":{let i=Math.min(e,n)*.14;return[se(-e*.22,-n*.2,i),se(e*.22,-n*.2,i*.8),se(-e*.22,n*.2,i*.8),se(e*.22,n*.2,i)]}case"sink":{let i=Math.min(.5,e-.2);return[le(-i/2,-n/2+.1,i/2,n/2-.08),se(0,-n/2+.06,.025,"nf-sym-fill")]}case"dishwasher":return[ie(-e/2+.08,n/2-.05,e/2-.08,n/2-.05,"nf-sym-strong")];case"washer":case"dryer":return[se(0,.05,Math.min(e,n)*.3),ie(-e/2,-n/2+.1,e/2,-n/2+.1)];case"bathtub":return[le(-e/2+.07,-n/2+.07,e/2-.07,n/2-.07),se(-e/2+.14,0,.03,"nf-sym-fill")];case"shower":return[ie(-e/2,-n/2,e/2,n/2),ie(e/2,-n/2,-e/2,n/2),se(0,0,.04)];case"wc":return[le(-e/2,-n/2,e/2,-n/2+Math.min(.18,n*.3),"nf-sym-fill"),Nl(0,n*.1,e*.36,n*.3)];case"washbasin":return[Nl(0,.03,e*.34,n*.3)];case"tv_board":return[ie(-Math.min(e*.4,.72),-n/2+.14,Math.min(e*.4,.72),-n/2+.14,"nf-sym-strong"),...Bl(e,n,Math.max(2,Math.round(e/.6)))];case"tv_wall":return[ie(-e/2,0,e/2,0,"nf-sym-strong")];case"lamp_downlight":case"lamp_spot":return[se(0,0,Math.min(e,n)*.45,"nf-sym-fill"),se(0,0,Math.min(e,n)*1.4)];case"lamp_bollard":case"lamp_garden":return[se(0,0,Math.min(e,n)*.5,"nf-sym-fill"),se(0,0,Math.min(e,n)*1.6)];case"parking":return[le(-e/2+.08,-n/2+.08,e/2-.08,n/2-.08),ie(-e*.15,n/2-.5,0,n/2-.22,"nf-sym-strong"),ie(0,n/2-.22,e*.15,n/2-.5,"nf-sym-strong")];case"robot_vacuum":return[le(-e*.45,-n/2,e*.45,-n/2+n*.3,"nf-sym-fill"),se(0,n*.14,Math.min(e,n)*.47)];case"radiator":{let i=[],o=Math.max(3,Math.round(e/.1));for(let s=1;s<o;s++)i.push(ie(-e/2+e/o*s,-n/2,-e/2+e/o*s,n/2));return i}case"lamp_panel":return[le(-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 i=Math.min(e,n)/2,o=[se(0,0,i*.9,"nf-sym-fill"),se(0,0,i*.3)];if(t==="lamp_ceiling"||t==="lamp_pendant")for(let s=0;s<8;s++){let l=s/8*Math.PI*2;o.push(ie(Math.cos(l)*i*1.05,Math.sin(l)*i*1.05,Math.cos(l)*i*1.35,Math.sin(l)*i*1.35))}return o}case"ceiling_fan":{let i=Math.min(e,n)/2,o=[se(0,0,.11,"nf-sym-fill")];for(let s=0;s<5;s++){let l=s/5*Math.PI*2;o.push(ie(Math.cos(l)*.12,Math.sin(l)*.12,Math.cos(l)*i*.97,Math.sin(l)*i*.97,"nf-sym-strong"))}return[...o,se(0,0,i)]}case"lamp_wall":return[le(-e/2,-n/2,e/2,-n/2+.03,"nf-sym-fill"),Nl(0,.01,e*.4,n*.4)];case"led_strip":return[ie(-e/2,0,e/2,0,"nf-sym-strong")];case"plant":return[se(0,0,Math.min(e,n)*.46),se(0,0,Math.min(e,n)*.25)];case"rug":return[le(-e/2+.1,-n/2+.1,e/2-.1,n/2-.1)];case"stairs":{let i=Math.max(3,Math.roun Line truncated
</g>`}function Pm(t,e,n,r,i){return e?S0(t,e):n!=="polygon"&&n!=="measure"?_:M0(t,r,i,n==="measure")}var le=(t,e,n,r,i="")=>R`<rect class=${i} x=${Math.min(t,n)} y=${Math.min(e,r)} width=${Math.abs(n-t)} height=${Math.abs(r-e)} />`,ie=(t,e,n,r,i="")=>R`<line class=${i} x1=${t} y1=${e} x2=${n} y2=${r} />`,Im=(t,e="")=>R`<polygon class=${e} points=${t.map(n=>n.join(",")).join(" ")} />`,se=(t,e,n,r="")=>R`<circle class=${r} cx=${t} cy=${e} r=${n} />`,Nl=(t,e,n,r,i="")=>R`<ellipse class=${i} cx=${t} cy=${e} rx=${n} ry=${r} />`;function Bl(t,e,n){let r=[];for(let i=1;i<n;i++){let o=-t/2+t/n*i;r.push(ie(o,e/2,o,e/2-Math.min(.12,e*.3)))}return r}function Dm(t,e,n,r){let i=Math.min(.24,e*.28),o=r?Math.min(.2,t*.12):0,s=[le(-t/2,-e/2,t/2,-e/2+i,"nf-sym-fill")];r&&s.push(le(-t/2,-e/2,-t/2+o,e/2,"nf-sym-fill"),le(t/2-o,-e/2,t/2,e/2,"nf-sym-fill"));let l=t-2*o;for(let a=1;a<n;a++){let c=-t/2+o+l/n*a;s.push(ie(c,-e/2+i,c,e/2-.02))}return s}function Om(t,e,n,r){if(t==="stairs"&&r?.stair)return R0(r,e,n);switch(t){case"sofa":return Dm(e,n,Math.max(1,Math.round((e-.4)/.62)),!0);case"armchair":return Dm(e,n,1,!0);case"bench":return[le(-e/2,-n/2,e/2,-n/2+.08,"nf-sym-fill")];case"corner_bench":{let i=Math.min(.5,n*.4);return[le(-e/2,-n/2,e/2,-n/2+.08,"nf-sym-fill"),le(-e/2,-n/2,-e/2+.08,n/2,"nf-sym-fill"),ie(-e/2+i,-n/2+i,e/2,-n/2+i),ie(-e/2+i,-n/2+i,-e/2+i,n/2)]}case"chair":return[le(-e/2,-n/2,e/2,-n/2+.06,"nf-sym-fill")];case"office_chair":return[se(0,.03,Math.min(e,n)*.36),le(-e*.35,-n/2+.02,e*.35,-n/2+.1,"nf-sym-fill")];case"bar_stool":case"table_round":return[se(0,0,Math.min(e,n)*.42)];case"stool":return[le(-e/2+.04,-n/2+.04,e/2-.04,n/2-.04)];case"table":case"coffee_table":case"desk":{let i=[le(-e/2+.05,-n/2+.05,e/2-.05,n/2-.05)];return t==="desk"&&i.push(ie(-.3,-n/2+.1,.3,-n/2+.1,"nf-sym-strong")),i}case"bed":case"bunk_bed":{let i=e>1.2?2:1,o=(e-.2)/i,s=[le(-e/2,-n/2,e/2,-n/2+.07,"nf-sym-fill"),ie(-e/2,-n/2+(n-.1)*.36,e/2,-n/2+(n-.1)*.36)];for(let l=0;l<i;l++)s.push(le(-e/2+.13+o*l,-n/2+.12,-e/2+.07+o*(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 Bl(e,n,t==="nightstand"||t==="tall_cabinet"||t==="kitchen_tall"?1:Math.max(2,Math.round(e/.5)));case"coat_rack":return[le(-e/2,-n/2,e/2,-n/2+.03,"nf-sym-fill"),...Bl(e,n,Math.max(2,Math.round(e/.5)))];case"island":return[ie(-e/2,n/2-.3,e/2,n/2-.3)];case"fridge":return[ie(-e/2+.06,n/2-.04,e/2-.06,n/2-.04,"nf-sym-strong")];case"stove":{let i=Math.min(e,n)*.14;return[se(-e*.22,-n*.2,i),se(e*.22,-n*.2,i*.8),se(-e*.22,n*.2,i*.8),se(e*.22,n*.2,i)]}case"sink":{let i=Math.min(.5,e-.2);return[le(-i/2,-n/2+.1,i/2,n/2-.08),se(0,-n/2+.06,.025,"nf-sym-fill")]}case"dishwasher":return[ie(-e/2+.08,n/2-.05,e/2-.08,n/2-.05,"nf-sym-strong")];case"washer":case"dryer":return[se(0,.05,Math.min(e,n)*.3),ie(-e/2,-n/2+.1,e/2,-n/2+.1)];case"bathtub":return[le(-e/2+.07,-n/2+.07,e/2-.07,n/2-.07),se(-e/2+.14,0,.03,"nf-sym-fill")];case"shower":return[ie(-e/2,-n/2,e/2,n/2),ie(e/2,-n/2,-e/2,n/2),se(0,0,.04)];case"wc":return[le(-e/2,-n/2,e/2,-n/2+Math.min(.18,n*.3),"nf-sym-fill"),Nl(0,n*.1,e*.36,n*.3)];case"washbasin":return[Nl(0,.03,e*.34,n*.3)];case"tv_board":return[ie(-Math.min(e*.4,.72),-n/2+.14,Math.min(e*.4,.72),-n/2+.14,"nf-sym-strong"),...Bl(e,n,Math.max(2,Math.round(e/.6)))];case"tv_wall":return[ie(-e/2,0,e/2,0,"nf-sym-strong")];case"lamp_downlight":case"lamp_spot":return[se(0,0,Math.min(e,n)*.45,"nf-sym-fill"),se(0,0,Math.min(e,n)*1.4)];case"lamp_bollard":case"lamp_garden":return[se(0,0,Math.min(e,n)*.5,"nf-sym-fill"),se(0,0,Math.min(e,n)*1.6)];case"parking":return[le(-e/2+.08,-n/2+.08,e/2-.08,n/2-.08),ie(-e*.15,n/2-.5,0,n/2-.22,"nf-sym-strong"),ie(0,n/2-.22,e*.15,n/2-.5,"nf-sym-strong")];case"robot_vacuum":return[le(-e*.45,-n/2,e*.45,-n/2+n*.3,"nf-sym-fill"),se(0,n*.14,Math.min(e,n)*.47)];case"radiator":{let i=[],o=Math.max(3,Math.round(e/.1));for(let s=1;s<o;s++)i.push(ie(-e/2+e/o*s,-n/2,-e/2+e/o*s,n/2));return i}case"lamp_panel":return[le(-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 i=Math.min(e,n)/2,o=[se(0,0,i*.9,"nf-sym-fill"),se(0,0,i*.3)];if(t==="lamp_ceiling"||t==="lamp_pendant")for(let s=0;s<8;s++){let l=s/8*Math.PI*2;o.push(ie(Math.cos(l)*i*1.05,Math.sin(l)*i*1.05,Math.cos(l)*i*1.35,Math.sin(l)*i*1.35))}return o}case"ceiling_fan":{let i=Math.min(e,n)/2,o=[se(0,0,.11,"nf-sym-fill")];for(let s=0;s<5;s++){let l=s/5*Math.PI*2;o.push(ie(Math.cos(l)*.12,Math.sin(l)*.12,Math.cos(l)*i*.97,Math.sin(l)*i*.97,"nf-sym-strong"))}return[...o,se(0,0,i)]}case"lamp_wall":return[le(-e/2,-n/2,e/2,-n/2+.03,"nf-sym-fill"),Nl(0,.01,e*.4,n*.4)];case"led_strip":return[ie(-e/2,0,e/2,0,"nf-sym-strong")];case"plant":return[se(0,0,Math.min(e,n)*.46),se(0,0,Math.min(e,n)*.25)];case"rug":return[le(-e/2+.1,-n/2+.1,e/2-.1,n/2-.1)];case"stairs":{let i=Math.max(3,Math.roun Line truncated
<g transform="translate(${c} ${u}) rotate(${s.rotation}) scale(${s.mirror?-i:i} ${i})">
<rect class="nf-furn-body" x=${-s.w/2} y=${-s.d/2} width=${s.w} height=${s.d} />
<g class="nf-furn-sym">${Om(s.type,s.w,s.d,s)}</g>
@@ -1314,10 +1314,10 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${u&&o.locked?R`<text class="nf-lock" x=${l+16} y=${a-12}>🔒</text>`:_}`};return R`<g>${e.placements.map(i)}</g>`}function Bm(t,e,n){return R`${(e.notes??[]).map(r=>{let[i,o]=t.toScreen([r.x,r.z]);return R`<g data-note=${r.id} class=${`nf-note${ji(r)?" nf-note-due":""}${r.id===n?" nf-note-sel":""}`} transform="translate(${i} ${o})">
<title>${r.text}</title>
<rect x="-11" y="-11" width="22" height="22" rx="4" /><text y="5" text-anchor="middle">✎</text>
</g>`})}`}var ns=(t,e,n=6)=>R`<circle cx=${t} cy=${e} r="16" class="nf-hit" /><circle cx=${t} cy=${e} r=${n} />`;function Wm(t,e){let{scale:n}=t,r=n>=90?.1:n>=30?.5:1,i=n>=20?1:5,o=t.toWorld(0,0),s=t.toWorld(e.w,e.h),l=[],a=(d,p)=>{for(let h=Math.ceil(o[0]/d)*d;h<=s[0];h+=d){let f=t.toScreen([h,0])[0];l.push(R`<line class=${p} x1=${f} y1="0" x2=${f} y2=${e.h} />`)}for(let h=Math.ceil(o[1]/d)*d;h<=s[1];h+=d){let f=t.toScreen([0,h])[1];l.push(R`<line class=${p} x1="0" y1=${f} x2=${e.w} y2=${f} />`)}};r<i&&a(r,"nf-grid-minor"),a(i,"nf-grid-major");let[c,u]=t.toScreen([0,0]);return l.push(R`<circle class="nf-origin" cx=${c} cy=${u} r="3" />`),R`<g pointer-events="none">${l}</g>`}function Vm(t){let e=t.host.doc.floors,n=e.findIndex(o=>o.id===t.floorId),r=n>0?e[n-1]:void 0;if(!r)return _;let i=Au(e,e[n]);return R`<g pointer-events="none">${r.rooms.map(o=>R`<polygon class="nf-ghost" points=${lt(t,o.points)} />`)}${i.map(o=>R`<polygon class="nf-void" points=${lt(t,o)} />`)}</g>`}function Km(t,e){let n=t.host.floor?.height??2.5;return R`<g pointer-events="none">${e.map(r=>{let i=r.height!==void 0&&r.height<n-.01;return R`<polygon class=${`nf-wall${r.exterior?" nf-wall-ext":""}${i?" nf-wall-low":""}`} points=${lt(t,r.footprint)} />`})}</g>`}function jm(t,e,n){let r=i=>{let[o,s]=t.toScreen(be(i.points)),l=de(i.points),a=Math.min(l.x1-l.x0,l.z1-l.z0)*t.scale>40;return R`<g data-outdoor=${i.id} class=${`nf-out nf-out-${i.type}${i.id===n?" nf-out-sel":""}`}>
</g>`})}`}var rs=(t,e,n=6)=>R`<circle cx=${t} cy=${e} r="16" class="nf-hit" /><circle cx=${t} cy=${e} r=${n} />`;function Wm(t,e){let{scale:n}=t,r=n>=90?.1:n>=30?.5:1,i=n>=20?1:5,o=t.toWorld(0,0),s=t.toWorld(e.w,e.h),l=[],a=(d,p)=>{for(let h=Math.ceil(o[0]/d)*d;h<=s[0];h+=d){let f=t.toScreen([h,0])[0];l.push(R`<line class=${p} x1=${f} y1="0" x2=${f} y2=${e.h} />`)}for(let h=Math.ceil(o[1]/d)*d;h<=s[1];h+=d){let f=t.toScreen([0,h])[1];l.push(R`<line class=${p} x1="0" y1=${f} x2=${e.w} y2=${f} />`)}};r<i&&a(r,"nf-grid-minor"),a(i,"nf-grid-major");let[c,u]=t.toScreen([0,0]);return l.push(R`<circle class="nf-origin" cx=${c} cy=${u} r="3" />`),R`<g pointer-events="none">${l}</g>`}function Vm(t){let e=t.host.doc.floors,n=e.findIndex(o=>o.id===t.floorId),r=n>0?e[n-1]:void 0;if(!r)return _;let i=Au(e,e[n]);return R`<g pointer-events="none">${r.rooms.map(o=>R`<polygon class="nf-ghost" points=${lt(t,o.points)} />`)}${i.map(o=>R`<polygon class="nf-void" points=${lt(t,o)} />`)}</g>`}function Km(t,e){let n=t.host.floor?.height??2.5;return R`<g pointer-events="none">${e.map(r=>{let i=r.height!==void 0&&r.height<n-.01;return R`<polygon class=${`nf-wall${r.exterior?" nf-wall-ext":""}${i?" nf-wall-low":""}`} points=${lt(t,r.footprint)} />`})}</g>`}function jm(t,e,n){let r=i=>{let[o,s]=t.toScreen(be(i.points)),l=de(i.points),a=Math.min(l.x1-l.x0,l.z1-l.z0)*t.scale>40;return R`<g data-outdoor=${i.id} class=${`nf-out nf-out-${i.type}${i.id===n?" nf-out-sel":""}`}>
<polygon points=${lt(t,i.points)} />
${a?R`<text x=${o} y=${s+4}>${t.host.t(`out_${i.type}`)}</text>`:_}
</g>`};return R`<g>${e.outdoor.map(r)}</g>`}function Um(t,e,n){let{host:r}=t;if(!e||!r.admin||n!=="select"||r.doc.settings.lock_plan)return _;let i=e.points;return R`${i.map((o,s)=>Bo(t,o,i[(s+1)%i.length],"out",e.id,s))}${i.map((o,s)=>R`<g class="nf-vertex" data-out-vertex=${`${e.id}:${s}`}>${ns(...t.toScreen(o))}</g>`)}`}function Gm(t,e,n,r){let i=e.rooms.find(s=>s.id===n),o=i&&r!==null&&r<i.points.length?[t.toScreen(i.points[r]),t.toScreen(i.points[(r+1)%i.points.length])]:null;return R`<g>${e.rooms.map(s=>R`<polygon data-room=${s.id} class=${s.id===n?"nf-room nf-room-sel":"nf-room"} points=${lt(t,s.points)} />`)}</g>
</g>`};return R`<g>${e.outdoor.map(r)}</g>`}function Um(t,e,n){let{host:r}=t;if(!e||!r.admin||n!=="select"||r.doc.settings.lock_plan)return _;let i=e.points;return R`${i.map((o,s)=>Wo(t,o,i[(s+1)%i.length],"out",e.id,s))}${i.map((o,s)=>R`<g class="nf-vertex" data-out-vertex=${`${e.id}:${s}`}>${rs(...t.toScreen(o))}</g>`)}`}function Gm(t,e,n,r){let i=e.rooms.find(s=>s.id===n),o=i&&r!==null&&r<i.points.length?[t.toScreen(i.points[r]),t.toScreen(i.points[(r+1)%i.points.length])]:null;return R`<g>${e.rooms.map(s=>R`<polygon data-room=${s.id} class=${s.id===n?"nf-room nf-room-sel":"nf-room"} points=${lt(t,s.points)} />`)}</g>
${o?R`<line class="nf-edge-hi" pointer-events="none" x1=${o[0][0]} y1=${o[0][1]} x2=${o[1][0]} y2=${o[1][1]} />`:_}
<g pointer-events="none">${e.rooms.map(s=>{let[l,a]=t.toScreen(be(s.points));return R`<text class="nf-room-name" x=${l} y=${a-2}>${s.name}</text>
<text class="nf-room-area" x=${l} y=${a+14}>${ze(t.host.hass,xe(s.points))}</text>`})}</g>`}function Zm(t,e){let n=t.host.doc.energy?.meter;if(!n||n.floor_id!==e.id)return _;let[r,i]=t.toScreen([n.x,n.z]);return R`<g class="nf-meter" transform="translate(${r} ${i})" pointer-events="none">
@@ -1327,8 +1327,8 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<line class="nf-hit" x1=${s[0]} y1=${s[1]} x2=${l[0]} y2=${l[1]} />
<line class="nf-free-wall-line" x1=${s[0]} y1=${s[1]} x2=${l[0]} y2=${l[1]} />
</g>
${c?R`<g class="nf-vertex" data-wall-end=${`${o.id}:a`}>${ns(s[0],s[1])}</g><g class="nf-vertex" data-wall-end=${`${o.id}:b`}>${ns(l[0],l[1])}</g>`:_}`};return R`<g>${(e.walls??[]).map(i)}</g>`}function Ym(t,e){let n=e.points,r=(e.wall_splits??[]).flatMap((i,o)=>{if(!i||o>=n.length)return[];let[s,l]=[n[o],n[(o+1)%n.length]],a=Math.hypot(l[0]-s[0],l[1]-s[1])||1,[c,u]=[(l[0]-s[0])/a,(l[1]-s[1])/a];return i.map(d=>{let[p,h]=t.toScreen([s[0]+c*d,s[1]+u*d]);return R`<line class="nf-split-mark" x1=${p-u*7} y1=${h+c*7} x2=${p+u*7} y2=${h-c*7} />`})});return R`${r}`}function Xm(t,e,n){let r=e.points,[i,o]=t.toScreen(be(r)),s=(a,c,u)=>{let[[d,p],[h,f]]=[t.toScreen(a),t.toScreen(c)],[g,b]=[(d+h)/2,(p+f)/2],y=Math.hypot(h-d,f-p),[v,w]=[-(f-p),h-d],x=Math.hypot(v,w)||1;return[v,w]=[v/x,w/x],v*(g-i)+w*(b-o)<0&&([v,w]=[-v,-w]),R`${y>50?R`<text class="nf-dim" x=${g+v*16} y=${b+w*16+4}>${pe(t.host.hass,Math.hypot(c[0]-a[0],c[1]-a[1]))}</text>`:_}
${y>36?R`<g data-mid=${u} class="nf-mid"><circle cx=${g} cy=${b} r="14" class="nf-hit" /><circle cx=${g} cy=${b} r="6" /><path d="M${g-3} ${b}h6M${g} ${b-3}v6" /></g>`:_}`},l=(a,c)=>{let[u,d]=t.toScreen(a);return R`<g data-vertex=${c} class=${c===n?"nf-vertex nf-vertex-sel":"nf-vertex"}>${ns(u,d)}</g><text class="nf-vertex-no" x=${u+9} y=${d-9}>${c+1}</text>`};return R`<g>${r.map((a,c)=>s(a,r[(c+1)%r.length],c))}${r.map(l)}</g>`}function Jm(t,e){let n=e.rooms.flatMap(r=>{if(r.points.length<3)return[];let[i,o]=be(r.points);return r.points.map((s,l)=>{let a=r.points[(l+1)%r.points.length],c=Math.hypot(a[0]-s[0],a[1]-s[1]);if(c<.4)return _;let u=[(s[0]+a[0])/2,(s[1]+a[1])/2],d=Math.hypot(i-u[0],o-u[1])||1,p=Math.min(.35,d/2),h=[u[0]+(i-u[0])/d*p,u[1]+(o-u[1])/d*p],[f,g]=t.toScreen(h),b=Math.atan2(a[1]-s[1],a[0]-s[0])*180/Math.PI;return b>90&&(b-=180),b<-90&&(b+=180),R`<text class="nf-dim" x=${f} y=${g} transform=${`rotate(${b.toFixed(1)} ${f} ${g})`} text-anchor="middle" dominant-baseline="middle">${pe(t.host.hass,c)}</text>`})});return R`<g pointer-events="none">${n}</g>`}function Qm(t,e,n){let r=t.t;return m`<section>
${c?R`<g class="nf-vertex" data-wall-end=${`${o.id}:a`}>${rs(s[0],s[1])}</g><g class="nf-vertex" data-wall-end=${`${o.id}:b`}>${rs(l[0],l[1])}</g>`:_}`};return R`<g>${(e.walls??[]).map(i)}</g>`}function Ym(t,e){let n=e.points,r=(e.wall_splits??[]).flatMap((i,o)=>{if(!i||o>=n.length)return[];let[s,l]=[n[o],n[(o+1)%n.length]],a=Math.hypot(l[0]-s[0],l[1]-s[1])||1,[c,u]=[(l[0]-s[0])/a,(l[1]-s[1])/a];return i.map(d=>{let[p,h]=t.toScreen([s[0]+c*d,s[1]+u*d]);return R`<line class="nf-split-mark" x1=${p-u*7} y1=${h+c*7} x2=${p+u*7} y2=${h-c*7} />`})});return R`${r}`}function Xm(t,e,n){let r=e.points,[i,o]=t.toScreen(be(r)),s=(a,c,u)=>{let[[d,p],[h,f]]=[t.toScreen(a),t.toScreen(c)],[g,b]=[(d+h)/2,(p+f)/2],y=Math.hypot(h-d,f-p),[v,w]=[-(f-p),h-d],x=Math.hypot(v,w)||1;return[v,w]=[v/x,w/x],v*(g-i)+w*(b-o)<0&&([v,w]=[-v,-w]),R`${y>50?R`<text class="nf-dim" x=${g+v*16} y=${b+w*16+4}>${pe(t.host.hass,Math.hypot(c[0]-a[0],c[1]-a[1]))}</text>`:_}
${y>36?R`<g data-mid=${u} class="nf-mid"><circle cx=${g} cy=${b} r="14" class="nf-hit" /><circle cx=${g} cy=${b} r="6" /><path d="M${g-3} ${b}h6M${g} ${b-3}v6" /></g>`:_}`},l=(a,c)=>{let[u,d]=t.toScreen(a);return R`<g data-vertex=${c} class=${c===n?"nf-vertex nf-vertex-sel":"nf-vertex"}>${rs(u,d)}</g><text class="nf-vertex-no" x=${u+9} y=${d-9}>${c+1}</text>`};return R`<g>${r.map((a,c)=>s(a,r[(c+1)%r.length],c))}${r.map(l)}</g>`}function Jm(t,e){let n=e.rooms.flatMap(r=>{if(r.points.length<3)return[];let[i,o]=be(r.points);return r.points.map((s,l)=>{let a=r.points[(l+1)%r.points.length],c=Math.hypot(a[0]-s[0],a[1]-s[1]);if(c<.4)return _;let u=[(s[0]+a[0])/2,(s[1]+a[1])/2],d=Math.hypot(i-u[0],o-u[1])||1,p=Math.min(.35,d/2),h=[u[0]+(i-u[0])/d*p,u[1]+(o-u[1])/d*p],[f,g]=t.toScreen(h),b=Math.atan2(a[1]-s[1],a[0]-s[0])*180/Math.PI;return b>90&&(b-=180),b<-90&&(b+=180),R`<text class="nf-dim" x=${f} y=${g} transform=${`rotate(${b.toFixed(1)} ${f} ${g})`} text-anchor="middle" dominant-baseline="middle">${pe(t.host.hass,c)}</text>`})});return R`<g pointer-events="none">${n}</g>`}function Qm(t,e,n){let r=t.t;return m`<section>
<h3>✎ ${r("note")}</h3>
<div class="nf-form">
<label class="nf-field nf-wide"
@@ -1348,7 +1348,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${J(m`<button class="nf-btn nf-danger" ?disabled=${!t.admin} @click=${()=>n.remove()}>${r("delete")}</button>`)}
</section>`}function z0(t,e,n){let r=t.t,i=!!e.photo?.startsWith("image:"),o=async s=>{let l=s.target,a=l.files?.[0];if(l.value="",!a||!t.hass)return;let{data:c}=await tr(a),u=I("img");await Wt(t.hass,u,c),n.patch({photo:`image:${u}`})};return m`${t.admin?m`<label class="nf-btn nf-wide nf-upload">📷 ${r(i?"picture_replace":"note_photo_upload")}<input type="file" accept="image/*" hidden @change=${o} /></label>`:_}
${i?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>`:V(t,r("picture_url"),e.photo??"",s=>n.patch({photo:s.trim()||null}),{wide:!0,placeholder:"/local/valve.jpg"})}
${S(r("note_photo_hint"),"nf-wide")}`}function P0(t,e,n,r){let i=Ce(e,n.rooms,n.walls??[]);if(!i)return null;let{room:o,edge:s}=i,l=Vt(r,e,i),a=Wn(o,s,e.offset-e.width/2),c=Wn(o,s,e.offset+e.width/2),u=[(c[0]-a[0])/(e.width||1),(c[1]-a[1])/(e.width||1)],d=_e(o.points)>=0?1:-1,p=[-u[1]*d,u[0]*d],h=[.06,.06];return l&&(h=l.wall.free||l.wall.roomLeft===o.id?[l.wall.left,l.wall.right]:[l.wall.right,l.wall.left]),{room:o,edge:s,p0:a,p1:c,inward:p,direction:d,across:h,exterior:l?.wall.exterior??!1,at:(f,g)=>t.toScreen([f[0]+p[0]*g,f[1]+p[1]*g])}}var Mt=(t,e,n="")=>R`<line class=${n} x1=${t[0]} y1=${t[1]} x2=${e[0]} y2=${e[1]} />`;function D0(t,e){let n=t.across[0]-.04,r=t.across[0]+Math.min(2,e.height),[i,o,s,l]=[t.at(t.p0,n),t.at(t.p1,n),t.at(t.p0,r),t.at(t.p1,r)];return R`${Mt(i,o)}<path class="nf-open-track" d="M${i[0]} ${i[1]}L${s[0]} ${s[1]}M${o[0]} ${o[1]}L${l[0]} ${l[1]}" />`}function I0(t,e,n){let r=n.swing==="out",i=r?-e.across[1]:e.across[0],o=(e.across[0]-e.across[1])/2,s=n.hinge==="left"==e.direction>0,l=rn(n,e.exterior),a=n.leaves===2,[c,u]=[e.p0,e.p1],d=[],p=Fu(n.width,l,s,n);if(p){let v=w=>w<=.02?e.p0:w>=n.width-.02?e.p1:Wn(e.room,e.edge,n.offset-n.width/2+w);[c,u]=[v(p.x0),v(p.x1)],d=p.panels.map(([w,x])=>[v(w),v(x)])}let h=[(c[0]+u[0])/2,(c[1]+u[1])/2],f=(a?.5:1)*Math.hypot(u[0]-c[0],u[1]-c[1]),g=d.map(([v,w])=>R`${Mt(e.at(v,o+.035),e.at(w,o+.035),"nf-open-pane")}${Mt(e.at(v,o-.035),e.at(w,o-.035),"nf-open-pane")}`),b=(v,w)=>{let[x,k]=e.at(v,i),[M,A]=e.at(w,i),T=e.at(v,i+(r?-f:f)),F=f*t.scale,L=(T[0]-x)*(A-k)-(T[1]-k)*(M-x)>0?1:0;return R`<path d="M${x} ${k}L${T[0]} ${T[1]}A${F} ${F} 0 0 ${L} ${M} ${A}" />`},y;return l==="passage"?y=Mt(e.at(e.p0,o),e.at(e.p1,o),"nf-open-passage"):l==="sliding"?y=Mt(e.at(c,i),e.at(u,i)):a?y=R`${b(c,h)}${b(u,h)}`:y=s?b(c,u):b(u,c),R`${g}${y}`}function O0(t,e){let n=(t.across[0]-t.across[1])/2;if(e.opens==="slide"){let i=e.leaves===2?4:2,o=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:i},(l,a)=>{let c=e.leaves===2?a===1||a===2?.035:-.035:a===0?.035:-.035;return Mt(t.at(o(Math.max(0,a/i-.03)),n+c),t.at(o(Math.min(1,(a+1)/i+.03)),n+c))});return R`${s}`}let r=e.leaves===2?Mt(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`${Mt(t.at(t.p0,n+.035),t.at(t.p1,n+.035))}${Mt(t.at(t.p0,n-.035),t.at(t.p1,n-.035))}${r}`}function eg(t,e,n,r){let i=e.openings.find(s=>s.id===r)?.front??null,o=s=>{let l=P0(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"&&Bs(rn(s,l.exterior)),u=s.id===r||!!s.front&&s.front===i,d=`nf-open nf-open-${s.type}${c?" nf-open-front":""}${u?" nf-open-sel":""}`,p=s.type==="garage"?D0(l,s):s.type==="door"?I0(t,l,s):O0(l,s);return R`<g data-opening=${s.id} class=${d}><polygon class="nf-open-gap" points=${a.map(h=>h.join(",")).join(" ")} />${p}</g>`};return R`<g>${e.openings.map(o)}</g>`}var tg=t=>Math.round(t*1e3)/1e3,ng=t=>Math.round(t*100)/100;function ir(t,e){let n=[...t??[]].slice(0,e);for(;n.length<e;)n.push(null);return n}var rs=t=>t.every(e=>e===null);function Si(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 Vl(t,e,n){let r=ir(t.wall_heights,t.points.length);r[e]=n,t.wall_heights=rs(r)?void 0:r,is(t,e,null)}function is(t,e,n){if(n===null&&!t.wall_slopes)return;let r=ir(t.wall_slopes,t.points.length);r[e]=n,t.wall_slopes=rs(r)?void 0:r}function rg(t,e,n,r){let[i,o]=[n,r].map(l=>Math.min(30,Math.max(.05,tg(l)))),s=ir(t.wall_heights,t.points.length);s[e]=i,t.wall_heights=s,is(t,e,o)}function ig(t,e,n){let r=t.wall_heights?.[e];is(t,e,null),typeof r=="number"&&r>=n-.005&&Vl(t,e,null)}function og(t,e,n,r,i){let o=ir(t.wall_heights,t.points.length),s=o[e],l=Array.isArray(s)?[...s]:new Array(i).fill(typeof s=="number"?s:null);for(;l.length<i;)l.push(null);l[n]=r,o[e]=l.every(a=>a===l[0])?l[0]:l,t.wall_heights=rs(o)?void 0:o,is(t,e,null)}function sg(t,e,n,r){let i=Si(t,e),o=n===void 0?0:r[n],s=n===void 0?i:r[n+1]??i;if(s-o<.4)return!1;let l=ng((o+s)/2),a=ir(t.wall_splits,t.points.length);a[e]=[...a[e]??[],l].sort((u,d)=>u-d),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 ag(t,e,n,r,i){let o=Si(t,e),s=i.filter(u=>Math.abs(u-n)>.001&&u>0),l=Math.max(.1,Math.min(o-.1,ng(r)));s.some(u=>Math.abs(u-l)<.1)&&(l=n);let a=t.wall_splits?.[e];if(!a)return;let c=a.findIndex(u=>Math.abs(u-n)<.001);c>=0&&(a[c]=l),a.sort((u,d)=>u-d)}function lg(t,e,n,r){let i=t.wall_splits;if(!i?.[e])return;let o=i[e].filter(l=>Math.abs(l-n)>.001);i[e]=o.length>0?o:null,i.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 cg(t,e,n,r,i=1){let o=ir(t.wall_thickness,t.points.length);if(r===void 0||i<2)o[e]=n;else{let s=o[e],l=Array. Line truncated
${S(r("note_photo_hint"),"nf-wide")}`}function P0(t,e,n,r){let i=Ce(e,n.rooms,n.walls??[]);if(!i)return null;let{room:o,edge:s}=i,l=Vt(r,e,i),a=Wn(o,s,e.offset-e.width/2),c=Wn(o,s,e.offset+e.width/2),u=[(c[0]-a[0])/(e.width||1),(c[1]-a[1])/(e.width||1)],d=_e(o.points)>=0?1:-1,p=[-u[1]*d,u[0]*d],h=[.06,.06];return l&&(h=l.wall.free||l.wall.roomLeft===o.id?[l.wall.left,l.wall.right]:[l.wall.right,l.wall.left]),{room:o,edge:s,p0:a,p1:c,inward:p,direction:d,across:h,exterior:l?.wall.exterior??!1,at:(f,g)=>t.toScreen([f[0]+p[0]*g,f[1]+p[1]*g])}}var Mt=(t,e,n="")=>R`<line class=${n} x1=${t[0]} y1=${t[1]} x2=${e[0]} y2=${e[1]} />`;function D0(t,e){let n=t.across[0]-.04,r=t.across[0]+Math.min(2,e.height),[i,o,s,l]=[t.at(t.p0,n),t.at(t.p1,n),t.at(t.p0,r),t.at(t.p1,r)];return R`${Mt(i,o)}<path class="nf-open-track" d="M${i[0]} ${i[1]}L${s[0]} ${s[1]}M${o[0]} ${o[1]}L${l[0]} ${l[1]}" />`}function I0(t,e,n){let r=n.swing==="out",i=r?-e.across[1]:e.across[0],o=(e.across[0]-e.across[1])/2,s=n.hinge==="left"==e.direction>0,l=rn(n,e.exterior),a=n.leaves===2,[c,u]=[e.p0,e.p1],d=[],p=Fu(n.width,l,s,n);if(p){let v=w=>w<=.02?e.p0:w>=n.width-.02?e.p1:Wn(e.room,e.edge,n.offset-n.width/2+w);[c,u]=[v(p.x0),v(p.x1)],d=p.panels.map(([w,x])=>[v(w),v(x)])}let h=[(c[0]+u[0])/2,(c[1]+u[1])/2],f=(a?.5:1)*Math.hypot(u[0]-c[0],u[1]-c[1]),g=d.map(([v,w])=>R`${Mt(e.at(v,o+.035),e.at(w,o+.035),"nf-open-pane")}${Mt(e.at(v,o-.035),e.at(w,o-.035),"nf-open-pane")}`),b=(v,w)=>{let[x,k]=e.at(v,i),[M,A]=e.at(w,i),T=e.at(v,i+(r?-f:f)),F=f*t.scale,L=(T[0]-x)*(A-k)-(T[1]-k)*(M-x)>0?1:0;return R`<path d="M${x} ${k}L${T[0]} ${T[1]}A${F} ${F} 0 0 ${L} ${M} ${A}" />`},y;return l==="passage"?y=Mt(e.at(e.p0,o),e.at(e.p1,o),"nf-open-passage"):l==="sliding"?y=Mt(e.at(c,i),e.at(u,i)):a?y=R`${b(c,h)}${b(u,h)}`:y=s?b(c,u):b(u,c),R`${g}${y}`}function O0(t,e){let n=(t.across[0]-t.across[1])/2;if(e.opens==="slide"){let i=e.leaves===2?4:2,o=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:i},(l,a)=>{let c=e.leaves===2?a===1||a===2?.035:-.035:a===0?.035:-.035;return Mt(t.at(o(Math.max(0,a/i-.03)),n+c),t.at(o(Math.min(1,(a+1)/i+.03)),n+c))});return R`${s}`}let r=e.leaves===2?Mt(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`${Mt(t.at(t.p0,n+.035),t.at(t.p1,n+.035))}${Mt(t.at(t.p0,n-.035),t.at(t.p1,n-.035))}${r}`}function eg(t,e,n,r){let i=e.openings.find(s=>s.id===r)?.front??null,o=s=>{let l=P0(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"&&Ws(rn(s,l.exterior)),u=s.id===r||!!s.front&&s.front===i,d=`nf-open nf-open-${s.type}${c?" nf-open-front":""}${u?" nf-open-sel":""}`,p=s.type==="garage"?D0(l,s):s.type==="door"?I0(t,l,s):O0(l,s);return R`<g data-opening=${s.id} class=${d}><polygon class="nf-open-gap" points=${a.map(h=>h.join(",")).join(" ")} />${p}</g>`};return R`<g>${e.openings.map(o)}</g>`}var tg=t=>Math.round(t*1e3)/1e3,ng=t=>Math.round(t*100)/100;function ir(t,e){let n=[...t??[]].slice(0,e);for(;n.length<e;)n.push(null);return n}var is=t=>t.every(e=>e===null);function Si(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 Vl(t,e,n){let r=ir(t.wall_heights,t.points.length);r[e]=n,t.wall_heights=is(r)?void 0:r,os(t,e,null)}function os(t,e,n){if(n===null&&!t.wall_slopes)return;let r=ir(t.wall_slopes,t.points.length);r[e]=n,t.wall_slopes=is(r)?void 0:r}function rg(t,e,n,r){let[i,o]=[n,r].map(l=>Math.min(30,Math.max(.05,tg(l)))),s=ir(t.wall_heights,t.points.length);s[e]=i,t.wall_heights=s,os(t,e,o)}function ig(t,e,n){let r=t.wall_heights?.[e];os(t,e,null),typeof r=="number"&&r>=n-.005&&Vl(t,e,null)}function og(t,e,n,r,i){let o=ir(t.wall_heights,t.points.length),s=o[e],l=Array.isArray(s)?[...s]:new Array(i).fill(typeof s=="number"?s:null);for(;l.length<i;)l.push(null);l[n]=r,o[e]=l.every(a=>a===l[0])?l[0]:l,t.wall_heights=is(o)?void 0:o,os(t,e,null)}function sg(t,e,n,r){let i=Si(t,e),o=n===void 0?0:r[n],s=n===void 0?i:r[n+1]??i;if(s-o<.4)return!1;let l=ng((o+s)/2),a=ir(t.wall_splits,t.points.length);a[e]=[...a[e]??[],l].sort((u,d)=>u-d),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 ag(t,e,n,r,i){let o=Si(t,e),s=i.filter(u=>Math.abs(u-n)>.001&&u>0),l=Math.max(.1,Math.min(o-.1,ng(r)));s.some(u=>Math.abs(u-l)<.1)&&(l=n);let a=t.wall_splits?.[e];if(!a)return;let c=a.findIndex(u=>Math.abs(u-n)<.001);c>=0&&(a[c]=l),a.sort((u,d)=>u-d)}function lg(t,e,n,r){let i=t.wall_splits;if(!i?.[e])return;let o=i[e].filter(l=>Math.abs(l-n)>.001);i[e]=o.length>0?o:null,i.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 cg(t,e,n,r,i=1){let o=ir(t.wall_thickness,t.points.length);if(r===void 0||i<2)o[e]=n;else{let s=o[e],l=Array. Line truncated
<span><b>${x}</b><br /><span class="nf-muted">${pe(t.hass,y)}</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"),u,P=>n.setSlope(e,c,P,M),.05,.05)}
@@ -1359,13 +1359,13 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${t.admin&&h===void 0&&f!==0&&!A?m`<button class="nf-btn" title=${r("wall_slope_hint")} @click=${()=>n.setSlope(e,c,T,T>=i-dg?T+1:i)}>∠ ${r("wall_slope")}</button>`:_}
${t.admin&&f!==0?m`<button class="nf-btn" title=${r("wall_none_hint")} @click=${()=>v(0)}>${r("wall_none")}</button>`:_}
${t.admin&&y>=.4?m`<button class="nf-btn" title=${r("wall_split_hint")} @click=${()=>n.cut(e,c,h)}>✂</button>`:_}
${h===void 0&&y>=.4?Go(t,hg(e,c),n.arc):_}
${h===void 0&&y>=.4?Zo(t,hg(e,c),n.arc):_}
${(h===void 0||h===0)&&f!==0?m`<button class="nf-btn" title=${r("wall_view_hint")} @click=${()=>n.openWall(e,c)}>▣ ${r("wall_view")}</button>`:_}
${f!==0?m`<span class="nf-wide nf-split-row" title=${r("wall_thickness_hint")}
>${E(t,r("edge_thickness"),b??w,P=>n.setThickness(e,c,ug(P,w),h,d.length),.01,.02)}
${t.admin&&b!=null?m`<button class="nf-btn" title=${r("wall_thickness_reset")} @click=${()=>n.setThickness(e,c,null,h,d.length)}>↺</button>`:_}</span
>`:_}
${h===void 0?Zo(t,hg(e,c),n.arc):_}
${h===void 0?qo(t,hg(e,c),n.arc):_}
${k?m`<span class="nf-wide nf-split-row"
>${E(t,r("wall_split_at"),d[h],P=>n.moveCut(e,c,d[h],P),.05,.1)}
${t.admin?m`<button class="nf-btn" title=${r("wall_join_hint")} @click=${()=>n.join(e,c,d[h],h)}>⨉</button>`:_}</span
@@ -1382,7 +1382,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<button class="nf-link nf-value-remove nf-wide" ?disabled=${!t.admin} @click=${()=>{let l=e.filter(a=>a.id!==o.id);n(l.length?l:void 0)}}>× ${t.t("device_value_remove")}</button>
</div>`)}
${S(t.t("device_values_hint"))}
</div>`}function mg(t,e,n){let r=e.color_entity&&e.color_entity!=="none"?e.color_entity:n;return r?t.states[r]:void 0}var Kl=["none","rainbow","pulse","flicker"];function os(t,e,n,r){let i=e.effect_animations??{},o=Du(),s=c=>Kl.includes(c)||o.includes(c),l=[...new Set([...Object.keys(i),...Array.isArray(n)?n.filter(c=>typeof c=="string"):[]])],a=(c,u,d,p=!1)=>{let h=Object.prototype.hasOwnProperty.call(i,c),f=Array.from(c).length,g=p&&h?"light_effect_exists":u!==""&&(f<1||f>255)?"light_effect_name_limit":u!==""&&!h&&Object.keys(i).length>=100?"light_effect_count_limit":void 0;if(d.setCustomValidity?.(g?t.t(g):""),g){let y=d.closest?.("details")?.querySelector("[data-effect-feedback]");return y&&(y.textContent=t.t(g)),d.reportValidity?.(),p||(d.value=h?i[c]:""),!1}let b={...i};return u===""?delete b[c]:Object.defineProperty(b,c,{value:u,enumerable:!0,configurable:!0,writable:!0}),r({effect_animations:b}),!0};return m`<details class="nf-wide">
</div>`}function mg(t,e,n){let r=e.color_entity&&e.color_entity!=="none"?e.color_entity:n;return r?t.states[r]:void 0}var Kl=["none","rainbow","pulse","flicker"];function ss(t,e,n,r){let i=e.effect_animations??{},o=Du(),s=c=>Kl.includes(c)||o.includes(c),l=[...new Set([...Object.keys(i),...Array.isArray(n)?n.filter(c=>typeof c=="string"):[]])],a=(c,u,d,p=!1)=>{let h=Object.prototype.hasOwnProperty.call(i,c),f=Array.from(c).length,g=p&&h?"light_effect_exists":u!==""&&(f<1||f>255)?"light_effect_name_limit":u!==""&&!h&&Object.keys(i).length>=100?"light_effect_count_limit":void 0;if(d.setCustomValidity?.(g?t.t(g):""),g){let y=d.closest?.("details")?.querySelector("[data-effect-feedback]");return y&&(y.textContent=t.t(g)),d.reportValidity?.(),p||(d.value=h?i[c]:""),!1}let b={...i};return u===""?delete b[c]:Object.defineProperty(b,c,{value:u,enumerable:!0,configurable:!0,writable:!0}),r({effect_animations:b}),!0};return m`<details class="nf-wide">
<summary>${t.t("light_effects")}</summary>
${S(t.t("light_effects_hint"))}
<label class="nf-check"><input type="checkbox" .checked=${e.animations_enabled!==!1} ?disabled=${!t.admin}
@@ -1420,7 +1420,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${e.position?D(t,r("cover_position_invert"),!!e.position_inverted,p=>a({position_inverted:p||void 0})):_}
${S(r("cover_direction_hint"),"nf-wide")}`:_}
${o?m`${H(t,r("lamp_mount"),s,d,u,{wide:!0})}${ln(t,e.glow_scale,p=>a({glow_scale:p}))}`:_}
${o?os(t,e,t.hass?.states[e.entity_id]?.attributes.effect_list,a):_}
${o?ss(t,e,t.hass?.states[e.entity_id]?.attributes.effect_list,a):_}
${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)}
@@ -1454,14 +1454,14 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${i.duration&&i.duration!=="none"?H(t,r("charging_duration_unit"),i.duration_unit??"auto",a,u=>s({duration_unit:u}),{wide:!0}):_}
${c("energy",r("charging_energy"),[1,2])}
${c("lock",r("charging_lock"),[1])}
</div>`}var Mi=t=>Number(t);function ss(t){if(Array.isArray(t)){let[o,s]=[Mi(t[0]),Mi(t[1])];return Number.isFinite(o)&&Number.isFinite(s)?[o,s]:null}if(!t||typeof t!="object")return null;let{x:e,y:n}=t,[r,i]=[Mi(e),Mi(n)];return Number.isFinite(r)&&Number.isFinite(i)?[r,i]:null}function yg(t){return t?ss(t.charger)??ss(t.charger_position):null}function as(t){for(let[e,n]of Object.entries(t.states))if(e.startsWith("camera.")&&(ss(n.attributes?.vacuum_position)??yg(n.attributes)))return e;return null}var Ul=(t,e)=>e?[t[0],-t[1]]:t;var vg=5e-4,wg=2,B0=1.5;function Gl(t,e){let n=e?t.states[e]?.attributes:void 0;return{at:n?ss(n.vacuum_position):null,dock:yg(n)}}function kg(t,e,n=!1){let r=Math.hypot(e.plan[0]-t.plan[0],e.plan[1]-t.plan[1]),i=Math.hypot(e.grid[0]-t.grid[0],e.grid[1]-t.grid[1]);if(!(i>1e-6)||!(r>=B0))return{cal:null,reason:"close"};let o=r/i;return o>=vg&&o<=wg?{cal:{a:t.plan,ga:t.grid,b:e.plan,gb:e.grid,mirror:n}}:{cal:null,reason:"scale"}}function xg(t,e){let n=e?t.states[e]?.attributes?.rooms:void 0;if(!n||typeof n!="object")return[];let r=[];for(let i of Object.values(n)){if(!i||typeof i!="object")continue;let o=i,s=typeof o.name=="string"?o.name.trim():"",l=[o.x0,o.y0,o.x1,o.y1].map(Mi);!s||!l.every(Number.isFinite)||r.push({name:s,center:[(l[0]+l[2])/2,(l[1]+l[3])/2]})}return r}var _g=t=>t.toLocaleLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^\p{L}\p{N}]+/gu,"");function W0(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]),[i,o]=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],[b,y]=[h.plan[0]-i,h.plan[1]-o];s+=f*b+g*y,l+=f*y-g*b,a+=f*f+g*g}if(!(a>1e-9))return null;let[c,u]=[s/a,l/a],d=h=>{let[f,g]=[h[0]-n,h[1]-r];return[i+c*f-u*g,o+u*f+c*g]},p=Math.sqrt(t.reduce((h,f)=>h+Math.hypot(d(f.seen)[0]-f.plan[0],d(f.seen)[1]-f.plan[1])**2,0)/e);return{map:d,scale:Math.hypot(c,u),rms:p}}function $g(t,e,n=!1){let r=new Map(e.map(g=>[_g(g.name),g])),i=[],o=new Set;for(let g of t){let b=_g(g.name),y=r.get(b);if(!y||o.has(b)||g.points.length<3)continue;o.add(b);let v=g.points.map(x=>x[0]),w=g.points.map(x=>x[1]);i.push({name:g.name,plan:[(Math.min(...v)+Math.max(...v))/2,(Math.min(...w)+Math.max(...w))/2],grid:y.center})}let s=i.map(g=>g.name);if(i.length<2)return{cal:null,reason:"rooms",matched:s};let a=(i.length>=3?[!1,!0]:[n]).flatMap(g=>{let b=W0(i.map(y=>({plan:y.plan,seen:Ul(y.grid,g)})));return b?[{mirror:g,...b}]:[]}).sort((g,b)=>g.rms-b.rms)[0];if(!a)return{cal:null,reason:"rooms",matched:s};if(!(a.scale>=vg&&a.scale<=wg))return{cal:null,reason:"scale",matched:s};let c=Math.max(...i.map(g=>Math.hypot(g.plan[0]-i[0].plan[0],g.plan[1]-i[0].plan[1])));if(!(a.rms<=Math.max(1,c/4)))return{cal:null,reason:"fit",matched:s};let[u,d,p]=[0,1,-1];for(let g=0;g<i.length;g++)for(let b=g+1;b<i.length;b++){let y=Math.hypot(i[g].grid[0]-i[b].grid[0],i[g].grid[1]-i[b].grid[1]);y>p&&([u,d,p]=[g,b,y])}let[h,f]=[i[u].grid,i[d].grid];return{cal:{a:a.map(Ul(h,a.mirror)),ga:h,b:a.map(Ul(f,a.mirror)),gb:f,mirror:a.mirror},matched:s,rms:a.rms}}function Sg(t,e){let[n,r]=[(t.a[0]+t.b[0])/2,(t.a[1]+t.b[1])/2],i=(e.turn??0)*Math.PI/180,[o,s,l]=[Math.cos(i),Math.sin(i),e.grow??1],[a,c]=e.move??[0,0],u=d=>{let[p,h]=[(d[0]-n)*l,(d[1]-r)*l];return[bg(n+p*o-h*s+a),bg(r+p*s+h*o+c)]};return{...t,a:u(t.a),b:u(t.b)}}var bg=t=>Math.round(t*1e3)/1e3;var V0=/^(binary_sensor|switch|input_boolean|light|fan|person|device_tracker|sensor)\./,Rt=t=>t==="none"?null:t;function Zl(t,e,n){let r=t.t,i=O(t.hass,a=>V0.test(a)),o=!!e.state_entity&&e.state_entity!=="none",s=o&&!!e.state_entity2&&e.state_entity2!=="none",l=[["left_right",r("furn_state_left_right")],["top_bottom",r("furn_state_top_bottom")]];return m`${z(t,r("furn_state_entity"),e.state_entity??null,void 0,i,a=>n.update({state_entity:Rt(a)}))}
</div>`}var Mi=t=>Number(t);function as(t){if(Array.isArray(t)){let[o,s]=[Mi(t[0]),Mi(t[1])];return Number.isFinite(o)&&Number.isFinite(s)?[o,s]:null}if(!t||typeof t!="object")return null;let{x:e,y:n}=t,[r,i]=[Mi(e),Mi(n)];return Number.isFinite(r)&&Number.isFinite(i)?[r,i]:null}function yg(t){return t?as(t.charger)??as(t.charger_position):null}function ls(t){for(let[e,n]of Object.entries(t.states))if(e.startsWith("camera.")&&(as(n.attributes?.vacuum_position)??yg(n.attributes)))return e;return null}var Ul=(t,e)=>e?[t[0],-t[1]]:t;var vg=5e-4,wg=2,B0=1.5;function Gl(t,e){let n=e?t.states[e]?.attributes:void 0;return{at:n?as(n.vacuum_position):null,dock:yg(n)}}function kg(t,e,n=!1){let r=Math.hypot(e.plan[0]-t.plan[0],e.plan[1]-t.plan[1]),i=Math.hypot(e.grid[0]-t.grid[0],e.grid[1]-t.grid[1]);if(!(i>1e-6)||!(r>=B0))return{cal:null,reason:"close"};let o=r/i;return o>=vg&&o<=wg?{cal:{a:t.plan,ga:t.grid,b:e.plan,gb:e.grid,mirror:n}}:{cal:null,reason:"scale"}}function xg(t,e){let n=e?t.states[e]?.attributes?.rooms:void 0;if(!n||typeof n!="object")return[];let r=[];for(let i of Object.values(n)){if(!i||typeof i!="object")continue;let o=i,s=typeof o.name=="string"?o.name.trim():"",l=[o.x0,o.y0,o.x1,o.y1].map(Mi);!s||!l.every(Number.isFinite)||r.push({name:s,center:[(l[0]+l[2])/2,(l[1]+l[3])/2]})}return r}var _g=t=>t.toLocaleLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").replace(/[^\p{L}\p{N}]+/gu,"");function W0(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]),[i,o]=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],[b,y]=[h.plan[0]-i,h.plan[1]-o];s+=f*b+g*y,l+=f*y-g*b,a+=f*f+g*g}if(!(a>1e-9))return null;let[c,u]=[s/a,l/a],d=h=>{let[f,g]=[h[0]-n,h[1]-r];return[i+c*f-u*g,o+u*f+c*g]},p=Math.sqrt(t.reduce((h,f)=>h+Math.hypot(d(f.seen)[0]-f.plan[0],d(f.seen)[1]-f.plan[1])**2,0)/e);return{map:d,scale:Math.hypot(c,u),rms:p}}function $g(t,e,n=!1){let r=new Map(e.map(g=>[_g(g.name),g])),i=[],o=new Set;for(let g of t){let b=_g(g.name),y=r.get(b);if(!y||o.has(b)||g.points.length<3)continue;o.add(b);let v=g.points.map(x=>x[0]),w=g.points.map(x=>x[1]);i.push({name:g.name,plan:[(Math.min(...v)+Math.max(...v))/2,(Math.min(...w)+Math.max(...w))/2],grid:y.center})}let s=i.map(g=>g.name);if(i.length<2)return{cal:null,reason:"rooms",matched:s};let a=(i.length>=3?[!1,!0]:[n]).flatMap(g=>{let b=W0(i.map(y=>({plan:y.plan,seen:Ul(y.grid,g)})));return b?[{mirror:g,...b}]:[]}).sort((g,b)=>g.rms-b.rms)[0];if(!a)return{cal:null,reason:"rooms",matched:s};if(!(a.scale>=vg&&a.scale<=wg))return{cal:null,reason:"scale",matched:s};let c=Math.max(...i.map(g=>Math.hypot(g.plan[0]-i[0].plan[0],g.plan[1]-i[0].plan[1])));if(!(a.rms<=Math.max(1,c/4)))return{cal:null,reason:"fit",matched:s};let[u,d,p]=[0,1,-1];for(let g=0;g<i.length;g++)for(let b=g+1;b<i.length;b++){let y=Math.hypot(i[g].grid[0]-i[b].grid[0],i[g].grid[1]-i[b].grid[1]);y>p&&([u,d,p]=[g,b,y])}let[h,f]=[i[u].grid,i[d].grid];return{cal:{a:a.map(Ul(h,a.mirror)),ga:h,b:a.map(Ul(f,a.mirror)),gb:f,mirror:a.mirror},matched:s,rms:a.rms}}function Sg(t,e){let[n,r]=[(t.a[0]+t.b[0])/2,(t.a[1]+t.b[1])/2],i=(e.turn??0)*Math.PI/180,[o,s,l]=[Math.cos(i),Math.sin(i),e.grow??1],[a,c]=e.move??[0,0],u=d=>{let[p,h]=[(d[0]-n)*l,(d[1]-r)*l];return[bg(n+p*o-h*s+a),bg(r+p*s+h*o+c)]};return{...t,a:u(t.a),b:u(t.b)}}var bg=t=>Math.round(t*1e3)/1e3;var V0=/^(binary_sensor|switch|input_boolean|light|fan|person|device_tracker|sensor)\./,Rt=t=>t==="none"?null:t;function Zl(t,e,n){let r=t.t,i=O(t.hass,a=>V0.test(a)),o=!!e.state_entity&&e.state_entity!=="none",s=o&&!!e.state_entity2&&e.state_entity2!=="none",l=[["left_right",r("furn_state_left_right")],["top_bottom",r("furn_state_top_bottom")]];return m`${z(t,r("furn_state_entity"),e.state_entity??null,void 0,i,a=>n.update({state_entity:Rt(a)}))}
${o?z(t,r("furn_state_entity2"),e.state_entity2??null,void 0,i,a=>n.update({state_entity2:Rt(a)})):_}
${s?H(t,r("furn_state_split"),e.state_split==="top_bottom"?"top_bottom":"left_right",l,a=>n.update({state_split:a})):_}
${S(r("furn_state_hint"),"nf-wide")}`}function K0(t,e){let r=On(t.type)&&(!vt(t.type)||Yc(t.type));return ue(t.type)?{accept:i=>/^(light|switch|input_boolean)\./.test(i),label:"furn_entity_light"}:t.type==="radiator"||En(t.type)?{accept:i=>i.startsWith("climate."),label:"furn_entity_climate"}:r?{accept:i=>/^(media_player|switch|input_boolean|light)\./.test(i),label:"furn_entity_tv"}:t.type==="robot_vacuum"?{accept:i=>i.startsWith("vacuum."),label:"furn_entity_vacuum"}:/:(robot_mower|mower_dock)$/.test(t.type)?{accept:i=>i.startsWith("lawn_mower."),label:"furn_entity_mower"}:/:(sprinkler|valve_box)$/.test(t.type)?{accept:i=>/^(valve|switch|input_boolean)\./.test(i),label:"furn_entity_water"}:{accept:i=>/^(switch|media_player|fan|input_boolean|climate|vacuum|cover|valve)\./.test(i)||Bc(e?.states[i]),label:"furn_entity"}}function ls(t,e,n){if(!t.hass)return null;let r=structuredClone(t.doc.floors);for(let i of r)for(let o of i.furniture)o.id===e.id&&(o[n==="fan"?"fan_entity":n]=null);return Me(t.hass,r).get(e.id)?.[n]??null}var j0=t=>t==="meter"?"energy_grid":t==="inverter"?"energy_solar_sensor":t==="home_battery"?"energy_battery_sensor":"furn_power",ct=(...t)=>m`<div class="nf-form nf-links">${t}</div>`;async function U0(t){let e=t.hass?as(t.hass):null;if(!t.hass||!e)return{at:null,dock:null};let n=()=>{let i=t.hass?.states[e]?.attributes??{};return`${String(i.render_count??"")}|${JSON.stringify(i.vacuum_position??null)}`},r=n();try{await t.hass.fetchWithAuth?.(`/api/camera_proxy/${e}`)}catch{}for(let i=0;i<8&&n()===r;i++)await new Promise(o=>setTimeout(o,100));return Gl(t.hass,e)}function G0(t,e){let n=t.t,r=a=>t.change(c=>{c.settings.vacuum_map=Sg(e,a)}),i=(a,c,u)=>m`<button class="nf-btn" title=${c} aria-label=${c} ?disabled=${!t.admin} @click=${()=>r(u)}>${a}</button>`,[o,s,l]=[n("robot_cal_nudge_move"),n("robot_cal_nudge_turn"),n("robot_cal_nudge_grow")];return m`${S(n("robot_cal_nudge"),"nf-wide")}
${S(r("furn_state_hint"),"nf-wide")}`}function K0(t,e){let r=On(t.type)&&(!vt(t.type)||Yc(t.type));return ue(t.type)?{accept:i=>/^(light|switch|input_boolean)\./.test(i),label:"furn_entity_light"}:t.type==="radiator"||En(t.type)?{accept:i=>i.startsWith("climate."),label:"furn_entity_climate"}:r?{accept:i=>/^(media_player|switch|input_boolean|light)\./.test(i),label:"furn_entity_tv"}:t.type==="robot_vacuum"?{accept:i=>i.startsWith("vacuum."),label:"furn_entity_vacuum"}:/:(robot_mower|mower_dock)$/.test(t.type)?{accept:i=>i.startsWith("lawn_mower."),label:"furn_entity_mower"}:/:(sprinkler|valve_box)$/.test(t.type)?{accept:i=>/^(valve|switch|input_boolean)\./.test(i),label:"furn_entity_water"}:{accept:i=>/^(switch|media_player|fan|input_boolean|climate|vacuum|cover|valve)\./.test(i)||Bc(e?.states[i]),label:"furn_entity"}}function cs(t,e,n){if(!t.hass)return null;let r=structuredClone(t.doc.floors);for(let i of r)for(let o of i.furniture)o.id===e.id&&(o[n==="fan"?"fan_entity":n]=null);return Me(t.hass,r).get(e.id)?.[n]??null}var j0=t=>t==="meter"?"energy_grid":t==="inverter"?"energy_solar_sensor":t==="home_battery"?"energy_battery_sensor":"furn_power",ct=(...t)=>m`<div class="nf-form nf-links">${t}</div>`;async function U0(t){let e=t.hass?ls(t.hass):null;if(!t.hass||!e)return{at:null,dock:null};let n=()=>{let i=t.hass?.states[e]?.attributes??{};return`${String(i.render_count??"")}|${JSON.stringify(i.vacuum_position??null)}`},r=n();try{await t.hass.fetchWithAuth?.(`/api/camera_proxy/${e}`)}catch{}for(let i=0;i<8&&n()===r;i++)await new Promise(o=>setTimeout(o,100));return Gl(t.hass,e)}function G0(t,e){let n=t.t,r=a=>t.change(c=>{c.settings.vacuum_map=Sg(e,a)}),i=(a,c,u)=>m`<button class="nf-btn" title=${c} aria-label=${c} ?disabled=${!t.admin} @click=${()=>r(u)}>${a}</button>`,[o,s,l]=[n("robot_cal_nudge_move"),n("robot_cal_nudge_turn"),n("robot_cal_nudge_grow")];return m`${S(n("robot_cal_nudge"),"nf-wide")}
<div class="nf-wide" style="display:flex;flex-wrap:wrap;gap:6px">
${i("\u2190",o,{move:[-.1,0]})}${i("\u2192",o,{move:[.1,0]})}${i("\u2191",o,{move:[0,-.1]})}${i("\u2193",o,{move:[0,.1]})}
${i("\u27F2",s,{turn:-1})}${i("\u27F3",s,{turn:1})}${i("\u2212",l,{grow:.99})}${i("+",l,{grow:1.01})}
</div>`}function Z0(t,e){let n=t.t,r=t.doc.settings.vacuum_map??null,i=t.hass?Gl(t.hass,as(t.hass)):{at:null,dock:null},o=r?Math.hypot(r.gb[0]-r.ga[0],r.gb[1]-r.ga[1]):0,s=r&&o>0?Math.hypot(r.b[0]-r.a[0],r.b[1]-r.a[1])/o:0,l=()=>{t.pickPoint(p=>{p&&U0(t).then(h=>{if(!h.at||!h.dock)return;let f={plan:[e.x,e.z],grid:h.dock},g=kg(f,{plan:p,grid:h.at},r?.mirror??!1);g.cal&&t.change(b=>{b.settings.vacuum_map=g.cal})})})},a=t.hass?as(t.hass):null,c=t.hass?xg(t.hass,a):[],u=t.doc.floors.find(p=>p.furniture.some(h=>h.id===e.id)),d=()=>{if(!u)return;let p=$g(u.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 ct(S(i.at&&i.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||!u} @click=${d}>${n("robot_cal_rooms",{n:c.length})}</button>`:_,m`<button class="nf-btn nf-wide" ?disabled=${!t.admin||!i.at||!i.dock} @click=${l}>${n("robot_cal_do")}</button>`,r?D(t,n("robot_cal_mirror"),!!r.mirror,p=>t.change(h=>{h.settings.vacuum_map={...r,mirror:p}})):_,r?G0(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>`:_,S(n("robot_cal_hint"),"nf-wide"))}function q0(t,e,n){let r=t.t,i=t.doc;if(!i.energy.advanced)return _;let o=qn(i),s=i.floors.flatMap(l=>l.furniture.filter(a=>o.has(a.id)).map(a=>[a.id,`${a.name||r("furn_meter")} \xB7 ${l.name}`]));return ct(H(t,r("meter_parent"),ai(i,e)??"",[["",r("meter_main")],...s],l=>n.update({parent_meter:l||null}),{wide:!0}),S(r("meter_device_hint"),"nf-wide"))}function Y0(t,e,n){let r=t.t,i=t.doc;if(!i.energy.advanced)return _;let o=i.floors.flatMap(c=>c.furniture.filter(u=>hh(i,e,u)).map(u=>[u.id,`${u.name||r("furn_meter")} \xB7 ${c.name}`])),s=!!_n(i,e),l=e.meter_floors??[],a=(c,u)=>n.update({meter_floors:u?[...l.filter(d=>d!==c),c]:l.filter(d=>d!==c)});return ct(H(t,r("meter_parent"),s?e.parent_meter:"",[["",r("meter_parent_none")],...o],c=>n.update({parent_meter:c||null}),{wide:!0}),s?D(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>${i.floors.map(c=>D(t,c.name,l.includes(c.id),u=>a(c.id,u)))}`:_,S(r("meter_sub_hint"),"nf-wide"))}function Mg(t,e,n,r){let i=t.t,o=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">
</div>`}function Z0(t,e){let n=t.t,r=t.doc.settings.vacuum_map??null,i=t.hass?Gl(t.hass,ls(t.hass)):{at:null,dock:null},o=r?Math.hypot(r.gb[0]-r.ga[0],r.gb[1]-r.ga[1]):0,s=r&&o>0?Math.hypot(r.b[0]-r.a[0],r.b[1]-r.a[1])/o:0,l=()=>{t.pickPoint(p=>{p&&U0(t).then(h=>{if(!h.at||!h.dock)return;let f={plan:[e.x,e.z],grid:h.dock},g=kg(f,{plan:p,grid:h.at},r?.mirror??!1);g.cal&&t.change(b=>{b.settings.vacuum_map=g.cal})})})},a=t.hass?ls(t.hass):null,c=t.hass?xg(t.hass,a):[],u=t.doc.floors.find(p=>p.furniture.some(h=>h.id===e.id)),d=()=>{if(!u)return;let p=$g(u.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 ct(S(i.at&&i.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||!u} @click=${d}>${n("robot_cal_rooms",{n:c.length})}</button>`:_,m`<button class="nf-btn nf-wide" ?disabled=${!t.admin||!i.at||!i.dock} @click=${l}>${n("robot_cal_do")}</button>`,r?D(t,n("robot_cal_mirror"),!!r.mirror,p=>t.change(h=>{h.settings.vacuum_map={...r,mirror:p}})):_,r?G0(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>`:_,S(n("robot_cal_hint"),"nf-wide"))}function q0(t,e,n){let r=t.t,i=t.doc;if(!i.energy.advanced)return _;let o=qn(i),s=i.floors.flatMap(l=>l.furniture.filter(a=>o.has(a.id)).map(a=>[a.id,`${a.name||r("furn_meter")} \xB7 ${l.name}`]));return ct(H(t,r("meter_parent"),ai(i,e)??"",[["",r("meter_main")],...s],l=>n.update({parent_meter:l||null}),{wide:!0}),S(r("meter_device_hint"),"nf-wide"))}function Y0(t,e,n){let r=t.t,i=t.doc;if(!i.energy.advanced)return _;let o=i.floors.flatMap(c=>c.furniture.filter(u=>hh(i,e,u)).map(u=>[u.id,`${u.name||r("furn_meter")} \xB7 ${c.name}`])),s=!!_n(i,e),l=e.meter_floors??[],a=(c,u)=>n.update({meter_floors:u?[...l.filter(d=>d!==c),c]:l.filter(d=>d!==c)});return ct(H(t,r("meter_parent"),s?e.parent_meter:"",[["",r("meter_parent_none")],...o],c=>n.update({parent_meter:c||null}),{wide:!0}),s?D(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>${i.floors.map(c=>D(t,c.name,l.includes(c.id),u=>a(c.id,u)))}`:_,S(r("meter_sub_hint"),"nf-wide"))}function Mg(t,e,n,r){let i=t.t,o=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">
${z(t,i(`care_entity_${n}`),e.care_entity??null,void 0,O(t.hass,o),s=>r.update({care_entity:Rt(s)}))}
${n==="plant"?E(t,i("care_thirsty_below"),e.thirsty_below??20,s=>r.update({thirsty_below:Math.min(90,Math.max(1,Math.round(s)))}),1,1):_}
${S(i(`care_hint_${n}`),"nf-wide")}
@@ -1472,7 +1472,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</div>`}function Eg(t,e,n,r){let i=t.t,o=/socket/.test(e.type),s=O(t.hass,c=>/^(light|switch|input_boolean|fan)\./.test(c)),l=e.gang_entities??[],a=c=>u=>{let d=Array.from({length:n},(p,h)=>l[h]??null);d[c]=Rt(u),r.update({gang_entities:d})};return m`<div class="nf-form nf-links">
${Array.from({length:n},(c,u)=>z(t,n===1?i(o?"gang_socket_one":"gang_switch_one"):i(o?"gang_socket":"gang_switch",{n:u+1}),l[u]??null,void 0,s,a(u),{types:[0,1,2],role:"light"}))}
${S(i(o?"gang_socket_hint":"gang_switch_hint"),"nf-wide")}
</div>`}function X0(t,e,n){let r=t.t,i=O(t.hass,o=>{let s=t.hass?.states[o]?.attributes;return o.startsWith("sensor.")&&(s?.device_class==="temperature"||s?.unit_of_measurement==="\xB0C"||s?.unit_of_measurement==="\xB0F")});return ct(z(t,r("fridge_temp"),e.temp_entity??null,void 0,i,o=>n.update({temp_entity:Rt(o)}),{types:[1,2]}),z(t,r("freezer_temp"),e.temp_entity2??null,void 0,i,o=>n.update({temp_entity2:Rt(o)}),{types:[1,2]}),S(r("fridge_temp_hint"),"nf-wide"))}function J0(t,e,n){let r=t.t,i=O(t.hass,o=>{let s=t.hass?.states[o]?.attributes;return o.startsWith("sensor.")&&(s?.device_class==="temperature"||s?.unit_of_measurement==="\xB0C"||s?.unit_of_measurement==="\xB0F")});return ct(z(t,r("device_temp"),e.temp_entity??null,void 0,i,o=>n.update({temp_entity:Rt(o)}),{types:[1,2]}),S(r("device_temp_hint"),"nf-wide"))}function Q0(t,e,n){let r=t.t,i=e.extra_lights??[],o=O(t.hass,a=>a.startsWith("light.")&&a!==e.entity&&a!==e.color_entity),s=a=>c=>{let u=[...i];c&&c!=="none"?u[a]=c:u.splice(a,1),n.update({extra_lights:u.filter(Boolean).length?u.filter(Boolean):void 0})},l=Math.min(4,i.length+1);return m`${Array.from({length:l},(a,c)=>z(t,r("lamp_extra_light",{n:c+2}),i[c]??null,void 0,o,s(c),{types:[0,1,2],role:"light"}))}${S(r("lamp_extra_hint"),"nf-wide")}`}function Ag(t,e,n){let{hass:r}=t;if(!r)return _;let i=t.t,o=ue(e.type),s=K0(e,r),l=O(r,b=>X(r)?He(r,b,[1,2]):Hn(r,b)),a=b=>y=>n.update({[b]:Rt(y)}),c=b=>O(r,b),u=(t.doc.settings.roof.strings??[]).filter(b=>b.inverter===e.id).map(b=>b.name),d=!!e.entity&&e.entity!=="none",p=ls(t,e,"power"),h=e.power==="none"?null:e.power||p,f=e.type==="fridge_smart"?c(b=>b.startsWith("binary_sensor.")):[],g=e.type==="ceiling_fan"?"fan_hint":o?e.type==="lamp_pendant"?"lamp_hint_pendant":"lamp_hint":On(e.type)?"furn_links_hint_tv":e.type==="robot_vacuum"?"robot_hint":"furn_links_hint";return m`${ct(e.type==="grid_point"?S(i("grid_point_hint"),"nf-wide"):z(t,i(s.label),e.entity??null,ls(t,e,"entity"),c(s.accept),b=>n.update({entity:b}),o?{types:[0,1,2],role:"light"}:{}),e.type==="ceiling_fan"?z(t,i("furn_fan_entity"),e.fan_entity??null,ls(t,e,"fan"),c(b=>b.startsWith("fan.")),b=>n.update({fan_entity:b}),{types:[0,1,2]}):_,!o&&!Ke.includes(e.type)&&!zr(e.type)?Zl(t,e,n):_,o&&d?m`${z(t,i("furn_color_entity"),e.color_entity??null,void 0,c(b=>b.startsWith("light.")&&b!==e.entity),a("color_entity"),{types:[0,1,2],role:"light"})}${S(i("furn_color_entity_hint"),"nf-wide")}`:_,o&&d?Q0(t,e,n):_,o?ln(t,e.glow_scale,b=>n.update({glow_scale:b})):_,o?os(t,e,mg(r,e,e.entity&&e.entity!=="none"?e.entity:ls(t,e,"entity"))?.attributes.effect_list,n.update):_,zr(e.type)?ln(t,e.ambilight,b=>n.update({ambilight:b}),{label:"ambilight",hint:"ambilight_hint",lowest:0}):_,On(e.type)||uo(e.type)?ln(t,e.sound_rings,b=>n.update({sound_rings:b}),{label:"sound_rings",hint:"sound_rings_hint",lowest:0}):_,e.type==="grid_point"?_:m`${z(t,i(_n(t.doc,e)?"meter_sub_power":j0(e.type)),e.power??null,p,l,b=>n.update({power:b}),{types:[1,2]})}
</div>`}function X0(t,e,n){let r=t.t,i=O(t.hass,o=>{let s=t.hass?.states[o]?.attributes;return o.startsWith("sensor.")&&(s?.device_class==="temperature"||s?.unit_of_measurement==="\xB0C"||s?.unit_of_measurement==="\xB0F")});return ct(z(t,r("fridge_temp"),e.temp_entity??null,void 0,i,o=>n.update({temp_entity:Rt(o)}),{types:[1,2]}),z(t,r("freezer_temp"),e.temp_entity2??null,void 0,i,o=>n.update({temp_entity2:Rt(o)}),{types:[1,2]}),S(r("fridge_temp_hint"),"nf-wide"))}function J0(t,e,n){let r=t.t,i=O(t.hass,o=>{let s=t.hass?.states[o]?.attributes;return o.startsWith("sensor.")&&(s?.device_class==="temperature"||s?.unit_of_measurement==="\xB0C"||s?.unit_of_measurement==="\xB0F")});return ct(z(t,r("device_temp"),e.temp_entity??null,void 0,i,o=>n.update({temp_entity:Rt(o)}),{types:[1,2]}),S(r("device_temp_hint"),"nf-wide"))}function Q0(t,e,n){let r=t.t,i=e.extra_lights??[],o=O(t.hass,a=>a.startsWith("light.")&&a!==e.entity&&a!==e.color_entity),s=a=>c=>{let u=[...i];c&&c!=="none"?u[a]=c:u.splice(a,1),n.update({extra_lights:u.filter(Boolean).length?u.filter(Boolean):void 0})},l=Math.min(4,i.length+1);return m`${Array.from({length:l},(a,c)=>z(t,r("lamp_extra_light",{n:c+2}),i[c]??null,void 0,o,s(c),{types:[0,1,2],role:"light"}))}${S(r("lamp_extra_hint"),"nf-wide")}`}function Ag(t,e,n){let{hass:r}=t;if(!r)return _;let i=t.t,o=ue(e.type),s=K0(e,r),l=O(r,b=>X(r)?He(r,b,[1,2]):Hn(r,b)),a=b=>y=>n.update({[b]:Rt(y)}),c=b=>O(r,b),u=(t.doc.settings.roof.strings??[]).filter(b=>b.inverter===e.id).map(b=>b.name),d=!!e.entity&&e.entity!=="none",p=cs(t,e,"power"),h=e.power==="none"?null:e.power||p,f=e.type==="fridge_smart"?c(b=>b.startsWith("binary_sensor.")):[],g=e.type==="ceiling_fan"?"fan_hint":o?e.type==="lamp_pendant"?"lamp_hint_pendant":"lamp_hint":On(e.type)?"furn_links_hint_tv":e.type==="robot_vacuum"?"robot_hint":"furn_links_hint";return m`${ct(e.type==="grid_point"?S(i("grid_point_hint"),"nf-wide"):z(t,i(s.label),e.entity??null,cs(t,e,"entity"),c(s.accept),b=>n.update({entity:b}),o?{types:[0,1,2],role:"light"}:{}),e.type==="ceiling_fan"?z(t,i("furn_fan_entity"),e.fan_entity??null,cs(t,e,"fan"),c(b=>b.startsWith("fan.")),b=>n.update({fan_entity:b}),{types:[0,1,2]}):_,!o&&!Ke.includes(e.type)&&!zr(e.type)?Zl(t,e,n):_,o&&d?m`${z(t,i("furn_color_entity"),e.color_entity??null,void 0,c(b=>b.startsWith("light.")&&b!==e.entity),a("color_entity"),{types:[0,1,2],role:"light"})}${S(i("furn_color_entity_hint"),"nf-wide")}`:_,o&&d?Q0(t,e,n):_,o?ln(t,e.glow_scale,b=>n.update({glow_scale:b})):_,o?ss(t,e,mg(r,e,e.entity&&e.entity!=="none"?e.entity:cs(t,e,"entity"))?.attributes.effect_list,n.update):_,zr(e.type)?ln(t,e.ambilight,b=>n.update({ambilight:b}),{label:"ambilight",hint:"ambilight_hint",lowest:0}):_,On(e.type)||uo(e.type)?ln(t,e.sound_rings,b=>n.update({sound_rings:b}),{label:"sound_rings",hint:"sound_rings_hint",lowest:0}):_,e.type==="grid_point"?_:m`${z(t,i(_n(t.doc,e)?"meter_sub_power":j0(e.type)),e.power??null,p,l,b=>n.update({power:b}),{types:[1,2]})}
${D(t,i(sr(e.type)?"charging_card":"furniture_power_card"),!!e.power_card,b=>n.update({power_card:b||void 0}))}${S(i(sr(e.type)?"charging_hint":"furniture_power_card_hint"),"nf-wide")}`)}
${sd(e.type)?X0(t,e,n):o||e.type==="grid_point"?_:J0(t,e,n)}
${e.type==="meter"?Y0(t,e,n):_}
@@ -1513,7 +1513,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${S(i("parking_hint"))}
${t.hass?m`${z(t,i("live_car_device"),a.device??null,null,O(t.hass,f=>nk.test(f)),f=>r.update({car:{...a,device:f}}))}
${S(i("live_car_device_hint"),"nf-wide")}
${z(t,i("live_car_departure_entity"),a.departure??null,void 0,O(t.hass,f=>/^(sensor|input_datetime|time|datetime)\./.test(f)),f=>r.update({car:{...a,departure:f==="none"?null:f}}))}`:_}`}function Pg(t,e){let r=wn(t,e.w,e.d,e.h).treads.findIndex(i=>i.landing);return r>=0?r+1:1}function ok(t){let e=wn(ki(t),t.w,t.d,t.h),n=e.treads.map(Uo),r=0;for(let o=1;o<n.length;o++)r+=Math.hypot(n[o][0]-n[o-1][0],n[o][1]-n[o-1][1]);let i=n.length>1?r/(n.length-1):0;return{rise:e.rise,going:i,measure:2*e.rise+i,steps:e.steps}}function sk(t){let[e,n]=ul[t],r=wn({..._t,shape:t},e,n,2.8),i=26/Math.max(e,n);return m`<svg viewBox="-14 -14 28 28" width="28" height="28" aria-hidden="true">
${z(t,i("live_car_departure_entity"),a.departure??null,void 0,O(t.hass,f=>/^(sensor|input_datetime|time|datetime)\./.test(f)),f=>r.update({car:{...a,departure:f==="none"?null:f}}))}`:_}`}function Pg(t,e){let r=wn(t,e.w,e.d,e.h).treads.findIndex(i=>i.landing);return r>=0?r+1:1}function ok(t){let e=wn(ki(t),t.w,t.d,t.h),n=e.treads.map(Go),r=0;for(let o=1;o<n.length;o++)r+=Math.hypot(n[o][0]-n[o-1][0],n[o][1]-n[o-1][1]);let i=n.length>1?r/(n.length-1):0;return{rise:e.rise,going:i,measure:2*e.rise+i,steps:e.steps}}function sk(t){let[e,n]=ul[t],r=wn({..._t,shape:t},e,n,2.8),i=26/Math.max(e,n);return m`<svg viewBox="-14 -14 28 28" width="28" height="28" aria-hidden="true">
${r.treads.map(o=>R`<polygon points=${o.poly.map(([s,l])=>`${s*i},${l*i}`).join(" ")} fill=${o.landing?"currentColor":"none"} fill-opacity="0.25" stroke="currentColor" stroke-width="0.8" />`)}
</svg>`}function Dg(t,e,n){let r=t.t,i=ki(e),o=f=>n.update({stair:{...i,...f}}),s=i.shape!=="straight",l=f=>{let[g,b]=ul[f];n.update({stair:{...i,shape:f,run_width:null},w:g,d:b})},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,u=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:{...i,down:f},...g?{h:Math.round(g*1e3)/1e3}:{}})},d=ok(e),p=f=>K(t.hass,f*100,1),h=d.measure>=.59&&d.measure<=.65&&d.rise<=.21;return m`<div class="nf-form">
<div class="nf-field nf-wide">
@@ -1549,16 +1549,17 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</div></details>`,c=m`${l("Vorlauf",r.flow,d=>o({flow:d}))}${l("R\xFCcklauf",r.return,d=>o({return:d}))}`,u=(d,p)=>{let h=f=>o({circuits:(r.circuits??[]).map(g=>g.id===d.id?{...g,...f}:g)});return m`<details class="nf-hydronic-circuit" data-circuit=${d.id} ?open=${p===0}><summary>${d.name||`Kreis ${p+1}`}</summary><div class="nf-form">
${V(t,"Name",d.name,f=>h({name:f}),{wide:!0,maxlength:100})}
${H(t,"Kreisart",d.kind,[["heating","Heizkreis"],["cooling","K\xFChlkreis"],["changeover","Heizen / K\xFChlen"],["pump","Einspeise- / Vorschubpumpe (ohne Ventil)"]],f=>h({kind:f,...f==="pump"?{has_pump:!0,has_valve:!1}:{}}),{wide:!0})}
${d.kind!=="pump"?m`${D(t,"Pumpe vorhanden",Xn(d),f=>h({has_pump:f}))}${D(t,"Ventil vorhanden",Ka(d),f=>h({has_valve:f}))}`:_}
${d.kind!=="pump"?m`${D(t,"Pumpe vorhanden",Xn(d),f=>h({has_pump:f}))}${D(t,"Ventil vorhanden",Ao(d),f=>h({has_valve:f}))}`:_}
${Xn(d)?a("Pumpe",d.pump,f=>h({pump:f})):_}
${Ka(d)?a("Ventil",d.valve,f=>h({valve:f}),!0):_}
${Ao(d)?H(t,"Ventilbauart",d.valve_type??"mixing",[["mixing","Mischer (Dreiwegeventil)"],["two_way","Durchgangsventil (Zweiwege)"]],f=>h({valve_type:f}),{wide:!0}):_}
${Ao(d)?a("Ventil",d.valve,f=>h({valve:f}),!0):_}
${l("Vorlauf",d.flow,f=>h({flow:f}))}${l("R\xFCcklauf",d.return,f=>h({return:f}))}
${Xn(d)?l("Pumpenleistung (optional)",d.power,f=>h({power:f})):_}
${d.kind==="changeover"?m`${s("Umschaltung Heizen / K\xFChlen",d.mode_entity,[0,1],f=>h({mode_entity:f}))}${E(t,"K\xFChlbetrieb bei Wert",d.cooling_value??1,f=>h({cooling_value:Math.round(f)}),1)}`:_}
<button class="nf-link nf-wide nf-hydronic-remove" ?disabled=${!t.admin} @click=${()=>o({circuits:(r.circuits??[]).filter(f=>f.id!==d.id)})}>× Kreis entfernen</button>
</div></details>`};return m`<section class="nf-hydronic-form">
<div class="nf-form">${D(t,"Schwebende 3D-Kachel",r.card!==!1,d=>o({card:d}))}${Bt(t,e.pin_offset,d=>n({pin_offset:d}))}${S("Verkn\xFCpfe jeden Datenpunkt \xFCber den Objektbaum. Namen und Pfade schr\xE4nken die Auswahl nicht ein. Nicht verkn\xFCpfte Werte bleiben in der 3D-Kachel ausgeblendet. Das Bauteil \xF6ffnet beim Antippen seine Werte und Bedienung.","nf-wide")}</div>
${e.type==="heating_manifold"?m`${Pr(r.circuits??[],d=>d.id,u)}<button class="nf-btn nf-hydronic-add" title="Bis zu 32 Kreise" ?disabled=${!t.admin||(r.circuits?.length??0)>=32} @click=${()=>o({circuits:[...r.circuits??[],Wa(I("circuit"),`Kreis ${(r.circuits?.length??0)+1}`)]})}>+ Kreis hinzufügen</button>`:_}
${e.type==="heating_manifold"?m`${Pr(r.circuits??[],d=>d.id,u)}<button class="nf-btn nf-hydronic-add" title="Bis zu 32 Kreise" ?disabled=${!t.admin||(r.circuits?.length??0)>=32} @click=${()=>o({circuits:[...r.circuits??[],Va(I("circuit"),`Kreis ${(r.circuits?.length??0)+1}`)]})}>+ Kreis hinzufügen</button>`:_}
${e.type==="buffer_tank"?m`<div class="nf-form">${c}${S("Die sieben Startpl\xE4tze liegen von oben nach unten. H\xF6he 100 % liegt oben, 0 % unten. F\xFChlerpl\xE4tze k\xF6nnen erg\xE4nzt, entfernt und frei in der H\xF6he positioniert werden; die Anzeige sortiert sie von oben nach unten.","nf-wide")}</div>
${Pr([...r.sensors??[]].sort((d,p)=>p.level-d.level),d=>d.id,d=>{let p=h=>o({sensors:(r.sensors??[]).map(f=>f.id===d.id?{...f,...h}:f)});return m`<details class="nf-hydronic-probe" data-probe=${d.id}><summary>${d.name||"F\xFChler"} · ${Math.round(d.level*100)} %</summary><div class="nf-form">
${V(t,"Bezeichnung",d.name,h=>p({name:h}),{wide:!0,maxlength:100})}${l("Temperatur",d.entity,h=>p({entity:h}))}
@@ -1602,7 +1603,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${fk(e)&&o?m`${E(t,r("ceiling_here"),Ki(o,e),s=>i({ceiling_y:Math.abs(s-ht(o,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=${()=>i({ceiling_y:null})}>${r("height_auto")}</button>`:_}
${Og(t,e)!==null?m`<button class="nf-btn nf-field-btn" ?disabled=${!t.admin} title=${r("ceiling_slope_hint")} @click=${()=>i({ceiling_y:Og(t,e)})}>📐 ${r("ceiling_slope")}</button>`:_}
${S(r("ceiling_here_hint"),"nf-wide")}`:_}`}function Og(t,e){let n=t.floor;if(!n)return null;let r=Vr(t.doc,e.x,e.z);if(r===null)return null;let i=Math.round((r-n.elevation)*1e3)/1e3;return i>.5&&i<ht(n,e.x,e.z)-.02?i:null}var fk=t=>Hs.has(t.type)||G(t.type)?.mount==="ceiling";function mk(t,e,n){if(e.type==="stairs"&&e.stair)return _;if(e.type==="stairs")return m`${S(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:{..._t}})}>${t.t("stair_upgrade")}</button></div>`:_}`;if(e.type!=="stairwell")return _;let r=t.floor&&!t.floor.rooms.some(i=>i.points.length>=3&&nf(Ws(e),i.points));return m`${S(t.t("stairwell_hint"))}${r?m`<p class="nf-sub nf-pack-error">${t.t("stairwell_outside")}</p>`:_}`}function gk(t,e,n){if(!t.admin)return _;let r=t.t,i=!!e.entity&&e.entity!=="none"&&e.type!=="parking",o=t.doc.floors.filter(s=>s.id!==t.floor?.id);return m`<div class="nf-actions">
${S(r("ceiling_here_hint"),"nf-wide")}`:_}`}function Og(t,e){let n=t.floor;if(!n)return null;let r=Vr(t.doc,e.x,e.z);if(r===null)return null;let i=Math.round((r-n.elevation)*1e3)/1e3;return i>.5&&i<ht(n,e.x,e.z)-.02?i:null}var fk=t=>Ls.has(t.type)||G(t.type)?.mount==="ceiling";function mk(t,e,n){if(e.type==="stairs"&&e.stair)return _;if(e.type==="stairs")return m`${S(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:{..._t}})}>${t.t("stair_upgrade")}</button></div>`:_}`;if(e.type!=="stairwell")return _;let r=t.floor&&!t.floor.rooms.some(i=>i.points.length>=3&&nf(Vs(e),i.points));return m`${S(t.t("stairwell_hint"))}${r?m`<p class="nf-sub nf-pack-error">${t.t("stairwell_outside")}</p>`:_}`}function gk(t,e,n){if(!t.admin)return _;let r=t.t,i=!!e.entity&&e.entity!=="none"&&e.type!=="parking",o=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>
${i?m`<button class="nf-btn" title=${r("as_device_hint")} @click=${()=>n.toDevice(e)}>${r("as_device")}</button>`:_}
@@ -1633,10 +1634,10 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
${Yn(e.type)?Ig(t,e,o=>n.update(o)):i} ${e.type.endsWith(":sprinkler")?m`<div class="nf-form">${E(t,t.t("spray_reach"),e.spray??3,o=>n.update({spray:Math.min(15,Math.max(.5,o))}),.5,.5)}${S(t.t("spray_hint"),"nf-wide")}</div>`:_}
${Xc(e.type)?bk(t,e,n):_}
${G(e.type)?.pet?m`<div class="nf-form nf-links">${z(t,t.t("pet_room_sensor"),e.room_sensor??null,void 0,O(t.hass,o=>/^(sensor|device_tracker|input_select|select)\./.test(o)),o=>n.update({room_sensor:o&&o!=="none"?o:null}))}${S(t.t("pet_room_hint"),"nf-wide")}</div>`:_}
${Ds(e.type)?Mg(t,e,Ds(e.type),n):_} ${Ps(G(e.type))?Rg(t,e,n):_} ${e.type==="parking"?zg(t,e,n.packs,n):_}
${Is(e.type)?Mg(t,e,Is(e.type),n):_} ${Ds(G(e.type))?Rg(t,e,n):_} ${e.type==="parking"?zg(t,e,n.packs,n):_}
${e.type.startsWith("pack:nextfloor.fahrzeuge:")&&t.admin?m`<section>${S(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?_k(t,e,n):_} ${vk(t,e,n)} ${gk(t,e,n)}
</section>`}var wk=["door","window","opening","garage_door"],kk=/griff|handle|fenster|window|drehgriff/i;function xk(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 $k(t){let{hass:e}=t,n=o=>e?.states[o],r=o=>n(o)?.attributes.device_class,i=o=>o.startsWith("binary_sensor.")&&wk.includes(r(o)??"");return{covers:O(e,o=>o.startsWith("cover.")),positions:O(e,o=>lo(e,o)),contacts:O(e,o=>i(o)||me(o)&&Js(n(o))!==null),plainContacts:O(e,i),handles:O(e,o=>o.startsWith("binary_sensor.")?typeof n(o)?.attributes.window_state=="string":me(o)&&(Js(n(o))!==null||kk.test(`${o} ${B(e,o)}`))),numbers:O(e,me),locks:O(e,o=>o.startsWith("lock."))}}function Yl(t,e,n){if(!t.hass)return null;let r=structuredClone(t.doc.floors);for(let i of r)for(let o of i.openings)o.id===e.id&&(o[n]=null);return Ot(t.hass,r).get(e.id)?.[n]??null}var ut=t=>t==="none"?null:t;function Sk(t,e,n){let r=e.type==="door"?Cs:Ns,i=rn({type:e.type,style:null},n.isExterior(e)),o=e.style&&r.includes(e.style)?e.style:"",s=[["",t.t("style_auto",{style:t.t(`style_${i}`)})],...r.map(l=>[l,t.t(`style_${l}`)])];return H(t,t.t("opening_style"),o,s,l=>n.update({style:l||null}),{wide:!0})}function ql(t,e,n,r,i){return m`<label class="nf-field"
</section>`}var wk=["door","window","opening","garage_door"],kk=/griff|handle|fenster|window|drehgriff/i;function xk(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 $k(t){let{hass:e}=t,n=o=>e?.states[o],r=o=>n(o)?.attributes.device_class,i=o=>o.startsWith("binary_sensor.")&&wk.includes(r(o)??"");return{covers:O(e,o=>o.startsWith("cover.")),positions:O(e,o=>lo(e,o)),contacts:O(e,o=>i(o)||me(o)&&Qs(n(o))!==null),plainContacts:O(e,i),handles:O(e,o=>o.startsWith("binary_sensor.")?typeof n(o)?.attributes.window_state=="string":me(o)&&(Qs(n(o))!==null||kk.test(`${o} ${B(e,o)}`))),numbers:O(e,me),locks:O(e,o=>o.startsWith("lock."))}}function Yl(t,e,n){if(!t.hass)return null;let r=structuredClone(t.doc.floors);for(let i of r)for(let o of i.openings)o.id===e.id&&(o[n]=null);return Ot(t.hass,r).get(e.id)?.[n]??null}var ut=t=>t==="none"?null:t;function Sk(t,e,n){let r=e.type==="door"?Ns:Bs,i=rn({type:e.type,style:null},n.isExterior(e)),o=e.style&&r.includes(e.style)?e.style:"",s=[["",t.t("style_auto",{style:t.t(`style_${i}`)})],...r.map(l=>[l,t.t(`style_${l}`)])];return H(t,t.t("opening_style"),o,s,l=>n.update({style:l||null}),{wide:!0})}function ql(t,e,n,r,i){return m`<label class="nf-field"
>${t.t(r)}
<input
type="number"
@@ -1711,7 +1712,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
</div>
${S(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 ar(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 lr(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 cr(t,e,n,r){return m`<div class="nf-seg nf-dev-source">${e.map(([i,o])=>m`<button aria-pressed=${i===n} ?disabled=${!t.admin} @click=${()=>r(i)}>${o}</button>`)}</div>`}function Et(t,e){let{t:n,doc:r,hass:i}=t,o=n(`compass_${za(e,r.settings.north??0)}`);if(e.key===Ne)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 ${o} \xB7 ${K(i,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 ${o} \xB7 ${Math.round(e.pitch)}\xB0`}var Jl=(t,e)=>m`<div class="nf-h3row"><h3>${t}</h3>${e}</div>`,Ql=(t,e)=>m`<button class="nf-btn nf-back" @click=${e}>‹ ${t}</button>`,$n=(t,e)=>n=>Math.max(t,Math.min(e,ae(n)));function Fk(t,e){let{host:n,roof:r}=t,i=n.t,o=w=>r.patchSection(w),s=e.shape==="flat"||e.shape==="parapet",l=e.shape==="pent",a=e.axis==="x"?[i("roof_side_top"),i("roof_side_bottom")]:[i("roof_side_left"),i("roof_side_right")],[c,u]=e.flip?[a[1],a[0]]:a,d=!!n.doc.settings.lock_plan,p=(w,x,k,M=.05,A=0)=>E(n,w,x,T=>k(Math.max(A,ae(T))),M,A),h=[...n.doc.floors].filter(w=>w.rooms.length>0).sort((w,x)=>x.elevation-w.elevation),f=wa(n.doc,e)?.id,g=w=>{let x=n.doc.floors.find(A=>A.id===w);if(!x)return;let k=ae(x.elevation+x.height),M=k-e.base;o({base:k,eave_a:ae(e.eave_a+M),eave_b:ae(e.eave_b+M)})},b=d?m`<button class="nf-btn nf-fix" aria-pressed="true" title=${i("lock_plan_hint")} @click=${()=>t.toggleLockPlan()}>🔒 ${i("plan_locked")}</button>`:lr(n,!!e.locked,()=>o({locked:!e.locked})),y=cu.map(w=>[w,i(`roof_shape_${w}`)]),v=(w,x)=>m`<button class="nf-btn" title=${i("roof_dormer_hint")} @click=${()=>r.addDormer(w)}>+ ${i("roof_dormer")} ${x}</button>`;return m`${Ql(i("roof_sections"),()=>r.sectionId=null)}
</section>`}function ar(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 lr(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 cr(t,e,n,r){return m`<div class="nf-seg nf-dev-source">${e.map(([i,o])=>m`<button aria-pressed=${i===n} ?disabled=${!t.admin} @click=${()=>r(i)}>${o}</button>`)}</div>`}function Et(t,e){let{t:n,doc:r,hass:i}=t,o=n(`compass_${Pa(e,r.settings.north??0)}`);if(e.key===Ne)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 ${o} \xB7 ${K(i,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 ${o} \xB7 ${Math.round(e.pitch)}\xB0`}var Jl=(t,e)=>m`<div class="nf-h3row"><h3>${t}</h3>${e}</div>`,Ql=(t,e)=>m`<button class="nf-btn nf-back" @click=${e}>‹ ${t}</button>`,$n=(t,e)=>n=>Math.max(t,Math.min(e,ae(n)));function Fk(t,e){let{host:n,roof:r}=t,i=n.t,o=w=>r.patchSection(w),s=e.shape==="flat"||e.shape==="parapet",l=e.shape==="pent",a=e.axis==="x"?[i("roof_side_top"),i("roof_side_bottom")]:[i("roof_side_left"),i("roof_side_right")],[c,u]=e.flip?[a[1],a[0]]:a,d=!!n.doc.settings.lock_plan,p=(w,x,k,M=.05,A=0)=>E(n,w,x,T=>k(Math.max(A,ae(T))),M,A),h=[...n.doc.floors].filter(w=>w.rooms.length>0).sort((w,x)=>x.elevation-w.elevation),f=ka(n.doc,e)?.id,g=w=>{let x=n.doc.floors.find(A=>A.id===w);if(!x)return;let k=ae(x.elevation+x.height),M=k-e.base;o({base:k,eave_a:ae(e.eave_a+M),eave_b:ae(e.eave_b+M)})},b=d?m`<button class="nf-btn nf-fix" aria-pressed="true" title=${i("lock_plan_hint")} @click=${()=>t.toggleLockPlan()}>🔒 ${i("plan_locked")}</button>`:lr(n,!!e.locked,()=>o({locked:!e.locked})),y=cu.map(w=>[w,i(`roof_shape_${w}`)]),v=(w,x)=>m`<button class="nf-btn" title=${i("roof_dormer_hint")} @click=${()=>r.addDormer(w)}>+ ${i("roof_dormer")} ${x}</button>`;return m`${Ql(i("roof_sections"),()=>r.sectionId=null)}
<section>
${ar(t)}
${Jl(`${e.dormer?i("roof_dormer"):i("roof_section")} ${Pf(n.doc.settings.roof.sections??[],e.id)}`,n.admin?b:_)}
@@ -1863,7 +1864,7 @@ ${o}`}else i=op(s)}}catch(s){let l=s.message,a={not_json:"import_error_not_json"
<div class="nf-form">${Lk(t,e)}</div>
${S(i("solar_string_hint"))} ${S(i("solar_form_hint"))}
${n.admin?J(m`<button class="nf-btn" ?disabled=${!l} @click=${()=>l&&o({...jn(l,e.id),portrait:e.portrait})}>${i("solar_fit")}</button>`,m`<button class="nf-btn nf-danger" @click=${()=>r.removeField()}>${i("delete")}</button>`):_}
</section>`}var qg=t=>Math.round(t*1e3)/1e3,cs=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=ka(r,()=>I("roof")))}),this.sectionId=null)}addSection(e,n){if(!this.admin)return;let r=Tf(this.doc,e,n);this.ctx.host.change(i=>{i.settings.roof.type="custom",i.settings.roof.sections=[...i.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,i=fa(e.rooms,e.walls??[],n,r);if(!i)return;let o=i.map(([s,l])=>[qg(s),qg(l)]);this.patchSection({shape:"flat",points:o,...Kt(o)})}addDormer(e){let n=this.section;if(!n||!this.admin)return;let r=ma(n,e,I("roof"));this.ctx.host.change(i=>{i.settings.roof.sections=[...i.settings.roof.sections??[],r]}),this.sectionId=r.id}patchSection(e){let n=this.sectionSel;!n||!this.admin||this.ctx.host.change(r=>{let i=r.settings.roof.sections?.find(o=>o.id===n);i&&Object.assign(i,e)})}removeCorner(e){let n=this.sectionSel;!n||!this.admin||this.ctx.host.change(r=>{let i=r.settings.roof.sections?.find(o=>o.id===n);i&&If(i,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=zf(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=ni(Z(this.doc).filter(i=>!i.flat),e)??Z(this.doc)[0];if(!n)return;let r=ei(n,I("rwin"));this.ctx.host.change(i=>i.settings.roof.windows=[...i.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 i=r.settings.roof.windows?.find(s=>s.id===n);if(!i)return;Object.assign(i,e);let o=Z(r).find(s=>s.key===i.face);o&&Object.assign(i,mt(o,mn(i)))})}removeWindow(){let e=this.windowSel;!e||!this.admin||(this.ctx.host.change(n=>n.settings.roof.windows=(n.settings.roof.windows??[]).filter(r=>r.id!==e)),this.windowId=null)}addChimney(){if(!this.admin)return;let e=Z(this.doc),n=e.find(i=>!i.flat)??e[0];if(!n)return;let r=ti(n,I("chim"));this.ctx.host.change(i=>i.settings.roof.chimneys=[...i.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 i=r.settings.roof.chimneys?.find(s=>s.id===n);if(!i)return;Object.assign(i,e);let o=Z(r).find(s=>s.key===i.face);o&&Object.assign(i,mt(o,$t(i,o)))})}removeChimney(){let e=this.chimneySel;!e||!this.admin||(this.ctx.host.change(n=>n.settings.roof.chimneys=(n.settings.roof.chimneys??[]).filter(r=>r.id!==e)),this.chimneyId=null)}addField(){if(!this.admin)return;let e=Z(this.doc),n=new Set((this.settings.solar??[]).map(o=>o.face)),r=this.doc.settings.north??0,i=ni(e.filter(o=>!n.has(o.key)),r)??ni(e,r);i&&(this.appendField(jn(i,I("pv"))),this.sectionSel=null)}addWallField(){let e=this.ctx.floorId()??this.doc.floors[0]?.id,n=this.admin&&e?Ea(this.doc,I("pv"),e):null;n&&this.appendField(n)}addGroundField(){this.admin&&this.appendField(Jr(this.doc,I("pv")))}appendField(e){this.ctx.host.change(n=>n.settings.roof.solar=[...n.settings.roof.solar??[],e]),this.solarId=e.id}selectField(e){this.fieldSel=e,this.sectionSel=null;let n=this.settings.solar?.find(r=>r.id===e);n?.face.startsWith("wall:")&&this.ctx.setFloorId(n.face.split(":")[1]),this.ctx.refresh()}patchField(e){this.editField((n,r)=>{Object.assign(n,e);let i=Se(r,n);i&&Object.assign(n,mt(i,n))})}toggleCellLine truncated
</section>`}var qg=t=>Math.round(t*1e3)/1e3,us=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=xa(r,()=>I("roof")))}),this.sectionId=null)}addSection(e,n){if(!this.admin)return;let r=Tf(this.doc,e,n);this.ctx.host.change(i=>{i.settings.roof.type="custom",i.settings.roof.sections=[...i.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,i=ma(e.rooms,e.walls??[],n,r);if(!i)return;let o=i.map(([s,l])=>[qg(s),qg(l)]);this.patchSection({shape:"flat",points:o,...Kt(o)})}addDormer(e){let n=this.section;if(!n||!this.admin)return;let r=ga(n,e,I("roof"));this.ctx.host.change(i=>{i.settings.roof.sections=[...i.settings.roof.sections??[],r]}),this.sectionId=r.id}patchSection(e){let n=this.sectionSel;!n||!this.admin||this.ctx.host.change(r=>{let i=r.settings.roof.sections?.find(o=>o.id===n);i&&Object.assign(i,e)})}removeCorner(e){let n=this.sectionSel;!n||!this.admin||this.ctx.host.change(r=>{let i=r.settings.roof.sections?.find(o=>o.id===n);i&&If(i,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=zf(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=ni(Z(this.doc).filter(i=>!i.flat),e)??Z(this.doc)[0];if(!n)return;let r=ei(n,I("rwin"));this.ctx.host.change(i=>i.settings.roof.windows=[...i.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 i=r.settings.roof.windows?.find(s=>s.id===n);if(!i)return;Object.assign(i,e);let o=Z(r).find(s=>s.key===i.face);o&&Object.assign(i,mt(o,mn(i)))})}removeWindow(){let e=this.windowSel;!e||!this.admin||(this.ctx.host.change(n=>n.settings.roof.windows=(n.settings.roof.windows??[]).filter(r=>r.id!==e)),this.windowId=null)}addChimney(){if(!this.admin)return;let e=Z(this.doc),n=e.find(i=>!i.flat)??e[0];if(!n)return;let r=ti(n,I("chim"));this.ctx.host.change(i=>i.settings.roof.chimneys=[...i.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 i=r.settings.roof.chimneys?.find(s=>s.id===n);if(!i)return;Object.assign(i,e);let o=Z(r).find(s=>s.key===i.face);o&&Object.assign(i,mt(o,$t(i,o)))})}removeChimney(){let e=this.chimneySel;!e||!this.admin||(this.ctx.host.change(n=>n.settings.roof.chimneys=(n.settings.roof.chimneys??[]).filter(r=>r.id!==e)),this.chimneyId=null)}addField(){if(!this.admin)return;let e=Z(this.doc),n=new Set((this.settings.solar??[]).map(o=>o.face)),r=this.doc.settings.north??0,i=ni(e.filter(o=>!n.has(o.key)),r)??ni(e,r);i&&(this.appendField(jn(i,I("pv"))),this.sectionSel=null)}addWallField(){let e=this.ctx.floorId()??this.doc.floors[0]?.id,n=this.admin&&e?Aa(this.doc,I("pv"),e):null;n&&this.appendField(n)}addGroundField(){this.admin&&this.appendField(Jr(this.doc,I("pv")))}appendField(e){this.ctx.host.change(n=>n.settings.roof.solar=[...n.settings.roof.solar??[],e]),this.solarId=e.id}selectField(e){this.fieldSel=e,this.sectionSel=null;let n=this.settings.solar?.find(r=>r.id===e);n?.face.startsWith("wall:")&&this.ctx.setFloorId(n.face.split(":")[1]),this.ctx.refresh()}patchField(e){this.editField((n,r)=>{Object.assign(n,e);let i=Se(r,n);i&&Object.assign(n,mt(i,n))})}toggleCellLine truncated
<svg width="12" height="12" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M3 2v15h15M5 13l4-5 4 2 4-6"/></svg>
</button>${this.error?m`<span role="alert">${this.error}</span>`:_}`}static styles=ee`:host{position:relative;display:inline-flex;flex:0 0 18px;width:18px;height:18px;vertical-align:middle;margin-left:3px;font-weight:normal;line-height:0}button{display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;width:18px;height:18px;padding:2px;border:0;border-radius:3px;background:transparent;color:var(--nf-accent,#40c8ff);opacity:.8;cursor:pointer}svg{display:block;flex-shrink:0}button:hover,button:focus-visible{opacity:1;background:#40c8ff18}button:focus-visible{outline:1px solid currentColor;outline-offset:1px}button:disabled{opacity:.4}span{position:absolute;right:0;top:22px;z-index:10;box-sizing:border-box;width:200px;padding:8px;border:1px solid #ff9b9b50;border-radius:6px;background:var(--nf-chrome-solid,#1c1c1c);font:12px/1.4 system-ui;color:#ff9b9b;white-space:normal}`};customElements.get("nf-trend-button")||customElements.define("nf-trend-button",sc);function s_(t,e,n=""){let r=oc(t,e);return r.length?m`<nf-trend-button .hass=${t} .ids=${r} .label=${n}></nf-trend-button>`:_}var ac=class extends Y{static properties={hass:{attribute:!1},readings:{attribute:!1}};constructor(){super(),this.readings=[]}render(){return m`${wt.filter(e=>this.readings.some(n=>n.kind===e)).map(e=>m`<section aria-label=${St[e]}>
<h4>${Jn[e]} ${St[e]}</h4>
@@ -1881,7 +1882,7 @@ ${n.sources.map(r=>this.hass.states[r]?.attributes.symcon_path||this.hass.states
.reading span { color:var(--nf-muted,#aaa); }
b { white-space:nowrap; font-variant-numeric:tabular-nums; }
small { font-size:.85em; }
`};customElements.get("nf-utility-report")||customElements.define("nf-utility-report",ac);var Gk=/garage|carport|keller|cellar|basement|technik|heizung|heizraum|boiler|utility|werkstatt|schuppen|shed|dachboden|attic/i,Ei=t=>t.living??!Gk.test(t.name),Zk=.1,a_=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 lc(t,e,n,r,i=Zk){if(n.points.length<3)return{roomId:n.id,floor:0,living:0,low:0};let o=a_(n.points),s=r.filter(f=>{let g=a_(f.footprint);return g.x1>=o.x0&&g.x0<=o.x1&&g.z1>=o.z0&&g.z0<=o.z1}),l=e.elevation+(n.ceiling!=null&&n.ceiling>0?n.ceiling:e.height),a=(t.settings.roof?.sections??[]).some(f=>!f.open),c=Ls(n),u=0,d=0,p=0;for(let f=o.x0+i/2;f<o.x1;f+=i)for(let g=o.z0+i/2;g<o.z1;g+=i){if(!C([f,g],n.points)||s.some(v=>C([f,g],v.footprint)))continue;let b=a?Vr(t,f,g):null,y=Math.min(l,b??1/0)-e.elevation-c;y>=2?u++:y>=1?d++:p++}let h=i*i;return{roomId:n.id,floor:(u+d+p)*h,living:Ei(n)?(u+d/2)*h:0,low:(d+p)*h}}var l_=new WeakMap;function Ai(t,e){if(e.layer)return[];let n=l_.get(e);if(n&&n.roof===t.settings.roof)return n.areas;let r=qk(t,e);return l_.set(e,{roof:t.settings.roof,areas:r}),r}function qk(t,e){let n=fe(e.rooms,{exterior:t.settings.wall_exterior,interior:t.settings.wall_interior},e.walls??[]).walls;return e.rooms.map(r=>lc(t,e,r,n))}var hr=t=>t.reduce((e,n)=>({floor:e.floor+n.floor,living:e.living+n.living,low:e.low+n.low}),{floor:0,living:0,low:0});function c_(t,e,n){let r=t.floors.length,i=e?.name??(r===0?n.first:n.next(r));return{...Ve(I("floor"),i,xu(t.floors,e?.level)),ha_floor:e?.floor_id??null}}function cc(t,e){let n=t.findIndex(i=>i.elevation>e.elevation),r=n<0?t.length:n;return[...t.slice(0,r),e,...t.slice(r)]}function u_(t,e,n){let r=t.findIndex(s=>s.id===e),i=r+n;if(r<0||i<0||i>=t.length)return[...t];let o=[...t];return[o[r],o[i]]=[o[i],o[r]],o}function d_(t,e){let n=new Set(t.floors.map(r=>r.ha_floor));return Object.values(e??{}).filter(r=>!n.has(r.floor_id)).sort((r,i)=>(r.level??99)-(i.level??99)||r.name.localeCompare(i.name))}function pr(t,e,n){if(!e.ha_floor)return[];let r=new Set(t.floors.flatMap(i=>i.rooms.map(o=>o.area_id)));return Object.values(n??{}).filter(i=>i.floor_id===e.ha_floor&&!r.has(i.area_id)).sort((i,o)=>i.name.localeCompare(o.name))}function h_(t,e,n){return Object.values(n??{}).filter(r=>r.floor_id===e.ha_floor||!t.floors.some(i=>i.ha_floor===r.floor_id))}function p_(t,e,n,r,i=I){let o=structuredClone(e),s=t.floors.reduce((u,d)=>Math.max(u,d.elevation+d.height),e.elevation+e.height),l=new Map,a=new Map;o.id=i("floor"),o.name=n,o.elevation=Math.round(s*1e3)/1e3,o.ha_floor=null,o.start_view=null,o.rooms=o.rooms.map(u=>{let d=i("room");return l.set(u.id,d),{...u,id:d,area_id:null}}),o.walls=(o.walls??[]).map(u=>{let d=i("wall");return a.set(u.id,d),{...u,id:d}}),o.openings=o.openings.filter(u=>l.has(u.room_id)).map(u=>({...u,id:i("opening"),room_id:l.get(u.room_id),wall:u.wall?a.get(u.wall)??null:u.wall}));let c=new Set(["meter","inverter","home_battery","wallbox","grid_point"]);return o.furniture=r.furniture?o.furniture.filter(u=>!c.has(u.type)).map(u=>Qk({...u,id:i("furniture")})):[],o.placements=r.devices?o.placements:[],o.outdoor=r.outdoor?o.outdoor.map(u=>({...u,id:i("outdoor")})):[],o}var Yk=["entity","power","fan_entity","room_sensor"],Xk=["door_left","door_right","soc","charge","export","status","temp_entity","temp_entity2","state_entity","state_entity2","color_entity","care_entity","cover_entity","type_entity","parent_meter","car","tap"],Jk=["gang_entities","pictures","types","meter_floors","show_when","extra_lights"];function Qk(t){let e={...t};for(let n of Yk)(n==="entity"||n==="power"||e[n]!=null)&&(e[n]="none");for(let n of Xk)e[n]!=null&&(e[n]=null);for(let n of Jk)delete e[n];return e}function f_(t,e,n,r){let i=t.floors.find(a=>a.id===e),o=t.floors.find(a=>a.id===r);if(!i||!o||i===o)return!1;let s=i.furniture.findIndex(a=>a.id===n);if(s<0)return!1;let[l]=i.furniture.splice(s,1);return o.furniture.push(l),!0}function ex(t,e,n){if(e.layer||!e.rooms.length)return _;let r=t.t,i=hr(Ai(t.doc,e)).living,o=hr(t.doc.floors.flatMap(s=>Ai(t.doc,s))).living;return m`<p class="nf-sub nf-wide" title=${r("living_area_hint")}>
`};customElements.get("nf-utility-report")||customElements.define("nf-utility-report",ac);var Gk=/garage|carport|keller|cellar|basement|technik|heizung|heizraum|boiler|utility|werkstatt|schuppen|shed|dachboden|attic/i,Ei=t=>t.living??!Gk.test(t.name),Zk=.1,a_=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 lc(t,e,n,r,i=Zk){if(n.points.length<3)return{roomId:n.id,floor:0,living:0,low:0};let o=a_(n.points),s=r.filter(f=>{let g=a_(f.footprint);return g.x1>=o.x0&&g.x0<=o.x1&&g.z1>=o.z0&&g.z0<=o.z1}),l=e.elevation+(n.ceiling!=null&&n.ceiling>0?n.ceiling:e.height),a=(t.settings.roof?.sections??[]).some(f=>!f.open),c=Cs(n),u=0,d=0,p=0;for(let f=o.x0+i/2;f<o.x1;f+=i)for(let g=o.z0+i/2;g<o.z1;g+=i){if(!C([f,g],n.points)||s.some(v=>C([f,g],v.footprint)))continue;let b=a?Vr(t,f,g):null,y=Math.min(l,b??1/0)-e.elevation-c;y>=2?u++:y>=1?d++:p++}let h=i*i;return{roomId:n.id,floor:(u+d+p)*h,living:Ei(n)?(u+d/2)*h:0,low:(d+p)*h}}var l_=new WeakMap;function Ai(t,e){if(e.layer)return[];let n=l_.get(e);if(n&&n.roof===t.settings.roof)return n.areas;let r=qk(t,e);return l_.set(e,{roof:t.settings.roof,areas:r}),r}function qk(t,e){let n=fe(e.rooms,{exterior:t.settings.wall_exterior,interior:t.settings.wall_interior},e.walls??[]).walls;return e.rooms.map(r=>lc(t,e,r,n))}var hr=t=>t.reduce((e,n)=>({floor:e.floor+n.floor,living:e.living+n.living,low:e.low+n.low}),{floor:0,living:0,low:0});function c_(t,e,n){let r=t.floors.length,i=e?.name??(r===0?n.first:n.next(r));return{...Ve(I("floor"),i,xu(t.floors,e?.level)),ha_floor:e?.floor_id??null}}function cc(t,e){let n=t.findIndex(i=>i.elevation>e.elevation),r=n<0?t.length:n;return[...t.slice(0,r),e,...t.slice(r)]}function u_(t,e,n){let r=t.findIndex(s=>s.id===e),i=r+n;if(r<0||i<0||i>=t.length)return[...t];let o=[...t];return[o[r],o[i]]=[o[i],o[r]],o}function d_(t,e){let n=new Set(t.floors.map(r=>r.ha_floor));return Object.values(e??{}).filter(r=>!n.has(r.floor_id)).sort((r,i)=>(r.level??99)-(i.level??99)||r.name.localeCompare(i.name))}function pr(t,e,n){if(!e.ha_floor)return[];let r=new Set(t.floors.flatMap(i=>i.rooms.map(o=>o.area_id)));return Object.values(n??{}).filter(i=>i.floor_id===e.ha_floor&&!r.has(i.area_id)).sort((i,o)=>i.name.localeCompare(o.name))}function h_(t,e,n){return Object.values(n??{}).filter(r=>r.floor_id===e.ha_floor||!t.floors.some(i=>i.ha_floor===r.floor_id))}function p_(t,e,n,r,i=I){let o=structuredClone(e),s=t.floors.reduce((u,d)=>Math.max(u,d.elevation+d.height),e.elevation+e.height),l=new Map,a=new Map;o.id=i("floor"),o.name=n,o.elevation=Math.round(s*1e3)/1e3,o.ha_floor=null,o.start_view=null,o.rooms=o.rooms.map(u=>{let d=i("room");return l.set(u.id,d),{...u,id:d,area_id:null}}),o.walls=(o.walls??[]).map(u=>{let d=i("wall");return a.set(u.id,d),{...u,id:d}}),o.openings=o.openings.filter(u=>l.has(u.room_id)).map(u=>({...u,id:i("opening"),room_id:l.get(u.room_id),wall:u.wall?a.get(u.wall)??null:u.wall}));let c=new Set(["meter","inverter","home_battery","wallbox","grid_point"]);return o.furniture=r.furniture?o.furniture.filter(u=>!c.has(u.type)).map(u=>Qk({...u,id:i("furniture")})):[],o.placements=r.devices?o.placements:[],o.outdoor=r.outdoor?o.outdoor.map(u=>({...u,id:i("outdoor")})):[],o}var Yk=["entity","power","fan_entity","room_sensor"],Xk=["door_left","door_right","soc","charge","export","status","temp_entity","temp_entity2","state_entity","state_entity2","color_entity","care_entity","cover_entity","type_entity","parent_meter","car","tap"],Jk=["gang_entities","pictures","types","meter_floors","show_when","extra_lights"];function Qk(t){let e={...t};for(let n of Yk)(n==="entity"||n==="power"||e[n]!=null)&&(e[n]="none");for(let n of Xk)e[n]!=null&&(e[n]=null);for(let n of Jk)delete e[n];return e}function f_(t,e,n,r){let i=t.floors.find(a=>a.id===e),o=t.floors.find(a=>a.id===r);if(!i||!o||i===o)return!1;let s=i.furniture.findIndex(a=>a.id===n);if(s<0)return!1;let[l]=i.furniture.splice(s,1);return o.furniture.push(l),!0}function ex(t,e,n){if(e.layer||!e.rooms.length)return _;let r=t.t,i=hr(Ai(t.doc,e)).living,o=hr(t.doc.floors.flatMap(s=>Ai(t.doc,s))).living;return m`<p class="nf-sub nf-wide" title=${r("living_area_hint")}>
${r(t.doc.floors.length>1?"living_area_floor_house":"living_area_floor",{floor:ze(t.hass,i),house:ze(t.hass,o)})}
</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 tx(t,e,n,r){let i=d_(t.doc,t.hass?.floors),o=()=>i.length>0?e.floorMenu=!e.floorMenu:n.addFloor(null);return m`<div class="nf-floor-list">
@@ -1943,14 +1944,14 @@ ${n.sources.map(r=>this.hass.states[r]?.attributes.symcon_path||this.hass.states
</div>`}function m_(t,e,n,r,i){return m`<section>
<h3>${t.t("floors")}</h3>
${tx(t,e,n,i)} ${r?ox(t,e,n,r):_}
</section>`}var g_=["lamp_downlight","lamp_spot","lamp_panel","lamp_ceiling"];function __(t,e){let n=de(t.points);return{type:"lamp_downlight",rows:Math.max(1,Math.round((n.z1-n.z0)/1.2)),cols:Math.max(1,Math.round((n.x1-n.x0)/1.2)),entity:e[0]??null}}function ms(t,e){let[n,r,i]=nt[e.type];return Eu(t,e.rows,e.cols).map(([o,s])=>({id:I("furniture"),type:e.type,x:o,z:s,rotation:0,w:n,d:r,h:i,variant:null,entity:e.entity??"none",power:null}))}var uc=t=>Math.max(1,Math.min(12,Math.round(t)));var sx=globalThis.__nfAnnounced??new Set;globalThis.__nfAnnounced=sx;var b_=/^(media_player|assist_satellite)\./;function ax(t,e){return e?Object.values(t.entities??{}).filter(n=>!n.hidden&&(n.area_id??(n.device_id?t.devices?.[n.device_id]?.area_id:null))===e).map(n=>n.entity_id):[]}function y_(t,e){let n=t.states[e];return!n||n.state==="unavailable"?!1:e.startsWith("notify.")?t.entities?.[e]?.platform==="alexa_devices"&&e.endsWith("_announce"):n.state==="off"||n.state==="unknown"?!1:n.attributes.device_class!=="tv"}function v_(t,e,n){if(n.announce_speaker==="none")return null;if(n.announce_speaker)return n.announce_speaker;if(e&&n.points.length>=3){let o=[...e.placements.filter(s=>b_.test(s.entity_id)).map(s=>({id:s.entity_id,x:s.x,z:s.z})),...e.furniture.filter(s=>s.entity&&b_.test(s.entity)).map(s=>({id:s.entity,x:s.x,z:s.z}))].find(s=>C([s.x,s.z],n.points)&&y_(t,s.id));if(o)return o.id}let r=ax(t,n.area_id);for(let i of["assist_satellite.","notify.","media_player."]){let o=r.filter(s=>s.startsWith(i)&&y_(t,s)).sort()[0];if(o)return o}return null}function w_(t,e,n){return e.rooms.length===0?_:m`<section>
</section>`}var g_=["lamp_downlight","lamp_spot","lamp_panel","lamp_ceiling"];function __(t,e){let n=de(t.points);return{type:"lamp_downlight",rows:Math.max(1,Math.round((n.z1-n.z0)/1.2)),cols:Math.max(1,Math.round((n.x1-n.x0)/1.2)),entity:e[0]??null}}function gs(t,e){let[n,r,i]=nt[e.type];return Eu(t,e.rows,e.cols).map(([o,s])=>({id:I("furniture"),type:e.type,x:o,z:s,rotation:0,w:n,d:r,h:i,variant:null,entity:e.entity??"none",power:null}))}var uc=t=>Math.max(1,Math.min(12,Math.round(t)));var sx=globalThis.__nfAnnounced??new Set;globalThis.__nfAnnounced=sx;var b_=/^(media_player|assist_satellite)\./;function ax(t,e){return e?Object.values(t.entities??{}).filter(n=>!n.hidden&&(n.area_id??(n.device_id?t.devices?.[n.device_id]?.area_id:null))===e).map(n=>n.entity_id):[]}function y_(t,e){let n=t.states[e];return!n||n.state==="unavailable"?!1:e.startsWith("notify.")?t.entities?.[e]?.platform==="alexa_devices"&&e.endsWith("_announce"):n.state==="off"||n.state==="unknown"?!1:n.attributes.device_class!=="tv"}function v_(t,e,n){if(n.announce_speaker==="none")return null;if(n.announce_speaker)return n.announce_speaker;if(e&&n.points.length>=3){let o=[...e.placements.filter(s=>b_.test(s.entity_id)).map(s=>({id:s.entity_id,x:s.x,z:s.z})),...e.furniture.filter(s=>s.entity&&b_.test(s.entity)).map(s=>({id:s.entity,x:s.x,z:s.z}))].find(s=>C([s.x,s.z],n.points)&&y_(t,s.id));if(o)return o.id}let r=ax(t,n.area_id);for(let i of["assist_satellite.","notify.","media_player."]){let o=r.filter(s=>s.startsWith(i)&&y_(t,s)).sort()[0];if(o)return o}return null}function w_(t,e,n){return e.rooms.length===0?_:m`<section>
<h3>${t.t("rooms")}</h3>
<div class="nf-room-list">
${e.rooms.map(r=>m`<button class="nf-row" @click=${()=>n.select(r.id)}>
<span>${r.name}</span><span class="nf-muted">${ze(t.hass,xe(r.points))}</span>
</button>`)}
</div>
</section>`}function lx(t,e,n,r){let i=e.spots,o=c=>e.spots={...i,...c},s=ms(n,i).length,l=O(t.hass,c=>/^(light|switch|input_boolean)\./.test(c)),a=g_.map(c=>[c,t.t(`furn_${c}`)]);return m`<div class="nf-form nf-spot-form">
</section>`}function lx(t,e,n,r){let i=e.spots,o=c=>e.spots={...i,...c},s=gs(n,i).length,l=O(t.hass,c=>/^(light|switch|input_boolean)\./.test(c)),a=g_.map(c=>[c,t.t(`furn_${c}`)]);return m`<div class="nf-form nf-spot-form">
${H(t,t.t("spots_type"),i.type,a,c=>o({type:c}),{wide:!0})}
${E(t,t.t("spots_cols"),i.cols,c=>o({cols:uc(c)}),1,1)}
${E(t,t.t("spots_rows"),i.rows,c=>o({rows:uc(c)}),1,1)}
@@ -4026,7 +4027,7 @@ ${n.sources.map(r=>this.hass.states[r]?.attributes.symcon_path||this.hass.states
.nf-hydronic-form summary { cursor:pointer; font-weight:500; }
.nf-hydronic-form details[open]>.nf-form { margin-top:9px; }
.nf-hydronic-control { border-top:1px solid var(--nf-line); padding-top:7px; }
`;var x_=["cabinet","shelf","lamp","device"],Sn="own_studio";var px={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"}},hc=(t,e)=>({kind:t,name:e,...px[t]}),$_=(t,e)=>({...hc(e,t.name),body:t.body,front:t.front}),fr=(t,e,n)=>Math.min(n,Math.max(e,Number.isFinite(t)?t:e)),mr=t=>Math.round(t*1e4)/1e4;function pc(t){return{...t,name:t.name.trim().slice(0,60),w:fr(Math.round(t.w),5,400),d:fr(Math.round(t.d),2,200),h:fr(Math.round(t.h),2,300),doors:fr(Math.round(t.doors),0,6),drawers:fr(Math.round(t.drawers),0,6),shelves:fr(Math.round(t.shelves),0,12)}}function ce(t,e,n,r,i,o,s,l,a={}){let[c,u,d]=t,p=(x,k,M)=>{let A=Math.max(-M,x-k/2),T=Math.min(M,x+k/2);return T-A<1e-4?[Math.max(-M,Math.min(M,x)),.001*M*2]:[(A+T)/2,T-A]},[h,f]=p(e,r,c/2),[g,b]=p(n,i,u/2),y=Math.max(0,Math.min(d*.999,o)),v=Math.max(d*.001,Math.min(d-y,s)),w=x=>mr(Math.max(.001,Math.min(1,x)));return{shape:"box",x:mr(h/c),z:mr(g/u),w:w(f/c),d:w(b/u),y:mr(y/d),h:w(v/d),color:l,...a}}function S_(t,e,n){let[r,i,o]=t;if(e==="legs"){let s=Math.min(.1,o*.25),l=Math.min(.04,r/6,i/6);for(let[a,c]of[[-1,-1],[1,-1],[-1,1],[1,1]])n.push(ce(t,a*(r/2-l),c*(i/2-l),l,l,0,s,"metal"));return s}if(e==="plinth"){let s=Math.min(.08,o*.2);return n.push(ce(t,0,-.02,r-.02,i-.04,0,s,"dark")),s}return 0}function fx(t,e){let[n,r,i]=e,o=[],s=S_(e,t.base,o),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,u=r-c-a,d=-r/2+u/2,p=i-s;if(!l){let v=Math.min(.018,n/10,p/10);o.push(ce(e,-n/2+v/2,0,v,r,s,p,t.body,{edges:!0})),o.push(ce(e,n/2-v/2,0,v,r,s,p,t.body,{edges:!0})),o.push(ce(e,0,-r/2+.005,n-2*v,.01,s,p,t.body));for(let w=0;w<=t.shelves+1;w++)o.push(ce(e,0,.005,n-2*v,r-.01,s+(p-v)*w/(t.shelves+1),v,t.front,{edges:"faint"}));return o}o.push(ce(e,0,d,n,u,s,p,t.body,{edges:!0}));let h=.004,f=-r/2+u+c/2,g=t.doors>0?Math.min(.18,Math.max(.08,(p-.3)/Math.max(1,t.drawers))):p/t.drawers,b=s+(t.drawers>0?g*t.drawers:0),y=(v,w,x)=>{if(t.handle==="none")return;let k=r/2-a/2;t.handle==="knob"?o.push(ce(e,v,k,.025,a,w-.0125,.025,"metal")):x?o.push(ce(e,v,k,.015,a,w-.08,.16,"metal")):o.push(ce(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;o.push(ce(e,0,f,n-2*h,c,w+h,g-2*h,t.front,{edges:"faint"})),y(0,w+g*(t.drawers===1&&t.doors===0?.5:.7),!1)}if(t.doors>0){let v=n/t.doors,w=i-b;for(let x=0;x<t.doors;x++){let k=-n/2+v*(x+.5);o.push(ce(e,k,f,v-2*h,c,b+h,w-2*h,t.front,{edges:"faint"}));let M=t.doors===1||x%2===0?1:-1,A=b+w*(i>1.2?.45:.8);y(k+M*(v/2-.04),Math.min(A,i-.1),!0)}}return o}function mx(t,e){let[n,r,i]=e,o=Math.min(.02,n/10,i/10),s=[ce(e,-n/2+o/2,0,o,r,0,i,t.body,{edges:!0}),ce(e,n/2-o/2,0,o,r,0,i,t.body,{edges:!0})];t.back&&s.push(ce(e,0,-r/2+.005,n-2*o,.01,0,i,t.body));let l=t.shelves+2;for(let a=0;a<l;a++)s.push(ce(e,0,t.back?.005:0,n-2*o,t.back?r-.01:r,(i-o)*a/(l-1),o,t.front,{edges:!0}));return s}function gx(t,e){let[n,r,i]=e,o=Math.min(n,r),s=(a,c,u,d,p,h,f={})=>({...ce(e,a,c,u,u,d,p,h,f),shape:"cyl"}),l=(a,c,u)=>({...ce(e,0,0,o,o,a,c,t.front,{glow:!0,edges:"faint"}),shape:"loft",tw:mr(Math.min(1,o*u/n)),td:mr(Math.min(1,o*u/r))});switch(t.lamp){case"pendant":{let a=Math.min(.3,i*.4);return[s(0,0,Math.min(.12,o),i-.03,.03,t.body),s(0,0,Math.min(.01,o/4),a,i-a-.03,"dark"),l(0,a,.35)]}case"wall":{let a=Math.min(.02,r*.2);return[ce(e,0,-r/2+a/2,Math.min(.1,n),a,i*.3,i*.4,t.body),ce(e,0,0,Math.min(.02,n),r-a,i*.45,Math.min(.02,i*.1),t.body),l(i*.15,i*.7,.7)]}default:{let a=Math.min(t.lamp==="table"?.25:.35,i*.4);return[s(0,0,o*.6,0,Math.min(.03,i*.05),t.body,{edges:!0}),s(0,0,Math.min(.03,o/6),.02,i-a-.02,t.body),l(i-a,a,.7)]}}}function _x(t,e){let[n,r,i]=e,o=[],s=t.mount==="floor"?S_(e,t.base,o):0,l=t.display?Math.min(.01,r*.1):0;if(o.push(ce(e,0,-l/2,n,r-l,s,i-s,t.body,{edges:!0})),t.display){let a=Math.min(.02,n*.08,(i-s)*.08);o.push(ce(e,0,r/2-l/2,n-2*a,l,s+a,i-s-2*a,t.front,{screen:!0}))}return o}function gs(t,e,n){let r=pc(t),i=[r.w/100,r.d/100,r.h/100],o=r.name||e,s=n==="en"?{en:o}:{[n.slice(0,5)]:o,en:o},l={id:e,name:s,size:i,parts:[],recipe:r};switch(r.kind){case"cabinet":l.parts=fx(r,i),l.surface=!0;break;case"shelf":l.parts=mx(r,i);break;case"lamp":l.parts=gx(r,i),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=_x(r,i),l.electric=!0,l.mount=r.mount,r.mount==="wall"&&(l.wall_y=1.2);break}return l}function M_(t,e){let n Line truncated
`;var x_=["cabinet","shelf","lamp","device"],Sn="own_studio";var px={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"}},hc=(t,e)=>({kind:t,name:e,...px[t]}),$_=(t,e)=>({...hc(e,t.name),body:t.body,front:t.front}),fr=(t,e,n)=>Math.min(n,Math.max(e,Number.isFinite(t)?t:e)),mr=t=>Math.round(t*1e4)/1e4;function pc(t){return{...t,name:t.name.trim().slice(0,60),w:fr(Math.round(t.w),5,400),d:fr(Math.round(t.d),2,200),h:fr(Math.round(t.h),2,300),doors:fr(Math.round(t.doors),0,6),drawers:fr(Math.round(t.drawers),0,6),shelves:fr(Math.round(t.shelves),0,12)}}function ce(t,e,n,r,i,o,s,l,a={}){let[c,u,d]=t,p=(x,k,M)=>{let A=Math.max(-M,x-k/2),T=Math.min(M,x+k/2);return T-A<1e-4?[Math.max(-M,Math.min(M,x)),.001*M*2]:[(A+T)/2,T-A]},[h,f]=p(e,r,c/2),[g,b]=p(n,i,u/2),y=Math.max(0,Math.min(d*.999,o)),v=Math.max(d*.001,Math.min(d-y,s)),w=x=>mr(Math.max(.001,Math.min(1,x)));return{shape:"box",x:mr(h/c),z:mr(g/u),w:w(f/c),d:w(b/u),y:mr(y/d),h:w(v/d),color:l,...a}}function S_(t,e,n){let[r,i,o]=t;if(e==="legs"){let s=Math.min(.1,o*.25),l=Math.min(.04,r/6,i/6);for(let[a,c]of[[-1,-1],[1,-1],[-1,1],[1,1]])n.push(ce(t,a*(r/2-l),c*(i/2-l),l,l,0,s,"metal"));return s}if(e==="plinth"){let s=Math.min(.08,o*.2);return n.push(ce(t,0,-.02,r-.02,i-.04,0,s,"dark")),s}return 0}function fx(t,e){let[n,r,i]=e,o=[],s=S_(e,t.base,o),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,u=r-c-a,d=-r/2+u/2,p=i-s;if(!l){let v=Math.min(.018,n/10,p/10);o.push(ce(e,-n/2+v/2,0,v,r,s,p,t.body,{edges:!0})),o.push(ce(e,n/2-v/2,0,v,r,s,p,t.body,{edges:!0})),o.push(ce(e,0,-r/2+.005,n-2*v,.01,s,p,t.body));for(let w=0;w<=t.shelves+1;w++)o.push(ce(e,0,.005,n-2*v,r-.01,s+(p-v)*w/(t.shelves+1),v,t.front,{edges:"faint"}));return o}o.push(ce(e,0,d,n,u,s,p,t.body,{edges:!0}));let h=.004,f=-r/2+u+c/2,g=t.doors>0?Math.min(.18,Math.max(.08,(p-.3)/Math.max(1,t.drawers))):p/t.drawers,b=s+(t.drawers>0?g*t.drawers:0),y=(v,w,x)=>{if(t.handle==="none")return;let k=r/2-a/2;t.handle==="knob"?o.push(ce(e,v,k,.025,a,w-.0125,.025,"metal")):x?o.push(ce(e,v,k,.015,a,w-.08,.16,"metal")):o.push(ce(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;o.push(ce(e,0,f,n-2*h,c,w+h,g-2*h,t.front,{edges:"faint"})),y(0,w+g*(t.drawers===1&&t.doors===0?.5:.7),!1)}if(t.doors>0){let v=n/t.doors,w=i-b;for(let x=0;x<t.doors;x++){let k=-n/2+v*(x+.5);o.push(ce(e,k,f,v-2*h,c,b+h,w-2*h,t.front,{edges:"faint"}));let M=t.doors===1||x%2===0?1:-1,A=b+w*(i>1.2?.45:.8);y(k+M*(v/2-.04),Math.min(A,i-.1),!0)}}return o}function mx(t,e){let[n,r,i]=e,o=Math.min(.02,n/10,i/10),s=[ce(e,-n/2+o/2,0,o,r,0,i,t.body,{edges:!0}),ce(e,n/2-o/2,0,o,r,0,i,t.body,{edges:!0})];t.back&&s.push(ce(e,0,-r/2+.005,n-2*o,.01,0,i,t.body));let l=t.shelves+2;for(let a=0;a<l;a++)s.push(ce(e,0,t.back?.005:0,n-2*o,t.back?r-.01:r,(i-o)*a/(l-1),o,t.front,{edges:!0}));return s}function gx(t,e){let[n,r,i]=e,o=Math.min(n,r),s=(a,c,u,d,p,h,f={})=>({...ce(e,a,c,u,u,d,p,h,f),shape:"cyl"}),l=(a,c,u)=>({...ce(e,0,0,o,o,a,c,t.front,{glow:!0,edges:"faint"}),shape:"loft",tw:mr(Math.min(1,o*u/n)),td:mr(Math.min(1,o*u/r))});switch(t.lamp){case"pendant":{let a=Math.min(.3,i*.4);return[s(0,0,Math.min(.12,o),i-.03,.03,t.body),s(0,0,Math.min(.01,o/4),a,i-a-.03,"dark"),l(0,a,.35)]}case"wall":{let a=Math.min(.02,r*.2);return[ce(e,0,-r/2+a/2,Math.min(.1,n),a,i*.3,i*.4,t.body),ce(e,0,0,Math.min(.02,n),r-a,i*.45,Math.min(.02,i*.1),t.body),l(i*.15,i*.7,.7)]}default:{let a=Math.min(t.lamp==="table"?.25:.35,i*.4);return[s(0,0,o*.6,0,Math.min(.03,i*.05),t.body,{edges:!0}),s(0,0,Math.min(.03,o/6),.02,i-a-.02,t.body),l(i-a,a,.7)]}}}function _x(t,e){let[n,r,i]=e,o=[],s=t.mount==="floor"?S_(e,t.base,o):0,l=t.display?Math.min(.01,r*.1):0;if(o.push(ce(e,0,-l/2,n,r-l,s,i-s,t.body,{edges:!0})),t.display){let a=Math.min(.02,n*.08,(i-s)*.08);o.push(ce(e,0,r/2-l/2,n-2*a,l,s+a,i-s-2*a,t.front,{screen:!0}))}return o}function _s(t,e,n){let r=pc(t),i=[r.w/100,r.d/100,r.h/100],o=r.name||e,s=n==="en"?{en:o}:{[n.slice(0,5)]:o,en:o},l={id:e,name:s,size:i,parts:[],recipe:r};switch(r.kind){case"cabinet":l.parts=fx(r,i),l.surface=!0;break;case"shelf":l.parts=mx(r,i);break;case"lamp":l.parts=gx(r,i),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=_x(r,i),l.electric=!0,l.mount=r.mount,r.mount==="wall"&&(l.wall_y=1.2);break}return l}function M_(t,e){let n Line truncated
${l.map(a=>{let c=a.w*o,u=a.h*s,d=(a.x+.5)*o-c/2,p=s-(a.y+a.h)*s,h=a.shape==="cyl"?Math.min(c,u)/2:a.shape==="loft"?3:1;return R`<rect x=${d} y=${p} width=${Math.max(.6,c)} height=${Math.max(.6,u)} rx=${h} fill=${a.screen?"#0b1020":A_(a.color)} stroke="rgba(10,16,32,0.55)" stroke-width="0.8" class=${a.glow?"nf-studio-glow":""} />`})}
</svg>`}function E_(t,e,n,r){let i=t.t,o=!R_.includes(n),s=[...R_.map(l=>[l,i(l==="body"?"studio_color_plan":`studio_color_${l}`)]),["own",i("studio_color_own")]];return m`${H(t,e,o?"own":n,s,l=>r(l==="own"?A_(n):l))}
${o?Ue(t,i("studio_color_own"),n,"#8a6a4a",l=>r(l??"wood")):_}`}function F_(t,e,n){let r=t.t,i=e.recipe,o=c=>n.change(pc({...i,...c})),s=(c,u,d)=>E(t,r(c),u,p=>o({[d]:p}),1,1),l=(c,u,d)=>E(t,r(c),u,p=>o({[d]:p}),1,0),a=()=>{switch(i.kind){case"cabinet":return m`${l("studio_doors",i.doors,"doors")} ${l("studio_drawers",i.drawers,"drawers")}
@@ -4068,7 +4069,7 @@ ${n.sources.map(r=>this.hass.states[r]?.attributes.symcon_path||this.hass.states
<button class="nf-btn" ?disabled=${!t.admin} @click=${()=>n.ignore([i])}>${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 z_=(t,e)=>m`<button class="nf-btn nf-check-open" title=${t.t("check_open_hint")} @click=${e}>✓ ${t.t("check_open")}</button>`;function P_(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]),i=r||/^eur$/i.test(n[1])?"\u20AC":n[1];return{value:Math.round(t*e.value*(r?1:100))/100,currency:i}}var I_=20,D_=new WeakMap;function $x(t){let e=t.entities??{},n=D_.get(e);if(!n){n=new Map;for(let[r,i]of Object.entries(e))i.device_id&&r.startsWith("sensor.")&&t.states[r]?.attributes.device_class==="battery"&&!n.has(i.device_id)&&n.set(i.device_id,r);D_.set(e,n)}return n}function Sx(t,e){let n=t.entities?.[e]?.device_id,r=n?$x(t).get(n):void 0;if(r){let s=Number(t.states[r]?.state);if(Number.isFinite(s))return s}let i=t.states[e]?.attributes;if(!i||i.battery_level===void 0&&i.battery===void 0)return null;let o=Number(i.battery_level??i.battery);return Number.isFinite(o)?o:null}function Mx(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 i of[r.entity,r.power])n(i)&&e.push({entity:i,x:r.x,z:r.z,room:null});for(let r of t.openings)for(let i of[r.contact,r.contact2,r.tilt,r.tilt2,r.cover,r.cover2,r.lock])n(i)&&e.push({entity:i,x:NaN,z:NaN,room:r.room_id});return e}var Rx=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function O_(t,e){let n=new Set,r=[];for(let i of e.floors)for(let o of Mx(i)){let s=t.entities?.[o.entity]?.device_id??o.entity;if(n.has(s))continue;let l=Sx(t,o.entity);l!==null&&(n.add(s),r.push({entity:o.entity,level:l,floorId:i.id,roomId:o.room??Rx(i,o.x,o.z)?.id??null}))}return r.sort((i,o)=>i.level-o.level)}var gr=.08;function H_(t,e){let n=1/0;for(let r=0;r<e.length;r++){let i=e[r],o=e[(r+1)%e.length],[s,l]=[o[0]-i[0],o[1]-i[1]],a=s*s+l*l,c=a>0?Math.max(0,Math.min(1,((t[0]-i[0])*s+(t[1]-i[1])*l)/a)):0;n=Math.min(n,Math.hypot(t[0]-(i[0]+s*c),t[1]-(i[1]+l*c)))}return n}var L_=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 Ex(t,e,n=.2){if(t.points.length<3||e.points.length<3)return!1;let[r,i]=[L_(t.points),L_(e.points)],o=Math.max(r.x0,i.x0)+gr,s=Math.min(r.x1,i.x1)-gr,l=Math.max(r.z0,i.z0)+gr,a=Math.min(r.z1,i.z1)-gr;if(s<=o||a<=l)return!1;for(let c=o;c<=s+1e-9;c+=Math.min(n,s-o||n))for(let u=l;u<=a+1e-9;u+=Math.min(n,a-l||n)){let d=[c,u];if(C(d,t.points)&&C(d,e.points)&&H_(d,t.points)>gr&&H_(d,e.points)>gr)return!0}return!1}function N_(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,i])=>e.has(r)?[]:Array.isArray(i)?i.filter(n):n(i)?[i]:[])}var C_=t=>N_(t),Ax=3,Fx=new Set(["off","standby","idle"]);function Tx(t,e,n,r){let i=e.energy.tariff,o=i?t.states[i]:void 0,s=o?{value:Number(o.state),unit:String(o.attributes.unit_of_measurement??"")}:null,l=new Set,a=(c,u)=>{if(!c||c==="none"||l.has(c))return;l.add(c);let d=t.states[c]?.state;if(!d||!Fx.has(d)||c.startsWith("light."))return;let p=li(t,c),h=p?Fe(t.states[p]):null;if(h===null||h<=Ax)return;let f=P_(h*24*365/1e3,s);r.push({kind:"standby",floorId:n.id,vars:{name:B(t,c),w:Math.round(h),cost:f?`${f.value.toFixed(0)} ${f.currency}`:`${Math.round(h*24*365/1e3)} kWh`},fix:u,changes:!1})};for(let c of n.furniture)a(c.entity,{do:"show_furniture",furnitureId:c.id});for(let c of n.placements){let u=n.rooms.find(d=>d.points.length>=3&&C([c.x,c.z],d.points));u&&a(c.entity_id,{do:"show_room",roomId:u.id})}}function B_(t,e){let n=[],r=e?.areas,i=new Set(t.settings.check_ignore??[]),o=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(u=>u.name.trim().toLowerCase()===a.name.trim().toLowerCase()&&!o.has(u.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=pr(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=Me(e,[s]),c=Ot(e,[s]);for(let u of s.rooms){if(!u.area_id)continue;let d=Yo(s,u);for(let f of s.furniture)if(C([f.x,f.z],u.points))for(let g of C_(f))d.add(g);for(let f of s.openings)if(f.room_id===u.id){for(let g of N_(f))d.add(g);for(let g of Object.values(c.get(f.id)??{}))typeof g=="string"&&d.add(g)}for(let f of s.furniture){let g=a.get(f.id);if(g&&C([f.x,f.z],u.points))for(let b of[g.entity,g.power])typeof b=="string"&&d.add(b)}let p=ye(e,u).filter(f=>Ft(je(e,f))),h=Dn(e,p).map(f=>f.primary).filter(f=>!d.has(f)&&!Line truncated
</details>`}var z_=(t,e)=>m`<button class="nf-btn nf-check-open" title=${t.t("check_open_hint")} @click=${e}>✓ ${t.t("check_open")}</button>`;function P_(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]),i=r||/^eur$/i.test(n[1])?"\u20AC":n[1];return{value:Math.round(t*e.value*(r?1:100))/100,currency:i}}var I_=20,D_=new WeakMap;function $x(t){let e=t.entities??{},n=D_.get(e);if(!n){n=new Map;for(let[r,i]of Object.entries(e))i.device_id&&r.startsWith("sensor.")&&t.states[r]?.attributes.device_class==="battery"&&!n.has(i.device_id)&&n.set(i.device_id,r);D_.set(e,n)}return n}function Sx(t,e){let n=t.entities?.[e]?.device_id,r=n?$x(t).get(n):void 0;if(r){let s=Number(t.states[r]?.state);if(Number.isFinite(s))return s}let i=t.states[e]?.attributes;if(!i||i.battery_level===void 0&&i.battery===void 0)return null;let o=Number(i.battery_level??i.battery);return Number.isFinite(o)?o:null}function Mx(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 i of[r.entity,r.power])n(i)&&e.push({entity:i,x:r.x,z:r.z,room:null});for(let r of t.openings)for(let i of[r.contact,r.contact2,r.tilt,r.tilt2,r.cover,r.cover2,r.lock])n(i)&&e.push({entity:i,x:NaN,z:NaN,room:r.room_id});return e}var Rx=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function O_(t,e){let n=new Set,r=[];for(let i of e.floors)for(let o of Mx(i)){let s=t.entities?.[o.entity]?.device_id??o.entity;if(n.has(s))continue;let l=Sx(t,o.entity);l!==null&&(n.add(s),r.push({entity:o.entity,level:l,floorId:i.id,roomId:o.room??Rx(i,o.x,o.z)?.id??null}))}return r.sort((i,o)=>i.level-o.level)}var gr=.08;function H_(t,e){let n=1/0;for(let r=0;r<e.length;r++){let i=e[r],o=e[(r+1)%e.length],[s,l]=[o[0]-i[0],o[1]-i[1]],a=s*s+l*l,c=a>0?Math.max(0,Math.min(1,((t[0]-i[0])*s+(t[1]-i[1])*l)/a)):0;n=Math.min(n,Math.hypot(t[0]-(i[0]+s*c),t[1]-(i[1]+l*c)))}return n}var L_=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 Ex(t,e,n=.2){if(t.points.length<3||e.points.length<3)return!1;let[r,i]=[L_(t.points),L_(e.points)],o=Math.max(r.x0,i.x0)+gr,s=Math.min(r.x1,i.x1)-gr,l=Math.max(r.z0,i.z0)+gr,a=Math.min(r.z1,i.z1)-gr;if(s<=o||a<=l)return!1;for(let c=o;c<=s+1e-9;c+=Math.min(n,s-o||n))for(let u=l;u<=a+1e-9;u+=Math.min(n,a-l||n)){let d=[c,u];if(C(d,t.points)&&C(d,e.points)&&H_(d,t.points)>gr&&H_(d,e.points)>gr)return!0}return!1}function N_(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,i])=>e.has(r)?[]:Array.isArray(i)?i.filter(n):n(i)?[i]:[])}var C_=t=>N_(t),Ax=3,Fx=new Set(["off","standby","idle"]);function Tx(t,e,n,r){let i=e.energy.tariff,o=i?t.states[i]:void 0,s=o?{value:Number(o.state),unit:String(o.attributes.unit_of_measurement??"")}:null,l=new Set,a=(c,u)=>{if(!c||c==="none"||l.has(c))return;l.add(c);let d=t.states[c]?.state;if(!d||!Fx.has(d)||c.startsWith("light."))return;let p=li(t,c),h=p?Fe(t.states[p]):null;if(h===null||h<=Ax)return;let f=P_(h*24*365/1e3,s);r.push({kind:"standby",floorId:n.id,vars:{name:B(t,c),w:Math.round(h),cost:f?`${f.value.toFixed(0)} ${f.currency}`:`${Math.round(h*24*365/1e3)} kWh`},fix:u,changes:!1})};for(let c of n.furniture)a(c.entity,{do:"show_furniture",furnitureId:c.id});for(let c of n.placements){let u=n.rooms.find(d=>d.points.length>=3&&C([c.x,c.z],d.points));u&&a(c.entity_id,{do:"show_room",roomId:u.id})}}function B_(t,e){let n=[],r=e?.areas,i=new Set(t.settings.check_ignore??[]),o=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(u=>u.name.trim().toLowerCase()===a.name.trim().toLowerCase()&&!o.has(u.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=pr(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=Me(e,[s]),c=Ot(e,[s]);for(let u of s.rooms){if(!u.area_id)continue;let d=Xo(s,u);for(let f of s.furniture)if(C([f.x,f.z],u.points))for(let g of C_(f))d.add(g);for(let f of s.openings)if(f.room_id===u.id){for(let g of N_(f))d.add(g);for(let g of Object.values(c.get(f.id)??{}))typeof g=="string"&&d.add(g)}for(let f of s.furniture){let g=a.get(f.id);if(g&&C([f.x,f.z],u.points))for(let b of[g.entity,g.power])typeof b=="string"&&d.add(b)}let p=ye(e,u).filter(f=>Ft(je(e,f))),h=Dn(e,p).map(f=>f.primary).filter(f=>!d.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; }
@@ -4083,15 +4084,15 @@ ${n.sources.map(r=>this.hass.states[r]?.attributes.symcon_path||this.hass.states
tr.grand td { font-size: 12pt; border-top: 0.6mm solid #222; }
.note { color: #666; font-size: 9pt; margin-top: 4mm; }
@media print { .page { padding: 0; } }
</style></head><body>${r.join("")}${l}<script>window.addEventListener("load", () => setTimeout(() => window.print(), 300));<\/script></body></html>`}var V_="nextfloor.tour_done",Px=[["Ctrl Z","keys_undo"],["Ctrl Shift Z \xB7 Ctrl Y","keys_redo"],["Ctrl D","keys_duplicate"],["Entf / Delete","keys_delete"],["\u2190 \u2191 \u2192 \u2193","keys_nudge"],["Shift + \u2190\u2191\u2192\u2193","keys_nudge_10"],["Alt + \u2190\u2191\u2192\u2193","keys_nudge_1"],["R \xB7 Shift R","keys_rotate"],["L","keys_lock"],["Enter","keys_close_shape"],["Esc","keys_escape"],["Shift","keys_straight"],["?","keys_sheet"]],_s=[["tour_1_title","tour_1"],["tour_2_title","tour_2"],["tour_3_title","tour_3"],["tour_4_title","tour_4"]];function K_(){try{return localStorage.getItem(V_)!=="1"}catch{return!1}}function j_(){try{localStorage.setItem(V_,"1")}catch{}}function U_(t,e){return m`<div class="nf-keys" role="dialog" aria-label=${t("keys_title")} @click=${n=>n.target===n.currentTarget&&e()}>
</style></head><body>${r.join("")}${l}<script>window.addEventListener("load", () => setTimeout(() => window.print(), 300));<\/script></body></html>`}var V_="nextfloor.tour_done",Px=[["Ctrl Z","keys_undo"],["Ctrl Shift Z \xB7 Ctrl Y","keys_redo"],["Ctrl D","keys_duplicate"],["Entf / Delete","keys_delete"],["\u2190 \u2191 \u2192 \u2193","keys_nudge"],["Shift + \u2190\u2191\u2192\u2193","keys_nudge_10"],["Alt + \u2190\u2191\u2192\u2193","keys_nudge_1"],["R \xB7 Shift R","keys_rotate"],["L","keys_lock"],["Enter","keys_close_shape"],["Esc","keys_escape"],["Shift","keys_straight"],["?","keys_sheet"]],bs=[["tour_1_title","tour_1"],["tour_2_title","tour_2"],["tour_3_title","tour_3"],["tour_4_title","tour_4"]];function K_(){try{return localStorage.getItem(V_)!=="1"}catch{return!1}}function j_(){try{localStorage.setItem(V_,"1")}catch{}}function U_(t,e){return m`<div class="nf-keys" role="dialog" aria-label=${t("keys_title")} @click=${n=>n.target===n.currentTarget&&e()}>
<div class="nf-keys-card">
<div class="nf-h3row"><h3>⌨ ${t("keys_title")}</h3><button class="nf-btn nf-field-btn" aria-label=${t("close")} @click=${e}>✕</button></div>
<dl>
${Px.map(([n,r])=>m`<dt>${n.split(" \xB7 ").map((i,o)=>m`${o?" \xB7 ":""}<kbd>${i}</kbd>`)}</dt><dd>${t(r)}</dd>`)}
</dl>
</div>
</div>`}function Dx(t){return{rect:t("tool_rect"),free:t("tool_polygon"),rooms:t("area_rooms",{n:"\u2026"}).replace(/\s*\(…\)\s*$/,""),opening:t("tool_opening"),furniture:t("tool_furniture"),split:t("split_3d"),check:t("check_open")}}function G_(t,e,n){if(e===null||e>=_s.length)return _;let[r,i]=_s[e],o=e===_s.length-1;return m`<div class="nf-tour" role="dialog" aria-label=${t("tour_title")}>
<div class="nf-tour-step">${e+1} / ${_s.length}</div>
</div>`}function Dx(t){return{rect:t("tool_rect"),free:t("tool_polygon"),rooms:t("area_rooms",{n:"\u2026"}).replace(/\s*\(…\)\s*$/,""),opening:t("tool_opening"),furniture:t("tool_furniture"),split:t("split_3d"),check:t("check_open")}}function G_(t,e,n){if(e===null||e>=bs.length)return _;let[r,i]=bs[e],o=e===bs.length-1;return m`<div class="nf-tour" role="dialog" aria-label=${t("tour_title")}>
<div class="nf-tour-step">${e+1} / ${bs.length}</div>
<h3>${t(r)}</h3>
<p>${t(i,Dx(t))}</p>
<div class="nf-actions">
@@ -4321,7 +4322,7 @@ ${n.sources.map(r=>this.hass.states[r]?.attributes.symcon_path||this.hass.states
color: inherit;
font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}
`]};customElements.get("nf-pack-manager")||customElements.define("nf-pack-manager",_c);var XL=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 Vx=new Map;var rb=()=>[...Vx.values()];var bc=class extends Y{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=eo(()=>this.requestUpdate())}disconnectedCallback(){super.disconnectedCallback(),this.stop?.()}t(e,n){return we(this.hass,e,n)}emit(e){this.dispatchEvent(new CustomEvent("plugins-changed",{detail:e,bubbles:!0,composed:!0}))}add(e){let n=Vs(e.value),r=this.plugins??[];if(!Ks(n))return void(this._error=this.t("plugins_url_invalid"));if(r.some(i=>i.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 X_()}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(i=>i.id===e.id);if(!r&&n.length>=20)return void(this._error=this.t("plugins_limit"));if(!r&&n.some(i=>i.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(Q_(n,e)))}renderStore(){return m`<div class="nf-store">
`]};customElements.get("nf-pack-manager")||customElements.define("nf-pack-manager",_c);var XL=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 Vx=new Map;var rb=()=>[...Vx.values()];var bc=class extends Y{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=eo(()=>this.requestUpdate())}disconnectedCallback(){super.disconnectedCallback(),this.stop?.()}t(e,n){return we(this.hass,e,n)}emit(e){this.dispatchEvent(new CustomEvent("plugins-changed",{detail:e,bubbles:!0,composed:!0}))}add(e){let n=Ks(e.value),r=this.plugins??[];if(!js(n))return void(this._error=this.t("plugins_url_invalid"));if(r.some(i=>i.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 X_()}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(i=>i.id===e.id);if(!r&&n.length>=20)return void(this._error=this.t("plugins_limit"));if(!r&&n.some(i=>i.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(Q_(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/${yr}" target="_blank" rel="noopener">${this.t("store_submit")}</a></p>
${this._storeError?m`<p class="nf-error" role="alert">${this._storeError}</p>`:_}
@@ -4337,7 +4338,7 @@ ${n.sources.map(r=>this.hass.states[r]?.attributes.symcon_path||this.hass.states
${n==="installed"?m`<span class="nf-state ok">${this.t("store_installed")}</span>`:m`<button class="nf-btn" @click=${()=>this.install(e)}>${n==="update"?this.t("store_update"):this.t("store_install")}</button>`}
</li>`})}
</ul>`:_}
</div>`}stateOf(e){let n=rb().find(o=>o.url===e),r=Us().filter(o=>o.source===e),i=[...n?.error?[n.error]:[],...r.flatMap(o=>o.errors)];if(n?.state==="error")return{label:this.t("plugins_error"),tone:"err",detail:i.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 o=r.map(s=>`${s.name}${s.version?` ${s.version}`:""}`).join(", ");return{label:this.t("plugins_loaded"),tone:i.length?"warn":"ok",detail:i.length?`${o} \xB7 ${i.join(" \xB7 ")}`:o}}return{label:this.t("plugins_reload_hint"),tone:"warn",detail:""}}render(){let e=this.plugins??[],n=Us().filter(r=>!r.source);return m`<section class="nf-plugins">
</div>`}stateOf(e){let n=rb().find(o=>o.url===e),r=Gs().filter(o=>o.source===e),i=[...n?.error?[n.error]:[],...r.flatMap(o=>o.errors)];if(n?.state==="error")return{label:this.t("plugins_error"),tone:"err",detail:i.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 o=r.map(s=>`${s.name}${s.version?` ${s.version}`:""}`).join(", ");return{label:this.t("plugins_loaded"),tone:i.length?"warn":"ok",detail:i.length?`${o} \xB7 ${i.join(" \xB7 ")}`:o}}return{label:this.t("plugins_reload_hint"),tone:"warn",detail:""}}render(){let e=this.plugins??[],n=Gs().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="${Yt}/blob/main/docs/plugins.md" target="_blank" rel="noopener">${this.t("plugins_docs")}</a></p>
<p class="nf-warn">⚠️ ${this.t("plugins_warning")}</p>
@@ -4489,7 +4490,7 @@ ${n.sources.map(r=>this.hass.states[r]?.attributes.symcon_path||this.hass.states
color: var(--nf-soft);
font-size: 13px;
}
`]};customElements.get("nf-extensions")||customElements.define("nf-extensions",yc);var Ti="handled",ib=["select","rect","polygon","wall","opening","furniture","stairs","outdoor","hole","roof","energy"],ob=new Set(["vertex","room","device","opening","furniture","rotate","resize","outdoor","roofmove","roofcorner","roofvertex","outvertex","solarmove","solarturn","bgmove","bgscale","bgrotate"]),bs=10,We=t=>Math.round(t*1e3)/1e3,sb={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},vc=class extends Y{static properties={hass:{attribute:!1},building:{attribute:!1},narrow:{type:Boolean},roomLabels:{attribute:!1},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 us(100);lib=new Jo(()=>this.requestUpdate());side=new fs(()=>this.requestUpdate());sel=new ps(()=>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.roomLabels=!0,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 we(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),i=r.floors.find(c=>c.id===this._floorId);if(!i)return;let[o,s,l]=e.key.split(":");if(!(o==="wall"?Mm(i,s,e.bulge).length>0:Sm(i,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:Ef(r,e,n)})},duplicate:()=>this.duplicateOutdoor(),remove:()=>this.deleteOutdoor(),removeCorner:e=>{let n=this.sel.outdoor;n&&this.change((r,i)=>{_f(i.outdoor.find(o=>o.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:${Sn}:`)?n.id:null;this._studio={recipe:r&&n?.recipe?{...n.recipe}:hc("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=Rr().find(u=>u.id===Sn),i=r?.items??[],o={...e.recipe,name:e.recipe.name||this.t(`studio_kind_${e.recipe.kind}`)},s=e.itemId??M_(o.name,i.map(u=>u.id)),l=gs(o,s,n),a={id:Sn,name:r?.name??this.t("studio_pack_name"),publisher:r?.publisher??this.t("studio_pack_publisher"),release:(r?.release??0)+1,items:e.itemId?i.map(u=>u.id===s?l:u):[...i,l]};this._studio={...e,busy:!0,error:null};try{let{builtin:u,imported_at:d,...p}=a;await Dr(this.hass, Line truncated
`]};customElements.get("nf-extensions")||customElements.define("nf-extensions",yc);var Ti="handled",ib=["select","rect","polygon","wall","opening","furniture","stairs","outdoor","hole","roof","energy"],ob=new Set(["vertex","room","device","opening","furniture","rotate","resize","outdoor","roofmove","roofcorner","roofvertex","outvertex","solarmove","solarturn","bgmove","bgscale","bgrotate"]),ys=10,We=t=>Math.round(t*1e3)/1e3,sb={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]},vc=class extends Y{static properties={hass:{attribute:!1},building:{attribute:!1},narrow:{type:Boolean},roomLabels:{attribute:!1},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 ds(100);lib=new Qo(()=>this.requestUpdate());side=new ms(()=>this.requestUpdate());sel=new fs(()=>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.roomLabels=!0,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 we(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),i=r.floors.find(c=>c.id===this._floorId);if(!i)return;let[o,s,l]=e.key.split(":");if(!(o==="wall"?Mm(i,s,e.bulge).length>0:Sm(i,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:Ef(r,e,n)})},duplicate:()=>this.duplicateOutdoor(),remove:()=>this.deleteOutdoor(),removeCorner:e=>{let n=this.sel.outdoor;n&&this.change((r,i)=>{_f(i.outdoor.find(o=>o.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:${Sn}:`)?n.id:null;this._studio={recipe:r&&n?.recipe?{...n.recipe}:hc("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=Rr().find(u=>u.id===Sn),i=r?.items??[],o={...e.recipe,name:e.recipe.name||this.t(`studio_kind_${e.recipe.kind}`)},s=e.itemId??M_(o.name,i.map(u=>u.id)),l=_s(o,s,n),a={id:Sn,name:r?.name??this.t("studio_pack_name"),publisher:r?.publisher??this.t("studio_pack_publisher"),release:(r?.release??0)+1,items:e.itemId?i.map(u=>u.id===s?l:u):[...i,l]};this._studio={...e,busy:!0,error:null};try{let{builtin:u,imported_at:d,...p}=a;await Dr(this.hass, Line truncated
>${s}
<input
type="number"
@@ -4537,7 +4538,7 @@ ${n.sources.map(r=>this.hass.states[r]?.attributes.symcon_path||this.hass.states
<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(o=>o.id===n);if(r==="win"){let o=e.settings.roof.windows?.find(s=>s.id===n);return o?mn(o):void 0}let i=e.settings.roof.chimneys?.find(o=>o.id===n);return i?$t(i,Z(e).find(o=>o.key===i.face)):void 0}grab3dStart(e){let n=this._doc,r=Z(n),i=null,o=(l,a,c,u,d=!1,p=!1)=>{if(!c||d)return;let h=xo(c,e.o,e.d);!h||!Ta(c,u,h.u,h.s)||i&&i.t<=h.t||(i={id:l,win:a,chimney:p,t:h.t,du:h.u-u.u,ds:h.s-u.v})};if(this._tool==="energy")for(let l of n.settings.roof.solar??[])o(l.id,!1,Se(n,l,r),l,!!l.locked);if(this._tool==="roof")for(let l of n.settings.roof.windows??[])o(l.id,!0,r.find(a=>a.key===l.face)??null,mn(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;o(l.id,!1,a,$t(l,a),!!l.locked,!0)}if(!i)return!1;let s=i;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,i=this.fittingField(r,n.id,n.win?"win":n.chimney?"chimney":"field");if(!i)return;let o=Se(r,i),s=o?.unbounded?[o]:n.win||n.chimney?Z(r):[...Z(r),...qe(r)],l=null;for(let p of s){let h=xo(p,e.o,e.d);h&&Fa(p,h.u,h.s)&&(!l||h.t<l.t)&&(l={face:p,...h})}if(!l)return;let a=l.face,c=.05,u=p=>We(Math.round(p/c)*c),d=mt(a,{...i,face:a.key,u:u(l.u-n.du),v:u(l.s-n.ds),tilt:a.flat?i.tilt??15:i.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,...d});return}let h=p.settings.roof.solar?.find(f=>f.id===n.id);h&&Object.assign(h,{face:a.key,...d},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(o=>o.id===n);if(r==="win"){let o=e.settings.roof.windows?.find(s=>s.id===n);return o?mn(o):void 0}let i=e.settings.roof.chimneys?.find(o=>o.id===n);return i?$t(i,Z(e).find(o=>o.key===i.face)):void 0}grab3dStart(e){let n=this._doc,r=Z(n),i=null,o=(l,a,c,u,d=!1,p=!1)=>{if(!c||d)return;let h=xo(c,e.o,e.d);!h||!za(c,u,h.u,h.s)||i&&i.t<=h.t||(i={id:l,win:a,chimney:p,t:h.t,du:h.u-u.u,ds:h.s-u.v})};if(this._tool==="energy")for(let l of n.settings.roof.solar??[])o(l.id,!1,Se(n,l,r),l,!!l.locked);if(this._tool==="roof")for(let l of n.settings.roof.windows??[])o(l.id,!0,r.find(a=>a.key===l.face)??null,mn(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;o(l.id,!1,a,$t(l,a),!!l.locked,!0)}if(!i)return!1;let s=i;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,i=this.fittingField(r,n.id,n.win?"win":n.chimney?"chimney":"field");if(!i)return;let o=Se(r,i),s=o?.unbounded?[o]:n.win||n.chimney?Z(r):[...Z(r),...qe(r)],l=null;for(let p of s){let h=xo(p,e.o,e.d);h&&Ta(p,h.u,h.s)&&(!l||h.t<l.t)&&(l={face:p,...h})}if(!l)return;let a=l.face,c=.05,u=p=>We(Math.round(p/c)*c),d=mt(a,{...i,face:a.key,u:u(l.u-n.du),v:u(l.s-n.ds),tilt:a.flat?i.tilt??15:i.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,...d});return}let h=p.settings.roof.solar?.find(f=>f.id===n.id);h&&Object.assign(h,{face:a.key,...d},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>
@@ -4580,7 +4581,7 @@ ${n.sources.map(r=>this.hass.states[r]?.attributes.symcon_path||this.hass.states
@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 i=structuredClone(n),o=i.floors.find(s=>s.id===this._floorId);!o&&this._floorId||(e(i,o),this.setDoc(i,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:i}=this._view;return[e[0]*n+r,e[1]*n+i]}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:i,oy:o}=this._view;return[(e-i)/r,(n-o)/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,i=n.x1-n.x0+2*r,o=n.z1-n.z0+2*r,s=Math.max(8,Math.min(400,Math.min(this._size.w/i,this._size.h/o)));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:i,ox:o,oy:s}=this._view,l=Math.max(8,Math.min(600,i*e)),a=l/i;this._view={scale:l,ox:n-(n-o)*a,oy:r-(r-s)*a}}snap(e,n,r=!1){if(this._guides={},r)return e;let i=Tm(e,{rooms:this.floor?.rooms??[],grid:this._doc.settings.grid,reach:bs/this._view.scale,skip:n});return this._guides=i.guides,i.point}onPointerDown(e){if(this._pick){let[r,i]=this.localPoint(e),o=this._pick;this.cancelPick(),o(this.toWorld(r,i));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),i=e.target;this.pressStart=r,this.pressTimer=window.setTimeout(()=>{let o=this.drag;o&&"moved"in o&&o.moved||(this.drag=null,this.openContext(i,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 o=this.drag;o&&ob.has(o.kind)&&"moved"in o&&o.moved&&"base"in o&&this.restoreLive(o.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},i=this.pressRoute(r)??this.pressBackground(r)??this.pressWallTool(r)??this.pressRoofTools(r)??this.pressDrawingTool(r)??this.pressItem(r)??this.pressRoom(r);i!==Ti&&(this.drag=i)}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,i=this.floor?.background;if(this.bg.level&&this.isAdmin&&i)return this.bg.tapLevel(n),Ti;if(this.bg.handlesShown&&i&&r.closest("[data-bg-rotate]")){let s=er(i,this.bg.picture(i.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 i=structuredClone(n),o=i.floors.find(s=>s.id===this._floorId);!o&&this._floorId||(e(i,o),this.setDoc(i,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:i}=this._view;return[e[0]*n+r,e[1]*n+i]}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:i,oy:o}=this._view;return[(e-i)/r,(n-o)/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,i=n.x1-n.x0+2*r,o=n.z1-n.z0+2*r,s=Math.max(8,Math.min(400,Math.min(this._size.w/i,this._size.h/o)));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:i,ox:o,oy:s}=this._view,l=Math.max(8,Math.min(600,i*e)),a=l/i;this._view={scale:l,ox:n-(n-o)*a,oy:r-(r-s)*a}}snap(e,n,r=!1){if(this._guides={},r)return e;let i=Tm(e,{rooms:this.floor?.rooms??[],grid:this._doc.settings.grid,reach:ys/this._view.scale,skip:n});return this._guides=i.guides,i.point}onPointerDown(e){if(this._pick){let[r,i]=this.localPoint(e),o=this._pick;this.cancelPick(),o(this.toWorld(r,i));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),i=e.target;this.pressStart=r,this.pressTimer=window.setTimeout(()=>{let o=this.drag;o&&"moved"in o&&o.moved||(this.drag=null,this.openContext(i,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 o=this.drag;o&&ob.has(o.kind)&&"moved"in o&&o.moved&&"base"in o&&this.restoreLive(o.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},i=this.pressRoute(r)??this.pressBackground(r)??this.pressWallTool(r)??this.pressRoofTools(r)??this.pressDrawingTool(r)??this.pressItem(r)??this.pressRoom(r);i!==Ti&&(this.drag=i)}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,i=this.floor?.background;if(this.bg.level&&this.isAdmin&&i)return this.bg.tapLevel(n),Ti;if(this.bg.handlesShown&&i&&r.closest("[data-bg-rotate]")){let s=er(i,this.bg.picture(i.image_id)?.aspect??1);return{kind:"bgrotate",base:this._doc,moved:!1,start:Math.atan2(n[1]-s[1Line truncated
${e?R`${jm(r,e,this.sel.outdoor)} ${Gm(r,e,this.sel.room,this.sel.edge)} ${Cm(r,e,this.sel.furniture)}
${qm(r,e,this.sel.wall)} ${n?eg(r,e,n,this.sel.opening):_} ${Zm(r,e)}
${this._tool==="select"?Nm(r,e,this.sel.device):_}
@@ -4591,7 +4592,7 @@ ${n.sources.map(r=>this.hass.states[r]?.attributes.symcon_path||this.hass.states
${i&&this._tool==="select"?Ym(r,i):_}
${Np(r,e)}`:_}
${this._tool==="roof"?R`${tl(r,this.roof)}${Lp(r,this.roof)}${Wp(r,this.roof)}`:this._tool==="energy"?R`${tl(r,this.roof)}${Hp(r,this.roof)}${Bp(r,this.floor,this._doc.energy.routes??[],this._routeDraft)}${Cp(r,this.floor,this.sel.furniture)}`:_}
${Pm(r,s,this._tool,this._draft,this._cursor)} ${zm(r,this._guides,this._size)}`}wallsOfFloor(){let e=this.floor,{wall_exterior:n,wall_interior:r}=this._doc.settings;return e?fe(e.rooms,{exterior:n,interior:r},e.walls??[]).walls:[]}edgeParts(e,n){let r=this.wallsOfFloor().flatMap(i=>i.sources.filter(o=>o.room_id===e.id&&o.edge===n).map(o=>o.t0));return r.length>0?[...new Set(r)].sort((i,o)=>i-o):[0]}changeRoom(e,n){this.isAdmin&&this.change((r,i)=>{let o=i.rooms.find(s=>s.id===e.id);o&&n(o)})}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(i=>i.room_id===e.id&&i.edge===n)),setHeight:(e,n,r,i)=>{if(r!==void 0){let s=this.edgeParts(e,n).length;this.changeRoom(e,l=>og(l,n,r,i,s));return}let o=this.wallsOfFloor().filter(s=>s.sources.some(l=>l.room_id===e.id&&l.edge===n)).flatMap(s=>s.sources);o.some(s=>s.room_id===e.id&&s.edge===n)||o.push({room_id:e.id,edge:n,t0:0,t1:0}),this.isAdmin&&this.change((s,l)=>{for(let a of o){let c=l.rooms.find(u=>u.id===a.room_id);c&&Vl(c,a.edge,i)}})},setSlope:(e,n,r,i)=>this.changeRoom(e,o=>rg(o,n,r,i)),clearSlope:(e,n)=>this.changeRoom(e,r=>ig(r,n,this.floor?.height??2.5)),setThickness:(e,n,r,i,o)=>this.changeRoom(e,s=>cg(s,n,r,i,o)),arc:this.arcActions(),cut:(e,n,r)=>{let i=this.edgeParts(e,n);this.changeRoom(e,o=>sg(o,n,r,i))},moveCut:(e,n,r,i)=>{let o=this.edgeParts(e,n);this.changeRoom(e,s=>ag(s,n,r,i,o))},join:(e,n,r,i)=>this.changeRoom(e,o=>lg(o,n,r,i)),lit:this.sel.edge,light:e=>this.sel.edge=e}}addFloor(e=null){let n=c_(this._doc,e,{first:this.t("default_floor"),next:i=>this.t("new_floor",{n:i})}),r=structuredClone(this._doc);r.floors=cc(r.floors,n),this.setDoc(r),this._floorId=n.id,this.sel.room=null,this.side.floorMenu=!1,this.fit()}addAreaRooms(e){let n=pr(this._doc,e,this.hass?.areas);if(n.length===0)return;let r=$u(e,n,()=>I("room"));this.change((i,o)=>o.rooms.push(...r)),this.fit()}duplicateFloor(e){let n=this.floor;if(!n||!this.isAdmin)return;let r=p_(this._doc,n,this.t("floor_copy_name",{name:n.name}),e),i=structuredClone(this._doc);i.floors=cc(i.floors,r),this.setDoc(i),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=u_(this._doc.floors,n,e);if(r.every((o,s)=>o.id===this._doc.floors[s].id))return;let i=structuredClone(this._doc);i.floors=r.map(o=>i.floors.find(s=>s.id===o.id)),this.setDoc(i)}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,i)=>this.setPoint(n,r,i),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?ye(this.hass,e).filter(r=>r.startsWith("light.")):[];this.side.spots=__(e,n)},placeSpots:()=>this.placeSpots(e),lockButton:this.fixButton("room",e.id),wallHeights:pg(this.host,e,this.edgeActions()),climate:Nf(this.host,e,n=>this.updateRoom(n)),corner:this.sel.corner}}applyPackage(e,n){if(!this.isAdmin)return;let r=ah(e,n,()=>I("furniture"));this.change((i,o)=>o.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=ms(e,n);this.change((i,o)=>o.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=df(e,n);this.change((i,o)=>o.walls=[...o.walls??[],r]),this.selectItem("wall",r.id)}addHole(e,n){if(!this.floor)return;let r=ff(e,n);this.change((i,o)=>o.furniture.push(r)),this.selectItem("furniture",r.id),this._tool="select"}addStairs(e,n){let r=this.floor;if(!r)return;let[i,o]=[n[0]-e[0],n[1]-e[1]],s=dl("stairs",this._doc,r,[(e[0]+n[0])/2,(e[1]+n[1])/2]),l=i>o*1.2;Object.assign(s,{w:Math.round((l?o:i)*1e3)/1e3,d:Math.round((l?i:o)*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=mf(e);this.change((r,i)=>i.outdoor.push(n)),this.selectItem("outdoor",n.id),this._tool="select"}duplicateOutdoor(){let e=this.outdoorArea;if(!e||!this.isAdmin)return;let n=bf(e);this.change((r,i)=>i.outdoor.push(n)),this.selectItem("outdoor",n.id)}addRoom(e){if(! Line truncated
${Pm(r,s,this._tool,this._draft,this._cursor)} ${zm(r,this._guides,this._size)}`}wallsOfFloor(){let e=this.floor,{wall_exterior:n,wall_interior:r}=this._doc.settings;return e?fe(e.rooms,{exterior:n,interior:r},e.walls??[]).walls:[]}edgeParts(e,n){let r=this.wallsOfFloor().flatMap(i=>i.sources.filter(o=>o.room_id===e.id&&o.edge===n).map(o=>o.t0));return r.length>0?[...new Set(r)].sort((i,o)=>i-o):[0]}changeRoom(e,n){this.isAdmin&&this.change((r,i)=>{let o=i.rooms.find(s=>s.id===e.id);o&&n(o)})}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(i=>i.room_id===e.id&&i.edge===n)),setHeight:(e,n,r,i)=>{if(r!==void 0){let s=this.edgeParts(e,n).length;this.changeRoom(e,l=>og(l,n,r,i,s));return}let o=this.wallsOfFloor().filter(s=>s.sources.some(l=>l.room_id===e.id&&l.edge===n)).flatMap(s=>s.sources);o.some(s=>s.room_id===e.id&&s.edge===n)||o.push({room_id:e.id,edge:n,t0:0,t1:0}),this.isAdmin&&this.change((s,l)=>{for(let a of o){let c=l.rooms.find(u=>u.id===a.room_id);c&&Vl(c,a.edge,i)}})},setSlope:(e,n,r,i)=>this.changeRoom(e,o=>rg(o,n,r,i)),clearSlope:(e,n)=>this.changeRoom(e,r=>ig(r,n,this.floor?.height??2.5)),setThickness:(e,n,r,i,o)=>this.changeRoom(e,s=>cg(s,n,r,i,o)),arc:this.arcActions(),cut:(e,n,r)=>{let i=this.edgeParts(e,n);this.changeRoom(e,o=>sg(o,n,r,i))},moveCut:(e,n,r,i)=>{let o=this.edgeParts(e,n);this.changeRoom(e,s=>ag(s,n,r,i,o))},join:(e,n,r,i)=>this.changeRoom(e,o=>lg(o,n,r,i)),lit:this.sel.edge,light:e=>this.sel.edge=e}}addFloor(e=null){let n=c_(this._doc,e,{first:this.t("default_floor"),next:i=>this.t("new_floor",{n:i})}),r=structuredClone(this._doc);r.floors=cc(r.floors,n),this.setDoc(r),this._floorId=n.id,this.sel.room=null,this.side.floorMenu=!1,this.fit()}addAreaRooms(e){let n=pr(this._doc,e,this.hass?.areas);if(n.length===0)return;let r=$u(e,n,()=>I("room"));this.change((i,o)=>o.rooms.push(...r)),this.fit()}duplicateFloor(e){let n=this.floor;if(!n||!this.isAdmin)return;let r=p_(this._doc,n,this.t("floor_copy_name",{name:n.name}),e),i=structuredClone(this._doc);i.floors=cc(i.floors,r),this.setDoc(i),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=u_(this._doc.floors,n,e);if(r.every((o,s)=>o.id===this._doc.floors[s].id))return;let i=structuredClone(this._doc);i.floors=r.map(o=>i.floors.find(s=>s.id===o.id)),this.setDoc(i)}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,i)=>this.setPoint(n,r,i),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?ye(this.hass,e).filter(r=>r.startsWith("light.")):[];this.side.spots=__(e,n)},placeSpots:()=>this.placeSpots(e),lockButton:this.fixButton("room",e.id),wallHeights:pg(this.host,e,this.edgeActions()),climate:Nf(this.host,e,n=>this.updateRoom(n)),corner:this.sel.corner}}applyPackage(e,n){if(!this.isAdmin)return;let r=ah(e,n,()=>I("furniture"));this.change((i,o)=>o.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=gs(e,n);this.change((i,o)=>o.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=df(e,n);this.change((i,o)=>o.walls=[...o.walls??[],r]),this.selectItem("wall",r.id)}addHole(e,n){if(!this.floor)return;let r=ff(e,n);this.change((i,o)=>o.furniture.push(r)),this.selectItem("furniture",r.id),this._tool="select"}addStairs(e,n){let r=this.floor;if(!r)return;let[i,o]=[n[0]-e[0],n[1]-e[1]],s=dl("stairs",this._doc,r,[(e[0]+n[0])/2,(e[1]+n[1])/2]),l=i>o*1.2;Object.assign(s,{w:Math.round((l?o:i)*1e3)/1e3,d:Math.round((l?i:o)*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=mf(e);this.change((r,i)=>i.outdoor.push(n)),this.selectItem("outdoor",n.id),this._tool="select"}duplicateOutdoor(){let e=this.outdoorArea;if(!e||!this.isAdmin)return;let n=bf(e);this.change((r,i)=>i.outdoor.push(n)),this.selectItem("outdoor",n.id)}addRoom(e){if(! Line truncated
${Ri(this.host,n,this.furnitureActions())}`;let r=this.energyActions();return m`${Fp(this.host,r)}${Gg(this.roofDeps())}${Tp(this.host,r)}${Ip(this.host,this.routeActions())}${zp(this.host,r)}${Pp(this.host)}`}fixItem(e,n,r){if(e)switch(n){case"room":return e.rooms.find(i=>i.id===r);case"opening":return e.openings.find(i=>i.id===r);case"furniture":return e.furniture.find(i=>i.id===r);case"device":return e.placements.find(i=>i.entity_id===r);case"wall":return(e.walls??[]).find(i=>i.id===r);case"outdoor":return e.outdoor.find(i=>i.id===r)}}isFixedItem(e,n){return Gi(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((i,o)=>{let s=this.fixItem(o,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),i=f=>e.closest(`[${f}]`)?.getAttribute(f)??null,o=null,s=i("data-device"),l=i("data-opening"),a=e.closest("[data-vertex], [data-mid]")?null:i("data-furniture"),c=i("data-free-wall"),u=i("data-outdoor"),d=i("data-room")??this.roomAt(r);if(s?o=["device",s]:l?o=["opening",l]:a?o=["furniture",a]:c?o=["wall",c]:u&&!d?o=["outdoor",u]:d&&(o=["room",d]),!o){this._ctx=null;return}let[p,h]=o;this.selectItem(p,h),(p==="opening"||p==="furniture")&&(this.sel.room=this.sel.room??d),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"),i=Math.max(4,Math.min(e.x,(r?.clientWidth??800)-190)),o=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:${i}px;top:${o}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>`:_}
@@ -4604,7 +4605,7 @@ ${n.sources.map(r=>this.hass.states[r]?.attributes.symcon_path||this.hass.states
🔒 ${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,i,o){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 Mf(a,c,i,o?.01:this._doc.settings.grid)}selectItem(e,n){this.side.notice=null,n&&(this._sideOpen=!0),this.sel.select(e,n,{roomOfDevice:r=>{let i=this.floor?.placements.find(o=>o.entity_id===r);return(i&&this.roomAt([i.x,i.z]))??null},roomOfOpening:r=>this.floor?.openings.find(i=>i.id===r)?.room_id??null})}get opening(){let e=this.sel.opening?this.floor?.openings.find(i=>i.id===this.sel.opening):void 0;if(!e?.front||!this.floor)return e;let n=this.floor.rooms.find(i=>i.id===e.room_id),r=n?Zn(n,jt(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 i=null;for(let g of r.walls??[]){let b=Ce({room_id:"",edge:0,wall:g.id},r.rooms,r.walls??[]);if(!b)continue;let[y,v]=this.toScreen(g.a),[w,x]=this.toScreen(g.b),k=(w-y)**2+(x-v)**2||1,M=Math.min(1,Math.max(0,((n[0]-y)*(w-y)+(n[1]-v)*(x-v))/k)),A=Math.hypot(n[0]-y-(w-y)*M,n[1]-v-(x-v)*M),T=[(g.a[0]+g.b[0])/2,(g.a[1]+g.b[1])/2],F=r.rooms.find(L=>L.points.length>=3&&C(T,L.points));A<bs*2.2&&(!i||A-1<i.d)&&(i={room:b.room,edge:0,d:A-1,wall:g.id,roomId:F?.id??g.id})}for(let g of r.rooms)for(let b=0;b<g.points.length;b++){let[y,v]=this.toScreen(g.points[b]),[w,x]=this.toScreen(g.points[(b+1)%g.points.length]),k=(w-y)**2+(x-v)**2||1,M=Math.min(1,Math.max(0,((n[0]-y)*(w-y)+(n[1]-v)*(x-v))/k)),A=Math.hypot(n[0]-y-(w-y)*M,n[1]-v-(x-v)*M),T=A-(g.id===this.sel.room?.5:0);A<bs*2.2&&(!i||T<i.d)&&(i={room:g,edge:b,d:T})}if(!i)return!1;let{room:o,edge:s,wall:l}=i,a=o.points[s],c=o.points[(s+1)%o.points.length],u=Math.hypot(c[0]-a[0],c[1]-a[1]),d=Fn[e],p=d.type;if(d.style==="glass_wall"&&!l){let g=Ia(o,this.toWorld(...n)),b=Da(o,g-d.width/2,d.width);if(b&&b.length>1){let y=I("front"),v=b.map(w=>({id:I("opening"),room_id:i.roomId??o.id,edge:w.edge,offset:w.offset,width:w.width,front:y,type:p,sill:d.sill,height:d.height,hinge:"left",leaves:d.leaves,swing:"in",...Ji.has(d.style)?{}:{style:d.style},...d.opens?{opens:d.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=We(Math.min(d.width,Math.max(.3,u-.1))),f={id:I("opening"),room_id:i.roomId??o.id,edge:s,...l?{wall:l}:{},offset:this.dropOffset(o,s,this.toWorld(...n),h,!1),width:h,type:p,sill:d.sill,height:d.height,hinge:"left",leaves:d.leaves,swing:"in",...d.style&&!Ji.has(d.style)?{style:d.style}:{},...d.opens?{opens:d.opens}:{},cover:null,contact:null,contact2:null,tilt:null};return this.change((g,b)=>b.openings.push(f)),this._tool="select",this.selectItem("opening",f.id),!0}updateOpening(e){let n=this.sel.opening;this.change((r,i)=>{let o=i.openings.find(u=>u.id===n);if(!o)return;let s=jt(i.openings,o),l=o.wall?null:i.rooms.find(u=>u.id===o.room_id),a=l&&o.type==="window"&&o.style==="glass_wall"&&(e.width!=null||e.offset!=null),c=a&&l?Zn(l,s):null;if(a&&l&&c){let u=Math.max(.3,e.width??c.width),d=c.from;e.width!=null&&(d+=(c.width-u)/2),e.offset!=null&&(d+=e.offset-o.offset),d=Math.max(0,Math.min(ri(l)-u,d));let p=ii(i.openings,l,{...o,...e},d,u,()=>I("opening"));p&&(i.openings=p);return}for(let u of s)Object.assign(u,e)})}deleteOpening(){let e=this.sel.opening;!e||!this.isAdmin||!this.confirmFixedDelete("opening",e)||(this.change((n,r)=>{let i=r.openings.find(s=>s.id===e),o=new Set((i?jt(r.openings,i):[i]).map(s=>s?.id));r.openings=r.openings.filter(s=>!o.has(s.id))}),this.sel.opening=null)}snapToWall(e){return this.floor?Ir(this.floor,e,this._doc.settings.wall_interior):null}updateFurniture(e){let n=this.sel.furniture;this.change((r,i)=>Object.assign(i.furniture.find(o=>o.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(i=>i.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,i)=>Object.assign(i.placements.find(o=>o.entity_id===n),e))}closeFloorGaps(){let e=this.floor;if(!e||!this.isAdmin)return;let{rooms:n,gaps:r}=zd(e.rooms);if(!r.length){this.side.notice=this.t("gaps_none");return}let i=Pd(r);this.change((o,s)=>{s.rooms=n,i&&(o.settings.wall_interior=i)}),this.side.notice=i?this.t("gaps_closed_wall",{n:r.length,t:K(this.hass,i,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,i)=>Object.assign(i.rooms.find(o=>o.id===n),e))}render(){Wf(this._doc.settings.units);let e=this.floor,n=e?fe(e.rooms,Line truncated
</button>`}dropOffset(e,n,r,i,o){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 Mf(a,c,i,o?.01:this._doc.settings.grid)}selectItem(e,n){this.side.notice=null,n&&(this._sideOpen=!0),this.sel.select(e,n,{roomOfDevice:r=>{let i=this.floor?.placements.find(o=>o.entity_id===r);return(i&&this.roomAt([i.x,i.z]))??null},roomOfOpening:r=>this.floor?.openings.find(i=>i.id===r)?.room_id??null})}get opening(){let e=this.sel.opening?this.floor?.openings.find(i=>i.id===this.sel.opening):void 0;if(!e?.front||!this.floor)return e;let n=this.floor.rooms.find(i=>i.id===e.room_id),r=n?Zn(n,jt(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 i=null;for(let g of r.walls??[]){let b=Ce({room_id:"",edge:0,wall:g.id},r.rooms,r.walls??[]);if(!b)continue;let[y,v]=this.toScreen(g.a),[w,x]=this.toScreen(g.b),k=(w-y)**2+(x-v)**2||1,M=Math.min(1,Math.max(0,((n[0]-y)*(w-y)+(n[1]-v)*(x-v))/k)),A=Math.hypot(n[0]-y-(w-y)*M,n[1]-v-(x-v)*M),T=[(g.a[0]+g.b[0])/2,(g.a[1]+g.b[1])/2],F=r.rooms.find(L=>L.points.length>=3&&C(T,L.points));A<ys*2.2&&(!i||A-1<i.d)&&(i={room:b.room,edge:0,d:A-1,wall:g.id,roomId:F?.id??g.id})}for(let g of r.rooms)for(let b=0;b<g.points.length;b++){let[y,v]=this.toScreen(g.points[b]),[w,x]=this.toScreen(g.points[(b+1)%g.points.length]),k=(w-y)**2+(x-v)**2||1,M=Math.min(1,Math.max(0,((n[0]-y)*(w-y)+(n[1]-v)*(x-v))/k)),A=Math.hypot(n[0]-y-(w-y)*M,n[1]-v-(x-v)*M),T=A-(g.id===this.sel.room?.5:0);A<ys*2.2&&(!i||T<i.d)&&(i={room:g,edge:b,d:T})}if(!i)return!1;let{room:o,edge:s,wall:l}=i,a=o.points[s],c=o.points[(s+1)%o.points.length],u=Math.hypot(c[0]-a[0],c[1]-a[1]),d=Fn[e],p=d.type;if(d.style==="glass_wall"&&!l){let g=Oa(o,this.toWorld(...n)),b=Ia(o,g-d.width/2,d.width);if(b&&b.length>1){let y=I("front"),v=b.map(w=>({id:I("opening"),room_id:i.roomId??o.id,edge:w.edge,offset:w.offset,width:w.width,front:y,type:p,sill:d.sill,height:d.height,hinge:"left",leaves:d.leaves,swing:"in",...Ji.has(d.style)?{}:{style:d.style},...d.opens?{opens:d.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=We(Math.min(d.width,Math.max(.3,u-.1))),f={id:I("opening"),room_id:i.roomId??o.id,edge:s,...l?{wall:l}:{},offset:this.dropOffset(o,s,this.toWorld(...n),h,!1),width:h,type:p,sill:d.sill,height:d.height,hinge:"left",leaves:d.leaves,swing:"in",...d.style&&!Ji.has(d.style)?{style:d.style}:{},...d.opens?{opens:d.opens}:{},cover:null,contact:null,contact2:null,tilt:null};return this.change((g,b)=>b.openings.push(f)),this._tool="select",this.selectItem("opening",f.id),!0}updateOpening(e){let n=this.sel.opening;this.change((r,i)=>{let o=i.openings.find(u=>u.id===n);if(!o)return;let s=jt(i.openings,o),l=o.wall?null:i.rooms.find(u=>u.id===o.room_id),a=l&&o.type==="window"&&o.style==="glass_wall"&&(e.width!=null||e.offset!=null),c=a&&l?Zn(l,s):null;if(a&&l&&c){let u=Math.max(.3,e.width??c.width),d=c.from;e.width!=null&&(d+=(c.width-u)/2),e.offset!=null&&(d+=e.offset-o.offset),d=Math.max(0,Math.min(ri(l)-u,d));let p=ii(i.openings,l,{...o,...e},d,u,()=>I("opening"));p&&(i.openings=p);return}for(let u of s)Object.assign(u,e)})}deleteOpening(){let e=this.sel.opening;!e||!this.isAdmin||!this.confirmFixedDelete("opening",e)||(this.change((n,r)=>{let i=r.openings.find(s=>s.id===e),o=new Set((i?jt(r.openings,i):[i]).map(s=>s?.id));r.openings=r.openings.filter(s=>!o.has(s.id))}),this.sel.opening=null)}snapToWall(e){return this.floor?Ir(this.floor,e,this._doc.settings.wall_interior):null}updateFurniture(e){let n=this.sel.furniture;this.change((r,i)=>Object.assign(i.furniture.find(o=>o.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(i=>i.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,i)=>Object.assign(i.placements.find(o=>o.entity_id===n),e))}closeFloorGaps(){let e=this.floor;if(!e||!this.isAdmin)return;let{rooms:n,gaps:r}=zd(e.rooms);if(!r.length){this.side.notice=this.t("gaps_none");return}let i=Pd(r);this.change((o,s)=>{s.rooms=n,i&&(o.settings.wall_interior=i)}),this.side.notice=i?this.t("gaps_closed_wall",{n:r.length,t:K(this.hass,i,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,i)=>Object.assign(i.rooms.find(o=>o.id===n),e))}render(){Wf(this._doc.settings.units);let e=this.floor,n=e?fe(e.rooms,Line truncated
${gm(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":""}">