/*! 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 ko=globalThis,xo=ko.ShadowRoot&&(ko.ShadyCSS===void 0||ko.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ns=Symbol(),Ul=new WeakMap,hr=class{constructor(e,n,r){if(this._$cssResult$=!0,r!==ns)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(xo&&e===void 0){let r=n!==void 0&&n.length===1;r&&(e=Ul.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Ul.set(n,e))}return e}toString(){return this.cssText}},Zl=t=>new hr(typeof t=="string"?t:t+"",void 0,ns),re=(t,...e)=>{let n=t.length===1?t[0]:e.reduce((r,o,i)=>r+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(o)+t[i+1],t[0]);return new hr(n,t,ns)},ql=(t,e)=>{if(xo)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let r=document.createElement("style"),o=ko.litNonce;o!==void 0&&r.setAttribute("nonce",o),r.textContent=n.cssText,t.appendChild(r)}},rs=xo?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let r of e.cssRules)n+=r.cssText;return Zl(n)})(t):t;var{is:k_,defineProperty:x_,getOwnPropertyDescriptor:$_,getOwnPropertyNames:S_,getOwnPropertySymbols:M_,getPrototypeOf:R_}=Object,$o=globalThis,Yl=$o.trustedTypes,E_=Yl?Yl.emptyScript:"",A_=$o.reactiveElementPolyfillSupport,pr=(t,e)=>t,os={toAttribute(t,e){switch(e){case Boolean:t=t?E_: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}},Ql=(t,e)=>!k_(t,e),Xl={attribute:!0,type:String,converter:os,reflect:!1,useDefault:!1,hasChanged:Ql};Symbol.metadata??=Symbol("metadata"),$o.litPropertyMetadata??=new WeakMap;var _t=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=Xl){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(e,n),!n.noAccessor){let r=Symbol(),o=this.getPropertyDescriptor(e,r,n);o!==void 0&&x_(this.prototype,e,o)}}static getPropertyDescriptor(e,n,r){let{get:o,set:i}=$_(this.prototype,e)??{get(){return this[n]},set(s){this[n]=s}};return{get:o,set(s){let l=o?.call(this);i?.call(this,s),this.requestUpdate(e,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Xl}static _$Ei(){if(this.hasOwnProperty(pr("elementProperties")))return;let e=R_(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(pr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(pr("properties"))){let n=this.properties,r=[...S_(n),...M_(n)];for(let o of r)this.createProperty(o,n[o])}let e=this[Symbol.metadata];if(e!==null){let n=litPropertyMetadata.get(e);if(n!==void 0)for(let[r,o]of n)this.elementProperties.set(r,o)}this._$Eh=new Map;for(let[n,r]of this.elementProperties){let o=this._$Eu(n,r);o!==void 0&&this._$Eh.set(o,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let n=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let o of r)n.unshift(rs(o))}else e!==void 0&&n.push(rs(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 ql(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,n,r){this._$AK(e,r)}_$ET(e,n){let r=this.constructor.elementProperties.get(e),o=this.constructor._$Eu(e,r);if(o!==void 0&&r.reflect===!0){let i=(r.converter?.toAttribute!==void 0?r.converter:os).toAttribute(n,r.type);this._$Em=e,i==null?this.removeAttribute(o):this.setAttribute(o,i),this._$Em=null}}_$AK(e,n){let r=this.constructor,o=r._$Eh.get(e);if(o!==void 0&&this._$Em!==o){let i=r.getPropertyOptions(o),s=typeof i.converter=="function"?{fromAttribute:i.converter}:i.converter?.fromAttribute!==void 0?i.converter:os;this._$Em=o;let l=s.fromAttribute(n,i.type);this[o]=l??this._$Ej?.get(o)??l,this._$Em=null}}requestUpdate(e,n,r,o=!1,i){if(e!==void 0){let s=this.constructor;if(o===!1&&(i=this[e]),r??=s.getPropertyOptions(e),!((r.hasChanged??Ql)(i,n)||r.useDefault&&r.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(s._$Eu(e,r))))return;this.C(e,n,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,n,{useDefault:r,reflect:o,wrapped:i},s){r&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,s??n??this[e]),i!==!0||s!==void 0)||(this._$AL.has(e)||(this.hasUpdated||r||(n=void 0),this._$AL.set(e,n)),o===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(n){Promise.reject(n)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[o,i]of this._$Ep)this[o]=i;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[o,i]of r){let{wrapped:s}=i,l=this[o];s!==!0||this._$AL.has(o)||l===void 0||this.C(o,void 0,i,l)}}let e=!1,n=this._$AL;try{e=this.shouldUpdate(n),e?(this.willUpdate(n),this._$EO?.forEach(r=>r.hostUpdate?.()),this.update(n)):this._$EM()}catch(r){throw e=!1,this._$EM(),r}e&&this._$AE(n)}willUpdate(e){}_$AE(e){this._$EO?.forEach(n=>n.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(n=>this._$ET(n,this[n])),this._$EM()}updated(e){}firstUpdated(e){}};_t.elementStyles=[],_t.shadowRootOptions={mode:"open"},_t[pr("elementProperties")]=new Map,_t[pr("finalized")]=new Map,A_?.({ReactiveElement:_t}),($o.reactiveElementVersions??=[]).push("2.1.2");var ss=globalThis,Jl=t=>t,So=ss.trustedTypes,ec=So?So.createPolicy("lit-html",{createHTML:t=>t}):void 0,as="$lit$",bt=`lit$${Math.random().toFixed(9).slice(2)}$`,ls="?"+bt,F_=`<${ls}>`,qt=document,mr=()=>qt.createComment(""),gr=t=>t===null||typeof t!="object"&&typeof t!="function",cs=Array.isArray,sc=t=>cs(t)||typeof t?.[Symbol.iterator]=="function",is=`[ \f\r]`,fr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,tc=/-->/g,nc=/>/g,Ut=RegExp(`>|${is}(?:([^\\s"'>=/]+)(${is}*=${is}*(?:[^ \f\r"'\`<>=]|("|')|))|$)`,"g"),rc=/'/g,oc=/"/g,ac=/^(?:script|style|textarea|title)$/i,us=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),m=us(1),R=us(2),tx=us(3),Je=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),ic=new WeakMap,Zt=qt.createTreeWalker(qt,129);function lc(t,e){if(!cs(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return ec!==void 0?ec.createHTML(e):e}var cc=(t,e)=>{let n=t.length-1,r=[],o,i=e===2?"":e===3?"":"",s=fr;for(let l=0;l"?(s=o??fr,d=-1):u[1]===void 0?d=-2:(d=s.lastIndex-u[2].length,c=u[1],s=u[3]===void 0?Ut:u[3]==='"'?oc:rc):s===oc||s===rc?s=Ut:s===tc||s===nc?s=fr:(s=Ut,o=void 0);let h=s===Ut&&t[l+1].startsWith("/>")?" ":"";i+=s===fr?a+F_:d>=0?(r.push(c),a.slice(0,d)+as+a.slice(d)+bt+h):a+bt+(d===-2?l:h)}return[lc(t,i+(t[n]||"")+(e===2?"":e===3?"":"")),r]},_r=class t{constructor({strings:e,_$litType$:n},r){let o;this.parts=[];let i=0,s=0,l=e.length-1,a=this.parts,[c,u]=cc(e,n);if(this.el=t.createElement(c,r),Zt.currentNode=this.el.content,n===2||n===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(o=Zt.nextNode())!==null&&a.length0){o.textContent=So?So.emptyScript:"";for(let h=0;h2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=_}_$AI(e,n=this,r,o){let i=this.strings,s=!1;if(i===void 0)e=Yt(this,e,n,0),s=!gr(e)||e!==this._$AH&&e!==Je,s&&(this._$AH=e);else{let l=e,a,c;for(e=i[0],a=0;a{let r=n?.renderBefore??e,o=r._$litPart$;if(o===void 0){let i=n?.renderBefore??null;r._$litPart$=o=new wn(e.insertBefore(mr(),i),i,void 0,n??{})}return o._$AI(t),o};var ds=globalThis,Q=class extends _t{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=dc(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Je}};Q._$litElement$=!0,Q.finalized=!0,ds.litElementHydrateSupport?.({LitElement:Q});var z_=ds.litElementPolyfillSupport;z_?.({LitElement:Q});(ds.litElementVersions??=[]).push("4.2.2");var ps=t=>t.slice(0,t.indexOf(".")),P_={light:"light",switch:"switch",input_boolean:"switch",valve:"switch",fan:"fan",cover:"cover",climate:"climate",media_player:"media",lock:"lock",sensor:"sensor",binary_sensor:"binary",event:"sensor",scene:"scene",script:"script"},X=t=>P_[ps(t)]??null,fs=["light","cover","climate","media","switch","fan","lock","binary","sensor","scene","script"];var hc=new Set(["light","switch","fan"]),Rt=t=>t!==null&&t!=="scene"&&t!=="script",et=t=>!t||t.state==="unavailable"||t.state==="unknown"&&!t.entity_id.startsWith("event.");function W(t,e,n){let r=String(t?.states[e]?.attributes.friendly_name??t?.entities?.[e]?.name??e);if(!n||r.length<=n.length+1||!r.toLowerCase().startsWith(`${n.toLowerCase()} `))return r;let o=r.slice(n.length+1);return o[0].toUpperCase()+o.slice(1)}var pc=t=>!!t&&t.entity_id.startsWith("sensor.")&&t.attributes.device_class==="enum";var fc=t=>Math.min(1,Math.max(0,t));function D_(t){let e=fc((t-2200)/4300),n=[1,.66,.26],r=[.78,.9,1];return[0,1,2].map(o=>n[o]+(r[o]-n[o])*e)}function hs(t,e){if(!t||t.state!=="on")return null;let n=e&&!["unavailable","unknown"].includes(e.state)?e.attributes:t.attributes,r=typeof n.brightness=="number"?.2+.8*Math.sqrt(fc(n.brightness/255)):1,o=n.rgb_color;return o&&!["color_temp","brightness","onoff"].includes(String(n.color_mode))?{color:[o[0]/255,o[1]/255,o[2]/255],level:r}:typeof n.color_temp_kelvin=="number"?{color:D_(n.color_temp_kelvin),level:r}:{color:[1,.71,.28],level:r}}function mc(t,e,n){let r=hs(t,n);if(r)return r;for(let o of e){let i=hs(o);if(i)return{color:i.color,level:i.level*.6}}return null}function To(t,e,n=null){if(t==="light"&&n==="floor")return 1.95;if(t==="light"&&n==="table")return 1.25;if(t==="light"&&n==="wall")return 1.95;switch(t){case"light":return Math.max(.5,e-.25);case"cover":return Math.min(2,e-.3);case"climate":return .6;case"media":return .9;case"binary":case"sensor":return 1.4;default:return 1.05}}var yc=[],zo=new Map,I_=0,de=(t,e)=>`pack:${t}:${e}`,yt=t=>t.startsWith("pack:");function ms(t){yc=t,zo=new Map;for(let e of t)for(let n of e.items)zo.set(de(e.id,n.id),n);I_+=1}var yr=()=>yc;var O_={};function j(t){if(!yt(t))return;let e=zo.get(t);if(e)return e;let[,n,...r]=t.split(":"),o=O_[n];return o?zo.get(de(o,r.join(":"))):void 0}var H_=.22;function gc(t,e,n,r){let o=Math.min(H_,n/3);if(r<=o*2.4||Math.abs(r-n)<1e-6)return e*(r/n)+(t-e)*(r/n);let i=e*(r/n),s=t-e;return s<=o?i+s:s>=n-o?i+r-(n-s):i+o+(s-o)*(r-2*o)/(n-2*o)}function br(t,e,n,r,o){return[gc(t*r,n*r,r,o)/o,gc(e*r,n*r,r,o)/o]}var _c=new WeakMap;function vc(t,e,n,r){let[o,i,s]=t.size;if(t.vehicle||t.stretch||Math.abs(e-o)<1e-4&&Math.abs(n-i)<1e-4&&Math.abs(r-s)<1e-4)return t.parts;let l=`${e.toFixed(4)}|${n.toFixed(4)}|${r.toFixed(4)}`,a=_c.get(t),c=a?.get(l);if(c)return c;let u=t.parts.map(d=>{if(d.shape==="sweep")return d;let[p,h]=br(d.x-d.w/2,d.x+d.w/2,-.5,o,e),[f,g]=br(d.z-d.d/2,d.z+d.d/2,-.5,i,n),[y,b]=br(d.y,d.y+d.h,0,s,r);if(d.rot)return{...d,x:(p+h)/2,z:(f+g)/2,w:d.w*o/e,d:d.d*i/n,y,h:b-y};let v={...d,x:(p+h)/2,z:(f+g)/2,w:h-p,d:g-f,y,h:b-y};if(d.shape==="loft"){let[w,x,k,M]=[d.tx??d.x,d.tz??d.z,d.tw??d.w,d.td??d.d],[A,F]=br(w-k/2,w+k/2,-.5,o,e),[T,O]=br(x-M/2,x+M/2,-.5,i,n);Object.assign(v,{tx:(A+F)/2,tz:(T+O)/2,tw:F-A,td:O-T})}return v});return a||_c.set(t,a=new Map),a.size>32&&a.clear(),a.set(l,u),u}var gs=t=>!!t?.parts.some(e=>e.move);var wc=t=>j(t)?.parts.find(e=>e.screen),bc=.06;function kc(t){let e=j(t);if(!e)return!1;let[n,r,o]=e.size;return e.parts.filter(i=>i.screen).some(i=>{let[s,l]=[i.w*n,i.d*r,i.h*o].sort((a,c)=>c-a);return l>=bc&&s>=bc})}function ut(t){return tt[t]??j(t)?.size??[.6,.6,.8]}function Et(t){let e=j(t);return Fc.has(t)||!!e?.electric||!!e?.light||!!e?.climate}var xc=t=>!!j(t)?.parts.some(e=>e.picture),kn=t=>!!j(t)?.climate;function $c(t,e){return t.name[e.split("-")[0]]??t.name.en??Object.values(t.name)[0]??t.id}var L_={wohnen:"Living & Pets",kino:"Home Cinema & Gaming",kueche:"Kitchen Extras",bad:"Bathroom Extras",schlafen:"Bedroom & Kids",technik:"Office & Homelab",energie:"Energy & Building Services",garten:"Garden & Terrace (older)",fitness:"Fitness (older)",fahrzeuge:"Vehicles",ikea:"IKEA sizes",treppen:"Stairs & railings",ausbau:"Architecture & fit-out",werkstatt:"Garage & workshop",a_wohnzimmer:"Living room",a_schlafzimmer:"Bedroom",a_kueche:"Kitchen",a_bad:"Bathroom",a_kinderzimmer:"Kids' room",a_buero:"Office & gaming",a_fitness:"Fitness",a_haustiere:"Pets",a_garten:"Garden & patio",a_kino:"Home cinema & hi-fi",a_smart:"Smart home & tech",a_haustechnik:"Utility & building services",a_saison:"Season & decoration",a_smart2:"Smart home 2",a_haustechnik2:"Building services 2",a_wellness:"Wellness",a_garten2:"Garden 2",a_kueche2:"Kitchen 2",a_fahrzeuge2:"Vehicles 2",a_aussenkueche:"Outdoor kitchen & terrace",a_werkstatt2:"Workshop 2",a_japandi:"Japandi & Scandi",a_loft:"Loft & industrial",a_gruen:"Indoor greenery",a_musik:"Music & studio",a_bilder:"Pictures & frames"};function Sc(t,e){if(e.split("-")[0]==="de")return t.name;let n=/^nextfloor\.(.+)$/.exec(t.id)?.[1];return n&&L_[n]||t.name}function At(t,e){return e.mount_y!=null?e.mount_y:N_(t,e)+(C_(e)?0:Ec(t,e.x,e.z))}var C_=t=>t.type==="led_strip"||j(t.type)?.mount==="ceiling";function N_(t,e){if(e.type==="lamp_wall")return Mc;if(e.type==="led_strip")return Math.max(0,dt(t,e.x,e.z)-.04-Math.max(.02,e.h));let n=j(e.type);if(!n)return Rc(e);switch(n.mount){case"surface":return Ac(t,e.x,e.z);case"wall":return n.wall_y??1;case"ceiling":return Math.max(0,Po(t,e)-e.h);default:return 0}}function _s(t){if(t==="plant")return"plant";let e=j(t);return e?e.household?e.household:/monstera|plant|herb_garden|flower_pots|bonsai|ficus|cactus|kaktus/.test(e.id)?"plant":null:null}var Tc=["condition","temperature","humidity","pressure","wind_speed","wind_gust_speed","wind_bearing","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility","snow","fog","lightning"],zc=["turn","slide","top"],Pc=["always","active","no_power","never"],Dc=1.3,Do=(t,e=new Date().toISOString().slice(0,10))=>!!t.due&&t.due<=e,Ic=["gable","hip","halfhip","pyramid","mansard","pent","flat","parapet"],Oc=["brick","round","wide","steel"],Io=["navigate","more_info","service","fire_dom_event"];function Oo(t,e,n){return t?e?!!n.lock_plan:!!t.locked:!1}var Hc=["rain","snow","fog","clouds","lightning","sky"],Lc=["rain","snow","clouds","lightning","sky"],Cc=["lawn","terrace","path","driveway","pool","bed","wild","hedge","fence","pergola"],bs={lawn:.012,terrace:.12,path:.02,driveway:.02,pool:-.25,bed:.15,wild:.03,hedge:1.2,fence:1,pergola:2.2};function ys(t){return t==="hedge"||t==="fence"||t==="pergola"}var Nc=["x","-x","z","-z"];function B_(t,e,n){let r=t.slope??0;if(!r||t.type==="pool")return 0;let o=t.slope_dir??"x",i=(c,u)=>o==="x"?c:o==="-x"?-c:o==="z"?u:-u,s=1/0,l=-1/0;for(let[c,u]of t.points){let d=i(c,u);s=Math.min(s,d),l=Math.max(l,d)}if(l-s<1e-6)return 0;let a=Math.min(1,Math.max(0,(i(e,n)-s)/(l-s)));return r*a}function W_(t,e,n,r){return Bc(t)+(e.offset??0)+bs[e.type]-B_(e,n,r)}function Bc(t){return t.elevation>.3?0:-.2}function Wc(t,e,n){let r=(t.outdoor??[]).filter(i=>!ys(i.type)&&i.type!=="pool"&&N([e,n],i.points)),o=[...r].reverse().find(i=>i.cut)??r[0];return o?W_(t,o,e,n):Bc(t)}var Vc=t=>t.cut??t.type==="pool",Kc=30,Gc={meter:null,grid:null,grid_invert:!1,solar:null,battery:null,battery_invert:!1,battery_soc:null,consumption:null,tariff:null},jc=["wood","oak","tiles","carpet","stone","concrete"],Uc={type:"none",pitch:35,overhang:.4},Ho="#d6cfc2",Lo="#e8e3da",Zc={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...Uc}};function Ft(){return{version:1,floors:[],settings:{...Zc},energy:{...Gc},presence:[]}}function Ce(t,e,n){return{id:t,name:e,elevation:n,height:2.5,cut_height:1.15,rooms:[],openings:[],furniture:[],placements:[],background:null,outdoor:[],walls:[],ha_floor:null}}var V_=2.75;function qc(t,e){if(e!=null&&Number.isFinite(e))return Math.round(e*V_*100)/100;let n=t.reduce((r,o)=>!r||o.elevation>r.elevation?o:r,null);return n?Math.round((n.elevation+n.height+.25)*100)/100:0}function Yc(t,e,n){let r=t.rooms.flatMap(l=>l.points.map(a=>a[0])),o=t.rooms.flatMap(l=>l.points.map(a=>a[1])),i=r.length?Math.ceil(Math.max(...r))+1:0,s=o.length?Math.floor(Math.min(...o)):0;return e.map((l,a)=>{let c=i+a%3*4.5,u=s+Math.floor(a/3)*3.5;return{id:n(),name:l.name,area_id:l.area_id,points:[[c,u],[c+4,u],[c+4,u+3],[c,u+3]],floor_material:"wood"}})}function Xc(t,e,n,r){let o=t.rotation*Math.PI/180,i=Math.cos(o),s=Math.sin(o),[l,a]=e,c=t.x-l*(t.w/2)*i+a*(t.d/2)*s,u=t.z-l*(t.w/2)*s-a*(t.d/2)*i,d=n[0]-c,p=n[1]-u,h=b=>Math.max(.1,Math.round(b/r)*r),f=h((d*i+p*s)*l),g=h((-d*s+p*i)*a),y=b=>Math.round(b*1e3)/1e3;return{x:y(c+l*(f/2)*i-a*(g/2)*s),z:y(u+l*(f/2)*s+a*(g/2)*i),w:y(f),d:y(g)}}var Co=["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan","lamp_floor","lamp_table","lamp_wall","led_strip","lamp_uplight","lamp_bollard","lamp_garden","radiator","sofa","armchair","stool","coffee_table","tv_board","tv_wall","sideboard","shelf","plant","rug","table","table_round","chair","bench","corner_bench","bar_stool","kitchen","kitchen_wall","kitchen_tall","island","worktop","sink","stove","dishwasher","fridge","bed","bunk_bed","nightstand","wardrobe","dresser","bathtub","shower","wc","washbasin","washer","dryer","desk","office_chair","tall_cabinet","coat_rack","stairs","robot_vacuum","inverter","home_battery","wallbox","meter","grid_point","parking","fridge_smart","stairwell"],Qc={lights:["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan","lamp_floor","lamp_uplight","lamp_table","lamp_wall","led_strip","lamp_bollard","lamp_garden"],living:["sofa","armchair","stool","coffee_table","tv_board","tv_wall","sideboard","shelf","plant","rug"],dining:["table","table_round","chair","bench","corner_bench","bar_stool"],kitchen:["kitchen","kitchen_wall","kitchen_tall","island","worktop","sink","stove","dishwasher","fridge"],sleeping:["bed","bunk_bed","nightstand","wardrobe","dresser"],bath:["bathtub","shower","wc","washbasin","washer","dryer"],work:["desk","worktop","office_chair","tall_cabinet","coat_rack","radiator","stairs","robot_vacuum"],vehicles:["parking"]},Ne=["meter","inverter","home_battery","wallbox","grid_point"],Jc=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan","lamp_floor","lamp_uplight","lamp_table","lamp_wall","led_strip","lamp_bollard","lamp_garden"]),Mc=1.75;function No(t){return vs.has(t.type)||["stairwell","parking"].includes(t.type)?!1:j(t.type)?.mount!=="ceiling"}function ce(t){return Jc.has(t)||!!j(t)?.light}var K_=new Set(["table","table_round","coffee_table","desk","nightstand","sideboard","dresser","kitchen","island","worktop","tv_board","dishwasher","washer","dryer"]);function eu(t,e,n,r=0){let o=ue(t.points),i=o.x1-o.x0-2*r,s=o.z1-o.z0-2*r,l=[];for(let a=0;aMath.round(s*1e3)/1e3,[o,i]={right:[1,0],down:[0,1],left:[-1,0],up:[0,-1]}[n];return[r(t[0]+o*e),r(t[1]+i*e)]}function Rc(t){switch(t.type){case"home_battery":return t.variant==="wall"?.5:0;case"kitchen_wall":return 1.45;case"tv_wall":return Math.max(0,1.3-t.h/2);case"radiator":return .12;case"inverter":return 1.1;case"wallbox":return 1;case"meter":return .4;default:return 0}}var vs=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function tu(t,e){return t.filter(n=>n.elevationn.rooms.filter(r=>r.points.length>=3&&r.ceiling!=null&&r.ceiling>n.height+.005&&n.elevation+r.ceiling>e.elevation+.05)).map(n=>n.points)}var ws=t=>t?.floor_offset&&Number.isFinite(t.floor_offset)?t.floor_offset:0;function Ec(t,e,n){let r=t.rooms.find(o=>o.points.length>=3&&o.floor_offset&&N([e,n],o.points));return ws(r)}function dt(t,e,n){let r=t.rooms.find(o=>o.points.length>=3&&N([e,n],o.points));return r?.ceiling!=null&&r.ceiling>0?r.ceiling:t.height}var Po=(t,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:dt(t,e.x,e.z);function Ac(t,e,n){let r=0;for(let o of t.furniture)!(K_.has(o.type)||j(o.type)?.surface)||!N([e,n],Ss(o))||(r=Math.max(r,o.h));return r}var Fc=new Set([...Jc,"radiator","robot_vacuum","inverter","home_battery","wallbox","meter","tv_board","tv_wall","desk","fridge","fridge_smart","stove","kitchen_tall","dishwasher","washer","dryer","kitchen","island","sink"]),tt={sofa:[2.2,.9,.82],armchair:[.85,.85,.8],table:[1.6,.9,.75],chair:[.46,.5,.9],bed:[1.6,2.05,.9],nightstand:[.45,.4,.5],wardrobe:[1.8,.6,2.1],shelf:[.9,.35,1.9],kitchen:[2.4,.62,.92],worktop:[1.2,.62,.91],inverter:[.5,.2,.65],home_battery:[.6,.25,1.1],wallbox:[.3,.15,.42],meter:[.55,.21,1.1],grid_point:[.4,.22,.6],fridge:[.6,.65,1.8],fridge_smart:[.91,.73,1.78],stairwell:[1,2.6,.02],stove:[.6,.62,.92],sink:[.9,.62,.92],bathtub:[1.7,.75,.58],shower:[.9,.9,2],wc:[.38,.6,.8],washbasin:[.6,.46,.85],desk:[1.4,.7,.75],tv_board:[1.8,.42,.5],plant:[.45,.45,1.1],rug:[2,1.4,.01],stairs:[1,3.2,2.75],stool:[.55,.55,.42],lamp_ceiling:[.4,.4,.08],lamp_downlight:[.1,.1,.02],lamp_spot:[.1,.1,.14],lamp_panel:[.6,.6,.03],lamp_uplight:[.35,.35,1.8],lamp_bollard:[.16,.16,.8],lamp_garden:[.12,.12,.3],radiator:[1,.1,.6],robot_vacuum:[.36,.5,.1],parking:[2.6,5.2,.02],lamp_pendant:[.4,.4,.8],ceiling_fan:[1.32,1.32,.32],lamp_floor:[.4,.4,1.7],lamp_table:[.28,.28,.45],lamp_wall:[.22,.12,.2],led_strip:[2,.04,.03],coffee_table:[1.1,.6,.42],tv_wall:[1.3,.08,.75],sideboard:[1.6,.45,.8],table_round:[1.1,1.1,.75],bench:[1.4,.45,.85],corner_bench:[2,1.6,.9],bar_stool:[.42,.42,.75],kitchen_wall:[.8,.35,.7],kitchen_tall:[.6,.62,2.1],island:[1.8,.9,.92],dishwasher:[.6,.62,.92],bunk_bed:[1,2.05,1.65],dresser:[1,.5,.9],washer:[.6,.6,.85],dryer:[.6,.6,.85],office_chair:[.65,.65,1.1],tall_cabinet:[.6,.6,2.1],coat_rack:[1,.35,1.9]};var ks=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],xs=["standard","bars","glass_wall"],Bo=new Set(["interior","front"]);function Qt(t,e){return t.type==="door"?t.style&&ks.includes(t.style)?t.style:e?"front":"interior":t.style&&xs.includes(t.style)?t.style:"standard"}function nu(t,e,n,r){if(e!=="sidelight"&&e!=="sidelights")return null;let o=e==="sidelights",i=t-.04,s=Math.min(1.05,Math.max(.6,i-(o?.6:.3))),l=(i-s)/(o?2:1),a=r.sidelight_width??l,c=o?r.sidelight_width2??r.sidelight_width??l:0;a=Math.max(.1,a),c=o?Math.max(.1,c):0;let u=i-.5;if(a+c>u){let p=Math.max(0,u)/(a+c);a*=p,c*=p}return o?{panels:[[.02,.02+a],[t-.02-c,t-.02]],x0:.02+a,x1:t-.02-c}:(n?!!r.sidelight_hinge:!r.sidelight_hinge)?{panels:[[.02,.02+a]],x0:.02+a,x1:t-.02}:{panels:[[t-.02-a,t-.02]],x0:.02,x1:t-.02-a}}function $s(t){return t==="front"||t==="front_glass"||t==="sidelight"||t==="sidelights"}var $n={door:{type:"door",leaves:1,width:.9,sill:0,height:2.05,style:"interior"},front:{type:"door",leaves:1,width:1,sill:0,height:2.1,style:"front"},door_double:{type:"door",leaves:2,width:1.6,sill:0,height:2.05},window:{type:"window",leaves:1,width:1.2,sill:.9,height:1.3},window_double:{type:"window",leaves:2,width:1.6,sill:.9,height:1.3},terrace:{type:"window",leaves:1,width:1,sill:0,height:2.1},terrace_double:{type:"window",leaves:2,width:1.8,sill:0,height:2.1},lift_slide:{type:"window",leaves:1,width:2.4,sill:0,height:2.15,opens:"slide"},garage:{type:"garage",leaves:1,width:2.5,sill:0,height:2.1},glass_wall:{type:"window",leaves:1,width:2,sill:0,height:2.4,style:"glass_wall"}};function Sn(t){if(t.type==="garage")return"garage";if(t.type==="window"&&t.style==="glass_wall")return"glass_wall";if(t.type==="window"&&t.opens==="slide"&&t.sill<.1)return"lift_slide";let e=t.leaves===2;return t.type==="door"?!e&&t.style&&$s(t.style)?"front":e?"door_double":"door":t.sill<.1?e?"terrace_double":"terrace":e?"window_double":"window"}function Pe(t){t.energy={...Gc,...t.energy??{}},t.presence=t.presence??[],t.version=1,t.settings={...Zc,...t.settings,roof:{...Uc,...t.settings?.roof??{}}},t.floors.forEach((e,n)=>{let r=Ce(e.id,e.name??`Floor ${n+1}`,e.elevation??n*2.8);for(let o of Object.keys(r))e[o]===void 0&&(e[o]=r[o])});for(let e of t.floors){e.outdoor=e.outdoor??[],e.walls=e.walls??[],e.rooms=e.rooms.map(r=>({...r,name:r.name??"",area_id:r.area_id??null,floor_material:r.floor_material??"wood",panel:r.panel??[]})),e.ha_floor=e.ha_floor??null,e.placements=e.placements.map(r=>({...r,mount:r.mount??null,rotation:r.rotation??0})),e.furniture=e.furniture.map(r=>({...r,entity:r.entity??null,power:r.power??null}));let n=e.placements.filter(r=>r.entity_id.startsWith("light."));if(n.length){let r={ceiling:"lamp_ceiling",floor:"lamp_floor",table:"lamp_table",wall:"lamp_wall"};for(let o of n){let i=r[o.mount??"ceiling"],[s,l,a]=tt[i],c=`lamp_${o.entity_id.slice(6).replace(/[^A-Za-z0-9_\-.]/g,"_")}`.slice(0,54),u=c,d=1;for(;e.furniture.some(p=>p.id===u);)u=`${c}_${d++}`;e.furniture.push({id:u,type:i,x:o.x,z:o.z,rotation:0,w:s,d:l,h:a,variant:null,entity:o.entity_id,power:null,animations_enabled:o.animations_enabled,effect_animations:structuredClone(o.effect_animations)})}e.placements=e.placements.filter(o=>!o.entity_id.startsWith("light."))}e.openings=e.openings.map(r=>({...r,type:["door","window","garage"].includes(r.type)?r.type:"door",edge:Number.isInteger(r.edge)?r.edge:0,offset:Number.isFinite(r.offset)?r.offset:.5,width:Number.isFinite(r.width)&&r.width>0?r.width:r.type==="garage"?2.5:r.type==="window"?1.2:.9,height:Number.isFinite(r.height)&&r.height>0?r.height:r.type==="window"?1.3:r.type==="garage"?2.1:2.05,sill:Number.isFinite(r.sill)?r.sill:r.type==="window"?.9:0,hinge:r.hinge??"left",leaves:r.leaves??1,swing:r.swing??"in",style:r.style??null,cover:r.cover??null,contact:r.contact??null,contact2:r.contact2??null,tilt:r.tilt??null}))}return G_(t),t}function G_(t){let e=(n,r)=>{let o=new Set;for(let i of n)(typeof i.id!="string"||!i.id||o.has(i.id))&&(i.id=D(r)),o.add(i.id)};e(t.floors,"floor");for(let n of t.floors){for(let r of n.rooms)(typeof r.id!="string"||!r.id)&&(r.id=D("room"));e(n.openings,"op"),e(n.furniture,"furn"),e(n.outdoor,"out")}}function D(t){return`${t}_${Math.random().toString(36).slice(2,10)}`}function _e(t){let e=0;for(let n=0;ni+s[0],0)/o,t.reduce((i,s)=>i+s[1],0)/o]}let n=0,r=0;for(let o=0;o1e-6&&Math.abs(r-i)>1e-6)return!1}return!0}function ue(t){let e=1/0,n=1/0,r=-1/0,o=-1/0;for(let[i,s]of t)e=Math.min(e,i),n=Math.min(n,s),r=Math.max(r,i),o=Math.max(o,s);return{x0:e,z0:n,x1:r,z1:o}}function Ss(t){let e=t.rotation*Math.PI/180,n=Math.cos(e),r=Math.sin(e),o=t.w/2,i=t.d/2;return[[-o,-i],[o,-i],[o,i],[-o,i]].map(([s,l])=>[t.x+s*n-l*r,t.z+s*r+l*n])}function N(t,e){let n=!1;for(let r=0,o=e.length-1;rt[1]!=a>t[1]&&t[0]<(l-i)*(t[1]-s)/(a-s)+i&&(n=!n)}return n}var Wo={lamp_ceiling:"ceiling",lamp_downlight:"downlight",lamp_spot:"spot",lamp_panel:"panel",lamp_uplight:"uplight",lamp_bollard:"bollard",lamp_garden:"garden",lamp_pendant:"pendant",ceiling_fan:"fan",lamp_floor:"floor",lamp_table:"table",lamp_wall:"wall",led_strip:"strip"};var Ms=t=>t.trim().replace(/^\/local\/www\//i,"/local/"),Rs=t=>/^(https:\/\/|\/local\/|\/hacsfiles\/)\S+\.m?js(\?\S*)?$/i.test(t.trim());var U_=globalThis,ou=U_.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},Es=ou.plugins,ru=ou.listeners;var Z_=5;function iu(t,e){t.errors.lengthru.delete(t)}var As=()=>[...Es.values()].map(t=>t.status),su=()=>[...Es.values()].flatMap(t=>Object.keys(t.plugin.lightAnimations??{}));function*Ko(t,e){for(let{plugin:n,status:r}of Es.values())for(let o of n.devices??[]){let i=!1;try{i=o.match(t,e)}catch(s){iu(r,s)}i&&(yield{device:o,status:r})}}function Go(t,e){for(let{device:n}of Ko(t,e))return n.kind??"sensor";return null}function au(t,e){let n=t.states[e];if(!n)return null;let r=q_({hass:t,entityId:e,state:n})?.icon?.trim();return r&&/^mdi:[a-z0-9-]+$/i.test(r)?r:null}function q_(t){let e=null;for(let{device:n,status:r}of Ko(t.entityId,t.state))if(n.marker)try{let o=n.marker(t);if(!o)continue;e={...e??{}},typeof o.icon=="string"&&o.icon&&(e.icon=o.icon),typeof o.text=="string"&&(e.text=o.text.slice(0,60)),typeof o.active=="boolean"&&(e.active=o.active)}catch(o){iu(r,o)}return e}function jo(t,e){return t?typeof t=="string"?t:t[e]??t[e.split("-")[0]]??t.en??Object.values(t)[0]??"":""}function lu(t,e){let n=[];for(let{device:r,status:o}of Ko(t,e))r.settings?.length&&n.push({pluginId:o.id,name:o.name,settings:r.settings});return n}function cu(t,e){let n={};for(let r of t??[]){let o=e?.[r.key],i=r.type==="number"?typeof o=="number"&&Number.isFinite(o):r.type==="boolean"?typeof o=="boolean":typeof o=="string"&&(r.options??[]).some(([s])=>s===o);n[r.key]=i?o:r.default}return n}function uu(t,e){for(let{device:n}of Ko(t,e))if(n.floorWedge)return!0;return!1}var Y_=new Set(["temperature","humidity","power","carbon_dioxide","energy","gas","water","volume","volume_storage","volume_flow_rate","illuminance","pressure","atmospheric_pressure","pm1","pm25","pm10","volatile_organic_compounds","volatile_organic_compounds_parts","carbon_monoxide","nitrogen_dioxide","moisture","sound_pressure"]),X_=new Set(["m\xB3","m3","L","l","kWh","Wh","MWh","lx"]),Q_=new Set(["door","window","opening","garage_door","motion","occupancy","presence","smoke","moisture","gas","carbon_monoxide"]),J_=new Set(["battery","signal_strength","timestamp","date","duration","data_rate","data_size","frequency","enum"]);function Tt(t,e){let n=t.entities?.[e];return n&&(n.area_id||(n.device_id?t.devices?.[n.device_id]?.area_id:null))||null}var hu=(t,e)=>{let n=t.entities?.[e];return!!(n?.hidden||n?.entity_category)},Be=(t,e)=>X(e)??Go(e,t.states[e]);function du(t,e){let n=t.states[e];if(!n||hu(t,e))return!1;if(Go(e,n)!==null)return!0;let r=X(e);if(!r)return!1;let o=n.attributes.device_class;return e.startsWith("event.")?!o||o==="button"||o==="doorbell":r==="sensor"?o?Y_.has(o):X_.has(String(n.attributes.unit_of_measurement??"")):r==="binary"?o?Q_.has(o):!!t.entities?.[e]?.area_id:!0}function eb(t,e){let n=t.states[e];return X(e)!=="sensor"||!n?.attributes.unit_of_measurement||hu(t,e)||J_.has(String(n.attributes.device_class??""))?!1:Number.isFinite(Number(n.state))||et(n)}var Zo=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power",Fs=null;Vo(()=>Fs=null);function Ts(t,e){let n=t.get(e);return n||t.set(e,n=[]),n}function tb(t){let e=new Map,n=new Map,r=new Map,o=new Map,i=[],s=u=>{(du(t,u)||eb(t,u))&&Rt(Be(t,u))&&i.push(u)};for(let[u,d]of Object.entries(t.entities??{})){let p=d.device_id;p&&d.area_id&&(o.get(p)??o.set(p,new Set).get(p)).add(d.area_id),p&&Zo(t,u)&&Ts(n,p).push(u),p&&!d.hidden&&!d.entity_category&&(r.get(p)??r.set(p,new Set).get(p)).add(ps(u));let h=Tt(t,u);h===null?s(u):du(t,u)&&Ts(e,h).push(u)}if(t.entities)for(let u of Object.keys(t.states))t.entities[u]||s(u);let l=fs.indexOf("binary")-.5,a=u=>{let d=X(u),p=d?fs.indexOf(d):l;return p>l&&Go(u,t.states[u])!==null?l:p};i.sort((u,d)=>a(u)-a(d)||W(t,u).localeCompare(W(t,d)));for(let[u,d]of e){let p=t.areas?.[u]?.name;d.sort((h,f)=>a(h)-a(f)||W(t,h,p).localeCompare(W(t,f,p)))}let c=new Set;for(let[u,d]of o)d.size>1&&c.add(u);return{entities:t.entities,devices:t.devices,states:t.states,stateCount:Object.keys(t.states).length,byArea:e,powerByDevice:n,withoutArea:i,domainsByDevice:r,hubs:c}}function Rn(t){let e=Fs;return e&&e.entities===t.entities&&e.devices===t.devices&&(e.states===t.states||(e.states=t.states,Object.keys(t.states).length===e.stateCount))?e:Fs=tb(t)}function ye(t,e){let n=Uo(t,e.area_id);return e.sub_areas?.length?[...new Set([...n,...e.sub_areas.flatMap(r=>Uo(t,r))])]:n}function Uo(t,e){return!e||!t.entities?[]:Rn(t).byArea.get(e)??[]}function pu(t,e){if(!t.entities)return[];let n=[];for(let[r,o]of Rn(t).byArea){let i=o.filter(s=>Rt(Be(t,s)));r!==e&&i.length>0&&n.push({areaId:r,name:t.areas?.[r]?.name??r,ids:i})}return n.sort((r,o)=>r.name.localeCompare(o.name))}var fu=t=>t.entities?Rn(t).withoutArea:[],zs=(t,e)=>!!t.entities&&Rn(t).hubs.has(e),qo=(t,e)=>t.entities?Rn(t).powerByDevice.get(e)??[]:[];function En(t,e){let n=new Map;for(let o of e)Ts(n,t.entities?.[o]?.device_id??`entity:${o}`).push(o);let r=new Map(e.map((o,i)=>[o,i]));return[...n.values()].map(o=>{let i=o.find(s=>!t.entities?.[s]?.name)??o[0];return{primary:i,others:o.filter(s=>s!==i)}}).sort((o,i)=>r.get(o.primary)-r.get(i.primary))}var Yo=(t,e)=>En(t,e).map(n=>n.primary),nb={temperature:"temperature",humidity:"humidity",co2:"carbon_dioxide",illuminance:"illuminance"};function Ps(t,e,n,r=!1){let o=t.states[e]?.attributes;if(!o)return!1;let i=(o.symcon_variable_type===1||o.symcon_variable_type===2)&&typeof o.symcon_id=="number";if(typeof o.symcon_id=="number"&&!i||!i&&!/^(sensor|input_number|number)\./.test(e))return!1;if(r&&i)return!0;let s=String(o.unit_of_measurement??"").replace(/\s/g,"").toLowerCase();return n==="temperature"&&["\xB0c","\xB0f","\u2103","\u2109","k"].includes(s)||n==="humidity"&&!o.device_class&&["%","%rh","%r.h.","%rf","%r.f."].includes(s)||n==="co2"&&s==="ppm"&&/co[₂2]/i.test(String(o.friendly_name??""))||n==="illuminance"&&["lx","lux"].includes(s)?!0:o.device_class===nb[n]}var rb=new Set(["climate","water_heater","switch","button","camera","media_player","vacuum","light","fan","lawn_mower"]),ob=["vorlauf","r(\xFC|ue)cklauf","flow","return","d(\xFC|ue)se","nozzle","hotend","extruder","druckbett","heatbed","(^|[^a-z])bed($|[^a-z])","chamber","cpu","gpu","chip","soc","akku","batter","wasser","water","kessel","boiler","au(\xDF|ss)en","outdoor","outside","abgas","exhaust","sole","brine","verdampfer","kondensat","verdichter","compressor","motor","k(\xFC|ue)hl","freezer","fridge","gefrier"],ib=new RegExp(`(${ob.join("|")})`,"i");function Ds(t,e){let n=t.entities?.[e]?.device_id,r=n&&!zs(t,n)?Rn(t).domainsByDevice.get(n):void 0;return r&&[...r].some(o=>rb.has(o))?!1:!ib.test(`${e} ${t.states[e]?.attributes.friendly_name??""}`)}function mu(t,e,n,r){let o=n.climate?.[r];if(o==="none")return[];if(o)return[o].flat().filter(c=>t.states[c]);let i=(e?.placements??[]).filter(c=>c.entity_id.startsWith("sensor.")),s=i.filter(c=>N([c.x,c.z],n.points)).map(c=>c.entity_id),l=new Set(i.filter(c=>!N([c.x,c.z],n.points)).map(c=>c.entity_id));return[...new Set([...ye(t,n).filter(c=>!l.has(c)),...s])].filter(c=>c.startsWith("sensor.")&&Ps(t,c,r)&&Ds(t,c))}function gu(t){let e=t.attributes;if(typeof e.symcon_numeric_value!="number")return null;let n=typeof e.symcon_min=="number"?e.symcon_min:0,r=typeof e.symcon_max=="number"&&e.symcon_max>n?e.symcon_max:100;return Math.max(0,Math.min(100,(e.symcon_numeric_value-n)/(r-n)*100))}function Xo(t,e){let n=t?.states[e];if(!n)return!1;let r=n.attributes;return typeof r.symcon_id=="number"?r.symcon_variable_type===1||r.symcon_variable_type===2:typeof r.current_position=="number"||/^(sensor|number|input_number)\./.test(e)&&!!n.state.trim()&&Number.isFinite(Number(n.state))}function Qo(t,e){let n=e?t.states[e]:void 0;if(!n||et(n))return null;let r=n.attributes;if(r.nf_cover_control&&typeof r.current_position=="number")return r.current_position;let o=gu(n);if(o!==null)return o;if(typeof r.current_position=="number")return Math.max(0,Math.min(100,r.current_position));if(!n.state.trim())return null;let i=Number(n.state);if(!Number.isFinite(i))return null;let s=r.unit_of_measurement==="%"||i>1||i<0?i:i*100;return Math.max(0,Math.min(100,s))}var sb=new Set([void 0,"shutter","blind","awning","shade","curtain","window"]),ab=new Set(["garage","gate"]),lb=new Set(["window","opening"]);function vr(t,e,n=!1){let r=new Map;return t.forEach((o,i)=>{let s=n&&e.length===1?e[0]:e[i];s&&r.set(o.id,s)}),r}var _u=(t,e)=>t==="none"?null:t??e??null,zt=t=>t&&t!=="none"?t:null;function Pt(t,e){let n=new Map;for(let r of e)for(let o of r.rooms){let i=r.openings.filter(g=>g.room_id===o.id).sort((g,y)=>g.edge-y.edge||g.offset-y.offset);if(i.length===0)continue;let s=ye(t,o),l=g=>t.states[g]?.attributes.device_class,a=g=>s.filter(y=>X(y)==="binary"&&g(l(y)??"")),c=g=>i.filter(y=>y.type===g),u=vr(c("window"),s.filter(g=>X(g)==="cover"&&sb.has(l(g))),!0),d=vr(c("window"),a(g=>lb.has(g))),p=vr(c("door"),a(g=>g==="door")),h=vr(c("garage"),s.filter(g=>X(g)==="cover"&&ab.has(l(g)??""))),f=vr(c("garage"),a(g=>g==="garage_door"));for(let g of i){let y=g.type==="window"?u:g.type==="garage"?h:null,b=g.type==="window"?d:g.type==="garage"?f:p,v=g.leaves===2;n.set(g.id,{cover:_u(g.cover,y?.get(g.id)),contact:g.sensor==="handle"&&g.contact==null?null:_u(g.contact,b.get(g.id)),tilt:g.tilt==="none"?null:g.tilt,contact2:v?zt(g.contact2):null,tilt2:v?zt(g.tilt2):null,position:zt(g.position),positionInverted:!!g.position_inverted,tiltAngle:zt(g.tilt_angle),tiltMax:g.tilt_max??null,tiltOffset:g.tilt_offset??null,tiltInvert:!!g.tilt_invert,shut:!!g.shut,angled:g.type==="door"&&!!g.open_angle,lock:g.type==="door"?zt(g.lock):null,cover2:g.type==="garage"?null:zt(g.cover2),coverTilt:zt(g.cover_tilt),cover2Tilt:zt(g.cover2_tilt),coverInverted:!!g.cover_inverted,coverTiltInverted:!!g.cover_tilt_inverted,cover2Inverted:!!g.cover2_inverted,cover2TiltInverted:!!g.cover2_tilt_inverted})}}return n}var cb=[[/^(tilted|tilt|gekippt|kipp)/i,"tilted"],[/^(open|opened|offen|geöffnet|on)$/i,"open"],[/^(closed|close|geschlossen|zu|off)$/i,"closed"]];function Is(t){if(!t||et(t))return null;let e=t.attributes.window_state;for(let n of[typeof e=="string"?e:"",t.state]){let r=n.trim(),o=r&&cb.find(([i])=>i.test(r));if(o)return o[1]}return null}var bu=new WeakMap,yu=new WeakMap;function vu(t,e){let n=yu.get(t)??t,r=bu.get(n)??new WeakMap;bu.set(n,r);let o=r.get(e);if(o)return o;let i=new Map;for(let a of e)for(let c of a.placements)c.entity_id.startsWith("cover.")&&i.set(c.entity_id,{tilt:c.cover_tilt==="none"?null:c.cover_tilt,position:c.position});for(let a of Pt(n,e).values())a.cover&&!i.has(a.cover)&&i.set(a.cover,{tilt:a.coverTilt,position:a.position}),a.cover2&&!i.has(a.cover2)&&i.set(a.cover2,{tilt:a.cover2Tilt});let s={...n.states};for(let[a,c]of i){let u=n.states[a];if(!u)continue;let d={...u.attributes,nf_cover_control:!0},p=Qo(n,c.position);p===null&&(p=typeof u.attributes.current_position=="number"?u.attributes.current_position:null),p!==null&&(d.current_position=p);let h=c.tilt?n.states[c.tilt]:u,f=typeof h?.attributes.current_tilt_position=="number"?h.attributes.current_tilt_position:c.tilt?Qo(n,c.tilt):null;f!==null&&(d.current_tilt_position=f,d.supported_features=Number(d.supported_features??0)|128);let g=u.state;typeof d.current_position=="number"&&g!=="unavailable"&&g!=="unknown"&&g!=="opening"&&g!=="closing"&&(g=d.current_position>0?"open":"closed"),s[a]={...u,state:g,attributes:d}}let l={...n,states:s,callService:async(a,c,u={})=>{if(a!=="cover")return n.callService(a,c,u);let d=Array.isArray(u.entity_id)?u.entity_id:[u.entity_id],p=async h=>{let f=typeof h=="string"?i.get(h):void 0;if(!f)return n.callService(a,c,{...u,entity_id:h});let g={...u,entity_id:h},y=c;(y==="toggle"||y==="toggle_cover")&&(y=s[String(h)]?.state==="closed"?"open_cover":"close_cover");let b=y.includes("tilt");b&&f.tilt&&(g.entity_id=f.tilt);let v=f.tilt?n.states[f.tilt]:void 0;return b&&f.tilt&&!v?.attributes.symcon_id&&typeof v?.attributes.current_tilt_position!="number"&&(y==="set_cover_tilt_position"?(y="set_cover_position",g.position=g.tilt_position,delete g.tilt_position):y==="open_cover_tilt"?y="open_cover":y==="close_cover_tilt"&&(y="close_cover")),n.callService(a,y,g)};return Array.isArray(u.entity_id)?Promise.all(d.map(p)):p(d[0])}};return yu.set(l,n),r.set(e,l),l}var fe=t=>t?.symconObjects!==void 0;function Fn(t,e,n=[0,1,2,3]){let r=t?.states[e]?.attributes;return!!r?.symcon_id&&!r.symcon_source_entity&&n.includes(Number(r.symcon_variable_type))}function An(t){return!t||t.state==="unknown"||t.state==="unavailable"?null:t.attributes.symcon_value??t.attributes.symcon_numeric_value??t.state}function Os(t){let e=An(t);if(e===null||typeof e=="boolean"||e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}function wr(t){let e=An(t);if(e===null)return null;if(typeof e=="boolean")return e;if(typeof e=="number")return e>0;let n=String(e).trim().toLowerCase();if(["on","true","1","home","open","an","ein","ja","regen","rain","wet","nass"].includes(n))return!0;if(["off","false","0","not_home","closed","aus","nein","trocken","dry"].includes(n))return!1;let r=Number(n);return n!==""&&Number.isFinite(r)?r>0:null}function wu(t){return An(t)===null?"\u2013":String(t?.attributes.symcon_formatted??An(t))}function ku(t,e){switch(e){case"m/s":return t*3.6;case"mph":return t*1.609;case"kn":return t*1.852;case"ft/s":return t*1.097;default:return t}}var xu="weather.nextfloor_symcon",Su={condition:"Wetterzustand",temperature:"Au\xDFentemperatur",humidity:"Au\xDFenluftfeuchte",pressure:"Luftdruck",wind_speed:"Windgeschwindigkeit",wind_gust_speed:"Windb\xF6en",wind_bearing:"Windrichtung",cloud_coverage:"Bew\xF6lkung",precipitation:"Niederschlagsrate",precipitation_total:"Niederschlagsmenge",illuminance:"Au\xDFenhelligkeit",uv_index:"UV-Index",visibility:"Sichtweite",snow:"Schnee",fog:"Nebel",lightning:"Gewitter"},$u=new WeakMap;function ub(t){let e=t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").trim();return["sunny","clear-night","partlycloudy","cloudy","fog","rainy","pouring","lightning-rainy","lightning","hail","snowy","snowy-rainy","windy","windy-variant"].includes(e)?e:/kein regen|trocken|wolkenlos|klar|sonnig/.test(e)?"sunny":/gewitter|blitz/.test(e)?"lightning-rainy":/schneeregen/.test(e)?"snowy-rainy":/schnee/.test(e)?"snowy":/hagel/.test(e)?"hail":/starkregen/.test(e)?"pouring":/regen|niesel/.test(e)?"rainy":/nebel/.test(e)?"fog":/teil.*wolk|heiter|leicht.*wolk/.test(e)?"partlycloudy":/wolk|bedeckt/.test(e)?"cloudy":/wind|sturm/.test(e)?"windy":null}function Mu(t,e){if(!fe(t))return t;let n=e.weather_variables??{};if(!e.rain_sensor&&!Object.values(n).some(h=>h&&h!=="none"))return t;let r=$u.get(t)??new WeakMap;$u.set(t,r);let o=r.get(e);if(o)return o;let i={friendly_name:"Wetter",nf_symcon_weather:!0},s=h=>n[h]&&n[h]!=="none"?t.states[n[h]]:void 0;for(let h of["temperature","humidity","pressure","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility"]){let f=s(h),g=Os(f);g!==null&&(i[h]=h==="cloud_coverage"&&f?.attributes.symcon_max===1?g*100:g),f?.attributes.unit_of_measurement&&(i[`${h}_unit`]=f.attributes.unit_of_measurement)}for(let h of["wind_speed","wind_gust_speed"]){let f=s(h),g=Os(f);g!==null&&(i[h]=ku(g,f?.attributes.unit_of_measurement))}i.wind_speed_unit="km/h";let l=An(s("wind_bearing"));l!==null&&(i.wind_bearing=l);let a=ub(wu(s("condition"))),c=e.rain_sensor?t.states[e.rain_sensor]:void 0,u=wr(c);u!==null&&e.rain_sensor_inverted&&(u=!u),u===null&&typeof i.precipitation=="number"&&(u=i.precipitation>0),wr(s("lightning"))?a=u?"lightning-rainy":"lightning":wr(s("snow"))?a=u?"snowy-rainy":"snowy":wr(s("fog"))?a="fog":u===!0?a=Number(i.precipitation??0)>=8?"pouring":"rainy":u===!1&&a&&/rain|pouring/.test(a)&&(a=null),!a&&typeof i.cloud_coverage=="number"&&(a=i.cloud_coverage>70?"cloudy":i.cloud_coverage>20?"partlycloudy":"sunny"),!a&&u===!1&&(a="sunny");let d={entity_id:xu,state:a??"unknown",attributes:i},p={...t,states:{...t.states,[xu]:d}};return r.set(e,p),p}var Tn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Jt=t=>(...e)=>({_$litDirective$:t,values:e}),Dt=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,n,r){this._$Ct=e,this._$AM=n,this._$Ci=r}_$AS(e,n){return this.update(e,n)}update(e,n){return this.render(...n)}};var kr=class extends Dt{constructor(e){if(super(e),this.it=_,e.type!==Tn.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===_||e==null)return this._t=void 0,this.it=e;if(e===Je)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let n=[e];return n.raw=n,this._t={_$litType$:this.constructor.resultType,strings:n,values:[]}}};kr.directiveName="unsafeHTML",kr.resultType=1;var Ru=Jt(kr);var Eu=/\b(tv|fernseh|television|fire ?tv|apple ?tv|chromecast|shield)/i,Au=/(kühl|fridge|gefrier|freezer)/i,Fu=/(spülmaschine|geschirrspül|dishwasher)/i,db=/(kochfeld|herd|induktion|cooktop)/i,hb={robot_vacuum:/(saug|vacuum|robo|roomba|roborock|dreame|ecovacs|deebot)/i,tv_board:Eu,tv_wall:Eu,desk:/\b(pc|computer|rechner|desktop|monitor|workstation)/i,fridge:Au,fridge_smart:Au,stove:/(herd|kochfeld|cooktop|stove|induktion)/i,kitchen_tall:/(backofen|oven|ofen)/i,dishwasher:Fu,washer:/(waschmaschine|washer|washing)/i,dryer:/(trockner|dryer)/i,kitchen:/(kaffee|coffee|wasserkocher|kettle)/i,island:db,sink:Fu,radiator:/(heiz|radiator|thermostat|climate|hk|trv)/i},Tu={lamp_ceiling:/(decke|ceiling|haupt|main)/i,lamp_downlight:/(spot|strahler|downlight|einbau)/i,lamp_spot:/(spot|strahler)/i,lamp_panel:/(panel|decke|ceiling)/i,lamp_uplight:/(fluter|uplight|steh)/i,lamp_bollard:/(weg|garten|garden|path|poller|außen|aussen|outdoor)/i,lamp_garden:/(garten|garden|spot|außen|aussen|outdoor|baum|tree)/i,lamp_pendant:/(pendel|pendant|hänge|esstisch|dining)/i,ceiling_fan:/(ventilator|fan)/i,lamp_floor:/(steh|floor)/i,lamp_table:/(tisch|nacht|table|bedside|lese|reading)/i,lamp_wall:/(wand|wall)/i,led_strip:/(led|strip|streifen|leiste|band)/i},zu=new Set(["tv_board","tv_wall"]);var zn=t=>zu.has(t)||!!wc(t),Jo=t=>!!j(t)?.electric&&/speaker|multiroom|soundbar/.test(t.split(":").pop()??t),$r=t=>zn(t)||t==="desk"||t==="fridge_smart",pb=t=>!!t&&t!=="none";function fb(t,e){if(Zo(t,e))return e;let n=t.entities?.[e]?.device_id;return n?qo(t,n).find(r=>r!==e)??null:null}var mb=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&N([e,n],r.points));function xr(t,e,n,r){return t.find(o=>e?.test(n(o)))??(r?t[0]??null:null)}function We(t,e){let n=new Map;for(let r of e){let o=new Set([...r.furniture.flatMap(i=>[i.entity,i.power,i.fan_entity]),...r.placements.map(i=>i.entity_id)].filter(pb));for(let i of r.furniture){let s=i.type in Tu,l=kn(i.type),a=s?Tu[i.type]:hb[i.type];if(!a&&!l&&!Jo(i.type)&&i.entity==null&&i.power==null)continue;let c=mb(r,i.x,i.z),u=(c?Yo(t,ye(t,c)):[]).filter(y=>!o.has(y)),d=y=>`${y} ${W(t,y)}`,p=y=>u.filter(b=>X(b)===y),h=i.entity==="none"?null:i.entity??null;if(i.entity==null){if(i.type==="ceiling_fan"){let y=(c?ye(t,c):[]).filter(v=>!o.has(v)),b=new Set(y.filter(v=>X(v)==="fan").map(v=>t.entities?.[v]?.device_id).filter(Boolean));h=y.find(v=>X(v)==="light"&&b.has(t.entities?.[v]?.device_id))??xr(p("light"),a,d,!1)}else if(s)h=xr(p("light"),a,d,!0);else if(i.type==="robot_vacuum"){let y=c?.area_id??null;h=Object.keys(t.entities??{}).find(b=>b.startsWith("vacuum.")&&!o.has(b)&&Tt(t,b)===y)??null}else if(i.type==="radiator"||l)h=xr(p("climate"),a,d,!0);else if(zn(i.type)){let y=p("media");h=y.find(b=>t.states[b]?.attributes.device_class==="tv")??xr(y,a,d,zu.has(i.type))}else if(Jo(i.type)){let y=p("media").filter(b=>t.states[b]?.attributes.device_class!=="tv");h=xr(y,a,d,!1)??(y.length===1?y[0]:null)}else a&&(h=u.find(y=>["switch","media","fan"].includes(X(y)??"")&&a.test(d(y)))??null);h&&o.add(h)}let f=i.power==="none"?null:i.power??null;i.power==null&&(f=h?fb(t,h):null,!f&&a&&c&&!s&&(f=ye(t,c).find(y=>Zo(t,y)&&!o.has(y)&&a.test(d(y)))??null),f&&o.add(f));let g=null;if(i.type==="ceiling_fan"&&(g=i.fan_entity==="none"?null:i.fan_entity??null,i.fan_entity==null)){let y=(c?ye(t,c):[]).filter(v=>X(v)==="fan"&&!o.has(v)),b=h?t.entities?.[h]?.device_id:void 0;g=(b?y.find(v=>t.entities?.[v]?.device_id===b):void 0)??y[0]??null,g&&o.add(g)}(h||f||g)&&n.set(i.id,{entity:h,power:f,...i.type==="ceiling_fan"?{fan:g}:{}})}}return n}var Pu=t=>t==="fridge"||t==="fridge_smart"||/(fridge|freezer|kuehl|gefrier|chest_freezer)/.test(t.slice(t.lastIndexOf(":")+1));function Du(t,e,n=[]){let r=[];for(let o of e){let i=(l,a)=>o.rooms.some(c=>c.points.length>=3&&N([l,a],c.points)),s=We(t,[o]);r.push(...o.placements.filter(l=>l.outside||!i(l.x,l.z)).map(l=>l.entity_id)),r.push(...o.furniture.filter(l=>!i(l.x,l.z)).flatMap(l=>[s.get(l.id)?.entity,s.get(l.id)?.power]));for(let l of o.outdoor??[])l.area_id&&r.push(...Yo(t,Uo(t,l.area_id))),r.push(l.pump_entity,l.temp_entity)}return[...new Set(r.filter(o=>!!o&&!!t.states[o]&&!n.includes(o)))]}function gb(t,e){return Math.min(...e.map((n,r)=>{let o=e[(r+1)%e.length],[i,s]=[o[0]-n[0],o[1]-n[1]],l=Math.min(1,Math.max(0,((t[0]-n[0])*i+(t[1]-n[1])*s)/(i*i+s*s||1)));return Math.hypot(t[0]-n[0]-i*l,t[1]-n[1]-s*l)}))}function Ou(t,e,n=[]){let r=t.points;if(r.length<3||e.length===0)return[];let o=r.map(b=>b[0]),i=r.map(b=>b[1]),[s,l,a,c]=[Math.min(...o),Math.max(...o),Math.min(...i),Math.max(...i)],u=Math.min(l-s,c-a),d=Math.max(.1,Math.min(.25,u/8)),p=Math.min(.35,u/5),h=Math.min(.7,u/4),f=be(r),g=[];for(let b=s+d/2;b=p&&g.push({at:w,wallDistance:x})}g.length===0&&g.push({at:f,wallDistance:0});let y=[...n];return e.map(b=>{let v=X(b)==="light",w=g[0].at,x=-1/0;for(let{at:M,wallDistance:A}of g){let F=y.length?Math.min(...y.map(P=>Math.hypot(M[0]-P[0],M[1]-P[1]))):3,T=Math.hypot(M[0]-f[0],M[1]-f[1]),O=Math.min(F,3)*2;Tx+1e-9&&(x=O,w=M)}let k=[Math.round(w[0]*100)/100,Math.round(w[1]*100)/100];return y.push(k),{entity_id:b,x:k[0],z:k[1],y:null,mount:null}})}var Iu=/(^|_)(current_room|current_segment|aktueller_raum|current_area)($|_)/;function Hu(t,e,n){if(n==="none")return null;if(n)return n;let r=e?t.entities?.[e]?.device_id:null;return!r||!t.entities?null:Object.values(t.entities).find(i=>i.device_id===r&&i.entity_id.startsWith("sensor.")&&(Iu.test(i.translation_key??"")||Iu.test(i.entity_id.split(".")[1])))?.entity_id??null}var ve=re` :host { --nf-text: var(--primary-text-color, #e1e1e1); --nf-muted: var(--secondary-text-color, #9b9b9b); --nf-accent: var(--primary-color, #03a9f4); --nf-accent-text: var(--text-primary-color, #ffffff); --nf-surface: var(--ha-card-background, var(--card-background-color, #1c1c1c)); --nf-bg: var(--primary-background-color, #111111); --nf-bg2: var(--secondary-background-color, #1c1c1c); /* floating bars and cards over the 3D view: the card colour, a little see-through */ --nf-chrome: color-mix(in srgb, var(--nf-surface) var(--nf-chrome-mix, 84%), transparent); --nf-chrome-solid: var(--nf-surface); --nf-line: var(--divider-color, rgba(255, 255, 255, 0.12)); /* quiet fills for buttons and fields, and the tonal accent of an active control */ --nf-fill: color-mix(in srgb, var(--nf-text) 7%, transparent); --nf-fill-strong: color-mix(in srgb, var(--nf-text) 13%, transparent); --nf-tonal: color-mix(in srgb, var(--nf-accent) 20%, transparent); --nf-soft: var(--info-color, #4a90e2); --nf-warm: var(--state-light-active-color, #ffa726); --nf-danger: var(--error-color, #db4437); --nf-good: var(--success-color, #43a047); --nf-radius: var(--ha-card-border-radius, 12px); --nf-shadow: var(--ha-card-box-shadow, 0 1px 2px rgba(0, 0, 0, 0.18), 0 6px 20px rgba(0, 0, 0, 0.2)); --nf-font: var(--primary-font-family, Roboto, "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif); --nf-title-font: var(--nf-font); font-family: var(--nf-font); color: var(--nf-text); } `,t$=re` :host([readable]) { --secondary-text-color: var(--primary-text-color, #e1e1e1); --divider-color: color-mix(in srgb, var(--primary-text-color, #e1e1e1) 40%, transparent); --nf-chrome-mix: 97%; } :host([readable]) nf-room-panel, :host([readable]) .nf-nav, :host([readable]) .nf-overlay { zoom: 1.2; } `,ht=re` /* a group of switches: one rounded pill, the active one tinted with the accent */ .nf-seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 999px; background: var(--nf-chrome); box-shadow: var(--nf-shadow); backdrop-filter: blur(10px); } .nf-seg button, .nf-chip { font: inherit; font-size: 14px; font-weight: 500; border: none; background: none; color: var(--nf-muted); padding: 7px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap; min-height: 36px; transition: background 0.15s, color 0.15s; } .nf-seg button:hover:not(:disabled), .nf-chip:hover { background: var(--nf-fill); color: var(--nf-text); } /* on a small stage (a small window, a zoomed browser, a dashboard column) the switches at the bottom take less room */ @container nf ((max-width: 1360px) or (max-height: 640px)) { :is(.nf-overlay, .nf-card-controls) .nf-seg { padding: 3px; } :is(.nf-overlay, .nf-card-controls) :is(.nf-seg button, .nf-chip) { font-size: 12.5px; padding: 5px 10px; } } .nf-time-slider { display: inline-flex; align-items: center; padding: 4px 10px; } .nf-time-slider input { width: 160px; accent-color: var(--nf-accent); } .nf-seg button[aria-pressed="true"], .nf-chip[aria-pressed="true"] { background: color-mix(in srgb, var(--nf-accent) 24%, var(--nf-chrome-solid)); color: var(--nf-accent); font-weight: 600; } .nf-seg button:disabled { opacity: 0.4; cursor: default; } /* a single pill, like the chips of the Mushroom cards */ .nf-chip { background: var(--nf-chrome); color: var(--nf-text); box-shadow: var(--nf-shadow); backdrop-filter: blur(10px); } button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--nf-accent); outline-offset: 2px; } /* the round icon badge every row and card starts with */ .nf-ico { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 38px; height: 38px; border-radius: 50%; background: var(--nf-tonal); color: var(--nf-accent); --mdc-icon-size: 20px; } .nf-ico.nf-warm { background: color-mix(in srgb, var(--nf-warm) 22%, transparent); color: var(--nf-warm); } .nf-ico.nf-off { background: var(--nf-fill); color: var(--nf-muted); } .nf-btn { font: inherit; font-size: 14px; font-weight: 500; border: none; background: var(--nf-fill); color: var(--nf-text); border-radius: var(--nf-radius); padding: 7px 14px; cursor: pointer; min-height: 36px; transition: background 0.15s; } .nf-btn:hover { background: var(--nf-fill-strong); } .nf-btn.nf-danger { color: var(--nf-danger); } .nf-btn.nf-primary { background: var(--nf-accent); color: var(--nf-accent-text); } .nf-btn.nf-primary:hover { background: color-mix(in srgb, var(--nf-accent) 88%, var(--nf-text)); } .nf-field { display: grid; gap: 4px; font-size: 12px; color: var(--nf-muted); } .nf-field input, .nf-field select, .nf-field textarea { font: inherit; font-size: 14px; color: var(--nf-text); background: var(--nf-fill); border: none; border-bottom: 1px solid var(--nf-line); border-radius: 10px 10px 4px 4px; padding: 8px 10px; min-width: 0; } .nf-field input:focus, .nf-field select:focus, .nf-field textarea:focus { border-bottom-color: var(--nf-accent); } .nf-field input[type="range"] { padding: 0; accent-color: var(--nf-accent); } .nf-field select option { background: var(--nf-chrome-solid); color: var(--nf-text); } /* fingers need 40 px */ @media (pointer: coarse) { .nf-seg button, .nf-chip, .nf-btn { min-height: 40px; } } `;var{I:_b}=uc,Lu=t=>t;var Nu=t=>t.strings===void 0,Cu=()=>document.createComment(""),Pn=(t,e,n)=>{let r=t._$AA.parentNode,o=e===void 0?t._$AB:e._$AA;if(n===void 0){let i=r.insertBefore(Cu(),o),s=r.insertBefore(Cu(),o);n=new _b(i,s,t,t.options)}else{let i=n._$AB.nextSibling,s=n._$AM,l=s!==t;if(l){let a;n._$AQ?.(t),n._$AM=t,n._$AP!==void 0&&(a=t._$AU)!==s._$AU&&n._$AP(a)}if(i!==o||l){let a=n._$AA;for(;a!==i;){let c=Lu(a).nextSibling;Lu(r).insertBefore(a,o),a=c}}}return n},It=(t,e,n=t)=>(t._$AI(e,n),t),bb={},Bu=(t,e=bb)=>t._$AH=e,Wu=t=>t._$AH,ei=t=>{t._$AR(),t._$AA.remove()};var Vu=(t,e,n)=>{let r=new Map;for(let o=e;o<=n;o++)r.set(t[o],o);return r},Ku=Jt(class extends Dt{constructor(t){if(super(t),t.type!==Tn.CHILD)throw Error("repeat() can only be used in text expressions")}dt(t,e,n){let r;n===void 0?n=e:e!==void 0&&(r=e);let o=[],i=[],s=0;for(let l of t)o[s]=r?r(l,s):s,i[s]=n(l,s),s++;return{values:i,keys:o}}render(t,e,n){return this.dt(t,e,n).values}update(t,[e,n,r]){let o=Wu(t),{values:i,keys:s}=this.dt(e,n,r);if(!Array.isArray(o))return this.ut=s,i;let l=this.ut??=[],a=[],c,u,d=0,p=o.length-1,h=0,f=i.length-1;for(;d<=p&&h<=f;)if(o[d]===null)d++;else if(o[p]===null)p--;else if(l[d]===s[h])a[h]=It(o[d],i[h]),d++,h++;else if(l[p]===s[f])a[f]=It(o[p],i[f]),p--,f--;else if(l[d]===s[f])a[f]=It(o[d],i[f]),Pn(t,a[f+1],o[d]),d++,f--;else if(l[p]===s[h])a[h]=It(o[p],i[h]),Pn(t,o[d],o[p]),p--,h++;else if(c===void 0&&(c=Vu(s,h,f),u=Vu(l,d,p)),c.has(l[d]))if(c.has(l[p])){let g=u.get(s[h]),y=g!==void 0?o[g]:null;if(y===null){let b=Pn(t,o[d]);It(b,i[h]),a[h]=b}else a[h]=It(y,i[h]),Pn(t,o[d],y),o[g]=null;h++}else ei(o[p]),p--;else ei(o[d]),d++;for(;h<=f;){let g=Pn(t,a[f+1]);It(g,i[h]),a[h++]=g}for(;d<=p;){let g=o[d++];g!==null&&ei(g)}return this.ut=s,Bu(t,a),Je}});var yb=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),Hs=-1,ju=[{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"}],Gu=t=>t.object_type===1&&ju.some(e=>e.type===t.module_type);function vb(t){let e=new Map(t.map(a=>[a.object_id,a])),n=t.filter(a=>{if(!Gu(a))return!1;let c=new Set([a.object_id]),u=e.get(a.parent_id);for(;u&&!c.has(u.object_id);){if(Gu(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),o=new Map;for(let a of t){let c=o.get(a.parent_id)??[];c.push(a),o.set(a.parent_id,c)}let i=(a,c,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(Hs,i(Hs,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 o.get(a.object_id)??[])l(p,a.object_id,d.path)};return ju.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,i(d,Hs,a.name,p,c));for(let h of u)l(h,d,p)}),[...r.values()]}function Ls(t){let e=vb(t),n=new Map(e.map(o=>[o.object_id,o])),r=new Map;for(let o of e){let i=n.has(o.parent_id)?o.parent_id:0,s=r.get(i)??[];s.push(o),r.set(i,s)}for(let o of r.values())o.sort((i,s)=>i.position-s.position||i.object_type-s.object_type||yb.compare(i.name,s.name));return{nodes:n,children:r}}function Cs(t,e){let n=[],r=new Set([e]),o=t.nodes.get(e)?.parent_id;for(;o&&!r.has(o)&&t.nodes.has(o);)n.push(o),r.add(o),o=t.nodes.get(o)?.parent_id;return n}function Ns(t,e,n=""){let r=n.trim().toLocaleLowerCase("de").split(/\s+/).filter(Boolean),o=r.length?new Set:null;if(o){for(let a of t.nodes.values())if(r.every(c=>`${a.name} ${a.path}`.toLocaleLowerCase("de").includes(c))){o.add(a.object_id);for(let c of Cs(t,a.object_id))o.add(c)}}let i=[],s=new Set,l=(a,c)=>{let u=(t.children.get(a)??[]).filter(d=>!o||o.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&&(!!o||e.has(d.object_id));i.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),i}var wb=["Kategorie","Instanz","Variable","Skript","Ereignis","Medium","Link"],Bs=class extends Q{static properties={objects:{attribute:!1},options:{attribute:!1},fixed:{attribute:!1},value:{attribute:!1},disabled:{type:Boolean},placeholder:{attribute:!1},_query:{state:!0},_expanded:{state:!0},_pending:{state:!0},_active:{state:!0},_selected:{state:!0}};tree=Ls([]);allowed=new Map;allowedSources=new Map;constructor(){super(),this.objects=[],this.options=[],this.fixed=[],this.value=null,this.disabled=!1,this.placeholder="Datenpunkt ausw\xE4hlen",this._query="",this._expanded=new Set,this._pending=null,this._active=null,this._selected=null}willUpdate(e){e.has("objects")&&(this.tree=Ls(this.objects)),(e.has("options")||e.has("fixed"))&&(this.allowed=new Map([...this.fixed,...this.options].map(n=>[n.id,n])),this.allowedSources=new Map(this.options.filter(n=>n.sourceEntity).map(n=>[n.sourceEntity,n.id])))}get dialog(){return this.renderRoot.querySelector("dialog")}variableNode(e){let n=this.allowed.get(e??"")?.sourceEntity??e,r=this.objects.find(o=>o.entity_id===n&&(o.object_type===2||o.object_type===4));return r?this.tree.nodes.get(r.object_id):void 0}async open(){if(this.disabled)return;this._pending=this.allowed.has(this.value??"")?this.value:null,this._query="";let e=this.variableNode(this.value)??this.objects.find(r=>r.entity_id===this.value);this._active=e?.object_id??null,this._selected=e?.object_id??null;let n=new Set(this._expanded);if(e)for(let r of Cs(this.tree,e.object_id))n.add(r);this._expanded=n,await this.updateComplete,this.isConnected&&(this.dialog?.open||this.dialog?.showModal(),this.renderRoot.querySelector(".search")?.focus(),this.renderRoot.querySelector("[aria-selected=true]")?.scrollIntoView({block:"nearest"}))}close(){this.dialog?.close()}clear(e){e.preventDefault(),e.stopPropagation(),!this.disabled&&(this.value=this.fixed.some(n=>n.id==="none")?"none":null,this._pending=this.value,this._selected=null,this._active=null,this.close(),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})))}commit(){this.disabled||!this._pending||!this.allowed.has(this._pending)||(this.value=this._pending,this.close(),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})))}toggle(e){let n=new Set(this._expanded);n.has(e)?n.delete(e):n.add(e),this._expanded=n}select(e){this._active=e.object_id;let n=this.entityFor(e);n&&(this._pending=n,this._selected=e.object_id)}entityFor(e){if(e.entity_id)return this.allowed.has(e.entity_id)?e.entity_id:this.allowedSources.get(e.entity_id)}async onTreeKey(e){let n=Ns(this.tree,this._expanded,this._query),r=Math.max(0,n.findIndex(s=>s.node.object_id===this._active)),o=n[r];if(!o)return;let i=r;if(e.key==="ArrowDown")i=Math.min(n.length-1,r+1);else if(e.key==="ArrowUp")i=Math.max(0,r-1);else if(e.key==="Home")i=0;else if(e.key==="End")i=n.length-1;else if(e.key==="ArrowRight")o.hasChildren&&!o.expanded?this.toggle(o.node.object_id):o.hasChildren&&(i=Math.min(n.length-1,r+1));else if(e.key==="ArrowLeft")o.expanded&&!this._query?this.toggle(o.node.object_id):i=Math.max(0,n.findIndex(s=>s.node.object_id===o.node.parent_id));else if(e.key===" "||e.key==="Enter")this.select(o.node),e.key==="Enter"&&this.entityFor(o.node)&&this.commit();else return;e.preventDefault(),(i!==r||this._active===null)&&(this._active=n[i].node.object_id),await this.updateComplete,this.renderRoot.querySelector(`#object-${this._active}`)?.scrollIntoView({block:"nearest"})}icon(e){let n=[R``,R``,R``,R``,R``,R``,R``];return R``}renderRow(e){let{node:n}=e,r=this.entityFor(n),o=!!r;return m`
{this.select(n),this.renderRoot.querySelector(".tree")?.focus()}} @dblclick=${()=>{o?(this.select(n),this.commit()):e.hasChildren&&this.toggle(n.object_id)}}> ${this.icon(n.object_type)}${n.name||"(Ohne Namen)"} ${n.virtual?"Systembereich":wb[n.object_type]??"Objekt"}${n.hidden?" \xB7 ausgeblendet":""} ${o&&n.object_id===this._selected&&r===this._pending?m``:_}
`}render(){let e=this.allowed.get(this.value??""),n=this.variableNode(this.value),r=this.allowed.get(this._pending??""),o=this._selected===null?void 0:this.tree.nodes.get(this._selected),i=(o&&this.entityFor(o)===this._pending?o:void 0)??this.variableNode(this._pending),s=Ns(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`
${a?m``:_}
{if(c.stopPropagation(),c.target===this.dialog){let u=this.dialog.getBoundingClientRect();(c.clientXu.right||c.clientYu.bottom)&&this.close()}}} @keydown=${c=>c.stopPropagation()} @change=${c=>c.stopPropagation()}>

