/*! 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 Pc=[],Hi=new Map,Mb=0,he=(t,e)=>`pack:${t}:${e}`,yt=t=>t.startsWith("pack:");function Ss(t){Pc=t,Hi=new Map;for(let e of t)for(let n of e.items)Hi.set(he(e.id,n.id),n);Mb+=1}var $r=()=>Pc;var Rb={};function U(t){if(!yt(t))return;let e=Hi.get(t);if(e)return e;let[,n,...r]=t.split(":"),i=Rb[n];return i?Hi.get(he(i,r.join(":"))):void 0}var Eb=.22;function Fc(t,e,n,r){let i=Math.min(Eb,n/3);if(r<=i*2.4||Math.abs(r-n)<1e-6)return e*(r/n)+(t-e)*(r/n);let o=e*(r/n),s=t-e;return s<=i?o+s:s>=n-i?o+r-(n-s):o+i+(s-i)*(r-2*i)/(n-2*i)}function xr(t,e,n,r,i){return[Fc(t*r,n*r,r,i)/i,Fc(e*r,n*r,r,i)/i]}var Tc=new WeakMap;function Dc(t,e,n,r){let[i,o,s]=t.size;if(t.vehicle||t.stretch||Math.abs(e-i)<1e-4&&Math.abs(n-o)<1e-4&&Math.abs(r-s)<1e-4)return t.parts;let a=`${e.toFixed(4)}|${n.toFixed(4)}|${r.toFixed(4)}`,l=Tc.get(t),c=l?.get(a);if(c)return c;let u=t.parts.map(d=>{if(d.shape==="sweep")return d;let[p,h]=xr(d.x-d.w/2,d.x+d.w/2,-.5,i,e),[f,g]=xr(d.z-d.d/2,d.z+d.d/2,-.5,o,n),[b,y]=xr(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*i/e,d:d.d*o/n,y:b,h:y-b};let v={...d,x:(p+h)/2,z:(f+g)/2,w:h-p,d:g-f,y:b,h:y-b};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,T]=xr(w-k/2,w+k/2,-.5,i,e),[F,L]=xr(x-M/2,x+M/2,-.5,o,n);Object.assign(v,{tx:(A+T)/2,tz:(F+L)/2,tw:T-A,td:L-F})}return v});return l||Tc.set(t,l=new Map),l.size>32&&l.clear(),l.set(a,u),u}var Ms=t=>!!t?.parts.some(e=>e.move);var Ic=t=>U(t)?.parts.find(e=>e.screen),zc=.06;function Oc(t){let e=U(t);if(!e)return!1;let[n,r,i]=e.size;return e.parts.filter(o=>o.screen).some(o=>{let[s,a]=[o.w*n,o.d*r,o.h*i].sort((l,c)=>c-l);return a>=zc&&s>=zc})}function dt(t){return tt[t]??U(t)?.size??[.6,.6,.8]}function Tt(t){let e=U(t);return Kc.has(t)||!!e?.electric||!!e?.light||!!e?.climate}var Hc=t=>!!U(t)?.parts.some(e=>e.picture),An=t=>!!U(t)?.climate;function Lc(t,e){return t.name[e.split("-")[0]]??t.name.en??Object.values(t.name)[0]??t.id}var Ab={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 Cc(t,e){if(e.split("-")[0]==="de")return t.name;let n=/^nextfloor\.(.+)$/.exec(t.id)?.[1];return n&&Ab[n]||t.name}function zt(t,e){return e.mount_y!=null?e.mount_y:Tb(t,e)+(Fb(e)?0:Vc(t,e.x,e.z))}var Fb=t=>t.type==="led_strip"||U(t.type)?.mount==="ceiling";function Tb(t,e){if(e.type==="lamp_wall")return Nc;if(e.type==="led_strip")return Math.max(0,ht(t,e.x,e.z)-.04-Math.max(.02,e.h));let n=U(e.type);if(!n)return Bc(e);switch(n.mount){case"surface":return Wc(t,e.x,e.z);case"wall":return n.wall_y??1;case"ceiling":return Math.max(0,Li(t,e)-e.h);default:return 0}}function Rs(t){if(t==="plant")return"plant";let e=U(t);return e?e.household?e.household:/monstera|plant|herb_garden|flower_pots|bonsai|ficus|cactus|kaktus/.test(e.id)?"plant":null:null}var vt=["electricity","water","gas","heating","cooling"],jc=["condition","temperature","humidity","pressure","wind_speed","wind_gust_speed","wind_bearing","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility","snow","fog","lightning"],Gc=["turn","slide","top"],Uc=["always","active","no_power","never"],Zc=1.3,Ci=(t,e=new Date().toISOString().slice(0,10))=>!!t.due&&t.due<=e,qc=["gable","hip","halfhip","pyramid","mansard","pent","flat","parapet"],Yc=["brick","round","wide","steel"],Ni=["navigate","more_info","service","fire_dom_event"];function Bi(t,e,n){return t?e?!!n.lock_plan:!!t.locked:!1}var Xc=["rain","snow","fog","clouds","lightning","sky"],Jc=["rain","snow","clouds","lightning","sky"],Qc=["lawn","terrace","path","driveway","pavers","stepping_stones","natural_stone","street","sidewalk","gravel","river","stream","pool","bed","wild","hedge","fence","pergola"],Es={lawn:.012,terrace:.12,path:.02,driveway:.02,pavers:.025,stepping_stones:.025,natural_stone:.03,street:.02,sidewalk:.12,gravel:.018,river:.008,stream:.006,pool:-.25,bed:.15,wild:.03,hedge:1.2,fence:1,pergola:2.2};function As(t){return t==="hedge"||t==="fence"||t==="pergola"}var eu=["x","-x","z","-z"];function zb(t,e,n){let r=t.slope??0;if(!r||t.type==="pool")return 0;let i=t.slope_dir??"x",o=(c,u)=>i==="x"?c:i==="-x"?-c:i==="z"?u:-u,s=1/0,a=-1/0;for(let[c,u]of t.points){let d=o(c,u);s=Math.min(s,d),a=Math.max(a,d)}if(a-s<1e-6)return 0;let l=Math.min(1,Math.max(0,(o(e,n)-s)/(a-s)));return r*l}function Pb(t,e,n,r){return tu(t)+(e.offset??0)+Es[e.type]-zb(e,n,r)}function tu(t){return t.elevation>.3?0:-.2}function nu(t,e,n){let r=(t.outdoor??[]).filter(o=>!As(o.type)&&o.type!=="pool"&&C([e,n],o.points)),i=[...r].reverse().find(o=>o.cut)??r[0];return i?Pb(t,i,e,n):tu(t)}var Fs=t=>t.cut??(t.type==="pool"||t.type==="river"||t.type==="stream");function Vi(t){let e=Number.isFinite(t.texture_scale)?Math.max(.05,Math.min(20,t.texture_scale)):1,n=Number.isFinite(t.texture_rotation)?(t.texture_rotation%360+360)%360:0;return{scale:e,rotation:n}}var ru=30,iu={meter:null,grid:null,grid_invert:!1,solar:null,battery:null,battery_invert:!1,battery_soc:null,consumption:null,tariff:null},ou=["wood","oak","tiles","carpet","stone","concrete"],su={type:"none",pitch:35,overhang:.4},Wi="#d6cfc2",Ki="#e8e3da",au={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...su}};function Pt(){return{version:1,floors:[],settings:{...au},energy:{...iu},presence:[]}}function Me(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 Db=2.75;function lu(t,e){if(e!=null&&Number.isFinite(e))return Math.round(e*Db*100)/100;let n=t.reduce((r,i)=>!r||i.elevation>r.elevation?i:r,null);return n?Math.round((n.elevation+n.height+.25)*100)/100:0}function cu(t,e,n){let r=t.rooms.flatMap(a=>a.points.map(l=>l[0])),i=t.rooms.flatMap(a=>a.points.map(l=>l[1])),o=r.length?Math.ceil(Math.max(...r))+1:0,s=i.length?Math.floor(Math.min(...i)):0;return e.map((a,l)=>{let c=o+l%3*4.5,u=s+Math.floor(l/3)*3.5;return{id:n(),name:a.name,area_id:a.area_id,points:[[c,u],[c+4,u],[c+4,u+3],[c,u+3]],floor_material:"wood"}})}function uu(t,e,n,r){let i=t.rotation*Math.PI/180,o=Math.cos(i),s=Math.sin(i),[a,l]=e,c=t.x-a*(t.w/2)*o+l*(t.d/2)*s,u=t.z-a*(t.w/2)*s-l*(t.d/2)*o,d=n[0]-c,p=n[1]-u,h=y=>Math.max(.1,Math.round(y/r)*r),f=h((d*o+p*s)*a),g=h((-d*s+p*o)*l),b=y=>Math.round(y*1e3)/1e3;return{x:b(c+a*(f/2)*o-l*(g/2)*s),z:b(u+a*(f/2)*s+l*(g/2)*o),w:b(f),d:b(g)}}var ji=["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","heating_manifold","buffer_tank","freshwater_station","stairwell"],du={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","heating_manifold","buffer_tank","freshwater_station"],vehicles:["parking"]},Ke=["meter","inverter","home_battery","wallbox","grid_point"],hu=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"]),Nc=1.75;function Gi(t){return Ts.has(t.type)||["stairwell","parking"].includes(t.type)?!1:U(t.type)?.mount!=="ceiling"}function ue(t){return hu.has(t)||!!U(t)?.light}var Ib=new Set(["table","table_round","coffee_table","desk","nightstand","sideboard","dresser","kitchen","island","worktop","tv_board","dishwasher","washer","dryer"]);function pu(t,e,n,r=0){let i=de(t.points),o=i.x1-i.x0-2*r,s=i.z1-i.z0-2*r,a=[];for(let l=0;lMath.round(s*1e3)/1e3,[i,o]={right:[1,0],down:[0,1],left:[-1,0],up:[0,-1]}[n];return[r(t[0]+i*e),r(t[1]+o*e)]}function Bc(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 Ts=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function fu(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 zs=t=>t?.floor_offset&&Number.isFinite(t.floor_offset)?t.floor_offset:0;function Vc(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&i.floor_offset&&C([e,n],i.points));return zs(r)}function ht(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&C([e,n],i.points));return r?.ceiling!=null&&r.ceiling>0?r.ceiling:t.height}var Li=(t,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:ht(t,e.x,e.z);function Wc(t,e,n){let r=0;for(let i of t.furniture)!(Ib.has(i.type)||U(i.type)?.surface)||!C([e,n],Os(i))||(r=Math.max(r,i.h));return r}var Kc=new Set([...hu,"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],heating_manifold:[1.5,.35,1.1],buffer_tank:[.85,.85,1.85],freshwater_station:[.65,.28,.9],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 Ps=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],Ds=["standard","bars","glass_wall"],Ui=new Set(["interior","front"]);function Qt(t,e){return t.type==="door"?t.style&&Ps.includes(t.style)?t.style:e?"front":"interior":t.style&&Ds.includes(t.style)?t.style:"standard"}function mu(t,e,n,r){if(e!=="sidelight"&&e!=="sidelights")return null;let i=e==="sidelights",o=t-.04,s=Math.min(1.05,Math.max(.6,o-(i?.6:.3))),a=(o-s)/(i?2:1),l=r.sidelight_width??a,c=i?r.sidelight_width2??r.sidelight_width??a:0;l=Math.max(.1,l),c=i?Math.max(.1,c):0;let u=o-.5;if(l+c>u){let p=Math.max(0,u)/(l+c);l*=p,c*=p}return i?{panels:[[.02,.02+l],[t-.02-c,t-.02]],x0:.02+l,x1:t-.02-c}:(n?!!r.sidelight_hinge:!r.sidelight_hinge)?{panels:[[.02,.02+l]],x0:.02+l,x1:t-.02}:{panels:[[t-.02-l,t-.02]],x0:.02,x1:t-.02-l}}function Is(t){return t==="front"||t==="front_glass"||t==="sidelight"||t==="sidelights"}var Tn={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 zn(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&&Is(t.style)?"front":e?"door_double":"door":t.sill<.1?e?"terrace_double":"terrace":e?"window_double":"window"}function Oe(t){t.energy={...iu,...t.energy??{}},t.presence=t.presence??[],t.version=1,t.settings={...au,...t.settings,roof:{...su,...t.settings?.roof??{}}},t.floors.forEach((e,n)=>{let r=Me(e.id,e.name??`Floor ${n+1}`,e.elevation??n*2.8);for(let i of Object.keys(r))e[i]===void 0&&(e[i]=r[i])});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 i of n){let o=r[i.mount??"ceiling"],[s,a,l]=tt[o],c=`lamp_${i.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:o,x:i.x,z:i.z,rotation:0,w:s,d:a,h:l,variant:null,entity:i.entity_id,power:null,animations_enabled:i.animations_enabled,effect_animations:structuredClone(i.effect_animations)})}e.placements=e.placements.filter(i=>!i.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 Ob(t),t.topology&&qi(t),t}function Ob(t){let e=(n,r)=>{let i=new Set;for(let o of n)(typeof o.id!="string"||!o.id||i.has(o.id))&&(o.id=P(r)),i.add(o.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=P("room"));e(n.openings,"op"),e(n.furniture,"furn"),e(n.outdoor,"out")}}function P(t){return`${t}_${Math.random().toString(36).slice(2,10)}`}function _e(t){let e=0;for(let n=0;no+s[0],0)/i,t.reduce((o,s)=>o+s[1],0)/i]}let n=0,r=0;for(let i=0;i1e-6&&Math.abs(r-o)>1e-6)return!1}return!0}function de(t){let e=1/0,n=1/0,r=-1/0,i=-1/0;for(let[o,s]of t)e=Math.min(e,o),n=Math.min(n,s),r=Math.max(r,o),i=Math.max(i,s);return{x0:e,z0:n,x1:r,z1:i}}function Os(t){let e=t.rotation*Math.PI/180,n=Math.cos(e),r=Math.sin(e),i=t.w/2,o=t.d/2;return[[-i,-o],[i,-o],[i,o],[-i,o]].map(([s,a])=>[t.x+s*n-a*r,t.z+s*r+a*n])}function C(t,e){let n=!1;for(let r=0,i=e.length-1;rt[1]!=l>t[1]&&t[0]<(a-o)*(t[1]-s)/(l-s)+o&&(n=!n)}return n}var Zi={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 gu=t=>[t.kind,t.floorId,t.id].filter(Boolean).join(":");function _u(t,e="Geb\xE4ude 1"){if(t.topology)return;let n=P("location"),r=P("branch"),i=P("building");t.topology={locations:[{id:n,name:"Ort 1"}],branches:[{id:r,name:"Niederlassung 1",location_id:n}],buildings:[{id:i,name:e,branch_id:r}]};for(let o of t.floors)o.building_id=i}function qi(t){let e=t.topology;e.locations??=[],e.branches??=[],e.buildings??=[];let n=o=>(o||=e.locations[0]?.id||P("location"),e.locations.some(s=>s.id===o)||e.locations.push({id:o,name:"Ort"}),o),r=o=>(o||=e.branches[0]?.id||P("branch"),e.branches.some(s=>s.id===o)||e.branches.push({id:o,name:"Niederlassung",location_id:n()}),o),i=o=>(o||=e.buildings[0]?.id||P("building"),e.buildings.some(s=>s.id===o)||e.buildings.push({id:o,name:"Geb\xE4ude",branch_id:r()}),o);for(let o of e.branches)o.location_id=n(o.location_id);for(let o of e.buildings)o.branch_id=r(o.branch_id);for(let o of t.floors)o.outdoor_location_id?(o.outdoor_location_id=n(o.outdoor_location_id),o.building_id=null):o.building_id=i(o.building_id)}function bu(t,e){let n=t.floors.find(i=>i.outdoor_location_id===e);if(n)return n;let r={...Me(P("outside"),"Au\xDFen",0),outdoor_location_id:e,building_id:null};return t.floors.push(r),r}function Hs(t,e,n){let r=t.floors.find(i=>i.id===e);return n?{kind:"room",id:n,floorId:e}:r?.outdoor_location_id?{kind:"outside",id:r.outdoor_location_id}:{kind:"floor",id:e}}function Hb(t){let e=(i,o,s,a=[],l=a.flatMap(u=>u.floorIds),c)=>{let u={kind:i,...o?{id:o}:{},...c?{floorId:c.floorId}:{}};return{key:gu(u),name:s,selection:u,floorIds:[...new Set(l)],children:a,...c?{room:c}:{}}},n=i=>e("floor",i.id,i.name,i.rooms.map(o=>e("room",o.id,o.name,[],[i.id],{floorId:i.id,roomId:o.id})),[i.id]);if(!t.topology)return e("all",void 0,"Alle Etagen",[...t.floors].sort((i,o)=>o.elevation-i.elevation).map(n));let r=t.topology;return e("all",void 0,"Alle Orte",r.locations.map(i=>{let o=r.branches.filter(a=>a.location_id===i.id).map(a=>e("branch",a.id,a.name,r.buildings.filter(l=>l.branch_id===a.id).map(l=>e("building",l.id,l.name,t.floors.filter(c=>!c.outdoor_location_id&&c.building_id===l.id).sort((c,u)=>u.elevation-c.elevation).map(n))))),s=t.floors.filter(a=>a.outdoor_location_id===i.id);return s.length&&o.push(e("outside",i.id,"Au\xDFen",s.flatMap(a=>a.rooms.map(l=>e("room",l.id,l.name,[],[a.id],{floorId:a.id,roomId:l.id}))),s.map(a=>a.id))),e("location",i.id,i.name,o)}))}function yu(t,e){let n=Hb(t),r=gu(e),i=o=>{if(o.key===r)return[o];for(let s of o.children){let a=i(s);if(a)return[o,...a]}return null};return i(n)??[n]}function vu(t,e,n=!1){if(!t.topology||e.kind==="all")return t.floors;let r=yu(t,e),i=(n&&(e.kind==="floor"||e.kind==="room")?r.find(s=>s.selection.kind==="building"):null)??r.at(-1),o=new Set(i.floorIds);return t.floors.filter(s=>o.has(s.id))}function Ls(t,e){return t.topology?yu(t,Hs(t,e.id)).slice(1).map(n=>n.name).join(" / "):e.name}var Yi=globalThis,Xi=Yi.ShadowRoot&&(Yi.ShadyCSS===void 0||Yi.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Cs=Symbol(),wu=new WeakMap,Sr=class{constructor(e,n,r){if(this._$cssResult$=!0,r!==Cs)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(Xi&&e===void 0){let r=n!==void 0&&n.length===1;r&&(e=wu.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&wu.set(n,e))}return e}toString(){return this.cssText}},ku=t=>new Sr(typeof t=="string"?t:t+"",void 0,Cs),ee=(t,...e)=>{let n=t.length===1?t[0]:e.reduce((r,i,o)=>r+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[o+1],t[0]);return new Sr(n,t,Cs)},xu=(t,e)=>{if(Xi)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let r=document.createElement("style"),i=Yi.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=n.cssText,t.appendChild(r)}},Ns=Xi?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let r of e.cssRules)n+=r.cssText;return ku(n)})(t):t;var{is:Lb,defineProperty:Cb,getOwnPropertyDescriptor:Nb,getOwnPropertyNames:Bb,getOwnPropertySymbols:Vb,getPrototypeOf:Wb}=Object,Ji=globalThis,$u=Ji.trustedTypes,Kb=$u?$u.emptyScript:"",jb=Ji.reactiveElementPolyfillSupport,Mr=(t,e)=>t,Bs={toAttribute(t,e){switch(e){case Boolean:t=t?Kb: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}},Mu=(t,e)=>!Lb(t,e),Su={attribute:!0,type:String,converter:Bs,reflect:!1,useDefault:!1,hasChanged:Mu};Symbol.metadata??=Symbol("metadata"),Ji.litPropertyMetadata??=new WeakMap;var wt=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=Su){if(n.state&&(n.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((n=Object.create(n)).wrapped=!0),this.elementProperties.set(e,n),!n.noAccessor){let r=Symbol(),i=this.getPropertyDescriptor(e,r,n);i!==void 0&&Cb(this.prototype,e,i)}}static getPropertyDescriptor(e,n,r){let{get:i,set:o}=Nb(this.prototype,e)??{get(){return this[n]},set(s){this[n]=s}};return{get:i,set(s){let a=i?.call(this);o?.call(this,s),this.requestUpdate(e,a,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Su}static _$Ei(){if(this.hasOwnProperty(Mr("elementProperties")))return;let e=Wb(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Mr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Mr("properties"))){let n=this.properties,r=[...Bb(n),...Vb(n)];for(let i of r)this.createProperty(i,n[i])}let e=this[Symbol.metadata];if(e!==null){let n=litPropertyMetadata.get(e);if(n!==void 0)for(let[r,i]of n)this.elementProperties.set(r,i)}this._$Eh=new Map;for(let[n,r]of this.elementProperties){let i=this._$Eu(n,r);i!==void 0&&this._$Eh.set(i,n)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let n=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let i of r)n.unshift(Ns(i))}else e!==void 0&&n.push(Ns(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 xu(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),i=this.constructor._$Eu(e,r);if(i!==void 0&&r.reflect===!0){let o=(r.converter?.toAttribute!==void 0?r.converter:Bs).toAttribute(n,r.type);this._$Em=e,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(e,n){let r=this.constructor,i=r._$Eh.get(e);if(i!==void 0&&this._$Em!==i){let o=r.getPropertyOptions(i),s=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:Bs;this._$Em=i;let a=s.fromAttribute(n,o.type);this[i]=a??this._$Ej?.get(i)??a,this._$Em=null}}requestUpdate(e,n,r,i=!1,o){if(e!==void 0){let s=this.constructor;if(i===!1&&(o=this[e]),r??=s.getPropertyOptions(e),!((r.hasChanged??Mu)(o,n)||r.useDefault&&r.reflect&&o===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:i,wrapped:o},s){r&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,s??n??this[e]),o!==!0||s!==void 0)||(this._$AL.has(e)||(this.hasUpdated||r||(n=void 0),this._$AL.set(e,n)),i===!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[i,o]of this._$Ep)this[i]=o;this._$Ep=void 0}let r=this.constructor.elementProperties;if(r.size>0)for(let[i,o]of r){let{wrapped:s}=o,a=this[i];s!==!0||this._$AL.has(i)||a===void 0||this.C(i,void 0,o,a)}}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){}};wt.elementStyles=[],wt.shadowRootOptions={mode:"open"},wt[Mr("elementProperties")]=new Map,wt[Mr("finalized")]=new Map,jb?.({ReactiveElement:wt}),(Ji.reactiveElementVersions??=[]).push("2.1.2");var Ws=globalThis,Ru=t=>t,Qi=Ws.trustedTypes,Eu=Qi?Qi.createPolicy("lit-html",{createHTML:t=>t}):void 0,Ks="$lit$",kt=`lit$${Math.random().toFixed(9).slice(2)}$`,js="?"+kt,Gb=`<${js}>`,nn=document,Er=()=>nn.createComment(""),Ar=t=>t===null||typeof t!="object"&&typeof t!="function",Gs=Array.isArray,Du=t=>Gs(t)||typeof t?.[Symbol.iterator]=="function",Vs=`[ \f\r]`,Rr=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Au=/-->/g,Fu=/>/g,en=RegExp(`>|${Vs}(?:([^\\s"'>=/]+)(${Vs}*=${Vs}*(?:[^ \f\r"'\`<>=]|("|')|))|$)`,"g"),Tu=/'/g,zu=/"/g,Iu=/^(?:script|style|textarea|title)$/i,Us=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),m=Us(1),R=Us(2),R1=Us(3),nt=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),Pu=new WeakMap,tn=nn.createTreeWalker(nn,129);function Ou(t,e){if(!Gs(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Eu!==void 0?Eu.createHTML(e):e}var Hu=(t,e)=>{let n=t.length-1,r=[],i,o=e===2?"":e===3?"":"",s=Rr;for(let a=0;a"?(s=i??Rr,d=-1):u[1]===void 0?d=-2:(d=s.lastIndex-u[2].length,c=u[1],s=u[3]===void 0?en:u[3]==='"'?zu:Tu):s===zu||s===Tu?s=en:s===Au||s===Fu?s=Rr:(s=en,i=void 0);let h=s===en&&t[a+1].startsWith("/>")?" ":"";o+=s===Rr?l+Gb:d>=0?(r.push(c),l.slice(0,d)+Ks+l.slice(d)+kt+h):l+kt+(d===-2?a:h)}return[Ou(t,o+(t[n]||"")+(e===2?"":e===3?"":"")),r]},Fr=class t{constructor({strings:e,_$litType$:n},r){let i;this.parts=[];let o=0,s=0,a=e.length-1,l=this.parts,[c,u]=Hu(e,n);if(this.el=t.createElement(c,r),tn.currentNode=this.el.content,n===2||n===3){let d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(i=tn.nextNode())!==null&&l.length0){i.textContent=Qi?Qi.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,i){let o=this.strings,s=!1;if(o===void 0)e=rn(this,e,n,0),s=!Ar(e)||e!==this._$AH&&e!==nt,s&&(this._$AH=e);else{let a=e,l,c;for(e=o[0],l=0;l{let r=n?.renderBefore??e,i=r._$litPart$;if(i===void 0){let o=n?.renderBefore??null;r._$litPart$=i=new Dn(e.insertBefore(Er(),o),o,void 0,n??{})}return i._$AI(t),i};var Zs=globalThis,X=class extends wt{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=Cu(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return nt}};X._$litElement$=!0,X.finalized=!0,Zs.litElementHydrateSupport?.({LitElement:X});var Zb=Zs.litElementPolyfillSupport;Zb?.({LitElement:X});(Zs.litElementVersions??=[]).push("4.2.2");var Ys=t=>t.slice(0,t.indexOf(".")),qb={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"},Q=t=>qb[Ys(t)]??null,Xs=["light","cover","climate","media","switch","fan","lock","binary","sensor","scene","script"];var Nu=new Set(["light","switch","fan"]),Dt=t=>t!==null&&t!=="scene"&&t!=="script",He=t=>!t||t.state==="unavailable"||t.state==="unknown"&&!t.entity_id.startsWith("event.");function B(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 i=r.slice(n.length+1);return i[0].toUpperCase()+i.slice(1)}var Bu=t=>!!t&&t.entity_id.startsWith("sensor.")&&t.attributes.device_class==="enum";var Vu=t=>Math.min(1,Math.max(0,t));function Yb(t){let e=Vu((t-2200)/4300),n=[1,.66,.26],r=[.78,.9,1];return[0,1,2].map(i=>n[i]+(r[i]-n[i])*e)}function qs(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(Vu(n.brightness/255)):1,i=n.rgb_color;return i&&!["color_temp","brightness","onoff"].includes(String(n.color_mode))?{color:[i[0]/255,i[1]/255,i[2]/255],level:r}:typeof n.color_temp_kelvin=="number"?{color:Yb(n.color_temp_kelvin),level:r}:{color:[1,.71,.28],level:r}}function Wu(t,e,n){let r=qs(t,n);if(r)return r;for(let i of e){let o=qs(i);if(o)return{color:o.color,level:o.level*.6}}return null}function oo(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 Js=t=>t.trim().replace(/^\/local\/www\//i,"/local/"),Qs=t=>/^(https:\/\/|\/local\/|\/hacsfiles\/)\S+\.m?js(\?\S*)?$/i.test(t.trim());var Jb=globalThis,ju=Jb.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},ea=ju.plugins,Ku=ju.listeners;var Qb=5;function Gu(t,e){t.errors.lengthKu.delete(t)}var ta=()=>[...ea.values()].map(t=>t.status),Uu=()=>[...ea.values()].flatMap(t=>Object.keys(t.plugin.lightAnimations??{}));function*ao(t,e){for(let{plugin:n,status:r}of ea.values())for(let i of n.devices??[]){let o=!1;try{o=i.match(t,e)}catch(s){Gu(r,s)}o&&(yield{device:i,status:r})}}function lo(t,e){for(let{device:n}of ao(t,e))return n.kind??"sensor";return null}function Zu(t,e){let n=t.states[e];if(!n)return null;let r=ey({hass:t,entityId:e,state:n})?.icon?.trim();return r&&/^mdi:[a-z0-9-]+$/i.test(r)?r:null}function ey(t){let e=null;for(let{device:n,status:r}of ao(t.entityId,t.state))if(n.marker)try{let i=n.marker(t);if(!i)continue;e={...e??{}},typeof i.icon=="string"&&i.icon&&(e.icon=i.icon),typeof i.text=="string"&&(e.text=i.text.slice(0,60)),typeof i.active=="boolean"&&(e.active=i.active)}catch(i){Gu(r,i)}return e}function co(t,e){return t?typeof t=="string"?t:t[e]??t[e.split("-")[0]]??t.en??Object.values(t)[0]??"":""}function qu(t,e){let n=[];for(let{device:r,status:i}of ao(t,e))r.settings?.length&&n.push({pluginId:i.id,name:i.name,settings:r.settings});return n}function Yu(t,e){let n={};for(let r of t??[]){let i=e?.[r.key],o=r.type==="number"?typeof i=="number"&&Number.isFinite(i):r.type==="boolean"?typeof i=="boolean":typeof i=="string"&&(r.options??[]).some(([s])=>s===i);n[r.key]=o?i:r.default}return n}function Xu(t,e){for(let{device:n}of ao(t,e))if(n.floorWedge)return!0;return!1}var ty=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"]),ny=new Set(["m\xB3","m3","L","l","kWh","Wh","MWh","lx"]),ry=new Set(["door","window","opening","garage_door","motion","occupancy","presence","smoke","moisture","gas","carbon_monoxide"]),iy=new Set(["battery","signal_strength","timestamp","date","duration","data_rate","data_size","frequency","enum"]);function It(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 Qu=(t,e)=>{let n=t.entities?.[e];return!!(n?.hidden||n?.entity_category)},je=(t,e)=>Q(e)??lo(e,t.states[e]);function Ju(t,e){let n=t.states[e];if(!n||Qu(t,e))return!1;if(lo(e,n)!==null)return!0;let r=Q(e);if(!r)return!1;let i=n.attributes.device_class;return e.startsWith("event.")?!i||i==="button"||i==="doorbell":r==="sensor"?i?ty.has(i):ny.has(String(n.attributes.unit_of_measurement??"")):r==="binary"?i?ry.has(i):!!t.entities?.[e]?.area_id:!0}function oy(t,e){let n=t.states[e];return Q(e)!=="sensor"||!n?.attributes.unit_of_measurement||Qu(t,e)||iy.has(String(n.attributes.device_class??""))?!1:Number.isFinite(Number(n.state))||He(n)}var ho=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power",na=null;so(()=>na=null);function ra(t,e){let n=t.get(e);return n||t.set(e,n=[]),n}function sy(t){let e=new Map,n=new Map,r=new Map,i=new Map,o=[],s=u=>{(Ju(t,u)||oy(t,u))&&Dt(je(t,u))&&o.push(u)};for(let[u,d]of Object.entries(t.entities??{})){let p=d.device_id;p&&d.area_id&&(i.get(p)??i.set(p,new Set).get(p)).add(d.area_id),p&&ho(t,u)&&ra(n,p).push(u),p&&!d.hidden&&!d.entity_category&&(r.get(p)??r.set(p,new Set).get(p)).add(Ys(u));let h=It(t,u);h===null?s(u):Ju(t,u)&&ra(e,h).push(u)}if(t.entities)for(let u of Object.keys(t.states))t.entities[u]||s(u);let a=Xs.indexOf("binary")-.5,l=u=>{let d=Q(u),p=d?Xs.indexOf(d):a;return p>a&&lo(u,t.states[u])!==null?a:p};o.sort((u,d)=>l(u)-l(d)||B(t,u).localeCompare(B(t,d)));for(let[u,d]of e){let p=t.areas?.[u]?.name;d.sort((h,f)=>l(h)-l(f)||B(t,h,p).localeCompare(B(t,f,p)))}let c=new Set;for(let[u,d]of i)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:o,domainsByDevice:r,hubs:c}}function In(t){let e=na;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:na=sy(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?[]:In(t).byArea.get(e)??[]}function ed(t,e){if(!t.entities)return[];let n=[];for(let[r,i]of In(t).byArea){let o=i.filter(s=>Dt(je(t,s)));r!==e&&o.length>0&&n.push({areaId:r,name:t.areas?.[r]?.name??r,ids:o})}return n.sort((r,i)=>r.name.localeCompare(i.name))}var td=t=>t.entities?In(t).withoutArea:[],ia=(t,e)=>!!t.entities&&In(t).hubs.has(e),po=(t,e)=>t.entities?In(t).powerByDevice.get(e)??[]:[];function On(t,e){let n=new Map;for(let i of e)ra(n,t.entities?.[i]?.device_id??`entity:${i}`).push(i);let r=new Map(e.map((i,o)=>[i,o]));return[...n.values()].map(i=>{let o=i.find(s=>!t.entities?.[s]?.name)??i[0];return{primary:o,others:i.filter(s=>s!==o)}}).sort((i,o)=>r.get(i.primary)-r.get(o.primary))}var fo=(t,e)=>On(t,e).map(n=>n.primary),ay={temperature:"temperature",humidity:"humidity",co2:"carbon_dioxide",illuminance:"illuminance"};function oa(t,e,n,r=!1){let i=t.states[e]?.attributes;if(!i)return!1;let o=(i.symcon_variable_type===1||i.symcon_variable_type===2)&&typeof i.symcon_id=="number";if(typeof i.symcon_id=="number"&&!o||!o&&!/^(sensor|input_number|number)\./.test(e))return!1;if(r&&o)return!0;let s=String(i.unit_of_measurement??"").replace(/\s/g,"").toLowerCase();return n==="temperature"&&["\xB0c","\xB0f","\u2103","\u2109","k"].includes(s)||n==="humidity"&&!i.device_class&&["%","%rh","%r.h.","%rf","%r.f."].includes(s)||n==="co2"&&s==="ppm"&&/co[₂2]/i.test(String(i.friendly_name??""))||n==="illuminance"&&["lx","lux"].includes(s)?!0:i.device_class===ay[n]}var ly=new Set(["climate","water_heater","switch","button","camera","media_player","vacuum","light","fan","lawn_mower"]),cy=["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"],uy=new RegExp(`(${cy.join("|")})`,"i");function sa(t,e){let n=t.entities?.[e]?.device_id,r=n&&!ia(t,n)?In(t).domainsByDevice.get(n):void 0;return r&&[...r].some(i=>ly.has(i))?!1:!uy.test(`${e} ${t.states[e]?.attributes.friendly_name??""}`)}function nd(t,e,n,r){let i=n.climate?.[r];if(i==="none")return[];if(i)return[i].flat().filter(c=>t.states[c]);let o=(e?.placements??[]).filter(c=>c.entity_id.startsWith("sensor.")),s=o.filter(c=>C([c.x,c.z],n.points)).map(c=>c.entity_id),a=new Set(o.filter(c=>!C([c.x,c.z],n.points)).map(c=>c.entity_id));return[...new Set([...ye(t,n).filter(c=>!a.has(c)),...s])].filter(c=>c.startsWith("sensor.")&&oa(t,c,r)&&sa(t,c))}function rd(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 mo(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 go(t,e){let n=e?t.states[e]:void 0;if(!n||He(n))return null;let r=n.attributes;if(r.nf_cover_control&&typeof r.current_position=="number")return r.current_position;let i=rd(n);if(i!==null)return i;if(typeof r.current_position=="number")return Math.max(0,Math.min(100,r.current_position));if(!n.state.trim())return null;let o=Number(n.state);if(!Number.isFinite(o))return null;let s=r.unit_of_measurement==="%"||o>1||o<0?o:o*100;return Math.max(0,Math.min(100,s))}var dy=new Set([void 0,"shutter","blind","awning","shade","curtain","window"]),hy=new Set(["garage","gate"]),py=new Set(["window","opening"]);function Tr(t,e,n=!1){let r=new Map;return t.forEach((i,o)=>{let s=n&&e.length===1?e[0]:e[o];s&&r.set(i.id,s)}),r}var id=(t,e)=>t==="none"?null:t??e??null,Ot=t=>t&&t!=="none"?t:null;function Ht(t,e){let n=new Map;for(let r of e)for(let i of r.rooms){let o=r.openings.filter(g=>g.room_id===i.id).sort((g,b)=>g.edge-b.edge||g.offset-b.offset);if(o.length===0)continue;let s=ye(t,i),a=g=>t.states[g]?.attributes.device_class,l=g=>s.filter(b=>Q(b)==="binary"&&g(a(b)??"")),c=g=>o.filter(b=>b.type===g),u=Tr(c("window"),s.filter(g=>Q(g)==="cover"&&dy.has(a(g))),!0),d=Tr(c("window"),l(g=>py.has(g))),p=Tr(c("door"),l(g=>g==="door")),h=Tr(c("garage"),s.filter(g=>Q(g)==="cover"&&hy.has(a(g)??""))),f=Tr(c("garage"),l(g=>g==="garage_door"));for(let g of o){let b=g.type==="window"?u:g.type==="garage"?h:null,y=g.type==="window"?d:g.type==="garage"?f:p,v=g.leaves===2;n.set(g.id,{cover:id(g.cover,b?.get(g.id)),contact:g.sensor==="handle"&&g.contact==null?null:id(g.contact,y.get(g.id)),tilt:g.tilt==="none"?null:g.tilt,contact2:v?Ot(g.contact2):null,tilt2:v?Ot(g.tilt2):null,position:Ot(g.position),positionInverted:!!g.position_inverted,tiltAngle:Ot(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"?Ot(g.lock):null,cover2:g.type==="garage"?null:Ot(g.cover2),coverTilt:Ot(g.cover_tilt),cover2Tilt:Ot(g.cover2_tilt),coverInverted:!!g.cover_inverted,coverTiltInverted:!!g.cover_tilt_inverted,cover2Inverted:!!g.cover2_inverted,cover2TiltInverted:!!g.cover2_tilt_inverted})}}return n}var fy=[[/^(tilted|tilt|gekippt|kipp)/i,"tilted"],[/^(open|opened|offen|geöffnet|on)$/i,"open"],[/^(closed|close|geschlossen|zu|off)$/i,"closed"]];function aa(t){if(!t||He(t))return null;let e=t.attributes.window_state;for(let n of[typeof e=="string"?e:"",t.state]){let r=n.trim(),i=r&&fy.find(([o])=>o.test(r));if(i)return i[1]}return null}var od=new WeakMap,sd=new WeakMap;function ad(t,e){let n=sd.get(t)??t,r=od.get(n)??new WeakMap;od.set(n,r);let i=r.get(e);if(i)return i;let o=new Map;for(let l of e)for(let c of l.placements)c.entity_id.startsWith("cover.")&&o.set(c.entity_id,{tilt:c.cover_tilt==="none"?null:c.cover_tilt,position:c.position});for(let l of Ht(n,e).values())l.cover&&!o.has(l.cover)&&o.set(l.cover,{tilt:l.coverTilt,position:l.position}),l.cover2&&!o.has(l.cover2)&&o.set(l.cover2,{tilt:l.cover2Tilt});let s={...n.states};for(let[l,c]of o){let u=n.states[l];if(!u)continue;let d={...u.attributes,nf_cover_control:!0},p=go(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?go(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[l]={...u,state:g,attributes:d}}let a={...n,states:s,callService:async(l,c,u={})=>{if(l!=="cover")return n.callService(l,c,u);let d=Array.isArray(u.entity_id)?u.entity_id:[u.entity_id],p=async h=>{let f=typeof h=="string"?o.get(h):void 0;if(!f)return n.callService(l,c,{...u,entity_id:h});let g={...u,entity_id:h},b=c;(b==="toggle"||b==="toggle_cover")&&(b=s[String(h)]?.state==="closed"?"open_cover":"close_cover");let y=b.includes("tilt");y&&f.tilt&&(g.entity_id=f.tilt);let v=f.tilt?n.states[f.tilt]:void 0;return y&&f.tilt&&!v?.attributes.symcon_id&&typeof v?.attributes.current_tilt_position!="number"&&(b==="set_cover_tilt_position"?(b="set_cover_position",g.position=g.tilt_position,delete g.tilt_position):b==="open_cover_tilt"?b="open_cover":b==="close_cover_tilt"&&(b="close_cover")),n.callService(l,b,g)};return Array.isArray(u.entity_id)?Promise.all(d.map(p)):p(d[0])}};return sd.set(a,n),r.set(e,a),a}var Z=t=>t?.symconObjects!==void 0;function Le(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 sn(t){return!t||t.state==="unknown"||t.state==="unavailable"?null:t.attributes.symcon_value??t.attributes.symcon_numeric_value??t.state}function Lt(t){let e=sn(t);if(e===null||typeof e=="boolean"||e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}function zr(t){let e=sn(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 la(t){return sn(t)===null?"\u2013":String(t?.attributes.symcon_formatted??sn(t))}function ld(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 cd="weather.nextfloor_symcon",dd={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"},ud=new WeakMap;function my(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 hd(t,e){if(!Z(t))return t;let n=e.weather_variables??{};if(!e.rain_sensor&&!Object.values(n).some(h=>h&&h!=="none"))return t;let r=ud.get(t)??new WeakMap;ud.set(t,r);let i=r.get(e);if(i)return i;let o={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=Lt(f);g!==null&&(o[h]=h==="cloud_coverage"&&f?.attributes.symcon_max===1?g*100:g),f?.attributes.unit_of_measurement&&(o[`${h}_unit`]=f.attributes.unit_of_measurement)}for(let h of["wind_speed","wind_gust_speed"]){let f=s(h),g=Lt(f);g!==null&&(o[h]=ld(g,f?.attributes.unit_of_measurement))}o.wind_speed_unit="km/h";let a=sn(s("wind_bearing"));a!==null&&(o.wind_bearing=a);let l=my(la(s("condition"))),c=e.rain_sensor?t.states[e.rain_sensor]:void 0,u=zr(c);u!==null&&e.rain_sensor_inverted&&(u=!u),u===null&&typeof o.precipitation=="number"&&(u=o.precipitation>0),zr(s("lightning"))?l=u?"lightning-rainy":"lightning":zr(s("snow"))?l=u?"snowy-rainy":"snowy":zr(s("fog"))?l="fog":u===!0?l=Number(o.precipitation??0)>=8?"pouring":"rainy":u===!1&&l&&/rain|pouring/.test(l)&&(l=null),!l&&typeof o.cloud_coverage=="number"&&(l=o.cloud_coverage>70?"cloudy":o.cloud_coverage>20?"partlycloudy":"sunny"),!l&&u===!1&&(l="sunny");let d={entity_id:cd,state:l??"unknown",attributes:o},p={...t,states:{...t.states,[cd]:d}};return r.set(e,p),p}var Hn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},an=t=>(...e)=>({_$litDirective$:t,values:e}),Ct=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 Pr=class extends Ct{constructor(e){if(super(e),this.it=_,e.type!==Hn.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===_||e==null)return this._t=void 0,this.it=e;if(e===nt)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:[]}}};Pr.directiveName="unsafeHTML",Pr.resultType=1;var pd=an(Pr);var fd=/\b(tv|fernseh|television|fire ?tv|apple ?tv|chromecast|shield)/i,md=/(kühl|fridge|gefrier|freezer)/i,gd=/(spülmaschine|geschirrspül|dishwasher)/i,gy=/(kochfeld|herd|induktion|cooktop)/i,_y={robot_vacuum:/(saug|vacuum|robo|roomba|roborock|dreame|ecovacs|deebot)/i,tv_board:fd,tv_wall:fd,desk:/\b(pc|computer|rechner|desktop|monitor|workstation)/i,fridge:md,fridge_smart:md,stove:/(herd|kochfeld|cooktop|stove|induktion)/i,kitchen_tall:/(backofen|oven|ofen)/i,dishwasher:gd,washer:/(waschmaschine|washer|washing)/i,dryer:/(trockner|dryer)/i,kitchen:/(kaffee|coffee|wasserkocher|kettle)/i,island:gy,sink:gd,radiator:/(heiz|radiator|thermostat|climate|hk|trv)/i},_d={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},bd=new Set(["tv_board","tv_wall"]);var Ln=t=>bd.has(t)||!!Ic(t),_o=t=>!!U(t)?.electric&&/speaker|multiroom|soundbar/.test(t.split(":").pop()??t),Ir=t=>Ln(t)||t==="desk"||t==="fridge_smart",by=t=>!!t&&t!=="none";function yy(t,e){if(ho(t,e))return e;let n=t.entities?.[e]?.device_id;return n?po(t,n).find(r=>r!==e)??null:null}var vy=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function Dr(t,e,n,r){return t.find(i=>e?.test(n(i)))??(r?t[0]??null:null)}function Re(t,e){let n=new Map;for(let r of e){let i=new Set([...r.furniture.flatMap(o=>[o.entity,o.power,o.fan_entity]),...r.placements.map(o=>o.entity_id)].filter(by));for(let o of r.furniture){let s=o.type in _d,a=An(o.type),l=s?_d[o.type]:_y[o.type];if(!l&&!a&&!_o(o.type)&&o.entity==null&&o.power==null)continue;let c=vy(r,o.x,o.z),u=(c?fo(t,ye(t,c)):[]).filter(b=>!i.has(b)),d=b=>`${b} ${B(t,b)}`,p=b=>u.filter(y=>Q(y)===b),h=o.entity==="none"?null:o.entity??null;if(o.entity==null){if(o.type==="ceiling_fan"){let b=(c?ye(t,c):[]).filter(v=>!i.has(v)),y=new Set(b.filter(v=>Q(v)==="fan").map(v=>t.entities?.[v]?.device_id).filter(Boolean));h=b.find(v=>Q(v)==="light"&&y.has(t.entities?.[v]?.device_id))??Dr(p("light"),l,d,!1)}else if(s)h=Dr(p("light"),l,d,!0);else if(o.type==="robot_vacuum"){let b=c?.area_id??null;h=Object.keys(t.entities??{}).find(y=>y.startsWith("vacuum.")&&!i.has(y)&&It(t,y)===b)??null}else if(o.type==="radiator"||a)h=Dr(p("climate"),l,d,!0);else if(Ln(o.type)){let b=p("media");h=b.find(y=>t.states[y]?.attributes.device_class==="tv")??Dr(b,l,d,bd.has(o.type))}else if(_o(o.type)){let b=p("media").filter(y=>t.states[y]?.attributes.device_class!=="tv");h=Dr(b,l,d,!1)??(b.length===1?b[0]:null)}else l&&(h=u.find(b=>["switch","media","fan"].includes(Q(b)??"")&&l.test(d(b)))??null);h&&i.add(h)}let f=o.power==="none"?null:o.power??null;o.power==null&&(f=h?yy(t,h):null,!f&&l&&c&&!s&&(f=ye(t,c).find(b=>ho(t,b)&&!i.has(b)&&l.test(d(b)))??null),f&&i.add(f));let g=null;if(o.type==="ceiling_fan"&&(g=o.fan_entity==="none"?null:o.fan_entity??null,o.fan_entity==null)){let b=(c?ye(t,c):[]).filter(v=>Q(v)==="fan"&&!i.has(v)),y=h?t.entities?.[h]?.device_id:void 0;g=(y?b.find(v=>t.entities?.[v]?.device_id===y):void 0)??b[0]??null,g&&i.add(g)}(h||f||g)&&n.set(o.id,{entity:h,power:f,...o.type==="ceiling_fan"?{fan:g}:{}})}}return n}var yd=t=>t==="fridge"||t==="fridge_smart"||/(fridge|freezer|kuehl|gefrier|chest_freezer)/.test(t.slice(t.lastIndexOf(":")+1));function vd(t,e,n=[]){let r=[];for(let i of e){let o=(a,l)=>i.rooms.some(c=>c.points.length>=3&&C([a,l],c.points)),s=Re(t,[i]);r.push(...i.placements.filter(a=>a.outside||!o(a.x,a.z)).map(a=>a.entity_id)),r.push(...i.furniture.filter(a=>!o(a.x,a.z)).flatMap(a=>[s.get(a.id)?.entity,s.get(a.id)?.power]));for(let a of i.outdoor??[])a.area_id&&r.push(...fo(t,uo(t,a.area_id))),r.push(a.pump_entity,a.temp_entity)}return[...new Set(r.filter(i=>!!i&&!!t.states[i]&&!n.includes(i)))]}function wy(t,e){return Math.min(...e.map((n,r)=>{let i=e[(r+1)%e.length],[o,s]=[i[0]-n[0],i[1]-n[1]],a=Math.min(1,Math.max(0,((t[0]-n[0])*o+(t[1]-n[1])*s)/(o*o+s*s||1)));return Math.hypot(t[0]-n[0]-o*a,t[1]-n[1]-s*a)}))}function kd(t,e,n=[]){let r=t.points;if(r.length<3||e.length===0)return[];let i=r.map(y=>y[0]),o=r.map(y=>y[1]),[s,a,l,c]=[Math.min(...i),Math.max(...i),Math.min(...o),Math.max(...o)],u=Math.min(a-s,c-l),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 y=s+d/2;y=p&&g.push({at:w,wallDistance:x})}g.length===0&&g.push({at:f,wallDistance:0});let b=[...n];return e.map(y=>{let v=Q(y)==="light",w=g[0].at,x=-1/0;for(let{at:M,wallDistance:A}of g){let T=b.length?Math.min(...b.map(D=>Math.hypot(M[0]-D[0],M[1]-D[1]))):3,F=Math.hypot(M[0]-f[0],M[1]-f[1]),L=Math.min(T,3)*2;Fx+1e-9&&(x=L,w=M)}let k=[Math.round(w[0]*100)/100,Math.round(w[1]*100)/100];return b.push(k),{entity_id:y,x:k[0],z:k[1],y:null,mount:null}})}var wd=/(^|_)(current_room|current_segment|aktueller_raum|current_area)($|_)/;function xd(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(o=>o.device_id===r&&o.entity_id.startsWith("sensor.")&&(wd.test(o.translation_key??"")||wd.test(o.entity_id.split(".")[1])))?.entity_id??null}var me=t=>/^(sensor|input_number|number)\./.test(t),bo=t=>/^(binary_sensor|input_boolean)\./.test(t);function Cn(t,e){if(!me(e))return!1;let n=t?.states[e]?.attributes;return n?.device_class==="power"||n?.unit_of_measurement==="W"||n?.unit_of_measurement==="kW"}function ky(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=ky(t,n),i=t?.states[n],o=typeof i?.attributes.symcon_path=="string"?i.attributes.symcon_path:void 0,s={id:n,label:r?`${B(t,n)} \xB7 ${r}`:B(t,n)};return o&&(s.detail=`Objektbaum: ${o}`),typeof i?.attributes.symcon_source_entity=="string"&&(s.sourceEntity=i.attributes.symcon_source_entity),s}).sort((n,r)=>n.label.localeCompare(r.label))}function $d(t,e,n){return e.unsupported?[]:H(t,r=>Le(t,r,e.types)&&!e.excluded?.(r)).map(r=>{if(!e.role)return r;let i=t.states[r.id],o=`${e.role}.${i.attributes.symcon_id}`,s=n?t.states[n]:void 0,a=n&&(n===r.id||s?.attributes.symcon_source_entity===r.id)?n:t.states[o]?o:r.id;return a===r.id?r:{...r,id:a,sourceEntity:r.id}})}function yo(t,e){return t.power&&t.power!=="none"?t.power:e.get(t.id)?.power??null}var ve=ee` :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); } `,SS=ee` :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; } `,pt=ee` /* 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:xy}=Lu,Sd=t=>t;var Rd=t=>t.strings===void 0,Md=()=>document.createComment(""),Nn=(t,e,n)=>{let r=t._$AA.parentNode,i=e===void 0?t._$AB:e._$AA;if(n===void 0){let o=r.insertBefore(Md(),i),s=r.insertBefore(Md(),i);n=new xy(o,s,t,t.options)}else{let o=n._$AB.nextSibling,s=n._$AM,a=s!==t;if(a){let l;n._$AQ?.(t),n._$AM=t,n._$AP!==void 0&&(l=t._$AU)!==s._$AU&&n._$AP(l)}if(o!==i||a){let l=n._$AA;for(;l!==o;){let c=Sd(l).nextSibling;Sd(r).insertBefore(l,i),l=c}}}return n},Nt=(t,e,n=t)=>(t._$AI(e,n),t),$y={},Ed=(t,e=$y)=>t._$AH=e,Ad=t=>t._$AH,vo=t=>{t._$AR(),t._$AA.remove()};var Fd=(t,e,n)=>{let r=new Map;for(let i=e;i<=n;i++)r.set(t[i],i);return r},ln=an(class extends Ct{constructor(t){if(super(t),t.type!==Hn.CHILD)throw Error("repeat() can only be used in text expressions")}dt(t,e,n){let r;n===void 0?n=e:e!==void 0&&(r=e);let i=[],o=[],s=0;for(let a of t)i[s]=r?r(a,s):s,o[s]=n(a,s),s++;return{values:o,keys:i}}render(t,e,n){return this.dt(t,e,n).values}update(t,[e,n,r]){let i=Ad(t),{values:o,keys:s}=this.dt(e,n,r);if(!Array.isArray(i))return this.ut=s,o;let a=this.ut??=[],l=[],c,u,d=0,p=i.length-1,h=0,f=o.length-1;for(;d<=p&&h<=f;)if(i[d]===null)d++;else if(i[p]===null)p--;else if(a[d]===s[h])l[h]=Nt(i[d],o[h]),d++,h++;else if(a[p]===s[f])l[f]=Nt(i[p],o[f]),p--,f--;else if(a[d]===s[f])l[f]=Nt(i[d],o[f]),Nn(t,l[f+1],i[d]),d++,f--;else if(a[p]===s[h])l[h]=Nt(i[p],o[h]),Nn(t,i[d],i[p]),p--,h++;else if(c===void 0&&(c=Fd(s,h,f),u=Fd(a,d,p)),c.has(a[d]))if(c.has(a[p])){let g=u.get(s[h]),b=g!==void 0?i[g]:null;if(b===null){let y=Nn(t,i[d]);Nt(y,o[h]),l[h]=y}else l[h]=Nt(b,o[h]),Nn(t,i[d],b),i[g]=null;h++}else vo(i[p]),p--;else vo(i[d]),d++;for(;h<=f;){let g=Nn(t,l[f+1]);Nt(g,o[h]),l[h++]=g}for(;d<=p;){let g=i[d++];g!==null&&vo(g)}return this.ut=s,Ed(t,l),nt}});var Sy=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),ca=-1,zd=[{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"}],Td=t=>t.object_type===1&&zd.some(e=>e.type===t.module_type);function My(t){let e=new Map(t.map(l=>[l.object_id,l])),n=t.filter(l=>{if(!Td(l))return!1;let c=new Set([l.object_id]),u=e.get(l.parent_id);for(;u&&!c.has(u.object_id);){if(Td(u))return!1;c.add(u.object_id),u=e.get(u.parent_id)}return!0});if(!n.length)return t;let r=new Map(e),i=new Map;for(let l of t){let c=i.get(l.parent_id)??[];c.push(l),i.set(l.parent_id,c)}let o=(l,c,u,d,p)=>({object_id:l,parent_id:c,name:u,path:d,position:p,object_type:0,hidden:!1,icon:"",virtual:!0});r.set(ca,o(ca,0,"System","System",Number.MAX_SAFE_INTEGER));let s=new Set,a=(l,c,u)=>{if(s.has(l.object_id))return;s.add(l.object_id);let d={...l,parent_id:c,path:`${u} / ${l.name}`};r.set(l.object_id,d);for(let p of i.get(l.object_id)??[])a(p,l.object_id,d.path)};return zd.forEach((l,c)=>{let u=n.filter(h=>h.module_type===l.type);if(!u.length)return;let d=-10-l.type,p=`System / ${l.name}`;r.set(d,o(d,ca,l.name,p,c));for(let h of u)a(h,d,p)}),[...r.values()]}function ua(t){let e=My(t),n=new Map(e.map(i=>[i.object_id,i])),r=new Map;for(let i of e){let o=n.has(i.parent_id)?i.parent_id:0,s=r.get(o)??[];s.push(i),r.set(o,s)}for(let i of r.values())i.sort((o,s)=>o.position-s.position||o.object_type-s.object_type||Sy.compare(o.name,s.name));return{nodes:n,children:r}}function da(t,e){let n=[],r=new Set([e]),i=t.nodes.get(e)?.parent_id;for(;i&&!r.has(i)&&t.nodes.has(i);)n.push(i),r.add(i),i=t.nodes.get(i)?.parent_id;return n}function ha(t,e,n=""){let r=n.trim().toLocaleLowerCase("de").split(/\s+/).filter(Boolean),i=r.length?new Set:null;if(i){for(let l of t.nodes.values())if(r.every(c=>`${l.name} ${l.path}`.toLocaleLowerCase("de").includes(c))){i.add(l.object_id);for(let c of da(t,l.object_id))i.add(c)}}let o=[],s=new Set,a=(l,c)=>{let u=(t.children.get(l)??[]).filter(d=>!i||i.has(d.object_id));u.forEach((d,p)=>{if(s.has(d.object_id))return;s.add(d.object_id);let h=(t.children.get(d.object_id)?.length??0)>0,f=h&&(!!i||e.has(d.object_id));o.push({node:d,depth:c,hasChildren:h,expanded:f,index:p+1,siblings:u.length}),f&&a(d.object_id,c+1)})};return a(0,0),o}var Pd=["Boolean","Integer","Float","String"],Ry={light:"Licht",cover:"Jalousie/Tor",switch:"Schalter",binary_sensor:"Bin\xE4rsensor",sensor:"Sensor",climate:"Heizung",lock:"Schloss",script:"Skript",schedule:"Schaltuhr",media_player:"Medienger\xE4t",fan:"L\xFCfter"};function Dd(t,e={}){if(t.virtual||t.object_type===0)return"Das ist eine Kategorie. Klappe sie auf und w\xE4hle den Datenpunkt darunter aus.";if(t.object_type===1)return"Das ist eine Instanz. Klappe sie auf und w\xE4hle ihre Variable aus, zum Beispiel \u201EValue\u201C.";if(e.schedule&&t.object_type!==4)return"Hier wird eine klassische Symcon-Schaltuhr (Wochenplan-Ereignis) erwartet, keine Variable.";if(e.unsupported)return e.unsupported;if(!t.entity_id)return t.object_type===2?"Diese Variable wurde noch nicht geladen. Lade die Variablen oben in der Titelleiste neu und \xF6ffne die Auswahl erneut.":t.object_type===6?"Dieser Link verweist auf keinen unterst\xFCtzten Datenpunkt. W\xE4hle die Variable direkt im Objektbaum aus.":t.object_type===4?"Dieses Ereignis ist keine unterst\xFCtzte klassische Symcon-Schaltuhr (Wochenplan).":"Dieser Objekttyp kann in diesem Feld nicht verkn\xFCpft werden. W\xE4hle eine passende Variable aus.";let n=e.states?.[t.entity_id];if(e.states&&!n)return"Diese Variable ist im aktuellen Datenbestand nicht mehr vorhanden. Lade die Variablen oben in der Titelleiste neu.";let r=n?.attributes.symcon_variable_type,i=r===void 0?void 0:Pd[Number(r)];if(n&&!n.attributes.symcon_schedule&&!i)return"Der native Datentyp dieser Variable ist nicht verf\xFCgbar. Lade die Variablen oben in der Titelleiste neu.";if(i&&e.types&&!e.types.includes(Number(r)))return`Datentyp ${i} passt hier nicht. F\xFCr \u201E${e.label||"dieses Feld"}\u201C wird ${e.types.map(c=>Pd[c]).join(" oder ")} ben\xF6tigt.`;let o=e.excluded?.(t.entity_id);if(o)return o;let s=Ry[t.entity_id.split(".")[0]],a=n?.attributes.unit_of_measurement,l=[i&&`Datentyp: ${i}`,a&&`Einheit: ${a}`,s&&`erkannte Funktion: ${s}`].filter(Boolean).join(" \xB7 ");return`Dieser Datenpunkt erf\xFCllt den Filter${e.label?` f\xFCr \u201E${e.label}\u201C`:" dieses Feldes"} nicht.${l?` ${l}.`:""}`}var Ey=["Kategorie","Instanz","Variable","Skript","Ereignis","Medium","Link"],pa=class extends X{static properties={objects:{attribute:!1},options:{attribute:!1},fixed:{attribute:!1},value:{attribute:!1},disabled:{type:Boolean},placeholder:{attribute:!1},context:{attribute:!1},_notice:{state:!0},_query:{state:!0},_expanded:{state:!0},_pending:{state:!0},_active:{state:!0},_selected:{state:!0}};tree=ua([]);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._notice="",this._query="",this._expanded=new Set,this._pending=null,this._active=null,this._selected=null}willUpdate(e){e.has("objects")&&(this.tree=ua(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(i=>i.entity_id===n&&(i.object_type===2||i.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="",this._notice="";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 da(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,this._notice=""):(this._pending=null,this._selected=null,this._notice=Dd(e,this.context))}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=ha(this.tree,this._expanded,this._query),r=Math.max(0,n.findIndex(s=>s.node.object_id===this._active)),i=n[r];if(!i)return;let o=r;if(e.key==="ArrowDown")o=Math.min(n.length-1,r+1);else if(e.key==="ArrowUp")o=Math.max(0,r-1);else if(e.key==="Home")o=0;else if(e.key==="End")o=n.length-1;else if(e.key==="ArrowRight")i.hasChildren&&!i.expanded?this.toggle(i.node.object_id):i.hasChildren&&(o=Math.min(n.length-1,r+1));else if(e.key==="ArrowLeft")i.expanded&&!this._query?this.toggle(i.node.object_id):o=Math.max(0,n.findIndex(s=>s.node.object_id===i.node.parent_id));else if(e.key===" "||e.key==="Enter")this.select(i.node),e.key==="Enter"&&this.entityFor(i.node)&&this.commit();else return;e.preventDefault(),(o!==r||this._active===null)&&(this._active=n[o].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),i=!!r;return m`
{this.select(n),this.renderRoot.querySelector(".tree")?.focus()}} @dblclick=${()=>{i?(this.select(n),this.commit()):e.hasChildren&&this.toggle(n.object_id)}}> ${this.icon(n.object_type)}${n.name||"(Ohne Namen)"} ${n.virtual?"Systembereich":Ey[n.object_type]??"Objekt"}${n.hidden?" \xB7 ausgeblendet":""} ${i&&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??""),i=this._selected===null?void 0:this.tree.nodes.get(this._selected),o=(i&&this.entityFor(i)===this._pending?i:void 0)??this.variableNode(this._pending),s=ha(this.tree,this._expanded,this._query),a=s.find(c=>c.node.object_id===this._active),l=!!this.value&&!this.fixed.some(c=>c.id===this.value);return m`
${l?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 · ${this.context?.label||"Objektbaum"}

${this.fixed.length?m`
${this.fixed.map(c=>m` `)}
`:_}
${ln(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."}

`}
${this._notice?m`
${this._notice}
`:_}
${o?.name??r?.label??"Noch kein Datenpunkt ausgew\xE4hlt"} ${o?.path??"Nur passende Datenpunkte k\xF6nnen ausgew\xE4hlt werden."}
`}static styles=[ve,ee` :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); } .rejection { flex:none; margin:0 20px 12px; padding:8px 10px; border-left:2px solid #e5b56d; border-radius:4px; background:#e5b56d0c; color:var(--nf-text); font-size:12px; line-height:1.4; overflow-wrap:anywhere; } 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",pa);var Id=40,fa=class extends X{static properties={options:{attribute:!1},objectTree:{attribute:!1},context:{attribute:!1},fixed:{attribute:!1},value:{attribute:!1},disabled:{type:Boolean},placeholder:{attribute:!1},_query:{state:!0},_open:{state:!0},_cursor:{state:!0}};blurTimer;constructor(){super(),this.options=[],this.objectTree=void 0,this.fixed=[],this.value=null,this.disabled=!1,this.placeholder="",this._query="",this._open=!1,this._cursor=0}get current(){return[...this.fixed,...this.options].find(e=>e.id===this.value)}get hits(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=s=>{let a=`${s.label} ${s.detail??s.id}`.toLowerCase();return n.every(l=>a.includes(l))},i=this.fixed.filter(s=>!e||r(s)),o=e?this.options.filter(r):this.options;return[...i,...o.slice(0,Id)]}get leftOut(){let e=this._query.trim().toLowerCase(),n=e.split(/\s+/).filter(Boolean),r=e?this.options.filter(i=>n.every(o=>`${i.label} ${i.detail??i.id}`.toLowerCase().includes(o))).length:this.options.length;return Math.max(0,r-Id)}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,i)=>m`
  • o.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,ee` :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",fa);var ma=class extends X{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,ee` :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",ma);var cn=t=>t.target.value,ga=t=>Number.parseFloat(t.replace(",",".")),ae=t=>Math.round(t*1e3)/1e3,Od=t=>t.wide?"nf-field nf-wide":"nf-field";function E(t,e,n,r,i=.01,o){return m``}function W(t,e,n,r,i={}){return m``}function O(t,e,n,r,i,o={}){return m``}function I(t,e,n,r,i={}){return m``}function Ge(t,e,n,r,i){return m``}function z(t,e,n,r,i,o,s={}){let a=r===void 0?null:r?t.t("entity_auto",{name:B(t.hass,r)}):t.t("entity_auto_none"),l=[...a!==null?[{id:"__auto",label:a}]:[],{id:"none",label:t.t("entity_none")}],c=n??(a!==null?"__auto":"none"),u=t.hass?.symconObjects!==void 0&&!s.schedule?$d(t.hass,s,n):i;return m``}function Bn(t,e,n){return n?(n.startsWith("mdi:")?n:`mdi:${n}`).replace(/[^a-z0-9:-]/gi,""):t.hass?Zu(t.hass,e):null}function Bt(t,e,n){let r=e?(e.startsWith("mdi:")?e:`mdi:${e}`).replace(/[^a-z0-9:-]/gi,""):"";return m``}function Vn(t,e,n){return m``}function Vt(t,e,n){let r=e??{},i=o=>s=>{let a={...r,[o]:Math.round(Math.max(-5,Math.min(5,s))*100)/100};n(a.x||a.z||a.y?a:null)};return m`
${t.t("pin_shift")}
${E(t,"\u2194 x",r.x??0,i("x"),.05)} ${E(t,"\u2195 z",r.z??0,i("z"),.05)} ${E(t,t.t("pin_shift_up"),r.y??0,i("y"),.05)} ${e?m``:_} ${S(t.t("pin_shift_hint"),"nf-wide")}
`}var J=(...t)=>m`
${t}
`,S=(t,e="")=>m``;function un(t,e,n,r={}){let i=r.lowest??10;return m``}var rt=(t,e,n={})=>t.callWS({type:`nextfloor/${e}`,...n});async function wo(t,e){return(await rt(t,"image/get",{image_id:e})).data}async function Wt(t,e,n){await rt(t,"image/set",{image_id:e,data:n})}async function Hd(t){return(await rt(t,"history/list")).snapshots}async function Ld(t,e){return(await rt(t,"history/snapshot",e?{name:e}:{})).id}async function Cd(t,e){return(await rt(t,"history/get",{snapshot_id:e})).building}async function Nd(t,e){await rt(t,"history/delete",{snapshot_id:e})}async function Bd(t,e){return(await rt(t,"history/restore",{snapshot_id:e})).revision}var Or=(t,e)=>rt(t,"packs/import",{pack:e});async function Vd(t,e){await rt(t,"packs/remove",{pack_id:e})}var Wd=t=>rt(t,"backup/export"),Kd=(t,e,n)=>rt(t,"backup/import",{building:e,packs:n});var G=(t,e)=>[t[0]-e[0],t[1]-e[1]],ft=(t,e)=>[t[0]+e[0],t[1]+e[1]],it=(t,e)=>[t[0]*e,t[1]*e],te=(t,e)=>t[0]*e[0]+t[1]*e[1],Ee=(t,e)=>t[0]*e[1]-t[1]*e[0],ge=t=>Math.hypot(t[0],t[1]),ot=t=>{let e=ge(t)||1;return[t[0]/e,t[1]/e]},_a=t=>[-t[1],t[0]],ba=t=>[t[1],-t[0]];var Ay=.05,Fy=.2,Ty=.12;function zy(t){let e=[];return t.forEach((n,r)=>{let i=n.points;if(i.length<3)return;let o=_e(i)>=0;i.forEach((s,a)=>{let l=i[(a+1)%i.length],c=ge(G(l,s));if(c<.05)return;let u=[(l[0]-s[0])/c,(l[1]-s[1])/c],d=o?[u[1],-u[0]]:[-u[1],u[0]];(u[1]<-1e-9||Math.abs(u[1])<=1e-9&&u[0]<0)&&(u=[-u[0],-u[1]]);let p=[-u[1],u[0]],[h,f]=[te(s,u),te(l,u)];e.push({room:r,index:a,dir:u,normal:p,offset:te(s,p),outside:te(d,p)>0?1:-1,from:Math.min(h,f),to:Math.max(h,f)})})}),e}function Py(t,e,n){if(t.room===e.room||Math.abs(Ee(t.dir,e.dir))>Ay||t.outside===e.outside)return null;let r=(e.offset-t.offset)*t.outside;return r>n||r<-Ty||Math.abs(r)<1e-4||Math.min(t.to,e.to)-Math.max(t.from,e.from)Math.round(t*1e3)/1e3;function jd(t,e=.6){let n=zy(t),r=n.map((g,b)=>b),i=g=>r[g]===g?g:r[g]=i(r[g]),o=[],s=new Set,a=[];for(let g=0;gMath.abs(g[2])-Math.abs(b[2]));let l=new Map(n.map((g,b)=>[b,[b]])),c=(g,b)=>g.some(y=>b.some(v=>n[y].room===n[v].room&&Math.abs(n[y].offset-n[v].offset)>=.002));for(let[g,b,y]of a){let[v,w]=[i(g),i(b)];if(v!==w){if(c(l.get(v),l.get(w)))continue;r[v]=w,l.set(w,[...l.get(w),...l.get(v)]),l.delete(v)}o.push(ya(y)),s.add(g).add(b)}let u=new Map(n.map((g,b)=>[`${g.room}:${g.index}`,b]));for(let g=s.size>0;g;)g=!1,n.forEach((b,y)=>{let v=u.get(`${b.room}:${(b.index+1)%t[b.room].points.length}`);if(v===void 0||v===y)return;let w=n[v];!(Math.abs(Ee(b.dir,w.dir))<1e-6&&Math.abs(b.offset-w.offset)<.002&&b.outside===w.outside)||s.has(y)===s.has(v)||(s.add(y).add(v),g=!0)});n.forEach((g,b)=>{let y=u.get(`${g.room}:${(g.index+1)%t[g.room].points.length}`);if(y===void 0||y===b||!s.has(b)||!s.has(y))return;let v=n[y];Math.abs(Ee(g.dir,v.dir))<1e-6&&Math.abs(g.offset-v.offset)<.002&&g.outside===v.outside&&(r[i(b)]=i(y))});let d=()=>t.map(g=>({...g,points:g.points.map(b=>[b[0],b[1]])}));if(o.length===0)return{rooms:d(),gaps:o};let p=new Map;for(let g of s)p.set(i(g),[...p.get(i(g))??[],g]);let h=t.map(g=>g.points.map(()=>new Map));for(let[g,b]of p){let y=new Map(b.map(w=>[`${n[w].room}:${Math.round(n[w].offset*500)}`,n[w].offset])),v=[...y.values()].reduce((w,x)=>w+x,0)/y.size;for(let w of b){let x=n[w],k=[x.normal[0]*(v-x.offset),x.normal[1]*(v-x.offset)];h[x.room][x.index].set(g,k),h[x.room][(x.index+1)%t[x.room].points.length].set(g,k)}}return{rooms:t.map((g,b)=>({...g,points:g.points.map((y,v)=>{let w=[...h[b][v].values()].reduce((x,k)=>[x[0]+k[0],x[1]+k[1]],[y[0],y[1]]);return[ya(w[0]),ya(w[1])]})})),gaps:o}}function Gd(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 Dy=.25,Ud=t=>Math.round(t*1e3)/1e3,Zd=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function wa(t,e,n,r,i){let o=Zd(t,e,n);if(!o)return[r,i];let s=(a,l)=>C([a,l],o.points);return s(r,i)?[r,i]:s(r,n)?[r,n]:s(e,i)?[e,i]:[e,n]}function Iy(t,e,n,r){return t.rooms.some(i=>i.id!==e.id&&i.points.some((o,s)=>{let a=i.points[(s+1)%i.points.length];return Math.abs(te(G(o,n),r))<.02&&Math.abs(te(G(a,n),r))<.02}))}var va=(t,e)=>Math.abs((t-e+540)%360-180);function Hr(t,e,n,r=Dy){let i=Zd(t,e.x,e.z);if(!i)return null;let o=i.points,s=_e(o)>=0?1:-1,a=null;return o.forEach((l,c)=>{let u=o[(c+1)%o.length],d=ge(G(u,l));if(d<.3)return;let p=[(u[0]-l[0])/d,(u[1]-l[1])/d],h=[-p[1]*s,p[0]*s],f=te(G([e.x,e.z],l),p);if(f<0||f>d)return;let g=Iy(t,i,l,h)?n/2:0,b=te(G([e.x,e.z],l),h)-g,y=Math.atan2(-h[0],h[1])*180/Math.PI,w=[{rotation:y,extent:e.d/2},{rotation:y+90,extent:e.w/2},{rotation:y-90,extent:e.w/2}].reduce((k,M)=>va(e.rotation,M.rotation)50)return;let x=b-w.extent;Math.abs(x)>r||a&&Math.abs(x)>=Math.abs(a.gap)||(a={x:Ud(e.x-h[0]*x),z:Ud(e.z-h[1]*x),rotation:(Math.round(w.rotation)%360+360)%360,gap:x})}),a&&{x:a.x,z:a.z,rotation:a.rotation}}var Wn=Math.PI/180,st=t=>Math.tan(Math.min(80,Math.max(0,t))*Wn);function Cr(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 qd(t){if(!t.rotation)return null;let e=t.rotation*Wn;return{cx:(t.x0+t.x1)/2,cz:(t.z0+t.z1)/2,c:Math.cos(e),sn:Math.sin(e)}}function Yd(t,e){let n=qd(t);if(!n)return e;let[r,i]=[e[0]-n.cx,e[1]-n.cz];return[n.cx+r*n.c-i*n.sn,n.cz+r*n.sn+i*n.c]}function ka(t,e,n){let r=qd(t);if(!r)return[e,n];let[i,o]=[e-r.cx,n-r.cz];return[r.cx+i*r.c+o*r.sn,r.cz-i*r.sn+o*r.c]}function Nr(t,e=0){let{x0:n,x1:r,z0:i,z1:o}=Cr(t);return[[n-e,i-e],[r+e,i-e],[r+e,o+e],[n-e,o+e]].map(s=>Yd(t,s))}function $e(t){let{x0:e,x1:n,z0:r,z1:i}=Cr(t),o=s=>Yd(t,s);return t.axis==="x"?{u0:e,u1:n,w:i-r,at:(s,a)=>o([s,t.flip?i-a:r+a])}:{u0:r,u1:i,w:n-e,at:(s,a)=>o([t.flip?n-a:e+a,s])}}function Br(t,e,n){let{x0:r,x1:i,z0:o,z1:s}=Cr(t),[a,l]=ka(t,e,n);return t.axis==="x"?[a,t.flip?s-l:l-o]:[l,t.flip?i-a:a-r]}var Lr=Math.tan(30*Wn);function Vr(t,e,n,r,i){let o=Math.min(t*.3,r>1e-6?2.4/r:t*.3),s=Math.min(t*.3,i>1e-6?2.4/i:t*.3),a=e+o*r,l=n+s*i,c=Math.min(t-s,Math.max(o,(l-a+Lr*(t-s+o))/(2*Lr))),u=a+(c-o)*Lr;return{vla:o,vlb:s,yla:a,ylb:l,vr:c,rh:u,y:p=>p<=o?e+p*r:p<=c?a+(p-o)*Lr:p<=t-s?l+(t-s-p)*Lr:n+(t-p)*i}}function Ce(t){let e=$e(t).w,[n,r]=[t.eave_a,t.eave_b],[i,o]=[st(t.pitch_a),st(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*i,y:s=>n+s*i};case"mansard":{let s=Vr(e,n,r,i,o);return{vr:s.vr,rh:s.rh,y:s.y}}default:{let s=i+o>1e-6?Math.min(e,Math.max(0,(r-n+e*o)/(i+o))):e/2;return{vr:s,rh:n+s*i,y:a=>a<=s?n+a*i:r+(e-a)*o}}}}var dn=t=>Ce(t).rh;function Xd(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 Oy(t,e){let n=t.map(r=>({...r}));for(let r of e){let i=n.find(o=>o.room_id===r.room_id&&o.edge===r.edge&&(Math.abs(o.t1-r.t0)<1e-6||Math.abs(r.t1-o.t0)<1e-6));i?(i.t0=Math.min(i.t0,r.t0),i.t1=Math.max(i.t1,r.t1)):n.push({...r})}return n}function Hy(t,e,n){if(t.a===e.b)return!1;let r=ot(G(n[t.b],n[t.a])),i=ot(G(n[e.b],n[e.a]));return Math.abs(Ee(r,i))>1e-6||te(r,i)<=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 Jd(t,e,n=new Set){let r=t.slice();for(;;){let i=new Map;r.forEach((s,a)=>{for(let l of[s.a,s.b])i.set(l,[...i.get(l)??[],a])});let o=null;for(let[s,a]of i){if(a.length!==2||n.has(s))continue;let l=r[a[0]].b===s?r[a[0]]:Xd(r[a[0]]),c=r[a[1]].a===s?r[a[1]]:Xd(r[a[1]]);if(!Hy(l,c,e))continue;let u={...l,b:c.b,sources:Oy(l.sources,c.sources)};o=[...r.filter((d,p)=>p!==a[0]&&p!==a[1]),u];break}if(!o)return r;r=o}}function Qd(t,e){let n=new Map;t.forEach((i,o)=>{let s=ot(G(e[i.b],e[i.a])),a=[[i.a,{key:`${o}:a`,d:s,left:i.left,right:i.right,angle:Math.atan2(s[1],s[0])}],[i.b,{key:`${o}:b`,d:it(s,-1),left:i.right,right:i.left,angle:Math.atan2(-s[1],-s[0])}]];for(let[l,c]of a)n.set(l,[...n.get(l)??[],c])});let r=new Map;for(let[i,o]of n){let s=e[i];o.sort((l,c)=>l.angle-c.angle);for(let l of o)r.set(l.key,{left:ft(s,it(_a(l.d),l.left)),right:ft(s,it(ba(l.d),l.right))});if(o.length<2)continue;let a=4*Math.max(...o.map(l=>Math.max(l.left,l.right)))+1e-9;o.forEach((l,c)=>{let u=o[(c+1)%o.length],d=ft(s,it(_a(l.d),l.left)),p=ft(s,it(ba(u.d),u.right)),h=Ee(l.d,u.d);if(Math.abs(h)<1e-4)return;let f=ft(d,it(l.d,Ee(G(p,d),u.d)/h));ge(G(f,s))>a||(r.get(l.key).left=f,r.get(u.key).right=f)})}return r}function eh(t,e){let n=t.filter((r,i)=>ge(G(r,t[(i+1)%t.length]))>e);for(;;){if(n.length<=3)return n;let r=n.findIndex((i,o)=>{let s=n[(o+n.length-1)%n.length],a=n[(o+1)%n.length],[l,c]=[G(i,s),G(a,i)];return Math.abs(Ee(ot(l),ot(c)))<1e-7&&te(l,c)>0});if(r===-1)return n;n=n.filter((i,o)=>o!==r)}}function Ly(t){let e=[];return{points:e,idOf(n){let r=e.findIndex(i=>Math.abs(i[0]-n[0])<=t&&Math.abs(i[1]-n[1])<=t);return r>=0?r:(e.push([n[0],n[1]]),e.length-1)}}}function Cy(t,e){let n=[];for(let r of t){let i=r.points;if(i.length<3||Math.abs(_e(i))<1e-6)continue;let o=_e(i)>0,s=i.map(a=>e.idOf(a));s.forEach((a,l)=>{let c=s[(l+1)%s.length];a!==c&&n.push(o?{u:a,v:c,room:r.id,edge:l,forward:!0}:{u:c,v:a,room:r.id,edge:l,forward:!1})})}return n}function Ny(t,e,n){let r=[];for(let i of t){let[o,s]=[e[i.u],e[i.v]],a=G(s,o),l=ge(a),c=it(a,1/l),u=e.map((p,h)=>({id:h,rel:G(p,o)})).filter(({id:p,rel:h})=>p!==i.u&&p!==i.v&&te(h,c)>n&&te(h,c)({t:te(h,c),id:p})).sort((p,h)=>p.t-h.t),d=[{t:0,id:i.u},...u,{t:l,id:i.v}];for(let p=0;p+1({room_id:t.room,edge:t.edge,t0:t.t0,t1:t.t1});function By(t,e){let n=new Map(t.map(a=>[a.id,a])),r=new Map;for(let a of e){let l=`${a.room}:${a.edge}`;r.set(l,[...r.get(l)??[],a.t0].sort((c,u)=>c-u))}let i=a=>{let l=n.get(a.room)?.wall_heights?.[a.edge];return Array.isArray(l)?l[(r.get(`${a.room}:${a.edge}`)??[]).indexOf(a.t0)]??null:l},o=a=>{let l=n.get(a.room),[c,u]=[l?.wall_heights?.[a.edge],l?.wall_slopes?.[a.edge]];if(!l||typeof c!="number"||typeof u!="number"||c<=0||u<=0)return null;let[d,p]=[l.points[a.edge],l.points[(a.edge+1)%l.points.length]];return{from:c,to:u,length:Math.hypot(p[0]-d[0],p[1]-d[1])}},s=a=>{let l=o(a);if(!l||l.length<1e-9){let u=i(a);return typeof u=="number"&&u>0?[u,u]:[null,null]}let c=u=>l.from+(l.to-l.from)*u/l.length;return a.forward?[c(a.t0),c(a.t1)]:[c(a.t1),c(a.t0)]};return{heightsOf(a){let[l,c]=[1/0,1/0];for(let d of a){let[p,h]=s(d),[f,g]=d===a[0]?[p,h]:[h,p];f!==null&&(l=Math.min(l,f)),g!==null&&(c=Math.min(c,g))}let u=a.map(d=>n.get(d.room)?.ceiling);if(u.every(d=>typeof d=="number"&&d>0)){let d=Math.max(...u);l===1/0&&(l=d),c===1/0&&(c=d)}return{...l<1/0?{a:l}:{},...c<1/0?{b:c}:{}}},thicknessOf(a){let l=a.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 l.length?Math.max(...l):void 0},hasNoWall:a=>a.some(l=>i(l)===0)}}function nh(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 Vy(t,e,n,r){let i=By(e,t),o=new Map;for(let l of t){let c=l.up!==c&&p.u===c.v&&p.v===c.u&&p.room!==c.room);for(let p of l)p!==c&&p!==u&&p.room!==c.room&&r.push(`overlap:${c.room}:${p.room}`);let d=u?[c,u]:[c];if(i.hasNoWall(d)){u&&a.push([c.room,u.room]);continue}if(u){let p=i.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(th),...nh(i.heightsOf(d))})}else s.push({a:c.u,b:c.v,left:0,right:i.thicknessOf(d)??n.exterior,exterior:!0,roomLeft:c.room,roomRight:null,sources:[th(c)],...nh(i.heightsOf(d))})}return{drafts:s,open:a}}function Wy(t,e){let n=o=>ot(G(e[o.b],e[o.a])),r=t.filter(o=>!o.exterior&&!o.free),i=new Map;for(let o of r){if(i.has(o))continue;let s=[o];i.set(o,s);for(let a=0;a1e-6||l.add(te(s,h)>0?"left":"right")}if(l.size!==1)continue;let c=[...l][0];for(let u of o){let d=u.left+u.right,p=te(n(u),s)>0,h=c==="left"===p;[u.left,u.right]=h?[0,d]:[d,0]}}}var Ky=(t,e)=>{let n=o=>Math.round(o*100),[r,i]=t[0]Math.hypot(y.b[0]-y.a[0],y.b[1]-y.a[1])>.05),l=a.map(y=>[o.idOf(y.a),o.idOf(y.b)]),c=new Set;for(let y of t){let v=y.points;v.length<3||(y.wall_splits??[]).forEach((w,x)=>{if(!w||x>=v.length)return;let k=v[x],M=G(v[(x+1)%v.length],k),A=ge(M);for(let T of w)T>r&&T{let[w,x]=l[v];if(w===x)return;let k=[(y.a[0]+y.b[0])/2,(y.a[1]+y.b[1])/2],M=t.find(T=>T.points.length>=3&&C(k,T.points))?.id??null,A=(y.thickness??e.interior)/2;h.push({free:y.id,a:w,b:x,left:A,right:A,exterior:!1,roomLeft:M,roomRight:M,sources:[],height:typeof y.height=="number"&&y.height>0?y.height:void 0,...typeof y.height=="number"&&y.height>0&&typeof y.height_end=="number"&&y.height_end>0&&Math.abs(y.height_end-y.height)>1e-6?{heightEnd:y.height_end}:{}})});let f=Jd(h,o.points,c),g=Qd(f,o.points);return{walls:f.map((y,v)=>{let[w,x]=[o.points[y.a],o.points[y.b]],[k,M]=[g.get(`${v}:a`),g.get(`${v}:b`)],A=eh([k.right,M.left,x,M.right,k.left,w],1e-6);return{id:Ky(w,x),a:[w[0],w[1]],b:[x[0],x[1]],left:y.left,right:y.right,exterior:y.exterior,roomLeft:y.roomLeft,roomRight:y.roomRight,sources:y.sources,footprint:A,...y.free?{free:y.free}:{},...y.height!==void 0?{height:y.height}:{},...y.heightEnd!==void 0?{heightEnd:y.heightEnd}:{}}}),warnings:[...new Set(i)],open:p}}function Kn(t,e,n){let r=t.points[e];return ft(r,it(ot(G(t.points[(e+1)%t.points.length],r)),n))}function Ne(t,e,n){if(t.wall){let i=n.find(a=>a.id===t.wall);if(!i||Math.hypot(i.b[0]-i.a[0],i.b[1]-i.a[1])<.05)return null;let o=ot(G(i.b,i.a));return{room:{id:t.room_id,name:"",area_id:null,points:[i.a,i.b,ft(i.a,[-o[1],o[0]])]},edge:0}}let r=e.find(i=>i.id===t.room_id);return r&&t.edgete(G(e,t.a),ot(G(t.b,t.a)));function Kt(t,e,n){if(!e.wall)return jy(t,n.room,n.edge,e.offset);let r=t.find(i=>i.free===e.wall);return r?{wall:r,s:rh(r,Kn(n.room,0,e.offset))}:null}function jy(t,e,n,r){for(let i of t)if(i.sources.some(s=>s.room_id===e.id&&s.edge===n&&r>=s.t0-1e-6&&r<=s.t1+1e-6))return{wall:i,s:rh(i,Kn(e,n,r))};return null}function ih(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[i,o,s,a]=[Math.min(...n),Math.max(...n),Math.min(...r),Math.max(...r)],l=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=o-i-l(h=>u(h,0,i))-l(h=>u(h,0,o)),p=a-s-l(h=>u(h,1,s))-l(h=>u(h,1,a));return[Math.round(d*1e3)/1e3,Math.round(p*1e3)/1e3]}var oh=([t,e])=>{let n=Math.hypot(t,e)||1;return[t/n,e/n]};function Gy(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 sh(t,e){let n=t.length;if(n<3||Math.abs(e)<1e-9)return t.map(([i,o])=>[i,o]);let r=Gy(t)>=0?1:-1;return t.map((i,o)=>{let s=t[(o+n-1)%n],a=t[(o+1)%n],[l,c]=oh([i[0]-s[0],i[1]-s[1]]),[u,d]=oh([a[0]-i[0],a[1]-i[1]]),p=[c*r,-l*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[i[0]+p[0]*e,i[1]+p[1]*e];let b=(f[0]*p[0]+f[1]*p[1])/g,y=Math.min(4,1/Math.max(.25,b));return[i[0]+f[0]/g*e*y,i[1]+f[1]/g*e*y]})}function jt(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 Uy(t){let e=([o,s])=>`${Math.round(o*1e3)}:${Math.round(s*1e3)}`,n=new Map;for(let o of t)for(let s of[o.a,o.b])n.set(e(s),[...n.get(e(s))??[],o]);let r=new Set,i=null;for(let o of t){if(r.has(o))continue;r.add(o);let s=[o.a,o.b],a=o.b;for(;;){let c=(n.get(e(a))??[]).find(u=>!r.has(u));if(!c||(r.add(c),a=e(c.a)===e(a)?c.b:c.a,e(a)===e(s[0])))break;s.push(a)}s.length>=3&&e(a)===e(s[0])&&(!i||Math.abs(xe(s))>Math.abs(xe(i)))&&(i=s)}return i}function xa(t,e,n,r){let i=fe(t,{exterior:n,interior:r},e).walls.filter(a=>a.exterior&&!a.free),o=i.length?Uy(i.map(a=>({a:a.a,b:a.b}))):null;if(!o)return null;let s=o.filter((a,l)=>{let c=o[(l+o.length-1)%o.length],u=o[(l+1)%o.length];return Math.abs((a[0]-c[0])*(u[1]-a[1])-(a[1]-c[1])*(u[0]-a[0]))>1e-6});return s.length>=3?sh(s,n):null}function hn(t,e){let n=$e(t),r=Ce(t),i=n.w,[o,s]=[Math.max(0,e.a),Math.max(0,e.b)],a=n.u0-Math.max(0,e.u0),l=n.u1+Math.max(0,e.u1),c=(y,v)=>[y,v,r.y(v)],u=c(a,-o),d=c(l,-o),p=c(l,i+s),h=c(a,i+s),[f,g]=[st(t.pitch_a),st(t.pitch_b)],b=y=>[y,r.vr,r.rh];if(t.ends&&(t.shape==="gable"||t.shape==="hip"||t.shape==="halfhip")){let y=(n.u1-n.u0)/2,v=Math.min(y,Math.min(r.vr,i-r.vr)||i/2),w=Math.min(r.y(0),r.y(i)),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,i-(x-t.eave_b)/g):r.vr,A=Math.min(y-.1,(r.rh-x)/Math.max(.2,f)),T=[[0,r.y(0)],[r.vr,r.rh],[i,r.y(i)]],F=[[0,r.y(0)],[k,x],[M,x],[i,r.y(i)]],L=(j,Jt,Oi)=>{if(j==="hip")return{upA:[],upB:[],ridge:b(Jt===a?n.u0+v*Oi:n.u1-v*Oi),profile:null};if(j==="halfhip"){let $b=b(Jt===a?n.u0+A:n.u1-A);return{upA:[[Jt,k,x]],upB:[[Jt,M,x]],ridge:$b,profile:F}}return{upA:[],upB:[],ridge:b(Jt),profile:T}},D=L(t.ends[0],a,1),N=L(t.ends[1],l,1),V=[[u,d,...N.upA,N.ridge,D.ridge,...[...D.upA].reverse()],[D.ridge,N.ridge,...[...N.upB].reverse(),p,h,...D.upB]],Y=[[D.ridge,N.ridge]];for(let[j,Jt,Oi]of[[D,u,h],[N,d,p]])j.profile===null?(V.push(j===D?[h,u,j.ridge]:[d,p,j.ridge]),Y.push([Jt,j.ridge],[Oi,j.ridge])):j.upA.length&&(V.push(j===D?[j.upB[0],j.upA[0],j.ridge]:[j.upA[0],j.upB[0],j.ridge]),Y.push([j.upA[0],j.ridge],[j.upB[0],j.ridge]));let ke=j=>j.profile===null?[]:j.upA.length?[j.upA[0],j.upB[0]]:[j.ridge],Ft=[u,d,...ke(N),p,h,...[...ke(D)].reverse()];return{faces:V,rim:Ft,ridges:Y,gable:T,endProfiles:[D.profile,N.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)],[i,r.y(i)]]};case"hip":case"pyramid":{let y=(n.u1-n.u0)/2,v=t.shape==="pyramid"?y:Math.min(y,Math.min(r.vr,i-r.vr)||i/2),w=b(n.u0+v),x=b(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 y=Math.min(r.y(0),r.y(i)),v=y+(r.rh-y)*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,i-(v-t.eave_b)/g):r.vr,k=Math.min((n.u1-n.u0)/2-.1,(r.rh-v)/Math.max(.2,f)),M=b(n.u0+k),A=b(n.u1-k),T=[a,w,v],F=[a,x,v],L=[l,w,v],D=[l,x,v];return{faces:[[u,d,L,A,M,T],[M,A,D,p,h,F],[F,T,M],[L,D,A]],rim:[u,d,L,D,p,h,F,T],ridges:[[M,A],[T,M],[F,M],[L,A],[D,A]],gable:[[0,r.y(0)],[w,v],[x,v],[i,r.y(i)]]}}case"mansard":{let y=Vr(i,t.eave_a,t.eave_b,f,g),v=[a,y.vla,y.yla],w=[l,y.vla,y.yla],x=[a,i-y.vlb,y.ylb],k=[l,i-y.vlb,y.ylb],M=[a,y.vr,y.rh],A=[l,y.vr,y.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)],[y.vla,y.yla],[y.vr,y.rh],[i-y.vlb,y.ylb],[i,r.y(i)]]}}default:{let y=b(a),v=b(l);return{faces:[[u,d,v,y],[y,v,p,h]],rim:[u,d,v,p,h,y],ridges:[[y,v]],gable:[[0,r.y(0)],[r.vr,r.rh],[i,r.y(i)]]}}}}function Wr(t,e,n){let r=null;for(let i of t.faces){if(!C([e,n],i.map(([p,h])=>[p,h])))continue;let[o,s]=i,a=i.slice(2).find(p=>Math.abs((s[0]-o[0])*(p[1]-o[1])-(s[1]-o[1])*(p[0]-o[0]))>1e-9);if(!a)continue;let l=[s[0]-o[0],s[2]-o[2],s[1]-o[1]],c=[a[0]-o[0],a[2]-o[2],a[1]-o[1]],u=[l[1]*c[2]-l[2]*c[1],l[2]*c[0]-l[0]*c[2],l[0]*c[1]-l[1]*c[0]];if(Math.abs(u[1])<1e-9)continue;let d=o[2]-(u[0]*(e-o[0])+u[2]*(n-o[1]))/u[1];r=r===null?d:Math.min(r,d)}return r}function Kr(t,e,n){let r=$e(e),i=t.floors.flatMap(d=>d.rooms.filter(p=>p.points.length>=3&&d.elevation+d.height>e.base+.05)),o=d=>d.some(p=>i.some(h=>C(p,h.points))),s=.35,a=[.15,.5,.85].map(d=>r.u0+(r.u1-r.u0)*d),l=[.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(o(a.map(d=>r.at(d,-s))))),b:u("b",c(o(a.map(d=>r.at(d,r.w+s))))),u0:u("u0",c(o(l.map(d=>r.at(r.u0-s,d))))),u1:u("u1",c(o(l.map(d=>r.at(r.u1+s,d)))))}}var ko=t=>Math.abs((t.x1-t.x0)*(t.z1-t.z0)),ah=t=>t.shape==="flat"||t.shape==="parapet",pn=t=>Math.round(t*100)/100;function xo(t,e){let[n,r]=[(e.x0+e.x1)/2,(e.z0+e.z1)/2];return t.filter(o=>{if(o===e||o.dormer||o.open||ah(o)||ko(o)=s.x0&&n<=s.x1&&r>=s.z0&&r<=s.z1}).reduce((o,s)=>o===null||ko(s){let[o,s]=e.at(i,e.w/2),[a,l]=Br(t,o,s);return Wr(n,a,l)??r.y(l)}}function Sa(t,e){if(ah(e))return e;let n=$e(e),r=Ce(e).rh,i=qy(t,n),o=i(n.u0)<=i(n.u1),[s,a]=o?[n.u0,n.u1]:[n.u1,n.u0],l=o?1:-1,c=a;for(let p=.5;p=r-.02){c=s+l*p;break}if(Math.abs(c-a)<.05)return e;let u={...e},d=a===n.u1;return e.axis==="x"?u[d?"x1":"x0"]=c:u[d?"z1":"z0"]=c,u}var Ma=.14,lh=t=>t.shape==="flat"||t.shape==="parapet";function Ra(t,e){return!t.open&&Math.min(t.base,t.eave_a,t.eave_b)l+i||pu+i||s.points&&s.points.length>=3&&!C([e,n],s.points))continue;let[h,f]=Br(s,e,n),g=Math.max(0,s.overhang??r),b=lh(s)?null:Wr(hn(s,{u0:g,u1:g,a:g,b:g}),h,f);o.push((b??Ce(s).y(f))-Ma)}return o.length?Math.max(...o):null}function Ea(t,e,n){let r=[],i=e+n+Ma;for(let o of t.settings.roof.sections??[]){if(o.open||lh(o)||o.shape==="mansard")continue;let s=$e(o),a=Ce(o),[l,c]=[st(o.pitch_a),st(o.pitch_b)],u=[];l>1e-6&&u.push((i-o.eave_a)/l),o.shape==="gable"&&c>1e-6&&u.push(s.w-(i-o.eave_b)/c);for(let d of u)d<=.01||d>=s.w-.01||o.shape==="gable"&&Math.abs(a.y(d)-i)>1e-6||r.push([s.at(s.u0,d),s.at(s.u1,d)])}return r}function Aa(t,e,n,r,i){let o=[];for(let a of[.2,.5,.8])for(let l of[.2,.5,.8])o.push([e+(r-e)*a,n+(i-n)*l]);let s=t.floors.filter(a=>a.rooms.some(l=>l.points.length>=3&&o.some(c=>C(c,l.points)))).map(a=>a.elevation+a.height);return s.length?Math.max(...s):null}function Fa(t,e){let n=t.floors.filter(l=>l.rooms.length>0).sort((l,c)=>l.elevation-c.elevation),r=n.filter(l=>l.elevationu.rooms.some(d=>d.points.length>=3&&l.some(p=>C(p,d.points))));if(c)return c}return r.at(-1)??n[0]}var xt=t=>Math.round(t*1e3)/1e3;function Ta(t,e=n=>`roof_${n+1}`){let n=t.settings.roof?.pitch??35,r=t.settings.wall_exterior,i=t.floors.filter(l=>l.rooms.some(c=>c.points.length>=3)).sort((l,c)=>c.elevation-l.elevation),o=[],s=[],a=(l,c)=>l.some(u=>C(c,u.points));for(let l of i){let c=l.rooms.filter(b=>b.points.length>=3),u=[...new Set(c.flatMap(b=>b.points.map(y=>xt(y[0]))))].sort((b,y)=>b-y),d=[...new Set(c.flatMap(b=>b.points.map(y=>xt(y[1]))))].sort((b,y)=>b-y),p=d.slice(0,-1).map((b,y)=>u.slice(0,-1).map((v,w)=>{let x=[(u[w]+u[w+1])/2,(d[y]+d[y+1])/2];return a(c,x)&&!a(s,x)})),h=p.map(b=>b.map(()=>!1)),f=(b,y)=>p[y][b]&&!h[y][b],g=l.elevation+l.height;for(let b=0;bf(y+F,w+1)).every(Boolean);)w++;for(let T=b;T<=w;T++)for(let F=y;F<=v;F++)h[T][F]=!0;let[x,k]=[u[y]-r,u[v+1]+r],[M,A]=[d[b]-r,d[w+1]+r];Math.min(k-x,A-M)<.8||o.push({id:e(o.length),x0:xt(x),z0:xt(M),x1:xt(k),z1:xt(A),shape:"gable",axis:k-x>=A-M?"x":"z",eave_a:xt(g),eave_b:xt(g),pitch_a:n,pitch_b:n,base:xt(g),overhang:null})}s.push(...c)}return o}var Ae=Math.PI/180,Ue=(t,e)=>[t[0]-e[0],t[1]-e[1],t[2]-e[2]],fn=(t,e)=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2],jn=t=>Math.hypot(t[0],t[1],t[2]),mn=t=>{let e=jn(t)||1;return[t[0]/e,t[1]/e,t[2]/e]},ch=(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]],Ze=t=>Math.round(t*100)/100,Gr=([t,e],n)=>(Math.atan2(t,-e)/Ae-n+720)%360;var dh=.25;function hh(t,e,n,r,i,o,s){let a=i-n>=o-r,l=a?i-n:o-r;return{key:`${t}:top`,section:e,side:"top",flat:!0,o:[n,s,r],eu:a?[1,0,0]:[0,0,1],es:a?[0,0,1]:[1,0,0],n:[0,1,0],lu:l,ls:a?o-r:i-n,pitch:0,span:()=>[0,l],facing:a?[0,1]:[1,0]}}function ph(t,e){let n=mn(ch(t,e));return n[1]<0?[-n[0],-n[1],-n[2]]:n}var fh=t=>{let e=mn([-t[0],0,-t[2]]);return[e[0],e[2]]};function $t(t,e,n,r,i,o,s,a){let l=mn(Ue(i,r)),c=mn(Ue(o,r));return{key:t,section:e,side:n,flat:!1,o:r,eu:l,es:c,n:ph(l,c),lu:jn(Ue(i,r)),ls:jn(Ue(o,r)),pitch:s,span:a,facing:fh(c)}}function uh(t,e,n,r,i,o){let s=jn(Ue(i,r));if(s<.3)return null;let a=mn(Ue(i,r)),l=Ue(o,r),c=l[0]*a[0]+l[1]*a[1]+l[2]*a[2],u=[l[0]-a[0]*c,l[1]-a[1]*c,l[2]-a[2]*c],d=jn(u);if(d<.3)return null;let p=mn(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:a,es:p,n:ph(a,p),lu:s,ls:d,pitch:Math.atan2(p[1],Math.hypot(p[0],p[2]))/Ae,span:h,facing:fh(p)}}function Yy(t,e){let n=$e(t),r=Ce(t),i=(v,w,x)=>{let[k,M]=n.at(v,w);return[k,x,M]},[o,s]=[Math.max(0,e.a),Math.max(0,e.b)],a=n.u0-Math.max(0,e.u0),l=n.u1+Math.max(0,e.u1),c=l-a,u=r.y(-o),d=r.y(n.w+s);if(t.shape==="flat"||t.shape==="parapet"){let[v,w]=[n.at(a,-o),n.at(l,n.w+s)];return[hh(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+dh)]}if(t.shape==="pent")return[$t(`${t.id}:a`,t.id,"a",i(a,-o,u),i(l,-o,u),i(a,n.w+s,d),t.pitch_a,()=>[0,c])];if(t.shape==="mansard")return Xy(t,n,a,l,o,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-a:0,b=p?l-(n.u1-f):0,y=[];if(r.vr>.3){let v=Math.hypot(r.vr+o,r.rh-u);y.push($t(`${t.id}:a`,t.id,"a",i(a,-o,u),i(l,-o,u),i(a,r.vr,r.rh),t.pitch_a,w=>[g*(w/v),c-b*(w/v)]))}if(n.w-r.vr>.3){let v=Math.hypot(n.w+s-r.vr,r.rh-d);y.push($t(`${t.id}:b`,t.id,"b",i(l,n.w+s,d),i(a,n.w+s,d),i(l,r.vr,r.rh),t.pitch_b,w=>[b*(w/v),c-g*(w/v)]))}if(p){let v=uh(`${t.id}:c`,t.id,"c",i(a,n.w+s,d),i(a,-o,u),i(n.u0+f,r.vr,r.rh)),w=uh(`${t.id}:d`,t.id,"d",i(l,-o,u),i(l,n.w+s,d),i(n.u1-f,r.vr,r.rh));y.push(...[v,w].filter(x=>x!==null))}return y}function Xy(t,e,n,r,i,o){let s=Vr(e.w,t.eave_a,t.eave_b,st(t.pitch_a),st(t.pitch_b)),a=(f,g)=>{let[b,y]=e.at(f,g);return[b,s.y(g),y]},l=r-n,c=()=>[0,l],u=(f,g)=>Math.atan2(f,g)/Ae,d=[],[p,h]=[e.w+o,e.w-s.vlb];return s.vla+i>.3&&d.push($t(`${t.id}:a`,t.id,"a",a(n,-i),a(r,-i),a(n,s.vla),t.pitch_a,c)),s.vr-s.vla>.3&&d.push($t(`${t.id}:au`,t.id,"a",a(n,s.vla),a(r,s.vla),a(n,s.vr),u(s.rh-s.yla,s.vr-s.vla),c)),s.vlb+o>.3&&d.push($t(`${t.id}:b`,t.id,"b",a(r,p),a(n,p),a(r,h),t.pitch_b,c)),h-s.vr>.3&&d.push($t(`${t.id}:bu`,t.id,"b",a(r,h),a(n,h),a(r,s.vr),u(s.rh-s.ylb,h-s.vr),c)),d}function za(t){return t.floors.filter(n=>n.rooms.some(r=>r.points.length>=3)).sort((n,r)=>r.elevation-n.elevation)[0]??null}function q(t){let e=t.settings.roof;if(!e||e.type==="none")return[];if(e.type==="custom")return(e.sections??[]).flatMap(w=>Yy(w,Kr(t,w,w.overhang??e.overhang)));let n=za(t);if(!n)return[];let r=n.rooms.flatMap(w=>w.points.map(x=>x[0])),i=n.rooms.flatMap(w=>w.points.map(x=>x[1])),o=t.settings.wall_exterior+e.overhang,[s,a]=[Math.min(...r)-o,Math.max(...r)+o],[l,c]=[Math.min(...i)-o,Math.max(...i)+o],u=n.elevation+n.height;if(e.type==="flat")return[hh("main",null,s,l,a,c,u+dh)];let d=a-s>=c-l,p=e.ridge==="short"?!d:d,h=(p?c-l:a-s)/2,f=h*Math.tan(e.pitch*Ae),g=(w,x,k)=>p?[w,u+k,(l+c)/2+x]:[(s+a)/2+x,u+k,w],[b,y]=p?[s,a]:[l,c],v=()=>[0,y-b];return[$t("main:a",null,"a",g(b,-h,0),g(y,-h,0),g(b,0,f),e.pitch,v),$t("main:b",null,"b",g(b,h,0),g(y,h,0),g(b,0,f),e.pitch,v)]}function qe(t,e){let n=[];for(let r of t.floors.filter(i=>!e||i.id===e)){let{walls:i}=fe(r.rooms,{exterior:t.settings.wall_exterior,interior:t.settings.wall_interior},r.walls??[]);for(let o of i){if(!o.exterior&&!o.free)continue;let[s,a]=[o.b[0]-o.a[0],o.b[1]-o.a[1]],l=Math.hypot(s,a);if(l<1.2)continue;let[c,u]=[a/l,-s/l],d=Math.min(r.height,o.height??r.height,o.heightEnd??1/0),p=(h,f,g,b)=>n.push({key:h,section:null,side:"top",flat:!1,o:f,eu:g,es:[0,1,0],n:b,lu:l,ls:d,pitch:90,span:()=>[0,l],facing:[b[0],b[2]],wall:{floorId:r.id}});p(`wall:${r.id}:${o.id}`,[o.a[0]+c*o.right,r.elevation,o.a[1]+u*o.right],[s/l,0,a/l],[c,0,u]),o.free&&p(`wall:${r.id}:${o.id}:back`,[o.b[0]-c*o.left,r.elevation,o.b[1]-u*o.left],[-s/l,0,-a/l],[-c,0,-u])}}return n}var Be="ground";function $o(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 So(t,e){let n=(e.rotation??0)*Ae,r=[Math.cos(n),0,Math.sin(n)],i=[-Math.sin(n),0,Math.cos(n)],o=$o(t),s=r[0]*e.u+i[0]*e.v,a=r[2]*e.u+i[2]*e.v,l=o?o.elevation+(e.base!=null?e.base:nu(o,s,a)):e.base??0;return{key:Be,section:null,side:"top",flat:!0,o:[0,l,0],eu:r,es:i,n:[0,1,0],lu:1e4,ls:1e4,pitch:0,span:()=>[-1e4,1e4],facing:[i[0],i[2]],unbounded:!0}}function Se(t,e,n=q(t)){return e.face===Be?So(t,e):e.face.startsWith("wall:")?qe(t,e.face.split(":")[1]).find(r=>r.key===e.face)??null:n.find(r=>r.key===e.face)??null}var Mo=1.13,Zr=1.72,Ye=.025,at=.07;function gn(t){let e=t.module_w||Mo,n=t.module_h||Zr;return t.portrait===!1?[n,e]:[e,n]}function qr(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 Pa(t,e){return t.flat?Math.min(45,Math.max(0,e.tilt??15))*Ae:t.wall?Math.min(90,Math.max(0,e.tilt??0))*Ae:Math.min(45,Math.max(0,e.tilt??0))*Ae}function Yr(t,e){let[,n]=gn(e),r=Pa(t,e);return t.wall?n*Math.cos(r)+Ye:!t.flat&&r<.001?n+Ye:t.flat&&e.rack==="ew"?n*Math.cos(r)+.08:n*Math.cos(r)+Math.max(.3,2*n*Math.sin(r))}function Gn(t,e){let[n,r]=gn(e),i=qr(e),o=Math.max(1,...i);return[o*n+(o-1)*Ye,(i.length-1)*Yr(t,e)+r*Math.cos(Pa(t,e))]}var Jy=t=>t.flat&&!t.unbounded&&!t.wall;function mh(t,e){if(!Jy(t)||!e.rotation)return null;let n=e.rotation*Ae,[r,i]=Gn(t,e);return{cos:Math.cos(n),sin:Math.sin(n),u:e.u+r/2,s:e.v+i/2}}function Xe(t,e,n=!1){let[r,i]=gn(e),o=Pa(t,e),s=i*Math.cos(o),a=Yr(t,e),l=qr(e),c=Math.max(1,...l),u=new Set(e.skip??[]),d=mh(t,e),p=(b,y)=>d?[d.u+(b-d.u)*d.cos-(y-d.s)*d.sin,d.s+(b-d.u)*d.sin+(y-d.s)*d.cos]:[b,y],h=(b,y,v)=>{let[w,x]=p(b,y);return[0,1,2].map(k=>t.o[k]+t.eu[k]*w+t.es[k]*x+t.n[k]*v)},f=(b,y)=>{let[v,w]=p(b,y);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 l.forEach((b,y)=>{let v=e.align==="right"?c-b:e.align==="center"?(c-b)/2:0;for(let w=0;w.001?s:i);if([[M,T],[A,T],[A,F],[M,F]].every(([L,D])=>f(L,D)))if(t.wall&&o>.001){let L=at+i*Math.sin(o),[D,N]=e.flip?[L,at]:[at,L],V=[h(M,T,D),h(A,T,D),h(A,F,N),h(M,F,N)],Y=e.flip?T:F;g.push({corners:V,posts:[M+.05,A-.05].map(ke=>[h(ke,Y,0),h(ke,Y,L)]),cell:x,skipped:k})}else if(!t.flat&&o>.001){let L=at+i*Math.sin(o),D=[h(M,T,at),h(A,T,at),h(A,F,L),h(M,F,L)];g.push({corners:D,posts:[M+.05,A-.05].map(N=>[h(N,F,0),h(N,F,L)]),cell:x,skipped:k})}else if(!t.flat)g.push({corners:[h(M,T,at),h(A,T,at),h(A,F,at),h(M,F,at)],posts:[],cell:x,skipped:k});else{let D=.15+i*Math.sin(o),N=e.rack==="ew"&&y%2===1?!e.flip:!!e.flip,[V,Y]=N?[F,T]:[T,F],ke=[h(M,V,.15),h(A,V,.15),h(A,Y,D),h(M,Y,D)],Ft=[M+.05,A-.05].flatMap(j=>[[h(j,V,0),h(j,V,.15)],[h(j,Y,0),h(j,Y,D)]]);g.push({corners:ke,posts:Ft,cell:x,skipped:k})}}}),g}function mt(t,e){if(t.unbounded)return{u:e.u,v:e.v};let[n,r]=Gn(t,e),i=mh(t,e);if(i){let[s,a]=[(n*Math.abs(i.cos)+r*Math.abs(i.sin))/2,(n*Math.abs(i.sin)+r*Math.abs(i.cos))/2],l=(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((l(c,s,t.lu)-n/2)*100)/100,v:Math.round((l(u,a,t.ls)-r/2)*100)/100}}let o=s=>Math.floor(s*100+1e-6)/100;return{u:o(Math.min(Math.max(0,e.u),Math.max(0,t.lu-n))),v:o(Math.min(Math.max(0,e.v),Math.max(0,t.ls-r)))}}function Xr(t,e){let[n,r]=Gn(t,e),[i,o]=[e.u+n/2,e.v+r/2];return[t.o[0]+t.eu[0]*i+t.es[0]*o,t.o[2]+t.eu[2]*i+t.es[2]*o]}var Ro=.78,Jr=1.18,_n=t=>({id:t.id,face:t.face,u:t.u,v:t.v,rows:1,cols:1,portrait:!0,module_w:t.w||Ro,module_h:t.h||Jr});function Da(t,e){let n=Xe(t,_n(e))[0];if(!n)return null;let r=i=>[i[0]-t.n[0]*.05,i[1]-t.n[1]*.05,i[2]-t.n[2]*.05];return n.corners.map(r)}var Ur={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 bn(t){let e=t.shape??"brick",n=Ur[e]??Ur.brick;return{shape:e,w:t.w||n.w,d:t.d||n.d,h:t.h||n.h}}function St(t,e){let{w:n,d:r}=bn(t),i=e&&!e.flat?Math.cos(e.pitch*Ae):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,i),tilt:0}}function Ia(t,e){let n=St(e,t),[r,i]=[n.module_w,n.module_h],o=(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,a]=[o(e.u+r/2,e.v),o(e.u+r/2,e.v+i)],l=o(e.u+r/2,e.v+i/2),c=u=>{let d=Math.hypot(u[0],u[2])||1;return[u[0]/d,u[2]/d]};return{center:[l[0],l[2]],along:c(t.eu),across:c(t.es),low:Math.min(s[1],a[1]),high:Math.max(s[1],a[1])}}function Oa(t,e){let[n]=gn(e);return Ze((t.lu-(e.cols*n+(e.cols-1)*Ye))/2)}var Qr=.4;function Un(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]=gn(n),[i,o]=t.span(t.ls/2);for(n.cols=Math.max(1,Math.floor((o-i-2*Qr+Ye)/(r+Ye))),n.rows=Math.max(1,Math.min(4,Math.floor((t.ls-2*Qr)/Yr(t,n))));n.cols>1&&Xe(t,{...n,u:Oa(t,n),v:Qr}).lengtha.lu*(1.3+Math.cos((Gr(a.facing,r)-180)*Math.PI/180)),o=qe(t,n).sort((a,l)=>i(l)-i(a))[0];if(!o)return null;let s={...Un(o,e),portrait:!1,rows:1};return s.cols=Math.max(1,Math.floor((o.lu-.8+Ye)/(Zr+Ye))),s.u=Ze((o.lu-(s.cols*Zr+(s.cols-1)*Ye))/2),s.v=Ze(Math.max(0,o.ls-Mo-.3)),s}function ei(t,e){let n=t.floors.flatMap(o=>o.rooms.flatMap(s=>s.points)),r=n.length?Math.max(...n.map(o=>o[0]))+3:0,i=n.length?Math.min(...n.map(o=>o[1])):0;return{id:e,face:Be,u:Ze(r),v:Ze(i),rows:2,cols:4,portrait:!0,tilt:25,flip:!0,rotation:(t.settings.north??0)||0,look:"black",entity:null}}function ti(t,e,n){let r=So(t,e),[i,o]=Gn(r,e),[s,a]=[e.u+i/2,e.v+o/2],l=[r.eu[0]*s+r.es[0]*a,r.eu[2]*s+r.es[2]*a],c=n*Ae,u=l[0]*Math.cos(c)+l[1]*Math.sin(c)-i/2,d=l[0]*-Math.sin(c)+l[1]*Math.cos(c)-o/2;return{u:Ze(u),v:Ze(d),rotation:(Math.round(n)%360+360)%360}}function ni(t,e){let[n,r]=t.span(t.ls/2);return{id:e,face:t.key,u:Ze((n+r-Ro)/2),v:Ze(Math.max(0,Math.min(t.ls-Jr,t.ls*.45-Jr/2))),w:null,h:null,cover:null,contact:null,tilt:null}}function ri(t,e){let n=Ur.brick,[r,i]=t.span(t.ls*.8),o=St({id:e,face:t.key,u:0,v:0},t).module_h;return{id:e,face:t.key,u:Ze((r+i-n.w)/2),v:Ze(Math.max(0,Math.min(t.ls-o,t.ls*.8-o/2))),shape:"brick",w:null,d:null,h:null}}function Zn(t,e){let[n,r]=[e[0]-t.o[0],e[1]-t.o[2]],[i,o,s,a]=[t.eu[0],t.eu[2],t.es[0],t.es[2]],l=i*a-o*s;if(Math.abs(l)<1e-9)return null;let c=(n*a-r*s)/l,u=(i*r-o*n)/l;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 La(t,e){let n=null;for(let r of t){if(r.wall){let[s,a]=[e[0]-r.o[0],e[1]-r.o[2]],l=s*r.eu[0]+a*r.eu[2],c=s*r.n[0]+a*r.n[2],u=l>=0&&l<=r.lu;if(u&&c>=-.05&&c<=.35)return{face:r,u:l,s:Number.NaN};u&&c>.35&&c<=.8&&!n&&(n={face:r,u:l,s:Number.NaN,y:-1/0});continue}let i=Zn(r,e);if(!i)continue;let o=r.o[1]+r.es[1]*i.s;(!n||o>n.y)&&(n={face:r,...i,y:o})}return n&&{face:n.face,u:n.u,s:n.s}}function Ao(t,e,n){let r=fn(n,t.n);if(Math.abs(r)<1e-6)return null;let i=fn(Ue(t.o,e),t.n)/r;if(i<=0)return null;let o=Ue([e[0]+n[0]*i,e[1]+n[1]*i,e[2]+n[2]*i],t.o);return{t:i,u:fn(o,t.eu),s:fn(o,t.es)}}function Ca(t,e,n){if(t.unbounded)return!0;if(n<0||n>t.ls)return!1;let[r,i]=t.span(n);return e>=r&&e<=i}function Na(t,e,n,r){return Xe(t,e).some(o=>{let s=o.corners.map(c=>{let u=Ue(c,t.o);return[fn(u,t.eu),fn(u,t.es)]}),a=s.map(c=>c[0]),l=s.map(c=>c[1]);return n>=Math.min(...a)-.05&&n<=Math.max(...a)+.05&&r>=Math.min(...l)-.05&&r<=Math.max(...l)+.05})}var Qy=["n","ne","e","se","s","sw","w","nw"],Ba=(t,e)=>Qy[Math.round(Gr(t.facing,e)/45)%8];function ii(t,e){let n=r=>{if(r.flat)return r.lu*r.ls*.8;let i=Math.cos((Gr(r.facing,e)-180)*Math.PI/180);return r.lu*r.ls*(1.2+i)};return[...t].sort((r,i)=>n(i)-n(r))[0]??null}var yh=["kitchen_row","kitchen_l","bath","bedroom","living","dining","office","kids","hall"],gh={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]]}},_h=t=>typeof t=="string"?t:t[0],Fo=t=>typeof t=="string"?tt[t]:t[1],qn=.05,ev=.02,bh=t=>Math.round(t*1e3)/1e3;function tv(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 vh(t,e,n){let r=de(t.points),i=r.x1-r.x0,o=r.z1-r.z0,s=[],a=(l,c,u,d,[p,h,f])=>{s.push({id:n(),type:l,x:bh(c),z:bh(u),rotation:d,w:p,d:h,h:f,variant:null,entity:null,power:null})};for(let[l,c,u]of gh[e].rows){let d=l==="back"||l==="front"?i:o,p=0,h=[];for(let g of u){if(p+Fo(g)[0]>d-.1)break;h.push(g),p+=Fo(g)[0]}let f=c==="start"?qn:c==="end"?d-p-qn:(d-p)/2;for(let g of h){let b=Fo(g),y=tv(r,l,f+b[0]/2,b[1]/2+ev);a(_h(g),y.x,y.z,y.turn,b),f+=b[0]}}for(let[l,c,u,d]of gh[e].spots){let p=Fo(l),h=(b,y,v)=>Math.min(v,Math.max(y,b)),f=h(r.x0+i*c,r.x0+p[0]/2+qn,r.x1-p[0]/2-qn),g=h(r.z0+o*u,r.z0+p[1]/2+qn,r.z1-p[1]/2-qn);a(_h(l),f,g,d,p)}return s}var nv=30*Math.PI/180,wh=.05;function Va(t){let e=t.points.length;return t.points.map((n,r)=>{let i=t.points[(r+1)%e];return Math.hypot(i[0]-n[0],i[1]-n[1])})}function oi(t){return Va(t).reduce((e,n)=>e+n,0)}function rv(t,e){let n=Va(t),r=0;for(let i=0;ih+f,0);if(i<3||!(o>0)||!(n>0))return null;let s=Math.min(n,o),a=(e%o+o)%o,l=0,c=0;for(;l=c+r[l];)c+=r[l],l++;let u=a-c,d=s,p=[];for(let h=0;h<=i&&d>1e-9;h++){let f=r[l]-u,g=Math.min(d,f);g>1e-9&&p.push({edge:l,t0:u,t1:u+g}),d-=g,u=0;let b=(l+1)%i;if(d>1e-9&&iv(t,l)>nv)break;l=b}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 Yn(t,e){let n=e[0];return n?{from:rv(t,n.edge)+n.offset-n.width/2,width:e.reduce((r,i)=>r+i.width,0)}:null}function Gt(t,e){return e.front?t.filter(n=>n.front===e.front):[e]}function Ka(t,e){let n=t.points.length,r=1/0,i=0,o=0;for(let s=0;sP("opening")){let s=Wa(e,r,i);if(!s)return null;let a=Gt(t,n),l=new Set(a.map(h=>h.id)),c=s.length>1?a[0].front??`front-${a[0].id}`:null,u=s.map((h,f)=>({...n,id:f===0?a[0].id:o(),edge:h.edge,offset:h.offset,width:h.width,front:c})),d=[],p=!1;for(let h of t){if(!l.has(h.id)){d.push(h);continue}p||(d.push(...u),p=!0)}return d}var Ua=globalThis,ja=Ua.__nextfloorBuiltin?.de??{},Ga=Ua.__nextfloorBuiltin?.en??{};Ua.__nextfloorBuiltin??={de:ja,en:Ga};var ov=()=>typeof $=="object"&&$||{},sv=globalThis,av=sv.__nextfloorTexts??=new Map;function lv(t){let e=t.toLowerCase().split("-")[0];return e!=="de"&&e!=="en"&&e in ov()?e:void 0}function kh(t){let e=lv(t),n=e===void 0?void 0:av.get(e);return n instanceof Promise?void 0:n}function To(t,e){return kh(t)?.[e]}function we(t,e,n={}){let r=t?.language??navigator.language,i=r.startsWith("de"),o=(i?void 0:kh(r)?.[e])??(i?ja:Ga)[e]??Ga[e]??ja[e]??e;for(let[s,a]of Object.entries(n))o=o.replace(`{${s}}`,String(a));return o}function K(t,e,n=2){return e.toLocaleString(t?.language??void 0,{maximumFractionDigits:n})}var cv=new Set(["on","home","open","true","active","playing","heat","heating"]);function xh(t,e){let n=e.show_when;if(!n?.entity||!t)return!0;let r=t.states[n.entity];if(!r||He(r))return!0;let i=String(r.state).toLowerCase(),o=(n.state??"").split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),s=o.length?o.includes(i):cv.has(i)||Number.isFinite(Number(i))&&Number(i)>0;return n.invert?!s:s}function Fe(t,e){if(!yt(e))return we(t,`furn_${e}`);let n=U(e);return n?Je(n,e,t?.language??navigator.language):we(t,"pack_missing_item")}function Je(t,e,n){return t.name[n.split("-")[0]]??To(n,e)??Lc(t,n)}function Ve(t,e){return To(e,`packname:${t.id}`)??Cc(t,e)}function $h(t,e){return t.name[e.split("-")[0]]??To(e,`color:${t.id}`)??t.name.en??Object.values(t.name)[0]}var ai=t=>t&&t!=="none"?t:null,li=(t,e)=>{e&&!t.includes(e)&&t.push(e)},Za=t=>new Map(t.floors.flatMap(e=>e.furniture.filter(n=>n.type==="meter").map(n=>[n.id,n])));function yn(t,e){if(!t.energy.advanced||e.type!=="meter"||!e.parent_meter)return null;let n=Za(t),r=new Set([e.id]);for(let i=n.get(e.parent_meter);i;i=n.get(i.parent_meter??"")){if(r.has(i.id))return null;r.add(i.id)}return n.has(e.parent_meter)?e.parent_meter:null}function Xn(t){return new Set([...Za(t).values()].filter(e=>yn(t,e)).map(e=>e.id))}function ci(t,e){return!t.energy.advanced||!e.parent_meter?null:Xn(t).has(e.parent_meter)?e.parent_meter:null}function Sh(t,e,n){if(n.type!=="meter"||n.id===e.id)return!1;let r=Za(t),i=new Set;for(let o=n;o&&!i.has(o.id);o=r.get(o.parent_meter??"")){if(o.id===e.id)return!1;i.add(o.id)}return!0}function Po(t,e=n=>ai(n.power)){let n={grid:null,gridExport:null,solar:[],battery:[],charge:[],batteries:[],soc:[]};for(let r of t.floors.flatMap(i=>i.furniture)){let i=e(r),o=r.type==="meter"?yn(t,r):null;if(o)(n.subMeters??=[]).push({id:r.id,parent:o,power:i,invert:!!r.meter_invert,floors:r.meter_floors??[],solar:[],batteries:[]});else if(r.type==="meter")n.grid??=i,n.gridExport??=ai(r.export);else if(r.type==="inverter")li(n.solar,i);else if(r.type==="home_battery"){let s=ai(r.charge);li(n.battery,i),li(n.charge,s),li(n.soc,ai(r.soc)),(i||s)&&n.batteries.push({power:i,charge:s})}}for(let r of n.subMeters?t.floors.flatMap(i=>i.furniture):[]){let i=r.type==="inverter"||r.type==="home_battery"?n.subMeters?.find(a=>a.id===ci(t,r)):void 0,o=i?e(r):null;i&&r.type==="inverter"&&li(i.solar,o);let s=ai(r.charge);i&&r.type==="home_battery"&&(o||s)&&i.batteries.push({power:o,charge:s})}return n}function uv(t){for(let e of t.floors){let n=e.furniture.find(r=>r.type==="meter"&&!yn(t,r));if(n)return{floor_id:e.id,x:n.x,z:n.z}}return t.energy.meter}var dv=/(phase|_l[123]\b|_[abc]$|today|daily|heute)/,hv=/_?(energy|energie|total|today|daily|kwh|import|export|consumption|production)/g;function zo(t,e,n="power"){let r=e?t.entities?.[e]?.device_id:void 0;if(!e||!r)return null;let i=Object.keys(t.states).filter(a=>a.startsWith("sensor.")&&t.entities?.[a]?.device_id===r&&t.states[a]?.attributes.device_class===n);if(i.length<=1)return i[0]??null;let o=i.filter(a=>!dv.test(a)),s=e.replace(/^sensor\./,"").replace(hv,"");return o.find(a=>s&&a.includes(s))??o[0]??i[0]}function Mh(t,e){let n={},r=(i,o)=>{o&&!n[i]&&(n[i]=o)};for(let i of e.energy_sources??[])if(i.type==="grid")r("grid",zo(t,i.flow_from?.[0]?.stat_energy_from??i.flow_to?.[0]?.stat_energy_to));else if(i.type==="solar")r("solar",zo(t,i.stat_energy_from));else if(i.type==="battery"){let o=i.stat_energy_from??i.stat_energy_to;r("battery",zo(t,o)),r("battery_soc",zo(t,o,"battery"))}return n}function Te(t,e=!1){let n=t?.attributes.symcon_id?Lt(t):t?Number(t.state):null;if(n===null||!Number.isFinite(n))return null;let r={kW:1e3,MW:1e6}[String(t.attributes.unit_of_measurement??"W")]??1;return e?-n*r:n*r}var pv=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power";function ui(t,e){if(pv(t,e))return e;let n=t.entities?.[e]?.device_id;if(!n)return null;let r=ia(t,n),i=r?It(t,e):null,o=po(t,n).filter(s=>s!==e);return(r?o.find(s=>i!==null&&It(t,s)===i):o[0])??null}var Rh=t=>{let e=t.filter(n=>n!==null);return e.length?e.reduce((n,r)=>n+r,0):null};function fv(t,e,n){let r=e.grid??n.grid,i=r?Te(t.states[r],e.grid_invert):null;if(!e.grid&&n.gridExport){let o=Math.max(0,Te(t.states[n.gridExport])??0);return Math.max(0,i??0)-o}return i}function mv(t,e,n){return e.solar?Te(t.states[e.solar]):n.solar.length?Rh(n.solar.map(r=>Te(t.states[r]))):null}function qa(t,e,n){return e.charge?(e.power?Math.max(0,Te(t.states[e.power])??0):0)-Math.max(0,Te(t.states[e.charge])??0):e.power?Te(t.states[e.power],n):null}function gv(t,e,n){return e.battery?Te(t.states[e.battery],e.battery_invert):Rh(n.batteries.map(r=>qa(t,r,e.battery_invert)))}function Ya(t,e,n,r=Po(e)){let i=e.energy,o=fv(t,i,r),s=mv(t,i,r),a=gv(t,i,r),l=(i.battery_soc?[i.battery_soc]:r.soc).map(f=>Number(t.states[f]?.state)).filter(Number.isFinite),c=l.length?l.reduce((f,g)=>f+g,0)/l.length:null,u=i.tariff?t.states[i.tariff]:void 0,d=Number(u?.state),p=i.consumption?Te(t.states[i.consumption]):null;p===null&&(o!==null||s!==null||a!==null)&&(p=(o??0)+Math.max(0,s??0)+(a??0)),p===null&&n.length>0&&(p=n.reduce((f,g)=>f+g.power,0));let h={grid:o,solar:s===null?null:Math.max(0,s),battery:a,soc:c,tariff:u&&Number.isFinite(d)?{value:d,unit:String(u.attributes.unit_of_measurement??"")}:null,consumption:p===null?null:Math.max(0,p)};return r.subMeters?{...h,..._v(t,r,h.consumption,i.battery_invert,n)}:h}function _v(t,e,n,r,i){let o=e.subMeters??[],s=new Map;for(let p of o)for(let h of p.floors)s.has(h)||s.set(h,p.id);let a=new Set([e.grid,e.gridExport,...e.solar,...e.battery,...e.charge,...o.flatMap(p=>[p.power,...p.solar,...p.batteries.flatMap(h=>[h.power,h.charge])])]),l=p=>i.filter(h=>s.get(h.floorId)===p&&!a.has(h.powerEntity)).reduce((h,f)=>h+f.power,0),c=new Map(o.map(p=>[p.id,p.power?Te(t.states[p.power],p.invert):null])),u=o.map(p=>{let h=c.get(p.id)??null,f=p.solar.reduce((v,w)=>v+Math.max(0,Te(t.states[w])??0),0),g=p.batteries.reduce((v,w)=>v+(qa(t,w,r)??0),0),b=o.filter(v=>v.parent===p.id).reduce((v,w)=>v+(c.get(w.id)??0),0),y=h===null?null:Math.max(0,h+f+g-b);return{id:p.id,parent:p.parent,power:h,solar:f,battery:g,use:y,unmetered:y===null?null:Math.max(0,y-l(p.id))}}),d=u.reduce((p,h)=>p+(h.use??0),0);return{subMeters:u,rest:n===null?null:Math.max(0,n-d)}}function bv(t,e,n){let r=t.b[0]-t.a[0],i=t.b[1]-t.a[1],o=Math.hypot(r,i)||1,s=Math.min(1,Math.max(0,((e.x-t.a[0])*r+(e.z-t.a[1])*i)/(o*o))),a=t.a[0]+r*s,l=t.a[1]+i*s,c=i/o*(a-n.x)+-r/o*(l-n.z)<0?-1:1;return{x:a,z:l,nx:c*i/o,nz:-c*r/o,distance:Math.hypot(e.x-a,e.z-l)}}function Eh(t){let e=uv(t),n=e?t.floors.find(c=>c.id===e.floor_id):void 0;if(!e||!n)return null;let r={exterior:t.settings.wall_exterior,interior:t.settings.wall_interior},i=fe(n.rooms,r,n.walls??[]).walls.filter(c=>c.exterior),o=n.rooms.flatMap(c=>c.points);if(i.length===0||o.length===0)return null;let s={x:o.reduce((c,u)=>c+u[0],0)/o.length,z:o.reduce((c,u)=>c+u[1],0)/o.length},a=i.map(c=>bv(c,e,s)).reduce((c,u)=>u.distance({id:t,name:e,has_valve:!0}),Do=t=>t.has_valve!==!1;function di(t){let e=t.hydronic??{};return e.stations?.length?e.stations.slice(0,16):[{...Xa("station-1"),flow:e.flow,return:e.return,hot_water:e.hot_water,cold_water:e.cold_water,pump:e.pump}]}function Ah(t,e){let n={...t,stations:e};for(let r of["flow","return","hot_water","cold_water","pump"])delete n[r];return n}var yv=["heating_manifold","buffer_tank","freshwater_station"],Jn=t=>yv.includes(t),Ja=(t,e="Heizkreis")=>({id:t,name:e,kind:"heating",has_pump:!0,has_valve:!0});function Qa(t){return{card:!0,...t==="heating_manifold"?{circuits:[Ja("c1","Heizkreis 1")]}:{},...t==="buffer_tank"?{sensors:Array.from({length:7},(e,n)=>({id:`s${n+1}`,name:`F\xFChler ${n+1}`,entity:null,level:1-n/6}))}:{}}}function Qn(t){return{...Qa(t.type),...t.hydronic}}var er=t=>t.has_pump!==!1,Io=t=>t.kind!=="pump"&&t.has_valve!==!1;var hi=t=>!!t&&t!=="none";var Ho=(t,e)=>String(t.states[e]?.attributes.symcon_source_entity||e);function Oo(t,e){let n=t.states[Ho(t,e)]?.attributes;return n?.device_class==="power"||/^[km]?w$/i.test(String(n?.unit_of_measurement??"").trim())}function Fh(t,e){let n=new Map;if(!Z(t))return n;let r=Re(t,[e]),i=(o,s,a,l,c)=>{if(!hi(c))return;let u=e.rooms.find(p=>p.points.length>=3&&C([a,l],p.points));if(!u)return;let d=n.get(u.id)??[];d.push({id:o,name:s,source:Ho(t,c)}),n.set(u.id,d)};for(let o of e.furniture){if(!xh(t,o))continue;let s=o.name||Fe(t,o.type),a=(o.values??[]).find(u=>hi(u.entity)&&Oo(t,u.entity)),l=r.get(o.id)?.entity,c=o.power==="none"?null:o.power||r.get(o.id)?.power||(l&&Oo(t,l)?l:null);if(i(`furniture:${o.id}`,s,o.x,o.z,c||a?.entity),!c&&!a){let u=new Set;for(let d of o.gang_entities??[]){if(!hi(d))continue;let p=ui(t,d);!p||u.has(Ho(t,p))||(u.add(Ho(t,p)),i(`furniture:${o.id}:${d}`,`${s} \xB7 ${B(t,d)}`,o.x,o.z,p))}}if(Jn(o.type))for(let u of Qn(o).circuits??[])er(u)&&i(`furniture:${o.id}:${u.id}`,`${s} \xB7 ${u.name||"Pumpe"}`,o.x,o.z,u.power);if(o.type==="freshwater_station")for(let u of di(o))i(`furniture:${o.id}:station:${u.id}`,`${s} \xB7 ${u.name}`,o.x,o.z,u.power)}for(let o of e.placements){if(o.outside)continue;let s=(o.values??[]).find(l=>hi(l.entity)&&Oo(t,l.entity)),a=Oo(t,o.entity_id)?o.entity_id:ui(t,o.entity_id);i(`device:${o.entity_id}`,o.name||B(t,o.entity_id),o.x,o.z,a||s?.entity)}return n}var Mt={electricity:"Strom",water:"Wasser",gas:"Gas",heating:"Heizen",cooling:"K\xFChlen"},tr={electricity:"\u26A1",water:"\u{1F4A7}",gas:"\u{1F525}",heating:"\u2668",cooling:"\u2744"},Co=t=>t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/ß/g,"ss").replace(/[^a-z0-9]+/g," ").trim(),vv="{485D0419-BE97-4548-AA9C-C083EB82E61E}",wv=t=>t.object_type!==0&&!(t.object_type===1&&t.module_id?.toUpperCase()===vv)?null:{elektro:"electricity",strom:"electricity","elektro strom":"electricity","strom elektro":"electricity",wasser:"water",gas:"gas",heizen:"heating",heizung:"heating",warme:"heating",waerme:"heating",kuhlen:"cooling",kuehlen:"cooling",kuhlung:"cooling",kuehlung:"cooling",kalte:"cooling",kaelte:"cooling"}[Co(t.name)]??null,Lo=t=>/^symcon-category-(\d+)$/.exec(t??"")?.[1],tl=t=>/\b(heute|tag|tagesverbrauch|today|daily)\b/.test(t)?"day":/monat|month/.test(t)?"month":/jahr|year/.test(t)?"year":"total",No=(t,e)=>String(t.states[e]?.attributes.symcon_source_entity||e);function Ph(t){let e=String(t?.attributes.unit_of_measurement??"").trim(),n=e.replace(/[³]/g,"3").replace(/[²]/g,"2").replace(/\s+/g,"").toLowerCase();return["w","kw","mw"].includes(n)?{metric:"power",unit:"W",factor:e==="mW"?.001:n==="kw"?1e3:n==="mw"?1e6:1}:["wh","kwh","mwh","j","kj","mj","gj"].includes(n)?{metric:"energy",unit:"kWh",factor:{wh:.001,kwh:1,mwh:1e3,j:1/36e5,kj:1/3600,mj:1/3.6,gj:1e3/3.6}[n]}:["m3/h","m3h","m3/min","m3/s","l/h","l/min","l/s","liter/h","liter/min"].includes(n)?{metric:"power",unit:"m\xB3/h",factor:{"m3/h":1,m3h:1,"m3/min":60,"m3/s":3600,"l/h":.001,"l/min":.06,"l/s":3.6,"liter/h":.001,"liter/min":.06}[n]}:["m3","l","liter"].includes(n)?{metric:"energy",unit:"m\xB3",factor:n==="m3"?1:.001}:null}function kv(t,e){if(!e.entity_id||e.object_type!==2&&e.object_type!==6)return null;let n=No(t,e.entity_id),r=t.states[n];if(!r||![1,2].includes(Number(r.attributes.symcon_variable_type)))return null;let i=Co(e.name),o=Ph(r),s=/^(leistung|wirkleistung|gesamtleistung|aktuelle leistung|durchfluss|volumenstrom)(\b|$)/.test(i),a=/^(verbrauch|energie|energieverbrauch|gesamtverbrauch|gesamtenergie|zahlerstand|zaehlerstand|arbeit)(\b|$)/.test(i),l=o?.metric??(s?"power":a?"energy":null);if(!l)return null;let c=l==="power"?/^(leistung|wirkleistung|gesamtleistung|durchfluss|volumenstrom)$/.test(i):/^(verbrauch|energie|energieverbrauch|gesamtverbrauch|gesamtenergie|zahlerstand|zaehlerstand|arbeit)$/.test(i),u=l==="energy"?tl(i):"total";return{metric:l,source:n,period:u,group:`${l}|${o?.unit??String(r.attributes.unit_of_measurement??"")}|${u}`,score:/^gesamt(leistung|verbrauch|energie)$/.test(i)?110:c?100:(l==="power"?s:a)?70:20}}var Th=new WeakMap,zh=new WeakMap;function Dh(t){let e=Th.get(t);if(e)return e;let n={nodes:new Map(t.map(r=>[r.object_id,r])),children:new Map};for(let r of t){let i=n.children.get(r.parent_id)??[];i.push(r),n.children.set(r.parent_id,i)}return Th.set(t,n),n}function xv(t,e,n){if(!Z(t))return[];let r=[e.area_id,...e.sub_areas??[]].map(Lo).filter(p=>!!p);if(!r.length)return[];let i=new Set(n.filter(p=>p.id!==e.id).flatMap(p=>[p.area_id,...p.sub_areas??[]]).map(Lo).filter(p=>!!p&&!r.includes(p))),o=`${r.join(",")}|${[...i].sort().join(",")}`,s=zh.get(t)??new Map;zh.set(t,s);let a=s.get(o);if(a)return a;let l=Dh(t.symconObjects),c=[],u=new Set,d=(p,h,f)=>{if(u.has(p)||i.has(String(p)))return;u.add(p);let g=l.nodes.get(p);if(!g)return;let b=wv(g),y=b??h,v=new Set(b&&b!==h?[]:f),w=l.children.get(p)??[];if(y){let x=w.map(k=>kv(t,k)).filter(k=>k!==null);for(let k of new Set(x.map(M=>M.group))){if(v.has(k))continue;let M=x.filter(F=>F.group===k),A=Math.max(...M.map(F=>F.score)),T=M.filter(F=>F.score===A);for(let F of A>=100?T.slice(0,1):T)c.push({kind:y,metric:F.metric,id:F.source,period:F.period});v.add(k)}}for(let x of w)(x.object_type===0||x.object_type===1)&&d(x.object_id,y,v)};for(let p of r)d(Number(p),null,new Set);return s.set(o,c),c}function pi(t,e,n=!1){let r=new Map,i=new Set;for(let o of e){let s=No(t,o.id),a=`${o.kind}|${o.metric}|${s}`;if(i.has(a))continue;i.add(a);let l=t.states[s],c=Ph(l),u=c?.metric===o.metric?c.unit:String(l?.attributes.unit_of_measurement??"").trim(),d=`${o.kind}|${o.metric}|${u}|${o.period}`,p=r.get(d)??{kind:o.kind,metric:o.metric,unit:u,value:null,period:o.period,sources:[],manual:n,incomplete:!1},h=Lt(l);h===null?p.incomplete=!0:p.value=(p.value??0)+h*(c?.metric===o.metric?c.factor:1),p.sources.push(s),r.set(d,p)}return[...r.values()]}function el(t,e){return vt.flatMap(n=>["power","energy"].flatMap(r=>{let i=e.utility_meters?.[n]?.[r];if(!i||i==="none")return[];let o=No(t,i);return[{kind:n,metric:r,id:o,period:r==="energy"?tl(Co(String(t.states[o]?.attributes.friendly_name??""))):"total"}]}))}function $v(t,e){return Z(t)?pi(t,el(t,e),!0):[]}function Sv(t,e,n=e.rooms,r=!1){if(!Z(t))return[];let i=r?Fh(t,e):new Map,o=new Map;for(let a of e.rooms){let l=[...new Set([a.area_id,...a.sub_areas??[]].filter(c=>!!Lo(c)))];!l.length&&(el(t,a).length||i.get(a.id)?.length)&&l.push("unassigned");for(let c of l){let u=o.get(c)??{seed:a,members:[]};c===l[0]&&u.members.push(a),o.set(c,u)}}let s=Dh(t.symconObjects).nodes;return[...o].map(([a,l])=>{let c=s.get(Number(Lo(a))),u=a==="unassigned"?[]:pi(t,xv(t,{...l.seed,area_id:a,sub_areas:null},n)),d=pi(t,l.members.flatMap(f=>el(t,f)),!0),p=f=>u.some(g=>g.kind===f.kind&&g.metric===f.metric&&g.unit===f.unit&&g.period===f.period),h=l.members.map(f=>({id:f.id,name:f.name,readings:$v(t,f),devices:(i.get(f.id)??[]).map(g=>({id:g.id,name:g.name,readings:pi(t,[{kind:"electricity",metric:"power",id:g.source,period:"total"}],!0)}))})).filter(f=>f.readings.length||f.devices.length);return{id:a,name:a==="unassigned"?"Nicht zugeordnet":c?.name||t.areas?.[a]?.name||"Bereich nicht verf\xFCgbar",path:c?.path||"",readings:[...u,...d.filter(f=>!p(f))],rooms:h}}).filter(a=>a.readings.length||a.rooms.length)}function nl(t,e,n,r){let i=e.utility_meters?.[n],o=i&&Object.prototype.hasOwnProperty.call(i,r)?i[r]:n==="electricity"&&r==="power"?e.power_entity:null;return o&&o!=="none"?No(t,o):null}function Ih(t,e,n=e.rooms){let r=Sv(t,e,n).flatMap(o=>o.readings.flatMap(s=>s.sources.map(a=>({kind:s.kind,metric:s.metric,period:s.period,id:a})))),i=[];for(let o of vt)for(let s of["power","energy"]){let a=nl(t,e,o,s);i.push(...pi(t,a?[{kind:o,metric:s,id:a,period:s==="energy"?tl(Co(String(t.states[a]?.attributes.friendly_name??""))):"total"}]:r.filter(l=>l.kind===o&&l.metric===s),!!a))}return i}function rl(t){return t.metric==="power"?t.unit==="m\xB3/h"?"Durchfluss":"Leistung":{total:"Verbrauch",day:"Verbrauch heute",month:"Verbrauch Monat",year:"Verbrauch Jahr"}[t.period]}function Oh(t,e){let n=e.incomplete?"Err: ":"";if(e.value===null)return`${n}\u2013`;let r=e.unit==="W"&&Math.abs(e.value)>=1e3?e.value/1e3:e.value,i=e.unit==="W"&&Math.abs(e.value)>=1e3?"kW":e.unit,o=Number.isInteger(r)?0:Math.min(6,Math.max(2,1-Math.floor(Math.log10(Math.abs(r)))));return`${n}${K(t,r,o)}${i?` ${i}`:""}`}var Hh=[{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 Lh(t,e,n){let r=H(t.hass,i=>Le(t.hass,i,[1,2]));return m`
Eigene Raumzähler
${S("Nur direkt zugewiesene Raumz\xE4hler erscheinen als einger\xFCckte Raumzeile unter dem verkn\xFCpften Bereich. Die Bereichswerte stehen einmal beim Bereich; vorhandene Bereichssummen enthalten die Raumwerte bereits. Fehlt dem Bereich ein passender Z\xE4hler, werden daf\xFCr die eigenen Raumz\xE4hler summiert.","nf-wide")} ${vt.map(i=>m`${tr[i]} ${Mt[i]}${["power","energy"].map(o=>z(t,o==="power"?"Leistung / Durchfluss":"Energie / Verbrauch",e.utility_meters?.[i]?.[o]??null,void 0,r,s=>{let a={...e.utility_meters,[i]:{...e.utility_meters?.[i],[o]:s==="none"?null:s}};Object.values(a[i]).some(l=>l&&l!=="none")||delete a[i],n({utility_meters:Object.keys(a).length?a:null})},{types:[1,2]}))}`)}
`}function Ch(t,e,n){let r=s=>n({hvac:{...e.hvac,...s}}),i=e.hvac?.schedules??[],o=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=>Le(t.hass,s,[0,1,2])),s=>n({floor_heating:s==="none"?null:s}),{types:[0,1,2]})} ${Hh.map(s=>z(t,s.label,e.hvac?.[s.key]??null,void 0,H(t.hass,a=>Le(t.hass,a,s.types)),a=>r({[s.key]:a==="none"?null:a}),{types:s.types}))} ${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")} ${i.map((s,a)=>z(t,`Schaltuhr ${a+1}`,s,void 0,o.filter(l=>l.id===s||!i.includes(l.id)),l=>r({schedules:l&&l!=="none"?i.map((c,u)=>a===u?l:c):i.filter((c,u)=>a!==u)}),{schedule:!0,excluded:l=>i.includes(l)?"Diese Schaltuhr ist in diesem Raum bereits verkn\xFCpft.":void 0}))} ${z(t,"Schaltuhr hinzuf\xFCgen",null,void 0,o.filter(s=>!i.includes(s.id)),s=>s&&s!=="none"&&r({schedules:[...i,s]}),{schedule:!0,excluded:s=>i.includes(s)?"Diese Schaltuhr ist in diesem Raum bereits verkn\xFCpft.":void 0})}`}function Nh(t,e,n){let r=i=>i==="condition"?[0,1,2,3]:i==="wind_bearing"?[1,2,3]:["snow","fog","lightning"].includes(i)?[0,1,2]:[1,2];return m`
Wettervariablen
${jc.map(i=>z(t,dd[i],e.weather_variables?.[i]??null,void 0,H(t.hass,o=>Le(t.hass,o,r(i))),o=>n({weather_variables:{...e.weather_variables,[i]:o==="none"?null:o}}),{types:r(i)}))} ${z(t,t.t("rain_sensor"),e.rain_sensor??null,void 0,H(t.hass,i=>Le(t.hass,i,[0,1,2])),i=>n({rain_sensor:i==="none"?null:i}),{types:[0,1,2]})} ${e.rain_sensor?I(t,t.t("rain_sensor_inverted"),!!e.rain_sensor_inverted,i=>n({rain_sensor_inverted:i||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 Bh(t){let e=t.doc.presence,n=s=>t.replace({...structuredClone(t.doc),presence:s}),r=(s,a)=>n(e.map((l,c)=>c===s?{...l,...a,sensor:null}:l)),i=t.doc.floors.flatMap(s=>s.rooms.map(a=>({id:a.id,name:`${s.name} \xB7 ${a.name}`}))),o=H(t.hass,s=>Le(t.hass,s,[0]));return m`
${t.t("presence")} ${e.map((s,a)=>m`
${W(t,"Person",s.name??B(t.hass,s.person),l=>r(a,{name:l}),{wide:!0,maxlength:100})} ${z(t,"Anwesenheit (Boolean)",s.person,void 0,o.filter(l=>l.id===s.person||!e.some(c=>c.person===l.id)),l=>l&&l!=="none"?r(a,{person:l}):n(e.filter((c,u)=>u!==a)),{types:[0],excluded:l=>e.some(c=>c.person===l)?"Diese Anwesenheitsvariable ist bereits mit einer Person verkn\xFCpft.":void 0})}
`)}
${z(t,"Person hinzuf\xFCgen (Boolean)",null,void 0,o.filter(s=>!e.some(a=>a.person===s.id)),s=>s&&s!=="none"&&n([...e,{person:s,sensor:null}]),{types:[0],excluded:s=>e.some(a=>a.person===s)?"Diese Anwesenheitsvariable ist bereits mit einer Person verkn\xFCpft.":void 0})}
${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 Vh(t,e,n){let r=t.find(l=>l.person===e),i="sensor"in n?n.sensor&&n.sensor!=="none"?n.sensor:null:r?.sensor??null,o="room"in n?n.room||null:r?.room??null,s=t.filter(l=>l.person!==e);if(!i&&!o)return s;let a=o?{person:e,sensor:i,room:o}:{person:e,sensor:i};return r?t.map(l=>l.person===e?a:l):[...s,a]}function Wh(t,e){let n=e.slice(e.indexOf(".")+1),r=i=>i.id.includes(n)&&/(area|room|raum|bermuda|espresense)/.test(i.id);return[...t.filter(r),...t.filter(i=>!r(i))]}function Kh(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 jh(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 Bo(t,e,n){let r=[...t],[i]=r.splice(e,1);return r.splice(Math.max(0,Math.min(r.length,e+n)),0,i),r}var Ut=(t,e)=>t.filter((n,r)=>r!==e),fi=(t,e,n)=>t.map((r,i)=>i===e?{...r,...n}:r),gt=t=>t.length>0?t:void 0;var Mv=["scene","script","automation","button","input_button","switch","input_boolean","light","fan","cover","lock"],Rv=40,Ev=20,Av=30,Fv=["music","url","playlist","SPOTIFY","AMAZON_MUSIC","TUNEIN","APPLE_MUSIC"],il={navigate:"/lovelace/rollos",more_info:"cover.wohnzimmer",service:"script.turn_on",fire_dom_event:""},mi=(t,e,n,r=!1)=>m``;function Tv(t){let e=t.doc.settings.favorites??[],n=a=>t.change(l=>l.settings.favorites=gt(a)),r=t.doc.floors,i=t.doc.settings.favorite_floors??{},o=H(t.hass,a=>Mv.includes(a.split(".")[0])&&!e.includes(a)),s=(a,l)=>m`
${B(t.hass,a)} ${r.length>1?m``:_} ${mi(t.t("move_up"),"\u2191",()=>n(Bo(e,l,-1)),l===0)} ${mi(t.t("move_down"),"\u2193",()=>n(Bo(e,l,1)),l===e.length-1)} ${mi(t.t("delete"),"\u2715",()=>n(Ut(e,l)))}
`;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,o,a=>a&&a!=="none"&&!e.includes(a)&&n([...e,a]),{excluded:a=>e.includes(a)?"Diese Variable ist bereits als Favorit verkn\xFCpft.":void 0})}`:_}`}function zv(t,e){let n=t.doc.settings.outside_hidden??[],r=s=>t.change(a=>a.settings.outside_hidden=gt(s)),i=new Set(t.hass?vd(t.hass,t.doc.floors):[]),o=H(t.hass,s=>!n.includes(s)&&i.has(s));return m`${e?Pv(t,e):_}

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

${S(t.t("outside_hidden_hint"))} ${n.map((s,a)=>m`
${B(t.hass,s)}${mi(t.t("delete"),"\u2715",()=>r(Ut(n,a)))}
`)}
${z(t,t.t("outside_hidden_add"),null,void 0,o,s=>s&&s!=="none"&&!n.includes(s)&&r([...n,s]),{excluded:s=>n.includes(s)?"Diese Variable ist hier bereits eingetragen.":void 0})}
`}function Pv(t,e){let n=t.doc.settings.outside_view??null,r=()=>{let i=e();i&&t.change(o=>o.settings.outside_view=i)};return m`${S(t.t("outside_view_hint"))} ${J(m``,n?m``:_)}`}function Dv(t){let e=t.doc.settings.own_alerts??[],n=s=>t.change(a=>a.settings.own_alerts=gt(s)),r=(s,a)=>n(fi(e,s,a)),i=[["",t.t("own_alert_house")],...t.doc.floors.flatMap(s=>s.rooms.map(a=>[a.id,`${a.name} \xB7 ${s.name}`]))],o=(s,a)=>m`
${z(t,t.t("own_alert_entity"),s.entity||null,void 0,H(t.hass,()=>!0),l=>r(a,{entity:l&&l!=="none"?l:""}))} ${W(t,t.t("own_alert_state"),s.state??"",l=>r(a,{state:l||null}),{placeholder:t.hass?.states[s.entity]?.state??"on \xB7 <20 \xB7 >80"})} ${W(t,t.t("own_alert_text"),s.text,l=>r(a,{text:l||t.t("own_alert_new")}),{wide:!0,maxlength:120})} ${O(t,t.t("room"),s.room_id??"",i,l=>r(a,{room_id:l||null}),{wide:!0})} ${Ge(t,t.t("own_alert_color"),s.color??null,"#ffb547",l=>r(a,{color:l}))} ${O(t,t.t("own_alert_tap"),s.tap??"",[["",t.t("own_alert_tap_info")],["toggle",t.t("own_alert_tap_toggle")],["room",t.t("own_alert_tap_room")]],l=>r(a,{tap:l||null}))}
`;return m`

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

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

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

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

📅 ${o("today_calendars")}

${S(o("today_calendars_hint"))} ${e.map(i)} ${e.length<12?m`
${z(t,o("favorites_add"),null,void 0,r,a=>a&&a!=="none"&&!e.includes(a)&&n([...e,a]),{unsupported:"Dieses Feld ben\xF6tigt eine Kalenderquelle mit Terminen. Eine Symcon-Variable ist kein Kalender; Kalenderquellen werden vom Symcon-Modul derzeit nicht bereitgestellt."})}
`:_} ${e.length?m`
${O(t,o("today_days"),String(s),[1,2,3,5,7].map(a=>[String(a),o(a===1?"today_days_one":"today_days_n",{n:a})]),a=>t.change(l=>l.settings.today_days=Number(a)>1?Number(a):void 0))}
`:_} ${Hv(t)}`}function Hv(t){let e=t.t,n=t.doc.settings.forecast??null,r=i=>t.change(o=>o.settings.forecast=i??void 0);return m`

🌦 ${e("forecast")}

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

${t.t("presets")}

${S(t.t("presets_hint"))} ${Fv.map(s=>m``)} ${e.map(o)} ${e.lengthn([...e,{id:P("preset"),label:"Radio",type:"music",content:""}])}>+ ${t.t("preset_add")}`):_}`}function ol(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"}',i=o=>{let s=o.target;s.setCustomValidity("");let a=jh(s.value);if(a.ok)return n(a.value);s.setCustomValidity(t.t("own_data_bad")),s.reportValidity()};return m``}function Cv(t){let e=t.doc.settings.buttons??[],n=s=>t.change(a=>a.settings.buttons=gt(s)),r=(s,a)=>n(fi(e,s,a)),i=Ni.map(s=>[s,t.t(`own_action_${s}`)]),o=(s,a)=>m`
${W(t,t.t("own_button_label"),s.label,l=>r(a,{label:l||t.t("own_button_new")}),{maxlength:60})} ${O(t,t.t("own_button_action"),s.action,i,l=>r(a,{action:l}))} ${Bt(t,s.icon??null,l=>r(a,{icon:l}))} ${s.action!=="fire_dom_event"?W(t,t.t(`own_target_${s.action}`),s.target??"",l=>r(a,{target:l||null}),{wide:!0,placeholder:il[s.action]}):_} ${s.action==="service"||s.action==="fire_dom_event"?ol(t,s,l=>r(a,{data:l})):_} ${z(t,t.t("own_button_state"),s.state_entity??null,void 0,H(t.hass,l=>/^(switch|light|input_boolean|binary_sensor|fan|cover|media_player|climate|lock|person|device_tracker)\./.test(l)),l=>r(a,{state_entity:l&&l!=="none"?l:null}))}
`;return m`

${t.t("own_buttons")}

${S(t.t("own_buttons_hint"))} ${e.map(o)} ${e.lengthn([...e,{id:P("btn"),label:t.t("own_button_new"),action:"navigate",target:null}])}>+ ${t.t("own_button_add")}`):_}`}function Nv(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),i=>t.change(o=>o.settings.room_facts_off=gt(i?e.filter(s=>s!==r):[...e,r]))));return m`

${t.t("room_facts")}

${n}
`}function Gh(t){return m`
${Tv(t)} ${Cv(t)} ${Dv(t)} ${Iv(t)} ${Ov(t)} ${Lv(t)} ${Nv(t)}
`}function Uh(t,e){return m`
🌳 ${t.t("outside_area")} ${zv(t,e)}
`}function Zh(t,e){let n=t.doc.settings.start_view??null,r=()=>{let i=e();i&&t.change(o=>o.settings.start_view=i)};return m`
${t.t("start_view")} ${S(t.t("start_view_hint"))} ${J(m``,n?m``:_)} ${n?m`${S(t.t("start_view_saved"))} ${S(t.t("start_view_card"))}${Kh(n)}`:_}
`}function qh(t){if(Z(t.hass))return Bh(t);let e=t.doc.presence.map(l=>l.person),n=[...new Set([...Object.keys(t.hass?.states??{}).filter(l=>l.startsWith("person.")).sort(),...e])],r=H(t.hass,me),i=t.doc.floors.flatMap(l=>l.rooms.map(c=>({id:c.id,label:t.doc.floors.length>1?`${l.name} \xB7 ${c.name}`:c.name}))),o=(l,c)=>t.replace({...structuredClone(t.doc),presence:Vh(t.doc.presence,l,c)}),s=l=>{let c=t.doc.presence.find(d=>d.person===l),u=!l.startsWith("person.");return m`${z(t,`${B(t.hass,l)} \xB7 ${t.t("presence_sensor")}`,c?.sensor??null,void 0,Wh(r,l),d=>o(l,{sensor:d}))} ${u?m``:_}`},a=H(t.hass,l=>/^(input_boolean|binary_sensor|device_tracker)\./.test(l)&&!n.includes(l));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,a,l=>l&&l!=="none"&&t.replace({...structuredClone(t.doc),presence:[...t.doc.presence,{person:l,sensor:null}]}))}
${S(t.t("presence_hint"))}
`}function Yh(t,e){return Z(t.hass)?m``:m`
${t.t("ble")} ${S(t.t("ble_hint"))}
`}var gi=(t,e)=>{let n=t._$AN;if(n===void 0)return!1;for(let r of n)r._$AO?.(e,!1),gi(r,e);return!0},Vo=t=>{let e,n;do{if((e=t._$AM)===void 0)break;n=e._$AN,n.delete(t),t=e}while(n?.size===0)},Xh=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),Wv(e)}};function Bv(t){this._$AN!==void 0?(Vo(this),this._$AM=t,Xh(this)):this._$AM=t}function Vv(t,e=!1,n=0){let r=this._$AH,i=this._$AN;if(i!==void 0&&i.size!==0)if(e)if(Array.isArray(r))for(let o=n;o{t.type==Hn.CHILD&&(t._$AP??=Vv,t._$AQ??=Bv)},Wo=class extends Ct{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,n,r){super._$AT(e,n,r),Xh(this),this.isConnected=e._$AU}_$AO(e,n=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),n&&(gi(this,e),Vo(this))}setValue(e){if(Rd(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 sl=new WeakMap,Jh=an(class extends Wo{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=sl.get(e);n===void 0&&(n=new WeakMap,sl.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"?sl.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 Qh=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 ep(t){let e=t.t,n=t.doc.settings.card_templates??{},r=Object.keys(n),i=a=>t.change(l=>{l.settings.card_templates=Object.keys(a).length?a:void 0});t.loadCardEditor?.();let o=a=>{t.hass?.callService("nextfloor","reload_screens",a?{template:a}:{})},s=a=>{let l=Qh(a.value);!l||l in n||r.length>=20||(a.value="",i({...n,[l]:{}}))};return m`
${e("card_templates")}${r.length?m` ${r.length}`:_} ${S(e("card_templates_hint"))} ${r.map(a=>m`
${a} l&&l.setConfig({type:"custom:nextfloor-card",...n[a]}))} @config-changed=${l=>{l.stopPropagation();let{type:c,template:u,...d}=l.detail.config;i({...n,[a]:d})}} > ${t.admin?m`
`:_} ${S(e("template_use",{name:a}))}
`)} ${t.admin?m`
`:_}
`}var Ko=.05,Kv=(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),vn=t=>new Map(t.map(e=>[e.id,e]));function jv(t,e,n,r){let i=e.name,[o,s]=[vn(t.rooms),vn(e.rooms)];for(let h of e.rooms){let f=o.get(h.id);f?(f.name!==h.name&&n.push({kind:"room_renamed",floor:i,name:h.name,detail:f.name}),Kv(f.points,h.points)||n.push({kind:"room_reshaped",floor:i,name:h.name,detail:Math.round((xe(h.points)-xe(f.points))*10)/10})):n.push({kind:"room_added",floor:i,name:h.name})}for(let h of t.rooms)s.has(h.id)||n.push({kind:"room_removed",floor:i,name:h.name});let[a,l]=[vn(t.openings),vn(e.openings)];for(let h of e.openings)a.has(h.id)||n.push({kind:"opening_added",floor:i,name:h.type,detail:r(h.room_id)});for(let h of t.openings)l.has(h.id)||n.push({kind:"opening_removed",floor:i,name:h.type,detail:r(h.room_id)});let[c,u]=[vn(t.furniture),vn(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)>Ko||Math.abs(h.rotation-f.rotation)>1||Math.abs(h.w-f.w)>Ko||Math.abs(h.d-f.d)>Ko)&&n.push({kind:"furniture_moved",floor:i,name:h.name||h.type}):n.push({kind:"furniture_added",floor:i,name:h.name||h.type})}for(let h of t.furniture)u.has(h.id)||n.push({kind:"furniture_removed",floor:i,name:h.name||h.type});let[d,p]=[new Map(t.placements.map(h=>[h.entity_id,h])),new Map(e.placements.map(h=>[h.entity_id,h]))];for(let h of e.placements){let f=d.get(h.entity_id);f?Math.hypot(h.x-f.x,h.z-f.z)>Ko&&n.push({kind:"device_moved",floor:i,name:h.entity_id}):n.push({kind:"device_added",floor:i,name:h.entity_id})}for(let h of t.placements)p.has(h.entity_id)||n.push({kind:"device_removed",floor:i,name:h.entity_id})}function tp(t,e){let n=[],r=vn(t.floors),i=new Map([...t.floors,...e.floors].flatMap(a=>a.rooms.map(l=>[l.id,l.name]))),o=a=>i.get(a)??"";for(let a of e.floors){let l=r.get(a.id);l?jv(l,a,n,o):n.push({kind:"floor_added",floor:a.name,name:a.name})}let s=new Set(e.floors.map(a=>a.id));for(let a of t.floors)s.has(a.id)||n.push({kind:"floor_removed",floor:a.name,name:a.name});return n}var wn=(t,e)=>t.getUint16(e,!0),_i=(t,e)=>t.getUint32(e,!0);function np(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),n=-1;for(let a=t.length-22;a>=Math.max(0,t.length-65557);a--)if(_i(e,a)===101010256){n=a;break}if(n<0)throw new Error("not_zip");let r=wn(e,n+10),i=_i(e,n+16),o=[],s=new TextDecoder;for(let a=0;a",quot:'"',apos:"'"},Uv=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)):Gv[n]??e);function Zv(t){let e={};for(let n of t.matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))e[n[1]]=Uv(n[2]??n[3]);return e}function qv(t){let e=[],n=null;for(let r of t.matchAll(/<(\/?)(level|room|point|wall|doorOrWindow|pieceOfFurniture)\b([^>]*?)(\/?)>/g)){let[,i,o,s,a]=r;if(i){o==="room"&&(n=null);continue}let l=Zv(s);if(o==="point"){n&&n.points.push([Number(l.x)/100,Number(l.y)/100]);continue}let c={name:o,attrs:l,...o==="room"?{points:[]}:{}};e.push(c),o==="room"&&!a&&(n=c)}return e}var oe=(t,e,n)=>Number.isFinite(Number(t[e]))&&t[e]!==void 0?Number(t[e]):n,ze=t=>Math.round(t*1e3)/1e3;function ip(t,e,n){let[r,i]=[n[0]-e[0],n[1]-e[1]],o=Math.hypot(r,i)||1e-9,s=Math.max(0,Math.min(o,((t[0]-e[0])*r+(t[1]-e[1])*i)/o)),a=[e[0]+r*s/o,e[1]+i*s/o];return{dist:Math.hypot(t[0]-a[0],t[1]-a[1]),along:s,length:o}}function Yv(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 Xv(t,e){let n=t.length,r=t.map((i,o)=>{let s=t[(o+1)%n],[a,l]=[s[0]-i[0],s[1]-i[1]],c=Math.hypot(a,l)||1e-9,u=[a/c,l/c],d=[(i[0]+s[0])/2,(i[1]+s[1])/2],p=[0,0];for(let h of e){let[f,g]=[h.b[0]-h.a[0],h.b[1]-h.a[1]],b=Math.hypot(f,g)||1e-9;if(Math.abs((u[0]*g-u[1]*f)/b)>.05)continue;let y=(h.a[0]-d[0])*-u[1]+(h.a[1]-d[1])*u[0],v=((d[0]-h.a[0])*f+(d[1]-h.a[1])*g)/b;if(!(Math.abs(y)>h.thickness/2+.06||v<-.05||v>b+.05)){p=[-u[1]*y,u[0]*y];break}}return{p:[i[0]+p[0],i[1]+p[1]],dir:u}});return r.map((i,o)=>{let s=r[(o-1+n)%n],a=s.dir[0]*i.dir[1]-s.dir[1]*i.dir[0];if(Math.abs(a)<1e-6)return i.p;let l=((i.p[0]-s.p[0])*i.dir[1]-(i.p[1]-s.p[1])*i.dir[0])/a;return[s.p[0]+s.dir[0]*l,s.p[1]+s.dir[1]*l]})}function Jv(t){let e=Pt(),n={floors:0,rooms:0,openings:0,walls:0,furniture:0},r=t.filter(l=>l.name==="level"),i=r.length?r.map(l=>l.attrs.id??""):[""],o=t.filter(l=>l.name==="wall"),s=o.length?Math.max(...o.map(l=>oe(l.attrs,"height",250)))/100:2.5;return(r.length?[...r].sort((l,c)=>oe(l.attrs,"elevation",0)-oe(c.attrs,"elevation",0)||oe(l.attrs,"elevationIndex",0)-oe(c.attrs,"elevationIndex",0)):[{name:"level",attrs:{id:""}}]).forEach((l,c)=>{let u=l.attrs.id??"",d=b=>r.length?(b.attrs.level??i[0])===u:!0,p=Me(P("floor"),l.attrs.name||(c===0?"Erdgeschoss":`Etage ${c+1}`),ze(oe(l.attrs,"elevation",0)/100));p.height=ze(oe(l.attrs,"height",s*100)/100);let h=o.filter(d).map(b=>({a:[oe(b.attrs,"xStart",0)/100,oe(b.attrs,"yStart",0)/100],b:[oe(b.attrs,"xEnd",0)/100,oe(b.attrs,"yEnd",0)/100],thickness:oe(b.attrs,"thickness",10)/100})),f=t.filter(b=>b.name==="room"&&d(b)&&(b.points?.length??0)>=3).map((b,y)=>({id:P("room"),name:b.attrs.name||`Raum ${y+1}`,area_id:null,points:Xv(b.points,h).map(([v,w])=>[ze(v),ze(w)]),floor_material:"wood",panel:[]}));p.rooms=f;for(let b of t.filter(y=>y.name==="doorOrWindow"&&d(y))){let y=[oe(b.attrs,"x",0)/100,oe(b.attrs,"y",0)/100],v=Math.max(.6,oe(b.attrs,"depth",30)/100+.3),w=null;for(let L of f)L.points.forEach((D,N)=>{let V=ip(y,D,L.points[(N+1)%L.points.length]);V.dist<=v&&(!w||V.dist1.4?2:1,swing:"in",cover:null,contact:null,contact2:null,tilt:null})}let g=[];for(let b of o.filter(d)){let y=[oe(b.attrs,"xStart",0)/100,oe(b.attrs,"yStart",0)/100],v=[oe(b.attrs,"xEnd",0)/100,oe(b.attrs,"yEnd",0)/100];if(Math.hypot(v[0]-y[0],v[1]-y[1])<.1)continue;let w=Math.max(.15,oe(b.attrs,"thickness",10)/100),x=F=>f.some(L=>L.points.some((D,N)=>ip(F,D,L.points[(N+1)%L.points.length]).dist[y[0]+(v[0]-y[0])*F/M,y[1]+(v[1]-y[1])*F/M],T=Array.from({length:M+1},(F,L)=>!x(A(L)));for(let F=0;F<=M;){if(!T[F]){F++;continue}let L=F;for(;L+1<=M&&T[L+1];)L++;let[D,N]=[A(Math.max(0,F-1)),A(Math.min(M,L+1))];Math.hypot(N[0]-D[0],N[1]-D[1])>=.3&&g.push({id:P("wall"),a:[ze(D[0]),ze(D[1])],b:[ze(N[0]),ze(N[1])],thickness:ze(oe(b.attrs,"thickness",10)/100),height:b.attrs.height?ze(oe(b.attrs,"height",250)/100):null}),F=L+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(l=>l.name==="pieceOfFurniture").length,{building:Oe(e),report:n}}async function op(t){let e=np(t).find(i=>i.name==="Home.xml");if(!e)throw new Error("sh3d_no_xml");let n=new TextDecoder().decode(await rp(t,e)),r=Jv(qv(n));if(r.report.rooms===0&&r.report.walls===0)throw new Error("sh3d_empty");return r}function Qv(t){let e=t.split(/\r?\n/),n=[];for(let r=0;r+1r===9&&i==="$INSUNITS"),n=e>=0?Number(t[e+1]?.[1]):NaN;return{1:.0254,2:.3048,4:.001,5:.01,6:1}[n]??null}function tw(t){let e=Qv(t),n=ew(e),r=e.findIndex(([s,a],l)=>s===2&&a==="ENTITIES"&&e[l-1]?.[1]==="SECTION"),i=[];if(r<0)return{shapes:i,unit:n};let o=r+1;for(;oNumber(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))&&i.push({points:d,closed:!1})}else if(a==="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&&i.push({points:h,closed:(p&1)===1})}o=l}return{shapes:i,unit:n}}var sp=t=>Math.round(t*1e3)/1e3;function ap(t){let{shapes:e,unit:n}=tw(t);if(!e.length)throw new Error("dxf_empty");let r=e.flatMap(h=>h.points),i=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]))),o=n??(i>2e3?.001:i>200?.01:1),s=Math.min(...r.map(h=>h[0])),a=Math.max(...r.map(h=>h[1])),l=([h,f])=>[sp((h-s)*o),sp((a-f)*o)],c=Me(P("floor"),"Erdgeschoss",0),u=[],d=[];for(let h of e){let f=h.points.map(l);if(h.closed&&f.length>=3)u.push({id:P("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:P("wall"),a:f[g],b:f[g+1]})}c.rooms=u,c.walls=d;let p=Pt();return p.floors=[c],{building:Oe(p),report:{floors:1,rooms:u.length,openings:0,walls:d.length,furniture:0}}}var Qe=t=>Math.round(t*100)/100;function nw(t,e){let n=t.category;return typeof n=="string"?n:n&&typeof n=="object"?Object.keys(n)[0]??e:e}function rw(t,e){let n=t,r=n?.transform,i=n?.dimensions;if(!n||!Array.isArray(r)||r.length<16||!Array.isArray(i)||i.length<3)return null;let o=a=>Number(a),s=Math.hypot(o(r[0]),o(r[2]));return![...r.slice(0,16),...i.slice(0,3)].every(a=>Number.isFinite(o(a)))||s<1e-6?null:{centre:[o(r[12]),o(r[13]),o(r[14])],dir:[o(r[0])/s,o(r[2])/s],size:[o(i[0]),o(i[1]),o(i[2])],kind:nw(n,e)}}var nr=(t,e,n)=>(Array.isArray(t[e])?t[e]:[]).map(r=>rw(r,n)).filter(r=>!!r);function iw(t){if(t.length<3)return null;let e=t.map(l=>{let c=l.size[0]/2;return[[l.centre[0]-l.dir[0]*c,l.centre[2]-l.dir[1]*c],[l.centre[0]+l.dir[0]*c,l.centre[2]+l.dir[1]*c]]}),n=(l,c)=>Math.hypot(l[0]-c[0],l[1]-c[1]),r=.4,i=new Set([0]),o=[e[0][0]],s=[0],a=e[0][1];for(;i.sizer?null:(o[0]=[(a[0]+o[0][0])/2,(a[1]+o[0][1])/2],{points:o,edgeWall:s})}function lp(t){let e=[],n=[];for(let a of t){let l=a.size[0]/2;for(let c of[-1,1])e.push(a.centre[0]+c*a.dir[0]*l),n.push(a.centre[2]+c*a.dir[1]*l)}let[r,i,o,s]=[Math.min(...e),Math.max(...e),Math.min(...n),Math.max(...n)];return[[r,o],[i,o],[i,s],[r,s]]}function ow(t,e,n){let[r,i]=[n[0]-e[0],n[1]-e[1]],o=Math.hypot(r,i)||1e-9,s=Math.min(o,Math.max(0,((t[0]-e[0])*r+(t[1]-e[1])*i)/o));return{dist:Math.hypot(t[0]-(e[0]+r/o*s),t[1]-(e[1]+i/o*s)),along:s,length:o}}var sw={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 cp(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)&&nr(r,"walls","wall").length>0)}function up(t){let e=t,r=(Array.isArray(e.rooms)?e.rooms:[e]).filter(b=>b&&typeof b=="object").map(b=>({walls:nr(b,"walls","wall"),doors:[...nr(b,"doors","door"),...nr(b,"openings","opening")],windows:nr(b,"windows","window"),objects:nr(b,"objects","object")})).filter(b=>b.walls.length);if(!r.length)throw new Error("roomplan_empty");let i=r.flatMap(b=>b.walls),o=Math.min(...i.map(b=>b.centre[1]-b.size[1]/2)),s=r.map(b=>iw(b.walls)),a=r.flatMap((b,y)=>s[y]?.points??lp(b.walls)),[l,c]=[Math.min(...a.map(b=>b[0]))-.5,Math.min(...a.map(b=>b[1]))-.5],u=([b,y])=>[Qe(b-l),Qe(y-c)],d=Me(P("floor"),"Erdgeschoss",0);d.height=Qe(Math.max(2.2,Math.min(4,Math.max(...i.map(b=>b.size[1])))));let p=[],h=[];r.forEach((b,y)=>{let w=(s[y]?.points??lp(b.walls)).map(u),x={id:P("room"),name:`Raum ${y+1}`,area_id:null,points:w,floor_material:"wood",panel:[]};p.push(x);for(let k of[...b.doors.map(M=>({v:M,window:!1})),...b.windows.map(M=>({v:M,window:!0}))]){let M=[k.v.centre[0]-l,k.v.centre[2]-c],A=null;if(w.forEach((D,N)=>{let V=ow(M,D,w[(N+1)%w.length]);V.dist<=.6&&(!A||V.dist1.4?2:1,swing:"in",...L?{style:"passage"}:{},cover:null,contact:null,contact2:null,tilt:null})}for(let k of b.objects){let M=sw[k.kind];if(!M)continue;let[A,T,F]=[k.size[0],k.size[2],k.size[1]];A<.1||T<.1||h.push({id:P("f"),type:M,x:Qe(k.centre[0]-l),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(T),h:Qe(F),variant:null,entity:null,power:null})}}),d.rooms=p,d.furniture=h;let f=Pt();f.floors=[d];let g=r.reduce((b,y)=>b+y.objects.length,0)-h.length;return{building:Oe(f),report:{floors:1,rooms:p.length,openings:d.openings.length,walls:0,furniture:g}}}var bi=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&"ref"in t;function aw(t){let e=0,n=()=>{for(;t[e]===" ";)e++;let i=t[e];if(i==="("){e++;let l=[];for(;eString.fromCharCode(...(n.match(/.{4}/g)??[]).map(r=>parseInt(r,16)))).replace(/\\S\\(.)/g,(e,n)=>String.fromCharCode(n.charCodeAt(0)+128))}function cw(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:aw(r[3])});return e}var dp={x:0,y:0,z:0,c:1,s:0},hp=(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 pp(t){let e=cw(t);if(!e.size)throw new Error("ifc_empty");let n=k=>bi(k)?e.get(k.ref):void 0,r=k=>typeof k=="number"?k:NaN,i=k=>(n(k)?.args[0]??[]).map(M=>r(M)),o=[...e.values()].find(k=>k.type==="IFCSIUNIT"&&k.args[1]===".LENGTHUNIT."),s=o?{".MILLI.":.001,".CENTI.":.01,".DECI.":.1}[String(o.args[2])]??1:1,a=k=>{let M=n(k);if(!M)return dp;let[A=0,T=0,F=0]=i(M.args[0]),L=n(M.type==="IFCAXIS2PLACEMENT3D"?M.args[2]:M.args[1]),[D=1,N=0]=(L?.args[0]??[]).map(Y=>r(Y)),V=Math.hypot(D,N)||1;return{x:A||0,y:T||0,z:F||0,c:D/V,s:N/V}},l=(k,M=0)=>{let A=n(k);return!A||A.type!=="IFCLOCALPLACEMENT"||M>30?dp:hp(l(A.args[0],M+1),a(A.args[1]))},c=k=>{for(let M of n(k)?.args[2]??[])for(let A of n(M)?.args[3]??[]){let T=n(A);if(T?.type!=="IFCEXTRUDEDAREASOLID")continue;let F=n(T.args[0]),L=hp(a(T.args[1]),a(F?.args[2])),D=[];if(F?.type==="IFCRECTANGLEPROFILEDEF"){let[N,V]=[r(F.args[3])/2,r(F.args[4])/2];D=[[-N,-V],[N,-V],[N,V],[-N,V]]}else if(F?.type==="IFCARBITRARYCLOSEDPROFILEDEF"){let N=n(F.args[2]);N?.type==="IFCPOLYLINE"&&(D=(N.args[0]??[]).map(V=>i(V)))}if(D=D.filter(N=>Number.isFinite(N[0])&&Number.isFinite(N[1])),D.length>3&&Math.hypot(D[0][0]-D[D.length-1][0],D[0][1]-D[D.length-1][1])<1e-6&&D.pop(),D.length>=3)return D.map(([N,V])=>[L.x+L.c*N-L.s*V,L.y+L.s*N+L.c*V])}return null},u=new Map;for(let[,k]of e){if(k.type==="IFCRELAGGREGATES"&&bi(k.args[4]))for(let M of k.args[5]??[])bi(M)&&u.set(M.ref,k.args[4].ref);if(k.type==="IFCRELCONTAINEDINSPATIALSTRUCTURE"&&bi(k.args[5]))for(let M of k.args[4]??[])bi(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 T=l(M.args[5]),F=A.map(([D,N])=>[(T.x+T.c*D-T.s*N)*s,(T.y+T.s*D+T.c*N)*s]),L=String(M.args[7]||M.args[2]||"")||`Raum ${p.length+1}`;p.push({storey:u.get(k)??null,name:L,ring:F})}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])),b=k=>Math.round(k*1e3)/1e3,y=[],v=new Map;if(d.filter(k=>p.some(M=>M.storey===k.id)).forEach((k,M)=>{let A=Me(P("floor"),k.name??`Etage ${M+1}`,Number.isFinite(k.elevation)?b(k.elevation):M*2.8);y.push(A),v.set(k.id,A)}),p.some(k=>k.storey===null||!v.has(k.storey))){let k=Me(P("floor"),y.length?"Weitere R\xE4ume":"Erdgeschoss",y.length?y[y.length-1].elevation+2.8:0);y.push(k),v.set(null,k)}y.forEach((k,M)=>{let A=y[M+1];A&&A.elevation-k.elevation>1.8&&(k.height=b(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:P("room"),name:k.name,area_id:null,points:k.ring.map(([A,T])=>[b(A-f),b(g-T)]),floor_material:"wood",panel:[]});let x=Pt();return x.floors=y,{building:Oe(x),report:{floors:y.length,rooms:p.length,openings:0,walls:0,furniture:0}}}var mp="nextfloor",uw="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",fp=new RegExp(`^(?:${uw})\\.[a-z0-9_]+$`),dw=/^[0-9a-f]{32}$/,hw=new Set(["area_id","ha_floor"]),pw=new Set(["sub_areas"]),fw=new Set(["tap","show_when","pictures","moods"]);function al(t){if(typeof t=="string")return fp.test(t)||dw.test(t)?null:t;if(Array.isArray(t))return t.map(e=>al(e)).filter(e=>e!==null);if(t&&typeof t=="object"){let e={};for(let[n,r]of Object.entries(t))fp.test(n)||fw.has(n)||(hw.has(n)||pw.has(n)?e[n]=null:e[n]=al(r));return e}return t}var mw=["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 gp(t){let e=structuredClone(t),n={};for(let i of mw)e.settings?.[i]!==void 0&&(n[i]=e.settings[i]);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 i of e.floors){i.background=null,i.placements=[],i.power_entity=null,i.utility_meters=null,i.ha_floor=null;for(let o of i.rooms)Object.assign(o,{area_id:null,sub_areas:null,panel:[],hidden:[],no_state:[]});i.furniture.forEach(o=>{Object.assign(o,{entity:null,power:null}),delete o.effect_animations,o.picture&&!(o.picture.startsWith("image:")||o.picture.startsWith("https://"))&&(o.picture=null)}),i.openings.forEach(o=>Object.assign(o,{cover:null,contact:null,tilt:null}))}return al(e)}function _p(t,e){return{format:mp,version:1,exported_at:new Date().toISOString(),building:e?gp(t):structuredClone(t)}}var gw=t=>!!t&&(t.version===1||t.version===void 0)&&Array.isArray(t.floors)&&t.floors.every(e=>!!e&&typeof e=="object"),_w="https://therealmrbk.github.io/NextFloor/preview/?shared&noshowcase";function bp(t,e,n,r,i=_w){let o=new Set(t.floors.flatMap(c=>c.furniture.map(u=>u.type)).filter(c=>c.startsWith("pack:")).map(c=>c.split(":")[1])),s={building:gp(t),packs:e.filter(c=>!c.builtin&&o.has(c.id))},a=JSON.stringify(s).replace(/c.replace(/[&<>"]/g,u=>({"&":"&","<":"<",">":">",'"':"""})[u]);return` ${l(n)}