From 382d6e04f2b61c780ca8df07469d59e75e5424a7 Mon Sep 17 00:00:00 2001 From: jhartworks Date: Thu, 19 Nov 2026 09:46:31 +0100 Subject: [PATCH] fix: separate hierarchy management from selected building editing --- CHANGELOG.md | 2 + .../nextfloor/frontend/nextfloor-editor.js | 1579 +++++++++-------- .../nextfloor/frontend/nextfloor.js | 2 +- frontend/src/components/editor.ts | 153 +- frontend/src/components/editor/canvas/plan.ts | 3 +- .../components/editor/editor-context.test.ts | 44 + .../src/components/editor/editor-context.ts | 48 + frontend/src/components/editor/forms/floor.ts | 10 +- frontend/src/components/editor/forms/room.ts | 10 +- .../src/components/editor/forms/topology.ts | 45 - .../components/editor/hierarchy-manager.ts | 75 + frontend/src/components/editor/styles.ts | 10 + frontend/symcon-editor-context-smoke.mjs | 131 ++ frontend/symcon-topology-smoke.mjs | 23 +- symcon/NextFloor/assets/nextfloor-designer.js | 4 +- symcon/NextFloor/assets/nextfloor-editor.js | 1579 +++++++++-------- symcon/README.md | 27 +- symcon/library.json | 6 +- 18 files changed, 2103 insertions(+), 1648 deletions(-) create mode 100644 frontend/src/components/editor/editor-context.test.ts create mode 100644 frontend/src/components/editor/editor-context.ts delete mode 100644 frontend/src/components/editor/forms/topology.ts create mode 100644 frontend/src/components/editor/hierarchy-manager.ts create mode 100644 frontend/symcon-editor-context-smoke.mjs diff --git a/CHANGELOG.md b/CHANGELOG.md index 34339bd..811f7c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ All notable changes to NextFloor, newest first. Every release lists what is **Ad ### Fixed +- **Unambiguous editor hierarchy (Symcon 0.4.1):** Move location, branch and building management into a separate Hierarchy dialog. Choose the building above the plan and add storeys only inside that selection; leave the right panel for existing floor, room and device properties. Group the room list by its linked native Symcon category, retain explicit room-name adoption and show the selected room's floor path. Building or metadata selection never reassigns floors or creates a storey. Preserve an empty building selection across refreshes and last-storey deletion, clear old plan selections on navigation and reject stale room edits. Replace the implicit floor-assignment dropdown with a dialog that names and captures the selected floor and changes its parent only when explicitly applied. Keep floor reordering and the lower-floor tracing layer inside the selected building or location's outside plan. Preserve legacy IDs, data points, per-location outdoors and permission keys. + - **Symcon version notices (Symcon 0.3.3):** Hide Home Assistant restart/companion-cache version banners in the Symcon designer, label the version tooltip for the Symcon module and rebuild the designer with the current release version. Actual load/save errors remain visible. - **Native account form (Symcon 0.3.2):** Serialize every row of Symcon's iterable form List variables before saving rights, fixing rejected or lost room/device/object grants. Move the password and reset action below the user name. Reload all three tables and their target choices on account changes, preserving missing plan targets for their owner and clearing password/new-user inputs. Correct the designer button and documentation: `link:` opens a browser, whereas IPSView's internal Pro Console tab is a dedicated console integration, not a general module API. diff --git a/custom_components/nextfloor/frontend/nextfloor-editor.js b/custom_components/nextfloor/frontend/nextfloor-editor.js index cf122fd..a443e0a 100644 --- a/custom_components/nextfloor/frontend/nextfloor-editor.js +++ b/custom_components/nextfloor/frontend/nextfloor-editor.js @@ -1,7 +1,7 @@ /*! NextFloor, MIT licence. Includes three.js (MIT) and Lit (BSD-3-Clause); see LICENSE and THIRD_PARTY_NOTICES.md */ -var $={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` +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 An=t=>t?`${t.kind}:${t.id}`:"";function As(t){return t?t.outdoor_location_id?{kind:"outside",id:t.outdoor_location_id}:t.building_id?{kind:"building",id:t.building_id}:null:null}function Fs(t,e){return!!e&&!!t.topology&&(e.kind==="building"?t.topology.buildings.some(n=>n.id===e.id):t.topology.locations.some(n=>n.id===e.id)&&t.floors.some(n=>n.outdoor_location_id===e.id))}function $r(t,e){return t.topology?Fs(t,e)?t.floors.filter(n=>e.kind==="outside"?n.outdoor_location_id===e.id:!n.outdoor_location_id&&n.building_id===e.id):[]:t.floors}function Hc(t,e){return{scope:e,floorId:$r(t,e)[0]?.id??null}}function Lc(t,e){if(!t.topology)return{scope:null,floorId:t.floors.some(i=>i.id===e.floorId)?e.floorId:t.floors[0]?.id??null};let n=Fs(t,e.scope)?e.scope:As(t.floors.find(i=>i.id===e.floorId)??t.floors[0])??(t.topology.buildings[0]?{kind:"building",id:t.topology.buildings[0].id}:null),r=$r(t,n);return{scope:n,floorId:r.some(i=>i.id===e.floorId)?e.floorId:r[0]?.id??null}}function Ts(t){let e=t.topology;return e?[...e.buildings.map(n=>{let r=e.branches.find(o=>o.id===n.branch_id),i=e.locations.find(o=>o.id===r?.location_id);return[`building:${n.id}`,[i?.name,r?.name,n.name].filter(Boolean).join(" / ")]}),...e.locations.filter(n=>t.floors.some(r=>r.outdoor_location_id===n.id)).map(n=>[`outside:${n.id}`,`${n.name} / Au\xDFen`])]:[]}function zs(t,e){let n=e.indexOf(":"),r=e.slice(0,n),i=e.slice(n+1),o=r==="building"||r==="outside"?{kind:r,id:i}:null;return Fs(t,o)?o:null}function Cc(t,e,n,r){let i=t.floors.find(o=>o.id===n);return e!==n||!i||i.outdoor_location_id||!t.topology?.buildings.some(o=>o.id===r)||i.building_id===r?!1:(i.building_id=r,!0)}var Ni=globalThis,Bi=Ni.ShadowRoot&&(Ni.ShadyCSS===void 0||Ni.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ps=Symbol(),Nc=new WeakMap,Sr=class{constructor(e,n,r){if(this._$cssResult$=!0,r!==Ps)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(Bi&&e===void 0){let r=n!==void 0&&n.length===1;r&&(e=Nc.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Nc.set(n,e))}return e}toString(){return this.cssText}},Bc=t=>new Sr(typeof t=="string"?t:t+"",void 0,Ps),J=(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,Ps)},Vc=(t,e)=>{if(Bi)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let r=document.createElement("style"),i=Ni.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=n.cssText,t.appendChild(r)}},Is=Bi?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let r of e.cssRules)n+=r.cssText;return Bc(n)})(t):t;var{is:Ib,defineProperty:Db,getOwnPropertyDescriptor:Ob,getOwnPropertyNames:Hb,getOwnPropertySymbols:Lb,getPrototypeOf:Cb}=Object,Vi=globalThis,Wc=Vi.trustedTypes,Nb=Wc?Wc.emptyScript:"",Bb=Vi.reactiveElementPolyfillSupport,Mr=(t,e)=>t,Ds={toAttribute(t,e){switch(e){case Boolean:t=t?Nb: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}},jc=(t,e)=>!Ib(t,e),Kc={attribute:!0,type:String,converter:Ds,reflect:!1,useDefault:!1,hasChanged:jc};Symbol.metadata??=Symbol("metadata"),Vi.litPropertyMetadata??=new WeakMap;var yt=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=Kc){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&&Db(this.prototype,e,i)}}static getPropertyDescriptor(e,n,r){let{get:i,set:o}=Ob(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)??Kc}static _$Ei(){if(this.hasOwnProperty(Mr("elementProperties")))return;let e=Cb(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=[...Hb(n),...Lb(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(Is(i))}else e!==void 0&&n.push(Is(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 Vc(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:Ds).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:Ds;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??jc)(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){}};yt.elementStyles=[],yt.shadowRootOptions={mode:"open"},yt[Mr("elementProperties")]=new Map,yt[Mr("finalized")]=new Map,Bb?.({ReactiveElement:yt}),(Vi.reactiveElementVersions??=[]).push("2.1.2");var Hs=globalThis,Gc=t=>t,Wi=Hs.trustedTypes,Uc=Wi?Wi.createPolicy("lit-html",{createHTML:t=>t}):void 0,Ls="$lit$",vt=`lit$${Math.random().toFixed(9).slice(2)}$`,Cs="?"+vt,Vb=`<${Cs}>`,tn=document,Rr=()=>tn.createComment(""),Ar=t=>t===null||typeof t!="object"&&typeof t!="function",Ns=Array.isArray,Qc=t=>Ns(t)||typeof t?.[Symbol.iterator]=="function",Os=`[ +\f\r]`,Er=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Zc=/-->/g,qc=/>/g,Qt=RegExp(`>|${Os}(?:([^\\s"'>=/]+)(${Os}*=${Os}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),Yc=/'/g,Xc=/"/g,ed=/^(?:script|style|textarea|title)$/i,Bs=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),m=Bs(1),E=Bs(2),E1=Bs(3),tt=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),Jc=new WeakMap,en=tn.createTreeWalker(tn,129);function td(t,e){if(!Ns(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Uc!==void 0?Uc.createHTML(e):e}var nd=(t,e)=>{let n=t.length-1,r=[],i,o=e===2?"":e===3?"":"",s=Er;for(let a=0;a"?(s=i??Er,u=-1):d[1]===void 0?u=-2:(u=s.lastIndex-d[2].length,c=d[1],s=d[3]===void 0?Qt:d[3]==='"'?Xc:Yc):s===Xc||s===Yc?s=Qt:s===Zc||s===qc?s=Er:(s=Qt,i=void 0);let h=s===Qt&&t[a+1].startsWith("/>")?" ":"";o+=s===Er?l+Vb:u>=0?(r.push(c),l.slice(0,u)+Ls+l.slice(u)+vt+h):l+vt+(u===-2?a:h)}return[td(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,d]=nd(e,n);if(this.el=t.createElement(c,r),en.currentNode=this.el.content,n===2||n===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(i=en.nextNode())!==null&&l.length0){i.textContent=Wi?Wi.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=nn(this,e,n,0),s=!Ar(e)||e!==this._$AH&&e!==tt,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 Fn(e.insertBefore(Rr(),o),o,void 0,n??{})}return i._$AI(t),i};var Vs=globalThis,q=class extends yt{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=id(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return tt}};q._$litElement$=!0,q.finalized=!0,Vs.litElementHydrateSupport?.({LitElement:q});var Kb=Vs.litElementPolyfillSupport;Kb?.({LitElement:q});(Vs.litElementVersions??=[]).push("4.2.2");var ld=[],qi=new Map,jb=0,he=(t,e)=>`pack:${t}:${e}`,wt=t=>t.startsWith("pack:");function Ws(t){ld=t,qi=new Map;for(let e of t)for(let n of e.items)qi.set(he(e.id,n.id),n);jb+=1}var zr=()=>ld;var Gb={};function U(t){if(!wt(t))return;let e=qi.get(t);if(e)return e;let[,n,...r]=t.split(":"),i=Gb[n];return i?qi.get(he(i,r.join(":"))):void 0}var Ub=.22;function od(t,e,n,r){let i=Math.min(Ub,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 Tr(t,e,n,r,i){return[od(t*r,n*r,r,i)/i,od(e*r,n*r,r,i)/i]}var sd=new WeakMap;function cd(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=sd.get(t),c=l?.get(a);if(c)return c;let d=t.parts.map(u=>{if(u.shape==="sweep")return u;let[p,h]=Tr(u.x-u.w/2,u.x+u.w/2,-.5,i,e),[f,g]=Tr(u.z-u.d/2,u.z+u.d/2,-.5,o,n),[b,y]=Tr(u.y,u.y+u.h,0,s,r);if(u.rot)return{...u,x:(p+h)/2,z:(f+g)/2,w:u.w*i/e,d:u.d*o/n,y:b,h:y-b};let v={...u,x:(p+h)/2,z:(f+g)/2,w:h-p,d:g-f,y:b,h:y-b};if(u.shape==="loft"){let[w,k,x,M]=[u.tx??u.x,u.tz??u.z,u.tw??u.w,u.td??u.d],[A,T]=Tr(w-x/2,w+x/2,-.5,i,e),[F,L]=Tr(k-M/2,k+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||sd.set(t,l=new Map),l.size>32&&l.clear(),l.set(a,d),d}var Ks=t=>!!t?.parts.some(e=>e.move);var dd=t=>U(t)?.parts.find(e=>e.screen),ad=.06;function ud(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>=ad&&s>=ad})}function ut(t){return nt[t]??U(t)?.size??[.6,.6,.8]}function Tt(t){let e=U(t);return yd.has(t)||!!e?.electric||!!e?.light||!!e?.climate}var hd=t=>!!U(t)?.parts.some(e=>e.picture),Tn=t=>!!U(t)?.climate;function pd(t,e){return t.name[e.split("-")[0]]??t.name.en??Object.values(t.name)[0]??t.id}var Zb={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 fd(t,e){if(e.split("-")[0]==="de")return t.name;let n=/^nextfloor\.(.+)$/.exec(t.id)?.[1];return n&&Zb[n]||t.name}function zt(t,e){return e.mount_y!=null?e.mount_y:Yb(t,e)+(qb(e)?0:_d(t,e.x,e.z))}var qb=t=>t.type==="led_strip"||U(t.type)?.mount==="ceiling";function Yb(t,e){if(e.type==="lamp_wall")return md;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 gd(e);switch(n.mount){case"surface":return bd(t,e.x,e.z);case"wall":return n.wall_y??1;case"ceiling":return Math.max(0,Yi(t,e)-e.h);default:return 0}}function js(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 vd=t=>[t.kind,t.floorId,t.id].filter(Boolean).join(":");function wd(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 Xi(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 xd(t,e){let n=t.floors.find(i=>i.outdoor_location_id===e);if(n)return n;let r={...Ee(P("outside"),"Au\xDFen",0),outdoor_location_id:e,building_id:null};return t.floors.push(r),r}function Gs(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 Xb(t){let e=(i,o,s,a=[],l=a.flatMap(d=>d.floorIds),c)=>{let d={kind:i,...o?{id:o}:{},...c?{floorId:c.floorId}:{}};return{key:vd(d),name:s,selection:d,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,d)=>d.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 kd(t,e){let n=Xb(t),r=vd(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 $d(t,e,n=!1){if(!t.topology||e.kind==="all")return t.floors;let r=kd(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 Pr(t,e){return t.topology?kd(t,Gs(t,e.id)).slice(1).map(n=>n.name).join(" / "):e.name}var xt=["electricity","water","gas","heating","cooling"],Sd=["condition","temperature","humidity","pressure","wind_speed","wind_gust_speed","wind_bearing","cloud_coverage","precipitation","precipitation_total","illuminance","uv_index","visibility","snow","fog","lightning"],Md=["turn","slide","top"],Ed=["always","active","no_power","never"],Rd=1.3,Ji=(t,e=new Date().toISOString().slice(0,10))=>!!t.due&&t.due<=e,Ad=["gable","hip","halfhip","pyramid","mansard","pent","flat","parapet"],Fd=["brick","round","wide","steel"],Qi=["navigate","more_info","service","fire_dom_event"];function eo(t,e,n){return t?e?!!n.lock_plan:!!t.locked:!1}var Td=["rain","snow","fog","clouds","lightning","sky"],zd=["rain","snow","clouds","lightning","sky"],Pd=["lawn","terrace","path","driveway","pavers","stepping_stones","natural_stone","street","sidewalk","gravel","river","stream","pool","bed","wild","hedge","fence","pergola"],Us={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 Zs(t){return t==="hedge"||t==="fence"||t==="pergola"}var Id=["x","-x","z","-z"];function Jb(t,e,n){let r=t.slope??0;if(!r||t.type==="pool")return 0;let i=t.slope_dir??"x",o=(c,d)=>i==="x"?c:i==="-x"?-c:i==="z"?d:-d,s=1/0,a=-1/0;for(let[c,d]of t.points){let u=o(c,d);s=Math.min(s,u),a=Math.max(a,u)}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 Qb(t,e,n,r){return Dd(t)+(e.offset??0)+Us[e.type]-Jb(e,n,r)}function Dd(t){return t.elevation>.3?0:-.2}function Od(t,e,n){let r=(t.outdoor??[]).filter(o=>!Zs(o.type)&&o.type!=="pool"&&C([e,n],o.points)),i=[...r].reverse().find(o=>o.cut)??r[0];return i?Qb(t,i,e,n):Dd(t)}var qs=t=>t.cut??(t.type==="pool"||t.type==="river"||t.type==="stream");function to(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 Hd=30,Ld={meter:null,grid:null,grid_invert:!1,solar:null,battery:null,battery_invert:!1,battery_soc:null,consumption:null,tariff:null},Cd=["wood","oak","tiles","carpet","stone","concrete"],Nd={type:"none",pitch:35,overhang:.4},no="#d6cfc2",ro="#e8e3da",Bd={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...Nd}};function Pt(){return{version:1,floors:[],settings:{...Bd},energy:{...Ld},presence:[]}}function Ee(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 ey=2.75;function Vd(t,e){if(e!=null&&Number.isFinite(e))return Math.round(e*ey*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 Wd(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,d=s+Math.floor(l/3)*3.5;return{id:n(),name:a.name,area_id:a.area_id,points:[[c,d],[c+4,d],[c+4,d+3],[c,d+3]],floor_material:"wood"}})}function Kd(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,d=t.z-a*(t.w/2)*s-l*(t.d/2)*o,u=n[0]-c,p=n[1]-d,h=y=>Math.max(.1,Math.round(y/r)*r),f=h((u*o+p*s)*a),g=h((-u*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(d+a*(f/2)*s+l*(g/2)*o),w:b(f),d:b(g)}}var io=["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"],jd={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"],Gd=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"]),md=1.75;function oo(t){return Ys.has(t.type)||["stairwell","parking"].includes(t.type)?!1:U(t.type)?.mount!=="ceiling"}function de(t){return Gd.has(t)||!!U(t)?.light}var ty=new Set(["table","table_round","coffee_table","desk","nightstand","sideboard","dresser","kitchen","island","worktop","tv_board","dishwasher","washer","dryer"]);function Ud(t,e,n,r=0){let i=ue(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 gd(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 Ys=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function Zd(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 Xs=t=>t?.floor_offset&&Number.isFinite(t.floor_offset)?t.floor_offset:0;function _d(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&i.floor_offset&&C([e,n],i.points));return Xs(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 Yi=(t,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:ht(t,e.x,e.z);function bd(t,e,n){let r=0;for(let i of t.furniture)!(ty.has(i.type)||U(i.type)?.surface)||!C([e,n],ta(i))||(r=Math.max(r,i.h));return r}var yd=new Set([...Gd,"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"]),nt={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 Js=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],Qs=["standard","bars","glass_wall"],so=new Set(["interior","front"]);function on(t,e){return t.type==="door"?t.style&&Js.includes(t.style)?t.style:e?"front":"interior":t.style&&Qs.includes(t.style)?t.style:"standard"}function qd(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 d=o-.5;if(l+c>d){let p=Math.max(0,d)/(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 ea(t){return t==="front"||t==="front_glass"||t==="sidelight"||t==="sidelights"}var Pn={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 In(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&&ea(t.style)?"front":e?"door_double":"door":t.sill<.1?e?"terrace_double":"terrace":e?"window_double":"window"}function Oe(t){t.energy={...Ld,...t.energy??{}},t.presence=t.presence??[],t.version=1,t.settings={...Bd,...t.settings,roof:{...Nd,...t.settings?.roof??{}}},t.floors.forEach((e,n)=>{let r=Ee(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]=nt[o],c=`lamp_${i.entity_id.slice(6).replace(/[^A-Za-z0-9_\-.]/g,"_")}`.slice(0,54),d=c,u=1;for(;e.furniture.some(p=>p.id===d);)d=`${c}_${u++}`;e.furniture.push({id:d,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 ny(t),t.topology&&Xi(t),t}function ny(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 be(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 ue(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 ta(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 ao={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 fe=J` :host { --nf-text: var(--primary-text-color, #e1e1e1); --nf-muted: var(--secondary-text-color, #9b9b9b); @@ -29,7 +29,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f font-family: var(--nf-font); color: var(--nf-text); } -`,SS=ee` +`,t$=J` :host([readable]) { --secondary-text-color: var(--primary-text-color, #e1e1e1); --divider-color: color-mix(in srgb, var(--primary-text-color, #e1e1e1) 40%, transparent); @@ -40,7 +40,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f :host([readable]) .nf-overlay { zoom: 1.2; } -`,pt=ee` +`,pt=J` /* a group of switches: one rounded pill, the active one tinted with the accent */ .nf-seg { display: inline-flex; @@ -203,7 +203,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f 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`
(...e)=>({_$litDirective$:t,values:e}),It=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 Ir=class extends It{constructor(e){if(super(e),this.it=_,e.type!==On.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===tt)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:[]}}};Ir.directiveName="unsafeHTML",Ir.resultType=1;var Yd=sn(Ir);var ra=t=>t.slice(0,t.indexOf(".")),ry={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"},ee=t=>ry[ra(t)]??null,ia=["light","cover","climate","media","switch","fan","lock","binary","sensor","scene","script"];var Xd=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 Jd=t=>!!t&&t.entity_id.startsWith("sensor.")&&t.attributes.device_class==="enum";var Qd=t=>Math.min(1,Math.max(0,t));function iy(t){let e=Qd((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 na(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(Qd(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:iy(n.color_temp_kelvin),level:r}:{color:[1,.71,.28],level:r}}function eu(t,e,n){let r=na(t,n);if(r)return r;for(let i of e){let o=na(i);if(o)return{color:o.color,level:o.level*.6}}return null}function lo(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 oa=t=>t.trim().replace(/^\/local\/www\//i,"/local/"),sa=t=>/^(https:\/\/|\/local\/|\/hacsfiles\/)\S+\.m?js(\?\S*)?$/i.test(t.trim());var sy=globalThis,nu=sy.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},aa=nu.plugins,tu=nu.listeners;var ay=5;function ru(t,e){t.errors.lengthtu.delete(t)}var la=()=>[...aa.values()].map(t=>t.status),iu=()=>[...aa.values()].flatMap(t=>Object.keys(t.plugin.lightAnimations??{}));function*uo(t,e){for(let{plugin:n,status:r}of aa.values())for(let i of n.devices??[]){let o=!1;try{o=i.match(t,e)}catch(s){ru(r,s)}o&&(yield{device:i,status:r})}}function ho(t,e){for(let{device:n}of uo(t,e))return n.kind??"sensor";return null}function ou(t,e){let n=t.states[e];if(!n)return null;let r=ly({hass:t,entityId:e,state:n})?.icon?.trim();return r&&/^mdi:[a-z0-9-]+$/i.test(r)?r:null}function ly(t){let e=null;for(let{device:n,status:r}of uo(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){ru(r,i)}return e}function po(t,e){return t?typeof t=="string"?t:t[e]??t[e.split("-")[0]]??t.en??Object.values(t)[0]??"":""}function su(t,e){let n=[];for(let{device:r,status:i}of uo(t,e))r.settings?.length&&n.push({pluginId:i.id,name:i.name,settings:r.settings});return n}function au(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 lu(t,e){for(let{device:n}of uo(t,e))if(n.floorWedge)return!0;return!1}var cy=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"]),dy=new Set(["m\xB3","m3","L","l","kWh","Wh","MWh","lx"]),uy=new Set(["door","window","opening","garage_door","motion","occupancy","presence","smoke","moisture","gas","carbon_monoxide"]),hy=new Set(["battery","signal_strength","timestamp","date","duration","data_rate","data_size","frequency","enum"]);function Ot(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 du=(t,e)=>{let n=t.entities?.[e];return!!(n?.hidden||n?.entity_category)},je=(t,e)=>ee(e)??ho(e,t.states[e]);function cu(t,e){let n=t.states[e];if(!n||du(t,e))return!1;if(ho(e,n)!==null)return!0;let r=ee(e);if(!r)return!1;let i=n.attributes.device_class;return e.startsWith("event.")?!i||i==="button"||i==="doorbell":r==="sensor"?i?cy.has(i):dy.has(String(n.attributes.unit_of_measurement??"")):r==="binary"?i?uy.has(i):!!t.entities?.[e]?.area_id:!0}function py(t,e){let n=t.states[e];return ee(e)!=="sensor"||!n?.attributes.unit_of_measurement||du(t,e)||hy.has(String(n.attributes.device_class??""))?!1:Number.isFinite(Number(n.state))||He(n)}var mo=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power",ca=null;co(()=>ca=null);function da(t,e){let n=t.get(e);return n||t.set(e,n=[]),n}function fy(t){let e=new Map,n=new Map,r=new Map,i=new Map,o=[],s=d=>{(cu(t,d)||py(t,d))&&Dt(je(t,d))&&o.push(d)};for(let[d,u]of Object.entries(t.entities??{})){let p=u.device_id;p&&u.area_id&&(i.get(p)??i.set(p,new Set).get(p)).add(u.area_id),p&&mo(t,d)&&da(n,p).push(d),p&&!u.hidden&&!u.entity_category&&(r.get(p)??r.set(p,new Set).get(p)).add(ra(d));let h=Ot(t,d);h===null?s(d):cu(t,d)&&da(e,h).push(d)}if(t.entities)for(let d of Object.keys(t.states))t.entities[d]||s(d);let a=ia.indexOf("binary")-.5,l=d=>{let u=ee(d),p=u?ia.indexOf(u):a;return p>a&&ho(d,t.states[d])!==null?a:p};o.sort((d,u)=>l(d)-l(u)||B(t,d).localeCompare(B(t,u)));for(let[d,u]of e){let p=t.areas?.[d]?.name;u.sort((h,f)=>l(h)-l(f)||B(t,h,p).localeCompare(B(t,f,p)))}let c=new Set;for(let[d,u]of i)u.size>1&&c.add(d);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 Hn(t){let e=ca;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:ca=fy(t)}function we(t,e){let n=fo(t,e.area_id);return e.sub_areas?.length?[...new Set([...n,...e.sub_areas.flatMap(r=>fo(t,r))])]:n}function fo(t,e){return!e||!t.entities?[]:Hn(t).byArea.get(e)??[]}function uu(t,e){if(!t.entities)return[];let n=[];for(let[r,i]of Hn(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 hu=t=>t.entities?Hn(t).withoutArea:[],ua=(t,e)=>!!t.entities&&Hn(t).hubs.has(e),go=(t,e)=>t.entities?Hn(t).powerByDevice.get(e)??[]:[];function Ln(t,e){let n=new Map;for(let i of e)da(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 _o=(t,e)=>Ln(t,e).map(n=>n.primary),my={temperature:"temperature",humidity:"humidity",co2:"carbon_dioxide",illuminance:"illuminance"};function ha(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===my[n]}var gy=new Set(["climate","water_heater","switch","button","camera","media_player","vacuum","light","fan","lawn_mower"]),_y=["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"],by=new RegExp(`(${_y.join("|")})`,"i");function pa(t,e){let n=t.entities?.[e]?.device_id,r=n&&!ua(t,n)?Hn(t).domainsByDevice.get(n):void 0;return r&&[...r].some(i=>gy.has(i))?!1:!by.test(`${e} ${t.states[e]?.attributes.friendly_name??""}`)}function pu(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([...we(t,n).filter(c=>!a.has(c)),...s])].filter(c=>c.startsWith("sensor.")&&ha(t,c,r)&&pa(t,c))}function fu(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 bo(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 yo(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=fu(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 yy=new Set([void 0,"shutter","blind","awning","shade","curtain","window"]),vy=new Set(["garage","gate"]),wy=new Set(["window","opening"]);function Dr(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 mu=(t,e)=>t==="none"?null:t??e??null,Ht=t=>t&&t!=="none"?t:null;function Lt(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=we(t,i),a=g=>t.states[g]?.attributes.device_class,l=g=>s.filter(b=>ee(b)==="binary"&&g(a(b)??"")),c=g=>o.filter(b=>b.type===g),d=Dr(c("window"),s.filter(g=>ee(g)==="cover"&&yy.has(a(g))),!0),u=Dr(c("window"),l(g=>wy.has(g))),p=Dr(c("door"),l(g=>g==="door")),h=Dr(c("garage"),s.filter(g=>ee(g)==="cover"&&vy.has(a(g)??""))),f=Dr(c("garage"),l(g=>g==="garage_door"));for(let g of o){let b=g.type==="window"?d:g.type==="garage"?h:null,y=g.type==="window"?u:g.type==="garage"?f:p,v=g.leaves===2;n.set(g.id,{cover:mu(g.cover,b?.get(g.id)),contact:g.sensor==="handle"&&g.contact==null?null:mu(g.contact,y.get(g.id)),tilt:g.tilt==="none"?null:g.tilt,contact2:v?Ht(g.contact2):null,tilt2:v?Ht(g.tilt2):null,position:Ht(g.position),positionInverted:!!g.position_inverted,tiltAngle:Ht(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"?Ht(g.lock):null,cover2:g.type==="garage"?null:Ht(g.cover2),coverTilt:Ht(g.cover_tilt),cover2Tilt:Ht(g.cover2_tilt),coverInverted:!!g.cover_inverted,coverTiltInverted:!!g.cover_tilt_inverted,cover2Inverted:!!g.cover2_inverted,cover2TiltInverted:!!g.cover2_tilt_inverted})}}return n}var xy=[[/^(tilted|tilt|gekippt|kipp)/i,"tilted"],[/^(open|opened|offen|geöffnet|on)$/i,"open"],[/^(closed|close|geschlossen|zu|off)$/i,"closed"]];function fa(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&&xy.find(([o])=>o.test(r));if(i)return i[1]}return null}var gu=/\b(tv|fernseh|television|fire ?tv|apple ?tv|chromecast|shield)/i,_u=/(kühl|fridge|gefrier|freezer)/i,bu=/(spülmaschine|geschirrspül|dishwasher)/i,ky=/(kochfeld|herd|induktion|cooktop)/i,$y={robot_vacuum:/(saug|vacuum|robo|roomba|roborock|dreame|ecovacs|deebot)/i,tv_board:gu,tv_wall:gu,desk:/\b(pc|computer|rechner|desktop|monitor|workstation)/i,fridge:_u,fridge_smart:_u,stove:/(herd|kochfeld|cooktop|stove|induktion)/i,kitchen_tall:/(backofen|oven|ofen)/i,dishwasher:bu,washer:/(waschmaschine|washer|washing)/i,dryer:/(trockner|dryer)/i,kitchen:/(kaffee|coffee|wasserkocher|kettle)/i,island:ky,sink:bu,radiator:/(heiz|radiator|thermostat|climate|hk|trv)/i},yu={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},vu=new Set(["tv_board","tv_wall"]);var Cn=t=>vu.has(t)||!!dd(t),vo=t=>!!U(t)?.electric&&/speaker|multiroom|soundbar/.test(t.split(":").pop()??t),Hr=t=>Cn(t)||t==="desk"||t==="fridge_smart",Sy=t=>!!t&&t!=="none";function My(t,e){if(mo(t,e))return e;let n=t.entities?.[e]?.device_id;return n?go(t,n).find(r=>r!==e)??null:null}var Ey=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function Or(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(Sy));for(let o of r.furniture){let s=o.type in yu,a=Tn(o.type),l=s?yu[o.type]:$y[o.type];if(!l&&!a&&!vo(o.type)&&o.entity==null&&o.power==null)continue;let c=Ey(r,o.x,o.z),d=(c?_o(t,we(t,c)):[]).filter(b=>!i.has(b)),u=b=>`${b} ${B(t,b)}`,p=b=>d.filter(y=>ee(y)===b),h=o.entity==="none"?null:o.entity??null;if(o.entity==null){if(o.type==="ceiling_fan"){let b=(c?we(t,c):[]).filter(v=>!i.has(v)),y=new Set(b.filter(v=>ee(v)==="fan").map(v=>t.entities?.[v]?.device_id).filter(Boolean));h=b.find(v=>ee(v)==="light"&&y.has(t.entities?.[v]?.device_id))??Or(p("light"),l,u,!1)}else if(s)h=Or(p("light"),l,u,!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)&&Ot(t,y)===b)??null}else if(o.type==="radiator"||a)h=Or(p("climate"),l,u,!0);else if(Cn(o.type)){let b=p("media");h=b.find(y=>t.states[y]?.attributes.device_class==="tv")??Or(b,l,u,vu.has(o.type))}else if(vo(o.type)){let b=p("media").filter(y=>t.states[y]?.attributes.device_class!=="tv");h=Or(b,l,u,!1)??(b.length===1?b[0]:null)}else l&&(h=d.find(b=>["switch","media","fan"].includes(ee(b)??"")&&l.test(u(b)))??null);h&&i.add(h)}let f=o.power==="none"?null:o.power??null;o.power==null&&(f=h?My(t,h):null,!f&&l&&c&&!s&&(f=we(t,c).find(b=>mo(t,b)&&!i.has(b)&&l.test(u(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?we(t,c):[]).filter(v=>ee(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 wu=t=>t==="fridge"||t==="fridge_smart"||/(fridge|freezer|kuehl|gefrier|chest_freezer)/.test(t.slice(t.lastIndexOf(":")+1));function xu(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(..._o(t,fo(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 Ry(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 $u(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)],d=Math.min(a-s,c-l),u=Math.max(.1,Math.min(.25,d/8)),p=Math.min(.35,d/5),h=Math.min(.7,d/4),f=ve(r),g=[];for(let y=s+u/2;y=p&&g.push({at:w,wallDistance:k})}g.length===0&&g.push({at:f,wallDistance:0});let b=[...n];return e.map(y=>{let v=ee(y)==="light",w=g[0].at,k=-1/0;for(let{at:M,wallDistance:A}of g){let T=b.length?Math.min(...b.map(I=>Math.hypot(M[0]-I[0],M[1]-I[1]))):3,F=Math.hypot(M[0]-f[0],M[1]-f[1]),L=Math.min(T,3)*2;Fk+1e-9&&(k=L,w=M)}let x=[Math.round(w[0]*100)/100,Math.round(w[1]*100)/100];return b.push(x),{entity_id:y,x:x[0],z:x[1],y:null,mount:null}})}var ku=/(^|_)(current_room|current_segment|aktueller_raum|current_area)($|_)/;function Su(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.")&&(ku.test(o.translation_key??"")||ku.test(o.entity_id.split(".")[1])))?.entity_id??null}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 an(t){return!t||t.state==="unknown"||t.state==="unavailable"?null:t.attributes.symcon_value??t.attributes.symcon_numeric_value??t.state}function Ct(t){let e=an(t);if(e===null||typeof e=="boolean"||e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}function Lr(t){let e=an(t);if(e===null)return null;if(typeof e=="boolean")return e;if(typeof e=="number")return e>0;let n=String(e).trim().toLowerCase();if(["on","true","1","home","open","an","ein","ja","regen","rain","wet","nass"].includes(n))return!0;if(["off","false","0","not_home","closed","aus","nein","trocken","dry"].includes(n))return!1;let r=Number(n);return n!==""&&Number.isFinite(r)?r>0:null}function ma(t){return an(t)===null?"\u2013":String(t?.attributes.symcon_formatted??an(t))}var ge=t=>/^(sensor|input_number|number)\./.test(t),wo=t=>/^(binary_sensor|input_boolean)\./.test(t);function Nn(t,e){if(!ge(e))return!1;let n=t?.states[e]?.attributes;return n?.device_class==="power"||n?.unit_of_measurement==="W"||n?.unit_of_measurement==="kW"}function Ay(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 O(t,e){return Object.keys(t?.states??{}).filter(e).map(n=>{let r=Ay(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 Mu(t,e,n){return e.unsupported?[]:O(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 xo(t,e){return t.power&&t.power!=="none"?t.power:e.get(t.id)?.power??null}var{I:Fy}=rd,Eu=t=>t;var Au=t=>t.strings===void 0,Ru=()=>document.createComment(""),Bn=(t,e,n)=>{let r=t._$AA.parentNode,i=e===void 0?t._$AB:e._$AA;if(n===void 0){let o=r.insertBefore(Ru(),i),s=r.insertBefore(Ru(),i);n=new Fy(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=Eu(l).nextSibling;Eu(r).insertBefore(l,i),l=c}}}return n},Nt=(t,e,n=t)=>(t._$AI(e,n),t),Ty={},Fu=(t,e=Ty)=>t._$AH=e,Tu=t=>t._$AH,ko=t=>{t._$AR(),t._$AA.remove()};var zu=(t,e,n)=>{let r=new Map;for(let i=e;i<=n;i++)r.set(t[i],i);return r},ln=sn(class extends It{constructor(t){if(super(t),t.type!==On.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=Tu(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,d,u=0,p=i.length-1,h=0,f=o.length-1;for(;u<=p&&h<=f;)if(i[u]===null)u++;else if(i[p]===null)p--;else if(a[u]===s[h])l[h]=Nt(i[u],o[h]),u++,h++;else if(a[p]===s[f])l[f]=Nt(i[p],o[f]),p--,f--;else if(a[u]===s[f])l[f]=Nt(i[u],o[f]),Bn(t,l[f+1],i[u]),u++,f--;else if(a[p]===s[h])l[h]=Nt(i[p],o[h]),Bn(t,i[u],i[p]),p--,h++;else if(c===void 0&&(c=zu(s,h,f),d=zu(a,u,p)),c.has(a[u]))if(c.has(a[p])){let g=d.get(s[h]),b=g!==void 0?i[g]:null;if(b===null){let y=Bn(t,i[u]);Nt(y,o[h]),l[h]=y}else l[h]=Nt(b,o[h]),Bn(t,i[u],b),i[g]=null;h++}else ko(i[p]),p--;else ko(i[u]),u++;for(;h<=f;){let g=Bn(t,l[f+1]);Nt(g,o[h]),l[h++]=g}for(;u<=p;){let g=i[u++];g!==null&&ko(g)}return this.ut=s,Fu(t,l),tt}});var zy=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),ga=-1,Iu=[{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"}],Pu=t=>t.object_type===1&&Iu.some(e=>e.type===t.module_type);function Py(t){let e=new Map(t.map(l=>[l.object_id,l])),n=t.filter(l=>{if(!Pu(l))return!1;let c=new Set([l.object_id]),d=e.get(l.parent_id);for(;d&&!c.has(d.object_id);){if(Pu(d))return!1;c.add(d.object_id),d=e.get(d.parent_id)}return!0});if(!n.length)return t;let r=new Map(e),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,d,u,p)=>({object_id:l,parent_id:c,name:d,path:u,position:p,object_type:0,hidden:!1,icon:"",virtual:!0});r.set(ga,o(ga,0,"System","System",Number.MAX_SAFE_INTEGER));let s=new Set,a=(l,c,d)=>{if(s.has(l.object_id))return;s.add(l.object_id);let u={...l,parent_id:c,path:`${d} / ${l.name}`};r.set(l.object_id,u);for(let p of i.get(l.object_id)??[])a(p,l.object_id,u.path)};return Iu.forEach((l,c)=>{let d=n.filter(h=>h.module_type===l.type);if(!d.length)return;let u=-10-l.type,p=`System / ${l.name}`;r.set(u,o(u,ga,l.name,p,c));for(let h of d)a(h,u,p)}),[...r.values()]}function _a(t){let e=Py(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||zy.compare(o.name,s.name));return{nodes:n,children:r}}function ba(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 ya(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 ba(t,l.object_id))i.add(c)}}let o=[],s=new Set,a=(l,c)=>{let d=(t.children.get(l)??[]).filter(u=>!i||i.has(u.object_id));d.forEach((u,p)=>{if(s.has(u.object_id))return;s.add(u.object_id);let h=(t.children.get(u.object_id)?.length??0)>0,f=h&&(!!i||e.has(u.object_id));o.push({node:u,depth:c,hasChildren:h,expanded:f,index:p+1,siblings:d.length}),f&&a(u.object_id,c+1)})};return a(0,0),o}var Du=["Boolean","Integer","Float","String"],Iy={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 Ou(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:Du[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=>Du[c]).join(" oder ")} ben\xF6tigt.`;let o=e.excluded?.(t.entity_id);if(o)return o;let s=Iy[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 Dy=["Kategorie","Instanz","Variable","Skript","Ereignis","Medium","Link"],va=class extends q{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=_a([]);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=_a(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 ba(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=Ou(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=ya(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=[E``,E``,E``,E``,E``,E``,E``];return E``}renderRow(e){let{node:n}=e,r=this.entityFor(n),i=!!r;return m`
${this.icon(n.object_type)}${n.name||"(Ohne Namen)"} - ${n.virtual?"Systembereich":Ey[n.object_type]??"Objekt"}${n.hidden?" \xB7 ausgeblendet":""} + ${n.virtual?"Systembereich":Dy[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`
`}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=ya(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()}> + {if(c.stopPropagation(),c.target===this.dialog){let d=this.dialog.getBoundingClientRect();(c.clientXd.right||c.clientYd.bottom)&&this.close()}}} @keydown=${c=>c.stopPropagation()} @change=${c=>c.stopPropagation()}>

Datenpunkt auswählen

IP-Symcon · ${this.context?.label||"Objektbaum"}

-
`}static styles=[ve,ee` +
`}static styles=[fe,J` :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; } @@ -294,7 +294,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f .tree { margin:0 8px; } .node { gap:6px; padding-left:calc(2px + var(--depth)*18px); } .node small { display:none; } footer { padding:12px; flex-direction:column; align-items:stretch; } .actions { justify-content:flex-end; } } - `]};customElements.get("nf-symcon-object-picker")||customElements.define("nf-symcon-object-picker",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`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,Hu)]}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-Hu)}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.leftOut>0?m`
  • … +${this.leftOut} · ${this.placeholder}
  • `:_} `:_} -
    `}static styles=[ve,ee` + `}static styles=[fe,J` :host { display: block; position: relative; @@ -393,11 +393,11 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f color: var(--nf-muted); cursor: default; } - `]};customElements.get("nf-entity-picker")||customElements.define("nf-entity-picker",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` + `]};customElements.get("nf-entity-picker")||customElements.define("nf-entity-picker",wa);var xa=class extends q{static properties={text:{attribute:!1}};constructor(){super(),this.text=""}get dialog(){return this.renderRoot.querySelector("dialog")}render(){return m` e.stopPropagation()} @click=${e=>{if(e.target!==e.currentTarget)return;let n=this.dialog.getBoundingClientRect();(e.clientXn.right||e.clientYn.bottom)&&this.dialog?.close()}}>
    Information

    ${this.text}

    -
    `}static styles=[ve,ee` + `}static styles=[fe,J` :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; } @@ -408,7 +408,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f header { display:flex; align-items:center; justify-content:space-between; gap:20px; font-size:16px; } .close { width:30px; height:30px; padding:0; font-size:23px; } p { white-space:pre-wrap; overflow-wrap:anywhere; margin:16px 0 4px; } - `]};customElements.get("nf-help-popup")||customElements.define("nf-help-popup",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`