diff --git a/CHANGELOG.md b/CHANGELOG.md index 811f7c1..b06239e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ All notable changes to NextFloor, newest first. Every release lists what is **Ad ### Added +- **Branch overviews, scoped outdoors and room moves (Symcon 0.4.2):** Select entire locations or branches above the editor, with read-only plan overviews and scoped 3D scenes. Create independent outdoor plans at location, branch and building level; preserve legacy location references, unique navigation keys, owner paths, thumbnails, isolated live values, stack ranks and roof exclusions through saves and backups. Add an explicit room-move dialog with destination building/storey and adjustable position, retaining room IDs, native links, openings, contained furniture/devices/notes and related geometry. Reject stale selections and duplicate destination devices before changing the plan. Migrate existing room/device grants only for unique stable identities when their floor changes, preserving permission levels and undo without granting access to additional users. + - **Five-level site topology (Symcon 0.4.0):** Add optional location → branch → building → floor → room groups with editor creation, naming, reassignment and protected removal. Preserve existing floor/room IDs and native grants when enabling the hierarchy. Each location owns an independent outdoor plan. Designer and tile navigation drill into the selected branch, keep the upper room menu hidden until a floor is selected, frame previews from the node's own geometry and clip room previews. Scope live values and utility overviews to the selected group, keep floor explosion/automatic roofs within each building, and limit whole-building transforms to its floors. Native permission choices expose complete paths. Persist topology and outdoor membership through schema validation and backups. - **Hydronic status bindings (Symcon 0.3.1):** Add native object-tree status selection for individual heating/cooling circuits, every fresh-water cascade unit and the common plant. Floating cards and detail dialogs preserve formatted Integer aliases, including zero, live updates, unavailable values, archive access and scoped user permissions. Status readings remain read-only, hide unlinked rows and truncate long labels without widening cards; existing single stations retain their links when promoted to cascades. diff --git a/custom_components/nextfloor/frontend/nextfloor-3d.js b/custom_components/nextfloor/frontend/nextfloor-3d.js index 17cda21..b1deb69 100644 --- a/custom_components/nextfloor/frontend/nextfloor-3d.js +++ b/custom_components/nextfloor/frontend/nextfloor-3d.js @@ -1,11 +1,11 @@ /*! NextFloor, MIT licence. Includes three.js (MIT) and Lit (BSD-3-Clause); see LICENSE and THIRD_PARTY_NOTICES.md */ -var D0=1.3,U0=(i,e=new Date().toISOString().slice(0,10))=>!!i.due&&i.due<=e;var Vl={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 jr(i){return i==="hedge"||i==="fence"||i==="pergola"}function cf(i,e,t){let n=i.slope??0;if(!n||i.type==="pool")return 0;let r=i.slope_dir??"x",s=(c,u)=>r==="x"?c:r==="-x"?-c:r==="z"?u:-u,o=1/0,a=-1/0;for(let[c,u]of i.points){let h=s(c,u);o=Math.min(o,h),a=Math.max(a,h)}if(a-o<1e-6)return 0;let l=Math.min(1,Math.max(0,(s(e,t)-o)/(a-o)));return n*l}function N1(i,e,t,n){return ea(i)+(e.offset??0)+Vl[e.type]-cf(e,t,n)}function ea(i){return i.elevation>.3?0:-.2}function k0(i,e,t){let n=(i.outdoor??[]).filter(s=>!jr(s.type)&&s.type!=="pool"&&Ge([e,t],s.points)),r=[...n].reverse().find(s=>s.cut)??n[0];return r?N1(i,r,e,t):ea(i)}var B0=i=>i.cut??(i.type==="pool"||i.type==="river"||i.type==="stream");function z0(i){let e=Number.isFinite(i.texture_scale)?Math.max(.05,Math.min(20,i.texture_scale)):1,t=Number.isFinite(i.texture_rotation)?(i.texture_rotation%360+360)%360:0;return{scale:e,rotation:t}}var O1={type:"none",pitch:35,overhang:.4},V0="#d6cfc2",uf="#e8e3da",PI={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...O1}};var G0=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"]),Gl=1.75;function H0(i){return G0.has(i)||!!_t(i)?.light}var D1=new Set(["table","table_round","coffee_table","desk","nightstand","sideboard","dresser","kitchen","island","worktop","tv_board","dishwasher","washer","dryer"]);function Qr(i){switch(i.type){case"home_battery":return i.variant==="wall"?.5:0;case"kitchen_wall":return 1.45;case"tv_wall":return Math.max(0,1.3-i.h/2);case"radiator":return .12;case"inverter":return 1.1;case"wallbox":return 1;case"meter":return .4;default:return 0}}var W0=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function X0(i,e){return i.filter(t=>t.elevationt.rooms.filter(n=>n.points.length>=3&&n.ceiling!=null&&n.ceiling>t.height+.005&&t.elevation+n.ceiling>e.elevation+.05)).map(t=>t.points)}var es=i=>i?.floor_offset&&Number.isFinite(i.floor_offset)?i.floor_offset:0;function Y0(i,e,t){let n=i.rooms.find(r=>r.points.length>=3&&r.floor_offset&&Ge([e,t],r.points));return es(n)}function hf(i,e,t){let n=i.rooms.find(r=>r.points.length>=3&&Ge([e,t],r.points));return n?.ceiling!=null&&n.ceiling>0?n.ceiling:i.height}var Hl=(i,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:hf(i,e.x,e.z);function q0(i,e,t){let n=0;for(let r of i.furniture)!(D1.has(r.type)||_t(r.type)?.surface)||!Ge([e,t],ns(r))||(n=Math.max(n,r.h));return n}var U1=new Set([...G0,"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"]);var k1=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],B1=["standard","bars","glass_wall"];function Sr(i,e){return i.type==="door"?i.style&&k1.includes(i.style)?i.style:e?"front":"interior":i.style&&B1.includes(i.style)?i.style:"standard"}function $0(i,e,t,n){if(e!=="sidelight"&&e!=="sidelights")return null;let r=e==="sidelights",s=i-.04,o=Math.min(1.05,Math.max(.6,s-(r?.6:.3))),a=(s-o)/(r?2:1),l=n.sidelight_width??a,c=r?n.sidelight_width2??n.sidelight_width??a:0;l=Math.max(.1,l),c=r?Math.max(.1,c):0;let u=s-.5;if(l+c>u){let f=Math.max(0,u)/(l+c);l*=f,c*=f}return r?{panels:[[.02,.02+l],[i-.02-c,i-.02]],x0:.02+l,x1:i-.02-c}:(t?!!n.sidelight_hinge:!n.sidelight_hinge)?{panels:[[.02,.02+l]],x0:.02+l,x1:i-.02}:{panels:[[i-.02-l,i-.02]],x0:.02,x1:i-.02-l}}function K0(i){return i==="front"||i==="front_glass"||i==="sidelight"||i==="sidelights"}function ts(i){let e=0;for(let t=0;ts+o[0],0)/r,i.reduce((s,o)=>s+o[1],0)/r]}let t=0,n=0;for(let r=0;r1e-6&&Math.abs(n-s)>1e-6)return!1}return!0}function J0(i){let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let[s,o]of i)e=Math.min(e,s),t=Math.min(t,o),n=Math.max(n,s),r=Math.max(r,o);return{x0:e,z0:t,x1:n,z1:r}}function ns(i){let e=i.rotation*Math.PI/180,t=Math.cos(e),n=Math.sin(e),r=i.w/2,s=i.d/2;return[[-r,-s],[r,-s],[r,s],[-r,s]].map(([o,a])=>[i.x+o*t-a*n,i.z+o*n+a*t])}function Ge(i,e){let t=!1;for(let n=0,r=e.length-1;ni[1]!=l>i[1]&&i[0]<(a-s)*(i[1]-o)/(l-o)+s&&(t=!t)}return t}var z1=[],na=new Map,V1=0,eg=(i,e)=>`pack:${i}:${e}`,G1=i=>i.startsWith("pack:");function Wl(i){z1=i,na=new Map;for(let e of i)for(let t of e.items)na.set(eg(e.id,t.id),t);V1+=1}var H1={};function _t(i){if(!G1(i))return;let e=na.get(i);if(e)return e;let[,t,...n]=i.split(":"),r=H1[t];return r?na.get(eg(r,n.join(":"))):void 0}var W1=.22;function j0(i,e,t,n){let r=Math.min(W1,t/3);if(n<=r*2.4||Math.abs(n-t)<1e-6)return e*(n/t)+(i-e)*(n/t);let s=e*(n/t),o=i-e;return o<=r?s+o:o>=t-r?s+n-(t-o):s+r+(o-r)*(n-2*r)/(t-2*r)}function ta(i,e,t,n,r){return[j0(i*n,t*n,n,r)/r,j0(e*n,t*n,n,r)/r]}var Q0=new WeakMap;function ia(i,e,t,n){let[r,s,o]=i.size;if(i.vehicle||i.stretch||Math.abs(e-r)<1e-4&&Math.abs(t-s)<1e-4&&Math.abs(n-o)<1e-4)return i.parts;let a=`${e.toFixed(4)}|${t.toFixed(4)}|${n.toFixed(4)}`,l=Q0.get(i),c=l?.get(a);if(c)return c;let u=i.parts.map(h=>{if(h.shape==="sweep")return h;let[f,d]=ta(h.x-h.w/2,h.x+h.w/2,-.5,r,e),[p,x]=ta(h.z-h.d/2,h.z+h.d/2,-.5,s,t),[m,g]=ta(h.y,h.y+h.h,0,o,n);if(h.rot)return{...h,x:(f+d)/2,z:(p+x)/2,w:h.w*r/e,d:h.d*s/t,y:m,h:g-m};let y={...h,x:(f+d)/2,z:(p+x)/2,w:d-f,d:x-p,y:m,h:g-m};if(h.shape==="loft"){let[_,b,M,S]=[h.tx??h.x,h.tz??h.z,h.tw??h.w,h.td??h.d],[v,w]=ta(_-M/2,_+M/2,-.5,r,e),[P,T]=ta(b-S/2,b+S/2,-.5,s,t);Object.assign(y,{tx:(v+w)/2,tz:(P+T)/2,tw:w-v,td:T-P})}return y});return l||Q0.set(i,l=new Map),l.size>32&&l.clear(),l.set(a,u),u}var tg=i=>!!i?.parts.some(e=>e.move);function ng(i,e){if(e===null)return Math.min(1,Math.max(0,i.cover_rest??1));let t=Math.min(1,Math.max(0,e/100));return i.cover==="extends"?t:1-t}function ig(i,e){let t=[];for(let n of i){if(!n.move)continue;let r={...n},s=(o,a)=>a+(o-a)*e;if(n.move==="down"){let[o,a]=[s(n.y,1),s(n.y+n.h,1)];Object.assign(r,{y:o,h:a-o})}else if(n.move==="left"||n.move==="right"){let o=n.move==="left"?-.5:.5,[a,l]=[s(n.x-n.w/2,o),s(n.x+n.w/2,o)];if(Object.assign(r,{x:(a+l)/2,w:Math.abs(l-a)}),n.tx!==void 0||n.tw!==void 0){let[c,u]=[s((n.tx??n.x)-(n.tw??n.w)/2,o),s((n.tx??n.x)+(n.tw??n.w)/2,o)];Object.assign(r,{tx:(c+u)/2,tw:Math.abs(u-c)})}}else if(n.move==="out"){let[o,a]=[s(n.z-n.d/2,-.5),s(n.z+n.d/2,-.5)];if(Object.assign(r,{z:(o+a)/2,d:a-o}),n.tz!==void 0||n.td!==void 0){let[l,c]=[s((n.tz??n.z)-(n.td??n.d)/2,-.5),s((n.tz??n.z)+(n.td??n.d)/2,-.5)];Object.assign(r,{tz:(l+c)/2,td:c-l})}}else{let o=(1-e)*n.w*(n.move==="slide_left"?-1:1);Object.assign(r,{x:n.x+o,...n.tx!==void 0?{tx:n.tx+o}:{}})}r.w>.002&&r.d>.002&&r.h>.002&&t.push(r)}return t}function Gt(i,e){return e.mount_y!=null?e.mount_y:Y1(i,e)+(X1(e)?0:Y0(i,e.x,e.z))}var X1=i=>i.type==="led_strip"||_t(i.type)?.mount==="ceiling";function Y1(i,e){if(e.type==="lamp_wall")return Gl;if(e.type==="led_strip")return Math.max(0,hf(i,e.x,e.z)-.04-Math.max(.02,e.h));let t=_t(e.type);if(!t)return Qr(e);switch(t.mount){case"surface":return q0(i,e.x,e.z);case"wall":return t.wall_y??1;case"ceiling":return Math.max(0,Hl(i,e)-e.h);default:return 0}}var rg=null,sg=new Set,og=i=>{rg=i},ag=()=>rg,lg=i=>{sg.add(i)};function Xl(i){let e=na.get(i)?.mesh;return e!==void 0&&sg.has(e)}var nx=0,Qf=1,ix=2;var Wa=1,rx=2,Mo=3,Ai=0,un=1,ht=2,xs=0,Ei=1,Ft=2,ed=3,Xa=4,sx=5;var ys=100,ox=101,ax=102,lx=103,cx=104,ux=200,hx=201,fx=202,dx=203,td=204,nd=205,px=206,mx=207,gx=208,xx=209,yx=210,bx=211,vx=212,_x=213,Mx=214,wc=0,Tc=1,Ac=2,lo=3,Ec=4,Rc=5,Cc=6,Pc=7,$c=0,Sx=1,wx=2,Ri=0,id=1,rd=2,sd=3,od=4,ad=5,ld=6,cd=7,Uf="attached",Tx="detached",ud=300,bs=301,So=302,Kc=303,Zc=304,zn=1e3,ln=1001,Ir=1002,Ut=1003,wo=1004;var ur=1005;var Ht=1006,kr=1007;var Nn=1008;var On=1009,hd=1010,fd=1011,To=1012,Jc=1013,ai=1014,Gn=1015,li=1016,jc=1017,Qc=1018,vs=1020,dd=35902,pd=35899,md=1021,gd=1022,Dn=1023,Zi=1026,hr=1027,eu=1028,tu=1029,Br=1030,nu=1031;var iu=1033,Ya=33776,qa=33777,$a=33778,Ka=33779,ru=35840,su=35841,ou=35842,au=35843,lu=36196,cu=37492,uu=37496,hu=37488,fu=37489,Za=37490,du=37491,pu=37808,mu=37809,gu=37810,xu=37811,yu=37812,bu=37813,vu=37814,_u=37815,Mu=37816,Su=37817,wu=37818,Tu=37819,Au=37820,Eu=37821,Ru=36492,Cu=36494,Pu=36495,Iu=36283,Lu=36284,Ja=36285,Fu=36286;var Ji=2300,ji=2301,Mc=2302,kf=2303,Bf=2400,zf=2401,Vf=2402,Ax=2500;var xd=0,ja=1,Ao=2,Ex=3200;var Qa=0,Rx=1,ci="",dt="srgb",Sn="srgb-linear",ba="linear",Mt="srgb";var Sc=7680;var Cx=519,Px=512,Ix=513,Lx=514,yd=515,Fx=516,Nx=517,bd=518,vd=519,_d=35044,Md=35048;var Sd="300 es",Kn=2e3,co=2001;function q1(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function $1(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function uo(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Ox(){let i=uo("canvas");return i.style.display="block",i}var cg={},ho=null;function va(...i){let e="THREE."+i.shift();ho?ho("log",e,...i):console.log(e,...i)}function Dx(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Oe(...i){i=Dx(i);let e="THREE."+i.shift();if(ho)ho("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function We(...i){i=Dx(i);let e="THREE."+i.shift();if(ho)ho("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function as(...i){let e=i.join(" ");e in cg||(cg[e]=!0,Oe(...i))}function Ux(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}var kx={[wc]:wc,[Ac]:Cc,[Ec]:Ec,[lo]:Rc,[Tc]:Tc,[Cc]:Ac,[Pc]:Pc,[Rc]:lo},vi=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let r=n.slice(0);for(let s=0,o=r.length;s>8&255]+dn[i>>16&255]+dn[i>>24&255]+"-"+dn[e&255]+dn[e>>8&255]+"-"+dn[e>>16&15|64]+dn[e>>24&255]+"-"+dn[t&63|128]+dn[t>>8&255]+"-"+dn[t>>16&255]+dn[t>>24&255]+dn[n&255]+dn[n>>8&255]+dn[n>>16&255]+dn[n>>24&255]).toLowerCase()}function st(i,e,t){return Math.max(e,Math.min(t,i))}function wd(i,e){return(i%e+e)%e}function K1(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function Z1(i,e,t){return i!==e?(t-i)/(e-i):0}function ya(i,e,t){return(1-t)*i+t*e}function J1(i,e,t,n){return ya(i,e,1-Math.exp(-t*n))}function j1(i,e=1){return e-Math.abs(wd(i,e*2)-e)}function Q1(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function eS(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function tS(i,e){return i+Math.floor(Math.random()*(e-i+1))}function nS(i,e){return i+Math.random()*(e-i)}function iS(i){return i*(.5-Math.random())}function rS(i){i!==void 0&&(ug=i);let e=ug+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function sS(i){return i*xa}function oS(i){return i*ls}function aS(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function lS(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Td(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function cS(i,e,t,n,r){let s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),u=o((e+n)/2),h=s((e-n)/2),f=o((e-n)/2),d=s((n-e)/2),p=o((n-e)/2);switch(r){case"XYX":i.set(a*u,l*h,l*f,a*c);break;case"YZY":i.set(l*f,a*u,l*h,a*c);break;case"ZXZ":i.set(l*h,l*f,a*u,a*c);break;case"XZX":i.set(a*u,l*p,l*d,a*c);break;case"YXY":i.set(l*d,a*u,l*p,a*c);break;case"ZYZ":i.set(l*p,l*d,a*u,a*c);break;default:Oe("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Nu(i){switch(i.constructor){case Uint32Array:return 4294967295;case Uint16Array:return 65535;case Uint8Array:case Uint8ClampedArray:return 255;case Int32Array:return 2147483647;case Int16Array:return 32767;case Int8Array:return 127;default:return}}function Ad(i,e){if(e.constructor===Float32Array)return i;let t=Nu(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.max(i/t,-1)}function Ed(i,e){if(e.constructor===Float32Array)return i;let t=Nu(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.round(i*t)}var zr={DEG2RAD:xa,RAD2DEG:ls,generateUUID:Ci,clamp:st,euclideanModulo:wd,mapLinear:K1,inverseLerp:Z1,lerp:ya,damp:J1,pingpong:j1,smoothstep:Q1,smootherstep:eS,randInt:tS,randFloat:nS,randFloatSpread:iS,seededRandom:rS,degToRad:sS,radToDeg:oS,isPowerOfTwo:aS,ceilPowerOfTwo:lS,floorPowerOfTwo:Td,setQuaternionFromProperEuler:cS,normalize:Ed,denormalize:Ad},Ld=class Ld{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=st(this.x,e.x,t.x),this.y=st(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=st(this.x,e,t),this.y=st(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(st(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(st(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*r+e.x,this.y=s*r+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Ld.prototype.isVector2=!0;var Ue=Ld,wn=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,o,a){let l=n[r+0],c=n[r+1],u=n[r+2],h=n[r+3],f=s[o+0],d=s[o+1],p=s[o+2],x=s[o+3];if(h!==x||l!==f||c!==d||u!==p){let m=l*f+c*d+u*p+h*x;m<0&&(f=-f,d=-d,p=-p,x=-x,m=-m);let g=1-a;if(m<.9995){let y=Math.acos(m),_=Math.sin(y);g=Math.sin(g*y)/_,a=Math.sin(a*y)/_,l=l*g+f*a,c=c*g+d*a,u=u*g+p*a,h=h*g+x*a}else{l=l*g+f*a,c=c*g+d*a,u=u*g+p*a,h=h*g+x*a;let y=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=y,c*=y,u*=y,h*=y}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,r,s,o){let a=n[r],l=n[r+1],c=n[r+2],u=n[r+3],h=s[o],f=s[o+1],d=s[o+2],p=s[o+3];return e[t]=a*p+u*h+l*d-c*f,e[t+1]=l*p+u*f+c*h-a*d,e[t+2]=c*p+u*d+a*f-l*h,e[t+3]=u*p-a*h-l*f-c*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(r/2),h=a(s/2),f=l(n/2),d=l(r/2),p=l(s/2);switch(o){case"XYZ":this._x=f*u*h+c*d*p,this._y=c*d*h-f*u*p,this._z=c*u*p+f*d*h,this._w=c*u*h-f*d*p;break;case"YXZ":this._x=f*u*h+c*d*p,this._y=c*d*h-f*u*p,this._z=c*u*p-f*d*h,this._w=c*u*h+f*d*p;break;case"ZXY":this._x=f*u*h-c*d*p,this._y=c*d*h+f*u*p,this._z=c*u*p+f*d*h,this._w=c*u*h-f*d*p;break;case"ZYX":this._x=f*u*h-c*d*p,this._y=c*d*h+f*u*p,this._z=c*u*p-f*d*h,this._w=c*u*h+f*d*p;break;case"YZX":this._x=f*u*h+c*d*p,this._y=c*d*h+f*u*p,this._z=c*u*p-f*d*h,this._w=c*u*h-f*d*p;break;case"XZY":this._x=f*u*h-c*d*p,this._y=c*d*h-f*u*p,this._z=c*u*p+f*d*h,this._w=c*u*h+f*d*p;break;default:Oe("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],h=t[10],f=n+a+h;if(f>0){let d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-l)*d,this._y=(s-c)*d,this._z=(o-r)*d}else if(n>a&&n>h){let d=2*Math.sqrt(1+n-a-h);this._w=(u-l)/d,this._x=.25*d,this._y=(r+o)/d,this._z=(s+c)/d}else if(a>h){let d=2*Math.sqrt(1+a-n-h);this._w=(s-c)/d,this._x=(r+o)/d,this._y=.25*d,this._z=(l+u)/d}else{let d=2*Math.sqrt(1+h-n-a);this._w=(o-r)/d,this._x=(s+c)/d,this._y=(l+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(st(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+o*a+r*c-s*l,this._y=r*u+o*l+s*a-n*c,this._z=s*u+o*c+n*l-r*a,this._w=o*u-n*a-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,s=e._z,o=e._w,a=this.dot(e);a<0&&(n=-n,r=-r,s=-s,o=-o,a=-a);let l=1-t;if(a<.9995){let c=Math.acos(a),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+o*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+o*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Fd=class Fd{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(hg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(hg.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*r-a*n),u=2*(a*t-s*r),h=2*(s*n-o*t);return this.x=t+l*c+o*h-a*u,this.y=n+l*u+a*c-s*h,this.z=r+l*h+s*u-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=st(this.x,e.x,t.x),this.y=st(this.y,e.y,t.y),this.z=st(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=st(this.x,e,t),this.y=st(this.y,e,t),this.z=st(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(st(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=r*l-s*a,this.y=s*o-n*l,this.z=n*a-r*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return ff.copy(this).projectOnVector(e),this.sub(ff)}reflect(e){return this.sub(ff.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(st(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Fd.prototype.isVector3=!0;var D=Fd,ff=new D,hg=new wn,Nd=class Nd{constructor(e,t,n,r,s,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,o,a,l,c)}set(e,t,n,r,s,o,a,l,c){let u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],h=n[7],f=n[2],d=n[5],p=n[8],x=r[0],m=r[3],g=r[6],y=r[1],_=r[4],b=r[7],M=r[2],S=r[5],v=r[8];return s[0]=o*x+a*y+l*M,s[3]=o*m+a*_+l*S,s[6]=o*g+a*b+l*v,s[1]=c*x+u*y+h*M,s[4]=c*m+u*_+h*S,s[7]=c*g+u*b+h*v,s[2]=f*x+d*y+p*M,s[5]=f*m+d*_+p*S,s[8]=f*g+d*b+p*v,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-n*s*u+n*a*l+r*s*c-r*o*l}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*o-a*c,f=a*l-u*s,d=c*s-o*l,p=t*h+n*f+r*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/p;return e[0]=h*x,e[1]=(r*c-u*n)*x,e[2]=(a*n-r*o)*x,e[3]=f*x,e[4]=(u*t-r*l)*x,e[5]=(r*s-a*t)*x,e[6]=d*x,e[7]=(n*l-c*t)*x,e[8]=(o*t-n*s)*x,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,o,a){let l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-r*c,r*l,-r*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return as("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(df.makeScale(e,t)),this}rotate(e){return as("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(df.makeRotation(-e)),this}translate(e,t){return as("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(df.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Nd.prototype.isMatrix3=!0;var Xe=Nd,df=new Xe,fg=new Xe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),dg=new Xe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function uS(){let i={enabled:!0,workingColorSpace:Sn,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Mt&&(r.r=Ki(r.r),r.g=Ki(r.g),r.b=Ki(r.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Mt&&(r.r=ao(r.r),r.g=ao(r.g),r.b=ao(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===ci?ba:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[o].fromXYZ).multiply(this.spaces[s].toXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Sn]:{primaries:e,whitePoint:n,transfer:ba,toXYZ:fg,fromXYZ:dg,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:dt},outputColorSpaceConfig:{drawingBufferColorSpace:dt}},[dt]:{primaries:e,whitePoint:n,transfer:Mt,toXYZ:fg,fromXYZ:dg,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:dt}}}),i}var it=uS();function Ki(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ao(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Hs,fo=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Hs===void 0&&(Hs=uo("canvas")),Hs.width=e.width,Hs.height=e.height;let r=Hs.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Hs}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=uo("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o1),this.pmremVersion=0,this.isPMREMTexture=!1,this.normalized=!1}get width(){return this.source.getSize(mf).x}get height(){return this.source.getSize(mf).y}get depth(){return this.source.getSize(mf).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.mipmapsAutoUpdate=e.mipmapsAutoUpdate,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isPMREMTexture=e.isPMREMTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Oe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Oe(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,mipmapsAutoUpdate:this.mipmapsAutoUpdate,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ud)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case zn:e.x=e.x-Math.floor(e.x);break;case ln:e.x=e.x<0?0:1;break;case Ir:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case zn:e.y=e.y-Math.floor(e.y);break;case ln:e.y=e.y<0?0:1;break;case Ir:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Kt.DEFAULT_IMAGE=null;Kt.DEFAULT_MAPPING=ud;Kt.DEFAULT_ANISOTROPY=1;var Od=class Od{constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*r+o[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s,l=e.elements,c=l[0],u=l[4],h=l[8],f=l[1],d=l[5],p=l[9],x=l[2],m=l[6],g=l[10];if(Math.abs(u-f)<.01&&Math.abs(h-x)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+x)<.1&&Math.abs(p+m)<.1&&Math.abs(c+d+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let _=(c+1)/2,b=(d+1)/2,M=(g+1)/2,S=(u+f)/4,v=(h+x)/4,w=(p+m)/4;return _>b&&_>M?_<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(_),r=S/n,s=v/n):b>M?b<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(b),n=S/r,s=w/r):M<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(M),n=v/s,r=w/s),this.set(n,r,s,t),this}let y=Math.sqrt((m-p)*(m-p)+(h-x)*(h-x)+(f-u)*(f-u));return Math.abs(y)<.001&&(y=1),this.x=(m-p)/y,this.y=(h-x)/y,this.z=(f-u)/y,this.w=Math.acos((c+d+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=st(this.x,e.x,t.x),this.y=st(this.y,e.y,t.y),this.z=st(this.z,e.z,t.z),this.w=st(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=st(this.x,e,t),this.y=st(this.y,e,t),this.z=st(this.z,e,t),this.w=st(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(st(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Od.prototype.isVector4=!0;var vt=Od,Ic=class extends vi{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ht,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new vt(0,0,e,t),this.scissorTest=!1,this.viewport=new vt(0,0,e,t),this.textures=[];let r=n.count;for(let s=0;s1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(a=>({...a})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){r.children=[];for(let a=0;a0){r.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),p.length>0&&(n.nodes=p)}return n.object=r,n;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;nd+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=d-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.quaternion,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));a!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(bS)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new et;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Bx={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ar={h:0,s:0,l:0},$l={h:0,s:0,l:0};function xf(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var W=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=dt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=it.workingColorSpace){return this.r=e,this.g=t,this.b=n,it.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=it.workingColorSpace){if(e=wd(e,1),t=st(t,0,1),n=st(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=xf(o,s,e+1/3),this.g=xf(o,s,e),this.b=xf(o,s,e-1/3)}return it.colorSpaceToWorking(this,r),this}setStyle(e,t=dt){function n(s){s!==void 0&&parseFloat(s)<1&&Oe("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseFloat(s[1]))/100,Math.min(100,parseFloat(s[2]))/100,Math.min(100,parseFloat(s[3]))/100,t);break;case"hsl":case"hsla":if(s=/^\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Oe("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);Oe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=dt){let n=Bx[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Oe("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ki(e.r),this.g=Ki(e.g),this.b=Ki(e.b),this}copyLinearToSRGB(e){return this.r=ao(e.r),this.g=ao(e.g),this.b=ao(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=dt){return it.workingToColorSpace(pn.copy(this),e),Math.round(st(pn.r*255,0,255))*65536+Math.round(st(pn.g*255,0,255))*256+Math.round(st(pn.b*255,0,255))}getHexString(e=dt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(pn.copy(this),t);let n=pn.r,r=pn.g,s=pn.b,o=Math.max(n,r,s),a=Math.min(n,r,s),l,c,u=(a+o)/2;if(a===o)l=0,c=0;else{let h=o-a;switch(c=u<=.5?h/(o+a):h/(2-o-a),o){case n:l=(r-s)/h+(r0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){si.subVectors(r,t),Hi.subVectors(n,t),yf.subVectors(e,t);let o=si.dot(si),a=si.dot(Hi),l=si.dot(yf),c=Hi.dot(Hi),u=Hi.dot(yf),h=o*c-a*a;if(h===0)return s.set(0,0,0),null;let f=1/h,d=(c*l-a*u)*f,p=(o*u-a*l)*f;return s.set(1-d-p,p,d)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Wi)===null?!1:Wi.x>=0&&Wi.y>=0&&Wi.x+Wi.y<=1}static getInterpolation(e,t,n,r,s,o,a,l){return this.getBarycoord(e,t,n,r,Wi)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Wi.x),l.addScaledVector(o,Wi.y),l.addScaledVector(a,Wi.z),l)}static getInterpolatedAttribute(e,t,n,r,s,o){return Mf.setScalar(0),Sf.setScalar(0),wf.setScalar(0),Mf.fromBufferAttribute(e,t),Sf.fromBufferAttribute(e,n),wf.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(Mf,s.x),o.addScaledVector(Sf,s.y),o.addScaledVector(wf,s.z),o}static isFrontFacing(e,t,n,r){return si.subVectors(n,t),Hi.subVectors(e,t),si.cross(Hi).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return si.subVectors(this.c,this.b),Hi.subVectors(this.a,this.b),si.cross(Hi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return i.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,s=this.c,o,a;qs.subVectors(r,n),$s.subVectors(s,n),bf.subVectors(e,n);let l=qs.dot(bf),c=$s.dot(bf);if(l<=0&&c<=0)return t.copy(n);vf.subVectors(e,r);let u=qs.dot(vf),h=$s.dot(vf);if(u>=0&&h<=u)return t.copy(r);let f=l*h-u*c;if(f<=0&&l>=0&&u<=0&&l-u>0)return o=l/(l-u),t.copy(n).addScaledVector(qs,o);_f.subVectors(e,s);let d=qs.dot(_f),p=$s.dot(_f);if(p>=0&&d<=p)return t.copy(s);let x=d*c-l*p;if(x<=0&&c>=0&&p<=0)return a=c/(c-p),t.copy(n).addScaledVector($s,a);let m=u*p-d*h;if(m<=0&&h-u>=0&&d-p>=0)return _g.subVectors(s,r),a=(h-u)/(h-u+(d-p)),t.copy(r).addScaledVector(_g,a);let g=1/(m+x+f);return o=x*g,a=f*g,t.copy(n).addScaledVector(qs,o).addScaledVector($s,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Ct=class{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,oi),oi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(sa),Zl.subVectors(this.max,sa),Ks.subVectors(e.a,sa),Zs.subVectors(e.b,sa),Js.subVectors(e.c,sa),Er.subVectors(Zs,Ks),Rr.subVectors(Js,Zs),is.subVectors(Ks,Js);let t=[0,-Er.z,Er.y,0,-Rr.z,Rr.y,0,-is.z,is.y,Er.z,0,-Er.x,Rr.z,0,-Rr.x,is.z,0,-is.x,-Er.y,Er.x,0,-Rr.y,Rr.x,0,-is.y,is.x,0];return!Tf(t,Ks,Zs,Js,Zl)||(t=[1,0,0,0,1,0,0,0,1],!Tf(t,Ks,Zs,Js,Zl))?!1:(Jl.crossVectors(Er,Rr),t=[Jl.x,Jl.y,Jl.z],Tf(t,Ks,Zs,Js,Zl))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,oi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(oi).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Xi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Xi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Xi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Xi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Xi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Xi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Xi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Xi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Xi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Xi=[new D,new D,new D,new D,new D,new D,new D,new D],oi=new D,Kl=new Ct,Ks=new D,Zs=new D,Js=new D,Er=new D,Rr=new D,is=new D,sa=new D,Zl=new D,Jl=new D,rs=new D;function Tf(i,e,t,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){rs.fromArray(i,s);let a=r.x*Math.abs(rs.x)+r.y*Math.abs(rs.y)+r.z*Math.abs(rs.z),l=e.dot(rs),c=t.dot(rs),u=n.dot(rs);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var $t=new D,jl=new Ue,vS=0,wt=class extends vi{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:vS++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=_d,this.updateRanges=[],this.gpuType=Gn,this.version=0,this._normalizationScale=e!==void 0?Nu(e):void 0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this._normalizationScale=e._normalizationScale,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;oa.subVectors(e,this.center);let t=oa.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(oa,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Af.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(oa.copy(e.center).add(Af)),this.expandByPoint(oa.copy(e.center).sub(Af))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},MS=0,$n=new ze,Ef=new Et,js=new D,Bn=new Ct,aa=new Ct,rn=new D,Pe=class i extends vi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:MS++}),this.uuid=Ci(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(q1(e)?us:Ma)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new Xe().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return $n.makeRotationFromQuaternion(e),this.applyMatrix4($n),this}rotateX(e){return $n.makeRotationX(e),this.applyMatrix4($n),this}rotateY(e){return $n.makeRotationY(e),this.applyMatrix4($n),this}rotateZ(e){return $n.makeRotationZ(e),this.applyMatrix4($n),this}translate(e,t,n){return $n.makeTranslation(e,t,n),this.applyMatrix4($n),this}scale(e,t,n){return $n.makeScale(e,t,n),this.applyMatrix4($n),this}lookAt(e){return Ef.lookAt(e),Ef.updateMatrix(),this.applyMatrix4(Ef.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(js).negate(),this.translate(js.x,js.y,js.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let r=0,s=e.length;rt.count&&Oe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ct);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){We("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let r={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let h=0,f=c.length;h0&&(r[l]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let c in r){let u=r[c];this.setAttribute(c,u.clone(t))}let s=e.morphAttributes;for(let c in s){let u=[],h=s[c];for(let f=0,d=h.length;f1)?null:t.copy(e.start).addScaledVector(r,o)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||wS.getNormalMatrix(e),r=this.coplanarPoint(Rf).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},TS=0,gn=class extends vi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:TS++}),this.uuid=Ci(),this.name="",this.type="Material",this.blending=Ei,this.side=Ai,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=td,this.blendDst=nd,this.blendEquation=ys,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new W(0,0,0),this.blendAlpha=0,this.depthFunc=lo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Cx,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Sc,this.stencilZFail=Sc,this.stencilZPass=Sc,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){Oe(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Oe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.diffuseRoughness!==void 0&&(n.diffuseRoughness=this.diffuseRoughness),this.diffuseRoughnessMap&&this.diffuseRoughnessMap.isTexture&&(n.diffuseRoughnessMap=this.diffuseRoughnessMap.toJSON(e).uuid),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessMinimum=this.iridescenceThicknessMinimum),this.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessMaximum=this.iridescenceThicknessMaximum),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(s=>s.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(t){let s=r(e.textures),o=r(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new W().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.diffuseRoughness!==void 0&&(this.diffuseRoughness=e.diffuseRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessMinimum!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum),e.iridescenceThicknessMaximum!==void 0&&(this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],this.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1]),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(n=>new mn().fromJSON(n))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Ue().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ue().fromArray(e.clearcoatNormalScale)),e.diffuseRoughnessMap!==void 0&&(this.diffuseRoughnessMap=t[e.diffuseRoughnessMap]||null),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},_i=class extends gn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new W(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Qs,la=new D,eo=new D,to=new D,no=new Ue,ca=new Ue,zx=new ze,Ql=new D,ua=new D,ec=new D,Sg=new Ue,Cf=new Ue,wg=new Ue,er=class extends Et{constructor(e=new _i){if(super(),this.isSprite=!0,this.type="Sprite",Qs===void 0){Qs=new Pe;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new hs(t,5);Qs.setIndex([0,1,2,0,2,3]),Qs.setAttribute("position",new Lr(n,3,0,!1)),Qs.setAttribute("uv",new Lr(n,2,3,!1))}this.geometry=Qs,this.material=e,this.center=new Ue(.5,.5),this.count=1}intersectsFrustum(e){return e.intersectsSprite(this)}raycast(e,t){e.camera===null&&We('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),eo.setFromMatrixScale(this.matrixWorld),zx.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),to.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&eo.multiplyScalar(-to.z);let n=this.material.rotation,r,s;n!==0&&(s=Math.cos(n),r=Math.sin(n));let o=this.center;tc(Ql.set(-.5,-.5,0),to,o,eo,r,s),tc(ua.set(.5,-.5,0),to,o,eo,r,s),tc(ec.set(.5,.5,0),to,o,eo,r,s),Sg.set(0,0),Cf.set(1,0),wg.set(1,1);let a=e.ray.intersectTriangle(Ql,ua,ec,!1,la);if(a===null&&(tc(ua.set(-.5,.5,0),to,o,eo,r,s),Cf.set(0,1),a=e.ray.intersectTriangle(Ql,ec,ua,!1,la),a===null))return;let l=e.ray.origin.distanceTo(la);le.far||t.push({distance:l,point:la.clone(),uv:$i.getInterpolation(la,Ql,ua,ec,Sg,Cf,wg,new Ue),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}toJSON(e){let t=super.toJSON(e);return t.object.center=this.center.toArray(),t}};function tc(i,e,t,n,r,s){no.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(ca.x=s*no.x-r*no.y,ca.y=r*no.x+s*no.y):ca.copy(no),i.copy(e),i.x+=ca.x,i.y+=ca.y,i.applyMatrix4(zx)}var Yi=new D,Pf=new D,nc=new D,ic=new D,Fr=class{constructor(e=new D,t=new D(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Yi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Yi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Yi.copy(this.origin).addScaledVector(this.direction,t),Yi.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Pf.copy(e).add(t).multiplyScalar(.5),nc.copy(t).sub(e).normalize(),ic.copy(this.origin).sub(Pf);let s=e.distanceTo(t)*.5,o=-this.direction.dot(nc),a=ic.dot(this.direction),l=-ic.dot(nc),c=ic.lengthSq(),u=Math.abs(1-o*o),h,f,d,p;if(u>0)if(h=o*l-a,f=o*a-l,p=s*u,h>=0)if(f>=-p)if(f<=p){let x=1/u;h*=x,f*=x,d=h*(h+o*f+2*a)+f*(o*h+f+2*l)+c}else f=s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*l)+c;else f=-s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*l)+c;else f<=-p?(h=Math.max(0,-(-o*s+a)),f=h>0?-s:Math.min(Math.max(-s,-l),s),d=-h*h+f*(f+2*l)+c):f<=p?(h=0,f=Math.min(Math.max(-s,-l),s),d=f*(f+2*l)+c):(h=Math.max(0,-(o*s+a)),f=h>0?s:Math.min(Math.max(-s,-l),s),d=-h*h+f*(f+2*l)+c);else f=o>0?-s:s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(Pf).addScaledVector(nc,f),d}intersectSphere(e,t){if(e.radius<0)return null;Yi.subVectors(e.center,this.origin);let n=Yi.dot(this.direction),r=Yi.dot(Yi)-n*n,s=e.radius*e.radius;if(r>s)return null;let o=Math.sqrt(s-r),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,o,a,l,c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return c>=0?(n=(e.min.x-f.x)*c,r=(e.max.x-f.x)*c):(n=(e.max.x-f.x)*c,r=(e.min.x-f.x)*c),u>=0?(s=(e.min.y-f.y)*u,o=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,o=(e.min.y-f.y)*u),n>o||s>r||((s>n||isNaN(n))&&(n=s),(o=0?(a=(e.min.z-f.z)*h,l=(e.max.z-f.z)*h):(a=(e.max.z-f.z)*h,l=(e.min.z-f.z)*h),n>l||a>r)||((a>n||n!==n)&&(n=a),(l=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Yi)!==null}intersectTriangle(e,t,n,r,s){let o=this.origin,a=this.direction,l=a.x,c=a.y,u=a.z,h=e.x-o.x,f=e.y-o.y,d=e.z-o.z,p=t.x-o.x,x=t.y-o.y,m=t.z-o.z,g=n.x-o.x,y=n.y-o.y,_=n.z-o.z,b=Math.abs(l),M=Math.abs(c),S=Math.abs(u),v,w,P,T,R,L,k,C,I,O,F,H;if(b>=M&&b>=S?(P=l,L=h,I=p,H=g,l>=0?(v=c,w=u,T=f,R=d,k=x,C=m,O=y,F=_):(v=u,w=c,T=d,R=f,k=m,C=x,O=_,F=y)):M>=S?(P=c,L=f,I=x,H=y,c>=0?(v=u,w=l,T=d,R=h,k=m,C=p,O=_,F=g):(v=l,w=u,T=h,R=d,k=p,C=m,O=g,F=_)):(P=u,L=d,I=m,H=_,u>=0?(v=l,w=c,T=h,R=f,k=p,C=x,O=g,F=y):(v=c,w=l,T=f,R=h,k=x,C=p,O=y,F=g)),P===0)return null;let U=v/P,X=w/P,V=1/P,re=T-U*L,ye=R-X*L,Y=k-U*I,Q=C-X*I,se=O-U*H,we=F-X*H,le=se*Q-we*Y,Ne=re*we-ye*se,at=Y*ye-Q*re;if(r){if(le<0||Ne<0||at<0)return null}else if((le<0||Ne<0||at<0)&&(le>0||Ne>0||at>0))return null;let Ae=le+Ne+at;if(Ae===0)return null;let ft=V*(le*L+Ne*I+at*H);return(Ae>0?ft<0:ft>0)?null:this.at(ft/Ae,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ye=class extends gn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new W(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Zn,this.combine=$c,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Tg=new ze,ss=new Fr,rc=new Pn,Ag=new D,sc=new D,oc=new D,ac=new D,If=new D,lc=new D,Eg=new D,cc=new D,Se=class extends Et{constructor(e=new Pe,t=new Ye){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0?this.morphTargetInfluences=e.morphTargetInfluences.slice():this.morphTargetInfluences=void 0,e.morphTargetDictionary!==void 0?this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary):this.morphTargetDictionary=void 0,this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s(e.far-e.near)**2))&&(Tg.copy(s).invert(),ss.copy(e.ray).applyMatrix4(Tg),!(n.boundingBox!==null&&ss.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ss)))}_computeIntersections(e,t,n){let r,s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,f=s.groups,d=s.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,x=f.length;pt.far?null:{distance:c,point:cc.clone(),object:i}}function uc(i,e,t,n,r,s,o,a,l,c){i.getVertexPosition(a,sc),i.getVertexPosition(l,oc),i.getVertexPosition(c,ac);let u=AS(i,e,t,n,sc,oc,ac,Eg);if(u){let h=new D;$i.getBarycoord(Eg,sc,oc,ac,h),r&&(u.uv=$i.getInterpolatedAttribute(r,a,l,c,h,new Ue)),s&&(u.uv1=$i.getInterpolatedAttribute(s,a,l,c,h,new Ue)),o&&(u.normal=$i.getInterpolatedAttribute(o,a,l,c,h,new D),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));let f={a,b:l,c,normal:new D,materialIndex:0};$i.getNormal(sc,oc,ac,f.normal),u.face=f,u.barycoord=h}return u}var ha=new vt,Rg=new vt,Cg=new vt,ES=new vt,Pg=new ze,hc=new D,Lf=new Pn,Ig=new ze,Ff=new Fr,Sa=class extends Se{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Uf,this.bindMatrix=new ze,this.bindMatrixInverse=new ze,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ct),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n0?e.max.x:e.min.x,dc.y=r.normal.y>0?e.max.y:e.min.y,dc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(dc)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},Og=new ze,Fc=class i{constructor(){this.coordinateSystem=Kn,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let r=0;r0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;sn)return;Nf.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(Nf);if(!(ce.far))return{distance:c,point:Ug.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var kg=new D,Bg=new D,xn=class extends In{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let r=0,s=t.count;r0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;sr.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var Or=class extends Kt{constructor(e=[],t,n,r,s,o,a,l,c,u,h,f){super(null,o,a,l,c,u,r,s,h,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}};var Aa=class extends Kt{constructor(e=[],t=bs,n,r,s,o,a,l,c,u){super(e,t,n,r,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},zt=class extends Kt{constructor(e,t,n,r,s,o,a,l,c){super(e,t,n,r,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var nr=class extends Kt{constructor(e,t,n=ai,r,s,o,a=Ut,l=Ut,c,u=Zi,h=1){if(u!==Zi&&u!==hr)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:h};super(f,r,s,o,a,l,u,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Qi(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},Ea=class extends nr{constructor(e,t=ai,n=bs,r,s,o=Ut,a=Ut,l,c=Zi){let u={width:e,height:e,depth:1},h=[u,u,u,u,u,u];super(e,e,t,n,r,s,o,a,l,c),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Ra=class extends Kt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Mi=class i extends Pe{constructor(e=1,t=1,n=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:o};let a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let l=[],c=[],u=[],h=[],f=0,d=0;p("z","y","x",-1,-1,n,t,e,o,s,0),p("z","y","x",1,-1,n,t,-e,o,s,1),p("x","z","y",1,1,e,n,t,r,o,2),p("x","z","y",1,-1,e,n,-t,r,o,3),p("x","y","z",1,-1,e,t,n,r,s,4),p("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new Le(c,3)),this.setAttribute("normal",new Le(u,3)),this.setAttribute("uv",new Le(h,2));function p(x,m,g,y,_,b,M,S,v,w,P){let T=b/v,R=M/w,L=b/2,k=M/2,C=S/2,I=v+1,O=w+1,F=0,H=0,U=new D;for(let X=0;X0?1:-1,u.push(U.x,U.y,U.z),h.push(re/v),h.push(1-X/w),F+=1}}for(let X=0;X0&&_(!0),t>0&&_(!1)),this.setIndex(u),this.setAttribute("position",new Le(h,3)),this.setAttribute("normal",new Le(f,3)),this.setAttribute("uv",new Le(d,2));function y(){let b=new D,M=new D,S=0,v=(t-e)/n;for(let w=0;w<=s;w++){let P=[],T=w/s,R=T*(t-e)+e;for(let L=0;L<=r;L++){let k=L/r,C=k*l+a,I=Math.sin(C),O=Math.cos(C);M.x=R*I,M.y=-T*n+m,M.z=R*O,h.push(M.x,M.y,M.z),b.set(I,v,O).normalize(),f.push(b.x,b.y,b.z),d.push(k,1-T),P.push(p++)}x.push(P)}for(let w=0;w0||P!==0)&&(u.push(T,R,k),S+=3),(t>0||P!==s-1)&&(u.push(R,L,k),S+=3)}c.addGroup(g,S,0),g+=S}function _(b){let M=p,S=new Ue,v=new D,w=0,P=b===!0?e:t,T=b===!0?1:-1;for(let L=1;L<=r;L++)h.push(0,m*T,0),f.push(0,T,0),d.push(.5,.5),p++;let R=p;for(let L=0;L<=r;L++){let C=L/r*l+a,I=Math.cos(C),O=Math.sin(C);v.x=P*O,v.y=m*T,v.z=P*I,h.push(v.x,v.y,v.z),f.push(0,T,0),S.x=I*.5+.5,S.y=O*.5*T+.5,d.push(S.x,S.y),p++}for(let L=0;L80*t){a=i[0],l=i[1];let u=a,h=l;for(let f=t;fu&&(u=d),p>h&&(h=p)}c=Math.max(u-a,h-l),c=c!==0?32767/c:0}return Pa(s,o,t,a,l,c,0),o}function Vx(i,e,t,n,r){let s;if(r===qS(i,e,t,n)>0)for(let o=e;o=e;o-=n)s=Gg(o/n|0,i[o],i[o+1],s);return s&&yo(s,s.next)&&(La(s),s=s.next),s}function ps(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(yo(t,t.next)||Dt(t.prev,t,t.next)===0)){if(La(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Pa(i,e,t,n,r,s,o){if(!i)return;!o&&s&&VS(i,n,r,s);let a=i;for(;i.prev!==i.next;){let l=i.prev,c=i.next;if(s?FS(i,n,r,s):LS(i)){e.push(l.i,i.i,c.i),La(i),i=c.next,a=c.next;continue}if(i=c,i===a){o?o===1?(i=NS(ps(i),e),Pa(i,e,t,n,r,s,2)):o===2&&OS(i,e,t,n,r,s):Pa(ps(i),e,t,n,r,s,1);break}}}function LS(i){let e=i.prev,t=i,n=i.next;if(Dt(e,t,n)>=0)return!1;let r=e.x,s=t.x,o=n.x,a=e.y,l=t.y,c=n.y,u=Math.min(r,s,o),h=Math.min(a,l,c),f=Math.max(r,s,o),d=Math.max(a,l,c),p=n.next;for(;p!==e;){if(p.x>=u&&p.x<=f&&p.y>=h&&p.y<=d&&ma(r,a,s,l,o,c,p.x,p.y)&&Dt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function FS(i,e,t,n){let r=i.prev,s=i,o=i.next;if(Dt(r,s,o)>=0)return!1;let a=r.x,l=s.x,c=o.x,u=r.y,h=s.y,f=o.y,d=Math.min(a,l,c),p=Math.min(u,h,f),x=Math.max(a,l,c),m=Math.max(u,h,f),g=Hf(d,p,e,t,n),y=Hf(x,m,e,t,n),_=i.prevZ,b=i.nextZ;for(;_&&_.z>=g&&b&&b.z<=y;){if(_.x>=d&&_.x<=x&&_.y>=p&&_.y<=m&&_!==r&&_!==o&&ma(a,u,l,h,c,f,_.x,_.y)&&Dt(_.prev,_,_.next)>=0||(_=_.prevZ,b.x>=d&&b.x<=x&&b.y>=p&&b.y<=m&&b!==r&&b!==o&&ma(a,u,l,h,c,f,b.x,b.y)&&Dt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;_&&_.z>=g;){if(_.x>=d&&_.x<=x&&_.y>=p&&_.y<=m&&_!==r&&_!==o&&ma(a,u,l,h,c,f,_.x,_.y)&&Dt(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;b&&b.z<=y;){if(b.x>=d&&b.x<=x&&b.y>=p&&b.y<=m&&b!==r&&b!==o&&ma(a,u,l,h,c,f,b.x,b.y)&&Dt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function NS(i,e){let t=i;do{let n=t.prev,r=t.next.next;!yo(n,r)&&Hx(n,t,t.next,r)&&Ia(n,r)&&Ia(r,n)&&(e.push(n.i,t.i,r.i),La(t),La(t.next),t=i=r),t=t.next}while(t!==i);return ps(t)}function OS(i,e,t,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&WS(o,a)){let l=Wx(o,a);o=ps(o,o.next),l=ps(l,l.next),Pa(o,e,t,n,r,s,0),Pa(l,e,t,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function DS(i,e,t,n){let r=[];for(let s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){let h=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=n&&h>s&&(s=h,o=t.x=t.x&&t.x>=l&&n!==t.x&&Gx(ro.x||t.x===o.x&&zS(o,t)))&&(o=t,u=h)}t=t.next}while(t!==a);return o}function zS(i,e){return Dt(i.prev,i,e.prev)<0&&Dt(e.next,i,i.next)<0}function VS(i,e,t,n){let r=i;do r.z===0&&(r.z=Hf(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,GS(r)}function GS(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let o=n,a=0;for(let c=0;c0||l>0&&o;)a!==0&&(l===0||!o||n.z<=o.z)?(r=n,n=n.nextZ,a--):(r=o,o=o.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=o}s.nextZ=null,t*=2}while(e>1);return i}function Hf(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function HS(i){let e=i,t=i;do(e.x=(i-o)*(s-a)&&(i-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(n-a)}function ma(i,e,t,n,r,s,o,a){return!(i===o&&e===a)&&Gx(i,e,t,n,r,s,o,a)}function WS(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!XS(i,e)&&(Ia(i,e)&&Ia(e,i)&&YS(i,e)&&(Dt(i.prev,i,e.prev)||Dt(i,e.prev,e))||yo(i,e)&&Dt(i.prev,i,i.next)>0&&Dt(e.prev,e,e.next)>0)}function Dt(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function yo(i,e){return i.x===e.x&&i.y===e.y}function Hx(i,e,t,n){let r=bc(Dt(i,e,t)),s=bc(Dt(i,e,n)),o=bc(Dt(t,n,i)),a=bc(Dt(t,n,e));return!!(r!==s&&o!==a||r===0&&yc(i,t,e)||s===0&&yc(i,n,e)||o===0&&yc(t,i,n)||a===0&&yc(t,e,n))}function yc(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function bc(i){return i>0?1:i<0?-1:0}function XS(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Hx(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function Ia(i,e){return Dt(i.prev,i,i.next)<0?Dt(i,e,i.next)>=0&&Dt(i,i.prev,e)>=0:Dt(i,e,i.prev)<0||Dt(i,i.next,e)<0}function YS(i,e){let t=i,n=!1,r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Wx(i,e){let t=Wf(i.i,i.x,i.y),n=Wf(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Gg(i,e,t,n){let r=Wf(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function La(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Wf(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function qS(i,e,t,n){let r=0;for(let s=e,o=t-n;s2&&i[e-1].equals(i[0])&&i.pop()}function Wg(i,e){for(let t=0;t0)&&d.push(_,b,S),(g!==n-1||l`pack:${i}:${e}`,k1=i=>i.startsWith("pack:");function Gl(i){O1=i,ta=new Map;for(let e of i)for(let t of e.items)ta.set(B0(e.id,t.id),t);D1+=1}var U1={};function _t(i){if(!k1(i))return;let e=ta.get(i);if(e)return e;let[,t,...n]=i.split(":"),r=U1[t];return r?ta.get(B0(r,n.join(":"))):void 0}var B1=.22;function k0(i,e,t,n){let r=Math.min(B1,t/3);if(n<=r*2.4||Math.abs(n-t)<1e-6)return e*(n/t)+(i-e)*(n/t);let s=e*(n/t),o=i-e;return o<=r?s+o:o>=t-r?s+n-(t-o):s+r+(o-r)*(n-2*r)/(t-2*r)}function ea(i,e,t,n,r){return[k0(i*n,t*n,n,r)/r,k0(e*n,t*n,n,r)/r]}var U0=new WeakMap;function na(i,e,t,n){let[r,s,o]=i.size;if(i.vehicle||i.stretch||Math.abs(e-r)<1e-4&&Math.abs(t-s)<1e-4&&Math.abs(n-o)<1e-4)return i.parts;let a=`${e.toFixed(4)}|${t.toFixed(4)}|${n.toFixed(4)}`,l=U0.get(i),c=l?.get(a);if(c)return c;let u=i.parts.map(h=>{if(h.shape==="sweep")return h;let[f,d]=ea(h.x-h.w/2,h.x+h.w/2,-.5,r,e),[p,x]=ea(h.z-h.d/2,h.z+h.d/2,-.5,s,t),[m,g]=ea(h.y,h.y+h.h,0,o,n);if(h.rot)return{...h,x:(f+d)/2,z:(p+x)/2,w:h.w*r/e,d:h.d*s/t,y:m,h:g-m};let y={...h,x:(f+d)/2,z:(p+x)/2,w:d-f,d:x-p,y:m,h:g-m};if(h.shape==="loft"){let[_,b,M,S]=[h.tx??h.x,h.tz??h.z,h.tw??h.w,h.td??h.d],[v,w]=ea(_-M/2,_+M/2,-.5,r,e),[P,T]=ea(b-S/2,b+S/2,-.5,s,t);Object.assign(y,{tx:(v+w)/2,tz:(P+T)/2,tw:w-v,td:T-P})}return y});return l||U0.set(i,l=new Map),l.size>32&&l.clear(),l.set(a,u),u}var z0=i=>!!i?.parts.some(e=>e.move);function V0(i,e){if(e===null)return Math.min(1,Math.max(0,i.cover_rest??1));let t=Math.min(1,Math.max(0,e/100));return i.cover==="extends"?t:1-t}function G0(i,e){let t=[];for(let n of i){if(!n.move)continue;let r={...n},s=(o,a)=>a+(o-a)*e;if(n.move==="down"){let[o,a]=[s(n.y,1),s(n.y+n.h,1)];Object.assign(r,{y:o,h:a-o})}else if(n.move==="left"||n.move==="right"){let o=n.move==="left"?-.5:.5,[a,l]=[s(n.x-n.w/2,o),s(n.x+n.w/2,o)];if(Object.assign(r,{x:(a+l)/2,w:Math.abs(l-a)}),n.tx!==void 0||n.tw!==void 0){let[c,u]=[s((n.tx??n.x)-(n.tw??n.w)/2,o),s((n.tx??n.x)+(n.tw??n.w)/2,o)];Object.assign(r,{tx:(c+u)/2,tw:Math.abs(u-c)})}}else if(n.move==="out"){let[o,a]=[s(n.z-n.d/2,-.5),s(n.z+n.d/2,-.5)];if(Object.assign(r,{z:(o+a)/2,d:a-o}),n.tz!==void 0||n.td!==void 0){let[l,c]=[s((n.tz??n.z)-(n.td??n.d)/2,-.5),s((n.tz??n.z)+(n.td??n.d)/2,-.5)];Object.assign(r,{tz:(l+c)/2,td:c-l})}}else{let o=(1-e)*n.w*(n.move==="slide_left"?-1:1);Object.assign(r,{x:n.x+o,...n.tx!==void 0?{tx:n.tx+o}:{}})}r.w>.002&&r.d>.002&&r.h>.002&&t.push(r)}return t}function Gt(i,e){return e.mount_y!=null?e.mount_y:V1(i,e)+(z1(e)?0:$0(i,e.x,e.z))}var z1=i=>i.type==="led_strip"||_t(i.type)?.mount==="ceiling";function V1(i,e){if(e.type==="lamp_wall")return Wl;if(e.type==="led_strip")return Math.max(0,uf(i,e.x,e.z)-.04-Math.max(.02,e.h));let t=_t(e.type);if(!t)return jr(e);switch(t.mount){case"surface":return K0(i,e.x,e.z);case"wall":return t.wall_y??1;case"ceiling":return Math.max(0,Xl(i,e)-e.h);default:return 0}}var H0=null,W0=new Set,X0=i=>{H0=i},Y0=()=>H0,q0=i=>{W0.add(i)};function Hl(i){let e=ta.get(i)?.mesh;return e!==void 0&&W0.has(e)}var Z0=1.3,J0=(i,e=new Date().toISOString().slice(0,10))=>!!i.due&&i.due<=e;var Yl={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 Qr(i){return i==="hedge"||i==="fence"||i==="pergola"}function hf(i,e,t){let n=i.slope??0;if(!n||i.type==="pool")return 0;let r=i.slope_dir??"x",s=(c,u)=>r==="x"?c:r==="-x"?-c:r==="z"?u:-u,o=1/0,a=-1/0;for(let[c,u]of i.points){let h=s(c,u);o=Math.min(o,h),a=Math.max(a,h)}if(a-o<1e-6)return 0;let l=Math.min(1,Math.max(0,(s(e,t)-o)/(a-o)));return n*l}function H1(i,e,t,n){return ia(i)+(e.offset??0)+Yl[e.type]-hf(e,t,n)}function ia(i){return i.elevation>.3?0:-.2}function j0(i,e,t){let n=(i.outdoor??[]).filter(s=>!Qr(s.type)&&s.type!=="pool"&&Ge([e,t],s.points)),r=[...n].reverse().find(s=>s.cut)??n[0];return r?H1(i,r,e,t):ia(i)}var Q0=i=>i.cut??(i.type==="pool"||i.type==="river"||i.type==="stream");function eg(i){let e=Number.isFinite(i.texture_scale)?Math.max(.05,Math.min(20,i.texture_scale)):1,t=Number.isFinite(i.texture_rotation)?(i.texture_rotation%360+360)%360:0;return{scale:e,rotation:t}}var W1={type:"none",pitch:35,overhang:.4},tg="#d6cfc2",ff="#e8e3da",PI={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...W1}};var ng=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"]),Wl=1.75;function ig(i){return ng.has(i)||!!_t(i)?.light}var X1=new Set(["table","table_round","coffee_table","desk","nightstand","sideboard","dresser","kitchen","island","worktop","tv_board","dishwasher","washer","dryer"]);function jr(i){switch(i.type){case"home_battery":return i.variant==="wall"?.5:0;case"kitchen_wall":return 1.45;case"tv_wall":return Math.max(0,1.3-i.h/2);case"radiator":return .12;case"inverter":return 1.1;case"wallbox":return 1;case"meter":return .4;default:return 0}}var rg=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function sg(i,e){return i.filter(t=>t.elevationt.rooms.filter(n=>n.points.length>=3&&n.ceiling!=null&&n.ceiling>t.height+.005&&t.elevation+n.ceiling>e.elevation+.05)).map(t=>t.points)}var es=i=>i?.floor_offset&&Number.isFinite(i.floor_offset)?i.floor_offset:0;function $0(i,e,t){let n=i.rooms.find(r=>r.points.length>=3&&r.floor_offset&&Ge([e,t],r.points));return es(n)}function uf(i,e,t){let n=i.rooms.find(r=>r.points.length>=3&&Ge([e,t],r.points));return n?.ceiling!=null&&n.ceiling>0?n.ceiling:i.height}var Xl=(i,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:uf(i,e.x,e.z);function K0(i,e,t){let n=0;for(let r of i.furniture)!(X1.has(r.type)||_t(r.type)?.surface)||!Ge([e,t],ns(r))||(n=Math.max(n,r.h));return n}var G1=new Set([...ng,"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"]);var Y1=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],q1=["standard","bars","glass_wall"];function Sr(i,e){return i.type==="door"?i.style&&Y1.includes(i.style)?i.style:e?"front":"interior":i.style&&q1.includes(i.style)?i.style:"standard"}function og(i,e,t,n){if(e!=="sidelight"&&e!=="sidelights")return null;let r=e==="sidelights",s=i-.04,o=Math.min(1.05,Math.max(.6,s-(r?.6:.3))),a=(s-o)/(r?2:1),l=n.sidelight_width??a,c=r?n.sidelight_width2??n.sidelight_width??a:0;l=Math.max(.1,l),c=r?Math.max(.1,c):0;let u=s-.5;if(l+c>u){let f=Math.max(0,u)/(l+c);l*=f,c*=f}return r?{panels:[[.02,.02+l],[i-.02-c,i-.02]],x0:.02+l,x1:i-.02-c}:(t?!!n.sidelight_hinge:!n.sidelight_hinge)?{panels:[[.02,.02+l]],x0:.02+l,x1:i-.02}:{panels:[[i-.02-l,i-.02]],x0:.02,x1:i-.02-l}}function ag(i){return i==="front"||i==="front_glass"||i==="sidelight"||i==="sidelights"}function ts(i){let e=0;for(let t=0;ts+o[0],0)/r,i.reduce((s,o)=>s+o[1],0)/r]}let t=0,n=0;for(let r=0;r1e-6&&Math.abs(n-s)>1e-6)return!1}return!0}function cg(i){let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let[s,o]of i)e=Math.min(e,s),t=Math.min(t,o),n=Math.max(n,s),r=Math.max(r,o);return{x0:e,z0:t,x1:n,z1:r}}function ns(i){let e=i.rotation*Math.PI/180,t=Math.cos(e),n=Math.sin(e),r=i.w/2,s=i.d/2;return[[-r,-s],[r,-s],[r,s],[-r,s]].map(([o,a])=>[i.x+o*t-a*n,i.z+o*n+a*t])}function Ge(i,e){let t=!1;for(let n=0,r=e.length-1;ni[1]!=l>i[1]&&i[0]<(a-s)*(i[1]-o)/(l-o)+s&&(t=!t)}return t}function $1(i){return i?.outdoor_building_id?{kind:"building",id:i.outdoor_building_id}:i?.outdoor_branch_id?{kind:"branch",id:i.outdoor_branch_id}:i?.outdoor_location_id?{kind:"location",id:i.outdoor_location_id}:null}var ra=i=>!!$1(i);var ix=0,ed=1,rx=2;var Xa=1,sx=2,Mo=3,Ai=0,un=1,ht=2,xs=0,Ei=1,Ft=2,td=3,Ya=4,ox=5;var ys=100,ax=101,lx=102,cx=103,ux=104,hx=200,fx=201,dx=202,px=203,nd=204,id=205,mx=206,gx=207,xx=208,yx=209,bx=210,vx=211,_x=212,Mx=213,Sx=214,Tc=0,Ac=1,Ec=2,lo=3,Rc=4,Cc=5,Pc=6,Ic=7,Kc=0,wx=1,Tx=2,Ri=0,rd=1,sd=2,od=3,ad=4,ld=5,cd=6,ud=7,Uf="attached",Ax="detached",hd=300,bs=301,So=302,Zc=303,Jc=304,zn=1e3,ln=1001,Ir=1002,kt=1003,wo=1004;var ur=1005;var Ht=1006,Ur=1007;var Nn=1008;var On=1009,fd=1010,dd=1011,To=1012,jc=1013,ai=1014,Gn=1015,li=1016,Qc=1017,eu=1018,vs=1020,pd=35902,md=35899,gd=1021,xd=1022,Dn=1023,Zi=1026,hr=1027,tu=1028,nu=1029,Br=1030,iu=1031;var ru=1033,qa=33776,$a=33777,Ka=33778,Za=33779,su=35840,ou=35841,au=35842,lu=35843,cu=36196,uu=37492,hu=37496,fu=37488,du=37489,Ja=37490,pu=37491,mu=37808,gu=37809,xu=37810,yu=37811,bu=37812,vu=37813,_u=37814,Mu=37815,Su=37816,wu=37817,Tu=37818,Au=37819,Eu=37820,Ru=37821,Cu=36492,Pu=36494,Iu=36495,Lu=36283,Fu=36284,ja=36285,Nu=36286;var Ji=2300,ji=2301,Sc=2302,Bf=2303,zf=2400,Vf=2401,Gf=2402,Ex=2500;var yd=0,Qa=1,Ao=2,Rx=3200;var el=0,Cx=1,ci="",dt="srgb",Sn="srgb-linear",va="linear",Mt="srgb";var wc=7680;var Px=519,Ix=512,Lx=513,Fx=514,bd=515,Nx=516,Ox=517,vd=518,_d=519,Md=35044,Sd=35048;var wd="300 es",Kn=2e3,co=2001;function K1(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Z1(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function uo(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Dx(){let i=uo("canvas");return i.style.display="block",i}var ug={},ho=null;function _a(...i){let e="THREE."+i.shift();ho?ho("log",e,...i):console.log(e,...i)}function kx(i){let e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Oe(...i){i=kx(i);let e="THREE."+i.shift();if(ho)ho("warn",e,...i);else{let t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function We(...i){i=kx(i);let e="THREE."+i.shift();if(ho)ho("error",e,...i);else{let t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function as(...i){let e=i.join(" ");e in ug||(ug[e]=!0,Oe(...i))}function Ux(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}var Bx={[Tc]:Tc,[Ec]:Pc,[Rc]:Rc,[lo]:Cc,[Ac]:Ac,[Pc]:Ec,[Ic]:Ic,[Cc]:lo},vi=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners;if(n===void 0)return;let r=n[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){let t=this._listeners;if(t===void 0)return;let n=t[e.type];if(n!==void 0){e.target=this;let r=n.slice(0);for(let s=0,o=r.length;s>8&255]+dn[i>>16&255]+dn[i>>24&255]+"-"+dn[e&255]+dn[e>>8&255]+"-"+dn[e>>16&15|64]+dn[e>>24&255]+"-"+dn[t&63|128]+dn[t>>8&255]+"-"+dn[t>>16&255]+dn[t>>24&255]+dn[n&255]+dn[n>>8&255]+dn[n>>16&255]+dn[n>>24&255]).toLowerCase()}function st(i,e,t){return Math.max(e,Math.min(t,i))}function Td(i,e){return(i%e+e)%e}function J1(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function j1(i,e,t){return i!==e?(t-i)/(e-i):0}function ba(i,e,t){return(1-t)*i+t*e}function Q1(i,e,t,n){return ba(i,e,1-Math.exp(-t*n))}function eS(i,e=1){return e-Math.abs(Td(i,e*2)-e)}function tS(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function nS(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function iS(i,e){return i+Math.floor(Math.random()*(e-i+1))}function rS(i,e){return i+Math.random()*(e-i)}function sS(i){return i*(.5-Math.random())}function oS(i){i!==void 0&&(hg=i);let e=hg+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function aS(i){return i*ya}function lS(i){return i*ls}function cS(i){return i>0&&Number.isInteger(i)&&2**Math.round(Math.log2(i))===i}function uS(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Ad(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function hS(i,e,t,n,r){let s=Math.cos,o=Math.sin,a=s(t/2),l=o(t/2),c=s((e+n)/2),u=o((e+n)/2),h=s((e-n)/2),f=o((e-n)/2),d=s((n-e)/2),p=o((n-e)/2);switch(r){case"XYX":i.set(a*u,l*h,l*f,a*c);break;case"YZY":i.set(l*f,a*u,l*h,a*c);break;case"ZXZ":i.set(l*h,l*f,a*u,a*c);break;case"XZX":i.set(a*u,l*p,l*d,a*c);break;case"YXY":i.set(l*d,a*u,l*p,a*c);break;case"ZYZ":i.set(l*p,l*d,a*u,a*c);break;default:Oe("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Ou(i){switch(i.constructor){case Uint32Array:return 4294967295;case Uint16Array:return 65535;case Uint8Array:case Uint8ClampedArray:return 255;case Int32Array:return 2147483647;case Int16Array:return 32767;case Int8Array:return 127;default:return}}function Ed(i,e){if(e.constructor===Float32Array)return i;let t=Ou(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.max(i/t,-1)}function Rd(i,e){if(e.constructor===Float32Array)return i;let t=Ou(e);if(t===void 0)throw new Error("THREE.MathUtils: Invalid component type.");return Math.round(i*t)}var zr={DEG2RAD:ya,RAD2DEG:ls,generateUUID:Ci,clamp:st,euclideanModulo:Td,mapLinear:J1,inverseLerp:j1,lerp:ba,damp:Q1,pingpong:eS,smoothstep:tS,smootherstep:nS,randInt:iS,randFloat:rS,randFloatSpread:sS,seededRandom:oS,degToRad:aS,radToDeg:lS,isPowerOfTwo:cS,ceilPowerOfTwo:uS,floorPowerOfTwo:Ad,setQuaternionFromProperEuler:hS,normalize:Rd,denormalize:Ed},Fd=class Fd{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=st(this.x,e.x,t.x),this.y=st(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=st(this.x,e,t),this.y=st(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(st(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(st(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*r+e.x,this.y=s*r+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};Fd.prototype.isVector2=!0;var ke=Fd,wn=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,o,a){let l=n[r+0],c=n[r+1],u=n[r+2],h=n[r+3],f=s[o+0],d=s[o+1],p=s[o+2],x=s[o+3];if(h!==x||l!==f||c!==d||u!==p){let m=l*f+c*d+u*p+h*x;m<0&&(f=-f,d=-d,p=-p,x=-x,m=-m);let g=1-a;if(m<.9995){let y=Math.acos(m),_=Math.sin(y);g=Math.sin(g*y)/_,a=Math.sin(a*y)/_,l=l*g+f*a,c=c*g+d*a,u=u*g+p*a,h=h*g+x*a}else{l=l*g+f*a,c=c*g+d*a,u=u*g+p*a,h=h*g+x*a;let y=1/Math.sqrt(l*l+c*c+u*u+h*h);l*=y,c*=y,u*=y,h*=y}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,r,s,o){let a=n[r],l=n[r+1],c=n[r+2],u=n[r+3],h=s[o],f=s[o+1],d=s[o+2],p=s[o+3];return e[t]=a*p+u*h+l*d-c*f,e[t+1]=l*p+u*f+c*h-a*d,e[t+2]=c*p+u*d+a*f-l*h,e[t+3]=u*p-a*h-l*f-c*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,l=Math.sin,c=a(n/2),u=a(r/2),h=a(s/2),f=l(n/2),d=l(r/2),p=l(s/2);switch(o){case"XYZ":this._x=f*u*h+c*d*p,this._y=c*d*h-f*u*p,this._z=c*u*p+f*d*h,this._w=c*u*h-f*d*p;break;case"YXZ":this._x=f*u*h+c*d*p,this._y=c*d*h-f*u*p,this._z=c*u*p-f*d*h,this._w=c*u*h+f*d*p;break;case"ZXY":this._x=f*u*h-c*d*p,this._y=c*d*h+f*u*p,this._z=c*u*p+f*d*h,this._w=c*u*h-f*d*p;break;case"ZYX":this._x=f*u*h-c*d*p,this._y=c*d*h+f*u*p,this._z=c*u*p-f*d*h,this._w=c*u*h+f*d*p;break;case"YZX":this._x=f*u*h+c*d*p,this._y=c*d*h+f*u*p,this._z=c*u*p-f*d*h,this._w=c*u*h-f*d*p;break;case"XZY":this._x=f*u*h-c*d*p,this._y=c*d*h-f*u*p,this._z=c*u*p+f*d*h,this._w=c*u*h+f*d*p;break;default:Oe("Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],s=t[8],o=t[1],a=t[5],l=t[9],c=t[2],u=t[6],h=t[10],f=n+a+h;if(f>0){let d=.5/Math.sqrt(f+1);this._w=.25/d,this._x=(u-l)*d,this._y=(s-c)*d,this._z=(o-r)*d}else if(n>a&&n>h){let d=2*Math.sqrt(1+n-a-h);this._w=(u-l)/d,this._x=.25*d,this._y=(r+o)/d,this._z=(s+c)/d}else if(a>h){let d=2*Math.sqrt(1+a-n-h);this._w=(s-c)/d,this._x=(r+o)/d,this._y=.25*d,this._z=(l+u)/d}else{let d=2*Math.sqrt(1+h-n-a);this._w=(o-r)/d,this._x=(s+c)/d,this._y=(l+u)/d,this._z=.25*d}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(st(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,s=e._z,o=e._w,a=t._x,l=t._y,c=t._z,u=t._w;return this._x=n*u+o*a+r*c-s*l,this._y=r*u+o*l+s*a-n*c,this._z=s*u+o*c+n*l-r*a,this._w=o*u-n*a-r*l-s*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,s=e._z,o=e._w,a=this.dot(e);a<0&&(n=-n,r=-r,s=-s,o=-o,a=-a);let l=1-t;if(a<.9995){let c=Math.acos(a),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+o*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+r*t,this._z=this._z*l+s*t,this._w=this._w*l+o*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Nd=class Nd{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(fg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(fg.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,s=e.x,o=e.y,a=e.z,l=e.w,c=2*(o*r-a*n),u=2*(a*t-s*r),h=2*(s*n-o*t);return this.x=t+l*c+o*h-a*u,this.y=n+l*u+a*c-s*h,this.z=r+l*h+s*u-o*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=st(this.x,e.x,t.x),this.y=st(this.y,e.y,t.y),this.z=st(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=st(this.x,e,t),this.y=st(this.y,e,t),this.z=st(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(st(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,s=e.z,o=t.x,a=t.y,l=t.z;return this.x=r*l-s*a,this.y=s*o-n*l,this.z=n*a-r*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return df.copy(this).projectOnVector(e),this.sub(df)}reflect(e){return this.sub(df.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(st(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};Nd.prototype.isVector3=!0;var D=Nd,df=new D,fg=new wn,Od=class Od{constructor(e,t,n,r,s,o,a,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,o,a,l,c)}set(e,t,n,r,s,o,a,l,c){let u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=l,u[6]=n,u[7]=o,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,s=this.elements,o=n[0],a=n[3],l=n[6],c=n[1],u=n[4],h=n[7],f=n[2],d=n[5],p=n[8],x=r[0],m=r[3],g=r[6],y=r[1],_=r[4],b=r[7],M=r[2],S=r[5],v=r[8];return s[0]=o*x+a*y+l*M,s[3]=o*m+a*_+l*S,s[6]=o*g+a*b+l*v,s[1]=c*x+u*y+h*M,s[4]=c*m+u*_+h*S,s[7]=c*g+u*b+h*v,s[2]=f*x+d*y+p*M,s[5]=f*m+d*_+p*S,s[8]=f*g+d*b+p*v,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t*o*u-t*a*c-n*s*u+n*a*l+r*s*c-r*o*l}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=u*o-a*c,f=a*l-u*s,d=c*s-o*l,p=t*h+n*f+r*d;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let x=1/p;return e[0]=h*x,e[1]=(r*c-u*n)*x,e[2]=(a*n-r*o)*x,e[3]=f*x,e[4]=(u*t-r*l)*x,e[5]=(r*s-a*t)*x,e[6]=d*x,e[7]=(n*l-c*t)*x,e[8]=(o*t-n*s)*x,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,o,a){let l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*o+c*a)+o+e,-r*c,r*l,-r*(-c*o+l*a)+a+t,0,0,1),this}scale(e,t){return as("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(pf.makeScale(e,t)),this}rotate(e){return as("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(pf.makeRotation(-e)),this}translate(e,t){return as("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(pf.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}};Od.prototype.isMatrix3=!0;var Xe=Od,pf=new Xe,dg=new Xe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),pg=new Xe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function fS(){let i={enabled:!0,workingColorSpace:Sn,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Mt&&(r.r=Ki(r.r),r.g=Ki(r.g),r.b=Ki(r.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Mt&&(r.r=ao(r.r),r.g=ao(r.g),r.b=ao(r.b))),r},workingToColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},colorSpaceToWorking:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===ci?va:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[o].fromXYZ).multiply(this.spaces[s].toXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Sn]:{primaries:e,whitePoint:n,transfer:va,toXYZ:dg,fromXYZ:pg,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:dt},outputColorSpaceConfig:{drawingBufferColorSpace:dt}},[dt]:{primaries:e,whitePoint:n,transfer:Mt,toXYZ:dg,fromXYZ:pg,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:dt}}}),i}var it=fS();function Ki(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function ao(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Hs,fo=class{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Hs===void 0&&(Hs=uo("canvas")),Hs.width=e.width,Hs.height=e.height;let r=Hs.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Hs}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=uo("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o1),this.pmremVersion=0,this.isPMREMTexture=!1,this.normalized=!1}get width(){return this.source.getSize(gf).x}get height(){return this.source.getSize(gf).y}get depth(){return this.source.getSize(gf).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.mipmapsAutoUpdate=e.mipmapsAutoUpdate,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isPMREMTexture=e.isPMREMTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(n===void 0){Oe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Oe(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,mipmapsAutoUpdate:this.mipmapsAutoUpdate,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==hd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case zn:e.x=e.x-Math.floor(e.x);break;case ln:e.x=e.x<0?0:1;break;case Ir:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case zn:e.y=e.y-Math.floor(e.y);break;case ln:e.y=e.y<0?0:1;break;case Ir:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Kt.DEFAULT_IMAGE=null;Kt.DEFAULT_MAPPING=hd;Kt.DEFAULT_ANISOTROPY=1;var Dd=class Dd{constructor(e=0,t=0,n=0,r=1){this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*r+o[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s,l=e.elements,c=l[0],u=l[4],h=l[8],f=l[1],d=l[5],p=l[9],x=l[2],m=l[6],g=l[10];if(Math.abs(u-f)<.01&&Math.abs(h-x)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+f)<.1&&Math.abs(h+x)<.1&&Math.abs(p+m)<.1&&Math.abs(c+d+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let _=(c+1)/2,b=(d+1)/2,M=(g+1)/2,S=(u+f)/4,v=(h+x)/4,w=(p+m)/4;return _>b&&_>M?_<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(_),r=S/n,s=v/n):b>M?b<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(b),n=S/r,s=w/r):M<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(M),n=v/s,r=w/s),this.set(n,r,s,t),this}let y=Math.sqrt((m-p)*(m-p)+(h-x)*(h-x)+(f-u)*(f-u));return Math.abs(y)<.001&&(y=1),this.x=(m-p)/y,this.y=(h-x)/y,this.z=(f-u)/y,this.w=Math.acos((c+d+g-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=st(this.x,e.x,t.x),this.y=st(this.y,e.y,t.y),this.z=st(this.z,e.z,t.z),this.w=st(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=st(this.x,e,t),this.y=st(this.y,e,t),this.z=st(this.z,e,t),this.w=st(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(st(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};Dd.prototype.isVector4=!0;var vt=Dd,Lc=class extends vi{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ht,depthBuffer:!0,stencilBuffer:!1,resolveColorBuffer:!0,resolveDepthBuffer:!0,resolveStencilBuffer:!0,storeMultisampledColorBuffer:!0,storeMultisampledDepthBuffer:!0,storeMultisampledStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new vt(0,0,e,t),this.scissorTest=!1,this.viewport=new vt(0,0,e,t),this.textures=[];let r=n.count;for(let s=0;s1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let n=0;n0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.pivot!==null&&(r.pivot=this.pivot.toArray()),this.morphTargetDictionary!==void 0&&(r.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(r.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(a=>({...a,boundingBox:a.boundingBox?a.boundingBox.toJSON():void 0,boundingSphere:a.boundingSphere?a.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(a=>({...a})),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function s(a,l){return a[l.uuid]===void 0&&(a[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let l=a.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){r.children=[];for(let a=0;a0){r.animations=[];for(let a=0;a0&&(n.geometries=a),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),f.length>0&&(n.skeletons=f),d.length>0&&(n.animations=d),p.length>0&&(n.nodes=p)}return n.object=r,n;function o(a){let l=[];for(let c in a){let u=a[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;nd+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&f<=d-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.quaternion,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));a!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(_S)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new et;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},zx={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ar={h:0,s:0,l:0},Kl={h:0,s:0,l:0};function yf(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var W=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=dt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=it.workingColorSpace){return this.r=e,this.g=t,this.b=n,it.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=it.workingColorSpace){if(e=Td(e,1),t=st(t,0,1),n=st(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=yf(o,s,e+1/3),this.g=yf(o,s,e),this.b=yf(o,s,e-1/3)}return it.colorSpaceToWorking(this,r),this}setStyle(e,t=dt){function n(s){s!==void 0&&parseFloat(s)<1&&Oe("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseFloat(s[1]))/100,Math.min(100,parseFloat(s[2]))/100,Math.min(100,parseFloat(s[3]))/100,t);break;case"hsl":case"hsla":if(s=/^\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:Oe("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);Oe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=dt){let n=zx[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Oe("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Ki(e.r),this.g=Ki(e.g),this.b=Ki(e.b),this}copyLinearToSRGB(e){return this.r=ao(e.r),this.g=ao(e.g),this.b=ao(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=dt){return it.workingToColorSpace(pn.copy(this),e),Math.round(st(pn.r*255,0,255))*65536+Math.round(st(pn.g*255,0,255))*256+Math.round(st(pn.b*255,0,255))}getHexString(e=dt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(pn.copy(this),t);let n=pn.r,r=pn.g,s=pn.b,o=Math.max(n,r,s),a=Math.min(n,r,s),l,c,u=(a+o)/2;if(a===o)l=0,c=0;else{let h=o-a;switch(c=u<=.5?h/(o+a):h/(2-o-a),o){case n:l=(r-s)/h+(r0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){si.subVectors(r,t),Hi.subVectors(n,t),bf.subVectors(e,t);let o=si.dot(si),a=si.dot(Hi),l=si.dot(bf),c=Hi.dot(Hi),u=Hi.dot(bf),h=o*c-a*a;if(h===0)return s.set(0,0,0),null;let f=1/h,d=(c*l-a*u)*f,p=(o*u-a*l)*f;return s.set(1-d-p,p,d)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Wi)===null?!1:Wi.x>=0&&Wi.y>=0&&Wi.x+Wi.y<=1}static getInterpolation(e,t,n,r,s,o,a,l){return this.getBarycoord(e,t,n,r,Wi)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Wi.x),l.addScaledVector(o,Wi.y),l.addScaledVector(a,Wi.z),l)}static getInterpolatedAttribute(e,t,n,r,s,o){return Sf.setScalar(0),wf.setScalar(0),Tf.setScalar(0),Sf.fromBufferAttribute(e,t),wf.fromBufferAttribute(e,n),Tf.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(Sf,s.x),o.addScaledVector(wf,s.y),o.addScaledVector(Tf,s.z),o}static isFrontFacing(e,t,n,r){return si.subVectors(n,t),Hi.subVectors(e,t),si.cross(Hi).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return si.subVectors(this.c,this.b),Hi.subVectors(this.a,this.b),si.cross(Hi).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return i.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,s=this.c,o,a;qs.subVectors(r,n),$s.subVectors(s,n),vf.subVectors(e,n);let l=qs.dot(vf),c=$s.dot(vf);if(l<=0&&c<=0)return t.copy(n);_f.subVectors(e,r);let u=qs.dot(_f),h=$s.dot(_f);if(u>=0&&h<=u)return t.copy(r);let f=l*h-u*c;if(f<=0&&l>=0&&u<=0&&l-u>0)return o=l/(l-u),t.copy(n).addScaledVector(qs,o);Mf.subVectors(e,s);let d=qs.dot(Mf),p=$s.dot(Mf);if(p>=0&&d<=p)return t.copy(s);let x=d*c-l*p;if(x<=0&&c>=0&&p<=0)return a=c/(c-p),t.copy(n).addScaledVector($s,a);let m=u*p-d*h;if(m<=0&&h-u>=0&&d-p>=0)return Mg.subVectors(s,r),a=(h-u)/(h-u+(d-p)),t.copy(r).addScaledVector(Mg,a);let g=1/(m+x+f);return o=x*g,a=f*g,t.copy(n).addScaledVector(qs,o).addScaledVector($s,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Ct=class{constructor(e=new D(1/0,1/0,1/0),t=new D(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,oi),oi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(oa),Jl.subVectors(this.max,oa),Ks.subVectors(e.a,oa),Zs.subVectors(e.b,oa),Js.subVectors(e.c,oa),Er.subVectors(Zs,Ks),Rr.subVectors(Js,Zs),is.subVectors(Ks,Js);let t=[0,-Er.z,Er.y,0,-Rr.z,Rr.y,0,-is.z,is.y,Er.z,0,-Er.x,Rr.z,0,-Rr.x,is.z,0,-is.x,-Er.y,Er.x,0,-Rr.y,Rr.x,0,-is.y,is.x,0];return!Af(t,Ks,Zs,Js,Jl)||(t=[1,0,0,0,1,0,0,0,1],!Af(t,Ks,Zs,Js,Jl))?!1:(jl.crossVectors(Er,Rr),t=[jl.x,jl.y,jl.z],Af(t,Ks,Zs,Js,Jl))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,oi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(oi).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Xi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Xi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Xi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Xi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Xi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Xi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Xi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Xi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Xi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}},Xi=[new D,new D,new D,new D,new D,new D,new D,new D],oi=new D,Zl=new Ct,Ks=new D,Zs=new D,Js=new D,Er=new D,Rr=new D,is=new D,oa=new D,Jl=new D,jl=new D,rs=new D;function Af(i,e,t,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){rs.fromArray(i,s);let a=r.x*Math.abs(rs.x)+r.y*Math.abs(rs.y)+r.z*Math.abs(rs.z),l=e.dot(rs),c=t.dot(rs),u=n.dot(rs);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>a)return!1}return!0}var $t=new D,Ql=new ke,MS=0,wt=class extends vi{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:MS++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Md,this.updateRanges=[],this.gpuType=Gn,this.version=0,this._normalizationScale=e!==void 0?Ou(e):void 0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this._normalizationScale=e._normalizationScale,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;rthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;aa.subVectors(e,this.center);let t=aa.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(aa,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Ef.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(aa.copy(e.center).add(Ef)),this.expandByPoint(aa.copy(e.center).sub(Ef))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}},wS=0,$n=new ze,Rf=new Et,js=new D,Bn=new Ct,la=new Ct,rn=new D,Pe=class i extends vi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:wS++}),this.uuid=Ci(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(K1(e)?us:Sa)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new Xe().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return $n.makeRotationFromQuaternion(e),this.applyMatrix4($n),this}rotateX(e){return $n.makeRotationX(e),this.applyMatrix4($n),this}rotateY(e){return $n.makeRotationY(e),this.applyMatrix4($n),this}rotateZ(e){return $n.makeRotationZ(e),this.applyMatrix4($n),this}translate(e,t,n){return $n.makeTranslation(e,t,n),this.applyMatrix4($n),this}scale(e,t,n){return $n.makeScale(e,t,n),this.applyMatrix4($n),this}lookAt(e){return Rf.lookAt(e),Rf.updateMatrix(),this.applyMatrix4(Rf.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(js).negate(),this.translate(js.x,js.y,js.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let r=0,s=e.length;rt.count&&Oe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ct);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){We("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let l=this.parameters;for(let c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let l in n){let c=n[l];e.data.attributes[l]=c.toJSON(e.data)}let r={},s=!1;for(let l in this.morphAttributes){let c=this.morphAttributes[l],u=[];for(let h=0,f=c.length;h0&&(r[l]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere=a.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone());let r=e.attributes;for(let c in r){let u=r[c];this.setAttribute(c,u.clone(t))}let s=e.morphAttributes;for(let c in s){let u=[],h=s[c];for(let f=0,d=h.length;f1)?null:t.copy(e.start).addScaledVector(r,o)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||AS.getNormalMatrix(e),r=this.coplanarPoint(Cf).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}toJSON(){return{normal:this.normal.toArray(),constant:this.constant}}fromJSON(e){return this.normal.fromArray(e.normal),this.constant=e.constant,this}},ES=0,gn=class extends vi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ES++}),this.uuid=Ci(),this.name="",this.type="Material",this.blending=Ei,this.side=Ai,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=nd,this.blendDst=id,this.blendEquation=ys,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new W(0,0,0),this.blendAlpha=0,this.depthFunc=lo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Px,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=wc,this.stencilZFail=wc,this.stencilZPass=wc,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){Oe(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){Oe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector2&&n&&n.isVector2||r&&r.isEuler&&n&&n.isEuler||r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,n.blending=this.blending,n.side=this.side,n.shadowSide=this.shadowSide,n.vertexColors=this.vertexColors,n.opacity=this.opacity,n.transparent=this.transparent,n.blendSrc=this.blendSrc,n.blendDst=this.blendDst,n.blendEquation=this.blendEquation,n.blendSrcAlpha=this.blendSrcAlpha,n.blendDstAlpha=this.blendDstAlpha,n.blendEquationAlpha=this.blendEquationAlpha,n.blendColor=this.blendColor.getHex(),n.blendAlpha=this.blendAlpha,n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.clipIntersection=this.clipIntersection,n.clipShadows=this.clipShadows,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,n.stencilWrite=this.stencilWrite,n.polygonOffset=this.polygonOffset,n.polygonOffsetFactor=this.polygonOffsetFactor,n.polygonOffsetUnits=this.polygonOffsetUnits,n.dithering=this.dithering,n.alphaTest=this.alphaTest,n.alphaHash=this.alphaHash,n.alphaToCoverage=this.alphaToCoverage,n.premultipliedAlpha=this.premultipliedAlpha,n.forceSinglePass=this.forceSinglePass,n.allowOverride=this.allowOverride,n.visible=this.visible,n.toneMapped=this.toneMapped,n.name=this.name,this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.diffuseRoughness!==void 0&&(n.diffuseRoughness=this.diffuseRoughness),this.diffuseRoughnessMap&&this.diffuseRoughnessMap.isTexture&&(n.diffuseRoughnessMap=this.diffuseRoughnessMap.toJSON(e).uuid),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.retroreflectivity!==void 0&&(n.retroreflectivity=this.retroreflectivity),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessMinimum=this.iridescenceThicknessMinimum),this.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessMaximum=this.iridescenceThicknessMaximum),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),Array.isArray(this.clippingPlanes)&&this.clippingPlanes.length>0&&(n.clippingPlanes=this.clippingPlanes.map(s=>s.toJSON())),this.rotation!==void 0&&(n.rotation=this.rotation),this.depthPacking!==void 0&&(n.depthPacking=this.depthPacking),this.linewidth!==void 0&&(n.linewidth=this.linewidth),this.linecap!==void 0&&(n.linecap=this.linecap),this.linejoin!==void 0&&(n.linejoin=this.linejoin),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.wireframe!==void 0&&(n.wireframe=this.wireframe),this.wireframeLinewidth!==void 0&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==void 0&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==void 0&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading!==void 0&&(n.flatShading=this.flatShading),this.fog!==void 0&&(n.fog=this.fog),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){let o=[];for(let a in s){let l=s[a];delete l.metadata,o.push(l)}return o}if(t){let s=r(e.textures),o=r(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new W().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.diffuseRoughness!==void 0&&(this.diffuseRoughness=e.diffuseRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.retroreflectivity!==void 0&&(this.retroreflectivity=e.retroreflectivity),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessMinimum!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum),e.iridescenceThicknessMaximum!==void 0&&(this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],this.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1]),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.clippingPlanes!==void 0&&(this.clippingPlanes=e.clippingPlanes.map(n=>new mn().fromJSON(n))),e.clipIntersection!==void 0&&(this.clipIntersection=e.clipIntersection),e.clipShadows!==void 0&&(this.clipShadows=e.clipShadows),e.depthPacking!==void 0&&(this.depthPacking=e.depthPacking),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.linecap!==void 0&&(this.linecap=e.linecap),e.linejoin!==void 0&&(this.linejoin=e.linejoin),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new ke().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new ke().fromArray(e.clearcoatNormalScale)),e.diffuseRoughnessMap!==void 0&&(this.diffuseRoughnessMap=t[e.diffuseRoughnessMap]||null),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},_i=class extends gn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new W(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Qs,ca=new D,eo=new D,to=new D,no=new ke,ua=new ke,Vx=new ze,ec=new D,ha=new D,tc=new D,wg=new ke,Pf=new ke,Tg=new ke,er=class extends Et{constructor(e=new _i){if(super(),this.isSprite=!0,this.type="Sprite",Qs===void 0){Qs=new Pe;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new hs(t,5);Qs.setIndex([0,1,2,0,2,3]),Qs.setAttribute("position",new Lr(n,3,0,!1)),Qs.setAttribute("uv",new Lr(n,2,3,!1))}this.geometry=Qs,this.material=e,this.center=new ke(.5,.5),this.count=1}intersectsFrustum(e){return e.intersectsSprite(this)}raycast(e,t){e.camera===null&&We('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),eo.setFromMatrixScale(this.matrixWorld),Vx.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),to.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&eo.multiplyScalar(-to.z);let n=this.material.rotation,r,s;n!==0&&(s=Math.cos(n),r=Math.sin(n));let o=this.center;nc(ec.set(-.5,-.5,0),to,o,eo,r,s),nc(ha.set(.5,-.5,0),to,o,eo,r,s),nc(tc.set(.5,.5,0),to,o,eo,r,s),wg.set(0,0),Pf.set(1,0),Tg.set(1,1);let a=e.ray.intersectTriangle(ec,ha,tc,!1,ca);if(a===null&&(nc(ha.set(-.5,.5,0),to,o,eo,r,s),Pf.set(0,1),a=e.ray.intersectTriangle(ec,tc,ha,!1,ca),a===null))return;let l=e.ray.origin.distanceTo(ca);le.far||t.push({distance:l,point:ca.clone(),uv:$i.getInterpolation(ca,ec,ha,tc,wg,Pf,Tg,new ke),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}toJSON(e){let t=super.toJSON(e);return t.object.center=this.center.toArray(),t}};function nc(i,e,t,n,r,s){no.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(ua.x=s*no.x-r*no.y,ua.y=r*no.x+s*no.y):ua.copy(no),i.copy(e),i.x+=ua.x,i.y+=ua.y,i.applyMatrix4(Vx)}var Yi=new D,If=new D,ic=new D,rc=new D,Fr=class{constructor(e=new D,t=new D(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Yi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Yi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Yi.copy(this.origin).addScaledVector(this.direction,t),Yi.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){If.copy(e).add(t).multiplyScalar(.5),ic.copy(t).sub(e).normalize(),rc.copy(this.origin).sub(If);let s=e.distanceTo(t)*.5,o=-this.direction.dot(ic),a=rc.dot(this.direction),l=-rc.dot(ic),c=rc.lengthSq(),u=Math.abs(1-o*o),h,f,d,p;if(u>0)if(h=o*l-a,f=o*a-l,p=s*u,h>=0)if(f>=-p)if(f<=p){let x=1/u;h*=x,f*=x,d=h*(h+o*f+2*a)+f*(o*h+f+2*l)+c}else f=s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*l)+c;else f=-s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*l)+c;else f<=-p?(h=Math.max(0,-(-o*s+a)),f=h>0?-s:Math.min(Math.max(-s,-l),s),d=-h*h+f*(f+2*l)+c):f<=p?(h=0,f=Math.min(Math.max(-s,-l),s),d=f*(f+2*l)+c):(h=Math.max(0,-(o*s+a)),f=h>0?s:Math.min(Math.max(-s,-l),s),d=-h*h+f*(f+2*l)+c);else f=o>0?-s:s,h=Math.max(0,-(o*f+a)),d=-h*h+f*(f+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(If).addScaledVector(ic,f),d}intersectSphere(e,t){if(e.radius<0)return null;Yi.subVectors(e.center,this.origin);let n=Yi.dot(this.direction),r=Yi.dot(Yi)-n*n,s=e.radius*e.radius;if(r>s)return null;let o=Math.sqrt(s-r),a=n-o,l=n+o;return l<0?null:a<0?this.at(l,t):this.at(a,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,o,a,l,c=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,f=this.origin;return c>=0?(n=(e.min.x-f.x)*c,r=(e.max.x-f.x)*c):(n=(e.max.x-f.x)*c,r=(e.min.x-f.x)*c),u>=0?(s=(e.min.y-f.y)*u,o=(e.max.y-f.y)*u):(s=(e.max.y-f.y)*u,o=(e.min.y-f.y)*u),n>o||s>r||((s>n||isNaN(n))&&(n=s),(o=0?(a=(e.min.z-f.z)*h,l=(e.max.z-f.z)*h):(a=(e.max.z-f.z)*h,l=(e.min.z-f.z)*h),n>l||a>r)||((a>n||n!==n)&&(n=a),(l=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Yi)!==null}intersectTriangle(e,t,n,r,s){let o=this.origin,a=this.direction,l=a.x,c=a.y,u=a.z,h=e.x-o.x,f=e.y-o.y,d=e.z-o.z,p=t.x-o.x,x=t.y-o.y,m=t.z-o.z,g=n.x-o.x,y=n.y-o.y,_=n.z-o.z,b=Math.abs(l),M=Math.abs(c),S=Math.abs(u),v,w,P,T,R,L,U,C,I,O,F,H;if(b>=M&&b>=S?(P=l,L=h,I=p,H=g,l>=0?(v=c,w=u,T=f,R=d,U=x,C=m,O=y,F=_):(v=u,w=c,T=d,R=f,U=m,C=x,O=_,F=y)):M>=S?(P=c,L=f,I=x,H=y,c>=0?(v=u,w=l,T=d,R=h,U=m,C=p,O=_,F=g):(v=l,w=u,T=h,R=d,U=p,C=m,O=g,F=_)):(P=u,L=d,I=m,H=_,u>=0?(v=l,w=c,T=h,R=f,U=p,C=x,O=g,F=y):(v=c,w=l,T=f,R=h,U=x,C=p,O=y,F=g)),P===0)return null;let k=v/P,X=w/P,V=1/P,re=T-k*L,ye=R-X*L,Y=U-k*I,Q=C-X*I,se=O-k*H,we=F-X*H,le=se*Q-we*Y,Ne=re*we-ye*se,at=Y*ye-Q*re;if(r){if(le<0||Ne<0||at<0)return null}else if((le<0||Ne<0||at<0)&&(le>0||Ne>0||at>0))return null;let Ae=le+Ne+at;if(Ae===0)return null;let ft=V*(le*L+Ne*I+at*H);return(Ae>0?ft<0:ft>0)?null:this.at(ft/Ae,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Ye=class extends gn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new W(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Zn,this.combine=Kc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Ag=new ze,ss=new Fr,sc=new Pn,Eg=new D,oc=new D,ac=new D,lc=new D,Lf=new D,cc=new D,Rg=new D,uc=new D,Se=class extends Et{constructor(e=new Pe,t=new Ye){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0?this.morphTargetInfluences=e.morphTargetInfluences.slice():this.morphTargetInfluences=void 0,e.morphTargetDictionary!==void 0?this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary):this.morphTargetDictionary=void 0,this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s(e.far-e.near)**2))&&(Ag.copy(s).invert(),ss.copy(e.ray).applyMatrix4(Ag),!(n.boundingBox!==null&&ss.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,ss)))}_computeIntersections(e,t,n){let r,s=this.geometry,o=this.material,a=s.index,l=s.attributes.position,c=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,f=s.groups,d=s.drawRange;if(a!==null)if(Array.isArray(o))for(let p=0,x=f.length;pt.far?null:{distance:c,point:uc.clone(),object:i}}function hc(i,e,t,n,r,s,o,a,l,c){i.getVertexPosition(a,oc),i.getVertexPosition(l,ac),i.getVertexPosition(c,lc);let u=RS(i,e,t,n,oc,ac,lc,Rg);if(u){let h=new D;$i.getBarycoord(Rg,oc,ac,lc,h),r&&(u.uv=$i.getInterpolatedAttribute(r,a,l,c,h,new ke)),s&&(u.uv1=$i.getInterpolatedAttribute(s,a,l,c,h,new ke)),o&&(u.normal=$i.getInterpolatedAttribute(o,a,l,c,h,new D),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));let f={a,b:l,c,normal:new D,materialIndex:0};$i.getNormal(oc,ac,lc,f.normal),u.face=f,u.barycoord=h}return u}var fa=new vt,Cg=new vt,Pg=new vt,CS=new vt,Ig=new ze,fc=new D,Ff=new Pn,Lg=new ze,Nf=new Fr,wa=class extends Se{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Uf,this.bindMatrix=new ze,this.bindMatrixInverse=new ze,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new Ct),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n0?e.max.x:e.min.x,pc.y=r.normal.y>0?e.max.y:e.min.y,pc.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(pc)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}},Dg=new ze,Nc=class i{constructor(){this.coordinateSystem=Kn,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let r=0;r0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;sn)return;Of.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(Of);if(!(ce.far))return{distance:c,point:Ug.clone().applyMatrix4(i.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:i}}var Bg=new D,zg=new D,xn=class extends In{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let r=0,s=t.count;r0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;sr.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var Or=class extends Kt{constructor(e=[],t,n,r,s,o,a,l,c,u,h,f){super(null,o,a,l,c,u,r,s,h,f),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}};var Ea=class extends Kt{constructor(e=[],t=bs,n,r,s,o,a,l,c,u){super(e,t,n,r,s,o,a,l,c,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},zt=class extends Kt{constructor(e,t,n,r,s,o,a,l,c){super(e,t,n,r,s,o,a,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}};var nr=class extends Kt{constructor(e,t,n=ai,r,s,o,a=kt,l=kt,c,u=Zi,h=1){if(u!==Zi&&u!==hr)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let f={width:e,height:t,depth:h};super(f,r,s,o,a,l,u,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Qi(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},Ra=class extends nr{constructor(e,t=ai,n=bs,r,s,o=kt,a=kt,l,c=Zi){let u={width:e,height:e,depth:1},h=[u,u,u,u,u,u];super(e,e,t,n,r,s,o,a,l,c),this.image=h,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},Ca=class extends Kt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},Mi=class i extends Pe{constructor(e=1,t=1,n=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:o};let a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let l=[],c=[],u=[],h=[],f=0,d=0;p("z","y","x",-1,-1,n,t,e,o,s,0),p("z","y","x",1,-1,n,t,-e,o,s,1),p("x","z","y",1,1,e,n,t,r,o,2),p("x","z","y",1,-1,e,n,-t,r,o,3),p("x","y","z",1,-1,e,t,n,r,s,4),p("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(l),this.setAttribute("position",new Le(c,3)),this.setAttribute("normal",new Le(u,3)),this.setAttribute("uv",new Le(h,2));function p(x,m,g,y,_,b,M,S,v,w,P){let T=b/v,R=M/w,L=b/2,U=M/2,C=S/2,I=v+1,O=w+1,F=0,H=0,k=new D;for(let X=0;X0?1:-1,u.push(k.x,k.y,k.z),h.push(re/v),h.push(1-X/w),F+=1}}for(let X=0;X0&&_(!0),t>0&&_(!1)),this.setIndex(u),this.setAttribute("position",new Le(h,3)),this.setAttribute("normal",new Le(f,3)),this.setAttribute("uv",new Le(d,2));function y(){let b=new D,M=new D,S=0,v=(t-e)/n;for(let w=0;w<=s;w++){let P=[],T=w/s,R=T*(t-e)+e;for(let L=0;L<=r;L++){let U=L/r,C=U*l+a,I=Math.sin(C),O=Math.cos(C);M.x=R*I,M.y=-T*n+m,M.z=R*O,h.push(M.x,M.y,M.z),b.set(I,v,O).normalize(),f.push(b.x,b.y,b.z),d.push(U,1-T),P.push(p++)}x.push(P)}for(let w=0;w0||P!==0)&&(u.push(T,R,U),S+=3),(t>0||P!==s-1)&&(u.push(R,L,U),S+=3)}c.addGroup(g,S,0),g+=S}function _(b){let M=p,S=new ke,v=new D,w=0,P=b===!0?e:t,T=b===!0?1:-1;for(let L=1;L<=r;L++)h.push(0,m*T,0),f.push(0,T,0),d.push(.5,.5),p++;let R=p;for(let L=0;L<=r;L++){let C=L/r*l+a,I=Math.cos(C),O=Math.sin(C);v.x=P*O,v.y=m*T,v.z=P*I,h.push(v.x,v.y,v.z),f.push(0,T,0),S.x=I*.5+.5,S.y=O*.5*T+.5,d.push(S.x,S.y),p++}for(let L=0;L80*t){a=i[0],l=i[1];let u=a,h=l;for(let f=t;fu&&(u=d),p>h&&(h=p)}c=Math.max(u-a,h-l),c=c!==0?32767/c:0}return Ia(s,o,t,a,l,c,0),o}function Gx(i,e,t,n,r){let s;if(r===KS(i,e,t,n)>0)for(let o=e;o=e;o-=n)s=Hg(o/n|0,i[o],i[o+1],s);return s&&yo(s,s.next)&&(Fa(s),s=s.next),s}function ps(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(yo(t,t.next)||Dt(t.prev,t,t.next)===0)){if(Fa(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Ia(i,e,t,n,r,s,o){if(!i)return;!o&&s&&HS(i,n,r,s);let a=i;for(;i.prev!==i.next;){let l=i.prev,c=i.next;if(s?OS(i,n,r,s):NS(i)){e.push(l.i,i.i,c.i),Fa(i),i=c.next,a=c.next;continue}if(i=c,i===a){o?o===1?(i=DS(ps(i),e),Ia(i,e,t,n,r,s,2)):o===2&&kS(i,e,t,n,r,s):Ia(ps(i),e,t,n,r,s,1);break}}}function NS(i){let e=i.prev,t=i,n=i.next;if(Dt(e,t,n)>=0)return!1;let r=e.x,s=t.x,o=n.x,a=e.y,l=t.y,c=n.y,u=Math.min(r,s,o),h=Math.min(a,l,c),f=Math.max(r,s,o),d=Math.max(a,l,c),p=n.next;for(;p!==e;){if(p.x>=u&&p.x<=f&&p.y>=h&&p.y<=d&&ga(r,a,s,l,o,c,p.x,p.y)&&Dt(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function OS(i,e,t,n){let r=i.prev,s=i,o=i.next;if(Dt(r,s,o)>=0)return!1;let a=r.x,l=s.x,c=o.x,u=r.y,h=s.y,f=o.y,d=Math.min(a,l,c),p=Math.min(u,h,f),x=Math.max(a,l,c),m=Math.max(u,h,f),g=Wf(d,p,e,t,n),y=Wf(x,m,e,t,n),_=i.prevZ,b=i.nextZ;for(;_&&_.z>=g&&b&&b.z<=y;){if(_.x>=d&&_.x<=x&&_.y>=p&&_.y<=m&&_!==r&&_!==o&&ga(a,u,l,h,c,f,_.x,_.y)&&Dt(_.prev,_,_.next)>=0||(_=_.prevZ,b.x>=d&&b.x<=x&&b.y>=p&&b.y<=m&&b!==r&&b!==o&&ga(a,u,l,h,c,f,b.x,b.y)&&Dt(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;_&&_.z>=g;){if(_.x>=d&&_.x<=x&&_.y>=p&&_.y<=m&&_!==r&&_!==o&&ga(a,u,l,h,c,f,_.x,_.y)&&Dt(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;b&&b.z<=y;){if(b.x>=d&&b.x<=x&&b.y>=p&&b.y<=m&&b!==r&&b!==o&&ga(a,u,l,h,c,f,b.x,b.y)&&Dt(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function DS(i,e){let t=i;do{let n=t.prev,r=t.next.next;!yo(n,r)&&Wx(n,t,t.next,r)&&La(n,r)&&La(r,n)&&(e.push(n.i,t.i,r.i),Fa(t),Fa(t.next),t=i=r),t=t.next}while(t!==i);return ps(t)}function kS(i,e,t,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&YS(o,a)){let l=Xx(o,a);o=ps(o,o.next),l=ps(l,l.next),Ia(o,e,t,n,r,s,0),Ia(l,e,t,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function US(i,e,t,n){let r=[];for(let s=0,o=e.length;s=t.next.y&&t.next.y!==t.y){let h=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(h<=n&&h>s&&(s=h,o=t.x=t.x&&t.x>=l&&n!==t.x&&Hx(ro.x||t.x===o.x&&GS(o,t)))&&(o=t,u=h)}t=t.next}while(t!==a);return o}function GS(i,e){return Dt(i.prev,i,e.prev)<0&&Dt(e.next,i,i.next)<0}function HS(i,e,t,n){let r=i;do r.z===0&&(r.z=Wf(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,WS(r)}function WS(i){let e,t=1;do{let n=i,r;i=null;let s=null;for(e=0;n;){e++;let o=n,a=0;for(let c=0;c0||l>0&&o;)a!==0&&(l===0||!o||n.z<=o.z)?(r=n,n=n.nextZ,a--):(r=o,o=o.nextZ,l--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;n=o}s.nextZ=null,t*=2}while(e>1);return i}function Wf(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function XS(i){let e=i,t=i;do(e.x=(i-o)*(s-a)&&(i-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(n-a)}function ga(i,e,t,n,r,s,o,a){return!(i===o&&e===a)&&Hx(i,e,t,n,r,s,o,a)}function YS(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!qS(i,e)&&(La(i,e)&&La(e,i)&&$S(i,e)&&(Dt(i.prev,i,e.prev)||Dt(i,e.prev,e))||yo(i,e)&&Dt(i.prev,i,i.next)>0&&Dt(e.prev,e,e.next)>0)}function Dt(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function yo(i,e){return i.x===e.x&&i.y===e.y}function Wx(i,e,t,n){let r=vc(Dt(i,e,t)),s=vc(Dt(i,e,n)),o=vc(Dt(t,n,i)),a=vc(Dt(t,n,e));return!!(r!==s&&o!==a||r===0&&bc(i,t,e)||s===0&&bc(i,n,e)||o===0&&bc(t,i,n)||a===0&&bc(t,e,n))}function bc(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function vc(i){return i>0?1:i<0?-1:0}function qS(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Wx(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function La(i,e){return Dt(i.prev,i,i.next)<0?Dt(i,e,i.next)>=0&&Dt(i,i.prev,e)>=0:Dt(i,e,i.prev)<0||Dt(i,i.next,e)<0}function $S(i,e){let t=i,n=!1,r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Xx(i,e){let t=Xf(i.i,i.x,i.y),n=Xf(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function Hg(i,e,t,n){let r=Xf(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Fa(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Xf(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function KS(i,e,t,n){let r=0;for(let s=e,o=t-n;s2&&i[e-1].equals(i[0])&&i.pop()}function Xg(i,e){for(let t=0;t0)&&d.push(_,b,S),(g!==n-1||l0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case"t":this.uniforms[n].value=t[r.value]||null;break;case"c":this.uniforms[n].value=new W().setHex(r.value);break;case"v2":this.uniforms[n].value=new Ue().fromArray(r.value);break;case"v3":this.uniforms[n].value=new D().fromArray(r.value);break;case"v4":this.uniforms[n].value=new vt().fromArray(r.value);break;case"m3":this.uniforms[n].value=new Xe().fromArray(r.value);break;case"m4":this.uniforms[n].value=new ze().fromArray(r.value);break;default:this.uniforms[n].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},Dc=class extends Si{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Ln=class extends gn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new W(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new W(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qa,this.normalScale=new Ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Zn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},En=class extends Ln{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ue(1,1),this.clearcoatNormalMap=null,this.diffuseRoughnessMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return st(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessMinimum=100,this.iridescenceThicknessMaximum=400,this.iridescenceThicknessMap=null,this.sheenColor=new W(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new W(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new W(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._diffuseRoughness=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get diffuseRoughness(){return this._diffuseRoughness}set diffuseRoughness(e){this._diffuseRoughness>0!=e>0&&this.version++,this._diffuseRoughness=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){this._retroreflectivity>0!=e>0&&this.version++,this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}get iridescenceThicknessRange(){return as('MeshPhysicalMaterial: The "iridescenceThicknessRange" property has been replaced by "iridescenceThicknessMinimum" and "iridescenceThicknessMaximum".'),[this.iridescenceThicknessMinimum,this.iridescenceThicknessMaximum]}set iridescenceThicknessRange(e){as('MeshPhysicalMaterial: The "iridescenceThicknessRange" property has been replaced by "iridescenceThicknessMinimum" and "iridescenceThicknessMaximum".'),this.iridescenceThicknessMinimum=e[0],this.iridescenceThicknessMaximum=e[1]}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.diffuseRoughness=e.diffuseRoughness,this.diffuseRoughnessMap=e.diffuseRoughnessMap,this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum,this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum,this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}};var Oa=class extends gn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new W(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new W(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Qa,this.normalScale=new Ue(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Zn,this.combine=$c,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Uc=class extends gn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Ex,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},kc=class extends gn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function Pr(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function ga(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}function JS(i){function e(r,s){return i[r]-i[s]}let t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function Yg(i,e,t){let n=i.length,r=new i.constructor(n);for(let s=0,o=0;o!==n;++s){let a=t[s]*e;for(let l=0;l!==e;++l)r[o++]=i[a+l]}return r}function jS(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push(...o)),s=i[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=i[r++];while(s!==void 0)}var wi=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],s=t[n-1];n:{e:{let o;t:{i:if(!(e=s)){let a=t[1];e=s)break e}o=n,n=0;break t}break n}for(;n>>1;et;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=n.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(We("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,r=this.values,s=n.length;s===0&&(We("KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){We("KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){We("KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(r!==void 0&&$1(r))for(let a=0,l=r.length;a!==l;++a){let c=r[a];if(isNaN(c)){We("KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===Mc,s=e.length-1,o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,ga(this.settings)&&(r.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),r}};function qg(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]+=e}function $g(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]*=e}Fn.prototype.ValueTypeName="";Fn.prototype.TimeBufferType=Float32Array;Fn.prototype.ValueBufferType=Float32Array;Fn.prototype.DefaultInterpolation=ji;var rr=class extends Fn{constructor(e,t,n){super(e,t,n)}};rr.prototype.ValueTypeName="bool";rr.prototype.ValueBufferType=Array;rr.prototype.DefaultInterpolation=Ji;rr.prototype.InterpolantFactoryMethodLinear=void 0;rr.prototype.InterpolantFactoryMethodSmooth=void 0;var Da=class extends Fn{constructor(e,t,n,r){super(e,t,n,r)}};Da.prototype.ValueTypeName="color";var sr=class extends Fn{constructor(e,t,n,r){super(e,t,n,r)}};sr.prototype.ValueTypeName="number";var Hc=class extends wi{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(r-t),c=e*a;for(let u=c+a;c!==u;c+=4)wn.slerpFlat(s,0,o,c-a,o,c,l);return s}},or=class extends Fn{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Hc(this.times,this.values,this.getValueSize(),e)}};or.prototype.ValueTypeName="quaternion";or.prototype.InterpolantFactoryMethodSmooth=void 0;var ar=class extends Fn{constructor(e,t,n){super(e,t,n)}};ar.prototype.ValueTypeName="string";ar.prototype.ValueBufferType=Array;ar.prototype.DefaultInterpolation=Ji;ar.prototype.InterpolantFactoryMethodLinear=void 0;ar.prototype.InterpolantFactoryMethodSmooth=void 0;var Dr=class extends Fn{constructor(e,t,n,r){super(e,t,n,r)}};Dr.prototype.ValueTypeName="vector";var Ua=class{constructor(e="",t=-1,n=[],r=Ax){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Ci(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(nw(n[o]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,o=n.length;s!==o;++s)t.push(Fn.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let s=t.length,o=[];for(let a=0;a1){let h=u[1],f=r[h];f||(r[h]=f=[]),f.push(c)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,n));return o}resetDuration(){let e=this.tracks,t=0;for(let n=0,r=e.length;n!==r;++n){let s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e{t&&t(s),this.manager.itemEnd(e)},0);return}if(qi[e]!==void 0){qi[e].push({onLoad:t,onProgress:n,onError:r});return}qi[e]=[],qi[e].push({onLoad:t,onProgress:n,onError:r});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",priority:this.priority,cache:this.cache,signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Oe("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let u=qi[e],h=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),d=f?parseInt(f):0,p=d!==0,x=0,m=new ReadableStream({start(g){y();function y(){h.read().then(({done:_,value:b})=>{if(_)g.close();else{x+=b.byteLength;let M=new ProgressEvent("progress",{lengthComputable:p,loaded:x,total:d});for(let S=0,v=u.length;S{g.error(_)})}}});return new Response(m)}else throw new Yf(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a==="")return c.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),f=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(f);return c.arrayBuffer().then(p=>d.decode(p))}}}).then(c=>{bi.add(`file:${e}`,c);let u=qi[e];delete qi[e];for(let h=0,f=u.length;h{let u=qi[e];if(u===void 0)throw this.manager.itemError(e),c;delete qi[e];for(let h=0,f=u.length;h{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};var ro=new WeakMap,Xc=class extends Ti{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=bi.get(`image:${e}`);if(o!==void 0){if(o.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0);else{let h=ro.get(o);h===void 0&&(h=[],ro.set(o,h)),h.push({onLoad:t,onError:r})}return o}let a=uo("img");function l(){u(),t&&t(this);let h=ro.get(this)||[];for(let f=0;f"u"&&Oe("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Oe("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=bi.get(`image-bitmap:${e}`);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(c=>{Df.has(o)===!0?(r&&r(Df.get(o)),s.manager.itemError(e),s.manager.itemEnd(e)):(t&&t(c),s.manager.itemEnd(e))});return}setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0);return}let a={};a.credentials=this.withCredentials||this.crossOrigin!=="anonymous"?"include":"same-origin",a.headers=this.requestHeader,a.priority=this.priority,a.cache=this.cache,a.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},s.options,{colorSpaceConversion:"none"}))}).then(function(c){return bi.add(`image-bitmap:${e}`,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),Df.set(l,c),bi.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});bi.add(`image-bitmap:${e}`,l),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};var so=-90,oo=1,_o=class extends Et{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Jt(so,oo,e,t);r.layers=this.layers,this.add(r);let s=new Jt(so,oo,e,t);s.layers=this.layers,this.add(s);let o=new Jt(so,oo,e,t);o.layers=this.layers,this.add(o);let a=new Jt(so,oo,e,t);a.layers=this.layers,this.add(a);let l=new Jt(so,oo,e,t);l.layers=this.layers,this.add(l);let c=new Jt(so,oo,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,s,o,a,l]=t;for(let c of t)this.remove(c);if(e===Kn)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===co)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,l,c,u]=this.children,h=e.getRenderTarget(),f=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let x=n.texture.mipmapsAutoUpdate;n.texture.mipmapsAutoUpdate=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,1,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,2,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,3,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.mipmapsAutoUpdate=x,e.setRenderTarget(n,5,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(h,f,d),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},Yc=class extends Jt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e,this.perCameraFrustumCulled=!1}};var Cd="\\[\\]\\.:\\/",iw=new RegExp("["+Cd+"]","g"),Pd="[^"+Cd+"]",rw="[^"+Cd.replace("\\.","")+"]",sw=/((?:WC+[\/:])*)/.source.replace("WC",Pd),ow=/(WCOD+)?/.source.replace("WCOD",rw),aw=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Pd),lw=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Pd),cw=new RegExp("^"+sw+ow+aw+lw+"$"),uw=["material","materials","bones","map"],Zf=class{constructor(e,t,n){let r=n||gt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},gt=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(iw,"")}static parseTrackName(e){let t=cw.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=n.nodeName.substring(r+1);uw.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;od.start-p.start);let f=0;for(let d=1;d0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(let n in e.uniforms){let r=e.uniforms[n];switch(this.uniforms[n]={},r.type){case"t":this.uniforms[n].value=t[r.value]||null;break;case"c":this.uniforms[n].value=new W().setHex(r.value);break;case"v2":this.uniforms[n].value=new ke().fromArray(r.value);break;case"v3":this.uniforms[n].value=new D().fromArray(r.value);break;case"v4":this.uniforms[n].value=new vt().fromArray(r.value);break;case"m3":this.uniforms[n].value=new Xe().fromArray(r.value);break;case"m4":this.uniforms[n].value=new ze().fromArray(r.value);break;default:this.uniforms[n].value=r.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(let n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}},kc=class extends Si{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Ln=class extends gn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new W(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new W(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=el,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Zn,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},En=class extends Ln{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ke(1,1),this.clearcoatNormalMap=null,this.diffuseRoughnessMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return st(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessMinimum=100,this.iridescenceThicknessMaximum=400,this.iridescenceThicknessMap=null,this.sheenColor=new W(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new W(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new W(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._diffuseRoughness=0,this._dispersion=0,this._iridescence=0,this._retroreflectivity=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get diffuseRoughness(){return this._diffuseRoughness}set diffuseRoughness(e){this._diffuseRoughness>0!=e>0&&this.version++,this._diffuseRoughness=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get retroreflectivity(){return this._retroreflectivity}set retroreflectivity(e){this._retroreflectivity>0!=e>0&&this.version++,this._retroreflectivity=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}get iridescenceThicknessRange(){return as('MeshPhysicalMaterial: The "iridescenceThicknessRange" property has been replaced by "iridescenceThicknessMinimum" and "iridescenceThicknessMaximum".'),[this.iridescenceThicknessMinimum,this.iridescenceThicknessMaximum]}set iridescenceThicknessRange(e){as('MeshPhysicalMaterial: The "iridescenceThicknessRange" property has been replaced by "iridescenceThicknessMinimum" and "iridescenceThicknessMaximum".'),this.iridescenceThicknessMinimum=e[0],this.iridescenceThicknessMaximum=e[1]}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.diffuseRoughness=e.diffuseRoughness,this.diffuseRoughnessMap=e.diffuseRoughnessMap,this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum,this.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum,this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.retroreflectivity=e.retroreflectivity,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}};var Da=class extends gn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new W(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new W(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=el,this.normalScale=new ke(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Zn,this.combine=Kc,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Uc=class extends gn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Rx,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Bc=class extends gn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}};function Pr(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function xa(i){return i!==void 0&&i.inTangents!==void 0&&i.outTangents!==void 0}function QS(i){function e(r,s){return i[r]-i[s]}let t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function qg(i,e,t){let n=i.length,r=new i.constructor(n);for(let s=0,o=0;o!==n;++s){let a=t[s]*e;for(let l=0;l!==e;++l)r[o++]=i[a+l]}return r}function ew(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push(...o)),s=i[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=i[r++];while(s!==void 0)}var wi=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],s=t[n-1];n:{e:{let o;t:{i:if(!(e=s)){let a=t[1];e=s)break e}o=n,n=0;break t}break n}for(;n>>1;et;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=n.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(We("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,r=this.values,s=n.length;s===0&&(We("KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let l=n[a];if(typeof l=="number"&&isNaN(l)){We("KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){We("KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(r!==void 0&&Z1(r))for(let a=0,l=r.length;a!==l;++a){let c=r[a];if(isNaN(c)){We("KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===Sc,s=e.length-1,o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*n,l=o*n,c=0;c!==n;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,xa(this.settings)&&(r.settings={inTangents:this.settings.inTangents.slice(),outTangents:this.settings.outTangents.slice()}),r}};function $g(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]+=e}function Kg(i,e){for(let t=0,n=i.length;t!==n;t+=2)i[t]*=e}Fn.prototype.ValueTypeName="";Fn.prototype.TimeBufferType=Float32Array;Fn.prototype.ValueBufferType=Float32Array;Fn.prototype.DefaultInterpolation=ji;var rr=class extends Fn{constructor(e,t,n){super(e,t,n)}};rr.prototype.ValueTypeName="bool";rr.prototype.ValueBufferType=Array;rr.prototype.DefaultInterpolation=Ji;rr.prototype.InterpolantFactoryMethodLinear=void 0;rr.prototype.InterpolantFactoryMethodSmooth=void 0;var ka=class extends Fn{constructor(e,t,n,r){super(e,t,n,r)}};ka.prototype.ValueTypeName="color";var sr=class extends Fn{constructor(e,t,n,r){super(e,t,n,r)}};sr.prototype.ValueTypeName="number";var Wc=class extends wi{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(n-t)/(r-t),c=e*a;for(let u=c+a;c!==u;c+=4)wn.slerpFlat(s,0,o,c-a,o,c,l);return s}},or=class extends Fn{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new Wc(this.times,this.values,this.getValueSize(),e)}};or.prototype.ValueTypeName="quaternion";or.prototype.InterpolantFactoryMethodSmooth=void 0;var ar=class extends Fn{constructor(e,t,n){super(e,t,n)}};ar.prototype.ValueTypeName="string";ar.prototype.ValueBufferType=Array;ar.prototype.DefaultInterpolation=Ji;ar.prototype.InterpolantFactoryMethodLinear=void 0;ar.prototype.InterpolantFactoryMethodSmooth=void 0;var Dr=class extends Fn{constructor(e,t,n,r){super(e,t,n,r)}};Dr.prototype.ValueTypeName="vector";var Ua=class{constructor(e="",t=-1,n=[],r=Ex){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Ci(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push(rw(n[o]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s.userData=JSON.parse(e.userData||"{}"),s}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let s=0,o=n.length;s!==o;++s)t.push(Fn.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let s=t.length,o=[];for(let a=0;a1){let h=u[1],f=r[h];f||(r[h]=f=[]),f.push(c)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,n));return o}resetDuration(){let e=this.tracks,t=0;for(let n=0,r=e.length;n!==r;++n){let s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e{t&&t(s),this.manager.itemEnd(e)},0);return}if(qi[e]!==void 0){qi[e].push({onLoad:t,onProgress:n,onError:r});return}qi[e]=[],qi[e].push({onLoad:t,onProgress:n,onError:r});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",priority:this.priority,cache:this.cache,signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&Oe("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;let u=qi[e],h=c.body.getReader(),f=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),d=f?parseInt(f):0,p=d!==0,x=0,m=new ReadableStream({start(g){y();function y(){h.read().then(({done:_,value:b})=>{if(_)g.close();else{x+=b.byteLength;let M=new ProgressEvent("progress",{lengthComputable:p,loaded:x,total:d});for(let S=0,v=u.length;S{g.error(_)})}}});return new Response(m)}else throw new qf(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return c.json();default:if(a==="")return c.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),f=h&&h[1]?h[1].toLowerCase():void 0,d=new TextDecoder(f);return c.arrayBuffer().then(p=>d.decode(p))}}}).then(c=>{bi.add(`file:${e}`,c);let u=qi[e];delete qi[e];for(let h=0,f=u.length;h{let u=qi[e];if(u===void 0)throw this.manager.itemError(e),c;delete qi[e];for(let h=0,f=u.length;h{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};var ro=new WeakMap,Yc=class extends Ti{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=bi.get(`image:${e}`);if(o!==void 0){if(o.complete===!0)s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0);else{let h=ro.get(o);h===void 0&&(h=[],ro.set(o,h)),h.push({onLoad:t,onError:r})}return o}let a=uo("img");function l(){u(),t&&t(this);let h=ro.get(this)||[];for(let f=0;f"u"&&Oe("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Oe("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=bi.get(`image-bitmap:${e}`);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(c=>{kf.has(o)===!0?(r&&r(kf.get(o)),s.manager.itemError(e),s.manager.itemEnd(e)):(t&&t(c),s.manager.itemEnd(e))});return}setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0);return}let a={};a.credentials=this.withCredentials||this.crossOrigin!=="anonymous"?"include":"same-origin",a.headers=this.requestHeader,a.priority=this.priority,a.cache=this.cache,a.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let l=fetch(e,a).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign({},s.options,{colorSpaceConversion:"none"}))}).then(function(c){return bi.add(`image-bitmap:${e}`,c),t&&t(c),s.manager.itemEnd(e),c}).catch(function(c){r&&r(c),kf.set(l,c),bi.remove(`image-bitmap:${e}`),s.manager.itemError(e),s.manager.itemEnd(e)});bi.add(`image-bitmap:${e}`,l),s.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}};var so=-90,oo=1,_o=class extends Et{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new Jt(so,oo,e,t);r.layers=this.layers,this.add(r);let s=new Jt(so,oo,e,t);s.layers=this.layers,this.add(s);let o=new Jt(so,oo,e,t);o.layers=this.layers,this.add(o);let a=new Jt(so,oo,e,t);a.layers=this.layers,this.add(a);let l=new Jt(so,oo,e,t);l.layers=this.layers,this.add(l);let c=new Jt(so,oo,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,s,o,a,l]=t;for(let c of t)this.remove(c);if(e===Kn)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===co)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,l,c,u]=this.children,h=e.getRenderTarget(),f=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let x=n.texture.mipmapsAutoUpdate;n.texture.mipmapsAutoUpdate=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,s),e.setRenderTarget(n,1,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,2,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,3,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.mipmapsAutoUpdate=x,e.setRenderTarget(n,5,r),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(h,f,d),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},qc=class extends Jt{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e,this.perCameraFrustumCulled=!1}};var Pd="\\[\\]\\.:\\/",sw=new RegExp("["+Pd+"]","g"),Id="[^"+Pd+"]",ow="[^"+Pd.replace("\\.","")+"]",aw=/((?:WC+[\/:])*)/.source.replace("WC",Id),lw=/(WCOD+)?/.source.replace("WCOD",ow),cw=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Id),uw=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Id),hw=new RegExp("^"+aw+lw+cw+uw+"$"),fw=["material","materials","bones","map"],Jf=class{constructor(e,t,n){let r=n||gt.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},gt=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(sw,"")}static parseTrackName(e){let t=hw.exec(e);if(t===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=n.nodeName.substring(r+1);fw.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;od.start-p.start);let f=0;for(let d=1;d!!i.due&&i.due<=e;var : cases.z; return clamp( threshold , 1.0e-6, 1.0 ); } -#endif`,mw=`#ifdef USE_ALPHAMAP +#endif`,xw=`#ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; -#endif`,gw=`#ifdef USE_ALPHAMAP +#endif`,yw=`#ifdef USE_ALPHAMAP uniform sampler2D alphaMap; -#endif`,xw=`#ifdef USE_ALPHATEST +#endif`,bw=`#ifdef USE_ALPHATEST #ifdef ALPHA_TO_COVERAGE diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a ); if ( diffuseColor.a == 0.0 ) discard; #else if ( diffuseColor.a < alphaTest ) discard; #endif -#endif`,yw=`#ifdef USE_ALPHATEST +#endif`,vw=`#ifdef USE_ALPHATEST uniform float alphaTest; -#endif`,bw=`#ifdef USE_AOMAP +#endif`,_w=`#ifdef USE_AOMAP float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0; reflectedLight.indirectDiffuse *= ambientOcclusion; #if defined( USE_CLEARCOAT ) @@ -66,10 +66,10 @@ var D0=1.3,U0=(i,e=new Date().toISOString().slice(0,10))=>!!i.due&&i.due<=e;var float dotNV = saturate( dot( geometryNormal, geometryViewDir ) ); reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); #endif -#endif`,vw=`#ifdef USE_AOMAP +#endif`,Mw=`#ifdef USE_AOMAP uniform sampler2D aoMap; uniform float aoMapIntensity; -#endif`,_w=`#ifdef USE_BATCHING +#endif`,Sw=`#ifdef USE_BATCHING #if ! defined( GL_ANGLE_multi_draw ) #define gl_DrawID _gl_DrawID uniform int _gl_DrawID; @@ -103,15 +103,15 @@ var D0=1.3,U0=(i,e=new Date().toISOString().slice(0,10))=>!!i.due&&i.due<=e;var int y = j / size; return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ); } -#endif`,Mw=`#ifdef USE_BATCHING +#endif`,ww=`#ifdef USE_BATCHING mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) ); -#endif`,Sw=`vec3 transformed = vec3( position ); +#endif`,Tw=`vec3 transformed = vec3( position ); #ifdef USE_ALPHAHASH vPosition = vec3( position ); -#endif`,ww=`vec3 objectNormal = vec3( normal ); +#endif`,Aw=`vec3 objectNormal = vec3( normal ); #ifdef USE_TANGENT vec3 objectTangent = vec3( tangent.xyz ); -#endif`,Tw=`float G_BlinnPhong_Implicit( ) { +#endif`,Ew=`float G_BlinnPhong_Implicit( ) { return 0.25; } float D_BlinnPhong( const in float shininess, const in float dotNH ) { @@ -125,7 +125,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve float G = G_BlinnPhong_Implicit( ); float D = D_BlinnPhong( shininess, dotNH ); return F * ( G * D ); -} // validated`,Aw=`#ifdef USE_IRIDESCENCE +} // validated`,Rw=`#ifdef USE_IRIDESCENCE const mat3 XYZ_TO_REC709 = mat3( 3.2404542, -0.9692660, 0.0556434, -1.5371385, 1.8760108, -0.2040259, @@ -188,7 +188,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve } return max( I, vec3( 0.0 ) ); } -#endif`,Ew=`#ifdef USE_BUMPMAP +#endif`,Cw=`#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; vec2 dHdxy_fwd() { @@ -209,7 +209,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } -#endif`,Rw=`#if NUM_CLIPPING_PLANES > 0 +#endif`,Pw=`#if NUM_CLIPPING_PLANES > 0 vec4 plane; #ifdef ALPHA_TO_COVERAGE float distanceToPlane, distanceGradient; @@ -255,20 +255,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve if ( clipped ) discard; #endif #endif -#endif`,Cw=`#if NUM_CLIPPING_PLANES > 0 +#endif`,Iw=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; -#endif`,Pw=`#if NUM_CLIPPING_PLANES > 0 +#endif`,Lw=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; -#endif`,Iw=`#if NUM_CLIPPING_PLANES > 0 +#endif`,Fw=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; -#endif`,Lw=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) +#endif`,Nw=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; -#endif`,Fw=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) +#endif`,Ow=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) varying vec4 vColor; -#endif`,Nw=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) +#endif`,Dw=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec4 vColor; -#endif`,Ow=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) +#endif`,kw=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec4( 1.0 ); #endif #ifdef USE_COLOR_ALPHA @@ -281,7 +281,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve #endif #ifdef USE_BATCHING_COLOR vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); -#endif`,Dw=`#define PI 3.141592653589793 +#endif`,Uw=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 @@ -352,7 +352,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); -} // validated`,Uw=`vec3 transformedNormal = objectNormal; +} // validated`,Bw=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif @@ -378,21 +378,21 @@ transformedNormal = normalMatrix * transformedNormal; #endif #ifdef USE_TANGENT transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; -#endif`,kw=`#ifdef USE_DISPLACEMENTMAP +#endif`,zw=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; -#endif`,Bw=`#ifdef USE_DISPLACEMENTMAP +#endif`,Vw=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); -#endif`,zw=`#ifdef USE_EMISSIVEMAP +#endif`,Gw=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; -#endif`,Vw=`#ifdef USE_EMISSIVEMAP +#endif`,Hw=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; -#endif`,Gw="gl_FragColor = linearToOutputTexel( gl_FragColor );",Hw=`vec4 LinearTransferOETF( in vec4 value ) { +#endif`,Ww="gl_FragColor = linearToOutputTexel( gl_FragColor );",Xw=`vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( in vec4 value ) { @@ -400,7 +400,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) { } vec4 sRGBTransferOETF( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); -}`,Ww=`#ifdef USE_ENVMAP +}`,Yw=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { @@ -427,7 +427,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif -#endif`,Xw=`#ifdef USE_ENVMAP +#endif`,qw=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform mat3 envMapRotation; uniform samplerCube envMap; @@ -437,7 +437,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { return ENVMAP_MAX_LOD * r * ( 2.0 - r ); } #endif -#endif`,Yw=`#ifdef USE_ENVMAP +#endif`,$w=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS @@ -448,7 +448,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { #else varying vec3 vReflect; #endif -#endif`,qw=`#ifdef USE_ENVMAP +#endif`,Kw=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif @@ -459,7 +459,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { varying vec3 vReflect; uniform float refractionRatio; #endif -#endif`,$w=`#ifdef USE_ENVMAP +#endif`,Zw=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else @@ -476,18 +476,18 @@ vec4 sRGBTransferOETF( in vec4 value ) { vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif -#endif`,Kw=`#ifdef USE_FOG - vFogDepth = - mvPosition.z; -#endif`,Zw=`#ifdef USE_FOG - varying float vFogDepth; #endif`,Jw=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,jw=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Qw=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); -#endif`,jw=`#ifdef USE_FOG +#endif`,e2=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 @@ -496,7 +496,7 @@ vec4 sRGBTransferOETF( in vec4 value ) { uniform float fogNear; uniform float fogFar; #endif -#endif`,Qw=`#ifdef USE_GRADIENTMAP +#endif`,t2=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { @@ -508,12 +508,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif -}`,e2=`#ifdef USE_LIGHTMAP +}`,n2=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; -#endif`,t2=`LambertMaterial material; +#endif`,i2=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; -material.specularStrength = specularStrength;`,n2=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,r2=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; @@ -527,7 +527,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert -#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,i2=`uniform bool receiveShadow; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,s2=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; @@ -656,7 +656,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi return irradiance; } #endif -#include `,r2=`#ifdef USE_ENVMAP +#include `,o2=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_PMREM vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); @@ -713,8 +713,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi } #endif #endif -#endif`,s2=`ToonMaterial material; -material.diffuseColor = diffuseColor.rgb;`,o2=`varying vec3 vViewPosition; +#endif`,a2=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,l2=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; @@ -726,11 +726,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon -#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,a2=`BlinnPhongMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,c2=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; -material.specularStrength = specularStrength;`,l2=`varying vec3 vViewPosition; +material.specularStrength = specularStrength;`,u2=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; @@ -747,7 +747,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong -#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,c2=`PhysicalMaterial material; +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,h2=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb; material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); material.metalness = metalnessFactor; @@ -848,7 +848,7 @@ material.roughness = min( material.roughness, 1.0 ); material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; -#endif`,u2=`uniform sampler2D dfgLUT; +#endif`,f2=`uniform sampler2D dfgLUT; struct PhysicalMaterial { vec3 diffuseColor; vec3 diffuseContribution; @@ -1271,7 +1271,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); -}`,h2=` +}`,d2=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); @@ -1429,7 +1429,7 @@ IncidentLight directLight; #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); -#endif`,f2=`#if defined( RE_IndirectDiffuse ) +#endif`,p2=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; @@ -1459,7 +1459,7 @@ IncidentLight directLight; #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif -#endif`,d2=`#if defined( RE_IndirectDiffuse ) +#endif`,m2=`#if defined( RE_IndirectDiffuse ) #if defined( LAMBERT ) || defined( PHONG ) irradiance += iblIrradiance; #endif @@ -1467,7 +1467,7 @@ IncidentLight directLight; #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); -#endif`,p2=`#if NUM_LIGHT_PROBE_GRIDS > 0 +#endif`,g2=`#if NUM_LIGHT_PROBE_GRIDS > 0 uniform highp sampler3D probesSH[ NUM_LIGHT_PROBE_GRIDS ]; uniform vec3 probesMin[ NUM_LIGHT_PROBE_GRIDS ]; uniform vec3 probesMax[ NUM_LIGHT_PROBE_GRIDS ]; @@ -1516,27 +1516,27 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3 result += c8 * 0.429043 * ( x * x - y * y ); return max( result, vec3( 0.0 ) ); } -#endif`,m2=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) +#endif`,x2=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; -#endif`,g2=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) +#endif`,y2=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; -#endif`,x2=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,b2=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; -#endif`,y2=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER +#endif`,v2=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); -#endif`,b2=`#ifdef USE_MAP +#endif`,_2=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; -#endif`,v2=`#ifdef USE_MAP +#endif`,M2=`#ifdef USE_MAP uniform sampler2D map; -#endif`,_2=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) +#endif`,S2=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else @@ -1548,7 +1548,7 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3 #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; -#endif`,M2=`#if defined( USE_POINTS_UV ) +#endif`,w2=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) @@ -1560,19 +1560,19 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3 #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; -#endif`,S2=`float metalnessFactor = metalness; +#endif`,T2=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; -#endif`,w2=`#ifdef USE_METALNESSMAP +#endif`,A2=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; -#endif`,T2=`#ifdef USE_INSTANCING_MORPH +#endif`,E2=`#ifdef USE_INSTANCING_MORPH float morphTargetInfluences[ MORPHTARGETS_COUNT ]; float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; } -#endif`,A2=`#if defined( USE_MORPHCOLORS ) +#endif`,R2=`#if defined( USE_MORPHCOLORS ) #if defined( USE_COLOR_ALPHA ) vColor *= morphTargetBaseInfluence; #elif defined( USE_COLOR ) @@ -1585,12 +1585,12 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3 if ( morphTargetInfluences[ i ] != 0.0 ) vColor.rgb += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } -#endif`,E2=`#ifdef USE_MORPHNORMALS +#endif`,C2=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } -#endif`,R2=`#ifdef USE_MORPHTARGETS +#endif`,P2=`#ifdef USE_MORPHTARGETS #ifndef USE_INSTANCING_MORPH uniform float morphTargetBaseInfluence; uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; @@ -1604,12 +1604,12 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3 ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } -#endif`,C2=`#ifdef USE_MORPHTARGETS +#endif`,I2=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } -#endif`,P2=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#endif`,L2=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); @@ -1650,7 +1650,7 @@ vec3 getLightProbeGridIrradiance( highp sampler3D probesSH, vec3 probesMin, vec3 tbn2[1] *= faceDirection; #endif #endif -vec3 nonPerturbedNormal = normal;`,I2=`#ifdef USE_NORMALMAP_OBJECTSPACE +vec3 nonPerturbedNormal = normal;`,F2=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; @@ -1668,19 +1668,19 @@ vec3 nonPerturbedNormal = normal;`,I2=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); -#endif`,L2=`#ifndef FLAT_SHADED - varying vec3 vNormal; - #ifdef USE_TANGENT - varying vec3 vTangent; - varying vec3 vBitangent; - #endif -#endif`,F2=`#ifndef FLAT_SHADED - varying vec3 vNormal; - #ifdef USE_TANGENT - varying vec3 vTangent; - varying vec3 vBitangent; - #endif #endif`,N2=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,O2=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,D2=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); @@ -1689,7 +1689,7 @@ vec3 nonPerturbedNormal = normal;`,I2=`#ifdef USE_NORMALMAP_OBJECTSPACE vBitangent = - vBitangent; #endif #endif -#endif`,O2=`#ifdef USE_NORMALMAP +#endif`,k2=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif @@ -1711,13 +1711,13 @@ vec3 nonPerturbedNormal = normal;`,I2=`#ifdef USE_NORMALMAP_OBJECTSPACE float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } -#endif`,D2=`#ifdef USE_CLEARCOAT +#endif`,U2=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; -#endif`,U2=`#ifdef USE_CLEARCOAT_NORMALMAP +#endif`,B2=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); -#endif`,k2=`#ifdef USE_CLEARCOATMAP +#endif`,z2=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP @@ -1726,18 +1726,18 @@ vec3 nonPerturbedNormal = normal;`,I2=`#ifdef USE_NORMALMAP_OBJECTSPACE #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; -#endif`,B2=`#ifdef USE_IRIDESCENCEMAP +#endif`,V2=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; -#endif`,z2=`#ifdef OPAQUE +#endif`,G2=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif -gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,V2=`vec3 packNormalToRGB( const in vec3 normal ) { +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,H2=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { @@ -1816,9 +1816,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const #else return ( near * far ) / ( ( far - near ) * depth - far ); #endif -}`,G2=`#ifdef PREMULTIPLIED_ALPHA +}`,W2=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; -#endif`,H2=`vec4 mvPosition = vec4( transformed, 1.0 ); +#endif`,X2=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif @@ -1826,22 +1826,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; -gl_Position = projectionMatrix * mvPosition;`,W2=`#ifdef DITHERING +gl_Position = projectionMatrix * mvPosition;`,Y2=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); -#endif`,X2=`#ifdef DITHERING +#endif`,q2=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } -#endif`,Y2=`float roughnessFactor = roughness; +#endif`,$2=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; -#endif`,q2=`#ifdef USE_ROUGHNESSMAP +#endif`,K2=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; -#endif`,$2=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,Z2=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 @@ -2095,7 +2095,7 @@ gl_Position = projectionMatrix * mvPosition;`,W2=`#ifdef DITHERING } #endif #endif -#endif`,K2=`#if NUM_SPOT_LIGHT_COORDS > 0 +#endif`,J2=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif @@ -2140,7 +2140,7 @@ gl_Position = projectionMatrix * mvPosition;`,W2=`#ifdef DITHERING }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif -#endif`,Z2=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) +#endif`,j2=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SUN_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) #ifdef HAS_NORMAL vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); #else @@ -2180,7 +2180,7 @@ gl_Position = projectionMatrix * mvPosition;`,W2=`#ifdef DITHERING vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end -#endif`,J2=`float getShadowMask() { +#endif`,Q2=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_SUN_LIGHT_SHADOWS > 0 @@ -2221,12 +2221,12 @@ gl_Position = projectionMatrix * mvPosition;`,W2=`#ifdef DITHERING #endif #endif return shadow; -}`,j2=`#ifdef USE_SKINNING +}`,eT=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); -#endif`,Q2=`#ifdef USE_SKINNING +#endif`,tT=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; @@ -2241,7 +2241,7 @@ gl_Position = projectionMatrix * mvPosition;`,W2=`#ifdef DITHERING vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } -#endif`,eT=`#ifdef USE_SKINNING +#endif`,nT=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; @@ -2249,7 +2249,7 @@ gl_Position = projectionMatrix * mvPosition;`,W2=`#ifdef DITHERING skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; -#endif`,tT=`#ifdef USE_SKINNING +#endif`,iT=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; @@ -2260,17 +2260,17 @@ gl_Position = projectionMatrix * mvPosition;`,W2=`#ifdef DITHERING #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif -#endif`,nT=`float specularStrength; +#endif`,rT=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; -#endif`,iT=`#ifdef USE_SPECULARMAP +#endif`,sT=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; -#endif`,rT=`#if defined( TONE_MAPPING ) +#endif`,oT=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); -#endif`,sT=`#ifndef saturate +#endif`,aT=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; @@ -2367,7 +2367,7 @@ vec3 NeutralToneMapping( vec3 color ) { float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); return mix( color, vec3( newPeak ), g ); } -vec3 CustomToneMapping( vec3 color ) { return color; }`,oT=`#ifdef USE_TRANSMISSION +vec3 CustomToneMapping( vec3 color ) { return color; }`,lT=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; @@ -2388,7 +2388,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,oT=`#ifdef USE_TRANSMISS material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); -#endif`,aT=`#ifdef USE_TRANSMISSION +#endif`,cT=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; @@ -2514,7 +2514,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,oT=`#ifdef USE_TRANSMISS float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } -#endif`,lT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,uT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2587,7 +2587,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,oT=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,cT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,hT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP @@ -2685,7 +2685,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,oT=`#ifdef USE_TRANSMISS #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; -#endif`,uT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) +#endif`,fT=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP @@ -2759,7 +2759,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,oT=`#ifdef USE_TRANSMISS #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; -#endif`,hT=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 +#endif`,dT=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; @@ -2768,12 +2768,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,oT=`#ifdef USE_TRANSMISS worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; -#endif`,fT=`varying vec2 vUv; +#endif`,pT=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); -}`,dT=`uniform sampler2D t2D; +}`,mT=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { @@ -2785,14 +2785,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,pT=`varying vec3 vWorldDirection; +}`,gT=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,mT=`uniform float backgroundBlurriness; +}`,xT=`uniform float backgroundBlurriness; uniform float backgroundIntensity; uniform mat3 backgroundRotation; varying vec3 vWorldDirection; @@ -2807,14 +2807,14 @@ void main() { gl_FragColor = texColor; #include #include -}`,gT=`varying vec3 vWorldDirection; +}`,yT=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; -}`,xT=`uniform samplerCube tCube; +}`,bT=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; @@ -2824,7 +2824,7 @@ void main() { gl_FragColor.a *= opacity; #include #include -}`,yT=`#include +}`,vT=`#include #include #include #include @@ -2851,7 +2851,7 @@ void main() { #include #include vHighPrecisionZW = gl_Position.zw; -}`,bT=`#if DEPTH_PACKING == 3200 +}`,_T=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include @@ -2889,7 +2889,7 @@ void main() { #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif -}`,vT=`#define DISTANCE +}`,MT=`#define DISTANCE varying vec3 vWorldPosition; #include #include @@ -2916,7 +2916,7 @@ void main() { #include #include vWorldPosition = worldPosition.xyz; -}`,_T=`#define DISTANCE +}`,ST=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; @@ -2939,13 +2939,13 @@ void main() { dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); -}`,MT=`varying vec3 vWorldDirection; +}`,wT=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include -}`,ST=`uniform sampler2D tEquirect; +}`,TT=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { @@ -2954,7 +2954,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include -}`,wT=`uniform float scale; +}`,AT=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include @@ -2976,7 +2976,7 @@ void main() { #include #include #include -}`,TT=`uniform vec3 diffuse; +}`,ET=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; @@ -3004,7 +3004,7 @@ void main() { #include #include #include -}`,AT=`#include +}`,RT=`#include #include #include #include @@ -3036,7 +3036,7 @@ void main() { #include #include #include -}`,ET=`uniform vec3 diffuse; +}`,CT=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; @@ -3084,7 +3084,7 @@ void main() { #include #include #include -}`,RT=`#define LAMBERT +}`,PT=`#define LAMBERT varying vec3 vViewPosition; #include #include @@ -3123,7 +3123,7 @@ void main() { #include #include #include -}`,CT=`#define LAMBERT +}`,IT=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3180,7 +3180,7 @@ void main() { #include #include #include -}`,PT=`#define MATCAP +}`,LT=`#define MATCAP varying vec3 vViewPosition; #include #include @@ -3214,7 +3214,7 @@ void main() { #include #include vViewPosition = - mvPosition.xyz; -}`,IT=`#define MATCAP +}`,FT=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; @@ -3260,7 +3260,7 @@ void main() { #include #include #include -}`,LT=`#define NORMAL +}`,NT=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif @@ -3293,7 +3293,7 @@ void main() { #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif -}`,FT=`#define NORMAL +}`,OT=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; @@ -3314,7 +3314,7 @@ void main() { #ifdef OPAQUE gl_FragColor.a = 1.0; #endif -}`,NT=`#define PHONG +}`,DT=`#define PHONG varying vec3 vViewPosition; #include #include @@ -3353,7 +3353,7 @@ void main() { #include #include #include -}`,OT=`#define PHONG +}`,kT=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; @@ -3412,7 +3412,7 @@ void main() { #include #include #include -}`,DT=`#define STANDARD +}`,UT=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; @@ -3455,7 +3455,7 @@ void main() { #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif -}`,UT=`#define STANDARD +}`,BT=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR @@ -3588,7 +3588,7 @@ void main() { #include #include #include -}`,kT=`#define TOON +}`,zT=`#define TOON varying vec3 vViewPosition; #include #include @@ -3625,7 +3625,7 @@ void main() { #include #include #include -}`,BT=`#define TOON +}`,VT=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; @@ -3677,7 +3677,7 @@ void main() { #include #include #include -}`,zT=`uniform float size; +}`,GT=`uniform float size; uniform float scale; #include #include @@ -3708,7 +3708,7 @@ void main() { #include #include #include -}`,VT=`uniform vec3 diffuse; +}`,HT=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3733,7 +3733,7 @@ void main() { #include #include #include -}`,GT=`#include +}`,WT=`#include #include #include #include @@ -3756,7 +3756,7 @@ void main() { #include #include #include -}`,HT=`uniform vec3 color; +}`,XT=`uniform vec3 color; uniform float opacity; #include #include @@ -3772,7 +3772,7 @@ void main() { #include #include #include -}`,WT=`uniform float rotation; +}`,YT=`uniform float rotation; uniform vec2 center; #include #include @@ -3796,7 +3796,7 @@ void main() { #include #include #include -}`,XT=`uniform vec3 diffuse; +}`,qT=`uniform vec3 diffuse; uniform float opacity; #include #include @@ -3821,7 +3821,7 @@ void main() { #include #include #include -}`,tt={alphahash_fragment:dw,alphahash_pars_fragment:pw,alphamap_fragment:mw,alphamap_pars_fragment:gw,alphatest_fragment:xw,alphatest_pars_fragment:yw,aomap_fragment:bw,aomap_pars_fragment:vw,batching_pars_vertex:_w,batching_vertex:Mw,begin_vertex:Sw,beginnormal_vertex:ww,bsdfs:Tw,iridescence_fragment:Aw,bumpmap_pars_fragment:Ew,clipping_planes_fragment:Rw,clipping_planes_pars_fragment:Cw,clipping_planes_pars_vertex:Pw,clipping_planes_vertex:Iw,color_fragment:Lw,color_pars_fragment:Fw,color_pars_vertex:Nw,color_vertex:Ow,common:Dw,defaultnormal_vertex:Uw,displacementmap_pars_vertex:kw,displacementmap_vertex:Bw,emissivemap_fragment:zw,emissivemap_pars_fragment:Vw,colorspace_fragment:Gw,colorspace_pars_fragment:Hw,envmap_fragment:Ww,envmap_common_pars_fragment:Xw,envmap_pars_fragment:Yw,envmap_pars_vertex:qw,envmap_physical_pars_fragment:r2,envmap_vertex:$w,fog_vertex:Kw,fog_pars_vertex:Zw,fog_fragment:Jw,fog_pars_fragment:jw,gradientmap_pars_fragment:Qw,lightmap_pars_fragment:e2,lights_lambert_fragment:t2,lights_lambert_pars_fragment:n2,lights_pars_begin:i2,lights_toon_fragment:s2,lights_toon_pars_fragment:o2,lights_phong_fragment:a2,lights_phong_pars_fragment:l2,lights_physical_fragment:c2,lights_physical_pars_fragment:u2,lights_fragment_begin:h2,lights_fragment_maps:f2,lights_fragment_end:d2,lightprobes_pars_fragment:p2,logdepthbuf_fragment:m2,logdepthbuf_pars_fragment:g2,logdepthbuf_pars_vertex:x2,logdepthbuf_vertex:y2,map_fragment:b2,map_pars_fragment:v2,map_particle_fragment:_2,map_particle_pars_fragment:M2,metalnessmap_fragment:S2,metalnessmap_pars_fragment:w2,morphinstance_vertex:T2,morphcolor_vertex:A2,morphnormal_vertex:E2,morphtarget_pars_vertex:R2,morphtarget_vertex:C2,normal_fragment_begin:P2,normal_fragment_maps:I2,normal_pars_fragment:L2,normal_pars_vertex:F2,normal_vertex:N2,normalmap_pars_fragment:O2,clearcoat_normal_fragment_begin:D2,clearcoat_normal_fragment_maps:U2,clearcoat_pars_fragment:k2,iridescence_pars_fragment:B2,opaque_fragment:z2,packing:V2,premultiplied_alpha_fragment:G2,project_vertex:H2,dithering_fragment:W2,dithering_pars_fragment:X2,roughnessmap_fragment:Y2,roughnessmap_pars_fragment:q2,shadowmap_pars_fragment:$2,shadowmap_pars_vertex:K2,shadowmap_vertex:Z2,shadowmask_pars_fragment:J2,skinbase_vertex:j2,skinning_pars_vertex:Q2,skinning_vertex:eT,skinnormal_vertex:tT,specularmap_fragment:nT,specularmap_pars_fragment:iT,tonemapping_fragment:rT,tonemapping_pars_fragment:sT,transmission_fragment:oT,transmission_pars_fragment:aT,uv_pars_fragment:lT,uv_pars_vertex:cT,uv_vertex:uT,worldpos_vertex:hT,background_vert:fT,background_frag:dT,backgroundCube_vert:pT,backgroundCube_frag:mT,cube_vert:gT,cube_frag:xT,depth_vert:yT,depth_frag:bT,distance_vert:vT,distance_frag:_T,equirect_vert:MT,equirect_frag:ST,linedashed_vert:wT,linedashed_frag:TT,meshbasic_vert:AT,meshbasic_frag:ET,meshlambert_vert:RT,meshlambert_frag:CT,meshmatcap_vert:PT,meshmatcap_frag:IT,meshnormal_vert:LT,meshnormal_frag:FT,meshphong_vert:NT,meshphong_frag:OT,meshphysical_vert:DT,meshphysical_frag:UT,meshtoon_vert:kT,meshtoon_frag:BT,points_vert:zT,points_frag:VT,shadow_vert:GT,shadow_frag:HT,sprite_vert:WT,sprite_frag:XT},_e={common:{diffuse:{value:new W(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xe}},envmap:{envMap:{value:null},envMapRotation:{value:new Xe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xe},normalScale:{value:new Ue(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new W(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:[]},probesMin:{value:[]},probesMax:{value:[]},probesResolution:{value:[]}},points:{diffuse:{value:new W(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0},uvTransform:{value:new Xe}},sprite:{diffuse:{value:new W(16777215)},opacity:{value:1},center:{value:new Ue(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xe},alphaMap:{value:null},alphaMapTransform:{value:new Xe},alphaTest:{value:0}}},Ii={basic:{uniforms:bn([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.fog]),vertexShader:tt.meshbasic_vert,fragmentShader:tt.meshbasic_frag},lambert:{uniforms:bn([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,_e.lights,{emissive:{value:new W(0)},envMapIntensity:{value:1}}]),vertexShader:tt.meshlambert_vert,fragmentShader:tt.meshlambert_frag},phong:{uniforms:bn([_e.common,_e.specularmap,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,_e.lights,{emissive:{value:new W(0)},specular:{value:new W(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:tt.meshphong_vert,fragmentShader:tt.meshphong_frag},standard:{uniforms:bn([_e.common,_e.envmap,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.roughnessmap,_e.metalnessmap,_e.fog,_e.lights,{emissive:{value:new W(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:tt.meshphysical_vert,fragmentShader:tt.meshphysical_frag},toon:{uniforms:bn([_e.common,_e.aomap,_e.lightmap,_e.emissivemap,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.gradientmap,_e.fog,_e.lights,{emissive:{value:new W(0)}}]),vertexShader:tt.meshtoon_vert,fragmentShader:tt.meshtoon_frag},matcap:{uniforms:bn([_e.common,_e.bumpmap,_e.normalmap,_e.displacementmap,_e.fog,{matcap:{value:null}}]),vertexShader:tt.meshmatcap_vert,fragmentShader:tt.meshmatcap_frag},points:{uniforms:bn([_e.points,_e.fog]),vertexShader:tt.points_vert,fragmentShader:tt.points_frag},dashed:{uniforms:bn([_e.common,_e.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:tt.linedashed_vert,fragmentShader:tt.linedashed_frag},depth:{uniforms:bn([_e.common,_e.displacementmap]),vertexShader:tt.depth_vert,fragmentShader:tt.depth_frag},normal:{uniforms:bn([_e.common,_e.bumpmap,_e.normalmap,_e.displacementmap,{opacity:{value:1}}]),vertexShader:tt.meshnormal_vert,fragmentShader:tt.meshnormal_frag},sprite:{uniforms:bn([_e.sprite,_e.fog]),vertexShader:tt.sprite_vert,fragmentShader:tt.sprite_frag},background:{uniforms:{uvTransform:{value:new Xe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:tt.background_vert,fragmentShader:tt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Xe}},vertexShader:tt.backgroundCube_vert,fragmentShader:tt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:tt.cube_vert,fragmentShader:tt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:tt.equirect_vert,fragmentShader:tt.equirect_frag},distance:{uniforms:bn([_e.common,_e.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:tt.distance_vert,fragmentShader:tt.distance_frag},shadow:{uniforms:bn([_e.lights,_e.fog,{color:{value:new W(0)},opacity:{value:1}}]),vertexShader:tt.shadow_vert,fragmentShader:tt.shadow_frag}};Ii.physical={uniforms:bn([Ii.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xe},clearcoatNormalScale:{value:new Ue(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xe},diffuseRoughness:{value:0},diffuseRoughnessMap:{value:null},diffuseRoughnessMapTransform:{value:new Xe},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xe},sheen:{value:0},sheenColor:{value:new W(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xe},transmissionSamplerSize:{value:new Ue},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xe},attenuationDistance:{value:0},attenuationColor:{value:new W(0)},specularColor:{value:new W(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xe},anisotropyVector:{value:new Ue},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xe}}]),vertexShader:tt.meshphysical_vert,fragmentShader:tt.meshphysical_frag};var Ou={r:0,b:0,g:0},YT=new ze,gy=new Xe;gy.set(-1,0,0,0,1,0,0,0,1);function qT(i,e,t,n,r,s){let o=new W(0),a=r===!0?0:1,l,c,u=null,h=0,f=null;function d(y){let _=y.isScene===!0?y.background:null;if(_&&_.isTexture){let b=y.backgroundBlurriness>0;_=e.get(_,b)}return _}function p(y){let _=!1,b=d(y);b===null?m(o,a):b&&b.isColor&&(m(b,1),_=!0);let M=i.xr.getEnvironmentBlendMode();M==="additive"?t.buffers.color.setClear(0,0,0,1,s):M==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(i.autoClear||_)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(y,_){let b=d(_);b&&b.isCubeTexture?(c===void 0&&(c=new Se(new Mi(1,1,1),new Si({name:"BackgroundCubeMaterial",uniforms:_s(Ii.backgroundCube.uniforms),vertexShader:Ii.backgroundCube.vertexShader,fragmentShader:Ii.backgroundCube.fragmentShader,side:un,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(M,S,v){this.matrixWorld.copyPosition(v.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=b,c.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(YT.makeRotationFromEuler(_.backgroundRotation)).transpose(),b.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(gy),c.material.toneMapped=it.getTransfer(b.colorSpace)!==Mt,(u!==b||h!==b.version||f!==i.toneMapping)&&(c.material.needsUpdate=!0,u=b,h=b.version,f=i.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null)):b&&b.isTexture&&(l===void 0&&(l=new Se(new sn(2,2),new Si({name:"BackgroundMaterial",uniforms:_s(Ii.background.uniforms),vertexShader:Ii.background.vertexShader,fragmentShader:Ii.background.fragmentShader,side:Ai,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=b,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.toneMapped=it.getTransfer(b.colorSpace)!==Mt,b.matrixAutoUpdate===!0&&b.updateMatrix(),l.material.uniforms.uvTransform.value.copy(b.matrix),(u!==b||h!==b.version||f!==i.toneMapping)&&(l.material.needsUpdate=!0,u=b,h=b.version,f=i.toneMapping),l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null))}function m(y,_){y.getRGB(Ou,Rd(i)),t.buffers.color.setClear(Ou.r,Ou.g,Ou.b,_,s)}function g(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(y,_=1){o.set(y),a=_,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(y){a=y,m(o,a)},render:p,addToRenderList:x,dispose:g}}function $T(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=f(null),s=r,o=!1;function a(R,L,k,C,I){let O=!1,F=h(R,C,k,L);s!==F&&(s=F,c(s.object)),O=d(R,C,k,I),O&&p(R,C,k,I),I!==null&&e.update(I,i.ELEMENT_ARRAY_BUFFER),(O||o)&&(o=!1,b(R,L,k,C),I!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(I).buffer))}function l(){return i.createVertexArray()}function c(R){return i.bindVertexArray(R)}function u(R){return i.deleteVertexArray(R)}function h(R,L,k,C){let I=C.wireframe===!0,O=n[L.id];O===void 0&&(O={},n[L.id]=O);let F=R.isInstancedMesh===!0?R.id:0,H=O[F];H===void 0&&(H={},O[F]=H);let U=H[k.id];U===void 0&&(U={},H[k.id]=U);let X=U[I];return X===void 0&&(X=f(l()),U[I]=X),X}function f(R){let L=[],k=[],C=[];for(let I=0;I=0){let V=I[U],re=O[U];if(re===void 0&&(U==="instanceMatrix"&&R.instanceMatrix&&(re=R.instanceMatrix),U==="instanceColor"&&R.instanceColor&&(re=R.instanceColor)),V===void 0||V.attribute!==re||re&&V.data!==re.data)return!0;F++}return s.attributesNum!==F||s.index!==C}function p(R,L,k,C){let I={},O=L.attributes,F=0,H=k.getAttributes();for(let U in H)if(H[U].location>=0){let V=O[U];V===void 0&&(U==="instanceMatrix"&&R.instanceMatrix&&(V=R.instanceMatrix),U==="instanceColor"&&R.instanceColor&&(V=R.instanceColor));let re={};re.attribute=V,V&&V.data&&(re.data=V.data),I[U]=re,F++}s.attributes=I,s.attributesNum=F,s.index=C}function x(){let R=s.newAttributes;for(let L=0,k=R.length;L=0){let X=I[H];if(X===void 0&&(H==="instanceMatrix"&&R.instanceMatrix&&(X=R.instanceMatrix),H==="instanceColor"&&R.instanceColor&&(X=R.instanceColor)),X!==void 0){let V=X.normalized,re=X.itemSize,ye=e.get(X);if(ye===void 0)continue;let Y=ye.buffer,Q=ye.type,se=ye.bytesPerElement,we=Q===i.INT||Q===i.UNSIGNED_INT||X.gpuType===Jc;if(X.isInterleavedBufferAttribute){let le=X.data,Ne=le.isInterleavedBuffer===!0?le.stride:le.itemSize,at=X.offset;if(le.isInstancedInterleavedBuffer||le.isInstancedBufferAttribute){for(let Ae=0;Ae0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";v="mediump"}return v==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",u=l(c);u!==c&&(Oe("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);let h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),f=t.logarithmicDepthBuffer===!0&&h===!1;t.reversedDepthBuffer===!0&&h===!1&&Oe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),t.logarithmicDepthBuffer===!0&&h===!0&&Oe("WebGLRenderer: Logarithmic depth buffer is ignored when reversed depth buffer is enabled.");let d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),p=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),g=i.getParameter(i.MAX_VERTEX_ATTRIBS),y=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),_=i.getParameter(i.MAX_VARYING_VECTORS),b=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),M=i.getParameter(i.MAX_SAMPLES),S=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:p,maxTextureSize:x,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:y,maxVaryings:_,maxFragmentUniforms:b,maxSamples:M,samples:S}}function JT(i){let e=this,t=null,n=0,r=!1,s=!1,o=new mn,a=new Xe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){let d=h.length!==0||f||n!==0||r;return r=f,n=h.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){t=u(h,f,0)},this.setState=function(h,f,d){let p=h.clippingPlanes,x=h.clipIntersection,m=h.clipShadows,g=i.get(h);if(!r||p===null||p.length===0||s&&!m)s?u(null):c();else{let y=s?0:n,_=y*4,b=g.clippingState||null;l.value=b,b=u(p,f,_,d);for(let M=0;M!==_;++M)b[M]=t[M];g.clippingState=b,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,f,d,p){let x=h!==null?h.length:0,m=null;if(x!==0){if(m=l.value,p!==!0||m===null){let g=d+x*4,y=f.matrixWorldInverse;a.getNormalMatrix(y),(m===null||m.length0;_=e.get(_,b)}return _}function p(y){let _=!1,b=d(y);b===null?m(o,a):b&&b.isColor&&(m(b,1),_=!0);let M=i.xr.getEnvironmentBlendMode();M==="additive"?t.buffers.color.setClear(0,0,0,1,s):M==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,s),(i.autoClear||_)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(y,_){let b=d(_);b&&b.isCubeTexture?(c===void 0&&(c=new Se(new Mi(1,1,1),new Si({name:"BackgroundCubeMaterial",uniforms:_s(Ii.backgroundCube.uniforms),vertexShader:Ii.backgroundCube.vertexShader,fragmentShader:Ii.backgroundCube.fragmentShader,side:un,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(M,S,v){this.matrixWorld.copyPosition(v.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=b,c.material.uniforms.backgroundBlurriness.value=_.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4($T.makeRotationFromEuler(_.backgroundRotation)).transpose(),b.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(xy),c.material.toneMapped=it.getTransfer(b.colorSpace)!==Mt,(u!==b||h!==b.version||f!==i.toneMapping)&&(c.material.needsUpdate=!0,u=b,h=b.version,f=i.toneMapping),c.layers.enableAll(),y.unshift(c,c.geometry,c.material,0,0,null)):b&&b.isTexture&&(l===void 0&&(l=new Se(new sn(2,2),new Si({name:"BackgroundMaterial",uniforms:_s(Ii.background.uniforms),vertexShader:Ii.background.vertexShader,fragmentShader:Ii.background.fragmentShader,side:Ai,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=b,l.material.uniforms.backgroundIntensity.value=_.backgroundIntensity,l.material.toneMapped=it.getTransfer(b.colorSpace)!==Mt,b.matrixAutoUpdate===!0&&b.updateMatrix(),l.material.uniforms.uvTransform.value.copy(b.matrix),(u!==b||h!==b.version||f!==i.toneMapping)&&(l.material.needsUpdate=!0,u=b,h=b.version,f=i.toneMapping),l.layers.enableAll(),y.unshift(l,l.geometry,l.material,0,0,null))}function m(y,_){y.getRGB(Du,Cd(i)),t.buffers.color.setClear(Du.r,Du.g,Du.b,_,s)}function g(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return o},setClearColor:function(y,_=1){o.set(y),a=_,m(o,a)},getClearAlpha:function(){return a},setClearAlpha:function(y){a=y,m(o,a)},render:p,addToRenderList:x,dispose:g}}function ZT(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=f(null),s=r,o=!1;function a(R,L,U,C,I){let O=!1,F=h(R,C,U,L);s!==F&&(s=F,c(s.object)),O=d(R,C,U,I),O&&p(R,C,U,I),I!==null&&e.update(I,i.ELEMENT_ARRAY_BUFFER),(O||o)&&(o=!1,b(R,L,U,C),I!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(I).buffer))}function l(){return i.createVertexArray()}function c(R){return i.bindVertexArray(R)}function u(R){return i.deleteVertexArray(R)}function h(R,L,U,C){let I=C.wireframe===!0,O=n[L.id];O===void 0&&(O={},n[L.id]=O);let F=R.isInstancedMesh===!0?R.id:0,H=O[F];H===void 0&&(H={},O[F]=H);let k=H[U.id];k===void 0&&(k={},H[U.id]=k);let X=k[I];return X===void 0&&(X=f(l()),k[I]=X),X}function f(R){let L=[],U=[],C=[];for(let I=0;I=0){let V=I[k],re=O[k];if(re===void 0&&(k==="instanceMatrix"&&R.instanceMatrix&&(re=R.instanceMatrix),k==="instanceColor"&&R.instanceColor&&(re=R.instanceColor)),V===void 0||V.attribute!==re||re&&V.data!==re.data)return!0;F++}return s.attributesNum!==F||s.index!==C}function p(R,L,U,C){let I={},O=L.attributes,F=0,H=U.getAttributes();for(let k in H)if(H[k].location>=0){let V=O[k];V===void 0&&(k==="instanceMatrix"&&R.instanceMatrix&&(V=R.instanceMatrix),k==="instanceColor"&&R.instanceColor&&(V=R.instanceColor));let re={};re.attribute=V,V&&V.data&&(re.data=V.data),I[k]=re,F++}s.attributes=I,s.attributesNum=F,s.index=C}function x(){let R=s.newAttributes;for(let L=0,U=R.length;L=0){let X=I[H];if(X===void 0&&(H==="instanceMatrix"&&R.instanceMatrix&&(X=R.instanceMatrix),H==="instanceColor"&&R.instanceColor&&(X=R.instanceColor)),X!==void 0){let V=X.normalized,re=X.itemSize,ye=e.get(X);if(ye===void 0)continue;let Y=ye.buffer,Q=ye.type,se=ye.bytesPerElement,we=Q===i.INT||Q===i.UNSIGNED_INT||X.gpuType===jc;if(X.isInterleavedBufferAttribute){let le=X.data,Ne=le.isInterleavedBuffer===!0?le.stride:le.itemSize,at=X.offset;if(le.isInstancedInterleavedBuffer||le.isInstancedBufferAttribute){for(let Ae=0;Ae0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";v="mediump"}return v==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp",u=l(c);u!==c&&(Oe("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);let h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),f=t.logarithmicDepthBuffer===!0&&h===!1;t.reversedDepthBuffer===!0&&h===!1&&Oe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."),t.logarithmicDepthBuffer===!0&&h===!0&&Oe("WebGLRenderer: Logarithmic depth buffer is ignored when reversed depth buffer is enabled.");let d=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),p=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),g=i.getParameter(i.MAX_VERTEX_ATTRIBS),y=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),_=i.getParameter(i.MAX_VARYING_VECTORS),b=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),M=i.getParameter(i.MAX_SAMPLES),S=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:a,precision:c,logarithmicDepthBuffer:f,reversedDepthBuffer:h,maxTextures:d,maxVertexTextures:p,maxTextureSize:x,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:y,maxVaryings:_,maxFragmentUniforms:b,maxSamples:M,samples:S}}function QT(i){let e=this,t=null,n=0,r=!1,s=!1,o=new mn,a=new Xe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(h,f){let d=h.length!==0||f||n!==0||r;return r=f,n=h.length,d},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,f){t=u(h,f,0)},this.setState=function(h,f,d){let p=h.clippingPlanes,x=h.clipIntersection,m=h.clipShadows,g=i.get(h);if(!r||p===null||p.length===0||s&&!m)s?u(null):c();else{let y=s?0:n,_=y*4,b=g.clippingState||null;l.value=b,b=u(p,f,_,d);for(let M=0;M!==_;++M)b[M]=t[M];g.clippingState=b,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=y}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,f,d,p){let x=h!==null?h.length:0,m=null;if(x!==0){if(m=l.value,p!==!0||m===null){let g=d+x*4,y=f.matrixWorldInverse;a.getNormalMatrix(y),(m===null||m.length0&&(u.texture.mipmapsAutoUpdate=!1);let h=l.autoClear,f=l.autoClearColor,d=l.autoClearDepth,p=l.autoClearStencil,x=e.background;l.autoClear=!0,l.autoClearColor=!0,l.autoClearDepth=!0,l.autoClearStencil=!0,x===null&&(e.background=l.getClearColor(nA));let m=new _o(n,r,u);return m.position.copy(a),m.update(l,e),l.autoClear=h,l.autoClearColor=f,l.autoClearDepth=d,l.autoClearStencil=p,e.background=x,t>0&&(u.texture.mipmapsAutoUpdate=!0,this._blur(c,t)),this._applyPMREM(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Jx(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Zx(),this._compileMaterial(this._equirectMaterial))}dispose(){this._sourceTarget!==null&&this._sourceTarget.dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._integrationMaterial!==null&&this._integrationMaterial.dispose(),this._boxMesh.geometry.dispose()}static lodToRoughness(e,t){return t>0?1-Math.sqrt(1-e/t):0}_setSize(e){this._cubeSize=Math.max($x,Td(e))}_fromTexture(e,t){e.mapping===bs||e.mapping===So?this._setSize(e.image.length===0?$x:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4);let n=t||this._allocateTarget();return this._textureToCubemap(e),this._applyPMREM(n),n}_allocateTarget(){let e=this._cubeSize,t=Kx(e,!1,!1),n=Math.log2(e)-jT;for(let r=0;r<=n;r++)t.texture.mipmaps.push({width:e>>r,height:e>>r});return t.texture.name="PMREM",t.texture.isPMREMTexture=!0,t}_getSourceTarget(e=!1){let t=this._cubeSize,n=this._sourceTarget;return(n===null||n.width!==t||e&&n.depthBuffer===!1)&&(n!==null&&n.dispose(),this._sourceTarget=Kx(t,!0,e)),this._sourceTarget}_compileMaterial(e){this._boxMesh.material=e,this._renderer.compile(this._boxMesh,this._cubeCamera.children[0])}_renderCube(e,t,n){let r=this._boxMesh,s=this._cubeCamera;r.material=n,s.renderTarget=e,s.activeMipmapLevel=t;let o=e.width>>t;e.viewport.set(0,0,o,o),s.update(this._renderer,r),e.viewport.set(0,0,e.width,e.height)}_textureToCubemap(e){let t;e.mapping===bs||e.mapping===So?(this._cubemapMaterial===null&&(this._cubemapMaterial=Jx()),t=this._cubemapMaterial,t.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):(this._equirectMaterial===null&&(this._equirectMaterial=Zx()),t=this._equirectMaterial),t.uniforms.envMap.value=e,this._renderCube(this._getSourceTarget(),0,t)}_applyPMREM(e){this._ggxMaterial===null&&(this._ggxMaterial=iA(),this._integrationMaterial=rA());let t=this._cubeSize,n=e.texture.mipmaps.length-1,r=this._ggxMaterial.uniforms;r.envMap.value=this._sourceTarget.texture;let s=this._integrationMaterial.uniforms;s.envMap.value=this._sourceTarget.texture,s.sourceLod.value=Math.log2(t/yy);for(let o=0;o<=n;o++){let a=i.lodToRoughness(o,n);if(o>n-eA)s.roughness.value=a,this._renderCube(e,o,this._integrationMaterial);else{let l=a>0?Math.log2(t)+.5*Math.log2(6/(xy*Math.pow(a,4)))+.5:0;r.roughness.value=a,r.lodBias.value=l,this._renderCube(e,o,this._ggxMaterial)}}}_blur(e,t){this._blurMaterial===null&&(this._blurMaterial=sA());let n=this._blurMaterial,r=n.uniforms,s=this._sourceTarget;r.sigma.value=Math.min(t,Math.PI)/Math.SQRT2,r.envMap.value=s.texture,this._renderCube(e,0,n),r.envMap.value=e.texture,this._renderCube(s,0,n)}};function Kx(i,e,t){return new nl(i,{minFilter:Nn,generateMipmaps:e,type:li,colorSpace:Sn,depthBuffer:t})}function il(i,e,t){return new Si({name:i,uniforms:e,vertexShader:tt.cube_vert,fragmentShader:t,side:un,blending:xs,depthTest:!1,depthWrite:!1})}function iA(){return il("PMREMGGXConvolution",{envMap:{value:null},roughness:{value:0},lodBias:{value:0}},` + `},r=new Mi(5,5,5),s=new Si({name:"CubemapFromEquirect",uniforms:_s(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:un,blending:xs});s.uniforms.tEquirect.value=t;let o=new Se(r,s),a=t.minFilter;return t.minFilter===Nn&&(t.minFilter=Ht),new _o(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,r);e.setRenderTarget(s)}},Kx=256,eA=3,tA=20,yy=256,by=16,nA=3,iA=new D,rA=new W,Ro=class i{constructor(e){this._renderer=e,this._cubeSize=0,this._sourceTarget=null,this._cubeCamera=new _o(1,10,null),this._boxMesh=new Se(new Mi(5,5,5),null),this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null,this._integrationMaterial=null}fromScene(e,t=0,n=.1,r=100,s={}){let{size:o=256,position:a=iA}=s,l=this._renderer;this._setSize(o);let c=this._allocateTarget(),u=this._getSourceTarget(!0);t>0&&(u.texture.mipmapsAutoUpdate=!1);let h=l.autoClear,f=l.autoClearColor,d=l.autoClearDepth,p=l.autoClearStencil,x=e.background;l.autoClear=!0,l.autoClearColor=!0,l.autoClearDepth=!0,l.autoClearStencil=!0,x===null&&(e.background=l.getClearColor(rA));let m=new _o(n,r,u);return m.position.copy(a),m.update(l,e),l.autoClear=h,l.autoClearColor=f,l.autoClearDepth=d,l.autoClearStencil=p,e.background=x,t>0&&(u.texture.mipmapsAutoUpdate=!0,this._blur(c,t)),this._applyPMREM(c),c}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=jx(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Jx(),this._compileMaterial(this._equirectMaterial))}dispose(){this._sourceTarget!==null&&this._sourceTarget.dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._integrationMaterial!==null&&this._integrationMaterial.dispose(),this._boxMesh.geometry.dispose()}static lodToRoughness(e,t){return t>0?1-Math.sqrt(1-e/t):0}_setSize(e){this._cubeSize=Math.max(Kx,Ad(e))}_fromTexture(e,t){e.mapping===bs||e.mapping===So?this._setSize(e.image.length===0?Kx:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4);let n=t||this._allocateTarget();return this._textureToCubemap(e),this._applyPMREM(n),n}_allocateTarget(){let e=this._cubeSize,t=Zx(e,!1,!1),n=Math.log2(e)-eA;for(let r=0;r<=n;r++)t.texture.mipmaps.push({width:e>>r,height:e>>r});return t.texture.name="PMREM",t.texture.isPMREMTexture=!0,t}_getSourceTarget(e=!1){let t=this._cubeSize,n=this._sourceTarget;return(n===null||n.width!==t||e&&n.depthBuffer===!1)&&(n!==null&&n.dispose(),this._sourceTarget=Zx(t,!0,e)),this._sourceTarget}_compileMaterial(e){this._boxMesh.material=e,this._renderer.compile(this._boxMesh,this._cubeCamera.children[0])}_renderCube(e,t,n){let r=this._boxMesh,s=this._cubeCamera;r.material=n,s.renderTarget=e,s.activeMipmapLevel=t;let o=e.width>>t;e.viewport.set(0,0,o,o),s.update(this._renderer,r),e.viewport.set(0,0,e.width,e.height)}_textureToCubemap(e){let t;e.mapping===bs||e.mapping===So?(this._cubemapMaterial===null&&(this._cubemapMaterial=jx()),t=this._cubemapMaterial,t.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):(this._equirectMaterial===null&&(this._equirectMaterial=Jx()),t=this._equirectMaterial),t.uniforms.envMap.value=e,this._renderCube(this._getSourceTarget(),0,t)}_applyPMREM(e){this._ggxMaterial===null&&(this._ggxMaterial=sA(),this._integrationMaterial=oA());let t=this._cubeSize,n=e.texture.mipmaps.length-1,r=this._ggxMaterial.uniforms;r.envMap.value=this._sourceTarget.texture;let s=this._integrationMaterial.uniforms;s.envMap.value=this._sourceTarget.texture,s.sourceLod.value=Math.log2(t/by);for(let o=0;o<=n;o++){let a=i.lodToRoughness(o,n);if(o>n-nA)s.roughness.value=a,this._renderCube(e,o,this._integrationMaterial);else{let l=a>0?Math.log2(t)+.5*Math.log2(6/(yy*Math.pow(a,4)))+.5:0;r.roughness.value=a,r.lodBias.value=l,this._renderCube(e,o,this._ggxMaterial)}}}_blur(e,t){this._blurMaterial===null&&(this._blurMaterial=aA());let n=this._blurMaterial,r=n.uniforms,s=this._sourceTarget;r.sigma.value=Math.min(t,Math.PI)/Math.SQRT2,r.envMap.value=s.texture,this._renderCube(e,0,n),r.envMap.value=e.texture,this._renderCube(s,0,n)}};function Zx(i,e,t){return new il(i,{minFilter:Nn,generateMipmaps:e,type:li,colorSpace:Sn,depthBuffer:t})}function rl(i,e,t){return new Si({name:i,uniforms:e,vertexShader:tt.cube_vert,fragmentShader:t,side:un,blending:xs,depthTest:!1,depthWrite:!1})}function sA(){return rl("PMREMGGXConvolution",{envMap:{value:null},roughness:{value:0},lodBias:{value:0}},` - #define GGX_SAMPLES ${xy}u + #define GGX_SAMPLES ${yy}u varying vec3 vWorldDirection; @@ -3940,7 +3940,7 @@ void main() { gl_FragColor = vec4( prefilteredColor / totalWeight, 1.0 ); } - `)}function rA(){return il("PMREMGGXIntegration",{envMap:{value:null},roughness:{value:0},sourceLod:{value:0},sourceSize:{value:yy}},` + `)}function oA(){return rl("PMREMGGXIntegration",{envMap:{value:null},roughness:{value:0},sourceLod:{value:0},sourceSize:{value:by}},` varying vec3 vWorldDirection; @@ -3993,9 +3993,9 @@ void main() { gl_FragColor = vec4( prefilteredColor / totalWeight, 1.0 ); } - `)}function sA(){return il("PMREMSphericalGaussianBlur",{envMap:{value:null},sigma:{value:0}},` + `)}function aA(){return rl("PMREMSphericalGaussianBlur",{envMap:{value:null},sigma:{value:0}},` - #define SAMPLES ${QT} + #define SAMPLES ${tA} #define GOLDEN_ANGLE 2.39996322973 varying vec3 vWorldDirection; @@ -4041,7 +4041,7 @@ void main() { gl_FragColor = vec4( accumColor / accumWeight, 1.0 ); } - `)}function Zx(){return il("PMREMEquirectangularToCubemap",{envMap:{value:null}},` + `)}function Jx(){return rl("PMREMEquirectangularToCubemap",{envMap:{value:null}},` varying vec3 vWorldDirection; @@ -4063,7 +4063,7 @@ void main() { gl_FragColor = vec4( color * 0.25, 1.0 ); } - `)}function Jx(){return il("PMREMCubemapToCubemap",{envMap:{value:null},flipEnvMap:{value:-1}},` + `)}function jx(){return rl("PMREMCubemapToCubemap",{envMap:{value:null},flipEnvMap:{value:-1}},` varying vec3 vWorldDirection; @@ -4075,7 +4075,7 @@ void main() { gl_FragColor = vec4( textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ).rgb, 1.0 ); } - `)}function oA(i){let e=new WeakMap,t=new WeakMap,n=null;function r(f,d=!1){return f==null?null:d?o(f):s(f)}function s(f){if(f&&f.isTexture){let d=f.mapping;if(d===Kc||d===Zc)if(e.has(f)){let p=e.get(f).texture;return a(p,f.mapping)}else{let p=f.image;if(p&&p.height>0){let x=new nl(p.height);return x.fromEquirectangularTexture(i,f),e.set(f,x),f.addEventListener("dispose",c),a(x.texture,f.mapping)}else return null}}return f}function o(f){if(f&&f.isTexture&&f.isPMREMTexture!==!0){let d=f.mapping,p=d===Kc||d===Zc,x=d===bs||d===So;if(p||x){let m=t.get(f),g=m!==void 0?m.texture.pmremVersion:0;if(f.isRenderTargetTexture&&f.pmremVersion!==g)return n===null&&(n=new Ro(i)),m=p?n.fromEquirectangular(f,m):n.fromCubemap(f,m),m.texture.pmremVersion=f.pmremVersion,t.set(f,m),m.texture;if(m!==void 0)return m.texture;{let y=f.image;return p&&y&&y.height>0||x&&y&&l(y)?(n===null&&(n=new Ro(i)),m=p?n.fromEquirectangular(f):n.fromCubemap(f),m.texture.pmremVersion=f.pmremVersion,t.set(f,m),f.addEventListener("dispose",u),m.texture):null}}}return f}function a(f,d){return d===Kc?f.mapping=bs:d===Zc&&(f.mapping=So),f}function l(f){let d=0,p=6;for(let x=0;xdelete r[p]);function a(p){l(p.target)}function l(p){p.index!==null&&e.remove(p.index);for(let m in p.attributes)e.remove(p.attributes[m]);p.removeEventListener("dispose",a),delete r[p.id],o.unregister(p);let x=s.get(p);x&&(e.remove(x),s.delete(p)),n.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,t.memory.geometries--}function c(p,x){return r[x.id]!==void 0||(x.addEventListener("dispose",a),r[x.id]=new WeakRef(x),o.register(x,x.id,x),t.memory.geometries++),x}function u(p){let x=p.attributes;for(let m in x)e.update(x[m],i.ARRAY_BUFFER)}function h(p){let x=p.index,m=p.attributes.position,g=0;if(m===void 0)return;let y=x!==null?x.array.length:m.array.length/3-1,_=m.count>=65535?us:Ma,b=new _(Math.ceil(y/3)*6,1),M=b.array;if(x!==null){let v=x.array;g=x.version;for(let w=0,P=0;we.maxTextureSize&&(M=Math.ceil(b/e.maxTextureSize),b=e.maxTextureSize);let S=new Float32Array(b*M*4*h),v=new _a(S,b,M,h);v.type=Gn,v.needsUpdate=!0;let w=_*4;for(let T=0;T0){let x=new il(p.height);return x.fromEquirectangularTexture(i,f),e.set(f,x),f.addEventListener("dispose",c),a(x.texture,f.mapping)}else return null}}return f}function o(f){if(f&&f.isTexture&&f.isPMREMTexture!==!0){let d=f.mapping,p=d===Zc||d===Jc,x=d===bs||d===So;if(p||x){let m=t.get(f),g=m!==void 0?m.texture.pmremVersion:0;if(f.isRenderTargetTexture&&f.pmremVersion!==g)return n===null&&(n=new Ro(i)),m=p?n.fromEquirectangular(f,m):n.fromCubemap(f,m),m.texture.pmremVersion=f.pmremVersion,t.set(f,m),m.texture;if(m!==void 0)return m.texture;{let y=f.image;return p&&y&&y.height>0||x&&y&&l(y)?(n===null&&(n=new Ro(i)),m=p?n.fromEquirectangular(f):n.fromCubemap(f),m.texture.pmremVersion=f.pmremVersion,t.set(f,m),f.addEventListener("dispose",u),m.texture):null}}}return f}function a(f,d){return d===Zc?f.mapping=bs:d===Jc&&(f.mapping=So),f}function l(f){let d=0,p=6;for(let x=0;xdelete r[p]);function a(p){l(p.target)}function l(p){p.index!==null&&e.remove(p.index);for(let m in p.attributes)e.remove(p.attributes[m]);p.removeEventListener("dispose",a),delete r[p.id],o.unregister(p);let x=s.get(p);x&&(e.remove(x),s.delete(p)),n.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,t.memory.geometries--}function c(p,x){return r[x.id]!==void 0||(x.addEventListener("dispose",a),r[x.id]=new WeakRef(x),o.register(x,x.id,x),t.memory.geometries++),x}function u(p){let x=p.attributes;for(let m in x)e.update(x[m],i.ARRAY_BUFFER)}function h(p){let x=p.index,m=p.attributes.position,g=0;if(m===void 0)return;let y=x!==null?x.array.length:m.array.length/3-1,_=m.count>=65535?us:Sa,b=new _(Math.ceil(y/3)*6,1),M=b.array;if(x!==null){let v=x.array;g=x.version;for(let w=0,P=0;we.maxTextureSize&&(M=Math.ceil(b/e.maxTextureSize),b=e.maxTextureSize);let S=new Float32Array(b*M*4*h),v=new Ma(S,b,M,h);v.type=Gn,v.needsUpdate=!0;let w=_*4;for(let T=0;T0&&_[0].isRenderPass===!0;let S=o.width,v=o.height;_.length>0&&a===null&&(a=new Tn(S,v,{type:li,depthBuffer:!1,stencilBuffer:!1}),l=new Tn(S,v,{type:li,depthBuffer:!1,stencilBuffer:!1}));let w=r===!0&&_.some(P=>P.needsDepthTexture===!0);w!==(o.depthTexture!==null)&&(w===!0&&c===null&&(c=new nr(S,v),s===!0&&(c.format=hr,c.type=vs)),o.dispose(),o.depthTexture=w?c:null,o.resolveDepthBuffer=w,o.storeMultisampledDepthBuffer=w);for(let P=0;P<_.length;P++){let T=_[P];T.setSize&&T.setSize(S,v),w&&T.needsDepthTexture===!0&&T.setDepthTexture&&T.setDepthTexture(c)}},this.begin=function(M,S){if(m||M.toneMapping===Ri&&_.length===0)return!1;if(y=S,S!==null){let v=S.width,w=S.height;(o.width!==v||o.height!==w)&&this.setSize(v,w)}return b===!1&&M.setRenderTarget(o),g=M.toneMapping,M.toneMapping=Ri,!0},this.hasRenderPass=function(){return b},this.end=function(M,S){M.toneMapping=g,m=!0;let v=o,w=a;for(let P=0;P<_.length;P++){let T=_[P];T.enabled!==!1&&(T.render(M,w,v,S),T.needsSwap!==!1&&(v=w,w=w===a?l:a))}if(p!==M.outputColorSpace||x!==M.toneMapping){p=M.outputColorSpace,x=M.toneMapping,h.defines={},it.getTransfer(p)===Mt&&(h.defines.SRGB_TRANSFER="");let P=dA[x];P&&(h.defines[P]=""),h.needsUpdate=!0}h.uniforms.tDiffuse.value=v.texture,M.setRenderTarget(y),M.render(f,d),y=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){o.dispose(),a!==null&&a.dispose(),l!==null&&l.dispose(),u.dispose(),h.dispose()}}var by=new Kt,vy=new nr(1,1),_y=new Ea(1),My=new _a,Sy=new Lc,wy=new Aa,jx=[],Qx=[],ey=new Float32Array(16),ty=new Float32Array(9),ny=new Float32Array(4);function Co(i,e,t){let n=i[0];if(n<=0||n>0)return i;let r=e*t,s=jx[r];if(s===void 0&&(s=new Float32Array(r),jx[r]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(s,a)}return s}function jt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t0&&(this.seq=r.concat(s))}setValue(e,t,n,r){let s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,o=t.length;s!==o;++s){let a=t[s],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,s=e.length;r!==s;++r){let o=e[r];o.id in t&&n.push(o)}return n}};function ry(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var nE=37297,iE=0;function rE(i,e){let t=i.split(` + }`,depthTest:!1,depthWrite:!1}),f=new Se(u,h),d=new Vn(-1,1,1,-1,0,1),p=null,x=null,m=!1,g,y=null,_=[],b=!1;this.setSize=function(M,S){o.setSize(M,S),a!==null&&a.setSize(M,S),l!==null&&l.setSize(M,S);for(let v=0;v<_.length;v++){let w=_[v];w.setSize&&w.setSize(M,S)}},this.setEffects=function(M){_=M,b=_.length>0&&_[0].isRenderPass===!0;let S=o.width,v=o.height;_.length>0&&a===null&&(a=new Tn(S,v,{type:li,depthBuffer:!1,stencilBuffer:!1}),l=new Tn(S,v,{type:li,depthBuffer:!1,stencilBuffer:!1}));let w=r===!0&&_.some(P=>P.needsDepthTexture===!0);w!==(o.depthTexture!==null)&&(w===!0&&c===null&&(c=new nr(S,v),s===!0&&(c.format=hr,c.type=vs)),o.dispose(),o.depthTexture=w?c:null,o.resolveDepthBuffer=w,o.storeMultisampledDepthBuffer=w);for(let P=0;P<_.length;P++){let T=_[P];T.setSize&&T.setSize(S,v),w&&T.needsDepthTexture===!0&&T.setDepthTexture&&T.setDepthTexture(c)}},this.begin=function(M,S){if(m||M.toneMapping===Ri&&_.length===0)return!1;if(y=S,S!==null){let v=S.width,w=S.height;(o.width!==v||o.height!==w)&&this.setSize(v,w)}return b===!1&&M.setRenderTarget(o),g=M.toneMapping,M.toneMapping=Ri,!0},this.hasRenderPass=function(){return b},this.end=function(M,S){M.toneMapping=g,m=!0;let v=o,w=a;for(let P=0;P<_.length;P++){let T=_[P];T.enabled!==!1&&(T.render(M,w,v,S),T.needsSwap!==!1&&(v=w,w=w===a?l:a))}if(p!==M.outputColorSpace||x!==M.toneMapping){p=M.outputColorSpace,x=M.toneMapping,h.defines={},it.getTransfer(p)===Mt&&(h.defines.SRGB_TRANSFER="");let P=mA[x];P&&(h.defines[P]=""),h.needsUpdate=!0}h.uniforms.tDiffuse.value=v.texture,M.setRenderTarget(y),M.render(f,d),y=null,m=!1},this.isCompositing=function(){return m},this.dispose=function(){o.dispose(),a!==null&&a.dispose(),l!==null&&l.dispose(),u.dispose(),h.dispose()}}var vy=new Kt,_y=new nr(1,1),My=new Ra(1),Sy=new Ma,wy=new Fc,Ty=new Ea,Qx=[],ey=[],ty=new Float32Array(16),ny=new Float32Array(9),iy=new Float32Array(4);function Co(i,e,t){let n=i[0];if(n<=0||n>0)return i;let r=e*t,s=Qx[r];if(s===void 0&&(s=new Float32Array(r),Qx[r]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(s,a)}return s}function jt(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t0&&(this.seq=r.concat(s))}setValue(e,t,n,r){let s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,o=t.length;s!==o;++s){let a=t[s],l=n[a.id];l.needsUpdate!==!1&&a.setValue(e,l.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,s=e.length;r!==s;++r){let o=e[r];o.id in t&&n.push(o)}return n}};function sy(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var rE=37297,sE=0;function oE(i,e){let t=i.split(` `),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o":" "} ${a}: ${t[o]}`)}return n.join(` -`)}var sy=new Xe;function sE(i){it._getMatrix(sy,it.workingColorSpace,i);let e=`mat3( ${sy.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(i)){case ba:return[e,"LinearTransferOETF"];case Mt:return[e,"sRGBTransferOETF"];default:return Oe("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function oy(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),s=(i.getShaderInfoLog(e)||"").trim();if(n&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return t.toUpperCase()+` +`)}var oy=new Xe;function aE(i){it._getMatrix(oy,it.workingColorSpace,i);let e=`mat3( ${oy.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(i)){case va:return[e,"LinearTransferOETF"];case Mt:return[e,"sRGBTransferOETF"];default:return Oe("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function ay(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),s=(i.getShaderInfoLog(e)||"").trim();if(n&&s==="")return"";let o=/ERROR: 0:(\d+)/.exec(s);if(o){let a=parseInt(o[1]);return t.toUpperCase()+` `+s+` -`+rE(i.getShaderSource(e),a)}else return s}function oE(i,e){let t=sE(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( ${t[0]} * value.rgb, value.a ) );`,"}"].join(` -`)}var aE={[id]:"Linear",[rd]:"Reinhard",[sd]:"Cineon",[od]:"ACESFilmic",[ld]:"AgX",[cd]:"Neutral",[ad]:"Custom"};function lE(i,e){let t=aE[e];return t===void 0?(Oe("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var Du=new D;function cE(){it.getLuminanceCoefficients(Du);let i=Du.x.toFixed(4),e=Du.y.toFixed(4),t=Du.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` -`)}function uE(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(tl).join(` -`)}function hE(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(` -`)}function fE(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r/gm;function Gd(i){return i.replace(dE,pE)}function pE(i,e){let t=tt[e];if(t===void 0)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">");return Gd(t)}var mE=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function cy(i){return i.replace(mE,gE)}function gE(i,e,t,n){let r="";for(let s=parseInt(e);s/gm;function Hd(i){return i.replace(mE,gE)}function gE(i,e){let t=tt[e];if(t===void 0)throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">");return Hd(t)}var xE=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function uy(i){return i.replace(xE,yE)}function yE(i,e,t,n){let r="";for(let s=parseInt(e);s0&&(x+=` -`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,d].filter(tl).join(` +`),m=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,d].filter(nl).join(` `),m.length>0&&(m+=` -`)):(x=[uy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,d,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.diffuseRoughnessMap?"#define USE_DIFFUSE_ROUGHNESSMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.diffuseRoughnessMapUv?"#define DIFFUSE_ROUGHNESSMAP_UV "+t.diffuseRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` -`].filter(tl).join(` -`),m=[uy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,d,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",t.envMapPMREM?"#define ENVMAP_MAX_LOD "+t.envMapMaxLod+".0":"",t.envMapPMREM?"#define ENVMAP_SIZE "+t.envMapSize+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.diffuseRoughness?"#define USE_DIFFUSE_ROUGHNESS":"",t.diffuseRoughnessMap?"#define USE_DIFFUSE_ROUGHNESSMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.retroreflection?"#define USE_RETROREFLECTION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Ri?"#define TONE_MAPPING":"",t.toneMapping!==Ri?tt.tonemapping_pars_fragment:"",t.toneMapping!==Ri?lE("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",tt.colorspace_pars_fragment,oE("linearToOutputTexel",t.outputColorSpace),cE(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` -`].filter(tl).join(` -`)),o=Gd(o),o=ay(o,t),o=ly(o,t),a=Gd(a),a=ay(a,t),a=ly(a,t),o=cy(o),a=cy(a),t.isRawShaderMaterial!==!0&&(g=`#version 300 es +`)):(x=[hy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,d,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.diffuseRoughnessMap?"#define USE_DIFFUSE_ROUGHNESSMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.diffuseRoughnessMapUv?"#define DIFFUSE_ROUGHNESSMAP_UV "+t.diffuseRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(nl).join(` +`),m=[hy(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,d,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",t.envMapPMREM?"#define ENVMAP_MAX_LOD "+t.envMapMaxLod+".0":"",t.envMapPMREM?"#define ENVMAP_SIZE "+t.envMapSize+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.diffuseRoughness?"#define USE_DIFFUSE_ROUGHNESS":"",t.diffuseRoughnessMap?"#define USE_DIFFUSE_ROUGHNESSMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.retroreflection?"#define USE_RETROREFLECTION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Ri?"#define TONE_MAPPING":"",t.toneMapping!==Ri?tt.tonemapping_pars_fragment:"",t.toneMapping!==Ri?uE("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",tt.colorspace_pars_fragment,lE("linearToOutputTexel",t.outputColorSpace),hE(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(nl).join(` +`)),o=Hd(o),o=ly(o,t),o=cy(o,t),a=Hd(a),a=ly(a,t),a=cy(a,t),o=uy(o),a=uy(a),t.isRawShaderMaterial!==!0&&(g=`#version 300 es `,x=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` -`+x,m=["#define varying in",t.glslVersion===Sd?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Sd?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`+x,m=["#define varying in",t.glslVersion===wd?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===wd?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` `)+` -`+m);let y=g+x+o,_=g+m+a,b=ry(r,r.VERTEX_SHADER,y),M=ry(r,r.FRAGMENT_SHADER,_);r.attachShader(p,b),r.attachShader(p,M),t.index0AttributeName!==void 0?r.bindAttribLocation(p,0,t.index0AttributeName):t.hasPositionAttribute===!0&&r.bindAttribLocation(p,0,"position"),r.linkProgram(p);function S(T){if(i.debug.checkShaderErrors){let R=r.getProgramInfoLog(p)||"",L=r.getShaderInfoLog(b)||"",k=r.getShaderInfoLog(M)||"",C=R.trim(),I=L.trim(),O=k.trim(),F=!0,H=!0;if(r.getProgramParameter(p,r.LINK_STATUS)===!1)if(F=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,p,b,M);else{let U=oy(r,b,"vertex"),X=oy(r,M,"fragment");We("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(p,r.VALIDATE_STATUS)+` +`+m);let y=g+x+o,_=g+m+a,b=sy(r,r.VERTEX_SHADER,y),M=sy(r,r.FRAGMENT_SHADER,_);r.attachShader(p,b),r.attachShader(p,M),t.index0AttributeName!==void 0?r.bindAttribLocation(p,0,t.index0AttributeName):t.hasPositionAttribute===!0&&r.bindAttribLocation(p,0,"position"),r.linkProgram(p);function S(T){if(i.debug.checkShaderErrors){let R=r.getProgramInfoLog(p)||"",L=r.getShaderInfoLog(b)||"",U=r.getShaderInfoLog(M)||"",C=R.trim(),I=L.trim(),O=U.trim(),F=!0,H=!0;if(r.getProgramParameter(p,r.LINK_STATUS)===!1)if(F=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,p,b,M);else{let k=ay(r,b,"vertex"),X=ay(r,M,"fragment");We("WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(p,r.VALIDATE_STATUS)+` Material Name: `+T.name+` Material Type: `+T.type+` Program Info Log: `+C+` -`+U+` -`+X)}else C!==""?Oe("WebGLProgram: Program Info Log:",C):(I===""||O==="")&&(H=!1);H&&(T.diagnostics={runnable:F,programLog:C,vertexShader:{log:I,prefix:x},fragmentShader:{log:O,prefix:m}})}r.deleteShader(b),r.deleteShader(M),v=new Eo(r,p),w=fE(r,p)}let v;this.getUniforms=function(){return v===void 0&&S(this),v};let w;this.getAttributes=function(){return w===void 0&&S(this),w};let P=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=r.getProgramParameter(p,nE)),P},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(p),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=iE++,this.cacheKey=e,this.usedTimes=1,this.program=p,this.vertexShader=b,this.fragmentShader=M,this}var wE=0,Hd=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(n)===!1&&(r.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Wd(e),t.set(e,n)),n}},Wd=class{constructor(e){this.id=wE++,this.code=e,this.usedTimes=0}};function TE(i){return i===Br||i===Za||i===Ja}function AE(i,e,t,n,r,s){let o=new po,a=new Hd,l=new Set,c=[],u=new Map,h=n.logarithmicDepthBuffer,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function d(v){return l.add(v),v===0?"uv":`uv${v}`}function p(v,w,P,T,R,L){let k=T.fog,C=R.geometry,I=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?T.environment:null,O=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,F=e.get(v.envMap||I,O),H=f[v.type],U=n.precision;v.precision!==null&&(U=n.getMaxPrecision(v.precision),U!==v.precision&&Oe("WebGLProgram.getParameters:",v.precision,"not supported, using",U,"instead."));let X=C.morphAttributes.position||C.morphAttributes.normal||C.morphAttributes.color,V=X!==void 0?X.length:0,re=0;C.morphAttributes.position!==void 0&&(re=1),C.morphAttributes.normal!==void 0&&(re=2),C.morphAttributes.color!==void 0&&(re=3);let ye,Y,Q,se;if(H){let ve=Ii[H];ye=ve.vertexShader,Y=ve.fragmentShader}else{ye=v.vertexShader,Y=v.fragmentShader;let ve=a.getVertexShaderStage(v),St=a.getFragmentShaderStage(v);a.update(v,ve,St),Q=ve.id,se=St.id}let we=i.getRenderTarget(),le=i.state.buffers.depth.getReversed(),Ne=R.isInstancedMesh===!0,at=R.isBatchedMesh===!0,Ae=!!v.map,ft=!!v.matcap,yt=!!F,nt=yt&&F.isPMREMTexture===!0,Yt=!!v.aoMap,Bt=!!v.lightMap,on=!!v.bumpMap&&v.wireframe===!1,Nt=!!v.normalMap,xi=!!v.displacementMap,en=!!v.emissiveMap,Wn=!!v.metalnessMap,Xn=!!v.roughnessMap,Yn=v.anisotropy>0,G=v.clearcoat>0,qn=v.diffuseRoughness>0,Pt=v.dispersion>0,It=v.retroreflectivity>0,be=v.iridescence>0,Zt=v.sheen>0,Ve=v.transmission>0,qe=Yn&&!!v.anisotropyMap,N=G&&!!v.clearcoatMap,A=G&&!!v.clearcoatNormalMap,K=G&&!!v.clearcoatRoughnessMap,oe=qn&&!!v.diffuseRoughnessMap,ie=be&&!!v.iridescenceMap,he=be&&!!v.iridescenceThicknessMap,ge=Zt&&!!v.sheenColorMap,ee=Zt&&!!v.sheenRoughnessMap,te=!!v.specularMap,de=!!v.specularColorMap,B=!!v.specularIntensityMap,ne=Ve&&!!v.transmissionMap,j=Ve&&!!v.thicknessMap,pe=!!v.gradientMap,ce=!!v.alphaMap,fe=v.alphaTest>0,De=!!v.alphaHash,Qe=!!v.extensions,ae=Ri;v.toneMapped&&(we===null||we.isXRRenderTarget===!0)&&(ae=i.toneMapping);let ke=nt?F.isCompressedCubeTexture?F.image[0].mipmaps:F.mipmaps:null,je={shaderID:H,shaderType:v.type,shaderName:v.name,vertexShader:ye,fragmentShader:Y,defines:v.defines,customVertexShaderID:Q,customFragmentShaderID:se,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:U,batching:at,batchingColor:at&&R._colorsTexture!==null,instancing:Ne,instancingColor:Ne&&R.instanceColor!==null,instancingMorph:Ne&&R.morphTexture!==null,outputColorSpace:we===null?i.outputColorSpace:we.isXRRenderTarget===!0?we.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Ae,matcap:ft,envMap:yt,envMapMode:yt&&F.mapping,envMapPMREM:nt,envMapMaxLod:nt?ke.length-1:null,envMapSize:nt?ke[0].width:null,aoMap:Yt,lightMap:Bt,bumpMap:on,normalMap:Nt,displacementMap:xi,emissiveMap:en,normalMapObjectSpace:Nt&&v.normalMapType===Rx,normalMapTangentSpace:Nt&&v.normalMapType===Qa,packedNormalMap:Nt&&v.normalMapType===Qa&&TE(v.normalMap.format),metalnessMap:Wn,roughnessMap:Xn,anisotropy:Yn,anisotropyMap:qe,clearcoat:G,clearcoatMap:N,clearcoatNormalMap:A,clearcoatRoughnessMap:K,diffuseRoughness:qn,diffuseRoughnessMap:oe,dispersion:Pt,retroreflection:It,iridescence:be,iridescenceMap:ie,iridescenceThicknessMap:he,sheen:Zt,sheenColorMap:ge,sheenRoughnessMap:ee,specularMap:te,specularColorMap:de,specularIntensityMap:B,transmission:Ve,transmissionMap:ne,thicknessMap:j,gradientMap:pe,opaque:v.transparent===!1&&v.blending===Ei&&v.alphaToCoverage===!1,alphaMap:ce,alphaTest:fe,alphaHash:De,combine:v.combine,mapUv:Ae&&d(v.map.channel),aoMapUv:Yt&&d(v.aoMap.channel),lightMapUv:Bt&&d(v.lightMap.channel),bumpMapUv:on&&d(v.bumpMap.channel),normalMapUv:Nt&&d(v.normalMap.channel),displacementMapUv:xi&&d(v.displacementMap.channel),emissiveMapUv:en&&d(v.emissiveMap.channel),metalnessMapUv:Wn&&d(v.metalnessMap.channel),roughnessMapUv:Xn&&d(v.roughnessMap.channel),anisotropyMapUv:qe&&d(v.anisotropyMap.channel),clearcoatMapUv:N&&d(v.clearcoatMap.channel),clearcoatNormalMapUv:A&&d(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:K&&d(v.clearcoatRoughnessMap.channel),diffuseRoughnessMapUv:oe&&d(v.diffuseRoughnessMap.channel),iridescenceMapUv:ie&&d(v.iridescenceMap.channel),iridescenceThicknessMapUv:he&&d(v.iridescenceThicknessMap.channel),sheenColorMapUv:ge&&d(v.sheenColorMap.channel),sheenRoughnessMapUv:ee&&d(v.sheenRoughnessMap.channel),specularMapUv:te&&d(v.specularMap.channel),specularColorMapUv:de&&d(v.specularColorMap.channel),specularIntensityMapUv:B&&d(v.specularIntensityMap.channel),transmissionMapUv:ne&&d(v.transmissionMap.channel),thicknessMapUv:j&&d(v.thicknessMap.channel),alphaMapUv:ce&&d(v.alphaMap.channel),vertexTangents:!!C.attributes.tangent&&(Nt||Yn),vertexNormals:!!C.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!C.attributes.color&&C.attributes.color.itemSize===4,pointsUvs:R.isPoints===!0&&!!C.attributes.uv&&(Ae||ce),fog:!!k,useFog:v.fog===!0,fogExp2:!!k&&k.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||C.attributes.normal===void 0&&Nt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:le,skinning:R.isSkinnedMesh===!0,hasPositionAttribute:C.attributes.position!==void 0,morphTargets:C.morphAttributes.position!==void 0,morphNormals:C.morphAttributes.normal!==void 0,morphColors:C.morphAttributes.color!==void 0,morphTargetsCount:V,morphTextureStride:re,numSunLights:w.sun.length,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numSunLightShadows:w.sunShadowMap.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numLightProbeGrids:L.filter(ve=>ve.texture!==null).length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:ae,decodeVideoTexture:Ae&&v.map.isVideoTexture===!0&&it.getTransfer(v.map.colorSpace)===Mt,decodeVideoTextureEmissive:en&&v.emissiveMap.isVideoTexture===!0&&it.getTransfer(v.emissiveMap.colorSpace)===Mt,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===ht,flipSided:v.side===un,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Qe&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Qe&&v.extensions.multiDraw===!0||at)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return je.vertexUv1s=l.has(1),je.vertexUv2s=l.has(2),je.vertexUv3s=l.has(3),l.clear(),je}function x(v){let w=[];if(v.shaderID?w.push(v.shaderID):(w.push(v.customVertexShaderID),w.push(v.customFragmentShaderID)),v.defines!==void 0)for(let P in v.defines)w.push(P),w.push(v.defines[P]);return v.isRawShaderMaterial===!1&&(m(w,v),g(w,v),w.push(i.outputColorSpace)),w.push(v.customProgramCacheKey),w.join()}function m(v,w){v.push(w.precision),v.push(w.outputColorSpace),v.push(w.envMapMode),v.push(w.envMapPMREM),v.push(w.envMapMaxLod),v.push(w.envMapSize),v.push(w.mapUv),v.push(w.alphaMapUv),v.push(w.lightMapUv),v.push(w.aoMapUv),v.push(w.bumpMapUv),v.push(w.normalMapUv),v.push(w.displacementMapUv),v.push(w.emissiveMapUv),v.push(w.metalnessMapUv),v.push(w.roughnessMapUv),v.push(w.anisotropyMapUv),v.push(w.clearcoatMapUv),v.push(w.clearcoatNormalMapUv),v.push(w.clearcoatRoughnessMapUv),v.push(w.diffuseRoughnessMapUv),v.push(w.iridescenceMapUv),v.push(w.iridescenceThicknessMapUv),v.push(w.sheenColorMapUv),v.push(w.sheenRoughnessMapUv),v.push(w.specularMapUv),v.push(w.specularColorMapUv),v.push(w.specularIntensityMapUv),v.push(w.transmissionMapUv),v.push(w.thicknessMapUv),v.push(w.combine),v.push(w.fogExp2),v.push(w.sizeAttenuation),v.push(w.morphTargetsCount),v.push(w.numSunLights),v.push(w.numDirLights),v.push(w.numPointLights),v.push(w.numSpotLights),v.push(w.numSpotLightMaps),v.push(w.numHemiLights),v.push(w.numRectAreaLights),v.push(w.numSunLightShadows),v.push(w.numDirLightShadows),v.push(w.numPointLightShadows),v.push(w.numSpotLightShadows),v.push(w.numSpotLightShadowsWithMaps),v.push(w.numLightProbes),v.push(w.numLightProbeGrids),v.push(w.shadowMapType),v.push(w.toneMapping),v.push(w.numClippingPlanes),v.push(w.numClipIntersection),v.push(w.depthPacking)}function g(v,w){o.disableAll(),w.instancing&&o.enable(0),w.instancingColor&&o.enable(1),w.instancingMorph&&o.enable(2),w.matcap&&o.enable(3),w.envMap&&o.enable(4),w.normalMapObjectSpace&&o.enable(5),w.normalMapTangentSpace&&o.enable(6),w.clearcoat&&o.enable(7),w.iridescence&&o.enable(8),w.alphaTest&&o.enable(9),w.vertexColors&&o.enable(10),w.vertexAlphas&&o.enable(11),w.vertexUv1s&&o.enable(12),w.vertexUv2s&&o.enable(13),w.vertexUv3s&&o.enable(14),w.vertexTangents&&o.enable(15),w.anisotropy&&o.enable(16),w.alphaHash&&o.enable(17),w.batching&&o.enable(18),w.dispersion&&o.enable(19),w.retroreflection&&o.enable(24),w.diffuseRoughness&&o.enable(25),w.batchingColor&&o.enable(20),w.gradientMap&&o.enable(21),w.packedNormalMap&&o.enable(22),w.vertexNormals&&o.enable(23),v.push(o.mask),o.disableAll(),w.fog&&o.enable(0),w.useFog&&o.enable(1),w.flatShading&&o.enable(2),w.logarithmicDepthBuffer&&o.enable(3),w.reversedDepthBuffer&&o.enable(4),w.skinning&&o.enable(5),w.morphTargets&&o.enable(6),w.morphNormals&&o.enable(7),w.morphColors&&o.enable(8),w.premultipliedAlpha&&o.enable(9),w.shadowMapEnabled&&o.enable(10),w.doubleSided&&o.enable(11),w.flipSided&&o.enable(12),w.useDepthPacking&&o.enable(13),w.dithering&&o.enable(14),w.transmission&&o.enable(15),w.sheen&&o.enable(16),w.opaque&&o.enable(17),w.pointsUvs&&o.enable(18),w.decodeVideoTexture&&o.enable(19),w.decodeVideoTextureEmissive&&o.enable(20),w.alphaToCoverage&&o.enable(21),w.numLightProbeGrids>0&&o.enable(22),w.hasPositionAttribute&&o.enable(23),v.push(o.mask)}function y(v){let w=f[v.type],P;if(w){let T=Ii[w];P=Xx.clone(T.uniforms)}else P=v.uniforms;return P}function _(v,w){let P=u.get(w);return P!==void 0?++P.usedTimes:(P=new SE(i,w,v,r),c.push(P),u.set(w,P)),P}function b(v){if(--v.usedTimes===0){let w=c.indexOf(v);c[w]=c[c.length-1],c.pop(),u.delete(v.cacheKey),v.destroy()}}function M(v){a.remove(v)}function S(){a.dispose()}return{getParameters:p,getProgramCacheKey:x,getUniforms:y,acquireProgram:_,releaseProgram:b,releaseShaderCache:M,programs:c,dispose:S}}function EE(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function r(o,a,l){i.get(o)[a]=l}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function RE(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function hy(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function fy(){let i=[],e=0,t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function o(f){let d=0;return f.isInstancedMesh&&(d+=2),f.isSkinnedMesh&&(d+=1),d}function a(f,d,p,x,m,g){let y=i[e];return y===void 0?(y={id:f.id,object:f,geometry:d,material:p,materialVariant:o(f),groupOrder:x,renderOrder:f.renderOrder,z:m,group:g},i[e]=y):(y.id=f.id,y.object=f,y.geometry=d,y.material=p,y.materialVariant=o(f),y.groupOrder=x,y.renderOrder=f.renderOrder,y.z=m,y.group=g),e++,y}function l(f,d,p,x,m,g,y){y.reversedDepth===!0&&(m=-m);let _=a(f,d,p,x,m,g);p.transmission>0?n.push(_):p.transparent===!0?r.push(_):t.push(_)}function c(f,d,p,x,m,g){let y=a(f,d,p,x,m,g);p.transmission>0?n.unshift(y):p.transparent===!0?r.unshift(y):t.unshift(y)}function u(f,d){t.length>1&&t.sort(f||RE),n.length>1&&n.sort(d||hy),r.length>1&&r.sort(d||hy)}function h(){for(let f=e,d=i.length;f=s.length?(o=new fy,s.push(o)):o=s[r],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function PE(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new D,color:new W};break;case"SpotLight":t={position:new D,direction:new D,color:new W,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new W,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new W,groundColor:new W};break;case"RectAreaLight":t={color:new W,position:new D,halfWidth:new D,halfHeight:new D};break}return i[e.id]=t,t}}}function IE(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ue,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var LE=0;function FE(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function NE(i){let e=new PE,t=IE(),n={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new D);let r=new D,s=new ze,o=new ze;function a(c){let u=0,h=0,f=0;for(let L=0;L<9;L++)n.probe[L].set(0,0,0);let d=0,p=0,x=0,m=0,g=0,y=0,_=0,b=0,M=0,S=0,v=0,w=0,P=0,T=0;c.sort(FE);for(let L=0,k=c.length;L0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=_e.LTC_FLOAT_1,n.rectAreaLTC2=_e.LTC_FLOAT_2):(n.rectAreaLTC1=_e.LTC_HALF_1,n.rectAreaLTC2=_e.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=f;let R=n.hash;(R.sunLength!==d||R.directionalLength!==m||R.pointLength!==g||R.spotLength!==y||R.rectAreaLength!==_||R.hemiLength!==b||R.numSunShadows!==p||R.numDirectionalShadows!==M||R.numPointShadows!==S||R.numSpotShadows!==v||R.numSpotMaps!==w||R.numLightProbes!==T)&&(n.sun.length=d,n.directional.length=m,n.spot.length=y,n.rectArea.length=_,n.point.length=g,n.hemi.length=b,n.sunShadow.length=p,n.sunShadowMap.length=p,n.sunShadowMatrix.length=x,n.sunShadowCascade.length=x,n.directionalShadow.length=M,n.directionalShadowMap.length=M,n.directionalShadowMatrix.length=M,n.pointShadow.length=S,n.pointShadowMap.length=S,n.pointShadowMatrix.length=S,n.spotShadow.length=v,n.spotShadowMap.length=v,n.spotLightMatrix.length=v+w-P,n.spotLightMap.length=w,n.numSpotLightShadowsWithMaps=P,n.numLightProbes=T,R.sunLength=d,R.directionalLength=m,R.pointLength=g,R.spotLength=y,R.rectAreaLength=_,R.hemiLength=b,R.numSunShadows=p,R.numDirectionalShadows=M,R.numPointShadows=S,R.numSpotShadows=v,R.numSpotMaps=w,R.numLightProbes=T,n.version=LE++)}function l(c,u){let h=0,f=0,d=0,p=0,x=0,m=0,g=u.matrixWorldInverse;for(let y=0,_=c.length;y<_;y++){let b=c[y];if(b.isSunLight){let M=n.sun[h];M.direction.setFromMatrixPosition(b.matrixWorld),M.direction.transformDirection(g),h++}else if(b.isDirectionalLight){let M=n.directional[f];M.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(g),f++}else if(b.isSpotLight){let M=n.spot[p];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(g),M.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(g),p++}else if(b.isRectAreaLight){let M=n.rectArea[x];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(g),o.identity(),s.copy(b.matrixWorld),s.premultiply(g),o.extractRotation(s),M.halfWidth.set(b.width*.5,0,0),M.halfHeight.set(0,b.height*.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),x++}else if(b.isPointLight){let M=n.point[d];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(g),d++}else if(b.isHemisphereLight){let M=n.hemi[m];M.direction.setFromMatrixPosition(b.matrixWorld),M.direction.transformDirection(g),m++}}}return{setup:a,setupView:l,state:n}}function dy(i){let e=new NE(i),t=[],n=[],r=[];function s(h){u.camera=h,t.length=0,n.length=0,r.length=0}function o(h){h.isLightProbeGrid?r.push(h):t.push(h)}function a(h){n.push(h)}function l(){e.setup(t),r.sort((h,f)=>h.priority-f.priority||h.id-f.id)}function c(h){e.setupView(t,h)}let u={lightsArray:t,shadowsArray:n,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:u,setupLights:l,setupLightsView:c,pushLight:o,pushShadow:a}}function OE(i){let e=new WeakMap;function t(r,s=0){let o=e.get(r),a;return o===void 0?(a=new dy(i),e.set(r,[a])):s>=o.length?(a=new dy(i),o.push(a)):a=o[s],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var DE=`void main() { +`+k+` +`+X)}else C!==""?Oe("WebGLProgram: Program Info Log:",C):(I===""||O==="")&&(H=!1);H&&(T.diagnostics={runnable:F,programLog:C,vertexShader:{log:I,prefix:x},fragmentShader:{log:O,prefix:m}})}r.deleteShader(b),r.deleteShader(M),v=new Eo(r,p),w=pE(r,p)}let v;this.getUniforms=function(){return v===void 0&&S(this),v};let w;this.getAttributes=function(){return w===void 0&&S(this),w};let P=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=r.getProgramParameter(p,rE)),P},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(p),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=sE++,this.cacheKey=e,this.usedTimes=1,this.program=p,this.vertexShader=b,this.fragmentShader=M,this}var AE=0,Wd=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){let r=this._getShaderCacheForMaterial(e);return r.has(t)===!1&&(r.add(t),t.usedTimes++),r.has(n)===!1&&(r.add(n),n.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Xd(e),t.set(e,n)),n}},Xd=class{constructor(e){this.id=AE++,this.code=e,this.usedTimes=0}};function EE(i){return i===Br||i===Ja||i===ja}function RE(i,e,t,n,r,s){let o=new po,a=new Wd,l=new Set,c=[],u=new Map,h=n.logarithmicDepthBuffer,f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function d(v){return l.add(v),v===0?"uv":`uv${v}`}function p(v,w,P,T,R,L){let U=T.fog,C=R.geometry,I=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?T.environment:null,O=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,F=e.get(v.envMap||I,O),H=f[v.type],k=n.precision;v.precision!==null&&(k=n.getMaxPrecision(v.precision),k!==v.precision&&Oe("WebGLProgram.getParameters:",v.precision,"not supported, using",k,"instead."));let X=C.morphAttributes.position||C.morphAttributes.normal||C.morphAttributes.color,V=X!==void 0?X.length:0,re=0;C.morphAttributes.position!==void 0&&(re=1),C.morphAttributes.normal!==void 0&&(re=2),C.morphAttributes.color!==void 0&&(re=3);let ye,Y,Q,se;if(H){let ve=Ii[H];ye=ve.vertexShader,Y=ve.fragmentShader}else{ye=v.vertexShader,Y=v.fragmentShader;let ve=a.getVertexShaderStage(v),St=a.getFragmentShaderStage(v);a.update(v,ve,St),Q=ve.id,se=St.id}let we=i.getRenderTarget(),le=i.state.buffers.depth.getReversed(),Ne=R.isInstancedMesh===!0,at=R.isBatchedMesh===!0,Ae=!!v.map,ft=!!v.matcap,yt=!!F,nt=yt&&F.isPMREMTexture===!0,Yt=!!v.aoMap,Bt=!!v.lightMap,on=!!v.bumpMap&&v.wireframe===!1,Nt=!!v.normalMap,xi=!!v.displacementMap,en=!!v.emissiveMap,Wn=!!v.metalnessMap,Xn=!!v.roughnessMap,Yn=v.anisotropy>0,G=v.clearcoat>0,qn=v.diffuseRoughness>0,Pt=v.dispersion>0,It=v.retroreflectivity>0,be=v.iridescence>0,Zt=v.sheen>0,Ve=v.transmission>0,qe=Yn&&!!v.anisotropyMap,N=G&&!!v.clearcoatMap,A=G&&!!v.clearcoatNormalMap,K=G&&!!v.clearcoatRoughnessMap,oe=qn&&!!v.diffuseRoughnessMap,ie=be&&!!v.iridescenceMap,he=be&&!!v.iridescenceThicknessMap,ge=Zt&&!!v.sheenColorMap,ee=Zt&&!!v.sheenRoughnessMap,te=!!v.specularMap,de=!!v.specularColorMap,B=!!v.specularIntensityMap,ne=Ve&&!!v.transmissionMap,j=Ve&&!!v.thicknessMap,pe=!!v.gradientMap,ce=!!v.alphaMap,fe=v.alphaTest>0,De=!!v.alphaHash,Qe=!!v.extensions,ae=Ri;v.toneMapped&&(we===null||we.isXRRenderTarget===!0)&&(ae=i.toneMapping);let Ue=nt?F.isCompressedCubeTexture?F.image[0].mipmaps:F.mipmaps:null,je={shaderID:H,shaderType:v.type,shaderName:v.name,vertexShader:ye,fragmentShader:Y,defines:v.defines,customVertexShaderID:Q,customFragmentShaderID:se,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:k,batching:at,batchingColor:at&&R._colorsTexture!==null,instancing:Ne,instancingColor:Ne&&R.instanceColor!==null,instancingMorph:Ne&&R.morphTexture!==null,outputColorSpace:we===null?i.outputColorSpace:we.isXRRenderTarget===!0?we.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Ae,matcap:ft,envMap:yt,envMapMode:yt&&F.mapping,envMapPMREM:nt,envMapMaxLod:nt?Ue.length-1:null,envMapSize:nt?Ue[0].width:null,aoMap:Yt,lightMap:Bt,bumpMap:on,normalMap:Nt,displacementMap:xi,emissiveMap:en,normalMapObjectSpace:Nt&&v.normalMapType===Cx,normalMapTangentSpace:Nt&&v.normalMapType===el,packedNormalMap:Nt&&v.normalMapType===el&&EE(v.normalMap.format),metalnessMap:Wn,roughnessMap:Xn,anisotropy:Yn,anisotropyMap:qe,clearcoat:G,clearcoatMap:N,clearcoatNormalMap:A,clearcoatRoughnessMap:K,diffuseRoughness:qn,diffuseRoughnessMap:oe,dispersion:Pt,retroreflection:It,iridescence:be,iridescenceMap:ie,iridescenceThicknessMap:he,sheen:Zt,sheenColorMap:ge,sheenRoughnessMap:ee,specularMap:te,specularColorMap:de,specularIntensityMap:B,transmission:Ve,transmissionMap:ne,thicknessMap:j,gradientMap:pe,opaque:v.transparent===!1&&v.blending===Ei&&v.alphaToCoverage===!1,alphaMap:ce,alphaTest:fe,alphaHash:De,combine:v.combine,mapUv:Ae&&d(v.map.channel),aoMapUv:Yt&&d(v.aoMap.channel),lightMapUv:Bt&&d(v.lightMap.channel),bumpMapUv:on&&d(v.bumpMap.channel),normalMapUv:Nt&&d(v.normalMap.channel),displacementMapUv:xi&&d(v.displacementMap.channel),emissiveMapUv:en&&d(v.emissiveMap.channel),metalnessMapUv:Wn&&d(v.metalnessMap.channel),roughnessMapUv:Xn&&d(v.roughnessMap.channel),anisotropyMapUv:qe&&d(v.anisotropyMap.channel),clearcoatMapUv:N&&d(v.clearcoatMap.channel),clearcoatNormalMapUv:A&&d(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:K&&d(v.clearcoatRoughnessMap.channel),diffuseRoughnessMapUv:oe&&d(v.diffuseRoughnessMap.channel),iridescenceMapUv:ie&&d(v.iridescenceMap.channel),iridescenceThicknessMapUv:he&&d(v.iridescenceThicknessMap.channel),sheenColorMapUv:ge&&d(v.sheenColorMap.channel),sheenRoughnessMapUv:ee&&d(v.sheenRoughnessMap.channel),specularMapUv:te&&d(v.specularMap.channel),specularColorMapUv:de&&d(v.specularColorMap.channel),specularIntensityMapUv:B&&d(v.specularIntensityMap.channel),transmissionMapUv:ne&&d(v.transmissionMap.channel),thicknessMapUv:j&&d(v.thicknessMap.channel),alphaMapUv:ce&&d(v.alphaMap.channel),vertexTangents:!!C.attributes.tangent&&(Nt||Yn),vertexNormals:!!C.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!C.attributes.color&&C.attributes.color.itemSize===4,pointsUvs:R.isPoints===!0&&!!C.attributes.uv&&(Ae||ce),fog:!!U,useFog:v.fog===!0,fogExp2:!!U&&U.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||C.attributes.normal===void 0&&Nt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:le,skinning:R.isSkinnedMesh===!0,hasPositionAttribute:C.attributes.position!==void 0,morphTargets:C.morphAttributes.position!==void 0,morphNormals:C.morphAttributes.normal!==void 0,morphColors:C.morphAttributes.color!==void 0,morphTargetsCount:V,morphTextureStride:re,numSunLights:w.sun.length,numDirLights:w.directional.length,numPointLights:w.point.length,numSpotLights:w.spot.length,numSpotLightMaps:w.spotLightMap.length,numRectAreaLights:w.rectArea.length,numHemiLights:w.hemi.length,numSunLightShadows:w.sunShadowMap.length,numDirLightShadows:w.directionalShadowMap.length,numPointLightShadows:w.pointShadowMap.length,numSpotLightShadows:w.spotShadowMap.length,numSpotLightShadowsWithMaps:w.numSpotLightShadowsWithMaps,numLightProbes:w.numLightProbes,numLightProbeGrids:L.filter(ve=>ve.texture!==null).length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:v.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:ae,decodeVideoTexture:Ae&&v.map.isVideoTexture===!0&&it.getTransfer(v.map.colorSpace)===Mt,decodeVideoTextureEmissive:en&&v.emissiveMap.isVideoTexture===!0&&it.getTransfer(v.emissiveMap.colorSpace)===Mt,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===ht,flipSided:v.side===un,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Qe&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Qe&&v.extensions.multiDraw===!0||at)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return je.vertexUv1s=l.has(1),je.vertexUv2s=l.has(2),je.vertexUv3s=l.has(3),l.clear(),je}function x(v){let w=[];if(v.shaderID?w.push(v.shaderID):(w.push(v.customVertexShaderID),w.push(v.customFragmentShaderID)),v.defines!==void 0)for(let P in v.defines)w.push(P),w.push(v.defines[P]);return v.isRawShaderMaterial===!1&&(m(w,v),g(w,v),w.push(i.outputColorSpace)),w.push(v.customProgramCacheKey),w.join()}function m(v,w){v.push(w.precision),v.push(w.outputColorSpace),v.push(w.envMapMode),v.push(w.envMapPMREM),v.push(w.envMapMaxLod),v.push(w.envMapSize),v.push(w.mapUv),v.push(w.alphaMapUv),v.push(w.lightMapUv),v.push(w.aoMapUv),v.push(w.bumpMapUv),v.push(w.normalMapUv),v.push(w.displacementMapUv),v.push(w.emissiveMapUv),v.push(w.metalnessMapUv),v.push(w.roughnessMapUv),v.push(w.anisotropyMapUv),v.push(w.clearcoatMapUv),v.push(w.clearcoatNormalMapUv),v.push(w.clearcoatRoughnessMapUv),v.push(w.diffuseRoughnessMapUv),v.push(w.iridescenceMapUv),v.push(w.iridescenceThicknessMapUv),v.push(w.sheenColorMapUv),v.push(w.sheenRoughnessMapUv),v.push(w.specularMapUv),v.push(w.specularColorMapUv),v.push(w.specularIntensityMapUv),v.push(w.transmissionMapUv),v.push(w.thicknessMapUv),v.push(w.combine),v.push(w.fogExp2),v.push(w.sizeAttenuation),v.push(w.morphTargetsCount),v.push(w.numSunLights),v.push(w.numDirLights),v.push(w.numPointLights),v.push(w.numSpotLights),v.push(w.numSpotLightMaps),v.push(w.numHemiLights),v.push(w.numRectAreaLights),v.push(w.numSunLightShadows),v.push(w.numDirLightShadows),v.push(w.numPointLightShadows),v.push(w.numSpotLightShadows),v.push(w.numSpotLightShadowsWithMaps),v.push(w.numLightProbes),v.push(w.numLightProbeGrids),v.push(w.shadowMapType),v.push(w.toneMapping),v.push(w.numClippingPlanes),v.push(w.numClipIntersection),v.push(w.depthPacking)}function g(v,w){o.disableAll(),w.instancing&&o.enable(0),w.instancingColor&&o.enable(1),w.instancingMorph&&o.enable(2),w.matcap&&o.enable(3),w.envMap&&o.enable(4),w.normalMapObjectSpace&&o.enable(5),w.normalMapTangentSpace&&o.enable(6),w.clearcoat&&o.enable(7),w.iridescence&&o.enable(8),w.alphaTest&&o.enable(9),w.vertexColors&&o.enable(10),w.vertexAlphas&&o.enable(11),w.vertexUv1s&&o.enable(12),w.vertexUv2s&&o.enable(13),w.vertexUv3s&&o.enable(14),w.vertexTangents&&o.enable(15),w.anisotropy&&o.enable(16),w.alphaHash&&o.enable(17),w.batching&&o.enable(18),w.dispersion&&o.enable(19),w.retroreflection&&o.enable(24),w.diffuseRoughness&&o.enable(25),w.batchingColor&&o.enable(20),w.gradientMap&&o.enable(21),w.packedNormalMap&&o.enable(22),w.vertexNormals&&o.enable(23),v.push(o.mask),o.disableAll(),w.fog&&o.enable(0),w.useFog&&o.enable(1),w.flatShading&&o.enable(2),w.logarithmicDepthBuffer&&o.enable(3),w.reversedDepthBuffer&&o.enable(4),w.skinning&&o.enable(5),w.morphTargets&&o.enable(6),w.morphNormals&&o.enable(7),w.morphColors&&o.enable(8),w.premultipliedAlpha&&o.enable(9),w.shadowMapEnabled&&o.enable(10),w.doubleSided&&o.enable(11),w.flipSided&&o.enable(12),w.useDepthPacking&&o.enable(13),w.dithering&&o.enable(14),w.transmission&&o.enable(15),w.sheen&&o.enable(16),w.opaque&&o.enable(17),w.pointsUvs&&o.enable(18),w.decodeVideoTexture&&o.enable(19),w.decodeVideoTextureEmissive&&o.enable(20),w.alphaToCoverage&&o.enable(21),w.numLightProbeGrids>0&&o.enable(22),w.hasPositionAttribute&&o.enable(23),v.push(o.mask)}function y(v){let w=f[v.type],P;if(w){let T=Ii[w];P=Yx.clone(T.uniforms)}else P=v.uniforms;return P}function _(v,w){let P=u.get(w);return P!==void 0?++P.usedTimes:(P=new TE(i,w,v,r),c.push(P),u.set(w,P)),P}function b(v){if(--v.usedTimes===0){let w=c.indexOf(v);c[w]=c[c.length-1],c.pop(),u.delete(v.cacheKey),v.destroy()}}function M(v){a.remove(v)}function S(){a.dispose()}return{getParameters:p,getProgramCacheKey:x,getUniforms:y,acquireProgram:_,releaseProgram:b,releaseShaderCache:M,programs:c,dispose:S}}function CE(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function r(o,a,l){i.get(o)[a]=l}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function PE(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function fy(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function dy(){let i=[],e=0,t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function o(f){let d=0;return f.isInstancedMesh&&(d+=2),f.isSkinnedMesh&&(d+=1),d}function a(f,d,p,x,m,g){let y=i[e];return y===void 0?(y={id:f.id,object:f,geometry:d,material:p,materialVariant:o(f),groupOrder:x,renderOrder:f.renderOrder,z:m,group:g},i[e]=y):(y.id=f.id,y.object=f,y.geometry=d,y.material=p,y.materialVariant=o(f),y.groupOrder=x,y.renderOrder=f.renderOrder,y.z=m,y.group=g),e++,y}function l(f,d,p,x,m,g,y){y.reversedDepth===!0&&(m=-m);let _=a(f,d,p,x,m,g);p.transmission>0?n.push(_):p.transparent===!0?r.push(_):t.push(_)}function c(f,d,p,x,m,g){let y=a(f,d,p,x,m,g);p.transmission>0?n.unshift(y):p.transparent===!0?r.unshift(y):t.unshift(y)}function u(f,d){t.length>1&&t.sort(f||PE),n.length>1&&n.sort(d||fy),r.length>1&&r.sort(d||fy)}function h(){for(let f=e,d=i.length;f=s.length?(o=new dy,s.push(o)):o=s[r],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function LE(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={direction:new D,color:new W};break;case"SpotLight":t={position:new D,direction:new D,color:new W,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new D,color:new W,distance:0,decay:0};break;case"HemisphereLight":t={direction:new D,skyColor:new W,groundColor:new W};break;case"RectAreaLight":t={color:new W,position:new D,halfWidth:new D,halfHeight:new D};break}return i[e.id]=t,t}}}function FE(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"SunLight":case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ke,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var NE=0;function OE(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function DE(i){let e=new LE,t=FE(),n={version:0,hash:{sunLength:-1,directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numSunShadows:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],sun:[],sunShadow:[],sunShadowMap:[],sunShadowMatrix:[],sunShadowCascade:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new D);let r=new D,s=new ze,o=new ze;function a(c){let u=0,h=0,f=0;for(let L=0;L<9;L++)n.probe[L].set(0,0,0);let d=0,p=0,x=0,m=0,g=0,y=0,_=0,b=0,M=0,S=0,v=0,w=0,P=0,T=0;c.sort(OE);for(let L=0,U=c.length;L0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=_e.LTC_FLOAT_1,n.rectAreaLTC2=_e.LTC_FLOAT_2):(n.rectAreaLTC1=_e.LTC_HALF_1,n.rectAreaLTC2=_e.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=f;let R=n.hash;(R.sunLength!==d||R.directionalLength!==m||R.pointLength!==g||R.spotLength!==y||R.rectAreaLength!==_||R.hemiLength!==b||R.numSunShadows!==p||R.numDirectionalShadows!==M||R.numPointShadows!==S||R.numSpotShadows!==v||R.numSpotMaps!==w||R.numLightProbes!==T)&&(n.sun.length=d,n.directional.length=m,n.spot.length=y,n.rectArea.length=_,n.point.length=g,n.hemi.length=b,n.sunShadow.length=p,n.sunShadowMap.length=p,n.sunShadowMatrix.length=x,n.sunShadowCascade.length=x,n.directionalShadow.length=M,n.directionalShadowMap.length=M,n.directionalShadowMatrix.length=M,n.pointShadow.length=S,n.pointShadowMap.length=S,n.pointShadowMatrix.length=S,n.spotShadow.length=v,n.spotShadowMap.length=v,n.spotLightMatrix.length=v+w-P,n.spotLightMap.length=w,n.numSpotLightShadowsWithMaps=P,n.numLightProbes=T,R.sunLength=d,R.directionalLength=m,R.pointLength=g,R.spotLength=y,R.rectAreaLength=_,R.hemiLength=b,R.numSunShadows=p,R.numDirectionalShadows=M,R.numPointShadows=S,R.numSpotShadows=v,R.numSpotMaps=w,R.numLightProbes=T,n.version=NE++)}function l(c,u){let h=0,f=0,d=0,p=0,x=0,m=0,g=u.matrixWorldInverse;for(let y=0,_=c.length;y<_;y++){let b=c[y];if(b.isSunLight){let M=n.sun[h];M.direction.setFromMatrixPosition(b.matrixWorld),M.direction.transformDirection(g),h++}else if(b.isDirectionalLight){let M=n.directional[f];M.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(g),f++}else if(b.isSpotLight){let M=n.spot[p];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(g),M.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),M.direction.sub(r),M.direction.transformDirection(g),p++}else if(b.isRectAreaLight){let M=n.rectArea[x];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(g),o.identity(),s.copy(b.matrixWorld),s.premultiply(g),o.extractRotation(s),M.halfWidth.set(b.width*.5,0,0),M.halfHeight.set(0,b.height*.5,0),M.halfWidth.applyMatrix4(o),M.halfHeight.applyMatrix4(o),x++}else if(b.isPointLight){let M=n.point[d];M.position.setFromMatrixPosition(b.matrixWorld),M.position.applyMatrix4(g),d++}else if(b.isHemisphereLight){let M=n.hemi[m];M.direction.setFromMatrixPosition(b.matrixWorld),M.direction.transformDirection(g),m++}}}return{setup:a,setupView:l,state:n}}function py(i){let e=new DE(i),t=[],n=[],r=[];function s(h){u.camera=h,t.length=0,n.length=0,r.length=0}function o(h){h.isLightProbeGrid?r.push(h):t.push(h)}function a(h){n.push(h)}function l(){e.setup(t),r.sort((h,f)=>h.priority-f.priority||h.id-f.id)}function c(h){e.setupView(t,h)}let u={lightsArray:t,shadowsArray:n,lightProbeGridArray:r,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:u,setupLights:l,setupLightsView:c,pushLight:o,pushShadow:a}}function kE(i){let e=new WeakMap;function t(r,s=0){let o=e.get(r),a;return o===void 0?(a=new py(i),e.set(r,[a])):s>=o.length?(a=new py(i),o.push(a)):a=o[s],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var UE=`void main() { gl_Position = vec4( position, 1.0 ); -}`,UE=`uniform sampler2D shadow_pass; +}`,BE=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; void main() { @@ -4199,12 +4199,12 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); -}`,kE=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],BE=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],py=new ze,el=new D,kd=new D;function zE(i,e,t){let n=new Nr,r=new Ue,s=new Ue,o=new vt,a=new Uc,l=new kc,c={},u=t.maxTextureSize,h={[Ai]:un,[un]:Ai,[ht]:ht},f=new Si({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ue},radius:{value:4}},vertexShader:DE,fragmentShader:UE}),d=f.clone();d.defines.HORIZONTAL_PASS=1;let p=new Pe;p.setAttribute("position",new wt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Se(p,f),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Wa;let g=this.type;this.render=function(S,v,w){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===rx&&(Oe("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Wa);let P=i.getRenderTarget(),T=i.getActiveCubeFace(),R=i.getActiveMipmapLevel(),L=i.state;L.setBlending(xs),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);let k=g!==this.type;k&&v.traverse(function(C){C.material&&(Array.isArray(C.material)?C.material.forEach(I=>I.needsUpdate=!0):C.material.needsUpdate=!0)});for(let C=0,I=S.length;Cu||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/H.x),r.x=s.x*H.x,F.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/H.y),r.y=s.y*H.y,F.mapSize.y=s.y));let U=i.state.buffers.depth.getReversed();if(F.camera._reversedDepth=U,F.map===null||k===!0){if(F.map!==null&&(F.map.depthTexture!==null&&(F.map.depthTexture.dispose(),F.map.depthTexture=null),F.map.dispose()),this.type===Mo){if(O.isPointLight){Oe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}F.map=new Tn(r.x,r.y,{format:Br,type:li,minFilter:Ht,magFilter:Ht,generateMipmaps:!1}),F.map.texture.name=O.name+".shadowMap",F.map.depthTexture=new nr(r.x,r.y,Gn),F.map.depthTexture.name=O.name+".shadowMapDepth",F.map.depthTexture.format=Zi,F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=Ut,F.map.depthTexture.magFilter=Ut}else O.isPointLight?(F.map=new nl(r.x),F.map.depthTexture=new Ea(r.x,ai)):(F.map=new Tn(r.x,r.y),F.map.depthTexture=new nr(r.x,r.y,ai)),F.map.depthTexture.name=O.name+".shadowMap",F.map.depthTexture.format=Zi,this.type===Wa?(F.map.depthTexture.compareFunction=U?bd:yd,F.map.depthTexture.minFilter=Ht,F.map.depthTexture.magFilter=Ht):(F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=Ut,F.map.depthTexture.magFilter=Ut);F.camera.updateProjectionMatrix()}F.map.isWebGLCubeRenderTarget!==!0&&(F.map.width!==r.x||F.map.height!==r.y)&&F.map.setSize(r.x,r.y);let X=F.map.isWebGLCubeRenderTarget?6:F.getViewportCount();O.isPointLight!==!0&&F.updateMatrices(O,w);let V=(F.camera.layers.mask&4294967294)!==0?F.camera.layers:w.layers;for(let re=0;re0||v.map&&v.alphaTest>0||v.alphaToCoverage===!0){let L=T.uuid,k=v.uuid,C=c[L];C===void 0&&(C={},c[L]=C);let I=C[k];I===void 0&&(I=T.clone(),C[k]=I,v.addEventListener("dispose",M)),T=I}if(T.visible=v.visible,T.wireframe=v.wireframe,P===Mo?T.side=v.shadowSide!==null?v.shadowSide:v.side:T.side=v.shadowSide!==null?v.shadowSide:h[v.side],T.alphaMap=v.alphaMap,T.alphaTest=v.alphaToCoverage===!0?.5:v.alphaTest,T.map=v.map,T.clipShadows=v.clipShadows,T.clippingPlanes=v.clippingPlanes,T.clipIntersection=v.clipIntersection,T.displacementMap=v.displacementMap,T.displacementScale=v.displacementScale,T.displacementBias=v.displacementBias,T.wireframeLinewidth=v.wireframeLinewidth,T.linewidth=v.linewidth,w.isPointLight===!0&&T.isMeshDistanceMaterial===!0){let L=i.properties.get(T);L.light=w}return T}function b(S,v,w,P,T,R){if(S.visible===!1)return;if(S.layers.test(T)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&R===Mo)&&(!S.frustumCulled||S.intersectsFrustum(n))){S.modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,S.matrixWorld);let C=e.update(S),I=S.material;if(Array.isArray(I)){let O=C.groups;for(let F=0,H=O.length;F=1):U.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(U)[1]),F=H>=2);let X=null,V={},re=i.getParameter(i.SCISSOR_BOX),ye=i.getParameter(i.VIEWPORT),Y=new vt().fromArray(re),Q=new vt().fromArray(ye);function se(B,ne,j,pe){let ce=new Uint8Array(4),fe=i.createTexture();i.bindTexture(B,fe),i.texParameteri(B,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(B,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let De=0;De"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ue,u=new WeakMap,h=new Set,f,d=new WeakMap,p=new Set,x=new FinalizationRegistry(N=>p.delete(N)),m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(N,A){return m?new OffscreenCanvas(N,A):uo("canvas")}function y(N,A,K){let oe=1,ie=qe(N);if((ie.width>K||ie.height>K)&&(oe=K/Math.max(ie.width,ie.height)),oe<1)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap||typeof VideoFrame<"u"&&N instanceof VideoFrame){let he=Math.floor(oe*ie.width),ge=Math.floor(oe*ie.height);f===void 0&&(f=g(he,ge));let ee=A?g(he,ge):f;return ee.width=he,ee.height=ge,ee.getContext("2d").drawImage(N,0,0,he,ge),Oe("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+he+"x"+ge+")."),ee}else return"data"in N&&Oe("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+")."),N;return N}function _(N){return N.generateMipmaps}function b(N){i.generateMipmap(N)}function M(N){return N.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:N.isWebGL3DRenderTarget?i.TEXTURE_3D:N.isWebGLArrayRenderTarget||N.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function S(N,A,K,oe,ie,he=!1){if(N!==null){if(i[N]!==void 0)return i[N];Oe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let ge;oe&&(ge=e.get("EXT_texture_norm16"),ge||Oe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let ee=A;if(A===i.RED&&(K===i.FLOAT&&(ee=i.R32F),K===i.HALF_FLOAT&&(ee=i.R16F),K===i.UNSIGNED_BYTE&&(ee=i.R8),K===i.UNSIGNED_SHORT&&ge&&(ee=ge.R16_EXT),K===i.SHORT&&ge&&(ee=ge.R16_SNORM_EXT)),A===i.RED_INTEGER&&(K===i.UNSIGNED_BYTE&&(ee=i.R8UI),K===i.UNSIGNED_SHORT&&(ee=i.R16UI),K===i.UNSIGNED_INT&&(ee=i.R32UI),K===i.BYTE&&(ee=i.R8I),K===i.SHORT&&(ee=i.R16I),K===i.INT&&(ee=i.R32I)),A===i.RG&&(K===i.FLOAT&&(ee=i.RG32F),K===i.HALF_FLOAT&&(ee=i.RG16F),K===i.UNSIGNED_BYTE&&(ee=i.RG8),K===i.UNSIGNED_SHORT&&ge&&(ee=ge.RG16_EXT),K===i.SHORT&&ge&&(ee=ge.RG16_SNORM_EXT)),A===i.RG_INTEGER&&(K===i.UNSIGNED_BYTE&&(ee=i.RG8UI),K===i.UNSIGNED_SHORT&&(ee=i.RG16UI),K===i.UNSIGNED_INT&&(ee=i.RG32UI),K===i.BYTE&&(ee=i.RG8I),K===i.SHORT&&(ee=i.RG16I),K===i.INT&&(ee=i.RG32I)),A===i.RGB_INTEGER&&(K===i.UNSIGNED_BYTE&&(ee=i.RGB8UI),K===i.UNSIGNED_SHORT&&(ee=i.RGB16UI),K===i.UNSIGNED_INT&&(ee=i.RGB32UI),K===i.BYTE&&(ee=i.RGB8I),K===i.SHORT&&(ee=i.RGB16I),K===i.INT&&(ee=i.RGB32I)),A===i.RGBA_INTEGER&&(K===i.UNSIGNED_BYTE&&(ee=i.RGBA8UI),K===i.UNSIGNED_SHORT&&(ee=i.RGBA16UI),K===i.UNSIGNED_INT&&(ee=i.RGBA32UI),K===i.BYTE&&(ee=i.RGBA8I),K===i.SHORT&&(ee=i.RGBA16I),K===i.INT&&(ee=i.RGBA32I)),A===i.RGB&&(K===i.UNSIGNED_SHORT&&ge&&(ee=ge.RGB16_EXT),K===i.SHORT&&ge&&(ee=ge.RGB16_SNORM_EXT),K===i.UNSIGNED_INT_5_9_9_9_REV&&(ee=i.RGB9_E5),K===i.UNSIGNED_INT_10F_11F_11F_REV&&(ee=i.R11F_G11F_B10F)),A===i.RGBA){let te=he?ba:it.getTransfer(ie);K===i.FLOAT&&(ee=i.RGBA32F),K===i.HALF_FLOAT&&(ee=i.RGBA16F),K===i.UNSIGNED_BYTE&&(ee=te===Mt?i.SRGB8_ALPHA8:i.RGBA8),K===i.UNSIGNED_SHORT&&ge&&(ee=ge.RGBA16_EXT),K===i.SHORT&&ge&&(ee=ge.RGBA16_SNORM_EXT),K===i.UNSIGNED_SHORT_4_4_4_4&&(ee=i.RGBA4),K===i.UNSIGNED_SHORT_5_5_5_1&&(ee=i.RGB5_A1)}return(ee===i.R16F||ee===i.R32F||ee===i.RG16F||ee===i.RG32F||ee===i.RGBA16F||ee===i.RGBA32F)&&e.get("EXT_color_buffer_float"),ee}function v(N,A){let K;return N?A===null||A===ai||A===vs?K=i.DEPTH24_STENCIL8:A===Gn?K=i.DEPTH32F_STENCIL8:A===To&&(K=i.DEPTH24_STENCIL8,Oe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):A===null||A===ai||A===vs?K=i.DEPTH_COMPONENT24:A===Gn?K=i.DEPTH_COMPONENT32F:A===To&&(K=i.DEPTH_COMPONENT16),K}function w(N,A){return _(N)===!0||N.isFramebufferTexture&&N.minFilter!==Ut&&N.minFilter!==Ht?Math.log2(Math.max(A.width,A.height))+1:N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?A.mipmaps.length:1}function P(N){let A=new WeakRef(N);n.get(N).__ref=A,p.add(A),x.register(N,A,A)}function T(N){let A=n.get(N).__ref;A!==void 0&&(p.delete(A),x.unregister(A))}function R(N){k(N.target)}function L(N){C(N.target)}function k(N){N.removeEventListener("dispose",R),T(N),O(N),N.isVideoTexture&&u.delete(N),N.isHTMLTexture&&h.delete(N)}function C(N){N.removeEventListener("dispose",L),T(N),H(N)}function I(){for(let N of p){let A=N.deref();A!==void 0&&(A.isRenderTarget===!0?C(A):k(A))}p.clear(),h.clear()}function O(N){let A=n.get(N);if(A.__webglInit===void 0)return;let K=N.source,oe=d.get(K);if(oe){let ie=oe[A.__cacheKey];ie.usedTimes--,ie.usedTimes===0&&F(N),Object.keys(oe).length===0&&d.delete(K)}n.remove(N)}function F(N){let A=n.get(N);i.deleteTexture(A.__webglTexture);let K=N.source,oe=d.get(K);delete oe[A.__cacheKey],o.memory.textures--}function H(N){let A=n.get(N);A.__depthDisposeCallback&&A.__depthDisposeCallback();let K=N.depthTexture;if(K&&K.renderTarget===N&&k(K),N.isWebGLCubeRenderTarget)for(let ie=0;ie<6;ie++){if(Array.isArray(A.__webglFramebuffer[ie]))for(let he=0;he=r.maxTextures&&Oe("WebGLTextures: Trying to use "+(N+1)+" texture units while this GPU supports only "+r.maxTextures),U+=1,N}function Y(N){let A=[];return A.push(N.wrapS),A.push(N.wrapT),A.push(N.wrapR||0),A.push(N.magFilter),A.push(N.minFilter),A.push(N.anisotropy),A.push(N.internalFormat),A.push(N.format),A.push(N.type),A.push(N.generateMipmaps),A.push(N.mipmapsAutoUpdate),A.push(N.premultiplyAlpha),A.push(N.flipY),A.push(N.unpackAlignment),A.push(N.colorSpace),A.join()}function Q(N,A){let K=n.get(N);if(N.isVideoTexture&&Zt(N),N.isRenderTargetTexture===!1&&N.isExternalTexture!==!0&&N.version>0&&K.__version!==N.version){let oe=N.image;if(oe===null)Oe("WebGLRenderer: Texture marked for update but no image data found.");else if(oe.complete===!1)Oe("WebGLRenderer: Texture marked for update but image is incomplete");else{Bt(K,N,A);return}}else N.isExternalTexture&&(K.__webglTexture=N.sourceTexture?N.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,K.__webglTexture,i.TEXTURE0+A)}function se(N,A){let K=n.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&K.__version!==N.version){Bt(K,N,A);return}else N.isExternalTexture&&(K.__webglTexture=N.sourceTexture?N.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,K.__webglTexture,i.TEXTURE0+A)}function we(N,A){let K=n.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&K.__version!==N.version){Bt(K,N,A);return}t.bindTexture(i.TEXTURE_3D,K.__webglTexture,i.TEXTURE0+A)}function le(N,A){let K=n.get(N);if(N.version>0&&K.__version!==N.version){on(K,N,A);return}t.bindTexture(i.TEXTURE_CUBE_MAP,K.__webglTexture,i.TEXTURE0+A)}let Ne={[zn]:i.REPEAT,[ln]:i.CLAMP_TO_EDGE,[Ir]:i.MIRRORED_REPEAT},at={[Ut]:i.NEAREST,[wo]:i.NEAREST_MIPMAP_NEAREST,[ur]:i.NEAREST_MIPMAP_LINEAR,[Ht]:i.LINEAR,[kr]:i.LINEAR_MIPMAP_NEAREST,[Nn]:i.LINEAR_MIPMAP_LINEAR},Ae={[Px]:i.NEVER,[vd]:i.ALWAYS,[Ix]:i.LESS,[yd]:i.LEQUAL,[Lx]:i.EQUAL,[bd]:i.GEQUAL,[Fx]:i.GREATER,[Nx]:i.NOTEQUAL};function ft(N,A){if(A.type===Gn&&e.has("OES_texture_float_linear")===!1&&(A.magFilter===Ht||A.magFilter===kr||A.magFilter===ur||A.magFilter===Nn||A.minFilter===Ht||A.minFilter===kr||A.minFilter===ur||A.minFilter===Nn)&&Oe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(N,i.TEXTURE_WRAP_S,Ne[A.wrapS]),i.texParameteri(N,i.TEXTURE_WRAP_T,Ne[A.wrapT]),(N===i.TEXTURE_3D||N===i.TEXTURE_2D_ARRAY)&&i.texParameteri(N,i.TEXTURE_WRAP_R,Ne[A.wrapR]),i.texParameteri(N,i.TEXTURE_MAG_FILTER,at[A.magFilter]),i.texParameteri(N,i.TEXTURE_MIN_FILTER,at[A.minFilter]),A.compareFunction&&(i.texParameteri(N,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(N,i.TEXTURE_COMPARE_FUNC,Ae[A.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(A.magFilter===Ut||A.minFilter!==ur&&A.minFilter!==Nn||A.type===Gn&&e.has("OES_texture_float_linear")===!1)return;if(A.anisotropy>1||n.get(A).__currentAnisotropy){let K=e.get("EXT_texture_filter_anisotropic");i.texParameterf(N,K.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(A.anisotropy,r.getMaxAnisotropy())),n.get(A).__currentAnisotropy=A.anisotropy}}}function yt(N,A){let K=!1;N.__webglInit===void 0&&(N.__webglInit=!0,A.addEventListener("dispose",R),P(A));let oe=A.source,ie=d.get(oe);ie===void 0&&(ie={},d.set(oe,ie));let he=Y(A);if(he!==N.__cacheKey){ie[he]===void 0&&(ie[he]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,K=!0),ie[he].usedTimes++;let ge=ie[N.__cacheKey];ge!==void 0&&(ie[N.__cacheKey].usedTimes--,ge.usedTimes===0&&F(A)),N.__cacheKey=he,N.__webglTexture=ie[he].texture}return K}function nt(N,A,K){return Math.floor(Math.floor(N/K)/A)}function Yt(N,A,K,oe){let he=N.updateRanges;if(he.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,A.width,A.height,K,oe,A.data);else{he.sort((B,ne)=>B.start-ne.start);let ge=0;for(let B=1;B0){ce&&fe&&t.texStorage2D(i.TEXTURE_2D,Qe,ne,pe[0].width,pe[0].height);for(let ae=0,ke=pe.length;ae0){let je=Id(j.width,j.height,A.format,A.type);for(let ve of A.layerUpdates){let St=j.data.subarray(ve*je/j.data.BYTES_PER_ELEMENT,(ve+1)*je/j.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ae,0,0,ve,j.width,j.height,1,de,St)}}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ae,0,0,0,j.width,j.height,te.depth,de,j.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,ae,ne,j.width,j.height,te.depth,0,j.data,0,0);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ce?De&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,ae,0,0,0,j.width,j.height,te.depth,de,B,j.data):t.texImage3D(i.TEXTURE_2D_ARRAY,ae,ne,j.width,j.height,te.depth,0,de,B,j.data);A.layerUpdates.size>0&&A.clearLayerUpdates()}else{ce&&fe&&t.texStorage2D(i.TEXTURE_2D,Qe,ne,pe[0].width,pe[0].height);for(let ae=0,ke=pe.length;ae0){let ae=Id(te.width,te.height,A.format,A.type);for(let ke of A.layerUpdates){let je=te.data.subarray(ke*ae/te.data.BYTES_PER_ELEMENT,(ke+1)*ae/te.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ke,te.width,te.height,1,de,B,je)}A.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,de,B,te.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ne,te.width,te.height,te.depth,0,de,B,te.data);else if(A.isData3DTexture)ce?(fe&&t.texStorage3D(i.TEXTURE_3D,Qe,ne,te.width,te.height,te.depth),De&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,de,B,te.data)):t.texImage3D(i.TEXTURE_3D,0,ne,te.width,te.height,te.depth,0,de,B,te.data);else if(A.isFramebufferTexture){if(fe)if(ce)t.texStorage2D(i.TEXTURE_2D,Qe,ne,te.width,te.height);else{let ae=te.width,ke=te.height;for(let je=0;je>=1,ke>>=1}}else if(A.isHTMLTexture){if("texElementImage2D"in i){let ae=i.canvas;if(ae.hasAttribute("layoutsubtree")||ae.setAttribute("layoutsubtree","true"),te.parentNode!==ae){ae.appendChild(te),h.add(A),ae.onpaint=ke=>{let je=ke.changedElements;for(let ve of h)je.includes(ve.image)&&(ve.needsUpdate=!0)},ae.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,te);else{let je=i.RGBA,ve=i.RGBA,St=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,je,ve,St,te)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(pe.length>0){if(ce&&fe){let ae=qe(pe[0]);t.texStorage2D(i.TEXTURE_2D,Qe,ne,ae.width,ae.height)}for(let ae=0,ke=pe.length;ae0&&ke++;let ve=qe(ne[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,ke,fe,ve.width,ve.height)}for(let ve=0;ve<6;ve++)if(B){De?ae&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,ne[ve].width,ne[ve].height,pe,ce,ne[ve].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,fe,ne[ve].width,ne[ve].height,0,pe,ce,ne[ve].data);for(let St=0;St>he),j=Math.max(1,A.height>>he);ie===i.TEXTURE_3D||ie===i.TEXTURE_2D_ARRAY?t.texImage3D(ie,he,te,ne,j,A.depth,0,ge,ee,null):t.texImage2D(ie,he,te,ne,j,0,ge,ee,null)}t.bindFramebuffer(i.FRAMEBUFFER,N),be(A)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,oe,ie,B.__webglTexture,0,It(A)):(ie===i.TEXTURE_2D||ie>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,oe,ie,B.__webglTexture,he),t.bindFramebuffer(i.FRAMEBUFFER,null)}function xi(N,A,K){if(i.bindRenderbuffer(i.RENDERBUFFER,N),A.depthBuffer){let oe=A.depthTexture,ie=oe&&oe.isDepthTexture?oe.type:null,he=v(A.stencilBuffer,ie),ge=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;be(A)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,It(A),he,A.width,A.height):K?i.renderbufferStorageMultisample(i.RENDERBUFFER,It(A),he,A.width,A.height):i.renderbufferStorage(i.RENDERBUFFER,he,A.width,A.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ge,i.RENDERBUFFER,N)}else{let oe=A.textures;for(let ie=0;ie{delete A.__boundDepthTexture,delete A.__depthDisposeCallback,oe.removeEventListener("dispose",ie)};oe.addEventListener("dispose",ie),A.__depthDisposeCallback=ie}A.__boundDepthTexture=oe}if(N.depthTexture&&!A.__autoAllocateDepthBuffer)if(K)for(let oe=0;oe<6;oe++)en(A.__webglFramebuffer[oe],N,oe);else N.texture.mipmaps.length>0?en(A.__webglFramebuffer[0],N,0):en(A.__webglFramebuffer,N,0);else if(K){A.__webglDepthbuffer=[];for(let oe=0;oe<6;oe++)if(t.bindFramebuffer(i.FRAMEBUFFER,A.__webglFramebuffer[oe]),A.__webglDepthbuffer[oe]===void 0)A.__webglDepthbuffer[oe]=i.createRenderbuffer(),xi(A.__webglDepthbuffer[oe],N,!1);else{let ie=N.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,he=A.__webglDepthbuffer[oe];i.bindRenderbuffer(i.RENDERBUFFER,he),i.framebufferRenderbuffer(i.FRAMEBUFFER,ie,i.RENDERBUFFER,he)}}else if(N.texture.mipmaps.length>0?t.bindFramebuffer(i.FRAMEBUFFER,A.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,A.__webglFramebuffer),A.__webglDepthbuffer===void 0)A.__webglDepthbuffer=i.createRenderbuffer(),xi(A.__webglDepthbuffer,N,!1);else{let ie=N.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,he=A.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,he),i.framebufferRenderbuffer(i.FRAMEBUFFER,ie,i.RENDERBUFFER,he)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Xn(N,A,K){let oe=n.get(N);A!==void 0&&Nt(oe.__webglFramebuffer,N,N.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),K!==void 0&&Wn(N)}function Yn(N){let A=N.texture,K=n.get(N),oe=n.get(A);N.addEventListener("dispose",L),P(N);let ie=N.textures,he=N.isWebGLCubeRenderTarget===!0,ge=ie.length>1;if(ge||(oe.__webglTexture===void 0&&(oe.__webglTexture=i.createTexture()),oe.__version=A.version,o.memory.textures++),he){K.__webglFramebuffer=[];for(let ee=0;ee<6;ee++)if(A.mipmaps.length>0){K.__webglFramebuffer[ee]=[];for(let te=0;te0){K.__webglFramebuffer=[];for(let ee=0;ee0&&be(N)===!1){K.__webglMultisampledFramebuffer=i.createFramebuffer(),K.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,K.__webglMultisampledFramebuffer);for(let ee=0;ee0)for(let te=0;te0&&i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,A.mipmaps.length-1),t.unbindTexture()}else if(ge){for(let ee=0,te=ie.length;ee0)for(let te=0;te0&&i.texParameteri(ee,i.TEXTURE_MAX_LEVEL,A.mipmaps.length-1),t.unbindTexture()}N.depthBuffer&&Wn(N)}function G(N){let A=N.textures;for(let K=0,oe=A.length;K0){if(be(N)===!1){let A=N.textures,K=N.width,oe=N.height,ie=i.COLOR_BUFFER_BIT,he=N.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ge=n.get(N),ee=A.length>1;if(ee)for(let de=0;de0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ge.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ge.__webglFramebuffer);for(let de=0;de0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&A.__useRenderToTexture!==!1}function Zt(N){let A=o.render.frame;u.get(N)!==A&&(u.set(N,A),N.update())}function Ve(N,A){let K=N.colorSpace,oe=N.format,ie=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||K!==Sn&&K!==ci&&(it.getTransfer(K)===Mt?(oe!==Dn||ie!==On)&&Oe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):We("WebGLTextures: Unsupported texture color space:",K)),A}function qe(N){return typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement?(c.width=N.naturalWidth||N.width,c.height=N.naturalHeight||N.height):typeof VideoFrame<"u"&&N instanceof VideoFrame?(c.width=N.displayWidth,c.height=N.displayHeight):(c.width=N.width,c.height=N.height),c}this.allocateTextureUnit=ye,this.resetTextureUnits=X,this.getTextureUnits=V,this.setTextureUnits=re,this.setTexture2D=Q,this.setTexture2DArray=se,this.setTexture3D=we,this.setTextureCube=le,this.rebindTextures=Xn,this.setupRenderTarget=Yn,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=Pt,this.setupDepthRenderbuffer=Wn,this.setupFrameBufferTexture=Nt,this.useMultisampledRTT=be,this.dispose=I}function HE(i,e){function t(n,r=ci){let s,o=it.getTransfer(r);if(n===On)return i.UNSIGNED_BYTE;if(n===jc)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Qc)return i.UNSIGNED_SHORT_5_5_5_1;if(n===dd)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===pd)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===hd)return i.BYTE;if(n===fd)return i.SHORT;if(n===To)return i.UNSIGNED_SHORT;if(n===Jc)return i.INT;if(n===ai)return i.UNSIGNED_INT;if(n===Gn)return i.FLOAT;if(n===li)return i.HALF_FLOAT;if(n===md)return i.ALPHA;if(n===gd)return i.RGB;if(n===Dn)return i.RGBA;if(n===Zi)return i.DEPTH_COMPONENT;if(n===hr)return i.DEPTH_STENCIL;if(n===eu)return i.RED;if(n===tu)return i.RED_INTEGER;if(n===Br)return i.RG;if(n===nu)return i.RG_INTEGER;if(n===iu)return i.RGBA_INTEGER;if(n===Ya||n===qa||n===$a||n===Ka)if(o===Mt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Ya)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===qa)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===$a)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ka)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Ya)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===qa)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===$a)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ka)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ru||n===su||n===ou||n===au)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===ru)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===su)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ou)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===au)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===lu||n===cu||n===uu||n===hu||n===fu||n===Za||n===du)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===lu||n===cu)return o===Mt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===uu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(n===hu)return s.COMPRESSED_R11_EAC;if(n===fu)return s.COMPRESSED_SIGNED_R11_EAC;if(n===Za)return s.COMPRESSED_RG11_EAC;if(n===du)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===pu||n===mu||n===gu||n===xu||n===yu||n===bu||n===vu||n===_u||n===Mu||n===Su||n===wu||n===Tu||n===Au||n===Eu)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===pu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===mu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===gu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===xu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===yu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===bu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===vu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===_u)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Mu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Su)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===wu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Tu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Au)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Eu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ru||n===Cu||n===Pu)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Ru)return o===Mt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Cu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Pu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Iu||n===Lu||n===Ja||n===Fu)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Iu)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Lu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Ja)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Fu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===vs?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var WE=` +}`,zE=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],VE=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],my=new ze,tl=new D,Bd=new D;function GE(i,e,t){let n=new Nr,r=new ke,s=new ke,o=new vt,a=new Uc,l=new Bc,c={},u=t.maxTextureSize,h={[Ai]:un,[un]:Ai,[ht]:ht},f=new Si({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ke},radius:{value:4}},vertexShader:UE,fragmentShader:BE}),d=f.clone();d.defines.HORIZONTAL_PASS=1;let p=new Pe;p.setAttribute("position",new wt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let x=new Se(p,f),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Xa;let g=this.type;this.render=function(S,v,w){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===sx&&(Oe("WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead."),this.type=Xa);let P=i.getRenderTarget(),T=i.getActiveCubeFace(),R=i.getActiveMipmapLevel(),L=i.state;L.setBlending(xs),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);let U=g!==this.type;U&&v.traverse(function(C){C.material&&(Array.isArray(C.material)?C.material.forEach(I=>I.needsUpdate=!0):C.material.needsUpdate=!0)});for(let C=0,I=S.length;Cu||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/H.x),r.x=s.x*H.x,F.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/H.y),r.y=s.y*H.y,F.mapSize.y=s.y));let k=i.state.buffers.depth.getReversed();if(F.camera._reversedDepth=k,F.map===null||U===!0){if(F.map!==null&&(F.map.depthTexture!==null&&(F.map.depthTexture.dispose(),F.map.depthTexture=null),F.map.dispose()),this.type===Mo){if(O.isPointLight){Oe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}F.map=new Tn(r.x,r.y,{format:Br,type:li,minFilter:Ht,magFilter:Ht,generateMipmaps:!1}),F.map.texture.name=O.name+".shadowMap",F.map.depthTexture=new nr(r.x,r.y,Gn),F.map.depthTexture.name=O.name+".shadowMapDepth",F.map.depthTexture.format=Zi,F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=kt,F.map.depthTexture.magFilter=kt}else O.isPointLight?(F.map=new il(r.x),F.map.depthTexture=new Ra(r.x,ai)):(F.map=new Tn(r.x,r.y),F.map.depthTexture=new nr(r.x,r.y,ai)),F.map.depthTexture.name=O.name+".shadowMap",F.map.depthTexture.format=Zi,this.type===Xa?(F.map.depthTexture.compareFunction=k?vd:bd,F.map.depthTexture.minFilter=Ht,F.map.depthTexture.magFilter=Ht):(F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=kt,F.map.depthTexture.magFilter=kt);F.camera.updateProjectionMatrix()}F.map.isWebGLCubeRenderTarget!==!0&&(F.map.width!==r.x||F.map.height!==r.y)&&F.map.setSize(r.x,r.y);let X=F.map.isWebGLCubeRenderTarget?6:F.getViewportCount();O.isPointLight!==!0&&F.updateMatrices(O,w);let V=(F.camera.layers.mask&4294967294)!==0?F.camera.layers:w.layers;for(let re=0;re0||v.map&&v.alphaTest>0||v.alphaToCoverage===!0){let L=T.uuid,U=v.uuid,C=c[L];C===void 0&&(C={},c[L]=C);let I=C[U];I===void 0&&(I=T.clone(),C[U]=I,v.addEventListener("dispose",M)),T=I}if(T.visible=v.visible,T.wireframe=v.wireframe,P===Mo?T.side=v.shadowSide!==null?v.shadowSide:v.side:T.side=v.shadowSide!==null?v.shadowSide:h[v.side],T.alphaMap=v.alphaMap,T.alphaTest=v.alphaToCoverage===!0?.5:v.alphaTest,T.map=v.map,T.clipShadows=v.clipShadows,T.clippingPlanes=v.clippingPlanes,T.clipIntersection=v.clipIntersection,T.displacementMap=v.displacementMap,T.displacementScale=v.displacementScale,T.displacementBias=v.displacementBias,T.wireframeLinewidth=v.wireframeLinewidth,T.linewidth=v.linewidth,w.isPointLight===!0&&T.isMeshDistanceMaterial===!0){let L=i.properties.get(T);L.light=w}return T}function b(S,v,w,P,T,R){if(S.visible===!1)return;if(S.layers.test(T)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&R===Mo)&&(!S.frustumCulled||S.intersectsFrustum(n))){S.modelViewMatrix.multiplyMatrices(w.matrixWorldInverse,S.matrixWorld);let C=e.update(S),I=S.material;if(Array.isArray(I)){let O=C.groups;for(let F=0,H=O.length;F=1):k.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),F=H>=2);let X=null,V={},re=i.getParameter(i.SCISSOR_BOX),ye=i.getParameter(i.VIEWPORT),Y=new vt().fromArray(re),Q=new vt().fromArray(ye);function se(B,ne,j,pe){let ce=new Uint8Array(4),fe=i.createTexture();i.bindTexture(B,fe),i.texParameteri(B,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(B,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let De=0;De"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new ke,u=new WeakMap,h=new Set,f,d=new WeakMap,p=new Set,x=new FinalizationRegistry(N=>p.delete(N)),m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(N,A){return m?new OffscreenCanvas(N,A):uo("canvas")}function y(N,A,K){let oe=1,ie=qe(N);if((ie.width>K||ie.height>K)&&(oe=K/Math.max(ie.width,ie.height)),oe<1)if(typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&N instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&N instanceof ImageBitmap||typeof VideoFrame<"u"&&N instanceof VideoFrame){let he=Math.floor(oe*ie.width),ge=Math.floor(oe*ie.height);f===void 0&&(f=g(he,ge));let ee=A?g(he,ge):f;return ee.width=he,ee.height=ge,ee.getContext("2d").drawImage(N,0,0,he,ge),Oe("WebGLRenderer: Texture has been resized from ("+ie.width+"x"+ie.height+") to ("+he+"x"+ge+")."),ee}else return"data"in N&&Oe("WebGLRenderer: Image in DataTexture is too big ("+ie.width+"x"+ie.height+")."),N;return N}function _(N){return N.generateMipmaps}function b(N){i.generateMipmap(N)}function M(N){return N.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:N.isWebGL3DRenderTarget?i.TEXTURE_3D:N.isWebGLArrayRenderTarget||N.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function S(N,A,K,oe,ie,he=!1){if(N!==null){if(i[N]!==void 0)return i[N];Oe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+N+"'")}let ge;oe&&(ge=e.get("EXT_texture_norm16"),ge||Oe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let ee=A;if(A===i.RED&&(K===i.FLOAT&&(ee=i.R32F),K===i.HALF_FLOAT&&(ee=i.R16F),K===i.UNSIGNED_BYTE&&(ee=i.R8),K===i.UNSIGNED_SHORT&&ge&&(ee=ge.R16_EXT),K===i.SHORT&&ge&&(ee=ge.R16_SNORM_EXT)),A===i.RED_INTEGER&&(K===i.UNSIGNED_BYTE&&(ee=i.R8UI),K===i.UNSIGNED_SHORT&&(ee=i.R16UI),K===i.UNSIGNED_INT&&(ee=i.R32UI),K===i.BYTE&&(ee=i.R8I),K===i.SHORT&&(ee=i.R16I),K===i.INT&&(ee=i.R32I)),A===i.RG&&(K===i.FLOAT&&(ee=i.RG32F),K===i.HALF_FLOAT&&(ee=i.RG16F),K===i.UNSIGNED_BYTE&&(ee=i.RG8),K===i.UNSIGNED_SHORT&&ge&&(ee=ge.RG16_EXT),K===i.SHORT&&ge&&(ee=ge.RG16_SNORM_EXT)),A===i.RG_INTEGER&&(K===i.UNSIGNED_BYTE&&(ee=i.RG8UI),K===i.UNSIGNED_SHORT&&(ee=i.RG16UI),K===i.UNSIGNED_INT&&(ee=i.RG32UI),K===i.BYTE&&(ee=i.RG8I),K===i.SHORT&&(ee=i.RG16I),K===i.INT&&(ee=i.RG32I)),A===i.RGB_INTEGER&&(K===i.UNSIGNED_BYTE&&(ee=i.RGB8UI),K===i.UNSIGNED_SHORT&&(ee=i.RGB16UI),K===i.UNSIGNED_INT&&(ee=i.RGB32UI),K===i.BYTE&&(ee=i.RGB8I),K===i.SHORT&&(ee=i.RGB16I),K===i.INT&&(ee=i.RGB32I)),A===i.RGBA_INTEGER&&(K===i.UNSIGNED_BYTE&&(ee=i.RGBA8UI),K===i.UNSIGNED_SHORT&&(ee=i.RGBA16UI),K===i.UNSIGNED_INT&&(ee=i.RGBA32UI),K===i.BYTE&&(ee=i.RGBA8I),K===i.SHORT&&(ee=i.RGBA16I),K===i.INT&&(ee=i.RGBA32I)),A===i.RGB&&(K===i.UNSIGNED_SHORT&&ge&&(ee=ge.RGB16_EXT),K===i.SHORT&&ge&&(ee=ge.RGB16_SNORM_EXT),K===i.UNSIGNED_INT_5_9_9_9_REV&&(ee=i.RGB9_E5),K===i.UNSIGNED_INT_10F_11F_11F_REV&&(ee=i.R11F_G11F_B10F)),A===i.RGBA){let te=he?va:it.getTransfer(ie);K===i.FLOAT&&(ee=i.RGBA32F),K===i.HALF_FLOAT&&(ee=i.RGBA16F),K===i.UNSIGNED_BYTE&&(ee=te===Mt?i.SRGB8_ALPHA8:i.RGBA8),K===i.UNSIGNED_SHORT&&ge&&(ee=ge.RGBA16_EXT),K===i.SHORT&&ge&&(ee=ge.RGBA16_SNORM_EXT),K===i.UNSIGNED_SHORT_4_4_4_4&&(ee=i.RGBA4),K===i.UNSIGNED_SHORT_5_5_5_1&&(ee=i.RGB5_A1)}return(ee===i.R16F||ee===i.R32F||ee===i.RG16F||ee===i.RG32F||ee===i.RGBA16F||ee===i.RGBA32F)&&e.get("EXT_color_buffer_float"),ee}function v(N,A){let K;return N?A===null||A===ai||A===vs?K=i.DEPTH24_STENCIL8:A===Gn?K=i.DEPTH32F_STENCIL8:A===To&&(K=i.DEPTH24_STENCIL8,Oe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):A===null||A===ai||A===vs?K=i.DEPTH_COMPONENT24:A===Gn?K=i.DEPTH_COMPONENT32F:A===To&&(K=i.DEPTH_COMPONENT16),K}function w(N,A){return _(N)===!0||N.isFramebufferTexture&&N.minFilter!==kt&&N.minFilter!==Ht?Math.log2(Math.max(A.width,A.height))+1:N.mipmaps.length>0?N.mipmaps.length:N.isCompressedTexture&&Array.isArray(N.image)?A.mipmaps.length:1}function P(N){let A=new WeakRef(N);n.get(N).__ref=A,p.add(A),x.register(N,A,A)}function T(N){let A=n.get(N).__ref;A!==void 0&&(p.delete(A),x.unregister(A))}function R(N){U(N.target)}function L(N){C(N.target)}function U(N){N.removeEventListener("dispose",R),T(N),O(N),N.isVideoTexture&&u.delete(N),N.isHTMLTexture&&h.delete(N)}function C(N){N.removeEventListener("dispose",L),T(N),H(N)}function I(){for(let N of p){let A=N.deref();A!==void 0&&(A.isRenderTarget===!0?C(A):U(A))}p.clear(),h.clear()}function O(N){let A=n.get(N);if(A.__webglInit===void 0)return;let K=N.source,oe=d.get(K);if(oe){let ie=oe[A.__cacheKey];ie.usedTimes--,ie.usedTimes===0&&F(N),Object.keys(oe).length===0&&d.delete(K)}n.remove(N)}function F(N){let A=n.get(N);i.deleteTexture(A.__webglTexture);let K=N.source,oe=d.get(K);delete oe[A.__cacheKey],o.memory.textures--}function H(N){let A=n.get(N);A.__depthDisposeCallback&&A.__depthDisposeCallback();let K=N.depthTexture;if(K&&K.renderTarget===N&&U(K),N.isWebGLCubeRenderTarget)for(let ie=0;ie<6;ie++){if(Array.isArray(A.__webglFramebuffer[ie]))for(let he=0;he=r.maxTextures&&Oe("WebGLTextures: Trying to use "+(N+1)+" texture units while this GPU supports only "+r.maxTextures),k+=1,N}function Y(N){let A=[];return A.push(N.wrapS),A.push(N.wrapT),A.push(N.wrapR||0),A.push(N.magFilter),A.push(N.minFilter),A.push(N.anisotropy),A.push(N.internalFormat),A.push(N.format),A.push(N.type),A.push(N.generateMipmaps),A.push(N.mipmapsAutoUpdate),A.push(N.premultiplyAlpha),A.push(N.flipY),A.push(N.unpackAlignment),A.push(N.colorSpace),A.join()}function Q(N,A){let K=n.get(N);if(N.isVideoTexture&&Zt(N),N.isRenderTargetTexture===!1&&N.isExternalTexture!==!0&&N.version>0&&K.__version!==N.version){let oe=N.image;if(oe===null)Oe("WebGLRenderer: Texture marked for update but no image data found.");else if(oe.complete===!1)Oe("WebGLRenderer: Texture marked for update but image is incomplete");else{Bt(K,N,A);return}}else N.isExternalTexture&&(K.__webglTexture=N.sourceTexture?N.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,K.__webglTexture,i.TEXTURE0+A)}function se(N,A){let K=n.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&K.__version!==N.version){Bt(K,N,A);return}else N.isExternalTexture&&(K.__webglTexture=N.sourceTexture?N.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,K.__webglTexture,i.TEXTURE0+A)}function we(N,A){let K=n.get(N);if(N.isRenderTargetTexture===!1&&N.version>0&&K.__version!==N.version){Bt(K,N,A);return}t.bindTexture(i.TEXTURE_3D,K.__webglTexture,i.TEXTURE0+A)}function le(N,A){let K=n.get(N);if(N.version>0&&K.__version!==N.version){on(K,N,A);return}t.bindTexture(i.TEXTURE_CUBE_MAP,K.__webglTexture,i.TEXTURE0+A)}let Ne={[zn]:i.REPEAT,[ln]:i.CLAMP_TO_EDGE,[Ir]:i.MIRRORED_REPEAT},at={[kt]:i.NEAREST,[wo]:i.NEAREST_MIPMAP_NEAREST,[ur]:i.NEAREST_MIPMAP_LINEAR,[Ht]:i.LINEAR,[Ur]:i.LINEAR_MIPMAP_NEAREST,[Nn]:i.LINEAR_MIPMAP_LINEAR},Ae={[Ix]:i.NEVER,[_d]:i.ALWAYS,[Lx]:i.LESS,[bd]:i.LEQUAL,[Fx]:i.EQUAL,[vd]:i.GEQUAL,[Nx]:i.GREATER,[Ox]:i.NOTEQUAL};function ft(N,A){if(A.type===Gn&&e.has("OES_texture_float_linear")===!1&&(A.magFilter===Ht||A.magFilter===Ur||A.magFilter===ur||A.magFilter===Nn||A.minFilter===Ht||A.minFilter===Ur||A.minFilter===ur||A.minFilter===Nn)&&Oe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(N,i.TEXTURE_WRAP_S,Ne[A.wrapS]),i.texParameteri(N,i.TEXTURE_WRAP_T,Ne[A.wrapT]),(N===i.TEXTURE_3D||N===i.TEXTURE_2D_ARRAY)&&i.texParameteri(N,i.TEXTURE_WRAP_R,Ne[A.wrapR]),i.texParameteri(N,i.TEXTURE_MAG_FILTER,at[A.magFilter]),i.texParameteri(N,i.TEXTURE_MIN_FILTER,at[A.minFilter]),A.compareFunction&&(i.texParameteri(N,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(N,i.TEXTURE_COMPARE_FUNC,Ae[A.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(A.magFilter===kt||A.minFilter!==ur&&A.minFilter!==Nn||A.type===Gn&&e.has("OES_texture_float_linear")===!1)return;if(A.anisotropy>1||n.get(A).__currentAnisotropy){let K=e.get("EXT_texture_filter_anisotropic");i.texParameterf(N,K.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(A.anisotropy,r.getMaxAnisotropy())),n.get(A).__currentAnisotropy=A.anisotropy}}}function yt(N,A){let K=!1;N.__webglInit===void 0&&(N.__webglInit=!0,A.addEventListener("dispose",R),P(A));let oe=A.source,ie=d.get(oe);ie===void 0&&(ie={},d.set(oe,ie));let he=Y(A);if(he!==N.__cacheKey){ie[he]===void 0&&(ie[he]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,K=!0),ie[he].usedTimes++;let ge=ie[N.__cacheKey];ge!==void 0&&(ie[N.__cacheKey].usedTimes--,ge.usedTimes===0&&F(A)),N.__cacheKey=he,N.__webglTexture=ie[he].texture}return K}function nt(N,A,K){return Math.floor(Math.floor(N/K)/A)}function Yt(N,A,K,oe){let he=N.updateRanges;if(he.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,A.width,A.height,K,oe,A.data);else{he.sort((B,ne)=>B.start-ne.start);let ge=0;for(let B=1;B0){ce&&fe&&t.texStorage2D(i.TEXTURE_2D,Qe,ne,pe[0].width,pe[0].height);for(let ae=0,Ue=pe.length;ae0){let je=Ld(j.width,j.height,A.format,A.type);for(let ve of A.layerUpdates){let St=j.data.subarray(ve*je/j.data.BYTES_PER_ELEMENT,(ve+1)*je/j.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ae,0,0,ve,j.width,j.height,1,de,St)}}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,ae,0,0,0,j.width,j.height,te.depth,de,j.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,ae,ne,j.width,j.height,te.depth,0,j.data,0,0);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ce?De&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,ae,0,0,0,j.width,j.height,te.depth,de,B,j.data):t.texImage3D(i.TEXTURE_2D_ARRAY,ae,ne,j.width,j.height,te.depth,0,de,B,j.data);A.layerUpdates.size>0&&A.clearLayerUpdates()}else{ce&&fe&&t.texStorage2D(i.TEXTURE_2D,Qe,ne,pe[0].width,pe[0].height);for(let ae=0,Ue=pe.length;ae0){let ae=Ld(te.width,te.height,A.format,A.type);for(let Ue of A.layerUpdates){let je=te.data.subarray(Ue*ae/te.data.BYTES_PER_ELEMENT,(Ue+1)*ae/te.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,Ue,te.width,te.height,1,de,B,je)}A.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,te.width,te.height,te.depth,de,B,te.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ne,te.width,te.height,te.depth,0,de,B,te.data);else if(A.isData3DTexture)ce?(fe&&t.texStorage3D(i.TEXTURE_3D,Qe,ne,te.width,te.height,te.depth),De&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,te.width,te.height,te.depth,de,B,te.data)):t.texImage3D(i.TEXTURE_3D,0,ne,te.width,te.height,te.depth,0,de,B,te.data);else if(A.isFramebufferTexture){if(fe)if(ce)t.texStorage2D(i.TEXTURE_2D,Qe,ne,te.width,te.height);else{let ae=te.width,Ue=te.height;for(let je=0;je>=1,Ue>>=1}}else if(A.isHTMLTexture){if("texElementImage2D"in i){let ae=i.canvas;if(ae.hasAttribute("layoutsubtree")||ae.setAttribute("layoutsubtree","true"),te.parentNode!==ae){ae.appendChild(te),h.add(A),ae.onpaint=Ue=>{let je=Ue.changedElements;for(let ve of h)je.includes(ve.image)&&(ve.needsUpdate=!0)},ae.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,te);else{let je=i.RGBA,ve=i.RGBA,St=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,je,ve,St,te)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(pe.length>0){if(ce&&fe){let ae=qe(pe[0]);t.texStorage2D(i.TEXTURE_2D,Qe,ne,ae.width,ae.height)}for(let ae=0,Ue=pe.length;ae0&&Ue++;let ve=qe(ne[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Ue,fe,ve.width,ve.height)}for(let ve=0;ve<6;ve++)if(B){De?ae&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,0,0,ne[ve].width,ne[ve].height,pe,ce,ne[ve].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ve,0,fe,ne[ve].width,ne[ve].height,0,pe,ce,ne[ve].data);for(let St=0;St>he),j=Math.max(1,A.height>>he);ie===i.TEXTURE_3D||ie===i.TEXTURE_2D_ARRAY?t.texImage3D(ie,he,te,ne,j,A.depth,0,ge,ee,null):t.texImage2D(ie,he,te,ne,j,0,ge,ee,null)}t.bindFramebuffer(i.FRAMEBUFFER,N),be(A)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,oe,ie,B.__webglTexture,0,It(A)):(ie===i.TEXTURE_2D||ie>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&ie<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,oe,ie,B.__webglTexture,he),t.bindFramebuffer(i.FRAMEBUFFER,null)}function xi(N,A,K){if(i.bindRenderbuffer(i.RENDERBUFFER,N),A.depthBuffer){let oe=A.depthTexture,ie=oe&&oe.isDepthTexture?oe.type:null,he=v(A.stencilBuffer,ie),ge=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;be(A)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,It(A),he,A.width,A.height):K?i.renderbufferStorageMultisample(i.RENDERBUFFER,It(A),he,A.width,A.height):i.renderbufferStorage(i.RENDERBUFFER,he,A.width,A.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ge,i.RENDERBUFFER,N)}else{let oe=A.textures;for(let ie=0;ie{delete A.__boundDepthTexture,delete A.__depthDisposeCallback,oe.removeEventListener("dispose",ie)};oe.addEventListener("dispose",ie),A.__depthDisposeCallback=ie}A.__boundDepthTexture=oe}if(N.depthTexture&&!A.__autoAllocateDepthBuffer)if(K)for(let oe=0;oe<6;oe++)en(A.__webglFramebuffer[oe],N,oe);else N.texture.mipmaps.length>0?en(A.__webglFramebuffer[0],N,0):en(A.__webglFramebuffer,N,0);else if(K){A.__webglDepthbuffer=[];for(let oe=0;oe<6;oe++)if(t.bindFramebuffer(i.FRAMEBUFFER,A.__webglFramebuffer[oe]),A.__webglDepthbuffer[oe]===void 0)A.__webglDepthbuffer[oe]=i.createRenderbuffer(),xi(A.__webglDepthbuffer[oe],N,!1);else{let ie=N.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,he=A.__webglDepthbuffer[oe];i.bindRenderbuffer(i.RENDERBUFFER,he),i.framebufferRenderbuffer(i.FRAMEBUFFER,ie,i.RENDERBUFFER,he)}}else if(N.texture.mipmaps.length>0?t.bindFramebuffer(i.FRAMEBUFFER,A.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,A.__webglFramebuffer),A.__webglDepthbuffer===void 0)A.__webglDepthbuffer=i.createRenderbuffer(),xi(A.__webglDepthbuffer,N,!1);else{let ie=N.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,he=A.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,he),i.framebufferRenderbuffer(i.FRAMEBUFFER,ie,i.RENDERBUFFER,he)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Xn(N,A,K){let oe=n.get(N);A!==void 0&&Nt(oe.__webglFramebuffer,N,N.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),K!==void 0&&Wn(N)}function Yn(N){let A=N.texture,K=n.get(N),oe=n.get(A);N.addEventListener("dispose",L),P(N);let ie=N.textures,he=N.isWebGLCubeRenderTarget===!0,ge=ie.length>1;if(ge||(oe.__webglTexture===void 0&&(oe.__webglTexture=i.createTexture()),oe.__version=A.version,o.memory.textures++),he){K.__webglFramebuffer=[];for(let ee=0;ee<6;ee++)if(A.mipmaps.length>0){K.__webglFramebuffer[ee]=[];for(let te=0;te0){K.__webglFramebuffer=[];for(let ee=0;ee0&&be(N)===!1){K.__webglMultisampledFramebuffer=i.createFramebuffer(),K.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,K.__webglMultisampledFramebuffer);for(let ee=0;ee0)for(let te=0;te0&&i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,A.mipmaps.length-1),t.unbindTexture()}else if(ge){for(let ee=0,te=ie.length;ee0)for(let te=0;te0&&i.texParameteri(ee,i.TEXTURE_MAX_LEVEL,A.mipmaps.length-1),t.unbindTexture()}N.depthBuffer&&Wn(N)}function G(N){let A=N.textures;for(let K=0,oe=A.length;K0){if(be(N)===!1){let A=N.textures,K=N.width,oe=N.height,ie=i.COLOR_BUFFER_BIT,he=N.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ge=n.get(N),ee=A.length>1;if(ee)for(let de=0;de0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ge.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ge.__webglFramebuffer);for(let de=0;de0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&A.__useRenderToTexture!==!1}function Zt(N){let A=o.render.frame;u.get(N)!==A&&(u.set(N,A),N.update())}function Ve(N,A){let K=N.colorSpace,oe=N.format,ie=N.type;return N.isCompressedTexture===!0||N.isVideoTexture===!0||K!==Sn&&K!==ci&&(it.getTransfer(K)===Mt?(oe!==Dn||ie!==On)&&Oe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):We("WebGLTextures: Unsupported texture color space:",K)),A}function qe(N){return typeof HTMLImageElement<"u"&&N instanceof HTMLImageElement?(c.width=N.naturalWidth||N.width,c.height=N.naturalHeight||N.height):typeof VideoFrame<"u"&&N instanceof VideoFrame?(c.width=N.displayWidth,c.height=N.displayHeight):(c.width=N.width,c.height=N.height),c}this.allocateTextureUnit=ye,this.resetTextureUnits=X,this.getTextureUnits=V,this.setTextureUnits=re,this.setTexture2D=Q,this.setTexture2DArray=se,this.setTexture3D=we,this.setTextureCube=le,this.rebindTextures=Xn,this.setupRenderTarget=Yn,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=Pt,this.setupDepthRenderbuffer=Wn,this.setupFrameBufferTexture=Nt,this.useMultisampledRTT=be,this.dispose=I}function XE(i,e){function t(n,r=ci){let s,o=it.getTransfer(r);if(n===On)return i.UNSIGNED_BYTE;if(n===Qc)return i.UNSIGNED_SHORT_4_4_4_4;if(n===eu)return i.UNSIGNED_SHORT_5_5_5_1;if(n===pd)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===md)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===fd)return i.BYTE;if(n===dd)return i.SHORT;if(n===To)return i.UNSIGNED_SHORT;if(n===jc)return i.INT;if(n===ai)return i.UNSIGNED_INT;if(n===Gn)return i.FLOAT;if(n===li)return i.HALF_FLOAT;if(n===gd)return i.ALPHA;if(n===xd)return i.RGB;if(n===Dn)return i.RGBA;if(n===Zi)return i.DEPTH_COMPONENT;if(n===hr)return i.DEPTH_STENCIL;if(n===tu)return i.RED;if(n===nu)return i.RED_INTEGER;if(n===Br)return i.RG;if(n===iu)return i.RG_INTEGER;if(n===ru)return i.RGBA_INTEGER;if(n===qa||n===$a||n===Ka||n===Za)if(o===Mt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===qa)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===$a)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ka)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Za)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===qa)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===$a)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ka)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Za)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===su||n===ou||n===au||n===lu)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===su)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ou)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===au)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===lu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===cu||n===uu||n===hu||n===fu||n===du||n===Ja||n===pu)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===cu||n===uu)return o===Mt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===hu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(n===fu)return s.COMPRESSED_R11_EAC;if(n===du)return s.COMPRESSED_SIGNED_R11_EAC;if(n===Ja)return s.COMPRESSED_RG11_EAC;if(n===pu)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===mu||n===gu||n===xu||n===yu||n===bu||n===vu||n===_u||n===Mu||n===Su||n===wu||n===Tu||n===Au||n===Eu||n===Ru)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===mu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===gu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===xu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===yu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===bu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===vu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===_u)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Mu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Su)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===wu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Tu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Au)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Eu)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ru)return o===Mt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Cu||n===Pu||n===Iu)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Cu)return o===Mt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Pu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Iu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Lu||n===Fu||n===ja||n===Nu)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Lu)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Fu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ja)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Nu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===vs?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var YE=` void main() { gl_Position = vec4( position, 1.0 ); -}`,XE=` +}`,qE=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; @@ -4223,7 +4223,7 @@ void main() { } -}`,Xd=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Ra(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new Si({vertexShader:WE,fragmentShader:XE,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Se(new sn(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Yd=class extends vi{constructor(e,t){super();let n=this,r=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,f=null,d=null,p=null,x=typeof XRWebGLBinding<"u",m=new Xd,g={},y=t.getContextAttributes(),_=null,b=null,M=[],S=[],v=new Ue,w=null,P=null,T=new Jt;T.viewport=new vt;let R=new Jt;R.viewport=new vt;let L=[T,R],k=new Yc,C=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let Q=M[Y];return Q===void 0&&(Q=new mo,M[Y]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(Y){let Q=M[Y];return Q===void 0&&(Q=new mo,M[Y]=Q),Q.getGripSpace()},this.getHand=function(Y){let Q=M[Y];return Q===void 0&&(Q=new mo,M[Y]=Q),Q.getHandSpace()};function O(Y){let Q=S.indexOf(Y.inputSource);if(Q===-1)return;let se=M[Q];se!==void 0&&(se.update(Y.inputSource,Y.frame,c||o),se.dispatchEvent({type:Y.type,data:Y.inputSource}))}function F(){r.removeEventListener("select",O),r.removeEventListener("selectstart",O),r.removeEventListener("selectend",O),r.removeEventListener("squeeze",O),r.removeEventListener("squeezestart",O),r.removeEventListener("squeezeend",O),r.removeEventListener("end",F),r.removeEventListener("inputsourceschange",H);for(let Y=0;Y=0&&(S[we]=null,M[we].disconnect(se))}for(let Q=0;Q=S.length){S.push(se),we=Ne;break}else if(S[Ne]===null){S[Ne]=se,we=Ne;break}if(we===-1)break}let le=M[we];le&&le.connect(se)}}function U(Y,Q){Q===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(Q.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(r===null)return;let Q=Y.near,se=Y.far;m.texture!==null&&(m.depthNear>0&&(Q=m.depthNear),m.depthFar>0&&(se=m.depthFar)),k.near=R.near=T.near=Q,k.far=R.far=T.far=se,(C!==k.near||I!==k.far)&&(r.updateRenderState({depthNear:k.near,depthFar:k.far}),C=k.near,I=k.far),k.layers.mask=Y.layers.mask|6,T.layers.mask=k.layers.mask&-5,R.layers.mask=k.layers.mask&-3;let we=Y.parent,le=k.cameras;U(k,we);for(let Ne=0;Ne0&&(m.alphaTest.value=g.alphaTest);let y=e.get(g),_=y.envMap,b=y.envMapRotation;_&&(m.envMap.value=_,m.envMapRotation.value.setFromMatrix4(YE.makeRotationFromEuler(b)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Ty),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function o(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function a(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function l(m,g,y,_){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=_*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function h(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function f(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function d(m,g,y){m.ior.value=g.ior,g.diffuseRoughness>0&&(m.diffuseRoughness.value=g.diffuseRoughness,g.diffuseRoughnessMap&&(m.diffuseRoughnessMap.value=g.diffuseRoughnessMap,t(g.diffuseRoughnessMap,m.diffuseRoughnessMapTransform))),g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===un&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.retroreflectivity>0&&(m.retroreflectivity.value=g.retroreflectivity),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessMinimum,m.iridescenceThicknessMaximum.value=g.iridescenceThicknessMaximum,g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function x(m,g){let y=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(y.matrixWorld),m.nearDistance.value=y.shadow.camera.near,m.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function $E(i,e,t,n){let r={},s={};function o(y,_){let b=_.program;n.uniformBlockBinding(y,b,r[y.id])}function a(y,_){let b=r[y.id];b===void 0&&(p(y),b=l(y),r[y.id]=b,y.addEventListener("dispose",m));let M=_.program;n.updateUBOMapping(y,M);let S=e.render.frame;s[y.id]!==S&&(c(y),s[y.id]=S)}function l(y){let _=i.createBuffer(),b=y.__size,M=y.usage;return i.bindBuffer(i.UNIFORM_BUFFER,_),i.bufferData(i.UNIFORM_BUFFER,b,M),i.bindBuffer(i.UNIFORM_BUFFER,null),_}function c(y){let _=r[y.id],b=y.uniforms,M=y.__cache;i.bindBuffer(i.UNIFORM_BUFFER,_);for(let S=0,v=b.length;S0&&(b+=M-S),y.__size=b,y.__cache={},this}function x(y,_){let b={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(b.boundary=4,b.storage=4):y.isVector2?(b.boundary=8,b.storage=8):y.isVector3||y.isColor?(b.boundary=16,b.storage=12):y.isVector4?(b.boundary=16,b.storage=16):y.isMatrix3?(b.boundary=16,b.storage=48):y.isMatrix4?(b.boundary=16,b.storage=64):y.isTexture?Oe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(b.boundary=16,b.storage=y.byteLength):Oe("WebGLRenderer: Unsupported uniform value type.",y),_===!0&&(b.boundary=16,b.storage=Math.ceil(b.storage/16)*16),b}function m(y){let _=y.target;_.removeEventListener("dispose",m),i.deleteBuffer(r[_.id]),delete r[_.id],delete s[_.id]}function g(){for(let y in r)i.deleteBuffer(r[y]);r={},s={}}return{bind:o,update:a,dispose:g}}var KE=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Pi=null;function ZE(){return Pi===null&&(Pi=new xo(KE,16,16,Br,li),Pi.name="DFG_LUT",Pi.minFilter=Ht,Pi.magFilter=Ht,Pi.wrapS=ln,Pi.wrapT=ln,Pi.generateMipmaps=!1,Pi.needsUpdate=!0),Pi}var Vr=class{constructor(e={}){let{canvas:t=Ox(),context:n=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:f=!1,outputBufferType:d=On}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=o;let x=d,m=new Set([iu,nu,tu]),g=new Set([On,ai,To,vs,jc,Qc]),y=new Uint32Array(4),_=new Int32Array(4),b={textures:[],min:[],max:[],resolution:[]},M=null,S=null,v=[],w=[],P=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Ri,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let T=this,R=!1,L=null,k=null,C=null,I=null;this._outputColorSpace=dt;let O=0,F=0,H=null,U=-1,X=null,V=new vt,re=new vt,ye=null,Y=new W(0),Q=0,se=t.width,we=t.height,le=1,Ne=null,at=null,Ae=new vt(0,0,se,we),ft=new vt(0,0,se,we),yt=!1,nt=new Nr,Yt=new Fc,Bt=!1,on=!1,Nt=new ze,xi=new D,en=new vt,Wn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Xn=!1;function Yn(){return H===null?le:1}let G=n;function qn(E,z){return t.getContext(E,z)}let Pt,It,be,Zt,Ve,qe,N,A,K,oe,ie,he,ge,ee,te,de,B,ne,j,pe,ce,fe,De;try{let E={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"187"}`),t.addEventListener("webglcontextlost",ke,!1),t.addEventListener("webglcontextrestored",je,!1),t.addEventListener("webglcontextcreationerror",ve,!1),G===null){let z="webgl2";if(G=qn(z,E),G===null)throw qn(z)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Qe()}catch(E){throw t.removeEventListener("webglcontextlost",ke,!1),t.removeEventListener("webglcontextrestored",je,!1),t.removeEventListener("webglcontextcreationerror",ve,!1),We("WebGLRenderer: "+E.message),E}function Qe(){Pt=new aA(G),Pt.init(),ce=new HE(G,Pt),It=new ZT(G,Pt,e,ce),be=new VE(G,Pt),It.reversedDepthBuffer&&f&&be.buffers.depth.setReversed(!0),k=G.createFramebuffer(),C=G.createFramebuffer(),I=G.createFramebuffer(),Zt=new uA(G),Ve=new EE,qe=new GE(G,Pt,be,Ve,It,ce,Zt),N=new oA(T),A=new fw(G),fe=new $T(G,A),K=new lA(G,A,Zt,fe),oe=new fA(G,K,A,fe,Zt),ne=new hA(G,It,qe),te=new JT(Ve),ie=new AE(T,N,Pt,It,fe,te),he=new qE(T,Ve),ge=new CE,ee=new OE(Pt),B=new qT(T,N,be,oe,p,l),de=new zE(T,oe,It),De=new $E(G,Zt,It,be),j=new KT(G,Pt,Zt),pe=new cA(G,Pt,Zt),Zt.programs=ie.programs,T.capabilities=It,T.extensions=Pt,T.properties=Ve,T.renderLists=ge,T.shadowMap=de,T.state=be,T.info=Zt}x!==On&&(P=new pA(x,t.width,t.height,a,r,s));let ae=new Yd(T,G);this.xr=ae,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){let E=Pt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){let E=Pt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return le},this.setPixelRatio=function(E){E!==void 0&&(le=E,this.setSize(se,we,!1))},this.getSize=function(E){return E.set(se,we)},this.setSize=function(E,z,J=!0){if(ae.isPresenting){Oe("WebGLRenderer: Can't change size while VR device is presenting.");return}se=E,we=z,t.width=Math.floor(E*le),t.height=Math.floor(z*le),J===!0&&(t.style.width=E+"px",t.style.height=z+"px"),P!==null&&P.setSize(t.width,t.height),this.setViewport(0,0,E,z)},this.getDrawingBufferSize=function(E){return E.set(se*le,we*le).floor()},this.setDrawingBufferSize=function(E,z,J){se=E,we=z,le=J,t.width=Math.floor(E*J),t.height=Math.floor(z*J),this.setViewport(0,0,E,z)},this.setEffects=function(E){if(x===On){We("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let z=0;z{function xe(){if($.forEach(function(Ee){let Me=Ve.get(Ee).currentProgram;(Me===void 0||Me.isReady())&&$.delete(Ee)}),$.size===0){Z(E);return}setTimeout(xe,10)}Pt.get("KHR_parallel_shader_compile")!==null?xe():setTimeout(xe,10)})};let af=null;function C1(E){af&&af(E)}function A0(){Kr.stop()}function E0(){Kr.start()}let Kr=new my;Kr.setAnimationLoop(C1),typeof self<"u"&&Kr.setContext(self),this.setAnimationLoop=function(E){af=E,ae.setAnimationLoop(E),E===null?Kr.stop():Kr.start()},ae.addEventListener("sessionstart",A0),ae.addEventListener("sessionend",E0),this.render=function(E,z){if(z!==void 0&&z.isCamera!==!0){We("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;L!==null&&L.renderStart(E,z);let J=ae.enabled===!0&&ae.isPresenting===!0,$=P!==null&&(H===null||J)&&P.begin(T,H);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),z.parent===null&&z.matrixWorldAutoUpdate===!0&&z.updateMatrixWorld(),ae.enabled===!0&&ae.isPresenting===!0&&(P===null||P.isCompositing()===!1)&&(ae.cameraAutoUpdate===!0&&ae.updateCamera(z),z=ae.getCamera()),E.isScene===!0&&E.onBeforeRender(T,E,z,H),S=ee.get(E,w.length),S.init(z),S.state.textureUnits=qe.getTextureUnits(),w.push(S),Nt.multiplyMatrices(z.projectionMatrix,z.matrixWorldInverse),z.isArrayCamera?Yt.setFromArrayCamera(z):nt.setFromProjectionMatrix(Nt,Kn,z.reversedDepth),on=this.localClippingEnabled,Bt=te.init(this.clippingPlanes,on),M=ge.get(E,v.length),M.init(),v.push(M),this.info.render.frame++,ae.enabled===!0&&ae.isPresenting===!0){let Ee=T.xr.getDepthSensingMesh();Ee!==null&&lf(Ee,z,-1/0,T.sortObjects)}lf(E,z,0,T.sortObjects),M.finish(),L!==null&&L.updateLights(S.state.lightsArray),T.sortObjects===!0&&M.sort(Ne,at),Xn=ae.enabled===!1||ae.isPresenting===!1||ae.hasDepthSensing()===!1,Xn&&B.addToRenderList(M,E),this.info.autoReset===!0&&this.info.reset(),Bt===!0&&te.beginShadows();let Z=S.state.shadowsArray;if(de.render(Z,E,z),Bt===!0&&te.endShadows(),($&&P.hasRenderPass())===!1){let Ee=M.opaque,me=M.transmissive;if(S.setupLights(),z.isArrayCamera){let Me=z.cameras;if(me.length>0)for(let Ie=0,Ke=Me.length;Ie0&&C0(Ee,me,E,z),Xn&&B.render(E),R0(M,E,z)}H!==null&&F===0&&(qe.updateMultisampleRenderTarget(H),qe.updateRenderTargetMipmap(H)),$&&P.end(T),E.isScene===!0&&E.onAfterRender(T,E,z),fe.resetDefaultState(),U=-1,X=null,w.pop(),w.length>0?(S=w[w.length-1],qe.setTextureUnits(S.state.textureUnits),Bt===!0&&te.setGlobalState(T.clippingPlanes,S.state.camera)):S=null,v.pop(),v.length>0?M=v[v.length-1]:M=null,L!==null&&L.renderEnd()};function lf(E,z,J,$){if(E.visible===!1)return;if(E.layers.test(z.layers)){if(E.isGroup)J=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(z);else if(E.isLight)S.pushLight(E),E.castShadow&&S.pushShadow(E);else if(E.isSprite){let Ee=z.isArrayCamera?Yt:nt;if(!E.frustumCulled||E.intersectsFrustum(Ee)){$&&en.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Nt);let me=oe.update(E),Me=E.material;Me.visible&&M.push(E,me,Me,J,en.z,null,z)}}else if(E.isMesh||E.isLine||E.isPoints){let Ee=z.isArrayCamera?Yt:nt;if(!E.frustumCulled||E.intersectsFrustum(Ee)){let me=oe.update(E),Me=E.material;if($&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),en.copy(E.boundingSphere.center)):(me.boundingSphere===null&&me.computeBoundingSphere(),en.copy(me.boundingSphere.center)),en.applyMatrix4(E.matrixWorld).applyMatrix4(Nt)),Array.isArray(Me)){let Ie=me.groups;for(let Ke=0,lt=Ie.length;Ke0&&Bl(Z,z,J),xe.length>0&&Bl(xe,z,J),Ee.length>0&&Bl(Ee,z,J),be.buffers.depth.setTest(!0),be.buffers.depth.setMask(!0),be.buffers.color.setMask(!0),be.setPolygonOffset(!1)}function C0(E,z,J,$){if((J.isScene===!0?J.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[$.id]===void 0){let Re=Pt.has("EXT_color_buffer_half_float")||Pt.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[$.id]=new Tn(1,1,{generateMipmaps:!0,type:Re?li:On,minFilter:Nn,samples:Math.max(4,It.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:it.workingColorSpace})}let xe=S.state.transmissionRenderTarget[$.id],Ee=$.viewport||V;xe.setSize(Ee.z*T.transmissionResolutionScale,Ee.w*T.transmissionResolutionScale);let me=T.getRenderTarget(),Me=T.getActiveCubeFace(),Ie=T.getActiveMipmapLevel();T.setRenderTarget(xe),T.getClearColor(Y),Q=T.getClearAlpha(),Q<1&&T.setClearColor(16777215,.5),T.clear(),Xn&&B.render(J);let Ke=T.toneMapping;T.toneMapping=Ri;let lt=$.viewport;if($.viewport!==void 0&&($.viewport=void 0),S.setupLightsView($),Bt===!0&&te.setGlobalState(T.clippingPlanes,$),Bl(E,J,$),qe.updateMultisampleRenderTarget(xe),qe.updateRenderTargetMipmap(xe),Pt.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let ct=0,qt=z.length;ct0),Re=!!J.morphAttributes.position,ct=!!J.morphAttributes.normal,qt=!!J.morphAttributes.color,Rt=Ri;$.toneMapped&&(H===null||H.isXRRenderTarget===!0)&&(Rt=T.toneMapping);let At=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,hn=At!==void 0?At.length:0,Ce=Ve.get($),_n=S.state.lights;if(Bt===!0&&(on===!0||E!==X)){let Ot=E===X&&$.id===U;te.setState($,E,Ot)}let bt=!1,Zr=!1;$.version===Ce.__version?Ce.needsLights&&Ce.lightsStateVersion!==_n.state.version||Z.isBatchedMesh&&Ce.batching===!1||!Z.isBatchedMesh&&Ce.batching===!0||Z.isBatchedMesh&&Ce.batchingColor===!0&&Z._colorsTexture===null||Z.isBatchedMesh&&Ce.batchingColor===!1&&Z._colorsTexture!==null||Z.isInstancedMesh&&Ce.instancing===!1||!Z.isInstancedMesh&&Ce.instancing===!0||Z.isSkinnedMesh&&Ce.skinning===!1||!Z.isSkinnedMesh&&Ce.skinning===!0||Z.isInstancedMesh&&Ce.instancingColor===!0&&Z.instanceColor===null||Z.isInstancedMesh&&Ce.instancingColor===!1&&Z.instanceColor!==null||Z.isInstancedMesh&&Ce.instancingMorph===!0&&Z.morphTexture===null||Z.isInstancedMesh&&Ce.instancingMorph===!1&&Z.morphTexture!==null||Ce.envMap!==Ie||$.fog===!0&&Ce.fog!==xe||Ce.numClippingPlanes!==void 0&&(Ce.numClippingPlanes!==te.numPlanes||Ce.numIntersection!==te.numIntersection)||Ce.vertexAlphas!==Ke||Ce.vertexTangents!==lt||Ce.morphTargets!==Re||Ce.morphNormals!==ct||Ce.morphColors!==qt||Ce.morphTargetsCount!==hn||Ce.numLightProbeGrids!==I0(S.state.lightProbeGridArray)?bt=!0:(Ce.outputColorSpace!==me||Ce.toneMapping!==Rt)&&(Zr=!0):(bt=!0,Ce.__version=$.version);let fn=Ce.currentProgram;(bt===!0||Zr===!0)&&(fn=Zr===!0?P1($,z,Z,me,Rt):Qo($,z,Z),L&&$.isNodeMaterial&&L.onUpdateProgram($,fn,Ce));let zl=!1,Mr=!1,Jr=!1,pt=fn.getUniforms(),an=Ce.uniforms;if(be.useProgram(fn.program)&&(zl=!0,Mr=!0,Jr=!0),$.id!==U&&(U=$.id,Mr=!0),zl||X!==E){be.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),pt.setValue(G,"projectionMatrix",E.projectionMatrix),pt.setValue(G,"viewMatrix",E.matrixWorldInverse);let nn=pt.map.cameraPosition;nn!==void 0&&nn.setValue(G,xi.setFromMatrixPosition(E.matrixWorld)),It.logarithmicDepthBuffer&&pt.setValue(G,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&pt.setValue(G,"isOrthographic",E.isOrthographicCamera===!0),X!==E&&(X=E,Mr=!0,Jr=!0)}if(Ce.needsLights&&(_n.state.sunShadowMap.length>0&&pt.setValue(G,"sunShadowMap",_n.state.sunShadowMap,qe),_n.state.directionalShadowMap.length>0&&pt.setValue(G,"directionalShadowMap",_n.state.directionalShadowMap,qe),_n.state.spotShadowMap.length>0&&pt.setValue(G,"spotShadowMap",_n.state.spotShadowMap,qe),_n.state.pointShadowMap.length>0&&pt.setValue(G,"pointShadowMap",_n.state.pointShadowMap,qe)),Z.isSkinnedMesh){pt.setOptional(G,Z,"bindMatrix"),pt.setOptional(G,Z,"bindMatrixInverse");let Ot=Z.skeleton;Ot&&(Ot.boneTexture===null&&Ot.computeBoneTexture(),pt.setValue(G,"boneTexture",Ot.boneTexture,qe))}Z.isBatchedMesh&&(pt.setOptional(G,Z,"batchingTexture"),pt.setValue(G,"batchingTexture",Z._matricesTexture,qe),pt.setOptional(G,Z,"batchingIdTexture"),pt.setValue(G,"batchingIdTexture",Z._indirectTexture,qe),pt.setOptional(G,Z,"batchingColorTexture"),Z._colorsTexture!==null&&pt.setValue(G,"batchingColorTexture",Z._colorsTexture,qe));let ii=J.morphAttributes;if((ii.position!==void 0||ii.normal!==void 0||ii.color!==void 0)&&ne.update(Z,J,fn),(Mr||Ce.receiveShadow!==Z.receiveShadow)&&(Ce.receiveShadow=Z.receiveShadow,pt.setValue(G,"receiveShadow",Z.receiveShadow)),($.isMeshStandardMaterial||$.isMeshLambertMaterial||$.isMeshPhongMaterial)&&$.envMap===null&&z.environment!==null&&(an.envMapIntensity.value=z.environmentIntensity),an.dfgLUT!==void 0&&(an.dfgLUT.value=ZE()),Mr){if(pt.setValue(G,"toneMappingExposure",T.toneMappingExposure),Ce.needsLights&&L1(an,Jr),xe&&$.fog===!0&&he.refreshFogUniforms(an,xe),he.refreshMaterialUniforms(an,$,le,we,S.state.transmissionRenderTarget[E.id]),Ce.needsLights&&Ce.numLightProbeGrids>0){let Ot=b,nn=0;for(let Vi of S.state.lightProbeGridArray)Vi.texture!==null&&(Ot.textures[nn]=Vi.texture,Ot.min[nn]=Vi.boundingBox.min,Ot.max[nn]=Vi.boundingBox.max,Ot.resolution[nn]=Vi.resolution,nn++);for(let Vi in Ot)Ot[Vi].length=nn;an.probesSH.value=Ot.textures,an.probesMin.value=Ot.min,an.probesMax.value=Ot.max,an.probesResolution.value=Ot.resolution}Eo.upload(G,L0(Ce),an,qe)}if($.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(Eo.upload(G,L0(Ce),an,qe),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&pt.setValue(G,"center",Z.center),pt.setValue(G,"modelViewMatrix",Z.modelViewMatrix),pt.setValue(G,"normalMatrix",Z.normalMatrix),pt.setValue(G,"modelMatrix",Z.matrixWorld),$.uniformsGroups!==void 0){let Ot=$.uniformsGroups;for(let nn=0,Vi=Ot.length;nn0&&qe.useMultisampledRTT(E)===!1?$=Ve.get(E).__webglMultisampledFramebuffer:Array.isArray(Ie)?$=Ie[J]:$=Ie,V.copy(E.viewport),re.copy(E.scissor),ye=E.scissorTest}else V.copy(Ae).multiplyScalar(le).floor(),re.copy(ft).multiplyScalar(le).floor(),ye=yt;if(J!==0&&($=k),be.bindFramebuffer(G.FRAMEBUFFER,$)&&be.drawBuffers(E,$),be.viewport(V),be.scissor(re),be.setScissorTest(ye),Z){let me=Ve.get(E.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_CUBE_MAP_POSITIVE_X+z,me.__webglTexture,J)}else if(xe){let me=z;for(let Me=0;Me1&&G.readBuffer(G.COLOR_ATTACHMENT0+me);let Re=N0(Ie);if(Re.__formatReadable===!1){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re.__typeReadable===!1){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}z>=0&&z<=E.width-$&&J>=0&&J<=E.height-Z&&G.readPixels(z,J,$,Z,ce.convert(Ke),ce.convert(lt),xe)}finally{let Ie=H!==null?Ve.get(H).__webglFramebuffer:null;be.bindFramebuffer(G.FRAMEBUFFER,Ie)}}},this.readRenderTargetPixelsAsync=async function(E,z,J,$,Z,xe,Ee,me=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Me=Ve.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Ee!==void 0&&(Me=Me[Ee],Array.isArray(Me)&&(Me=Me[0])),Me)if(z>=0&&z<=E.width-$&&J>=0&&J<=E.height-Z){be.bindFramebuffer(G.FRAMEBUFFER,Me);let Ie=E.textures[me],Ke=Ie.format,lt=Ie.type;E.textures.length>1&&G.readBuffer(G.COLOR_ATTACHMENT0+me);let Re=N0(Ie);if(Re.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Re.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ct=G.createBuffer();G.bindBuffer(G.PIXEL_PACK_BUFFER,ct),G.bufferData(G.PIXEL_PACK_BUFFER,xe.byteLength,G.STREAM_READ),G.readPixels(z,J,$,Z,ce.convert(Ke),ce.convert(lt),0),G.bindBuffer(G.PIXEL_PACK_BUFFER,null);let qt=H!==null?Ve.get(H).__webglFramebuffer:null;be.bindFramebuffer(G.FRAMEBUFFER,qt);let Rt=G.fenceSync(G.SYNC_GPU_COMMANDS_COMPLETE,0);return G.flush(),await Ux(G,Rt,4),G.bindBuffer(G.PIXEL_PACK_BUFFER,ct),G.getBufferSubData(G.PIXEL_PACK_BUFFER,0,xe),G.bindBuffer(G.PIXEL_PACK_BUFFER,null),G.deleteBuffer(ct),G.deleteSync(Rt),xe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,z=null,J=0){let $=Math.pow(2,-J),Z=Math.floor(E.image.width*$),xe=Math.floor(E.image.height*$),Ee=z!==null?z.x:0,me=z!==null?z.y:0;qe.setTexture2D(E,0),G.copyTexSubImage2D(G.TEXTURE_2D,J,0,0,Ee,me,Z,xe),be.unbindTexture()},this.copyTextureToTexture=function(E,z,J=null,$=null,Z=0,xe=0){let Ee,me,Me,Ie,Ke,lt,Re,ct,qt,Rt=E.isCompressedTexture?E.mipmaps[xe]:E.image;if(J!==null)Ee=J.max.x-J.min.x,me=J.max.y-J.min.y,Me=J.isBox3?J.max.z-J.min.z:1,Ie=J.min.x,Ke=J.min.y,lt=J.isBox3?J.min.z:0;else{let pt=Math.pow(2,-Z);Ee=Math.floor(Rt.width*pt),me=Math.floor(Rt.height*pt),E.isDataArrayTexture?Me=Rt.depth:E.isData3DTexture?Me=Math.floor(Rt.depth*pt):Me=1,Ie=0,Ke=0,lt=0}$!==null?(Re=$.x,ct=$.y,qt=$.z):(Re=0,ct=0,qt=0);let At=ce.convert(z.format),hn=ce.convert(z.type),Ce;z.isData3DTexture?(qe.setTexture3D(z,0),Ce=G.TEXTURE_3D):z.isDataArrayTexture||z.isCompressedArrayTexture?(qe.setTexture2DArray(z,0),Ce=G.TEXTURE_2D_ARRAY):(qe.setTexture2D(z,0),Ce=G.TEXTURE_2D),be.activeTexture(G.TEXTURE0),be.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,z.flipY),be.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL,z.premultiplyAlpha),be.pixelStorei(G.UNPACK_ALIGNMENT,z.unpackAlignment);let _n=be.getParameter(G.UNPACK_ROW_LENGTH),bt=be.getParameter(G.UNPACK_IMAGE_HEIGHT),Zr=be.getParameter(G.UNPACK_SKIP_PIXELS),fn=be.getParameter(G.UNPACK_SKIP_ROWS),zl=be.getParameter(G.UNPACK_SKIP_IMAGES);be.pixelStorei(G.UNPACK_ROW_LENGTH,Rt.width),be.pixelStorei(G.UNPACK_IMAGE_HEIGHT,Rt.height),be.pixelStorei(G.UNPACK_SKIP_PIXELS,Ie),be.pixelStorei(G.UNPACK_SKIP_ROWS,Ke),be.pixelStorei(G.UNPACK_SKIP_IMAGES,lt);let Mr=E.isDataArrayTexture||E.isData3DTexture,Jr=z.isDataArrayTexture||z.isData3DTexture;if(E.isDepthTexture){let pt=Ve.get(E),an=Ve.get(z),ii=Ve.get(pt.__renderTarget),Ot=Ve.get(an.__renderTarget);be.bindFramebuffer(G.READ_FRAMEBUFFER,ii.__webglFramebuffer),be.bindFramebuffer(G.DRAW_FRAMEBUFFER,Ot.__webglFramebuffer);for(let nn=0;nn.5+.5*Math.min(1,Math.max(0,i/1.6));function Kd(i,e){let t=Math.hypot(i,e);return .8+.28*((e/t*rl[0]-i/t*rl[1]+1)/2)}var $e=-1,ol=16,fr=32,Zd=48,zu=64,Jd=128,Fi=(i,e)=>new Le(i,e),ut=class{p=[];c=[];f=[];uv;tile;surface=null;surfaceTransform=null;constructor(e=!1,t=!1){this.uv=e?[]:null,this.tile=t?[]:null}tri(e,t,n,r,s=r,o=r,a,l=$e,c=[0,1]){this.p.push(...e,...t,...n);for(let u of[r,s,o])this.c.push(u.r,u.g,u.b);this.f.push(l,l,l),this.uv?.push(...a??[.5,.5,.5,.5,.5,.5]),this.tile?.push(...c,...c,...c),this.surface?.push(0,0,0),this.surfaceTransform?.push(1,0,1,0,1,0)}get count(){return this.p.length/9}geometry(){let e=new Pe;return e.setAttribute("position",Fi(this.p,3)),e.setAttribute("color",Fi(this.c,3)),e.setAttribute("fold",Fi(this.f,1)),this.uv&&e.setAttribute("uv",Fi(this.uv,2)),this.tile&&e.setAttribute("tile",Fi(this.tile,2)),this.surface&&e.setAttribute("surface",Fi(this.surface,1)),this.surfaceTransform&&e.setAttribute("surfaceTransform",Fi(this.surfaceTransform,2)),e.computeBoundingSphere(),e}},Wt=class{p=[];c=[];f=[];seg(e,t,n=Li,r=$e){this.p.push(...e,...t),this.c.push(n.r,n.g,n.b,n.r,n.g,n.b),this.f.push(r,r)}segSplit(e,t,n,r,s){let[o,a]=e[1]<=t[1]?[e,t]:[t,e];if(a[1]<=r+1e-6||s<0)return this.seg(o,a,n,$e);if(o[1]>=r-1e-6)return this.seg(o,a,n,s);let l=(r-o[1])/(a[1]-o[1]),c=[o[0]+(a[0]-o[0])*l,r,o[2]+(a[2]-o[2])*l];this.seg(o,c,n,$e),this.seg(c,a,n,s)}geometry(){let e=new Pe;return e.setAttribute("position",Fi(this.p,3)),e.setAttribute("color",Fi(this.c,3)),e.setAttribute("fold",Fi(this.f,1)),e}};var jd=(i,e,t)=>i.map((n,r)=>n+(e[r]-n)*t);function Ay(i,e,t){let n=(t-i.p[1])/(e.p[1]-i.p[1]);return{p:jd(i.p,e.p,n),c:jd(i.c,e.c,n),uv:i.uv&&e.uv?jd(i.uv,e.uv,n):null,tile:i.tile,surface:i.surface,surfaceTransform:i.surfaceTransform}}function JE(i,e){return{p:i.p.slice(e*3,e*3+3),c:i.c.slice(e*3,e*3+3),uv:i.uv?i.uv.slice(e*2,e*2+2):null,tile:i.tile?i.tile.slice(e*2,e*2+2):null,surface:i.surface?.[e]??0,surfaceTransform:i.surfaceTransform?.slice(e*2,e*2+2)??null}}function jE(i,e,t,n){t.forEach((r,s)=>{let o=e*3+s;r.p.forEach((a,l)=>i.p[o*3+l]=a),r.c.forEach((a,l)=>i.c[o*3+l]=a),i.uv&&r.uv&&r.uv.forEach((a,l)=>i.uv[o*2+l]=a),i.tile&&r.tile&&r.tile.forEach((a,l)=>i.tile[o*2+l]=a),i.f[o]=n,i.surface&&(i.surface[o]=r.surface),i.surfaceTransform&&r.surfaceTransform&&r.surfaceTransform.forEach((a,l)=>i.surfaceTransform[o*2+l]=a)})}function Ey(i,e,t){for(let n of e)i.p.push(...n.p),i.c.push(...n.c),i.f.push(t),i.uv?.push(...n.uv??[.5,.5]),i.tile?.push(...n.tile??[0,1]),i.surface?.push(n.surface),i.surfaceTransform?.push(...n.surfaceTransform??[1,0])}function Qd(i,e,t,n){let r=i.count;for(let s=e;sJE(i,s*3+_)),a=o.map(_=>_.p[1]>t+1e-6),l=o.map(_=>_.p[1]=t-1e-6){i.f[s*2]=n,i.f[s*2+1]=n;continue}let u=(t-l[1])/(c[1]-l[1]),h=[l[0]+(c[0]-l[0])*u,t,l[2]+(c[2]-l[2])*u],f=i.c.slice(s*6,s*6+3);i.p.splice(s*6,6,...l,...h),i.p.push(...h,...c),i.c.push(...f,...f),i.f.push(n,n)}}var QE=i=>i.reduce((e,t,n)=>e+t[0]*i[(n+1)%i.length][1]-i[(n+1)%i.length][0]*t[1],0),Ry=([i,e])=>new Ue(i,e);function Gr(i,e=[]){return Fa.triangulateShape(i.map(Ry),e.map(t=>t.map(Ry)))}var Po=(i,e)=>[i[0]-e[0],i[1]-e[1],i[2]-e[2]],Cy=(i,e)=>[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]],Py=(i,e)=>i[0]*e[0]+i[1]*e[1]+i[2]*e[2],Iy=i=>{let e=Math.hypot(i[0],i[1],i[2])||1;return[i[0]/e,i[1]/e,i[2]/e]};function tp(i,e,t,n,r,s,o){let a=new W(o);for(let f=0;f<4;f++){let[d,p]=[e[f],e[(f+1)%4]],[x,m]=[t[f],t[(f+1)%4]],[g,y]=[p[0]-d[0],p[1]-d[1]],_=Math.hypot(g,y);if(_<1e-6)continue;let b=(x[0]+m[0]-d[0]-p[0])/2*(-y/_)+(x[1]+m[1]-d[1]-p[1])/2*(g/_),M=Math.max(0,Math.min(1,b/Math.max(1e-6,Math.hypot(b,r-n)))),S=Kd(g,y),v=Be(s,sl(n)*S).lerp(a,M),w=Be(s,sl(r)*S).lerp(a,M);i.tri([d[0],n,d[1]],[x[0],r,x[1]],[m[0],r,m[1]],v,w,w),i.tri([d[0],n,d[1]],[m[0],r,m[1]],[p[0],n,p[1]],v,w,v)}let[l,c,u,h]=t;Math.hypot(u[0]-l[0],u[1]-l[1])>1e-4&&(i.tri([l[0],r,l[1]],[u[0],r,u[1]],[c[0],r,c[1]],a),i.tri([l[0],r,l[1]],[h[0],r,h[1]],[u[0],r,u[1]],a))}function np(i,e,t,n){let r=e.length;if(r<2)return;let s=e[0].length,o=new W(n),a=e.map(h=>[0,1,2].map(f=>h.reduce((d,p)=>d+p[f],0)/s)),l=e.map((h,f)=>h.map((d,p)=>{let x=Po(e[Math.min(r-1,f+1)][p],e[Math.max(0,f-1)][p]),m=Po(h[(p+1)%s],h[(p+s-1)%s]),g=Iy(Cy(x,m));return Py(g,Po(d,a[f]))<0?g.map(y=>-y):g})),c=(h,f)=>{let d=(f[0]*rl[0]+f[2]*rl[1]+1)/2;return Be(t,sl(h[1])*(.8+.28*d)).lerp(o,Math.max(0,f[1])*.9)},u=(h,f,d,p,x,m,g)=>{Py(Cy(Po(f,h),Po(d,h)),p)>=0?i.tri(h,f,d,x,m,g):i.tri(h,d,f,x,g,m)};for(let h=0;h+1c(M,x[S])),b=[0,1,2].map(M=>x.reduce((S,v)=>S+v[M],0));u(p[0],p[1],p[2],b,m,g,y),u(p[0],p[2],p[3],b,m,y,_)}for(let[h,f]of[[0,-1],[r-1,1]]){let d=e[h],p=Po(e[h===0?1:r-2][0],d[0]),x=Iy(p.map(g=>g*-f)),m=c(a[h],x);for(let g=0;g{let x=p/c*Math.PI*2;return{y:s+Math.cos(x)*o,across:r+Math.sin(x)*o}}),f=(d,p)=>{let{y:x,across:m}=h[p%c],[g,y]=e(d,m);return[g,x,y]};for(let d=0;dn:x=>Math.max(t+.002,n(x[0],x[1])),l=o.aoFrom??t,c=o.fold??$e,u=x=>sl(x-l),h=(o.holes??[]).map(x=>QE(x)>0?[...x].reverse():x),f=h.length?[...e,...h.flat()]:e,d=o.topFace!==!1,p=!d&&!o.bottom?[]:Gr(e,h);if(d){let x=new W(s);for(let[m,g,y]of p){let[_,b,M]=[f[m],f[g],f[y]];i.tri([_[0],a(_),_[1]],[M[0],a(M),M[1]],[b[0],a(b),b[1]],x,x,x,void 0,o.topFold??c)}}if(o.bottom){let x=Be(r,.55);for(let[m,g,y]of p){let[_,b,M]=[f[m],f[g],f[y]];i.tri([_[0],t,_[1]],[b[0],t,b[1]],[M[0],t,M[1]],x,x,x,void 0,c)}}for(let x of[e,...h])x.forEach((m,g)=>{let y=x[(g+1)%x.length];if(Math.hypot(y[0]-m[0],y[1]-m[1])<1e-6||o.skipSide?.(m,y))return;let _=Kd(y[0]-m[0],y[1]-m[1]),[b,M]=[a(m),a(y)],S=o.sideColor?o.sideColor(m,y):r,v=Be(S,u(t)*_),w=Be(S,u(b)*_),P=Be(S,u(M)*_);i.tri([m[0],t,m[1]],[m[0],b,m[1]],[y[0],M,y[1]],v,w,P,void 0,c),i.tri([m[0],t,m[1]],[y[0],M,y[1]],[y[0],t,y[1]],v,P,v,void 0,c)})}var Ms=i=>{let e=Math.hypot(i[0],i[1])||1;return[i[0]/e,i[1]/e]};function Hr(i){return i.reduce((t,n,r)=>t+n[0]*i[(r+1)%i.length][1]-i[(r+1)%i.length][0]*n[1],0)>=0?i:[...i].reverse()}function Ly(i,e){let t=[];return i.forEach((n,r)=>{let s=i[(r+1)%i.length],[o,a]=[e(n),e(s)];if(o>=0&&t.push(n),o>=0!=a>=0){let l=o/(o-a);t.push([n[0]+(s[0]-n[0])*l,n[1]+(s[1]-n[1])*l])}}),t}function sp(i,e,t,n,r){let s=a=>(a[0]-e[0])*t[0]+(a[1]-e[1])*t[1],o=i;return Number.isFinite(n)&&(o=Ly(o,a=>s(a)-n)),Number.isFinite(r)&&(o=Ly(o,a=>r-s(a))),o}var Fy=i=>Math.round(i*1e3),al=i=>`${Fy(i[0])},${Fy(i[1])}`,rp=(i,e)=>{let[t,n]=[al(i),al(e)];return t{let s=i[(r+1)%i.length],[o,a]=[s[0]-n[0],s[1]-n[1]],l=o*o+a*a;if(l<1e-8)return;let c=e.map(h=>({t:((h[0]-n[0])*o+(h[1]-n[1])*a)/l,off:Math.abs((h[0]-n[0])*a-(h[1]-n[1])*o)/Math.sqrt(l)})).filter(({t:h,off:f})=>h>1e-6&&h<1-1e-6&&f<1e-4).map(({t:h})=>h).sort((h,f)=>h-f),u=n;for(let h of c){let f=[n[0]+o*h,n[1]+a*h];al(f)!==al(u)&&t.push([u,f]),u=f}t.push([u,s])}),t}function op(i,e){let t=i.map(l=>({wall:l,edges:eR(l.footprint,e)})),n=new Map;for(let{edges:l}of t)for(let[c,u]of l)n.set(rp(c,u),(n.get(rp(c,u))??0)+1);let r=[],s=new Map,o=(l,c,u)=>{let h=al(l);s.has(h)||s.set(h,{p:l,wall:c,d:[]}),s.get(h).d.push(u)};for(let{wall:l,edges:c}of t)for(let[u,h]of c){let f=Math.hypot(h[0]-u[0],h[1]-u[1]);if(n.get(rp(u,h))!==1||f<1e-4)continue;r.push({a:u,b:h,wall:l});let d=[(h[0]-u[0])/f,(h[1]-u[1])/f];o(u,l,d),o(h,l,d)}let a=[...s.values()].filter(({d:l})=>l.some(c=>l.some(u=>Math.abs(c[0]*u[1]-c[1]*u[0])>.05))).map(({p:l,wall:c})=>({p:l,wall:c}));return{edges:r,corners:a}}function Io(i,e){if(e.length===0)return[[i.a,i.b]];let t=Ms([i.wall.b[0]-i.wall.a[0],i.wall.b[1]-i.wall.a[1]]),n=Ms([i.b[0]-i.a[0],i.b[1]-i.a[1]]);if(Math.abs(t[0]*n[0]+t[1]*n[1])<.99)return[[i.a,i.b]];let r=c=>(c[0]-i.wall.a[0])*t[0]+(c[1]-i.wall.a[1])*t[1],[s,o]=[r(i.a),r(i.b)],a=[[Math.min(s,o),Math.max(s,o)]];for(let c of e)a=a.flatMap(([u,h])=>{if(c.s1<=u||c.s0>=h)return[[u,h]];let f=[];return c.s0>u&&f.push([u,c.s0]),c.s1{let u=(c-s)/(o-s||1);return[i.a[0]+(i.b[0]-i.a[0])*u,i.a[1]+(i.b[1]-i.a[1])*u]};return a.filter(([c,u])=>u-c>1e-4).map(([c,u])=>s<=o?[l(c),l(u)]:[l(u),l(c)])}var Ny=["body","wood","fabric","white","metal","dark"];var Fe={body:1516088,bodyTop:1911623,fabric:1713732,fabricTop:2241114,cushion:2373217,wood:1647420,woodTop:2108747,white:1911110,whiteTop:2504542,metal:2767456,dark:725279,glass:1849938,plant:1191982,plantTop:1721664,pot:1910336,accent:2854835},He=(i,e=i)=>({side:i,top:e}),q={body:He(Fe.body,Fe.bodyTop),fabric:He(Fe.fabric,Fe.fabricTop),cushion:He(Fe.cushion),cushionSoft:He(Fe.cushion,Fe.fabricTop),wood:He(Fe.wood,Fe.woodTop),white:He(Fe.white,Fe.whiteTop),worktop:He(Fe.whiteTop),metal:He(Fe.metal),dark:He(Fe.dark),darkBody:He(Fe.dark,Fe.body),glass:He(Fe.glass),accent:He(Fe.accent),pot:He(Fe.pot),plant:He(Fe.plant,Fe.plantTop),bedding:He(Fe.white,Fe.whiteTop),pillow:He(Fe.whiteTop)};var ue=Be(5995775,.3),Te=Be(5995775,.17),Ze=Be(3662079,.45);var ap={...Fe},Oy=Object.fromEntries(Object.entries(q).map(([i,e])=>[i,{...e}])),Dy="",tR=i=>typeof i=="string"&&/^#[0-9a-f]{6}$/i.test(i)?Number.parseInt(i.slice(1),16):null;function Uy(i){let e=Object.fromEntries(Ny.map(s=>[s,tR(i?.[s])]).filter(([,s])=>s!==null)),t=JSON.stringify(e);if(t===Dy)return!1;Dy=t,Object.assign(Fe,ap);for(let[s,o]of Object.entries(Oy))Object.assign(q[s],o);let n=s=>Be(s,1.25).getHex(),r=(s,o,a,l)=>{let c=e[s];if(c===void 0)return;for(let h of o)Fe[h]=c;for(let h of a)Fe[h]=n(c);let u=new Map([...o.map(h=>[ap[h],c]),...a.map(h=>[ap[h],n(c)])]);for(let h of l){let f=Oy[h];q[h].side=u.get(f.side)??q[h].side,q[h].top=u.get(f.top)??q[h].top}};return r("body",["body"],["bodyTop"],["body","darkBody"]),r("wood",["wood"],["woodTop"],["wood"]),r("fabric",["fabric","cushion"],["fabricTop"],["fabric","cushion","cushionSoft"]),r("white",["white"],["whiteTop"],["white","worktop","bedding","pillow"]),r("metal",["metal"],[],["metal"]),r("dark",["dark"],[],["dark","darkBody"]),!0}function ky(i){let e=i(0,0),t=i(1,0),n=i(0,1);return(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0])<0}function Ss(i,e){let t=(n,r,s)=>{if(n)for(let o=0;othis.plan(e+(o-e)*r-(a-t)*s,t+(o-e)*s+(a-t)*r))}seg(e,t,n,r,s,o,a=ue){this.edge(this.plan(e,n),this.plan(r,o),t,s,a)}edge(e,t,n,r,s){this.lines.seg([e[0],n,e[1]],[t[0],r,t[1]],s,$e)}block({x:[e,t],y:[n,r],z:[s,o]},a,l=null){if(t-e<1e-4||o-s<1e-4||r-n<1e-4)return;let c=[this.plan(e,s),this.plan(e,o),this.plan(t,o),this.plan(t,s)];Tt(this.buf,Hr(c),n,r,a.side,a.top,{aoFrom:0,bottom:n>.05}),l&&c.forEach((u,h)=>{this.edge(u,c[(h+1)%4],r,r,l),this.edge(u,u,n,r,l)})}prism(e,t,n,r,s=null){if(e.length<3||n-t<1e-4)return;let o=e.map(([a,l])=>this.plan(a,l));Tt(this.buf,Hr(o),t,n,r.side,r.top,{aoFrom:Math.min(0,t),bottom:!0}),s&&o.forEach((a,l)=>this.edge(a,o[(l+1)%o.length],n,n,s))}loft(e,t,n,r,s,o=null){if(r-n<1e-4)return;let a=u=>[this.plan(u[0],u[2]),this.plan(u[0],u[3]),this.plan(u[1],u[3]),this.plan(u[1],u[2])],l=a(e),c=a(t);if(l!==Hr(l)&&(l.reverse(),c.reverse()),tp(this.buf,l,c,n,r,s.side,s.top),o)for(let u=0;u<4;u++)this.edge(c[u],c[(u+1)%4],r,r,o),this.edge(l[u],c[u],n,r,o)}sweep(e,t,n=16,r=2.6,s=null){if(e.length<2)return;let o=e.map(a=>{let[l,c]=[Math.max(.004,(a.y1-a.y0)/2),Math.max(.004,a.hw)],u=(a.y0+a.y1)/2;return Array.from({length:n},(h,f)=>{let d=f/n*Math.PI*2,[p,x]=[Math.cos(d),Math.sin(d)],[m,g]=this.plan(a.x+c*Math.sign(p)*Math.abs(p)**(2/r),a.z);return[m,u+l*Math.sign(x)*Math.abs(x)**(2/r),g]})});if(np(this.buf,o,t.side,t.top),s){let a=Math.round(n/4);for(let l=0;l+1.005&&this.block({x:[s,o],y:[a+h,l-h],z:[c,u]},f,r),this.loft([s,o,c,u],[s+h,o-h,c+h,u-h],l-h,l,t)}lyingCylinder(e,t,n,r,s,o,a,l,c=12,u=null){let h=Math.min(a,s-r)/2;if(h<1e-4||o<1e-4)return;let f=(r+s)/2,[d,p]=e==="x"?[t,n]:[n,t],x=(g,y)=>e==="x"?this.plan(g,y):this.plan(y,g),m=this.buf.p.length;if(ip(this.buf,x,d-o/2,d+o/2,p,f,h,l.side,l.top,c),this.mirrored!==(e==="z")&&Ss(this.buf,m),!!u)for(let g of[d-o/2,d+o/2])for(let y=0;ythis.plan(e+Math.cos(h/a*Math.PI*2)*n,t+Math.sin(h/a*Math.PI*2)*n));Tt(this.buf,Hr(c),r,s,o.side,o.top,{aoFrom:0,bottom:r>.05}),l&&c.forEach((u,h)=>this.edge(u,c[(h+1)%a],s,s,l))}ring(e,t,n,r,s=20,o=ue){for(let a=0;a[e(-t/2-p,-n/2-p),e(t/2+p,-n/2-p),e(t/2+p,n/2+p),e(-t/2-p,n/2+p)],[u,h]=[c(0),c(s)],f=p=>[p[0],l,p[1]],d=i.p.length;i.tri(f(u[0]),f(u[1]),f(u[2]),o),i.tri(f(u[0]),f(u[2]),f(u[3]),o);for(let p=0;p<4;p++){let x=(p+1)%4;i.tri(f(u[p]),f(h[p]),f(h[x]),o,a,a),i.tri(f(u[p]),f(h[x]),f(u[x]),o,a,o)}ky(e)&&Ss(i,d)}function lp(i,e){if(!i)return null;if(i.startsWith("#"))return Number.parseInt(i.slice(1),16);let t=Fe;return(e?t[`${i}Top`]:void 0)??t[i]??null}function ws(i,e,t,n,r,s,o,a=null,l=null,c=null){let u=e.colors?.length?(e.colors.find(f=>f.id===l)??e.colors[0]).hex:null,h=ia(e,t,n,r);for(let f of c===null?h:ig(h,c)){if(c===null&&f.move||a&&!a(f))continue;let d=a?{...f,glow:!0,w:f.w+.006/t,d:f.d+.006/n,y:Math.max(0,f.y-.002/r),h:f.h+.004/r}:f,p=d.glow&&o!==null,x=!!(d.paint&&u),m=x?u:d.color,g=p?o:lp(m,!1)??Fe.body,y=p?o:lp(x?void 0:d.top,!1)??lp(m,!0)??Be(g,1.25).getHex(),_=He(g,y),[b,M]=[s+d.y*r,s+Math.min(r,(d.y+d.h)*r)],S=d.edges==="glow"?Li:d.edges==="faint"?Te:d.edges?ue:null,v=d.rot?i.turned(d.x*t,d.z*n,d.rot):i,[w,P]=[d.x*t,d.z*n];if(d.shape==="cyl"&&(d.axis==="x"||d.axis==="z"))v.lyingCylinder(d.axis,w,P,b,M,d.axis==="x"?d.w*t:d.d*n,d.axis==="x"?d.d*n:d.w*t,_,14,S);else if(d.shape==="cyl")v.cylinder(w,P,Math.min(d.w*t,d.d*n)/2,b,M,_,14,S);else if(d.shape==="loft"){let[T,R,L,k]=[d.tx??d.x,d.tz??d.z,d.tw??d.w,d.td??d.d];v.loft([(d.x-d.w/2)*t,(d.x+d.w/2)*t,(d.z-d.d/2)*n,(d.z+d.d/2)*n],[(T-L/2)*t,(T+L/2)*t,(R-k/2)*n,(R+k/2)*n],b,M,_,S)}else if(d.shape==="sweep"){let T=(d.stations??[]).map(([R,L,k,C])=>({x:w,z:R*n,y0:s+L*r,y1:s+k*r,hw:C*t/2}));v.sweep(T,_,d.n??16,d.exp??2.6,S)}else v.block({x:[(d.x-d.w/2)*t,(d.x+d.w/2)*t],y:[b,M],z:[(d.z-d.d/2)*n,(d.z+d.d/2)*n]},_,S)}}function Ts(i){let[e,t]=[Math.cos(i.rotation*mt),Math.sin(i.rotation*mt)],n=i.mirror?-1:1;return(r,s)=>[i.x+n*r*e-s*t,i.z+n*r*t+s*e]}var cp=i=>[Math.max(.05,i.w),Math.max(.05,i.d),Math.max(.005,i.h)];function ll(i,e,t,n,r,s=o=>!!o.glow){ws(new Ni(i,new Wt,Ts(t)),e,...cp(t),n,r,s)}function up(i,e,t,n,r){let s=i.p.length;ws(new Ni(i,new Wt,Ts(t)),e,...cp(t),n,null,null,t.variant??null,r),t.mirror&&Ss(i,s)}function cl(i,e,t,n,r){ws(new Ni(i,new Wt,Ts(t)),e,...cp(t),n,r)}function zy(i){let e=2166136261;for(let t=0;t(e=Math.imul(e^e>>>15,2246822507),e=Math.imul(e^e>>>13,3266489909),e^=e>>>16,(e>>>0)/4294967296)}var nR=(i,e,t)=>{let[n,r]=[t[0]-e[0],t[1]-e[1]],s=n*n+r*r||1e-9,o=Math.max(0,Math.min(1,((i[0]-e[0])*n+(i[1]-e[1])*r)/s));return Math.hypot(i[0]-e[0]-n*o,i[1]-e[1]-r*o)};function iR(i,e,t=.25){if(!Ge(e,i.points))return!1;let n=i.points;for(let r=0;rGe(e,r))}function rR(i,e,t){let n=i.obstacles.filter(s=>!Ge(e,s)),r=Math.max(1,Math.ceil(Math.hypot(t[0]-e[0],t[1]-e[1])/.1));for(let s=1;s<=r;s++){let o=[e[0]+(t[0]-e[0])*s/r,e[1]+(t[1]-e[1])*s/r];if(n.some(a=>Ge(o,a)))return!1}return!0}function sR(i,e,t){let n=i.points.map(c=>c[0]),r=i.points.map(c=>c[1]),[s,o,a,l]=[Math.min(...n),Math.max(...n),Math.min(...r),Math.max(...r)];for(let c=0;c<24;c++){let u=[s+(o-s)*t(),a+(l-a)*t()];if(Math.hypot(u[0]-e[0],u[1]-e[1])>.6&&iR(i,u)&&rR(i,e,u))return u}return null}function oR(i,e,t,n){if(!i.target){if(i.rest-=t,i.rest>0)return!1;if(i.target=sR(e,i.pos,n),!i.target)return i.rest=2,!1}let[r,s]=[i.target[0]-i.pos[0],i.target[1]-i.pos[1]],o=Math.hypot(r,s),l=Math.atan2(r,s)-i.heading;for(;l>Math.PI;)l-=2*Math.PI;for(;l<-Math.PI;)l+=2*Math.PI;i.heading+=Math.max(-4*t,Math.min(4*t,l));let c=e.speed*t*(Math.abs(l)>1.2?.3:1);return o<=c?(i.pos=[i.target[0],i.target[1]],i.target=null,i.rest=2+n()*6,!0):(i.pos=[i.pos[0]+r/o*c,i.pos[1]+s/o*c],!0)}function Vy(i,e,t,n){let r=Math.min(.2,Math.max(0,t));return i.target||(i.rest-=Math.max(0,t)-r),oR(i,e,r,n)}function Gy(){let e=navigator.deviceMemory??8,t=navigator.hardwareConcurrency||8;return e<=3||t<=4||/Silk|KF[A-Z]{2,4}\b/.test(navigator.userAgent)}var Vu=class{times=[];settle=30;ratio;lastDown=-1/0;slowAtFloor=0;max;min;constructor(e,t=1){this.max=e,this.min=t,this.ratio=e}get pixelRatio(){return this.ratio}frame(e,t){if(this.settle>0)return this.settle--,null;if(e<=0||e>=100||(this.times.push(e),this.times.length<45))return null;let n=[...this.times].sort((s,o)=>s-o);this.times=[];let r=1e3/n[Math.floor(n.length/2)];return r<26&&this.ratio>this.min+1e-6?(this.ratio=Math.max(this.min,Math.round((this.ratio-.25)*100)/100),this.lastDown=t,this.settle=30,{ratio:this.ratio}):r<16&&this.ratio<=this.min+1e-6?++this.slowAtFloor>=2?{low:!0}:null:(this.slowAtFloor=0,r>55&&this.ratio3e4?(this.ratio=Math.min(this.max,Math.round((this.ratio+.25)*100)/100),this.settle=30,{ratio:this.ratio}):null)}};function Hy(i){let e=i.length/3,t=new Float32Array(e);for(let n=0;n0&&(t[n]=r)}return t}function Wy(i,e,t,n){for(let r=t.start*3;rMath.tan(Math.min(80,Math.max(0,i))*Gu);function As(i){return{x0:Math.min(i.x0,i.x1),x1:Math.max(i.x0,i.x1),z0:Math.min(i.z0,i.z1),z1:Math.max(i.z0,i.z1)}}function Xy(i){if(!i.rotation)return null;let e=i.rotation*Gu;return{cx:(i.x0+i.x1)/2,cz:(i.z0+i.z1)/2,c:Math.cos(e),sn:Math.sin(e)}}function Yy(i,e){let t=Xy(i);if(!t)return e;let[n,r]=[e[0]-t.cx,e[1]-t.cz];return[t.cx+n*t.c-r*t.sn,t.cz+n*t.sn+r*t.c]}function hp(i,e,t){let n=Xy(i);if(!n)return[e,t];let[r,s]=[e-n.cx,t-n.cz];return[n.cx+r*n.c+s*n.sn,n.cz-r*n.sn+s*n.c]}function qy(i,e=0){let{x0:t,x1:n,z0:r,z1:s}=As(i);return[[t-e,r-e],[n+e,r-e],[n+e,s+e],[t-e,s+e]].map(o=>Yy(i,o))}function Un(i){let{x0:e,x1:t,z0:n,z1:r}=As(i),s=o=>Yy(i,o);return i.axis==="x"?{u0:e,u1:t,w:r-n,at:(o,a)=>s([o,i.flip?r-a:n+a])}:{u0:n,u1:r,w:t-e,at:(o,a)=>s([i.flip?t-a:e+a,o])}}function Oi(i,e,t){let{x0:n,x1:r,z0:s,z1:o}=As(i),[a,l]=hp(i,e,t);return i.axis==="x"?[a,i.flip?o-l:l-s]:[l,i.flip?r-a:a-n]}var ul=Math.tan(30*Gu);function hl(i,e,t,n,r){let s=Math.min(i*.3,n>1e-6?2.4/n:i*.3),o=Math.min(i*.3,r>1e-6?2.4/r:i*.3),a=e+s*n,l=t+o*r,c=Math.min(i-o,Math.max(s,(l-a+ul*(i-o+s))/(2*ul))),u=a+(c-s)*ul;return{vla:s,vlb:o,yla:a,ylb:l,vr:c,rh:u,y:f=>f<=s?e+f*n:f<=c?a+(f-s)*ul:f<=i-o?l+(i-o-f)*ul:t+(i-f)*r}}function Rn(i){let e=Un(i).w,[t,n]=[i.eave_a,i.eave_b],[r,s]=[dr(i.pitch_a),dr(i.pitch_b)];switch(i.shape){case"flat":case"parapet":return{vr:e/2,rh:t,y:()=>t};case"pent":return{vr:e,rh:t+e*r,y:o=>t+o*r};case"mansard":{let o=hl(e,t,n,r,s);return{vr:o.vr,rh:o.rh,y:o.y}}default:{let o=r+s>1e-6?Math.min(e,Math.max(0,(n-t+e*s)/(r+s))):e/2;return{vr:o,rh:t+o*r,y:a=>a<=o?t+a*r:n+(e-a)*s}}}}var fp=i=>Rn(i).rh;var xt=(i,e)=>[i[0]-e[0],i[1]-e[1]],Di=(i,e)=>[i[0]+e[0],i[1]+e[1]],hi=(i,e)=>[i[0]*e,i[1]*e],vn=(i,e)=>i[0]*e[0]+i[1]*e[1],Cn=(i,e)=>i[0]*e[1]-i[1]*e[0],Jn=i=>Math.hypot(i[0],i[1]),fi=i=>{let e=Jn(i)||1;return[i[0]/e,i[1]/e]},dp=i=>[-i[1],i[0]],pp=i=>[i[1],-i[0]];function $y(i){let e=i.heightEnd!==void 0;return{...i,a:i.b,b:i.a,left:i.right,right:i.left,roomLeft:i.roomRight,roomRight:i.roomLeft,height:e?i.heightEnd:i.height,heightEnd:e?i.height:void 0}}function aR(i,e){let t=i.map(n=>({...n}));for(let n of e){let r=t.find(s=>s.room_id===n.room_id&&s.edge===n.edge&&(Math.abs(s.t1-n.t0)<1e-6||Math.abs(n.t1-s.t0)<1e-6));r?(r.t0=Math.min(r.t0,n.t0),r.t1=Math.max(r.t1,n.t1)):t.push({...n})}return t}function lR(i,e,t){if(i.a===e.b)return!1;let n=fi(xt(t[i.b],t[i.a])),r=fi(xt(t[e.b],t[e.a]));return Math.abs(Cn(n,r))>1e-6||vn(n,r)<=0||i.free||e.free||i.heightEnd!==void 0||e.heightEnd!==void 0?!1:i.height===e.height&&i.exterior===e.exterior&&i.roomLeft===e.roomLeft&&i.roomRight===e.roomRight&&Math.abs(i.left-e.left)<=1e-9&&Math.abs(i.right-e.right)<=1e-9}function Ky(i,e,t=new Set){let n=i.slice();for(;;){let r=new Map;n.forEach((o,a)=>{for(let l of[o.a,o.b])r.set(l,[...r.get(l)??[],a])});let s=null;for(let[o,a]of r){if(a.length!==2||t.has(o))continue;let l=n[a[0]].b===o?n[a[0]]:$y(n[a[0]]),c=n[a[1]].a===o?n[a[1]]:$y(n[a[1]]);if(!lR(l,c,e))continue;let u={...l,b:c.b,sources:aR(l.sources,c.sources)};s=[...n.filter((h,f)=>f!==a[0]&&f!==a[1]),u];break}if(!s)return n;n=s}}function Zy(i,e){let t=new Map;i.forEach((r,s)=>{let o=fi(xt(e[r.b],e[r.a])),a=[[r.a,{key:`${s}:a`,d:o,left:r.left,right:r.right,angle:Math.atan2(o[1],o[0])}],[r.b,{key:`${s}:b`,d:hi(o,-1),left:r.right,right:r.left,angle:Math.atan2(-o[1],-o[0])}]];for(let[l,c]of a)t.set(l,[...t.get(l)??[],c])});let n=new Map;for(let[r,s]of t){let o=e[r];s.sort((l,c)=>l.angle-c.angle);for(let l of s)n.set(l.key,{left:Di(o,hi(dp(l.d),l.left)),right:Di(o,hi(pp(l.d),l.right))});if(s.length<2)continue;let a=4*Math.max(...s.map(l=>Math.max(l.left,l.right)))+1e-9;s.forEach((l,c)=>{let u=s[(c+1)%s.length],h=Di(o,hi(dp(l.d),l.left)),f=Di(o,hi(pp(u.d),u.right)),d=Cn(l.d,u.d);if(Math.abs(d)<1e-4)return;let p=Di(h,hi(l.d,Cn(xt(f,h),u.d)/d));Jn(xt(p,o))>a||(n.get(l.key).left=p,n.get(u.key).right=p)})}return n}function Jy(i,e){let t=i.filter((n,r)=>Jn(xt(n,i[(r+1)%i.length]))>e);for(;;){if(t.length<=3)return t;let n=t.findIndex((r,s)=>{let o=t[(s+t.length-1)%t.length],a=t[(s+1)%t.length],[l,c]=[xt(r,o),xt(a,r)];return Math.abs(Cn(fi(l),fi(c)))<1e-7&&vn(l,c)>0});if(n===-1)return t;t=t.filter((r,s)=>s!==n)}}function cR(i){let e=[];return{points:e,idOf(t){let n=e.findIndex(r=>Math.abs(r[0]-t[0])<=i&&Math.abs(r[1]-t[1])<=i);return n>=0?n:(e.push([t[0],t[1]]),e.length-1)}}}function uR(i,e){let t=[];for(let n of i){let r=n.points;if(r.length<3||Math.abs(ts(r))<1e-6)continue;let s=ts(r)>0,o=r.map(a=>e.idOf(a));o.forEach((a,l)=>{let c=o[(l+1)%o.length];a!==c&&t.push(s?{u:a,v:c,room:n.id,edge:l,forward:!0}:{u:c,v:a,room:n.id,edge:l,forward:!1})})}return t}function hR(i,e,t){let n=[];for(let r of i){let[s,o]=[e[r.u],e[r.v]],a=xt(o,s),l=Jn(a),c=hi(a,1/l),u=e.map((f,d)=>({id:d,rel:xt(f,s)})).filter(({id:f,rel:d})=>f!==r.u&&f!==r.v&&vn(d,c)>t&&vn(d,c)({t:vn(d,c),id:f})).sort((f,d)=>f.t-d.t),h=[{t:0,id:r.u},...u,{t:l,id:r.v}];for(let f=0;f+1({room_id:i.room,edge:i.edge,t0:i.t0,t1:i.t1});function fR(i,e){let t=new Map(i.map(a=>[a.id,a])),n=new Map;for(let a of e){let l=`${a.room}:${a.edge}`;n.set(l,[...n.get(l)??[],a.t0].sort((c,u)=>c-u))}let r=a=>{let l=t.get(a.room)?.wall_heights?.[a.edge];return Array.isArray(l)?l[(n.get(`${a.room}:${a.edge}`)??[]).indexOf(a.t0)]??null:l},s=a=>{let l=t.get(a.room),[c,u]=[l?.wall_heights?.[a.edge],l?.wall_slopes?.[a.edge]];if(!l||typeof c!="number"||typeof u!="number"||c<=0||u<=0)return null;let[h,f]=[l.points[a.edge],l.points[(a.edge+1)%l.points.length]];return{from:c,to:u,length:Math.hypot(f[0]-h[0],f[1]-h[1])}},o=a=>{let l=s(a);if(!l||l.length<1e-9){let u=r(a);return typeof u=="number"&&u>0?[u,u]:[null,null]}let c=u=>l.from+(l.to-l.from)*u/l.length;return a.forward?[c(a.t0),c(a.t1)]:[c(a.t1),c(a.t0)]};return{heightsOf(a){let[l,c]=[1/0,1/0];for(let h of a){let[f,d]=o(h),[p,x]=h===a[0]?[f,d]:[d,f];p!==null&&(l=Math.min(l,p)),x!==null&&(c=Math.min(c,x))}let u=a.map(h=>t.get(h.room)?.ceiling);if(u.every(h=>typeof h=="number"&&h>0)){let h=Math.max(...u);l===1/0&&(l=h),c===1/0&&(c=h)}return{...l<1/0?{a:l}:{},...c<1/0?{b:c}:{}}},thicknessOf(a){let l=a.map(c=>{let u=t.get(c.room)?.wall_thickness?.[c.edge];return Array.isArray(u)?u[(n.get(`${c.room}:${c.edge}`)??[]).indexOf(c.t0)]:u}).filter(c=>typeof c=="number"&&c>0);return l.length?Math.max(...l):void 0},hasNoWall:a=>a.some(l=>r(l)===0)}}function Qy(i){let e=t=>Math.round(t*1e6)/1e6;return i.a===void 0||i.b===void 0?i.a!==void 0?{height:e(i.a)}:i.b!==void 0?{height:e(i.b)}:{}:Math.abs(i.a-i.b)<1e-6?{height:e(i.a)}:{height:e(i.a),heightEnd:e(i.b)}}function dR(i,e,t,n){let r=fR(e,i),s=new Map;for(let l of i){let c=l.uf!==c&&f.u===c.v&&f.v===c.u&&f.room!==c.room);for(let f of l)f!==c&&f!==u&&f.room!==c.room&&n.push(`overlap:${c.room}:${f.room}`);let h=u?[c,u]:[c];if(r.hasNoWall(h)){u&&a.push([c.room,u.room]);continue}if(u){let f=r.thicknessOf(h)??t.interior;o.push({a:c.u,b:c.v,left:f/2,right:f/2,exterior:!1,roomLeft:c.room,roomRight:u.room,sources:h.map(jy),...Qy(r.heightsOf(h))})}else o.push({a:c.u,b:c.v,left:0,right:r.thicknessOf(h)??t.exterior,exterior:!0,roomLeft:c.room,roomRight:null,sources:[jy(c)],...Qy(r.heightsOf(h))})}return{drafts:o,open:a}}function pR(i,e){let t=s=>fi(xt(e[s.b],e[s.a])),n=i.filter(s=>!s.exterior&&!s.free),r=new Map;for(let s of n){if(r.has(s))continue;let o=[s];r.set(s,o);for(let a=0;a1e-6||l.add(vn(o,d)>0?"left":"right")}if(l.size!==1)continue;let c=[...l][0];for(let u of s){let h=u.left+u.right,f=vn(t(u),o)>0,d=c==="left"===f;[u.left,u.right]=d?[0,h]:[h,0]}}}var mR=(i,e)=>{let t=s=>Math.round(s*100),[n,r]=i[0]Math.hypot(g.b[0]-g.a[0],g.b[1]-g.a[1])>.05),l=a.map(g=>[s.idOf(g.a),s.idOf(g.b)]),c=new Set;for(let g of i){let y=g.points;y.length<3||(g.wall_splits??[]).forEach((_,b)=>{if(!_||b>=y.length)return;let M=y[b],S=xt(y[(b+1)%y.length],M),v=Jn(S);for(let w of _)w>n&&w{let[_,b]=l[y];if(_===b)return;let M=[(g.a[0]+g.b[0])/2,(g.a[1]+g.b[1])/2],S=i.find(w=>w.points.length>=3&&Ge(M,w.points))?.id??null,v=(g.thickness??e.interior)/2;d.push({free:g.id,a:_,b,left:v,right:v,exterior:!1,roomLeft:S,roomRight:S,sources:[],height:typeof g.height=="number"&&g.height>0?g.height:void 0,...typeof g.height=="number"&&g.height>0&&typeof g.height_end=="number"&&g.height_end>0&&Math.abs(g.height_end-g.height)>1e-6?{heightEnd:g.height_end}:{}})});let p=Ky(d,s.points,c),x=Zy(p,s.points);return{walls:p.map((g,y)=>{let[_,b]=[s.points[g.a],s.points[g.b]],[M,S]=[x.get(`${y}:a`),x.get(`${y}:b`)],v=Jy([M.right,S.left,b,S.right,M.left,_],1e-6);return{id:mR(_,b),a:[_[0],_[1]],b:[b[0],b[1]],left:g.left,right:g.right,exterior:g.exterior,roomLeft:g.roomLeft,roomRight:g.roomRight,sources:g.sources,footprint:v,...g.free?{free:g.free}:{},...g.height!==void 0?{height:g.height}:{},...g.heightEnd!==void 0?{heightEnd:g.heightEnd}:{}}}),warnings:[...new Set(r)],open:f}}function eb(i,e,t){let n=i.points[e];return Di(n,hi(fi(xt(i.points[(e+1)%i.points.length],n)),t))}function tb(i,e,t){if(i.wall){let r=t.find(a=>a.id===i.wall);if(!r||Math.hypot(r.b[0]-r.a[0],r.b[1]-r.a[1])<.05)return null;let s=fi(xt(r.b,r.a));return{room:{id:i.room_id,name:"",area_id:null,points:[r.a,r.b,Di(r.a,[-s[1],s[0]])]},edge:0}}let n=e.find(r=>r.id===i.room_id);return n&&i.edgevn(xt(e,i.a),fi(xt(i.b,i.a)));function ib(i,e,t){if(!e.wall)return gR(i,t.room,t.edge,e.offset);let n=i.find(r=>r.free===e.wall);return n?{wall:n,s:nb(n,eb(t.room,0,e.offset))}:null}function gR(i,e,t,n){for(let r of i)if(r.sources.some(o=>o.room_id===e.id&&o.edge===t&&n>=o.t0-1e-6&&n<=o.t1+1e-6))return{wall:r,s:nb(r,eb(e,t,n))};return null}var rb=([i,e])=>{let t=Math.hypot(i,e)||1;return[i/t,e/t]};function xR(i){return i.reduce((e,t,n)=>e+(t[0]*i[(n+1)%i.length][1]-i[(n+1)%i.length][0]*t[1]),0)/2}function Hu(i,e){let t=i.length;if(t<3||Math.abs(e)<1e-9)return i.map(([r,s])=>[r,s]);let n=xR(i)>=0?1:-1;return i.map((r,s)=>{let o=i[(s+t-1)%t],a=i[(s+1)%t],[l,c]=rb([r[0]-o[0],r[1]-o[1]]),[u,h]=rb([a[0]-r[0],a[1]-r[1]]),f=[c*n,-l*n],d=[h*n,-u*n],p=[f[0]+d[0],f[1]+d[1]],x=Math.hypot(p[0],p[1]);if(x<1e-6)return[r[0]+f[0]*e,r[1]+f[1]*e];let m=(p[0]*f[0]+p[1]*f[1])/x,g=Math.min(4,1/Math.max(.25,m));return[r[0]+p[0]/x*e*g,r[1]+p[1]/x*e*g]})}function mp(i,e){if(i.points&&i.points.length>=3)return Hu(i.points,e);if(i.rotation)return qy(i,e);let t=Math.min(i.x0,i.x1)-e,n=Math.max(i.x0,i.x1)+e,r=Math.min(i.z0,i.z1)-e,s=Math.max(i.z0,i.z1)+e;return[[t,r],[n,r],[n,s],[t,s]]}function Wr(i,e){let t=Un(i),n=Rn(i),r=t.w,[s,o]=[Math.max(0,e.a),Math.max(0,e.b)],a=t.u0-Math.max(0,e.u0),l=t.u1+Math.max(0,e.u1),c=(g,y)=>[g,y,n.y(y)],u=c(a,-s),h=c(l,-s),f=c(l,r+o),d=c(a,r+o),[p,x]=[dr(i.pitch_a),dr(i.pitch_b)],m=g=>[g,n.vr,n.rh];if(i.ends&&(i.shape==="gable"||i.shape==="hip"||i.shape==="halfhip")){let g=(t.u1-t.u0)/2,y=Math.min(g,Math.min(n.vr,r-n.vr)||r/2),_=Math.min(n.y(0),n.y(r)),b=_+(n.rh-_)*Math.min(.9,Math.max(.2,i.halfhip??.55)),M=p>1e-6?Math.min(n.vr,(b-i.eave_a)/p):n.vr,S=x>1e-6?Math.max(n.vr,r-(b-i.eave_b)/x):n.vr,v=Math.min(g-.1,(n.rh-b)/Math.max(.2,p)),w=[[0,n.y(0)],[n.vr,n.rh],[r,n.y(r)]],P=[[0,n.y(0)],[M,b],[S,b],[r,n.y(r)]],T=(F,H,U)=>{if(F==="hip")return{upA:[],upB:[],ridge:m(H===a?t.u0+y*U:t.u1-y*U),profile:null};if(F==="halfhip"){let X=m(H===a?t.u0+v:t.u1-v);return{upA:[[H,M,b]],upB:[[H,S,b]],ridge:X,profile:P}}return{upA:[],upB:[],ridge:m(H),profile:w}},R=T(i.ends[0],a,1),L=T(i.ends[1],l,1),k=[[u,h,...L.upA,L.ridge,R.ridge,...[...R.upA].reverse()],[R.ridge,L.ridge,...[...L.upB].reverse(),f,d,...R.upB]],C=[[R.ridge,L.ridge]];for(let[F,H,U]of[[R,u,d],[L,h,f]])F.profile===null?(k.push(F===R?[d,u,F.ridge]:[h,f,F.ridge]),C.push([H,F.ridge],[U,F.ridge])):F.upA.length&&(k.push(F===R?[F.upB[0],F.upA[0],F.ridge]:[F.upA[0],F.upB[0],F.ridge]),C.push([F.upA[0],F.ridge],[F.upB[0],F.ridge]));let I=F=>F.profile===null?[]:F.upA.length?[F.upA[0],F.upB[0]]:[F.ridge],O=[u,h,...I(L),f,d,...[...I(R)].reverse()];return{faces:k,rim:O,ridges:C,gable:w,endProfiles:[R.profile,L.profile]}}switch(i.shape){case"pent":return{faces:[[u,h,f,d]],rim:[u,h,f,d],ridges:[[f,d]],gable:[[0,n.y(0)],[r,n.y(r)]]};case"hip":case"pyramid":{let g=(t.u1-t.u0)/2,y=i.shape==="pyramid"?g:Math.min(g,Math.min(n.vr,r-n.vr)||r/2),_=m(t.u0+y),b=m(t.u1-y);return i.shape==="pyramid"?{faces:[[u,h,_],[h,f,_],[f,d,_],[d,u,_]],rim:[u,h,f,d],ridges:[[u,_],[d,_],[h,_],[f,_]],gable:null}:{faces:[[u,h,b,_],[_,b,f,d],[d,u,_],[h,f,b]],rim:[u,h,f,d],ridges:[[_,b],[u,_],[d,_],[h,b],[f,b]],gable:null}}case"halfhip":{let g=Math.min(n.y(0),n.y(r)),y=g+(n.rh-g)*Math.min(.9,Math.max(.2,i.halfhip??.55)),_=p>1e-6?Math.min(n.vr,(y-i.eave_a)/p):n.vr,b=x>1e-6?Math.max(n.vr,r-(y-i.eave_b)/x):n.vr,M=Math.min((t.u1-t.u0)/2-.1,(n.rh-y)/Math.max(.2,p)),S=m(t.u0+M),v=m(t.u1-M),w=[a,_,y],P=[a,b,y],T=[l,_,y],R=[l,b,y];return{faces:[[u,h,T,v,S,w],[S,v,R,f,d,P],[P,w,S],[T,R,v]],rim:[u,h,T,R,f,d,P,w],ridges:[[S,v],[w,S],[P,S],[T,v],[R,v]],gable:[[0,n.y(0)],[_,y],[b,y],[r,n.y(r)]]}}case"mansard":{let g=hl(r,i.eave_a,i.eave_b,p,x),y=[a,g.vla,g.yla],_=[l,g.vla,g.yla],b=[a,r-g.vlb,g.ylb],M=[l,r-g.vlb,g.ylb],S=[a,g.vr,g.rh],v=[l,g.vr,g.rh];return{faces:[[u,h,_,y],[y,_,v,S],[S,v,M,b],[b,M,f,d]],rim:[u,h,_,v,M,f,d,b,S,y],ridges:[[S,v],[y,_],[b,M]],gable:[[0,n.y(0)],[g.vla,g.yla],[g.vr,g.rh],[r-g.vlb,g.ylb],[r,n.y(r)]]}}default:{let g=m(a),y=m(l);return{faces:[[u,h,y,g],[g,y,f,d]],rim:[u,h,y,f,d,g],ridges:[[g,y]],gable:[[0,n.y(0)],[n.vr,n.rh],[r,n.y(r)]]}}}}function Es(i,e,t){let n=null;for(let r of i.faces){if(!Ge([e,t],r.map(([f,d])=>[f,d])))continue;let[s,o]=r,a=r.slice(2).find(f=>Math.abs((o[0]-s[0])*(f[1]-s[1])-(o[1]-s[1])*(f[0]-s[0]))>1e-9);if(!a)continue;let l=[o[0]-s[0],o[2]-s[2],o[1]-s[1]],c=[a[0]-s[0],a[2]-s[2],a[1]-s[1]],u=[l[1]*c[2]-l[2]*c[1],l[2]*c[0]-l[0]*c[2],l[0]*c[1]-l[1]*c[0]];if(Math.abs(u[1])<1e-9)continue;let h=s[2]-(u[0]*(e-s[0])+u[2]*(t-s[1]))/u[1];n=n===null?h:Math.min(n,h)}return n}function Lo(i,e,t,n){let r=o=>n?o[e]<=t+1e-9:o[e]>=t-1e-9,s=[];return i.forEach((o,a)=>{let l=i[(a+1)%i.length];if(r(o)&&s.push(o),r(o)!==r(l)){let c=(t-o[e])/(l[e]-o[e]);s.push([o[0]+(l[0]-o[0])*c,o[1]+(l[1]-o[1])*c,o[2]+(l[2]-o[2])*c])}}),s}function Wu(i,e){let t=Lo(Lo(i,0,e.u0,!1),0,e.u1,!0);return[Lo(i,0,e.u0,!0),Lo(i,0,e.u1,!1),Lo(t,1,e.v0,!0),Lo(t,1,e.v1,!1)].filter(r=>r.length>=3&&Math.abs(wr(r.map(([s,o])=>[s,o])))>1e-6)}function dl(i,e,t){let n=Un(e),r=i.floors.flatMap(h=>h.rooms.filter(f=>f.points.length>=3&&h.elevation+h.height>e.base+.05)),s=h=>h.some(f=>r.some(d=>Ge(f,d.points))),o=.35,a=[.15,.5,.85].map(h=>n.u0+(n.u1-n.u0)*h),l=[.15,.5,.85].map(h=>n.w*h),c=h=>h?0:t,u=(h,f)=>{let d=e.overhang_sides?.[h];return typeof d=="number"&&Number.isFinite(d)?Math.min(2,Math.max(0,d)):f};return{a:u("a",c(s(a.map(h=>n.at(h,-o))))),b:u("b",c(s(a.map(h=>n.at(h,n.w+o))))),u0:u("u0",c(s(l.map(h=>n.at(n.u0-o,h))))),u1:u("u1",c(s(l.map(h=>n.at(n.u1+o,h)))))}}var Fo=i=>Math.abs((i.x1-i.x0)*(i.z1-i.z0)),Xu=i=>i.shape==="flat"||i.shape==="parapet";function Rs(i,e){let[t,n]=[(e.x0+e.x1)/2,(e.z0+e.z1)/2];return i.filter(s=>{if(s===e||s.dormer||s.open||Xu(s)||Fo(s)=o.x0&&t<=o.x1&&n>=o.z0&&n<=o.z1}).reduce((s,o)=>s===null||Fo(o){let[s,o]=e.at(r,e.w/2),[a,l]=Oi(i,s,o);return Es(t,a,l)??n.y(l)}}function pl(i,e){if(Xu(e))return e;let t=Un(e),n=Rn(e).rh,r=sb(i,t),s=r(t.u0)<=r(t.u1),[o,a]=s?[t.u0,t.u1]:[t.u1,t.u0],l=s?1:-1,c=a;for(let f=.5;f=n-.02){c=o+l*f;break}if(Math.abs(c-a)<.05)return e;let u={...e},h=a===t.u1;return e.axis==="x"?u[h?"x1":"x0"]=c:u[h?"z1":"z0"]=c,u}function Yu(i,e){let t=pl(i,e),n=Un(t),r=Rn(t),s=sb(i,n),o=s(n.u0)<=s(n.u1),a=n.u1-n.u0,l=Math.max(1,Math.ceil(a/.15)),c=[];for(let u=0;ux+.02&&(m=Math.min(m,M),g=Math.max(g,M))}if(!(g-m>.05))continue;let y=Oi(i,...n.at(d,m)),_=Oi(i,...n.at(p,g));c.push({u0:Math.min(y[0],_[0]),u1:Math.max(y[0],_[0]),v0:Math.min(y[1],_[1]),v1:Math.max(y[1],_[1])})}return c}function ml(i,e){if(e.dormer||e.open||Xu(e)||Rs(i,e))return null;let t=As(e),n=.35;for(let r of i){if(r===e||r.dormer||r.open||Xu(r)||r.axis===e.axis||Fo(r)a[3]+.05)continue;let l=(o[2]+o[3])/2,[c,u]=e.axis==="z"?["z0","z1"]:["x0","x1"],h;if(Math.abs(o[0]-o[3])<=n)h=[l,o[1]];else if(Math.abs(o[1]-o[2])<=n)h=[o[0],l];else continue;let f={...e,[c]:h[0],[u]:h[1]};return{parent:r,extended:pl(r,f)}}return null}var ob=.14,yR=i=>i.shape==="flat"||i.shape==="parapet";function gp(i,e){return!i.open&&Math.min(i.base,i.eave_a,i.eave_b)l+r||fu+r||o.points&&o.points.length>=3&&!Ge([e,t],o.points))continue;let[d,p]=Oi(o,e,t),x=Math.max(0,o.overhang??n),m=yR(o)?null:Es(Wr(o,{u0:x,u1:x,a:x,b:x}),d,p);s.push((m??Rn(o).y(p))-ob)}return s.length?Math.max(...s):null}function yp(i,e){let t=i.floors.filter(l=>l.rooms.length>0).sort((l,c)=>l.elevation-c.elevation),n=t.filter(l=>l.elevationu.rooms.some(h=>h.points.length>=3&&l.some(f=>Ge(f,h.points))));if(c)return c}return n.at(-1)??t[0]}function bp(i,e,t){let n=i.settings.roof.sections??[],r=n.filter(l=>t.includes(l.id)).map(l=>Rs(n,l)??l);if(r.length===0)return e.id;let s=Math.max(...r.map(fp)),o=l=>l.rooms.some(c=>{if(c.points.length<3)return!1;let u=c.points.reduce((f,d)=>f+d[0],0)/c.points.length,h=c.points.reduce((f,d)=>f+d[1],0)/c.points.length;return r.some(f=>u>=Math.min(f.x0,f.x1)&&u<=Math.max(f.x0,f.x1)&&h>=Math.min(f.z0,f.z1)&&h<=Math.max(f.z0,f.z1))});return i.floors.filter(l=>l.elevation>=e.elevation&&l.elevationc.elevation-l.elevation)[0]?.id??e.id}var No=new D;function ab(i,e,t,n=1.05){return No.set(e[0],e[1],e[2]).project(i),{x:(No.x+1)/2*t.w,y:(1-No.y)/2*t.h,off:No.z>1||Math.abs(No.x)>n||Math.abs(No.y)>n}}var gl=i=>`translate(${i.x}px, ${i.y}px) translate(-50%, -50%)`,lb=(i,e)=>`translate(${i}px, ${e}px) translate(0, -50%)`,qu=class{placed=new WeakMap;place(e,t){let n=t===null;e.hidden!==n&&(e.hidden=n),!(t===null||this.placed.get(e)===t)&&(this.placed.set(e,t),e.style.transform=t)}},bR=8;function cb(i){let e=[...i].sort((t,n)=>n.rank-t.rank).map(t=>({...t}));for(let t=1;tc.xc.x>l.x?c:l),s=8+t.inset,[o,a]=[n.x-e-14,n.y];return o=.99&&i.o>=.9&&!e}function hb(i){return i.to>0&&Math.abs(i.o-i.to)<.05}function fb(i,e,t,n){return e===void 0?{y:t?i*2.4:0,opacity:1}:i>e?{y:5+i,opacity:0}:i===e?{y:0,opacity:1}:n==="stacked"?{y:0,opacity:1}:{y:-.4,opacity:n==="single"?0:.22}}function db(i,e){let[t,n]=[i.ty-i.y,i.to-i.o];if(Math.abs(t)<.004&&Math.abs(n)<.004){let r=t!==0||n!==0;return r&&([i.y,i.o]=[i.ty,i.to]),{moving:!1,settled:r}}return i.y+=t*e,i.o+=n*e,{moving:!0,settled:!1}}function pb(i,e){let t=e>.999;for(let n of[i.floor,i.wall,i.frames,i.blinds,i.lamps])n.transparent===t&&(n.transparent=!t,n.depthWrite=t,n.needsUpdate=!0),n.opacity=e;for(let n of i.ghosts)n.material.opacity=n.base*e;for(let n of[i.pattern,i.glow,i.lines,i.glass,i.glassWall,i.halos,i.cones,i.screens])n.opacity=e}var _p=i=>1-Math.exp(-i/140);var gb=["open","open2","tilt","tilt2"],Mp=i=>1-Math.exp(-i/160),mb=(i,e)=>(i??null)===(e??null)||typeof i=="number"&&typeof e=="number"&&Math.abs(i-e)<.003;function Sp(i,e){return gb.every(t=>mb(e[t]??0,i[t]??0))&&mb(e.cover,i.cover)&&!!e.sensed==!!i.sensed&&!!e.unlocked==!!i.unlocked&&!!e.assumed==!!i.assumed}function xb(i,e,t){let n={...i,open2:i.open2??0,tilt2:i.tilt2??0,sensed:e.sensed,unlocked:e.unlocked,assumed:e.assumed},r=!1,s=(o,a)=>Math.abs(a-o)<.003?a:(r=!0,o+(a-o)*t);for(let o of gb)n[o]=s(i[o]??0,e[o]??0);return n.cover=e.cover===null||i.cover===null?e.cover:s(i.cover,e.cover),{state:n,moving:r}}var Cs={ceiling:[.4,.4,.08],downlight:[.1,.1,.02],spot:[.1,.1,.14],panel:[.6,.6,.03],uplight:[.35,.35,1.8],bollard:[.16,.16,.8],garden:[.12,.12,.3],pendant:[.4,.4,.8],fan:[1.32,1.32,.32],floor:[.42,.42,1.7],table:[.26,.26,.45],wall:[.22,.12,.2],strip:[2,.04,.03]},$u=new Set(["ceiling","downlight","spot","panel","pendant","fan","strip"]),vR=1;function yb(i,e,t,n){switch(i){case"ceiling":return[e-.12,"ceiling"];case"downlight":return[e-.03,"spot"];case"spot":return[e-n,"spot"];case"panel":return[e-.05,"ceiling"];case"pendant":return[Math.max(.5,e-n),"pendant"];case"fan":return[Math.max(.5,e-n+.02),"ceiling"];case"floor":return[t+n-.15,"omni"];case"uplight":return[t+n,"up"];case"table":return[t+n-.1,"omni"];case"wall":return[t+.1,"wall"];case"strip":return[t+Math.max(.02,n)-.01,t_R&&d=0&&p<=1&&(l=d)}return l}function Mb(i,e,t){let n=i.count,r=e.wedge;if(!r)return{start:n,end:n};let s=(e.rotation??0)*mt,o=[-Math.sin(s),Math.cos(s)],a=r.angle*mt/2,l=new W(...r.color.map(d=>d*r.opacity)),c=new W(0,0,0),u=Math.max(4,Math.round(a/.15)),h=[e.x,e.z],f=(d,p)=>[e.x+(o[0]*Math.cos(d)-o[1]*Math.sin(d))*p,vb,e.z+(o[1]*Math.cos(d)+o[0]*Math.sin(d))*p];for(let d=0;d{i.positions.push(h,f,d);for(let x of t.color)i.colours.push(x*t.level*MR*p)};if(e.lamp==="strip")for(let h of[-.4,-.13,.13,.4])e.upright?u(e.x,a+r*(.5+h),e.z,.6):u(...Ku(e.x,c+Oo(e.base,r,e.rise),e.z,l,r,e.rise,h),.6);else e.lamp==="wall"?u(e.x-Math.sin(l)*(s/2+.05),c,e.z+Math.cos(l)*(s/2+.05),1):u(e.x,c,e.z,1)}function Tb(i,e,t,n){let[r,,s]=e.size??Cs[e.lamp],o=Sb(e.lamp,n,e.base??0,s),a=new W(...t.color.map(d=>d*.09*t.level)),l=new W(0,0,0),[c,u]=[Math.max(.03,r/2),.45+.35*t.level],h=16,f=(d,p,x)=>[e.x+Math.cos(d)*p,x,e.z+Math.sin(d)*p];for(let d=0;d$u.has(i);var Eb=7,SR=.25,wR=.3,TR=2,wp=[1,.82,.55],AR=.45;function Rb(i,e,t,n){return i?`${i.elevation.toFixed(1)},${i.azimuth.toFixed(1)},${e*mt},${t.toFixed(2)},${[...n].map(r=>(r.cover??0).toFixed(2)).join(",")}`:""}var Do=(i,e)=>[Math.sin((e+i)*mt),-Math.cos((e+i)*mt)],Tp=(i,e)=>Math.min(1,i/12)*(1-.8*e),ER=(i,e)=>-i.toRoom[0]*e[0]+-i.toRoom[1]*e[1];function Cb({floor:i,openings:e,states:t,sun:n,northDegrees:r,cloud:s}){let o=new ut;if(!n||n.elevation<=TR||s>=.97)return o;let a=Tp(n.elevation,s),l=Do(n.azimuth,r),c=1/Math.tan(n.elevation*mt);for(let u of e){if(u.opening.type!=="window"||!u.exterior)continue;let h=ER(u,l);if(h<.05)continue;let f=u.top-(t.get(u.opening.id)?.cover??0)*(u.top-u.sill);if(f-u.sill<.05)continue;let d=i.rooms.find(M=>M.id===u.opening.room_id);if(!d||d.points.length<3)continue;let p=(M,S)=>{let v=Math.min(Eb,S*c);return[u.start[0]+u.axis[0]*M+u.toRoom[0]*u.faceRoom-l[0]*v,.02,u.start[1]+u.axis[1]*M+u.toRoom[1]*u.faceRoom-l[1]*v]},x=.14*a*Math.min(1,h*1.5),m=new W(wp[0]*x,wp[1]*x,wp[2]*x),g=m.clone().multiplyScalar(AR),y=Math.max(1,Math.ceil(Math.min(Eb,f*c)/SR)),_=Math.max(1,Math.ceil(u.width/wR)),b=f-u.sill;for(let M=0;Me+Cn(t,i[(n+1)%i.length]),0)/2}var Ib=i=>Pb(i)>=0?[...i]:[...i].reverse();function Lb(i,e,t,n){let r=xt(e,i),s=xt(n,t),o=Cn(r,s);if(Math.abs(o)<1e-12)return null;let a=Cn(xt(t,i),s)/o,l=Cn(xt(t,i),r)/o;return a>pr&&a<1-pr&&l>-pr&&l<1+pr?a:null}function Ap(i,e,t){let n=xt(t,e),r=vn(n,n);if(r<1e-12)return null;let s=vn(xt(i,e),n)/r;return s<=pr||s>=1-pr?null:Math.abs(Cn(xt(i,e),n))/Math.sqrt(r)Jn(xt(i,e))i.map((e,t)=>[e,i[(t+1)%i.length]]);function RR(i,e){for(let[t,n]of yl(i))for(let[r,s]of yl(e))if(Lb(t,n,r,s)!==null||Ap(r,t,n)!==null||Ap(t,r,s)!==null||xl(t,r))return!0;return Ge(i[0],e)||Ge(e[0],i)}function CR(i){let e=i.map(Ib),t=[];e.forEach((s,o)=>{for(let[a,l]of yl(s)){let c=[0,1];e.forEach((u,h)=>{if(h!==o)for(let[f,d]of yl(u)){let p=Lb(a,l,f,d)??Ap(f,a,l);p!==null&&c.push(p)}}),c.sort((u,h)=>u-h);for(let u=1;um!==o&&Ge(p,x))||t.some(([x,m])=>xl(x,h)&&xl(m,f))||t.push([h,f])}}});let n=[],r=new Set;return t.forEach(([s,o],a)=>{if(r.has(a))return;r.add(a);let l=[s],c=o;for(let u=0;u!r.has(d)&&xl(f,c,.001));if(h<0)break;r.add(h),l.push(t[h][0]),c=t[h][1]}l.length>=3&&Pb(l)>1e-6&&n.push(l)}),n}function mr(i){let e=i.filter(s=>s.length>=3),t=e.map((s,o)=>o),n=s=>t[s]===s?s:t[s]=n(t[s]);e.forEach((s,o)=>{for(let a=o+1;ar.set(n(o),[...r.get(n(o))??[],s])),[...r.values()].flatMap(s=>s.length===1?s:CR(s))}function PR(i,e,t){let n=xt(t,e),r=vn(n,n),s=r?Math.max(0,Math.min(1,vn(xt(i,e),n)/r)):0;return Jn(xt(i,[e[0]+n[0]*s,e[1]+n[1]*s]))}function Fb(i,e,t=.03){return i.every(n=>Ge(n,e)||yl(e).some(([r,s])=>PR(n,r,s)<=t))}function Nb(i,e){let t=Ib(i),n=(r,s)=>{let o=xt(s,r),a=Jn(o)||1;return[-o[1]/a,o[0]/a]};return t.map((r,s)=>{let o=n(t[(s-1+t.length)%t.length],r),a=n(r,t[(s+1)%t.length]),l=1+vn(o,a);return l<.1?r:[r[0]+(o[0]+a[0])/l*e,r[1]+(o[1]+a[1])/l*e]})}var IR=30,Ob=i=>i.reduce((e,t,n)=>e+t[0]*i[(n+1)%i.length][1]-i[(n+1)%i.length][0]*t[1],0)/2;function LR(i,e,t,n){if(!t||t.elevation<=2||e<=0||!i.length)return[];let r=Math.min(IR,e/Math.tan(t.elevation*Math.PI/180)),[s,o]=Do(t.azimuth,n),a=c=>[c[0]-s*r,c[1]-o*r],l=[];for(let c of i){l.push([...c],c.map(a));let u=Math.sign(Ob(c))||1;c.forEach((h,f)=>{let d=c[(f+1)%c.length];if(u*((d[1]-h[1])*-s-(d[0]-h[0])*-o)<=1e-9)return;let x=[h,d,a(d),a(h)];Math.abs(Ob(x))>.001&&l.push(x)})}return mr(l)}var Zu=class{mesh;material=new Ye({color:0,side:ht,transparent:!0,opacity:0,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2});constructor(){this.mesh=new Se(new Pe,this.material),this.mesh.renderOrder=1,this.mesh.visible=!1}update(e,t,n,r,s,o,a){let l=a?[]:LR(e,t,r,s),c=[];for(let h of l){let f=e.filter(p=>Ge([p.reduce((x,m)=>x+m[0],0)/p.length,p.reduce((x,m)=>x+m[1],0)/p.length],h)),d=[...h,...f.flat()];for(let[p,x,m]of Gr(h,f.map(g=>[...g])))for(let g of[d[p],d[x],d[m]])c.push(g[0],n,g[1])}this.mesh.geometry.dispose();let u=new Pe;u.setAttribute("position",new Le(c,3)),this.mesh.geometry=u,this.material.opacity=r?.32*Tp(r.elevation,o):0,this.mesh.visible=c.length>0&&this.material.opacity>.02}dispose(){this.mesh.geometry.dispose(),this.material.dispose()}};var bl=i=>ts(i)>=0?i:[...i].reverse();function vl(i,[e,t],n,r,s,o,a){Tt(i,bl([[e-n,t-n],[e+n,t-n],[e+n,t+n],[e-n,t+n]]),r,s,o,a)}function Ju(i,e,t,n,r,s,o,a,l=0){let[c,u]=[t[0]-e[0],t[1]-e[1]],h=Math.hypot(c,u);if(h<1e-6)return;let[f,d]=[-u/h*n*.5,c/h*n*.5];if(Math.abs(l)<1e-4){Tt(i,bl([[e[0]+f,e[1]+d],[t[0]+f,t[1]+d],[t[0]-f,t[1]-d],[e[0]-f,e[1]-d]]),r,s,o,a,{aoFrom:r-1});return}let p=(b,M)=>[e[0]+f*M,b,e[1]+d*M],x=(b,M)=>[t[0]+f*M,b+l,t[1]+d*M],m=(b,M)=>{for(let[S,v,w]of[[0,1,2],[0,2,3],[0,2,1],[0,3,2]])i.tri(b[S],b[v],b[w],M,M,M,void 0,$e)},g=new W(a),y=Be(o,.9),_=Be(o,.6);m([p(s,1),x(s,1),x(s,-1),p(s,-1)],g),m([p(r,1),x(r,1),x(r,-1),p(r,-1)],_),m([p(r,1),x(r,1),x(s,1),p(s,1)],y),m([p(r,-1),x(r,-1),x(s,-1),p(s,-1)],y),m([p(r,1),p(r,-1),p(s,-1),p(s,1)],y),m([x(r,1),x(r,-1),x(s,-1),x(s,1)],y)}function Db(i,e,t){let n=(o,a)=>Math.abs(o[0]-a[0])<1e-6&&Math.abs(o[1]-a[1])<1e-6,r=Math.hypot(t[0]-e[0],t[1]-e[1]),s=[];for(let o of i.gates??[]){let a=i.points[o.edge],l=i.points[(o.edge+1)%i.points.length];!a||!l||(n(a,e)&&n(l,t)?s.push({gate:o,offset:o.offset}):n(a,t)&&n(l,e)&&s.push({gate:o,offset:r-o.offset}))}return s.sort((o,a)=>o.offset-a.offset)}function Ub(i,e,t,n,r){let s=Math.hypot(e[0]-i[0],e[1]-i[1]);if(s<.3)return null;let o=Math.min(t.width,s-.1);if(o<.3)return null;let a=Math.max(.05,Math.min(s-o-.05,n-o/2)),l=a+o,[c,u]=[(e[0]-i[0])/s,(e[1]-i[1])/s],[h,f]=[-u,c],d=(g,y=0)=>[i[0]+c*g+h*y,i[1]+u*g+f*y],[p,x]=[d(a),d(l)],m=[];if(t.kind==="double"){let g=(a+l)/2;m.push(r?{a:p,b:d(a,o/2)}:{a:p,b:d(g)}),m.push(r?{a:x,b:d(l,o/2)}:{a:x,b:d(g)})}else t.kind==="sliding"?m.push(r?{a:d(l,-.12),b:d(l+o,-.12)}:{a:p,b:x}):m.push(r?{a:p,b:d(a,o)}:{a:p,b:x});return{from:a,to:l,posts:[p,x],leaves:m}}var kb={lawn:{color:927778,side:729115,edge:4121250,edgeAlpha:.16},terrace:{color:1841968,side:1447464,edge:5995775,edgeAlpha:.32},path:{color:1778228,side:1383209,edge:5995775,edgeAlpha:.22},driveway:{color:1514796,side:1185573,edge:5995775,edgeAlpha:.18},pavers:{color:4736319,side:2696992,edge:10853768,edgeAlpha:.25},stepping_stones:{color:5592907,side:2699042,edge:10399619,edgeAlpha:.22},natural_stone:{color:5327421,side:2696735,edge:11641738,edgeAlpha:.25},street:{color:2369325,side:1382430,edge:10134706,edgeAlpha:.25},sidewalk:{color:4739163,side:2699579,edge:11451337,edgeAlpha:.28},gravel:{color:5327678,side:2762786,edge:12101762,edgeAlpha:.26},river:{color:1393488,side:1060150,edge:4829115,edgeAlpha:.3},stream:{color:2118484,side:1522750,edge:6669508,edgeAlpha:.3},pool:{color:736091,side:861497,edge:3662079,edgeAlpha:.6},bed:{color:1775123,side:1380623,edge:4121250,edgeAlpha:.2},wild:{color:1384987,side:1055509,edge:10146383,edgeAlpha:.14},hedge:{color:1524016,side:1126693,edge:4121250,edgeAlpha:.35},fence:{color:1976903,side:1976903,edge:5995775,edgeAlpha:.45},pergola:{color:2827065,side:2104109,edge:5995775,edgeAlpha:.5}};var Bb={lawn:1,terrace:2,path:3,driveway:4,pool:5,bed:6,wild:7,hedge:8,fence:9,pergola:9,street:10,sidewalk:11,gravel:12,river:13,stream:14,pavers:15,stepping_stones:16,natural_stone:17},FR=` +}`,Yd=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Ca(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new Si({vertexShader:YE,fragmentShader:qE,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Se(new sn(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},qd=class extends vi{constructor(e,t){super();let n=this,r=null,s=1,o=null,a="local-floor",l=1,c=null,u=null,h=null,f=null,d=null,p=null,x=typeof XRWebGLBinding<"u",m=new Yd,g={},y=t.getContextAttributes(),_=null,b=null,M=[],S=[],v=new ke,w=null,P=null,T=new Jt;T.viewport=new vt;let R=new Jt;R.viewport=new vt;let L=[T,R],U=new qc,C=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let Q=M[Y];return Q===void 0&&(Q=new mo,M[Y]=Q),Q.getTargetRaySpace()},this.getControllerGrip=function(Y){let Q=M[Y];return Q===void 0&&(Q=new mo,M[Y]=Q),Q.getGripSpace()},this.getHand=function(Y){let Q=M[Y];return Q===void 0&&(Q=new mo,M[Y]=Q),Q.getHandSpace()};function O(Y){let Q=S.indexOf(Y.inputSource);if(Q===-1)return;let se=M[Q];se!==void 0&&(se.update(Y.inputSource,Y.frame,c||o),se.dispatchEvent({type:Y.type,data:Y.inputSource}))}function F(){r.removeEventListener("select",O),r.removeEventListener("selectstart",O),r.removeEventListener("selectend",O),r.removeEventListener("squeeze",O),r.removeEventListener("squeezestart",O),r.removeEventListener("squeezeend",O),r.removeEventListener("end",F),r.removeEventListener("inputsourceschange",H);for(let Y=0;Y=0&&(S[we]=null,M[we].disconnect(se))}for(let Q=0;Q=S.length){S.push(se),we=Ne;break}else if(S[Ne]===null){S[Ne]=se,we=Ne;break}if(we===-1)break}let le=M[we];le&&le.connect(se)}}function k(Y,Q){Q===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(Q.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(r===null)return;let Q=Y.near,se=Y.far;m.texture!==null&&(m.depthNear>0&&(Q=m.depthNear),m.depthFar>0&&(se=m.depthFar)),U.near=R.near=T.near=Q,U.far=R.far=T.far=se,(C!==U.near||I!==U.far)&&(r.updateRenderState({depthNear:U.near,depthFar:U.far}),C=U.near,I=U.far),U.layers.mask=Y.layers.mask|6,T.layers.mask=U.layers.mask&-5,R.layers.mask=U.layers.mask&-3;let we=Y.parent,le=U.cameras;k(U,we);for(let Ne=0;Ne0&&(m.alphaTest.value=g.alphaTest);let y=e.get(g),_=y.envMap,b=y.envMapRotation;_&&(m.envMap.value=_,m.envMapRotation.value.setFromMatrix4($E.makeRotationFromEuler(b)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Ay),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function o(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function a(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function l(m,g,y,_){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*y,m.scale.value=_*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function h(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function f(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function d(m,g,y){m.ior.value=g.ior,g.diffuseRoughness>0&&(m.diffuseRoughness.value=g.diffuseRoughness,g.diffuseRoughnessMap&&(m.diffuseRoughnessMap.value=g.diffuseRoughnessMap,t(g.diffuseRoughnessMap,m.diffuseRoughnessMapTransform))),g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===un&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.retroreflectivity>0&&(m.retroreflectivity.value=g.retroreflectivity),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessMinimum,m.iridescenceThicknessMaximum.value=g.iridescenceThicknessMaximum,g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=y.texture,m.transmissionSamplerSize.value.set(y.width,y.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function x(m,g){let y=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(y.matrixWorld),m.nearDistance.value=y.shadow.camera.near,m.farDistance.value=y.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function ZE(i,e,t,n){let r={},s={};function o(y,_){let b=_.program;n.uniformBlockBinding(y,b,r[y.id])}function a(y,_){let b=r[y.id];b===void 0&&(p(y),b=l(y),r[y.id]=b,y.addEventListener("dispose",m));let M=_.program;n.updateUBOMapping(y,M);let S=e.render.frame;s[y.id]!==S&&(c(y),s[y.id]=S)}function l(y){let _=i.createBuffer(),b=y.__size,M=y.usage;return i.bindBuffer(i.UNIFORM_BUFFER,_),i.bufferData(i.UNIFORM_BUFFER,b,M),i.bindBuffer(i.UNIFORM_BUFFER,null),_}function c(y){let _=r[y.id],b=y.uniforms,M=y.__cache;i.bindBuffer(i.UNIFORM_BUFFER,_);for(let S=0,v=b.length;S0&&(b+=M-S),y.__size=b,y.__cache={},this}function x(y,_){let b={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(b.boundary=4,b.storage=4):y.isVector2?(b.boundary=8,b.storage=8):y.isVector3||y.isColor?(b.boundary=16,b.storage=12):y.isVector4?(b.boundary=16,b.storage=16):y.isMatrix3?(b.boundary=16,b.storage=48):y.isMatrix4?(b.boundary=16,b.storage=64):y.isTexture?Oe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(b.boundary=16,b.storage=y.byteLength):Oe("WebGLRenderer: Unsupported uniform value type.",y),_===!0&&(b.boundary=16,b.storage=Math.ceil(b.storage/16)*16),b}function m(y){let _=y.target;_.removeEventListener("dispose",m),i.deleteBuffer(r[_.id]),delete r[_.id],delete s[_.id]}function g(){for(let y in r)i.deleteBuffer(r[y]);r={},s={}}return{bind:o,update:a,dispose:g}}var JE=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),Pi=null;function jE(){return Pi===null&&(Pi=new xo(JE,16,16,Br,li),Pi.name="DFG_LUT",Pi.minFilter=Ht,Pi.magFilter=Ht,Pi.wrapS=ln,Pi.wrapT=ln,Pi.generateMipmaps=!1,Pi.needsUpdate=!0),Pi}var Vr=class{constructor(e={}){let{canvas:t=Dx(),context:n=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reversedDepthBuffer:f=!1,outputBufferType:d=On}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=o;let x=d,m=new Set([ru,iu,nu]),g=new Set([On,ai,To,vs,Qc,eu]),y=new Uint32Array(4),_=new Int32Array(4),b={textures:[],min:[],max:[],resolution:[]},M=null,S=null,v=[],w=[],P=null;this.domElement=t,this.debug={checkShaderErrors:!0,diagnostics:{keywords:!1},onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Ri,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let T=this,R=!1,L=null,U=null,C=null,I=null;this._outputColorSpace=dt;let O=0,F=0,H=null,k=-1,X=null,V=new vt,re=new vt,ye=null,Y=new W(0),Q=0,se=t.width,we=t.height,le=1,Ne=null,at=null,Ae=new vt(0,0,se,we),ft=new vt(0,0,se,we),yt=!1,nt=new Nr,Yt=new Nc,Bt=!1,on=!1,Nt=new ze,xi=new D,en=new vt,Wn={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Xn=!1;function Yn(){return H===null?le:1}let G=n;function qn(E,z){return t.getContext(E,z)}let Pt,It,be,Zt,Ve,qe,N,A,K,oe,ie,he,ge,ee,te,de,B,ne,j,pe,ce,fe,De;try{let E={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"187"}`),t.addEventListener("webglcontextlost",Ue,!1),t.addEventListener("webglcontextrestored",je,!1),t.addEventListener("webglcontextcreationerror",ve,!1),G===null){let z="webgl2";if(G=qn(z,E),G===null)throw qn(z)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}Qe()}catch(E){throw t.removeEventListener("webglcontextlost",Ue,!1),t.removeEventListener("webglcontextrestored",je,!1),t.removeEventListener("webglcontextcreationerror",ve,!1),We("WebGLRenderer: "+E.message),E}function Qe(){Pt=new cA(G),Pt.init(),ce=new XE(G,Pt),It=new jT(G,Pt,e,ce),be=new HE(G,Pt),It.reversedDepthBuffer&&f&&be.buffers.depth.setReversed(!0),U=G.createFramebuffer(),C=G.createFramebuffer(),I=G.createFramebuffer(),Zt=new fA(G),Ve=new CE,qe=new WE(G,Pt,be,Ve,It,ce,Zt),N=new lA(T),A=new pw(G),fe=new ZT(G,A),K=new uA(G,A,Zt,fe),oe=new pA(G,K,A,fe,Zt),ne=new dA(G,It,qe),te=new QT(Ve),ie=new RE(T,N,Pt,It,fe,te),he=new KE(T,Ve),ge=new IE,ee=new kE(Pt),B=new KT(T,N,be,oe,p,l),de=new GE(T,oe,It),De=new ZE(G,Zt,It,be),j=new JT(G,Pt,Zt),pe=new hA(G,Pt,Zt),Zt.programs=ie.programs,T.capabilities=It,T.extensions=Pt,T.properties=Ve,T.renderLists=ge,T.shadowMap=de,T.state=be,T.info=Zt}x!==On&&(P=new gA(x,t.width,t.height,a,r,s));let ae=new qd(T,G);this.xr=ae,this.getContext=function(){return G},this.getContextAttributes=function(){return G.getContextAttributes()},this.forceContextLoss=function(){let E=Pt.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){let E=Pt.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return le},this.setPixelRatio=function(E){E!==void 0&&(le=E,this.setSize(se,we,!1))},this.getSize=function(E){return E.set(se,we)},this.setSize=function(E,z,J=!0){if(ae.isPresenting){Oe("WebGLRenderer: Can't change size while VR device is presenting.");return}se=E,we=z,t.width=Math.floor(E*le),t.height=Math.floor(z*le),J===!0&&(t.style.width=E+"px",t.style.height=z+"px"),P!==null&&P.setSize(t.width,t.height),this.setViewport(0,0,E,z)},this.getDrawingBufferSize=function(E){return E.set(se*le,we*le).floor()},this.setDrawingBufferSize=function(E,z,J){se=E,we=z,le=J,t.width=Math.floor(E*J),t.height=Math.floor(z*J),this.setViewport(0,0,E,z)},this.setEffects=function(E){if(x===On){We("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let z=0;z{function xe(){if($.forEach(function(Ee){let Me=Ve.get(Ee).currentProgram;(Me===void 0||Me.isReady())&&$.delete(Ee)}),$.size===0){Z(E);return}setTimeout(xe,10)}Pt.get("KHR_parallel_shader_compile")!==null?xe():setTimeout(xe,10)})};let lf=null;function P1(E){lf&&lf(E)}function E0(){Kr.stop()}function R0(){Kr.start()}let Kr=new gy;Kr.setAnimationLoop(P1),typeof self<"u"&&Kr.setContext(self),this.setAnimationLoop=function(E){lf=E,ae.setAnimationLoop(E),E===null?Kr.stop():Kr.start()},ae.addEventListener("sessionstart",E0),ae.addEventListener("sessionend",R0),this.render=function(E,z){if(z!==void 0&&z.isCamera!==!0){We("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(R===!0)return;L!==null&&L.renderStart(E,z);let J=ae.enabled===!0&&ae.isPresenting===!0,$=P!==null&&(H===null||J)&&P.begin(T,H);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),z.parent===null&&z.matrixWorldAutoUpdate===!0&&z.updateMatrixWorld(),ae.enabled===!0&&ae.isPresenting===!0&&(P===null||P.isCompositing()===!1)&&(ae.cameraAutoUpdate===!0&&ae.updateCamera(z),z=ae.getCamera()),E.isScene===!0&&E.onBeforeRender(T,E,z,H),S=ee.get(E,w.length),S.init(z),S.state.textureUnits=qe.getTextureUnits(),w.push(S),Nt.multiplyMatrices(z.projectionMatrix,z.matrixWorldInverse),z.isArrayCamera?Yt.setFromArrayCamera(z):nt.setFromProjectionMatrix(Nt,Kn,z.reversedDepth),on=this.localClippingEnabled,Bt=te.init(this.clippingPlanes,on),M=ge.get(E,v.length),M.init(),v.push(M),this.info.render.frame++,ae.enabled===!0&&ae.isPresenting===!0){let Ee=T.xr.getDepthSensingMesh();Ee!==null&&cf(Ee,z,-1/0,T.sortObjects)}cf(E,z,0,T.sortObjects),M.finish(),L!==null&&L.updateLights(S.state.lightsArray),T.sortObjects===!0&&M.sort(Ne,at),Xn=ae.enabled===!1||ae.isPresenting===!1||ae.hasDepthSensing()===!1,Xn&&B.addToRenderList(M,E),this.info.autoReset===!0&&this.info.reset(),Bt===!0&&te.beginShadows();let Z=S.state.shadowsArray;if(de.render(Z,E,z),Bt===!0&&te.endShadows(),($&&P.hasRenderPass())===!1){let Ee=M.opaque,me=M.transmissive;if(S.setupLights(),z.isArrayCamera){let Me=z.cameras;if(me.length>0)for(let Ie=0,Ke=Me.length;Ie0&&P0(Ee,me,E,z),Xn&&B.render(E),C0(M,E,z)}H!==null&&F===0&&(qe.updateMultisampleRenderTarget(H),qe.updateRenderTargetMipmap(H)),$&&P.end(T),E.isScene===!0&&E.onAfterRender(T,E,z),fe.resetDefaultState(),k=-1,X=null,w.pop(),w.length>0?(S=w[w.length-1],qe.setTextureUnits(S.state.textureUnits),Bt===!0&&te.setGlobalState(T.clippingPlanes,S.state.camera)):S=null,v.pop(),v.length>0?M=v[v.length-1]:M=null,L!==null&&L.renderEnd()};function cf(E,z,J,$){if(E.visible===!1)return;if(E.layers.test(z.layers)){if(E.isGroup)J=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(z);else if(E.isLight)S.pushLight(E),E.castShadow&&S.pushShadow(E);else if(E.isSprite){let Ee=z.isArrayCamera?Yt:nt;if(!E.frustumCulled||E.intersectsFrustum(Ee)){$&&en.setFromMatrixPosition(E.matrixWorld).applyMatrix4(Nt);let me=oe.update(E),Me=E.material;Me.visible&&M.push(E,me,Me,J,en.z,null,z)}}else if(E.isMesh||E.isLine||E.isPoints){let Ee=z.isArrayCamera?Yt:nt;if(!E.frustumCulled||E.intersectsFrustum(Ee)){let me=oe.update(E),Me=E.material;if($&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),en.copy(E.boundingSphere.center)):(me.boundingSphere===null&&me.computeBoundingSphere(),en.copy(me.boundingSphere.center)),en.applyMatrix4(E.matrixWorld).applyMatrix4(Nt)),Array.isArray(Me)){let Ie=me.groups;for(let Ke=0,lt=Ie.length;Ke0&&zl(Z,z,J),xe.length>0&&zl(xe,z,J),Ee.length>0&&zl(Ee,z,J),be.buffers.depth.setTest(!0),be.buffers.depth.setMask(!0),be.buffers.color.setMask(!0),be.setPolygonOffset(!1)}function P0(E,z,J,$){if((J.isScene===!0?J.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[$.id]===void 0){let Re=Pt.has("EXT_color_buffer_half_float")||Pt.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[$.id]=new Tn(1,1,{generateMipmaps:!0,type:Re?li:On,minFilter:Nn,samples:Math.max(4,It.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:it.workingColorSpace})}let xe=S.state.transmissionRenderTarget[$.id],Ee=$.viewport||V;xe.setSize(Ee.z*T.transmissionResolutionScale,Ee.w*T.transmissionResolutionScale);let me=T.getRenderTarget(),Me=T.getActiveCubeFace(),Ie=T.getActiveMipmapLevel();T.setRenderTarget(xe),T.getClearColor(Y),Q=T.getClearAlpha(),Q<1&&T.setClearColor(16777215,.5),T.clear(),Xn&&B.render(J);let Ke=T.toneMapping;T.toneMapping=Ri;let lt=$.viewport;if($.viewport!==void 0&&($.viewport=void 0),S.setupLightsView($),Bt===!0&&te.setGlobalState(T.clippingPlanes,$),zl(E,J,$),qe.updateMultisampleRenderTarget(xe),qe.updateRenderTargetMipmap(xe),Pt.has("WEBGL_multisampled_render_to_texture")===!1){let Re=!1;for(let ct=0,qt=z.length;ct0),Re=!!J.morphAttributes.position,ct=!!J.morphAttributes.normal,qt=!!J.morphAttributes.color,Rt=Ri;$.toneMapped&&(H===null||H.isXRRenderTarget===!0)&&(Rt=T.toneMapping);let At=J.morphAttributes.position||J.morphAttributes.normal||J.morphAttributes.color,hn=At!==void 0?At.length:0,Ce=Ve.get($),_n=S.state.lights;if(Bt===!0&&(on===!0||E!==X)){let Ot=E===X&&$.id===k;te.setState($,E,Ot)}let bt=!1,Zr=!1;$.version===Ce.__version?Ce.needsLights&&Ce.lightsStateVersion!==_n.state.version||Z.isBatchedMesh&&Ce.batching===!1||!Z.isBatchedMesh&&Ce.batching===!0||Z.isBatchedMesh&&Ce.batchingColor===!0&&Z._colorsTexture===null||Z.isBatchedMesh&&Ce.batchingColor===!1&&Z._colorsTexture!==null||Z.isInstancedMesh&&Ce.instancing===!1||!Z.isInstancedMesh&&Ce.instancing===!0||Z.isSkinnedMesh&&Ce.skinning===!1||!Z.isSkinnedMesh&&Ce.skinning===!0||Z.isInstancedMesh&&Ce.instancingColor===!0&&Z.instanceColor===null||Z.isInstancedMesh&&Ce.instancingColor===!1&&Z.instanceColor!==null||Z.isInstancedMesh&&Ce.instancingMorph===!0&&Z.morphTexture===null||Z.isInstancedMesh&&Ce.instancingMorph===!1&&Z.morphTexture!==null||Ce.envMap!==Ie||$.fog===!0&&Ce.fog!==xe||Ce.numClippingPlanes!==void 0&&(Ce.numClippingPlanes!==te.numPlanes||Ce.numIntersection!==te.numIntersection)||Ce.vertexAlphas!==Ke||Ce.vertexTangents!==lt||Ce.morphTargets!==Re||Ce.morphNormals!==ct||Ce.morphColors!==qt||Ce.morphTargetsCount!==hn||Ce.numLightProbeGrids!==L0(S.state.lightProbeGridArray)?bt=!0:(Ce.outputColorSpace!==me||Ce.toneMapping!==Rt)&&(Zr=!0):(bt=!0,Ce.__version=$.version);let fn=Ce.currentProgram;(bt===!0||Zr===!0)&&(fn=Zr===!0?I1($,z,Z,me,Rt):Qo($,z,Z),L&&$.isNodeMaterial&&L.onUpdateProgram($,fn,Ce));let Vl=!1,Mr=!1,Jr=!1,pt=fn.getUniforms(),an=Ce.uniforms;if(be.useProgram(fn.program)&&(Vl=!0,Mr=!0,Jr=!0),$.id!==k&&(k=$.id,Mr=!0),Vl||X!==E){be.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),pt.setValue(G,"projectionMatrix",E.projectionMatrix),pt.setValue(G,"viewMatrix",E.matrixWorldInverse);let nn=pt.map.cameraPosition;nn!==void 0&&nn.setValue(G,xi.setFromMatrixPosition(E.matrixWorld)),It.logarithmicDepthBuffer&&pt.setValue(G,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),($.isMeshPhongMaterial||$.isMeshToonMaterial||$.isMeshLambertMaterial||$.isMeshBasicMaterial||$.isMeshStandardMaterial||$.isShaderMaterial)&&pt.setValue(G,"isOrthographic",E.isOrthographicCamera===!0),X!==E&&(X=E,Mr=!0,Jr=!0)}if(Ce.needsLights&&(_n.state.sunShadowMap.length>0&&pt.setValue(G,"sunShadowMap",_n.state.sunShadowMap,qe),_n.state.directionalShadowMap.length>0&&pt.setValue(G,"directionalShadowMap",_n.state.directionalShadowMap,qe),_n.state.spotShadowMap.length>0&&pt.setValue(G,"spotShadowMap",_n.state.spotShadowMap,qe),_n.state.pointShadowMap.length>0&&pt.setValue(G,"pointShadowMap",_n.state.pointShadowMap,qe)),Z.isSkinnedMesh){pt.setOptional(G,Z,"bindMatrix"),pt.setOptional(G,Z,"bindMatrixInverse");let Ot=Z.skeleton;Ot&&(Ot.boneTexture===null&&Ot.computeBoneTexture(),pt.setValue(G,"boneTexture",Ot.boneTexture,qe))}Z.isBatchedMesh&&(pt.setOptional(G,Z,"batchingTexture"),pt.setValue(G,"batchingTexture",Z._matricesTexture,qe),pt.setOptional(G,Z,"batchingIdTexture"),pt.setValue(G,"batchingIdTexture",Z._indirectTexture,qe),pt.setOptional(G,Z,"batchingColorTexture"),Z._colorsTexture!==null&&pt.setValue(G,"batchingColorTexture",Z._colorsTexture,qe));let ii=J.morphAttributes;if((ii.position!==void 0||ii.normal!==void 0||ii.color!==void 0)&&ne.update(Z,J,fn),(Mr||Ce.receiveShadow!==Z.receiveShadow)&&(Ce.receiveShadow=Z.receiveShadow,pt.setValue(G,"receiveShadow",Z.receiveShadow)),($.isMeshStandardMaterial||$.isMeshLambertMaterial||$.isMeshPhongMaterial)&&$.envMap===null&&z.environment!==null&&(an.envMapIntensity.value=z.environmentIntensity),an.dfgLUT!==void 0&&(an.dfgLUT.value=jE()),Mr){if(pt.setValue(G,"toneMappingExposure",T.toneMappingExposure),Ce.needsLights&&F1(an,Jr),xe&&$.fog===!0&&he.refreshFogUniforms(an,xe),he.refreshMaterialUniforms(an,$,le,we,S.state.transmissionRenderTarget[E.id]),Ce.needsLights&&Ce.numLightProbeGrids>0){let Ot=b,nn=0;for(let Vi of S.state.lightProbeGridArray)Vi.texture!==null&&(Ot.textures[nn]=Vi.texture,Ot.min[nn]=Vi.boundingBox.min,Ot.max[nn]=Vi.boundingBox.max,Ot.resolution[nn]=Vi.resolution,nn++);for(let Vi in Ot)Ot[Vi].length=nn;an.probesSH.value=Ot.textures,an.probesMin.value=Ot.min,an.probesMax.value=Ot.max,an.probesResolution.value=Ot.resolution}Eo.upload(G,F0(Ce),an,qe)}if($.isShaderMaterial&&$.uniformsNeedUpdate===!0&&(Eo.upload(G,F0(Ce),an,qe),$.uniformsNeedUpdate=!1),$.isSpriteMaterial&&pt.setValue(G,"center",Z.center),pt.setValue(G,"modelViewMatrix",Z.modelViewMatrix),pt.setValue(G,"normalMatrix",Z.normalMatrix),pt.setValue(G,"modelMatrix",Z.matrixWorld),$.uniformsGroups!==void 0){let Ot=$.uniformsGroups;for(let nn=0,Vi=Ot.length;nn0&&qe.useMultisampledRTT(E)===!1?$=Ve.get(E).__webglMultisampledFramebuffer:Array.isArray(Ie)?$=Ie[J]:$=Ie,V.copy(E.viewport),re.copy(E.scissor),ye=E.scissorTest}else V.copy(Ae).multiplyScalar(le).floor(),re.copy(ft).multiplyScalar(le).floor(),ye=yt;if(J!==0&&($=U),be.bindFramebuffer(G.FRAMEBUFFER,$)&&be.drawBuffers(E,$),be.viewport(V),be.scissor(re),be.setScissorTest(ye),Z){let me=Ve.get(E.texture);G.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_CUBE_MAP_POSITIVE_X+z,me.__webglTexture,J)}else if(xe){let me=z;for(let Me=0;Me1&&G.readBuffer(G.COLOR_ATTACHMENT0+me);let Re=O0(Ie);if(Re.__formatReadable===!1){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(Re.__typeReadable===!1){We("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}z>=0&&z<=E.width-$&&J>=0&&J<=E.height-Z&&G.readPixels(z,J,$,Z,ce.convert(Ke),ce.convert(lt),xe)}finally{let Ie=H!==null?Ve.get(H).__webglFramebuffer:null;be.bindFramebuffer(G.FRAMEBUFFER,Ie)}}},this.readRenderTargetPixelsAsync=async function(E,z,J,$,Z,xe,Ee,me=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Me=Ve.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&Ee!==void 0&&(Me=Me[Ee],Array.isArray(Me)&&(Me=Me[0])),Me)if(z>=0&&z<=E.width-$&&J>=0&&J<=E.height-Z){be.bindFramebuffer(G.FRAMEBUFFER,Me);let Ie=E.textures[me],Ke=Ie.format,lt=Ie.type;E.textures.length>1&&G.readBuffer(G.COLOR_ATTACHMENT0+me);let Re=O0(Ie);if(Re.__formatReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(Re.__typeReadable===!1)throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let ct=G.createBuffer();G.bindBuffer(G.PIXEL_PACK_BUFFER,ct),G.bufferData(G.PIXEL_PACK_BUFFER,xe.byteLength,G.STREAM_READ),G.readPixels(z,J,$,Z,ce.convert(Ke),ce.convert(lt),0),G.bindBuffer(G.PIXEL_PACK_BUFFER,null);let qt=H!==null?Ve.get(H).__webglFramebuffer:null;be.bindFramebuffer(G.FRAMEBUFFER,qt);let Rt=G.fenceSync(G.SYNC_GPU_COMMANDS_COMPLETE,0);return G.flush(),await Ux(G,Rt,4),G.bindBuffer(G.PIXEL_PACK_BUFFER,ct),G.getBufferSubData(G.PIXEL_PACK_BUFFER,0,xe),G.bindBuffer(G.PIXEL_PACK_BUFFER,null),G.deleteBuffer(ct),G.deleteSync(Rt),xe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,z=null,J=0){let $=Math.pow(2,-J),Z=Math.floor(E.image.width*$),xe=Math.floor(E.image.height*$),Ee=z!==null?z.x:0,me=z!==null?z.y:0;qe.setTexture2D(E,0),G.copyTexSubImage2D(G.TEXTURE_2D,J,0,0,Ee,me,Z,xe),be.unbindTexture()},this.copyTextureToTexture=function(E,z,J=null,$=null,Z=0,xe=0){let Ee,me,Me,Ie,Ke,lt,Re,ct,qt,Rt=E.isCompressedTexture?E.mipmaps[xe]:E.image;if(J!==null)Ee=J.max.x-J.min.x,me=J.max.y-J.min.y,Me=J.isBox3?J.max.z-J.min.z:1,Ie=J.min.x,Ke=J.min.y,lt=J.isBox3?J.min.z:0;else{let pt=Math.pow(2,-Z);Ee=Math.floor(Rt.width*pt),me=Math.floor(Rt.height*pt),E.isDataArrayTexture?Me=Rt.depth:E.isData3DTexture?Me=Math.floor(Rt.depth*pt):Me=1,Ie=0,Ke=0,lt=0}$!==null?(Re=$.x,ct=$.y,qt=$.z):(Re=0,ct=0,qt=0);let At=ce.convert(z.format),hn=ce.convert(z.type),Ce;z.isData3DTexture?(qe.setTexture3D(z,0),Ce=G.TEXTURE_3D):z.isDataArrayTexture||z.isCompressedArrayTexture?(qe.setTexture2DArray(z,0),Ce=G.TEXTURE_2D_ARRAY):(qe.setTexture2D(z,0),Ce=G.TEXTURE_2D),be.activeTexture(G.TEXTURE0),be.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,z.flipY),be.pixelStorei(G.UNPACK_PREMULTIPLY_ALPHA_WEBGL,z.premultiplyAlpha),be.pixelStorei(G.UNPACK_ALIGNMENT,z.unpackAlignment);let _n=be.getParameter(G.UNPACK_ROW_LENGTH),bt=be.getParameter(G.UNPACK_IMAGE_HEIGHT),Zr=be.getParameter(G.UNPACK_SKIP_PIXELS),fn=be.getParameter(G.UNPACK_SKIP_ROWS),Vl=be.getParameter(G.UNPACK_SKIP_IMAGES);be.pixelStorei(G.UNPACK_ROW_LENGTH,Rt.width),be.pixelStorei(G.UNPACK_IMAGE_HEIGHT,Rt.height),be.pixelStorei(G.UNPACK_SKIP_PIXELS,Ie),be.pixelStorei(G.UNPACK_SKIP_ROWS,Ke),be.pixelStorei(G.UNPACK_SKIP_IMAGES,lt);let Mr=E.isDataArrayTexture||E.isData3DTexture,Jr=z.isDataArrayTexture||z.isData3DTexture;if(E.isDepthTexture){let pt=Ve.get(E),an=Ve.get(z),ii=Ve.get(pt.__renderTarget),Ot=Ve.get(an.__renderTarget);be.bindFramebuffer(G.READ_FRAMEBUFFER,ii.__webglFramebuffer),be.bindFramebuffer(G.DRAW_FRAMEBUFFER,Ot.__webglFramebuffer);for(let nn=0;nn.5+.5*Math.min(1,Math.max(0,i/1.6));function Zd(i,e){let t=Math.hypot(i,e);return .8+.28*((e/t*sl[0]-i/t*sl[1]+1)/2)}var $e=-1,al=16,fr=32,Jd=48,Vu=64,jd=128,Fi=(i,e)=>new Le(i,e),ut=class{p=[];c=[];f=[];uv;tile;surface=null;surfaceTransform=null;constructor(e=!1,t=!1){this.uv=e?[]:null,this.tile=t?[]:null}tri(e,t,n,r,s=r,o=r,a,l=$e,c=[0,1]){this.p.push(...e,...t,...n);for(let u of[r,s,o])this.c.push(u.r,u.g,u.b);this.f.push(l,l,l),this.uv?.push(...a??[.5,.5,.5,.5,.5,.5]),this.tile?.push(...c,...c,...c),this.surface?.push(0,0,0),this.surfaceTransform?.push(1,0,1,0,1,0)}get count(){return this.p.length/9}geometry(){let e=new Pe;return e.setAttribute("position",Fi(this.p,3)),e.setAttribute("color",Fi(this.c,3)),e.setAttribute("fold",Fi(this.f,1)),this.uv&&e.setAttribute("uv",Fi(this.uv,2)),this.tile&&e.setAttribute("tile",Fi(this.tile,2)),this.surface&&e.setAttribute("surface",Fi(this.surface,1)),this.surfaceTransform&&e.setAttribute("surfaceTransform",Fi(this.surfaceTransform,2)),e.computeBoundingSphere(),e}},Wt=class{p=[];c=[];f=[];seg(e,t,n=Li,r=$e){this.p.push(...e,...t),this.c.push(n.r,n.g,n.b,n.r,n.g,n.b),this.f.push(r,r)}segSplit(e,t,n,r,s){let[o,a]=e[1]<=t[1]?[e,t]:[t,e];if(a[1]<=r+1e-6||s<0)return this.seg(o,a,n,$e);if(o[1]>=r-1e-6)return this.seg(o,a,n,s);let l=(r-o[1])/(a[1]-o[1]),c=[o[0]+(a[0]-o[0])*l,r,o[2]+(a[2]-o[2])*l];this.seg(o,c,n,$e),this.seg(c,a,n,s)}geometry(){let e=new Pe;return e.setAttribute("position",Fi(this.p,3)),e.setAttribute("color",Fi(this.c,3)),e.setAttribute("fold",Fi(this.f,1)),e}};var Qd=(i,e,t)=>i.map((n,r)=>n+(e[r]-n)*t);function Ey(i,e,t){let n=(t-i.p[1])/(e.p[1]-i.p[1]);return{p:Qd(i.p,e.p,n),c:Qd(i.c,e.c,n),uv:i.uv&&e.uv?Qd(i.uv,e.uv,n):null,tile:i.tile,surface:i.surface,surfaceTransform:i.surfaceTransform}}function QE(i,e){return{p:i.p.slice(e*3,e*3+3),c:i.c.slice(e*3,e*3+3),uv:i.uv?i.uv.slice(e*2,e*2+2):null,tile:i.tile?i.tile.slice(e*2,e*2+2):null,surface:i.surface?.[e]??0,surfaceTransform:i.surfaceTransform?.slice(e*2,e*2+2)??null}}function eR(i,e,t,n){t.forEach((r,s)=>{let o=e*3+s;r.p.forEach((a,l)=>i.p[o*3+l]=a),r.c.forEach((a,l)=>i.c[o*3+l]=a),i.uv&&r.uv&&r.uv.forEach((a,l)=>i.uv[o*2+l]=a),i.tile&&r.tile&&r.tile.forEach((a,l)=>i.tile[o*2+l]=a),i.f[o]=n,i.surface&&(i.surface[o]=r.surface),i.surfaceTransform&&r.surfaceTransform&&r.surfaceTransform.forEach((a,l)=>i.surfaceTransform[o*2+l]=a)})}function Ry(i,e,t){for(let n of e)i.p.push(...n.p),i.c.push(...n.c),i.f.push(t),i.uv?.push(...n.uv??[.5,.5]),i.tile?.push(...n.tile??[0,1]),i.surface?.push(n.surface),i.surfaceTransform?.push(...n.surfaceTransform??[1,0])}function ep(i,e,t,n){let r=i.count;for(let s=e;sQE(i,s*3+_)),a=o.map(_=>_.p[1]>t+1e-6),l=o.map(_=>_.p[1]=t-1e-6){i.f[s*2]=n,i.f[s*2+1]=n;continue}let u=(t-l[1])/(c[1]-l[1]),h=[l[0]+(c[0]-l[0])*u,t,l[2]+(c[2]-l[2])*u],f=i.c.slice(s*6,s*6+3);i.p.splice(s*6,6,...l,...h),i.p.push(...h,...c),i.c.push(...f,...f),i.f.push(n,n)}}var tR=i=>i.reduce((e,t,n)=>e+t[0]*i[(n+1)%i.length][1]-i[(n+1)%i.length][0]*t[1],0),Cy=([i,e])=>new ke(i,e);function Gr(i,e=[]){return Na.triangulateShape(i.map(Cy),e.map(t=>t.map(Cy)))}var Po=(i,e)=>[i[0]-e[0],i[1]-e[1],i[2]-e[2]],Py=(i,e)=>[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]],Iy=(i,e)=>i[0]*e[0]+i[1]*e[1]+i[2]*e[2],Ly=i=>{let e=Math.hypot(i[0],i[1],i[2])||1;return[i[0]/e,i[1]/e,i[2]/e]};function np(i,e,t,n,r,s,o){let a=new W(o);for(let f=0;f<4;f++){let[d,p]=[e[f],e[(f+1)%4]],[x,m]=[t[f],t[(f+1)%4]],[g,y]=[p[0]-d[0],p[1]-d[1]],_=Math.hypot(g,y);if(_<1e-6)continue;let b=(x[0]+m[0]-d[0]-p[0])/2*(-y/_)+(x[1]+m[1]-d[1]-p[1])/2*(g/_),M=Math.max(0,Math.min(1,b/Math.max(1e-6,Math.hypot(b,r-n)))),S=Zd(g,y),v=Be(s,ol(n)*S).lerp(a,M),w=Be(s,ol(r)*S).lerp(a,M);i.tri([d[0],n,d[1]],[x[0],r,x[1]],[m[0],r,m[1]],v,w,w),i.tri([d[0],n,d[1]],[m[0],r,m[1]],[p[0],n,p[1]],v,w,v)}let[l,c,u,h]=t;Math.hypot(u[0]-l[0],u[1]-l[1])>1e-4&&(i.tri([l[0],r,l[1]],[u[0],r,u[1]],[c[0],r,c[1]],a),i.tri([l[0],r,l[1]],[h[0],r,h[1]],[u[0],r,u[1]],a))}function ip(i,e,t,n){let r=e.length;if(r<2)return;let s=e[0].length,o=new W(n),a=e.map(h=>[0,1,2].map(f=>h.reduce((d,p)=>d+p[f],0)/s)),l=e.map((h,f)=>h.map((d,p)=>{let x=Po(e[Math.min(r-1,f+1)][p],e[Math.max(0,f-1)][p]),m=Po(h[(p+1)%s],h[(p+s-1)%s]),g=Ly(Py(x,m));return Iy(g,Po(d,a[f]))<0?g.map(y=>-y):g})),c=(h,f)=>{let d=(f[0]*sl[0]+f[2]*sl[1]+1)/2;return Be(t,ol(h[1])*(.8+.28*d)).lerp(o,Math.max(0,f[1])*.9)},u=(h,f,d,p,x,m,g)=>{Iy(Py(Po(f,h),Po(d,h)),p)>=0?i.tri(h,f,d,x,m,g):i.tri(h,d,f,x,g,m)};for(let h=0;h+1c(M,x[S])),b=[0,1,2].map(M=>x.reduce((S,v)=>S+v[M],0));u(p[0],p[1],p[2],b,m,g,y),u(p[0],p[2],p[3],b,m,y,_)}for(let[h,f]of[[0,-1],[r-1,1]]){let d=e[h],p=Po(e[h===0?1:r-2][0],d[0]),x=Ly(p.map(g=>g*-f)),m=c(a[h],x);for(let g=0;g{let x=p/c*Math.PI*2;return{y:s+Math.cos(x)*o,across:r+Math.sin(x)*o}}),f=(d,p)=>{let{y:x,across:m}=h[p%c],[g,y]=e(d,m);return[g,x,y]};for(let d=0;dn:x=>Math.max(t+.002,n(x[0],x[1])),l=o.aoFrom??t,c=o.fold??$e,u=x=>ol(x-l),h=(o.holes??[]).map(x=>tR(x)>0?[...x].reverse():x),f=h.length?[...e,...h.flat()]:e,d=o.topFace!==!1,p=!d&&!o.bottom?[]:Gr(e,h);if(d){let x=new W(s);for(let[m,g,y]of p){let[_,b,M]=[f[m],f[g],f[y]];i.tri([_[0],a(_),_[1]],[M[0],a(M),M[1]],[b[0],a(b),b[1]],x,x,x,void 0,o.topFold??c)}}if(o.bottom){let x=Be(r,.55);for(let[m,g,y]of p){let[_,b,M]=[f[m],f[g],f[y]];i.tri([_[0],t,_[1]],[b[0],t,b[1]],[M[0],t,M[1]],x,x,x,void 0,c)}}for(let x of[e,...h])x.forEach((m,g)=>{let y=x[(g+1)%x.length];if(Math.hypot(y[0]-m[0],y[1]-m[1])<1e-6||o.skipSide?.(m,y))return;let _=Zd(y[0]-m[0],y[1]-m[1]),[b,M]=[a(m),a(y)],S=o.sideColor?o.sideColor(m,y):r,v=Be(S,u(t)*_),w=Be(S,u(b)*_),P=Be(S,u(M)*_);i.tri([m[0],t,m[1]],[m[0],b,m[1]],[y[0],M,y[1]],v,w,P,void 0,c),i.tri([m[0],t,m[1]],[y[0],M,y[1]],[y[0],t,y[1]],v,P,v,void 0,c)})}var Ms=i=>{let e=Math.hypot(i[0],i[1])||1;return[i[0]/e,i[1]/e]};function Hr(i){return i.reduce((t,n,r)=>t+n[0]*i[(r+1)%i.length][1]-i[(r+1)%i.length][0]*n[1],0)>=0?i:[...i].reverse()}function Fy(i,e){let t=[];return i.forEach((n,r)=>{let s=i[(r+1)%i.length],[o,a]=[e(n),e(s)];if(o>=0&&t.push(n),o>=0!=a>=0){let l=o/(o-a);t.push([n[0]+(s[0]-n[0])*l,n[1]+(s[1]-n[1])*l])}}),t}function op(i,e,t,n,r){let s=a=>(a[0]-e[0])*t[0]+(a[1]-e[1])*t[1],o=i;return Number.isFinite(n)&&(o=Fy(o,a=>s(a)-n)),Number.isFinite(r)&&(o=Fy(o,a=>r-s(a))),o}var Ny=i=>Math.round(i*1e3),ll=i=>`${Ny(i[0])},${Ny(i[1])}`,sp=(i,e)=>{let[t,n]=[ll(i),ll(e)];return t{let s=i[(r+1)%i.length],[o,a]=[s[0]-n[0],s[1]-n[1]],l=o*o+a*a;if(l<1e-8)return;let c=e.map(h=>({t:((h[0]-n[0])*o+(h[1]-n[1])*a)/l,off:Math.abs((h[0]-n[0])*a-(h[1]-n[1])*o)/Math.sqrt(l)})).filter(({t:h,off:f})=>h>1e-6&&h<1-1e-6&&f<1e-4).map(({t:h})=>h).sort((h,f)=>h-f),u=n;for(let h of c){let f=[n[0]+o*h,n[1]+a*h];ll(f)!==ll(u)&&t.push([u,f]),u=f}t.push([u,s])}),t}function ap(i,e){let t=i.map(l=>({wall:l,edges:nR(l.footprint,e)})),n=new Map;for(let{edges:l}of t)for(let[c,u]of l)n.set(sp(c,u),(n.get(sp(c,u))??0)+1);let r=[],s=new Map,o=(l,c,u)=>{let h=ll(l);s.has(h)||s.set(h,{p:l,wall:c,d:[]}),s.get(h).d.push(u)};for(let{wall:l,edges:c}of t)for(let[u,h]of c){let f=Math.hypot(h[0]-u[0],h[1]-u[1]);if(n.get(sp(u,h))!==1||f<1e-4)continue;r.push({a:u,b:h,wall:l});let d=[(h[0]-u[0])/f,(h[1]-u[1])/f];o(u,l,d),o(h,l,d)}let a=[...s.values()].filter(({d:l})=>l.some(c=>l.some(u=>Math.abs(c[0]*u[1]-c[1]*u[0])>.05))).map(({p:l,wall:c})=>({p:l,wall:c}));return{edges:r,corners:a}}function Io(i,e){if(e.length===0)return[[i.a,i.b]];let t=Ms([i.wall.b[0]-i.wall.a[0],i.wall.b[1]-i.wall.a[1]]),n=Ms([i.b[0]-i.a[0],i.b[1]-i.a[1]]);if(Math.abs(t[0]*n[0]+t[1]*n[1])<.99)return[[i.a,i.b]];let r=c=>(c[0]-i.wall.a[0])*t[0]+(c[1]-i.wall.a[1])*t[1],[s,o]=[r(i.a),r(i.b)],a=[[Math.min(s,o),Math.max(s,o)]];for(let c of e)a=a.flatMap(([u,h])=>{if(c.s1<=u||c.s0>=h)return[[u,h]];let f=[];return c.s0>u&&f.push([u,c.s0]),c.s1{let u=(c-s)/(o-s||1);return[i.a[0]+(i.b[0]-i.a[0])*u,i.a[1]+(i.b[1]-i.a[1])*u]};return a.filter(([c,u])=>u-c>1e-4).map(([c,u])=>s<=o?[l(c),l(u)]:[l(u),l(c)])}var Oy=["body","wood","fabric","white","metal","dark"];var Fe={body:1516088,bodyTop:1911623,fabric:1713732,fabricTop:2241114,cushion:2373217,wood:1647420,woodTop:2108747,white:1911110,whiteTop:2504542,metal:2767456,dark:725279,glass:1849938,plant:1191982,plantTop:1721664,pot:1910336,accent:2854835},He=(i,e=i)=>({side:i,top:e}),q={body:He(Fe.body,Fe.bodyTop),fabric:He(Fe.fabric,Fe.fabricTop),cushion:He(Fe.cushion),cushionSoft:He(Fe.cushion,Fe.fabricTop),wood:He(Fe.wood,Fe.woodTop),white:He(Fe.white,Fe.whiteTop),worktop:He(Fe.whiteTop),metal:He(Fe.metal),dark:He(Fe.dark),darkBody:He(Fe.dark,Fe.body),glass:He(Fe.glass),accent:He(Fe.accent),pot:He(Fe.pot),plant:He(Fe.plant,Fe.plantTop),bedding:He(Fe.white,Fe.whiteTop),pillow:He(Fe.whiteTop)};var ue=Be(5995775,.3),Te=Be(5995775,.17),Ze=Be(3662079,.45);var lp={...Fe},Dy=Object.fromEntries(Object.entries(q).map(([i,e])=>[i,{...e}])),ky="",iR=i=>typeof i=="string"&&/^#[0-9a-f]{6}$/i.test(i)?Number.parseInt(i.slice(1),16):null;function Uy(i){let e=Object.fromEntries(Oy.map(s=>[s,iR(i?.[s])]).filter(([,s])=>s!==null)),t=JSON.stringify(e);if(t===ky)return!1;ky=t,Object.assign(Fe,lp);for(let[s,o]of Object.entries(Dy))Object.assign(q[s],o);let n=s=>Be(s,1.25).getHex(),r=(s,o,a,l)=>{let c=e[s];if(c===void 0)return;for(let h of o)Fe[h]=c;for(let h of a)Fe[h]=n(c);let u=new Map([...o.map(h=>[lp[h],c]),...a.map(h=>[lp[h],n(c)])]);for(let h of l){let f=Dy[h];q[h].side=u.get(f.side)??q[h].side,q[h].top=u.get(f.top)??q[h].top}};return r("body",["body"],["bodyTop"],["body","darkBody"]),r("wood",["wood"],["woodTop"],["wood"]),r("fabric",["fabric","cushion"],["fabricTop"],["fabric","cushion","cushionSoft"]),r("white",["white"],["whiteTop"],["white","worktop","bedding","pillow"]),r("metal",["metal"],[],["metal"]),r("dark",["dark"],[],["dark","darkBody"]),!0}function By(i){let e=i(0,0),t=i(1,0),n=i(0,1);return(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0])<0}function Ss(i,e){let t=(n,r,s)=>{if(n)for(let o=0;othis.plan(e+(o-e)*r-(a-t)*s,t+(o-e)*s+(a-t)*r))}seg(e,t,n,r,s,o,a=ue){this.edge(this.plan(e,n),this.plan(r,o),t,s,a)}edge(e,t,n,r,s){this.lines.seg([e[0],n,e[1]],[t[0],r,t[1]],s,$e)}block({x:[e,t],y:[n,r],z:[s,o]},a,l=null){if(t-e<1e-4||o-s<1e-4||r-n<1e-4)return;let c=[this.plan(e,s),this.plan(e,o),this.plan(t,o),this.plan(t,s)];Tt(this.buf,Hr(c),n,r,a.side,a.top,{aoFrom:0,bottom:n>.05}),l&&c.forEach((u,h)=>{this.edge(u,c[(h+1)%4],r,r,l),this.edge(u,u,n,r,l)})}prism(e,t,n,r,s=null){if(e.length<3||n-t<1e-4)return;let o=e.map(([a,l])=>this.plan(a,l));Tt(this.buf,Hr(o),t,n,r.side,r.top,{aoFrom:Math.min(0,t),bottom:!0}),s&&o.forEach((a,l)=>this.edge(a,o[(l+1)%o.length],n,n,s))}loft(e,t,n,r,s,o=null){if(r-n<1e-4)return;let a=u=>[this.plan(u[0],u[2]),this.plan(u[0],u[3]),this.plan(u[1],u[3]),this.plan(u[1],u[2])],l=a(e),c=a(t);if(l!==Hr(l)&&(l.reverse(),c.reverse()),np(this.buf,l,c,n,r,s.side,s.top),o)for(let u=0;u<4;u++)this.edge(c[u],c[(u+1)%4],r,r,o),this.edge(l[u],c[u],n,r,o)}sweep(e,t,n=16,r=2.6,s=null){if(e.length<2)return;let o=e.map(a=>{let[l,c]=[Math.max(.004,(a.y1-a.y0)/2),Math.max(.004,a.hw)],u=(a.y0+a.y1)/2;return Array.from({length:n},(h,f)=>{let d=f/n*Math.PI*2,[p,x]=[Math.cos(d),Math.sin(d)],[m,g]=this.plan(a.x+c*Math.sign(p)*Math.abs(p)**(2/r),a.z);return[m,u+l*Math.sign(x)*Math.abs(x)**(2/r),g]})});if(ip(this.buf,o,t.side,t.top),s){let a=Math.round(n/4);for(let l=0;l+1.005&&this.block({x:[s,o],y:[a+h,l-h],z:[c,u]},f,r),this.loft([s,o,c,u],[s+h,o-h,c+h,u-h],l-h,l,t)}lyingCylinder(e,t,n,r,s,o,a,l,c=12,u=null){let h=Math.min(a,s-r)/2;if(h<1e-4||o<1e-4)return;let f=(r+s)/2,[d,p]=e==="x"?[t,n]:[n,t],x=(g,y)=>e==="x"?this.plan(g,y):this.plan(y,g),m=this.buf.p.length;if(rp(this.buf,x,d-o/2,d+o/2,p,f,h,l.side,l.top,c),this.mirrored!==(e==="z")&&Ss(this.buf,m),!!u)for(let g of[d-o/2,d+o/2])for(let y=0;ythis.plan(e+Math.cos(h/a*Math.PI*2)*n,t+Math.sin(h/a*Math.PI*2)*n));Tt(this.buf,Hr(c),r,s,o.side,o.top,{aoFrom:0,bottom:r>.05}),l&&c.forEach((u,h)=>this.edge(u,c[(h+1)%a],s,s,l))}ring(e,t,n,r,s=20,o=ue){for(let a=0;a[e(-t/2-p,-n/2-p),e(t/2+p,-n/2-p),e(t/2+p,n/2+p),e(-t/2-p,n/2+p)],[u,h]=[c(0),c(s)],f=p=>[p[0],l,p[1]],d=i.p.length;i.tri(f(u[0]),f(u[1]),f(u[2]),o),i.tri(f(u[0]),f(u[2]),f(u[3]),o);for(let p=0;p<4;p++){let x=(p+1)%4;i.tri(f(u[p]),f(h[p]),f(h[x]),o,a,a),i.tri(f(u[p]),f(h[x]),f(u[x]),o,a,o)}By(e)&&Ss(i,d)}function cp(i,e){if(!i)return null;if(i.startsWith("#"))return Number.parseInt(i.slice(1),16);let t=Fe;return(e?t[`${i}Top`]:void 0)??t[i]??null}function ws(i,e,t,n,r,s,o,a=null,l=null,c=null){let u=e.colors?.length?(e.colors.find(f=>f.id===l)??e.colors[0]).hex:null,h=na(e,t,n,r);for(let f of c===null?h:G0(h,c)){if(c===null&&f.move||a&&!a(f))continue;let d=a?{...f,glow:!0,w:f.w+.006/t,d:f.d+.006/n,y:Math.max(0,f.y-.002/r),h:f.h+.004/r}:f,p=d.glow&&o!==null,x=!!(d.paint&&u),m=x?u:d.color,g=p?o:cp(m,!1)??Fe.body,y=p?o:cp(x?void 0:d.top,!1)??cp(m,!0)??Be(g,1.25).getHex(),_=He(g,y),[b,M]=[s+d.y*r,s+Math.min(r,(d.y+d.h)*r)],S=d.edges==="glow"?Li:d.edges==="faint"?Te:d.edges?ue:null,v=d.rot?i.turned(d.x*t,d.z*n,d.rot):i,[w,P]=[d.x*t,d.z*n];if(d.shape==="cyl"&&(d.axis==="x"||d.axis==="z"))v.lyingCylinder(d.axis,w,P,b,M,d.axis==="x"?d.w*t:d.d*n,d.axis==="x"?d.d*n:d.w*t,_,14,S);else if(d.shape==="cyl")v.cylinder(w,P,Math.min(d.w*t,d.d*n)/2,b,M,_,14,S);else if(d.shape==="loft"){let[T,R,L,U]=[d.tx??d.x,d.tz??d.z,d.tw??d.w,d.td??d.d];v.loft([(d.x-d.w/2)*t,(d.x+d.w/2)*t,(d.z-d.d/2)*n,(d.z+d.d/2)*n],[(T-L/2)*t,(T+L/2)*t,(R-U/2)*n,(R+U/2)*n],b,M,_,S)}else if(d.shape==="sweep"){let T=(d.stations??[]).map(([R,L,U,C])=>({x:w,z:R*n,y0:s+L*r,y1:s+U*r,hw:C*t/2}));v.sweep(T,_,d.n??16,d.exp??2.6,S)}else v.block({x:[(d.x-d.w/2)*t,(d.x+d.w/2)*t],y:[b,M],z:[(d.z-d.d/2)*n,(d.z+d.d/2)*n]},_,S)}}function Ts(i){let[e,t]=[Math.cos(i.rotation*mt),Math.sin(i.rotation*mt)],n=i.mirror?-1:1;return(r,s)=>[i.x+n*r*e-s*t,i.z+n*r*t+s*e]}var up=i=>[Math.max(.05,i.w),Math.max(.05,i.d),Math.max(.005,i.h)];function cl(i,e,t,n,r,s=o=>!!o.glow){ws(new Ni(i,new Wt,Ts(t)),e,...up(t),n,r,s)}function hp(i,e,t,n,r){let s=i.p.length;ws(new Ni(i,new Wt,Ts(t)),e,...up(t),n,null,null,t.variant??null,r),t.mirror&&Ss(i,s)}function ul(i,e,t,n,r){ws(new Ni(i,new Wt,Ts(t)),e,...up(t),n,r)}function Vy(i){let e=2166136261;for(let t=0;t(e=Math.imul(e^e>>>15,2246822507),e=Math.imul(e^e>>>13,3266489909),e^=e>>>16,(e>>>0)/4294967296)}var rR=(i,e,t)=>{let[n,r]=[t[0]-e[0],t[1]-e[1]],s=n*n+r*r||1e-9,o=Math.max(0,Math.min(1,((i[0]-e[0])*n+(i[1]-e[1])*r)/s));return Math.hypot(i[0]-e[0]-n*o,i[1]-e[1]-r*o)};function sR(i,e,t=.25){if(!Ge(e,i.points))return!1;let n=i.points;for(let r=0;rGe(e,r))}function oR(i,e,t){let n=i.obstacles.filter(s=>!Ge(e,s)),r=Math.max(1,Math.ceil(Math.hypot(t[0]-e[0],t[1]-e[1])/.1));for(let s=1;s<=r;s++){let o=[e[0]+(t[0]-e[0])*s/r,e[1]+(t[1]-e[1])*s/r];if(n.some(a=>Ge(o,a)))return!1}return!0}function aR(i,e,t){let n=i.points.map(c=>c[0]),r=i.points.map(c=>c[1]),[s,o,a,l]=[Math.min(...n),Math.max(...n),Math.min(...r),Math.max(...r)];for(let c=0;c<24;c++){let u=[s+(o-s)*t(),a+(l-a)*t()];if(Math.hypot(u[0]-e[0],u[1]-e[1])>.6&&sR(i,u)&&oR(i,e,u))return u}return null}function lR(i,e,t,n){if(!i.target){if(i.rest-=t,i.rest>0)return!1;if(i.target=aR(e,i.pos,n),!i.target)return i.rest=2,!1}let[r,s]=[i.target[0]-i.pos[0],i.target[1]-i.pos[1]],o=Math.hypot(r,s),l=Math.atan2(r,s)-i.heading;for(;l>Math.PI;)l-=2*Math.PI;for(;l<-Math.PI;)l+=2*Math.PI;i.heading+=Math.max(-4*t,Math.min(4*t,l));let c=e.speed*t*(Math.abs(l)>1.2?.3:1);return o<=c?(i.pos=[i.target[0],i.target[1]],i.target=null,i.rest=2+n()*6,!0):(i.pos=[i.pos[0]+r/o*c,i.pos[1]+s/o*c],!0)}function Gy(i,e,t,n){let r=Math.min(.2,Math.max(0,t));return i.target||(i.rest-=Math.max(0,t)-r),lR(i,e,r,n)}function Hy(){let e=navigator.deviceMemory??8,t=navigator.hardwareConcurrency||8;return e<=3||t<=4||/Silk|KF[A-Z]{2,4}\b/.test(navigator.userAgent)}var Gu=class{times=[];settle=30;ratio;lastDown=-1/0;slowAtFloor=0;max;min;constructor(e,t=1){this.max=e,this.min=t,this.ratio=e}get pixelRatio(){return this.ratio}frame(e,t){if(this.settle>0)return this.settle--,null;if(e<=0||e>=100||(this.times.push(e),this.times.length<45))return null;let n=[...this.times].sort((s,o)=>s-o);this.times=[];let r=1e3/n[Math.floor(n.length/2)];return r<26&&this.ratio>this.min+1e-6?(this.ratio=Math.max(this.min,Math.round((this.ratio-.25)*100)/100),this.lastDown=t,this.settle=30,{ratio:this.ratio}):r<16&&this.ratio<=this.min+1e-6?++this.slowAtFloor>=2?{low:!0}:null:(this.slowAtFloor=0,r>55&&this.ratio3e4?(this.ratio=Math.min(this.max,Math.round((this.ratio+.25)*100)/100),this.settle=30,{ratio:this.ratio}):null)}};function Wy(i){let e=i.length/3,t=new Float32Array(e);for(let n=0;n0&&(t[n]=r)}return t}function Xy(i,e,t,n){for(let r=t.start*3;rMath.tan(Math.min(80,Math.max(0,i))*Hu);function As(i){return{x0:Math.min(i.x0,i.x1),x1:Math.max(i.x0,i.x1),z0:Math.min(i.z0,i.z1),z1:Math.max(i.z0,i.z1)}}function Yy(i){if(!i.rotation)return null;let e=i.rotation*Hu;return{cx:(i.x0+i.x1)/2,cz:(i.z0+i.z1)/2,c:Math.cos(e),sn:Math.sin(e)}}function qy(i,e){let t=Yy(i);if(!t)return e;let[n,r]=[e[0]-t.cx,e[1]-t.cz];return[t.cx+n*t.c-r*t.sn,t.cz+n*t.sn+r*t.c]}function fp(i,e,t){let n=Yy(i);if(!n)return[e,t];let[r,s]=[e-n.cx,t-n.cz];return[n.cx+r*n.c+s*n.sn,n.cz-r*n.sn+s*n.c]}function $y(i,e=0){let{x0:t,x1:n,z0:r,z1:s}=As(i);return[[t-e,r-e],[n+e,r-e],[n+e,s+e],[t-e,s+e]].map(o=>qy(i,o))}function kn(i){let{x0:e,x1:t,z0:n,z1:r}=As(i),s=o=>qy(i,o);return i.axis==="x"?{u0:e,u1:t,w:r-n,at:(o,a)=>s([o,i.flip?r-a:n+a])}:{u0:n,u1:r,w:t-e,at:(o,a)=>s([i.flip?t-a:e+a,o])}}function Oi(i,e,t){let{x0:n,x1:r,z0:s,z1:o}=As(i),[a,l]=fp(i,e,t);return i.axis==="x"?[a,i.flip?o-l:l-s]:[l,i.flip?r-a:a-n]}var hl=Math.tan(30*Hu);function fl(i,e,t,n,r){let s=Math.min(i*.3,n>1e-6?2.4/n:i*.3),o=Math.min(i*.3,r>1e-6?2.4/r:i*.3),a=e+s*n,l=t+o*r,c=Math.min(i-o,Math.max(s,(l-a+hl*(i-o+s))/(2*hl))),u=a+(c-s)*hl;return{vla:s,vlb:o,yla:a,ylb:l,vr:c,rh:u,y:f=>f<=s?e+f*n:f<=c?a+(f-s)*hl:f<=i-o?l+(i-o-f)*hl:t+(i-f)*r}}function Rn(i){let e=kn(i).w,[t,n]=[i.eave_a,i.eave_b],[r,s]=[dr(i.pitch_a),dr(i.pitch_b)];switch(i.shape){case"flat":case"parapet":return{vr:e/2,rh:t,y:()=>t};case"pent":return{vr:e,rh:t+e*r,y:o=>t+o*r};case"mansard":{let o=fl(e,t,n,r,s);return{vr:o.vr,rh:o.rh,y:o.y}}default:{let o=r+s>1e-6?Math.min(e,Math.max(0,(n-t+e*s)/(r+s))):e/2;return{vr:o,rh:t+o*r,y:a=>a<=o?t+a*r:n+(e-a)*s}}}}var dp=i=>Rn(i).rh;var xt=(i,e)=>[i[0]-e[0],i[1]-e[1]],Di=(i,e)=>[i[0]+e[0],i[1]+e[1]],hi=(i,e)=>[i[0]*e,i[1]*e],vn=(i,e)=>i[0]*e[0]+i[1]*e[1],Cn=(i,e)=>i[0]*e[1]-i[1]*e[0],Jn=i=>Math.hypot(i[0],i[1]),fi=i=>{let e=Jn(i)||1;return[i[0]/e,i[1]/e]},pp=i=>[-i[1],i[0]],mp=i=>[i[1],-i[0]];function Ky(i){let e=i.heightEnd!==void 0;return{...i,a:i.b,b:i.a,left:i.right,right:i.left,roomLeft:i.roomRight,roomRight:i.roomLeft,height:e?i.heightEnd:i.height,heightEnd:e?i.height:void 0}}function cR(i,e){let t=i.map(n=>({...n}));for(let n of e){let r=t.find(s=>s.room_id===n.room_id&&s.edge===n.edge&&(Math.abs(s.t1-n.t0)<1e-6||Math.abs(n.t1-s.t0)<1e-6));r?(r.t0=Math.min(r.t0,n.t0),r.t1=Math.max(r.t1,n.t1)):t.push({...n})}return t}function uR(i,e,t){if(i.a===e.b)return!1;let n=fi(xt(t[i.b],t[i.a])),r=fi(xt(t[e.b],t[e.a]));return Math.abs(Cn(n,r))>1e-6||vn(n,r)<=0||i.free||e.free||i.heightEnd!==void 0||e.heightEnd!==void 0?!1:i.height===e.height&&i.exterior===e.exterior&&i.roomLeft===e.roomLeft&&i.roomRight===e.roomRight&&Math.abs(i.left-e.left)<=1e-9&&Math.abs(i.right-e.right)<=1e-9}function Zy(i,e,t=new Set){let n=i.slice();for(;;){let r=new Map;n.forEach((o,a)=>{for(let l of[o.a,o.b])r.set(l,[...r.get(l)??[],a])});let s=null;for(let[o,a]of r){if(a.length!==2||t.has(o))continue;let l=n[a[0]].b===o?n[a[0]]:Ky(n[a[0]]),c=n[a[1]].a===o?n[a[1]]:Ky(n[a[1]]);if(!uR(l,c,e))continue;let u={...l,b:c.b,sources:cR(l.sources,c.sources)};s=[...n.filter((h,f)=>f!==a[0]&&f!==a[1]),u];break}if(!s)return n;n=s}}function Jy(i,e){let t=new Map;i.forEach((r,s)=>{let o=fi(xt(e[r.b],e[r.a])),a=[[r.a,{key:`${s}:a`,d:o,left:r.left,right:r.right,angle:Math.atan2(o[1],o[0])}],[r.b,{key:`${s}:b`,d:hi(o,-1),left:r.right,right:r.left,angle:Math.atan2(-o[1],-o[0])}]];for(let[l,c]of a)t.set(l,[...t.get(l)??[],c])});let n=new Map;for(let[r,s]of t){let o=e[r];s.sort((l,c)=>l.angle-c.angle);for(let l of s)n.set(l.key,{left:Di(o,hi(pp(l.d),l.left)),right:Di(o,hi(mp(l.d),l.right))});if(s.length<2)continue;let a=4*Math.max(...s.map(l=>Math.max(l.left,l.right)))+1e-9;s.forEach((l,c)=>{let u=s[(c+1)%s.length],h=Di(o,hi(pp(l.d),l.left)),f=Di(o,hi(mp(u.d),u.right)),d=Cn(l.d,u.d);if(Math.abs(d)<1e-4)return;let p=Di(h,hi(l.d,Cn(xt(f,h),u.d)/d));Jn(xt(p,o))>a||(n.get(l.key).left=p,n.get(u.key).right=p)})}return n}function jy(i,e){let t=i.filter((n,r)=>Jn(xt(n,i[(r+1)%i.length]))>e);for(;;){if(t.length<=3)return t;let n=t.findIndex((r,s)=>{let o=t[(s+t.length-1)%t.length],a=t[(s+1)%t.length],[l,c]=[xt(r,o),xt(a,r)];return Math.abs(Cn(fi(l),fi(c)))<1e-7&&vn(l,c)>0});if(n===-1)return t;t=t.filter((r,s)=>s!==n)}}function hR(i){let e=[];return{points:e,idOf(t){let n=e.findIndex(r=>Math.abs(r[0]-t[0])<=i&&Math.abs(r[1]-t[1])<=i);return n>=0?n:(e.push([t[0],t[1]]),e.length-1)}}}function fR(i,e){let t=[];for(let n of i){let r=n.points;if(r.length<3||Math.abs(ts(r))<1e-6)continue;let s=ts(r)>0,o=r.map(a=>e.idOf(a));o.forEach((a,l)=>{let c=o[(l+1)%o.length];a!==c&&t.push(s?{u:a,v:c,room:n.id,edge:l,forward:!0}:{u:c,v:a,room:n.id,edge:l,forward:!1})})}return t}function dR(i,e,t){let n=[];for(let r of i){let[s,o]=[e[r.u],e[r.v]],a=xt(o,s),l=Jn(a),c=hi(a,1/l),u=e.map((f,d)=>({id:d,rel:xt(f,s)})).filter(({id:f,rel:d})=>f!==r.u&&f!==r.v&&vn(d,c)>t&&vn(d,c)({t:vn(d,c),id:f})).sort((f,d)=>f.t-d.t),h=[{t:0,id:r.u},...u,{t:l,id:r.v}];for(let f=0;f+1({room_id:i.room,edge:i.edge,t0:i.t0,t1:i.t1});function pR(i,e){let t=new Map(i.map(a=>[a.id,a])),n=new Map;for(let a of e){let l=`${a.room}:${a.edge}`;n.set(l,[...n.get(l)??[],a.t0].sort((c,u)=>c-u))}let r=a=>{let l=t.get(a.room)?.wall_heights?.[a.edge];return Array.isArray(l)?l[(n.get(`${a.room}:${a.edge}`)??[]).indexOf(a.t0)]??null:l},s=a=>{let l=t.get(a.room),[c,u]=[l?.wall_heights?.[a.edge],l?.wall_slopes?.[a.edge]];if(!l||typeof c!="number"||typeof u!="number"||c<=0||u<=0)return null;let[h,f]=[l.points[a.edge],l.points[(a.edge+1)%l.points.length]];return{from:c,to:u,length:Math.hypot(f[0]-h[0],f[1]-h[1])}},o=a=>{let l=s(a);if(!l||l.length<1e-9){let u=r(a);return typeof u=="number"&&u>0?[u,u]:[null,null]}let c=u=>l.from+(l.to-l.from)*u/l.length;return a.forward?[c(a.t0),c(a.t1)]:[c(a.t1),c(a.t0)]};return{heightsOf(a){let[l,c]=[1/0,1/0];for(let h of a){let[f,d]=o(h),[p,x]=h===a[0]?[f,d]:[d,f];p!==null&&(l=Math.min(l,p)),x!==null&&(c=Math.min(c,x))}let u=a.map(h=>t.get(h.room)?.ceiling);if(u.every(h=>typeof h=="number"&&h>0)){let h=Math.max(...u);l===1/0&&(l=h),c===1/0&&(c=h)}return{...l<1/0?{a:l}:{},...c<1/0?{b:c}:{}}},thicknessOf(a){let l=a.map(c=>{let u=t.get(c.room)?.wall_thickness?.[c.edge];return Array.isArray(u)?u[(n.get(`${c.room}:${c.edge}`)??[]).indexOf(c.t0)]:u}).filter(c=>typeof c=="number"&&c>0);return l.length?Math.max(...l):void 0},hasNoWall:a=>a.some(l=>r(l)===0)}}function eb(i){let e=t=>Math.round(t*1e6)/1e6;return i.a===void 0||i.b===void 0?i.a!==void 0?{height:e(i.a)}:i.b!==void 0?{height:e(i.b)}:{}:Math.abs(i.a-i.b)<1e-6?{height:e(i.a)}:{height:e(i.a),heightEnd:e(i.b)}}function mR(i,e,t,n){let r=pR(e,i),s=new Map;for(let l of i){let c=l.uf!==c&&f.u===c.v&&f.v===c.u&&f.room!==c.room);for(let f of l)f!==c&&f!==u&&f.room!==c.room&&n.push(`overlap:${c.room}:${f.room}`);let h=u?[c,u]:[c];if(r.hasNoWall(h)){u&&a.push([c.room,u.room]);continue}if(u){let f=r.thicknessOf(h)??t.interior;o.push({a:c.u,b:c.v,left:f/2,right:f/2,exterior:!1,roomLeft:c.room,roomRight:u.room,sources:h.map(Qy),...eb(r.heightsOf(h))})}else o.push({a:c.u,b:c.v,left:0,right:r.thicknessOf(h)??t.exterior,exterior:!0,roomLeft:c.room,roomRight:null,sources:[Qy(c)],...eb(r.heightsOf(h))})}return{drafts:o,open:a}}function gR(i,e){let t=s=>fi(xt(e[s.b],e[s.a])),n=i.filter(s=>!s.exterior&&!s.free),r=new Map;for(let s of n){if(r.has(s))continue;let o=[s];r.set(s,o);for(let a=0;a1e-6||l.add(vn(o,d)>0?"left":"right")}if(l.size!==1)continue;let c=[...l][0];for(let u of s){let h=u.left+u.right,f=vn(t(u),o)>0,d=c==="left"===f;[u.left,u.right]=d?[0,h]:[h,0]}}}var xR=(i,e)=>{let t=s=>Math.round(s*100),[n,r]=i[0]Math.hypot(g.b[0]-g.a[0],g.b[1]-g.a[1])>.05),l=a.map(g=>[s.idOf(g.a),s.idOf(g.b)]),c=new Set;for(let g of i){let y=g.points;y.length<3||(g.wall_splits??[]).forEach((_,b)=>{if(!_||b>=y.length)return;let M=y[b],S=xt(y[(b+1)%y.length],M),v=Jn(S);for(let w of _)w>n&&w{let[_,b]=l[y];if(_===b)return;let M=[(g.a[0]+g.b[0])/2,(g.a[1]+g.b[1])/2],S=i.find(w=>w.points.length>=3&&Ge(M,w.points))?.id??null,v=(g.thickness??e.interior)/2;d.push({free:g.id,a:_,b,left:v,right:v,exterior:!1,roomLeft:S,roomRight:S,sources:[],height:typeof g.height=="number"&&g.height>0?g.height:void 0,...typeof g.height=="number"&&g.height>0&&typeof g.height_end=="number"&&g.height_end>0&&Math.abs(g.height_end-g.height)>1e-6?{heightEnd:g.height_end}:{}})});let p=Zy(d,s.points,c),x=Jy(p,s.points);return{walls:p.map((g,y)=>{let[_,b]=[s.points[g.a],s.points[g.b]],[M,S]=[x.get(`${y}:a`),x.get(`${y}:b`)],v=jy([M.right,S.left,b,S.right,M.left,_],1e-6);return{id:xR(_,b),a:[_[0],_[1]],b:[b[0],b[1]],left:g.left,right:g.right,exterior:g.exterior,roomLeft:g.roomLeft,roomRight:g.roomRight,sources:g.sources,footprint:v,...g.free?{free:g.free}:{},...g.height!==void 0?{height:g.height}:{},...g.heightEnd!==void 0?{heightEnd:g.heightEnd}:{}}}),warnings:[...new Set(r)],open:f}}function tb(i,e,t){let n=i.points[e];return Di(n,hi(fi(xt(i.points[(e+1)%i.points.length],n)),t))}function nb(i,e,t){if(i.wall){let r=t.find(a=>a.id===i.wall);if(!r||Math.hypot(r.b[0]-r.a[0],r.b[1]-r.a[1])<.05)return null;let s=fi(xt(r.b,r.a));return{room:{id:i.room_id,name:"",area_id:null,points:[r.a,r.b,Di(r.a,[-s[1],s[0]])]},edge:0}}let n=e.find(r=>r.id===i.room_id);return n&&i.edgevn(xt(e,i.a),fi(xt(i.b,i.a)));function rb(i,e,t){if(!e.wall)return yR(i,t.room,t.edge,e.offset);let n=i.find(r=>r.free===e.wall);return n?{wall:n,s:ib(n,tb(t.room,0,e.offset))}:null}function yR(i,e,t,n){for(let r of i)if(r.sources.some(o=>o.room_id===e.id&&o.edge===t&&n>=o.t0-1e-6&&n<=o.t1+1e-6))return{wall:r,s:ib(r,tb(e,t,n))};return null}var sb=([i,e])=>{let t=Math.hypot(i,e)||1;return[i/t,e/t]};function bR(i){return i.reduce((e,t,n)=>e+(t[0]*i[(n+1)%i.length][1]-i[(n+1)%i.length][0]*t[1]),0)/2}function Wu(i,e){let t=i.length;if(t<3||Math.abs(e)<1e-9)return i.map(([r,s])=>[r,s]);let n=bR(i)>=0?1:-1;return i.map((r,s)=>{let o=i[(s+t-1)%t],a=i[(s+1)%t],[l,c]=sb([r[0]-o[0],r[1]-o[1]]),[u,h]=sb([a[0]-r[0],a[1]-r[1]]),f=[c*n,-l*n],d=[h*n,-u*n],p=[f[0]+d[0],f[1]+d[1]],x=Math.hypot(p[0],p[1]);if(x<1e-6)return[r[0]+f[0]*e,r[1]+f[1]*e];let m=(p[0]*f[0]+p[1]*f[1])/x,g=Math.min(4,1/Math.max(.25,m));return[r[0]+p[0]/x*e*g,r[1]+p[1]/x*e*g]})}function gp(i,e){if(i.points&&i.points.length>=3)return Wu(i.points,e);if(i.rotation)return $y(i,e);let t=Math.min(i.x0,i.x1)-e,n=Math.max(i.x0,i.x1)+e,r=Math.min(i.z0,i.z1)-e,s=Math.max(i.z0,i.z1)+e;return[[t,r],[n,r],[n,s],[t,s]]}function Wr(i,e){let t=kn(i),n=Rn(i),r=t.w,[s,o]=[Math.max(0,e.a),Math.max(0,e.b)],a=t.u0-Math.max(0,e.u0),l=t.u1+Math.max(0,e.u1),c=(g,y)=>[g,y,n.y(y)],u=c(a,-s),h=c(l,-s),f=c(l,r+o),d=c(a,r+o),[p,x]=[dr(i.pitch_a),dr(i.pitch_b)],m=g=>[g,n.vr,n.rh];if(i.ends&&(i.shape==="gable"||i.shape==="hip"||i.shape==="halfhip")){let g=(t.u1-t.u0)/2,y=Math.min(g,Math.min(n.vr,r-n.vr)||r/2),_=Math.min(n.y(0),n.y(r)),b=_+(n.rh-_)*Math.min(.9,Math.max(.2,i.halfhip??.55)),M=p>1e-6?Math.min(n.vr,(b-i.eave_a)/p):n.vr,S=x>1e-6?Math.max(n.vr,r-(b-i.eave_b)/x):n.vr,v=Math.min(g-.1,(n.rh-b)/Math.max(.2,p)),w=[[0,n.y(0)],[n.vr,n.rh],[r,n.y(r)]],P=[[0,n.y(0)],[M,b],[S,b],[r,n.y(r)]],T=(F,H,k)=>{if(F==="hip")return{upA:[],upB:[],ridge:m(H===a?t.u0+y*k:t.u1-y*k),profile:null};if(F==="halfhip"){let X=m(H===a?t.u0+v:t.u1-v);return{upA:[[H,M,b]],upB:[[H,S,b]],ridge:X,profile:P}}return{upA:[],upB:[],ridge:m(H),profile:w}},R=T(i.ends[0],a,1),L=T(i.ends[1],l,1),U=[[u,h,...L.upA,L.ridge,R.ridge,...[...R.upA].reverse()],[R.ridge,L.ridge,...[...L.upB].reverse(),f,d,...R.upB]],C=[[R.ridge,L.ridge]];for(let[F,H,k]of[[R,u,d],[L,h,f]])F.profile===null?(U.push(F===R?[d,u,F.ridge]:[h,f,F.ridge]),C.push([H,F.ridge],[k,F.ridge])):F.upA.length&&(U.push(F===R?[F.upB[0],F.upA[0],F.ridge]:[F.upA[0],F.upB[0],F.ridge]),C.push([F.upA[0],F.ridge],[F.upB[0],F.ridge]));let I=F=>F.profile===null?[]:F.upA.length?[F.upA[0],F.upB[0]]:[F.ridge],O=[u,h,...I(L),f,d,...[...I(R)].reverse()];return{faces:U,rim:O,ridges:C,gable:w,endProfiles:[R.profile,L.profile]}}switch(i.shape){case"pent":return{faces:[[u,h,f,d]],rim:[u,h,f,d],ridges:[[f,d]],gable:[[0,n.y(0)],[r,n.y(r)]]};case"hip":case"pyramid":{let g=(t.u1-t.u0)/2,y=i.shape==="pyramid"?g:Math.min(g,Math.min(n.vr,r-n.vr)||r/2),_=m(t.u0+y),b=m(t.u1-y);return i.shape==="pyramid"?{faces:[[u,h,_],[h,f,_],[f,d,_],[d,u,_]],rim:[u,h,f,d],ridges:[[u,_],[d,_],[h,_],[f,_]],gable:null}:{faces:[[u,h,b,_],[_,b,f,d],[d,u,_],[h,f,b]],rim:[u,h,f,d],ridges:[[_,b],[u,_],[d,_],[h,b],[f,b]],gable:null}}case"halfhip":{let g=Math.min(n.y(0),n.y(r)),y=g+(n.rh-g)*Math.min(.9,Math.max(.2,i.halfhip??.55)),_=p>1e-6?Math.min(n.vr,(y-i.eave_a)/p):n.vr,b=x>1e-6?Math.max(n.vr,r-(y-i.eave_b)/x):n.vr,M=Math.min((t.u1-t.u0)/2-.1,(n.rh-y)/Math.max(.2,p)),S=m(t.u0+M),v=m(t.u1-M),w=[a,_,y],P=[a,b,y],T=[l,_,y],R=[l,b,y];return{faces:[[u,h,T,v,S,w],[S,v,R,f,d,P],[P,w,S],[T,R,v]],rim:[u,h,T,R,f,d,P,w],ridges:[[S,v],[w,S],[P,S],[T,v],[R,v]],gable:[[0,n.y(0)],[_,y],[b,y],[r,n.y(r)]]}}case"mansard":{let g=fl(r,i.eave_a,i.eave_b,p,x),y=[a,g.vla,g.yla],_=[l,g.vla,g.yla],b=[a,r-g.vlb,g.ylb],M=[l,r-g.vlb,g.ylb],S=[a,g.vr,g.rh],v=[l,g.vr,g.rh];return{faces:[[u,h,_,y],[y,_,v,S],[S,v,M,b],[b,M,f,d]],rim:[u,h,_,v,M,f,d,b,S,y],ridges:[[S,v],[y,_],[b,M]],gable:[[0,n.y(0)],[g.vla,g.yla],[g.vr,g.rh],[r-g.vlb,g.ylb],[r,n.y(r)]]}}default:{let g=m(a),y=m(l);return{faces:[[u,h,y,g],[g,y,f,d]],rim:[u,h,y,f,d,g],ridges:[[g,y]],gable:[[0,n.y(0)],[n.vr,n.rh],[r,n.y(r)]]}}}}function Es(i,e,t){let n=null;for(let r of i.faces){if(!Ge([e,t],r.map(([f,d])=>[f,d])))continue;let[s,o]=r,a=r.slice(2).find(f=>Math.abs((o[0]-s[0])*(f[1]-s[1])-(o[1]-s[1])*(f[0]-s[0]))>1e-9);if(!a)continue;let l=[o[0]-s[0],o[2]-s[2],o[1]-s[1]],c=[a[0]-s[0],a[2]-s[2],a[1]-s[1]],u=[l[1]*c[2]-l[2]*c[1],l[2]*c[0]-l[0]*c[2],l[0]*c[1]-l[1]*c[0]];if(Math.abs(u[1])<1e-9)continue;let h=s[2]-(u[0]*(e-s[0])+u[2]*(t-s[1]))/u[1];n=n===null?h:Math.min(n,h)}return n}function Lo(i,e,t,n){let r=o=>n?o[e]<=t+1e-9:o[e]>=t-1e-9,s=[];return i.forEach((o,a)=>{let l=i[(a+1)%i.length];if(r(o)&&s.push(o),r(o)!==r(l)){let c=(t-o[e])/(l[e]-o[e]);s.push([o[0]+(l[0]-o[0])*c,o[1]+(l[1]-o[1])*c,o[2]+(l[2]-o[2])*c])}}),s}function Xu(i,e){let t=Lo(Lo(i,0,e.u0,!1),0,e.u1,!0);return[Lo(i,0,e.u0,!0),Lo(i,0,e.u1,!1),Lo(t,1,e.v0,!0),Lo(t,1,e.v1,!1)].filter(r=>r.length>=3&&Math.abs(wr(r.map(([s,o])=>[s,o])))>1e-6)}function pl(i,e,t){let n=kn(e),r=i.floors.flatMap(h=>h.rooms.filter(f=>f.points.length>=3&&h.elevation+h.height>e.base+.05)),s=h=>h.some(f=>r.some(d=>Ge(f,d.points))),o=.35,a=[.15,.5,.85].map(h=>n.u0+(n.u1-n.u0)*h),l=[.15,.5,.85].map(h=>n.w*h),c=h=>h?0:t,u=(h,f)=>{let d=e.overhang_sides?.[h];return typeof d=="number"&&Number.isFinite(d)?Math.min(2,Math.max(0,d)):f};return{a:u("a",c(s(a.map(h=>n.at(h,-o))))),b:u("b",c(s(a.map(h=>n.at(h,n.w+o))))),u0:u("u0",c(s(l.map(h=>n.at(n.u0-o,h))))),u1:u("u1",c(s(l.map(h=>n.at(n.u1+o,h)))))}}var Fo=i=>Math.abs((i.x1-i.x0)*(i.z1-i.z0)),Yu=i=>i.shape==="flat"||i.shape==="parapet";function Rs(i,e){let[t,n]=[(e.x0+e.x1)/2,(e.z0+e.z1)/2];return i.filter(s=>{if(s===e||s.dormer||s.open||Yu(s)||Fo(s)=o.x0&&t<=o.x1&&n>=o.z0&&n<=o.z1}).reduce((s,o)=>s===null||Fo(o){let[s,o]=e.at(r,e.w/2),[a,l]=Oi(i,s,o);return Es(t,a,l)??n.y(l)}}function ml(i,e){if(Yu(e))return e;let t=kn(e),n=Rn(e).rh,r=ob(i,t),s=r(t.u0)<=r(t.u1),[o,a]=s?[t.u0,t.u1]:[t.u1,t.u0],l=s?1:-1,c=a;for(let f=.5;f=n-.02){c=o+l*f;break}if(Math.abs(c-a)<.05)return e;let u={...e},h=a===t.u1;return e.axis==="x"?u[h?"x1":"x0"]=c:u[h?"z1":"z0"]=c,u}function qu(i,e){let t=ml(i,e),n=kn(t),r=Rn(t),s=ob(i,n),o=s(n.u0)<=s(n.u1),a=n.u1-n.u0,l=Math.max(1,Math.ceil(a/.15)),c=[];for(let u=0;ux+.02&&(m=Math.min(m,M),g=Math.max(g,M))}if(!(g-m>.05))continue;let y=Oi(i,...n.at(d,m)),_=Oi(i,...n.at(p,g));c.push({u0:Math.min(y[0],_[0]),u1:Math.max(y[0],_[0]),v0:Math.min(y[1],_[1]),v1:Math.max(y[1],_[1])})}return c}function gl(i,e){if(e.dormer||e.open||Yu(e)||Rs(i,e))return null;let t=As(e),n=.35;for(let r of i){if(r===e||r.dormer||r.open||Yu(r)||r.axis===e.axis||Fo(r)a[3]+.05)continue;let l=(o[2]+o[3])/2,[c,u]=e.axis==="z"?["z0","z1"]:["x0","x1"],h;if(Math.abs(o[0]-o[3])<=n)h=[l,o[1]];else if(Math.abs(o[1]-o[2])<=n)h=[o[0],l];else continue;let f={...e,[c]:h[0],[u]:h[1]};return{parent:r,extended:ml(r,f)}}return null}var ab=.14,vR=i=>i.shape==="flat"||i.shape==="parapet";function xp(i,e){return!i.open&&Math.min(i.base,i.eave_a,i.eave_b)l+r||fu+r||o.points&&o.points.length>=3&&!Ge([e,t],o.points))continue;let[d,p]=Oi(o,e,t),x=Math.max(0,o.overhang??n),m=vR(o)?null:Es(Wr(o,{u0:x,u1:x,a:x,b:x}),d,p);s.push((m??Rn(o).y(p))-ab)}return s.length?Math.max(...s):null}function bp(i,e){let t=i.floors.filter(l=>l.rooms.length>0).sort((l,c)=>l.elevation-c.elevation),n=t.filter(l=>l.elevationu.rooms.some(h=>h.points.length>=3&&l.some(f=>Ge(f,h.points))));if(c)return c}return n.at(-1)??t[0]}function vp(i,e,t){let n=i.settings.roof.sections??[],r=n.filter(l=>t.includes(l.id)).map(l=>Rs(n,l)??l);if(r.length===0)return e.id;let s=Math.max(...r.map(dp)),o=l=>l.rooms.some(c=>{if(c.points.length<3)return!1;let u=c.points.reduce((f,d)=>f+d[0],0)/c.points.length,h=c.points.reduce((f,d)=>f+d[1],0)/c.points.length;return r.some(f=>u>=Math.min(f.x0,f.x1)&&u<=Math.max(f.x0,f.x1)&&h>=Math.min(f.z0,f.z1)&&h<=Math.max(f.z0,f.z1))});return i.floors.filter(l=>l.elevation>=e.elevation&&l.elevationc.elevation-l.elevation)[0]?.id??e.id}var No=new D;function lb(i,e,t,n=1.05){return No.set(e[0],e[1],e[2]).project(i),{x:(No.x+1)/2*t.w,y:(1-No.y)/2*t.h,off:No.z>1||Math.abs(No.x)>n||Math.abs(No.y)>n}}var xl=i=>`translate(${i.x}px, ${i.y}px) translate(-50%, -50%)`,cb=(i,e)=>`translate(${i}px, ${e}px) translate(0, -50%)`,$u=class{placed=new WeakMap;place(e,t){let n=t===null;e.hidden!==n&&(e.hidden=n),!(t===null||this.placed.get(e)===t)&&(this.placed.set(e,t),e.style.transform=t)}},_R=8;function ub(i){let e=[...i].sort((t,n)=>n.rank-t.rank).map(t=>({...t}));for(let t=1;tc.xc.x>l.x?c:l),s=8+t.inset,[o,a]=[n.x-e-14,n.y];return o=.99&&i.o>=.9&&!e}function fb(i){return i.to>0&&Math.abs(i.o-i.to)<.05}function db(i,e,t,n){return e===void 0?{y:t?i*2.4:0,opacity:1}:i>e?{y:5+i,opacity:0}:i===e?{y:0,opacity:1}:n==="stacked"?{y:0,opacity:1}:{y:-.4,opacity:n==="single"?0:.22}}function pb(i,e){let[t,n]=[i.ty-i.y,i.to-i.o];if(Math.abs(t)<.004&&Math.abs(n)<.004){let r=t!==0||n!==0;return r&&([i.y,i.o]=[i.ty,i.to]),{moving:!1,settled:r}}return i.y+=t*e,i.o+=n*e,{moving:!0,settled:!1}}function mb(i,e){let t=e>.999;for(let n of[i.floor,i.wall,i.frames,i.blinds,i.lamps])n.transparent===t&&(n.transparent=!t,n.depthWrite=t,n.needsUpdate=!0),n.opacity=e;for(let n of i.ghosts)n.material.opacity=n.base*e;for(let n of[i.pattern,i.glow,i.lines,i.glass,i.glassWall,i.halos,i.cones,i.screens])n.opacity=e}var Mp=i=>1-Math.exp(-i/140);var xb=["open","open2","tilt","tilt2"],Sp=i=>1-Math.exp(-i/160),gb=(i,e)=>(i??null)===(e??null)||typeof i=="number"&&typeof e=="number"&&Math.abs(i-e)<.003;function wp(i,e){return xb.every(t=>gb(e[t]??0,i[t]??0))&&gb(e.cover,i.cover)&&!!e.sensed==!!i.sensed&&!!e.unlocked==!!i.unlocked&&!!e.assumed==!!i.assumed}function yb(i,e,t){let n={...i,open2:i.open2??0,tilt2:i.tilt2??0,sensed:e.sensed,unlocked:e.unlocked,assumed:e.assumed},r=!1,s=(o,a)=>Math.abs(a-o)<.003?a:(r=!0,o+(a-o)*t);for(let o of xb)n[o]=s(i[o]??0,e[o]??0);return n.cover=e.cover===null||i.cover===null?e.cover:s(i.cover,e.cover),{state:n,moving:r}}var Cs={ceiling:[.4,.4,.08],downlight:[.1,.1,.02],spot:[.1,.1,.14],panel:[.6,.6,.03],uplight:[.35,.35,1.8],bollard:[.16,.16,.8],garden:[.12,.12,.3],pendant:[.4,.4,.8],fan:[1.32,1.32,.32],floor:[.42,.42,1.7],table:[.26,.26,.45],wall:[.22,.12,.2],strip:[2,.04,.03]},Ku=new Set(["ceiling","downlight","spot","panel","pendant","fan","strip"]),MR=1;function bb(i,e,t,n){switch(i){case"ceiling":return[e-.12,"ceiling"];case"downlight":return[e-.03,"spot"];case"spot":return[e-n,"spot"];case"panel":return[e-.05,"ceiling"];case"pendant":return[Math.max(.5,e-n),"pendant"];case"fan":return[Math.max(.5,e-n+.02),"ceiling"];case"floor":return[t+n-.15,"omni"];case"uplight":return[t+n,"up"];case"table":return[t+n-.1,"omni"];case"wall":return[t+.1,"wall"];case"strip":return[t+Math.max(.02,n)-.01,tSR&&d=0&&p<=1&&(l=d)}return l}function Sb(i,e,t){let n=i.count,r=e.wedge;if(!r)return{start:n,end:n};let s=(e.rotation??0)*mt,o=[-Math.sin(s),Math.cos(s)],a=r.angle*mt/2,l=new W(...r.color.map(d=>d*r.opacity)),c=new W(0,0,0),u=Math.max(4,Math.round(a/.15)),h=[e.x,e.z],f=(d,p)=>[e.x+(o[0]*Math.cos(d)-o[1]*Math.sin(d))*p,_b,e.z+(o[1]*Math.cos(d)+o[0]*Math.sin(d))*p];for(let d=0;d{i.positions.push(h,f,d);for(let x of t.color)i.colours.push(x*t.level*wR*p)};if(e.lamp==="strip")for(let h of[-.4,-.13,.13,.4])e.upright?u(e.x,a+r*(.5+h),e.z,.6):u(...Zu(e.x,c+Oo(e.base,r,e.rise),e.z,l,r,e.rise,h),.6);else e.lamp==="wall"?u(e.x-Math.sin(l)*(s/2+.05),c,e.z+Math.cos(l)*(s/2+.05),1):u(e.x,c,e.z,1)}function Ab(i,e,t,n){let[r,,s]=e.size??Cs[e.lamp],o=wb(e.lamp,n,e.base??0,s),a=new W(...t.color.map(d=>d*.09*t.level)),l=new W(0,0,0),[c,u]=[Math.max(.03,r/2),.45+.35*t.level],h=16,f=(d,p,x)=>[e.x+Math.cos(d)*p,x,e.z+Math.sin(d)*p];for(let d=0;dKu.has(i);var Rb=7,TR=.25,AR=.3,ER=2,Tp=[1,.82,.55],RR=.45;function Cb(i,e,t,n){return i?`${i.elevation.toFixed(1)},${i.azimuth.toFixed(1)},${e*mt},${t.toFixed(2)},${[...n].map(r=>(r.cover??0).toFixed(2)).join(",")}`:""}var Do=(i,e)=>[Math.sin((e+i)*mt),-Math.cos((e+i)*mt)],Ap=(i,e)=>Math.min(1,i/12)*(1-.8*e),CR=(i,e)=>-i.toRoom[0]*e[0]+-i.toRoom[1]*e[1];function Pb({floor:i,openings:e,states:t,sun:n,northDegrees:r,cloud:s}){let o=new ut;if(!n||n.elevation<=ER||s>=.97)return o;let a=Ap(n.elevation,s),l=Do(n.azimuth,r),c=1/Math.tan(n.elevation*mt);for(let u of e){if(u.opening.type!=="window"||!u.exterior)continue;let h=CR(u,l);if(h<.05)continue;let f=u.top-(t.get(u.opening.id)?.cover??0)*(u.top-u.sill);if(f-u.sill<.05)continue;let d=i.rooms.find(M=>M.id===u.opening.room_id);if(!d||d.points.length<3)continue;let p=(M,S)=>{let v=Math.min(Rb,S*c);return[u.start[0]+u.axis[0]*M+u.toRoom[0]*u.faceRoom-l[0]*v,.02,u.start[1]+u.axis[1]*M+u.toRoom[1]*u.faceRoom-l[1]*v]},x=.14*a*Math.min(1,h*1.5),m=new W(Tp[0]*x,Tp[1]*x,Tp[2]*x),g=m.clone().multiplyScalar(RR),y=Math.max(1,Math.ceil(Math.min(Rb,f*c)/TR)),_=Math.max(1,Math.ceil(u.width/AR)),b=f-u.sill;for(let M=0;Me+Cn(t,i[(n+1)%i.length]),0)/2}var Lb=i=>Ib(i)>=0?[...i]:[...i].reverse();function Fb(i,e,t,n){let r=xt(e,i),s=xt(n,t),o=Cn(r,s);if(Math.abs(o)<1e-12)return null;let a=Cn(xt(t,i),s)/o,l=Cn(xt(t,i),r)/o;return a>pr&&a<1-pr&&l>-pr&&l<1+pr?a:null}function Ep(i,e,t){let n=xt(t,e),r=vn(n,n);if(r<1e-12)return null;let s=vn(xt(i,e),n)/r;return s<=pr||s>=1-pr?null:Math.abs(Cn(xt(i,e),n))/Math.sqrt(r)Jn(xt(i,e))i.map((e,t)=>[e,i[(t+1)%i.length]]);function PR(i,e){for(let[t,n]of bl(i))for(let[r,s]of bl(e))if(Fb(t,n,r,s)!==null||Ep(r,t,n)!==null||Ep(t,r,s)!==null||yl(t,r))return!0;return Ge(i[0],e)||Ge(e[0],i)}function IR(i){let e=i.map(Lb),t=[];e.forEach((s,o)=>{for(let[a,l]of bl(s)){let c=[0,1];e.forEach((u,h)=>{if(h!==o)for(let[f,d]of bl(u)){let p=Fb(a,l,f,d)??Ep(f,a,l);p!==null&&c.push(p)}}),c.sort((u,h)=>u-h);for(let u=1;um!==o&&Ge(p,x))||t.some(([x,m])=>yl(x,h)&&yl(m,f))||t.push([h,f])}}});let n=[],r=new Set;return t.forEach(([s,o],a)=>{if(r.has(a))return;r.add(a);let l=[s],c=o;for(let u=0;u!r.has(d)&&yl(f,c,.001));if(h<0)break;r.add(h),l.push(t[h][0]),c=t[h][1]}l.length>=3&&Ib(l)>1e-6&&n.push(l)}),n}function mr(i){let e=i.filter(s=>s.length>=3),t=e.map((s,o)=>o),n=s=>t[s]===s?s:t[s]=n(t[s]);e.forEach((s,o)=>{for(let a=o+1;ar.set(n(o),[...r.get(n(o))??[],s])),[...r.values()].flatMap(s=>s.length===1?s:IR(s))}function LR(i,e,t){let n=xt(t,e),r=vn(n,n),s=r?Math.max(0,Math.min(1,vn(xt(i,e),n)/r)):0;return Jn(xt(i,[e[0]+n[0]*s,e[1]+n[1]*s]))}function Nb(i,e,t=.03){return i.every(n=>Ge(n,e)||bl(e).some(([r,s])=>LR(n,r,s)<=t))}function Ob(i,e){let t=Lb(i),n=(r,s)=>{let o=xt(s,r),a=Jn(o)||1;return[-o[1]/a,o[0]/a]};return t.map((r,s)=>{let o=n(t[(s-1+t.length)%t.length],r),a=n(r,t[(s+1)%t.length]),l=1+vn(o,a);return l<.1?r:[r[0]+(o[0]+a[0])/l*e,r[1]+(o[1]+a[1])/l*e]})}var FR=30,Db=i=>i.reduce((e,t,n)=>e+t[0]*i[(n+1)%i.length][1]-i[(n+1)%i.length][0]*t[1],0)/2;function NR(i,e,t,n){if(!t||t.elevation<=2||e<=0||!i.length)return[];let r=Math.min(FR,e/Math.tan(t.elevation*Math.PI/180)),[s,o]=Do(t.azimuth,n),a=c=>[c[0]-s*r,c[1]-o*r],l=[];for(let c of i){l.push([...c],c.map(a));let u=Math.sign(Db(c))||1;c.forEach((h,f)=>{let d=c[(f+1)%c.length];if(u*((d[1]-h[1])*-s-(d[0]-h[0])*-o)<=1e-9)return;let x=[h,d,a(d),a(h)];Math.abs(Db(x))>.001&&l.push(x)})}return mr(l)}var Ju=class{mesh;material=new Ye({color:0,side:ht,transparent:!0,opacity:0,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2});constructor(){this.mesh=new Se(new Pe,this.material),this.mesh.renderOrder=1,this.mesh.visible=!1}update(e,t,n,r,s,o,a){let l=a?[]:NR(e,t,r,s),c=[];for(let h of l){let f=e.filter(p=>Ge([p.reduce((x,m)=>x+m[0],0)/p.length,p.reduce((x,m)=>x+m[1],0)/p.length],h)),d=[...h,...f.flat()];for(let[p,x,m]of Gr(h,f.map(g=>[...g])))for(let g of[d[p],d[x],d[m]])c.push(g[0],n,g[1])}this.mesh.geometry.dispose();let u=new Pe;u.setAttribute("position",new Le(c,3)),this.mesh.geometry=u,this.material.opacity=r?.32*Ap(r.elevation,o):0,this.mesh.visible=c.length>0&&this.material.opacity>.02}dispose(){this.mesh.geometry.dispose(),this.material.dispose()}};var vl=i=>ts(i)>=0?i:[...i].reverse();function _l(i,[e,t],n,r,s,o,a){Tt(i,vl([[e-n,t-n],[e+n,t-n],[e+n,t+n],[e-n,t+n]]),r,s,o,a)}function ju(i,e,t,n,r,s,o,a,l=0){let[c,u]=[t[0]-e[0],t[1]-e[1]],h=Math.hypot(c,u);if(h<1e-6)return;let[f,d]=[-u/h*n*.5,c/h*n*.5];if(Math.abs(l)<1e-4){Tt(i,vl([[e[0]+f,e[1]+d],[t[0]+f,t[1]+d],[t[0]-f,t[1]-d],[e[0]-f,e[1]-d]]),r,s,o,a,{aoFrom:r-1});return}let p=(b,M)=>[e[0]+f*M,b,e[1]+d*M],x=(b,M)=>[t[0]+f*M,b+l,t[1]+d*M],m=(b,M)=>{for(let[S,v,w]of[[0,1,2],[0,2,3],[0,2,1],[0,3,2]])i.tri(b[S],b[v],b[w],M,M,M,void 0,$e)},g=new W(a),y=Be(o,.9),_=Be(o,.6);m([p(s,1),x(s,1),x(s,-1),p(s,-1)],g),m([p(r,1),x(r,1),x(r,-1),p(r,-1)],_),m([p(r,1),x(r,1),x(s,1),p(s,1)],y),m([p(r,-1),x(r,-1),x(s,-1),p(s,-1)],y),m([p(r,1),p(r,-1),p(s,-1),p(s,1)],y),m([x(r,1),x(r,-1),x(s,-1),x(s,1)],y)}function kb(i,e,t){let n=(o,a)=>Math.abs(o[0]-a[0])<1e-6&&Math.abs(o[1]-a[1])<1e-6,r=Math.hypot(t[0]-e[0],t[1]-e[1]),s=[];for(let o of i.gates??[]){let a=i.points[o.edge],l=i.points[(o.edge+1)%i.points.length];!a||!l||(n(a,e)&&n(l,t)?s.push({gate:o,offset:o.offset}):n(a,t)&&n(l,e)&&s.push({gate:o,offset:r-o.offset}))}return s.sort((o,a)=>o.offset-a.offset)}function Ub(i,e,t,n,r){let s=Math.hypot(e[0]-i[0],e[1]-i[1]);if(s<.3)return null;let o=Math.min(t.width,s-.1);if(o<.3)return null;let a=Math.max(.05,Math.min(s-o-.05,n-o/2)),l=a+o,[c,u]=[(e[0]-i[0])/s,(e[1]-i[1])/s],[h,f]=[-u,c],d=(g,y=0)=>[i[0]+c*g+h*y,i[1]+u*g+f*y],[p,x]=[d(a),d(l)],m=[];if(t.kind==="double"){let g=(a+l)/2;m.push(r?{a:p,b:d(a,o/2)}:{a:p,b:d(g)}),m.push(r?{a:x,b:d(l,o/2)}:{a:x,b:d(g)})}else t.kind==="sliding"?m.push(r?{a:d(l,-.12),b:d(l+o,-.12)}:{a:p,b:x}):m.push(r?{a:p,b:d(a,o)}:{a:p,b:x});return{from:a,to:l,posts:[p,x],leaves:m}}var Bb={lawn:{color:927778,side:729115,edge:4121250,edgeAlpha:.16},terrace:{color:1841968,side:1447464,edge:5995775,edgeAlpha:.32},path:{color:1778228,side:1383209,edge:5995775,edgeAlpha:.22},driveway:{color:1514796,side:1185573,edge:5995775,edgeAlpha:.18},pavers:{color:4736319,side:2696992,edge:10853768,edgeAlpha:.25},stepping_stones:{color:5592907,side:2699042,edge:10399619,edgeAlpha:.22},natural_stone:{color:5327421,side:2696735,edge:11641738,edgeAlpha:.25},street:{color:2369325,side:1382430,edge:10134706,edgeAlpha:.25},sidewalk:{color:4739163,side:2699579,edge:11451337,edgeAlpha:.28},gravel:{color:5327678,side:2762786,edge:12101762,edgeAlpha:.26},river:{color:1393488,side:1060150,edge:4829115,edgeAlpha:.3},stream:{color:2118484,side:1522750,edge:6669508,edgeAlpha:.3},pool:{color:736091,side:861497,edge:3662079,edgeAlpha:.6},bed:{color:1775123,side:1380623,edge:4121250,edgeAlpha:.2},wild:{color:1384987,side:1055509,edge:10146383,edgeAlpha:.14},hedge:{color:1524016,side:1126693,edge:4121250,edgeAlpha:.35},fence:{color:1976903,side:1976903,edge:5995775,edgeAlpha:.45},pergola:{color:2827065,side:2104109,edge:5995775,edgeAlpha:.5}};var zb={lawn:1,terrace:2,path:3,driveway:4,pool:5,bed:6,wild:7,hedge:8,fence:9,pergola:9,street:10,sidewalk:11,gravel:12,river:13,stream:14,pavers:15,stepping_stones:16,natural_stone:17},OR=` varying vec3 vNfGround; varying float vNfSurface; varying vec2 vNfSurfaceTransform; @@ -4342,7 +4342,7 @@ vec3 nfOutdoorTexture(vec3 position, float kind) { } return nfPebbles(p * 22.0, false); } -`;function ju(i){let e=i.onBeforeCompile.bind(i),t=i.customProgramCacheKey.bind(i);return i.onBeforeCompile=(n,r)=>{e(n,r),n.vertexShader=n.vertexShader.replace("#include ",`#include +`;function Qu(i){let e=i.onBeforeCompile.bind(i),t=i.customProgramCacheKey.bind(i);return i.onBeforeCompile=(n,r)=>{e(n,r),n.vertexShader=n.vertexShader.replace("#include ",`#include attribute float surface; attribute vec2 surfaceTransform; varying vec3 vNfGround; @@ -4351,11 +4351,11 @@ varying vec2 vNfSurfaceTransform;`).replace("#include ",`#include vNfGround = position; vNfSurface = surface; vNfSurfaceTransform = surfaceTransform;`),n.fragmentShader=n.fragmentShader.replace("#include ",`#include -${FR}`).replace("#include ",`if (vNfSurface > 0.5) { +${OR}`).replace("#include ",`if (vNfSurface > 0.5) { if (uTheme == 2) outgoingLight = nfOutdoorDay(vNfSurface) * (0.7 + dot(outgoingLight, vec3(0.299, 0.587, 0.114)) * 0.4); outgoingLight *= nfOutdoorTexture(vNfGround, vNfSurface); } - #include `)},i.customProgramCacheKey=()=>`${t()}-outdoor-textures-2`,i}function Ep(i,e){return ea(i)+(e.offset??0)+(jr(e.type)?.01:Vl[e.type])}function Qu(i,e){let t=i[e];return jr(t.type)||t.type==="pool"?[]:i.filter((n,r)=>r!==e&&B0(n)&&n.points.length>=3&&n.points.every(s=>Ge(s,t.points))).map(n=>bl(n.points))}var eh=(i,e)=>i.map((t,n)=>[n,t,i[(n+1)%i.length]]).filter(([t])=>t!==e);function _l(i,e){if(i.area.outline!==!1)for(let[,t,n]of eh(i.poly,i.openEdge))i.lines.seg([t[0],e(t[0],t[1]),t[1]],[n[0],e(n[0],n[1]),n[1]],i.edge,$e)}function NR(i){let{buf:e,poly:t,base:n,top:r,look:s}=i,o=new W(s.color);for(let[l,c,u]of Gr(t)){let[h,f,d]=[t[l],t[c],t[u]];e.tri([h[0],n+r,h[1]],[d[0],n+r,d[1]],[f[0],n+r,f[1]],o,o,o,void 0,$e)}let a=new W(s.side);for(let[,l,c]of eh(t,-1))e.tri([c[0],n+r,c[1]],[c[0],n+.06,c[1]],[l[0],n+.06,l[1]],a,a,a,void 0,$e),e.tri([c[0],n+r,c[1]],[l[0],n+.06,l[1]],[l[0],n+r,l[1]],a,a,a,void 0,$e);_l(i,()=>n+.06),_l(i,()=>n+r+.005)}function OR(i){let{buf:e,lines:t,poly:n,area:r,top:s,look:o,groundAt:a,edge:l,openEdge:c}=i;for(let[u,h,f]of eh(n,c)){let d=Math.hypot(f[0]-h[0],f[1]-h[1]),p=Math.max(1,Math.round(d/2)),x=Db(r,h,f).map(({gate:M,offset:S})=>({gate:M,layout:Ub(h,f,M,S,!!M.open)})).filter(M=>!!M.layout),m=M=>x.some(S=>M>S.layout.from-.15&&M=0&&u===c-1?p:p-1;for(let M=0;M<=g;M++){if(m(d*M/p))continue;let S=h[0]+(f[0]-h[0])*M/p,v=h[1]+(f[1]-h[1])*M/p,w=a(S,v);vl(e,[S,v],.04,w,w+s,o.side,o.color)}let y=[],_=0;for(let M of x)y.push([_,M.layout.from]),_=M.layout.to;y.push([_,d]);let b=M=>[h[0]+(f[0]-h[0])*M/d,h[1]+(f[1]-h[1])*M/d];for(let[M,S]of y){if(S-M<.02)continue;let[v,w]=[b(M),b(S)];for(let P of[.35,.85])t.seg([v[0],a(v[0],v[1])+P*s,v[1]],[w[0],a(w[0],w[1])+P*s,w[1]],l,$e)}for(let{layout:M}of x){for(let S of M.posts){let v=a(S[0],S[1]);vl(e,S,.07,v,v+s*1.05,o.side,o.color)}for(let S of M.leaves)DR(i,S.a,S.b)}}}function DR(i,e,t){let{buf:n,lines:r,top:s,look:o,groundAt:a,edge:l}=i,c=Math.hypot(t[0]-e[0],t[1]-e[1]);if(c<.05)return;let[u,h]=[a(e[0],e[1]),a(t[0],t[1])],f=h-u;for(let[p,x]of[[.12,.2],[.78,.86]])Ju(n,e,t,.05,u+p*s,u+x*s,o.side,o.color,f);let d=Math.max(2,Math.round(c/.18));for(let p=0;p<=d;p++){let x=p/d,m=e[0]+(t[0]-e[0])*x,g=e[1]+(t[1]-e[1])*x,y=u+f*x;vl(n,[m,g],p===0||p===d?.03:.012,y+.1*s,y+.9*s,o.side,o.color)}r.seg([e[0],u+.2*s,e[1]],[t[0],h+.78*s,t[1]],l,$e)}function UR(i){let{buf:e,lines:t,poly:n,area:r,top:s,look:o,groundAt:a,edge:l,openEdge:c}=i;for(let u of n){let h=a(u[0],u[1]);vl(e,u,.06,h,h+s,o.side,o.color)}for(let[,u,h]of eh(n,c)){let[f,d]=[a(u[0],u[1]),a(h[0],h[1])];Ju(e,u,h,.12,f+s-.16,f+s,o.side,o.color,d-f),r.bracing&&(t.seg([u[0],f+.25,u[1]],[h[0],d+s-.25,h[1]],l,$e),t.seg([h[0],d+.25,h[1]],[u[0],f+s-.25,u[1]],l,$e))}if(Z0(n)){let u=J0(n),h=u.x1-u.x0>=u.z1-u.z0,[f,d]=h?[u.x0,u.x1-u.x0]:[u.z0,u.z1-u.z0],p=Math.max(1,Math.round(d/.6));for(let x=1;xa(u,h)+s+.004)}function kR(i,e,t){let{buf:n,lines:r,poly:s,area:o,top:a,look:l,groundAt:c,base:u,edge:h}=i,f=u-(o.slope??0),d=(x,m)=>c(x,m)+a,p=Qu(e,t);if(Tt(n,s,f,o.slope?d:u+a,l.side,l.color,{aoFrom:f,holes:p}),_l(i,(x,m)=>d(x,m)+.004),o.type==="hedge"&&_l(i,(x,m)=>c(x,m)+.004),o.outline!==!1)for(let x of p)x.forEach((m,g)=>{let y=x[(g+1)%x.length];r.seg([m[0],d(m[0],m[1])+.004,m[1]],[y[0],d(y[0],y[1])+.004,y[1]],h,$e)})}function zb(i){let e=i.opacity;return e==null||!(e<1)?1:Math.max(.1,Math.round(e*20)/20)}function Rp(i,e,t,n,r){i.surface??=Array(i.p.length/3).fill(0),i.surfaceTransform??=Array.from({length:i.p.length/3*2},(a,l)=>l%2===0?1:0);let s=ea(t),o=t.outdoor??[];o.forEach((a,l)=>{if(a.points.length<3)return;let c=s+(a.offset??0),u=kb[a.type],h=bl(a.points),f=zb(a),d=i;f<1&&n&&r&&(n.has(f)||n.set(f,r()),d=n.get(f)),d.surface??=Array(d.p.length/3).fill(0),d.surfaceTransform??=Array.from({length:d.p.length/3*2},(g,y)=>y%2===0?1:0);let p=d.p.length/3,x={buf:d,lines:e,area:a,poly:h,base:c,groundAt:(g,y)=>c-cf(a,g,y),top:jr(a.type)&&a.height?a.height:Vl[a.type],look:u,edge:Be(u.edge,u.edgeAlpha),openEdge:a.open&&(a.type==="fence"||a.type==="pergola")?h.length-1:-1};a.type==="pool"?NR(x):a.type==="fence"?OR(x):a.type==="pergola"?UR(x):kR(x,o,l),d.surface.fill(Bb[a.type],p);let m=z0(a);for(let g=p;g({pos:new Float32Array(i),normal:new Float32Array(e),room:Int16Array.from(t),fold:new Float32Array(n),doors:r})}}function Wb(i,e){let[t,n]=[i.b[0]-i.a[0],i.b[1]-i.a[1]],r=Math.hypot(t,n)||1;return Math.abs((e.start[0]-i.a[0])*n-(e.start[1]-i.a[1])*t)/r<.02&&Math.abs((e.axis[0]*t+e.axis[1]*n)/r)>.99}function VR(i,e,t,n){let r=[];for(let s of n.filter(o=>Wb(i,o))){let o=(s.start[0]-i.a[0])*e[0]+(s.start[1]-i.a[1])*e[1],a=s.axis[0]*e[0]+s.axis[1]*e[1]>0?o:o-s.width;a>t||a+s.width<0||r.push({s0:a,s1:a+s.width,y0:s.sill-.01,y1:s.top+.01})}return r}function Gb(i,e,t){let n=[e,t,...i.filter(r=>r>e+.005&&rr-s);return n.filter((r,s)=>s===0||r>n[s-1]+.005)}function Hb(i,e,t=()=>!1){let n=i.map(u=>u[0]),r=i.map(u=>u[1]),[s,o]=[Math.min(...n),Math.min(...r)],[a,l]=[Math.max(1,Math.ceil((Math.max(...n)-s)/e)),Math.max(1,Math.ceil((Math.max(...r)-o)/e))],c=[];for(let u=0;ua.add([d,x,p],[d,x,p+r],[d+r,x,p+r],[d+r,x,p],[0,1,0],m,-1);i.rooms.forEach((d,p)=>{if(!(d.points.length<3))for(let{a:x,b:m}of Hb(d.points,r,(g,y)=>s.some(_=>Ge([g,y],_))))l(x,m,Vb,p)});let c=i.rooms.length,u=i.outdoor??[];u.forEach((d,p)=>{if(d.points.length<3||jr(d.type))return;let x=Ep(i,d)+Vb,m=Qu(u,p);for(let{a:g,b:y}of Hb(d.points,r,(_,b)=>m.some(M=>Ge([_,b],M))))l(g,y,x,c)});let h=Math.min(i.cut_height,i.height);e.forEach((d,p)=>{let x=d.heightEnd===void 0?null:[d.height??i.height,d.heightEnd],m=x?Math.max(...x):d.height??i.height,g=Math.min(h,m-.02),[y,_]=[d.b[0]-d.a[0],d.b[1]-d.a[1]],b=Math.hypot(y,_);if(b<.05)return;let M=[y/b,_/b],S=[-M[1],M[0]],v=t[p],w=VR(d,M,b,n),P=Gb([g,(g+m)/2,...w.flatMap(R=>[R.y0+.01,R.y1-.01])],.02,m-.02),T=Gb(w.flatMap(R=>[R.s0,R.s1]),0,b);for(let R of[1,-1]){let L=R>0?d.roomLeft:d.roomRight,k=L?i.rooms.findIndex(H=>H.id===L):d.exterior?c:-1;if(k<0)continue;let C=(R>0?d.left:d.right)+BR,I=[S[0]*R,S[1]*R],O=(H,U)=>[d.a[0]+M[0]*H+I[0]*C,U,d.a[1]+M[1]*H+I[1]*C],F=H=>{let U=O(H,0),X=o?.(U[0],U[2]),V=x?x[0]+(x[1]-x[0])*H/b-.02:1/0;return Math.min(V,X==null?1/0:X-.02)};for(let H=0;H+1we>Ae.s0&&weAe.y0&&le=h-1e-6?v:fr+v)}}}}});let f=[];for(let d of n.filter(p=>p.opening.type==="door")){let p=e.find(g=>Wb(g,d));if(!p?.roomLeft||!p.roomRight)continue;let[x,m]=[i.rooms.findIndex(g=>g.id===p.roomLeft),i.rooms.findIndex(g=>g.id===p.roomRight)];x<0||m<0||f.push({id:d.opening.id,a:x,b:m,x:d.start[0]+d.axis[0]*(d.width/2),y:Math.min(1.1,d.top*.55),z:d.start[1]+d.axis[1]*(d.width/2)})}return a.finish(f)}function GR(i,e){let t=Math.max(0,-e),n=Math.max(0,e);switch(i){case"ceiling":return .3+.7*t;case"spot":return .06+.94*t**5;case"pendant":return .25+.85*t**2+.2*n;case"up":return .25+.75*n;case"wall":return .45+.35*Math.abs(e);default:return 1}}function HR(i){return(i.kind==="spot"?2:i.kind==="wall"?1.4:2.4)*(.55+.45*i.level)}function Xb(i,e,t){let[n,r,s]=[e[0]-i.x,e[1]-i.y,e[2]-i.z],o=n*n+r*r+s*s,a=Math.sqrt(o)||1e-6,l=HR(i),c=1/(1+o/(l*l)),u=c*Math.sqrt(c),h=Math.max(0,-(n*t[0]+r*t[1]+s*t[2])/a);return i.level*u*(.2+.8*h)*GR(i.kind,r/a)}function WR(i,e,t){let n=[];return i.doors.forEach((r,s)=>{let o=t[s]??.5;if(!(o<=.01))for(let[a,l]of[[r.a,r.b],[r.b,r.a]]){let c=[0,0,0];for(let h of e.filter(f=>f.room===a)){let f=[h.x-r.x,h.y-r.y,h.z-r.z],d=Math.hypot(...f)||1,p=Xb(h,[r.x,r.y,r.z],[f[0]/d,f[1]/d,f[2]/d]);for(let x=0;x<3;x++)c[x]+=h.color[x]*p}let u=Math.max(...c);u<.01||n.push({x:r.x,y:r.y,z:r.z,color:[c[0]/u,c[1]/u,c[2]/u],level:Math.min(1,u*.9*(.35+.65*o)),kind:"wall",room:l})}}),n}function Pp(i,e,t=.7,n=[]){let r=new Map;for(let c of[...e,...WR(i,e,n)]){let u={...c,color:c.color.map(h=>h**1.5)};r.set(c.room,[...r.get(c.room)??[],u])}let{pos:s,normal:o,room:a}=i,l=new Float32Array(s.length);for(let c=0;cr.points.length>=3&&Ge([e,t],r.points));return n<0?i.rooms.length:n}var Lp=(i,e)=>i&&e>=0&&e45,y=d+Oo(s.base,l,s.rise);for(let _ of qR)if(s.upright)r.push({x:s.x,y:u+l*(.5+_),z:s.z,color:p,level:x*Yb,kind:"omni",room:a});else{let[b,M,S]=Ku(s.x,y,s.z,m,l,s.rise,_);r.push({x:b,y:M,z:S,color:p,level:x*Yb,kind:g?"omni":f,room:a})}}return r}function $b(i,e,t="plain"){return i.onBeforeCompile=n=>{n.uniforms.uStanding=e.standing,n.uniforms.uGlass=e.glass,n.uniforms.uSlope=e.slope??{value:{x:0,y:0,z:0,w:0}},n.uniforms.uSlopeY=e.slopeY??{value:{x:0,y:0}},n.uniforms.uGlassAlpha=e.glassAlpha??{value:.2},n.vertexShader=n.vertexShader.replace("#include ",`#include + #include `)},i.customProgramCacheKey=()=>`${t()}-outdoor-textures-2`,i}function Rp(i,e){return ia(i)+(e.offset??0)+(Qr(e.type)?.01:Yl[e.type])}function eh(i,e){let t=i[e];return Qr(t.type)||t.type==="pool"?[]:i.filter((n,r)=>r!==e&&Q0(n)&&n.points.length>=3&&n.points.every(s=>Ge(s,t.points))).map(n=>vl(n.points))}var th=(i,e)=>i.map((t,n)=>[n,t,i[(n+1)%i.length]]).filter(([t])=>t!==e);function Ml(i,e){if(i.area.outline!==!1)for(let[,t,n]of th(i.poly,i.openEdge))i.lines.seg([t[0],e(t[0],t[1]),t[1]],[n[0],e(n[0],n[1]),n[1]],i.edge,$e)}function DR(i){let{buf:e,poly:t,base:n,top:r,look:s}=i,o=new W(s.color);for(let[l,c,u]of Gr(t)){let[h,f,d]=[t[l],t[c],t[u]];e.tri([h[0],n+r,h[1]],[d[0],n+r,d[1]],[f[0],n+r,f[1]],o,o,o,void 0,$e)}let a=new W(s.side);for(let[,l,c]of th(t,-1))e.tri([c[0],n+r,c[1]],[c[0],n+.06,c[1]],[l[0],n+.06,l[1]],a,a,a,void 0,$e),e.tri([c[0],n+r,c[1]],[l[0],n+.06,l[1]],[l[0],n+r,l[1]],a,a,a,void 0,$e);Ml(i,()=>n+.06),Ml(i,()=>n+r+.005)}function kR(i){let{buf:e,lines:t,poly:n,area:r,top:s,look:o,groundAt:a,edge:l,openEdge:c}=i;for(let[u,h,f]of th(n,c)){let d=Math.hypot(f[0]-h[0],f[1]-h[1]),p=Math.max(1,Math.round(d/2)),x=kb(r,h,f).map(({gate:M,offset:S})=>({gate:M,layout:Ub(h,f,M,S,!!M.open)})).filter(M=>!!M.layout),m=M=>x.some(S=>M>S.layout.from-.15&&M=0&&u===c-1?p:p-1;for(let M=0;M<=g;M++){if(m(d*M/p))continue;let S=h[0]+(f[0]-h[0])*M/p,v=h[1]+(f[1]-h[1])*M/p,w=a(S,v);_l(e,[S,v],.04,w,w+s,o.side,o.color)}let y=[],_=0;for(let M of x)y.push([_,M.layout.from]),_=M.layout.to;y.push([_,d]);let b=M=>[h[0]+(f[0]-h[0])*M/d,h[1]+(f[1]-h[1])*M/d];for(let[M,S]of y){if(S-M<.02)continue;let[v,w]=[b(M),b(S)];for(let P of[.35,.85])t.seg([v[0],a(v[0],v[1])+P*s,v[1]],[w[0],a(w[0],w[1])+P*s,w[1]],l,$e)}for(let{layout:M}of x){for(let S of M.posts){let v=a(S[0],S[1]);_l(e,S,.07,v,v+s*1.05,o.side,o.color)}for(let S of M.leaves)UR(i,S.a,S.b)}}}function UR(i,e,t){let{buf:n,lines:r,top:s,look:o,groundAt:a,edge:l}=i,c=Math.hypot(t[0]-e[0],t[1]-e[1]);if(c<.05)return;let[u,h]=[a(e[0],e[1]),a(t[0],t[1])],f=h-u;for(let[p,x]of[[.12,.2],[.78,.86]])ju(n,e,t,.05,u+p*s,u+x*s,o.side,o.color,f);let d=Math.max(2,Math.round(c/.18));for(let p=0;p<=d;p++){let x=p/d,m=e[0]+(t[0]-e[0])*x,g=e[1]+(t[1]-e[1])*x,y=u+f*x;_l(n,[m,g],p===0||p===d?.03:.012,y+.1*s,y+.9*s,o.side,o.color)}r.seg([e[0],u+.2*s,e[1]],[t[0],h+.78*s,t[1]],l,$e)}function BR(i){let{buf:e,lines:t,poly:n,area:r,top:s,look:o,groundAt:a,edge:l,openEdge:c}=i;for(let u of n){let h=a(u[0],u[1]);_l(e,u,.06,h,h+s,o.side,o.color)}for(let[,u,h]of th(n,c)){let[f,d]=[a(u[0],u[1]),a(h[0],h[1])];ju(e,u,h,.12,f+s-.16,f+s,o.side,o.color,d-f),r.bracing&&(t.seg([u[0],f+.25,u[1]],[h[0],d+s-.25,h[1]],l,$e),t.seg([h[0],d+.25,h[1]],[u[0],f+s-.25,u[1]],l,$e))}if(lg(n)){let u=cg(n),h=u.x1-u.x0>=u.z1-u.z0,[f,d]=h?[u.x0,u.x1-u.x0]:[u.z0,u.z1-u.z0],p=Math.max(1,Math.round(d/.6));for(let x=1;xa(u,h)+s+.004)}function zR(i,e,t){let{buf:n,lines:r,poly:s,area:o,top:a,look:l,groundAt:c,base:u,edge:h}=i,f=u-(o.slope??0),d=(x,m)=>c(x,m)+a,p=eh(e,t);if(Tt(n,s,f,o.slope?d:u+a,l.side,l.color,{aoFrom:f,holes:p}),Ml(i,(x,m)=>d(x,m)+.004),o.type==="hedge"&&Ml(i,(x,m)=>c(x,m)+.004),o.outline!==!1)for(let x of p)x.forEach((m,g)=>{let y=x[(g+1)%x.length];r.seg([m[0],d(m[0],m[1])+.004,m[1]],[y[0],d(y[0],y[1])+.004,y[1]],h,$e)})}function Vb(i){let e=i.opacity;return e==null||!(e<1)?1:Math.max(.1,Math.round(e*20)/20)}function Cp(i,e,t,n,r){i.surface??=Array(i.p.length/3).fill(0),i.surfaceTransform??=Array.from({length:i.p.length/3*2},(a,l)=>l%2===0?1:0);let s=ia(t),o=t.outdoor??[];o.forEach((a,l)=>{if(a.points.length<3)return;let c=s+(a.offset??0),u=Bb[a.type],h=vl(a.points),f=Vb(a),d=i;f<1&&n&&r&&(n.has(f)||n.set(f,r()),d=n.get(f)),d.surface??=Array(d.p.length/3).fill(0),d.surfaceTransform??=Array.from({length:d.p.length/3*2},(g,y)=>y%2===0?1:0);let p=d.p.length/3,x={buf:d,lines:e,area:a,poly:h,base:c,groundAt:(g,y)=>c-hf(a,g,y),top:Qr(a.type)&&a.height?a.height:Yl[a.type],look:u,edge:Be(u.edge,u.edgeAlpha),openEdge:a.open&&(a.type==="fence"||a.type==="pergola")?h.length-1:-1};a.type==="pool"?DR(x):a.type==="fence"?kR(x):a.type==="pergola"?BR(x):zR(x,o,l),d.surface.fill(zb[a.type],p);let m=eg(a);for(let g=p;g({pos:new Float32Array(i),normal:new Float32Array(e),room:Int16Array.from(t),fold:new Float32Array(n),doors:r})}}function Xb(i,e){let[t,n]=[i.b[0]-i.a[0],i.b[1]-i.a[1]],r=Math.hypot(t,n)||1;return Math.abs((e.start[0]-i.a[0])*n-(e.start[1]-i.a[1])*t)/r<.02&&Math.abs((e.axis[0]*t+e.axis[1]*n)/r)>.99}function HR(i,e,t,n){let r=[];for(let s of n.filter(o=>Xb(i,o))){let o=(s.start[0]-i.a[0])*e[0]+(s.start[1]-i.a[1])*e[1],a=s.axis[0]*e[0]+s.axis[1]*e[1]>0?o:o-s.width;a>t||a+s.width<0||r.push({s0:a,s1:a+s.width,y0:s.sill-.01,y1:s.top+.01})}return r}function Hb(i,e,t){let n=[e,t,...i.filter(r=>r>e+.005&&rr-s);return n.filter((r,s)=>s===0||r>n[s-1]+.005)}function Wb(i,e,t=()=>!1){let n=i.map(u=>u[0]),r=i.map(u=>u[1]),[s,o]=[Math.min(...n),Math.min(...r)],[a,l]=[Math.max(1,Math.ceil((Math.max(...n)-s)/e)),Math.max(1,Math.ceil((Math.max(...r)-o)/e))],c=[];for(let u=0;ua.add([d,x,p],[d,x,p+r],[d+r,x,p+r],[d+r,x,p],[0,1,0],m,-1);i.rooms.forEach((d,p)=>{if(!(d.points.length<3))for(let{a:x,b:m}of Wb(d.points,r,(g,y)=>s.some(_=>Ge([g,y],_))))l(x,m,Gb,p)});let c=i.rooms.length,u=i.outdoor??[];u.forEach((d,p)=>{if(d.points.length<3||Qr(d.type))return;let x=Rp(i,d)+Gb,m=eh(u,p);for(let{a:g,b:y}of Wb(d.points,r,(_,b)=>m.some(M=>Ge([_,b],M))))l(g,y,x,c)});let h=Math.min(i.cut_height,i.height);e.forEach((d,p)=>{let x=d.heightEnd===void 0?null:[d.height??i.height,d.heightEnd],m=x?Math.max(...x):d.height??i.height,g=Math.min(h,m-.02),[y,_]=[d.b[0]-d.a[0],d.b[1]-d.a[1]],b=Math.hypot(y,_);if(b<.05)return;let M=[y/b,_/b],S=[-M[1],M[0]],v=t[p],w=HR(d,M,b,n),P=Hb([g,(g+m)/2,...w.flatMap(R=>[R.y0+.01,R.y1-.01])],.02,m-.02),T=Hb(w.flatMap(R=>[R.s0,R.s1]),0,b);for(let R of[1,-1]){let L=R>0?d.roomLeft:d.roomRight,U=L?i.rooms.findIndex(H=>H.id===L):d.exterior?c:-1;if(U<0)continue;let C=(R>0?d.left:d.right)+VR,I=[S[0]*R,S[1]*R],O=(H,k)=>[d.a[0]+M[0]*H+I[0]*C,k,d.a[1]+M[1]*H+I[1]*C],F=H=>{let k=O(H,0),X=o?.(k[0],k[2]),V=x?x[0]+(x[1]-x[0])*H/b-.02:1/0;return Math.min(V,X==null?1/0:X-.02)};for(let H=0;H+1we>Ae.s0&&weAe.y0&&le=h-1e-6?v:fr+v)}}}}});let f=[];for(let d of n.filter(p=>p.opening.type==="door")){let p=e.find(g=>Xb(g,d));if(!p?.roomLeft||!p.roomRight)continue;let[x,m]=[i.rooms.findIndex(g=>g.id===p.roomLeft),i.rooms.findIndex(g=>g.id===p.roomRight)];x<0||m<0||f.push({id:d.opening.id,a:x,b:m,x:d.start[0]+d.axis[0]*(d.width/2),y:Math.min(1.1,d.top*.55),z:d.start[1]+d.axis[1]*(d.width/2)})}return a.finish(f)}function WR(i,e){let t=Math.max(0,-e),n=Math.max(0,e);switch(i){case"ceiling":return .3+.7*t;case"spot":return .06+.94*t**5;case"pendant":return .25+.85*t**2+.2*n;case"up":return .25+.75*n;case"wall":return .45+.35*Math.abs(e);default:return 1}}function XR(i){return(i.kind==="spot"?2:i.kind==="wall"?1.4:2.4)*(.55+.45*i.level)}function Yb(i,e,t){let[n,r,s]=[e[0]-i.x,e[1]-i.y,e[2]-i.z],o=n*n+r*r+s*s,a=Math.sqrt(o)||1e-6,l=XR(i),c=1/(1+o/(l*l)),u=c*Math.sqrt(c),h=Math.max(0,-(n*t[0]+r*t[1]+s*t[2])/a);return i.level*u*(.2+.8*h)*WR(i.kind,r/a)}function YR(i,e,t){let n=[];return i.doors.forEach((r,s)=>{let o=t[s]??.5;if(!(o<=.01))for(let[a,l]of[[r.a,r.b],[r.b,r.a]]){let c=[0,0,0];for(let h of e.filter(f=>f.room===a)){let f=[h.x-r.x,h.y-r.y,h.z-r.z],d=Math.hypot(...f)||1,p=Yb(h,[r.x,r.y,r.z],[f[0]/d,f[1]/d,f[2]/d]);for(let x=0;x<3;x++)c[x]+=h.color[x]*p}let u=Math.max(...c);u<.01||n.push({x:r.x,y:r.y,z:r.z,color:[c[0]/u,c[1]/u,c[2]/u],level:Math.min(1,u*.9*(.35+.65*o)),kind:"wall",room:l})}}),n}function Ip(i,e,t=.7,n=[]){let r=new Map;for(let c of[...e,...YR(i,e,n)]){let u={...c,color:c.color.map(h=>h**1.5)};r.set(c.room,[...r.get(c.room)??[],u])}let{pos:s,normal:o,room:a}=i,l=new Float32Array(s.length);for(let c=0;cr.points.length>=3&&Ge([e,t],r.points));return n<0?i.rooms.length:n}var Fp=(i,e)=>i&&e>=0&&e45,y=d+Oo(s.base,l,s.rise);for(let _ of KR)if(s.upright)r.push({x:s.x,y:u+l*(.5+_),z:s.z,color:p,level:x*qb,kind:"omni",room:a});else{let[b,M,S]=Zu(s.x,y,s.z,m,l,s.rise,_);r.push({x:b,y:M,z:S,color:p,level:x*qb,kind:g?"omni":f,room:a})}}return r}function Kb(i,e,t="plain"){return i.onBeforeCompile=n=>{n.uniforms.uStanding=e.standing,n.uniforms.uGlass=e.glass,n.uniforms.uSlope=e.slope??{value:{x:0,y:0,z:0,w:0}},n.uniforms.uSlopeY=e.slopeY??{value:{x:0,y:0}},n.uniforms.uGlassAlpha=e.glassAlpha??{value:.2},n.vertexShader=n.vertexShader.replace("#include ",`#include attribute float fold; uniform int uStanding; uniform int uGlass; @@ -4389,7 +4389,7 @@ uniform float uGlassAlpha;`),t!=="glass"&&(n.fragmentShader=n.fragmentShader.rep if (vNfPaint > 0.5) diffuseColor.rgb = vColor.rgb; #endif`)),t==="glass"&&(n.fragmentShader=n.fragmentShader.replace("#include ",`#include diffuseColor.rgb = diffuseColor.rgb * 1.7 + vec3(0.015, 0.05, 0.075); - diffuseColor.a *= uGlassAlpha;`))},i.customProgramCacheKey=()=>`nf-fold-${t}`,i}var Fp=["neon","blueprint","day"],JO=["auto",...Fp];var Kb=i=>Fp.indexOf(i),th={value:new D(.22,.88,1)},nh={value:0};function Zb(i){let e=/^#?([0-9a-f]{6})$/i.exec(i?.trim()??"");if(!e)return null;let t=Number.parseInt(e[1],16);return[(t>>16&255)/255,(t>>8&255)/255,(t&255)/255]}var $R=` + diffuseColor.a *= uGlassAlpha;`))},i.customProgramCacheKey=()=>`nf-fold-${t}`,i}var Np=["neon","blueprint","day"],QO=["auto",...Np];var Zb=i=>Np.indexOf(i),nh={value:new D(.22,.88,1)},ih={value:0};function Jb(i){let e=/^#?([0-9a-f]{6})$/i.exec(i?.trim()??"");if(!e)return null;let t=Number.parseInt(e[1],16);return[(t>>16&255)/255,(t>>8&255)/255,(t&255)/255]}var ZR=` uniform int uTheme; uniform vec3 uAccent; uniform int uAccentOn; @@ -4416,19 +4416,19 @@ vec3 nfThemed(vec3 c, bool isLine) { vec3 grey = vec3(clamp(0.66 + luma * 2.6, 0.0, 0.96)); return mix(grey, grey * (c / max(strongest, 0.001)), 0.1); } -`;function jn(i,e,t=!1){let n=i.onBeforeCompile.bind(i),r=i.customProgramCacheKey.bind(i);return i.onBeforeCompile=(s,o)=>{n(s,o),Object.assign(s.uniforms,{uTheme:e,uAccent:th,uAccentOn:nh}),s.fragmentShader=s.fragmentShader.replace("#include ",`#include -${$R}`).replace("#include ",`#include - diffuseColor.rgb = nfThemed(diffuseColor.rgb, ${t});`)},i.customProgramCacheKey=()=>`${r()}-themed-${t?"l":"s"}`,i}var Ml=i=>i==="day"?Ei:Ft;var KR=`#include +`;function jn(i,e,t=!1){let n=i.onBeforeCompile.bind(i),r=i.customProgramCacheKey.bind(i);return i.onBeforeCompile=(s,o)=>{n(s,o),Object.assign(s.uniforms,{uTheme:e,uAccent:nh,uAccentOn:ih}),s.fragmentShader=s.fragmentShader.replace("#include ",`#include +${ZR}`).replace("#include ",`#include + diffuseColor.rgb = nfThemed(diffuseColor.rgb, ${t});`)},i.customProgramCacheKey=()=>`${r()}-themed-${t?"l":"s"}`,i}var Sl=i=>i==="day"?Ei:Ft;var JR=`#include attribute vec2 tile; -varying vec2 vNfTile;`,ZR=`#include -vNfTile = tile;`,JR=`#ifdef USE_MAP +varying vec2 vNfTile;`,jR=`#include +vNfTile = tile;`,QR=`#ifdef USE_MAP vec2 nfCell = fract(vMapUv); vec2 nfUv = (vNfTile + 0.004 + nfCell * 0.992) / vec2(3.0, 2.0); // gradients of the unwrapped coordinates avoid mip seams at the tile borders vec4 sampledDiffuseColor = textureGrad(map, nfUv, dFdx(vMapUv) / vec2(3.0, 2.0), dFdy(vMapUv) / vec2(3.0, 2.0)); diffuseColor *= sampledDiffuseColor; - #endif`;function jR(i){let e=new Ye({map:i,transparent:!0,blending:Ft,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-2});return e.onBeforeCompile=t=>{t.vertexShader=t.vertexShader.replace("#include ",KR).replace("#include ",ZR),t.fragmentShader=t.fragmentShader.replace("#include ",`#include -varying vec2 vNfTile;`).replace("#include ",JR)},e.customProgramCacheKey=()=>"nf-pattern",e}var ih=(i={})=>new Ye({vertexColors:!0,transparent:!0,blending:Ft,depthWrite:!1,...i});function Jb({mask:i,look:e,theme:t,textures:n}){let r=(o={})=>new Ye({vertexColors:!0,...o}),s=(o,a)=>$b(o,i,a);return{floor:jn(r(),e),pattern:jR(n.pattern),wall:ju(jn(s(r(),"solid"),e)),glassWall:s(r({transparent:!0,depthWrite:!1}),"glass"),shadow:r({blending:Xa,premultipliedAlpha:!0,transparent:!0,depthWrite:!1,side:ht,polygonOffset:!0,polygonOffsetFactor:-1}),lines:jn(s(new Lt({vertexColors:!0,transparent:!0,blending:Ml(t),depthWrite:!1})),e,!0),glow:s(ih({side:ht,polygonOffset:!0,polygonOffsetFactor:-3}),"solid"),frames:jn(s(r({side:ht})),e),glass:s(ih({side:ht})),blinds:jn(s(r({map:n.blinds,side:ht})),e),lamps:jn(r(),e),halos:new cn({map:n.halo,size:.9,sizeAttenuation:!0,vertexColors:!0,transparent:!0,blending:Ft,depthWrite:!1}),cones:ih({side:ht}),screens:ih({side:ht}),ghosts:[]}}var rh=i=>Object.assign(document.createElement("span"),{className:i});function jb(i,e){let t=Object.assign(document.createElement("button"),{className:"nf-dev"});t.dataset.entity=i,t.append(rh("nf-dev-icon"),rh("nf-dev-text"),rh("nf-dev-watt"),rh("nf-dev-name"));let n,r=!1,s=a=>{let{x:l,y:c}=e.centre(t);a(i,l,c)},o=()=>clearTimeout(n);t.addEventListener("pointerdown",a=>{if(e.furnishing())return e.pressedWhileFurnishing(i);a.stopPropagation(),r=!1,o(),n=setTimeout(()=>{r=!0,s(e.hold)},500)});for(let a of["pointerleave","pointercancel","pointerup"])t.addEventListener(a,o);return t.addEventListener("contextmenu",a=>a.preventDefault()),t.addEventListener("click",a=>{if(a.stopPropagation(),e.furnishing())return e.selectWhileFurnishing(i);r||s(e.tap)}),t.addEventListener("keydown",a=>{(a.key==="Enter"&&a.shiftKey||a.key==="ContextMenu")&&(a.preventDefault(),s(e.hold))}),t}function Qb(i,e=10,t="NextFloor"){let n=[];for(let{positions:o,lift:a}of i)for(let l=0;l+8[o[l+x]*e,-o[l+x+2]*e,(o[l+x+1]+a)*e]),[u,h,f]=c,d=[(h[1]-u[1])*(f[2]-u[2])-(h[2]-u[2])*(f[1]-u[1]),(h[2]-u[2])*(f[0]-u[0])-(h[0]-u[0])*(f[2]-u[2]),(h[0]-u[0])*(f[1]-u[1])-(h[1]-u[1])*(f[0]-u[0])],p=Math.hypot(d[0],d[1],d[2]);p<1e-9||n.push([d[0]/p,d[1]/p,d[2]/p,...u,...h,...f])}let r=new Uint8Array(84+n.length*50),s=new DataView(r.buffer);return r.set(new TextEncoder().encode(`${t} STL`.slice(0,79)),0),s.setUint32(80,n.length,!0),n.forEach((o,a)=>{let l=84+a*50;o.forEach((c,u)=>s.setFloat32(l+u*4,c,!0))}),r}var Ps=Math.PI/180;function ev(i,e,t){let n=i.getTime()/864e5-10957.5,r=(357.529+.98560028*n)*Ps,o=(280.459+.98564736*n+1.915*Math.sin(r)+.02*Math.sin(2*r))*Ps,a=(23.439-36e-8*n)*Ps,l=Math.atan2(Math.cos(a)*Math.sin(o),Math.cos(o)),c=Math.asin(Math.sin(a)*Math.sin(o)),h=(((18.697374558+24.06570982441908*n)%24+24)%24*15+t)*Ps-l,f=e*Ps,d=Math.asin(Math.sin(f)*Math.sin(c)+Math.cos(f)*Math.cos(c)*Math.cos(h)),p=Math.atan2(Math.sin(h),Math.cos(h)*Math.sin(f)-Math.tan(c)*Math.cos(f))/Ps+180;return{elevation:d/Ps,azimuth:(p%360+360)%360}}function Np(i,e){let t=Object.fromEntries(new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}).formatToParts(new Date(i)).map(n=>[n.type,Number(n.value)]));return Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second)}function tv(i,e,t=new Date){let[n,r]=[Math.floor(i),Math.round(i%1*60)];if(e)try{let o=new Date(Np(t.getTime(),e)),a=Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),n,r),l=a-(Np(a,e)-a);return l=a-(Np(l,e)-l),new Date(l)}catch{}let s=new Date(t);return s.setHours(n,r,0,0),s}function QR(i,e=new Date){let t=[];for(let n=0;n<=24;n+=.25){let r=ev(tv(Math.min(n,23.99),i.zone,e),i.latitude,i.longitude);r.elevation<0||t.push(nv(i,r))}return t}function nv(i,e){let[t,n]=Do(e.azimuth,i.north),r=Math.max(0,e.elevation)*Math.PI/180;return[i.centre[0]+t*i.radius*Math.cos(r),Math.sin(r)*i.radius*.9,i.centre[1]+n*i.radius*Math.cos(r)]}function eC(i,e){let t=document.createElement("canvas");t.width=t.height=64;let n=t.getContext("2d");n&&(n.font="bold 44px system-ui, sans-serif",n.fillStyle=e,n.textAlign="center",n.textBaseline="middle",n.fillText(i,32,34));let r=new er(new _i({map:new zt(t),transparent:!0,depthWrite:!1,depthTest:!1}));return r.renderOrder=20,r}var sh=class{group=new et;key="";constructor(){this.group.visible=!1,this.group.renderOrder=15}update(e,t,n){let r=e?`${e.centre},${e.radius.toFixed(1)},${e.north},${e.latitude.toFixed(2)},${e.longitude.toFixed(2)},${new Date().toDateString()},${n},${t?`${t.elevation.toFixed(0)},${t.azimuth.toFixed(0)}`:"-"}`:"off";if(r===this.key)return;if(this.key=r,this.clear(),!e){this.group.visible=!1;return}this.group.visible=!0;let s=n+.05,o=[];for(let h=0;h<=96;h++){let f=h/96*Math.PI*2;o.push(e.centre[0]+Math.cos(f)*e.radius,s,e.centre[1]+Math.sin(f)*e.radius)}let a=new Pe;a.setAttribute("position",new Le(o,3)),this.group.add(new In(a,new Lt({color:7311304,transparent:!0,opacity:.55,depthWrite:!1})));let l=[];[["N",0],["E",90],["S",180],["W",270]].forEach(([h,f])=>{let[d,p]=Do(f,e.north);l.push(e.centre[0]+d*e.radius*.94,s,e.centre[1]+p*e.radius*.94,e.centre[0]+d*e.radius*1.04,s,e.centre[1]+p*e.radius*1.04);let x=eC(h,h==="N"?"#ff6b6b":"#9fb4d8");x.position.set(e.centre[0]+d*e.radius*1.12,s+.4,e.centre[1]+p*e.radius*1.12),x.scale.setScalar(Math.max(1.2,e.radius*.12)),this.group.add(x)});let c=new Pe;c.setAttribute("position",new Le(l,3)),this.group.add(new xn(c,new Lt({color:10466520,transparent:!0,opacity:.8,depthWrite:!1})));let u=QR(e).map(([h,f,d])=>[h,n+f,d]);if(u.length>1){let h=new Pe;h.setAttribute("position",new Le(u.flat(),3)),this.group.add(new In(h,new Lt({color:16761415,transparent:!0,opacity:.85,depthWrite:!1})))}if(t&&t.elevation>0){let[h,f,d]=nv(e,t),p=new Se(new ir(Math.max(.35,e.radius*.035),12,8),new Ye({color:16765530}));p.position.set(h,n+f,d),this.group.add(p)}}clear(){for(let e of[...this.group.children]){this.group.remove(e);let t=e;t.geometry?.dispose();let n=t.material;n?.map?.dispose(),n?.dispose()}}dispose(){this.clear()}};var tC=["straight","quarter","l","half","u","spiral"],nC=["solid","stringer","mono","cantilever"],iC=["none","left","right","both"],rC=["headroom","full","none"],oh={shape:"straight",turn:"right",build:"solid",risers:!0,steps:null,run_width:null,down:!1,rail:"none",opening:"headroom",landing_after:null};var av=2,lv=40,sC=2.2,ah=(i,e)=>typeof e=="string"&&i.includes(e);function Op(i){let e=i.stair??{},t=typeof e.steps=="number"&&Number.isFinite(e.steps)?Math.round(Math.min(lv,Math.max(av,e.steps))):null,n=typeof e.run_width=="number"&&Number.isFinite(e.run_width)&&e.run_width>.2?e.run_width:null;return{shape:ah(tC,e.shape)?e.shape:oh.shape,turn:e.turn==="left"?"left":"right",build:ah(nC,e.build)?e.build:oh.build,risers:e.risers!==!1,steps:t,run_width:n,down:e.down===!0,rail:ah(iC,e.rail)?e.rail:oh.rail,opening:ah(rC,e.opening)?e.opening:oh.opening,landing_after:typeof e.landing_after=="number"&&Number.isFinite(e.landing_after)?Math.max(1,Math.round(e.landing_after)):null}}var ch=i=>i.type==="stairs"&&!!i.stair,wl=(i,e,t)=>[i[0]+(e[0]-i[0])*t,i[1]+(e[1]-i[1])*t],iv=(i,e)=>Math.abs(i[0]-e[0])<1e-6&&Math.abs(i[1]-e[1])<1e-6;function cv(i){let e=[];for(let t of i)(!e.length||!iv(e[e.length-1],t))&&e.push(t);for(;e.length>1&&iv(e[0],e[e.length-1]);)e.pop();return e}function Tl(i,e,t=!1){return{poly:cv([...i,...[...e].reverse()]),landing:t,left:i,right:e}}function Sl(i,e,t,n,r){let s=[];for(let o=0;oe+1e-6&&ri.reduce((e,t,n)=>n?e+Math.hypot(t[0]-i[n-1][0],t[1]-i[n-1][1]):e,0);function sv(i,e,t,n,r){let s=aC(i),o=[];for(let a=0;a=8?3:2),[f,d]=i.shape==="l"?ov(i,n)??lh(n-h,t-l,e-l):lh(n-h,t-l,e-l),p=Sl([r,a],[r+l,a],[r,o+l],c,f),x=i.shape==="l"?[Tl(u,[c],!0)]:sv(u,c,c,c,h),m=Sl([r+l,o],c,[s,o],[s,o+l],d);return{treads:[...p,...x,...m],flight:l,column:0}}case"half":case"u":{let l=Math.min(i.run_width??Math.min(1.1,(e-.1)/2),(e-.02)/2),c=o+l,u=[[r,c],[r,o],[s,o],[s,c]],[h,f]=[[r+l,c],[s-l,c]],d=i.shape==="u"?1:Math.min(n,n>=12?6:n>=8?4:2),[p,x]=i.shape==="u"?ov(i,n)??lh(n-d,t-l,t-l):lh(n-d,t-l,t-l),m=Sl([r,a],[r+l,a],[r,c],h,p),g=i.shape==="u"?[Tl(u,[h,f],!0)]:sv(u,h,[0,c],f,d),y=Sl([s,c],f,[s,a],[s-l,a],x);return{treads:[...m,...g,...y],flight:l,column:0}}case"spiral":{let l=Math.min(e,t)/2,c=Math.min(.08,l*.12),u=Math.min(.75,Math.max(.3,.22/(l*.6))),h=(d,p)=>[Math.cos(p)*d,Math.sin(p)*d],f=[];for(let d=0;dh(l,p+(x-p)*g));f.push(Tl(m,[h(c,p),h(c,x)]))}return{treads:f,flight:l-c,column:c}}default:return{treads:Sl([r,a],[s,a],[r,o],[s,o],n),flight:e,column:0}}}var cC=(i,e)=>i.steps??Math.min(lv,Math.max(av,Math.round(Math.abs(e)/.18)));function Dp(i,e,t,n){let r=cC(i,n),s=Math.abs(n)/r,o=lC(i,Math.max(.3,e),Math.max(.3,t),r),a=c=>[-c[0],c[1]];return{treads:o.treads.map((c,u)=>{let h=i.down?-s*(u+1):s*(u+1);return i.turn==="right"?{...c,top:h}:{poly:c.poly.map(a).reverse(),top:h,landing:c.landing,left:c.right.map(a),right:c.left.map(a)}}),rise:s,steps:r,column:o.column,flight:o.flight}}function uv(i){let e=i.poly.reduce((t,n)=>[t[0]+n[0],t[1]+n[1]],[0,0]);return[e[0]/i.poly.length,e[1]/i.poly.length]}function uC(i,e,t,n="headroom"){if(n==="none")return[];let r=t?0:Math.abs(e),s=n==="full"?i.treads:i.treads.filter((o,a)=>o.top>r-sC||!t&&a===i.treads.length-1||t&&a===0);return mr(s.map(o=>o.poly).filter(o=>o.length>=3))}function Up(i){let e=Op(i),t=uC(Dp(e,i.w,i.d,i.h),i.h,e.down,e.opening),n=i.rotation*Math.PI/180,[r,s]=[Math.cos(n),Math.sin(n)],o=i.mirror?-1:1;return t.map(a=>a.map(([l,c])=>[i.x+o*l*r-c*s,i.z+o*l*s+c*r]))}function Ui(i,e,t,n,r,s,o=Fe.metal,a=!1){let[l,c]=[e/2-s-r,t/2-s-r],u=He(o);for(let h of[-1,1])for(let f of[-1,1]){let[d,p]=[h*l,f*c];a?i.loft([d-r*.3,d+r*.3,p-r*.3,p+r*.3],[d-r/2,d+r/2,p-r/2,p+r/2],0,n,u):i.block({x:[d-r/2,d+r/2],y:[0,n],z:[p-r/2,p+r/2]},u)}}function Is(i,e,t,n,r,s,o,a=null,l=!1){let c=(t-e)/o;for(let u=1;u1?h+(u%2?-c/2+.06:c/2-.06):h+c/2-.06;i.seg(d,f-.08,s+.012,d,f+.08,s+.012,Ze)}}}function di(i,e,t,n,r,s=null,o=!1,a=q.body){i.block({x:[-e/2,e/2],y:[.02,n],z:[-t/2,t/2-.02]},a,ue),i.block({x:[-e/2+.02,e/2-.02],y:[0,.08],z:[-t/2+.02,t/2-.06]},He(Fe.dark)),Is(i,-e/2,e/2,.08,n,t/2-.02,r,s,o)}function kp(i,e,t,n,r){let[s,o,a,l]=[-e/2,e/2,-t/2,t/2],c=Math.min(.2,e*.12),u=n*.5,h=Math.min(.24,t*.28);Ui(i,e,t,.07,.05,.05,Fe.wood,!0),i.pad({x:[s,o],y:[.07,u-.08],z:[a+.02,l]},q.fabric,.04,ue),i.loft([s,o,a,a+h],[s+.01,o-.01,a,a+h*.5],u-.08,n,q.fabric,ue);for(let[d,p]of[[s,s+c],[o-c,o]])i.pad({x:[d,p],y:[u-.08,n*.72],z:[a+.02,l-.02]},q.fabric,.04,ue);let f=(o-c-(s+c))/r;for(let d=0;d1.2?2:1,f=(e-.2)/h;for(let d=0;d0?.05:0),o*(e/2)+(o<0?.05:0)],y:[0,n],z:[a*(t/2)-(a>0?.05:0),a*(t/2)+(a<0?.05:0)]},q.wood);for(let o of[.25,n-.55])i.block({x:[-e/2,e/2],y:[o,o+.08],z:[-t/2,t/2]},q.wood,ue),i.block({x:[-e/2+.04,e/2-.04],y:[o+.08,o+.24],z:[-t/2+.05,t/2-.05]},q.bedding,Te),i.block({x:[-e/2+.05,e/2-.05],y:[o+.24,o+.33],z:[-t/2+.08,-t/2+.4]},q.pillow);i.block({x:[-e/2,e/2],y:[n-.2,n-.15],z:[t/2-.05,t/2]},q.wood);let s=e/2-.35;for(let o of[s-.18,s+.18])i.seg(o,0,t/2+.02,o,n-.15,t/2+.02,ue);for(let o=.3;oi.block({x:[-e/2,e/2],y:[n-.04,n],z:[-t/2,t/2]},q.worktop,ue);function yv(i,e,t,n){di(i,e,t-.02,n-.04,Math.max(1,Math.round(e/.6)),n-.2),Vp(i,e,t,n)}function bv(i,e,t,n){i.block({x:[-e/2,e/2],y:[Math.max(0,n-.04),n],z:[-t/2,t/2]},q.worktop,ue)}function vv(i,e,t,n){i.block({x:[-e/2,e/2],y:[0,n],z:[-t/2,t/2]},q.white,ue);let r=n*.62;i.seg(-e/2,r,t/2,e/2,r,t/2,Te);let s=e/2-.06;i.seg(s,r+.08,t/2+.015,s,r+.4,t/2+.015,Ze),i.seg(s,r-.4,t/2+.015,s,r-.08,t/2+.015,Ze)}var Gp=.06;function _v(i,e,t,n){let r=t/2-Gp;i.block({x:[-e/2,e/2],y:[.02,n],z:[-t/2,r]},q.body,ue),i.block({x:[-e/2+.05,e/2-.05],y:[0,.02],z:[-t/2+.05,r-.05]},q.dark);for(let s of[.35,.7,1.05,1.4])s>n-.15||(i.seg(-e/2+.03,s,r+.001,-.03,s,r+.001,Te),i.seg(.03,s,r+.001,e/2-.03,s,r+.001,Te))}var zp=1.83;function hC(i,e,t,n,r){let[s,o]=[Math.cos(e.rotation*mt),Math.sin(e.rotation*mt)],a=e.mirror?-1:1,l=(y,_)=>[e.x+a*y*s-_*o,e.z+a*y*o+_*s],[c,u]=[t+.05,t+e.h-.02],h=new W(.75,.1,.14),f=new W(Fe.dark),d=new W(Fe.accent),p=e.w/2-.006,x=(y,_,b)=>{let M=b/zp,S=new W(2043212).lerp(h,M),v=new W(Fe.body).lerp(h,M*.8),[w,P]=[Math.cos(b),Math.sin(b)],T=(k,C)=>l(y+_*(k*w-C*P),e.d/2+k*P+C*w),R=(k,C,I,O)=>{let[F,H,U,X]=k;i.tri([F[0],C,F[1]],[H[0],C,H[1]],[U[0],I,U[1]],O),i.tri([F[0],C,F[1]],[U[0],I,U[1]],[X[0],I,X[1]],O)},L=(k,C,I,O,F,H,U,X=U)=>{let V=[T(k,H),T(C,H),T(C,F),T(k,F)];R([V[0],V[1],V[1],V[0]],I,O,X),R([V[3],V[2],V[2],V[3]],I,O,U),R([V[0],V[3],V[3],V[0]],I,O,U),R([V[1],V[2],V[2],V[1]],I,O,U),R([V[0],V[1],V[2],V[3]],O,O,U),R([V[3],V[2],V[1],V[0]],I,I,U)};return L(0,p,c,u,-Gp,0,v,S),L(p-.05,p-.03,t+e.h*.45,t+e.h*.75,.005,.025,d),L};x(-e.w/2,1,n*zp)(.12,.3,t+e.h*.5,t+e.h*.68,.001,.005,f),x(e.w/2,-1,r*zp)(.06,p-.06,t+e.h*.52,t+e.h*.86,.001,.005,f)}function Hp(i,e,t,n,r){let s=i.p.length;hC(i,e,t,n,r),e.mirror&&Ss(i,s)}function Mv(i,e,t,n){di(i,e,t-.02,n-.04,1,n-.24,!0),i.block({x:[-e/2,e/2],y:[n-.04,n],z:[-t/2,t/2]},q.dark,ue);let r=[[-.14,-.13,.09],[.14,-.13,.07],[-.14,.13,.07],[.14,.13,.09]];for(let[s,o,a]of r)i.cylinder(s*e/.6,o*t/.62,a,n,n+.004,He(Fe.dark,1451583),12,Ze)}function Sv(i,e,t,n){di(i,e,t-.02,n-.04,Math.max(1,Math.round(e/.45)),n-.2);let r=Math.min(.5,e-.2),s=(o,a,l,c,u=!1)=>i.block({x:[o,a],y:[n-.04,n],z:[l,c]},q.worktop,u?ue:null);s(-e/2,-r/2,-t/2,t/2,!0),s(r/2,e/2,-t/2,t/2,!0),s(-r/2,r/2,-t/2,-t/2+.1),s(-r/2,r/2,t/2-.08,t/2),i.block({x:[-r/2,r/2],y:[n-.2,n-.17],z:[-t/2+.1,t/2-.08]},q.metal,Ze),i.cylinder(0,-t/2+.05,.02,n,n+.28,q.metal,8),i.block({x:[-.015,.015],y:[n+.24,n+.28],z:[-t/2+.05,-t/2+.22]},q.metal)}function wv(i,e,t,n){i.block({x:[-e/2,e/2],y:[1.45,1.45+n],z:[-t/2,t/2-.02]},q.body,ue),Is(i,-e/2,e/2,1.45,1.45+n,t/2-.02,Math.max(1,Math.round(e/.5)),1.45+.08)}function Tv(i,e,t,n){i.block({x:[-e/2,e/2],y:[.02,n],z:[-t/2,t/2-.02]},q.body,ue),i.block({x:[-e/2+.02,e/2-.02],y:[0,.08],z:[-t/2+.02,t/2-.06]},q.dark);let r=t/2-.02;i.block({x:[-e/2+.03,e/2-.03],y:[.85,1.45],z:[r,r+.01]},q.dark,Ze),i.seg(-e/2+.08,1.4,r+.02,e/2-.08,1.4,r+.02,Ze);for(let s of[.85,1.45])i.seg(-e/2,s,r,e/2,s,r,Te);i.seg(e/2-.06,.5,r+.012,e/2-.06,.7,r+.012,Ze),i.seg(e/2-.06,1.6,r+.012,e/2-.06,1.8,r+.012,Ze)}function Av(i,e,t,n){let r=t-.3;i.block({x:[-e/2+.05,e/2-.05],y:[.08,n-.04],z:[-t/2+.02,-t/2+r]},q.body,ue),i.block({x:[-e/2+.07,e/2-.07],y:[0,.08],z:[-t/2+.04,-t/2+r-.04]},q.dark),Is(i,-e/2+.05,e/2-.05,.08,n-.04,-t/2+r,Math.max(2,Math.round(e/.6)),n-.2),Vp(i,e,t,n)}function Ev(i,e,t,n){i.block({x:[-e/2,e/2],y:[.02,n-.04],z:[-t/2,t/2-.02]},q.body,ue),i.block({x:[-e/2+.02,e/2-.02],y:[0,.08],z:[-t/2+.02,t/2-.06]},q.dark),i.seg(-e/2+.08,n-.12,t/2-.008,e/2-.08,n-.12,t/2-.008,Ze),Vp(i,e,t,n)}function Wp(i,e,t,n,r){i.block({x:[-e/2,e/2],y:[0,n],z:[-t/2,t/2-.02]},q.white,ue);let s=t/2-.012;i.seg(-e/2,n-.14,s,e/2,n-.14,s,Te),i.seg(e/2-.16,n-.07,s,e/2-.08,n-.07,s,Ze);let o=(n-.14)/2+.04,a=Math.min(e*.36,(n-.2)*.42),l=20;for(let c=0;ci.seg(Math.cos(u)*a*d,o+Math.sin(u)*a*d,s,Math.cos(h)*a*d,o+Math.sin(h)*a*d,s,p);f(1,Ze),r||f(.72,Te)}}function Rv(i,e,t,n){i.block({x:[-e/2,e/2],y:[0,n-.02],z:[-t/2,t/2]},q.white,ue);let s=(o,a,l,c)=>i.block({x:[o,a],y:[n-.02,n],z:[l,c]},q.worktop);s(-e/2,e/2,-t/2,-t/2+.07),s(-e/2,e/2,t/2-.07,t/2),s(-e/2,-e/2+.07,-t/2+.07,t/2-.07),s(e/2-.07,e/2,-t/2+.07,t/2-.07),i.block({x:[-e/2+.07,e/2-.07],y:[n-.03,n-.02],z:[-t/2+.07,t/2-.07]},q.glass,Ze),i.cylinder(-e/2+.04,0,.02,n,n+.12,q.metal,8)}function Cv(i,e,t,n){i.block({x:[-e/2,e/2],y:[0,.05],z:[-t/2,t/2]},q.worktop,ue),i.cylinder(0,0,.04,.05,.052,q.metal,8);for(let[r,s,o,a]of[[-e/2,t/2,e/2,t/2],[e/2,-t/2,e/2,t/2]])i.seg(r,.05,s,o,.05,a,Ze),i.seg(r,n,s,o,n,a,Ze),i.seg(o,.05,a,o,n,a,Ze);i.cylinder(-e/2+.06,-t/2+.06,.015,.05,n-.05,q.metal,6),i.cylinder(-e/2+.2,-t/2+.2,.1,n-.08,n-.06,q.metal,12,Ze)}function Pv(i,e,t,n){let r=Math.min(.18,t*.3);i.block({x:[-e/2,e/2],y:[.45,n],z:[-t/2,-t/2+r]},q.white,ue),i.block({x:[-e*.3,e*.3],y:[0,.36],z:[-t/2+r-.02,t/2-.12]},q.white),i.cylinder(0,t/2-.26,Math.min(e/2,.19),.36,.41,q.white,12,ue),i.block({x:[-e/2+.02,e/2-.02],y:[.41,.43],z:[-t/2+r,-t/2+r+.05]},q.worktop)}function Iv(i,e,t,n){di(i,e,t-.02,n-.12,e>.8?2:1,n-.3),i.block({x:[-e/2,e/2],y:[n-.12,n],z:[-t/2,t/2]},q.white,ue),i.block({x:[-e/2+.07,e/2-.07],y:[n-.005,n],z:[-t/2+.12,t/2-.06]},q.glass,Ze),i.cylinder(0,-t/2+.06,.018,n,n+.2,q.metal,8),i.block({x:[-e/2+.04,e/2-.04],y:[n+.35,n+1],z:[-t/2,-t/2+.02]},q.glass,Ze)}var Al=.12;function Lv(i,e,t,n){let r=Al;i.block({x:[-e/2+.05,-e/2+.08],y:[0,r],z:[-t/2,-t/2+.03]},q.metal),i.block({x:[e/2-.08,e/2-.05],y:[0,r],z:[-t/2,-t/2+.03]},q.metal),i.block({x:[-e/2,e/2],y:[r,r+n],z:[-t/2+.02,t/2]},q.white,ue);let s=Math.max(3,Math.round(e/.1));for(let o=1;oi.block({x:[-e/2,e/2],y:[1.1,1.1+n],z:[-t/2,t/2]},l,ue);if(r==="slim"){a(q.darkBody),i.seg(-e*.25,1.1+n*.15,o+.004,-e*.25,1.1+n*.85,o+.004,Ze),i.block({x:[-e*.1,e*.3],y:[1.1+n*.7,1.1+n*.85],z:[o,o+.005]},q.dark);return}if(a(q.white),r==="hybrid"){i.ring(0,1.1+n*.66,Math.min(e,n)*.22,o+.004,20,Ze),i.seg(-e*.08,1.1+n*.66,o+.005,e*.08,1.1+n*.66,o+.005,Ze);for(let l of[-1,1])i.ring(l*e*.22,1.1+n*.2,Math.min(e,n)*.1,-t/2-.002,12,Ze);return}i.block({x:[-e*.28,e*.28],y:[1.1+n*.58,1.1+n*.82],z:[t/2,t/2+.006]},q.dark),i.seg(-e*.3,1.1+n*.45,t/2+.004,e*.3,1.1+n*.45,t/2+.004,Ze);for(let l of[-1,1])for(let c=1;c<6;c++)i.seg(l*e/2+l*.002,1.1+n*c/6,-t/2+.03,l*e/2+l*.002,1.1+n*c/6,t/2-.03,Te)}function $v(i,e,t,n){i.block({x:[-e/2,e/2],y:[0,n],z:[-t/2,t/2]},q.darkBody,ue),i.block({x:[-e/2-.01,e/2+.01],y:[n,n+.03],z:[-t/2-.01,t/2+.01]},q.darkBody),i.seg(-e/2,n+.032,t/2+.01,e/2,n+.032,t/2+.01,Ze),i.seg(-e*.3,n*.55,t/2+.003,e*.3,n*.55,t/2+.003,Te)}function Kv(i,e,t,n){i.block({x:[-e/2,e/2],y:[1,1+n],z:[-t/2,t/2]},q.darkBody,ue),i.ring(0,1+n*.58,Math.min(e,n)*.28,t/2+.003,16,Ze),i.block({x:[-.015,.015],y:[1-.35,1],z:[t/2-.03,t/2]},q.dark),i.block({x:[-.06,.06],y:[1-.42,1-.35],z:[t/2-.05,t/2]},q.darkBody)}function Zv(i,e,t,n){i.block({x:[-e/2,e/2],y:[.4,.4+n],z:[-t/2,t/2]},q.white,ue),i.seg(-e/2+.025,.4+.025,t/2+.003,-e/2+.025,.4+n-.025,t/2+.003,Te),i.seg(-e/2+.025,.4+n-.025,t/2+.003,e/2-.025,.4+n-.025,t/2+.003,Te),i.block({x:[e/2-.06,e/2-.035],y:[.4+n*.5-.05,.4+n*.5+.05],z:[t/2,t/2+.012]},q.dark),i.block({x:[-e*.3,e*.3],y:[.4+n*.6,.4+n*.8],z:[t/2,t/2+.005]},q.dark),i.seg(-e*.22,.4+n*.7,t/2+.008,e*.22,.4+n*.7,t/2+.008,Ze)}function Jv(i,e,t,n,r){if(r==="wall"){i.block({x:[-e/2,e/2],y:[.5,.5+n],z:[-t/2,t/2]},q.white,ue),i.seg(-e*.3,.5+n*.9,t/2+.004,e*.3,.5+n*.9,t/2+.004,Ze),i.seg(-e*.3,.5+n*.08,t/2+.003,e*.3,.5+n*.08,t/2+.003,Te);return}if(r==="cube"){i.block({x:[-e/2+.01,e/2-.01],y:[0,.03],z:[-t/2+.01,t/2-.01]},q.dark),i.block({x:[-e/2,e/2],y:[.03,n],z:[-t/2,t/2]},q.darkBody,ue),i.seg(-e*.35,n*.85,t/2+.004,e*.35,n*.85,t/2+.004,Ze),i.block({x:[-e*.15,e*.15],y:[n,n+.025],z:[-.012,.012]},q.dark);return}i.block({x:[-e/2+.02,e/2-.02],y:[0,.06],z:[-t/2+.02,t/2-.02]},q.dark);let s=Math.max(2,Math.round((n-.06)/.3)),o=(n-.06)/s;for(let a=0;a[x[0]+h*m,x[1]+f*m];i.prism([e,t,p(t,o),p(e,o)],r,s,a,Te)}var fC=i=>i.slice(1).map((e,t)=>[i[t],e]).filter(([e,t])=>Math.hypot(t[0]-e[0],t[1]-e[1])>.01);function dC(i,e,t,n,r){let s=e.build==="cantilever"?.07:.05;t.forEach((o,a)=>{let l=uv(o),c=a===0?0:t[a-1].top;if(e.build==="solid"){i.prism(o.poly,Math.min(r,o.top),o.top,q.body,ue);return}if(i.prism(o.poly,o.top-s,o.top,q.wood,ue),e.risers&&!o.landing){let[u,h]=[Math.min(c,o.top),Math.max(c,o.top)-s];jv(i,o.left[0],o.right[0],l,u,h,.02)}if(e.build==="stringer")for(let u of[o.left,o.right])for(let[h,f]of fC(u))jv(i,h,f,l,o.top-n-.2,o.top+.05,.04);else e.build==="mono"&&i.block({x:[l[0]-.07,l[0]+.07],y:[o.top-n-.12,o.top-s],z:[l[1]-.07,l[1]+.07]},q.metal)})}function pC(i,e,t){let n=e.rail==="both"?["left","right"]:e.rail==="none"?[]:[e.rail];for(let r of n){let s=[];for(let o of t)for(let a of o[r])s.push([a[0],o.top+uh,a[1]]);for(let[o,a]of t.entries()){if(o%2&&o!==t.length-1)continue;let l=a[r][0];i.cylinder(l[0],l[1],.012,a.top,a.top+uh,q.metal,6)}for(let o=1;o0&&i.cylinder(0,0,o.column,Math.min(0,a),s.down?0:r,q.metal,12,ue),dC(i,s,o.treads,o.rise,a),pC(i,s,o.treads)}var mC=(i,e="Station 1")=>({id:i,name:e,has_valve:!0}),hh=i=>i.has_valve!==!1;function fh(i){let e=i.hydronic??{};return e.stations?.length?e.stations.slice(0,16):[{...mC("station-1"),flow:e.flow,return:e.return,hot_water:e.hot_water,cold_water:e.cold_water,pump:e.pump}]}var gC=(i,e="Heizkreis")=>({id:i,name:e,kind:"heating",has_pump:!0,has_valve:!0});function xC(i){return{card:!0,...i==="heating_manifold"?{circuits:[gC("c1","Heizkreis 1")]}:{},...i==="buffer_tank"?{sensors:Array.from({length:7},(e,t)=>({id:`s${t+1}`,name:`F\xFChler ${t+1}`,entity:null,level:1-t/6}))}:{}}}function El(i){return{...xC(i.type),...i.hydronic}}var Rl=i=>i.has_pump!==!1,Ls=i=>i.kind!=="pump"&&i.has_valve!==!1,e_=(i,e)=>-.4+.8*(i+.5)/Math.max(1,e),Xp=i=>!!i&&i!=="none";function dh(i,e,t,n){let r=Math.min(i.w*.8/Math.max(1,n),i.h*.5),s=i.w*e_(t,n),o=s-r*.22,a=s+r*.22,l=i.d*.16,c=-i.d*.14,u=i.h*.15,h=i.h*.07,f=i.h*.24,d=i.h*.34,p=i.h*.55,x=i.h*.73,m=i.h*.87,g=Math.min(r*.04,i.h*.018,i.d*.08),y=Math.min(r*.13,i.h*.055,i.d*.28),_=Math.min(r*.09,i.h*.04,i.d*.18),b=Math.min(r*.06,i.h*.025,i.d*.14),M=l+Math.min(i.d*.28,y*.8),S=l+Math.min(i.d*.24,_*.9),v=l+g+b*.65,w=o-r*.13,P=a+r*.13,T=Ls(e)&&e.valve_type!=="two_way",R=Math.min(r*.23,i.h*.115),L=l+Math.min(i.d*.22,R*.4),k=e.kind==="pump"?i.h*.93:m,C=[{from:[o,u,c],to:[o,f,c],kind:"flow"},{from:[o,f,c],to:[o,f,l],kind:"flow"},{from:[o,f,l],to:[o,k,l],kind:"flow"},{from:[a,h,l],to:[a,k,l],kind:"return"}];return T&&C.push({from:[o,d,l],to:[a,d,l],kind:"mix"}),e.kind!=="pump"&&(C.push({from:[o,m,l],to:[s-R,m,l],kind:"flow"}),C.push({from:[s+R,m,l],to:[a,m,l],kind:"return"})),{x:s,column:r,flowX:o,returnX:a,frontZ:l,backZ:c,flowHeaderY:u,returnHeaderY:h,valveY:d,pumpY:p,temperatureY:x,loadY:m,loadR:R,loadFront:L,pipeR:g,pumpR:y,valveR:_,gaugeR:b,pumpFront:M,valveFront:S,gaugeFront:v,flowGaugeX:w,returnGaugeX:P,mixing:T,topY:k,pipes:C}}function Uo(i){let{w:e,d:t,h:n}=i,r=fh(i),s=Math.min(e*.2,n*.25),o=(e-s)/r.length,a=t*.24,l=-t*.03,c=-t*.25,u={flow:n*.98,back:n*.9,hot:n*.82,cold:n*.06},h=Math.min(n*.012,t*.065,o*.04),f=Math.min(n*.009,t*.045,o*.025),d=[{from:[-e*.49,u.flow,l],to:[e*.49,u.flow,l],medium:"primary_flow"},{from:[-e*.49,u.back,c],to:[e*.49,u.back,c],medium:"primary_return"},{from:[-e*.49,u.hot,a],to:[e*.49,u.hot,a],medium:"hot_water"},{from:[-e*.49,u.cold,a],to:[e*.49,u.cold,a],medium:"cold_water"}],p=(M,S,v)=>({x:M,y:S,z:a,front:a+Math.min(t*.22,v*.85),r:v}),x=r.map((M,S)=>{let v=-e/2+s+o*(S+.5),w=v-o*.33,P=v+o*.4,T=v+o*.23,R=o*.18,L=[],k=(H,U)=>{for(let X=1;X1e-6?i.lyingCylinder("x",(s+l)/2,a,o-n,o+n,Math.abs(l-s),n*2,r,12,Te):Math.abs(u-a)>1e-6?i.lyingCylinder("z",s,(a+u)/2,o-n,o+n,Math.abs(u-a),n*2,r,12,Te):i.cylinder(s,a,n,Math.min(o,c),Math.max(o,c),r,12,Te)}function Cl(i,e,t,n,r,s,o=ph){i.lyingCylinder("z",e,(r+s)/2,t-n,t+n,s-r,n*2,o,24,Te)}var Pl={primary_flow:He(11088437,14109762),primary_return:He(2383516,5019861),hot_water:He(11957285,15639884),cold_water:He(3242318,7192440),circulation:He(7950748,11895505)},yC=He(9597515,13215082),bC=He(8293780,11582912),gh=new W(10859712);function t_(i,e){let t=Uo(e);for(let n of t.headers)mh(i,n.from,n.to,t.headerR,Pl[n.medium]);for(let n of t.circulationPipes)mh(i,n.from,n.to,t.pipeR,Pl[n.medium]);if(t.circulationPipes.length){let n=t.circPump;Cl(i,n.x,n.y,n.r,n.z-t.pipeR,n.front,q.darkBody);let r=t.circProbe;Cl(i,r.x,r.y,r.r,r.z,r.front,ph)}t.units.forEach((n,r)=>{let s=n.pitch*.45;i.block({x:[n.x-s,n.x+s],y:[e.h*.18,e.h*.76],z:[-e.d*.46,-e.d*.34]},q.darkBody,Te);for(let d of n.pipes)mh(i,d.from,d.to,t.pipeR,Pl[d.medium]);i.block({x:[n.plate.x0,n.plate.x1],y:[n.plate.y0,n.plate.y1],z:[n.plate.back,n.plate.front]},bC,Te);for(let d=1;d<7;d++){let p=n.plate.x0+(n.plate.x1-n.plate.x0)*d/7;i.seg(p,n.plate.y0+e.h*.015,n.plate.front+.001,p+n.pitch*.045,n.plate.y1-e.h*.015,n.plate.front+.001,Te)}for(let[d,p]of[[n.plate.x0,Pl.primary_flow],[n.plate.x1,Pl.hot_water]])i.block({x:[d-n.pitch*.016,d+n.pitch*.016],y:[n.plate.y0,n.plate.y1],z:[n.plate.front,n.plate.front+e.d*.015]},p);for(let d of[n.pump,...n.valve?[n.valve]:[]])Cl(i,d.x,d.y,d.r,d.z-t.pipeR,d.front,d===n.valve?yC:q.darkBody);for(let d of n.probes)Cl(i,d.x,d.y,d.r,d.z,d.front,ph);let o=Math.min(n.pitch*.055,e.h*.022),a=n.x-s+o*.6,l=e.h*.72,c=e.d*.31;i.seg(a,l-o,c,a,l+o,c,gh),i.seg(a,l,c,a+o,l+o,c,gh),i.seg(a,l,c,a+o,l-o,c,gh);let u=String(r+1),h=["abcdef","bc","abdeg","abcdg","bcfg","acdfg","acdefg","abc","abcdefg","abcdfg"],f={a:[0,1,1,1],b:[1,1,1,0],c:[1,0,1,-1],d:[0,-1,1,-1],e:[0,0,0,-1],f:[0,1,0,0],g:[0,0,1,0]};for(let d=0;d.5?yh:Yp,12,Te)}for(let a of s.sensors??[]){let l=r*(.1+.8*a.level);i.lyingCylinder("z",0,o,l-.018,l+.018,.035,.036,bh,10,Te),i.ring(0,l,.025,o+.022,12,Te)}for(let a of[-1,1])for(let l of[-1,1])i.cylinder(a*o*.52,l*o*.52,.025,0,r*.05,q.metal);return}if(i.block({x:[-t*.49,t*.49],y:[r*.02,r*.98],z:[-n*.48,-n*.35]},q.darkBody,ue),e.type==="heating_manifold"){let o=s.circuits??[],a=Math.min(r*.025,n*.12);for(let[u,h,f]of[[r*.15,-n*.14,yh],[r*.07,n*.16,Yp]])i.lyingCylinder("x",0,h,u-a,u+a,t*.94,a*2,f,16,Te);let l=(u,h,f,d=yh)=>{let[p,x,m]=u,[g,y,_]=h;Math.abs(g-p)>1e-6?i.lyingCylinder("x",(p+g)/2,m,x-f,x+f,Math.abs(g-p),f*2,d,12,Te):Math.abs(_-m)>1e-6?i.lyingCylinder("z",p,(m+_)/2,x-f,x+f,Math.abs(_-m),f*2,d,12,Te):i.cylinder(p,m,f,Math.min(x,y),Math.max(x,y),d,12,Te)},c=(u,h,f,d,p,x=qp)=>i.lyingCylinder("z",u,(d+p)/2,h-f,h+f,p-d,f*2,x,24,Te);o.forEach((u,h)=>{let f=dh(e,u,h,o.length);for(let d of f.pipes)l(d.from,d.to,f.pipeR,d.kind==="flow"?yh:Yp);if(u.kind!=="pump"){c(f.x,f.loadY,f.loadR,f.frontZ,f.loadFront,vC),i.ring(f.x,f.loadY,f.loadR*.55,f.loadFront+.001,24,Te);let d=f.loadR*.45;for(let p=0;p<4;p++)i.seg(f.x-d+p*d/2,f.loadY-d*.3,f.loadFront+.002,f.x-d+(p+.5)*d/2,f.loadY+d*.3,f.loadFront+.002,ue)}if(Rl(u)){c(f.flowX,f.pumpY,f.pumpR,f.frontZ-f.pipeR,f.pumpFront,q.darkBody);for(let d of[-1,1])i.cylinder(f.flowX,f.frontZ,f.pipeR*1.65,f.pumpY+d*f.pumpR-f.pipeR*.5,f.pumpY+d*f.pumpR+f.pipeR*.5,qp,12,Te)}if(Ls(u)){c(f.flowX,f.valveY,f.valveR,f.frontZ-f.pipeR,f.valveFront,bh);for(let d of[-1,1])i.cylinder(f.flowX,f.frontZ,f.pipeR*1.5,f.valveY+d*f.valveR-f.pipeR*.4,f.valveY+d*f.valveR+f.pipeR*.4,bh,12,Te);f.mixing&&l([f.flowX+f.valveR*.6,f.valveY,f.frontZ],[f.flowX+f.valveR*1.3,f.valveY,f.frontZ],f.pipeR*1.5,bh),i.block({x:[f.flowX-f.valveR*.65,f.flowX+f.valveR*.65],y:[f.valveY-f.valveR*.65,f.valveY+f.valveR*.65],z:[f.frontZ,f.frontZ+(f.valveFront-f.frontZ)*.9]},q.darkBody,Te)}for(let[d,p]of[[f.flowX,f.flowGaugeX],[f.returnX,f.returnGaugeX]])l([d,f.temperatureY,f.frontZ],[p,f.temperatureY,f.frontZ],f.pipeR*.5,qp),c(p,f.temperatureY,f.gaugeR,f.frontZ,f.gaugeFront,_C),i.ring(p,f.temperatureY,f.gaugeR*.8,f.gaugeFront+.001,16,Te)})}}function MC(i,e,t,n,r,s){switch(e.type){case"heating_manifold":case"buffer_tank":case"freshwater_station":return n_(i,e,t,n,r),"yes";case"sofa":return e.variant==="l"||e.variant==="u"?hv(i,t,n,r,e.variant):kp(i,t,n,r,Math.max(1,Math.round((t-.4)/.62))),"yes";case"armchair":return kp(i,t,n,r,1),"yes";case"bed":return fv(i,t,n,r),"yes";case"chair":return dv(i,t,n,r),"yes";case"table":return Fv(i,t,n,r),"yes";case"desk":return Dv(i,t,n,r),"yes";case"nightstand":return Uv(i,t,n,r),"yes";case"wardrobe":return di(i,t,n,r,Math.max(2,Math.round(t/.5)),r*.5),"yes";case"tall_cabinet":return di(i,t,n,r,1,r*.5),"yes";case"shelf":return kv(i,t,n,r),"yes";case"kitchen":return yv(i,t,n,r),"yes";case"fridge":return vv(i,t,n,r),"yes";case"fridge_smart":return _v(i,t,n,r),"yes";case"stove":return Mv(i,t,n,r),"yes";case"sink":return Sv(i,t,n,r),"yes";case"bathtub":return Rv(i,t,n,r),"yes";case"shower":return Cv(i,t,n,r),"yes";case"wc":return Pv(i,t,n,r),"yes";case"washbasin":return Iv(i,t,n,r),"yes";case"tv_board":return Xv(i,t,n,r,e.ambilight===0?ue:void 0),"yes";case"plant":return Gv(i,t,n,r),"yes";case"rug":return Hv(i,t,n),"no";case"stairs":return e.stair?(Qv(i,e,t,n,r),e.stair.down?"no":"yes"):(Wv(i,t,n,r),"yes");case"stairwell":return"no";case"sideboard":return Bv(i,t,n,r),"yes";case"dresser":return zv(i,t,n,r),"yes";case"coat_rack":return Vv(i,t,n,r),"yes";case"bench":return Bp(i,t,n,r,!1),"yes";case"corner_bench":return Bp(i,t,n,r,!0),"yes";case"bar_stool":return pv(i,t,n,r),"yes";case"office_chair":return mv(i,t,n,r),"yes";case"stool":return gv(i,t,n,r),"yes";case"kitchen_wall":return wv(i,t,n,r),"no";case"kitchen_tall":return Tv(i,t,n,r),"yes";case"island":return Av(i,t,n,r),"yes";case"worktop":return bv(i,t,n,r),"no";case"dishwasher":return Ev(i,t,n,r),"yes";case"washer":return Wp(i,t,n,r,!1),"yes";case"dryer":return Wp(i,t,n,r,!0),"yes";case"bunk_bed":return xv(i,t,n,r),"yes";case"table_round":return Nv(i,t,n,r),"yes";case"coffee_table":return Ov(i,t,n,r),"yes";case"tv_wall":return Yv(i,t,n,r,e.ambilight===0?ue:void 0),"no";case"parking":{let a=[[-t/2,-n/2],[t/2,-n/2],[t/2,n/2],[-t/2,n/2]];return a.forEach(([l,c],u)=>i.seg(l,.012,c,a[(u+1)%4][0],.012,a[(u+1)%4][1],Te)),i.seg(-t*.15,.012,n/2-.45,0,.012,n/2-.2,ue),i.seg(0,.012,n/2-.2,t*.15,.012,n/2-.45,ue),"no"}case"robot_vacuum":return i.block({x:[-t*.45,t*.45],y:[0,r],z:[-n/2,-n/2+n*.3]},q.white,ue),i.block({x:[-t*.2,t*.2],y:[r*.5,r*.62],z:[-n/2+n*.3,-n/2+n*.31]},q.accent),"no";case"radiator":return Lv(i,t,n,r),"no";case"inverter":return qv(i,t,n,r,e.variant??null),"no";case"grid_point":return $v(i,t,n,r),"yes";case"wallbox":return Kv(i,t,n,r),"no";case"meter":return Zv(i,t,n,r),"no";case"home_battery":return Jv(i,t,n,r,e.variant??null),e.variant==="wall"?"no":"yes";default:{let o=_t(e.type);return o?o.pet?"no":(ws(i,o,t,n,r,s,null,null,e.variant??null),s>.05?"no":"yes"):(i.block({x:[-t/2,t/2],y:[0,r],z:[-n/2,n/2]},q.body,ue),"yes")}}}function i_(i,e,t,n,r){let s=Ts(n),o=new Ni(i,e,s),[a,l,c]=[Math.max(.05,n.w),Math.max(.05,n.d),Math.max(.005,n.h)];MC(o,n,a,l,c,r)==="yes"&&By(t,s,a,l,n.type==="plant"?.35:.5)}function r_(i,e,t){let[n,r]=[Math.cos(t),Math.sin(t)],s=e[0]*i[0]+e[1]*i[1]+e[2]*i[2],o=[e[1]*i[2]-e[2]*i[1],e[2]*i[0]-e[0]*i[2],e[0]*i[1]-e[1]*i[0]];return[i[0]*n+o[0]*r+e[0]*s*(1-n),i[1]*n+o[1]*r+e[1]*s*(1-n),i[2]*n+o[2]*r+e[2]*s*(1-n)]}function SC(i,e,t,n,r){let[s,o]=[n.tilt_x??0,n.tilt_z??0];if(!s&&!o)return;let a=n.rotation*Math.PI/180,l=[Math.cos(a),0,Math.sin(a)],c=[-Math.sin(a),0,Math.cos(a)],u=(h,f)=>{for(let d=f;d+2c.screen);if(o){let c=e?Gt(e,i):0,[u,h]=[(o.x-o.w/2)*t,(o.x+o.w/2)*t],f=Math.min(.02,(h-u)*.05);return{x0:u+f,x1:h-f,y0:c+o.y*r+f,y1:c+(o.y+o.h)*r-f,z:(o.z+o.d/2)*n}}let a=e&&i.type!=="fridge_smart"?Gt(e,i)-Qr(i):0,l=TC(i,t,n,r,e);return l&&{...l,y0:l.y0+a,y1:l.y1+a}}function vh(i,e){let t=AC(i,e);return t&&i.mirror?{...t,x0:-t.x1,x1:-t.x0}:t}function $p(i,e){let[t,n,r]=[Math.max(.05,i.w),Math.max(.05,i.d),Math.max(.005,i.h)],s=_t(i.type),o=s&&ia(s,t,n,r).find(h=>h.picture);if(!o)return null;let a=e?Gt(e,i):0,[l,c]=[(o.x-o.w/2)*t,(o.x+o.w/2)*t],u={x0:l,x1:c,y0:a+o.y*r,y1:a+(o.y+o.h)*r,z:(o.z+o.d/2)*n};return i.mirror?{...u,x0:-u.x1,x1:-u.x0}:u}function Kp(i,e){if(i.type!=="home_battery")return null;let[t,n,r]=[Math.max(.05,i.w),Math.max(.05,i.d),Math.max(.05,i.h)],s=e?Gt(e,i)-Qr(i):0,o=n/2+.005;return i.variant==="wall"?{rect:{x0:-t*.3,x1:t*.3,y0:s+.5+r*.84,y1:s+.5+r*.9,z:o},vertical:!1}:i.variant==="cube"?{rect:{x0:-t*.35,x1:t*.35,y0:s+r*.8,y1:s+r*.86,z:o},vertical:!1}:{rect:{x0:-t*.05,x1:t*.05,y0:s+.06+r*.16,y1:s+r-.12,z:o},vertical:!0}}var Qn=Math.PI/180,gr=(i,e)=>[i[0]-e[0],i[1]-e[1],i[2]-e[2]];var ko=i=>Math.hypot(i[0],i[1],i[2]),Fs=i=>{let e=ko(i)||1;return[i[0]/e,i[1]/e,i[2]/e]},s_=(i,e)=>[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]];var a_=.25;function l_(i,e,t,n,r,s,o){let a=r-t>=s-n,l=a?r-t:s-n;return{key:`${i}:top`,section:e,side:"top",flat:!0,o:[t,o,n],eu:a?[1,0,0]:[0,0,1],es:a?[0,0,1]:[1,0,0],n:[0,1,0],lu:l,ls:a?s-n:r-t,pitch:0,span:()=>[0,l],facing:a?[0,1]:[1,0]}}function c_(i,e){let t=Fs(s_(i,e));return t[1]<0?[-t[0],-t[1],-t[2]]:t}var u_=i=>{let e=Fs([-i[0],0,-i[2]]);return[e[0],e[2]]};function xr(i,e,t,n,r,s,o,a){let l=Fs(gr(r,n)),c=Fs(gr(s,n));return{key:i,section:e,side:t,flat:!1,o:n,eu:l,es:c,n:c_(l,c),lu:ko(gr(r,n)),ls:ko(gr(s,n)),pitch:o,span:a,facing:u_(c)}}function o_(i,e,t,n,r,s){let o=ko(gr(r,n));if(o<.3)return null;let a=Fs(gr(r,n)),l=gr(s,n),c=l[0]*a[0]+l[1]*a[1]+l[2]*a[2],u=[l[0]-a[0]*c,l[1]-a[1]*c,l[2]-a[2]*c],h=ko(u);if(h<.3)return null;let f=Fs(u),d=p=>{let x=Math.min(1,Math.max(0,p/h));return[c*x,o-(o-c)*x]};return{key:i,section:e,side:t,flat:!1,o:n,eu:a,es:f,n:c_(a,f),lu:o,ls:h,pitch:Math.atan2(f[1],Math.hypot(f[0],f[2]))/Qn,span:d,facing:u_(f)}}function EC(i,e){let t=Un(i),n=Rn(i),r=(y,_,b)=>{let[M,S]=t.at(y,_);return[M,b,S]},[s,o]=[Math.max(0,e.a),Math.max(0,e.b)],a=t.u0-Math.max(0,e.u0),l=t.u1+Math.max(0,e.u1),c=l-a,u=n.y(-s),h=n.y(t.w+o);if(i.shape==="flat"||i.shape==="parapet"){let[y,_]=[t.at(a,-s),t.at(l,t.w+o)];return[l_(i.id,i.id,Math.min(y[0],_[0]),Math.min(y[1],_[1]),Math.max(y[0],_[0]),Math.max(y[1],_[1]),i.eave_a+a_)]}if(i.shape==="pent")return[xr(`${i.id}:a`,i.id,"a",r(a,-s,u),r(l,-s,u),r(a,t.w+o,h),i.pitch_a,()=>[0,c])];if(i.shape==="mansard")return RC(i,t,a,l,s,o);let f=i.shape==="hip"||i.shape==="pyramid",d=(t.u1-t.u0)/2,p=i.shape==="pyramid"?d:f?Math.min(d,Math.min(n.vr,t.w-n.vr)||t.w/2):0,x=f?t.u0+p-a:0,m=f?l-(t.u1-p):0,g=[];if(n.vr>.3){let y=Math.hypot(n.vr+s,n.rh-u);g.push(xr(`${i.id}:a`,i.id,"a",r(a,-s,u),r(l,-s,u),r(a,n.vr,n.rh),i.pitch_a,_=>[x*(_/y),c-m*(_/y)]))}if(t.w-n.vr>.3){let y=Math.hypot(t.w+o-n.vr,n.rh-h);g.push(xr(`${i.id}:b`,i.id,"b",r(l,t.w+o,h),r(a,t.w+o,h),r(l,n.vr,n.rh),i.pitch_b,_=>[m*(_/y),c-x*(_/y)]))}if(f){let y=o_(`${i.id}:c`,i.id,"c",r(a,t.w+o,h),r(a,-s,u),r(t.u0+p,n.vr,n.rh)),_=o_(`${i.id}:d`,i.id,"d",r(l,-s,u),r(l,t.w+o,h),r(t.u1-p,n.vr,n.rh));g.push(...[y,_].filter(b=>b!==null))}return g}function RC(i,e,t,n,r,s){let o=hl(e.w,i.eave_a,i.eave_b,dr(i.pitch_a),dr(i.pitch_b)),a=(p,x)=>{let[m,g]=e.at(p,x);return[m,o.y(x),g]},l=n-t,c=()=>[0,l],u=(p,x)=>Math.atan2(p,x)/Qn,h=[],[f,d]=[e.w+s,e.w-o.vlb];return o.vla+r>.3&&h.push(xr(`${i.id}:a`,i.id,"a",a(t,-r),a(n,-r),a(t,o.vla),i.pitch_a,c)),o.vr-o.vla>.3&&h.push(xr(`${i.id}:au`,i.id,"a",a(t,o.vla),a(n,o.vla),a(t,o.vr),u(o.rh-o.yla,o.vr-o.vla),c)),o.vlb+s>.3&&h.push(xr(`${i.id}:b`,i.id,"b",a(n,f),a(t,f),a(n,d),i.pitch_b,c)),d-o.vr>.3&&h.push(xr(`${i.id}:bu`,i.id,"b",a(n,d),a(t,d),a(n,o.vr),u(o.rh-o.ylb,d-o.vr),c)),h}function h_(i){return i.floors.filter(t=>t.rooms.some(n=>n.points.length>=3)).sort((t,n)=>n.elevation-t.elevation)[0]??null}function Ns(i){let e=i.settings.roof;if(!e||e.type==="none")return[];if(e.type==="custom")return(e.sections??[]).flatMap(_=>EC(_,dl(i,_,_.overhang??e.overhang)));let t=h_(i);if(!t)return[];let n=t.rooms.flatMap(_=>_.points.map(b=>b[0])),r=t.rooms.flatMap(_=>_.points.map(b=>b[1])),s=i.settings.wall_exterior+e.overhang,[o,a]=[Math.min(...n)-s,Math.max(...n)+s],[l,c]=[Math.min(...r)-s,Math.max(...r)+s],u=t.elevation+t.height;if(e.type==="flat")return[l_("main",null,o,l,a,c,u+a_)];let h=a-o>=c-l,f=e.ridge==="short"?!h:h,d=(f?c-l:a-o)/2,p=d*Math.tan(e.pitch*Qn),x=(_,b,M)=>f?[_,u+M,(l+c)/2+b]:[(o+a)/2+b,u+M,_],[m,g]=f?[o,a]:[l,c],y=()=>[0,g-m];return[xr("main:a",null,"a",x(m,-d,0),x(g,-d,0),x(m,0,p),e.pitch,y),xr("main:b",null,"b",x(m,d,0),x(g,d,0),x(m,0,p),e.pitch,y)]}function _h(i,e){let t=[];for(let n of i.floors.filter(r=>!e||r.id===e)){let{walls:r}=fl(n.rooms,{exterior:i.settings.wall_exterior,interior:i.settings.wall_interior},n.walls??[]);for(let s of r){if(!s.exterior&&!s.free)continue;let[o,a]=[s.b[0]-s.a[0],s.b[1]-s.a[1]],l=Math.hypot(o,a);if(l<1.2)continue;let[c,u]=[a/l,-o/l],h=Math.min(n.height,s.height??n.height,s.heightEnd??1/0),f=(d,p,x,m)=>t.push({key:d,section:null,side:"top",flat:!1,o:p,eu:x,es:[0,1,0],n:m,lu:l,ls:h,pitch:90,span:()=>[0,l],facing:[m[0],m[2]],wall:{floorId:n.id}});f(`wall:${n.id}:${s.id}`,[s.a[0]+c*s.right,n.elevation,s.a[1]+u*s.right],[o/l,0,a/l],[c,0,u]),s.free&&f(`wall:${n.id}:${s.id}:back`,[s.b[0]-c*s.left,n.elevation,s.b[1]-u*s.left],[-o/l,0,-a/l],[-c,0,-u])}}return t}var Ll="ground";function Mh(i){let e=i.floors.filter(t=>t.rooms.some(n=>n.points.length>=3)).sort((t,n)=>t.elevation-n.elevation);return e.find(t=>t.elevation>-.5)??e[0]??i.floors[0]??null}function Sh(i,e){let t=(e.rotation??0)*Qn,n=[Math.cos(t),0,Math.sin(t)],r=[-Math.sin(t),0,Math.cos(t)],s=Mh(i),o=n[0]*e.u+r[0]*e.v,a=n[2]*e.u+r[2]*e.v,l=s?s.elevation+(e.base!=null?e.base:k0(s,o,a)):e.base??0;return{key:Ll,section:null,side:"top",flat:!0,o:[0,l,0],eu:n,es:r,n:[0,1,0],lu:1e4,ls:1e4,pitch:0,span:()=>[-1e4,1e4],facing:[r[0],r[2]],unbounded:!0}}var Zp=1.13,Jp=1.72,Bo=.025,pi=.07;function Fl(i){let e=i.module_w||Zp,t=i.module_h||Jp;return i.portrait===!1?[t,e]:[e,t]}function jp(i){return i.layout?.length?i.layout.map(e=>Math.max(0,Math.min(60,Math.round(e)))):Array.from({length:Math.max(1,i.rows)},()=>Math.max(1,i.cols))}function Qp(i,e){return i.flat?Math.min(45,Math.max(0,e.tilt??15))*Qn:i.wall?Math.min(90,Math.max(0,e.tilt??0))*Qn:Math.min(45,Math.max(0,e.tilt??0))*Qn}function Th(i,e){let[,t]=Fl(e),n=Qp(i,e);return i.wall?t*Math.cos(n)+Bo:!i.flat&&n<.001?t+Bo:i.flat&&e.rack==="ew"?t*Math.cos(n)+.08:t*Math.cos(n)+Math.max(.3,2*t*Math.sin(n))}function em(i,e){let[t,n]=Fl(e),r=jp(e),s=Math.max(1,...r);return[s*t+(s-1)*Bo,(r.length-1)*Th(i,e)+n*Math.cos(Qp(i,e))]}var CC=i=>i.flat&&!i.unbounded&&!i.wall;function PC(i,e){if(!CC(i)||!e.rotation)return null;let t=e.rotation*Qn,[n,r]=em(i,e);return{cos:Math.cos(t),sin:Math.sin(t),u:e.u+n/2,s:e.v+r/2}}function zo(i,e,t=!1){let[n,r]=Fl(e),s=Qp(i,e),o=r*Math.cos(s),a=Th(i,e),l=jp(e),c=Math.max(1,...l),u=new Set(e.skip??[]),h=PC(i,e),f=(m,g)=>h?[h.u+(m-h.u)*h.cos-(g-h.s)*h.sin,h.s+(m-h.u)*h.sin+(g-h.s)*h.cos]:[m,g],d=(m,g,y)=>{let[_,b]=f(m,g);return[0,1,2].map(M=>i.o[M]+i.eu[M]*_+i.es[M]*b+i.n[M]*y)},p=(m,g)=>{let[y,_]=f(m,g);if(i.unbounded)return!0;if(_<-1e-6||_>i.ls+1e-6)return!1;let[b,M]=i.span(_);return y>=b-1e-6&&y<=M+1e-6},x=[];return l.forEach((m,g)=>{let y=e.align==="right"?c-m:e.align==="center"?(c-m)/2:0;for(let _=0;_.001?o:r);if([[S,w],[v,w],[v,P],[S,P]].every(([T,R])=>p(T,R)))if(i.wall&&s>.001){let T=pi+r*Math.sin(s),[R,L]=e.flip?[T,pi]:[pi,T],k=[d(S,w,R),d(v,w,R),d(v,P,L),d(S,P,L)],C=e.flip?w:P;x.push({corners:k,posts:[S+.05,v-.05].map(I=>[d(I,C,0),d(I,C,T)]),cell:b,skipped:M})}else if(!i.flat&&s>.001){let T=pi+r*Math.sin(s),R=[d(S,w,pi),d(v,w,pi),d(v,P,T),d(S,P,T)];x.push({corners:R,posts:[S+.05,v-.05].map(L=>[d(L,P,0),d(L,P,T)]),cell:b,skipped:M})}else if(!i.flat)x.push({corners:[d(S,w,pi),d(v,w,pi),d(v,P,pi),d(S,P,pi)],posts:[],cell:b,skipped:M});else{let R=.15+r*Math.sin(s),L=e.rack==="ew"&&g%2===1?!e.flip:!!e.flip,[k,C]=L?[P,w]:[w,P],I=[d(S,k,.15),d(v,k,.15),d(v,C,R),d(S,C,R)],O=[S+.05,v-.05].flatMap(F=>[[d(F,k,0),d(F,k,.15)],[d(F,C,0),d(F,C,R)]]);x.push({corners:I,posts:O,cell:b,skipped:M})}}}),x}var tm=.78,nm=1.18,f_=i=>({id:i.id,face:i.face,u:i.u,v:i.v,rows:1,cols:1,portrait:!0,module_w:i.w||tm,module_h:i.h||nm});function Nl(i,e){let t=zo(i,f_(e))[0];if(!t)return null;let n=r=>[r[0]-i.n[0]*.05,r[1]-i.n[1]*.05,r[2]-i.n[2]*.05];return t.corners.map(n)}var wh={brick:{w:.5,d:.5,h:1},round:{w:.4,d:.4,h:1},wide:{w:1,d:.5,h:1},steel:{w:.2,d:.2,h:1.2}};function Ah(i){let e=i.shape??"brick",t=wh[e]??wh.brick;return{shape:e,w:i.w||t.w,d:i.d||t.d,h:i.h||t.h}}function im(i,e){let{w:t,d:n}=Ah(i),r=e&&!e.flat?Math.cos(e.pitch*Qn):1;return{id:i.id,face:i.face,u:i.u,v:i.v,rows:1,cols:1,portrait:!0,module_w:t,module_h:n/Math.max(.2,r),tilt:0}}function rm(i,e){let t=im(e,i),[n,r]=[t.module_w,t.module_h],s=(u,h)=>[i.o[0]+i.eu[0]*u+i.es[0]*h,i.o[1]+i.eu[1]*u+i.es[1]*h,i.o[2]+i.eu[2]*u+i.es[2]*h],[o,a]=[s(e.u+n/2,e.v),s(e.u+n/2,e.v+r)],l=s(e.u+n/2,e.v+r/2),c=u=>{let h=Math.hypot(u[0],u[2])||1;return[u[0]/h,u[2]/h]};return{center:[l[0],l[2]],along:c(i.eu),across:c(i.es),low:Math.min(o[1],a[1]),high:Math.max(o[1],a[1])}}var Os=1712952,Ds=2239816,Eh=1318193,yr=Be(3662079,.9),br=Be(5995775,.45),Xt=.14,d_=9427199,p_=13226982,m_=14936565,g_={black:{glass:new W(329483),edge:Be(9082544,.32),cells:Be(2766160,.22)},blue:{glass:new W(1386842),edge:Be(10467583,.55),cells:Be(4025599,.35)}},x_=Be(13226982,.5),y_=Be(13226982,.85),b_=Be(16757575,.95),sm=new W(2845583),om=new W(3818072),am=3812144,lm=4864064,Rh=2765896,Vo=329483,Ch=9148333,Ph=11845844,v_=Be(5995775,.4);var Go=(i,e,t)=>[i[0]+(e[0]-i[0])*t,i[1]+(e[1]-i[1])*t,i[2]+(e[2]-i[2])*t],Ih=(i,e,t)=>[i[0]+e[0]*t,i[1]+e[1]*t,i[2]+e[2]*t],cm=(i,e)=>e.section?i.find(t=>t.sections?.includes(e.section)):i[0];function __(i,e,t){let n=i.settings.roof?.windows??[];if(n.length===0||e.length===0)return;let r=new Map(Ns(i).map(s=>[s.key,s]));for(let s of n){let o=r.get(s.face),a=o?Nl(o,s):null,l=o&&a?cm(e,o):void 0;if(!o||!a||!l)continue;let c=l.floor.elevation+l.base,[u,h,f,d]=a.map(P=>[P[0],P[1]-c,P[2]]),p=t.get(s.id)??{open:0,tilt:0,cover:0},x=(P,T)=>Ih(P,o.n,T),m=p.open>.02||p.tilt>.02?b_:y_,g=[u,h,f,d].map(P=>x(P,.06));g.forEach((P,T)=>l.lines.seg(P,g[(T+1)%4],m));let y=(p.open>.02?30*Math.min(1,p.open):p.tilt>.5?12:0)*mt,_=Math.hypot(f[0]-h[0],f[1]-h[1],f[2]-h[2]),b=P=>Ih(Ih(P,o.es,-_*Math.cos(y)),o.n,_*Math.sin(y)),[M,S]=[x(d,.065),x(f,.065)],[v,w]=[b(M),b(S)];l.solid.tri(v,w,S,sm),l.solid.tri(v,S,M,sm);for(let[P,T]of[[v,w],[w,S],[S,M],[M,v]])l.lines.seg(P,T,m);if(p.cover>.02){let P=Math.min(1,p.cover),[T,R]=[x(Go(M,v,P),.01),x(Go(S,w,P),.01)],[L,k]=[x(M,.01),x(S,.01)];l.solid.tri(T,R,k,om),l.solid.tri(T,k,L,om)}}}function Lh(i,e,t,n,r){let s=c=>[c[0],c[1]-r,c[2]],o=g_[n.look==="blue"?"blue":"black"],[a,l]=n.portrait===!1?[10,6]:[6,10];for(let c of zo(t,n)){let[u,h,f,d]=c.corners.map(s);for(let[m,g,y]of[[u,h,f],[u,f,d],[u,f,h],[u,d,f]])i.tri(m,g,y,o.glass);let p=m=>Ih(m,t.n,.004),x=[u,h,f,d].map(p);x.forEach((m,g)=>e.seg(m,x[(g+1)%4],o.edge));for(let m=1;m[r.key,r]));for(let r of t){let s=n.get(r.face),o=s?cm(e,s):void 0;s&&o&&Lh(o.solid,o.lines,s,r,o.floor.elevation+o.base)}}function S_(i,e){let t=i.settings.roof?.chimneys??[];if(t.length===0||e.length===0)return;let n=new Map(Ns(i).map(r=>[r.key,r]));for(let r of t){let s=n.get(r.face),o=s?cm(e,s):void 0;if(!s||!o)continue;let a=o.floor.elevation+o.base,{shape:l,w:c,d:u,h}=Ah(r),f=rm(s,r),[d,p]=[f.low-a-.1,f.high-a+h],x=(v,w)=>{let{center:P,along:T,across:R}=f,L=(k,C)=>[P[0]+T[0]*v*k+R[0]*w*C,P[1]+T[1]*v*k+R[1]*w*C];return[L(-1,-1),L(1,-1),L(1,1),L(-1,1)]},m=(v,w=16)=>Array.from({length:w},(P,T)=>[f.center[0]+Math.cos(T/w*2*Math.PI)*v,f.center[1]+Math.sin(T/w*2*Math.PI)*v]),g=(v,w)=>v.forEach((P,T)=>o.lines.seg([P[0],w,P[1]],[v[(T+1)%v.length][0],w,v[(T+1)%v.length][1]],v_)),y=(v,w,P,T,R)=>Tt(o.solid,FC(v),w,P,T,R);if(l==="steel"){let v=Math.min(c,u)/2;y(m(v,12),d,p,Ch,Ph),y(m(v*.75,12),p,p+.001,Vo,Vo),y(m(v*.25,6),p,p+.1,Ch,Ph);let w=m(v*1.9,12);y(w,p+.1,p+.13,Ch,Ph),g(w,p+.13);continue}if(l==="round"){let v=Math.min(c,u)/2,w=m(v);y(w,d,p,am,lm),y(m(v*.55),p,p+.002,Vo,Vo),g(w,p);continue}let _=x(c/2,u/2);y(_,d,p,am,lm);let b=x(c/2+.04,u/2+.04);y(b,p,p+.06,Rh,Rh),g(b,p+.06),g(_,p-.25);let M=Math.min(c,u)*.25,S=l==="wide"?[-c/4,c/4]:[0];for(let v of S){let w=[f.center[0]+f.along[0]*v,f.center[1]+f.along[1]*v],P=[[-1,-1],[1,-1],[1,1],[-1,1]].map(([T,R])=>[w[0]+f.along[0]*M*T+f.across[0]*M*R,w[1]+f.along[1]*M*T+f.across[1]*M*R]);y(P,p+.06,p+.16,Rh,Vo)}}}function FC(i){let e=0;for(let t=0;t0,r.b>0,r.u0>0,r.u1>0],f=(p,x,m,g,y,_)=>{let b=[t.at(p,m),t.at(x,m),t.at(x,g),t.at(p,g)],M=(b[1][0]-b[0][0])*(b[2][1]-b[0][1])-(b[2][0]-b[0][0])*(b[1][1]-b[0][1]);Tt(i,M<0?[...b].reverse():b,y-o,_-o,p_,m_,{bottom:!0})};for(let[p,x]of[[0,l],[a,c]]){if(!x)continue;let m=n.y(p)-.03,g=p===0?0:a-ei;f(t.u0,t.u1,g,g+ei,m-Ol,m),e.seg(s(t.u0,p,m-Ol),s(t.u1,p,m-Ol),br)}for(let[p,x]of[[t.u0,u],[t.u1-ei,h]])if(x)for(let m=0;m<6;m++){let[g,y]=[a*m/6,a*(m+1)/6],_=Math.min(n.y(g),n.y(y))-.03;f(p,p+ei,g,y,_-Ol,_)}let d=[];for(let[p,x]of[[0,l],[a-ei,c]]){if(!x)continue;let m=t.u1-t.u0-ei,g=Math.max(1,Math.ceil(m/3.5));for(let y=0;y<=g;y++)y===0&&!u||y===g&&!h||d.push([t.u0+m*y/g,p])}!l&&!c&&(u&&d.push([t.u0,a/2-ei/2]),h&&d.push([t.u1-ei,a/2-ei/2]));for(let[p,x]of d)f(p,p+ei,x,x+ei,o,n.y(x+ei/2)-.03-Ol)}function NC(i,e){let t=[];if(i.forEach(([s,o],a)=>{o>=e&&t.push([s,o]);let l=i[a+1];if(l&&(o-e)*(l[1]-e)<0){let c=(e-o)/(l[1]-o);t.push([s+(l[0]-s)*c,e])}}),t.length<2)return[];let[n,r]=[t[0],t[t.length-1]];return r[1]>e&&t.push([r[0],e]),n[1]>e&&t.unshift([n[0],e]),t}var T_=i=>wr(i)>=0?i:[...i].reverse();function A_(i,e,t,n,r,s=i,o=!1,a=[],l=null){let c=Un(t),u=Rn(t),h=typeof n=="number"?{u0:n,u1:n,a:n,b:n}:n,[f,d]=[Math.max(0,h.a),Math.max(0,h.b)],p=c.w,x=c.u0-Math.max(0,h.u0),m=c.u1+Math.max(0,h.u1),g=(I,O,F)=>{let[H,U]=c.at(I,O);return[H,F-r,U]},y=new W(Ds),_=new W(Os),b=new W(Eh),M=(I,O)=>{for(let F=1;F+1g(I,O,F-H),v=[],w=[],P=[],T=null,R=null;if(t.shape==="flat"||t.shape==="parapet"){let I=t.eave_a-r,O=t.shape==="parapet",F=t.points&&t.points.length>=3?mp(t,O?0:Math.max(0,Math.min(h.a,h.b,h.u0,h.u1))):O?[c.at(c.u0,0),c.at(c.u1,0),c.at(c.u1,p),c.at(c.u0,p)]:[c.at(x,-f),c.at(m,-f),c.at(m,p+d),c.at(x,p+d)];if(Tt(i,F,I,I+.25,Os,Ds,{bottom:!0}),F.forEach((H,U)=>{let X=F[(U+1)%F.length];e.seg([H[0],I+.252,H[1]],[X[0],I+.252,X[1]],yr),e.seg([H[0],I,H[1]],[X[0],I,X[1]],br)}),O){let H=T_(F),U=Hu(H,-.2);H.forEach((X,V)=>{let re=(V+1)%H.length;Tt(i,T_([X,H[re],U[re],U[V]]),I+.25,I+.65,Os,Ds),e.seg([X[0],I+.652,X[1]],[H[re][0],I+.652,H[re][1]],yr),e.seg([U[V][0],I+.652,U[V][1]],[U[re][0],I+.652,U[re][1]],yr)})}}else{let I=Wr(t,h);v=a.reduce((O,F)=>O.flatMap(H=>Wu(H,F)),I.faces),w=I.rim,P=I.ridges,T=I.gable,R=I.endProfiles??null}let L=!!t.open,k=new W(d_);for(let I of v)if(L)for(let O=1;O+1S(O)),y),M(I.map(O=>S(O,Xt)),_);if(w.forEach((I,O)=>{let F=w[(O+1)%w.length];L||M([S(I),S(F),S(F,Xt),S(I,Xt)],_),e.seg(S(I),S(F),L?yr:br)}),L){w_(i,e,c,u,h,(I,O,F)=>g(I,O,F),r);return}for(let[I,O]of P)e.seg(S([I[0],I[1],I[2]+.004]),S([O[0],O[1],O[2]+.004]),yr);let C=t.base;if(!o){if(T){let I=l===null?[c.u0,c.u1]:[l===0?c.u0:c.u1];for(let O of I){let F=R?R[O===c.u0?0:1]:T,H=F?NC(F,C-Xt):[];H.length>=3&&M(H.map(([U,X])=>g(O,U,X)),b)}}if(t.shape!=="flat"&&t.shape!=="parapet")for(let I of[0,p]){let O=u.y(I)-Xt;O>C+.02&&M([g(c.u0,I,C),g(c.u1,I,C),g(c.u1,I,O),g(c.u0,I,O)],b)}else if(t.eave_a>C+.02){let I=[[c.u0,0],[c.u1,0],[c.u1,p],[c.u0,p]];I.forEach(([O,F],H)=>{let[U,X]=I[(H+1)%4];M([g(O,F,C),g(U,X,C),g(U,X,t.eave_a),g(O,F,t.eave_a)],b)})}}}function E_(i,e,t){let n=i.floors.filter(o=>o.rooms.length>0).sort((o,a)=>o.elevation-a.elevation);if(n.length===0)return[];let r=new Map,s=new Map(Ns(i).map(o=>[o.key,o]));for(let o of e){if(Math.abs(o.x1-o.x0)<.1||Math.abs(o.z1-o.z0)<.1)continue;let a=yp(i,o)??n[0],l=o.open?`${a.id}:open`:a.id,c=r.get(l);c||r.set(l,c={floor:a,base:0,solid:new ut,lines:new Wt,glass:new ut,sections:[],lift:!o.open}),c.sections.push(o.id);let u=ml(e,o),h=Rs(e,o)??u?.parent??null,f=a.elevation+a.height>o.base+.05&&!o.dormer&&!h,d=e.filter(m=>m!==o).flatMap(m=>Rs(e,m)===o?Yu(o,m):ml(e,m)?.parent===o?Yu(o,ml(e,m).extended):[]);for(let m of i.settings.roof.windows??[]){let g=s.get(m.face),y=g&&g.section===o.id?Nl(g,m):null;if(!y)continue;let _=y.map(b=>Oi(o,b[0],b[2]));d.push({u0:Math.min(..._.map(b=>b[0])),u1:Math.max(..._.map(b=>b[0])),v0:Math.min(..._.map(b=>b[1])),v1:Math.max(..._.map(b=>b[1]))})}let p=u?u.extended:h?pl(h,o):o,x=null;if(h){let m=Un(p),g=Wr(h,{u0:0,u1:0,a:0,b:0}),y=_=>{let[b,M]=m.at(_,m.w/2),[S,v]=Oi(h,b,M);return Es(g,S,v)??Rn(h).y(v)};x=y(m.u0)<=y(m.u1)?0:1}A_(c.solid,c.lines,p,dl(i,p,p.overhang??t),a.elevation,c.glass,f,d,x)}return[...r.values()].sort((o,a)=>+(o.lift===!1)-+(a.lift===!1))}function R_(i){return i.floors.filter(e=>e.rooms.some(t=>t.points.length>=3)).sort((e,t)=>t.elevation-e.elevation)[0]??null}function C_(i){let e=i.settings.roof,t=R_(i);if(!t||!e||e.type==="none"||e.type==="custom")return null;let n=t.rooms.flatMap(L=>L.points.map(k=>k[0])),r=t.rooms.flatMap(L=>L.points.map(k=>k[1])),s=i.settings.wall_exterior+e.overhang,[o,a]=[Math.min(...n)-s,Math.max(...n)+s],[l,c]=[Math.min(...r)-s,Math.max(...r)+s],u=new ut,h=new Wt,f={floor:t,base:t.height,solid:u,lines:h,glass:new ut};if(e.type==="flat"){let L=[[o,l],[a,l],[a,c],[o,c]];return Tt(u,L,0,.25,Os,Ds,{bottom:!0}),L.forEach(([k,C],I)=>{let[O,F]=L[(I+1)%4];h.seg([k,.252,C],[O,.252,F],yr),h.seg([k,0,C],[O,0,F],br)}),f}let d=a-o>=c-l,p=e.ridge==="short"?!d:d,x=(p?c-l:a-o)/2,m=Math.tan(e.pitch*mt),g=x*m,y=(L,k,C)=>p?[L,C,(l+c)/2+k]:[(o+a)/2+k,C,L],[_,b]=p?[o,a]:[l,c],M=new W(Ds),S=new W(Os),v=(L,k,C,I,O)=>{u.tri(L,k,C,O),u.tri(L,C,I,O)};for(let L of[-1,1]){v(y(_,L*x,0),y(b,L*x,0),y(b,0,g),y(_,0,g),M),v(y(_,L*x,-Xt),y(_,0,g-Xt),y(b,0,g-Xt),y(b,L*x,-Xt),S),v(y(_,L*x,-Xt),y(b,L*x,-Xt),y(b,L*x,0),y(_,L*x,0),S);for(let k of[_,b])v(y(k,L*x,-Xt),y(k,L*x,0),y(k,0,g),y(k,0,g-Xt),S);h.seg(y(_,L*x,0),y(b,L*x,0),br);for(let k of[_,b])h.seg(y(k,L*x,0),y(k,0,g),br)}let w=e.overhang,P=new W(Eh),T=x-w,R=T*m;for(let L of[_+w,b-w])u.tri(y(L,-T,-Xt),y(L,T,-Xt),y(L,0,R-Xt),P),u.tri(y(L,T,-Xt),y(L,-T,-Xt),y(L,0,R-Xt),P);return h.seg(y(_,0,g+.004),y(b,0,g+.004),yr),f}function Fh(i,e=new Map){let t=i.settings.roof;if(i.topology&&t?.type!=="custom"){let s=new Map;for(let o of i.floors)if(!o.outdoor_location_id){let a=o.building_id??"legacy";s.set(a,[...s.get(a)??[],o])}return[...s.values()].flatMap(o=>Fh({...i,topology:void 0,floors:o},e))}let n=t?.type==="custom"?null:C_(i),r=t?.type==="custom"?E_(i,t.sections??[],t.overhang):n?[n]:[];return M_(i,r),__(i,r,e),S_(i,r),r}function Nh(i){let{start:e,axis:t,width:n}=i.info;return[[e[0],e[1]],[e[0]+t[0]*n,e[1]+t[1]*n]]}var P_=(i,e)=>`${i}|${Math.round(e[0]*50)},${Math.round(e[1]*50)}`;function I_(i,e){let t=[];for(let n of i){let r=n.info.opening.front;if(!r)continue;let[s,o]=Nh(n);e.at(r,s)&&t.push(n.s0),e.at(r,o)&&t.push(n.s1)}return t}function L_(i,e){let t=Math.hypot(i.b[0]-i.a[0],i.b[1]-i.a[1])||1;return((e[0]-i.a[0])*(i.b[0]-i.a[0])+(e[1]-i.a[1])*(i.b[1]-i.a[1]))/t}function Oh(i){let e=new Map,t=new Map;for(let r of i)for(let s of r){let o=s.info.opening.front;if(o)for(let a of Nh(s)){let l=P_(o,a);e.set(l,(e.get(l)??0)+1),t.has(l)||t.set(l,[a[0],a[1]])}}return{points:[...e].filter(([,r])=>r>1).map(([r])=>t.get(r)).filter(r=>!!r),at:(r,s)=>(e.get(P_(r,s))??0)>1}}var Us={floor:923177,slab:659744,wall:1252657,wallTop:1323071,edge:3662079,edgeSoft:5995775},Dh={wood:{color:1120814,tile:[0,0]},oak:{color:1252141,tile:[1,0]},tiles:{color:923695,tile:[2,0]},carpet:{color:1053995,tile:[0,1]},stone:{color:988971,tile:[1,1]},concrete:{color:1120295,tile:[2,1]}},mi=.2,Ho=8;var F_=(i,e)=>i.heightEnd===void 0?i.height??e:Math.max(i.height??e,i.heightEnd);function N_(i){let e=new Map,t=[],n=new Map;for(let r of i){let s="interior",o=null;if(r.exterior){let[a,l]=[r.b[0]-r.a[0],r.b[1]-r.a[1]],c=Math.hypot(a,l)||1,u=[l/c,-a/c],h=(Math.round(Math.atan2(u[1],u[0])/(2*Math.PI)*Ho)%Ho+Ho)%Ho;s=`s${h}`;let f=h/Ho*2*Math.PI;o=[Math.cos(f),Math.sin(f)]}e.has(s)||(e.set(s,t.length),t.push(o)),n.set(r,e.get(s))}return{buckets:t,wallBucket:n}}function O_(i){let e=(n,r,s)=>{let o=i?i(n,r):null;return o===null?s:Math.max(.05,Math.min(s,o))};return{topAt:e,lowestTop:(n,r,s,o,a)=>{if(!i)return a;let l=Math.max(2,Math.ceil((o-s)/.25)+1),c=a;for(let u=0;ut.topAt(h,f,n),lowestTop:(h,f)=>t.lowestTop(i.a,s,h,f,n)};let[o,a]=[i.height??e,i.heightEnd],l=(h,f)=>{let d=r>1e-9?((h-i.a[0])*s[0]+(f-i.a[1])*s[1])/r:0;return o+(a-o)*Math.max(0,Math.min(1,d))},c=(h,f)=>t.topAt(h,f,l(h,f));return{H:n,varies:!0,topAt:c,lowestTop:(h,f)=>{let d=Math.max(2,Math.ceil((f-h)/.25)+1),p=1/0;for(let x=0;x0:c.roomLeft===o.room_id,g=[-h[1],h[0]],y=m?g:[-g[0],-g[1]],_=es(i.rooms.find(P=>P.id===o.room_id)),b=Math.min(Wo(c,i.height,n).lowestTop(p,p+d)-.02,_+o.sill+o.height),M=Math.max(Math.min(0,_),Math.min(_+o.sill,b-.1)),S=[y[1],-y[0]],v=h[0]*S[0]+h[1]*S[1]>0,w={opening:o,bucket:t.get(c),start:[c.a[0]+h[0]*p,c.a[1]+h[1]*p],axis:h,width:d,toRoom:y,faceRoom:m?c.left:c.right,faceOut:m?c.right:c.left,sill:M,top:b,hingeAtStart:o.hinge==="left"===v,exterior:c.exterior};s.push(w),r.set(c,[...r.get(c)??[],{s0:p,s1:p+d,sill:M,top:b,info:w}])}return{openings:s,spans:r}}var U_=i=>`${Math.round(i[0]*50)},${Math.round(i[1]*50)}`;function OC(i,e,t,n=!1,r=!1){let{info:s}=e,o=s.bucket,a=(u,h,f)=>[s.start[0]+s.axis[0]*(u-e.s0)+s.toRoom[0]*h,f,s.start[1]+s.axis[1]*(u-e.s0)+s.toRoom[1]*h],l=u=>u>t+1e-6?o:$e,c=e.sill<0?e.sill+.004:Math.max(e.sill,.004);for(let u of[s.faceRoom,-s.faceOut])n||i.segSplit(a(e.s0,u,c),a(e.s0,u,e.top),ui,t,o),r||i.segSplit(a(e.s1,u,c),a(e.s1,u,e.top),ui,t,o),i.seg(a(e.s0,u,e.top),a(e.s1,u,e.top),ui,l(e.top)),e.sill>.01&&i.seg(a(e.s0,u,e.sill),a(e.s1,u,e.sill),ui,l(e.sill));for(let[u,h]of[[e.s0,n],[e.s1,r]])h||(i.seg(a(u,s.faceRoom,e.top),a(u,-s.faceOut,e.top),ui,l(e.top)),e.sill>.01&&i.seg(a(u,s.faceRoom,e.sill),a(u,-s.faceOut,e.sill),ui,l(e.sill)),e.sillt&&i.seg(a(u,s.faceRoom,t),a(u,-s.faceOut,t),Bu,ol+o))}function k_(i,e,t,n,r,s,o){let a=Math.min(e.cut_height,e.height),l=(f,d)=>(r.get(f)??[]).filter(d);for(let f of t.edges){let d=n.get(f.wall);for(let[g,y]of Io(f,l(f.wall,_=>_.sill<=.005)))i.seg([g[0],.004,g[1]],[y[0],.004,y[1]],$d);for(let[g,y]of Io(f,l(f.wall,_=>_.silla)))i.seg([g[0],a,g[1]],[y[0],a,y[1]],Bu,ol+d);let p=Wo(f.wall,e.height,s),{H:x,topAt:m}=p;for(let[g,y]of Io(f,l(f.wall,_=>_.top>=x-.021))){if(!o&&!p.varies){i.seg([g[0],x,g[1]],[y[0],x,y[1]],Li,x<=a+1e-6?fr+d:d);continue}let _=Math.max(1,Math.ceil(Math.hypot(y[0]-g[0],y[1]-g[1])/.3)),b=M=>[g[0]+(y[0]-g[0])*M/_,g[1]+(y[1]-g[1])*M/_];for(let M=0;M<_;M++){let[S,v]=[b(M),b(M+1)],[w,P]=[m(S[0],S[1]),m(v[0],v[1])];i.seg([S[0],w,S[1]],[v[0],P,v[1]],Li,Math.max(w,P)<=a+1e-6?fr+d:d)}}}let c=Oh(r.values()),u=new Set(c.points.map(U_)),h=new Map;for(let[f,d]of r)h.set(f,I_(d,c));for(let f of t.corners){let d=L_(f.wall,f.p),x=(r.get(f.wall)??[]).some(y=>!!y.info.opening.front&&d>y.s0+.05&&dMath.abs(y-d)<.06);if(x||m||u.has(U_(f.p)))continue;let g=Wo(f.wall,e.height,s).topAt(f.p[0],f.p[1]);i.segSplit([f.p[0],.004,f.p[1]],[f.p[0],g,f.p[1]],ui,Math.min(a,g),n.get(f.wall))}for(let f of r.values())for(let d of f){let p=d.info.opening.front,[x,m]=Nh(d);OC(i,d,a,p?c.at(p,x):!1,p?c.at(p,m):!1)}}function B_(i,e){let t=new ut(!0,!0),n=[],r=new Wt,s=[],o=new W(Us.slab),a=(l,c=0,u=c-mi)=>{l.forEach((h,f)=>{let d=l[(f+1)%l.length];t.tri([h[0],u,h[1]],[h[0],c,h[1]],[d[0],c,d[1]],o),t.tri([h[0],u,h[1]],[d[0],c,d[1]],[d[0],u,d[1]],o)})};for(let l of i.rooms){if(l.points.length<3)continue;let c=Hr(l.points),u=Dh[l.floor_material]??Dh.wood,h=new W(u.color),f=e.filter(m=>Fb(m,c)).map(m=>Nb(m,.003));s.push(...f);let d=[...c,...f.flat()],p=t.count,x=es(l);for(let[m,g,y]of Gr(c,f)){let[_,b,M]=[d[m],d[g],d[y]];t.tri([_[0],x,_[1]],[M[0],x,M[1]],[b[0],x,b[1]],h,h,h,[_[0],_[1],M[0],M[1],b[0],b[1]],$e,u.tile)}n.push({roomId:l.id,start:p,end:t.count,color:u.color}),a(c,x),Math.abs(x)>.005&&(a(c,Math.max(0,x),Math.min(0,x)),a([...c].reverse(),Math.max(0,x),Math.min(0,x)));for(let m of f)a([...Hr(m)].reverse()),m.forEach((g,y)=>{let _=m[(y+1)%m.length];r.seg([g[0],x+.006,g[1]],[_[0],x+.006,_[1]],Li),r.seg([g[0],x-mi,g[1]],[_[0],x-mi,_[1]],ui)})}return{buffer:t,roomTris:n,holeLines:r,cutHoles:s}}var Uh=.42,um=.42;function z_(i,e,t){let n=new ut,r=new W(um,um,um),s=new W(1,1,1),o=.002;for(let a of i)for(let[l,c]of Io(a,(t.get(a.wall)??[]).filter(u=>u.sill<=.005))){let[u,h]=[c[0]-l[0],c[1]-l[1]],f=Math.hypot(u,h);if(f<.05)continue;let d=[h/f,-u/f],p=[(l[0]+c[0])/2+d[0]*.05,(l[1]+c[1])/2+d[1]*.05];if(!e.some(g=>g.points.length>=3&&Ge(p,g.points)))continue;let x=[l[0]+d[0]*Uh,l[1]+d[1]*Uh],m=[c[0]+d[0]*Uh,c[1]+d[1]*Uh];n.tri([l[0],o,l[1]],[x[0],o,x[1]],[m[0],o,m[1]],r,s,s),n.tri([l[0],o,l[1]],[m[0],o,m[1]],[c[0],o,c[1]],r,s,r)}return n}var hm=(i,e)=>Number.parseInt(/^#?([0-9a-f]{6})$/i.exec(i?.trim()??"")?.[1]??e.slice(1),16),DC=i=>/^#?[0-9a-f]{6}$/i.test(i?.trim()??"");function fm(i,e){return{outside:hm(DC(e.wall_paint_outside)?e.wall_paint_outside:i.wall_paint_outside,V0),inside:hm(i.wall_paint_inside,uf),rooms:e.rooms.filter(t=>t.wall_paint&&t.points.length>=3).map(t=>({points:t.points,color:hm(t.wall_paint,uf)}))}}var UC=14276045;function kC(i,e,t,n,r){let s=Math.hypot(t[0]-e[0],t[1]-e[1])||1,o=[(e[0]+t[0])/2,(e[1]+t[1])/2],a=[(t[1]-e[1])/s,-(t[0]-e[0])/s];Ge([o[0]+a[0]*.01,o[1]+a[1]*.01],i)&&(a=[-a[0],-a[1]]);let l=[o[0]+a[0]*.06,o[1]+a[1]*.06],c=n.rooms.find(u=>Ge(l,u.points));return c?c.color:r.some(u=>u.points.length>=3&&Ge(l,u.points))?n.inside:n.outside}function BC(i,e,t=-mi){let n=[-1/0,...new Set(i.flatMap(s=>[s.s0,s.s1])).values(),1/0].sort((s,o)=>s-o),r=[];for(let s=0;s+1f.s0l).map(f=>[f.sill,f.top]).sort((f,d)=>f[0]-d[0]),u=[],h=t;for(let[f,d]of c)f>h+1e-4&&u.push([h,f]),h=Math.max(h,d);e>h+1e-4&&u.push([h,e]),r.push({t0:o,t1:a,ranges:u})}return r}function V_(i,e,t,n,r,s,o,a){let l=Math.min(e.cut_height,e.height),c=a?Jd:0,u=a?m=>(g,y)=>kC(m,g,y,a,e.rooms):null,h=a?UC:Us.wallTop,f=Oh(r.values()),d=m=>f.points.some(g=>Math.hypot(g[0]-m[0],g[1]-m[1])<.03),p=m=>m&&m.info.opening.front?[m.sill,m.top]:null,x=(m,g)=>{let y=[];for(let[_,b]of m)g[0]>_+1e-4&&y.push([_,Math.min(b,g[0])]),b>g[1]+1e-4&&y.push([Math.max(_,g[1]),b]);return y};for(let m of t){let g=n.get(m),y=Ms([m.b[0]-m.a[0],m.b[1]-m.a[1]]),_=(r.get(m)??[]).sort((I,O)=>I.s0-O.s0),b=Wo(m,e.height,s),{H:M,topAt:S}=b,v=Math.min(0,...[m.roomLeft,m.roomRight].map(I=>es(e.rooms.find(O=>O.id===I)))),w=BC(_,M,v-mi),P=Math.hypot(m.b[0]-m.a[0],m.b[1]-m.a[1]),T=(o||b.varies)&&b.lowestTop(0,P){let O=Math.max(I.t0,-.5),F=Math.min(I.t1,P+.5),H=Math.max(1,Math.ceil((F-O)/.3));return Array.from({length:H},(U,X)=>({t0:X===0?I.t0:O+(F-O)*X/H,t1:X===H-1?I.t1:O+(F-O)*(X+1)/H,ranges:I.ranges,inner0:X>0,inner1:X({...I,inner0:!1,inner1:!1})),L=I=>(I[0]-m.a[0])*y[0]+(I[1]-m.a[1])*y[1],k=d(m.a)?p(_[0]):null,C=d(m.b)?p(_[_.length-1]):null;for(let I of R){let O=sp(m.footprint,m.a,y,I.t0,I.t1);if(O.length<3)continue;let F=I.t1<=1e-6&&I.t0<0?k:I.t0>=P-1e-6?C:null,H=F?x(I.ranges,F):I.ranges,U=(Y,Q)=>Math.abs(L(Y)-Q)<1e-4,X=(Y,Q)=>I.inner0&&U(Y,I.t0)&&U(Q,I.t0)||I.inner1&&U(Y,I.t1)&&U(Q,I.t1),V=(Y,Q)=>!f.points.length||Math.hypot(Y[0]-Q[0],Y[1]-Q[1])>.5?!1:f.points.some(se=>Math.min(Math.hypot(se[0]-Y[0],se[1]-Y[1]),Math.hypot(se[0]-Q[0],se[1]-Q[1]))<.05),re=(Y,Q)=>X(Y,Q)||V(Y,Q),ye=T?Math.min(...O.map(([Y,Q])=>S(Y,Q))):M;for(let[Y,Q]of H){let se=Math.min(Q,T?Math.max(...O.map(([at,Ae])=>S(at,Ae))):Q);if(se-Y<1e-4||ye-Y<.01)continue;let we=Y>.01,le=T&&Q>ye,Ne=(at,Ae)=>Math.min(Q,S(at,Ae));if(Yl+1e-6?Zd+g:fr+g,Ae=le&&yeMath.min(l,Ne(ft,yt)):Math.min(se,l);Tt(i,O,Y,Ae,Us.wall,h,{aoFrom:0,bottom:we,fold:c+fr+g,topFold:c+at,skipSide:re,sideColor:u?.(O)})}se>l+1e-6&&ye>l+1e-6&&Tt(i,O,Math.max(Y,l),le?Ne:se,Us.wall,h,{aoFrom:0,fold:c+g,bottom:we&&Y>=l,skipSide:re,sideColor:u?.(O)})}}}}function dm(i,e,t,n=[],r=[],s,o){let{walls:a,open:l}=fl(i.rooms,{exterior:e,interior:t},i.walls??[]),c=O_(s),u=!!s,h=B_(i,n),{buckets:f,wallBucket:d}=N_(a),{openings:p,spans:x}=D_(i,a,d,c),m=new ut;V_(m,i,a,d,x,c,u,o);let g=op(a,a.flatMap(v=>v.footprint)),y=new Wt;y.p.push(...h.holeLines.p),y.c.push(...h.holeLines.c),y.f.push(...h.holeLines.f),k_(y,i,g,d,x,c,u);let _=z_(g.edges,i.rooms,x),b=new Map;Rp(m,y,i,b,()=>new ut);for(let v of r)Lh(m,y,v.face,v.field,i.elevation);let M=Math.min(i.cut_height,i.height),S=[];for(let v of i.furniture.filter(w=>!H0(w.type))){let w=m.count,P=y.p.length/6,T=Gt(i,v);Xl(v.type)||Il(m,y,_,v,T),T+v.h>M+.05&&(Qd(m,w,M,zu),ep(y,P,M,zu)),S.push({id:v.id,start:w,end:m.count})}return{floor:h.buffer.geometry(),roomTris:h.roomTris,holes:h.cutHoles,walls:m.geometry(),ghosts:[...b].map(([v,w])=>({opacity:v,geometry:w.geometry()})),lines:y.geometry(),shadow:_.geometry(),buckets:f,openings:p,walls2d:a,openRooms:l,wallBuckets:a.map(v=>d.get(v)),furnitureTris:S,roofUnder:s}}function pm(i,e){let t=X0(i,e),n=[...e.furniture.filter(a=>a.type==="stairwell").map(ns),...e.furniture.filter(a=>ch(a)&&a.stair?.down).flatMap(Up)].filter(a=>a.length>=3),r=i.filter(a=>a.elevationl.elevation-a.elevation)[0];if(!r)return mr([...n,...t]);let o=r.furniture.filter(a=>(a.type==="stairs"||_t(a.type)?.hole)&&!(ch(a)&&a.stair?.down)&&r.elevation+a.h>=e.elevation-.3).flatMap(a=>ch(a)?Up(a):[ns(a)]).filter(a=>a.length>=3);return mr([...n,...o,...t])}var G_=.12,H_=1.35,ki=(i,e,t)=>Math.min(t,Math.max(e,i)),zC=i=>i<.5?4*i*i*i:1-(-2*i+2)**3/2,W_=i=>({...i,target:i.target.clone()});function X_({target:i,radius:e,theta:t,phi:n}){return new D(i.x+e*Math.sin(n)*Math.sin(t),i.y+e*Math.cos(n),i.z+e*Math.sin(n)*Math.cos(t))}function Y_(i,e,t){let n=zC(t);return{target:new D().lerpVectors(i.target,e.target,n),radius:i.radius+(e.radius-i.radius)*n,theta:i.theta+(e.theta-i.theta)*n,phi:i.phi+(e.phi-i.phi)*n}}function q_(i,e){let t=e.theta??i.theta;for(;t-i.theta>Math.PI;)t-=2*Math.PI;for(;t-i.theta<-Math.PI;)t+=2*Math.PI;return{target:(e.target??i.target).clone(),radius:e.radius??i.radius,theta:t,phi:e.phi??i.phi}}function mm(i,e,t,n,r){let s=2*i.radius*Math.tan(r*Math.PI/360)/(n||1),o=new D(Math.cos(i.theta),0,-Math.sin(i.theta)),a=new D(-Math.sin(i.theta),0,-Math.cos(i.theta));i.target.addScaledVector(o,-e*s),i.target.addScaledVector(a,t*s/Math.max(.35,Math.cos(i.phi)))}function $_(i,e,t,n){let r=n||1,s={theta:-e/r*3.2,phi:-t/r*2.4};return i.theta+=s.theta,i.phi=ki(i.phi+s.phi,G_,H_),s}function K_(i,e){return Math.abs(e.theta)<=1e-4&&Math.abs(e.phi)<=1e-4?!1:(i.theta+=e.theta,i.phi=ki(i.phi+e.phi,G_,H_),e.theta*=.9,e.phi*=.9,!0)}var VC={KeyW:"w",KeyA:"a",KeyS:"s",KeyD:"d",KeyQ:"q",KeyE:"e"},GC=new Set(["w","a","s","d","q","e","arrowup","arrowdown","arrowleft","arrowright"]);function HC(i){let e=i.code?.startsWith("Key")?VC[i.code]??null:i.key.toLowerCase();return e&&GC.has(e)?e:null}var WC=500,XC=400,YC=320,qC=6,Z_=1.5,$C=1.8;function KC(i,e){let t=i.keys,n=(t.has("w")||t.has("arrowup")?1:0)-(t.has("s")||t.has("arrowdown")?1:0)-i.stick[1],r=(t.has("d")?1:0)-(t.has("a")?1:0),s=(t.has("arrowleft")||t.has("q")?1:0)-(t.has("arrowright")||t.has("e")?1:0)-i.stick[0];if(!n&&!r&&!s)return!1;let o=e/1e3;i.yaw+=s*$C*o;let[a,l]=[-Math.sin(i.yaw),-Math.cos(i.yaw)],[c,u]=[Math.cos(i.yaw),-Math.sin(i.yaw)];return i.eye.x=ki(i.eye.x+(a*n+c*r)*Z_*o,i.bounds.x0,i.bounds.x1),i.eye.z=ki(i.eye.z+(l*n+u*r)*Z_*o,i.bounds.z0,i.bounds.z1),!0}var Dl=class{view={target:new D,radius:16,theta:-.6,phi:.85};minRadius=2;maxRadius=80;locked=!1;walk=null;pointers=new Map;velocity={theta:0,phi:0};flight=null;press=null;lastTap=0;holdTimer;held=!1;grabbing=!1;swiping=null;pinch=null;listeners=[];el;camera;events;constructor(e,t,n){this.el=e,this.camera=t,this.events=n;let r=(l,c,u)=>{e.addEventListener(l,c,u),this.listeners.push([l,c])};r("pointerdown",l=>this.onDown(l)),r("pointermove",l=>this.onMove(l)),r("pointerup",l=>this.onUp(l)),r("pointercancel",l=>this.onUp(l)),r("wheel",l=>this.onWheel(l),{passive:!1}),r("contextmenu",l=>l.preventDefault());let s=l=>c=>{if(!this.walk||c.target?.closest?.("input, textarea, select"))return;let u=HC(c);u&&(c.preventDefault(),l?this.walk.keys.add(u):this.walk.keys.delete(u),this.events.change())},o=s(!0),a=s(!1);window.addEventListener("keydown",o),window.addEventListener("keyup",a),this.listeners.push(["__window_keydown",o],["__window_keyup",a])}dispose(){clearTimeout(this.holdTimer);for(let[e,t]of this.listeners)e.startsWith("__window_")?window.removeEventListener(e.slice(9),t):this.el.removeEventListener(e,t)}get active(){return this.pointers.size>0||this.flight!==null}get busy(){return this.active}update(e){if(this.walk){let n=this.walk,r=KC(n,n.last?Math.min(100,e-n.last):16);n.last=r?e:0;let s=new D(-Math.sin(n.yaw)*Math.cos(n.pitch),Math.sin(n.pitch),-Math.cos(n.yaw)*Math.cos(n.pitch));return this.view.target.copy(n.eye).add(s),this.camera.position.copy(n.eye),this.camera.lookAt(this.view.target),r}let t=!1;if(this.flight){let{from:n,to:r,start:s,duration:o}=this.flight,a=Math.min(1,(e-s)/o);this.view=Y_(n,r,a),a>=1&&(this.flight=null),t=!0}else this.pointers.size===0&&(t=K_(this.view,this.velocity));return this.camera.position.copy(X_(this.view)),this.camera.lookAt(this.view.target),t}flyTo(e,t=700){let n=q_(this.view,e),r=W_(this.view);this.velocity={theta:0,phi:0},t<=0||matchMedia("(prefers-reduced-motion: reduce)").matches?(this.view=n,this.flight=null):this.flight={from:r,to:n,start:performance.now(),duration:t},this.events.change()}local(e){let t=this.el.getBoundingClientRect();return[e.clientX-t.left,e.clientY-t.top]}stopMotion(){this.flight=null,this.velocity={theta:0,phi:0}}onDown(e){this.el.setPointerCapture(e.pointerId);let t=this.pointers.size===0;if(this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY,button:e.button}),this.stopMotion(),t&&e.button===0&&this.events.grab?.(...this.local(e))){this.grabbing=!0;return}if(clearTimeout(this.holdTimer),this.held=!1,this.pointers.size===1){this.press={x:e.clientX,y:e.clientY,time:performance.now(),moved:!1};let[n,r]=this.local(e);this.holdTimer=setTimeout(()=>{!this.press||this.press.moved||this.pointers.size!==1||(this.held=!0,this.events.hold(n,r))},WC)}else this.press=null,this.pinch=this.pinchState()}onMove(e){let t=this.pointers.get(e.pointerId);if(!t)return;if(this.grabbing)return void this.events.drag?.(...this.local(e));if(this.swiping)return void this.events.swipeMove?.(e.clientY-this.swiping.startY);let[n,r]=[e.clientX-t.x,e.clientY-t.y];if(this.press&&!this.press.moved&&Math.hypot(e.clientX-this.press.x,e.clientY-this.press.y)>qC){this.press.moved=!0,clearTimeout(this.holdTimer);let[s,o]=this.local({clientX:this.press.x,clientY:this.press.y});if(this.pointers.size===1&&t.button===0&&!e.shiftKey&&this.events.swipeStart?.(s,o,e.clientX-this.press.x,e.clientY-this.press.y))return this.swiping={startY:this.press.y},this.velocity={theta:0,phi:0},void this.events.swipeMove?.(e.clientY-this.press.y)}if(this.locked){[t.x,t.y]=[e.clientX,e.clientY];return}if(this.walk){if(!(this.press&&!this.press.moved)&&this.pointers.size===1){let s=this.el.clientHeight||1;this.walk.yaw+=n/s*2.4,this.walk.pitch=ki(this.walk.pitch+r/s*1.8,-1.1,1.1),this.events.change()}[t.x,t.y]=[e.clientX,e.clientY];return}if(this.pointers.size===1)this.press&&!this.press.moved||(t.button===1||t.button===2||e.shiftKey?mm(this.view,n,r,this.el.clientHeight,this.camera.fov):this.velocity=$_(this.view,n,r,this.el.clientHeight)),[t.x,t.y]=[e.clientX,e.clientY];else{[t.x,t.y]=[e.clientX,e.clientY];let s=this.pinchState();this.pinch&&s&&(this.zoom(this.pinch.dist/Math.max(1,s.dist)),mm(this.view,s.mid[0]-this.pinch.mid[0],s.mid[1]-this.pinch.mid[1],this.el.clientHeight,this.camera.fov)),this.pinch=s}this.pointers.size===1&&this.press&&!this.press.moved||this.events.change()}onUp(e){if(this.pointers.has(e.pointerId)){if(this.pointers.delete(e.pointerId),this.grabbing)return this.grabbing=!1,void this.events.drop?.();if(this.swiping)return this.swiping=null,this.press=null,void this.events.swipeEnd?.();if(this.pointers.size<2&&(this.pinch=null),clearTimeout(this.holdTimer),this.held)this.held=!1,this.press=null;else if(this.press&&!this.press.moved&&e.type==="pointerup"&&performance.now()-this.press.timea*n);return{id:`${i.id}:vehicle`,type:e,x:i.x,z:i.z,rotation:i.rotation,w:r,d:s,h:o,variant:i.variant??null,entity:null,power:null}}function kh(i,e){let t=[],n=!1;for(let r of i.furniture){t.push(r);let s=r.type==="parking"?e.get(r.id):void 0,o=s?ZC(r,s):null;o&&(t.push(o),n=!0)}return n?{...i,furniture:t}:i}var JC="https://tile.openstreetmap.org/{z}/{x}/{y}.png";var jC=40075016686e-3,Bh=Math.PI/180,QC=18,eP=.5,tP=160;function nP(i,e,t){let n=2**t,r=(e+180)/360*n,s=(1-Math.log(Math.tan(i*Bh)+1/Math.cos(i*Bh))/Math.PI)/2*n;return[r,s]}var iP=(i,e)=>jC*Math.cos(i*Bh)/2**e;function J_(i,e,t,n=tP){let[r,s]=nP(i,e,t),o=iP(i,t),a=n/o,l=2**t-1,c=[];for(let u=Math.floor(s-a);u<=Math.floor(s+a);u++)for(let h=Math.floor(r-a);h<=Math.floor(r+a);h++){if(u<0||u>l)continue;let f=(h%(l+1)+l+1)%(l+1);c.push({x:f,y:u,z:t,east:(h-r)*o,north:-(u-s)*o,size:o})}return c}function j_(i,e){return i.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)).replace("{s}","abc"[(e.x+e.y)%3])}var Q_=i=>i.url&&i.url.startsWith("https://")?i.url:JC;function eM(i,e,t,n){let r=t*Bh;return[n.x+i*Math.cos(r)+e*Math.sin(r),n.z+i*Math.sin(r)-e*Math.cos(r)]}var tM=i=>!!i&&i.on===!0&&Number.isFinite(i.lat)&&Number.isFinite(i.lon),nM=i=>({x:i.x??0,z:i.z??0,opacity:i.opacity??eP,zoom:i.zoom??QC});var rP="strict-origin-when-cross-origin",gm=new Map;function iM(i){let e=gm.get(i);return e||(e=fetch(i,{referrerPolicy:rP,mode:"cors",credentials:"omit"}).then(async t=>t.ok&&(t.headers.get("content-type")??"").startsWith("image/")?await t.blob():null).catch(()=>null).then(t=>(t||setTimeout(()=>gm.delete(i),6e4),t)),gm.set(i,e)),e}var Xo=256,sP=Math.PI/180,zh=class{mesh=new Se(new sn(1,1),new Ye({transparent:!0,depthWrite:!1,side:ht}));canvas=null;texture=null;key="";generation=0;centre=[0,0];onChange=()=>{};scene;constructor(e){this.scene=e,this.mesh.rotation.order="YXZ",this.mesh.renderOrder=-2,this.mesh.visible=!1,this.mesh.name="live-map",e.add(this.mesh)}set(e,t,n,r=1){if(!tM(e)){this.mesh.visible=!1,this.generation++,this.key="";return}let s=nM(e),o=Q_(e),a=`${e.lat},${e.lon},${s.zoom},${o}`;a!==this.key&&this.load(a,e,s.zoom,o);let[l,c]=this.centre,[u,h]=eM(l,c,t,s);this.mesh.position.set(u,n,h),this.mesh.rotation.set(-Math.PI/2,-t*sP,0);let f=this.mesh.material;f.opacity=s.opacity,f.color.setScalar(r),this.mesh.visible=this.canvas!==null}load(e,t,n,r){this.key=e;let s=++this.generation,o=J_(t.lat,t.lon,n);if(!o.length)return;let a=o[0].size,l=Math.min(...o.map(x=>x.east)),c=Math.max(...o.map(x=>x.north)),u=Math.round((Math.max(...o.map(x=>x.east))-l)/a)+1,h=Math.round((c-Math.min(...o.map(x=>x.north)))/a)+1,f=document.createElement("canvas");f.width=u*Xo,f.height=h*Xo,this.canvas=f,this.texture?.dispose(),this.texture=new zt(f),this.texture.colorSpace=dt,this.texture.anisotropy=4;let d=this.mesh.material;d.map=this.texture,d.needsUpdate=!0,this.mesh.geometry.dispose(),this.mesh.geometry=new sn(u*a,h*a),this.centre=[l+u*a/2,c-h*a/2];let p=f.getContext("2d");if(p)for(let x of o)this.draw(p,x,r,s,Math.round((x.east-l)/a),Math.round((c-x.north)/a))}draw(e,t,n,r,s,o){iM(j_(n,t)).then(a=>a?createImageBitmap(a):null).then(a=>{!a||r!==this.generation||(e.drawImage(a,s*Xo,o*Xo,Xo,Xo),this.texture&&(this.texture.needsUpdate=!0),this.onChange())})}dispose(){this.generation++,this.scene.remove(this.mesh),this.mesh.geometry.dispose(),this.mesh.material.dispose(),this.texture?.dispose()}};var oP=globalThis,rM=oP.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},aP=rM.plugins,pz=rM.listeners;var lP=5;function cP(i,e){i.errors.lengthNumber.isFinite(a))&&Number.isFinite(r.level)))return i;let o=a=>Math.max(0,Math.min(1,a));return{color:[o(r.color[0]),o(r.color[1]),o(r.color[2])],level:o(r.level)}}catch(r){return cP(n.status,r),i}}var oM={rainbow:(i,e)=>{let t=(e*.08%1+1)%1,n=r=>Math.max(0,Math.min(1,Math.abs((t*6+r)%6-3)-1));return{color:[n(0),n(4),n(2)],level:i.level}},flicker:(i,e)=>({...i,level:i.level*(.75+.15*Math.sin(e*17)+.1*Math.sin(e*31+1))}),pulse:(i,e)=>({...i,level:i.level*(.65+.35*Math.sin(e*Math.PI))})};function aM(i,e,t){return!i||!e?i:Object.prototype.hasOwnProperty.call(oM,e)?oM[e]?.(i,t)??i:sM(i,e,t)}var Yo=2043986,Xr=2769520,lM=2242399,Vh=1845831,cM=1450554,gi=16758087,uM=1846349,hM=2572395,fM=1120816,dM=1845831,pM=3662079,mM=5995775,gM=9085695,Yr=Be(3662079,.08),xM=1.2,yM=1.5,bM=.2,vM=.52;function Gh(i,e,t,n,r,s){let o=(x,m,g)=>e(x,m,g),{x0:a,x1:l,n0:c,n1:u,y0:h,y1:f}=t,d=x=>Be(n.getHex(),x),p=[[o(a,c,f),o(l,c,f),o(l,u,f),o(a,u,f),r],[o(a,c,h),o(l,c,h),o(l,u,h),o(a,u,h),d(.6)],[o(a,u,h),o(l,u,h),o(l,u,f),o(a,u,f),n],[o(a,c,h),o(l,c,h),o(l,c,f),o(a,c,f),d(.85)],[o(a,c,h),o(a,u,h),o(a,u,f),o(a,c,f),d(.92)],[o(l,c,h),o(l,u,h),o(l,u,f),o(l,c,f),d(.92)]];for(let[x,m,g,y,_]of p)i.tri(x,m,g,_,_,_,void 0,s),i.tri(x,g,y,_,_,_,void 0,s)}function Vt(i,e,t,n,r,{cut:s,bucket:o}){if(t.y1<=s+1e-6)return Gh(i,e,t,n,r,$e);if(t.y0>=s-1e-6)return Gh(i,e,t,n,r,o);Gh(i,e,{...t,y1:s},n,r,$e),Gh(i,e,{...t,y0:s},n,r,o)}function ti(i,e,t,n,r,s,o,a,{cut:l,bucket:c},u=0){let h=(f,d,p)=>{let x=b=>u?(o-b)/u:.5,[m,g,y,_]=[e(t,r,f),e(n,r,f),e(n,r,d),e(t,r,d)];i.tri(m,g,y,a,a,a,[0,x(f),1,x(f),1,x(d)],p),i.tri(m,y,_,a,a,a,[0,x(f),1,x(d),0,x(d)],p)};o<=l+1e-6?h(s,o,$e):s>=l-1e-6?h(s,o,c):(h(s,l,$e),h(l,o,c))}function _M(i,e,t,n,r,s,o,a,l,c){let[u,h,f,d]=[e(t,r,o),e(n,r,o),e(n,s,o),e(t,s,o)],p=(s-r)/c;i.tri(u,h,f,a,a,a,[0,0,1,0,1,p],l),i.tri(u,f,d,a,a,a,[0,0,1,p,0,p],l)}var hP=16777215,fP=13225686,dP=15722456,MM=.08,SM=.085;function wM(i){let{info:e,state:t,frame:n,fold:r}=i;if(t.cover===null)return;let[s,o,a]=[e.width,e.sill,e.top],l=e.opening.blind??"roller",c=-e.faceOut,u=e.faceRoom;l==="inside"?Vt(i.frames,n,{x0:-.03,x1:s+.03,n0:u,n1:u+.07,y0:a-.02,y1:a+.07},new W(15921906),new W(16250871),r):Vt(i.frames,n,{x0:-.05,x1:s+.05,n0:c-.15,n1:c,y0:a,y1:a+.2},new W(cM),new W(Xr),r);let h=t.cover2!=null?[[0,s/2,t.cover,t.slats??0],[s/2,s,t.cover2,t.slats2??t.slats??0]]:[[0,s,t.cover,t.slats??0]];for(let[f,d,p,x]of h){let m=Math.min(1,Math.max(0,p));if(m<=.01)continue;let g=a-m*(a-o);l==="inside"?ti(i.blinds,n,f+.01,d-.01,u+.04,g,a-.02,new W(dP),r):l==="venetian"?pP(i,f,d,c-.07,g,a,x):ti(i.blinds,n,f,d,c-.07,g,a,new W(hP),r,.045)}}function pP(i,e,t,n,r,s,o){let{frame:a,fold:l}=i,c=new W(fP),u=Math.PI/2*(.12+.88*Math.min(1,Math.max(0,o))),h=Math.sin(u)*SM/2,f=Math.cos(u)*SM/2;for(let d=s-MM/2;d>r;d-=MM){let p=d>=l.cut?l.bucket:$e,[x,m,g,y]=[a(e,n-h,d+f),a(t,n-h,d+f),a(t,n+h,d-f),a(e,n+h,d-f)];i.blinds.tri(x,m,g,c,c,c,[0,.5,1,.5,1,.5],p),i.blinds.tri(x,g,y,c,c,c,[0,.5,1,.5,0,.5],p)}}function TM(i){let{info:e,state:t,frame:n,fold:r}=i,[s,o,a]=[e.width,e.top,Math.min(0,e.sill)],l=e.opening.type==="garage"&&(i.markClosed?!!t.sensed&&(t.cover??1)>=.95:(t.cover??1)<.95),c=l?Be(gi,.8):new W(Yo),u=l?Be(gi,1):new W(Xr),[h,f]=[-e.faceOut-.012,e.faceRoom+.012],d=(p,x,m)=>Vt(i.frames,n,{x0:p,x1:x,n0:h,n1:f,y0:m,y1:o+.045},c,u,r);d(-.045,.02,a),d(s-.02,s+.045,a),d(.02,s-.02,o-.02)}function AM(i){let{info:e,state:t,frame:n,fold:r,mid:s}=i,[o,a,l]=[e.width,e.top,Math.min(0,e.sill)],c=a-l,u=Sr(e.opening,e.exterior),h=u==="passage",f=K0(u),d=e.opening.swing==="out"?-1:1,p=d>0?e.faceRoom:-e.faceOut,x=e.opening.leaves===2,m=new W(Yo),g=new W(Xr),y=.02,_=o-.02,b=$0(o,u,e.hingeAtStart,e.opening);if(b){for(let[P,T]of b.panels){let R=(L,k,C,I)=>Vt(i.frames,n,{x0:L,x1:k,n0:s-.03,n1:s+.03,y0:C,y1:I},m,g,r);R(P,P+.04,l+.02,a-.02),R(T-.04,T,l+.02,a-.02),R(P,T,l+.02,l+.1),ti(i.glass,n,P+.04,T-.04,s,l+.1,a-.02,Yr,r)}y=b.x0,_=b.x1}let M=x?(_-y)/2-.004:_-y,S=f?.06:.04;f&&(Vt(i.frames,n,{x0:.02,x1:o-.02,n0:-e.faceOut-.02,n1:e.faceRoom,y0:l,y1:l+.02},new W(Vh),g,r),e.exterior&&Vt(i.frames,n,{x0:o/2-.08,x1:o/2+.08,n0:-e.faceOut-.1,n1:-e.faceOut,y0:a+.1,y1:a+.17},Be(gi,.55),Be(gi,.85),{cut:r.cut,bucket:$e}));let v=e.opening.open_angle?Math.min(180,Math.max(5,e.opening.open_angle))*mt:yM,w=h?[]:[[e.hingeAtStart,t.open]];x&&!h&&w.push([!e.hingeAtStart,t.open2??0]);for(let[P,T]of w){let R=Math.min(1,Math.max(0,T)),L=u==="sliding"?0:R*v,k=u==="sliding"?R*M:0,C=(Q,se,we)=>{let le=Q*Math.cos(L)-se*Math.sin(L)-k,Ne=p+d*(se*Math.cos(L)+Q*Math.sin(L)+(k?.05:0));return n(P?y+le:_-le,Ne,we)},I={cut:r.cut,bucket:R>.05?$e:r.bucket},O=i.markClosed?!!t.sensed&&R<.05:R>.9&&!(P===e.hingeAtStart&&t.assumed),F=O?Be(gi,.7):new W(f?fM:uM),H=O?Be(gi,.9):new W(f?dM:hM),U=(Q,se,we,le,Ne=-S,at=0)=>Vt(i.frames,C,{x0:Q,x1:se,n0:Ne,n1:at,y0:we,y1:le},F,H,I);u==="glass"?(U(0,.05,l+.01,a-.01),U(M-.05,M,l+.01,a-.01),U(.05,M-.05,l+.01,l+.12),U(.05,M-.05,a-.08,a-.01),ti(i.glass,C,.05,M-.05,-S/2,l+.12,a-.08,Yr,I)):U(0,M,l+.01,a-.01),u==="front_glass"?ti(i.glass,C,.12,M-.12,.001,l+c*.55,a-.18,Yr,I):f&&ti(i.glass,C,.1,.18,.001,l+.3,a-.3,Yr,I);let X=l+Math.min(1.05,c*.5),V=f?.3:.012,[re,ye]=f?[M-.11,M-.08]:[M-.16,M-.05],Y=(Q,se)=>Vt(i.frames,C,{x0:re,x1:ye,n0:Q,n1:se,y0:X-V,y1:X+V},new W(mM),new W(gM),I);if(Y(.004,.05),Y(-S-.05,-S-.004),t.unlocked){let Q=new W(pM);Vt(i.frames,C,{x0:M-.012,x1:M+.004,n0:-S-.004,n1:.004,y0:l+.06,y1:a-.06},Q,Q,{cut:r.cut,bucket:$e})}}}function EM(i){let{info:e,state:t,frame:n,fold:r}=i,[s,o,a]=[e.width,e.top,Math.min(0,e.sill)],l=Math.min(1,Math.max(0,t.cover??1)),c=new W(13951231),u=e.faceRoom-.03;l>.01&&ti(i.blinds,n,.02,s-.02,u,a+(o-a)*(1-l),o,c,r,.5);let h=(1-l)*(o-a);h>.01&&_M(i.blinds,n,.02,s-.02,u,u+h,o+.03,c,r.bucket,.5)}var mP=4936290,gP=7041926,RM=2764860,CM=9082024;function PM(i,e){let{info:t}=i;return t.opening.type!=="window"||!t.exterior||t.opening.light_well===!1?!1:t.opening.light_well===!0||t.sillVt(i.frames,n,{x0:g,x1:y,n0:_,n1:b,y0:c,y1:u},h,f,r);p(s-d,s,a-l,a),p(o,o+d,a-l,a),p(s-d,o+d,a-l-d,a-l),Vt(i.frames,n,{x0:s,x1:o,n0:a-l,n1:a,y0:c-d,y1:c},h,f,r);let x=(g,y)=>Vt(i.frames,n,{x0:g,x1:y,n0:a-l,n1:a,y0:u-.025,y1:u},new W(RM),new W(CM),r),m=Math.max(3,Math.round((o-s)/.06));for(let g=0;g<=m;g++){let y=s+(o-s)*g/m;x(y-.008,y+.008)}Vt(i.frames,n,{x0:s,x1:o,n0:a-l-.01,n1:a-l+.02,y0:u-.03,y1:u},new W(RM),new W(CM),r)}var ks={open:0,open2:0,tilt:0,tilt2:0,cover:null};function LM(i){let{info:e,frame:t,fold:n,mid:r}=i,[s,o,a]=[e.width,e.sill,e.top],[l,c]=[.04,.025],u=new W(Yo),h=new W(Xr),f=(y,_,b,M)=>Vt(i.frames,t,{x0:y,x1:_,n0:r-c,n1:r+c,y0:b,y1:M},u,h,n);i.first&&f(0,l,o,a),i.last&&f(s-l,s,o,a);let[d,p]=[i.first?l:-i.over[0],i.last?s-l:s+i.over[1]];f(d,p,o,o+.03),f(d,p,a-l,a);let x=e.opening.front?0:e.opening.panes,m=Math.max(1,x==null?Math.max(1,Math.round((p-d)/.9)):Math.round(x)),g=(p-d)/m;for(let y=1;yVt(i.frames,n,{x0:T,x1:R,n0:s-u,n1:s+u,y0:L,y1:k},h,f,r),x=a+(a>.05?c:.03);p(0,c,a,l),p(o-c,o,a,l),p(c,o-c,a,x),p(c,o-c,l-c,l);let m=e.opening.sill_boards??"auto";m!=="none"&&(m!=="auto"||a>.3)&&(m!=="outside"&&Vt(i.frames,n,{x0:-.04,x1:o+.04,n0:s+u,n1:e.faceRoom+.07,y0:a-.03,y1:a},d,f,r),e.exterior&&m!=="inside"&&Vt(i.frames,n,{x0:-.03,x1:o+.03,n0:-e.faceOut-.06,n1:s-u,y0:a-.04,y1:a-.02},d,f,r));let g=.055,[y,_]=[x,l-c],[b,M]=[s+u,s+u+.06],S=e.hingeAtStart,v=e.opening.opens??"turn",w=v==="slide"?xP(o,c,S,e.opening.leaves,t.open,t.open2??0):e.opening.leaves===2?[{atStart:S,x0:S?c:o/2,x1:S?o/2:o-c,open:t.open,tilt:t.tilt},{atStart:!S,x0:S?o/2:c,x1:S?o-c:o/2,open:t.open2??0,tilt:t.tilt2??0}]:[{atStart:S,x0:c,x1:o-c,open:t.open,tilt:t.tilt}],P=Sr(e.opening,e.exterior);for(let T of w){let R=v==="top"?Math.max(T.open,T.tilt)*vM:0,k=(v!=="slide"||!!T.slide)&&(T.open>.02||T.tilt>.02),C=i.markClosed?!!t.sensed&&!k:k,I=C?Be(gi,.75):new W(lM),O=C?Be(gi,.95):f,F=T.x1-T.x0,H=v==="turn",U=H?T.open*xM:0,X=H?T.tilt*bM:0,V=(T.slide??0)*T.open,re=v==="slide"&&T.track===0?-.065:0,ye=(se,we,le)=>{if(R>0){let[nt,Yt]=[we-b,le-_],[Bt,on]=[Math.cos(R),Math.sin(R)];return n(T.atStart?T.x0+se:T.x1-se,b+nt*Bt+Yt*on,_-nt*on+Yt*Bt)}let Ne=le-y,at=we+Ne*Math.sin(X)+re,Ae=y+Ne*Math.cos(X),ft=se*Math.cos(U)-(at-b)*Math.sin(U),yt=b+(at-b)*Math.cos(U)+se*Math.sin(U);return n((T.atStart?T.x0+ft:T.x1-ft)+V,yt,Ae)},Y={cut:r.cut,bucket:U>.05||R>.05?$e:r.bucket},Q=(se,we,le,Ne,at=b,Ae=M)=>Vt(i.frames,ye,{x0:se,x1:we,n0:at,n1:Ae,y0:le,y1:Ne},I,O,Y);if(Q(0,g,y,_),Q(F-g,F,y,_),Q(g,F-g,y,y+g),Q(g,F-g,_-g,_),ti(i.glass,ye,g,F-g,(b+M)/2,y+g,_-g,C?Be(gi,.16):Yr,Y),P==="bars"){let[se,we]=[(y+_)/2,(b+M)/2];Q(g,F-g,se-.012,se+.012,we-.012,we+.012),Q(F/2-.012,F/2+.012,y+g,_-g,we-.012,we+.012)}}}var xm=i=>i.opening.front??i.opening.id;function ym(i,e,t,n=-1/0){let r=new ut,s=new ut,o=new ut(!0),a=[],l=[],c=[],u=new Map;i.forEach((x,m)=>{let g=xm(x);u.set(g,[...u.get(g)??[],m])});let h=x=>[[x.start[0],x.start[1]],[x.start[0]+x.axis[0]*x.width,x.start[1]+x.axis[1]*x.width]],f=x=>`${Math.round(x[0]*50)},${Math.round(x[1]*50)}`,d=new Map,p=new Map;for(let x of u.values()){let m=new Map,g=new Map;for(let _ of x){let[b,M]=h(i[_]);m.set(f(b),[...m.get(f(b))??[],_]),g.set(f(M),[...g.get(f(M))??[],_])}let y=(_,b)=>{if(b==null||b===_)return 0;let M=Math.abs((i[_].faceRoom-i[_].faceOut)/2),[S,v]=[i[_].axis,i[b].axis],w=Math.max(-1,Math.min(1,S[0]*v[0]+S[1]*v[1])),P=Math.acos(w);return Pw!==_),v=(m.get(f(M))??[]).find(w=>w!==_);d.set(_,[S==null,v==null]),p.set(_,[y(_,S),y(_,v)])}}for(let x=0;x[m.start[0]+m.axis[0]*w+m.toRoom[0]*P,T,m.start[1]+m.axis[1]*w+m.toRoom[1]*P],mid:(m.faceRoom-m.faceOut)/2,markClosed:m.opening.mark==="closed",fold:{cut:t,bucket:m.bucket},frames:r,glass:s,blinds:o,first:b,last:M,over:p.get(x)??[0,0]};(y==="door"&&_!=="passage"||y==="garage")&&TM(S),y==="door"?AM(S):y==="garage"?EM(S):_==="glass_wall"?LM(S):FM(S),PM(S,n)&&IM(S,n),y!=="garage"&&wM(S);let v=xm(m);a.push({id:v,start:g.frames,end:r.count}),l.push({id:v,start:g.glass,end:s.count}),c.push({id:v,start:g.blinds,end:o.count})}return{frames:r.geometry(),glass:s.geometry(),blinds:o.geometry(),frameTris:a,glassTris:l,blindTris:c}}var bm=Math.PI/180,Ul=2400,qo=1600,vm=9,NM=360;function Hh(i,e=64){let t=document.createElement("canvas");t.width=t.height=e;let n=t.getContext("2d"),r=n.createRadialGradient(e/2,e/2,0,e/2,e/2,e/2);for(let[s,o]of i)r.addColorStop(s,o);return n.fillStyle=r,n.fillRect(0,0,e,e),new zt(t)}function yP(i){let t=document.createElement("canvas");t.width=128,t.height=128/2;let n=t.getContext("2d"),r=i*9301+49297,s=()=>(r=(r*9301+49297)%233280)/233280;for(let o=0;o<7;o++){let a=128*(.2+.6*s()),l=128/2*(.45+.25*s()),c=128*(.12+.14*s()),u=n.createRadialGradient(a,l,0,a,l,c);u.addColorStop(0,"rgba(255,255,255,0.9)"),u.addColorStop(.6,"rgba(255,255,255,0.45)"),u.addColorStop(1,"rgba(255,255,255,0)"),n.fillStyle=u,n.fillRect(0,0,128,128/2)}return new zt(t)}var Wh=class{group=new et;scene;bounds={x0:-10,x1:10,z0:-10,z1:10,y0:0,y1:8};view=null;rain;rainVel=new Float32Array(Ul*3);snow;snowPhase=new Float32Array(qo);hail;clouds=[];bolt;disc;halo;stars;cover;last=0;nextBolt=0;boltUntil=0;onFlash=null;constructor(e){this.scene=e,this.group.name="live-weather",this.group.renderOrder=5;let t=new Pe;t.setAttribute("position",new Le(new Float32Array(Ul*6),3)),this.rain=new xn(t,new Lt({color:11128309,transparent:!0,opacity:.5,depthWrite:!1}));let n=Hh([[0,"rgba(255,255,255,1)"],[.5,"rgba(255,255,255,0.6)"],[1,"rgba(255,255,255,0)"]],32),r=new Pe;r.setAttribute("position",new Le(new Float32Array(qo*3),3)),this.snow=new yn(r,new cn({color:16185855,size:.16,map:n,transparent:!0,opacity:.9,depthWrite:!1}));for(let h=0;h.02,this.stars.position.set((n.x0+n.x1)/2,n.y0,(n.z0+n.z1)/2),this.stars.scale.setScalar(r*3);let a=this.cover.material,l=(t?.snow??0)+(t?.hail??0)*.5,c=t?.rain??0;a.color.setHex(l>.05?16054527:1848656),a.opacity=l>.05?.3+.45*Math.min(1,l):c>.1?.25*Math.min(1,c):0,this.cover.visible=a.opacity>.02,this.cover.position.set((n.x0+n.x1)/2,n.y0-.18,(n.z0+n.z1)/2),this.cover.scale.set(n.x1-n.x0,n.z1-n.z0,1)}set(e){let t=this.view;this.view=e,this.group.visible=!!e;let n=e?.weather??null;if(e&&n&&n.fog>.02&&!e.low){let r=new W(e.sky[0]/255,e.sky[1]/255,e.sky[2]/255);this.scene.fog=new cs(r,.008+.04*n.fog)}else this.scene.fog instanceof cs&&(this.scene.fog=null);(!t||t.low!==e?.low||!!t.weather!=!!n)&&this.seed(),this.placeDisc(),this.placeNight(),n?.lightning||this.endBolt()}windVector(){let e=this.view?.weather;if(!e)return[0,0];let n=((e.windFrom??270)+(this.view?.north??0)+180)*bm,r=.4+7*e.wind;return[Math.sin(n)*r,-Math.cos(n)*r]}count(e,t){let n=this.view?.low??!1;return Math.round(Math.min(1,e)*t*(n?.3:1))}seed(){let e=this.bounds,t=this.view?.weather,n=()=>e.x0+Math.random()*(e.x1-e.x0),r=()=>e.z0+Math.random()*(e.z1-e.z0),s=()=>e.y0+Math.random()*(e.y1-e.y0),o=this.rain.geometry.getAttribute("position");for(let c=0;c.01,this.snow.visible=!!t&&t.snow>.01,this.hail.visible=!!t&&t.hail>.01,this.clouds.forEach((c,u)=>{c.angle=u/vm*Math.PI*2+Math.random()*.5,c.ring=1.7+Math.random()*.9,c.lift=.35+Math.random()*.35,c.scale=.55+Math.random()*.45,c.sx=e.x0+Math.random()*(e.x1-e.x0),c.sz=e.z0+Math.random()*(e.z1-e.z0)}),this.placeClouds(0)}placeClouds(e){let t=this.view,n=t?.weather,r=n?.cloud??0,s=this.bounds,o=(s.x0+s.x1)/2,a=(s.z0+s.z1)/2,l=Math.max(s.x1-s.x0,s.z1-s.z0),[c,u]=this.windVector(),h=Math.round(r*vm),f=t?.sky??[20,28,44],d=(f[0]+f[1]+f[2])/765,p=n?.rain||n?.lightning?.3:0,x=Math.max(.12,Math.min(1,.28+d*.9-p-.25*Math.max(0,r-.6))),m=Math.hypot(c,u)/Math.max(20,l*4)*e*Math.sign(c||1);this.clouds.forEach((g,y)=>{let _=ys.x1+S&&(g.sx=s.x0-S),g.sxs.z1+S&&(g.sz=s.z0-S),g.sz.9||!r&&t.elevation<.5){this.disc.visible=this.halo.visible=!1;return}let s=this.bounds,o=new D((s.x0+s.x1)/2,s.y0,(s.z0+s.z1)/2),a=Math.max(70,Math.max(s.x1-s.x0,s.z1-s.z0)*3.5),l=((r?t.azimuth+180:t.azimuth)+e.north)*bm,c=Math.max(8,Math.abs(t.elevation))*bm,u=new D(Math.sin(l)*Math.cos(c),Math.sin(c),-Math.cos(l)*Math.cos(c)),h=o.addScaledVector(u,a),f=a*(r?.07:.1);this.disc.position.copy(h),this.halo.position.copy(h),this.disc.scale.setScalar(f),this.halo.scale.setScalar(f*3.2);let d=this.disc.material,p=this.halo.material,x=r?0:Math.max(0,1-t.elevation/20);d.color.set(r?14016242:new W(1,.9-.25*x,.6-.35*x)),p.color.copy(d.color),d.opacity=(r?.7:.95)*(1-n),p.opacity=(r?.35:.6)*(1-n),this.disc.visible=this.halo.visible=!0}endBolt(){this.bolt.visible&&(this.bolt.visible=!1,this.onFlash?.(!1))}strike(e){let t=this.bounds,r=(Math.random()<.5?-1:1)<0?t.x0-2-Math.random()*6:t.x1+2+Math.random()*6,s=t.z0+Math.random()*(t.z1-t.z0),o=t.y1+4,a=this.bolt.geometry.getAttribute("position"),l=24,c=o;for(let u=0;u.01&&this.placeClouds(r),n.lightning&&!t.low?(this.nextBolt||(this.nextBolt=e+2500+Math.random()*6e3),e>=this.nextBolt&&(this.strike(e),this.nextBolt=e+3500+Math.random()*9e3),this.bolt.visible&&e>this.boltUntil&&this.endBolt()):this.nextBolt=0,this.rain.visible||this.snow.visible||this.hail.visible||n.cloud>.01||n.lightning}dispose(){this.endBolt(),this.group.traverse(e=>{let t=e;t.geometry?.dispose();let n=t.material;n?.map?.dispose(),n?.dispose()}),this.scene.remove(this.group),this.scene.fog instanceof cs&&(this.scene.fog=null)}};var Xh=46,Yh=33,Bs=900;function _m(){let i=document.createElement("canvas");i.width=i.height=32;let e=i.getContext("2d"),t=e.createRadialGradient(16,16,0,16,16,16);return t.addColorStop(0,"rgba(255,255,255,1)"),t.addColorStop(.35,"rgba(255,255,255,0.7)"),t.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=t,e.fillRect(0,0,32,32),new zt(i)}var qh=class{group=new et;scene;lift;tex=_m();arcs=new Map;sparkFields=[];sparks;sparkBase=new Float32Array(Bs*3);sparkField=new Int16Array(Bs);sparkPhase=new Float32Array(Bs);sparkCount=0;last=0;constructor(e,t){this.scene=e,this.lift=t,this.group.name="live-energy";let n=new Pe;n.setAttribute("position",new Le(new Float32Array(Bs*3),3)),n.setAttribute("color",new Le(new Float32Array(Bs*3),3)),this.sparks=new yn(n,new cn({size:.4,map:this.tex,vertexColors:!0,transparent:!0,depthWrite:!1,blending:Ft})),this.sparks.frustumCulled=!1,this.group.add(this.sparks),e.add(this.group)}get active(){return this.arcs.size>0||this.sparkCount>0}setArcs(e){let t=new Set(e.map(n=>n.key));for(let[n,r]of this.arcs)t.has(n)||(this.group.remove(r.line,r.points),r.line.geometry.dispose(),r.line.material.dispose(),r.points.geometry.dispose(),r.points.material.dispose(),this.arcs.delete(n));for(let n of e){let r=this.arcs.get(n.key);if(!r){let o=new Pe;o.setAttribute("position",new Le(new Float32Array(Yh*3),3));let a=new In(o,new Lt({transparent:!0,opacity:.4,depthWrite:!1,blending:Ft})),l=new Pe;l.setAttribute("position",new Le(new Float32Array(Xh*3),3));let c=new yn(l,new cn({size:.55,map:this.tex,transparent:!0,depthWrite:!1,blending:Ft}));a.frustumCulled=c.frustumCulled=!1;let u=new Float32Array(Xh);for(let h=0;hnew D):null,r.points.material.color.copy(s),r.count=n.power<=0?0:Math.max(3,Math.min(Xh,Math.round(3+Math.sqrt(n.power)/2.2))),r.speed=.18+Math.min(.5,Math.log10(1+n.power)*.1),r.points.geometry.setDrawRange(0,r.count)}this.place()}setSparks(e){this.sparkFields=e;let t=e.reduce((r,s)=>r+s.quads.length*s.level,0),n=0;t>0&&e.forEach((r,s)=>{if(r.level<=0)return;let o=Math.round(Bs*r.quads.length*r.level/Math.max(t,e.reduce((a,l)=>a+l.quads.length,0)));for(let a=0;a0}world(e,t){let n=this.lift(e.floorId);return t.set(e.x,n.y+e.y,e.z),n.visible}place(){for(let e of this.arcs.values()){if(e.path){this.placeRoute(e,e.path);continue}let t=this.world(e.arc.from,e.a),n=this.world(e.arc.to,e.b),r=e.a.distanceTo(e.b);e.c.copy(e.a).add(e.b).multiplyScalar(.5),e.c.y=Math.max(e.a.y,e.b.y)+.6+r*.22;let s=t&&n;e.line.visible=e.points.visible=s;let o=e.line.geometry.getAttribute("position");for(let a=0;ar=this.world(o,t[a])&&r),e.line.visible=e.points.visible=r,e.along=[0];for(let o=1;os.setXYZ(a,o.x,o.y,o.z)),e.line.geometry.setDrawRange(0,t.length),s.needsUpdate=!0}at(e,t){if(!e.path)return this.bezier(e,t);let n=e.along[e.along.length-1]||1,r=t*n,s=1;for(;s0}set(e,t){let n=new Set(e.map(r=>r.id));for(let[r,s]of this.spots)if(!n.has(r)){for(let o of s.rings)this.group.remove(o),o.material.dispose();this.spots.delete(r)}for(let r of e){let s=this.spots.get(r.id);if(!s){let a=Array.from({length:OM},()=>{let l=new Se(this.ringGeo,new Ye({transparent:!0,opacity:0,depthWrite:!1,blending:Ft,side:ht}));return l.rotation.x=-Math.PI/2,l.frustumCulled=!1,this.group.add(l),l});s={spot:r,rings:a},this.spots.set(r.id,s)}s.spot=r;let o=new W(r.color[0]/255,r.color[1]/255,r.color[2]/255);for(let a of s.rings)a.material.color.copy(o)}for(let r of this.links)this.group.remove(r.line),r.line.geometry.dispose(),r.line.material.dispose();this.links=t.map(([r,s])=>{let o=new Pe;o.setAttribute("position",new Le(new Float32Array(51),3));let a=new In(o,new Lt({color:12616956,transparent:!0,opacity:.55,depthWrite:!1,blending:Ft}));return a.frustumCulled=!1,this.group.add(a),{a:r,b:s,line:a}})}step(e){if(!this.spots.size&&!this.links.length)return!1;let t=e/1e3;for(let n of this.spots.values()){let r=this.lift(n.spot.at.floorId),s=.9+1.6*n.spot.level;n.rings.forEach((o,a)=>{let l=(t*.55+a/OM)%1;o.visible=r.visible,o.position.set(n.spot.at.x,r.y+n.spot.at.y,n.spot.at.z),o.scale.setScalar((.25+l*s)*(n.spot.size??1)),o.material.opacity=(1-l)*(.35+.5*n.spot.level)})}for(let n of this.links){let r=this.lift(n.a.floorId),s=this.lift(n.b.floorId);n.line.visible=r.visible&&s.visible;let o=n.line.geometry.getAttribute("position"),a=r.y+n.a.y,l=s.y+n.b.y,c=Math.hypot(n.a.x-n.b.x,n.a.z-n.b.z);for(let u=0;u<=16;u++){let h=u/16,f=Math.sin(Math.PI*h)*(.3+c*.12)+Math.sin(t*3+h*12)*.03;o.setXYZ(u,n.a.x+(n.b.x-n.a.x)*h,a+(l-a)*h+f,n.a.z+(n.b.z-n.a.z)*h)}o.needsUpdate=!0}return!0}dispose(){this.set([],[]),this.ringGeo.dispose(),this.scene.remove(this.group)}};var Kh=6,UM=24,DM=Kh*UM;function bP(i,e,t){let n=i%Kh,r=Math.floor(i/Kh),s=(r/UM+e*.7)%1,o=n/Kh*Math.PI*2+e*.35+(r*7%5-2)*.012,a=s*t,l=Math.min(1.2,t/3);return[Math.cos(o)*a,4*l*s*(1-s),Math.sin(o)*a]}var Zh=class{group=new et;scene;lift;tex=_m();material=new cn({color:11068159,size:.09,map:this.tex,transparent:!0,opacity:.9,depthWrite:!1});sprays=new Map;constructor(e,t){this.scene=e,this.lift=t,this.group.name="live-water",e.add(this.group)}get active(){return this.sprays.size>0}set(e){let t=new Set(e.map(n=>n.id));for(let[n,r]of this.sprays)t.has(n)||(this.group.remove(r.points),r.points.geometry.dispose(),this.sprays.delete(n));for(let n of e){let r=this.sprays.get(n.id);if(r){r.spot=n;continue}let s=new Pe;s.setAttribute("position",new Le(new Float32Array(DM*3),3));let o=new yn(s,this.material);o.frustumCulled=!1,this.group.add(o),this.sprays.set(n.id,{spot:n,points:o})}}step(e){if(!this.sprays.size)return!1;let t=e/1e3;for(let n of this.sprays.values()){let r=this.lift(n.spot.at.floorId);n.points.visible=r.visible,n.points.position.set(n.spot.at.x,r.y+n.spot.at.y,n.spot.at.z);let s=n.points.geometry.getAttribute("position");for(let o=0;on.value!==null&&Number.isFinite(n.value)&&Number.isFinite(n.level)).slice().sort((n,r)=>n.level-r.level);return Array.from({length:e},(n,r)=>{if(!t.length)return null;let s=(r+.5)/e;if(s<=t[0].level)return t[0].value;let o=t.findIndex(u=>u.level>=s);if(o<0)return t.at(-1).value;let a=t[o-1],l=t[o],c=l.level-a.level;return c>0?a.value+(l.value-a.value)*(s-a.level)/c:l.value})}function zs(i,e){let t=i.item;return new D(e[0]*(t.mirror?-1:1),e[1],e[2]).applyEuler(new Zn((t.tilt_x??0)*Math.PI/180,-t.rotation*Math.PI/180,(t.tilt_z??0)*Math.PI/180,"YZX")).add(new D(t.x,i.base,t.z))}var BM=i=>zs(i,[1,0,0]).sub(zs(i,[0,0,0]));function vP(i,e){let t=i.item,n=e.item,r=Uo(t),s=zs(i,[0,t.h/2,0]),o=zs(e,[0,n.h/2,0]),a=BM(i),l=BM(e),c=o.clone().sub(s).dot(a)>=0?1:-1,u=s.clone().sub(o).dot(l)>=0?1:-1,h=-1/0;for(let f of[i,e])for(let d of[-f.item.w/2,f.item.w/2])for(let p of[-f.item.d/2,f.item.d/2])for(let x of[0,f.item.h])h=Math.max(h,zs(f,[d,x,p]).z);return["primary_flow","primary_return"].map((f,d)=>{let p=zs(i,[c*t.w*.49,d?r.ys.back:r.ys.flow,d?r.blueZ:r.redZ]),x=zs(e,xh(n,u,d?.12:.88).end),m=p.clone().addScaledVector(a,c*.15),g=x.clone().addScaledVector(l,u*.15),y=h+.24+d*.07;return{medium:f,points:[p,m,new D(m.x,m.y,y),new D(g.x,m.y,y),new D(g.x,g.y,y),g,x]}})}var zM=i=>{let e=i.item;return[i.floorId,i.base,e.id,e.x,e.z,e.w,e.d,e.h,e.rotation,e.tilt_x??0,e.tilt_z??0,!!e.mirror].join("|")},Jh=class{views=new Map;parent;lift;constructor(e,t){this.parent=e,this.lift=t}remove(e){let t=new Set;e.group.traverse(n=>{n instanceof Se&&(n.geometry.dispose(),Array.isArray(n.material)?n.material.forEach(r=>t.add(r)):t.add(n.material))}),t.forEach(n=>n.dispose()),this.parent.remove(e.group)}set(e){let t=new Set;for(let n of e){if(n.item.type!=="freshwater_station"||!n.item.hydronic?.buffer_id)continue;let r=e.find(u=>u.id===n.item.hydronic.buffer_id&&u.floorId===n.floorId&&u.item.type==="buffer_tank");if(!r)continue;t.add(n.id);let s=this.views.get(n.id),o=zM(n)+"/"+zM(r);if(s?.key===o){s.station=n,s.buffer=r;continue}s&&this.remove(s);let a=new et;a.name=`hydronic-connection-${n.id}`;let l=Math.min(n.item.d*.05,.018),c=new D(0,1,0);for(let u of vP(n,r)){let h=new Ye({color:u.medium==="primary_flow"?12140088:3308718});for(let f=1;fi===null?new W(6910332):new W().setHSL((1-Math.max(0,Math.min(1,i/85)))*.62,.8,.55),MP=new W(1342650),VM=new W(12379625),SP=new W(13642552),jh=class{group=new et;views=new Map;scene;lift;connections;constructor(e,t){this.scene=e,this.lift=t,this.connections=new Jh(this.group,t),this.group.name="live-hydronics",e.add(this.group)}remove(e){e.group.traverse(t=>{t instanceof Se&&(t.geometry.dispose(),t.material.dispose())}),this.group.remove(e.group)}set(e){let t=new Set(e.map(n=>n.id));for(let[n,r]of this.views)t.has(n)||(this.remove(r),this.views.delete(n));for(let n of e){let r=this.views.get(n.id);r?.spot.item!==n.item&&(r&&this.remove(r),r=this.build(n),this.views.set(n.id,r)),r.spot=n,r.bands=n.item.type==="buffer_tank"?kM(n.probes):[]}this.connections.set(e)}build(e){let t=new et,n=[],r=e.item,s=El(r),o=(l,c,u,h,f,d={},p)=>{let x=new Se(p??(f==="temperature"?new ir(h,10,6):new Mi(h*1.6,h*.3,.012)),new Ye({color:6910332,depthWrite:!0}));x.name=`hydronic-${f}-${d.circulation?"circulation":d.station!==void 0?`station-${d.station}${f==="temperature"?`-${d.temp??0}`:""}`:d.circuit??d.probe??d.temp??0}`,x.position.set(l,c,u),t.add(x),n.push({mesh:x,kind:f,...d})},a=(l,c,u,h,f)=>{o(l,c,u+.001,h*.84,"pumpState",f,new Ca(h*.84,24));let d=[];for(let p=0;p<3;p++)for(let[x,m]of[[0,.1],[.28,.18],[0,.73]]){let g=p*Math.PI*2/3;d.push(h*(x*Math.cos(g)-m*Math.sin(g)),h*(x*Math.sin(g)+m*Math.cos(g)),0)}o(l,c,u+.002,h,"pump",f,new Pe().setAttribute("position",new Le(d,3)))};if(r.type==="heating_manifold"){let l=s.circuits??[];l.forEach((c,u)=>{let h=dh(r,c,u,l.length);Rl(c)&&a(h.flowX,h.pumpY,h.pumpFront,h.pumpR,{circuit:u}),Ls(c)&&o(h.flowX,h.valveY,h.valveFront+.003,h.valveR*.8,"valve",{circuit:u}),o(h.flowGaugeX,h.temperatureY,h.gaugeFront+.001,h.gaugeR*.45,"temperature",{circuit:u,temp:0}),o(h.returnGaugeX,h.temperatureY,h.gaugeFront+.001,h.gaugeR*.45,"temperature",{circuit:u,temp:1})})}else if(r.type==="buffer_tank"){(s.sensors??[]).forEach((l,c)=>o(0,r.h*(.1+.8*l.level),Math.min(r.w,r.d)*.46+.025,.021,"temperature",{probe:c}));for(let l=0;l<24;l++){let c=Math.min(r.w,r.d)*.464;o(0,r.h*(.1+.8*(l+.5)/24),0,c,"bufferBand",{band:l},new ds(c,c,r.h*.8/24,32,1,!0));let u=n.at(-1).mesh.material;u.transparent=!0,u.opacity=.8,u.depthWrite=!1}}else{let l=Uo(r);if(l.units.forEach((c,u)=>{let h=c.pump;if(a(h.x,h.y,h.front,h.r,{station:u}),c.valve){let f=c.valve;o(f.x,f.y,f.front+.003,f.r*.8,"valve",{station:u})}c.probes.forEach((f,d)=>o(f.x,f.y,f.front+.001,f.r*.5,"temperature",{station:u,temp:d}))}),l.circulationPipes.length){let c=l.circPump;a(c.x,c.y,c.front,c.r,{circulation:!0});let u=l.circProbe;o(u.x,u.y,u.front+.001,u.r*.5,"temperature",{temp:2})}}return t.rotation.set((r.tilt_x??0)*Math.PI/180,-r.rotation*Math.PI/180,(r.tilt_z??0)*Math.PI/180,"YZX"),t.scale.x=r.mirror?-1:1,t.name=`hydronic-${r.id}`,this.group.add(t),{spot:e,group:t,parts:n,bands:[]}}step(e){let t=!1;this.connections.step();for(let n of this.views.values()){let{spot:r}=n,s=this.lift(r.floorId);n.group.visible=s.visible,n.group.position.set(r.item.x,s.y+r.base,r.item.z);for(let o of n.parts){let a=o.circuit===void 0?void 0:r.circuits[o.circuit],l=o.station===void 0?void 0:r.stations?.[o.station];if(o.kind==="bufferBand"){let c=n.bands[o.band??0];if(o.mesh.visible=c!=null,c!=null){let u=Math.max(0,Math.min(1,(c-20)/45));o.mesh.material.color.copy(u<.5?MP:VM).lerp(u<.5?VM:SP,u<.5?u*2:(u-.5)*2)}}else if(o.kind==="temperature"){let c=o.station!==void 0?l?.temperatures[o.temp??0]:o.probe!==void 0?r.probes[o.probe]?.value:a?o.temp===0?a.flow:a.return:r.temperatures[o.temp??0];o.mesh.material.color.copy(_P(c??null))}else if(o.kind==="pump"||o.kind==="pumpState"){let c=o.station!==void 0?l?.pump??null:a?a.pump:o.circulation?r.circulation:r.pump;if(o.kind==="pumpState"){o.mesh.material.color.set(c===null?7501950:c?4953657:11019832);continue}o.mesh.material.color.set(c===null?11712441:14739417),o.mesh.rotation.z=Number(o.mesh.userData.angle??0)+(c&&r.animate!==!1?e/350:0),t||=s.visible&&c===!0&&r.animate!==!1}else{let c=o.station!==void 0?l?.valve:a?.valve;o.mesh.rotation.z=c==null?0:c/100*Math.PI/2,o.mesh.material.color.set(c==null?9015450:a?.cooling?5290239:9357674)}}}return t}dispose(){this.connections.dispose();for(let e of this.views.values())this.remove(e);this.views.clear(),this.scene.remove(this.group)}};var wP=Math.PI/180;function TP(){let i=document.createElement("canvas");i.width=i.height=64;let e=i.getContext("2d"),t=e.createRadialGradient(32,32,4,32,32,32);return t.addColorStop(0,"rgba(255,255,255,0.9)"),t.addColorStop(.5,"rgba(255,255,255,0.35)"),t.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=t,e.fillRect(0,0,64,64),new zt(i)}var Qh=class{group=new et;scene;lift;glowTex=TP();views=new Map;onChange=null;constructor(e,t){this.scene=e,this.lift=t,this.group.name="live-screens",e.add(this.group)}get active(){return[...this.views.values()].some(e=>e.s.playing)}set(e){let t=new Set(e.map(n=>n.id));for(let[n,r]of this.views)t.has(n)||this.drop(n,r);for(let n of e){let r=this.views.get(n.id);if(!r){let o=document.createElement("canvas");o.width=512,o.height=288;let a=new zt(o);a.colorSpace=dt;let l=new Se(new sn(1,1),new Ye({map:a,transparent:!0,toneMapped:!1}));l.renderOrder=6;let c=new Se(new sn(1,1),new Ye({map:this.glowTex,transparent:!0,depthWrite:!1,blending:Ft,side:ht}));c.renderOrder=2,this.group.add(l,c),r={s:n,sig:"",screen:l,glow:c,canvas:o,texture:a,image:null},this.views.set(n.id,r)}r.s=n;let s=[n.title,n.subtitle,n.app,n.picture,n.color.join(","),n.playing].join("|");if(s!==r.sig){let o=r.sig.split("|")[3]!==(n.picture??"");r.sig=s,o&&this.loadPicture(r),this.draw(r)}this.place(r)}}loadPicture(e){e.image=null;let t=e.s.picture;if(!t)return;let n=new Image;n.crossOrigin="anonymous",n.onload=()=>{e.s.picture!==t||!this.views.has(e.s.id)||(e.image=n,this.draw(e),this.onChange?.())},n.src=t}draw(e){let t=e.s,n=e.canvas.getContext("2d"),r=e.canvas.width,s=e.canvas.height,[o,a,l]=t.color,c=n.createLinearGradient(0,0,r,s);c.addColorStop(0,`rgb(${Math.round(o*.35)},${Math.round(a*.35)},${Math.round(l*.35)})`),c.addColorStop(1,"rgb(6,9,18)"),n.fillStyle=c,n.fillRect(0,0,r,s);let u=22,h=u;if(e.image){let f=s-u*2-30;n.save(),n.shadowColor=`rgba(${o},${a},${l},0.7)`,n.shadowBlur=24;let d=e.image.naturalWidth||1,p=e.image.naturalHeight||1,x=Math.max(f/d,f/p),m=f/x,g=f/x;n.drawImage(e.image,(d-m)/2,(p-g)/2,m,g,u,u,f,f),n.restore(),h=u*2+f}n.fillStyle="#ffffff",n.font="600 34px Figtree, Roboto, sans-serif",this.text(n,t.title||t.app||"",h,s/2-18,r-h-u),n.fillStyle="rgba(230,240,255,0.75)",n.font="26px Figtree, Roboto, sans-serif",this.text(n,t.subtitle,h,s/2+22,r-h-u),t.app&&(n.fillStyle=`rgb(${o},${a},${l})`,n.font="700 22px Figtree, Roboto, sans-serif",this.text(n,(t.playing?"\u25B6 ":"\u275A\u275A ")+t.app,h,s-u-14,r-h-u)),n.fillStyle=`rgba(${o},${a},${l},0.9)`,n.fillRect(0,s-6,r*(t.playing?1:.4),6),e.texture.needsUpdate=!0}text(e,t,n,r,s){let o=t;for(;o.length>1&&e.measureText(o).width>s;)o=o.slice(0,-2);e.fillText(o===t?o:`${o}\u2026`,n,r)}place(e){let t=e.s,n=t.rect,r=t.rotation*wP,s=this.lift(t.floorId),o=(n.x0+n.x1)/2,a=(p,x)=>[t.x+p*Math.cos(r)-x*Math.sin(r),t.z+p*Math.sin(r)+x*Math.cos(r)],l=n.x1-n.x0,c=n.y1-n.y0,[u,h]=a(o,n.z+.012);e.screen.position.set(u,s.y+(n.y0+n.y1)/2,h),e.screen.rotation.set(0,-r,0),e.screen.scale.set(l,c,1);let[f,d]=a(o,n.z-.18);e.glow.position.set(f,s.y+(n.y0+n.y1)/2,d),e.glow.rotation.set(0,-r,0),e.glow.scale.set(l*2.4,c*2.6,1),e.glow.material.color=new W(t.color[0]/255,t.color[1]/255,t.color[2]/255),e.screen.visible=s.visible,e.glow.visible=s.visible&&(t.ambilight??1)>0}step(e){let t=!1;for(let n of this.views.values()){this.place(n);let r=n.glow.material;r.opacity=(n.s.playing?.55+.25*Math.sin(e/900+n.s.x):.25)*Math.min(1.5,n.s.ambilight??1),t||=n.s.playing}return t}drop(e,t){this.group.remove(t.screen,t.glow),t.screen.geometry.dispose(),t.screen.material.dispose(),t.texture.dispose(),t.glow.geometry.dispose(),t.glow.material.dispose(),this.views.delete(e)}dispose(){for(let[e,t]of this.views)this.drop(e,t);this.glowTex.dispose(),this.scene.remove(this.group)}};var AP=Math.PI/180,EP="#f4f1ea",ef=class{group=new et;scene;lift;views=new Map;onChange=null;constructor(e,t){this.scene=e,this.lift=t,this.group.name="live-pictures",e.add(this.group)}set(e){let t=new Set(e.map(n=>n.id));for(let[n,r]of this.views)t.has(n)||this.drop(n,r);for(let n of e){let r=this.views.get(n.id);if(!r){let c=document.createElement("canvas"),u=new zt(c);u.colorSpace=dt;let h=new Se(new sn(1,1),new Ye({map:u,toneMapped:!1}));h.renderOrder=5,this.group.add(h),r={p:n,sig:"",mesh:h,canvas:c,texture:u,image:null},this.views.set(n.id,r)}let s=r.p.url!==n.url||!r.sig;r.p=n;let o=n.rect.x1-n.rect.x0,a=n.rect.y1-n.rect.y0,l=[n.url,n.border,n.fit,o.toFixed(3),a.toFixed(3)].join("|");l!==r.sig&&(r.sig=l,s&&this.load(r),this.draw(r)),this.place(r)}}load(e){e.image=null;let t=e.p.url,n=new Image;n.crossOrigin="anonymous",n.onload=()=>{e.p.url!==t||!this.views.has(e.p.id)||(e.image=n,this.draw(e),this.onChange?.())},n.src=t}draw(e){let t=e.p,n=Math.max(.01,t.rect.x1-t.rect.x0),r=Math.max(.01,t.rect.y1-t.rect.y0),s=600/Math.max(n,r),o=e.canvas.width=Math.max(16,Math.round(n*s)),a=e.canvas.height=Math.max(16,Math.round(r*s)),l=e.canvas.getContext("2d");l.fillStyle=t.border>0?EP:"#20242c",l.fillRect(0,0,o,a);let c=Math.round(Math.min(o,a)*Math.min(40,Math.max(0,t.border))/100),[u,h,f,d]=[c,c,o-2*c,a-2*c];if(e.image&&f>4&&d>4){let p=e.image.naturalWidth||1,x=e.image.naturalHeight||1;if(t.fit==="contain"){let m=Math.min(f/p,d/x);l.drawImage(e.image,u+(f-p*m)/2,h+(d-x*m)/2,p*m,x*m)}else{let m=Math.max(f/p,d/x),g=f/m,y=d/m;l.drawImage(e.image,(p-g)/2,(x-y)/2,g,y,u,h,f,d)}c>0&&(l.strokeStyle="rgba(0,0,0,0.25)",l.lineWidth=Math.max(1,c*.04),l.strokeRect(u,h,f,d))}else f>4&&d>4&&(l.fillStyle="#3a4250",l.fillRect(u,h,f,d));e.texture.needsUpdate=!0}place(e){let t=e.p,n=t.rect,r=t.rotation*AP,s=this.lift(t.floorId),o=(n.x0+n.x1)/2,a=n.z+.004;e.mesh.position.set(t.x+o*Math.cos(r)-a*Math.sin(r),s.y+(n.y0+n.y1)/2,t.z+o*Math.sin(r)+a*Math.cos(r)),e.mesh.rotation.set(0,-r,0),e.mesh.scale.set(n.x1-n.x0,n.y1-n.y0,1),e.mesh.visible=s.visible}step(){for(let e of this.views.values())this.place(e);return!1}drop(e,t){this.group.remove(t.mesh),t.mesh.geometry.dispose(),t.mesh.material.dispose(),t.texture.dispose(),this.views.delete(e)}dispose(){for(let[e,t]of this.views)this.drop(e,t);this.scene.remove(this.group)}};var tf=class extends An{constructor(){super(),this.name="RoomEnvironment",this.position.y=-3.5;let e=new Mi;e.deleteAttribute("uv");let t=new Ln({side:un}),n=new Ln,r=new gs(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let s=new Se(e,t);s.position.set(-.757,13.219,.717),s.scale.set(31.713,28.305,28.591),this.add(s);let o=new fs(e,n,6),a=new Et;a.position.set(-10.906,2.009,1.846),a.rotation.set(0,-.195,0),a.scale.set(2.328,7.905,4.651),a.updateMatrix(),o.setMatrixAt(0,a.matrix),a.position.set(-5.607,-.754,-.758),a.rotation.set(0,.994,0),a.scale.set(1.97,1.534,3.955),a.updateMatrix(),o.setMatrixAt(1,a.matrix),a.position.set(6.167,.857,7.803),a.rotation.set(0,.561,0),a.scale.set(3.927,6.285,3.687),a.updateMatrix(),o.setMatrixAt(2,a.matrix),a.position.set(-2.017,.018,6.124),a.rotation.set(0,.333,0),a.scale.set(2.002,4.566,2.064),a.updateMatrix(),o.setMatrixAt(3,a.matrix),a.position.set(2.291,-.756,-2.621),a.rotation.set(0,-.286,0),a.scale.set(1.546,1.552,1.496),a.updateMatrix(),o.setMatrixAt(4,a.matrix),a.position.set(-2.193,-.369,-5.547),a.rotation.set(0,.516,0),a.scale.set(3.875,3.487,2.986),a.updateMatrix(),o.setMatrixAt(5,a.matrix),this.add(o);let l=new Se(e,$o(50));l.position.set(-16.116,14.37,8.208),l.scale.set(.1,2.428,2.739),this.add(l);let c=new Se(e,$o(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(.1,2.425,2.751),this.add(c);let u=new Se(e,$o(17));u.position.set(14.904,12.198,-1.832),u.scale.set(.15,4.265,6.331),this.add(u);let h=new Se(e,$o(43));h.position.set(-.462,8.89,14.52),h.scale.set(4.38,5.441,.088),this.add(h);let f=new Se(e,$o(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,.1),this.add(f);let d=new Se(e,$o(100));d.position.set(0,20,0),d.scale.set(1,.1,1),this.add(d)}dispose(){let e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function $o(i){return new Oa({color:0,emissive:16777215,emissiveIntensity:i})}function Mm(i,e){if(e===xd)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===Ao||e===ja){let t=i.getIndex();if(t===null){let s=[],o=i.getAttribute("position");if(o!==void 0){for(let a=0;ao&&(L+=U,k+=X,C+=V)}let I=1/(Math.sqrt(L*L+k*k+C*C)||1);_[3*T+0]=L*I,_[3*T+1]=k*I,_[3*T+2]=C*I}}return t.setAttribute("normal",new wt(_,3,!1)),t}function HM(i){let e=new Map,t=new Map,n=i.clone();return WM(i,n,function(r,s){e.set(s,r),t.set(r,s)}),n.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=e.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(l){return t.get(l)}),s.bind(s.skeleton,s.bindMatrix)}),n}function WM(i,e,t){t(i,e);for(let n=0;n=2.0 are supported."));return}let c=new Jm(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,priority:this.priority,cache:this.cache,withCredentials:this.withCredentials,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,s){n.parse(e,t,r,s)})}};function RP(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}function kt(i,e,t){let n=i.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}var rt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DIFFUSE_ROUGHNESS:"KHR_materials_diffuse_roughness",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},Am=class{constructor(e){this.parser=e,this.name=rt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}},Vm=class{constructor(e){this.parser=e,this.name=rt.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=r.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}},Gm=class{constructor(e){this.parser=e,this.name=rt.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=r.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}},nf=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let r=n.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){let l=r.byteOffset||0,c=r.byteLength||0,u=r.count,h=r.byteStride,f=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,h,f,r.mode,r.filter).then(function(d){return d.buffer}):o.ready.then(function(){let d=new ArrayBuffer(u*h);return o.decodeGltfBuffer(new Uint8Array(d),u,h,f,r.mode,r.filter),d})})}else return null}},Hm=class{constructor(e){this.name=rt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let c of r.primitives)if(c.mode!==ni.TRIANGLES&&c.mode!==ni.TRIANGLE_STRIP&&c.mode!==ni.TRIANGLE_FAN&&c.mode!==void 0)return null;let o=n.extensions[this.name].attributes,a=[],l={};for(let c in o)a.push(this.parser.getDependency("accessor",o[c]).then(u=>(l[c]=u,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{let u=c.pop(),h=u.isGroup?u.children:[u],f=c[0].count,d=[];for(let p of h){let x=new ze,m=new D,g=new wn,y=new D(1,1,1),_=new fs(p.geometry,p.material,f);for(let M=0;M0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":i.search(/\.ktx2($|\?)/i)>0||i.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var DP=new ze,Jm=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new RP,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,s=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let l=a.match(/Version\/(\d+)/);r=n&&l?parseInt(l[1],10):-1,s=a.indexOf("Firefox")>-1,o=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&r<17||s&&o<98?(this.textureLoader=new ka(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)):(this.textureLoader=new Ga(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setWithCredentials(this.options.withCredentials),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new bo(this.options.manager),this.fileLoader.setPriority(this.options.priority),this.fileLoader.setCache(this.options.cache),this.fileLoader.setResponseType("arraybuffer"),(this.options.withCredentials||this.options.crossOrigin==="use-credentials")&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){let a={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:n,userData:{}};return Vs(s,a,r),Bi(a,r),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(let l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,s=t.length;r{let l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(let[c,u]of o.children.entries())s(u,a.children[c])};return s(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&m.setY(P,S[v*l+1]),l>=3&&m.setZ(P,S[v*l+2]),l>=4&&m.setW(P,S[v*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=p}return m})}loadTexture(e){let t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s],a=this.textureLoader;if(o.uri){let l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){let r=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];let c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);let f=(s.samplers||{})[o.sampler]||{};return u.magFilter=YM[f.magFilter]||Ht,u.minFilter=YM[f.minFilter]||Nn,u.wrapS=qM[f.wrapS]||zn,u.wrapT=qM[f.wrapT]||zn,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==Ut&&u.minFilter!==Ht,r.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){let n=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());let o=r.images[e],a=self.URL||self.webkitURL,l=o.uri||"",c=!1,u;if(t.isKTX2Loader===!0&&o.bufferView!==void 0)u=n.getDependency("bufferView",o.bufferView).then(function(f){return new Promise(function(d,p){t.parse(f,d,p)})});else{if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(f){c=!0;let d=new Blob([f],{type:o.mimeType});return l=a.createObjectURL(d),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");u=Promise.resolve(l).then(function(f){return new Promise(function(d,p){let x=d;t.isImageBitmapLoader===!0&&(x=function(m){let g=new Kt(m);g.needsUpdate=!0,d(g)}),t.load(cr.resolveURL(f,s.path),x,void 0,p)})})}let h=u.then(function(f){return c===!0&&a.revokeObjectURL(l),Bi(f,o),f.userData.mimeType=o.mimeType||OP(o.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),f});return this.sourceCache[e]=h,h}assignTexture(e,t,n,r){let s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[rt.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[rt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let l=s.associations.get(o);o=s.extensions[rt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new cn,gn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new Lt,gn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(r||s||o){let a="ClonedMaterial:"+n.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return Ln}loadMaterial(e){let t=this,n=this.json,r=this.extensions,s=n.materials[e],o,a={},l=s.extensions||{},c=[];if(l[rt.KHR_MATERIALS_UNLIT]){let h=r[rt.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),c.push(h.extendParams(a,s,t))}else{let h=s.pbrMetallicRoughness||{};if(a.color=new W(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){let f=h.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],Sn),a.opacity=f[3]}h.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",h.baseColorTexture,dt)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=ht);let u=s.alphaMode||wm.OPAQUE;if(u===wm.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===wm.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==Ye&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Ue(1,1),s.normalTexture.scale!==void 0)){let h=s.normalTexture.scale;a.normalScale.set(h,h)}if(s.occlusionTexture!==void 0&&o!==Ye&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==Ye){let h=s.emissiveFactor;a.emissive=new W().setRGB(h[0],h[1],h[2],Sn)}return s.emissiveTexture!==void 0&&o!==Ye&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,dt)),Promise.all(c).then(function(){let h=new o(a);return s.name&&(h.name=s.name),Bi(h,s),t.associations.set(h,{materials:e}),s.extensions&&Vs(r,h,s),h})}createUniqueName(e){let t=gt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function s(a){return n[rt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return $M(l,a,t)})}let o=[];for(let a=0,l=e.length;aMm(d,ja)):c.mode===ni.TRIANGLE_FAN&&(f=f.then(d=>Mm(d,Ao))),r[u]={primitive:c,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){let t=this,n=this.json,r=this.extensions,s=n.meshes[e],o=s.primitives,a=[];for(let l=0,c=o.length;l0&&FP(g,s),g.name=t.createUniqueName(s.name||"mesh_"+e),Bi(g,s),m.extensions&&Vs(r,g,m),t.assignFinalMaterial(g),h.push(g)}for(let d=0,p=h.length;d0){let d=u.userData.pivot,p=h[0];u.pivot=new D().fromArray(d),u.position.x-=d[0],u.position.y-=d[1],u.position.z-=d[2],p.position.set(0,0,0),delete u.userData.pivot}return u})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let s=t.nodes[e],o=s.name?r.createUniqueName(s.name):"",a=[],l=r._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),s.camera!==void 0&&a.push(r.getDependency("camera",s.camera).then(function(c){return r._getNodeRef(r.cameraCache,s.camera,c)})),r._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let u;if(s.isBone===!0?u=new go:c.length>1?u=new et:c.length===1?u=c[0]:u=new Et,u!==c[0])for(let h=0,f=c.length;h1){let h=r.associations.get(u);r.associations.set(u,{...h})}return r.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,s=new et;n.name&&(s.name=r.createUniqueName(n.name)),Bi(s,n),n.extensions&&Vs(t,s,n);let o=n.nodes||[],a=[];for(let l=0,c=o.length;l{let h=new Map;for(let[f,d]of r.associations)(f instanceof gn||f instanceof Kt)&&h.set(f,d);return u.traverse(f=>{let d=r.associations.get(f);d!=null&&h.set(f,d)}),h};return r.associations=c(s),s})}_createAnimationTracks(e,t,n,r,s){let o=[],a=e.name?e.name:e.uuid,l=[];function c(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}qr[s.path]===qr.weights?(c(e),e.isGroup&&e.children.forEach(c)):l.push(a);let u;switch(qr[s.path]){case qr.weights:u=sr;break;case qr.rotation:u=or;break;case qr.translation:case qr.scale:u=Dr;break;default:n.itemSize===1?u=sr:u=Dr;break}let h=r.interpolation!==void 0?PP[r.interpolation]:ji,f=this._getArrayFromAccessor(n);for(let d=0,p=l.length;d{let t=e;if(!t.isMesh)return;let n=t.geometry,r=t.material,s=r.name??"";t.userData.paint=!!r.userData?.paint||/^Paint/.test(s),n.getAttribute("normal")||(t.userData.paint?n.computeVertexNormals():t.geometry=GM(n,kP)),r.flatShading=!1;let o=/glass/i.test(s);r.metalness=t.userData.paint?.55:o?0:Math.min(r.metalness??0,.4),r.roughness=t.userData.paint?.28:o?.05:Math.max(r.roughness??.6,.45),o&&(r.transparent=!0,r.depthWrite=!1,r.opacity=Math.max(r.opacity,.9))})}function jM(i){let e=ZM.get(i);if(!e){let t=ag();if(!t)return Promise.resolve(!1);e=t(i).then(n=>n&&new Promise(r=>{new Zo().parse(n,"",s=>{BP(s.scene);let o=new Ct().setFromObject(s.scene),a=[o.max.x-o.min.x,o.max.y-o.min.y,o.max.z-o.min.z];s.scene.position.set(-(o.max.x+o.min.x)/2,-o.min.y,-(o.max.z+o.min.z)/2);let l=new et;l.add(s.scene),JM.set(i,{root:l,size:a}),lg(i),r({root:l,size:a})},()=>r(null))})).catch(()=>null),ZM.set(i,e)}return e.then(t=>!!t)}function QM(i,e){let t=JM.get(i);if(!t)return null;let n=t.root.clone(!0),r=[];n.traverse(o=>{let a=o;if(!a.isMesh)return;let l=a.material.clone();a.userData.paint&&e.paint&&(l.color=new W(e.paint)),a.material=l,r.push(l)});let s=new et;return s.add(n),s.scale.set((e.mirror?-1:1)*(e.w/t.size[0]),e.h/t.size[1],e.d/t.size[2]),s.position.set(e.x,e.y,e.z),s.rotation.y=-e.rotation*Math.PI/180,s.userData.own=r,s}function jm(i){for(let e of i.userData.own??[])e.dispose()}function e1(i,e){let t=new Ro(e),n=t.fromScene(new tf,.04).texture;t.dispose();let r=new ms(16777215,9081766,.9),s=new lr(16777215,1.6);return s.position.set(-4,9,6),i.add(r,s),{env:n,dispose:()=>{n.dispose(),r.removeFromParent(),s.removeFromParent()}}}function t1(i,e){for(let t of i.userData.own??[])t.envMap=e,t.envMapIntensity=.9}var zP=.3,n1=2.6,sf=.05;function VP(i,e,t,n){let r=n*.7071,s=[i,[i[0]+n,i[1]],[i[0]-n,i[1]],[i[0],i[1]+n],[i[0],i[1]-n]],o=[[i[0]+r,i[1]+r],[i[0]-r,i[1]+r],[i[0]+r,i[1]-r],[i[0]-r,i[1]-r]];return s.every(a=>Ge(a,e))&&!t.some(a=>[...s,...o].some(l=>Ge(l,a)))}function i1(i,e,t){let n=Math.ceil(Math.hypot(e[0]-i[0],e[1]-i[1])/sf);for(let r=1;rt+1e-6)&&r!==null){let a=o?s:s-sf;(!n||a-r>n[1]-n[0])&&(n=[r,a]),r=null}}return n}function r1(i,e=.32,t=.22,n=[]){let r=i.map(_=>_[0]),s=i.map(_=>_[1]),[o,a,l,c]=[Math.min(...r),Math.max(...r),Math.min(...s),Math.max(...s)],u=c-l>=a-o,h=_=>VP(_,i,n,t),f=(_,b)=>u?[_,b]:[b,_],[d,p,x,m]=u?[o,a,l,c]:[l,c,o,a],g=[],y=!0;for(let _=d+t;_<=p-t+1e-6;_+=e){let b=GP(w=>h(f(_,w)),x,m);if(!b||b[1]-b[0]<.2)continue;let M=w=>w?[f(_,b[0]),f(_,b[1])]:[f(_,b[1]),f(_,b[0])],S=M(y),v=g[g.length-1];if(v&&n.length>0&&!i1(v,S[0],h)){let w=M(!y);if(!i1(v,w[0],h))continue;S=w,y=!y}g.push(...S),y=!y}return g}function e0(i,e=.7,t=12){return Array.from({length:t},(n,r)=>[i[0]+Math.cos(r/t*Math.PI*2)*e,i[1]+Math.sin(r/t*Math.PI*2)*e])}var Qm=i=>Math.atan2(Math.sin(i),Math.cos(i));function s1(i,e,t){let n;if(e.mode==="cleaning"){if(i.path.length===0)return!1;n=i.path[i.next%i.path.length]}else if(e.mode==="returning"||e.mode==="docked")n=e.rest;else return!1;let[r,s]=[n[0]-i.pos[0],n[1]-i.pos[1]],o=Math.hypot(r,s);if(o<.02){if(e.mode==="cleaning")return i.next=(i.next+1)%i.path.length,!0;let l=Qm(e.restHeading-i.heading);return Math.abs(l)<.02?!1:(i.heading+=Math.sign(l)*Math.min(Math.abs(l),n1*t),!0)}let a=Qm(Math.atan2(r,s)-i.heading);if(i.heading=Qm(i.heading+Math.sign(a)*Math.min(Math.abs(a),n1*t)),Math.abs(a)<.35){let l=Math.min(o,zP*t);i.pos=[i.pos[0]+r/o*l,i.pos[1]+s/o*l]}return!0}var of=600*1e3,HP=3e3;function o1(i,e){if(i==null)return 1;let t=e-i;return t>of?Math.max(0,1-(t-of)/HP):1}function t0(i,e,t){let n=e/2,r=[],s=(a,l,c)=>r.push(a[0],t,a[1],l[0],t,l[1],c[0],t,c[1]);for(let a of i){for(let c=0;c+14?o=i.array[r*i.itemSize+s]:(s===0?o=i.getX(r):s===1?o=i.getY(r):s===2?o=i.getZ(r):s===3&&(o=i.getW(r)),i.normalized===!0&&(o=zr.normalize(o,i.array))),n.min[s]=Math.min(n.min[s],o),n.max[s]=Math.max(n.max[s],o)}return n}function f1(i){return Math.ceil(i/4)*4}function i0(i,e=0){let t=f1(i.byteLength);if(t!==i.byteLength){let n=new Uint8Array(t);if(n.set(new Uint8Array(i)),e!==0)for(let r=i.byteLength;r"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function jP(i,e){if(typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas){let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),i.convertToBlob({type:e,quality:t})}else return new Promise(t=>i.toBlob(t,e))}var s0=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r187"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map,normalMaps:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1,copyright:null},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);let r=this,s=r.buffers,o=r.json;n=r.options;let a=r.extensionsUsed,l=r.extensionsRequired,c=new Blob(s,{type:"application/octet-stream"}),u=Object.keys(a),h=Object.keys(l);if(u.length>0&&(o.extensionsUsed=u),h.length>0&&(o.extensionsRequired=h),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=c.size),n.copyright&&(o.asset.copyright=n.copyright),n.binary===!0){let f=new FileReader;f.readAsArrayBuffer(c),f.onloadend=function(){let d=i0(f.result),p=new DataView(new ArrayBuffer(h1));p.setUint32(0,d.byteLength,!0),p.setUint32(4,$P,!0);let x=i0(KP(JSON.stringify(o)),32),m=new DataView(new ArrayBuffer(h1));m.setUint32(0,x.byteLength,!0),m.setUint32(4,qP,!0);let g=new ArrayBuffer(u1),y=new DataView(g);y.setUint32(0,XP,!0),y.setUint32(4,YP,!0);let _=u1+m.byteLength+x.byteLength+p.byteLength+d.byteLength;y.setUint32(8,_,!0);let b=new Blob([g,m,x,p,d],{type:"application/octet-stream"}),M=new FileReader;M.readAsArrayBuffer(b),M.onloadend=function(){t(M.result)}}}else if(o.buffers&&o.buffers.length>0){let f=new FileReader;f.readAsDataURL(c),f.onloadend=function(){let d=f.result;o.buffers[0].uri=d,t(o)}}else t(o)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;let n=this.options,r=this.extensionsUsed;try{let s=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&s.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let o in s.gltfExtensions)t.extensions[o]=s.gltfExtensions[o],r[o]=!0;delete s.gltfExtensions}Object.keys(s).length>0&&(t.extras=s)}catch(s){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+s.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){let r=new Map;r.set(!0,this.uid++),r.set(!1,this.uid++),this.uids.set(e,r)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let n=new D;for(let r=0,s=e.count;r5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),r=new D;for(let s=0,o=n.count;s4?m=e.array[p*e.itemSize+x]:(x===0?m=e.getX(p):x===1?m=e.getY(p):x===2?m=e.getZ(p):x===3&&(m=e.getW(p)),e.normalized===!0&&(m=zr.normalize(m,e.array))),t===ot.FLOAT?u.setFloat32(h,m,!0):t===ot.INT?u.setInt32(h,m,!0):t===ot.UNSIGNED_INT?u.setUint32(h,m,!0):t===ot.SHORT?u.setInt16(h,m,!0):t===ot.UNSIGNED_SHORT?u.setUint16(h,m,!0):t===ot.BYTE?u.setInt8(h,m):t===ot.UNSIGNED_BYTE&&u.setUint8(h,m),h+=a}h%l!==0&&(h+=l-h%l)}let f={buffer:this.processBuffer(u.buffer),byteOffset:this.byteOffset,byteLength:c};return s!==void 0&&(f.target=s),s===ot.ARRAY_BUFFER&&(f.byteStride=l),this.byteOffset+=c,o.bufferViews.push(f),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(r){let s=new FileReader;s.readAsArrayBuffer(e),s.onloadend=function(){let o=i0(s.result),a={buffer:t.processBuffer(o),byteOffset:t.byteOffset,byteLength:o.byteLength};t.byteOffset+=o.byteLength,r(n.bufferViews.push(a)-1)}})}processAccessor(e,t,n,r){let s=this.json,o={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"},a;if(e.array.constructor===Float32Array)a=ot.FLOAT;else if(e.array.constructor===Int32Array)a=ot.INT;else if(e.array.constructor===Uint32Array)a=ot.UNSIGNED_INT;else if(e.array.constructor===Int16Array)a=ot.SHORT;else if(e.array.constructor===Uint16Array)a=ot.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)a=ot.BYTE;else if(e.array.constructor===Uint8Array)a=ot.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),(r===void 0||r===1/0)&&(r=e.count),r===0)return null;let l=JP(e,n,r),c;t!==void 0&&(c=e===t.index?ot.ELEMENT_ARRAY_BUFFER:ot.ARRAY_BUFFER);let u=this.processBufferView(e,a,n,r,c),h={bufferView:u.id,byteOffset:u.byteOffset,componentType:a,count:r,max:l.max,min:l.min,type:o[e.itemSize]};return e.normalized===!0&&(h.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(h)-1}processImage(e,t,n,r="image/png"){if(e!==null){let s=this,o=s.cache,a=s.json,l=s.options,c=s.pending;o.images.has(e)||o.images.set(e,{});let u=o.images.get(e),h=r+":flipY/"+n.toString();if(u[h]!==void 0)return u[h];a.images||(a.images=[]);let f={mimeType:r},d=r0();d.width=Math.min(e.width,l.maxTextureSize),d.height=Math.min(e.height,l.maxTextureSize);let p=d.getContext("2d",{willReadFrequently:!0});if(n===!0&&(p.translate(0,d.height),p.scale(1,-1)),e.data!==void 0){t!==Dn&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let m=new Uint8ClampedArray(e.height*e.width*4);for(let g=0;gs.processBufferViewImage(m)).then(m=>{f.bufferView=m})):f.uri=fo.getDataURL(d,r);let x=a.images.push(f)-1;return u[h]=x,x}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:Hn[e.magFilter],minFilter:Hn[e.minFilter],wrapS:Hn[e.wrapS],wrapT:Hn[e.wrapT]};return t.samplers.push(n)-1}async processTextureAsync(e){let n=this.options,r=this.cache,s=this.json;if(r.textures.has(e))return r.textures.get(e);s.textures||(s.textures=[]),e instanceof Or&&(e=await this.decompressTextureAsync(e,n.maxTextureSize));let o=e.userData.mimeType,a=this.processImage(e.image,e.format,e.flipY,o),l={sampler:this.processSampler(e)};o==="image/webp"?(l.extensions=l.extensions||{},l.extensions.EXT_texture_webp={source:a},this.extensionsUsed.EXT_texture_webp=!0,this.extensionsRequired.EXT_texture_webp=!0):l.source=a,e.name&&(l.name=e.name),await this._invokeAllAsync(async function(u){u.writeTexture&&await u.writeTexture(e,l)});let c=s.textures.push(l)-1;return r.textures.set(e,c),c}async processMaterialAsync(e,t){let n=this.cache,r=this.json,s=t!==void 0&&t.hasAttribute("tangent"),o=e.normalMap?e.uuid+":"+s:e.uuid;if(n.materials.has(o))return n.materials.get(o);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;r.materials||(r.materials=[]);let a={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let l=e.color.toArray().concat([e.opacity]);if(vr(l,[1,1,1,1])||(a.pbrMetallicRoughness.baseColorFactor=l),e.isMeshStandardMaterial?(a.pbrMetallicRoughness.metallicFactor=e.metalness,a.pbrMetallicRoughness.roughnessFactor=e.roughness):(a.pbrMetallicRoughness.metallicFactor=0,a.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){let u=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),h={index:await this.processTextureAsync(u),texCoord:u.channel};this.applyTextureTransform(h,u),a.pbrMetallicRoughness.metallicRoughnessTexture=h}if(e.map){let u={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(u,e.map),a.pbrMetallicRoughness.baseColorTexture=u}if(e.emissive){let u=e.emissive;if(Math.max(u.r,u.g,u.b)>0&&(a.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let f={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(f,e.emissiveMap),a.emissiveTexture=f}}if(e.normalMap){let u=e.normalScale,h=u.x<0,f=s?u.y<0:u.y>0,d=e.normalMap;if(h||f){n.normalMaps.has(e.normalMap)===!1&&n.normalMaps.set(e.normalMap,{});let x=n.normalMaps.get(e.normalMap),m=`${h}:${f}`;x[m]===void 0&&(x[m]=await this.buildNormalMapTextureAsync(e.normalMap,h,f)),d=x[m]}let p={index:await this.processTextureAsync(d),texCoord:e.normalMap.channel};Math.abs(u.x)!==1&&(p.scale=Math.abs(u.x)),this.applyTextureTransform(p,e.normalMap),a.normalTexture=p}if(e.aoMap){let u={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(u.strength=e.aoMapIntensity),this.applyTextureTransform(u,e.aoMap),a.occlusionTexture=u}e.transparent?a.alphaMode="BLEND":e.alphaTest>0&&(a.alphaMode="MASK",a.alphaCutoff=e.alphaTest),e.side===ht&&(a.doubleSided=!0),e.name!==""&&(a.name=e.name),this.serializeUserData(e,a),await this._invokeAllAsync(async function(u){u.writeMaterialAsync&&await u.writeMaterialAsync(e,a)});let c=r.materials.push(a)-1;return n.materials.set(o,c),c}async processMeshAsync(e){let t=this.cache,n=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let b=0,M=e.material.length;b0){let b=[],M=[],S={};if(e.morphTargetDictionary!==void 0)for(let v in e.morphTargetDictionary)S[e.morphTargetDictionary[v]]=v;for(let v=0;v0&&(l.extras={},l.extras.targetNames=M)}let x=Array.isArray(e.material);if(x&&o.groups.length===0)return null;let m=!1;if(x&&o.index===null){let b=[];for(let M=0,S=o.attributes.position.count;M0&&(S.targets=h),o.index!==null){let w=this.getUID(o.index);(y[b].start!==void 0||y[b].count!==void 0)&&(w+=":"+y[b].start+":"+y[b].count),t.attributes.has(w)?S.indices=t.attributes.get(w):(S.indices=this.processAccessor(o.index,o,y[b].start,y[b].count),t.attributes.set(w,S.indices)),S.indices===null&&delete S.indices}let v=await this.processMaterialAsync(g[y[b].materialIndex],o);v!==null&&(S.material=v),u.push(S)}m===!0&&o.setIndex(null),l.primitives=u,n.meshes||(n.meshes=[]),await this._invokeAllAsync(function(b){b.writeMesh&&b.writeMesh(e,l)});let _=n.meshes.push(l)-1;return t.meshes.set(s,_),_}detectMeshQuantization(e,t){if(this.extensionsUsed[n0])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");let r=e.split("_",1)[0];l1[r]&&l1[r].includes(n)&&(this.extensionsUsed[n0]=!0,this.extensionsRequired[n0]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,r={type:n?"orthographic":"perspective"};return n?r.orthographic={xmag:e.right,ymag:e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:zr.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let n=this.json,r=this.nodeMap;n.animations||(n.animations=[]),e=$r.Utils.mergeMorphTargetTracks(e.clone(),t);let s=e.tracks,o=[],a=[];for(let c=0;c0){let a=[];for(let l=0,c=e.children.length;l0&&(s.children=a)}return await this._invokeAllAsync(function(a){a.writeNode&&a.writeNode(e,s)}),o}async _processNodeWithPivotAsync(e){let t=this.json,n=this.options,r=this.nodeMap,s=e.pivot,o={},a=e.quaternion.toArray(),l=[e.position.x+s.x,e.position.y+s.y,e.position.z+s.z],c=e.scale.toArray();vr(a,[0,0,0,1])||(o.rotation=a),vr(l,[0,0,0])||(o.translation=l),vr(c,[1,1,1])||(o.scale=c),o.extras={pivot:s.toArray()},e.name!==""&&(o.name=String(e.name)),this.serializeUserData(e,o);let u=t.nodes.push(o)-1;r.set(e,u);let h={},f=[-s.x,-s.y,-s.z];if(vr(f,[0,0,0])||(h.translation=f),e.isMesh||e.isLine||e.isPoints){let x=await this.processMeshAsync(e);x!==null&&(h.mesh=x)}else e.isCamera&&(h.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);let p=[t.nodes.push(h)-1];if(e.children.length>0){let x=[];for(let m=0,g=e.children.length;m0&&(h.children=x)}return o.children=p,await this._invokeAllAsync(function(x){x.writeNode&&x.writeNode(e,o)}),u}async processSceneAsync(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};e.name!==""&&(r.name=e.name),t.scenes.push(r);let s=[];for(let o=0,a=e.children.length;o0&&(r.nodes=s),this.serializeUserData(e,r)}async processObjectsAsync(e){let t=new An;t.name="AuxScene";for(let n=0;n0&&await this.processObjectsAsync(n);for(let r=0;r0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(1-e.penumbra)*e.angle,o.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),s[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},s[this.name]=!0);let a=r.extensions[this.name].lights;a.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}},a0=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,t){if(!e.isMeshBasicMaterial)return;let r=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},l0=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;let n=this.writer,r=n.extensionsUsed,s={};if(s.clearcoatFactor=e.clearcoat,e.clearcoatMap){let o={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(o,e.clearcoatMap),s.clearcoatTexture=o}if(s.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let o={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(o,e.clearcoatRoughnessMap),s.clearcoatRoughnessTexture=o}if(e.clearcoatNormalMap){let o={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(o.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(o,e.clearcoatNormalMap),s.clearcoatNormalTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},c0=class{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;let r=this.writer.extensionsUsed,s={};s.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},u0=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;let n=this.writer,r=n.extensionsUsed,s={};if(s.iridescenceFactor=e.iridescence,e.iridescenceMap){let o={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(o,e.iridescenceMap),s.iridescenceTexture=o}if(s.iridescenceIor=e.iridescenceIOR,s.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum,s.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum,e.iridescenceThicknessMap){let o={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(o,e.iridescenceThicknessMap),s.iridescenceThicknessTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},h0=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,s={};if(s.transmissionFactor=e.transmission,e.transmissionMap){let o={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(o,e.transmissionMap),s.transmissionTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},f0=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,s={};if(s.thicknessFactor=e.thickness,e.thicknessMap){let o={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(o,e.thicknessMap),s.thicknessTexture=o}e.attenuationDistance!==1/0&&(s.attenuationDistance=e.attenuationDistance),s.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},d0=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;let r=this.writer.extensionsUsed,s={};s.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},p0=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(WP)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,r=n.extensionsUsed,s={};if(e.specularIntensityMap){let o={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(o,e.specularIntensityMap),s.specularTexture=o}if(e.specularColorMap){let o={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(o,e.specularColorMap),s.specularColorTexture=o}s.specularFactor=e.specularIntensity,s.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},m0=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;let n=this.writer,r=n.extensionsUsed,s={};if(e.sheenRoughnessMap){let o={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(o,e.sheenRoughnessMap),s.sheenRoughnessTexture=o}if(e.sheenColorMap){let o={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(o,e.sheenColorMap),s.sheenColorTexture=o}s.sheenRoughnessFactor=e.sheenRoughness,s.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},g0=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;let n=this.writer,r=n.extensionsUsed,s={};if(e.anisotropyMap){let o={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(o,e.anisotropyMap),s.anisotropyTexture=o}s.anisotropyStrength=e.anisotropy,s.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},x0=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;let r=this.writer.extensionsUsed,s={};s.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},y0=class{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;let n=this.writer,r=n.extensionsUsed,s={};if(e.bumpMap){let o={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(o,e.bumpMap),s.bumpTexture=o}s.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},b0=class{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,r=e,s=new Float32Array(r.count*3),o=new Float32Array(r.count*4),a=new Float32Array(r.count*3),l=new ze,c=new D,u=new wn,h=new D;for(let d=0;di.times[i.times.length-1]){if(Math.abs(i.times[i.times.length-1]-e)<.001)return i.times.length-1;r[r.length-1]=e,r.set(i.times,0),s.set(i.values,0),s.set(o.evaluate(e),i.values.length),a=r.length-1}else for(let l=0;le){r.set(i.times.slice(0,l+1),0),r[l+1]=e,r.set(i.times.slice(l+1),l+2),s.set(i.values.slice(0,(l+1)*n),0),s.set(o.evaluate(e),(l+1)*n),s.set(i.values.slice((l+1)*n),(l+2)*n),a=l+1;break}}return i.times=r,i.values=s,a},mergeMorphTargetTracks:function(i,e){let t=[],n={},r=i.tracks;for(let s=0;sQP.test(r.name)).map(r=>r.name);if(e.length>0)return e;let n=[...i.filter(r=>r.opacity>=.9&&r.lightness>.12&&!/glass|window|light|lamp/i.test(r.name))].sort((r,s)=>s.area-r.area)[0];return n?[n.name]:[]}function p1(i,e){let t=i.reduce((r,s)=>r+s,0);if(t<=e)return[...i];let n=e/t;return i.map(r=>Math.max(1,Math.floor(r*n)))}var m1=i=>/^Paint/.test(i)?i:`Paint_${i||"body"}`;var Jo=i=>i.indices.length/3;function eI(i){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let n=0;nMath.floor(o/t)+1),s=new Float64Array(n);for(let o=0;oe?r=l:(s=l,o=c)}return nI(i,o)}var zi=class extends Error{reason;constructor(e,t){super(t),this.reason=e}},iI=1179937895;function rI(i){if(i.byteLength<20||new DataView(i).getUint32(0,!0)!==iI)throw new zi("not_glb","not a binary glTF (.glb) file")}async function v0(i){return rI(i),new Promise((e,t)=>{new Zo().parse(i,"",n=>e(n.scene),n=>{let r=String(n?.message??n);t(/draco|meshopt|ktx/i.test(r)?new zi("compressed",r):new zi("unreadable",r))})})}var sI=i=>i instanceof Ln?i:Object.assign(new Ln,{color:i.color?.clone()??new W(8947848),name:i.name,opacity:i.opacity,transparent:i.transparent});function y1(i,e){i.updateMatrixWorld(!0);let t=new Map;return i.traverse(n=>{let r=n;if(!r.isMesh)return;let s=r.geometry,o=s.getAttribute("position");if(!o)return;let a=sI(Array.isArray(r.material)?r.material[0]:r.material),l=t.get(a)??{positions:[],indices:[]};t.set(a,l);let c=new ze().multiplyMatrices(e,r.matrixWorld),u=l.positions.length/3,h=new D;for(let p=0;p({material:n,mesh:{positions:Float32Array.from(r.positions),indices:Uint32Array.from(r.indices)}}))}var oI=i=>{let e=0,[t,n,r]=[new D,new D,new D];for(let s=0;s.299*i.r+.587*i.g+.114*i.b;async function lI(i){let e=y1(await v0(i),new ze);if(e.length===0)throw new zi("empty","the file has no 3D parts");let t=new Ct;for(let s of e)t.union(new Ct().setFromArray(s.mesh.positions));let n=t.getSize(new D),r=e.map(s=>({name:s.material.name||"material",area:oI(s.mesh),opacity:s.material.opacity,lightness:aI(s.material.color)}));return{triangles:e.reduce((s,o)=>s+Jo(o.mesh),0),size:[n.x,n.y,n.z],materials:r,paint:d1(r)}}async function cI(i,e){let t=new ze().makeRotationY(e.turns*Math.PI/2),n=y1(await v0(i),t);if(n.length===0)throw new zi("empty","the file has no 3D parts");let r=p1(n.map(l=>Jo(l.mesh)),e.maxTriangles),s=new An,o=0;return n.forEach((l,c)=>{let u=x1(l.mesh,r[c]);if(Jo(u)===0)return;o+=Jo(u);let h=new Pe;h.setAttribute("position",new wt(u.positions,3)),h.setIndex(new wt(u.indices,1));let f=l.material.name||"material",d=e.paint.includes(f),p=new Ln({color:l.material.color.clone(),name:d?m1(f):f,metalness:l.material.metalness,roughness:l.material.roughness,opacity:l.material.opacity,transparent:l.material.opacity<1});d&&(p.userData.paint=!0),s.add(new Se(h,p))}),{glb:await new Promise((l,c)=>{new $r().parse(s,u=>u instanceof ArrayBuffer?l(u):c(new zi("unreadable","export gave no binary")),u=>c(new zi("unreadable",String(u))),{binary:!0})}),triangles:o}}async function uI(i,e,t=220){let n=await v0(i),r=new Ct().setFromObject(n),s=r.getCenter(new D),o=r.getSize(new D);n.traverse(d=>{let p=d;if(!p.isMesh)return;let x=p.material;(x.userData?.paint||/^Paint/.test(x.name))&&x.color.set(e),x.metalness=Math.min(x.metalness??0,.5)});let a=new An,l=new lr(16777215,1.6);l.position.set(-4,9,6),a.add(n,new Va(16777215,.5),new ms(16777215,6713480,1.1),l);let c=Math.max(o.x,o.y,o.z)*.75,u=new Vn(-c,c,c,-c,.01,100);u.position.copy(s).add(new D(.9,.7,1.2).normalize().multiplyScalar(20)),u.lookAt(s);let h=new Vr({alpha:!0,antialias:!0,preserveDrawingBuffer:!0});h.setSize(t,t,!1),h.render(a,u);let f=h.domElement.toDataURL("image/png");return h.dispose(),a.traverse(d=>{let p=d;p.isMesh&&p.geometry.dispose()}),f}var jo=null,b1=new Map,v1=16758087;function hI(i,e,t){let n=_t(i.type);if(n?.light)cl(e,n,{x:0,z:0,rotation:0,w:i.w,d:i.d,h:i.h},0,v1);else if(i.lamp)_0(e,{x:0,z:0,size:[i.w,i.d,i.h],base:0,rotation:0,variant:i.variant??null,lamp:i.lamp},Math.max(i.h+.15,.6),v1);else{let r={id:"preview",type:i.type,x:0,z:0,rotation:0,w:i.w,d:i.d,h:i.h,variant:i.variant??null,entity:null,power:null};Il(e,t,new ut,r)}}function fI(i){let e=i.getCenter(new D),t=new Vn(-1,1,1,-1,.01,100);t.position.copy(e).add(new D(.9,.75,1.3).normalize().multiplyScalar(20)),t.lookAt(e),t.updateMatrixWorld();let n=.05;for(let s of[i.min.x,i.max.x])for(let o of[i.min.y,i.max.y])for(let a of[i.min.z,i.max.z]){let l=new D(s,o,a).applyMatrix4(t.matrixWorldInverse);n=Math.max(n,Math.abs(l.x),Math.abs(l.y))}let r=n*1.12;return Object.assign(t,{left:-r,right:r,top:r,bottom:-r}),t.updateProjectionMatrix(),t}function dI(i,e=180,t,n=1.3){let r=[i.type,i.w,i.d,i.h,i.variant??"",e,n].join("|"),s=b1.get(r);if(s)return s;t&&Wl(t),jo??=new Vr({alpha:!0,antialias:!0,preserveDrawingBuffer:!0}),jo.setPixelRatio(Math.min(2,window.devicePixelRatio||1)),jo.setSize(e,e,!1),jo.setClearColor(0,0);let[o,a]=[new ut,new Wt];hI(i,o,a);let l=new Se(o.geometry(),new Ye({vertexColors:!0,color:new W(n,n,n)})),c=new xn(a.geometry(),new Lt({vertexColors:!0,color:new W(n*1.8,n*1.8,n*1.8)})),u=new An;u.add(l,c),jo.render(u,fI(new Ct().setFromObject(l)));let h=jo.domElement.toDataURL("image/png");for(let f of[l,c])f.geometry.dispose(),f.material.dispose();return b1.set(r,h),h}var M1={cleaning:3662079,returning:16758087,docked:4310123,idle:5995775,error:16726863},pI=1.4,S0=32,Je=2767456,S1=4873352,mI=1911110,M0=450,w1=125,gI=1.6,T1=3e4,E1=5,R1=360/E1,xI=new W(1714765),A1=.94;var w0=class{host;options;renderer;scene=new An;camera=new Jt(38,1,.1,400);controls;labels;root=new et;patternTexture;blindTexture;openingTargets=new Map;fridges=new Map;covers=new Map;screens=new Map;pickFurniture=new Map;pickOpenings=new Map;pickOpenings2=new Map;flashes=new Map;surfaceGrab=null;surfaceDragging=!1;furnishTypes=null;roofWindows=new Map;roofWindowsKey="";persons=[];personPins=new Map;floorInfo=new Map;roomInfo=new Map;groundTexture=null;devices=[];devicePins=new Map;ground;floors=[];building=null;furnitureColors=null;notePhoto=null;floorId=null;roomId=null;wallMode="auto";painted=!1;explode;frame=0;lastFrame=0;qualityMode="auto";governor=null;disposed=!1;resizeObserver;fpsFrames=0;worstFrame=0;lastStatsFrame=0;lowQuality=!1;highQuality=!1;effectTime=0;effectTick=!1;tintTick=!1;effectTimer;awakeUntil=0;deviceLook="";haloTexture;roof=null;roofO=0;keepRoof=!1;robots=new Map;pets=new Map;petMat=null;petTimer;robotGeo=null;robotTrails=new Map;trailTimers=new Map;robotMat=null;mowerMat=null;robotLedGeo=null;robotLast=0;petLast=0;meshes=[];meshLight=null;meshAsked=new Set;robotTimer;floorStack="dim";floorMap=new Map;labelsDirty=!0;viewKey=new Float64Array(6);pinMode=new WeakMap;size={w:1,h:1};labelInset=0;effectFloors=new Set;deviceFloor=new Map;statsOn=!1;parked=new Map;parkedSig="";plain=!1;rightBack=!1;rightDown=null;gateOpen=new Map;gateSig="";orbitSpeed=0;orbitLast=0;orbitTimer;onScreen=!0;intersection=null;swipe=null;furnish=!1;selectedFurniture=null;selectedDevice=null;pendingDevice=null;labelPlacer=new qu;pinHooks={furnishing:()=>this.furnish,pressedWhileFurnishing:e=>this.pendingDevice=e,selectWhileFurnishing:e=>{this.selectDevice(e),this.options.onDeviceSelect?.(e)},centre:e=>{let[t,n]=[e.getBoundingClientRect(),this.host.getBoundingClientRect()];return{x:t.left+t.width/2-n.left,y:t.top+t.height/2-n.top}},tap:(e,t,n)=>{let r=this.tapInRoom?this.devices.find(s=>s.id===e):void 0;if(r&&!this.deviceInReach(r.floorId,r.roomId))return this.options.onRoomTap?.(r.floorId,r.roomId);this.options.onDeviceTap?.(e,t,n)},hold:(e,t,n)=>this.options.onDeviceHold?.(e,t,n)};tapInRoom=!1;deviceGrab=null;grab=null;ghost=null;theme="neon";themeUniform={value:0};sun=null;weatherLayer;houseShadow=new Zu;sunArc=new sh;sunArcLocation=null;shadowKey="";footprint={key:"",rings:[]};mapLayer;mapSettings=null;mapNorth=0;groundY=0;skyView=null;weatherTimer;energyLayer;soundLayer;waterLayer;hydronicLayer;glassAlpha={value:.2};screenLayer;pictureLayer;liveAnchors=[];liveAnchorCb=null;roomTint=null;houseRadius=20;startView=null;fpsStart=0;constructor(e,t={}){this.host=e,this.options=t,this.explode=t.explode??!0,this.qualityMode=t.quality??"auto",this.renderer=this.makeRenderer(this.qualityMode),this.labels=document.createElement("div"),this.labels.className="nf-labels",e.append(this.labels),this.patternTexture=yI(),this.blindTexture=bI(),this.haloTexture=_I(),this.ground=new Se(new sn(1,1),new Ye({transparent:!0,blending:Ft,depthWrite:!1})),this.ground.rotation.x=-Math.PI/2,this.ground.renderOrder=-1,this.scene.add(this.ground,this.root),this.weatherLayer=new Wh(this.scene),this.scene.add(this.houseShadow.mesh),this.scene.add(this.sunArc.group),this.mapLayer=new zh(this.scene),this.mapLayer.onChange=()=>this.invalidate(),this.energyLayer=new qh(this.scene,this.liftOf),this.soundLayer=new $h(this.scene,this.liftOf),this.waterLayer=new Zh(this.scene,this.liftOf),this.hydronicLayer=new jh(this.scene,this.liftOf),this.screenLayer=new Qh(this.scene,this.liftOf),this.screenLayer.onChange=()=>this.invalidate(),this.pictureLayer=new ef(this.scene,this.liftOf),this.pictureLayer.onChange=()=>this.invalidate(),this.weatherLayer.onFlash=n=>this.host.classList.toggle("live-flash",n),this.controls=this.makeControls(),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(e),document.addEventListener("visibilitychange",this.onVisibility),this.host.addEventListener("pointerdown",this.onTouch,{passive:!0}),this.renderer.domElement.addEventListener("pointerdown",this.onRightDown),this.renderer.domElement.addEventListener("pointerup",this.onRightUp),this.renderer.domElement.addEventListener("contextmenu",this.onContext),this.awakeUntil=performance.now()+T1,typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(n=>{let r=n.some(s=>s.isIntersecting);r!==this.onScreen&&(this.onScreen=r,r||(clearTimeout(this.effectTimer),this.effectTimer=void 0),r&&this.invalidate())}),this.intersection.observe(e)),this.resize()}get low(){return this.lowQuality}setRightBack(e){this.rightBack=e}onRightDown=e=>{this.rightDown=this.rightBack&&e.button===2?{x:e.clientX,y:e.clientY,at:performance.now()}:null};onRightUp=e=>{let t=this.rightDown;this.rightDown=null,!(!this.rightBack||!t||e.button!==2)&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<6&&performance.now()-t.at<400&&this.options.onBack?.()};onContext=e=>{this.rightBack&&e.preventDefault()};setPlain(e){e!==this.plain&&(this.plain=e,this.building&&(this.rebuild(),this.invalidate()))}exportStl(e=10){let t=[];for(let n of this.floors)for(let r of[n.wallMesh,n.floorMesh]){let s=r.geometry.getAttribute("position");s&&t.push({positions:s.array,lift:n.floor.elevation})}return Qb(t,e)}setGateStates(e){let t=[...e].map(([n,r])=>`${n}=${r?1:0}`).sort().join("|");t!==this.gateSig&&(this.gateSig=t,this.gateOpen=e,this.building&&(this.rebuild(),this.invalidate()))}setParked(e){let t=[...e].map(([n,r])=>`${n}=${r}`).sort().join("|");t!==this.parkedSig&&(this.parkedSig=t,this.parked=e,this.building&&(this.rebuild(),this.invalidate()))}setStats(e){this.statsOn=e}setLabelInset(e){this.labelInset!==e&&(this.labelInset=e,this.labelsDirty=!0,this.invalidate())}setAutoOrbit(e){this.orbitSpeed=e,this.orbitLast=0,this.invalidate()}setQuality(e){this.qualityMode=e,this.swapRenderer(e)}dropToLow(){this.disposed||this.lowQuality||this.swapRenderer("low")}swapRenderer(e){let t=this.renderer.domElement,n=this.makeRenderer(e);this.rebuildTier(),this.applyTierFlags(),t.replaceWith(n.domElement),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=n;let{view:r,locked:s}=this.controls;this.controls.dispose(),this.controls=this.makeControls(),this.controls.view=r,this.controls.locked=s,this.resize()}setMeshSource(e){og(e)}setPacks(e){Wl(e),this.building&&(this.rebuild(),this.invalidate())}setBuilding(e){let t=this.building===null;this.building=e,this.rebuild(),t&&this.fit(0),this.invalidate()}get walking(){return this.controls.walk!==null}startWalk(){let e=this.floors.filter(l=>l.floor.rooms.some(c=>c.points.length>=3)),t=(this.floorId?this.floorMap.get(this.floorId):void 0)??[...e].sort((l,c)=>Math.abs(l.floor.elevation)-Math.abs(c.floor.elevation))[0];if(!t||!t.bbox)return null;let n=t.floor.rooms.filter(l=>l.points.length>=3),r=n.find(l=>l.id===this.roomId)??[...n].sort((l,c)=>wr(c.points)-wr(l.points))[0],[s,o]=r?Gs(r.points):[(t.bbox.x0+t.bbox.x1)/2,(t.bbox.z0+t.bbox.z1)/2];this.floorId!==t.floor.id&&this.setFloor(t.floor.id,!1);let a=.3;return this.controls.walk={eye:new D(s,t.floor.elevation+t.ty+gI,o),yaw:this.controls.view.theta,pitch:-.05,stick:[0,0],keys:new Set,bounds:{x0:t.bbox.x0-a,x1:t.bbox.x1+a,z0:t.bbox.z0-a,z1:t.bbox.z1+a},last:0},this.labelsDirty=!0,this.wake(),t.floor.id}stopWalk(){this.controls.walk&&(this.controls.walk=null,this.labelsDirty=!0,this.fit(700))}setWalkStick(e,t){this.controls.walk&&(this.controls.walk.stick=[e,t],this.wake())}setFloor(e,t=!0){let n=this.keepCamera&&this.floorId!==null&&e!==null&&e!==this.floorId?{theta:this.controls.view.theta,phi:this.controls.view.phi,radius:this.controls.view.radius}:null;this.floorId=e,this.roomId=null,this.labelsDirty=!0,this.applyTargets(!t),this.applyHighlight(),this.fit(t?700:0,n)}setKeepCamera(e){this.keepCamera=e}setZoom(e){let t=Math.min(3,Math.max(.5,e||1));t!==this.zoom&&(this.zoom=t,this.building&&this.fit(400))}setFloorStack(e){e!==this.floorStack&&(this.floorStack=e,this.applyTargets(!1))}setKeepRoof(e){e!==this.keepRoof&&(this.keepRoof=e,this.invalidate())}setExplode(e){e!==this.explode&&(this.explode=e,this.applyTargets(!1),this.floorId===null&&this.fit(700))}selectRoom(e){if(this.roomId=e,this.labelsDirty=!0,this.applyHighlight(),!e){this.fit(700);return}let t=this.floors.find(u=>u.floor.rooms.some(h=>h.id===e)),n=t?.floor.rooms.find(u=>u.id===e);if(!t||!n)return;let r=n.start_view;if(r){let u=t.floor.elevation+t.ty,[h,f]=Gs(n.points),d=r.target??{x:h,y:.3,z:f};this.controls.flyTo({target:new D(d.x,d.y+u,d.z),radius:r.radius,phi:r.phi,theta:r.theta});return}let[s,o]=Gs(n.points),a=n.points.map(u=>u[0]),l=n.points.map(u=>u[1]),c=new D(Math.max(...a)-Math.min(...a),t.floor.cut_height,Math.max(...l)-Math.min(...l));this.controls.flyTo({target:new D(s,t.floor.elevation+t.ty+.3,o),radius:Math.max(4,this.distanceFor(c)*1.05),phi:.72})}get lowered(){return this.wallMode!=="auto"}setPaintedWalls(e){e!==this.painted&&(this.painted=e,this.rebuild(),this.invalidate())}wallPaint(e){return this.painted&&this.building?fm(this.building.settings,e):void 0}setWallMode(e){this.wallMode=e;for(let t of this.floors)this.buildLamps(t);this.invalidate()}setDevices(e){let t=e.map(r=>`${r.id}:${r.active?1:0}:${r.glow?r.glow.level.toFixed(1):"-"}`).join(";");t!==this.deviceLook&&(this.deviceLook=t,this.wake()),this.devices=e,this.labelsDirty=!0,this.effectFloors=new Set(e.filter(r=>r.effect&&r.glow||(r.spin??0)>0).map(r=>r.floorId)),this.deviceFloor=new Map(e.map(r=>[r.id,r.floorId]));let n=new Set;for(let r of e){n.add(r.id);let s=this.devicePins.get(r.id);s||(s={el:jb(r.id,this.pinHooks),icon:"",text:"",watt:"",label:"",active:!1,unavailable:!1,glow:"",caption:""},this.devicePins.set(r.id,s),this.labels.append(s.el));let o=s.el;s.icon!==r.icon&&(s.icon=r.icon,o.querySelector(".nf-dev-icon").innerHTML=r.icon),s.text!==r.text&&(s.text=r.text,o.querySelector(".nf-dev-text").textContent=r.text);let a=r.caption??"";s.caption!==a&&(s.caption=a,o.querySelector(".nf-dev-name").textContent=a);let l=r.power!==null&&r.power!==void 0&&r.power>=1?r.powerText??`${Math.round(r.power)} W`:"";s.watt!==l&&(s.watt=l,o.querySelector(".nf-dev-watt").textContent=l);let c=`${r.name}: ${r.text}`;s.label!==c&&(s.label=c,o.title=r.name,o.setAttribute("aria-label",c)),s.active!==r.active&&(s.active=r.active,o.classList.toggle("nf-dev-on",r.active)),s.unavailable!==r.unavailable&&(s.unavailable=r.unavailable,o.classList.toggle("nf-dev-na",r.unavailable));let u=r.glow?`rgb(${r.glow.color.map(h=>Math.round(h*255)).join(", ")})`:"";s.glow!==u&&(s.glow=u,u?o.style.setProperty("--nf-glow",u):o.style.removeProperty("--nf-glow"))}for(let[r,s]of this.devicePins)n.has(r)||(s.el.remove(),this.devicePins.delete(r));for(let r of this.floors)this.buildGlow(r),this.buildLamps(r);this.invalidate()}setRoofWindows(e){let t=JSON.stringify([...e]);t!==this.roofWindowsKey&&(this.roofWindowsKey=t,this.roofWindows=e,this.buildRoofMesh(),this.invalidate())}setPersons(e){this.labelsDirty=!0,this.persons=e;let t=new Set;for(let n of e){t.add(n.id);let r=this.personPins.get(n.id);if(r||(r=document.createElement("div"),r.className="nf-person",r.dataset.entity=n.id,this.personPins.set(n.id,r),this.labels.append(r)),r.title=n.name,r.setAttribute("aria-label",n.name),r.dataset.picture!==(n.picture??"")||r.dataset.initials!==n.initials)if(r.dataset.picture=n.picture??"",r.dataset.initials=n.initials,r.replaceChildren(),n.picture){let s=document.createElement("img");s.src=n.picture,s.alt="",s.addEventListener("error",()=>s.replaceWith(document.createTextNode(n.initials))),r.append(s)}else r.textContent=n.initials}for(let[n,r]of this.personPins)t.has(n)||(r.remove(),this.personPins.delete(n));this.invalidate()}setNavigationLocked(e){this.controls.locked=e}setPickTargets(e,t,n=new Map){this.pickFurniture=e,this.pickOpenings=t,this.pickOpenings2=n}setNotePhotos(e){this.notePhoto=e}setFurnitureColors(e){JSON.stringify(e??{})!==JSON.stringify(this.furnitureColors??{})&&(this.furnitureColors=e,this.building&&(this.rebuild(),this.invalidate()))}setAccent(e){let t=Zb(e),n=t?1:0;n===nh.value&&(!t||th.value.equals(new D(...t)))||(nh.value=n,t&&th.value.set(...t),this.invalidate())}setTheme(e){if(e===this.theme)return;this.theme=e,this.placeMap(),this.themeUniform.value=Kb(e);let t=Ml(e),n=[...this.floors.map(r=>r.materials.lines),...this.roof?[this.roof.lines]:[]];for(let r of n)r.blending=t,r.needsUpdate=!0;this.placeGround(),this.invalidate()}setFurnishMode(e){this.furnish=e,e||this.selectFurniture(null),this.invalidate()}selectFurniture(e){e&&this.selectedDevice&&this.selectDevice(null),this.selectedFurniture=e,this.updateGhost(),this.invalidate()}setSun(e){this.sun=e;for(let t of this.floors)this.buildSun(t);this.buildHouseShadow(),this.buildSunArc(),this.invalidate()}setLocation(e){this.sunArcLocation=e,this.buildSunArc(),this.invalidate()}buildSunArc(){let e=this.building,t=this.sunArcLocation,n=(e?.floors??[]).flatMap(c=>[...c.rooms.flatMap(u=>u.points),...(c.outdoor??[]).flatMap(u=>u.points)]);if(!e||!e.settings.sun_arc||!t||!n.length)return void this.sunArc.update(null,null,0);let r=n.map(c=>c[0]),s=n.map(c=>c[1]),o=[(Math.min(...r)+Math.max(...r))/2,(Math.min(...s)+Math.max(...s))/2],a=Math.max(6,Math.hypot(Math.max(...r)-Math.min(...r),Math.max(...s)-Math.min(...s))/2+3),l=Math.min(0,...e.floors.map(c=>c.elevation));this.sunArc.update({centre:o,radius:a,north:e.settings.north??0,...t},this.sun,l)}buildHouseShadow(){if(!this.houseShadow)return;let e=this.building,t=(e?.floors??[]).filter(u=>u.elevation>=-.01&&u.rooms.length),n=!e||!t.length||e.settings.sun_patches===!1||this.lowQuality,r=this.weatherLayer?.cloud??0,s=e?.settings.north??0,o=t.map(u=>`${u.elevation}:${u.height}:${JSON.stringify(u.rooms.map(h=>h.points))}`).join("|"),a=n?"off":`${this.sun?.elevation.toFixed(1)},${this.sun?.azimuth.toFixed(1)},${s},${r.toFixed(2)},${o}`;if(a===this.shadowKey)return;if(this.shadowKey=a,n){this.houseShadow.update([],0,0,null,0,0,!0);return}let l=Math.min(...t.map(u=>u.elevation)),c=Math.max(...t.map(u=>u.elevation+u.height));this.footprint.key!==o&&(this.footprint={key:o,rings:mr(t.flatMap(u=>u.rooms.map(h=>h.points)))}),this.houseShadow.update(this.footprint.rings,c-l,l+.03,this.sun,s,r,!1)}liftOf=e=>{if(!e)return{y:0,dy:0,visible:!0};let t=this.floorMap.get(e);return t?{y:t.floor.elevation+t.y,dy:t.y,visible:t.group.visible}:{y:0,dy:0,visible:!1}};setLiveEnergy(e,t){this.energyLayer.setArcs(e),this.energyLayer.setSparks(t),this.invalidate()}setLiveSound(e,t){this.soundLayer.set(e,t),this.invalidate()}setGlassWalls(e){let t=Math.min(1,Math.max(0,e));t!==this.glassAlpha.value&&(this.glassAlpha.value=t,this.invalidate())}setLiveWater(e){this.waterLayer.set(e),this.invalidate()}setHydronics(e){this.hydronicLayer.set(e),this.invalidate()}setLiveScreens(e){let t=[];for(let n of e){let r=this.building?.floors.find(a=>a.id===n.floorId),s=r?.furniture.find(a=>a.id===n.furnitureId),o=s&&r?vh(s,r):null;!s||!o||t.push({...n,x:s.x,z:s.z,rotation:s.rotation,rect:o})}this.screenLayer.set(t),this.invalidate()}setPictures(e){let t=[];for(let n of e){let r=this.building?.floors.find(a=>a.id===n.floorId),s=r?.furniture.find(a=>a.id===n.furnitureId),o=s&&r?$p(s,r):null;!s||!o||t.push({id:n.furnitureId,floorId:n.floorId,url:n.url,border:n.border,fit:n.fit,x:s.x,z:s.z,rotation:s.rotation,rect:o})}this.pictureLayer.set(t),this.invalidate()}setLiveAnchors(e,t){this.liveAnchors=e,this.liveAnchorCb=t,this.invalidate()}placeLhAnchors(){let e=this.liveAnchorCb;if(!e||!this.liveAnchors.length)return;let t=new D,n=this.camera.matrixWorldInverse.elements,r=this.size.h*this.camera.projectionMatrix.elements[5]/2;this.liveAnchors.forEach((s,o)=>{let a=this.liftOf(s.floorId);t.set(s.x,a.y+s.y,s.z);let l=-(n[2]*t.x+n[6]*t.y+n[10]*t.z+n[14]);t.project(this.camera);let c=a.visible&&t.z>-1&&t.z<1&&Math.abs(t.x)<1.15&&Math.abs(t.y)<1.15;e(o,(t.x+1)/2*this.size.w,(1-t.y)/2*this.size.h,c,l>0?r/l:0)})}setSky(e){this.skyView=e,this.weatherLayer.set(e?{...e,low:e.low||this.lowQuality}:null),this.buildHouseShadow();for(let t of this.floors)this.buildSun(t);this.invalidate()}setRoomTint(e){let t=!!e!=!!this.roomTint;if(this.roomTint=e,this.tintTick=!0,this.applyHighlight(),t)for(let n of this.floors)n.glowSig="",this.buildGlow(n)}setScreens(e){this.screens=e;for(let t of this.floors)this.buildScreens(t);this.invalidate()}fillRoomPin(e,t,n){if(e.textContent=t||"\u2013",n){let r=document.createElement("small");r.textContent=n,e.append(r),e.classList.add("nf-pin-info")}else e.classList.remove("nf-pin-info")}setRoomInfo(e){if(!(e.size===this.roomInfo.size&&[...e].every(([n,r])=>this.roomInfo.get(n)===r))){this.roomInfo=e;for(let n of this.floors)for(let r of n.roomPins)this.fillRoomPin(r.pin,r.room.name,e.get(r.room.id))}}setFloorInfo(e){this.floorInfo=e;for(let t of this.floors){let n=t.label.querySelector("span"),r=e.get(t.floor.id)??this.options.floorInfo?.(t.floor)??"";n&&n.textContent!==r&&(n.textContent=r,t.labelSize=null,this.labelsDirty=!0)}this.invalidate()}setOpeningStates(e){let t=this.openingTargets;this.openingTargets=e,[...e].some(([n,r])=>!Sp(t.get(n)??ks,r))&&this.wake(),this.invalidate()}wake(){this.awakeUntil=performance.now()+T1,this.invalidate()}get resting(){return this.lowQuality&&performance.now()>this.awakeUntil}setFridgeDoors(e){for(let[t,n]of e){let r=this.fridges.get(t)??{l:n.left?1:0,r:n.right?1:0,tl:0,tr:0};r.tl=n.left?1:0,r.tr=n.right?1:0,this.fridges.set(t,r)}for(let t of[...this.fridges.keys()])e.has(t)||this.fridges.delete(t);this.invalidate()}setCovers(e){let t=!1;for(let[n,r]of e){let s=this.covers.get(n);s?s.t!==r&&(s.t=r,t=!0):(this.covers.set(n,{k:r,t:r}),t=!0)}for(let n of[...this.covers.keys()])e.has(n)||this.covers.delete(n);if(t){for(let n of this.floors)this.buildFridges(n);this.wake()}}stepCovers(e){let t=Math.min(1,e/4e3),n=!1;for(let r of this.covers.values()){if(r.k===r.t)continue;let s=r.t-r.k;r.k=Math.abs(s)<=t?r.t:r.k+Math.sign(s)*t,n=!0}if(n)for(let r of this.floors)this.buildFridges(r);return n}stepFridges(e){let t=Mp(e),n=new Set;for(let[r,s]of this.fridges)for(let[o,a]of[["l","tl"],["r","tr"]]){let l=s[a]-s[o];if(Math.abs(l)<.004){l!==0&&(s[o]=s[a],n.add(r));continue}s[o]+=l*t,n.add(r)}if(!n.size)return!1;for(let r of this.floors)r.floor.furniture.some(s=>n.has(s.id))&&this.buildFridges(r);return!0}buildFridges(e){let t=new ut;for(let n of e.floor.furniture){let r=_t(n.type);if(r&&tg(r)){up(t,r,n,Gt(e.floor,n),this.covers.get(n.id)?.k??ng(r,null));continue}if(n.type!=="fridge_smart")continue;let s=this.fridges.get(n.id);Hp(t,n,Gt(e.floor,n),s?.l??0,s?.r??0)}e.fridgeMesh.geometry.dispose(),e.fridgeMesh.geometry=t.geometry(),e.fridgeMesh.visible=t.count>0}resetView(){this.fit(700)}setStartView(e){this.startView=e}currentView(){let e=this.controls.view,t=this.floorBase(this.floorId);return{theta:e.theta,phi:e.phi,radius:e.radius,target:{x:e.target.x,y:e.target.y-t,z:e.target.z}}}floorBase(e){let t=e===null?void 0:this.floorMap.get(e);return t?t.floor.elevation+t.ty:0}dispose(){this.disposed=!0,cancelAnimationFrame(this.frame),clearTimeout(this.effectTimer),clearTimeout(this.robotTimer),clearTimeout(this.orbitTimer),clearTimeout(this.weatherTimer),this.weatherLayer.dispose(),this.sunArc?.dispose(),this.houseShadow?.dispose(),this.mapLayer.dispose(),this.energyLayer.dispose(),this.soundLayer.dispose(),this.waterLayer.dispose(),this.hydronicLayer.dispose(),this.screenLayer.dispose(),this.pictureLayer.dispose(),this.resizeObserver.disconnect(),this.intersection?.disconnect(),document.removeEventListener("visibilitychange",this.onVisibility),this.host?.removeEventListener("pointerdown",this.onTouch),this.renderer?.domElement?.removeEventListener?.("pointerdown",this.onRightDown),this.renderer?.domElement?.removeEventListener?.("pointerup",this.onRightUp),this.renderer?.domElement?.removeEventListener?.("contextmenu",this.onContext),clearTimeout(this.petTimer),this.controls.dispose(),this.clear(),this.building=null,this.buildRoofMesh(),this.ground.geometry.dispose(),this.ground.material.dispose(),this.patternTexture.dispose(),this.blindTexture.dispose(),this.groundTexture?.dispose(),this.haloTexture.dispose();for(let e of this.robots.values())e.led.dispose();this.robots.clear();for(let e of this.robotTrails.values())e.removeFromParent(),e.geometry.dispose(),e.material.dispose();this.robotTrails.clear();for(let e of this.trailTimers.values())clearTimeout(e);this.trailTimers.clear(),this.robotGeo?.dispose(),this.robotLedGeo?.dispose(),this.robotMat?.dispose(),this.mowerMat?.dispose(),this.meshLight?.dispose(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer.domElement.remove(),this.labels.remove()}invalidate(){this.frame||this.disposed||document.hidden||!this.onScreen||(this.frame=requestAnimationFrame(e=>this.render(e)))}makeRenderer(e){let t=e==="low"||e==="auto"&&Gy();this.lowQuality=t,this.weatherLayer&&this.skyView&&this.weatherLayer.set({...this.skyView,low:this.skyView.low||t}),this.weatherLayer&&this.buildHouseShadow(),this.highQuality=e==="high";let n=new Vr({antialias:!t,alpha:!0,powerPreference:t?"low-power":"default"}),r=Math.min(window.devicePixelRatio||1,t?1:e==="high"?2.5:2);return n.setPixelRatio(r),this.governor=e==="auto"&&!t?new Vu(r,Math.min(1,r)):null,n.setClearColor(0,0),n.outputColorSpace=dt,n.domElement.className="nf-canvas",this.host.prepend(n.domElement),n}makeControls(){return new Dl(this.renderer.domElement,this.camera,{change:()=>this.wake(),tap:(e,t)=>this.onTap(e,t),hold:(e,t)=>this.onHold(e,t),swipeStart:(e,t,n,r)=>this.swipeStart(e,t,n,r),swipeMove:e=>this.swipe&&this.options.onDeviceSwipe?.(this.swipe.entity,"move",e,this.swipe.x,this.swipe.y),swipeEnd:()=>{this.swipe&&this.options.onDeviceSwipe?.(this.swipe.entity,"end",0,this.swipe.x,this.swipe.y),this.swipe=null},grab:(e,t)=>this.grabFurniture(e,t),drag:(e,t)=>this.dragFurniture(e,t),drop:()=>this.dropFurniture(),doubleTap:(e,t)=>{let n=this.floorId&&this.options.onRoomDoubleTap?this.pick(e,t):null;n&&!("entity"in n)&&n.roomId?this.options.onRoomDoubleTap(n.floorId,n.roomId):this.options.onBack?.()}})}onTouch=()=>this.wake();onVisibility=()=>{document.hidden&&(clearTimeout(this.effectTimer),this.effectTimer=void 0),document.hidden||this.invalidate()};scheduleEffects(){if(!this.hasVisibleEffects(document.hidden)||this.resting){clearTimeout(this.effectTimer),this.effectTimer=void 0;return}if(this.effectTimer!==void 0)return;let e=this.lowQuality?2*w1:w1;this.effectTimer=setTimeout(()=>{if(this.effectTimer=void 0,!!this.hasVisibleEffects(document.hidden)){this.effectTime=performance.now()/1e3,this.effectTick=!0;for(let t of this.floors)t.o<.02||!this.effectFloors.has(t.floor.id)||(this.buildLamps(t),this.buildGlow(t));this.invalidate()}},e)}hasVisibleEffects(e){return!e&&!this.disposed&&this.onScreen&&this.floors.some(t=>t.o>=.02&&this.effectFloors.has(t.floor.id))}resize(){let e=this.host.clientWidth||1,t=this.host.clientHeight||1;this.size={w:e,h:t},this.labelsDirty=!0,this.renderer.setSize(e,t,!1),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.invalidate()}clear(){for(let e of this.robots.values())e.group.removeFromParent();for(let e of this.meshes)e.group.removeFromParent(),jm(e.group);this.meshes=[];for(let e of this.floors){e.group.traverse(t=>{t.geometry?.dispose()});for(let t of Object.values(e.materials))Array.isArray(t)||t.dispose();for(let t of e.materials.ghosts)t.material.dispose();this.root.remove(e.group)}this.floors=[],this.floorMap=new Map;for(let e of[...this.labels.children])e.dataset.entity||e.remove()}buildLightSurface(e){let t=this.lowQuality?.5:.25,n=Cp(e.floor,e.geo.walls2d,e.geo.wallBuckets,e.geo.openings,t,e.geo.holes,e.geo.roofUnder),r=vI(e.floor,e.geo.openRooms);if(e.lightZones=r.some((a,l)=>a!==l)?r:null,e.lightZones){for(let a=0;a=0&&l=0&&a.a=0&&a.bthis.glowOf(h)),r=t.doors.map(h=>{let f=e.geo.openings.find(p=>p.opening.id===h.id);if(f&&Sr(f.opening,f.exterior)==="passage")return 1;let d=e.openings.get(h.id);return d?Math.max(d.open,d.open2??0):.5}),s=n.map(h=>`${h.x.toFixed(2)},${h.y.toFixed(2)},${h.z.toFixed(2)},${h.kind},${h.level.toFixed(3)},${h.color.map(f=>f.toFixed(3)).join("/")}`).join(";")+"|"+r.map(h=>h.toFixed(1)).join(",");if(s===e.glowSig)return;e.glowSig=s;let o=e.glowMesh.geometry,a=o.getAttribute("color");if(!n.length){e.glowMesh.visible=!1,o.setDrawRange(0,0);return}let l=Pp(t,n,.42,r);if(this.roomTint){let h=e.floor.rooms.length;for(let f=0;f.004;if(f)for(let d=0;d<6;d++)c[u++]=h*6+d}o.index.needsUpdate=!0,o.setDrawRange(0,u),e.glowMesh.visible=u>0}withoutFurniture(e){if(this.gateOpen.size&&(e.outdoor??[]).some(n=>n.gates?.length)&&(e={...e,outdoor:e.outdoor.map(n=>n.gates?.length?{...n,gates:n.gates.map(r=>({...r,open:this.gateOpen.get(r.id)??!1}))}:n)}),!this.plain)return e;let t=n=>n.type==="stairs"||n.type==="stairwell"||!!_t(n.type)?.hole;return{...e,furniture:e.furniture.filter(t)}}rebuild(){let e=new Map(this.floors.map(s=>[s.floor.id,{y:s.y,o:s.o}])),t=new Map(this.floors.map(s=>[s.floor.id,s.openings]));this.clear();let n=this.building;if(!n)return;Uy({...n.settings.furniture_colors,...this.furnitureColors});let r=[...n.floors].sort((s,o)=>s.elevation-o.elevation);for(let s of n.floors){let o=n.settings.roof?.solar??[],a=Mh(n)?.id===s.id?o.filter(V=>V.face===Ll).map(V=>({field:V,face:Sh(n,V)})):[],l=o.filter(V=>V.face.startsWith(`wall:${s.id}:`));if(l.length){let V=new Map(_h(n,s.id).map(re=>[re.key,re]));for(let re of l){let ye=V.get(re.face);ye&&a.push({field:re,face:ye})}}let u=(n.settings.roof.sections??[]).some(V=>gp(V,s.elevation+s.height))?(V,re)=>{let ye=xp(n,V,re);return ye===null?null:ye-s.elevation}:void 0,h=dm(this.withoutFurniture(kh(s,this.parked)),n.settings.wall_exterior,n.settings.wall_interior,pm(n.floors,s),a,u,this.wallPaint(s)),f={standing:{value:65535},glass:{value:0},slope:{value:new vt},slopeY:{value:new Ue},glassAlpha:this.glassAlpha},d=Jb({mask:f,look:this.themeUniform,theme:this.theme,textures:{pattern:this.patternTexture,blinds:this.blindTexture,halo:this.haloTexture}}),p=new et,x=new Se(h.floor,d.floor),m=new Se(h.shadow,d.shadow);m.renderOrder=1;let g=new Se(h.floor,d.pattern);g.renderOrder=2;let y=new Se(new Pe,d.glow);y.renderOrder=3,y.visible=!1;let _=new Se(new Pe,d.frames),b=new Se(new Pe,d.blinds),M=new Se(new Pe,d.glass);M.renderOrder=4;let S=new Se(new Pe,d.lamps);S.visible=!1;let v=new Se(new Pe,d.cones);v.visible=!1,v.renderOrder=3;let w=new yn(new Pe,d.halos);w.visible=!1,w.renderOrder=7;let P=new Se(new Pe,d.cones);P.visible=!1,P.renderOrder=7;let T=new Se(new Pe,d.lamps);T.visible=!1;let R=new Se(new Pe,d.screens);R.visible=!1,R.renderOrder=5;for(let V of[_,b,M])V.frustumCulled=!1;let L=new Se(h.walls,d.glassWall),k=new Se(h.walls,d.wall);L.renderOrder=6,p.add(x,m,g,y,k,new xn(h.lines,d.lines),_,b,M,S,v,w,P,T,R,L);for(let V of h.ghosts){let re=ju(jn(new Ye({vertexColors:!0,transparent:!0,opacity:V.opacity,depthWrite:!1,side:ht}),this.themeUniform));d.ghosts.push({material:re,base:V.opacity});let ye=new Se(V.geometry,re);ye.renderOrder=2,p.add(ye)}this.root.add(p);let C=document.createElement("button");C.className="nf-pin nf-pin-floor",C.dataset.floor=s.id;let I=document.createElement("b");I.textContent=s.name||"\u2013";let O=document.createElement("span");O.textContent=this.floorInfo.get(s.id)??this.options.floorInfo?.(s)??"",C.append(I,O),C.addEventListener("click",()=>this.options.onFloorTap?.(s.id)),this.labels.append(C);let F=e.get(s.id),H=[],U=null;for(let V of s.rooms){let re=document.createElement("button");re.className="nf-pin",re.dataset.room=V.id,re.dataset.floor=s.id,this.fillRoomPin(re,V.name,this.roomInfo.get(V.id)),re.addEventListener("click",()=>this.options.onRoomTap?.(s.id,V.id)),this.labels.append(re);let[ye,Y]=Gs(V.points);H.push({pin:re,room:V,cx:ye,cz:Y});for(let[Q,se]of V.points)U??={x0:Q,x1:Q,z0:se,z1:se},U.x0=Math.min(U.x0,Q),U.x1=Math.max(U.x1,Q),U.z0=Math.min(U.z0,se),U.z1=Math.max(U.z1,se)}let X=[];for(let V of s.notes??[]){if(!V.text)continue;let re=document.createElement("button");re.className=`nf-pin nf-note-pin${U0(V)?" nf-note-due":""}`,re.title=V.text;let ye=V.text.length>28?`${V.text.slice(0,27)}\u2026`:V.text;re.textContent=`${V.photo?"\u{1F4F7} ":"\u270E "}${ye}`,re.addEventListener("click",()=>{let Y=re.classList.toggle("nf-note-open");re.textContent=`${V.photo?"\u{1F4F7} ":"\u270E "}${Y?V.text:ye}`;let Q=Y&&V.photo?this.notePhoto?.(V.photo):null;if(Q){let se=document.createElement("img");se.className="nf-note-photo",se.alt="",se.src=Q,se.addEventListener("load",()=>{this.labelsDirty=!0,this.invalidate()}),re.append(se)}this.labelsDirty=!0,this.invalidate()}),this.labels.append(re),X.push({pin:re,note:V})}this.floors.push({floor:s,rank:n.topology?s.outdoor_location_id?0:r.filter(V=>!V.outdoor_location_id&&V.building_id===s.building_id).indexOf(s):r.indexOf(s),group:p,geo:h,floorMesh:x,shadowMesh:m,patternMesh:g,glowMesh:y,lightSurface:null,lightZones:null,framesMesh:_,glassMesh:M,blindsMesh:b,lampMesh:S,sunMesh:v,sunSig:"",haloMesh:w,coneMesh:P,wedgeTris:[],fridgeMesh:T,lampTris:[],lampFurnTris:[],frameTris:[],glassTris:[],blindTris:[],wallMesh:k,screenMesh:R,screenSig:"",flowLayout:"",glowSig:"",lampShapeSig:"",lampColorSig:"",lampShade:new Float32Array(0),lampRanges:new Map,bbox:U,roomPins:H,notePins:X,labelSize:null,materials:d,mask:f,openings:new Map,y:F?.y??0,o:F?.o??1,ty:0,to:1,appliedO:-1,label:C})}this.floorMap=new Map(this.floors.map(s=>[s.floor.id,s])),this.buildPets();for(let s of this.floors)this.buildFridges(s);this.labelsDirty=!0,this.floorId&&!n.floors.some(s=>s.id===this.floorId)&&(this.floorId=null);for(let s of this.floors){this.buildLamps(s),this.buildScreens(s);let o=t.get(s.floor.id);for(let a of s.geo.openings)s.openings.set(a.opening.id,o?.get(a.opening.id)??this.openingTargets.get(a.opening.id)??ks);this.buildOpenings(s),this.buildLightSurface(s),this.buildSun(s)}this.applyTargets(e.size===0),this.applyHighlight(),this.applyTierFlags(),this.buildRoofMesh(),this.updateGhost(),this.placeMeshes()}placeMeshes(){for(let e of this.meshes)e.group.removeFromParent(),jm(e.group);this.meshes=[];for(let e of this.floors)for(let t of kh(e.floor,this.parked).furniture){let n=_t(t.type);if(!n?.mesh)continue;let r=n.mesh;if(!Xl(t.type)){this.meshAsked.has(r)||(this.meshAsked.add(r),jM(r).then(a=>{a&&!this.disposed&&this.rebuild()}));continue}let s=n.colors?.length?(n.colors.find(a=>a.id===t.variant)??n.colors[0]).hex:null,o=QM(r,{x:t.x,z:t.z,y:Gt(e.floor,t),rotation:t.rotation,mirror:t.mirror,w:t.w,d:t.d,h:t.h,paint:s});o&&(this.meshLight||(this.meshLight=e1(this.root,this.renderer)),t1(o,this.meshLight.env),e.group.add(o),this.meshes.push({group:o,furnitureId:t.id}))}this.invalidate()}buildRoofMesh(){this.roof&&(this.roof.group.traverse(a=>a.geometry?.dispose()),this.roof.solid.dispose(),this.roof.lines.dispose(),this.roof.glass.dispose(),this.scene.remove(this.roof.group),this.roof=null);let e=this.building?Fh(this.building,this.roofWindows):[];if(!e.length)return;let t=new et,n=jn(new Ye({vertexColors:!0,transparent:!0,side:ht}),this.themeUniform),r=jn(new Lt({vertexColors:!0,transparent:!0,blending:Ml(this.theme),depthWrite:!1}),this.themeUniform,!0),s=jn(new Ye({vertexColors:!0,transparent:!0,side:ht,depthWrite:!1}),this.themeUniform),o=e.map(a=>{let l=new et;return l.add(new Se(a.solid.geometry(),n),new xn(a.lines.geometry(),r)),a.glass.count&&l.add(new Se(a.glass.geometry(),s)),l.renderOrder=8,t.add(l),{group:l,floorId:a.floor.id,rideId:bp(this.building,a.floor,a.sections??[]),base:a.base,lift:a.lift!==!1}});t.renderOrder=8,this.scene.add(t),this.roof={group:t,parts:o,solid:n,lines:r,glass:s},this.placeRoof()}placeRoof(e=1e3){let t=this.roof;if(!t)return!1;let n=this.keepRoof?1:Math.min(1,Math.max(0,(this.controls.view.radius/this.houseRadius-.62)/.3)),s=(this.floorId===null||this.floors.length===1)&&!this.lowered?A1*n:0,o=_p(e),a=this.roofO;this.roofO+=(s-this.roofO)*o,Math.abs(s-this.roofO)<.004&&(this.roofO=s),t.group.visible=this.roofO>.02;for(let l of t.parts){let c=this.floorMap.get(l.floorId);if(!c)continue;let u=this.floorMap.get(l.rideId)??c,h=u.ty>0?Math.min(1,u.y/u.ty):this.explode&&this.floorId===null?1:0,f=Math.max(0,1-this.roofO/A1);l.group.position.y=c.floor.elevation+u.y+l.base+f*2.2+(l.lift?h*pI:0)}return t.solid.opacity=this.roofO,t.solid.depthWrite=this.roofO>.5,t.lines.opacity=this.roofO,t.glass.opacity=this.roofO*.28,this.roofO!==a&&this.roofO!==s}applyTierFlags(){let e=this.lowQuality;this.ground.visible=!e&&this.theme!=="day"&&this.floors.some(t=>t.floor.rooms.length>0);for(let t of this.floors)t.patternMesh.visible=!e,t.shadowMesh.visible=!e&&t.o>.98;this.invalidate()}rebuildTier(){for(let e of this.floors)e.flowLayout="",this.buildLightSurface(e),e.lampShapeSig="",this.buildLamps(e)}get houseView(){return this.floorId===null&&this.floors.length>1}applyTargets(e){let t=this.floorId?this.floorMap.get(this.floorId):void 0;for(let n of this.floors){let r=fb(n.rank,t?.rank,this.explode,this.floorStack);[n.ty,n.to]=[r.y,r.opacity],e&&([n.y,n.o]=[r.y,r.opacity]),this.applyFloor(n)}this.invalidate()}applyFloor(e){e.group.position.y=e.floor.elevation+e.y,e.group.visible=e.o>.02,e.shadowMesh.visible=e.o>.98&&!this.lowQuality,!(Math.abs(e.appliedO-e.o)<.001)&&(e.appliedO=e.o,pb(e.materials,e.o))}stepFloors(e){let t=!1,n=_p(e);for(let r of this.floors){let s=db(r,n);s.settled&&(this.labelsDirty=!0),(s.moving||s.settled)&&this.applyFloor(r),t||=s.moving}return t}stepOpenings(e){let t=!1,n=Mp(e);for(let r of this.floors){let s=!1;for(let[o,a]of r.openings){let l=this.openingTargets.get(o)??ks;if(Sp(a,l))continue;let c=xb(a,l,n);r.openings.set(o,c.state),s=!0,t||=c.moving}s&&(this.buildOpenings(r),this.buildGlow(r),this.buildSun(r))}return t}fanPhase(e){return e.lamp!=="fan"||!e.spin?0:Math.round(this.effectTime*e.spin*360%R1*10)/10}glowOf(e){return aM(e.glow,e.effect,this.effectTime)}buildLamps(e){let t=performance.now(),n=h=>{let f=this.flashes.get(h);if(!f||f<=t)return 0;let d=f-t,p=d>M0?.5+.5*Math.sin(d/140):d/M0;return Math.round(p*10)/10},r=this.devices.filter(h=>h.floorId===e.floor.id&&h.lamp),s=this.wallMode+(this.lowQuality?"L":this.highQuality?"H":"M")+r.map(h=>`${h.id},${h.lamp},${h.variant},${h.x},${h.z},${h.y},${h.rotation??0},${h.roll??0},${h.upright?1:0},${h.rise??0},${h.size?.join("/")},${h.base??0},${h.pack??""},${h.mirror?1:0},${h.ceiling??""},${this.fanPhase(h)}`).join(";"),o=r.map(h=>this.glowOf(h)),a=this.devices.filter(h=>h.floorId===e.floor.id&&h.wedge),l=r.map((h,f)=>`${n(h.id)},${o[f]?`${o[f].level.toFixed(3)},${o[f].color.map(d=>d.toFixed(3)).join("/")}`:"off"}`).join(";")+"|"+a.map(h=>`${h.id},${h.x},${h.z},${h.rotation??0},${JSON.stringify(h.wedge)}`).join(";");if(s!==e.lampShapeSig||!e.lampMesh.geometry.getAttribute("position")){e.lampShapeSig=s,e.lampColorSig="";let h=new ut,f=[],d=[],p=new Map,x=e.floor.height;for(let m of r){let g=m.lamp==="strip"?(m.base??x)>Math.min(e.floor.cut_height,m.ceiling??x):m.lamp?$u.has(m.lamp):!1;if(!m.lamp||g&&this.lowered)continue;let y=h.count,_=m.pack?_t(m.pack):void 0,[b,M,S]=m.size??[.3,.3,.3];_?cl(h,_,{x:m.x,z:m.z,rotation:m.rotation??0,w:b,d:M,h:S,mirror:m.mirror},m.base??0,65280):_0(h,{...m,lamp:m.lamp,phase:this.fanPhase(m)},m.ceiling??x,65280),p.set(m.furnitureId??m.id,{start:y,end:h.count}),m.pickable!==!1&&f.push({id:m.id,start:y,end:h.count}),m.furnitureId&&d.push({id:m.furnitureId,start:y,end:h.count})}e.lampTris=f,e.lampFurnTris=d,e.lampRanges=p,e.lampShade=Hy(h.c),e.lampMesh.geometry.dispose(),e.lampMesh.geometry=h.geometry(),e.lampMesh.visible=h.count>0}if(l===e.lampColorSig)return;e.lampColorSig=l;let c=e.lampMesh.geometry.getAttribute("color"),u=c.array;r.forEach((h,f)=>{let d=e.lampRanges.get(h.furnitureId??h.id);if(!d)return;let p=o[f],x=p?.55+.45*p.level:0,m=p?new W(...p.color.map(_=>Math.min(1,_*x))):new W(mI),g=n(h.id);g>0&&m.lerp(new W(1,1,1),.7*g);let y=new W(m.getHex());Wy(u,e.lampShade,d,[y.r,y.g,y.b])}),c.needsUpdate=!0,this.buildHalos(e)}buildSun(e){let t=this.building?.settings.sun_patches===!1?null:this.sun,n=this.building?.settings.north??0,r=this.weatherLayer?.cloud??0,s=Rb(t,n,r,e.openings.values());if(s===e.sunSig)return;e.sunSig=s;let o=Cb({floor:e.floor,openings:e.geo.openings,states:e.openings,sun:t,northDegrees:n,cloud:r});e.sunMesh.geometry.dispose(),e.sunMesh.geometry=o.geometry(),e.sunMesh.visible=o.count>0}buildHalos(e){let t={positions:[],colours:[]},n=new ut,r=[];for(let a of this.devices)if(a.floorId===e.floor.id&&a.wedge){let l=Mb(n,a,e.geo.walls2d);a.wedge.through||r.push({id:a.id,...l})}e.wedgeTris=r;let s=this.lowered;for(let a of this.lowQuality?[]:this.devices){let l=this.glowOf(a);if(a.floorId!==e.floor.id||!a.lamp||!l||s&&Ab(a.lamp))continue;let c=a;wb(t,c,l,a.ceiling??e.floor.height),this.highQuality&&(a.lamp==="downlight"||a.lamp==="spot")&&Tb(n,c,l,a.ceiling??e.floor.height)}let o=new Pe;o.setAttribute("position",new Le(t.positions,3)),o.setAttribute("color",new Le(t.colours,3)),e.haloMesh.geometry.dispose(),e.haloMesh.geometry=o,e.haloMesh.visible=!this.lowQuality&&t.positions.length>0,e.coneMesh.geometry.dispose(),e.coneMesh.geometry=n.geometry(),e.coneMesh.visible=n.count>0}buildScreens(e){let t=kh(e.floor,this.parked).furniture.filter(s=>this.screens.has(s.id)),n=t.map(s=>`${s.id}:${s.x},${s.z},${s.rotation},${s.w},${s.d},${s.h},${s.mount_y??""},${s.mirror?1:0}:${JSON.stringify(this.screens.get(s.id))}`).join(";");if(n===e.screenSig&&e.screenMesh.geometry.getAttribute("position"))return;e.screenSig=n;let r=new ut;for(let s of t){let o=this.screens.get(s.id),a=s.rotation*mt,l=Math.cos(a),c=Math.sin(a),u=(b,M,S)=>[s.x+b*l-S*c,M,s.z+b*c+S*l];if(o.gangs){let b=_t(s.type);if(!b)continue;for(let M of o.gangs){let S=new W(...M.color.map(v=>Math.min(1,v*(.45+.55*M.level))));ll(r,b,s,Gt(e.floor,s),S.getHex(),v=>v.gang===M.gang)}continue}if(o.print!==void 0){let b=Gt(e.floor,s)+s.h*.2,M=Math.min(s.w,s.d)*.16,S=b+s.h*.38*Math.min(1,Math.max(0,o.print)),v=new W(...o.color.map(R=>Math.min(1,R*(.35+.65*o.level)))),w=v.clone().multiplyScalar(.7),P=[u(-M,b,-M),u(M,b,-M),u(M,b,M),u(-M,b,M)],T=[u(-M,S,-M),u(M,S,-M),u(M,S,M),u(-M,S,M)];r.tri(T[0],T[2],T[1],v),r.tri(T[0],T[3],T[2],v);for(let R=0;R<4;R++){let L=(R+1)%4;r.tri(P[R],P[L],T[L],w),r.tri(P[R],T[L],T[R],w)}continue}if(o.fill!==void 0){let b=Kp(s,e.floor);if(!b)continue;let M=b.rect,S=Math.min(1,Math.max(0,o.fill)),v=new W(...o.color.map(R=>Math.min(1,R*(.35+.65*o.level)))),w=new W(.08,.1,.13),P=M.z,T=(R,L,k,C,I)=>{r.tri(u(R,k,P),u(L,k,P),u(L,C,P),I),r.tri(u(R,k,P),u(L,C,P),u(R,C,P),I)};if(b.vertical){let R=M.y0+(M.y1-M.y0)*S;S>0&&T(M.x0,M.x1,M.y0,R,v),S<1&&T(M.x0,M.x1,R,M.y1,w)}else{let R=M.x0+(M.x1-M.x0)*S;S>0&&T(M.x0,R,M.y0,M.y1,v),S<1&&T(R,M.x1,M.y0,M.y1,w)}continue}if(o.leds){let b=_t(s.type);if(!b)continue;let M=new W(...o.color.map(S=>Math.min(1,S*(.35+.65*o.level))));ll(r,b,s,Gt(e.floor,s),M.getHex(),S=>!!S.glow||!!S.screen);continue}if(o.heat){let b=_t(s.type);if(!b)continue;let M=new W(...o.color.map(S=>Math.min(1,S*(.35+.65*o.level))));ll(r,b,s,Gt(e.floor,s),M.getHex(),()=>!0);continue}if(o.faces){let b=Math.max(.05,s.w)*(s.mirror?-1:1),M=Math.max(.05,s.d),S=Math.max(.005,s.h),v=Gt(e.floor,s);for(let w of o.faces){let P=w.part==="right"?.03:-Math.abs(b)/2+.03,T=w.part==="left"?-.03:Math.abs(b)/2-.03,R=v+(w.part==="bottom"?S*.45:S)+.006,L=new W(...w.color.map(U=>Math.min(1,U*(.35+.65*w.level)))),k=new W(0,0,0),C=(U,X,V=R)=>u(U*Math.sign(b),V,X),I=[C(P,-M/2+.03),C(T,-M/2+.03),C(T,M/2-.03),C(P,M/2-.03)];r.tri(I[0],I[2],I[1],L),r.tri(I[0],I[3],I[2],L);let O=.12+.1*w.level,F=L.clone().multiplyScalar(.5),H=[C(P-O,-M/2-O,R+.004),C(T+O,-M/2-O,R+.004),C(T+O,M/2+O,R+.004),C(P-O,M/2+O,R+.004)];for(let U=0;U<4;U++){let X=(U+1)%4;r.tri(I[U],H[X],H[U],F,k,k),r.tri(I[U],I[X],H[X],F,F,k)}}continue}let h=vh(s,e.floor);if(!h)continue;let f=new W(...o.color.map(b=>Math.min(1,b*(.35+.65*o.level)))),d=new W(0,0,0),p=h.z+.004;r.tri(u(h.x0,h.y0,p),u(h.x1,h.y0,p),u(h.x1,h.y1,p),f),r.tri(u(h.x0,h.y0,p),u(h.x1,h.y1,p),u(h.x0,h.y1,p),f);let x=Math.min(1.5,o.halo??1);if(x<=0)continue;let m=(.18+.12*o.level)*Math.min(1,x),g=f.clone().multiplyScalar(.5*x),y=[u(h.x0,h.y0,p),u(h.x1,h.y0,p),u(h.x1,h.y1,p),u(h.x0,h.y1,p)],_=[u(h.x0-m,h.y0-m,p+.01),u(h.x1+m,h.y0-m,p+.01),u(h.x1+m,h.y1+m,p+.01),u(h.x0-m,h.y1+m,p+.01)];for(let b=0;b<4;b++){let M=(b+1)%4;r.tri(y[b],_[b],_[M],g,d,d),r.tri(y[b],_[M],y[M],g,d,g)}}e.screenMesh.geometry.dispose(),e.screenMesh.geometry=r.geometry(),e.screenMesh.visible=r.count>0}buildOpenings(e){let t=ym(e.geo.openings,e.openings,Math.min(e.floor.cut_height,e.floor.height),-.2-e.floor.elevation);e.frameTris=t.frameTris,e.glassTris=t.glassTris,e.blindTris=t.blindTris;for(let[n,r]of[[e.framesMesh,t.frames],[e.glassMesh,t.glass],[e.blindsMesh,t.blinds]])n.geometry.dispose(),n.geometry=r,n.visible=r.getAttribute("position").count>0}activeFloors(){return this.floors.filter(e=>e.to>.99)}applyHighlight(){for(let e of this.floors){let t=e.geo.floor.getAttribute("color");for(let n of e.geo.roomTris){let r=new W(n.color),s=this.roomTint?.get(n.roomId);s&&r.lerp(new W(...s).multiplyScalar(.6),.9),n.roomId===this.roomId&&r.lerp(xI,s?.3:.75);for(let o=n.start*3;oc.group),!0)[0];if(l){let c=l.object;for(;c&&!this.meshes.some(h=>h.group===c);)c=c.parent;let u=c?this.pickFurniture.get(this.meshes.find(h=>h.group===c).furnitureId):void 0;if(u)return{entity:u}}}let o=s.flatMap(l=>[l.lampMesh,l.coneMesh,l.framesMesh,l.glassMesh,l.blindsMesh,l.wallMesh,l.floorMesh].filter(c=>c.visible)),a=(l,c)=>l.find(u=>c>=u.start&&ch.group===l.object.parent);if(!(!n&&(l.object===u.lampMesh||l.object===u.coneMesh||l.object===u.framesMesh||l.object===u.blindsMesh||l.object===u.glassMesh))){if(l.object===u.lampMesh||l.object===u.coneMesh){let h=a(l.object===u.lampMesh?u.lampTris:u.wedgeTris,c);if(h)return{entity:h}}else if(l.object===u.framesMesh||l.object===u.blindsMesh||l.object===u.glassMesh){if(this.lowered&&l.face){let x=l.object.geometry.getAttribute("fold")?.getX(l.face.a)??$e;if(x!==$e&&Math.floor(x/16)%8===0)continue}let h=a(l.object===u.framesMesh?u.frameTris:l.object===u.glassMesh?u.glassTris:u.blindTris,c),f=h?this.pickOpenings.get(h):void 0,d=h?this.pickOpenings2.get(h):void 0,p=d?u.geo.openings.find(x=>x.opening.id===h):void 0;if(d&&p&&(l.point.x-p.start[0])*p.axis[0]+(l.point.z-p.start[1])*p.axis[1]>p.width/2&&(f=d),f)return{entity:f}}else if(l.object===u.wallMesh){let h=a(u.geo.furnitureTris,c),f=h&&n?this.pickFurniture.get(h):void 0;if(f)return{entity:f};if(l.face&&!h){let d=u.wallMesh.geometry.getAttribute("fold")?.getX(l.face.a)??32,p=Math.floor(d/16)%8,x=d%16,m=this.lowered&&p===0,g=(u.mask.glass.value&1<S.points.length>=3&&Ge(b,S.points))?.id??null;if(this.roomId!==null){if(M===this.roomId)return{floorId:u.floor.id,roomId:M}}else if(!g&&M)return{floorId:u.floor.id,roomId:M}}}}else if(l.object===u.floorMesh)return{floorId:u.floor.id,roomId:a(u.geo.roomTris.map(h=>({id:h.roomId,start:h.start,end:h.end})),c)??null}}}return null}onTap(e,t){let n=this.furnish?this.pick(e,t):this.pickInReach(e,t);if(n&&"entity"in n&&this.furnish){this.selectDevice(n.entity),this.options.onDeviceSelect?.(n.entity);return}if(n&&"entity"in n){this.flashes.set(n.entity,performance.now()+M0),this.invalidate(),this.options.onDeviceTap?.(n.entity,e,t);return}this.options.onRoomTap?.(n?.floorId??this.floorId??"",n?.roomId??null)}furnitureAt(e,t){let n=this.rayAt(e,t),r=this.activeFloors(),s=r.flatMap(o=>[o.lampMesh,o.wallMesh].filter(a=>a.visible));for(let o of n.intersectObjects(s,!1)){if(o.faceIndex==null)continue;let a=r.find(u=>u.group===o.object.parent),c=(o.object===a.lampMesh?a.lampFurnTris:a.geo.furnitureTris).find(u=>o.faceIndex>=u.start&&o.faceIndexh.id===n)?.furnitureId:void 0,a=o?null:this.furnitureAt(e,t),l=o??a?.id,c=l?this.floors.find(h=>h.floor.furniture.some(f=>f.id===l)):void 0,u=c?.floor.furniture.find(h=>h.id===l)?.type;return!!(c&&l&&u&&r.has(u))&&this.grabItem(c,l,e,t)}if(n){let o=this.devices.find(l=>l.id===n)?.furnitureId,a=o?this.floors.find(l=>l.floor.furniture.some(c=>c.id===o)):void 0;return!o||!a?this.grabDevice(n,e,t):this.grabItem(a,o,e,t)}let s=this.furnitureAt(e,t);if(!s){let o=this.pick(e,t);return o&&"entity"in o?this.grabDevice(o.entity,e,t):(this.selectedFurniture&&(this.selectFurniture(null),this.options.onFurnitureSelect?.(null)),this.selectedDevice&&(this.selectDevice(null),this.options.onDeviceSelect?.(null)),!1)}return this.grabItem(s.fv,s.id,e,t)}grabItem(e,t,n,r){let s=e.floor.furniture.find(a=>a.id===t),o=this.floorPoint(e,n,r);return!s||!o?!1:s.locked?(this.selectFurniture(s.id),this.options.onFurnitureSelect?.(s.id),!1):(this.grab={floorId:e.floor.id,id:s.id,offset:[s.x-o[0],s.z-o[1]],x:s.x,z:s.z,moved:!1},this.selectFurniture(s.id),this.options.onFurnitureSelect?.(s.id),!0)}grabDevice(e,t,n){let r=this.devices.find(a=>a.id===e),s=r&&this.floorMap.get(r.floorId),o=s&&this.floorPoint(s,t,n);return!r||!s||!o?!1:r.fixed?(this.selectDevice(e),this.options.onDeviceSelect?.(e),!1):(this.deviceGrab={id:e,floorId:s.floor.id,offset:[r.x-o[0],r.z-o[1]],x:r.x,z:r.z,moved:!1},this.selectDevice(e),this.options.onDeviceSelect?.(e),!0)}setSelectedDevice(e){e!==this.selectedDevice&&this.selectDevice(e)}selectDevice(e){e&&this.selectedFurniture&&(this.selectFurniture(null),this.options.onFurnitureSelect?.(null)),this.selectedDevice=e;for(let[t,n]of this.devicePins)n.el.classList.toggle("nf-dev-sel",t===e)}dragFurniture(e,t){if(this.surfaceDragging){this.surfaceGrab?.move(this.surfaceRay(e,t));return}let n=this.deviceGrab;if(n){let l=this.floorMap.get(n.floorId),c=this.devices.find(f=>f.id===n.id),u=l&&this.floorPoint(l,e,t);if(!l||!c||!u)return;let h=this.building?.settings.grid??.05;n.x=c.x=Math.round((u[0]+n.offset[0])/h)*h,n.z=c.z=Math.round((u[1]+n.offset[1])/h)*h,n.moved=!0,this.labelsDirty=!0,this.invalidate();return}let r=this.grab,s=r&&this.floorMap.get(r.floorId);if(!r||!s)return;let o=this.floorPoint(s,e,t);if(!o)return;let a=this.building?.settings.grid??.05;r.x=Math.round((o[0]+r.offset[0])/a)*a,r.z=Math.round((o[1]+r.offset[1])/a)*a,r.moved=!0,this.updateGhost(),this.invalidate()}dropFurniture(){if(this.surfaceDragging){this.surfaceDragging=!1,this.surfaceGrab?.end();return}let e=this.deviceGrab;this.deviceGrab=null,e?.moved&&this.options.onDeviceMove?.(e.id,Math.round(e.x*1e3)/1e3,Math.round(e.z*1e3)/1e3);let t=this.grab;this.grab=null,t?.moved&&this.options.onFurnitureMove?.(t.id,Math.round(t.x*1e3)/1e3,Math.round(t.z*1e3)/1e3),this.updateGhost()}updateGhost(){this.ghost&&(this.ghost.geometry.dispose(),this.ghost.material.dispose(),this.scene.remove(this.ghost),this.ghost=null);let e=this.selectedFurniture,t=e?this.floors.find(g=>g.floor.furniture.some(y=>y.id===e)):void 0,n=t?.floor.furniture.find(g=>g.id===e);if(!t||!n)return;let r=this.grab?.id===n.id?this.grab.x:n.x,s=this.grab?.id===n.id?this.grab.z:n.z,o=Hl(t.floor,{...n,x:r,z:s}),a=W0.has(n.type),l=Math.max(.1,n.type==="lamp_pendant"?.3:n.h),c=_t(n.type)||n.type==="lamp_wall"||n.type==="led_strip"?Gt(t.floor,n):a?n.type==="lamp_pendant"||n.type==="ceiling_fan"?o-n.h-.1:o-l:Gt(t.floor,n),u=n.rotation*mt,h=Math.cos(u),f=Math.sin(u),d=(g,y,_)=>[r+g*h-y*f,_,s+g*f+y*h],p=new Wt,x=[[-n.w/2,-n.d/2],[n.w/2,-n.d/2],[n.w/2,n.d/2],[-n.w/2,n.d/2]],m=new W(.25,.9,1);for(let g=0;g<4;g++){let[y,_]=x[g],[b,M]=x[(g+1)%4];p.seg(d(y,_,c+.01),d(b,M,c+.01),m),p.seg(d(y,_,c+l),d(b,M,c+l),m),p.seg(d(y,_,c+.01),d(y,_,c+l),m)}p.seg(d(-n.w/2,n.d/2+.03,c+.02),d(n.w/2,n.d/2+.03,c+.02),new W(1,1,1)),this.ghost=new xn(p.geometry(),new Lt({vertexColors:!0,depthTest:!1,transparent:!0})),this.ghost.position.y=t.floor.elevation+t.y,this.ghost.renderOrder=20,this.scene.add(this.ghost)}onHold(e,t){let n=this.pick(e,t);n&&"entity"in n&&this.options.onDeviceHold?.(n.entity,e,t)}swipeStart(e,t,n,r){if(this.furnish||Math.abs(r)n.floor.rooms.some(r=>r.points.length>=3)).map(n=>({key:n.floor.id,floorIds:[n.floor.id]})),e,t).map(n=>({floorId:n.key,url:n.url}))}scopeThumbnails(e,t=150,n=112){if(!e.length||!this.floors.length)return[];let r=this.lowQuality?1:Math.min(2,window.devicePixelRatio||1),s=Math.round(t*r),o=Math.round(n*r),a=new Tn(s,o);a.texture.colorSpace=dt;let l=new Vn(-1,1,1,-1,.1,4e3),c=this.floors.map(y=>({fv:y,visible:y.group.visible,y:y.y,o:y.o,standing:y.mask.standing.value,glass:y.mask.glass.value})),u=new Set(this.floors.map(y=>y.group)),h=[...this.scene.children.filter(y=>y!==this.root),...this.root.children.filter(y=>!u.has(y))].filter(y=>!y.isLight).map(y=>({node:y,visible:y.visible})),f=this.renderer.getClearAlpha(),d=this.renderer.clippingPlanes,p=new Uint8Array(s*o*4),x=document.createElement("canvas");x.width=s,x.height=o;let m=x.getContext("2d"),g=[];try{for(let y of h)y.node.visible=!1;this.renderer.setClearAlpha(0);for(let y of e){let _=new Set(y.floorIds),b=this.floors.filter(C=>_.has(C.floor.id)),M=new Ct;for(let C of this.floors){let I=_.has(C.floor.id);if(C.group.visible=I,!I)continue;C.y=0,C.o=1,this.applyFloor(C),C.group.visible=!0,C.mask.standing.value=0,C.mask.glass.value=0;let O=C.floor,F=y.room&&y.room.floorId===O.id?O.rooms.find(U=>U.id===y.room.roomId):null,H=F?F.points:[...O.rooms.flatMap(U=>U.points),...O.outdoor.flatMap(U=>U.points),...(O.walls??[]).flatMap(U=>[U.a,U.b]),...O.furniture.flatMap(U=>[[U.x-U.w/2,U.z-U.d/2],[U.x+U.w/2,U.z+U.d/2]])];for(let[U,X]of H)M.expandByPoint(new D(U,O.elevation,X)),M.expandByPoint(new D(U,O.elevation+Math.min(O.cut_height,O.height),X))}if(!b.length||M.isEmpty())continue;M.expandByScalar(.25),this.renderer.clippingPlanes=y.room?[new mn(new D(1,0,0),-M.min.x),new mn(new D(-1,0,0),M.max.x),new mn(new D(0,0,1),-M.min.z),new mn(new D(0,0,-1),M.max.z)]:[];let S=M.getCenter(new D),v=-.6,w=.8,P=new D(Math.sin(w)*Math.sin(v),Math.cos(w),Math.sin(w)*Math.cos(v));l.position.copy(S).addScaledVector(P,Math.max(100,M.getSize(new D).length()*2)),l.lookAt(S),l.updateMatrixWorld();let T=.5,R=.5;for(let C of[M.min.x,M.max.x])for(let I of[M.min.y,M.max.y])for(let O of[M.min.z,M.max.z]){let F=new D(C,I,O).applyMatrix4(l.matrixWorldInverse);T=Math.max(T,Math.abs(F.x)),R=Math.max(R,Math.abs(F.y))}let L=s/o;T/R>L?R=T/L:T=R*L,l.left=-T*1.05,l.right=T*1.05,l.top=R*1.05,l.bottom=-R*1.05,l.updateProjectionMatrix(),this.renderer.setRenderTarget(a),this.renderer.clear(),this.renderer.render(this.scene,l),this.renderer.readRenderTargetPixels(a,0,0,s,o,p);let k=m.createImageData(s,o);for(let C=0;C{Math.hypot(u[0]-r.motion.pos[0],u[1]-r.motion.pos[1])o.length?`${o.length}:${o[0].map(a=>a.toFixed(2))}/${o[o.length-1].map(a=>a.toFixed(2))}`:"").join("|"),r=this.robotTrails.get(e.id);if(r&&r.userData.key===n){this.showRobotTrail(e);return}let s=r;if(!s){let o=new Ye({color:3590399,transparent:!0,opacity:.34,depthWrite:!1,side:ht});s=new Se(t0([],.16,0),o),s.renderOrder=3,s.name=`robot-trail:${e.id}`,this.robotTrails.set(e.id,s);let a=this.robots.get(e.id)?.group.parent;a&&a.add(s)}s.geometry.dispose(),s.geometry=t0(t,.16,(e.y??0)+.012),s.userData.key=n,this.showRobotTrail(e)}showRobotTrail(e){let t=this.robotTrails.get(e.id);if(!t)return;let n=this.trailTimers.get(e.id);n!==void 0&&(clearTimeout(n),this.trailTimers.delete(e.id));let r=Date.now(),s=o1(e.settledAt,r);if(t.material.opacity=.34*s,t.visible=(e.track?.length??0)>0&&s>.01,s<=0||s>=1&&e.settledAt==null)return;let o=s>=1?Math.max(0,(e.settledAt??r)+of-r):250;this.trailTimers.set(e.id,setTimeout(()=>{this.showRobotTrail(e),this.invalidate()},o))}makeRobot(e){if(!this.robotGeo){let s=new ut,o=(l,c,u,h,f)=>{let d=[];for(let p=0;p<20;p++)d.push([Math.cos(p/20*Math.PI*2)*l,Math.sin(p/20*Math.PI*2)*l]);Tt(s,d,c,u,h,f,{aoFrom:0,bottom:!1})};o(.17,.012,.08,2371657,3424863),o(.055,.08,.1,3820138,5070726),this.robotGeo=s.geometry(),this.robotMat=new Ye({vertexColors:!0});let a=new ut;Tt(a,[[-.05,.1],[.05,.1],[.05,.14],[-.05,.14]],.08,.085,16777215,16777215,{aoFrom:0,bottom:!1}),this.robotLedGeo=a.geometry()}let t=new et,n=new Ye({color:M1[e.mode]}),r=e.mower?this.mowerMat??=new Ye({color:4164170}):this.robotMat;return t.add(new Se(this.robotGeo,r),new Se(this.robotLedGeo,n)),e.mower&&t.scale.set(1.7,1.6,1.7),{info:e,motion:{pos:[...e.rest],heading:e.restHeading,path:[],next:0},group:t,led:n}}buildPets(){let e=new Map(this.pets);this.pets.clear(),this.petMat??=new Ye({vertexColors:!0});for(let t of this.floors)for(let n of t.floor.furniture){let r=_t(n.type);if(!r?.pet)continue;let s=t.floor.rooms.find(f=>f.points.length>=3&&Ge([n.x,n.z],f.points)),o=e.get(n.id),a=new ut;ws(new Ni(a,new Wt,Ts({x:0,z:0,rotation:0,mirror:n.mirror})),r,Math.max(.05,n.w),Math.max(.05,n.d),Math.max(.05,n.h),0,null,null,n.variant??null),o?.group.removeFromParent();let l=new et;l.add(new Se(a.geometry(),this.petMat));let c=s?t.floor.furniture.filter(f=>f.id!==n.id&&!_t(f.type)?.pet&&f.type!=="rug"&&Gt(t.floor,f)<.5&&Ge([f.x,f.z],s.points)).map(f=>ns(f)):[],u={points:s?.points??[[n.x-.5,n.z-.5],[n.x+.5,n.z-.5],[n.x+.5,n.z+.5],[n.x-.5,n.z+.5]],obstacles:c,speed:n.type.endsWith(":pet_dog")?.7:.45},h=o&&s&&Ge(o.motion.pos,s.points)?o.motion:{pos:[n.x,n.z],heading:n.rotation*Math.PI/180,target:null,rest:1};this.pets.set(n.id,{motion:h,room:u,random:zy(n.id),group:l,floorId:t.floor.id})}for(let[t,n]of e)this.pets.has(t)||n.group.removeFromParent()}setPetRooms(e){for(let[t,n]of this.pets){let r=this.floorMap.get(n.floorId),s=e.get(t);if(!r||s===void 0)continue;let o=s?r.floor.rooms.find(l=>l.id===s&&l.points.length>=3):void 0;if(!o||n.room.points===o.points)continue;let a=r.floor.furniture.filter(l=>!_t(l.type)?.pet&&l.type!=="rug"&&Gt(r.floor,l)<.5&&Ge([l.x,l.z],o.points)).map(l=>ns(l));n.room={...n.room,points:o.points,obstacles:a},Ge(n.motion.pos,o.points)||(n.motion={...n.motion,pos:Gs(o.points),target:null,rest:.5})}this.invalidate()}stepRobots(e){if(!this.robots.size&&!this.pets.size)return!1;let t=this.robotLast?Math.min(.2,(e-this.robotLast)/1e3):0;this.robotLast=e;let n=!1,r=1/0,s=this.petLast?(e-this.petLast)/1e3:0;this.petLast=e;for(let o of this.pets.values()){let a=this.floorMap.get(o.floorId);if(!a)continue;o.group.parent!==a.group&&a.group.add(o.group),Vy(o.motion,o.room,s,o.random)||!!o.motion.target?n=!0:r=Math.min(r,Math.max(0,o.motion.rest)),o.group.position.set(o.motion.pos[0],0,o.motion.pos[1]),o.group.rotation.y=o.motion.heading}clearTimeout(this.petTimer),!n&&Number.isFinite(r)&&(this.petTimer=setTimeout(()=>this.invalidate(),r*1e3+50));for(let o of this.robots.values()){let a=this.floorMap.get(o.info.floorId);if(!a)continue;o.group.parent!==a.group&&a.group.add(o.group);let l=this.robotTrails.get(o.info.id);l&&l.parent!==a.group&&a.group.add(l),t>0?n=s1(o.motion,o.info,t)||n:n||=o.info.mode==="cleaning"||o.info.mode==="returning",o.group.position.set(o.motion.pos[0],o.info.y??0,o.motion.pos[1]),o.group.rotation.y=o.motion.heading}return n||(this.robotLast=0),n}getView(){return{...this.controls.view,target:this.controls.view.target.clone()}}showView(e,t=900){let n=e.target??{x:0,y:0,z:0};this.controls.maxRadius=Math.max(this.controls.maxRadius,e.radius*1.5),this.controls.flyTo({target:new D(n.x,n.y,n.z),radius:e.radius,phi:e.phi,theta:e.theta},t)}flyTo(e,t=900){this.controls.flyTo(e,t)}focus(e,t,n,r,s){let o=this.floorMap.get(e);if(o){if(this.controls.flyTo({target:new D(t,o.floor.elevation+o.ty+r,n),radius:5.5,phi:.78},900),s){this.flashes.set(s,performance.now()+2400);let a=this.host.querySelector(`.nf-dev[data-entity="${CSS.escape(s)}"]`);a?.classList.add("nf-dev-found"),setTimeout(()=>a?.classList.remove("nf-dev-found"),2600)}this.invalidate()}}render(e){if(this.frame=0,this.disposed)return;let t=this.lastFrame?Math.min(100,e-this.lastFrame):16,n=!1;this.orbitSpeed&&!this.controls.active?(this.orbitLast&&(this.controls.view.theta+=this.orbitSpeed*Math.min(100,e-this.orbitLast)/1e3),this.orbitLast=e,n=!0):this.orbitLast=0;let r=this.controls.update(e),s=this.stepFloors(t),a=[this.stepOpenings(t),this.stepFridges(t),this.stepCovers(t)].some(Boolean),l=!1;if(this.flashes.size){let m=new Set;for(let[g,y]of this.flashes){let _=this.deviceFloor.get(g);_&&m.add(_),y<=e&&this.flashes.delete(g)}l=this.flashes.size>0;for(let g of this.floors)m.has(g.floor.id)&&this.buildLamps(g)}let c=this.placeRoof(t),u=this.stepRobots(e);this.pictureLayer.step();let f=[this.weatherLayer,this.energyLayer,this.soundLayer,this.screenLayer,this.waterLayer,this.hydronicLayer].map(m=>m.step(e)).some(Boolean),d=r||s||a||l||c,p=[];if(r&&p.push("camera"),s&&p.push("floors"),a&&p.push("openings"),l&&p.push("flash"),c&&p.push("roof"),this.effectTick&&p.push("effect"),u&&p.push("robot"),n&&p.push("orbit"),this.tintTick&&p.push("tint"),this.effectTick=this.tintTick=!1,this.lastFrame=d?e:0,d&&this.governor){let m=this.governor.frame(t,e);m&&"ratio"in m?(this.renderer.setPixelRatio(m.ratio),this.resize()):m&&setTimeout(()=>this.dropToLow(),0)}this.updateWalls(),this.renderer.render(this.scene,this.camera),this.placeLhAnchors(),(this.viewChanged()||s||this.labelsDirty)&&(this.labelsDirty=!1,this.updateLabels()),this.reportStats(e,p),d&&this.invalidate(),this.scheduleEffects(),!d&&n&&!this.orbitTimer&&(this.orbitTimer=setTimeout(()=>{this.orbitTimer=void 0,this.invalidate()},this.lowQuality?66:33));let x=this.resting;!d&&f&&!this.weatherTimer&&!x&&(this.weatherTimer=setTimeout(()=>{this.weatherTimer=void 0,this.invalidate()},33)),!d&&u&&!this.robotTimer&&!x&&(this.robotTimer=setTimeout(()=>{this.robotTimer=void 0,this.invalidate()},this.lowQuality?66:33))}updateWalls(){if(this.controls.walk){for(let o of this.floors)o.mask.standing.value=65535,o.mask.glass.value=0,o.mask.slope?.value.set(0,0,0,0);return}let e=this.camera.position,t=this.controls.view.target,n=e.x-t.x,r=e.z-t.z,s=Math.hypot(n,r)||1;for(let o of this.floors){let a=this.roomId!==null&&o.floor.rooms.some(h=>h.id===this.roomId),l=this.wallMode==="cut",c=0,u=0;o.geo.buckets.forEach((h,f)=>{let d=h?h[0]*n/s+h[1]*r/s>=.25:a;this.wallMode!=="auto"||!d||(this.painted?a&&(u|=1<.5&&r)){this.labelPlacer.place(n.label,null);continue}let s=n.floor.elevation+n.y+n.floor.cut_height*.5,o=[r.x0,r.x1].flatMap(l=>[r.z0,r.z1].map(c=>this.screenPoint([l,s,c],1/0)));n.label.hidden&&(n.label.hidden=!1),n.labelSize??={w:n.label.offsetWidth,h:n.label.offsetHeight};let a=ub(o,n.labelSize.w,{width:this.size.w,inset:this.labelInset});t.push({fv:n,rank:n.rank,left:a.left,y:a.y,height:n.labelSize.h})}for(let n of cb(t))this.labelPlacer.place(n.fv.label,lb(n.left,n.y));this.updateDevicePins();for(let n of this.floors){let r=n.to<.99||n.o<.9||e||this.roomId!==null||this.otherFloor(n),s=n.floor.elevation+n.y+.05;for(let a of n.roomPins){let l=r?null:this.screenPoint([a.cx,s,a.cz],1.1);this.labelPlacer.place(a.pin,l&&!l.off?gl(l):null)}let o=e||n.o<.9||this.otherFloor(n);for(let{pin:a,note:l}of n.notePins){let c=o?null:this.screenPoint([l.x,n.floor.elevation+n.y+(l.y??D0),l.z]);this.labelPlacer.place(a,c&&!c.off?gl(c):null)}}}otherFloor(e){return this.floorId!==null&&e.floor.id!==this.floorId}updateDevicePins(){let e=this.houseView;for(let t of this.persons){let n=this.personPins.get(t.id),r=this.floorMap.get(t.floorId);if(!n)continue;let s=r&&!e&&vp(r,this.otherFloor(r))?this.screenPoint([t.x,r.floor.elevation+r.y+.9,t.z]):null;this.labelPlacer.place(n,s&&!s.off?gl(s):null)}for(let t of this.devices){let n=this.devicePins.get(t.id)?.el;if(!n)continue;let r=this.floorMap.get(t.floorId),s=t.id.startsWith("detect:"),o=!!t.full&&t.roomId===null,a=!!r&&(o?hb(r):(!e||s)&&vp(r,this.otherFloor(r))),c=!!r&&a&&t.pin!==!1?this.screenPoint([t.x,r.floor.elevation+r.y+t.y,t.z]):null;if(!c||c.off){this.labelPlacer.place(n,null);continue}let u=this.roomId===null?t.full?"full":"":t.roomId===this.roomId?"full":"dim";this.pinMode.get(n)!==u&&(this.pinMode.set(n,u),n.classList.toggle("nf-dev-full",u==="full"),n.classList.toggle("nf-dev-dim",u==="dim")),this.labelPlacer.place(n,gl(c))}}reportStats(e,t){if(!this.statsOn||!this.options.onStats)return;let n=t.length>0;this.fpsStart||(this.fpsStart=e),this.lastStatsFrame&&n&&(this.worstFrame=Math.max(this.worstFrame,e-this.lastStatsFrame)),this.lastStatsFrame=n?e:0,this.fpsFrames++;let r=e-this.fpsStart;if(r>500||!n){let s=this.renderer.info.render;this.options.onStats({fps:n?Math.round(this.fpsFrames*1e3/r):0,busy:t,worstMs:Math.round(this.worstFrame),calls:s.calls,triangles:s.triangles,low:this.lowQuality,pixelRatio:this.renderer.getPixelRatio()}),this.fpsFrames=0,this.fpsStart=e,this.worstFrame=0}}};function yI(){let e=document.createElement("canvas");e.width=256*3,e.height=256*2;let t=e.getContext("2d"),n=(o,a,l,c,u)=>{t.strokeStyle=`rgba(55,224,255,${u})`,t.beginPath(),t.moveTo(o,a),t.lineTo(l,c),t.stroke()};t.lineWidth=1.5;let r=(o,a,l)=>{t.save(),t.beginPath(),t.rect(o*256,a*256,256,256),t.clip(),l(o*256,a*256),t.restore()};r(0,0,(o,a)=>{for(let l=0;l<5;l++){let c=a+l*256/5+.75;n(o,c,o+256,c,.09);let u=o+l*.37%1*256;n(u,c,u,c+256/5,.07)}}),r(1,0,(o,a)=>{for(let l=0;l<7;l++){let c=o+l*256/7+.75;n(c,a,c,a+256,.08);let u=a+l*.53%1*256;n(c,u,c+256/7,u,.06)}}),r(2,0,(o,a)=>{for(let l=0;l<4;l++){let c=l*256/4+.75;n(o+c,a,o+c,a+256,.1),n(o,a+c,o+256,a+c,.1)}}),r(1,1,(o,a)=>{for(let l=0;l<2;l++){let c=a+l*256/2+.75;n(o,c,o+256,c,.09);let u=l?256/4:0;for(let h of[u,u+256/2])n(o+h+.75,c,o+h+.75,c+256/2,.09)}}),r(2,1,(o,a)=>{n(o+.75,a,o+.75,a+256,.08),n(o,a+.75,o+256,a+.75,.08),t.fillStyle="rgba(55,224,255,0.05)";for(let l=0;l<90;l++)t.fillRect(o+l*97%256,a+(l*61+l*l%37)%256,2,2)});let s=new zt(e);return s.flipY=!1,s.wrapS=ln,s.wrapT=ln,s.anisotropy=4,s.colorSpace=dt,s}function bI(){let i=document.createElement("canvas");i.width=8,i.height=32;let e=i.getContext("2d");e.fillStyle="#1a2742",e.fillRect(0,0,8,32),e.fillStyle="#223556",e.fillRect(0,4,8,14),e.fillStyle="rgba(55,224,255,0.45)",e.fillRect(0,29,8,2);let t=new zt(i);return t.wrapS=zn,t.wrapT=zn,t.colorSpace=dt,t}function vI(i,e){let t=i.rooms.map((r,s)=>s),n=r=>t[r]===r?r:t[r]=n(t[r]);for(let[r,s]of e){let o=i.rooms.findIndex(u=>u.id===r),a=i.rooms.findIndex(u=>u.id===s);if(o<0||a<0)continue;let l=n(o),c=n(a);l!==c&&(t[Math.max(l,c)]=Math.min(l,c))}return t.map((r,s)=>n(s))}function _I(){let e=document.createElement("canvas");e.width=64,e.height=64;let t=e.getContext("2d"),n=t.createRadialGradient(64/2,64/2,0,64/2,64/2,64/2);n.addColorStop(0,"rgba(255,255,255,0.9)"),n.addColorStop(.2,"rgba(255,255,255,0.45)"),n.addColorStop(.55,"rgba(255,255,255,0.1)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,64,64);let r=new zt(e);return r.colorSpace=dt,r}function MI(){let e=S0,t=document.createElement("canvas");t.width=1024,t.height=1024;let n=t.getContext("2d");n.strokeStyle="rgba(91,124,255,0.16)",n.lineWidth=1;for(let o=0;o<=e;o++){let a=Math.round(o/e*1024)+.5;n.beginPath(),n.moveTo(a,0),n.lineTo(a,1024),n.moveTo(0,a),n.lineTo(1024,a),n.stroke()}n.globalCompositeOperation="destination-in";let r=n.createRadialGradient(1024/2,1024/2,1024*.12,1024/2,1024/2,1024/2);r.addColorStop(0,"rgba(0,0,0,1)"),r.addColorStop(1,"rgba(0,0,0,0)"),n.fillStyle=r,n.fillRect(0,0,1024,1024);let s=new zt(t);return s.anisotropy=4,s.colorSpace=dt,s}function m4(i,e){return new w0(i,e)}function _0(i,e,t,n){let[r,s,o]=e.size??Cs[e.lamp],a=e.base??0,l=(e.rotation??0)*mt,c=Math.cos(l),u=Math.sin(l),h=(x,m)=>[e.x+x*c-m*u,e.z+x*u+m*c],f=(x,m,g,y,_,b=14)=>{let M=[];for(let S=0;STt(i,[h(x,g),h(m,g),h(m,y),h(x,y)],_,b,M,S,{aoFrom:0,bottom:!0}),p=Math.max(.05,Math.min(r,s)/2);switch(e.lamp){case"ceiling":f(p*.25,t-.04,t,Je,Je,8),f(p,t-Math.max(.04,o)-.035,t-.04,n,n);break;case"pendant":{let x=Math.max(.4,t-o);f(.06,t-.02,t,Je,Je,8);let m=e.variant==="globe"?x+2*p:e.variant==="drum"?x+.24:x+.2;if(f(.008,m,t-.02,Je,Je,5),e.variant==="globe")for(let y=0;y<7;y++){let _=Math.PI*(y/7),b=Math.PI*((y+1)/7);f(p*Math.max(.2,Math.sin((_+b)/2)),x+p-p*Math.cos(_),x+p-p*Math.cos(b),n,n,14)}else if(e.variant==="cone")for(let y=0;y<4;y++)f(p*(.25+.75*(4-y)/4),x+.06*y,x+.06*(y+1),n,n,16);else e.variant==="drum"?f(p,x,x+.24,n,n,18):(f(p*.35,x+.14,x+.2,n,n,12),f(p,x,x+.14,n,n,16));break}case"fan":{let x=Math.max(.05,t-Math.max(.22,o)),m=x+.16;f(.07,t-.05,t,Je,Je,10),m[e.x+w*M-P*S,e.z+w*S+P*M];Tt(i,[v(.1,-.035),v(g,-.075),v(g,.075),v(.1,.035)],y,y+.012,S1,S1,{aoFrom:0,bottom:!0})}break}case"downlight":f(p,t-.012,t,Je,Je,12),f(p*.7,t-.02,t-.012,n,n,12);break;case"spot":f(p*.6,t-.02,t,Je,Je,10),f(p,t-Math.max(.06,o),t-.02,Je,Je,12),f(p*.8,t-Math.max(.06,o)-.008,t-Math.max(.06,o),n,n,12);break;case"panel":d(-r/2,r/2,-s/2,s/2,t-Math.max(.015,o),t,Je,Je),d(-r/2+.02,r/2-.02,-s/2+.02,s/2-.02,t-Math.max(.015,o)-.004,t-Math.max(.015,o),n);break;case"uplight":f(Math.max(.1,p*.6),a,a+.03,Je,Je),f(.014,a+.03,a+o-.12,Je,Je,6),f(p,a+o-.14,a+o-.02,Je,Je),f(p*.92,a+o-.02,a+o,n,n);break;case"bollard":f(p,a,a+o-.14,Je,Je,10),f(p*.9,a+o-.14,a+o-.03,n,n,10),f(p*1.1,a+o-.03,a+o,Je,Je,10);break;case"garden":f(.012,a,a+o-.08,Je,Je,5),f(p,a+o-.08,a+o-.01,Je,Je,10),f(p*.8,a+o-.01,a+o,n,n,10);break;case"floor":f(Math.max(.1,p*.7),a,a+.03,Je,Je),f(.014,a+.03,a+o-.28,Je,Je,6),f(p,a+o-.3,a+o,n,n);break;case"table":f(Math.max(.05,p*.55),a,a+.03,Je,Je),f(.012,a+.03,a+o-.16,Je,Je,6),f(p,a+o-.18,a+o,n,n);break;case"wall":{let x=e.base??Gl;d(-r/2+.03,r/2-.03,-s/2,-s/2+.02,x,x+o,Je),d(-r/2,r/2,-s/2+.02,s/2,x+o*.15,x+o*.85,n);break}case"strip":{let x=Math.max(.02,o),m=e.base!=null?e.base+x:t-.04,g=e.upright?0:(e.rise??0)*mt;if(!e.roll&&!e.upright&&!g){d(-r/2,r/2,-s/2,s/2,m-x,m,n);break}let y=(e.roll??0)*mt,_=Math.cos(y),b=Math.sin(y),[M,S]=[Math.cos(g),Math.sin(g)],v=e.upright?a+r/2:m-x/2+Oo(e.base,r,e.rise),w=(k,C,I)=>{let O=k,F=C*_-I*b,H=C*b+I*_;return e.upright?[O,F]=[-F,O]:g&&([O,F]=[O*M-F*S,O*S+F*M]),[e.x+O*c-H*u,v+F,e.z+O*u+H*c]},P=[w(-r/2,-x/2,-s/2),w(r/2,-x/2,-s/2),w(r/2,-x/2,s/2),w(-r/2,-x/2,s/2),w(-r/2,x/2,-s/2),w(r/2,x/2,-s/2),w(r/2,x/2,s/2),w(-r/2,x/2,s/2)],T=new W(n),R=[e.x,v,e.z],L=(k,C,I,O)=>{let[F,H,U]=[P[k],P[C],P[I]],X=[(H[1]-F[1])*(U[2]-F[2])-(H[2]-F[2])*(U[1]-F[1]),(H[2]-F[2])*(U[0]-F[0])-(H[0]-F[0])*(U[2]-F[2]),(H[0]-F[0])*(U[1]-F[1])-(H[1]-F[1])*(U[0]-F[0])],V=[F[0]-R[0],F[1]-R[1],F[2]-R[2]],re=X[0]*V[0]+X[1]*V[1]+X[2]*V[2]<0,[ye,Y,Q,se]=re?[P[O],P[I],P[C],P[k]]:[P[k],P[C],P[I],P[O]];i.tri(ye,Y,Q,T,T,T),i.tri(ye,Q,se,T,T,T)};L(0,1,2,3),L(4,5,6,7),L(0,1,5,4),L(1,2,6,5),L(2,3,7,6),L(3,0,4,7);break}}}export{zi as ModelError,w0 as NextFloorViewer,m4 as createViewer,dI as furniturePreview,lI as inspectModel,Gy as isLowEnd,cI as prepareModel,uI as previewModel,_0 as pushLampModel}; + #endif`;function eC(i){let e=new Ye({map:i,transparent:!0,blending:Ft,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-2});return e.onBeforeCompile=t=>{t.vertexShader=t.vertexShader.replace("#include ",JR).replace("#include ",jR),t.fragmentShader=t.fragmentShader.replace("#include ",`#include +varying vec2 vNfTile;`).replace("#include ",QR)},e.customProgramCacheKey=()=>"nf-pattern",e}var rh=(i={})=>new Ye({vertexColors:!0,transparent:!0,blending:Ft,depthWrite:!1,...i});function jb({mask:i,look:e,theme:t,textures:n}){let r=(o={})=>new Ye({vertexColors:!0,...o}),s=(o,a)=>Kb(o,i,a);return{floor:jn(r(),e),pattern:eC(n.pattern),wall:Qu(jn(s(r(),"solid"),e)),glassWall:s(r({transparent:!0,depthWrite:!1}),"glass"),shadow:r({blending:Ya,premultipliedAlpha:!0,transparent:!0,depthWrite:!1,side:ht,polygonOffset:!0,polygonOffsetFactor:-1}),lines:jn(s(new Lt({vertexColors:!0,transparent:!0,blending:Sl(t),depthWrite:!1})),e,!0),glow:s(rh({side:ht,polygonOffset:!0,polygonOffsetFactor:-3}),"solid"),frames:jn(s(r({side:ht})),e),glass:s(rh({side:ht})),blinds:jn(s(r({map:n.blinds,side:ht})),e),lamps:jn(r(),e),halos:new cn({map:n.halo,size:.9,sizeAttenuation:!0,vertexColors:!0,transparent:!0,blending:Ft,depthWrite:!1}),cones:rh({side:ht}),screens:rh({side:ht}),ghosts:[]}}var sh=i=>Object.assign(document.createElement("span"),{className:i});function Qb(i,e){let t=Object.assign(document.createElement("button"),{className:"nf-dev"});t.dataset.entity=i,t.append(sh("nf-dev-icon"),sh("nf-dev-text"),sh("nf-dev-watt"),sh("nf-dev-name"));let n,r=!1,s=a=>{let{x:l,y:c}=e.centre(t);a(i,l,c)},o=()=>clearTimeout(n);t.addEventListener("pointerdown",a=>{if(e.furnishing())return e.pressedWhileFurnishing(i);a.stopPropagation(),r=!1,o(),n=setTimeout(()=>{r=!0,s(e.hold)},500)});for(let a of["pointerleave","pointercancel","pointerup"])t.addEventListener(a,o);return t.addEventListener("contextmenu",a=>a.preventDefault()),t.addEventListener("click",a=>{if(a.stopPropagation(),e.furnishing())return e.selectWhileFurnishing(i);r||s(e.tap)}),t.addEventListener("keydown",a=>{(a.key==="Enter"&&a.shiftKey||a.key==="ContextMenu")&&(a.preventDefault(),s(e.hold))}),t}function ev(i,e=10,t="NextFloor"){let n=[];for(let{positions:o,lift:a}of i)for(let l=0;l+8[o[l+x]*e,-o[l+x+2]*e,(o[l+x+1]+a)*e]),[u,h,f]=c,d=[(h[1]-u[1])*(f[2]-u[2])-(h[2]-u[2])*(f[1]-u[1]),(h[2]-u[2])*(f[0]-u[0])-(h[0]-u[0])*(f[2]-u[2]),(h[0]-u[0])*(f[1]-u[1])-(h[1]-u[1])*(f[0]-u[0])],p=Math.hypot(d[0],d[1],d[2]);p<1e-9||n.push([d[0]/p,d[1]/p,d[2]/p,...u,...h,...f])}let r=new Uint8Array(84+n.length*50),s=new DataView(r.buffer);return r.set(new TextEncoder().encode(`${t} STL`.slice(0,79)),0),s.setUint32(80,n.length,!0),n.forEach((o,a)=>{let l=84+a*50;o.forEach((c,u)=>s.setFloat32(l+u*4,c,!0))}),r}var Ps=Math.PI/180;function tv(i,e,t){let n=i.getTime()/864e5-10957.5,r=(357.529+.98560028*n)*Ps,o=(280.459+.98564736*n+1.915*Math.sin(r)+.02*Math.sin(2*r))*Ps,a=(23.439-36e-8*n)*Ps,l=Math.atan2(Math.cos(a)*Math.sin(o),Math.cos(o)),c=Math.asin(Math.sin(a)*Math.sin(o)),h=(((18.697374558+24.06570982441908*n)%24+24)%24*15+t)*Ps-l,f=e*Ps,d=Math.asin(Math.sin(f)*Math.sin(c)+Math.cos(f)*Math.cos(c)*Math.cos(h)),p=Math.atan2(Math.sin(h),Math.cos(h)*Math.sin(f)-Math.tan(c)*Math.cos(f))/Ps+180;return{elevation:d/Ps,azimuth:(p%360+360)%360}}function Op(i,e){let t=Object.fromEntries(new Intl.DateTimeFormat("en-US",{timeZone:e,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}).formatToParts(new Date(i)).map(n=>[n.type,Number(n.value)]));return Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second)}function nv(i,e,t=new Date){let[n,r]=[Math.floor(i),Math.round(i%1*60)];if(e)try{let o=new Date(Op(t.getTime(),e)),a=Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate(),n,r),l=a-(Op(a,e)-a);return l=a-(Op(l,e)-l),new Date(l)}catch{}let s=new Date(t);return s.setHours(n,r,0,0),s}function tC(i,e=new Date){let t=[];for(let n=0;n<=24;n+=.25){let r=tv(nv(Math.min(n,23.99),i.zone,e),i.latitude,i.longitude);r.elevation<0||t.push(iv(i,r))}return t}function iv(i,e){let[t,n]=Do(e.azimuth,i.north),r=Math.max(0,e.elevation)*Math.PI/180;return[i.centre[0]+t*i.radius*Math.cos(r),Math.sin(r)*i.radius*.9,i.centre[1]+n*i.radius*Math.cos(r)]}function nC(i,e){let t=document.createElement("canvas");t.width=t.height=64;let n=t.getContext("2d");n&&(n.font="bold 44px system-ui, sans-serif",n.fillStyle=e,n.textAlign="center",n.textBaseline="middle",n.fillText(i,32,34));let r=new er(new _i({map:new zt(t),transparent:!0,depthWrite:!1,depthTest:!1}));return r.renderOrder=20,r}var oh=class{group=new et;key="";constructor(){this.group.visible=!1,this.group.renderOrder=15}update(e,t,n){let r=e?`${e.centre},${e.radius.toFixed(1)},${e.north},${e.latitude.toFixed(2)},${e.longitude.toFixed(2)},${new Date().toDateString()},${n},${t?`${t.elevation.toFixed(0)},${t.azimuth.toFixed(0)}`:"-"}`:"off";if(r===this.key)return;if(this.key=r,this.clear(),!e){this.group.visible=!1;return}this.group.visible=!0;let s=n+.05,o=[];for(let h=0;h<=96;h++){let f=h/96*Math.PI*2;o.push(e.centre[0]+Math.cos(f)*e.radius,s,e.centre[1]+Math.sin(f)*e.radius)}let a=new Pe;a.setAttribute("position",new Le(o,3)),this.group.add(new In(a,new Lt({color:7311304,transparent:!0,opacity:.55,depthWrite:!1})));let l=[];[["N",0],["E",90],["S",180],["W",270]].forEach(([h,f])=>{let[d,p]=Do(f,e.north);l.push(e.centre[0]+d*e.radius*.94,s,e.centre[1]+p*e.radius*.94,e.centre[0]+d*e.radius*1.04,s,e.centre[1]+p*e.radius*1.04);let x=nC(h,h==="N"?"#ff6b6b":"#9fb4d8");x.position.set(e.centre[0]+d*e.radius*1.12,s+.4,e.centre[1]+p*e.radius*1.12),x.scale.setScalar(Math.max(1.2,e.radius*.12)),this.group.add(x)});let c=new Pe;c.setAttribute("position",new Le(l,3)),this.group.add(new xn(c,new Lt({color:10466520,transparent:!0,opacity:.8,depthWrite:!1})));let u=tC(e).map(([h,f,d])=>[h,n+f,d]);if(u.length>1){let h=new Pe;h.setAttribute("position",new Le(u.flat(),3)),this.group.add(new In(h,new Lt({color:16761415,transparent:!0,opacity:.85,depthWrite:!1})))}if(t&&t.elevation>0){let[h,f,d]=iv(e,t),p=new Se(new ir(Math.max(.35,e.radius*.035),12,8),new Ye({color:16765530}));p.position.set(h,n+f,d),this.group.add(p)}}clear(){for(let e of[...this.group.children]){this.group.remove(e);let t=e;t.geometry?.dispose();let n=t.material;n?.map?.dispose(),n?.dispose()}}dispose(){this.clear()}};var iC=["straight","quarter","l","half","u","spiral"],rC=["solid","stringer","mono","cantilever"],sC=["none","left","right","both"],oC=["headroom","full","none"],ah={shape:"straight",turn:"right",build:"solid",risers:!0,steps:null,run_width:null,down:!1,rail:"none",opening:"headroom",landing_after:null};var lv=2,cv=40,aC=2.2,lh=(i,e)=>typeof e=="string"&&i.includes(e);function Dp(i){let e=i.stair??{},t=typeof e.steps=="number"&&Number.isFinite(e.steps)?Math.round(Math.min(cv,Math.max(lv,e.steps))):null,n=typeof e.run_width=="number"&&Number.isFinite(e.run_width)&&e.run_width>.2?e.run_width:null;return{shape:lh(iC,e.shape)?e.shape:ah.shape,turn:e.turn==="left"?"left":"right",build:lh(rC,e.build)?e.build:ah.build,risers:e.risers!==!1,steps:t,run_width:n,down:e.down===!0,rail:lh(sC,e.rail)?e.rail:ah.rail,opening:lh(oC,e.opening)?e.opening:ah.opening,landing_after:typeof e.landing_after=="number"&&Number.isFinite(e.landing_after)?Math.max(1,Math.round(e.landing_after)):null}}var uh=i=>i.type==="stairs"&&!!i.stair,Tl=(i,e,t)=>[i[0]+(e[0]-i[0])*t,i[1]+(e[1]-i[1])*t],rv=(i,e)=>Math.abs(i[0]-e[0])<1e-6&&Math.abs(i[1]-e[1])<1e-6;function uv(i){let e=[];for(let t of i)(!e.length||!rv(e[e.length-1],t))&&e.push(t);for(;e.length>1&&rv(e[0],e[e.length-1]);)e.pop();return e}function Al(i,e,t=!1){return{poly:uv([...i,...[...e].reverse()]),landing:t,left:i,right:e}}function wl(i,e,t,n,r){let s=[];for(let o=0;oe+1e-6&&ri.reduce((e,t,n)=>n?e+Math.hypot(t[0]-i[n-1][0],t[1]-i[n-1][1]):e,0);function ov(i,e,t,n,r){let s=cC(i),o=[];for(let a=0;a=8?3:2),[f,d]=i.shape==="l"?av(i,n)??ch(n-h,t-l,e-l):ch(n-h,t-l,e-l),p=wl([r,a],[r+l,a],[r,o+l],c,f),x=i.shape==="l"?[Al(u,[c],!0)]:ov(u,c,c,c,h),m=wl([r+l,o],c,[s,o],[s,o+l],d);return{treads:[...p,...x,...m],flight:l,column:0}}case"half":case"u":{let l=Math.min(i.run_width??Math.min(1.1,(e-.1)/2),(e-.02)/2),c=o+l,u=[[r,c],[r,o],[s,o],[s,c]],[h,f]=[[r+l,c],[s-l,c]],d=i.shape==="u"?1:Math.min(n,n>=12?6:n>=8?4:2),[p,x]=i.shape==="u"?av(i,n)??ch(n-d,t-l,t-l):ch(n-d,t-l,t-l),m=wl([r,a],[r+l,a],[r,c],h,p),g=i.shape==="u"?[Al(u,[h,f],!0)]:ov(u,h,[0,c],f,d),y=wl([s,c],f,[s,a],[s-l,a],x);return{treads:[...m,...g,...y],flight:l,column:0}}case"spiral":{let l=Math.min(e,t)/2,c=Math.min(.08,l*.12),u=Math.min(.75,Math.max(.3,.22/(l*.6))),h=(d,p)=>[Math.cos(p)*d,Math.sin(p)*d],f=[];for(let d=0;dh(l,p+(x-p)*g));f.push(Al(m,[h(c,p),h(c,x)]))}return{treads:f,flight:l-c,column:c}}default:return{treads:wl([r,a],[s,a],[r,o],[s,o],n),flight:e,column:0}}}var hC=(i,e)=>i.steps??Math.min(cv,Math.max(lv,Math.round(Math.abs(e)/.18)));function kp(i,e,t,n){let r=hC(i,n),s=Math.abs(n)/r,o=uC(i,Math.max(.3,e),Math.max(.3,t),r),a=c=>[-c[0],c[1]];return{treads:o.treads.map((c,u)=>{let h=i.down?-s*(u+1):s*(u+1);return i.turn==="right"?{...c,top:h}:{poly:c.poly.map(a).reverse(),top:h,landing:c.landing,left:c.right.map(a),right:c.left.map(a)}}),rise:s,steps:r,column:o.column,flight:o.flight}}function hv(i){let e=i.poly.reduce((t,n)=>[t[0]+n[0],t[1]+n[1]],[0,0]);return[e[0]/i.poly.length,e[1]/i.poly.length]}function fC(i,e,t,n="headroom"){if(n==="none")return[];let r=t?0:Math.abs(e),s=n==="full"?i.treads:i.treads.filter((o,a)=>o.top>r-aC||!t&&a===i.treads.length-1||t&&a===0);return mr(s.map(o=>o.poly).filter(o=>o.length>=3))}function Up(i){let e=Dp(i),t=fC(kp(e,i.w,i.d,i.h),i.h,e.down,e.opening),n=i.rotation*Math.PI/180,[r,s]=[Math.cos(n),Math.sin(n)],o=i.mirror?-1:1;return t.map(a=>a.map(([l,c])=>[i.x+o*l*r-c*s,i.z+o*l*s+c*r]))}function ki(i,e,t,n,r,s,o=Fe.metal,a=!1){let[l,c]=[e/2-s-r,t/2-s-r],u=He(o);for(let h of[-1,1])for(let f of[-1,1]){let[d,p]=[h*l,f*c];a?i.loft([d-r*.3,d+r*.3,p-r*.3,p+r*.3],[d-r/2,d+r/2,p-r/2,p+r/2],0,n,u):i.block({x:[d-r/2,d+r/2],y:[0,n],z:[p-r/2,p+r/2]},u)}}function Is(i,e,t,n,r,s,o,a=null,l=!1){let c=(t-e)/o;for(let u=1;u1?h+(u%2?-c/2+.06:c/2-.06):h+c/2-.06;i.seg(d,f-.08,s+.012,d,f+.08,s+.012,Ze)}}}function di(i,e,t,n,r,s=null,o=!1,a=q.body){i.block({x:[-e/2,e/2],y:[.02,n],z:[-t/2,t/2-.02]},a,ue),i.block({x:[-e/2+.02,e/2-.02],y:[0,.08],z:[-t/2+.02,t/2-.06]},He(Fe.dark)),Is(i,-e/2,e/2,.08,n,t/2-.02,r,s,o)}function Bp(i,e,t,n,r){let[s,o,a,l]=[-e/2,e/2,-t/2,t/2],c=Math.min(.2,e*.12),u=n*.5,h=Math.min(.24,t*.28);ki(i,e,t,.07,.05,.05,Fe.wood,!0),i.pad({x:[s,o],y:[.07,u-.08],z:[a+.02,l]},q.fabric,.04,ue),i.loft([s,o,a,a+h],[s+.01,o-.01,a,a+h*.5],u-.08,n,q.fabric,ue);for(let[d,p]of[[s,s+c],[o-c,o]])i.pad({x:[d,p],y:[u-.08,n*.72],z:[a+.02,l-.02]},q.fabric,.04,ue);let f=(o-c-(s+c))/r;for(let d=0;d1.2?2:1,f=(e-.2)/h;for(let d=0;d0?.05:0),o*(e/2)+(o<0?.05:0)],y:[0,n],z:[a*(t/2)-(a>0?.05:0),a*(t/2)+(a<0?.05:0)]},q.wood);for(let o of[.25,n-.55])i.block({x:[-e/2,e/2],y:[o,o+.08],z:[-t/2,t/2]},q.wood,ue),i.block({x:[-e/2+.04,e/2-.04],y:[o+.08,o+.24],z:[-t/2+.05,t/2-.05]},q.bedding,Te),i.block({x:[-e/2+.05,e/2-.05],y:[o+.24,o+.33],z:[-t/2+.08,-t/2+.4]},q.pillow);i.block({x:[-e/2,e/2],y:[n-.2,n-.15],z:[t/2-.05,t/2]},q.wood);let s=e/2-.35;for(let o of[s-.18,s+.18])i.seg(o,0,t/2+.02,o,n-.15,t/2+.02,ue);for(let o=.3;oi.block({x:[-e/2,e/2],y:[n-.04,n],z:[-t/2,t/2]},q.worktop,ue);function bv(i,e,t,n){di(i,e,t-.02,n-.04,Math.max(1,Math.round(e/.6)),n-.2),Gp(i,e,t,n)}function vv(i,e,t,n){i.block({x:[-e/2,e/2],y:[Math.max(0,n-.04),n],z:[-t/2,t/2]},q.worktop,ue)}function _v(i,e,t,n){i.block({x:[-e/2,e/2],y:[0,n],z:[-t/2,t/2]},q.white,ue);let r=n*.62;i.seg(-e/2,r,t/2,e/2,r,t/2,Te);let s=e/2-.06;i.seg(s,r+.08,t/2+.015,s,r+.4,t/2+.015,Ze),i.seg(s,r-.4,t/2+.015,s,r-.08,t/2+.015,Ze)}var Hp=.06;function Mv(i,e,t,n){let r=t/2-Hp;i.block({x:[-e/2,e/2],y:[.02,n],z:[-t/2,r]},q.body,ue),i.block({x:[-e/2+.05,e/2-.05],y:[0,.02],z:[-t/2+.05,r-.05]},q.dark);for(let s of[.35,.7,1.05,1.4])s>n-.15||(i.seg(-e/2+.03,s,r+.001,-.03,s,r+.001,Te),i.seg(.03,s,r+.001,e/2-.03,s,r+.001,Te))}var Vp=1.83;function dC(i,e,t,n,r){let[s,o]=[Math.cos(e.rotation*mt),Math.sin(e.rotation*mt)],a=e.mirror?-1:1,l=(y,_)=>[e.x+a*y*s-_*o,e.z+a*y*o+_*s],[c,u]=[t+.05,t+e.h-.02],h=new W(.75,.1,.14),f=new W(Fe.dark),d=new W(Fe.accent),p=e.w/2-.006,x=(y,_,b)=>{let M=b/Vp,S=new W(2043212).lerp(h,M),v=new W(Fe.body).lerp(h,M*.8),[w,P]=[Math.cos(b),Math.sin(b)],T=(U,C)=>l(y+_*(U*w-C*P),e.d/2+U*P+C*w),R=(U,C,I,O)=>{let[F,H,k,X]=U;i.tri([F[0],C,F[1]],[H[0],C,H[1]],[k[0],I,k[1]],O),i.tri([F[0],C,F[1]],[k[0],I,k[1]],[X[0],I,X[1]],O)},L=(U,C,I,O,F,H,k,X=k)=>{let V=[T(U,H),T(C,H),T(C,F),T(U,F)];R([V[0],V[1],V[1],V[0]],I,O,X),R([V[3],V[2],V[2],V[3]],I,O,k),R([V[0],V[3],V[3],V[0]],I,O,k),R([V[1],V[2],V[2],V[1]],I,O,k),R([V[0],V[1],V[2],V[3]],O,O,k),R([V[3],V[2],V[1],V[0]],I,I,k)};return L(0,p,c,u,-Hp,0,v,S),L(p-.05,p-.03,t+e.h*.45,t+e.h*.75,.005,.025,d),L};x(-e.w/2,1,n*Vp)(.12,.3,t+e.h*.5,t+e.h*.68,.001,.005,f),x(e.w/2,-1,r*Vp)(.06,p-.06,t+e.h*.52,t+e.h*.86,.001,.005,f)}function Wp(i,e,t,n,r){let s=i.p.length;dC(i,e,t,n,r),e.mirror&&Ss(i,s)}function Sv(i,e,t,n){di(i,e,t-.02,n-.04,1,n-.24,!0),i.block({x:[-e/2,e/2],y:[n-.04,n],z:[-t/2,t/2]},q.dark,ue);let r=[[-.14,-.13,.09],[.14,-.13,.07],[-.14,.13,.07],[.14,.13,.09]];for(let[s,o,a]of r)i.cylinder(s*e/.6,o*t/.62,a,n,n+.004,He(Fe.dark,1451583),12,Ze)}function wv(i,e,t,n){di(i,e,t-.02,n-.04,Math.max(1,Math.round(e/.45)),n-.2);let r=Math.min(.5,e-.2),s=(o,a,l,c,u=!1)=>i.block({x:[o,a],y:[n-.04,n],z:[l,c]},q.worktop,u?ue:null);s(-e/2,-r/2,-t/2,t/2,!0),s(r/2,e/2,-t/2,t/2,!0),s(-r/2,r/2,-t/2,-t/2+.1),s(-r/2,r/2,t/2-.08,t/2),i.block({x:[-r/2,r/2],y:[n-.2,n-.17],z:[-t/2+.1,t/2-.08]},q.metal,Ze),i.cylinder(0,-t/2+.05,.02,n,n+.28,q.metal,8),i.block({x:[-.015,.015],y:[n+.24,n+.28],z:[-t/2+.05,-t/2+.22]},q.metal)}function Tv(i,e,t,n){i.block({x:[-e/2,e/2],y:[1.45,1.45+n],z:[-t/2,t/2-.02]},q.body,ue),Is(i,-e/2,e/2,1.45,1.45+n,t/2-.02,Math.max(1,Math.round(e/.5)),1.45+.08)}function Av(i,e,t,n){i.block({x:[-e/2,e/2],y:[.02,n],z:[-t/2,t/2-.02]},q.body,ue),i.block({x:[-e/2+.02,e/2-.02],y:[0,.08],z:[-t/2+.02,t/2-.06]},q.dark);let r=t/2-.02;i.block({x:[-e/2+.03,e/2-.03],y:[.85,1.45],z:[r,r+.01]},q.dark,Ze),i.seg(-e/2+.08,1.4,r+.02,e/2-.08,1.4,r+.02,Ze);for(let s of[.85,1.45])i.seg(-e/2,s,r,e/2,s,r,Te);i.seg(e/2-.06,.5,r+.012,e/2-.06,.7,r+.012,Ze),i.seg(e/2-.06,1.6,r+.012,e/2-.06,1.8,r+.012,Ze)}function Ev(i,e,t,n){let r=t-.3;i.block({x:[-e/2+.05,e/2-.05],y:[.08,n-.04],z:[-t/2+.02,-t/2+r]},q.body,ue),i.block({x:[-e/2+.07,e/2-.07],y:[0,.08],z:[-t/2+.04,-t/2+r-.04]},q.dark),Is(i,-e/2+.05,e/2-.05,.08,n-.04,-t/2+r,Math.max(2,Math.round(e/.6)),n-.2),Gp(i,e,t,n)}function Rv(i,e,t,n){i.block({x:[-e/2,e/2],y:[.02,n-.04],z:[-t/2,t/2-.02]},q.body,ue),i.block({x:[-e/2+.02,e/2-.02],y:[0,.08],z:[-t/2+.02,t/2-.06]},q.dark),i.seg(-e/2+.08,n-.12,t/2-.008,e/2-.08,n-.12,t/2-.008,Ze),Gp(i,e,t,n)}function Xp(i,e,t,n,r){i.block({x:[-e/2,e/2],y:[0,n],z:[-t/2,t/2-.02]},q.white,ue);let s=t/2-.012;i.seg(-e/2,n-.14,s,e/2,n-.14,s,Te),i.seg(e/2-.16,n-.07,s,e/2-.08,n-.07,s,Ze);let o=(n-.14)/2+.04,a=Math.min(e*.36,(n-.2)*.42),l=20;for(let c=0;ci.seg(Math.cos(u)*a*d,o+Math.sin(u)*a*d,s,Math.cos(h)*a*d,o+Math.sin(h)*a*d,s,p);f(1,Ze),r||f(.72,Te)}}function Cv(i,e,t,n){i.block({x:[-e/2,e/2],y:[0,n-.02],z:[-t/2,t/2]},q.white,ue);let s=(o,a,l,c)=>i.block({x:[o,a],y:[n-.02,n],z:[l,c]},q.worktop);s(-e/2,e/2,-t/2,-t/2+.07),s(-e/2,e/2,t/2-.07,t/2),s(-e/2,-e/2+.07,-t/2+.07,t/2-.07),s(e/2-.07,e/2,-t/2+.07,t/2-.07),i.block({x:[-e/2+.07,e/2-.07],y:[n-.03,n-.02],z:[-t/2+.07,t/2-.07]},q.glass,Ze),i.cylinder(-e/2+.04,0,.02,n,n+.12,q.metal,8)}function Pv(i,e,t,n){i.block({x:[-e/2,e/2],y:[0,.05],z:[-t/2,t/2]},q.worktop,ue),i.cylinder(0,0,.04,.05,.052,q.metal,8);for(let[r,s,o,a]of[[-e/2,t/2,e/2,t/2],[e/2,-t/2,e/2,t/2]])i.seg(r,.05,s,o,.05,a,Ze),i.seg(r,n,s,o,n,a,Ze),i.seg(o,.05,a,o,n,a,Ze);i.cylinder(-e/2+.06,-t/2+.06,.015,.05,n-.05,q.metal,6),i.cylinder(-e/2+.2,-t/2+.2,.1,n-.08,n-.06,q.metal,12,Ze)}function Iv(i,e,t,n){let r=Math.min(.18,t*.3);i.block({x:[-e/2,e/2],y:[.45,n],z:[-t/2,-t/2+r]},q.white,ue),i.block({x:[-e*.3,e*.3],y:[0,.36],z:[-t/2+r-.02,t/2-.12]},q.white),i.cylinder(0,t/2-.26,Math.min(e/2,.19),.36,.41,q.white,12,ue),i.block({x:[-e/2+.02,e/2-.02],y:[.41,.43],z:[-t/2+r,-t/2+r+.05]},q.worktop)}function Lv(i,e,t,n){di(i,e,t-.02,n-.12,e>.8?2:1,n-.3),i.block({x:[-e/2,e/2],y:[n-.12,n],z:[-t/2,t/2]},q.white,ue),i.block({x:[-e/2+.07,e/2-.07],y:[n-.005,n],z:[-t/2+.12,t/2-.06]},q.glass,Ze),i.cylinder(0,-t/2+.06,.018,n,n+.2,q.metal,8),i.block({x:[-e/2+.04,e/2-.04],y:[n+.35,n+1],z:[-t/2,-t/2+.02]},q.glass,Ze)}var El=.12;function Fv(i,e,t,n){let r=El;i.block({x:[-e/2+.05,-e/2+.08],y:[0,r],z:[-t/2,-t/2+.03]},q.metal),i.block({x:[e/2-.08,e/2-.05],y:[0,r],z:[-t/2,-t/2+.03]},q.metal),i.block({x:[-e/2,e/2],y:[r,r+n],z:[-t/2+.02,t/2]},q.white,ue);let s=Math.max(3,Math.round(e/.1));for(let o=1;oi.block({x:[-e/2,e/2],y:[1.1,1.1+n],z:[-t/2,t/2]},l,ue);if(r==="slim"){a(q.darkBody),i.seg(-e*.25,1.1+n*.15,o+.004,-e*.25,1.1+n*.85,o+.004,Ze),i.block({x:[-e*.1,e*.3],y:[1.1+n*.7,1.1+n*.85],z:[o,o+.005]},q.dark);return}if(a(q.white),r==="hybrid"){i.ring(0,1.1+n*.66,Math.min(e,n)*.22,o+.004,20,Ze),i.seg(-e*.08,1.1+n*.66,o+.005,e*.08,1.1+n*.66,o+.005,Ze);for(let l of[-1,1])i.ring(l*e*.22,1.1+n*.2,Math.min(e,n)*.1,-t/2-.002,12,Ze);return}i.block({x:[-e*.28,e*.28],y:[1.1+n*.58,1.1+n*.82],z:[t/2,t/2+.006]},q.dark),i.seg(-e*.3,1.1+n*.45,t/2+.004,e*.3,1.1+n*.45,t/2+.004,Ze);for(let l of[-1,1])for(let c=1;c<6;c++)i.seg(l*e/2+l*.002,1.1+n*c/6,-t/2+.03,l*e/2+l*.002,1.1+n*c/6,t/2-.03,Te)}function Kv(i,e,t,n){i.block({x:[-e/2,e/2],y:[0,n],z:[-t/2,t/2]},q.darkBody,ue),i.block({x:[-e/2-.01,e/2+.01],y:[n,n+.03],z:[-t/2-.01,t/2+.01]},q.darkBody),i.seg(-e/2,n+.032,t/2+.01,e/2,n+.032,t/2+.01,Ze),i.seg(-e*.3,n*.55,t/2+.003,e*.3,n*.55,t/2+.003,Te)}function Zv(i,e,t,n){i.block({x:[-e/2,e/2],y:[1,1+n],z:[-t/2,t/2]},q.darkBody,ue),i.ring(0,1+n*.58,Math.min(e,n)*.28,t/2+.003,16,Ze),i.block({x:[-.015,.015],y:[1-.35,1],z:[t/2-.03,t/2]},q.dark),i.block({x:[-.06,.06],y:[1-.42,1-.35],z:[t/2-.05,t/2]},q.darkBody)}function Jv(i,e,t,n){i.block({x:[-e/2,e/2],y:[.4,.4+n],z:[-t/2,t/2]},q.white,ue),i.seg(-e/2+.025,.4+.025,t/2+.003,-e/2+.025,.4+n-.025,t/2+.003,Te),i.seg(-e/2+.025,.4+n-.025,t/2+.003,e/2-.025,.4+n-.025,t/2+.003,Te),i.block({x:[e/2-.06,e/2-.035],y:[.4+n*.5-.05,.4+n*.5+.05],z:[t/2,t/2+.012]},q.dark),i.block({x:[-e*.3,e*.3],y:[.4+n*.6,.4+n*.8],z:[t/2,t/2+.005]},q.dark),i.seg(-e*.22,.4+n*.7,t/2+.008,e*.22,.4+n*.7,t/2+.008,Ze)}function jv(i,e,t,n,r){if(r==="wall"){i.block({x:[-e/2,e/2],y:[.5,.5+n],z:[-t/2,t/2]},q.white,ue),i.seg(-e*.3,.5+n*.9,t/2+.004,e*.3,.5+n*.9,t/2+.004,Ze),i.seg(-e*.3,.5+n*.08,t/2+.003,e*.3,.5+n*.08,t/2+.003,Te);return}if(r==="cube"){i.block({x:[-e/2+.01,e/2-.01],y:[0,.03],z:[-t/2+.01,t/2-.01]},q.dark),i.block({x:[-e/2,e/2],y:[.03,n],z:[-t/2,t/2]},q.darkBody,ue),i.seg(-e*.35,n*.85,t/2+.004,e*.35,n*.85,t/2+.004,Ze),i.block({x:[-e*.15,e*.15],y:[n,n+.025],z:[-.012,.012]},q.dark);return}i.block({x:[-e/2+.02,e/2-.02],y:[0,.06],z:[-t/2+.02,t/2-.02]},q.dark);let s=Math.max(2,Math.round((n-.06)/.3)),o=(n-.06)/s;for(let a=0;a[x[0]+h*m,x[1]+f*m];i.prism([e,t,p(t,o),p(e,o)],r,s,a,Te)}var pC=i=>i.slice(1).map((e,t)=>[i[t],e]).filter(([e,t])=>Math.hypot(t[0]-e[0],t[1]-e[1])>.01);function mC(i,e,t,n,r){let s=e.build==="cantilever"?.07:.05;t.forEach((o,a)=>{let l=hv(o),c=a===0?0:t[a-1].top;if(e.build==="solid"){i.prism(o.poly,Math.min(r,o.top),o.top,q.body,ue);return}if(i.prism(o.poly,o.top-s,o.top,q.wood,ue),e.risers&&!o.landing){let[u,h]=[Math.min(c,o.top),Math.max(c,o.top)-s];Qv(i,o.left[0],o.right[0],l,u,h,.02)}if(e.build==="stringer")for(let u of[o.left,o.right])for(let[h,f]of pC(u))Qv(i,h,f,l,o.top-n-.2,o.top+.05,.04);else e.build==="mono"&&i.block({x:[l[0]-.07,l[0]+.07],y:[o.top-n-.12,o.top-s],z:[l[1]-.07,l[1]+.07]},q.metal)})}function gC(i,e,t){let n=e.rail==="both"?["left","right"]:e.rail==="none"?[]:[e.rail];for(let r of n){let s=[];for(let o of t)for(let a of o[r])s.push([a[0],o.top+hh,a[1]]);for(let[o,a]of t.entries()){if(o%2&&o!==t.length-1)continue;let l=a[r][0];i.cylinder(l[0],l[1],.012,a.top,a.top+hh,q.metal,6)}for(let o=1;o0&&i.cylinder(0,0,o.column,Math.min(0,a),s.down?0:r,q.metal,12,ue),mC(i,s,o.treads,o.rise,a),gC(i,s,o.treads)}var xC=(i,e="Station 1")=>({id:i,name:e,has_valve:!0}),fh=i=>i.has_valve!==!1;function dh(i){let e=i.hydronic??{};return e.stations?.length?e.stations.slice(0,16):[{...xC("station-1"),flow:e.flow,return:e.return,hot_water:e.hot_water,cold_water:e.cold_water,pump:e.pump}]}var yC=(i,e="Heizkreis")=>({id:i,name:e,kind:"heating",has_pump:!0,has_valve:!0});function bC(i){return{card:!0,...i==="heating_manifold"?{circuits:[yC("c1","Heizkreis 1")]}:{},...i==="buffer_tank"?{sensors:Array.from({length:7},(e,t)=>({id:`s${t+1}`,name:`F\xFChler ${t+1}`,entity:null,level:1-t/6}))}:{}}}function Rl(i){return{...bC(i.type),...i.hydronic}}var Cl=i=>i.has_pump!==!1,Ls=i=>i.kind!=="pump"&&i.has_valve!==!1,t_=(i,e)=>-.4+.8*(i+.5)/Math.max(1,e),Yp=i=>!!i&&i!=="none";function ph(i,e,t,n){let r=Math.min(i.w*.8/Math.max(1,n),i.h*.5),s=i.w*t_(t,n),o=s-r*.22,a=s+r*.22,l=i.d*.16,c=-i.d*.14,u=i.h*.15,h=i.h*.07,f=i.h*.24,d=i.h*.34,p=i.h*.55,x=i.h*.73,m=i.h*.87,g=Math.min(r*.04,i.h*.018,i.d*.08),y=Math.min(r*.13,i.h*.055,i.d*.28),_=Math.min(r*.09,i.h*.04,i.d*.18),b=Math.min(r*.06,i.h*.025,i.d*.14),M=l+Math.min(i.d*.28,y*.8),S=l+Math.min(i.d*.24,_*.9),v=l+g+b*.65,w=o-r*.13,P=a+r*.13,T=Ls(e)&&e.valve_type!=="two_way",R=Math.min(r*.23,i.h*.115),L=l+Math.min(i.d*.22,R*.4),U=e.kind==="pump"?i.h*.93:m,C=[{from:[o,u,c],to:[o,f,c],kind:"flow"},{from:[o,f,c],to:[o,f,l],kind:"flow"},{from:[o,f,l],to:[o,U,l],kind:"flow"},{from:[a,h,l],to:[a,U,l],kind:"return"}];return T&&C.push({from:[o,d,l],to:[a,d,l],kind:"mix"}),e.kind!=="pump"&&(C.push({from:[o,m,l],to:[s-R,m,l],kind:"flow"}),C.push({from:[s+R,m,l],to:[a,m,l],kind:"return"})),{x:s,column:r,flowX:o,returnX:a,frontZ:l,backZ:c,flowHeaderY:u,returnHeaderY:h,valveY:d,pumpY:p,temperatureY:x,loadY:m,loadR:R,loadFront:L,pipeR:g,pumpR:y,valveR:_,gaugeR:b,pumpFront:M,valveFront:S,gaugeFront:v,flowGaugeX:w,returnGaugeX:P,mixing:T,topY:U,pipes:C}}function ko(i){let{w:e,d:t,h:n}=i,r=dh(i),s=Math.min(e*.2,n*.25),o=(e-s)/r.length,a=t*.24,l=-t*.03,c=-t*.25,u={flow:n*.98,back:n*.9,hot:n*.82,cold:n*.06},h=Math.min(n*.012,t*.065,o*.04),f=Math.min(n*.009,t*.045,o*.025),d=[{from:[-e*.49,u.flow,l],to:[e*.49,u.flow,l],medium:"primary_flow"},{from:[-e*.49,u.back,c],to:[e*.49,u.back,c],medium:"primary_return"},{from:[-e*.49,u.hot,a],to:[e*.49,u.hot,a],medium:"hot_water"},{from:[-e*.49,u.cold,a],to:[e*.49,u.cold,a],medium:"cold_water"}],p=(M,S,v)=>({x:M,y:S,z:a,front:a+Math.min(t*.22,v*.85),r:v}),x=r.map((M,S)=>{let v=-e/2+s+o*(S+.5),w=v-o*.33,P=v+o*.4,T=v+o*.23,R=o*.18,L=[],U=(H,k)=>{for(let X=1;X1e-6?i.lyingCylinder("x",(s+l)/2,a,o-n,o+n,Math.abs(l-s),n*2,r,12,Te):Math.abs(u-a)>1e-6?i.lyingCylinder("z",s,(a+u)/2,o-n,o+n,Math.abs(u-a),n*2,r,12,Te):i.cylinder(s,a,n,Math.min(o,c),Math.max(o,c),r,12,Te)}function Pl(i,e,t,n,r,s,o=mh){i.lyingCylinder("z",e,(r+s)/2,t-n,t+n,s-r,n*2,o,24,Te)}var Il={primary_flow:He(11088437,14109762),primary_return:He(2383516,5019861),hot_water:He(11957285,15639884),cold_water:He(3242318,7192440),circulation:He(7950748,11895505)},vC=He(9597515,13215082),_C=He(8293780,11582912),xh=new W(10859712);function n_(i,e){let t=ko(e);for(let n of t.headers)gh(i,n.from,n.to,t.headerR,Il[n.medium]);for(let n of t.circulationPipes)gh(i,n.from,n.to,t.pipeR,Il[n.medium]);if(t.circulationPipes.length){let n=t.circPump;Pl(i,n.x,n.y,n.r,n.z-t.pipeR,n.front,q.darkBody);let r=t.circProbe;Pl(i,r.x,r.y,r.r,r.z,r.front,mh)}t.units.forEach((n,r)=>{let s=n.pitch*.45;i.block({x:[n.x-s,n.x+s],y:[e.h*.18,e.h*.76],z:[-e.d*.46,-e.d*.34]},q.darkBody,Te);for(let d of n.pipes)gh(i,d.from,d.to,t.pipeR,Il[d.medium]);i.block({x:[n.plate.x0,n.plate.x1],y:[n.plate.y0,n.plate.y1],z:[n.plate.back,n.plate.front]},_C,Te);for(let d=1;d<7;d++){let p=n.plate.x0+(n.plate.x1-n.plate.x0)*d/7;i.seg(p,n.plate.y0+e.h*.015,n.plate.front+.001,p+n.pitch*.045,n.plate.y1-e.h*.015,n.plate.front+.001,Te)}for(let[d,p]of[[n.plate.x0,Il.primary_flow],[n.plate.x1,Il.hot_water]])i.block({x:[d-n.pitch*.016,d+n.pitch*.016],y:[n.plate.y0,n.plate.y1],z:[n.plate.front,n.plate.front+e.d*.015]},p);for(let d of[n.pump,...n.valve?[n.valve]:[]])Pl(i,d.x,d.y,d.r,d.z-t.pipeR,d.front,d===n.valve?vC:q.darkBody);for(let d of n.probes)Pl(i,d.x,d.y,d.r,d.z,d.front,mh);let o=Math.min(n.pitch*.055,e.h*.022),a=n.x-s+o*.6,l=e.h*.72,c=e.d*.31;i.seg(a,l-o,c,a,l+o,c,xh),i.seg(a,l,c,a+o,l+o,c,xh),i.seg(a,l,c,a+o,l-o,c,xh);let u=String(r+1),h=["abcdef","bc","abdeg","abcdg","bcfg","acdfg","acdefg","abc","abcdefg","abcdfg"],f={a:[0,1,1,1],b:[1,1,1,0],c:[1,0,1,-1],d:[0,-1,1,-1],e:[0,0,0,-1],f:[0,1,0,0],g:[0,0,1,0]};for(let d=0;d.5?bh:qp,12,Te)}for(let a of s.sensors??[]){let l=r*(.1+.8*a.level);i.lyingCylinder("z",0,o,l-.018,l+.018,.035,.036,vh,10,Te),i.ring(0,l,.025,o+.022,12,Te)}for(let a of[-1,1])for(let l of[-1,1])i.cylinder(a*o*.52,l*o*.52,.025,0,r*.05,q.metal);return}if(i.block({x:[-t*.49,t*.49],y:[r*.02,r*.98],z:[-n*.48,-n*.35]},q.darkBody,ue),e.type==="heating_manifold"){let o=s.circuits??[],a=Math.min(r*.025,n*.12);for(let[u,h,f]of[[r*.15,-n*.14,bh],[r*.07,n*.16,qp]])i.lyingCylinder("x",0,h,u-a,u+a,t*.94,a*2,f,16,Te);let l=(u,h,f,d=bh)=>{let[p,x,m]=u,[g,y,_]=h;Math.abs(g-p)>1e-6?i.lyingCylinder("x",(p+g)/2,m,x-f,x+f,Math.abs(g-p),f*2,d,12,Te):Math.abs(_-m)>1e-6?i.lyingCylinder("z",p,(m+_)/2,x-f,x+f,Math.abs(_-m),f*2,d,12,Te):i.cylinder(p,m,f,Math.min(x,y),Math.max(x,y),d,12,Te)},c=(u,h,f,d,p,x=$p)=>i.lyingCylinder("z",u,(d+p)/2,h-f,h+f,p-d,f*2,x,24,Te);o.forEach((u,h)=>{let f=ph(e,u,h,o.length);for(let d of f.pipes)l(d.from,d.to,f.pipeR,d.kind==="flow"?bh:qp);if(u.kind!=="pump"){c(f.x,f.loadY,f.loadR,f.frontZ,f.loadFront,MC),i.ring(f.x,f.loadY,f.loadR*.55,f.loadFront+.001,24,Te);let d=f.loadR*.45;for(let p=0;p<4;p++)i.seg(f.x-d+p*d/2,f.loadY-d*.3,f.loadFront+.002,f.x-d+(p+.5)*d/2,f.loadY+d*.3,f.loadFront+.002,ue)}if(Cl(u)){c(f.flowX,f.pumpY,f.pumpR,f.frontZ-f.pipeR,f.pumpFront,q.darkBody);for(let d of[-1,1])i.cylinder(f.flowX,f.frontZ,f.pipeR*1.65,f.pumpY+d*f.pumpR-f.pipeR*.5,f.pumpY+d*f.pumpR+f.pipeR*.5,$p,12,Te)}if(Ls(u)){c(f.flowX,f.valveY,f.valveR,f.frontZ-f.pipeR,f.valveFront,vh);for(let d of[-1,1])i.cylinder(f.flowX,f.frontZ,f.pipeR*1.5,f.valveY+d*f.valveR-f.pipeR*.4,f.valveY+d*f.valveR+f.pipeR*.4,vh,12,Te);f.mixing&&l([f.flowX+f.valveR*.6,f.valveY,f.frontZ],[f.flowX+f.valveR*1.3,f.valveY,f.frontZ],f.pipeR*1.5,vh),i.block({x:[f.flowX-f.valveR*.65,f.flowX+f.valveR*.65],y:[f.valveY-f.valveR*.65,f.valveY+f.valveR*.65],z:[f.frontZ,f.frontZ+(f.valveFront-f.frontZ)*.9]},q.darkBody,Te)}for(let[d,p]of[[f.flowX,f.flowGaugeX],[f.returnX,f.returnGaugeX]])l([d,f.temperatureY,f.frontZ],[p,f.temperatureY,f.frontZ],f.pipeR*.5,$p),c(p,f.temperatureY,f.gaugeR,f.frontZ,f.gaugeFront,SC),i.ring(p,f.temperatureY,f.gaugeR*.8,f.gaugeFront+.001,16,Te)})}}function wC(i,e,t,n,r,s){switch(e.type){case"heating_manifold":case"buffer_tank":case"freshwater_station":return i_(i,e,t,n,r),"yes";case"sofa":return e.variant==="l"||e.variant==="u"?fv(i,t,n,r,e.variant):Bp(i,t,n,r,Math.max(1,Math.round((t-.4)/.62))),"yes";case"armchair":return Bp(i,t,n,r,1),"yes";case"bed":return dv(i,t,n,r),"yes";case"chair":return pv(i,t,n,r),"yes";case"table":return Nv(i,t,n,r),"yes";case"desk":return kv(i,t,n,r),"yes";case"nightstand":return Uv(i,t,n,r),"yes";case"wardrobe":return di(i,t,n,r,Math.max(2,Math.round(t/.5)),r*.5),"yes";case"tall_cabinet":return di(i,t,n,r,1,r*.5),"yes";case"shelf":return Bv(i,t,n,r),"yes";case"kitchen":return bv(i,t,n,r),"yes";case"fridge":return _v(i,t,n,r),"yes";case"fridge_smart":return Mv(i,t,n,r),"yes";case"stove":return Sv(i,t,n,r),"yes";case"sink":return wv(i,t,n,r),"yes";case"bathtub":return Cv(i,t,n,r),"yes";case"shower":return Pv(i,t,n,r),"yes";case"wc":return Iv(i,t,n,r),"yes";case"washbasin":return Lv(i,t,n,r),"yes";case"tv_board":return Yv(i,t,n,r,e.ambilight===0?ue:void 0),"yes";case"plant":return Hv(i,t,n,r),"yes";case"rug":return Wv(i,t,n),"no";case"stairs":return e.stair?(e_(i,e,t,n,r),e.stair.down?"no":"yes"):(Xv(i,t,n,r),"yes");case"stairwell":return"no";case"sideboard":return zv(i,t,n,r),"yes";case"dresser":return Vv(i,t,n,r),"yes";case"coat_rack":return Gv(i,t,n,r),"yes";case"bench":return zp(i,t,n,r,!1),"yes";case"corner_bench":return zp(i,t,n,r,!0),"yes";case"bar_stool":return mv(i,t,n,r),"yes";case"office_chair":return gv(i,t,n,r),"yes";case"stool":return xv(i,t,n,r),"yes";case"kitchen_wall":return Tv(i,t,n,r),"no";case"kitchen_tall":return Av(i,t,n,r),"yes";case"island":return Ev(i,t,n,r),"yes";case"worktop":return vv(i,t,n,r),"no";case"dishwasher":return Rv(i,t,n,r),"yes";case"washer":return Xp(i,t,n,r,!1),"yes";case"dryer":return Xp(i,t,n,r,!0),"yes";case"bunk_bed":return yv(i,t,n,r),"yes";case"table_round":return Ov(i,t,n,r),"yes";case"coffee_table":return Dv(i,t,n,r),"yes";case"tv_wall":return qv(i,t,n,r,e.ambilight===0?ue:void 0),"no";case"parking":{let a=[[-t/2,-n/2],[t/2,-n/2],[t/2,n/2],[-t/2,n/2]];return a.forEach(([l,c],u)=>i.seg(l,.012,c,a[(u+1)%4][0],.012,a[(u+1)%4][1],Te)),i.seg(-t*.15,.012,n/2-.45,0,.012,n/2-.2,ue),i.seg(0,.012,n/2-.2,t*.15,.012,n/2-.45,ue),"no"}case"robot_vacuum":return i.block({x:[-t*.45,t*.45],y:[0,r],z:[-n/2,-n/2+n*.3]},q.white,ue),i.block({x:[-t*.2,t*.2],y:[r*.5,r*.62],z:[-n/2+n*.3,-n/2+n*.31]},q.accent),"no";case"radiator":return Fv(i,t,n,r),"no";case"inverter":return $v(i,t,n,r,e.variant??null),"no";case"grid_point":return Kv(i,t,n,r),"yes";case"wallbox":return Zv(i,t,n,r),"no";case"meter":return Jv(i,t,n,r),"no";case"home_battery":return jv(i,t,n,r,e.variant??null),e.variant==="wall"?"no":"yes";default:{let o=_t(e.type);return o?o.pet?"no":(ws(i,o,t,n,r,s,null,null,e.variant??null),s>.05?"no":"yes"):(i.block({x:[-t/2,t/2],y:[0,r],z:[-n/2,n/2]},q.body,ue),"yes")}}}function r_(i,e,t,n,r){let s=Ts(n),o=new Ni(i,e,s),[a,l,c]=[Math.max(.05,n.w),Math.max(.05,n.d),Math.max(.005,n.h)];wC(o,n,a,l,c,r)==="yes"&&zy(t,s,a,l,n.type==="plant"?.35:.5)}function s_(i,e,t){let[n,r]=[Math.cos(t),Math.sin(t)],s=e[0]*i[0]+e[1]*i[1]+e[2]*i[2],o=[e[1]*i[2]-e[2]*i[1],e[2]*i[0]-e[0]*i[2],e[0]*i[1]-e[1]*i[0]];return[i[0]*n+o[0]*r+e[0]*s*(1-n),i[1]*n+o[1]*r+e[1]*s*(1-n),i[2]*n+o[2]*r+e[2]*s*(1-n)]}function TC(i,e,t,n,r){let[s,o]=[n.tilt_x??0,n.tilt_z??0];if(!s&&!o)return;let a=n.rotation*Math.PI/180,l=[Math.cos(a),0,Math.sin(a)],c=[-Math.sin(a),0,Math.cos(a)],u=(h,f)=>{for(let d=f;d+2c.screen);if(o){let c=e?Gt(e,i):0,[u,h]=[(o.x-o.w/2)*t,(o.x+o.w/2)*t],f=Math.min(.02,(h-u)*.05);return{x0:u+f,x1:h-f,y0:c+o.y*r+f,y1:c+(o.y+o.h)*r-f,z:(o.z+o.d/2)*n}}let a=e&&i.type!=="fridge_smart"?Gt(e,i)-jr(i):0,l=EC(i,t,n,r,e);return l&&{...l,y0:l.y0+a,y1:l.y1+a}}function _h(i,e){let t=RC(i,e);return t&&i.mirror?{...t,x0:-t.x1,x1:-t.x0}:t}function Kp(i,e){let[t,n,r]=[Math.max(.05,i.w),Math.max(.05,i.d),Math.max(.005,i.h)],s=_t(i.type),o=s&&na(s,t,n,r).find(h=>h.picture);if(!o)return null;let a=e?Gt(e,i):0,[l,c]=[(o.x-o.w/2)*t,(o.x+o.w/2)*t],u={x0:l,x1:c,y0:a+o.y*r,y1:a+(o.y+o.h)*r,z:(o.z+o.d/2)*n};return i.mirror?{...u,x0:-u.x1,x1:-u.x0}:u}function Zp(i,e){if(i.type!=="home_battery")return null;let[t,n,r]=[Math.max(.05,i.w),Math.max(.05,i.d),Math.max(.05,i.h)],s=e?Gt(e,i)-jr(i):0,o=n/2+.005;return i.variant==="wall"?{rect:{x0:-t*.3,x1:t*.3,y0:s+.5+r*.84,y1:s+.5+r*.9,z:o},vertical:!1}:i.variant==="cube"?{rect:{x0:-t*.35,x1:t*.35,y0:s+r*.8,y1:s+r*.86,z:o},vertical:!1}:{rect:{x0:-t*.05,x1:t*.05,y0:s+.06+r*.16,y1:s+r-.12,z:o},vertical:!0}}var Qn=Math.PI/180,gr=(i,e)=>[i[0]-e[0],i[1]-e[1],i[2]-e[2]];var Uo=i=>Math.hypot(i[0],i[1],i[2]),Fs=i=>{let e=Uo(i)||1;return[i[0]/e,i[1]/e,i[2]/e]},o_=(i,e)=>[i[1]*e[2]-i[2]*e[1],i[2]*e[0]-i[0]*e[2],i[0]*e[1]-i[1]*e[0]];var l_=.25;function c_(i,e,t,n,r,s,o){let a=r-t>=s-n,l=a?r-t:s-n;return{key:`${i}:top`,section:e,side:"top",flat:!0,o:[t,o,n],eu:a?[1,0,0]:[0,0,1],es:a?[0,0,1]:[1,0,0],n:[0,1,0],lu:l,ls:a?s-n:r-t,pitch:0,span:()=>[0,l],facing:a?[0,1]:[1,0]}}function u_(i,e){let t=Fs(o_(i,e));return t[1]<0?[-t[0],-t[1],-t[2]]:t}var h_=i=>{let e=Fs([-i[0],0,-i[2]]);return[e[0],e[2]]};function xr(i,e,t,n,r,s,o,a){let l=Fs(gr(r,n)),c=Fs(gr(s,n));return{key:i,section:e,side:t,flat:!1,o:n,eu:l,es:c,n:u_(l,c),lu:Uo(gr(r,n)),ls:Uo(gr(s,n)),pitch:o,span:a,facing:h_(c)}}function a_(i,e,t,n,r,s){let o=Uo(gr(r,n));if(o<.3)return null;let a=Fs(gr(r,n)),l=gr(s,n),c=l[0]*a[0]+l[1]*a[1]+l[2]*a[2],u=[l[0]-a[0]*c,l[1]-a[1]*c,l[2]-a[2]*c],h=Uo(u);if(h<.3)return null;let f=Fs(u),d=p=>{let x=Math.min(1,Math.max(0,p/h));return[c*x,o-(o-c)*x]};return{key:i,section:e,side:t,flat:!1,o:n,eu:a,es:f,n:u_(a,f),lu:o,ls:h,pitch:Math.atan2(f[1],Math.hypot(f[0],f[2]))/Qn,span:d,facing:h_(f)}}function CC(i,e){let t=kn(i),n=Rn(i),r=(y,_,b)=>{let[M,S]=t.at(y,_);return[M,b,S]},[s,o]=[Math.max(0,e.a),Math.max(0,e.b)],a=t.u0-Math.max(0,e.u0),l=t.u1+Math.max(0,e.u1),c=l-a,u=n.y(-s),h=n.y(t.w+o);if(i.shape==="flat"||i.shape==="parapet"){let[y,_]=[t.at(a,-s),t.at(l,t.w+o)];return[c_(i.id,i.id,Math.min(y[0],_[0]),Math.min(y[1],_[1]),Math.max(y[0],_[0]),Math.max(y[1],_[1]),i.eave_a+l_)]}if(i.shape==="pent")return[xr(`${i.id}:a`,i.id,"a",r(a,-s,u),r(l,-s,u),r(a,t.w+o,h),i.pitch_a,()=>[0,c])];if(i.shape==="mansard")return PC(i,t,a,l,s,o);let f=i.shape==="hip"||i.shape==="pyramid",d=(t.u1-t.u0)/2,p=i.shape==="pyramid"?d:f?Math.min(d,Math.min(n.vr,t.w-n.vr)||t.w/2):0,x=f?t.u0+p-a:0,m=f?l-(t.u1-p):0,g=[];if(n.vr>.3){let y=Math.hypot(n.vr+s,n.rh-u);g.push(xr(`${i.id}:a`,i.id,"a",r(a,-s,u),r(l,-s,u),r(a,n.vr,n.rh),i.pitch_a,_=>[x*(_/y),c-m*(_/y)]))}if(t.w-n.vr>.3){let y=Math.hypot(t.w+o-n.vr,n.rh-h);g.push(xr(`${i.id}:b`,i.id,"b",r(l,t.w+o,h),r(a,t.w+o,h),r(l,n.vr,n.rh),i.pitch_b,_=>[m*(_/y),c-x*(_/y)]))}if(f){let y=a_(`${i.id}:c`,i.id,"c",r(a,t.w+o,h),r(a,-s,u),r(t.u0+p,n.vr,n.rh)),_=a_(`${i.id}:d`,i.id,"d",r(l,-s,u),r(l,t.w+o,h),r(t.u1-p,n.vr,n.rh));g.push(...[y,_].filter(b=>b!==null))}return g}function PC(i,e,t,n,r,s){let o=fl(e.w,i.eave_a,i.eave_b,dr(i.pitch_a),dr(i.pitch_b)),a=(p,x)=>{let[m,g]=e.at(p,x);return[m,o.y(x),g]},l=n-t,c=()=>[0,l],u=(p,x)=>Math.atan2(p,x)/Qn,h=[],[f,d]=[e.w+s,e.w-o.vlb];return o.vla+r>.3&&h.push(xr(`${i.id}:a`,i.id,"a",a(t,-r),a(n,-r),a(t,o.vla),i.pitch_a,c)),o.vr-o.vla>.3&&h.push(xr(`${i.id}:au`,i.id,"a",a(t,o.vla),a(n,o.vla),a(t,o.vr),u(o.rh-o.yla,o.vr-o.vla),c)),o.vlb+s>.3&&h.push(xr(`${i.id}:b`,i.id,"b",a(n,f),a(t,f),a(n,d),i.pitch_b,c)),d-o.vr>.3&&h.push(xr(`${i.id}:bu`,i.id,"b",a(n,d),a(t,d),a(n,o.vr),u(o.rh-o.ylb,d-o.vr),c)),h}function f_(i){return i.floors.filter(t=>t.rooms.some(n=>n.points.length>=3)).sort((t,n)=>n.elevation-t.elevation)[0]??null}function Ns(i){let e=i.settings.roof;if(!e||e.type==="none")return[];if(e.type==="custom")return(e.sections??[]).flatMap(_=>CC(_,pl(i,_,_.overhang??e.overhang)));let t=f_(i);if(!t)return[];let n=t.rooms.flatMap(_=>_.points.map(b=>b[0])),r=t.rooms.flatMap(_=>_.points.map(b=>b[1])),s=i.settings.wall_exterior+e.overhang,[o,a]=[Math.min(...n)-s,Math.max(...n)+s],[l,c]=[Math.min(...r)-s,Math.max(...r)+s],u=t.elevation+t.height;if(e.type==="flat")return[c_("main",null,o,l,a,c,u+l_)];let h=a-o>=c-l,f=e.ridge==="short"?!h:h,d=(f?c-l:a-o)/2,p=d*Math.tan(e.pitch*Qn),x=(_,b,M)=>f?[_,u+M,(l+c)/2+b]:[(o+a)/2+b,u+M,_],[m,g]=f?[o,a]:[l,c],y=()=>[0,g-m];return[xr("main:a",null,"a",x(m,-d,0),x(g,-d,0),x(m,0,p),e.pitch,y),xr("main:b",null,"b",x(m,d,0),x(g,d,0),x(m,0,p),e.pitch,y)]}function Mh(i,e){let t=[];for(let n of i.floors.filter(r=>!e||r.id===e)){let{walls:r}=dl(n.rooms,{exterior:i.settings.wall_exterior,interior:i.settings.wall_interior},n.walls??[]);for(let s of r){if(!s.exterior&&!s.free)continue;let[o,a]=[s.b[0]-s.a[0],s.b[1]-s.a[1]],l=Math.hypot(o,a);if(l<1.2)continue;let[c,u]=[a/l,-o/l],h=Math.min(n.height,s.height??n.height,s.heightEnd??1/0),f=(d,p,x,m)=>t.push({key:d,section:null,side:"top",flat:!1,o:p,eu:x,es:[0,1,0],n:m,lu:l,ls:h,pitch:90,span:()=>[0,l],facing:[m[0],m[2]],wall:{floorId:n.id}});f(`wall:${n.id}:${s.id}`,[s.a[0]+c*s.right,n.elevation,s.a[1]+u*s.right],[o/l,0,a/l],[c,0,u]),s.free&&f(`wall:${n.id}:${s.id}:back`,[s.b[0]-c*s.left,n.elevation,s.b[1]-u*s.left],[-o/l,0,-a/l],[-c,0,-u])}}return t}var Fl="ground";function Sh(i){let e=i.floors.filter(t=>t.rooms.some(n=>n.points.length>=3)).sort((t,n)=>t.elevation-n.elevation);return e.find(t=>t.elevation>-.5)??e[0]??i.floors[0]??null}function wh(i,e){let t=(e.rotation??0)*Qn,n=[Math.cos(t),0,Math.sin(t)],r=[-Math.sin(t),0,Math.cos(t)],s=Sh(i),o=n[0]*e.u+r[0]*e.v,a=n[2]*e.u+r[2]*e.v,l=s?s.elevation+(e.base!=null?e.base:j0(s,o,a)):e.base??0;return{key:Fl,section:null,side:"top",flat:!0,o:[0,l,0],eu:n,es:r,n:[0,1,0],lu:1e4,ls:1e4,pitch:0,span:()=>[-1e4,1e4],facing:[r[0],r[2]],unbounded:!0}}var Jp=1.13,jp=1.72,Bo=.025,pi=.07;function Nl(i){let e=i.module_w||Jp,t=i.module_h||jp;return i.portrait===!1?[t,e]:[e,t]}function Qp(i){return i.layout?.length?i.layout.map(e=>Math.max(0,Math.min(60,Math.round(e)))):Array.from({length:Math.max(1,i.rows)},()=>Math.max(1,i.cols))}function em(i,e){return i.flat?Math.min(45,Math.max(0,e.tilt??15))*Qn:i.wall?Math.min(90,Math.max(0,e.tilt??0))*Qn:Math.min(45,Math.max(0,e.tilt??0))*Qn}function Ah(i,e){let[,t]=Nl(e),n=em(i,e);return i.wall?t*Math.cos(n)+Bo:!i.flat&&n<.001?t+Bo:i.flat&&e.rack==="ew"?t*Math.cos(n)+.08:t*Math.cos(n)+Math.max(.3,2*t*Math.sin(n))}function tm(i,e){let[t,n]=Nl(e),r=Qp(e),s=Math.max(1,...r);return[s*t+(s-1)*Bo,(r.length-1)*Ah(i,e)+n*Math.cos(em(i,e))]}var IC=i=>i.flat&&!i.unbounded&&!i.wall;function LC(i,e){if(!IC(i)||!e.rotation)return null;let t=e.rotation*Qn,[n,r]=tm(i,e);return{cos:Math.cos(t),sin:Math.sin(t),u:e.u+n/2,s:e.v+r/2}}function zo(i,e,t=!1){let[n,r]=Nl(e),s=em(i,e),o=r*Math.cos(s),a=Ah(i,e),l=Qp(e),c=Math.max(1,...l),u=new Set(e.skip??[]),h=LC(i,e),f=(m,g)=>h?[h.u+(m-h.u)*h.cos-(g-h.s)*h.sin,h.s+(m-h.u)*h.sin+(g-h.s)*h.cos]:[m,g],d=(m,g,y)=>{let[_,b]=f(m,g);return[0,1,2].map(M=>i.o[M]+i.eu[M]*_+i.es[M]*b+i.n[M]*y)},p=(m,g)=>{let[y,_]=f(m,g);if(i.unbounded)return!0;if(_<-1e-6||_>i.ls+1e-6)return!1;let[b,M]=i.span(_);return y>=b-1e-6&&y<=M+1e-6},x=[];return l.forEach((m,g)=>{let y=e.align==="right"?c-m:e.align==="center"?(c-m)/2:0;for(let _=0;_.001?o:r);if([[S,w],[v,w],[v,P],[S,P]].every(([T,R])=>p(T,R)))if(i.wall&&s>.001){let T=pi+r*Math.sin(s),[R,L]=e.flip?[T,pi]:[pi,T],U=[d(S,w,R),d(v,w,R),d(v,P,L),d(S,P,L)],C=e.flip?w:P;x.push({corners:U,posts:[S+.05,v-.05].map(I=>[d(I,C,0),d(I,C,T)]),cell:b,skipped:M})}else if(!i.flat&&s>.001){let T=pi+r*Math.sin(s),R=[d(S,w,pi),d(v,w,pi),d(v,P,T),d(S,P,T)];x.push({corners:R,posts:[S+.05,v-.05].map(L=>[d(L,P,0),d(L,P,T)]),cell:b,skipped:M})}else if(!i.flat)x.push({corners:[d(S,w,pi),d(v,w,pi),d(v,P,pi),d(S,P,pi)],posts:[],cell:b,skipped:M});else{let R=.15+r*Math.sin(s),L=e.rack==="ew"&&g%2===1?!e.flip:!!e.flip,[U,C]=L?[P,w]:[w,P],I=[d(S,U,.15),d(v,U,.15),d(v,C,R),d(S,C,R)],O=[S+.05,v-.05].flatMap(F=>[[d(F,U,0),d(F,U,.15)],[d(F,C,0),d(F,C,R)]]);x.push({corners:I,posts:O,cell:b,skipped:M})}}}),x}var nm=.78,im=1.18,d_=i=>({id:i.id,face:i.face,u:i.u,v:i.v,rows:1,cols:1,portrait:!0,module_w:i.w||nm,module_h:i.h||im});function Ol(i,e){let t=zo(i,d_(e))[0];if(!t)return null;let n=r=>[r[0]-i.n[0]*.05,r[1]-i.n[1]*.05,r[2]-i.n[2]*.05];return t.corners.map(n)}var Th={brick:{w:.5,d:.5,h:1},round:{w:.4,d:.4,h:1},wide:{w:1,d:.5,h:1},steel:{w:.2,d:.2,h:1.2}};function Eh(i){let e=i.shape??"brick",t=Th[e]??Th.brick;return{shape:e,w:i.w||t.w,d:i.d||t.d,h:i.h||t.h}}function rm(i,e){let{w:t,d:n}=Eh(i),r=e&&!e.flat?Math.cos(e.pitch*Qn):1;return{id:i.id,face:i.face,u:i.u,v:i.v,rows:1,cols:1,portrait:!0,module_w:t,module_h:n/Math.max(.2,r),tilt:0}}function sm(i,e){let t=rm(e,i),[n,r]=[t.module_w,t.module_h],s=(u,h)=>[i.o[0]+i.eu[0]*u+i.es[0]*h,i.o[1]+i.eu[1]*u+i.es[1]*h,i.o[2]+i.eu[2]*u+i.es[2]*h],[o,a]=[s(e.u+n/2,e.v),s(e.u+n/2,e.v+r)],l=s(e.u+n/2,e.v+r/2),c=u=>{let h=Math.hypot(u[0],u[2])||1;return[u[0]/h,u[2]/h]};return{center:[l[0],l[2]],along:c(i.eu),across:c(i.es),low:Math.min(o[1],a[1]),high:Math.max(o[1],a[1])}}var Os=1712952,Ds=2239816,Rh=1318193,yr=Be(3662079,.9),br=Be(5995775,.45),Xt=.14,p_=9427199,m_=13226982,g_=14936565,x_={black:{glass:new W(329483),edge:Be(9082544,.32),cells:Be(2766160,.22)},blue:{glass:new W(1386842),edge:Be(10467583,.55),cells:Be(4025599,.35)}},y_=Be(13226982,.5),b_=Be(13226982,.85),v_=Be(16757575,.95),om=new W(2845583),am=new W(3818072),lm=3812144,cm=4864064,Ch=2765896,Vo=329483,Ph=9148333,Ih=11845844,__=Be(5995775,.4);var Go=(i,e,t)=>[i[0]+(e[0]-i[0])*t,i[1]+(e[1]-i[1])*t,i[2]+(e[2]-i[2])*t],Lh=(i,e,t)=>[i[0]+e[0]*t,i[1]+e[1]*t,i[2]+e[2]*t],um=(i,e)=>e.section?i.find(t=>t.sections?.includes(e.section)):i[0];function M_(i,e,t){let n=i.settings.roof?.windows??[];if(n.length===0||e.length===0)return;let r=new Map(Ns(i).map(s=>[s.key,s]));for(let s of n){let o=r.get(s.face),a=o?Ol(o,s):null,l=o&&a?um(e,o):void 0;if(!o||!a||!l)continue;let c=l.floor.elevation+l.base,[u,h,f,d]=a.map(P=>[P[0],P[1]-c,P[2]]),p=t.get(s.id)??{open:0,tilt:0,cover:0},x=(P,T)=>Lh(P,o.n,T),m=p.open>.02||p.tilt>.02?v_:b_,g=[u,h,f,d].map(P=>x(P,.06));g.forEach((P,T)=>l.lines.seg(P,g[(T+1)%4],m));let y=(p.open>.02?30*Math.min(1,p.open):p.tilt>.5?12:0)*mt,_=Math.hypot(f[0]-h[0],f[1]-h[1],f[2]-h[2]),b=P=>Lh(Lh(P,o.es,-_*Math.cos(y)),o.n,_*Math.sin(y)),[M,S]=[x(d,.065),x(f,.065)],[v,w]=[b(M),b(S)];l.solid.tri(v,w,S,om),l.solid.tri(v,S,M,om);for(let[P,T]of[[v,w],[w,S],[S,M],[M,v]])l.lines.seg(P,T,m);if(p.cover>.02){let P=Math.min(1,p.cover),[T,R]=[x(Go(M,v,P),.01),x(Go(S,w,P),.01)],[L,U]=[x(M,.01),x(S,.01)];l.solid.tri(T,R,U,am),l.solid.tri(T,U,L,am)}}}function Fh(i,e,t,n,r){let s=c=>[c[0],c[1]-r,c[2]],o=x_[n.look==="blue"?"blue":"black"],[a,l]=n.portrait===!1?[10,6]:[6,10];for(let c of zo(t,n)){let[u,h,f,d]=c.corners.map(s);for(let[m,g,y]of[[u,h,f],[u,f,d],[u,f,h],[u,d,f]])i.tri(m,g,y,o.glass);let p=m=>Lh(m,t.n,.004),x=[u,h,f,d].map(p);x.forEach((m,g)=>e.seg(m,x[(g+1)%4],o.edge));for(let m=1;m[r.key,r]));for(let r of t){let s=n.get(r.face),o=s?um(e,s):void 0;s&&o&&Fh(o.solid,o.lines,s,r,o.floor.elevation+o.base)}}function w_(i,e){let t=i.settings.roof?.chimneys??[];if(t.length===0||e.length===0)return;let n=new Map(Ns(i).map(r=>[r.key,r]));for(let r of t){let s=n.get(r.face),o=s?um(e,s):void 0;if(!s||!o)continue;let a=o.floor.elevation+o.base,{shape:l,w:c,d:u,h}=Eh(r),f=sm(s,r),[d,p]=[f.low-a-.1,f.high-a+h],x=(v,w)=>{let{center:P,along:T,across:R}=f,L=(U,C)=>[P[0]+T[0]*v*U+R[0]*w*C,P[1]+T[1]*v*U+R[1]*w*C];return[L(-1,-1),L(1,-1),L(1,1),L(-1,1)]},m=(v,w=16)=>Array.from({length:w},(P,T)=>[f.center[0]+Math.cos(T/w*2*Math.PI)*v,f.center[1]+Math.sin(T/w*2*Math.PI)*v]),g=(v,w)=>v.forEach((P,T)=>o.lines.seg([P[0],w,P[1]],[v[(T+1)%v.length][0],w,v[(T+1)%v.length][1]],__)),y=(v,w,P,T,R)=>Tt(o.solid,OC(v),w,P,T,R);if(l==="steel"){let v=Math.min(c,u)/2;y(m(v,12),d,p,Ph,Ih),y(m(v*.75,12),p,p+.001,Vo,Vo),y(m(v*.25,6),p,p+.1,Ph,Ih);let w=m(v*1.9,12);y(w,p+.1,p+.13,Ph,Ih),g(w,p+.13);continue}if(l==="round"){let v=Math.min(c,u)/2,w=m(v);y(w,d,p,lm,cm),y(m(v*.55),p,p+.002,Vo,Vo),g(w,p);continue}let _=x(c/2,u/2);y(_,d,p,lm,cm);let b=x(c/2+.04,u/2+.04);y(b,p,p+.06,Ch,Ch),g(b,p+.06),g(_,p-.25);let M=Math.min(c,u)*.25,S=l==="wide"?[-c/4,c/4]:[0];for(let v of S){let w=[f.center[0]+f.along[0]*v,f.center[1]+f.along[1]*v],P=[[-1,-1],[1,-1],[1,1],[-1,1]].map(([T,R])=>[w[0]+f.along[0]*M*T+f.across[0]*M*R,w[1]+f.along[1]*M*T+f.across[1]*M*R]);y(P,p+.06,p+.16,Ch,Vo)}}}function OC(i){let e=0;for(let t=0;t0,r.b>0,r.u0>0,r.u1>0],f=(p,x,m,g,y,_)=>{let b=[t.at(p,m),t.at(x,m),t.at(x,g),t.at(p,g)],M=(b[1][0]-b[0][0])*(b[2][1]-b[0][1])-(b[2][0]-b[0][0])*(b[1][1]-b[0][1]);Tt(i,M<0?[...b].reverse():b,y-o,_-o,m_,g_,{bottom:!0})};for(let[p,x]of[[0,l],[a,c]]){if(!x)continue;let m=n.y(p)-.03,g=p===0?0:a-ei;f(t.u0,t.u1,g,g+ei,m-Dl,m),e.seg(s(t.u0,p,m-Dl),s(t.u1,p,m-Dl),br)}for(let[p,x]of[[t.u0,u],[t.u1-ei,h]])if(x)for(let m=0;m<6;m++){let[g,y]=[a*m/6,a*(m+1)/6],_=Math.min(n.y(g),n.y(y))-.03;f(p,p+ei,g,y,_-Dl,_)}let d=[];for(let[p,x]of[[0,l],[a-ei,c]]){if(!x)continue;let m=t.u1-t.u0-ei,g=Math.max(1,Math.ceil(m/3.5));for(let y=0;y<=g;y++)y===0&&!u||y===g&&!h||d.push([t.u0+m*y/g,p])}!l&&!c&&(u&&d.push([t.u0,a/2-ei/2]),h&&d.push([t.u1-ei,a/2-ei/2]));for(let[p,x]of d)f(p,p+ei,x,x+ei,o,n.y(x+ei/2)-.03-Dl)}function DC(i,e){let t=[];if(i.forEach(([s,o],a)=>{o>=e&&t.push([s,o]);let l=i[a+1];if(l&&(o-e)*(l[1]-e)<0){let c=(e-o)/(l[1]-o);t.push([s+(l[0]-s)*c,e])}}),t.length<2)return[];let[n,r]=[t[0],t[t.length-1]];return r[1]>e&&t.push([r[0],e]),n[1]>e&&t.unshift([n[0],e]),t}var A_=i=>wr(i)>=0?i:[...i].reverse();function E_(i,e,t,n,r,s=i,o=!1,a=[],l=null){let c=kn(t),u=Rn(t),h=typeof n=="number"?{u0:n,u1:n,a:n,b:n}:n,[f,d]=[Math.max(0,h.a),Math.max(0,h.b)],p=c.w,x=c.u0-Math.max(0,h.u0),m=c.u1+Math.max(0,h.u1),g=(I,O,F)=>{let[H,k]=c.at(I,O);return[H,F-r,k]},y=new W(Ds),_=new W(Os),b=new W(Rh),M=(I,O)=>{for(let F=1;F+1g(I,O,F-H),v=[],w=[],P=[],T=null,R=null;if(t.shape==="flat"||t.shape==="parapet"){let I=t.eave_a-r,O=t.shape==="parapet",F=t.points&&t.points.length>=3?gp(t,O?0:Math.max(0,Math.min(h.a,h.b,h.u0,h.u1))):O?[c.at(c.u0,0),c.at(c.u1,0),c.at(c.u1,p),c.at(c.u0,p)]:[c.at(x,-f),c.at(m,-f),c.at(m,p+d),c.at(x,p+d)];if(Tt(i,F,I,I+.25,Os,Ds,{bottom:!0}),F.forEach((H,k)=>{let X=F[(k+1)%F.length];e.seg([H[0],I+.252,H[1]],[X[0],I+.252,X[1]],yr),e.seg([H[0],I,H[1]],[X[0],I,X[1]],br)}),O){let H=A_(F),k=Wu(H,-.2);H.forEach((X,V)=>{let re=(V+1)%H.length;Tt(i,A_([X,H[re],k[re],k[V]]),I+.25,I+.65,Os,Ds),e.seg([X[0],I+.652,X[1]],[H[re][0],I+.652,H[re][1]],yr),e.seg([k[V][0],I+.652,k[V][1]],[k[re][0],I+.652,k[re][1]],yr)})}}else{let I=Wr(t,h);v=a.reduce((O,F)=>O.flatMap(H=>Xu(H,F)),I.faces),w=I.rim,P=I.ridges,T=I.gable,R=I.endProfiles??null}let L=!!t.open,U=new W(p_);for(let I of v)if(L)for(let O=1;O+1S(O)),y),M(I.map(O=>S(O,Xt)),_);if(w.forEach((I,O)=>{let F=w[(O+1)%w.length];L||M([S(I),S(F),S(F,Xt),S(I,Xt)],_),e.seg(S(I),S(F),L?yr:br)}),L){T_(i,e,c,u,h,(I,O,F)=>g(I,O,F),r);return}for(let[I,O]of P)e.seg(S([I[0],I[1],I[2]+.004]),S([O[0],O[1],O[2]+.004]),yr);let C=t.base;if(!o){if(T){let I=l===null?[c.u0,c.u1]:[l===0?c.u0:c.u1];for(let O of I){let F=R?R[O===c.u0?0:1]:T,H=F?DC(F,C-Xt):[];H.length>=3&&M(H.map(([k,X])=>g(O,k,X)),b)}}if(t.shape!=="flat"&&t.shape!=="parapet")for(let I of[0,p]){let O=u.y(I)-Xt;O>C+.02&&M([g(c.u0,I,C),g(c.u1,I,C),g(c.u1,I,O),g(c.u0,I,O)],b)}else if(t.eave_a>C+.02){let I=[[c.u0,0],[c.u1,0],[c.u1,p],[c.u0,p]];I.forEach(([O,F],H)=>{let[k,X]=I[(H+1)%4];M([g(O,F,C),g(k,X,C),g(k,X,t.eave_a),g(O,F,t.eave_a)],b)})}}}function R_(i,e,t){let n=i.floors.filter(o=>o.rooms.length>0).sort((o,a)=>o.elevation-a.elevation);if(n.length===0)return[];let r=new Map,s=new Map(Ns(i).map(o=>[o.key,o]));for(let o of e){if(Math.abs(o.x1-o.x0)<.1||Math.abs(o.z1-o.z0)<.1)continue;let a=bp(i,o)??n[0],l=o.open?`${a.id}:open`:a.id,c=r.get(l);c||r.set(l,c={floor:a,base:0,solid:new ut,lines:new Wt,glass:new ut,sections:[],lift:!o.open}),c.sections.push(o.id);let u=gl(e,o),h=Rs(e,o)??u?.parent??null,f=a.elevation+a.height>o.base+.05&&!o.dormer&&!h,d=e.filter(m=>m!==o).flatMap(m=>Rs(e,m)===o?qu(o,m):gl(e,m)?.parent===o?qu(o,gl(e,m).extended):[]);for(let m of i.settings.roof.windows??[]){let g=s.get(m.face),y=g&&g.section===o.id?Ol(g,m):null;if(!y)continue;let _=y.map(b=>Oi(o,b[0],b[2]));d.push({u0:Math.min(..._.map(b=>b[0])),u1:Math.max(..._.map(b=>b[0])),v0:Math.min(..._.map(b=>b[1])),v1:Math.max(..._.map(b=>b[1]))})}let p=u?u.extended:h?ml(h,o):o,x=null;if(h){let m=kn(p),g=Wr(h,{u0:0,u1:0,a:0,b:0}),y=_=>{let[b,M]=m.at(_,m.w/2),[S,v]=Oi(h,b,M);return Es(g,S,v)??Rn(h).y(v)};x=y(m.u0)<=y(m.u1)?0:1}E_(c.solid,c.lines,p,pl(i,p,p.overhang??t),a.elevation,c.glass,f,d,x)}return[...r.values()].sort((o,a)=>+(o.lift===!1)-+(a.lift===!1))}function C_(i){return i.floors.filter(e=>e.rooms.some(t=>t.points.length>=3)).sort((e,t)=>t.elevation-e.elevation)[0]??null}function P_(i){let e=i.settings.roof,t=C_(i);if(!t||!e||e.type==="none"||e.type==="custom")return null;let n=t.rooms.flatMap(L=>L.points.map(U=>U[0])),r=t.rooms.flatMap(L=>L.points.map(U=>U[1])),s=i.settings.wall_exterior+e.overhang,[o,a]=[Math.min(...n)-s,Math.max(...n)+s],[l,c]=[Math.min(...r)-s,Math.max(...r)+s],u=new ut,h=new Wt,f={floor:t,base:t.height,solid:u,lines:h,glass:new ut};if(e.type==="flat"){let L=[[o,l],[a,l],[a,c],[o,c]];return Tt(u,L,0,.25,Os,Ds,{bottom:!0}),L.forEach(([U,C],I)=>{let[O,F]=L[(I+1)%4];h.seg([U,.252,C],[O,.252,F],yr),h.seg([U,0,C],[O,0,F],br)}),f}let d=a-o>=c-l,p=e.ridge==="short"?!d:d,x=(p?c-l:a-o)/2,m=Math.tan(e.pitch*mt),g=x*m,y=(L,U,C)=>p?[L,C,(l+c)/2+U]:[(o+a)/2+U,C,L],[_,b]=p?[o,a]:[l,c],M=new W(Ds),S=new W(Os),v=(L,U,C,I,O)=>{u.tri(L,U,C,O),u.tri(L,C,I,O)};for(let L of[-1,1]){v(y(_,L*x,0),y(b,L*x,0),y(b,0,g),y(_,0,g),M),v(y(_,L*x,-Xt),y(_,0,g-Xt),y(b,0,g-Xt),y(b,L*x,-Xt),S),v(y(_,L*x,-Xt),y(b,L*x,-Xt),y(b,L*x,0),y(_,L*x,0),S);for(let U of[_,b])v(y(U,L*x,-Xt),y(U,L*x,0),y(U,0,g),y(U,0,g-Xt),S);h.seg(y(_,L*x,0),y(b,L*x,0),br);for(let U of[_,b])h.seg(y(U,L*x,0),y(U,0,g),br)}let w=e.overhang,P=new W(Rh),T=x-w,R=T*m;for(let L of[_+w,b-w])u.tri(y(L,-T,-Xt),y(L,T,-Xt),y(L,0,R-Xt),P),u.tri(y(L,T,-Xt),y(L,-T,-Xt),y(L,0,R-Xt),P);return h.seg(y(_,0,g+.004),y(b,0,g+.004),yr),f}function Nh(i,e=new Map){let t=i.settings.roof;if(i.topology&&t?.type!=="custom"){let s=new Map;for(let o of i.floors)if(!ra(o)){let a=o.building_id??"legacy";s.set(a,[...s.get(a)??[],o])}return[...s.values()].flatMap(o=>Nh({...i,topology:void 0,floors:o},e))}let n=t?.type==="custom"?null:P_(i),r=t?.type==="custom"?R_(i,t.sections??[],t.overhang):n?[n]:[];return S_(i,r),M_(i,r,e),w_(i,r),r}function Oh(i){let{start:e,axis:t,width:n}=i.info;return[[e[0],e[1]],[e[0]+t[0]*n,e[1]+t[1]*n]]}var I_=(i,e)=>`${i}|${Math.round(e[0]*50)},${Math.round(e[1]*50)}`;function L_(i,e){let t=[];for(let n of i){let r=n.info.opening.front;if(!r)continue;let[s,o]=Oh(n);e.at(r,s)&&t.push(n.s0),e.at(r,o)&&t.push(n.s1)}return t}function F_(i,e){let t=Math.hypot(i.b[0]-i.a[0],i.b[1]-i.a[1])||1;return((e[0]-i.a[0])*(i.b[0]-i.a[0])+(e[1]-i.a[1])*(i.b[1]-i.a[1]))/t}function Dh(i){let e=new Map,t=new Map;for(let r of i)for(let s of r){let o=s.info.opening.front;if(o)for(let a of Oh(s)){let l=I_(o,a);e.set(l,(e.get(l)??0)+1),t.has(l)||t.set(l,[a[0],a[1]])}}return{points:[...e].filter(([,r])=>r>1).map(([r])=>t.get(r)).filter(r=>!!r),at:(r,s)=>(e.get(I_(r,s))??0)>1}}var ks={floor:923177,slab:659744,wall:1252657,wallTop:1323071,edge:3662079,edgeSoft:5995775},kh={wood:{color:1120814,tile:[0,0]},oak:{color:1252141,tile:[1,0]},tiles:{color:923695,tile:[2,0]},carpet:{color:1053995,tile:[0,1]},stone:{color:988971,tile:[1,1]},concrete:{color:1120295,tile:[2,1]}},mi=.2,Ho=8;var N_=(i,e)=>i.heightEnd===void 0?i.height??e:Math.max(i.height??e,i.heightEnd);function O_(i){let e=new Map,t=[],n=new Map;for(let r of i){let s="interior",o=null;if(r.exterior){let[a,l]=[r.b[0]-r.a[0],r.b[1]-r.a[1]],c=Math.hypot(a,l)||1,u=[l/c,-a/c],h=(Math.round(Math.atan2(u[1],u[0])/(2*Math.PI)*Ho)%Ho+Ho)%Ho;s=`s${h}`;let f=h/Ho*2*Math.PI;o=[Math.cos(f),Math.sin(f)]}e.has(s)||(e.set(s,t.length),t.push(o)),n.set(r,e.get(s))}return{buckets:t,wallBucket:n}}function D_(i){let e=(n,r,s)=>{let o=i?i(n,r):null;return o===null?s:Math.max(.05,Math.min(s,o))};return{topAt:e,lowestTop:(n,r,s,o,a)=>{if(!i)return a;let l=Math.max(2,Math.ceil((o-s)/.25)+1),c=a;for(let u=0;ut.topAt(h,f,n),lowestTop:(h,f)=>t.lowestTop(i.a,s,h,f,n)};let[o,a]=[i.height??e,i.heightEnd],l=(h,f)=>{let d=r>1e-9?((h-i.a[0])*s[0]+(f-i.a[1])*s[1])/r:0;return o+(a-o)*Math.max(0,Math.min(1,d))},c=(h,f)=>t.topAt(h,f,l(h,f));return{H:n,varies:!0,topAt:c,lowestTop:(h,f)=>{let d=Math.max(2,Math.ceil((f-h)/.25)+1),p=1/0;for(let x=0;x0:c.roomLeft===o.room_id,g=[-h[1],h[0]],y=m?g:[-g[0],-g[1]],_=es(i.rooms.find(P=>P.id===o.room_id)),b=Math.min(Wo(c,i.height,n).lowestTop(p,p+d)-.02,_+o.sill+o.height),M=Math.max(Math.min(0,_),Math.min(_+o.sill,b-.1)),S=[y[1],-y[0]],v=h[0]*S[0]+h[1]*S[1]>0,w={opening:o,bucket:t.get(c),start:[c.a[0]+h[0]*p,c.a[1]+h[1]*p],axis:h,width:d,toRoom:y,faceRoom:m?c.left:c.right,faceOut:m?c.right:c.left,sill:M,top:b,hingeAtStart:o.hinge==="left"===v,exterior:c.exterior};s.push(w),r.set(c,[...r.get(c)??[],{s0:p,s1:p+d,sill:M,top:b,info:w}])}return{openings:s,spans:r}}var U_=i=>`${Math.round(i[0]*50)},${Math.round(i[1]*50)}`;function kC(i,e,t,n=!1,r=!1){let{info:s}=e,o=s.bucket,a=(u,h,f)=>[s.start[0]+s.axis[0]*(u-e.s0)+s.toRoom[0]*h,f,s.start[1]+s.axis[1]*(u-e.s0)+s.toRoom[1]*h],l=u=>u>t+1e-6?o:$e,c=e.sill<0?e.sill+.004:Math.max(e.sill,.004);for(let u of[s.faceRoom,-s.faceOut])n||i.segSplit(a(e.s0,u,c),a(e.s0,u,e.top),ui,t,o),r||i.segSplit(a(e.s1,u,c),a(e.s1,u,e.top),ui,t,o),i.seg(a(e.s0,u,e.top),a(e.s1,u,e.top),ui,l(e.top)),e.sill>.01&&i.seg(a(e.s0,u,e.sill),a(e.s1,u,e.sill),ui,l(e.sill));for(let[u,h]of[[e.s0,n],[e.s1,r]])h||(i.seg(a(u,s.faceRoom,e.top),a(u,-s.faceOut,e.top),ui,l(e.top)),e.sill>.01&&i.seg(a(u,s.faceRoom,e.sill),a(u,-s.faceOut,e.sill),ui,l(e.sill)),e.sillt&&i.seg(a(u,s.faceRoom,t),a(u,-s.faceOut,t),zu,al+o))}function B_(i,e,t,n,r,s,o){let a=Math.min(e.cut_height,e.height),l=(f,d)=>(r.get(f)??[]).filter(d);for(let f of t.edges){let d=n.get(f.wall);for(let[g,y]of Io(f,l(f.wall,_=>_.sill<=.005)))i.seg([g[0],.004,g[1]],[y[0],.004,y[1]],Kd);for(let[g,y]of Io(f,l(f.wall,_=>_.silla)))i.seg([g[0],a,g[1]],[y[0],a,y[1]],zu,al+d);let p=Wo(f.wall,e.height,s),{H:x,topAt:m}=p;for(let[g,y]of Io(f,l(f.wall,_=>_.top>=x-.021))){if(!o&&!p.varies){i.seg([g[0],x,g[1]],[y[0],x,y[1]],Li,x<=a+1e-6?fr+d:d);continue}let _=Math.max(1,Math.ceil(Math.hypot(y[0]-g[0],y[1]-g[1])/.3)),b=M=>[g[0]+(y[0]-g[0])*M/_,g[1]+(y[1]-g[1])*M/_];for(let M=0;M<_;M++){let[S,v]=[b(M),b(M+1)],[w,P]=[m(S[0],S[1]),m(v[0],v[1])];i.seg([S[0],w,S[1]],[v[0],P,v[1]],Li,Math.max(w,P)<=a+1e-6?fr+d:d)}}}let c=Dh(r.values()),u=new Set(c.points.map(U_)),h=new Map;for(let[f,d]of r)h.set(f,L_(d,c));for(let f of t.corners){let d=F_(f.wall,f.p),x=(r.get(f.wall)??[]).some(y=>!!y.info.opening.front&&d>y.s0+.05&&dMath.abs(y-d)<.06);if(x||m||u.has(U_(f.p)))continue;let g=Wo(f.wall,e.height,s).topAt(f.p[0],f.p[1]);i.segSplit([f.p[0],.004,f.p[1]],[f.p[0],g,f.p[1]],ui,Math.min(a,g),n.get(f.wall))}for(let f of r.values())for(let d of f){let p=d.info.opening.front,[x,m]=Oh(d);kC(i,d,a,p?c.at(p,x):!1,p?c.at(p,m):!1)}}function z_(i,e){let t=new ut(!0,!0),n=[],r=new Wt,s=[],o=new W(ks.slab),a=(l,c=0,u=c-mi)=>{l.forEach((h,f)=>{let d=l[(f+1)%l.length];t.tri([h[0],u,h[1]],[h[0],c,h[1]],[d[0],c,d[1]],o),t.tri([h[0],u,h[1]],[d[0],c,d[1]],[d[0],u,d[1]],o)})};for(let l of i.rooms){if(l.points.length<3)continue;let c=Hr(l.points),u=kh[l.floor_material]??kh.wood,h=new W(u.color),f=e.filter(m=>Nb(m,c)).map(m=>Ob(m,.003));s.push(...f);let d=[...c,...f.flat()],p=t.count,x=es(l);for(let[m,g,y]of Gr(c,f)){let[_,b,M]=[d[m],d[g],d[y]];t.tri([_[0],x,_[1]],[M[0],x,M[1]],[b[0],x,b[1]],h,h,h,[_[0],_[1],M[0],M[1],b[0],b[1]],$e,u.tile)}n.push({roomId:l.id,start:p,end:t.count,color:u.color}),a(c,x),Math.abs(x)>.005&&(a(c,Math.max(0,x),Math.min(0,x)),a([...c].reverse(),Math.max(0,x),Math.min(0,x)));for(let m of f)a([...Hr(m)].reverse()),m.forEach((g,y)=>{let _=m[(y+1)%m.length];r.seg([g[0],x+.006,g[1]],[_[0],x+.006,_[1]],Li),r.seg([g[0],x-mi,g[1]],[_[0],x-mi,_[1]],ui)})}return{buffer:t,roomTris:n,holeLines:r,cutHoles:s}}var Uh=.42,hm=.42;function V_(i,e,t){let n=new ut,r=new W(hm,hm,hm),s=new W(1,1,1),o=.002;for(let a of i)for(let[l,c]of Io(a,(t.get(a.wall)??[]).filter(u=>u.sill<=.005))){let[u,h]=[c[0]-l[0],c[1]-l[1]],f=Math.hypot(u,h);if(f<.05)continue;let d=[h/f,-u/f],p=[(l[0]+c[0])/2+d[0]*.05,(l[1]+c[1])/2+d[1]*.05];if(!e.some(g=>g.points.length>=3&&Ge(p,g.points)))continue;let x=[l[0]+d[0]*Uh,l[1]+d[1]*Uh],m=[c[0]+d[0]*Uh,c[1]+d[1]*Uh];n.tri([l[0],o,l[1]],[x[0],o,x[1]],[m[0],o,m[1]],r,s,s),n.tri([l[0],o,l[1]],[m[0],o,m[1]],[c[0],o,c[1]],r,s,r)}return n}var fm=(i,e)=>Number.parseInt(/^#?([0-9a-f]{6})$/i.exec(i?.trim()??"")?.[1]??e.slice(1),16),UC=i=>/^#?[0-9a-f]{6}$/i.test(i?.trim()??"");function dm(i,e){return{outside:fm(UC(e.wall_paint_outside)?e.wall_paint_outside:i.wall_paint_outside,tg),inside:fm(i.wall_paint_inside,ff),rooms:e.rooms.filter(t=>t.wall_paint&&t.points.length>=3).map(t=>({points:t.points,color:fm(t.wall_paint,ff)}))}}var BC=14276045;function zC(i,e,t,n,r){let s=Math.hypot(t[0]-e[0],t[1]-e[1])||1,o=[(e[0]+t[0])/2,(e[1]+t[1])/2],a=[(t[1]-e[1])/s,-(t[0]-e[0])/s];Ge([o[0]+a[0]*.01,o[1]+a[1]*.01],i)&&(a=[-a[0],-a[1]]);let l=[o[0]+a[0]*.06,o[1]+a[1]*.06],c=n.rooms.find(u=>Ge(l,u.points));return c?c.color:r.some(u=>u.points.length>=3&&Ge(l,u.points))?n.inside:n.outside}function VC(i,e,t=-mi){let n=[-1/0,...new Set(i.flatMap(s=>[s.s0,s.s1])).values(),1/0].sort((s,o)=>s-o),r=[];for(let s=0;s+1f.s0l).map(f=>[f.sill,f.top]).sort((f,d)=>f[0]-d[0]),u=[],h=t;for(let[f,d]of c)f>h+1e-4&&u.push([h,f]),h=Math.max(h,d);e>h+1e-4&&u.push([h,e]),r.push({t0:o,t1:a,ranges:u})}return r}function G_(i,e,t,n,r,s,o,a){let l=Math.min(e.cut_height,e.height),c=a?jd:0,u=a?m=>(g,y)=>zC(m,g,y,a,e.rooms):null,h=a?BC:ks.wallTop,f=Dh(r.values()),d=m=>f.points.some(g=>Math.hypot(g[0]-m[0],g[1]-m[1])<.03),p=m=>m&&m.info.opening.front?[m.sill,m.top]:null,x=(m,g)=>{let y=[];for(let[_,b]of m)g[0]>_+1e-4&&y.push([_,Math.min(b,g[0])]),b>g[1]+1e-4&&y.push([Math.max(_,g[1]),b]);return y};for(let m of t){let g=n.get(m),y=Ms([m.b[0]-m.a[0],m.b[1]-m.a[1]]),_=(r.get(m)??[]).sort((I,O)=>I.s0-O.s0),b=Wo(m,e.height,s),{H:M,topAt:S}=b,v=Math.min(0,...[m.roomLeft,m.roomRight].map(I=>es(e.rooms.find(O=>O.id===I)))),w=VC(_,M,v-mi),P=Math.hypot(m.b[0]-m.a[0],m.b[1]-m.a[1]),T=(o||b.varies)&&b.lowestTop(0,P){let O=Math.max(I.t0,-.5),F=Math.min(I.t1,P+.5),H=Math.max(1,Math.ceil((F-O)/.3));return Array.from({length:H},(k,X)=>({t0:X===0?I.t0:O+(F-O)*X/H,t1:X===H-1?I.t1:O+(F-O)*(X+1)/H,ranges:I.ranges,inner0:X>0,inner1:X({...I,inner0:!1,inner1:!1})),L=I=>(I[0]-m.a[0])*y[0]+(I[1]-m.a[1])*y[1],U=d(m.a)?p(_[0]):null,C=d(m.b)?p(_[_.length-1]):null;for(let I of R){let O=op(m.footprint,m.a,y,I.t0,I.t1);if(O.length<3)continue;let F=I.t1<=1e-6&&I.t0<0?U:I.t0>=P-1e-6?C:null,H=F?x(I.ranges,F):I.ranges,k=(Y,Q)=>Math.abs(L(Y)-Q)<1e-4,X=(Y,Q)=>I.inner0&&k(Y,I.t0)&&k(Q,I.t0)||I.inner1&&k(Y,I.t1)&&k(Q,I.t1),V=(Y,Q)=>!f.points.length||Math.hypot(Y[0]-Q[0],Y[1]-Q[1])>.5?!1:f.points.some(se=>Math.min(Math.hypot(se[0]-Y[0],se[1]-Y[1]),Math.hypot(se[0]-Q[0],se[1]-Q[1]))<.05),re=(Y,Q)=>X(Y,Q)||V(Y,Q),ye=T?Math.min(...O.map(([Y,Q])=>S(Y,Q))):M;for(let[Y,Q]of H){let se=Math.min(Q,T?Math.max(...O.map(([at,Ae])=>S(at,Ae))):Q);if(se-Y<1e-4||ye-Y<.01)continue;let we=Y>.01,le=T&&Q>ye,Ne=(at,Ae)=>Math.min(Q,S(at,Ae));if(Yl+1e-6?Jd+g:fr+g,Ae=le&&yeMath.min(l,Ne(ft,yt)):Math.min(se,l);Tt(i,O,Y,Ae,ks.wall,h,{aoFrom:0,bottom:we,fold:c+fr+g,topFold:c+at,skipSide:re,sideColor:u?.(O)})}se>l+1e-6&&ye>l+1e-6&&Tt(i,O,Math.max(Y,l),le?Ne:se,ks.wall,h,{aoFrom:0,fold:c+g,bottom:we&&Y>=l,skipSide:re,sideColor:u?.(O)})}}}}function pm(i,e,t,n=[],r=[],s,o){let{walls:a,open:l}=dl(i.rooms,{exterior:e,interior:t},i.walls??[]),c=D_(s),u=!!s,h=z_(i,n),{buckets:f,wallBucket:d}=O_(a),{openings:p,spans:x}=k_(i,a,d,c),m=new ut;G_(m,i,a,d,x,c,u,o);let g=ap(a,a.flatMap(v=>v.footprint)),y=new Wt;y.p.push(...h.holeLines.p),y.c.push(...h.holeLines.c),y.f.push(...h.holeLines.f),B_(y,i,g,d,x,c,u);let _=V_(g.edges,i.rooms,x),b=new Map;Cp(m,y,i,b,()=>new ut);for(let v of r)Fh(m,y,v.face,v.field,i.elevation);let M=Math.min(i.cut_height,i.height),S=[];for(let v of i.furniture.filter(w=>!ig(w.type))){let w=m.count,P=y.p.length/6,T=Gt(i,v);Hl(v.type)||Ll(m,y,_,v,T),T+v.h>M+.05&&(ep(m,w,M,Vu),tp(y,P,M,Vu)),S.push({id:v.id,start:w,end:m.count})}return{floor:h.buffer.geometry(),roomTris:h.roomTris,holes:h.cutHoles,walls:m.geometry(),ghosts:[...b].map(([v,w])=>({opacity:v,geometry:w.geometry()})),lines:y.geometry(),shadow:_.geometry(),buckets:f,openings:p,walls2d:a,openRooms:l,wallBuckets:a.map(v=>d.get(v)),furnitureTris:S,roofUnder:s}}function mm(i,e){let t=sg(i,e),n=[...e.furniture.filter(a=>a.type==="stairwell").map(ns),...e.furniture.filter(a=>uh(a)&&a.stair?.down).flatMap(Up)].filter(a=>a.length>=3),r=i.filter(a=>a.elevationl.elevation-a.elevation)[0];if(!r)return mr([...n,...t]);let o=r.furniture.filter(a=>(a.type==="stairs"||_t(a.type)?.hole)&&!(uh(a)&&a.stair?.down)&&r.elevation+a.h>=e.elevation-.3).flatMap(a=>uh(a)?Up(a):[ns(a)]).filter(a=>a.length>=3);return mr([...n,...o,...t])}var H_=.12,W_=1.35,Ui=(i,e,t)=>Math.min(t,Math.max(e,i)),GC=i=>i<.5?4*i*i*i:1-(-2*i+2)**3/2,X_=i=>({...i,target:i.target.clone()});function Y_({target:i,radius:e,theta:t,phi:n}){return new D(i.x+e*Math.sin(n)*Math.sin(t),i.y+e*Math.cos(n),i.z+e*Math.sin(n)*Math.cos(t))}function q_(i,e,t){let n=GC(t);return{target:new D().lerpVectors(i.target,e.target,n),radius:i.radius+(e.radius-i.radius)*n,theta:i.theta+(e.theta-i.theta)*n,phi:i.phi+(e.phi-i.phi)*n}}function $_(i,e){let t=e.theta??i.theta;for(;t-i.theta>Math.PI;)t-=2*Math.PI;for(;t-i.theta<-Math.PI;)t+=2*Math.PI;return{target:(e.target??i.target).clone(),radius:e.radius??i.radius,theta:t,phi:e.phi??i.phi}}function gm(i,e,t,n,r){let s=2*i.radius*Math.tan(r*Math.PI/360)/(n||1),o=new D(Math.cos(i.theta),0,-Math.sin(i.theta)),a=new D(-Math.sin(i.theta),0,-Math.cos(i.theta));i.target.addScaledVector(o,-e*s),i.target.addScaledVector(a,t*s/Math.max(.35,Math.cos(i.phi)))}function K_(i,e,t,n){let r=n||1,s={theta:-e/r*3.2,phi:-t/r*2.4};return i.theta+=s.theta,i.phi=Ui(i.phi+s.phi,H_,W_),s}function Z_(i,e){return Math.abs(e.theta)<=1e-4&&Math.abs(e.phi)<=1e-4?!1:(i.theta+=e.theta,i.phi=Ui(i.phi+e.phi,H_,W_),e.theta*=.9,e.phi*=.9,!0)}var HC={KeyW:"w",KeyA:"a",KeyS:"s",KeyD:"d",KeyQ:"q",KeyE:"e"},WC=new Set(["w","a","s","d","q","e","arrowup","arrowdown","arrowleft","arrowright"]);function XC(i){let e=i.code?.startsWith("Key")?HC[i.code]??null:i.key.toLowerCase();return e&&WC.has(e)?e:null}var YC=500,qC=400,$C=320,KC=6,J_=1.5,ZC=1.8;function JC(i,e){let t=i.keys,n=(t.has("w")||t.has("arrowup")?1:0)-(t.has("s")||t.has("arrowdown")?1:0)-i.stick[1],r=(t.has("d")?1:0)-(t.has("a")?1:0),s=(t.has("arrowleft")||t.has("q")?1:0)-(t.has("arrowright")||t.has("e")?1:0)-i.stick[0];if(!n&&!r&&!s)return!1;let o=e/1e3;i.yaw+=s*ZC*o;let[a,l]=[-Math.sin(i.yaw),-Math.cos(i.yaw)],[c,u]=[Math.cos(i.yaw),-Math.sin(i.yaw)];return i.eye.x=Ui(i.eye.x+(a*n+c*r)*J_*o,i.bounds.x0,i.bounds.x1),i.eye.z=Ui(i.eye.z+(l*n+u*r)*J_*o,i.bounds.z0,i.bounds.z1),!0}var kl=class{view={target:new D,radius:16,theta:-.6,phi:.85};minRadius=2;maxRadius=80;locked=!1;walk=null;pointers=new Map;velocity={theta:0,phi:0};flight=null;press=null;lastTap=0;holdTimer;held=!1;grabbing=!1;swiping=null;pinch=null;listeners=[];el;camera;events;constructor(e,t,n){this.el=e,this.camera=t,this.events=n;let r=(l,c,u)=>{e.addEventListener(l,c,u),this.listeners.push([l,c])};r("pointerdown",l=>this.onDown(l)),r("pointermove",l=>this.onMove(l)),r("pointerup",l=>this.onUp(l)),r("pointercancel",l=>this.onUp(l)),r("wheel",l=>this.onWheel(l),{passive:!1}),r("contextmenu",l=>l.preventDefault());let s=l=>c=>{if(!this.walk||c.target?.closest?.("input, textarea, select"))return;let u=XC(c);u&&(c.preventDefault(),l?this.walk.keys.add(u):this.walk.keys.delete(u),this.events.change())},o=s(!0),a=s(!1);window.addEventListener("keydown",o),window.addEventListener("keyup",a),this.listeners.push(["__window_keydown",o],["__window_keyup",a])}dispose(){clearTimeout(this.holdTimer);for(let[e,t]of this.listeners)e.startsWith("__window_")?window.removeEventListener(e.slice(9),t):this.el.removeEventListener(e,t)}get active(){return this.pointers.size>0||this.flight!==null}get busy(){return this.active}update(e){if(this.walk){let n=this.walk,r=JC(n,n.last?Math.min(100,e-n.last):16);n.last=r?e:0;let s=new D(-Math.sin(n.yaw)*Math.cos(n.pitch),Math.sin(n.pitch),-Math.cos(n.yaw)*Math.cos(n.pitch));return this.view.target.copy(n.eye).add(s),this.camera.position.copy(n.eye),this.camera.lookAt(this.view.target),r}let t=!1;if(this.flight){let{from:n,to:r,start:s,duration:o}=this.flight,a=Math.min(1,(e-s)/o);this.view=q_(n,r,a),a>=1&&(this.flight=null),t=!0}else this.pointers.size===0&&(t=Z_(this.view,this.velocity));return this.camera.position.copy(Y_(this.view)),this.camera.lookAt(this.view.target),t}flyTo(e,t=700){let n=$_(this.view,e),r=X_(this.view);this.velocity={theta:0,phi:0},t<=0||matchMedia("(prefers-reduced-motion: reduce)").matches?(this.view=n,this.flight=null):this.flight={from:r,to:n,start:performance.now(),duration:t},this.events.change()}local(e){let t=this.el.getBoundingClientRect();return[e.clientX-t.left,e.clientY-t.top]}stopMotion(){this.flight=null,this.velocity={theta:0,phi:0}}onDown(e){this.el.setPointerCapture(e.pointerId);let t=this.pointers.size===0;if(this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY,button:e.button}),this.stopMotion(),t&&e.button===0&&this.events.grab?.(...this.local(e))){this.grabbing=!0;return}if(clearTimeout(this.holdTimer),this.held=!1,this.pointers.size===1){this.press={x:e.clientX,y:e.clientY,time:performance.now(),moved:!1};let[n,r]=this.local(e);this.holdTimer=setTimeout(()=>{!this.press||this.press.moved||this.pointers.size!==1||(this.held=!0,this.events.hold(n,r))},YC)}else this.press=null,this.pinch=this.pinchState()}onMove(e){let t=this.pointers.get(e.pointerId);if(!t)return;if(this.grabbing)return void this.events.drag?.(...this.local(e));if(this.swiping)return void this.events.swipeMove?.(e.clientY-this.swiping.startY);let[n,r]=[e.clientX-t.x,e.clientY-t.y];if(this.press&&!this.press.moved&&Math.hypot(e.clientX-this.press.x,e.clientY-this.press.y)>KC){this.press.moved=!0,clearTimeout(this.holdTimer);let[s,o]=this.local({clientX:this.press.x,clientY:this.press.y});if(this.pointers.size===1&&t.button===0&&!e.shiftKey&&this.events.swipeStart?.(s,o,e.clientX-this.press.x,e.clientY-this.press.y))return this.swiping={startY:this.press.y},this.velocity={theta:0,phi:0},void this.events.swipeMove?.(e.clientY-this.press.y)}if(this.locked){[t.x,t.y]=[e.clientX,e.clientY];return}if(this.walk){if(!(this.press&&!this.press.moved)&&this.pointers.size===1){let s=this.el.clientHeight||1;this.walk.yaw+=n/s*2.4,this.walk.pitch=Ui(this.walk.pitch+r/s*1.8,-1.1,1.1),this.events.change()}[t.x,t.y]=[e.clientX,e.clientY];return}if(this.pointers.size===1)this.press&&!this.press.moved||(t.button===1||t.button===2||e.shiftKey?gm(this.view,n,r,this.el.clientHeight,this.camera.fov):this.velocity=K_(this.view,n,r,this.el.clientHeight)),[t.x,t.y]=[e.clientX,e.clientY];else{[t.x,t.y]=[e.clientX,e.clientY];let s=this.pinchState();this.pinch&&s&&(this.zoom(this.pinch.dist/Math.max(1,s.dist)),gm(this.view,s.mid[0]-this.pinch.mid[0],s.mid[1]-this.pinch.mid[1],this.el.clientHeight,this.camera.fov)),this.pinch=s}this.pointers.size===1&&this.press&&!this.press.moved||this.events.change()}onUp(e){if(this.pointers.has(e.pointerId)){if(this.pointers.delete(e.pointerId),this.grabbing)return this.grabbing=!1,void this.events.drop?.();if(this.swiping)return this.swiping=null,this.press=null,void this.events.swipeEnd?.();if(this.pointers.size<2&&(this.pinch=null),clearTimeout(this.holdTimer),this.held)this.held=!1,this.press=null;else if(this.press&&!this.press.moved&&e.type==="pointerup"&&performance.now()-this.press.timea*n);return{id:`${i.id}:vehicle`,type:e,x:i.x,z:i.z,rotation:i.rotation,w:r,d:s,h:o,variant:i.variant??null,entity:null,power:null}}function Bh(i,e){let t=[],n=!1;for(let r of i.furniture){t.push(r);let s=r.type==="parking"?e.get(r.id):void 0,o=s?jC(r,s):null;o&&(t.push(o),n=!0)}return n?{...i,furniture:t}:i}var QC="https://tile.openstreetmap.org/{z}/{x}/{y}.png";var eP=40075016686e-3,zh=Math.PI/180,tP=18,nP=.5,iP=160;function rP(i,e,t){let n=2**t,r=(e+180)/360*n,s=(1-Math.log(Math.tan(i*zh)+1/Math.cos(i*zh))/Math.PI)/2*n;return[r,s]}var sP=(i,e)=>eP*Math.cos(i*zh)/2**e;function j_(i,e,t,n=iP){let[r,s]=rP(i,e,t),o=sP(i,t),a=n/o,l=2**t-1,c=[];for(let u=Math.floor(s-a);u<=Math.floor(s+a);u++)for(let h=Math.floor(r-a);h<=Math.floor(r+a);h++){if(u<0||u>l)continue;let f=(h%(l+1)+l+1)%(l+1);c.push({x:f,y:u,z:t,east:(h-r)*o,north:-(u-s)*o,size:o})}return c}function Q_(i,e){return i.replace("{z}",String(e.z)).replace("{x}",String(e.x)).replace("{y}",String(e.y)).replace("{s}","abc"[(e.x+e.y)%3])}var eM=i=>i.url&&i.url.startsWith("https://")?i.url:QC;function tM(i,e,t,n){let r=t*zh;return[n.x+i*Math.cos(r)+e*Math.sin(r),n.z+i*Math.sin(r)-e*Math.cos(r)]}var nM=i=>!!i&&i.on===!0&&Number.isFinite(i.lat)&&Number.isFinite(i.lon),iM=i=>({x:i.x??0,z:i.z??0,opacity:i.opacity??nP,zoom:i.zoom??tP});var oP="strict-origin-when-cross-origin",xm=new Map;function rM(i){let e=xm.get(i);return e||(e=fetch(i,{referrerPolicy:oP,mode:"cors",credentials:"omit"}).then(async t=>t.ok&&(t.headers.get("content-type")??"").startsWith("image/")?await t.blob():null).catch(()=>null).then(t=>(t||setTimeout(()=>xm.delete(i),6e4),t)),xm.set(i,e)),e}var Xo=256,aP=Math.PI/180,Vh=class{mesh=new Se(new sn(1,1),new Ye({transparent:!0,depthWrite:!1,side:ht}));canvas=null;texture=null;key="";generation=0;centre=[0,0];onChange=()=>{};scene;constructor(e){this.scene=e,this.mesh.rotation.order="YXZ",this.mesh.renderOrder=-2,this.mesh.visible=!1,this.mesh.name="live-map",e.add(this.mesh)}set(e,t,n,r=1){if(!nM(e)){this.mesh.visible=!1,this.generation++,this.key="";return}let s=iM(e),o=eM(e),a=`${e.lat},${e.lon},${s.zoom},${o}`;a!==this.key&&this.load(a,e,s.zoom,o);let[l,c]=this.centre,[u,h]=tM(l,c,t,s);this.mesh.position.set(u,n,h),this.mesh.rotation.set(-Math.PI/2,-t*aP,0);let f=this.mesh.material;f.opacity=s.opacity,f.color.setScalar(r),this.mesh.visible=this.canvas!==null}load(e,t,n,r){this.key=e;let s=++this.generation,o=j_(t.lat,t.lon,n);if(!o.length)return;let a=o[0].size,l=Math.min(...o.map(x=>x.east)),c=Math.max(...o.map(x=>x.north)),u=Math.round((Math.max(...o.map(x=>x.east))-l)/a)+1,h=Math.round((c-Math.min(...o.map(x=>x.north)))/a)+1,f=document.createElement("canvas");f.width=u*Xo,f.height=h*Xo,this.canvas=f,this.texture?.dispose(),this.texture=new zt(f),this.texture.colorSpace=dt,this.texture.anisotropy=4;let d=this.mesh.material;d.map=this.texture,d.needsUpdate=!0,this.mesh.geometry.dispose(),this.mesh.geometry=new sn(u*a,h*a),this.centre=[l+u*a/2,c-h*a/2];let p=f.getContext("2d");if(p)for(let x of o)this.draw(p,x,r,s,Math.round((x.east-l)/a),Math.round((c-x.north)/a))}draw(e,t,n,r,s,o){rM(Q_(n,t)).then(a=>a?createImageBitmap(a):null).then(a=>{!a||r!==this.generation||(e.drawImage(a,s*Xo,o*Xo,Xo,Xo),this.texture&&(this.texture.needsUpdate=!0),this.onChange())})}dispose(){this.generation++,this.scene.remove(this.mesh),this.mesh.geometry.dispose(),this.mesh.material.dispose(),this.texture?.dispose()}};var lP=globalThis,sM=lP.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},cP=sM.plugins,xz=sM.listeners;var uP=5;function hP(i,e){i.errors.lengthNumber.isFinite(a))&&Number.isFinite(r.level)))return i;let o=a=>Math.max(0,Math.min(1,a));return{color:[o(r.color[0]),o(r.color[1]),o(r.color[2])],level:o(r.level)}}catch(r){return hP(n.status,r),i}}var aM={rainbow:(i,e)=>{let t=(e*.08%1+1)%1,n=r=>Math.max(0,Math.min(1,Math.abs((t*6+r)%6-3)-1));return{color:[n(0),n(4),n(2)],level:i.level}},flicker:(i,e)=>({...i,level:i.level*(.75+.15*Math.sin(e*17)+.1*Math.sin(e*31+1))}),pulse:(i,e)=>({...i,level:i.level*(.65+.35*Math.sin(e*Math.PI))})};function lM(i,e,t){return!i||!e?i:Object.prototype.hasOwnProperty.call(aM,e)?aM[e]?.(i,t)??i:oM(i,e,t)}var Yo=2043986,Xr=2769520,cM=2242399,Gh=1845831,uM=1450554,gi=16758087,hM=1846349,fM=2572395,dM=1120816,pM=1845831,mM=3662079,gM=5995775,xM=9085695,Yr=Be(3662079,.08),yM=1.2,bM=1.5,vM=.2,_M=.52;function Hh(i,e,t,n,r,s){let o=(x,m,g)=>e(x,m,g),{x0:a,x1:l,n0:c,n1:u,y0:h,y1:f}=t,d=x=>Be(n.getHex(),x),p=[[o(a,c,f),o(l,c,f),o(l,u,f),o(a,u,f),r],[o(a,c,h),o(l,c,h),o(l,u,h),o(a,u,h),d(.6)],[o(a,u,h),o(l,u,h),o(l,u,f),o(a,u,f),n],[o(a,c,h),o(l,c,h),o(l,c,f),o(a,c,f),d(.85)],[o(a,c,h),o(a,u,h),o(a,u,f),o(a,c,f),d(.92)],[o(l,c,h),o(l,u,h),o(l,u,f),o(l,c,f),d(.92)]];for(let[x,m,g,y,_]of p)i.tri(x,m,g,_,_,_,void 0,s),i.tri(x,g,y,_,_,_,void 0,s)}function Vt(i,e,t,n,r,{cut:s,bucket:o}){if(t.y1<=s+1e-6)return Hh(i,e,t,n,r,$e);if(t.y0>=s-1e-6)return Hh(i,e,t,n,r,o);Hh(i,e,{...t,y1:s},n,r,$e),Hh(i,e,{...t,y0:s},n,r,o)}function ti(i,e,t,n,r,s,o,a,{cut:l,bucket:c},u=0){let h=(f,d,p)=>{let x=b=>u?(o-b)/u:.5,[m,g,y,_]=[e(t,r,f),e(n,r,f),e(n,r,d),e(t,r,d)];i.tri(m,g,y,a,a,a,[0,x(f),1,x(f),1,x(d)],p),i.tri(m,y,_,a,a,a,[0,x(f),1,x(d),0,x(d)],p)};o<=l+1e-6?h(s,o,$e):s>=l-1e-6?h(s,o,c):(h(s,l,$e),h(l,o,c))}function MM(i,e,t,n,r,s,o,a,l,c){let[u,h,f,d]=[e(t,r,o),e(n,r,o),e(n,s,o),e(t,s,o)],p=(s-r)/c;i.tri(u,h,f,a,a,a,[0,0,1,0,1,p],l),i.tri(u,f,d,a,a,a,[0,0,1,p,0,p],l)}var dP=16777215,pP=13225686,mP=15722456,SM=.08,wM=.085;function TM(i){let{info:e,state:t,frame:n,fold:r}=i;if(t.cover===null)return;let[s,o,a]=[e.width,e.sill,e.top],l=e.opening.blind??"roller",c=-e.faceOut,u=e.faceRoom;l==="inside"?Vt(i.frames,n,{x0:-.03,x1:s+.03,n0:u,n1:u+.07,y0:a-.02,y1:a+.07},new W(15921906),new W(16250871),r):Vt(i.frames,n,{x0:-.05,x1:s+.05,n0:c-.15,n1:c,y0:a,y1:a+.2},new W(uM),new W(Xr),r);let h=t.cover2!=null?[[0,s/2,t.cover,t.slats??0],[s/2,s,t.cover2,t.slats2??t.slats??0]]:[[0,s,t.cover,t.slats??0]];for(let[f,d,p,x]of h){let m=Math.min(1,Math.max(0,p));if(m<=.01)continue;let g=a-m*(a-o);l==="inside"?ti(i.blinds,n,f+.01,d-.01,u+.04,g,a-.02,new W(mP),r):l==="venetian"?gP(i,f,d,c-.07,g,a,x):ti(i.blinds,n,f,d,c-.07,g,a,new W(dP),r,.045)}}function gP(i,e,t,n,r,s,o){let{frame:a,fold:l}=i,c=new W(pP),u=Math.PI/2*(.12+.88*Math.min(1,Math.max(0,o))),h=Math.sin(u)*wM/2,f=Math.cos(u)*wM/2;for(let d=s-SM/2;d>r;d-=SM){let p=d>=l.cut?l.bucket:$e,[x,m,g,y]=[a(e,n-h,d+f),a(t,n-h,d+f),a(t,n+h,d-f),a(e,n+h,d-f)];i.blinds.tri(x,m,g,c,c,c,[0,.5,1,.5,1,.5],p),i.blinds.tri(x,g,y,c,c,c,[0,.5,1,.5,0,.5],p)}}function AM(i){let{info:e,state:t,frame:n,fold:r}=i,[s,o,a]=[e.width,e.top,Math.min(0,e.sill)],l=e.opening.type==="garage"&&(i.markClosed?!!t.sensed&&(t.cover??1)>=.95:(t.cover??1)<.95),c=l?Be(gi,.8):new W(Yo),u=l?Be(gi,1):new W(Xr),[h,f]=[-e.faceOut-.012,e.faceRoom+.012],d=(p,x,m)=>Vt(i.frames,n,{x0:p,x1:x,n0:h,n1:f,y0:m,y1:o+.045},c,u,r);d(-.045,.02,a),d(s-.02,s+.045,a),d(.02,s-.02,o-.02)}function EM(i){let{info:e,state:t,frame:n,fold:r,mid:s}=i,[o,a,l]=[e.width,e.top,Math.min(0,e.sill)],c=a-l,u=Sr(e.opening,e.exterior),h=u==="passage",f=ag(u),d=e.opening.swing==="out"?-1:1,p=d>0?e.faceRoom:-e.faceOut,x=e.opening.leaves===2,m=new W(Yo),g=new W(Xr),y=.02,_=o-.02,b=og(o,u,e.hingeAtStart,e.opening);if(b){for(let[P,T]of b.panels){let R=(L,U,C,I)=>Vt(i.frames,n,{x0:L,x1:U,n0:s-.03,n1:s+.03,y0:C,y1:I},m,g,r);R(P,P+.04,l+.02,a-.02),R(T-.04,T,l+.02,a-.02),R(P,T,l+.02,l+.1),ti(i.glass,n,P+.04,T-.04,s,l+.1,a-.02,Yr,r)}y=b.x0,_=b.x1}let M=x?(_-y)/2-.004:_-y,S=f?.06:.04;f&&(Vt(i.frames,n,{x0:.02,x1:o-.02,n0:-e.faceOut-.02,n1:e.faceRoom,y0:l,y1:l+.02},new W(Gh),g,r),e.exterior&&Vt(i.frames,n,{x0:o/2-.08,x1:o/2+.08,n0:-e.faceOut-.1,n1:-e.faceOut,y0:a+.1,y1:a+.17},Be(gi,.55),Be(gi,.85),{cut:r.cut,bucket:$e}));let v=e.opening.open_angle?Math.min(180,Math.max(5,e.opening.open_angle))*mt:bM,w=h?[]:[[e.hingeAtStart,t.open]];x&&!h&&w.push([!e.hingeAtStart,t.open2??0]);for(let[P,T]of w){let R=Math.min(1,Math.max(0,T)),L=u==="sliding"?0:R*v,U=u==="sliding"?R*M:0,C=(Q,se,we)=>{let le=Q*Math.cos(L)-se*Math.sin(L)-U,Ne=p+d*(se*Math.cos(L)+Q*Math.sin(L)+(U?.05:0));return n(P?y+le:_-le,Ne,we)},I={cut:r.cut,bucket:R>.05?$e:r.bucket},O=i.markClosed?!!t.sensed&&R<.05:R>.9&&!(P===e.hingeAtStart&&t.assumed),F=O?Be(gi,.7):new W(f?dM:hM),H=O?Be(gi,.9):new W(f?pM:fM),k=(Q,se,we,le,Ne=-S,at=0)=>Vt(i.frames,C,{x0:Q,x1:se,n0:Ne,n1:at,y0:we,y1:le},F,H,I);u==="glass"?(k(0,.05,l+.01,a-.01),k(M-.05,M,l+.01,a-.01),k(.05,M-.05,l+.01,l+.12),k(.05,M-.05,a-.08,a-.01),ti(i.glass,C,.05,M-.05,-S/2,l+.12,a-.08,Yr,I)):k(0,M,l+.01,a-.01),u==="front_glass"?ti(i.glass,C,.12,M-.12,.001,l+c*.55,a-.18,Yr,I):f&&ti(i.glass,C,.1,.18,.001,l+.3,a-.3,Yr,I);let X=l+Math.min(1.05,c*.5),V=f?.3:.012,[re,ye]=f?[M-.11,M-.08]:[M-.16,M-.05],Y=(Q,se)=>Vt(i.frames,C,{x0:re,x1:ye,n0:Q,n1:se,y0:X-V,y1:X+V},new W(gM),new W(xM),I);if(Y(.004,.05),Y(-S-.05,-S-.004),t.unlocked){let Q=new W(mM);Vt(i.frames,C,{x0:M-.012,x1:M+.004,n0:-S-.004,n1:.004,y0:l+.06,y1:a-.06},Q,Q,{cut:r.cut,bucket:$e})}}}function RM(i){let{info:e,state:t,frame:n,fold:r}=i,[s,o,a]=[e.width,e.top,Math.min(0,e.sill)],l=Math.min(1,Math.max(0,t.cover??1)),c=new W(13951231),u=e.faceRoom-.03;l>.01&&ti(i.blinds,n,.02,s-.02,u,a+(o-a)*(1-l),o,c,r,.5);let h=(1-l)*(o-a);h>.01&&MM(i.blinds,n,.02,s-.02,u,u+h,o+.03,c,r.bucket,.5)}var xP=4936290,yP=7041926,CM=2764860,PM=9082024;function IM(i,e){let{info:t}=i;return t.opening.type!=="window"||!t.exterior||t.opening.light_well===!1?!1:t.opening.light_well===!0||t.sillVt(i.frames,n,{x0:g,x1:y,n0:_,n1:b,y0:c,y1:u},h,f,r);p(s-d,s,a-l,a),p(o,o+d,a-l,a),p(s-d,o+d,a-l-d,a-l),Vt(i.frames,n,{x0:s,x1:o,n0:a-l,n1:a,y0:c-d,y1:c},h,f,r);let x=(g,y)=>Vt(i.frames,n,{x0:g,x1:y,n0:a-l,n1:a,y0:u-.025,y1:u},new W(CM),new W(PM),r),m=Math.max(3,Math.round((o-s)/.06));for(let g=0;g<=m;g++){let y=s+(o-s)*g/m;x(y-.008,y+.008)}Vt(i.frames,n,{x0:s,x1:o,n0:a-l-.01,n1:a-l+.02,y0:u-.03,y1:u},new W(CM),new W(PM),r)}var Us={open:0,open2:0,tilt:0,tilt2:0,cover:null};function FM(i){let{info:e,frame:t,fold:n,mid:r}=i,[s,o,a]=[e.width,e.sill,e.top],[l,c]=[.04,.025],u=new W(Yo),h=new W(Xr),f=(y,_,b,M)=>Vt(i.frames,t,{x0:y,x1:_,n0:r-c,n1:r+c,y0:b,y1:M},u,h,n);i.first&&f(0,l,o,a),i.last&&f(s-l,s,o,a);let[d,p]=[i.first?l:-i.over[0],i.last?s-l:s+i.over[1]];f(d,p,o,o+.03),f(d,p,a-l,a);let x=e.opening.front?0:e.opening.panes,m=Math.max(1,x==null?Math.max(1,Math.round((p-d)/.9)):Math.round(x)),g=(p-d)/m;for(let y=1;yVt(i.frames,n,{x0:T,x1:R,n0:s-u,n1:s+u,y0:L,y1:U},h,f,r),x=a+(a>.05?c:.03);p(0,c,a,l),p(o-c,o,a,l),p(c,o-c,a,x),p(c,o-c,l-c,l);let m=e.opening.sill_boards??"auto";m!=="none"&&(m!=="auto"||a>.3)&&(m!=="outside"&&Vt(i.frames,n,{x0:-.04,x1:o+.04,n0:s+u,n1:e.faceRoom+.07,y0:a-.03,y1:a},d,f,r),e.exterior&&m!=="inside"&&Vt(i.frames,n,{x0:-.03,x1:o+.03,n0:-e.faceOut-.06,n1:s-u,y0:a-.04,y1:a-.02},d,f,r));let g=.055,[y,_]=[x,l-c],[b,M]=[s+u,s+u+.06],S=e.hingeAtStart,v=e.opening.opens??"turn",w=v==="slide"?bP(o,c,S,e.opening.leaves,t.open,t.open2??0):e.opening.leaves===2?[{atStart:S,x0:S?c:o/2,x1:S?o/2:o-c,open:t.open,tilt:t.tilt},{atStart:!S,x0:S?o/2:c,x1:S?o-c:o/2,open:t.open2??0,tilt:t.tilt2??0}]:[{atStart:S,x0:c,x1:o-c,open:t.open,tilt:t.tilt}],P=Sr(e.opening,e.exterior);for(let T of w){let R=v==="top"?Math.max(T.open,T.tilt)*_M:0,U=(v!=="slide"||!!T.slide)&&(T.open>.02||T.tilt>.02),C=i.markClosed?!!t.sensed&&!U:U,I=C?Be(gi,.75):new W(cM),O=C?Be(gi,.95):f,F=T.x1-T.x0,H=v==="turn",k=H?T.open*yM:0,X=H?T.tilt*vM:0,V=(T.slide??0)*T.open,re=v==="slide"&&T.track===0?-.065:0,ye=(se,we,le)=>{if(R>0){let[nt,Yt]=[we-b,le-_],[Bt,on]=[Math.cos(R),Math.sin(R)];return n(T.atStart?T.x0+se:T.x1-se,b+nt*Bt+Yt*on,_-nt*on+Yt*Bt)}let Ne=le-y,at=we+Ne*Math.sin(X)+re,Ae=y+Ne*Math.cos(X),ft=se*Math.cos(k)-(at-b)*Math.sin(k),yt=b+(at-b)*Math.cos(k)+se*Math.sin(k);return n((T.atStart?T.x0+ft:T.x1-ft)+V,yt,Ae)},Y={cut:r.cut,bucket:k>.05||R>.05?$e:r.bucket},Q=(se,we,le,Ne,at=b,Ae=M)=>Vt(i.frames,ye,{x0:se,x1:we,n0:at,n1:Ae,y0:le,y1:Ne},I,O,Y);if(Q(0,g,y,_),Q(F-g,F,y,_),Q(g,F-g,y,y+g),Q(g,F-g,_-g,_),ti(i.glass,ye,g,F-g,(b+M)/2,y+g,_-g,C?Be(gi,.16):Yr,Y),P==="bars"){let[se,we]=[(y+_)/2,(b+M)/2];Q(g,F-g,se-.012,se+.012,we-.012,we+.012),Q(F/2-.012,F/2+.012,y+g,_-g,we-.012,we+.012)}}}var ym=i=>i.opening.front??i.opening.id;function bm(i,e,t,n=-1/0){let r=new ut,s=new ut,o=new ut(!0),a=[],l=[],c=[],u=new Map;i.forEach((x,m)=>{let g=ym(x);u.set(g,[...u.get(g)??[],m])});let h=x=>[[x.start[0],x.start[1]],[x.start[0]+x.axis[0]*x.width,x.start[1]+x.axis[1]*x.width]],f=x=>`${Math.round(x[0]*50)},${Math.round(x[1]*50)}`,d=new Map,p=new Map;for(let x of u.values()){let m=new Map,g=new Map;for(let _ of x){let[b,M]=h(i[_]);m.set(f(b),[...m.get(f(b))??[],_]),g.set(f(M),[...g.get(f(M))??[],_])}let y=(_,b)=>{if(b==null||b===_)return 0;let M=Math.abs((i[_].faceRoom-i[_].faceOut)/2),[S,v]=[i[_].axis,i[b].axis],w=Math.max(-1,Math.min(1,S[0]*v[0]+S[1]*v[1])),P=Math.acos(w);return Pw!==_),v=(m.get(f(M))??[]).find(w=>w!==_);d.set(_,[S==null,v==null]),p.set(_,[y(_,S),y(_,v)])}}for(let x=0;x[m.start[0]+m.axis[0]*w+m.toRoom[0]*P,T,m.start[1]+m.axis[1]*w+m.toRoom[1]*P],mid:(m.faceRoom-m.faceOut)/2,markClosed:m.opening.mark==="closed",fold:{cut:t,bucket:m.bucket},frames:r,glass:s,blinds:o,first:b,last:M,over:p.get(x)??[0,0]};(y==="door"&&_!=="passage"||y==="garage")&&AM(S),y==="door"?EM(S):y==="garage"?RM(S):_==="glass_wall"?FM(S):NM(S),IM(S,n)&&LM(S,n),y!=="garage"&&TM(S);let v=ym(m);a.push({id:v,start:g.frames,end:r.count}),l.push({id:v,start:g.glass,end:s.count}),c.push({id:v,start:g.blinds,end:o.count})}return{frames:r.geometry(),glass:s.geometry(),blinds:o.geometry(),frameTris:a,glassTris:l,blindTris:c}}var vm=Math.PI/180,Ul=2400,qo=1600,_m=9,OM=360;function Wh(i,e=64){let t=document.createElement("canvas");t.width=t.height=e;let n=t.getContext("2d"),r=n.createRadialGradient(e/2,e/2,0,e/2,e/2,e/2);for(let[s,o]of i)r.addColorStop(s,o);return n.fillStyle=r,n.fillRect(0,0,e,e),new zt(t)}function vP(i){let t=document.createElement("canvas");t.width=128,t.height=128/2;let n=t.getContext("2d"),r=i*9301+49297,s=()=>(r=(r*9301+49297)%233280)/233280;for(let o=0;o<7;o++){let a=128*(.2+.6*s()),l=128/2*(.45+.25*s()),c=128*(.12+.14*s()),u=n.createRadialGradient(a,l,0,a,l,c);u.addColorStop(0,"rgba(255,255,255,0.9)"),u.addColorStop(.6,"rgba(255,255,255,0.45)"),u.addColorStop(1,"rgba(255,255,255,0)"),n.fillStyle=u,n.fillRect(0,0,128,128/2)}return new zt(t)}var Xh=class{group=new et;scene;bounds={x0:-10,x1:10,z0:-10,z1:10,y0:0,y1:8};view=null;rain;rainVel=new Float32Array(Ul*3);snow;snowPhase=new Float32Array(qo);hail;clouds=[];bolt;disc;halo;stars;cover;last=0;nextBolt=0;boltUntil=0;onFlash=null;constructor(e){this.scene=e,this.group.name="live-weather",this.group.renderOrder=5;let t=new Pe;t.setAttribute("position",new Le(new Float32Array(Ul*6),3)),this.rain=new xn(t,new Lt({color:11128309,transparent:!0,opacity:.5,depthWrite:!1}));let n=Wh([[0,"rgba(255,255,255,1)"],[.5,"rgba(255,255,255,0.6)"],[1,"rgba(255,255,255,0)"]],32),r=new Pe;r.setAttribute("position",new Le(new Float32Array(qo*3),3)),this.snow=new yn(r,new cn({color:16185855,size:.16,map:n,transparent:!0,opacity:.9,depthWrite:!1}));for(let h=0;h.02,this.stars.position.set((n.x0+n.x1)/2,n.y0,(n.z0+n.z1)/2),this.stars.scale.setScalar(r*3);let a=this.cover.material,l=(t?.snow??0)+(t?.hail??0)*.5,c=t?.rain??0;a.color.setHex(l>.05?16054527:1848656),a.opacity=l>.05?.3+.45*Math.min(1,l):c>.1?.25*Math.min(1,c):0,this.cover.visible=a.opacity>.02,this.cover.position.set((n.x0+n.x1)/2,n.y0-.18,(n.z0+n.z1)/2),this.cover.scale.set(n.x1-n.x0,n.z1-n.z0,1)}set(e){let t=this.view;this.view=e,this.group.visible=!!e;let n=e?.weather??null;if(e&&n&&n.fog>.02&&!e.low){let r=new W(e.sky[0]/255,e.sky[1]/255,e.sky[2]/255);this.scene.fog=new cs(r,.008+.04*n.fog)}else this.scene.fog instanceof cs&&(this.scene.fog=null);(!t||t.low!==e?.low||!!t.weather!=!!n)&&this.seed(),this.placeDisc(),this.placeNight(),n?.lightning||this.endBolt()}windVector(){let e=this.view?.weather;if(!e)return[0,0];let n=((e.windFrom??270)+(this.view?.north??0)+180)*vm,r=.4+7*e.wind;return[Math.sin(n)*r,-Math.cos(n)*r]}count(e,t){let n=this.view?.low??!1;return Math.round(Math.min(1,e)*t*(n?.3:1))}seed(){let e=this.bounds,t=this.view?.weather,n=()=>e.x0+Math.random()*(e.x1-e.x0),r=()=>e.z0+Math.random()*(e.z1-e.z0),s=()=>e.y0+Math.random()*(e.y1-e.y0),o=this.rain.geometry.getAttribute("position");for(let c=0;c.01,this.snow.visible=!!t&&t.snow>.01,this.hail.visible=!!t&&t.hail>.01,this.clouds.forEach((c,u)=>{c.angle=u/_m*Math.PI*2+Math.random()*.5,c.ring=1.7+Math.random()*.9,c.lift=.35+Math.random()*.35,c.scale=.55+Math.random()*.45,c.sx=e.x0+Math.random()*(e.x1-e.x0),c.sz=e.z0+Math.random()*(e.z1-e.z0)}),this.placeClouds(0)}placeClouds(e){let t=this.view,n=t?.weather,r=n?.cloud??0,s=this.bounds,o=(s.x0+s.x1)/2,a=(s.z0+s.z1)/2,l=Math.max(s.x1-s.x0,s.z1-s.z0),[c,u]=this.windVector(),h=Math.round(r*_m),f=t?.sky??[20,28,44],d=(f[0]+f[1]+f[2])/765,p=n?.rain||n?.lightning?.3:0,x=Math.max(.12,Math.min(1,.28+d*.9-p-.25*Math.max(0,r-.6))),m=Math.hypot(c,u)/Math.max(20,l*4)*e*Math.sign(c||1);this.clouds.forEach((g,y)=>{let _=ys.x1+S&&(g.sx=s.x0-S),g.sxs.z1+S&&(g.sz=s.z0-S),g.sz.9||!r&&t.elevation<.5){this.disc.visible=this.halo.visible=!1;return}let s=this.bounds,o=new D((s.x0+s.x1)/2,s.y0,(s.z0+s.z1)/2),a=Math.max(70,Math.max(s.x1-s.x0,s.z1-s.z0)*3.5),l=((r?t.azimuth+180:t.azimuth)+e.north)*vm,c=Math.max(8,Math.abs(t.elevation))*vm,u=new D(Math.sin(l)*Math.cos(c),Math.sin(c),-Math.cos(l)*Math.cos(c)),h=o.addScaledVector(u,a),f=a*(r?.07:.1);this.disc.position.copy(h),this.halo.position.copy(h),this.disc.scale.setScalar(f),this.halo.scale.setScalar(f*3.2);let d=this.disc.material,p=this.halo.material,x=r?0:Math.max(0,1-t.elevation/20);d.color.set(r?14016242:new W(1,.9-.25*x,.6-.35*x)),p.color.copy(d.color),d.opacity=(r?.7:.95)*(1-n),p.opacity=(r?.35:.6)*(1-n),this.disc.visible=this.halo.visible=!0}endBolt(){this.bolt.visible&&(this.bolt.visible=!1,this.onFlash?.(!1))}strike(e){let t=this.bounds,r=(Math.random()<.5?-1:1)<0?t.x0-2-Math.random()*6:t.x1+2+Math.random()*6,s=t.z0+Math.random()*(t.z1-t.z0),o=t.y1+4,a=this.bolt.geometry.getAttribute("position"),l=24,c=o;for(let u=0;u.01&&this.placeClouds(r),n.lightning&&!t.low?(this.nextBolt||(this.nextBolt=e+2500+Math.random()*6e3),e>=this.nextBolt&&(this.strike(e),this.nextBolt=e+3500+Math.random()*9e3),this.bolt.visible&&e>this.boltUntil&&this.endBolt()):this.nextBolt=0,this.rain.visible||this.snow.visible||this.hail.visible||n.cloud>.01||n.lightning}dispose(){this.endBolt(),this.group.traverse(e=>{let t=e;t.geometry?.dispose();let n=t.material;n?.map?.dispose(),n?.dispose()}),this.scene.remove(this.group),this.scene.fog instanceof cs&&(this.scene.fog=null)}};var Yh=46,qh=33,Bs=900;function Mm(){let i=document.createElement("canvas");i.width=i.height=32;let e=i.getContext("2d"),t=e.createRadialGradient(16,16,0,16,16,16);return t.addColorStop(0,"rgba(255,255,255,1)"),t.addColorStop(.35,"rgba(255,255,255,0.7)"),t.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=t,e.fillRect(0,0,32,32),new zt(i)}var $h=class{group=new et;scene;lift;tex=Mm();arcs=new Map;sparkFields=[];sparks;sparkBase=new Float32Array(Bs*3);sparkField=new Int16Array(Bs);sparkPhase=new Float32Array(Bs);sparkCount=0;last=0;constructor(e,t){this.scene=e,this.lift=t,this.group.name="live-energy";let n=new Pe;n.setAttribute("position",new Le(new Float32Array(Bs*3),3)),n.setAttribute("color",new Le(new Float32Array(Bs*3),3)),this.sparks=new yn(n,new cn({size:.4,map:this.tex,vertexColors:!0,transparent:!0,depthWrite:!1,blending:Ft})),this.sparks.frustumCulled=!1,this.group.add(this.sparks),e.add(this.group)}get active(){return this.arcs.size>0||this.sparkCount>0}setArcs(e){let t=new Set(e.map(n=>n.key));for(let[n,r]of this.arcs)t.has(n)||(this.group.remove(r.line,r.points),r.line.geometry.dispose(),r.line.material.dispose(),r.points.geometry.dispose(),r.points.material.dispose(),this.arcs.delete(n));for(let n of e){let r=this.arcs.get(n.key);if(!r){let o=new Pe;o.setAttribute("position",new Le(new Float32Array(qh*3),3));let a=new In(o,new Lt({transparent:!0,opacity:.4,depthWrite:!1,blending:Ft})),l=new Pe;l.setAttribute("position",new Le(new Float32Array(Yh*3),3));let c=new yn(l,new cn({size:.55,map:this.tex,transparent:!0,depthWrite:!1,blending:Ft}));a.frustumCulled=c.frustumCulled=!1;let u=new Float32Array(Yh);for(let h=0;hnew D):null,r.points.material.color.copy(s),r.count=n.power<=0?0:Math.max(3,Math.min(Yh,Math.round(3+Math.sqrt(n.power)/2.2))),r.speed=.18+Math.min(.5,Math.log10(1+n.power)*.1),r.points.geometry.setDrawRange(0,r.count)}this.place()}setSparks(e){this.sparkFields=e;let t=e.reduce((r,s)=>r+s.quads.length*s.level,0),n=0;t>0&&e.forEach((r,s)=>{if(r.level<=0)return;let o=Math.round(Bs*r.quads.length*r.level/Math.max(t,e.reduce((a,l)=>a+l.quads.length,0)));for(let a=0;a0}world(e,t){let n=this.lift(e.floorId);return t.set(e.x,n.y+e.y,e.z),n.visible}place(){for(let e of this.arcs.values()){if(e.path){this.placeRoute(e,e.path);continue}let t=this.world(e.arc.from,e.a),n=this.world(e.arc.to,e.b),r=e.a.distanceTo(e.b);e.c.copy(e.a).add(e.b).multiplyScalar(.5),e.c.y=Math.max(e.a.y,e.b.y)+.6+r*.22;let s=t&&n;e.line.visible=e.points.visible=s;let o=e.line.geometry.getAttribute("position");for(let a=0;ar=this.world(o,t[a])&&r),e.line.visible=e.points.visible=r,e.along=[0];for(let o=1;os.setXYZ(a,o.x,o.y,o.z)),e.line.geometry.setDrawRange(0,t.length),s.needsUpdate=!0}at(e,t){if(!e.path)return this.bezier(e,t);let n=e.along[e.along.length-1]||1,r=t*n,s=1;for(;s0}set(e,t){let n=new Set(e.map(r=>r.id));for(let[r,s]of this.spots)if(!n.has(r)){for(let o of s.rings)this.group.remove(o),o.material.dispose();this.spots.delete(r)}for(let r of e){let s=this.spots.get(r.id);if(!s){let a=Array.from({length:DM},()=>{let l=new Se(this.ringGeo,new Ye({transparent:!0,opacity:0,depthWrite:!1,blending:Ft,side:ht}));return l.rotation.x=-Math.PI/2,l.frustumCulled=!1,this.group.add(l),l});s={spot:r,rings:a},this.spots.set(r.id,s)}s.spot=r;let o=new W(r.color[0]/255,r.color[1]/255,r.color[2]/255);for(let a of s.rings)a.material.color.copy(o)}for(let r of this.links)this.group.remove(r.line),r.line.geometry.dispose(),r.line.material.dispose();this.links=t.map(([r,s])=>{let o=new Pe;o.setAttribute("position",new Le(new Float32Array(51),3));let a=new In(o,new Lt({color:12616956,transparent:!0,opacity:.55,depthWrite:!1,blending:Ft}));return a.frustumCulled=!1,this.group.add(a),{a:r,b:s,line:a}})}step(e){if(!this.spots.size&&!this.links.length)return!1;let t=e/1e3;for(let n of this.spots.values()){let r=this.lift(n.spot.at.floorId),s=.9+1.6*n.spot.level;n.rings.forEach((o,a)=>{let l=(t*.55+a/DM)%1;o.visible=r.visible,o.position.set(n.spot.at.x,r.y+n.spot.at.y,n.spot.at.z),o.scale.setScalar((.25+l*s)*(n.spot.size??1)),o.material.opacity=(1-l)*(.35+.5*n.spot.level)})}for(let n of this.links){let r=this.lift(n.a.floorId),s=this.lift(n.b.floorId);n.line.visible=r.visible&&s.visible;let o=n.line.geometry.getAttribute("position"),a=r.y+n.a.y,l=s.y+n.b.y,c=Math.hypot(n.a.x-n.b.x,n.a.z-n.b.z);for(let u=0;u<=16;u++){let h=u/16,f=Math.sin(Math.PI*h)*(.3+c*.12)+Math.sin(t*3+h*12)*.03;o.setXYZ(u,n.a.x+(n.b.x-n.a.x)*h,a+(l-a)*h+f,n.a.z+(n.b.z-n.a.z)*h)}o.needsUpdate=!0}return!0}dispose(){this.set([],[]),this.ringGeo.dispose(),this.scene.remove(this.group)}};var Zh=6,UM=24,kM=Zh*UM;function _P(i,e,t){let n=i%Zh,r=Math.floor(i/Zh),s=(r/UM+e*.7)%1,o=n/Zh*Math.PI*2+e*.35+(r*7%5-2)*.012,a=s*t,l=Math.min(1.2,t/3);return[Math.cos(o)*a,4*l*s*(1-s),Math.sin(o)*a]}var Jh=class{group=new et;scene;lift;tex=Mm();material=new cn({color:11068159,size:.09,map:this.tex,transparent:!0,opacity:.9,depthWrite:!1});sprays=new Map;constructor(e,t){this.scene=e,this.lift=t,this.group.name="live-water",e.add(this.group)}get active(){return this.sprays.size>0}set(e){let t=new Set(e.map(n=>n.id));for(let[n,r]of this.sprays)t.has(n)||(this.group.remove(r.points),r.points.geometry.dispose(),this.sprays.delete(n));for(let n of e){let r=this.sprays.get(n.id);if(r){r.spot=n;continue}let s=new Pe;s.setAttribute("position",new Le(new Float32Array(kM*3),3));let o=new yn(s,this.material);o.frustumCulled=!1,this.group.add(o),this.sprays.set(n.id,{spot:n,points:o})}}step(e){if(!this.sprays.size)return!1;let t=e/1e3;for(let n of this.sprays.values()){let r=this.lift(n.spot.at.floorId);n.points.visible=r.visible,n.points.position.set(n.spot.at.x,r.y+n.spot.at.y,n.spot.at.z);let s=n.points.geometry.getAttribute("position");for(let o=0;on.value!==null&&Number.isFinite(n.value)&&Number.isFinite(n.level)).slice().sort((n,r)=>n.level-r.level);return Array.from({length:e},(n,r)=>{if(!t.length)return null;let s=(r+.5)/e;if(s<=t[0].level)return t[0].value;let o=t.findIndex(u=>u.level>=s);if(o<0)return t.at(-1).value;let a=t[o-1],l=t[o],c=l.level-a.level;return c>0?a.value+(l.value-a.value)*(s-a.level)/c:l.value})}function zs(i,e){let t=i.item;return new D(e[0]*(t.mirror?-1:1),e[1],e[2]).applyEuler(new Zn((t.tilt_x??0)*Math.PI/180,-t.rotation*Math.PI/180,(t.tilt_z??0)*Math.PI/180,"YZX")).add(new D(t.x,i.base,t.z))}var zM=i=>zs(i,[1,0,0]).sub(zs(i,[0,0,0]));function MP(i,e){let t=i.item,n=e.item,r=ko(t),s=zs(i,[0,t.h/2,0]),o=zs(e,[0,n.h/2,0]),a=zM(i),l=zM(e),c=o.clone().sub(s).dot(a)>=0?1:-1,u=s.clone().sub(o).dot(l)>=0?1:-1,h=-1/0;for(let f of[i,e])for(let d of[-f.item.w/2,f.item.w/2])for(let p of[-f.item.d/2,f.item.d/2])for(let x of[0,f.item.h])h=Math.max(h,zs(f,[d,x,p]).z);return["primary_flow","primary_return"].map((f,d)=>{let p=zs(i,[c*t.w*.49,d?r.ys.back:r.ys.flow,d?r.blueZ:r.redZ]),x=zs(e,yh(n,u,d?.12:.88).end),m=p.clone().addScaledVector(a,c*.15),g=x.clone().addScaledVector(l,u*.15),y=h+.24+d*.07;return{medium:f,points:[p,m,new D(m.x,m.y,y),new D(g.x,m.y,y),new D(g.x,g.y,y),g,x]}})}var VM=i=>{let e=i.item;return[i.floorId,i.base,e.id,e.x,e.z,e.w,e.d,e.h,e.rotation,e.tilt_x??0,e.tilt_z??0,!!e.mirror].join("|")},jh=class{views=new Map;parent;lift;constructor(e,t){this.parent=e,this.lift=t}remove(e){let t=new Set;e.group.traverse(n=>{n instanceof Se&&(n.geometry.dispose(),Array.isArray(n.material)?n.material.forEach(r=>t.add(r)):t.add(n.material))}),t.forEach(n=>n.dispose()),this.parent.remove(e.group)}set(e){let t=new Set;for(let n of e){if(n.item.type!=="freshwater_station"||!n.item.hydronic?.buffer_id)continue;let r=e.find(u=>u.id===n.item.hydronic.buffer_id&&u.floorId===n.floorId&&u.item.type==="buffer_tank");if(!r)continue;t.add(n.id);let s=this.views.get(n.id),o=VM(n)+"/"+VM(r);if(s?.key===o){s.station=n,s.buffer=r;continue}s&&this.remove(s);let a=new et;a.name=`hydronic-connection-${n.id}`;let l=Math.min(n.item.d*.05,.018),c=new D(0,1,0);for(let u of MP(n,r)){let h=new Ye({color:u.medium==="primary_flow"?12140088:3308718});for(let f=1;fi===null?new W(6910332):new W().setHSL((1-Math.max(0,Math.min(1,i/85)))*.62,.8,.55),wP=new W(1342650),GM=new W(12379625),TP=new W(13642552),Qh=class{group=new et;views=new Map;scene;lift;connections;constructor(e,t){this.scene=e,this.lift=t,this.connections=new jh(this.group,t),this.group.name="live-hydronics",e.add(this.group)}remove(e){e.group.traverse(t=>{t instanceof Se&&(t.geometry.dispose(),t.material.dispose())}),this.group.remove(e.group)}set(e){let t=new Set(e.map(n=>n.id));for(let[n,r]of this.views)t.has(n)||(this.remove(r),this.views.delete(n));for(let n of e){let r=this.views.get(n.id);r?.spot.item!==n.item&&(r&&this.remove(r),r=this.build(n),this.views.set(n.id,r)),r.spot=n,r.bands=n.item.type==="buffer_tank"?BM(n.probes):[]}this.connections.set(e)}build(e){let t=new et,n=[],r=e.item,s=Rl(r),o=(l,c,u,h,f,d={},p)=>{let x=new Se(p??(f==="temperature"?new ir(h,10,6):new Mi(h*1.6,h*.3,.012)),new Ye({color:6910332,depthWrite:!0}));x.name=`hydronic-${f}-${d.circulation?"circulation":d.station!==void 0?`station-${d.station}${f==="temperature"?`-${d.temp??0}`:""}`:d.circuit??d.probe??d.temp??0}`,x.position.set(l,c,u),t.add(x),n.push({mesh:x,kind:f,...d})},a=(l,c,u,h,f)=>{o(l,c,u+.001,h*.84,"pumpState",f,new Pa(h*.84,24));let d=[];for(let p=0;p<3;p++)for(let[x,m]of[[0,.1],[.28,.18],[0,.73]]){let g=p*Math.PI*2/3;d.push(h*(x*Math.cos(g)-m*Math.sin(g)),h*(x*Math.sin(g)+m*Math.cos(g)),0)}o(l,c,u+.002,h,"pump",f,new Pe().setAttribute("position",new Le(d,3)))};if(r.type==="heating_manifold"){let l=s.circuits??[];l.forEach((c,u)=>{let h=ph(r,c,u,l.length);Cl(c)&&a(h.flowX,h.pumpY,h.pumpFront,h.pumpR,{circuit:u}),Ls(c)&&o(h.flowX,h.valveY,h.valveFront+.003,h.valveR*.8,"valve",{circuit:u}),o(h.flowGaugeX,h.temperatureY,h.gaugeFront+.001,h.gaugeR*.45,"temperature",{circuit:u,temp:0}),o(h.returnGaugeX,h.temperatureY,h.gaugeFront+.001,h.gaugeR*.45,"temperature",{circuit:u,temp:1})})}else if(r.type==="buffer_tank"){(s.sensors??[]).forEach((l,c)=>o(0,r.h*(.1+.8*l.level),Math.min(r.w,r.d)*.46+.025,.021,"temperature",{probe:c}));for(let l=0;l<24;l++){let c=Math.min(r.w,r.d)*.464;o(0,r.h*(.1+.8*(l+.5)/24),0,c,"bufferBand",{band:l},new ds(c,c,r.h*.8/24,32,1,!0));let u=n.at(-1).mesh.material;u.transparent=!0,u.opacity=.8,u.depthWrite=!1}}else{let l=ko(r);if(l.units.forEach((c,u)=>{let h=c.pump;if(a(h.x,h.y,h.front,h.r,{station:u}),c.valve){let f=c.valve;o(f.x,f.y,f.front+.003,f.r*.8,"valve",{station:u})}c.probes.forEach((f,d)=>o(f.x,f.y,f.front+.001,f.r*.5,"temperature",{station:u,temp:d}))}),l.circulationPipes.length){let c=l.circPump;a(c.x,c.y,c.front,c.r,{circulation:!0});let u=l.circProbe;o(u.x,u.y,u.front+.001,u.r*.5,"temperature",{temp:2})}}return t.rotation.set((r.tilt_x??0)*Math.PI/180,-r.rotation*Math.PI/180,(r.tilt_z??0)*Math.PI/180,"YZX"),t.scale.x=r.mirror?-1:1,t.name=`hydronic-${r.id}`,this.group.add(t),{spot:e,group:t,parts:n,bands:[]}}step(e){let t=!1;this.connections.step();for(let n of this.views.values()){let{spot:r}=n,s=this.lift(r.floorId);n.group.visible=s.visible,n.group.position.set(r.item.x,s.y+r.base,r.item.z);for(let o of n.parts){let a=o.circuit===void 0?void 0:r.circuits[o.circuit],l=o.station===void 0?void 0:r.stations?.[o.station];if(o.kind==="bufferBand"){let c=n.bands[o.band??0];if(o.mesh.visible=c!=null,c!=null){let u=Math.max(0,Math.min(1,(c-20)/45));o.mesh.material.color.copy(u<.5?wP:GM).lerp(u<.5?GM:TP,u<.5?u*2:(u-.5)*2)}}else if(o.kind==="temperature"){let c=o.station!==void 0?l?.temperatures[o.temp??0]:o.probe!==void 0?r.probes[o.probe]?.value:a?o.temp===0?a.flow:a.return:r.temperatures[o.temp??0];o.mesh.material.color.copy(SP(c??null))}else if(o.kind==="pump"||o.kind==="pumpState"){let c=o.station!==void 0?l?.pump??null:a?a.pump:o.circulation?r.circulation:r.pump;if(o.kind==="pumpState"){o.mesh.material.color.set(c===null?7501950:c?4953657:11019832);continue}o.mesh.material.color.set(c===null?11712441:14739417),o.mesh.rotation.z=Number(o.mesh.userData.angle??0)+(c&&r.animate!==!1?e/350:0),t||=s.visible&&c===!0&&r.animate!==!1}else{let c=o.station!==void 0?l?.valve:a?.valve;o.mesh.rotation.z=c==null?0:c/100*Math.PI/2,o.mesh.material.color.set(c==null?9015450:a?.cooling?5290239:9357674)}}}return t}dispose(){this.connections.dispose();for(let e of this.views.values())this.remove(e);this.views.clear(),this.scene.remove(this.group)}};var AP=Math.PI/180;function EP(){let i=document.createElement("canvas");i.width=i.height=64;let e=i.getContext("2d"),t=e.createRadialGradient(32,32,4,32,32,32);return t.addColorStop(0,"rgba(255,255,255,0.9)"),t.addColorStop(.5,"rgba(255,255,255,0.35)"),t.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=t,e.fillRect(0,0,64,64),new zt(i)}var ef=class{group=new et;scene;lift;glowTex=EP();views=new Map;onChange=null;constructor(e,t){this.scene=e,this.lift=t,this.group.name="live-screens",e.add(this.group)}get active(){return[...this.views.values()].some(e=>e.s.playing)}set(e){let t=new Set(e.map(n=>n.id));for(let[n,r]of this.views)t.has(n)||this.drop(n,r);for(let n of e){let r=this.views.get(n.id);if(!r){let o=document.createElement("canvas");o.width=512,o.height=288;let a=new zt(o);a.colorSpace=dt;let l=new Se(new sn(1,1),new Ye({map:a,transparent:!0,toneMapped:!1}));l.renderOrder=6;let c=new Se(new sn(1,1),new Ye({map:this.glowTex,transparent:!0,depthWrite:!1,blending:Ft,side:ht}));c.renderOrder=2,this.group.add(l,c),r={s:n,sig:"",screen:l,glow:c,canvas:o,texture:a,image:null},this.views.set(n.id,r)}r.s=n;let s=[n.title,n.subtitle,n.app,n.picture,n.color.join(","),n.playing].join("|");if(s!==r.sig){let o=r.sig.split("|")[3]!==(n.picture??"");r.sig=s,o&&this.loadPicture(r),this.draw(r)}this.place(r)}}loadPicture(e){e.image=null;let t=e.s.picture;if(!t)return;let n=new Image;n.crossOrigin="anonymous",n.onload=()=>{e.s.picture!==t||!this.views.has(e.s.id)||(e.image=n,this.draw(e),this.onChange?.())},n.src=t}draw(e){let t=e.s,n=e.canvas.getContext("2d"),r=e.canvas.width,s=e.canvas.height,[o,a,l]=t.color,c=n.createLinearGradient(0,0,r,s);c.addColorStop(0,`rgb(${Math.round(o*.35)},${Math.round(a*.35)},${Math.round(l*.35)})`),c.addColorStop(1,"rgb(6,9,18)"),n.fillStyle=c,n.fillRect(0,0,r,s);let u=22,h=u;if(e.image){let f=s-u*2-30;n.save(),n.shadowColor=`rgba(${o},${a},${l},0.7)`,n.shadowBlur=24;let d=e.image.naturalWidth||1,p=e.image.naturalHeight||1,x=Math.max(f/d,f/p),m=f/x,g=f/x;n.drawImage(e.image,(d-m)/2,(p-g)/2,m,g,u,u,f,f),n.restore(),h=u*2+f}n.fillStyle="#ffffff",n.font="600 34px Figtree, Roboto, sans-serif",this.text(n,t.title||t.app||"",h,s/2-18,r-h-u),n.fillStyle="rgba(230,240,255,0.75)",n.font="26px Figtree, Roboto, sans-serif",this.text(n,t.subtitle,h,s/2+22,r-h-u),t.app&&(n.fillStyle=`rgb(${o},${a},${l})`,n.font="700 22px Figtree, Roboto, sans-serif",this.text(n,(t.playing?"\u25B6 ":"\u275A\u275A ")+t.app,h,s-u-14,r-h-u)),n.fillStyle=`rgba(${o},${a},${l},0.9)`,n.fillRect(0,s-6,r*(t.playing?1:.4),6),e.texture.needsUpdate=!0}text(e,t,n,r,s){let o=t;for(;o.length>1&&e.measureText(o).width>s;)o=o.slice(0,-2);e.fillText(o===t?o:`${o}\u2026`,n,r)}place(e){let t=e.s,n=t.rect,r=t.rotation*AP,s=this.lift(t.floorId),o=(n.x0+n.x1)/2,a=(p,x)=>[t.x+p*Math.cos(r)-x*Math.sin(r),t.z+p*Math.sin(r)+x*Math.cos(r)],l=n.x1-n.x0,c=n.y1-n.y0,[u,h]=a(o,n.z+.012);e.screen.position.set(u,s.y+(n.y0+n.y1)/2,h),e.screen.rotation.set(0,-r,0),e.screen.scale.set(l,c,1);let[f,d]=a(o,n.z-.18);e.glow.position.set(f,s.y+(n.y0+n.y1)/2,d),e.glow.rotation.set(0,-r,0),e.glow.scale.set(l*2.4,c*2.6,1),e.glow.material.color=new W(t.color[0]/255,t.color[1]/255,t.color[2]/255),e.screen.visible=s.visible,e.glow.visible=s.visible&&(t.ambilight??1)>0}step(e){let t=!1;for(let n of this.views.values()){this.place(n);let r=n.glow.material;r.opacity=(n.s.playing?.55+.25*Math.sin(e/900+n.s.x):.25)*Math.min(1.5,n.s.ambilight??1),t||=n.s.playing}return t}drop(e,t){this.group.remove(t.screen,t.glow),t.screen.geometry.dispose(),t.screen.material.dispose(),t.texture.dispose(),t.glow.geometry.dispose(),t.glow.material.dispose(),this.views.delete(e)}dispose(){for(let[e,t]of this.views)this.drop(e,t);this.glowTex.dispose(),this.scene.remove(this.group)}};var RP=Math.PI/180,CP="#f4f1ea",tf=class{group=new et;scene;lift;views=new Map;onChange=null;constructor(e,t){this.scene=e,this.lift=t,this.group.name="live-pictures",e.add(this.group)}set(e){let t=new Set(e.map(n=>n.id));for(let[n,r]of this.views)t.has(n)||this.drop(n,r);for(let n of e){let r=this.views.get(n.id);if(!r){let c=document.createElement("canvas"),u=new zt(c);u.colorSpace=dt;let h=new Se(new sn(1,1),new Ye({map:u,toneMapped:!1}));h.renderOrder=5,this.group.add(h),r={p:n,sig:"",mesh:h,canvas:c,texture:u,image:null},this.views.set(n.id,r)}let s=r.p.url!==n.url||!r.sig;r.p=n;let o=n.rect.x1-n.rect.x0,a=n.rect.y1-n.rect.y0,l=[n.url,n.border,n.fit,o.toFixed(3),a.toFixed(3)].join("|");l!==r.sig&&(r.sig=l,s&&this.load(r),this.draw(r)),this.place(r)}}load(e){e.image=null;let t=e.p.url,n=new Image;n.crossOrigin="anonymous",n.onload=()=>{e.p.url!==t||!this.views.has(e.p.id)||(e.image=n,this.draw(e),this.onChange?.())},n.src=t}draw(e){let t=e.p,n=Math.max(.01,t.rect.x1-t.rect.x0),r=Math.max(.01,t.rect.y1-t.rect.y0),s=600/Math.max(n,r),o=e.canvas.width=Math.max(16,Math.round(n*s)),a=e.canvas.height=Math.max(16,Math.round(r*s)),l=e.canvas.getContext("2d");l.fillStyle=t.border>0?CP:"#20242c",l.fillRect(0,0,o,a);let c=Math.round(Math.min(o,a)*Math.min(40,Math.max(0,t.border))/100),[u,h,f,d]=[c,c,o-2*c,a-2*c];if(e.image&&f>4&&d>4){let p=e.image.naturalWidth||1,x=e.image.naturalHeight||1;if(t.fit==="contain"){let m=Math.min(f/p,d/x);l.drawImage(e.image,u+(f-p*m)/2,h+(d-x*m)/2,p*m,x*m)}else{let m=Math.max(f/p,d/x),g=f/m,y=d/m;l.drawImage(e.image,(p-g)/2,(x-y)/2,g,y,u,h,f,d)}c>0&&(l.strokeStyle="rgba(0,0,0,0.25)",l.lineWidth=Math.max(1,c*.04),l.strokeRect(u,h,f,d))}else f>4&&d>4&&(l.fillStyle="#3a4250",l.fillRect(u,h,f,d));e.texture.needsUpdate=!0}place(e){let t=e.p,n=t.rect,r=t.rotation*RP,s=this.lift(t.floorId),o=(n.x0+n.x1)/2,a=n.z+.004;e.mesh.position.set(t.x+o*Math.cos(r)-a*Math.sin(r),s.y+(n.y0+n.y1)/2,t.z+o*Math.sin(r)+a*Math.cos(r)),e.mesh.rotation.set(0,-r,0),e.mesh.scale.set(n.x1-n.x0,n.y1-n.y0,1),e.mesh.visible=s.visible}step(){for(let e of this.views.values())this.place(e);return!1}drop(e,t){this.group.remove(t.mesh),t.mesh.geometry.dispose(),t.mesh.material.dispose(),t.texture.dispose(),this.views.delete(e)}dispose(){for(let[e,t]of this.views)this.drop(e,t);this.scene.remove(this.group)}};var nf=class extends An{constructor(){super(),this.name="RoomEnvironment",this.position.y=-3.5;let e=new Mi;e.deleteAttribute("uv");let t=new Ln({side:un}),n=new Ln,r=new gs(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let s=new Se(e,t);s.position.set(-.757,13.219,.717),s.scale.set(31.713,28.305,28.591),this.add(s);let o=new fs(e,n,6),a=new Et;a.position.set(-10.906,2.009,1.846),a.rotation.set(0,-.195,0),a.scale.set(2.328,7.905,4.651),a.updateMatrix(),o.setMatrixAt(0,a.matrix),a.position.set(-5.607,-.754,-.758),a.rotation.set(0,.994,0),a.scale.set(1.97,1.534,3.955),a.updateMatrix(),o.setMatrixAt(1,a.matrix),a.position.set(6.167,.857,7.803),a.rotation.set(0,.561,0),a.scale.set(3.927,6.285,3.687),a.updateMatrix(),o.setMatrixAt(2,a.matrix),a.position.set(-2.017,.018,6.124),a.rotation.set(0,.333,0),a.scale.set(2.002,4.566,2.064),a.updateMatrix(),o.setMatrixAt(3,a.matrix),a.position.set(2.291,-.756,-2.621),a.rotation.set(0,-.286,0),a.scale.set(1.546,1.552,1.496),a.updateMatrix(),o.setMatrixAt(4,a.matrix),a.position.set(-2.193,-.369,-5.547),a.rotation.set(0,.516,0),a.scale.set(3.875,3.487,2.986),a.updateMatrix(),o.setMatrixAt(5,a.matrix),this.add(o);let l=new Se(e,$o(50));l.position.set(-16.116,14.37,8.208),l.scale.set(.1,2.428,2.739),this.add(l);let c=new Se(e,$o(50));c.position.set(-16.109,18.021,-8.207),c.scale.set(.1,2.425,2.751),this.add(c);let u=new Se(e,$o(17));u.position.set(14.904,12.198,-1.832),u.scale.set(.15,4.265,6.331),this.add(u);let h=new Se(e,$o(43));h.position.set(-.462,8.89,14.52),h.scale.set(4.38,5.441,.088),this.add(h);let f=new Se(e,$o(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,.1),this.add(f);let d=new Se(e,$o(100));d.position.set(0,20,0),d.scale.set(1,.1,1),this.add(d)}dispose(){let e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function $o(i){return new Da({color:0,emissive:16777215,emissiveIntensity:i})}function Sm(i,e){if(e===yd)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===Ao||e===Qa){let t=i.getIndex();if(t===null){let s=[],o=i.getAttribute("position");if(o!==void 0){for(let a=0;ao&&(L+=k,U+=X,C+=V)}let I=1/(Math.sqrt(L*L+U*U+C*C)||1);_[3*T+0]=L*I,_[3*T+1]=U*I,_[3*T+2]=C*I}}return t.setAttribute("normal",new wt(_,3,!1)),t}function WM(i){let e=new Map,t=new Map,n=i.clone();return XM(i,n,function(r,s){e.set(s,r),t.set(r,s)}),n.traverse(function(r){if(!r.isSkinnedMesh)return;let s=r,o=e.get(r),a=o.skeleton.bones;s.skeleton=o.skeleton.clone(),s.bindMatrix.copy(o.bindMatrix),s.skeleton.bones=a.map(function(l){return t.get(l)}),s.bind(s.skeleton,s.bindMatrix)}),n}function XM(i,e,t){t(i,e);for(let n=0;n=2.0 are supported."));return}let c=new jm(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,priority:this.priority,cache:this.cache,withCredentials:this.withCredentials,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,s){n.parse(e,t,r,s)})}};function PP(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}function Ut(i,e,t){let n=i.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}var rt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DIFFUSE_ROUGHNESS:"KHR_materials_diffuse_roughness",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},Em=class{constructor(e){this.parser=e,this.name=rt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}},Gm=class{constructor(e){this.parser=e,this.name=rt.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=r.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}},Hm=class{constructor(e){this.parser=e,this.name=rt.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=r.images[o.source],l=n.textureLoader;if(a.uri){let c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}},rf=class{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let r=n.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){let l=r.byteOffset||0,c=r.byteLength||0,u=r.count,h=r.byteStride,f=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,h,f,r.mode,r.filter).then(function(d){return d.buffer}):o.ready.then(function(){let d=new ArrayBuffer(u*h);return o.decodeGltfBuffer(new Uint8Array(d),u,h,f,r.mode,r.filter),d})})}else return null}},Wm=class{constructor(e){this.name=rt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let c of r.primitives)if(c.mode!==ni.TRIANGLES&&c.mode!==ni.TRIANGLE_STRIP&&c.mode!==ni.TRIANGLE_FAN&&c.mode!==void 0)return null;let o=n.extensions[this.name].attributes,a=[],l={};for(let c in o)a.push(this.parser.getDependency("accessor",o[c]).then(u=>(l[c]=u,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{let u=c.pop(),h=u.isGroup?u.children:[u],f=c[0].count,d=[];for(let p of h){let x=new ze,m=new D,g=new wn,y=new D(1,1,1),_=new fs(p.geometry,p.material,f);for(let M=0;M0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":i.search(/\.ktx2($|\?)/i)>0||i.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var UP=new ze,jm=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new PP,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,s=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let l=a.match(/Version\/(\d+)/);r=n&&l?parseInt(l[1],10):-1,s=a.indexOf("Firefox")>-1,o=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&r<17||s&&o<98?(this.textureLoader=new Ba(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)):(this.textureLoader=new Ha(this.options.manager),this.textureLoader.setPriority(this.options.priority),this.textureLoader.setCache(this.options.cache)),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setWithCredentials(this.options.withCredentials),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new bo(this.options.manager),this.fileLoader.setPriority(this.options.priority),this.fileLoader.setCache(this.options.cache),this.fileLoader.setResponseType("arraybuffer"),(this.options.withCredentials||this.options.crossOrigin==="use-credentials")&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){let a={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:n,userData:{}};return Vs(s,a,r),Bi(a,r),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(let l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,s=t.length;r{let l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(let[c,u]of o.children.entries())s(u,a.children[c])};return s(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&m.setY(P,S[v*l+1]),l>=3&&m.setZ(P,S[v*l+2]),l>=4&&m.setW(P,S[v*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=p}return m})}loadTexture(e){let t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s],a=this.textureLoader;if(o.uri){let l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){let r=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];let c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);let f=(s.samplers||{})[o.sampler]||{};return u.magFilter=qM[f.magFilter]||Ht,u.minFilter=qM[f.minFilter]||Nn,u.wrapS=$M[f.wrapS]||zn,u.wrapT=$M[f.wrapT]||zn,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==kt&&u.minFilter!==Ht,r.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){let n=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());let o=r.images[e],a=self.URL||self.webkitURL,l=o.uri||"",c=!1,u;if(t.isKTX2Loader===!0&&o.bufferView!==void 0)u=n.getDependency("bufferView",o.bufferView).then(function(f){return new Promise(function(d,p){t.parse(f,d,p)})});else{if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(f){c=!0;let d=new Blob([f],{type:o.mimeType});return l=a.createObjectURL(d),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");u=Promise.resolve(l).then(function(f){return new Promise(function(d,p){let x=d;t.isImageBitmapLoader===!0&&(x=function(m){let g=new Kt(m);g.needsUpdate=!0,d(g)}),t.load(cr.resolveURL(f,s.path),x,void 0,p)})})}let h=u.then(function(f){return c===!0&&a.revokeObjectURL(l),Bi(f,o),f.userData.mimeType=o.mimeType||kP(o.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),f});return this.sourceCache[e]=h,h}assignTexture(e,t,n,r){let s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[rt.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[rt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let l=s.associations.get(o);o=s.extensions[rt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new cn,gn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,l=this.cache.get(a);l||(l=new Lt,gn.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(r||s||o){let a="ClonedMaterial:"+n.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return Ln}loadMaterial(e){let t=this,n=this.json,r=this.extensions,s=n.materials[e],o,a={},l=s.extensions||{},c=[];if(l[rt.KHR_MATERIALS_UNLIT]){let h=r[rt.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),c.push(h.extendParams(a,s,t))}else{let h=s.pbrMetallicRoughness||{};if(a.color=new W(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){let f=h.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],Sn),a.opacity=f[3]}h.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",h.baseColorTexture,dt)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=ht);let u=s.alphaMode||Tm.OPAQUE;if(u===Tm.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===Tm.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==Ye&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new ke(1,1),s.normalTexture.scale!==void 0)){let h=s.normalTexture.scale;a.normalScale.set(h,h)}if(s.occlusionTexture!==void 0&&o!==Ye&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==Ye){let h=s.emissiveFactor;a.emissive=new W().setRGB(h[0],h[1],h[2],Sn)}return s.emissiveTexture!==void 0&&o!==Ye&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,dt)),Promise.all(c).then(function(){let h=new o(a);return s.name&&(h.name=s.name),Bi(h,s),t.associations.set(h,{materials:e}),s.extensions&&Vs(r,h,s),h})}createUniqueName(e){let t=gt.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function s(a){return n[rt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return KM(l,a,t)})}let o=[];for(let a=0,l=e.length;aSm(d,Qa)):c.mode===ni.TRIANGLE_FAN&&(f=f.then(d=>Sm(d,Ao))),r[u]={primitive:c,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(e){let t=this,n=this.json,r=this.extensions,s=n.meshes[e],o=s.primitives,a=[];for(let l=0,c=o.length;l0&&OP(g,s),g.name=t.createUniqueName(s.name||"mesh_"+e),Bi(g,s),m.extensions&&Vs(r,g,m),t.assignFinalMaterial(g),h.push(g)}for(let d=0,p=h.length;d0){let d=u.userData.pivot,p=h[0];u.pivot=new D().fromArray(d),u.position.x-=d[0],u.position.y-=d[1],u.position.z-=d[2],p.position.set(0,0,0),delete u.userData.pivot}return u})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let s=t.nodes[e],o=s.name?r.createUniqueName(s.name):"",a=[],l=r._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),s.camera!==void 0&&a.push(r.getDependency("camera",s.camera).then(function(c){return r._getNodeRef(r.cameraCache,s.camera,c)})),r._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let u;if(s.isBone===!0?u=new go:c.length>1?u=new et:c.length===1?u=c[0]:u=new Et,u!==c[0])for(let h=0,f=c.length;h1){let h=r.associations.get(u);r.associations.set(u,{...h})}return r.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,s=new et;n.name&&(s.name=r.createUniqueName(n.name)),Bi(s,n),n.extensions&&Vs(t,s,n);let o=n.nodes||[],a=[];for(let l=0,c=o.length;l{let h=new Map;for(let[f,d]of r.associations)(f instanceof gn||f instanceof Kt)&&h.set(f,d);return u.traverse(f=>{let d=r.associations.get(f);d!=null&&h.set(f,d)}),h};return r.associations=c(s),s})}_createAnimationTracks(e,t,n,r,s){let o=[],a=e.name?e.name:e.uuid,l=[];function c(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}qr[s.path]===qr.weights?(c(e),e.isGroup&&e.children.forEach(c)):l.push(a);let u;switch(qr[s.path]){case qr.weights:u=sr;break;case qr.rotation:u=or;break;case qr.translation:case qr.scale:u=Dr;break;default:n.itemSize===1?u=sr:u=Dr;break}let h=r.interpolation!==void 0?LP[r.interpolation]:ji,f=this._getArrayFromAccessor(n);for(let d=0,p=l.length;d{let t=e;if(!t.isMesh)return;let n=t.geometry,r=t.material,s=r.name??"";t.userData.paint=!!r.userData?.paint||/^Paint/.test(s),n.getAttribute("normal")||(t.userData.paint?n.computeVertexNormals():t.geometry=HM(n,zP)),r.flatShading=!1;let o=/glass/i.test(s);r.metalness=t.userData.paint?.55:o?0:Math.min(r.metalness??0,.4),r.roughness=t.userData.paint?.28:o?.05:Math.max(r.roughness??.6,.45),o&&(r.transparent=!0,r.depthWrite=!1,r.opacity=Math.max(r.opacity,.9))})}function QM(i){let e=JM.get(i);if(!e){let t=Y0();if(!t)return Promise.resolve(!1);e=t(i).then(n=>n&&new Promise(r=>{new Zo().parse(n,"",s=>{VP(s.scene);let o=new Ct().setFromObject(s.scene),a=[o.max.x-o.min.x,o.max.y-o.min.y,o.max.z-o.min.z];s.scene.position.set(-(o.max.x+o.min.x)/2,-o.min.y,-(o.max.z+o.min.z)/2);let l=new et;l.add(s.scene),jM.set(i,{root:l,size:a}),q0(i),r({root:l,size:a})},()=>r(null))})).catch(()=>null),JM.set(i,e)}return e.then(t=>!!t)}function e1(i,e){let t=jM.get(i);if(!t)return null;let n=t.root.clone(!0),r=[];n.traverse(o=>{let a=o;if(!a.isMesh)return;let l=a.material.clone();a.userData.paint&&e.paint&&(l.color=new W(e.paint)),a.material=l,r.push(l)});let s=new et;return s.add(n),s.scale.set((e.mirror?-1:1)*(e.w/t.size[0]),e.h/t.size[1],e.d/t.size[2]),s.position.set(e.x,e.y,e.z),s.rotation.y=-e.rotation*Math.PI/180,s.userData.own=r,s}function Qm(i){for(let e of i.userData.own??[])e.dispose()}function t1(i,e){let t=new Ro(e),n=t.fromScene(new nf,.04).texture;t.dispose();let r=new ms(16777215,9081766,.9),s=new lr(16777215,1.6);return s.position.set(-4,9,6),i.add(r,s),{env:n,dispose:()=>{n.dispose(),r.removeFromParent(),s.removeFromParent()}}}function n1(i,e){for(let t of i.userData.own??[])t.envMap=e,t.envMapIntensity=.9}var GP=.3,i1=2.6,of=.05;function HP(i,e,t,n){let r=n*.7071,s=[i,[i[0]+n,i[1]],[i[0]-n,i[1]],[i[0],i[1]+n],[i[0],i[1]-n]],o=[[i[0]+r,i[1]+r],[i[0]-r,i[1]+r],[i[0]+r,i[1]-r],[i[0]-r,i[1]-r]];return s.every(a=>Ge(a,e))&&!t.some(a=>[...s,...o].some(l=>Ge(l,a)))}function r1(i,e,t){let n=Math.ceil(Math.hypot(e[0]-i[0],e[1]-i[1])/of);for(let r=1;rt+1e-6)&&r!==null){let a=o?s:s-of;(!n||a-r>n[1]-n[0])&&(n=[r,a]),r=null}}return n}function s1(i,e=.32,t=.22,n=[]){let r=i.map(_=>_[0]),s=i.map(_=>_[1]),[o,a,l,c]=[Math.min(...r),Math.max(...r),Math.min(...s),Math.max(...s)],u=c-l>=a-o,h=_=>HP(_,i,n,t),f=(_,b)=>u?[_,b]:[b,_],[d,p,x,m]=u?[o,a,l,c]:[l,c,o,a],g=[],y=!0;for(let _=d+t;_<=p-t+1e-6;_+=e){let b=WP(w=>h(f(_,w)),x,m);if(!b||b[1]-b[0]<.2)continue;let M=w=>w?[f(_,b[0]),f(_,b[1])]:[f(_,b[1]),f(_,b[0])],S=M(y),v=g[g.length-1];if(v&&n.length>0&&!r1(v,S[0],h)){let w=M(!y);if(!r1(v,w[0],h))continue;S=w,y=!y}g.push(...S),y=!y}return g}function t0(i,e=.7,t=12){return Array.from({length:t},(n,r)=>[i[0]+Math.cos(r/t*Math.PI*2)*e,i[1]+Math.sin(r/t*Math.PI*2)*e])}var e0=i=>Math.atan2(Math.sin(i),Math.cos(i));function o1(i,e,t){let n;if(e.mode==="cleaning"){if(i.path.length===0)return!1;n=i.path[i.next%i.path.length]}else if(e.mode==="returning"||e.mode==="docked")n=e.rest;else return!1;let[r,s]=[n[0]-i.pos[0],n[1]-i.pos[1]],o=Math.hypot(r,s);if(o<.02){if(e.mode==="cleaning")return i.next=(i.next+1)%i.path.length,!0;let l=e0(e.restHeading-i.heading);return Math.abs(l)<.02?!1:(i.heading+=Math.sign(l)*Math.min(Math.abs(l),i1*t),!0)}let a=e0(Math.atan2(r,s)-i.heading);if(i.heading=e0(i.heading+Math.sign(a)*Math.min(Math.abs(a),i1*t)),Math.abs(a)<.35){let l=Math.min(o,GP*t);i.pos=[i.pos[0]+r/o*l,i.pos[1]+s/o*l]}return!0}var af=600*1e3,XP=3e3;function a1(i,e){if(i==null)return 1;let t=e-i;return t>af?Math.max(0,1-(t-af)/XP):1}function n0(i,e,t){let n=e/2,r=[],s=(a,l,c)=>r.push(a[0],t,a[1],l[0],t,l[1],c[0],t,c[1]);for(let a of i){for(let c=0;c+14?o=i.array[r*i.itemSize+s]:(s===0?o=i.getX(r):s===1?o=i.getY(r):s===2?o=i.getZ(r):s===3&&(o=i.getW(r)),i.normalized===!0&&(o=zr.normalize(o,i.array))),n.min[s]=Math.min(n.min[s],o),n.max[s]=Math.max(n.max[s],o)}return n}function d1(i){return Math.ceil(i/4)*4}function r0(i,e=0){let t=d1(i.byteLength);if(t!==i.byteLength){let n=new Uint8Array(t);if(n.set(new Uint8Array(i)),e!==0)for(let r=i.byteLength;r"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function eI(i,e){if(typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas){let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),i.convertToBlob({type:e,quality:t})}else return new Promise(t=>i.toBlob(t,e))}var o0=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r187"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map,normalMaps:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1,copyright:null},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);let r=this,s=r.buffers,o=r.json;n=r.options;let a=r.extensionsUsed,l=r.extensionsRequired,c=new Blob(s,{type:"application/octet-stream"}),u=Object.keys(a),h=Object.keys(l);if(u.length>0&&(o.extensionsUsed=u),h.length>0&&(o.extensionsRequired=h),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=c.size),n.copyright&&(o.asset.copyright=n.copyright),n.binary===!0){let f=new FileReader;f.readAsArrayBuffer(c),f.onloadend=function(){let d=r0(f.result),p=new DataView(new ArrayBuffer(f1));p.setUint32(0,d.byteLength,!0),p.setUint32(4,ZP,!0);let x=r0(JP(JSON.stringify(o)),32),m=new DataView(new ArrayBuffer(f1));m.setUint32(0,x.byteLength,!0),m.setUint32(4,KP,!0);let g=new ArrayBuffer(h1),y=new DataView(g);y.setUint32(0,qP,!0),y.setUint32(4,$P,!0);let _=h1+m.byteLength+x.byteLength+p.byteLength+d.byteLength;y.setUint32(8,_,!0);let b=new Blob([g,m,x,p,d],{type:"application/octet-stream"}),M=new FileReader;M.readAsArrayBuffer(b),M.onloadend=function(){t(M.result)}}}else if(o.buffers&&o.buffers.length>0){let f=new FileReader;f.readAsDataURL(c),f.onloadend=function(){let d=f.result;o.buffers[0].uri=d,t(o)}}else t(o)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;let n=this.options,r=this.extensionsUsed;try{let s=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&s.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let o in s.gltfExtensions)t.extensions[o]=s.gltfExtensions[o],r[o]=!0;delete s.gltfExtensions}Object.keys(s).length>0&&(t.extras=s)}catch(s){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+s.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){let r=new Map;r.set(!0,this.uid++),r.set(!1,this.uid++),this.uids.set(e,r)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let n=new D;for(let r=0,s=e.count;r5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let n=e.clone(),r=new D;for(let s=0,o=n.count;s4?m=e.array[p*e.itemSize+x]:(x===0?m=e.getX(p):x===1?m=e.getY(p):x===2?m=e.getZ(p):x===3&&(m=e.getW(p)),e.normalized===!0&&(m=zr.normalize(m,e.array))),t===ot.FLOAT?u.setFloat32(h,m,!0):t===ot.INT?u.setInt32(h,m,!0):t===ot.UNSIGNED_INT?u.setUint32(h,m,!0):t===ot.SHORT?u.setInt16(h,m,!0):t===ot.UNSIGNED_SHORT?u.setUint16(h,m,!0):t===ot.BYTE?u.setInt8(h,m):t===ot.UNSIGNED_BYTE&&u.setUint8(h,m),h+=a}h%l!==0&&(h+=l-h%l)}let f={buffer:this.processBuffer(u.buffer),byteOffset:this.byteOffset,byteLength:c};return s!==void 0&&(f.target=s),s===ot.ARRAY_BUFFER&&(f.byteStride=l),this.byteOffset+=c,o.bufferViews.push(f),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(r){let s=new FileReader;s.readAsArrayBuffer(e),s.onloadend=function(){let o=r0(s.result),a={buffer:t.processBuffer(o),byteOffset:t.byteOffset,byteLength:o.byteLength};t.byteOffset+=o.byteLength,r(n.bufferViews.push(a)-1)}})}processAccessor(e,t,n,r){let s=this.json,o={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"},a;if(e.array.constructor===Float32Array)a=ot.FLOAT;else if(e.array.constructor===Int32Array)a=ot.INT;else if(e.array.constructor===Uint32Array)a=ot.UNSIGNED_INT;else if(e.array.constructor===Int16Array)a=ot.SHORT;else if(e.array.constructor===Uint16Array)a=ot.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)a=ot.BYTE;else if(e.array.constructor===Uint8Array)a=ot.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),(r===void 0||r===1/0)&&(r=e.count),r===0)return null;let l=QP(e,n,r),c;t!==void 0&&(c=e===t.index?ot.ELEMENT_ARRAY_BUFFER:ot.ARRAY_BUFFER);let u=this.processBufferView(e,a,n,r,c),h={bufferView:u.id,byteOffset:u.byteOffset,componentType:a,count:r,max:l.max,min:l.min,type:o[e.itemSize]};return e.normalized===!0&&(h.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(h)-1}processImage(e,t,n,r="image/png"){if(e!==null){let s=this,o=s.cache,a=s.json,l=s.options,c=s.pending;o.images.has(e)||o.images.set(e,{});let u=o.images.get(e),h=r+":flipY/"+n.toString();if(u[h]!==void 0)return u[h];a.images||(a.images=[]);let f={mimeType:r},d=s0();d.width=Math.min(e.width,l.maxTextureSize),d.height=Math.min(e.height,l.maxTextureSize);let p=d.getContext("2d",{willReadFrequently:!0});if(n===!0&&(p.translate(0,d.height),p.scale(1,-1)),e.data!==void 0){t!==Dn&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let m=new Uint8ClampedArray(e.height*e.width*4);for(let g=0;gs.processBufferViewImage(m)).then(m=>{f.bufferView=m})):f.uri=fo.getDataURL(d,r);let x=a.images.push(f)-1;return u[h]=x,x}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let n={magFilter:Hn[e.magFilter],minFilter:Hn[e.minFilter],wrapS:Hn[e.wrapS],wrapT:Hn[e.wrapT]};return t.samplers.push(n)-1}async processTextureAsync(e){let n=this.options,r=this.cache,s=this.json;if(r.textures.has(e))return r.textures.get(e);s.textures||(s.textures=[]),e instanceof Or&&(e=await this.decompressTextureAsync(e,n.maxTextureSize));let o=e.userData.mimeType,a=this.processImage(e.image,e.format,e.flipY,o),l={sampler:this.processSampler(e)};o==="image/webp"?(l.extensions=l.extensions||{},l.extensions.EXT_texture_webp={source:a},this.extensionsUsed.EXT_texture_webp=!0,this.extensionsRequired.EXT_texture_webp=!0):l.source=a,e.name&&(l.name=e.name),await this._invokeAllAsync(async function(u){u.writeTexture&&await u.writeTexture(e,l)});let c=s.textures.push(l)-1;return r.textures.set(e,c),c}async processMaterialAsync(e,t){let n=this.cache,r=this.json,s=t!==void 0&&t.hasAttribute("tangent"),o=e.normalMap?e.uuid+":"+s:e.uuid;if(n.materials.has(o))return n.materials.get(o);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;r.materials||(r.materials=[]);let a={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let l=e.color.toArray().concat([e.opacity]);if(vr(l,[1,1,1,1])||(a.pbrMetallicRoughness.baseColorFactor=l),e.isMeshStandardMaterial?(a.pbrMetallicRoughness.metallicFactor=e.metalness,a.pbrMetallicRoughness.roughnessFactor=e.roughness):(a.pbrMetallicRoughness.metallicFactor=0,a.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){let u=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),h={index:await this.processTextureAsync(u),texCoord:u.channel};this.applyTextureTransform(h,u),a.pbrMetallicRoughness.metallicRoughnessTexture=h}if(e.map){let u={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(u,e.map),a.pbrMetallicRoughness.baseColorTexture=u}if(e.emissive){let u=e.emissive;if(Math.max(u.r,u.g,u.b)>0&&(a.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let f={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(f,e.emissiveMap),a.emissiveTexture=f}}if(e.normalMap){let u=e.normalScale,h=u.x<0,f=s?u.y<0:u.y>0,d=e.normalMap;if(h||f){n.normalMaps.has(e.normalMap)===!1&&n.normalMaps.set(e.normalMap,{});let x=n.normalMaps.get(e.normalMap),m=`${h}:${f}`;x[m]===void 0&&(x[m]=await this.buildNormalMapTextureAsync(e.normalMap,h,f)),d=x[m]}let p={index:await this.processTextureAsync(d),texCoord:e.normalMap.channel};Math.abs(u.x)!==1&&(p.scale=Math.abs(u.x)),this.applyTextureTransform(p,e.normalMap),a.normalTexture=p}if(e.aoMap){let u={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(u.strength=e.aoMapIntensity),this.applyTextureTransform(u,e.aoMap),a.occlusionTexture=u}e.transparent?a.alphaMode="BLEND":e.alphaTest>0&&(a.alphaMode="MASK",a.alphaCutoff=e.alphaTest),e.side===ht&&(a.doubleSided=!0),e.name!==""&&(a.name=e.name),this.serializeUserData(e,a),await this._invokeAllAsync(async function(u){u.writeMaterialAsync&&await u.writeMaterialAsync(e,a)});let c=r.materials.push(a)-1;return n.materials.set(o,c),c}async processMeshAsync(e){let t=this.cache,n=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let b=0,M=e.material.length;b0){let b=[],M=[],S={};if(e.morphTargetDictionary!==void 0)for(let v in e.morphTargetDictionary)S[e.morphTargetDictionary[v]]=v;for(let v=0;v0&&(l.extras={},l.extras.targetNames=M)}let x=Array.isArray(e.material);if(x&&o.groups.length===0)return null;let m=!1;if(x&&o.index===null){let b=[];for(let M=0,S=o.attributes.position.count;M0&&(S.targets=h),o.index!==null){let w=this.getUID(o.index);(y[b].start!==void 0||y[b].count!==void 0)&&(w+=":"+y[b].start+":"+y[b].count),t.attributes.has(w)?S.indices=t.attributes.get(w):(S.indices=this.processAccessor(o.index,o,y[b].start,y[b].count),t.attributes.set(w,S.indices)),S.indices===null&&delete S.indices}let v=await this.processMaterialAsync(g[y[b].materialIndex],o);v!==null&&(S.material=v),u.push(S)}m===!0&&o.setIndex(null),l.primitives=u,n.meshes||(n.meshes=[]),await this._invokeAllAsync(function(b){b.writeMesh&&b.writeMesh(e,l)});let _=n.meshes.push(l)-1;return t.meshes.set(s,_),_}detectMeshQuantization(e,t){if(this.extensionsUsed[i0])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");let r=e.split("_",1)[0];c1[r]&&c1[r].includes(n)&&(this.extensionsUsed[i0]=!0,this.extensionsRequired[i0]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let n=e.isOrthographicCamera,r={type:n?"orthographic":"perspective"};return n?r.orthographic={xmag:e.right,ymag:e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:zr.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let n=this.json,r=this.nodeMap;n.animations||(n.animations=[]),e=$r.Utils.mergeMorphTargetTracks(e.clone(),t);let s=e.tracks,o=[],a=[];for(let c=0;c0){let a=[];for(let l=0,c=e.children.length;l0&&(s.children=a)}return await this._invokeAllAsync(function(a){a.writeNode&&a.writeNode(e,s)}),o}async _processNodeWithPivotAsync(e){let t=this.json,n=this.options,r=this.nodeMap,s=e.pivot,o={},a=e.quaternion.toArray(),l=[e.position.x+s.x,e.position.y+s.y,e.position.z+s.z],c=e.scale.toArray();vr(a,[0,0,0,1])||(o.rotation=a),vr(l,[0,0,0])||(o.translation=l),vr(c,[1,1,1])||(o.scale=c),o.extras={pivot:s.toArray()},e.name!==""&&(o.name=String(e.name)),this.serializeUserData(e,o);let u=t.nodes.push(o)-1;r.set(e,u);let h={},f=[-s.x,-s.y,-s.z];if(vr(f,[0,0,0])||(h.translation=f),e.isMesh||e.isLine||e.isPoints){let x=await this.processMeshAsync(e);x!==null&&(h.mesh=x)}else e.isCamera&&(h.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);let p=[t.nodes.push(h)-1];if(e.children.length>0){let x=[];for(let m=0,g=e.children.length;m0&&(h.children=x)}return o.children=p,await this._invokeAllAsync(function(x){x.writeNode&&x.writeNode(e,o)}),u}async processSceneAsync(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};e.name!==""&&(r.name=e.name),t.scenes.push(r);let s=[];for(let o=0,a=e.children.length;o0&&(r.nodes=s),this.serializeUserData(e,r)}async processObjectsAsync(e){let t=new An;t.name="AuxScene";for(let n=0;n0&&await this.processObjectsAsync(n);for(let r=0;r0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(1-e.penumbra)*e.angle,o.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),s[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},s[this.name]=!0);let a=r.extensions[this.name].lights;a.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}},l0=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,t){if(!e.isMeshBasicMaterial)return;let r=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},c0=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;let n=this.writer,r=n.extensionsUsed,s={};if(s.clearcoatFactor=e.clearcoat,e.clearcoatMap){let o={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(o,e.clearcoatMap),s.clearcoatTexture=o}if(s.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let o={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(o,e.clearcoatRoughnessMap),s.clearcoatRoughnessTexture=o}if(e.clearcoatNormalMap){let o={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(o.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(o,e.clearcoatNormalMap),s.clearcoatNormalTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},u0=class{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;let r=this.writer.extensionsUsed,s={};s.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},h0=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;let n=this.writer,r=n.extensionsUsed,s={};if(s.iridescenceFactor=e.iridescence,e.iridescenceMap){let o={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(o,e.iridescenceMap),s.iridescenceTexture=o}if(s.iridescenceIor=e.iridescenceIOR,s.iridescenceThicknessMinimum=e.iridescenceThicknessMinimum,s.iridescenceThicknessMaximum=e.iridescenceThicknessMaximum,e.iridescenceThicknessMap){let o={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(o,e.iridescenceThicknessMap),s.iridescenceThicknessTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},f0=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,s={};if(s.transmissionFactor=e.transmission,e.transmissionMap){let o={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(o,e.transmissionMap),s.transmissionTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},d0=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,s={};if(s.thicknessFactor=e.thickness,e.thicknessMap){let o={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(o,e.thicknessMap),s.thicknessTexture=o}e.attenuationDistance!==1/0&&(s.attenuationDistance=e.attenuationDistance),s.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},p0=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;let r=this.writer.extensionsUsed,s={};s.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},m0=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(YP)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,r=n.extensionsUsed,s={};if(e.specularIntensityMap){let o={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(o,e.specularIntensityMap),s.specularTexture=o}if(e.specularColorMap){let o={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(o,e.specularColorMap),s.specularColorTexture=o}s.specularFactor=e.specularIntensity,s.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},g0=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;let n=this.writer,r=n.extensionsUsed,s={};if(e.sheenRoughnessMap){let o={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(o,e.sheenRoughnessMap),s.sheenRoughnessTexture=o}if(e.sheenColorMap){let o={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(o,e.sheenColorMap),s.sheenColorTexture=o}s.sheenRoughnessFactor=e.sheenRoughness,s.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},x0=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;let n=this.writer,r=n.extensionsUsed,s={};if(e.anisotropyMap){let o={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(o,e.anisotropyMap),s.anisotropyTexture=o}s.anisotropyStrength=e.anisotropy,s.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},y0=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;let r=this.writer.extensionsUsed,s={};s.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},b0=class{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;let n=this.writer,r=n.extensionsUsed,s={};if(e.bumpMap){let o={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(o,e.bumpMap),s.bumpTexture=o}s.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},v0=class{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let n=this.writer,r=e,s=new Float32Array(r.count*3),o=new Float32Array(r.count*4),a=new Float32Array(r.count*3),l=new ze,c=new D,u=new wn,h=new D;for(let d=0;di.times[i.times.length-1]){if(Math.abs(i.times[i.times.length-1]-e)<.001)return i.times.length-1;r[r.length-1]=e,r.set(i.times,0),s.set(i.values,0),s.set(o.evaluate(e),i.values.length),a=r.length-1}else for(let l=0;le){r.set(i.times.slice(0,l+1),0),r[l+1]=e,r.set(i.times.slice(l+1),l+2),s.set(i.values.slice(0,(l+1)*n),0),s.set(o.evaluate(e),(l+1)*n),s.set(i.values.slice((l+1)*n),(l+2)*n),a=l+1;break}}return i.times=r,i.values=s,a},mergeMorphTargetTracks:function(i,e){let t=[],n={},r=i.tracks;for(let s=0;stI.test(r.name)).map(r=>r.name);if(e.length>0)return e;let n=[...i.filter(r=>r.opacity>=.9&&r.lightness>.12&&!/glass|window|light|lamp/i.test(r.name))].sort((r,s)=>s.area-r.area)[0];return n?[n.name]:[]}function m1(i,e){let t=i.reduce((r,s)=>r+s,0);if(t<=e)return[...i];let n=e/t;return i.map(r=>Math.max(1,Math.floor(r*n)))}var g1=i=>/^Paint/.test(i)?i:`Paint_${i||"body"}`;var Jo=i=>i.indices.length/3;function nI(i){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let n=0;nMath.floor(o/t)+1),s=new Float64Array(n);for(let o=0;oe?r=l:(s=l,o=c)}return rI(i,o)}var zi=class extends Error{reason;constructor(e,t){super(t),this.reason=e}},sI=1179937895;function oI(i){if(i.byteLength<20||new DataView(i).getUint32(0,!0)!==sI)throw new zi("not_glb","not a binary glTF (.glb) file")}async function _0(i){return oI(i),new Promise((e,t)=>{new Zo().parse(i,"",n=>e(n.scene),n=>{let r=String(n?.message??n);t(/draco|meshopt|ktx/i.test(r)?new zi("compressed",r):new zi("unreadable",r))})})}var aI=i=>i instanceof Ln?i:Object.assign(new Ln,{color:i.color?.clone()??new W(8947848),name:i.name,opacity:i.opacity,transparent:i.transparent});function b1(i,e){i.updateMatrixWorld(!0);let t=new Map;return i.traverse(n=>{let r=n;if(!r.isMesh)return;let s=r.geometry,o=s.getAttribute("position");if(!o)return;let a=aI(Array.isArray(r.material)?r.material[0]:r.material),l=t.get(a)??{positions:[],indices:[]};t.set(a,l);let c=new ze().multiplyMatrices(e,r.matrixWorld),u=l.positions.length/3,h=new D;for(let p=0;p({material:n,mesh:{positions:Float32Array.from(r.positions),indices:Uint32Array.from(r.indices)}}))}var lI=i=>{let e=0,[t,n,r]=[new D,new D,new D];for(let s=0;s.299*i.r+.587*i.g+.114*i.b;async function uI(i){let e=b1(await _0(i),new ze);if(e.length===0)throw new zi("empty","the file has no 3D parts");let t=new Ct;for(let s of e)t.union(new Ct().setFromArray(s.mesh.positions));let n=t.getSize(new D),r=e.map(s=>({name:s.material.name||"material",area:lI(s.mesh),opacity:s.material.opacity,lightness:cI(s.material.color)}));return{triangles:e.reduce((s,o)=>s+Jo(o.mesh),0),size:[n.x,n.y,n.z],materials:r,paint:p1(r)}}async function hI(i,e){let t=new ze().makeRotationY(e.turns*Math.PI/2),n=b1(await _0(i),t);if(n.length===0)throw new zi("empty","the file has no 3D parts");let r=m1(n.map(l=>Jo(l.mesh)),e.maxTriangles),s=new An,o=0;return n.forEach((l,c)=>{let u=y1(l.mesh,r[c]);if(Jo(u)===0)return;o+=Jo(u);let h=new Pe;h.setAttribute("position",new wt(u.positions,3)),h.setIndex(new wt(u.indices,1));let f=l.material.name||"material",d=e.paint.includes(f),p=new Ln({color:l.material.color.clone(),name:d?g1(f):f,metalness:l.material.metalness,roughness:l.material.roughness,opacity:l.material.opacity,transparent:l.material.opacity<1});d&&(p.userData.paint=!0),s.add(new Se(h,p))}),{glb:await new Promise((l,c)=>{new $r().parse(s,u=>u instanceof ArrayBuffer?l(u):c(new zi("unreadable","export gave no binary")),u=>c(new zi("unreadable",String(u))),{binary:!0})}),triangles:o}}async function fI(i,e,t=220){let n=await _0(i),r=new Ct().setFromObject(n),s=r.getCenter(new D),o=r.getSize(new D);n.traverse(d=>{let p=d;if(!p.isMesh)return;let x=p.material;(x.userData?.paint||/^Paint/.test(x.name))&&x.color.set(e),x.metalness=Math.min(x.metalness??0,.5)});let a=new An,l=new lr(16777215,1.6);l.position.set(-4,9,6),a.add(n,new Ga(16777215,.5),new ms(16777215,6713480,1.1),l);let c=Math.max(o.x,o.y,o.z)*.75,u=new Vn(-c,c,c,-c,.01,100);u.position.copy(s).add(new D(.9,.7,1.2).normalize().multiplyScalar(20)),u.lookAt(s);let h=new Vr({alpha:!0,antialias:!0,preserveDrawingBuffer:!0});h.setSize(t,t,!1),h.render(a,u);let f=h.domElement.toDataURL("image/png");return h.dispose(),a.traverse(d=>{let p=d;p.isMesh&&p.geometry.dispose()}),f}var jo=null,v1=new Map,_1=16758087;function dI(i,e,t){let n=_t(i.type);if(n?.light)ul(e,n,{x:0,z:0,rotation:0,w:i.w,d:i.d,h:i.h},0,_1);else if(i.lamp)M0(e,{x:0,z:0,size:[i.w,i.d,i.h],base:0,rotation:0,variant:i.variant??null,lamp:i.lamp},Math.max(i.h+.15,.6),_1);else{let r={id:"preview",type:i.type,x:0,z:0,rotation:0,w:i.w,d:i.d,h:i.h,variant:i.variant??null,entity:null,power:null};Ll(e,t,new ut,r)}}function pI(i){let e=i.getCenter(new D),t=new Vn(-1,1,1,-1,.01,100);t.position.copy(e).add(new D(.9,.75,1.3).normalize().multiplyScalar(20)),t.lookAt(e),t.updateMatrixWorld();let n=.05;for(let s of[i.min.x,i.max.x])for(let o of[i.min.y,i.max.y])for(let a of[i.min.z,i.max.z]){let l=new D(s,o,a).applyMatrix4(t.matrixWorldInverse);n=Math.max(n,Math.abs(l.x),Math.abs(l.y))}let r=n*1.12;return Object.assign(t,{left:-r,right:r,top:r,bottom:-r}),t.updateProjectionMatrix(),t}function mI(i,e=180,t,n=1.3){let r=[i.type,i.w,i.d,i.h,i.variant??"",e,n].join("|"),s=v1.get(r);if(s)return s;t&&Gl(t),jo??=new Vr({alpha:!0,antialias:!0,preserveDrawingBuffer:!0}),jo.setPixelRatio(Math.min(2,window.devicePixelRatio||1)),jo.setSize(e,e,!1),jo.setClearColor(0,0);let[o,a]=[new ut,new Wt];dI(i,o,a);let l=new Se(o.geometry(),new Ye({vertexColors:!0,color:new W(n,n,n)})),c=new xn(a.geometry(),new Lt({vertexColors:!0,color:new W(n*1.8,n*1.8,n*1.8)})),u=new An;u.add(l,c),jo.render(u,pI(new Ct().setFromObject(l)));let h=jo.domElement.toDataURL("image/png");for(let f of[l,c])f.geometry.dispose(),f.material.dispose();return v1.set(r,h),h}var S1={cleaning:3662079,returning:16758087,docked:4310123,idle:5995775,error:16726863},gI=1.4,w0=32,Je=2767456,w1=4873352,xI=1911110,S0=450,T1=125,yI=1.6,A1=3e4,R1=5,C1=360/R1,bI=new W(1714765),E1=.94;var T0=class{host;options;renderer;scene=new An;camera=new Jt(38,1,.1,400);controls;labels;root=new et;patternTexture;blindTexture;openingTargets=new Map;fridges=new Map;covers=new Map;screens=new Map;pickFurniture=new Map;pickOpenings=new Map;pickOpenings2=new Map;flashes=new Map;surfaceGrab=null;surfaceDragging=!1;furnishTypes=null;roofWindows=new Map;roofWindowsKey="";persons=[];personPins=new Map;floorInfo=new Map;roomInfo=new Map;groundTexture=null;devices=[];devicePins=new Map;ground;floors=[];building=null;furnitureColors=null;notePhoto=null;floorId=null;roomId=null;wallMode="auto";painted=!1;explode;frame=0;lastFrame=0;qualityMode="auto";governor=null;disposed=!1;resizeObserver;fpsFrames=0;worstFrame=0;lastStatsFrame=0;lowQuality=!1;highQuality=!1;effectTime=0;effectTick=!1;tintTick=!1;effectTimer;awakeUntil=0;deviceLook="";haloTexture;roof=null;roofO=0;keepRoof=!1;robots=new Map;pets=new Map;petMat=null;petTimer;robotGeo=null;robotTrails=new Map;trailTimers=new Map;robotMat=null;mowerMat=null;robotLedGeo=null;robotLast=0;petLast=0;meshes=[];meshLight=null;meshAsked=new Set;robotTimer;floorStack="dim";floorMap=new Map;labelsDirty=!0;viewKey=new Float64Array(6);pinMode=new WeakMap;size={w:1,h:1};labelInset=0;effectFloors=new Set;deviceFloor=new Map;statsOn=!1;parked=new Map;parkedSig="";plain=!1;rightBack=!1;rightDown=null;gateOpen=new Map;gateSig="";orbitSpeed=0;orbitLast=0;orbitTimer;onScreen=!0;intersection=null;swipe=null;furnish=!1;selectedFurniture=null;selectedDevice=null;pendingDevice=null;labelPlacer=new $u;pinHooks={furnishing:()=>this.furnish,pressedWhileFurnishing:e=>this.pendingDevice=e,selectWhileFurnishing:e=>{this.selectDevice(e),this.options.onDeviceSelect?.(e)},centre:e=>{let[t,n]=[e.getBoundingClientRect(),this.host.getBoundingClientRect()];return{x:t.left+t.width/2-n.left,y:t.top+t.height/2-n.top}},tap:(e,t,n)=>{let r=this.tapInRoom?this.devices.find(s=>s.id===e):void 0;if(r&&!this.deviceInReach(r.floorId,r.roomId))return this.options.onRoomTap?.(r.floorId,r.roomId);this.options.onDeviceTap?.(e,t,n)},hold:(e,t,n)=>this.options.onDeviceHold?.(e,t,n)};tapInRoom=!1;deviceGrab=null;grab=null;ghost=null;theme="neon";themeUniform={value:0};sun=null;weatherLayer;houseShadow=new Ju;sunArc=new oh;sunArcLocation=null;shadowKey="";footprint={key:"",rings:[]};mapLayer;mapSettings=null;mapNorth=0;groundY=0;skyView=null;weatherTimer;energyLayer;soundLayer;waterLayer;hydronicLayer;glassAlpha={value:.2};screenLayer;pictureLayer;liveAnchors=[];liveAnchorCb=null;roomTint=null;houseRadius=20;startView=null;fpsStart=0;constructor(e,t={}){this.host=e,this.options=t,this.explode=t.explode??!0,this.qualityMode=t.quality??"auto",this.renderer=this.makeRenderer(this.qualityMode),this.labels=document.createElement("div"),this.labels.className="nf-labels",e.append(this.labels),this.patternTexture=vI(),this.blindTexture=_I(),this.haloTexture=SI(),this.ground=new Se(new sn(1,1),new Ye({transparent:!0,blending:Ft,depthWrite:!1})),this.ground.rotation.x=-Math.PI/2,this.ground.renderOrder=-1,this.scene.add(this.ground,this.root),this.weatherLayer=new Xh(this.scene),this.scene.add(this.houseShadow.mesh),this.scene.add(this.sunArc.group),this.mapLayer=new Vh(this.scene),this.mapLayer.onChange=()=>this.invalidate(),this.energyLayer=new $h(this.scene,this.liftOf),this.soundLayer=new Kh(this.scene,this.liftOf),this.waterLayer=new Jh(this.scene,this.liftOf),this.hydronicLayer=new Qh(this.scene,this.liftOf),this.screenLayer=new ef(this.scene,this.liftOf),this.screenLayer.onChange=()=>this.invalidate(),this.pictureLayer=new tf(this.scene,this.liftOf),this.pictureLayer.onChange=()=>this.invalidate(),this.weatherLayer.onFlash=n=>this.host.classList.toggle("live-flash",n),this.controls=this.makeControls(),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(e),document.addEventListener("visibilitychange",this.onVisibility),this.host.addEventListener("pointerdown",this.onTouch,{passive:!0}),this.renderer.domElement.addEventListener("pointerdown",this.onRightDown),this.renderer.domElement.addEventListener("pointerup",this.onRightUp),this.renderer.domElement.addEventListener("contextmenu",this.onContext),this.awakeUntil=performance.now()+A1,typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(n=>{let r=n.some(s=>s.isIntersecting);r!==this.onScreen&&(this.onScreen=r,r||(clearTimeout(this.effectTimer),this.effectTimer=void 0),r&&this.invalidate())}),this.intersection.observe(e)),this.resize()}get low(){return this.lowQuality}setRightBack(e){this.rightBack=e}onRightDown=e=>{this.rightDown=this.rightBack&&e.button===2?{x:e.clientX,y:e.clientY,at:performance.now()}:null};onRightUp=e=>{let t=this.rightDown;this.rightDown=null,!(!this.rightBack||!t||e.button!==2)&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<6&&performance.now()-t.at<400&&this.options.onBack?.()};onContext=e=>{this.rightBack&&e.preventDefault()};setPlain(e){e!==this.plain&&(this.plain=e,this.building&&(this.rebuild(),this.invalidate()))}exportStl(e=10){let t=[];for(let n of this.floors)for(let r of[n.wallMesh,n.floorMesh]){let s=r.geometry.getAttribute("position");s&&t.push({positions:s.array,lift:n.floor.elevation})}return ev(t,e)}setGateStates(e){let t=[...e].map(([n,r])=>`${n}=${r?1:0}`).sort().join("|");t!==this.gateSig&&(this.gateSig=t,this.gateOpen=e,this.building&&(this.rebuild(),this.invalidate()))}setParked(e){let t=[...e].map(([n,r])=>`${n}=${r}`).sort().join("|");t!==this.parkedSig&&(this.parkedSig=t,this.parked=e,this.building&&(this.rebuild(),this.invalidate()))}setStats(e){this.statsOn=e}setLabelInset(e){this.labelInset!==e&&(this.labelInset=e,this.labelsDirty=!0,this.invalidate())}setAutoOrbit(e){this.orbitSpeed=e,this.orbitLast=0,this.invalidate()}setQuality(e){this.qualityMode=e,this.swapRenderer(e)}dropToLow(){this.disposed||this.lowQuality||this.swapRenderer("low")}swapRenderer(e){let t=this.renderer.domElement,n=this.makeRenderer(e);this.rebuildTier(),this.applyTierFlags(),t.replaceWith(n.domElement),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer=n;let{view:r,locked:s}=this.controls;this.controls.dispose(),this.controls=this.makeControls(),this.controls.view=r,this.controls.locked=s,this.resize()}setMeshSource(e){X0(e)}setPacks(e){Gl(e),this.building&&(this.rebuild(),this.invalidate())}setBuilding(e){let t=this.building===null;this.building=e,this.rebuild(),t&&this.fit(0),this.invalidate()}get walking(){return this.controls.walk!==null}startWalk(){let e=this.floors.filter(l=>l.floor.rooms.some(c=>c.points.length>=3)),t=(this.floorId?this.floorMap.get(this.floorId):void 0)??[...e].sort((l,c)=>Math.abs(l.floor.elevation)-Math.abs(c.floor.elevation))[0];if(!t||!t.bbox)return null;let n=t.floor.rooms.filter(l=>l.points.length>=3),r=n.find(l=>l.id===this.roomId)??[...n].sort((l,c)=>wr(c.points)-wr(l.points))[0],[s,o]=r?Gs(r.points):[(t.bbox.x0+t.bbox.x1)/2,(t.bbox.z0+t.bbox.z1)/2];this.floorId!==t.floor.id&&this.setFloor(t.floor.id,!1);let a=.3;return this.controls.walk={eye:new D(s,t.floor.elevation+t.ty+yI,o),yaw:this.controls.view.theta,pitch:-.05,stick:[0,0],keys:new Set,bounds:{x0:t.bbox.x0-a,x1:t.bbox.x1+a,z0:t.bbox.z0-a,z1:t.bbox.z1+a},last:0},this.labelsDirty=!0,this.wake(),t.floor.id}stopWalk(){this.controls.walk&&(this.controls.walk=null,this.labelsDirty=!0,this.fit(700))}setWalkStick(e,t){this.controls.walk&&(this.controls.walk.stick=[e,t],this.wake())}setFloor(e,t=!0){let n=this.keepCamera&&this.floorId!==null&&e!==null&&e!==this.floorId?{theta:this.controls.view.theta,phi:this.controls.view.phi,radius:this.controls.view.radius}:null;this.floorId=e,this.roomId=null,this.labelsDirty=!0,this.applyTargets(!t),this.applyHighlight(),this.fit(t?700:0,n)}setKeepCamera(e){this.keepCamera=e}setZoom(e){let t=Math.min(3,Math.max(.5,e||1));t!==this.zoom&&(this.zoom=t,this.building&&this.fit(400))}setFloorStack(e){e!==this.floorStack&&(this.floorStack=e,this.applyTargets(!1))}setKeepRoof(e){e!==this.keepRoof&&(this.keepRoof=e,this.invalidate())}setExplode(e){e!==this.explode&&(this.explode=e,this.applyTargets(!1),this.floorId===null&&this.fit(700))}selectRoom(e){if(this.roomId=e,this.labelsDirty=!0,this.applyHighlight(),!e){this.fit(700);return}let t=this.floors.find(u=>u.floor.rooms.some(h=>h.id===e)),n=t?.floor.rooms.find(u=>u.id===e);if(!t||!n)return;let r=n.start_view;if(r){let u=t.floor.elevation+t.ty,[h,f]=Gs(n.points),d=r.target??{x:h,y:.3,z:f};this.controls.flyTo({target:new D(d.x,d.y+u,d.z),radius:r.radius,phi:r.phi,theta:r.theta});return}let[s,o]=Gs(n.points),a=n.points.map(u=>u[0]),l=n.points.map(u=>u[1]),c=new D(Math.max(...a)-Math.min(...a),t.floor.cut_height,Math.max(...l)-Math.min(...l));this.controls.flyTo({target:new D(s,t.floor.elevation+t.ty+.3,o),radius:Math.max(4,this.distanceFor(c)*1.05),phi:.72})}get lowered(){return this.wallMode!=="auto"}setPaintedWalls(e){e!==this.painted&&(this.painted=e,this.rebuild(),this.invalidate())}wallPaint(e){return this.painted&&this.building?dm(this.building.settings,e):void 0}setWallMode(e){this.wallMode=e;for(let t of this.floors)this.buildLamps(t);this.invalidate()}setDevices(e){let t=e.map(r=>`${r.id}:${r.active?1:0}:${r.glow?r.glow.level.toFixed(1):"-"}`).join(";");t!==this.deviceLook&&(this.deviceLook=t,this.wake()),this.devices=e,this.labelsDirty=!0,this.effectFloors=new Set(e.filter(r=>r.effect&&r.glow||(r.spin??0)>0).map(r=>r.floorId)),this.deviceFloor=new Map(e.map(r=>[r.id,r.floorId]));let n=new Set;for(let r of e){n.add(r.id);let s=this.devicePins.get(r.id);s||(s={el:Qb(r.id,this.pinHooks),icon:"",text:"",watt:"",label:"",active:!1,unavailable:!1,glow:"",caption:""},this.devicePins.set(r.id,s),this.labels.append(s.el));let o=s.el;s.icon!==r.icon&&(s.icon=r.icon,o.querySelector(".nf-dev-icon").innerHTML=r.icon),s.text!==r.text&&(s.text=r.text,o.querySelector(".nf-dev-text").textContent=r.text);let a=r.caption??"";s.caption!==a&&(s.caption=a,o.querySelector(".nf-dev-name").textContent=a);let l=r.power!==null&&r.power!==void 0&&r.power>=1?r.powerText??`${Math.round(r.power)} W`:"";s.watt!==l&&(s.watt=l,o.querySelector(".nf-dev-watt").textContent=l);let c=`${r.name}: ${r.text}`;s.label!==c&&(s.label=c,o.title=r.name,o.setAttribute("aria-label",c)),s.active!==r.active&&(s.active=r.active,o.classList.toggle("nf-dev-on",r.active)),s.unavailable!==r.unavailable&&(s.unavailable=r.unavailable,o.classList.toggle("nf-dev-na",r.unavailable));let u=r.glow?`rgb(${r.glow.color.map(h=>Math.round(h*255)).join(", ")})`:"";s.glow!==u&&(s.glow=u,u?o.style.setProperty("--nf-glow",u):o.style.removeProperty("--nf-glow"))}for(let[r,s]of this.devicePins)n.has(r)||(s.el.remove(),this.devicePins.delete(r));for(let r of this.floors)this.buildGlow(r),this.buildLamps(r);this.invalidate()}setRoofWindows(e){let t=JSON.stringify([...e]);t!==this.roofWindowsKey&&(this.roofWindowsKey=t,this.roofWindows=e,this.buildRoofMesh(),this.invalidate())}setPersons(e){this.labelsDirty=!0,this.persons=e;let t=new Set;for(let n of e){t.add(n.id);let r=this.personPins.get(n.id);if(r||(r=document.createElement("div"),r.className="nf-person",r.dataset.entity=n.id,this.personPins.set(n.id,r),this.labels.append(r)),r.title=n.name,r.setAttribute("aria-label",n.name),r.dataset.picture!==(n.picture??"")||r.dataset.initials!==n.initials)if(r.dataset.picture=n.picture??"",r.dataset.initials=n.initials,r.replaceChildren(),n.picture){let s=document.createElement("img");s.src=n.picture,s.alt="",s.addEventListener("error",()=>s.replaceWith(document.createTextNode(n.initials))),r.append(s)}else r.textContent=n.initials}for(let[n,r]of this.personPins)t.has(n)||(r.remove(),this.personPins.delete(n));this.invalidate()}setNavigationLocked(e){this.controls.locked=e}setPickTargets(e,t,n=new Map){this.pickFurniture=e,this.pickOpenings=t,this.pickOpenings2=n}setNotePhotos(e){this.notePhoto=e}setFurnitureColors(e){JSON.stringify(e??{})!==JSON.stringify(this.furnitureColors??{})&&(this.furnitureColors=e,this.building&&(this.rebuild(),this.invalidate()))}setAccent(e){let t=Jb(e),n=t?1:0;n===ih.value&&(!t||nh.value.equals(new D(...t)))||(ih.value=n,t&&nh.value.set(...t),this.invalidate())}setTheme(e){if(e===this.theme)return;this.theme=e,this.placeMap(),this.themeUniform.value=Zb(e);let t=Sl(e),n=[...this.floors.map(r=>r.materials.lines),...this.roof?[this.roof.lines]:[]];for(let r of n)r.blending=t,r.needsUpdate=!0;this.placeGround(),this.invalidate()}setFurnishMode(e){this.furnish=e,e||this.selectFurniture(null),this.invalidate()}selectFurniture(e){e&&this.selectedDevice&&this.selectDevice(null),this.selectedFurniture=e,this.updateGhost(),this.invalidate()}setSun(e){this.sun=e;for(let t of this.floors)this.buildSun(t);this.buildHouseShadow(),this.buildSunArc(),this.invalidate()}setLocation(e){this.sunArcLocation=e,this.buildSunArc(),this.invalidate()}buildSunArc(){let e=this.building,t=this.sunArcLocation,n=(e?.floors??[]).flatMap(c=>[...c.rooms.flatMap(u=>u.points),...(c.outdoor??[]).flatMap(u=>u.points)]);if(!e||!e.settings.sun_arc||!t||!n.length)return void this.sunArc.update(null,null,0);let r=n.map(c=>c[0]),s=n.map(c=>c[1]),o=[(Math.min(...r)+Math.max(...r))/2,(Math.min(...s)+Math.max(...s))/2],a=Math.max(6,Math.hypot(Math.max(...r)-Math.min(...r),Math.max(...s)-Math.min(...s))/2+3),l=Math.min(0,...e.floors.map(c=>c.elevation));this.sunArc.update({centre:o,radius:a,north:e.settings.north??0,...t},this.sun,l)}buildHouseShadow(){if(!this.houseShadow)return;let e=this.building,t=(e?.floors??[]).filter(u=>u.elevation>=-.01&&u.rooms.length),n=!e||!t.length||e.settings.sun_patches===!1||this.lowQuality,r=this.weatherLayer?.cloud??0,s=e?.settings.north??0,o=t.map(u=>`${u.elevation}:${u.height}:${JSON.stringify(u.rooms.map(h=>h.points))}`).join("|"),a=n?"off":`${this.sun?.elevation.toFixed(1)},${this.sun?.azimuth.toFixed(1)},${s},${r.toFixed(2)},${o}`;if(a===this.shadowKey)return;if(this.shadowKey=a,n){this.houseShadow.update([],0,0,null,0,0,!0);return}let l=Math.min(...t.map(u=>u.elevation)),c=Math.max(...t.map(u=>u.elevation+u.height));this.footprint.key!==o&&(this.footprint={key:o,rings:mr(t.flatMap(u=>u.rooms.map(h=>h.points)))}),this.houseShadow.update(this.footprint.rings,c-l,l+.03,this.sun,s,r,!1)}liftOf=e=>{if(!e)return{y:0,dy:0,visible:!0};let t=this.floorMap.get(e);return t?{y:t.floor.elevation+t.y,dy:t.y,visible:t.group.visible}:{y:0,dy:0,visible:!1}};setLiveEnergy(e,t){this.energyLayer.setArcs(e),this.energyLayer.setSparks(t),this.invalidate()}setLiveSound(e,t){this.soundLayer.set(e,t),this.invalidate()}setGlassWalls(e){let t=Math.min(1,Math.max(0,e));t!==this.glassAlpha.value&&(this.glassAlpha.value=t,this.invalidate())}setLiveWater(e){this.waterLayer.set(e),this.invalidate()}setHydronics(e){this.hydronicLayer.set(e),this.invalidate()}setLiveScreens(e){let t=[];for(let n of e){let r=this.building?.floors.find(a=>a.id===n.floorId),s=r?.furniture.find(a=>a.id===n.furnitureId),o=s&&r?_h(s,r):null;!s||!o||t.push({...n,x:s.x,z:s.z,rotation:s.rotation,rect:o})}this.screenLayer.set(t),this.invalidate()}setPictures(e){let t=[];for(let n of e){let r=this.building?.floors.find(a=>a.id===n.floorId),s=r?.furniture.find(a=>a.id===n.furnitureId),o=s&&r?Kp(s,r):null;!s||!o||t.push({id:n.furnitureId,floorId:n.floorId,url:n.url,border:n.border,fit:n.fit,x:s.x,z:s.z,rotation:s.rotation,rect:o})}this.pictureLayer.set(t),this.invalidate()}setLiveAnchors(e,t){this.liveAnchors=e,this.liveAnchorCb=t,this.invalidate()}placeLhAnchors(){let e=this.liveAnchorCb;if(!e||!this.liveAnchors.length)return;let t=new D,n=this.camera.matrixWorldInverse.elements,r=this.size.h*this.camera.projectionMatrix.elements[5]/2;this.liveAnchors.forEach((s,o)=>{let a=this.liftOf(s.floorId);t.set(s.x,a.y+s.y,s.z);let l=-(n[2]*t.x+n[6]*t.y+n[10]*t.z+n[14]);t.project(this.camera);let c=a.visible&&t.z>-1&&t.z<1&&Math.abs(t.x)<1.15&&Math.abs(t.y)<1.15;e(o,(t.x+1)/2*this.size.w,(1-t.y)/2*this.size.h,c,l>0?r/l:0)})}setSky(e){this.skyView=e,this.weatherLayer.set(e?{...e,low:e.low||this.lowQuality}:null),this.buildHouseShadow();for(let t of this.floors)this.buildSun(t);this.invalidate()}setRoomTint(e){let t=!!e!=!!this.roomTint;if(this.roomTint=e,this.tintTick=!0,this.applyHighlight(),t)for(let n of this.floors)n.glowSig="",this.buildGlow(n)}setScreens(e){this.screens=e;for(let t of this.floors)this.buildScreens(t);this.invalidate()}fillRoomPin(e,t,n){if(e.textContent=t||"\u2013",n){let r=document.createElement("small");r.textContent=n,e.append(r),e.classList.add("nf-pin-info")}else e.classList.remove("nf-pin-info")}setRoomInfo(e){if(!(e.size===this.roomInfo.size&&[...e].every(([n,r])=>this.roomInfo.get(n)===r))){this.roomInfo=e;for(let n of this.floors)for(let r of n.roomPins)this.fillRoomPin(r.pin,r.room.name,e.get(r.room.id))}}setFloorInfo(e){this.floorInfo=e;for(let t of this.floors){let n=t.label.querySelector("span"),r=e.get(t.floor.id)??this.options.floorInfo?.(t.floor)??"";n&&n.textContent!==r&&(n.textContent=r,t.labelSize=null,this.labelsDirty=!0)}this.invalidate()}setOpeningStates(e){let t=this.openingTargets;this.openingTargets=e,[...e].some(([n,r])=>!wp(t.get(n)??Us,r))&&this.wake(),this.invalidate()}wake(){this.awakeUntil=performance.now()+A1,this.invalidate()}get resting(){return this.lowQuality&&performance.now()>this.awakeUntil}setFridgeDoors(e){for(let[t,n]of e){let r=this.fridges.get(t)??{l:n.left?1:0,r:n.right?1:0,tl:0,tr:0};r.tl=n.left?1:0,r.tr=n.right?1:0,this.fridges.set(t,r)}for(let t of[...this.fridges.keys()])e.has(t)||this.fridges.delete(t);this.invalidate()}setCovers(e){let t=!1;for(let[n,r]of e){let s=this.covers.get(n);s?s.t!==r&&(s.t=r,t=!0):(this.covers.set(n,{k:r,t:r}),t=!0)}for(let n of[...this.covers.keys()])e.has(n)||this.covers.delete(n);if(t){for(let n of this.floors)this.buildFridges(n);this.wake()}}stepCovers(e){let t=Math.min(1,e/4e3),n=!1;for(let r of this.covers.values()){if(r.k===r.t)continue;let s=r.t-r.k;r.k=Math.abs(s)<=t?r.t:r.k+Math.sign(s)*t,n=!0}if(n)for(let r of this.floors)this.buildFridges(r);return n}stepFridges(e){let t=Sp(e),n=new Set;for(let[r,s]of this.fridges)for(let[o,a]of[["l","tl"],["r","tr"]]){let l=s[a]-s[o];if(Math.abs(l)<.004){l!==0&&(s[o]=s[a],n.add(r));continue}s[o]+=l*t,n.add(r)}if(!n.size)return!1;for(let r of this.floors)r.floor.furniture.some(s=>n.has(s.id))&&this.buildFridges(r);return!0}buildFridges(e){let t=new ut;for(let n of e.floor.furniture){let r=_t(n.type);if(r&&z0(r)){hp(t,r,n,Gt(e.floor,n),this.covers.get(n.id)?.k??V0(r,null));continue}if(n.type!=="fridge_smart")continue;let s=this.fridges.get(n.id);Wp(t,n,Gt(e.floor,n),s?.l??0,s?.r??0)}e.fridgeMesh.geometry.dispose(),e.fridgeMesh.geometry=t.geometry(),e.fridgeMesh.visible=t.count>0}resetView(){this.fit(700)}setStartView(e){this.startView=e}currentView(){let e=this.controls.view,t=this.floorBase(this.floorId);return{theta:e.theta,phi:e.phi,radius:e.radius,target:{x:e.target.x,y:e.target.y-t,z:e.target.z}}}floorBase(e){let t=e===null?void 0:this.floorMap.get(e);return t?t.floor.elevation+t.ty:0}dispose(){this.disposed=!0,cancelAnimationFrame(this.frame),clearTimeout(this.effectTimer),clearTimeout(this.robotTimer),clearTimeout(this.orbitTimer),clearTimeout(this.weatherTimer),this.weatherLayer.dispose(),this.sunArc?.dispose(),this.houseShadow?.dispose(),this.mapLayer.dispose(),this.energyLayer.dispose(),this.soundLayer.dispose(),this.waterLayer.dispose(),this.hydronicLayer.dispose(),this.screenLayer.dispose(),this.pictureLayer.dispose(),this.resizeObserver.disconnect(),this.intersection?.disconnect(),document.removeEventListener("visibilitychange",this.onVisibility),this.host?.removeEventListener("pointerdown",this.onTouch),this.renderer?.domElement?.removeEventListener?.("pointerdown",this.onRightDown),this.renderer?.domElement?.removeEventListener?.("pointerup",this.onRightUp),this.renderer?.domElement?.removeEventListener?.("contextmenu",this.onContext),clearTimeout(this.petTimer),this.controls.dispose(),this.clear(),this.building=null,this.buildRoofMesh(),this.ground.geometry.dispose(),this.ground.material.dispose(),this.patternTexture.dispose(),this.blindTexture.dispose(),this.groundTexture?.dispose(),this.haloTexture.dispose();for(let e of this.robots.values())e.led.dispose();this.robots.clear();for(let e of this.robotTrails.values())e.removeFromParent(),e.geometry.dispose(),e.material.dispose();this.robotTrails.clear();for(let e of this.trailTimers.values())clearTimeout(e);this.trailTimers.clear(),this.robotGeo?.dispose(),this.robotLedGeo?.dispose(),this.robotMat?.dispose(),this.mowerMat?.dispose(),this.meshLight?.dispose(),this.renderer.dispose(),this.renderer.forceContextLoss(),this.renderer.domElement.remove(),this.labels.remove()}invalidate(){this.frame||this.disposed||document.hidden||!this.onScreen||(this.frame=requestAnimationFrame(e=>this.render(e)))}makeRenderer(e){let t=e==="low"||e==="auto"&&Hy();this.lowQuality=t,this.weatherLayer&&this.skyView&&this.weatherLayer.set({...this.skyView,low:this.skyView.low||t}),this.weatherLayer&&this.buildHouseShadow(),this.highQuality=e==="high";let n=new Vr({antialias:!t,alpha:!0,powerPreference:t?"low-power":"default"}),r=Math.min(window.devicePixelRatio||1,t?1:e==="high"?2.5:2);return n.setPixelRatio(r),this.governor=e==="auto"&&!t?new Gu(r,Math.min(1,r)):null,n.setClearColor(0,0),n.outputColorSpace=dt,n.domElement.className="nf-canvas",this.host.prepend(n.domElement),n}makeControls(){return new kl(this.renderer.domElement,this.camera,{change:()=>this.wake(),tap:(e,t)=>this.onTap(e,t),hold:(e,t)=>this.onHold(e,t),swipeStart:(e,t,n,r)=>this.swipeStart(e,t,n,r),swipeMove:e=>this.swipe&&this.options.onDeviceSwipe?.(this.swipe.entity,"move",e,this.swipe.x,this.swipe.y),swipeEnd:()=>{this.swipe&&this.options.onDeviceSwipe?.(this.swipe.entity,"end",0,this.swipe.x,this.swipe.y),this.swipe=null},grab:(e,t)=>this.grabFurniture(e,t),drag:(e,t)=>this.dragFurniture(e,t),drop:()=>this.dropFurniture(),doubleTap:(e,t)=>{let n=this.floorId&&this.options.onRoomDoubleTap?this.pick(e,t):null;n&&!("entity"in n)&&n.roomId?this.options.onRoomDoubleTap(n.floorId,n.roomId):this.options.onBack?.()}})}onTouch=()=>this.wake();onVisibility=()=>{document.hidden&&(clearTimeout(this.effectTimer),this.effectTimer=void 0),document.hidden||this.invalidate()};scheduleEffects(){if(!this.hasVisibleEffects(document.hidden)||this.resting){clearTimeout(this.effectTimer),this.effectTimer=void 0;return}if(this.effectTimer!==void 0)return;let e=this.lowQuality?2*T1:T1;this.effectTimer=setTimeout(()=>{if(this.effectTimer=void 0,!!this.hasVisibleEffects(document.hidden)){this.effectTime=performance.now()/1e3,this.effectTick=!0;for(let t of this.floors)t.o<.02||!this.effectFloors.has(t.floor.id)||(this.buildLamps(t),this.buildGlow(t));this.invalidate()}},e)}hasVisibleEffects(e){return!e&&!this.disposed&&this.onScreen&&this.floors.some(t=>t.o>=.02&&this.effectFloors.has(t.floor.id))}resize(){let e=this.host.clientWidth||1,t=this.host.clientHeight||1;this.size={w:e,h:t},this.labelsDirty=!0,this.renderer.setSize(e,t,!1),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.invalidate()}clear(){for(let e of this.robots.values())e.group.removeFromParent();for(let e of this.meshes)e.group.removeFromParent(),Qm(e.group);this.meshes=[];for(let e of this.floors){e.group.traverse(t=>{t.geometry?.dispose()});for(let t of Object.values(e.materials))Array.isArray(t)||t.dispose();for(let t of e.materials.ghosts)t.material.dispose();this.root.remove(e.group)}this.floors=[],this.floorMap=new Map;for(let e of[...this.labels.children])e.dataset.entity||e.remove()}buildLightSurface(e){let t=this.lowQuality?.5:.25,n=Pp(e.floor,e.geo.walls2d,e.geo.wallBuckets,e.geo.openings,t,e.geo.holes,e.geo.roofUnder),r=MI(e.floor,e.geo.openRooms);if(e.lightZones=r.some((a,l)=>a!==l)?r:null,e.lightZones){for(let a=0;a=0&&l=0&&a.a=0&&a.bthis.glowOf(h)),r=t.doors.map(h=>{let f=e.geo.openings.find(p=>p.opening.id===h.id);if(f&&Sr(f.opening,f.exterior)==="passage")return 1;let d=e.openings.get(h.id);return d?Math.max(d.open,d.open2??0):.5}),s=n.map(h=>`${h.x.toFixed(2)},${h.y.toFixed(2)},${h.z.toFixed(2)},${h.kind},${h.level.toFixed(3)},${h.color.map(f=>f.toFixed(3)).join("/")}`).join(";")+"|"+r.map(h=>h.toFixed(1)).join(",");if(s===e.glowSig)return;e.glowSig=s;let o=e.glowMesh.geometry,a=o.getAttribute("color");if(!n.length){e.glowMesh.visible=!1,o.setDrawRange(0,0);return}let l=Ip(t,n,.42,r);if(this.roomTint){let h=e.floor.rooms.length;for(let f=0;f.004;if(f)for(let d=0;d<6;d++)c[u++]=h*6+d}o.index.needsUpdate=!0,o.setDrawRange(0,u),e.glowMesh.visible=u>0}withoutFurniture(e){if(this.gateOpen.size&&(e.outdoor??[]).some(n=>n.gates?.length)&&(e={...e,outdoor:e.outdoor.map(n=>n.gates?.length?{...n,gates:n.gates.map(r=>({...r,open:this.gateOpen.get(r.id)??!1}))}:n)}),!this.plain)return e;let t=n=>n.type==="stairs"||n.type==="stairwell"||!!_t(n.type)?.hole;return{...e,furniture:e.furniture.filter(t)}}rebuild(){let e=new Map(this.floors.map(s=>[s.floor.id,{y:s.y,o:s.o}])),t=new Map(this.floors.map(s=>[s.floor.id,s.openings]));this.clear();let n=this.building;if(!n)return;Uy({...n.settings.furniture_colors,...this.furnitureColors});let r=[...n.floors].sort((s,o)=>s.elevation-o.elevation);for(let s of n.floors){let o=n.settings.roof?.solar??[],a=Sh(n)?.id===s.id?o.filter(V=>V.face===Fl).map(V=>({field:V,face:wh(n,V)})):[],l=o.filter(V=>V.face.startsWith(`wall:${s.id}:`));if(l.length){let V=new Map(Mh(n,s.id).map(re=>[re.key,re]));for(let re of l){let ye=V.get(re.face);ye&&a.push({field:re,face:ye})}}let u=(n.settings.roof.sections??[]).some(V=>xp(V,s.elevation+s.height))?(V,re)=>{let ye=yp(n,V,re);return ye===null?null:ye-s.elevation}:void 0,h=pm(this.withoutFurniture(Bh(s,this.parked)),n.settings.wall_exterior,n.settings.wall_interior,mm(n.floors,s),a,u,this.wallPaint(s)),f={standing:{value:65535},glass:{value:0},slope:{value:new vt},slopeY:{value:new ke},glassAlpha:this.glassAlpha},d=jb({mask:f,look:this.themeUniform,theme:this.theme,textures:{pattern:this.patternTexture,blinds:this.blindTexture,halo:this.haloTexture}}),p=new et,x=new Se(h.floor,d.floor),m=new Se(h.shadow,d.shadow);m.renderOrder=1;let g=new Se(h.floor,d.pattern);g.renderOrder=2;let y=new Se(new Pe,d.glow);y.renderOrder=3,y.visible=!1;let _=new Se(new Pe,d.frames),b=new Se(new Pe,d.blinds),M=new Se(new Pe,d.glass);M.renderOrder=4;let S=new Se(new Pe,d.lamps);S.visible=!1;let v=new Se(new Pe,d.cones);v.visible=!1,v.renderOrder=3;let w=new yn(new Pe,d.halos);w.visible=!1,w.renderOrder=7;let P=new Se(new Pe,d.cones);P.visible=!1,P.renderOrder=7;let T=new Se(new Pe,d.lamps);T.visible=!1;let R=new Se(new Pe,d.screens);R.visible=!1,R.renderOrder=5;for(let V of[_,b,M])V.frustumCulled=!1;let L=new Se(h.walls,d.glassWall),U=new Se(h.walls,d.wall);L.renderOrder=6,p.add(x,m,g,y,U,new xn(h.lines,d.lines),_,b,M,S,v,w,P,T,R,L);for(let V of h.ghosts){let re=Qu(jn(new Ye({vertexColors:!0,transparent:!0,opacity:V.opacity,depthWrite:!1,side:ht}),this.themeUniform));d.ghosts.push({material:re,base:V.opacity});let ye=new Se(V.geometry,re);ye.renderOrder=2,p.add(ye)}this.root.add(p);let C=document.createElement("button");C.className="nf-pin nf-pin-floor",C.dataset.floor=s.id;let I=document.createElement("b");I.textContent=s.name||"\u2013";let O=document.createElement("span");O.textContent=this.floorInfo.get(s.id)??this.options.floorInfo?.(s)??"",C.append(I,O),C.addEventListener("click",()=>this.options.onFloorTap?.(s.id)),this.labels.append(C);let F=e.get(s.id),H=[],k=null;for(let V of s.rooms){let re=document.createElement("button");re.className="nf-pin",re.dataset.room=V.id,re.dataset.floor=s.id,this.fillRoomPin(re,V.name,this.roomInfo.get(V.id)),re.addEventListener("click",()=>this.options.onRoomTap?.(s.id,V.id)),this.labels.append(re);let[ye,Y]=Gs(V.points);H.push({pin:re,room:V,cx:ye,cz:Y});for(let[Q,se]of V.points)k??={x0:Q,x1:Q,z0:se,z1:se},k.x0=Math.min(k.x0,Q),k.x1=Math.max(k.x1,Q),k.z0=Math.min(k.z0,se),k.z1=Math.max(k.z1,se)}let X=[];for(let V of s.notes??[]){if(!V.text)continue;let re=document.createElement("button");re.className=`nf-pin nf-note-pin${J0(V)?" nf-note-due":""}`,re.title=V.text;let ye=V.text.length>28?`${V.text.slice(0,27)}\u2026`:V.text;re.textContent=`${V.photo?"\u{1F4F7} ":"\u270E "}${ye}`,re.addEventListener("click",()=>{let Y=re.classList.toggle("nf-note-open");re.textContent=`${V.photo?"\u{1F4F7} ":"\u270E "}${Y?V.text:ye}`;let Q=Y&&V.photo?this.notePhoto?.(V.photo):null;if(Q){let se=document.createElement("img");se.className="nf-note-photo",se.alt="",se.src=Q,se.addEventListener("load",()=>{this.labelsDirty=!0,this.invalidate()}),re.append(se)}this.labelsDirty=!0,this.invalidate()}),this.labels.append(re),X.push({pin:re,note:V})}this.floors.push({floor:s,rank:n.topology?ra(s)?0:r.filter(V=>!ra(V)&&V.building_id===s.building_id).indexOf(s):r.indexOf(s),group:p,geo:h,floorMesh:x,shadowMesh:m,patternMesh:g,glowMesh:y,lightSurface:null,lightZones:null,framesMesh:_,glassMesh:M,blindsMesh:b,lampMesh:S,sunMesh:v,sunSig:"",haloMesh:w,coneMesh:P,wedgeTris:[],fridgeMesh:T,lampTris:[],lampFurnTris:[],frameTris:[],glassTris:[],blindTris:[],wallMesh:U,screenMesh:R,screenSig:"",flowLayout:"",glowSig:"",lampShapeSig:"",lampColorSig:"",lampShade:new Float32Array(0),lampRanges:new Map,bbox:k,roomPins:H,notePins:X,labelSize:null,materials:d,mask:f,openings:new Map,y:F?.y??0,o:F?.o??1,ty:0,to:1,appliedO:-1,label:C})}this.floorMap=new Map(this.floors.map(s=>[s.floor.id,s])),this.buildPets();for(let s of this.floors)this.buildFridges(s);this.labelsDirty=!0,this.floorId&&!n.floors.some(s=>s.id===this.floorId)&&(this.floorId=null);for(let s of this.floors){this.buildLamps(s),this.buildScreens(s);let o=t.get(s.floor.id);for(let a of s.geo.openings)s.openings.set(a.opening.id,o?.get(a.opening.id)??this.openingTargets.get(a.opening.id)??Us);this.buildOpenings(s),this.buildLightSurface(s),this.buildSun(s)}this.applyTargets(e.size===0),this.applyHighlight(),this.applyTierFlags(),this.buildRoofMesh(),this.updateGhost(),this.placeMeshes()}placeMeshes(){for(let e of this.meshes)e.group.removeFromParent(),Qm(e.group);this.meshes=[];for(let e of this.floors)for(let t of Bh(e.floor,this.parked).furniture){let n=_t(t.type);if(!n?.mesh)continue;let r=n.mesh;if(!Hl(t.type)){this.meshAsked.has(r)||(this.meshAsked.add(r),QM(r).then(a=>{a&&!this.disposed&&this.rebuild()}));continue}let s=n.colors?.length?(n.colors.find(a=>a.id===t.variant)??n.colors[0]).hex:null,o=e1(r,{x:t.x,z:t.z,y:Gt(e.floor,t),rotation:t.rotation,mirror:t.mirror,w:t.w,d:t.d,h:t.h,paint:s});o&&(this.meshLight||(this.meshLight=t1(this.root,this.renderer)),n1(o,this.meshLight.env),e.group.add(o),this.meshes.push({group:o,furnitureId:t.id}))}this.invalidate()}buildRoofMesh(){this.roof&&(this.roof.group.traverse(a=>a.geometry?.dispose()),this.roof.solid.dispose(),this.roof.lines.dispose(),this.roof.glass.dispose(),this.scene.remove(this.roof.group),this.roof=null);let e=this.building?Nh(this.building,this.roofWindows):[];if(!e.length)return;let t=new et,n=jn(new Ye({vertexColors:!0,transparent:!0,side:ht}),this.themeUniform),r=jn(new Lt({vertexColors:!0,transparent:!0,blending:Sl(this.theme),depthWrite:!1}),this.themeUniform,!0),s=jn(new Ye({vertexColors:!0,transparent:!0,side:ht,depthWrite:!1}),this.themeUniform),o=e.map(a=>{let l=new et;return l.add(new Se(a.solid.geometry(),n),new xn(a.lines.geometry(),r)),a.glass.count&&l.add(new Se(a.glass.geometry(),s)),l.renderOrder=8,t.add(l),{group:l,floorId:a.floor.id,rideId:vp(this.building,a.floor,a.sections??[]),base:a.base,lift:a.lift!==!1}});t.renderOrder=8,this.scene.add(t),this.roof={group:t,parts:o,solid:n,lines:r,glass:s},this.placeRoof()}placeRoof(e=1e3){let t=this.roof;if(!t)return!1;let n=this.keepRoof?1:Math.min(1,Math.max(0,(this.controls.view.radius/this.houseRadius-.62)/.3)),s=(this.floorId===null||this.floors.length===1)&&!this.lowered?E1*n:0,o=Mp(e),a=this.roofO;this.roofO+=(s-this.roofO)*o,Math.abs(s-this.roofO)<.004&&(this.roofO=s),t.group.visible=this.roofO>.02;for(let l of t.parts){let c=this.floorMap.get(l.floorId);if(!c)continue;let u=this.floorMap.get(l.rideId)??c,h=u.ty>0?Math.min(1,u.y/u.ty):this.explode&&this.floorId===null?1:0,f=Math.max(0,1-this.roofO/E1);l.group.position.y=c.floor.elevation+u.y+l.base+f*2.2+(l.lift?h*gI:0)}return t.solid.opacity=this.roofO,t.solid.depthWrite=this.roofO>.5,t.lines.opacity=this.roofO,t.glass.opacity=this.roofO*.28,this.roofO!==a&&this.roofO!==s}applyTierFlags(){let e=this.lowQuality;this.ground.visible=!e&&this.theme!=="day"&&this.floors.some(t=>t.floor.rooms.length>0);for(let t of this.floors)t.patternMesh.visible=!e,t.shadowMesh.visible=!e&&t.o>.98;this.invalidate()}rebuildTier(){for(let e of this.floors)e.flowLayout="",this.buildLightSurface(e),e.lampShapeSig="",this.buildLamps(e)}get houseView(){return this.floorId===null&&this.floors.length>1}applyTargets(e){let t=this.floorId?this.floorMap.get(this.floorId):void 0;for(let n of this.floors){let r=db(n.rank,t?.rank,this.explode,this.floorStack);[n.ty,n.to]=[r.y,r.opacity],e&&([n.y,n.o]=[r.y,r.opacity]),this.applyFloor(n)}this.invalidate()}applyFloor(e){e.group.position.y=e.floor.elevation+e.y,e.group.visible=e.o>.02,e.shadowMesh.visible=e.o>.98&&!this.lowQuality,!(Math.abs(e.appliedO-e.o)<.001)&&(e.appliedO=e.o,mb(e.materials,e.o))}stepFloors(e){let t=!1,n=Mp(e);for(let r of this.floors){let s=pb(r,n);s.settled&&(this.labelsDirty=!0),(s.moving||s.settled)&&this.applyFloor(r),t||=s.moving}return t}stepOpenings(e){let t=!1,n=Sp(e);for(let r of this.floors){let s=!1;for(let[o,a]of r.openings){let l=this.openingTargets.get(o)??Us;if(wp(a,l))continue;let c=yb(a,l,n);r.openings.set(o,c.state),s=!0,t||=c.moving}s&&(this.buildOpenings(r),this.buildGlow(r),this.buildSun(r))}return t}fanPhase(e){return e.lamp!=="fan"||!e.spin?0:Math.round(this.effectTime*e.spin*360%C1*10)/10}glowOf(e){return lM(e.glow,e.effect,this.effectTime)}buildLamps(e){let t=performance.now(),n=h=>{let f=this.flashes.get(h);if(!f||f<=t)return 0;let d=f-t,p=d>S0?.5+.5*Math.sin(d/140):d/S0;return Math.round(p*10)/10},r=this.devices.filter(h=>h.floorId===e.floor.id&&h.lamp),s=this.wallMode+(this.lowQuality?"L":this.highQuality?"H":"M")+r.map(h=>`${h.id},${h.lamp},${h.variant},${h.x},${h.z},${h.y},${h.rotation??0},${h.roll??0},${h.upright?1:0},${h.rise??0},${h.size?.join("/")},${h.base??0},${h.pack??""},${h.mirror?1:0},${h.ceiling??""},${this.fanPhase(h)}`).join(";"),o=r.map(h=>this.glowOf(h)),a=this.devices.filter(h=>h.floorId===e.floor.id&&h.wedge),l=r.map((h,f)=>`${n(h.id)},${o[f]?`${o[f].level.toFixed(3)},${o[f].color.map(d=>d.toFixed(3)).join("/")}`:"off"}`).join(";")+"|"+a.map(h=>`${h.id},${h.x},${h.z},${h.rotation??0},${JSON.stringify(h.wedge)}`).join(";");if(s!==e.lampShapeSig||!e.lampMesh.geometry.getAttribute("position")){e.lampShapeSig=s,e.lampColorSig="";let h=new ut,f=[],d=[],p=new Map,x=e.floor.height;for(let m of r){let g=m.lamp==="strip"?(m.base??x)>Math.min(e.floor.cut_height,m.ceiling??x):m.lamp?Ku.has(m.lamp):!1;if(!m.lamp||g&&this.lowered)continue;let y=h.count,_=m.pack?_t(m.pack):void 0,[b,M,S]=m.size??[.3,.3,.3];_?ul(h,_,{x:m.x,z:m.z,rotation:m.rotation??0,w:b,d:M,h:S,mirror:m.mirror},m.base??0,65280):M0(h,{...m,lamp:m.lamp,phase:this.fanPhase(m)},m.ceiling??x,65280),p.set(m.furnitureId??m.id,{start:y,end:h.count}),m.pickable!==!1&&f.push({id:m.id,start:y,end:h.count}),m.furnitureId&&d.push({id:m.furnitureId,start:y,end:h.count})}e.lampTris=f,e.lampFurnTris=d,e.lampRanges=p,e.lampShade=Wy(h.c),e.lampMesh.geometry.dispose(),e.lampMesh.geometry=h.geometry(),e.lampMesh.visible=h.count>0}if(l===e.lampColorSig)return;e.lampColorSig=l;let c=e.lampMesh.geometry.getAttribute("color"),u=c.array;r.forEach((h,f)=>{let d=e.lampRanges.get(h.furnitureId??h.id);if(!d)return;let p=o[f],x=p?.55+.45*p.level:0,m=p?new W(...p.color.map(_=>Math.min(1,_*x))):new W(xI),g=n(h.id);g>0&&m.lerp(new W(1,1,1),.7*g);let y=new W(m.getHex());Xy(u,e.lampShade,d,[y.r,y.g,y.b])}),c.needsUpdate=!0,this.buildHalos(e)}buildSun(e){let t=this.building?.settings.sun_patches===!1?null:this.sun,n=this.building?.settings.north??0,r=this.weatherLayer?.cloud??0,s=Cb(t,n,r,e.openings.values());if(s===e.sunSig)return;e.sunSig=s;let o=Pb({floor:e.floor,openings:e.geo.openings,states:e.openings,sun:t,northDegrees:n,cloud:r});e.sunMesh.geometry.dispose(),e.sunMesh.geometry=o.geometry(),e.sunMesh.visible=o.count>0}buildHalos(e){let t={positions:[],colours:[]},n=new ut,r=[];for(let a of this.devices)if(a.floorId===e.floor.id&&a.wedge){let l=Sb(n,a,e.geo.walls2d);a.wedge.through||r.push({id:a.id,...l})}e.wedgeTris=r;let s=this.lowered;for(let a of this.lowQuality?[]:this.devices){let l=this.glowOf(a);if(a.floorId!==e.floor.id||!a.lamp||!l||s&&Eb(a.lamp))continue;let c=a;Tb(t,c,l,a.ceiling??e.floor.height),this.highQuality&&(a.lamp==="downlight"||a.lamp==="spot")&&Ab(n,c,l,a.ceiling??e.floor.height)}let o=new Pe;o.setAttribute("position",new Le(t.positions,3)),o.setAttribute("color",new Le(t.colours,3)),e.haloMesh.geometry.dispose(),e.haloMesh.geometry=o,e.haloMesh.visible=!this.lowQuality&&t.positions.length>0,e.coneMesh.geometry.dispose(),e.coneMesh.geometry=n.geometry(),e.coneMesh.visible=n.count>0}buildScreens(e){let t=Bh(e.floor,this.parked).furniture.filter(s=>this.screens.has(s.id)),n=t.map(s=>`${s.id}:${s.x},${s.z},${s.rotation},${s.w},${s.d},${s.h},${s.mount_y??""},${s.mirror?1:0}:${JSON.stringify(this.screens.get(s.id))}`).join(";");if(n===e.screenSig&&e.screenMesh.geometry.getAttribute("position"))return;e.screenSig=n;let r=new ut;for(let s of t){let o=this.screens.get(s.id),a=s.rotation*mt,l=Math.cos(a),c=Math.sin(a),u=(b,M,S)=>[s.x+b*l-S*c,M,s.z+b*c+S*l];if(o.gangs){let b=_t(s.type);if(!b)continue;for(let M of o.gangs){let S=new W(...M.color.map(v=>Math.min(1,v*(.45+.55*M.level))));cl(r,b,s,Gt(e.floor,s),S.getHex(),v=>v.gang===M.gang)}continue}if(o.print!==void 0){let b=Gt(e.floor,s)+s.h*.2,M=Math.min(s.w,s.d)*.16,S=b+s.h*.38*Math.min(1,Math.max(0,o.print)),v=new W(...o.color.map(R=>Math.min(1,R*(.35+.65*o.level)))),w=v.clone().multiplyScalar(.7),P=[u(-M,b,-M),u(M,b,-M),u(M,b,M),u(-M,b,M)],T=[u(-M,S,-M),u(M,S,-M),u(M,S,M),u(-M,S,M)];r.tri(T[0],T[2],T[1],v),r.tri(T[0],T[3],T[2],v);for(let R=0;R<4;R++){let L=(R+1)%4;r.tri(P[R],P[L],T[L],w),r.tri(P[R],T[L],T[R],w)}continue}if(o.fill!==void 0){let b=Zp(s,e.floor);if(!b)continue;let M=b.rect,S=Math.min(1,Math.max(0,o.fill)),v=new W(...o.color.map(R=>Math.min(1,R*(.35+.65*o.level)))),w=new W(.08,.1,.13),P=M.z,T=(R,L,U,C,I)=>{r.tri(u(R,U,P),u(L,U,P),u(L,C,P),I),r.tri(u(R,U,P),u(L,C,P),u(R,C,P),I)};if(b.vertical){let R=M.y0+(M.y1-M.y0)*S;S>0&&T(M.x0,M.x1,M.y0,R,v),S<1&&T(M.x0,M.x1,R,M.y1,w)}else{let R=M.x0+(M.x1-M.x0)*S;S>0&&T(M.x0,R,M.y0,M.y1,v),S<1&&T(R,M.x1,M.y0,M.y1,w)}continue}if(o.leds){let b=_t(s.type);if(!b)continue;let M=new W(...o.color.map(S=>Math.min(1,S*(.35+.65*o.level))));cl(r,b,s,Gt(e.floor,s),M.getHex(),S=>!!S.glow||!!S.screen);continue}if(o.heat){let b=_t(s.type);if(!b)continue;let M=new W(...o.color.map(S=>Math.min(1,S*(.35+.65*o.level))));cl(r,b,s,Gt(e.floor,s),M.getHex(),()=>!0);continue}if(o.faces){let b=Math.max(.05,s.w)*(s.mirror?-1:1),M=Math.max(.05,s.d),S=Math.max(.005,s.h),v=Gt(e.floor,s);for(let w of o.faces){let P=w.part==="right"?.03:-Math.abs(b)/2+.03,T=w.part==="left"?-.03:Math.abs(b)/2-.03,R=v+(w.part==="bottom"?S*.45:S)+.006,L=new W(...w.color.map(k=>Math.min(1,k*(.35+.65*w.level)))),U=new W(0,0,0),C=(k,X,V=R)=>u(k*Math.sign(b),V,X),I=[C(P,-M/2+.03),C(T,-M/2+.03),C(T,M/2-.03),C(P,M/2-.03)];r.tri(I[0],I[2],I[1],L),r.tri(I[0],I[3],I[2],L);let O=.12+.1*w.level,F=L.clone().multiplyScalar(.5),H=[C(P-O,-M/2-O,R+.004),C(T+O,-M/2-O,R+.004),C(T+O,M/2+O,R+.004),C(P-O,M/2+O,R+.004)];for(let k=0;k<4;k++){let X=(k+1)%4;r.tri(I[k],H[X],H[k],F,U,U),r.tri(I[k],I[X],H[X],F,F,U)}}continue}let h=_h(s,e.floor);if(!h)continue;let f=new W(...o.color.map(b=>Math.min(1,b*(.35+.65*o.level)))),d=new W(0,0,0),p=h.z+.004;r.tri(u(h.x0,h.y0,p),u(h.x1,h.y0,p),u(h.x1,h.y1,p),f),r.tri(u(h.x0,h.y0,p),u(h.x1,h.y1,p),u(h.x0,h.y1,p),f);let x=Math.min(1.5,o.halo??1);if(x<=0)continue;let m=(.18+.12*o.level)*Math.min(1,x),g=f.clone().multiplyScalar(.5*x),y=[u(h.x0,h.y0,p),u(h.x1,h.y0,p),u(h.x1,h.y1,p),u(h.x0,h.y1,p)],_=[u(h.x0-m,h.y0-m,p+.01),u(h.x1+m,h.y0-m,p+.01),u(h.x1+m,h.y1+m,p+.01),u(h.x0-m,h.y1+m,p+.01)];for(let b=0;b<4;b++){let M=(b+1)%4;r.tri(y[b],_[b],_[M],g,d,d),r.tri(y[b],_[M],y[M],g,d,g)}}e.screenMesh.geometry.dispose(),e.screenMesh.geometry=r.geometry(),e.screenMesh.visible=r.count>0}buildOpenings(e){let t=bm(e.geo.openings,e.openings,Math.min(e.floor.cut_height,e.floor.height),-.2-e.floor.elevation);e.frameTris=t.frameTris,e.glassTris=t.glassTris,e.blindTris=t.blindTris;for(let[n,r]of[[e.framesMesh,t.frames],[e.glassMesh,t.glass],[e.blindsMesh,t.blinds]])n.geometry.dispose(),n.geometry=r,n.visible=r.getAttribute("position").count>0}activeFloors(){return this.floors.filter(e=>e.to>.99)}applyHighlight(){for(let e of this.floors){let t=e.geo.floor.getAttribute("color");for(let n of e.geo.roomTris){let r=new W(n.color),s=this.roomTint?.get(n.roomId);s&&r.lerp(new W(...s).multiplyScalar(.6),.9),n.roomId===this.roomId&&r.lerp(bI,s?.3:.75);for(let o=n.start*3;oc.group),!0)[0];if(l){let c=l.object;for(;c&&!this.meshes.some(h=>h.group===c);)c=c.parent;let u=c?this.pickFurniture.get(this.meshes.find(h=>h.group===c).furnitureId):void 0;if(u)return{entity:u}}}let o=s.flatMap(l=>[l.lampMesh,l.coneMesh,l.framesMesh,l.glassMesh,l.blindsMesh,l.wallMesh,l.floorMesh].filter(c=>c.visible)),a=(l,c)=>l.find(u=>c>=u.start&&ch.group===l.object.parent);if(!(!n&&(l.object===u.lampMesh||l.object===u.coneMesh||l.object===u.framesMesh||l.object===u.blindsMesh||l.object===u.glassMesh))){if(l.object===u.lampMesh||l.object===u.coneMesh){let h=a(l.object===u.lampMesh?u.lampTris:u.wedgeTris,c);if(h)return{entity:h}}else if(l.object===u.framesMesh||l.object===u.blindsMesh||l.object===u.glassMesh){if(this.lowered&&l.face){let x=l.object.geometry.getAttribute("fold")?.getX(l.face.a)??$e;if(x!==$e&&Math.floor(x/16)%8===0)continue}let h=a(l.object===u.framesMesh?u.frameTris:l.object===u.glassMesh?u.glassTris:u.blindTris,c),f=h?this.pickOpenings.get(h):void 0,d=h?this.pickOpenings2.get(h):void 0,p=d?u.geo.openings.find(x=>x.opening.id===h):void 0;if(d&&p&&(l.point.x-p.start[0])*p.axis[0]+(l.point.z-p.start[1])*p.axis[1]>p.width/2&&(f=d),f)return{entity:f}}else if(l.object===u.wallMesh){let h=a(u.geo.furnitureTris,c),f=h&&n?this.pickFurniture.get(h):void 0;if(f)return{entity:f};if(l.face&&!h){let d=u.wallMesh.geometry.getAttribute("fold")?.getX(l.face.a)??32,p=Math.floor(d/16)%8,x=d%16,m=this.lowered&&p===0,g=(u.mask.glass.value&1<S.points.length>=3&&Ge(b,S.points))?.id??null;if(this.roomId!==null){if(M===this.roomId)return{floorId:u.floor.id,roomId:M}}else if(!g&&M)return{floorId:u.floor.id,roomId:M}}}}else if(l.object===u.floorMesh)return{floorId:u.floor.id,roomId:a(u.geo.roomTris.map(h=>({id:h.roomId,start:h.start,end:h.end})),c)??null}}}return null}onTap(e,t){let n=this.furnish?this.pick(e,t):this.pickInReach(e,t);if(n&&"entity"in n&&this.furnish){this.selectDevice(n.entity),this.options.onDeviceSelect?.(n.entity);return}if(n&&"entity"in n){this.flashes.set(n.entity,performance.now()+S0),this.invalidate(),this.options.onDeviceTap?.(n.entity,e,t);return}this.options.onRoomTap?.(n?.floorId??this.floorId??"",n?.roomId??null)}furnitureAt(e,t){let n=this.rayAt(e,t),r=this.activeFloors(),s=r.flatMap(o=>[o.lampMesh,o.wallMesh].filter(a=>a.visible));for(let o of n.intersectObjects(s,!1)){if(o.faceIndex==null)continue;let a=r.find(u=>u.group===o.object.parent),c=(o.object===a.lampMesh?a.lampFurnTris:a.geo.furnitureTris).find(u=>o.faceIndex>=u.start&&o.faceIndexh.id===n)?.furnitureId:void 0,a=o?null:this.furnitureAt(e,t),l=o??a?.id,c=l?this.floors.find(h=>h.floor.furniture.some(f=>f.id===l)):void 0,u=c?.floor.furniture.find(h=>h.id===l)?.type;return!!(c&&l&&u&&r.has(u))&&this.grabItem(c,l,e,t)}if(n){let o=this.devices.find(l=>l.id===n)?.furnitureId,a=o?this.floors.find(l=>l.floor.furniture.some(c=>c.id===o)):void 0;return!o||!a?this.grabDevice(n,e,t):this.grabItem(a,o,e,t)}let s=this.furnitureAt(e,t);if(!s){let o=this.pick(e,t);return o&&"entity"in o?this.grabDevice(o.entity,e,t):(this.selectedFurniture&&(this.selectFurniture(null),this.options.onFurnitureSelect?.(null)),this.selectedDevice&&(this.selectDevice(null),this.options.onDeviceSelect?.(null)),!1)}return this.grabItem(s.fv,s.id,e,t)}grabItem(e,t,n,r){let s=e.floor.furniture.find(a=>a.id===t),o=this.floorPoint(e,n,r);return!s||!o?!1:s.locked?(this.selectFurniture(s.id),this.options.onFurnitureSelect?.(s.id),!1):(this.grab={floorId:e.floor.id,id:s.id,offset:[s.x-o[0],s.z-o[1]],x:s.x,z:s.z,moved:!1},this.selectFurniture(s.id),this.options.onFurnitureSelect?.(s.id),!0)}grabDevice(e,t,n){let r=this.devices.find(a=>a.id===e),s=r&&this.floorMap.get(r.floorId),o=s&&this.floorPoint(s,t,n);return!r||!s||!o?!1:r.fixed?(this.selectDevice(e),this.options.onDeviceSelect?.(e),!1):(this.deviceGrab={id:e,floorId:s.floor.id,offset:[r.x-o[0],r.z-o[1]],x:r.x,z:r.z,moved:!1},this.selectDevice(e),this.options.onDeviceSelect?.(e),!0)}setSelectedDevice(e){e!==this.selectedDevice&&this.selectDevice(e)}selectDevice(e){e&&this.selectedFurniture&&(this.selectFurniture(null),this.options.onFurnitureSelect?.(null)),this.selectedDevice=e;for(let[t,n]of this.devicePins)n.el.classList.toggle("nf-dev-sel",t===e)}dragFurniture(e,t){if(this.surfaceDragging){this.surfaceGrab?.move(this.surfaceRay(e,t));return}let n=this.deviceGrab;if(n){let l=this.floorMap.get(n.floorId),c=this.devices.find(f=>f.id===n.id),u=l&&this.floorPoint(l,e,t);if(!l||!c||!u)return;let h=this.building?.settings.grid??.05;n.x=c.x=Math.round((u[0]+n.offset[0])/h)*h,n.z=c.z=Math.round((u[1]+n.offset[1])/h)*h,n.moved=!0,this.labelsDirty=!0,this.invalidate();return}let r=this.grab,s=r&&this.floorMap.get(r.floorId);if(!r||!s)return;let o=this.floorPoint(s,e,t);if(!o)return;let a=this.building?.settings.grid??.05;r.x=Math.round((o[0]+r.offset[0])/a)*a,r.z=Math.round((o[1]+r.offset[1])/a)*a,r.moved=!0,this.updateGhost(),this.invalidate()}dropFurniture(){if(this.surfaceDragging){this.surfaceDragging=!1,this.surfaceGrab?.end();return}let e=this.deviceGrab;this.deviceGrab=null,e?.moved&&this.options.onDeviceMove?.(e.id,Math.round(e.x*1e3)/1e3,Math.round(e.z*1e3)/1e3);let t=this.grab;this.grab=null,t?.moved&&this.options.onFurnitureMove?.(t.id,Math.round(t.x*1e3)/1e3,Math.round(t.z*1e3)/1e3),this.updateGhost()}updateGhost(){this.ghost&&(this.ghost.geometry.dispose(),this.ghost.material.dispose(),this.scene.remove(this.ghost),this.ghost=null);let e=this.selectedFurniture,t=e?this.floors.find(g=>g.floor.furniture.some(y=>y.id===e)):void 0,n=t?.floor.furniture.find(g=>g.id===e);if(!t||!n)return;let r=this.grab?.id===n.id?this.grab.x:n.x,s=this.grab?.id===n.id?this.grab.z:n.z,o=Xl(t.floor,{...n,x:r,z:s}),a=rg.has(n.type),l=Math.max(.1,n.type==="lamp_pendant"?.3:n.h),c=_t(n.type)||n.type==="lamp_wall"||n.type==="led_strip"?Gt(t.floor,n):a?n.type==="lamp_pendant"||n.type==="ceiling_fan"?o-n.h-.1:o-l:Gt(t.floor,n),u=n.rotation*mt,h=Math.cos(u),f=Math.sin(u),d=(g,y,_)=>[r+g*h-y*f,_,s+g*f+y*h],p=new Wt,x=[[-n.w/2,-n.d/2],[n.w/2,-n.d/2],[n.w/2,n.d/2],[-n.w/2,n.d/2]],m=new W(.25,.9,1);for(let g=0;g<4;g++){let[y,_]=x[g],[b,M]=x[(g+1)%4];p.seg(d(y,_,c+.01),d(b,M,c+.01),m),p.seg(d(y,_,c+l),d(b,M,c+l),m),p.seg(d(y,_,c+.01),d(y,_,c+l),m)}p.seg(d(-n.w/2,n.d/2+.03,c+.02),d(n.w/2,n.d/2+.03,c+.02),new W(1,1,1)),this.ghost=new xn(p.geometry(),new Lt({vertexColors:!0,depthTest:!1,transparent:!0})),this.ghost.position.y=t.floor.elevation+t.y,this.ghost.renderOrder=20,this.scene.add(this.ghost)}onHold(e,t){let n=this.pick(e,t);n&&"entity"in n&&this.options.onDeviceHold?.(n.entity,e,t)}swipeStart(e,t,n,r){if(this.furnish||Math.abs(r)n.floor.rooms.some(r=>r.points.length>=3)).map(n=>({key:n.floor.id,floorIds:[n.floor.id]})),e,t).map(n=>({floorId:n.key,url:n.url}))}scopeThumbnails(e,t=150,n=112){if(!e.length||!this.floors.length)return[];let r=this.lowQuality?1:Math.min(2,window.devicePixelRatio||1),s=Math.round(t*r),o=Math.round(n*r),a=new Tn(s,o);a.texture.colorSpace=dt;let l=new Vn(-1,1,1,-1,.1,4e3),c=this.floors.map(y=>({fv:y,visible:y.group.visible,y:y.y,o:y.o,standing:y.mask.standing.value,glass:y.mask.glass.value})),u=new Set(this.floors.map(y=>y.group)),h=[...this.scene.children.filter(y=>y!==this.root),...this.root.children.filter(y=>!u.has(y))].filter(y=>!y.isLight).map(y=>({node:y,visible:y.visible})),f=this.renderer.getClearAlpha(),d=this.renderer.clippingPlanes,p=new Uint8Array(s*o*4),x=document.createElement("canvas");x.width=s,x.height=o;let m=x.getContext("2d"),g=[];try{for(let y of h)y.node.visible=!1;this.renderer.setClearAlpha(0);for(let y of e){let _=new Set(y.floorIds),b=this.floors.filter(C=>_.has(C.floor.id)),M=new Ct;for(let C of this.floors){let I=_.has(C.floor.id);if(C.group.visible=I,!I)continue;C.y=0,C.o=1,this.applyFloor(C),C.group.visible=!0,C.mask.standing.value=0,C.mask.glass.value=0;let O=C.floor,F=y.room&&y.room.floorId===O.id?O.rooms.find(k=>k.id===y.room.roomId):null,H=F?F.points:[...O.rooms.flatMap(k=>k.points),...O.outdoor.flatMap(k=>k.points),...(O.walls??[]).flatMap(k=>[k.a,k.b]),...O.furniture.flatMap(k=>[[k.x-k.w/2,k.z-k.d/2],[k.x+k.w/2,k.z+k.d/2]])];for(let[k,X]of H)M.expandByPoint(new D(k,O.elevation,X)),M.expandByPoint(new D(k,O.elevation+Math.min(O.cut_height,O.height),X))}if(!b.length||M.isEmpty())continue;M.expandByScalar(.25),this.renderer.clippingPlanes=y.room?[new mn(new D(1,0,0),-M.min.x),new mn(new D(-1,0,0),M.max.x),new mn(new D(0,0,1),-M.min.z),new mn(new D(0,0,-1),M.max.z)]:[];let S=M.getCenter(new D),v=-.6,w=.8,P=new D(Math.sin(w)*Math.sin(v),Math.cos(w),Math.sin(w)*Math.cos(v));l.position.copy(S).addScaledVector(P,Math.max(100,M.getSize(new D).length()*2)),l.lookAt(S),l.updateMatrixWorld();let T=.5,R=.5;for(let C of[M.min.x,M.max.x])for(let I of[M.min.y,M.max.y])for(let O of[M.min.z,M.max.z]){let F=new D(C,I,O).applyMatrix4(l.matrixWorldInverse);T=Math.max(T,Math.abs(F.x)),R=Math.max(R,Math.abs(F.y))}let L=s/o;T/R>L?R=T/L:T=R*L,l.left=-T*1.05,l.right=T*1.05,l.top=R*1.05,l.bottom=-R*1.05,l.updateProjectionMatrix(),this.renderer.setRenderTarget(a),this.renderer.clear(),this.renderer.render(this.scene,l),this.renderer.readRenderTargetPixels(a,0,0,s,o,p);let U=m.createImageData(s,o);for(let C=0;C{Math.hypot(u[0]-r.motion.pos[0],u[1]-r.motion.pos[1])o.length?`${o.length}:${o[0].map(a=>a.toFixed(2))}/${o[o.length-1].map(a=>a.toFixed(2))}`:"").join("|"),r=this.robotTrails.get(e.id);if(r&&r.userData.key===n){this.showRobotTrail(e);return}let s=r;if(!s){let o=new Ye({color:3590399,transparent:!0,opacity:.34,depthWrite:!1,side:ht});s=new Se(n0([],.16,0),o),s.renderOrder=3,s.name=`robot-trail:${e.id}`,this.robotTrails.set(e.id,s);let a=this.robots.get(e.id)?.group.parent;a&&a.add(s)}s.geometry.dispose(),s.geometry=n0(t,.16,(e.y??0)+.012),s.userData.key=n,this.showRobotTrail(e)}showRobotTrail(e){let t=this.robotTrails.get(e.id);if(!t)return;let n=this.trailTimers.get(e.id);n!==void 0&&(clearTimeout(n),this.trailTimers.delete(e.id));let r=Date.now(),s=a1(e.settledAt,r);if(t.material.opacity=.34*s,t.visible=(e.track?.length??0)>0&&s>.01,s<=0||s>=1&&e.settledAt==null)return;let o=s>=1?Math.max(0,(e.settledAt??r)+af-r):250;this.trailTimers.set(e.id,setTimeout(()=>{this.showRobotTrail(e),this.invalidate()},o))}makeRobot(e){if(!this.robotGeo){let s=new ut,o=(l,c,u,h,f)=>{let d=[];for(let p=0;p<20;p++)d.push([Math.cos(p/20*Math.PI*2)*l,Math.sin(p/20*Math.PI*2)*l]);Tt(s,d,c,u,h,f,{aoFrom:0,bottom:!1})};o(.17,.012,.08,2371657,3424863),o(.055,.08,.1,3820138,5070726),this.robotGeo=s.geometry(),this.robotMat=new Ye({vertexColors:!0});let a=new ut;Tt(a,[[-.05,.1],[.05,.1],[.05,.14],[-.05,.14]],.08,.085,16777215,16777215,{aoFrom:0,bottom:!1}),this.robotLedGeo=a.geometry()}let t=new et,n=new Ye({color:S1[e.mode]}),r=e.mower?this.mowerMat??=new Ye({color:4164170}):this.robotMat;return t.add(new Se(this.robotGeo,r),new Se(this.robotLedGeo,n)),e.mower&&t.scale.set(1.7,1.6,1.7),{info:e,motion:{pos:[...e.rest],heading:e.restHeading,path:[],next:0},group:t,led:n}}buildPets(){let e=new Map(this.pets);this.pets.clear(),this.petMat??=new Ye({vertexColors:!0});for(let t of this.floors)for(let n of t.floor.furniture){let r=_t(n.type);if(!r?.pet)continue;let s=t.floor.rooms.find(f=>f.points.length>=3&&Ge([n.x,n.z],f.points)),o=e.get(n.id),a=new ut;ws(new Ni(a,new Wt,Ts({x:0,z:0,rotation:0,mirror:n.mirror})),r,Math.max(.05,n.w),Math.max(.05,n.d),Math.max(.05,n.h),0,null,null,n.variant??null),o?.group.removeFromParent();let l=new et;l.add(new Se(a.geometry(),this.petMat));let c=s?t.floor.furniture.filter(f=>f.id!==n.id&&!_t(f.type)?.pet&&f.type!=="rug"&&Gt(t.floor,f)<.5&&Ge([f.x,f.z],s.points)).map(f=>ns(f)):[],u={points:s?.points??[[n.x-.5,n.z-.5],[n.x+.5,n.z-.5],[n.x+.5,n.z+.5],[n.x-.5,n.z+.5]],obstacles:c,speed:n.type.endsWith(":pet_dog")?.7:.45},h=o&&s&&Ge(o.motion.pos,s.points)?o.motion:{pos:[n.x,n.z],heading:n.rotation*Math.PI/180,target:null,rest:1};this.pets.set(n.id,{motion:h,room:u,random:Vy(n.id),group:l,floorId:t.floor.id})}for(let[t,n]of e)this.pets.has(t)||n.group.removeFromParent()}setPetRooms(e){for(let[t,n]of this.pets){let r=this.floorMap.get(n.floorId),s=e.get(t);if(!r||s===void 0)continue;let o=s?r.floor.rooms.find(l=>l.id===s&&l.points.length>=3):void 0;if(!o||n.room.points===o.points)continue;let a=r.floor.furniture.filter(l=>!_t(l.type)?.pet&&l.type!=="rug"&&Gt(r.floor,l)<.5&&Ge([l.x,l.z],o.points)).map(l=>ns(l));n.room={...n.room,points:o.points,obstacles:a},Ge(n.motion.pos,o.points)||(n.motion={...n.motion,pos:Gs(o.points),target:null,rest:.5})}this.invalidate()}stepRobots(e){if(!this.robots.size&&!this.pets.size)return!1;let t=this.robotLast?Math.min(.2,(e-this.robotLast)/1e3):0;this.robotLast=e;let n=!1,r=1/0,s=this.petLast?(e-this.petLast)/1e3:0;this.petLast=e;for(let o of this.pets.values()){let a=this.floorMap.get(o.floorId);if(!a)continue;o.group.parent!==a.group&&a.group.add(o.group),Gy(o.motion,o.room,s,o.random)||!!o.motion.target?n=!0:r=Math.min(r,Math.max(0,o.motion.rest)),o.group.position.set(o.motion.pos[0],0,o.motion.pos[1]),o.group.rotation.y=o.motion.heading}clearTimeout(this.petTimer),!n&&Number.isFinite(r)&&(this.petTimer=setTimeout(()=>this.invalidate(),r*1e3+50));for(let o of this.robots.values()){let a=this.floorMap.get(o.info.floorId);if(!a)continue;o.group.parent!==a.group&&a.group.add(o.group);let l=this.robotTrails.get(o.info.id);l&&l.parent!==a.group&&a.group.add(l),t>0?n=o1(o.motion,o.info,t)||n:n||=o.info.mode==="cleaning"||o.info.mode==="returning",o.group.position.set(o.motion.pos[0],o.info.y??0,o.motion.pos[1]),o.group.rotation.y=o.motion.heading}return n||(this.robotLast=0),n}getView(){return{...this.controls.view,target:this.controls.view.target.clone()}}showView(e,t=900){let n=e.target??{x:0,y:0,z:0};this.controls.maxRadius=Math.max(this.controls.maxRadius,e.radius*1.5),this.controls.flyTo({target:new D(n.x,n.y,n.z),radius:e.radius,phi:e.phi,theta:e.theta},t)}flyTo(e,t=900){this.controls.flyTo(e,t)}focus(e,t,n,r,s){let o=this.floorMap.get(e);if(o){if(this.controls.flyTo({target:new D(t,o.floor.elevation+o.ty+r,n),radius:5.5,phi:.78},900),s){this.flashes.set(s,performance.now()+2400);let a=this.host.querySelector(`.nf-dev[data-entity="${CSS.escape(s)}"]`);a?.classList.add("nf-dev-found"),setTimeout(()=>a?.classList.remove("nf-dev-found"),2600)}this.invalidate()}}render(e){if(this.frame=0,this.disposed)return;let t=this.lastFrame?Math.min(100,e-this.lastFrame):16,n=!1;this.orbitSpeed&&!this.controls.active?(this.orbitLast&&(this.controls.view.theta+=this.orbitSpeed*Math.min(100,e-this.orbitLast)/1e3),this.orbitLast=e,n=!0):this.orbitLast=0;let r=this.controls.update(e),s=this.stepFloors(t),a=[this.stepOpenings(t),this.stepFridges(t),this.stepCovers(t)].some(Boolean),l=!1;if(this.flashes.size){let m=new Set;for(let[g,y]of this.flashes){let _=this.deviceFloor.get(g);_&&m.add(_),y<=e&&this.flashes.delete(g)}l=this.flashes.size>0;for(let g of this.floors)m.has(g.floor.id)&&this.buildLamps(g)}let c=this.placeRoof(t),u=this.stepRobots(e);this.pictureLayer.step();let f=[this.weatherLayer,this.energyLayer,this.soundLayer,this.screenLayer,this.waterLayer,this.hydronicLayer].map(m=>m.step(e)).some(Boolean),d=r||s||a||l||c,p=[];if(r&&p.push("camera"),s&&p.push("floors"),a&&p.push("openings"),l&&p.push("flash"),c&&p.push("roof"),this.effectTick&&p.push("effect"),u&&p.push("robot"),n&&p.push("orbit"),this.tintTick&&p.push("tint"),this.effectTick=this.tintTick=!1,this.lastFrame=d?e:0,d&&this.governor){let m=this.governor.frame(t,e);m&&"ratio"in m?(this.renderer.setPixelRatio(m.ratio),this.resize()):m&&setTimeout(()=>this.dropToLow(),0)}this.updateWalls(),this.renderer.render(this.scene,this.camera),this.placeLhAnchors(),(this.viewChanged()||s||this.labelsDirty)&&(this.labelsDirty=!1,this.updateLabels()),this.reportStats(e,p),d&&this.invalidate(),this.scheduleEffects(),!d&&n&&!this.orbitTimer&&(this.orbitTimer=setTimeout(()=>{this.orbitTimer=void 0,this.invalidate()},this.lowQuality?66:33));let x=this.resting;!d&&f&&!this.weatherTimer&&!x&&(this.weatherTimer=setTimeout(()=>{this.weatherTimer=void 0,this.invalidate()},33)),!d&&u&&!this.robotTimer&&!x&&(this.robotTimer=setTimeout(()=>{this.robotTimer=void 0,this.invalidate()},this.lowQuality?66:33))}updateWalls(){if(this.controls.walk){for(let o of this.floors)o.mask.standing.value=65535,o.mask.glass.value=0,o.mask.slope?.value.set(0,0,0,0);return}let e=this.camera.position,t=this.controls.view.target,n=e.x-t.x,r=e.z-t.z,s=Math.hypot(n,r)||1;for(let o of this.floors){let a=this.roomId!==null&&o.floor.rooms.some(h=>h.id===this.roomId),l=this.wallMode==="cut",c=0,u=0;o.geo.buckets.forEach((h,f)=>{let d=h?h[0]*n/s+h[1]*r/s>=.25:a;this.wallMode!=="auto"||!d||(this.painted?a&&(u|=1<.5&&r)){this.labelPlacer.place(n.label,null);continue}let s=n.floor.elevation+n.y+n.floor.cut_height*.5,o=[r.x0,r.x1].flatMap(l=>[r.z0,r.z1].map(c=>this.screenPoint([l,s,c],1/0)));n.label.hidden&&(n.label.hidden=!1),n.labelSize??={w:n.label.offsetWidth,h:n.label.offsetHeight};let a=hb(o,n.labelSize.w,{width:this.size.w,inset:this.labelInset});t.push({fv:n,rank:n.rank,left:a.left,y:a.y,height:n.labelSize.h})}for(let n of ub(t))this.labelPlacer.place(n.fv.label,cb(n.left,n.y));this.updateDevicePins();for(let n of this.floors){let r=n.to<.99||n.o<.9||e||this.roomId!==null||this.otherFloor(n),s=n.floor.elevation+n.y+.05;for(let a of n.roomPins){let l=r?null:this.screenPoint([a.cx,s,a.cz],1.1);this.labelPlacer.place(a.pin,l&&!l.off?xl(l):null)}let o=e||n.o<.9||this.otherFloor(n);for(let{pin:a,note:l}of n.notePins){let c=o?null:this.screenPoint([l.x,n.floor.elevation+n.y+(l.y??Z0),l.z]);this.labelPlacer.place(a,c&&!c.off?xl(c):null)}}}otherFloor(e){return this.floorId!==null&&e.floor.id!==this.floorId}updateDevicePins(){let e=this.houseView;for(let t of this.persons){let n=this.personPins.get(t.id),r=this.floorMap.get(t.floorId);if(!n)continue;let s=r&&!e&&_p(r,this.otherFloor(r))?this.screenPoint([t.x,r.floor.elevation+r.y+.9,t.z]):null;this.labelPlacer.place(n,s&&!s.off?xl(s):null)}for(let t of this.devices){let n=this.devicePins.get(t.id)?.el;if(!n)continue;let r=this.floorMap.get(t.floorId),s=t.id.startsWith("detect:"),o=!!t.full&&t.roomId===null,a=!!r&&(o?fb(r):(!e||s)&&_p(r,this.otherFloor(r))),c=!!r&&a&&t.pin!==!1?this.screenPoint([t.x,r.floor.elevation+r.y+t.y,t.z]):null;if(!c||c.off){this.labelPlacer.place(n,null);continue}let u=this.roomId===null?t.full?"full":"":t.roomId===this.roomId?"full":"dim";this.pinMode.get(n)!==u&&(this.pinMode.set(n,u),n.classList.toggle("nf-dev-full",u==="full"),n.classList.toggle("nf-dev-dim",u==="dim")),this.labelPlacer.place(n,xl(c))}}reportStats(e,t){if(!this.statsOn||!this.options.onStats)return;let n=t.length>0;this.fpsStart||(this.fpsStart=e),this.lastStatsFrame&&n&&(this.worstFrame=Math.max(this.worstFrame,e-this.lastStatsFrame)),this.lastStatsFrame=n?e:0,this.fpsFrames++;let r=e-this.fpsStart;if(r>500||!n){let s=this.renderer.info.render;this.options.onStats({fps:n?Math.round(this.fpsFrames*1e3/r):0,busy:t,worstMs:Math.round(this.worstFrame),calls:s.calls,triangles:s.triangles,low:this.lowQuality,pixelRatio:this.renderer.getPixelRatio()}),this.fpsFrames=0,this.fpsStart=e,this.worstFrame=0}}};function vI(){let e=document.createElement("canvas");e.width=256*3,e.height=256*2;let t=e.getContext("2d"),n=(o,a,l,c,u)=>{t.strokeStyle=`rgba(55,224,255,${u})`,t.beginPath(),t.moveTo(o,a),t.lineTo(l,c),t.stroke()};t.lineWidth=1.5;let r=(o,a,l)=>{t.save(),t.beginPath(),t.rect(o*256,a*256,256,256),t.clip(),l(o*256,a*256),t.restore()};r(0,0,(o,a)=>{for(let l=0;l<5;l++){let c=a+l*256/5+.75;n(o,c,o+256,c,.09);let u=o+l*.37%1*256;n(u,c,u,c+256/5,.07)}}),r(1,0,(o,a)=>{for(let l=0;l<7;l++){let c=o+l*256/7+.75;n(c,a,c,a+256,.08);let u=a+l*.53%1*256;n(c,u,c+256/7,u,.06)}}),r(2,0,(o,a)=>{for(let l=0;l<4;l++){let c=l*256/4+.75;n(o+c,a,o+c,a+256,.1),n(o,a+c,o+256,a+c,.1)}}),r(1,1,(o,a)=>{for(let l=0;l<2;l++){let c=a+l*256/2+.75;n(o,c,o+256,c,.09);let u=l?256/4:0;for(let h of[u,u+256/2])n(o+h+.75,c,o+h+.75,c+256/2,.09)}}),r(2,1,(o,a)=>{n(o+.75,a,o+.75,a+256,.08),n(o,a+.75,o+256,a+.75,.08),t.fillStyle="rgba(55,224,255,0.05)";for(let l=0;l<90;l++)t.fillRect(o+l*97%256,a+(l*61+l*l%37)%256,2,2)});let s=new zt(e);return s.flipY=!1,s.wrapS=ln,s.wrapT=ln,s.anisotropy=4,s.colorSpace=dt,s}function _I(){let i=document.createElement("canvas");i.width=8,i.height=32;let e=i.getContext("2d");e.fillStyle="#1a2742",e.fillRect(0,0,8,32),e.fillStyle="#223556",e.fillRect(0,4,8,14),e.fillStyle="rgba(55,224,255,0.45)",e.fillRect(0,29,8,2);let t=new zt(i);return t.wrapS=zn,t.wrapT=zn,t.colorSpace=dt,t}function MI(i,e){let t=i.rooms.map((r,s)=>s),n=r=>t[r]===r?r:t[r]=n(t[r]);for(let[r,s]of e){let o=i.rooms.findIndex(u=>u.id===r),a=i.rooms.findIndex(u=>u.id===s);if(o<0||a<0)continue;let l=n(o),c=n(a);l!==c&&(t[Math.max(l,c)]=Math.min(l,c))}return t.map((r,s)=>n(s))}function SI(){let e=document.createElement("canvas");e.width=64,e.height=64;let t=e.getContext("2d"),n=t.createRadialGradient(64/2,64/2,0,64/2,64/2,64/2);n.addColorStop(0,"rgba(255,255,255,0.9)"),n.addColorStop(.2,"rgba(255,255,255,0.45)"),n.addColorStop(.55,"rgba(255,255,255,0.1)"),n.addColorStop(1,"rgba(255,255,255,0)"),t.fillStyle=n,t.fillRect(0,0,64,64);let r=new zt(e);return r.colorSpace=dt,r}function wI(){let e=w0,t=document.createElement("canvas");t.width=1024,t.height=1024;let n=t.getContext("2d");n.strokeStyle="rgba(91,124,255,0.16)",n.lineWidth=1;for(let o=0;o<=e;o++){let a=Math.round(o/e*1024)+.5;n.beginPath(),n.moveTo(a,0),n.lineTo(a,1024),n.moveTo(0,a),n.lineTo(1024,a),n.stroke()}n.globalCompositeOperation="destination-in";let r=n.createRadialGradient(1024/2,1024/2,1024*.12,1024/2,1024/2,1024/2);r.addColorStop(0,"rgba(0,0,0,1)"),r.addColorStop(1,"rgba(0,0,0,0)"),n.fillStyle=r,n.fillRect(0,0,1024,1024);let s=new zt(t);return s.anisotropy=4,s.colorSpace=dt,s}function b4(i,e){return new T0(i,e)}function M0(i,e,t,n){let[r,s,o]=e.size??Cs[e.lamp],a=e.base??0,l=(e.rotation??0)*mt,c=Math.cos(l),u=Math.sin(l),h=(x,m)=>[e.x+x*c-m*u,e.z+x*u+m*c],f=(x,m,g,y,_,b=14)=>{let M=[];for(let S=0;STt(i,[h(x,g),h(m,g),h(m,y),h(x,y)],_,b,M,S,{aoFrom:0,bottom:!0}),p=Math.max(.05,Math.min(r,s)/2);switch(e.lamp){case"ceiling":f(p*.25,t-.04,t,Je,Je,8),f(p,t-Math.max(.04,o)-.035,t-.04,n,n);break;case"pendant":{let x=Math.max(.4,t-o);f(.06,t-.02,t,Je,Je,8);let m=e.variant==="globe"?x+2*p:e.variant==="drum"?x+.24:x+.2;if(f(.008,m,t-.02,Je,Je,5),e.variant==="globe")for(let y=0;y<7;y++){let _=Math.PI*(y/7),b=Math.PI*((y+1)/7);f(p*Math.max(.2,Math.sin((_+b)/2)),x+p-p*Math.cos(_),x+p-p*Math.cos(b),n,n,14)}else if(e.variant==="cone")for(let y=0;y<4;y++)f(p*(.25+.75*(4-y)/4),x+.06*y,x+.06*(y+1),n,n,16);else e.variant==="drum"?f(p,x,x+.24,n,n,18):(f(p*.35,x+.14,x+.2,n,n,12),f(p,x,x+.14,n,n,16));break}case"fan":{let x=Math.max(.05,t-Math.max(.22,o)),m=x+.16;f(.07,t-.05,t,Je,Je,10),m[e.x+w*M-P*S,e.z+w*S+P*M];Tt(i,[v(.1,-.035),v(g,-.075),v(g,.075),v(.1,.035)],y,y+.012,w1,w1,{aoFrom:0,bottom:!0})}break}case"downlight":f(p,t-.012,t,Je,Je,12),f(p*.7,t-.02,t-.012,n,n,12);break;case"spot":f(p*.6,t-.02,t,Je,Je,10),f(p,t-Math.max(.06,o),t-.02,Je,Je,12),f(p*.8,t-Math.max(.06,o)-.008,t-Math.max(.06,o),n,n,12);break;case"panel":d(-r/2,r/2,-s/2,s/2,t-Math.max(.015,o),t,Je,Je),d(-r/2+.02,r/2-.02,-s/2+.02,s/2-.02,t-Math.max(.015,o)-.004,t-Math.max(.015,o),n);break;case"uplight":f(Math.max(.1,p*.6),a,a+.03,Je,Je),f(.014,a+.03,a+o-.12,Je,Je,6),f(p,a+o-.14,a+o-.02,Je,Je),f(p*.92,a+o-.02,a+o,n,n);break;case"bollard":f(p,a,a+o-.14,Je,Je,10),f(p*.9,a+o-.14,a+o-.03,n,n,10),f(p*1.1,a+o-.03,a+o,Je,Je,10);break;case"garden":f(.012,a,a+o-.08,Je,Je,5),f(p,a+o-.08,a+o-.01,Je,Je,10),f(p*.8,a+o-.01,a+o,n,n,10);break;case"floor":f(Math.max(.1,p*.7),a,a+.03,Je,Je),f(.014,a+.03,a+o-.28,Je,Je,6),f(p,a+o-.3,a+o,n,n);break;case"table":f(Math.max(.05,p*.55),a,a+.03,Je,Je),f(.012,a+.03,a+o-.16,Je,Je,6),f(p,a+o-.18,a+o,n,n);break;case"wall":{let x=e.base??Wl;d(-r/2+.03,r/2-.03,-s/2,-s/2+.02,x,x+o,Je),d(-r/2,r/2,-s/2+.02,s/2,x+o*.15,x+o*.85,n);break}case"strip":{let x=Math.max(.02,o),m=e.base!=null?e.base+x:t-.04,g=e.upright?0:(e.rise??0)*mt;if(!e.roll&&!e.upright&&!g){d(-r/2,r/2,-s/2,s/2,m-x,m,n);break}let y=(e.roll??0)*mt,_=Math.cos(y),b=Math.sin(y),[M,S]=[Math.cos(g),Math.sin(g)],v=e.upright?a+r/2:m-x/2+Oo(e.base,r,e.rise),w=(U,C,I)=>{let O=U,F=C*_-I*b,H=C*b+I*_;return e.upright?[O,F]=[-F,O]:g&&([O,F]=[O*M-F*S,O*S+F*M]),[e.x+O*c-H*u,v+F,e.z+O*u+H*c]},P=[w(-r/2,-x/2,-s/2),w(r/2,-x/2,-s/2),w(r/2,-x/2,s/2),w(-r/2,-x/2,s/2),w(-r/2,x/2,-s/2),w(r/2,x/2,-s/2),w(r/2,x/2,s/2),w(-r/2,x/2,s/2)],T=new W(n),R=[e.x,v,e.z],L=(U,C,I,O)=>{let[F,H,k]=[P[U],P[C],P[I]],X=[(H[1]-F[1])*(k[2]-F[2])-(H[2]-F[2])*(k[1]-F[1]),(H[2]-F[2])*(k[0]-F[0])-(H[0]-F[0])*(k[2]-F[2]),(H[0]-F[0])*(k[1]-F[1])-(H[1]-F[1])*(k[0]-F[0])],V=[F[0]-R[0],F[1]-R[1],F[2]-R[2]],re=X[0]*V[0]+X[1]*V[1]+X[2]*V[2]<0,[ye,Y,Q,se]=re?[P[O],P[I],P[C],P[U]]:[P[U],P[C],P[I],P[O]];i.tri(ye,Y,Q,T,T,T),i.tri(ye,Q,se,T,T,T)};L(0,1,2,3),L(4,5,6,7),L(0,1,5,4),L(1,2,6,5),L(2,3,7,6),L(3,0,4,7);break}}}export{zi as ModelError,T0 as NextFloorViewer,b4 as createViewer,mI as furniturePreview,uI as inspectModel,Hy as isLowEnd,hI as prepareModel,fI as previewModel,M0 as pushLampModel}; /*! Bundled license information: three/build/three.core.js: diff --git a/custom_components/nextfloor/frontend/nextfloor-editor.js b/custom_components/nextfloor/frontend/nextfloor-editor.js index a443e0a..5d69906 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 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` +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 Zc=[],Gi=new Map,Vb=0,pe=(t,e)=>`pack:${t}:${e}`,vt=t=>t.startsWith("pack:");function Ls(t){Zc=t,Gi=new Map;for(let e of t)for(let n of e.items)Gi.set(pe(e.id,n.id),n);Vb+=1}var zr=()=>Zc;var Wb={};function U(t){if(!vt(t))return;let e=Gi.get(t);if(e)return e;let[,n,...r]=t.split(":"),i=Wb[n];return i?Gi.get(pe(i,r.join(":"))):void 0}var Kb=.22;function jc(t,e,n,r){let i=Math.min(Kb,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[jc(t*r,n*r,r,i)/i,jc(e*r,n*r,r,i)/i]}var Gc=new WeakMap;function qc(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=Gc.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,x,k,M]=[u.tx??u.x,u.tz??u.z,u.tw??u.w,u.td??u.d],[A,E]=Tr(w-k/2,w+k/2,-.5,i,e),[F,O]=Tr(x-M/2,x+M/2,-.5,o,n);Object.assign(v,{tx:(A+E)/2,tz:(F+O)/2,tw:E-A,td:O-F})}return v});return l||Gc.set(t,l=new Map),l.size>32&&l.clear(),l.set(a,d),d}var Cs=t=>!!t?.parts.some(e=>e.move);var Yc=t=>U(t)?.parts.find(e=>e.screen),Uc=.06;function Xc(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>=Uc&&s>=Uc})}function ht(t){return rt[t]??U(t)?.size??[.6,.6,.8]}function It(t){let e=U(t);return od.has(t)||!!e?.electric||!!e?.light||!!e?.climate}var Jc=t=>!!U(t)?.parts.some(e=>e.picture),Dn=t=>!!U(t)?.climate;function Qc(t,e){return t.name[e.split("-")[0]]??t.name.en??Object.values(t.name)[0]??t.id}var jb={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 ed(t,e){if(e.split("-")[0]==="de")return t.name;let n=/^nextfloor\.(.+)$/.exec(t.id)?.[1];return n&&jb[n]||t.name}function Dt(t,e){return e.mount_y!=null?e.mount_y:Ub(t,e)+(Gb(e)?0:rd(t,e.x,e.z))}var Gb=t=>t.type==="led_strip"||U(t.type)?.mount==="ceiling";function Ub(t,e){if(e.type==="lamp_wall")return td;if(e.type==="led_strip")return Math.max(0,pt(t,e.x,e.z)-.04-Math.max(.02,e.h));let n=U(e.type);if(!n)return nd(e);switch(n.mount){case"surface":return id(t,e.x,e.z);case"wall":return n.wall_y??1;case"ceiling":return Math.max(0,Ui(t,e)-e.h);default:return 0}}function Ns(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 wt=["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"],ad=["turn","slide","top"],ld=["always","active","no_power","never"],cd=1.3,Zi=(t,e=new Date().toISOString().slice(0,10))=>!!t.due&&t.due<=e,dd=["gable","hip","halfhip","pyramid","mansard","pent","flat","parapet"],ud=["brick","round","wide","steel"],qi=["navigate","more_info","service","fire_dom_event"];function Yi(t,e,n){return t?e?!!n.lock_plan:!!t.locked:!1}var hd=["rain","snow","fog","clouds","lightning","sky"],pd=["rain","snow","clouds","lightning","sky"],fd=["lawn","terrace","path","driveway","pavers","stepping_stones","natural_stone","street","sidewalk","gravel","river","stream","pool","bed","wild","hedge","fence","pergola"],Bs={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 Vs(t){return t==="hedge"||t==="fence"||t==="pergola"}var md=["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,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 gd(t)+(e.offset??0)+Bs[e.type]-Zb(e,n,r)}function gd(t){return t.elevation>.3?0:-.2}function _d(t,e,n){let r=(t.outdoor??[]).filter(o=>!Vs(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):gd(t)}var Ws=t=>t.cut??(t.type==="pool"||t.type==="river"||t.type==="stream");function Xi(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 bd=30,yd={meter:null,grid:null,grid_invert:!1,solar:null,battery:null,battery_invert:!1,battery_soc:null,consumption:null,tariff:null},vd=["wood","oak","tiles","carpet","stone","concrete"],wd={type:"none",pitch:35,overhang:.4},Ji="#d6cfc2",Qi="#e8e3da",kd={wall_exterior:.24,wall_interior:.12,grid:.05,north:0,roof:{...wd}};function Ot(){return{version:1,floors:[],settings:{...kd},energy:{...yd},presence:[]}}function Re(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 Yb=2.75;function xd(t,e){if(e!=null&&Number.isFinite(e))return Math.round(e*Yb*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 $d(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 Sd(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 eo=["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"],Md={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"]},je=["meter","inverter","home_battery","wallbox","grid_point"],Ed=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"]),td=1.75;function to(t){return Ks.has(t.type)||["stairwell","parking"].includes(t.type)?!1:U(t.type)?.mount!=="ceiling"}function he(t){return Ed.has(t)||!!U(t)?.light}var Xb=new Set(["table","table_round","coffee_table","desk","nightstand","sideboard","dresser","kitchen","island","worktop","tv_board","dishwasher","washer","dryer"]);function Rd(t,e,n,r=0){let i=le(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 nd(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 Ks=new Set(["lamp_ceiling","lamp_downlight","lamp_spot","lamp_panel","lamp_pendant","ceiling_fan"]);function Ad(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 js=t=>t?.floor_offset&&Number.isFinite(t.floor_offset)?t.floor_offset:0;function rd(t,e,n){let r=t.rooms.find(i=>i.points.length>=3&&i.floor_offset&&C([e,n],i.points));return js(r)}function pt(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 Ui=(t,e)=>e.ceiling_y!=null&&e.ceiling_y>0?e.ceiling_y:pt(t,e.x,e.z);function id(t,e,n){let r=0;for(let i of t.furniture)!(Xb.has(i.type)||U(i.type)?.surface)||!C([e,n],qs(i))||(r=Math.max(r,i.h));return r}var od=new Set([...Ed,"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"]),rt={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 Gs=["interior","front","front_glass","sidelight","sidelights","glass","sliding","passage"],Us=["standard","bars","glass_wall"],no=new Set(["interior","front"]);function rn(t,e){return t.type==="door"?t.style&&Gs.includes(t.style)?t.style:e?"front":"interior":t.style&&Us.includes(t.style)?t.style:"standard"}function Fd(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 Zs(t){return t==="front"||t==="front_glass"||t==="sidelight"||t==="sidelights"}var Hn={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 Ln(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&&Zs(t.style)?"front":e?"door_double":"door":t.sill<.1?e?"terrace_double":"terrace":e?"window_double":"window"}function He(t){t.energy={...yd,...t.energy??{}},t.presence=t.presence??[],t.version=1,t.settings={...kd,...t.settings,roof:{...wd,...t.settings?.roof??{}}},t.floors.forEach((e,n)=>{let r=Re(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]=rt[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 Jb(t),t.topology&&io(t),t}function Jb(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=I(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=I("room"));e(n.openings,"op"),e(n.furniture,"furn"),e(n.outdoor,"out")}}function I(t){return`${t}_${Math.random().toString(36).slice(2,10)}`}function ve(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 le(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 qs(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 ro={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 Ht=t=>[t.kind,t.ownerKind,t.floorId,t.id].filter(Boolean).join(":");function xt(t){return t?.outdoor_building_id?{kind:"building",id:t.outdoor_building_id}:t?.outdoor_branch_id?{kind:"branch",id:t.outdoor_branch_id}:t?.outdoor_location_id?{kind:"location",id:t.outdoor_location_id}:null}var ce=t=>!!xt(t),kt=t=>({kind:"outside",id:t.id,...t.kind!=="location"?{ownerKind:t.kind}:{}});function Nn(t,e){return e.kind==="outside"?t.floors.find(n=>{let r=xt(n);return r?.kind===(e.ownerKind??"location")&&r.id===e.id}):void 0}function Td(t,e="Geb\xE4ude 1"){if(t.topology)return;let n=I("location"),r=I("branch"),i=I("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 io(t){let e=t.topology;e.locations??=[],e.branches??=[],e.buildings??=[];let n=o=>(o||=e.locations[0]?.id||I("location"),e.locations.some(s=>s.id===o)||e.locations.push({id:o,name:"Ort"}),o),r=o=>(o||=e.branches[0]?.id||I("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||I("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){let s=xt(o);if(s){let a=s.kind==="building"?i(s.id):s.kind==="branch"?r(s.id):n(s.id);o.outdoor_location_id=s.kind==="location"?a:null,o.outdoor_branch_id=s.kind==="branch"?a:null,o.outdoor_building_id=s.kind==="building"?a:null,o.building_id=null}else o.building_id=i(o.building_id)}}function zd(t,e){let n=Nn(t,kt(e));if(n)return n;let r={...Re(I("outside"),"Au\xDFen",0),[e.kind==="building"?"outdoor_building_id":e.kind==="branch"?"outdoor_branch_id":"outdoor_location_id"]:e.id,building_id:null};return t.floors.push(r),r}function Ys(t,e,n){let r=t.floors.find(o=>o.id===e),i=xt(r);return n?{kind:"room",id:n,floorId:e}:i?kt(i):{kind:"floor",id:e}}function Qb(t){let e=(a,l,c,d=[],u=d.flatMap(h=>h.floorIds),p)=>{let h={kind:a,...l?{id:l}:{},...p?{floorId:p.floorId}:{}};return{key:Ht(h),name:c,selection:h,floorIds:[...new Set(u)],children:d,...p?{room:p}:{}}},n=a=>e("floor",a.id,a.name,a.rooms.map(l=>e("room",l.id,l.name,[],[a.id],{floorId:a.id,roomId:l.id})),[a.id]);if(!t.topology)return e("all",void 0,"Alle Etagen",[...t.floors].sort((a,l)=>l.elevation-a.elevation).map(n));let r=t.topology,i=(a,l)=>{let c=Nn(t,kt(a));if(!c)return l;let d=e("outside",a.id,"Au\xDFen",c.rooms.map(u=>e("room",u.id,u.name,[],[c.id],{floorId:c.id,roomId:u.id})),[c.id]);return d.selection=kt(a),d.key=Ht(d.selection),[...l,d]},o=a=>{let l=t.floors.filter(c=>!ce(c)&&c.building_id===a.id).sort((c,d)=>d.elevation-c.elevation);return e("building",a.id,a.name,i({kind:"building",id:a.id},l.map(n)))},s=a=>e("branch",a.id,a.name,i({kind:"branch",id:a.id},r.buildings.filter(l=>l.branch_id===a.id).map(o)));return e("all",void 0,"Alle Orte",r.locations.map(a=>e("location",a.id,a.name,i({kind:"location",id:a.id},r.branches.filter(l=>l.location_id===a.id).map(s)))))}function Pr(t,e){let n=Qb(t),r=Ht(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 Xs(t,e){let n=Pr(t,e),r=n.at(-1);return r.selection.kind==="room"?n.at(-2).children:!r.children.length&&["floor","outside"].includes(r.selection.kind)?[r]:r.children}function oo(t,e,n=!1){if(!t.topology||e.kind==="all")return t.floors;let r=Pr(t,e),i=(n&&(e.kind==="floor"||e.kind==="room")?r.find(s=>s.selection.kind==="outside")??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 Bn(t,e){return t.topology?Pr(t,Ys(t,e.id)).slice(1).map(n=>n.name).join(" / "):e.name}var on=t=>t?Ht(t):"";function so(t){if(!t)return null;let e=xt(t);return e?kt(e):t.building_id?{kind:"building",id:t.building_id}:null}function Js(t,e){return!e||!t.topology?!1:e.kind==="outside"?!!Nn(t,e):t.topology[e.kind==="building"?"buildings":e.kind==="branch"?"branches":"locations"].some(n=>n.id===e.id)}function sn(t,e){return t.topology?Js(t,e)?oo(t,e).filter(n=>e.kind!=="building"||!ce(n)):[]:t.floors}function Pd(t,e){return{scope:e,floorId:e.kind==="branch"||e.kind==="location"?null:sn(t,e)[0]?.id??null}}function Id(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=Js(t,e.scope)?e.scope:so(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=sn(t,n);return n?.kind==="branch"||n?.kind==="location"?{scope:n,floorId:null}:{scope:n,floorId:r.some(i=>i.id===e.floorId)?e.floorId:r[0]?.id??null}}function ao(t){let e=t.topology;return e?[...e.locations.map(r=>({kind:"location",id:r.id})),...e.branches.map(r=>({kind:"branch",id:r.id})),...e.buildings.map(r=>({kind:"building",id:r.id})),...t.floors.filter(ce).map(r=>so(r))].map(r=>[on(r),Pr(t,r).slice(1).map(i=>i.name).join(" / ")]):[]}function Qs(t,e){let[n,...r]=e.split(":"),i=n==="outside"&&r.length>1?r.shift():void 0,o=r.join(":"),s=["building","branch","location","outside"].includes(n)?{kind:n,id:o,...i?{ownerKind:i}:{}}:null;return Js(t,s)?s:null}function Dd(t,e,n,r){let i=t.floors.find(o=>o.id===n);return e!==n||!i||ce(i)||!t.topology?.buildings.some(o=>o.id===r)||i.building_id===r?!1:(i.building_id=r,!0)}var lo=globalThis,co=lo.ShadowRoot&&(lo.ShadyCSS===void 0||lo.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ea=Symbol(),Od=new WeakMap,Ir=class{constructor(e,n,r){if(this._$cssResult$=!0,r!==ea)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(co&&e===void 0){let r=n!==void 0&&n.length===1;r&&(e=Od.get(n)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Od.set(n,e))}return e}toString(){return this.cssText}},Hd=t=>new Ir(typeof t=="string"?t:t+"",void 0,ea),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 Ir(n,t,ea)},Ld=(t,e)=>{if(co)t.adoptedStyleSheets=e.map(n=>n instanceof CSSStyleSheet?n:n.styleSheet);else for(let n of e){let r=document.createElement("style"),i=lo.litNonce;i!==void 0&&r.setAttribute("nonce",i),r.textContent=n.cssText,t.appendChild(r)}},ta=co?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let n="";for(let r of e.cssRules)n+=r.cssText;return Hd(n)})(t):t;var{is:ey,defineProperty:ty,getOwnPropertyDescriptor:ny,getOwnPropertyNames:ry,getOwnPropertySymbols:iy,getPrototypeOf:oy}=Object,uo=globalThis,Cd=uo.trustedTypes,sy=Cd?Cd.emptyScript:"",ay=uo.reactiveElementPolyfillSupport,Dr=(t,e)=>t,na={toAttribute(t,e){switch(e){case Boolean:t=t?sy: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}},Bd=(t,e)=>!ey(t,e),Nd={attribute:!0,type:String,converter:na,reflect:!1,useDefault:!1,hasChanged:Bd};Symbol.metadata??=Symbol("metadata"),uo.litPropertyMetadata??=new WeakMap;var $t=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,n=Nd){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&&ty(this.prototype,e,i)}}static getPropertyDescriptor(e,n,r){let{get:i,set:o}=ny(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)??Nd}static _$Ei(){if(this.hasOwnProperty(Dr("elementProperties")))return;let e=oy(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Dr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Dr("properties"))){let n=this.properties,r=[...ry(n),...iy(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(ta(i))}else e!==void 0&&n.push(ta(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 Ld(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:na).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:na;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??Bd)(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){}};$t.elementStyles=[],$t.shadowRootOptions={mode:"open"},$t[Dr("elementProperties")]=new Map,$t[Dr("finalized")]=new Map,ay?.({ReactiveElement:$t}),(uo.reactiveElementVersions??=[]).push("2.1.2");var ia=globalThis,Vd=t=>t,ho=ia.trustedTypes,Wd=ho?ho.createPolicy("lit-html",{createHTML:t=>t}):void 0,oa="$lit$",St=`lit$${Math.random().toFixed(9).slice(2)}$`,sa="?"+St,ly=`<${sa}>`,cn=document,Hr=()=>cn.createComment(""),Lr=t=>t===null||typeof t!="object"&&typeof t!="function",aa=Array.isArray,qd=t=>aa(t)||typeof t?.[Symbol.iterator]=="function",ra=`[ +\f\r]`,Or=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Kd=/-->/g,jd=/>/g,an=RegExp(`>|${ra}(?:([^\\s"'>=/]+)(${ra}*=${ra}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),Gd=/'/g,Ud=/"/g,Yd=/^(?:script|style|textarea|title)$/i,la=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),m=la(1),R=la(2),G1=la(3),it=Symbol.for("lit-noChange"),_=Symbol.for("lit-nothing"),Zd=new WeakMap,ln=cn.createTreeWalker(cn,129);function Xd(t,e){if(!aa(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Wd!==void 0?Wd.createHTML(e):e}var Jd=(t,e)=>{let n=t.length-1,r=[],i,o=e===2?"":e===3?"":"",s=Or;for(let a=0;a"?(s=i??Or,u=-1):d[1]===void 0?u=-2:(u=s.lastIndex-d[2].length,c=d[1],s=d[3]===void 0?an:d[3]==='"'?Ud:Gd):s===Ud||s===Gd?s=an:s===Kd||s===jd?s=Or:(s=an,i=void 0);let h=s===an&&t[a+1].startsWith("/>")?" ":"";o+=s===Or?l+ly:u>=0?(r.push(c),l.slice(0,u)+oa+l.slice(u)+St+h):l+St+(u===-2?a:h)}return[Xd(t,o+(t[n]||"")+(e===2?"":e===3?"":"")),r]},Cr=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]=Jd(e,n);if(this.el=t.createElement(c,r),ln.currentNode=this.el.content,n===2||n===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(i=ln.nextNode())!==null&&l.length0){i.textContent=ho?ho.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=dn(this,e,n,0),s=!Lr(e)||e!==this._$AH&&e!==it,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 Vn(e.insertBefore(Hr(),o),o,void 0,n??{})}return i._$AI(t),i};var ca=globalThis,q=class extends $t{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let n=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=eu(n,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return it}};q._$litElement$=!0,q.finalized=!0,ca.litElementHydrateSupport?.({LitElement:q});var dy=ca.litElementPolyfillSupport;dy?.({LitElement:q});(ca.litElementVersions??=[]).push("4.2.2");var me=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); } -`,t$=J` +`,d$=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=J` +`,ft=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 On={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},sn=t=>(...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`
(...e)=>({_$litDirective$:t,values:e}),Lt=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 Nr=class extends Lt{constructor(e){if(super(e),this.it=_,e.type!==Wn.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===it)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:[]}}};Nr.directiveName="unsafeHTML",Nr.resultType=1;var tu=hn(Nr);var ua=t=>t.slice(0,t.indexOf(".")),uy={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=>uy[ua(t)]??null,ha=["light","cover","climate","media","switch","fan","lock","binary","sensor","scene","script"];var nu=new Set(["light","switch","fan"]),Ct=t=>t!==null&&t!=="scene"&&t!=="script",Le=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 ru=t=>!!t&&t.entity_id.startsWith("sensor.")&&t.attributes.device_class==="enum";var iu=t=>Math.min(1,Math.max(0,t));function hy(t){let e=iu((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 da(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(iu(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:hy(n.color_temp_kelvin),level:r}:{color:[1,.71,.28],level:r}}function ou(t,e,n){let r=da(t,n);if(r)return r;for(let i of e){let o=da(i);if(o)return{color:o.color,level:o.level*.6}}return null}function bo(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 pa=t=>t.trim().replace(/^\/local\/www\//i,"/local/"),fa=t=>/^(https:\/\/|\/local\/|\/hacsfiles\/)\S+\.m?js(\?\S*)?$/i.test(t.trim());var fy=globalThis,au=fy.__nextfloorPluginStore??={plugins:new Map,listeners:new Set},ma=au.plugins,su=au.listeners;var my=5;function lu(t,e){t.errors.lengthsu.delete(t)}var ga=()=>[...ma.values()].map(t=>t.status),cu=()=>[...ma.values()].flatMap(t=>Object.keys(t.plugin.lightAnimations??{}));function*vo(t,e){for(let{plugin:n,status:r}of ma.values())for(let i of n.devices??[]){let o=!1;try{o=i.match(t,e)}catch(s){lu(r,s)}o&&(yield{device:i,status:r})}}function wo(t,e){for(let{device:n}of vo(t,e))return n.kind??"sensor";return null}function du(t,e){let n=t.states[e];if(!n)return null;let r=gy({hass:t,entityId:e,state:n})?.icon?.trim();return r&&/^mdi:[a-z0-9-]+$/i.test(r)?r:null}function gy(t){let e=null;for(let{device:n,status:r}of vo(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){lu(r,i)}return e}function ko(t,e){return t?typeof t=="string"?t:t[e]??t[e.split("-")[0]]??t.en??Object.values(t)[0]??"":""}function uu(t,e){let n=[];for(let{device:r,status:i}of vo(t,e))r.settings?.length&&n.push({pluginId:i.id,name:i.name,settings:r.settings});return n}function hu(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 pu(t,e){for(let{device:n}of vo(t,e))if(n.floorWedge)return!0;return!1}var _y=new Set(["temperature","humidity","power","carbon_dioxide","energy","gas","water","volume","volume_storage","volume_flow_rate","illuminance","pressure","atmospheric_pressure","pm1","pm25","pm10","volatile_organic_compounds","volatile_organic_compounds_parts","carbon_monoxide","nitrogen_dioxide","moisture","sound_pressure"]),by=new Set(["m\xB3","m3","L","l","kWh","Wh","MWh","lx"]),yy=new Set(["door","window","opening","garage_door","motion","occupancy","presence","smoke","moisture","gas","carbon_monoxide"]),vy=new Set(["battery","signal_strength","timestamp","date","duration","data_rate","data_size","frequency","enum"]);function Nt(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 mu=(t,e)=>{let n=t.entities?.[e];return!!(n?.hidden||n?.entity_category)},Ge=(t,e)=>ee(e)??wo(e,t.states[e]);function fu(t,e){let n=t.states[e];if(!n||mu(t,e))return!1;if(wo(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?_y.has(i):by.has(String(n.attributes.unit_of_measurement??"")):r==="binary"?i?yy.has(i):!!t.entities?.[e]?.area_id:!0}function wy(t,e){let n=t.states[e];return ee(e)!=="sensor"||!n?.attributes.unit_of_measurement||mu(t,e)||vy.has(String(n.attributes.device_class??""))?!1:Number.isFinite(Number(n.state))||Le(n)}var $o=(t,e)=>e.startsWith("sensor.")&&t.states[e]?.attributes.device_class==="power",_a=null;yo(()=>_a=null);function ba(t,e){let n=t.get(e);return n||t.set(e,n=[]),n}function ky(t){let e=new Map,n=new Map,r=new Map,i=new Map,o=[],s=d=>{(fu(t,d)||wy(t,d))&&Ct(Ge(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&&$o(t,d)&&ba(n,p).push(d),p&&!u.hidden&&!u.entity_category&&(r.get(p)??r.set(p,new Set).get(p)).add(ua(d));let h=Nt(t,d);h===null?s(d):fu(t,d)&&ba(e,h).push(d)}if(t.entities)for(let d of Object.keys(t.states))t.entities[d]||s(d);let a=ha.indexOf("binary")-.5,l=d=>{let u=ee(d),p=u?ha.indexOf(u):a;return p>a&&wo(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 Kn(t){let e=_a;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:_a=ky(t)}function ke(t,e){let n=xo(t,e.area_id);return e.sub_areas?.length?[...new Set([...n,...e.sub_areas.flatMap(r=>xo(t,r))])]:n}function xo(t,e){return!e||!t.entities?[]:Kn(t).byArea.get(e)??[]}function gu(t,e){if(!t.entities)return[];let n=[];for(let[r,i]of Kn(t).byArea){let o=i.filter(s=>Ct(Ge(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 _u=t=>t.entities?Kn(t).withoutArea:[],ya=(t,e)=>!!t.entities&&Kn(t).hubs.has(e),So=(t,e)=>t.entities?Kn(t).powerByDevice.get(e)??[]:[];function jn(t,e){let n=new Map;for(let i of e)ba(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 Mo=(t,e)=>jn(t,e).map(n=>n.primary),xy={temperature:"temperature",humidity:"humidity",co2:"carbon_dioxide",illuminance:"illuminance"};function va(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===xy[n]}var $y=new Set(["climate","water_heater","switch","button","camera","media_player","vacuum","light","fan","lawn_mower"]),Sy=["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"],My=new RegExp(`(${Sy.join("|")})`,"i");function wa(t,e){let n=t.entities?.[e]?.device_id,r=n&&!ya(t,n)?Kn(t).domainsByDevice.get(n):void 0;return r&&[...r].some(i=>$y.has(i))?!1:!My.test(`${e} ${t.states[e]?.attributes.friendly_name??""}`)}function bu(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([...ke(t,n).filter(c=>!a.has(c)),...s])].filter(c=>c.startsWith("sensor.")&&va(t,c,r)&&wa(t,c))}function yu(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 Eo(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 Ro(t,e){let n=e?t.states[e]:void 0;if(!n||Le(n))return null;let r=n.attributes;if(r.nf_cover_control&&typeof r.current_position=="number")return r.current_position;let i=yu(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 Ey=new Set([void 0,"shutter","blind","awning","shade","curtain","window"]),Ry=new Set(["garage","gate"]),Ay=new Set(["window","opening"]);function Br(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 vu=(t,e)=>t==="none"?null:t??e??null,Bt=t=>t&&t!=="none"?t:null;function Vt(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=ke(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=Br(c("window"),s.filter(g=>ee(g)==="cover"&&Ey.has(a(g))),!0),u=Br(c("window"),l(g=>Ay.has(g))),p=Br(c("door"),l(g=>g==="door")),h=Br(c("garage"),s.filter(g=>ee(g)==="cover"&&Ry.has(a(g)??""))),f=Br(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:vu(g.cover,b?.get(g.id)),contact:g.sensor==="handle"&&g.contact==null?null:vu(g.contact,y.get(g.id)),tilt:g.tilt==="none"?null:g.tilt,contact2:v?Bt(g.contact2):null,tilt2:v?Bt(g.tilt2):null,position:Bt(g.position),positionInverted:!!g.position_inverted,tiltAngle:Bt(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"?Bt(g.lock):null,cover2:g.type==="garage"?null:Bt(g.cover2),coverTilt:Bt(g.cover_tilt),cover2Tilt:Bt(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 ka(t){if(!t||Le(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 wu=/\b(tv|fernseh|television|fire ?tv|apple ?tv|chromecast|shield)/i,ku=/(kühl|fridge|gefrier|freezer)/i,xu=/(spülmaschine|geschirrspül|dishwasher)/i,Ty=/(kochfeld|herd|induktion|cooktop)/i,zy={robot_vacuum:/(saug|vacuum|robo|roomba|roborock|dreame|ecovacs|deebot)/i,tv_board:wu,tv_wall:wu,desk:/\b(pc|computer|rechner|desktop|monitor|workstation)/i,fridge:ku,fridge_smart:ku,stove:/(herd|kochfeld|cooktop|stove|induktion)/i,kitchen_tall:/(backofen|oven|ofen)/i,dishwasher:xu,washer:/(waschmaschine|washer|washing)/i,dryer:/(trockner|dryer)/i,kitchen:/(kaffee|coffee|wasserkocher|kettle)/i,island:Ty,sink:xu,radiator:/(heiz|radiator|thermostat|climate|hk|trv)/i},$u={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},Su=new Set(["tv_board","tv_wall"]);var Gn=t=>Su.has(t)||!!Yc(t),Ao=t=>!!U(t)?.electric&&/speaker|multiroom|soundbar/.test(t.split(":").pop()??t),Wr=t=>Gn(t)||t==="desk"||t==="fridge_smart",Py=t=>!!t&&t!=="none";function Iy(t,e){if($o(t,e))return e;let n=t.entities?.[e]?.device_id;return n?So(t,n).find(r=>r!==e)??null:null}var Dy=(t,e,n)=>t.rooms.find(r=>r.points.length>=3&&C([e,n],r.points));function Vr(t,e,n,r){return t.find(i=>e?.test(n(i)))??(r?t[0]??null:null)}function Ae(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(Py));for(let o of r.furniture){let s=o.type in $u,a=Dn(o.type),l=s?$u[o.type]:zy[o.type];if(!l&&!a&&!Ao(o.type)&&o.entity==null&&o.power==null)continue;let c=Dy(r,o.x,o.z),d=(c?Mo(t,ke(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?ke(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))??Vr(p("light"),l,u,!1)}else if(s)h=Vr(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)&&Nt(t,y)===b)??null}else if(o.type==="radiator"||a)h=Vr(p("climate"),l,u,!0);else if(Gn(o.type)){let b=p("media");h=b.find(y=>t.states[y]?.attributes.device_class==="tv")??Vr(b,l,u,Su.has(o.type))}else if(Ao(o.type)){let b=p("media").filter(y=>t.states[y]?.attributes.device_class!=="tv");h=Vr(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?Iy(t,h):null,!f&&l&&c&&!s&&(f=ke(t,c).find(b=>$o(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?ke(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 Mu=t=>t==="fridge"||t==="fridge_smart"||/(fridge|freezer|kuehl|gefrier|chest_freezer)/.test(t.slice(t.lastIndexOf(":")+1));function Eu(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=Ae(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(...Mo(t,xo(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 Oy(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 Au(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=_e(r),g=[];for(let y=s+u/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=ee(y)==="light",w=g[0].at,x=-1/0;for(let{at:M,wallDistance:A}of g){let E=b.length?Math.min(...b.map(P=>Math.hypot(M[0]-P[0],M[1]-P[1]))):3,F=Math.hypot(M[0]-f[0],M[1]-f[1]),O=Math.min(E,3)*2;Fx+1e-9&&(x=O,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 Ru=/(^|_)(current_room|current_segment|aktueller_raum|current_area)($|_)/;function Fu(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.")&&(Ru.test(o.translation_key??"")||Ru.test(o.entity_id.split(".")[1])))?.entity_id??null}var Z=t=>t?.symconObjects!==void 0;function Ce(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 pn(t){return!t||t.state==="unknown"||t.state==="unavailable"?null:t.attributes.symcon_value??t.attributes.symcon_numeric_value??t.state}function Wt(t){let e=pn(t);if(e===null||typeof e=="boolean"||e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}function Kr(t){let e=pn(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 xa(t){return pn(t)===null?"\u2013":String(t?.attributes.symcon_formatted??pn(t))}var be=t=>/^(sensor|input_number|number)\./.test(t),Fo=t=>/^(binary_sensor|input_boolean)\./.test(t);function Un(t,e){if(!be(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 Hy(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=Hy(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 Tu(t,e,n){return e.unsupported?[]:H(t,r=>Ce(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 To(t,e){return t.power&&t.power!=="none"?t.power:e.get(t.id)?.power??null}var{I:Ly}=Qd,zu=t=>t;var Iu=t=>t.strings===void 0,Pu=()=>document.createComment(""),Zn=(t,e,n)=>{let r=t._$AA.parentNode,i=e===void 0?t._$AB:e._$AA;if(n===void 0){let o=r.insertBefore(Pu(),i),s=r.insertBefore(Pu(),i);n=new Ly(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=zu(l).nextSibling;zu(r).insertBefore(l,i),l=c}}}return n},Kt=(t,e,n=t)=>(t._$AI(e,n),t),Cy={},Du=(t,e=Cy)=>t._$AH=e,Ou=t=>t._$AH,zo=t=>{t._$AR(),t._$AA.remove()};var Hu=(t,e,n)=>{let r=new Map;for(let i=e;i<=n;i++)r.set(t[i],i);return r},fn=hn(class extends Lt{constructor(t){if(super(t),t.type!==Wn.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=Ou(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]=Kt(i[u],o[h]),u++,h++;else if(a[p]===s[f])l[f]=Kt(i[p],o[f]),p--,f--;else if(a[u]===s[f])l[f]=Kt(i[u],o[f]),Zn(t,l[f+1],i[u]),u++,f--;else if(a[p]===s[h])l[h]=Kt(i[p],o[h]),Zn(t,i[u],i[p]),p--,h++;else if(c===void 0&&(c=Hu(s,h,f),d=Hu(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=Zn(t,i[u]);Kt(y,o[h]),l[h]=y}else l[h]=Kt(b,o[h]),Zn(t,i[u],b),i[g]=null;h++}else zo(i[p]),p--;else zo(i[u]),u++;for(;h<=f;){let g=Zn(t,l[f+1]);Kt(g,o[h]),l[h++]=g}for(;u<=p;){let g=i[u++];g!==null&&zo(g)}return this.ut=s,Du(t,l),it}});var Ny=new Intl.Collator("de",{numeric:!0,sensitivity:"base"}),$a=-1,Cu=[{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"}],Lu=t=>t.object_type===1&&Cu.some(e=>e.type===t.module_type);function By(t){let e=new Map(t.map(l=>[l.object_id,l])),n=t.filter(l=>{if(!Lu(l))return!1;let c=new Set([l.object_id]),d=e.get(l.parent_id);for(;d&&!c.has(d.object_id);){if(Lu(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($a,o($a,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 Cu.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,$a,l.name,p,c));for(let h of d)a(h,u,p)}),[...r.values()]}function Sa(t){let e=By(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||Ny.compare(o.name,s.name));return{nodes:n,children:r}}function Ma(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 Ea(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 Ma(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 Nu=["Boolean","Integer","Float","String"],Vy={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 Bu(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:Nu[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=>Nu[c]).join(" oder ")} ben\xF6tigt.`;let o=e.excluded?.(t.entity_id);if(o)return o;let s=Vy[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 Wy=["Kategorie","Instanz","Variable","Skript","Ereignis","Medium","Link"],Ra=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=Sa([]);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=Sa(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 Ma(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=Bu(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=Ea(this.tree,this._expanded,this._query),r=Math.max(0,n.findIndex(s=>s.node.object_id===this._active)),i=n[r];if(!i)return;let o=r;if(e.key==="ArrowDown")o=Math.min(n.length-1,r+1);else if(e.key==="ArrowUp")o=Math.max(0,r-1);else if(e.key==="Home")o=0;else if(e.key==="End")o=n.length-1;else if(e.key==="ArrowRight")i.hasChildren&&!i.expanded?this.toggle(i.node.object_id):i.hasChildren&&(o=Math.min(n.length-1,r+1));else if(e.key==="ArrowLeft")i.expanded&&!this._query?this.toggle(i.node.object_id):o=Math.max(0,n.findIndex(s=>s.node.object_id===i.node.parent_id));else if(e.key===" "||e.key==="Enter")this.select(i.node),e.key==="Enter"&&this.entityFor(i.node)&&this.commit();else return;e.preventDefault(),(o!==r||this._active===null)&&(this._active=n[o].node.object_id),await this.updateComplete,this.renderRoot.querySelector(`#object-${this._active}`)?.scrollIntoView({block:"nearest"})}icon(e){let n=[R``,R``,R``,R``,R``,R``,R``];return R``}renderRow(e){let{node:n}=e,r=this.entityFor(n),i=!!r;return m`
${this.icon(n.object_type)}${n.name||"(Ohne Namen)"} - ${n.virtual?"Systembereich":Dy[n.object_type]??"Objekt"}${n.hidden?" \xB7 ausgeblendet":""} + ${n.virtual?"Systembereich":Wy[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=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`
`}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=Ea(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``:_}
@@ -234,7 +234,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f `)}
`:_}
- ${ln(s,c=>c.node.object_id,c=>this.renderRow(c))} + ${fn(s,c=>c.node.object_id,c=>this.renderRow(c))} ${s.length?_:m`

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

`}
${this._notice?m`
${this._notice}
`:_} @@ -243,7 +243,7 @@ var $={cs:"4be67fcd522e",da:"0fe66a82bf2a",es:"bd89dffd1355",fi:"9a17bc084f56",f
- `}static styles=[fe,J` + `}static styles=[me,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",va);var Hu=40,wa=class extends q{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,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`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,Vu)]}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-Vu)}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=[fe,J` + `}static styles=[me,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",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` + `]};customElements.get("nf-entity-picker")||customElements.define("nf-entity-picker",Aa);var Fa=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=[fe,J` + `}static styles=[me,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",xa);var cn=t=>t.target.value,ka=t=>Number.parseFloat(t.replace(",",".")),ae=t=>Math.round(t*1e3)/1e3,Lu=t=>t.wide?"nf-field nf-wide":"nf-field";function R(t,e,n,r,i=.01,o){return m`