Datenpunkt auswählen

IP-Symcon · Objektbaum

${this.fixed.length?m`
${this.fixed.map(c=>m` `)}
`:_}
${Ku(s,c=>c.node.object_id,c=>this.renderRow(c))} ${s.length?_:m`

${this.objects.length?"Keine Objekte gefunden.":"Kein Objektbaum verf\xFCgbar. Bitte das Symcon-Modul aktualisieren und den Designer neu laden."}

`}
${i?.name??r?.label??"Noch kein Datenpunkt ausgew\xE4hlt"} ${i?.path??"Nur passende Datenpunkte k\xF6nnen ausgew\xE4hlt werden."}
`}static styles=[ve,re` :host { display:block; min-width:0; max-width:100%; font:inherit; color:var(--nf-text); } button,input { font:inherit; box-sizing:border-box; } button { cursor:pointer; color:var(--nf-text); border:1px solid var(--nf-line); background:var(--nf-chrome-solid); border-radius:9px; padding:8px 12px; } button:disabled { opacity:.45; cursor:default; } button:focus-visible,input:focus-visible { outline:2px solid var(--nf-accent); outline-offset:2px; } .field { display:flex; gap:6px; min-width:0; } .trigger { flex:1; min-width:0; width:100%; display:flex; align-items:center; justify-content:space-between; text-align:left; gap:12px; padding:9px 11px; } .trigger-text { flex:1; min-width:0; overflow:hidden; } .trigger strong { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; } .picker-icon { flex:none; } .clear { flex:none; width:32px; padding:0; font-size:22px; } strong { font-weight:500; } small { display:block; color:var(--nf-muted); font-size:11px; } .trigger small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; margin-top:3px; } dialog { width:min(780px,calc(100vw - 32px)); max-width:none; height:min(690px,calc(100dvh - 32px)); max-height:none; box-sizing:border-box; padding:0; border:1px solid var(--nf-line); border-radius:16px; color:var(--nf-text); background:var(--nf-chrome-solid); box-shadow:0 24px 80px #0008; font:14px system-ui,sans-serif; } dialog[open] { display:flex; flex-direction:column; } dialog::backdrop { background:#050b16a6; backdrop-filter:blur(3px); } header { display:flex; align-items:center; justify-content:space-between; padding:20px 22px 16px; border-bottom:1px solid var(--nf-line); } h2 { font-size:18px; font-weight:600; margin:0 0 4px; } header p { margin:0; color:var(--nf-muted); font-size:12px; } .close { font-size:25px; padding:0; width:32px; height:32px; border-color:transparent; } .search-bar { display:flex; align-items:center; gap:12px; padding:16px 20px 10px; } .search { flex:1; min-width:0; border:1px solid var(--nf-line); border-radius:9px; padding:10px 12px; background:var(--nf-bg); color:var(--nf-text); } .text-button { border:0; background:transparent; color:var(--nf-muted); font-size:12px; padding:6px 0; white-space:nowrap; } .fixed { display:flex; flex-wrap:wrap; gap:6px; padding:0 20px 10px; } .fixed button { padding:5px 10px; font-size:12px; } .fixed [aria-pressed=true] { color:var(--nf-accent); border-color:var(--nf-accent); } .tree { flex:1; min-height:80px; overflow:auto; overscroll-behavior:contain; margin:0 12px; padding:4px 0 12px; outline-offset:-2px; } .node { display:flex; align-items:center; gap:8px; min-height:34px; border-radius:6px; padding:2px 10px 2px calc(4px + var(--depth)*22px); box-sizing:border-box; width:max-content; min-width:100%; } .node:hover { background:color-mix(in srgb,var(--nf-accent) 8%,transparent); } .node.active { outline:1px solid color-mix(in srgb,var(--nf-accent) 40%,transparent); outline-offset:-1px; } .node[aria-selected=true] { background:color-mix(in srgb,var(--nf-accent) 16%,transparent); color:var(--nf-accent); } .node.selectable { cursor:pointer; } .node[aria-disabled=true] .node-name { color:var(--nf-muted); } .node.hidden-object .node-name { font-style:italic; } .node-name { flex:1; white-space:nowrap; } .node small { margin-left:20px; white-space:nowrap; } .twisty { border:0; background:transparent; border-radius:4px; padding:0; width:20px; height:26px; flex:none; font-size:18px; } .icon { flex:none; width:17px; height:17px; color:#8796a9; } .type-0 { color:#c69a42; } .type-1 { color:#8d9ac6; } .type-2 { color:#55a58c; } .selected-mark { margin-left:8px; } .empty { padding:20px; color:var(--nf-muted); } footer { display:flex; align-items:center; justify-content:space-between; gap:16px; border-top:1px solid var(--nf-line); padding:15px 20px; } .selection { min-width:0; } .selection small { margin-top:4px; overflow-wrap:anywhere; } .actions { display:flex; gap:8px; flex-shrink:0; } .apply { color:white; background:var(--nf-accent); border-color:transparent; } @media(max-width:580px) { dialog { width:calc(100vw - 16px); height:calc(100dvh - 32px); border-radius:12px; } header { padding:16px; } .search-bar { padding:12px; gap:8px; } .fixed { padding:0 12px 8px; } .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",Bs);var Uu=40,Ws=class extends Q{static properties={options:{attribute:!1},objectTree:{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))},o=this.fixed.filter(s=>!e||r(s)),i=e?this.options.filter(r):this.options;return[...o,...i.slice(0,Uu)]}get leftOut(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=e?this.options.filter(o=>n.every(i=>`${o.label} ${o.detail??o.id}`.toLowerCase().includes(i))).length:this.options.length;return Math.max(0,r-Uu)}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`{this.value=r.detail.value}} >`;let e=this.current,n=this._open?this.hits:[];return m`
{clearTimeout(this.blurTimer),this._open=!0,this._query="",this._cursor=0}} @blur=${()=>{this.blurTimer=setTimeout(()=>this._open=!1,150)}} @input=${r=>{this._query=r.target.value,this._cursor=0,this._open=!0}} @keydown=${this.onKey} /> ${this._open?m`
    ${n.length?_:m`
  • –
  • `} ${n.map((r,o)=>m`
  • i.preventDefault()} @click=${()=>this.choose(r.id)} > ${r.label}${r.detail||r.id.includes(".")?m`${r.detail??r.id}`:_}
  • `)} ${this.leftOut>0?m`
  • … +${this.leftOut} · ${this.placeholder}
  • `:_}
`:_}
`}static styles=[ve,re` :host { display: block; position: relative; min-width: 0; max-width: 100%; } input { width: 100%; box-sizing: border-box; font: inherit; color: var(--nf-text); background: var(--nf-chrome-solid); border: 1px solid var(--nf-line); border-radius: 10px; padding: 8px 10px; } input::placeholder { color: var(--nf-text); opacity: 0.9; } input:focus::placeholder { color: var(--nf-muted); } input:focus { outline: 2px solid var(--nf-accent); outline-offset: -1px; } .list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; margin: 0; padding: 4px; list-style: none; max-height: 280px; overflow-y: auto; background: var(--nf-chrome-solid); border: 1px solid var(--nf-line); border-radius: 10px; box-shadow: var(--nf-shadow); } li { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13.5px; } li small { color: var(--nf-muted); font-size: 11px; } li.cursor, li:hover { background: color-mix(in srgb, var(--nf-accent) 18%, transparent); } li.chosen { color: var(--nf-accent); } li.empty { color: var(--nf-muted); cursor: default; } `]};customElements.get("nf-entity-picker")||customElements.define("nf-entity-picker",Ws);var Vs=class extends Q{static properties={text:{attribute:!1}};constructor(){super(),this.text=""}get dialog(){return this.renderRoot.querySelector("dialog")}render(){return m` e.stopPropagation()} @click=${e=>{if(e.target!==e.currentTarget)return;let n=this.dialog.getBoundingClientRect();(e.clientXn.right||e.clientYn.bottom)&&this.dialog?.close()}}>
Information

${this.text}

`}static styles=[ve,re` :host { display:inline-block; margin:4px 0; vertical-align:middle; } button { font:inherit; cursor:pointer; color:var(--nf-muted); background:transparent; border:1px solid var(--nf-line); border-radius:50%; pointer-events:auto; } .info { width:26px; height:26px; padding:0; font-size:18px; line-height:24px; } button:hover { color:var(--nf-accent); } button:focus-visible { outline:2px solid var(--nf-accent); outline-offset:2px; } dialog { box-sizing:border-box; width:min(560px,calc(100vw - 32px)); max-height:80vh; max-height:80dvh; overflow:auto; padding:18px 22px; border:1px solid var(--nf-line); border-radius:14px; background:var(--nf-chrome-solid); color:var(--nf-text); font:14px/1.5 system-ui,sans-serif; box-shadow:var(--nf-shadow); pointer-events:auto; } dialog::backdrop { background:#050b16a6; } 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",Vs);var en=t=>t.target.value,Ks=t=>Number.parseFloat(t.replace(",",".")),se=t=>Math.round(t*1e3)/1e3,Zu=t=>t.wide?"nf-field nf-wide":"nf-field";function E(t,e,n,r,o=.01,i){return m``}function V(t,e,n,r,o={}){return m``}function L(t,e,n,r,o,i={}){return m``}function I(t,e,n,r,o={}){return m``}function Ve(t,e,n,r,o){return m``}function z(t,e,n,r,o,i){let s=r===void 0?null:r?t.t("entity_auto",{name:W(t.hass,r)}):t.t("entity_auto_none"),l=[...s!==null?[{id:"__auto",label:s}]:[],{id:"none",label:t.t("entity_none")}],a=n??(s!==null?"__auto":"none");return m``}function Dn(t,e,n){return n?(n.startsWith("mdi:")?n:`mdi:${n}`).replace(/[^a-z0-9:-]/gi,""):t.hass?au(t.hass,e):null}function Ot(t,e,n){let r=e?(e.startsWith("mdi:")?e:`mdi:${e}`).replace(/[^a-z0-9:-]/gi,""):"";return m``}function In(t,e,n){return m``}function On(t,e,n){let r=e??{},o=i=>s=>{let l={...r,[i]:Math.round(Math.max(-5,Math.min(5,s))*100)/100};n(l.x||l.z||l.y?l:null)};return m`
${t.t("pin_shift")}
${E(t,"\u2194 x",r.x??0,o("x"),.05)} ${E(t,"\u2195 z",r.z??0,o("z"),.05)} ${E(t,t.t("pin_shift_up"),r.y??0,o("y"),.05)} ${e?m``:_} ${S(t.t("pin_shift_hint"),"nf-wide")}
`}var Y=(...t)=>m`
${t}
`,S=(t,e="")=>m``;function tn(t,e,n,r={}){let o=r.lowest??10;return m``}var nt=(t,e,n={})=>t.callWS({type:`nextfloor/${e}`,...n});async function ti(t,e){return(await nt(t,"image/get",{image_id:e})).data}async function Ht(t,e,n){await nt(t,"image/set",{image_id:e,data:n})}async function qu(t){return(await nt(t,"history/list")).snapshots}async function Yu(t,e){return(await nt(t,"history/snapshot",e?{name:e}:{})).id}async function Xu(t,e){return(await nt(t,"history/get",{snapshot_id:e})).building}async function Qu(t,e){await nt(t,"history/delete",{snapshot_id:e})}async function Ju(t,e){return(await nt(t,"history/restore",{snapshot_id:e})).revision}var Sr=(t,e)=>nt(t,"packs/import",{pack:e});async function ed(t,e){await nt(t,"packs/remove",{pack_id:e})}var td=t=>nt(t,"backup/export"),nd=(t,e,n)=>nt(t,"backup/import",{building:e,packs:n});var G=(t,e)=>[t[0]-e[0],t[1]-e[1]],pt=(t,e)=>[t[0]+e[0],t[1]+e[1]],rt=(t,e)=>[t[0]*e,t[1]*e],J=(t,e)=>t[0]*e[0]+t[1]*e[1],Me=(t,e)=>t[0]*e[1]-t[1]*e[0],me=t=>Math.hypot(t[0],t[1]),ot=t=>{let e=me(t)||1;return[t[0]/e,t[1]/e]},Gs=t=>[-t[1],t[0]],js=t=>[t[1],-t[0]];var kb=.05,xb=.2,$b=.12;function Sb(t){let e=[];return t.forEach((n,r)=>{let o=n.points;if(o.length<3)return;let i=_e(o)>=0;o.forEach((s,l)=>{let a=o[(l+1)%o.length],c=me(G(a,s));if(c<.05)return;let u=[(a[0]-s[0])/c,(a[1]-s[1])/c],d=i?[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]=[J(s,u),J(a,u)];e.push({room:r,index:l,dir:u,normal:p,offset:J(s,p),outside:J(d,p)>0?1:-1,from:Math.min(h,f),to:Math.max(h,f)})})}),e}function Mb(t,e,n){if(t.room===e.room||Math.abs(Me(t.dir,e.dir))>kb||t.outside===e.outside)return null;let r=(e.offset-t.offset)*t.outside;return r>n||r<-$b||Math.abs(r)<1e-4||Math.min(t.to,e.to)-Math.max(t.from,e.from)Math.round(t*1e3)/1e3;function rd(t,e=.6){let n=Sb(t),r=n.map((g,y)=>y),o=g=>r[g]===g?g:r[g]=o(r[g]),i=[],s=new Set,l=[];for(let g=0;gMath.abs(g[2])-Math.abs(y[2]));let a=new Map(n.map((g,y)=>[y,[y]])),c=(g,y)=>g.some(b=>y.some(v=>n[b].room===n[v].room&&Math.abs(n[b].offset-n[v].offset)>=.002));for(let[g,y,b]of l){let[v,w]=[o(g),o(y)];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)}i.push(Us(b)),s.add(g).add(y)}let u=new Map(n.map((g,y)=>[`${g.room}:${g.index}`,y]));for(let g=s.size>0;g;)g=!1,n.forEach((y,b)=>{let v=u.get(`${y.room}:${(y.index+1)%t[y.room].points.length}`);if(v===void 0||v===b)return;let w=n[v];!(Math.abs(Me(y.dir,w.dir))<1e-6&&Math.abs(y.offset-w.offset)<.002&&y.outside===w.outside)||s.has(b)===s.has(v)||(s.add(b).add(v),g=!0)});n.forEach((g,y)=>{let b=u.get(`${g.room}:${(g.index+1)%t[g.room].points.length}`);if(b===void 0||b===y||!s.has(y)||!s.has(b))return;let v=n[b];Math.abs(Me(g.dir,v.dir))<1e-6&&Math.abs(g.offset-v.offset)<.002&&g.outside===v.outside&&(r[o(y)]=o(b))});let d=()=>t.map(g=>({...g,points:g.points.map(y=>[y[0],y[1]])}));if(i.length===0)return{rooms:d(),gaps:i};let p=new Map;for(let g of s)p.set(o(g),[...p.get(o(g))??[],g]);let h=t.map(g=>g.points.map(()=>new Map));for(let[g,y]of p){let b=new Map(y.map(w=>[`${n[w].room}:${Math.round(n[w].offset*500)}`,n[w].offset])),v=[...b.values()].reduce((w,x)=>w+x,0)/b.size;for(let w of y){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,y)=>({...g,points:g.points.map((b,v)=>{let w=[...h[y][v].values()].reduce((x,k)=>[x[0]+k[0],x[1]+k[1]],[b[0],b[1]]);return[Us(w[0]),Us(w[1])]})})),gaps:i}}function od(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 Rb=.25,id=t=>Math.round(t*1e3)/1e3,sd=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&N([e,n],r.points));function qs(t,e,n,r,o){let i=sd(t,e,n);if(!i)return[r,o];let s=(l,a)=>N([l,a],i.points);return s(r,o)?[r,o]:s(r,n)?[r,n]:s(e,o)?[e,o]:[e,n]}function Eb(t,e,n,r){return t.rooms.some(o=>o.id!==e.id&&o.points.some((i,s)=>{let l=o.points[(s+1)%o.points.length];return Math.abs(J(G(i,n),r))<.02&&Math.abs(J(G(l,n),r))<.02}))}var Zs=(t,e)=>Math.abs((t-e+540)%360-180);function Mr(t,e,n,r=Rb){let o=sd(t,e.x,e.z);if(!o)return null;let i=o.points,s=_e(i)>=0?1:-1,l=null;return i.forEach((a,c)=>{let u=i[(c+1)%i.length],d=me(G(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=J(G([e.x,e.z],a),p);if(f<0||f>d)return;let g=Eb(t,o,a,h)?n/2:0,y=J(G([e.x,e.z],a),h)-g,b=Math.atan2(-h[0],h[1])*180/Math.PI,w=[{rotation:b,extent:e.d/2},{rotation:b+90,extent:e.w/2},{rotation:b-90,extent:e.w/2}].reduce((k,M)=>Zs(e.rotation,M.rotation)50)return;let x=y-w.extent;Math.abs(x)>r||l&&Math.abs(x)>=Math.abs(l.gap)||(l={x:id(e.x-h[0]*x),z:id(e.z-h[1]*x),rotation:(Math.round(w.rotation)%360+360)%360,gap:x})}),l&&{x:l.x,z:l.z,rotation:l.rotation}}var Hn=Math.PI/180,it=t=>Math.tan(Math.min(80,Math.max(0,t))*Hn);function Er(t){return{x0:Math.min(t.x0,t.x1),x1:Math.max(t.x0,t.x1),z0:Math.min(t.z0,t.z1),z1:Math.max(t.z0,t.z1)}}function ad(t){if(!t.rotation)return null;let e=t.rotation*Hn;return{cx:(t.x0+t.x1)/2,cz:(t.z0+t.z1)/2,c:Math.cos(e),sn:Math.sin(e)}}function ld(t,e){let n=ad(t);if(!n)return e;let[r,o]=[e[0]-n.cx,e[1]-n.cz];return[n.cx+r*n.c-o*n.sn,n.cz+r*n.sn+o*n.c]}function Ys(t,e,n){let r=ad(t);if(!r)return[e,n];let[o,i]=[e-r.cx,n-r.cz];return[r.cx+o*r.c+i*r.sn,r.cz-o*r.sn+i*r.c]}function Ar(t,e=0){let{x0:n,x1:r,z0:o,z1:i}=Er(t);return[[n-e,o-e],[r+e,o-e],[r+e,i+e],[n-e,i+e]].map(s=>ld(t,s))}function xe(t){let{x0:e,x1:n,z0:r,z1:o}=Er(t),i=s=>ld(t,s);return t.axis==="x"?{u0:e,u1:n,w:o-r,at:(s,l)=>i([s,t.flip?o-l:r+l])}:{u0:r,u1:o,w:n-e,at:(s,l)=>i([t.flip?n-l:e+l,s])}}function Fr(t,e,n){let{x0:r,x1:o,z0:i,z1:s}=Er(t),[l,a]=Ys(t,e,n);return t.axis==="x"?[l,t.flip?s-a:a-i]:[a,t.flip?o-l:l-r]}var Rr=Math.tan(30*Hn);function Tr(t,e,n,r,o){let i=Math.min(t*.3,r>1e-6?2.4/r:t*.3),s=Math.min(t*.3,o>1e-6?2.4/o:t*.3),l=e+i*r,a=n+s*o,c=Math.min(t-s,Math.max(i,(a-l+Rr*(t-s+i))/(2*Rr))),u=l+(c-i)*Rr;return{vla:i,vlb:s,yla:l,ylb:a,vr:c,rh:u,y:p=>p<=i?e+p*r:p<=c?l+(p-i)*Rr:p<=t-s?a+(t-s-p)*Rr:n+(t-p)*o}}function De(t){let e=xe(t).w,[n,r]=[t.eave_a,t.eave_b],[o,i]=[it(t.pitch_a),it(t.pitch_b)];switch(t.shape){case"flat":case"parapet":return{vr:e/2,rh:n,y:()=>n};case"pent":return{vr:e,rh:n+e*o,y:s=>n+s*o};case"mansard":{let s=Tr(e,n,r,o,i);return{vr:s.vr,rh:s.rh,y:s.y}}default:{let s=o+i>1e-6?Math.min(e,Math.max(0,(r-n+e*i)/(o+i))):e/2;return{vr:s,rh:n+s*o,y:l=>l<=s?n+l*o:r+(e-l)*i}}}}var nn=t=>De(t).rh;function cd(t){let e=t.heightEnd!==void 0;return{...t,a:t.b,b:t.a,left:t.right,right:t.left,roomLeft:t.roomRight,roomRight:t.roomLeft,height:e?t.heightEnd:t.height,heightEnd:e?t.height:void 0}}function Ab(t,e){let n=t.map(r=>({...r}));for(let r of e){let o=n.find(i=>i.room_id===r.room_id&&i.edge===r.edge&&(Math.abs(i.t1-r.t0)<1e-6||Math.abs(r.t1-i.t0)<1e-6));o?(o.t0=Math.min(o.t0,r.t0),o.t1=Math.max(o.t1,r.t1)):n.push({...r})}return n}function Fb(t,e,n){if(t.a===e.b)return!1;let r=ot(G(n[t.b],n[t.a])),o=ot(G(n[e.b],n[e.a]));return Math.abs(Me(r,o))>1e-6||J(r,o)<=0||t.free||e.free||t.heightEnd!==void 0||e.heightEnd!==void 0?!1:t.height===e.height&&t.exterior===e.exterior&&t.roomLeft===e.roomLeft&&t.roomRight===e.roomRight&&Math.abs(t.left-e.left)<=1e-9&&Math.abs(t.right-e.right)<=1e-9}function ud(t,e,n=new Set){let r=t.slice();for(;;){let o=new Map;r.forEach((s,l)=>{for(let a of[s.a,s.b])o.set(a,[...o.get(a)??[],l])});let i=null;for(let[s,l]of o){if(l.length!==2||n.has(s))continue;let a=r[l[0]].b===s?r[l[0]]:cd(r[l[0]]),c=r[l[1]].a===s?r[l[1]]:cd(r[l[1]]);if(!Fb(a,c,e))continue;let u={...a,b:c.b,sources:Ab(a.sources,c.sources)};i=[...r.filter((d,p)=>p!==l[0]&&p!==l[1]),u];break}if(!i)return r;r=i}}function dd(t,e){let n=new Map;t.forEach((o,i)=>{let s=ot(G(e[o.b],e[o.a])),l=[[o.a,{key:`${i}:a`,d:s,left:o.left,right:o.right,angle:Math.atan2(s[1],s[0])}],[o.b,{key:`${i}:b`,d:rt(s,-1),left:o.right,right:o.left,angle:Math.atan2(-s[1],-s[0])}]];for(let[a,c]of l)n.set(a,[...n.get(a)??[],c])});let r=new Map;for(let[o,i]of n){let s=e[o];i.sort((a,c)=>a.angle-c.angle);for(let a of i)r.set(a.key,{left:pt(s,rt(Gs(a.d),a.left)),right:pt(s,rt(js(a.d),a.right))});if(i.length<2)continue;let l=4*Math.max(...i.map(a=>Math.max(a.left,a.right)))+1e-9;i.forEach((a,c)=>{let u=i[(c+1)%i.length],d=pt(s,rt(Gs(a.d),a.left)),p=pt(s,rt(js(u.d),u.right)),h=Me(a.d,u.d);if(Math.abs(h)<1e-4)return;let f=pt(d,rt(a.d,Me(G(p,d),u.d)/h));me(G(f,s))>l||(r.get(a.key).left=f,r.get(u.key).right=f)})}return r}function hd(t,e){let n=t.filter((r,o)=>me(G(r,t[(o+1)%t.length]))>e);for(;;){if(n.length<=3)return n;let r=n.findIndex((o,i)=>{let s=n[(i+n.length-1)%n.length],l=n[(i+1)%n.length],[a,c]=[G(o,s),G(l,o)];return Math.abs(Me(ot(a),ot(c)))<1e-7&&J(a,c)>0});if(r===-1)return n;n=n.filter((o,i)=>i!==r)}}function Tb(t){let e=[];return{points:e,idOf(n){let r=e.findIndex(o=>Math.abs(o[0]-n[0])<=t&&Math.abs(o[1]-n[1])<=t);return r>=0?r:(e.push([n[0],n[1]]),e.length-1)}}}function zb(t,e){let n=[];for(let r of t){let o=r.points;if(o.length<3||Math.abs(_e(o))<1e-6)continue;let i=_e(o)>0,s=o.map(l=>e.idOf(l));s.forEach((l,a)=>{let c=s[(a+1)%s.length];l!==c&&n.push(i?{u:l,v:c,room:r.id,edge:a,forward:!0}:{u:c,v:l,room:r.id,edge:a,forward:!1})})}return n}function Pb(t,e,n){let r=[];for(let o of t){let[i,s]=[e[o.u],e[o.v]],l=G(s,i),a=me(l),c=rt(l,1/a),u=e.map((p,h)=>({id:h,rel:G(p,i)})).filter(({id:p,rel:h})=>p!==o.u&&p!==o.v&&J(h,c)>n&&J(h,c)({t:J(h,c),id:p})).sort((p,h)=>p.t-h.t),d=[{t:0,id:o.u},...u,{t:a,id:o.v}];for(let p=0;p+1({room_id:t.room,edge:t.edge,t0:t.t0,t1:t.t1});function Db(t,e){let n=new Map(t.map(l=>[l.id,l])),r=new Map;for(let l of e){let a=`${l.room}:${l.edge}`;r.set(a,[...r.get(a)??[],l.t0].sort((c,u)=>c-u))}let o=l=>{let a=n.get(l.room)?.wall_heights?.[l.edge];return Array.isArray(a)?a[(r.get(`${l.room}:${l.edge}`)??[]).indexOf(l.t0)]??null:a},i=l=>{let a=n.get(l.room),[c,u]=[a?.wall_heights?.[l.edge],a?.wall_slopes?.[l.edge]];if(!a||typeof c!="number"||typeof u!="number"||c<=0||u<=0)return null;let[d,p]=[a.points[l.edge],a.points[(l.edge+1)%a.points.length]];return{from:c,to:u,length:Math.hypot(p[0]-d[0],p[1]-d[1])}},s=l=>{let a=i(l);if(!a||a.length<1e-9){let u=o(l);return typeof u=="number"&&u>0?[u,u]:[null,null]}let c=u=>a.from+(a.to-a.from)*u/a.length;return l.forward?[c(l.t0),c(l.t1)]:[c(l.t1),c(l.t0)]};return{heightsOf(l){let[a,c]=[1/0,1/0];for(let d of l){let[p,h]=s(d),[f,g]=d===l[0]?[p,h]:[h,p];f!==null&&(a=Math.min(a,f)),g!==null&&(c=Math.min(c,g))}let u=l.map(d=>n.get(d.room)?.ceiling);if(u.every(d=>typeof d=="number"&&d>0)){let d=Math.max(...u);a===1/0&&(a=d),c===1/0&&(c=d)}return{...a<1/0?{a}:{},...c<1/0?{b:c}:{}}},thicknessOf(l){let a=l.map(c=>{let u=n.get(c.room)?.wall_thickness?.[c.edge];return Array.isArray(u)?u[(r.get(`${c.room}:${c.edge}`)??[]).indexOf(c.t0)]:u}).filter(c=>typeof c=="number"&&c>0);return a.length?Math.max(...a):void 0},hasNoWall:l=>l.some(a=>o(a)===0)}}function fd(t){let e=n=>Math.round(n*1e6)/1e6;return t.a===void 0||t.b===void 0?t.a!==void 0?{height:e(t.a)}:t.b!==void 0?{height:e(t.b)}:{}:Math.abs(t.a-t.b)<1e-6?{height:e(t.a)}:{height:e(t.a),heightEnd:e(t.b)}}function Ib(t,e,n,r){let o=Db(e,t),i=new Map;for(let a of t){let c=a.up!==c&&p.u===c.v&&p.v===c.u&&p.room!==c.room);for(let p of a)p!==c&&p!==u&&p.room!==c.room&&r.push(`overlap:${c.room}:${p.room}`);let d=u?[c,u]:[c];if(o.hasNoWall(d)){u&&l.push([c.room,u.room]);continue}if(u){let p=o.thicknessOf(d)??n.interior;s.push({a:c.u,b:c.v,left:p/2,right:p/2,exterior:!1,roomLeft:c.room,roomRight:u.room,sources:d.map(pd),...fd(o.heightsOf(d))})}else s.push({a:c.u,b:c.v,left:0,right:o.thicknessOf(d)??n.exterior,exterior:!0,roomLeft:c.room,roomRight:null,sources:[pd(c)],...fd(o.heightsOf(d))})}return{drafts:s,open:l}}function Ob(t,e){let n=i=>ot(G(e[i.b],e[i.a])),r=t.filter(i=>!i.exterior&&!i.free),o=new Map;for(let i of r){if(o.has(i))continue;let s=[i];o.set(i,s);for(let l=0;l1e-6||a.add(J(s,h)>0?"left":"right")}if(a.size!==1)continue;let c=[...a][0];for(let u of i){let d=u.left+u.right,p=J(n(u),s)>0,h=c==="left"===p;[u.left,u.right]=h?[0,d]:[d,0]}}}var Hb=(t,e)=>{let n=i=>Math.round(i*100),[r,o]=t[0]Math.hypot(b.b[0]-b.a[0],b.b[1]-b.a[1])>.05),a=l.map(b=>[i.idOf(b.a),i.idOf(b.b)]),c=new Set;for(let b of t){let v=b.points;v.length<3||(b.wall_splits??[]).forEach((w,x)=>{if(!w||x>=v.length)return;let k=v[x],M=G(v[(x+1)%v.length],k),A=me(M);for(let F of w)F>r&&F{let[w,x]=a[v];if(w===x)return;let k=[(b.a[0]+b.b[0])/2,(b.a[1]+b.b[1])/2],M=t.find(F=>F.points.length>=3&&N(k,F.points))?.id??null,A=(b.thickness??e.interior)/2;h.push({free:b.id,a:w,b:x,left:A,right:A,exterior:!1,roomLeft:M,roomRight:M,sources:[],height:typeof b.height=="number"&&b.height>0?b.height:void 0,...typeof b.height=="number"&&b.height>0&&typeof b.height_end=="number"&&b.height_end>0&&Math.abs(b.height_end-b.height)>1e-6?{heightEnd:b.height_end}:{}})});let f=ud(h,i.points,c),g=dd(f,i.points);return{walls:f.map((b,v)=>{let[w,x]=[i.points[b.a],i.points[b.b]],[k,M]=[g.get(`${v}:a`),g.get(`${v}:b`)],A=hd([k.right,M.left,x,M.right,k.left,w],1e-6);return{id:Hb(w,x),a:[w[0],w[1]],b:[x[0],x[1]],left:b.left,right:b.right,exterior:b.exterior,roomLeft:b.roomLeft,roomRight:b.roomRight,sources:b.sources,footprint:A,...b.free?{free:b.free}:{},...b.height!==void 0?{height:b.height}:{},...b.heightEnd!==void 0?{heightEnd:b.heightEnd}:{}}}),warnings:[...new Set(o)],open:p}}function Ln(t,e,n){let r=t.points[e];return pt(r,rt(ot(G(t.points[(e+1)%t.points.length],r)),n))}function Ie(t,e,n){if(t.wall){let o=n.find(l=>l.id===t.wall);if(!o||Math.hypot(o.b[0]-o.a[0],o.b[1]-o.a[1])<.05)return null;let i=ot(G(o.b,o.a));return{room:{id:t.room_id,name:"",area_id:null,points:[o.a,o.b,pt(o.a,[-i[1],i[0]])]},edge:0}}let r=e.find(o=>o.id===t.room_id);return r&&t.edgeJ(G(e,t.a),ot(G(t.b,t.a)));function Lt(t,e,n){if(!e.wall)return Lb(t,n.room,n.edge,e.offset);let r=t.find(o=>o.free===e.wall);return r?{wall:r,s:md(r,Ln(n.room,0,e.offset))}:null}function Lb(t,e,n,r){for(let o of t)if(o.sources.some(s=>s.room_id===e.id&&s.edge===n&&r>=s.t0-1e-6&&r<=s.t1+1e-6))return{wall:o,s:md(o,Ln(e,n,r))};return null}function gd(t,e){let n=t.points.map(h=>h[0]),r=t.points.map(h=>h[1]);if(t.points.length!==4||new Set(n.map(h=>h.toFixed(3))).size!==2||new Set(r.map(h=>h.toFixed(3))).size!==2)return null;let[o,i,s,l]=[Math.min(...n),Math.max(...n),Math.min(...r),Math.max(...r)],a=h=>Math.max(0,...e.filter(f=>(f.roomLeft===t.id||f.roomRight===t.id)&&h(f)).map(f=>f.roomLeft===t.id?f.left:f.right)),c=(h,f)=>Math.abs(h-f)<.001,u=(h,f,g)=>c(h.a[f],g)&&c(h.b[f],g),d=i-o-a(h=>u(h,0,o))-a(h=>u(h,0,i)),p=l-s-a(h=>u(h,1,s))-a(h=>u(h,1,l));return[Math.round(d*1e3)/1e3,Math.round(p*1e3)/1e3]}var _d=([t,e])=>{let n=Math.hypot(t,e)||1;return[t/n,e/n]};function Cb(t){return t.reduce((e,n,r)=>e+(n[0]*t[(r+1)%t.length][1]-t[(r+1)%t.length][0]*n[1]),0)/2}function bd(t,e){let n=t.length;if(n<3||Math.abs(e)<1e-9)return t.map(([o,i])=>[o,i]);let r=Cb(t)>=0?1:-1;return t.map((o,i)=>{let s=t[(i+n-1)%n],l=t[(i+1)%n],[a,c]=_d([o[0]-s[0],o[1]-s[1]]),[u,d]=_d([l[0]-o[0],l[1]-o[1]]),p=[c*r,-a*r],h=[d*r,-u*r],f=[p[0]+h[0],p[1]+h[1]],g=Math.hypot(f[0],f[1]);if(g<1e-6)return[o[0]+p[0]*e,o[1]+p[1]*e];let y=(f[0]*p[0]+f[1]*p[1])/g,b=Math.min(4,1/Math.max(.25,y));return[o[0]+f[0]/g*e*b,o[1]+f[1]/g*e*b]})}function Ct(t){let e=t.map(r=>r[0]),n=t.map(r=>r[1]);return{x0:Math.min(...e),z0:Math.min(...n),x1:Math.max(...e),z1:Math.max(...n)}}function Nb(t){let e=([i,s])=>`${Math.round(i*1e3)}:${Math.round(s*1e3)}`,n=new Map;for(let i of t)for(let s of[i.a,i.b])n.set(e(s),[...n.get(e(s))??[],i]);let r=new Set,o=null;for(let i of t){if(r.has(i))continue;r.add(i);let s=[i.a,i.b],l=i.b;for(;;){let c=(n.get(e(l))??[]).find(u=>!r.has(u));if(!c||(r.add(c),l=e(c.a)===e(l)?c.b:c.a,e(l)===e(s[0])))break;s.push(l)}s.length>=3&&e(l)===e(s[0])&&(!o||Math.abs(ke(s))>Math.abs(ke(o)))&&(o=s)}return o}function Xs(t,e,n,r){let o=pe(t,{exterior:n,interior:r},e).walls.filter(l=>l.exterior&&!l.free),i=o.length?Nb(o.map(l=>({a:l.a,b:l.b}))):null;if(!i)return null;let s=i.filter((l,a)=>{let c=i[(a+i.length-1)%i.length],u=i[(a+1)%i.length];return Math.abs((l[0]-c[0])*(u[1]-l[1])-(l[1]-c[1])*(u[0]-l[0]))>1e-6});return s.length>=3?bd(s,n):null}function rn(t,e){let n=xe(t),r=De(t),o=n.w,[i,s]=[Math.max(0,e.a),Math.max(0,e.b)],l=n.u0-Math.max(0,e.u0),a=n.u1+Math.max(0,e.u1),c=(b,v)=>[b,v,r.y(v)],u=c(l,-i),d=c(a,-i),p=c(a,o+s),h=c(l,o+s),[f,g]=[it(t.pitch_a),it(t.pitch_b)],y=b=>[b,r.vr,r.rh];if(t.ends&&(t.shape==="gable"||t.shape==="hip"||t.shape==="halfhip")){let b=(n.u1-n.u0)/2,v=Math.min(b,Math.min(r.vr,o-r.vr)||o/2),w=Math.min(r.y(0),r.y(o)),x=w+(r.rh-w)*Math.min(.9,Math.max(.2,t.halfhip??.55)),k=f>1e-6?Math.min(r.vr,(x-t.eave_a)/f):r.vr,M=g>1e-6?Math.max(r.vr,o-(x-t.eave_b)/g):r.vr,A=Math.min(b-.1,(r.rh-x)/Math.max(.2,f)),F=[[0,r.y(0)],[r.vr,r.rh],[o,r.y(o)]],T=[[0,r.y(0)],[k,x],[M,x],[o,r.y(o)]],O=(K,jt,wo)=>{if(K==="hip")return{upA:[],upB:[],ridge:y(jt===l?n.u0+v*wo:n.u1-v*wo),profile:null};if(K==="halfhip"){let v_=y(jt===l?n.u0+A:n.u1-A);return{upA:[[jt,k,x]],upB:[[jt,M,x]],ridge:v_,profile:T}}return{upA:[],upB:[],ridge:y(jt),profile:F}},P=O(t.ends[0],l,1),C=O(t.ends[1],a,1),B=[[u,d,...C.upA,C.ridge,P.ridge,...[...P.upA].reverse()],[P.ridge,C.ridge,...[...C.upB].reverse(),p,h,...P.upB]],q=[[P.ridge,C.ridge]];for(let[K,jt,wo]of[[P,u,h],[C,d,p]])K.profile===null?(B.push(K===P?[h,u,K.ridge]:[d,p,K.ridge]),q.push([jt,K.ridge],[wo,K.ridge])):K.upA.length&&(B.push(K===P?[K.upB[0],K.upA[0],K.ridge]:[K.upA[0],K.upB[0],K.ridge]),q.push([K.upA[0],K.ridge],[K.upB[0],K.ridge]));let we=K=>K.profile===null?[]:K.upA.length?[K.upA[0],K.upB[0]]:[K.ridge],Mt=[u,d,...we(C),p,h,...[...we(P)].reverse()];return{faces:B,rim:Mt,ridges:q,gable:F,endProfiles:[P.profile,C.profile]}}switch(t.shape){case"pent":return{faces:[[u,d,p,h]],rim:[u,d,p,h],ridges:[[p,h]],gable:[[0,r.y(0)],[o,r.y(o)]]};case"hip":case"pyramid":{let b=(n.u1-n.u0)/2,v=t.shape==="pyramid"?b:Math.min(b,Math.min(r.vr,o-r.vr)||o/2),w=y(n.u0+v),x=y(n.u1-v);return t.shape==="pyramid"?{faces:[[u,d,w],[d,p,w],[p,h,w],[h,u,w]],rim:[u,d,p,h],ridges:[[u,w],[h,w],[d,w],[p,w]],gable:null}:{faces:[[u,d,x,w],[w,x,p,h],[h,u,w],[d,p,x]],rim:[u,d,p,h],ridges:[[w,x],[u,w],[h,w],[d,x],[p,x]],gable:null}}case"halfhip":{let b=Math.min(r.y(0),r.y(o)),v=b+(r.rh-b)*Math.min(.9,Math.max(.2,t.halfhip??.55)),w=f>1e-6?Math.min(r.vr,(v-t.eave_a)/f):r.vr,x=g>1e-6?Math.max(r.vr,o-(v-t.eave_b)/g):r.vr,k=Math.min((n.u1-n.u0)/2-.1,(r.rh-v)/Math.max(.2,f)),M=y(n.u0+k),A=y(n.u1-k),F=[l,w,v],T=[l,x,v],O=[a,w,v],P=[a,x,v];return{faces:[[u,d,O,A,M,F],[M,A,P,p,h,T],[T,F,M],[O,P,A]],rim:[u,d,O,P,p,h,T,F],ridges:[[M,A],[F,M],[T,M],[O,A],[P,A]],gable:[[0,r.y(0)],[w,v],[x,v],[o,r.y(o)]]}}case"mansard":{let b=Tr(o,t.eave_a,t.eave_b,f,g),v=[l,b.vla,b.yla],w=[a,b.vla,b.yla],x=[l,o-b.vlb,b.ylb],k=[a,o-b.vlb,b.ylb],M=[l,b.vr,b.rh],A=[a,b.vr,b.rh];return{faces:[[u,d,w,v],[v,w,A,M],[M,A,k,x],[x,k,p,h]],rim:[u,d,w,A,k,p,h,x,M,v],ridges:[[M,A],[v,w],[x,k]],gable:[[0,r.y(0)],[b.vla,b.yla],[b.vr,b.rh],[o-b.vlb,b.ylb],[o,r.y(o)]]}}default:{let b=y(l),v=y(a);return{faces:[[u,d,v,b],[b,v,p,h]],rim:[u,d,v,p,h,b],ridges:[[b,v]],gable:[[0,r.y(0)],[r.vr,r.rh],[o,r.y(o)]]}}}}function zr(t,e,n){let r=null;for(let o of t.faces){if(!N([e,n],o.map(([p,h])=>[p,h])))continue;let[i,s]=o,l=o.slice(2).find(p=>Math.abs((s[0]-i[0])*(p[1]-i[1])-(s[1]-i[1])*(p[0]-i[0]))>1e-9);if(!l)continue;let a=[s[0]-i[0],s[2]-i[2],s[1]-i[1]],c=[l[0]-i[0],l[2]-i[2],l[1]-i[1]],u=[a[1]*c[2]-a[2]*c[1],a[2]*c[0]-a[0]*c[2],a[0]*c[1]-a[1]*c[0]];if(Math.abs(u[1])<1e-9)continue;let d=i[2]-(u[0]*(e-i[0])+u[2]*(n-i[1]))/u[1];r=r===null?d:Math.min(r,d)}return r}function Pr(t,e,n){let r=xe(e),o=t.floors.flatMap(d=>d.rooms.filter(p=>p.points.length>=3&&d.elevation+d.height>e.base+.05)),i=d=>d.some(p=>o.some(h=>N(p,h.points))),s=.35,l=[.15,.5,.85].map(d=>r.u0+(r.u1-r.u0)*d),a=[.15,.5,.85].map(d=>r.w*d),c=d=>d?0:n,u=(d,p)=>{let h=e.overhang_sides?.[d];return typeof h=="number"&&Number.isFinite(h)?Math.min(2,Math.max(0,h)):p};return{a:u("a",c(i(l.map(d=>r.at(d,-s))))),b:u("b",c(i(l.map(d=>r.at(d,r.w+s))))),u0:u("u0",c(i(a.map(d=>r.at(r.u0-s,d))))),u1:u("u1",c(i(a.map(d=>r.at(r.u1+s,d)))))}}var ni=t=>Math.abs((t.x1-t.x0)*(t.z1-t.z0)),yd=t=>t.shape==="flat"||t.shape==="parapet",on=t=>Math.round(t*100)/100;function ri(t,e){let[n,r]=[(e.x0+e.x1)/2,(e.z0+e.z1)/2];return t.filter(i=>{if(i===e||i.dormer||i.open||yd(i)||ni(i)=s.x0&&n<=s.x1&&r>=s.z0&&r<=s.z1}).reduce((i,s)=>i===null||ni(s){let[i,s]=e.at(o,e.w/2),[l,a]=Fr(t,i,s);return zr(n,l,a)??r.y(a)}}function Js(t,e){if(yd(e))return e;let n=xe(e),r=De(e).rh,o=Wb(t,n),i=o(n.u0)<=o(n.u1),[s,l]=i?[n.u0,n.u1]:[n.u1,n.u0],a=i?1:-1,c=l;for(let p=.5;p=r-.02){c=s+a*p;break}if(Math.abs(c-l)<.05)return e;let u={...e},d=l===n.u1;return e.axis==="x"?u[d?"x1":"x0"]=c:u[d?"z1":"z0"]=c,u}var ea=.14,vd=t=>t.shape==="flat"||t.shape==="parapet";function ta(t,e){return!t.open&&Math.min(t.base,t.eave_a,t.eave_b)a+o||pu+o||s.points&&s.points.length>=3&&!N([e,n],s.points))continue;let[h,f]=Fr(s,e,n),g=Math.max(0,s.overhang??r),y=vd(s)?null:zr(rn(s,{u0:g,u1:g,a:g,b:g}),h,f);i.push((y??De(s).y(f))-ea)}return i.length?Math.max(...i):null}function na(t,e,n){let r=[],o=e+n+ea;for(let i of t.settings.roof.sections??[]){if(i.open||vd(i)||i.shape==="mansard")continue;let s=xe(i),l=De(i),[a,c]=[it(i.pitch_a),it(i.pitch_b)],u=[];a>1e-6&&u.push((o-i.eave_a)/a),i.shape==="gable"&&c>1e-6&&u.push(s.w-(o-i.eave_b)/c);for(let d of u)d<=.01||d>=s.w-.01||i.shape==="gable"&&Math.abs(l.y(d)-o)>1e-6||r.push([s.at(s.u0,d),s.at(s.u1,d)])}return r}function ra(t,e,n,r,o){let i=[];for(let l of[.2,.5,.8])for(let a of[.2,.5,.8])i.push([e+(r-e)*l,n+(o-n)*a]);let s=t.floors.filter(l=>l.rooms.some(a=>a.points.length>=3&&i.some(c=>N(c,a.points)))).map(l=>l.elevation+l.height);return s.length?Math.max(...s):null}function oa(t,e){let n=t.floors.filter(a=>a.rooms.length>0).sort((a,c)=>a.elevation-c.elevation),r=n.filter(a=>a.elevationu.rooms.some(d=>d.points.length>=3&&a.some(p=>N(p,d.points))));if(c)return c}return r.at(-1)??n[0]}var vt=t=>Math.round(t*1e3)/1e3;function ia(t,e=n=>`roof_${n+1}`){let n=t.settings.roof?.pitch??35,r=t.settings.wall_exterior,o=t.floors.filter(a=>a.rooms.some(c=>c.points.length>=3)).sort((a,c)=>c.elevation-a.elevation),i=[],s=[],l=(a,c)=>a.some(u=>N(c,u.points));for(let a of o){let c=a.rooms.filter(y=>y.points.length>=3),u=[...new Set(c.flatMap(y=>y.points.map(b=>vt(b[0]))))].sort((y,b)=>y-b),d=[...new Set(c.flatMap(y=>y.points.map(b=>vt(b[1]))))].sort((y,b)=>y-b),p=d.slice(0,-1).map((y,b)=>u.slice(0,-1).map((v,w)=>{let x=[(u[w]+u[w+1])/2,(d[b]+d[b+1])/2];return l(c,x)&&!l(s,x)})),h=p.map(y=>y.map(()=>!1)),f=(y,b)=>p[b][y]&&!h[b][y],g=a.elevation+a.height;for(let y=0;yf(b+T,w+1)).every(Boolean);)w++;for(let F=y;F<=w;F++)for(let T=b;T<=v;T++)h[F][T]=!0;let[x,k]=[u[b]-r,u[v+1]+r],[M,A]=[d[y]-r,d[w+1]+r];Math.min(k-x,A-M)<.8||i.push({id:e(i.length),x0:vt(x),z0:vt(M),x1:vt(k),z1:vt(A),shape:"gable",axis:k-x>=A-M?"x":"z",eave_a:vt(g),eave_b:vt(g),pitch_a:n,pitch_b:n,base:vt(g),overhang:null})}s.push(...c)}return i}var Re=Math.PI/180,Ke=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],sn=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],Cn=t=>Math.hypot(t[0],t[1],t[2]),an=t=>{let e=Cn(t)||1;return[t[0]/e,t[1]/e,t[2]/e]},wd=(t,e)=>[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]],Ge=t=>Math.round(t*100)/100,Ir=([t,e],n)=>(Math.atan2(t,-e)/Re-n+720)%360;var xd=.25;function $d(t,e,n,r,o,i,s){let l=o-n>=i-r,a=l?o-n:i-r;return{key:`${t}:top`,section:e,side:"top",flat:!0,o:[n,s,r],eu:l?[1,0,0]:[0,0,1],es:l?[0,0,1]:[1,0,0],n:[0,1,0],lu:a,ls:l?i-r:o-n,pitch:0,span:()=>[0,a],facing:l?[0,1]:[1,0]}}function Sd(t,e){let n=an(wd(t,e));return n[1]<0?[-n[0],-n[1],-n[2]]:n}var Md=t=>{let e=an([-t[0],0,-t[2]]);return[e[0],e[2]]};function wt(t,e,n,r,o,i,s,l){let a=an(Ke(o,r)),c=an(Ke(i,r));return{key:t,section:e,side:n,flat:!1,o:r,eu:a,es:c,n:Sd(a,c),lu:Cn(Ke(o,r)),ls:Cn(Ke(i,r)),pitch:s,span:l,facing:Md(c)}}function kd(t,e,n,r,o,i){let s=Cn(Ke(o,r));if(s<.3)return null;let l=an(Ke(o,r)),a=Ke(i,r),c=a[0]*l[0]+a[1]*l[1]+a[2]*l[2],u=[a[0]-l[0]*c,a[1]-l[1]*c,a[2]-l[2]*c],d=Cn(u);if(d<.3)return null;let p=an(u),h=f=>{let g=Math.min(1,Math.max(0,f/d));return[c*g,s-(s-c)*g]};return{key:t,section:e,side:n,flat:!1,o:r,eu:l,es:p,n:Sd(l,p),lu:s,ls:d,pitch:Math.atan2(p[1],Math.hypot(p[0],p[2]))/Re,span:h,facing:Md(p)}}function Vb(t,e){let n=xe(t),r=De(t),o=(v,w,x)=>{let[k,M]=n.at(v,w);return[k,x,M]},[i,s]=[Math.max(0,e.a),Math.max(0,e.b)],l=n.u0-Math.max(0,e.u0),a=n.u1+Math.max(0,e.u1),c=a-l,u=r.y(-i),d=r.y(n.w+s);if(t.shape==="flat"||t.shape==="parapet"){let[v,w]=[n.at(l,-i),n.at(a,n.w+s)];return[$d(t.id,t.id,Math.min(v[0],w[0]),Math.min(v[1],w[1]),Math.max(v[0],w[0]),Math.max(v[1],w[1]),t.eave_a+xd)]}if(t.shape==="pent")return[wt(`${t.id}:a`,t.id,"a",o(l,-i,u),o(a,-i,u),o(l,n.w+s,d),t.pitch_a,()=>[0,c])];if(t.shape==="mansard")return Kb(t,n,l,a,i,s);let p=t.shape==="hip"||t.shape==="pyramid",h=(n.u1-n.u0)/2,f=t.shape==="pyramid"?h:p?Math.min(h,Math.min(r.vr,n.w-r.vr)||n.w/2):0,g=p?n.u0+f-l:0,y=p?a-(n.u1-f):0,b=[];if(r.vr>.3){let v=Math.hypot(r.vr+i,r.rh-u);b.push(wt(`${t.id}:a`,t.id,"a",o(l,-i,u),o(a,-i,u),o(l,r.vr,r.rh),t.pitch_a,w=>[g*(w/v),c-y*(w/v)]))}if(n.w-r.vr>.3){let v=Math.hypot(n.w+s-r.vr,r.rh-d);b.push(wt(`${t.id}:b`,t.id,"b",o(a,n.w+s,d),o(l,n.w+s,d),o(a,r.vr,r.rh),t.pitch_b,w=>[y*(w/v),c-g*(w/v)]))}if(p){let v=kd(`${t.id}:c`,t.id,"c",o(l,n.w+s,d),o(l,-i,u),o(n.u0+f,r.vr,r.rh)),w=kd(`${t.id}:d`,t.id,"d",o(a,-i,u),o(a,n.w+s,d),o(n.u1-f,r.vr,r.rh));b.push(...[v,w].filter(x=>x!==null))}return b}function Kb(t,e,n,r,o,i){let s=Tr(e.w,t.eave_a,t.eave_b,it(t.pitch_a),it(t.pitch_b)),l=(f,g)=>{let[y,b]=e.at(f,g);return[y,s.y(g),b]},a=r-n,c=()=>[0,a],u=(f,g)=>Math.atan2(f,g)/Re,d=[],[p,h]=[e.w+i,e.w-s.vlb];return s.vla+o>.3&&d.push(wt(`${t.id}:a`,t.id,"a",l(n,-o),l(r,-o),l(n,s.vla),t.pitch_a,c)),s.vr-s.vla>.3&&d.push(wt(`${t.id}:au`,t.id,"a",l(n,s.vla),l(r,s.vla),l(n,s.vr),u(s.rh-s.yla,s.vr-s.vla),c)),s.vlb+i>.3&&d.push(wt(`${t.id}:b`,t.id,"b",l(r,p),l(n,p),l(r,h),t.pitch_b,c)),h-s.vr>.3&&d.push(wt(`${t.id}:bu`,t.id,"b",l(r,h),l(n,h),l(r,s.vr),u(s.rh-s.ylb,h-s.vr),c)),d}function sa(t){return t.floors.filter(n=>n.rooms.some(r=>r.points.length>=3)).sort((n,r)=>r.elevation-n.elevation)[0]??null}function Z(t){let e=t.settings.roof;if(!e||e.type==="none")return[];if(e.type==="custom")return(e.sections??[]).flatMap(w=>Vb(w,Pr(t,w,w.overhang??e.overhang)));let n=sa(t);if(!n)return[];let r=n.rooms.flatMap(w=>w.points.map(x=>x[0])),o=n.rooms.flatMap(w=>w.points.map(x=>x[1])),i=t.settings.wall_exterior+e.overhang,[s,l]=[Math.min(...r)-i,Math.max(...r)+i],[a,c]=[Math.min(...o)-i,Math.max(...o)+i],u=n.elevation+n.height;if(e.type==="flat")return[$d("main",null,s,a,l,c,u+xd)];let d=l-s>=c-a,p=e.ridge==="short"?!d:d,h=(p?c-a:l-s)/2,f=h*Math.tan(e.pitch*Re),g=(w,x,k)=>p?[w,u+k,(a+c)/2+x]:[(s+l)/2+x,u+k,w],[y,b]=p?[s,l]:[a,c],v=()=>[0,b-y];return[wt("main:a",null,"a",g(y,-h,0),g(b,-h,0),g(y,0,f),e.pitch,v),wt("main:b",null,"b",g(y,h,0),g(b,h,0),g(y,0,f),e.pitch,v)]}function je(t,e){let n=[];for(let r of t.floors.filter(o=>!e||o.id===e)){let{walls:o}=pe(r.rooms,{exterior:t.settings.wall_exterior,interior:t.settings.wall_interior},r.walls??[]);for(let i of o){if(!i.exterior&&!i.free)continue;let[s,l]=[i.b[0]-i.a[0],i.b[1]-i.a[1]],a=Math.hypot(s,l);if(a<1.2)continue;let[c,u]=[l/a,-s/a],d=Math.min(r.height,i.height??r.height,i.heightEnd??1/0),p=(h,f,g,y)=>n.push({key:h,section:null,side:"top",flat:!1,o:f,eu:g,es:[0,1,0],n:y,lu:a,ls:d,pitch:90,span:()=>[0,a],facing:[y[0],y[2]],wall:{floorId:r.id}});p(`wall:${r.id}:${i.id}`,[i.a[0]+c*i.right,r.elevation,i.a[1]+u*i.right],[s/a,0,l/a],[c,0,u]),i.free&&p(`wall:${r.id}:${i.id}:back`,[i.b[0]-c*i.left,r.elevation,i.b[1]-u*i.left],[-s/a,0,-l/a],[-c,0,-u])}}return n}var Oe="ground";function oi(t){let e=t.floors.filter(n=>n.rooms.some(r=>r.points.length>=3)).sort((n,r)=>n.elevation-r.elevation);return e.find(n=>n.elevation>-.5)??e[0]??t.floors[0]??null}function ii(t,e){let n=(e.rotation??0)*Re,r=[Math.cos(n),0,Math.sin(n)],o=[-Math.sin(n),0,Math.cos(n)],i=oi(t),s=r[0]*e.u+o[0]*e.v,l=r[2]*e.u+o[2]*e.v,a=i?i.elevation+(e.base!=null?e.base:Wc(i,s,l)):e.base??0;return{key:Oe,section:null,side:"top",flat:!0,o:[0,a,0],eu:r,es:o,n:[0,1,0],lu:1e4,ls:1e4,pitch:0,span:()=>[-1e4,1e4],facing:[o[0],o[2]],unbounded:!0}}function $e(t,e,n=Z(t)){return e.face===Oe?ii(t,e):e.face.startsWith("wall:")?je(t,e.face.split(":")[1]).find(r=>r.key===e.face)??null:n.find(r=>r.key===e.face)??null}var si=1.13,Hr=1.72,Ue=.025,st=.07;function ln(t){let e=t.module_w||si,n=t.module_h||Hr;return t.portrait===!1?[n,e]:[e,n]}function Lr(t){return t.layout?.length?t.layout.map(e=>Math.max(0,Math.min(60,Math.round(e)))):Array.from({length:Math.max(1,t.rows)},()=>Math.max(1,t.cols))}function aa(t,e){return t.flat?Math.min(45,Math.max(0,e.tilt??15))*Re:t.wall?Math.min(90,Math.max(0,e.tilt??0))*Re:Math.min(45,Math.max(0,e.tilt??0))*Re}function Cr(t,e){let[,n]=ln(e),r=aa(t,e);return t.wall?n*Math.cos(r)+Ue:!t.flat&&r<.001?n+Ue:t.flat&&e.rack==="ew"?n*Math.cos(r)+.08:n*Math.cos(r)+Math.max(.3,2*n*Math.sin(r))}function Nn(t,e){let[n,r]=ln(e),o=Lr(e),i=Math.max(1,...o);return[i*n+(i-1)*Ue,(o.length-1)*Cr(t,e)+r*Math.cos(aa(t,e))]}var Gb=t=>t.flat&&!t.unbounded&&!t.wall;function Rd(t,e){if(!Gb(t)||!e.rotation)return null;let n=e.rotation*Re,[r,o]=Nn(t,e);return{cos:Math.cos(n),sin:Math.sin(n),u:e.u+r/2,s:e.v+o/2}}function Ze(t,e,n=!1){let[r,o]=ln(e),i=aa(t,e),s=o*Math.cos(i),l=Cr(t,e),a=Lr(e),c=Math.max(1,...a),u=new Set(e.skip??[]),d=Rd(t,e),p=(y,b)=>d?[d.u+(y-d.u)*d.cos-(b-d.s)*d.sin,d.s+(y-d.u)*d.sin+(b-d.s)*d.cos]:[y,b],h=(y,b,v)=>{let[w,x]=p(y,b);return[0,1,2].map(k=>t.o[k]+t.eu[k]*w+t.es[k]*x+t.n[k]*v)},f=(y,b)=>{let[v,w]=p(y,b);if(t.unbounded)return!0;if(w<-1e-6||w>t.ls+1e-6)return!1;let[x,k]=t.span(w);return v>=x-1e-6&&v<=k+1e-6},g=[];return a.forEach((y,b)=>{let v=e.align==="right"?c-y:e.align==="center"?(c-y)/2:0;for(let w=0;w.001?s:o);if([[M,F],[A,F],[A,T],[M,T]].every(([O,P])=>f(O,P)))if(t.wall&&i>.001){let O=st+o*Math.sin(i),[P,C]=e.flip?[O,st]:[st,O],B=[h(M,F,P),h(A,F,P),h(A,T,C),h(M,T,C)],q=e.flip?F:T;g.push({corners:B,posts:[M+.05,A-.05].map(we=>[h(we,q,0),h(we,q,O)]),cell:x,skipped:k})}else if(!t.flat&&i>.001){let O=st+o*Math.sin(i),P=[h(M,F,st),h(A,F,st),h(A,T,O),h(M,T,O)];g.push({corners:P,posts:[M+.05,A-.05].map(C=>[h(C,T,0),h(C,T,O)]),cell:x,skipped:k})}else if(!t.flat)g.push({corners:[h(M,F,st),h(A,F,st),h(A,T,st),h(M,T,st)],posts:[],cell:x,skipped:k});else{let P=.15+o*Math.sin(i),C=e.rack==="ew"&&b%2===1?!e.flip:!!e.flip,[B,q]=C?[T,F]:[F,T],we=[h(M,B,.15),h(A,B,.15),h(A,q,P),h(M,q,P)],Mt=[M+.05,A-.05].flatMap(K=>[[h(K,B,0),h(K,B,.15)],[h(K,q,0),h(K,q,P)]]);g.push({corners:we,posts:Mt,cell:x,skipped:k})}}}),g}function ft(t,e){if(t.unbounded)return{u:e.u,v:e.v};let[n,r]=Nn(t,e),o=Rd(t,e);if(o){let[s,l]=[(n*Math.abs(o.cos)+r*Math.abs(o.sin))/2,(n*Math.abs(o.sin)+r*Math.abs(o.cos))/2],a=(d,p,h)=>Math.floor(Math.max(p,Math.min(d,h-p))*100+1e-6)/100,[c,u]=[e.u+n/2,e.v+r/2];return{u:Math.round((a(c,s,t.lu)-n/2)*100)/100,v:Math.round((a(u,l,t.ls)-r/2)*100)/100}}let i=s=>Math.floor(s*100+1e-6)/100;return{u:i(Math.min(Math.max(0,e.u),Math.max(0,t.lu-n))),v:i(Math.min(Math.max(0,e.v),Math.max(0,t.ls-r)))}}function Nr(t,e){let[n,r]=Nn(t,e),[o,i]=[e.u+n/2,e.v+r/2];return[t.o[0]+t.eu[0]*o+t.es[0]*i,t.o[2]+t.eu[2]*o+t.es[2]*i]}var ai=.78,Br=1.18,cn=t=>({id:t.id,face:t.face,u:t.u,v:t.v,rows:1,cols:1,portrait:!0,module_w:t.w||ai,module_h:t.h||Br});function la(t,e){let n=Ze(t,cn(e))[0];if(!n)return null;let r=o=>[o[0]-t.n[0]*.05,o[1]-t.n[1]*.05,o[2]-t.n[2]*.05];return n.corners.map(r)}var Or={brick:{w:.5,d:.5,h:1},round:{w:.4,d:.4,h:1},wide:{w:1,d:.5,h:1},steel:{w:.2,d:.2,h:1.2}};function un(t){let e=t.shape??"brick",n=Or[e]??Or.brick;return{shape:e,w:t.w||n.w,d:t.d||n.d,h:t.h||n.h}}function kt(t,e){let{w:n,d:r}=un(t),o=e&&!e.flat?Math.cos(e.pitch*Re):1;return{id:t.id,face:t.face,u:t.u,v:t.v,rows:1,cols:1,portrait:!0,module_w:n,module_h:r/Math.max(.2,o),tilt:0}}function ca(t,e){let n=kt(e,t),[r,o]=[n.module_w,n.module_h],i=(u,d)=>[t.o[0]+t.eu[0]*u+t.es[0]*d,t.o[1]+t.eu[1]*u+t.es[1]*d,t.o[2]+t.eu[2]*u+t.es[2]*d],[s,l]=[i(e.u+r/2,e.v),i(e.u+r/2,e.v+o)],a=i(e.u+r/2,e.v+o/2),c=u=>{let d=Math.hypot(u[0],u[2])||1;return[u[0]/d,u[2]/d]};return{center:[a[0],a[2]],along:c(t.eu),across:c(t.es),low:Math.min(s[1],l[1]),high:Math.max(s[1],l[1])}}function ua(t,e){let[n]=ln(e);return Ge((t.lu-(e.cols*n+(e.cols-1)*Ue))/2)}var Wr=.4;function Bn(t,e){let n={id:e,face:t.key,u:0,v:0,rows:1,cols:1,portrait:!0,tilt:t.flat?15:null,flip:!1,entity:null,look:"black"},[r]=ln(n),[o,i]=t.span(t.ls/2);for(n.cols=Math.max(1,Math.floor((i-o-2*Wr+Ue)/(r+Ue))),n.rows=Math.max(1,Math.min(4,Math.floor((t.ls-2*Wr)/Cr(t,n))));n.cols>1&&Ze(t,{...n,u:ua(t,n),v:Wr}).lengthl.lu*(1.3+Math.cos((Ir(l.facing,r)-180)*Math.PI/180)),i=je(t,n).sort((l,a)=>o(a)-o(l))[0];if(!i)return null;let s={...Bn(i,e),portrait:!1,rows:1};return s.cols=Math.max(1,Math.floor((i.lu-.8+Ue)/(Hr+Ue))),s.u=Ge((i.lu-(s.cols*Hr+(s.cols-1)*Ue))/2),s.v=Ge(Math.max(0,i.ls-si-.3)),s}function Vr(t,e){let n=t.floors.flatMap(i=>i.rooms.flatMap(s=>s.points)),r=n.length?Math.max(...n.map(i=>i[0]))+3:0,o=n.length?Math.min(...n.map(i=>i[1])):0;return{id:e,face:Oe,u:Ge(r),v:Ge(o),rows:2,cols:4,portrait:!0,tilt:25,flip:!0,rotation:(t.settings.north??0)||0,look:"black",entity:null}}function Kr(t,e,n){let r=ii(t,e),[o,i]=Nn(r,e),[s,l]=[e.u+o/2,e.v+i/2],a=[r.eu[0]*s+r.es[0]*l,r.eu[2]*s+r.es[2]*l],c=n*Re,u=a[0]*Math.cos(c)+a[1]*Math.sin(c)-o/2,d=a[0]*-Math.sin(c)+a[1]*Math.cos(c)-i/2;return{u:Ge(u),v:Ge(d),rotation:(Math.round(n)%360+360)%360}}function Gr(t,e){let[n,r]=t.span(t.ls/2);return{id:e,face:t.key,u:Ge((n+r-ai)/2),v:Ge(Math.max(0,Math.min(t.ls-Br,t.ls*.45-Br/2))),w:null,h:null,cover:null,contact:null,tilt:null}}function jr(t,e){let n=Or.brick,[r,o]=t.span(t.ls*.8),i=kt({id:e,face:t.key,u:0,v:0},t).module_h;return{id:e,face:t.key,u:Ge((r+o-n.w)/2),v:Ge(Math.max(0,Math.min(t.ls-i,t.ls*.8-i/2))),shape:"brick",w:null,d:null,h:null}}function Wn(t,e){let[n,r]=[e[0]-t.o[0],e[1]-t.o[2]],[o,i,s,l]=[t.eu[0],t.eu[2],t.es[0],t.es[2]],a=o*l-i*s;if(Math.abs(a)<1e-9)return null;let c=(n*l-r*s)/a,u=(o*r-i*n)/a;if(u<0||u>t.ls)return null;let[d,p]=t.span(u);return c>=d&&c<=p?{u:c,s:u}:null}function ha(t,e){let n=null;for(let r of t){if(r.wall){let[s,l]=[e[0]-r.o[0],e[1]-r.o[2]],a=s*r.eu[0]+l*r.eu[2],c=s*r.n[0]+l*r.n[2],u=a>=0&&a<=r.lu;if(u&&c>=-.05&&c<=.35)return{face:r,u:a,s:Number.NaN};u&&c>.35&&c<=.8&&!n&&(n={face:r,u:a,s:Number.NaN,y:-1/0});continue}let o=Wn(r,e);if(!o)continue;let i=r.o[1]+r.es[1]*o.s;(!n||i>n.y)&&(n={face:r,...o,y:i})}return n&&{face:n.face,u:n.u,s:n.s}}function ci(t,e,n){let r=sn(n,t.n);if(Math.abs(r)<1e-6)return null;let o=sn(Ke(t.o,e),t.n)/r;if(o<=0)return null;let i=Ke([e[0]+n[0]*o,e[1]+n[1]*o,e[2]+n[2]*o],t.o);return{t:o,u:sn(i,t.eu),s:sn(i,t.es)}}function pa(t,e,n){if(t.unbounded)return!0;if(n<0||n>t.ls)return!1;let[r,o]=t.span(n);return e>=r&&e<=o}function fa(t,e,n,r){return Ze(t,e).some(i=>{let s=i.corners.map(c=>{let u=Ke(c,t.o);return[sn(u,t.eu),sn(u,t.es)]}),l=s.map(c=>c[0]),a=s.map(c=>c[1]);return n>=Math.min(...l)-.05&&n<=Math.max(...l)+.05&&r>=Math.min(...a)-.05&&r<=Math.max(...a)+.05})}var jb=["n","ne","e","se","s","sw","w","nw"],ma=(t,e)=>jb[Math.round(Ir(t.facing,e)/45)%8];function Ur(t,e){let n=r=>{if(r.flat)return r.lu*r.ls*.8;let o=Math.cos((Ir(r.facing,e)-180)*Math.PI/180);return r.lu*r.ls*(1.2+o)};return[...t].sort((r,o)=>n(o)-n(r))[0]??null}var Td=["kitchen_row","kitchen_l","bath","bedroom","living","dining","office","kids","hall"],Ed={kitchen_row:{rows:[["back","start",["fridge","kitchen_tall",["kitchen",[.9,.62,.92]],"sink","dishwasher","stove",["kitchen",[.6,.62,.92]]]],["back","start",[["kitchen_wall",[1.2,.35,.7]]]]],spots:[[["table",[1.2,.8,.75]],.5,.72,0],["lamp_pendant",.5,.72,0],["lamp_ceiling",.5,.3,0]]},kitchen_l:{rows:[["back","start",["fridge",["kitchen",[.9,.62,.92]],"sink","dishwasher","stove"]],["right","start",[["kitchen",[.9,.62,.92]],["kitchen",[.6,.62,.92]],"kitchen_tall"]],["back","start",[["kitchen_wall",[1.2,.35,.7]]]]],spots:[["table",.4,.68,0],["bar_stool",.72,.86,180],["lamp_ceiling",.5,.35,0]]},bath:{rows:[["back","center",["washbasin"]],["back","end",["wc"]],["front","start",["bathtub"]],["left","start",["washer"]]],spots:[["lamp_downlight",.5,.5,0]]},bedroom:{rows:[["back","center",["nightstand","bed","nightstand"]],["left","center",[["wardrobe",[2,.6,2.1]]]],["front","end",["dresser"]]],spots:[["lamp_ceiling",.5,.55,0]]},living:{rows:[["back","center",["tv_board"]],["right","start",["shelf"]]],spots:[["sofa",.5,.72,180],["coffee_table",.5,.52,0],[["rug",[2.2,1.6,.01]],.5,.55,0],["armchair",.14,.5,270],["lamp_floor",.86,.8,0],["plant",.9,.12,0],["lamp_ceiling",.5,.45,0]]},dining:{rows:[["back","center",["sideboard"]]],spots:[["table",.5,.55,0],["chair",.4,.35,0],["chair",.6,.35,0],["chair",.4,.75,180],["chair",.6,.75,180],["lamp_pendant",.5,.55,0]]},office:{rows:[["back","center",["desk"]],["left","center",["shelf","shelf"]]],spots:[["office_chair",.5,.38,180],["lamp_ceiling",.5,.55,0]]},kids:{rows:[["left","start",[["bed",[.9,2,.8]]]],["back","end",[["desk",[1.2,.6,.75]]]],["right","end",["shelf"]]],spots:[[["rug",[1.6,1.2,.01]],.55,.6,0],["lamp_ceiling",.5,.5,0]]},hall:{rows:[["left","start",["coat_rack"]]],spots:[["lamp_downlight",.5,.3,0],["lamp_downlight",.5,.7,0]]}},Ad=t=>typeof t=="string"?t:t[0],ui=t=>typeof t=="string"?tt[t]:t[1],Vn=.05,Ub=.02,Fd=t=>Math.round(t*1e3)/1e3;function Zb(t,e,n,r){switch(e){case"back":return{x:t.x0+n,z:t.z0+r,turn:0};case"right":return{x:t.x1-r,z:t.z0+n,turn:90};case"front":return{x:t.x1-n,z:t.z1-r,turn:180};case"left":return{x:t.x0+r,z:t.z1-n,turn:270}}}function zd(t,e,n){let r=ue(t.points),o=r.x1-r.x0,i=r.z1-r.z0,s=[],l=(a,c,u,d,[p,h,f])=>{s.push({id:n(),type:a,x:Fd(c),z:Fd(u),rotation:d,w:p,d:h,h:f,variant:null,entity:null,power:null})};for(let[a,c,u]of Ed[e].rows){let d=a==="back"||a==="front"?o:i,p=0,h=[];for(let g of u){if(p+ui(g)[0]>d-.1)break;h.push(g),p+=ui(g)[0]}let f=c==="start"?Vn:c==="end"?d-p-Vn:(d-p)/2;for(let g of h){let y=ui(g),b=Zb(r,a,f+y[0]/2,y[1]/2+Ub);l(Ad(g),b.x,b.z,b.turn,y),f+=y[0]}}for(let[a,c,u,d]of Ed[e].spots){let p=ui(a),h=(y,b,v)=>Math.min(v,Math.max(b,y)),f=h(r.x0+o*c,r.x0+p[0]/2+Vn,r.x1-p[0]/2-Vn),g=h(r.z0+i*u,r.z0+p[1]/2+Vn,r.z1-p[1]/2-Vn);l(Ad(a),f,g,d,p)}return s}var qb=30*Math.PI/180,Pd=.05;function ga(t){let e=t.points.length;return t.points.map((n,r)=>{let o=t.points[(r+1)%e];return Math.hypot(o[0]-n[0],o[1]-n[1])})}function Zr(t){return ga(t).reduce((e,n)=>e+n,0)}function Yb(t,e){let n=ga(t),r=0;for(let o=0;oh+f,0);if(o<3||!(i>0)||!(n>0))return null;let s=Math.min(n,i),l=(e%i+i)%i,a=0,c=0;for(;a=c+r[a];)c+=r[a],a++;let u=l-c,d=s,p=[];for(let h=0;h<=o&&d>1e-9;h++){let f=r[a]-u,g=Math.min(d,f);g>1e-9&&p.push({edge:a,t0:u,t1:u+g}),d-=g,u=0;let y=(a+1)%o;if(d>1e-9&&Xb(t,a)>qb)break;a=y}for(;p.length>1&&p[0].t1-p[0].t01&&p[p.length-1].t1-p[p.length-1].t0({edge:h.edge,offset:(h.t0+h.t1)/2,width:h.t1-h.t0})):null}function Kn(t,e){let n=e[0];return n?{from:Yb(t,n.edge)+n.offset-n.width/2,width:e.reduce((r,o)=>r+o.width,0)}:null}function Nt(t,e){return e.front?t.filter(n=>n.front===e.front):[e]}function ba(t,e){let n=t.points.length,r=1/0,o=0,i=0;for(let s=0;sD("opening")){let s=_a(e,r,o);if(!s)return null;let l=Nt(t,n),a=new Set(l.map(h=>h.id)),c=s.length>1?l[0].front??`front-${l[0].id}`:null,u=s.map((h,f)=>({...n,id:f===0?l[0].id:i(),edge:h.edge,offset:h.offset,width:h.width,front:c})),d=[],p=!1;for(let h of t){if(!a.has(h.id)){d.push(h);continue}p||(d.push(...u),p=!0)}return d}var wa=globalThis,ya=wa.__nextfloorBuiltin?.de??{},va=wa.__nextfloorBuiltin?.en??{};wa.__nextfloorBuiltin??={de:ya,en:va};var Qb=()=>typeof $=="object"&&$||{},Jb=globalThis,ey=Jb.__nextfloorTexts??=new Map;function ty(t){let e=t.toLowerCase().split("-")[0];return e!=="de"&&e!=="en"&&e in Qb()?e:void 0}function Dd(t){let e=ty(t),n=e===void 0?void 0:ey.get(e);return n instanceof Promise?void 0:n}function di(t,e){return Dd(t)?.[e]}function Se(t,e,n={}){let r=t?.language??navigator.language,o=r.startsWith("de"),i=(o?void 0:Dd(r)?.[e])??(o?ya:va)[e]??va[e]??ya[e]??e;for(let[s,l]of Object.entries(n))i=i.replace(`{${s}}`,String(l));return i}function U(t,e,n=2){return e.toLocaleString(t?.language??void 0,{maximumFractionDigits:n})}var ge=t=>/^(sensor|input_number|number)\./.test(t),hi=t=>/^(binary_sensor|input_boolean)\./.test(t);function Gn(t,e){if(!ge(e))return!1;let n=t?.states[e]?.attributes;return n?.device_class==="power"||n?.unit_of_measurement==="W"||n?.unit_of_measurement==="kW"}function ny(t,e){let n=t?.entities?.[e],r=n?.area_id??(n?.device_id?t?.devices?.[n.device_id]?.area_id:null);return r?t?.areas?.[r]?.name:void 0}function H(t,e){return Object.keys(t?.states??{}).filter(e).map(n=>{let r=ny(t,n),o=t?.states[n],i=typeof o?.attributes.symcon_path=="string"?o.attributes.symcon_path:void 0,s={id:n,label:r?`${W(t,n)} \xB7 ${r}`:W(t,n)};return i&&(s.detail=`Objektbaum: ${i}`),typeof o?.attributes.symcon_source_entity=="string"&&(s.sourceEntity=o.attributes.symcon_source_entity),s}).sort((n,r)=>n.label.localeCompare(r.label))}function pi(t,e){return t.power&&t.power!=="none"?t.power:e.get(t.id)?.power??null}var Id=[{key:"supply_vsr",label:"Zuluft-VSR",types:[0,1,2],control:!0},{key:"extract_vsr",label:"Abluft-VSR",types:[0,1,2],control:!0},{key:"supply_temperature",label:"Zulufttemperatur",types:[1,2]},{key:"extract_temperature",label:"Ablufttemperatur",types:[1,2]},{key:"reheat",label:"NHR (Nachheizregister)",types:[0,1,2],control:!0},{key:"status",label:"Raumstatus",types:[1]}];function Od(t,e,n){let r=s=>n({hvac:{...e.hvac,...s}}),o=e.hvac?.schedules??[],i=H(t.hass,s=>!!t.hass?.states[s]?.attributes.symcon_schedule);return m` ${z(t,t.t("floor_heating"),e.floor_heating??null,void 0,H(t.hass,s=>Fn(t.hass,s,[0,1,2])),s=>n({floor_heating:s==="none"?null:s}))} ${Id.map(s=>z(t,s.label,e.hvac?.[s.key]??null,void 0,H(t.hass,l=>Fn(t.hass,l,s.types)),l=>r({[s.key]:l==="none"?null:l})))} ${S("Raumstatus zeigt den in Symcon hinterlegten Alias der Integer-Variable. Beschreibbare Heizungs- und L\xFCftungswerte k\xF6nnen im Raummen\xFC bedient werden.","nf-wide")} ${o.map((s,l)=>z(t,`Schaltuhr ${l+1}`,s,void 0,i.filter(a=>a.id===s||!o.includes(a.id)),a=>r({schedules:a&&a!=="none"?o.map((c,u)=>l===u?a:c):o.filter((c,u)=>l!==u)})))} ${z(t,"Schaltuhr hinzuf\xFCgen",null,void 0,i.filter(s=>!o.includes(s.id)),s=>s&&s!=="none"&&r({schedules:[...o,s]}))}`}function Hd(t,e,n){return m`
Wettervariablen
${Tc.map(r=>z(t,Su[r],e.weather_variables?.[r]??null,void 0,H(t.hass,o=>Fn(t.hass,o,r==="condition"?[0,1,2,3]:r==="wind_bearing"?[1,2,3]:["snow","fog","lightning"].includes(r)?[0,1,2]:[1,2])),o=>n({weather_variables:{...e.weather_variables,[r]:o==="none"?null:o}})))} ${z(t,t.t("rain_sensor"),e.rain_sensor??null,void 0,H(t.hass,r=>Fn(t.hass,r,[0,1,2])),r=>n({rain_sensor:r==="none"?null:r}))} ${e.rain_sensor?I(t,t.t("rain_sensor_inverted"),!!e.rain_sensor_inverted,r=>n({rain_sensor_inverted:r||void 0})):_} ${S("W\xE4hle die Wetterwerte einzeln aus dem Symcon-Objektbaum. Einheiten werden aus den Variablen \xFCbernommen. Der Regensensor kann Boolean oder eine numerische Regenrate sein.","nf-wide")}
`}function Ld(t){let e=t.doc.presence,n=s=>t.replace({...structuredClone(t.doc),presence:s}),r=(s,l)=>n(e.map((a,c)=>c===s?{...a,...l,sensor:null}:a)),o=t.doc.floors.flatMap(s=>s.rooms.map(l=>({id:l.id,name:`${s.name} \xB7 ${l.name}`}))),i=H(t.hass,s=>Fn(t.hass,s,[0]));return m`
${t.t("presence")} ${e.map((s,l)=>m`
${V(t,"Person",s.name??W(t.hass,s.person),a=>r(l,{name:a}),{wide:!0,maxlength:100})} ${z(t,"Anwesenheit (Boolean)",s.person,void 0,i.filter(a=>a.id===s.person||!e.some(c=>c.person===a.id)),a=>a&&a!=="none"?r(l,{person:a}):n(e.filter((c,u)=>u!==l)))}
`)}
${z(t,"Person hinzuf\xFCgen (Boolean)",null,void 0,i.filter(s=>!e.some(l=>l.person===s.id)),s=>s&&s!=="none"&&n([...e,{person:s,sensor:null}]))}
${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.")}
`}function Cd(t,e,n){let r=t.find(a=>a.person===e),o="sensor"in n?n.sensor&&n.sensor!=="none"?n.sensor:null:r?.sensor??null,i="room"in n?n.room||null:r?.room??null,s=t.filter(a=>a.person!==e);if(!o&&!i)return s;let l=i?{person:e,sensor:o,room:i}:{person:e,sensor:o};return r?t.map(a=>a.person===e?l:a):[...s,l]}function Nd(t,e){let n=e.slice(e.indexOf(".")+1),r=o=>o.id.includes(n)&&/(area|room|raum|bermuda|espresense)/.test(o.id);return[...t.filter(r),...t.filter(o=>!r(o))]}function Bd(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 Wd(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 fi(t,e,n){let r=[...t],[o]=r.splice(e,1);return r.splice(Math.max(0,Math.min(r.length,e+n)),0,o),r}var Bt=(t,e)=>t.filter((n,r)=>r!==e),Yr=(t,e,n)=>t.map((r,o)=>o===e?{...r,...n}:r),mt=t=>t.length>0?t:void 0;var ry=["scene","script","automation","button","input_button","switch","input_boolean","light","fan","cover","lock"],oy=40,iy=20,sy=30,ay=["music","url","playlist","SPOTIFY","AMAZON_MUSIC","TUNEIN","APPLE_MUSIC"],ka={navigate:"/lovelace/rollos",more_info:"cover.wohnzimmer",service:"script.turn_on",fire_dom_event:""},Xr=(t,e,n,r=!1)=>m``;function ly(t){let e=t.doc.settings.favorites??[],n=l=>t.change(a=>a.settings.favorites=mt(l)),r=t.doc.floors,o=t.doc.settings.favorite_floors??{},i=H(t.hass,l=>ry.includes(l.split(".")[0])&&!e.includes(l)),s=(l,a)=>m`
${W(t.hass,l)} ${r.length>1?m``:_} ${Xr(t.t("move_up"),"\u2191",()=>n(fi(e,a,-1)),a===0)} ${Xr(t.t("move_down"),"\u2193",()=>n(fi(e,a,1)),a===e.length-1)} ${Xr(t.t("delete"),"\u2715",()=>n(Bt(e,a)))}
`;return m`${t.t("favorites")}${e.length>0?m` ${e.length}`:_} ${S(t.t("favorites_hint"))} ${e.map(s)} ${e.length${z(t,t.t("favorites_add"),null,void 0,i,l=>l&&l!=="none"&&!e.includes(l)&&n([...e,l]))}`:_}`}function cy(t,e){let n=t.doc.settings.outside_hidden??[],r=s=>t.change(l=>l.settings.outside_hidden=mt(s)),o=new Set(t.hass?Du(t.hass,t.doc.floors):[]),i=H(t.hass,s=>!n.includes(s)&&o.has(s));return m`${e?uy(t,e):_}

${t.t("outside_hidden")}${n.length>0?m` ${n.length}`:_}

${S(t.t("outside_hidden_hint"))} ${n.map((s,l)=>m`
${W(t.hass,s)}${Xr(t.t("delete"),"\u2715",()=>r(Bt(n,l)))}
`)}
${z(t,t.t("outside_hidden_add"),null,void 0,i,s=>s&&s!=="none"&&!n.includes(s)&&r([...n,s]))}
`}function uy(t,e){let n=t.doc.settings.outside_view??null,r=()=>{let o=e();o&&t.change(i=>i.settings.outside_view=o)};return m`${S(t.t("outside_view_hint"))} ${Y(m``,n?m``:_)}`}function dy(t){let e=t.doc.settings.own_alerts??[],n=s=>t.change(l=>l.settings.own_alerts=mt(s)),r=(s,l)=>n(Yr(e,s,l)),o=[["",t.t("own_alert_house")],...t.doc.floors.flatMap(s=>s.rooms.map(l=>[l.id,`${l.name} \xB7 ${s.name}`]))],i=(s,l)=>m`
${z(t,t.t("own_alert_entity"),s.entity||null,void 0,H(t.hass,()=>!0),a=>r(l,{entity:a&&a!=="none"?a:""}))} ${V(t,t.t("own_alert_state"),s.state??"",a=>r(l,{state:a||null}),{placeholder:t.hass?.states[s.entity]?.state??"on \xB7 <20 \xB7 >80"})} ${V(t,t.t("own_alert_text"),s.text,a=>r(l,{text:a||t.t("own_alert_new")}),{wide:!0,maxlength:120})} ${L(t,t.t("room"),s.room_id??"",o,a=>r(l,{room_id:a||null}),{wide:!0})} ${Ve(t,t.t("own_alert_color"),s.color??null,"#ffb547",a=>r(l,{color:a}))} ${L(t,t.t("own_alert_tap"),s.tap??"",[["",t.t("own_alert_tap_info")],["toggle",t.t("own_alert_tap_toggle")],["room",t.t("own_alert_tap_room")]],a=>r(l,{tap:a||null}))}
`;return m`

⚠ ${t.t("own_alerts")}

${S(t.t("own_alerts_hint"))} ${e.map(i)} ${e.length<40?Y(m``):_}`}function hy(t){let e=t.doc.settings.circuits??[],n=l=>t.change(a=>a.settings.circuits=mt(l)),r=(l,a)=>n(Yr(e,l,a)),o=t.doc.floors.flatMap(l=>l.rooms.map(a=>({id:a.id,label:t.doc.floors.length>1?`${a.name} \xB7 ${l.name}`:a.name}))),i=l=>o.find(a=>a.id===l)?.label??l,s=(l,a)=>m`
${V(t,t.t("circuit_name"),l.name,c=>r(a,{name:c||t.t("circuit_new")}),{wide:!0,maxlength:80})}
${l.rooms.map(c=>m`${i(c)} `)}
${L(t,t.t("circuit_add_room"),"",[["","\u2013"],...o.filter(c=>!l.rooms.includes(c.id)).map(c=>[c.id,c.label])],c=>c&&r(a,{rooms:[...l.rooms,c]}),{wide:!0})}
`;return m`

🔌 ${t.t("circuits")}

${S(t.t("circuits_hint"))} ${e.map(s)} ${e.length<120?Y(m``):_}`}function py(t){let e=t.doc.settings.calendars??[],n=l=>t.change(a=>a.settings.calendars=mt(l)),r=H(t.hass,l=>l.startsWith("calendar.")&&!e.includes(l)),o=(l,a)=>m`
${W(t.hass,l)} ${Xr(t.t("delete"),"\u2715",()=>n(Bt(e,a)))}
`,i=t.t,s=t.doc.settings.today_days??1;return m`

📅 ${i("today_calendars")}

${S(i("today_calendars_hint"))} ${e.map(o)} ${e.length<12?m`
${z(t,i("favorites_add"),null,void 0,r,l=>l&&l!=="none"&&!e.includes(l)&&n([...e,l]))}
`:_} ${e.length?m`
${L(t,i("today_days"),String(s),[1,2,3,5,7].map(l=>[String(l),i(l===1?"today_days_one":"today_days_n",{n:l})]),l=>t.change(a=>a.settings.today_days=Number(l)>1?Number(l):void 0))}
`:_} ${fy(t)}`}function fy(t){let e=t.t,n=t.doc.settings.forecast??null,r=o=>t.change(i=>i.settings.forecast=o??void 0);return m`

🌦 ${e("forecast")}

${S(e("forecast_hint"))}
${L(t,e("forecast_days"),n?String(n.days):"0",[0,3,5,7].map(o=>[String(o),o?e("today_days_n",{n:o}):e("forecast_off")]),o=>r(Number(o)>0?{days:Number(o),corner:n?.corner??"top_right"}:null))} ${n?L(t,e("forecast_corner"),n.corner,[["top_right",e("clock_top_right")],["top_left",e("clock_top_left")]],o=>r({...n,corner:o==="top_left"?"top_left":"top_right"})):_}
`}function my(t){let e=t.doc.settings.media_presets??[],n=s=>t.change(l=>l.settings.media_presets=mt(s)),r=(s,l)=>n(Yr(e,s,l)),o=[...new Set(t.doc.floors.flatMap(s=>[...s.placements.map(l=>l.entity_id),...s.furniture.map(l=>l.entity??"")]).filter(s=>s.startsWith("media_player.")))],i=(s,l)=>m`
${V(t,t.t("own_button_label"),s.label,a=>r(l,{label:a||"Radio"}),{maxlength:60})} ${V(t,t.t("preset_type"),s.type,a=>r(l,{type:a||"music"}),{title:t.t("preset_type_hint")})} ${V(t,t.t("preset_content"),s.content,a=>r(l,{content:a}),{wide:!0,title:t.t("preset_content_hint"),placeholder:"https://\u2026 \xB7 spotify:playlist:\u2026 \xB7 Rock Antenne"})} ${o.length>1?m`
${t.t("preset_speakers")}
${o.map(a=>I(t,W(t.hass,a),!!s.speakers?.includes(a),c=>r(l,{speakers:mt(c?[...s.speakers??[],a]:(s.speakers??[]).filter(u=>u!==a))}),{wide:!1}))}`:_}
`;return m`

${t.t("presets")}

${S(t.t("presets_hint"))} ${ay.map(s=>m``)} ${e.map(i)} ${e.lengthn([...e,{id:D("preset"),label:"Radio",type:"music",content:""}])}>+ ${t.t("preset_add")}`):_}`}function xa(t,e,n){let r=e.action==="fire_dom_event"?'{"browser_mod": {"service": "browser_mod.popup", "data": {"title": "Rollos", "content": {"type": "custom:my-cover-card"}}}}':'{"entity_id": "script.party"}',o=i=>{let s=i.target;s.setCustomValidity("");let l=Wd(s.value);if(l.ok)return n(l.value);s.setCustomValidity(t.t("own_data_bad")),s.reportValidity()};return m``}function gy(t){let e=t.doc.settings.buttons??[],n=s=>t.change(l=>l.settings.buttons=mt(s)),r=(s,l)=>n(Yr(e,s,l)),o=Io.map(s=>[s,t.t(`own_action_${s}`)]),i=(s,l)=>m`
${V(t,t.t("own_button_label"),s.label,a=>r(l,{label:a||t.t("own_button_new")}),{maxlength:60})} ${L(t,t.t("own_button_action"),s.action,o,a=>r(l,{action:a}))} ${Ot(t,s.icon??null,a=>r(l,{icon:a}))} ${s.action!=="fire_dom_event"?V(t,t.t(`own_target_${s.action}`),s.target??"",a=>r(l,{target:a||null}),{wide:!0,placeholder:ka[s.action]}):_} ${s.action==="service"||s.action==="fire_dom_event"?xa(t,s,a=>r(l,{data:a})):_} ${z(t,t.t("own_button_state"),s.state_entity??null,void 0,H(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}))}
`;return m`

${t.t("own_buttons")}

${S(t.t("own_buttons_hint"))} ${e.map(i)} ${e.lengthn([...e,{id:D("btn"),label:t.t("own_button_new"),action:"navigate",target:null}])}>+ ${t.t("own_button_add")}`):_}`}function _y(t){let e=t.doc.settings.room_facts_off??[],n=["sun","comfort","air","circuits"].map(r=>I(t,t.t(`room_fact_${r}`),!e.includes(r),o=>t.change(i=>i.settings.room_facts_off=mt(o?e.filter(s=>s!==r):[...e,r]))));return m`

${t.t("room_facts")}

${n}
`}function Vd(t){return m`
${ly(t)} ${gy(t)} ${dy(t)} ${hy(t)} ${py(t)} ${my(t)} ${_y(t)}
`}function Kd(t,e){return m`
🌳 ${t.t("outside_area")} ${cy(t,e)}
`}function Gd(t,e){let n=t.doc.settings.start_view??null,r=()=>{let o=e();o&&t.change(i=>i.settings.start_view=o)};return m`
${t.t("start_view")} ${S(t.t("start_view_hint"))} ${Y(m``,n?m``:_)} ${n?m`${S(t.t("start_view_saved"))} ${S(t.t("start_view_card"))}${Bd(n)}`:_}
`}function jd(t){if(fe(t.hass))return Ld(t);let e=t.doc.presence.map(a=>a.person),n=[...new Set([...Object.keys(t.hass?.states??{}).filter(a=>a.startsWith("person.")).sort(),...e])],r=H(t.hass,ge),o=t.doc.floors.flatMap(a=>a.rooms.map(c=>({id:c.id,label:t.doc.floors.length>1?`${a.name} \xB7 ${c.name}`:c.name}))),i=(a,c)=>t.replace({...structuredClone(t.doc),presence:Cd(t.doc.presence,a,c)}),s=a=>{let c=t.doc.presence.find(d=>d.person===a),u=!a.startsWith("person.");return m`${z(t,`${W(t.hass,a)} \xB7 ${t.t("presence_sensor")}`,c?.sensor??null,void 0,Nd(r,a),d=>i(a,{sensor:d}))} ${u?m``:_}`},l=H(t.hass,a=>/^(input_boolean|binary_sensor|device_tracker)\./.test(a)&&!n.includes(a));return m`
${t.t("presence")}
${n.length>0?n.map(s):m`

${t.t("no_persons")}

`}
${z(t,t.t("presence_add"),null,void 0,l,a=>a&&a!=="none"&&t.replace({...structuredClone(t.doc),presence:[...t.doc.presence,{person:a,sensor:null}]}))}
${S(t.t("presence_hint"))}
`}function Ud(t,e){return fe(t.hass)?m``:m`
${t.t("ble")} ${S(t.t("ble_hint"))}
`}var Qr=(t,e)=>{let n=t._$AN;if(n===void 0)return!1;for(let r of n)r._$AO?.(e,!1),Qr(r,e);return!0},mi=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while(n?.size===0)},Zd=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),vy(e)}};function by(t){this._$AN!==void 0?(mi(this),this._$AM=t,Zd(this)):this._$AM=t}function yy(t,e=!1,n=0){let r=this._$AH,o=this._$AN;if(o!==void 0&&o.size!==0)if(e)if(Array.isArray(r))for(let i=n;i{t.type==Tn.CHILD&&(t._$AP??=yy,t._$AQ??=by)},gi=class extends Dt{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),Zd(this),this.isConnected=e._$AU}_$AO(e,n=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),n&&(Qr(this,e),mi(this))}setValue(e){if(Nu(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 $a=new WeakMap,qd=Jt(class extends gi{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=$a.get(e);n===void 0&&(n=new WeakMap,$a.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"?$a.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 Yd=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 Xd(t){let e=t.t,n=t.doc.settings.card_templates??{},r=Object.keys(n),o=l=>t.change(a=>{a.settings.card_templates=Object.keys(l).length?l:void 0});t.loadCardEditor?.();let i=l=>{t.hass?.callService("nextfloor","reload_screens",l?{template:l}:{})},s=l=>{let a=Yd(l.value);!a||a in n||r.length>=20||(l.value="",o({...n,[a]:{}}))};return m`
${e("card_templates")}${r.length?m` ${r.length}`:_} ${S(e("card_templates_hint"))} ${r.map(l=>m`
${l} a&&a.setConfig({type:"custom:nextfloor-card",...n[l]}))} @config-changed=${a=>{a.stopPropagation();let{type:c,template:u,...d}=a.detail.config;o({...n,[l]:d})}} > ${t.admin?m`
`:_} ${S(e("template_use",{name:l}))}
`)} ${t.admin?m`
`:_}
`}var _i=.05,wy=(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),dn=t=>new Map(t.map(e=>[e.id,e]));function ky(t,e,n,r){let o=e.name,[i,s]=[dn(t.rooms),dn(e.rooms)];for(let h of e.rooms){let f=i.get(h.id);f?(f.name!==h.name&&n.push({kind:"room_renamed",floor:o,name:h.name,detail:f.name}),wy(f.points,h.points)||n.push({kind:"room_reshaped",floor:o,name:h.name,detail:Math.round((ke(h.points)-ke(f.points))*10)/10})):n.push({kind:"room_added",floor:o,name:h.name})}for(let h of t.rooms)s.has(h.id)||n.push({kind:"room_removed",floor:o,name:h.name});let[l,a]=[dn(t.openings),dn(e.openings)];for(let h of e.openings)l.has(h.id)||n.push({kind:"opening_added",floor:o,name:h.type,detail:r(h.room_id)});for(let h of t.openings)a.has(h.id)||n.push({kind:"opening_removed",floor:o,name:h.type,detail:r(h.room_id)});let[c,u]=[dn(t.furniture),dn(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)>_i||Math.abs(h.rotation-f.rotation)>1||Math.abs(h.w-f.w)>_i||Math.abs(h.d-f.d)>_i)&&n.push({kind:"furniture_moved",floor:o,name:h.name||h.type}):n.push({kind:"furniture_added",floor:o,name:h.name||h.type})}for(let h of t.furniture)u.has(h.id)||n.push({kind:"furniture_removed",floor:o,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)>_i&&n.push({kind:"device_moved",floor:o,name:h.entity_id}):n.push({kind:"device_added",floor:o,name:h.entity_id})}for(let h of t.placements)p.has(h.entity_id)||n.push({kind:"device_removed",floor:o,name:h.entity_id})}function Qd(t,e){let n=[],r=dn(t.floors),o=new Map([...t.floors,...e.floors].flatMap(l=>l.rooms.map(a=>[a.id,a.name]))),i=l=>o.get(l)??"";for(let l of e.floors){let a=r.get(l.id);a?ky(a,l,n,i):n.push({kind:"floor_added",floor:l.name,name:l.name})}let s=new Set(e.floors.map(l=>l.id));for(let l of t.floors)s.has(l.id)||n.push({kind:"floor_removed",floor:l.name,name:l.name});return n}var hn=(t,e)=>t.getUint16(e,!0),Jr=(t,e)=>t.getUint32(e,!0);function Jd(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(Jr(e,l)===101010256){n=l;break}if(n<0)throw new Error("not_zip");let r=hn(e,n+10),o=Jr(e,n+16),i=[],s=new TextDecoder;for(let l=0;l",quot:'"',apos:"'"},$y=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)):xy[n]??e);function Sy(t){let e={};for(let n of t.matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))e[n[1]]=$y(n[2]??n[3]);return e}function My(t){let e=[],n=null;for(let r of t.matchAll(/<(\/?)(level|room|point|wall|doorOrWindow|pieceOfFurniture)\b([^>]*?)(\/?)>/g)){let[,o,i,s,l]=r;if(o){i==="room"&&(n=null);continue}let a=Sy(s);if(i==="point"){n&&n.points.push([Number(a.x)/100,Number(a.y)/100]);continue}let c={name:i,attrs:a,...i==="room"?{points:[]}:{}};e.push(c),i==="room"&&!l&&(n=c)}return e}var oe=(t,e,n)=>Number.isFinite(Number(t[e]))&&t[e]!==void 0?Number(t[e]):n,Ee=t=>Math.round(t*1e3)/1e3;function th(t,e,n){let[r,o]=[n[0]-e[0],n[1]-e[1]],i=Math.hypot(r,o)||1e-9,s=Math.max(0,Math.min(i,((t[0]-e[0])*r+(t[1]-e[1])*o)/i)),l=[e[0]+r*s/i,e[1]+o*s/i];return{dist:Math.hypot(t[0]-l[0],t[1]-l[1]),along:s,length:i}}function Ry(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 Ey(t,e){let n=t.length,r=t.map((o,i)=>{let s=t[(i+1)%n],[l,a]=[s[0]-o[0],s[1]-o[1]],c=Math.hypot(l,a)||1e-9,u=[l/c,a/c],d=[(o[0]+s[0])/2,(o[1]+s[1])/2],p=[0,0];for(let h of e){let[f,g]=[h.b[0]-h.a[0],h.b[1]-h.a[1]],y=Math.hypot(f,g)||1e-9;if(Math.abs((u[0]*g-u[1]*f)/y)>.05)continue;let b=(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)/y;if(!(Math.abs(b)>h.thickness/2+.06||v<-.05||v>y+.05)){p=[-u[1]*b,u[0]*b];break}}return{p:[o[0]+p[0],o[1]+p[1]],dir:u}});return r.map((o,i)=>{let s=r[(i-1+n)%n],l=s.dir[0]*o.dir[1]-s.dir[1]*o.dir[0];if(Math.abs(l)<1e-6)return o.p;let a=((o.p[0]-s.p[0])*o.dir[1]-(o.p[1]-s.p[1])*o.dir[0])/l;return[s.p[0]+s.dir[0]*a,s.p[1]+s.dir[1]*a]})}function Ay(t){let e=Ft(),n={floors:0,rooms:0,openings:0,walls:0,furniture:0},r=t.filter(a=>a.name==="level"),o=r.length?r.map(a=>a.attrs.id??""):[""],i=t.filter(a=>a.name==="wall"),s=i.length?Math.max(...i.map(a=>oe(a.attrs,"height",250)))/100:2.5;return(r.length?[...r].sort((a,c)=>oe(a.attrs,"elevation",0)-oe(c.attrs,"elevation",0)||oe(a.attrs,"elevationIndex",0)-oe(c.attrs,"elevationIndex",0)):[{name:"level",attrs:{id:""}}]).forEach((a,c)=>{let u=a.attrs.id??"",d=y=>r.length?(y.attrs.level??o[0])===u:!0,p=Ce(D("floor"),a.attrs.name||(c===0?"Erdgeschoss":`Etage ${c+1}`),Ee(oe(a.attrs,"elevation",0)/100));p.height=Ee(oe(a.attrs,"height",s*100)/100);let h=i.filter(d).map(y=>({a:[oe(y.attrs,"xStart",0)/100,oe(y.attrs,"yStart",0)/100],b:[oe(y.attrs,"xEnd",0)/100,oe(y.attrs,"yEnd",0)/100],thickness:oe(y.attrs,"thickness",10)/100})),f=t.filter(y=>y.name==="room"&&d(y)&&(y.points?.length??0)>=3).map((y,b)=>({id:D("room"),name:y.attrs.name||`Raum ${b+1}`,area_id:null,points:Ey(y.points,h).map(([v,w])=>[Ee(v),Ee(w)]),floor_material:"wood",panel:[]}));p.rooms=f;for(let y of t.filter(b=>b.name==="doorOrWindow"&&d(b))){let b=[oe(y.attrs,"x",0)/100,oe(y.attrs,"y",0)/100],v=Math.max(.6,oe(y.attrs,"depth",30)/100+.3),w=null;for(let O of f)O.points.forEach((P,C)=>{let B=th(b,P,O.points[(C+1)%O.points.length]);B.dist<=v&&(!w||B.dist1.4?2:1,swing:"in",cover:null,contact:null,contact2:null,tilt:null})}let g=[];for(let y of i.filter(d)){let b=[oe(y.attrs,"xStart",0)/100,oe(y.attrs,"yStart",0)/100],v=[oe(y.attrs,"xEnd",0)/100,oe(y.attrs,"yEnd",0)/100];if(Math.hypot(v[0]-b[0],v[1]-b[1])<.1)continue;let w=Math.max(.15,oe(y.attrs,"thickness",10)/100),x=T=>f.some(O=>O.points.some((P,C)=>th(T,P,O.points[(C+1)%O.points.length]).dist[b[0]+(v[0]-b[0])*T/M,b[1]+(v[1]-b[1])*T/M],F=Array.from({length:M+1},(T,O)=>!x(A(O)));for(let T=0;T<=M;){if(!F[T]){T++;continue}let O=T;for(;O+1<=M&&F[O+1];)O++;let[P,C]=[A(Math.max(0,T-1)),A(Math.min(M,O+1))];Math.hypot(C[0]-P[0],C[1]-P[1])>=.3&&g.push({id:D("wall"),a:[Ee(P[0]),Ee(P[1])],b:[Ee(C[0]),Ee(C[1])],thickness:Ee(oe(y.attrs,"thickness",10)/100),height:y.attrs.height?Ee(oe(y.attrs,"height",250)/100):null}),T=O+1}}p.walls=g,n.rooms+=f.length,n.openings+=p.openings.length,n.walls+=g.length,(f.length||g.length)&&e.floors.push(p)}),n.floors=e.floors.length,n.furniture=t.filter(a=>a.name==="pieceOfFurniture").length,{building:Pe(e),report:n}}async function nh(t){let e=Jd(t).find(o=>o.name==="Home.xml");if(!e)throw new Error("sh3d_no_xml");let n=new TextDecoder().decode(await eh(t,e)),r=Ay(My(n));if(r.report.rooms===0&&r.report.walls===0)throw new Error("sh3d_empty");return r}function Fy(t){let e=t.split(/\r?\n/),n=[];for(let r=0;r+1r===9&&o==="$INSUNITS"),n=e>=0?Number(t[e+1]?.[1]):NaN;return{1:.0254,2:.3048,4:.001,5:.01,6:1}[n]??null}function zy(t){let e=Fy(t),n=Ty(e),r=e.findIndex(([s,l],a)=>s===2&&l==="ENTITIES"&&e[a-1]?.[1]==="SECTION"),o=[];if(r<0)return{shapes:o,unit:n};let i=r+1;for(;iNumber(c.find(([h])=>h===p)?.[1]??NaN),d=[[u(10),u(20)],[u(11),u(21)]];d.every(([p,h])=>Number.isFinite(p)&&Number.isFinite(h))&&o.push({points:d,closed:!1})}else if(l==="LWPOLYLINE"){let u=c.filter(([f])=>f===10).map(([,f])=>Number(f)),d=c.filter(([f])=>f===20).map(([,f])=>Number(f)),p=Number(c.find(([f])=>f===70)?.[1]??0),h=u.map((f,g)=>[f,d[g]]).filter(([f,g])=>Number.isFinite(f)&&Number.isFinite(g));h.length>=2&&o.push({points:h,closed:(p&1)===1})}i=a}return{shapes:o,unit:n}}var rh=t=>Math.round(t*1e3)/1e3;function oh(t){let{shapes:e,unit:n}=zy(t);if(!e.length)throw new Error("dxf_empty");let r=e.flatMap(h=>h.points),o=Math.max(Math.max(...r.map(h=>h[0]))-Math.min(...r.map(h=>h[0])),Math.max(...r.map(h=>h[1]))-Math.min(...r.map(h=>h[1]))),i=n??(o>2e3?.001:o>200?.01:1),s=Math.min(...r.map(h=>h[0])),l=Math.max(...r.map(h=>h[1])),a=([h,f])=>[rh((h-s)*i),rh((l-f)*i)],c=Ce(D("floor"),"Erdgeschoss",0),u=[],d=[];for(let h of e){let f=h.points.map(a);if(h.closed&&f.length>=3)u.push({id:D("room"),name:`Raum ${u.length+1}`,area_id:null,points:f,floor_material:"wood",panel:[]});else for(let g=0;g+1.05&&d.push({id:D("wall"),a:f[g],b:f[g+1]})}c.rooms=u,c.walls=d;let p=Ft();return p.floors=[c],{building:Pe(p),report:{floors:1,rooms:u.length,openings:0,walls:d.length,furniture:0}}}var qe=t=>Math.round(t*100)/100;function Py(t,e){let n=t.category;return typeof n=="string"?n:n&&typeof n=="object"?Object.keys(n)[0]??e:e}function Dy(t,e){let n=t,r=n?.transform,o=n?.dimensions;if(!n||!Array.isArray(r)||r.length<16||!Array.isArray(o)||o.length<3)return null;let i=l=>Number(l),s=Math.hypot(i(r[0]),i(r[2]));return![...r.slice(0,16),...o.slice(0,3)].every(l=>Number.isFinite(i(l)))||s<1e-6?null:{centre:[i(r[12]),i(r[13]),i(r[14])],dir:[i(r[0])/s,i(r[2])/s],size:[i(o[0]),i(o[1]),i(o[2])],kind:Py(n,e)}}var jn=(t,e,n)=>(Array.isArray(t[e])?t[e]:[]).map(r=>Dy(r,n)).filter(r=>!!r);function Iy(t){if(t.length<3)return null;let e=t.map(a=>{let c=a.size[0]/2;return[[a.centre[0]-a.dir[0]*c,a.centre[2]-a.dir[1]*c],[a.centre[0]+a.dir[0]*c,a.centre[2]+a.dir[1]*c]]}),n=(a,c)=>Math.hypot(a[0]-c[0],a[1]-c[1]),r=.4,o=new Set([0]),i=[e[0][0]],s=[0],l=e[0][1];for(;o.sizer?null:(i[0]=[(l[0]+i[0][0])/2,(l[1]+i[0][1])/2],{points:i,edgeWall:s})}function ih(t){let e=[],n=[];for(let l of t){let a=l.size[0]/2;for(let c of[-1,1])e.push(l.centre[0]+c*l.dir[0]*a),n.push(l.centre[2]+c*l.dir[1]*a)}let[r,o,i,s]=[Math.min(...e),Math.max(...e),Math.min(...n),Math.max(...n)];return[[r,i],[o,i],[o,s],[r,s]]}function Oy(t,e,n){let[r,o]=[n[0]-e[0],n[1]-e[1]],i=Math.hypot(r,o)||1e-9,s=Math.min(i,Math.max(0,((t[0]-e[0])*r+(t[1]-e[1])*o)/i));return{dist:Math.hypot(t[0]-(e[0]+r/i*s),t[1]-(e[1]+o/i*s)),along:s,length:i}}var Hy={sofa:"sofa",bed:"bed",table:"table",chair:"chair",bathtub:"bathtub",toilet:"wc",sink:"sink",refrigerator:"fridge",stove:"stove",oven:"stove",dishwasher:"dishwasher",washerDryer:"washer",storage:"tall_cabinet",television:"tv_board"};function sh(t){let e=t;return!e||typeof e!="object"||"floors"in e||"settings"in e?!1:(Array.isArray(e.rooms)?e.rooms:[e]).some(r=>r&&Array.isArray(r.walls)&&jn(r,"walls","wall").length>0)}function ah(t){let e=t,r=(Array.isArray(e.rooms)?e.rooms:[e]).filter(y=>y&&typeof y=="object").map(y=>({walls:jn(y,"walls","wall"),doors:[...jn(y,"doors","door"),...jn(y,"openings","opening")],windows:jn(y,"windows","window"),objects:jn(y,"objects","object")})).filter(y=>y.walls.length);if(!r.length)throw new Error("roomplan_empty");let o=r.flatMap(y=>y.walls),i=Math.min(...o.map(y=>y.centre[1]-y.size[1]/2)),s=r.map(y=>Iy(y.walls)),l=r.flatMap((y,b)=>s[b]?.points??ih(y.walls)),[a,c]=[Math.min(...l.map(y=>y[0]))-.5,Math.min(...l.map(y=>y[1]))-.5],u=([y,b])=>[qe(y-a),qe(b-c)],d=Ce(D("floor"),"Erdgeschoss",0);d.height=qe(Math.max(2.2,Math.min(4,Math.max(...o.map(y=>y.size[1])))));let p=[],h=[];r.forEach((y,b)=>{let w=(s[b]?.points??ih(y.walls)).map(u),x={id:D("room"),name:`Raum ${b+1}`,area_id:null,points:w,floor_material:"wood",panel:[]};p.push(x);for(let k of[...y.doors.map(M=>({v:M,window:!1})),...y.windows.map(M=>({v:M,window:!0}))]){let M=[k.v.centre[0]-a,k.v.centre[2]-c],A=null;if(w.forEach((P,C)=>{let B=Oy(M,P,w[(C+1)%w.length]);B.dist<=.6&&(!A||B.dist1.4?2:1,swing:"in",...O?{style:"passage"}:{},cover:null,contact:null,contact2:null,tilt:null})}for(let k of y.objects){let M=Hy[k.kind];if(!M)continue;let[A,F,T]=[k.size[0],k.size[2],k.size[1]];A<.1||F<.1||h.push({id:D("f"),type:M,x:qe(k.centre[0]-a),z:qe(k.centre[2]-c),rotation:Math.round((Math.atan2(k.dir[1],k.dir[0])*180/Math.PI+360)%360),w:qe(A),d:qe(F),h:qe(T),variant:null,entity:null,power:null})}}),d.rooms=p,d.furniture=h;let f=Ft();f.floors=[d];let g=r.reduce((y,b)=>y+b.objects.length,0)-h.length;return{building:Pe(f),report:{floors:1,rooms:p.length,openings:d.openings.length,walls:0,furniture:g}}}var eo=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&"ref"in t;function Ly(t){let e=0,n=()=>{for(;t[e]===" ";)e++;let o=t[e];if(o==="("){e++;let a=[];for(;eString.fromCharCode(...(n.match(/.{4}/g)??[]).map(r=>parseInt(r,16)))).replace(/\\S\\(.)/g,(e,n)=>String.fromCharCode(n.charCodeAt(0)+128))}function Ny(t){let e=new Map,n=t.slice(Math.max(0,t.indexOf("DATA;")));for(let r of n.matchAll(/#(\d+)\s*=\s*([A-Z0-9_]+)\s*\(([\s\S]*?)\)\s*;(?=\s*(?:#|ENDSEC))/g))e.set(Number(r[1]),{type:r[2],args:Ly(r[3])});return e}var lh={x:0,y:0,z:0,c:1,s:0},ch=(t,e)=>({x:t.x+t.c*e.x-t.s*e.y,y:t.y+t.s*e.x+t.c*e.y,z:t.z+e.z,c:t.c*e.c-t.s*e.s,s:t.s*e.c+t.c*e.s});function uh(t){let e=Ny(t);if(!e.size)throw new Error("ifc_empty");let n=k=>eo(k)?e.get(k.ref):void 0,r=k=>typeof k=="number"?k:NaN,o=k=>(n(k)?.args[0]??[]).map(M=>r(M)),i=[...e.values()].find(k=>k.type==="IFCSIUNIT"&&k.args[1]===".LENGTHUNIT."),s=i?{".MILLI.":.001,".CENTI.":.01,".DECI.":.1}[String(i.args[2])]??1:1,l=k=>{let M=n(k);if(!M)return lh;let[A=0,F=0,T=0]=o(M.args[0]),O=n(M.type==="IFCAXIS2PLACEMENT3D"?M.args[2]:M.args[1]),[P=1,C=0]=(O?.args[0]??[]).map(q=>r(q)),B=Math.hypot(P,C)||1;return{x:A||0,y:F||0,z:T||0,c:P/B,s:C/B}},a=(k,M=0)=>{let A=n(k);return!A||A.type!=="IFCLOCALPLACEMENT"||M>30?lh:ch(a(A.args[0],M+1),l(A.args[1]))},c=k=>{for(let M of n(k)?.args[2]??[])for(let A of n(M)?.args[3]??[]){let F=n(A);if(F?.type!=="IFCEXTRUDEDAREASOLID")continue;let T=n(F.args[0]),O=ch(l(F.args[1]),l(T?.args[2])),P=[];if(T?.type==="IFCRECTANGLEPROFILEDEF"){let[C,B]=[r(T.args[3])/2,r(T.args[4])/2];P=[[-C,-B],[C,-B],[C,B],[-C,B]]}else if(T?.type==="IFCARBITRARYCLOSEDPROFILEDEF"){let C=n(T.args[2]);C?.type==="IFCPOLYLINE"&&(P=(C.args[0]??[]).map(B=>o(B)))}if(P=P.filter(C=>Number.isFinite(C[0])&&Number.isFinite(C[1])),P.length>3&&Math.hypot(P[0][0]-P[P.length-1][0],P[0][1]-P[P.length-1][1])<1e-6&&P.pop(),P.length>=3)return P.map(([C,B])=>[O.x+O.c*C-O.s*B,O.y+O.s*C+O.c*B])}return null},u=new Map;for(let[,k]of e){if(k.type==="IFCRELAGGREGATES"&&eo(k.args[4]))for(let M of k.args[5]??[])eo(M)&&u.set(M.ref,k.args[4].ref);if(k.type==="IFCRELCONTAINEDINSPATIALSTRUCTURE"&&eo(k.args[5]))for(let M of k.args[4]??[])eo(M)&&u.set(M.ref,k.args[5].ref)}let d=[...e].filter(([,k])=>k.type==="IFCBUILDINGSTOREY").map(([k,M])=>({id:k,name:String(M.args[7]||M.args[2]||"")||null,elevation:r(M.args[9])*s}));d.sort((k,M)=>(k.elevation||0)-(M.elevation||0));let p=[];for(let[k,M]of e){if(M.type!=="IFCSPACE")continue;let A=c(M.args[6]);if(!A)continue;let F=a(M.args[5]),T=A.map(([P,C])=>[(F.x+F.c*P-F.s*C)*s,(F.y+F.s*P+F.c*C)*s]),O=String(M.args[7]||M.args[2]||"")||`Raum ${p.length+1}`;p.push({storey:u.get(k)??null,name:O,ring:T})}if(!p.length)throw new Error("ifc_empty");let h=p.flatMap(k=>k.ring),f=Math.min(...h.map(k=>k[0])),g=Math.max(...h.map(k=>k[1])),y=k=>Math.round(k*1e3)/1e3,b=[],v=new Map;if(d.filter(k=>p.some(M=>M.storey===k.id)).forEach((k,M)=>{let A=Ce(D("floor"),k.name??`Etage ${M+1}`,Number.isFinite(k.elevation)?y(k.elevation):M*2.8);b.push(A),v.set(k.id,A)}),p.some(k=>k.storey===null||!v.has(k.storey))){let k=Ce(D("floor"),b.length?"Weitere R\xE4ume":"Erdgeschoss",b.length?b[b.length-1].elevation+2.8:0);b.push(k),v.set(null,k)}b.forEach((k,M)=>{let A=b[M+1];A&&A.elevation-k.elevation>1.8&&(k.height=y(A.elevation-k.elevation-.2))});for(let k of p)v.get(k.storey!==null&&v.has(k.storey)?k.storey:null).rooms.push({id:D("room"),name:k.name,area_id:null,points:k.ring.map(([A,F])=>[y(A-f),y(g-F)]),floor_material:"wood",panel:[]});let x=Ft();return x.floors=b,{building:Pe(x),report:{floors:b.length,rooms:p.length,openings:0,walls:0,furniture:0}}}var hh="nextfloor",By="alarm_control_panel|automation|binary_sensor|button|calendar|camera|climate|conversation|cover|date|datetime|device_tracker|event|fan|group|humidifier|image|input_boolean|input_button|input_datetime|input_number|input_select|input_text|lawn_mower|light|lock|media_player|notify|number|person|remote|scene|script|select|sensor|siren|stt|sun|switch|text|time|timer|todo|tts|update|vacuum|valve|water_heater|weather|zone",dh=new RegExp(`^(?:${By})\\.[a-z0-9_]+$`),Wy=/^[0-9a-f]{32}$/,Vy=new Set(["area_id","ha_floor"]),Ky=new Set(["sub_areas"]),Gy=new Set(["tap","show_when","pictures","moods"]);function Sa(t){if(typeof t=="string")return dh.test(t)||Wy.test(t)?null:t;if(Array.isArray(t))return t.map(e=>Sa(e)).filter(e=>e!==null);if(t&&typeof t=="object"){let e={};for(let[n,r]of Object.entries(t))dh.test(n)||Gy.has(n)||(Vy.has(n)||Ky.has(n)?e[n]=null:e[n]=Sa(r));return e}return t}var jy=["wall_exterior","wall_interior","wall_paint_outside","wall_paint_inside","grid","north","roof","weather_effects","rain_warning","sun_patches","lock_plan","start_view","units","motion_markers_active","room_double_tap"];function ph(t){let e=structuredClone(t),n={};for(let o of jy)e.settings?.[o]!==void 0&&(n[o]=e.settings[o]);let r=e.settings?.backdrop;r&&(r.color||r.dim!=null)&&(n.backdrop={color:r.color??null,dim:r.dim??null}),e.settings=n,e.energy={...e.energy,grid:null,solar:null,battery:null,battery_soc:null,tariff:null,consumption:null,gas:null,water:null},e.presence=[];for(let o of e.floors){o.background=null,o.placements=[],o.power_entity=null,o.ha_floor=null;for(let i of o.rooms)Object.assign(i,{area_id:null,sub_areas:null,panel:[],hidden:[],no_state:[]});o.furniture.forEach(i=>{Object.assign(i,{entity:null,power:null}),delete i.effect_animations,i.picture&&!(i.picture.startsWith("image:")||i.picture.startsWith("https://"))&&(i.picture=null)}),o.openings.forEach(i=>Object.assign(i,{cover:null,contact:null,tilt:null}))}return Sa(e)}function fh(t,e){return{format:hh,version:1,exported_at:new Date().toISOString(),building:e?ph(t):structuredClone(t)}}var Uy=t=>!!t&&(t.version===1||t.version===void 0)&&Array.isArray(t.floors)&&t.floors.every(e=>!!e&&typeof e=="object"),Zy="https://therealmrbk.github.io/NextFloor/preview/?shared&noshowcase";function mh(t,e,n,r,o=Zy){let i=new Set(t.floors.flatMap(c=>c.furniture.map(u=>u.type)).filter(c=>c.startsWith("pack:")).map(c=>c.split(":")[1])),s={building:ph(t),packs:e.filter(c=>!c.builtin&&i.has(c.id))},l=JSON.stringify(s).replace(/c.replace(/[&<>"]/g,u=>({"&":"&","<":"<",">":">",'"':"""})[u]);return` ${a(n)}