@selvajs/selva 4.21.0-beta.20 → 4.21.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/adapter-node.js +1 -1
- package/build/client/_app/immutable/chunks/C36Kxzt3.js +1 -0
- package/build/client/_app/immutable/chunks/C36Kxzt3.js.br +1 -0
- package/build/client/_app/immutable/chunks/C36Kxzt3.js.gz +0 -0
- package/build/client/_app/immutable/chunks/{D2C9ht__.js → C6zhj8Tc.js} +59 -59
- package/build/client/_app/immutable/chunks/C6zhj8Tc.js.br +0 -0
- package/build/client/_app/immutable/chunks/C6zhj8Tc.js.gz +0 -0
- package/build/client/_app/immutable/entry/{app.D3YN7-nC.js → app.C2KpbBu3.js} +2 -2
- package/build/client/_app/immutable/entry/app.C2KpbBu3.js.br +0 -0
- package/build/client/_app/immutable/entry/app.C2KpbBu3.js.gz +0 -0
- package/build/client/_app/immutable/nodes/21.C3YDbmsU.js +1 -0
- package/build/client/_app/immutable/nodes/21.C3YDbmsU.js.br +0 -0
- package/build/client/_app/immutable/nodes/21.C3YDbmsU.js.gz +0 -0
- package/build/client/_app/version.json +1 -1
- package/build/client/_app/version.json.br +0 -0
- package/build/client/_app/version.json.gz +0 -0
- package/build/server/chunks/capture.js +1 -1
- package/build/server/chunks/instance.js +3 -3
- package/build/server/chunks/internal.js +1 -1
- package/build/server/chunks/package.js +1 -1
- package/build/server/chunks/package.js.map +1 -1
- package/build/server/chunks/schema.js +1 -1
- package/build/server/chunks/schema.js.map +1 -1
- package/build/server/chunks/solve.js +1 -1
- package/build/server/entries/endpoints/mcp/_server.ts.js +6 -2
- package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
- package/build/server/entries/pages/library/_guid_/_page.svelte.js +3 -1
- package/build/server/entries/pages/library/_guid_/_page.svelte.js.map +1 -1
- package/build/server/manifest-full.js +1 -1
- package/build/server/manifest.js +1 -1
- package/build/server/nodes/21.js +1 -1
- package/build/server/server.js +1 -1
- package/package.json +6 -6
- package/build/client/_app/immutable/chunks/D2C9ht__.js.br +0 -0
- package/build/client/_app/immutable/chunks/D2C9ht__.js.gz +0 -0
- package/build/client/_app/immutable/chunks/DIMAEw3m.js +0 -1
- package/build/client/_app/immutable/chunks/DIMAEw3m.js.br +0 -1
- package/build/client/_app/immutable/chunks/DIMAEw3m.js.gz +0 -0
- package/build/client/_app/immutable/entry/app.D3YN7-nC.js.br +0 -0
- package/build/client/_app/immutable/entry/app.D3YN7-nC.js.gz +0 -0
- package/build/client/_app/immutable/nodes/21.BA-9DMG6.js +0 -1
- package/build/client/_app/immutable/nodes/21.BA-9DMG6.js.br +0 -0
- package/build/client/_app/immutable/nodes/21.BA-9DMG6.js.gz +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./71J-lVIC.js","./CRzLMJPS.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./CRzLMJPS.js";import{A as t,At as n,B as r,C as i,D as a,E as o,Et as s,Ft as c,G as l,H as u,It as d,J as f,K as p,L as m,Lt as h,M as g,N as _,Nt as v,O as y,Ot as b,P as x,Pt as S,Q as C,Rt as w,St as T,T as E,U as D,V as O,W as k,X as A,Y as j,Z as M,_ as N,_t as P,a as F,b as I,bt as ee,ct as te,dt as L,et as R,f as z,ft as B,g as ne,ht as re,j as ie,k as ae,kt as V,m as H,mt as U,n as W,o as oe,ot as G,p as se,pt as K,q as ce,r as q,st as le,t as J,tt as Y,u as ue,ut as de,v as fe,w as X,xt as pe,y as me,yt as Z}from"./sphvlIzg.js";import{c as he,o as ge,s as _e,t as ve}from"./C1xbQMZF.js";import{i as ye,r as be,t as xe}from"./BJGlbpZ0.js";import{C as Se,E as Ce,d as we,f as Te,m as Ee,n as De,o as Oe,r as ke,s as Ae,t as je,y as Me}from"./CoRMsLUN.js";import{a as Ne}from"./B3e8ZKjr.js";import{n as Pe}from"./BFJ8iwO4.js";import"./BHnRUwtv.js";import{n as Fe,r as Ie,t as Le}from"./Ca-1xMUo.js";import{_ as Re,a as ze,b as Be,d as Ve,f as He,g as Ue,h as We,l as Ge,m as Ke,n as qe,p as Je,t as Ye,u as Xe,v as Ze,w as Qe,x as $e,y as et}from"./Nv1S5RTq.js";import{t as tt}from"./BbFMtSJ8.js";import{i as nt,n as rt,r as it,t as at}from"./BEzPIk5e.js";import{o as ot}from"./DNFu5yLd.js";import{t as st}from"./B9-uqzXO.js";import{t as ct}from"./BvRGv1MX.js";import{t as lt}from"./Dqc45la5.js";import{t as ut}from"./B187F-XR.js";import{t as dt}from"./BmbAoXqr.js";import{a as ft,o as pt}from"./CivEAG-M.js";import{a as mt,c as ht,d as gt,f as _t,i as vt,l as yt,m as bt,n as xt,o as St,p as Ct,r as wt,s as Tt,t as Et,u as Dt}from"./BSN2qO1R.js";import{t as Ot}from"./Bct5vmEM.js";import{t as kt}from"./nJUe9gXb.js";import{a as At,i as jt,n as Mt,o as Nt,r as Pt,t as Ft}from"./Cms9vBTq.js";import{t as It}from"./1VJx1aVI.js";import{t as Lt}from"./DtmJiR65.js";import{D as Rt,E as zt,G as Bt,K as Vt,L as Ht,M as Ut,T as Wt,U as Gt,V as Kt,h as qt,n as Jt,p as Yt,q as Xt,v as Zt,w as Qt,y as $t,z as en}from"./OznVWGiS.js";import{a as tn,i as nn,n as rn,r as an,t as on}from"./CVl4suwo.js";import{o as sn}from"./Rbl3OsBf.js";import{t as cn}from"./DcS7V4T3.js";import{a as ln,i as un,n as dn,r as fn,t as pn}from"./aBYenH6-.js";import{t as mn}from"./BCgmDXNw.js";import{i as hn,n as gn,r as _n,t as vn}from"./CK2nnbJa.js";import{n as yn,t as bn}from"./DG4fF26P.js";import{t as xn}from"./CUaHcctM.js";import{t as Sn}from"./Cj9-pF71.js";import{n as Cn}from"./BQmUk61d.js";import{t as wn}from"./DIYaLgLs.js";import{t as Tn}from"./DnJObvmm.js";import{t as En}from"./DqR8kuM6.js";var Dn={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`}],[`circle`,{cx:`12`,cy:`13`,r:`3`}]]};Dn.node;var On=new Set([`$$slots`,`$$events`,`$$legacy`]);function kn(e,t){let n=W(t,On);Ie(e,q(()=>n,{get icon(){return Dn}}))}var An={name:`chevrons-down-up`,size:24,node:[[`path`,{d:`m7 20 5-5 5 5`}],[`path`,{d:`m7 4 5 5 5-5`}]]};An.node;var jn=new Set([`$$slots`,`$$events`,`$$legacy`]);function Mn(e,t){let n=W(t,jn);Ie(e,q(()=>n,{get icon(){return An}}))}var Nn={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}],[`path`,{d:`M12 17h.01`}]],aliases:[`help-circle`,`circle-help`]};Nn.node;var Pn=new Set([`$$slots`,`$$events`,`$$legacy`]);function Fn(e,t){let n=W(t,Pn);Ie(e,q(()=>n,{get icon(){return Nn}}))}var In={name:`cuboid`,size:24,node:[[`path`,{d:`M10 22v-8`}],[`path`,{d:`M2.336 8.89 10 14l11.715-7.029`}],[`path`,{d:`M22 14a2 2 0 0 1-.971 1.715l-10 6a2 2 0 0 1-2.138-.05l-6-4A2 2 0 0 1 2 16v-6a2 2 0 0 1 .971-1.715l10-6a2 2 0 0 1 2.138.05l6 4A2 2 0 0 1 22 8z`}]]};In.node;var Ln=new Set([`$$slots`,`$$events`,`$$legacy`]);function Rn(e,t){let n=W(t,Ln);Ie(e,q(()=>n,{get icon(){return In}}))}var zn={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}],[`path`,{d:`m7 10 5 5 5-5`}]]};zn.node;var Bn=new Set([`$$slots`,`$$events`,`$$legacy`]);function Vn(e,t){let n=W(t,Bn);Ie(e,q(()=>n,{get icon(){return zn}}))}var Hn={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]]};Hn.node;var Un=new Set([`$$slots`,`$$events`,`$$legacy`]);function Wn(e,t){let n=W(t,Un);Ie(e,q(()=>n,{get icon(){return Hn}}))}var Gn={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`}],[`path`,{d:`m2 2 20 20`}]]};Gn.node;var Kn=new Set([`$$slots`,`$$events`,`$$legacy`]);function qn(e,t){let n=W(t,Kn);Ie(e,q(()=>n,{get icon(){return Gn}}))}var Jn={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}]]};Jn.node;var Yn=new Set([`$$slots`,`$$events`,`$$legacy`]);function Xn(e,t){let n=W(t,Yn);Ie(e,q(()=>n,{get icon(){return Jn}}))}var Zn={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`}]]};Zn.node;var Qn=new Set([`$$slots`,`$$events`,`$$legacy`]);function $n(e,t){let n=W(t,Qn);Ie(e,q(()=>n,{get icon(){return Zn}}))}var er={name:`grid-3x3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M3 9h18`}],[`path`,{d:`M3 15h18`}],[`path`,{d:`M9 3v18`}],[`path`,{d:`M15 3v18`}]],aliases:[`grid`,`grid-3-x-3`]};er.node;var tr=new Set([`$$slots`,`$$events`,`$$legacy`]);function nr(e,t){let n=W(t,tr);Ie(e,q(()=>n,{get icon(){return er}}))}var rr={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`}]]};rr.node;var ir=new Set([`$$slots`,`$$events`,`$$legacy`]);function ar(e,t){let n=W(t,ir);Ie(e,q(()=>n,{get icon(){return rr}}))}var or={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`}]],aliases:[`layers-3`]};or.node;var sr=new Set([`$$slots`,`$$events`,`$$legacy`]);function cr(e,t){let n=W(t,sr);Ie(e,q(()=>n,{get icon(){return or}}))}var lr={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`}]]};lr.node;var ur=new Set([`$$slots`,`$$events`,`$$legacy`]);function dr(e,t){let n=W(t,ur);Ie(e,q(()=>n,{get icon(){return lr}}))}var fr={name:`loader`,size:24,node:[[`path`,{d:`M12 2v4`}],[`path`,{d:`m16.2 7.8 2.9-2.9`}],[`path`,{d:`M18 12h4`}],[`path`,{d:`m16.2 16.2 2.9 2.9`}],[`path`,{d:`M12 18v4`}],[`path`,{d:`m4.9 19.1 2.9-2.9`}],[`path`,{d:`M2 12h4`}],[`path`,{d:`m4.9 4.9 2.9 2.9`}]]};fr.node;var pr=new Set([`$$slots`,`$$events`,`$$legacy`]);function mr(e,t){let n=W(t,pr);Ie(e,q(()=>n,{get icon(){return fr}}))}var hr={name:`locate-fixed`,size:24,node:[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`}],[`circle`,{cx:`12`,cy:`12`,r:`7`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]]};hr.node;var gr=new Set([`$$slots`,`$$events`,`$$legacy`]);function _r(e,t){let n=W(t,gr);Ie(e,q(()=>n,{get icon(){return hr}}))}var vr={name:`maximize`,size:24,node:[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`}]]};vr.node;var yr=new Set([`$$slots`,`$$events`,`$$legacy`]);function br(e,t){let n=W(t,yr);Ie(e,q(()=>n,{get icon(){return vr}}))}var xr={name:`minimize`,size:24,node:[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`}]]};xr.node;var Sr=new Set([`$$slots`,`$$events`,`$$legacy`]);function Cr(e,t){let n=W(t,Sr);Ie(e,q(()=>n,{get icon(){return xr}}))}var wr={name:`palette`,size:24,node:[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]]};wr.node;var Tr=new Set([`$$slots`,`$$events`,`$$legacy`]);function Er(e,t){let n=W(t,Tr);Ie(e,q(()=>n,{get icon(){return wr}}))}var Dr={name:`pipette`,size:24,node:[[`path`,{d:`m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12`}],[`path`,{d:`m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z`}],[`path`,{d:`m2 22 .414-.414`}]]};Dr.node;var Or=new Set([`$$slots`,`$$events`,`$$legacy`]);function kr(e,t){let n=W(t,Or);Ie(e,q(()=>n,{get icon(){return Dr}}))}var Ar={name:`ruler`,size:24,node:[[`path`,{d:`M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z`}],[`path`,{d:`m14.5 12.5 2-2`}],[`path`,{d:`m11.5 9.5 2-2`}],[`path`,{d:`m8.5 6.5 2-2`}],[`path`,{d:`m17.5 15.5 2-2`}]]};Ar.node;var jr=new Set([`$$slots`,`$$events`,`$$legacy`]);function Mr(e,t){let n=W(t,jr);Ie(e,q(()=>n,{get icon(){return Ar}}))}var Nr={name:`scan`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`}]]};Nr.node;var Pr=new Set([`$$slots`,`$$events`,`$$legacy`]);function Fr(e,t){let n=W(t,Pr);Ie(e,q(()=>n,{get icon(){return Nr}}))}var Ir={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`}],[`path`,{d:`M19 7h-9`}],[`circle`,{cx:`17`,cy:`17`,r:`3`}],[`circle`,{cx:`7`,cy:`7`,r:`3`}]]};Ir.node;var Lr=new Set([`$$slots`,`$$events`,`$$legacy`]);function Rr(e,t){let n=W(t,Lr);Ie(e,q(()=>n,{get icon(){return Ir}}))}var zr={name:`spline`,size:24,node:[[`circle`,{cx:`19`,cy:`5`,r:`2`}],[`circle`,{cx:`5`,cy:`19`,r:`2`}],[`path`,{d:`M5 17A12 12 0 0 1 17 5`}]]};zr.node;var Br=new Set([`$$slots`,`$$events`,`$$legacy`]);function Vr(e,t){let n=W(t,Br);Ie(e,q(()=>n,{get icon(){return zr}}))}var Hr={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`}]]};Hr.node;var Ur=new Set([`$$slots`,`$$events`,`$$legacy`]);function Wr(e,t){let n=W(t,Ur);Ie(e,q(()=>n,{get icon(){return Hr}}))}var Gr={name:`zoom-in`,size:24,node:[[`circle`,{cx:`11`,cy:`11`,r:`8`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`}]]};Gr.node;var Kr=new Set([`$$slots`,`$$events`,`$$legacy`]);function qr(e,t){let n=W(t,Kr);Ie(e,q(()=>n,{get icon(){return Gr}}))}var Jr={name:`zoom-out`,size:24,node:[[`circle`,{cx:`11`,cy:`11`,r:`8`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`}]]};Jr.node;var Yr=new Set([`$$slots`,`$$events`,`$$legacy`]);function Xr(e,t){let n=W(t,Yr);Ie(e,q(()=>n,{get icon(){return Jr}}))}var Zr=Oe({component:`checkbox`,parts:[`root`,`group`,`group-label`,`input`]}),Qr=new Xt(`Checkbox.Group`),$r=new Xt(`Checkbox.Root`),ei=class e{static create(t,n=null){return $r.set(new e(t,n))}opts;group;#e=T(()=>this.group&&this.group.opts.name.current?this.group.opts.name.current:this.opts.name.current);get trueName(){return C(this.#e)}set trueName(e){P(this.#e,e)}#t=T(()=>this.group&&this.group.opts.required.current?!0:this.opts.required.current);get trueRequired(){return C(this.#t)}set trueRequired(e){P(this.#t,e)}#n=T(()=>this.group&&this.group.opts.disabled.current?!0:this.opts.disabled.current);get trueDisabled(){return C(this.#n)}set trueDisabled(e){P(this.#n,e)}#r=T(()=>this.group&&this.group.opts.readonly.current?!0:this.opts.readonly.current);get trueReadonly(){return C(this.#r)}set trueReadonly(e){P(this.#r,e)}attachment;constructor(e,t){this.opts=e,this.group=t,this.attachment=we(this.opts.ref),this.onkeydown=this.onkeydown.bind(this),this.onclick=this.onclick.bind(this),Bt.pre([()=>v(this.group?.opts.value.current),()=>this.opts.value.current],([e,t])=>{e&&t&&(this.opts.checked.current=e.includes(t))}),Bt.pre(()=>this.opts.checked.current,e=>{this.group&&(e?this.group?.addValue(this.opts.value.current):this.group?.removeValue(this.opts.value.current))})}onkeydown(e){this.trueDisabled||this.trueReadonly||(e.key===`Enter`?(e.preventDefault(),this.opts.type.current===`submit`&&(e.currentTarget.form??e.currentTarget.closest(`form`))?.requestSubmit()):e.key===` `&&(e.preventDefault(),this.#i()))}#i(){this.opts.indeterminate.current?(this.opts.indeterminate.current=!1,this.opts.checked.current=!0):this.opts.checked.current=!this.opts.checked.current}onclick(e){this.trueDisabled||this.trueReadonly||(this.opts.type.current===`submit`||e.preventDefault(),this.#i())}#a=T(()=>({checked:this.opts.checked.current,indeterminate:this.opts.indeterminate.current}));get snippetProps(){return C(this.#a)}set snippetProps(e){P(this.#a,e)}#o=T(()=>({id:this.opts.id.current,role:`checkbox`,type:this.opts.type.current,form:this.opts.form.current,disabled:this.trueDisabled,"aria-checked":Ae(this.opts.checked.current,this.opts.indeterminate.current),"aria-required":ke(this.trueRequired),"aria-readonly":ke(this.trueReadonly),"data-disabled":De(this.trueDisabled),"data-readonly":De(this.trueReadonly),"data-state":ni(this.opts.checked.current,this.opts.indeterminate.current),[Zr.root]:``,onclick:this.onclick,onkeydown:this.onkeydown,...this.attachment}));get props(){return C(this.#o)}set props(e){P(this.#o,e)}},ti=class e{static create(){return new e($r.get())}root;#e=T(()=>this.root.group?!!(this.root.opts.value.current!==void 0&&this.root.group.opts.value.current.includes(this.root.opts.value.current)):this.root.opts.checked.current);get trueChecked(){return C(this.#e)}set trueChecked(e){P(this.#e,e)}#t=T(()=>!!this.root.trueName);get shouldRender(){return C(this.#t)}set shouldRender(e){P(this.#t,e)}constructor(e){this.root=e,this.onfocus=this.onfocus.bind(this)}onfocus(e){$t(this.root.opts.ref.current)&&this.root.opts.ref.current.focus()}#n=T(()=>({type:`checkbox`,checked:this.root.opts.checked.current===!0,disabled:this.root.trueDisabled,required:this.root.trueRequired,name:this.root.trueName,form:this.root.opts.form.current,value:this.root.opts.value.current,readonly:this.root.trueReadonly,onfocus:this.onfocus}));get props(){return C(this.#n)}set props(e){P(this.#n,e)}};function ni(e,t){return t?`indeterminate`:e?`checked`:`unchecked`}function ri(e,n){V(n,!0);let r=ti.create();var i=u(),a=B(i),o=e=>{cn(e,q(()=>r.props))};t(a,e=>{r.shouldRender&&e(o)}),O(e,i),b()}var ii=new Set([`$$slots`,`$$events`,`$$legacy`,`checked`,`ref`,`onCheckedChange`,`children`,`disabled`,`required`,`name`,`form`,`value`,`id`,`indeterminate`,`onIndeterminateChange`,`child`,`type`,`readonly`]),ai=D(`<button><!></button>`),oi=D(`<!> <!>`,1);function si(e,n){let r=l();V(n,!0);let i=J(n,`checked`,15,!1),a=J(n,`ref`,15,null),o=J(n,`disabled`,3,!1),s=J(n,`required`,3,!1),d=J(n,`name`,3,void 0),f=J(n,`form`,3,void 0),p=J(n,`value`,3,`on`),m=J(n,`id`,19,()=>je(r)),g=J(n,`indeterminate`,15,!1),_=J(n,`type`,3,`button`),v=W(n,ii),y=Qr.getOr(null);Y(()=>{y&&p()&&(y.opts.value.current.includes(p())?i(!0):i(!1))}),Bt.pre(()=>p(),()=>{y&&p()&&(y.opts.value.current.includes(p())?i(!0):i(!1))});let S=ei.create({checked:Me(()=>i(),e=>{i(e),n.onCheckedChange?.(e)}),disabled:Me(()=>o()??!1),required:Me(()=>s()),name:Me(()=>d()),form:Me(()=>f()),value:Me(()=>p()),id:Me(()=>m()),ref:Me(()=>a(),e=>a(e)),indeterminate:Me(()=>g(),e=>{g(e),n.onIndeterminateChange?.(e)}),type:Me(()=>_()),readonly:Me(()=>!!n.readonly)},y),w=T(()=>Te({...v},S.props));var E=oi(),D=B(E),k=e=>{var t=u(),r=B(t);{let e=T(()=>({props:C(w),...S.snippetProps}));x(r,()=>n.child,()=>C(e))}O(e,t)},A=e=>{var t=ai();z(t,()=>({...C(w)}));var r=L(t);x(r,()=>n.children??h,()=>S.snippetProps),c(t),O(e,t)};t(D,e=>{n.child?e(k):e(A,-1)}),ri(U(D,2),{}),O(e,E),b()}var ci=new Set([`$$slots`,`$$events`,`$$legacy`,`children`,`child`,`ref`,`value`,`onSelect`,`id`,`disabled`,`closeOnSelect`]),li=D(`<div><!></div>`);function ui(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`onSelect`,3,Yt),o=J(n,`id`,19,()=>je(r)),s=J(n,`disabled`,3,!1),d=J(n,`closeOnSelect`,3,!0),f=W(n,ci),p=$e.create({value:Me(()=>n.value),id:Me(()=>o()),disabled:Me(()=>s()),onSelect:Me(()=>m),ref:Me(()=>i(),e=>i(e)),closeOnSelect:Me(()=>d())});function m(e){a()(e),!e.defaultPrevented&&p.selectValue()}let g=T(()=>Te(f,p.props));var _=u(),v=B(_),y=e=>{var t=u(),r=B(t);x(r,()=>n.child,()=>({props:C(g),checked:p.isChecked})),O(e,t)},S=e=>{var t=li();z(t,()=>({...C(g)}));var r=L(t);x(r,()=>n.children??h,()=>({checked:p.isChecked})),c(t),O(e,t)};t(v,e=>{n.child?e(y):e(S,-1)}),O(e,_),b()}var di=new Set([`$$slots`,`$$events`,`$$legacy`,`id`,`children`,`child`,`ref`,`value`,`onValueChange`]),fi=D(`<div><!></div>`);function pi(e,n){let r=l();V(n,!0);let i=J(n,`id`,19,()=>je(r)),a=J(n,`ref`,15,null),o=J(n,`value`,15,``),s=J(n,`onValueChange`,3,Yt),d=W(n,di),f=Be.create({value:Me(()=>o(),e=>{o(e),s()(e)}),ref:Me(()=>a(),e=>a(e)),id:Me(()=>i())}),p=T(()=>Te(d,f.props));var m=u(),g=B(m),_=e=>{var t=u(),r=B(t);x(r,()=>n.child,()=>({props:C(p)})),O(e,t)},v=e=>{var t=fi();z(t,()=>({...C(p)}));var r=L(t);x(r,()=>n.children??h),c(t),O(e,t)};t(g,e=>{n.child?e(_):e(v,-1)}),O(e,m),b()}var mi=new Set([`$$slots`,`$$events`,`$$legacy`,`child`,`children`,`ref`,`checked`,`id`,`onCheckedChange`,`disabled`,`onSelect`,`closeOnSelect`,`indeterminate`,`onIndeterminateChange`,`value`]),hi=D(`<div><!></div>`);function gi(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`checked`,15,!1),o=J(n,`id`,19,()=>je(r)),s=J(n,`onCheckedChange`,3,Yt),d=J(n,`disabled`,3,!1),f=J(n,`onSelect`,3,Yt),p=J(n,`closeOnSelect`,3,!0),m=J(n,`indeterminate`,15,!1),g=J(n,`onIndeterminateChange`,3,Yt),_=J(n,`value`,3,``),v=W(n,mi),y=Ze.getOr(null);Y(()=>{y&&_()&&(y.opts.value.current.includes(_())?a(!0):a(!1))}),Bt.pre(()=>_(),()=>{y&&_()&&(y.opts.value.current.includes(_())?a(!0):a(!1))});let S=et.create({checked:Me(()=>a(),e=>{e!==a()&&(a(e),s()(e))}),id:Me(()=>o()),disabled:Me(()=>d()),onSelect:Me(()=>w),ref:Me(()=>i(),e=>i(e)),closeOnSelect:Me(()=>p()),indeterminate:Me(()=>m(),e=>{e!==m()&&(m(e),g()(e))}),value:Me(()=>_())},y);function w(e){f()(e),!e.defaultPrevented&&S.toggleChecked()}let E=T(()=>Te(v,S.props));var D=u(),k=B(D),A=e=>{var t=u(),r=B(t);x(r,()=>n.child,()=>({checked:a(),indeterminate:m(),props:C(E)})),O(e,t)},j=e=>{var t=hi();z(t,()=>({...C(E)}));var r=L(t);x(r,()=>n.children??h,()=>({checked:a(),indeterminate:m()})),c(t),O(e,t)};t(k,e=>{n.child?e(A):e(j,-1)}),O(e,D),b()}var _i=null,vi=new WeakMap;function yi(){return _i??=new ResizeObserver(e=>{for(let t of e){let e=vi.get(t.target);if(e)for(let t of[...e])t()}}),_i}function bi(e,t){let n=vi.get(e);return n===void 0?(n=new Set,vi.set(e,n),n.add(t),yi().observe(e)):(n.add(t),t()),()=>{let n=vi.get(e);n&&(n.delete(t),!n.size&&(vi.delete(e),_i?.unobserve(e)))}}var xi=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t,this.handler=this.handler.bind(this),le(this.handler)}handler(){let e=0,t=this.#e();if(!t)return;let n=bi(t,()=>{cancelAnimationFrame(e),e=window.requestAnimationFrame(this.#t)});return()=>{window.cancelAnimationFrame(e),n()}}},Si=class{opts;present;#e;#t=Z(!1);#n=!1;#r=Z(void 0);#i=null;constructor(e){this.opts=e,this.present=this.opts.open,P(this.#t,e.open.current,!0),this.#e=new qt({ref:this.opts.ref,afterTick:this.opts.open}),Kt(()=>this.#o()),Bt(()=>this.present.current,e=>{this.#n?(this.#o(),e&&P(this.#t,!0),P(this.#r,e?`starting`:`ending`,!0),e&&(this.#i=window.requestAnimationFrame(()=>{this.#i=null,this.present.current&&P(this.#r,void 0)})),this.#e.run(()=>{e===this.present.current&&(e||P(this.#t,!1),P(this.#r,void 0))})):this.#n=!0})}#a=T(()=>C(this.#t));get isPresent(){return C(this.#a)}set isPresent(e){P(this.#a,e)}get transitionStatus(){return C(this.#r)}#o(){this.#i!==null&&(window.cancelAnimationFrame(this.#i),this.#i=null)}};function Ci(e,n){V(n,!0);let r=new Si({open:Me(()=>n.open),ref:Y(()=>n.ref)});var i=u(),a=B(i),o=e=>{var t=u(),i=B(t);x(i,()=>n.presence??h,()=>({present:r.isPresent,transitionStatus:r.transitionStatus})),O(e,t)};t(a,e=>{(n.forceMount||n.open||r.isPresent)&&e(o)}),O(e,i),b()}function wi(e,t,n){return Math.min(n,Math.max(t,e))}var Ti=class{state;#e;constructor(e,t){this.state=Se(e),this.#e=t,this.dispatch=this.dispatch.bind(this)}#t(e){return this.#e[this.state.current][e]??this.state.current}dispatch(e){this.state.current=this.#t(e)}},Ei=Oe({component:`scroll-area`,parts:[`root`,`viewport`,`corner`,`thumb`,`scrollbar`]}),Di=new Xt(`ScrollArea.Root`),Oi=new Xt(`ScrollArea.Scrollbar`),ki=new Xt(`ScrollArea.ScrollbarVisible`),Ai=new Xt(`ScrollArea.ScrollbarAxis`),ji=new Xt(`ScrollArea.ScrollbarShared`),Mi=class e{static create(t){return Di.set(new e(t))}opts;attachment;#e=Z(null);get scrollAreaNode(){return C(this.#e)}set scrollAreaNode(e){P(this.#e,e,!0)}#t=Z(null);get viewportNode(){return C(this.#t)}set viewportNode(e){P(this.#t,e,!0)}#n=Z(null);get contentNode(){return C(this.#n)}set contentNode(e){P(this.#n,e,!0)}#r=Z(null);get scrollbarXNode(){return C(this.#r)}set scrollbarXNode(e){P(this.#r,e,!0)}#i=Z(null);get scrollbarYNode(){return C(this.#i)}set scrollbarYNode(e){P(this.#i,e,!0)}#a=Z(0);get cornerWidth(){return C(this.#a)}set cornerWidth(e){P(this.#a,e,!0)}#o=Z(0);get cornerHeight(){return C(this.#o)}set cornerHeight(e){P(this.#o,e,!0)}#s=Z(!1);get scrollbarXEnabled(){return C(this.#s)}set scrollbarXEnabled(e){P(this.#s,e,!0)}#c=Z(!1);get scrollbarYEnabled(){return C(this.#c)}set scrollbarYEnabled(e){P(this.#c,e,!0)}domContext;constructor(e){this.opts=e,this.attachment=we(e.ref,e=>this.scrollAreaNode=e),this.domContext=new Ht(e.ref)}#l=T(()=>({id:this.opts.id.current,dir:this.opts.dir.current,style:{position:`relative`,"--bits-scroll-area-corner-height":`${this.cornerHeight}px`,"--bits-scroll-area-corner-width":`${this.cornerWidth}px`},[Ei.root]:``,...this.attachment}));get props(){return C(this.#l)}set props(e){P(this.#l,e)}},Ni=class e{static create(t){return new e(t,Di.get())}opts;root;attachment;#e=Se(Jt());#t=Se(null);contentAttachment=we(this.#t,e=>this.root.contentNode=e);constructor(e,t){this.opts=e,this.root=t,this.attachment=we(e.ref,e=>this.root.viewportNode=e)}#n=T(()=>({id:this.opts.id.current,style:{overflowX:this.root.scrollbarXEnabled?`scroll`:`hidden`,overflowY:this.root.scrollbarYEnabled?`scroll`:`hidden`},[Ei.viewport]:``,...this.attachment}));get props(){return C(this.#n)}set props(e){P(this.#n,e)}#r=T(()=>({id:this.#e.current,"data-scroll-area-content":``,style:{minWidth:this.root.scrollbarXEnabled?`fit-content`:void 0},...this.contentAttachment}));get contentProps(){return C(this.#r)}set contentProps(e){P(this.#r,e)}},Pi=class e{static create(t){return Oi.set(new e(t,Di.get()))}opts;root;#e=T(()=>this.opts.orientation.current===`horizontal`);get isHorizontal(){return C(this.#e)}set isHorizontal(e){P(this.#e,e)}#t=Z(!1);get hasThumb(){return C(this.#t)}set hasThumb(e){P(this.#t,e,!0)}constructor(e,t){this.opts=e,this.root=t,Bt(()=>this.isHorizontal,e=>e?(this.root.scrollbarXEnabled=!0,()=>{this.root.scrollbarXEnabled=!1}):(this.root.scrollbarYEnabled=!0,()=>{this.root.scrollbarYEnabled=!1}))}},Fi=class e{static create(){return new e(Oi.get())}scrollbar;root;#e=Z(!1);get isVisible(){return C(this.#e)}set isVisible(e){P(this.#e,e,!0)}constructor(e){this.scrollbar=e,this.root=e.root,le(()=>{let e=this.root.scrollAreaNode,t=this.root.opts.scrollHideDelay.current,n=0;if(!e)return;let r=Ee(A(e,`pointerenter`,()=>{this.root.domContext.clearTimeout(n),Y(()=>this.isVisible=!0)}),A(e,`pointerleave`,()=>{n&&this.root.domContext.clearTimeout(n),n=this.root.domContext.setTimeout(()=>{Y(()=>{this.scrollbar.hasThumb=!1,this.isVisible=!1})},t)}));return()=>{this.root.domContext.getWindow().clearTimeout(n),r()}})}#t=T(()=>({"data-state":this.isVisible?`visible`:`hidden`}));get props(){return C(this.#t)}set props(e){P(this.#t,e)}},Ii=class e{static create(){return new e(Oi.get())}scrollbar;root;machine=new Ti(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});#e=T(()=>this.machine.state.current===`hidden`);get isHidden(){return C(this.#e)}set isHidden(e){P(this.#e,e)}constructor(e){this.scrollbar=e,this.root=e.root;let t=Vt(()=>this.machine.dispatch(`SCROLL_END`),100);le(()=>{let e=this.machine.state.current,t=this.root.opts.scrollHideDelay.current;if(e===`idle`){let e=this.root.domContext.setTimeout(()=>this.machine.dispatch(`HIDE`),t);return()=>this.root.domContext.clearTimeout(e)}}),le(()=>{let e=this.root.viewportNode;if(!e)return;let n=this.scrollbar.isHorizontal?`scrollLeft`:`scrollTop`,r=e[n];return A(e,`scroll`,()=>{let i=e[n];r!==i&&(this.machine.dispatch(`SCROLL`),t()),r=i})}),this.onpointerenter=this.onpointerenter.bind(this),this.onpointerleave=this.onpointerleave.bind(this)}onpointerenter(e){this.machine.dispatch(`POINTER_ENTER`)}onpointerleave(e){this.machine.dispatch(`POINTER_LEAVE`)}#t=T(()=>({"data-state":this.machine.state.current===`hidden`?`hidden`:`visible`,onpointerenter:this.onpointerenter,onpointerleave:this.onpointerleave}));get props(){return C(this.#t)}set props(e){P(this.#t,e)}},Li=class e{static create(){return new e(Oi.get())}scrollbar;root;#e=Z(!1);get isVisible(){return C(this.#e)}set isVisible(e){P(this.#e,e,!0)}constructor(e){this.scrollbar=e,this.root=e.root;let t=()=>{let e=this.root.viewportNode;if(!e)return;let t=e.offsetWidth<e.scrollWidth,n=e.offsetHeight<e.scrollHeight;this.isVisible=this.scrollbar.isHorizontal?t:n};new xi(()=>this.root.viewportNode,t),new xi(()=>this.root.contentNode,t)}#t=T(()=>({"data-state":this.isVisible?`visible`:`hidden`}));get props(){return C(this.#t)}set props(e){P(this.#t,e)}},Ri=class e{static create(){return ki.set(new e(Oi.get()))}scrollbar;root;#e=Z(null);get thumbNode(){return C(this.#e)}set thumbNode(e){P(this.#e,e,!0)}#t=Z(0);get pointerOffset(){return C(this.#t)}set pointerOffset(e){P(this.#t,e,!0)}#n=Z({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}});get sizes(){return C(this.#n)}set sizes(e){P(this.#n,e)}#r=T(()=>Gi(this.sizes.viewport,this.sizes.content));get thumbRatio(){return C(this.#r)}set thumbRatio(e){P(this.#r,e)}#i=T(()=>this.thumbRatio>0&&this.thumbRatio<1);get hasThumb(){return C(this.#i)}set hasThumb(e){P(this.#i,e)}#a=Z(``);get prevTransformStyle(){return C(this.#a)}set prevTransformStyle(e){P(this.#a,e,!0)}constructor(e){this.scrollbar=e,this.root=e.root,le(()=>{this.scrollbar.hasThumb=this.hasThumb}),le(()=>{!this.scrollbar.hasThumb&&this.thumbNode&&(this.prevTransformStyle=this.thumbNode.style.transform)})}setSizes(e){this.sizes=e}getScrollPosition(e,t){return qi({pointerPos:e,pointerOffset:this.pointerOffset,sizes:this.sizes,dir:t})}onThumbPointerUp(){this.pointerOffset=0}onThumbPointerDown(e){this.pointerOffset=e}xOnThumbPositionChange(){if(!(this.root.viewportNode&&this.thumbNode))return;let e=this.root.viewportNode.scrollLeft,t=`translate3d(${Ji({scrollPos:e,sizes:this.sizes,dir:this.root.opts.dir.current})}px, 0, 0)`;this.thumbNode.style.transform=t,this.prevTransformStyle=t}xOnWheelScroll(e){this.root.viewportNode&&(this.root.viewportNode.scrollLeft=e)}xOnDragScroll(e){this.root.viewportNode&&(this.root.viewportNode.scrollLeft=this.getScrollPosition(e,this.root.opts.dir.current))}yOnThumbPositionChange(){if(!(this.root.viewportNode&&this.thumbNode))return;let e=this.root.viewportNode.scrollTop,t=`translate3d(0, ${Ji({scrollPos:e,sizes:this.sizes})}px, 0)`;this.thumbNode.style.transform=t,this.prevTransformStyle=t}yOnWheelScroll(e){this.root.viewportNode&&(this.root.viewportNode.scrollTop=e)}yOnDragScroll(e){this.root.viewportNode&&(this.root.viewportNode.scrollTop=this.getScrollPosition(e,this.root.opts.dir.current))}},zi=class e{static create(t){return Ai.set(new e(t,ki.get()))}opts;scrollbarVis;root;scrollbar;attachment;#e=Z();get computedStyle(){return C(this.#e)}set computedStyle(e){P(this.#e,e,!0)}constructor(e,t){this.opts=e,this.scrollbarVis=t,this.root=t.root,this.scrollbar=t.scrollbar,this.attachment=we(this.scrollbar.opts.ref,e=>this.root.scrollbarXNode=e),le(()=>{this.scrollbar.opts.ref.current&&this.opts.mounted.current&&(this.computedStyle=getComputedStyle(this.scrollbar.opts.ref.current))}),le(()=>{this.onResize()})}onThumbPointerDown=e=>{this.scrollbarVis.onThumbPointerDown(e.x)};onDragScroll=e=>{this.scrollbarVis.xOnDragScroll(e.x)};onThumbPointerUp=()=>{this.scrollbarVis.onThumbPointerUp()};onThumbPositionChange=()=>{this.scrollbarVis.xOnThumbPositionChange()};onWheelScroll=(e,t)=>{if(!this.root.viewportNode)return;let n=this.root.viewportNode.scrollLeft+e.deltaX;this.scrollbarVis.xOnWheelScroll(n),Xi(n,t)&&e.preventDefault()};onResize=()=>{this.scrollbar.opts.ref.current&&this.root.viewportNode&&this.computedStyle&&this.scrollbarVis.setSizes({content:this.root.viewportNode.scrollWidth,viewport:this.root.viewportNode.offsetWidth,scrollbar:{size:this.scrollbar.opts.ref.current.clientWidth,paddingStart:Wi(this.computedStyle.paddingLeft),paddingEnd:Wi(this.computedStyle.paddingRight)}})};#t=T(()=>Ki(this.scrollbarVis.sizes));get thumbSize(){return C(this.#t)}set thumbSize(e){P(this.#t,e)}#n=T(()=>({id:this.scrollbar.opts.id.current,"data-orientation":`horizontal`,style:{bottom:0,left:this.root.opts.dir.current===`rtl`?`var(--bits-scroll-area-corner-width)`:0,right:this.root.opts.dir.current===`ltr`?`var(--bits-scroll-area-corner-width)`:0,"--bits-scroll-area-thumb-width":`${this.thumbSize}px`},...this.attachment}));get props(){return C(this.#n)}set props(e){P(this.#n,e)}},Bi=class e{static create(t){return Ai.set(new e(t,ki.get()))}opts;scrollbarVis;root;scrollbar;attachment;#e=Z();get computedStyle(){return C(this.#e)}set computedStyle(e){P(this.#e,e,!0)}constructor(e,t){this.opts=e,this.scrollbarVis=t,this.root=t.root,this.scrollbar=t.scrollbar,this.attachment=we(this.scrollbar.opts.ref,e=>this.root.scrollbarYNode=e),le(()=>{this.scrollbar.opts.ref.current&&this.opts.mounted.current&&(this.computedStyle=getComputedStyle(this.scrollbar.opts.ref.current))}),le(()=>{this.onResize()}),this.onThumbPointerDown=this.onThumbPointerDown.bind(this),this.onDragScroll=this.onDragScroll.bind(this),this.onThumbPointerUp=this.onThumbPointerUp.bind(this),this.onThumbPositionChange=this.onThumbPositionChange.bind(this),this.onWheelScroll=this.onWheelScroll.bind(this),this.onResize=this.onResize.bind(this)}onThumbPointerDown(e){this.scrollbarVis.onThumbPointerDown(e.y)}onDragScroll(e){this.scrollbarVis.yOnDragScroll(e.y)}onThumbPointerUp(){this.scrollbarVis.onThumbPointerUp()}onThumbPositionChange(){this.scrollbarVis.yOnThumbPositionChange()}onWheelScroll(e,t){if(!this.root.viewportNode)return;let n=this.root.viewportNode.scrollTop+e.deltaY;this.scrollbarVis.yOnWheelScroll(n),Xi(n,t)&&e.preventDefault()}onResize(){this.scrollbar.opts.ref.current&&this.root.viewportNode&&this.computedStyle&&this.scrollbarVis.setSizes({content:this.root.viewportNode.scrollHeight,viewport:this.root.viewportNode.offsetHeight,scrollbar:{size:this.scrollbar.opts.ref.current.clientHeight,paddingStart:Wi(this.computedStyle.paddingTop),paddingEnd:Wi(this.computedStyle.paddingBottom)}})}#t=T(()=>Ki(this.scrollbarVis.sizes));get thumbSize(){return C(this.#t)}set thumbSize(e){P(this.#t,e)}#n=T(()=>({id:this.scrollbar.opts.id.current,"data-orientation":`vertical`,style:{top:0,right:this.root.opts.dir.current===`ltr`?0:void 0,left:this.root.opts.dir.current===`rtl`?0:void 0,bottom:`var(--bits-scroll-area-corner-height)`,"--bits-scroll-area-thumb-height":`${this.thumbSize}px`},...this.attachment}));get props(){return C(this.#n)}set props(e){P(this.#n,e)}},Vi=class e{static create(){return ji.set(new e(Ai.get()))}scrollbarState;root;scrollbarVis;scrollbar;#e=Z(null);get rect(){return C(this.#e)}set rect(e){P(this.#e,e)}#t=Z(``);get prevWebkitUserSelect(){return C(this.#t)}set prevWebkitUserSelect(e){P(this.#t,e,!0)}handleResize;handleThumbPositionChange;handleWheelScroll;handleThumbPointerDown;handleThumbPointerUp;#n=T(()=>this.scrollbarVis.sizes.content-this.scrollbarVis.sizes.viewport);get maxScrollPos(){return C(this.#n)}set maxScrollPos(e){P(this.#n,e)}constructor(e){this.scrollbarState=e,this.root=e.root,this.scrollbarVis=e.scrollbarVis,this.scrollbar=e.scrollbarVis.scrollbar,this.handleResize=()=>this.scrollbarState.onResize(),this.handleThumbPositionChange=this.scrollbarState.onThumbPositionChange,this.handleWheelScroll=this.scrollbarState.onWheelScroll,this.handleThumbPointerDown=this.scrollbarState.onThumbPointerDown,this.handleThumbPointerUp=this.scrollbarState.onThumbPointerUp,le(()=>{let e=this.maxScrollPos,t=this.scrollbar.opts.ref.current;return this.root.viewportNode,A(this.root.domContext.getDocument(),`wheel`,n=>{let r=n.target;t?.contains(r)&&this.handleWheelScroll(n,e)},{passive:!1})}),te(()=>{this.scrollbarVis.sizes,Y(()=>this.handleThumbPositionChange())}),new xi(()=>this.scrollbar.opts.ref.current,this.handleResize),new xi(()=>this.root.contentNode,this.handleResize),this.onpointerdown=this.onpointerdown.bind(this),this.onpointermove=this.onpointermove.bind(this),this.onpointerup=this.onpointerup.bind(this),this.onlostpointercapture=this.onlostpointercapture.bind(this)}handleDragScroll(e){if(!this.rect)return;let t=e.clientX-this.rect.left,n=e.clientY-this.rect.top;this.scrollbarState.onDragScroll({x:t,y:n})}#r(){this.rect!==null&&(this.root.domContext.getDocument().body.style.webkitUserSelect=this.prevWebkitUserSelect,this.root.viewportNode&&(this.root.viewportNode.style.scrollBehavior=``),this.rect=null)}onpointerdown(e){e.button===0&&(e.target.setPointerCapture(e.pointerId),this.rect=this.scrollbar.opts.ref.current?.getBoundingClientRect()??null,this.prevWebkitUserSelect=this.root.domContext.getDocument().body.style.webkitUserSelect,this.root.domContext.getDocument().body.style.webkitUserSelect=`none`,this.root.viewportNode&&(this.root.viewportNode.style.scrollBehavior=`auto`),this.handleDragScroll(e))}onpointermove(e){this.handleDragScroll(e)}onpointerup(e){let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),this.#r()}onlostpointercapture(e){this.#r()}#i=T(()=>Te({...this.scrollbarState.props,style:{position:`absolute`,...this.scrollbarState.props.style},[Ei.scrollbar]:``,onpointerdown:this.onpointerdown,onpointermove:this.onpointermove,onpointerup:this.onpointerup,onlostpointercapture:this.onlostpointercapture}));get props(){return C(this.#i)}set props(e){P(this.#i,e)}},Hi=class e{static create(t){return new e(t,ji.get())}opts;scrollbarState;attachment;#e;#t=Z();#n=Vt(()=>{C(this.#t)&&(C(this.#t)(),P(this.#t,void 0))},100);constructor(e,t){this.opts=e,this.scrollbarState=t,this.#e=t.root,this.attachment=we(this.opts.ref,e=>this.scrollbarState.scrollbarVis.thumbNode=e),le(()=>{let e=this.#e.viewportNode;return e?(Y(()=>this.scrollbarState.handleThumbPositionChange()),A(e,`scroll`,()=>{if(this.#n(),!C(this.#t)){let t=Zi(e,this.scrollbarState.handleThumbPositionChange);P(this.#t,t,!0),this.scrollbarState.handleThumbPositionChange()}})):void 0}),this.onpointerdowncapture=this.onpointerdowncapture.bind(this),this.onpointerup=this.onpointerup.bind(this)}onpointerdowncapture(e){let t=e.target;if(!t)return;let n=t.getBoundingClientRect(),r=e.clientX-n.left,i=e.clientY-n.top;this.scrollbarState.handleThumbPointerDown({x:r,y:i})}onpointerup(e){this.scrollbarState.handleThumbPointerUp()}#r=T(()=>({id:this.opts.id.current,"data-state":this.scrollbarState.scrollbarVis.hasThumb?`visible`:`hidden`,style:{width:`var(--bits-scroll-area-thumb-width)`,height:`var(--bits-scroll-area-thumb-height)`,transform:this.scrollbarState.scrollbarVis.prevTransformStyle},onpointerdowncapture:this.onpointerdowncapture,onpointerup:this.onpointerup,[Ei.thumb]:``,...this.attachment}));get props(){return C(this.#r)}set props(e){P(this.#r,e)}},Ui=class e{static create(t){return new e(t,Di.get())}opts;root;attachment;#e=Z(0);#t=Z(0);#n=T(()=>!!(C(this.#e)&&C(this.#t)));get hasSize(){return C(this.#n)}set hasSize(e){P(this.#n,e)}constructor(e,t){this.opts=e,this.root=t,this.attachment=we(this.opts.ref),new xi(()=>this.root.scrollbarXNode,()=>{let e=this.root.scrollbarXNode?.offsetHeight||0;this.root.cornerHeight=e,P(this.#t,e,!0)}),new xi(()=>this.root.scrollbarYNode,()=>{let e=this.root.scrollbarYNode?.offsetWidth||0;this.root.cornerWidth=e,P(this.#e,e,!0)})}#r=T(()=>({id:this.opts.id.current,style:{width:C(this.#e),height:C(this.#t),position:`absolute`,right:this.root.opts.dir.current===`ltr`?0:void 0,left:this.root.opts.dir.current===`rtl`?0:void 0,bottom:0},[Ei.corner]:``,...this.attachment}));get props(){return C(this.#r)}set props(e){P(this.#r,e)}};function Wi(e){return e?Number.parseInt(e,10):0}function Gi(e,t){let n=e/t;return Number.isNaN(n)?0:n}function Ki(e){let t=Gi(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function qi({pointerPos:e,pointerOffset:t,sizes:n,dir:r=`ltr`}){let i=Ki(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return Yi([c,l],d)(e)}function Ji({scrollPos:e,sizes:t,dir:n=`ltr`}){let r=Ki(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=n===`ltr`?[0,o]:[o*-1,0],l=wi(e,c[0],c[1]);return Yi([0,o],[0,s])(l)}function Yi(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Xi(e,t){return e>0&&e<t}function Zi(e,t){let n={left:e.scrollLeft,top:e.scrollTop},r=0,i=en(e);return(function a(){let o={left:e.scrollLeft,top:e.scrollTop},s=n.left!==o.left,c=n.top!==o.top;(s||c)&&t(),n=o,r=i.requestAnimationFrame(a)})(),()=>i.cancelAnimationFrame(r)}var Qi=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`id`,`type`,`dir`,`scrollHideDelay`,`children`,`child`]),$i=D(`<div><!></div>`);function ea(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`id`,19,()=>je(r)),o=J(n,`type`,3,`hover`),s=J(n,`dir`,3,`ltr`),d=J(n,`scrollHideDelay`,3,600),f=W(n,Qi),p=Mi.create({type:Me(()=>o()),dir:Me(()=>s()),scrollHideDelay:Me(()=>d()),id:Me(()=>a()),ref:Me(()=>i(),e=>i(e))}),m=T(()=>Te(f,p.props));var g=u(),_=B(g),v=e=>{var t=u(),r=B(t);x(r,()=>n.child,()=>({props:C(m)})),O(e,t)},y=e=>{var t=$i();z(t,()=>({...C(m)}));var r=L(t);x(r,()=>n.children??h),c(t),O(e,t)};t(_,e=>{n.child?e(v):e(y,-1)}),O(e,g),b()}var ta=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`id`,`children`]),na=D(`<div><div><!></div></div>`);function ra(e,t){let n=l();V(t,!0);let r=J(t,`ref`,15,null),i=J(t,`id`,19,()=>je(n)),a=W(t,ta),o=Ni.create({id:Me(()=>i()),ref:Me(()=>r(),e=>r(e))}),s=T(()=>Te(a,o.props)),u=T(()=>Te({},o.contentProps));var d=na();z(d,()=>({...C(s)}));var f=L(d);z(f,()=>({...C(u)}));var p=L(f);x(p,()=>t.children??h),c(f),c(d),O(e,d),b()}var ia=new Set([`$$slots`,`$$events`,`$$legacy`,`child`,`children`]),aa=D(`<div><!></div>`);function oa(e,n){V(n,!0);let r=W(n,ia),i=Vi.create(),a=T(()=>Te(r,i.props));var o=u(),s=B(o),l=e=>{var t=u(),r=B(t);x(r,()=>n.child,()=>({props:C(a)})),O(e,t)},d=e=>{var t=aa();z(t,()=>({...C(a)}));var r=L(t);x(r,()=>n.children??h),c(t),O(e,t)};t(s,e=>{n.child?e(l):e(d,-1)}),O(e,o),b()}var sa=new Set([`$$slots`,`$$events`,`$$legacy`]);function ca(e,t){V(t,!0);let n=W(t,sa),r=new Gt,i=zi.create({mounted:Me(()=>r.current)}),a=T(()=>Te(n,i.props));oa(e,q(()=>C(a))),b()}var la=new Set([`$$slots`,`$$events`,`$$legacy`]);function ua(e,t){V(t,!0);let n=W(t,la),r=new Gt,i=Bi.create({mounted:Me(()=>r.current)}),a=T(()=>Te(n,i.props));oa(e,q(()=>C(a))),b()}var da=new Set([`$$slots`,`$$events`,`$$legacy`]);function fa(e,n){V(n,!0);let r=W(n,da),i=Ri.create();var a=u(),o=B(a),s=e=>{ca(e,q(()=>r))},c=e=>{ua(e,q(()=>r))};t(o,e=>{i.scrollbar.opts.orientation.current===`horizontal`?e(s):e(c,-1)}),O(e,a),b()}var pa=new Set([`$$slots`,`$$events`,`$$legacy`,`forceMount`]);function ma(e,t){V(t,!0);let n=J(t,`forceMount`,3,!1),r=W(t,pa),i=Li.create(),a=T(()=>Te(r,i.props));{let t=e=>{fa(e,q(()=>C(a)))},r=T(()=>n()||i.isVisible);Ci(e,{get open(){return C(r)},get ref(){return i.scrollbar.opts.ref},presence:t,$$slots:{presence:!0}})}b()}var ha=new Set([`$$slots`,`$$events`,`$$legacy`,`forceMount`]);function ga(e,t){V(t,!0);let n=J(t,`forceMount`,3,!1),r=W(t,ha),i=Ii.create(),a=T(()=>Te(r,i.props));{let t=e=>{fa(e,q(()=>C(a)))},r=T(()=>n()||!i.isHidden);Ci(e,q(()=>C(a),{get open(){return C(r)},get ref(){return i.scrollbar.opts.ref},presence:t,$$slots:{presence:!0}}))}b()}var _a=new Set([`$$slots`,`$$events`,`$$legacy`,`forceMount`]);function va(e,t){V(t,!0);let n=J(t,`forceMount`,3,!1),r=W(t,_a),i=Fi.create(),a=Li.create(),o=T(()=>Te(r,i.props,a.props,{"data-state":i.isVisible?`visible`:`hidden`})),s=T(()=>n()||i.isVisible&&a.isVisible);Ci(e,{get open(){return C(s)},get ref(){return a.scrollbar.opts.ref},presence:e=>{fa(e,q(()=>C(o)))},$$slots:{presence:!0}}),b()}var ya=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`id`,`orientation`]);function ba(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`id`,19,()=>je(r)),o=W(n,ya),s=Pi.create({orientation:Me(()=>n.orientation),id:Me(()=>a()),ref:Me(()=>i(),e=>i(e))}),c=T(()=>s.root.opts.type.current);var d=u(),f=B(d),p=e=>{va(e,q(()=>o,{get id(){return a()}}))},m=e=>{ga(e,q(()=>o,{get id(){return a()}}))},h=e=>{ma(e,q(()=>o,{get id(){return a()}}))},g=e=>{fa(e,q(()=>o,{get id(){return a()}}))};t(f,e=>{C(c)===`hover`?e(p):C(c)===`scroll`?e(m,1):C(c)===`auto`?e(h,2):C(c)===`always`&&e(g,3)}),O(e,d),b()}var xa=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`id`,`child`,`children`,`present`]),Sa=D(`<div><!></div>`);function Ca(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=W(n,xa),a=new Gt,o=Hi.create({id:Me(()=>n.id),ref:Me(()=>r(),e=>r(e)),mounted:Me(()=>a.current)}),s=T(()=>Te(i,o.props,{style:{hidden:!n.present}}));var l=u(),d=B(l),f=e=>{var t=u(),r=B(t);x(r,()=>n.child,()=>({props:C(s)})),O(e,t)},p=e=>{var t=Sa();z(t,()=>({...C(s)}));var r=L(t);x(r,()=>n.children??h),c(t),O(e,t)};t(d,e=>{n.child?e(f):e(p,-1)}),O(e,l),b()}var wa=new Set([`$$slots`,`$$events`,`$$legacy`,`id`,`ref`,`forceMount`]);function Ta(e,t){let n=l();V(t,!0);let r=J(t,`id`,19,()=>je(n)),i=J(t,`ref`,15,null),a=J(t,`forceMount`,3,!1),o=W(t,wa),s=ki.get();{let t=(e,t)=>{let n=()=>(t?.()).present;Ca(e,q(()=>o,{get id(){return r()},get present(){return n()},get ref(){return i()},set ref(e){i(e)}}))},n=T(()=>a()||s.hasThumb);Ci(e,{get open(){return C(n)},get ref(){return s.scrollbar.opts.ref},presence:t,$$slots:{presence:!0}})}b()}var Ea=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`id`,`children`,`child`]),Da=D(`<div><!></div>`);function Oa(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=W(n,Ea),a=Ui.create({id:Me(()=>n.id),ref:Me(()=>r(),e=>r(e))}),o=T(()=>Te(i,a.props));var s=u(),l=B(s),d=e=>{var t=u(),r=B(t);x(r,()=>n.child,()=>({props:C(o)})),O(e,t)},f=e=>{var t=Da();z(t,()=>({...C(o)}));var r=L(t);x(r,()=>n.children??h),c(t),O(e,t)};t(l,e=>{n.child?e(d):e(f,-1)}),O(e,s),b()}var ka=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`id`]);function Aa(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`id`,19,()=>je(r)),o=W(n,ka),s=Di.get(),c=T(()=>!!(s.scrollbarXNode&&s.scrollbarYNode)),d=T(()=>s.opts.type.current!==`scroll`&&C(c));var f=u(),p=B(f),m=e=>{Oa(e,q(()=>o,{get id(){return a()},get ref(){return i()},set ref(e){i(e)}}))};t(p,e=>{C(d)&&e(m)}),O(e,f),b()}function ja(e,t,n){let r={position:`absolute`};return e===`lr`?(r.left=`${t}%`,r.right=`${n}%`):e===`rl`?(r.right=`${t}%`,r.left=`${n}%`):e===`bt`?(r.bottom=`${t}%`,r.top=`${n}%`):(r.top=`${t}%`,r.bottom=`${n}%`),r}function Ma(e,t){let n={position:`absolute`};return e===`lr`?(n.left=`${t}%`,n.translate=`-50% 0`):e===`rl`?(n.right=`${t}%`,n.translate=`50% 0`):e===`bt`?(n.bottom=`${t}%`,n.translate=`0 50%`):(n.top=`${t}%`,n.translate=`0 -50%`),n}function Na(e,t,n){let r={position:`absolute`};return e===`lr`?(r.left=`${t}%`,r.translate=`${n}% 0`):e===`rl`?(r.right=`${t}%`,r.translate=`${-n}% 0`):e===`bt`?(r.bottom=`${t}%`,r.translate=`0 ${-n}%`):(r.top=`${t}%`,r.translate=`0 ${n}%`),r}function Pa(e){if(Math.floor(e)===e)return 0;let t=e.toString();if(t.indexOf(`.`)!==-1&&t.indexOf(`e-`)===-1)return t.split(`.`)[1].length;if(t.indexOf(`e-`)!==-1){let e=t.split(`e-`);return parseInt(e[1],10)}return 0}function Fa(e,t){let n=10**t;return Math.round(e*n)/n}function Ia(e,t,n){if(typeof e==`number`){if(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(e)||e<=0)throw Error(`Slider requires finite \`min\` and \`max\` values and a finite \`step\` greater than 0. Received min=${t}, max=${n}, step=${e}.`);let r=n-t,i=Math.ceil(r/e),a=Pa(e),o=10**a;Math.round(r*o)%Math.round(e*o)===0&&i++;let s=[];for(let n=0;n<i;n++){let r=Fa(t+n*e,a);s.push(r)}return s}return[...new Set(e)].filter(e=>e>=t&&e<=n).sort((e,t)=>e-t)}function La(e,t){if(t.length===0)return e;let n=t[0],r=Math.abs(e-n);for(let i of t){let t=Math.abs(e-i);t<r&&(r=t,n=i)}return n}function Ra(e,t,n){let r=t.indexOf(e);return r===-1?La(e,t):n===`next`?r<t.length-1?t[r+1]:e:r>0?t[r-1]:e}function za(e,t,n=!0){let[r,i]=e,[a,o]=t,s=(o-a)/(i-r);return e=>{let t=a+s*(e-r);return n?t>Math.max(a,o)?Math.max(a,o):t<Math.min(a,o)?Math.min(a,o):t:t}}var Ba=Oe({component:`slider`,parts:[`root`,`thumb`,`range`,`tick`,`tick-label`,`thumb-label`]}),Va=new Xt(`Slider.Root`),Ha=class{opts;attachment;#e=Z(!1);get isActive(){return C(this.#e)}set isActive(e){P(this.#e,e,!0)}#t=Z(0);#n=T(()=>this.opts.orientation.current===`horizontal`?this.opts.dir.current===`rtl`?`rl`:`lr`:this.opts.dir.current===`rtl`?`tb`:`bt`);get direction(){return C(this.#n)}set direction(e){P(this.#n,e)}#r=T(()=>Ia(this.opts.step.current,this.opts.min.current,this.opts.max.current));get normalizedSteps(){return C(this.#r)}set normalizedSteps(e){P(this.#r,e)}domContext;constructor(e){this.opts=e,this.attachment=we(e.ref),this.domContext=new Ht(this.opts.ref),new xi(()=>this.opts.ref.current,this.#i)}#i=()=>{P(this.#t,C(this.#t)+1)};isThumbActive(e){return this.isActive}#a=T(()=>{if(!this.opts.disabled.current)return this.opts.orientation.current===`horizontal`?`pan-y`:`pan-x`});getAllThumbs=()=>{let e=this.opts.ref.current;return e?Array.from(e.querySelectorAll(Ba.selector(`thumb`))):[]};getThumbScale=()=>{C(this.#t);let e=this.opts.trackPadding?.current;if(e!==void 0&&e>0)return[e,100-e];if(this.opts.thumbPositioning.current===`exact`)return[0,100];let t=this.opts.orientation.current===`vertical`,n=this.getAllThumbs()[0],r=t?n?.offsetHeight:n?.offsetWidth;if(r===void 0||Number.isNaN(r)||r===0)return[0,100];let i=t?this.opts.ref.current?.offsetHeight:this.opts.ref.current?.offsetWidth;if(i===void 0||Number.isNaN(i)||i===0)return[0,100];let a=r/2/i*100;return[a,100-a]};getPositionFromValue=e=>{let t=this.getThumbScale();return za([this.opts.min.current,this.opts.max.current],t)(e)};#o=T(()=>({id:this.opts.id.current,"data-orientation":this.opts.orientation.current,"data-disabled":De(this.opts.disabled.current),style:{touchAction:C(this.#a)},[Ba.root]:``,...this.attachment}));get props(){return C(this.#o)}set props(e){P(this.#o,e)}},Ua=class extends Ha{opts;isMulti=!1;constructor(e){super(e),this.opts=e,tn(()=>Ee(A(this.domContext.getDocument(),`pointerdown`,this.handlePointerDown),A(this.domContext.getDocument(),`pointerup`,this.handlePointerUp),A(this.domContext.getDocument(),`pointermove`,this.handlePointerMove),A(this.domContext.getDocument(),`pointerleave`,this.handlePointerUp))),Bt([()=>this.opts.step.current,()=>this.opts.min.current,()=>this.opts.max.current,()=>this.opts.value.current],([e,t,n,r])=>{let i=Ia(e,t,n),a=e=>i.includes(e),o=e=>La(e,i);a(r)||(this.opts.value.current=o(r))})}isTickValueSelected=e=>this.opts.value.current===e;applyPosition({clientXY:e,start:t,end:n}){let r=this.opts.min.current,i=this.opts.max.current,a=(e-t)/(n-t)*(i-r)+r;if(a<r)this.updateValue(r);else if(a>i)this.updateValue(i);else{let e=this.normalizedSteps,t=La(a,e);this.updateValue(t)}}updateValue=e=>{this.opts.value.current=La(e,this.normalizedSteps)};handlePointerMove=e=>{if(!this.isActive||this.opts.disabled.current)return;e.preventDefault(),e.stopPropagation();let t=this.opts.ref.current,n=this.getAllThumbs()[0];if(!t||!n)return;n.focus();let{left:r,right:i,top:a,bottom:o}=t.getBoundingClientRect();this.direction===`lr`?this.applyPosition({clientXY:e.clientX,start:r,end:i}):this.direction===`rl`?this.applyPosition({clientXY:e.clientX,start:i,end:r}):this.direction===`bt`?this.applyPosition({clientXY:e.clientY,start:o,end:a}):this.direction===`tb`&&this.applyPosition({clientXY:e.clientY,start:a,end:o})};handlePointerDown=e=>{if(e.button!==0||this.opts.disabled.current)return;let t=this.opts.ref.current,n=this.getAllThumbs()[0];if(!n||!t)return;let r=e.composedPath()[0]??e.target;Zt(r)&&t.contains(r)&&(e.preventDefault(),n.focus(),this.isActive=!0,this.handlePointerMove(e))};handlePointerUp=()=>{this.opts.disabled.current||(this.isActive&&this.opts.onValueCommit.current(Y(()=>this.opts.value.current)),this.isActive=!1)};#e=T(()=>{let e=this.opts.value.current;return Array.from({length:1},()=>{let t=e,n=this.getPositionFromValue(t),r=Ma(this.direction,n);return{role:`slider`,"aria-valuemin":this.opts.min.current,"aria-valuemax":this.opts.max.current,"aria-valuenow":t,"aria-disabled":ke(this.opts.disabled.current),"aria-orientation":this.opts.orientation.current,"data-value":t,"data-orientation":this.opts.orientation.current,style:r,[Ba.thumb]:``}})});get thumbsPropsArr(){return C(this.#e)}set thumbsPropsArr(e){P(this.#e,e)}#t=T(()=>this.thumbsPropsArr.map((e,t)=>t));get thumbsRenderArr(){return C(this.#t)}set thumbsRenderArr(e){P(this.#t,e)}#n=T(()=>{let e=this.normalizedSteps,t=this.opts.value.current;return e.map((n,r)=>{let i=this.getPositionFromValue(n),a=r===0,o=r===e.length-1,s=a?0:o?-100:-50,c=Na(this.direction,i,s),l=n<=t;return{"data-disabled":De(this.opts.disabled.current),"data-orientation":this.opts.orientation.current,"data-bounded":l?``:void 0,"data-value":n,"data-selected":this.isTickValueSelected(n)?``:void 0,style:c,[Ba.tick]:``}})});get ticksPropsArr(){return C(this.#n)}set ticksPropsArr(e){P(this.#n,e)}#r=T(()=>this.ticksPropsArr.map((e,t)=>t));get ticksRenderArr(){return C(this.#r)}set ticksRenderArr(e){P(this.#r,e)}#i=T(()=>this.ticksPropsArr.map((e,t)=>({value:e[`data-value`],index:t})));get tickItemsArr(){return C(this.#i)}set tickItemsArr(e){P(this.#i,e)}#a=T(()=>[{value:this.opts.value.current,index:0}]);get thumbItemsArr(){return C(this.#a)}set thumbItemsArr(e){P(this.#a,e)}#o=T(()=>({ticks:this.ticksRenderArr,thumbs:this.thumbsRenderArr,tickItems:this.tickItemsArr,thumbItems:this.thumbItemsArr}));get snippetProps(){return C(this.#o)}set snippetProps(e){P(this.#o,e)}},Wa=class extends Ha{opts;isMulti=!0;#e=Z(null);get activeThumb(){return C(this.#e)}set activeThumb(e){P(this.#e,e,!0)}#t=Z(0);get currentThumbIdx(){return C(this.#t)}set currentThumbIdx(e){P(this.#t,e,!0)}constructor(e){super(e),this.opts=e,tn(()=>Ee(A(this.domContext.getDocument(),`pointerdown`,this.handlePointerDown),A(this.domContext.getDocument(),`pointerup`,this.handlePointerUp),A(this.domContext.getDocument(),`pointermove`,this.handlePointerMove),A(this.domContext.getDocument(),`pointerleave`,this.handlePointerUp))),Bt([()=>this.opts.step.current,()=>this.opts.min.current,()=>this.opts.max.current,()=>this.opts.value.current],([e,t,n,r])=>{let i=Ia(e,t,n),a=e=>i.includes(e),o=e=>La(e,i);r.some(e=>!a(e))&&(this.opts.value.current=r.map(o))})}isTickValueSelected=e=>this.opts.value.current.includes(e);isThumbActive(e){return this.isActive&&this.activeThumb?.idx===e}applyPosition({clientXY:e,activeThumbIdx:t,start:n,end:r}){let i=this.opts.min.current,a=this.opts.max.current,o=(e-n)/(r-n)*(a-i)+i;if(o<i)this.updateValue(i,t);else if(o>a)this.updateValue(a,t);else{let e=this.normalizedSteps,n=La(o,e);this.updateValue(n,t)}}#n=e=>{let t=this.getAllThumbs();if(!t.length)return;for(let e of t)e.blur();let n=t.map(t=>{if(this.opts.orientation.current===`horizontal`){let{left:n,right:r}=t.getBoundingClientRect();return Math.abs(e.clientX-(n+r)/2)}{let{top:n,bottom:r}=t.getBoundingClientRect();return Math.abs(e.clientY-(n+r)/2)}}),r=t[n.indexOf(Math.min(...n))];return{node:r,idx:t.indexOf(r)}};handlePointerMove=e=>{if(!this.isActive||this.opts.disabled.current)return;e.preventDefault(),e.stopPropagation();let t=this.opts.ref.current,n=this.activeThumb;if(!t||!n)return;n.node.focus();let{left:r,right:i,top:a,bottom:o}=t.getBoundingClientRect(),s=this.direction;s===`lr`?this.applyPosition({clientXY:e.clientX,activeThumbIdx:n.idx,start:r,end:i}):s===`rl`?this.applyPosition({clientXY:e.clientX,activeThumbIdx:n.idx,start:i,end:r}):s===`bt`?this.applyPosition({clientXY:e.clientY,activeThumbIdx:n.idx,start:o,end:a}):s===`tb`&&this.applyPosition({clientXY:e.clientY,activeThumbIdx:n.idx,start:a,end:o})};handlePointerDown=e=>{if(e.button!==0||this.opts.disabled.current)return;let t=this.opts.ref.current,n=this.#n(e);if(!n||!t)return;let r=e.composedPath()[0]??e.target;Zt(r)&&t.contains(r)&&(e.preventDefault(),this.activeThumb=n,n.node.focus(),this.isActive=!0,this.handlePointerMove(e))};handlePointerUp=()=>{this.opts.disabled.current||(this.isActive&&this.opts.onValueCommit.current(Y(()=>this.opts.value.current)),this.isActive=!1)};getAllThumbs=()=>{let e=this.opts.ref.current;return e?Array.from(e.querySelectorAll(Ba.selector(`thumb`))):[]};updateValue=(e,t)=>{let n=this.opts.value.current;if(!n.length){this.opts.value.current.push(e);return}if(n[t]===e)return;let r=[...n];if(!sn(t,r))return;let i=r[t]>e?-1:1,a=()=>{let n=t+i;r[t]=r[n],r[n]=e;let a=this.getAllThumbs();a.length&&(a[n]?.focus(),this.activeThumb={node:a[n],idx:n})};if(this.opts.autoSort.current&&(i===-1&&e<r[t-1]||i===1&&e>r[t+1])){a(),this.opts.value.current=r;return}let o=this.normalizedSteps;r[t]=La(e,o),this.opts.value.current=r};#r=T(()=>{let e=this.opts.value.current;return Array.from({length:e.length||1},(t,n)=>{let r=Y(()=>this.currentThumbIdx);r<e.length&&Y(()=>{this.currentThumbIdx=r+1});let i=e[n],a=this.getPositionFromValue(i??0),o=Ma(this.direction,a);return{role:`slider`,"aria-valuemin":this.opts.min.current,"aria-valuemax":this.opts.max.current,"aria-valuenow":i,"aria-disabled":ke(this.opts.disabled.current),"aria-orientation":this.opts.orientation.current,"data-value":i,"data-orientation":this.opts.orientation.current,style:o,[Ba.thumb]:``}})});get thumbsPropsArr(){return C(this.#r)}set thumbsPropsArr(e){P(this.#r,e)}#i=T(()=>this.thumbsPropsArr.map((e,t)=>t));get thumbsRenderArr(){return C(this.#i)}set thumbsRenderArr(e){P(this.#i,e)}#a=T(()=>{let e=this.normalizedSteps,t=this.opts.value.current;return e.map((n,r)=>{let i=this.getPositionFromValue(n),a=r===0,o=r===e.length-1,s=a?0:o?-100:-50,c=Na(this.direction,i,s),l=t.length===1?n<=t[0]:t[0]<=n&&n<=t[t.length-1];return{"data-disabled":De(this.opts.disabled.current),"data-orientation":this.opts.orientation.current,"data-bounded":l?``:void 0,"data-value":n,style:c,[Ba.tick]:``}})});get ticksPropsArr(){return C(this.#a)}set ticksPropsArr(e){P(this.#a,e)}#o=T(()=>this.ticksPropsArr.map((e,t)=>t));get ticksRenderArr(){return C(this.#o)}set ticksRenderArr(e){P(this.#o,e)}#s=T(()=>this.ticksPropsArr.map((e,t)=>({value:e[`data-value`],index:t})));get tickItemsArr(){return C(this.#s)}set tickItemsArr(e){P(this.#s,e)}#c=T(()=>this.opts.value.current.map((e,t)=>({value:e,index:t})));get thumbItemsArr(){return C(this.#c)}set thumbItemsArr(e){P(this.#c,e)}#l=T(()=>({ticks:this.ticksRenderArr,thumbs:this.thumbsRenderArr,tickItems:this.tickItemsArr,thumbItems:this.thumbItemsArr}));get snippetProps(){return C(this.#l)}set snippetProps(e){P(this.#l,e)}},Ga=class{static create(e){let{type:t,...n}=e,r=t===`single`?new Ua(n):new Wa(n);return Va.set(r)}},Ka=[Wt,zt,Rt,Qt,Ut,`End`],qa=class e{static create(t){return new e(t,Va.get())}opts;root;attachment;constructor(e,t){this.opts=e,this.root=t,this.attachment=we(e.ref)}#e=T(()=>{if(Array.isArray(this.root.opts.value.current)){let e=this.root.opts.value.current.length>1?this.root.getPositionFromValue(Math.min(...this.root.opts.value.current)??0):0,t=100-this.root.getPositionFromValue(Math.max(...this.root.opts.value.current)??0);return{position:`absolute`,...ja(this.root.direction,e,t)}}{let e=this.root.opts.trackPadding?.current,t=this.root.opts.value.current,n=this.root.opts.max.current,r=e!==void 0&&e>0&&t===n?0:100-this.root.getPositionFromValue(t);return{position:`absolute`,...ja(this.root.direction,0,r)}}});get rangeStyles(){return C(this.#e)}set rangeStyles(e){P(this.#e,e)}#t=T(()=>({id:this.opts.id.current,"data-orientation":this.root.opts.orientation.current,"data-disabled":De(this.root.opts.disabled.current),style:this.rangeStyles,[Ba.range]:``,...this.attachment}));get props(){return C(this.#t)}set props(e){P(this.#t,e)}},Ja=class e{static create(t){return new e(t,Va.get())}opts;root;attachment;#e=T(()=>this.root.opts.disabled.current||this.opts.disabled.current);constructor(e,t){this.opts=e,this.root=t,this.attachment=we(e.ref),this.onkeydown=this.onkeydown.bind(this)}#t(e){this.root.isMulti?this.root.updateValue(e,this.opts.index.current):this.root.updateValue(e)}onkeydown(e){if(C(this.#e))return;let t=this.opts.ref.current;if(!t)return;let n=this.root.getAllThumbs();if(!n.length)return;let r=n.indexOf(t);if(this.root.isMulti&&(this.root.currentThumbIdx=r),!Ka.includes(e.key))return;e.preventDefault();let i=this.root.opts.min.current,a=this.root.opts.max.current,o=this.root.opts.value.current,s=Array.isArray(o)?o[r]:o,c=this.root.opts.orientation.current,l=this.root.direction,u=this.root.normalizedSteps;switch(e.key){case Ut:this.#t(i);break;case`End`:this.#t(a);break;case Wt:if(c!==`horizontal`)break;if(e.metaKey){let e=l===`rl`?a:i;this.#t(e)}else{let e=Ra(s,u,l===`rl`?`next`:`prev`);this.#t(e)}break;case zt:if(c!==`horizontal`)break;if(e.metaKey){let e=l===`rl`?i:a;this.#t(e)}else{let e=Ra(s,u,l===`rl`?`prev`:`next`);this.#t(e)}break;case Rt:if(e.metaKey){let e=l===`tb`?i:a;this.#t(e)}else{let e=Ra(s,u,l===`tb`?`prev`:`next`);this.#t(e)}break;case Qt:if(e.metaKey){let e=l===`tb`?a:i;this.#t(e)}else{let e=Ra(s,u,l===`tb`?`next`:`prev`);this.#t(e)}}this.root.opts.onValueCommit.current(this.root.opts.value.current)}#n=T(()=>({...this.root.thumbsPropsArr[this.opts.index.current],id:this.opts.id.current,onkeydown:this.onkeydown,"data-active":this.root.isThumbActive(this.opts.index.current)?``:void 0,"data-disabled":De(this.opts.disabled.current||this.root.opts.disabled.current),tabindex:this.opts.disabled.current||this.root.opts.disabled.current?-1:0,...this.attachment}));get props(){return C(this.#n)}set props(e){P(this.#n,e)}},Ya=new Set([`$$slots`,`$$events`,`$$legacy`,`children`,`child`,`id`,`ref`,`value`,`type`,`onValueChange`,`onValueCommit`,`disabled`,`min`,`max`,`step`,`dir`,`autoSort`,`orientation`,`thumbPositioning`,`trackPadding`]),Xa=D(`<span><!></span>`);function Za(e,n){let r=l();V(n,!0);let i=J(n,`id`,19,()=>je(r)),a=J(n,`ref`,15,null),o=J(n,`value`,15),s=J(n,`onValueChange`,3,Yt),d=J(n,`onValueCommit`,3,Yt),f=J(n,`disabled`,3,!1),p=J(n,`step`,3,1),m=J(n,`dir`,3,`ltr`),g=J(n,`autoSort`,3,!0),_=J(n,`orientation`,3,`horizontal`),v=J(n,`thumbPositioning`,3,`contain`),y=W(n,Ya),S=T(()=>n.min===void 0?Array.isArray(p())?Math.min(...p()):0:n.min),w=T(()=>n.max===void 0?Array.isArray(p())?Math.max(...p()):100:n.max);function E(){if(o()===void 0)return n.type===`single`?C(S):[]}E(),Bt.pre(()=>o(),()=>{E()});let D=Ga.create({id:Me(()=>i()),ref:Me(()=>a(),e=>a(e)),value:Me(()=>o(),e=>{o(e),s()(e)}),onValueCommit:Me(()=>d()),disabled:Me(()=>f()),min:Me(()=>C(S)),max:Me(()=>C(w)),step:Me(()=>p()),dir:Me(()=>m()),autoSort:Me(()=>g()),orientation:Me(()=>_()),thumbPositioning:Me(()=>v()),type:Y(()=>n.type),trackPadding:Me(()=>n.trackPadding)}),k=T(()=>Te(y,D.props));var A=u(),j=B(A),M=e=>{var t=u(),r=B(t);{let e=T(()=>({props:C(k),...D.snippetProps}));x(r,()=>n.child,()=>C(e))}O(e,t)},N=e=>{var t=Xa();z(t,()=>({...C(k)}));var r=L(t);x(r,()=>n.children??h,()=>D.snippetProps),c(t),O(e,t)};t(j,e=>{n.child?e(M):e(N,-1)}),O(e,A),b()}var Qa=new Set([`$$slots`,`$$events`,`$$legacy`,`children`,`child`,`ref`,`id`]),$a=D(`<span><!></span>`);function eo(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`id`,19,()=>je(r)),o=W(n,Qa),s=qa.create({id:Me(()=>a()),ref:Me(()=>i(),e=>i(e))}),d=T(()=>Te(o,s.props));var f=u(),p=B(f),m=e=>{var t=u(),r=B(t);x(r,()=>n.child,()=>({props:C(d)})),O(e,t)},g=e=>{var t=$a();z(t,()=>({...C(d)}));var r=L(t);x(r,()=>n.children??h),c(t),O(e,t)};t(p,e=>{n.child?e(m):e(g,-1)}),O(e,f),b()}var to=new Set([`$$slots`,`$$events`,`$$legacy`,`children`,`child`,`ref`,`id`,`index`,`disabled`]),no=D(`<span><!></span>`);function ro(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`id`,19,()=>je(r)),o=J(n,`disabled`,3,!1),s=W(n,to),d=Ja.create({id:Me(()=>a()),ref:Me(()=>i(),e=>i(e)),index:Me(()=>n.index),disabled:Me(()=>o())}),f=T(()=>Te(s,d.props));var p=u(),m=B(p),g=e=>{var t=u(),r=B(t);{let e=T(()=>({active:d.root.isThumbActive(d.opts.index.current),props:C(f)}));x(r,()=>n.child,()=>C(e))}O(e,t)},_=e=>{var t=no();z(t,()=>({...C(f)}));var r=L(t);{let e=T(()=>({active:d.root.isThumbActive(d.opts.index.current)}));x(r,()=>n.children??h,()=>C(e))}c(t),O(e,t)};t(m,e=>{n.child?e(g):e(_,-1)}),O(e,p),b()}var io=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`checked`,`indeterminate`,`class`,`children`,`closeOnSelect`,`switch`]),ao=D(`<span data-slot="dropdown-menu-checkbox-item-switch" aria-hidden="true"><span></span></span>`),oo=D(`<span class="right-2 pointer-events-none absolute flex items-center justify-center" data-slot="dropdown-menu-checkbox-item-indicator"><!></span>`),so=D(`<!> <!>`,1);function co(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=J(n,`checked`,15,!1),a=J(n,`indeterminate`,15,!1),o=J(n,`closeOnSelect`,3,!1),s=J(n,`switch`,3,!1),l=W(n,io);var d=u(),f=B(d);{let e=(e,r)=>{let i=()=>(r?.()).checked,a=()=>(r?.()).indeterminate;var o=so(),l=B(o);x(l,()=>n.children??h);var u=U(l,2),d=e=>{var t=ao(),n=K(t);G(()=>{fe(t,1,`not-pointer-coarse:[[data-slot=dropdown-menu-shortcut]+&]:ml-2 h-4.5 w-8 pointer-events-none relative ml-auto shrink-0 rounded-full transition-colors ${i()?`bg-primary`:`bg-input`}`),fe(n,1,`left-0.5 top-0.5 size-3.5 absolute rounded-full bg-background transition-transform dark:bg-foreground ${i()?`translate-x-3.5 dark:bg-primary-foreground`:``}`)}),O(e,t)},f=e=>{var n=oo(),r=L(n),o=e=>{kt(e,{})},s=e=>{ot(e,{})};t(r,e=>{a()?e(o):i()&&e(s,1)}),c(n),O(e,n)};t(u,e=>{s()?e(d):e(f,-1)}),O(e,o)},u=T(()=>Fe(s()?`pr-2 gap-2.5`:`pr-8`,`gap-1.5 py-1 pointer-coarse:py-2.5 pl-1.5 text-sm data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center rounded-inner outline-hidden select-none focus:bg-hover focus:text-foreground focus:**:text-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,n.class));E(f,()=>gi,(t,n)=>{n(t,q({get closeOnSelect(){return o()},"data-slot":`dropdown-menu-checkbox-item`,get class(){return C(u)}},()=>l,{get ref(){return r()},set ref(e){r(e)},get checked(){return i()},set checked(e){i(e)},get indeterminate(){return a()},set indeterminate(e){a(e)},children:e,$$slots:{default:!0}}))})}O(e,d),b()}var lo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`inset`,`children`]),uo=D(`<div><!></div>`);function fo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,lo);var i=uo();z(i,e=>({"data-slot":`dropdown-menu-label`,"data-inset":t.inset,class:e,...r}),[()=>Fe(`px-1.5 py-1 text-xs font-medium data-inset:pl-7 text-muted-foreground`,t.class)]);var a=L(i);x(a,()=>t.children??h),c(i),F(i,e=>n(e),()=>n()),O(e,i),b()}var po=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`value`]);function mo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=J(t,`value`,15),i=W(t,po);var a=u(),o=B(a);E(o,()=>pi,(e,t)=>{t(e,q({"data-slot":`dropdown-menu-radio-group`},()=>i,{get ref(){return n()},set ref(e){n(e)},get value(){return r()},set value(e){r(e)}}))}),O(e,a),b()}var ho=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`,`closeOnSelect`]),go=D(`<span class="right-2 pointer-events-none absolute flex items-center justify-center" data-slot="dropdown-menu-radio-item-indicator"><!></span> <!>`,1);function _o(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=J(n,`closeOnSelect`,3,!1),a=W(n,ho);var o=u(),s=B(o);{let e=(e,r)=>{let i=()=>(r?.()).checked;var a=go(),o=B(a),s=L(o),l=e=>{ot(e,{})};t(s,e=>{i()&&e(l)}),c(o);var u=U(o,2);x(u,()=>n.children??h,()=>({checked:i()})),O(e,a)},o=T(()=>Fe(`gap-1.5 py-1 pointer-coarse:py-2.5 pr-8 pl-1.5 text-sm data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center rounded-inner outline-hidden select-none focus:bg-hover focus:text-foreground focus:**:text-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,n.class));E(s,()=>ui,(t,n)=>{n(t,q({get closeOnSelect(){return i()},"data-slot":`dropdown-menu-radio-item`,get class(){return C(o)}},()=>a,{get ref(){return r()},set ref(e){r(e)},children:e,$$slots:{default:!0}}))})}O(e,o),b()}var vo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`]),yo=D(`<span><!></span>`);function bo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,vo);var i=yo();z(i,e=>({"data-slot":`dropdown-menu-shortcut`,class:e,...r}),[()=>Fe(`h-5 min-w-5 px-1 font-mono ml-auto inline-flex items-center justify-center rounded-sm border bg-muted text-2xs text-muted-foreground group-focus/dropdown-menu-item:text-foreground pointer-coarse:hidden`,t.class)]);var a=L(i);x(a,()=>t.children??h),c(i),F(i,e=>n(e),()=>n()),O(e,i),b()}var xo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`checked`,`indeterminate`,`class`]),So=D(`<div data-slot="checkbox-indicator" class="text-current transition-none"><!></div>`);function Co(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=J(n,`checked`,15,!1),a=J(n,`indeterminate`,15,!1),o=W(n,xo);var s=u(),l=B(s);{let e=(e,n)=>{let r=()=>(n?.()).checked,i=()=>(n?.()).indeterminate;var a=So(),o=L(a),s=e=>{ot(e,{class:`size-3.5`})},l=e=>{kt(e,{class:`size-3.5`})};t(o,e=>{r()?e(s):i()&&e(l,1)}),c(a),O(e,a)},s=T(()=>Fe(`peer size-4 shadow-xs flex shrink-0 items-center justify-center rounded-sm border border-input bg-field transition-shadow outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary`,n.class));E(l,()=>si,(t,n)=>{n(t,q({"data-slot":`checkbox`,get class(){return C(s)}},()=>o,{get ref(){return r()},set ref(e){r(e)},get checked(){return i()},set checked(e){i(e)},get indeterminate(){return a()},set indeterminate(e){a(e)},children:e,$$slots:{default:!0}}))})}O(e,s),b()}var wo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`value`,`orientation`,`class`,`thumbLabelledby`]),To=D(`<span data-slot="slider-track"><!></span> <!>`,1);function Eo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=J(t,`value`,15),i=J(t,`orientation`,3,`horizontal`),o=W(t,wo);var s=u(),l=B(s);{let e=(e,n)=>{let r=()=>(n?.()).thumbs;var o=To(),s=B(o),l=L(s);{let e=T(()=>Fe(`absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full`));E(l,()=>eo,(t,n)=>{n(t,{"data-slot":`slider-range`,get class(){return C(e)}})})}c(s);var d=U(s,2);a(d,16,r,e=>e,(e,n)=>{var r=u(),i=B(r);E(i,()=>ro,(e,r)=>{r(e,{"data-slot":`slider-thumb`,get index(){return n},get"aria-labelledby"(){return t.thumbLabelledby},class:`size-4 shadow-sm block shrink-0 rounded-full border border-primary bg-background ring-ring/50 transition hover:ring-4 focus-visible:ring-4 focus-visible:ring-ring focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50`})}),O(e,r)}),G(e=>{H(s,`data-orientation`,i()),fe(s,1,e)},[()=>me(Fe(`data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:w-1.5 relative grow overflow-hidden rounded-full bg-input data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full`))]),O(e,o)},s=T(()=>Fe(`data-[orientation=vertical]:min-h-44 relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col`,t.class));E(l,()=>Za,(t,a)=>{a(t,q({"data-slot":`slider`,get orientation(){return i()},get class(){return C(s)}},()=>o,{get ref(){return n()},set ref(e){n(e)},get value(){return r()},set value(e){r(e)},children:e,$$slots:{default:!0}}))})}O(e,s),b()}var Do=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`]),Oo=D(`<div><!></div>`);function ko(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,Do);var i=Oo();z(i,e=>({"data-slot":`empty-description`,class:e,...r}),[()=>Fe(`text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,t.class)]);var a=L(i);x(a,()=>t.children??h),c(i),F(i,e=>n(e),()=>n()),O(e,i),b()}var Ao=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`]),jo=D(`<div><!></div>`);function Mo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,Ao);var i=jo();z(i,e=>({"data-slot":`empty-header`,class:e,...r}),[()=>Fe(`gap-2 max-w-sm flex flex-col items-center`,t.class)]);var a=L(i);x(a,()=>t.children??h),c(i),F(i,e=>n(e),()=>n()),O(e,i),b()}var No=Le({base:`mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,variants:{variant:{default:`bg-transparent`,icon:`bg-muted text-foreground flex size-8 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-4`}},defaultVariants:{variant:`default`}}),Po=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`,`variant`]),Fo=D(`<div><!></div>`);function Io(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=J(t,`variant`,3,`default`),i=W(t,Po);var a=Fo();z(a,e=>({"data-slot":`empty-icon`,"data-variant":r(),class:e,...i}),[()=>Fe(No({variant:r()}),t.class)]);var o=L(a);x(o,()=>t.children??h),c(a),F(a,e=>n(e),()=>n()),O(e,a),b()}var Lo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`]),Ro=D(`<div><!></div>`);function zo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,Lo);var i=Ro();z(i,e=>({"data-slot":`empty-title`,class:e,...r}),[()=>Fe(`text-sm font-medium tracking-tight`,t.class)]);var a=L(i);x(a,()=>t.children??h),c(i),F(i,e=>n(e),()=>n()),O(e,i),b()}var Bo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`]),Vo=D(`<div><!></div>`);function Ho(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,Bo);var i=Vo();z(i,e=>({"data-slot":`empty`,class:e,...r}),[()=>Fe(`gap-4 p-6 min-w-0 flex w-full flex-1 flex-col items-center justify-center rounded-xl border-dashed text-center text-balance`,t.class)]);var a=L(i);x(a,()=>t.children??h),c(i),F(i,e=>n(e),()=>n()),O(e,i),b()}var Uo=new Set([`$$slots`,`$$events`,`$$legacy`,`class`,`role`,`name`,`color`,`stroke`,`className`,`aria-label`]);function Wo(e,t){V(t,!0);let n=J(t,`role`,3,`status`),r=J(t,`aria-label`,3,`Loading`),i=W(t,Uo);{let a=T(()=>Fe(`size-4 animate-spin`,t.class));_t(e,q({get role(){return n()}},()=>t.name==null?{}:{name:t.name},()=>t.color==null?{}:{color:t.color},()=>t.stroke==null?{}:{stroke:t.stroke},()=>t.className==null?{}:{className:t.className},{get"aria-label"(){return r()},get class(){return C(a)}},()=>i))}b()}var Go=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`orientation`,`children`]),Ko=D(`<!> <!>`,1);function qo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=J(t,`orientation`,3,`vertical`),i=W(t,Go);var a=u(),o=B(a);{let e=T(()=>Fe(`flex touch-none p-px transition-colors select-none`,r()===`vertical`&&`w-2.5 h-full border-s border-s-transparent`,r()===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,t.class));E(o,()=>ba,(a,o)=>{o(a,q({"data-slot":`scroll-area-scrollbar`,get orientation(){return r()},get class(){return C(e)}},()=>i,{get ref(){return n()},set ref(e){n(e)},children:(e,n)=>{var r=Ko(),i=B(r);x(i,()=>t.children??h);var a=U(i,2);E(a,()=>Ta,(e,t)=>{t(e,{"data-slot":`scroll-area-thumb`,class:`relative flex-1 rounded-full bg-border`})}),O(e,r)},$$slots:{default:!0}}))})}O(e,a),b()}var Jo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`viewportRef`,`class`,`orientation`,`scrollbarXClasses`,`scrollbarYClasses`,`children`]),Yo=D(`<!> <!> <!> <!>`,1);function Xo(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=J(n,`viewportRef`,15,null),a=J(n,`orientation`,3,`vertical`),o=J(n,`scrollbarXClasses`,3,``),s=J(n,`scrollbarYClasses`,3,``),c=W(n,Jo);var l=u(),d=B(l);{let e=T(()=>Fe(`relative`,n.class));E(d,()=>ea,(l,d)=>{d(l,q({"data-slot":`scroll-area`,get class(){return C(e)}},()=>c,{get ref(){return r()},set ref(e){r(e)},children:(e,r)=>{var c=Yo(),l=B(c);E(l,()=>ra,(e,t)=>{t(e,{"data-slot":`scroll-area-viewport`,class:`size-full rounded-inherit ring-ring/10 outline-ring transition focus-visible:ring-4 focus-visible:outline-1 dark:ring-ring/20`,get ref(){return i()},set ref(e){i(e)},children:(e,t)=>{var r=u(),i=B(r);x(i,()=>n.children??h),O(e,r)},$$slots:{default:!0}})});var d=U(l,2),f=e=>{qo(e,{orientation:`vertical`,get class(){return s()}})};t(d,e=>{(a()===`vertical`||a()===`both`)&&e(f)});var p=U(d,2),m=e=>{qo(e,{orientation:`horizontal`,get class(){return o()}})};t(p,e=>{(a()===`horizontal`||a()===`both`)&&e(m)});var g=U(p,2);E(g,()=>Aa,(e,t)=>{t(e,{})}),O(e,c)},$$slots:{default:!0}}))})}O(e,l),b()}function Zo(e){return typeof e==`function`}function Qo(e){return typeof e==`object`&&!!e}var $o=[`string`,`number`,`bigint`,`boolean`];function es(e){return e==null||$o.includes(typeof e)?!0:Array.isArray(e)?e.every(e=>es(e)):typeof e==`object`&&Object.getPrototypeOf(e)===Object.prototype}var ts=Symbol(`box`),ns=Symbol(`is-writable`);function rs(e){return Qo(e)&&ts in e}function is(e){return as.isBox(e)&&ns in e}function as(e){let t=Z(re(e));return{[ts]:!0,[ns]:!0,get current(){return C(t)},set current(e){P(t,e,!0)}}}function os(e,t){let n=T(e);return t?{[ts]:!0,[ns]:!0,get current(){return C(n)},set current(e){t(e)}}:{[ts]:!0,get current(){return e()}}}function ss(e){return as.isBox(e)?e:Zo(e)?as.with(e):as(e)}function cs(e){return Object.entries(e).reduce((e,[t,n])=>as.isBox(n)?(as.isWritableBox(n)?Object.defineProperty(e,t,{get(){return n.current},set(e){n.current=e}}):Object.defineProperty(e,t,{get(){return n.current}}),e):Object.assign(e,{[t]:n}),{})}function ls(e){return as.isWritableBox(e)?{[ts]:!0,get current(){return e.current}}:e}as.from=ss,as.with=os,as.flatten=cs,as.readonly=ls,as.isBox=rs,as.isWritableBox=is;function us(...e){return function(t){for(let n of e)if(n){if(t.defaultPrevented)return;typeof n==`function`?n.call(this,t):n.current?.call(this,t)}}}var ds=/\d/,fs=[`-`,`_`,`/`,`.`];function ps(e=``){if(!ds.test(e))return e!==e.toLowerCase()}function ms(e){let t=[],n=``,r,i;for(let a of e){let e=fs.includes(a);if(e===!0){t.push(n),n=``,r=void 0;continue}let o=ps(a);if(i===!1){if(r===!1&&o===!0){t.push(n),n=a,r=o;continue}if(r===!0&&o===!1&&n.length>1){let e=n.at(-1);t.push(n.slice(0,Math.max(0,n.length-1))),n=e+a,r=o;continue}}n+=a,r=o,i=e}return t.push(n),t}function hs(e){return e?ms(e).map(e=>_s(e)).join(``):``}function gs(e){return vs(hs(e||``))}function _s(e){return e?e[0].toUpperCase()+e.slice(1):``}function vs(e){return e?e[0].toLowerCase()+e.slice(1):``}function ys(e){if(!e)return{};let t={};function n(e,n){e.startsWith(`-moz-`)||e.startsWith(`-webkit-`)||e.startsWith(`-ms-`)||e.startsWith(`-o-`)?t[hs(e)]=n:e.startsWith(`--`)?t[e]=n:t[gs(e)]=n}return Ce(e,n),t}function bs(...e){return(...t)=>{for(let n of e)typeof n==`function`&&n(...t)}}function xs(e,t,n,r){let i=Array.isArray(t)?t:[t];return i.forEach(t=>e.addEventListener(t,n,r)),()=>{i.forEach(t=>e.removeEventListener(t,n,r))}}function Ss(e,t){let n=RegExp(e,`g`);return e=>{if(typeof e!=`string`)throw TypeError(`expected an argument of type string, but got ${typeof e}`);return e.match(n)?e.replace(n,t):e}}var Cs=Ss(/[A-Z]/,e=>`-${e.toLowerCase()}`);function ws(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`expected an argument of type object, but got ${typeof e}`);return Object.keys(e).map(t=>`${Cs(t)}: ${e[t]};`).join(`
|
|
2
|
+
import{t as e}from"./CRzLMJPS.js";import{A as t,At as n,B as r,C as i,D as a,E as o,Et as s,Ft as c,G as l,H as u,It as d,J as f,K as p,L as m,Lt as h,M as g,N as _,Nt as v,O as y,Ot as b,P as x,Pt as S,Q as C,Rt as w,St as T,T as E,U as D,V as O,W as k,X as A,Y as j,Z as M,_ as N,_t as P,a as F,b as ee,bt as te,ct as ne,dt as I,et as L,f as R,ft as z,g as re,ht as B,j as ie,k as ae,kt as V,m as H,mt as U,n as W,o as oe,ot as G,p as se,pt as K,q as ce,r as q,st as le,t as J,tt as Y,u as ue,ut as de,v as fe,w as X,xt as pe,y as me,yt as Z}from"./sphvlIzg.js";import{c as he,o as ge,s as _e,t as ve}from"./C1xbQMZF.js";import{i as ye,r as be,t as xe}from"./BJGlbpZ0.js";import{C as Se,E as Ce,d as we,f as Te,m as Ee,n as De,o as Oe,r as ke,s as Ae,t as je,y as Me}from"./CoRMsLUN.js";import{a as Ne}from"./B3e8ZKjr.js";import{n as Pe}from"./BFJ8iwO4.js";import"./BHnRUwtv.js";import{n as Fe,r as Ie,t as Le}from"./Ca-1xMUo.js";import{_ as Re,a as ze,b as Be,d as Ve,f as He,g as Ue,h as We,l as Ge,m as Ke,n as qe,p as Je,t as Ye,u as Xe,v as Ze,w as Qe,x as $e,y as et}from"./Nv1S5RTq.js";import{t as tt}from"./BbFMtSJ8.js";import{i as nt,n as rt,r as it,t as at}from"./BEzPIk5e.js";import{o as ot}from"./DNFu5yLd.js";import{t as st}from"./B9-uqzXO.js";import{t as ct}from"./BvRGv1MX.js";import{t as lt}from"./Dqc45la5.js";import{t as ut}from"./B187F-XR.js";import{t as dt}from"./BmbAoXqr.js";import{a as ft,o as pt}from"./CivEAG-M.js";import{a as mt,c as ht,d as gt,f as _t,i as vt,l as yt,m as bt,n as xt,o as St,p as Ct,r as wt,s as Tt,t as Et,u as Dt}from"./BSN2qO1R.js";import{t as Ot}from"./Bct5vmEM.js";import{t as kt}from"./nJUe9gXb.js";import{a as At,i as jt,n as Mt,o as Nt,r as Pt,t as Ft}from"./Cms9vBTq.js";import{t as It}from"./1VJx1aVI.js";import{t as Lt}from"./DtmJiR65.js";import{D as Rt,E as zt,G as Bt,K as Vt,L as Ht,M as Ut,T as Wt,U as Gt,V as Kt,h as qt,n as Jt,p as Yt,q as Xt,v as Zt,w as Qt,y as $t,z as en}from"./OznVWGiS.js";import{a as tn,i as nn,n as rn,r as an,t as on}from"./CVl4suwo.js";import{o as sn}from"./Rbl3OsBf.js";import{t as cn}from"./DcS7V4T3.js";import{a as ln,i as un,n as dn,r as fn,t as pn}from"./aBYenH6-.js";import{t as mn}from"./BCgmDXNw.js";import{i as hn,n as gn,r as _n,t as vn}from"./CK2nnbJa.js";import{n as yn,t as bn}from"./DG4fF26P.js";import{t as xn}from"./CUaHcctM.js";import{t as Sn}from"./Cj9-pF71.js";import{n as Cn}from"./BQmUk61d.js";import{t as wn}from"./DIYaLgLs.js";import{t as Tn}from"./DnJObvmm.js";import{t as En}from"./DqR8kuM6.js";var Dn={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`}],[`circle`,{cx:`12`,cy:`13`,r:`3`}]]};Dn.node;var On=new Set([`$$slots`,`$$events`,`$$legacy`]);function kn(e,t){let n=W(t,On);Ie(e,q(()=>n,{get icon(){return Dn}}))}var An={name:`chevrons-down-up`,size:24,node:[[`path`,{d:`m7 20 5-5 5 5`}],[`path`,{d:`m7 4 5 5 5-5`}]]};An.node;var jn=new Set([`$$slots`,`$$events`,`$$legacy`]);function Mn(e,t){let n=W(t,jn);Ie(e,q(()=>n,{get icon(){return An}}))}var Nn={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`}],[`path`,{d:`M12 17h.01`}]],aliases:[`help-circle`,`circle-help`]};Nn.node;var Pn=new Set([`$$slots`,`$$events`,`$$legacy`]);function Fn(e,t){let n=W(t,Pn);Ie(e,q(()=>n,{get icon(){return Nn}}))}var In={name:`cuboid`,size:24,node:[[`path`,{d:`M10 22v-8`}],[`path`,{d:`M2.336 8.89 10 14l11.715-7.029`}],[`path`,{d:`M22 14a2 2 0 0 1-.971 1.715l-10 6a2 2 0 0 1-2.138-.05l-6-4A2 2 0 0 1 2 16v-6a2 2 0 0 1 .971-1.715l10-6a2 2 0 0 1 2.138.05l6 4A2 2 0 0 1 22 8z`}]]};In.node;var Ln=new Set([`$$slots`,`$$events`,`$$legacy`]);function Rn(e,t){let n=W(t,Ln);Ie(e,q(()=>n,{get icon(){return In}}))}var zn={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}],[`path`,{d:`m7 10 5 5 5-5`}]]};zn.node;var Bn=new Set([`$$slots`,`$$events`,`$$legacy`]);function Vn(e,t){let n=W(t,Bn);Ie(e,q(()=>n,{get icon(){return zn}}))}var Hn={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]]};Hn.node;var Un=new Set([`$$slots`,`$$events`,`$$legacy`]);function Wn(e,t){let n=W(t,Un);Ie(e,q(()=>n,{get icon(){return Hn}}))}var Gn={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`}],[`path`,{d:`m2 2 20 20`}]]};Gn.node;var Kn=new Set([`$$slots`,`$$events`,`$$legacy`]);function qn(e,t){let n=W(t,Kn);Ie(e,q(()=>n,{get icon(){return Gn}}))}var Jn={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`}]]};Jn.node;var Yn=new Set([`$$slots`,`$$events`,`$$legacy`]);function Xn(e,t){let n=W(t,Yn);Ie(e,q(()=>n,{get icon(){return Jn}}))}var Zn={name:`folder`,size:24,node:[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`}]]};Zn.node;var Qn=new Set([`$$slots`,`$$events`,`$$legacy`]);function $n(e,t){let n=W(t,Qn);Ie(e,q(()=>n,{get icon(){return Zn}}))}var er={name:`grid-3x3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}],[`path`,{d:`M3 9h18`}],[`path`,{d:`M3 15h18`}],[`path`,{d:`M9 3v18`}],[`path`,{d:`M15 3v18`}]],aliases:[`grid`,`grid-3-x-3`]};er.node;var tr=new Set([`$$slots`,`$$events`,`$$legacy`]);function nr(e,t){let n=W(t,tr);Ie(e,q(()=>n,{get icon(){return er}}))}var rr={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`}]]};rr.node;var ir=new Set([`$$slots`,`$$events`,`$$legacy`]);function ar(e,t){let n=W(t,ir);Ie(e,q(()=>n,{get icon(){return rr}}))}var or={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`}]],aliases:[`layers-3`]};or.node;var sr=new Set([`$$slots`,`$$events`,`$$legacy`]);function cr(e,t){let n=W(t,sr);Ie(e,q(()=>n,{get icon(){return or}}))}var lr={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`}]]};lr.node;var ur=new Set([`$$slots`,`$$events`,`$$legacy`]);function dr(e,t){let n=W(t,ur);Ie(e,q(()=>n,{get icon(){return lr}}))}var fr={name:`loader`,size:24,node:[[`path`,{d:`M12 2v4`}],[`path`,{d:`m16.2 7.8 2.9-2.9`}],[`path`,{d:`M18 12h4`}],[`path`,{d:`m16.2 16.2 2.9 2.9`}],[`path`,{d:`M12 18v4`}],[`path`,{d:`m4.9 19.1 2.9-2.9`}],[`path`,{d:`M2 12h4`}],[`path`,{d:`m4.9 4.9 2.9 2.9`}]]};fr.node;var pr=new Set([`$$slots`,`$$events`,`$$legacy`]);function mr(e,t){let n=W(t,pr);Ie(e,q(()=>n,{get icon(){return fr}}))}var hr={name:`locate-fixed`,size:24,node:[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`}],[`circle`,{cx:`12`,cy:`12`,r:`7`}],[`circle`,{cx:`12`,cy:`12`,r:`3`}]]};hr.node;var gr=new Set([`$$slots`,`$$events`,`$$legacy`]);function _r(e,t){let n=W(t,gr);Ie(e,q(()=>n,{get icon(){return hr}}))}var vr={name:`maximize`,size:24,node:[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`}]]};vr.node;var yr=new Set([`$$slots`,`$$events`,`$$legacy`]);function br(e,t){let n=W(t,yr);Ie(e,q(()=>n,{get icon(){return vr}}))}var xr={name:`minimize`,size:24,node:[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`}]]};xr.node;var Sr=new Set([`$$slots`,`$$events`,`$$legacy`]);function Cr(e,t){let n=W(t,Sr);Ie(e,q(()=>n,{get icon(){return xr}}))}var wr={name:`palette`,size:24,node:[[`path`,{d:`M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z`}],[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`}]]};wr.node;var Tr=new Set([`$$slots`,`$$events`,`$$legacy`]);function Er(e,t){let n=W(t,Tr);Ie(e,q(()=>n,{get icon(){return wr}}))}var Dr={name:`pipette`,size:24,node:[[`path`,{d:`m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12`}],[`path`,{d:`m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z`}],[`path`,{d:`m2 22 .414-.414`}]]};Dr.node;var Or=new Set([`$$slots`,`$$events`,`$$legacy`]);function kr(e,t){let n=W(t,Or);Ie(e,q(()=>n,{get icon(){return Dr}}))}var Ar={name:`ruler`,size:24,node:[[`path`,{d:`M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z`}],[`path`,{d:`m14.5 12.5 2-2`}],[`path`,{d:`m11.5 9.5 2-2`}],[`path`,{d:`m8.5 6.5 2-2`}],[`path`,{d:`m17.5 15.5 2-2`}]]};Ar.node;var jr=new Set([`$$slots`,`$$events`,`$$legacy`]);function Mr(e,t){let n=W(t,jr);Ie(e,q(()=>n,{get icon(){return Ar}}))}var Nr={name:`scan`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`}]]};Nr.node;var Pr=new Set([`$$slots`,`$$events`,`$$legacy`]);function Fr(e,t){let n=W(t,Pr);Ie(e,q(()=>n,{get icon(){return Nr}}))}var Ir={name:`settings-2`,size:24,node:[[`path`,{d:`M14 17H5`}],[`path`,{d:`M19 7h-9`}],[`circle`,{cx:`17`,cy:`17`,r:`3`}],[`circle`,{cx:`7`,cy:`7`,r:`3`}]]};Ir.node;var Lr=new Set([`$$slots`,`$$events`,`$$legacy`]);function Rr(e,t){let n=W(t,Lr);Ie(e,q(()=>n,{get icon(){return Ir}}))}var zr={name:`spline`,size:24,node:[[`circle`,{cx:`19`,cy:`5`,r:`2`}],[`circle`,{cx:`5`,cy:`19`,r:`2`}],[`path`,{d:`M5 17A12 12 0 0 1 17 5`}]]};zr.node;var Br=new Set([`$$slots`,`$$events`,`$$legacy`]);function Vr(e,t){let n=W(t,Br);Ie(e,q(()=>n,{get icon(){return zr}}))}var Hr={name:`zap`,size:24,node:[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`}]]};Hr.node;var Ur=new Set([`$$slots`,`$$events`,`$$legacy`]);function Wr(e,t){let n=W(t,Ur);Ie(e,q(()=>n,{get icon(){return Hr}}))}var Gr={name:`zoom-in`,size:24,node:[[`circle`,{cx:`11`,cy:`11`,r:`8`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`}]]};Gr.node;var Kr=new Set([`$$slots`,`$$events`,`$$legacy`]);function qr(e,t){let n=W(t,Kr);Ie(e,q(()=>n,{get icon(){return Gr}}))}var Jr={name:`zoom-out`,size:24,node:[[`circle`,{cx:`11`,cy:`11`,r:`8`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`}]]};Jr.node;var Yr=new Set([`$$slots`,`$$events`,`$$legacy`]);function Xr(e,t){let n=W(t,Yr);Ie(e,q(()=>n,{get icon(){return Jr}}))}var Zr=Oe({component:`checkbox`,parts:[`root`,`group`,`group-label`,`input`]}),Qr=new Xt(`Checkbox.Group`),$r=new Xt(`Checkbox.Root`),ei=class e{static create(t,n=null){return $r.set(new e(t,n))}opts;group;#e=T(()=>this.group&&this.group.opts.name.current?this.group.opts.name.current:this.opts.name.current);get trueName(){return C(this.#e)}set trueName(e){P(this.#e,e)}#t=T(()=>this.group&&this.group.opts.required.current?!0:this.opts.required.current);get trueRequired(){return C(this.#t)}set trueRequired(e){P(this.#t,e)}#n=T(()=>this.group&&this.group.opts.disabled.current?!0:this.opts.disabled.current);get trueDisabled(){return C(this.#n)}set trueDisabled(e){P(this.#n,e)}#r=T(()=>this.group&&this.group.opts.readonly.current?!0:this.opts.readonly.current);get trueReadonly(){return C(this.#r)}set trueReadonly(e){P(this.#r,e)}attachment;constructor(e,t){this.opts=e,this.group=t,this.attachment=we(this.opts.ref),this.onkeydown=this.onkeydown.bind(this),this.onclick=this.onclick.bind(this),Bt.pre([()=>v(this.group?.opts.value.current),()=>this.opts.value.current],([e,t])=>{e&&t&&(this.opts.checked.current=e.includes(t))}),Bt.pre(()=>this.opts.checked.current,e=>{this.group&&(e?this.group?.addValue(this.opts.value.current):this.group?.removeValue(this.opts.value.current))})}onkeydown(e){this.trueDisabled||this.trueReadonly||(e.key===`Enter`?(e.preventDefault(),this.opts.type.current===`submit`&&(e.currentTarget.form??e.currentTarget.closest(`form`))?.requestSubmit()):e.key===` `&&(e.preventDefault(),this.#i()))}#i(){this.opts.indeterminate.current?(this.opts.indeterminate.current=!1,this.opts.checked.current=!0):this.opts.checked.current=!this.opts.checked.current}onclick(e){this.trueDisabled||this.trueReadonly||(this.opts.type.current===`submit`||e.preventDefault(),this.#i())}#a=T(()=>({checked:this.opts.checked.current,indeterminate:this.opts.indeterminate.current}));get snippetProps(){return C(this.#a)}set snippetProps(e){P(this.#a,e)}#o=T(()=>({id:this.opts.id.current,role:`checkbox`,type:this.opts.type.current,form:this.opts.form.current,disabled:this.trueDisabled,"aria-checked":Ae(this.opts.checked.current,this.opts.indeterminate.current),"aria-required":ke(this.trueRequired),"aria-readonly":ke(this.trueReadonly),"data-disabled":De(this.trueDisabled),"data-readonly":De(this.trueReadonly),"data-state":ni(this.opts.checked.current,this.opts.indeterminate.current),[Zr.root]:``,onclick:this.onclick,onkeydown:this.onkeydown,...this.attachment}));get props(){return C(this.#o)}set props(e){P(this.#o,e)}},ti=class e{static create(){return new e($r.get())}root;#e=T(()=>this.root.group?!!(this.root.opts.value.current!==void 0&&this.root.group.opts.value.current.includes(this.root.opts.value.current)):this.root.opts.checked.current);get trueChecked(){return C(this.#e)}set trueChecked(e){P(this.#e,e)}#t=T(()=>!!this.root.trueName);get shouldRender(){return C(this.#t)}set shouldRender(e){P(this.#t,e)}constructor(e){this.root=e,this.onfocus=this.onfocus.bind(this)}onfocus(e){$t(this.root.opts.ref.current)&&this.root.opts.ref.current.focus()}#n=T(()=>({type:`checkbox`,checked:this.root.opts.checked.current===!0,disabled:this.root.trueDisabled,required:this.root.trueRequired,name:this.root.trueName,form:this.root.opts.form.current,value:this.root.opts.value.current,readonly:this.root.trueReadonly,onfocus:this.onfocus}));get props(){return C(this.#n)}set props(e){P(this.#n,e)}};function ni(e,t){return t?`indeterminate`:e?`checked`:`unchecked`}function ri(e,n){V(n,!0);let r=ti.create();var i=u(),a=z(i),o=e=>{cn(e,q(()=>r.props))};t(a,e=>{r.shouldRender&&e(o)}),O(e,i),b()}var ii=new Set([`$$slots`,`$$events`,`$$legacy`,`checked`,`ref`,`onCheckedChange`,`children`,`disabled`,`required`,`name`,`form`,`value`,`id`,`indeterminate`,`onIndeterminateChange`,`child`,`type`,`readonly`]),ai=D(`<button><!></button>`),oi=D(`<!> <!>`,1);function si(e,n){let r=l();V(n,!0);let i=J(n,`checked`,15,!1),a=J(n,`ref`,15,null),o=J(n,`disabled`,3,!1),s=J(n,`required`,3,!1),d=J(n,`name`,3,void 0),f=J(n,`form`,3,void 0),p=J(n,`value`,3,`on`),m=J(n,`id`,19,()=>je(r)),g=J(n,`indeterminate`,15,!1),_=J(n,`type`,3,`button`),v=W(n,ii),y=Qr.getOr(null);Y(()=>{y&&p()&&(y.opts.value.current.includes(p())?i(!0):i(!1))}),Bt.pre(()=>p(),()=>{y&&p()&&(y.opts.value.current.includes(p())?i(!0):i(!1))});let S=ei.create({checked:Me(()=>i(),e=>{i(e),n.onCheckedChange?.(e)}),disabled:Me(()=>o()??!1),required:Me(()=>s()),name:Me(()=>d()),form:Me(()=>f()),value:Me(()=>p()),id:Me(()=>m()),ref:Me(()=>a(),e=>a(e)),indeterminate:Me(()=>g(),e=>{g(e),n.onIndeterminateChange?.(e)}),type:Me(()=>_()),readonly:Me(()=>!!n.readonly)},y),w=T(()=>Te({...v},S.props));var E=oi(),D=z(E),k=e=>{var t=u(),r=z(t);{let e=T(()=>({props:C(w),...S.snippetProps}));x(r,()=>n.child,()=>C(e))}O(e,t)},A=e=>{var t=ai();R(t,()=>({...C(w)}));var r=I(t);x(r,()=>n.children??h,()=>S.snippetProps),c(t),O(e,t)};t(D,e=>{n.child?e(k):e(A,-1)}),ri(U(D,2),{}),O(e,E),b()}var ci=new Set([`$$slots`,`$$events`,`$$legacy`,`children`,`child`,`ref`,`value`,`onSelect`,`id`,`disabled`,`closeOnSelect`]),li=D(`<div><!></div>`);function ui(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`onSelect`,3,Yt),o=J(n,`id`,19,()=>je(r)),s=J(n,`disabled`,3,!1),d=J(n,`closeOnSelect`,3,!0),f=W(n,ci),p=$e.create({value:Me(()=>n.value),id:Me(()=>o()),disabled:Me(()=>s()),onSelect:Me(()=>m),ref:Me(()=>i(),e=>i(e)),closeOnSelect:Me(()=>d())});function m(e){a()(e),!e.defaultPrevented&&p.selectValue()}let g=T(()=>Te(f,p.props));var _=u(),v=z(_),y=e=>{var t=u(),r=z(t);x(r,()=>n.child,()=>({props:C(g),checked:p.isChecked})),O(e,t)},S=e=>{var t=li();R(t,()=>({...C(g)}));var r=I(t);x(r,()=>n.children??h,()=>({checked:p.isChecked})),c(t),O(e,t)};t(v,e=>{n.child?e(y):e(S,-1)}),O(e,_),b()}var di=new Set([`$$slots`,`$$events`,`$$legacy`,`id`,`children`,`child`,`ref`,`value`,`onValueChange`]),fi=D(`<div><!></div>`);function pi(e,n){let r=l();V(n,!0);let i=J(n,`id`,19,()=>je(r)),a=J(n,`ref`,15,null),o=J(n,`value`,15,``),s=J(n,`onValueChange`,3,Yt),d=W(n,di),f=Be.create({value:Me(()=>o(),e=>{o(e),s()(e)}),ref:Me(()=>a(),e=>a(e)),id:Me(()=>i())}),p=T(()=>Te(d,f.props));var m=u(),g=z(m),_=e=>{var t=u(),r=z(t);x(r,()=>n.child,()=>({props:C(p)})),O(e,t)},v=e=>{var t=fi();R(t,()=>({...C(p)}));var r=I(t);x(r,()=>n.children??h),c(t),O(e,t)};t(g,e=>{n.child?e(_):e(v,-1)}),O(e,m),b()}var mi=new Set([`$$slots`,`$$events`,`$$legacy`,`child`,`children`,`ref`,`checked`,`id`,`onCheckedChange`,`disabled`,`onSelect`,`closeOnSelect`,`indeterminate`,`onIndeterminateChange`,`value`]),hi=D(`<div><!></div>`);function gi(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`checked`,15,!1),o=J(n,`id`,19,()=>je(r)),s=J(n,`onCheckedChange`,3,Yt),d=J(n,`disabled`,3,!1),f=J(n,`onSelect`,3,Yt),p=J(n,`closeOnSelect`,3,!0),m=J(n,`indeterminate`,15,!1),g=J(n,`onIndeterminateChange`,3,Yt),_=J(n,`value`,3,``),v=W(n,mi),y=Ze.getOr(null);Y(()=>{y&&_()&&(y.opts.value.current.includes(_())?a(!0):a(!1))}),Bt.pre(()=>_(),()=>{y&&_()&&(y.opts.value.current.includes(_())?a(!0):a(!1))});let S=et.create({checked:Me(()=>a(),e=>{e!==a()&&(a(e),s()(e))}),id:Me(()=>o()),disabled:Me(()=>d()),onSelect:Me(()=>w),ref:Me(()=>i(),e=>i(e)),closeOnSelect:Me(()=>p()),indeterminate:Me(()=>m(),e=>{e!==m()&&(m(e),g()(e))}),value:Me(()=>_())},y);function w(e){f()(e),!e.defaultPrevented&&S.toggleChecked()}let E=T(()=>Te(v,S.props));var D=u(),k=z(D),A=e=>{var t=u(),r=z(t);x(r,()=>n.child,()=>({checked:a(),indeterminate:m(),props:C(E)})),O(e,t)},j=e=>{var t=hi();R(t,()=>({...C(E)}));var r=I(t);x(r,()=>n.children??h,()=>({checked:a(),indeterminate:m()})),c(t),O(e,t)};t(k,e=>{n.child?e(A):e(j,-1)}),O(e,D),b()}var _i=null,vi=new WeakMap;function yi(){return _i??=new ResizeObserver(e=>{for(let t of e){let e=vi.get(t.target);if(e)for(let t of[...e])t()}}),_i}function bi(e,t){let n=vi.get(e);return n===void 0?(n=new Set,vi.set(e,n),n.add(t),yi().observe(e)):(n.add(t),t()),()=>{let n=vi.get(e);n&&(n.delete(t),!n.size&&(vi.delete(e),_i?.unobserve(e)))}}var xi=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t,this.handler=this.handler.bind(this),le(this.handler)}handler(){let e=0,t=this.#e();if(!t)return;let n=bi(t,()=>{cancelAnimationFrame(e),e=window.requestAnimationFrame(this.#t)});return()=>{window.cancelAnimationFrame(e),n()}}},Si=class{opts;present;#e;#t=Z(!1);#n=!1;#r=Z(void 0);#i=null;constructor(e){this.opts=e,this.present=this.opts.open,P(this.#t,e.open.current,!0),this.#e=new qt({ref:this.opts.ref,afterTick:this.opts.open}),Kt(()=>this.#o()),Bt(()=>this.present.current,e=>{this.#n?(this.#o(),e&&P(this.#t,!0),P(this.#r,e?`starting`:`ending`,!0),e&&(this.#i=window.requestAnimationFrame(()=>{this.#i=null,this.present.current&&P(this.#r,void 0)})),this.#e.run(()=>{e===this.present.current&&(e||P(this.#t,!1),P(this.#r,void 0))})):this.#n=!0})}#a=T(()=>C(this.#t));get isPresent(){return C(this.#a)}set isPresent(e){P(this.#a,e)}get transitionStatus(){return C(this.#r)}#o(){this.#i!==null&&(window.cancelAnimationFrame(this.#i),this.#i=null)}};function Ci(e,n){V(n,!0);let r=new Si({open:Me(()=>n.open),ref:Y(()=>n.ref)});var i=u(),a=z(i),o=e=>{var t=u(),i=z(t);x(i,()=>n.presence??h,()=>({present:r.isPresent,transitionStatus:r.transitionStatus})),O(e,t)};t(a,e=>{(n.forceMount||n.open||r.isPresent)&&e(o)}),O(e,i),b()}function wi(e,t,n){return Math.min(n,Math.max(t,e))}var Ti=class{state;#e;constructor(e,t){this.state=Se(e),this.#e=t,this.dispatch=this.dispatch.bind(this)}#t(e){return this.#e[this.state.current][e]??this.state.current}dispatch(e){this.state.current=this.#t(e)}},Ei=Oe({component:`scroll-area`,parts:[`root`,`viewport`,`corner`,`thumb`,`scrollbar`]}),Di=new Xt(`ScrollArea.Root`),Oi=new Xt(`ScrollArea.Scrollbar`),ki=new Xt(`ScrollArea.ScrollbarVisible`),Ai=new Xt(`ScrollArea.ScrollbarAxis`),ji=new Xt(`ScrollArea.ScrollbarShared`),Mi=class e{static create(t){return Di.set(new e(t))}opts;attachment;#e=Z(null);get scrollAreaNode(){return C(this.#e)}set scrollAreaNode(e){P(this.#e,e,!0)}#t=Z(null);get viewportNode(){return C(this.#t)}set viewportNode(e){P(this.#t,e,!0)}#n=Z(null);get contentNode(){return C(this.#n)}set contentNode(e){P(this.#n,e,!0)}#r=Z(null);get scrollbarXNode(){return C(this.#r)}set scrollbarXNode(e){P(this.#r,e,!0)}#i=Z(null);get scrollbarYNode(){return C(this.#i)}set scrollbarYNode(e){P(this.#i,e,!0)}#a=Z(0);get cornerWidth(){return C(this.#a)}set cornerWidth(e){P(this.#a,e,!0)}#o=Z(0);get cornerHeight(){return C(this.#o)}set cornerHeight(e){P(this.#o,e,!0)}#s=Z(!1);get scrollbarXEnabled(){return C(this.#s)}set scrollbarXEnabled(e){P(this.#s,e,!0)}#c=Z(!1);get scrollbarYEnabled(){return C(this.#c)}set scrollbarYEnabled(e){P(this.#c,e,!0)}domContext;constructor(e){this.opts=e,this.attachment=we(e.ref,e=>this.scrollAreaNode=e),this.domContext=new Ht(e.ref)}#l=T(()=>({id:this.opts.id.current,dir:this.opts.dir.current,style:{position:`relative`,"--bits-scroll-area-corner-height":`${this.cornerHeight}px`,"--bits-scroll-area-corner-width":`${this.cornerWidth}px`},[Ei.root]:``,...this.attachment}));get props(){return C(this.#l)}set props(e){P(this.#l,e)}},Ni=class e{static create(t){return new e(t,Di.get())}opts;root;attachment;#e=Se(Jt());#t=Se(null);contentAttachment=we(this.#t,e=>this.root.contentNode=e);constructor(e,t){this.opts=e,this.root=t,this.attachment=we(e.ref,e=>this.root.viewportNode=e)}#n=T(()=>({id:this.opts.id.current,style:{overflowX:this.root.scrollbarXEnabled?`scroll`:`hidden`,overflowY:this.root.scrollbarYEnabled?`scroll`:`hidden`},[Ei.viewport]:``,...this.attachment}));get props(){return C(this.#n)}set props(e){P(this.#n,e)}#r=T(()=>({id:this.#e.current,"data-scroll-area-content":``,style:{minWidth:this.root.scrollbarXEnabled?`fit-content`:void 0},...this.contentAttachment}));get contentProps(){return C(this.#r)}set contentProps(e){P(this.#r,e)}},Pi=class e{static create(t){return Oi.set(new e(t,Di.get()))}opts;root;#e=T(()=>this.opts.orientation.current===`horizontal`);get isHorizontal(){return C(this.#e)}set isHorizontal(e){P(this.#e,e)}#t=Z(!1);get hasThumb(){return C(this.#t)}set hasThumb(e){P(this.#t,e,!0)}constructor(e,t){this.opts=e,this.root=t,Bt(()=>this.isHorizontal,e=>e?(this.root.scrollbarXEnabled=!0,()=>{this.root.scrollbarXEnabled=!1}):(this.root.scrollbarYEnabled=!0,()=>{this.root.scrollbarYEnabled=!1}))}},Fi=class e{static create(){return new e(Oi.get())}scrollbar;root;#e=Z(!1);get isVisible(){return C(this.#e)}set isVisible(e){P(this.#e,e,!0)}constructor(e){this.scrollbar=e,this.root=e.root,le(()=>{let e=this.root.scrollAreaNode,t=this.root.opts.scrollHideDelay.current,n=0;if(!e)return;let r=Ee(A(e,`pointerenter`,()=>{this.root.domContext.clearTimeout(n),Y(()=>this.isVisible=!0)}),A(e,`pointerleave`,()=>{n&&this.root.domContext.clearTimeout(n),n=this.root.domContext.setTimeout(()=>{Y(()=>{this.scrollbar.hasThumb=!1,this.isVisible=!1})},t)}));return()=>{this.root.domContext.getWindow().clearTimeout(n),r()}})}#t=T(()=>({"data-state":this.isVisible?`visible`:`hidden`}));get props(){return C(this.#t)}set props(e){P(this.#t,e)}},Ii=class e{static create(){return new e(Oi.get())}scrollbar;root;machine=new Ti(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});#e=T(()=>this.machine.state.current===`hidden`);get isHidden(){return C(this.#e)}set isHidden(e){P(this.#e,e)}constructor(e){this.scrollbar=e,this.root=e.root;let t=Vt(()=>this.machine.dispatch(`SCROLL_END`),100);le(()=>{let e=this.machine.state.current,t=this.root.opts.scrollHideDelay.current;if(e===`idle`){let e=this.root.domContext.setTimeout(()=>this.machine.dispatch(`HIDE`),t);return()=>this.root.domContext.clearTimeout(e)}}),le(()=>{let e=this.root.viewportNode;if(!e)return;let n=this.scrollbar.isHorizontal?`scrollLeft`:`scrollTop`,r=e[n];return A(e,`scroll`,()=>{let i=e[n];r!==i&&(this.machine.dispatch(`SCROLL`),t()),r=i})}),this.onpointerenter=this.onpointerenter.bind(this),this.onpointerleave=this.onpointerleave.bind(this)}onpointerenter(e){this.machine.dispatch(`POINTER_ENTER`)}onpointerleave(e){this.machine.dispatch(`POINTER_LEAVE`)}#t=T(()=>({"data-state":this.machine.state.current===`hidden`?`hidden`:`visible`,onpointerenter:this.onpointerenter,onpointerleave:this.onpointerleave}));get props(){return C(this.#t)}set props(e){P(this.#t,e)}},Li=class e{static create(){return new e(Oi.get())}scrollbar;root;#e=Z(!1);get isVisible(){return C(this.#e)}set isVisible(e){P(this.#e,e,!0)}constructor(e){this.scrollbar=e,this.root=e.root;let t=()=>{let e=this.root.viewportNode;if(!e)return;let t=e.offsetWidth<e.scrollWidth,n=e.offsetHeight<e.scrollHeight;this.isVisible=this.scrollbar.isHorizontal?t:n};new xi(()=>this.root.viewportNode,t),new xi(()=>this.root.contentNode,t)}#t=T(()=>({"data-state":this.isVisible?`visible`:`hidden`}));get props(){return C(this.#t)}set props(e){P(this.#t,e)}},Ri=class e{static create(){return ki.set(new e(Oi.get()))}scrollbar;root;#e=Z(null);get thumbNode(){return C(this.#e)}set thumbNode(e){P(this.#e,e,!0)}#t=Z(0);get pointerOffset(){return C(this.#t)}set pointerOffset(e){P(this.#t,e,!0)}#n=Z({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}});get sizes(){return C(this.#n)}set sizes(e){P(this.#n,e)}#r=T(()=>Gi(this.sizes.viewport,this.sizes.content));get thumbRatio(){return C(this.#r)}set thumbRatio(e){P(this.#r,e)}#i=T(()=>this.thumbRatio>0&&this.thumbRatio<1);get hasThumb(){return C(this.#i)}set hasThumb(e){P(this.#i,e)}#a=Z(``);get prevTransformStyle(){return C(this.#a)}set prevTransformStyle(e){P(this.#a,e,!0)}constructor(e){this.scrollbar=e,this.root=e.root,le(()=>{this.scrollbar.hasThumb=this.hasThumb}),le(()=>{!this.scrollbar.hasThumb&&this.thumbNode&&(this.prevTransformStyle=this.thumbNode.style.transform)})}setSizes(e){this.sizes=e}getScrollPosition(e,t){return qi({pointerPos:e,pointerOffset:this.pointerOffset,sizes:this.sizes,dir:t})}onThumbPointerUp(){this.pointerOffset=0}onThumbPointerDown(e){this.pointerOffset=e}xOnThumbPositionChange(){if(!(this.root.viewportNode&&this.thumbNode))return;let e=this.root.viewportNode.scrollLeft,t=`translate3d(${Ji({scrollPos:e,sizes:this.sizes,dir:this.root.opts.dir.current})}px, 0, 0)`;this.thumbNode.style.transform=t,this.prevTransformStyle=t}xOnWheelScroll(e){this.root.viewportNode&&(this.root.viewportNode.scrollLeft=e)}xOnDragScroll(e){this.root.viewportNode&&(this.root.viewportNode.scrollLeft=this.getScrollPosition(e,this.root.opts.dir.current))}yOnThumbPositionChange(){if(!(this.root.viewportNode&&this.thumbNode))return;let e=this.root.viewportNode.scrollTop,t=`translate3d(0, ${Ji({scrollPos:e,sizes:this.sizes})}px, 0)`;this.thumbNode.style.transform=t,this.prevTransformStyle=t}yOnWheelScroll(e){this.root.viewportNode&&(this.root.viewportNode.scrollTop=e)}yOnDragScroll(e){this.root.viewportNode&&(this.root.viewportNode.scrollTop=this.getScrollPosition(e,this.root.opts.dir.current))}},zi=class e{static create(t){return Ai.set(new e(t,ki.get()))}opts;scrollbarVis;root;scrollbar;attachment;#e=Z();get computedStyle(){return C(this.#e)}set computedStyle(e){P(this.#e,e,!0)}constructor(e,t){this.opts=e,this.scrollbarVis=t,this.root=t.root,this.scrollbar=t.scrollbar,this.attachment=we(this.scrollbar.opts.ref,e=>this.root.scrollbarXNode=e),le(()=>{this.scrollbar.opts.ref.current&&this.opts.mounted.current&&(this.computedStyle=getComputedStyle(this.scrollbar.opts.ref.current))}),le(()=>{this.onResize()})}onThumbPointerDown=e=>{this.scrollbarVis.onThumbPointerDown(e.x)};onDragScroll=e=>{this.scrollbarVis.xOnDragScroll(e.x)};onThumbPointerUp=()=>{this.scrollbarVis.onThumbPointerUp()};onThumbPositionChange=()=>{this.scrollbarVis.xOnThumbPositionChange()};onWheelScroll=(e,t)=>{if(!this.root.viewportNode)return;let n=this.root.viewportNode.scrollLeft+e.deltaX;this.scrollbarVis.xOnWheelScroll(n),Xi(n,t)&&e.preventDefault()};onResize=()=>{this.scrollbar.opts.ref.current&&this.root.viewportNode&&this.computedStyle&&this.scrollbarVis.setSizes({content:this.root.viewportNode.scrollWidth,viewport:this.root.viewportNode.offsetWidth,scrollbar:{size:this.scrollbar.opts.ref.current.clientWidth,paddingStart:Wi(this.computedStyle.paddingLeft),paddingEnd:Wi(this.computedStyle.paddingRight)}})};#t=T(()=>Ki(this.scrollbarVis.sizes));get thumbSize(){return C(this.#t)}set thumbSize(e){P(this.#t,e)}#n=T(()=>({id:this.scrollbar.opts.id.current,"data-orientation":`horizontal`,style:{bottom:0,left:this.root.opts.dir.current===`rtl`?`var(--bits-scroll-area-corner-width)`:0,right:this.root.opts.dir.current===`ltr`?`var(--bits-scroll-area-corner-width)`:0,"--bits-scroll-area-thumb-width":`${this.thumbSize}px`},...this.attachment}));get props(){return C(this.#n)}set props(e){P(this.#n,e)}},Bi=class e{static create(t){return Ai.set(new e(t,ki.get()))}opts;scrollbarVis;root;scrollbar;attachment;#e=Z();get computedStyle(){return C(this.#e)}set computedStyle(e){P(this.#e,e,!0)}constructor(e,t){this.opts=e,this.scrollbarVis=t,this.root=t.root,this.scrollbar=t.scrollbar,this.attachment=we(this.scrollbar.opts.ref,e=>this.root.scrollbarYNode=e),le(()=>{this.scrollbar.opts.ref.current&&this.opts.mounted.current&&(this.computedStyle=getComputedStyle(this.scrollbar.opts.ref.current))}),le(()=>{this.onResize()}),this.onThumbPointerDown=this.onThumbPointerDown.bind(this),this.onDragScroll=this.onDragScroll.bind(this),this.onThumbPointerUp=this.onThumbPointerUp.bind(this),this.onThumbPositionChange=this.onThumbPositionChange.bind(this),this.onWheelScroll=this.onWheelScroll.bind(this),this.onResize=this.onResize.bind(this)}onThumbPointerDown(e){this.scrollbarVis.onThumbPointerDown(e.y)}onDragScroll(e){this.scrollbarVis.yOnDragScroll(e.y)}onThumbPointerUp(){this.scrollbarVis.onThumbPointerUp()}onThumbPositionChange(){this.scrollbarVis.yOnThumbPositionChange()}onWheelScroll(e,t){if(!this.root.viewportNode)return;let n=this.root.viewportNode.scrollTop+e.deltaY;this.scrollbarVis.yOnWheelScroll(n),Xi(n,t)&&e.preventDefault()}onResize(){this.scrollbar.opts.ref.current&&this.root.viewportNode&&this.computedStyle&&this.scrollbarVis.setSizes({content:this.root.viewportNode.scrollHeight,viewport:this.root.viewportNode.offsetHeight,scrollbar:{size:this.scrollbar.opts.ref.current.clientHeight,paddingStart:Wi(this.computedStyle.paddingTop),paddingEnd:Wi(this.computedStyle.paddingBottom)}})}#t=T(()=>Ki(this.scrollbarVis.sizes));get thumbSize(){return C(this.#t)}set thumbSize(e){P(this.#t,e)}#n=T(()=>({id:this.scrollbar.opts.id.current,"data-orientation":`vertical`,style:{top:0,right:this.root.opts.dir.current===`ltr`?0:void 0,left:this.root.opts.dir.current===`rtl`?0:void 0,bottom:`var(--bits-scroll-area-corner-height)`,"--bits-scroll-area-thumb-height":`${this.thumbSize}px`},...this.attachment}));get props(){return C(this.#n)}set props(e){P(this.#n,e)}},Vi=class e{static create(){return ji.set(new e(Ai.get()))}scrollbarState;root;scrollbarVis;scrollbar;#e=Z(null);get rect(){return C(this.#e)}set rect(e){P(this.#e,e)}#t=Z(``);get prevWebkitUserSelect(){return C(this.#t)}set prevWebkitUserSelect(e){P(this.#t,e,!0)}handleResize;handleThumbPositionChange;handleWheelScroll;handleThumbPointerDown;handleThumbPointerUp;#n=T(()=>this.scrollbarVis.sizes.content-this.scrollbarVis.sizes.viewport);get maxScrollPos(){return C(this.#n)}set maxScrollPos(e){P(this.#n,e)}constructor(e){this.scrollbarState=e,this.root=e.root,this.scrollbarVis=e.scrollbarVis,this.scrollbar=e.scrollbarVis.scrollbar,this.handleResize=()=>this.scrollbarState.onResize(),this.handleThumbPositionChange=this.scrollbarState.onThumbPositionChange,this.handleWheelScroll=this.scrollbarState.onWheelScroll,this.handleThumbPointerDown=this.scrollbarState.onThumbPointerDown,this.handleThumbPointerUp=this.scrollbarState.onThumbPointerUp,le(()=>{let e=this.maxScrollPos,t=this.scrollbar.opts.ref.current;return this.root.viewportNode,A(this.root.domContext.getDocument(),`wheel`,n=>{let r=n.target;t?.contains(r)&&this.handleWheelScroll(n,e)},{passive:!1})}),ne(()=>{this.scrollbarVis.sizes,Y(()=>this.handleThumbPositionChange())}),new xi(()=>this.scrollbar.opts.ref.current,this.handleResize),new xi(()=>this.root.contentNode,this.handleResize),this.onpointerdown=this.onpointerdown.bind(this),this.onpointermove=this.onpointermove.bind(this),this.onpointerup=this.onpointerup.bind(this),this.onlostpointercapture=this.onlostpointercapture.bind(this)}handleDragScroll(e){if(!this.rect)return;let t=e.clientX-this.rect.left,n=e.clientY-this.rect.top;this.scrollbarState.onDragScroll({x:t,y:n})}#r(){this.rect!==null&&(this.root.domContext.getDocument().body.style.webkitUserSelect=this.prevWebkitUserSelect,this.root.viewportNode&&(this.root.viewportNode.style.scrollBehavior=``),this.rect=null)}onpointerdown(e){e.button===0&&(e.target.setPointerCapture(e.pointerId),this.rect=this.scrollbar.opts.ref.current?.getBoundingClientRect()??null,this.prevWebkitUserSelect=this.root.domContext.getDocument().body.style.webkitUserSelect,this.root.domContext.getDocument().body.style.webkitUserSelect=`none`,this.root.viewportNode&&(this.root.viewportNode.style.scrollBehavior=`auto`),this.handleDragScroll(e))}onpointermove(e){this.handleDragScroll(e)}onpointerup(e){let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),this.#r()}onlostpointercapture(e){this.#r()}#i=T(()=>Te({...this.scrollbarState.props,style:{position:`absolute`,...this.scrollbarState.props.style},[Ei.scrollbar]:``,onpointerdown:this.onpointerdown,onpointermove:this.onpointermove,onpointerup:this.onpointerup,onlostpointercapture:this.onlostpointercapture}));get props(){return C(this.#i)}set props(e){P(this.#i,e)}},Hi=class e{static create(t){return new e(t,ji.get())}opts;scrollbarState;attachment;#e;#t=Z();#n=Vt(()=>{C(this.#t)&&(C(this.#t)(),P(this.#t,void 0))},100);constructor(e,t){this.opts=e,this.scrollbarState=t,this.#e=t.root,this.attachment=we(this.opts.ref,e=>this.scrollbarState.scrollbarVis.thumbNode=e),le(()=>{let e=this.#e.viewportNode;return e?(Y(()=>this.scrollbarState.handleThumbPositionChange()),A(e,`scroll`,()=>{if(this.#n(),!C(this.#t)){let t=Zi(e,this.scrollbarState.handleThumbPositionChange);P(this.#t,t,!0),this.scrollbarState.handleThumbPositionChange()}})):void 0}),this.onpointerdowncapture=this.onpointerdowncapture.bind(this),this.onpointerup=this.onpointerup.bind(this)}onpointerdowncapture(e){let t=e.target;if(!t)return;let n=t.getBoundingClientRect(),r=e.clientX-n.left,i=e.clientY-n.top;this.scrollbarState.handleThumbPointerDown({x:r,y:i})}onpointerup(e){this.scrollbarState.handleThumbPointerUp()}#r=T(()=>({id:this.opts.id.current,"data-state":this.scrollbarState.scrollbarVis.hasThumb?`visible`:`hidden`,style:{width:`var(--bits-scroll-area-thumb-width)`,height:`var(--bits-scroll-area-thumb-height)`,transform:this.scrollbarState.scrollbarVis.prevTransformStyle},onpointerdowncapture:this.onpointerdowncapture,onpointerup:this.onpointerup,[Ei.thumb]:``,...this.attachment}));get props(){return C(this.#r)}set props(e){P(this.#r,e)}},Ui=class e{static create(t){return new e(t,Di.get())}opts;root;attachment;#e=Z(0);#t=Z(0);#n=T(()=>!!(C(this.#e)&&C(this.#t)));get hasSize(){return C(this.#n)}set hasSize(e){P(this.#n,e)}constructor(e,t){this.opts=e,this.root=t,this.attachment=we(this.opts.ref),new xi(()=>this.root.scrollbarXNode,()=>{let e=this.root.scrollbarXNode?.offsetHeight||0;this.root.cornerHeight=e,P(this.#t,e,!0)}),new xi(()=>this.root.scrollbarYNode,()=>{let e=this.root.scrollbarYNode?.offsetWidth||0;this.root.cornerWidth=e,P(this.#e,e,!0)})}#r=T(()=>({id:this.opts.id.current,style:{width:C(this.#e),height:C(this.#t),position:`absolute`,right:this.root.opts.dir.current===`ltr`?0:void 0,left:this.root.opts.dir.current===`rtl`?0:void 0,bottom:0},[Ei.corner]:``,...this.attachment}));get props(){return C(this.#r)}set props(e){P(this.#r,e)}};function Wi(e){return e?Number.parseInt(e,10):0}function Gi(e,t){let n=e/t;return Number.isNaN(n)?0:n}function Ki(e){let t=Gi(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function qi({pointerPos:e,pointerOffset:t,sizes:n,dir:r=`ltr`}){let i=Ki(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return Yi([c,l],d)(e)}function Ji({scrollPos:e,sizes:t,dir:n=`ltr`}){let r=Ki(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=n===`ltr`?[0,o]:[o*-1,0],l=wi(e,c[0],c[1]);return Yi([0,o],[0,s])(l)}function Yi(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Xi(e,t){return e>0&&e<t}function Zi(e,t){let n={left:e.scrollLeft,top:e.scrollTop},r=0,i=en(e);return(function a(){let o={left:e.scrollLeft,top:e.scrollTop},s=n.left!==o.left,c=n.top!==o.top;(s||c)&&t(),n=o,r=i.requestAnimationFrame(a)})(),()=>i.cancelAnimationFrame(r)}var Qi=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`id`,`type`,`dir`,`scrollHideDelay`,`children`,`child`]),$i=D(`<div><!></div>`);function ea(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`id`,19,()=>je(r)),o=J(n,`type`,3,`hover`),s=J(n,`dir`,3,`ltr`),d=J(n,`scrollHideDelay`,3,600),f=W(n,Qi),p=Mi.create({type:Me(()=>o()),dir:Me(()=>s()),scrollHideDelay:Me(()=>d()),id:Me(()=>a()),ref:Me(()=>i(),e=>i(e))}),m=T(()=>Te(f,p.props));var g=u(),_=z(g),v=e=>{var t=u(),r=z(t);x(r,()=>n.child,()=>({props:C(m)})),O(e,t)},y=e=>{var t=$i();R(t,()=>({...C(m)}));var r=I(t);x(r,()=>n.children??h),c(t),O(e,t)};t(_,e=>{n.child?e(v):e(y,-1)}),O(e,g),b()}var ta=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`id`,`children`]),na=D(`<div><div><!></div></div>`);function ra(e,t){let n=l();V(t,!0);let r=J(t,`ref`,15,null),i=J(t,`id`,19,()=>je(n)),a=W(t,ta),o=Ni.create({id:Me(()=>i()),ref:Me(()=>r(),e=>r(e))}),s=T(()=>Te(a,o.props)),u=T(()=>Te({},o.contentProps));var d=na();R(d,()=>({...C(s)}));var f=I(d);R(f,()=>({...C(u)}));var p=I(f);x(p,()=>t.children??h),c(f),c(d),O(e,d),b()}var ia=new Set([`$$slots`,`$$events`,`$$legacy`,`child`,`children`]),aa=D(`<div><!></div>`);function oa(e,n){V(n,!0);let r=W(n,ia),i=Vi.create(),a=T(()=>Te(r,i.props));var o=u(),s=z(o),l=e=>{var t=u(),r=z(t);x(r,()=>n.child,()=>({props:C(a)})),O(e,t)},d=e=>{var t=aa();R(t,()=>({...C(a)}));var r=I(t);x(r,()=>n.children??h),c(t),O(e,t)};t(s,e=>{n.child?e(l):e(d,-1)}),O(e,o),b()}var sa=new Set([`$$slots`,`$$events`,`$$legacy`]);function ca(e,t){V(t,!0);let n=W(t,sa),r=new Gt,i=zi.create({mounted:Me(()=>r.current)}),a=T(()=>Te(n,i.props));oa(e,q(()=>C(a))),b()}var la=new Set([`$$slots`,`$$events`,`$$legacy`]);function ua(e,t){V(t,!0);let n=W(t,la),r=new Gt,i=Bi.create({mounted:Me(()=>r.current)}),a=T(()=>Te(n,i.props));oa(e,q(()=>C(a))),b()}var da=new Set([`$$slots`,`$$events`,`$$legacy`]);function fa(e,n){V(n,!0);let r=W(n,da),i=Ri.create();var a=u(),o=z(a),s=e=>{ca(e,q(()=>r))},c=e=>{ua(e,q(()=>r))};t(o,e=>{i.scrollbar.opts.orientation.current===`horizontal`?e(s):e(c,-1)}),O(e,a),b()}var pa=new Set([`$$slots`,`$$events`,`$$legacy`,`forceMount`]);function ma(e,t){V(t,!0);let n=J(t,`forceMount`,3,!1),r=W(t,pa),i=Li.create(),a=T(()=>Te(r,i.props));{let t=e=>{fa(e,q(()=>C(a)))},r=T(()=>n()||i.isVisible);Ci(e,{get open(){return C(r)},get ref(){return i.scrollbar.opts.ref},presence:t,$$slots:{presence:!0}})}b()}var ha=new Set([`$$slots`,`$$events`,`$$legacy`,`forceMount`]);function ga(e,t){V(t,!0);let n=J(t,`forceMount`,3,!1),r=W(t,ha),i=Ii.create(),a=T(()=>Te(r,i.props));{let t=e=>{fa(e,q(()=>C(a)))},r=T(()=>n()||!i.isHidden);Ci(e,q(()=>C(a),{get open(){return C(r)},get ref(){return i.scrollbar.opts.ref},presence:t,$$slots:{presence:!0}}))}b()}var _a=new Set([`$$slots`,`$$events`,`$$legacy`,`forceMount`]);function va(e,t){V(t,!0);let n=J(t,`forceMount`,3,!1),r=W(t,_a),i=Fi.create(),a=Li.create(),o=T(()=>Te(r,i.props,a.props,{"data-state":i.isVisible?`visible`:`hidden`})),s=T(()=>n()||i.isVisible&&a.isVisible);Ci(e,{get open(){return C(s)},get ref(){return a.scrollbar.opts.ref},presence:e=>{fa(e,q(()=>C(o)))},$$slots:{presence:!0}}),b()}var ya=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`id`,`orientation`]);function ba(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`id`,19,()=>je(r)),o=W(n,ya),s=Pi.create({orientation:Me(()=>n.orientation),id:Me(()=>a()),ref:Me(()=>i(),e=>i(e))}),c=T(()=>s.root.opts.type.current);var d=u(),f=z(d),p=e=>{va(e,q(()=>o,{get id(){return a()}}))},m=e=>{ga(e,q(()=>o,{get id(){return a()}}))},h=e=>{ma(e,q(()=>o,{get id(){return a()}}))},g=e=>{fa(e,q(()=>o,{get id(){return a()}}))};t(f,e=>{C(c)===`hover`?e(p):C(c)===`scroll`?e(m,1):C(c)===`auto`?e(h,2):C(c)===`always`&&e(g,3)}),O(e,d),b()}var xa=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`id`,`child`,`children`,`present`]),Sa=D(`<div><!></div>`);function Ca(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=W(n,xa),a=new Gt,o=Hi.create({id:Me(()=>n.id),ref:Me(()=>r(),e=>r(e)),mounted:Me(()=>a.current)}),s=T(()=>Te(i,o.props,{style:{hidden:!n.present}}));var l=u(),d=z(l),f=e=>{var t=u(),r=z(t);x(r,()=>n.child,()=>({props:C(s)})),O(e,t)},p=e=>{var t=Sa();R(t,()=>({...C(s)}));var r=I(t);x(r,()=>n.children??h),c(t),O(e,t)};t(d,e=>{n.child?e(f):e(p,-1)}),O(e,l),b()}var wa=new Set([`$$slots`,`$$events`,`$$legacy`,`id`,`ref`,`forceMount`]);function Ta(e,t){let n=l();V(t,!0);let r=J(t,`id`,19,()=>je(n)),i=J(t,`ref`,15,null),a=J(t,`forceMount`,3,!1),o=W(t,wa),s=ki.get();{let t=(e,t)=>{let n=()=>(t?.()).present;Ca(e,q(()=>o,{get id(){return r()},get present(){return n()},get ref(){return i()},set ref(e){i(e)}}))},n=T(()=>a()||s.hasThumb);Ci(e,{get open(){return C(n)},get ref(){return s.scrollbar.opts.ref},presence:t,$$slots:{presence:!0}})}b()}var Ea=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`id`,`children`,`child`]),Da=D(`<div><!></div>`);function Oa(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=W(n,Ea),a=Ui.create({id:Me(()=>n.id),ref:Me(()=>r(),e=>r(e))}),o=T(()=>Te(i,a.props));var s=u(),l=z(s),d=e=>{var t=u(),r=z(t);x(r,()=>n.child,()=>({props:C(o)})),O(e,t)},f=e=>{var t=Da();R(t,()=>({...C(o)}));var r=I(t);x(r,()=>n.children??h),c(t),O(e,t)};t(l,e=>{n.child?e(d):e(f,-1)}),O(e,s),b()}var ka=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`id`]);function Aa(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`id`,19,()=>je(r)),o=W(n,ka),s=Di.get(),c=T(()=>!!(s.scrollbarXNode&&s.scrollbarYNode)),d=T(()=>s.opts.type.current!==`scroll`&&C(c));var f=u(),p=z(f),m=e=>{Oa(e,q(()=>o,{get id(){return a()},get ref(){return i()},set ref(e){i(e)}}))};t(p,e=>{C(d)&&e(m)}),O(e,f),b()}function ja(e,t,n){let r={position:`absolute`};return e===`lr`?(r.left=`${t}%`,r.right=`${n}%`):e===`rl`?(r.right=`${t}%`,r.left=`${n}%`):e===`bt`?(r.bottom=`${t}%`,r.top=`${n}%`):(r.top=`${t}%`,r.bottom=`${n}%`),r}function Ma(e,t){let n={position:`absolute`};return e===`lr`?(n.left=`${t}%`,n.translate=`-50% 0`):e===`rl`?(n.right=`${t}%`,n.translate=`50% 0`):e===`bt`?(n.bottom=`${t}%`,n.translate=`0 50%`):(n.top=`${t}%`,n.translate=`0 -50%`),n}function Na(e,t,n){let r={position:`absolute`};return e===`lr`?(r.left=`${t}%`,r.translate=`${n}% 0`):e===`rl`?(r.right=`${t}%`,r.translate=`${-n}% 0`):e===`bt`?(r.bottom=`${t}%`,r.translate=`0 ${-n}%`):(r.top=`${t}%`,r.translate=`0 ${n}%`),r}function Pa(e){if(Math.floor(e)===e)return 0;let t=e.toString();if(t.indexOf(`.`)!==-1&&t.indexOf(`e-`)===-1)return t.split(`.`)[1].length;if(t.indexOf(`e-`)!==-1){let e=t.split(`e-`);return parseInt(e[1],10)}return 0}function Fa(e,t){let n=10**t;return Math.round(e*n)/n}function Ia(e,t,n){if(typeof e==`number`){if(!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(e)||e<=0)throw Error(`Slider requires finite \`min\` and \`max\` values and a finite \`step\` greater than 0. Received min=${t}, max=${n}, step=${e}.`);let r=n-t,i=Math.ceil(r/e),a=Pa(e),o=10**a;Math.round(r*o)%Math.round(e*o)===0&&i++;let s=[];for(let n=0;n<i;n++){let r=Fa(t+n*e,a);s.push(r)}return s}return[...new Set(e)].filter(e=>e>=t&&e<=n).sort((e,t)=>e-t)}function La(e,t){if(t.length===0)return e;let n=t[0],r=Math.abs(e-n);for(let i of t){let t=Math.abs(e-i);t<r&&(r=t,n=i)}return n}function Ra(e,t,n){let r=t.indexOf(e);return r===-1?La(e,t):n===`next`?r<t.length-1?t[r+1]:e:r>0?t[r-1]:e}function za(e,t,n=!0){let[r,i]=e,[a,o]=t,s=(o-a)/(i-r);return e=>{let t=a+s*(e-r);return n?t>Math.max(a,o)?Math.max(a,o):t<Math.min(a,o)?Math.min(a,o):t:t}}var Ba=Oe({component:`slider`,parts:[`root`,`thumb`,`range`,`tick`,`tick-label`,`thumb-label`]}),Va=new Xt(`Slider.Root`),Ha=class{opts;attachment;#e=Z(!1);get isActive(){return C(this.#e)}set isActive(e){P(this.#e,e,!0)}#t=Z(0);#n=T(()=>this.opts.orientation.current===`horizontal`?this.opts.dir.current===`rtl`?`rl`:`lr`:this.opts.dir.current===`rtl`?`tb`:`bt`);get direction(){return C(this.#n)}set direction(e){P(this.#n,e)}#r=T(()=>Ia(this.opts.step.current,this.opts.min.current,this.opts.max.current));get normalizedSteps(){return C(this.#r)}set normalizedSteps(e){P(this.#r,e)}domContext;constructor(e){this.opts=e,this.attachment=we(e.ref),this.domContext=new Ht(this.opts.ref),new xi(()=>this.opts.ref.current,this.#i)}#i=()=>{P(this.#t,C(this.#t)+1)};isThumbActive(e){return this.isActive}#a=T(()=>{if(!this.opts.disabled.current)return this.opts.orientation.current===`horizontal`?`pan-y`:`pan-x`});getAllThumbs=()=>{let e=this.opts.ref.current;return e?Array.from(e.querySelectorAll(Ba.selector(`thumb`))):[]};getThumbScale=()=>{C(this.#t);let e=this.opts.trackPadding?.current;if(e!==void 0&&e>0)return[e,100-e];if(this.opts.thumbPositioning.current===`exact`)return[0,100];let t=this.opts.orientation.current===`vertical`,n=this.getAllThumbs()[0],r=t?n?.offsetHeight:n?.offsetWidth;if(r===void 0||Number.isNaN(r)||r===0)return[0,100];let i=t?this.opts.ref.current?.offsetHeight:this.opts.ref.current?.offsetWidth;if(i===void 0||Number.isNaN(i)||i===0)return[0,100];let a=r/2/i*100;return[a,100-a]};getPositionFromValue=e=>{let t=this.getThumbScale();return za([this.opts.min.current,this.opts.max.current],t)(e)};#o=T(()=>({id:this.opts.id.current,"data-orientation":this.opts.orientation.current,"data-disabled":De(this.opts.disabled.current),style:{touchAction:C(this.#a)},[Ba.root]:``,...this.attachment}));get props(){return C(this.#o)}set props(e){P(this.#o,e)}},Ua=class extends Ha{opts;isMulti=!1;constructor(e){super(e),this.opts=e,tn(()=>Ee(A(this.domContext.getDocument(),`pointerdown`,this.handlePointerDown),A(this.domContext.getDocument(),`pointerup`,this.handlePointerUp),A(this.domContext.getDocument(),`pointermove`,this.handlePointerMove),A(this.domContext.getDocument(),`pointerleave`,this.handlePointerUp))),Bt([()=>this.opts.step.current,()=>this.opts.min.current,()=>this.opts.max.current,()=>this.opts.value.current],([e,t,n,r])=>{let i=Ia(e,t,n),a=e=>i.includes(e),o=e=>La(e,i);a(r)||(this.opts.value.current=o(r))})}isTickValueSelected=e=>this.opts.value.current===e;applyPosition({clientXY:e,start:t,end:n}){let r=this.opts.min.current,i=this.opts.max.current,a=(e-t)/(n-t)*(i-r)+r;if(a<r)this.updateValue(r);else if(a>i)this.updateValue(i);else{let e=this.normalizedSteps,t=La(a,e);this.updateValue(t)}}updateValue=e=>{this.opts.value.current=La(e,this.normalizedSteps)};handlePointerMove=e=>{if(!this.isActive||this.opts.disabled.current)return;e.preventDefault(),e.stopPropagation();let t=this.opts.ref.current,n=this.getAllThumbs()[0];if(!t||!n)return;n.focus();let{left:r,right:i,top:a,bottom:o}=t.getBoundingClientRect();this.direction===`lr`?this.applyPosition({clientXY:e.clientX,start:r,end:i}):this.direction===`rl`?this.applyPosition({clientXY:e.clientX,start:i,end:r}):this.direction===`bt`?this.applyPosition({clientXY:e.clientY,start:o,end:a}):this.direction===`tb`&&this.applyPosition({clientXY:e.clientY,start:a,end:o})};handlePointerDown=e=>{if(e.button!==0||this.opts.disabled.current)return;let t=this.opts.ref.current,n=this.getAllThumbs()[0];if(!n||!t)return;let r=e.composedPath()[0]??e.target;Zt(r)&&t.contains(r)&&(e.preventDefault(),n.focus(),this.isActive=!0,this.handlePointerMove(e))};handlePointerUp=()=>{this.opts.disabled.current||(this.isActive&&this.opts.onValueCommit.current(Y(()=>this.opts.value.current)),this.isActive=!1)};#e=T(()=>{let e=this.opts.value.current;return Array.from({length:1},()=>{let t=e,n=this.getPositionFromValue(t),r=Ma(this.direction,n);return{role:`slider`,"aria-valuemin":this.opts.min.current,"aria-valuemax":this.opts.max.current,"aria-valuenow":t,"aria-disabled":ke(this.opts.disabled.current),"aria-orientation":this.opts.orientation.current,"data-value":t,"data-orientation":this.opts.orientation.current,style:r,[Ba.thumb]:``}})});get thumbsPropsArr(){return C(this.#e)}set thumbsPropsArr(e){P(this.#e,e)}#t=T(()=>this.thumbsPropsArr.map((e,t)=>t));get thumbsRenderArr(){return C(this.#t)}set thumbsRenderArr(e){P(this.#t,e)}#n=T(()=>{let e=this.normalizedSteps,t=this.opts.value.current;return e.map((n,r)=>{let i=this.getPositionFromValue(n),a=r===0,o=r===e.length-1,s=a?0:o?-100:-50,c=Na(this.direction,i,s),l=n<=t;return{"data-disabled":De(this.opts.disabled.current),"data-orientation":this.opts.orientation.current,"data-bounded":l?``:void 0,"data-value":n,"data-selected":this.isTickValueSelected(n)?``:void 0,style:c,[Ba.tick]:``}})});get ticksPropsArr(){return C(this.#n)}set ticksPropsArr(e){P(this.#n,e)}#r=T(()=>this.ticksPropsArr.map((e,t)=>t));get ticksRenderArr(){return C(this.#r)}set ticksRenderArr(e){P(this.#r,e)}#i=T(()=>this.ticksPropsArr.map((e,t)=>({value:e[`data-value`],index:t})));get tickItemsArr(){return C(this.#i)}set tickItemsArr(e){P(this.#i,e)}#a=T(()=>[{value:this.opts.value.current,index:0}]);get thumbItemsArr(){return C(this.#a)}set thumbItemsArr(e){P(this.#a,e)}#o=T(()=>({ticks:this.ticksRenderArr,thumbs:this.thumbsRenderArr,tickItems:this.tickItemsArr,thumbItems:this.thumbItemsArr}));get snippetProps(){return C(this.#o)}set snippetProps(e){P(this.#o,e)}},Wa=class extends Ha{opts;isMulti=!0;#e=Z(null);get activeThumb(){return C(this.#e)}set activeThumb(e){P(this.#e,e,!0)}#t=Z(0);get currentThumbIdx(){return C(this.#t)}set currentThumbIdx(e){P(this.#t,e,!0)}constructor(e){super(e),this.opts=e,tn(()=>Ee(A(this.domContext.getDocument(),`pointerdown`,this.handlePointerDown),A(this.domContext.getDocument(),`pointerup`,this.handlePointerUp),A(this.domContext.getDocument(),`pointermove`,this.handlePointerMove),A(this.domContext.getDocument(),`pointerleave`,this.handlePointerUp))),Bt([()=>this.opts.step.current,()=>this.opts.min.current,()=>this.opts.max.current,()=>this.opts.value.current],([e,t,n,r])=>{let i=Ia(e,t,n),a=e=>i.includes(e),o=e=>La(e,i);r.some(e=>!a(e))&&(this.opts.value.current=r.map(o))})}isTickValueSelected=e=>this.opts.value.current.includes(e);isThumbActive(e){return this.isActive&&this.activeThumb?.idx===e}applyPosition({clientXY:e,activeThumbIdx:t,start:n,end:r}){let i=this.opts.min.current,a=this.opts.max.current,o=(e-n)/(r-n)*(a-i)+i;if(o<i)this.updateValue(i,t);else if(o>a)this.updateValue(a,t);else{let e=this.normalizedSteps,n=La(o,e);this.updateValue(n,t)}}#n=e=>{let t=this.getAllThumbs();if(!t.length)return;for(let e of t)e.blur();let n=t.map(t=>{if(this.opts.orientation.current===`horizontal`){let{left:n,right:r}=t.getBoundingClientRect();return Math.abs(e.clientX-(n+r)/2)}{let{top:n,bottom:r}=t.getBoundingClientRect();return Math.abs(e.clientY-(n+r)/2)}}),r=t[n.indexOf(Math.min(...n))];return{node:r,idx:t.indexOf(r)}};handlePointerMove=e=>{if(!this.isActive||this.opts.disabled.current)return;e.preventDefault(),e.stopPropagation();let t=this.opts.ref.current,n=this.activeThumb;if(!t||!n)return;n.node.focus();let{left:r,right:i,top:a,bottom:o}=t.getBoundingClientRect(),s=this.direction;s===`lr`?this.applyPosition({clientXY:e.clientX,activeThumbIdx:n.idx,start:r,end:i}):s===`rl`?this.applyPosition({clientXY:e.clientX,activeThumbIdx:n.idx,start:i,end:r}):s===`bt`?this.applyPosition({clientXY:e.clientY,activeThumbIdx:n.idx,start:o,end:a}):s===`tb`&&this.applyPosition({clientXY:e.clientY,activeThumbIdx:n.idx,start:a,end:o})};handlePointerDown=e=>{if(e.button!==0||this.opts.disabled.current)return;let t=this.opts.ref.current,n=this.#n(e);if(!n||!t)return;let r=e.composedPath()[0]??e.target;Zt(r)&&t.contains(r)&&(e.preventDefault(),this.activeThumb=n,n.node.focus(),this.isActive=!0,this.handlePointerMove(e))};handlePointerUp=()=>{this.opts.disabled.current||(this.isActive&&this.opts.onValueCommit.current(Y(()=>this.opts.value.current)),this.isActive=!1)};getAllThumbs=()=>{let e=this.opts.ref.current;return e?Array.from(e.querySelectorAll(Ba.selector(`thumb`))):[]};updateValue=(e,t)=>{let n=this.opts.value.current;if(!n.length){this.opts.value.current.push(e);return}if(n[t]===e)return;let r=[...n];if(!sn(t,r))return;let i=r[t]>e?-1:1,a=()=>{let n=t+i;r[t]=r[n],r[n]=e;let a=this.getAllThumbs();a.length&&(a[n]?.focus(),this.activeThumb={node:a[n],idx:n})};if(this.opts.autoSort.current&&(i===-1&&e<r[t-1]||i===1&&e>r[t+1])){a(),this.opts.value.current=r;return}let o=this.normalizedSteps;r[t]=La(e,o),this.opts.value.current=r};#r=T(()=>{let e=this.opts.value.current;return Array.from({length:e.length||1},(t,n)=>{let r=Y(()=>this.currentThumbIdx);r<e.length&&Y(()=>{this.currentThumbIdx=r+1});let i=e[n],a=this.getPositionFromValue(i??0),o=Ma(this.direction,a);return{role:`slider`,"aria-valuemin":this.opts.min.current,"aria-valuemax":this.opts.max.current,"aria-valuenow":i,"aria-disabled":ke(this.opts.disabled.current),"aria-orientation":this.opts.orientation.current,"data-value":i,"data-orientation":this.opts.orientation.current,style:o,[Ba.thumb]:``}})});get thumbsPropsArr(){return C(this.#r)}set thumbsPropsArr(e){P(this.#r,e)}#i=T(()=>this.thumbsPropsArr.map((e,t)=>t));get thumbsRenderArr(){return C(this.#i)}set thumbsRenderArr(e){P(this.#i,e)}#a=T(()=>{let e=this.normalizedSteps,t=this.opts.value.current;return e.map((n,r)=>{let i=this.getPositionFromValue(n),a=r===0,o=r===e.length-1,s=a?0:o?-100:-50,c=Na(this.direction,i,s),l=t.length===1?n<=t[0]:t[0]<=n&&n<=t[t.length-1];return{"data-disabled":De(this.opts.disabled.current),"data-orientation":this.opts.orientation.current,"data-bounded":l?``:void 0,"data-value":n,style:c,[Ba.tick]:``}})});get ticksPropsArr(){return C(this.#a)}set ticksPropsArr(e){P(this.#a,e)}#o=T(()=>this.ticksPropsArr.map((e,t)=>t));get ticksRenderArr(){return C(this.#o)}set ticksRenderArr(e){P(this.#o,e)}#s=T(()=>this.ticksPropsArr.map((e,t)=>({value:e[`data-value`],index:t})));get tickItemsArr(){return C(this.#s)}set tickItemsArr(e){P(this.#s,e)}#c=T(()=>this.opts.value.current.map((e,t)=>({value:e,index:t})));get thumbItemsArr(){return C(this.#c)}set thumbItemsArr(e){P(this.#c,e)}#l=T(()=>({ticks:this.ticksRenderArr,thumbs:this.thumbsRenderArr,tickItems:this.tickItemsArr,thumbItems:this.thumbItemsArr}));get snippetProps(){return C(this.#l)}set snippetProps(e){P(this.#l,e)}},Ga=class{static create(e){let{type:t,...n}=e,r=t===`single`?new Ua(n):new Wa(n);return Va.set(r)}},Ka=[Wt,zt,Rt,Qt,Ut,`End`],qa=class e{static create(t){return new e(t,Va.get())}opts;root;attachment;constructor(e,t){this.opts=e,this.root=t,this.attachment=we(e.ref)}#e=T(()=>{if(Array.isArray(this.root.opts.value.current)){let e=this.root.opts.value.current.length>1?this.root.getPositionFromValue(Math.min(...this.root.opts.value.current)??0):0,t=100-this.root.getPositionFromValue(Math.max(...this.root.opts.value.current)??0);return{position:`absolute`,...ja(this.root.direction,e,t)}}{let e=this.root.opts.trackPadding?.current,t=this.root.opts.value.current,n=this.root.opts.max.current,r=e!==void 0&&e>0&&t===n?0:100-this.root.getPositionFromValue(t);return{position:`absolute`,...ja(this.root.direction,0,r)}}});get rangeStyles(){return C(this.#e)}set rangeStyles(e){P(this.#e,e)}#t=T(()=>({id:this.opts.id.current,"data-orientation":this.root.opts.orientation.current,"data-disabled":De(this.root.opts.disabled.current),style:this.rangeStyles,[Ba.range]:``,...this.attachment}));get props(){return C(this.#t)}set props(e){P(this.#t,e)}},Ja=class e{static create(t){return new e(t,Va.get())}opts;root;attachment;#e=T(()=>this.root.opts.disabled.current||this.opts.disabled.current);constructor(e,t){this.opts=e,this.root=t,this.attachment=we(e.ref),this.onkeydown=this.onkeydown.bind(this)}#t(e){this.root.isMulti?this.root.updateValue(e,this.opts.index.current):this.root.updateValue(e)}onkeydown(e){if(C(this.#e))return;let t=this.opts.ref.current;if(!t)return;let n=this.root.getAllThumbs();if(!n.length)return;let r=n.indexOf(t);if(this.root.isMulti&&(this.root.currentThumbIdx=r),!Ka.includes(e.key))return;e.preventDefault();let i=this.root.opts.min.current,a=this.root.opts.max.current,o=this.root.opts.value.current,s=Array.isArray(o)?o[r]:o,c=this.root.opts.orientation.current,l=this.root.direction,u=this.root.normalizedSteps;switch(e.key){case Ut:this.#t(i);break;case`End`:this.#t(a);break;case Wt:if(c!==`horizontal`)break;if(e.metaKey){let e=l===`rl`?a:i;this.#t(e)}else{let e=Ra(s,u,l===`rl`?`next`:`prev`);this.#t(e)}break;case zt:if(c!==`horizontal`)break;if(e.metaKey){let e=l===`rl`?i:a;this.#t(e)}else{let e=Ra(s,u,l===`rl`?`prev`:`next`);this.#t(e)}break;case Rt:if(e.metaKey){let e=l===`tb`?i:a;this.#t(e)}else{let e=Ra(s,u,l===`tb`?`prev`:`next`);this.#t(e)}break;case Qt:if(e.metaKey){let e=l===`tb`?a:i;this.#t(e)}else{let e=Ra(s,u,l===`tb`?`next`:`prev`);this.#t(e)}}this.root.opts.onValueCommit.current(this.root.opts.value.current)}#n=T(()=>({...this.root.thumbsPropsArr[this.opts.index.current],id:this.opts.id.current,onkeydown:this.onkeydown,"data-active":this.root.isThumbActive(this.opts.index.current)?``:void 0,"data-disabled":De(this.opts.disabled.current||this.root.opts.disabled.current),tabindex:this.opts.disabled.current||this.root.opts.disabled.current?-1:0,...this.attachment}));get props(){return C(this.#n)}set props(e){P(this.#n,e)}},Ya=new Set([`$$slots`,`$$events`,`$$legacy`,`children`,`child`,`id`,`ref`,`value`,`type`,`onValueChange`,`onValueCommit`,`disabled`,`min`,`max`,`step`,`dir`,`autoSort`,`orientation`,`thumbPositioning`,`trackPadding`]),Xa=D(`<span><!></span>`);function Za(e,n){let r=l();V(n,!0);let i=J(n,`id`,19,()=>je(r)),a=J(n,`ref`,15,null),o=J(n,`value`,15),s=J(n,`onValueChange`,3,Yt),d=J(n,`onValueCommit`,3,Yt),f=J(n,`disabled`,3,!1),p=J(n,`step`,3,1),m=J(n,`dir`,3,`ltr`),g=J(n,`autoSort`,3,!0),_=J(n,`orientation`,3,`horizontal`),v=J(n,`thumbPositioning`,3,`contain`),y=W(n,Ya),S=T(()=>n.min===void 0?Array.isArray(p())?Math.min(...p()):0:n.min),w=T(()=>n.max===void 0?Array.isArray(p())?Math.max(...p()):100:n.max);function E(){if(o()===void 0)return n.type===`single`?C(S):[]}E(),Bt.pre(()=>o(),()=>{E()});let D=Ga.create({id:Me(()=>i()),ref:Me(()=>a(),e=>a(e)),value:Me(()=>o(),e=>{o(e),s()(e)}),onValueCommit:Me(()=>d()),disabled:Me(()=>f()),min:Me(()=>C(S)),max:Me(()=>C(w)),step:Me(()=>p()),dir:Me(()=>m()),autoSort:Me(()=>g()),orientation:Me(()=>_()),thumbPositioning:Me(()=>v()),type:Y(()=>n.type),trackPadding:Me(()=>n.trackPadding)}),k=T(()=>Te(y,D.props));var A=u(),j=z(A),M=e=>{var t=u(),r=z(t);{let e=T(()=>({props:C(k),...D.snippetProps}));x(r,()=>n.child,()=>C(e))}O(e,t)},N=e=>{var t=Xa();R(t,()=>({...C(k)}));var r=I(t);x(r,()=>n.children??h,()=>D.snippetProps),c(t),O(e,t)};t(j,e=>{n.child?e(M):e(N,-1)}),O(e,A),b()}var Qa=new Set([`$$slots`,`$$events`,`$$legacy`,`children`,`child`,`ref`,`id`]),$a=D(`<span><!></span>`);function eo(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`id`,19,()=>je(r)),o=W(n,Qa),s=qa.create({id:Me(()=>a()),ref:Me(()=>i(),e=>i(e))}),d=T(()=>Te(o,s.props));var f=u(),p=z(f),m=e=>{var t=u(),r=z(t);x(r,()=>n.child,()=>({props:C(d)})),O(e,t)},g=e=>{var t=$a();R(t,()=>({...C(d)}));var r=I(t);x(r,()=>n.children??h),c(t),O(e,t)};t(p,e=>{n.child?e(m):e(g,-1)}),O(e,f),b()}var to=new Set([`$$slots`,`$$events`,`$$legacy`,`children`,`child`,`ref`,`id`,`index`,`disabled`]),no=D(`<span><!></span>`);function ro(e,n){let r=l();V(n,!0);let i=J(n,`ref`,15,null),a=J(n,`id`,19,()=>je(r)),o=J(n,`disabled`,3,!1),s=W(n,to),d=Ja.create({id:Me(()=>a()),ref:Me(()=>i(),e=>i(e)),index:Me(()=>n.index),disabled:Me(()=>o())}),f=T(()=>Te(s,d.props));var p=u(),m=z(p),g=e=>{var t=u(),r=z(t);{let e=T(()=>({active:d.root.isThumbActive(d.opts.index.current),props:C(f)}));x(r,()=>n.child,()=>C(e))}O(e,t)},_=e=>{var t=no();R(t,()=>({...C(f)}));var r=I(t);{let e=T(()=>({active:d.root.isThumbActive(d.opts.index.current)}));x(r,()=>n.children??h,()=>C(e))}c(t),O(e,t)};t(m,e=>{n.child?e(g):e(_,-1)}),O(e,p),b()}var io=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`checked`,`indeterminate`,`class`,`children`,`closeOnSelect`,`switch`]),ao=D(`<span data-slot="dropdown-menu-checkbox-item-switch" aria-hidden="true"><span></span></span>`),oo=D(`<span class="right-2 pointer-events-none absolute flex items-center justify-center" data-slot="dropdown-menu-checkbox-item-indicator"><!></span>`),so=D(`<!> <!>`,1);function co(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=J(n,`checked`,15,!1),a=J(n,`indeterminate`,15,!1),o=J(n,`closeOnSelect`,3,!1),s=J(n,`switch`,3,!1),l=W(n,io);var d=u(),f=z(d);{let e=(e,r)=>{let i=()=>(r?.()).checked,a=()=>(r?.()).indeterminate;var o=so(),l=z(o);x(l,()=>n.children??h);var u=U(l,2),d=e=>{var t=ao(),n=K(t);G(()=>{fe(t,1,`not-pointer-coarse:[[data-slot=dropdown-menu-shortcut]+&]:ml-2 h-4.5 w-8 pointer-events-none relative ml-auto shrink-0 rounded-full transition-colors ${i()?`bg-primary`:`bg-input`}`),fe(n,1,`left-0.5 top-0.5 size-3.5 absolute rounded-full bg-background transition-transform dark:bg-foreground ${i()?`translate-x-3.5 dark:bg-primary-foreground`:``}`)}),O(e,t)},f=e=>{var n=oo(),r=I(n),o=e=>{kt(e,{})},s=e=>{ot(e,{})};t(r,e=>{a()?e(o):i()&&e(s,1)}),c(n),O(e,n)};t(u,e=>{s()?e(d):e(f,-1)}),O(e,o)},u=T(()=>Fe(s()?`pr-2 gap-2.5`:`pr-8`,`gap-1.5 py-1 pointer-coarse:py-2.5 pl-1.5 text-sm data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center rounded-inner outline-hidden select-none focus:bg-hover focus:text-foreground focus:**:text-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,n.class));E(f,()=>gi,(t,n)=>{n(t,q({get closeOnSelect(){return o()},"data-slot":`dropdown-menu-checkbox-item`,get class(){return C(u)}},()=>l,{get ref(){return r()},set ref(e){r(e)},get checked(){return i()},set checked(e){i(e)},get indeterminate(){return a()},set indeterminate(e){a(e)},children:e,$$slots:{default:!0}}))})}O(e,d),b()}var lo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`inset`,`children`]),uo=D(`<div><!></div>`);function fo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,lo);var i=uo();R(i,e=>({"data-slot":`dropdown-menu-label`,"data-inset":t.inset,class:e,...r}),[()=>Fe(`px-1.5 py-1 text-xs font-medium data-inset:pl-7 text-muted-foreground`,t.class)]);var a=I(i);x(a,()=>t.children??h),c(i),F(i,e=>n(e),()=>n()),O(e,i),b()}var po=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`value`]);function mo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=J(t,`value`,15),i=W(t,po);var a=u(),o=z(a);E(o,()=>pi,(e,t)=>{t(e,q({"data-slot":`dropdown-menu-radio-group`},()=>i,{get ref(){return n()},set ref(e){n(e)},get value(){return r()},set value(e){r(e)}}))}),O(e,a),b()}var ho=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`,`closeOnSelect`]),go=D(`<span class="right-2 pointer-events-none absolute flex items-center justify-center" data-slot="dropdown-menu-radio-item-indicator"><!></span> <!>`,1);function _o(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=J(n,`closeOnSelect`,3,!1),a=W(n,ho);var o=u(),s=z(o);{let e=(e,r)=>{let i=()=>(r?.()).checked;var a=go(),o=z(a),s=I(o),l=e=>{ot(e,{})};t(s,e=>{i()&&e(l)}),c(o);var u=U(o,2);x(u,()=>n.children??h,()=>({checked:i()})),O(e,a)},o=T(()=>Fe(`gap-1.5 py-1 pointer-coarse:py-2.5 pr-8 pl-1.5 text-sm data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center rounded-inner outline-hidden select-none focus:bg-hover focus:text-foreground focus:**:text-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0`,n.class));E(s,()=>ui,(t,n)=>{n(t,q({get closeOnSelect(){return i()},"data-slot":`dropdown-menu-radio-item`,get class(){return C(o)}},()=>a,{get ref(){return r()},set ref(e){r(e)},children:e,$$slots:{default:!0}}))})}O(e,o),b()}var vo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`]),yo=D(`<span><!></span>`);function bo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,vo);var i=yo();R(i,e=>({"data-slot":`dropdown-menu-shortcut`,class:e,...r}),[()=>Fe(`h-5 min-w-5 px-1 font-mono ml-auto inline-flex items-center justify-center rounded-sm border bg-muted text-2xs text-muted-foreground group-focus/dropdown-menu-item:text-foreground pointer-coarse:hidden`,t.class)]);var a=I(i);x(a,()=>t.children??h),c(i),F(i,e=>n(e),()=>n()),O(e,i),b()}var xo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`checked`,`indeterminate`,`class`]),So=D(`<div data-slot="checkbox-indicator" class="text-current transition-none"><!></div>`);function Co(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=J(n,`checked`,15,!1),a=J(n,`indeterminate`,15,!1),o=W(n,xo);var s=u(),l=z(s);{let e=(e,n)=>{let r=()=>(n?.()).checked,i=()=>(n?.()).indeterminate;var a=So(),o=I(a),s=e=>{ot(e,{class:`size-3.5`})},l=e=>{kt(e,{class:`size-3.5`})};t(o,e=>{r()?e(s):i()&&e(l,1)}),c(a),O(e,a)},s=T(()=>Fe(`peer size-4 shadow-xs flex shrink-0 items-center justify-center rounded-sm border border-input bg-field transition-shadow outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary`,n.class));E(l,()=>si,(t,n)=>{n(t,q({"data-slot":`checkbox`,get class(){return C(s)}},()=>o,{get ref(){return r()},set ref(e){r(e)},get checked(){return i()},set checked(e){i(e)},get indeterminate(){return a()},set indeterminate(e){a(e)},children:e,$$slots:{default:!0}}))})}O(e,s),b()}var wo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`value`,`orientation`,`class`,`thumbLabelledby`]),To=D(`<span data-slot="slider-track"><!></span> <!>`,1);function Eo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=J(t,`value`,15),i=J(t,`orientation`,3,`horizontal`),o=W(t,wo);var s=u(),l=z(s);{let e=(e,n)=>{let r=()=>(n?.()).thumbs;var o=To(),s=z(o),l=I(s);{let e=T(()=>Fe(`absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full`));E(l,()=>eo,(t,n)=>{n(t,{"data-slot":`slider-range`,get class(){return C(e)}})})}c(s);var d=U(s,2);a(d,16,r,e=>e,(e,n)=>{var r=u(),i=z(r);E(i,()=>ro,(e,r)=>{r(e,{"data-slot":`slider-thumb`,get index(){return n},get"aria-labelledby"(){return t.thumbLabelledby},class:`size-4 shadow-sm block shrink-0 rounded-full border border-primary bg-background ring-ring/50 transition hover:ring-4 focus-visible:ring-4 focus-visible:ring-ring focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50`})}),O(e,r)}),G(e=>{H(s,`data-orientation`,i()),fe(s,1,e)},[()=>me(Fe(`data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:w-1.5 relative grow overflow-hidden rounded-full bg-input data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full`))]),O(e,o)},s=T(()=>Fe(`data-[orientation=vertical]:min-h-44 relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col`,t.class));E(l,()=>Za,(t,a)=>{a(t,q({"data-slot":`slider`,get orientation(){return i()},get class(){return C(s)}},()=>o,{get ref(){return n()},set ref(e){n(e)},get value(){return r()},set value(e){r(e)},children:e,$$slots:{default:!0}}))})}O(e,s),b()}var Do=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`]),Oo=D(`<div><!></div>`);function ko(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,Do);var i=Oo();R(i,e=>({"data-slot":`empty-description`,class:e,...r}),[()=>Fe(`text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,t.class)]);var a=I(i);x(a,()=>t.children??h),c(i),F(i,e=>n(e),()=>n()),O(e,i),b()}var Ao=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`]),jo=D(`<div><!></div>`);function Mo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,Ao);var i=jo();R(i,e=>({"data-slot":`empty-header`,class:e,...r}),[()=>Fe(`gap-2 max-w-sm flex flex-col items-center`,t.class)]);var a=I(i);x(a,()=>t.children??h),c(i),F(i,e=>n(e),()=>n()),O(e,i),b()}var No=Le({base:`mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,variants:{variant:{default:`bg-transparent`,icon:`bg-muted text-foreground flex size-8 shrink-0 items-center justify-center rounded-lg [&_svg:not([class*='size-'])]:size-4`}},defaultVariants:{variant:`default`}}),Po=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`,`variant`]),Fo=D(`<div><!></div>`);function Io(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=J(t,`variant`,3,`default`),i=W(t,Po);var a=Fo();R(a,e=>({"data-slot":`empty-icon`,"data-variant":r(),class:e,...i}),[()=>Fe(No({variant:r()}),t.class)]);var o=I(a);x(o,()=>t.children??h),c(a),F(a,e=>n(e),()=>n()),O(e,a),b()}var Lo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`]),Ro=D(`<div><!></div>`);function zo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,Lo);var i=Ro();R(i,e=>({"data-slot":`empty-title`,class:e,...r}),[()=>Fe(`text-sm font-medium tracking-tight`,t.class)]);var a=I(i);x(a,()=>t.children??h),c(i),F(i,e=>n(e),()=>n()),O(e,i),b()}var Bo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`]),Vo=D(`<div><!></div>`);function Ho(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,Bo);var i=Vo();R(i,e=>({"data-slot":`empty`,class:e,...r}),[()=>Fe(`gap-4 p-6 min-w-0 flex w-full flex-1 flex-col items-center justify-center rounded-xl border-dashed text-center text-balance`,t.class)]);var a=I(i);x(a,()=>t.children??h),c(i),F(i,e=>n(e),()=>n()),O(e,i),b()}var Uo=new Set([`$$slots`,`$$events`,`$$legacy`,`class`,`role`,`name`,`color`,`stroke`,`className`,`aria-label`]);function Wo(e,t){V(t,!0);let n=J(t,`role`,3,`status`),r=J(t,`aria-label`,3,`Loading`),i=W(t,Uo);{let a=T(()=>Fe(`size-4 animate-spin`,t.class));_t(e,q({get role(){return n()}},()=>t.name==null?{}:{name:t.name},()=>t.color==null?{}:{color:t.color},()=>t.stroke==null?{}:{stroke:t.stroke},()=>t.className==null?{}:{className:t.className},{get"aria-label"(){return r()},get class(){return C(a)}},()=>i))}b()}var Go=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`orientation`,`children`]),Ko=D(`<!> <!>`,1);function qo(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=J(t,`orientation`,3,`vertical`),i=W(t,Go);var a=u(),o=z(a);{let e=T(()=>Fe(`flex touch-none p-px transition-colors select-none`,r()===`vertical`&&`w-2.5 h-full border-s border-s-transparent`,r()===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,t.class));E(o,()=>ba,(a,o)=>{o(a,q({"data-slot":`scroll-area-scrollbar`,get orientation(){return r()},get class(){return C(e)}},()=>i,{get ref(){return n()},set ref(e){n(e)},children:(e,n)=>{var r=Ko(),i=z(r);x(i,()=>t.children??h);var a=U(i,2);E(a,()=>Ta,(e,t)=>{t(e,{"data-slot":`scroll-area-thumb`,class:`relative flex-1 rounded-full bg-border`})}),O(e,r)},$$slots:{default:!0}}))})}O(e,a),b()}var Jo=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`viewportRef`,`class`,`orientation`,`scrollbarXClasses`,`scrollbarYClasses`,`children`]),Yo=D(`<!> <!> <!> <!>`,1);function Xo(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=J(n,`viewportRef`,15,null),a=J(n,`orientation`,3,`vertical`),o=J(n,`scrollbarXClasses`,3,``),s=J(n,`scrollbarYClasses`,3,``),c=W(n,Jo);var l=u(),d=z(l);{let e=T(()=>Fe(`relative`,n.class));E(d,()=>ea,(l,d)=>{d(l,q({"data-slot":`scroll-area`,get class(){return C(e)}},()=>c,{get ref(){return r()},set ref(e){r(e)},children:(e,r)=>{var c=Yo(),l=z(c);E(l,()=>ra,(e,t)=>{t(e,{"data-slot":`scroll-area-viewport`,class:`size-full rounded-inherit ring-ring/10 outline-ring transition focus-visible:ring-4 focus-visible:outline-1 dark:ring-ring/20`,get ref(){return i()},set ref(e){i(e)},children:(e,t)=>{var r=u(),i=z(r);x(i,()=>n.children??h),O(e,r)},$$slots:{default:!0}})});var d=U(l,2),f=e=>{qo(e,{orientation:`vertical`,get class(){return s()}})};t(d,e=>{(a()===`vertical`||a()===`both`)&&e(f)});var p=U(d,2),m=e=>{qo(e,{orientation:`horizontal`,get class(){return o()}})};t(p,e=>{(a()===`horizontal`||a()===`both`)&&e(m)});var g=U(p,2);E(g,()=>Aa,(e,t)=>{t(e,{})}),O(e,c)},$$slots:{default:!0}}))})}O(e,l),b()}function Zo(e){return typeof e==`function`}function Qo(e){return typeof e==`object`&&!!e}var $o=[`string`,`number`,`bigint`,`boolean`];function es(e){return e==null||$o.includes(typeof e)?!0:Array.isArray(e)?e.every(e=>es(e)):typeof e==`object`&&Object.getPrototypeOf(e)===Object.prototype}var ts=Symbol(`box`),ns=Symbol(`is-writable`);function rs(e){return Qo(e)&&ts in e}function is(e){return as.isBox(e)&&ns in e}function as(e){let t=Z(B(e));return{[ts]:!0,[ns]:!0,get current(){return C(t)},set current(e){P(t,e,!0)}}}function os(e,t){let n=T(e);return t?{[ts]:!0,[ns]:!0,get current(){return C(n)},set current(e){t(e)}}:{[ts]:!0,get current(){return e()}}}function ss(e){return as.isBox(e)?e:Zo(e)?as.with(e):as(e)}function cs(e){return Object.entries(e).reduce((e,[t,n])=>as.isBox(n)?(as.isWritableBox(n)?Object.defineProperty(e,t,{get(){return n.current},set(e){n.current=e}}):Object.defineProperty(e,t,{get(){return n.current}}),e):Object.assign(e,{[t]:n}),{})}function ls(e){return as.isWritableBox(e)?{[ts]:!0,get current(){return e.current}}:e}as.from=ss,as.with=os,as.flatten=cs,as.readonly=ls,as.isBox=rs,as.isWritableBox=is;function us(...e){return function(t){for(let n of e)if(n){if(t.defaultPrevented)return;typeof n==`function`?n.call(this,t):n.current?.call(this,t)}}}var ds=/\d/,fs=[`-`,`_`,`/`,`.`];function ps(e=``){if(!ds.test(e))return e!==e.toLowerCase()}function ms(e){let t=[],n=``,r,i;for(let a of e){let e=fs.includes(a);if(e===!0){t.push(n),n=``,r=void 0;continue}let o=ps(a);if(i===!1){if(r===!1&&o===!0){t.push(n),n=a,r=o;continue}if(r===!0&&o===!1&&n.length>1){let e=n.at(-1);t.push(n.slice(0,Math.max(0,n.length-1))),n=e+a,r=o;continue}}n+=a,r=o,i=e}return t.push(n),t}function hs(e){return e?ms(e).map(e=>_s(e)).join(``):``}function gs(e){return vs(hs(e||``))}function _s(e){return e?e[0].toUpperCase()+e.slice(1):``}function vs(e){return e?e[0].toLowerCase()+e.slice(1):``}function ys(e){if(!e)return{};let t={};function n(e,n){e.startsWith(`-moz-`)||e.startsWith(`-webkit-`)||e.startsWith(`-ms-`)||e.startsWith(`-o-`)?t[hs(e)]=n:e.startsWith(`--`)?t[e]=n:t[gs(e)]=n}return Ce(e,n),t}function bs(...e){return(...t)=>{for(let n of e)typeof n==`function`&&n(...t)}}function xs(e,t,n,r){let i=Array.isArray(t)?t:[t];return i.forEach(t=>e.addEventListener(t,n,r)),()=>{i.forEach(t=>e.removeEventListener(t,n,r))}}function Ss(e,t){let n=RegExp(e,`g`);return e=>{if(typeof e!=`string`)throw TypeError(`expected an argument of type string, but got ${typeof e}`);return e.match(n)?e.replace(n,t):e}}var Cs=Ss(/[A-Z]/,e=>`-${e.toLowerCase()}`);function ws(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`expected an argument of type object, but got ${typeof e}`);return Object.keys(e).map(t=>`${Cs(t)}: ${e[t]};`).join(`
|
|
3
3
|
`)}function Ts(e={}){return ws(e).replace(`
|
|
4
|
-
`,` `)}Ts({position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`,transform:`translateX(-100%)`});var Es=new Set(`onabort.onanimationcancel.onanimationend.onanimationiteration.onanimationstart.onauxclick.onbeforeinput.onbeforetoggle.onblur.oncancel.oncanplay.oncanplaythrough.onchange.onclick.onclose.oncompositionend.oncompositionstart.oncompositionupdate.oncontextlost.oncontextmenu.oncontextrestored.oncopy.oncuechange.oncut.ondblclick.ondrag.ondragend.ondragenter.ondragleave.ondragover.ondragstart.ondrop.ondurationchange.onemptied.onended.onerror.onfocus.onfocusin.onfocusout.onformdata.ongotpointercapture.oninput.oninvalid.onkeydown.onkeypress.onkeyup.onload.onloadeddata.onloadedmetadata.onloadstart.onlostpointercapture.onmousedown.onmouseenter.onmouseleave.onmousemove.onmouseout.onmouseover.onmouseup.onpaste.onpause.onplay.onplaying.onpointercancel.onpointerdown.onpointerenter.onpointerleave.onpointermove.onpointerout.onpointerover.onpointerup.onprogress.onratechange.onreset.onresize.onscroll.onscrollend.onsecuritypolicyviolation.onseeked.onseeking.onselect.onselectionchange.onselectstart.onslotchange.onstalled.onsubmit.onsuspend.ontimeupdate.ontoggle.ontouchcancel.ontouchend.ontouchmove.ontouchstart.ontransitioncancel.ontransitionend.ontransitionrun.ontransitionstart.onvolumechange.onwaiting.onwebkitanimationend.onwebkitanimationiteration.onwebkitanimationstart.onwebkittransitionend.onwheel`.split(`.`));function Ds(e){return Es.has(e)}function Os(...e){let t={...e[0]};for(let n=1;n<e.length;n++){let r=e[n];if(r){for(let e of Object.keys(r)){let n=t[e],i=r[e],a=typeof n==`function`,o=typeof i==`function`;if(a&&typeof o&&Ds(e))t[e]=us(n,i);else if(a&&o)t[e]=bs(n,i);else if(e===`class`){let r=es(n),a=es(i);r&&a?t[e]=
|
|
5
|
-
`,` `)),t.hidden!==!0&&(t.hidden=void 0,delete t.hidden),t.disabled!==!0&&(t.disabled=void 0,delete t.disabled),t}var ks=typeof window<`u`?window:void 0;typeof window<`u`&&window.document,typeof window<`u`&&window.navigator,typeof window<`u`&&window.location;function As(e){let t=e.activeElement;for(;t?.shadowRoot;){let e=t.shadowRoot.activeElement;if(e===t)break;t=e}return t}new class{#e;#t;constructor(e={}){let{window:t=ks,document:n=t?.document}=e;t!==void 0&&(this.#e=n,this.#t=r(e=>{let n=A(t,`focusin`,e),r=A(t,`focusout`,e);return()=>{n(),r()}}))}get current(){return this.#t?.(),this.#e?As(this.#e):null}};function js(e){R().then(e)}var Ms=9;function Ns(e){return Qo(e)&&e.nodeType===Ms}function Ps(e){return Qo(e)&&e.constructor?.name===`VisualViewport`}function Fs(e){return Ns(e)?e:Ps(e)?e.document:e?.ownerDocument??document}function Is(e){let t=e.activeElement;for(;t?.shadowRoot;){let e=t.shadowRoot.activeElement;if(e===t)break;t=e}return t}var Ls=class{element;#e=T(()=>this.element.current?this.element.current.getRootNode()??document:document);get root(){return C(this.#e)}set root(e){P(this.#e,e)}constructor(e){this.element=typeof e==`function`?as.with(e):e}getDocument=()=>Fs(this.root);getWindow=()=>this.getDocument().defaultView??window;getActiveElement=()=>Is(this.root);isActiveElement=e=>e===this.getActiveElement();getElementById(e){return this.root.getElementById(e)}querySelector=e=>this.root?this.root.querySelector(e):null;querySelectorAll=e=>this.root?this.root.querySelectorAll(e):[];setTimeout=(e,t)=>this.getWindow().setTimeout(e,t);clearTimeout=e=>this.getWindow().clearTimeout(e)};function Rs(e,t){return{[ie()]:n=>as.isBox(e)?(e.current=n,Y(()=>t?.(n)),()=>{`isConnected`in n&&n.isConnected||(e.current=null,t?.(null))}):(e(n),Y(()=>t?.(n)),()=>{`isConnected`in n&&n.isConnected||(e(null),t?.(null))})}}function zs({layout:e,panesArray:t,pivotIndices:n}){let r=0,i=100,a=0,o=0,s=n[0];for(let e=0;e<t.length;e++){let{maxSize:n=100,minSize:c=0}=t[e].constraints;e===s?(r=c,i=n):(a+=c,o+=n)}return{valueMax:Math.min(i,100-a),valueMin:Math.max(r,100-o),valueNow:e[s]}}function Bs(e,t=`Assertion failed!`){if(!e)throw console.error(t),Error(t)}function Vs(e,t,n=10){return Hs(e,t,n)===0}function Hs(e,t,n=10){let r=Ws(e,n),i=Ws(t,n);return Math.sign(r-i)}function Us(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ws(e,t){return Number.parseFloat(e.toFixed(t))}var Gs=typeof document<`u`;function Ks(e){return e instanceof HTMLElement}function qs(e){return e.type===`keydown`}function Js(e){return e.type.startsWith(`mouse`)}function Ys(e){return e.type.startsWith(`touch`)}function Xs({paneConstraints:e,paneIndex:t,initialSize:n}){let r=e[t];Bs(r!=null,`Pane constraints should not be null.`);let{collapsedSize:i=0,collapsible:a,maxSize:o=100,minSize:s=0}=r,c=n;return Hs(c,s)<0&&(c=Zs(c,a,i,s)),c=Math.min(o,c),Number.parseFloat(c.toFixed(10))}function Zs(e,t,n,r){return t&&Hs(e,(n+r)/2)<0?n:r}function Qs(){}function $s({groupId:e,layout:t,panesArray:n,domContext:r}){let i=ec(e,r);for(let e=0;e<n.length-1;e++){let{valueMax:r,valueMin:a,valueNow:o}=zs({layout:t,panesArray:n,pivotIndices:[e,e+1]}),s=i[e];if(Ks(s)){let t=n[e];s.setAttribute(`aria-controls`,t.opts.id.current),s.setAttribute(`aria-valuemax`,`${Math.round(r)}`),s.setAttribute(`aria-valuemin`,`${Math.round(a)}`),s.setAttribute(`aria-valuenow`,o==null?``:`${Math.round(o)}`)}}return()=>{for(let e of i)e.removeAttribute(`aria-controls`),e.removeAttribute(`aria-valuemax`),e.removeAttribute(`aria-valuemin`),e.removeAttribute(`aria-valuenow`)}}function ec(e,t){return Gs?Array.from(t.querySelectorAll(`[data-pane-resizer-id][data-pane-group-id="${e}"]`)):[]}function tc({groupId:e,id:t,domContext:n}){return Gs?ec(e,n).findIndex(e=>e.getAttribute(`data-pane-resizer-id`)===t)??null:null}function nc({groupId:e,dragHandleId:t,domContext:n}){let r=tc({groupId:e,id:t,domContext:n});return r==null?[-1,-1]:[r,r+1]}function rc(e,t,n){let r=e.map(e=>e.constraints),i=ic(e,t),a=r[i],o=i===e.length-1?[i-1,i]:[i,i+1],s=n[i];return{...a,paneSize:s,pivotIndices:o}}function ic(e,t){return e.findIndex(e=>e.opts.id.current===t.opts.id.current)}function ac(e,t,n){for(let r=0;r<t.length;r++){let i=t[r],a=e[r];Bs(a);let{collapsedSize:o=0,collapsible:s}=a.constraints,c=n[a.opts.id.current];if(c!=null&&i===c)continue;n[a.opts.id.current]=i;let{onCollapse:l,onExpand:u,onResize:d}=a.callbacks;d?.(i,c),s&&(l||u)&&(u&&(c==null||c===o)&&i!==o&&u(),l&&(c==null||c!==o)&&i===o&&l())}}function oc({panesArray:e}){let t=Array(e.length),n=e.map(e=>e.constraints),r=0,i=100;for(let a=0;a<e.length;a++){let e=n[a];Bs(e);let{defaultSize:o}=e;o!=null&&(r++,t[a]=o,i-=o)}for(let a=0;a<e.length;a++){let o=n[a];Bs(o);let{defaultSize:s}=o;if(s!=null)continue;let c=e.length-r,l=i/c;r++,t[a]=l,i-=l}return t}function sc({layout:e,paneConstraints:t}){let n=[...e],r=n.reduce((e,t)=>e+t,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} pane layout: ${n.map(e=>`${e}%`).join(`, `)}`);if(!Vs(r,100))for(let e=0;e<t.length;e++){let t=n[e];Bs(t!=null);let i=100/r*t;n[e]=i}let i=0;for(let e=0;e<t.length;e++){let r=n[e];Bs(r!=null);let a=Xs({paneConstraints:t,paneIndex:e,initialSize:r});r!==a&&(i+=r-a,n[e]=a)}if(!Vs(i,0))for(let e=0;e<t.length;e++){let r=n[e];Bs(r!=null);let a=r+i,o=Xs({paneConstraints:t,paneIndex:e,initialSize:a});if(r!==o&&(i-=o-r,n[e]=o,Vs(i,0)))break}return n}function cc(e,t){return Gs&&t.querySelector(`[data-pane-group][data-pane-group-id="${e}"]`)||null}function lc(e,t){return Gs&&t.querySelector(`[data-pane-resizer-id="${e}"]`)||null}function uc({event:e,dragHandleId:t,dir:n,initialDragState:r,domContext:i}){let a=n===`horizontal`,o=lc(t,i);Bs(o);let s=o.getAttribute(`data-pane-group-id`);Bs(s);let{initialCursorPosition:c}=r,l=fc(n,e),u=cc(s,i);Bs(u);let d=u.getBoundingClientRect(),f=a?d.width:d.height;return(l-c)/f*100}function dc({event:e,dragHandleId:t,dir:n,initialDragState:r,keyboardResizeBy:i,domContext:a}){if(qs(e)){let t=n===`horizontal`,r=0;r=e.shiftKey?100:i??10;let a=0;switch(e.key){case`ArrowDown`:a=t?0:r;break;case`ArrowLeft`:a=t?-r:0;break;case`ArrowRight`:a=t?r:0;break;case`ArrowUp`:a=t?0:-r;break;case`End`:a=100;break;case`Home`:a=-100}return a}return r==null?0:uc({event:e,dragHandleId:t,dir:n,initialDragState:r,domContext:a})}function fc(e,t){let n=e===`horizontal`;if(Js(t))return n?t.clientX:t.clientY;if(Ys(t)){let e=t.touches[0];return Bs(e),n?e.screenX:e.screenY}throw Error(`Unsupported event type "${t.type}"`)}function pc({groupId:e,handleId:t,panesArray:n,domContext:r}){let i=lc(t,r),a=ec(e,r),o=i?a.indexOf(i):-1;return[n[o]?.opts.id.current??null,n[o+1]?.opts.id.current??null]}function mc({delta:e,layout:t,paneConstraints:n,pivotIndices:r,trigger:i}){if(Vs(e,0))return t;let a=[...t],[o,s]=r,c=0;if(i===`keyboard`){{let r=e<0?s:o,i=n[r];if(Bs(i),i.collapsible){let i=t[r];Bs(i!=null);let a=n[r];Bs(a);let{collapsedSize:o=0,minSize:s=0}=a;if(Vs(i,o)){let t=s-i;Hs(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let r=e<0?o:s,i=n[r];Bs(i);let{collapsible:a}=i;if(a){let i=t[r];Bs(i!=null);let a=n[r];Bs(a);let{collapsedSize:o=0,minSize:s=0}=a;if(Vs(i,s)){let t=i-o;Hs(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}}{let r=e<0?1:-1,i=e<0?s:o,a=0;for(;;){let e=t[i];Bs(e!=null);let o=Xs({paneConstraints:n,paneIndex:i,initialSize:100})-e;if(a+=o,i+=r,i<0||i>=n.length)break}let c=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-c:c}{let r=e<0?o:s;for(;r>=0&&r<n.length;){let i=Math.abs(e)-Math.abs(c),o=t[r];Bs(o!=null);let s=o-i,l=Xs({paneConstraints:n,paneIndex:r,initialSize:s});if(!Vs(o,l)&&(c+=o-l,a[r]=l,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?r--:r++}}if(Vs(c,0))return t;{let r=e<0?s:o,i=t[r];Bs(i!=null);let l=i+c,u=Xs({paneConstraints:n,paneIndex:r,initialSize:l});if(a[r]=u,!Vs(u,l)){let t=l-u,r=e<0?s:o;for(;r>=0&&r<n.length;){let i=a[r];Bs(i!=null);let o=i+t,s=Xs({paneConstraints:n,paneIndex:r,initialSize:o});if(Vs(i,s)||(t-=s-i,a[r]=s),Vs(t,0))break;e>0?r--:r++}}}return Vs(a.reduce((e,t)=>t+e,0),100)?a:t}var hc=null,gc=null;function _c(e){switch(e){case`horizontal`:return`ew-resize`;case`horizontal-max`:return`w-resize`;case`horizontal-min`:return`e-resize`;case`vertical`:return`ns-resize`;case`vertical-max`:return`n-resize`;case`vertical-min`:return`s-resize`}}function vc(){gc!==null&&(document.head.removeChild(gc),hc=null,gc=null)}function yc(e,t){if(hc===e)return;hc=e;let n=_c(e);gc===null&&(gc=t.createElement(`style`),t.head.appendChild(gc)),gc.innerHTML=`*{cursor: ${n}!important;}`}function bc({defaultSize:e,dragState:t,layout:n,panesArray:r,paneIndex:i,precision:a=3}){let o=n[i],s;return s=o==null?e??`1`:r.length===1?`1`:o.toPrecision(a),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:`hidden`,pointerEvents:t===null?void 0:`none`}}function xc(e){try{if(typeof localStorage>`u`)throw TypeError(`localStorage is not supported in this environment`);e.getItem=e=>localStorage.getItem(e),e.setItem=(e,t)=>localStorage.setItem(e,t)}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Sc(e){return`paneforge:${e}`}function Cc(e){return e.map(e=>e.opts.order.current?`${e.opts.order.current}:${JSON.stringify(e.constraints)}`:JSON.stringify(e.constraints)).sort().join(`,`)}function wc(e,t){try{let n=Sc(e),r=t.getItem(n),i=JSON.parse(r||``);if(typeof i==`object`&&i)return i}catch{}return null}function Tc(e,t,n){return(wc(e,n)||{})[Cc(t)]||null}function Ec(e,t,n,r,i){let a=Sc(e),o=Cc(t),s=wc(e,i)||{};s[o]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(a,JSON.stringify(s))}catch(e){console.error(e)}}var Dc={};function Oc(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function kc({autoSaveId:e,layout:t,storage:n,panesArray:r,paneSizeBeforeCollapse:i}){if(t.length===0||t.length!==r.length)return;let a=Dc[e];a??(a=Oc(Ec,100),Dc[e]=a);let o=[...r],s=new Map(i);a(e,o,s,t,n)}var Ac={getItem:e=>(xc(Ac),Ac.getItem(e)),setItem:(e,t)=>{xc(Ac),Ac.setItem(e,t)}},jc=new _e(`PaneGroup`),Mc=class e{static create(t){return jc.set(new e(t))}opts;attachment;domContext;#e=Z(null);get dragState(){return C(this.#e)}set dragState(e){P(this.#e,e)}#t=Z([]);get layout(){return C(this.#t)}set layout(e){P(this.#t,e)}#n=Z([]);get panesArray(){return C(this.#n)}set panesArray(e){P(this.#n,e)}#r=Z(!1);get panesArrayChanged(){return C(this.#r)}set panesArrayChanged(e){P(this.#r,e,!0)}#i=Z(re({}));get paneIdToLastNotifiedSizeMap(){return C(this.#i)}set paneIdToLastNotifiedSizeMap(e){P(this.#i,e,!0)}paneSizeBeforeCollapseMap=new Map;prevDelta=0;constructor(e){this.opts=e,this.attachment=Rs(this.opts.ref),this.domContext=new Ls(this.opts.ref),he([()=>this.opts.id.current,()=>this.layout,()=>this.panesArray],()=>$s({groupId:this.opts.id.current,layout:this.layout,panesArray:this.panesArray,domContext:this.domContext})),le(()=>Y(()=>this.#a())),he([()=>this.opts.autoSaveId.current,()=>this.layout,()=>this.opts.storage.current],()=>{this.opts.autoSaveId.current&&kc({autoSaveId:this.opts.autoSaveId.current,layout:this.layout,storage:this.opts.storage.current,panesArray:this.panesArray,paneSizeBeforeCollapse:this.paneSizeBeforeCollapseMap})}),he(()=>this.panesArrayChanged,()=>{if(!this.panesArrayChanged)return;this.panesArrayChanged=!1;let e=this.layout,t=null;if(this.opts.autoSaveId.current){let e=Tc(this.opts.autoSaveId.current,this.panesArray,this.opts.storage.current);e&&(this.paneSizeBeforeCollapseMap=new Map(Object.entries(e.expandToSizes)),t=e.layout)}t??=oc({panesArray:this.panesArray});let n=sc({layout:t,paneConstraints:this.panesArray.map(e=>e.constraints)});Us(e,n)||(this.layout=n,this.opts.onLayout.current?.(n),ac(this.panesArray,n,this.paneIdToLastNotifiedSizeMap))})}setLayout=e=>{this.layout=e};registerResizeHandle=e=>t=>{t.preventDefault();let n=this.opts.direction.current,r=this.dragState,i=this.opts.id.current,a=this.opts.keyboardResizeBy.current,o=this.layout,s=this.panesArray,{initialLayout:c}=r??{},l=this.domContext.getDocument(),u=nc({groupId:i,dragHandleId:e,domContext:this.domContext}),d=dc({event:t,dragHandleId:e,dir:n,initialDragState:r,keyboardResizeBy:a,domContext:this.domContext});if(d===0)return;let f=n===`horizontal`;l.dir===`rtl`&&f&&(d=-d);let p=s.map(e=>e.constraints),m=mc({delta:d,layout:c??o,paneConstraints:p,pivotIndices:u,trigger:qs(t)?`keyboard`:`mouse-or-touch`}),h=!Us(o,m);(Js(t)||Ys(t))&&this.prevDelta!==d&&(this.prevDelta=d,yc(h?f?`horizontal`:`vertical`:f?d<0?`horizontal-min`:`horizontal-max`:d<0?`vertical-min`:`vertical-max`,l)),h&&(this.setLayout(m),this.opts.onLayout.current?.(m),ac(s,m,this.paneIdToLastNotifiedSizeMap))};resizePane=(e,t)=>{let n=this.layout,r=this.panesArray,i=r.map(e=>e.constraints),{paneSize:a,pivotIndices:o}=rc(r,e,n);Bs(a!=null);let s=mc({delta:ic(r,e)===r.length-1?a-t:t-a,layout:n,paneConstraints:i,pivotIndices:o,trigger:`imperative-api`});Us(n,s)||(this.setLayout(s),this.opts.onLayout.current?.(s),ac(r,s,this.paneIdToLastNotifiedSizeMap))};startDragging=(e,t)=>{let n=this.opts.direction.current,r=this.layout,i=lc(e,this.domContext);Bs(i);let a=fc(n,t);this.dragState={dragHandleId:e,dragHandleRect:i.getBoundingClientRect(),initialCursorPosition:a,initialLayout:r}};stopDragging=()=>{vc(),this.dragState=null};isPaneCollapsed=e=>{let t=this.panesArray,n=this.layout,{collapsedSize:r=0,collapsible:i,paneSize:a}=rc(t,e,n);return typeof a!=`number`||typeof r!=`number`?!1:i===!0&&Vs(a,r)};expandPane=e=>{let t=this.layout,n=this.panesArray;if(!e.constraints.collapsible)return;let r=n.map(e=>e.constraints),{collapsedSize:i=0,paneSize:a,minSize:o=0,pivotIndices:s}=rc(n,e,t);if(a!==i)return;let c=this.paneSizeBeforeCollapseMap.get(e.opts.id.current),l=c!=null&&c>=o?c:o,u=mc({delta:ic(n,e)===n.length-1?a-l:l-a,layout:t,paneConstraints:r,pivotIndices:s,trigger:`imperative-api`});Us(t,u)||(this.setLayout(u),this.opts.onLayout.current?.(u),ac(n,u,this.paneIdToLastNotifiedSizeMap))};collapsePane=e=>{let t=this.layout,n=this.panesArray;if(!e.constraints.collapsible)return;let r=n.map(e=>e.constraints),{collapsedSize:i=0,paneSize:a,pivotIndices:o}=rc(n,e,t);if(Bs(a!=null),a===i)return;this.paneSizeBeforeCollapseMap.set(e.opts.id.current,a);let s=mc({delta:ic(n,e)===n.length-1?a-i:i-a,layout:t,paneConstraints:r,pivotIndices:o,trigger:`imperative-api`});Us(t,s)||(this.layout=s,this.opts.onLayout.current?.(s),ac(n,s,this.paneIdToLastNotifiedSizeMap))};getPaneSize=e=>rc(this.panesArray,e,this.layout).paneSize;getPaneStyle=(e,t)=>{let n=this.panesArray,r=this.layout,i=this.dragState;return bc({defaultSize:t,dragState:i,layout:r,panesArray:n,paneIndex:ic(n,e)})};isPaneExpanded=e=>{let{collapsedSize:t=0,collapsible:n,paneSize:r}=rc(this.panesArray,e,this.layout);return!n||r>t};registerPane=e=>{let t=[...this.panesArray,e];return t.sort((e,t)=>{let n=e.opts.order.current,r=t.opts.order.current;return n==null&&r==null?0:n==null?-1:r==null?1:n-r}),this.panesArray=t,this.panesArrayChanged=!0,()=>{let t=[...this.panesArray],n=ic(this.panesArray,e);n<0||(t.splice(n,1),this.panesArray=t,delete this.paneIdToLastNotifiedSizeMap[e.opts.id.current],this.panesArrayChanged=!0)}};#a=()=>{let e=this.opts.id.current,t=ec(e,this.domContext),n=this.panesArray,r=t.map(t=>{let r=t.getAttribute(`data-pane-resizer-id`);if(!r)return Qs;let[i,a]=pc({groupId:e,handleId:r,panesArray:n,domContext:this.domContext});if(i==null||a==null)return Qs;let o=xs(t,`keydown`,t=>{if(t.defaultPrevented||t.key!==`Enter`)return;t.preventDefault();let n=this.panesArray,a=n.findIndex(e=>e.opts.id.current===i);if(a<0)return;let o=n[a];Bs(o);let s=this.layout,c=s[a],{collapsedSize:l=0,collapsible:u,minSize:d=0}=o.constraints;if(!(c!=null&&u))return;let f=mc({delta:Vs(c,l)?d-c:l-c,layout:s,paneConstraints:n.map(e=>e.constraints),pivotIndices:nc({groupId:e,dragHandleId:r,domContext:this.domContext}),trigger:`keyboard`});s!==f&&(this.layout=f)});return()=>{o()}});return()=>{for(let e of r)e()}};#o=T(()=>({id:this.opts.id.current,"data-pane-group":``,"data-direction":this.opts.direction.current,"data-pane-group-id":this.opts.id.current,style:{display:`flex`,flexDirection:this.opts.direction.current===`horizontal`?`row`:`column`,height:`100%`,overflow:`hidden`,width:`100%`},...this.attachment}));get props(){return C(this.#o)}set props(e){P(this.#o,e)}},Nc=[`ArrowDown`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`End`,`Home`],Pc=class e{static create(t){return new e(t,jc.get())}opts;#e;attachment;domContext;#t=T(()=>this.#e.dragState?.dragHandleId===this.opts.id.current);#n=Z(!1);resizeHandler=null;constructor(e,t){this.opts=e,this.#e=t,this.attachment=Rs(this.opts.ref),this.domContext=new Ls(this.opts.ref),le(()=>{this.resizeHandler=this.opts.disabled.current?null:this.#e.registerResizeHandle(this.opts.id.current)}),le(()=>{let e=this.opts.ref.current;if(!e)return;let t=this.opts.disabled.current,n=this.resizeHandler,r=C(this.#t);if(t||n===null||!r)return;let i=e=>{n(e)},a=e=>{n(e)},o=()=>{e.blur(),this.#e.stopDragging(),this.opts.onDraggingChange.current(!1)},s=this.domContext.getDocument().body,c=this.domContext.getWindow();return bs(A(s,`contextmenu`,o),A(s,`mousemove`,i),A(s,`touchmove`,i,{passive:!1}),A(s,`mouseleave`,a),A(c,`mouseup`,o),A(c,`touchend`,o))})}#r=e=>{e.preventDefault(),!this.opts.disabled.current&&(this.#e.startDragging(this.opts.id.current,e),this.opts.onDraggingChange.current(!0))};#i=()=>{let e=this.opts.ref.current;e&&(e.blur(),this.#e.stopDragging(),this.opts.onDraggingChange.current(!1))};#a=e=>{if(this.opts.disabled.current||!this.resizeHandler||e.defaultPrevented)return;if(Nc.includes(e.key)){e.preventDefault(),this.resizeHandler(e);return}if(e.key!==`F6`)return;e.preventDefault();let t=ec(this.#e.opts.id.current,this.domContext),n=tc({groupId:this.#e.opts.id.current,id:this.opts.id.current,domContext:this.domContext});if(n===null)return;let r=0;r=e.shiftKey?n>0?n-1:t.length-1:n+1<t.length?n+1:0,t[r].focus()};#o=()=>{P(this.#n,!1)};#s=()=>{P(this.#n,!0)};#c=e=>{this.#r(e)};#l=()=>{this.#i()};#u=()=>{this.#i()};#d=()=>{this.#i()};#f=e=>{this.#r(e)};#p=T(()=>({id:this.opts.id.current,role:`separator`,"data-direction":this.#e.opts.direction.current,"data-pane-group-id":this.#e.opts.id.current,"data-active":C(this.#t)?`pointer`:C(this.#n)?`keyboard`:void 0,"data-enabled":!this.opts.disabled.current,"data-pane-resizer-id":this.opts.id.current,"data-pane-resizer":``,tabIndex:this.opts.tabIndex.current,style:{cursor:_c(this.#e.opts.direction.current),touchAction:`none`,userSelect:`none`,"-webkit-user-select":`none`,"-webkit-touch-callout":`none`},onkeydown:this.#a,onblur:this.#o,onfocus:this.#s,onmousedown:this.#c,onmouseup:this.#l,ontouchcancel:this.#u,ontouchend:this.#d,ontouchstart:this.#f,...this.attachment}));get props(){return C(this.#p)}set props(e){P(this.#p,e)}},Fc=class e{static create(t){return new e(t,jc.get())}opts;group;attachment;domContext;#e=Z(``);#t=T(()=>({onCollapse:this.opts.onCollapse.current,onExpand:this.opts.onExpand.current,onResize:this.opts.onResize.current}));get callbacks(){return C(this.#t)}set callbacks(e){P(this.#t,e)}#n=T(()=>({collapsedSize:this.opts.collapsedSize.current,collapsible:this.opts.collapsible.current,defaultSize:this.opts.defaultSize.current,maxSize:this.opts.maxSize.current,minSize:this.opts.minSize.current}));get constraints(){return C(this.#n)}set constraints(e){P(this.#n,e)}#r=e=>{P(this.#e,e,!0),js(()=>{if(this.opts.ref.current){let e=this.opts.ref.current;if(getComputedStyle(e).transitionDuration===`0s`){P(this.#e,``);return}let t=n=>{n.propertyName===`flex-grow`&&(P(this.#e,``),e.removeEventListener(`transitionend`,t))};e.addEventListener(`transitionend`,t)}else P(this.#e,``)})};pane={collapse:()=>{this.#r(`collapsing`),this.group.collapsePane(this)},expand:()=>{this.#r(`expanding`),this.group.expandPane(this)},getSize:()=>this.group.getPaneSize(this),isCollapsed:()=>this.group.isPaneCollapsed(this),isExpanded:()=>this.group.isPaneExpanded(this),resize:e=>this.group.resizePane(this,e),getId:()=>this.opts.id.current};constructor(e,t){this.opts=e,this.group=t,this.attachment=Rs(this.opts.ref),this.domContext=new Ls(this.opts.ref),_(()=>this.group.registerPane(this)),he(()=>v(this.constraints),()=>{this.group.panesArrayChanged=!0})}#i=T(()=>this.group.isPaneCollapsed(this));#a=T(()=>C(this.#e)===``?C(this.#i)?`collapsed`:`expanded`:C(this.#e));#o=T(()=>({id:this.opts.id.current,style:this.group.getPaneStyle(this,this.opts.defaultSize.current),"data-pane":``,"data-pane-id":this.opts.id.current,"data-pane-group-id":this.group.opts.id.current,"data-collapsed":C(this.#i)?``:void 0,"data-expanded":C(this.#i)?void 0:``,"data-pane-state":C(this.#a),...this.attachment}));get props(){return C(this.#o)}set props(e){P(this.#o,e)}},Ic=new Set([`$$slots`,`$$events`,`$$legacy`,`autoSaveId`,`direction`,`id`,`keyboardResizeBy`,`onLayoutChange`,`storage`,`ref`,`child`,`children`]),Lc=D(`<div><!></div>`);function Rc(e,n){let r=l();V(n,!0);let i=J(n,`autoSaveId`,3,null),a=J(n,`id`,3,r),o=J(n,`keyboardResizeBy`,3,null),s=J(n,`onLayoutChange`,3,Qs),d=J(n,`storage`,3,Ac),f=J(n,`ref`,15,null),p=W(n,Ic),m=Mc.create({id:as.with(()=>a()??r),ref:as.with(()=>f(),e=>f(e)),autoSaveId:as.with(()=>i()),direction:as.with(()=>n.direction),keyboardResizeBy:as.with(()=>o()),onLayout:as.with(()=>s()),storage:as.with(()=>d())}),g=()=>m.layout,_=m.setLayout,v=()=>m.opts.id.current,y=T(()=>Os(p,m.props));var S={getLayout:g,setLayout:_,getId:v},w=u(),E=B(w),D=e=>{var t=u(),r=B(t);x(r,()=>n.child,()=>({props:C(y)})),O(e,t)},k=e=>{var t=Lc();z(t,()=>({...C(y)}));var r=L(t);x(r,()=>n.children??h),c(t),O(e,t)};return t(E,e=>{n.child?e(D):e(k,-1)}),O(e,w),b(S)}var zc=new Set([`$$slots`,`$$events`,`$$legacy`,`id`,`ref`,`collapsedSize`,`collapsible`,`defaultSize`,`maxSize`,`minSize`,`onCollapse`,`onExpand`,`onResize`,`order`,`child`,`children`]),Bc=D(`<div><!></div>`);function Vc(e,n){let r=l();V(n,!0);let i=J(n,`id`,3,r),a=J(n,`ref`,15,null),o=J(n,`onCollapse`,3,Qs),s=J(n,`onExpand`,3,Qs),d=J(n,`onResize`,3,Qs),f=W(n,zc),p=Fc.create({id:as.with(()=>i()),ref:as.with(()=>a(),e=>a(e)),collapsedSize:as.with(()=>n.collapsedSize),collapsible:as.with(()=>n.collapsible),defaultSize:as.with(()=>n.defaultSize),maxSize:as.with(()=>n.maxSize),minSize:as.with(()=>n.minSize),onCollapse:as.with(()=>o()),onExpand:as.with(()=>s()),onResize:as.with(()=>d()),order:as.with(()=>n.order)}),m=p.pane.collapse,g=p.pane.expand,_=p.pane.getSize,v=p.pane.isCollapsed,y=p.pane.isExpanded,S=p.pane.resize,w=p.pane.getId,E=T(()=>Os(f,p.props));var D={collapse:m,expand:g,getSize:_,isCollapsed:v,isExpanded:y,resize:S,getId:w},k=u(),A=B(k),j=e=>{var t=u(),r=B(t);x(r,()=>n.child,()=>({props:C(E)})),O(e,t)},M=e=>{var t=Bc();z(t,()=>({...C(E)}));var r=L(t);x(r,()=>n.children??h),c(t),O(e,t)};return t(A,e=>{n.child?e(j):e(M,-1)}),O(e,k),b(D)}var Hc=new Set([`$$slots`,`$$events`,`$$legacy`,`id`,`ref`,`disabled`,`onDraggingChange`,`tabindex`,`child`,`children`]),Uc=D(`<div><!></div>`);function Wc(e,n){let r=l();V(n,!0);let i=J(n,`id`,3,r),a=J(n,`ref`,15,null),o=J(n,`disabled`,3,!1),s=J(n,`onDraggingChange`,3,Qs),d=J(n,`tabindex`,3,0),f=W(n,Hc),p=Pc.create({id:as.with(()=>i()),ref:as.with(()=>a(),e=>a(e)),disabled:as.with(()=>o()),onDraggingChange:as.with(()=>s()),tabIndex:as.with(()=>d())}),m=T(()=>Os(f,p.props));var g=u(),_=B(g),v=e=>{var t=u(),r=B(t);x(r,()=>n.child,()=>({props:C(m)})),O(e,t)},y=e=>{var t=Uc();z(t,()=>({...C(m)}));var r=L(t);x(r,()=>n.children??h),c(t),O(e,t)};t(_,e=>{n.child?e(v):e(y,-1)}),O(e,g),b()}var Gc=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`withHandle`,`line`]),Kc=D(`<div class="h-8 w-0.75 group-hover/handle:h-12 z-10 flex shrink-0 rounded-full bg-border-strong transition duration-150 group-hover/handle:bg-input group-active/handle:bg-muted-foreground"></div>`);function qc(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=J(n,`withHandle`,3,!1),a=J(n,`line`,3,!0),o=W(n,Gc);var s=u(),c=B(s);{let e=T(()=>Fe(`group/handle after:inset-y-0 after:w-1 data-[direction=vertical]:after:left-0 data-[direction=vertical]:after:h-1 data-[direction=vertical]:after:translate-x-0 relative flex w-px items-center justify-center after:absolute after:left-1/2 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-hidden data-[direction=vertical]:h-px data-[direction=vertical]:w-full data-[direction=vertical]:after:w-full data-[direction=vertical]:after:-translate-y-1/2 [&[data-direction=vertical]>div]:rotate-90`,a()?`bg-border`:`w-3 data-[direction=vertical]:h-3 bg-transparent`,n.class));E(c,()=>Wc,(n,a)=>{a(n,q({"data-slot":`resizable-handle`,get class(){return C(e)}},()=>o,{get ref(){return r()},set ref(e){r(e)},children:(e,n)=>{var r=u(),a=B(r),o=e=>{var t=Kc();O(e,t)};t(a,e=>{i()&&e(o)}),O(e,r)},$$slots:{default:!0}}))})}O(e,s),b()}var Jc=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`this`,`class`]);function Yc(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=J(t,`this`,15),i=W(t,Jc);var a=u(),o=B(a);{let e=T(()=>Fe(`flex h-full w-full data-[direction=vertical]:flex-col`,t.class));E(o,()=>Rc,(t,a)=>{F(a(t,q({"data-slot":`resizable-pane-group`,get class(){return C(e)}},()=>i,{get ref(){return n()},set ref(e){n(e)}})),e=>r(e),()=>r())})}O(e,a),b()}var Xc=D(`<!> <!> <!>`,1);function Zc(e,n){V(n,!0);let r=J(n,`message`,3,``),i=J(n,`size`,3,`medium`),a=J(n,`class`,3,``),o={small:`p-4`,medium:`p-8`,large:`p-12`};var s=u(),c=B(s);{let e=T(()=>Fe(o[i()],a()));E(c,()=>Ho,(i,a)=>{a(i,{get class(){return C(e)},children:(e,i)=>{var a=u(),o=B(a);E(o,()=>Mo,(e,i)=>{i(e,{children:(e,i)=>{var a=Xc(),o=B(a);E(o,()=>Io,(e,r)=>{r(e,{variant:`icon`,children:(e,r)=>{var i=u(),a=B(i),o=e=>{Wo(e,{})},s=e=>{ar(e,{})},c=e=>{Ue(e,{get severity(){return n.type}})};t(a,e=>{n.type===`loading`?e(o):n.type===`empty`?e(s,1):e(c,-1)}),O(e,i)},$$slots:{default:!0}})});var s=U(o,2),c=e=>{var t=u(),r=B(t);E(r,()=>zo,(e,t)=>{t(e,{children:(e,t)=>{S();var r=p();G(()=>m(r,n.title)),O(e,r)},$$slots:{default:!0}})}),O(e,t)};t(s,e=>{n.title&&e(c)});var l=U(s,2),d=e=>{var t=u(),n=B(t);E(n,()=>ko,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,r())),O(e,n)},$$slots:{default:!0}})}),O(e,t)};t(l,e=>{r()&&e(d)}),O(e,a)},$$slots:{default:!0}})}),O(e,a)},$$slots:{default:!0}})})}O(e,s),b()}var Qc=D(`<!> <kbd class="px-1 rounded-sm border border-current/30 font-sans text-2xs opacity-70">Esc</kbd>`,1),$c=D(`<!> `,1),el=D(`<span class="size-1.5 shrink-0 rounded-full bg-success" aria-hidden="true"></span> `,1),tl=D(`<div class="bottom-0 mt-3 pb-3 pt-2 backdrop-blur-sm px-2 sticky border-t border-border"><span class="sr-only" role="status" aria-live="polite"> </span> <div class="gap-2 flex"><!> <!></div></div>`);function nl(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),a=J(n,`hasNeverSolved`,3,!1),o=Z(``),s=!1;le(()=>{let e=n.isSolving;Y(()=>{e?P(o,C(i).solvingEllipsis,!0):s&&P(o,n.hasPendingChanges?``:C(i).upToDate,!0),s=e})});var l=tl(),d=L(l),f=K(d,!0),p=U(d,2),g=L(p);{let e=T(()=>n.hasPendingChanges?`default`:`ghost`),r=T(()=>!n.hasPendingChanges&&!n.isSolving),o=T(()=>n.hasPendingChanges&&!n.isSolving?`shadow-md`:``),s=T(()=>!n.hasPendingChanges&&!n.isSolving?`text-muted-foreground`:``);tt(g,{get variant(){return C(e)},size:`lg`,onclick:()=>!n.isSolving&&n.oncalculate(),get disabled(){return C(r)},get"aria-busy"(){return n.isSolving},get class(){return`gap-2 font-medium min-w-0 flex-1 transition-all duration-200
|
|
4
|
+
`,` `)}Ts({position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`,transform:`translateX(-100%)`});var Es=new Set(`onabort.onanimationcancel.onanimationend.onanimationiteration.onanimationstart.onauxclick.onbeforeinput.onbeforetoggle.onblur.oncancel.oncanplay.oncanplaythrough.onchange.onclick.onclose.oncompositionend.oncompositionstart.oncompositionupdate.oncontextlost.oncontextmenu.oncontextrestored.oncopy.oncuechange.oncut.ondblclick.ondrag.ondragend.ondragenter.ondragleave.ondragover.ondragstart.ondrop.ondurationchange.onemptied.onended.onerror.onfocus.onfocusin.onfocusout.onformdata.ongotpointercapture.oninput.oninvalid.onkeydown.onkeypress.onkeyup.onload.onloadeddata.onloadedmetadata.onloadstart.onlostpointercapture.onmousedown.onmouseenter.onmouseleave.onmousemove.onmouseout.onmouseover.onmouseup.onpaste.onpause.onplay.onplaying.onpointercancel.onpointerdown.onpointerenter.onpointerleave.onpointermove.onpointerout.onpointerover.onpointerup.onprogress.onratechange.onreset.onresize.onscroll.onscrollend.onsecuritypolicyviolation.onseeked.onseeking.onselect.onselectionchange.onselectstart.onslotchange.onstalled.onsubmit.onsuspend.ontimeupdate.ontoggle.ontouchcancel.ontouchend.ontouchmove.ontouchstart.ontransitioncancel.ontransitionend.ontransitionrun.ontransitionstart.onvolumechange.onwaiting.onwebkitanimationend.onwebkitanimationiteration.onwebkitanimationstart.onwebkittransitionend.onwheel`.split(`.`));function Ds(e){return Es.has(e)}function Os(...e){let t={...e[0]};for(let n=1;n<e.length;n++){let r=e[n];if(r){for(let e of Object.keys(r)){let n=t[e],i=r[e],a=typeof n==`function`,o=typeof i==`function`;if(a&&typeof o&&Ds(e))t[e]=us(n,i);else if(a&&o)t[e]=bs(n,i);else if(e===`class`){let r=es(n),a=es(i);r&&a?t[e]=ee(n,i):r?t[e]=ee(n):a&&(t[e]=ee(i))}else if(e===`style`){let r=typeof n==`object`,a=typeof i==`object`,o=typeof n==`string`,s=typeof i==`string`;if(r&&a)t[e]={...n,...i};else if(r&&s){let r=ys(i);t[e]={...n,...r}}else if(o&&a)t[e]={...ys(n),...i};else if(o&&s){let r=ys(n),a=ys(i);t[e]={...r,...a}}else r?t[e]=n:a?t[e]=i:o?t[e]=n:s&&(t[e]=i)}else t[e]=i===void 0?n:i}for(let e of Object.getOwnPropertySymbols(r)){let n=t[e],i=r[e];t[e]=i===void 0?n:i}}}return typeof t.style==`object`&&(t.style=Ts(t.style).replaceAll(`
|
|
5
|
+
`,` `)),t.hidden!==!0&&(t.hidden=void 0,delete t.hidden),t.disabled!==!0&&(t.disabled=void 0,delete t.disabled),t}var ks=typeof window<`u`?window:void 0;typeof window<`u`&&window.document,typeof window<`u`&&window.navigator,typeof window<`u`&&window.location;function As(e){let t=e.activeElement;for(;t?.shadowRoot;){let e=t.shadowRoot.activeElement;if(e===t)break;t=e}return t}new class{#e;#t;constructor(e={}){let{window:t=ks,document:n=t?.document}=e;t!==void 0&&(this.#e=n,this.#t=r(e=>{let n=A(t,`focusin`,e),r=A(t,`focusout`,e);return()=>{n(),r()}}))}get current(){return this.#t?.(),this.#e?As(this.#e):null}};function js(e){L().then(e)}var Ms=9;function Ns(e){return Qo(e)&&e.nodeType===Ms}function Ps(e){return Qo(e)&&e.constructor?.name===`VisualViewport`}function Fs(e){return Ns(e)?e:Ps(e)?e.document:e?.ownerDocument??document}function Is(e){let t=e.activeElement;for(;t?.shadowRoot;){let e=t.shadowRoot.activeElement;if(e===t)break;t=e}return t}var Ls=class{element;#e=T(()=>this.element.current?this.element.current.getRootNode()??document:document);get root(){return C(this.#e)}set root(e){P(this.#e,e)}constructor(e){this.element=typeof e==`function`?as.with(e):e}getDocument=()=>Fs(this.root);getWindow=()=>this.getDocument().defaultView??window;getActiveElement=()=>Is(this.root);isActiveElement=e=>e===this.getActiveElement();getElementById(e){return this.root.getElementById(e)}querySelector=e=>this.root?this.root.querySelector(e):null;querySelectorAll=e=>this.root?this.root.querySelectorAll(e):[];setTimeout=(e,t)=>this.getWindow().setTimeout(e,t);clearTimeout=e=>this.getWindow().clearTimeout(e)};function Rs(e,t){return{[ie()]:n=>as.isBox(e)?(e.current=n,Y(()=>t?.(n)),()=>{`isConnected`in n&&n.isConnected||(e.current=null,t?.(null))}):(e(n),Y(()=>t?.(n)),()=>{`isConnected`in n&&n.isConnected||(e(null),t?.(null))})}}function zs({layout:e,panesArray:t,pivotIndices:n}){let r=0,i=100,a=0,o=0,s=n[0];for(let e=0;e<t.length;e++){let{maxSize:n=100,minSize:c=0}=t[e].constraints;e===s?(r=c,i=n):(a+=c,o+=n)}return{valueMax:Math.min(i,100-a),valueMin:Math.max(r,100-o),valueNow:e[s]}}function Bs(e,t=`Assertion failed!`){if(!e)throw console.error(t),Error(t)}function Vs(e,t,n=10){return Hs(e,t,n)===0}function Hs(e,t,n=10){let r=Ws(e,n),i=Ws(t,n);return Math.sign(r-i)}function Us(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ws(e,t){return Number.parseFloat(e.toFixed(t))}var Gs=typeof document<`u`;function Ks(e){return e instanceof HTMLElement}function qs(e){return e.type===`keydown`}function Js(e){return e.type.startsWith(`mouse`)}function Ys(e){return e.type.startsWith(`touch`)}function Xs({paneConstraints:e,paneIndex:t,initialSize:n}){let r=e[t];Bs(r!=null,`Pane constraints should not be null.`);let{collapsedSize:i=0,collapsible:a,maxSize:o=100,minSize:s=0}=r,c=n;return Hs(c,s)<0&&(c=Zs(c,a,i,s)),c=Math.min(o,c),Number.parseFloat(c.toFixed(10))}function Zs(e,t,n,r){return t&&Hs(e,(n+r)/2)<0?n:r}function Qs(){}function $s({groupId:e,layout:t,panesArray:n,domContext:r}){let i=ec(e,r);for(let e=0;e<n.length-1;e++){let{valueMax:r,valueMin:a,valueNow:o}=zs({layout:t,panesArray:n,pivotIndices:[e,e+1]}),s=i[e];if(Ks(s)){let t=n[e];s.setAttribute(`aria-controls`,t.opts.id.current),s.setAttribute(`aria-valuemax`,`${Math.round(r)}`),s.setAttribute(`aria-valuemin`,`${Math.round(a)}`),s.setAttribute(`aria-valuenow`,o==null?``:`${Math.round(o)}`)}}return()=>{for(let e of i)e.removeAttribute(`aria-controls`),e.removeAttribute(`aria-valuemax`),e.removeAttribute(`aria-valuemin`),e.removeAttribute(`aria-valuenow`)}}function ec(e,t){return Gs?Array.from(t.querySelectorAll(`[data-pane-resizer-id][data-pane-group-id="${e}"]`)):[]}function tc({groupId:e,id:t,domContext:n}){return Gs?ec(e,n).findIndex(e=>e.getAttribute(`data-pane-resizer-id`)===t)??null:null}function nc({groupId:e,dragHandleId:t,domContext:n}){let r=tc({groupId:e,id:t,domContext:n});return r==null?[-1,-1]:[r,r+1]}function rc(e,t,n){let r=e.map(e=>e.constraints),i=ic(e,t),a=r[i],o=i===e.length-1?[i-1,i]:[i,i+1],s=n[i];return{...a,paneSize:s,pivotIndices:o}}function ic(e,t){return e.findIndex(e=>e.opts.id.current===t.opts.id.current)}function ac(e,t,n){for(let r=0;r<t.length;r++){let i=t[r],a=e[r];Bs(a);let{collapsedSize:o=0,collapsible:s}=a.constraints,c=n[a.opts.id.current];if(c!=null&&i===c)continue;n[a.opts.id.current]=i;let{onCollapse:l,onExpand:u,onResize:d}=a.callbacks;d?.(i,c),s&&(l||u)&&(u&&(c==null||c===o)&&i!==o&&u(),l&&(c==null||c!==o)&&i===o&&l())}}function oc({panesArray:e}){let t=Array(e.length),n=e.map(e=>e.constraints),r=0,i=100;for(let a=0;a<e.length;a++){let e=n[a];Bs(e);let{defaultSize:o}=e;o!=null&&(r++,t[a]=o,i-=o)}for(let a=0;a<e.length;a++){let o=n[a];Bs(o);let{defaultSize:s}=o;if(s!=null)continue;let c=e.length-r,l=i/c;r++,t[a]=l,i-=l}return t}function sc({layout:e,paneConstraints:t}){let n=[...e],r=n.reduce((e,t)=>e+t,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} pane layout: ${n.map(e=>`${e}%`).join(`, `)}`);if(!Vs(r,100))for(let e=0;e<t.length;e++){let t=n[e];Bs(t!=null);let i=100/r*t;n[e]=i}let i=0;for(let e=0;e<t.length;e++){let r=n[e];Bs(r!=null);let a=Xs({paneConstraints:t,paneIndex:e,initialSize:r});r!==a&&(i+=r-a,n[e]=a)}if(!Vs(i,0))for(let e=0;e<t.length;e++){let r=n[e];Bs(r!=null);let a=r+i,o=Xs({paneConstraints:t,paneIndex:e,initialSize:a});if(r!==o&&(i-=o-r,n[e]=o,Vs(i,0)))break}return n}function cc(e,t){return Gs&&t.querySelector(`[data-pane-group][data-pane-group-id="${e}"]`)||null}function lc(e,t){return Gs&&t.querySelector(`[data-pane-resizer-id="${e}"]`)||null}function uc({event:e,dragHandleId:t,dir:n,initialDragState:r,domContext:i}){let a=n===`horizontal`,o=lc(t,i);Bs(o);let s=o.getAttribute(`data-pane-group-id`);Bs(s);let{initialCursorPosition:c}=r,l=fc(n,e),u=cc(s,i);Bs(u);let d=u.getBoundingClientRect(),f=a?d.width:d.height;return(l-c)/f*100}function dc({event:e,dragHandleId:t,dir:n,initialDragState:r,keyboardResizeBy:i,domContext:a}){if(qs(e)){let t=n===`horizontal`,r=0;r=e.shiftKey?100:i??10;let a=0;switch(e.key){case`ArrowDown`:a=t?0:r;break;case`ArrowLeft`:a=t?-r:0;break;case`ArrowRight`:a=t?r:0;break;case`ArrowUp`:a=t?0:-r;break;case`End`:a=100;break;case`Home`:a=-100}return a}return r==null?0:uc({event:e,dragHandleId:t,dir:n,initialDragState:r,domContext:a})}function fc(e,t){let n=e===`horizontal`;if(Js(t))return n?t.clientX:t.clientY;if(Ys(t)){let e=t.touches[0];return Bs(e),n?e.screenX:e.screenY}throw Error(`Unsupported event type "${t.type}"`)}function pc({groupId:e,handleId:t,panesArray:n,domContext:r}){let i=lc(t,r),a=ec(e,r),o=i?a.indexOf(i):-1;return[n[o]?.opts.id.current??null,n[o+1]?.opts.id.current??null]}function mc({delta:e,layout:t,paneConstraints:n,pivotIndices:r,trigger:i}){if(Vs(e,0))return t;let a=[...t],[o,s]=r,c=0;if(i===`keyboard`){{let r=e<0?s:o,i=n[r];if(Bs(i),i.collapsible){let i=t[r];Bs(i!=null);let a=n[r];Bs(a);let{collapsedSize:o=0,minSize:s=0}=a;if(Vs(i,o)){let t=s-i;Hs(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let r=e<0?o:s,i=n[r];Bs(i);let{collapsible:a}=i;if(a){let i=t[r];Bs(i!=null);let a=n[r];Bs(a);let{collapsedSize:o=0,minSize:s=0}=a;if(Vs(i,s)){let t=i-o;Hs(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}}{let r=e<0?1:-1,i=e<0?s:o,a=0;for(;;){let e=t[i];Bs(e!=null);let o=Xs({paneConstraints:n,paneIndex:i,initialSize:100})-e;if(a+=o,i+=r,i<0||i>=n.length)break}let c=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-c:c}{let r=e<0?o:s;for(;r>=0&&r<n.length;){let i=Math.abs(e)-Math.abs(c),o=t[r];Bs(o!=null);let s=o-i,l=Xs({paneConstraints:n,paneIndex:r,initialSize:s});if(!Vs(o,l)&&(c+=o-l,a[r]=l,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?r--:r++}}if(Vs(c,0))return t;{let r=e<0?s:o,i=t[r];Bs(i!=null);let l=i+c,u=Xs({paneConstraints:n,paneIndex:r,initialSize:l});if(a[r]=u,!Vs(u,l)){let t=l-u,r=e<0?s:o;for(;r>=0&&r<n.length;){let i=a[r];Bs(i!=null);let o=i+t,s=Xs({paneConstraints:n,paneIndex:r,initialSize:o});if(Vs(i,s)||(t-=s-i,a[r]=s),Vs(t,0))break;e>0?r--:r++}}}return Vs(a.reduce((e,t)=>t+e,0),100)?a:t}var hc=null,gc=null;function _c(e){switch(e){case`horizontal`:return`ew-resize`;case`horizontal-max`:return`w-resize`;case`horizontal-min`:return`e-resize`;case`vertical`:return`ns-resize`;case`vertical-max`:return`n-resize`;case`vertical-min`:return`s-resize`}}function vc(){gc!==null&&(document.head.removeChild(gc),hc=null,gc=null)}function yc(e,t){if(hc===e)return;hc=e;let n=_c(e);gc===null&&(gc=t.createElement(`style`),t.head.appendChild(gc)),gc.innerHTML=`*{cursor: ${n}!important;}`}function bc({defaultSize:e,dragState:t,layout:n,panesArray:r,paneIndex:i,precision:a=3}){let o=n[i],s;return s=o==null?e??`1`:r.length===1?`1`:o.toPrecision(a),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:`hidden`,pointerEvents:t===null?void 0:`none`}}function xc(e){try{if(typeof localStorage>`u`)throw TypeError(`localStorage is not supported in this environment`);e.getItem=e=>localStorage.getItem(e),e.setItem=(e,t)=>localStorage.setItem(e,t)}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Sc(e){return`paneforge:${e}`}function Cc(e){return e.map(e=>e.opts.order.current?`${e.opts.order.current}:${JSON.stringify(e.constraints)}`:JSON.stringify(e.constraints)).sort().join(`,`)}function wc(e,t){try{let n=Sc(e),r=t.getItem(n),i=JSON.parse(r||``);if(typeof i==`object`&&i)return i}catch{}return null}function Tc(e,t,n){return(wc(e,n)||{})[Cc(t)]||null}function Ec(e,t,n,r,i){let a=Sc(e),o=Cc(t),s=wc(e,i)||{};s[o]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{i.setItem(a,JSON.stringify(s))}catch(e){console.error(e)}}var Dc={};function Oc(e,t=10){let n=null;return(...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}}function kc({autoSaveId:e,layout:t,storage:n,panesArray:r,paneSizeBeforeCollapse:i}){if(t.length===0||t.length!==r.length)return;let a=Dc[e];a??(a=Oc(Ec,100),Dc[e]=a);let o=[...r],s=new Map(i);a(e,o,s,t,n)}var Ac={getItem:e=>(xc(Ac),Ac.getItem(e)),setItem:(e,t)=>{xc(Ac),Ac.setItem(e,t)}},jc=new _e(`PaneGroup`),Mc=class e{static create(t){return jc.set(new e(t))}opts;attachment;domContext;#e=Z(null);get dragState(){return C(this.#e)}set dragState(e){P(this.#e,e)}#t=Z([]);get layout(){return C(this.#t)}set layout(e){P(this.#t,e)}#n=Z([]);get panesArray(){return C(this.#n)}set panesArray(e){P(this.#n,e)}#r=Z(!1);get panesArrayChanged(){return C(this.#r)}set panesArrayChanged(e){P(this.#r,e,!0)}#i=Z(B({}));get paneIdToLastNotifiedSizeMap(){return C(this.#i)}set paneIdToLastNotifiedSizeMap(e){P(this.#i,e,!0)}paneSizeBeforeCollapseMap=new Map;prevDelta=0;constructor(e){this.opts=e,this.attachment=Rs(this.opts.ref),this.domContext=new Ls(this.opts.ref),he([()=>this.opts.id.current,()=>this.layout,()=>this.panesArray],()=>$s({groupId:this.opts.id.current,layout:this.layout,panesArray:this.panesArray,domContext:this.domContext})),le(()=>Y(()=>this.#a())),he([()=>this.opts.autoSaveId.current,()=>this.layout,()=>this.opts.storage.current],()=>{this.opts.autoSaveId.current&&kc({autoSaveId:this.opts.autoSaveId.current,layout:this.layout,storage:this.opts.storage.current,panesArray:this.panesArray,paneSizeBeforeCollapse:this.paneSizeBeforeCollapseMap})}),he(()=>this.panesArrayChanged,()=>{if(!this.panesArrayChanged)return;this.panesArrayChanged=!1;let e=this.layout,t=null;if(this.opts.autoSaveId.current){let e=Tc(this.opts.autoSaveId.current,this.panesArray,this.opts.storage.current);e&&(this.paneSizeBeforeCollapseMap=new Map(Object.entries(e.expandToSizes)),t=e.layout)}t??=oc({panesArray:this.panesArray});let n=sc({layout:t,paneConstraints:this.panesArray.map(e=>e.constraints)});Us(e,n)||(this.layout=n,this.opts.onLayout.current?.(n),ac(this.panesArray,n,this.paneIdToLastNotifiedSizeMap))})}setLayout=e=>{this.layout=e};registerResizeHandle=e=>t=>{t.preventDefault();let n=this.opts.direction.current,r=this.dragState,i=this.opts.id.current,a=this.opts.keyboardResizeBy.current,o=this.layout,s=this.panesArray,{initialLayout:c}=r??{},l=this.domContext.getDocument(),u=nc({groupId:i,dragHandleId:e,domContext:this.domContext}),d=dc({event:t,dragHandleId:e,dir:n,initialDragState:r,keyboardResizeBy:a,domContext:this.domContext});if(d===0)return;let f=n===`horizontal`;l.dir===`rtl`&&f&&(d=-d);let p=s.map(e=>e.constraints),m=mc({delta:d,layout:c??o,paneConstraints:p,pivotIndices:u,trigger:qs(t)?`keyboard`:`mouse-or-touch`}),h=!Us(o,m);(Js(t)||Ys(t))&&this.prevDelta!==d&&(this.prevDelta=d,yc(h?f?`horizontal`:`vertical`:f?d<0?`horizontal-min`:`horizontal-max`:d<0?`vertical-min`:`vertical-max`,l)),h&&(this.setLayout(m),this.opts.onLayout.current?.(m),ac(s,m,this.paneIdToLastNotifiedSizeMap))};resizePane=(e,t)=>{let n=this.layout,r=this.panesArray,i=r.map(e=>e.constraints),{paneSize:a,pivotIndices:o}=rc(r,e,n);Bs(a!=null);let s=mc({delta:ic(r,e)===r.length-1?a-t:t-a,layout:n,paneConstraints:i,pivotIndices:o,trigger:`imperative-api`});Us(n,s)||(this.setLayout(s),this.opts.onLayout.current?.(s),ac(r,s,this.paneIdToLastNotifiedSizeMap))};startDragging=(e,t)=>{let n=this.opts.direction.current,r=this.layout,i=lc(e,this.domContext);Bs(i);let a=fc(n,t);this.dragState={dragHandleId:e,dragHandleRect:i.getBoundingClientRect(),initialCursorPosition:a,initialLayout:r}};stopDragging=()=>{vc(),this.dragState=null};isPaneCollapsed=e=>{let t=this.panesArray,n=this.layout,{collapsedSize:r=0,collapsible:i,paneSize:a}=rc(t,e,n);return typeof a!=`number`||typeof r!=`number`?!1:i===!0&&Vs(a,r)};expandPane=e=>{let t=this.layout,n=this.panesArray;if(!e.constraints.collapsible)return;let r=n.map(e=>e.constraints),{collapsedSize:i=0,paneSize:a,minSize:o=0,pivotIndices:s}=rc(n,e,t);if(a!==i)return;let c=this.paneSizeBeforeCollapseMap.get(e.opts.id.current),l=c!=null&&c>=o?c:o,u=mc({delta:ic(n,e)===n.length-1?a-l:l-a,layout:t,paneConstraints:r,pivotIndices:s,trigger:`imperative-api`});Us(t,u)||(this.setLayout(u),this.opts.onLayout.current?.(u),ac(n,u,this.paneIdToLastNotifiedSizeMap))};collapsePane=e=>{let t=this.layout,n=this.panesArray;if(!e.constraints.collapsible)return;let r=n.map(e=>e.constraints),{collapsedSize:i=0,paneSize:a,pivotIndices:o}=rc(n,e,t);if(Bs(a!=null),a===i)return;this.paneSizeBeforeCollapseMap.set(e.opts.id.current,a);let s=mc({delta:ic(n,e)===n.length-1?a-i:i-a,layout:t,paneConstraints:r,pivotIndices:o,trigger:`imperative-api`});Us(t,s)||(this.layout=s,this.opts.onLayout.current?.(s),ac(n,s,this.paneIdToLastNotifiedSizeMap))};getPaneSize=e=>rc(this.panesArray,e,this.layout).paneSize;getPaneStyle=(e,t)=>{let n=this.panesArray,r=this.layout,i=this.dragState;return bc({defaultSize:t,dragState:i,layout:r,panesArray:n,paneIndex:ic(n,e)})};isPaneExpanded=e=>{let{collapsedSize:t=0,collapsible:n,paneSize:r}=rc(this.panesArray,e,this.layout);return!n||r>t};registerPane=e=>{let t=[...this.panesArray,e];return t.sort((e,t)=>{let n=e.opts.order.current,r=t.opts.order.current;return n==null&&r==null?0:n==null?-1:r==null?1:n-r}),this.panesArray=t,this.panesArrayChanged=!0,()=>{let t=[...this.panesArray],n=ic(this.panesArray,e);n<0||(t.splice(n,1),this.panesArray=t,delete this.paneIdToLastNotifiedSizeMap[e.opts.id.current],this.panesArrayChanged=!0)}};#a=()=>{let e=this.opts.id.current,t=ec(e,this.domContext),n=this.panesArray,r=t.map(t=>{let r=t.getAttribute(`data-pane-resizer-id`);if(!r)return Qs;let[i,a]=pc({groupId:e,handleId:r,panesArray:n,domContext:this.domContext});if(i==null||a==null)return Qs;let o=xs(t,`keydown`,t=>{if(t.defaultPrevented||t.key!==`Enter`)return;t.preventDefault();let n=this.panesArray,a=n.findIndex(e=>e.opts.id.current===i);if(a<0)return;let o=n[a];Bs(o);let s=this.layout,c=s[a],{collapsedSize:l=0,collapsible:u,minSize:d=0}=o.constraints;if(!(c!=null&&u))return;let f=mc({delta:Vs(c,l)?d-c:l-c,layout:s,paneConstraints:n.map(e=>e.constraints),pivotIndices:nc({groupId:e,dragHandleId:r,domContext:this.domContext}),trigger:`keyboard`});s!==f&&(this.layout=f)});return()=>{o()}});return()=>{for(let e of r)e()}};#o=T(()=>({id:this.opts.id.current,"data-pane-group":``,"data-direction":this.opts.direction.current,"data-pane-group-id":this.opts.id.current,style:{display:`flex`,flexDirection:this.opts.direction.current===`horizontal`?`row`:`column`,height:`100%`,overflow:`hidden`,width:`100%`},...this.attachment}));get props(){return C(this.#o)}set props(e){P(this.#o,e)}},Nc=[`ArrowDown`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`End`,`Home`],Pc=class e{static create(t){return new e(t,jc.get())}opts;#e;attachment;domContext;#t=T(()=>this.#e.dragState?.dragHandleId===this.opts.id.current);#n=Z(!1);resizeHandler=null;constructor(e,t){this.opts=e,this.#e=t,this.attachment=Rs(this.opts.ref),this.domContext=new Ls(this.opts.ref),le(()=>{this.resizeHandler=this.opts.disabled.current?null:this.#e.registerResizeHandle(this.opts.id.current)}),le(()=>{let e=this.opts.ref.current;if(!e)return;let t=this.opts.disabled.current,n=this.resizeHandler,r=C(this.#t);if(t||n===null||!r)return;let i=e=>{n(e)},a=e=>{n(e)},o=()=>{e.blur(),this.#e.stopDragging(),this.opts.onDraggingChange.current(!1)},s=this.domContext.getDocument().body,c=this.domContext.getWindow();return bs(A(s,`contextmenu`,o),A(s,`mousemove`,i),A(s,`touchmove`,i,{passive:!1}),A(s,`mouseleave`,a),A(c,`mouseup`,o),A(c,`touchend`,o))})}#r=e=>{e.preventDefault(),!this.opts.disabled.current&&(this.#e.startDragging(this.opts.id.current,e),this.opts.onDraggingChange.current(!0))};#i=()=>{let e=this.opts.ref.current;e&&(e.blur(),this.#e.stopDragging(),this.opts.onDraggingChange.current(!1))};#a=e=>{if(this.opts.disabled.current||!this.resizeHandler||e.defaultPrevented)return;if(Nc.includes(e.key)){e.preventDefault(),this.resizeHandler(e);return}if(e.key!==`F6`)return;e.preventDefault();let t=ec(this.#e.opts.id.current,this.domContext),n=tc({groupId:this.#e.opts.id.current,id:this.opts.id.current,domContext:this.domContext});if(n===null)return;let r=0;r=e.shiftKey?n>0?n-1:t.length-1:n+1<t.length?n+1:0,t[r].focus()};#o=()=>{P(this.#n,!1)};#s=()=>{P(this.#n,!0)};#c=e=>{this.#r(e)};#l=()=>{this.#i()};#u=()=>{this.#i()};#d=()=>{this.#i()};#f=e=>{this.#r(e)};#p=T(()=>({id:this.opts.id.current,role:`separator`,"data-direction":this.#e.opts.direction.current,"data-pane-group-id":this.#e.opts.id.current,"data-active":C(this.#t)?`pointer`:C(this.#n)?`keyboard`:void 0,"data-enabled":!this.opts.disabled.current,"data-pane-resizer-id":this.opts.id.current,"data-pane-resizer":``,tabIndex:this.opts.tabIndex.current,style:{cursor:_c(this.#e.opts.direction.current),touchAction:`none`,userSelect:`none`,"-webkit-user-select":`none`,"-webkit-touch-callout":`none`},onkeydown:this.#a,onblur:this.#o,onfocus:this.#s,onmousedown:this.#c,onmouseup:this.#l,ontouchcancel:this.#u,ontouchend:this.#d,ontouchstart:this.#f,...this.attachment}));get props(){return C(this.#p)}set props(e){P(this.#p,e)}},Fc=class e{static create(t){return new e(t,jc.get())}opts;group;attachment;domContext;#e=Z(``);#t=T(()=>({onCollapse:this.opts.onCollapse.current,onExpand:this.opts.onExpand.current,onResize:this.opts.onResize.current}));get callbacks(){return C(this.#t)}set callbacks(e){P(this.#t,e)}#n=T(()=>({collapsedSize:this.opts.collapsedSize.current,collapsible:this.opts.collapsible.current,defaultSize:this.opts.defaultSize.current,maxSize:this.opts.maxSize.current,minSize:this.opts.minSize.current}));get constraints(){return C(this.#n)}set constraints(e){P(this.#n,e)}#r=e=>{P(this.#e,e,!0),js(()=>{if(this.opts.ref.current){let e=this.opts.ref.current;if(getComputedStyle(e).transitionDuration===`0s`){P(this.#e,``);return}let t=n=>{n.propertyName===`flex-grow`&&(P(this.#e,``),e.removeEventListener(`transitionend`,t))};e.addEventListener(`transitionend`,t)}else P(this.#e,``)})};pane={collapse:()=>{this.#r(`collapsing`),this.group.collapsePane(this)},expand:()=>{this.#r(`expanding`),this.group.expandPane(this)},getSize:()=>this.group.getPaneSize(this),isCollapsed:()=>this.group.isPaneCollapsed(this),isExpanded:()=>this.group.isPaneExpanded(this),resize:e=>this.group.resizePane(this,e),getId:()=>this.opts.id.current};constructor(e,t){this.opts=e,this.group=t,this.attachment=Rs(this.opts.ref),this.domContext=new Ls(this.opts.ref),_(()=>this.group.registerPane(this)),he(()=>v(this.constraints),()=>{this.group.panesArrayChanged=!0})}#i=T(()=>this.group.isPaneCollapsed(this));#a=T(()=>C(this.#e)===``?C(this.#i)?`collapsed`:`expanded`:C(this.#e));#o=T(()=>({id:this.opts.id.current,style:this.group.getPaneStyle(this,this.opts.defaultSize.current),"data-pane":``,"data-pane-id":this.opts.id.current,"data-pane-group-id":this.group.opts.id.current,"data-collapsed":C(this.#i)?``:void 0,"data-expanded":C(this.#i)?void 0:``,"data-pane-state":C(this.#a),...this.attachment}));get props(){return C(this.#o)}set props(e){P(this.#o,e)}},Ic=new Set([`$$slots`,`$$events`,`$$legacy`,`autoSaveId`,`direction`,`id`,`keyboardResizeBy`,`onLayoutChange`,`storage`,`ref`,`child`,`children`]),Lc=D(`<div><!></div>`);function Rc(e,n){let r=l();V(n,!0);let i=J(n,`autoSaveId`,3,null),a=J(n,`id`,3,r),o=J(n,`keyboardResizeBy`,3,null),s=J(n,`onLayoutChange`,3,Qs),d=J(n,`storage`,3,Ac),f=J(n,`ref`,15,null),p=W(n,Ic),m=Mc.create({id:as.with(()=>a()??r),ref:as.with(()=>f(),e=>f(e)),autoSaveId:as.with(()=>i()),direction:as.with(()=>n.direction),keyboardResizeBy:as.with(()=>o()),onLayout:as.with(()=>s()),storage:as.with(()=>d())}),g=()=>m.layout,_=m.setLayout,v=()=>m.opts.id.current,y=T(()=>Os(p,m.props));var S={getLayout:g,setLayout:_,getId:v},w=u(),E=z(w),D=e=>{var t=u(),r=z(t);x(r,()=>n.child,()=>({props:C(y)})),O(e,t)},k=e=>{var t=Lc();R(t,()=>({...C(y)}));var r=I(t);x(r,()=>n.children??h),c(t),O(e,t)};return t(E,e=>{n.child?e(D):e(k,-1)}),O(e,w),b(S)}var zc=new Set([`$$slots`,`$$events`,`$$legacy`,`id`,`ref`,`collapsedSize`,`collapsible`,`defaultSize`,`maxSize`,`minSize`,`onCollapse`,`onExpand`,`onResize`,`order`,`child`,`children`]),Bc=D(`<div><!></div>`);function Vc(e,n){let r=l();V(n,!0);let i=J(n,`id`,3,r),a=J(n,`ref`,15,null),o=J(n,`onCollapse`,3,Qs),s=J(n,`onExpand`,3,Qs),d=J(n,`onResize`,3,Qs),f=W(n,zc),p=Fc.create({id:as.with(()=>i()),ref:as.with(()=>a(),e=>a(e)),collapsedSize:as.with(()=>n.collapsedSize),collapsible:as.with(()=>n.collapsible),defaultSize:as.with(()=>n.defaultSize),maxSize:as.with(()=>n.maxSize),minSize:as.with(()=>n.minSize),onCollapse:as.with(()=>o()),onExpand:as.with(()=>s()),onResize:as.with(()=>d()),order:as.with(()=>n.order)}),m=p.pane.collapse,g=p.pane.expand,_=p.pane.getSize,v=p.pane.isCollapsed,y=p.pane.isExpanded,S=p.pane.resize,w=p.pane.getId,E=T(()=>Os(f,p.props));var D={collapse:m,expand:g,getSize:_,isCollapsed:v,isExpanded:y,resize:S,getId:w},k=u(),A=z(k),j=e=>{var t=u(),r=z(t);x(r,()=>n.child,()=>({props:C(E)})),O(e,t)},M=e=>{var t=Bc();R(t,()=>({...C(E)}));var r=I(t);x(r,()=>n.children??h),c(t),O(e,t)};return t(A,e=>{n.child?e(j):e(M,-1)}),O(e,k),b(D)}var Hc=new Set([`$$slots`,`$$events`,`$$legacy`,`id`,`ref`,`disabled`,`onDraggingChange`,`tabindex`,`child`,`children`]),Uc=D(`<div><!></div>`);function Wc(e,n){let r=l();V(n,!0);let i=J(n,`id`,3,r),a=J(n,`ref`,15,null),o=J(n,`disabled`,3,!1),s=J(n,`onDraggingChange`,3,Qs),d=J(n,`tabindex`,3,0),f=W(n,Hc),p=Pc.create({id:as.with(()=>i()),ref:as.with(()=>a(),e=>a(e)),disabled:as.with(()=>o()),onDraggingChange:as.with(()=>s()),tabIndex:as.with(()=>d())}),m=T(()=>Os(f,p.props));var g=u(),_=z(g),v=e=>{var t=u(),r=z(t);x(r,()=>n.child,()=>({props:C(m)})),O(e,t)},y=e=>{var t=Uc();R(t,()=>({...C(m)}));var r=I(t);x(r,()=>n.children??h),c(t),O(e,t)};t(_,e=>{n.child?e(v):e(y,-1)}),O(e,g),b()}var Gc=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`withHandle`,`line`]),Kc=D(`<div class="h-8 w-0.75 group-hover/handle:h-12 z-10 flex shrink-0 rounded-full bg-border-strong transition duration-150 group-hover/handle:bg-input group-active/handle:bg-muted-foreground"></div>`);function qc(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=J(n,`withHandle`,3,!1),a=J(n,`line`,3,!0),o=W(n,Gc);var s=u(),c=z(s);{let e=T(()=>Fe(`group/handle after:inset-y-0 after:w-1 data-[direction=vertical]:after:left-0 data-[direction=vertical]:after:h-1 data-[direction=vertical]:after:translate-x-0 relative flex w-px items-center justify-center after:absolute after:left-1/2 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-hidden data-[direction=vertical]:h-px data-[direction=vertical]:w-full data-[direction=vertical]:after:w-full data-[direction=vertical]:after:-translate-y-1/2 [&[data-direction=vertical]>div]:rotate-90`,a()?`bg-border`:`w-3 data-[direction=vertical]:h-3 bg-transparent`,n.class));E(c,()=>Wc,(n,a)=>{a(n,q({"data-slot":`resizable-handle`,get class(){return C(e)}},()=>o,{get ref(){return r()},set ref(e){r(e)},children:(e,n)=>{var r=u(),a=z(r),o=e=>{var t=Kc();O(e,t)};t(a,e=>{i()&&e(o)}),O(e,r)},$$slots:{default:!0}}))})}O(e,s),b()}var Jc=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`this`,`class`]);function Yc(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=J(t,`this`,15),i=W(t,Jc);var a=u(),o=z(a);{let e=T(()=>Fe(`flex h-full w-full data-[direction=vertical]:flex-col`,t.class));E(o,()=>Rc,(t,a)=>{F(a(t,q({"data-slot":`resizable-pane-group`,get class(){return C(e)}},()=>i,{get ref(){return n()},set ref(e){n(e)}})),e=>r(e),()=>r())})}O(e,a),b()}var Xc=D(`<!> <!> <!>`,1);function Zc(e,n){V(n,!0);let r=J(n,`message`,3,``),i=J(n,`size`,3,`medium`),a=J(n,`class`,3,``),o={small:`p-4`,medium:`p-8`,large:`p-12`};var s=u(),c=z(s);{let e=T(()=>Fe(o[i()],a()));E(c,()=>Ho,(i,a)=>{a(i,{get class(){return C(e)},children:(e,i)=>{var a=u(),o=z(a);E(o,()=>Mo,(e,i)=>{i(e,{children:(e,i)=>{var a=Xc(),o=z(a);E(o,()=>Io,(e,r)=>{r(e,{variant:`icon`,children:(e,r)=>{var i=u(),a=z(i),o=e=>{Wo(e,{})},s=e=>{ar(e,{})},c=e=>{Ue(e,{get severity(){return n.type}})};t(a,e=>{n.type===`loading`?e(o):n.type===`empty`?e(s,1):e(c,-1)}),O(e,i)},$$slots:{default:!0}})});var s=U(o,2),c=e=>{var t=u(),r=z(t);E(r,()=>zo,(e,t)=>{t(e,{children:(e,t)=>{S();var r=p();G(()=>m(r,n.title)),O(e,r)},$$slots:{default:!0}})}),O(e,t)};t(s,e=>{n.title&&e(c)});var l=U(s,2),d=e=>{var t=u(),n=z(t);E(n,()=>ko,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,r())),O(e,n)},$$slots:{default:!0}})}),O(e,t)};t(l,e=>{r()&&e(d)}),O(e,a)},$$slots:{default:!0}})}),O(e,a)},$$slots:{default:!0}})})}O(e,s),b()}var Qc=D(`<!> <kbd class="px-1 rounded-sm border border-current/30 font-sans text-2xs opacity-70">Esc</kbd>`,1),$c=D(`<!> `,1),el=D(`<span class="size-1.5 shrink-0 rounded-full bg-success" aria-hidden="true"></span> `,1),tl=D(`<div class="bottom-0 mt-3 pb-3 pt-2 backdrop-blur-sm px-2 sticky border-t border-border"><span class="sr-only" role="status" aria-live="polite"> </span> <div class="gap-2 flex"><!> <!></div></div>`);function nl(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),a=J(n,`hasNeverSolved`,3,!1),o=Z(``),s=!1;le(()=>{let e=n.isSolving;Y(()=>{e?P(o,C(i).solvingEllipsis,!0):s&&P(o,n.hasPendingChanges?``:C(i).upToDate,!0),s=e})});var l=tl(),d=I(l),f=K(d,!0),p=U(d,2),g=I(p);{let e=T(()=>n.hasPendingChanges?`default`:`ghost`),r=T(()=>!n.hasPendingChanges&&!n.isSolving),o=T(()=>n.hasPendingChanges&&!n.isSolving?`shadow-md`:``),s=T(()=>!n.hasPendingChanges&&!n.isSolving?`text-muted-foreground`:``);tt(g,{get variant(){return C(e)},size:`lg`,onclick:()=>!n.isSolving&&n.oncalculate(),get disabled(){return C(r)},get"aria-busy"(){return n.isSolving},get class(){return`gap-2 font-medium min-w-0 flex-1 transition-all duration-200
|
|
6
6
|
${C(o)??``}
|
|
7
|
-
${C(s)??``}`},children:(e,r)=>{var o=u(),s=B(o),c=e=>{var t=Qc(),n=B(t);_t(n,{class:`h-4 w-4 animate-spin`});var r=U(n),a=U(r);G(()=>{m(r,` ${C(i).solvingEllipsis??``} `),H(a,`title`,C(i).solveMessagesEscHint)}),O(e,t)},l=e=>{var t=$c(),n=B(t);gt(n,{class:`h-4 w-4`});var r=U(n);G(()=>m(r,` ${C(i).pressToCalculate??``}`)),O(e,t)},d=e=>{var t=$c(),n=B(t);Wr(n,{class:`h-4 w-4`});var r=U(n);G(()=>m(r,` ${C(i).calculate??``}`)),O(e,t)},f=e=>{var t=el(),n=U(B(t));G(()=>m(n,` ${C(i).upToDate??``}`)),O(e,t)};t(s,e=>{n.isSolving?e(c):a()?e(l,1):n.hasPendingChanges?e(d,2):e(f,-1)}),O(e,o)},$$slots:{default:!0}})}var _=U(g,2);x(_,()=>n.trailing??h),c(p),c(l),G(()=>m(f,C(o))),O(e,l),b()}var rl={FILE_UPLOAD:{MAX_SIZE_MB:300,MAX_SIZE_BYTES:314572800},TIMEOUTS:{SOLVE_STATE_DURATION:3500,DRAWER_ANIMATION_MS:350},SOLVING_INDICATOR:{SHOW_AFTER_MS:400,MIN_VISIBLE_MS:500,SLOW_AFTER_MS:2e3},FILE_SIZE:{BYTES_PER_KB:1024}},il=new Set;function al(e){return e?!il.has(e):!1}var ol=new WeakSet;function sl(e){ol.add(e)}function cl(e){ol.delete(e)}function ll(e){return ol.has(e)}var ul=new WeakMap;function dl(e,t){ul.set(e,t)}function fl(e){if(ol.has(e))return e;let t=ul.get(e);return t&&ol.has(t)?t:null}var pl={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ml={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},hl=1e3,gl=1001,_l=1002,vl=1003,yl=1004,bl=1005,xl=1006,Sl=1007,Cl=1008,wl=1009,Tl=1010,El=1011,Dl=1012,Ol=1013,kl=1014,Al=1015,jl=1016,Ml=1017,Nl=1018,Pl=1020,Fl=35902,Il=35899,Ll=1021,Rl=1022,zl=1023,Bl=1026,Vl=1027,Hl=1028,Ul=1029,Wl=1030,Gl=1031,Kl=1033,ql=33776,Jl=33777,Yl=33778,Xl=33779,Zl=35840,Ql=35841,$l=35842,eu=35843,tu=36196,nu=37492,ru=37496,iu=37488,au=37489,ou=37490,su=37491,cu=37808,lu=37809,uu=37810,du=37811,fu=37812,pu=37813,mu=37814,hu=37815,gu=37816,_u=37817,vu=37818,yu=37819,bu=37820,xu=37821,Su=36492,Cu=36494,wu=36495,Tu=36283,Eu=36284,Du=36285,Ou=36286,ku=2300,Au=2301,ju=2302,Mu=2303,Nu=2400,Pu=2401,Fu=2402,Iu=3200,Lu=`srgb`,Ru=`srgb-linear`,zu=`linear`,Bu=`srgb`,Vu=7680,Hu=35044,Uu=2e3;function Wu(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Gu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ku(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function qu(){let e=Ku(`canvas`);return e.style.display=`block`,e}var Ju={};function Yu(...e){let t=`THREE.`+e.shift();console.log(t,...e)}function Xu(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function Zu(...e){e=Xu(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function Qu(...e){e=Xu(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function $u(...e){let t=e.join(` `);t in Ju||(Ju[t]=!0,Zu(...e))}function ed(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var td={0:0,2:6,4:4,3:5,1:1,6:2,7:7,5:3},nd=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&&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 e=r.indexOf(t);e!==-1&&r.splice(e,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 t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},rd=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),id=1234567,ad=Math.PI/180,od=180/Math.PI;function sd(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(rd[e&255]+rd[e>>8&255]+rd[e>>16&255]+rd[e>>24&255]+`-`+rd[t&255]+rd[t>>8&255]+`-`+rd[t>>16&15|64]+rd[t>>24&255]+`-`+rd[n&63|128]+rd[n>>8&255]+`-`+rd[n>>16&255]+rd[n>>24&255]+rd[r&255]+rd[r>>8&255]+rd[r>>16&255]+rd[r>>24&255]).toLowerCase()}function cd(e,t,n){return Math.max(t,Math.min(n,e))}function ld(e,t){return(e%t+t)%t}function ud(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function dd(e,t,n){return e===t?0:(n-e)/(t-e)}function fd(e,t,n){return(1-n)*e+n*t}function pd(e,t,n,r){return fd(e,t,1-Math.exp(-n*r))}function md(e,t=1){return t-Math.abs(ld(e,t*2)-t)}function hd(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function gd(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function _d(e,t){return e+Math.floor(Math.random()*(t-e+1))}function vd(e,t){return e+Math.random()*(t-e)}function yd(e){return e*(.5-Math.random())}function bd(e){e!==void 0&&(id=e);let t=id+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function xd(e){return e*ad}function Sd(e){return e*od}function Cd(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function wd(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function Td(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function Ed(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:Zu(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function Dd(e){switch(e.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 Od(e,t){if(t.constructor===Float32Array)return e;let n=Dd(t);if(n===void 0)throw Error(`THREE.MathUtils: Invalid component type.`);return Math.max(e/n,-1)}function kd(e,t){if(t.constructor===Float32Array)return e;let n=Dd(t);if(n===void 0)throw Error(`THREE.MathUtils: Invalid component type.`);return Math.round(e*n)}var Ad={DEG2RAD:ad,RAD2DEG:od,generateUUID:sd,clamp:cd,euclideanModulo:ld,mapLinear:ud,inverseLerp:dd,lerp:fd,damp:pd,pingpong:md,smoothstep:hd,smootherstep:gd,randInt:_d,randFloat:vd,randFloatSpread:yd,seededRandom:bd,degToRad:xd,radToDeg:Sd,isPowerOfTwo:Cd,ceilPowerOfTwo:wd,floorPowerOfTwo:Td,setQuaternionFromProperEuler:Ed,normalize:kd,denormalize:Od},Q=class{static{this.prototype.isVector2=!0}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 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 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=cd(this.x,e.x,t.x),this.y=cd(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=cd(this.x,e,t),this.y=cd(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(cd(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(cd(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),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},jd=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,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,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,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:Zu(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}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],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}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(cd(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*=e,this._y*=e,this._z*=e,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,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*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),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*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}},$=class{static{this.prototype.isVector3=!0}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 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 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(Nd.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Nd.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*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,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[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=cd(this.x,e.x,t.x),this.y=cd(this.y,e.y,t.y),this.z=cd(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=cd(this.x,e,t),this.y=cd(this.y,e,t),this.z=cd(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(cd(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,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,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 Md.copy(this).projectOnVector(e),this.sub(Md)}reflect(e){return this.sub(Md.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(cd(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}},Md=new $,Nd=new jd,Pd=class{static{this.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[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,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,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],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,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,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return $u(`Matrix3: .scale() is deprecated. Use .makeScale() instead.`),this.premultiply(Fd.makeScale(e,t)),this}rotate(e){return $u(`Matrix3: .rotate() is deprecated. Use .makeRotation() instead.`),this.premultiply(Fd.makeRotation(-e)),this}translate(e,t){return $u(`Matrix3: .translate() is deprecated. Use .makeTranslation() instead.`),this.premultiply(Fd.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 e=0;e<9;e++)if(t[e]!==n[e])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)}},Fd=new Pd,Id=new Pd().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ld=new Pd().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Rd(){let e={enabled:!0,workingColorSpace:Ru,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n||(this.spaces[t].transfer===`srgb`&&(e.r=Bd(e.r),e.g=Bd(e.g),e.b=Bd(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Vd(e.r),e.g=Vd(e.g),e.b=Vd(e.b))),e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?zu:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[n].fromXYZ).multiply(this.spaces[t].toXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Ru]:{primaries:t,whitePoint:r,transfer:zu,toXYZ:Id,fromXYZ:Ld,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Lu},outputColorSpaceConfig:{drawingBufferColorSpace:Lu}},[Lu]:{primaries:t,whitePoint:r,transfer:Bu,toXYZ:Id,fromXYZ:Ld,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Lu}}}),e}var zd=Rd();function Bd(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Vd(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Hd,Ud=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{Hd===void 0&&(Hd=Ku(`canvas`)),Hd.width=e.width,Hd.height=e.height;let t=Hd.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Hd}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=Ku(`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),i=r.data;for(let e=0;e<i.length;e++)i[e]=Bd(i[e]/255)*255;return n.putImageData(r,0,0),t}if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(Bd(t[e]/255)*255):t[e]=Bd(t[e]);return{data:t,width:e.width,height:e.height}}return Zu(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},Wd=0,Gd=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Wd++}),this.uuid=sd(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t===null?e.set(0,0,0):e.set(t.width||0,t.height||0,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(Kd(r[t].image)):e.push(Kd(r[t]))}else e=Kd(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function Kd(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?Ud.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(Zu(`Texture: Unable to serialize Texture.`),{})}var qd=0,Jd=new $,Yd=class e extends nd{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=gl,i=gl,a=xl,o=Cl,s=zl,c=wl,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:qd++}),this.uuid=sd(),this.name=``,this.source=new Gd(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new Q(0,0),this.repeat=new Q(1,1),this.center=new Q(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Pd,this.generateMipmaps=!0,this.mipmapsAutoUpdate=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.isPMREMTexture=!1,this.normalized=!1}get width(){return this.source.getSize(Jd).x}get height(){return this.source.getSize(Jd).y}get depth(){return this.source.getSize(Jd).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){Zu(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?Zu(`Texture.setValues(): property '${t}' does not exist.`):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!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case hl:e.x-=Math.floor(e.x);break;case gl:e.x=e.x<0?0:1;break;case _l:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case hl:e.y-=Math.floor(e.y);break;case gl:e.y=e.y<0?0:1;break;case _l:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y)}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++}};Yd.DEFAULT_IMAGE=null,Yd.DEFAULT_MAPPING=300,Yd.DEFAULT_ANISOTROPY=1;var Xd=class{static{this.prototype.isVector4=!0}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 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 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?1:e.w,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,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,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,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+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=cd(this.x,e.x,t.x),this.y=cd(this.y,e.y,t.y),this.z=cd(this.z,e.z,t.z),this.w=cd(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=cd(this.x,e,t),this.y=cd(this.y,e,t),this.z=cd(this.z,e,t),this.w=cd(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(cd(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}},Zd=class extends nd{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:xl,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 Xd(0,0,e,t),this.scissorTest=!1,this.viewport=new Xd(0,0,e,t),this.textures=[];let r=n.count;for(let i=0;i<r;i++)this.textures[i]=new Yd({width:e,height:t,depth:n.depth}),this.textures[i].isRenderTargetTexture=!0,this.textures[i].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:xl,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.mipmapsAutoUpdate!==void 0&&(t.mipmapsAutoUpdate=e.mipmapsAutoUpdate),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);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<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new Gd(n)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null){if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture}else this.depthTexture=null;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:`dispose`})}},Qd=class extends Zd{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},$d=class extends Yd{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=vl,this.minFilter=vl,this.wrapR=gl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},ef=class extends Yd{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=vl,this.minFilter=vl,this.wrapR=gl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}},tf=class e{static{this.prototype.isMatrix4=!0}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}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],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,r=1/nf.setFromMatrixColumn(e,0).length(),i=1/nf.setFromMatrixColumn(e,1).length(),a=1/nf.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(af,e,of)}lookAt(e,t,n){let r=this.elements;return lf.subVectors(e,t),lf.lengthSq()===0&&(lf.z=1),lf.normalize(),sf.crossVectors(n,lf),sf.lengthSq()===0&&(Math.abs(n.z)===1?lf.x+=1e-4:lf.z+=1e-4,lf.normalize(),sf.crossVectors(n,lf)),sf.normalize(),cf.crossVectors(lf,sf),r[0]=sf.x,r[4]=cf.x,r[8]=lf.x,r[1]=sf.y,r[5]=cf.y,r[9]=lf.y,r[2]=sf.z,r[6]=cf.z,r[10]=lf.z,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,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],N=r[3],P=r[7],F=r[11],I=r[15];return i[0]=a*x+o*T+s*k+c*N,i[4]=a*S+o*E+s*A+c*P,i[8]=a*C+o*D+s*j+c*F,i[12]=a*w+o*O+s*M+c*I,i[1]=l*x+u*T+d*k+f*N,i[5]=l*S+u*E+d*A+f*P,i[9]=l*C+u*D+d*j+f*F,i[13]=l*w+u*O+d*M+f*I,i[2]=p*x+m*T+h*k+g*N,i[6]=p*S+m*E+h*A+g*P,i[10]=p*C+m*D+h*j+g*F,i[14]=p*w+m*O+h*M+g*I,i[3]=_*x+v*T+y*k+b*N,i[7]=_*S+v*E+y*A+b*P,i[11]=_*C+v*D+y*j+b*F,i[15]=_*w+v*O+y*M+b*I,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[1],a=e[5],o=e[9],s=e[2],c=e[6],l=e[10];return t*(a*l-o*c)-n*(i*l-o*s)+r*(i*c-a*s)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinantAffine();if(i===0)return n.set(1,1,1),t.identity(),this;let a=nf.set(r[0],r[1],r[2]).length(),o=nf.set(r[4],r[5],r[6]).length(),s=nf.set(r[8],r[9],r[10]).length();i<0&&(a=-a),rf.copy(this);let c=1/a,l=1/o,u=1/s;return rf.elements[0]*=c,rf.elements[1]*=c,rf.elements[2]*=c,rf.elements[4]*=l,rf.elements[5]*=l,rf.elements[6]*=l,rf.elements[8]*=u,rf.elements[9]*=u,rf.elements[10]*=u,t.setFromRotationMatrix(rf),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=Uu,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Uu,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;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[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},nf=new $,rf=new tf,af=new $(0,0,0),of=new $(1,1,1),sf=new $,cf=new $,lf=new $,uf=new tf,df=new jd,ff=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}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 order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(cd(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-cd(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(cd(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-cd(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(cd(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-cd(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:Zu(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return uf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(uf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return df.setFromEuler(this),this.setFromQuaternion(df,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[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._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ff.DEFAULT_ORDER=`XYZ`;var pf=class{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return!!(this.mask&1<<e)}},mf=0,hf=new $,gf=new jd,_f=new tf,vf=new $,yf=new $,bf=new $,xf=new jd,Sf=new $(1,0,0),Cf=new $(0,1,0),wf=new $(0,0,1),Tf={type:`added`},Ef={type:`removed`},Df={type:`childadded`,child:null},Of={type:`childremoved`,child:null},kf=class e extends nd{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:mf++}),this.uuid=sd(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new $,n=new ff,r=new jd,i=new $(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new tf},normalMatrix:{value:new Pd}}),this.matrix=new tf,this.matrixWorld=new tf,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new pf,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale),this.pivot!==null&&this.position.copy(this.pivot).applyMatrix4(this.matrix).sub(this.pivot)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return gf.setFromAxisAngle(e,t),this.quaternion.multiply(gf),this}rotateOnWorldAxis(e,t){return gf.setFromAxisAngle(e,t),this.quaternion.premultiply(gf),this}rotateX(e){return this.rotateOnAxis(Sf,e)}rotateY(e){return this.rotateOnAxis(Cf,e)}rotateZ(e){return this.rotateOnAxis(wf,e)}translateOnAxis(e,t){return hf.copy(e).applyQuaternion(this.quaternion),this.position.add(hf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Sf,e)}translateY(e){return this.translateOnAxis(Cf,e)}translateZ(e){return this.translateOnAxis(wf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(_f.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?vf.copy(e):vf.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),yf.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?_f.lookAt(yf,vf,this.up):_f.lookAt(vf,yf,this.up),this.quaternion.setFromRotationMatrix(_f),r&&(_f.extractRotation(r.matrixWorld),gf.setFromRotationMatrix(_f),this.quaternion.premultiply(gf.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(Qu(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Tf),Df.child=e,this.dispatchEvent(Df),Df.child=null):Qu(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Ef),Of.child=e,this.dispatchEvent(Of),Of.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),_f.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),_f.multiply(e.parent.matrixWorld)),e.applyMatrix4(_f),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Tf),Df.child=e,this.dispatchEvent(Df),Df.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yf,e,bf),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yf,xf,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){return!0}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){let e=this.children;for(let t=0,r=e.length;t<r;t++)e[t].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,r.name=this.name,r.castShadow=this.castShadow,r.receiveShadow=this.receiveShadow,r.visible=this.visible,r.frustumCulled=this.frustumCulled,r.renderOrder=this.renderOrder,r.static=this.static,r.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(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(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),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 i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.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=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0){if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material)}if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}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?null:e.pivot.clone(),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 t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}dispose(){this.dispatchEvent({type:`dispose`})}};kf.DEFAULT_UP=new $(0,1,0),kf.DEFAULT_MATRIX_AUTO_UPDATE=!0,kf.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Af=class extends kf{constructor(){super(),this.isGroup=!0,this.type=`Group`}},jf={type:`move`},Mf=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Af,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Af,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new $,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new $),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Af,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new $,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new $,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(jf)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Af;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Nf={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},Pf={h:0,s:0,l:0},Ff={h:0,s:0,l:0};function If(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var Lf=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 t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Lu){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,zd.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=zd.workingColorSpace){return this.r=e,this.g=t,this.b=n,zd.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=zd.workingColorSpace){if(e=ld(e,1),t=cd(t,0,1),n=cd(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=If(i,r,e+1/3),this.g=If(i,r,e),this.b=If(i,r,e-1/3)}return zd.colorSpaceToWorking(this,r),this}setStyle(e,t=Lu){function n(t){t!==void 0&&parseFloat(t)<1&&Zu(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseFloat(i[1]))/100,Math.min(100,parseFloat(i[2]))/100,Math.min(100,parseFloat(i[3]))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:Zu(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);Zu(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Lu){let n=Nf[e.toLowerCase()];return n===void 0?Zu(`Color: Unknown color `+e):this.setHex(n,t),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=Bd(e.r),this.g=Bd(e.g),this.b=Bd(e.b),this}copyLinearToSRGB(e){return this.r=Vd(e.r),this.g=Vd(e.g),this.b=Vd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Lu){return zd.workingToColorSpace(Rf.copy(this),e),Math.round(cd(Rf.r*255,0,255))*65536+Math.round(cd(Rf.g*255,0,255))*256+Math.round(cd(Rf.b*255,0,255))}getHexString(e=Lu){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=zd.workingColorSpace){zd.workingToColorSpace(Rf.copy(this),t);let n=Rf.r,r=Rf.g,i=Rf.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=zd.workingColorSpace){return zd.workingToColorSpace(Rf.copy(this),t),e.r=Rf.r,e.g=Rf.g,e.b=Rf.b,e}getStyle(e=Lu){zd.workingToColorSpace(Rf.copy(this),e);let t=Rf.r,n=Rf.g,r=Rf.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(Pf),this.setHSL(Pf.h+e,Pf.s+t,Pf.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Pf),e.getHSL(Ff);let n=fd(Pf.h,Ff.h,t),r=fd(Pf.s,Ff.s,t),i=fd(Pf.l,Ff.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Rf=new Lf;Lf.NAMES=Nf;var zf=class extends kf{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ff,this.environmentIntensity=1,this.environmentRotation=new ff,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),this.background=e.background===null?null:e.background.clone(),this.environment=e.environment===null?null:e.environment.clone(),this.fog=e.fog===null?null:e.fog.clone(),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),this.overrideMaterial=e.overrideMaterial===null?null:e.overrideMaterial.clone(),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},Bf=new $,Vf=new $,Hf=new $,Uf=new $,Wf=new $,Gf=new $,Kf=new $,qf=new $,Jf=new $,Yf=new $,Xf=new Xd,Zf=new Xd,Qf=new Xd,$f=class e{constructor(e=new $,t=new $,n=new $){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Bf.subVectors(e,t),r.cross(Bf);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Bf.subVectors(r,t),Vf.subVectors(n,t),Hf.subVectors(e,t);let a=Bf.dot(Bf),o=Bf.dot(Vf),s=Bf.dot(Hf),c=Vf.dot(Vf),l=Vf.dot(Hf),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Uf)!==null&&Uf.x>=0&&Uf.y>=0&&Uf.x+Uf.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Uf)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Uf.x),s.addScaledVector(a,Uf.y),s.addScaledVector(o,Uf.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Xf.setScalar(0),Zf.setScalar(0),Qf.setScalar(0),Xf.fromBufferAttribute(e,t),Zf.fromBufferAttribute(e,n),Qf.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Xf,i.x),a.addScaledVector(Zf,i.y),a.addScaledVector(Qf,i.z),a}static isFrontFacing(e,t,n,r){return Bf.subVectors(n,t),Vf.subVectors(e,t),Bf.cross(Vf).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 Bf.subVectors(this.c,this.b),Vf.subVectors(this.a,this.b),Bf.cross(Vf).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Wf.subVectors(r,n),Gf.subVectors(i,n),qf.subVectors(e,n);let s=Wf.dot(qf),c=Gf.dot(qf);if(s<=0&&c<=0)return t.copy(n);Jf.subVectors(e,r);let l=Wf.dot(Jf),u=Gf.dot(Jf);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0&&s-l>0)return a=s/(s-l),t.copy(n).addScaledVector(Wf,a);Yf.subVectors(e,i);let f=Wf.dot(Yf),p=Gf.dot(Yf);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Gf,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Kf.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Kf,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Wf,a).addScaledVector(Gf,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},ep=class{constructor(e=new $(1/0,1/0,1/0),t=new $(-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<n;t+=3)this.expandByPoint(np.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(np.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=np.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0&&e.isBatchedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,np):np.fromBufferAttribute(r,t),np.applyMatrix4(e.matrixWorld),this.expandByPoint(np);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),rp.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),rp.copy(e.boundingBox)),rp.applyMatrix4(e.matrixWorld),this.union(rp)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=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,np),np.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(up),dp.subVectors(this.max,up),ip.subVectors(e.a,up),ap.subVectors(e.b,up),op.subVectors(e.c,up),sp.subVectors(ap,ip),cp.subVectors(op,ap),lp.subVectors(ip,op);let t=[0,-sp.z,sp.y,0,-cp.z,cp.y,0,-lp.z,lp.y,sp.z,0,-sp.x,cp.z,0,-cp.x,lp.z,0,-lp.x,-sp.y,sp.x,0,-cp.y,cp.x,0,-lp.y,lp.x,0];return!mp(t,ip,ap,op,dp)||(t=[1,0,0,0,1,0,0,0,1],!mp(t,ip,ap,op,dp))?!1:(fp.crossVectors(sp,cp),t=[fp.x,fp.y,fp.z],mp(t,ip,ap,op,dp))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,np).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(np).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()||(tp[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),tp[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),tp[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),tp[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),tp[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),tp[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),tp[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),tp[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(tp)),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}},tp=[new $,new $,new $,new $,new $,new $,new $,new $],np=new $,rp=new ep,ip=new $,ap=new $,op=new $,sp=new $,cp=new $,lp=new $,up=new $,dp=new $,fp=new $,pp=new $;function mp(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){pp.fromArray(e,a);let o=i.x*Math.abs(pp.x)+i.y*Math.abs(pp.y)+i.z*Math.abs(pp.z),s=t.dot(pp),c=n.dot(pp),l=r.dot(pp);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var hp=gp();function gp(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[e|256]=32768,i[e]=24,i[e|256]=24):t<-14?(r[e]=1024>>-t-14,r[e|256]=1024>>-t-14|32768,i[e]=-t-1,i[e|256]=-t-1):t<=15?(r[e]=t+15<<10,r[e|256]=t+15<<10|32768,i[e]=13,i[e|256]=13):t<128?(r[e]=31744,r[e|256]=64512,i[e]=24,i[e|256]=24):(r[e]=31744,r[e|256]=64512,i[e]=13,i[e|256]=13)}let a=new Uint32Array(2048),o=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(t&8388608);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:a,exponentTable:o,offsetTable:s}}function _p(e){Math.abs(e)>65504&&Zu(`DataUtils.toHalfFloat(): Value out of range.`),e=cd(e,-65504,65504),hp.floatView[0]=e;let t=hp.uint32View[0],n=t>>23&511;return hp.baseTable[n]+((t&8388607)>>hp.shiftTable[n])}function vp(e){let t=e>>10;return hp.uint32View[0]=hp.mantissaTable[hp.offsetTable[t]+(e&1023)]+hp.exponentTable[t],hp.floatView[0]}var yp=class{static toHalfFloat(e){return _p(e)}static fromHalfFloat(e){return vp(e)}},bp=new $,xp=new Q,Sp=0,Cp=class extends nd{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Sp++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Hu,this.updateRanges=[],this.gpuType=Al,this.version=0,this._normalizationScale=e===void 0?void 0:Dd(e)}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,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)xp.fromBufferAttribute(this,t),xp.applyMatrix3(e),this.setXY(t,xp.x,xp.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)bp.fromBufferAttribute(this,t),bp.applyMatrix3(e),this.setXYZ(t,bp.x,bp.y,bp.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)bp.fromBufferAttribute(this,t),bp.applyMatrix4(e),this.setXYZ(t,bp.x,bp.y,bp.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)bp.fromBufferAttribute(this,t),bp.applyNormalMatrix(e),this.setXYZ(t,bp.x,bp.y,bp.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)bp.fromBufferAttribute(this,t),bp.transformDirection(e),this.setXYZ(t,bp.x,bp.y,bp.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=this._denormalize(t)),t}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=this._denormalize(t)),t}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=this._denormalize(t)),t}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=this._denormalize(t)),t}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r),i=this._normalize(i)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:`dispose`})}_denormalize(e){let t=this._normalizationScale;return t===void 0?Od(e,this.array):Math.max(e/t,-1)}_normalize(e){let t=this._normalizationScale;return t===void 0?kd(e,this.array):Math.round(e*t)}},wp=class extends Cp{constructor(e,t,n){super(new Uint16Array(e),t,n)}},Tp=class extends Cp{constructor(e,t,n){super(new Uint32Array(e),t,n)}},Ep=class extends Cp{constructor(e,t,n){super(new Float32Array(e),t,n)}},Dp=new ep,Op=new $,kp=new $,Ap=class{constructor(e=new $,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?Dp.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.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*=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;Op.subVectors(e,this.center);let t=Op.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(Op,n/e),this.radius+=n}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):(kp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Op.copy(e.center).add(kp)),this.expandByPoint(Op.copy(e.center).sub(kp))),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}},jp=0,Mp=new tf,Np=new kf,Pp=new $,Fp=new ep,Ip=new ep,Lp=new $,Rp=class e extends nd{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:jp++}),this.uuid=sd(),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 this.index=Array.isArray(e)?new(Wu(e)?Tp:wp)(e,1):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 t=new Pd().getNormalMatrix(e);n.applyNormalMatrix(t),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 Mp.makeRotationFromQuaternion(e),this.applyMatrix4(Mp),this}rotateX(e){return Mp.makeRotationX(e),this.applyMatrix4(Mp),this}rotateY(e){return Mp.makeRotationY(e),this.applyMatrix4(Mp),this}rotateZ(e){return Mp.makeRotationZ(e),this.applyMatrix4(Mp),this}translate(e,t,n){return Mp.makeTranslation(e,t,n),this.applyMatrix4(Mp),this}scale(e,t,n){return Mp.makeScale(e,t,n),this.applyMatrix4(Mp),this}lookAt(e){return Np.lookAt(e),Np.updateMatrix(),this.applyMatrix4(Np.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Pp).negate(),this.translate(Pp.x,Pp.y,Pp.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new Ep(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&Zu(`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 ep);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)Qu(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new $(-1/0,-1/0,-1/0),new $(1/0,1/0,1/0));else{if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Fp.setFromBufferAttribute(n),this.morphTargetsRelative?(Lp.addVectors(this.boundingBox.min,Fp.min),this.boundingBox.expandByPoint(Lp),Lp.addVectors(this.boundingBox.max,Fp.max),this.boundingBox.expandByPoint(Lp)):(this.boundingBox.expandByPoint(Fp.min),this.boundingBox.expandByPoint(Fp.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Qu(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ap);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)Qu(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new $,1/0);else if(e){let n=this.boundingSphere.center;if(Fp.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Ip.setFromBufferAttribute(n),this.morphTargetsRelative?(Lp.addVectors(Fp.min,Ip.min),Fp.expandByPoint(Lp),Lp.addVectors(Fp.max,Ip.max),Fp.expandByPoint(Lp)):(Fp.expandByPoint(Ip.min),Fp.expandByPoint(Ip.max))}Fp.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Lp.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Lp));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Lp.fromBufferAttribute(a,t),o&&(Pp.fromBufferAttribute(e,t),Lp.add(Pp)),r=Math.max(r,n.distanceToSquared(Lp))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Qu(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Qu(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv,a=this.getAttribute(`tangent`);(a===void 0||a.count!==n.count)&&(a=new Cp(new Float32Array(4*n.count),4),this.setAttribute(`tangent`,a));let o=[],s=[],c=new Uint8Array(n.count);for(let e=0;e<n.count;e++)o[e]=new $,s[e]=new $;let l=new $,u=new $,d=new $,f=new Q,p=new Q,m=new Q,h=new $,g=new $;function _(e,t,r){c[e]=c[t]=c[r]=1,l.fromBufferAttribute(n,e),u.fromBufferAttribute(n,t),d.fromBufferAttribute(n,r),f.fromBufferAttribute(i,e),p.fromBufferAttribute(i,t),m.fromBufferAttribute(i,r),u.sub(l),d.sub(l),p.sub(f),m.sub(f);let a=1/(p.x*m.y-m.x*p.y);isFinite(a)&&(h.copy(u).multiplyScalar(m.y).addScaledVector(d,-p.y).multiplyScalar(a),g.copy(d).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(a),o[e].add(h),o[t].add(h),o[r].add(h),s[e].add(g),s[t].add(g),s[r].add(g))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let t=0,n=v.length;t<n;++t){let n=v[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)_(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let y=new $,b=new $,x=new $,S=new $;function C(e){x.fromBufferAttribute(r,e),S.copy(x);let t=o[e];y.copy(t),y.sub(x.multiplyScalar(x.dot(t))).normalize(),b.crossVectors(S,t);let n=b.dot(s[e])<0?-1:1;a.setXYZW(e,y.x,y.y,y.z,n)}for(let e=0,t=n.count;e<t;++e)c[e]&&C(e);this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0||n.count!==t.count)n=new Cp(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new $,i=new $,a=new $,o=new $,s=new $,c=new $,l=new $,u=new $;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Lp.fromBufferAttribute(e,t),Lp.normalize(),e.setXYZ(t,Lp.x,Lp.y,Lp.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new Cp(a,r,i)}if(this.index===null)return Zu(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?`BufferGeometry`:this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);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 t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.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 e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:`dispose`})}},zp=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=Hu,this.updateRanges=[],this.version=0,this.uuid=sd()}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.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={});let t=Bp(this.array);e.arrayBuffers[t]===void 0&&(e.arrayBuffers[t]=this.array.slice(0).buffer);let n=new this.array.constructor(e.arrayBuffers[t]),r=new this.constructor(n,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){e.arrayBuffers===void 0&&(e.arrayBuffers={});let t=Bp(this.array);e.arrayBuffers[t]===void 0&&(e.arrayBuffers[t]=Array.from(new Uint32Array(this.array.slice(0).buffer)));let n={uuid:this.uuid,buffer:t,type:this.array.constructor.name,stride:this.stride};return n.usage=this.usage,n}};function Bp(e){return e.buffer._uuid===void 0&&(e.buffer._uuid=sd()),e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer._uuid:e.buffer._uuid+`:`+e.byteOffset+`:`+e.byteLength}var Vp=new $,Hp=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r,this._normalizationScale=e===void 0?void 0:Dd(e.array)}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Vp.fromBufferAttribute(this,t),Vp.applyMatrix4(e),this.setXYZ(t,Vp.x,Vp.y,Vp.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Vp.fromBufferAttribute(this,t),Vp.applyNormalMatrix(e),this.setXYZ(t,Vp.x,Vp.y,Vp.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Vp.fromBufferAttribute(this,t),Vp.transformDirection(e),this.setXYZ(t,Vp.x,Vp.y,Vp.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=this._denormalize(t)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=this._denormalize(t)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=this._denormalize(t)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=this._denormalize(t)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r),i=this._normalize(i)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){Yu(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new Cp(new this.array.constructor(e),this.itemSize,this.normalized)}return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Yu(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}_denormalize(e){let t=this._normalizationScale;return t===void 0?Od(e,this.data.array):Math.max(e/t,-1)}_normalize(e){let t=this._normalizationScale;return t===void 0?kd(e,this.data.array):Math.round(e*t)}},Up=new $,Wp=new $,Gp=new Pd,Kp=class{constructor(e=new $(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=Up.subVectors(n,t).cross(Wp.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let r=e.delta(Up),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/i;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}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||Gp.getNormalMatrix(e),r=this.coplanarPoint(Up).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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}},qp=0,Jp=class extends nd{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:qp++}),this.uuid=sd(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Lf(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Vu,this.stencilZFail=Vu,this.stencilZPass=Vu,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){Zu(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?Zu(`Material: '${t}' is not a property of THREE.${this.type}.`):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(e=>e.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(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}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 Lf().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(e=>new Kp().fromJSON(e))),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&&(this.vertexColors=typeof e.vertexColors==`number`?e.vertexColors>0: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 t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),this.normalScale=new Q().fromArray(t)}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 Q().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 e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].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++}},Yp=class extends Jp{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new Lf(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}},Xp,Zp=new $,Qp=new $,$p=new $,em=new Q,tm=new Q,nm=new tf,rm=new $,im=new $,am=new $,om=new Q,sm=new Q,cm=new Q,lm=class extends kf{constructor(e=new Yp){if(super(),this.isSprite=!0,this.type=`Sprite`,Xp===void 0){Xp=new Rp;let e=new zp(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Xp.setIndex([0,1,2,0,2,3]),Xp.setAttribute(`position`,new Hp(e,3,0,!1)),Xp.setAttribute(`uv`,new Hp(e,2,3,!1))}this.geometry=Xp,this.material=e,this.center=new Q(.5,.5),this.count=1}intersectsFrustum(e){return e.intersectsSprite(this)}raycast(e,t){e.camera===null&&Qu(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),Qp.setFromMatrixScale(this.matrixWorld),nm.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),$p.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Qp.multiplyScalar(-$p.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;um(rm.set(-.5,-.5,0),$p,a,Qp,r,i),um(im.set(.5,-.5,0),$p,a,Qp,r,i),um(am.set(.5,.5,0),$p,a,Qp,r,i),om.set(0,0),sm.set(1,0),cm.set(1,1);let o=e.ray.intersectTriangle(rm,im,am,!1,Zp);if(o===null&&(um(im.set(-.5,.5,0),$p,a,Qp,r,i),sm.set(0,1),o=e.ray.intersectTriangle(rm,am,im,!1,Zp),o===null))return;let s=e.ray.origin.distanceTo(Zp);s<e.near||s>e.far||t.push({distance:s,point:Zp.clone(),uv:$f.getInterpolation(Zp,rm,im,am,om,sm,cm,new Q),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 um(e,t,n,r,i,a){em.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?tm.copy(em):(tm.x=a*em.x-i*em.y,tm.y=i*em.x+a*em.y),e.copy(t),e.x+=tm.x,e.y+=tm.y,e.applyMatrix4(nm)}var dm=new $,fm=new $,pm=new $,mm=new $,hm=class{constructor(e=new $,t=new $(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,dm)),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=dm.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(dm.copy(this.origin).addScaledVector(this.direction,t),dm.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){fm.copy(e).add(t).multiplyScalar(.5),pm.copy(t).sub(e).normalize(),mm.copy(this.origin).sub(fm);let i=e.distanceTo(t)*.5,a=-this.direction.dot(pm),o=mm.dot(this.direction),s=-mm.dot(pm),c=mm.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0){if(u=a*s-o,d=a*o-s,p=i*l,u>=0){if(d>=-p){if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c)}else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(fm).addScaledVector(pm,d),f}intersectSphere(e,t){if(e.radius<0)return null;dm.subVectors(e.center,this.origin);let n=dm.dot(this.direction),r=dm.dot(dm)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,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,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,dm)!==null}intersectTriangle(e,t,n,r,i){let a=this.origin,o=this.direction,s=o.x,c=o.y,l=o.z,u=e.x-a.x,d=e.y-a.y,f=e.z-a.z,p=t.x-a.x,m=t.y-a.y,h=t.z-a.z,g=n.x-a.x,_=n.y-a.y,v=n.z-a.z,y=Math.abs(s),b=Math.abs(c),x=Math.abs(l),S,C,w,T,E,D,O,k,A,j,M,N;if(y>=b&&y>=x?(w=s,D=u,A=p,N=g,s>=0?(S=c,C=l,T=d,E=f,O=m,k=h,j=_,M=v):(S=l,C=c,T=f,E=d,O=h,k=m,j=v,M=_)):b>=x?(w=c,D=d,A=m,N=_,c>=0?(S=l,C=s,T=f,E=u,O=h,k=p,j=v,M=g):(S=s,C=l,T=u,E=f,O=p,k=h,j=g,M=v)):(w=l,D=f,A=h,N=v,l>=0?(S=s,C=c,T=u,E=d,O=p,k=m,j=g,M=_):(S=c,C=s,T=d,E=u,O=m,k=p,j=_,M=g)),w===0)return null;let P=S/w,F=C/w,I=1/w,ee=T-P*D,te=E-F*D,L=O-P*A,R=k-F*A,z=j-P*N,B=M-F*N,ne=z*R-B*L,re=ee*B-te*z,ie=L*te-R*ee;if(r){if(ne<0||re<0||ie<0)return null}else if((ne<0||re<0||ie<0)&&(ne>0||re>0||ie>0))return null;let ae=ne+re+ie;if(ae===0)return null;let V=I*(ne*D+re*A+ie*N);return(ae>0?V<0:V>0)?null:this.at(V/ae,i)}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)}},gm=class extends Jp{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new Lf(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 ff,this.combine=0,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}},_m=new tf,vm=new hm,ym=new Ap,bm=new $,xm=new $,Sm=new $,Cm=new $,wm=new $,Tm=new $,Em=new $,Dm=new $,Om=class extends kf{constructor(e=new Rp,t=new gm){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),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Tm.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(wm.fromBufferAttribute(s,e),a?Tm.addScaledVector(wm,r):Tm.addScaledVector(wm.sub(t),r))}t.add(Tm)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ym.copy(n.boundingSphere),ym.applyMatrix4(i),vm.copy(e.ray).recast(e.near),!(ym.containsPoint(vm.origin)===!1&&(vm.intersectSphere(ym,bm)===null||vm.origin.distanceToSquared(bm)>(e.far-e.near)**2))&&(_m.copy(i).invert(),vm.copy(e.ray).applyMatrix4(_m),(n.boundingBox===null||vm.intersectsBox(n.boundingBox)!==!1)&&this._computeIntersections(e,t,vm)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null){if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Am(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Am(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}}else if(s!==void 0){if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Am(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Am(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}}};function km(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;Dm.copy(s),Dm.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Dm);return l<n.near||l>n.far?null:{distance:l,point:Dm.clone(),object:e}}function Am(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,xm),e.getVertexPosition(c,Sm),e.getVertexPosition(l,Cm);let u=km(e,t,n,r,xm,Sm,Cm,Em);if(u){let e=new $;$f.getBarycoord(Em,xm,Sm,Cm,e),i&&(u.uv=$f.getInterpolatedAttribute(i,s,c,l,e,new Q)),a&&(u.uv1=$f.getInterpolatedAttribute(a,s,c,l,e,new Q)),o&&(u.normal=$f.getInterpolatedAttribute(o,s,c,l,e,new $),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new $,materialIndex:0};$f.getNormal(xm,Sm,Cm,t.normal),u.face=t,u.barycoord=e}return u}var jm=class extends Yd{constructor(e=null,t=1,n=1,r,i,a,o,s,c=vl,l=vl,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Mm=new Ap,Nm=new Q(.5,.5),Pm=new $,Fm=class{constructor(e=new Kp,t=new Kp,n=new Kp,r=new Kp,i=new Kp,a=new Kp){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Uu,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Mm.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Mm.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Mm)}intersectsSprite(e){return Mm.center.set(0,0,0),Mm.radius=.7071067811865476+Nm.distanceTo(e.center),Mm.applyMatrix4(e.matrixWorld),this.intersectsSphere(Mm)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(Pm.x=r.normal.x>0?e.max.x:e.min.x,Pm.y=r.normal.y>0?e.max.y:e.min.y,Pm.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Pm)<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)}},Im=new tf,Lm=class e{constructor(){this.coordinateSystem=Uu,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let e=0;e<t.length;e++){let r=t[e];Im.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),n[e]===void 0&&(n[e]=new Fm),n[e].setFromProjectionMatrix(Im,r.coordinateSystem,r.reversedDepth)}return this._count=t.length,this}getFrustum(e){return this._frustums[e]}intersectsObject(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,n=e._frustums;for(let r=0;r<e._count;r++)t[r]===void 0&&(t[r]=new Fm),t[r].copy(n[r]);return this._count=e._count,this}clone(){return new e().copy(this)}},Rm=class extends Jp{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new Lf(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},zm=new $,Bm=new $,Vm=new tf,Hm=new hm,Um=new Ap,Wm=new $,Gm=new $,Km=class extends kf{constructor(e=new Rp,t=new Rm){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)zm.fromBufferAttribute(t,e-1),Bm.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=zm.distanceTo(Bm);e.setAttribute(`lineDistance`,new Ep(n,1))}else Zu(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Um.copy(n.boundingSphere),Um.applyMatrix4(r),Um.radius+=i,e.ray.intersectsSphere(Um)===!1)return;Vm.copy(r).invert(),Hm.copy(e.ray).applyMatrix4(Vm);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=qm(this,e,Hm,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=qm(this,e,Hm,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=qm(this,e,Hm,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=qm(this,e,Hm,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function qm(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(zm.fromBufferAttribute(s,i),Bm.fromBufferAttribute(s,a),n.distanceSqToSegment(zm,Bm,Wm,Gm)>r)return;Wm.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(Wm);if(!(c<t.near||c>t.far))return{distance:c,point:Gm.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Jm=class extends Jp{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new Lf(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!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.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Ym=new tf,Xm=new hm,Zm=new Ap,Qm=new $,$m=class extends kf{constructor(e=new Rp,t=new Jm){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Zm.copy(n.boundingSphere),Zm.applyMatrix4(r),Zm.radius+=i,e.ray.intersectsSphere(Zm)===!1)return;Ym.copy(r).invert(),Xm.copy(e.ray).applyMatrix4(Ym);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);Qm.fromBufferAttribute(l,n),eh(Qm,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)Qm.fromBufferAttribute(l,a),eh(Qm,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function eh(e,t,n,r,i,a,o){let s=Xm.distanceSqToPoint(e);if(s<n){let n=new $;Xm.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var th=class extends Yd{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},nh=class extends Yd{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},rh=class extends Yd{constructor(e,t,n=kl,r,i,a,o=vl,s=vl,c,l=Bl,u=1){if(l!==1026&&l!==1027)throw Error(`THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Gd(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},ih=class extends rh{constructor(e,t=kl,n=301,r,i,a=vl,o=vl,s,c=Bl){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},ah=class extends Yd{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},oh=class e extends Rp{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new Ep(c,3)),this.setAttribute(`normal`,new Ep(l,3)),this.setAttribute(`uv`,new Ep(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new $;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},sh=class e extends Rp{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new Ep(u,3)),this.setAttribute(`normal`,new Ep(d,3)),this.setAttribute(`uv`,new Ep(f,2));function _(){let a=new $,_=new $,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new Q,m=new $,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ch=new $,lh=new $,uh=new $,dh=new $f,fh=class extends Rp{constructor(e=null,t=1){if(super(),this.type=`EdgesGeometry`,this.parameters={geometry:e,thresholdAngle:t},e!==null){let n=1e4,r=Math.cos(ad*t),i=e.getIndex(),a=e.getAttribute(`position`),o=i?i.count:a.count,s=[0,0,0],c=[`a`,`b`,`c`],l=[,,,],u=new Map,d=[];for(let e=0;e<o;e+=3){i?(s[0]=i.getX(e),s[1]=i.getX(e+1),s[2]=i.getX(e+2)):(s[0]=e,s[1]=e+1,s[2]=e+2);let{a:t,b:o,c:f}=dh;if(t.fromBufferAttribute(a,s[0]),o.fromBufferAttribute(a,s[1]),f.fromBufferAttribute(a,s[2]),dh.getNormal(uh),l[0]=`${Math.round(t.x*n)},${Math.round(t.y*n)},${Math.round(t.z*n)}`,l[1]=`${Math.round(o.x*n)},${Math.round(o.y*n)},${Math.round(o.z*n)}`,l[2]=`${Math.round(f.x*n)},${Math.round(f.y*n)},${Math.round(f.z*n)}`,l[0]!==l[1]&&l[1]!==l[2]&&l[2]!==l[0])for(let e=0;e<3;e++){let t=(e+1)%3,n=l[e],i=l[t],a=dh[c[e]],o=dh[c[t]],f=`${n}_${i}`,p=`${i}_${n}`,m=u.get(p);m?(uh.dot(m.normal)<=r&&(d.push(a.x,a.y,a.z),d.push(o.x,o.y,o.z)),u.set(p,null)):u.has(f)||u.set(f,{index0:s[e],index1:s[t],normal:uh.clone()})}}for(let e of u.values())if(e){let{index0:t,index1:n}=e;ch.fromBufferAttribute(a,t),lh.fromBufferAttribute(a,n),d.push(ch.x,ch.y,ch.z),d.push(lh.x,lh.y,lh.z)}this.setAttribute(`position`,new Ep(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},ph=class e extends Rp{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new Ep(p,3)),this.setAttribute(`normal`,new Ep(m,3)),this.setAttribute(`uv`,new Ep(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},mh=class extends Rp{constructor(e=null){if(super(),this.type=`WireframeGeometry`,this.parameters={geometry:e},e!==null){let t=[],n=new Set,r=new $,i=new $;if(e.index!==null){let a=e.attributes.position,o=e.index,s=e.groups;s.length===0&&(s=[{start:0,count:o.count,materialIndex:0}]);for(let e=0,c=s.length;e<c;++e){let c=s[e],l=c.start,u=c.count;for(let e=l,s=l+u;e<s;e+=3)for(let s=0;s<3;s++){let c=o.getX(e+s),l=o.getX(e+(s+1)%3);r.fromBufferAttribute(a,c),i.fromBufferAttribute(a,l),hh(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}}else{let a=e.attributes.position;for(let e=0,o=a.count/3;e<o;e++)for(let o=0;o<3;o++){let s=3*e+o,c=3*e+(o+1)%3;r.fromBufferAttribute(a,s),i.fromBufferAttribute(a,c),hh(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}this.setAttribute(`position`,new Ep(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};function hh(e,t,n){let r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}function gh(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];if(vh(i))i.isRenderTargetTexture?(Zu(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone();else if(Array.isArray(i)){if(vh(i[0])){let e=[];for(let t=0,n=i.length;t<n;t++)e[t]=i[t].clone();t[n][r]=e}else t[n][r]=i.slice()}else t[n][r]=i}}return t}function _h(e){let t={};for(let n=0;n<e.length;n++){let r=gh(e[n]);for(let e in r)t[e]=r[e]}return t}function vh(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function yh(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function bh(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:zd.workingColorSpace}var xh={clone:gh,merge:_h},Sh=`void main() {
|
|
7
|
+
${C(s)??``}`},children:(e,r)=>{var o=u(),s=z(o),c=e=>{var t=Qc(),n=z(t);_t(n,{class:`h-4 w-4 animate-spin`});var r=U(n),a=U(r);G(()=>{m(r,` ${C(i).solvingEllipsis??``} `),H(a,`title`,C(i).solveMessagesEscHint)}),O(e,t)},l=e=>{var t=$c(),n=z(t);gt(n,{class:`h-4 w-4`});var r=U(n);G(()=>m(r,` ${C(i).pressToCalculate??``}`)),O(e,t)},d=e=>{var t=$c(),n=z(t);Wr(n,{class:`h-4 w-4`});var r=U(n);G(()=>m(r,` ${C(i).calculate??``}`)),O(e,t)},f=e=>{var t=el(),n=U(z(t));G(()=>m(n,` ${C(i).upToDate??``}`)),O(e,t)};t(s,e=>{n.isSolving?e(c):a()?e(l,1):n.hasPendingChanges?e(d,2):e(f,-1)}),O(e,o)},$$slots:{default:!0}})}var _=U(g,2);x(_,()=>n.trailing??h),c(p),c(l),G(()=>m(f,C(o))),O(e,l),b()}var rl={FILE_UPLOAD:{MAX_SIZE_MB:300,MAX_SIZE_BYTES:314572800},TIMEOUTS:{SOLVE_STATE_DURATION:3500,DRAWER_ANIMATION_MS:350},SOLVING_INDICATOR:{SHOW_AFTER_MS:400,MIN_VISIBLE_MS:500,SLOW_AFTER_MS:2e3},FILE_SIZE:{BYTES_PER_KB:1024}},il=new Set;function al(e){return e?!il.has(e):!1}var ol=new WeakSet;function sl(e){ol.add(e)}function cl(e){ol.delete(e)}function ll(e){return ol.has(e)}var ul=new WeakMap;function dl(e,t){ul.set(e,t)}function fl(e){if(ol.has(e))return e;let t=ul.get(e);return t&&ol.has(t)?t:null}var pl={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ml={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},hl=1e3,gl=1001,_l=1002,vl=1003,yl=1004,bl=1005,xl=1006,Sl=1007,Cl=1008,wl=1009,Tl=1010,El=1011,Dl=1012,Ol=1013,kl=1014,Al=1015,jl=1016,Ml=1017,Nl=1018,Pl=1020,Fl=35902,Il=35899,Ll=1021,Rl=1022,zl=1023,Bl=1026,Vl=1027,Hl=1028,Ul=1029,Wl=1030,Gl=1031,Kl=1033,ql=33776,Jl=33777,Yl=33778,Xl=33779,Zl=35840,Ql=35841,$l=35842,eu=35843,tu=36196,nu=37492,ru=37496,iu=37488,au=37489,ou=37490,su=37491,cu=37808,lu=37809,uu=37810,du=37811,fu=37812,pu=37813,mu=37814,hu=37815,gu=37816,_u=37817,vu=37818,yu=37819,bu=37820,xu=37821,Su=36492,Cu=36494,wu=36495,Tu=36283,Eu=36284,Du=36285,Ou=36286,ku=2300,Au=2301,ju=2302,Mu=2303,Nu=2400,Pu=2401,Fu=2402,Iu=3200,Lu=`srgb`,Ru=`srgb-linear`,zu=`linear`,Bu=`srgb`,Vu=7680,Hu=35044,Uu=2e3;function Wu(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Gu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ku(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function qu(){let e=Ku(`canvas`);return e.style.display=`block`,e}var Ju={};function Yu(...e){let t=`THREE.`+e.shift();console.log(t,...e)}function Xu(e){let t=e[0];if(typeof t==`string`&&t.startsWith(`TSL:`)){let t=e[1];t&&t.isStackTrace?e[0]+=` `+t.getLocation():e[1]=`Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.`}return e}function Zu(...e){e=Xu(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.warn(n.getError(t)):console.warn(t,...e)}}function Qu(...e){e=Xu(e);let t=`THREE.`+e.shift();{let n=e[0];n&&n.isStackTrace?console.error(n.getError(t)):console.error(t,...e)}}function $u(...e){let t=e.join(` `);t in Ju||(Ju[t]=!0,Zu(...e))}function ed(e,t,n){return new Promise(function(r,i){function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:i();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}var td={0:0,2:6,4:4,3:5,1:1,6:2,7:7,5:3},nd=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&&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 e=r.indexOf(t);e!==-1&&r.splice(e,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 t=n.slice(0);for(let n=0,r=t.length;n<r;n++)t[n].call(this,e);e.target=null}}},rd=`00.01.02.03.04.05.06.07.08.09.0a.0b.0c.0d.0e.0f.10.11.12.13.14.15.16.17.18.19.1a.1b.1c.1d.1e.1f.20.21.22.23.24.25.26.27.28.29.2a.2b.2c.2d.2e.2f.30.31.32.33.34.35.36.37.38.39.3a.3b.3c.3d.3e.3f.40.41.42.43.44.45.46.47.48.49.4a.4b.4c.4d.4e.4f.50.51.52.53.54.55.56.57.58.59.5a.5b.5c.5d.5e.5f.60.61.62.63.64.65.66.67.68.69.6a.6b.6c.6d.6e.6f.70.71.72.73.74.75.76.77.78.79.7a.7b.7c.7d.7e.7f.80.81.82.83.84.85.86.87.88.89.8a.8b.8c.8d.8e.8f.90.91.92.93.94.95.96.97.98.99.9a.9b.9c.9d.9e.9f.a0.a1.a2.a3.a4.a5.a6.a7.a8.a9.aa.ab.ac.ad.ae.af.b0.b1.b2.b3.b4.b5.b6.b7.b8.b9.ba.bb.bc.bd.be.bf.c0.c1.c2.c3.c4.c5.c6.c7.c8.c9.ca.cb.cc.cd.ce.cf.d0.d1.d2.d3.d4.d5.d6.d7.d8.d9.da.db.dc.dd.de.df.e0.e1.e2.e3.e4.e5.e6.e7.e8.e9.ea.eb.ec.ed.ee.ef.f0.f1.f2.f3.f4.f5.f6.f7.f8.f9.fa.fb.fc.fd.fe.ff`.split(`.`),id=1234567,ad=Math.PI/180,od=180/Math.PI;function sd(){let e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(rd[e&255]+rd[e>>8&255]+rd[e>>16&255]+rd[e>>24&255]+`-`+rd[t&255]+rd[t>>8&255]+`-`+rd[t>>16&15|64]+rd[t>>24&255]+`-`+rd[n&63|128]+rd[n>>8&255]+`-`+rd[n>>16&255]+rd[n>>24&255]+rd[r&255]+rd[r>>8&255]+rd[r>>16&255]+rd[r>>24&255]).toLowerCase()}function cd(e,t,n){return Math.max(t,Math.min(n,e))}function ld(e,t){return(e%t+t)%t}function ud(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function dd(e,t,n){return e===t?0:(n-e)/(t-e)}function fd(e,t,n){return(1-n)*e+n*t}function pd(e,t,n,r){return fd(e,t,1-Math.exp(-n*r))}function md(e,t=1){return t-Math.abs(ld(e,t*2)-t)}function hd(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function gd(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function _d(e,t){return e+Math.floor(Math.random()*(t-e+1))}function vd(e,t){return e+Math.random()*(t-e)}function yd(e){return e*(.5-Math.random())}function bd(e){e!==void 0&&(id=e);let t=id+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function xd(e){return e*ad}function Sd(e){return e*od}function Cd(e){return e>0&&Number.isInteger(e)&&2**Math.round(Math.log2(e))===e}function wd(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function Td(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function Ed(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:Zu(`MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function Dd(e){switch(e.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 Od(e,t){if(t.constructor===Float32Array)return e;let n=Dd(t);if(n===void 0)throw Error(`THREE.MathUtils: Invalid component type.`);return Math.max(e/n,-1)}function kd(e,t){if(t.constructor===Float32Array)return e;let n=Dd(t);if(n===void 0)throw Error(`THREE.MathUtils: Invalid component type.`);return Math.round(e*n)}var Ad={DEG2RAD:ad,RAD2DEG:od,generateUUID:sd,clamp:cd,euclideanModulo:ld,mapLinear:ud,inverseLerp:dd,lerp:fd,damp:pd,pingpong:md,smoothstep:hd,smootherstep:gd,randInt:_d,randFloat:vd,randFloatSpread:yd,seededRandom:bd,degToRad:xd,radToDeg:Sd,isPowerOfTwo:Cd,ceilPowerOfTwo:wd,floorPowerOfTwo:Td,setQuaternionFromProperEuler:Ed,normalize:kd,denormalize:Od},Q=class{static{this.prototype.isVector2=!0}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 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 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=cd(this.x,e.x,t.x),this.y=cd(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=cd(this.x,e,t),this.y=cd(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(cd(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(cd(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),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},jd=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,i,a,o){let s=n[r+0],c=n[r+1],l=n[r+2],u=n[r+3],d=i[a+0],f=i[a+1],p=i[a+2],m=i[a+3];if(u!==m||s!==d||c!==f||l!==p){let e=s*d+c*f+l*p+u*m;e<0&&(d=-d,f=-f,p=-p,m=-m,e=-e);let t=1-o;if(e<.9995){let n=Math.acos(e),r=Math.sin(n);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r,s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o}else{s=s*t+d*o,c=c*t+f*o,l=l*t+p*o,u=u*t+m*o;let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,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,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:Zu(`Quaternion: .setFromEuler() encountered an unknown order: `+a)}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],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}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(cd(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*=e,this._y*=e,this._z*=e,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,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,r=-r,i=-i,a=-a,o=-o);let s=1-t;if(o<.9995){let e=Math.acos(o),c=Math.sin(e);s=Math.sin(s*e)/c,t=Math.sin(t*e)/c,this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*t,this._onChangeCallback()}else this._x=this._x*s+n*t,this._y=this._y*s+r*t,this._z=this._z*s+i*t,this._w=this._w*s+a*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),i=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),i*Math.sin(t),i*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}},$=class{static{this.prototype.isVector3=!0}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 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 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(Nd.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Nd.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*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,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[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=cd(this.x,e.x,t.x),this.y=cd(this.y,e.y,t.y),this.z=cd(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=cd(this.x,e,t),this.y=cd(this.y,e,t),this.z=cd(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(cd(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,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,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 Md.copy(this).projectOnVector(e),this.sub(Md)}reflect(e){return this.sub(Md.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(cd(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}},Md=new $,Nd=new jd,Pd=class{static{this.prototype.isMatrix3=!0}constructor(e,t,n,r,i,a,o,s,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[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,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,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],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,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,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return $u(`Matrix3: .scale() is deprecated. Use .makeScale() instead.`),this.premultiply(Fd.makeScale(e,t)),this}rotate(e){return $u(`Matrix3: .rotate() is deprecated. Use .makeRotation() instead.`),this.premultiply(Fd.makeRotation(-e)),this}translate(e,t){return $u(`Matrix3: .translate() is deprecated. Use .makeTranslation() instead.`),this.premultiply(Fd.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 e=0;e<9;e++)if(t[e]!==n[e])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)}},Fd=new Pd,Id=new Pd().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ld=new Pd().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Rd(){let e={enabled:!0,workingColorSpace:Ru,spaces:{},convert:function(e,t,n){return this.enabled===!1||t===n||!t||!n||(this.spaces[t].transfer===`srgb`&&(e.r=Bd(e.r),e.g=Bd(e.g),e.b=Bd(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===`srgb`&&(e.r=Vd(e.r),e.g=Vd(e.g),e.b=Vd(e.b))),e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return e===``?zu:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||`standard`},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[n].fromXYZ).multiply(this.spaces[t].toXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace}},t=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return e.define({[Ru]:{primaries:t,whitePoint:r,transfer:zu,toXYZ:Id,fromXYZ:Ld,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Lu},outputColorSpaceConfig:{drawingBufferColorSpace:Lu}},[Lu]:{primaries:t,whitePoint:r,transfer:Bu,toXYZ:Id,fromXYZ:Ld,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Lu}}}),e}var zd=Rd();function Bd(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function Vd(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var Hd,Ud=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{Hd===void 0&&(Hd=Ku(`canvas`)),Hd.width=e.width,Hd.height=e.height;let t=Hd.getContext(`2d`);e instanceof ImageData?t.putImageData(e,0,0):t.drawImage(e,0,0,e.width,e.height),n=Hd}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=Ku(`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),i=r.data;for(let e=0;e<i.length;e++)i[e]=Bd(i[e]/255)*255;return n.putImageData(r,0,0),t}if(e.data){let t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(Bd(t[e]/255)*255):t[e]=Bd(t[e]);return{data:t,width:e.width,height:e.height}}return Zu(`ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.`),e}},Wd=0,Gd=class{constructor(e=null){this.isTextureSource=!0,Object.defineProperty(this,"id",{value:Wd++}),this.uuid=sd(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){let t=this.data;return typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<`u`&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t===null?e.set(0,0,0):e.set(t.width||0,t.height||0,t.depth||0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){let t=e===void 0||typeof e==`string`;if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];let n={uuid:this.uuid,url:``},r=this.data;if(r!==null){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(Kd(r[t].image)):e.push(Kd(r[t]))}else e=Kd(r);n.url=e}return t||(e.images[this.uuid]=n),n}};function Kd(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap?Ud.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(Zu(`Texture: Unable to serialize Texture.`),{})}var qd=0,Jd=new $,Yd=class e extends nd{constructor(t=e.DEFAULT_IMAGE,n=e.DEFAULT_MAPPING,r=gl,i=gl,a=xl,o=Cl,s=zl,c=wl,l=e.DEFAULT_ANISOTROPY,u=``){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:qd++}),this.uuid=sd(),this.name=``,this.source=new Gd(t),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=c,this.offset=new Q(0,0),this.repeat=new Q(1,1),this.center=new Q(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Pd,this.generateMipmaps=!0,this.mipmapsAutoUpdate=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.isPMREMTexture=!1,this.normalized=!1}get width(){return this.source.getSize(Jd).x}get height(){return this.source.getSize(Jd).y}get depth(){return this.source.getSize(Jd).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){Zu(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?Zu(`Texture.setValues(): property '${t}' does not exist.`):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!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case hl:e.x-=Math.floor(e.x);break;case gl:e.x=e.x<0?0:1;break;case _l:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case hl:e.y-=Math.floor(e.y);break;case gl:e.y=e.y<0?0:1;break;case _l:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y)}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++}};Yd.DEFAULT_IMAGE=null,Yd.DEFAULT_MAPPING=300,Yd.DEFAULT_ANISOTROPY=1;var Xd=class{static{this.prototype.isVector4=!0}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 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 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?1:e.w,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,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,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,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)<a&&Math.abs(u-m)<a&&Math.abs(p-h)<a){if(Math.abs(l+d)<o&&Math.abs(u+m)<o&&Math.abs(p+h)<o&&Math.abs(c+f+g-3)<o)return this.set(1,0,0,0),this;t=Math.PI;let e=(c+1)/2,s=(f+1)/2,_=(g+1)/2,v=(l+d)/4,y=(u+m)/4,b=(p+h)/4;return e>s&&e>_?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>_?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):_<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(_),n=y/i,r=b/i),this.set(n,r,i,t),this}let _=Math.sqrt((h-p)*(h-p)+(u-m)*(u-m)+(d-l)*(d-l));return Math.abs(_)<.001&&(_=1),this.x=(h-p)/_,this.y=(u-m)/_,this.z=(d-l)/_,this.w=Math.acos((c+f+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=cd(this.x,e.x,t.x),this.y=cd(this.y,e.y,t.y),this.z=cd(this.z,e.z,t.z),this.w=cd(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=cd(this.x,e,t),this.y=cd(this.y,e,t),this.z=cd(this.z,e,t),this.w=cd(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(cd(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}},Zd=class extends nd{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:xl,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 Xd(0,0,e,t),this.scissorTest=!1,this.viewport=new Xd(0,0,e,t),this.textures=[];let r=n.count;for(let i=0;i<r;i++)this.textures[i]=new Yd({width:e,height:t,depth:n.depth}),this.textures[i].isRenderTargetTexture=!0,this.textures[i].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveColorBuffer=n.resolveColorBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.storeMultisampledColorBuffer=n.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=n.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=n.storeMultisampledStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(e={}){let t={minFilter:xl,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.mipmapsAutoUpdate!==void 0&&(t.mipmapsAutoUpdate=e.mipmapsAutoUpdate),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let e=0;e<this.textures.length;e++)this.textures[e].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&this._depthTexture.renderTarget===this&&(this._depthTexture.renderTarget=null),e!==null&&e.renderTarget===null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,i=this.textures.length;r<i;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);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<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;let n=Object.assign({},e.textures[t].image);this.textures[t].source=new Gd(n)}if(this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveColorBuffer=e.resolveColorBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,this.storeMultisampledColorBuffer=e.storeMultisampledColorBuffer,this.storeMultisampledDepthBuffer=e.storeMultisampledDepthBuffer,this.storeMultisampledStencilBuffer=e.storeMultisampledStencilBuffer,e.depthTexture!==null){if(e.depthTexture.renderTarget===e){let t=e.depthTexture.clone();t.renderTarget=null,this.depthTexture=t}else this.depthTexture=e.depthTexture}else this.depthTexture=null;return this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:`dispose`})}},Qd=class extends Zd{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},$d=class extends Yd{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=vl,this.minFilter=vl,this.wrapR=gl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},ef=class extends Yd{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=vl,this.minFilter=vl,this.wrapR=gl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}copy(e){return super.copy(e),this.wrapR=e.wrapR,this}},tf=class e{static{this.prototype.isMatrix4=!0}constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}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],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,n=e.elements,r=1/nf.setFromMatrixColumn(e,0).length(),i=1/nf.setFromMatrixColumn(e,1).length(),a=1/nf.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(af,e,of)}lookAt(e,t,n){let r=this.elements;return lf.subVectors(e,t),lf.lengthSq()===0&&(lf.z=1),lf.normalize(),sf.crossVectors(n,lf),sf.lengthSq()===0&&(Math.abs(n.z)===1?lf.x+=1e-4:lf.z+=1e-4,lf.normalize(),sf.crossVectors(n,lf)),sf.normalize(),cf.crossVectors(lf,sf),r[0]=sf.x,r[4]=cf.x,r[8]=lf.x,r[1]=sf.y,r[5]=cf.y,r[9]=lf.y,r[2]=sf.z,r[6]=cf.z,r[10]=lf.z,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,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],N=r[3],P=r[7],F=r[11],ee=r[15];return i[0]=a*x+o*T+s*k+c*N,i[4]=a*S+o*E+s*A+c*P,i[8]=a*C+o*D+s*j+c*F,i[12]=a*w+o*O+s*M+c*ee,i[1]=l*x+u*T+d*k+f*N,i[5]=l*S+u*E+d*A+f*P,i[9]=l*C+u*D+d*j+f*F,i[13]=l*w+u*O+d*M+f*ee,i[2]=p*x+m*T+h*k+g*N,i[6]=p*S+m*E+h*A+g*P,i[10]=p*C+m*D+h*j+g*F,i[14]=p*w+m*O+h*M+g*ee,i[3]=_*x+v*T+y*k+b*N,i[7]=_*S+v*E+y*A+b*P,i[11]=_*C+v*D+y*j+b*F,i[15]=_*w+v*O+y*M+b*ee,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15],_=s*f-c*d,v=o*f-c*u,y=o*d-s*u,b=a*f-c*l,x=a*d-s*l,S=a*u-o*l;return t*(m*_-h*v+g*y)-n*(p*_-h*b+g*x)+r*(p*v-m*b+g*S)-i*(p*y-m*x+h*S)}determinantAffine(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[1],a=e[5],o=e[9],s=e[2],c=e[6],l=e[10];return t*(a*l-o*c)-n*(i*l-o*s)+r*(i*c-a*s)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=t*o-n*a,v=t*s-r*a,y=t*c-i*a,b=n*s-r*o,x=n*c-i*o,S=r*c-i*s,C=l*m-u*p,w=l*h-d*p,T=l*g-f*p,E=u*h-d*m,D=u*g-f*m,O=d*g-f*h,k=_*O-v*D+y*E+b*T-x*w+S*C;if(k===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let A=1/k;return e[0]=(o*O-s*D+c*E)*A,e[1]=(r*D-n*O-i*E)*A,e[2]=(m*S-h*x+g*b)*A,e[3]=(d*x-u*S-f*b)*A,e[4]=(s*T-a*O-c*w)*A,e[5]=(t*O-r*T+i*w)*A,e[6]=(h*y-p*S-g*v)*A,e[7]=(l*S-d*y+f*v)*A,e[8]=(a*D-o*T+c*C)*A,e[9]=(n*T-t*D-i*C)*A,e[10]=(p*x-m*y+g*_)*A,e[11]=(u*y-l*x-f*_)*A,e[12]=(o*w-a*E-s*C)*A,e[13]=(t*E-n*w+r*C)*A,e[14]=(m*v-p*b-h*_)*A,e[15]=(l*b-u*v+d*_)*A,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements;e.x=r[12],e.y=r[13],e.z=r[14];let i=this.determinantAffine();if(i===0)return n.set(1,1,1),t.identity(),this;let a=nf.set(r[0],r[1],r[2]).length(),o=nf.set(r[4],r[5],r[6]).length(),s=nf.set(r[8],r[9],r[10]).length();i<0&&(a=-a),rf.copy(this);let c=1/a,l=1/o,u=1/s;return rf.elements[0]*=c,rf.elements[1]*=c,rf.elements[2]*=c,rf.elements[4]*=l,rf.elements[5]*=l,rf.elements[6]*=l,rf.elements[8]*=u,rf.elements[9]*=u,rf.elements[10]*=u,t.setFromRotationMatrix(rf),n.x=a,n.y=o,n.z=s,this}makePerspective(e,t,n,r,i,a,o=Uu,s=!1){let c=this.elements,l=2*i/(t-e),u=2*i/(n-r),d=(t+e)/(t-e),f=(n+r)/(n-r),p,m;if(s)p=i/(a-i),m=a*i/(a-i);else if(o===2e3)p=-(a+i)/(a-i),m=-2*a*i/(a-i);else if(o===2001)p=-a/(a-i),m=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=f,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Uu,s=!1){let c=this.elements,l=2/(t-e),u=2/(n-r),d=-(t+e)/(t-e),f=-(n+r)/(n-r),p,m;if(s)p=1/(a-i),m=a/(a-i);else if(o===2e3)p=-2/(a-i),m=-(a+i)/(a-i);else if(o===2001)p=-1/(a-i),m=-i/(a-i);else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return c[0]=l,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=f,c[2]=0,c[6]=0,c[10]=p,c[14]=m,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;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[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},nf=new $,rf=new tf,af=new $(0,0,0),of=new $(1,1,1),sf=new $,cf=new $,lf=new $,uf=new tf,df=new jd,ff=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}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 order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(cd(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-cd(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(cd(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-cd(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(cd(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-cd(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:Zu(`Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return uf.makeRotationFromQuaternion(e),this.setFromRotationMatrix(uf,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return df.setFromEuler(this),this.setFromQuaternion(df,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[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._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};ff.DEFAULT_ORDER=`XYZ`;var pf=class{constructor(){this.mask=1}set(e){this.mask=1<<e>>>0}enable(e){this.mask|=1<<e}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e}disable(e){this.mask&=~(1<<e)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return!!(this.mask&1<<e)}},mf=0,hf=new $,gf=new jd,_f=new tf,vf=new $,yf=new $,bf=new $,xf=new jd,Sf=new $(1,0,0),Cf=new $(0,1,0),wf=new $(0,0,1),Tf={type:`added`},Ef={type:`removed`},Df={type:`childadded`,child:null},Of={type:`childremoved`,child:null},kf=class e extends nd{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:mf++}),this.uuid=sd(),this.name=``,this.type=`Object3D`,this.parent=null,this.children=[],this.up=e.DEFAULT_UP.clone();let t=new $,n=new ff,r=new jd,i=new $(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),r._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:r},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new tf},normalMatrix:{value:new Pd}}),this.matrix=new tf,this.matrixWorld=new tf,this.matrixAutoUpdate=e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new pf,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale),this.pivot!==null&&this.position.copy(this.pivot).applyMatrix4(this.matrix).sub(this.pivot)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return gf.setFromAxisAngle(e,t),this.quaternion.multiply(gf),this}rotateOnWorldAxis(e,t){return gf.setFromAxisAngle(e,t),this.quaternion.premultiply(gf),this}rotateX(e){return this.rotateOnAxis(Sf,e)}rotateY(e){return this.rotateOnAxis(Cf,e)}rotateZ(e){return this.rotateOnAxis(wf,e)}translateOnAxis(e,t){return hf.copy(e).applyQuaternion(this.quaternion),this.position.add(hf.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Sf,e)}translateY(e){return this.translateOnAxis(Cf,e)}translateZ(e){return this.translateOnAxis(wf,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(_f.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?vf.copy(e):vf.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),yf.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?_f.lookAt(yf,vf,this.up):_f.lookAt(vf,yf,this.up),this.quaternion.setFromRotationMatrix(_f),r&&(_f.extractRotation(r.matrixWorld),gf.setFromRotationMatrix(_f),this.quaternion.premultiply(gf.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(Qu(`Object3D.add: object can't be added as a child of itself.`,e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Tf),Df.child=e,this.dispatchEvent(Df),Df.child=null):Qu(`Object3D.add: object not an instance of THREE.Object3D.`,e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(Ef),Of.child=e,this.dispatchEvent(Of),Of.child=null),this}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),_f.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),_f.multiply(e.parent.matrixWorld)),e.applyMatrix4(_f),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Tf),Df.child=e,this.dispatchEvent(Df),Df.child=null,this}getObjectById(e){return this.getObjectByProperty(`id`,e)}getObjectByName(e){return this.getObjectByProperty(`name`,e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){let r=this.children[n].getObjectByProperty(e,t);if(r!==void 0)return r}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let i=0,a=r.length;i<a;i++)r[i].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yf,e,bf),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(yf,xf,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}intersectsFrustum(){return!0}traverse(e){e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){let t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);let e=this.pivot;if(e!==null){let t=e.x,n=e.y,r=e.z,i=this.matrix.elements;i[12]+=t-i[0]*t-i[4]*n-i[8]*r,i[13]+=n-i[1]*t-i[5]*n-i[9]*r,i[14]+=r-i[2]*t-i[6]*n-i[10]*r}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);let t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){let r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),t===!0){let e=this.children;for(let t=0,r=e.length;t<r;t++)e[t].updateWorldMatrix(!1,!0,n)}}toJSON(e){let t=e===void 0||typeof e==`string`,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:`Object`,generator:`Object3D.toJSON`});let r={};r.uuid=this.uuid,r.type=this.type,r.name=this.name,r.castShadow=this.castShadow,r.receiveShadow=this.receiveShadow,r.visible=this.visible,r.frustumCulled=this.frustumCulled,r.renderOrder=this.renderOrder,r.static=this.static,r.matrixAutoUpdate=this.matrixAutoUpdate,Object.keys(this.userData).length>0&&(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(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(e=>({...e})),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 i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.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=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){let r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0){if(Array.isArray(this.material)){let t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material)}if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){let n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){let t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),c=a(e.skeletons),l=a(e.animations),u=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}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?null:e.pivot.clone(),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 t=0;t<e.children.length;t++){let n=e.children[t];this.add(n.clone())}return this}dispose(){this.dispatchEvent({type:`dispose`})}};kf.DEFAULT_UP=new $(0,1,0),kf.DEFAULT_MATRIX_AUTO_UPDATE=!0,kf.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var Af=class extends kf{constructor(){super(),this.isGroup=!0,this.type=`Group`}},jf={type:`move`},Mf=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Af,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Af,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new $,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new $),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Af,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new $,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new $,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.quaternion,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,s.eventsEnabled&&s.dispatchEvent({type:`gripUpdated`,data:e,target:this})));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(jf)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Af;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Nf={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},Pf={h:0,s:0,l:0},Ff={h:0,s:0,l:0};function If(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var Lf=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 t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Lu){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,zd.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=zd.workingColorSpace){return this.r=e,this.g=t,this.b=n,zd.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=zd.workingColorSpace){if(e=ld(e,1),t=cd(t,0,1),n=cd(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=If(i,r,e+1/3),this.g=If(i,r,e),this.b=If(i,r,e-1/3)}return zd.colorSpaceToWorking(this,r),this}setStyle(e,t=Lu){function n(t){t!==void 0&&parseFloat(t)<1&&Zu(`Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseFloat(i[1]))/100,Math.min(100,parseFloat(i[2]))/100,Math.min(100,parseFloat(i[3]))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:Zu(`Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);Zu(`Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Lu){let n=Nf[e.toLowerCase()];return n===void 0?Zu(`Color: Unknown color `+e):this.setHex(n,t),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=Bd(e.r),this.g=Bd(e.g),this.b=Bd(e.b),this}copyLinearToSRGB(e){return this.r=Vd(e.r),this.g=Vd(e.g),this.b=Vd(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Lu){return zd.workingToColorSpace(Rf.copy(this),e),Math.round(cd(Rf.r*255,0,255))*65536+Math.round(cd(Rf.g*255,0,255))*256+Math.round(cd(Rf.b*255,0,255))}getHexString(e=Lu){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=zd.workingColorSpace){zd.workingToColorSpace(Rf.copy(this),t);let n=Rf.r,r=Rf.g,i=Rf.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4}s/=6}return e.h=s,e.s=c,e.l=l,e}getRGB(e,t=zd.workingColorSpace){return zd.workingToColorSpace(Rf.copy(this),t),e.r=Rf.r,e.g=Rf.g,e.b=Rf.b,e}getStyle(e=Lu){zd.workingToColorSpace(Rf.copy(this),e);let t=Rf.r,n=Rf.g,r=Rf.b;return e===`srgb`?`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`:`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`}offsetHSL(e,t,n){return this.getHSL(Pf),this.setHSL(Pf.h+e,Pf.s+t,Pf.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Pf),e.getHSL(Ff);let n=fd(Pf.h,Ff.h,t),r=fd(Pf.s,Ff.s,t),i=fd(Pf.l,Ff.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}},Rf=new Lf;Lf.NAMES=Nf;var zf=class extends kf{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new ff,this.environmentIntensity=1,this.environmentRotation=new ff,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),this.background=e.background===null?null:e.background.clone(),this.environment=e.environment===null?null:e.environment.clone(),this.fog=e.fog===null?null:e.fog.clone(),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),this.overrideMaterial=e.overrideMaterial===null?null:e.overrideMaterial.clone(),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),t.object.backgroundBlurriness=this.backgroundBlurriness,t.object.backgroundIntensity=this.backgroundIntensity,t.object.backgroundRotation=this.backgroundRotation.toArray(),t.object.environmentIntensity=this.environmentIntensity,t.object.environmentRotation=this.environmentRotation.toArray(),t}},Bf=new $,Vf=new $,Hf=new $,Uf=new $,Wf=new $,Gf=new $,Kf=new $,qf=new $,Jf=new $,Yf=new $,Xf=new Xd,Zf=new Xd,Qf=new Xd,$f=class e{constructor(e=new $,t=new $,n=new $){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),Bf.subVectors(e,t),r.cross(Bf);let i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){Bf.subVectors(r,t),Vf.subVectors(n,t),Hf.subVectors(e,t);let a=Bf.dot(Bf),o=Bf.dot(Vf),s=Bf.dot(Hf),c=Vf.dot(Vf),l=Vf.dot(Hf),u=a*c-o*o;if(u===0)return i.set(0,0,0),null;let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Uf)!==null&&Uf.x>=0&&Uf.y>=0&&Uf.x+Uf.y<=1}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Uf)===null?(s.x=0,s.y=0,`z`in s&&(s.z=0),`w`in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(i,Uf.x),s.addScaledVector(a,Uf.y),s.addScaledVector(o,Uf.z),s)}static getInterpolatedAttribute(e,t,n,r,i,a){return Xf.setScalar(0),Zf.setScalar(0),Qf.setScalar(0),Xf.fromBufferAttribute(e,t),Zf.fromBufferAttribute(e,n),Qf.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Xf,i.x),a.addScaledVector(Zf,i.y),a.addScaledVector(Qf,i.z),a}static isFrontFacing(e,t,n,r){return Bf.subVectors(n,t),Vf.subVectors(e,t),Bf.cross(Vf).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 Bf.subVectors(this.c,this.b),Vf.subVectors(this.a,this.b),Bf.cross(Vf).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Wf.subVectors(r,n),Gf.subVectors(i,n),qf.subVectors(e,n);let s=Wf.dot(qf),c=Gf.dot(qf);if(s<=0&&c<=0)return t.copy(n);Jf.subVectors(e,r);let l=Wf.dot(Jf),u=Gf.dot(Jf);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0&&s-l>0)return a=s/(s-l),t.copy(n).addScaledVector(Wf,a);Yf.subVectors(e,i);let f=Wf.dot(Yf),p=Gf.dot(Yf);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Gf,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Kf.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Kf,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Wf,a).addScaledVector(Gf,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},ep=class{constructor(e=new $(1/0,1/0,1/0),t=new $(-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<n;t+=3)this.expandByPoint(np.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(np.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){let n=np.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);let n=e.geometry;if(n!==void 0){let r=n.getAttribute(`position`);if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0&&e.isBatchedMesh!==!0)for(let t=0,n=r.count;t<n;t++)e.isMesh===!0?e.getVertexPosition(t,np):np.fromBufferAttribute(r,t),np.applyMatrix4(e.matrixWorld),this.expandByPoint(np);else e.boundingBox===void 0?(n.boundingBox===null&&n.computeBoundingBox(),rp.copy(n.boundingBox)):(e.boundingBox===null&&e.computeBoundingBox(),rp.copy(e.boundingBox)),rp.applyMatrix4(e.matrixWorld),this.union(rp)}let r=e.children;for(let e=0,n=r.length;e<n;e++)this.expandByObject(r[e],t);return this}containsPoint(e){return e.x>=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,np),np.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(up),dp.subVectors(this.max,up),ip.subVectors(e.a,up),ap.subVectors(e.b,up),op.subVectors(e.c,up),sp.subVectors(ap,ip),cp.subVectors(op,ap),lp.subVectors(ip,op);let t=[0,-sp.z,sp.y,0,-cp.z,cp.y,0,-lp.z,lp.y,sp.z,0,-sp.x,cp.z,0,-cp.x,lp.z,0,-lp.x,-sp.y,sp.x,0,-cp.y,cp.x,0,-lp.y,lp.x,0];return!mp(t,ip,ap,op,dp)||(t=[1,0,0,0,1,0,0,0,1],!mp(t,ip,ap,op,dp))?!1:(fp.crossVectors(sp,cp),t=[fp.x,fp.y,fp.z],mp(t,ip,ap,op,dp))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,np).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(np).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()||(tp[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),tp[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),tp[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),tp[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),tp[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),tp[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),tp[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),tp[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(tp)),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}},tp=[new $,new $,new $,new $,new $,new $,new $,new $],np=new $,rp=new ep,ip=new $,ap=new $,op=new $,sp=new $,cp=new $,lp=new $,up=new $,dp=new $,fp=new $,pp=new $;function mp(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){pp.fromArray(e,a);let o=i.x*Math.abs(pp.x)+i.y*Math.abs(pp.y)+i.z*Math.abs(pp.z),s=t.dot(pp),c=n.dot(pp),l=r.dot(pp);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var hp=gp();function gp(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),r=new Uint32Array(512),i=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(r[e]=0,r[e|256]=32768,i[e]=24,i[e|256]=24):t<-14?(r[e]=1024>>-t-14,r[e|256]=1024>>-t-14|32768,i[e]=-t-1,i[e|256]=-t-1):t<=15?(r[e]=t+15<<10,r[e|256]=t+15<<10|32768,i[e]=13,i[e|256]=13):t<128?(r[e]=31744,r[e|256]=64512,i[e]=24,i[e|256]=24):(r[e]=31744,r[e|256]=64512,i[e]=13,i[e|256]=13)}let a=new Uint32Array(2048),o=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;!(t&8388608);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)e!==32&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:a,exponentTable:o,offsetTable:s}}function _p(e){Math.abs(e)>65504&&Zu(`DataUtils.toHalfFloat(): Value out of range.`),e=cd(e,-65504,65504),hp.floatView[0]=e;let t=hp.uint32View[0],n=t>>23&511;return hp.baseTable[n]+((t&8388607)>>hp.shiftTable[n])}function vp(e){let t=e>>10;return hp.uint32View[0]=hp.mantissaTable[hp.offsetTable[t]+(e&1023)]+hp.exponentTable[t],hp.floatView[0]}var yp=class{static toHalfFloat(e){return _p(e)}static fromHalfFloat(e){return vp(e)}},bp=new $,xp=new Q,Sp=0,Cp=class extends nd{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Sp++}),this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Hu,this.updateRanges=[],this.gpuType=Al,this.version=0,this._normalizationScale=e===void 0?void 0:Dd(e)}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,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)xp.fromBufferAttribute(this,t),xp.applyMatrix3(e),this.setXY(t,xp.x,xp.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)bp.fromBufferAttribute(this,t),bp.applyMatrix3(e),this.setXYZ(t,bp.x,bp.y,bp.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)bp.fromBufferAttribute(this,t),bp.applyMatrix4(e),this.setXYZ(t,bp.x,bp.y,bp.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)bp.fromBufferAttribute(this,t),bp.applyNormalMatrix(e),this.setXYZ(t,bp.x,bp.y,bp.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)bp.fromBufferAttribute(this,t),bp.transformDirection(e),this.setXYZ(t,bp.x,bp.y,bp.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=this._denormalize(t)),t}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=this._denormalize(t)),t}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=this._denormalize(t)),t}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=this._denormalize(t)),t}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r),i=this._normalize(i)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){let e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return e.name=this.name,e.usage=this.usage,e.gpuType=this.gpuType,e}dispose(){this.dispatchEvent({type:`dispose`})}_denormalize(e){let t=this._normalizationScale;return t===void 0?Od(e,this.array):Math.max(e/t,-1)}_normalize(e){let t=this._normalizationScale;return t===void 0?kd(e,this.array):Math.round(e*t)}},wp=class extends Cp{constructor(e,t,n){super(new Uint16Array(e),t,n)}},Tp=class extends Cp{constructor(e,t,n){super(new Uint32Array(e),t,n)}},Ep=class extends Cp{constructor(e,t,n){super(new Float32Array(e),t,n)}},Dp=new ep,Op=new $,kp=new $,Ap=class{constructor(e=new $,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?Dp.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){let t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){let n=this.center.distanceToSquared(e);return t.copy(e),n>this.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*=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;Op.subVectors(e,this.center);let t=Op.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(Op,n/e),this.radius+=n}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):(kp.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Op.copy(e.center).add(kp)),this.expandByPoint(Op.copy(e.center).sub(kp))),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}},jp=0,Mp=new tf,Np=new kf,Pp=new $,Fp=new ep,Ip=new ep,Lp=new $,Rp=class e extends nd{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:jp++}),this.uuid=sd(),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 this.index=Array.isArray(e)?new(Wu(e)?Tp:wp)(e,1):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 t=new Pd().getNormalMatrix(e);n.applyNormalMatrix(t),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 Mp.makeRotationFromQuaternion(e),this.applyMatrix4(Mp),this}rotateX(e){return Mp.makeRotationX(e),this.applyMatrix4(Mp),this}rotateY(e){return Mp.makeRotationY(e),this.applyMatrix4(Mp),this}rotateZ(e){return Mp.makeRotationZ(e),this.applyMatrix4(Mp),this}translate(e,t,n){return Mp.makeTranslation(e,t,n),this.applyMatrix4(Mp),this}scale(e,t,n){return Mp.makeScale(e,t,n),this.applyMatrix4(Mp),this}lookAt(e){return Np.lookAt(e),Np.updateMatrix(),this.applyMatrix4(Np.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Pp).negate(),this.translate(Pp.x,Pp.y,Pp.z),this}setFromPoints(e){let t=this.getAttribute(`position`);if(t===void 0){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];t.push(r.x,r.y,r.z||0)}this.setAttribute(`position`,new Ep(t,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let n=e[r];t.setXYZ(r,n.x,n.y,n.z||0)}e.length>t.count&&Zu(`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 ep);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)Qu(`BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.`,this),this.boundingBox.set(new $(-1/0,-1/0,-1/0),new $(1/0,1/0,1/0));else{if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Fp.setFromBufferAttribute(n),this.morphTargetsRelative?(Lp.addVectors(this.boundingBox.min,Fp.min),this.boundingBox.expandByPoint(Lp),Lp.addVectors(this.boundingBox.max,Fp.max),this.boundingBox.expandByPoint(Lp)):(this.boundingBox.expandByPoint(Fp.min),this.boundingBox.expandByPoint(Fp.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Qu(`BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.`,this)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ap);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)Qu(`BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.`,this),this.boundingSphere.set(new $,1/0);else if(e){let n=this.boundingSphere.center;if(Fp.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){let n=t[e];Ip.setFromBufferAttribute(n),this.morphTargetsRelative?(Lp.addVectors(Fp.min,Ip.min),Fp.expandByPoint(Lp),Lp.addVectors(Fp.max,Ip.max),Fp.expandByPoint(Lp)):(Fp.expandByPoint(Ip.min),Fp.expandByPoint(Ip.max))}Fp.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)Lp.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(Lp));if(t)for(let i=0,a=t.length;i<a;i++){let a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)Lp.fromBufferAttribute(a,t),o&&(Pp.fromBufferAttribute(e,t),Lp.add(Pp)),r=Math.max(r,n.distanceToSquared(Lp))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Qu(`BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.`,this)}}computeTangents(){let e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Qu(`BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)`);return}let n=t.position,r=t.normal,i=t.uv,a=this.getAttribute(`tangent`);(a===void 0||a.count!==n.count)&&(a=new Cp(new Float32Array(4*n.count),4),this.setAttribute(`tangent`,a));let o=[],s=[],c=new Uint8Array(n.count);for(let e=0;e<n.count;e++)o[e]=new $,s[e]=new $;let l=new $,u=new $,d=new $,f=new Q,p=new Q,m=new Q,h=new $,g=new $;function _(e,t,r){c[e]=c[t]=c[r]=1,l.fromBufferAttribute(n,e),u.fromBufferAttribute(n,t),d.fromBufferAttribute(n,r),f.fromBufferAttribute(i,e),p.fromBufferAttribute(i,t),m.fromBufferAttribute(i,r),u.sub(l),d.sub(l),p.sub(f),m.sub(f);let a=1/(p.x*m.y-m.x*p.y);isFinite(a)&&(h.copy(u).multiplyScalar(m.y).addScaledVector(d,-p.y).multiplyScalar(a),g.copy(d).multiplyScalar(p.x).addScaledVector(u,-m.x).multiplyScalar(a),o[e].add(h),o[t].add(h),o[r].add(h),s[e].add(g),s[t].add(g),s[r].add(g))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let t=0,n=v.length;t<n;++t){let n=v[t],r=n.start,i=n.count;for(let t=r,n=r+i;t<n;t+=3)_(e.getX(t+0),e.getX(t+1),e.getX(t+2))}let y=new $,b=new $,x=new $,S=new $;function C(e){x.fromBufferAttribute(r,e),S.copy(x);let t=o[e];y.copy(t),y.sub(x.multiplyScalar(x.dot(t))).normalize(),b.crossVectors(S,t);let n=b.dot(s[e])<0?-1:1;a.setXYZW(e,y.x,y.y,y.z,n)}for(let e=0,t=n.count;e<t;++e)c[e]&&C(e);this._transformed=!0}computeVertexNormals(){let e=this.index,t=this.getAttribute(`position`);if(t!==void 0){let n=this.getAttribute(`normal`);if(n===void 0||n.count!==t.count)n=new Cp(new Float32Array(t.count*3),3),this.setAttribute(`normal`,n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);let r=new $,i=new $,a=new $,o=new $,s=new $,c=new $,l=new $,u=new $;if(e)for(let d=0,f=e.count;d<f;d+=3){let f=e.getX(d+0),p=e.getX(d+1),m=e.getX(d+2);r.fromBufferAttribute(t,f),i.fromBufferAttribute(t,p),a.fromBufferAttribute(t,m),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),o.fromBufferAttribute(n,f),s.fromBufferAttribute(n,p),c.fromBufferAttribute(n,m),o.add(l),s.add(l),c.add(l),n.setXYZ(f,o.x,o.y,o.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Lp.fromBufferAttribute(e,t),Lp.normalize(),e.setXYZ(t,Lp.x,Lp.y,Lp.z)}toNonIndexed(){function t(e,t){let n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r),o=0,s=0;for(let i=0,c=t.length;i<c;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new Cp(a,r,i)}if(this.index===null)return Zu(`BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed.`),this;let n=new e,r=this.index.array,i=this.attributes;for(let e in i){let a=i[e],o=t(a,r);n.setAttribute(e,o)}let a=this.morphAttributes;for(let e in a){let i=[],o=a[e];for(let e=0,n=o.length;e<n;e++){let n=o[e],a=t(n,r);i.push(a)}n.morphAttributes[e]=i}n.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let e=0,t=o.length;e<t;e++){let t=o[e];n.addGroup(t.start,t.count,t.materialIndex)}return n}toJSON(){let e={metadata:{version:4.7,type:`BufferGeometry`,generator:`BufferGeometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?`BufferGeometry`:this.type,e.name=this.name,Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);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 t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){let r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.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 e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;let a=e.groups;for(let e=0,t=a.length;e<t;e++){let t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}let o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());let s=e.boundingSphere;return s!==null&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:`dispose`})}},zp=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=Hu,this.updateRanges=[],this.version=0,this.uuid=sd()}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.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={});let t=Bp(this.array);e.arrayBuffers[t]===void 0&&(e.arrayBuffers[t]=this.array.slice(0).buffer);let n=new this.array.constructor(e.arrayBuffers[t]),r=new this.constructor(n,this.stride);return r.setUsage(this.usage),r}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){e.arrayBuffers===void 0&&(e.arrayBuffers={});let t=Bp(this.array);e.arrayBuffers[t]===void 0&&(e.arrayBuffers[t]=Array.from(new Uint32Array(this.array.slice(0).buffer)));let n={uuid:this.uuid,buffer:t,type:this.array.constructor.name,stride:this.stride};return n.usage=this.usage,n}};function Bp(e){return e.buffer._uuid===void 0&&(e.buffer._uuid=sd()),e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer._uuid:e.buffer._uuid+`:`+e.byteOffset+`:`+e.byteLength}var Vp=new $,Hp=class e{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name=``,this.data=e,this.itemSize=t,this.offset=n,this.normalized=r,this._normalizationScale=e===void 0?void 0:Dd(e.array)}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Vp.fromBufferAttribute(this,t),Vp.applyMatrix4(e),this.setXYZ(t,Vp.x,Vp.y,Vp.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Vp.fromBufferAttribute(this,t),Vp.applyNormalMatrix(e),this.setXYZ(t,Vp.x,Vp.y,Vp.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Vp.fromBufferAttribute(this,t),Vp.transformDirection(e),this.setXYZ(t,Vp.x,Vp.y,Vp.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=this._denormalize(n)),n}setComponent(e,t,n){return this.normalized&&(n=this._normalize(n)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=this._normalize(t)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=this._denormalize(t)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=this._denormalize(t)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=this._denormalize(t)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=this._denormalize(t)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=this._normalize(t),n=this._normalize(n),r=this._normalize(r),i=this._normalize(i)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(t){if(t===void 0){Yu(`InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new Cp(new this.array.constructor(e),this.itemSize,this.normalized)}return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new e(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Yu(`InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.`);let e=[];for(let t=0;t<this.count;t++){let n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}_denormalize(e){let t=this._normalizationScale;return t===void 0?Od(e,this.data.array):Math.max(e/t,-1)}_normalize(e){let t=this._normalizationScale;return t===void 0?kd(e,this.data.array):Math.round(e*t)}},Up=new $,Wp=new $,Gp=new Pd,Kp=class{constructor(e=new $(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=Up.subVectors(n,t).cross(Wp.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){let r=e.delta(Up),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/i;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(r,a)}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||Gp.getNormalMatrix(e),r=this.coplanarPoint(Up).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),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}},qp=0,Jp=class extends nd{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:qp++}),this.uuid=sd(),this.name=``,this.type=`Material`,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Lf(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Vu,this.stencilZFail=Vu,this.stencilZPass=Vu,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){Zu(`Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];r===void 0?Zu(`Material: '${t}' is not a property of THREE.${this.type}.`):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(e=>e.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(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}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 Lf().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(e=>new Kp().fromJSON(e))),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&&(this.vertexColors=typeof e.vertexColors==`number`?e.vertexColors>0: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 t=e.normalScale;Array.isArray(t)===!1&&(t=[t,t]),this.normalScale=new Q().fromArray(t)}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 Q().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 e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].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++}},Yp=class extends Jp{constructor(e){super(),this.isSpriteMaterial=!0,this.type=`SpriteMaterial`,this.color=new Lf(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}},Xp,Zp=new $,Qp=new $,$p=new $,em=new Q,tm=new Q,nm=new tf,rm=new $,im=new $,am=new $,om=new Q,sm=new Q,cm=new Q,lm=class extends kf{constructor(e=new Yp){if(super(),this.isSprite=!0,this.type=`Sprite`,Xp===void 0){Xp=new Rp;let e=new zp(new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),5);Xp.setIndex([0,1,2,0,2,3]),Xp.setAttribute(`position`,new Hp(e,3,0,!1)),Xp.setAttribute(`uv`,new Hp(e,2,3,!1))}this.geometry=Xp,this.material=e,this.center=new Q(.5,.5),this.count=1}intersectsFrustum(e){return e.intersectsSprite(this)}raycast(e,t){e.camera===null&&Qu(`Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.`),Qp.setFromMatrixScale(this.matrixWorld),nm.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),$p.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Qp.multiplyScalar(-$p.z);let n=this.material.rotation,r,i;n!==0&&(i=Math.cos(n),r=Math.sin(n));let a=this.center;um(rm.set(-.5,-.5,0),$p,a,Qp,r,i),um(im.set(.5,-.5,0),$p,a,Qp,r,i),um(am.set(.5,.5,0),$p,a,Qp,r,i),om.set(0,0),sm.set(1,0),cm.set(1,1);let o=e.ray.intersectTriangle(rm,im,am,!1,Zp);if(o===null&&(um(im.set(-.5,.5,0),$p,a,Qp,r,i),sm.set(0,1),o=e.ray.intersectTriangle(rm,am,im,!1,Zp),o===null))return;let s=e.ray.origin.distanceTo(Zp);s<e.near||s>e.far||t.push({distance:s,point:Zp.clone(),uv:$f.getInterpolation(Zp,rm,im,am,om,sm,cm,new Q),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 um(e,t,n,r,i,a){em.subVectors(e,n).addScalar(.5).multiply(r),i===void 0?tm.copy(em):(tm.x=a*em.x-i*em.y,tm.y=i*em.x+a*em.y),e.copy(t),e.x+=tm.x,e.y+=tm.y,e.applyMatrix4(nm)}var dm=new $,fm=new $,pm=new $,mm=new $,hm=class{constructor(e=new $,t=new $(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,dm)),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=dm.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(dm.copy(this.origin).addScaledVector(this.direction,t),dm.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){fm.copy(e).add(t).multiplyScalar(.5),pm.copy(t).sub(e).normalize(),mm.copy(this.origin).sub(fm);let i=e.distanceTo(t)*.5,a=-this.direction.dot(pm),o=mm.dot(this.direction),s=-mm.dot(pm),c=mm.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0){if(u=a*s-o,d=a*o-s,p=i*l,u>=0){if(d>=-p){if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c}else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c)}else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(fm).addScaledVector(pm,d),f}intersectSphere(e,t){if(e.radius<0)return null;dm.subVectors(e.center,this.origin);let n=dm.dot(this.direction),r=dm.dot(dm)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,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,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s<r||r!==r)&&(r=s),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,dm)!==null}intersectTriangle(e,t,n,r,i){let a=this.origin,o=this.direction,s=o.x,c=o.y,l=o.z,u=e.x-a.x,d=e.y-a.y,f=e.z-a.z,p=t.x-a.x,m=t.y-a.y,h=t.z-a.z,g=n.x-a.x,_=n.y-a.y,v=n.z-a.z,y=Math.abs(s),b=Math.abs(c),x=Math.abs(l),S,C,w,T,E,D,O,k,A,j,M,N;if(y>=b&&y>=x?(w=s,D=u,A=p,N=g,s>=0?(S=c,C=l,T=d,E=f,O=m,k=h,j=_,M=v):(S=l,C=c,T=f,E=d,O=h,k=m,j=v,M=_)):b>=x?(w=c,D=d,A=m,N=_,c>=0?(S=l,C=s,T=f,E=u,O=h,k=p,j=v,M=g):(S=s,C=l,T=u,E=f,O=p,k=h,j=g,M=v)):(w=l,D=f,A=h,N=v,l>=0?(S=s,C=c,T=u,E=d,O=p,k=m,j=g,M=_):(S=c,C=s,T=d,E=u,O=m,k=p,j=_,M=g)),w===0)return null;let P=S/w,F=C/w,ee=1/w,te=T-P*D,ne=E-F*D,I=O-P*A,L=k-F*A,R=j-P*N,z=M-F*N,re=R*L-z*I,B=te*z-ne*R,ie=I*ne-L*te;if(r){if(re<0||B<0||ie<0)return null}else if((re<0||B<0||ie<0)&&(re>0||B>0||ie>0))return null;let ae=re+B+ie;if(ae===0)return null;let V=ee*(re*D+B*A+ie*N);return(ae>0?V<0:V>0)?null:this.at(V/ae,i)}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)}},gm=class extends Jp{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new Lf(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 ff,this.combine=0,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}},_m=new tf,vm=new hm,ym=new Ap,bm=new $,xm=new $,Sm=new $,Cm=new $,wm=new $,Tm=new $,Em=new $,Dm=new $,Om=class extends kf{constructor(e=new Rp,t=new gm){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),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let o=this.morphTargetInfluences;if(i&&o){Tm.set(0,0,0);for(let n=0,r=i.length;n<r;n++){let r=o[n],s=i[n];r!==0&&(wm.fromBufferAttribute(s,e),a?Tm.addScaledVector(wm,r):Tm.addScaledVector(wm.sub(t),r))}t.add(Tm)}return t}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.material,i=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ym.copy(n.boundingSphere),ym.applyMatrix4(i),vm.copy(e.ray).recast(e.near),!(ym.containsPoint(vm.origin)===!1&&(vm.intersectSphere(ym,bm)===null||vm.origin.distanceToSquared(bm)>(e.far-e.near)**2))&&(_m.copy(i).invert(),vm.copy(e.ray).applyMatrix4(_m),(n.boundingBox===null||vm.intersectsBox(n.boundingBox)!==!1)&&this._computeIntersections(e,t,vm)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null){if(Array.isArray(a))for(let i=0,s=d.length;i<s;i++){let s=d[i],p=a[s.materialIndex],m=Math.max(s.start,f.start),h=Math.min(o.count,Math.min(s.start+s.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=o.getX(i),d=o.getX(i+1),f=o.getX(i+2);r=Am(this,p,e,n,c,l,u,a,d,f),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=s.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),s=Math.min(o.count,f.start+f.count);for(let d=i,f=s;d<f;d+=3){let i=o.getX(d),s=o.getX(d+1),f=o.getX(d+2);r=Am(this,a,e,n,c,l,u,i,s,f),r&&(r.faceIndex=Math.floor(d/3),t.push(r))}}}else if(s!==void 0){if(Array.isArray(a))for(let i=0,o=d.length;i<o;i++){let o=d[i],p=a[o.materialIndex],m=Math.max(o.start,f.start),h=Math.min(s.count,Math.min(o.start+o.count,f.start+f.count));for(let i=m,a=h;i<a;i+=3){let a=i,s=i+1,d=i+2;r=Am(this,p,e,n,c,l,u,a,s,d),r&&(r.faceIndex=Math.floor(i/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{let i=Math.max(0,f.start),o=Math.min(s.count,f.start+f.count);for(let s=i,d=o;s<d;s+=3){let i=s,o=s+1,d=s+2;r=Am(this,a,e,n,c,l,u,i,o,d),r&&(r.faceIndex=Math.floor(s/3),t.push(r))}}}}};function km(e,t,n,r,i,a,o,s){let c;if(c=t.side===1?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===0,s),c===null)return null;Dm.copy(s),Dm.applyMatrix4(e.matrixWorld);let l=n.ray.origin.distanceTo(Dm);return l<n.near||l>n.far?null:{distance:l,point:Dm.clone(),object:e}}function Am(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,xm),e.getVertexPosition(c,Sm),e.getVertexPosition(l,Cm);let u=km(e,t,n,r,xm,Sm,Cm,Em);if(u){let e=new $;$f.getBarycoord(Em,xm,Sm,Cm,e),i&&(u.uv=$f.getInterpolatedAttribute(i,s,c,l,e,new Q)),a&&(u.uv1=$f.getInterpolatedAttribute(a,s,c,l,e,new Q)),o&&(u.normal=$f.getInterpolatedAttribute(o,s,c,l,e,new $),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let t={a:s,b:c,c:l,normal:new $,materialIndex:0};$f.getNormal(xm,Sm,Cm,t.normal),u.face=t,u.barycoord=e}return u}var jm=class extends Yd{constructor(e=null,t=1,n=1,r,i,a,o,s,c=vl,l=vl,u,d){super(null,a,o,s,c,l,r,i,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Mm=new Ap,Nm=new Q(.5,.5),Pm=new $,Fm=class{constructor(e=new Kp,t=new Kp,n=new Kp,r=new Kp,i=new Kp,a=new Kp){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Uu,n=!1){let r=this.planes,i=e.elements,a=i[0],o=i[1],s=i[2],c=i[3],l=i[4],u=i[5],d=i[6],f=i[7],p=i[8],m=i[9],h=i[10],g=i[11],_=i[12],v=i[13],y=i[14],b=i[15];if(r[0].setComponents(c-a,f-l,g-p,b-_).normalize(),r[1].setComponents(c+a,f+l,g+p,b+_).normalize(),r[2].setComponents(c+o,f+u,g+m,b+v).normalize(),r[3].setComponents(c-o,f-u,g-m,b-v).normalize(),n)r[4].setComponents(s,d,h,y).normalize(),r[5].setComponents(c-s,f-d,g-h,b-y).normalize();else if(r[4].setComponents(c-s,f-d,g-h,b-y).normalize(),t===2e3)r[5].setComponents(c+s,f+d,g+h,b+y).normalize();else if(t===2001)r[5].setComponents(s,d,h,y).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Mm.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Mm.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Mm)}intersectsSprite(e){return Mm.center.set(0,0,0),Mm.radius=.7071067811865476+Nm.distanceTo(e.center),Mm.applyMatrix4(e.matrixWorld),this.intersectsSphere(Mm)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){let t=this.planes;for(let n=0;n<6;n++){let r=t[n];if(Pm.x=r.normal.x>0?e.max.x:e.min.x,Pm.y=r.normal.y>0?e.max.y:e.min.y,Pm.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Pm)<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)}},Im=new tf,Lm=class e{constructor(){this.coordinateSystem=Uu,this._frustums=[],this._count=0}setFromArrayCamera(e){let t=e.cameras,n=this._frustums;for(let e=0;e<t.length;e++){let r=t[e];Im.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),n[e]===void 0&&(n[e]=new Fm),n[e].setFromProjectionMatrix(Im,r.coordinateSystem,r.reversedDepth)}return this._count=t.length,this}getFrustum(e){return this._frustums[e]}intersectsObject(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsObject(e))return!0;return!1}intersectsSprite(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSprite(e))return!0;return!1}intersectsSphere(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsSphere(e))return!0;return!1}intersectsBox(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].intersectsBox(e))return!0;return!1}containsPoint(e){let t=this._frustums;for(let n=0;n<this._count;n++)if(t[n].containsPoint(e))return!0;return!1}copy(e){this.coordinateSystem=e.coordinateSystem;let t=this._frustums,n=e._frustums;for(let r=0;r<e._count;r++)t[r]===void 0&&(t[r]=new Fm),t[r].copy(n[r]);return this._count=e._count,this}clone(){return new e().copy(this)}},Rm=class extends Jp{constructor(e){super(),this.isLineBasicMaterial=!0,this.type=`LineBasicMaterial`,this.color=new Lf(16777215),this.map=null,this.linewidth=1,this.linecap=`round`,this.linejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}},zm=new $,Bm=new $,Vm=new tf,Hm=new hm,Um=new Ap,Wm=new $,Gm=new $,Km=class extends kf{constructor(e=new Rp,t=new Rm){super(),this.isLine=!0,this.type=`Line`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)zm.fromBufferAttribute(t,e-1),Bm.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=zm.distanceTo(Bm);e.setAttribute(`lineDistance`,new Ep(n,1))}else Zu(`Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`);return this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Um.copy(n.boundingSphere),Um.applyMatrix4(r),Um.radius+=i,e.ray.intersectsSphere(Um)===!1)return;Vm.copy(r).invert(),Hm.copy(e.ray).applyMatrix4(Vm);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=this.isLineSegments?2:1,l=n.index,u=n.attributes.position;if(l!==null){let n=Math.max(0,a.start),r=Math.min(l.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=l.getX(i),r=l.getX(i+1),a=qm(this,e,Hm,s,n,r,i);a&&t.push(a)}if(this.isLineLoop){let i=l.getX(r-1),a=l.getX(n),o=qm(this,e,Hm,s,i,a,r-1);o&&t.push(o)}}else{let n=Math.max(0,a.start),r=Math.min(u.count,a.start+a.count);for(let i=n,a=r-1;i<a;i+=c){let n=qm(this,e,Hm,s,i,i+1,i);n&&t.push(n)}if(this.isLineLoop){let i=qm(this,e,Hm,s,r-1,n,r-1);i&&t.push(i)}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function qm(e,t,n,r,i,a,o){let s=e.geometry.attributes.position;if(zm.fromBufferAttribute(s,i),Bm.fromBufferAttribute(s,a),n.distanceSqToSegment(zm,Bm,Wm,Gm)>r)return;Wm.applyMatrix4(e.matrixWorld);let c=t.ray.origin.distanceTo(Wm);if(!(c<t.near||c>t.far))return{distance:c,point:Gm.clone().applyMatrix4(e.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:e}}var Jm=class extends Jp{constructor(e){super(),this.isPointsMaterial=!0,this.type=`PointsMaterial`,this.color=new Lf(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!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.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}},Ym=new tf,Xm=new hm,Zm=new Ap,Qm=new $,$m=class extends kf{constructor(e=new Rp,t=new Jm){super(),this.isPoints=!0,this.type=`Points`,this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.morphTargetInfluences=e.morphTargetInfluences===void 0?void 0:e.morphTargetInfluences.slice(),this.morphTargetDictionary=e.morphTargetDictionary===void 0?void 0:Object.assign({},e.morphTargetDictionary),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}intersectsFrustum(e){return e.intersectsObject(this)}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Zm.copy(n.boundingSphere),Zm.applyMatrix4(r),Zm.radius+=i,e.ray.intersectsSphere(Zm)===!1)return;Ym.copy(r).invert(),Xm.copy(e.ray).applyMatrix4(Ym);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,c=n.index,l=n.attributes.position;if(c!==null){let n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let a=n,o=i;a<o;a++){let n=c.getX(a);Qm.fromBufferAttribute(l,n),eh(Qm,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(l.count,a.start+a.count);for(let a=n,o=i;a<o;a++)Qm.fromBufferAttribute(l,a),eh(Qm,a,s,r,e,t,this)}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){let t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}};function eh(e,t,n,r,i,a,o){let s=Xm.distanceSqToPoint(e);if(s<n){let n=new $;Xm.closestPointToPoint(e,n),n.applyMatrix4(r);let c=i.ray.origin.distanceTo(n);if(c<i.near||c>i.far)return;a.push({distance:c,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:o})}}var th=class extends Yd{constructor(e=[],t=301,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},nh=class extends Yd{constructor(e,t,n,r,i,a,o,s,c){super(e,t,n,r,i,a,o,s,c),this.isCanvasTexture=!0,this.needsUpdate=!0}},rh=class extends Yd{constructor(e,t,n=kl,r,i,a,o=vl,s=vl,c,l=Bl,u=1){if(l!==1026&&l!==1027)throw Error(`THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat`);super({width:e,height:t,depth:u},r,i,a,o,s,l,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Gd(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return t.compareFunction=this.compareFunction,t}},ih=class extends rh{constructor(e,t=kl,n=301,r,i,a=vl,o=vl,s,c=Bl){let l={width:e,height:e,depth:1},u=[l,l,l,l,l,l];super(e,e,t,n,r,i,a,o,s,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}},ah=class extends Yd{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}},oh=class e extends Rp{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new Ep(c,3)),this.setAttribute(`normal`,new Ep(l,3)),this.setAttribute(`uv`,new Ep(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new $;for(let a=0;a<w;a++){let o=a*y-x;for(let s=0;s<C;s++)D[e]=(s*v-b)*r,D[t]=o*i,D[n]=S,c.push(D.x,D.y,D.z),D[e]=0,D[t]=0,D[n]=m>0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e<g;e++)for(let t=0;t<h;t++){let n=d+t+C*e,r=d+t+C*(e+1),i=d+(t+1)+C*(e+1),a=d+(t+1)+C*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(f,E,_),f+=E,d+=T}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}},sh=class e extends Rp{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=Math.PI*2){super(),this.type=`CylinderGeometry`,this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};let c=this;r=Math.floor(r),i=Math.floor(i);let l=[],u=[],d=[],f=[],p=0,m=[],h=n/2,g=0;_(),a===!1&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(l),this.setAttribute(`position`,new Ep(u,3)),this.setAttribute(`normal`,new Ep(d,3)),this.setAttribute(`uv`,new Ep(f,2));function _(){let a=new $,_=new $,v=0,y=(t-e)/n;for(let c=0;c<=i;c++){let l=[],g=c/i,v=g*(t-e)+e;for(let e=0;e<=r;e++){let t=e/r,i=t*s+o,c=Math.sin(i),m=Math.cos(i);_.x=v*c,_.y=-g*n+h,_.z=v*m,u.push(_.x,_.y,_.z),a.set(c,y,m).normalize(),d.push(a.x,a.y,a.z),f.push(t,1-g),l.push(p++)}m.push(l)}for(let n=0;n<r;n++)for(let r=0;r<i;r++){let a=m[r][n],o=m[r+1][n],s=m[r+1][n+1],c=m[r][n+1];(e>0||r!==0)&&(l.push(a,o,c),v+=3),(t>0||r!==i-1)&&(l.push(o,s,c),v+=3)}c.addGroup(g,v,0),g+=v}function v(n){let i=p,a=new Q,m=new $,_=0,v=n===!0?e:t,y=n===!0?1:-1;for(let e=1;e<=r;e++)u.push(0,h*y,0),d.push(0,y,0),f.push(.5,.5),p++;let b=p;for(let e=0;e<=r;e++){let t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);m.x=v*i,m.y=h*y,m.z=v*n,u.push(m.x,m.y,m.z),d.push(0,y,0),a.x=n*.5+.5,a.y=i*.5*y+.5,f.push(a.x,a.y),p++}for(let e=0;e<r;e++){let t=i+e,r=b+e;n===!0?l.push(r,r+1,t):l.push(r+1,r,t),_+=3}c.addGroup(g,_,n===!0?1:2),g+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}},ch=new $,lh=new $,uh=new $,dh=new $f,fh=class extends Rp{constructor(e=null,t=1){if(super(),this.type=`EdgesGeometry`,this.parameters={geometry:e,thresholdAngle:t},e!==null){let n=1e4,r=Math.cos(ad*t),i=e.getIndex(),a=e.getAttribute(`position`),o=i?i.count:a.count,s=[0,0,0],c=[`a`,`b`,`c`],l=[,,,],u=new Map,d=[];for(let e=0;e<o;e+=3){i?(s[0]=i.getX(e),s[1]=i.getX(e+1),s[2]=i.getX(e+2)):(s[0]=e,s[1]=e+1,s[2]=e+2);let{a:t,b:o,c:f}=dh;if(t.fromBufferAttribute(a,s[0]),o.fromBufferAttribute(a,s[1]),f.fromBufferAttribute(a,s[2]),dh.getNormal(uh),l[0]=`${Math.round(t.x*n)},${Math.round(t.y*n)},${Math.round(t.z*n)}`,l[1]=`${Math.round(o.x*n)},${Math.round(o.y*n)},${Math.round(o.z*n)}`,l[2]=`${Math.round(f.x*n)},${Math.round(f.y*n)},${Math.round(f.z*n)}`,l[0]!==l[1]&&l[1]!==l[2]&&l[2]!==l[0])for(let e=0;e<3;e++){let t=(e+1)%3,n=l[e],i=l[t],a=dh[c[e]],o=dh[c[t]],f=`${n}_${i}`,p=`${i}_${n}`,m=u.get(p);m?(uh.dot(m.normal)<=r&&(d.push(a.x,a.y,a.z),d.push(o.x,o.y,o.z)),u.set(p,null)):u.has(f)||u.set(f,{index0:s[e],index1:s[t],normal:uh.clone()})}}for(let e of u.values())if(e){let{index0:t,index1:n}=e;ch.fromBufferAttribute(a,t),lh.fromBufferAttribute(a,n),d.push(ch.x,ch.y,ch.z),d.push(lh.x,lh.y,lh.z)}this.setAttribute(`position`,new Ep(d,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},ph=class e extends Rp{constructor(e=1,t=1,n=1,r=1){super(),this.type=`PlaneGeometry`,this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),c=o+1,l=s+1,u=e/o,d=t/s,f=[],p=[],m=[],h=[];for(let e=0;e<l;e++){let t=e*d-a;for(let n=0;n<c;n++){let r=n*u-i;p.push(r,-t,0),m.push(0,0,1),h.push(n/o),h.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){let n=t+c*e,r=t+c*(e+1),i=t+1+c*(e+1),a=t+1+c*e;f.push(n,r,a),f.push(r,i,a)}this.setIndex(f),this.setAttribute(`position`,new Ep(p,3)),this.setAttribute(`normal`,new Ep(m,3)),this.setAttribute(`uv`,new Ep(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(t){return new e(t.width,t.height,t.widthSegments,t.heightSegments)}},mh=class extends Rp{constructor(e=null){if(super(),this.type=`WireframeGeometry`,this.parameters={geometry:e},e!==null){let t=[],n=new Set,r=new $,i=new $;if(e.index!==null){let a=e.attributes.position,o=e.index,s=e.groups;s.length===0&&(s=[{start:0,count:o.count,materialIndex:0}]);for(let e=0,c=s.length;e<c;++e){let c=s[e],l=c.start,u=c.count;for(let e=l,s=l+u;e<s;e+=3)for(let s=0;s<3;s++){let c=o.getX(e+s),l=o.getX(e+(s+1)%3);r.fromBufferAttribute(a,c),i.fromBufferAttribute(a,l),hh(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}}else{let a=e.attributes.position;for(let e=0,o=a.count/3;e<o;e++)for(let o=0;o<3;o++){let s=3*e+o,c=3*e+(o+1)%3;r.fromBufferAttribute(a,s),i.fromBufferAttribute(a,c),hh(r,i,n)===!0&&(t.push(r.x,r.y,r.z),t.push(i.x,i.y,i.z))}}this.setAttribute(`position`,new Ep(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};function hh(e,t,n){let r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return n.has(r)===!0||n.has(i)===!0?!1:(n.add(r),n.add(i),!0)}function gh(e){let t={};for(let n in e){t[n]={};for(let r in e[n]){let i=e[n][r];if(vh(i))i.isRenderTargetTexture?(Zu(`UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms().`),t[n][r]=null):t[n][r]=i.clone();else if(Array.isArray(i)){if(vh(i[0])){let e=[];for(let t=0,n=i.length;t<n;t++)e[t]=i[t].clone();t[n][r]=e}else t[n][r]=i.slice()}else t[n][r]=i}}return t}function _h(e){let t={};for(let n=0;n<e.length;n++){let r=gh(e[n]);for(let e in r)t[e]=r[e]}return t}function vh(e){return e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture||e.isQuaternion)}function yh(e){let t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}function bh(e){let t=e.getRenderTarget();return t===null?e.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:zd.workingColorSpace}var xh={clone:gh,merge:_h},Sh=`void main() {
|
|
8
8
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
9
9
|
}`,Ch=`void main() {
|
|
10
10
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
@@ -4177,7 +4177,7 @@ Material Type: `+t.type+`
|
|
|
4177
4177
|
|
|
4178
4178
|
Program Info Log: `+o+`
|
|
4179
4179
|
`+e+`
|
|
4180
|
-
`+n)}}else o===``?(s===``||c===``)&&(u=!1):Zu(`WebGLProgram: Program Info Log:`,o);u&&(t.diagnostics={runnable:l,programLog:o,vertexShader:{log:s,prefix:h},fragmentShader:{log:c,prefix:g}})}i.deleteShader(b),i.deleteShader(x),C=new ry(i,m),w=vy(i,m)}let C;this.getUniforms=function(){return C===void 0&&S(this),C};let w;this.getAttributes=function(){return w===void 0&&S(this),w};let T=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return T===!1&&(T=i.getProgramParameter(m,ay)),T},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=oy++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=b,this.fragmentShader=x,this}var Iy=0,Ly=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 e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.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 Ry(e),t.set(e,n)),n}},Ry=class{constructor(e){this.id=Iy++,this.code=e,this.usedTimes=0}};function zy(e){return e===1030||e===37490||e===36285}function By(e,t,n,r,i,a){let o=new pf,s=new Ly,c=new Set,l=[],u=new Map,d=r.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 p(e){return c.add(e),e===0?`uv`:`uv${e}`}function m(i,o,l,u,m,h){let g=u.fog,_=m.geometry,v=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?u.environment:null,y=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,b=t.get(i.envMap||v,y),x=f[i.type],S=r.precision;i.precision!==null&&(S=r.getMaxPrecision(i.precision),S!==i.precision&&Zu(`WebGLProgram.getParameters:`,i.precision,`not supported, using`,S,`instead.`));let C=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,w=C===void 0?0:C.length,T=0;_.morphAttributes.position!==void 0&&(T=1),_.morphAttributes.normal!==void 0&&(T=2),_.morphAttributes.color!==void 0&&(T=3);let E,D,O,k;if(x){let e=m_[x];E=e.vertexShader,D=e.fragmentShader}else{E=i.vertexShader,D=i.fragmentShader;let e=s.getVertexShaderStage(i),t=s.getFragmentShaderStage(i);s.update(i,e,t),O=e.id,k=t.id}let A=e.getRenderTarget(),j=e.state.buffers.depth.getReversed(),M=m.isInstancedMesh===!0,N=m.isBatchedMesh===!0,P=!!i.map,F=!!i.matcap,I=!!b,ee=I&&b.isPMREMTexture===!0,te=!!i.aoMap,L=!!i.lightMap,R=!!i.bumpMap&&i.wireframe===!1,z=!!i.normalMap,B=!!i.displacementMap,ne=!!i.emissiveMap,re=!!i.metalnessMap,ie=!!i.roughnessMap,ae=i.anisotropy>0,V=i.clearcoat>0,H=i.diffuseRoughness>0,U=i.dispersion>0,W=i.retroreflectivity>0,oe=i.iridescence>0,G=i.sheen>0,se=i.transmission>0,K=ae&&!!i.anisotropyMap,ce=V&&!!i.clearcoatMap,q=V&&!!i.clearcoatNormalMap,le=V&&!!i.clearcoatRoughnessMap,J=H&&!!i.diffuseRoughnessMap,Y=oe&&!!i.iridescenceMap,ue=oe&&!!i.iridescenceThicknessMap,de=G&&!!i.sheenColorMap,fe=G&&!!i.sheenRoughnessMap,X=!!i.specularMap,pe=!!i.specularColorMap,me=!!i.specularIntensityMap,Z=se&&!!i.transmissionMap,he=se&&!!i.thicknessMap,ge=!!i.gradientMap,_e=!!i.alphaMap,ve=i.alphaTest>0,ye=!!i.alphaHash,be=!!i.extensions,xe=0;i.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(xe=e.toneMapping);let Se=ee?b.isCompressedCubeTexture?b.image[0].mipmaps:b.mipmaps:null,Ce={shaderID:x,shaderType:i.type,shaderName:i.name,vertexShader:E,fragmentShader:D,defines:i.defines,customVertexShaderID:O,customFragmentShaderID:k,isRawShaderMaterial:i.isRawShaderMaterial===!0,glslVersion:i.glslVersion,precision:S,batching:N,batchingColor:N&&m._colorsTexture!==null,instancing:M,instancingColor:M&&m.instanceColor!==null,instancingMorph:M&&m.morphTexture!==null,outputColorSpace:A===null?e.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:zd.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:P,matcap:F,envMap:I,envMapMode:I&&b.mapping,envMapPMREM:ee,envMapMaxLod:ee?Se.length-1:null,envMapSize:ee?Se[0].width:null,aoMap:te,lightMap:L,bumpMap:R,normalMap:z,displacementMap:B,emissiveMap:ne,normalMapObjectSpace:z&&i.normalMapType===1,normalMapTangentSpace:z&&i.normalMapType===0,packedNormalMap:z&&i.normalMapType===0&&zy(i.normalMap.format),metalnessMap:re,roughnessMap:ie,anisotropy:ae,anisotropyMap:K,clearcoat:V,clearcoatMap:ce,clearcoatNormalMap:q,clearcoatRoughnessMap:le,diffuseRoughness:H,diffuseRoughnessMap:J,dispersion:U,retroreflection:W,iridescence:oe,iridescenceMap:Y,iridescenceThicknessMap:ue,sheen:G,sheenColorMap:de,sheenRoughnessMap:fe,specularMap:X,specularColorMap:pe,specularIntensityMap:me,transmission:se,transmissionMap:Z,thicknessMap:he,gradientMap:ge,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:_e,alphaTest:ve,alphaHash:ye,combine:i.combine,mapUv:P&&p(i.map.channel),aoMapUv:te&&p(i.aoMap.channel),lightMapUv:L&&p(i.lightMap.channel),bumpMapUv:R&&p(i.bumpMap.channel),normalMapUv:z&&p(i.normalMap.channel),displacementMapUv:B&&p(i.displacementMap.channel),emissiveMapUv:ne&&p(i.emissiveMap.channel),metalnessMapUv:re&&p(i.metalnessMap.channel),roughnessMapUv:ie&&p(i.roughnessMap.channel),anisotropyMapUv:K&&p(i.anisotropyMap.channel),clearcoatMapUv:ce&&p(i.clearcoatMap.channel),clearcoatNormalMapUv:q&&p(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:le&&p(i.clearcoatRoughnessMap.channel),diffuseRoughnessMapUv:J&&p(i.diffuseRoughnessMap.channel),iridescenceMapUv:Y&&p(i.iridescenceMap.channel),iridescenceThicknessMapUv:ue&&p(i.iridescenceThicknessMap.channel),sheenColorMapUv:de&&p(i.sheenColorMap.channel),sheenRoughnessMapUv:fe&&p(i.sheenRoughnessMap.channel),specularMapUv:X&&p(i.specularMap.channel),specularColorMapUv:pe&&p(i.specularColorMap.channel),specularIntensityMapUv:me&&p(i.specularIntensityMap.channel),transmissionMapUv:Z&&p(i.transmissionMap.channel),thicknessMapUv:he&&p(i.thicknessMap.channel),alphaMapUv:_e&&p(i.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(z||ae),vertexNormals:!!_.attributes.normal,vertexColors:i.vertexColors,vertexAlphas:i.vertexColors===!0&&!!_.attributes.color&&_.attributes.color.itemSize===4,pointsUvs:m.isPoints===!0&&!!_.attributes.uv&&(P||_e),fog:!!g,useFog:i.fog===!0,fogExp2:!!g&&g.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||_.attributes.normal===void 0&&z===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:j,skinning:m.isSkinnedMesh===!0,hasPositionAttribute:_.attributes.position!==void 0,morphTargets:_.morphAttributes.position!==void 0,morphNormals:_.morphAttributes.normal!==void 0,morphColors:_.morphAttributes.color!==void 0,morphTargetsCount:w,morphTextureStride:T,numSunLights:o.sun.length,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numSunLightShadows:o.sunShadowMap.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:h.filter(e=>e.texture!==null).length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:xe,decodeVideoTexture:P&&i.map.isVideoTexture===!0&&zd.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:ne&&i.emissiveMap.isVideoTexture===!0&&zd.getTransfer(i.emissiveMap.colorSpace)===`srgb`,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===2,flipSided:i.side===1,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:be&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(be&&i.extensions.multiDraw===!0||N)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return Ce.vertexUv1s=c.has(1),Ce.vertexUv2s=c.has(2),Ce.vertexUv3s=c.has(3),c.clear(),Ce}function h(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(g(n,t),_(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function g(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapPMREM),e.push(t.envMapMaxLod),e.push(t.envMapSize),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.diffuseRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.numSunLights),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numSunLightShadows),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.numLightProbeGrids),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function _(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.retroreflection&&o.enable(24),t.diffuseRoughness&&o.enable(25),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),t.hasPositionAttribute&&o.enable(23),e.push(o.mask)}function v(e){let t=f[e.type],n;if(t){let e=m_[t];n=xh.clone(e.uniforms)}else n=e.uniforms;return n}function y(t,n){let r=u.get(n);return r===void 0?(r=new Fy(e,n,t,i),l.push(r),u.set(n,r)):++r.usedTimes,r}function b(e){if(--e.usedTimes===0){let t=l.indexOf(e);l[t]=l[l.length-1],l.pop(),u.delete(e.cacheKey),e.destroy()}}function x(e){s.remove(e)}function S(){s.dispose()}return{getParameters:m,getProgramCacheKey:h,getUniforms:v,acquireProgram:y,releaseProgram:b,releaseShaderCache:x,programs:l,dispose:S}}function Vy(){let e=new WeakMap;function t(t){return e.has(t)}function n(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}function r(t){e.delete(t)}function i(t,n,r){e.get(t)[n]=r}function a(){e=new WeakMap}return{has:t,get:n,remove:r,update:i,dispose:a}}function Hy(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.material.id===t.material.id?e.materialVariant===t.materialVariant?e.z===t.z?e.id-t.id:e.z-t.z:e.materialVariant-t.materialVariant:e.material.id-t.material.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function Uy(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function Wy(){let e=[],t=0,n=[],r=[],i=[];function a(){t=0,n.length=0,r.length=0,i.length=0}function o(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function s(n,r,i,a,s,c){let l=e[t];return l===void 0?(l={id:n.id,object:n,geometry:r,material:i,materialVariant:o(n),groupOrder:a,renderOrder:n.renderOrder,z:s,group:c},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.materialVariant=o(n),l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=c),t++,l}function c(e,t,a,o,c,l,u){u.reversedDepth===!0&&(c=-c);let d=s(e,t,a,o,c,l);a.transmission>0?r.push(d):a.transparent===!0?i.push(d):n.push(d)}function l(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function u(e,t){n.length>1&&n.sort(e||Hy),r.length>1&&r.sort(t||Uy),i.length>1&&i.sort(t||Uy)}function d(){for(let n=t,r=e.length;n<r;n++){let t=e[n];if(t.id===null)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:c,unshift:l,finish:d,sort:u}}function Gy(){let e=new WeakMap;function t(t,n){let r=e.get(t),i;return r===void 0?(i=new Wy,e.set(t,[i])):n>=r.length?(i=new Wy,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function Ky(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`SunLight`:case`DirectionalLight`:n={direction:new $,color:new Lf};break;case`SpotLight`:n={position:new $,direction:new $,color:new Lf,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new $,color:new Lf,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new $,skyColor:new Lf,groundColor:new Lf};break;case`RectAreaLight`:n={color:new Lf,position:new $,halfWidth:new $,halfHeight:new $}}return e[t.id]=n,n}}}function qy(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`SunLight`:case`DirectionalLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}var Jy=0;function Yy(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function Xy(e){let t=new Ky,n=qy(),r={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 e=0;e<9;e++)r.probe.push(new $);let i=new $,a=new tf,o=new tf;function s(i){let a=0,o=0,s=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0;i.sort(Yy);for(let e=0,S=i.length;e<S;e++){let S=i[e],C=S.color,w=S.intensity,T=S.distance,E=null;if(S.shadow&&S.shadow.map&&(E=S.shadow.map.texture.format===1030?S.shadow.map.texture:S.shadow.map.depthTexture||S.shadow.map.texture),S.isAmbientLight)a+=C.r*w,o+=C.g*w,s+=C.b*w;else if(S.isLightProbe){for(let e=0;e<9;e++)r.probe[e].addScaledVector(S.sh.coefficients[e],w);x++}else if(S.isSunLight){let e=t.get(S);if(e.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){let e=S.shadow,t=n.get(S);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize.copy(e.mapSize).multiply(e.getFrameExtents()),r.sunShadow[l]=t,r.sunShadowMap[l]=E;let i=e.getViewportCount();for(let t=0;t<i;t++)r.sunShadowMatrix[u+t]=e.getMatrix(t),r.sunShadowCascade[u+t]=e._cascadeData[t];u+=i,l++}r.sun[c]=e,c++}else if(S.isDirectionalLight){let e=t.get(S);if(e.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){let e=S.shadow,t=n.get(S);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,r.directionalShadow[d]=t,r.directionalShadowMap[d]=E,r.directionalShadowMatrix[d]=S.shadow.matrix,g++}r.directional[d]=e,d++}else if(S.isSpotLight){let e=t.get(S);e.position.setFromMatrixPosition(S.matrixWorld),e.color.copy(C).multiplyScalar(w),e.distance=T,e.coneCos=Math.cos(S.angle),e.penumbraCos=Math.cos(S.angle*(1-S.penumbra)),e.decay=S.decay,r.spot[p]=e;let i=S.shadow;if(S.map&&(r.spotLightMap[y]=S.map,y++,i.updateMatrices(S),S.castShadow&&b++),r.spotLightMatrix[p]=i.matrix,S.castShadow){let e=n.get(S);e.shadowIntensity=i.intensity,e.shadowBias=i.bias,e.shadowNormalBias=i.normalBias,e.shadowRadius=i.radius,e.shadowMapSize=i.mapSize,r.spotShadow[p]=e,r.spotShadowMap[p]=E,v++}p++}else if(S.isRectAreaLight){let e=t.get(S);e.color.copy(C).multiplyScalar(w),e.halfWidth.set(S.width*.5,0,0),e.halfHeight.set(0,S.height*.5,0),r.rectArea[m]=e,m++}else if(S.isPointLight){let e=t.get(S);if(e.color.copy(S.color).multiplyScalar(S.intensity),e.distance=S.distance,e.decay=S.decay,S.castShadow){let e=S.shadow,t=n.get(S);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,r.pointShadow[f]=t,r.pointShadowMap[f]=E,r.pointShadowMatrix[f]=S.shadow.matrix,_++}r.point[f]=e,f++}else if(S.isHemisphereLight){let e=t.get(S);e.skyColor.copy(S.color).multiplyScalar(w),e.groundColor.copy(S.groundColor).multiplyScalar(w),r.hemi[h]=e,h++}}m>0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=p_.LTC_FLOAT_1,r.rectAreaLTC2=p_.LTC_FLOAT_2):(r.rectAreaLTC1=p_.LTC_HALF_1,r.rectAreaLTC2=p_.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let S=r.hash;(S.sunLength!==c||S.directionalLength!==d||S.pointLength!==f||S.spotLength!==p||S.rectAreaLength!==m||S.hemiLength!==h||S.numSunShadows!==l||S.numDirectionalShadows!==g||S.numPointShadows!==_||S.numSpotShadows!==v||S.numSpotMaps!==y||S.numLightProbes!==x)&&(r.sun.length=c,r.directional.length=d,r.spot.length=p,r.rectArea.length=m,r.point.length=f,r.hemi.length=h,r.sunShadow.length=l,r.sunShadowMap.length=l,r.sunShadowMatrix.length=u,r.sunShadowCascade.length=u,r.directionalShadow.length=g,r.directionalShadowMap.length=g,r.directionalShadowMatrix.length=g,r.pointShadow.length=_,r.pointShadowMap.length=_,r.pointShadowMatrix.length=_,r.spotShadow.length=v,r.spotShadowMap.length=v,r.spotLightMatrix.length=v+y-b,r.spotLightMap.length=y,r.numSpotLightShadowsWithMaps=b,r.numLightProbes=x,S.sunLength=c,S.directionalLength=d,S.pointLength=f,S.spotLength=p,S.rectAreaLength=m,S.hemiLength=h,S.numSunShadows=l,S.numDirectionalShadows=g,S.numPointShadows=_,S.numSpotShadows=v,S.numSpotMaps=y,S.numLightProbes=x,r.version=Jy++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=0,f=t.matrixWorldInverse;for(let t=0,p=e.length;t<p;t++){let p=e[t];if(p.isSunLight){let e=r.sun[n];e.direction.setFromMatrixPosition(p.matrixWorld),e.direction.transformDirection(f),n++}else if(p.isDirectionalLight){let e=r.directional[s];e.direction.setFromMatrixPosition(p.matrixWorld),i.setFromMatrixPosition(p.target.matrixWorld),e.direction.sub(i),e.direction.transformDirection(f),s++}else if(p.isSpotLight){let e=r.spot[l];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(f),e.direction.setFromMatrixPosition(p.matrixWorld),i.setFromMatrixPosition(p.target.matrixWorld),e.direction.sub(i),e.direction.transformDirection(f),l++}else if(p.isRectAreaLight){let e=r.rectArea[u];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(f),o.identity(),a.copy(p.matrixWorld),a.premultiply(f),o.extractRotation(a),e.halfWidth.set(p.width*.5,0,0),e.halfHeight.set(0,p.height*.5,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),u++}else if(p.isPointLight){let e=r.point[c];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(f),c++}else if(p.isHemisphereLight){let e=r.hemi[d];e.direction.setFromMatrixPosition(p.matrixWorld),e.direction.transformDirection(f),d++}}}return{setup:s,setupView:c,state:r}}function Zy(e){let t=new Xy(e),n=[],r=[],i=[];function a(e){u.camera=e,n.length=0,r.length=0,i.length=0}function o(e){e.isLightProbeGrid?i.push(e):n.push(e)}function s(e){r.push(e)}function c(){t.setup(n),i.sort((e,t)=>e.priority-t.priority||e.id-t.id)}function l(e){t.setupView(n,e)}let u={lightsArray:n,shadowsArray:r,lightProbeGridArray:i,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:a,state:u,setupLights:c,setupLightsView:l,pushLight:o,pushShadow:s}}function Qy(e){let t=new WeakMap;function n(n,r=0){let i=t.get(n),a;return i===void 0?(a=new Zy(e),t.set(n,[a])):r>=i.length?(a=new Zy(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var $y=`void main() {
|
|
4180
|
+
`+n)}}else o===``?(s===``||c===``)&&(u=!1):Zu(`WebGLProgram: Program Info Log:`,o);u&&(t.diagnostics={runnable:l,programLog:o,vertexShader:{log:s,prefix:h},fragmentShader:{log:c,prefix:g}})}i.deleteShader(b),i.deleteShader(x),C=new ry(i,m),w=vy(i,m)}let C;this.getUniforms=function(){return C===void 0&&S(this),C};let w;this.getAttributes=function(){return w===void 0&&S(this),w};let T=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return T===!1&&(T=i.getProgramParameter(m,ay)),T},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(m),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=oy++,this.cacheKey=t,this.usedTimes=1,this.program=m,this.vertexShader=b,this.fragmentShader=x,this}var Iy=0,Ly=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 e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.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 Ry(e),t.set(e,n)),n}},Ry=class{constructor(e){this.id=Iy++,this.code=e,this.usedTimes=0}};function zy(e){return e===1030||e===37490||e===36285}function By(e,t,n,r,i,a){let o=new pf,s=new Ly,c=new Set,l=[],u=new Map,d=r.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 p(e){return c.add(e),e===0?`uv`:`uv${e}`}function m(i,o,l,u,m,h){let g=u.fog,_=m.geometry,v=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?u.environment:null,y=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap,b=t.get(i.envMap||v,y),x=f[i.type],S=r.precision;i.precision!==null&&(S=r.getMaxPrecision(i.precision),S!==i.precision&&Zu(`WebGLProgram.getParameters:`,i.precision,`not supported, using`,S,`instead.`));let C=_.morphAttributes.position||_.morphAttributes.normal||_.morphAttributes.color,w=C===void 0?0:C.length,T=0;_.morphAttributes.position!==void 0&&(T=1),_.morphAttributes.normal!==void 0&&(T=2),_.morphAttributes.color!==void 0&&(T=3);let E,D,O,k;if(x){let e=m_[x];E=e.vertexShader,D=e.fragmentShader}else{E=i.vertexShader,D=i.fragmentShader;let e=s.getVertexShaderStage(i),t=s.getFragmentShaderStage(i);s.update(i,e,t),O=e.id,k=t.id}let A=e.getRenderTarget(),j=e.state.buffers.depth.getReversed(),M=m.isInstancedMesh===!0,N=m.isBatchedMesh===!0,P=!!i.map,F=!!i.matcap,ee=!!b,te=ee&&b.isPMREMTexture===!0,ne=!!i.aoMap,I=!!i.lightMap,L=!!i.bumpMap&&i.wireframe===!1,R=!!i.normalMap,z=!!i.displacementMap,re=!!i.emissiveMap,B=!!i.metalnessMap,ie=!!i.roughnessMap,ae=i.anisotropy>0,V=i.clearcoat>0,H=i.diffuseRoughness>0,U=i.dispersion>0,W=i.retroreflectivity>0,oe=i.iridescence>0,G=i.sheen>0,se=i.transmission>0,K=ae&&!!i.anisotropyMap,ce=V&&!!i.clearcoatMap,q=V&&!!i.clearcoatNormalMap,le=V&&!!i.clearcoatRoughnessMap,J=H&&!!i.diffuseRoughnessMap,Y=oe&&!!i.iridescenceMap,ue=oe&&!!i.iridescenceThicknessMap,de=G&&!!i.sheenColorMap,fe=G&&!!i.sheenRoughnessMap,X=!!i.specularMap,pe=!!i.specularColorMap,me=!!i.specularIntensityMap,Z=se&&!!i.transmissionMap,he=se&&!!i.thicknessMap,ge=!!i.gradientMap,_e=!!i.alphaMap,ve=i.alphaTest>0,ye=!!i.alphaHash,be=!!i.extensions,xe=0;i.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(xe=e.toneMapping);let Se=te?b.isCompressedCubeTexture?b.image[0].mipmaps:b.mipmaps:null,Ce={shaderID:x,shaderType:i.type,shaderName:i.name,vertexShader:E,fragmentShader:D,defines:i.defines,customVertexShaderID:O,customFragmentShaderID:k,isRawShaderMaterial:i.isRawShaderMaterial===!0,glslVersion:i.glslVersion,precision:S,batching:N,batchingColor:N&&m._colorsTexture!==null,instancing:M,instancingColor:M&&m.instanceColor!==null,instancingMorph:M&&m.morphTexture!==null,outputColorSpace:A===null?e.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:zd.workingColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:P,matcap:F,envMap:ee,envMapMode:ee&&b.mapping,envMapPMREM:te,envMapMaxLod:te?Se.length-1:null,envMapSize:te?Se[0].width:null,aoMap:ne,lightMap:I,bumpMap:L,normalMap:R,displacementMap:z,emissiveMap:re,normalMapObjectSpace:R&&i.normalMapType===1,normalMapTangentSpace:R&&i.normalMapType===0,packedNormalMap:R&&i.normalMapType===0&&zy(i.normalMap.format),metalnessMap:B,roughnessMap:ie,anisotropy:ae,anisotropyMap:K,clearcoat:V,clearcoatMap:ce,clearcoatNormalMap:q,clearcoatRoughnessMap:le,diffuseRoughness:H,diffuseRoughnessMap:J,dispersion:U,retroreflection:W,iridescence:oe,iridescenceMap:Y,iridescenceThicknessMap:ue,sheen:G,sheenColorMap:de,sheenRoughnessMap:fe,specularMap:X,specularColorMap:pe,specularIntensityMap:me,transmission:se,transmissionMap:Z,thicknessMap:he,gradientMap:ge,opaque:i.transparent===!1&&i.blending===1&&i.alphaToCoverage===!1,alphaMap:_e,alphaTest:ve,alphaHash:ye,combine:i.combine,mapUv:P&&p(i.map.channel),aoMapUv:ne&&p(i.aoMap.channel),lightMapUv:I&&p(i.lightMap.channel),bumpMapUv:L&&p(i.bumpMap.channel),normalMapUv:R&&p(i.normalMap.channel),displacementMapUv:z&&p(i.displacementMap.channel),emissiveMapUv:re&&p(i.emissiveMap.channel),metalnessMapUv:B&&p(i.metalnessMap.channel),roughnessMapUv:ie&&p(i.roughnessMap.channel),anisotropyMapUv:K&&p(i.anisotropyMap.channel),clearcoatMapUv:ce&&p(i.clearcoatMap.channel),clearcoatNormalMapUv:q&&p(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:le&&p(i.clearcoatRoughnessMap.channel),diffuseRoughnessMapUv:J&&p(i.diffuseRoughnessMap.channel),iridescenceMapUv:Y&&p(i.iridescenceMap.channel),iridescenceThicknessMapUv:ue&&p(i.iridescenceThicknessMap.channel),sheenColorMapUv:de&&p(i.sheenColorMap.channel),sheenRoughnessMapUv:fe&&p(i.sheenRoughnessMap.channel),specularMapUv:X&&p(i.specularMap.channel),specularColorMapUv:pe&&p(i.specularColorMap.channel),specularIntensityMapUv:me&&p(i.specularIntensityMap.channel),transmissionMapUv:Z&&p(i.transmissionMap.channel),thicknessMapUv:he&&p(i.thicknessMap.channel),alphaMapUv:_e&&p(i.alphaMap.channel),vertexTangents:!!_.attributes.tangent&&(R||ae),vertexNormals:!!_.attributes.normal,vertexColors:i.vertexColors,vertexAlphas:i.vertexColors===!0&&!!_.attributes.color&&_.attributes.color.itemSize===4,pointsUvs:m.isPoints===!0&&!!_.attributes.uv&&(P||_e),fog:!!g,useFog:i.fog===!0,fogExp2:!!g&&g.isFogExp2,flatShading:i.wireframe===!1&&(i.flatShading===!0||_.attributes.normal===void 0&&R===!1&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:j,skinning:m.isSkinnedMesh===!0,hasPositionAttribute:_.attributes.position!==void 0,morphTargets:_.morphAttributes.position!==void 0,morphNormals:_.morphAttributes.normal!==void 0,morphColors:_.morphAttributes.color!==void 0,morphTargetsCount:w,morphTextureStride:T,numSunLights:o.sun.length,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numSunLightShadows:o.sunShadowMap.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numLightProbeGrids:h.filter(e=>e.texture!==null).length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:xe,decodeVideoTexture:P&&i.map.isVideoTexture===!0&&zd.getTransfer(i.map.colorSpace)===`srgb`,decodeVideoTextureEmissive:re&&i.emissiveMap.isVideoTexture===!0&&zd.getTransfer(i.emissiveMap.colorSpace)===`srgb`,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===2,flipSided:i.side===1,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:be&&i.extensions.clipCullDistance===!0&&n.has(`WEBGL_clip_cull_distance`),extensionMultiDraw:(be&&i.extensions.multiDraw===!0||N)&&n.has(`WEBGL_multi_draw`),rendererExtensionParallelShaderCompile:n.has(`KHR_parallel_shader_compile`),customProgramCacheKey:i.customProgramCacheKey()};return Ce.vertexUv1s=c.has(1),Ce.vertexUv2s=c.has(2),Ce.vertexUv3s=c.has(3),c.clear(),Ce}function h(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(g(n,t),_(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function g(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapPMREM),e.push(t.envMapMaxLod),e.push(t.envMapSize),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.diffuseRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.numSunLights),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numSunLightShadows),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.numLightProbeGrids),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function _(e,t){o.disableAll(),t.instancing&&o.enable(0),t.instancingColor&&o.enable(1),t.instancingMorph&&o.enable(2),t.matcap&&o.enable(3),t.envMap&&o.enable(4),t.normalMapObjectSpace&&o.enable(5),t.normalMapTangentSpace&&o.enable(6),t.clearcoat&&o.enable(7),t.iridescence&&o.enable(8),t.alphaTest&&o.enable(9),t.vertexColors&&o.enable(10),t.vertexAlphas&&o.enable(11),t.vertexUv1s&&o.enable(12),t.vertexUv2s&&o.enable(13),t.vertexUv3s&&o.enable(14),t.vertexTangents&&o.enable(15),t.anisotropy&&o.enable(16),t.alphaHash&&o.enable(17),t.batching&&o.enable(18),t.dispersion&&o.enable(19),t.retroreflection&&o.enable(24),t.diffuseRoughness&&o.enable(25),t.batchingColor&&o.enable(20),t.gradientMap&&o.enable(21),t.packedNormalMap&&o.enable(22),t.vertexNormals&&o.enable(23),e.push(o.mask),o.disableAll(),t.fog&&o.enable(0),t.useFog&&o.enable(1),t.flatShading&&o.enable(2),t.logarithmicDepthBuffer&&o.enable(3),t.reversedDepthBuffer&&o.enable(4),t.skinning&&o.enable(5),t.morphTargets&&o.enable(6),t.morphNormals&&o.enable(7),t.morphColors&&o.enable(8),t.premultipliedAlpha&&o.enable(9),t.shadowMapEnabled&&o.enable(10),t.doubleSided&&o.enable(11),t.flipSided&&o.enable(12),t.useDepthPacking&&o.enable(13),t.dithering&&o.enable(14),t.transmission&&o.enable(15),t.sheen&&o.enable(16),t.opaque&&o.enable(17),t.pointsUvs&&o.enable(18),t.decodeVideoTexture&&o.enable(19),t.decodeVideoTextureEmissive&&o.enable(20),t.alphaToCoverage&&o.enable(21),t.numLightProbeGrids>0&&o.enable(22),t.hasPositionAttribute&&o.enable(23),e.push(o.mask)}function v(e){let t=f[e.type],n;if(t){let e=m_[t];n=xh.clone(e.uniforms)}else n=e.uniforms;return n}function y(t,n){let r=u.get(n);return r===void 0?(r=new Fy(e,n,t,i),l.push(r),u.set(n,r)):++r.usedTimes,r}function b(e){if(--e.usedTimes===0){let t=l.indexOf(e);l[t]=l[l.length-1],l.pop(),u.delete(e.cacheKey),e.destroy()}}function x(e){s.remove(e)}function S(){s.dispose()}return{getParameters:m,getProgramCacheKey:h,getUniforms:v,acquireProgram:y,releaseProgram:b,releaseShaderCache:x,programs:l,dispose:S}}function Vy(){let e=new WeakMap;function t(t){return e.has(t)}function n(t){let n=e.get(t);return n===void 0&&(n={},e.set(t,n)),n}function r(t){e.delete(t)}function i(t,n,r){e.get(t)[n]=r}function a(){e=new WeakMap}return{has:t,get:n,remove:r,update:i,dispose:a}}function Hy(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.material.id===t.material.id?e.materialVariant===t.materialVariant?e.z===t.z?e.id-t.id:e.z-t.z:e.materialVariant-t.materialVariant:e.material.id-t.material.id:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function Uy(e,t){return e.groupOrder===t.groupOrder?e.renderOrder===t.renderOrder?e.z===t.z?e.id-t.id:t.z-e.z:e.renderOrder-t.renderOrder:e.groupOrder-t.groupOrder}function Wy(){let e=[],t=0,n=[],r=[],i=[];function a(){t=0,n.length=0,r.length=0,i.length=0}function o(e){let t=0;return e.isInstancedMesh&&(t+=2),e.isSkinnedMesh&&(t+=1),t}function s(n,r,i,a,s,c){let l=e[t];return l===void 0?(l={id:n.id,object:n,geometry:r,material:i,materialVariant:o(n),groupOrder:a,renderOrder:n.renderOrder,z:s,group:c},e[t]=l):(l.id=n.id,l.object=n,l.geometry=r,l.material=i,l.materialVariant=o(n),l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=c),t++,l}function c(e,t,a,o,c,l,u){u.reversedDepth===!0&&(c=-c);let d=s(e,t,a,o,c,l);a.transmission>0?r.push(d):a.transparent===!0?i.push(d):n.push(d)}function l(e,t,a,o,c,l){let u=s(e,t,a,o,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function u(e,t){n.length>1&&n.sort(e||Hy),r.length>1&&r.sort(t||Uy),i.length>1&&i.sort(t||Uy)}function d(){for(let n=t,r=e.length;n<r;n++){let t=e[n];if(t.id===null)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:c,unshift:l,finish:d,sort:u}}function Gy(){let e=new WeakMap;function t(t,n){let r=e.get(t),i;return r===void 0?(i=new Wy,e.set(t,[i])):n>=r.length?(i=new Wy,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function Ky(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`SunLight`:case`DirectionalLight`:n={direction:new $,color:new Lf};break;case`SpotLight`:n={position:new $,direction:new $,color:new Lf,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new $,color:new Lf,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new $,skyColor:new Lf,groundColor:new Lf};break;case`RectAreaLight`:n={color:new Lf,position:new $,halfWidth:new $,halfHeight:new $}}return e[t.id]=n,n}}}function qy(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`SunLight`:case`DirectionalLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q};break;case`SpotLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q};break;case`PointLight`:n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Q,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}var Jy=0;function Yy(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function Xy(e){let t=new Ky,n=qy(),r={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 e=0;e<9;e++)r.probe.push(new $);let i=new $,a=new tf,o=new tf;function s(i){let a=0,o=0,s=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0,x=0;i.sort(Yy);for(let e=0,S=i.length;e<S;e++){let S=i[e],C=S.color,w=S.intensity,T=S.distance,E=null;if(S.shadow&&S.shadow.map&&(E=S.shadow.map.texture.format===1030?S.shadow.map.texture:S.shadow.map.depthTexture||S.shadow.map.texture),S.isAmbientLight)a+=C.r*w,o+=C.g*w,s+=C.b*w;else if(S.isLightProbe){for(let e=0;e<9;e++)r.probe[e].addScaledVector(S.sh.coefficients[e],w);x++}else if(S.isSunLight){let e=t.get(S);if(e.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){let e=S.shadow,t=n.get(S);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize.copy(e.mapSize).multiply(e.getFrameExtents()),r.sunShadow[l]=t,r.sunShadowMap[l]=E;let i=e.getViewportCount();for(let t=0;t<i;t++)r.sunShadowMatrix[u+t]=e.getMatrix(t),r.sunShadowCascade[u+t]=e._cascadeData[t];u+=i,l++}r.sun[c]=e,c++}else if(S.isDirectionalLight){let e=t.get(S);if(e.color.copy(S.color).multiplyScalar(S.intensity),S.castShadow){let e=S.shadow,t=n.get(S);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,r.directionalShadow[d]=t,r.directionalShadowMap[d]=E,r.directionalShadowMatrix[d]=S.shadow.matrix,g++}r.directional[d]=e,d++}else if(S.isSpotLight){let e=t.get(S);e.position.setFromMatrixPosition(S.matrixWorld),e.color.copy(C).multiplyScalar(w),e.distance=T,e.coneCos=Math.cos(S.angle),e.penumbraCos=Math.cos(S.angle*(1-S.penumbra)),e.decay=S.decay,r.spot[p]=e;let i=S.shadow;if(S.map&&(r.spotLightMap[y]=S.map,y++,i.updateMatrices(S),S.castShadow&&b++),r.spotLightMatrix[p]=i.matrix,S.castShadow){let e=n.get(S);e.shadowIntensity=i.intensity,e.shadowBias=i.bias,e.shadowNormalBias=i.normalBias,e.shadowRadius=i.radius,e.shadowMapSize=i.mapSize,r.spotShadow[p]=e,r.spotShadowMap[p]=E,v++}p++}else if(S.isRectAreaLight){let e=t.get(S);e.color.copy(C).multiplyScalar(w),e.halfWidth.set(S.width*.5,0,0),e.halfHeight.set(0,S.height*.5,0),r.rectArea[m]=e,m++}else if(S.isPointLight){let e=t.get(S);if(e.color.copy(S.color).multiplyScalar(S.intensity),e.distance=S.distance,e.decay=S.decay,S.castShadow){let e=S.shadow,t=n.get(S);t.shadowIntensity=e.intensity,t.shadowBias=e.bias,t.shadowNormalBias=e.normalBias,t.shadowRadius=e.radius,t.shadowMapSize=e.mapSize,t.shadowCameraNear=e.camera.near,t.shadowCameraFar=e.camera.far,r.pointShadow[f]=t,r.pointShadowMap[f]=E,r.pointShadowMatrix[f]=S.shadow.matrix,_++}r.point[f]=e,f++}else if(S.isHemisphereLight){let e=t.get(S);e.skyColor.copy(S.color).multiplyScalar(w),e.groundColor.copy(S.groundColor).multiplyScalar(w),r.hemi[h]=e,h++}}m>0&&(e.has(`OES_texture_float_linear`)===!0?(r.rectAreaLTC1=p_.LTC_FLOAT_1,r.rectAreaLTC2=p_.LTC_FLOAT_2):(r.rectAreaLTC1=p_.LTC_HALF_1,r.rectAreaLTC2=p_.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=o,r.ambient[2]=s;let S=r.hash;(S.sunLength!==c||S.directionalLength!==d||S.pointLength!==f||S.spotLength!==p||S.rectAreaLength!==m||S.hemiLength!==h||S.numSunShadows!==l||S.numDirectionalShadows!==g||S.numPointShadows!==_||S.numSpotShadows!==v||S.numSpotMaps!==y||S.numLightProbes!==x)&&(r.sun.length=c,r.directional.length=d,r.spot.length=p,r.rectArea.length=m,r.point.length=f,r.hemi.length=h,r.sunShadow.length=l,r.sunShadowMap.length=l,r.sunShadowMatrix.length=u,r.sunShadowCascade.length=u,r.directionalShadow.length=g,r.directionalShadowMap.length=g,r.directionalShadowMatrix.length=g,r.pointShadow.length=_,r.pointShadowMap.length=_,r.pointShadowMatrix.length=_,r.spotShadow.length=v,r.spotShadowMap.length=v,r.spotLightMatrix.length=v+y-b,r.spotLightMap.length=y,r.numSpotLightShadowsWithMaps=b,r.numLightProbes=x,S.sunLength=c,S.directionalLength=d,S.pointLength=f,S.spotLength=p,S.rectAreaLength=m,S.hemiLength=h,S.numSunShadows=l,S.numDirectionalShadows=g,S.numPointShadows=_,S.numSpotShadows=v,S.numSpotMaps=y,S.numLightProbes=x,r.version=Jy++)}function c(e,t){let n=0,s=0,c=0,l=0,u=0,d=0,f=t.matrixWorldInverse;for(let t=0,p=e.length;t<p;t++){let p=e[t];if(p.isSunLight){let e=r.sun[n];e.direction.setFromMatrixPosition(p.matrixWorld),e.direction.transformDirection(f),n++}else if(p.isDirectionalLight){let e=r.directional[s];e.direction.setFromMatrixPosition(p.matrixWorld),i.setFromMatrixPosition(p.target.matrixWorld),e.direction.sub(i),e.direction.transformDirection(f),s++}else if(p.isSpotLight){let e=r.spot[l];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(f),e.direction.setFromMatrixPosition(p.matrixWorld),i.setFromMatrixPosition(p.target.matrixWorld),e.direction.sub(i),e.direction.transformDirection(f),l++}else if(p.isRectAreaLight){let e=r.rectArea[u];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(f),o.identity(),a.copy(p.matrixWorld),a.premultiply(f),o.extractRotation(a),e.halfWidth.set(p.width*.5,0,0),e.halfHeight.set(0,p.height*.5,0),e.halfWidth.applyMatrix4(o),e.halfHeight.applyMatrix4(o),u++}else if(p.isPointLight){let e=r.point[c];e.position.setFromMatrixPosition(p.matrixWorld),e.position.applyMatrix4(f),c++}else if(p.isHemisphereLight){let e=r.hemi[d];e.direction.setFromMatrixPosition(p.matrixWorld),e.direction.transformDirection(f),d++}}}return{setup:s,setupView:c,state:r}}function Zy(e){let t=new Xy(e),n=[],r=[],i=[];function a(e){u.camera=e,n.length=0,r.length=0,i.length=0}function o(e){e.isLightProbeGrid?i.push(e):n.push(e)}function s(e){r.push(e)}function c(){t.setup(n),i.sort((e,t)=>e.priority-t.priority||e.id-t.id)}function l(e){t.setupView(n,e)}let u={lightsArray:n,shadowsArray:r,lightProbeGridArray:i,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:a,state:u,setupLights:c,setupLightsView:l,pushLight:o,pushShadow:s}}function Qy(e){let t=new WeakMap;function n(n,r=0){let i=t.get(n),a;return i===void 0?(a=new Zy(e),t.set(n,[a])):r>=i.length?(a=new Zy(e),i.push(a)):a=i[r],a}function r(){t=new WeakMap}return{get:n,dispose:r}}var $y=`void main() {
|
|
4181
4181
|
gl_Position = vec4( position, 1.0 );
|
|
4182
4182
|
}`,eb=`uniform sampler2D shadow_pass;
|
|
4183
4183
|
uniform vec2 resolution;
|
|
@@ -4204,7 +4204,7 @@ void main() {
|
|
|
4204
4204
|
squared_mean = squared_mean / samples;
|
|
4205
4205
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4206
4206
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4207
|
-
}`,tb=[new $(1,0,0),new $(-1,0,0),new $(0,1,0),new $(0,-1,0),new $(0,0,1),new $(0,0,-1)],nb=[new $(0,-1,0),new $(0,-1,0),new $(0,0,1),new $(0,0,-1),new $(0,-1,0),new $(0,-1,0)],rb=new tf,ib=new $,ab=new $;function ob(e,t,n){let r=new Fm,i=new Q,a=new Q,o=new Xd,s=new kh,c=new Ah,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new wh({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Q},radius:{value:4}},vertexShader:$y,fragmentShader:eb}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Rp;m.setAttribute(`position`,new Cp(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new Om(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;this.render=function(t,n,s){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||t.length===0)return;this.type===2&&(Zu(`WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead.`),this.type=1);let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.depth.getReversed()===!0?f.buffers.color.setClear(0,0,0,0):f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let c=0,l=t.length;c<l;c++){let l=t[c],d=l.shadow;if(d===void 0){Zu(`WebGLShadowMap:`,l,`has no shadow.`);continue}if(d.autoUpdate===!1&&d.needsUpdate===!1)continue;i.copy(d.mapSize);let m=d.getFrameExtents();i.multiply(m),a.copy(d.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/m.x),i.x=a.x*m.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/m.y),i.y=a.y*m.y,d.mapSize.y=a.y));let h=e.state.buffers.depth.getReversed();if(d.camera._reversedDepth=h,d.map===null||p===!0){if(d.map!==null&&(d.map.depthTexture!==null&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),this.type===3){if(l.isPointLight){Zu(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new Qd(i.x,i.y,{format:Wl,type:jl,minFilter:xl,magFilter:xl,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new rh(i.x,i.y,Al),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=Bl,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=vl,d.map.depthTexture.magFilter=vl}else l.isPointLight?(d.map=new C_(i.x),d.map.depthTexture=new ih(i.x,kl)):(d.map=new Qd(i.x,i.y),d.map.depthTexture=new rh(i.x,i.y,kl)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=Bl,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=xl,d.map.depthTexture.magFilter=xl):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=vl,d.map.depthTexture.magFilter=vl);d.camera.updateProjectionMatrix()}d.map.isWebGLCubeRenderTarget!==!0&&(d.map.width!==i.x||d.map.height!==i.y)&&d.map.setSize(i.x,i.y);let g=d.map.isWebGLCubeRenderTarget?6:d.getViewportCount();l.isPointLight!==!0&&d.updateMatrices(l,s);let _=d.camera.layers.mask&4294967294?d.camera.layers:s.layers;for(let t=0;t<g;t++){let i=d.getCamera(t);if(l.isPointLight){let e=d.camera,n=d.matrix,r=l.distance||e.far;r!==e.far&&(e.far=r,e.updateProjectionMatrix()),ib.setFromMatrixPosition(l.matrixWorld),e.position.copy(ib),ab.copy(e.position),ab.add(tb[t]),e.up.copy(nb[t]),e.lookAt(ab),e.updateMatrixWorld(),n.makeTranslation(-ib.x,-ib.y,-ib.z),rb.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),d._frustum.setFromProjectionMatrix(rb,e.coordinateSystem,e.reversedDepth)}if(d.map.isWebGLCubeRenderTarget)e.setRenderTarget(d.map,t),e.clear();else{t===0&&(e.setRenderTarget(d.map),e.clear());let n=d.getViewport(t);o.set(a.x*n.x,a.y*n.y,a.x*n.z,a.y*n.w),f.viewport(o)}r=d.getFrustum(t),b(n,s,i,l,_,this.type)}d.isPointLightShadow!==!0&&this.type===3&&v(d,s),d.needsUpdate=!1}_=this.type,g.needsUpdate=!1,e.setRenderTarget(c,l,d)};function v(n,r){let a=t.update(h);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),n.mapPass===null?n.mapPass=new Qd(i.x,i.y,{format:Wl,type:jl}):(n.mapPass.width!==n.map.width||n.mapPass.height!==n.map.height)&&n.mapPass.setSize(n.map.width,n.map.height),f.uniforms.shadow_pass.value=n.map.depthTexture,f.uniforms.resolution.value.set(n.map.width,n.map.height),f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,a,f,h,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value.set(n.map.width,n.map.height),p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,a,p,h,null)}function y(t,n,r,i){let a=null,o=r.isPointLight===!0?t.customDistanceMaterial:t.customDepthMaterial;if(o!==void 0)a=o;else if(a=r.isPointLight===!0?c:s,e.localClippingEnabled&&n.clipShadows===!0&&Array.isArray(n.clippingPlanes)&&n.clippingPlanes.length!==0||n.displacementMap&&n.displacementScale!==0||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||n.alphaToCoverage===!0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,x)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaToCoverage===!0?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s,c){if(n.visible===!1)return;if(n.layers.test(s)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&c===3)&&(!n.frustumCulled||n.intersectsFrustum(r))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),s=n.material;if(Array.isArray(s)){let t=r.groups;for(let l=0,u=t.length;l<u;l++){let u=t[l],d=s[u.materialIndex];if(d&&d.visible){let t=y(n,d,o,c);n.onBeforeShadow(e,n,i,a,r,t,u),e.renderBufferDirect(a,null,r,t,n,u),n.onAfterShadow(e,n,i,a,r,t,u)}}}else if(s.visible){let t=y(n,s,o,c);n.onBeforeShadow(e,n,i,a,r,t,null),e.renderBufferDirect(a,null,r,t,n,null),n.onAfterShadow(e,n,i,a,r,t,null)}}let l=n.children;for(let e=0,t=l.length;e<t;e++)b(l[e],i,a,o,s,c)}function x(e){e.target.removeEventListener(`dispose`,x);for(let t in l){let n=l[t],r=e.target.uuid;r in n&&(n[r].dispose(),delete n[r])}}}function sb(e,t){function n(){let t=!1,n=new Xd,r=null,i=new Xd(0,0,0,0);return{setMask:function(n){r!==n&&!t&&(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,a,o,s){s===!0&&(t*=o,r*=o,a*=o),n.set(t,r,a,o),i.equals(n)===!1&&(e.clearColor(t,r,a,o),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}}function r(){let n=!1,r=!1,i=null,a=null,o=null;return{setReversed:function(e){if(r!==e){let n=t.get(`EXT_clip_control`);e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),r=e;let i=o;o=null,this.setClear(i)}},getReversed:function(){return r},setTest:function(t){t?re(e.DEPTH_TEST):ie(e.DEPTH_TEST)},setMask:function(t){i!==t&&!n&&(e.depthMask(t),i=t)},setFunc:function(t){if(r&&(t=td[t]),a!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}a=t}},setLocked:function(e){n=e},setClear:function(t){o!==t&&(o=t,r&&(t=1-t),e.clearDepth(t))},reset:function(){n=!1,i=null,a=null,o=null,r=!1}}}function i(){let t=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(n){t||(n?re(e.STENCIL_TEST):ie(e.STENCIL_TEST))},setMask:function(r){n!==r&&!t&&(e.stencilMask(r),n=r)},setFunc:function(t,n,o){(r!==t||i!==n||a!==o)&&(e.stencilFunc(t,n,o),r=t,i=n,a=o)},setOp:function(t,n,r){(o!==t||s!==n||c!==r)&&(e.stencilOp(t,n,r),o=t,s=n,c=r)},setLocked:function(e){t=e},setClear:function(t){l!==t&&(e.clearStencil(t),l=t)},reset:function(){t=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null}}}let a=new n,o=new r,s=new i,c={},l=new WeakMap,u={},d={},f={},p=new WeakMap,m=[],h=null,g=!1,_=null,v=null,y=null,b=null,x=null,S=null,C=null,w=new Lf(0,0,0),T=0,E=!1,D=null,O=null,k=null,A=null,j=null,M=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),N=!1,P=0,F=e.getParameter(e.VERSION);F.indexOf(`WebGL`)===-1?F.indexOf(`OpenGL ES`)!==-1&&(P=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),N=P>=2):(P=parseFloat(/^WebGL (\d)/.exec(F)[1]),N=P>=1);let I=null,ee={},te=e.getParameter(e.SCISSOR_BOX),L=e.getParameter(e.VIEWPORT),R=new Xd().fromArray(te),z=new Xd().fromArray(L);function B(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<r;o++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,i,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a);return o}let ne={};ne[e.TEXTURE_2D]=B(e.TEXTURE_2D,e.TEXTURE_2D,1),ne[e.TEXTURE_CUBE_MAP]=B(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),ne[e.TEXTURE_2D_ARRAY]=B(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),ne[e.TEXTURE_3D]=B(e.TEXTURE_3D,e.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),s.setClear(0),re(e.DEPTH_TEST),o.setFunc(3),se(!1),K(1),re(e.CULL_FACE),oe(0);function re(t){u[t]!==!0&&(e.enable(t),u[t]=!0)}function ie(t){u[t]!==!1&&(e.disable(t),u[t]=!1)}function ae(t,n){return f[t]!==n&&(e.bindFramebuffer(t,n),f[t]=n,t===e.DRAW_FRAMEBUFFER&&(f[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(f[e.DRAW_FRAMEBUFFER]=n),!0)}function V(t,n){let r=m,i=!1;if(t){r=p.get(n),r===void 0&&(r=[],p.set(n,r));let a=t.textures;if(r.length!==a.length||r[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=a.length;t<n;t++)r[t]=e.COLOR_ATTACHMENT0+t;r.length=a.length,i=!0}}else r[0]!==e.BACK&&(r[0]=e.BACK,i=!0);i&&e.drawBuffers(r)}function H(t){return h!==t&&(e.useProgram(t),h=t,!0)}let U={100:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT};U[103]=e.MIN,U[104]=e.MAX;let W={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA,211:e.CONSTANT_COLOR,212:e.ONE_MINUS_CONSTANT_COLOR,213:e.CONSTANT_ALPHA,214:e.ONE_MINUS_CONSTANT_ALPHA};function oe(t,n,r,i,a,o,s,c,l,u){if(t===0)g===!0&&(ie(e.BLEND),g=!1);else if(g===!1&&(re(e.BLEND),g=!0),t!==5){if(t!==_||u!==E){if((v!==100||x!==100)&&(e.blendEquation(e.FUNC_ADD),v=100,x=100),u)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Qu(`WebGLState: Invalid blending: `,t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case 3:Qu(`WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true`);break;case 4:Qu(`WebGLState: MultiplyBlending requires material.premultipliedAlpha = true`);break;default:Qu(`WebGLState: Invalid blending: `,t)}y=null,b=null,S=null,C=null,w.set(0,0,0),T=0,_=t,E=u}}else a||=n,o||=r,s||=i,(n!==v||a!==x)&&(e.blendEquationSeparate(U[n],U[a]),v=n,x=a),(r!==y||i!==b||o!==S||s!==C)&&(e.blendFuncSeparate(W[r],W[i],W[o],W[s]),y=r,b=i,S=o,C=s),(c.equals(w)===!1||l!==T)&&(e.blendColor(c.r,c.g,c.b,l),w.copy(c),T=l),_=t,E=!1}function G(t,n){t.side===2?ie(e.CULL_FACE):re(e.CULL_FACE);let r=t.side===1;n&&(r=!r),se(r),t.blending===1&&t.transparent===!1?oe(0):oe(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),o.setFunc(t.depthFunc),o.setTest(t.depthTest),o.setMask(t.depthWrite),a.setMask(t.colorWrite);let i=t.stencilWrite;s.setTest(i),i&&(s.setMask(t.stencilWriteMask),s.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),s.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),q(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),t.alphaToCoverage===!0?re(e.SAMPLE_ALPHA_TO_COVERAGE):ie(e.SAMPLE_ALPHA_TO_COVERAGE)}function se(t){D!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),D=t)}function K(t){t===0?ie(e.CULL_FACE):(re(e.CULL_FACE),t!==O&&(t===1?e.cullFace(e.BACK):t===2?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))),O=t}function ce(t){t!==k&&(N&&e.lineWidth(t),k=t)}function q(t,n,r){t?(re(e.POLYGON_OFFSET_FILL),(A!==n||j!==r)&&(A=n,j=r,o.getReversed()&&(n=-n,r=-r),e.polygonOffset(n,r))):ie(e.POLYGON_OFFSET_FILL)}function le(t){t?re(e.SCISSOR_TEST):ie(e.SCISSOR_TEST)}function J(t){t===void 0&&(t=e.TEXTURE0+M-1),I!==t&&(e.activeTexture(t),I=t)}function Y(t,n,r){r===void 0&&(r=I===null?e.TEXTURE0+M-1:I);let i=ee[r];i===void 0&&(i={type:void 0,texture:void 0},ee[r]=i),(i.type!==t||i.texture!==n)&&(I!==r&&(e.activeTexture(r),I=r),e.bindTexture(t,n||ne[t]),i.type=t,i.texture=n)}function ue(){let t=ee[I];t!==void 0&&t.type!==void 0&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)}function de(){try{e.compressedTexImage2D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function fe(){try{e.compressedTexImage3D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function X(){try{e.texSubImage2D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function pe(){try{e.texSubImage3D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function me(){try{e.compressedTexSubImage2D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function Z(){try{e.compressedTexSubImage3D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function he(){try{e.texStorage2D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function ge(){try{e.texStorage3D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function _e(){try{e.texImage2D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function ve(){try{e.texImage3D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function ye(t){return d[t]===void 0?e.getParameter(t):d[t]}function be(t,n){d[t]!==n&&(e.pixelStorei(t,n),d[t]=n)}function xe(t){R.equals(t)===!1&&(e.scissor(t.x,t.y,t.z,t.w),R.copy(t))}function Se(t){z.equals(t)===!1&&(e.viewport(t.x,t.y,t.z,t.w),z.copy(t))}function Ce(t,n){let r=l.get(n);r===void 0&&(r=new WeakMap,l.set(n,r));let i=r.get(t);i===void 0&&(i=e.getUniformBlockIndex(n,t.name),e.uniformBlockBinding(n,i,i),r.set(t,i))}function we(t,n,r){let i=l.get(n).get(t);c[i]!==r&&(e.bindBufferBase(e.UNIFORM_BUFFER,i,r),c[i]=r)}function Te(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},I=null,ee={},f={},c={},p=new WeakMap,m=[],h=null,g=!1,_=null,v=null,y=null,b=null,x=null,S=null,C=null,w=new Lf(0,0,0),T=0,E=!1,D=null,O=null,k=null,A=null,j=null,R.set(0,0,e.canvas.width,e.canvas.height),z.set(0,0,e.canvas.width,e.canvas.height),a.reset(),o.reset(),s.reset()}return{buffers:{color:a,depth:o,stencil:s},enable:re,disable:ie,bindFramebuffer:ae,drawBuffers:V,useProgram:H,setBlending:oe,setMaterial:G,setFlipSided:se,setCullFace:K,setLineWidth:ce,setPolygonOffset:q,setScissorTest:le,activeTexture:J,bindTexture:Y,unbindTexture:ue,compressedTexImage2D:de,compressedTexImage3D:fe,texImage2D:_e,texImage3D:ve,pixelStorei:be,getParameter:ye,updateUBOMapping:Ce,uniformBlockBinding:we,texStorage2D:he,texStorage3D:ge,texSubImage2D:X,texSubImage3D:pe,compressedTexSubImage2D:me,compressedTexSubImage3D:Z,scissor:xe,viewport:Se,reset:Te}}function cb(e,t,n,r,i,a,o){let s=t.has(`WEBGL_multisampled_render_to_texture`)?t.get(`WEBGL_multisampled_render_to_texture`):null,c=typeof navigator>`u`?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Q,u=new WeakMap,d=new Set,f,p=new WeakMap,m=new Set,h=new FinalizationRegistry(e=>m.delete(e)),g=!1;try{g=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function _(e,t){return g?new OffscreenCanvas(e,t):Ku(`canvas`)}function v(e,t,n){let r=1,i=he(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);f===void 0&&(f=_(n,a));let o=t?_(n,a):f;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),Zu(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}return`data`in e&&Zu(`WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e}return e}function y(e){return e.generateMipmaps}function b(t){e.generateMipmap(t)}function x(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function S(n,r,i,a,o,s=!1){if(n!==null){if(e[n]!==void 0)return e[n];Zu(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||Zu(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=r;if(r===e.RED&&(i===e.FLOAT&&(l=e.R32F),i===e.HALF_FLOAT&&(l=e.R16F),i===e.UNSIGNED_BYTE&&(l=e.R8),i===e.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),i===e.SHORT&&c&&(l=c.R16_SNORM_EXT)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.R8UI),i===e.UNSIGNED_SHORT&&(l=e.R16UI),i===e.UNSIGNED_INT&&(l=e.R32UI),i===e.BYTE&&(l=e.R8I),i===e.SHORT&&(l=e.R16I),i===e.INT&&(l=e.R32I)),r===e.RG&&(i===e.FLOAT&&(l=e.RG32F),i===e.HALF_FLOAT&&(l=e.RG16F),i===e.UNSIGNED_BYTE&&(l=e.RG8),i===e.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),i===e.SHORT&&c&&(l=c.RG16_SNORM_EXT)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RG8UI),i===e.UNSIGNED_SHORT&&(l=e.RG16UI),i===e.UNSIGNED_INT&&(l=e.RG32UI),i===e.BYTE&&(l=e.RG8I),i===e.SHORT&&(l=e.RG16I),i===e.INT&&(l=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGB8UI),i===e.UNSIGNED_SHORT&&(l=e.RGB16UI),i===e.UNSIGNED_INT&&(l=e.RGB32UI),i===e.BYTE&&(l=e.RGB8I),i===e.SHORT&&(l=e.RGB16I),i===e.INT&&(l=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(l=e.RGBA16UI),i===e.UNSIGNED_INT&&(l=e.RGBA32UI),i===e.BYTE&&(l=e.RGBA8I),i===e.SHORT&&(l=e.RGBA16I),i===e.INT&&(l=e.RGBA32I)),r===e.RGB&&(i===e.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),i===e.SHORT&&c&&(l=c.RGB16_SNORM_EXT),i===e.UNSIGNED_INT_5_9_9_9_REV&&(l=e.RGB9_E5),i===e.UNSIGNED_INT_10F_11F_11F_REV&&(l=e.R11F_G11F_B10F)),r===e.RGBA){let t=s?zu:zd.getTransfer(o);i===e.FLOAT&&(l=e.RGBA32F),i===e.HALF_FLOAT&&(l=e.RGBA16F),i===e.UNSIGNED_BYTE&&(l=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),i===e.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),i===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),l}function C(t,n){let r;return t?n===null||n===1014||n===1020?r=e.DEPTH24_STENCIL8:n===1015?r=e.DEPTH32F_STENCIL8:n===1012&&(r=e.DEPTH24_STENCIL8,Zu(`DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.`)):n===null||n===1014||n===1020?r=e.DEPTH_COMPONENT24:n===1015?r=e.DEPTH_COMPONENT32F:n===1012&&(r=e.DEPTH_COMPONENT16),r}function w(e,t){return y(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function T(e){let t=new WeakRef(e);r.get(e).__ref=t,m.add(t),h.register(e,t,t)}function E(e){let t=r.get(e).__ref;t!==void 0&&(m.delete(t),h.unregister(t))}function D(e){k(e.target)}function O(e){A(e.target)}function k(e){e.removeEventListener(`dispose`,D),E(e),M(e),e.isVideoTexture&&u.delete(e),e.isHTMLTexture&&d.delete(e)}function A(e){e.removeEventListener(`dispose`,O),E(e),P(e)}function j(){for(let e of m){let t=e.deref();t!==void 0&&(t.isRenderTarget===!0?A(t):k(t))}m.clear(),d.clear()}function M(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=p.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&N(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}function N(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=p.get(i);delete a[n.__cacheKey],o.memory.textures--}function P(t){let n=r.get(t);n.__depthDisposeCallback&&n.__depthDisposeCallback();let i=t.depthTexture;if(i&&i.renderTarget===t&&k(i),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r<n.__webglFramebuffer[t].length;r++)e.deleteFramebuffer(n.__webglFramebuffer[t][r]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}let a=t.textures;for(let t=0,n=a.length;t<n;t++){let n=r.get(a[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),o.memory.textures--),r.remove(a[t])}r.remove(t)}let F=0;function I(){F=0}function ee(){return F}function te(e){F=e}function L(){let e=F;return e>=i.maxTextures&&Zu(`WebGLTextures: Trying to use `+(e+1)+` texture units while this GPU supports only `+i.maxTextures),F+=1,e}function R(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.mipmapsAutoUpdate),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function z(t,i){let a=r.get(t);if(t.isVideoTexture&&me(t),t.isRenderTargetTexture===!1&&t.isExternalTexture!==!0&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)Zu(`WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)Zu(`WebGLRenderer: Texture marked for update but image is incomplete`);else{G(a,t,i);return}}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function B(t,i){let a=r.get(t);t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version?G(a,t,i):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i))}function ne(t,i){let a=r.get(t);t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version?G(a,t,i):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function re(t,i){let a=r.get(t);t.version>0&&a.__version!==t.version?se(a,t,i):n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let ie={[hl]:e.REPEAT,[gl]:e.CLAMP_TO_EDGE,[_l]:e.MIRRORED_REPEAT},ae={[vl]:e.NEAREST,[yl]:e.NEAREST_MIPMAP_NEAREST,[bl]:e.NEAREST_MIPMAP_LINEAR,[xl]:e.LINEAR,[Sl]:e.LINEAR_MIPMAP_NEAREST,[Cl]:e.LINEAR_MIPMAP_LINEAR},V={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function H(n,a){if(a.type===1015&&t.has(`OES_texture_float_linear`)===!1&&(a.magFilter===1006||a.magFilter===1007||a.magFilter===1005||a.magFilter===1008||a.minFilter===1006||a.minFilter===1007||a.minFilter===1005||a.minFilter===1008)&&Zu(`WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),e.texParameteri(n,e.TEXTURE_WRAP_S,ie[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,ie[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,ie[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,ae[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,ae[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,V[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1)return;if(a.anisotropy>1||r.get(a).__currentAnisotropy){let o=t.get(`EXT_texture_filter_anisotropic`);e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy}}}function U(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,D),T(n));let i=n.source,a=p.get(i);a===void 0&&(a={},p.set(i,a));let s=R(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&N(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function W(e,t,n){return Math.floor(Math.floor(e/n)/t)}function oe(t,r,i,a){let o=t.updateRanges;if(o.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,i,a,r.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e<o.length;e++){let t=o[s],n=o[e],i=t.start+t.count,a=W(n.start,r.width,4),c=W(t.start,r.width,4);n.start<=i+1&&a===c&&W(n.start+n.count-1,r.width,4)===a?t.count=Math.max(t.count,n.start+n.count-t.start):(++s,o[s]=n)}o.length=s+1;let c=n.getParameter(e.UNPACK_ROW_LENGTH),l=n.getParameter(e.UNPACK_SKIP_PIXELS),u=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,r.width);for(let t=0,s=o.length;t<s;t++){let s=o[t],c=Math.floor(s.start/4),l=Math.ceil(s.count/4),u=c%r.width,d=Math.floor(c/r.width),f=l;n.pixelStorei(e.UNPACK_SKIP_PIXELS,u),n.pixelStorei(e.UNPACK_SKIP_ROWS,d),n.texSubImage2D(e.TEXTURE_2D,0,u,d,f,1,i,a,r.data)}t.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,c),n.pixelStorei(e.UNPACK_SKIP_PIXELS,l),n.pixelStorei(e.UNPACK_SKIP_ROWS,u)}}function G(t,o,s){let c=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(c=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(c=e.TEXTURE_3D);let l=U(t,o),u=o.source;n.bindTexture(c,t.__webglTexture,e.TEXTURE0+s);let f=r.get(u);if(u.version!==f.__version||l===!0){if(n.activeTexture(e.TEXTURE0+s),!(typeof ImageBitmap<`u`&&o.image instanceof ImageBitmap)){let t=zd.getPrimaries(zd.workingColorSpace),r=o.colorSpace===``?null:zd.getPrimaries(o.colorSpace),i=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,i)}n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment);let t=v(o.image,!1,i.maxTextureSize);t=Z(o,t);let r=a.convert(o.format,o.colorSpace),p=a.convert(o.type),m=S(o.internalFormat,r,p,o.normalized,o.colorSpace,o.isVideoTexture);H(c,o);let h,g=o.mipmaps,_=o.isVideoTexture!==!0,x=f.__version===void 0||l===!0,T=u.dataReady,E=w(o,t);if(o.isDepthTexture)m=C(o.format===Vl,o.type),x&&(_?n.texStorage2D(e.TEXTURE_2D,1,m,t.width,t.height):n.texImage2D(e.TEXTURE_2D,0,m,t.width,t.height,0,r,p,null));else if(o.isDataTexture){if(g.length>0){_&&x&&n.texStorage2D(e.TEXTURE_2D,E,m,g[0].width,g[0].height);for(let t=0,i=g.length;t<i;t++)h=g[t],_?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,h.width,h.height,r,p,h.data):n.texImage2D(e.TEXTURE_2D,t,m,h.width,h.height,0,r,p,h.data);o.generateMipmaps=!1}else _?(x&&n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height),T&&oe(o,t,r,p)):n.texImage2D(e.TEXTURE_2D,0,m,t.width,t.height,0,r,p,t.data)}else if(o.isCompressedTexture){if(o.isCompressedArrayTexture){_&&x&&n.texStorage3D(e.TEXTURE_2D_ARRAY,E,m,g[0].width,g[0].height,t.depth);for(let i=0,a=g.length;i<a;i++)if(h=g[i],o.format!==1023){if(r!==null){if(_){if(T){if(o.layerUpdates.size>0){let t=c_(h.width,h.height,o.format,o.type);for(let a of o.layerUpdates){let o=h.data.subarray(a*t/h.data.BYTES_PER_ELEMENT,(a+1)*t/h.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,h.width,h.height,1,r,o)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,h.data)}}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,h.data,0,0)}else Zu(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`)}else _?T&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,p,h.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,r,p,h.data);o.layerUpdates.size>0&&o.clearLayerUpdates()}else{_&&x&&n.texStorage2D(e.TEXTURE_2D,E,m,g[0].width,g[0].height);for(let t=0,i=g.length;t<i;t++)h=g[t],o.format===1023?_?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,h.width,h.height,r,p,h.data):n.texImage2D(e.TEXTURE_2D,t,m,h.width,h.height,0,r,p,h.data):r===null?Zu(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`):_?T&&n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,h.width,h.height,r,h.data):n.compressedTexImage2D(e.TEXTURE_2D,t,m,h.width,h.height,0,h.data)}}else if(o.isDataArrayTexture){if(_){if(x&&n.texStorage3D(e.TEXTURE_2D_ARRAY,E,m,t.width,t.height,t.depth),T){if(o.layerUpdates.size>0){let i=c_(t.width,t.height,o.format,o.type);for(let a of o.layerUpdates){let o=t.data.subarray(a*i/t.data.BYTES_PER_ELEMENT,(a+1)*i/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,a,t.width,t.height,1,r,p,o)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)}}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,m,t.width,t.height,t.depth,0,r,p,t.data)}else if(o.isData3DTexture)_?(x&&n.texStorage3D(e.TEXTURE_3D,E,m,t.width,t.height,t.depth),T&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isFramebufferTexture){if(x){if(_)n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height);else{let i=t.width,a=t.height;for(let t=0;t<E;t++)n.texImage2D(e.TEXTURE_2D,t,m,i,a,0,r,p,null),i>>=1,a>>=1}}}else if(o.isHTMLTexture){if(`texElementImage2D`in e){let n=e.canvas;if(n.hasAttribute(`layoutsubtree`)||n.setAttribute(`layoutsubtree`,`true`),t.parentNode!==n){n.appendChild(t),d.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of d)t.includes(e.image)&&(e.needsUpdate=!0)},n.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,t);else{let n=e.RGBA,r=e.RGBA,i=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,n,r,i,t)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(g.length>0){if(_&&x){let t=he(g[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,i=g.length;t<i;t++)h=g[t],_?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,r,p,h):n.texImage2D(e.TEXTURE_2D,t,m,r,p,h);o.generateMipmaps=!1}else if(_){if(x){let r=he(t);n.texStorage2D(e.TEXTURE_2D,E,m,r.width,r.height)}T&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,r,p,t)}else n.texImage2D(e.TEXTURE_2D,0,m,r,p,t);y(o)&&o.mipmapsAutoUpdate===!0&&b(c),f.__version=u.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function se(t,o,s){if(o.image.length!==6)return;let c=U(t,o),l=o.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let u=r.get(l);if(l.version!==u.__version||c===!0){n.activeTexture(e.TEXTURE0+s);let t=zd.getPrimaries(zd.workingColorSpace),r=o.colorSpace===``?null:zd.getPrimaries(o.colorSpace),d=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let f=o.isCompressedTexture||o.image[0].isCompressedTexture,p=o.image[0]&&o.image[0].isDataTexture,m=[];for(let e=0;e<6;e++)!f&&!p?m[e]=v(o.image[e],!0,i.maxCubemapSize):m[e]=p?o.image[e].image:o.image[e],m[e]=Z(o,m[e]);let h=m[0],g=a.convert(o.format,o.colorSpace),_=a.convert(o.type),x=S(o.internalFormat,g,_,o.normalized,o.colorSpace),T=o.isVideoTexture!==!0,E=u.__version===void 0||c===!0,D=l.dataReady,O=w(o,h);H(e.TEXTURE_CUBE_MAP,o);let k;if(o.isDepthTexture){if(x=C(o.format===Vl,o.type),E){if(T)n.texStorage2D(e.TEXTURE_CUBE_MAP,1,x,h.width,h.height);else for(let t=0;t<6;t++)n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,x,h.width,h.height,0,g,_,null)}}else if(f){T&&E&&n.texStorage2D(e.TEXTURE_CUBE_MAP,O,x,h.width,h.height);for(let t=0;t<6;t++){k=m[t].mipmaps;for(let r=0;r<k.length;r++){let i=k[r];o.format===1023?T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,i.width,i.height,g,_,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,x,i.width,i.height,0,g,_,i.data):g===null?Zu(`WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()`):T?D&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,i.width,i.height,g,i.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,x,i.width,i.height,0,i.data)}}}else{if(k=o.mipmaps,T&&E){k.length>0&&O++;let t=he(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,O,x,t.width,t.height)}for(let t=0;t<6;t++)if(p){T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,g,_,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,x,m[t].width,m[t].height,0,g,_,m[t].data);for(let r=0;r<k.length;r++){let i=k[r].image[t].image;T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,i.width,i.height,g,_,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,x,i.width,i.height,0,g,_,i.data)}}else{T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g,_,m[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,x,g,_,m[t]);for(let r=0;r<k.length;r++){let i=k[r];T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,g,_,i.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,x,g,_,i.image[t])}}}y(o)&&o.mipmapsAutoUpdate===!0&&b(e.TEXTURE_CUBE_MAP),u.__version=l.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function K(t,i,o,c,l,u){let d=a.convert(o.format,o.colorSpace),f=a.convert(o.type),p=S(o.internalFormat,d,f,o.normalized,o.colorSpace),m=r.get(i),h=r.get(o);if(h.__renderTarget=i,!m.__hasExternalTextures){let t=Math.max(1,i.width>>u),r=Math.max(1,i.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,p,t,r,i.depth,0,d,f,null):n.texImage2D(l,u,p,t,r,0,d,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),pe(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,X(i)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,c,l,h.__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function ce(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=C(n.stencilBuffer,a),c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;pe(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,X(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,X(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i<t.length;i++){let o=t[i],c=a.convert(o.format,o.colorSpace),l=a.convert(o.type),u=S(o.internalFormat,c,l,o.normalized,o.colorSpace);pe(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,X(n),u,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,X(n),u,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,u,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function q(t,i,a){let o=i.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,t),!(i.depthTexture&&i.depthTexture.isDepthTexture))throw Error(`THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.`);let c=r.get(i.depthTexture);c.__renderTarget=i;let l=o?i.depthTexture.image[0]:i.depthTexture.image;c.__webglTexture&&l.width===i.width&&l.height===i.height||(l.width=i.width,l.height=i.height,i.depthTexture.needsUpdate=!0),o?re(i.depthTexture,0):z(i.depthTexture,0);let u=c.__webglTexture,d=X(i),f=o?e.TEXTURE_CUBE_MAP_POSITIVE_X+a:e.TEXTURE_2D,p=i.depthTexture.format===1027?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(i.depthTexture.format===1026)pe(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,u,0,d):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,u,0);else if(i.depthTexture.format===1027)pe(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,u,0,d):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,u,0);else throw Error(`THREE.WebGLTextures: Unknown depthTexture format.`)}function le(t){let i=r.get(t),a=t.isWebGLCubeRenderTarget===!0;if(i.__boundDepthTexture!==t.depthTexture){let e=t.depthTexture;if(i.__depthDisposeCallback&&i.__depthDisposeCallback(),e){let t=()=>{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener(`dispose`,t)};e.addEventListener(`dispose`,t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(a)for(let e=0;e<6;e++)q(i.__webglFramebuffer[e],t,e);else t.texture.mipmaps.length>0?q(i.__webglFramebuffer[0],t,0):q(i.__webglFramebuffer,t,0)}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]===void 0)i.__webglDepthbuffer[r]=e.createRenderbuffer(),ce(i.__webglDepthbuffer[r],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=i.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else if(t.texture.mipmaps.length>0?n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer===void 0)i.__webglDepthbuffer=e.createRenderbuffer(),ce(i.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}n.bindFramebuffer(e.FRAMEBUFFER,null)}function J(t,n,i){let a=r.get(t);n!==void 0&&K(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&le(t)}function Y(t){let i=t.texture,s=r.get(t),c=r.get(i);t.addEventListener(`dispose`,O),T(t);let l=t.textures,u=t.isWebGLCubeRenderTarget===!0,d=l.length>1;if(d||(c.__webglTexture===void 0&&(c.__webglTexture=e.createTexture()),c.__version=i.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n<i.mipmaps.length;n++)s.__webglFramebuffer[t][n]=e.createFramebuffer()}else s.__webglFramebuffer[t]=e.createFramebuffer()}else{if(i.mipmaps.length>0){s.__webglFramebuffer=[];for(let t=0;t<i.mipmaps.length;t++)s.__webglFramebuffer[t]=e.createFramebuffer()}else s.__webglFramebuffer=e.createFramebuffer();if(d)for(let t=0,n=l.length;t<n;t++){let n=r.get(l[t]);n.__webglTexture===void 0&&(n.__webglTexture=e.createTexture(),o.memory.textures++)}if(t.samples>0&&pe(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n<l.length;n++){let r=l[n];s.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,s.__webglColorRenderbuffer[n]);let i=a.convert(r.format,r.colorSpace),o=a.convert(r.type),c=S(r.internalFormat,i,o,r.normalized,r.colorSpace,t.isXRRenderTarget===!0),u=X(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,u,c,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,s.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(s.__webglDepthRenderbuffer=e.createRenderbuffer(),ce(s.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){n.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),H(e.TEXTURE_CUBE_MAP,i);for(let n=0;n<6;n++)if(i.mipmaps.length>0)for(let r=0;r<i.mipmaps.length;r++)K(s.__webglFramebuffer[n][r],t,i,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,r);else K(s.__webglFramebuffer[n],t,i,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);y(i)?b(e.TEXTURE_CUBE_MAP):i.mipmaps.length>0&&e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAX_LEVEL,i.mipmaps.length-1),n.unbindTexture()}else if(d){for(let i=0,a=l.length;i<a;i++){let a=l[i],o=r.get(a),c=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(c=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(c,o.__webglTexture),H(c,a),K(s.__webglFramebuffer,t,a,e.COLOR_ATTACHMENT0+i,c,0),y(a)&&b(c)}n.unbindTexture()}else{let r=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(r=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(r,c.__webglTexture),H(r,i),i.mipmaps.length>0)for(let n=0;n<i.mipmaps.length;n++)K(s.__webglFramebuffer[n],t,i,e.COLOR_ATTACHMENT0,r,n);else K(s.__webglFramebuffer,t,i,e.COLOR_ATTACHMENT0,r,0);y(i)?b(r):i.mipmaps.length>0&&e.texParameteri(r,e.TEXTURE_MAX_LEVEL,i.mipmaps.length-1),n.unbindTexture()}t.depthBuffer&&le(t)}function ue(e){let t=e.textures;for(let i=0,a=t.length;i<a;i++){let a=t[i];if(y(a)&&a.mipmapsAutoUpdate===!0){let t=x(e),i=r.get(a).__webglTexture;n.bindTexture(t,i),b(t),n.unbindTexture()}}}let de=[];function fe(t){if(t.samples>0){if(pe(t)===!1){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=i.length>1;if(d)for(let t=0;t<i.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.texture.mipmaps.length>0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<i.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(s|=e.STENCIL_BUFFER_BIT)),d){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,u.__webglColorRenderbuffer[n]);let t=r.get(i[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,o,0,0,a,o,s,e.NEAREST),c===!0&&(de.length=0,de.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&t.storeMultisampledDepthBuffer===!1&&de.push(l),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,de))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),d)for(let t=0;t<i.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,u.__webglColorRenderbuffer[t]);let a=r.get(i[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&t.storeMultisampledDepthBuffer===!1&&c){let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}}}function X(e){return Math.min(i.maxSamples,e.samples)}function pe(e){let n=r.get(e);return e.samples>0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function me(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function Z(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(zd.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&Zu(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):Qu(`WebGLTextures: Unsupported texture color space:`,n)),t}function he(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(l.width=e.naturalWidth||e.width,l.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(l.width=e.displayWidth,l.height=e.displayHeight):(l.width=e.width,l.height=e.height),l}this.allocateTextureUnit=L,this.resetTextureUnits=I,this.getTextureUnits=ee,this.setTextureUnits=te,this.setTexture2D=z,this.setTexture2DArray=B,this.setTexture3D=ne,this.setTextureCube=re,this.rebindTextures=J,this.setupRenderTarget=Y,this.updateRenderTargetMipmap=ue,this.updateMultisampleRenderTarget=fe,this.setupDepthRenderbuffer=le,this.setupFrameBufferTexture=K,this.useMultisampledRTT=pe,this.dispose=j}function lb(e,t){function n(n,r=``){let i,a=zd.getTransfer(r);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===35899)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return e.HALF_FLOAT;if(n===1021)return e.ALPHA;if(n===1022)return e.RGB;if(n===1023)return e.RGBA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779){if(a===`srgb`){if(i=t.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(n===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null}else if(i=t.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(n===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null}if(n===35840||n===35841||n===35842||n===35843){if(i=t.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(n===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null}if(n===36196||n===37492||n===37496||n===37488||n===37489||n===37490||n===37491){if(i=t.get(`WEBGL_compressed_texture_etc`),i!==null){if(n===36196||n===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(n===37488)return i.COMPRESSED_R11_EAC;if(n===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(n===37490)return i.COMPRESSED_RG11_EAC;if(n===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null}if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821){if(i=t.get(`WEBGL_compressed_texture_astc`),i!==null){if(n===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null}if(n===36492||n===36494||n===36495){if(i=t.get(`EXT_texture_compression_bptc`),i!==null){if(n===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null}if(n===36283||n===36284||n===36285||n===36286){if(i=t.get(`EXT_texture_compression_rgtc`),i!==null){if(n===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null}return n===1020?e.UNSIGNED_INT_24_8:e[n]===void 0?null:e[n]}return{convert:n}}var ub=`
|
|
4207
|
+
}`,tb=[new $(1,0,0),new $(-1,0,0),new $(0,1,0),new $(0,-1,0),new $(0,0,1),new $(0,0,-1)],nb=[new $(0,-1,0),new $(0,-1,0),new $(0,0,1),new $(0,0,-1),new $(0,-1,0),new $(0,-1,0)],rb=new tf,ib=new $,ab=new $;function ob(e,t,n){let r=new Fm,i=new Q,a=new Q,o=new Xd,s=new kh,c=new Ah,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new wh({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Q},radius:{value:4}},vertexShader:$y,fragmentShader:eb}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Rp;m.setAttribute(`position`,new Cp(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new Om(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;this.render=function(t,n,s){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||t.length===0)return;this.type===2&&(Zu(`WebGLShadowMap: PCFSoftShadowMap has been removed. Using PCFShadowMap instead.`),this.type=1);let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.depth.getReversed()===!0?f.buffers.color.setClear(0,0,0,0):f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==this.type;p&&n.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let c=0,l=t.length;c<l;c++){let l=t[c],d=l.shadow;if(d===void 0){Zu(`WebGLShadowMap:`,l,`has no shadow.`);continue}if(d.autoUpdate===!1&&d.needsUpdate===!1)continue;i.copy(d.mapSize);let m=d.getFrameExtents();i.multiply(m),a.copy(d.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/m.x),i.x=a.x*m.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/m.y),i.y=a.y*m.y,d.mapSize.y=a.y));let h=e.state.buffers.depth.getReversed();if(d.camera._reversedDepth=h,d.map===null||p===!0){if(d.map!==null&&(d.map.depthTexture!==null&&(d.map.depthTexture.dispose(),d.map.depthTexture=null),d.map.dispose()),this.type===3){if(l.isPointLight){Zu(`WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.`);continue}d.map=new Qd(i.x,i.y,{format:Wl,type:jl,minFilter:xl,magFilter:xl,generateMipmaps:!1}),d.map.texture.name=l.name+`.shadowMap`,d.map.depthTexture=new rh(i.x,i.y,Al),d.map.depthTexture.name=l.name+`.shadowMapDepth`,d.map.depthTexture.format=Bl,d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=vl,d.map.depthTexture.magFilter=vl}else l.isPointLight?(d.map=new C_(i.x),d.map.depthTexture=new ih(i.x,kl)):(d.map=new Qd(i.x,i.y),d.map.depthTexture=new rh(i.x,i.y,kl)),d.map.depthTexture.name=l.name+`.shadowMap`,d.map.depthTexture.format=Bl,this.type===1?(d.map.depthTexture.compareFunction=h?518:515,d.map.depthTexture.minFilter=xl,d.map.depthTexture.magFilter=xl):(d.map.depthTexture.compareFunction=null,d.map.depthTexture.minFilter=vl,d.map.depthTexture.magFilter=vl);d.camera.updateProjectionMatrix()}d.map.isWebGLCubeRenderTarget!==!0&&(d.map.width!==i.x||d.map.height!==i.y)&&d.map.setSize(i.x,i.y);let g=d.map.isWebGLCubeRenderTarget?6:d.getViewportCount();l.isPointLight!==!0&&d.updateMatrices(l,s);let _=d.camera.layers.mask&4294967294?d.camera.layers:s.layers;for(let t=0;t<g;t++){let i=d.getCamera(t);if(l.isPointLight){let e=d.camera,n=d.matrix,r=l.distance||e.far;r!==e.far&&(e.far=r,e.updateProjectionMatrix()),ib.setFromMatrixPosition(l.matrixWorld),e.position.copy(ib),ab.copy(e.position),ab.add(tb[t]),e.up.copy(nb[t]),e.lookAt(ab),e.updateMatrixWorld(),n.makeTranslation(-ib.x,-ib.y,-ib.z),rb.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),d._frustum.setFromProjectionMatrix(rb,e.coordinateSystem,e.reversedDepth)}if(d.map.isWebGLCubeRenderTarget)e.setRenderTarget(d.map,t),e.clear();else{t===0&&(e.setRenderTarget(d.map),e.clear());let n=d.getViewport(t);o.set(a.x*n.x,a.y*n.y,a.x*n.z,a.y*n.w),f.viewport(o)}r=d.getFrustum(t),b(n,s,i,l,_,this.type)}d.isPointLightShadow!==!0&&this.type===3&&v(d,s),d.needsUpdate=!1}_=this.type,g.needsUpdate=!1,e.setRenderTarget(c,l,d)};function v(n,r){let a=t.update(h);f.defines.VSM_SAMPLES!==n.blurSamples&&(f.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,f.needsUpdate=!0,p.needsUpdate=!0),n.mapPass===null?n.mapPass=new Qd(i.x,i.y,{format:Wl,type:jl}):(n.mapPass.width!==n.map.width||n.mapPass.height!==n.map.height)&&n.mapPass.setSize(n.map.width,n.map.height),f.uniforms.shadow_pass.value=n.map.depthTexture,f.uniforms.resolution.value.set(n.map.width,n.map.height),f.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,a,f,h,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value.set(n.map.width,n.map.height),p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,a,p,h,null)}function y(t,n,r,i){let a=null,o=r.isPointLight===!0?t.customDistanceMaterial:t.customDepthMaterial;if(o!==void 0)a=o;else if(a=r.isPointLight===!0?c:s,e.localClippingEnabled&&n.clipShadows===!0&&Array.isArray(n.clippingPlanes)&&n.clippingPlanes.length!==0||n.displacementMap&&n.displacementScale!==0||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||n.alphaToCoverage===!0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i,n.addEventListener(`dispose`,x)),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaToCoverage===!0?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s,c){if(n.visible===!1)return;if(n.layers.test(s)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&c===3)&&(!n.frustumCulled||n.intersectsFrustum(r))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),s=n.material;if(Array.isArray(s)){let t=r.groups;for(let l=0,u=t.length;l<u;l++){let u=t[l],d=s[u.materialIndex];if(d&&d.visible){let t=y(n,d,o,c);n.onBeforeShadow(e,n,i,a,r,t,u),e.renderBufferDirect(a,null,r,t,n,u),n.onAfterShadow(e,n,i,a,r,t,u)}}}else if(s.visible){let t=y(n,s,o,c);n.onBeforeShadow(e,n,i,a,r,t,null),e.renderBufferDirect(a,null,r,t,n,null),n.onAfterShadow(e,n,i,a,r,t,null)}}let l=n.children;for(let e=0,t=l.length;e<t;e++)b(l[e],i,a,o,s,c)}function x(e){e.target.removeEventListener(`dispose`,x);for(let t in l){let n=l[t],r=e.target.uuid;r in n&&(n[r].dispose(),delete n[r])}}}function sb(e,t){function n(){let t=!1,n=new Xd,r=null,i=new Xd(0,0,0,0);return{setMask:function(n){r!==n&&!t&&(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,a,o,s){s===!0&&(t*=o,r*=o,a*=o),n.set(t,r,a,o),i.equals(n)===!1&&(e.clearColor(t,r,a,o),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}}function r(){let n=!1,r=!1,i=null,a=null,o=null;return{setReversed:function(e){if(r!==e){let n=t.get(`EXT_clip_control`);e?n.clipControlEXT(n.LOWER_LEFT_EXT,n.ZERO_TO_ONE_EXT):n.clipControlEXT(n.LOWER_LEFT_EXT,n.NEGATIVE_ONE_TO_ONE_EXT),r=e;let i=o;o=null,this.setClear(i)}},getReversed:function(){return r},setTest:function(t){t?B(e.DEPTH_TEST):ie(e.DEPTH_TEST)},setMask:function(t){i!==t&&!n&&(e.depthMask(t),i=t)},setFunc:function(t){if(r&&(t=td[t]),a!==t){switch(t){case 0:e.depthFunc(e.NEVER);break;case 1:e.depthFunc(e.ALWAYS);break;case 2:e.depthFunc(e.LESS);break;case 3:e.depthFunc(e.LEQUAL);break;case 4:e.depthFunc(e.EQUAL);break;case 5:e.depthFunc(e.GEQUAL);break;case 6:e.depthFunc(e.GREATER);break;case 7:e.depthFunc(e.NOTEQUAL);break;default:e.depthFunc(e.LEQUAL)}a=t}},setLocked:function(e){n=e},setClear:function(t){o!==t&&(o=t,r&&(t=1-t),e.clearDepth(t))},reset:function(){n=!1,i=null,a=null,o=null,r=!1}}}function i(){let t=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null;return{setTest:function(n){t||(n?B(e.STENCIL_TEST):ie(e.STENCIL_TEST))},setMask:function(r){n!==r&&!t&&(e.stencilMask(r),n=r)},setFunc:function(t,n,o){(r!==t||i!==n||a!==o)&&(e.stencilFunc(t,n,o),r=t,i=n,a=o)},setOp:function(t,n,r){(o!==t||s!==n||c!==r)&&(e.stencilOp(t,n,r),o=t,s=n,c=r)},setLocked:function(e){t=e},setClear:function(t){l!==t&&(e.clearStencil(t),l=t)},reset:function(){t=!1,n=null,r=null,i=null,a=null,o=null,s=null,c=null,l=null}}}let a=new n,o=new r,s=new i,c={},l=new WeakMap,u={},d={},f={},p=new WeakMap,m=[],h=null,g=!1,_=null,v=null,y=null,b=null,x=null,S=null,C=null,w=new Lf(0,0,0),T=0,E=!1,D=null,O=null,k=null,A=null,j=null,M=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),N=!1,P=0,F=e.getParameter(e.VERSION);F.indexOf(`WebGL`)===-1?F.indexOf(`OpenGL ES`)!==-1&&(P=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]),N=P>=2):(P=parseFloat(/^WebGL (\d)/.exec(F)[1]),N=P>=1);let ee=null,te={},ne=e.getParameter(e.SCISSOR_BOX),I=e.getParameter(e.VIEWPORT),L=new Xd().fromArray(ne),R=new Xd().fromArray(I);function z(t,n,r,i){let a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;o<r;o++)t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY?e.texImage3D(n,0,e.RGBA,1,1,i,0,e.RGBA,e.UNSIGNED_BYTE,a):e.texImage2D(n+o,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,a);return o}let re={};re[e.TEXTURE_2D]=z(e.TEXTURE_2D,e.TEXTURE_2D,1),re[e.TEXTURE_CUBE_MAP]=z(e.TEXTURE_CUBE_MAP,e.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[e.TEXTURE_2D_ARRAY]=z(e.TEXTURE_2D_ARRAY,e.TEXTURE_2D_ARRAY,1,1),re[e.TEXTURE_3D]=z(e.TEXTURE_3D,e.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),s.setClear(0),B(e.DEPTH_TEST),o.setFunc(3),se(!1),K(1),B(e.CULL_FACE),oe(0);function B(t){u[t]!==!0&&(e.enable(t),u[t]=!0)}function ie(t){u[t]!==!1&&(e.disable(t),u[t]=!1)}function ae(t,n){return f[t]!==n&&(e.bindFramebuffer(t,n),f[t]=n,t===e.DRAW_FRAMEBUFFER&&(f[e.FRAMEBUFFER]=n),t===e.FRAMEBUFFER&&(f[e.DRAW_FRAMEBUFFER]=n),!0)}function V(t,n){let r=m,i=!1;if(t){r=p.get(n),r===void 0&&(r=[],p.set(n,r));let a=t.textures;if(r.length!==a.length||r[0]!==e.COLOR_ATTACHMENT0){for(let t=0,n=a.length;t<n;t++)r[t]=e.COLOR_ATTACHMENT0+t;r.length=a.length,i=!0}}else r[0]!==e.BACK&&(r[0]=e.BACK,i=!0);i&&e.drawBuffers(r)}function H(t){return h!==t&&(e.useProgram(t),h=t,!0)}let U={100:e.FUNC_ADD,101:e.FUNC_SUBTRACT,102:e.FUNC_REVERSE_SUBTRACT};U[103]=e.MIN,U[104]=e.MAX;let W={200:e.ZERO,201:e.ONE,202:e.SRC_COLOR,204:e.SRC_ALPHA,210:e.SRC_ALPHA_SATURATE,208:e.DST_COLOR,206:e.DST_ALPHA,203:e.ONE_MINUS_SRC_COLOR,205:e.ONE_MINUS_SRC_ALPHA,209:e.ONE_MINUS_DST_COLOR,207:e.ONE_MINUS_DST_ALPHA,211:e.CONSTANT_COLOR,212:e.ONE_MINUS_CONSTANT_COLOR,213:e.CONSTANT_ALPHA,214:e.ONE_MINUS_CONSTANT_ALPHA};function oe(t,n,r,i,a,o,s,c,l,u){if(t===0)g===!0&&(ie(e.BLEND),g=!1);else if(g===!1&&(B(e.BLEND),g=!0),t!==5){if(t!==_||u!==E){if((v!==100||x!==100)&&(e.blendEquation(e.FUNC_ADD),v=100,x=100),u)switch(t){case 1:e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFunc(e.ONE,e.ONE);break;case 3:e.blendFuncSeparate(e.ZERO,e.ONE_MINUS_SRC_COLOR,e.ZERO,e.ONE);break;case 4:e.blendFuncSeparate(e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ZERO,e.ONE);break;default:Qu(`WebGLState: Invalid blending: `,t)}else switch(t){case 1:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);break;case 2:e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE);break;case 3:Qu(`WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true`);break;case 4:Qu(`WebGLState: MultiplyBlending requires material.premultipliedAlpha = true`);break;default:Qu(`WebGLState: Invalid blending: `,t)}y=null,b=null,S=null,C=null,w.set(0,0,0),T=0,_=t,E=u}}else a||=n,o||=r,s||=i,(n!==v||a!==x)&&(e.blendEquationSeparate(U[n],U[a]),v=n,x=a),(r!==y||i!==b||o!==S||s!==C)&&(e.blendFuncSeparate(W[r],W[i],W[o],W[s]),y=r,b=i,S=o,C=s),(c.equals(w)===!1||l!==T)&&(e.blendColor(c.r,c.g,c.b,l),w.copy(c),T=l),_=t,E=!1}function G(t,n){t.side===2?ie(e.CULL_FACE):B(e.CULL_FACE);let r=t.side===1;n&&(r=!r),se(r),t.blending===1&&t.transparent===!1?oe(0):oe(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.blendColor,t.blendAlpha,t.premultipliedAlpha),o.setFunc(t.depthFunc),o.setTest(t.depthTest),o.setMask(t.depthWrite),a.setMask(t.colorWrite);let i=t.stencilWrite;s.setTest(i),i&&(s.setMask(t.stencilWriteMask),s.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),s.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),q(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),t.alphaToCoverage===!0?B(e.SAMPLE_ALPHA_TO_COVERAGE):ie(e.SAMPLE_ALPHA_TO_COVERAGE)}function se(t){D!==t&&(t?e.frontFace(e.CW):e.frontFace(e.CCW),D=t)}function K(t){t===0?ie(e.CULL_FACE):(B(e.CULL_FACE),t!==O&&(t===1?e.cullFace(e.BACK):t===2?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK))),O=t}function ce(t){t!==k&&(N&&e.lineWidth(t),k=t)}function q(t,n,r){t?(B(e.POLYGON_OFFSET_FILL),(A!==n||j!==r)&&(A=n,j=r,o.getReversed()&&(n=-n,r=-r),e.polygonOffset(n,r))):ie(e.POLYGON_OFFSET_FILL)}function le(t){t?B(e.SCISSOR_TEST):ie(e.SCISSOR_TEST)}function J(t){t===void 0&&(t=e.TEXTURE0+M-1),ee!==t&&(e.activeTexture(t),ee=t)}function Y(t,n,r){r===void 0&&(r=ee===null?e.TEXTURE0+M-1:ee);let i=te[r];i===void 0&&(i={type:void 0,texture:void 0},te[r]=i),(i.type!==t||i.texture!==n)&&(ee!==r&&(e.activeTexture(r),ee=r),e.bindTexture(t,n||re[t]),i.type=t,i.texture=n)}function ue(){let t=te[ee];t!==void 0&&t.type!==void 0&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)}function de(){try{e.compressedTexImage2D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function fe(){try{e.compressedTexImage3D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function X(){try{e.texSubImage2D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function pe(){try{e.texSubImage3D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function me(){try{e.compressedTexSubImage2D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function Z(){try{e.compressedTexSubImage3D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function he(){try{e.texStorage2D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function ge(){try{e.texStorage3D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function _e(){try{e.texImage2D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function ve(){try{e.texImage3D(...arguments)}catch(e){Qu(`WebGLState:`,e)}}function ye(t){return d[t]===void 0?e.getParameter(t):d[t]}function be(t,n){d[t]!==n&&(e.pixelStorei(t,n),d[t]=n)}function xe(t){L.equals(t)===!1&&(e.scissor(t.x,t.y,t.z,t.w),L.copy(t))}function Se(t){R.equals(t)===!1&&(e.viewport(t.x,t.y,t.z,t.w),R.copy(t))}function Ce(t,n){let r=l.get(n);r===void 0&&(r=new WeakMap,l.set(n,r));let i=r.get(t);i===void 0&&(i=e.getUniformBlockIndex(n,t.name),e.uniformBlockBinding(n,i,i),r.set(t,i))}function we(t,n,r){let i=l.get(n).get(t);c[i]!==r&&(e.bindBufferBase(e.UNIFORM_BUFFER,i,r),c[i]=r)}function Te(){e.disable(e.BLEND),e.disable(e.CULL_FACE),e.disable(e.DEPTH_TEST),e.disable(e.POLYGON_OFFSET_FILL),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.blendEquation(e.FUNC_ADD),e.blendFunc(e.ONE,e.ZERO),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendColor(0,0,0,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(e.LESS),o.setReversed(!1),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(e.ALWAYS,0,4294967295),e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.clearStencil(0),e.cullFace(e.BACK),e.frontFace(e.CCW),e.polygonOffset(0,0),e.activeTexture(e.TEXTURE0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),e.bindFramebuffer(e.READ_FRAMEBUFFER,null),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),e.pixelStorei(e.PACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_ALIGNMENT,4),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.BROWSER_DEFAULT_WEBGL),e.pixelStorei(e.PACK_ROW_LENGTH,0),e.pixelStorei(e.PACK_SKIP_PIXELS,0),e.pixelStorei(e.PACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_ROW_LENGTH,0),e.pixelStorei(e.UNPACK_IMAGE_HEIGHT,0),e.pixelStorei(e.UNPACK_SKIP_PIXELS,0),e.pixelStorei(e.UNPACK_SKIP_ROWS,0),e.pixelStorei(e.UNPACK_SKIP_IMAGES,0),u={},d={},ee=null,te={},f={},c={},p=new WeakMap,m=[],h=null,g=!1,_=null,v=null,y=null,b=null,x=null,S=null,C=null,w=new Lf(0,0,0),T=0,E=!1,D=null,O=null,k=null,A=null,j=null,L.set(0,0,e.canvas.width,e.canvas.height),R.set(0,0,e.canvas.width,e.canvas.height),a.reset(),o.reset(),s.reset()}return{buffers:{color:a,depth:o,stencil:s},enable:B,disable:ie,bindFramebuffer:ae,drawBuffers:V,useProgram:H,setBlending:oe,setMaterial:G,setFlipSided:se,setCullFace:K,setLineWidth:ce,setPolygonOffset:q,setScissorTest:le,activeTexture:J,bindTexture:Y,unbindTexture:ue,compressedTexImage2D:de,compressedTexImage3D:fe,texImage2D:_e,texImage3D:ve,pixelStorei:be,getParameter:ye,updateUBOMapping:Ce,uniformBlockBinding:we,texStorage2D:he,texStorage3D:ge,texSubImage2D:X,texSubImage3D:pe,compressedTexSubImage2D:me,compressedTexSubImage3D:Z,scissor:xe,viewport:Se,reset:Te}}function cb(e,t,n,r,i,a,o){let s=t.has(`WEBGL_multisampled_render_to_texture`)?t.get(`WEBGL_multisampled_render_to_texture`):null,c=typeof navigator>`u`?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Q,u=new WeakMap,d=new Set,f,p=new WeakMap,m=new Set,h=new FinalizationRegistry(e=>m.delete(e)),g=!1;try{g=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function _(e,t){return g?new OffscreenCanvas(e,t):Ku(`canvas`)}function v(e,t,n){let r=1,i=he(e);if((i.width>n||i.height>n)&&(r=n/Math.max(i.width,i.height)),r<1){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof VideoFrame<`u`&&e instanceof VideoFrame){let n=Math.floor(r*i.width),a=Math.floor(r*i.height);f===void 0&&(f=_(n,a));let o=t?_(n,a):f;return o.width=n,o.height=a,o.getContext(`2d`).drawImage(e,0,0,n,a),Zu(`WebGLRenderer: Texture has been resized from (`+i.width+`x`+i.height+`) to (`+n+`x`+a+`).`),o}return`data`in e&&Zu(`WebGLRenderer: Image in DataTexture is too big (`+i.width+`x`+i.height+`).`),e}return e}function y(e){return e.generateMipmaps}function b(t){e.generateMipmap(t)}function x(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function S(n,r,i,a,o,s=!1){if(n!==null){if(e[n]!==void 0)return e[n];Zu(`WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c;a&&(c=t.get(`EXT_texture_norm16`),c||Zu(`WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension`));let l=r;if(r===e.RED&&(i===e.FLOAT&&(l=e.R32F),i===e.HALF_FLOAT&&(l=e.R16F),i===e.UNSIGNED_BYTE&&(l=e.R8),i===e.UNSIGNED_SHORT&&c&&(l=c.R16_EXT),i===e.SHORT&&c&&(l=c.R16_SNORM_EXT)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.R8UI),i===e.UNSIGNED_SHORT&&(l=e.R16UI),i===e.UNSIGNED_INT&&(l=e.R32UI),i===e.BYTE&&(l=e.R8I),i===e.SHORT&&(l=e.R16I),i===e.INT&&(l=e.R32I)),r===e.RG&&(i===e.FLOAT&&(l=e.RG32F),i===e.HALF_FLOAT&&(l=e.RG16F),i===e.UNSIGNED_BYTE&&(l=e.RG8),i===e.UNSIGNED_SHORT&&c&&(l=c.RG16_EXT),i===e.SHORT&&c&&(l=c.RG16_SNORM_EXT)),r===e.RG_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RG8UI),i===e.UNSIGNED_SHORT&&(l=e.RG16UI),i===e.UNSIGNED_INT&&(l=e.RG32UI),i===e.BYTE&&(l=e.RG8I),i===e.SHORT&&(l=e.RG16I),i===e.INT&&(l=e.RG32I)),r===e.RGB_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGB8UI),i===e.UNSIGNED_SHORT&&(l=e.RGB16UI),i===e.UNSIGNED_INT&&(l=e.RGB32UI),i===e.BYTE&&(l=e.RGB8I),i===e.SHORT&&(l=e.RGB16I),i===e.INT&&(l=e.RGB32I)),r===e.RGBA_INTEGER&&(i===e.UNSIGNED_BYTE&&(l=e.RGBA8UI),i===e.UNSIGNED_SHORT&&(l=e.RGBA16UI),i===e.UNSIGNED_INT&&(l=e.RGBA32UI),i===e.BYTE&&(l=e.RGBA8I),i===e.SHORT&&(l=e.RGBA16I),i===e.INT&&(l=e.RGBA32I)),r===e.RGB&&(i===e.UNSIGNED_SHORT&&c&&(l=c.RGB16_EXT),i===e.SHORT&&c&&(l=c.RGB16_SNORM_EXT),i===e.UNSIGNED_INT_5_9_9_9_REV&&(l=e.RGB9_E5),i===e.UNSIGNED_INT_10F_11F_11F_REV&&(l=e.R11F_G11F_B10F)),r===e.RGBA){let t=s?zu:zd.getTransfer(o);i===e.FLOAT&&(l=e.RGBA32F),i===e.HALF_FLOAT&&(l=e.RGBA16F),i===e.UNSIGNED_BYTE&&(l=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT&&c&&(l=c.RGBA16_EXT),i===e.SHORT&&c&&(l=c.RGBA16_SNORM_EXT),i===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),l}function C(t,n){let r;return t?n===null||n===1014||n===1020?r=e.DEPTH24_STENCIL8:n===1015?r=e.DEPTH32F_STENCIL8:n===1012&&(r=e.DEPTH24_STENCIL8,Zu(`DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.`)):n===null||n===1014||n===1020?r=e.DEPTH_COMPONENT24:n===1015?r=e.DEPTH_COMPONENT32F:n===1012&&(r=e.DEPTH_COMPONENT16),r}function w(e,t){return y(e)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function T(e){let t=new WeakRef(e);r.get(e).__ref=t,m.add(t),h.register(e,t,t)}function E(e){let t=r.get(e).__ref;t!==void 0&&(m.delete(t),h.unregister(t))}function D(e){k(e.target)}function O(e){A(e.target)}function k(e){e.removeEventListener(`dispose`,D),E(e),M(e),e.isVideoTexture&&u.delete(e),e.isHTMLTexture&&d.delete(e)}function A(e){e.removeEventListener(`dispose`,O),E(e),P(e)}function j(){for(let e of m){let t=e.deref();t!==void 0&&(t.isRenderTarget===!0?A(t):k(t))}m.clear(),d.clear()}function M(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=p.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&N(e),Object.keys(i).length===0&&p.delete(n)}r.remove(e)}function N(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=p.get(i);delete a[n.__cacheKey],o.memory.textures--}function P(t){let n=r.get(t);n.__depthDisposeCallback&&n.__depthDisposeCallback();let i=t.depthTexture;if(i&&i.renderTarget===t&&k(i),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let r=0;r<n.__webglFramebuffer[t].length;r++)e.deleteFramebuffer(n.__webglFramebuffer[t][r]);else e.deleteFramebuffer(n.__webglFramebuffer[t]);n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer[t])}else{if(Array.isArray(n.__webglFramebuffer))for(let t=0;t<n.__webglFramebuffer.length;t++)e.deleteFramebuffer(n.__webglFramebuffer[t]);else e.deleteFramebuffer(n.__webglFramebuffer);if(n.__webglDepthbuffer&&e.deleteRenderbuffer(n.__webglDepthbuffer),n.__webglMultisampledFramebuffer&&e.deleteFramebuffer(n.__webglMultisampledFramebuffer),n.__webglColorRenderbuffer)for(let t=0;t<n.__webglColorRenderbuffer.length;t++)n.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]);n.__webglDepthRenderbuffer&&e.deleteRenderbuffer(n.__webglDepthRenderbuffer)}let a=t.textures;for(let t=0,n=a.length;t<n;t++){let n=r.get(a[t]);n.__webglTexture&&(e.deleteTexture(n.__webglTexture),o.memory.textures--),r.remove(a[t])}r.remove(t)}let F=0;function ee(){F=0}function te(){return F}function ne(e){F=e}function I(){let e=F;return e>=i.maxTextures&&Zu(`WebGLTextures: Trying to use `+(e+1)+` texture units while this GPU supports only `+i.maxTextures),F+=1,e}function L(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.mipmapsAutoUpdate),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function R(t,i){let a=r.get(t);if(t.isVideoTexture&&me(t),t.isRenderTargetTexture===!1&&t.isExternalTexture!==!0&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)Zu(`WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)Zu(`WebGLRenderer: Texture marked for update but image is incomplete`);else{G(a,t,i);return}}else t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function z(t,i){let a=r.get(t);t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version?G(a,t,i):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i))}function re(t,i){let a=r.get(t);t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version?G(a,t,i):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function B(t,i){let a=r.get(t);t.version>0&&a.__version!==t.version?se(a,t,i):n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let ie={[hl]:e.REPEAT,[gl]:e.CLAMP_TO_EDGE,[_l]:e.MIRRORED_REPEAT},ae={[vl]:e.NEAREST,[yl]:e.NEAREST_MIPMAP_NEAREST,[bl]:e.NEAREST_MIPMAP_LINEAR,[xl]:e.LINEAR,[Sl]:e.LINEAR_MIPMAP_NEAREST,[Cl]:e.LINEAR_MIPMAP_LINEAR},V={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function H(n,a){if(a.type===1015&&t.has(`OES_texture_float_linear`)===!1&&(a.magFilter===1006||a.magFilter===1007||a.magFilter===1005||a.magFilter===1008||a.minFilter===1006||a.minFilter===1007||a.minFilter===1005||a.minFilter===1008)&&Zu(`WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.`),e.texParameteri(n,e.TEXTURE_WRAP_S,ie[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,ie[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,ie[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,ae[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,ae[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,V[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1)return;if(a.anisotropy>1||r.get(a).__currentAnisotropy){let o=t.get(`EXT_texture_filter_anisotropic`);e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy}}}function U(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,D),T(n));let i=n.source,a=p.get(i);a===void 0&&(a={},p.set(i,a));let s=L(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&N(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function W(e,t,n){return Math.floor(Math.floor(e/n)/t)}function oe(t,r,i,a){let o=t.updateRanges;if(o.length===0)n.texSubImage2D(e.TEXTURE_2D,0,0,0,r.width,r.height,i,a,r.data);else{o.sort((e,t)=>e.start-t.start);let s=0;for(let e=1;e<o.length;e++){let t=o[s],n=o[e],i=t.start+t.count,a=W(n.start,r.width,4),c=W(t.start,r.width,4);n.start<=i+1&&a===c&&W(n.start+n.count-1,r.width,4)===a?t.count=Math.max(t.count,n.start+n.count-t.start):(++s,o[s]=n)}o.length=s+1;let c=n.getParameter(e.UNPACK_ROW_LENGTH),l=n.getParameter(e.UNPACK_SKIP_PIXELS),u=n.getParameter(e.UNPACK_SKIP_ROWS);n.pixelStorei(e.UNPACK_ROW_LENGTH,r.width);for(let t=0,s=o.length;t<s;t++){let s=o[t],c=Math.floor(s.start/4),l=Math.ceil(s.count/4),u=c%r.width,d=Math.floor(c/r.width),f=l;n.pixelStorei(e.UNPACK_SKIP_PIXELS,u),n.pixelStorei(e.UNPACK_SKIP_ROWS,d),n.texSubImage2D(e.TEXTURE_2D,0,u,d,f,1,i,a,r.data)}t.clearUpdateRanges(),n.pixelStorei(e.UNPACK_ROW_LENGTH,c),n.pixelStorei(e.UNPACK_SKIP_PIXELS,l),n.pixelStorei(e.UNPACK_SKIP_ROWS,u)}}function G(t,o,s){let c=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(c=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(c=e.TEXTURE_3D);let l=U(t,o),u=o.source;n.bindTexture(c,t.__webglTexture,e.TEXTURE0+s);let f=r.get(u);if(u.version!==f.__version||l===!0){if(n.activeTexture(e.TEXTURE0+s),!(typeof ImageBitmap<`u`&&o.image instanceof ImageBitmap)){let t=zd.getPrimaries(zd.workingColorSpace),r=o.colorSpace===``?null:zd.getPrimaries(o.colorSpace),i=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,i)}n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment);let t=v(o.image,!1,i.maxTextureSize);t=Z(o,t);let r=a.convert(o.format,o.colorSpace),p=a.convert(o.type),m=S(o.internalFormat,r,p,o.normalized,o.colorSpace,o.isVideoTexture);H(c,o);let h,g=o.mipmaps,_=o.isVideoTexture!==!0,x=f.__version===void 0||l===!0,T=u.dataReady,E=w(o,t);if(o.isDepthTexture)m=C(o.format===Vl,o.type),x&&(_?n.texStorage2D(e.TEXTURE_2D,1,m,t.width,t.height):n.texImage2D(e.TEXTURE_2D,0,m,t.width,t.height,0,r,p,null));else if(o.isDataTexture){if(g.length>0){_&&x&&n.texStorage2D(e.TEXTURE_2D,E,m,g[0].width,g[0].height);for(let t=0,i=g.length;t<i;t++)h=g[t],_?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,h.width,h.height,r,p,h.data):n.texImage2D(e.TEXTURE_2D,t,m,h.width,h.height,0,r,p,h.data);o.generateMipmaps=!1}else _?(x&&n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height),T&&oe(o,t,r,p)):n.texImage2D(e.TEXTURE_2D,0,m,t.width,t.height,0,r,p,t.data)}else if(o.isCompressedTexture){if(o.isCompressedArrayTexture){_&&x&&n.texStorage3D(e.TEXTURE_2D_ARRAY,E,m,g[0].width,g[0].height,t.depth);for(let i=0,a=g.length;i<a;i++)if(h=g[i],o.format!==1023){if(r!==null){if(_){if(T){if(o.layerUpdates.size>0){let t=c_(h.width,h.height,o.format,o.type);for(let a of o.layerUpdates){let o=h.data.subarray(a*t/h.data.BYTES_PER_ELEMENT,(a+1)*t/h.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,h.width,h.height,1,r,o)}}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,h.data)}}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,h.data,0,0)}else Zu(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`)}else _?T&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,h.width,h.height,t.depth,r,p,h.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,m,h.width,h.height,t.depth,0,r,p,h.data);o.layerUpdates.size>0&&o.clearLayerUpdates()}else{_&&x&&n.texStorage2D(e.TEXTURE_2D,E,m,g[0].width,g[0].height);for(let t=0,i=g.length;t<i;t++)h=g[t],o.format===1023?_?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,h.width,h.height,r,p,h.data):n.texImage2D(e.TEXTURE_2D,t,m,h.width,h.height,0,r,p,h.data):r===null?Zu(`WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()`):_?T&&n.compressedTexSubImage2D(e.TEXTURE_2D,t,0,0,h.width,h.height,r,h.data):n.compressedTexImage2D(e.TEXTURE_2D,t,m,h.width,h.height,0,h.data)}}else if(o.isDataArrayTexture){if(_){if(x&&n.texStorage3D(e.TEXTURE_2D_ARRAY,E,m,t.width,t.height,t.depth),T){if(o.layerUpdates.size>0){let i=c_(t.width,t.height,o.format,o.type);for(let a of o.layerUpdates){let o=t.data.subarray(a*i/t.data.BYTES_PER_ELEMENT,(a+1)*i/t.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,a,t.width,t.height,1,r,p,o)}o.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)}}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,m,t.width,t.height,t.depth,0,r,p,t.data)}else if(o.isData3DTexture)_?(x&&n.texStorage3D(e.TEXTURE_3D,E,m,t.width,t.height,t.depth),T&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,t.width,t.height,t.depth,r,p,t.data)):n.texImage3D(e.TEXTURE_3D,0,m,t.width,t.height,t.depth,0,r,p,t.data);else if(o.isFramebufferTexture){if(x){if(_)n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height);else{let i=t.width,a=t.height;for(let t=0;t<E;t++)n.texImage2D(e.TEXTURE_2D,t,m,i,a,0,r,p,null),i>>=1,a>>=1}}}else if(o.isHTMLTexture){if(`texElementImage2D`in e){let n=e.canvas;if(n.hasAttribute(`layoutsubtree`)||n.setAttribute(`layoutsubtree`,`true`),t.parentNode!==n){n.appendChild(t),d.add(o),n.onpaint=e=>{let t=e.changedElements;for(let e of d)t.includes(e.image)&&(e.needsUpdate=!0)},n.requestPaint();return}if(e.texElementImage2D.length===3)e.texElementImage2D(e.TEXTURE_2D,e.RGBA8,t);else{let n=e.RGBA,r=e.RGBA,i=e.UNSIGNED_BYTE;e.texElementImage2D(e.TEXTURE_2D,0,n,r,i,t)}e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}}else if(g.length>0){if(_&&x){let t=he(g[0]);n.texStorage2D(e.TEXTURE_2D,E,m,t.width,t.height)}for(let t=0,i=g.length;t<i;t++)h=g[t],_?T&&n.texSubImage2D(e.TEXTURE_2D,t,0,0,r,p,h):n.texImage2D(e.TEXTURE_2D,t,m,r,p,h);o.generateMipmaps=!1}else if(_){if(x){let r=he(t);n.texStorage2D(e.TEXTURE_2D,E,m,r.width,r.height)}T&&n.texSubImage2D(e.TEXTURE_2D,0,0,0,r,p,t)}else n.texImage2D(e.TEXTURE_2D,0,m,r,p,t);y(o)&&o.mipmapsAutoUpdate===!0&&b(c),f.__version=u.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function se(t,o,s){if(o.image.length!==6)return;let c=U(t,o),l=o.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+s);let u=r.get(l);if(l.version!==u.__version||c===!0){n.activeTexture(e.TEXTURE0+s);let t=zd.getPrimaries(zd.workingColorSpace),r=o.colorSpace===``?null:zd.getPrimaries(o.colorSpace),d=o.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),n.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let f=o.isCompressedTexture||o.image[0].isCompressedTexture,p=o.image[0]&&o.image[0].isDataTexture,m=[];for(let e=0;e<6;e++)!f&&!p?m[e]=v(o.image[e],!0,i.maxCubemapSize):m[e]=p?o.image[e].image:o.image[e],m[e]=Z(o,m[e]);let h=m[0],g=a.convert(o.format,o.colorSpace),_=a.convert(o.type),x=S(o.internalFormat,g,_,o.normalized,o.colorSpace),T=o.isVideoTexture!==!0,E=u.__version===void 0||c===!0,D=l.dataReady,O=w(o,h);H(e.TEXTURE_CUBE_MAP,o);let k;if(o.isDepthTexture){if(x=C(o.format===Vl,o.type),E){if(T)n.texStorage2D(e.TEXTURE_CUBE_MAP,1,x,h.width,h.height);else for(let t=0;t<6;t++)n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,x,h.width,h.height,0,g,_,null)}}else if(f){T&&E&&n.texStorage2D(e.TEXTURE_CUBE_MAP,O,x,h.width,h.height);for(let t=0;t<6;t++){k=m[t].mipmaps;for(let r=0;r<k.length;r++){let i=k[r];o.format===1023?T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,i.width,i.height,g,_,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,x,i.width,i.height,0,g,_,i.data):g===null?Zu(`WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()`):T?D&&n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,0,0,i.width,i.height,g,i.data):n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r,x,i.width,i.height,0,i.data)}}}else{if(k=o.mipmaps,T&&E){k.length>0&&O++;let t=he(m[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,O,x,t.width,t.height)}for(let t=0;t<6;t++)if(p){T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,g,_,m[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,x,m[t].width,m[t].height,0,g,_,m[t].data);for(let r=0;r<k.length;r++){let i=k[r].image[t].image;T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,i.width,i.height,g,_,i.data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,x,i.width,i.height,0,g,_,i.data)}}else{T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,g,_,m[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,x,g,_,m[t]);for(let r=0;r<k.length;r++){let i=k[r];T?D&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,0,0,g,_,i.image[t]):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,r+1,x,g,_,i.image[t])}}}y(o)&&o.mipmapsAutoUpdate===!0&&b(e.TEXTURE_CUBE_MAP),u.__version=l.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function K(t,i,o,c,l,u){let d=a.convert(o.format,o.colorSpace),f=a.convert(o.type),p=S(o.internalFormat,d,f,o.normalized,o.colorSpace),m=r.get(i),h=r.get(o);if(h.__renderTarget=i,!m.__hasExternalTextures){let t=Math.max(1,i.width>>u),r=Math.max(1,i.height>>u);l===e.TEXTURE_3D||l===e.TEXTURE_2D_ARRAY?n.texImage3D(l,u,p,t,r,i.depth,0,d,f,null):n.texImage2D(l,u,p,t,r,0,d,f,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),pe(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,c,l,h.__webglTexture,0,X(i)):(l===e.TEXTURE_2D||l>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,c,l,h.__webglTexture,u),n.bindFramebuffer(e.FRAMEBUFFER,null)}function ce(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let i=n.depthTexture,a=i&&i.isDepthTexture?i.type:null,o=C(n.stencilBuffer,a),c=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;pe(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,X(n),o,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,X(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,c,e.RENDERBUFFER,t)}else{let t=n.textures;for(let i=0;i<t.length;i++){let o=t[i],c=a.convert(o.format,o.colorSpace),l=a.convert(o.type),u=S(o.internalFormat,c,l,o.normalized,o.colorSpace);pe(n)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,X(n),u,n.width,n.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,X(n),u,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,u,n.width,n.height)}}e.bindRenderbuffer(e.RENDERBUFFER,null)}function q(t,i,a){let o=i.isWebGLCubeRenderTarget===!0;if(n.bindFramebuffer(e.FRAMEBUFFER,t),!(i.depthTexture&&i.depthTexture.isDepthTexture))throw Error(`THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.`);let c=r.get(i.depthTexture);c.__renderTarget=i;let l=o?i.depthTexture.image[0]:i.depthTexture.image;c.__webglTexture&&l.width===i.width&&l.height===i.height||(l.width=i.width,l.height=i.height,i.depthTexture.needsUpdate=!0),o?B(i.depthTexture,0):R(i.depthTexture,0);let u=c.__webglTexture,d=X(i),f=o?e.TEXTURE_CUBE_MAP_POSITIVE_X+a:e.TEXTURE_2D,p=i.depthTexture.format===1027?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;if(i.depthTexture.format===1026)pe(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,u,0,d):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,u,0);else if(i.depthTexture.format===1027)pe(i)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,p,f,u,0,d):e.framebufferTexture2D(e.FRAMEBUFFER,p,f,u,0);else throw Error(`THREE.WebGLTextures: Unknown depthTexture format.`)}function le(t){let i=r.get(t),a=t.isWebGLCubeRenderTarget===!0;if(i.__boundDepthTexture!==t.depthTexture){let e=t.depthTexture;if(i.__depthDisposeCallback&&i.__depthDisposeCallback(),e){let t=()=>{delete i.__boundDepthTexture,delete i.__depthDisposeCallback,e.removeEventListener(`dispose`,t)};e.addEventListener(`dispose`,t),i.__depthDisposeCallback=t}i.__boundDepthTexture=e}if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(a)for(let e=0;e<6;e++)q(i.__webglFramebuffer[e],t,e);else t.texture.mipmaps.length>0?q(i.__webglFramebuffer[0],t,0):q(i.__webglFramebuffer,t,0)}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]===void 0)i.__webglDepthbuffer[r]=e.createRenderbuffer(),ce(i.__webglDepthbuffer[r],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=i.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else if(t.texture.mipmaps.length>0?n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,i.__webglFramebuffer),i.__webglDepthbuffer===void 0)i.__webglDepthbuffer=e.createRenderbuffer(),ce(i.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=i.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,r)}n.bindFramebuffer(e.FRAMEBUFFER,null)}function J(t,n,i){let a=r.get(t);n!==void 0&&K(a.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0),i!==void 0&&le(t)}function Y(t){let i=t.texture,s=r.get(t),c=r.get(i);t.addEventListener(`dispose`,O),T(t);let l=t.textures,u=t.isWebGLCubeRenderTarget===!0,d=l.length>1;if(d||(c.__webglTexture===void 0&&(c.__webglTexture=e.createTexture()),c.__version=i.version,o.memory.textures++),u){s.__webglFramebuffer=[];for(let t=0;t<6;t++)if(i.mipmaps.length>0){s.__webglFramebuffer[t]=[];for(let n=0;n<i.mipmaps.length;n++)s.__webglFramebuffer[t][n]=e.createFramebuffer()}else s.__webglFramebuffer[t]=e.createFramebuffer()}else{if(i.mipmaps.length>0){s.__webglFramebuffer=[];for(let t=0;t<i.mipmaps.length;t++)s.__webglFramebuffer[t]=e.createFramebuffer()}else s.__webglFramebuffer=e.createFramebuffer();if(d)for(let t=0,n=l.length;t<n;t++){let n=r.get(l[t]);n.__webglTexture===void 0&&(n.__webglTexture=e.createTexture(),o.memory.textures++)}if(t.samples>0&&pe(t)===!1){s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,s.__webglMultisampledFramebuffer);for(let n=0;n<l.length;n++){let r=l[n];s.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,s.__webglColorRenderbuffer[n]);let i=a.convert(r.format,r.colorSpace),o=a.convert(r.type),c=S(r.internalFormat,i,o,r.normalized,r.colorSpace,t.isXRRenderTarget===!0),u=X(t);e.renderbufferStorageMultisample(e.RENDERBUFFER,u,c,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+n,e.RENDERBUFFER,s.__webglColorRenderbuffer[n])}e.bindRenderbuffer(e.RENDERBUFFER,null),t.depthBuffer&&(s.__webglDepthRenderbuffer=e.createRenderbuffer(),ce(s.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(e.FRAMEBUFFER,null)}}if(u){n.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),H(e.TEXTURE_CUBE_MAP,i);for(let n=0;n<6;n++)if(i.mipmaps.length>0)for(let r=0;r<i.mipmaps.length;r++)K(s.__webglFramebuffer[n][r],t,i,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,r);else K(s.__webglFramebuffer[n],t,i,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+n,0);y(i)?b(e.TEXTURE_CUBE_MAP):i.mipmaps.length>0&&e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAX_LEVEL,i.mipmaps.length-1),n.unbindTexture()}else if(d){for(let i=0,a=l.length;i<a;i++){let a=l[i],o=r.get(a),c=e.TEXTURE_2D;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(c=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(c,o.__webglTexture),H(c,a),K(s.__webglFramebuffer,t,a,e.COLOR_ATTACHMENT0+i,c,0),y(a)&&b(c)}n.unbindTexture()}else{let r=e.TEXTURE_2D;if((t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(r=t.isWebGL3DRenderTarget?e.TEXTURE_3D:e.TEXTURE_2D_ARRAY),n.bindTexture(r,c.__webglTexture),H(r,i),i.mipmaps.length>0)for(let n=0;n<i.mipmaps.length;n++)K(s.__webglFramebuffer[n],t,i,e.COLOR_ATTACHMENT0,r,n);else K(s.__webglFramebuffer,t,i,e.COLOR_ATTACHMENT0,r,0);y(i)?b(r):i.mipmaps.length>0&&e.texParameteri(r,e.TEXTURE_MAX_LEVEL,i.mipmaps.length-1),n.unbindTexture()}t.depthBuffer&&le(t)}function ue(e){let t=e.textures;for(let i=0,a=t.length;i<a;i++){let a=t[i];if(y(a)&&a.mipmapsAutoUpdate===!0){let t=x(e),i=r.get(a).__webglTexture;n.bindTexture(t,i),b(t),n.unbindTexture()}}}let de=[];function fe(t){if(t.samples>0){if(pe(t)===!1){let i=t.textures,a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=i.length>1;if(d)for(let t=0;t<i.length;t++)n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,null),n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,null,0);n.bindFramebuffer(e.READ_FRAMEBUFFER,u.__webglMultisampledFramebuffer),t.texture.mipmaps.length>0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglFramebuffer);for(let n=0;n<i.length;n++){if(t.resolveDepthBuffer&&(t.depthBuffer&&(s|=e.DEPTH_BUFFER_BIT),t.stencilBuffer&&t.resolveStencilBuffer&&(s|=e.STENCIL_BUFFER_BIT)),d){e.framebufferRenderbuffer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,u.__webglColorRenderbuffer[n]);let t=r.get(i[n]).__webglTexture;e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)}e.blitFramebuffer(0,0,a,o,0,0,a,o,s,e.NEAREST),c===!0&&(de.length=0,de.push(e.COLOR_ATTACHMENT0+n),t.depthBuffer&&t.storeMultisampledDepthBuffer===!1&&de.push(l),e.invalidateFramebuffer(e.READ_FRAMEBUFFER,de))}if(n.bindFramebuffer(e.READ_FRAMEBUFFER,null),n.bindFramebuffer(e.DRAW_FRAMEBUFFER,null),d)for(let t=0;t<i.length;t++){n.bindFramebuffer(e.FRAMEBUFFER,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.RENDERBUFFER,u.__webglColorRenderbuffer[t]);let a=r.get(i[t]).__webglTexture;n.bindFramebuffer(e.FRAMEBUFFER,u.__webglFramebuffer),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0+t,e.TEXTURE_2D,a,0)}n.bindFramebuffer(e.DRAW_FRAMEBUFFER,u.__webglMultisampledFramebuffer)}else if(t.depthBuffer&&t.storeMultisampledDepthBuffer===!1&&c){let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER,[n])}}}function X(e){return Math.min(i.maxSamples,e.samples)}function pe(e){let n=r.get(e);return e.samples>0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function me(e){let t=o.render.frame;u.get(e)!==t&&(u.set(e,t),e.update())}function Z(e,t){let n=e.colorSpace,r=e.format,i=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||n!==`srgb-linear`&&n!==``&&(zd.getTransfer(n)===`srgb`?(r!==1023||i!==1009)&&Zu(`WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):Qu(`WebGLTextures: Unsupported texture color space:`,n)),t}function he(e){return typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement?(l.width=e.naturalWidth||e.width,l.height=e.naturalHeight||e.height):typeof VideoFrame<`u`&&e instanceof VideoFrame?(l.width=e.displayWidth,l.height=e.displayHeight):(l.width=e.width,l.height=e.height),l}this.allocateTextureUnit=I,this.resetTextureUnits=ee,this.getTextureUnits=te,this.setTextureUnits=ne,this.setTexture2D=R,this.setTexture2DArray=z,this.setTexture3D=re,this.setTextureCube=B,this.rebindTextures=J,this.setupRenderTarget=Y,this.updateRenderTargetMipmap=ue,this.updateMultisampleRenderTarget=fe,this.setupDepthRenderbuffer=le,this.setupFrameBufferTexture=K,this.useMultisampledRTT=pe,this.dispose=j}function lb(e,t){function n(n,r=``){let i,a=zd.getTransfer(r);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===35902)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===35899)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return e.HALF_FLOAT;if(n===1021)return e.ALPHA;if(n===1022)return e.RGB;if(n===1023)return e.RGBA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779){if(a===`srgb`){if(i=t.get(`WEBGL_compressed_texture_s3tc_srgb`),i!==null){if(n===33776)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null}else if(i=t.get(`WEBGL_compressed_texture_s3tc`),i!==null){if(n===33776)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null}if(n===35840||n===35841||n===35842||n===35843){if(i=t.get(`WEBGL_compressed_texture_pvrtc`),i!==null){if(n===35840)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null}if(n===36196||n===37492||n===37496||n===37488||n===37489||n===37490||n===37491){if(i=t.get(`WEBGL_compressed_texture_etc`),i!==null){if(n===36196||n===37492)return a===`srgb`?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===37496)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(n===37488)return i.COMPRESSED_R11_EAC;if(n===37489)return i.COMPRESSED_SIGNED_R11_EAC;if(n===37490)return i.COMPRESSED_RG11_EAC;if(n===37491)return i.COMPRESSED_SIGNED_RG11_EAC}else return null}if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821){if(i=t.get(`WEBGL_compressed_texture_astc`),i!==null){if(n===37808)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return a===`srgb`?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null}if(n===36492||n===36494||n===36495){if(i=t.get(`EXT_texture_compression_bptc`),i!==null){if(n===36492)return a===`srgb`?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null}if(n===36283||n===36284||n===36285||n===36286){if(i=t.get(`EXT_texture_compression_rgtc`),i!==null){if(n===36283)return i.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null}return n===1020?e.UNSIGNED_INT_24_8:e[n]===void 0?null:e[n]}return{convert:n}}var ub=`
|
|
4208
4208
|
void main() {
|
|
4209
4209
|
|
|
4210
4210
|
gl_Position = vec4( position, 1.0 );
|
|
@@ -4228,7 +4228,7 @@ void main() {
|
|
|
4228
4228
|
|
|
4229
4229
|
}
|
|
4230
4230
|
|
|
4231
|
-
}`,fb=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ah(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 wh({vertexShader:ub,fragmentShader:db,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Om(new ph(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},pb=class extends nd{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new fb,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new Q,C=null,w=null,T=new xg;T.viewport=new Xd;let E=new xg;E.viewport=new Xd;let D=[T,E],O=new Mg,k=null,A=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new Mf,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Mf,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Mf,b[e]=t),t.getHandSpace()};function j(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function M(){r.removeEventListener(`select`,j),r.removeEventListener(`selectstart`,j),r.removeEventListener(`selectend`,j),r.removeEventListener(`squeeze`,j),r.removeEventListener(`squeezestart`,j),r.removeEventListener(`squeezeend`,j),r.removeEventListener(`end`,M),r.removeEventListener(`inputsourceschange`,N);for(let e=0;e<b.length;e++){let t=x[e];t!==null&&(x[e]=null,b[e].disconnect(t))}k=null,A=null,h.reset();for(let e in g)delete g[e];if(e.setRenderTarget(v),f=null,d=null,u=null,r=null,y=null,te.stop(),n.isPresenting=!1,e.setPixelRatio(C),e.setSize(S.width,S.height,!1),w!==null){let e=w.camera;e.fov=w.fov,e.zoom=w.zoom,e.updateProjectionMatrix(),w=null}n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&Zu(`WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&Zu(`WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return d===null?f:d},this.getBinding=function(){return u===null&&m&&(u=new XRWebGLBinding(r,t)),u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,r!==null){if(v=e.getRenderTarget(),r.addEventListener(`select`,j),r.addEventListener(`selectstart`,j),r.addEventListener(`selectend`,j),r.addEventListener(`squeeze`,j),r.addEventListener(`squeezestart`,j),r.addEventListener(`squeezeend`,j),r.addEventListener(`end`,M),r.addEventListener(`inputsourceschange`,N),_.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(S),m&&`createProjectionLayer`in XRWebGLBinding.prototype){let n=null,a=null,o=null;_.depth&&(o=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=_.stencil?Vl:Bl,a=_.stencil?Pl:kl);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};u=this.getBinding(),d=u.createProjectionLayer(s),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new Qd(d.textureWidth,d.textureHeight,{format:zl,type:wl,depthTexture:new rh(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let n={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new Qd(f.framebufferWidth,f.framebufferHeight,{format:zl,type:wl,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),te.setContext(r),te.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};function N(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=x.indexOf(n);r>=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=x.indexOf(n);if(r===-1){for(let e=0;e<b.length;e++)if(e>=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}function P(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),O.near=E.near=T.near=t,O.far=E.far=T.far=n,(k!==O.near||A!==O.far)&&(r.updateRenderState({depthNear:O.near,depthFar:O.far}),k=O.near,A=O.far),O.layers.mask=e.layers.mask|6,T.layers.mask=O.layers.mask&-5,E.layers.mask=O.layers.mask&-3;let i=e.parent,a=O.cameras;P(O,i);for(let e=0;e<a.length;e++)P(a[e],i);O.projectionMatrix.copy(T.projectionMatrix),O.projectionMatrixInverse.copy(T.projectionMatrixInverse),w===null&&e.isPerspectiveCamera&&(w={camera:e,fov:e.fov,zoom:e.zoom}),F(e,O,i)};function F(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=od*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(d!==null||f!==null)return s},this.setFoveation=function(e){s=e,d!==null&&(d.fixedFoveation=e),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=e)},this.hasDepthSensing=function(){return h.texture!==null},this.getDepthSensingMesh=function(){return h.getMesh(O)},this.getCameraTexture=function(e){return g[e]};let I=null;function ee(t,i){if(l=i.getViewerPose(c||a),p=i,l!==null){let t=l.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let i=!1;t.length!==O.cameras.length&&(O.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(f!==null)a=f.getViewport(r);else{let t=u.getViewSubImage(d,r);a=t.viewport,n===0&&(e.setRenderTargetTextures(y,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(y))}let o=D[n];o===void 0&&(o=new xg,o.layers.enable(n),o.viewport=new Xd,D[n]=o),o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(r.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),n===0&&(O.matrix.copy(o.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),i===!0&&O.cameras.push(o)}let a=r.enabledFeatures;if(a&&a.includes(`depth-sensing`)&&r.depthUsage==`gpu-optimized`&&m){u=n.getBinding();let e=u.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&h.init(e,r.renderState)}if(a&&a.includes(`camera-access`)&&m){e.state.unbindTexture(),u=n.getBinding();for(let e=0;e<t.length;e++){let n=t[e].camera;if(n){let e=g[n];e||(e=new ah,g[n]=e);let t=u.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<b.length;e++){let t=x[e],n=b[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}I&&I(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),p=null}let te=new u_;te.setAnimationLoop(ee),this.setAnimationLoop=function(e){I=e},this.dispose=function(){}}},mb=new tf,hb=new Pd;hb.set(-1,0,0,0,1,0,0,0,1);function gb(e,t){function n(e,t){e.matrixAutoUpdate===!0&&e.updateMatrix(),t.value.copy(e.matrix)}function r(t,n){n.color.getRGB(t.fogColor.value,bh(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)}function i(e,t,n,r,i){t.isNodeMaterial?t.uniformsNeedUpdate=!1:t.isMeshBasicMaterial?a(e,t):t.isMeshLambertMaterial?(a(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshToonMaterial?(a(e,t),d(e,t)):t.isMeshPhongMaterial?(a(e,t),u(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshStandardMaterial?(a(e,t),f(e,t),t.isMeshPhysicalMaterial&&p(e,t,i)):t.isMeshMatcapMaterial?(a(e,t),m(e,t)):t.isMeshDepthMaterial?a(e,t):t.isMeshDistanceMaterial?(a(e,t),h(e,t)):t.isMeshNormalMaterial?a(e,t):t.isLineBasicMaterial?(o(e,t),t.isLineDashedMaterial&&s(e,t)):t.isPointsMaterial?c(e,t,n,r):t.isSpriteMaterial?l(e,t):t.isShadowMaterial?(e.color.value.copy(t.color),e.opacity.value=t.opacity):t.isShaderMaterial&&(t.uniformsNeedUpdate=!1)}function a(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===1&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===1&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,e.envMapRotation.value.setFromMatrix4(mb.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(hb),e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.diffuseRoughness>0&&(e.diffuseRoughness.value=t.diffuseRoughness,t.diffuseRoughnessMap&&(e.diffuseRoughnessMap.value=t.diffuseRoughnessMap,n(t.diffuseRoughnessMap,e.diffuseRoughnessMapTransform))),t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.retroreflectivity>0&&(e.retroreflectivity.value=t.retroreflectivity),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessMinimum,e.iridescenceThicknessMaximum.value=t.iridescenceThicknessMaximum,t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function _b(e,t,n,r){let i={},a={};function o(e,t){let n=t.program;r.uniformBlockBinding(e,n,i[e.id])}function s(e,n){let o=i[e.id];o===void 0&&(m(e),o=c(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let u=t.render.frame;a[e.id]!==u&&(l(e),a[e.id]=u)}function c(t){let n=e.createBuffer(),r=t.__size,i=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,n),e.bufferData(e.UNIFORM_BUFFER,r,i),e.bindBuffer(e.UNIFORM_BUFFER,null),n}function l(t){let n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let e=0,t=r.length;e<t;e++){let t=r[e];if(Array.isArray(t))for(let n=0,r=t.length;n<r;n++)u(t[n],e,n,a);else u(t,e,0,a)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function u(t,n,r,i){if(f(t,n,r,i)===!0){let n=t.__offset,r=t.value;if(Array.isArray(r)){let e=0;for(let n=0;n<r.length;n++){let i=r[n],a=h(i,!0);d(i,t.__data,e),e+=a.storage/Float32Array.BYTES_PER_ELEMENT}}else d(r,t.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,n,t.__data)}}function d(e,t,n){typeof e==`number`||typeof e==`boolean`?t[n]=e:e.isMatrix3?(t[n]=e.elements[0],t[n+1]=e.elements[1],t[n+2]=e.elements[2],t[n+3]=0,t[n+4]=e.elements[3],t[n+5]=e.elements[4],t[n+6]=e.elements[5],t[n+7]=0,t[n+8]=e.elements[6],t[n+9]=e.elements[7],t[n+10]=e.elements[8],t[n+11]=0):ArrayBuffer.isView(e)?t.set(e.subarray(0,t.length-n),n):e.toArray(t,n)}function f(e,t,n,r){let i=e.value,a=t+`_`+n;if(Array.isArray(i)){r[a]===void 0&&(r[a]=[]);let e=r[a],t=!1;for(let n=0;n<i.length;n++)p(i[n],e,n)===!0&&(t=!0);return t}return p(i,r,a)}function p(e,t,n){if(t[n]===void 0)return t[n]=typeof e==`number`||typeof e==`boolean`?e:ArrayBuffer.isView(e)?e.slice():e.clone(),!0;{let r=t[n];if(typeof e==`number`||typeof e==`boolean`){if(r!==e)return t[n]=e,!0}else if(ArrayBuffer.isView(e))return!0;else if(r.equals(e)===!1)return r.copy(e),!0}return!1}function m(e){let t=e.uniforms,n=0;for(let e=0,r=t.length;e<r;e++){let r=Array.isArray(t[e])?t[e]:[t[e]];for(let i=0,a=r.length;i<a;i++){let a=r[i],o=Array.isArray(a.value)?a.value:[a.value],s=Array.isArray(t[e])||Array.isArray(a.value),c=n;for(let e=0,t=o.length;e<t;e++){let t=o[e],r=h(t,s),i=n%16,a=i%r.boundary,l=i+a;n+=a,l!==0&&16-l<r.storage&&(n+=16-l),e===0&&(c=n),n+=r.storage}a.__data=new(a.type===`int`?Int32Array:a.type===`uint`?Uint32Array:Float32Array)((n-c)/Float32Array.BYTES_PER_ELEMENT),a.__offset=c}}let r=n%16;return r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e,t){let n={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(n.boundary=4,n.storage=4):e.isVector2?(n.boundary=8,n.storage=8):e.isVector3||e.isColor?(n.boundary=16,n.storage=12):e.isVector4?(n.boundary=16,n.storage=16):e.isMatrix3?(n.boundary=16,n.storage=48):e.isMatrix4?(n.boundary=16,n.storage=64):e.isTexture?Zu(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(n.boundary=16,n.storage=e.byteLength):Zu(`WebGLRenderer: Unsupported uniform value type.`,e),t===!0&&(n.boundary=16,n.storage=Math.ceil(n.storage/16)*16),n}function g(t){let n=t.target;n.removeEventListener(`dispose`,g),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);i={},a={}}return{bind:o,update:s,dispose:_}}var vb=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]),yb=null;function bb(){return yb===null&&(yb=new jm(vb,16,16,Wl,jl),yb.name=`DFG_LUT`,yb.minFilter=xl,yb.magFilter=xl,yb.wrapS=gl,yb.wrapT=gl,yb.generateMipmaps=!1,yb.needsUpdate=!0),yb}var xb=class{constructor(e={}){let{canvas:t=qu(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=wl}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([Kl,Gl,Ul]),g=new Set([wl,kl,Dl,Pl,Ml,Nl]),_=new Uint32Array(4),v=new Int32Array(4),y={textures:[],min:[],max:[],resolution:[]},b=null,x=null,S=[],C=[],w=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=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let T=this,E=!1,D=null,O=null,k=null,A=null;this._outputColorSpace=Lu;let j=0,M=0,N=null,P=-1,F=null,I=new Xd,ee=new Xd,te=null,L=new Lf(0),R=0,z=t.width,B=t.height,ne=1,re=null,ie=null,ae=new Xd(0,0,z,B),V=new Xd(0,0,z,B),H=!1,U=new Fm,W=new Lm,oe=!1,G=!1,se=new tf,K=new $,ce=new Xd,q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},le=!1;function J(){return N===null?ne:1}let Y=n;function ue(e,n){return t.getContext(e,n)}let de,fe,X,pe,me,Z,he,ge,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je;try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r187`),t.addEventListener(`webglcontextlost`,Pe,!1),t.addEventListener(`webglcontextrestored`,Fe,!1),t.addEventListener(`webglcontextcreationerror`,Ie,!1),Y===null){let t=`webgl2`;if(Y=ue(t,e),Y===null)throw ue(t)?Error(`THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.`):Error(`THREE.WebGLRenderer: Error creating WebGL context.`)}Me()}catch(e){throw t.removeEventListener(`webglcontextlost`,Pe,!1),t.removeEventListener(`webglcontextrestored`,Fe,!1),t.removeEventListener(`webglcontextcreationerror`,Ie,!1),Qu(`WebGLRenderer: `+e.message),e}function Me(){de=new V_(Y),de.init(),ke=new lb(Y,de),fe=new x_(Y,de,e,ke),X=new sb(Y,de),fe.reversedDepthBuffer&&d&&X.buffers.depth.setReversed(!0),O=Y.createFramebuffer(),k=Y.createFramebuffer(),A=Y.createFramebuffer(),pe=new W_(Y),me=new Vy,Z=new cb(Y,de,X,me,fe,ke,pe),he=new B_(T),ge=new d_(Y),Ae=new y_(Y,ge),_e=new H_(Y,ge,pe,Ae),ve=new K_(Y,_e,ge,Ae,pe),Ee=new G_(Y,fe,Z),Ce=new S_(me),ye=new By(T,he,de,fe,Ae,Ce),be=new gb(T,me),xe=new Gy,Se=new Qy(de),Te=new v_(T,he,X,ve,p,s),we=new ob(T,ve,fe),je=new _b(Y,pe,fe,X),De=new b_(Y,de,pe),Oe=new U_(Y,de,pe),pe.programs=ye.programs,T.capabilities=fe,T.extensions=de,T.properties=me,T.renderLists=xe,T.shadowMap=we,T.state=X,T.info=pe}m!==1009&&(w=new J_(m,t.width,t.height,o,r,i));let Ne=new pb(T,Y);this.xr=Ne,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){let e=de.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=de.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(e){e!==void 0&&(ne=e,this.setSize(z,B,!1))},this.getSize=function(e){return e.set(z,B)},this.setSize=function(e,n,r=!0){Ne.isPresenting?Zu(`WebGLRenderer: Can't change size while VR device is presenting.`):(z=e,B=n,t.width=Math.floor(e*ne),t.height=Math.floor(n*ne),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),w!==null&&w.setSize(t.width,t.height),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(z*ne,B*ne).floor()},this.setDrawingBufferSize=function(e,n,r){z=e,B=n,ne=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009)Qu(`WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);else{if(e){for(let t=0;t<e.length;t++)if(e[t].isOutputPass===!0){Zu(`WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.`);break}}w.setEffects(e||[])}},this.getCurrentViewport=function(e){return e.copy(I)},this.getViewport=function(e){return e.copy(ae)},this.setViewport=function(e,t,n,r){e.isVector4?ae.set(e.x,e.y,e.z,e.w):ae.set(e,t,n,r),X.viewport(I.copy(ae).multiplyScalar(J()).round())},this.getScissor=function(e){return e.copy(V)},this.setScissor=function(e,t,n,r){e.isVector4?V.set(e.x,e.y,e.z,e.w):V.set(e,t,n,r),X.scissor(ee.copy(V).multiplyScalar(J()).round())},this.getScissorTest=function(){return H},this.setScissorTest=function(e){X.setScissorTest(H=e)},this.setOpaqueSort=function(e){re=e},this.setTransparentSort=function(e){ie=e},this.getClearColor=function(e){return e.copy(Te.getClearColor())},this.setClearColor=function(){Te.setClearColor(...arguments)},this.getClearAlpha=function(){return Te.getClearAlpha()},this.setClearAlpha=function(){Te.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(N!==null){let t=N.texture.format;e=h.has(t)}if(e){let e=N.texture.type,t=g.has(e),n=Te.getClearColor(),r=Te.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(_[0]=i,_[1]=a,_[2]=o,_[3]=r,Y.clearBufferuiv(Y.COLOR,0,_)):(v[0]=i,v[1]=a,v[2]=o,v[3]=r,Y.clearBufferiv(Y.COLOR,0,v))}else r|=Y.COLOR_BUFFER_BIT}t&&(r|=Y.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),n&&(r|=Y.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),r!==0&&Y.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(e){e.setRenderer(this),D=e},this.dispose=function(){t.removeEventListener(`webglcontextlost`,Pe,!1),t.removeEventListener(`webglcontextrestored`,Fe,!1),t.removeEventListener(`webglcontextcreationerror`,Ie,!1),Te.dispose(),xe.dispose(),Se.dispose(),Z.dispose(),me.dispose(),he.dispose(),ve.dispose(),_e.dispose(),Ae.dispose(),je.dispose(),ye.dispose(),Ne.dispose(),Ne.removeEventListener(`sessionstart`,Ue),Ne.removeEventListener(`sessionend`,We),Ge.stop()};function Pe(e){e.preventDefault(),Yu(`WebGLRenderer: Context Lost.`),E=!0}function Fe(){Yu(`WebGLRenderer: Context Restored.`),E=!1;let e=pe.autoReset,t=we.enabled,n=we.autoUpdate,r=we.needsUpdate,i=we.type;Me(),pe.autoReset=e,we.enabled=t,we.autoUpdate=n,we.needsUpdate=r,we.type=i}function Ie(e){Qu(`WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function Le(e){let t=e.target;t.removeEventListener(`dispose`,Le),Re(t)}function Re(e){ze(e),me.remove(e)}function ze(e){let t=me.get(e).programs;t!==void 0&&(t.forEach(function(e){ye.releaseProgram(e)}),e.isShaderMaterial&&ye.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=q);let o=i.isMesh&&i.matrixWorld.determinantAffine()<0,s=nt(e,t,n,r,i);X.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=_e.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;Ae.setup(i,r,s,n,c);let h,g=De;if(c!==null&&(h=ge.get(c),g=Oe,g.setIndex(h)),i.isMesh)r.wireframe===!0?(X.setLineWidth(r.wireframeLinewidth*J()),g.setMode(Y.LINES)):g.setMode(Y.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),X.setLineWidth(e*J()),i.isLineSegments?g.setMode(Y.LINES):i.isLineLoop?g.setMode(Y.LINE_LOOP):g.setMode(Y.LINE_STRIP)}else i.isPoints?g.setMode(Y.POINTS):i.isSprite&&g.setMode(Y.TRIANGLES);if(i.isBatchedMesh){if(de.get(`WEBGL_multi_draw`))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{let e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=c?ge.get(c).bytesPerElement:1,o=me.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(Y,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function Be(e,t,n,r){D!==null&&e.isNodeMaterial&&D.setObject(r,e),oe===!0&&Ce.setState(e,n,!1),e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,Qe(e,t,r),e.side=0,e.needsUpdate=!0,Qe(e,t,r),e.side=2):Qe(e,t,r)}this.compile=function(e,t,n=null){n===null&&(n=e),D!==null&&D.renderStart(e,t,n),x=Se.get(n),x.init(t),C.push(x),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),x.setupLights(),D!==null&&D.updateLights(x.state.lightsArray),G=this.localClippingEnabled,oe=Ce.init(this.clippingPlanes,G),oe===!0&&Ce.setGlobalState(this.clippingPlanes,t),D!==null&&we.render(x.state.shadowsArray,n,t);let r=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let i=e.material;if(i){if(Array.isArray(i))for(let a=0;a<i.length;a++){let o=i[a];Be(o,n,t,e),r.add(o)}else Be(i,n,t,e),r.add(i)}}),x=C.pop(),D!==null&&D.renderEnd(),r},this.compileAsync=function(e,t,n=null){let r=this.compile(e,t,n);return new Promise(t=>{function n(){r.forEach(function(e){let t=me.get(e).currentProgram;(t===void 0||t.isReady())&&r.delete(e)}),r.size===0?t(e):setTimeout(n,10)}de.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let Ve=null;function He(e){Ve&&Ve(e)}function Ue(){Ge.stop()}function We(){Ge.start()}let Ge=new u_;Ge.setAnimationLoop(He),typeof self<`u`&&Ge.setContext(self),this.setAnimationLoop=function(e){Ve=e,Ne.setAnimationLoop(e),e===null?Ge.stop():Ge.start()},Ne.addEventListener(`sessionstart`,Ue),Ne.addEventListener(`sessionend`,We),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){Qu(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(E===!0)return;D!==null&&D.renderStart(e,t);let n=Ne.enabled===!0&&Ne.isPresenting===!0,r=w!==null&&(N===null||n)&&w.begin(T,N);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(t),t=Ne.getCamera()),e.isScene===!0&&e.onBeforeRender(T,e,t,N),x=Se.get(e,C.length),x.init(t),x.state.textureUnits=Z.getTextureUnits(),C.push(x),se.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),t.isArrayCamera?W.setFromArrayCamera(t):U.setFromProjectionMatrix(se,Uu,t.reversedDepth),G=this.localClippingEnabled,oe=Ce.init(this.clippingPlanes,G),b=xe.get(e,S.length),b.init(),S.push(b),this.info.render.frame++,Ne.enabled===!0&&Ne.isPresenting===!0){let e=T.xr.getDepthSensingMesh();e!==null&&Ke(e,t,-1/0,T.sortObjects)}Ke(e,t,0,T.sortObjects),b.finish(),D!==null&&D.updateLights(x.state.lightsArray),T.sortObjects===!0&&b.sort(re,ie),le=Ne.enabled===!1||Ne.isPresenting===!1||Ne.hasDepthSensing()===!1,le&&Te.addToRenderList(b,e),this.info.autoReset===!0&&this.info.reset(),oe===!0&&Ce.beginShadows();let i=x.state.shadowsArray;if(we.render(i,e,t),oe===!0&&Ce.endShadows(),(r&&w.hasRenderPass())===!1){let n=b.opaque,r=b.transmissive;if(x.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t<a;t++){let a=i[t];Je(n,r,e,a)}le&&Te.render(e);for(let t=0,n=i.length;t<n;t++){let n=i[t];qe(b,e,n,n.viewport)}}else r.length>0&&Je(n,r,e,t),le&&Te.render(e),qe(b,e,t)}N!==null&&M===0&&(Z.updateMultisampleRenderTarget(N),Z.updateRenderTargetMipmap(N)),r&&w.end(T),e.isScene===!0&&e.onAfterRender(T,e,t),Ae.resetDefaultState(),P=-1,F=null,C.pop(),C.length>0?(x=C[C.length-1],Z.setTextureUnits(x.state.textureUnits),oe===!0&&Ce.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()};function Ke(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){let i=t.isArrayCamera?W:U;if(!e.frustumCulled||e.intersectsFrustum(i)){r&&ce.setFromMatrixPosition(e.matrixWorld).applyMatrix4(se);let i=ve.update(e),a=e.material;a.visible&&b.push(e,i,a,n,ce.z,null,t)}}else if(e.isMesh||e.isLine||e.isPoints){let i=t.isArrayCamera?W:U;if(!e.frustumCulled||e.intersectsFrustum(i)){let i=ve.update(e),a=e.material;if(r&&(e.boundingSphere===void 0?(i.boundingSphere===null&&i.computeBoundingSphere(),ce.copy(i.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),ce.copy(e.boundingSphere.center)),ce.applyMatrix4(e.matrixWorld).applyMatrix4(se)),Array.isArray(a)){let r=i.groups;for(let o=0,s=r.length;o<s;o++){let s=r[o],c=a[s.materialIndex];c&&c.visible&&b.push(e,i,c,n,ce.z,s,t)}}else a.visible&&b.push(e,i,a,n,ce.z,null,t)}}}let i=e.children;for(let e=0,a=i.length;e<a;e++)Ke(i[e],t,n,r)}function qe(e,t,n,r){let{opaque:i,transmissive:a,transparent:o}=e;x.setupLightsView(n),oe===!0&&Ce.setGlobalState(T.clippingPlanes,n),r&&X.viewport(I.copy(r)),i.length>0&&Ye(i,t,n),a.length>0&&Ye(a,t,n),o.length>0&&Ye(o,t,n),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function Je(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[r.id]===void 0){let e=de.has(`EXT_color_buffer_half_float`)||de.has(`EXT_color_buffer_float`);x.state.transmissionRenderTarget[r.id]=new Qd(1,1,{generateMipmaps:!0,type:e?jl:wl,minFilter:Cl,samples:Math.max(4,fe.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:zd.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||I;a.setSize(o.z*T.transmissionResolutionScale,o.w*T.transmissionResolutionScale);let s=T.getRenderTarget(),c=T.getActiveCubeFace(),l=T.getActiveMipmapLevel();T.setRenderTarget(a),T.getClearColor(L),R=T.getClearAlpha(),R<1&&T.setClearColor(16777215,.5),T.clear(),le&&Te.render(n);let u=T.toneMapping;T.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),x.setupLightsView(r),oe===!0&&Ce.setGlobalState(T.clippingPlanes,r),Ye(e,n,r),Z.updateMultisampleRenderTarget(a),Z.updateRenderTargetMipmap(a),de.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i<a;i++){let{object:a,geometry:o,material:s,group:c}=t[i];if(s.side===2&&a.layers.test(r.layers)){let t=s.side;s.side=1,s.needsUpdate=!0,Xe(a,n,r,o,s,c),s.side=t,s.needsUpdate=!0,e=!0}}e===!0&&(Z.updateMultisampleRenderTarget(a),Z.updateRenderTargetMipmap(a))}T.setRenderTarget(s,c,l),T.setClearColor(L,R),d!==void 0&&(r.viewport=d),T.toneMapping=u}function Ye(e,t,n){let r=t.isScene===!0?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){let a=e[i],{object:o,geometry:s,group:c}=a,l=a.material;l.allowOverride===!0&&r!==null&&(l=r),o.layers.test(n.layers)&&Xe(o,t,n,s,l,c)}}function Xe(e,t,n,r,i,a){D!==null&&i.isNodeMaterial&&D.setObject(e,i),e.onBeforeRender(T,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(T,t,n,r,e,a),i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,i.needsUpdate=!0,T.renderBufferDirect(n,t,r,i,e,a),i.side=0,i.needsUpdate=!0,T.renderBufferDirect(n,t,r,i,e,a),i.side=2):T.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(T,t,n,r,i,a)}function Ze(e){let t=0;for(let n of e)n.texture!==null&&t++;return t}function Qe(e,t,n){t.isScene!==!0&&(t=q);let r=me.get(e),i=x.state.lights,a=x.state.shadowsArray,o=i.state.version,s=ye.getParameters(e,i.state,a,t,n,x.state.lightProbeGridArray),c=ye.getProgramCacheKey(s),l=r.programs;r.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,r.fog=t.fog;let u=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;r.envMap=he.get(e.envMap||r.environment,u),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,Le),l=new Map,r.programs=l,r.programVariants=new Map);let d=l.get(c);if(d!==void 0){if(r.currentProgram===d&&r.lightsStateVersion===o)return tt(e,s),d}else s.uniforms=ye.getUniforms(e),D!==null&&e.isNodeMaterial&&D.build(e,n,s),e.onBeforeCompile(s,T),d=ye.acquireProgram(s,c),l.set(c,d),r.uniforms=s.uniforms;let f=r.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||e.clipping===!0)&&(f.clippingPlanes=Ce.uniform),tt(e,s),r.needsLights=it(e),r.lightsStateVersion=o,r.needsLights&&(f.ambientLightColor.value=i.state.ambient,f.lightProbe.value=i.state.probe,f.sunLights.value=i.state.sun,f.sunLightShadows.value=i.state.sunShadow,f.directionalLights.value=i.state.directional,f.directionalLightShadows.value=i.state.directionalShadow,f.spotLights.value=i.state.spot,f.spotLightShadows.value=i.state.spotShadow,f.rectAreaLights.value=i.state.rectArea,f.ltc_1.value=i.state.rectAreaLTC1,f.ltc_2.value=i.state.rectAreaLTC2,f.pointLights.value=i.state.point,f.pointLightShadows.value=i.state.pointShadow,f.hemisphereLights.value=i.state.hemi,f.sunShadowMatrix.value=i.state.sunShadowMatrix,f.sunShadowCascade.value=i.state.sunShadowCascade,f.directionalShadowMatrix.value=i.state.directionalShadowMatrix,f.spotLightMatrix.value=i.state.spotLightMatrix,f.spotLightMap.value=i.state.spotLightMap,f.pointShadowMatrix.value=i.state.pointShadowMatrix),r.numLightProbeGrids=Ze(x.state.lightProbeGridArray),r.currentProgram=d,r.uniformsList=null,d}function $e(e,t,n,r,i){let a=me.get(e),o=a.currentProgram.id+`,`+r+`,`+i,s=a.programVariants.get(o);return s===void 0?(s=Qe(e,t,n),a.programVariants.set(o,s)):(a.currentProgram=s,a.uniformsList=null,a.outputColorSpace=r,a.toneMapping=i),s}function et(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=ry.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function tt(e,t){let n=me.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function nt(e,t,n,r,i){t.isScene!==!0&&(t=q),Z.resetTextureUnits();let a=t.fog,o=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?t.environment:null,s=N===null?T.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:zd.workingColorSpace,c=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,l=he.get(r.envMap||o,c),u=r.vertexColors===!0&&!!n.attributes.color&&n.attributes.color.itemSize===4,d=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(h=T.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=me.get(r),b=x.state.lights;if(oe===!0&&(G===!0||e!==F)){let t=e===F&&r.id===P;Ce.setState(r,e,t)}let S=!1,C=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==b.state.version||i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i._colorsTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i._colorsTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?S=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Ce.numPlanes||v.numIntersection!==Ce.numIntersection)?S=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.morphTargetsCount===_&&v.numLightProbeGrids===Ze(x.state.lightProbeGridArray)?(v.outputColorSpace!==s||v.toneMapping!==h)&&(C=!0):S=!0:S=!0:(S=!0,v.__version=r.version);let w=v.currentProgram;(S===!0||C===!0)&&(w=C===!0?$e(r,t,i,s,h):Qe(r,t,i),D&&r.isNodeMaterial&&D.onUpdateProgram(r,w,v));let E=!1,O=!1,k=!1,A=w.getUniforms(),j=v.uniforms;if(X.useProgram(w.program)&&(E=!0,O=!0,k=!0),r.id!==P&&(P=r.id,O=!0),E||F!==e){X.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),A.setValue(Y,`projectionMatrix`,e.projectionMatrix),A.setValue(Y,`viewMatrix`,e.matrixWorldInverse);let t=A.map.cameraPosition;t!==void 0&&t.setValue(Y,K.setFromMatrixPosition(e.matrixWorld)),fe.logarithmicDepthBuffer&&A.setValue(Y,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&A.setValue(Y,`isOrthographic`,e.isOrthographicCamera===!0),F!==e&&(F=e,O=!0,k=!0)}if(v.needsLights&&(b.state.sunShadowMap.length>0&&A.setValue(Y,`sunShadowMap`,b.state.sunShadowMap,Z),b.state.directionalShadowMap.length>0&&A.setValue(Y,`directionalShadowMap`,b.state.directionalShadowMap,Z),b.state.spotShadowMap.length>0&&A.setValue(Y,`spotShadowMap`,b.state.spotShadowMap,Z),b.state.pointShadowMap.length>0&&A.setValue(Y,`pointShadowMap`,b.state.pointShadowMap,Z)),i.isSkinnedMesh){A.setOptional(Y,i,`bindMatrix`),A.setOptional(Y,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),A.setValue(Y,`boneTexture`,e.boneTexture,Z))}i.isBatchedMesh&&(A.setOptional(Y,i,`batchingTexture`),A.setValue(Y,`batchingTexture`,i._matricesTexture,Z),A.setOptional(Y,i,`batchingIdTexture`),A.setValue(Y,`batchingIdTexture`,i._indirectTexture,Z),A.setOptional(Y,i,`batchingColorTexture`),i._colorsTexture!==null&&A.setValue(Y,`batchingColorTexture`,i._colorsTexture,Z));let M=n.morphAttributes;if((M.position!==void 0||M.normal!==void 0||M.color!==void 0)&&Ee.update(i,n,w),(O||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,A.setValue(Y,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(j.envMapIntensity.value=t.environmentIntensity),j.dfgLUT!==void 0&&(j.dfgLUT.value=bb()),O){if(A.setValue(Y,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&&rt(j,k),a&&r.fog===!0&&be.refreshFogUniforms(j,a),be.refreshMaterialUniforms(j,r,ne,B,x.state.transmissionRenderTarget[e.id]),v.needsLights&&v.numLightProbeGrids>0){let e=y,t=0;for(let n of x.state.lightProbeGridArray)n.texture!==null&&(e.textures[t]=n.texture,e.min[t]=n.boundingBox.min,e.max[t]=n.boundingBox.max,e.resolution[t]=n.resolution,t++);for(let n in e)e[n].length=t;j.probesSH.value=e.textures,j.probesMin.value=e.min,j.probesMax.value=e.max,j.probesResolution.value=e.resolution}ry.upload(Y,et(v),j,Z)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(ry.upload(Y,et(v),j,Z),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&A.setValue(Y,`center`,i.center),A.setValue(Y,`modelViewMatrix`,i.modelViewMatrix),A.setValue(Y,`normalMatrix`,i.normalMatrix),A.setValue(Y,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];je.update(n,w),je.bind(n,w)}}return w}function rt(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.sunLights.needsUpdate=t,e.sunLightShadows.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function it(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&e.lights===!0}this.getActiveCubeFace=function(){return j},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(e,t,n){let r=me.get(e);r.__autoAllocateDepthBuffer=e.resolveDepthBuffer===!1,r.__autoAllocateDepthBuffer===!1&&(r.__useRenderToTexture=!1),me.get(e.texture).__webglTexture=t,me.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=me.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0},this.setRenderTarget=function(e,t=0,n=0){N=e,j=t,M=n;let r=null,i=!1,a=!1;if(e){let o=me.get(e);if(o.__useDefaultFramebuffer!==void 0){X.bindFramebuffer(Y.FRAMEBUFFER,o.__webglFramebuffer),I.copy(e.viewport),ee.copy(e.scissor),te=e.scissorTest,X.viewport(I),X.scissor(ee),X.setScissorTest(te),P=-1;return}if(o.__webglFramebuffer===void 0)Z.setupRenderTarget(e);else if(o.__hasExternalTextures)Z.rebindTextures(e,me.get(e.texture).__webglTexture,me.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(o.__boundDepthTexture!==t){if(t!==null&&me.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.`);Z.setupDepthRenderbuffer(e)}}let s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);let c=me.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],i=!0):r=e.samples>0&&Z.useMultisampledRTT(e)===!1?me.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,I.copy(e.viewport),ee.copy(e.scissor),te=e.scissorTest}else I.copy(ae).multiplyScalar(ne).floor(),ee.copy(V).multiplyScalar(ne).floor(),te=H;if(n!==0&&(r=O),X.bindFramebuffer(Y.FRAMEBUFFER,r)&&X.drawBuffers(e,r),X.viewport(I),X.scissor(ee),X.setScissorTest(te),i){let r=me.get(e.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t<e.textures.length;t++){let i=me.get(e.textures[t]);Y.framebufferTextureLayer(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=me.get(e.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,t.__webglTexture,n)}P=-1};function at(e){let t=me.get(e);return(t.__readFormat!==e.format||t.__readType!==e.type)&&(t.__readFormat=e.format,t.__readType=e.type,t.__formatReadable=fe.textureFormatReadable(e.format),t.__typeReadable=fe.textureTypeReadable(e.type)),t}this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){Qu(`WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let c=me.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o],Array.isArray(c)&&(c=c[0])),c){X.bindFramebuffer(Y.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;e.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+s);let u=at(o);if(u.__formatReadable===!1){Qu(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(u.__typeReadable===!1){Qu(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&Y.readPixels(t,n,r,i,ke.convert(c),ke.convert(l),a)}finally{let e=N===null?null:me.get(N).__webglFramebuffer;X.bindFramebuffer(Y.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=me.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o],Array.isArray(c)&&(c=c[0])),c){if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){X.bindFramebuffer(Y.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;e.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+s);let d=at(o);if(d.__formatReadable===!1)throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(d.__typeReadable===!1)throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let f=Y.createBuffer();Y.bindBuffer(Y.PIXEL_PACK_BUFFER,f),Y.bufferData(Y.PIXEL_PACK_BUFFER,a.byteLength,Y.STREAM_READ),Y.readPixels(t,n,r,i,ke.convert(l),ke.convert(u),0),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,null);let p=N===null?null:me.get(N).__webglFramebuffer;X.bindFramebuffer(Y.FRAMEBUFFER,p);let m=Y.fenceSync(Y.SYNC_GPU_COMMANDS_COMPLETE,0);return Y.flush(),await ed(Y,m,4),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,f),Y.getBufferSubData(Y.PIXEL_PACK_BUFFER,0,a),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,null),Y.deleteBuffer(f),Y.deleteSync(m),a}throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)}},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;Z.setTexture2D(e,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,n,0,0,o,s,i,a),X.unbindTexture()},this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=ke.convert(t.format),_=ke.convert(t.type),v;t.isData3DTexture?(Z.setTexture3D(t,0),v=Y.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(Z.setTexture2DArray(t,0),v=Y.TEXTURE_2D_ARRAY):(Z.setTexture2D(t,0),v=Y.TEXTURE_2D),X.activeTexture(Y.TEXTURE0),X.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,t.flipY),X.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),X.pixelStorei(Y.UNPACK_ALIGNMENT,t.unpackAlignment);let y=X.getParameter(Y.UNPACK_ROW_LENGTH),b=X.getParameter(Y.UNPACK_IMAGE_HEIGHT),x=X.getParameter(Y.UNPACK_SKIP_PIXELS),S=X.getParameter(Y.UNPACK_SKIP_ROWS),C=X.getParameter(Y.UNPACK_SKIP_IMAGES);X.pixelStorei(Y.UNPACK_ROW_LENGTH,h.width),X.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,h.height),X.pixelStorei(Y.UNPACK_SKIP_PIXELS,l),X.pixelStorei(Y.UNPACK_SKIP_ROWS,u),X.pixelStorei(Y.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=me.get(e),r=me.get(t),h=me.get(n.__renderTarget),g=me.get(r.__renderTarget);X.bindFramebuffer(Y.READ_FRAMEBUFFER,h.__webglFramebuffer),X.bindFramebuffer(Y.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,me.get(e).__webglTexture,i,d+n),Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,me.get(t).__webglTexture,a,m+n)),Y.blitFramebuffer(l,u,l+o,u+s,f,p,f+o,p+s,Y.DEPTH_BUFFER_BIT,Y.NEAREST);X.bindFramebuffer(Y.READ_FRAMEBUFFER,null),X.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||me.has(e)){let n=me.get(e),r=me.get(t);X.bindFramebuffer(Y.READ_FRAMEBUFFER,k),X.bindFramebuffer(Y.DRAW_FRAMEBUFFER,A);for(let e=0;e<c;e++)w?Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):Y.framebufferTexture2D(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,n.__webglTexture,i),T?Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):Y.framebufferTexture2D(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,r.__webglTexture,a),i===0?T?Y.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):Y.copyTexSubImage2D(v,a,f,p,l,u,o,s):Y.blitFramebuffer(l,u,l+o,u+s,f,p,f+o,p+s,Y.COLOR_BUFFER_BIT,Y.NEAREST);X.bindFramebuffer(Y.READ_FRAMEBUFFER,null),X.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?Y.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?Y.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):Y.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?Y.texSubImage2D(Y.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?Y.compressedTexSubImage2D(Y.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):Y.texSubImage2D(Y.TEXTURE_2D,a,f,p,o,s,g,_,h);X.pixelStorei(Y.UNPACK_ROW_LENGTH,y),X.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,b),X.pixelStorei(Y.UNPACK_SKIP_PIXELS,x),X.pixelStorei(Y.UNPACK_SKIP_ROWS,S),X.pixelStorei(Y.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps===!0&&t.mipmapsAutoUpdate===!0&&Y.generateMipmap(v),X.unbindTexture()},this.initRenderTarget=function(e){me.get(e).__webglFramebuffer===void 0&&Z.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?Z.setTextureCube(e,0):e.isData3DTexture?Z.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Z.setTexture2DArray(e,0):Z.setTexture2D(e,0),X.unbindTexture()},this.resetState=function(){j=0,M=0,N=null,X.reset(),Ae.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return Uu}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=zd._getDrawingBufferColorSpace(e),t.unpackColorSpace=zd._getUnpackColorSpace()}},Sb={VALIDATION_ERROR:`VALIDATION_ERROR`,INVALID_STATE:`INVALID_STATE`,ENVIRONMENT_ERROR:`ENVIRONMENT_ERROR`,INVALID_CONFIG:`INVALID_CONFIG`,ENCODING_ERROR:`ENCODING_ERROR`,UNKNOWN_ERROR:`UNKNOWN_ERROR`},Cb=class extends Error{code;context;originalError;constructor(e,t=Sb.UNKNOWN_ERROR,n){super(e),this.name=`VisualizationError`,this.code=t,this.context=n?.context,this.originalError=n?.originalError,n?.originalError&&(this.cause=n.originalError)}},wb=new class{debug(){}info(){}warn(){}error(){}};function Tb(){return wb}var Eb={studio:{toneMapping:4,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:.85,hemisphereIntensity:.5,ambientIntensity:.25,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:1.6},technical:{toneMapping:7,toneMappingExposure:1,envMapIntensity:.55,environmentIntensity:.6,hemisphereIntensity:.25,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2.2},showcase:{toneMapping:4,toneMappingExposure:1.15,envMapIntensity:1.4,environmentIntensity:1,hemisphereIntensity:.2,ambientIntensity:.1,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2.6},arctic:{toneMapping:7,toneMappingExposure:1.05,envMapIntensity:.85,environmentIntensity:1.1,hemisphereIntensity:.3,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2,materialOverride:{color:15659509,metalness:0,roughness:.75,emissiveIntensity:0}},xray:{toneMapping:7,toneMappingExposure:1.3,envMapIntensity:.4,environmentIntensity:.8,hemisphereIntensity:.6,ambientIntensity:.6,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:.6,materialOverride:{color:10470632,metalness:0,roughness:.9,emissiveIntensity:0,opacity:.28,depthWrite:!1,side:2}},lineart:{toneMapping:7,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.6,ambientIntensity:3.2,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:0,requiresEdges:!0,materialOverride:{color:16251130,metalness:0,roughness:1,emissiveIntensity:0}},night:{toneMapping:4,toneMappingExposure:1,envMapIntensity:.12,metalReflection:.05,environmentIntensity:.04,hemisphereIntensity:.06,ambientIntensity:.02,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:.03,background:658962,emissiveLightScale:3,bloom:{strength:.2,radius:.3,threshold:1.8},emissiveLights:!0,lowPower:{ambientOcclusion:!1,bloom:void 0,maxEmissiveLights:1,maxPixelRatio:1.5}},wireframe:{toneMapping:7,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.4,ambientIntensity:2,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:0,materialOverride:{color:2830648,metalness:0,roughness:1,emissiveIntensity:0,wireframe:!0,side:2}}};function Db(e,t=!1){let n=Eb[e];return t?{...n,...n.lowPower}:n}var Ob=`selvaEmissive`,kb=`selvaEmissiveLight`,Ab=`selvaEnvMapIntensity`;function jb(e,t,n=1){return e+(n-e)*Math.min(1,Math.max(0,t))}function Mb(e){let t=Eb[e];return{envMapIntensity:t.envMapIntensity,metalReflection:t.metalReflection,cullBackfaces:t.cullBackfaces}}function Nb(e){if(!e||typeof e!=`string`)return Tb().warn(`Invalid color input: ${e}, using white`),new Lf(16777215);let t=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(t))try{return new Lf(t.startsWith(`#`)?t:`#${t}`)}catch{return Tb().warn(`Invalid hex color: ${e}, using white`),new Lf(16777215)}if(t.includes(`,`)){let e=t.split(`,`).map(e=>parseInt(e.trim(),10));if(e.length===3&&e.every(e=>!isNaN(e)&&e>=0&&e<=255))return new Lf(e[0]/255,e[1]/255,e[2]/255)}let n=t.toLowerCase();return n in Lf.NAMES?new Lf(Lf.NAMES[n]):(Tb().warn(`Invalid color string: ${e}, using white`),new Lf(16777215))}function Pb(e,t,n=`z`){e.forEach(e=>{e.position[n]-=t})}function Fb(e){let t=new ep;return e.length===0||e.forEach(e=>{e.updateMatrixWorld(!0);let n=new ep().setFromObject(e);t.union(n)}),t}var Ib=new Set,Lb=1;function Rb(e){let t=Math.max(1,e);if(t!==Lb){Lb=t;for(let e of Ib)e(t)}}function zb(e){return Ib.add(e),e(Lb),()=>Ib.delete(e)}var Bb=`selvaGlass`;function Vb(e){return e?Array.isArray(e)?e.some(e=>e.userData[Bb]===!0):e.userData[Bb]===!0:!1}function Hb(e){let t=[];return e.traverse(e=>{e.visible&&Vb(e.material)&&(e.visible=!1,t.push(e))}),()=>{for(let e of t)e.visible=!0}}function Ub(e){if(al(e)){for(let[t,n]of Object.entries(e))t!==`envMap`&&n instanceof Yd&&n.dispose();e.dispose()}}function Wb(e){e&&(Array.isArray(e)?e.forEach(Ub):Ub(e))}function Gb(e,t={}){let{materials:n=!0,keepUploaded:r}=t;e.traverse(e=>{let t=e;(t.geometry||t.material)&&(t.geometry&&Kb(t.geometry,r),n&&Wb(t.material))})}function Kb(e,t){let n=fl(e);if(n!==e){if(n){e.setIndex(null);for(let t of Object.keys(e.attributes))e.deleteAttribute(t)}e.dispose()}n&&t&&!t.has(n)&&n.dispose()}var qb=new WeakMap,Jb=new WeakMap,Yb=new WeakMap,Xb=new Set;function Zb(e){let t=e.userData?.members;return!Array.isArray(t)||t.length===0||t.some(e=>e.indexStart==null||e.indexCount==null)?null:t}function Qb(e){let t=qb.get(e);return t||(t={base:Array.isArray(e.material)?e.material[0]:e.material,hidden:Xb,selection:null,hover:null},qb.set(e,t)),t}function $b(e){let t=e.geometry;if(!ll(t))return t;let n=new Rp;n.setIndex(t.index);for(let[e,r]of Object.entries(t.attributes))n.setAttribute(e,r);return n.boundingBox=t.boundingBox?.clone()??null,n.boundingSphere=t.boundingSphere?.clone()??null,dl(n,t),e.geometry=n,n}function ex(e,t,n){let r=$b(e);r.clearGroups();let{selection:i,hover:a}=n;if(n.hidden.size===0&&!i&&!a){e.material=n.base,qb.delete(e);return}let o=[n.base],s=i?o.push(i.material)-1:0,c=a?o.push(a.material)-1:0,l=-1,u=0,d=0,f=()=>{l>=0&&r.addGroup(l,u-l,d),l=-1};for(let e=0;e<t.length;e++){if(n.hidden.has(e)){f();continue}let{indexStart:r,indexCount:o}=t[e],p=i?.members.has(e)?s:a?.members.has(e)?c:0;(l<0||p!==d||r!==u)&&(f(),l=r,d=p),u=r+o}f(),e.material=o}function tx(e,t){let n=Zb(e);if(!n)return;let r=Qb(e);t(r),ex(e,n,r),Jb.get(e)?.forEach(e=>e())}function nx(e){return qb.get(e)?.hidden??Xb}function rx(e,t){let n=nx(e);n.size===t.size&&[...t].every(e=>n.has(e))||tx(e,e=>{e.hidden=new Set(t)})}function ix(e){let t=qb.get(e)?.base??(Array.isArray(e.material)?e.material[0]:e.material);return Yb.get(t)??t}function ax(e){let t=e.clone();return Yb.set(t,Yb.get(e)??e),t}function ox(e,t,n,r=`selection`){tx(e,e=>{e[r]={members:t,material:n}})}function sx(e,t=`selection`){qb.get(e)?.[t]&&tx(e,e=>{e[t]=null})}function cx(e,t){let n=Jb.get(e);return n||Jb.set(e,n=new Set),n.add(t),()=>n.delete(t)}var lx=new ep,ux=new $,dx=class extends Og{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new Ep([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new Ep([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new qg(t,6,1);return this.setAttribute(`instanceStart`,new Hp(n,3,0)),this.setAttribute(`instanceEnd`,new Hp(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new qg(t,6,1);return this.setAttribute(`instanceColorStart`,new Hp(n,3,0)),this.setAttribute(`instanceColorEnd`,new Hp(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new mh(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ep);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),lx.setFromBufferAttribute(t),this.boundingBox.union(lx))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ap),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let i=0,a=e.count;i<a;i++)ux.fromBufferAttribute(e,i),r=Math.max(r,n.distanceToSquared(ux)),ux.fromBufferAttribute(t,i),r=Math.max(r,n.distanceToSquared(ux));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}};p_.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Q},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},m_.line={uniforms:xh.merge([p_.common,p_.fog,p_.line]),vertexShader:`
|
|
4231
|
+
}`,fb=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new ah(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 wh({vertexShader:ub,fragmentShader:db,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Om(new ph(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},pb=class extends nd{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new fb,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new Q,C=null,w=null,T=new xg;T.viewport=new Xd;let E=new xg;E.viewport=new Xd;let D=[T,E],O=new Mg,k=null,A=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new Mf,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new Mf,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new Mf,b[e]=t),t.getHandSpace()};function j(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function M(){r.removeEventListener(`select`,j),r.removeEventListener(`selectstart`,j),r.removeEventListener(`selectend`,j),r.removeEventListener(`squeeze`,j),r.removeEventListener(`squeezestart`,j),r.removeEventListener(`squeezeend`,j),r.removeEventListener(`end`,M),r.removeEventListener(`inputsourceschange`,N);for(let e=0;e<b.length;e++){let t=x[e];t!==null&&(x[e]=null,b[e].disconnect(t))}k=null,A=null,h.reset();for(let e in g)delete g[e];if(e.setRenderTarget(v),f=null,d=null,u=null,r=null,y=null,ne.stop(),n.isPresenting=!1,e.setPixelRatio(C),e.setSize(S.width,S.height,!1),w!==null){let e=w.camera;e.fov=w.fov,e.zoom=w.zoom,e.updateProjectionMatrix(),w=null}n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&Zu(`WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&Zu(`WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return d===null?f:d},this.getBinding=function(){return u===null&&m&&(u=new XRWebGLBinding(r,t)),u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,r!==null){if(v=e.getRenderTarget(),r.addEventListener(`select`,j),r.addEventListener(`selectstart`,j),r.addEventListener(`selectend`,j),r.addEventListener(`squeeze`,j),r.addEventListener(`squeezestart`,j),r.addEventListener(`squeezeend`,j),r.addEventListener(`end`,M),r.addEventListener(`inputsourceschange`,N),_.xrCompatible!==!0&&await t.makeXRCompatible(),C=e.getPixelRatio(),e.getSize(S),m&&`createProjectionLayer`in XRWebGLBinding.prototype){let n=null,a=null,o=null;_.depth&&(o=_.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=_.stencil?Vl:Bl,a=_.stencil?Pl:kl);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};u=this.getBinding(),d=u.createProjectionLayer(s),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),y=new Qd(d.textureWidth,d.textureHeight,{format:zl,type:wl,depthTexture:new rh(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1,storeMultisampledDepthBuffer:d.ignoreDepthValues===!1,storeMultisampledStencilBuffer:d.ignoreDepthValues===!1})}else{let n={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),y=new Qd(f.framebufferWidth,f.framebufferHeight,{format:zl,type:wl,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1,storeMultisampledDepthBuffer:f.ignoreDepthValues===!1,storeMultisampledStencilBuffer:f.ignoreDepthValues===!1})}y.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),ne.setContext(r),ne.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};function N(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=x.indexOf(n);r>=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=x.indexOf(n);if(r===-1){for(let e=0;e<b.length;e++)if(e>=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}function P(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),O.near=E.near=T.near=t,O.far=E.far=T.far=n,(k!==O.near||A!==O.far)&&(r.updateRenderState({depthNear:O.near,depthFar:O.far}),k=O.near,A=O.far),O.layers.mask=e.layers.mask|6,T.layers.mask=O.layers.mask&-5,E.layers.mask=O.layers.mask&-3;let i=e.parent,a=O.cameras;P(O,i);for(let e=0;e<a.length;e++)P(a[e],i);O.projectionMatrix.copy(T.projectionMatrix),O.projectionMatrixInverse.copy(T.projectionMatrixInverse),w===null&&e.isPerspectiveCamera&&(w={camera:e,fov:e.fov,zoom:e.zoom}),F(e,O,i)};function F(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=od*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return O},this.getFoveation=function(){if(d!==null||f!==null)return s},this.setFoveation=function(e){s=e,d!==null&&(d.fixedFoveation=e),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=e)},this.hasDepthSensing=function(){return h.texture!==null},this.getDepthSensingMesh=function(){return h.getMesh(O)},this.getCameraTexture=function(e){return g[e]};let ee=null;function te(t,i){if(l=i.getViewerPose(c||a),p=i,l!==null){let t=l.views;f!==null&&(e.setRenderTargetFramebuffer(y,f.framebuffer),e.setRenderTarget(y));let i=!1;t.length!==O.cameras.length&&(O.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(f!==null)a=f.getViewport(r);else{let t=u.getViewSubImage(d,r);a=t.viewport,n===0&&(e.setRenderTargetTextures(y,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(y))}let o=D[n];o===void 0&&(o=new xg,o.layers.enable(n),o.viewport=new Xd,D[n]=o),o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(r.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),n===0&&(O.matrix.copy(o.matrix),O.matrix.decompose(O.position,O.quaternion,O.scale)),i===!0&&O.cameras.push(o)}let a=r.enabledFeatures;if(a&&a.includes(`depth-sensing`)&&r.depthUsage==`gpu-optimized`&&m){u=n.getBinding();let e=u.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&h.init(e,r.renderState)}if(a&&a.includes(`camera-access`)&&m){e.state.unbindTexture(),u=n.getBinding();for(let e=0;e<t.length;e++){let n=t[e].camera;if(n){let e=g[n];e||(e=new ah,g[n]=e);let t=u.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<b.length;e++){let t=x[e],n=b[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}ee&&ee(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),p=null}let ne=new u_;ne.setAnimationLoop(te),this.setAnimationLoop=function(e){ee=e},this.dispose=function(){}}},mb=new tf,hb=new Pd;hb.set(-1,0,0,0,1,0,0,0,1);function gb(e,t){function n(e,t){e.matrixAutoUpdate===!0&&e.updateMatrix(),t.value.copy(e.matrix)}function r(t,n){n.color.getRGB(t.fogColor.value,bh(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)}function i(e,t,n,r,i){t.isNodeMaterial?t.uniformsNeedUpdate=!1:t.isMeshBasicMaterial?a(e,t):t.isMeshLambertMaterial?(a(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshToonMaterial?(a(e,t),d(e,t)):t.isMeshPhongMaterial?(a(e,t),u(e,t),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)):t.isMeshStandardMaterial?(a(e,t),f(e,t),t.isMeshPhysicalMaterial&&p(e,t,i)):t.isMeshMatcapMaterial?(a(e,t),m(e,t)):t.isMeshDepthMaterial?a(e,t):t.isMeshDistanceMaterial?(a(e,t),h(e,t)):t.isMeshNormalMaterial?a(e,t):t.isLineBasicMaterial?(o(e,t),t.isLineDashedMaterial&&s(e,t)):t.isPointsMaterial?c(e,t,n,r):t.isSpriteMaterial?l(e,t):t.isShadowMaterial?(e.color.value.copy(t.color),e.opacity.value=t.opacity):t.isShaderMaterial&&(t.uniformsNeedUpdate=!1)}function a(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===1&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===1&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,e.envMapRotation.value.setFromMatrix4(mb.makeRotationFromEuler(o)).transpose(),a.isCubeTexture&&a.isRenderTargetTexture===!1&&e.envMapRotation.value.premultiply(hb),e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.diffuseRoughness>0&&(e.diffuseRoughness.value=t.diffuseRoughness,t.diffuseRoughnessMap&&(e.diffuseRoughnessMap.value=t.diffuseRoughnessMap,n(t.diffuseRoughnessMap,e.diffuseRoughnessMapTransform))),t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.retroreflectivity>0&&(e.retroreflectivity.value=t.retroreflectivity),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessMinimum,e.iridescenceThicknessMaximum.value=t.iridescenceThicknessMaximum,t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function _b(e,t,n,r){let i={},a={};function o(e,t){let n=t.program;r.uniformBlockBinding(e,n,i[e.id])}function s(e,n){let o=i[e.id];o===void 0&&(m(e),o=c(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let u=t.render.frame;a[e.id]!==u&&(l(e),a[e.id]=u)}function c(t){let n=e.createBuffer(),r=t.__size,i=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,n),e.bufferData(e.UNIFORM_BUFFER,r,i),e.bindBuffer(e.UNIFORM_BUFFER,null),n}function l(t){let n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let e=0,t=r.length;e<t;e++){let t=r[e];if(Array.isArray(t))for(let n=0,r=t.length;n<r;n++)u(t[n],e,n,a);else u(t,e,0,a)}e.bindBuffer(e.UNIFORM_BUFFER,null)}function u(t,n,r,i){if(f(t,n,r,i)===!0){let n=t.__offset,r=t.value;if(Array.isArray(r)){let e=0;for(let n=0;n<r.length;n++){let i=r[n],a=h(i,!0);d(i,t.__data,e),e+=a.storage/Float32Array.BYTES_PER_ELEMENT}}else d(r,t.__data,0);e.bufferSubData(e.UNIFORM_BUFFER,n,t.__data)}}function d(e,t,n){typeof e==`number`||typeof e==`boolean`?t[n]=e:e.isMatrix3?(t[n]=e.elements[0],t[n+1]=e.elements[1],t[n+2]=e.elements[2],t[n+3]=0,t[n+4]=e.elements[3],t[n+5]=e.elements[4],t[n+6]=e.elements[5],t[n+7]=0,t[n+8]=e.elements[6],t[n+9]=e.elements[7],t[n+10]=e.elements[8],t[n+11]=0):ArrayBuffer.isView(e)?t.set(e.subarray(0,t.length-n),n):e.toArray(t,n)}function f(e,t,n,r){let i=e.value,a=t+`_`+n;if(Array.isArray(i)){r[a]===void 0&&(r[a]=[]);let e=r[a],t=!1;for(let n=0;n<i.length;n++)p(i[n],e,n)===!0&&(t=!0);return t}return p(i,r,a)}function p(e,t,n){if(t[n]===void 0)return t[n]=typeof e==`number`||typeof e==`boolean`?e:ArrayBuffer.isView(e)?e.slice():e.clone(),!0;{let r=t[n];if(typeof e==`number`||typeof e==`boolean`){if(r!==e)return t[n]=e,!0}else if(ArrayBuffer.isView(e))return!0;else if(r.equals(e)===!1)return r.copy(e),!0}return!1}function m(e){let t=e.uniforms,n=0;for(let e=0,r=t.length;e<r;e++){let r=Array.isArray(t[e])?t[e]:[t[e]];for(let i=0,a=r.length;i<a;i++){let a=r[i],o=Array.isArray(a.value)?a.value:[a.value],s=Array.isArray(t[e])||Array.isArray(a.value),c=n;for(let e=0,t=o.length;e<t;e++){let t=o[e],r=h(t,s),i=n%16,a=i%r.boundary,l=i+a;n+=a,l!==0&&16-l<r.storage&&(n+=16-l),e===0&&(c=n),n+=r.storage}a.__data=new(a.type===`int`?Int32Array:a.type===`uint`?Uint32Array:Float32Array)((n-c)/Float32Array.BYTES_PER_ELEMENT),a.__offset=c}}let r=n%16;return r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e,t){let n={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(n.boundary=4,n.storage=4):e.isVector2?(n.boundary=8,n.storage=8):e.isVector3||e.isColor?(n.boundary=16,n.storage=12):e.isVector4?(n.boundary=16,n.storage=16):e.isMatrix3?(n.boundary=16,n.storage=48):e.isMatrix4?(n.boundary=16,n.storage=64):e.isTexture?Zu(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):ArrayBuffer.isView(e)?(n.boundary=16,n.storage=e.byteLength):Zu(`WebGLRenderer: Unsupported uniform value type.`,e),t===!0&&(n.boundary=16,n.storage=Math.ceil(n.storage/16)*16),n}function g(t){let n=t.target;n.removeEventListener(`dispose`,g),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);i={},a={}}return{bind:o,update:s,dispose:_}}var vb=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]),yb=null;function bb(){return yb===null&&(yb=new jm(vb,16,16,Wl,jl),yb.name=`DFG_LUT`,yb.minFilter=xl,yb.magFilter=xl,yb.wrapS=gl,yb.wrapT=gl,yb.generateMipmaps=!1,yb.needsUpdate=!0),yb}var xb=class{constructor(e={}){let{canvas:t=qu(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=wl}=e;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);p=n.getContextAttributes().alpha}else p=a;let m=f,h=new Set([Kl,Gl,Ul]),g=new Set([wl,kl,Dl,Pl,Ml,Nl]),_=new Uint32Array(4),v=new Int32Array(4),y={textures:[],min:[],max:[],resolution:[]},b=null,x=null,S=[],C=[],w=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=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let T=this,E=!1,D=null,O=null,k=null,A=null;this._outputColorSpace=Lu;let j=0,M=0,N=null,P=-1,F=null,ee=new Xd,te=new Xd,ne=null,I=new Lf(0),L=0,R=t.width,z=t.height,re=1,B=null,ie=null,ae=new Xd(0,0,R,z),V=new Xd(0,0,R,z),H=!1,U=new Fm,W=new Lm,oe=!1,G=!1,se=new tf,K=new $,ce=new Xd,q={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},le=!1;function J(){return N===null?re:1}let Y=n;function ue(e,n){return t.getContext(e,n)}let de,fe,X,pe,me,Z,he,ge,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je;try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r187`),t.addEventListener(`webglcontextlost`,Pe,!1),t.addEventListener(`webglcontextrestored`,Fe,!1),t.addEventListener(`webglcontextcreationerror`,Ie,!1),Y===null){let t=`webgl2`;if(Y=ue(t,e),Y===null)throw ue(t)?Error(`THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.`):Error(`THREE.WebGLRenderer: Error creating WebGL context.`)}Me()}catch(e){throw t.removeEventListener(`webglcontextlost`,Pe,!1),t.removeEventListener(`webglcontextrestored`,Fe,!1),t.removeEventListener(`webglcontextcreationerror`,Ie,!1),Qu(`WebGLRenderer: `+e.message),e}function Me(){de=new V_(Y),de.init(),ke=new lb(Y,de),fe=new x_(Y,de,e,ke),X=new sb(Y,de),fe.reversedDepthBuffer&&d&&X.buffers.depth.setReversed(!0),O=Y.createFramebuffer(),k=Y.createFramebuffer(),A=Y.createFramebuffer(),pe=new W_(Y),me=new Vy,Z=new cb(Y,de,X,me,fe,ke,pe),he=new B_(T),ge=new d_(Y),Ae=new y_(Y,ge),_e=new H_(Y,ge,pe,Ae),ve=new K_(Y,_e,ge,Ae,pe),Ee=new G_(Y,fe,Z),Ce=new S_(me),ye=new By(T,he,de,fe,Ae,Ce),be=new gb(T,me),xe=new Gy,Se=new Qy(de),Te=new v_(T,he,X,ve,p,s),we=new ob(T,ve,fe),je=new _b(Y,pe,fe,X),De=new b_(Y,de,pe),Oe=new U_(Y,de,pe),pe.programs=ye.programs,T.capabilities=fe,T.extensions=de,T.properties=me,T.renderLists=xe,T.shadowMap=we,T.state=X,T.info=pe}m!==1009&&(w=new J_(m,t.width,t.height,o,r,i));let Ne=new pb(T,Y);this.xr=Ne,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.getContextAttributes()},this.forceContextLoss=function(){let e=de.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=de.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return re},this.setPixelRatio=function(e){e!==void 0&&(re=e,this.setSize(R,z,!1))},this.getSize=function(e){return e.set(R,z)},this.setSize=function(e,n,r=!0){Ne.isPresenting?Zu(`WebGLRenderer: Can't change size while VR device is presenting.`):(R=e,z=n,t.width=Math.floor(e*re),t.height=Math.floor(n*re),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),w!==null&&w.setSize(t.width,t.height),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(R*re,z*re).floor()},this.setDrawingBufferSize=function(e,n,r){R=e,z=n,re=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(m===1009)Qu(`WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.`);else{if(e){for(let t=0;t<e.length;t++)if(e[t].isOutputPass===!0){Zu(`WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.`);break}}w.setEffects(e||[])}},this.getCurrentViewport=function(e){return e.copy(ee)},this.getViewport=function(e){return e.copy(ae)},this.setViewport=function(e,t,n,r){e.isVector4?ae.set(e.x,e.y,e.z,e.w):ae.set(e,t,n,r),X.viewport(ee.copy(ae).multiplyScalar(J()).round())},this.getScissor=function(e){return e.copy(V)},this.setScissor=function(e,t,n,r){e.isVector4?V.set(e.x,e.y,e.z,e.w):V.set(e,t,n,r),X.scissor(te.copy(V).multiplyScalar(J()).round())},this.getScissorTest=function(){return H},this.setScissorTest=function(e){X.setScissorTest(H=e)},this.setOpaqueSort=function(e){B=e},this.setTransparentSort=function(e){ie=e},this.getClearColor=function(e){return e.copy(Te.getClearColor())},this.setClearColor=function(){Te.setClearColor(...arguments)},this.getClearAlpha=function(){return Te.getClearAlpha()},this.setClearAlpha=function(){Te.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(N!==null){let t=N.texture.format;e=h.has(t)}if(e){let e=N.texture.type,t=g.has(e),n=Te.getClearColor(),r=Te.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(_[0]=i,_[1]=a,_[2]=o,_[3]=r,Y.clearBufferuiv(Y.COLOR,0,_)):(v[0]=i,v[1]=a,v[2]=o,v[3]=r,Y.clearBufferiv(Y.COLOR,0,v))}else r|=Y.COLOR_BUFFER_BIT}t&&(r|=Y.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),n&&(r|=Y.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),r!==0&&Y.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(e){e.setRenderer(this),D=e},this.dispose=function(){t.removeEventListener(`webglcontextlost`,Pe,!1),t.removeEventListener(`webglcontextrestored`,Fe,!1),t.removeEventListener(`webglcontextcreationerror`,Ie,!1),Te.dispose(),xe.dispose(),Se.dispose(),Z.dispose(),me.dispose(),he.dispose(),ve.dispose(),_e.dispose(),Ae.dispose(),je.dispose(),ye.dispose(),Ne.dispose(),Ne.removeEventListener(`sessionstart`,Ue),Ne.removeEventListener(`sessionend`,We),Ge.stop()};function Pe(e){e.preventDefault(),Yu(`WebGLRenderer: Context Lost.`),E=!0}function Fe(){Yu(`WebGLRenderer: Context Restored.`),E=!1;let e=pe.autoReset,t=we.enabled,n=we.autoUpdate,r=we.needsUpdate,i=we.type;Me(),pe.autoReset=e,we.enabled=t,we.autoUpdate=n,we.needsUpdate=r,we.type=i}function Ie(e){Qu(`WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function Le(e){let t=e.target;t.removeEventListener(`dispose`,Le),Re(t)}function Re(e){ze(e),me.remove(e)}function ze(e){let t=me.get(e).programs;t!==void 0&&(t.forEach(function(e){ye.releaseProgram(e)}),e.isShaderMaterial&&ye.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=q);let o=i.isMesh&&i.matrixWorld.determinantAffine()<0,s=nt(e,t,n,r,i);X.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=_e.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;Ae.setup(i,r,s,n,c);let h,g=De;if(c!==null&&(h=ge.get(c),g=Oe,g.setIndex(h)),i.isMesh)r.wireframe===!0?(X.setLineWidth(r.wireframeLinewidth*J()),g.setMode(Y.LINES)):g.setMode(Y.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),X.setLineWidth(e*J()),i.isLineSegments?g.setMode(Y.LINES):i.isLineLoop?g.setMode(Y.LINE_LOOP):g.setMode(Y.LINE_STRIP)}else i.isPoints?g.setMode(Y.POINTS):i.isSprite&&g.setMode(Y.TRIANGLES);if(i.isBatchedMesh){if(de.get(`WEBGL_multi_draw`))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{let e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=c?ge.get(c).bytesPerElement:1,o=me.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(Y,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function Be(e,t,n,r){D!==null&&e.isNodeMaterial&&D.setObject(r,e),oe===!0&&Ce.setState(e,n,!1),e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,Qe(e,t,r),e.side=0,e.needsUpdate=!0,Qe(e,t,r),e.side=2):Qe(e,t,r)}this.compile=function(e,t,n=null){n===null&&(n=e),D!==null&&D.renderStart(e,t,n),x=Se.get(n),x.init(t),C.push(x),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(x.pushLight(e),e.castShadow&&x.pushShadow(e))}),x.setupLights(),D!==null&&D.updateLights(x.state.lightsArray),G=this.localClippingEnabled,oe=Ce.init(this.clippingPlanes,G),oe===!0&&Ce.setGlobalState(this.clippingPlanes,t),D!==null&&we.render(x.state.shadowsArray,n,t);let r=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let i=e.material;if(i){if(Array.isArray(i))for(let a=0;a<i.length;a++){let o=i[a];Be(o,n,t,e),r.add(o)}else Be(i,n,t,e),r.add(i)}}),x=C.pop(),D!==null&&D.renderEnd(),r},this.compileAsync=function(e,t,n=null){let r=this.compile(e,t,n);return new Promise(t=>{function n(){r.forEach(function(e){let t=me.get(e).currentProgram;(t===void 0||t.isReady())&&r.delete(e)}),r.size===0?t(e):setTimeout(n,10)}de.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let Ve=null;function He(e){Ve&&Ve(e)}function Ue(){Ge.stop()}function We(){Ge.start()}let Ge=new u_;Ge.setAnimationLoop(He),typeof self<`u`&&Ge.setContext(self),this.setAnimationLoop=function(e){Ve=e,Ne.setAnimationLoop(e),e===null?Ge.stop():Ge.start()},Ne.addEventListener(`sessionstart`,Ue),Ne.addEventListener(`sessionend`,We),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){Qu(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(E===!0)return;D!==null&&D.renderStart(e,t);let n=Ne.enabled===!0&&Ne.isPresenting===!0,r=w!==null&&(N===null||n)&&w.begin(T,N);if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(w===null||w.isCompositing()===!1)&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(t),t=Ne.getCamera()),e.isScene===!0&&e.onBeforeRender(T,e,t,N),x=Se.get(e,C.length),x.init(t),x.state.textureUnits=Z.getTextureUnits(),C.push(x),se.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),t.isArrayCamera?W.setFromArrayCamera(t):U.setFromProjectionMatrix(se,Uu,t.reversedDepth),G=this.localClippingEnabled,oe=Ce.init(this.clippingPlanes,G),b=xe.get(e,S.length),b.init(),S.push(b),this.info.render.frame++,Ne.enabled===!0&&Ne.isPresenting===!0){let e=T.xr.getDepthSensingMesh();e!==null&&Ke(e,t,-1/0,T.sortObjects)}Ke(e,t,0,T.sortObjects),b.finish(),D!==null&&D.updateLights(x.state.lightsArray),T.sortObjects===!0&&b.sort(B,ie),le=Ne.enabled===!1||Ne.isPresenting===!1||Ne.hasDepthSensing()===!1,le&&Te.addToRenderList(b,e),this.info.autoReset===!0&&this.info.reset(),oe===!0&&Ce.beginShadows();let i=x.state.shadowsArray;if(we.render(i,e,t),oe===!0&&Ce.endShadows(),(r&&w.hasRenderPass())===!1){let n=b.opaque,r=b.transmissive;if(x.setupLights(),t.isArrayCamera){let i=t.cameras;if(r.length>0)for(let t=0,a=i.length;t<a;t++){let a=i[t];Je(n,r,e,a)}le&&Te.render(e);for(let t=0,n=i.length;t<n;t++){let n=i[t];qe(b,e,n,n.viewport)}}else r.length>0&&Je(n,r,e,t),le&&Te.render(e),qe(b,e,t)}N!==null&&M===0&&(Z.updateMultisampleRenderTarget(N),Z.updateRenderTargetMipmap(N)),r&&w.end(T),e.isScene===!0&&e.onAfterRender(T,e,t),Ae.resetDefaultState(),P=-1,F=null,C.pop(),C.length>0?(x=C[C.length-1],Z.setTextureUnits(x.state.textureUnits),oe===!0&&Ce.setGlobalState(T.clippingPlanes,x.state.camera)):x=null,S.pop(),b=S.length>0?S[S.length-1]:null,D!==null&&D.renderEnd()};function Ke(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)x.pushLight(e),e.castShadow&&x.pushShadow(e);else if(e.isSprite){let i=t.isArrayCamera?W:U;if(!e.frustumCulled||e.intersectsFrustum(i)){r&&ce.setFromMatrixPosition(e.matrixWorld).applyMatrix4(se);let i=ve.update(e),a=e.material;a.visible&&b.push(e,i,a,n,ce.z,null,t)}}else if(e.isMesh||e.isLine||e.isPoints){let i=t.isArrayCamera?W:U;if(!e.frustumCulled||e.intersectsFrustum(i)){let i=ve.update(e),a=e.material;if(r&&(e.boundingSphere===void 0?(i.boundingSphere===null&&i.computeBoundingSphere(),ce.copy(i.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),ce.copy(e.boundingSphere.center)),ce.applyMatrix4(e.matrixWorld).applyMatrix4(se)),Array.isArray(a)){let r=i.groups;for(let o=0,s=r.length;o<s;o++){let s=r[o],c=a[s.materialIndex];c&&c.visible&&b.push(e,i,c,n,ce.z,s,t)}}else a.visible&&b.push(e,i,a,n,ce.z,null,t)}}}let i=e.children;for(let e=0,a=i.length;e<a;e++)Ke(i[e],t,n,r)}function qe(e,t,n,r){let{opaque:i,transmissive:a,transparent:o}=e;x.setupLightsView(n),oe===!0&&Ce.setGlobalState(T.clippingPlanes,n),r&&X.viewport(ee.copy(r)),i.length>0&&Ye(i,t,n),a.length>0&&Ye(a,t,n),o.length>0&&Ye(o,t,n),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function Je(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;if(x.state.transmissionRenderTarget[r.id]===void 0){let e=de.has(`EXT_color_buffer_half_float`)||de.has(`EXT_color_buffer_float`);x.state.transmissionRenderTarget[r.id]=new Qd(1,1,{generateMipmaps:!0,type:e?jl:wl,minFilter:Cl,samples:Math.max(4,fe.samples),stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,storeMultisampledDepthBuffer:!1,storeMultisampledStencilBuffer:!1,colorSpace:zd.workingColorSpace})}let a=x.state.transmissionRenderTarget[r.id],o=r.viewport||ee;a.setSize(o.z*T.transmissionResolutionScale,o.w*T.transmissionResolutionScale);let s=T.getRenderTarget(),c=T.getActiveCubeFace(),l=T.getActiveMipmapLevel();T.setRenderTarget(a),T.getClearColor(I),L=T.getClearAlpha(),L<1&&T.setClearColor(16777215,.5),T.clear(),le&&Te.render(n);let u=T.toneMapping;T.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),x.setupLightsView(r),oe===!0&&Ce.setGlobalState(T.clippingPlanes,r),Ye(e,n,r),Z.updateMultisampleRenderTarget(a),Z.updateRenderTargetMipmap(a),de.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i<a;i++){let{object:a,geometry:o,material:s,group:c}=t[i];if(s.side===2&&a.layers.test(r.layers)){let t=s.side;s.side=1,s.needsUpdate=!0,Xe(a,n,r,o,s,c),s.side=t,s.needsUpdate=!0,e=!0}}e===!0&&(Z.updateMultisampleRenderTarget(a),Z.updateRenderTargetMipmap(a))}T.setRenderTarget(s,c,l),T.setClearColor(I,L),d!==void 0&&(r.viewport=d),T.toneMapping=u}function Ye(e,t,n){let r=t.isScene===!0?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){let a=e[i],{object:o,geometry:s,group:c}=a,l=a.material;l.allowOverride===!0&&r!==null&&(l=r),o.layers.test(n.layers)&&Xe(o,t,n,s,l,c)}}function Xe(e,t,n,r,i,a){D!==null&&i.isNodeMaterial&&D.setObject(e,i),e.onBeforeRender(T,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(T,t,n,r,e,a),i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,i.needsUpdate=!0,T.renderBufferDirect(n,t,r,i,e,a),i.side=0,i.needsUpdate=!0,T.renderBufferDirect(n,t,r,i,e,a),i.side=2):T.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(T,t,n,r,i,a)}function Ze(e){let t=0;for(let n of e)n.texture!==null&&t++;return t}function Qe(e,t,n){t.isScene!==!0&&(t=q);let r=me.get(e),i=x.state.lights,a=x.state.shadowsArray,o=i.state.version,s=ye.getParameters(e,i.state,a,t,n,x.state.lightProbeGridArray),c=ye.getProgramCacheKey(s),l=r.programs;r.environment=e.isMeshStandardMaterial||e.isMeshLambertMaterial||e.isMeshPhongMaterial?t.environment:null,r.fog=t.fog;let u=e.isMeshStandardMaterial||e.isMeshLambertMaterial&&!e.envMap||e.isMeshPhongMaterial&&!e.envMap;r.envMap=he.get(e.envMap||r.environment,u),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,Le),l=new Map,r.programs=l,r.programVariants=new Map);let d=l.get(c);if(d!==void 0){if(r.currentProgram===d&&r.lightsStateVersion===o)return tt(e,s),d}else s.uniforms=ye.getUniforms(e),D!==null&&e.isNodeMaterial&&D.build(e,n,s),e.onBeforeCompile(s,T),d=ye.acquireProgram(s,c),l.set(c,d),r.uniforms=s.uniforms;let f=r.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||e.clipping===!0)&&(f.clippingPlanes=Ce.uniform),tt(e,s),r.needsLights=it(e),r.lightsStateVersion=o,r.needsLights&&(f.ambientLightColor.value=i.state.ambient,f.lightProbe.value=i.state.probe,f.sunLights.value=i.state.sun,f.sunLightShadows.value=i.state.sunShadow,f.directionalLights.value=i.state.directional,f.directionalLightShadows.value=i.state.directionalShadow,f.spotLights.value=i.state.spot,f.spotLightShadows.value=i.state.spotShadow,f.rectAreaLights.value=i.state.rectArea,f.ltc_1.value=i.state.rectAreaLTC1,f.ltc_2.value=i.state.rectAreaLTC2,f.pointLights.value=i.state.point,f.pointLightShadows.value=i.state.pointShadow,f.hemisphereLights.value=i.state.hemi,f.sunShadowMatrix.value=i.state.sunShadowMatrix,f.sunShadowCascade.value=i.state.sunShadowCascade,f.directionalShadowMatrix.value=i.state.directionalShadowMatrix,f.spotLightMatrix.value=i.state.spotLightMatrix,f.spotLightMap.value=i.state.spotLightMap,f.pointShadowMatrix.value=i.state.pointShadowMatrix),r.numLightProbeGrids=Ze(x.state.lightProbeGridArray),r.currentProgram=d,r.uniformsList=null,d}function $e(e,t,n,r,i){let a=me.get(e),o=a.currentProgram.id+`,`+r+`,`+i,s=a.programVariants.get(o);return s===void 0?(s=Qe(e,t,n),a.programVariants.set(o,s)):(a.currentProgram=s,a.uniformsList=null,a.outputColorSpace=r,a.toneMapping=i),s}function et(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=ry.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function tt(e,t){let n=me.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function nt(e,t,n,r,i){t.isScene!==!0&&(t=q),Z.resetTextureUnits();let a=t.fog,o=r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial?t.environment:null,s=N===null?T.outputColorSpace:N.isXRRenderTarget===!0?N.texture.colorSpace:zd.workingColorSpace,c=r.isMeshStandardMaterial||r.isMeshLambertMaterial&&!r.envMap||r.isMeshPhongMaterial&&!r.envMap,l=he.get(r.envMap||o,c),u=r.vertexColors===!0&&!!n.attributes.color&&n.attributes.color.itemSize===4,d=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),f=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,m=!!n.morphAttributes.color,h=0;r.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(h=T.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,v=me.get(r),b=x.state.lights;if(oe===!0&&(G===!0||e!==F)){let t=e===F&&r.id===P;Ce.setState(r,e,t)}let S=!1,C=!1;r.version===v.__version?v.needsLights&&v.lightsStateVersion!==b.state.version||i.isBatchedMesh&&v.batching===!1||!i.isBatchedMesh&&v.batching===!0||i.isBatchedMesh&&v.batchingColor===!0&&i._colorsTexture===null||i.isBatchedMesh&&v.batchingColor===!1&&i._colorsTexture!==null||i.isInstancedMesh&&v.instancing===!1||!i.isInstancedMesh&&v.instancing===!0||i.isSkinnedMesh&&v.skinning===!1||!i.isSkinnedMesh&&v.skinning===!0||i.isInstancedMesh&&v.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===!1&&i.morphTexture!==null?S=!0:v.envMap===l?r.fog===!0&&v.fog!==a||v.numClippingPlanes!==void 0&&(v.numClippingPlanes!==Ce.numPlanes||v.numIntersection!==Ce.numIntersection)?S=!0:v.vertexAlphas===u&&v.vertexTangents===d&&v.morphTargets===f&&v.morphNormals===p&&v.morphColors===m&&v.morphTargetsCount===_&&v.numLightProbeGrids===Ze(x.state.lightProbeGridArray)?(v.outputColorSpace!==s||v.toneMapping!==h)&&(C=!0):S=!0:S=!0:(S=!0,v.__version=r.version);let w=v.currentProgram;(S===!0||C===!0)&&(w=C===!0?$e(r,t,i,s,h):Qe(r,t,i),D&&r.isNodeMaterial&&D.onUpdateProgram(r,w,v));let E=!1,O=!1,k=!1,A=w.getUniforms(),j=v.uniforms;if(X.useProgram(w.program)&&(E=!0,O=!0,k=!0),r.id!==P&&(P=r.id,O=!0),E||F!==e){X.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),A.setValue(Y,`projectionMatrix`,e.projectionMatrix),A.setValue(Y,`viewMatrix`,e.matrixWorldInverse);let t=A.map.cameraPosition;t!==void 0&&t.setValue(Y,K.setFromMatrixPosition(e.matrixWorld)),fe.logarithmicDepthBuffer&&A.setValue(Y,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&A.setValue(Y,`isOrthographic`,e.isOrthographicCamera===!0),F!==e&&(F=e,O=!0,k=!0)}if(v.needsLights&&(b.state.sunShadowMap.length>0&&A.setValue(Y,`sunShadowMap`,b.state.sunShadowMap,Z),b.state.directionalShadowMap.length>0&&A.setValue(Y,`directionalShadowMap`,b.state.directionalShadowMap,Z),b.state.spotShadowMap.length>0&&A.setValue(Y,`spotShadowMap`,b.state.spotShadowMap,Z),b.state.pointShadowMap.length>0&&A.setValue(Y,`pointShadowMap`,b.state.pointShadowMap,Z)),i.isSkinnedMesh){A.setOptional(Y,i,`bindMatrix`),A.setOptional(Y,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),A.setValue(Y,`boneTexture`,e.boneTexture,Z))}i.isBatchedMesh&&(A.setOptional(Y,i,`batchingTexture`),A.setValue(Y,`batchingTexture`,i._matricesTexture,Z),A.setOptional(Y,i,`batchingIdTexture`),A.setValue(Y,`batchingIdTexture`,i._indirectTexture,Z),A.setOptional(Y,i,`batchingColorTexture`),i._colorsTexture!==null&&A.setValue(Y,`batchingColorTexture`,i._colorsTexture,Z));let M=n.morphAttributes;if((M.position!==void 0||M.normal!==void 0||M.color!==void 0)&&Ee.update(i,n,w),(O||v.receiveShadow!==i.receiveShadow)&&(v.receiveShadow=i.receiveShadow,A.setValue(Y,`receiveShadow`,i.receiveShadow)),(r.isMeshStandardMaterial||r.isMeshLambertMaterial||r.isMeshPhongMaterial)&&r.envMap===null&&t.environment!==null&&(j.envMapIntensity.value=t.environmentIntensity),j.dfgLUT!==void 0&&(j.dfgLUT.value=bb()),O){if(A.setValue(Y,`toneMappingExposure`,T.toneMappingExposure),v.needsLights&&rt(j,k),a&&r.fog===!0&&be.refreshFogUniforms(j,a),be.refreshMaterialUniforms(j,r,re,z,x.state.transmissionRenderTarget[e.id]),v.needsLights&&v.numLightProbeGrids>0){let e=y,t=0;for(let n of x.state.lightProbeGridArray)n.texture!==null&&(e.textures[t]=n.texture,e.min[t]=n.boundingBox.min,e.max[t]=n.boundingBox.max,e.resolution[t]=n.resolution,t++);for(let n in e)e[n].length=t;j.probesSH.value=e.textures,j.probesMin.value=e.min,j.probesMax.value=e.max,j.probesResolution.value=e.resolution}ry.upload(Y,et(v),j,Z)}if(r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(ry.upload(Y,et(v),j,Z),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&A.setValue(Y,`center`,i.center),A.setValue(Y,`modelViewMatrix`,i.modelViewMatrix),A.setValue(Y,`normalMatrix`,i.normalMatrix),A.setValue(Y,`modelMatrix`,i.matrixWorld),r.uniformsGroups!==void 0){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];je.update(n,w),je.bind(n,w)}}return w}function rt(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.sunLights.needsUpdate=t,e.sunLightShadows.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function it(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&e.lights===!0}this.getActiveCubeFace=function(){return j},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(e,t,n){let r=me.get(e);r.__autoAllocateDepthBuffer=e.resolveDepthBuffer===!1,r.__autoAllocateDepthBuffer===!1&&(r.__useRenderToTexture=!1),me.get(e.texture).__webglTexture=t,me.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=me.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0},this.setRenderTarget=function(e,t=0,n=0){N=e,j=t,M=n;let r=null,i=!1,a=!1;if(e){let o=me.get(e);if(o.__useDefaultFramebuffer!==void 0){X.bindFramebuffer(Y.FRAMEBUFFER,o.__webglFramebuffer),ee.copy(e.viewport),te.copy(e.scissor),ne=e.scissorTest,X.viewport(ee),X.scissor(te),X.setScissorTest(ne),P=-1;return}if(o.__webglFramebuffer===void 0)Z.setupRenderTarget(e);else if(o.__hasExternalTextures)Z.rebindTextures(e,me.get(e.texture).__webglTexture,me.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(o.__boundDepthTexture!==t){if(t!==null&&me.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.`);Z.setupDepthRenderbuffer(e)}}let s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);let c=me.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(c[t])?c[t][n]:c[t],i=!0):r=e.samples>0&&Z.useMultisampledRTT(e)===!1?me.get(e).__webglMultisampledFramebuffer:Array.isArray(c)?c[n]:c,ee.copy(e.viewport),te.copy(e.scissor),ne=e.scissorTest}else ee.copy(ae).multiplyScalar(re).floor(),te.copy(V).multiplyScalar(re).floor(),ne=H;if(n!==0&&(r=O),X.bindFramebuffer(Y.FRAMEBUFFER,r)&&X.drawBuffers(e,r),X.viewport(ee),X.scissor(te),X.setScissorTest(ne),i){let r=me.get(e.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(a){let r=t;for(let t=0;t<e.textures.length;t++){let i=me.get(e.textures[t]);Y.framebufferTextureLayer(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=me.get(e.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,t.__webglTexture,n)}P=-1};function at(e){let t=me.get(e);return(t.__readFormat!==e.format||t.__readType!==e.type)&&(t.__readFormat=e.format,t.__readType=e.type,t.__formatReadable=fe.textureFormatReadable(e.format),t.__typeReadable=fe.textureTypeReadable(e.type)),t}this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){Qu(`WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let c=me.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o],Array.isArray(c)&&(c=c[0])),c){X.bindFramebuffer(Y.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;e.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+s);let u=at(o);if(u.__formatReadable===!1){Qu(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(u.__typeReadable===!1){Qu(`WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&Y.readPixels(t,n,r,i,ke.convert(c),ke.convert(l),a)}finally{let e=N===null?null:me.get(N).__webglFramebuffer;X.bindFramebuffer(Y.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=me.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o],Array.isArray(c)&&(c=c[0])),c){if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){X.bindFramebuffer(Y.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;e.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+s);let d=at(o);if(d.__formatReadable===!1)throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(d.__typeReadable===!1)throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let f=Y.createBuffer();Y.bindBuffer(Y.PIXEL_PACK_BUFFER,f),Y.bufferData(Y.PIXEL_PACK_BUFFER,a.byteLength,Y.STREAM_READ),Y.readPixels(t,n,r,i,ke.convert(l),ke.convert(u),0),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,null);let p=N===null?null:me.get(N).__webglFramebuffer;X.bindFramebuffer(Y.FRAMEBUFFER,p);let m=Y.fenceSync(Y.SYNC_GPU_COMMANDS_COMPLETE,0);return Y.flush(),await ed(Y,m,4),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,f),Y.getBufferSubData(Y.PIXEL_PACK_BUFFER,0,a),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,null),Y.deleteBuffer(f),Y.deleteSync(m),a}throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)}},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;Z.setTexture2D(e,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,n,0,0,o,s,i,a),X.unbindTexture()},this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=0){let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=ke.convert(t.format),_=ke.convert(t.type),v;t.isData3DTexture?(Z.setTexture3D(t,0),v=Y.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(Z.setTexture2DArray(t,0),v=Y.TEXTURE_2D_ARRAY):(Z.setTexture2D(t,0),v=Y.TEXTURE_2D),X.activeTexture(Y.TEXTURE0),X.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,t.flipY),X.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),X.pixelStorei(Y.UNPACK_ALIGNMENT,t.unpackAlignment);let y=X.getParameter(Y.UNPACK_ROW_LENGTH),b=X.getParameter(Y.UNPACK_IMAGE_HEIGHT),x=X.getParameter(Y.UNPACK_SKIP_PIXELS),S=X.getParameter(Y.UNPACK_SKIP_ROWS),C=X.getParameter(Y.UNPACK_SKIP_IMAGES);X.pixelStorei(Y.UNPACK_ROW_LENGTH,h.width),X.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,h.height),X.pixelStorei(Y.UNPACK_SKIP_PIXELS,l),X.pixelStorei(Y.UNPACK_SKIP_ROWS,u),X.pixelStorei(Y.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=me.get(e),r=me.get(t),h=me.get(n.__renderTarget),g=me.get(r.__renderTarget);X.bindFramebuffer(Y.READ_FRAMEBUFFER,h.__webglFramebuffer),X.bindFramebuffer(Y.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,me.get(e).__webglTexture,i,d+n),Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,me.get(t).__webglTexture,a,m+n)),Y.blitFramebuffer(l,u,l+o,u+s,f,p,f+o,p+s,Y.DEPTH_BUFFER_BIT,Y.NEAREST);X.bindFramebuffer(Y.READ_FRAMEBUFFER,null),X.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||me.has(e)){let n=me.get(e),r=me.get(t);X.bindFramebuffer(Y.READ_FRAMEBUFFER,k),X.bindFramebuffer(Y.DRAW_FRAMEBUFFER,A);for(let e=0;e<c;e++)w?Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):Y.framebufferTexture2D(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,n.__webglTexture,i),T?Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):Y.framebufferTexture2D(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,r.__webglTexture,a),i===0?T?Y.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):Y.copyTexSubImage2D(v,a,f,p,l,u,o,s):Y.blitFramebuffer(l,u,l+o,u+s,f,p,f+o,p+s,Y.COLOR_BUFFER_BIT,Y.NEAREST);X.bindFramebuffer(Y.READ_FRAMEBUFFER,null),X.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?Y.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?Y.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):Y.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?Y.texSubImage2D(Y.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?Y.compressedTexSubImage2D(Y.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):Y.texSubImage2D(Y.TEXTURE_2D,a,f,p,o,s,g,_,h);X.pixelStorei(Y.UNPACK_ROW_LENGTH,y),X.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,b),X.pixelStorei(Y.UNPACK_SKIP_PIXELS,x),X.pixelStorei(Y.UNPACK_SKIP_ROWS,S),X.pixelStorei(Y.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps===!0&&t.mipmapsAutoUpdate===!0&&Y.generateMipmap(v),X.unbindTexture()},this.initRenderTarget=function(e){me.get(e).__webglFramebuffer===void 0&&Z.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?Z.setTextureCube(e,0):e.isData3DTexture?Z.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Z.setTexture2DArray(e,0):Z.setTexture2D(e,0),X.unbindTexture()},this.resetState=function(){j=0,M=0,N=null,X.reset(),Ae.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return Uu}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=zd._getDrawingBufferColorSpace(e),t.unpackColorSpace=zd._getUnpackColorSpace()}},Sb={VALIDATION_ERROR:`VALIDATION_ERROR`,INVALID_STATE:`INVALID_STATE`,ENVIRONMENT_ERROR:`ENVIRONMENT_ERROR`,INVALID_CONFIG:`INVALID_CONFIG`,ENCODING_ERROR:`ENCODING_ERROR`,UNKNOWN_ERROR:`UNKNOWN_ERROR`},Cb=class extends Error{code;context;originalError;constructor(e,t=Sb.UNKNOWN_ERROR,n){super(e),this.name=`VisualizationError`,this.code=t,this.context=n?.context,this.originalError=n?.originalError,n?.originalError&&(this.cause=n.originalError)}},wb=new class{debug(){}info(){}warn(){}error(){}};function Tb(){return wb}var Eb={studio:{toneMapping:4,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:.85,hemisphereIntensity:.5,ambientIntensity:.25,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:1.6},technical:{toneMapping:7,toneMappingExposure:1,envMapIntensity:.55,environmentIntensity:.6,hemisphereIntensity:.25,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2.2},showcase:{toneMapping:4,toneMappingExposure:1.15,envMapIntensity:1.4,environmentIntensity:1,hemisphereIntensity:.2,ambientIntensity:.1,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2.6},arctic:{toneMapping:7,toneMappingExposure:1.05,envMapIntensity:.85,environmentIntensity:1.1,hemisphereIntensity:.3,ambientIntensity:.15,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:2,materialOverride:{color:15659509,metalness:0,roughness:.75,emissiveIntensity:0}},xray:{toneMapping:7,toneMappingExposure:1.3,envMapIntensity:.4,environmentIntensity:.8,hemisphereIntensity:.6,ambientIntensity:.6,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:.6,materialOverride:{color:10470632,metalness:0,roughness:.9,emissiveIntensity:0,opacity:.28,depthWrite:!1,side:2}},lineart:{toneMapping:7,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.6,ambientIntensity:3.2,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:0,requiresEdges:!0,materialOverride:{color:16251130,metalness:0,roughness:1,emissiveIntensity:0}},night:{toneMapping:4,toneMappingExposure:1,envMapIntensity:.12,metalReflection:.05,environmentIntensity:.04,hemisphereIntensity:.06,ambientIntensity:.02,cullBackfaces:!1,ambientOcclusion:!0,sunlightIntensity:.03,background:658962,emissiveLightScale:3,bloom:{strength:.2,radius:.3,threshold:1.8},emissiveLights:!0,lowPower:{ambientOcclusion:!1,bloom:void 0,maxEmissiveLights:1,maxPixelRatio:1.5}},wireframe:{toneMapping:7,toneMappingExposure:1,envMapIntensity:1,environmentIntensity:1,hemisphereIntensity:.4,ambientIntensity:2,cullBackfaces:!1,ambientOcclusion:!1,sunlightIntensity:0,materialOverride:{color:2830648,metalness:0,roughness:1,emissiveIntensity:0,wireframe:!0,side:2}}};function Db(e,t=!1){let n=Eb[e];return t?{...n,...n.lowPower}:n}var Ob=`selvaEmissive`,kb=`selvaEmissiveLight`,Ab=`selvaEnvMapIntensity`;function jb(e,t,n=1){return e+(n-e)*Math.min(1,Math.max(0,t))}function Mb(e){let t=Eb[e];return{envMapIntensity:t.envMapIntensity,metalReflection:t.metalReflection,cullBackfaces:t.cullBackfaces}}function Nb(e){if(!e||typeof e!=`string`)return Tb().warn(`Invalid color input: ${e}, using white`),new Lf(16777215);let t=e.trim();if(/^#?[0-9A-Fa-f]{6}$/.test(t))try{return new Lf(t.startsWith(`#`)?t:`#${t}`)}catch{return Tb().warn(`Invalid hex color: ${e}, using white`),new Lf(16777215)}if(t.includes(`,`)){let e=t.split(`,`).map(e=>parseInt(e.trim(),10));if(e.length===3&&e.every(e=>!isNaN(e)&&e>=0&&e<=255))return new Lf(e[0]/255,e[1]/255,e[2]/255)}let n=t.toLowerCase();return n in Lf.NAMES?new Lf(Lf.NAMES[n]):(Tb().warn(`Invalid color string: ${e}, using white`),new Lf(16777215))}function Pb(e,t,n=`z`){e.forEach(e=>{e.position[n]-=t})}function Fb(e){let t=new ep;return e.length===0||e.forEach(e=>{e.updateMatrixWorld(!0);let n=new ep().setFromObject(e);t.union(n)}),t}var Ib=new Set,Lb=1;function Rb(e){let t=Math.max(1,e);if(t!==Lb){Lb=t;for(let e of Ib)e(t)}}function zb(e){return Ib.add(e),e(Lb),()=>Ib.delete(e)}var Bb=`selvaGlass`;function Vb(e){return e?Array.isArray(e)?e.some(e=>e.userData[Bb]===!0):e.userData[Bb]===!0:!1}function Hb(e){let t=[];return e.traverse(e=>{e.visible&&Vb(e.material)&&(e.visible=!1,t.push(e))}),()=>{for(let e of t)e.visible=!0}}function Ub(e){if(al(e)){for(let[t,n]of Object.entries(e))t!==`envMap`&&n instanceof Yd&&n.dispose();e.dispose()}}function Wb(e){e&&(Array.isArray(e)?e.forEach(Ub):Ub(e))}function Gb(e,t={}){let{materials:n=!0,keepUploaded:r}=t;e.traverse(e=>{let t=e;(t.geometry||t.material)&&(t.geometry&&Kb(t.geometry,r),n&&Wb(t.material))})}function Kb(e,t){let n=fl(e);if(n!==e){if(n){e.setIndex(null);for(let t of Object.keys(e.attributes))e.deleteAttribute(t)}e.dispose()}n&&t&&!t.has(n)&&n.dispose()}var qb=new WeakMap,Jb=new WeakMap,Yb=new WeakMap,Xb=new Set;function Zb(e){let t=e.userData?.members;return!Array.isArray(t)||t.length===0||t.some(e=>e.indexStart==null||e.indexCount==null)?null:t}function Qb(e){let t=qb.get(e);return t||(t={base:Array.isArray(e.material)?e.material[0]:e.material,hidden:Xb,selection:null,hover:null},qb.set(e,t)),t}function $b(e){let t=e.geometry;if(!ll(t))return t;let n=new Rp;n.setIndex(t.index);for(let[e,r]of Object.entries(t.attributes))n.setAttribute(e,r);return n.boundingBox=t.boundingBox?.clone()??null,n.boundingSphere=t.boundingSphere?.clone()??null,dl(n,t),e.geometry=n,n}function ex(e,t,n){let r=$b(e);r.clearGroups();let{selection:i,hover:a}=n;if(n.hidden.size===0&&!i&&!a){e.material=n.base,qb.delete(e);return}let o=[n.base],s=i?o.push(i.material)-1:0,c=a?o.push(a.material)-1:0,l=-1,u=0,d=0,f=()=>{l>=0&&r.addGroup(l,u-l,d),l=-1};for(let e=0;e<t.length;e++){if(n.hidden.has(e)){f();continue}let{indexStart:r,indexCount:o}=t[e],p=i?.members.has(e)?s:a?.members.has(e)?c:0;(l<0||p!==d||r!==u)&&(f(),l=r,d=p),u=r+o}f(),e.material=o}function tx(e,t){let n=Zb(e);if(!n)return;let r=Qb(e);t(r),ex(e,n,r),Jb.get(e)?.forEach(e=>e())}function nx(e){return qb.get(e)?.hidden??Xb}function rx(e,t){let n=nx(e);n.size===t.size&&[...t].every(e=>n.has(e))||tx(e,e=>{e.hidden=new Set(t)})}function ix(e){let t=qb.get(e)?.base??(Array.isArray(e.material)?e.material[0]:e.material);return Yb.get(t)??t}function ax(e){let t=e.clone();return Yb.set(t,Yb.get(e)??e),t}function ox(e,t,n,r=`selection`){tx(e,e=>{e[r]={members:t,material:n}})}function sx(e,t=`selection`){qb.get(e)?.[t]&&tx(e,e=>{e[t]=null})}function cx(e,t){let n=Jb.get(e);return n||Jb.set(e,n=new Set),n.add(t),()=>n.delete(t)}var lx=new ep,ux=new $,dx=class extends Og{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new Ep([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new Ep([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new qg(t,6,1);return this.setAttribute(`instanceStart`,new Hp(n,3,0)),this.setAttribute(`instanceEnd`,new Hp(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new qg(t,6,1);return this.setAttribute(`instanceColorStart`,new Hp(n,3,0)),this.setAttribute(`instanceColorEnd`,new Hp(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new mh(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ep);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),lx.setFromBufferAttribute(t),this.boundingBox.union(lx))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ap),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let i=0,a=e.count;i<a;i++)ux.fromBufferAttribute(e,i),r=Math.max(r,n.distanceToSquared(ux)),ux.fromBufferAttribute(t,i),r=Math.max(r,n.distanceToSquared(ux));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}};p_.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new Q},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},m_.line={uniforms:xh.merge([p_.common,p_.fog,p_.line]),vertexShader:`
|
|
4232
4232
|
#include <common>
|
|
4233
4233
|
#include <color_pars_vertex>
|
|
4234
4234
|
#include <fog_pars_vertex>
|
|
@@ -4636,7 +4636,7 @@ void main() {
|
|
|
4636
4636
|
#include <premultiplied_alpha_fragment>
|
|
4637
4637
|
|
|
4638
4638
|
}
|
|
4639
|
-
`};var fx=class extends wh{constructor(e){super({type:`LineMaterial`,uniforms:xh.clone(m_.line.uniforms),vertexShader:m_.line.vertexShader,fragmentShader:m_.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return`WORLD_UNITS`in this.defines}set worldUnits(e){e===!0!==this.worldUnits&&(this.needsUpdate=!0),e===!0?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return`USE_DASH`in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH=``:delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return`USE_ALPHA_TO_COVERAGE`in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE=``:delete this.defines.USE_ALPHA_TO_COVERAGE)}},px=new Xd,mx=new $,hx=new $,gx=new Xd,_x=new Xd,vx=new Xd,yx=new $,bx=new tf,xx=new o_,Sx=new $,Cx=new ep,wx=new Ap,Tx=new Xd,Ex,Dx;function Ox(e,t,n){return Tx.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),Tx.multiplyScalar(1/Tx.w),Tx.x=Dx/n.width,Tx.y=Dx/n.height,Tx.applyMatrix4(e.projectionMatrixInverse),Tx.multiplyScalar(1/Tx.w),Math.abs(Math.max(Tx.x,Tx.y))}function kx(e,t){let n=e.matrixWorld,r=e.geometry,i=r.attributes.instanceStart,a=r.attributes.instanceEnd,o=Math.min(r.instanceCount,i.count);for(let r=0,s=o;r<s;r++){xx.start.fromBufferAttribute(i,r),xx.end.fromBufferAttribute(a,r),xx.applyMatrix4(n);let o=new $,s=new $;Ex.distanceSqToSegment(xx.start,xx.end,s,o),s.distanceTo(o)<Dx*.5&&t.push({point:s,pointOnLine:o,distance:Ex.origin.distanceTo(s),object:e,face:null,faceIndex:r,uv:null,uv1:null})}}function Ax(e,t,n){let r=t.projectionMatrix,i=e.material.resolution,a=e.matrixWorld,o=e.geometry,s=o.attributes.instanceStart,c=o.attributes.instanceEnd,l=Math.min(o.instanceCount,s.count),u=-t.near;Ex.at(1,vx),vx.w=1,vx.applyMatrix4(t.matrixWorldInverse),vx.applyMatrix4(r),vx.multiplyScalar(1/vx.w),vx.x*=i.x/2,vx.y*=i.y/2,vx.z=0,yx.copy(vx),bx.multiplyMatrices(t.matrixWorldInverse,a);for(let t=0,o=l;t<o;t++){if(gx.fromBufferAttribute(s,t),_x.fromBufferAttribute(c,t),gx.w=1,_x.w=1,gx.applyMatrix4(bx),_x.applyMatrix4(bx),gx.z>u&&_x.z>u)continue;if(gx.z>u){let e=gx.z-_x.z,t=(gx.z-u)/e;gx.lerp(_x,t)}else if(_x.z>u){let e=_x.z-gx.z,t=(_x.z-u)/e;_x.lerp(gx,t)}gx.applyMatrix4(r),_x.applyMatrix4(r),gx.multiplyScalar(1/gx.w),_x.multiplyScalar(1/_x.w),gx.x*=i.x/2,gx.y*=i.y/2,_x.x*=i.x/2,_x.y*=i.y/2,xx.start.copy(gx),xx.start.z=0,xx.end.copy(_x),xx.end.z=0;let o=xx.closestPointToPointParameter(yx,!0);xx.at(o,Sx);let l=Ad.lerp(gx.z,_x.z,o),d=l>=-1&&l<=1,f=yx.distanceTo(Sx)<Dx*.5;if(d&&f){xx.start.fromBufferAttribute(s,t),xx.end.fromBufferAttribute(c,t),xx.start.applyMatrix4(a),xx.end.applyMatrix4(a);let r=new $,i=new $;Ex.distanceSqToSegment(xx.start,xx.end,i,r),n.push({point:i,pointOnLine:r,distance:Ex.origin.distanceTo(i),object:e,face:null,faceIndex:t,uv:null,uv1:null})}}}var jx=class extends Om{constructor(e=new dx,t=new fx({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type=`LineSegments2`}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let e=0,i=0,a=t.count;e<a;e++,i+=2)mx.fromBufferAttribute(t,e),hx.fromBufferAttribute(n,e),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+mx.distanceTo(hx);let i=new qg(r,2,1);return e.setAttribute(`instanceDistanceStart`,new Hp(i,1,0)),e.setAttribute(`instanceDistanceEnd`,new Hp(i,1,1)),this}raycast(e,t){let n=this.material.worldUnits,r=e.camera;if(r===null&&!n&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.`),n===!1&&(this.material.resolution.x===0||this.material.resolution.y===0))return;let i=e.params.Line2===void 0?0:e.params.Line2.threshold||0;Ex=e.ray;let a=this.matrixWorld,o=this.geometry,s=this.material;Dx=s.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),wx.copy(o.boundingSphere).applyMatrix4(a);let c;if(c=n?Dx*.5:Ox(r,Math.max(r.near,wx.distanceToPoint(Ex.origin)),s.resolution),wx.radius+=c,Ex.intersectsSphere(wx)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),Cx.copy(o.boundingBox).applyMatrix4(a);let l;l=n?Dx*.5:Ox(r,Math.max(r.near,Cx.distanceToPoint(Ex.origin)),s.resolution),Cx.expandByScalar(l),Ex.intersectsBox(Cx)!==!1&&(n?kx(this,t):Ax(this,r,t))}onBeforeRender(e){let t=this.material.uniforms;t&&t.resolution&&(e.getViewport(px),this.material.uniforms.resolution.value.set(px.z,px.w))}},Mx=class extends dx{constructor(){super(),this.isLineGeometry=!0,this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}setFromPoints(e){let t=e.length-1,n=new Float32Array(6*t);for(let r=0;r<t;r++)n[6*r]=e[r].x,n[6*r+1]=e[r].y,n[6*r+2]=e[r].z||0,n[6*r+3]=e[r+1].x,n[6*r+4]=e[r+1].y,n[6*r+5]=e[r+1].z||0;return super.setPositions(n),this}fromLine(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}},Nx=class extends jx{constructor(e=new Mx,t=new fx({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type=`Line2`}},Px=class extends kf{constructor(e=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new Q(.5,.5),this.rotation2D=0,this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof e.element.ownerDocument.defaultView.Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this.rotation2D=e.rotation2D,this}},Fx=new $,Ix=new tf,Lx=new tf,Rx=new $,zx=new $,Bx=class{constructor(e={}){let t=this,n,r,i,a,o={objects:new WeakMap},s=e.element===void 0?document.createElement(`div`):e.element;s.style.overflow=`hidden`,this.domElement=s,this.sortObjects=!0,this.getSize=function(){return{width:n,height:r}},this.render=function(e,t){e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ix.copy(t.matrixWorldInverse),Lx.multiplyMatrices(t.projectionMatrix,Ix),l(e,e,t),this.sortObjects&&f(e)},this.setSize=function(e,t){n=e,r=t,i=n/2,a=r/2,s.style.width=e+`px`,s.style.height=t+`px`};function c(e){e.isCSS2DObject&&(e.element.style.display=`none`);for(let t=0,n=e.children.length;t<n;t++)c(e.children[t])}function l(e,n,r){if(e.visible===!1)c(e);else{if(e.isCSS2DObject){Fx.setFromMatrixPosition(e.matrixWorld),Fx.applyMatrix4(Lx);let c=Fx.z>=-1&&Fx.z<=1&&e.layers.test(r.layers)===!0,l=e.element;if(l.style.display=c===!0?``:`none`,c===!0){e.onBeforeRender(t,n,r);let o=100*e.center.x,c=100*e.center.y;l.style.transformOrigin=`${o}% ${c}%`;let u=-e.rotation2D,d=Fx.x*i+i,f=-Fx.y*a+a;l.style.transform=`translate(${-o}%, ${-c}%) translate(${d}px, ${f}px) rotate(${u}rad)`,l.parentNode!==s&&s.appendChild(l),e.onAfterRender(t,n,r)}let d={distanceToCameraSquared:u(r,e)};o.objects.set(e,d)}for(let t=0,i=e.children.length;t<i;t++)l(e.children[t],n,r)}}function u(e,t){return Rx.setFromMatrixPosition(e.matrixWorld),zx.setFromMatrixPosition(t.matrixWorld),Rx.distanceToSquared(zx)}function d(e){let t=[];return e.traverseVisible(function(e){e.isCSS2DObject&&t.push(e)}),t}function f(e){let t=d(e).sort(function(e,t){return e.renderOrder===t.renderOrder?o.objects.get(e).distanceToCameraSquared-o.objects.get(t).distanceToCameraSquared:t.renderOrder-e.renderOrder}),n=t.length;for(let e=0,r=t.length;e<r;e++)t[e].element.style.zIndex=n-e}}},Vx=1.25,Hx=65535,Ux=2**-24,Wx=Symbol(`SKIP_GENERATION`),Gx={strategy:0,maxDepth:40,targetLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Wx]:!1};function Kx(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function qx(e){let t=-1,n=-1/0;for(let r=0;r<3;r++){let i=e[r+3]-e[r];i>n&&(n=i,t=r)}return t}function Jx(e,t,n){for(let r=0;r<3;r++){let i=t[e+2*r],a=t[e+2*r+1],o=i-a,s=i+a;o<n[r]&&(n[r]=o),s>n[r+3]&&(n[r+3]=s)}}function Yx(e){let t=e[3]-e[0],n=e[4]-e[1],r=e[5]-e[2];return 2*(t*n+n*r+r*t)}function Xx(e,t){return t[e+15]===Hx}function Zx(e,t){return t[e+6]}function Qx(e,t){return t[e+14]}function $x(e){return e+8}function eS(e,t){return e+t[e+6]*8}function tS(e,t){return t[e+7]}function nS(e){return e}function rS(e,t,n,r,i){let a=1/0,o=1/0,s=1/0,c=-1/0,l=-1/0,u=-1/0,d=1/0,f=1/0,p=1/0,m=-1/0,h=-1/0,g=-1/0,_=e.offset||0;for(let r=(t-_)*6,i=(t+n-_)*6;r<i;r+=6){let t=e[r+0],n=e[r+1],i=t-n,_=t+n;i<a&&(a=i),_>c&&(c=_),t<d&&(d=t),t>m&&(m=t);let v=e[r+2],y=e[r+3],b=v-y,x=v+y;b<o&&(o=b),x>l&&(l=x),v<f&&(f=v),v>h&&(h=v);let S=e[r+4],C=e[r+5],w=S-C,T=S+C;w<s&&(s=w),T>u&&(u=T),S<p&&(p=S),S>g&&(g=S)}r[0]=a,r[1]=o,r[2]=s,r[3]=c,r[4]=l,r[5]=u,i[0]=d,i[1]=f,i[2]=p,i[3]=m,i[4]=h,i[5]=g}var iS=8,aS=8,oS=new Int32Array(iS),sS=new Float32Array(48),cS=new Float32Array(48),lS=new Float32Array(6),uS=new Float32Array(6),dS=new Int32Array(aS),fS=new Float32Array(48);function pS(e,t,n,r){for(let i=0;i<3;i++){let a=t[e+2*i],o=t[e+2*i+1],s=a-o,c=a+o;s<n[r+i]&&(n[r+i]=s),c>n[r+i+3]&&(n[r+i+3]=c)}}function mS(e,t){let n=e[t+3]-e[t],r=e[t+4]-e[t+1],i=e[t+5]-e[t+2];return 2*(n*r+r*i+i*n)}function hS(e,t,n,r,i,a){let o=-1,s=0;if(a===0)o=qx(t),o!==-1&&(s=(t[o]+t[o+3])/2);else if(a===1)o=qx(e),o!==-1&&(s=gS(n,r,i,o));else if(a===2){let a=Yx(e),c=Vx*i,l=n.offset||0,u=(r-l)*6,d=(r+i-l)*6;for(let e=0;e<3;e++){let r=t[e],l=(t[e+3]-r)/iS;if(i<aS){for(let t=0;t<i;t++){let r=u+t*6,i=n[r+2*e],a=t;for(;a>0&&n[dS[a-1]+2*e]>i;)dS[a]=dS[a-1],a--;dS[a]=r}for(let e=0;e<3;e++)lS[e]=1/0,lS[e+3]=-1/0,uS[e]=1/0,uS[e+3]=-1/0;for(let e=i-1;e>=0;e--)Jx(dS[e],n,uS),fS.set(uS,e*6);for(let t=0;t<i-1;t++){Jx(dS[t],n,lS);let r=n[dS[t+1]+2*e];if(n[dS[t]+2*e]===r)continue;let l=t+1,u=i-l,d=Yx(lS)/a,f=mS(fS,l*6)/a,p=1+Vx*(d*l+f*u);p<c&&(o=e,c=p,s=r)}}else{for(let e=0;e<iS;e++){oS[e]=0;for(let t=0;t<3;t++)sS[e*6+t]=1/0,sS[e*6+t+3]=-1/0}for(let t=u;t<d;t+=6){let i=~~((n[t+2*e]-r)/l);i>=iS&&(i=7),oS[i]++,pS(t,n,sS,i*6)}for(let e=0;e<6;e++)cS[42+e]=sS[42+e];for(let e=6;e>=0;e--){let t=e*6,n=t+6;for(let e=0;e<3;e++)cS[t+e]=Math.min(sS[t+e],cS[n+e]),cS[t+e+3]=Math.max(sS[t+e+3],cS[n+e+3])}let t=0;for(let n=0;n<7;n++){let u=n*6,d=oS[n];if(d!==0)for(let e=0;e<3;e++)t===0?(lS[e]=sS[u+e],lS[e+3]=sS[u+e+3]):(lS[e]=Math.min(lS[e],sS[u+e]),lS[e+3]=Math.max(lS[e+3],sS[u+e+3]));t+=d;let f=0,p=0;t!==0&&(f=Yx(lS)/a);let m=i-t;m!==0&&(p=mS(cS,u+6)/a);let h=1+Vx*(f*t+p*m);h<c&&(o=e,c=h,s=r+l+n*l)}}}}else console.warn(`BVH: Invalid build strategy value ${a} used.`);return{axis:o,pos:s}}function gS(e,t,n,r){let i=0,a=e.offset;for(let o=t,s=t+n;o<s;o++)i+=e[(o-a)*6+r*2];return i/n}function _S(e,t,n,r,i,a){let o=r,s=r+i-1,c=a.pos,l=a.axis*2,u=n.offset||0;for(;;){for(;o<=s&&n[(o-u)*6+l]<c;)o++;for(;o<=s&&n[(s-u)*6+l]>=c;)s--;if(o<s){for(let n=0;n<t;n++){let r=e[o*t+n];e[o*t+n]=e[s*t+n],e[s*t+n]=r}for(let e=0;e<6;e++){let t=o-u,r=s-u,i=n[t*6+e];n[t*6+e]=n[r*6+e],n[r*6+e]=i}o++,s--}else return o}}var vS=2**32,yS=new Float32Array(6),bS=new Float32Array(6);function xS(e,t,n,r,i,a){let{maxDepth:o,verbose:s,targetLeafSize:c,_strictLeafSize:l=1/0,strategy:u,onProgress:d,useSharedArrayBuffer:f=!1}=i,p=e.primitiveBuffer,m=e.primitiveBufferStride,h=new(f?SharedArrayBuffer:ArrayBuffer)(32*Math.max(1,2*Math.ceil(r)-1)),g=new Float32Array(h),_=new Uint32Array(h),v=new Uint16Array(h),y=0,b=!1;return rS(t,n,r,yS,bS),C(n,r,0),h.slice(0,y*32);function x(e){d&&d((e-a.offset)/a.count)}function S(e,t,n){let r=e*2;_[e+6]=t,v[r+14]=n,v[r+15]=Hx,x(t+n)}function C(e,n,r){let i=y++,a=i*8;g.set(yS,a),!b&&r>=o&&(b=!0,s&&console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`));let d=n>l;if(n<=c&&!d||r>=o){S(a,e,n);return}let f=hS(yS,bS,t,e,n,u),h=f.axis===-1?-1:_S(p,m,t,e,n,f);if(f.axis===-1||h===e||h===e+n){if(!d){S(a,e,n);return}f.axis=Math.max(0,qx(yS)),h=e+Math.max(1,Math.floor(n/2))}_[a+7]=f.axis;let v=h-e;rS(t,e,v,yS,bS),C(e,v,r+1);let x=y-i;if(x>vS)throw Error(`MeshBVH: Cannot store relative child node offset greater than 32 bits.`);_[a+6]=x;let w=n-v;rS(t,h,w,yS,bS),C(h,w,r+1)}}function SS(e,t){let n=e.getRootRanges(t.range),r=n[0],i=n[n.length-1],a={offset:r.offset,count:i.offset+i.count-r.offset},o=new Float32Array(6*a.count);o.offset=a.offset,e.computePrimitiveBounds(a.offset,a.count,o),e._roots=n.map(n=>xS(e,o,n.offset,n.count,t,a))}var CS=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}},wS=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;let e=[],t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}},TS,ES,DS=[],OS=new CS(()=>new ep);function kS(e,t,n,r,i,a){TS=OS.getPrimitive(),ES=OS.getPrimitive(),DS.push(TS,ES),wS.setBuffer(e._roots[t]);let o=AS(0,e.geometry,n,r,i,a);wS.clearBuffer(),OS.releasePrimitive(TS),OS.releasePrimitive(ES),DS.pop(),DS.pop();let s=DS.length;return s>0&&(ES=DS[s-1],TS=DS[s-2]),o}function AS(e,t,n,r,i=null,a=0,o=0){let{float32Array:s,uint16Array:c,uint32Array:l}=wS,u=e*2;if(Xx(u,c)){let t=Zx(e,l),n=Qx(u,c);return Kx(nS(e),s,TS),r(t,n,!1,o,a+e/8,TS)}{let u=$x(e),d=eS(e,l),f=u,p=d,m,h,g,_;if(i&&(g=TS,_=ES,Kx(nS(f),s,g),Kx(nS(p),s,_),m=i(g),h=i(_),h<m)){f=d,p=u;let e=m;m=h,h=e,g=_}g||(g=TS,Kx(nS(f),s,g));let v=Xx(f*2,c),y=n(g,v,m,o+1,a+f/8),b;if(y===2){let e=w(f);b=r(e,T(f)-e,!0,o+1,a+f/8,g)}else b=y&&AS(f,t,n,r,i,a,o+1);if(b)return!0;_=ES,Kx(nS(p),s,_);let x=Xx(p*2,c),S=n(_,x,h,o+1,a+p/8),C;if(S===2){let e=w(p);C=r(e,T(p)-e,!0,o+1,a+p/8,_)}else C=S&&AS(p,t,n,r,i,a,o+1);return!!C;function w(e){let{uint16Array:t,uint32Array:n}=wS,r=e*2;for(;!Xx(r,t);)e=$x(e),r=e*2;return Zx(e,n)}function T(e){let{uint16Array:t,uint32Array:n}=wS,r=e*2;for(;!Xx(r,t);)e=eS(e,n),r=e*2;return Zx(e,n)+Qx(r,t)}}}var jS=new wS.constructor,MS=new wS.constructor,NS=new CS(()=>new ep),PS=new ep,FS=new ep,IS=new ep,LS=new ep,RS=!1;function zS(e,t,n,r){if(RS)throw Error(`MeshBVH: Recursive calls to bvhcast not supported.`);RS=!0;let i=e._roots,a=t._roots,o,s=0,c=0,l=new tf().copy(n).invert();for(let e=0,t=i.length;e<t;e++){jS.setBuffer(i[e]),c=0;let t=NS.getPrimitive();Kx(nS(0),jS.float32Array,t),t.applyMatrix4(l);for(let e=0,i=a.length;e<i&&(MS.setBuffer(a[e]),o=BS(0,0,n,l,r,s,c,0,0,t),MS.clearBuffer(),c+=a[e].byteLength/32,!o);e++);if(NS.releasePrimitive(t),jS.clearBuffer(),s+=i[e].byteLength/32,o)break}return RS=!1,o}function BS(e,t,n,r,i,a=0,o=0,s=0,c=0,l=null,u=!1){let d,f;u?(d=MS,f=jS):(d=jS,f=MS);let p=d.float32Array,m=d.uint32Array,h=d.uint16Array,g=f.float32Array,_=f.uint32Array,v=f.uint16Array,y=e*2,b=t*2,x=Xx(y,h),S=Xx(b,v),C=!1;if(S&&x)C=u?i(Zx(t,_),Qx(t*2,v),Zx(e,m),Qx(e*2,h),c,o+t/8,s,a+e/8):i(Zx(e,m),Qx(e*2,h),Zx(t,_),Qx(t*2,v),s,a+e/8,c,o+t/8);else if(S){let l=NS.getPrimitive();Kx(nS(t),g,l),l.applyMatrix4(n);let d=$x(e),f=eS(e,m);Kx(nS(d),p,PS),Kx(nS(f),p,FS);let h=l.intersectsBox(PS),_=l.intersectsBox(FS);C=h&&BS(t,d,r,n,i,o,a,c,s+1,l,!u)||_&&BS(t,f,r,n,i,o,a,c,s+1,l,!u),NS.releasePrimitive(l)}else{let d=$x(t),f=eS(t,_);Kx(nS(d),g,IS),Kx(nS(f),g,LS);let h=l.intersectsBox(IS),v=l.intersectsBox(LS);if(h&&v)C=BS(e,d,n,r,i,a,o,s,c+1,l,u)||BS(e,f,n,r,i,a,o,s,c+1,l,u);else if(h){if(x)C=BS(e,d,n,r,i,a,o,s,c+1,l,u);else{let t=NS.getPrimitive();t.copy(IS).applyMatrix4(n);let l=$x(e),f=eS(e,m);Kx(nS(l),p,PS),Kx(nS(f),p,FS);let h=t.intersectsBox(PS),g=t.intersectsBox(FS);C=h&&BS(d,l,r,n,i,o,a,c,s+1,t,!u)||g&&BS(d,f,r,n,i,o,a,c,s+1,t,!u),NS.releasePrimitive(t)}}else if(v){if(x)C=BS(e,f,n,r,i,a,o,s,c+1,l,u);else{let t=NS.getPrimitive();t.copy(LS).applyMatrix4(n);let l=$x(e),d=eS(e,m);Kx(nS(l),p,PS),Kx(nS(d),p,FS);let h=t.intersectsBox(PS),g=t.intersectsBox(FS);C=h&&BS(f,l,r,n,i,o,a,c,s+1,t,!u)||g&&BS(f,d,r,n,i,o,a,c,s+1,t,!u),NS.releasePrimitive(t)}}}return C}var VS=new class{constructor(){let e=null,t=null,n=null,r=!1;this.root=null,this.buffer=null,this.uint32Array=null,this.uint16Array=null,this.setBVH=(i,a)=>{if(r)throw Error(`BVHTraversalHelper: cannot call setBVH during an active traversal.`);this.root=a,this.buffer=e=i._roots[a],this.uint16Array=n=new Uint16Array(e),this.uint32Array=t=new Uint32Array(e)},this.reset=()=>{this.root=null,this.buffer=e=null,this.uint16Array=n=null,this.uint32Array=t=null},this.getRangeStart=e=>{let r=e*2;for(;!Xx(r,n);)e=$x(e),r=e*2;return Zx(e,t)},this.getRangeEnd=e=>{let r=e*2;for(;!Xx(r,n);)e=eS(e,t),r=e*2;return Zx(e,t)+Qx(r,n)};let i=(e,r,a)=>{let o=Xx(r*2,n);if(!e(a,o,r)&&!o){let n=$x(r),o=eS(r,t);i(e,n,a+1),i(e,o,a+1)}};this.traverseBuffer=e=>{if(r)throw Error(`BVHTraversalHelper: cannot start a traversal during an active traversal.`);r=!0;try{i(e,0,0)}finally{r=!1}},this.traverse=r=>{this.traverseBuffer((i,a,o)=>{if(a){let s=o*2,c=t[o+6],l=n[s+14];return r(i,a,new Float32Array(e,o*4,6),c,l)}{let n=tS(o,t);return r(i,a,new Float32Array(e,o*4,6),n)}})}}},HS=new ep,US=new Float32Array(6),WS=class{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...Gx,...e},`maxLeafSize`in e&&(console.warn(`BVH: "maxLeafSize" option has been deprecated. Use "targetLeafSize", instead.`),e={...e,targetLeafSize:e.maxLeafSize}),SS(this,e)}getRootRanges(){throw Error(`BVH: getRootRanges() not implemented`)}writePrimitiveBounds(){throw Error(`BVH: writePrimitiveBounds() not implemented`)}writePrimitiveRangeBounds(e,t,n,r){let i=1/0,a=1/0,o=1/0,s=-1/0,c=-1/0,l=-1/0;for(let n=e,r=e+t;n<r;n++){this.writePrimitiveBounds(n,US,0);let[e,t,r,u,d,f]=US;e<i&&(i=e),u>s&&(s=u),t<a&&(a=t),d>c&&(c=d),r<o&&(o=r),f>l&&(l=f)}return n[r+0]=i,n[r+1]=a,n[r+2]=o,n[r+3]=s,n[r+4]=c,n[r+5]=l,n}computePrimitiveBounds(e,t,n){let r=n.offset||0;for(let i=e,a=e+t;i<a;i++){this.writePrimitiveBounds(i,US,0);let[e,t,a,o,s,c]=US,l=(e+o)/2,u=(t+s)/2,d=(a+c)/2,f=(o-e)/2,p=(s-t)/2,m=(c-a)/2,h=(i-r)*6;n[h+0]=l,n[h+1]=f+(Math.abs(l)+f)*Ux,n[h+2]=u,n[h+3]=p+(Math.abs(u)+p)*Ux,n[h+4]=d,n[h+5]=m+(Math.abs(d)+m)*Ux}return n}shiftPrimitiveOffsets(e){let t=this._indirectBuffer;if(t)for(let n=0,r=t.length;n<r;n++)t[n]+=e;else{let t=this._roots;for(let n=0;n<t.length;n++){let r=t[n],i=new Uint32Array(r),a=new Uint16Array(r),o=r.byteLength/32;for(let t=0;t<o;t++){let n=8*t;Xx(2*n,a)&&(i[n+6]+=e)}}}}traverse(e,t=0){VS.setBVH(this,t),VS.traverse(e),VS.reset()}refit(){let e=this._roots;for(let t=0,n=e.length;t<n;t++){let n=e[t],r=new Uint32Array(n),i=new Uint16Array(n),a=new Float32Array(n),o=n.byteLength/32;for(let e=o-1;e>=0;e--){let t=e*8,n=t*2;if(Xx(n,i)){let e=Zx(t,r),o=Qx(n,i);this.writePrimitiveRangeBounds(e,o,US,0),a.set(US,t)}else{let e=$x(t),n=eS(t,r);for(let r=0;r<3;r++){let i=a[e+r],o=a[e+r+3],s=a[n+r],c=a[n+r+3];a[t+r]=i<s?i:s,a[t+r+3]=o>c?o:c}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Kx(0,new Float32Array(t),HS),e.union(HS)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:r,intersectsPrimitive:i,scratchPrimitive:a,iterate:o}=e;if(r&&i){let e=r;r=(t,n,r,s,c)=>e(t,n,r,s,c)?!0:o(t,n,this,i,r,s,a)}else r||=i?(e,t,n,r)=>o(e,t,this,i,n,r,a):(e,t,n)=>n;let s=!1,c=0,l=this._roots;for(let e=0,i=l.length;e<i;e++){let i=l[e];if(s=kS(this,e,n,r,t,c),s)break;c+=i.byteLength/32}return s}bvhcast(e,t,n){let{intersectsRanges:r}=n;return zS(this,e,t,r)}};function GS(){return typeof SharedArrayBuffer<`u`}function KS(e){return e.index?e.index.count:e.attributes.position.count}function qS(e){return KS(e)/3}function JS(e,t=ArrayBuffer){return e>65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}function YS(e,t){if(!e.index){let n=e.attributes.position.count,r=JS(n,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);e.setIndex(new Cp(r,1));for(let e=0;e<n;e++)r[e]=e}}function XS(e,t,n){let r=KS(e)/n,i=t||e.drawRange,a=i.start/n,o=(i.start+i.count)/n,s=Math.max(0,a),c=Math.min(r,o)-s;return{offset:Math.floor(s),count:Math.floor(c)}}function ZS(e,t){return e.groups.map(e=>({offset:e.start/t,count:e.count/t}))}function QS(e,t,n){let r=XS(e,t,n),i=ZS(e,n);if(!i.length)return[r];let a=[],o=r.offset,s=r.offset+r.count,c=KS(e)/n,l=[];for(let e of i){let{offset:t,count:n}=e,r=t,i=t+(isFinite(n)?n:c-t);r<s&&i>o&&(l.push({pos:Math.max(o,r),isStart:!0}),l.push({pos:Math.min(s,i),isStart:!1}))}l.sort((e,t)=>e.pos===t.pos?e.type===`end`?-1:1:e.pos-t.pos);let u=0,d=null;for(let e of l){let t=e.pos;u!==0&&t!==d&&a.push({offset:d,count:t-d}),u+=e.isStart?1:-1,d=t}return a}function $S(e,t){let n=e[e.length-1],r=n.offset+n.count>2**16,i=e.reduce((e,t)=>e+t.count,0),a=r?4:2,o=t?new SharedArrayBuffer(i*a):new ArrayBuffer(i*a),s=r?new Uint32Array(o):new Uint16Array(o),c=0;for(let t=0;t<e.length;t++){let{offset:n,count:r}=e[t];for(let e=0;e<r;e++)s[c+e]=n+e;c+=r}return s}var eC=class extends WS{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(!e.isBufferGeometry)throw Error(`BVH: Only BufferGeometries are supported.`);if(e.index&&e.index.isInterleavedBufferAttribute)throw Error(`BVH: InterleavedBufferAttribute is not supported for the index attribute.`);if(t.useSharedArrayBuffer&&!GS())throw Error(`BVH: SharedArrayBuffer is not available.`);super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?e=>this._indirectBuffer[e]:e=>e,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...Gx,...t},t[Wx]||this.init(t)}init(e){let{geometry:t,primitiveStride:n}=this;if(e.indirect){let r=$S(QS(t,e.range,n),e.useSharedArrayBuffer);this._indirectBuffer=r}else YS(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new ep))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:QS(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw Error(`BVH: raycastObject3D() not implemented`)}},tC=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,r=-1/0;for(let i=0,a=e.length;i<a;i++){let a=e[i][t];n=a<n?a:n,r=a>r?a:r}this.min=n,this.max=r}setFromPoints(e,t){let n=1/0,r=-1/0;for(let i=0,a=t.length;i<a;i++){let a=t[i],o=e.dot(a);n=o<n?o:n,r=o>r?o:r}this.min=n,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};tC.prototype.setFromBox=(function(){let e=new $;return function(t,n){let r=n.min,i=n.max,a=1/0,o=-1/0;for(let n=0;n<=1;n++)for(let s=0;s<=1;s++)for(let c=0;c<=1;c++){e.x=r.x*n+i.x*(1-n),e.y=r.y*s+i.y*(1-s),e.z=r.z*c+i.z*(1-c);let l=t.dot(e);a=Math.min(l,a),o=Math.max(l,o)}this.min=a,this.max=o}})();var nC=(function(){let e=new $,t=new $,n=new $;return function(r,i,a){let o=r.start,s=e,c=i.start,l=t;n.subVectors(o,c),e.subVectors(r.end,r.start),t.subVectors(i.end,i.start);let u=n.dot(l),d=l.dot(s),f=l.dot(l),p=n.dot(s),m=s.dot(s)*f-d*d,h,g;h=m===0?0:(u*d-p*f)/m,g=(u+h*d)/f,a.x=h,a.y=g}})(),rC=(function(){let e=new Q,t=new $,n=new $;return function(r,i,a,o){nC(r,i,e);let s=e.x,c=e.y;if(s>=0&&s<=1&&c>=0&&c<=1)r.at(s,a),i.at(c,o);else if(s>=0&&s<=1)c<0?i.at(0,o):i.at(1,o),r.closestPointToPoint(o,!0,a);else if(c>=0&&c<=1)s<0?r.at(0,a):r.at(1,a),i.closestPointToPoint(a,!0,o);else{let e;e=s<0?r.start:r.end;let l;l=c<0?i.start:i.end;let u=t,d=n;if(r.closestPointToPoint(l,!0,t),i.closestPointToPoint(e,!0,n),u.distanceToSquared(l)<=d.distanceToSquared(e)){a.copy(u),o.copy(l);return}a.copy(e),o.copy(d);return}}})(),iC=(function(){let e=new $,t=new $,n=new Kp,r=new o_;return function(i,a){let{radius:o,center:s}=i,{a:c,b:l,c:u}=a;if(r.start=c,r.end=l,r.closestPointToPoint(s,!0,e).distanceTo(s)<=o||(r.start=c,r.end=u,r.closestPointToPoint(s,!0,e).distanceTo(s)<=o)||(r.start=l,r.end=u,r.closestPointToPoint(s,!0,e).distanceTo(s)<=o))return!0;let d=a.getPlane(n);if(Math.abs(d.distanceToPoint(s))<=o){let e=d.projectPoint(s,t);if(a.containsPoint(e))return!0}return!1}})(),aC=[`x`,`y`,`z`],oC=1e-15,sC=oC*oC;function cC(e){return Math.abs(e)<oC}var lC=class extends $f{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=[,,,,].fill().map(()=>new $),this.satBounds=[,,,,].fill().map(()=>new tC),this.points=[this.a,this.b,this.c],this.plane=new Kp,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new o_,this.needsUpdate=!0}intersectsSphere(e){return iC(e,this)}update(){let e=this.a,t=this.b,n=this.c,r=this.points,i=this.satAxes,a=this.satBounds,o=i[0],s=a[0];this.getNormal(o),s.setFromPoints(o,r);let c=i[1],l=a[1];c.subVectors(e,t),l.setFromPoints(c,r);let u=i[2],d=a[2];u.subVectors(t,n),d.setFromPoints(u,r);let f=i[3],p=a[3];f.subVectors(n,e),p.setFromPoints(f,r);let m=c.length(),h=u.length(),g=f.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,m<oC?h<oC||g<oC?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):h<oC?g<oC?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):g<oC&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}};lC.prototype.closestPointToSegment=(function(){let e=new $,t=new $,n=new o_;return function(r,i=null,a=null){this.needsUpdate&&this.update();let{start:o,end:s}=r,c=this.points,l,u=1/0;if(this.plane.distanceToPoint(o)*this.plane.distanceToPoint(s)<0&&this.plane.intersectLine(r,e)!==null&&this.containsPoint(e))return i&&i.copy(e),a&&a.copy(e),0;for(let o=0;o<3;o++){let s=(o+1)%3;n.start.copy(c[o]),n.end.copy(c[s]),rC(n,r,e,t),l=e.distanceToSquared(t),l<u&&(u=l,i&&i.copy(e),a&&a.copy(t))}return this.closestPointToPoint(o,e),l=o.distanceToSquared(e),l<u&&(u=l,i&&i.copy(e),a&&a.copy(o)),this.closestPointToPoint(s,e),l=s.distanceToSquared(e),l<u&&(u=l,i&&i.copy(e),a&&a.copy(s)),Math.sqrt(u)}})(),lC.prototype.intersectsTriangle=(function(){let e=new lC,t=new tC,n=new tC,r=new $,i=new $,a=new $,o=new $,s=new o_,c=new o_,l=new $,u=new Q,d=new Q;function f(e,i,a,s){let c=r;!e.isDegenerateIntoPoint&&!e.isDegenerateIntoSegment?c.copy(e.plane.normal):c.copy(i.plane.normal);let l=e.satBounds,u=e.satAxes;for(let r=1;r<4;r++){let a=l[r],s=u[r];if(t.setFromPoints(s,i.points),a.isSeparated(t)||(o.copy(c).cross(s),t.setFromPoints(o,e.points),n.setFromPoints(o,i.points),t.isSeparated(n)))return!1}let d=i.satBounds,f=i.satAxes;for(let r=1;r<4;r++){let a=d[r],s=f[r];if(t.setFromPoints(s,e.points),a.isSeparated(t)||(o.crossVectors(c,s),t.setFromPoints(o,e.points),n.setFromPoints(o,i.points),t.isSeparated(n)))return!1}return a&&(s||console.warn(`ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0.`),a.start.set(0,0,0),a.end.set(0,0,0)),!0}function p(e,t,n,r,i,a,o,s,c,l,u){let d=o/(o-s);l.x=r+(i-r)*d,u.start.subVectors(t,e).multiplyScalar(d).add(e),d=o/(o-c),l.y=r+(a-r)*d,u.end.subVectors(n,e).multiplyScalar(d).add(e)}function m(e,t,n,r,i,a,o,s,c,l,u){if(i>0)p(e.c,e.a,e.b,r,t,n,c,o,s,l,u);else if(a>0)p(e.b,e.a,e.c,n,t,r,s,o,c,l,u);else if(s*c>0||o!=0)p(e.a,e.b,e.c,t,n,r,o,s,c,l,u);else if(s!=0)p(e.b,e.a,e.c,n,t,r,s,o,c,l,u);else if(c!=0)p(e.c,e.a,e.b,r,t,n,c,o,s,l,u);else return!0;return!1}function h(e,t,n,i){let a=t.degenerateSegment,o=e.plane.distanceToPoint(a.start),s=e.plane.distanceToPoint(a.end);return cC(o)?cC(s)?f(e,t,n,i):(n&&(n.start.copy(a.start),n.end.copy(a.start)),e.containsPoint(a.start)):cC(s)?(n&&(n.start.copy(a.end),n.end.copy(a.end)),e.containsPoint(a.end)):e.plane.intersectLine(a,r)!=null&&(n&&(n.start.copy(r),n.end.copy(r)),e.containsPoint(r))}function g(e,t,n){let r=t.a;return cC(e.plane.distanceToPoint(r))&&e.containsPoint(r)?(n&&(n.start.copy(r),n.end.copy(r)),!0):!1}function _(e,t,n){let i=e.degenerateSegment,a=t.a;return i.closestPointToPoint(a,!0,r),a.distanceToSquared(r)<sC&&(n&&(n.start.copy(a),n.end.copy(a)),!0)}function v(e,t,n,o){if(e.isDegenerateIntoSegment){if(t.isDegenerateIntoSegment){let o=e.degenerateSegment,s=t.degenerateSegment,c=i,l=a;o.delta(c),s.delta(l);let u=r.subVectors(s.start,o.start),d=c.x*l.y-c.y*l.x;if(cC(d))return!1;let f=(u.x*l.y-u.y*l.x)/d,p=-(c.x*u.y-c.y*u.x)/d;return f<0||f>1||p<0||p>1?!1:cC(o.start.z+c.z*f-(s.start.z+l.z*p))?(n&&(n.start.copy(o.start).addScaledVector(c,f),n.end.copy(o.start).addScaledVector(c,f)),!0):!1}return t.isDegenerateIntoPoint?_(e,t,n):h(t,e,n,o)}if(e.isDegenerateIntoPoint)return t.isDegenerateIntoPoint?t.a.distanceToSquared(e.a)<sC&&(n&&(n.start.copy(e.a),n.end.copy(e.a)),!0):t.isDegenerateIntoSegment?_(t,e,n):g(t,e,n);if(t.isDegenerateIntoPoint)return g(e,t,n);if(t.isDegenerateIntoSegment)return h(e,t,n,o)}return function(t,n=null,r=!1){this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);let o=v(this,t,n,r);if(o!==void 0)return o;let p=this.plane,h=t.plane,g=h.distanceToPoint(this.a),_=h.distanceToPoint(this.b),y=h.distanceToPoint(this.c);cC(g)&&(g=0),cC(_)&&(_=0),cC(y)&&(y=0);let b=g*_,x=g*y;if(b>0&&x>0)return!1;let S=p.distanceToPoint(t.a),C=p.distanceToPoint(t.b),w=p.distanceToPoint(t.c);cC(S)&&(S=0),cC(C)&&(C=0),cC(w)&&(w=0);let T=S*C,E=S*w;if(T>0&&E>0)return!1;i.copy(p.normal),a.copy(h.normal);let D=i.cross(a),O=0,k=Math.abs(D.x),A=Math.abs(D.y);A>k&&(k=A,O=1),Math.abs(D.z)>k&&(O=2);let j=aC[O],M=this.a[j],N=this.b[j],P=this.c[j],F=t.a[j],I=t.b[j],ee=t.c[j];if(m(this,M,N,P,b,x,g,_,y,u,s)||m(t,F,I,ee,T,E,S,C,w,d,c))return f(this,t,n,r);if(u.y<u.x){let e=u.y;u.y=u.x,u.x=e,l.copy(s.start),s.start.copy(s.end),s.end.copy(l)}if(d.y<d.x){let e=d.y;d.y=d.x,d.x=e,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return u.y<d.x||d.y<u.x?!1:(n&&(d.x>u.x?n.start.copy(c.start):n.start.copy(s.start),d.y<u.y?n.end.copy(c.end):n.end.copy(s.end)),!0)}})(),lC.prototype.distanceToPoint=(function(){let e=new $;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}})(),lC.prototype.distanceToTriangle=(function(){let e=new $,t=new $,n=[`a`,`b`,`c`],r=new o_,i=new o_;return function(a,o=null,s=null){let c=o||s?r:null;if(this.intersectsTriangle(a,c,!0))return(o||s)&&(o&&c.getCenter(o),s&&c.getCenter(s)),0;let l=1/0;for(let t=0;t<3;t++){let r,i=n[t],c=a[i];this.closestPointToPoint(c,e),r=c.distanceToSquared(e),r<l&&(l=r,o&&o.copy(e),s&&s.copy(c));let u=this[i];a.closestPointToPoint(u,e),r=u.distanceToSquared(e),r<l&&(l=r,o&&o.copy(u),s&&s.copy(e))}for(let c=0;c<3;c++){let u=n[c],d=n[(c+1)%3];r.set(this[u],this[d]);for(let c=0;c<3;c++){let u=n[c],d=n[(c+1)%3];i.set(a[u],a[d]),rC(r,i,e,t);let f=e.distanceToSquared(t);f<l&&(l=f,o&&o.copy(e),s&&s.copy(t))}}return Math.sqrt(l)}})();var uC=class{constructor(e,t,n){this.isOrientedBox=!0,this.min=new $,this.max=new $,this.matrix=new tf,this.invMatrix=new tf,this.points=Array(8).fill().map(()=>new $),this.satAxes=[,,,].fill().map(()=>new $),this.satBounds=[,,,].fill().map(()=>new tC),this.alignedSatBounds=[,,,].fill().map(()=>new tC),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};uC.prototype.update=(function(){return function(){let e=this.matrix,t=this.min,n=this.max,r=this.points;for(let i=0;i<=1;i++)for(let a=0;a<=1;a++)for(let o=0;o<=1;o++){let s=r[1*i|2*a|4*o];s.x=i?n.x:t.x,s.y=a?n.y:t.y,s.z=o?n.z:t.z,s.applyMatrix4(e)}let i=this.satBounds,a=this.satAxes,o=r[0];for(let e=0;e<3;e++){let t=a[e],n=i[e],s=r[1<<e];t.subVectors(o,s),n.setFromPoints(t,r)}let s=this.alignedSatBounds;s[0].setFromPointsField(r,`x`),s[1].setFromPointsField(r,`y`),s[2].setFromPointsField(r,`z`),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),uC.prototype.intersectsBox=(function(){let e=new tC;return function(t){this.needsUpdate&&this.update();let n=t.min,r=t.max,i=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(e.min=n.x,e.max=r.x,o[0].isSeparated(e)||(e.min=n.y,e.max=r.y,o[1].isSeparated(e))||(e.min=n.z,e.max=r.z,o[2].isSeparated(e)))return!1;for(let n=0;n<3;n++){let r=a[n],o=i[n];if(e.setFromBox(r,t),o.isSeparated(e))return!1}return!0}})(),uC.prototype.intersectsTriangle=(function(){let e=new lC,t=[,,,],n=new tC,r=new tC,i=new $;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(e.copy(a),e.update(),a=e);let o=this.satBounds,s=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let e=0;e<3;e++){let r=o[e],i=s[e];if(n.setFromPoints(i,t),r.isSeparated(n))return!1}let c=a.satBounds,l=a.satAxes,u=this.points;for(let e=0;e<3;e++){let t=c[e],r=l[e];if(n.setFromPoints(r,u),t.isSeparated(n))return!1}for(let e=0;e<3;e++){let a=s[e];for(let e=0;e<4;e++){let o=l[e];if(i.crossVectors(a,o),n.setFromPoints(i,t),r.setFromPoints(i,u),n.isSeparated(r))return!1}}return!0}})(),uC.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})(),uC.prototype.distanceToPoint=(function(){let e=new $;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}})(),uC.prototype.distanceToBox=(function(){let e=[`x`,`y`,`z`],t=Array(12).fill().map(()=>new o_),n=Array(12).fill().map(()=>new o_),r=new $,i=new $;return function(a,o=0,s=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(s||c)&&(a.getCenter(i),this.closestPointToPoint(i,r),a.closestPointToPoint(r,i),s&&s.copy(r),c&&c.copy(i)),0;let l=o*o,u=a.min,d=a.max,f=this.points,p=1/0;for(let e=0;e<8;e++){let t=f[e];i.copy(t).clamp(u,d);let n=t.distanceToSquared(i);if(n<p&&(p=n,s&&s.copy(t),c&&c.copy(i),n<l))return Math.sqrt(n)}let m=0;for(let r=0;r<3;r++)for(let i=0;i<=1;i++)for(let a=0;a<=1;a++){let o=(r+1)%3,s=(r+2)%3,c=i<<o|a<<s,l=1<<r|i<<o|a<<s,p=f[c],h=f[l];t[m].set(p,h);let g=e[r],_=e[o],v=e[s],y=n[m],b=y.start,x=y.end;b[g]=u[g],b[_]=i?u[_]:d[_],b[v]=a?u[v]:d[v],x[g]=d[g],x[_]=i?u[_]:d[_],x[v]=a?u[v]:d[v],m++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){i.x=e?d.x:u.x,i.y=t?d.y:u.y,i.z=n?d.z:u.z,this.closestPointToPoint(i,r);let a=i.distanceToSquared(r);if(a<p&&(p=a,s&&s.copy(r),c&&c.copy(i),a<l))return Math.sqrt(a)}for(let e=0;e<12;e++){let a=t[e];for(let e=0;e<12;e++){let t=n[e];rC(a,t,r,i);let o=r.distanceToSquared(i);if(o<p&&(p=o,s&&s.copy(r),c&&c.copy(i),o<l))return Math.sqrt(o)}}return Math.sqrt(p)}})();var dC=new class extends CS{constructor(){super(()=>new lC)}},fC=new $,pC=new $;function mC(e,t,n={},r=0,i=1/0){let a=r*r,o=i*i,s=1/0,c=null;if(e.shapecast({boundsTraverseOrder:e=>(fC.copy(t).clamp(e.min,e.max),fC.distanceToSquared(t)),intersectsBounds:(e,t,n)=>n<s&&n<o,intersectsTriangle:(e,n)=>{e.closestPointToPoint(t,fC);let r=t.distanceToSquared(fC);return r<s&&(pC.copy(fC),s=r,c=n),r<a}}),s===1/0)return null;let l=Math.sqrt(s);return n.point?n.point.copy(pC):n.point=pC.clone(),n.distance=l,n.faceIndex=c,n}var hC=!0,gC=new $,_C=new $,vC=new $,yC=new Q,bC=new Q,xC=new Q,SC=new $,CC=new $,wC=new $,TC=new $;function EC(e,t,n,r,i,a,o,s){let c;if(c=a===1?e.intersectTriangle(r,n,t,!0,i):e.intersectTriangle(t,n,r,a!==2,i),c===null)return null;let l=e.origin.distanceTo(i);return l<o||l>s?null:{distance:l,point:i.clone()}}function DC(e,t,n,r,i,a,o,s,c,l,u){gC.fromBufferAttribute(t,a),_C.fromBufferAttribute(t,o),vC.fromBufferAttribute(t,s);let d=EC(e,gC,_C,vC,TC,c,l,u);if(d){if(r){yC.fromBufferAttribute(r,a),bC.fromBufferAttribute(r,o),xC.fromBufferAttribute(r,s),d.uv=new Q;let e=$f.getInterpolation(TC,gC,_C,vC,yC,bC,xC,d.uv);hC||(d.uv=e)}if(i){yC.fromBufferAttribute(i,a),bC.fromBufferAttribute(i,o),xC.fromBufferAttribute(i,s),d.uv1=new Q;let e=$f.getInterpolation(TC,gC,_C,vC,yC,bC,xC,d.uv1);hC||(d.uv1=e)}if(n){SC.fromBufferAttribute(n,a),CC.fromBufferAttribute(n,o),wC.fromBufferAttribute(n,s),d.normal=new $;let t=$f.getInterpolation(TC,gC,_C,vC,SC,CC,wC,d.normal);d.normal.dot(e.direction)>0&&d.normal.multiplyScalar(-1),hC||(d.normal=t)}let t={a,b:o,c:s,normal:new $,materialIndex:0};if($f.getNormal(gC,_C,vC,t.normal),d.face=t,d.faceIndex=a,hC){let e=new $;$f.getBarycoord(TC,gC,_C,vC,e),d.barycoord=e}}return d}function OC(e){return e&&e.isMaterial?e.side:e}function kC(e,t,n,r,i,a,o){let s=r*3,c=s+0,l=s+1,u=s+2,{index:d,groups:f}=e;e.index&&(c=d.getX(c),l=d.getX(l),u=d.getX(u));let{position:p,normal:m,uv:h,uv1:g}=e.attributes;if(Array.isArray(t)){let e=r*3;for(let s=0,d=f.length;s<d;s++){let{start:d,count:_,materialIndex:v}=f[s];if(e>=d&&e<d+_){let e=OC(t[v]),s=DC(n,p,m,h,g,c,l,u,e,a,o);if(s){if(s.faceIndex=r,s.face.materialIndex=v,i)i.push(s);else return s}}}}else{let e=OC(t),s=DC(n,p,m,h,g,c,l,u,e,a,o);if(s){if(s.faceIndex=r,s.face.materialIndex=0,i)i.push(s);else return s}}return null}function AC(e,t,n,r){let i=e.a,a=e.b,o=e.c,s=t,c=t+1,l=t+2;n&&(s=n.getX(s),c=n.getX(c),l=n.getX(l)),i.x=r.getX(s),i.y=r.getY(s),i.z=r.getZ(s),a.x=r.getX(c),a.y=r.getY(c),a.z=r.getZ(c),o.x=r.getX(l),o.y=r.getY(l),o.z=r.getZ(l)}function jC(e,t,n,r,i,a,o,s){let{geometry:c,_indirectBuffer:l}=e;for(let e=r,l=r+i;e<l;e++)kC(c,t,n,e,a,o,s)}function MC(e,t,n,r,i,a,o){let{geometry:s,_indirectBuffer:c}=e,l=1/0,u=null;for(let e=r,c=r+i;e<c;e++){let r;r=kC(s,t,n,e,null,a,o),r&&r.distance<l&&(u=r,l=r.distance)}return u}function NC(e,t,n,r,i,a,o){let{geometry:s}=n,{index:c}=s,l=s.attributes.position;for(let n=e,s=t+e;n<s;n++){let e;if(e=n,AC(o,e*3,c,l),o.needsUpdate=!0,r(o,e,i,a))return!0}return!1}function PC(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));let n=e.geometry,r=n.index?n.index.array:null,i=n.attributes.position,a,o,s,c,l=0,u=e._roots;for(let e=0,t=u.length;e<t;e++)a=u[e],o=new Uint32Array(a),s=new Uint16Array(a),c=new Float32Array(a),d(0,l),l+=a.byteLength;function d(e,n,a=!1){let l=e*2;if(Xx(l,s)){let t=Zx(e,o),n=Qx(l,s),a=1/0,u=1/0,d=1/0,f=-1/0,p=-1/0,m=-1/0;for(let e=3*t,o=3*(t+n);e<o;e++){let t=r[e],n=i.getX(t),o=i.getY(t),s=i.getZ(t);n<a&&(a=n),n>f&&(f=n),o<u&&(u=o),o>p&&(p=o),s<d&&(d=s),s>m&&(m=s)}return c[e+0]!==a||c[e+1]!==u||c[e+2]!==d||c[e+3]!==f||c[e+4]!==p||c[e+5]!==m?(c[e+0]=a,c[e+1]=u,c[e+2]=d,c[e+3]=f,c[e+4]=p,c[e+5]=m,!0):!1}{let r=$x(e),i=eS(e,o),s=a,l=!1,u=!1;if(t){if(!s){let e=r/8+n/32,a=i/8+n/32;l=t.has(e),u=t.has(a),s=!l&&!u}}else l=!0,u=!0;let f=s||l,p=s||u,m=!1;f&&(m=d(r,n,s));let h=!1;p&&(h=d(i,n,s));let g=m||h;if(g)for(let t=0;t<3;t++){let n=r+t,a=i+t,o=c[n],s=c[n+3],l=c[a],u=c[a+3];c[e+t]=o<l?o:l,c[e+t+3]=s>u?s:u}return g}}}function FC(e,t,n,r,i){let a,o,s,c,l,u,d=1/n.direction.x,f=1/n.direction.y,p=1/n.direction.z,m=n.origin.x,h=n.origin.y,g=n.origin.z,_=t[e],v=t[e+3],y=t[e+1],b=t[e+3+1],x=t[e+2],S=t[e+3+2];return d>=0?(a=(_-m)*d,o=(v-m)*d):(a=(v-m)*d,o=(_-m)*d),f>=0?(s=(y-h)*f,c=(b-h)*f):(s=(b-h)*f,c=(y-h)*f),a>c||s>o||((s>a||isNaN(a))&&(a=s),(c<o||isNaN(o))&&(o=c),p>=0?(l=(x-g)*p,u=(S-g)*p):(l=(S-g)*p,u=(x-g)*p),a>u||l>o)?!1:((l>a||a!==a)&&(a=l),(u<o||o!==o)&&(o=u),a<=i&&o>=r)}function IC(e,t,n,r,i,a,o,s){let{geometry:c,_indirectBuffer:l}=e;for(let e=r,u=r+i;e<u;e++)kC(c,t,n,l?l[e]:e,a,o,s)}function LC(e,t,n,r,i,a,o){let{geometry:s,_indirectBuffer:c}=e,l=1/0,u=null;for(let e=r,d=r+i;e<d;e++){let r;r=kC(s,t,n,c?c[e]:e,null,a,o),r&&r.distance<l&&(u=r,l=r.distance)}return u}function RC(e,t,n,r,i,a,o){let{geometry:s}=n,{index:c}=s,l=s.attributes.position;for(let s=e,u=t+e;s<u;s++){let e;if(e=n.resolveTriangleIndex(s),AC(o,e*3,c,l),o.needsUpdate=!0,r(o,e,i,a))return!0}return!1}function zC(e,t,n,r,i,a,o){wS.setBuffer(e._roots[t]),FC(0,wS.float32Array,r,a,o)&&BC(0,e,n,r,i,a,o),wS.clearBuffer()}function BC(e,t,n,r,i,a,o){let{float32Array:s,uint16Array:c,uint32Array:l}=wS,u=e*2;if(Xx(u,c))jC(t,n,r,Zx(e,l),Qx(u,c),i,a,o);else{let c=$x(e);FC(c,s,r,a,o)&&BC(c,t,n,r,i,a,o);let u=eS(e,l);FC(u,s,r,a,o)&&BC(u,t,n,r,i,a,o)}}var VC=[`x`,`y`,`z`];function HC(e,t,n,r,i,a){wS.setBuffer(e._roots[t]);let o=null;return FC(0,wS.float32Array,r,i,a)&&(o=UC(0,e,n,r,i,a)),wS.clearBuffer(),o}function UC(e,t,n,r,i,a){let{float32Array:o,uint16Array:s,uint32Array:c}=wS,l=e*2;if(Xx(l,s))return MC(t,n,r,Zx(e,c),Qx(l,s),i,a);{let s=tS(e,c),l=VC[s],u=r.direction[l]>=0,d,f;u?(d=$x(e),f=eS(e,c)):(d=eS(e,c),f=$x(e));let p=FC(d,o,r,i,a)?UC(d,t,n,r,i,a):null;if(p){let e=p.point[l];if(u?e<=o[f+s]:e>=o[f+s+3])return p}let m=FC(f,o,r,i,a)?UC(f,t,n,r,i,a):null;return p&&m?p.distance<=m.distance?p:m:p||m||null}}var WC=new ep,GC=new lC,KC=new lC,qC=new tf,JC=new uC,YC=new uC;function XC(e,t,n,r){wS.setBuffer(e._roots[t]);let i=ZC(0,e,n,r);return wS.clearBuffer(),i}function ZC(e,t,n,r,i=null){let{float32Array:a,uint16Array:o,uint32Array:s}=wS,c=e*2;if(i===null&&(n.boundingBox||n.computeBoundingBox(),JC.set(n.boundingBox.min,n.boundingBox.max,r),i=JC),Xx(c,o)){let i=t.geometry,l=i.index,u=i.attributes.position,d=n.index,f=n.attributes.position,p=Zx(e,s),m=Qx(c,o);if(qC.copy(r).invert(),n.boundsTree)return Kx(nS(e),a,YC),YC.matrix.copy(qC),YC.needsUpdate=!0,n.boundsTree.shapecast({intersectsBounds:e=>YC.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(r),e.b.applyMatrix4(r),e.c.applyMatrix4(r),e.needsUpdate=!0;for(let t=p*3,n=(m+p)*3;t<n;t+=3)if(AC(KC,t,l,u),KC.needsUpdate=!0,e.intersectsTriangle(KC))return!0;return!1}});{let e=qS(n);for(let t=p*3,n=(m+p)*3;t<n;t+=3){AC(GC,t,l,u),GC.a.applyMatrix4(qC),GC.b.applyMatrix4(qC),GC.c.applyMatrix4(qC),GC.needsUpdate=!0;for(let t=0,n=e*3;t<n;t+=3)if(AC(KC,t,d,f),KC.needsUpdate=!0,GC.intersectsTriangle(KC))return!0}}}else{let o=$x(e),c=eS(e,s);return Kx(nS(o),a,WC),!!(i.intersectsBox(WC)&&ZC(o,t,n,r,i)||(Kx(nS(c),a,WC),i.intersectsBox(WC)&&ZC(c,t,n,r,i)))}}var QC=new tf,$C=new uC,ew=new uC,tw=new $,nw=new $,rw=new $,iw=new $;function aw(e,t,n,r={},i={},a=0,o=1/0){t.boundingBox||t.computeBoundingBox(),$C.set(t.boundingBox.min,t.boundingBox.max,n),$C.needsUpdate=!0;let s=e.geometry,c=s.attributes.position,l=s.index,u=t.attributes.position,d=t.index,f=dC.getPrimitive(),p=dC.getPrimitive(),m=tw,h=nw,g=null,_=null;i&&(g=rw,_=iw);let v=1/0,y=null,b=null;return QC.copy(n).invert(),ew.matrix.copy(QC),e.shapecast({boundsTraverseOrder:e=>$C.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<o&&(t&&(ew.min.copy(e.min),ew.max.copy(e.max),ew.needsUpdate=!0),!0),intersectsRange:(e,r)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:e=>ew.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<o,intersectsRange:(t,i)=>{for(let o=t,s=t+i;o<s;o++){AC(p,3*o,d,u),p.a.applyMatrix4(n),p.b.applyMatrix4(n),p.c.applyMatrix4(n),p.needsUpdate=!0;for(let t=e,n=e+r;t<n;t++){AC(f,3*t,l,c),f.needsUpdate=!0;let e=f.distanceToTriangle(p,m,g);if(e<v&&(h.copy(m),_&&_.copy(g),v=e,y=t,b=o),e<a)return!0}}}});{let i=qS(t);for(let t=0,o=i;t<o;t++){AC(p,3*t,d,u),p.a.applyMatrix4(n),p.b.applyMatrix4(n),p.c.applyMatrix4(n),p.needsUpdate=!0;for(let n=e,i=e+r;n<i;n++){AC(f,3*n,l,c),f.needsUpdate=!0;let e=f.distanceToTriangle(p,m,g);if(e<v&&(h.copy(m),_&&_.copy(g),v=e,y=n,b=t),e<a)return!0}}}}}),dC.releasePrimitive(f),dC.releasePrimitive(p),v===1/0?null:(r.point?r.point.copy(h):r.point=h.clone(),r.distance=v,r.faceIndex=y,i&&(i.point?i.point.copy(_):i.point=_.clone(),i.point.applyMatrix4(QC),h.applyMatrix4(QC),i.distance=h.sub(i.point).length(),i.faceIndex=b),r)}function ow(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));let n=e.geometry,r=n.index?n.index.array:null,i=n.attributes.position,a,o,s,c,l=0,u=e._roots;for(let e=0,t=u.length;e<t;e++)a=u[e],o=new Uint32Array(a),s=new Uint16Array(a),c=new Float32Array(a),d(0,l),l+=a.byteLength;function d(n,a,l=!1){let u=n*2;if(Xx(u,s)){let t=Zx(n,o),a=Qx(u,s),l=1/0,d=1/0,f=1/0,p=-1/0,m=-1/0,h=-1/0;for(let n=t,o=t+a;n<o;n++){let t=3*e.resolveTriangleIndex(n);for(let e=0;e<3;e++){let n=t+e;n=r?r[n]:n;let a=i.getX(n),o=i.getY(n),s=i.getZ(n);a<l&&(l=a),a>p&&(p=a),o<d&&(d=o),o>m&&(m=o),s<f&&(f=s),s>h&&(h=s)}}return c[n+0]!==l||c[n+1]!==d||c[n+2]!==f||c[n+3]!==p||c[n+4]!==m||c[n+5]!==h?(c[n+0]=l,c[n+1]=d,c[n+2]=f,c[n+3]=p,c[n+4]=m,c[n+5]=h,!0):!1}{let e=$x(n),r=eS(n,o),i=l,s=!1,u=!1;if(t){if(!i){let n=e/8+a/32,o=r/8+a/32;s=t.has(n),u=t.has(o),i=!s&&!u}}else s=!0,u=!0;let f=i||s,p=i||u,m=!1;f&&(m=d(e,a,i));let h=!1;p&&(h=d(r,a,i));let g=m||h;if(g)for(let t=0;t<3;t++){let i=e+t,a=r+t,o=c[i],s=c[i+3],l=c[a],u=c[a+3];c[n+t]=o<l?o:l,c[n+t+3]=s>u?s:u}return g}}}function sw(e,t,n,r,i,a,o){wS.setBuffer(e._roots[t]),FC(0,wS.float32Array,r,a,o)&&cw(0,e,n,r,i,a,o),wS.clearBuffer()}function cw(e,t,n,r,i,a,o){let{float32Array:s,uint16Array:c,uint32Array:l}=wS,u=e*2;if(Xx(u,c))IC(t,n,r,Zx(e,l),Qx(u,c),i,a,o);else{let c=$x(e);FC(c,s,r,a,o)&&cw(c,t,n,r,i,a,o);let u=eS(e,l);FC(u,s,r,a,o)&&cw(u,t,n,r,i,a,o)}}var lw=[`x`,`y`,`z`];function uw(e,t,n,r,i,a){wS.setBuffer(e._roots[t]);let o=null;return FC(0,wS.float32Array,r,i,a)&&(o=dw(0,e,n,r,i,a)),wS.clearBuffer(),o}function dw(e,t,n,r,i,a){let{float32Array:o,uint16Array:s,uint32Array:c}=wS,l=e*2;if(Xx(l,s))return LC(t,n,r,Zx(e,c),Qx(l,s),i,a);{let s=tS(e,c),l=lw[s],u=r.direction[l]>=0,d,f;u?(d=$x(e),f=eS(e,c)):(d=eS(e,c),f=$x(e));let p=FC(d,o,r,i,a)?dw(d,t,n,r,i,a):null;if(p){let e=p.point[l];if(u?e<=o[f+s]:e>=o[f+s+3])return p}let m=FC(f,o,r,i,a)?dw(f,t,n,r,i,a):null;return p&&m?p.distance<=m.distance?p:m:p||m||null}}var fw=new ep,pw=new lC,mw=new lC,hw=new tf,gw=new uC,_w=new uC;function vw(e,t,n,r){wS.setBuffer(e._roots[t]);let i=yw(0,e,n,r);return wS.clearBuffer(),i}function yw(e,t,n,r,i=null){let{float32Array:a,uint16Array:o,uint32Array:s}=wS,c=e*2;if(i===null&&(n.boundingBox||n.computeBoundingBox(),gw.set(n.boundingBox.min,n.boundingBox.max,r),i=gw),Xx(c,o)){let i=t.geometry,l=i.index,u=i.attributes.position,d=n.index,f=n.attributes.position,p=Zx(e,s),m=Qx(c,o);if(hw.copy(r).invert(),n.boundsTree)return Kx(nS(e),a,_w),_w.matrix.copy(hw),_w.needsUpdate=!0,n.boundsTree.shapecast({intersectsBounds:e=>_w.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(r),e.b.applyMatrix4(r),e.c.applyMatrix4(r),e.needsUpdate=!0;for(let n=p,r=m+p;n<r;n++)if(AC(mw,3*t.resolveTriangleIndex(n),l,u),mw.needsUpdate=!0,e.intersectsTriangle(mw))return!0;return!1}});{let e=qS(n);for(let n=p,r=m+p;n<r;n++){AC(pw,3*t.resolveTriangleIndex(n),l,u),pw.a.applyMatrix4(hw),pw.b.applyMatrix4(hw),pw.c.applyMatrix4(hw),pw.needsUpdate=!0;for(let t=0,n=e*3;t<n;t+=3)if(AC(mw,t,d,f),mw.needsUpdate=!0,pw.intersectsTriangle(mw))return!0}}}else{let o=$x(e),c=eS(e,s);return Kx(nS(o),a,fw),!!(i.intersectsBox(fw)&&yw(o,t,n,r,i)||(Kx(nS(c),a,fw),i.intersectsBox(fw)&&yw(c,t,n,r,i)))}}var bw=new tf,xw=new uC,Sw=new uC,Cw=new $,ww=new $,Tw=new $,Ew=new $;function Dw(e,t,n,r={},i={},a=0,o=1/0){t.boundingBox||t.computeBoundingBox(),xw.set(t.boundingBox.min,t.boundingBox.max,n),xw.needsUpdate=!0;let s=e.geometry,c=s.attributes.position,l=s.index,u=t.attributes.position,d=t.index,f=dC.getPrimitive(),p=dC.getPrimitive(),m=Cw,h=ww,g=null,_=null;i&&(g=Tw,_=Ew);let v=1/0,y=null,b=null;return bw.copy(n).invert(),Sw.matrix.copy(bw),e.shapecast({boundsTraverseOrder:e=>xw.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<o&&(t&&(Sw.min.copy(e.min),Sw.max.copy(e.max),Sw.needsUpdate=!0),!0),intersectsRange:(r,i)=>{if(t.boundsTree){let s=t.boundsTree;return s.shapecast({boundsTraverseOrder:e=>Sw.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<o,intersectsRange:(t,o)=>{for(let x=t,S=t+o;x<S;x++){let t=s.resolveTriangleIndex(x);AC(p,3*t,d,u),p.a.applyMatrix4(n),p.b.applyMatrix4(n),p.c.applyMatrix4(n),p.needsUpdate=!0;for(let t=r,n=r+i;t<n;t++){let n=e.resolveTriangleIndex(t);AC(f,3*n,l,c),f.needsUpdate=!0;let r=f.distanceToTriangle(p,m,g);if(r<v&&(h.copy(m),_&&_.copy(g),v=r,y=t,b=x),r<a)return!0}}}})}{let o=qS(t);for(let t=0,s=o;t<s;t++){AC(p,3*t,d,u),p.a.applyMatrix4(n),p.b.applyMatrix4(n),p.c.applyMatrix4(n),p.needsUpdate=!0;for(let n=r,o=r+i;n<o;n++){let r=e.resolveTriangleIndex(n);AC(f,3*r,l,c),f.needsUpdate=!0;let i=f.distanceToTriangle(p,m,g);if(i<v&&(h.copy(m),_&&_.copy(g),v=i,y=n,b=t),i<a)return!0}}}}}),dC.releasePrimitive(f),dC.releasePrimitive(p),v===1/0?null:(r.point?r.point.copy(h):r.point=h.clone(),r.distance=v,r.faceIndex=y,i&&(i.point?i.point.copy(_):i.point=_.clone(),i.point.applyMatrix4(bw),h.applyMatrix4(bw),i.distance=h.sub(i.point).length(),i.faceIndex=b),r)}function Ow(e,t,n){return e===null?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(n.ray.origin),e.object=t,e)}var kw=new uC,Aw=new hm,jw=new $,Mw=new tf,Nw=new $,Pw=[`getX`,`getY`,`getZ`],Fw=class e extends eC{static serialize(e,t={}){t={cloneBuffers:!0,...t};let n=e.geometry,r=e._roots,i=e._indirectBuffer,a=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=r.map(e=>e.slice()),o.index=a?a.array.slice():null,o.indirectBuffer=i?i.slice():null):(o.roots=r,o.index=a?a.array:null,o.indirectBuffer=i),o}static deserialize(t,n,r={}){r={setIndex:!0,indirect:!!t.indirectBuffer,...r};let{index:i,roots:a,indirectBuffer:o}=t;t.version||(console.warn(`MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data.`),c(a));let s=new e(n,{...r,[Wx]:!0});if(s._roots=a,s._indirectBuffer=o||null,r.setIndex){let e=n.getIndex();if(e===null){let e=new Cp(t.index,1,!1);n.setIndex(e)}else e.array!==i&&(e.array.set(i),e.needsUpdate=!0)}return s;function c(e){for(let t=0;t<e.length;t++){let n=e[t],r=new Uint32Array(n),i=new Uint16Array(n);for(let e=0,t=n.byteLength/32;e<t;e++){let t=8*e;Xx(2*t,i)||(r[t+6]=r[t+6]/8-e)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn(`MeshBVH: "maxLeafTris" option has been deprecated. Use "targetLeafSize", instead.`),t={...t,targetLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,n){let r=this.geometry,i=this._indirectBuffer,a=r.attributes.position,o=r.index?r.index.array:null,s=(i?i[e]:e)*3,c=s+0,l=s+1,u=s+2;o&&(c=o[c],l=o[l],u=o[u]);for(let e=0;e<3;e++){let r=a[Pw[e]](c),i=a[Pw[e]](l),o=a[Pw[e]](u),s=r;i<s&&(s=i),o<s&&(s=o);let d=r;i>d&&(d=i),o>d&&(d=o),t[n+e]=s,t[n+e+3]=d}return t}computePrimitiveBounds(e,t,n){let r=this.geometry,i=this._indirectBuffer,a=r.attributes.position,o=r.index?r.index.array:null,s=a.normalized;if(e<0||t+e-n.offset>n.length/6)throw Error(`MeshBVH: compute triangle bounds range is invalid.`);let c=a.array,l=a.offset||0,u=3;a.isInterleavedBufferAttribute&&(u=a.data.stride);let d=[`getX`,`getY`,`getZ`],f=n.offset;for(let r=e,p=e+t;r<p;r++){let e=(i?i[r]:r)*3,t=(r-f)*6,p=e+0,m=e+1,h=e+2;o&&(p=o[p],m=o[m],h=o[h]),s||(p=p*u+l,m=m*u+l,h=h*u+l);for(let e=0;e<3;e++){let r,i,o;s?(r=a[d[e]](p),i=a[d[e]](m),o=a[d[e]](h)):(r=c[p+e],i=c[m+e],o=c[h+e]);let l=r;i<l&&(l=i),o<l&&(l=o);let u=r;i>u&&(u=i),o>u&&(u=o);let f=(u-l)/2,g=e*2;n[t+g+0]=l+f,n[t+g+1]=f+(Math.abs(l)+f)*Ux}}return n}raycastObject3D(e,t,n=[]){let{material:r}=e;if(r===void 0)return;Mw.copy(e.matrixWorld).invert(),Aw.copy(t.ray).applyMatrix4(Mw),Nw.setFromMatrixScale(e.matrixWorld),jw.copy(Aw.direction).multiply(Nw);let i=jw.length(),a=t.near/i,o=t.far/i;if(t.firstHitOnly===!0){let i=this.raycastFirst(Aw,r,a,o);i=Ow(i,e,t),i&&n.push(i)}else{let i=this.raycast(Aw,r,a,o);for(let r=0,a=i.length;r<a;r++){let a=Ow(i[r],e,t);a&&n.push(a)}}return n}refit(e=null){return(this.indirect?ow:PC)(this,e)}raycast(e,t=0,n=0,r=1/0){let i=this._roots,a=[],o=this.indirect?sw:zC;for(let s=0,c=i.length;s<c;s++)o(this,s,t,e,a,n,r);return a}raycastFirst(e,t=0,n=0,r=1/0){let i=this._roots,a=null,o=this.indirect?uw:HC;for(let s=0,c=i.length;s<c;s++){let i=o(this,s,t,e,n,r);i!=null&&(a==null||i.distance<a.distance)&&(a=i)}return a}intersectsGeometry(e,t){let n=!1,r=this._roots,i=this.indirect?vw:XC;for(let a=0,o=r.length;a<o&&(n=i(this,a,e,t),!n);a++);return n}shapecast(e){let t=dC.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?RC:NC});return dC.releasePrimitive(t),n}bvhcast(t,n,r){let{intersectsRanges:i,intersectsTriangles:a}=r,o=dC.getPrimitive(),s=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?e=>{let t=this.resolveTriangleIndex(e);AC(o,t*3,s,c)}:e=>{AC(o,e*3,s,c)},u=dC.getPrimitive(),d=t.geometry.index,f=t.geometry.attributes.position,p=t.indirect?e=>{let n=t.resolveTriangleIndex(e);AC(u,n*3,d,f)}:e=>{AC(u,e*3,d,f)};if(a){if(!(t instanceof e))throw Error(`MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.`);let r=(e,t,r,i,s,c,d,f)=>{for(let m=r,h=r+i;m<h;m++){p(m),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let n=e,r=e+t;n<r;n++)if(l(n),o.needsUpdate=!0,a(o,u,n,m,s,c,d,f))return!0}return!1};if(i){let e=i;i=function(t,n,i,a,o,s,c,l){return e(t,n,i,a,o,s,c,l)?!0:r(t,n,i,a,o,s,c,l)}}else i=r}return super.bvhcast(t,n,{intersectsRanges:i})}intersectsBox(e,t){return kw.set(e.min,e.max,t),kw.needsUpdate=!0,this.shapecast({intersectsBounds:e=>kw.intersectsBox(e),intersectsTriangle:e=>kw.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},r={},i=0,a=1/0){return(this.indirect?Dw:aw)(this,e,t,n,r,i,a)}closestPointToPoint(e,t={},n=0,r=1/0){return mC(this,e,t,n,r)}},Iw=class extends kf{constructor(e,t){super(),this.isViewHelper=!0,this.camera=e,this.animating=!1,this.center=new $,this.location={top:null,right:0,bottom:0,left:null};let n=new Lf(`#ff4466`),r=new Lf(`#88ff44`),i=new Lf(`#4488ff`),a=new Lf(`#000000`),o={},s=this,c=[],l=new Yg,u=new Q,d=new kf,f=new wg(-2,2,2,-2,0,4);f.position.set(0,0,2);let p=new sh(.04,.04,.8,5).rotateZ(-Math.PI/2).translate(.4,0,0),m=new Om(p,I(n)),h=new Om(p,I(r)),g=new Om(p,I(i));h.rotation.z=Math.PI/2,g.rotation.y=-Math.PI/2,this.add(m),this.add(g),this.add(h);let _=L(n),v=L(r),y=L(i),b=L(a),x=new lm(_),S=new lm(v),C=new lm(y),w=new lm(b),T=new lm(b),E=new lm(b);x.position.x=1,S.position.y=1,C.position.z=1,w.position.x=-1,T.position.y=-1,E.position.z=-1,w.material.opacity=.2,T.material.opacity=.2,E.material.opacity=.2,x.userData.type=`posX`,S.userData.type=`posY`,C.userData.type=`posZ`,w.userData.type=`negX`,T.userData.type=`negY`,E.userData.type=`negZ`,this.add(x),this.add(S),this.add(C),this.add(w),this.add(T),this.add(E),c.push(x),c.push(S),c.push(C),c.push(w),c.push(T),c.push(E);let D=new $,O=2*Math.PI;this.render=function(e){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld(),D.set(0,0,1),D.applyQuaternion(this.camera.quaternion);let n=this.location,r,i;r=n.left===null?t.offsetWidth-128-n.right:n.left,i=n.top===null?e.isWebGPURenderer?t.offsetHeight-128-n.bottom:n.bottom:e.isWebGPURenderer?n.top:t.offsetHeight-128-n.top,e.clearDepth(),e.getViewport(N),e.setViewport(r,i,128,128),e.render(this,f),e.setViewport(N.x,N.y,N.z,N.w)};let k=new $,A=new jd,j=new jd,M=new jd,N=new Xd,P=0;this.handleClick=function(e){if(this.animating===!0)return!1;let n=t.getBoundingClientRect(),r=this.location,i,a;i=r.left===null?n.left+t.offsetWidth-128-r.right:n.left+r.left,a=r.top===null?n.top+t.offsetHeight-128-r.bottom:n.top+r.top,u.x=(e.clientX-i)/128*2-1,u.y=-((e.clientY-a)/128)*2+1,l.setFromCamera(u,f);let o=l.intersectObjects(c);if(o.length>0){let e=o[0].object;return F(e,this.center),this.animating=!0,!0}return!1},this.setLabels=function(e,t,n){o.labelX=e,o.labelY=t,o.labelZ=n,R()},this.setLabelStyle=function(e,t,n){o.font=e,o.color=t,o.radius=n,R()},this.update=function(e){let t=e*O;j.rotateTowards(M,t),this.camera.position.set(0,0,1).applyQuaternion(j).multiplyScalar(P).add(this.center),this.camera.quaternion.rotateTowards(A,t),j.angleTo(M)===0&&(this.animating=!1)},this.dispose=function(){p.dispose(),m.material.dispose(),h.material.dispose(),g.material.dispose(),x.material.map.dispose(),S.material.map.dispose(),C.material.map.dispose(),w.material.map.dispose(),T.material.map.dispose(),E.material.map.dispose(),x.material.dispose(),S.material.dispose(),C.material.dispose(),w.material.dispose(),T.material.dispose(),E.material.dispose()};function F(e,t){switch(e.userData.type){case`posX`:k.set(1,0,0),A.setFromEuler(new ff(0,Math.PI*.5,0));break;case`posY`:k.set(0,1,0),A.setFromEuler(new ff(-Math.PI*.5,0,0));break;case`posZ`:k.set(0,0,1),A.setFromEuler(new ff);break;case`negX`:k.set(-1,0,0),A.setFromEuler(new ff(0,-Math.PI*.5,0));break;case`negY`:k.set(0,-1,0),A.setFromEuler(new ff(Math.PI*.5,0,0));break;case`negZ`:k.set(0,0,-1),A.setFromEuler(new ff(0,Math.PI,0));break;default:console.error(`ViewHelper: Invalid axis.`)}P=s.camera.position.distanceTo(t),k.multiplyScalar(P).add(t),d.position.copy(t),d.lookAt(s.camera.position),j.copy(d.quaternion),d.lookAt(k),M.copy(d.quaternion)}function I(e){return new gm({color:e,toneMapped:!1})}function ee(){let e=!1;try{e=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}return e}function te(e,t){let n;return ee()?n=new OffscreenCanvas(e,t):(n=document.createElement(`canvas`),n.width=e,n.height=t),n}function L(e,t){let{font:n=`24px Arial`,color:r=`#000000`,radius:i=14}=o,a=te(64,64),s=a.getContext(`2d`);s.beginPath(),s.arc(32,32,i,0,2*Math.PI),s.closePath(),s.fillStyle=e.getStyle(),s.fill(),t&&(s.font=n,s.textAlign=`center`,s.fillStyle=r,s.fillText(t,32,41));let c=new nh(a);return c.colorSpace=Lu,new Yp({map:c,toneMapped:!1})}function R(){x.material.map.dispose(),S.material.map.dispose(),C.material.map.dispose(),x.material.dispose(),S.material.dispose(),C.material.dispose(),x.material=L(n,o.labelX),S.material=L(r,o.labelY),C.material=L(i,o.labelZ)}}},Lw={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
4639
|
+
`};var fx=class extends wh{constructor(e){super({type:`LineMaterial`,uniforms:xh.clone(m_.line.uniforms),vertexShader:m_.line.vertexShader,fragmentShader:m_.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return`WORLD_UNITS`in this.defines}set worldUnits(e){e===!0!==this.worldUnits&&(this.needsUpdate=!0),e===!0?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return`USE_DASH`in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH=``:delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return`USE_ALPHA_TO_COVERAGE`in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE=``:delete this.defines.USE_ALPHA_TO_COVERAGE)}},px=new Xd,mx=new $,hx=new $,gx=new Xd,_x=new Xd,vx=new Xd,yx=new $,bx=new tf,xx=new o_,Sx=new $,Cx=new ep,wx=new Ap,Tx=new Xd,Ex,Dx;function Ox(e,t,n){return Tx.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),Tx.multiplyScalar(1/Tx.w),Tx.x=Dx/n.width,Tx.y=Dx/n.height,Tx.applyMatrix4(e.projectionMatrixInverse),Tx.multiplyScalar(1/Tx.w),Math.abs(Math.max(Tx.x,Tx.y))}function kx(e,t){let n=e.matrixWorld,r=e.geometry,i=r.attributes.instanceStart,a=r.attributes.instanceEnd,o=Math.min(r.instanceCount,i.count);for(let r=0,s=o;r<s;r++){xx.start.fromBufferAttribute(i,r),xx.end.fromBufferAttribute(a,r),xx.applyMatrix4(n);let o=new $,s=new $;Ex.distanceSqToSegment(xx.start,xx.end,s,o),s.distanceTo(o)<Dx*.5&&t.push({point:s,pointOnLine:o,distance:Ex.origin.distanceTo(s),object:e,face:null,faceIndex:r,uv:null,uv1:null})}}function Ax(e,t,n){let r=t.projectionMatrix,i=e.material.resolution,a=e.matrixWorld,o=e.geometry,s=o.attributes.instanceStart,c=o.attributes.instanceEnd,l=Math.min(o.instanceCount,s.count),u=-t.near;Ex.at(1,vx),vx.w=1,vx.applyMatrix4(t.matrixWorldInverse),vx.applyMatrix4(r),vx.multiplyScalar(1/vx.w),vx.x*=i.x/2,vx.y*=i.y/2,vx.z=0,yx.copy(vx),bx.multiplyMatrices(t.matrixWorldInverse,a);for(let t=0,o=l;t<o;t++){if(gx.fromBufferAttribute(s,t),_x.fromBufferAttribute(c,t),gx.w=1,_x.w=1,gx.applyMatrix4(bx),_x.applyMatrix4(bx),gx.z>u&&_x.z>u)continue;if(gx.z>u){let e=gx.z-_x.z,t=(gx.z-u)/e;gx.lerp(_x,t)}else if(_x.z>u){let e=_x.z-gx.z,t=(_x.z-u)/e;_x.lerp(gx,t)}gx.applyMatrix4(r),_x.applyMatrix4(r),gx.multiplyScalar(1/gx.w),_x.multiplyScalar(1/_x.w),gx.x*=i.x/2,gx.y*=i.y/2,_x.x*=i.x/2,_x.y*=i.y/2,xx.start.copy(gx),xx.start.z=0,xx.end.copy(_x),xx.end.z=0;let o=xx.closestPointToPointParameter(yx,!0);xx.at(o,Sx);let l=Ad.lerp(gx.z,_x.z,o),d=l>=-1&&l<=1,f=yx.distanceTo(Sx)<Dx*.5;if(d&&f){xx.start.fromBufferAttribute(s,t),xx.end.fromBufferAttribute(c,t),xx.start.applyMatrix4(a),xx.end.applyMatrix4(a);let r=new $,i=new $;Ex.distanceSqToSegment(xx.start,xx.end,i,r),n.push({point:i,pointOnLine:r,distance:Ex.origin.distanceTo(i),object:e,face:null,faceIndex:t,uv:null,uv1:null})}}}var jx=class extends Om{constructor(e=new dx,t=new fx({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type=`LineSegments2`}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let e=0,i=0,a=t.count;e<a;e++,i+=2)mx.fromBufferAttribute(t,e),hx.fromBufferAttribute(n,e),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+mx.distanceTo(hx);let i=new qg(r,2,1);return e.setAttribute(`instanceDistanceStart`,new Hp(i,1,0)),e.setAttribute(`instanceDistanceEnd`,new Hp(i,1,1)),this}raycast(e,t){let n=this.material.worldUnits,r=e.camera;if(r===null&&!n&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.`),n===!1&&(this.material.resolution.x===0||this.material.resolution.y===0))return;let i=e.params.Line2===void 0?0:e.params.Line2.threshold||0;Ex=e.ray;let a=this.matrixWorld,o=this.geometry,s=this.material;Dx=s.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),wx.copy(o.boundingSphere).applyMatrix4(a);let c;if(c=n?Dx*.5:Ox(r,Math.max(r.near,wx.distanceToPoint(Ex.origin)),s.resolution),wx.radius+=c,Ex.intersectsSphere(wx)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),Cx.copy(o.boundingBox).applyMatrix4(a);let l;l=n?Dx*.5:Ox(r,Math.max(r.near,Cx.distanceToPoint(Ex.origin)),s.resolution),Cx.expandByScalar(l),Ex.intersectsBox(Cx)!==!1&&(n?kx(this,t):Ax(this,r,t))}onBeforeRender(e){let t=this.material.uniforms;t&&t.resolution&&(e.getViewport(px),this.material.uniforms.resolution.value.set(px.z,px.w))}},Mx=class extends dx{constructor(){super(),this.isLineGeometry=!0,this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}setFromPoints(e){let t=e.length-1,n=new Float32Array(6*t);for(let r=0;r<t;r++)n[6*r]=e[r].x,n[6*r+1]=e[r].y,n[6*r+2]=e[r].z||0,n[6*r+3]=e[r+1].x,n[6*r+4]=e[r+1].y,n[6*r+5]=e[r+1].z||0;return super.setPositions(n),this}fromLine(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}},Nx=class extends jx{constructor(e=new Mx,t=new fx({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type=`Line2`}},Px=class extends kf{constructor(e=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new Q(.5,.5),this.rotation2D=0,this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof e.element.ownerDocument.defaultView.Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center,this.rotation2D=e.rotation2D,this}},Fx=new $,Ix=new tf,Lx=new tf,Rx=new $,zx=new $,Bx=class{constructor(e={}){let t=this,n,r,i,a,o={objects:new WeakMap},s=e.element===void 0?document.createElement(`div`):e.element;s.style.overflow=`hidden`,this.domElement=s,this.sortObjects=!0,this.getSize=function(){return{width:n,height:r}},this.render=function(e,t){e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ix.copy(t.matrixWorldInverse),Lx.multiplyMatrices(t.projectionMatrix,Ix),l(e,e,t),this.sortObjects&&f(e)},this.setSize=function(e,t){n=e,r=t,i=n/2,a=r/2,s.style.width=e+`px`,s.style.height=t+`px`};function c(e){e.isCSS2DObject&&(e.element.style.display=`none`);for(let t=0,n=e.children.length;t<n;t++)c(e.children[t])}function l(e,n,r){if(e.visible===!1)c(e);else{if(e.isCSS2DObject){Fx.setFromMatrixPosition(e.matrixWorld),Fx.applyMatrix4(Lx);let c=Fx.z>=-1&&Fx.z<=1&&e.layers.test(r.layers)===!0,l=e.element;if(l.style.display=c===!0?``:`none`,c===!0){e.onBeforeRender(t,n,r);let o=100*e.center.x,c=100*e.center.y;l.style.transformOrigin=`${o}% ${c}%`;let u=-e.rotation2D,d=Fx.x*i+i,f=-Fx.y*a+a;l.style.transform=`translate(${-o}%, ${-c}%) translate(${d}px, ${f}px) rotate(${u}rad)`,l.parentNode!==s&&s.appendChild(l),e.onAfterRender(t,n,r)}let d={distanceToCameraSquared:u(r,e)};o.objects.set(e,d)}for(let t=0,i=e.children.length;t<i;t++)l(e.children[t],n,r)}}function u(e,t){return Rx.setFromMatrixPosition(e.matrixWorld),zx.setFromMatrixPosition(t.matrixWorld),Rx.distanceToSquared(zx)}function d(e){let t=[];return e.traverseVisible(function(e){e.isCSS2DObject&&t.push(e)}),t}function f(e){let t=d(e).sort(function(e,t){return e.renderOrder===t.renderOrder?o.objects.get(e).distanceToCameraSquared-o.objects.get(t).distanceToCameraSquared:t.renderOrder-e.renderOrder}),n=t.length;for(let e=0,r=t.length;e<r;e++)t[e].element.style.zIndex=n-e}}},Vx=1.25,Hx=65535,Ux=2**-24,Wx=Symbol(`SKIP_GENERATION`),Gx={strategy:0,maxDepth:40,targetLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Wx]:!1};function Kx(e,t,n){return n.min.x=t[e],n.min.y=t[e+1],n.min.z=t[e+2],n.max.x=t[e+3],n.max.y=t[e+4],n.max.z=t[e+5],n}function qx(e){let t=-1,n=-1/0;for(let r=0;r<3;r++){let i=e[r+3]-e[r];i>n&&(n=i,t=r)}return t}function Jx(e,t,n){for(let r=0;r<3;r++){let i=t[e+2*r],a=t[e+2*r+1],o=i-a,s=i+a;o<n[r]&&(n[r]=o),s>n[r+3]&&(n[r+3]=s)}}function Yx(e){let t=e[3]-e[0],n=e[4]-e[1],r=e[5]-e[2];return 2*(t*n+n*r+r*t)}function Xx(e,t){return t[e+15]===Hx}function Zx(e,t){return t[e+6]}function Qx(e,t){return t[e+14]}function $x(e){return e+8}function eS(e,t){return e+t[e+6]*8}function tS(e,t){return t[e+7]}function nS(e){return e}function rS(e,t,n,r,i){let a=1/0,o=1/0,s=1/0,c=-1/0,l=-1/0,u=-1/0,d=1/0,f=1/0,p=1/0,m=-1/0,h=-1/0,g=-1/0,_=e.offset||0;for(let r=(t-_)*6,i=(t+n-_)*6;r<i;r+=6){let t=e[r+0],n=e[r+1],i=t-n,_=t+n;i<a&&(a=i),_>c&&(c=_),t<d&&(d=t),t>m&&(m=t);let v=e[r+2],y=e[r+3],b=v-y,x=v+y;b<o&&(o=b),x>l&&(l=x),v<f&&(f=v),v>h&&(h=v);let S=e[r+4],C=e[r+5],w=S-C,T=S+C;w<s&&(s=w),T>u&&(u=T),S<p&&(p=S),S>g&&(g=S)}r[0]=a,r[1]=o,r[2]=s,r[3]=c,r[4]=l,r[5]=u,i[0]=d,i[1]=f,i[2]=p,i[3]=m,i[4]=h,i[5]=g}var iS=8,aS=8,oS=new Int32Array(iS),sS=new Float32Array(48),cS=new Float32Array(48),lS=new Float32Array(6),uS=new Float32Array(6),dS=new Int32Array(aS),fS=new Float32Array(48);function pS(e,t,n,r){for(let i=0;i<3;i++){let a=t[e+2*i],o=t[e+2*i+1],s=a-o,c=a+o;s<n[r+i]&&(n[r+i]=s),c>n[r+i+3]&&(n[r+i+3]=c)}}function mS(e,t){let n=e[t+3]-e[t],r=e[t+4]-e[t+1],i=e[t+5]-e[t+2];return 2*(n*r+r*i+i*n)}function hS(e,t,n,r,i,a){let o=-1,s=0;if(a===0)o=qx(t),o!==-1&&(s=(t[o]+t[o+3])/2);else if(a===1)o=qx(e),o!==-1&&(s=gS(n,r,i,o));else if(a===2){let a=Yx(e),c=Vx*i,l=n.offset||0,u=(r-l)*6,d=(r+i-l)*6;for(let e=0;e<3;e++){let r=t[e],l=(t[e+3]-r)/iS;if(i<aS){for(let t=0;t<i;t++){let r=u+t*6,i=n[r+2*e],a=t;for(;a>0&&n[dS[a-1]+2*e]>i;)dS[a]=dS[a-1],a--;dS[a]=r}for(let e=0;e<3;e++)lS[e]=1/0,lS[e+3]=-1/0,uS[e]=1/0,uS[e+3]=-1/0;for(let e=i-1;e>=0;e--)Jx(dS[e],n,uS),fS.set(uS,e*6);for(let t=0;t<i-1;t++){Jx(dS[t],n,lS);let r=n[dS[t+1]+2*e];if(n[dS[t]+2*e]===r)continue;let l=t+1,u=i-l,d=Yx(lS)/a,f=mS(fS,l*6)/a,p=1+Vx*(d*l+f*u);p<c&&(o=e,c=p,s=r)}}else{for(let e=0;e<iS;e++){oS[e]=0;for(let t=0;t<3;t++)sS[e*6+t]=1/0,sS[e*6+t+3]=-1/0}for(let t=u;t<d;t+=6){let i=~~((n[t+2*e]-r)/l);i>=iS&&(i=7),oS[i]++,pS(t,n,sS,i*6)}for(let e=0;e<6;e++)cS[42+e]=sS[42+e];for(let e=6;e>=0;e--){let t=e*6,n=t+6;for(let e=0;e<3;e++)cS[t+e]=Math.min(sS[t+e],cS[n+e]),cS[t+e+3]=Math.max(sS[t+e+3],cS[n+e+3])}let t=0;for(let n=0;n<7;n++){let u=n*6,d=oS[n];if(d!==0)for(let e=0;e<3;e++)t===0?(lS[e]=sS[u+e],lS[e+3]=sS[u+e+3]):(lS[e]=Math.min(lS[e],sS[u+e]),lS[e+3]=Math.max(lS[e+3],sS[u+e+3]));t+=d;let f=0,p=0;t!==0&&(f=Yx(lS)/a);let m=i-t;m!==0&&(p=mS(cS,u+6)/a);let h=1+Vx*(f*t+p*m);h<c&&(o=e,c=h,s=r+l+n*l)}}}}else console.warn(`BVH: Invalid build strategy value ${a} used.`);return{axis:o,pos:s}}function gS(e,t,n,r){let i=0,a=e.offset;for(let o=t,s=t+n;o<s;o++)i+=e[(o-a)*6+r*2];return i/n}function _S(e,t,n,r,i,a){let o=r,s=r+i-1,c=a.pos,l=a.axis*2,u=n.offset||0;for(;;){for(;o<=s&&n[(o-u)*6+l]<c;)o++;for(;o<=s&&n[(s-u)*6+l]>=c;)s--;if(o<s){for(let n=0;n<t;n++){let r=e[o*t+n];e[o*t+n]=e[s*t+n],e[s*t+n]=r}for(let e=0;e<6;e++){let t=o-u,r=s-u,i=n[t*6+e];n[t*6+e]=n[r*6+e],n[r*6+e]=i}o++,s--}else return o}}var vS=2**32,yS=new Float32Array(6),bS=new Float32Array(6);function xS(e,t,n,r,i,a){let{maxDepth:o,verbose:s,targetLeafSize:c,_strictLeafSize:l=1/0,strategy:u,onProgress:d,useSharedArrayBuffer:f=!1}=i,p=e.primitiveBuffer,m=e.primitiveBufferStride,h=new(f?SharedArrayBuffer:ArrayBuffer)(32*Math.max(1,2*Math.ceil(r)-1)),g=new Float32Array(h),_=new Uint32Array(h),v=new Uint16Array(h),y=0,b=!1;return rS(t,n,r,yS,bS),C(n,r,0),h.slice(0,y*32);function x(e){d&&d((e-a.offset)/a.count)}function S(e,t,n){let r=e*2;_[e+6]=t,v[r+14]=n,v[r+15]=Hx,x(t+n)}function C(e,n,r){let i=y++,a=i*8;g.set(yS,a),!b&&r>=o&&(b=!0,s&&console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`));let d=n>l;if(n<=c&&!d||r>=o){S(a,e,n);return}let f=hS(yS,bS,t,e,n,u),h=f.axis===-1?-1:_S(p,m,t,e,n,f);if(f.axis===-1||h===e||h===e+n){if(!d){S(a,e,n);return}f.axis=Math.max(0,qx(yS)),h=e+Math.max(1,Math.floor(n/2))}_[a+7]=f.axis;let v=h-e;rS(t,e,v,yS,bS),C(e,v,r+1);let x=y-i;if(x>vS)throw Error(`MeshBVH: Cannot store relative child node offset greater than 32 bits.`);_[a+6]=x;let w=n-v;rS(t,h,w,yS,bS),C(h,w,r+1)}}function SS(e,t){let n=e.getRootRanges(t.range),r=n[0],i=n[n.length-1],a={offset:r.offset,count:i.offset+i.count-r.offset},o=new Float32Array(6*a.count);o.offset=a.offset,e.computePrimitiveBounds(a.offset,a.count,o),e._roots=n.map(n=>xS(e,o,n.offset,n.count,t,a))}var CS=class{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){let e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}},wS=new class{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;let e=[],t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}},TS,ES,DS=[],OS=new CS(()=>new ep);function kS(e,t,n,r,i,a){TS=OS.getPrimitive(),ES=OS.getPrimitive(),DS.push(TS,ES),wS.setBuffer(e._roots[t]);let o=AS(0,e.geometry,n,r,i,a);wS.clearBuffer(),OS.releasePrimitive(TS),OS.releasePrimitive(ES),DS.pop(),DS.pop();let s=DS.length;return s>0&&(ES=DS[s-1],TS=DS[s-2]),o}function AS(e,t,n,r,i=null,a=0,o=0){let{float32Array:s,uint16Array:c,uint32Array:l}=wS,u=e*2;if(Xx(u,c)){let t=Zx(e,l),n=Qx(u,c);return Kx(nS(e),s,TS),r(t,n,!1,o,a+e/8,TS)}{let u=$x(e),d=eS(e,l),f=u,p=d,m,h,g,_;if(i&&(g=TS,_=ES,Kx(nS(f),s,g),Kx(nS(p),s,_),m=i(g),h=i(_),h<m)){f=d,p=u;let e=m;m=h,h=e,g=_}g||(g=TS,Kx(nS(f),s,g));let v=Xx(f*2,c),y=n(g,v,m,o+1,a+f/8),b;if(y===2){let e=w(f);b=r(e,T(f)-e,!0,o+1,a+f/8,g)}else b=y&&AS(f,t,n,r,i,a,o+1);if(b)return!0;_=ES,Kx(nS(p),s,_);let x=Xx(p*2,c),S=n(_,x,h,o+1,a+p/8),C;if(S===2){let e=w(p);C=r(e,T(p)-e,!0,o+1,a+p/8,_)}else C=S&&AS(p,t,n,r,i,a,o+1);return!!C;function w(e){let{uint16Array:t,uint32Array:n}=wS,r=e*2;for(;!Xx(r,t);)e=$x(e),r=e*2;return Zx(e,n)}function T(e){let{uint16Array:t,uint32Array:n}=wS,r=e*2;for(;!Xx(r,t);)e=eS(e,n),r=e*2;return Zx(e,n)+Qx(r,t)}}}var jS=new wS.constructor,MS=new wS.constructor,NS=new CS(()=>new ep),PS=new ep,FS=new ep,IS=new ep,LS=new ep,RS=!1;function zS(e,t,n,r){if(RS)throw Error(`MeshBVH: Recursive calls to bvhcast not supported.`);RS=!0;let i=e._roots,a=t._roots,o,s=0,c=0,l=new tf().copy(n).invert();for(let e=0,t=i.length;e<t;e++){jS.setBuffer(i[e]),c=0;let t=NS.getPrimitive();Kx(nS(0),jS.float32Array,t),t.applyMatrix4(l);for(let e=0,i=a.length;e<i&&(MS.setBuffer(a[e]),o=BS(0,0,n,l,r,s,c,0,0,t),MS.clearBuffer(),c+=a[e].byteLength/32,!o);e++);if(NS.releasePrimitive(t),jS.clearBuffer(),s+=i[e].byteLength/32,o)break}return RS=!1,o}function BS(e,t,n,r,i,a=0,o=0,s=0,c=0,l=null,u=!1){let d,f;u?(d=MS,f=jS):(d=jS,f=MS);let p=d.float32Array,m=d.uint32Array,h=d.uint16Array,g=f.float32Array,_=f.uint32Array,v=f.uint16Array,y=e*2,b=t*2,x=Xx(y,h),S=Xx(b,v),C=!1;if(S&&x)C=u?i(Zx(t,_),Qx(t*2,v),Zx(e,m),Qx(e*2,h),c,o+t/8,s,a+e/8):i(Zx(e,m),Qx(e*2,h),Zx(t,_),Qx(t*2,v),s,a+e/8,c,o+t/8);else if(S){let l=NS.getPrimitive();Kx(nS(t),g,l),l.applyMatrix4(n);let d=$x(e),f=eS(e,m);Kx(nS(d),p,PS),Kx(nS(f),p,FS);let h=l.intersectsBox(PS),_=l.intersectsBox(FS);C=h&&BS(t,d,r,n,i,o,a,c,s+1,l,!u)||_&&BS(t,f,r,n,i,o,a,c,s+1,l,!u),NS.releasePrimitive(l)}else{let d=$x(t),f=eS(t,_);Kx(nS(d),g,IS),Kx(nS(f),g,LS);let h=l.intersectsBox(IS),v=l.intersectsBox(LS);if(h&&v)C=BS(e,d,n,r,i,a,o,s,c+1,l,u)||BS(e,f,n,r,i,a,o,s,c+1,l,u);else if(h){if(x)C=BS(e,d,n,r,i,a,o,s,c+1,l,u);else{let t=NS.getPrimitive();t.copy(IS).applyMatrix4(n);let l=$x(e),f=eS(e,m);Kx(nS(l),p,PS),Kx(nS(f),p,FS);let h=t.intersectsBox(PS),g=t.intersectsBox(FS);C=h&&BS(d,l,r,n,i,o,a,c,s+1,t,!u)||g&&BS(d,f,r,n,i,o,a,c,s+1,t,!u),NS.releasePrimitive(t)}}else if(v){if(x)C=BS(e,f,n,r,i,a,o,s,c+1,l,u);else{let t=NS.getPrimitive();t.copy(LS).applyMatrix4(n);let l=$x(e),d=eS(e,m);Kx(nS(l),p,PS),Kx(nS(d),p,FS);let h=t.intersectsBox(PS),g=t.intersectsBox(FS);C=h&&BS(f,l,r,n,i,o,a,c,s+1,t,!u)||g&&BS(f,d,r,n,i,o,a,c,s+1,t,!u),NS.releasePrimitive(t)}}}return C}var VS=new class{constructor(){let e=null,t=null,n=null,r=!1;this.root=null,this.buffer=null,this.uint32Array=null,this.uint16Array=null,this.setBVH=(i,a)=>{if(r)throw Error(`BVHTraversalHelper: cannot call setBVH during an active traversal.`);this.root=a,this.buffer=e=i._roots[a],this.uint16Array=n=new Uint16Array(e),this.uint32Array=t=new Uint32Array(e)},this.reset=()=>{this.root=null,this.buffer=e=null,this.uint16Array=n=null,this.uint32Array=t=null},this.getRangeStart=e=>{let r=e*2;for(;!Xx(r,n);)e=$x(e),r=e*2;return Zx(e,t)},this.getRangeEnd=e=>{let r=e*2;for(;!Xx(r,n);)e=eS(e,t),r=e*2;return Zx(e,t)+Qx(r,n)};let i=(e,r,a)=>{let o=Xx(r*2,n);if(!e(a,o,r)&&!o){let n=$x(r),o=eS(r,t);i(e,n,a+1),i(e,o,a+1)}};this.traverseBuffer=e=>{if(r)throw Error(`BVHTraversalHelper: cannot start a traversal during an active traversal.`);r=!0;try{i(e,0,0)}finally{r=!1}},this.traverse=r=>{this.traverseBuffer((i,a,o)=>{if(a){let s=o*2,c=t[o+6],l=n[s+14];return r(i,a,new Float32Array(e,o*4,6),c,l)}{let n=tS(o,t);return r(i,a,new Float32Array(e,o*4,6),n)}})}}},HS=new ep,US=new Float32Array(6),WS=class{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(e){e={...Gx,...e},`maxLeafSize`in e&&(console.warn(`BVH: "maxLeafSize" option has been deprecated. Use "targetLeafSize", instead.`),e={...e,targetLeafSize:e.maxLeafSize}),SS(this,e)}getRootRanges(){throw Error(`BVH: getRootRanges() not implemented`)}writePrimitiveBounds(){throw Error(`BVH: writePrimitiveBounds() not implemented`)}writePrimitiveRangeBounds(e,t,n,r){let i=1/0,a=1/0,o=1/0,s=-1/0,c=-1/0,l=-1/0;for(let n=e,r=e+t;n<r;n++){this.writePrimitiveBounds(n,US,0);let[e,t,r,u,d,f]=US;e<i&&(i=e),u>s&&(s=u),t<a&&(a=t),d>c&&(c=d),r<o&&(o=r),f>l&&(l=f)}return n[r+0]=i,n[r+1]=a,n[r+2]=o,n[r+3]=s,n[r+4]=c,n[r+5]=l,n}computePrimitiveBounds(e,t,n){let r=n.offset||0;for(let i=e,a=e+t;i<a;i++){this.writePrimitiveBounds(i,US,0);let[e,t,a,o,s,c]=US,l=(e+o)/2,u=(t+s)/2,d=(a+c)/2,f=(o-e)/2,p=(s-t)/2,m=(c-a)/2,h=(i-r)*6;n[h+0]=l,n[h+1]=f+(Math.abs(l)+f)*Ux,n[h+2]=u,n[h+3]=p+(Math.abs(u)+p)*Ux,n[h+4]=d,n[h+5]=m+(Math.abs(d)+m)*Ux}return n}shiftPrimitiveOffsets(e){let t=this._indirectBuffer;if(t)for(let n=0,r=t.length;n<r;n++)t[n]+=e;else{let t=this._roots;for(let n=0;n<t.length;n++){let r=t[n],i=new Uint32Array(r),a=new Uint16Array(r),o=r.byteLength/32;for(let t=0;t<o;t++){let n=8*t;Xx(2*n,a)&&(i[n+6]+=e)}}}}traverse(e,t=0){VS.setBVH(this,t),VS.traverse(e),VS.reset()}refit(){let e=this._roots;for(let t=0,n=e.length;t<n;t++){let n=e[t],r=new Uint32Array(n),i=new Uint16Array(n),a=new Float32Array(n),o=n.byteLength/32;for(let e=o-1;e>=0;e--){let t=e*8,n=t*2;if(Xx(n,i)){let e=Zx(t,r),o=Qx(n,i);this.writePrimitiveRangeBounds(e,o,US,0),a.set(US,t)}else{let e=$x(t),n=eS(t,r);for(let r=0;r<3;r++){let i=a[e+r],o=a[e+r+3],s=a[n+r],c=a[n+r+3];a[t+r]=i<s?i:s,a[t+r+3]=o>c?o:c}}}}}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(t=>{Kx(0,new Float32Array(t),HS),e.union(HS)}),e}shapecast(e){let{boundsTraverseOrder:t,intersectsBounds:n,intersectsRange:r,intersectsPrimitive:i,scratchPrimitive:a,iterate:o}=e;if(r&&i){let e=r;r=(t,n,r,s,c)=>e(t,n,r,s,c)?!0:o(t,n,this,i,r,s,a)}else r||=i?(e,t,n,r)=>o(e,t,this,i,n,r,a):(e,t,n)=>n;let s=!1,c=0,l=this._roots;for(let e=0,i=l.length;e<i;e++){let i=l[e];if(s=kS(this,e,n,r,t,c),s)break;c+=i.byteLength/32}return s}bvhcast(e,t,n){let{intersectsRanges:r}=n;return zS(this,e,t,r)}};function GS(){return typeof SharedArrayBuffer<`u`}function KS(e){return e.index?e.index.count:e.attributes.position.count}function qS(e){return KS(e)/3}function JS(e,t=ArrayBuffer){return e>65535?new Uint32Array(new t(4*e)):new Uint16Array(new t(2*e))}function YS(e,t){if(!e.index){let n=e.attributes.position.count,r=JS(n,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);e.setIndex(new Cp(r,1));for(let e=0;e<n;e++)r[e]=e}}function XS(e,t,n){let r=KS(e)/n,i=t||e.drawRange,a=i.start/n,o=(i.start+i.count)/n,s=Math.max(0,a),c=Math.min(r,o)-s;return{offset:Math.floor(s),count:Math.floor(c)}}function ZS(e,t){return e.groups.map(e=>({offset:e.start/t,count:e.count/t}))}function QS(e,t,n){let r=XS(e,t,n),i=ZS(e,n);if(!i.length)return[r];let a=[],o=r.offset,s=r.offset+r.count,c=KS(e)/n,l=[];for(let e of i){let{offset:t,count:n}=e,r=t,i=t+(isFinite(n)?n:c-t);r<s&&i>o&&(l.push({pos:Math.max(o,r),isStart:!0}),l.push({pos:Math.min(s,i),isStart:!1}))}l.sort((e,t)=>e.pos===t.pos?e.type===`end`?-1:1:e.pos-t.pos);let u=0,d=null;for(let e of l){let t=e.pos;u!==0&&t!==d&&a.push({offset:d,count:t-d}),u+=e.isStart?1:-1,d=t}return a}function $S(e,t){let n=e[e.length-1],r=n.offset+n.count>2**16,i=e.reduce((e,t)=>e+t.count,0),a=r?4:2,o=t?new SharedArrayBuffer(i*a):new ArrayBuffer(i*a),s=r?new Uint32Array(o):new Uint16Array(o),c=0;for(let t=0;t<e.length;t++){let{offset:n,count:r}=e[t];for(let e=0;e<r;e++)s[c+e]=n+e;c+=r}return s}var eC=class extends WS{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(e){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(e){}constructor(e,t={}){if(!e.isBufferGeometry)throw Error(`BVH: Only BufferGeometries are supported.`);if(e.index&&e.index.isInterleavedBufferAttribute)throw Error(`BVH: InterleavedBufferAttribute is not supported for the index attribute.`);if(t.useSharedArrayBuffer&&!GS())throw Error(`BVH: SharedArrayBuffer is not available.`);super(),this.geometry=e,this.resolvePrimitiveIndex=t.indirect?e=>this._indirectBuffer[e]:e=>e,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,t={...Gx,...t},t[Wx]||this.init(t)}init(e){let{geometry:t,primitiveStride:n}=this;if(e.indirect){let r=$S(QS(t,e.range,n),e.useSharedArrayBuffer);this._indirectBuffer=r}else YS(t,e);super.init(e),!t.boundingBox&&e.setBoundingBox&&(t.boundingBox=this.getBoundingBox(new ep))}getRootRanges(e){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:QS(this.geometry,e,this.primitiveStride)}raycastObject3D(){throw Error(`BVH: raycastObject3D() not implemented`)}},tC=class{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,r=-1/0;for(let i=0,a=e.length;i<a;i++){let a=e[i][t];n=a<n?a:n,r=a>r?a:r}this.min=n,this.max=r}setFromPoints(e,t){let n=1/0,r=-1/0;for(let i=0,a=t.length;i<a;i++){let a=t[i],o=e.dot(a);n=o<n?o:n,r=o>r?o:r}this.min=n,this.max=r}isSeparated(e){return this.min>e.max||e.min>this.max}};tC.prototype.setFromBox=(function(){let e=new $;return function(t,n){let r=n.min,i=n.max,a=1/0,o=-1/0;for(let n=0;n<=1;n++)for(let s=0;s<=1;s++)for(let c=0;c<=1;c++){e.x=r.x*n+i.x*(1-n),e.y=r.y*s+i.y*(1-s),e.z=r.z*c+i.z*(1-c);let l=t.dot(e);a=Math.min(l,a),o=Math.max(l,o)}this.min=a,this.max=o}})();var nC=(function(){let e=new $,t=new $,n=new $;return function(r,i,a){let o=r.start,s=e,c=i.start,l=t;n.subVectors(o,c),e.subVectors(r.end,r.start),t.subVectors(i.end,i.start);let u=n.dot(l),d=l.dot(s),f=l.dot(l),p=n.dot(s),m=s.dot(s)*f-d*d,h,g;h=m===0?0:(u*d-p*f)/m,g=(u+h*d)/f,a.x=h,a.y=g}})(),rC=(function(){let e=new Q,t=new $,n=new $;return function(r,i,a,o){nC(r,i,e);let s=e.x,c=e.y;if(s>=0&&s<=1&&c>=0&&c<=1)r.at(s,a),i.at(c,o);else if(s>=0&&s<=1)c<0?i.at(0,o):i.at(1,o),r.closestPointToPoint(o,!0,a);else if(c>=0&&c<=1)s<0?r.at(0,a):r.at(1,a),i.closestPointToPoint(a,!0,o);else{let e;e=s<0?r.start:r.end;let l;l=c<0?i.start:i.end;let u=t,d=n;if(r.closestPointToPoint(l,!0,t),i.closestPointToPoint(e,!0,n),u.distanceToSquared(l)<=d.distanceToSquared(e)){a.copy(u),o.copy(l);return}a.copy(e),o.copy(d);return}}})(),iC=(function(){let e=new $,t=new $,n=new Kp,r=new o_;return function(i,a){let{radius:o,center:s}=i,{a:c,b:l,c:u}=a;if(r.start=c,r.end=l,r.closestPointToPoint(s,!0,e).distanceTo(s)<=o||(r.start=c,r.end=u,r.closestPointToPoint(s,!0,e).distanceTo(s)<=o)||(r.start=l,r.end=u,r.closestPointToPoint(s,!0,e).distanceTo(s)<=o))return!0;let d=a.getPlane(n);if(Math.abs(d.distanceToPoint(s))<=o){let e=d.projectPoint(s,t);if(a.containsPoint(e))return!0}return!1}})(),aC=[`x`,`y`,`z`],oC=1e-15,sC=oC*oC;function cC(e){return Math.abs(e)<oC}var lC=class extends $f{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=[,,,,].fill().map(()=>new $),this.satBounds=[,,,,].fill().map(()=>new tC),this.points=[this.a,this.b,this.c],this.plane=new Kp,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new o_,this.needsUpdate=!0}intersectsSphere(e){return iC(e,this)}update(){let e=this.a,t=this.b,n=this.c,r=this.points,i=this.satAxes,a=this.satBounds,o=i[0],s=a[0];this.getNormal(o),s.setFromPoints(o,r);let c=i[1],l=a[1];c.subVectors(e,t),l.setFromPoints(c,r);let u=i[2],d=a[2];u.subVectors(t,n),d.setFromPoints(u,r);let f=i[3],p=a[3];f.subVectors(n,e),p.setFromPoints(f,r);let m=c.length(),h=u.length(),g=f.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,m<oC?h<oC||g<oC?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):h<oC?g<oC?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):g<oC&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(o,e),this.needsUpdate=!1}};lC.prototype.closestPointToSegment=(function(){let e=new $,t=new $,n=new o_;return function(r,i=null,a=null){this.needsUpdate&&this.update();let{start:o,end:s}=r,c=this.points,l,u=1/0;if(this.plane.distanceToPoint(o)*this.plane.distanceToPoint(s)<0&&this.plane.intersectLine(r,e)!==null&&this.containsPoint(e))return i&&i.copy(e),a&&a.copy(e),0;for(let o=0;o<3;o++){let s=(o+1)%3;n.start.copy(c[o]),n.end.copy(c[s]),rC(n,r,e,t),l=e.distanceToSquared(t),l<u&&(u=l,i&&i.copy(e),a&&a.copy(t))}return this.closestPointToPoint(o,e),l=o.distanceToSquared(e),l<u&&(u=l,i&&i.copy(e),a&&a.copy(o)),this.closestPointToPoint(s,e),l=s.distanceToSquared(e),l<u&&(u=l,i&&i.copy(e),a&&a.copy(s)),Math.sqrt(u)}})(),lC.prototype.intersectsTriangle=(function(){let e=new lC,t=new tC,n=new tC,r=new $,i=new $,a=new $,o=new $,s=new o_,c=new o_,l=new $,u=new Q,d=new Q;function f(e,i,a,s){let c=r;!e.isDegenerateIntoPoint&&!e.isDegenerateIntoSegment?c.copy(e.plane.normal):c.copy(i.plane.normal);let l=e.satBounds,u=e.satAxes;for(let r=1;r<4;r++){let a=l[r],s=u[r];if(t.setFromPoints(s,i.points),a.isSeparated(t)||(o.copy(c).cross(s),t.setFromPoints(o,e.points),n.setFromPoints(o,i.points),t.isSeparated(n)))return!1}let d=i.satBounds,f=i.satAxes;for(let r=1;r<4;r++){let a=d[r],s=f[r];if(t.setFromPoints(s,e.points),a.isSeparated(t)||(o.crossVectors(c,s),t.setFromPoints(o,e.points),n.setFromPoints(o,i.points),t.isSeparated(n)))return!1}return a&&(s||console.warn(`ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0.`),a.start.set(0,0,0),a.end.set(0,0,0)),!0}function p(e,t,n,r,i,a,o,s,c,l,u){let d=o/(o-s);l.x=r+(i-r)*d,u.start.subVectors(t,e).multiplyScalar(d).add(e),d=o/(o-c),l.y=r+(a-r)*d,u.end.subVectors(n,e).multiplyScalar(d).add(e)}function m(e,t,n,r,i,a,o,s,c,l,u){if(i>0)p(e.c,e.a,e.b,r,t,n,c,o,s,l,u);else if(a>0)p(e.b,e.a,e.c,n,t,r,s,o,c,l,u);else if(s*c>0||o!=0)p(e.a,e.b,e.c,t,n,r,o,s,c,l,u);else if(s!=0)p(e.b,e.a,e.c,n,t,r,s,o,c,l,u);else if(c!=0)p(e.c,e.a,e.b,r,t,n,c,o,s,l,u);else return!0;return!1}function h(e,t,n,i){let a=t.degenerateSegment,o=e.plane.distanceToPoint(a.start),s=e.plane.distanceToPoint(a.end);return cC(o)?cC(s)?f(e,t,n,i):(n&&(n.start.copy(a.start),n.end.copy(a.start)),e.containsPoint(a.start)):cC(s)?(n&&(n.start.copy(a.end),n.end.copy(a.end)),e.containsPoint(a.end)):e.plane.intersectLine(a,r)!=null&&(n&&(n.start.copy(r),n.end.copy(r)),e.containsPoint(r))}function g(e,t,n){let r=t.a;return cC(e.plane.distanceToPoint(r))&&e.containsPoint(r)?(n&&(n.start.copy(r),n.end.copy(r)),!0):!1}function _(e,t,n){let i=e.degenerateSegment,a=t.a;return i.closestPointToPoint(a,!0,r),a.distanceToSquared(r)<sC&&(n&&(n.start.copy(a),n.end.copy(a)),!0)}function v(e,t,n,o){if(e.isDegenerateIntoSegment){if(t.isDegenerateIntoSegment){let o=e.degenerateSegment,s=t.degenerateSegment,c=i,l=a;o.delta(c),s.delta(l);let u=r.subVectors(s.start,o.start),d=c.x*l.y-c.y*l.x;if(cC(d))return!1;let f=(u.x*l.y-u.y*l.x)/d,p=-(c.x*u.y-c.y*u.x)/d;return f<0||f>1||p<0||p>1?!1:cC(o.start.z+c.z*f-(s.start.z+l.z*p))?(n&&(n.start.copy(o.start).addScaledVector(c,f),n.end.copy(o.start).addScaledVector(c,f)),!0):!1}return t.isDegenerateIntoPoint?_(e,t,n):h(t,e,n,o)}if(e.isDegenerateIntoPoint)return t.isDegenerateIntoPoint?t.a.distanceToSquared(e.a)<sC&&(n&&(n.start.copy(e.a),n.end.copy(e.a)),!0):t.isDegenerateIntoSegment?_(t,e,n):g(t,e,n);if(t.isDegenerateIntoPoint)return g(e,t,n);if(t.isDegenerateIntoSegment)return h(e,t,n,o)}return function(t,n=null,r=!1){this.needsUpdate&&this.update(),t.isExtendedTriangle?t.needsUpdate&&t.update():(e.copy(t),e.update(),t=e);let o=v(this,t,n,r);if(o!==void 0)return o;let p=this.plane,h=t.plane,g=h.distanceToPoint(this.a),_=h.distanceToPoint(this.b),y=h.distanceToPoint(this.c);cC(g)&&(g=0),cC(_)&&(_=0),cC(y)&&(y=0);let b=g*_,x=g*y;if(b>0&&x>0)return!1;let S=p.distanceToPoint(t.a),C=p.distanceToPoint(t.b),w=p.distanceToPoint(t.c);cC(S)&&(S=0),cC(C)&&(C=0),cC(w)&&(w=0);let T=S*C,E=S*w;if(T>0&&E>0)return!1;i.copy(p.normal),a.copy(h.normal);let D=i.cross(a),O=0,k=Math.abs(D.x),A=Math.abs(D.y);A>k&&(k=A,O=1),Math.abs(D.z)>k&&(O=2);let j=aC[O],M=this.a[j],N=this.b[j],P=this.c[j],F=t.a[j],ee=t.b[j],te=t.c[j];if(m(this,M,N,P,b,x,g,_,y,u,s)||m(t,F,ee,te,T,E,S,C,w,d,c))return f(this,t,n,r);if(u.y<u.x){let e=u.y;u.y=u.x,u.x=e,l.copy(s.start),s.start.copy(s.end),s.end.copy(l)}if(d.y<d.x){let e=d.y;d.y=d.x,d.x=e,l.copy(c.start),c.start.copy(c.end),c.end.copy(l)}return u.y<d.x||d.y<u.x?!1:(n&&(d.x>u.x?n.start.copy(c.start):n.start.copy(s.start),d.y<u.y?n.end.copy(c.end):n.end.copy(s.end)),!0)}})(),lC.prototype.distanceToPoint=(function(){let e=new $;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}})(),lC.prototype.distanceToTriangle=(function(){let e=new $,t=new $,n=[`a`,`b`,`c`],r=new o_,i=new o_;return function(a,o=null,s=null){let c=o||s?r:null;if(this.intersectsTriangle(a,c,!0))return(o||s)&&(o&&c.getCenter(o),s&&c.getCenter(s)),0;let l=1/0;for(let t=0;t<3;t++){let r,i=n[t],c=a[i];this.closestPointToPoint(c,e),r=c.distanceToSquared(e),r<l&&(l=r,o&&o.copy(e),s&&s.copy(c));let u=this[i];a.closestPointToPoint(u,e),r=u.distanceToSquared(e),r<l&&(l=r,o&&o.copy(u),s&&s.copy(e))}for(let c=0;c<3;c++){let u=n[c],d=n[(c+1)%3];r.set(this[u],this[d]);for(let c=0;c<3;c++){let u=n[c],d=n[(c+1)%3];i.set(a[u],a[d]),rC(r,i,e,t);let f=e.distanceToSquared(t);f<l&&(l=f,o&&o.copy(e),s&&s.copy(t))}}return Math.sqrt(l)}})();var uC=class{constructor(e,t,n){this.isOrientedBox=!0,this.min=new $,this.max=new $,this.matrix=new tf,this.invMatrix=new tf,this.points=Array(8).fill().map(()=>new $),this.satAxes=[,,,].fill().map(()=>new $),this.satBounds=[,,,].fill().map(()=>new tC),this.alignedSatBounds=[,,,].fill().map(()=>new tC),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}};uC.prototype.update=(function(){return function(){let e=this.matrix,t=this.min,n=this.max,r=this.points;for(let i=0;i<=1;i++)for(let a=0;a<=1;a++)for(let o=0;o<=1;o++){let s=r[1*i|2*a|4*o];s.x=i?n.x:t.x,s.y=a?n.y:t.y,s.z=o?n.z:t.z,s.applyMatrix4(e)}let i=this.satBounds,a=this.satAxes,o=r[0];for(let e=0;e<3;e++){let t=a[e],n=i[e],s=r[1<<e];t.subVectors(o,s),n.setFromPoints(t,r)}let s=this.alignedSatBounds;s[0].setFromPointsField(r,`x`),s[1].setFromPointsField(r,`y`),s[2].setFromPointsField(r,`z`),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),uC.prototype.intersectsBox=(function(){let e=new tC;return function(t){this.needsUpdate&&this.update();let n=t.min,r=t.max,i=this.satBounds,a=this.satAxes,o=this.alignedSatBounds;if(e.min=n.x,e.max=r.x,o[0].isSeparated(e)||(e.min=n.y,e.max=r.y,o[1].isSeparated(e))||(e.min=n.z,e.max=r.z,o[2].isSeparated(e)))return!1;for(let n=0;n<3;n++){let r=a[n],o=i[n];if(e.setFromBox(r,t),o.isSeparated(e))return!1}return!0}})(),uC.prototype.intersectsTriangle=(function(){let e=new lC,t=[,,,],n=new tC,r=new tC,i=new $;return function(a){this.needsUpdate&&this.update(),a.isExtendedTriangle?a.needsUpdate&&a.update():(e.copy(a),e.update(),a=e);let o=this.satBounds,s=this.satAxes;t[0]=a.a,t[1]=a.b,t[2]=a.c;for(let e=0;e<3;e++){let r=o[e],i=s[e];if(n.setFromPoints(i,t),r.isSeparated(n))return!1}let c=a.satBounds,l=a.satAxes,u=this.points;for(let e=0;e<3;e++){let t=c[e],r=l[e];if(n.setFromPoints(r,u),t.isSeparated(n))return!1}for(let e=0;e<3;e++){let a=s[e];for(let e=0;e<4;e++){let o=l[e];if(i.crossVectors(a,o),n.setFromPoints(i,t),r.setFromPoints(i,u),n.isSeparated(r))return!1}}return!0}})(),uC.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})(),uC.prototype.distanceToPoint=(function(){let e=new $;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}})(),uC.prototype.distanceToBox=(function(){let e=[`x`,`y`,`z`],t=Array(12).fill().map(()=>new o_),n=Array(12).fill().map(()=>new o_),r=new $,i=new $;return function(a,o=0,s=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(a))return(s||c)&&(a.getCenter(i),this.closestPointToPoint(i,r),a.closestPointToPoint(r,i),s&&s.copy(r),c&&c.copy(i)),0;let l=o*o,u=a.min,d=a.max,f=this.points,p=1/0;for(let e=0;e<8;e++){let t=f[e];i.copy(t).clamp(u,d);let n=t.distanceToSquared(i);if(n<p&&(p=n,s&&s.copy(t),c&&c.copy(i),n<l))return Math.sqrt(n)}let m=0;for(let r=0;r<3;r++)for(let i=0;i<=1;i++)for(let a=0;a<=1;a++){let o=(r+1)%3,s=(r+2)%3,c=i<<o|a<<s,l=1<<r|i<<o|a<<s,p=f[c],h=f[l];t[m].set(p,h);let g=e[r],_=e[o],v=e[s],y=n[m],b=y.start,x=y.end;b[g]=u[g],b[_]=i?u[_]:d[_],b[v]=a?u[v]:d[v],x[g]=d[g],x[_]=i?u[_]:d[_],x[v]=a?u[v]:d[v],m++}for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)for(let n=0;n<=1;n++){i.x=e?d.x:u.x,i.y=t?d.y:u.y,i.z=n?d.z:u.z,this.closestPointToPoint(i,r);let a=i.distanceToSquared(r);if(a<p&&(p=a,s&&s.copy(r),c&&c.copy(i),a<l))return Math.sqrt(a)}for(let e=0;e<12;e++){let a=t[e];for(let e=0;e<12;e++){let t=n[e];rC(a,t,r,i);let o=r.distanceToSquared(i);if(o<p&&(p=o,s&&s.copy(r),c&&c.copy(i),o<l))return Math.sqrt(o)}}return Math.sqrt(p)}})();var dC=new class extends CS{constructor(){super(()=>new lC)}},fC=new $,pC=new $;function mC(e,t,n={},r=0,i=1/0){let a=r*r,o=i*i,s=1/0,c=null;if(e.shapecast({boundsTraverseOrder:e=>(fC.copy(t).clamp(e.min,e.max),fC.distanceToSquared(t)),intersectsBounds:(e,t,n)=>n<s&&n<o,intersectsTriangle:(e,n)=>{e.closestPointToPoint(t,fC);let r=t.distanceToSquared(fC);return r<s&&(pC.copy(fC),s=r,c=n),r<a}}),s===1/0)return null;let l=Math.sqrt(s);return n.point?n.point.copy(pC):n.point=pC.clone(),n.distance=l,n.faceIndex=c,n}var hC=!0,gC=new $,_C=new $,vC=new $,yC=new Q,bC=new Q,xC=new Q,SC=new $,CC=new $,wC=new $,TC=new $;function EC(e,t,n,r,i,a,o,s){let c;if(c=a===1?e.intersectTriangle(r,n,t,!0,i):e.intersectTriangle(t,n,r,a!==2,i),c===null)return null;let l=e.origin.distanceTo(i);return l<o||l>s?null:{distance:l,point:i.clone()}}function DC(e,t,n,r,i,a,o,s,c,l,u){gC.fromBufferAttribute(t,a),_C.fromBufferAttribute(t,o),vC.fromBufferAttribute(t,s);let d=EC(e,gC,_C,vC,TC,c,l,u);if(d){if(r){yC.fromBufferAttribute(r,a),bC.fromBufferAttribute(r,o),xC.fromBufferAttribute(r,s),d.uv=new Q;let e=$f.getInterpolation(TC,gC,_C,vC,yC,bC,xC,d.uv);hC||(d.uv=e)}if(i){yC.fromBufferAttribute(i,a),bC.fromBufferAttribute(i,o),xC.fromBufferAttribute(i,s),d.uv1=new Q;let e=$f.getInterpolation(TC,gC,_C,vC,yC,bC,xC,d.uv1);hC||(d.uv1=e)}if(n){SC.fromBufferAttribute(n,a),CC.fromBufferAttribute(n,o),wC.fromBufferAttribute(n,s),d.normal=new $;let t=$f.getInterpolation(TC,gC,_C,vC,SC,CC,wC,d.normal);d.normal.dot(e.direction)>0&&d.normal.multiplyScalar(-1),hC||(d.normal=t)}let t={a,b:o,c:s,normal:new $,materialIndex:0};if($f.getNormal(gC,_C,vC,t.normal),d.face=t,d.faceIndex=a,hC){let e=new $;$f.getBarycoord(TC,gC,_C,vC,e),d.barycoord=e}}return d}function OC(e){return e&&e.isMaterial?e.side:e}function kC(e,t,n,r,i,a,o){let s=r*3,c=s+0,l=s+1,u=s+2,{index:d,groups:f}=e;e.index&&(c=d.getX(c),l=d.getX(l),u=d.getX(u));let{position:p,normal:m,uv:h,uv1:g}=e.attributes;if(Array.isArray(t)){let e=r*3;for(let s=0,d=f.length;s<d;s++){let{start:d,count:_,materialIndex:v}=f[s];if(e>=d&&e<d+_){let e=OC(t[v]),s=DC(n,p,m,h,g,c,l,u,e,a,o);if(s){if(s.faceIndex=r,s.face.materialIndex=v,i)i.push(s);else return s}}}}else{let e=OC(t),s=DC(n,p,m,h,g,c,l,u,e,a,o);if(s){if(s.faceIndex=r,s.face.materialIndex=0,i)i.push(s);else return s}}return null}function AC(e,t,n,r){let i=e.a,a=e.b,o=e.c,s=t,c=t+1,l=t+2;n&&(s=n.getX(s),c=n.getX(c),l=n.getX(l)),i.x=r.getX(s),i.y=r.getY(s),i.z=r.getZ(s),a.x=r.getX(c),a.y=r.getY(c),a.z=r.getZ(c),o.x=r.getX(l),o.y=r.getY(l),o.z=r.getZ(l)}function jC(e,t,n,r,i,a,o,s){let{geometry:c,_indirectBuffer:l}=e;for(let e=r,l=r+i;e<l;e++)kC(c,t,n,e,a,o,s)}function MC(e,t,n,r,i,a,o){let{geometry:s,_indirectBuffer:c}=e,l=1/0,u=null;for(let e=r,c=r+i;e<c;e++){let r;r=kC(s,t,n,e,null,a,o),r&&r.distance<l&&(u=r,l=r.distance)}return u}function NC(e,t,n,r,i,a,o){let{geometry:s}=n,{index:c}=s,l=s.attributes.position;for(let n=e,s=t+e;n<s;n++){let e;if(e=n,AC(o,e*3,c,l),o.needsUpdate=!0,r(o,e,i,a))return!0}return!1}function PC(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));let n=e.geometry,r=n.index?n.index.array:null,i=n.attributes.position,a,o,s,c,l=0,u=e._roots;for(let e=0,t=u.length;e<t;e++)a=u[e],o=new Uint32Array(a),s=new Uint16Array(a),c=new Float32Array(a),d(0,l),l+=a.byteLength;function d(e,n,a=!1){let l=e*2;if(Xx(l,s)){let t=Zx(e,o),n=Qx(l,s),a=1/0,u=1/0,d=1/0,f=-1/0,p=-1/0,m=-1/0;for(let e=3*t,o=3*(t+n);e<o;e++){let t=r[e],n=i.getX(t),o=i.getY(t),s=i.getZ(t);n<a&&(a=n),n>f&&(f=n),o<u&&(u=o),o>p&&(p=o),s<d&&(d=s),s>m&&(m=s)}return c[e+0]!==a||c[e+1]!==u||c[e+2]!==d||c[e+3]!==f||c[e+4]!==p||c[e+5]!==m?(c[e+0]=a,c[e+1]=u,c[e+2]=d,c[e+3]=f,c[e+4]=p,c[e+5]=m,!0):!1}{let r=$x(e),i=eS(e,o),s=a,l=!1,u=!1;if(t){if(!s){let e=r/8+n/32,a=i/8+n/32;l=t.has(e),u=t.has(a),s=!l&&!u}}else l=!0,u=!0;let f=s||l,p=s||u,m=!1;f&&(m=d(r,n,s));let h=!1;p&&(h=d(i,n,s));let g=m||h;if(g)for(let t=0;t<3;t++){let n=r+t,a=i+t,o=c[n],s=c[n+3],l=c[a],u=c[a+3];c[e+t]=o<l?o:l,c[e+t+3]=s>u?s:u}return g}}}function FC(e,t,n,r,i){let a,o,s,c,l,u,d=1/n.direction.x,f=1/n.direction.y,p=1/n.direction.z,m=n.origin.x,h=n.origin.y,g=n.origin.z,_=t[e],v=t[e+3],y=t[e+1],b=t[e+3+1],x=t[e+2],S=t[e+3+2];return d>=0?(a=(_-m)*d,o=(v-m)*d):(a=(v-m)*d,o=(_-m)*d),f>=0?(s=(y-h)*f,c=(b-h)*f):(s=(b-h)*f,c=(y-h)*f),a>c||s>o||((s>a||isNaN(a))&&(a=s),(c<o||isNaN(o))&&(o=c),p>=0?(l=(x-g)*p,u=(S-g)*p):(l=(S-g)*p,u=(x-g)*p),a>u||l>o)?!1:((l>a||a!==a)&&(a=l),(u<o||o!==o)&&(o=u),a<=i&&o>=r)}function IC(e,t,n,r,i,a,o,s){let{geometry:c,_indirectBuffer:l}=e;for(let e=r,u=r+i;e<u;e++)kC(c,t,n,l?l[e]:e,a,o,s)}function LC(e,t,n,r,i,a,o){let{geometry:s,_indirectBuffer:c}=e,l=1/0,u=null;for(let e=r,d=r+i;e<d;e++){let r;r=kC(s,t,n,c?c[e]:e,null,a,o),r&&r.distance<l&&(u=r,l=r.distance)}return u}function RC(e,t,n,r,i,a,o){let{geometry:s}=n,{index:c}=s,l=s.attributes.position;for(let s=e,u=t+e;s<u;s++){let e;if(e=n.resolveTriangleIndex(s),AC(o,e*3,c,l),o.needsUpdate=!0,r(o,e,i,a))return!0}return!1}function zC(e,t,n,r,i,a,o){wS.setBuffer(e._roots[t]),FC(0,wS.float32Array,r,a,o)&&BC(0,e,n,r,i,a,o),wS.clearBuffer()}function BC(e,t,n,r,i,a,o){let{float32Array:s,uint16Array:c,uint32Array:l}=wS,u=e*2;if(Xx(u,c))jC(t,n,r,Zx(e,l),Qx(u,c),i,a,o);else{let c=$x(e);FC(c,s,r,a,o)&&BC(c,t,n,r,i,a,o);let u=eS(e,l);FC(u,s,r,a,o)&&BC(u,t,n,r,i,a,o)}}var VC=[`x`,`y`,`z`];function HC(e,t,n,r,i,a){wS.setBuffer(e._roots[t]);let o=null;return FC(0,wS.float32Array,r,i,a)&&(o=UC(0,e,n,r,i,a)),wS.clearBuffer(),o}function UC(e,t,n,r,i,a){let{float32Array:o,uint16Array:s,uint32Array:c}=wS,l=e*2;if(Xx(l,s))return MC(t,n,r,Zx(e,c),Qx(l,s),i,a);{let s=tS(e,c),l=VC[s],u=r.direction[l]>=0,d,f;u?(d=$x(e),f=eS(e,c)):(d=eS(e,c),f=$x(e));let p=FC(d,o,r,i,a)?UC(d,t,n,r,i,a):null;if(p){let e=p.point[l];if(u?e<=o[f+s]:e>=o[f+s+3])return p}let m=FC(f,o,r,i,a)?UC(f,t,n,r,i,a):null;return p&&m?p.distance<=m.distance?p:m:p||m||null}}var WC=new ep,GC=new lC,KC=new lC,qC=new tf,JC=new uC,YC=new uC;function XC(e,t,n,r){wS.setBuffer(e._roots[t]);let i=ZC(0,e,n,r);return wS.clearBuffer(),i}function ZC(e,t,n,r,i=null){let{float32Array:a,uint16Array:o,uint32Array:s}=wS,c=e*2;if(i===null&&(n.boundingBox||n.computeBoundingBox(),JC.set(n.boundingBox.min,n.boundingBox.max,r),i=JC),Xx(c,o)){let i=t.geometry,l=i.index,u=i.attributes.position,d=n.index,f=n.attributes.position,p=Zx(e,s),m=Qx(c,o);if(qC.copy(r).invert(),n.boundsTree)return Kx(nS(e),a,YC),YC.matrix.copy(qC),YC.needsUpdate=!0,n.boundsTree.shapecast({intersectsBounds:e=>YC.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(r),e.b.applyMatrix4(r),e.c.applyMatrix4(r),e.needsUpdate=!0;for(let t=p*3,n=(m+p)*3;t<n;t+=3)if(AC(KC,t,l,u),KC.needsUpdate=!0,e.intersectsTriangle(KC))return!0;return!1}});{let e=qS(n);for(let t=p*3,n=(m+p)*3;t<n;t+=3){AC(GC,t,l,u),GC.a.applyMatrix4(qC),GC.b.applyMatrix4(qC),GC.c.applyMatrix4(qC),GC.needsUpdate=!0;for(let t=0,n=e*3;t<n;t+=3)if(AC(KC,t,d,f),KC.needsUpdate=!0,GC.intersectsTriangle(KC))return!0}}}else{let o=$x(e),c=eS(e,s);return Kx(nS(o),a,WC),!!(i.intersectsBox(WC)&&ZC(o,t,n,r,i)||(Kx(nS(c),a,WC),i.intersectsBox(WC)&&ZC(c,t,n,r,i)))}}var QC=new tf,$C=new uC,ew=new uC,tw=new $,nw=new $,rw=new $,iw=new $;function aw(e,t,n,r={},i={},a=0,o=1/0){t.boundingBox||t.computeBoundingBox(),$C.set(t.boundingBox.min,t.boundingBox.max,n),$C.needsUpdate=!0;let s=e.geometry,c=s.attributes.position,l=s.index,u=t.attributes.position,d=t.index,f=dC.getPrimitive(),p=dC.getPrimitive(),m=tw,h=nw,g=null,_=null;i&&(g=rw,_=iw);let v=1/0,y=null,b=null;return QC.copy(n).invert(),ew.matrix.copy(QC),e.shapecast({boundsTraverseOrder:e=>$C.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<o&&(t&&(ew.min.copy(e.min),ew.max.copy(e.max),ew.needsUpdate=!0),!0),intersectsRange:(e,r)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:e=>ew.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<o,intersectsRange:(t,i)=>{for(let o=t,s=t+i;o<s;o++){AC(p,3*o,d,u),p.a.applyMatrix4(n),p.b.applyMatrix4(n),p.c.applyMatrix4(n),p.needsUpdate=!0;for(let t=e,n=e+r;t<n;t++){AC(f,3*t,l,c),f.needsUpdate=!0;let e=f.distanceToTriangle(p,m,g);if(e<v&&(h.copy(m),_&&_.copy(g),v=e,y=t,b=o),e<a)return!0}}}});{let i=qS(t);for(let t=0,o=i;t<o;t++){AC(p,3*t,d,u),p.a.applyMatrix4(n),p.b.applyMatrix4(n),p.c.applyMatrix4(n),p.needsUpdate=!0;for(let n=e,i=e+r;n<i;n++){AC(f,3*n,l,c),f.needsUpdate=!0;let e=f.distanceToTriangle(p,m,g);if(e<v&&(h.copy(m),_&&_.copy(g),v=e,y=n,b=t),e<a)return!0}}}}}),dC.releasePrimitive(f),dC.releasePrimitive(p),v===1/0?null:(r.point?r.point.copy(h):r.point=h.clone(),r.distance=v,r.faceIndex=y,i&&(i.point?i.point.copy(_):i.point=_.clone(),i.point.applyMatrix4(QC),h.applyMatrix4(QC),i.distance=h.sub(i.point).length(),i.faceIndex=b),r)}function ow(e,t=null){t&&Array.isArray(t)&&(t=new Set(t));let n=e.geometry,r=n.index?n.index.array:null,i=n.attributes.position,a,o,s,c,l=0,u=e._roots;for(let e=0,t=u.length;e<t;e++)a=u[e],o=new Uint32Array(a),s=new Uint16Array(a),c=new Float32Array(a),d(0,l),l+=a.byteLength;function d(n,a,l=!1){let u=n*2;if(Xx(u,s)){let t=Zx(n,o),a=Qx(u,s),l=1/0,d=1/0,f=1/0,p=-1/0,m=-1/0,h=-1/0;for(let n=t,o=t+a;n<o;n++){let t=3*e.resolveTriangleIndex(n);for(let e=0;e<3;e++){let n=t+e;n=r?r[n]:n;let a=i.getX(n),o=i.getY(n),s=i.getZ(n);a<l&&(l=a),a>p&&(p=a),o<d&&(d=o),o>m&&(m=o),s<f&&(f=s),s>h&&(h=s)}}return c[n+0]!==l||c[n+1]!==d||c[n+2]!==f||c[n+3]!==p||c[n+4]!==m||c[n+5]!==h?(c[n+0]=l,c[n+1]=d,c[n+2]=f,c[n+3]=p,c[n+4]=m,c[n+5]=h,!0):!1}{let e=$x(n),r=eS(n,o),i=l,s=!1,u=!1;if(t){if(!i){let n=e/8+a/32,o=r/8+a/32;s=t.has(n),u=t.has(o),i=!s&&!u}}else s=!0,u=!0;let f=i||s,p=i||u,m=!1;f&&(m=d(e,a,i));let h=!1;p&&(h=d(r,a,i));let g=m||h;if(g)for(let t=0;t<3;t++){let i=e+t,a=r+t,o=c[i],s=c[i+3],l=c[a],u=c[a+3];c[n+t]=o<l?o:l,c[n+t+3]=s>u?s:u}return g}}}function sw(e,t,n,r,i,a,o){wS.setBuffer(e._roots[t]),FC(0,wS.float32Array,r,a,o)&&cw(0,e,n,r,i,a,o),wS.clearBuffer()}function cw(e,t,n,r,i,a,o){let{float32Array:s,uint16Array:c,uint32Array:l}=wS,u=e*2;if(Xx(u,c))IC(t,n,r,Zx(e,l),Qx(u,c),i,a,o);else{let c=$x(e);FC(c,s,r,a,o)&&cw(c,t,n,r,i,a,o);let u=eS(e,l);FC(u,s,r,a,o)&&cw(u,t,n,r,i,a,o)}}var lw=[`x`,`y`,`z`];function uw(e,t,n,r,i,a){wS.setBuffer(e._roots[t]);let o=null;return FC(0,wS.float32Array,r,i,a)&&(o=dw(0,e,n,r,i,a)),wS.clearBuffer(),o}function dw(e,t,n,r,i,a){let{float32Array:o,uint16Array:s,uint32Array:c}=wS,l=e*2;if(Xx(l,s))return LC(t,n,r,Zx(e,c),Qx(l,s),i,a);{let s=tS(e,c),l=lw[s],u=r.direction[l]>=0,d,f;u?(d=$x(e),f=eS(e,c)):(d=eS(e,c),f=$x(e));let p=FC(d,o,r,i,a)?dw(d,t,n,r,i,a):null;if(p){let e=p.point[l];if(u?e<=o[f+s]:e>=o[f+s+3])return p}let m=FC(f,o,r,i,a)?dw(f,t,n,r,i,a):null;return p&&m?p.distance<=m.distance?p:m:p||m||null}}var fw=new ep,pw=new lC,mw=new lC,hw=new tf,gw=new uC,_w=new uC;function vw(e,t,n,r){wS.setBuffer(e._roots[t]);let i=yw(0,e,n,r);return wS.clearBuffer(),i}function yw(e,t,n,r,i=null){let{float32Array:a,uint16Array:o,uint32Array:s}=wS,c=e*2;if(i===null&&(n.boundingBox||n.computeBoundingBox(),gw.set(n.boundingBox.min,n.boundingBox.max,r),i=gw),Xx(c,o)){let i=t.geometry,l=i.index,u=i.attributes.position,d=n.index,f=n.attributes.position,p=Zx(e,s),m=Qx(c,o);if(hw.copy(r).invert(),n.boundsTree)return Kx(nS(e),a,_w),_w.matrix.copy(hw),_w.needsUpdate=!0,n.boundsTree.shapecast({intersectsBounds:e=>_w.intersectsBox(e),intersectsTriangle:e=>{e.a.applyMatrix4(r),e.b.applyMatrix4(r),e.c.applyMatrix4(r),e.needsUpdate=!0;for(let n=p,r=m+p;n<r;n++)if(AC(mw,3*t.resolveTriangleIndex(n),l,u),mw.needsUpdate=!0,e.intersectsTriangle(mw))return!0;return!1}});{let e=qS(n);for(let n=p,r=m+p;n<r;n++){AC(pw,3*t.resolveTriangleIndex(n),l,u),pw.a.applyMatrix4(hw),pw.b.applyMatrix4(hw),pw.c.applyMatrix4(hw),pw.needsUpdate=!0;for(let t=0,n=e*3;t<n;t+=3)if(AC(mw,t,d,f),mw.needsUpdate=!0,pw.intersectsTriangle(mw))return!0}}}else{let o=$x(e),c=eS(e,s);return Kx(nS(o),a,fw),!!(i.intersectsBox(fw)&&yw(o,t,n,r,i)||(Kx(nS(c),a,fw),i.intersectsBox(fw)&&yw(c,t,n,r,i)))}}var bw=new tf,xw=new uC,Sw=new uC,Cw=new $,ww=new $,Tw=new $,Ew=new $;function Dw(e,t,n,r={},i={},a=0,o=1/0){t.boundingBox||t.computeBoundingBox(),xw.set(t.boundingBox.min,t.boundingBox.max,n),xw.needsUpdate=!0;let s=e.geometry,c=s.attributes.position,l=s.index,u=t.attributes.position,d=t.index,f=dC.getPrimitive(),p=dC.getPrimitive(),m=Cw,h=ww,g=null,_=null;i&&(g=Tw,_=Ew);let v=1/0,y=null,b=null;return bw.copy(n).invert(),Sw.matrix.copy(bw),e.shapecast({boundsTraverseOrder:e=>xw.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<o&&(t&&(Sw.min.copy(e.min),Sw.max.copy(e.max),Sw.needsUpdate=!0),!0),intersectsRange:(r,i)=>{if(t.boundsTree){let s=t.boundsTree;return s.shapecast({boundsTraverseOrder:e=>Sw.distanceToBox(e),intersectsBounds:(e,t,n)=>n<v&&n<o,intersectsRange:(t,o)=>{for(let x=t,S=t+o;x<S;x++){let t=s.resolveTriangleIndex(x);AC(p,3*t,d,u),p.a.applyMatrix4(n),p.b.applyMatrix4(n),p.c.applyMatrix4(n),p.needsUpdate=!0;for(let t=r,n=r+i;t<n;t++){let n=e.resolveTriangleIndex(t);AC(f,3*n,l,c),f.needsUpdate=!0;let r=f.distanceToTriangle(p,m,g);if(r<v&&(h.copy(m),_&&_.copy(g),v=r,y=t,b=x),r<a)return!0}}}})}{let o=qS(t);for(let t=0,s=o;t<s;t++){AC(p,3*t,d,u),p.a.applyMatrix4(n),p.b.applyMatrix4(n),p.c.applyMatrix4(n),p.needsUpdate=!0;for(let n=r,o=r+i;n<o;n++){let r=e.resolveTriangleIndex(n);AC(f,3*r,l,c),f.needsUpdate=!0;let i=f.distanceToTriangle(p,m,g);if(i<v&&(h.copy(m),_&&_.copy(g),v=i,y=n,b=t),i<a)return!0}}}}}),dC.releasePrimitive(f),dC.releasePrimitive(p),v===1/0?null:(r.point?r.point.copy(h):r.point=h.clone(),r.distance=v,r.faceIndex=y,i&&(i.point?i.point.copy(_):i.point=_.clone(),i.point.applyMatrix4(bw),h.applyMatrix4(bw),i.distance=h.sub(i.point).length(),i.faceIndex=b),r)}function Ow(e,t,n){return e===null?null:(e.point.applyMatrix4(t.matrixWorld),e.distance=e.point.distanceTo(n.ray.origin),e.object=t,e)}var kw=new uC,Aw=new hm,jw=new $,Mw=new tf,Nw=new $,Pw=[`getX`,`getY`,`getZ`],Fw=class e extends eC{static serialize(e,t={}){t={cloneBuffers:!0,...t};let n=e.geometry,r=e._roots,i=e._indirectBuffer,a=n.getIndex(),o={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(o.roots=r.map(e=>e.slice()),o.index=a?a.array.slice():null,o.indirectBuffer=i?i.slice():null):(o.roots=r,o.index=a?a.array:null,o.indirectBuffer=i),o}static deserialize(t,n,r={}){r={setIndex:!0,indirect:!!t.indirectBuffer,...r};let{index:i,roots:a,indirectBuffer:o}=t;t.version||(console.warn(`MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data.`),c(a));let s=new e(n,{...r,[Wx]:!0});if(s._roots=a,s._indirectBuffer=o||null,r.setIndex){let e=n.getIndex();if(e===null){let e=new Cp(t.index,1,!1);n.setIndex(e)}else e.array!==i&&(e.array.set(i),e.needsUpdate=!0)}return s;function c(e){for(let t=0;t<e.length;t++){let n=e[t],r=new Uint32Array(n),i=new Uint16Array(n);for(let e=0,t=n.byteLength/32;e<t;e++){let t=8*e;Xx(2*t,i)||(r[t+6]=r[t+6]/8-e)}}}}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(e,t={}){t.maxLeafTris&&(console.warn(`MeshBVH: "maxLeafTris" option has been deprecated. Use "targetLeafSize", instead.`),t={...t,targetLeafSize:t.maxLeafTris}),super(e,t)}shiftTriangleOffsets(e){return super.shiftPrimitiveOffsets(e)}writePrimitiveBounds(e,t,n){let r=this.geometry,i=this._indirectBuffer,a=r.attributes.position,o=r.index?r.index.array:null,s=(i?i[e]:e)*3,c=s+0,l=s+1,u=s+2;o&&(c=o[c],l=o[l],u=o[u]);for(let e=0;e<3;e++){let r=a[Pw[e]](c),i=a[Pw[e]](l),o=a[Pw[e]](u),s=r;i<s&&(s=i),o<s&&(s=o);let d=r;i>d&&(d=i),o>d&&(d=o),t[n+e]=s,t[n+e+3]=d}return t}computePrimitiveBounds(e,t,n){let r=this.geometry,i=this._indirectBuffer,a=r.attributes.position,o=r.index?r.index.array:null,s=a.normalized;if(e<0||t+e-n.offset>n.length/6)throw Error(`MeshBVH: compute triangle bounds range is invalid.`);let c=a.array,l=a.offset||0,u=3;a.isInterleavedBufferAttribute&&(u=a.data.stride);let d=[`getX`,`getY`,`getZ`],f=n.offset;for(let r=e,p=e+t;r<p;r++){let e=(i?i[r]:r)*3,t=(r-f)*6,p=e+0,m=e+1,h=e+2;o&&(p=o[p],m=o[m],h=o[h]),s||(p=p*u+l,m=m*u+l,h=h*u+l);for(let e=0;e<3;e++){let r,i,o;s?(r=a[d[e]](p),i=a[d[e]](m),o=a[d[e]](h)):(r=c[p+e],i=c[m+e],o=c[h+e]);let l=r;i<l&&(l=i),o<l&&(l=o);let u=r;i>u&&(u=i),o>u&&(u=o);let f=(u-l)/2,g=e*2;n[t+g+0]=l+f,n[t+g+1]=f+(Math.abs(l)+f)*Ux}}return n}raycastObject3D(e,t,n=[]){let{material:r}=e;if(r===void 0)return;Mw.copy(e.matrixWorld).invert(),Aw.copy(t.ray).applyMatrix4(Mw),Nw.setFromMatrixScale(e.matrixWorld),jw.copy(Aw.direction).multiply(Nw);let i=jw.length(),a=t.near/i,o=t.far/i;if(t.firstHitOnly===!0){let i=this.raycastFirst(Aw,r,a,o);i=Ow(i,e,t),i&&n.push(i)}else{let i=this.raycast(Aw,r,a,o);for(let r=0,a=i.length;r<a;r++){let a=Ow(i[r],e,t);a&&n.push(a)}}return n}refit(e=null){return(this.indirect?ow:PC)(this,e)}raycast(e,t=0,n=0,r=1/0){let i=this._roots,a=[],o=this.indirect?sw:zC;for(let s=0,c=i.length;s<c;s++)o(this,s,t,e,a,n,r);return a}raycastFirst(e,t=0,n=0,r=1/0){let i=this._roots,a=null,o=this.indirect?uw:HC;for(let s=0,c=i.length;s<c;s++){let i=o(this,s,t,e,n,r);i!=null&&(a==null||i.distance<a.distance)&&(a=i)}return a}intersectsGeometry(e,t){let n=!1,r=this._roots,i=this.indirect?vw:XC;for(let a=0,o=r.length;a<o&&(n=i(this,a,e,t),!n);a++);return n}shapecast(e){let t=dC.getPrimitive(),n=super.shapecast({...e,intersectsPrimitive:e.intersectsTriangle,scratchPrimitive:t,iterate:this.indirect?RC:NC});return dC.releasePrimitive(t),n}bvhcast(t,n,r){let{intersectsRanges:i,intersectsTriangles:a}=r,o=dC.getPrimitive(),s=this.geometry.index,c=this.geometry.attributes.position,l=this.indirect?e=>{let t=this.resolveTriangleIndex(e);AC(o,t*3,s,c)}:e=>{AC(o,e*3,s,c)},u=dC.getPrimitive(),d=t.geometry.index,f=t.geometry.attributes.position,p=t.indirect?e=>{let n=t.resolveTriangleIndex(e);AC(u,n*3,d,f)}:e=>{AC(u,e*3,d,f)};if(a){if(!(t instanceof e))throw Error(`MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.`);let r=(e,t,r,i,s,c,d,f)=>{for(let m=r,h=r+i;m<h;m++){p(m),u.a.applyMatrix4(n),u.b.applyMatrix4(n),u.c.applyMatrix4(n),u.needsUpdate=!0;for(let n=e,r=e+t;n<r;n++)if(l(n),o.needsUpdate=!0,a(o,u,n,m,s,c,d,f))return!0}return!1};if(i){let e=i;i=function(t,n,i,a,o,s,c,l){return e(t,n,i,a,o,s,c,l)?!0:r(t,n,i,a,o,s,c,l)}}else i=r}return super.bvhcast(t,n,{intersectsRanges:i})}intersectsBox(e,t){return kw.set(e.min,e.max,t),kw.needsUpdate=!0,this.shapecast({intersectsBounds:e=>kw.intersectsBox(e),intersectsTriangle:e=>kw.intersectsTriangle(e)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},r={},i=0,a=1/0){return(this.indirect?Dw:aw)(this,e,t,n,r,i,a)}closestPointToPoint(e,t={},n=0,r=1/0){return mC(this,e,t,n,r)}},Iw=class extends kf{constructor(e,t){super(),this.isViewHelper=!0,this.camera=e,this.animating=!1,this.center=new $,this.location={top:null,right:0,bottom:0,left:null};let n=new Lf(`#ff4466`),r=new Lf(`#88ff44`),i=new Lf(`#4488ff`),a=new Lf(`#000000`),o={},s=this,c=[],l=new Yg,u=new Q,d=new kf,f=new wg(-2,2,2,-2,0,4);f.position.set(0,0,2);let p=new sh(.04,.04,.8,5).rotateZ(-Math.PI/2).translate(.4,0,0),m=new Om(p,ee(n)),h=new Om(p,ee(r)),g=new Om(p,ee(i));h.rotation.z=Math.PI/2,g.rotation.y=-Math.PI/2,this.add(m),this.add(g),this.add(h);let _=I(n),v=I(r),y=I(i),b=I(a),x=new lm(_),S=new lm(v),C=new lm(y),w=new lm(b),T=new lm(b),E=new lm(b);x.position.x=1,S.position.y=1,C.position.z=1,w.position.x=-1,T.position.y=-1,E.position.z=-1,w.material.opacity=.2,T.material.opacity=.2,E.material.opacity=.2,x.userData.type=`posX`,S.userData.type=`posY`,C.userData.type=`posZ`,w.userData.type=`negX`,T.userData.type=`negY`,E.userData.type=`negZ`,this.add(x),this.add(S),this.add(C),this.add(w),this.add(T),this.add(E),c.push(x),c.push(S),c.push(C),c.push(w),c.push(T),c.push(E);let D=new $,O=2*Math.PI;this.render=function(e){this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld(),D.set(0,0,1),D.applyQuaternion(this.camera.quaternion);let n=this.location,r,i;r=n.left===null?t.offsetWidth-128-n.right:n.left,i=n.top===null?e.isWebGPURenderer?t.offsetHeight-128-n.bottom:n.bottom:e.isWebGPURenderer?n.top:t.offsetHeight-128-n.top,e.clearDepth(),e.getViewport(N),e.setViewport(r,i,128,128),e.render(this,f),e.setViewport(N.x,N.y,N.z,N.w)};let k=new $,A=new jd,j=new jd,M=new jd,N=new Xd,P=0;this.handleClick=function(e){if(this.animating===!0)return!1;let n=t.getBoundingClientRect(),r=this.location,i,a;i=r.left===null?n.left+t.offsetWidth-128-r.right:n.left+r.left,a=r.top===null?n.top+t.offsetHeight-128-r.bottom:n.top+r.top,u.x=(e.clientX-i)/128*2-1,u.y=-((e.clientY-a)/128)*2+1,l.setFromCamera(u,f);let o=l.intersectObjects(c);if(o.length>0){let e=o[0].object;return F(e,this.center),this.animating=!0,!0}return!1},this.setLabels=function(e,t,n){o.labelX=e,o.labelY=t,o.labelZ=n,L()},this.setLabelStyle=function(e,t,n){o.font=e,o.color=t,o.radius=n,L()},this.update=function(e){let t=e*O;j.rotateTowards(M,t),this.camera.position.set(0,0,1).applyQuaternion(j).multiplyScalar(P).add(this.center),this.camera.quaternion.rotateTowards(A,t),j.angleTo(M)===0&&(this.animating=!1)},this.dispose=function(){p.dispose(),m.material.dispose(),h.material.dispose(),g.material.dispose(),x.material.map.dispose(),S.material.map.dispose(),C.material.map.dispose(),w.material.map.dispose(),T.material.map.dispose(),E.material.map.dispose(),x.material.dispose(),S.material.dispose(),C.material.dispose(),w.material.dispose(),T.material.dispose(),E.material.dispose()};function F(e,t){switch(e.userData.type){case`posX`:k.set(1,0,0),A.setFromEuler(new ff(0,Math.PI*.5,0));break;case`posY`:k.set(0,1,0),A.setFromEuler(new ff(-Math.PI*.5,0,0));break;case`posZ`:k.set(0,0,1),A.setFromEuler(new ff);break;case`negX`:k.set(-1,0,0),A.setFromEuler(new ff(0,-Math.PI*.5,0));break;case`negY`:k.set(0,-1,0),A.setFromEuler(new ff(Math.PI*.5,0,0));break;case`negZ`:k.set(0,0,-1),A.setFromEuler(new ff(0,Math.PI,0));break;default:console.error(`ViewHelper: Invalid axis.`)}P=s.camera.position.distanceTo(t),k.multiplyScalar(P).add(t),d.position.copy(t),d.lookAt(s.camera.position),j.copy(d.quaternion),d.lookAt(k),M.copy(d.quaternion)}function ee(e){return new gm({color:e,toneMapped:!1})}function te(){let e=!1;try{e=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}return e}function ne(e,t){let n;return te()?n=new OffscreenCanvas(e,t):(n=document.createElement(`canvas`),n.width=e,n.height=t),n}function I(e,t){let{font:n=`24px Arial`,color:r=`#000000`,radius:i=14}=o,a=ne(64,64),s=a.getContext(`2d`);s.beginPath(),s.arc(32,32,i,0,2*Math.PI),s.closePath(),s.fillStyle=e.getStyle(),s.fill(),t&&(s.font=n,s.textAlign=`center`,s.fillStyle=r,s.fillText(t,32,41));let c=new nh(a);return c.colorSpace=Lu,new Yp({map:c,toneMapped:!1})}function L(){x.material.map.dispose(),S.material.map.dispose(),C.material.map.dispose(),x.material.dispose(),S.material.dispose(),C.material.dispose(),x.material=I(n,o.labelX),S.material=I(r,o.labelY),C.material=I(i,o.labelZ)}}},Lw={name:`CopyShader`,uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
4640
4640
|
|
|
4641
4641
|
varying vec2 vUv;
|
|
4642
4642
|
|
|
@@ -5042,7 +5042,7 @@ void main() {
|
|
|
5042
5042
|
denoised /= totalWeight;
|
|
5043
5043
|
}
|
|
5044
5044
|
gl_FragColor = FRAGMENT_OUTPUT;
|
|
5045
|
-
}`};function $w(e,t,n){let r=eT(e,t,n),i=`vec3[SAMPLES](`;for(let t=0;t<e;t++){let n=r[t];i+=`vec3(${n.x}, ${n.y}, ${n.z})${t<e-1?`,`:`)`}`}return i}function eT(e,t,n){let r=[];for(let i=0;i<e;i++){let a=2*Math.PI*t*i/e,o=(i/(e-1))**n;r.push(new $(Math.cos(a),Math.sin(a),o))}return r}var tT=class{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[e&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}noise(e,t){let n,r,i,a=.5*(Math.sqrt(3)-1),o=(e+t)*a,s=Math.floor(e+o),c=Math.floor(t+o),l=(3-Math.sqrt(3))/6,u=(s+c)*l,d=s-u,f=c-u,p=e-d,m=t-f,h,g;p>m?(h=1,g=0):(h=0,g=1);let _=p-h+l,v=m-g+l,y=p-1+2*l,b=m-1+2*l,x=s&255,S=c&255,C=this.perm[x+this.perm[S]]%12,w=this.perm[x+h+this.perm[S+g]]%12,T=this.perm[x+1+this.perm[S+1]]%12,E=.5-p*p-m*m;E<0?n=0:(E*=E,n=E*E*this._dot(this.grad3[C],p,m));let D=.5-_*_-v*v;D<0?r=0:(D*=D,r=D*D*this._dot(this.grad3[w],_,v));let O=.5-y*y-b*b;return O<0?i=0:(O*=O,i=O*O*this._dot(this.grad3[T],y,b)),70*(n+r+i)}noise3d(e,t,n){let r,i,a,o,s=(e+t+n)*(1/3),c=Math.floor(e+s),l=Math.floor(t+s),u=Math.floor(n+s),d=1/6,f=(c+l+u)*d,p=c-f,m=l-f,h=u-f,g=e-p,_=t-m,v=n-h,y,b,x,S,C,w;g>=_?_>=v?(y=1,b=0,x=0,S=1,C=1,w=0):g>=v?(y=1,b=0,x=0,S=1,C=0,w=1):(y=0,b=0,x=1,S=1,C=0,w=1):_<v?(y=0,b=0,x=1,S=0,C=1,w=1):g<v?(y=0,b=1,x=0,S=0,C=1,w=1):(y=0,b=1,x=0,S=1,C=1,w=0);let T=g-y+d,E=_-b+d,D=v-x+d,O=g-S+2*d,k=_-C+2*d,A=v-w+2*d,j=g-1+3*d,M=_-1+3*d,N=v-1+3*d,P=c&255,F=l&255,I=u&255,ee=this.perm[P+this.perm[F+this.perm[I]]]%12,te=this.perm[P+y+this.perm[F+b+this.perm[I+x]]]%12,L=this.perm[P+S+this.perm[F+C+this.perm[I+w]]]%12,R=this.perm[P+1+this.perm[F+1+this.perm[I+1]]]%12,z=.6-g*g-_*_-v*v;z<0?r=0:(z*=z,r=z*z*this._dot3(this.grad3[ee],g,_,v));let B=.6-T*T-E*E-D*D;B<0?i=0:(B*=B,i=B*B*this._dot3(this.grad3[te],T,E,D));let ne=.6-O*O-k*k-A*A;ne<0?a=0:(ne*=ne,a=ne*ne*this._dot3(this.grad3[L],O,k,A));let re=.6-j*j-M*M-N*N;return re<0?o=0:(re*=re,o=re*re*this._dot3(this.grad3[R],j,M,N)),32*(r+i+a+o)}noise4d(e,t,n,r){let i=this.grad4,a=this.simplex,o=this.perm,s=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20,l,u,d,f,p,m=(e+t+n+r)*s,h=Math.floor(e+m),g=Math.floor(t+m),_=Math.floor(n+m),v=Math.floor(r+m),y=(h+g+_+v)*c,b=h-y,x=g-y,S=_-y,C=v-y,w=e-b,T=t-x,E=n-S,D=r-C,O=w>T?32:0,k=w>E?16:0,A=T>E?8:0,j=w>D?4:0,M=T>D?2:0,N=+(E>D),P=O+k+A+j+M+N,F=+(a[P][0]>=3),I=+(a[P][1]>=3),ee=+(a[P][2]>=3),te=+(a[P][3]>=3),L=+(a[P][0]>=2),R=+(a[P][1]>=2),z=+(a[P][2]>=2),B=+(a[P][3]>=2),ne=+(a[P][0]>=1),re=+(a[P][1]>=1),ie=+(a[P][2]>=1),ae=+(a[P][3]>=1),V=w-F+c,H=T-I+c,U=E-ee+c,W=D-te+c,oe=w-L+2*c,G=T-R+2*c,se=E-z+2*c,K=D-B+2*c,ce=w-ne+3*c,q=T-re+3*c,le=E-ie+3*c,J=D-ae+3*c,Y=w-1+4*c,ue=T-1+4*c,de=E-1+4*c,fe=D-1+4*c,X=h&255,pe=g&255,me=_&255,Z=v&255,he=o[X+o[pe+o[me+o[Z]]]]%32,ge=o[X+F+o[pe+I+o[me+ee+o[Z+te]]]]%32,_e=o[X+L+o[pe+R+o[me+z+o[Z+B]]]]%32,ve=o[X+ne+o[pe+re+o[me+ie+o[Z+ae]]]]%32,ye=o[X+1+o[pe+1+o[me+1+o[Z+1]]]]%32,be=.6-w*w-T*T-E*E-D*D;be<0?l=0:(be*=be,l=be*be*this._dot4(i[he],w,T,E,D));let xe=.6-V*V-H*H-U*U-W*W;xe<0?u=0:(xe*=xe,u=xe*xe*this._dot4(i[ge],V,H,U,W));let Se=.6-oe*oe-G*G-se*se-K*K;Se<0?d=0:(Se*=Se,d=Se*Se*this._dot4(i[_e],oe,G,se,K));let Ce=.6-ce*ce-q*q-le*le-J*J;Ce<0?f=0:(Ce*=Ce,f=Ce*Ce*this._dot4(i[ve],ce,q,le,J));let we=.6-Y*Y-ue*ue-de*de-fe*fe;return we<0?p=0:(we*=we,p=we*we*this._dot4(i[ye],Y,ue,de,fe)),27*(l+u+d+f+p)}_dot(e,t,n){return e[0]*t+e[1]*n}_dot3(e,t,n,r){return e[0]*t+e[1]*n+e[2]*r}_dot4(e,t,n,r,i){return e[0]*t+e[1]*n+e[2]*r+e[3]*i}},nT=class e extends Rw{constructor(e,t,n=512,r=512,i,a,o){super(),this.width=n,this.height=r,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=[],this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=Xw(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new Qd(this.width,this.height,{type:jl,depthBuffer:!1}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new wh({defines:Object.assign({},qw.defines),uniforms:xh.clone(qw.uniforms),vertexShader:qw.vertexShader,fragmentShader:qw.fragmentShader,blending:0,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=+!!this.camera.isPerspectiveCamera,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new Oh,this.normalMaterial.blending=0,this.pdMaterial=new wh({defines:Object.assign({},Qw.defines),uniforms:xh.clone(Qw.uniforms),vertexShader:Qw.vertexShader,fragmentShader:Qw.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new wh({defines:Object.assign({},Jw.defines),uniforms:xh.clone(Jw.uniforms),vertexShader:Jw.vertexShader,fragmentShader:Jw.fragmentShader,blending:0}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new wh({uniforms:xh.clone(Lw.uniforms),vertexShader:Lw.vertexShader,fragmentShader:Lw.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:208,blendDst:200,blendEquation:100,blendSrcAlpha:206,blendDstAlpha:200,blendEquationAlpha:100}),this.blendMaterial=new wh({uniforms:xh.clone(Yw.uniforms),vertexShader:Yw.vertexShader,fragmentShader:Yw.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:5,blendSrc:208,blendDst:200,blendEquation:100,blendSrcAlpha:206,blendDstAlpha:200,blendEquationAlpha:100}),this._fsQuad=new Vw(null),this._originalClearColor=new Lf,this.setGBuffer(i?i.depthTexture:void 0,i?i.normalTexture:void 0),a!==void 0&&this.updateGtaoMaterial(a),o!==void 0&&this.updatePdMaterial(o)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget&&this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget&&this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){if(e!==void 0)this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1;else{if(this.normalRenderTarget===void 0){let e=new rh;e.format=Vl,e.type=Pl,this.normalRenderTarget=new Qd(this.width,this.height,{minFilter:vl,magFilter:vl,type:jl,depthTexture:e})}this.depthTexture=this.normalRenderTarget.depthTexture,this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0}let n=+!!this.normalTexture;this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.needsUpdate=!0,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.needsUpdate=!0,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&+!!e.screenSpaceRadius!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=+!!e.screenSpaceRadius,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=$w(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(t,n,r){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(t,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(t,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case e.OUTPUT.Off:break;case e.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=r.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalTexture||null,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=r.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(t,this.blendMaterial,this.renderToScreen?null:n);break;default:console.warn(`THREE.GTAOPass: Unknown output type.`)}}_renderPass(e,t,n,r,i){e.getClearColor(this._originalClearColor);let a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r!=null&&(e.setClearColor(r),e.setClearAlpha(i||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_renderOverride(e,t,n,r,i){e.getClearColor(this._originalClearColor);let a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r=t.clearColor||r,i=t.clearAlpha||i,r!=null&&(e.setClearColor(r),e.setClearAlpha(i||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_overrideVisibility(){let e=this.scene,t=this._visibilityCache;e.traverse(function(e){(e.isPoints||e.isLine||e.isLine2)&&e.visible&&(e.visible=!1,t.push(e))})}_restoreVisibility(){let e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}_generateNoise(e=64){let t=new tT,n=e*e*4,r=new Uint8Array(n);for(let n=0;n<e;n++)for(let i=0;i<e;i++){let a=n,o=i;r[(n*e+i)*4]=(t.noise(a,o)*.5+.5)*255,r[(n*e+i)*4+1]=(t.noise(a+e,o)*.5+.5)*255,r[(n*e+i)*4+2]=(t.noise(a,o+e)*.5+.5)*255,r[(n*e+i)*4+3]=(t.noise(a+e,o+e)*.5+.5)*255}let i=new jm(r,e,e,zl,wl);return i.wrapS=hl,i.wrapT=hl,i.needsUpdate=!0,i}};nT.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};var rT={name:`SMAAEdgesShader`,defines:{SMAA_THRESHOLD:`0.1`},uniforms:{tDiffuse:{value:null},resolution:{value:new Q(1/1024,1/512)}},vertexShader:`
|
|
5045
|
+
}`};function $w(e,t,n){let r=eT(e,t,n),i=`vec3[SAMPLES](`;for(let t=0;t<e;t++){let n=r[t];i+=`vec3(${n.x}, ${n.y}, ${n.z})${t<e-1?`,`:`)`}`}return i}function eT(e,t,n){let r=[];for(let i=0;i<e;i++){let a=2*Math.PI*t*i/e,o=(i/(e-1))**n;r.push(new $(Math.cos(a),Math.sin(a),o))}return r}var tT=class{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let e=0;e<512;e++)this.perm[e]=this.p[e&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}noise(e,t){let n,r,i,a=.5*(Math.sqrt(3)-1),o=(e+t)*a,s=Math.floor(e+o),c=Math.floor(t+o),l=(3-Math.sqrt(3))/6,u=(s+c)*l,d=s-u,f=c-u,p=e-d,m=t-f,h,g;p>m?(h=1,g=0):(h=0,g=1);let _=p-h+l,v=m-g+l,y=p-1+2*l,b=m-1+2*l,x=s&255,S=c&255,C=this.perm[x+this.perm[S]]%12,w=this.perm[x+h+this.perm[S+g]]%12,T=this.perm[x+1+this.perm[S+1]]%12,E=.5-p*p-m*m;E<0?n=0:(E*=E,n=E*E*this._dot(this.grad3[C],p,m));let D=.5-_*_-v*v;D<0?r=0:(D*=D,r=D*D*this._dot(this.grad3[w],_,v));let O=.5-y*y-b*b;return O<0?i=0:(O*=O,i=O*O*this._dot(this.grad3[T],y,b)),70*(n+r+i)}noise3d(e,t,n){let r,i,a,o,s=(e+t+n)*(1/3),c=Math.floor(e+s),l=Math.floor(t+s),u=Math.floor(n+s),d=1/6,f=(c+l+u)*d,p=c-f,m=l-f,h=u-f,g=e-p,_=t-m,v=n-h,y,b,x,S,C,w;g>=_?_>=v?(y=1,b=0,x=0,S=1,C=1,w=0):g>=v?(y=1,b=0,x=0,S=1,C=0,w=1):(y=0,b=0,x=1,S=1,C=0,w=1):_<v?(y=0,b=0,x=1,S=0,C=1,w=1):g<v?(y=0,b=1,x=0,S=0,C=1,w=1):(y=0,b=1,x=0,S=1,C=1,w=0);let T=g-y+d,E=_-b+d,D=v-x+d,O=g-S+2*d,k=_-C+2*d,A=v-w+2*d,j=g-1+3*d,M=_-1+3*d,N=v-1+3*d,P=c&255,F=l&255,ee=u&255,te=this.perm[P+this.perm[F+this.perm[ee]]]%12,ne=this.perm[P+y+this.perm[F+b+this.perm[ee+x]]]%12,I=this.perm[P+S+this.perm[F+C+this.perm[ee+w]]]%12,L=this.perm[P+1+this.perm[F+1+this.perm[ee+1]]]%12,R=.6-g*g-_*_-v*v;R<0?r=0:(R*=R,r=R*R*this._dot3(this.grad3[te],g,_,v));let z=.6-T*T-E*E-D*D;z<0?i=0:(z*=z,i=z*z*this._dot3(this.grad3[ne],T,E,D));let re=.6-O*O-k*k-A*A;re<0?a=0:(re*=re,a=re*re*this._dot3(this.grad3[I],O,k,A));let B=.6-j*j-M*M-N*N;return B<0?o=0:(B*=B,o=B*B*this._dot3(this.grad3[L],j,M,N)),32*(r+i+a+o)}noise4d(e,t,n,r){let i=this.grad4,a=this.simplex,o=this.perm,s=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20,l,u,d,f,p,m=(e+t+n+r)*s,h=Math.floor(e+m),g=Math.floor(t+m),_=Math.floor(n+m),v=Math.floor(r+m),y=(h+g+_+v)*c,b=h-y,x=g-y,S=_-y,C=v-y,w=e-b,T=t-x,E=n-S,D=r-C,O=w>T?32:0,k=w>E?16:0,A=T>E?8:0,j=w>D?4:0,M=T>D?2:0,N=+(E>D),P=O+k+A+j+M+N,F=+(a[P][0]>=3),ee=+(a[P][1]>=3),te=+(a[P][2]>=3),ne=+(a[P][3]>=3),I=+(a[P][0]>=2),L=+(a[P][1]>=2),R=+(a[P][2]>=2),z=+(a[P][3]>=2),re=+(a[P][0]>=1),B=+(a[P][1]>=1),ie=+(a[P][2]>=1),ae=+(a[P][3]>=1),V=w-F+c,H=T-ee+c,U=E-te+c,W=D-ne+c,oe=w-I+2*c,G=T-L+2*c,se=E-R+2*c,K=D-z+2*c,ce=w-re+3*c,q=T-B+3*c,le=E-ie+3*c,J=D-ae+3*c,Y=w-1+4*c,ue=T-1+4*c,de=E-1+4*c,fe=D-1+4*c,X=h&255,pe=g&255,me=_&255,Z=v&255,he=o[X+o[pe+o[me+o[Z]]]]%32,ge=o[X+F+o[pe+ee+o[me+te+o[Z+ne]]]]%32,_e=o[X+I+o[pe+L+o[me+R+o[Z+z]]]]%32,ve=o[X+re+o[pe+B+o[me+ie+o[Z+ae]]]]%32,ye=o[X+1+o[pe+1+o[me+1+o[Z+1]]]]%32,be=.6-w*w-T*T-E*E-D*D;be<0?l=0:(be*=be,l=be*be*this._dot4(i[he],w,T,E,D));let xe=.6-V*V-H*H-U*U-W*W;xe<0?u=0:(xe*=xe,u=xe*xe*this._dot4(i[ge],V,H,U,W));let Se=.6-oe*oe-G*G-se*se-K*K;Se<0?d=0:(Se*=Se,d=Se*Se*this._dot4(i[_e],oe,G,se,K));let Ce=.6-ce*ce-q*q-le*le-J*J;Ce<0?f=0:(Ce*=Ce,f=Ce*Ce*this._dot4(i[ve],ce,q,le,J));let we=.6-Y*Y-ue*ue-de*de-fe*fe;return we<0?p=0:(we*=we,p=we*we*this._dot4(i[ye],Y,ue,de,fe)),27*(l+u+d+f+p)}_dot(e,t,n){return e[0]*t+e[1]*n}_dot3(e,t,n,r){return e[0]*t+e[1]*n+e[2]*r}_dot4(e,t,n,r,i){return e[0]*t+e[1]*n+e[2]*r+e[3]*i}},nT=class e extends Rw{constructor(e,t,n=512,r=512,i,a,o){super(),this.width=n,this.height=r,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=[],this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=Xw(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new Qd(this.width,this.height,{type:jl,depthBuffer:!1}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new wh({defines:Object.assign({},qw.defines),uniforms:xh.clone(qw.uniforms),vertexShader:qw.vertexShader,fragmentShader:qw.fragmentShader,blending:0,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=+!!this.camera.isPerspectiveCamera,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new Oh,this.normalMaterial.blending=0,this.pdMaterial=new wh({defines:Object.assign({},Qw.defines),uniforms:xh.clone(Qw.uniforms),vertexShader:Qw.vertexShader,fragmentShader:Qw.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new wh({defines:Object.assign({},Jw.defines),uniforms:xh.clone(Jw.uniforms),vertexShader:Jw.vertexShader,fragmentShader:Jw.fragmentShader,blending:0}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new wh({uniforms:xh.clone(Lw.uniforms),vertexShader:Lw.vertexShader,fragmentShader:Lw.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:208,blendDst:200,blendEquation:100,blendSrcAlpha:206,blendDstAlpha:200,blendEquationAlpha:100}),this.blendMaterial=new wh({uniforms:xh.clone(Yw.uniforms),vertexShader:Yw.vertexShader,fragmentShader:Yw.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:5,blendSrc:208,blendDst:200,blendEquation:100,blendSrcAlpha:206,blendDstAlpha:200,blendEquationAlpha:100}),this._fsQuad=new Vw(null),this._originalClearColor=new Lf,this.setGBuffer(i?i.depthTexture:void 0,i?i.normalTexture:void 0),a!==void 0&&this.updateGtaoMaterial(a),o!==void 0&&this.updatePdMaterial(o)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget&&this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget&&this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){if(e!==void 0)this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1;else{if(this.normalRenderTarget===void 0){let e=new rh;e.format=Vl,e.type=Pl,this.normalRenderTarget=new Qd(this.width,this.height,{minFilter:vl,magFilter:vl,type:jl,depthTexture:e})}this.depthTexture=this.normalRenderTarget.depthTexture,this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0}let n=+!!this.normalTexture;this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.needsUpdate=!0,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.needsUpdate=!0,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&+!!e.screenSpaceRadius!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=+!!e.screenSpaceRadius,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=$w(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(t,n,r){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(t,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(t,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case e.OUTPUT.Off:break;case e.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=r.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(t,this.depthRenderMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalTexture||null,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n);break;case e.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=r.texture,this.copyMaterial.blending=0,this._renderPass(t,this.copyMaterial,this.renderToScreen?null:n),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(t,this.blendMaterial,this.renderToScreen?null:n);break;default:console.warn(`THREE.GTAOPass: Unknown output type.`)}}_renderPass(e,t,n,r,i){e.getClearColor(this._originalClearColor);let a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r!=null&&(e.setClearColor(r),e.setClearAlpha(i||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_renderOverride(e,t,n,r,i){e.getClearColor(this._originalClearColor);let a=e.getClearAlpha(),o=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r=t.clearColor||r,i=t.clearAlpha||i,r!=null&&(e.setClearColor(r),e.setClearAlpha(i||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=o,e.setClearColor(this._originalClearColor),e.setClearAlpha(a)}_overrideVisibility(){let e=this.scene,t=this._visibilityCache;e.traverse(function(e){(e.isPoints||e.isLine||e.isLine2)&&e.visible&&(e.visible=!1,t.push(e))})}_restoreVisibility(){let e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}_generateNoise(e=64){let t=new tT,n=e*e*4,r=new Uint8Array(n);for(let n=0;n<e;n++)for(let i=0;i<e;i++){let a=n,o=i;r[(n*e+i)*4]=(t.noise(a,o)*.5+.5)*255,r[(n*e+i)*4+1]=(t.noise(a+e,o)*.5+.5)*255,r[(n*e+i)*4+2]=(t.noise(a,o+e)*.5+.5)*255,r[(n*e+i)*4+3]=(t.noise(a+e,o+e)*.5+.5)*255}let i=new jm(r,e,e,zl,wl);return i.wrapS=hl,i.wrapT=hl,i.needsUpdate=!0,i}};nT.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};var rT={name:`SMAAEdgesShader`,defines:{SMAA_THRESHOLD:`0.1`},uniforms:{tDiffuse:{value:null},resolution:{value:new Q(1/1024,1/512)}},vertexShader:`
|
|
5046
5046
|
|
|
5047
5047
|
uniform vec2 resolution;
|
|
5048
5048
|
|
|
@@ -5616,15 +5616,15 @@ void main() {
|
|
|
5616
5616
|
`))&&a<t&&r<e.byteLength;)o+=s,a+=s.length,r+=128,s=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));return-1<i&&(!1!==n&&(e.pos+=a+i+1),o+s.slice(0,i))},r=function(e){let r=/^#\?(\S+)/,i=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,a=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*FORMAT=(\S+)\s*$/,s=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,c={valid:0,string:``,comments:``,programtype:`RGBE`,format:``,gamma:1,exposure:1,width:0,height:0},l,u;for((e.pos>=e.byteLength||!(l=n(e)))&&t(1,`no header found`),(u=l.match(r))||t(3,`bad initial token`),c.valid|=1,c.programtype=u[1],c.string+=l+`
|
|
5617
5617
|
`;l=n(e),!1!==l;)if(c.string+=l+`
|
|
5618
5618
|
`,l.charAt(0)===`#`)c.comments+=l+`
|
|
5619
|
-
`;else if((u=l.match(i))&&(c.gamma=parseFloat(u[1])),(u=l.match(a))&&(c.exposure=parseFloat(u[1])),(u=l.match(o))&&(c.valid|=2,c.format=u[1]),(u=l.match(s))&&(c.valid|=4,c.height=parseInt(u[1],10),c.width=parseInt(u[2],10)),c.valid&2&&c.valid&4)break;return c.valid&2||t(3,`missing format specifier`),c.valid&4||t(3,`missing image size specifier`),c},i=function(e,n,r){let i=n;if(i<8||i>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,`wrong scanline width`);let a=new Uint8Array(4*n*r);a.length||t(4,`unable to allocate buffer space`);let o=0,s=0,c=4*i,l=new Uint8Array(4),u=new Uint8Array(c),d=r;for(;d>0&&s<e.byteLength;){s+4>e.byteLength&&t(1),l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++],(l[0]!=2||l[1]!=2||(l[2]<<8|l[3])!=i)&&t(3,`bad rgbe scanline format`);let n=0,r;for(;n<c&&s<e.byteLength;){r=e[s++];let i=r>128;if(i&&(r-=128),(r===0||n+r>c)&&t(3,`bad scanline data`),i){let t=e[s++];for(let e=0;e<r;e++)u[n++]=t}else u.set(e.subarray(s,s+r),n),n+=r,s+=r}let f=i;for(let e=0;e<f;e++){let t=0;a[o]=u[e+t],t+=i,a[o+1]=u[e+t],t+=i,a[o+2]=u[e+t],t+=i,a[o+3]=u[e+t],o+=4}d--}return a},a=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=e[t+0]*i,n[r+1]=e[t+1]*i,n[r+2]=e[t+2]*i,n[r+3]=1},o=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=yp.toHalfFloat(Math.min(e[t+0]*i,65504)),n[r+1]=yp.toHalfFloat(Math.min(e[t+1]*i,65504)),n[r+2]=yp.toHalfFloat(Math.min(e[t+2]*i,65504)),n[r+3]=yp.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;let c=r(s),l=c.width,u=c.height,d=i(s.subarray(s.pos),l,u),f,p,m;switch(this.type){case Al:m=d.length/4;let e=new Float32Array(m*4);for(let t=0;t<m;t++)a(d,t*4,e,t*4);f=e,p=Al;break;case jl:m=d.length/4;let t=new Uint16Array(m*4);for(let e=0;e<m;e++)o(d,e*4,t,e*4);f=t,p=jl;break;default:throw Error(`THREE.HDRLoader: Unsupported type: `+this.type)}return{width:l,height:u,data:f,header:c.string,gamma:c.gamma,exposure:c.exposure,type:p,colorSpace:Ru,minFilter:xl,magFilter:xl,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}},FT=[`technical`,`studio`,`showcase`,`arctic`,`xray`,`lineart`,`wireframe`,`night`],IT=`user`,LT=`app:`;function RT(e){return`${LT}${e}`}function zT(e){return typeof e!=`string`||!e.startsWith(LT)?null:e.slice(4)||null}function BT(e){let t=e.userData?.source;return t===`user`||zT(t)!==null}function VT(e,t){return t===void 0?BT(e):e.userData?.source===RT(t)}var HT=2.5,UT=11,WT=4.5,GT=3.5,KT=.05,qT=.06,JT=.65,YT=.8,XT=10;function ZT(e,t,n,r){let i=new Om(new ph(t,n),new gm({color:new Lf().setScalar(e),side:2}));return i.position.set(...r),i.lookAt(0,0,0),i}function QT(){let e=new zf,t=new Om($T(),new gm({vertexColors:!0,side:1})),n=new Om(new ph(XT,XT),new gm({color:new Lf().setScalar(KT)}));return n.rotation.x=-Math.PI/2,n.position.y=-4,e.add(t,n,ZT(HT,6.5,4.5,[0,4.8,.6]),ZT(UT,1.4,5.5,[-4.7,.8,1.6]),ZT(WT,.9,5,[4.7,.5,2.4]),ZT(GT,5,.8,[.6,2.2,-4.7])),e}function $T(){let e=new oh(XT,XT,XT,1,16,1),t=e.attributes.position,n=new Float32Array(t.count*3);for(let e=0;e<t.count;e++){let r=t.getY(e)/(XT/2),i=r<0?Ad.lerp(JT,qT,-r):Ad.lerp(JT,YT,r);n.fill(i,e*3,e*3+3)}return e.setAttribute(`color`,new Cp(n,3)),e}function eE(e){e.traverse(e=>{let t=e;t.geometry?.dispose(),t.material?.dispose()})}var tE=.5,nE=.03,rE=`selvaReflectionEnvironment`;function iE(e,t,n){let r=new M_(t),i=QT(),a=r.fromScene(i,nE).texture;eE(i),r.dispose(),aE(e,a,n)}function aE(e,t,n){let r={texture:t,rotation:n.clone()};e.userData[rE]=r,sE(e,e)}function oE(e){e.userData[rE]?.texture.dispose(),delete e.userData[rE]}function sE(e,t){let n=t.userData[rE];n&&e.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,r=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of r){if(!(e instanceof Eh)||e.envMap&&e.envMap!==n.texture)continue;let t=e.metalness>tE?n.texture:null;e.envMap!==t&&(e.envMap=t,e.envMapRotation.copy(n.rotation),e.needsUpdate=!0)}})}function cE(e){let t=e.clone().normalize(),n=new $(0,0,1),r=new $(0,1,0),i=Math.abs(t.dot(n))>.9?r:n,a=new $().crossVectors(i,t).normalize();return{up:t,forward:new $().crossVectors(t,a).normalize(),right:a}}function lE(e,t){let{forward:n,right:r,up:i}=cE(e);return n.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(t)}function uE(e,t,n){let{forward:r,right:i,up:a}=cE(e);return i.clone().multiplyScalar(t).add(r.clone().multiplyScalar(t)).add(a.clone().multiplyScalar(n))}function dE(e){let t=e.clone().normalize(),n=new $(0,1,0);if(t.dot(n)>.9999)return new ff;if(t.dot(n)<-.9999)return new ff(Math.PI,0,0);let r=new jd().setFromUnitVectors(n,t);return new ff().setFromQuaternion(r)}function fE(e){let t=Math.abs(e.x),n=Math.abs(e.y),r=Math.abs(e.z);return t>=n&&t>=r?`x`:n>=r?`y`:`z`}var pE=new $(0,0,1);function mE(){return(window.matchMedia?.(`(pointer: coarse)`).matches??!1)&&Math.min(window.screen.width,window.screen.height)<600}function hE(e){let t=e.sceneScale||`m`,n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[t],r=e.look??`technical`,i=e.render?.lowPower??mE(),a=Db(r,i);return{sceneScale:t,look:r,camera:{position:e.camera?.position||lE(e.environment?.sceneUp??pE,n.cameraDistance*Math.sqrt(3)),fov:e.camera?.fov||20,near:e.camera?.near||n.near,far:e.camera?.far||n.far,target:e.camera?.target||new $(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??a.sunlightIntensity,sunlightPosition:e.lighting?.sunlightPosition||uE(e.environment?.sceneUp??pE,n.lightDistance,n.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new Lf(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??a.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??a.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??a.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath===!1?!1:e.environment?.hdrPath||`/baseHDR.hdr`,backgroundColor:e.environment?.backgroundColor||new Lf(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||pE,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??a.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||n.floorSize,color:e.floor?.color||new Lf(8421504),roughness:e.floor?.roughness??.7,metalness:e.floor?.metalness??0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||1024,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping??a.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??a.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,lowPower:i,idleRefineFrames:e.render?.idleRefineFrames??(i?0:32),lightOrbitFrameMs:e.render?.lightOrbitFrameMs??22,ambientOcclusion:e.render?.ambientOcclusion??a.ambientOcclusion,aoIntensity:e.render?.aoIntensity??1,bloom:e.render?.bloom??a.bloom,aoPixelRatio:e.render?.aoPixelRatio??1,onDemand:e.render?.onDemand??!0},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||n.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??!1,cellSize:e.grid?.cellSize??1,majorEvery:e.grid?.majorEvery??10,cellColor:e.grid?.cellColor??8947848,majorColor:e.grid?.majorColor??4473924,fadeDistance:e.grid?.fadeDistance??100,plane:e.grid?.plane??fE(e.environment?.sceneUp??pE)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color,darken:e.edges?.darken,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??44,distanceFade:e.edges?.distanceFade??!0,maxTriangles:e.edges?.maxTriangles,maxSegments:e.edges?.maxSegments,maxOverlays:e.edges?.maxOverlays,screenSpaceFallback:e.edges?.screenSpaceFallback},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,displayUnit:e.measure?.displayUnit,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||`#ff0000`,enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame},onMaxAnisotropy:e.onMaxAnisotropy}}var gE=150,_E=8,vE=12;function yE(e,t){let n=0,r=1/t;for(let i=e;i>0;i=Math.floor(i/t))n+=i%t*r,r/=t;return n}function bE(e){let t=0;return e.traverseVisible(e=>{t+=1;let{material:n}=e;for(let e of Array.isArray(n)?n:n?[n]:[])t+=e.version*31}),t}function xE(e){let{scene:t,renderer:n,getPipeline:r,frames:i,lightOrbitFrameMs:a,jitterLights:o,restoreLights:s}=e,c=0,l=0,u=0,d=new Q,f=i>0&&a<=0,p=1,m=[],h=e=>{p=Math.min(1,Math.max(0,e)),r()?.setAoWeight(p)},g=e=>{m.push(e),!(m.length<vE)&&(m.sort((e,t)=>e-t),f=m[6]>a,m.length=0)},_=(e,t)=>{let r=e;if(!r.setViewOffset)return;n.getDrawingBufferSize(d);let i=t?yE(t,2)-.5:0,a=t?yE(t,3)-.5:0;r.setViewOffset(d.x,d.y,i,a,d.x,d.y)};return{reset:e=>{c=0,l=e},moving:e=>{i!==0&&(f?h(p-1/_E):g(e))},wants:e=>(c<i||p<1)&&e-l>=gE&&!!r(),step:e=>{let n=r();n&&(p<1?(h(p+1/_E),n.setCamera(e),n.accumulate(0)):(c>0&&o(c),_(e,c),n.setCamera(e),n.accumulate(c),e.clearViewOffset?.(),c>0&&s(),c+=1,c===i&&(u=bE(t))))},present:()=>i===0||c<i?!1:(r()?.presentAccumulated(),!!r()),isHolding:()=>i>0&&c>=i&&!!r()&&u===bE(t)}}var SE=.02,CE=6,wE=.62,TE=.018,EE=`sun-target`;function DE(e,t){let n=new Dg(t.lighting.ambientLightColor,t.lighting.ambientLightIntensity);e.add(n);let r=null;if(t.lighting.enableHemisphereLight){r=new lg(t.lighting.hemisphereSkyColor,t.lighting.hemisphereGroundColor,t.lighting.hemisphereIntensity);let n=t.environment.sceneUp??pE;r.position.copy(n),e.add(r)}if(!t.lighting.enableSunlight)return{ambient:n,hemisphere:r,sun:null};let i=new Eg(t.lighting.sunlightColor??16777215,t.lighting.sunlightIntensity),a=t.lighting.sunlightPosition;return a&&i.position.set(a.x,a.y,a.z),t.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=t.render.shadowMapSize,i.shadow.mapSize.height=t.render.shadowMapSize,i.shadow.bias=-1e-4,i.shadow.normalBias=SE,i.shadow.radius=CE,i.shadow.blurSamples=12,i.shadow.intensity=wE,e.add(i),i.target.userData.id=EE,e.add(i.target),{ambient:n,hemisphere:r,sun:i}):(e.add(i),{ambient:n,hemisphere:r,sun:null})}function OE(e,t){let n=e.position.clone(),r=n.clone().sub(e.target.position),i=new $(0,0,1).cross(r);i.lengthSq()===0&&i.set(1,0,0),i.setLength(r.length()*TE);let a=r.clone().cross(i).setLength(i.length()),o=yE(t,2)*Math.PI*2,s=Math.sqrt(yE(t,3));return e.position.addScaledVector(i,Math.cos(o)*s).addScaledVector(a,Math.sin(o)*s),()=>e.position.copy(n)}function kE(e,t){if(t.isEmpty())return;let n=t.getCenter(new $),r=t.getSize(new $).length()*.5*1.2;if(r===0)return;e.shadow.normalBias=Math.min(SE,r*.0015);let i=e.shadow.camera;i.left=-r,i.right=r,i.top=r,i.bottom=-r;let a=e.position.clone().sub(e.target.position).normalize();e.target.position.copy(n),e.target.updateMatrixWorld();let o=r*2;e.position.copy(n).addScaledVector(a,o),e.updateMatrixWorld(),i.near=o-r,i.far=o+r,i.updateProjectionMatrix()}var AE={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function jE(e,t,n,r,i){if(RE(e,IE(t)),t.length===0)return;t.forEach(t=>{e.add(t),sE(t,e)});let a=Fb(t),o=a.getCenter(new $),s=a.getSize(new $),c=Math.max(s.x,s.y,s.z);if(c/Math.min(s.x||1,s.y||1,s.z||1)>AE.SCALE_RATIO_THRESHOLD||c>AE.HUGE_THRESHOLD?(n.near=c*AE.NEAR_PLANE_FACTOR.TINY,n.far=c*AE.FAR_PLANE_FACTOR.HUGE):c>AE.LARGE_THRESHOLD?(n.near=c*AE.NEAR_PLANE_FACTOR.SMALL,n.far=c*AE.FAR_PLANE_FACTOR.LARGE):(n.near=Math.max(.01,c*AE.NEAR_PLANE_FACTOR.NORMAL),n.far=Math.max(2e3,c*AE.FAR_PLANE_FACTOR.NORMAL)),n.updateProjectionMatrix(),!i){let e=c*AE.INITIAL_DISTANCE_MULTIPLIER;n.position.copy(o).add(lE(n.up,e)),r.target.copy(o),r.update()}}var ME=new Set([`grid`,`floor`,`label-layer`,`measure`,EE]);function NE(e){return typeof e.userData.id==`string`&&ME.has(e.userData.id)}function PE(e){let t=e;for(;t;){if(NE(t))return!0;t=t.parent}return!1}function FE(e){e.updateMatrixWorld(!0);let t=new ep;return e.traverse(e=>{let n=e;e.visible&&!PE(e)&&n.geometry&&t.expandByObject(e)}),t}function IE(e){let t=new Set;for(let n of e)n.traverse(e=>{let n=e.geometry,r=n&&fl(n);r&&t.add(r)});return t}var LE=new Set([`floor`,`grid`,`label-layer`,EE]);function RE(e,t=new Set){let n=[],r=[];for(let t of e.children)t.isLight===!0||LE.has(t.userData.id)||BT(t)?n.push(t):r.push(t);e.children.length=0;for(let t of n)e.children.push(t);for(let n of r)Gb(n,{keepUploaded:t}),n.parent=null,n.dispatchEvent({type:`removed`}),e.dispatchEvent({type:`childremoved`,child:n})}function zE(e){let{up:t,forward:n,right:r}=cE(e),i=n.clone().negate(),a=r.clone();return{top:t.clone(),bottom:t.clone().negate(),front:i.clone(),back:i.clone().negate(),right:a.clone(),left:a.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(a.clone()).add(t.clone()).normalize()}}function BE(e){let{scene:t,perspective:n,controls:r,onActiveCameraChange:i}=e,a=(e.up??n.up).clone().normalize(),o=zE(a),s=new wg(-1,1,1,-1,n.near,n.far);s.up.copy(a);let c=`perspective`,l=n.aspect,u=()=>c===`perspective`?n:s,d=null,f=()=>{d?.cancel(),d=null},p=()=>{let e=(c===`orthographic`?s:n).position.distanceTo(r.target)*Math.tan(n.fov*Math.PI/360),t=e*l;s.left=-t,s.right=t,s.top=e,s.bottom=-e,s.near=n.near,s.far=n.far,s.updateProjectionMatrix()},m=e=>{if(e!==c){if(f(),e===`orthographic`)s.position.copy(n.position),s.up.copy(n.up),s.lookAt(r.target),s.zoom=1,p();else{let e=(s.top-s.bottom)/(2*s.zoom)/Math.tan(n.fov*Math.PI/360),t=s.position.clone().sub(r.target);t.lengthSq()<1e-12&&t.copy(a),t.normalize(),n.position.copy(r.target).add(t.multiplyScalar(e))}c=e,r.object=u(),r.update(),i(u())}},h=(e,t,i,o)=>{let l=n.fov*(Math.PI/180),m=t/(2*Math.tan(l/2))*1.5,h=VE(i,a),g=e.clone().add(h.clone().multiplyScalar(m)),_=u();c===`orthographic`&&(s.zoom=1),f(),o?d=UE(_,r,g,e,()=>{c===`orthographic`&&p()}):(_.position.copy(g),r.target.copy(e),c===`orthographic`&&p(),r.update())},g=(e,n=!0)=>{let i=FE(t),a=i.isEmpty()?r.target.clone():i.getCenter(new $),o=i.isEmpty()?new $(1,1,1):i.getSize(new $),s=Math.max(o.x,o.y,o.z)||1;h(a,s,e,n)};return{getActiveCamera:u,getProjection:()=>c,setProjection:m,toggleProjection:()=>(m(c===`perspective`?`orthographic`:`perspective`),c),setView:(e,t=!0)=>{g(o[e],t)},setViewDirection:g,frameBounds:(e,t=!0)=>{if(e.isEmpty())return;let n=e.getCenter(new $),i=e.getSize(new $),a=Math.max(i.x,i.y,i.z)||1,s=u().position.clone().sub(r.target);s.lengthSq()<1e-12&&s.copy(o.iso),h(n,a,s.normalize(),t)},setRotateEnabled:e=>{r.enableRotate=e},isRotateEnabled:()=>r.enableRotate,updateAspect:(e,t)=>{l=t===0?l:e/t,c===`orthographic`&&p()},dispose:f}}function VE(e,t){let{up:n,forward:r}=cE(t),i=e.clone().normalize();if(Math.abs(i.dot(n))<.9999)return e;let a=r.clone().negate(),o=.5*Math.PI/180;return i.multiplyScalar(Math.cos(o)).add(a.multiplyScalar(Math.sin(o))).normalize()}var HE=e=>1-(1-e)**3;function UE(e,t,n,r,i,a=250){let o=e.position.clone(),s=t.target.clone(),c=performance.now(),l=null,u=()=>{l=null;let d=HE(Math.min((performance.now()-c)/a,1));e.position.lerpVectors(o,n,d),t.target.lerpVectors(s,r,d),i(),t.update(),d<1&&(l=requestAnimationFrame(u))};return l=requestAnimationFrame(u),{cancel:()=>{l!==null&&(cancelAnimationFrame(l),l=null)}}}var WE=.15,GE=4096;function KE(e){let t=Math.floor(e.length/6);if(t===0)return 1/0;let n=Math.max(1,Math.ceil(t/GE)),r=[];for(let i=0;i<t;i+=n){let t=i*6,n=Math.hypot(e[t+3]-e[t],e[t+4]-e[t+1],e[t+5]-e[t+2]);n>0&&r.push(n)}return r.length===0?1/0:(r.sort((e,t)=>e-t),r[Math.min(r.length-1,Math.floor(r.length*WE))])}function qE(e){let t=new dx;return t.setPositions(e),{geometry:t,segmentCount:e.length/6,edgeSpacing:KE(e)}}function JE(e,t,n){let r=1e4,i=Math.cos(Math.PI/180*n),a=e.length/3;if(a>=67108864)throw Error(`extractEdgeSegments: ${a} vertices exceeds 2^26 limit`);let o=new Float64Array(a),s=new Float64Array(a),c=new Float64Array(a);for(let t=0;t<a;t++)o[t]=Math.round(e[3*t]*r),s[t]=Math.round(e[3*t+1]*r),c[t]=Math.round(e[3*t+2]*r);let l=16;for(;l<a*2;)l<<=1;let u=l-1,d=new Int32Array(l).fill(-1),f=new Int32Array(a);for(let e=0;e<a;e++){let t=(Math.imul(o[e]|0,73856093)^Math.imul(s[e]|0,19349663)^Math.imul(c[e]|0,83492791))&u;for(;;){let n=d[t];if(n===-1){d[t]=e,f[e]=e;break}if(o[n]===o[e]&&s[n]===s[e]&&c[n]===c[e]){f[e]=n;break}t=t+1&u}}let p=new Float32Array(6144),m=0,h=new Uint32Array(1024),g=(t,n,r)=>{if(m+6>p.length){let e=new Float32Array(p.length*2);e.set(p),p=e;let t=new Uint32Array(p.length/6);t.set(h),h=t}h[m/6]=r,p[m++]=e[3*t],p[m++]=e[3*t+1],p[m++]=e[3*t+2],p[m++]=e[3*n],p[m++]=e[3*n+1],p[m++]=e[3*n+2]},_=(t?t.length:a)/3,v=new Int32Array(a+1);for(let e=0;e<_;e++){let n=f[t?t[3*e]:3*e],r=f[t?t[3*e+1]:3*e+1],i=f[t?t[3*e+2]:3*e+2];n!==r&&r!==i&&i!==n&&(v[n+1]++,v[r+1]++,v[i+1]++)}for(let e=0;e<a;e++)v[e+1]+=v[e];let y=new Int32Array(v[a]);{let e=v.slice(0,a);for(let n=0;n<_;n++){let r=f[t?t[3*n]:3*n],i=f[t?t[3*n+1]:3*n+1],a=f[t?t[3*n+2]:3*n+2];r!==i&&i!==a&&a!==r&&(y[e[r]++]=i,y[e[i]++]=a,y[e[a]++]=r)}}let b=new Int32Array(y.length).fill(-2),x=(e,t)=>{for(let n=v[e],r=v[e+1];n<r;n++)if(y[n]===t)return n;return-1},S=(e,n)=>t?t[3*e+n]:3*e+n,C=new Float64Array(3),w=t=>{let n=S(t,0),r=S(t,1),i=S(t,2),a=e[3*i]-e[3*r],o=e[3*i+1]-e[3*r+1],s=e[3*i+2]-e[3*r+2],c=e[3*n]-e[3*r],l=e[3*n+1]-e[3*r+1],u=e[3*n+2]-e[3*r+2],d=o*u-s*l,f=s*c-a*u,p=a*l-o*c,m=d*d+f*f+p*p;if(m>0){let e=1/Math.sqrt(m);d*=e,f*=e,p*=e}else d=0,f=0,p=0;C[0]=d,C[1]=f,C[2]=p},T=0,E=new Uint32Array(Math.max(16,y.length>>1)),D=new Int32Array(E.length),O=()=>{let e=new Uint32Array(E.length*2);e.set(E),E=e;let t=new Int32Array(e.length);t.set(D),D=t};for(let e=0;e<_;e++){let t=S(e,0),n=S(e,1),r=S(e,2),a=f[t],o=f[n],s=f[r];if(a===o||o===s||s===a)continue;let c=!1,l=0,u=0,d=0;for(let f=0;f<3;f++){let p=f===0?a:f===1?o:s,m=f===0?o:f===1?s:a,h=x(m,p),_=h===-1?-2:b[h];if(_>=0)c||=(w(e),l=C[0],u=C[1],d=C[2],!0),w(Math.floor(E[_]/3)),l*C[0]+u*C[1]+d*C[2]<=i&&g(f===0?t:f===1?n:r,f===0?n:f===1?r:t,e),b[h]=-1;else{let t=x(p,m);if(b[t]===-2){T===E.length&&O();let n=T++;b[t]=n,E[n]=3*e+f,D[n]=t}}}}for(let e=0;e<T;e++){if(b[D[e]]!==e)continue;let t=E[e],n=Math.floor(t/3),r=t-3*n;g(S(n,r),S(n,r===2?0:r+1),n)}return{segments:p.slice(0,m),faces:h.slice(0,m/6)}}function YE(){return[`const extract = ${JE.toString()};`,`self.onmessage = (event) => {`,` const { id, positions, index, thresholdAngle } = event.data;`,` try {`,` const { segments, faces } = extract(positions, index, thresholdAngle);`,` self.postMessage({ id, segments, faces }, [segments.buffer, faces.buffer]);`,` } catch (error) {`,` self.postMessage({ id, error: String((error && error.message) || error) });`,` }`,`};`].join(`
|
|
5620
|
-
`)}var
|
|
5619
|
+
`;else if((u=l.match(i))&&(c.gamma=parseFloat(u[1])),(u=l.match(a))&&(c.exposure=parseFloat(u[1])),(u=l.match(o))&&(c.valid|=2,c.format=u[1]),(u=l.match(s))&&(c.valid|=4,c.height=parseInt(u[1],10),c.width=parseInt(u[2],10)),c.valid&2&&c.valid&4)break;return c.valid&2||t(3,`missing format specifier`),c.valid&4||t(3,`missing image size specifier`),c},i=function(e,n,r){let i=n;if(i<8||i>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,`wrong scanline width`);let a=new Uint8Array(4*n*r);a.length||t(4,`unable to allocate buffer space`);let o=0,s=0,c=4*i,l=new Uint8Array(4),u=new Uint8Array(c),d=r;for(;d>0&&s<e.byteLength;){s+4>e.byteLength&&t(1),l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++],(l[0]!=2||l[1]!=2||(l[2]<<8|l[3])!=i)&&t(3,`bad rgbe scanline format`);let n=0,r;for(;n<c&&s<e.byteLength;){r=e[s++];let i=r>128;if(i&&(r-=128),(r===0||n+r>c)&&t(3,`bad scanline data`),i){let t=e[s++];for(let e=0;e<r;e++)u[n++]=t}else u.set(e.subarray(s,s+r),n),n+=r,s+=r}let f=i;for(let e=0;e<f;e++){let t=0;a[o]=u[e+t],t+=i,a[o+1]=u[e+t],t+=i,a[o+2]=u[e+t],t+=i,a[o+3]=u[e+t],o+=4}d--}return a},a=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=e[t+0]*i,n[r+1]=e[t+1]*i,n[r+2]=e[t+2]*i,n[r+3]=1},o=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=yp.toHalfFloat(Math.min(e[t+0]*i,65504)),n[r+1]=yp.toHalfFloat(Math.min(e[t+1]*i,65504)),n[r+2]=yp.toHalfFloat(Math.min(e[t+2]*i,65504)),n[r+3]=yp.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;let c=r(s),l=c.width,u=c.height,d=i(s.subarray(s.pos),l,u),f,p,m;switch(this.type){case Al:m=d.length/4;let e=new Float32Array(m*4);for(let t=0;t<m;t++)a(d,t*4,e,t*4);f=e,p=Al;break;case jl:m=d.length/4;let t=new Uint16Array(m*4);for(let e=0;e<m;e++)o(d,e*4,t,e*4);f=t,p=jl;break;default:throw Error(`THREE.HDRLoader: Unsupported type: `+this.type)}return{width:l,height:u,data:f,header:c.string,gamma:c.gamma,exposure:c.exposure,type:p,colorSpace:Ru,minFilter:xl,magFilter:xl,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}},FT=[`technical`,`studio`,`showcase`,`arctic`,`xray`,`lineart`,`wireframe`,`night`],IT=`user`,LT=`app:`;function RT(e){return`${LT}${e}`}function zT(e){return typeof e!=`string`||!e.startsWith(LT)?null:e.slice(4)||null}function BT(e){let t=e.userData?.source;return t===`user`||zT(t)!==null}function VT(e,t){return t===void 0?BT(e):e.userData?.source===RT(t)}var HT=2.5,UT=11,WT=4.5,GT=3.5,KT=.05,qT=.06,JT=.65,YT=.8,XT=10;function ZT(e,t,n,r){let i=new Om(new ph(t,n),new gm({color:new Lf().setScalar(e),side:2}));return i.position.set(...r),i.lookAt(0,0,0),i}function QT(){let e=new zf,t=new Om($T(),new gm({vertexColors:!0,side:1})),n=new Om(new ph(XT,XT),new gm({color:new Lf().setScalar(KT)}));return n.rotation.x=-Math.PI/2,n.position.y=-4,e.add(t,n,ZT(HT,6.5,4.5,[0,4.8,.6]),ZT(UT,1.4,5.5,[-4.7,.8,1.6]),ZT(WT,.9,5,[4.7,.5,2.4]),ZT(GT,5,.8,[.6,2.2,-4.7])),e}function $T(){let e=new oh(XT,XT,XT,1,16,1),t=e.attributes.position,n=new Float32Array(t.count*3);for(let e=0;e<t.count;e++){let r=t.getY(e)/(XT/2),i=r<0?Ad.lerp(JT,qT,-r):Ad.lerp(JT,YT,r);n.fill(i,e*3,e*3+3)}return e.setAttribute(`color`,new Cp(n,3)),e}function eE(e){e.traverse(e=>{let t=e;t.geometry?.dispose(),t.material?.dispose()})}var tE=.5,nE=.03,rE=`selvaReflectionEnvironment`;function iE(e,t,n){let r=new M_(t),i=QT(),a=r.fromScene(i,nE).texture;eE(i),r.dispose(),aE(e,a,n)}function aE(e,t,n){let r={texture:t,rotation:n.clone()};e.userData[rE]=r,sE(e,e)}function oE(e){e.userData[rE]?.texture.dispose(),delete e.userData[rE]}function sE(e,t){let n=t.userData[rE];n&&e.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,r=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of r){if(!(e instanceof Eh)||e.envMap&&e.envMap!==n.texture)continue;let t=e.metalness>tE?n.texture:null;e.envMap!==t&&(e.envMap=t,e.envMapRotation.copy(n.rotation),e.needsUpdate=!0)}})}function cE(e){let t=e.clone().normalize(),n=new $(0,0,1),r=new $(0,1,0),i=Math.abs(t.dot(n))>.9?r:n,a=new $().crossVectors(i,t).normalize();return{up:t,forward:new $().crossVectors(t,a).normalize(),right:a}}function lE(e,t){let{forward:n,right:r,up:i}=cE(e);return n.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(t)}function uE(e,t,n){let{forward:r,right:i,up:a}=cE(e);return i.clone().multiplyScalar(t).add(r.clone().multiplyScalar(t)).add(a.clone().multiplyScalar(n))}function dE(e){let t=e.clone().normalize(),n=new $(0,1,0);if(t.dot(n)>.9999)return new ff;if(t.dot(n)<-.9999)return new ff(Math.PI,0,0);let r=new jd().setFromUnitVectors(n,t);return new ff().setFromQuaternion(r)}function fE(e){let t=Math.abs(e.x),n=Math.abs(e.y),r=Math.abs(e.z);return t>=n&&t>=r?`x`:n>=r?`y`:`z`}var pE=new $(0,0,1);function mE(){return(window.matchMedia?.(`(pointer: coarse)`).matches??!1)&&Math.min(window.screen.width,window.screen.height)<600}function hE(e){let t=e.sceneScale||`m`,n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[t],r=e.look??`technical`,i=e.render?.lowPower??mE(),a=Db(r,i);return{sceneScale:t,look:r,camera:{position:e.camera?.position||lE(e.environment?.sceneUp??pE,n.cameraDistance*Math.sqrt(3)),fov:e.camera?.fov||20,near:e.camera?.near||n.near,far:e.camera?.far||n.far,target:e.camera?.target||new $(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??a.sunlightIntensity,sunlightPosition:e.lighting?.sunlightPosition||uE(e.environment?.sceneUp??pE,n.lightDistance,n.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new Lf(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??a.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??a.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??a.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath===!1?!1:e.environment?.hdrPath||`/baseHDR.hdr`,backgroundColor:e.environment?.backgroundColor||new Lf(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||pE,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??a.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||n.floorSize,color:e.floor?.color||new Lf(8421504),roughness:e.floor?.roughness??.7,metalness:e.floor?.metalness??0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||1024,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping??a.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??a.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,lowPower:i,idleRefineFrames:e.render?.idleRefineFrames??(i?0:32),lightOrbitFrameMs:e.render?.lightOrbitFrameMs??22,ambientOcclusion:e.render?.ambientOcclusion??a.ambientOcclusion,aoIntensity:e.render?.aoIntensity??1,bloom:e.render?.bloom??a.bloom,aoPixelRatio:e.render?.aoPixelRatio??1,onDemand:e.render?.onDemand??!0},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||n.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??!1,cellSize:e.grid?.cellSize??1,majorEvery:e.grid?.majorEvery??10,cellColor:e.grid?.cellColor??8947848,majorColor:e.grid?.majorColor??4473924,fadeDistance:e.grid?.fadeDistance??100,plane:e.grid?.plane??fE(e.environment?.sceneUp??pE)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color,darken:e.edges?.darken,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??44,distanceFade:e.edges?.distanceFade??!0,maxTriangles:e.edges?.maxTriangles,maxSegments:e.edges?.maxSegments,maxOverlays:e.edges?.maxOverlays,screenSpaceFallback:e.edges?.screenSpaceFallback},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,displayUnit:e.measure?.displayUnit,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||`#ff0000`,enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame},onMaxAnisotropy:e.onMaxAnisotropy}}var gE=150,_E=8,vE=12;function yE(e,t){let n=0,r=1/t;for(let i=e;i>0;i=Math.floor(i/t))n+=i%t*r,r/=t;return n}function bE(e){let t=0;return e.traverseVisible(e=>{t+=1;let{material:n}=e;for(let e of Array.isArray(n)?n:n?[n]:[])t+=e.version*31}),t}function xE(e){let{scene:t,renderer:n,getPipeline:r,frames:i,lightOrbitFrameMs:a,jitterLights:o,restoreLights:s}=e,c=0,l=0,u=0,d=new Q,f=i>0&&a<=0,p=1,m=[],h=e=>{p=Math.min(1,Math.max(0,e)),r()?.setAoWeight(p)},g=e=>{m.push(e),!(m.length<vE)&&(m.sort((e,t)=>e-t),f=m[6]>a,m.length=0)},_=(e,t)=>{let r=e;if(!r.setViewOffset)return;n.getDrawingBufferSize(d);let i=t?yE(t,2)-.5:0,a=t?yE(t,3)-.5:0;r.setViewOffset(d.x,d.y,i,a,d.x,d.y)};return{reset:e=>{c=0,l=e},moving:e=>{i!==0&&(f?h(p-1/_E):g(e))},wants:e=>(c<i||p<1)&&e-l>=gE&&!!r(),step:e=>{let n=r();n&&(p<1?(h(p+1/_E),n.setCamera(e),n.accumulate(0)):(c>0&&o(c),_(e,c),n.setCamera(e),n.accumulate(c),e.clearViewOffset?.(),c>0&&s(),c+=1,c===i&&(u=bE(t))))},present:()=>i===0||c<i?!1:(r()?.presentAccumulated(),!!r()),isHolding:()=>i>0&&c>=i&&!!r()&&u===bE(t)}}var SE=.02,CE=6,wE=.62,TE=.018,EE=`sun-target`;function DE(e,t){let n=new Dg(t.lighting.ambientLightColor,t.lighting.ambientLightIntensity);e.add(n);let r=null;if(t.lighting.enableHemisphereLight){r=new lg(t.lighting.hemisphereSkyColor,t.lighting.hemisphereGroundColor,t.lighting.hemisphereIntensity);let n=t.environment.sceneUp??pE;r.position.copy(n),e.add(r)}if(!t.lighting.enableSunlight)return{ambient:n,hemisphere:r,sun:null};let i=new Eg(t.lighting.sunlightColor??16777215,t.lighting.sunlightIntensity),a=t.lighting.sunlightPosition;return a&&i.position.set(a.x,a.y,a.z),t.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=t.render.shadowMapSize,i.shadow.mapSize.height=t.render.shadowMapSize,i.shadow.bias=-1e-4,i.shadow.normalBias=SE,i.shadow.radius=CE,i.shadow.blurSamples=12,i.shadow.intensity=wE,e.add(i),i.target.userData.id=EE,e.add(i.target),{ambient:n,hemisphere:r,sun:i}):(e.add(i),{ambient:n,hemisphere:r,sun:null})}function OE(e,t){let n=e.position.clone(),r=n.clone().sub(e.target.position),i=new $(0,0,1).cross(r);i.lengthSq()===0&&i.set(1,0,0),i.setLength(r.length()*TE);let a=r.clone().cross(i).setLength(i.length()),o=yE(t,2)*Math.PI*2,s=Math.sqrt(yE(t,3));return e.position.addScaledVector(i,Math.cos(o)*s).addScaledVector(a,Math.sin(o)*s),()=>e.position.copy(n)}function kE(e,t){if(t.isEmpty())return;let n=t.getCenter(new $),r=t.getSize(new $).length()*.5*1.2;if(r===0)return;e.shadow.normalBias=Math.min(SE,r*.0015);let i=e.shadow.camera;i.left=-r,i.right=r,i.top=r,i.bottom=-r;let a=e.position.clone().sub(e.target.position).normalize();e.target.position.copy(n),e.target.updateMatrixWorld();let o=r*2;e.position.copy(n).addScaledVector(a,o),e.updateMatrixWorld(),i.near=o-r,i.far=o+r,i.updateProjectionMatrix()}var AE={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function jE(e,t,n,r,i){if(RE(e,IE(t)),t.length===0)return;t.forEach(t=>{e.add(t),sE(t,e)});let a=Fb(t),o=a.getCenter(new $),s=a.getSize(new $),c=Math.max(s.x,s.y,s.z);if(c/Math.min(s.x||1,s.y||1,s.z||1)>AE.SCALE_RATIO_THRESHOLD||c>AE.HUGE_THRESHOLD?(n.near=c*AE.NEAR_PLANE_FACTOR.TINY,n.far=c*AE.FAR_PLANE_FACTOR.HUGE):c>AE.LARGE_THRESHOLD?(n.near=c*AE.NEAR_PLANE_FACTOR.SMALL,n.far=c*AE.FAR_PLANE_FACTOR.LARGE):(n.near=Math.max(.01,c*AE.NEAR_PLANE_FACTOR.NORMAL),n.far=Math.max(2e3,c*AE.FAR_PLANE_FACTOR.NORMAL)),n.updateProjectionMatrix(),!i){let e=c*AE.INITIAL_DISTANCE_MULTIPLIER;n.position.copy(o).add(lE(n.up,e)),r.target.copy(o),r.update()}}var ME=new Set([`grid`,`floor`,`label-layer`,`measure`,EE]);function NE(e){return typeof e.userData.id==`string`&&ME.has(e.userData.id)}function PE(e){let t=e;for(;t;){if(NE(t))return!0;t=t.parent}return!1}function FE(e){e.updateMatrixWorld(!0);let t=new ep;return e.traverse(e=>{let n=e;e.visible&&!PE(e)&&n.geometry&&t.expandByObject(e)}),t}function IE(e){let t=new Set;for(let n of e)n.traverse(e=>{let n=e.geometry,r=n&&fl(n);r&&t.add(r)});return t}var LE=new Set([`floor`,`grid`,`label-layer`,EE]);function RE(e,t=new Set){let n=[],r=[];for(let t of e.children)t.isLight===!0||LE.has(t.userData.id)||BT(t)?n.push(t):r.push(t);e.children.length=0;for(let t of n)e.children.push(t);for(let n of r)Gb(n,{keepUploaded:t}),n.parent=null,n.dispatchEvent({type:`removed`}),e.dispatchEvent({type:`childremoved`,child:n})}function zE(e){let{up:t,forward:n,right:r}=cE(e),i=n.clone().negate(),a=r.clone();return{top:t.clone(),bottom:t.clone().negate(),front:i.clone(),back:i.clone().negate(),right:a.clone(),left:a.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(a.clone()).add(t.clone()).normalize()}}function BE(e){let{scene:t,perspective:n,controls:r,onActiveCameraChange:i}=e,a=(e.up??n.up).clone().normalize(),o=zE(a),s=new wg(-1,1,1,-1,n.near,n.far);s.up.copy(a);let c=`perspective`,l=n.aspect,u=()=>c===`perspective`?n:s,d=null,f=()=>{d?.cancel(),d=null},p=()=>{let e=(c===`orthographic`?s:n).position.distanceTo(r.target)*Math.tan(n.fov*Math.PI/360),t=e*l;s.left=-t,s.right=t,s.top=e,s.bottom=-e,s.near=n.near,s.far=n.far,s.updateProjectionMatrix()},m=e=>{if(e!==c){if(f(),e===`orthographic`)s.position.copy(n.position),s.up.copy(n.up),s.lookAt(r.target),s.zoom=1,p();else{let e=(s.top-s.bottom)/(2*s.zoom)/Math.tan(n.fov*Math.PI/360),t=s.position.clone().sub(r.target);t.lengthSq()<1e-12&&t.copy(a),t.normalize(),n.position.copy(r.target).add(t.multiplyScalar(e))}c=e,r.object=u(),r.update(),i(u())}},h=(e,t,i,o)=>{let l=n.fov*(Math.PI/180),m=t/(2*Math.tan(l/2))*1.5,h=UE(i,a),g=e.clone().add(h.clone().multiplyScalar(m)),_=u();c===`orthographic`&&(s.zoom=1),f(),o?d=GE(_,r,g,e,()=>{c===`orthographic`&&p()}):(_.position.copy(g),r.target.copy(e),c===`orthographic`&&p(),r.update())},g=(e,n=!0)=>{let i=FE(t),a=i.isEmpty()?r.target.clone():i.getCenter(new $),o=i.isEmpty()?new $(1,1,1):i.getSize(new $),s=Math.max(o.x,o.y,o.z)||1;h(a,s,e,n)},_=(e,t=!0)=>{if(e.isEmpty())return;let n=e.getCenter(new $),i=e.getSize(new $),a=Math.max(i.x,i.y,i.z)||1,s=u().position.clone().sub(r.target);s.lengthSq()<1e-12&&s.copy(o.iso),h(n,a,s.normalize(),t)},v=(e,t=!0)=>{g(o[e],t)};return{getActiveCamera:u,getProjection:()=>c,setProjection:m,toggleProjection:()=>(m(c===`perspective`?`orthographic`:`perspective`),c),setView:v,setViewDirection:g,getCameraView:()=>{let e=r.target,t=u().position.clone().sub(e);return t.lengthSq()<1e-12&&t.copy(o.iso),c===`orthographic`&&t.divideScalar(s.zoom),{direction:VE(t.clone().normalize()),position:VE(e.clone().add(t)),target:VE(e)}},setCameraView:(e,t=!1)=>{let n=HE(e.position),i=HE(e.target);if(n&&i&&n.distanceToSquared(i)>1e-12){f();let e=u();if(c===`orthographic`&&(s.zoom=1),t){d=GE(e,r,n,i,()=>{c===`orthographic`&&p()});return}e.position.copy(n),r.target.copy(i),c===`orthographic`&&p(),r.update();return}let a=HE(e.direction);a&&a.lengthSq()>1e-12?g(a.normalize(),t):v(`iso`,t)},frameBounds:_,setRotateEnabled:e=>{r.enableRotate=e},isRotateEnabled:()=>r.enableRotate,updateAspect:(e,t)=>{l=t===0?l:e/t,c===`orthographic`&&p()},dispose:f}}var VE=e=>[e.x,e.y,e.z].map(e=>Math.round(e*1e6)/1e6),HE=e=>e?.length===3&&e.every(Number.isFinite)?new $(e[0],e[1],e[2]):void 0;function UE(e,t){let{up:n,forward:r}=cE(t),i=e.clone().normalize();if(Math.abs(i.dot(n))<.9999)return e;let a=r.clone().negate(),o=.5*Math.PI/180;return i.multiplyScalar(Math.cos(o)).add(a.multiplyScalar(Math.sin(o))).normalize()}var WE=e=>1-(1-e)**3;function GE(e,t,n,r,i,a=250){let o=e.position.clone(),s=t.target.clone(),c=performance.now(),l=null,u=()=>{l=null;let d=WE(Math.min((performance.now()-c)/a,1));e.position.lerpVectors(o,n,d),t.target.lerpVectors(s,r,d),i(),t.update(),d<1&&(l=requestAnimationFrame(u))};return l=requestAnimationFrame(u),{cancel:()=>{l!==null&&(cancelAnimationFrame(l),l=null)}}}var KE=.15,qE=4096;function JE(e){let t=Math.floor(e.length/6);if(t===0)return 1/0;let n=Math.max(1,Math.ceil(t/qE)),r=[];for(let i=0;i<t;i+=n){let t=i*6,n=Math.hypot(e[t+3]-e[t],e[t+4]-e[t+1],e[t+5]-e[t+2]);n>0&&r.push(n)}return r.length===0?1/0:(r.sort((e,t)=>e-t),r[Math.min(r.length-1,Math.floor(r.length*KE))])}function YE(e){let t=new dx;return t.setPositions(e),{geometry:t,segmentCount:e.length/6,edgeSpacing:JE(e)}}function XE(e,t,n){let r=1e4,i=Math.cos(Math.PI/180*n),a=e.length/3;if(a>=67108864)throw Error(`extractEdgeSegments: ${a} vertices exceeds 2^26 limit`);let o=new Float64Array(a),s=new Float64Array(a),c=new Float64Array(a);for(let t=0;t<a;t++)o[t]=Math.round(e[3*t]*r),s[t]=Math.round(e[3*t+1]*r),c[t]=Math.round(e[3*t+2]*r);let l=16;for(;l<a*2;)l<<=1;let u=l-1,d=new Int32Array(l).fill(-1),f=new Int32Array(a);for(let e=0;e<a;e++){let t=(Math.imul(o[e]|0,73856093)^Math.imul(s[e]|0,19349663)^Math.imul(c[e]|0,83492791))&u;for(;;){let n=d[t];if(n===-1){d[t]=e,f[e]=e;break}if(o[n]===o[e]&&s[n]===s[e]&&c[n]===c[e]){f[e]=n;break}t=t+1&u}}let p=new Float32Array(6144),m=0,h=new Uint32Array(1024),g=(t,n,r)=>{if(m+6>p.length){let e=new Float32Array(p.length*2);e.set(p),p=e;let t=new Uint32Array(p.length/6);t.set(h),h=t}h[m/6]=r,p[m++]=e[3*t],p[m++]=e[3*t+1],p[m++]=e[3*t+2],p[m++]=e[3*n],p[m++]=e[3*n+1],p[m++]=e[3*n+2]},_=(t?t.length:a)/3,v=new Int32Array(a+1);for(let e=0;e<_;e++){let n=f[t?t[3*e]:3*e],r=f[t?t[3*e+1]:3*e+1],i=f[t?t[3*e+2]:3*e+2];n!==r&&r!==i&&i!==n&&(v[n+1]++,v[r+1]++,v[i+1]++)}for(let e=0;e<a;e++)v[e+1]+=v[e];let y=new Int32Array(v[a]);{let e=v.slice(0,a);for(let n=0;n<_;n++){let r=f[t?t[3*n]:3*n],i=f[t?t[3*n+1]:3*n+1],a=f[t?t[3*n+2]:3*n+2];r!==i&&i!==a&&a!==r&&(y[e[r]++]=i,y[e[i]++]=a,y[e[a]++]=r)}}let b=new Int32Array(y.length).fill(-2),x=(e,t)=>{for(let n=v[e],r=v[e+1];n<r;n++)if(y[n]===t)return n;return-1},S=(e,n)=>t?t[3*e+n]:3*e+n,C=new Float64Array(3),w=t=>{let n=S(t,0),r=S(t,1),i=S(t,2),a=e[3*i]-e[3*r],o=e[3*i+1]-e[3*r+1],s=e[3*i+2]-e[3*r+2],c=e[3*n]-e[3*r],l=e[3*n+1]-e[3*r+1],u=e[3*n+2]-e[3*r+2],d=o*u-s*l,f=s*c-a*u,p=a*l-o*c,m=d*d+f*f+p*p;if(m>0){let e=1/Math.sqrt(m);d*=e,f*=e,p*=e}else d=0,f=0,p=0;C[0]=d,C[1]=f,C[2]=p},T=0,E=new Uint32Array(Math.max(16,y.length>>1)),D=new Int32Array(E.length),O=()=>{let e=new Uint32Array(E.length*2);e.set(E),E=e;let t=new Int32Array(e.length);t.set(D),D=t};for(let e=0;e<_;e++){let t=S(e,0),n=S(e,1),r=S(e,2),a=f[t],o=f[n],s=f[r];if(a===o||o===s||s===a)continue;let c=!1,l=0,u=0,d=0;for(let f=0;f<3;f++){let p=f===0?a:f===1?o:s,m=f===0?o:f===1?s:a,h=x(m,p),_=h===-1?-2:b[h];if(_>=0)c||=(w(e),l=C[0],u=C[1],d=C[2],!0),w(Math.floor(E[_]/3)),l*C[0]+u*C[1]+d*C[2]<=i&&g(f===0?t:f===1?n:r,f===0?n:f===1?r:t,e),b[h]=-1;else{let t=x(p,m);if(b[t]===-2){T===E.length&&O();let n=T++;b[t]=n,E[n]=3*e+f,D[n]=t}}}}for(let e=0;e<T;e++){if(b[D[e]]!==e)continue;let t=E[e],n=Math.floor(t/3),r=t-3*n;g(S(n,r),S(n,r===2?0:r+1),n)}return{segments:p.slice(0,m),faces:h.slice(0,m/6)}}function ZE(){return[`const extract = ${XE.toString()};`,`self.onmessage = (event) => {`,` const { id, positions, index, thresholdAngle } = event.data;`,` try {`,` const { segments, faces } = extract(positions, index, thresholdAngle);`,` self.postMessage({ id, segments, faces }, [segments.buffer, faces.buffer]);`,` } catch (error) {`,` self.postMessage({ id, error: String((error && error.message) || error) });`,` }`,`};`].join(`
|
|
5620
|
+
`)}var QE=`edge-overlay`,$E=`triangle-cap`,eD=`overlay-budget`,tD=2236962,nD=1.5,rD=44,iD=.75,aD=8e6,oD=2e6,sD=1500;function cD(e){return{forcedColor:e.color==null?null:new Lf(e.color),darken:Ad.clamp(e.darken??iD,0,1),width:e.width??nD,thresholdAngle:e.thresholdAngle??rD,distanceFade:e.distanceFade??!0,maxTriangles:e.maxTriangles??aD,maxSegments:e.maxSegments??oD,maxOverlays:e.maxOverlays??sD}}function lD(e){let t=e.getAttribute(`position`);return t?(e.index?e.index.count:t.count)/3:0}function uD(e){let t=e.getAttribute(`position`);if(!t||t.isInterleavedBufferAttribute||t.itemSize!==3||!(t.array instanceof Float32Array)||t.count>=67108864)return null;let n=e.index;return n&&!(n.array instanceof Uint32Array)&&!(n.array instanceof Uint16Array)?null:{positions:t.array,index:n?n.array:null,version:`${t.version}:${n?.version??0}`}}function dD(e,t){let n=4096,r=2166136261,i=e=>{r^=e,r=Math.imul(r,16777619)},a=new Uint32Array(e.positions.buffer,e.positions.byteOffset,e.positions.length),o=Math.min(n,a.length);for(let e=0;e<o;e++)i(a[e]);for(let e=Math.max(o,a.length-n);e<a.length;e++)i(a[e]);let s=0;if(e.index){s=e.index.length;let t=Math.min(n,s);for(let n=0;n<t;n++)i(e.index[n]);for(let r=Math.max(t,s-n);r<s;r++)i(e.index[r])}return`${t}:${e.positions.length}:${s}:${r>>>0}`}function fD(e,t){let n=new fh(e,t),r=n.attributes.position?n.attributes.position.array:new Float32Array;return n.dispose(),{segments:r,faces:null}}var pD=new WeakMap,mD={};function hD(e,t){let n=pD.get(e.positions)?.get(e.index??mD)?.get(t);return n?.version===e.version?n.edges:void 0}function gD(e,t,n){let r=pD.get(e.positions);r||pD.set(e.positions,r=new WeakMap);let i=r.get(e.index??mD);return i||r.set(e.index??mD,i=new Map),i.set(t,{version:e.version,edges:n}),n}function _D(e,t){let n=uD(e);return n?hD(n,t)??gD(n,t,XE(n.positions,n.index,t)):fD(e,t)}var vD,yD=new Map,bD=1;function xD(){if(vD!==void 0)return vD;if(typeof Worker>`u`||typeof Blob>`u`||typeof URL>`u`||typeof URL.createObjectURL!=`function`)return vD=null,null;try{let e=URL.createObjectURL(new Blob([ZE()],{type:`text/javascript`})),t=new Worker(e);t.onmessage=e=>{let{id:t,segments:n,faces:r,error:i}=e.data,a=yD.get(t);a&&(yD.delete(t),n?a.resolve({segments:n,faces:r??null}):a.reject(Error(i??`edge extraction failed in worker`)))},t.onerror=()=>{for(let e of yD.values())e.reject(Error(`edge extraction worker crashed`));yD.clear(),t.terminate(),vD=null},vD=t}catch{vD=null}return vD}function SD(e,t,n){return new Promise((r,i)=>{let a=bD++;yD.set(a,{resolve:r,reject:i});let o=t.positions.slice(),s=t.index?t.index.slice():null,c=[o.buffer];s&&c.push(s.buffer),e.postMessage({id:a,positions:o,index:s,thresholdAngle:n},c)})}var CD=new Map;function wD(e,t){let n=uD(e);if(!n||lD(e)<25e3)return Promise.resolve(_D(e,t));let r=hD(n,t);if(r)return Promise.resolve(r);let i=dD(n,t),a=CD.get(i);if(a)return a;let o=xD();if(!o)return Promise.resolve(_D(e,t));let s=SD(o,n,t).catch(()=>XE(n.positions,n.index,t)).then(e=>gD(n,t,e)).finally(()=>{CD.delete(i)});return CD.set(i,s),s}function TD(e){let t=e.userData?.members;return Array.isArray(t)&&t.length>0?t:null}function ED(e){let t=TD(e.object);if(!t||e.faceIndex==null)return null;let n=e.faceIndex*3,r=0,i=t.length-1;for(;r<=i;){let e=r+i>>1,a=t[e];if(a.indexStart==null||a.indexCount==null)return null;if(n<a.indexStart)i=e-1;else if(n>=a.indexStart+a.indexCount)r=e+1;else return{member:a,index:e}}return null}function DD(e,t,n){let r=[];return e.traverse(e=>{let i=TD(e);if(i)i.forEach((i,a)=>{i.trackingKey===t&&(i.layer??``)===n&&r.push({object:e,memberIndex:a})});else{let i=e.userData;i?.trackingKey===t&&(i.layer??``)===n&&r.push({object:e,memberIndex:null})}}),r}function OD(e,t){let n=ED(t),r=n?n.member:t.object.userData,i={object:t.object,memberIndex:n?.index??null};if(typeof r?.trackingKey!=`string`||!r.trackingKey)return[i];let a=DD(e,r.trackingKey,r.layer??``);return a.length>1?a:[i]}function kD(e,t){let n=new ep,r=e.geometry.getIndex(),i=e.geometry.getAttribute(`position`);if(!r||!i||t.indexStart==null||t.indexCount==null)return n;e.updateMatrixWorld();let a=new $,o=Math.min(t.indexStart+t.indexCount,r.count);for(let s=t.indexStart;s<o;s++)a.fromBufferAttribute(i,r.getX(s)).applyMatrix4(e.matrixWorld),n.expandByPoint(a);return n}function AD(e,t,n,r){return ox(e,t,n,r),()=>sx(e,r)}function jD(e,t){let n=TD(e);if(!n)return null;let r=[];for(let e of n){if(e.indexStart==null)return null;r.push(e.indexStart)}let i=new Uint32Array(t.length);for(let e=0;e<t.length;e++){let n=t[e]*3,a=0,o=r.length-1;for(;a<o;){let e=a+o+1>>1;r[e]<=n?a=e:o=e-1}i[e]=a}return i}function MD(e,t,n){let r=0;for(let e=0;e<t.length;e++)n.has(t[e])||r++;let i=new Float32Array(r*6),a=0;for(let r=0;r<t.length;r++)n.has(t[r])||(i.set(e.subarray(r*6,r*6+6),a),a+=6);return i}function ND(e,t,n){let{segments:r,faces:i}=n;if(!i||!TD(t))return;let a,o=!1,s=()=>{let n=nx(t);if(n.size===0&&!o||(a??=jD(t,i),!a))return;let s=n.size===0?r:MD(r,a,n);e.geometry.dispose(),e.geometry=YE(s).geometry,o=n.size>0};s();let c=cx(t,s);e.addEventListener(`removed`,c)}function PD(e,t){let n=(Array.isArray(e.material)?e.material[0]:e.material)?.color;return n?n.clone().multiplyScalar(1-t):new Lf(tD)}var FD=class{options;byKey=new Map;constructor(e){this.options=e}for(e,t){let n=this.options.forcedColor??PD(e,this.options.darken),r=n.getHex()*2+ +!!t,i=this.byKey.get(r);return i||(i=ID(n,this.options.width,t),this.byKey.set(r,i)),i}disposeUnused(e){let t=new Set(e.map(e=>e.material));for(let e of this.byKey.values())t.has(e)||e.dispose()}};function ID(e,t,n){let r=new fx({color:e});return r.linewidth=t,r.polygonOffset=!0,r.polygonOffsetFactor=0,r.polygonOffsetUnits=-1,n&&(r.transparent=!0),r}function LD(e,t,n){let r=new jx(e.geometry,t);return r.userData.kind=QE,r.raycast=()=>{},n&&VD(r,e.edgeSpacing),r}var RD=new $,zD=new $;function BD(e,t,n){e.geometry.boundingSphere||e.geometry.computeBoundingSphere();let r=e.geometry.boundingSphere;if(!r)return 1/0;if(t.isPerspectiveCamera){let i=t;RD.copy(r.center).applyMatrix4(e.matrixWorld);let a=zD.setFromMatrixPosition(t.matrixWorld).distanceTo(RD);if(a<=r.radius*e.matrixWorld.getMaxScaleOnAxis())return 1/0;let o=Math.tan(Ad.degToRad(i.fov)*.5),s=2*a*o;return s>0?n/s:1/0}if(t.isOrthographicCamera){let e=t,r=(e.top-e.bottom)/e.zoom;return r>0?n/r:1/0}return 1/0}function VD(e,t){e.onBeforeRender=(n,r,i)=>{jx.prototype.onBeforeRender.call(e,n);let a=e.material,o=t*BD(e,i,a.resolution.y);a.opacity=Ad.clamp((o-1)/3,0,1)}}function HD(e){return e.userData?.kind===QE}function UD(e,t){let n=[],r=0;e.traverse(e=>{e instanceof Om&&e.userData.id!==`floor`&&e.userData.id!==`grid`&&e.userData.kind!==`edge-overlay`&&(e.children.some(e=>e.userData?.kind===`edge-overlay`)?r++:e.geometry&&(lD(e.geometry)>t.maxTriangles?e.userData.edgesSkipped=$E:n.push(e)))});let i=Math.max(0,t.maxOverlays-r),a=n.slice(0,i);for(let e of a)delete e.userData.edgesSkipped;for(let e of n.slice(i))e.userData.edgesSkipped=eD;return n.length>i&&console.debug(`[edges] overlay budget reached: ${n.length} meshes want overlays, ${i} allowed — the rest fall back to the screen-space edge pass.`),a}function WD(e,t,n,r){let i=YE(t.segments),a=r.distanceFade&&i.segmentCount<=r.maxSegments,o=LD(i,n.for(e,a),a);return e.add(o),ND(o,e,t),o}var GD=new WeakMap;function KD(e){return GD.get(e)??0}function qD(e,t){for(let n=e;n;n=n.parent)if(n===t)return!0;return!1}async function JD(e,t={}){let n=cD(t),r=new FD(n),i=KD(e),a=[],o=UD(e,n).map(async t=>{let o=await wD(t.geometry,n.thresholdAngle);KD(e)===i&&qD(t,e)&&(t.children.some(e=>e.userData?.kind===`edge-overlay`)||a.push(WD(t,o,r,n)))});return await Promise.all(o),r.disposeUnused(a),a}function YD(e){GD.set(e,KD(e)+1);let t=[];e.traverse(e=>{e instanceof jx&&HD(e)&&t.push(e)});let n=new Set;for(let e of t)e.geometry.dispose(),n.add(e.material),e.removeFromParent();return n.forEach(e=>e.dispose()),t.length}function XD(e){if(!(e>0)||!Number.isFinite(e))return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n>=5?5:n>=2?2:1)*t}var ZD=`
|
|
5621
5621
|
varying vec3 vWorldPos;
|
|
5622
5622
|
void main() {
|
|
5623
5623
|
vec4 world = modelMatrix * vec4(position, 1.0);
|
|
5624
5624
|
vWorldPos = world.xyz;
|
|
5625
5625
|
gl_Position = projectionMatrix * viewMatrix * world;
|
|
5626
5626
|
}
|
|
5627
|
-
`,
|
|
5627
|
+
`,QD=`
|
|
5628
5628
|
precision highp float;
|
|
5629
5629
|
varying vec3 vWorldPos;
|
|
5630
5630
|
|
|
@@ -5668,7 +5668,7 @@ void main() {
|
|
|
5668
5668
|
if (alpha < 0.001) discard;
|
|
5669
5669
|
gl_FragColor = vec4(color, alpha);
|
|
5670
5670
|
}
|
|
5671
|
-
`;function ZD(e={}){let{cellSize:t=1,majorEvery:n=10,cellColor:r=8947848,majorColor:i=4473924,fadeDistance:a=100,plane:o=`y`}=e,s=o===`y`?new Q(0,2):o===`z`?new Q(0,1):new Q(1,2),c=2.5,l=new ph(1,1);o===`y`?l.rotateX(-Math.PI/2):o===`x`&&l.rotateY(Math.PI/2);let u=new wh({vertexShader:YD,fragmentShader:XD,transparent:!0,depthWrite:!1,side:2,uniforms:{uAxes:{value:s},uCell:{value:t},uMajor:{value:n},uCellColor:{value:new Lf(r)},uMajorColor:{value:new Lf(i)},uCenter:{value:new $},uFade:{value:a}}}),d=new Om(l,u);d.name=`grid`,d.userData.id=`grid`,d.renderOrder=-1;let f=a,p=a*c,m=new $;return{object:d,update:e=>{o===`y`?(d.position.set(e.x,0,e.z),m.set(e.x,0,e.z)):o===`z`?(d.position.set(e.x,e.y,0),m.set(e.x,e.y,0)):(d.position.set(0,e.y,e.z),m.set(0,e.y,e.z)),u.uniforms.uCenter.value.copy(m),d.scale.setScalar(p)},fitToContent:e=>{if(e.isEmpty())return;let t=e.getSize(new $),n=(e,t)=>t===0?e.x:t===1?e.y:e.z,r=Math.max(n(t,s.x),n(t,s.y));r>0&&Number.isFinite(r)&&(u.uniforms.uCell.value=JD(r/20),f=r*2,u.uniforms.uFade.value=f,p=f*c)},setVisible:e=>{d.visible=e},dispose:()=>{d.removeFromParent(),l.dispose(),u.dispose()}}}function QD(e,t){let n=new Bx,r=n.domElement;r.style.position=`absolute`,r.style.top=`0`,r.style.left=`0`,r.style.overflow=`hidden`,r.style.pointerEvents=`none`,r.style.zIndex=`30`,getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.appendChild(r);let i={width:e.clientWidth||1,height:e.clientHeight||1};n.setSize(i.width,i.height);let a=new Af;a.name=`label-layer`,a.userData.id=`label-layer`,t.add(a);let o=new Set;return{addLabel:(e,t,n)=>{let r=document.createElement(`div`);r.textContent=e,n?r.className=n:Object.assign(r.style,{padding:`2px 6px`,borderRadius:`4px`,background:`rgba(20, 20, 20, 0.78)`,color:`#fff`,font:`12px/1.3 system-ui, sans-serif`,whiteSpace:`pre`,textAlign:`center`,userSelect:`none`}),r.style.pointerEvents=`none`;let i=new Px(r);return i.position.copy(t),a.add(i),o.add(i),{object:i,setPosition:e=>i.position.copy(e),setText:e=>{r.textContent=e},remove:()=>{i.removeFromParent(),r.remove(),o.delete(i)}}},render:(e,t)=>n.render(e,t),setSize:(e,t)=>n.setSize(e,t),dispose:()=>{o.forEach(e=>{e.removeFromParent(),e.element.remove()}),o.clear(),a.removeFromParent(),r.remove()}}}var $D=new WeakMap;function eO(e){return e?.version??0}function tO(e){let t=e.attributes.position;if(!t||t.count===0)return null;let n=e.index,r=n??t,i=$D.get(r);if(i===null)return null;if(i&&i.position===t&&i.positionVersion===eO(t)&&i.indexVersion===eO(n))return i.bvh;let a=new Rp;a.setAttribute(`position`,t),n&&a.setIndex(n);try{let e=new Fw(a,{indirect:!0});return $D.set(r,{position:t,positionVersion:eO(t),indexVersion:eO(n),bvh:e}),e}catch{return $D.set(r,null),null}}function nO(e){let t=e;return t.isMesh===!0&&!t.isInstancedMesh&&!t.isSkinnedMesh&&!t.isBatchedMesh&&!t.isLineSegments2&&!e.morphTargetInfluences?.length}function rO(e,t=[]){for(let n of e.children)!n.visible||NE(n)||BD(n)||(t.push(n),rO(n,t));return t}function iO(e){let{groups:t}=e.geometry;if(!Array.isArray(e.material)||t.length===0)return null;let n=e.material;return t.filter(e=>n[e.materialIndex??0]?.visible!==!1).map(e=>({start:e.start,end:e.start+e.count}))}var aO=new tf,oO=new hm,sO=new Ap;function cO(e,t,n){aO.copy(e.matrixWorld).invert(),oO.copy(n.ray).applyMatrix4(aO);let r=iO(e),i=null;if(!r)i=t.raycastFirst(oO,2);else for(let e of t.raycast(oO,2)){let t=(e.faceIndex??0)*3;r.some(e=>t>=e.start&&t<e.end)&&(!i||e.distance<i.distance)&&(i=e)}return!i||(i.point.applyMatrix4(e.matrixWorld),i.distance=i.point.distanceTo(n.ray.origin),i.object=e,i.distance<n.near||i.distance>n.far)?null:i}function lO(e,t){let n=[];for(let r of rO(e))if(r.layers.test(t.layers)){if(nO(r)){let{geometry:e}=r;if(e.boundingSphere||e.computeBoundingSphere(),!e.boundingSphere||(sO.copy(e.boundingSphere).applyMatrix4(r.matrixWorld),!t.ray.intersectsSphere(sO)))continue;let i=tO(e);if(i){let e=cO(r,i,t);e&&n.push(e);continue}}r.raycast(t,n)}return n.sort((e,t)=>e.distance-t.distance)}function uO(e){let t=rO(e).filter(nO),n=typeof requestIdleCallback==`function`?e=>requestIdleCallback(e,{timeout:500}):e=>setTimeout(e,16),r=typeof cancelIdleCallback==`function`?cancelIdleCallback:e=>clearTimeout(e),i=0,a=!1,o=()=>{if(a)return;let e=t.shift();e&&(tO(e.geometry),i=n(o))};return i=n(o),()=>{a=!0,r(i)}}var dO=12,fO=16763904,pO=.015,mO=998,hO=999,gO=1e3,_O={Millimeters:{metersPerUnit:1/1e3,suffix:`mm`},Centimeters:{metersPerUnit:1/100,suffix:`cm`},Meters:{metersPerUnit:1,suffix:`m`},Inches:{metersPerUnit:1/39.37,suffix:`in`},Feet:{metersPerUnit:1/3.28084,suffix:`ft`}};function vO(e){let t=e&&_O[e]||_O.Meters;return e=>{let n=e/t.metersPerUnit,r=Math.abs(n),i=r===0?0:Math.min(6,Math.max(0,2-Math.floor(Math.log10(r))));return`${n.toFixed(i)} ${t.suffix}`}}function yO(e){return(t,n)=>{let r=t*1e-6,i=[`x`,`y`,`z`].filter(e=>n[e]>r);return i.length<2?e(t):`${e(t)}\n${i.map(t=>`Δ${t} ${e(n[t])}`).join(` `)}`}}function bO(e,t){if(e.isOrthographicCamera){let t=e;return Math.abs(t.top-t.bottom)/(t.zoom||1)*pO}return((t?e.position.distanceTo(t):e.position.length())||1)*pO}function xO(e){let t=e.object,n=t.geometry;if(!n)return null;if(t.isLineSegments2){let t=n.attributes.instanceStart,r=n.attributes.instanceEnd,i=e.faceIndex;return!t||!r||i==null||i>=t.count?null:[new $().fromBufferAttribute(t,i),new $().fromBufferAttribute(r,i)]}let r=n.attributes.position;if(!r)return null;let i=e=>e.filter(e=>e<r.count).map(e=>new $().fromBufferAttribute(r,e));if(t instanceof Om)return e.face?i([e.face.a,e.face.b,e.face.c]):null;if(t instanceof $m)return e.index==null?null:i([e.index]);if(t instanceof Km){if(e.index==null)return null;let t=n.index;return t?e.index+1>=t.count?null:i([t.getX(e.index),t.getX(e.index+1)]):i([e.index,e.index+1])}return null}function SO(e,t,n){let r=e.clone().project(t);return new Q((r.x+1)/2*n.width,(1-r.y)/2*n.height)}function CO(e){return e.pointOnLine??e.point}function wO(e,t,n,r){let i=CO(e).clone(),a=xO(e);if(!a)return{point:i,snapped:!1};let o=SO(i,t,n),s={point:i,snapped:!1},c=r;for(let r of a){let i=r.applyMatrix4(e.object.matrixWorld),a=SO(i,t,n).distanceTo(o);a<c&&(c=a,s={point:i,snapped:!0})}return s}function TO(e,t,n,r){return wO(e,t,n,r).point}function EO(e){let{canvas:t,scene:n,getActiveCamera:r,getViewTarget:i,labelLayer:a,options:o={}}=e,s=e.requestRender??(()=>{}),c=o.snapPixels??dO,l=new Lf(o.color??fO),u=o.format??yO(vO(o.displayUnit)),d=new Yg,f=new Q,p=!1,m=null,h=[],g=new Jm({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),_=new Jm({color:l,size:12,sizeAttenuation:!1,depthTest:!1}),v=new Jm({color:l,size:7,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.6}),y=(e,t)=>(e.renderOrder=t,e.userData.id=`measure`,e.raycast=()=>{},e.frustumCulled=!1,e),b=(...e)=>{let t=new Rp;t.setAttribute(`position`,new Ep(e.flatMap(e=>[e.x,e.y,e.z]),3));let r=y(new $m(t,g),hO);return n.add(r),r},x=(e,t,r=1)=>{let i=new Mx;i.setPositions([e.x,e.y,e.z,t.x,t.y,t.z]);let a=new fx({color:l,transparent:r<1,opacity:r});a.linewidth=2,a.depthTest=!1;let o=y(new Nx(i,a),mO);return n.add(o),o},S=(e,t,n)=>{let r=e.geometry.attributes.instanceStart.data;r.array.set([t.x,t.y,t.z,n.x,n.y,n.z]),r.needsUpdate=!0},C=e=>{e.geometry.dispose(),e.material.dispose(),e.removeFromParent()},w=e=>{e.geometry.dispose(),e.removeFromParent()},T=(e,t)=>{let n=new $(Math.abs(t.x-e.x),Math.abs(t.y-e.y),Math.abs(t.z-e.z));return u(e.distanceTo(t),n)},E=(e,t)=>e.clone().add(t).multiplyScalar(.5),D=null,O=null,k=null,A=()=>{D&&(D.visible=!1),O&&(O.visible=!1),k?.remove(),k=null},j=e=>{if(!e){A();return}if(D||(D=b(new $),D.renderOrder=gO),D.material=e.snapped?_:v,D.position.copy(e.point),D.visible=!0,!m){O&&(O.visible=!1),k?.remove(),k=null;return}O||=x(m.point,e.point,.7),S(O,m.point,e.point),O.visible=!0;let t=T(m.point,e.point),n=E(m.point,e.point);k?(k.setText(t),k.setPosition(n)):k=a.addLabel(t,n,o.labelClassName)},M=e=>{let a=t.getBoundingClientRect(),o=e.clientX-a.left,s=e.clientY-a.top;f.x=o/a.width*2-1,f.y=-(s/a.height)*2+1;let l=r();d.setFromCamera(f,l);let u=bO(l,i?.())*2;d.params.Line.threshold=u,d.params.Points.threshold=u,d.params.Line2={threshold:c/2};let p={width:a.width,height:a.height},m=new Q(o,s);for(let e of lO(n,d))if(!(!(e.object.isMesh&&e.face!=null)&&SO(CO(e),l,p).distanceTo(m)>c))return wO(e,l,p,c);return null},N=null,P=0,F=()=>{P&&=(cancelAnimationFrame(P),0),N=null},I=e=>{p&&(N=e,!P&&(P=requestAnimationFrame(()=>{P=0;let e=N;N=null,p&&e&&(j(M(e)),s())})))},ee=()=>{F(),A(),s()},te=()=>{m&&=(w(m.marker),null)},L=()=>{te();for(let e of h)w(e.markers),C(e.line),e.label.remove();h.length=0,A(),s()},R=()=>{m?(te(),A(),s()):L()},z=e=>{if(!p)return!1;F();let t=M(e);if(!t)return!0;if(!m)m={point:t.point,marker:b(t.point)};else if(!t.point.equals(m.point)){let e=m.point,n=t.point;te(),h.push({markers:b(e,n),line:x(e,n),label:a.addLabel(T(e,n),E(e,n),o.labelClassName)})}return j(t),s(),!0},B=e=>{e.key===`Escape`&&(e.target?.closest?.(`input, textarea, select, [contenteditable]`)||R())},ne=``,re=null,ie=e=>{e!==p&&(p=e,e?(ne=t.style.cursor,t.style.cursor=`crosshair`,t.addEventListener(`mouseleave`,ee),window.addEventListener(`keydown`,B),re=uO(n)):(t.style.cursor=ne,t.removeEventListener(`mouseleave`,ee),window.removeEventListener(`keydown`,B),re?.(),re=null,F(),L()))};return{setEnabled:ie,isEnabled:()=>p,handleClick:z,handleMove:I,cancel:R,clear:L,dispose:()=>{ie(!1),L(),D&&w(D),O&&C(O),D=null,O=null,g.dispose(),_.dispose(),v.dispose()}}}var DO=.5,OO=.01,kO=.05,AO=256,jO=[];function MO({camera:e,scene:t,groundNormals:n=()=>jO}){let r=e.near,i=e.near,a=NO();return{update:()=>{e.near!==i&&(r=e.near);let o=a.measure(t,e),s=r;if(o!==null){let t=o;for(let r of n())t=Math.min(t,Math.abs(e.position.dot(r)));s=Ad.clamp(t*DO,r,e.far*OO)}Math.abs(s-i)>i*kO&&(e.near=s,e.updateProjectionMatrix(),i=s)}}}function NO(){let e=new WeakMap,t=new Fm,n=new tf,r=new $,i=new ep,a=new Float64Array(20),o=new Float64Array(20),s=new Float32Array(6),c=new Float64Array(21),l=new Float64Array(21),u=1/0,d=!1,f=(t,n)=>{let r=n.getAttribute(`position`),i=n.getIndex(),a=e.get(n);if(a&&a.position===r&&a.positionVersion===FO(r)&&a.index===i&&a.indexVersion===(i?.version??-1))return a;let o={...LO(r,i,IO(t)),position:r,positionVersion:FO(r),index:i,indexVersion:i?.version??-1};return e.set(n,o),o},p=(e,t,n)=>{let{position:r,index:i}=e,a=i?.array,o=1/0;for(let i=e.ranges[t*2];i<e.ranges[t*2+1];i++){for(let e=0;e<3;e++){let t=a?a[i*3+e]:i*3+e;c[e*3]=r.getX(t),c[e*3+1]=r.getY(t),c[e*3+2]=r.getZ(t)}let e=3;for(let t=0;t<16&&e>0;t+=4){let r=n[t],i=n[t+1],a=n[t+2],o=n[t+3],s=0;for(let t=0;t<e;t++){let n=(t+1)%e,u=c[t*3],d=c[t*3+1],f=c[t*3+2],p=c[n*3],m=c[n*3+1],h=c[n*3+2],g=r*u+i*d+a*f+o,_=r*p+i*m+a*h+o;if(g>=0&&(l[s*3]=u,l[s*3+1]=d,l[s*3+2]=f,s++),g>=0!=_>=0){let e=g/(g-_);l[s*3]=u+(p-u)*e,l[s*3+1]=d+(m-d)*e,l[s*3+2]=f+(h-f)*e,s++}}[c,l]=[l,c],e=s}for(let t=0;t<e;t++){let e=n[16]*c[t*3]+n[17]*c[t*3+1]+n[18]*c[t*3+2]+n[19];e<o&&(o=e)}}return o},m=e=>{let t=e.elements;for(let e=0;e<20;e+=4){let n=a[e],r=a[e+1],i=a[e+2];o[e]=t[0]*n+t[1]*r+t[2]*i,o[e+1]=t[4]*n+t[5]*r+t[6]*i,o[e+2]=t[8]*n+t[9]*r+t[10]*i,o[e+3]=n*t[12]+r*t[13]+i*t[14]+a[e+3]}return o},h=(e,t,n)=>{outer:for(let r=0;r<e.length;r+=6){let i=e[r],a=e[r+1],o=e[r+2],s=e[r+3],c=e[r+4],l=e[r+5];for(let e=0;e<16;e+=4){let n=t[e],r=t[e+1],u=t[e+2];if(n*(n>0?s:i)+r*(r>0?c:a)+u*(u>0?l:o)+t[e+3]<0)continue outer}let d=t[16],f=t[17],m=t[18],h=d*(d>0?i:s)+f*(f>0?a:c)+m*(m>0?o:l)+t[19];h>=u||(u=n?Math.min(u,p(n,r/6,t)):h)}},g=e=>{let t=e.geometry;if(!t?.getAttribute?.(`position`))return;if(d=!0,PO(e)){let n=f(e,t);h(n.boxes,m(e.matrixWorld),n);return}let n=e;n.isInstancedMesh?(n.boundingBox||n.computeBoundingBox(),i.copy(n.boundingBox)):(t.boundingBox||t.computeBoundingBox(),i.copy(t.boundingBox)),!i.isEmpty()&&(s[0]=i.min.x,s[1]=i.min.y,s[2]=i.min.z,s[3]=i.max.x,s[4]=i.max.y,s[5]=i.max.z,h(s,m(e.matrixWorld)))},_=e=>{if(e.visible&&!NE(e)&&e.userData.kind!==`edge-overlay`){g(e);for(let t of e.children)_(t)}};return{measure:(e,i)=>{e.updateMatrixWorld(),i.updateMatrixWorld(),n.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),t.setFromProjectionMatrix(n);for(let e=0;e<4;e++){let n=t.planes[e];a[e*4]=n.normal.x,a[e*4+1]=n.normal.y,a[e*4+2]=n.normal.z,a[e*4+3]=n.constant}i.getWorldDirection(r),a[16]=r.x,a[17]=r.y,a[18]=r.z,a[19]=-r.dot(i.position),u=1/0,d=!1;for(let t of e.children)_(t);return d?u:null}}}function PO(e){let t=e;if(!t.isMesh||t.isInstancedMesh||t.isSkinnedMesh)return!1;let n=t.geometry;return!n.isInstancedBufferGeometry&&Object.keys(n.morphAttributes).length===0}function FO(e){return e.isInterleavedBufferAttribute?e.data.version:e.version}function IO(e){let t=[];for(let n of CD(e)??[])n.indexStart!==void 0&&t.push(n.indexStart/3);return t.sort((e,t)=>e-t)}function LO(e,t,n){let r=Math.floor((t?t.count:e.count)/3),i=[],a=0;for(let e=0;e<r;){for(;a<n.length&&n[a]<=e;)a++;let t=Math.min(r,e+AO,n[a]??r);i.push(e,t),e=t}let o=i.length/2,s=new Float32Array(o*6),c=!e.isInterleavedBufferAttribute,l=e.array,u=c&&e.itemSize===3&&!e.normalized,d=t?.array;for(let t=0;t<o;t++){let n=1/0,r=1/0,a=1/0,o=-1/0,c=-1/0,f=-1/0,p=i[t*2+1]*3;for(let s=i[t*2]*3;s<p;s++){let t=d?d[s]:s,i=u?l[t*3]:e.getX(t),p=u?l[t*3+1]:e.getY(t),m=u?l[t*3+2]:e.getZ(t);i<n&&(n=i),p<r&&(r=p),m<a&&(a=m),i>o&&(o=i),p>c&&(c=p),m>f&&(f=m)}let m=t*6;s[m]=n,s[m+1]=r,s[m+2]=a,s[m+3]=o,s[m+4]=c,s[m+5]=f}return{boxes:s,ranges:Uint32Array.from(i)}}function RO(){let e=[],t=null,n=()=>e.sort((e,t)=>t.priority-e.priority),r=t=>e.findIndex(e=>e.id===t),i=n=>{let i=r(n);i!==-1&&(e.splice(i,1),t===n&&(t=null))};return{register:({id:t,tool:r,priority:a=0})=>(i(t),e.push({id:t,tool:r,priority:a}),n(),()=>i(t)),unregister:i,get:t=>e[r(t)]?.tool??null,setActive:n=>{t=n;for(let t of e)t.tool.setEnabled?.(t.id===n)},getActive:()=>t,handleClick:t=>{for(let n of[...e])if(n.tool.handleClick(t))return!0;return!1},handleMove:t=>{for(let n of[...e])n.tool.handleMove?.(t)}}}function zO(e,t){let n=t.getBoundingClientRect();return{x:(e.clientX-n.left)/n.width*2-1,y:-((e.clientY-n.top)/n.height)*2+1}}function BO(e){let{camera:t,domElement:n,controller:r}=e,i=new Iw(t,n);i.setLabels(`X`,`Y`,`Z`);let a=!0,o=new Yg,s=new wg(-2,2,2,-2,0,4);s.position.set(0,0,2),s.updateMatrixWorld();let c={posX:new $(1,0,0),negX:new $(-1,0,0),posY:new $(0,1,0),negY:new $(0,-1,0),posZ:new $(0,0,1),negZ:new $(0,0,-1)},l=e=>{let r=n.getBoundingClientRect(),a=r.left+n.offsetWidth-128-i.location.right,l=r.top+n.offsetHeight-128-i.location.bottom,u=new Q((e.clientX-a)/128*2-1,-((e.clientY-l)/128)*2+1);if(Math.abs(u.x)>1||Math.abs(u.y)>1)return null;i.quaternion.copy(t.quaternion).invert(),i.updateMatrixWorld(),o.setFromCamera(u,s);let d=o.intersectObjects(i.children,!1);for(let e of d){let t=e.object.userData?.type;if(typeof t==`string`&&t in c)return t}return null};return{render:e=>{if(!a)return;let t=e.autoClear;e.autoClear=!1,i.render(e),e.autoClear=t},handleClick:e=>{if(!a)return!1;let t=l(e);return t?(r.getProjection()===`orthographic`&&r.setProjection(`perspective`),r.setViewDirection(c[t],!1),!0):!1},setVisible:e=>{a=e},isVisible:()=>a,dispose:()=>i.dispose()}}function VO(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m=!0,h){let g=null,_=performance.now(),v=!0,y=0,b=new tf,x=new tf,S=null,C=()=>{v=!0},w=e=>{e.updateMatrixWorld();let t=S!==e||!b.equals(e.matrixWorld)||!x.equals(e.projectionMatrix);return t&&(S=e,b.copy(e.matrixWorld),x.copy(e.projectionMatrix)),t},T=e.domElement,E=[`pointerdown`,`pointerup`,`wheel`];if(m)for(let e of E)T.addEventListener(e,C,{passive:!0});let D=()=>{let{width:t,height:r}=o();if(t===0||r===0)return;let a=s(),c=Math.floor(t*a),l=Math.floor(r*a);(e.domElement.width!==c||e.domElement.height!==l)&&(e.setPixelRatio(a),e.setSize(t,r,!1),n.aspect=t/r,n.updateProjectionMatrix(),i.updateAspect(t,r),d?.()?.setSize(t,r,a),f?.setSize(t,r),C())},O=n=>{f&&f.render(t,n),u&&u.render(e)},k=(n,r)=>{let i=d?.();i?(i.setCamera(n),i.render(r)):e.render(t,n),O(n)},A=()=>{let e=r();h?.present()?O(e):k(e,0)},j=function(){g=requestAnimationFrame(j);let e=performance.now(),t=(e-_)/1e3;_=e,D(),(a.enableDamping||a.autoRotate)&&a.update(),l&&l.update(r().position),p&&p.update(),c?.(t);let n=r();if(m){let r=w(n);r&&h?.moving(t*1e3);let i=v||r;if(!i&&h?.wants(e)){h.step(n),O(n);return}let a=e-y>=500;if(!i&&!a||(y=e,!i&&h?.isHolding()))return;v=!1,h?.reset(e)}k(n,t)};return{animate:j,dispose:()=>{if(g!==null&&(cancelAnimationFrame(g),g=null),m)for(let e of E)T.removeEventListener(e,C)},invalidate:C,renderNow:A}}var HO=3,UO=2,WO=1024,GO=1/3,KO=.05,qO=160/(4*Math.PI)*.005,JO=.07,YO=7,XO=.15;function ZO(e){let t=ix(e);return t?.userData.selvaEmissive?t:null}function QO(e){let t=CD(e);if(!t)return[new ep().setFromObject(e)];let n=nx(e);return t.filter((e,t)=>!n.has(t)).map(t=>DD(e,t)).filter(e=>!e.isEmpty())}function $O(e,t){let n=e=>e.getSize(new $).length(),r=Math.max(n(e),n(t))*KO;return e.clone().expandByScalar(r).intersectsBox(t)}function ek(e,t){let n=[];for(let r of e){let i={bounds:r.bounds.clone(),meshes:new Set([r.mesh])},a=[];for(let e of n)if($O(e.bounds,r.bounds)){i.bounds.union(e.bounds);for(let t of e.meshes)i.meshes.add(t)}else a.push(e);if(n=[...a,i],n.length>t){let t=new ep;for(let n of e)t.union(n.bounds);return[{bounds:t,meshes:new Set(e.map(e=>e.mesh))}]}}return n}function tk(e,t){let n=new Map;for(let t of e){let{emissive:e,emissiveIntensity:r,userData:i}=t.material,a=`${e.getHexString()}|${r}|${i[kb]}`,o=n.get(a);o?o.push(t):n.set(a,[t])}return[...n.values()].flatMap(e=>{let{emissive:n,emissiveIntensity:r,userData:i}=e[0].material;return ek(e,t).map(e=>({...e,color:n,strength:r,light:i[kb]}))})}function nk(e,t=HO){let n=Math.max(0,...e.map(e=>e.strength));return e.filter(e=>e.strength>=n*GO).sort((e,t)=>t.strength-e.strength).slice(0,t)}function rk(e){let t=[],n=new Set,r=new $,i=n=>{let r=new Cg(16777215,1,0,2),i=new Cg(16777215,1,0,1);n&&(r.castShadow=!0,r.shadow.mapSize.setScalar(WO),r.shadow.radius=YO,r.shadow.autoUpdate=!1);let a={key:r,bounce:i,home:new $,size:new $};return t.push(a),e.add(r,i),a},a=()=>{let t=new ep,n=[];return e.traverseVisible(e=>{let r=e;if(!r.isMesh||e.userData.source!==`compute`)return;t.union(new ep().setFromObject(r));let i=ZO(r);if(i)for(let e of QO(r))n.push({mesh:r,material:i,bounds:e})}),{parts:n,radius:t.getSize(new $).length()/2}},o=(e,r)=>{for(let{mesh:i,bounds:a}of e)r.some((e,n)=>e.meshes.has(i)||a.containsPoint(t[n].key.position))&&i.castShadow&&(i.castShadow=!1,n.add(i))},s=(r,s=HO,c=1)=>{for(let e of n)e.castShadow=!0;n.clear();let{parts:l,radius:u}=r?a():{parts:[],radius:0},d=nk(tk(l,s),s);for(d.forEach((e,n)=>{let{key:r,bounce:a,home:o,size:s}=t[n]??i(n<UO),l=(e.light??e.strength*qO)*c;r.color.copy(e.color);let d=e.bounds.getSize(new $).length()/2/u;r.intensity=!e.light&&d>XO?0:l,e.bounds.getCenter(r.position),o.copy(r.position),e.bounds.getSize(s),a.color.copy(e.color),a.intensity=l*JO/u,a.position.copy(r.position),r.castShadow&&(r.shadow.camera.near=u*.005,r.shadow.camera.far=u*4,r.shadow.camera.updateProjectionMatrix(),r.shadow.bias=-.002,r.shadow.normalBias=u*.002,r.shadow.needsUpdate=!0)});t.length>d.length;){let{key:n,bounce:r}=t.pop();e.remove(n,r),n.dispose(),r.dispose()}o(l,d)},c=e=>{for(let{key:n,home:r,size:i}of t)n.position.copy(e(r,i)),n.castShadow&&(n.shadow.needsUpdate=!0)};return{sync:s,jitter:e=>c((t,n)=>r.set(yE(e,2)-.5,yE(e,3)-.5,yE(e,5)-.5).multiply(n).add(t)),settle:()=>c(e=>e),dispose:()=>s(!1)}}var ik=`__selvaLookBaseline`;function ak(e,t){e.color?.setHex(t.color),e.metalness!==void 0&&(e.metalness=t.metalness),e.roughness!==void 0&&(e.roughness=t.roughness),e.emissiveIntensity!==void 0&&(e.emissiveIntensity=t.emissiveIntensity),e.opacity=t.opacity,e.transparent=t.transparent,e.depthWrite=t.depthWrite,e.wireframe!==void 0&&(e.wireframe=t.wireframe),e.side=t.side}function ok(e){let t=e[ik];t&&(ak(e,t),delete e[ik])}function sk(e,t){let n=e;t?(n[ik]?ak(n,n[ik]):n[ik]={color:n.color?.getHex()??16777215,metalness:n.metalness??0,roughness:n.roughness??1,emissiveIntensity:n.emissiveIntensity??0,opacity:n.opacity,transparent:n.transparent,depthWrite:n.depthWrite,wireframe:n.wireframe??!1,side:n.side},t.color!==void 0&&n.color?.setHex(t.color),t.metalness!==void 0&&n.metalness!==void 0&&(n.metalness=t.metalness),t.roughness!==void 0&&n.roughness!==void 0&&(n.roughness=t.roughness),t.emissiveIntensity!==void 0&&n.userData.selvaEmissive&&(n.emissiveIntensity=t.emissiveIntensity),t.opacity!==void 0&&(n.opacity=t.opacity,n.transparent=t.opacity<1),t.depthWrite!==void 0&&(n.depthWrite=t.depthWrite),t.wireframe!==void 0&&n.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(n.side=t.side),n.needsUpdate=!0):(ok(n),n.needsUpdate=!0)}function ck(e,t){if(t.materialOverride)return t.envMapIntensity;let n=e.userData[Ab];if(n!=null)return n;let r=e,i=r[ik]?.metalness??r.metalness??0;return jb(t.envMapIntensity,i,t.metalReflection)}function lk(e,t){return Math.min(e,t.maxPixelRatio??e)}function uk(e){let{scene:t,renderer:n,lights:r,config:i,pipeline:a,fullPixelRatio:o,requestRender:s}=e,c=e=>Db(e,i.render.lowPower),l=i.look,u=rk(t),d=n.shadowMap.type,f=e=>{let t=e.emissiveLights?1:d;n.shadowMap.type!==t&&(n.shadowMap.type=t,n.shadowMap.needsUpdate=!0)},p,m=e=>{e.background===void 0?(p!==void 0&&(t.background=p),p=void 0):(p??=t.background,t.background=new Lf(e.background))};m(c(l)),f(c(l));let h=e=>{e.ambientIntensity!==void 0&&(r.ambient.intensity=e.ambientIntensity),e.hemisphereIntensity!==void 0&&!r.hemisphere&&e.hemisphereIntensity>0&&(r.hemisphere=new lg(e.hemisphereSkyColor??i.lighting.hemisphereSkyColor,e.hemisphereGroundColor??i.lighting.hemisphereGroundColor,e.hemisphereIntensity),r.hemisphere.position.copy(i.environment.sceneUp??pE),t.add(r.hemisphere)),r.hemisphere&&(e.hemisphereIntensity!==void 0&&(r.hemisphere.intensity=e.hemisphereIntensity),e.hemisphereSkyColor!==void 0&&r.hemisphere.color.set(e.hemisphereSkyColor),e.hemisphereGroundColor!==void 0&&r.hemisphere.groundColor.set(e.hemisphereGroundColor)),s()},g=e=>{i.environment.environmentIntensity=e,t.environmentIntensity=e,s()},_=e=>{i.render.toneMappingExposure=e,n.toneMappingExposure=e,a.get()&&a.rebuild()},v=e=>{i.render.aoIntensity=e,a.get()&&a.rebuild()},y=()=>{let{emissiveLights:e,maxEmissiveLights:t,emissiveLightScale:n}=c(l);u.sync(!!e,t,n),s()};return{setFillLights:h,setEnvironmentIntensity:g,setToneMappingExposure:_,setAoIntensity:v,setLook:(e,s)=>{let u=c(e);l=e,n.toneMapping=u.toneMapping,n.toneMappingExposure=u.toneMappingExposure,i.render.toneMapping=u.toneMapping,i.render.toneMappingExposure=u.toneMappingExposure,h({hemisphereIntensity:u.hemisphereIntensity,ambientIntensity:u.ambientIntensity}),g(u.environmentIntensity),r.sun&&(r.sun.intensity=u.sunlightIntensity,i.lighting.sunlightIntensity=u.sunlightIntensity),m(u),f(u),i.render.bloom=u.bloom,i.render.pixelRatio=lk(o,u),a.setAmbientOcclusion(u.ambientOcclusion),t.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,n=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of n)`envMapIntensity`in e&&(e.envMapIntensity=ck(e,u)),sk(e,u.materialOverride)}),sE(t,t),s?.deferEmissiveLights||y()},syncEmissiveLights:y,jitterEmissiveLights:u.jitter,settleEmissiveLights:u.settle,getMaterialAppearance:()=>Mb(l)}}function dk(e,t){let n=t.parentElement,r=n?n.clientWidth:window.innerWidth,i=n?n.clientHeight:window.innerHeight,a=new xg(e.camera.fov,r/i,e.camera.near,e.camera.far),o=e.camera.position;return o&&a.position.set(o.x,o.y,o.z),a}function fk(e){let t=new zf;return t.background=(typeof e.environment.backgroundColor==`string`?new Lf(e.environment.backgroundColor):e.environment.backgroundColor)||null,t}function pk(e,t){Gb(e,t),e.environment?.dispose(),oE(e),e.background instanceof Yd&&e.background.dispose()}var mk={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new Q(1,1)},uColor:{value:new Lf(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
|
|
5671
|
+
`;function $D(e={}){let{cellSize:t=1,majorEvery:n=10,cellColor:r=8947848,majorColor:i=4473924,fadeDistance:a=100,plane:o=`y`}=e,s=o===`y`?new Q(0,2):o===`z`?new Q(0,1):new Q(1,2),c=2.5,l=new ph(1,1);o===`y`?l.rotateX(-Math.PI/2):o===`x`&&l.rotateY(Math.PI/2);let u=new wh({vertexShader:ZD,fragmentShader:QD,transparent:!0,depthWrite:!1,side:2,uniforms:{uAxes:{value:s},uCell:{value:t},uMajor:{value:n},uCellColor:{value:new Lf(r)},uMajorColor:{value:new Lf(i)},uCenter:{value:new $},uFade:{value:a}}}),d=new Om(l,u);d.name=`grid`,d.userData.id=`grid`,d.renderOrder=-1;let f=a,p=a*c,m=new $;return{object:d,update:e=>{o===`y`?(d.position.set(e.x,0,e.z),m.set(e.x,0,e.z)):o===`z`?(d.position.set(e.x,e.y,0),m.set(e.x,e.y,0)):(d.position.set(0,e.y,e.z),m.set(0,e.y,e.z)),u.uniforms.uCenter.value.copy(m),d.scale.setScalar(p)},fitToContent:e=>{if(e.isEmpty())return;let t=e.getSize(new $),n=(e,t)=>t===0?e.x:t===1?e.y:e.z,r=Math.max(n(t,s.x),n(t,s.y));r>0&&Number.isFinite(r)&&(u.uniforms.uCell.value=XD(r/20),f=r*2,u.uniforms.uFade.value=f,p=f*c)},setVisible:e=>{d.visible=e},dispose:()=>{d.removeFromParent(),l.dispose(),u.dispose()}}}function eO(e,t){let n=new Bx,r=n.domElement;r.style.position=`absolute`,r.style.top=`0`,r.style.left=`0`,r.style.overflow=`hidden`,r.style.pointerEvents=`none`,r.style.zIndex=`30`,getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.appendChild(r);let i={width:e.clientWidth||1,height:e.clientHeight||1};n.setSize(i.width,i.height);let a=new Af;a.name=`label-layer`,a.userData.id=`label-layer`,t.add(a);let o=new Set;return{addLabel:(e,t,n)=>{let r=document.createElement(`div`);r.textContent=e,n?r.className=n:Object.assign(r.style,{padding:`2px 6px`,borderRadius:`4px`,background:`rgba(20, 20, 20, 0.78)`,color:`#fff`,font:`12px/1.3 system-ui, sans-serif`,whiteSpace:`pre`,textAlign:`center`,userSelect:`none`}),r.style.pointerEvents=`none`;let i=new Px(r);return i.position.copy(t),a.add(i),o.add(i),{object:i,setPosition:e=>i.position.copy(e),setText:e=>{r.textContent=e},remove:()=>{i.removeFromParent(),r.remove(),o.delete(i)}}},render:(e,t)=>n.render(e,t),setSize:(e,t)=>n.setSize(e,t),dispose:()=>{o.forEach(e=>{e.removeFromParent(),e.element.remove()}),o.clear(),a.removeFromParent(),r.remove()}}}var tO=new WeakMap;function nO(e){return e?.version??0}function rO(e){let t=e.attributes.position;if(!t||t.count===0)return null;let n=e.index,r=n??t,i=tO.get(r);if(i===null)return null;if(i&&i.position===t&&i.positionVersion===nO(t)&&i.indexVersion===nO(n))return i.bvh;let a=new Rp;a.setAttribute(`position`,t),n&&a.setIndex(n);try{let e=new Fw(a,{indirect:!0});return tO.set(r,{position:t,positionVersion:nO(t),indexVersion:nO(n),bvh:e}),e}catch{return tO.set(r,null),null}}function iO(e){let t=e;return t.isMesh===!0&&!t.isInstancedMesh&&!t.isSkinnedMesh&&!t.isBatchedMesh&&!t.isLineSegments2&&!e.morphTargetInfluences?.length}function aO(e,t=[]){for(let n of e.children)!n.visible||NE(n)||HD(n)||(t.push(n),aO(n,t));return t}function oO(e){let{groups:t}=e.geometry;if(!Array.isArray(e.material)||t.length===0)return null;let n=e.material;return t.filter(e=>n[e.materialIndex??0]?.visible!==!1).map(e=>({start:e.start,end:e.start+e.count}))}var sO=new tf,cO=new hm,lO=new Ap;function uO(e,t,n){sO.copy(e.matrixWorld).invert(),cO.copy(n.ray).applyMatrix4(sO);let r=oO(e),i=null;if(!r)i=t.raycastFirst(cO,2);else for(let e of t.raycast(cO,2)){let t=(e.faceIndex??0)*3;r.some(e=>t>=e.start&&t<e.end)&&(!i||e.distance<i.distance)&&(i=e)}return!i||(i.point.applyMatrix4(e.matrixWorld),i.distance=i.point.distanceTo(n.ray.origin),i.object=e,i.distance<n.near||i.distance>n.far)?null:i}function dO(e,t){let n=[];for(let r of aO(e))if(r.layers.test(t.layers)){if(iO(r)){let{geometry:e}=r;if(e.boundingSphere||e.computeBoundingSphere(),!e.boundingSphere||(lO.copy(e.boundingSphere).applyMatrix4(r.matrixWorld),!t.ray.intersectsSphere(lO)))continue;let i=rO(e);if(i){let e=uO(r,i,t);e&&n.push(e);continue}}r.raycast(t,n)}return n.sort((e,t)=>e.distance-t.distance)}function fO(e){let t=aO(e).filter(iO),n=typeof requestIdleCallback==`function`?e=>requestIdleCallback(e,{timeout:500}):e=>setTimeout(e,16),r=typeof cancelIdleCallback==`function`?cancelIdleCallback:e=>clearTimeout(e),i=0,a=!1,o=()=>{if(a)return;let e=t.shift();e&&(rO(e.geometry),i=n(o))};return i=n(o),()=>{a=!0,r(i)}}var pO=12,mO=16763904,hO=.015,gO=998,_O=999,vO=1e3,yO={Millimeters:{metersPerUnit:1/1e3,suffix:`mm`},Centimeters:{metersPerUnit:1/100,suffix:`cm`},Meters:{metersPerUnit:1,suffix:`m`},Inches:{metersPerUnit:1/39.37,suffix:`in`},Feet:{metersPerUnit:1/3.28084,suffix:`ft`}};function bO(e){let t=e&&yO[e]||yO.Meters;return e=>{let n=e/t.metersPerUnit,r=Math.abs(n),i=r===0?0:Math.min(6,Math.max(0,2-Math.floor(Math.log10(r))));return`${n.toFixed(i)} ${t.suffix}`}}function xO(e){return(t,n)=>{let r=t*1e-6,i=[`x`,`y`,`z`].filter(e=>n[e]>r);return i.length<2?e(t):`${e(t)}\n${i.map(t=>`Δ${t} ${e(n[t])}`).join(` `)}`}}function SO(e,t){if(e.isOrthographicCamera){let t=e;return Math.abs(t.top-t.bottom)/(t.zoom||1)*hO}return((t?e.position.distanceTo(t):e.position.length())||1)*hO}function CO(e){let t=e.object,n=t.geometry;if(!n)return null;if(t.isLineSegments2){let t=n.attributes.instanceStart,r=n.attributes.instanceEnd,i=e.faceIndex;return!t||!r||i==null||i>=t.count?null:[new $().fromBufferAttribute(t,i),new $().fromBufferAttribute(r,i)]}let r=n.attributes.position;if(!r)return null;let i=e=>e.filter(e=>e<r.count).map(e=>new $().fromBufferAttribute(r,e));if(t instanceof Om)return e.face?i([e.face.a,e.face.b,e.face.c]):null;if(t instanceof $m)return e.index==null?null:i([e.index]);if(t instanceof Km){if(e.index==null)return null;let t=n.index;return t?e.index+1>=t.count?null:i([t.getX(e.index),t.getX(e.index+1)]):i([e.index,e.index+1])}return null}function wO(e,t,n){let r=e.clone().project(t);return new Q((r.x+1)/2*n.width,(1-r.y)/2*n.height)}function TO(e){return e.pointOnLine??e.point}function EO(e,t,n,r){let i=TO(e).clone(),a=CO(e);if(!a)return{point:i,snapped:!1};let o=wO(i,t,n),s={point:i,snapped:!1},c=r;for(let r of a){let i=r.applyMatrix4(e.object.matrixWorld),a=wO(i,t,n).distanceTo(o);a<c&&(c=a,s={point:i,snapped:!0})}return s}function DO(e,t,n,r){return EO(e,t,n,r).point}function OO(e){let{canvas:t,scene:n,getActiveCamera:r,getViewTarget:i,labelLayer:a,options:o={}}=e,s=e.requestRender??(()=>{}),c=o.snapPixels??pO,l=new Lf(o.color??mO),u=o.format??xO(bO(o.displayUnit)),d=new Yg,f=new Q,p=!1,m=null,h=[],g=new Jm({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),_=new Jm({color:l,size:12,sizeAttenuation:!1,depthTest:!1}),v=new Jm({color:l,size:7,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.6}),y=(e,t)=>(e.renderOrder=t,e.userData.id=`measure`,e.raycast=()=>{},e.frustumCulled=!1,e),b=(...e)=>{let t=new Rp;t.setAttribute(`position`,new Ep(e.flatMap(e=>[e.x,e.y,e.z]),3));let r=y(new $m(t,g),_O);return n.add(r),r},x=(e,t,r=1)=>{let i=new Mx;i.setPositions([e.x,e.y,e.z,t.x,t.y,t.z]);let a=new fx({color:l,transparent:r<1,opacity:r});a.linewidth=2,a.depthTest=!1;let o=y(new Nx(i,a),gO);return n.add(o),o},S=(e,t,n)=>{let r=e.geometry.attributes.instanceStart.data;r.array.set([t.x,t.y,t.z,n.x,n.y,n.z]),r.needsUpdate=!0},C=e=>{e.geometry.dispose(),e.material.dispose(),e.removeFromParent()},w=e=>{e.geometry.dispose(),e.removeFromParent()},T=(e,t)=>{let n=new $(Math.abs(t.x-e.x),Math.abs(t.y-e.y),Math.abs(t.z-e.z));return u(e.distanceTo(t),n)},E=(e,t)=>e.clone().add(t).multiplyScalar(.5),D=null,O=null,k=null,A=()=>{D&&(D.visible=!1),O&&(O.visible=!1),k?.remove(),k=null},j=e=>{if(!e){A();return}if(D||(D=b(new $),D.renderOrder=vO),D.material=e.snapped?_:v,D.position.copy(e.point),D.visible=!0,!m){O&&(O.visible=!1),k?.remove(),k=null;return}O||=x(m.point,e.point,.7),S(O,m.point,e.point),O.visible=!0;let t=T(m.point,e.point),n=E(m.point,e.point);k?(k.setText(t),k.setPosition(n)):k=a.addLabel(t,n,o.labelClassName)},M=e=>{let a=t.getBoundingClientRect(),o=e.clientX-a.left,s=e.clientY-a.top;f.x=o/a.width*2-1,f.y=-(s/a.height)*2+1;let l=r();d.setFromCamera(f,l);let u=SO(l,i?.())*2;d.params.Line.threshold=u,d.params.Points.threshold=u,d.params.Line2={threshold:c/2};let p={width:a.width,height:a.height},m=new Q(o,s);for(let e of dO(n,d))if(!(!(e.object.isMesh&&e.face!=null)&&wO(TO(e),l,p).distanceTo(m)>c))return EO(e,l,p,c);return null},N=null,P=0,F=()=>{P&&=(cancelAnimationFrame(P),0),N=null},ee=e=>{p&&(N=e,!P&&(P=requestAnimationFrame(()=>{P=0;let e=N;N=null,p&&e&&(j(M(e)),s())})))},te=()=>{F(),A(),s()},ne=()=>{m&&=(w(m.marker),null)},I=()=>{ne();for(let e of h)w(e.markers),C(e.line),e.label.remove();h.length=0,A(),s()},L=()=>{m?(ne(),A(),s()):I()},R=e=>{if(!p)return!1;F();let t=M(e);if(!t)return!0;if(!m)m={point:t.point,marker:b(t.point)};else if(!t.point.equals(m.point)){let e=m.point,n=t.point;ne(),h.push({markers:b(e,n),line:x(e,n),label:a.addLabel(T(e,n),E(e,n),o.labelClassName)})}return j(t),s(),!0},z=e=>{e.key===`Escape`&&(e.target?.closest?.(`input, textarea, select, [contenteditable]`)||L())},re=``,B=null,ie=e=>{e!==p&&(p=e,e?(re=t.style.cursor,t.style.cursor=`crosshair`,t.addEventListener(`mouseleave`,te),window.addEventListener(`keydown`,z),B=fO(n)):(t.style.cursor=re,t.removeEventListener(`mouseleave`,te),window.removeEventListener(`keydown`,z),B?.(),B=null,F(),I()))};return{setEnabled:ie,isEnabled:()=>p,handleClick:R,handleMove:ee,cancel:L,clear:I,dispose:()=>{ie(!1),I(),D&&w(D),O&&C(O),D=null,O=null,g.dispose(),_.dispose(),v.dispose()}}}var kO=.5,AO=.01,jO=.05,MO=256,NO=[];function PO({camera:e,scene:t,groundNormals:n=()=>NO}){let r=e.near,i=e.near,a=FO();return{update:()=>{e.near!==i&&(r=e.near);let o=a.measure(t,e),s=r;if(o!==null){let t=o;for(let r of n())t=Math.min(t,Math.abs(e.position.dot(r)));s=Ad.clamp(t*kO,r,e.far*AO)}Math.abs(s-i)>i*jO&&(e.near=s,e.updateProjectionMatrix(),i=s)}}}function FO(){let e=new WeakMap,t=new Fm,n=new tf,r=new $,i=new ep,a=new Float64Array(20),o=new Float64Array(20),s=new Float32Array(6),c=new Float64Array(21),l=new Float64Array(21),u=1/0,d=!1,f=(t,n)=>{let r=n.getAttribute(`position`),i=n.getIndex(),a=e.get(n);if(a&&a.position===r&&a.positionVersion===LO(r)&&a.index===i&&a.indexVersion===(i?.version??-1))return a;let o={...zO(r,i,RO(t)),position:r,positionVersion:LO(r),index:i,indexVersion:i?.version??-1};return e.set(n,o),o},p=(e,t,n)=>{let{position:r,index:i}=e,a=i?.array,o=1/0;for(let i=e.ranges[t*2];i<e.ranges[t*2+1];i++){for(let e=0;e<3;e++){let t=a?a[i*3+e]:i*3+e;c[e*3]=r.getX(t),c[e*3+1]=r.getY(t),c[e*3+2]=r.getZ(t)}let e=3;for(let t=0;t<16&&e>0;t+=4){let r=n[t],i=n[t+1],a=n[t+2],o=n[t+3],s=0;for(let t=0;t<e;t++){let n=(t+1)%e,u=c[t*3],d=c[t*3+1],f=c[t*3+2],p=c[n*3],m=c[n*3+1],h=c[n*3+2],g=r*u+i*d+a*f+o,_=r*p+i*m+a*h+o;if(g>=0&&(l[s*3]=u,l[s*3+1]=d,l[s*3+2]=f,s++),g>=0!=_>=0){let e=g/(g-_);l[s*3]=u+(p-u)*e,l[s*3+1]=d+(m-d)*e,l[s*3+2]=f+(h-f)*e,s++}}[c,l]=[l,c],e=s}for(let t=0;t<e;t++){let e=n[16]*c[t*3]+n[17]*c[t*3+1]+n[18]*c[t*3+2]+n[19];e<o&&(o=e)}}return o},m=e=>{let t=e.elements;for(let e=0;e<20;e+=4){let n=a[e],r=a[e+1],i=a[e+2];o[e]=t[0]*n+t[1]*r+t[2]*i,o[e+1]=t[4]*n+t[5]*r+t[6]*i,o[e+2]=t[8]*n+t[9]*r+t[10]*i,o[e+3]=n*t[12]+r*t[13]+i*t[14]+a[e+3]}return o},h=(e,t,n)=>{outer:for(let r=0;r<e.length;r+=6){let i=e[r],a=e[r+1],o=e[r+2],s=e[r+3],c=e[r+4],l=e[r+5];for(let e=0;e<16;e+=4){let n=t[e],r=t[e+1],u=t[e+2];if(n*(n>0?s:i)+r*(r>0?c:a)+u*(u>0?l:o)+t[e+3]<0)continue outer}let d=t[16],f=t[17],m=t[18],h=d*(d>0?i:s)+f*(f>0?a:c)+m*(m>0?o:l)+t[19];h>=u||(u=n?Math.min(u,p(n,r/6,t)):h)}},g=e=>{let t=e.geometry;if(!t?.getAttribute?.(`position`))return;if(d=!0,IO(e)){let n=f(e,t);h(n.boxes,m(e.matrixWorld),n);return}let n=e;n.isInstancedMesh?(n.boundingBox||n.computeBoundingBox(),i.copy(n.boundingBox)):(t.boundingBox||t.computeBoundingBox(),i.copy(t.boundingBox)),!i.isEmpty()&&(s[0]=i.min.x,s[1]=i.min.y,s[2]=i.min.z,s[3]=i.max.x,s[4]=i.max.y,s[5]=i.max.z,h(s,m(e.matrixWorld)))},_=e=>{if(e.visible&&!NE(e)&&e.userData.kind!==`edge-overlay`){g(e);for(let t of e.children)_(t)}};return{measure:(e,i)=>{e.updateMatrixWorld(),i.updateMatrixWorld(),n.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),t.setFromProjectionMatrix(n);for(let e=0;e<4;e++){let n=t.planes[e];a[e*4]=n.normal.x,a[e*4+1]=n.normal.y,a[e*4+2]=n.normal.z,a[e*4+3]=n.constant}i.getWorldDirection(r),a[16]=r.x,a[17]=r.y,a[18]=r.z,a[19]=-r.dot(i.position),u=1/0,d=!1;for(let t of e.children)_(t);return d?u:null}}}function IO(e){let t=e;if(!t.isMesh||t.isInstancedMesh||t.isSkinnedMesh)return!1;let n=t.geometry;return!n.isInstancedBufferGeometry&&Object.keys(n.morphAttributes).length===0}function LO(e){return e.isInterleavedBufferAttribute?e.data.version:e.version}function RO(e){let t=[];for(let n of TD(e)??[])n.indexStart!==void 0&&t.push(n.indexStart/3);return t.sort((e,t)=>e-t)}function zO(e,t,n){let r=Math.floor((t?t.count:e.count)/3),i=[],a=0;for(let e=0;e<r;){for(;a<n.length&&n[a]<=e;)a++;let t=Math.min(r,e+MO,n[a]??r);i.push(e,t),e=t}let o=i.length/2,s=new Float32Array(o*6),c=!e.isInterleavedBufferAttribute,l=e.array,u=c&&e.itemSize===3&&!e.normalized,d=t?.array;for(let t=0;t<o;t++){let n=1/0,r=1/0,a=1/0,o=-1/0,c=-1/0,f=-1/0,p=i[t*2+1]*3;for(let s=i[t*2]*3;s<p;s++){let t=d?d[s]:s,i=u?l[t*3]:e.getX(t),p=u?l[t*3+1]:e.getY(t),m=u?l[t*3+2]:e.getZ(t);i<n&&(n=i),p<r&&(r=p),m<a&&(a=m),i>o&&(o=i),p>c&&(c=p),m>f&&(f=m)}let m=t*6;s[m]=n,s[m+1]=r,s[m+2]=a,s[m+3]=o,s[m+4]=c,s[m+5]=f}return{boxes:s,ranges:Uint32Array.from(i)}}function BO(){let e=[],t=null,n=()=>e.sort((e,t)=>t.priority-e.priority),r=t=>e.findIndex(e=>e.id===t),i=n=>{let i=r(n);i!==-1&&(e.splice(i,1),t===n&&(t=null))};return{register:({id:t,tool:r,priority:a=0})=>(i(t),e.push({id:t,tool:r,priority:a}),n(),()=>i(t)),unregister:i,get:t=>e[r(t)]?.tool??null,setActive:n=>{t=n;for(let t of e)t.tool.setEnabled?.(t.id===n)},getActive:()=>t,handleClick:t=>{for(let n of[...e])if(n.tool.handleClick(t))return!0;return!1},handleMove:t=>{for(let n of[...e])n.tool.handleMove?.(t)}}}function VO(e,t){let n=t.getBoundingClientRect();return{x:(e.clientX-n.left)/n.width*2-1,y:-((e.clientY-n.top)/n.height)*2+1}}function HO(e){let{camera:t,domElement:n,controller:r}=e,i=new Iw(t,n);i.setLabels(`X`,`Y`,`Z`);let a=!0,o=new Yg,s=new wg(-2,2,2,-2,0,4);s.position.set(0,0,2),s.updateMatrixWorld();let c={posX:new $(1,0,0),negX:new $(-1,0,0),posY:new $(0,1,0),negY:new $(0,-1,0),posZ:new $(0,0,1),negZ:new $(0,0,-1)},l=e=>{let r=n.getBoundingClientRect(),a=r.left+n.offsetWidth-128-i.location.right,l=r.top+n.offsetHeight-128-i.location.bottom,u=new Q((e.clientX-a)/128*2-1,-((e.clientY-l)/128)*2+1);if(Math.abs(u.x)>1||Math.abs(u.y)>1)return null;i.quaternion.copy(t.quaternion).invert(),i.updateMatrixWorld(),o.setFromCamera(u,s);let d=o.intersectObjects(i.children,!1);for(let e of d){let t=e.object.userData?.type;if(typeof t==`string`&&t in c)return t}return null};return{render:e=>{if(!a)return;let t=e.autoClear;e.autoClear=!1,i.render(e),e.autoClear=t},handleClick:e=>{if(!a)return!1;let t=l(e);return t?(r.getProjection()===`orthographic`&&r.setProjection(`perspective`),r.setViewDirection(c[t],!1),!0):!1},setVisible:e=>{a=e},isVisible:()=>a,dispose:()=>i.dispose()}}function UO(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m=!0,h){let g=null,_=performance.now(),v=!0,y=0,b=new tf,x=new tf,S=null,C=()=>{v=!0},w=e=>{e.updateMatrixWorld();let t=S!==e||!b.equals(e.matrixWorld)||!x.equals(e.projectionMatrix);return t&&(S=e,b.copy(e.matrixWorld),x.copy(e.projectionMatrix)),t},T=e.domElement,E=[`pointerdown`,`pointerup`,`wheel`];if(m)for(let e of E)T.addEventListener(e,C,{passive:!0});let D=()=>{let{width:t,height:r}=o();if(t===0||r===0)return;let a=s(),c=Math.floor(t*a),l=Math.floor(r*a);(e.domElement.width!==c||e.domElement.height!==l)&&(e.setPixelRatio(a),e.setSize(t,r,!1),n.aspect=t/r,n.updateProjectionMatrix(),i.updateAspect(t,r),d?.()?.setSize(t,r,a),f?.setSize(t,r),C())},O=n=>{f&&f.render(t,n),u&&u.render(e)},k=(n,r)=>{let i=d?.();i?(i.setCamera(n),i.render(r)):e.render(t,n),O(n)},A=()=>{let e=r();h?.present()?O(e):k(e,0)},j=function(){g=requestAnimationFrame(j);let e=performance.now(),t=(e-_)/1e3;_=e,D(),(a.enableDamping||a.autoRotate)&&a.update(),l&&l.update(r().position),p&&p.update(),c?.(t);let n=r();if(m){let r=w(n);r&&h?.moving(t*1e3);let i=v||r;if(!i&&h?.wants(e)){h.step(n),O(n);return}let a=e-y>=500;if(!i&&!a||(y=e,!i&&h?.isHolding()))return;v=!1,h?.reset(e)}k(n,t)};return{animate:j,dispose:()=>{if(g!==null&&(cancelAnimationFrame(g),g=null),m)for(let e of E)T.removeEventListener(e,C)},invalidate:C,renderNow:A}}var WO=3,GO=2,KO=1024,qO=1/3,JO=.05,YO=160/(4*Math.PI)*.005,XO=.07,ZO=7,QO=.15;function $O(e){let t=ix(e);return t?.userData.selvaEmissive?t:null}function ek(e){let t=TD(e);if(!t)return[new ep().setFromObject(e)];let n=nx(e);return t.filter((e,t)=>!n.has(t)).map(t=>kD(e,t)).filter(e=>!e.isEmpty())}function tk(e,t){let n=e=>e.getSize(new $).length(),r=Math.max(n(e),n(t))*JO;return e.clone().expandByScalar(r).intersectsBox(t)}function nk(e,t){let n=[];for(let r of e){let i={bounds:r.bounds.clone(),meshes:new Set([r.mesh])},a=[];for(let e of n)if(tk(e.bounds,r.bounds)){i.bounds.union(e.bounds);for(let t of e.meshes)i.meshes.add(t)}else a.push(e);if(n=[...a,i],n.length>t){let t=new ep;for(let n of e)t.union(n.bounds);return[{bounds:t,meshes:new Set(e.map(e=>e.mesh))}]}}return n}function rk(e,t){let n=new Map;for(let t of e){let{emissive:e,emissiveIntensity:r,userData:i}=t.material,a=`${e.getHexString()}|${r}|${i[kb]}`,o=n.get(a);o?o.push(t):n.set(a,[t])}return[...n.values()].flatMap(e=>{let{emissive:n,emissiveIntensity:r,userData:i}=e[0].material;return nk(e,t).map(e=>({...e,color:n,strength:r,light:i[kb]}))})}function ik(e,t=WO){let n=Math.max(0,...e.map(e=>e.strength));return e.filter(e=>e.strength>=n*qO).sort((e,t)=>t.strength-e.strength).slice(0,t)}function ak(e){let t=[],n=new Set,r=new $,i=n=>{let r=new Cg(16777215,1,0,2),i=new Cg(16777215,1,0,1);n&&(r.castShadow=!0,r.shadow.mapSize.setScalar(KO),r.shadow.radius=ZO,r.shadow.autoUpdate=!1);let a={key:r,bounce:i,home:new $,size:new $};return t.push(a),e.add(r,i),a},a=()=>{let t=new ep,n=[];return e.traverseVisible(e=>{let r=e;if(!r.isMesh||e.userData.source!==`compute`)return;t.union(new ep().setFromObject(r));let i=$O(r);if(i)for(let e of ek(r))n.push({mesh:r,material:i,bounds:e})}),{parts:n,radius:t.getSize(new $).length()/2}},o=(e,r)=>{for(let{mesh:i,bounds:a}of e)r.some((e,n)=>e.meshes.has(i)||a.containsPoint(t[n].key.position))&&i.castShadow&&(i.castShadow=!1,n.add(i))},s=(r,s=WO,c=1)=>{for(let e of n)e.castShadow=!0;n.clear();let{parts:l,radius:u}=r?a():{parts:[],radius:0},d=ik(rk(l,s),s);for(d.forEach((e,n)=>{let{key:r,bounce:a,home:o,size:s}=t[n]??i(n<GO),l=(e.light??e.strength*YO)*c;r.color.copy(e.color);let d=e.bounds.getSize(new $).length()/2/u;r.intensity=!e.light&&d>QO?0:l,e.bounds.getCenter(r.position),o.copy(r.position),e.bounds.getSize(s),a.color.copy(e.color),a.intensity=l*XO/u,a.position.copy(r.position),r.castShadow&&(r.shadow.camera.near=u*.005,r.shadow.camera.far=u*4,r.shadow.camera.updateProjectionMatrix(),r.shadow.bias=-.002,r.shadow.normalBias=u*.002,r.shadow.needsUpdate=!0)});t.length>d.length;){let{key:n,bounce:r}=t.pop();e.remove(n,r),n.dispose(),r.dispose()}o(l,d)},c=e=>{for(let{key:n,home:r,size:i}of t)n.position.copy(e(r,i)),n.castShadow&&(n.shadow.needsUpdate=!0)};return{sync:s,jitter:e=>c((t,n)=>r.set(yE(e,2)-.5,yE(e,3)-.5,yE(e,5)-.5).multiply(n).add(t)),settle:()=>c(e=>e),dispose:()=>s(!1)}}var ok=`__selvaLookBaseline`;function sk(e,t){e.color?.setHex(t.color),e.metalness!==void 0&&(e.metalness=t.metalness),e.roughness!==void 0&&(e.roughness=t.roughness),e.emissiveIntensity!==void 0&&(e.emissiveIntensity=t.emissiveIntensity),e.opacity=t.opacity,e.transparent=t.transparent,e.depthWrite=t.depthWrite,e.wireframe!==void 0&&(e.wireframe=t.wireframe),e.side=t.side}function ck(e){let t=e[ok];t&&(sk(e,t),delete e[ok])}function lk(e,t){let n=e;t?(n[ok]?sk(n,n[ok]):n[ok]={color:n.color?.getHex()??16777215,metalness:n.metalness??0,roughness:n.roughness??1,emissiveIntensity:n.emissiveIntensity??0,opacity:n.opacity,transparent:n.transparent,depthWrite:n.depthWrite,wireframe:n.wireframe??!1,side:n.side},t.color!==void 0&&n.color?.setHex(t.color),t.metalness!==void 0&&n.metalness!==void 0&&(n.metalness=t.metalness),t.roughness!==void 0&&n.roughness!==void 0&&(n.roughness=t.roughness),t.emissiveIntensity!==void 0&&n.userData.selvaEmissive&&(n.emissiveIntensity=t.emissiveIntensity),t.opacity!==void 0&&(n.opacity=t.opacity,n.transparent=t.opacity<1),t.depthWrite!==void 0&&(n.depthWrite=t.depthWrite),t.wireframe!==void 0&&n.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(n.side=t.side),n.needsUpdate=!0):(ck(n),n.needsUpdate=!0)}function uk(e,t){if(t.materialOverride)return t.envMapIntensity;let n=e.userData[Ab];if(n!=null)return n;let r=e,i=r[ok]?.metalness??r.metalness??0;return jb(t.envMapIntensity,i,t.metalReflection)}function dk(e,t){return Math.min(e,t.maxPixelRatio??e)}function fk(e){let{scene:t,renderer:n,lights:r,config:i,pipeline:a,fullPixelRatio:o,requestRender:s}=e,c=e=>Db(e,i.render.lowPower),l=i.look,u=ak(t),d=n.shadowMap.type,f=e=>{let t=e.emissiveLights?1:d;n.shadowMap.type!==t&&(n.shadowMap.type=t,n.shadowMap.needsUpdate=!0)},p,m=e=>{e.background===void 0?(p!==void 0&&(t.background=p),p=void 0):(p??=t.background,t.background=new Lf(e.background))};m(c(l)),f(c(l));let h=e=>{e.ambientIntensity!==void 0&&(r.ambient.intensity=e.ambientIntensity),e.hemisphereIntensity!==void 0&&!r.hemisphere&&e.hemisphereIntensity>0&&(r.hemisphere=new lg(e.hemisphereSkyColor??i.lighting.hemisphereSkyColor,e.hemisphereGroundColor??i.lighting.hemisphereGroundColor,e.hemisphereIntensity),r.hemisphere.position.copy(i.environment.sceneUp??pE),t.add(r.hemisphere)),r.hemisphere&&(e.hemisphereIntensity!==void 0&&(r.hemisphere.intensity=e.hemisphereIntensity),e.hemisphereSkyColor!==void 0&&r.hemisphere.color.set(e.hemisphereSkyColor),e.hemisphereGroundColor!==void 0&&r.hemisphere.groundColor.set(e.hemisphereGroundColor)),s()},g=e=>{i.environment.environmentIntensity=e,t.environmentIntensity=e,s()},_=e=>{i.render.toneMappingExposure=e,n.toneMappingExposure=e,a.get()&&a.rebuild()},v=e=>{i.render.aoIntensity=e,a.get()&&a.rebuild()},y=()=>{let{emissiveLights:e,maxEmissiveLights:t,emissiveLightScale:n}=c(l);u.sync(!!e,t,n),s()};return{setFillLights:h,setEnvironmentIntensity:g,setToneMappingExposure:_,setAoIntensity:v,setLook:(e,s)=>{let u=c(e);l=e,n.toneMapping=u.toneMapping,n.toneMappingExposure=u.toneMappingExposure,i.render.toneMapping=u.toneMapping,i.render.toneMappingExposure=u.toneMappingExposure,h({hemisphereIntensity:u.hemisphereIntensity,ambientIntensity:u.ambientIntensity}),g(u.environmentIntensity),r.sun&&(r.sun.intensity=u.sunlightIntensity,i.lighting.sunlightIntensity=u.sunlightIntensity),m(u),f(u),i.render.bloom=u.bloom,i.render.pixelRatio=dk(o,u),a.setAmbientOcclusion(u.ambientOcclusion),t.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,n=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of n)`envMapIntensity`in e&&(e.envMapIntensity=uk(e,u)),lk(e,u.materialOverride)}),sE(t,t),s?.deferEmissiveLights||y()},syncEmissiveLights:y,jitterEmissiveLights:u.jitter,settleEmissiveLights:u.settle,getMaterialAppearance:()=>Mb(l)}}function pk(e,t){let n=t.parentElement,r=n?n.clientWidth:window.innerWidth,i=n?n.clientHeight:window.innerHeight,a=new xg(e.camera.fov,r/i,e.camera.near,e.camera.far),o=e.camera.position;return o&&a.position.set(o.x,o.y,o.z),a}function mk(e){let t=new zf;return t.background=(typeof e.environment.backgroundColor==`string`?new Lf(e.environment.backgroundColor):e.environment.backgroundColor)||null,t}function hk(e,t){Gb(e,t),e.environment?.dispose(),oE(e),e.background instanceof Yd&&e.background.dispose()}var gk={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new Q(1,1)},uColor:{value:new Lf(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
|
|
5672
5672
|
varying vec2 vUv;
|
|
5673
5673
|
void main() {
|
|
5674
5674
|
vUv = uv;
|
|
@@ -5722,7 +5722,7 @@ void main() {
|
|
|
5722
5722
|
float edge = max(depthEdge, normalEdge) * uOpacity;
|
|
5723
5723
|
gl_FragColor = vec4(mix(color.rgb, uColor, edge), color.a);
|
|
5724
5724
|
}
|
|
5725
|
-
`},
|
|
5725
|
+
`},_k=class extends Rw{camera;scene;normalMaterial;edgeMaterial;fsQuad;normalTarget=null;width;height;constructor(e,t,n,r,i={}){super(),this.scene=e,this.camera=t,this.width=Math.max(1,n),this.height=Math.max(1,r),this.normalMaterial=new Oh,this.normalMaterial.blending=0,this.edgeMaterial=new wh({uniforms:xh.clone(gk.uniforms),vertexShader:gk.vertexShader,fragmentShader:gk.fragmentShader});let a=this.edgeMaterial.uniforms;a.uColor.value=new Lf(i.color??2236962),a.uOpacity.value=i.opacity??1,a.uNormalThreshold.value=i.normalThreshold??.4,a.uDepthThreshold.value=i.depthThreshold??.02,a.uThickness.value=i.thickness??1,this.fsQuad=new Vw(this.edgeMaterial),this.needsSwap=!0}acquireNormalTarget(){if(!this.normalTarget){let e=new rh(this.width,this.height);this.normalTarget=new Qd(this.width,this.height,{minFilter:vl,magFilter:vl,depthTexture:e})}return this.normalTarget}setSize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.normalTarget?.setSize(this.width,this.height)}render(e,t,n){let r=this.acquireNormalTarget(),i=e.getRenderTarget(),a=e.autoClear,o=e.getClearColor(new Lf),s=e.getClearAlpha(),c=this.scene.overrideMaterial;e.setRenderTarget(r),e.setClearColor(7829503,1),e.autoClear=!0,this.scene.overrideMaterial=this.normalMaterial;let l=Hb(this.scene);e.render(this.scene,this.camera),l(),this.scene.overrideMaterial=c,e.setClearColor(o,s),e.autoClear=a;let u=this.edgeMaterial.uniforms;u.tDiffuse.value=n.texture,u.tNormal.value=r.texture,u.tDepth.value=r.depthTexture,u.uResolution.value.set(this.width,this.height);let d=this.camera;u.uPerspective.value=+!!d.isPerspectiveCamera,u.uNear.value=this.camera.near??.1,u.uFar.value=this.camera.far??1e3,e.setRenderTarget(this.renderToScreen?null:t),this.fsQuad.render(e),e.setRenderTarget(i)}dispose(){this.normalTarget?.dispose(),this.normalMaterial.dispose(),this.edgeMaterial.dispose(),this.fsQuad.dispose()}},vk={name:`HdrClamp`,uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
5726
5726
|
varying vec2 vUv;
|
|
5727
5727
|
void main() {
|
|
5728
5728
|
vUv = uv;
|
|
@@ -5737,7 +5737,7 @@ void main() {
|
|
|
5737
5737
|
void main() {
|
|
5738
5738
|
vec4 color = texture2D(tDiffuse, vUv);
|
|
5739
5739
|
gl_FragColor = vec4(safe(color.r), safe(color.g), safe(color.b), color.a);
|
|
5740
|
-
}`},
|
|
5740
|
+
}`},yk={vertexShader:`
|
|
5741
5741
|
varying vec2 vUv;
|
|
5742
5742
|
void main() {
|
|
5743
5743
|
vUv = uv;
|
|
@@ -5747,12 +5747,12 @@ void main() {
|
|
|
5747
5747
|
varying vec2 vUv;
|
|
5748
5748
|
void main() {
|
|
5749
5749
|
gl_FragColor = texture2D(tFrame, vUv);
|
|
5750
|
-
}`};function vk(e){let t=new Qd(1,1,{type:jl,depthBuffer:!1}),n=new wh({..._k,uniforms:{tFrame:{value:null}},depthTest:!1,depthWrite:!1,toneMapped:!1,blending:5,blendSrc:213,blendDst:214}),r=new Vw(n),i=(t,i)=>{n.uniforms.tFrame.value=t,n.blendAlpha=i;let a=e.autoClear;e.autoClear=!1,r.render(e),e.autoClear=a},a=()=>{e.setRenderTarget(null),i(t.texture,1)};return{add:(n,r,o,s)=>{(t.width!==o||t.height!==s)&&t.setSize(o,s),e.setRenderTarget(t),i(n,1/(r+1)),a()},present:a,dispose:()=>{t.dispose(),n.dispose(),r.dispose()}}}function yk(e){return e>=2?0:4}function bk(e){let t=e,n=t._overrideVisibility.bind(e),r=t._restoreVisibility.bind(e),i=()=>{};t._overrideVisibility=()=>{n(),i=Hb(e.scene)},t._restoreVisibility=()=>{i(),r()}}function xk(e,t,n,r,i,a){let o=new Qd(r,i,{type:jl}),s=new Gw(e,o);s.renderTarget2.samples=0;let c=e=>{s.readBuffer=o,s.writeBuffer=s.renderTarget2,s.render(e)},l=new Kw(t,n);s.addPass(l);let u=null;(a.ambientOcclusion??!0)&&(u=new nT(t,n,r,i),u.blendIntensity=a.aoIntensity??1,u.updateGtaoMaterial({screenSpaceRadius:!0}),bk(u),s.addPass(u));let d=null,f=null;if(a.bloom){let{strength:e,radius:t,threshold:n}=a.bloom;d=new Hw(gk),s.addPass(d),f=new uT(new Q(r,i),e,t,n),s.addPass(f)}let p=new hk(t,n,r,i,typeof a.edgeDetection==`object`?a.edgeDetection:{});p.enabled=!!a.edgeDetection,s.addPass(p);let m=new oT;s.addPass(m);let h=new cT;s.addPass(h),e.toneMapping=a.toneMapping,e.toneMappingExposure=a.toneMappingExposure;let g=null,_=a.aoPixelRatio??1,v=1;if(u){let e=u.setSize.bind(u);u.setSize=(t,n)=>e(Math.max(1,Math.round(t*v)),Math.max(1,Math.round(n*v)))}let y=e=>{v=Math.min(e,_)/e;let t=yk(e);o.samples!==t&&(o.samples=t,o.dispose()),s.setPixelRatio(e)};return y(e.getPixelRatio()),s.setSize(r,i),{render:c,setSize:(e,t,n)=>{y(n),s.setSize(e,t)},setCamera:e=>{if(l.camera=e,p.camera=e,!u)return;u.camera=e;let t=+!!e.isPerspectiveCamera;u.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==t&&(u.gtaoMaterial.defines.PERSPECTIVE_CAMERA=t,u.gtaoMaterial.needsUpdate=!0)},setEdgeDetection:e=>{p.enabled=e},edgeDetectionEnabled:()=>p.enabled,accumulate:t=>{s.renderToScreen=!1,c(0),s.renderToScreen=!0,g??=vk(e);let{texture:n,width:r,height:i}=s.readBuffer;g.add(n,t,r,i)},presentAccumulated:()=>g?.present(),setAoWeight:e=>{u&&(u.enabled=e>0,u.blendIntensity=(a.aoIntensity??1)*e)},dispose:()=>{s.dispose(),g?.dispose(),u?.dispose(),d?.dispose(),f?.dispose(),p.dispose(),m.dispose(),h.dispose()}}}function Sk(e){let{renderer:t,scene:n,getActiveCamera:r,getCanvasSize:i,config:a,requestRender:o}=e,s=null,c=!!a.render.ambientOcclusion,l=!1,u=()=>({ambientOcclusion:c,bloom:a.render.bloom,toneMapping:a.render.toneMapping,toneMappingExposure:a.render.toneMappingExposure}),d=u(),f=()=>{let e=u();return e.ambientOcclusion!==d.ambientOcclusion||e.bloom!==d.bloom||e.toneMapping!==d.toneMapping||e.toneMappingExposure!==d.toneMappingExposure},p=()=>{let{width:e,height:o}=i(),s=xk(t,n,r(),Math.max(1,e),Math.max(1,o),{toneMapping:a.render.toneMapping??7,toneMappingExposure:a.render.toneMappingExposure??1,ambientOcclusion:c,aoIntensity:a.render.aoIntensity,aoPixelRatio:a.render.aoPixelRatio,bloom:a.render.bloom,edgeDetection:!1});return s.setSize(Math.max(1,e),Math.max(1,o),a.render.pixelRatio),s},m=()=>{c||l||a.render.bloom?((!s||f())&&(s?.dispose(),s=p(),d=u()),s.setEdgeDetection(l),o()):(s?.dispose(),s=null,o())};return{get:()=>s,sync:m,rebuild:()=>{s?.dispose(),s=null,m()},setAmbientOcclusion:e=>{c=e,m()},setEdgeFallback:e=>{e!==l&&(l=e,m())},isEdgeFallbackActive:()=>l,dispose:()=>{s?.dispose(),s=null}}}function Ck(e,t,n){let r=new xT(e,t),i=n.camera.target;return i&&r.target.set(i.x,i.y,i.z),r.enableDamping=n.controls.enableDamping||!1,r.dampingFactor=n.controls.dampingFactor||.05,r.autoRotate=n.controls.autoRotate||!1,r.autoRotateSpeed=n.controls.autoRotateSpeed||.5,r.enableZoom=n.controls.enableZoom??!0,r.enablePan=n.controls.enablePan??!0,r.minDistance=n.controls.minDistance||.001,r.maxDistance=n.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}function wk(e,t,n,r){if(n.environment.enableEnvironmentLighting){if(iE(e,t,dE(n.environment.sceneUp??pE)),n.environment.hdrPath===!1){n.events.onReady?.();return}new PT().load(n.environment.hdrPath||`/baseHDR.hdr`,function(i){if(r()){i.dispose();return}if(!i?.image){Tb().warn(`HDR loaded without image data; skipping environment map.`),i?.dispose(),n.events.onReady?.();return}i.mapping=303;let a=new M_(t);a.compileEquirectangularShader();let o=a.fromEquirectangular(i).texture;a.dispose(),e.environment=o,e.environmentIntensity=n.environment.environmentIntensity??1;let s=dE(n.environment.sceneUp??pE);e.environmentRotation.copy(s),n.environment.showEnvironment?(e.background=i,e.backgroundRotation.copy(s)):i.dispose(),n.events.onReady?.()},void 0,function(e){r()||(Tb().warn(`HDR texture could not be loaded, falling back to basic lighting:`,e),n.events.onReady?.())})}else n.events.onReady?.()}function Tk(e,t){let n=t.floor.size,r=new Om(new ph(n,n),new Eh({color:typeof t.floor.color==`string`?new Lf(t.floor.color):t.floor.color,roughness:t.floor.roughness,metalness:t.floor.metalness,side:2}));r.userData.id=`floor`,r.name=`floor`;let i=(t.environment?.sceneUp||pE).clone().normalize();r.quaternion.setFromUnitVectors(new $(0,0,1),i),r.position.set(0,0,0),t.floor.receiveShadow&&t.render.enableShadows&&(r.receiveShadow=!0),e.add(r)}var Ek=.75,Dk=.6,Ok=.2,kk=1,Ak=`#ffb020`,jk=[8,16],Mk=8,Nk=300,Pk=30,Fk=.35,Ik=new Lf(`#2f7bff`);function Lk(e,t){let n=e.color;return n&&Math.hypot(n.r-t.r,n.g-t.g,n.b-t.b)<Fk?Ik:t}function Rk(e,t,n){let r=Lk(e,t);if(n&&`emissive`in e){let t=e;t.emissive=r.clone(),t.emissiveIntensity=Dk,t.color.lerp(r,Ek),t.metalness=Math.min(t.metalness,Ok),t.opacity<kk&&(t.opacity=kk,t.transparent=!1,t.depthWrite=!0)}else`color`in e&&(e.color=r.clone())}function zk(e,t,n,r,i){let a=new Set,o=new Map,s=[],c=null,l=!1,u=new Yg,d=new Q,f=()=>n.getActiveCamera(),p=()=>{let e=FE(t);e.isEmpty()?Tb().warn(`No objects to fit to view`):n.frameBounds(e,!1)},m=typeof r.events.selectionColor==`string`?new Lf(r.events.selectionColor):r.events.selectionColor instanceof Lf?r.events.selectionColor:new Lf(`#ff0000`),h=new Lf(Ak),g=[],_=[],v=(e,n)=>{let r=e;for(;r.parent;)r=r.parent;r!==t&&(n instanceof Jp?n.dispose():n.forEach(e=>e.dispose()))},y=()=>{for(let{restore:e,material:t}of _)e(),t.dispose();_.length=0;for(let{object:e,original:t}of g){let n=e.material;n instanceof Jp&&n.dispose(),e.material=t,v(e,t)}g.length=0},b=e=>{let t=[],n=new Map;for(let{object:r,memberIndex:i}of e){if(i===null){t.push(r);continue}let e=n.get(r);e||n.set(r,e=new Set),e.add(i)}return{whole:t,membersByMesh:n}},x=(e,t=null)=>{if(y(),!e)return;let n=e instanceof kf?[{object:e,memberIndex:t}]:e,{whole:r,membersByMesh:i}=b(n);for(let[e,t]of i){if(!(e instanceof Om)){r.push(e);continue}let n=ix(e).clone();Rk(n,h,!0),_.push({restore:OD(e,t,n,`hover`),material:n})}for(let e of r){if(a.has(e))continue;let t=e;if(!(t.material instanceof Jp))continue;let n=ax(t.material);Rk(n,h,e instanceof Om),g.push({object:t,original:t.material}),t.material=n}},S=()=>{for(let{restore:e,material:t}of s)e(),t.dispose();s.length=0,a.forEach(e=>{let t=e;if(o.has(e)){let n=o.get(e),r=t.material;r instanceof Jp?r.dispose():Array.isArray(r)&&r.forEach(e=>e.dispose()),t.material=n,o.delete(e),v(e,n)}}),a.clear(),c=null,l=!1},C=(e,t)=>{if(t&&e instanceof Om){let n=ix(e).clone();return Rk(n,m,!0),s.push({restore:OD(e,t,n),material:n}),!0}let n=e;if(!(n.material instanceof Jp))return!1;let r=ax(n.material);return Rk(r,m,e instanceof Om),o.set(e,n.material),n.material=r,!0},w=e=>{let{whole:t,membersByMesh:n}=b(e);for(let e of t)a.add(e),C(e,null);for(let[e,t]of n)a.add(e),C(e,t)},T=e=>{(e.length!==0||l)&&(y(),S(),w(e),l=e.length>0)},E=null,D=-1,O=()=>{if(E===null||t.children.length!==D){let e=FE(t);E=e.isEmpty()?1:e.getSize(new $).length(),D=t.children.length}u.params.Points.threshold=E*.01},k=(t,n)=>{let r=e.getBoundingClientRect();d.x=(t-r.left)/r.width*2-1,d.y=-((n-r.top)/r.height)*2+1},A=(e,n)=>(k(e,n),O(),u.setFromCamera(d,f()),lO(t,u)[0]??null),j=(e,t,n)=>{let r=A(e,t);if(r||!n)return r;for(let n of jk){let r=null;for(let i=0;i<Mk;i++){let a=i/Mk*Math.PI*2,o=A(e+Math.cos(a)*n,t+Math.sin(a)*n);o&&(!r||o.distance<r.distance)&&(r=o)}if(r)return r}return null},M=null,N=e=>{let t=M;if(M={time:e.timeStamp,x:e.clientX,y:e.clientY},!t)return!1;let n=e.timeStamp-t.time<=Nk&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<=Pk;return n&&(M=null),n},P=e=>{if(!i.wasTap())return;let n=i.pointerType()!==`mouse`;if(n&&N(e)){I(e.clientX,e.clientY,!0);return}let a=j(e.clientX,e.clientY,n);if(!a){S(),k(e.clientX,e.clientY),r.events?.onBackgroundClicked?.({x:d.x,y:d.y});return}let o=a.object,s=wD(a),u=s?.index??null;(l||c?.object!==o||c.memberIndex!==u)&&(y(),S(),c={object:o,memberIndex:u},w(ED(t,a)),r.events?.onObjectSelected?.(o),s?r.events?.onMeshMetadataClicked?.({source:o.userData?.source,name:s.member.name,layer:s.member.layer,trackingKey:s.member.trackingKey,metadata:s.member.metadata}):o instanceof Om&&Object.keys(o.userData).length>0&&r.events?.onMeshMetadataClicked?.(o.userData))},F=e=>{i.wasTap()&&i.pointerType()===`mouse`&&I(e.clientX,e.clientY,!1)},I=(e,i,a)=>{let o=j(e,i,a);if(!o){r.events?.enableDoubleClickZoom&&n.frameBounds(FE(t),!0);return}let s=o.object;if(r.events?.onMeshDoubleClicked?.(s),!r.events?.enableDoubleClickZoom)return;let c=new ep;for(let{object:e,memberIndex:n}of ED(t,o)){let t=n===null?null:CD(e)?.[n];c.union(t&&e instanceof Om?DD(e,t):new ep().setFromObject(e))}c.isEmpty()||n.frameBounds(c,!0)},ee=e=>{if(r.events?.enableKeyboardControls)switch(e.key.toLowerCase()){case`f`:e.preventDefault(),p();break;case`escape`:e.preventDefault(),S();break;case` `:e.preventDefault(),p()}};return r.events?.enableClickToFocus&&(e.addEventListener(`click`,P),e.addEventListener(`dblclick`,F)),r.events?.enableKeyboardControls&&(e.setAttribute(`tabindex`,`0`),e.addEventListener(`keydown`,ee)),{dispose:()=>{e.removeEventListener(`click`,P),e.removeEventListener(`dblclick`,F),e.removeEventListener(`keydown`,ee),y(),S()},fitToView:p,clearSelection:S,selectEntries:T,setHover:x}}var Bk=5,Vk=10,Hk=500;function Uk(e){let t=new Map,n=`mouse`,r=0,i=0,a=0,o=!1,s=!1,c=e=>{let n=t.get(e.pointerId);n&&(a=Math.max(a,Math.hypot(e.clientX-n.x,e.clientY-n.y)))},l=e=>{t.size===0&&(n=e.pointerType,r=e.timeStamp,i=0,a=0,o=!1),t.set(e.pointerId,{x:e.clientX,y:e.clientY}),i=Math.max(i,t.size)},u=e=>c(e),d=e=>{if(!t.has(e.pointerId)||(c(e),e.type===`pointercancel`&&(o=!0),t.delete(e.pointerId),t.size>0))return;let l=n===`mouse`;s=!o&&i===1&&a<=(l?Bk:Vk)&&(l||e.timeStamp-r<=Hk)},f={capture:!0,passive:!0};return e.addEventListener(`pointerdown`,l,f),e.addEventListener(`pointermove`,u,f),e.addEventListener(`pointerup`,d,f),e.addEventListener(`pointercancel`,d,f),{wasTap:()=>s,pointerType:()=>n,dispose:()=>{e.removeEventListener(`pointerdown`,l,f),e.removeEventListener(`pointermove`,u,f),e.removeEventListener(`pointerup`,d,f),e.removeEventListener(`pointercancel`,d,f)}}}function Wk(e,t,n){let r=new xb({antialias:t.render.antialias,canvas:e,alpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:t.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),i=e.parentElement,a=i?i.clientWidth:window.innerWidth,o=i?i.clientHeight:window.innerHeight;return i&&(e.style.width=`100%`,e.style.height=`100%`,e.style.display=`block`),r.setSize(a,o,!1),r.setPixelRatio(n),t.render.enableShadows&&(r.shadowMap.enabled=!0,r.shadowMap.type=3),r.toneMapping=t.render.toneMapping,r.toneMappingExposure=t.render.toneMappingExposure??1,r.outputColorSpace=Lu,r.sortObjects=!0,r}var Gk=function(e,t){let n=hE(t||{}),r=n.environment?.sceneUp||pE,i=n.render.pixelRatio??Math.min(window.devicePixelRatio,2),a=lk(i,Db(n.look,n.render.lowPower));n.render.pixelRatio=a;let o=fk(n),s=dk(n,e);s.up.copy(r);let c=Wk(e,n,a);Rb(c.capabilities.getMaxAnisotropy()),t?.onMaxAnisotropy?.(c.capabilities.getMaxAnisotropy());let l=Ck(s,e,n),u=BE({scene:o,perspective:s,controls:l,onActiveCameraChange:()=>{},up:r}),d=()=>u.getActiveCamera(),f=!1;wk(o,c,n,()=>f);let p=DE(o,n),m=p.sun,h=()=>{m&&kE(m,FE(o))};n.floor?.enabled&&Tk(o,n);let g=n.floor?.enabled?o.children.find(e=>e.userData.id===`floor`)??null:null,_=n.grid.enabled?ZD({cellSize:n.grid.cellSize,majorEvery:n.grid.majorEvery,cellColor:n.grid.cellColor,majorColor:n.grid.majorColor,fadeDistance:n.grid.fadeDistance,plane:n.grid.plane}):null;_&&o.add(_.object);let v=()=>{_&&_.fitToContent(FE(o))},y=n.gizmo.enabled?BO({camera:s,domElement:e,controller:u}):null,b=n.grid.plane??fE(r),x=new $(+(b===`x`),+(b===`y`),+(b===`z`)),S=r.clone().normalize(),C=n.camera.dynamicNear?MO({camera:s,scene:o,groundNormals:()=>{let e=[];return _?.object.visible&&e.push(x),n.floor.enabled&&g?.visible&&e.push(S),e}}):null,w=QD(e.parentElement??e,o),T=n.measure.enabled?EO({canvas:e,scene:o,getActiveCamera:d,getViewTarget:()=>l.target,requestRender:()=>j(),labelLayer:w,options:{snapPixels:n.measure.snapPixels,color:n.measure.color,labelClassName:n.measure.labelClassName,displayUnit:n.measure.displayUnit,format:n.measure.format}}):null,E=Uk(e),D=n.events.enableEventHandlers===!1?{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{},selectEntries:()=>{},setHover:()=>{}}:zk(e,o,u,n,E),O=RO();T&&O.register({id:`measure`,tool:T,priority:0}),y&&O.register({id:`gizmo`,tool:y,priority:-100});let k=e=>{E.wasTap()&&O.handleClick(e)&&e.stopImmediatePropagation()};e.addEventListener(`click`,k,{capture:!0});let A=e=>O.handleMove(e);e.addEventListener(`mousemove`,A,{passive:!0});let j=()=>{},M=(e,t)=>{KD(e,{color:n.edges.color,darken:n.edges.darken,width:n.edges.width,thresholdAngle:n.edges.thresholdAngle,distanceFade:n.edges.distanceFade,maxTriangles:n.edges.maxTriangles,maxSegments:n.edges.maxSegments,maxOverlays:n.edges.maxOverlays,...t}).then(()=>{N(e),j()})},N=e=>{if(n.edges.screenSpaceFallback===!1)return;let t=!1;e.traverse(e=>{let n=e.userData?.edgesSkipped;(n===`triangle-cap`||n===`overlay-budget`)&&(t=!0)}),ee.setEdgeFallback(t)},P=e=>{qD(e),ee.setEdgeFallback(!1),j()},F=e.parentElement,I=()=>F?{width:F.clientWidth,height:F.clientHeight}:{width:window.innerWidth,height:window.innerHeight},ee=Sk({renderer:c,scene:o,getActiveCamera:d,getCanvasSize:I,config:n,requestRender:()=>j()});ee.sync();let te=uk({scene:o,renderer:c,lights:p,config:n,pipeline:ee,fullPixelRatio:i,requestRender:()=>j()}),L,R=xE({scene:o,renderer:c,getPipeline:()=>ee.get(),frames:n.render.idleRefineFrames,lightOrbitFrameMs:n.render.lightOrbitFrameMs,jitterLights:e=>{m&&(L=OE(m,e)),te.jitterEmissiveLights(e)},restoreLights:()=>{L?.(),te.settleEmissiveLights()}}),{animate:z,dispose:B,invalidate:ne,renderNow:re}=VO(c,o,s,d,u,l,I,()=>n.render.pixelRatio,n.events.onFrame,_,y,()=>ee.get(),w,C,n.render.onDemand??!0,R);return j=ne,z(),o.up.set(r.x,r.y,r.z),h(),v(),{scene:o,camera:s,controls:l,renderer:c,cameraController:u,grid:_,gizmo:y,measureTool:T,labelLayer:w,tools:O,applyEdges:M,clearEdges:P,invalidate:ne,captureImage:(e=`image/png`,t)=>(re(),new Promise(n=>c.domElement.toBlob(n,e,t))),setAmbientOcclusion:ee.setAmbientOcclusion,setLook:te.setLook,syncEmissiveLights:te.syncEmissiveLights,setFillLights:te.setFillLights,setEnvironmentIntensity:te.setEnvironmentIntensity,setToneMappingExposure:te.setToneMappingExposure,setAoIntensity:te.setAoIntensity,getMaterialAppearance:te.getMaterialAppearance,updateShadowBounds:h,updateGridScale:v,dispose:()=>{f||(f=!0,B(),D.dispose(),E.dispose(),e.removeEventListener(`click`,k,{capture:!0}),e.removeEventListener(`mousemove`,A),T?.dispose(),w?.dispose(),y?.dispose(),_?.dispose(),ee.dispose(),u.dispose(),l.dispose(),c.dispose(),c.forceContextLoss(),pk(o))},fitToView:D.fitToView,clearSelection:D.clearSelection,selectEntries:e=>{D.selectEntries(e),ne()},setHover:(e,t)=>{D.setHover(e,t),ne()},addUserGeometry:(e,t)=>{e.userData.source=t===void 0?IT:RT(t),o.add(e),j()},removeUserGeometry:e=>{e.removeFromParent(),Gb(e),j()},clearUserGeometry:e=>{o.children.filter(t=>VT(t,e)).forEach(e=>{e.removeFromParent(),Gb(e)}),j()}}},Kk=new Set([`grid`,`floor`,`label-layer`,`measure`,`sun-target`]);function qk(e){return!(e instanceof _g)&&!(e instanceof cg)&&!Kk.has(e.userData?.id)}function Jk(e){return e.children.filter(qk)}function Yk(e){return e.replace(/^Line(Segments)?2$/,`Curve`).replace(`Mesh`,``).replace(`Object3D`,`Obj`)||e}function Xk(e){return e.userData?.name||e.userData?.fileName||e.name||Yk(e.type)}function Zk(e){return Yk(e.type)}var Qk=``;function $k(e){let t=e.userData;if(!t)return null;if(typeof t.trackingKey==`string`&&t.trackingKey)return t.trackingKey;if(typeof t.id==`string`&&t.id)return t.id;let n=typeof t.name==`string`?t.name:e.name,r=typeof t.layer==`string`?t.layer:``;return n?`name${Qk}${r}${Qk}${n}`:null}function eA(e){return $k(e)??e.uuid}function tA(e){let t=e.userData?.members;return!Array.isArray(t)||t.length===0?[eA(e)]:t.map((t,n)=>typeof t.trackingKey==`string`&&t.trackingKey?t.trackingKey:t.name?`name${Qk}${t.layer}${Qk}${t.name}`:`${e.uuid}${Qk}${n}`)}function nA(e){let t=e.userData?.members;return Array.isArray(t)&&t.length>0?t:null}var rA=(e,t)=>e.userData?.layer||e.userData?.category||t;function iA(e,t){let n=[],r=new Map,i=e=>{let t=r.get(e)??0;return r.set(e,t+1),t===0?e:`${e}#${t}`},a=new Map,o=(e,t,r,o,s)=>{let c=`${s}\u001f${t}`,l=r?a.get(c):void 0;if(l){l.parts.push(e);return}let u={...e,parts:[e],key:t,rowKey:i(t),label:o,layer:s};r&&a.set(c,u),n.push(u)};for(let n of Jk(e)){let e=nA(n);if(!e){o({object:n,memberIndex:null},eA(n),!!n.userData?.trackingKey,Xk(n),rA(n,t));continue}let r=tA(n);e.forEach((e,i)=>{o({object:n,memberIndex:i},r[i]??`${n.uuid}:${i}`,!!e.trackingKey,e.name||Yk(n.type),e.layer||rA(n,t))})}return n}var aA=`Default`;function oA(e){let t=new Map;for(let n of e){let e=n.userData?.layer||n.userData?.category||`Default`,r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}return t}function sA(e,t){if(!t.trim())return e;let n=t.toLowerCase(),r=new Map;for(let[t,i]of e){let e=t.toLowerCase().includes(n)?i:i.filter(e=>Xk(e).toLowerCase().includes(n));e.length>0&&r.set(t,e)}return r}function cA(e){let t=new Map;for(let n of e){let e=t.get(n.layer);e||(e=[],t.set(n.layer,e)),e.push(n)}return t}function lA(e,t){if(!t.trim())return e;let n=t.toLowerCase(),r=new Map;for(let[t,i]of e){let e=t.toLowerCase().includes(n)?i:i.filter(e=>e.label.toLowerCase().includes(n));e.length>0&&r.set(t,e)}return r}function uA(e,t){let n=e;if(!n.isMesh||!Array.isArray(n.userData?.members))return;let r=new Set;tA(n).forEach((e,n)=>{t.has(e)&&r.add(n)}),rx(n,r)}function dA(e=new Set){let t=t=>tA(t).every(t=>e.has(t)),n={hidden:e,isHidden:t,setVisible(t,n){t.visible=n,t.traverse(e=>{e.visible=n});for(let r of tA(t))n?e.delete(r):e.add(r);uA(t,e)},isEntryHidden:n=>n.memberIndex===null?t(n.object):e.has(n.key),setEntryVisible(t,r){for(let i of t.parts??[t])i.memberIndex===null?n.setVisible(i.object,r):(r?e.delete(t.key):e.add(t.key),uA(i.object,e),r&&!i.object.visible&&i.object.traverse(e=>{e.visible=!0}))},isLayerHidden:e=>e.length>0&&e.every(e=>n.isHidden(e)),isLayerPartial(e){let t=e.filter(e=>n.isHidden(e)).length;return t>0&&t<e.length},toggleLayer(e){let t=n.isLayerHidden(e);for(let r of e)n.setVisible(r,t)},applyTo(n){for(let r of n)uA(r,e),t(r)&&(r.visible=!1,r.traverse(e=>{e.visible=!1}))},reset:()=>e.clear()};return n}function fA(e=new Set){let t=null,n=new Set,r=e=>{t=e;for(let t of n)t(e)};return{selected:e,get anchor(){return t},isSelected:t=>e.has(t),select(n,i,a){if(i.shiftKey&&t){let r=a(),o=r.indexOf(t),s=r.indexOf(n);if(o!==-1&&s!==-1){let[t,n]=o<s?[o,s]:[s,o];i.toggleKey||e.clear();for(let i=t;i<=n;i++)e.add(r[i])}}else i.toggleKey?e.has(n)?e.delete(n):e.add(n):(e.clear(),e.add(n)),r(n)},clear(){e.clear(),r(null)},onAnchorChange(e){return n.add(e),()=>n.delete(e)}}}function pA(e,t={}){let n=t.sets?.collapsed??new Set,r=dA(t.sets?.hidden),i=fA(t.sets?.selected),a={visibility:r,selection:i,collapsed:n,objects:()=>Jk(e),entries:()=>iA(e,aA),entryGroups:(t=``)=>lA(cA(iA(e,aA)),t),layerGroups:(t=``)=>sA(oA(Jk(e)),t),isCollapsed:e=>n.has(e),toggleCollapsed(e){n.has(e)?n.delete(e):n.add(e)},toggleObject(e){if(i.isSelected(e.uuid)&&i.selected.size>1){let e=a.objects().filter(e=>i.isSelected(e.uuid)),t=e.every(e=>r.isHidden(e));for(let n of e)r.setVisible(n,t)}else r.setVisible(e,r.isHidden(e))},toggleEntry(e){if(i.isSelected(e.key)&&i.selected.size>1){let e=a.entries().filter(e=>i.isSelected(e.key)),t=e.every(e=>r.isEntryHidden(e));for(let n of e)r.setEntryVisible(n,t)}else r.setEntryVisible(e,r.isEntryHidden(e))},select(e,t,n){i.select(e,t,()=>a.flatVisibleUuids(n))},onAnchorChange:e=>i.onAnchorChange(e),flatVisibleUuids(e){let t=[];for(let[r,i]of a.entryGroups(e))if(!n.has(r))for(let e of i)t.push(e.key);return t},applyTo(){r.applyTo(a.objects()),i.clear()},reset(){r.reset(),i.clear()}};return a}var mA={},hA=(function(e,t,n,r,i){var a=new Worker(mA[t]||(mA[t]=URL.createObjectURL(new Blob([e+`;addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})`],{type:`text/javascript`}))));return a.onmessage=function(e){var t=e.data,n=t.$e$;if(n){var r=Error(n[0]);r.code=n[1],r.stack=n[2],i(r,null)}else i(null,t)},a.postMessage(n,r),a}),gA=Uint8Array,_A=Uint16Array,vA=Int32Array,yA=new gA([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),bA=new gA([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),xA=new gA([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),SA=function(e,t){for(var n=new _A(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new vA(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},CA=SA(yA,2),wA=CA.b,TA=CA.r;wA[28]=258,TA[258]=28;for(var EA=SA(bA,0),DA=EA.b,OA=EA.r,kA=new _A(32768),AA=0;AA<32768;++AA){var jA=(AA&43690)>>1|(AA&21845)<<1;jA=(jA&52428)>>2|(jA&13107)<<2,jA=(jA&61680)>>4|(jA&3855)<<4,kA[AA]=((jA&65280)>>8|(jA&255)<<8)>>1}for(var MA=(function(e,t,n){for(var r=e.length,i=0,a=new _A(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new _A(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new _A(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[kA[d]>>c]=l}else for(s=new _A(r),i=0;i<r;++i)e[i]&&(s[i]=kA[o[e[i]-1]++]>>15-e[i]);return s}),NA=new gA(288),AA=0;AA<144;++AA)NA[AA]=8;for(var AA=144;AA<256;++AA)NA[AA]=9;for(var AA=256;AA<280;++AA)NA[AA]=7;for(var AA=280;AA<288;++AA)NA[AA]=8;for(var PA=new gA(32),AA=0;AA<32;++AA)PA[AA]=5;var FA=MA(NA,9,0),IA=MA(NA,9,1),LA=MA(PA,5,0),RA=MA(PA,5,1),zA=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},BA=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},VA=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},HA=function(e){return(e+7)/8|0},UA=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new gA(e.subarray(t,n))},WA=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],GA=function(e,t,n){var r=Error(t||WA[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,GA),!n)throw r;return r},KA=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new gA(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new gA(i*3));var l=function(e){var t=n.length;if(e>t){var r=new gA(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=BA(e,d,1);var v=BA(e,d+1,3);if(d+=3,!v){var y=HA(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&GA(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=IA,m=RA,h=9,g=5;else if(v==2){var S=BA(e,d,31)+257,C=BA(e,d+10,15)+4,w=S+BA(e,d+5,31)+1;d+=14;for(var T=new gA(w),E=new gA(19),D=0;D<C;++D)E[xA[D]]=BA(e,d+D*3,7);d+=C*3;for(var O=zA(E),k=(1<<O)-1,A=MA(E,O,1),D=0;D<w;){var j=A[BA(e,d,k)];d+=j&15;var y=j>>4;if(y<16)T[D++]=y;else{var M=0,N=0;for(y==16?(N=3+BA(e,d,3),d+=2,M=T[D-1]):y==17?(N=3+BA(e,d,7),d+=3):y==18&&(N=11+BA(e,d,127),d+=7);N--;)T[D++]=M}}var P=T.subarray(0,S),F=T.subarray(S);h=zA(P),g=zA(F),p=MA(P,h,1),m=MA(F,g,1)}else GA(1);if(d>_){c&&GA(0);break}}s&&l(f+131072);for(var I=(1<<h)-1,ee=(1<<g)-1,te=d;;te=d){var M=p[VA(e,d)&I],L=M>>4;if(d+=M&15,d>_){c&&GA(0);break}if(M||GA(2),L<256)n[f++]=L;else if(L==256){te=d,p=null;break}else{var R=L-254;if(L>264){var D=L-257,z=yA[D];R=BA(e,d,(1<<z)-1)+wA[D],d+=z}var B=m[VA(e,d)&ee],ne=B>>4;B||GA(3),d+=B&15;var F=DA[ne];if(ne>3){var z=bA[ne];F+=VA(e,d)&(1<<z)-1,d+=z}if(d>_){c&&GA(0);break}s&&l(f+131072);var re=f+R;if(f<F){var ie=a-F,ae=Math.min(F,re);for(ie+f<0&&GA(3);f<ae;++f)n[f]=r[ie+f]}for(;f<re;++f)n[f]=n[f-F]}}t.l=p,t.p=te,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?UA(n,0,f):n.subarray(0,f)},qA=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},JA=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},YA=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return{t:nj,l:0};if(i==1){var o=new gA(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,r=1;r<i;++r)a[r].s>f&&(f=a[r].s);var p=new _A(f+1),m=XA(n[u-1],p,0);if(m>t){var r=0,h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<i;++r){var v=a[r].s;if(p[v]>t)h+=_-(1<<m-p[v]),p[v]=t;else break}for(h>>=g;h>0;){var y=a[r].s;p[y]<t?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return{t:new gA(p),l:m}},XA=function(e,t,n){return e.s==-1?Math.max(XA(e.l,t,n+1),XA(e.r,t,n+1)):t[e.s]=n},ZA=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new _A(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},QA=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},$A=function(e,t,n){var r=n.length,i=HA(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},ej=function(e,t,n,r,i,a,o,s,c,l,u){qA(t,u++,n),++i[256];for(var d=YA(i,15),f=d.t,p=d.l,m=YA(a,15),h=m.t,g=m.l,_=ZA(f),v=_.c,y=_.n,b=ZA(h),x=b.c,S=b.n,C=new _A(19),w=0;w<v.length;++w)++C[v[w]&31];for(var w=0;w<x.length;++w)++C[x[w]&31];for(var T=YA(C,7),E=T.t,D=T.l,O=19;O>4&&!E[xA[O-1]];--O);var k=l+5<<3,A=QA(i,NA)+QA(a,PA)+o,j=QA(i,f)+QA(a,h)+o+14+3*O+QA(C,E)+2*C[16]+3*C[17]+7*C[18];if(c>=0&&k<=A&&k<=j)return $A(t,u,e.subarray(c,c+l));var M,N,P,F;if(qA(t,u,1+(j<A)),u+=2,j<A){M=MA(f,p,0),N=f,P=MA(h,g,0),F=h;var I=MA(E,D,0);qA(t,u,y-257),qA(t,u+5,S-1),qA(t,u+10,O-4),u+=14;for(var w=0;w<O;++w)qA(t,u+3*w,E[xA[w]]);u+=3*O;for(var ee=[v,x],te=0;te<2;++te)for(var L=ee[te],w=0;w<L.length;++w){var R=L[w]&31;qA(t,u,I[R]),u+=E[R],R>15&&(qA(t,u,L[w]>>5&127),u+=L[w]>>12)}}else M=FA,N=NA,P=LA,F=PA;for(var w=0;w<s;++w){var z=r[w];if(z>255){var R=z>>18&31;JA(t,u,M[R+257]),u+=N[R+257],R>7&&(qA(t,u,z>>23&31),u+=yA[R]);var B=z&31;JA(t,u,P[B]),u+=F[B],B>3&&(JA(t,u,z>>5&8191),u+=bA[B])}else JA(t,u,M[z]),u+=N[z]}return JA(t,u,M[256]),u+N[256]},tj=new vA([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),nj=new gA(0),rj=function(e,t,n,r,i,a){var o=a.z||e.length,s=new gA(r+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(r,s.length-i),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=tj[t-1],f=d>>13,p=d&8191,m=(1<<n)-1,h=a.p||new _A(32768),g=a.h||new _A(m+1),_=Math.ceil(n/3),v=2*_,y=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&m},b=new vA(25e3),x=new _A(288),S=new _A(32),C=0,w=0,T=a.i||0,E=0,D=a.w||0,O=0;T+2<o;++T){var k=y(T),A=T&32767,j=g[k];if(h[A]=j,g[k]=A,D<=T){var M=o-T;if((C>7e3||E>24576)&&(M>423||!l)){u=ej(e,c,0,b,x,S,w,E,O,T-O,u),E=C=w=0,O=T;for(var N=0;N<286;++N)x[N]=0;for(var N=0;N<30;++N)S[N]=0}var P=2,F=0,I=p,ee=A-j&32767;if(M>2&&k==y(T-ee))for(var te=Math.min(f,M)-1,L=Math.min(32767,T),R=Math.min(258,M);ee<=L&&--I&&A!=j;){if(e[T+P]==e[T+P-ee]){for(var z=0;z<R&&e[T+z]==e[T+z-ee];++z);if(z>P){if(P=z,F=ee,z>te)break;for(var B=Math.min(ee,z-2),ne=0,N=0;N<B;++N){var re=T-ee+N&32767,ie=re-h[re]&32767;ie>ne&&(ne=ie,j=re)}}}A=j,j=h[A],ee+=A-j&32767}if(F){b[E++]=268435456|TA[P]<<18|OA[F];var ae=TA[P]&31,V=OA[F]&31;w+=yA[ae]+bA[V],++x[257+ae],++S[V],D=T+P,++C}else b[E++]=e[T],++x[e[T]]}}for(T=Math.max(T,D);T<o;++T)b[E++]=e[T],++x[e[T]];u=ej(e,c,l,b,x,S,w,E,O,T-O,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=g,a.p=h,a.i=T,a.w=D)}else{for(var T=a.w||0;T<o+l;T+=65535){var H=T+65535;H>=o&&(c[u/8|0]=l,H=o),u=$A(c,u+1,e.subarray(T,H))}a.i=o}return UA(s,0,r+HA(u)+i)},ij=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),aj=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=ij[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},oj=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new gA(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return rj(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},sj=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},cj=function(e,t,n){for(var r=e(),i=e.toString(),a=i.slice(i.indexOf(`[`)+1,i.lastIndexOf(`]`)).replace(/\s+/g,``).split(`,`),o=0;o<r.length;++o){var s=r[o],c=a[o];if(typeof s==`function`){t+=`;`+c+`=`;var l=s.toString();if(s.prototype){if(l.indexOf(`[native code]`)!=-1){var u=l.indexOf(` `,8)+1;t+=l.slice(u,l.indexOf(`(`,u))}else for(var d in t+=l,s.prototype)t+=`;`+c+`.prototype.`+d+`=`+s.prototype[d].toString()}else t+=l}else n[c]=s}return t},lj=[],uj=function(e){var t=[];for(var n in e)e[n].buffer&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t},dj=function(e,t,n,r){if(!lj[n]){for(var i=``,a={},o=e.length-1,s=0;s<o;++s)i=cj(e[s],i,a);lj[n]={c:cj(e[o],i,a),e:a}}var c=sj({},lj[n].e);return hA(lj[n].c+`;onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=`+t.toString()+`}`,n,c,uj(c),r)},fj=function(){return[gA,_A,vA,yA,bA,xA,wA,DA,IA,RA,kA,WA,MA,zA,BA,VA,HA,UA,GA,KA,xj,mj,hj]},pj=function(){return[gA,_A,vA,yA,bA,xA,TA,OA,FA,NA,LA,PA,kA,tj,nj,MA,qA,JA,YA,XA,ZA,QA,$A,ej,HA,UA,rj,oj,yj,mj]},mj=function(e){return postMessage(e,[e.buffer])},hj=function(e){return e&&{out:e.size&&new gA(e.size),dictionary:e.dictionary}},gj=function(e,t,n,r,i,a){var o=dj(n,r,i,function(e,t){o.terminate(),a(e,t)});return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},_j=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function vj(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&GA(7),gj(e,t,[pj],function(e){return mj(yj(e.data[0],e.data[1]))},0,n)}function yj(e,t){return oj(e,t||{},0,0)}function bj(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&GA(7),gj(e,t,[fj],function(e){return mj(xj(e.data[0],hj(e.data[1])))},1,n)}function xj(e,t){return KA(e,{i:2},t&&t.out,t&&t.dictionary)}var Sj=function(e,t,n,r){for(var i in e){var a=e[i],o=t+i,s=r;Array.isArray(a)&&(s=sj(r,a[1]),a=a[0]),ArrayBuffer.isView(a)?n[o]=[a,s]:(n[o+=`/`]=[new gA(0),s],Sj(a,o,n,r))}},Cj=typeof TextEncoder<`u`&&new TextEncoder,wj=typeof TextDecoder<`u`&&new TextDecoder;try{wj.decode(nj,{stream:!0})}catch{}function Tj(e,t){if(t){for(var n=new gA(e.length),r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(Cj)return Cj.encode(e);for(var i=e.length,a=new gA(e.length+(e.length>>1)),o=0,s=function(e){a[o++]=e},r=0;r<i;++r){if(o+5>a.length){var c=new gA(o+8+(i-r<<1));c.set(a),a=c}var l=e.charCodeAt(r);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|e.charCodeAt(++r)&1023,s(240|l>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|l&63)):(s(224|l>>12),s(128|l>>6&63),s(128|l&63))}return UA(a,0,o)}var Ej=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&GA(9),t+=r+4}return t},Dj=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=Ej(l);_j(e,t,o==null?67324752:33639248),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&GA(10),_j(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(_j(e,t,n.crc),_j(e,t+4,a<0?-a-2:a),_j(e,t+8,n.size)),_j(e,t+12,c),_j(e,t+14,d),t+=16,o!=null&&(_j(e,t,u),_j(e,t+6,n.attrs),_j(e,t+10,o),t+=14),e.set(r,t),t+=c,d)for(var m in l){var h=l[m],g=h.length;_j(e,t,+m),_j(e,t+2,g),e.set(h,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},Oj=function(e,t,n,r,i){_j(e,t,101010256),_j(e,t+8,n),_j(e,t+10,n),_j(e,t+12,r),_j(e,t+16,i)};function kj(e,t,n){n||(n=t,t={}),typeof n!=`function`&&GA(7);var r={};Sj(e,``,r,t);var i=Object.keys(r),a=i.length,o=0,s=0,c=a,l=Array(a),u=[],d=function(){for(var e=0;e<u.length;++e)u[e]()},f=function(e,t){Aj(function(){n(e,t)})};Aj(function(){f=n});var p=function(){var e=new gA(s+22),t=o,n=s-o;s=0;for(var r=0;r<c;++r){var i=l[r];try{var a=i.c.length;Dj(e,s,i,i.f,i.u,a);var u=30+i.f.length+Ej(i.extra),d=s+u;e.set(i.c,d),Dj(e,o,i,i.f,i.u,a,s,i.m),o+=16+u+(i.m?i.m.length:0),s=d+a}catch(e){return f(e,null)}}Oj(e,o,l.length,n,t),f(null,e)};a||p();for(var m=function(e){var t=i[e],n=r[t],c=n[0],m=n[1],h=aj(),g=c.length;h.p(c);var _=Tj(t),v=_.length,y=m.comment,b=y&&Tj(y),x=b&&b.length,S=Ej(m.extra),C=m.level==0?0:8,w=function(n,r){if(n)d(),f(n,null);else{var i=r.length;l[e]=sj(m,{size:g,crc:h.d(),c:r,f:_,m:b,u:v!=t.length||b&&y.length!=x,compression:C}),o+=30+v+S+i,s+=76+2*(v+S)+(x||0)+i,--a||p()}};if(v>65535&&w(GA(11,0,1),null),!C)w(null,c);else if(g<16e4)try{w(null,yj(c,m))}catch(e){w(e,null)}else u.push(vj(c,m,w))},h=0;h<c;++h)m(h);return d}var Aj=typeof queueMicrotask==`function`?queueMicrotask:typeof setTimeout==`function`?setTimeout:function(e){e()};function jj(){let e=globalThis.Buffer;return typeof e==`function`?e:void 0}function Mj(e){let t=e.replace(/[\t\n\f\r ]/g,``);return t.length%4==0&&(t=t.replace(/={1,2}$/,``)),t.length%4==1?null:t}function Nj(e){let t=Mj(e),n=t===null?null:Pj(t);if(n===null)throw new Cb(`Invalid base64 input.`,Sb.ENCODING_ERROR,{context:{inputLength:e.length}});return n}function Pj(e){let t=jj();if(t){if(t.byteLength(e,`utf8`)!==e.length||e.includes(`-`)||e.includes(`_`))return null;let n=t.from(e,`base64`);return n.length===Math.floor(e.length*3/4)?n.byteOffset===0&&n.buffer.byteLength===n.length?new Uint8Array(n.buffer,0,n.length):new Uint8Array(n):null}if(typeof globalThis.atob==`function`){let t;try{t=globalThis.atob(e)}catch{return null}let n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e)&255;return n}throw new Cb(`Base64 decoding not supported in this environment.`,Sb.INVALID_STATE,{context:{environmentInfo:`atob or Buffer not available`}})}function Fj(e){return e.map(e=>{let t=e.clone(!0),n=[];e.traverse(e=>n.push(e));let r=0;return t.traverse(e=>{let t=n[r++],i=e;t.geometry&&(i.geometry=t.geometry.clone())}),t})}function Ij(e){e.forEach(e=>Gb(e,{materials:!1}))}function Lj(e){let t=0,n=new Set;for(let r of e)r.traverse(e=>{let r=e.geometry;if(r&&!n.has(r)){n.add(r);for(let e of Object.values(r.attributes))t+=e.array.byteLength;r.index&&(t+=r.index.array.byteLength)}});return t}var Rj={clone:Fj,release:Ij,byteSize:Lj};function zj(e,t){let n=t??1;return{color:new Lf(e??`#ffffff`),transparent:n<1,opacity:n}}var Bj=2,Vj=6;function Hj(e){let t=Uj(e);if(!t)return null;let n=new Mx;n.setPositions(t);let r=zj(e.color,e.opacity),i=new fx({color:r.color}),a=i;a.linewidth=e.width??Bj,a.transparent=r.transparent,a.opacity=r.opacity;let o=new Nx(n,i);return o.computeLineDistances(),o.name=e.name,o.userData={source:`compute`,id:e.id,layer:e.layer,kind:`curve`,metadata:e.metadata},o}function Uj(e){if(!e.points)throw new Cb(`Curve display item '${e.id}' has no tessellated points. It was produced by an outdated Display component — upgrade it in Grasshopper (Solution → Upgrade obsolete components) and re-save the definition.`,Sb.INVALID_CONFIG,{context:{itemId:e.id,kind:e.kind}});return e.points.length>=Vj?e.points:null}function Wj(e){let{position:t}=e;if(!t||typeof t.X!=`number`||!Number.isFinite(t.X)||typeof t.Y!=`number`||!Number.isFinite(t.Y)||typeof t.Z!=`number`||!Number.isFinite(t.Z))return Tb().warn(`Skipping point display item with missing or non-finite position (id: ${String(e.id)}).`),null;let n=new Rp;n.setAttribute(`position`,new Ep([t.X,t.Y,t.Z],3));let r=new $m(n,new Jm({...zj(e.color,e.opacity),size:6,sizeAttenuation:!1}));return r.name=e.name,r.userData={source:`compute`,id:e.id,layer:e.layer,kind:`point`,metadata:e.metadata},r}function Gj(e){if(!e||e.length===0)return[];let t=[];for(let n of e)switch(n.kind){case`curve`:{let e=Hj(n);e&&t.push(e);break}case`point`:{let e=Wj(n);e&&t.push(e);break}default:{let e=n;Tb().warn(`Skipping unknown display item kind: ${String(e.kind)}`);break}}return t}var Kj=1096174675,qj=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;function Jj(e){return typeof e==`string`?Nj(e):e instanceof Uint8Array?e:new Uint8Array(e)}function Yj(e){return e.byteLength>=8&&new DataView(e.buffer,e.byteOffset,8).getUint32(0,!0)===1515605075}function Xj(e){return Yj(e)?new DataView(e.buffer,e.byteOffset,8).getUint32(4,!0):0}function Zj(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(4,!0),n=e.subarray(8),r=Math.max(n.byteLength*1032+1024,1<<20);if(t>r)throw hM(`SLVZ header declares an implausible uncompressed length`,{uncompressedLen:t,deflatedBytes:n.byteLength,maxPlausibleLen:r});return{deflated:n,uncompressedLen:t}}function Qj(e,t){return hM(`Failed to inflate SLVZ blob: ${e instanceof Error?e.message:String(e)}`,{uncompressedLen:t.uncompressedLen,deflatedBytes:t.deflated.byteLength})}function $j(e,t){if(e.byteLength!==t.uncompressedLen)throw hM(`SLVZ payload inflated to a different size than the header declares.`,{declaredLen:t.uncompressedLen,actualLen:e.byteLength,deflatedBytes:t.deflated.byteLength});return e}function eM(e){if(!Yj(e))return e;let t=Zj(e),n;try{n=xj(t.deflated,{out:new Uint8Array(t.uncompressedLen+1)})}catch(e){throw Qj(e,t)}return $j(n,t)}function tM(e){return new Promise((t,n)=>{let r=Zj(e);try{bj(r.deflated,{size:r.uncompressedLen+1},(e,i)=>{if(e)n(Qj(e,r));else try{t($j(i,r))}catch(e){n(e)}})}catch(e){n(Qj(e,r))}})}function nM(e){if(typeof TextDecoder<`u`)return new TextDecoder(`utf-8`).decode(e);if(globalThis.Buffer!==void 0)return globalThis.Buffer.from(e).toString(`utf-8`);throw new Cb(`No UTF-8 decoder available in this environment.`,Sb.INVALID_STATE)}function rM(e,t,n){if(n===0)return new Int16Array;if(t%2==0)return new Int16Array(e,t,n);let r=new Uint8Array(n*2);return r.set(new Uint8Array(e,t,n*2)),new Int16Array(r.buffer)}function iM(e,t,n){if(n===0)return new Float32Array;if(t%4==0)return new Float32Array(e,t,n);let r=new Uint8Array(n*4);return r.set(new Uint8Array(e,t,n*4)),new Float32Array(r.buffer)}function aM(e,t,n){if(n===0)return new Uint16Array;if(t%2==0)return new Uint16Array(e,t,n);let r=new Uint8Array(n*2);return r.set(new Uint8Array(e,t,n*2)),new Uint16Array(r.buffer)}function oM(e,t,n){if(n===0)return new Uint32Array;if(t%4==0)return new Uint32Array(e,t,n);let r=new Uint8Array(n*4);return r.set(new Uint8Array(e,t,n*4)),new Uint32Array(r.buffer)}function sM(e,t){if(e.length!==0&&!(e instanceof Uint16Array&&t>65535)){for(let n=0;n<e.length;n++)if(e[n]>=t)throw hM(`Index out of range of vertexCount.`,{indexPosition:n,indexValue:e[n],vertexCount:t})}}function cM(e){return e>>>1^-(e&1)}function lM(e){let t=new Int16Array(e.length),n=0,r=0,i=0;for(let a=0;a<e.length;a+=3)n=n+cM(e[a])<<16>>16,r=r+cM(e[a+1])<<16>>16,i=i+cM(e[a+2])<<16>>16,t[a]=n,t[a+1]=r,t[a+2]=i;return t}function uM(e,t){let n=new Int16Array(t*3),r=t,i=0,a=0,o=0;for(let t=0;t<r;t++)i=i+cM(e[t]|e[r*3+t]<<8)<<16>>16,a=a+cM(e[r+t]|e[r*4+t]<<8)<<16>>16,o=o+cM(e[r*2+t]|e[r*5+t]<<8)<<16>>16,n[t*3]=i,n[t*3+1]=a,n[t*3+2]=o;return n}function dM(e,t){let n=new Uint16Array(t),r=0;for(let i=0;i<t;i++)r=r+cM(e[i]|e[t+i]<<8)&65535,n[i]=r;return n}function fM(e,t){let n=new Uint32Array(t),r=0;for(let i=0;i<t;i++){let a=(e[i]|e[t+i]<<8|e[t*2+i]<<16|e[t*3+i]<<24)>>>0;r=r+cM(a)>>>0,n[i]=r}return n}function pM(e){let t=new Uint16Array(e.length),n=0;for(let r=0;r<e.length;r++)n=n+cM(e[r])&65535,t[r]=n;return t}function mM(e){let t=new Uint32Array(e.length),n=0;for(let r=0;r<e.length;r++)n=n+cM(e[r])>>>0,t[r]=n;return t}function hM(e,t){return new Cb(e,Sb.VALIDATION_ERROR,{context:t})}var gM=36;function _M(e,t,n,r,i,a=!1){if(n+gM>e.byteLength)throw hM(`Insufficient data to read UV chunk header.`,{expectedBytes:gM,availableBytes:e.byteLength-n,offset:n});let o=t.getUint32(n,!0);n+=4;let s=t.getFloat64(n,!0);n+=8;let c=t.getFloat64(n,!0);n+=8;let l=t.getFloat64(n,!0);n+=8;let u=t.getFloat64(n,!0);n+=8;let d=r*2,f=o===1,p=d*(f?4:2);if(n+p>e.byteLength)throw hM(`Insufficient data to read UV chunk.`,{expectedBytes:p,availableBytes:e.byteLength-n,offset:n,uvFormat:o,vertexCount:r});let m=e.byteOffset+n,h;if(f)h=iM(e.buffer,m,d).slice();else if(a){let t=e.subarray(n,n+p),i=r;h=new Float32Array(d);let a=0,o=0;for(let e=0;e<i;e++)a=a+cM(t[e]|t[i*2+e]<<8)&65535,o=o+cM(t[i+e]|t[i*3+e]<<8)&65535,h[e*2]=s+a*l,h[e*2+1]=c+o*u}else{let t=aM(e.buffer,m,d);h=new Float32Array(d);let n=0,r=0;for(let e=0;e<d;e+=2)i?(n=n+cM(t[e])&65535,r=r+cM(t[e+1])&65535):(n=t[e],r=t[e+1]),h[e]=s+n*l,h[e+1]=c+r*u}return{uvs:h,offset:n+p}}function vM(e,t,n,r){let i=n*3;if(t+i>e.byteLength)throw hM(`Insufficient data to read vertex-color chunk.`,{expectedBytes:i,availableBytes:e.byteLength-t,offset:t,vertexCount:n});let a=e.subarray(t,t+i);if(!r)return a.slice();let o=new Uint8Array(i),s=0,c=0,l=0;for(let e=0;e<i;e+=3)s=s+cM(a[e])&255,c=c+cM(a[e+1])&255,l=l+cM(a[e+2])&255,o[e]=s,o[e+1]=c,o[e+2]=l;return o}var yM=1297040711,bM=1279410516,xM=1280590157,SM=1381516628,CM=1146309699,wM=`id`,TM=`slvm:tex:`,EM=0,DM=1,OM=2;function kM(e){return e.byteLength>=4&&new DataView(e.buffer,e.byteOffset,4).getUint32(0,!0)===1297501267}function AM(e){let t=jM(e),n=null,r=null,i=null,a=null,o=[];for(let{type:e,payload:s}of t)switch(e){case yM:n=s;break;case bM:r=eM(s);break;case xM:i=nM(s);break;case SM:o.push(s);break;case CM:a=eM(s)}if(n===null)throw hM(`SLVM container has no GEOM chunk.`,{chunkCount:t.length});if(r===null)throw hM(`SLVM container has no TABL chunk.`,{chunkCount:t.length});let{groups:s}=PM(r,a),c=FM(i,o);return{geometryBlob:n,metadata:{materials:c,groups:s}}}function jM(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.byteLength<12||t.getUint32(0,!0)!==1297501267)throw hM(`Not an SLVM container (bad magic).`,{byteLength:e.byteLength});let n=t.getUint32(4,!0);if(n!==3)throw hM(`Unsupported SLVM version: ${n}`,{expectedVersion:3});let r=t.getUint32(8,!0),i=[],a=12;for(let n=0;n<r;n++){if(a+8>e.byteLength)throw hM(`Truncated SLVM chunk header.`,{offset:a,chunkIndex:n});let r=t.getUint32(a,!0),o=t.getUint32(a+4,!0);if(a+=8,a+o>e.byteLength)throw hM(`Truncated SLVM chunk payload.`,{offset:a,chunkIndex:n,byteLen:o});i.push({type:r,payload:e.subarray(a,a+o)}),a+=o+(4-o%4)%4}return i}function MM(e){let t=0,n=0;for(;;){if(e.pos>=e.bytes.byteLength||n>28)throw hM(`Malformed varint in SLVM table.`,{pos:e.pos});let r=e.bytes[e.pos++];if(t|=(r&127)<<n,!(r&128))return t>>>0;n+=7}}function NM(e,t,n){let r=e.bytes[e.pos++],i=Array(t);switch(r){case EM:i.fill(``);break;case DM:for(let e=0;e<t;e++)i[e]=String(e+1);break;case OM:for(let r=0;r<t;r++)i[r]=n[MM(e)]??``;break;default:throw hM(`Unknown SLVM string column mode: ${r}`,{pos:e.pos})}return i}function PM(e,t){let n={bytes:e,pos:0},r=MM(n),i=MM(n),a=MM(n),o=r+i+a,s=MM(n),c=Array(s);for(let t=0;t<s;t++){let r=MM(n);c[t]=nM(e.subarray(n.pos,n.pos+r)),n.pos+=r}let l=Array(r),u=Array(r);for(let e=0;e<r;e++)l[e]=MM(n),u[e]=MM(n);for(let e=0;e<i;e++)MM(n);let d=MM(n),f=[];for(let e=0;e<d;e++)f.push({materialId:MM(n),meshCount:MM(n)});let p=NM(n,o,c),m=NM(n,o,c),h=Array(o),g=MM(n);for(let e=0;e<g;e++){let e=c[MM(n)]??``,t=MM(n),r=Array(t),i=0;for(let e=0;e<t;e++)i+=MM(n),r[e]=i;for(let i=0;i<t;i++){let t=c[MM(n)]??``,a=r[i];(h[a]??={})[e]=t}}let _=f.length>0||r===0?f:[{materialId:0,meshCount:r}],v=[],y=0,b=0,x=0;for(let e of _){let n=[];for(let i=0;i<e.meshCount&&y<r;i++,y++){let e=h[y],r=e?.[wM];e!==void 0&&delete e[wM];let i={id:r,name:p[y],layer:m[y],vertexCount:l[y],indexCount:u[y]*3,vertexStart:b,indexStart:x,metadata:e??{}},a=t?.[y];(a===1||a===2)&&(i.closed=a===2),n.push(i),b+=l[y],x+=u[y]*3}v.push({materialId:e.materialId,meshes:n})}return{groups:v}}function FM(e,t){if(e===null)return[];let n;try{n=JSON.parse(e).materials??[]}catch(t){throw hM(`Failed to parse SLVM materials JSON: ${t instanceof Error?t.message:String(t)}`,{byteLength:e.length})}for(let e of n)for(let n of IM){let r=e[n];if(r?.startsWith(TM)){let i=t[Number(r.slice(9))];i!==void 0&&(e[n]=LM(i))}}return n}var IM=[`map`,`roughnessMap`,`normalMap`];function LM(e){let t={bytes:e,pos:0},n=MM(t),r=nM(e.subarray(t.pos,t.pos+n)),i=e.subarray(t.pos+n),a=``,o=32768;for(let e=0;e<i.byteLength;e+=o)a+=String.fromCharCode(...i.subarray(e,e+o));return`data:${r};base64,${btoa(a)}`}function RM(e,t){return new Cb(e,Sb.VALIDATION_ERROR,{context:t})}var zM=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function BM(e,t,n,r){if(!Array.isArray(e))throw RM(`Batch materials must be an array.`,{materials:typeof e});let i=e.findIndex(e=>!zM(e));if(i!==-1)throw RM(`Each material entry must be an object.`,{materialIndex:i});let a=e.length;if(!Array.isArray(t))throw RM(`Batch groups must be an array.`,{groups:typeof t});t.forEach((e,t)=>{if(!zM(e)||!Array.isArray(e.meshes))throw RM(`Each group must be an object with a meshes array.`,{groupIndex:t});if(!e.meshes.every(zM))throw RM(`Each mesh entry must be an object.`,{groupIndex:t})});for(let e of t){if(!Number.isInteger(e.materialId)||e.materialId<0||e.materialId>=a)throw RM(`Group materialId out of range of the materials array.`,{materialId:e.materialId,materialCount:a});for(let t of e.meshes){let e={vertexStart:t.vertexStart,vertexCount:t.vertexCount,indexStart:t.indexStart,indexCount:t.indexCount};for(let[n,r]of Object.entries(e))if(!Number.isInteger(r)||r<0)throw RM(`Mesh metadata field "${n}" must be a non-negative integer.`,{meshName:t.name,field:n,value:r});if(t.vertexStart+t.vertexCount>n)throw RM(`Mesh vertex window exceeds the batch vertex buffer.`,{meshName:t.name,vertexStart:t.vertexStart,vertexCount:t.vertexCount,totalVertexCount:n});if(t.indexStart+t.indexCount>r)throw RM(`Mesh index window exceeds the batch index buffer.`,{meshName:t.name,indexStart:t.indexStart,indexCount:t.indexCount,totalIndexCount:r})}}}function VM(e,t){return RM(`Index references a vertex outside its mesh's vertex window.`,{meshName:t.name,indexValue:e,vertexStart:t.vertexStart,vertexCount:t.vertexCount})}function HM(e,t,n){let r=new Float32Array(e.length),i=t[0],a=t[1],o=t[2],s=n[0],c=n[1],l=n[2];for(let t=0;t<e.length;t+=3)r[t]=i+(e[t]+32767)*s,r[t+1]=a+(e[t+1]+32767)*c,r[t+2]=o+(e[t+2]+32767)*l;return r}function UM(e){let t;t=e.isFloat32?e.vertexData:e.planarByteSplit?uM(e.vertexData,e.vertexCount):e.deltaEncoded?lM(e.vertexData):e.vertexData;let n;if(e.planarByteSplit){let t=e.indexData;n=e.uint16Indices?dM(t,t.length/2):fM(t,t.length/4)}else n=e.deltaEncoded?e.indexData instanceof Uint16Array?pM(e.indexData):mM(e.indexData):e.indexData;return sM(n,e.vertexCount),{metadata:e.metadata,flags:e.flags,vertices:t,indices:n,origin:e.origin,scale:e.scale,uvs:e.uvs,colors:e.colors}}function WM(e){if(!qj)throw new Cb(`SLVA parsing requires a little-endian host: the zero-copy geometry readers view the wire bytes in host byte order.`,Sb.ENVIRONMENT_ERROR);let t=Jj(e);if(kM(t)){let e=AM(t),n=WM(e.geometryBlob);return n.metadata=e.metadata,n}let n=eM(t),r=new DataView(n.buffer,n.byteOffset,n.byteLength);if(n.byteLength<12)throw hM(`Blob too small to contain SLVA header.`,{expectedBytes:12,availableBytes:n.byteLength});let i=0,a=r.getUint32(i,!0);if(i+=4,a!==1096174675)throw hM(`Invalid SLVA magic: 0x${a.toString(16)}`,{expectedMagic:`0x${Kj.toString(16)}`,actualMagic:`0x${a.toString(16)}`});let o=r.getUint32(i,!0);if(i+=4,o<1||o>4)throw hM(`Unsupported SLVA version: ${o}`,{minSupportedVersion:1,maxSupportedVersion:4,actualVersion:o});let s=r.getUint32(i,!0);if(i+=4,i+s>n.byteLength)throw hM(`Insufficient data to read metadata JSON.`,{expectedBytes:s,availableBytes:n.byteLength-i,offset:i});let c=n.subarray(i,i+s);i+=s;let l;try{l=s===0?{}:JSON.parse(nM(c))}catch(e){throw hM(`Failed to parse metadata JSON: ${e instanceof Error?e.message:String(e)}`,{metadataLen:s})}if(!GM(l))throw hM(`Metadata JSON must be an object whose materials and groups are arrays.`,{metadataLen:s});if(i+56>n.byteLength)throw hM(`Insufficient data to read geometry header.`,{expectedBytes:56,availableBytes:n.byteLength-i,offset:i});let u=r.getUint32(i,!0);i+=4;let d=r.getFloat64(i,!0);i+=8;let f=r.getFloat64(i,!0);i+=8;let p=r.getFloat64(i,!0);i+=8;let m=r.getFloat64(i,!0);i+=8;let h=r.getFloat64(i,!0);i+=8;let g=r.getFloat64(i,!0);i+=8;let _=r.getUint32(i,!0);i+=4;let v=!!(u&1),y=!!(u&4),b=!!(u&32),x=_*3,S=x*(v?4:2);if(i+S>n.byteLength)throw hM(`Insufficient data to read vertices.`,{expectedBytes:S,availableBytes:n.byteLength-i,offset:i,useFloat32:v,vertexCount:_});let C=n.byteOffset+i,w;if(w=v?iM(n.buffer,C,x):b?n.subarray(i,i+S):y?aM(n.buffer,C,x):rM(n.buffer,C,x),i+=S,i+4>n.byteLength)throw hM(`Insufficient data to read index count.`,{expectedBytes:4,availableBytes:n.byteLength-i,offset:i});let T=r.getUint32(i,!0);i+=4;let E=!!(u&2),D=T*(E?2:4);if(i+D>n.byteLength)throw hM(`Insufficient data to read indices.`,{expectedBytes:D,availableBytes:n.byteLength-i,offset:i,indexCount:T,useUint16Indices:E});let O=b?n.subarray(i,i+D):E?aM(n.buffer,n.byteOffset+i,T):oM(n.buffer,n.byteOffset+i,T);i+=D;let k=null;if(u&8){let e=_M(n,r,i,_,y,b);k=e.uvs,i=e.offset}let A=null;return u&16&&(A=vM(n,i,_,y)),{metadata:l,flags:u,vertexData:w,indexData:O,isFloat32:v,deltaEncoded:y,planarByteSplit:b,uint16Indices:E,vertexCount:_,origin:[d,f,p],scale:[m,h,g],uvs:k,colors:A}}function GM(e){if(!zM(e))return!1;let{materials:t,groups:n}=e;return(t===void 0||Array.isArray(t))&&(n===void 0||Array.isArray(n))}function KM(e,t,n){if(n.length===0)return!1;let r=e=>{let t=16;for(;t<e*2;)t*=2;return t},i=e.length/3,a=new Int32Array(i),o=new Int32Array(i),s=new Int32Array,c=new Int32Array,l=new Int32Array,u=new Int32Array,d=new Int32Array,f=new Int32Array,p=new Int32Array,m=new Int32Array,h=new Int32Array,g=(e,t)=>e.length>=t?e:new Int32Array(t),_=(n,i,_)=>{if(_<12||_%3!=0)return!1;let v=2*n+1,y=v+1,b=0,x=0;for(let n=0;n<_;n++){let r=t[i+n];a[r]!==v&&(a[r]=v,x++,b=Math.max(b,Math.abs(e[r*3]),Math.abs(e[r*3+1]),Math.abs(e[r*3+2])))}if(!(b>0)||!Number.isFinite(b))return!1;let S=1/(2*2**(Math.floor(Math.log2(b))-23)),C=r(x),w=C-1;s=g(s,C),s.fill(-1,0,C),c=g(c,C),l=g(l,C),u=g(u,C);let T=(e,t,n)=>{let r=Math.imul(e,2654435761)^Math.imul(t,2246822519)^Math.imul(n,3266489917);for(r=(r^r>>>15)&w;s[r]!==-1&&(c[r]!==e||l[r]!==t||u[r]!==n);)r=r+1&w;return r},E=(e,t)=>{let n=e-t;return n>.25?t+1:n<-.25?t-1:t};d=g(d,_),f=g(f,x);let D=0;for(let n=0;n<_;n++){let r=t[i+n];if(a[r]===y){d[n]=o[r];continue}let p=e[r*3]*S,m=e[r*3+1]*S,h=e[r*3+2]*S,g=Math.round(p),_=Math.round(m),v=Math.round(h),b=E(p,g),x=E(m,_),C=E(h,v),w=-1,O=-1;for(let e=0;e<8&&w===-1;e++){if(e&1&&b===g||e&2&&x===_||e&4&&C===v)continue;let t=T(e&1?b:g,e&2?x:_,e&4?C:v);e===0&&(O=t),s[t]!==-1&&(w=s[t])}if(w===-1){let e=O;w=D++,s[e]=w,c[e]=g,l[e]=_,u[e]=v,f[w]=r}a[r]=y,o[r]=w,d[n]=w}p=g(p,D+1),p.fill(0,0,D+1);let O=0;for(let e=0;e<_;e+=3){let t=d[e],n=d[e+1],r=d[e+2];t!==n&&n!==r&&r!==t&&(p[t+1]+=1,p[n+1]+=1,p[r+1]+=1,O++)}if(O<4)return!1;for(let e=0;e<D;e++)p[e+1]+=p[e];m=g(m,p[D]),h=g(h,D),h.set(p.subarray(0,D));for(let e=0;e<_;e+=3){let t=d[e],n=d[e+1],r=d[e+2];t!==n&&n!==r&&r!==t&&(m[h[t]]=n,h[t]+=1,m[h[n]]=r,h[n]+=1,m[h[r]]=t,h[r]+=1)}for(let e=0;e<D;e++){let t=p[e],n=p[e+1];for(let r=t;r<n;r++){let n=m[r];for(let e=t;e<r;e++)if(m[e]===n)return!1;let i=!1;for(let t=p[n],r=p[n+1];t<r&&!i;t++)i=m[t]===e;if(!i)return!1}}let k=f[d[0]]*3,A=e[k],j=e[k+1],M=e[k+2],N=0;for(let t=0;t<_;t+=3){let n=f[d[t]]*3,r=f[d[t+1]]*3,i=f[d[t+2]]*3,a=e[n]-A,o=e[n+1]-j,s=e[n+2]-M,c=e[r]-A,l=e[r+1]-j,u=e[r+2]-M,p=e[i]-A,m=e[i+1]-j,h=e[i+2]-M;N+=a*(l*h-u*m)+o*(u*p-c*h)+s*(c*m-l*p)}return N>0},v=0;for(let e=0;e<n.length;e++){let t=n[e];if(!_(e,v,t))return!1;v+=t}return!0}function qM(e,t,n,r){let i=Math.cos(30*Math.PI/180),a=e.length/3,o=t.length,s=o/3,c=new Uint32Array;{let i=new Uint32Array(e.buffer,e.byteOffset,e.length),s=n?new Uint32Array(n.buffer,n.byteOffset,n.length):null,l=(e,t)=>e[t]===2147483648?0:e[t],u=16;for(;u<a*2;)u*=2;let d=u-1,f=new Int32Array(u).fill(-1),p=new Uint32Array(a),m=!1;for(let e=0;e<a;e++){let t=l(i,e*3),n=l(i,e*3+1),a=l(i,e*3+2),o=Math.imul(t,2654435761)^Math.imul(n,2246822519)^Math.imul(a,3266489917);for(o=(o^o>>>15)&d;;){let c=f[o];if(c===-1){f[o]=e,p[e]=e;break}if(l(i,c*3)===t&&l(i,c*3+1)===n&&l(i,c*3+2)===a&&(!r||r[c*3]===r[e*3]&&r[c*3+1]===r[e*3+1]&&r[c*3+2]===r[e*3+2])&&(!s||s[c*2]===s[e*2]&&s[c*2+1]===s[e*2+1])){p[e]=c,m=!0;break}o=o+1&d}}if(m){for(let e=0;e<o;e++)t[e]=p[t[e]];let e=0;for(let t=0;t<a;t++)p[t]!==t&&e++;c=new Uint32Array(e);for(let e=0,t=0;e<a;e++)p[e]!==e&&(c[t++]=e)}}let l=new Float32Array(s*3),u=new Float32Array(s);for(let n=0;n<s;n++){let r=t[n*3]*3,i=t[n*3+1]*3,a=t[n*3+2]*3,o=e[i]-e[r],s=e[i+1]-e[r+1],c=e[i+2]-e[r+2],d=e[a]-e[r],f=e[a+1]-e[r+1],p=e[a+2]-e[r+2],m=s*p-c*f,h=c*d-o*p,g=o*f-s*d,_=Math.sqrt(m*m+h*h+g*g);_!==0&&(l[n*3]=m/_,l[n*3+1]=h/_,l[n*3+2]=g/_,u[n]=_)}let d=new Uint32Array(a+1);for(let e=0;e<o;e++)d[t[e]+1]+=1;for(let e=0;e<a;e++)d[e+1]+=d[e];let f=new Uint32Array(o),p=d.slice(0,a);for(let e=0;e<o;e++){let n=t[e];f[p[n]]=e,p[n]+=1}let m=0;for(let e=0;e<a;e++)m=Math.max(m,d[e+1]-d[e]);let h=new Uint32Array(o),g=new Uint32Array(a),_=new Float32Array(Math.max(1,m)*3);for(let e=0;e<a;e++){let t=0;for(let n=d[e];n<d[e+1];n++){let e=f[n],r=Math.floor(e/3)*3,a=l[r],o=l[r+1],s=l[r+2],c=-1;if(a===0&&o===0&&s===0)c=0;else for(let e=0;e<t;e++)if(_[e*3]*a+_[e*3+1]*o+_[e*3+2]*s>=i){c=e;break}c===-1&&(c=t,_[t*3]=a,_[t*3+1]=o,_[t*3+2]=s,t++),h[e]=c}g[e]=Math.max(1,t)}let v=new Uint32Array(a+1);for(let e=0;e<a;e++)v[e+1]=v[e]+g[e]-1;let y=v[a],b=a+Math.max(0,y-c.length),x=new Uint32Array(y);for(let e=0;e<y;e++)x[e]=e<c.length?c[e]:a+e-c.length;let S=e,C=n,w=r;if(y>0){S=new Float32Array(b*3),S.set(e),C=n?new Float32Array(b*2):null,C&&n&&C.set(n),w=r?new Uint8Array(b*3):null,w&&r&&w.set(r);for(let t=0;t<a;t++)for(let i=1;i<g[t];i++){let a=x[v[t]+i-1];S[a*3]=e[t*3],S[a*3+1]=e[t*3+1],S[a*3+2]=e[t*3+2],C&&n&&(C[a*2]=n[t*2],C[a*2+1]=n[t*2+1]),w&&r&&(w[a*3]=r[t*3],w[a*3+1]=r[t*3+1],w[a*3+2]=r[t*3+2])}}let T=new Float32Array(b*3);for(let e=0;e<s;e++){let n=u[e],r=l[e*3]*n,i=l[e*3+1]*n,a=l[e*3+2]*n;for(let n=e*3;n<e*3+3;n++){let e=t[n],o=h[n];o!==0&&(e=x[v[e]+o-1],t[n]=e),T[e*3]+=r,T[e*3+1]+=i,T[e*3+2]+=a}}for(let e=0;e<T.length;e+=3){let t=T[e],n=T[e+1],r=T[e+2],i=Math.sqrt(t*t+n*n+r*r)||1;T[e]=t/i,T[e+1]=n/i,T[e+2]=r/i}return{positions:S,normals:T,indices:t,uvs:C,colors:w}}function JM(e,t,n,r){let i=e.length/3,a=new Float32Array(i*3),o=new Float32Array(i*3);for(let t=0;t<n.length;t+=3){let i=n[t],s=n[t+1],c=n[t+2],l=e[s*3]-e[i*3],u=e[s*3+1]-e[i*3+1],d=e[s*3+2]-e[i*3+2],f=e[c*3]-e[i*3],p=e[c*3+1]-e[i*3+1],m=e[c*3+2]-e[i*3+2],h=u*m-d*p,g=d*f-l*m,_=l*p-u*f,v=Math.sqrt(h*h+g*g+_*_);if(v===0)continue;let y=(p*_-m*g)/v,b=(m*h-f*_)/v,x=(f*g-p*h)/v,S=(g*d-_*u)/v,C=(_*l-h*d)/v,w=(h*u-g*l)/v,T=r[s*2]-r[i*2],E=r[c*2]-r[i*2],D=r[s*2+1]-r[i*2+1],O=r[c*2+1]-r[i*2+1],k=T*y+E*S,A=T*b+E*C,j=T*x+E*w,M=D*y+O*S,N=D*b+O*C,P=D*x+O*w;for(let e=0;e<3;e++){let r=n[t+e];a[r*3]+=k,a[r*3+1]+=A,a[r*3+2]+=j,o[r*3]+=M,o[r*3+1]+=N,o[r*3+2]+=P}}let s=new Float32Array(i*4);for(let e=0;e<i;e++){let n=t[e*3],r=t[e*3+1],i=t[e*3+2],c=a[e*3]*n+a[e*3+1]*r+a[e*3+2]*i,l=a[e*3]-c*n,u=a[e*3+1]-c*r,d=a[e*3+2]-c*i,f=Math.sqrt(l*l+u*u+d*d);if(!(f>1e-12)){let e=+(Math.abs(n)<.9),t=1-e;l=t*i,u=-e*i,d=e*r-t*n,f=Math.sqrt(l*l+u*u+d*d)||1}l/=f,u/=f,d/=f;let p=r*d-i*u,m=i*l-n*d,h=n*u-r*l,g=p*o[e*3]+m*o[e*3+1]+h*o[e*3+2];s[e*4]=l,s[e*4+1]=u,s[e*4+2]=d,s[e*4+3]=g<0?-1:1}return s}function YM(e,t){let n=t.every(e=>typeof e.closed==`boolean`)?t.length>0&&t.every(e=>e.closed):KM(e.positions,e.indices,t.map(e=>e.indexCount)),r=qM(e.positions,e.indices,e.uvs,e.colors),i=r.uvs?JM(r.positions,r.normals,r.indices,r.uvs):null;return{...r,closed:n,tangents:i}}function XM(e){let{isFloat32:t,deltaEncoded:n,planarByteSplit:r,uint16Indices:i,origin:a,scale:o,uvs:s,colors:c,jobs:l}=e,u=e=>e>>>1^-(e&1),d;if(t)d=e.vertexData;else{let t;if(r){let n=e.vertexData,r=n.length/6;t=new Int16Array(r*3);let i=0,a=0,o=0;for(let e=0;e<r;e++)i=i+u(n[e]|n[r*3+e]<<8)<<16>>16,a=a+u(n[r+e]|n[r*4+e]<<8)<<16>>16,o=o+u(n[r*2+e]|n[r*5+e]<<8)<<16>>16,t[e*3]=i,t[e*3+1]=a,t[e*3+2]=o}else if(n){let n=e.vertexData;t=new Int16Array(n.length);let r=0,i=0,a=0;for(let e=0;e<n.length;e+=3)r=r+u(n[e])<<16>>16,i=i+u(n[e+1])<<16>>16,a=a+u(n[e+2])<<16>>16,t[e]=r,t[e+1]=i,t[e+2]=a}else t=e.vertexData;d=new Float32Array(t.length);let i=a[0],s=a[1],c=a[2],l=o[0],f=o[1],p=o[2];for(let e=0;e<t.length;e+=3)d[e]=i+(t[e]+32767)*l,d[e+1]=s+(t[e+1]+32767)*f,d[e+2]=c+(t[e+2]+32767)*p}let f;if(r){let t=e.indexData;if(i){let e=t.length/2,n=new Uint16Array(e),r=0;for(let i=0;i<e;i++)r=r+u(t[i]|t[e+i]<<8)&65535,n[i]=r;f=n}else{let e=t.length/4,n=new Uint32Array(e),r=0;for(let i=0;i<e;i++){let a=(t[i]|t[e+i]<<8|t[e*2+i]<<16|t[e*3+i]<<24)>>>0;r=r+u(a)>>>0,n[i]=r}f=n}}else if(n){let t=e.indexData;if(t instanceof Uint16Array){let e=new Uint16Array(t.length),n=0;for(let r=0;r<t.length;r++)n=n+u(t[r])&65535,e[r]=n;f=e}else{let e=new Uint32Array(t.length),n=0;for(let r=0;r<t.length;r++)n=n+u(t[r])>>>0,e[r]=n;f=e}}else f=e.indexData;let p=d.length/3;for(let e=0;e<f.length;e++)if(f[e]>=p)throw Error(`Index ${f[e]} out of range of vertexCount ${p}`);let m=[];for(let e of l){let t=0,n=0;for(let r of e.windows)t+=r.vertexCount,n+=r.indexCount;let r=new Float32Array(t*3),i=new Uint32Array(n),a=s?new Float32Array(t*2):null,o=c?new Uint8Array(t*3):null,l=0,u=0;for(let t of e.windows){let e=t.vertexStart*3;r.set(d.subarray(e,e+t.vertexCount*3),l*3),a&&s&&a.set(s.subarray(t.vertexStart*2,(t.vertexStart+t.vertexCount)*2),l*2),o&&c&&o.set(c.subarray(e,e+t.vertexCount*3),l*3);let n=t.vertexStart,p=t.vertexStart+t.vertexCount,m=l-t.vertexStart;for(let e=0;e<t.indexCount;e++){let r=f[t.indexStart+e];if(r<n||r>=p)throw Error(`Index ${r} outside vertex window [${n}, ${p})`);i[u+e]=r+m}l+=t.vertexCount,u+=t.indexCount}m.push({positions:r,indices:i,uvs:a,colors:o})}return m}function ZM(){return[`const assemble = ${XM.toString()};`,`const isClosedSolid = ${KM.toString()};`,`const splitCreases = ${qM.toString()};`,`const grainTangents = ${JM.toString()};`,`self.onmessage = (event) => {`,` const { id, input } = event.data;`,` try {`,` const geometries = assemble(input).map((g, i) => {`,` const windows = input.jobs[i].windows;`,` const known = windows.every((w) => typeof w.closed === 'boolean');`,` const closed = known`,` ? windows.length > 0 && windows.every((w) => w.closed)`,` : isClosedSolid(g.positions, g.indices, windows.map((w) => w.indexCount));`,` const c = splitCreases(g.positions, g.indices, g.uvs, g.colors);`,` const tangents = c.uvs ? grainTangents(c.positions, c.normals, c.indices, c.uvs) : null;`,` return { ...c, closed, tangents };`,` });`,` const transfer = [];`,` for (const g of geometries) {`,` transfer.push(g.positions.buffer, g.normals.buffer, g.indices.buffer);`,` if (g.uvs) transfer.push(g.uvs.buffer);`,` if (g.tangents) transfer.push(g.tangents.buffer);`,` if (g.colors) transfer.push(g.colors.buffer);`,` }`,` self.postMessage({ id, geometries }, transfer);`,` } catch (error) {`,` self.postMessage({ id, error: String((error && error.message) || error) });`,` }`,`};`].join(`
|
|
5751
|
-
`)}var
|
|
5752
|
-
float cell = floor( uv.y / ${
|
|
5753
|
-
float plank = cell + ( uv.y < ${
|
|
5754
|
-
float lo = ${
|
|
5755
|
-
float hi = ${
|
|
5750
|
+
}`};function bk(e){let t=new Qd(1,1,{type:jl,depthBuffer:!1}),n=new wh({...yk,uniforms:{tFrame:{value:null}},depthTest:!1,depthWrite:!1,toneMapped:!1,blending:5,blendSrc:213,blendDst:214}),r=new Vw(n),i=(t,i)=>{n.uniforms.tFrame.value=t,n.blendAlpha=i;let a=e.autoClear;e.autoClear=!1,r.render(e),e.autoClear=a},a=()=>{e.setRenderTarget(null),i(t.texture,1)};return{add:(n,r,o,s)=>{(t.width!==o||t.height!==s)&&t.setSize(o,s),e.setRenderTarget(t),i(n,1/(r+1)),a()},present:a,dispose:()=>{t.dispose(),n.dispose(),r.dispose()}}}function xk(e){return e>=2?0:4}function Sk(e){let t=e,n=t._overrideVisibility.bind(e),r=t._restoreVisibility.bind(e),i=()=>{};t._overrideVisibility=()=>{n(),i=Hb(e.scene)},t._restoreVisibility=()=>{i(),r()}}function Ck(e,t,n,r,i,a){let o=new Qd(r,i,{type:jl}),s=new Gw(e,o);s.renderTarget2.samples=0;let c=e=>{s.readBuffer=o,s.writeBuffer=s.renderTarget2,s.render(e)},l=new Kw(t,n);s.addPass(l);let u=null;(a.ambientOcclusion??!0)&&(u=new nT(t,n,r,i),u.blendIntensity=a.aoIntensity??1,u.updateGtaoMaterial({screenSpaceRadius:!0}),Sk(u),s.addPass(u));let d=null,f=null;if(a.bloom){let{strength:e,radius:t,threshold:n}=a.bloom;d=new Hw(vk),s.addPass(d),f=new uT(new Q(r,i),e,t,n),s.addPass(f)}let p=new _k(t,n,r,i,typeof a.edgeDetection==`object`?a.edgeDetection:{});p.enabled=!!a.edgeDetection,s.addPass(p);let m=new oT;s.addPass(m);let h=new cT;s.addPass(h),e.toneMapping=a.toneMapping,e.toneMappingExposure=a.toneMappingExposure;let g=null,_=a.aoPixelRatio??1,v=1;if(u){let e=u.setSize.bind(u);u.setSize=(t,n)=>e(Math.max(1,Math.round(t*v)),Math.max(1,Math.round(n*v)))}let y=e=>{v=Math.min(e,_)/e;let t=xk(e);o.samples!==t&&(o.samples=t,o.dispose()),s.setPixelRatio(e)};return y(e.getPixelRatio()),s.setSize(r,i),{render:c,setSize:(e,t,n)=>{y(n),s.setSize(e,t)},setCamera:e=>{if(l.camera=e,p.camera=e,!u)return;u.camera=e;let t=+!!e.isPerspectiveCamera;u.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==t&&(u.gtaoMaterial.defines.PERSPECTIVE_CAMERA=t,u.gtaoMaterial.needsUpdate=!0)},setEdgeDetection:e=>{p.enabled=e},edgeDetectionEnabled:()=>p.enabled,accumulate:t=>{s.renderToScreen=!1,c(0),s.renderToScreen=!0,g??=bk(e);let{texture:n,width:r,height:i}=s.readBuffer;g.add(n,t,r,i)},presentAccumulated:()=>g?.present(),setAoWeight:e=>{u&&(u.enabled=e>0,u.blendIntensity=(a.aoIntensity??1)*e)},dispose:()=>{s.dispose(),g?.dispose(),u?.dispose(),d?.dispose(),f?.dispose(),p.dispose(),m.dispose(),h.dispose()}}}function wk(e){let{renderer:t,scene:n,getActiveCamera:r,getCanvasSize:i,config:a,requestRender:o}=e,s=null,c=!!a.render.ambientOcclusion,l=!1,u=()=>({ambientOcclusion:c,bloom:a.render.bloom,toneMapping:a.render.toneMapping,toneMappingExposure:a.render.toneMappingExposure}),d=u(),f=()=>{let e=u();return e.ambientOcclusion!==d.ambientOcclusion||e.bloom!==d.bloom||e.toneMapping!==d.toneMapping||e.toneMappingExposure!==d.toneMappingExposure},p=()=>{let{width:e,height:o}=i(),s=Ck(t,n,r(),Math.max(1,e),Math.max(1,o),{toneMapping:a.render.toneMapping??7,toneMappingExposure:a.render.toneMappingExposure??1,ambientOcclusion:c,aoIntensity:a.render.aoIntensity,aoPixelRatio:a.render.aoPixelRatio,bloom:a.render.bloom,edgeDetection:!1});return s.setSize(Math.max(1,e),Math.max(1,o),a.render.pixelRatio),s},m=()=>{c||l||a.render.bloom?((!s||f())&&(s?.dispose(),s=p(),d=u()),s.setEdgeDetection(l),o()):(s?.dispose(),s=null,o())};return{get:()=>s,sync:m,rebuild:()=>{s?.dispose(),s=null,m()},setAmbientOcclusion:e=>{c=e,m()},setEdgeFallback:e=>{e!==l&&(l=e,m())},isEdgeFallbackActive:()=>l,dispose:()=>{s?.dispose(),s=null}}}function Tk(e,t,n){let r=new xT(e,t),i=n.camera.target;return i&&r.target.set(i.x,i.y,i.z),r.enableDamping=n.controls.enableDamping||!1,r.dampingFactor=n.controls.dampingFactor||.05,r.autoRotate=n.controls.autoRotate||!1,r.autoRotateSpeed=n.controls.autoRotateSpeed||.5,r.enableZoom=n.controls.enableZoom??!0,r.enablePan=n.controls.enablePan??!0,r.minDistance=n.controls.minDistance||.001,r.maxDistance=n.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}function Ek(e,t,n,r){if(n.environment.enableEnvironmentLighting){if(iE(e,t,dE(n.environment.sceneUp??pE)),n.environment.hdrPath===!1){n.events.onReady?.();return}new PT().load(n.environment.hdrPath||`/baseHDR.hdr`,function(i){if(r()){i.dispose();return}if(!i?.image){Tb().warn(`HDR loaded without image data; skipping environment map.`),i?.dispose(),n.events.onReady?.();return}i.mapping=303;let a=new M_(t);a.compileEquirectangularShader();let o=a.fromEquirectangular(i).texture;a.dispose(),e.environment=o,e.environmentIntensity=n.environment.environmentIntensity??1;let s=dE(n.environment.sceneUp??pE);e.environmentRotation.copy(s),n.environment.showEnvironment?(e.background=i,e.backgroundRotation.copy(s)):i.dispose(),n.events.onReady?.()},void 0,function(e){r()||(Tb().warn(`HDR texture could not be loaded, falling back to basic lighting:`,e),n.events.onReady?.())})}else n.events.onReady?.()}function Dk(e,t){let n=t.floor.size,r=new Om(new ph(n,n),new Eh({color:typeof t.floor.color==`string`?new Lf(t.floor.color):t.floor.color,roughness:t.floor.roughness,metalness:t.floor.metalness,side:2}));r.userData.id=`floor`,r.name=`floor`;let i=(t.environment?.sceneUp||pE).clone().normalize();r.quaternion.setFromUnitVectors(new $(0,0,1),i),r.position.set(0,0,0),t.floor.receiveShadow&&t.render.enableShadows&&(r.receiveShadow=!0),e.add(r)}var Ok=.75,kk=.6,Ak=.2,jk=1,Mk=`#ffb020`,Nk=[8,16],Pk=8,Fk=300,Ik=30,Lk=.35,Rk=new Lf(`#2f7bff`);function zk(e,t){let n=e.color;return n&&Math.hypot(n.r-t.r,n.g-t.g,n.b-t.b)<Lk?Rk:t}function Bk(e,t,n){let r=zk(e,t);if(n&&`emissive`in e){let t=e;t.emissive=r.clone(),t.emissiveIntensity=kk,t.color.lerp(r,Ok),t.metalness=Math.min(t.metalness,Ak),t.opacity<jk&&(t.opacity=jk,t.transparent=!1,t.depthWrite=!0)}else`color`in e&&(e.color=r.clone())}function Vk(e,t,n,r,i){let a=new Set,o=new Map,s=[],c=null,l=!1,u=new Yg,d=new Q,f=()=>n.getActiveCamera(),p=()=>{let e=FE(t);e.isEmpty()?Tb().warn(`No objects to fit to view`):n.frameBounds(e,!1)},m=typeof r.events.selectionColor==`string`?new Lf(r.events.selectionColor):r.events.selectionColor instanceof Lf?r.events.selectionColor:new Lf(`#ff0000`),h=new Lf(Mk),g=[],_=[],v=(e,n)=>{let r=e;for(;r.parent;)r=r.parent;r!==t&&(n instanceof Jp?n.dispose():n.forEach(e=>e.dispose()))},y=()=>{for(let{restore:e,material:t}of _)e(),t.dispose();_.length=0;for(let{object:e,original:t}of g){let n=e.material;n instanceof Jp&&n.dispose(),e.material=t,v(e,t)}g.length=0},b=e=>{let t=[],n=new Map;for(let{object:r,memberIndex:i}of e){if(i===null){t.push(r);continue}let e=n.get(r);e||n.set(r,e=new Set),e.add(i)}return{whole:t,membersByMesh:n}},x=(e,t=null)=>{if(y(),!e)return;let n=e instanceof kf?[{object:e,memberIndex:t}]:e,{whole:r,membersByMesh:i}=b(n);for(let[e,t]of i){if(!(e instanceof Om)){r.push(e);continue}let n=ix(e).clone();Bk(n,h,!0),_.push({restore:AD(e,t,n,`hover`),material:n})}for(let e of r){if(a.has(e))continue;let t=e;if(!(t.material instanceof Jp))continue;let n=ax(t.material);Bk(n,h,e instanceof Om),g.push({object:t,original:t.material}),t.material=n}},S=()=>{for(let{restore:e,material:t}of s)e(),t.dispose();s.length=0,a.forEach(e=>{let t=e;if(o.has(e)){let n=o.get(e),r=t.material;r instanceof Jp?r.dispose():Array.isArray(r)&&r.forEach(e=>e.dispose()),t.material=n,o.delete(e),v(e,n)}}),a.clear(),c=null,l=!1},C=(e,t)=>{if(t&&e instanceof Om){let n=ix(e).clone();return Bk(n,m,!0),s.push({restore:AD(e,t,n),material:n}),!0}let n=e;if(!(n.material instanceof Jp))return!1;let r=ax(n.material);return Bk(r,m,e instanceof Om),o.set(e,n.material),n.material=r,!0},w=e=>{let{whole:t,membersByMesh:n}=b(e);for(let e of t)a.add(e),C(e,null);for(let[e,t]of n)a.add(e),C(e,t)},T=e=>{(e.length!==0||l)&&(y(),S(),w(e),l=e.length>0)},E=null,D=-1,O=()=>{if(E===null||t.children.length!==D){let e=FE(t);E=e.isEmpty()?1:e.getSize(new $).length(),D=t.children.length}u.params.Points.threshold=E*.01},k=(t,n)=>{let r=e.getBoundingClientRect();d.x=(t-r.left)/r.width*2-1,d.y=-((n-r.top)/r.height)*2+1},A=(e,n)=>(k(e,n),O(),u.setFromCamera(d,f()),dO(t,u)[0]??null),j=(e,t,n)=>{let r=A(e,t);if(r||!n)return r;for(let n of Nk){let r=null;for(let i=0;i<Pk;i++){let a=i/Pk*Math.PI*2,o=A(e+Math.cos(a)*n,t+Math.sin(a)*n);o&&(!r||o.distance<r.distance)&&(r=o)}if(r)return r}return null},M=null,N=e=>{let t=M;if(M={time:e.timeStamp,x:e.clientX,y:e.clientY},!t)return!1;let n=e.timeStamp-t.time<=Fk&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<=Ik;return n&&(M=null),n},P=e=>{if(!i.wasTap())return;let n=i.pointerType()!==`mouse`;if(n&&N(e)){ee(e.clientX,e.clientY,!0);return}let a=j(e.clientX,e.clientY,n);if(!a){S(),k(e.clientX,e.clientY),r.events?.onBackgroundClicked?.({x:d.x,y:d.y});return}let o=a.object,s=ED(a),u=s?.index??null;(l||c?.object!==o||c.memberIndex!==u)&&(y(),S(),c={object:o,memberIndex:u},w(OD(t,a)),r.events?.onObjectSelected?.(o),s?r.events?.onMeshMetadataClicked?.({source:o.userData?.source,name:s.member.name,layer:s.member.layer,trackingKey:s.member.trackingKey,metadata:s.member.metadata}):o instanceof Om&&Object.keys(o.userData).length>0&&r.events?.onMeshMetadataClicked?.(o.userData))},F=e=>{i.wasTap()&&i.pointerType()===`mouse`&&ee(e.clientX,e.clientY,!1)},ee=(e,i,a)=>{let o=j(e,i,a);if(!o){r.events?.enableDoubleClickZoom&&n.frameBounds(FE(t),!0);return}let s=o.object;if(r.events?.onMeshDoubleClicked?.(s),!r.events?.enableDoubleClickZoom)return;let c=new ep;for(let{object:e,memberIndex:n}of OD(t,o)){let t=n===null?null:TD(e)?.[n];c.union(t&&e instanceof Om?kD(e,t):new ep().setFromObject(e))}c.isEmpty()||n.frameBounds(c,!0)},te=e=>{if(r.events?.enableKeyboardControls)switch(e.key.toLowerCase()){case`f`:e.preventDefault(),p();break;case`escape`:e.preventDefault(),S();break;case` `:e.preventDefault(),p()}};return r.events?.enableClickToFocus&&(e.addEventListener(`click`,P),e.addEventListener(`dblclick`,F)),r.events?.enableKeyboardControls&&(e.setAttribute(`tabindex`,`0`),e.addEventListener(`keydown`,te)),{dispose:()=>{e.removeEventListener(`click`,P),e.removeEventListener(`dblclick`,F),e.removeEventListener(`keydown`,te),y(),S()},fitToView:p,clearSelection:S,selectEntries:T,setHover:x}}var Hk=5,Uk=10,Wk=500;function Gk(e){let t=new Map,n=`mouse`,r=0,i=0,a=0,o=!1,s=!1,c=e=>{let n=t.get(e.pointerId);n&&(a=Math.max(a,Math.hypot(e.clientX-n.x,e.clientY-n.y)))},l=e=>{t.size===0&&(n=e.pointerType,r=e.timeStamp,i=0,a=0,o=!1),t.set(e.pointerId,{x:e.clientX,y:e.clientY}),i=Math.max(i,t.size)},u=e=>c(e),d=e=>{if(!t.has(e.pointerId)||(c(e),e.type===`pointercancel`&&(o=!0),t.delete(e.pointerId),t.size>0))return;let l=n===`mouse`;s=!o&&i===1&&a<=(l?Hk:Uk)&&(l||e.timeStamp-r<=Wk)},f={capture:!0,passive:!0};return e.addEventListener(`pointerdown`,l,f),e.addEventListener(`pointermove`,u,f),e.addEventListener(`pointerup`,d,f),e.addEventListener(`pointercancel`,d,f),{wasTap:()=>s,pointerType:()=>n,dispose:()=>{e.removeEventListener(`pointerdown`,l,f),e.removeEventListener(`pointermove`,u,f),e.removeEventListener(`pointerup`,d,f),e.removeEventListener(`pointercancel`,d,f)}}}function Kk(e,t,n){let r=new xb({antialias:t.render.antialias,canvas:e,alpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:t.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),i=e.parentElement,a=i?i.clientWidth:window.innerWidth,o=i?i.clientHeight:window.innerHeight;return i&&(e.style.width=`100%`,e.style.height=`100%`,e.style.display=`block`),r.setSize(a,o,!1),r.setPixelRatio(n),t.render.enableShadows&&(r.shadowMap.enabled=!0,r.shadowMap.type=3),r.toneMapping=t.render.toneMapping,r.toneMappingExposure=t.render.toneMappingExposure??1,r.outputColorSpace=Lu,r.sortObjects=!0,r}var qk=function(e,t){let n=hE(t||{}),r=n.environment?.sceneUp||pE,i=n.render.pixelRatio??Math.min(window.devicePixelRatio,2),a=dk(i,Db(n.look,n.render.lowPower));n.render.pixelRatio=a;let o=mk(n),s=pk(n,e);s.up.copy(r);let c=Kk(e,n,a);Rb(c.capabilities.getMaxAnisotropy()),t?.onMaxAnisotropy?.(c.capabilities.getMaxAnisotropy());let l=Tk(s,e,n),u=BE({scene:o,perspective:s,controls:l,onActiveCameraChange:()=>{},up:r}),d=()=>u.getActiveCamera(),f=!1;Ek(o,c,n,()=>f);let p=DE(o,n),m=p.sun,h=()=>{m&&kE(m,FE(o))};n.floor?.enabled&&Dk(o,n);let g=n.floor?.enabled?o.children.find(e=>e.userData.id===`floor`)??null:null,_=n.grid.enabled?$D({cellSize:n.grid.cellSize,majorEvery:n.grid.majorEvery,cellColor:n.grid.cellColor,majorColor:n.grid.majorColor,fadeDistance:n.grid.fadeDistance,plane:n.grid.plane}):null;_&&o.add(_.object);let v=()=>{_&&_.fitToContent(FE(o))},y=n.gizmo.enabled?HO({camera:s,domElement:e,controller:u}):null,b=n.grid.plane??fE(r),x=new $(+(b===`x`),+(b===`y`),+(b===`z`)),S=r.clone().normalize(),C=n.camera.dynamicNear?PO({camera:s,scene:o,groundNormals:()=>{let e=[];return _?.object.visible&&e.push(x),n.floor.enabled&&g?.visible&&e.push(S),e}}):null,w=eO(e.parentElement??e,o),T=n.measure.enabled?OO({canvas:e,scene:o,getActiveCamera:d,getViewTarget:()=>l.target,requestRender:()=>j(),labelLayer:w,options:{snapPixels:n.measure.snapPixels,color:n.measure.color,labelClassName:n.measure.labelClassName,displayUnit:n.measure.displayUnit,format:n.measure.format}}):null,E=Gk(e),D=n.events.enableEventHandlers===!1?{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{},selectEntries:()=>{},setHover:()=>{}}:Vk(e,o,u,n,E),O=BO();T&&O.register({id:`measure`,tool:T,priority:0}),y&&O.register({id:`gizmo`,tool:y,priority:-100});let k=e=>{E.wasTap()&&O.handleClick(e)&&e.stopImmediatePropagation()};e.addEventListener(`click`,k,{capture:!0});let A=e=>O.handleMove(e);e.addEventListener(`mousemove`,A,{passive:!0});let j=()=>{},M=(e,t)=>{JD(e,{color:n.edges.color,darken:n.edges.darken,width:n.edges.width,thresholdAngle:n.edges.thresholdAngle,distanceFade:n.edges.distanceFade,maxTriangles:n.edges.maxTriangles,maxSegments:n.edges.maxSegments,maxOverlays:n.edges.maxOverlays,...t}).then(()=>{N(e),j()})},N=e=>{if(n.edges.screenSpaceFallback===!1)return;let t=!1;e.traverse(e=>{let n=e.userData?.edgesSkipped;(n===`triangle-cap`||n===`overlay-budget`)&&(t=!0)}),te.setEdgeFallback(t)},P=e=>{YD(e),te.setEdgeFallback(!1),j()},F=e.parentElement,ee=()=>F?{width:F.clientWidth,height:F.clientHeight}:{width:window.innerWidth,height:window.innerHeight},te=wk({renderer:c,scene:o,getActiveCamera:d,getCanvasSize:ee,config:n,requestRender:()=>j()});te.sync();let ne=fk({scene:o,renderer:c,lights:p,config:n,pipeline:te,fullPixelRatio:i,requestRender:()=>j()}),I,L=xE({scene:o,renderer:c,getPipeline:()=>te.get(),frames:n.render.idleRefineFrames,lightOrbitFrameMs:n.render.lightOrbitFrameMs,jitterLights:e=>{m&&(I=OE(m,e)),ne.jitterEmissiveLights(e)},restoreLights:()=>{I?.(),ne.settleEmissiveLights()}}),{animate:R,dispose:z,invalidate:re,renderNow:B}=UO(c,o,s,d,u,l,ee,()=>n.render.pixelRatio,n.events.onFrame,_,y,()=>te.get(),w,C,n.render.onDemand??!0,L);return j=re,R(),o.up.set(r.x,r.y,r.z),h(),v(),{scene:o,camera:s,controls:l,renderer:c,cameraController:u,grid:_,gizmo:y,measureTool:T,labelLayer:w,tools:O,applyEdges:M,clearEdges:P,invalidate:re,captureImage:(e=`image/png`,t)=>(B(),new Promise(n=>c.domElement.toBlob(n,e,t))),setAmbientOcclusion:te.setAmbientOcclusion,setLook:ne.setLook,syncEmissiveLights:ne.syncEmissiveLights,setFillLights:ne.setFillLights,setEnvironmentIntensity:ne.setEnvironmentIntensity,setToneMappingExposure:ne.setToneMappingExposure,setAoIntensity:ne.setAoIntensity,getMaterialAppearance:ne.getMaterialAppearance,updateShadowBounds:h,updateGridScale:v,dispose:()=>{f||(f=!0,z(),D.dispose(),E.dispose(),e.removeEventListener(`click`,k,{capture:!0}),e.removeEventListener(`mousemove`,A),T?.dispose(),w?.dispose(),y?.dispose(),_?.dispose(),te.dispose(),u.dispose(),l.dispose(),c.dispose(),c.forceContextLoss(),hk(o))},fitToView:D.fitToView,clearSelection:D.clearSelection,selectEntries:e=>{D.selectEntries(e),re()},setHover:(e,t)=>{D.setHover(e,t),re()},addUserGeometry:(e,t)=>{e.userData.source=t===void 0?IT:RT(t),o.add(e),j()},removeUserGeometry:e=>{e.removeFromParent(),Gb(e),j()},clearUserGeometry:e=>{o.children.filter(t=>VT(t,e)).forEach(e=>{e.removeFromParent(),Gb(e)}),j()}}},Jk=new Set([`grid`,`floor`,`label-layer`,`measure`,`sun-target`]);function Yk(e){return!(e instanceof _g)&&!(e instanceof cg)&&!Jk.has(e.userData?.id)}function Xk(e){return e.children.filter(Yk)}function Zk(e){return e.replace(/^Line(Segments)?2$/,`Curve`).replace(`Mesh`,``).replace(`Object3D`,`Obj`)||e}function Qk(e){return e.userData?.name||e.userData?.fileName||e.name||Zk(e.type)}function $k(e){return Zk(e.type)}var eA=``;function tA(e){let t=e.userData;if(!t)return null;if(typeof t.trackingKey==`string`&&t.trackingKey)return t.trackingKey;if(typeof t.id==`string`&&t.id)return t.id;let n=typeof t.name==`string`?t.name:e.name,r=typeof t.layer==`string`?t.layer:``;return n?`name${eA}${r}${eA}${n}`:null}function nA(e){return tA(e)??e.uuid}function rA(e){let t=e.userData?.members;return!Array.isArray(t)||t.length===0?[nA(e)]:t.map((t,n)=>typeof t.trackingKey==`string`&&t.trackingKey?t.trackingKey:t.name?`name${eA}${t.layer}${eA}${t.name}`:`${e.uuid}${eA}${n}`)}function iA(e){let t=e.userData?.members;return Array.isArray(t)&&t.length>0?t:null}var aA=(e,t)=>e.userData?.layer||e.userData?.category||t;function oA(e,t){let n=[],r=new Map,i=e=>{let t=r.get(e)??0;return r.set(e,t+1),t===0?e:`${e}#${t}`},a=new Map,o=(e,t,r,o,s)=>{let c=`${s}\u001f${t}`,l=r?a.get(c):void 0;if(l){l.parts.push(e);return}let u={...e,parts:[e],key:t,rowKey:i(t),label:o,layer:s};r&&a.set(c,u),n.push(u)};for(let n of Xk(e)){let e=iA(n);if(!e){o({object:n,memberIndex:null},nA(n),!!n.userData?.trackingKey,Qk(n),aA(n,t));continue}let r=rA(n);e.forEach((e,i)=>{o({object:n,memberIndex:i},r[i]??`${n.uuid}:${i}`,!!e.trackingKey,e.name||Zk(n.type),e.layer||aA(n,t))})}return n}var sA=`Default`;function cA(e){let t=new Map;for(let n of e){let e=n.userData?.layer||n.userData?.category||`Default`,r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}return t}function lA(e,t){if(!t.trim())return e;let n=t.toLowerCase(),r=new Map;for(let[t,i]of e){let e=t.toLowerCase().includes(n)?i:i.filter(e=>Qk(e).toLowerCase().includes(n));e.length>0&&r.set(t,e)}return r}function uA(e){let t=new Map;for(let n of e){let e=t.get(n.layer);e||(e=[],t.set(n.layer,e)),e.push(n)}return t}function dA(e,t){if(!t.trim())return e;let n=t.toLowerCase(),r=new Map;for(let[t,i]of e){let e=t.toLowerCase().includes(n)?i:i.filter(e=>e.label.toLowerCase().includes(n));e.length>0&&r.set(t,e)}return r}function fA(e,t){let n=e;if(!n.isMesh||!Array.isArray(n.userData?.members))return;let r=new Set;rA(n).forEach((e,n)=>{t.has(e)&&r.add(n)}),rx(n,r)}function pA(e=new Set){let t=t=>rA(t).every(t=>e.has(t)),n={hidden:e,isHidden:t,setVisible(t,n){t.visible=n,t.traverse(e=>{e.visible=n});for(let r of rA(t))n?e.delete(r):e.add(r);fA(t,e)},isEntryHidden:n=>n.memberIndex===null?t(n.object):e.has(n.key),setEntryVisible(t,r){for(let i of t.parts??[t])i.memberIndex===null?n.setVisible(i.object,r):(r?e.delete(t.key):e.add(t.key),fA(i.object,e),r&&!i.object.visible&&i.object.traverse(e=>{e.visible=!0}))},isLayerHidden:e=>e.length>0&&e.every(e=>n.isHidden(e)),isLayerPartial(e){let t=e.filter(e=>n.isHidden(e)).length;return t>0&&t<e.length},toggleLayer(e){let t=n.isLayerHidden(e);for(let r of e)n.setVisible(r,t)},applyTo(n){for(let r of n)fA(r,e),t(r)&&(r.visible=!1,r.traverse(e=>{e.visible=!1}))},reset:()=>e.clear()};return n}function mA(e=new Set){let t=null,n=new Set,r=e=>{t=e;for(let t of n)t(e)};return{selected:e,get anchor(){return t},isSelected:t=>e.has(t),select(n,i,a){if(i.shiftKey&&t){let r=a(),o=r.indexOf(t),s=r.indexOf(n);if(o!==-1&&s!==-1){let[t,n]=o<s?[o,s]:[s,o];i.toggleKey||e.clear();for(let i=t;i<=n;i++)e.add(r[i])}}else i.toggleKey?e.has(n)?e.delete(n):e.add(n):(e.clear(),e.add(n)),r(n)},clear(){e.clear(),r(null)},onAnchorChange(e){return n.add(e),()=>n.delete(e)}}}function hA(e,t={}){let n=t.sets?.collapsed??new Set,r=pA(t.sets?.hidden),i=mA(t.sets?.selected),a={visibility:r,selection:i,collapsed:n,objects:()=>Xk(e),entries:()=>oA(e,sA),entryGroups:(t=``)=>dA(uA(oA(e,sA)),t),layerGroups:(t=``)=>lA(cA(Xk(e)),t),isCollapsed:e=>n.has(e),toggleCollapsed(e){n.has(e)?n.delete(e):n.add(e)},toggleObject(e){if(i.isSelected(e.uuid)&&i.selected.size>1){let e=a.objects().filter(e=>i.isSelected(e.uuid)),t=e.every(e=>r.isHidden(e));for(let n of e)r.setVisible(n,t)}else r.setVisible(e,r.isHidden(e))},toggleEntry(e){if(i.isSelected(e.key)&&i.selected.size>1){let e=a.entries().filter(e=>i.isSelected(e.key)),t=e.every(e=>r.isEntryHidden(e));for(let n of e)r.setEntryVisible(n,t)}else r.setEntryVisible(e,r.isEntryHidden(e))},select(e,t,n){i.select(e,t,()=>a.flatVisibleUuids(n))},onAnchorChange:e=>i.onAnchorChange(e),flatVisibleUuids(e){let t=[];for(let[r,i]of a.entryGroups(e))if(!n.has(r))for(let e of i)t.push(e.key);return t},applyTo(){r.applyTo(a.objects()),i.clear()},reset(){r.reset(),i.clear()}};return a}var gA={},_A=(function(e,t,n,r,i){var a=new Worker(gA[t]||(gA[t]=URL.createObjectURL(new Blob([e+`;addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})`],{type:`text/javascript`}))));return a.onmessage=function(e){var t=e.data,n=t.$e$;if(n){var r=Error(n[0]);r.code=n[1],r.stack=n[2],i(r,null)}else i(null,t)},a.postMessage(n,r),a}),vA=Uint8Array,yA=Uint16Array,bA=Int32Array,xA=new vA([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),SA=new vA([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),CA=new vA([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),wA=function(e,t){for(var n=new yA(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new bA(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},TA=wA(xA,2),EA=TA.b,DA=TA.r;EA[28]=258,DA[258]=28;for(var OA=wA(SA,0),kA=OA.b,AA=OA.r,jA=new yA(32768),MA=0;MA<32768;++MA){var NA=(MA&43690)>>1|(MA&21845)<<1;NA=(NA&52428)>>2|(NA&13107)<<2,NA=(NA&61680)>>4|(NA&3855)<<4,jA[MA]=((NA&65280)>>8|(NA&255)<<8)>>1}for(var PA=(function(e,t,n){for(var r=e.length,i=0,a=new yA(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new yA(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new yA(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[jA[d]>>c]=l}else for(s=new yA(r),i=0;i<r;++i)e[i]&&(s[i]=jA[o[e[i]-1]++]>>15-e[i]);return s}),FA=new vA(288),MA=0;MA<144;++MA)FA[MA]=8;for(var MA=144;MA<256;++MA)FA[MA]=9;for(var MA=256;MA<280;++MA)FA[MA]=7;for(var MA=280;MA<288;++MA)FA[MA]=8;for(var IA=new vA(32),MA=0;MA<32;++MA)IA[MA]=5;var LA=PA(FA,9,0),RA=PA(FA,9,1),zA=PA(IA,5,0),BA=PA(IA,5,1),VA=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},HA=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},UA=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},WA=function(e){return(e+7)/8|0},GA=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new vA(e.subarray(t,n))},KA=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],qA=function(e,t,n){var r=Error(t||KA[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,qA),!n)throw r;return r},JA=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new vA(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new vA(i*3));var l=function(e){var t=n.length;if(e>t){var r=new vA(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=HA(e,d,1);var v=HA(e,d+1,3);if(d+=3,!v){var y=WA(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&qA(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=RA,m=BA,h=9,g=5;else if(v==2){var S=HA(e,d,31)+257,C=HA(e,d+10,15)+4,w=S+HA(e,d+5,31)+1;d+=14;for(var T=new vA(w),E=new vA(19),D=0;D<C;++D)E[CA[D]]=HA(e,d+D*3,7);d+=C*3;for(var O=VA(E),k=(1<<O)-1,A=PA(E,O,1),D=0;D<w;){var j=A[HA(e,d,k)];d+=j&15;var y=j>>4;if(y<16)T[D++]=y;else{var M=0,N=0;for(y==16?(N=3+HA(e,d,3),d+=2,M=T[D-1]):y==17?(N=3+HA(e,d,7),d+=3):y==18&&(N=11+HA(e,d,127),d+=7);N--;)T[D++]=M}}var P=T.subarray(0,S),F=T.subarray(S);h=VA(P),g=VA(F),p=PA(P,h,1),m=PA(F,g,1)}else qA(1);if(d>_){c&&qA(0);break}}s&&l(f+131072);for(var ee=(1<<h)-1,te=(1<<g)-1,ne=d;;ne=d){var M=p[UA(e,d)&ee],I=M>>4;if(d+=M&15,d>_){c&&qA(0);break}if(M||qA(2),I<256)n[f++]=I;else if(I==256){ne=d,p=null;break}else{var L=I-254;if(I>264){var D=I-257,R=xA[D];L=HA(e,d,(1<<R)-1)+EA[D],d+=R}var z=m[UA(e,d)&te],re=z>>4;z||qA(3),d+=z&15;var F=kA[re];if(re>3){var R=SA[re];F+=UA(e,d)&(1<<R)-1,d+=R}if(d>_){c&&qA(0);break}s&&l(f+131072);var B=f+L;if(f<F){var ie=a-F,ae=Math.min(F,B);for(ie+f<0&&qA(3);f<ae;++f)n[f]=r[ie+f]}for(;f<B;++f)n[f]=n[f-F]}}t.l=p,t.p=ne,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?GA(n,0,f):n.subarray(0,f)},YA=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},XA=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},ZA=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return{t:ij,l:0};if(i==1){var o=new vA(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,r=1;r<i;++r)a[r].s>f&&(f=a[r].s);var p=new yA(f+1),m=QA(n[u-1],p,0);if(m>t){var r=0,h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<i;++r){var v=a[r].s;if(p[v]>t)h+=_-(1<<m-p[v]),p[v]=t;else break}for(h>>=g;h>0;){var y=a[r].s;p[y]<t?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return{t:new vA(p),l:m}},QA=function(e,t,n){return e.s==-1?Math.max(QA(e.l,t,n+1),QA(e.r,t,n+1)):t[e.s]=n},$A=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new yA(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},ej=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},tj=function(e,t,n){var r=n.length,i=WA(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},nj=function(e,t,n,r,i,a,o,s,c,l,u){YA(t,u++,n),++i[256];for(var d=ZA(i,15),f=d.t,p=d.l,m=ZA(a,15),h=m.t,g=m.l,_=$A(f),v=_.c,y=_.n,b=$A(h),x=b.c,S=b.n,C=new yA(19),w=0;w<v.length;++w)++C[v[w]&31];for(var w=0;w<x.length;++w)++C[x[w]&31];for(var T=ZA(C,7),E=T.t,D=T.l,O=19;O>4&&!E[CA[O-1]];--O);var k=l+5<<3,A=ej(i,FA)+ej(a,IA)+o,j=ej(i,f)+ej(a,h)+o+14+3*O+ej(C,E)+2*C[16]+3*C[17]+7*C[18];if(c>=0&&k<=A&&k<=j)return tj(t,u,e.subarray(c,c+l));var M,N,P,F;if(YA(t,u,1+(j<A)),u+=2,j<A){M=PA(f,p,0),N=f,P=PA(h,g,0),F=h;var ee=PA(E,D,0);YA(t,u,y-257),YA(t,u+5,S-1),YA(t,u+10,O-4),u+=14;for(var w=0;w<O;++w)YA(t,u+3*w,E[CA[w]]);u+=3*O;for(var te=[v,x],ne=0;ne<2;++ne)for(var I=te[ne],w=0;w<I.length;++w){var L=I[w]&31;YA(t,u,ee[L]),u+=E[L],L>15&&(YA(t,u,I[w]>>5&127),u+=I[w]>>12)}}else M=LA,N=FA,P=zA,F=IA;for(var w=0;w<s;++w){var R=r[w];if(R>255){var L=R>>18&31;XA(t,u,M[L+257]),u+=N[L+257],L>7&&(YA(t,u,R>>23&31),u+=xA[L]);var z=R&31;XA(t,u,P[z]),u+=F[z],z>3&&(XA(t,u,R>>5&8191),u+=SA[z])}else XA(t,u,M[R]),u+=N[R]}return XA(t,u,M[256]),u+N[256]},rj=new bA([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),ij=new vA(0),aj=function(e,t,n,r,i,a){var o=a.z||e.length,s=new vA(r+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(r,s.length-i),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=rj[t-1],f=d>>13,p=d&8191,m=(1<<n)-1,h=a.p||new yA(32768),g=a.h||new yA(m+1),_=Math.ceil(n/3),v=2*_,y=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&m},b=new bA(25e3),x=new yA(288),S=new yA(32),C=0,w=0,T=a.i||0,E=0,D=a.w||0,O=0;T+2<o;++T){var k=y(T),A=T&32767,j=g[k];if(h[A]=j,g[k]=A,D<=T){var M=o-T;if((C>7e3||E>24576)&&(M>423||!l)){u=nj(e,c,0,b,x,S,w,E,O,T-O,u),E=C=w=0,O=T;for(var N=0;N<286;++N)x[N]=0;for(var N=0;N<30;++N)S[N]=0}var P=2,F=0,ee=p,te=A-j&32767;if(M>2&&k==y(T-te))for(var ne=Math.min(f,M)-1,I=Math.min(32767,T),L=Math.min(258,M);te<=I&&--ee&&A!=j;){if(e[T+P]==e[T+P-te]){for(var R=0;R<L&&e[T+R]==e[T+R-te];++R);if(R>P){if(P=R,F=te,R>ne)break;for(var z=Math.min(te,R-2),re=0,N=0;N<z;++N){var B=T-te+N&32767,ie=B-h[B]&32767;ie>re&&(re=ie,j=B)}}}A=j,j=h[A],te+=A-j&32767}if(F){b[E++]=268435456|DA[P]<<18|AA[F];var ae=DA[P]&31,V=AA[F]&31;w+=xA[ae]+SA[V],++x[257+ae],++S[V],D=T+P,++C}else b[E++]=e[T],++x[e[T]]}}for(T=Math.max(T,D);T<o;++T)b[E++]=e[T],++x[e[T]];u=nj(e,c,l,b,x,S,w,E,O,T-O,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=g,a.p=h,a.i=T,a.w=D)}else{for(var T=a.w||0;T<o+l;T+=65535){var H=T+65535;H>=o&&(c[u/8|0]=l,H=o),u=tj(c,u+1,e.subarray(T,H))}a.i=o}return GA(s,0,r+WA(u)+i)},oj=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),sj=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=oj[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},cj=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new vA(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return aj(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},lj=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},uj=function(e,t,n){for(var r=e(),i=e.toString(),a=i.slice(i.indexOf(`[`)+1,i.lastIndexOf(`]`)).replace(/\s+/g,``).split(`,`),o=0;o<r.length;++o){var s=r[o],c=a[o];if(typeof s==`function`){t+=`;`+c+`=`;var l=s.toString();if(s.prototype){if(l.indexOf(`[native code]`)!=-1){var u=l.indexOf(` `,8)+1;t+=l.slice(u,l.indexOf(`(`,u))}else for(var d in t+=l,s.prototype)t+=`;`+c+`.prototype.`+d+`=`+s.prototype[d].toString()}else t+=l}else n[c]=s}return t},dj=[],fj=function(e){var t=[];for(var n in e)e[n].buffer&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t},pj=function(e,t,n,r){if(!dj[n]){for(var i=``,a={},o=e.length-1,s=0;s<o;++s)i=uj(e[s],i,a);dj[n]={c:uj(e[o],i,a),e:a}}var c=lj({},dj[n].e);return _A(dj[n].c+`;onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=`+t.toString()+`}`,n,c,fj(c),r)},mj=function(){return[vA,yA,bA,xA,SA,CA,EA,kA,RA,BA,jA,KA,PA,VA,HA,UA,WA,GA,qA,JA,Cj,gj,_j]},hj=function(){return[vA,yA,bA,xA,SA,CA,DA,AA,LA,FA,zA,IA,jA,rj,ij,PA,YA,XA,ZA,QA,$A,ej,tj,nj,WA,GA,aj,cj,xj,gj]},gj=function(e){return postMessage(e,[e.buffer])},_j=function(e){return e&&{out:e.size&&new vA(e.size),dictionary:e.dictionary}},vj=function(e,t,n,r,i,a){var o=pj(n,r,i,function(e,t){o.terminate(),a(e,t)});return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},yj=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function bj(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&qA(7),vj(e,t,[hj],function(e){return gj(xj(e.data[0],e.data[1]))},0,n)}function xj(e,t){return cj(e,t||{},0,0)}function Sj(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&qA(7),vj(e,t,[mj],function(e){return gj(Cj(e.data[0],_j(e.data[1])))},1,n)}function Cj(e,t){return JA(e,{i:2},t&&t.out,t&&t.dictionary)}var wj=function(e,t,n,r){for(var i in e){var a=e[i],o=t+i,s=r;Array.isArray(a)&&(s=lj(r,a[1]),a=a[0]),ArrayBuffer.isView(a)?n[o]=[a,s]:(n[o+=`/`]=[new vA(0),s],wj(a,o,n,r))}},Tj=typeof TextEncoder<`u`&&new TextEncoder,Ej=typeof TextDecoder<`u`&&new TextDecoder;try{Ej.decode(ij,{stream:!0})}catch{}function Dj(e,t){if(t){for(var n=new vA(e.length),r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(Tj)return Tj.encode(e);for(var i=e.length,a=new vA(e.length+(e.length>>1)),o=0,s=function(e){a[o++]=e},r=0;r<i;++r){if(o+5>a.length){var c=new vA(o+8+(i-r<<1));c.set(a),a=c}var l=e.charCodeAt(r);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|e.charCodeAt(++r)&1023,s(240|l>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|l&63)):(s(224|l>>12),s(128|l>>6&63),s(128|l&63))}return GA(a,0,o)}var Oj=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&qA(9),t+=r+4}return t},kj=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=Oj(l);yj(e,t,o==null?67324752:33639248),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&qA(10),yj(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(yj(e,t,n.crc),yj(e,t+4,a<0?-a-2:a),yj(e,t+8,n.size)),yj(e,t+12,c),yj(e,t+14,d),t+=16,o!=null&&(yj(e,t,u),yj(e,t+6,n.attrs),yj(e,t+10,o),t+=14),e.set(r,t),t+=c,d)for(var m in l){var h=l[m],g=h.length;yj(e,t,+m),yj(e,t+2,g),e.set(h,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},Aj=function(e,t,n,r,i){yj(e,t,101010256),yj(e,t+8,n),yj(e,t+10,n),yj(e,t+12,r),yj(e,t+16,i)};function jj(e,t,n){n||(n=t,t={}),typeof n!=`function`&&qA(7);var r={};wj(e,``,r,t);var i=Object.keys(r),a=i.length,o=0,s=0,c=a,l=Array(a),u=[],d=function(){for(var e=0;e<u.length;++e)u[e]()},f=function(e,t){Mj(function(){n(e,t)})};Mj(function(){f=n});var p=function(){var e=new vA(s+22),t=o,n=s-o;s=0;for(var r=0;r<c;++r){var i=l[r];try{var a=i.c.length;kj(e,s,i,i.f,i.u,a);var u=30+i.f.length+Oj(i.extra),d=s+u;e.set(i.c,d),kj(e,o,i,i.f,i.u,a,s,i.m),o+=16+u+(i.m?i.m.length:0),s=d+a}catch(e){return f(e,null)}}Aj(e,o,l.length,n,t),f(null,e)};a||p();for(var m=function(e){var t=i[e],n=r[t],c=n[0],m=n[1],h=sj(),g=c.length;h.p(c);var _=Dj(t),v=_.length,y=m.comment,b=y&&Dj(y),x=b&&b.length,S=Oj(m.extra),C=m.level==0?0:8,w=function(n,r){if(n)d(),f(n,null);else{var i=r.length;l[e]=lj(m,{size:g,crc:h.d(),c:r,f:_,m:b,u:v!=t.length||b&&y.length!=x,compression:C}),o+=30+v+S+i,s+=76+2*(v+S)+(x||0)+i,--a||p()}};if(v>65535&&w(qA(11,0,1),null),!C)w(null,c);else if(g<16e4)try{w(null,xj(c,m))}catch(e){w(e,null)}else u.push(bj(c,m,w))},h=0;h<c;++h)m(h);return d}var Mj=typeof queueMicrotask==`function`?queueMicrotask:typeof setTimeout==`function`?setTimeout:function(e){e()};function Nj(){let e=globalThis.Buffer;return typeof e==`function`?e:void 0}function Pj(e){let t=e.replace(/[\t\n\f\r ]/g,``);return t.length%4==0&&(t=t.replace(/={1,2}$/,``)),t.length%4==1?null:t}function Fj(e){let t=Pj(e),n=t===null?null:Ij(t);if(n===null)throw new Cb(`Invalid base64 input.`,Sb.ENCODING_ERROR,{context:{inputLength:e.length}});return n}function Ij(e){let t=Nj();if(t){if(t.byteLength(e,`utf8`)!==e.length||e.includes(`-`)||e.includes(`_`))return null;let n=t.from(e,`base64`);return n.length===Math.floor(e.length*3/4)?n.byteOffset===0&&n.buffer.byteLength===n.length?new Uint8Array(n.buffer,0,n.length):new Uint8Array(n):null}if(typeof globalThis.atob==`function`){let t;try{t=globalThis.atob(e)}catch{return null}let n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e)&255;return n}throw new Cb(`Base64 decoding not supported in this environment.`,Sb.INVALID_STATE,{context:{environmentInfo:`atob or Buffer not available`}})}function Lj(e){return e.map(e=>{let t=e.clone(!0),n=[];e.traverse(e=>n.push(e));let r=0;return t.traverse(e=>{let t=n[r++],i=e;t.geometry&&(i.geometry=t.geometry.clone())}),t})}function Rj(e){e.forEach(e=>Gb(e,{materials:!1}))}function zj(e){let t=0,n=new Set;for(let r of e)r.traverse(e=>{let r=e.geometry;if(r&&!n.has(r)){n.add(r);for(let e of Object.values(r.attributes))t+=e.array.byteLength;r.index&&(t+=r.index.array.byteLength)}});return t}var Bj={clone:Lj,release:Rj,byteSize:zj};function Vj(e,t){let n=t??1;return{color:new Lf(e??`#ffffff`),transparent:n<1,opacity:n}}var Hj=2,Uj=6;function Wj(e){let t=Gj(e);if(!t)return null;let n=new Mx;n.setPositions(t);let r=Vj(e.color,e.opacity),i=new fx({color:r.color}),a=i;a.linewidth=e.width??Hj,a.transparent=r.transparent,a.opacity=r.opacity;let o=new Nx(n,i);return o.computeLineDistances(),o.name=e.name,o.userData={source:`compute`,id:e.id,layer:e.layer,kind:`curve`,metadata:e.metadata},o}function Gj(e){if(!e.points)throw new Cb(`Curve display item '${e.id}' has no tessellated points. It was produced by an outdated Display component — upgrade it in Grasshopper (Solution → Upgrade obsolete components) and re-save the definition.`,Sb.INVALID_CONFIG,{context:{itemId:e.id,kind:e.kind}});return e.points.length>=Uj?e.points:null}function Kj(e){let{position:t}=e;if(!t||typeof t.X!=`number`||!Number.isFinite(t.X)||typeof t.Y!=`number`||!Number.isFinite(t.Y)||typeof t.Z!=`number`||!Number.isFinite(t.Z))return Tb().warn(`Skipping point display item with missing or non-finite position (id: ${String(e.id)}).`),null;let n=new Rp;n.setAttribute(`position`,new Ep([t.X,t.Y,t.Z],3));let r=new $m(n,new Jm({...Vj(e.color,e.opacity),size:6,sizeAttenuation:!1}));return r.name=e.name,r.userData={source:`compute`,id:e.id,layer:e.layer,kind:`point`,metadata:e.metadata},r}function qj(e){if(!e||e.length===0)return[];let t=[];for(let n of e)switch(n.kind){case`curve`:{let e=Wj(n);e&&t.push(e);break}case`point`:{let e=Kj(n);e&&t.push(e);break}default:{let e=n;Tb().warn(`Skipping unknown display item kind: ${String(e.kind)}`);break}}return t}var Jj=1096174675,Yj=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;function Xj(e){return typeof e==`string`?Fj(e):e instanceof Uint8Array?e:new Uint8Array(e)}function Zj(e){return e.byteLength>=8&&new DataView(e.buffer,e.byteOffset,8).getUint32(0,!0)===1515605075}function Qj(e){return Zj(e)?new DataView(e.buffer,e.byteOffset,8).getUint32(4,!0):0}function $j(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(4,!0),n=e.subarray(8),r=Math.max(n.byteLength*1032+1024,1<<20);if(t>r)throw _M(`SLVZ header declares an implausible uncompressed length`,{uncompressedLen:t,deflatedBytes:n.byteLength,maxPlausibleLen:r});return{deflated:n,uncompressedLen:t}}function eM(e,t){return _M(`Failed to inflate SLVZ blob: ${e instanceof Error?e.message:String(e)}`,{uncompressedLen:t.uncompressedLen,deflatedBytes:t.deflated.byteLength})}function tM(e,t){if(e.byteLength!==t.uncompressedLen)throw _M(`SLVZ payload inflated to a different size than the header declares.`,{declaredLen:t.uncompressedLen,actualLen:e.byteLength,deflatedBytes:t.deflated.byteLength});return e}function nM(e){if(!Zj(e))return e;let t=$j(e),n;try{n=Cj(t.deflated,{out:new Uint8Array(t.uncompressedLen+1)})}catch(e){throw eM(e,t)}return tM(n,t)}function rM(e){return new Promise((t,n)=>{let r=$j(e);try{Sj(r.deflated,{size:r.uncompressedLen+1},(e,i)=>{if(e)n(eM(e,r));else try{t(tM(i,r))}catch(e){n(e)}})}catch(e){n(eM(e,r))}})}function iM(e){if(typeof TextDecoder<`u`)return new TextDecoder(`utf-8`).decode(e);if(globalThis.Buffer!==void 0)return globalThis.Buffer.from(e).toString(`utf-8`);throw new Cb(`No UTF-8 decoder available in this environment.`,Sb.INVALID_STATE)}function aM(e,t,n){if(n===0)return new Int16Array;if(t%2==0)return new Int16Array(e,t,n);let r=new Uint8Array(n*2);return r.set(new Uint8Array(e,t,n*2)),new Int16Array(r.buffer)}function oM(e,t,n){if(n===0)return new Float32Array;if(t%4==0)return new Float32Array(e,t,n);let r=new Uint8Array(n*4);return r.set(new Uint8Array(e,t,n*4)),new Float32Array(r.buffer)}function sM(e,t,n){if(n===0)return new Uint16Array;if(t%2==0)return new Uint16Array(e,t,n);let r=new Uint8Array(n*2);return r.set(new Uint8Array(e,t,n*2)),new Uint16Array(r.buffer)}function cM(e,t,n){if(n===0)return new Uint32Array;if(t%4==0)return new Uint32Array(e,t,n);let r=new Uint8Array(n*4);return r.set(new Uint8Array(e,t,n*4)),new Uint32Array(r.buffer)}function lM(e,t){if(e.length!==0&&!(e instanceof Uint16Array&&t>65535)){for(let n=0;n<e.length;n++)if(e[n]>=t)throw _M(`Index out of range of vertexCount.`,{indexPosition:n,indexValue:e[n],vertexCount:t})}}function uM(e){return e>>>1^-(e&1)}function dM(e){let t=new Int16Array(e.length),n=0,r=0,i=0;for(let a=0;a<e.length;a+=3)n=n+uM(e[a])<<16>>16,r=r+uM(e[a+1])<<16>>16,i=i+uM(e[a+2])<<16>>16,t[a]=n,t[a+1]=r,t[a+2]=i;return t}function fM(e,t){let n=new Int16Array(t*3),r=t,i=0,a=0,o=0;for(let t=0;t<r;t++)i=i+uM(e[t]|e[r*3+t]<<8)<<16>>16,a=a+uM(e[r+t]|e[r*4+t]<<8)<<16>>16,o=o+uM(e[r*2+t]|e[r*5+t]<<8)<<16>>16,n[t*3]=i,n[t*3+1]=a,n[t*3+2]=o;return n}function pM(e,t){let n=new Uint16Array(t),r=0;for(let i=0;i<t;i++)r=r+uM(e[i]|e[t+i]<<8)&65535,n[i]=r;return n}function mM(e,t){let n=new Uint32Array(t),r=0;for(let i=0;i<t;i++){let a=(e[i]|e[t+i]<<8|e[t*2+i]<<16|e[t*3+i]<<24)>>>0;r=r+uM(a)>>>0,n[i]=r}return n}function hM(e){let t=new Uint16Array(e.length),n=0;for(let r=0;r<e.length;r++)n=n+uM(e[r])&65535,t[r]=n;return t}function gM(e){let t=new Uint32Array(e.length),n=0;for(let r=0;r<e.length;r++)n=n+uM(e[r])>>>0,t[r]=n;return t}function _M(e,t){return new Cb(e,Sb.VALIDATION_ERROR,{context:t})}var vM=36;function yM(e,t,n,r,i,a=!1){if(n+vM>e.byteLength)throw _M(`Insufficient data to read UV chunk header.`,{expectedBytes:vM,availableBytes:e.byteLength-n,offset:n});let o=t.getUint32(n,!0);n+=4;let s=t.getFloat64(n,!0);n+=8;let c=t.getFloat64(n,!0);n+=8;let l=t.getFloat64(n,!0);n+=8;let u=t.getFloat64(n,!0);n+=8;let d=r*2,f=o===1,p=d*(f?4:2);if(n+p>e.byteLength)throw _M(`Insufficient data to read UV chunk.`,{expectedBytes:p,availableBytes:e.byteLength-n,offset:n,uvFormat:o,vertexCount:r});let m=e.byteOffset+n,h;if(f)h=oM(e.buffer,m,d).slice();else if(a){let t=e.subarray(n,n+p),i=r;h=new Float32Array(d);let a=0,o=0;for(let e=0;e<i;e++)a=a+uM(t[e]|t[i*2+e]<<8)&65535,o=o+uM(t[i+e]|t[i*3+e]<<8)&65535,h[e*2]=s+a*l,h[e*2+1]=c+o*u}else{let t=sM(e.buffer,m,d);h=new Float32Array(d);let n=0,r=0;for(let e=0;e<d;e+=2)i?(n=n+uM(t[e])&65535,r=r+uM(t[e+1])&65535):(n=t[e],r=t[e+1]),h[e]=s+n*l,h[e+1]=c+r*u}return{uvs:h,offset:n+p}}function bM(e,t,n,r){let i=n*3;if(t+i>e.byteLength)throw _M(`Insufficient data to read vertex-color chunk.`,{expectedBytes:i,availableBytes:e.byteLength-t,offset:t,vertexCount:n});let a=e.subarray(t,t+i);if(!r)return a.slice();let o=new Uint8Array(i),s=0,c=0,l=0;for(let e=0;e<i;e+=3)s=s+uM(a[e])&255,c=c+uM(a[e+1])&255,l=l+uM(a[e+2])&255,o[e]=s,o[e+1]=c,o[e+2]=l;return o}var xM=1297040711,SM=1279410516,CM=1280590157,wM=1381516628,TM=1146309699,EM=`id`,DM=`slvm:tex:`,OM=0,kM=1,AM=2;function jM(e){return e.byteLength>=4&&new DataView(e.buffer,e.byteOffset,4).getUint32(0,!0)===1297501267}function MM(e){let t=NM(e),n=null,r=null,i=null,a=null,o=[];for(let{type:e,payload:s}of t)switch(e){case xM:n=s;break;case SM:r=nM(s);break;case CM:i=iM(s);break;case wM:o.push(s);break;case TM:a=nM(s)}if(n===null)throw _M(`SLVM container has no GEOM chunk.`,{chunkCount:t.length});if(r===null)throw _M(`SLVM container has no TABL chunk.`,{chunkCount:t.length});let{groups:s}=IM(r,a),c=LM(i,o);return{geometryBlob:n,metadata:{materials:c,groups:s}}}function NM(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.byteLength<12||t.getUint32(0,!0)!==1297501267)throw _M(`Not an SLVM container (bad magic).`,{byteLength:e.byteLength});let n=t.getUint32(4,!0);if(n!==3)throw _M(`Unsupported SLVM version: ${n}`,{expectedVersion:3});let r=t.getUint32(8,!0),i=[],a=12;for(let n=0;n<r;n++){if(a+8>e.byteLength)throw _M(`Truncated SLVM chunk header.`,{offset:a,chunkIndex:n});let r=t.getUint32(a,!0),o=t.getUint32(a+4,!0);if(a+=8,a+o>e.byteLength)throw _M(`Truncated SLVM chunk payload.`,{offset:a,chunkIndex:n,byteLen:o});i.push({type:r,payload:e.subarray(a,a+o)}),a+=o+(4-o%4)%4}return i}function PM(e){let t=0,n=0;for(;;){if(e.pos>=e.bytes.byteLength||n>28)throw _M(`Malformed varint in SLVM table.`,{pos:e.pos});let r=e.bytes[e.pos++];if(t|=(r&127)<<n,!(r&128))return t>>>0;n+=7}}function FM(e,t,n){let r=e.bytes[e.pos++],i=Array(t);switch(r){case OM:i.fill(``);break;case kM:for(let e=0;e<t;e++)i[e]=String(e+1);break;case AM:for(let r=0;r<t;r++)i[r]=n[PM(e)]??``;break;default:throw _M(`Unknown SLVM string column mode: ${r}`,{pos:e.pos})}return i}function IM(e,t){let n={bytes:e,pos:0},r=PM(n),i=PM(n),a=PM(n),o=r+i+a,s=PM(n),c=Array(s);for(let t=0;t<s;t++){let r=PM(n);c[t]=iM(e.subarray(n.pos,n.pos+r)),n.pos+=r}let l=Array(r),u=Array(r);for(let e=0;e<r;e++)l[e]=PM(n),u[e]=PM(n);for(let e=0;e<i;e++)PM(n);let d=PM(n),f=[];for(let e=0;e<d;e++)f.push({materialId:PM(n),meshCount:PM(n)});let p=FM(n,o,c),m=FM(n,o,c),h=Array(o),g=PM(n);for(let e=0;e<g;e++){let e=c[PM(n)]??``,t=PM(n),r=Array(t),i=0;for(let e=0;e<t;e++)i+=PM(n),r[e]=i;for(let i=0;i<t;i++){let t=c[PM(n)]??``,a=r[i];(h[a]??={})[e]=t}}let _=f.length>0||r===0?f:[{materialId:0,meshCount:r}],v=[],y=0,b=0,x=0;for(let e of _){let n=[];for(let i=0;i<e.meshCount&&y<r;i++,y++){let e=h[y],r=e?.[EM];e!==void 0&&delete e[EM];let i={id:r,name:p[y],layer:m[y],vertexCount:l[y],indexCount:u[y]*3,vertexStart:b,indexStart:x,metadata:e??{}},a=t?.[y];(a===1||a===2)&&(i.closed=a===2),n.push(i),b+=l[y],x+=u[y]*3}v.push({materialId:e.materialId,meshes:n})}return{groups:v}}function LM(e,t){if(e===null)return[];let n;try{n=JSON.parse(e).materials??[]}catch(t){throw _M(`Failed to parse SLVM materials JSON: ${t instanceof Error?t.message:String(t)}`,{byteLength:e.length})}for(let e of n)for(let n of RM){let r=e[n];if(r?.startsWith(DM)){let i=t[Number(r.slice(9))];i!==void 0&&(e[n]=zM(i))}}return n}var RM=[`map`,`roughnessMap`,`normalMap`];function zM(e){let t={bytes:e,pos:0},n=PM(t),r=iM(e.subarray(t.pos,t.pos+n)),i=e.subarray(t.pos+n),a=``,o=32768;for(let e=0;e<i.byteLength;e+=o)a+=String.fromCharCode(...i.subarray(e,e+o));return`data:${r};base64,${btoa(a)}`}function BM(e,t){return new Cb(e,Sb.VALIDATION_ERROR,{context:t})}var VM=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function HM(e,t,n,r){if(!Array.isArray(e))throw BM(`Batch materials must be an array.`,{materials:typeof e});let i=e.findIndex(e=>!VM(e));if(i!==-1)throw BM(`Each material entry must be an object.`,{materialIndex:i});let a=e.length;if(!Array.isArray(t))throw BM(`Batch groups must be an array.`,{groups:typeof t});t.forEach((e,t)=>{if(!VM(e)||!Array.isArray(e.meshes))throw BM(`Each group must be an object with a meshes array.`,{groupIndex:t});if(!e.meshes.every(VM))throw BM(`Each mesh entry must be an object.`,{groupIndex:t})});for(let e of t){if(!Number.isInteger(e.materialId)||e.materialId<0||e.materialId>=a)throw BM(`Group materialId out of range of the materials array.`,{materialId:e.materialId,materialCount:a});for(let t of e.meshes){let e={vertexStart:t.vertexStart,vertexCount:t.vertexCount,indexStart:t.indexStart,indexCount:t.indexCount};for(let[n,r]of Object.entries(e))if(!Number.isInteger(r)||r<0)throw BM(`Mesh metadata field "${n}" must be a non-negative integer.`,{meshName:t.name,field:n,value:r});if(t.vertexStart+t.vertexCount>n)throw BM(`Mesh vertex window exceeds the batch vertex buffer.`,{meshName:t.name,vertexStart:t.vertexStart,vertexCount:t.vertexCount,totalVertexCount:n});if(t.indexStart+t.indexCount>r)throw BM(`Mesh index window exceeds the batch index buffer.`,{meshName:t.name,indexStart:t.indexStart,indexCount:t.indexCount,totalIndexCount:r})}}}function UM(e,t){return BM(`Index references a vertex outside its mesh's vertex window.`,{meshName:t.name,indexValue:e,vertexStart:t.vertexStart,vertexCount:t.vertexCount})}function WM(e,t,n){let r=new Float32Array(e.length),i=t[0],a=t[1],o=t[2],s=n[0],c=n[1],l=n[2];for(let t=0;t<e.length;t+=3)r[t]=i+(e[t]+32767)*s,r[t+1]=a+(e[t+1]+32767)*c,r[t+2]=o+(e[t+2]+32767)*l;return r}function GM(e){let t;t=e.isFloat32?e.vertexData:e.planarByteSplit?fM(e.vertexData,e.vertexCount):e.deltaEncoded?dM(e.vertexData):e.vertexData;let n;if(e.planarByteSplit){let t=e.indexData;n=e.uint16Indices?pM(t,t.length/2):mM(t,t.length/4)}else n=e.deltaEncoded?e.indexData instanceof Uint16Array?hM(e.indexData):gM(e.indexData):e.indexData;return lM(n,e.vertexCount),{metadata:e.metadata,flags:e.flags,vertices:t,indices:n,origin:e.origin,scale:e.scale,uvs:e.uvs,colors:e.colors}}function KM(e){if(!Yj)throw new Cb(`SLVA parsing requires a little-endian host: the zero-copy geometry readers view the wire bytes in host byte order.`,Sb.ENVIRONMENT_ERROR);let t=Xj(e);if(jM(t)){let e=MM(t),n=KM(e.geometryBlob);return n.metadata=e.metadata,n}let n=nM(t),r=new DataView(n.buffer,n.byteOffset,n.byteLength);if(n.byteLength<12)throw _M(`Blob too small to contain SLVA header.`,{expectedBytes:12,availableBytes:n.byteLength});let i=0,a=r.getUint32(i,!0);if(i+=4,a!==1096174675)throw _M(`Invalid SLVA magic: 0x${a.toString(16)}`,{expectedMagic:`0x${Jj.toString(16)}`,actualMagic:`0x${a.toString(16)}`});let o=r.getUint32(i,!0);if(i+=4,o<1||o>4)throw _M(`Unsupported SLVA version: ${o}`,{minSupportedVersion:1,maxSupportedVersion:4,actualVersion:o});let s=r.getUint32(i,!0);if(i+=4,i+s>n.byteLength)throw _M(`Insufficient data to read metadata JSON.`,{expectedBytes:s,availableBytes:n.byteLength-i,offset:i});let c=n.subarray(i,i+s);i+=s;let l;try{l=s===0?{}:JSON.parse(iM(c))}catch(e){throw _M(`Failed to parse metadata JSON: ${e instanceof Error?e.message:String(e)}`,{metadataLen:s})}if(!qM(l))throw _M(`Metadata JSON must be an object whose materials and groups are arrays.`,{metadataLen:s});if(i+56>n.byteLength)throw _M(`Insufficient data to read geometry header.`,{expectedBytes:56,availableBytes:n.byteLength-i,offset:i});let u=r.getUint32(i,!0);i+=4;let d=r.getFloat64(i,!0);i+=8;let f=r.getFloat64(i,!0);i+=8;let p=r.getFloat64(i,!0);i+=8;let m=r.getFloat64(i,!0);i+=8;let h=r.getFloat64(i,!0);i+=8;let g=r.getFloat64(i,!0);i+=8;let _=r.getUint32(i,!0);i+=4;let v=!!(u&1),y=!!(u&4),b=!!(u&32),x=_*3,S=x*(v?4:2);if(i+S>n.byteLength)throw _M(`Insufficient data to read vertices.`,{expectedBytes:S,availableBytes:n.byteLength-i,offset:i,useFloat32:v,vertexCount:_});let C=n.byteOffset+i,w;if(w=v?oM(n.buffer,C,x):b?n.subarray(i,i+S):y?sM(n.buffer,C,x):aM(n.buffer,C,x),i+=S,i+4>n.byteLength)throw _M(`Insufficient data to read index count.`,{expectedBytes:4,availableBytes:n.byteLength-i,offset:i});let T=r.getUint32(i,!0);i+=4;let E=!!(u&2),D=T*(E?2:4);if(i+D>n.byteLength)throw _M(`Insufficient data to read indices.`,{expectedBytes:D,availableBytes:n.byteLength-i,offset:i,indexCount:T,useUint16Indices:E});let O=b?n.subarray(i,i+D):E?sM(n.buffer,n.byteOffset+i,T):cM(n.buffer,n.byteOffset+i,T);i+=D;let k=null;if(u&8){let e=yM(n,r,i,_,y,b);k=e.uvs,i=e.offset}let A=null;return u&16&&(A=bM(n,i,_,y)),{metadata:l,flags:u,vertexData:w,indexData:O,isFloat32:v,deltaEncoded:y,planarByteSplit:b,uint16Indices:E,vertexCount:_,origin:[d,f,p],scale:[m,h,g],uvs:k,colors:A}}function qM(e){if(!VM(e))return!1;let{materials:t,groups:n}=e;return(t===void 0||Array.isArray(t))&&(n===void 0||Array.isArray(n))}function JM(e,t,n){if(n.length===0)return!1;let r=e=>{let t=16;for(;t<e*2;)t*=2;return t},i=e.length/3,a=new Int32Array(i),o=new Int32Array(i),s=new Int32Array,c=new Int32Array,l=new Int32Array,u=new Int32Array,d=new Int32Array,f=new Int32Array,p=new Int32Array,m=new Int32Array,h=new Int32Array,g=(e,t)=>e.length>=t?e:new Int32Array(t),_=(n,i,_)=>{if(_<12||_%3!=0)return!1;let v=2*n+1,y=v+1,b=0,x=0;for(let n=0;n<_;n++){let r=t[i+n];a[r]!==v&&(a[r]=v,x++,b=Math.max(b,Math.abs(e[r*3]),Math.abs(e[r*3+1]),Math.abs(e[r*3+2])))}if(!(b>0)||!Number.isFinite(b))return!1;let S=1/(2*2**(Math.floor(Math.log2(b))-23)),C=r(x),w=C-1;s=g(s,C),s.fill(-1,0,C),c=g(c,C),l=g(l,C),u=g(u,C);let T=(e,t,n)=>{let r=Math.imul(e,2654435761)^Math.imul(t,2246822519)^Math.imul(n,3266489917);for(r=(r^r>>>15)&w;s[r]!==-1&&(c[r]!==e||l[r]!==t||u[r]!==n);)r=r+1&w;return r},E=(e,t)=>{let n=e-t;return n>.25?t+1:n<-.25?t-1:t};d=g(d,_),f=g(f,x);let D=0;for(let n=0;n<_;n++){let r=t[i+n];if(a[r]===y){d[n]=o[r];continue}let p=e[r*3]*S,m=e[r*3+1]*S,h=e[r*3+2]*S,g=Math.round(p),_=Math.round(m),v=Math.round(h),b=E(p,g),x=E(m,_),C=E(h,v),w=-1,O=-1;for(let e=0;e<8&&w===-1;e++){if(e&1&&b===g||e&2&&x===_||e&4&&C===v)continue;let t=T(e&1?b:g,e&2?x:_,e&4?C:v);e===0&&(O=t),s[t]!==-1&&(w=s[t])}if(w===-1){let e=O;w=D++,s[e]=w,c[e]=g,l[e]=_,u[e]=v,f[w]=r}a[r]=y,o[r]=w,d[n]=w}p=g(p,D+1),p.fill(0,0,D+1);let O=0;for(let e=0;e<_;e+=3){let t=d[e],n=d[e+1],r=d[e+2];t!==n&&n!==r&&r!==t&&(p[t+1]+=1,p[n+1]+=1,p[r+1]+=1,O++)}if(O<4)return!1;for(let e=0;e<D;e++)p[e+1]+=p[e];m=g(m,p[D]),h=g(h,D),h.set(p.subarray(0,D));for(let e=0;e<_;e+=3){let t=d[e],n=d[e+1],r=d[e+2];t!==n&&n!==r&&r!==t&&(m[h[t]]=n,h[t]+=1,m[h[n]]=r,h[n]+=1,m[h[r]]=t,h[r]+=1)}for(let e=0;e<D;e++){let t=p[e],n=p[e+1];for(let r=t;r<n;r++){let n=m[r];for(let e=t;e<r;e++)if(m[e]===n)return!1;let i=!1;for(let t=p[n],r=p[n+1];t<r&&!i;t++)i=m[t]===e;if(!i)return!1}}let k=f[d[0]]*3,A=e[k],j=e[k+1],M=e[k+2],N=0;for(let t=0;t<_;t+=3){let n=f[d[t]]*3,r=f[d[t+1]]*3,i=f[d[t+2]]*3,a=e[n]-A,o=e[n+1]-j,s=e[n+2]-M,c=e[r]-A,l=e[r+1]-j,u=e[r+2]-M,p=e[i]-A,m=e[i+1]-j,h=e[i+2]-M;N+=a*(l*h-u*m)+o*(u*p-c*h)+s*(c*m-l*p)}return N>0},v=0;for(let e=0;e<n.length;e++){let t=n[e];if(!_(e,v,t))return!1;v+=t}return!0}function YM(e,t,n,r){let i=Math.cos(30*Math.PI/180),a=e.length/3,o=t.length,s=o/3,c=new Uint32Array;{let i=new Uint32Array(e.buffer,e.byteOffset,e.length),s=n?new Uint32Array(n.buffer,n.byteOffset,n.length):null,l=(e,t)=>e[t]===2147483648?0:e[t],u=16;for(;u<a*2;)u*=2;let d=u-1,f=new Int32Array(u).fill(-1),p=new Uint32Array(a),m=!1;for(let e=0;e<a;e++){let t=l(i,e*3),n=l(i,e*3+1),a=l(i,e*3+2),o=Math.imul(t,2654435761)^Math.imul(n,2246822519)^Math.imul(a,3266489917);for(o=(o^o>>>15)&d;;){let c=f[o];if(c===-1){f[o]=e,p[e]=e;break}if(l(i,c*3)===t&&l(i,c*3+1)===n&&l(i,c*3+2)===a&&(!r||r[c*3]===r[e*3]&&r[c*3+1]===r[e*3+1]&&r[c*3+2]===r[e*3+2])&&(!s||s[c*2]===s[e*2]&&s[c*2+1]===s[e*2+1])){p[e]=c,m=!0;break}o=o+1&d}}if(m){for(let e=0;e<o;e++)t[e]=p[t[e]];let e=0;for(let t=0;t<a;t++)p[t]!==t&&e++;c=new Uint32Array(e);for(let e=0,t=0;e<a;e++)p[e]!==e&&(c[t++]=e)}}let l=new Float32Array(s*3),u=new Float32Array(s);for(let n=0;n<s;n++){let r=t[n*3]*3,i=t[n*3+1]*3,a=t[n*3+2]*3,o=e[i]-e[r],s=e[i+1]-e[r+1],c=e[i+2]-e[r+2],d=e[a]-e[r],f=e[a+1]-e[r+1],p=e[a+2]-e[r+2],m=s*p-c*f,h=c*d-o*p,g=o*f-s*d,_=Math.sqrt(m*m+h*h+g*g);_!==0&&(l[n*3]=m/_,l[n*3+1]=h/_,l[n*3+2]=g/_,u[n]=_)}let d=new Uint32Array(a+1);for(let e=0;e<o;e++)d[t[e]+1]+=1;for(let e=0;e<a;e++)d[e+1]+=d[e];let f=new Uint32Array(o),p=d.slice(0,a);for(let e=0;e<o;e++){let n=t[e];f[p[n]]=e,p[n]+=1}let m=0;for(let e=0;e<a;e++)m=Math.max(m,d[e+1]-d[e]);let h=new Uint32Array(o),g=new Uint32Array(a),_=new Float32Array(Math.max(1,m)*3);for(let e=0;e<a;e++){let t=0;for(let n=d[e];n<d[e+1];n++){let e=f[n],r=Math.floor(e/3)*3,a=l[r],o=l[r+1],s=l[r+2],c=-1;if(a===0&&o===0&&s===0)c=0;else for(let e=0;e<t;e++)if(_[e*3]*a+_[e*3+1]*o+_[e*3+2]*s>=i){c=e;break}c===-1&&(c=t,_[t*3]=a,_[t*3+1]=o,_[t*3+2]=s,t++),h[e]=c}g[e]=Math.max(1,t)}let v=new Uint32Array(a+1);for(let e=0;e<a;e++)v[e+1]=v[e]+g[e]-1;let y=v[a],b=a+Math.max(0,y-c.length),x=new Uint32Array(y);for(let e=0;e<y;e++)x[e]=e<c.length?c[e]:a+e-c.length;let S=e,C=n,w=r;if(y>0){S=new Float32Array(b*3),S.set(e),C=n?new Float32Array(b*2):null,C&&n&&C.set(n),w=r?new Uint8Array(b*3):null,w&&r&&w.set(r);for(let t=0;t<a;t++)for(let i=1;i<g[t];i++){let a=x[v[t]+i-1];S[a*3]=e[t*3],S[a*3+1]=e[t*3+1],S[a*3+2]=e[t*3+2],C&&n&&(C[a*2]=n[t*2],C[a*2+1]=n[t*2+1]),w&&r&&(w[a*3]=r[t*3],w[a*3+1]=r[t*3+1],w[a*3+2]=r[t*3+2])}}let T=new Float32Array(b*3);for(let e=0;e<s;e++){let n=u[e],r=l[e*3]*n,i=l[e*3+1]*n,a=l[e*3+2]*n;for(let n=e*3;n<e*3+3;n++){let e=t[n],o=h[n];o!==0&&(e=x[v[e]+o-1],t[n]=e),T[e*3]+=r,T[e*3+1]+=i,T[e*3+2]+=a}}for(let e=0;e<T.length;e+=3){let t=T[e],n=T[e+1],r=T[e+2],i=Math.sqrt(t*t+n*n+r*r)||1;T[e]=t/i,T[e+1]=n/i,T[e+2]=r/i}return{positions:S,normals:T,indices:t,uvs:C,colors:w}}function XM(e,t,n,r){let i=e.length/3,a=new Float32Array(i*3),o=new Float32Array(i*3);for(let t=0;t<n.length;t+=3){let i=n[t],s=n[t+1],c=n[t+2],l=e[s*3]-e[i*3],u=e[s*3+1]-e[i*3+1],d=e[s*3+2]-e[i*3+2],f=e[c*3]-e[i*3],p=e[c*3+1]-e[i*3+1],m=e[c*3+2]-e[i*3+2],h=u*m-d*p,g=d*f-l*m,_=l*p-u*f,v=Math.sqrt(h*h+g*g+_*_);if(v===0)continue;let y=(p*_-m*g)/v,b=(m*h-f*_)/v,x=(f*g-p*h)/v,S=(g*d-_*u)/v,C=(_*l-h*d)/v,w=(h*u-g*l)/v,T=r[s*2]-r[i*2],E=r[c*2]-r[i*2],D=r[s*2+1]-r[i*2+1],O=r[c*2+1]-r[i*2+1],k=T*y+E*S,A=T*b+E*C,j=T*x+E*w,M=D*y+O*S,N=D*b+O*C,P=D*x+O*w;for(let e=0;e<3;e++){let r=n[t+e];a[r*3]+=k,a[r*3+1]+=A,a[r*3+2]+=j,o[r*3]+=M,o[r*3+1]+=N,o[r*3+2]+=P}}let s=new Float32Array(i*4);for(let e=0;e<i;e++){let n=t[e*3],r=t[e*3+1],i=t[e*3+2],c=a[e*3]*n+a[e*3+1]*r+a[e*3+2]*i,l=a[e*3]-c*n,u=a[e*3+1]-c*r,d=a[e*3+2]-c*i,f=Math.sqrt(l*l+u*u+d*d);if(!(f>1e-12)){let e=+(Math.abs(n)<.9),t=1-e;l=t*i,u=-e*i,d=e*r-t*n,f=Math.sqrt(l*l+u*u+d*d)||1}l/=f,u/=f,d/=f;let p=r*d-i*u,m=i*l-n*d,h=n*u-r*l,g=p*o[e*3]+m*o[e*3+1]+h*o[e*3+2];s[e*4]=l,s[e*4+1]=u,s[e*4+2]=d,s[e*4+3]=g<0?-1:1}return s}function ZM(e,t){let n=t.every(e=>typeof e.closed==`boolean`)?t.length>0&&t.every(e=>e.closed):JM(e.positions,e.indices,t.map(e=>e.indexCount)),r=YM(e.positions,e.indices,e.uvs,e.colors),i=r.uvs?XM(r.positions,r.normals,r.indices,r.uvs):null;return{...r,closed:n,tangents:i}}function QM(e){let{isFloat32:t,deltaEncoded:n,planarByteSplit:r,uint16Indices:i,origin:a,scale:o,uvs:s,colors:c,jobs:l}=e,u=e=>e>>>1^-(e&1),d;if(t)d=e.vertexData;else{let t;if(r){let n=e.vertexData,r=n.length/6;t=new Int16Array(r*3);let i=0,a=0,o=0;for(let e=0;e<r;e++)i=i+u(n[e]|n[r*3+e]<<8)<<16>>16,a=a+u(n[r+e]|n[r*4+e]<<8)<<16>>16,o=o+u(n[r*2+e]|n[r*5+e]<<8)<<16>>16,t[e*3]=i,t[e*3+1]=a,t[e*3+2]=o}else if(n){let n=e.vertexData;t=new Int16Array(n.length);let r=0,i=0,a=0;for(let e=0;e<n.length;e+=3)r=r+u(n[e])<<16>>16,i=i+u(n[e+1])<<16>>16,a=a+u(n[e+2])<<16>>16,t[e]=r,t[e+1]=i,t[e+2]=a}else t=e.vertexData;d=new Float32Array(t.length);let i=a[0],s=a[1],c=a[2],l=o[0],f=o[1],p=o[2];for(let e=0;e<t.length;e+=3)d[e]=i+(t[e]+32767)*l,d[e+1]=s+(t[e+1]+32767)*f,d[e+2]=c+(t[e+2]+32767)*p}let f;if(r){let t=e.indexData;if(i){let e=t.length/2,n=new Uint16Array(e),r=0;for(let i=0;i<e;i++)r=r+u(t[i]|t[e+i]<<8)&65535,n[i]=r;f=n}else{let e=t.length/4,n=new Uint32Array(e),r=0;for(let i=0;i<e;i++){let a=(t[i]|t[e+i]<<8|t[e*2+i]<<16|t[e*3+i]<<24)>>>0;r=r+u(a)>>>0,n[i]=r}f=n}}else if(n){let t=e.indexData;if(t instanceof Uint16Array){let e=new Uint16Array(t.length),n=0;for(let r=0;r<t.length;r++)n=n+u(t[r])&65535,e[r]=n;f=e}else{let e=new Uint32Array(t.length),n=0;for(let r=0;r<t.length;r++)n=n+u(t[r])>>>0,e[r]=n;f=e}}else f=e.indexData;let p=d.length/3;for(let e=0;e<f.length;e++)if(f[e]>=p)throw Error(`Index ${f[e]} out of range of vertexCount ${p}`);let m=[];for(let e of l){let t=0,n=0;for(let r of e.windows)t+=r.vertexCount,n+=r.indexCount;let r=new Float32Array(t*3),i=new Uint32Array(n),a=s?new Float32Array(t*2):null,o=c?new Uint8Array(t*3):null,l=0,u=0;for(let t of e.windows){let e=t.vertexStart*3;r.set(d.subarray(e,e+t.vertexCount*3),l*3),a&&s&&a.set(s.subarray(t.vertexStart*2,(t.vertexStart+t.vertexCount)*2),l*2),o&&c&&o.set(c.subarray(e,e+t.vertexCount*3),l*3);let n=t.vertexStart,p=t.vertexStart+t.vertexCount,m=l-t.vertexStart;for(let e=0;e<t.indexCount;e++){let r=f[t.indexStart+e];if(r<n||r>=p)throw Error(`Index ${r} outside vertex window [${n}, ${p})`);i[u+e]=r+m}l+=t.vertexCount,u+=t.indexCount}m.push({positions:r,indices:i,uvs:a,colors:o})}return m}function $M(){return[`const assemble = ${QM.toString()};`,`const isClosedSolid = ${JM.toString()};`,`const splitCreases = ${YM.toString()};`,`const grainTangents = ${XM.toString()};`,`self.onmessage = (event) => {`,` const { id, input } = event.data;`,` try {`,` const geometries = assemble(input).map((g, i) => {`,` const windows = input.jobs[i].windows;`,` const known = windows.every((w) => typeof w.closed === 'boolean');`,` const closed = known`,` ? windows.length > 0 && windows.every((w) => w.closed)`,` : isClosedSolid(g.positions, g.indices, windows.map((w) => w.indexCount));`,` const c = splitCreases(g.positions, g.indices, g.uvs, g.colors);`,` const tangents = c.uvs ? grainTangents(c.positions, c.normals, c.indices, c.uvs) : null;`,` return { ...c, closed, tangents };`,` });`,` const transfer = [];`,` for (const g of geometries) {`,` transfer.push(g.positions.buffer, g.normals.buffer, g.indices.buffer);`,` if (g.uvs) transfer.push(g.uvs.buffer);`,` if (g.tangents) transfer.push(g.tangents.buffer);`,` if (g.colors) transfer.push(g.colors.buffer);`,` }`,` self.postMessage({ id, geometries }, transfer);`,` } catch (error) {`,` self.postMessage({ id, error: String((error && error.message) || error) });`,` }`,`};`].join(`
|
|
5751
|
+
`)}var eN,tN=new Map,nN=1;function rN(){if(eN!==void 0)return eN;if(typeof Worker>`u`||typeof Blob>`u`||typeof URL>`u`||typeof URL.createObjectURL!=`function`)return eN=null,null;try{let e=URL.createObjectURL(new Blob([$M()],{type:`text/javascript`})),t=new Worker(e);t.onmessage=e=>{let{id:t,geometries:n,error:r}=e.data,i=tN.get(t);i&&(tN.delete(t),n?i.resolve(n):i.reject(Error(r??`mesh assembly failed in worker`)))},t.onerror=()=>{for(let e of tN.values())e.reject(Error(`mesh assembly worker crashed`));tN.clear(),t.terminate(),eN=null},eN=t}catch{eN=null}return eN}function iN(e,t,n){return new Promise((r,i)=>{let a=nN++;tN.set(a,{resolve:r,reject:i}),e.postMessage({id:a,input:t},n)})}var aN=1;function oN(e){aN=Math.max(1,e)}zb(oN);function sN(e,t,n,r){typeof document<`u`&&new sg().load(t,t=>{if(t.colorSpace=n===`map`?Lu:``,t.anisotropy=aN,r){let e=t.image,n=e?.width&&e.height?e.height/e.width:1;t.wrapS=hl,t.wrapT=hl,t.repeat.set(1/r,1/(r*n))}e[n]=t,e.needsUpdate=!0},void 0,e=>{Tb().warn(`Failed to load material ${n} ${t}:`,e)})}var cN=e=>e.toFixed(4),lN=120,uN=120,dN=160,fN=.7,pN=.0105,mN=.14,hN=.35,gN=.3,_N=.4,vN=gN*.7*.42,yN=e=>`( ( ${e} ) + ( selvaHash( vec2( ${e}, 6.0 ) ) - 0.5 ) * ${cN(fN)} ) * ${cN(dN)}`,bN=({ring:e,latewood:t,band:n,pores:r,streaks:i})=>`
|
|
5752
|
+
float cell = floor( uv.y / ${cN(dN)} );
|
|
5753
|
+
float plank = cell + ( uv.y < ${yN(`cell`)} ? -1.0 : ( uv.y >= ${yN(`cell + 1.0`)} ? 1.0 : 0.0 ) );
|
|
5754
|
+
float lo = ${yN(`plank`)};
|
|
5755
|
+
float hi = ${yN(`plank + 1.0`)};
|
|
5756
5756
|
// Each plank starts somewhere else along its log.
|
|
5757
5757
|
float along = uv.x + selvaHash( vec2( plank, 9.0 ) ) * 5000.0;
|
|
5758
5758
|
// The pith lies anywhere under the plank, sometimes past its edge, which leaves straight
|
|
@@ -5760,37 +5760,37 @@ void main() {
|
|
|
5760
5760
|
float heart = mix( lo, hi, selvaHash( vec2( plank, 3.0 ) ) * 1.6 - 0.3 );
|
|
5761
5761
|
heart += ( selvaNoise( vec2( along * 0.0006, plank * 7.0 ) ) - 0.5 ) * 50.0;
|
|
5762
5762
|
float s = uv.y - heart;
|
|
5763
|
-
float pith = ${
|
|
5764
|
-
pith += ( selvaFbm( vec2( along * 0.0004, plank * 5.0 + 1.0 ) ) - 0.5 ) * ${
|
|
5765
|
-
float lean = ${
|
|
5763
|
+
float pith = ${cN(lN)} + selvaHash( vec2( plank, 2.0 ) ) * ${cN(uN)};
|
|
5764
|
+
pith += ( selvaFbm( vec2( along * 0.0004, plank * 5.0 + 1.0 ) ) - 0.5 ) * ${cN(50)};
|
|
5765
|
+
float lean = ${cN(pN)} * ( 0.5 + selvaHash( vec2( plank, 8.0 ) ) );
|
|
5766
5766
|
// Rings wander a few mm and vary in spacing, as growth does from year to year.
|
|
5767
|
-
float wander = ( selvaFbm( vec2( along * 0.003, uv.y * 0.008 ) ) - 0.5 ) * ${
|
|
5767
|
+
float wander = ( selvaFbm( vec2( along * 0.003, uv.y * 0.008 ) ) - 0.5 ) * ${cN(e*2)};
|
|
5768
5768
|
float r = sqrt( pith * pith + s * s ) + along * lean + wander;
|
|
5769
|
-
r += selvaFbm( vec2( r * 0.02, plank ) ) * ${
|
|
5770
|
-
float year = fract( r / ${
|
|
5771
|
-
float late = smoothstep( ${
|
|
5769
|
+
r += selvaFbm( vec2( r * 0.02, plank ) ) * ${cN(e*3)} + selvaHash( vec2( plank, 1.0 ) ) * ${cN(e*20)};
|
|
5770
|
+
float year = fract( r / ${cN(e)} );
|
|
5771
|
+
float late = smoothstep( ${cN(1-n)}, ${cN(1-n*.4)}, year ) * ( 1.0 - smoothstep( 0.95, 1.0, year ) );
|
|
5772
5772
|
// Open-pored wood shows its rings as a broken band of pores, not a clean line.
|
|
5773
5773
|
float broken = 1.0 - smoothstep( 0.3, 0.7, selvaNoise( uv * vec2( 0.25, 2.0 ) ) );
|
|
5774
|
-
late *= 1.0 - ${
|
|
5775
|
-
late *= selvaDetail( ${
|
|
5774
|
+
late *= 1.0 - ${cN(r*.45)} * mix( 0.5, broken, selvaDetail( 0.5 ) );
|
|
5775
|
+
late *= selvaDetail( ${cN(e)} );
|
|
5776
5776
|
float fibre = ( selvaNoise( uv * vec2( 0.04, 1.6 ) ) - 0.5 ) * selvaDetail( 1.0 );
|
|
5777
5777
|
// Pores: thin dashes along the grain, most of each row empty. Smaller than a pixel they
|
|
5778
5778
|
// show as their average shade, or they would be static.
|
|
5779
|
-
float poreRow = floor( uv.y / ${
|
|
5779
|
+
float poreRow = floor( uv.y / ${cN(hN)} );
|
|
5780
5780
|
float poreAlong = uv.x / mix( 1.5, 5.0, selvaHash( vec2( poreRow, 11.0 ) ) ) + selvaHash( vec2( poreRow, 12.0 ) );
|
|
5781
5781
|
float poreT = fract( poreAlong );
|
|
5782
|
-
float pore = step( ${
|
|
5782
|
+
float pore = step( ${cN(.7)}, selvaHash( vec2( poreRow, 13.0 + 1.618 * floor( poreAlong ) ) ) );
|
|
5783
5783
|
pore *= smoothstep( 0.0, 0.3, poreT ) * smoothstep( 1.0, 0.7, poreT );
|
|
5784
|
-
pore *= 1.0 - smoothstep( 0.12, 0.3, abs( fract( uv.y / ${
|
|
5785
|
-
pore = mix( ${
|
|
5786
|
-
float streak = ( selvaFbm( vec2( along * 0.0015, uv.y * 0.012 ) ) - 0.5 ) * ${
|
|
5787
|
-
float shade = 1.0 + ${
|
|
5788
|
-
float board = ( selvaHash( vec2( plank, 4.0 ) ) - 0.5 ) * selvaDetail( ${
|
|
5789
|
-
float warmth = ( selvaHash( vec2( plank, 5.0 ) ) - 0.5 ) * selvaDetail( ${
|
|
5790
|
-
tone = vec3( shade ) * ( 1.0 + board * ${
|
|
5784
|
+
pore *= 1.0 - smoothstep( 0.12, 0.3, abs( fract( uv.y / ${cN(hN)} ) - 0.5 ) );
|
|
5785
|
+
pore = mix( ${cN(vN)}, pore, selvaDetail( ${cN(hN)} ) ) * ${cN(r)} * ( 1.0 - 0.6 * late );
|
|
5786
|
+
float streak = ( selvaFbm( vec2( along * 0.0015, uv.y * 0.012 ) ) - 0.5 ) * ${cN(i)};
|
|
5787
|
+
float shade = 1.0 + ${cN(t*n)} - late * ${cN(t)} + fibre * 0.1 - pore * ${cN(_N)} + streak * 0.6;
|
|
5788
|
+
float board = ( selvaHash( vec2( plank, 4.0 ) ) - 0.5 ) * selvaDetail( ${cN(dN*.5)} );
|
|
5789
|
+
float warmth = ( selvaHash( vec2( plank, 5.0 ) ) - 0.5 ) * selvaDetail( ${cN(dN*.5)} );
|
|
5790
|
+
tone = vec3( shade ) * ( 1.0 + board * ${cN(mN)} ) * vec3( 1.0 + warmth * 0.06, 1.0, 1.0 - warmth * 0.06 );
|
|
5791
5791
|
gloss = 1.0 + late * 0.08 + pore * 0.4 - fibre * 0.2;
|
|
5792
5792
|
// No relief from pores: a bump from screen derivatives beads any dash under a few pixels wide.
|
|
5793
|
-
height = fibre * 0.00008 * selvaDetail( 0.6 );`,
|
|
5793
|
+
height = fibre * 0.00008 * selvaDetail( 0.6 );`,xN={wood:bN({ring:4,latewood:.3,band:.4,pores:.4,streaks:.35}),walnut:bN({ring:5,latewood:.2,band:.4,pores:1,streaks:.45}),oak:bN({ring:3,latewood:.3,band:.35,pores:.9,streaks:.25}),maple:bN({ring:3,latewood:.2,band:.1,pores:0,streaks:.12}),wenge:bN({ring:1.5,latewood:.7,band:.5,pores:.6,streaks:.4}),concrete:`
|
|
5794
5794
|
float cloud = ( selvaFbm( uv * 0.002 ) - 0.5 ) * selvaDetail( 80.0 );
|
|
5795
5795
|
float mottle = ( selvaFbm( uv * 0.018 + vec2( 5.0, 1.0 ) ) - 0.5 ) * selvaDetail( 15.0 );
|
|
5796
5796
|
float sand = ( selvaNoise( uv * 0.5 ) - 0.5 ) * selvaDetail( 2.5 );
|
|
@@ -5933,7 +5933,7 @@ void main() {
|
|
|
5933
5933
|
tone = mix( vec3( 0.62, 0.52, 0.46 ), vec3( 1.28, 1.08, 0.9 ), smoothstep( 0.32, 0.68, bloom ) );
|
|
5934
5934
|
tone *= 1.0 + ( scale - 0.5 ) * 0.3;
|
|
5935
5935
|
gloss = 1.0 + ( scale - 0.5 ) * 0.25;
|
|
5936
|
-
height = scale * 0.0004;`};function
|
|
5936
|
+
height = scale * 0.0004;`};function SN(e,t){let n=xN[e];return!n||!(t>0)?null:{key:`surface:${e}:${cN(t)}`,patch:e=>{e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
|
|
5937
5937
|
float selvaFootprint;
|
|
5938
5938
|
// Hash without sine: sin() loses precision on the large arguments mm UVs produce.
|
|
5939
5939
|
float selvaHash( vec2 p ) {
|
|
@@ -5994,8 +5994,8 @@ void main() {
|
|
|
5994
5994
|
float gloss = 1.0;
|
|
5995
5995
|
float height = 0.0;
|
|
5996
5996
|
${n}
|
|
5997
|
-
diffuseColor.rgb *= mix( vec3( 1.0 ), tone, ${
|
|
5998
|
-
roughnessFactor = clamp( roughnessFactor * mix( 1.0, gloss, ${
|
|
5997
|
+
diffuseColor.rgb *= mix( vec3( 1.0 ), tone, ${cN(t)} );`).replace(`#include <roughnessmap_fragment>`,`#include <roughnessmap_fragment>
|
|
5998
|
+
roughnessFactor = clamp( roughnessFactor * mix( 1.0, gloss, ${cN(t)} ), 0.0, 1.0 );`).replace(`#include <normal_fragment_maps>`,`#include <normal_fragment_maps>
|
|
5999
5999
|
{
|
|
6000
6000
|
// Bump from screen derivatives, as three's perturbNormalArb.
|
|
6001
6001
|
vec3 dx = dFdx( - vViewPosition );
|
|
@@ -6003,9 +6003,9 @@ void main() {
|
|
|
6003
6003
|
vec3 r1 = cross( dy, normal );
|
|
6004
6004
|
vec3 r2 = cross( normal, dx );
|
|
6005
6005
|
float det = dot( dx, r1 ) * faceDirection;
|
|
6006
|
-
vec3 grad = sign( det ) * ( dFdx( height ) * r1 + dFdy( height ) * r2 ) * ${
|
|
6006
|
+
vec3 grad = sign( det ) * ( dFdx( height ) * r1 + dFdy( height ) * r2 ) * ${cN(t)};
|
|
6007
6007
|
normal = normalize( abs( det ) * normal - grad );
|
|
6008
|
-
}`)}}}var
|
|
6008
|
+
}`)}}}var CN={brushed:{fibres:[{pitch:.04,length:[2,12],depth:.3},{pitch:.25,length:[5,40],depth:.18}],bands:[]},rolled:{fibres:[{pitch:.3,length:[80,600],depth:.07}],bands:[{width:20,length:1500,depth:.05}]}},wN=.6,TN=.35,EN=16,DN=e=>e.toFixed(4);function ON(e,t){let n=CN[e];if(!n)return SN(e,t);if(!(t>0))return null;let r=n.fibres.map((e,t)=>`selvaFibres( vUv, footprint, ${DN(e.pitch)}, vec2( ${DN(e.length[0])}, ${DN(e.length[1])} ), ${DN(e.depth)}, ${DN(t*31+3)} )`).join(` + `)||`0.0`,i=n.bands.map(e=>`selvaBand( vUv, footprint, vec2( ${DN(e.length)}, ${DN(e.width)} ), ${DN(e.depth)} )`).join(` + `)||`0.0`;return{key:`finish:${e}:${DN(t)}`,patch:e=>{e.fragmentShader=e.fragmentShader.replace(`#include <common>`,`#include <common>
|
|
6009
6009
|
// Hash without sine: sin() loses precision on the large arguments mm UVs produce.
|
|
6010
6010
|
float selvaHash( vec2 p ) {
|
|
6011
6011
|
vec3 p3 = fract( vec3( p.xyx ) * 0.1031 );
|
|
@@ -6028,7 +6028,7 @@ void main() {
|
|
|
6028
6028
|
float selvaFibreRow( vec2 uv, float pitch, vec2 len, float seed ) {
|
|
6029
6029
|
float row = floor( uv.y / pitch );
|
|
6030
6030
|
// A coarse cell stays a streak: as wide as it is long it reads as speckle, not grain.
|
|
6031
|
-
float l = max( mix( len.x, len.y, selvaHash( vec2( row, seed + 1.0 ) ) ), pitch * ${
|
|
6031
|
+
float l = max( mix( len.x, len.y, selvaHash( vec2( row, seed + 1.0 ) ) ), pitch * ${DN(EN)} );
|
|
6032
6032
|
float along = uv.x / l + selvaHash( vec2( row, seed + 2.0 ) );
|
|
6033
6033
|
float seg = floor( along );
|
|
6034
6034
|
float depth = selvaHash( vec2( row, seed + 3.0 + 1.618 * seg ) ) * 2.0 - 1.0;
|
|
@@ -6041,9 +6041,9 @@ void main() {
|
|
|
6041
6041
|
float selvaFibres( vec2 uv, float footprint, float pitch, vec2 len, float depth, float seed ) {
|
|
6042
6042
|
float level = clamp( log2( footprint / pitch ) + 0.5, 0.0, 14.0 );
|
|
6043
6043
|
float l0 = floor( level );
|
|
6044
|
-
float a = selvaFibreRow( uv, pitch * exp2( l0 ), len, seed + 7.0 * l0 ) * exp2( -${TN
|
|
6044
|
+
float a = selvaFibreRow( uv, pitch * exp2( l0 ), len, seed + 7.0 * l0 ) * exp2( -${DN(TN)} * l0 );
|
|
6045
6045
|
float b = selvaFibreRow( uv, pitch * exp2( l0 + 1.0 ), len, seed + 7.0 * l0 + 7.0 )
|
|
6046
|
-
* exp2( -${TN
|
|
6046
|
+
* exp2( -${DN(TN)} * ( l0 + 1.0 ) );
|
|
6047
6047
|
return depth * mix( a, b, level - l0 );
|
|
6048
6048
|
}
|
|
6049
6049
|
float selvaBand( vec2 uv, float footprint, vec2 size, float depth ) {
|
|
@@ -6051,8 +6051,8 @@ void main() {
|
|
|
6051
6051
|
return depth * fade * ( selvaNoise( uv / size ) * 2.0 - 1.0 );
|
|
6052
6052
|
}`).replace(`#include <color_fragment>`,`#include <color_fragment>
|
|
6053
6053
|
float footprint = max( fwidth( vUv.y ), 1e-6 );
|
|
6054
|
-
float selvaFibre = ( ${r} ) * ${
|
|
6055
|
-
float selvaStreak = selvaFibre + ( ${i} ) * ${
|
|
6054
|
+
float selvaFibre = ( ${r} ) * ${DN(t)};
|
|
6055
|
+
float selvaStreak = selvaFibre + ( ${i} ) * ${DN(t)};
|
|
6056
6056
|
diffuseColor.rgb *= 1.0 + 0.5 * selvaStreak;`).replace(`#include <roughnessmap_fragment>`,`#include <roughnessmap_fragment>
|
|
6057
6057
|
roughnessFactor = clamp( roughnessFactor * ( 1.0 + selvaStreak ), 0.0, 1.0 );`).replace(`#include <normal_fragment_maps>`,`#include <normal_fragment_maps>
|
|
6058
6058
|
#ifdef USE_ANISOTROPY
|
|
@@ -6064,22 +6064,22 @@ void main() {
|
|
|
6064
6064
|
vec3 selvaAcross = cross( selvaQ1, normal ) * dFdx( vUv ).y + cross( normal, selvaQ0 ) * dFdy( vUv ).y;
|
|
6065
6065
|
selvaAcross *= inversesqrt( max( dot( selvaAcross, selvaAcross ), 1e-12 ) );
|
|
6066
6066
|
#endif
|
|
6067
|
-
normal = normalize( normal + ${
|
|
6068
|
-
${
|
|
6069
|
-
${
|
|
6070
|
-
gl_FragColor = vec4( ( outgoingLight - paneSpecular ) * diffuseColor.a + paneSpecular, diffuseColor.a );`)})}function
|
|
6067
|
+
normal = normalize( normal + ${DN(wN)} * selvaFibre * selvaAcross );`)}}}var kN=.25;function AN(e,t){return t?.appearance?.cullBackfaces?!0:(t?.closed??!1)&&!e.transparent&&e.opacity>=1}var jN=.2;function MN(e){return(e.transmission??0)>0&&!((e.thickness??0)>0)&&e.roughness<jN}function NN(e,t){let n=new Map;return(r,i)=>{let a=e[r],o=AN(a,{...t,closed:i}),s=`${r}:${o}`,c=n.get(s);return c||(c=PN(a,{...t,closed:o}),n.set(s,c)),c}}function PN(e,t){let n=Nb(e.color),r=t?.vertexColors??!1,i=t?.appearance,a=new Dh({color:n,metalness:e.metalness,roughness:e.roughness,opacity:e.opacity,transparent:e.transparent,vertexColors:r,side:AN(e,t)?0:2,polygonOffset:!0,polygonOffsetFactor:kN,polygonOffsetUnits:0,depthWrite:!(e.transparent||e.opacity<1),depthTest:!0});e.envMapIntensity==null?i?.envMapIntensity!=null&&(a.envMapIntensity=jb(i.envMapIntensity,e.metalness,i.metalReflection)):(a.envMapIntensity=e.envMapIntensity,a.userData[Ab]=e.envMapIntensity),e.emissive!=null&&(a.emissive.set(e.emissive),a.emissiveIntensity=e.emissiveIntensity??1,a.userData[Ob]=!0,e.emissiveLight!=null&&(a.userData[kb]=e.emissiveLight)),e.clearcoat!=null&&(a.clearcoat=e.clearcoat,a.clearcoatRoughness=e.clearcoatRoughness??0),e.sheen!=null&&e.sheen>0&&(a.sheen=e.sheen,a.sheenColor.set(e.sheenColor??`#ffffff`),a.sheenRoughness=e.sheenRoughness??.5),e.anisotropy!=null&&e.anisotropy>0&&t?.hasUvs&&(a.anisotropy=e.anisotropy,a.anisotropyRotation=(e.anisotropyRotation??0)+Math.PI/2),e.ior!=null&&(a.ior=e.ior),e.transmission!=null&&e.transmission>0&&zN(a,e),e.metalness>0&&RN(a),r&&VN(a);let o=e.finish&&t?.hasUvs?ON(e.finish,e.finishStrength??1):null;o&&(a.defines={...a.defines,USE_UV:``},BN(a,o.key,o.patch));let{mapSize:s}=e;return e.map&&sN(a,e.map,`map`,s),e.roughnessMap&&sN(a,e.roughnessMap,`roughnessMap`,s),e.normalMap&&sN(a,e.normalMap,`normalMap`,s),a}var FN=.1,IN=`#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )`,LN=`#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )`;function RN(e){BN(e,`sun-on-metal`,e=>{e.fragmentShader=e.fragmentShader.replace(`#include <lights_fragment_begin>`,f_.lights_fragment_begin.replace(IN,`vec3 specularBeforeSun = reflectedLight.directSpecular;
|
|
6068
|
+
${IN}`).replace(LN,`reflectedLight.directSpecular = specularBeforeSun + ( reflectedLight.directSpecular - specularBeforeSun ) * mix( 1.0, ${FN.toFixed(2)}, metalnessFactor );
|
|
6069
|
+
${LN}`))})}function zN(e,t){let n=Math.min(1,t.transmission);if(e.userData[Bb]=!0,!MN(t)){let r=t.thickness??0;e.transmission=n,e.thickness=r,t.attenuationColor&&r>0&&(e.attenuationColor.set(t.attenuationColor),e.attenuationDistance=r,BN(e,`glass-attenuation`,e=>{e.fragmentShader=e.fragmentShader.replace(`#include <transmission_fragment>`,f_.transmission_fragment.replace(`material.attenuationDistance = attenuationDistance;`,`material.attenuationDistance = attenuationDistance * length( modelMatrix[ 0 ].xyz );`))}))}else e.transparent=!0,e.opacity=t.opacity*(1-n*.96),e.depthWrite=!1,e.blending=5,e.blendSrc=201,e.blendDst=205,BN(e,`glass-pane`,e=>{e.fragmentShader=e.fragmentShader.replace(`#include <opaque_fragment>`,`vec3 paneSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
6070
|
+
gl_FragColor = vec4( ( outgoingLight - paneSpecular ) * diffuseColor.a + paneSpecular, diffuseColor.a );`)})}function BN(e,t,n){let r=e.onBeforeCompile,i=e.customProgramCacheKey.bind(e);e.onBeforeCompile=(t,i)=>{r.call(e,t,i),n(t)},e.customProgramCacheKey=()=>`${i()}|${t}`}function VN(e){BN(e,`srgb-vertex-colors`,e=>{e.vertexShader=e.vertexShader.replace(`#include <color_vertex>`,`#include <color_vertex>
|
|
6071
6071
|
#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
6072
6072
|
vColor.rgb = mix(
|
|
6073
6073
|
vColor.rgb / 12.92,
|
|
6074
6074
|
pow( ( vColor.rgb + 0.055 ) / 1.055, vec3( 2.4 ) ),
|
|
6075
6075
|
step( vec3( 0.04045 ), vColor.rgb )
|
|
6076
6076
|
);
|
|
6077
|
-
#endif`)})}function BN(e){let t=new Map;for(let n of e.meshes){let e=n.layer??``,r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}return[...t.values()].map(t=>({materialId:e.materialId,meshes:t}))}function VN(e){let t=new Map;for(let n of e){let e=t.get(n.materialId);if(e)for(let t of n.meshes)e.push(t);else t.set(n.materialId,n.meshes.slice())}return[...t].flatMap(([e,t])=>BN({materialId:e,meshes:t}))}function HN(e,t,n,r,i=null,a=null){let o=0,s=0;for(let t of e.meshes)o+=t.vertexCount,s+=t.indexCount;let c=new Float32Array(o*3),l=new Uint32Array(s),u=i?new Float32Array(o*2):null,d=a?new Uint8Array(o*3):null,f=0,p=0;for(let r of e.meshes){let e=r.vertexStart*3,o=r.vertexCount*3;if(c.set(t.subarray(e,e+o),f*3),u&&i){let e=r.vertexStart*2;u.set(i.subarray(e,e+r.vertexCount*2),f*2)}d&&a&&d.set(a.subarray(e,e+o),f*3);let s=n.subarray(r.indexStart,r.indexStart+r.indexCount),m=f-r.vertexStart,h=r.vertexStart,g=r.vertexStart+r.vertexCount;for(let e=0;e<s.length;e++){let t=s[e];if(t<h||t>=g)throw VM(t,r);l[p+e]=t+m}f+=r.vertexCount,p+=r.indexCount}let m=YM({positions:c,indices:l,uvs:u,colors:d},e.meshes);return GN(UN(m),e,r(e.materialId,m.closed))}function UN(e){let t=new Rp;return t.setAttribute(`position`,new Cp(e.positions,3)),t.setAttribute(`normal`,new Cp(e.normals,3)),t.setIndex(new Cp(e.indices,1)),e.uvs&&t.setAttribute(`uv`,new Cp(e.uvs,2)),e.tangents&&t.setAttribute(`tangent`,new Cp(e.tangents,4)),e.colors&&t.setAttribute(`color`,new Cp(e.colors,3,!0)),t}function WN(e){let t=[],n=0;for(let r of e.meshes)t.push({trackingKey:r.id,name:r.name,layer:r.layer,metadata:r.metadata??{},indexStart:n,indexCount:r.indexCount}),n+=r.indexCount;return t}function GN(e,t,n){let r=new Om(e,n),i=t.meshes[0],a=t.meshes.map(e=>e.name).filter(e=>e&&e.length>0);return r.name=a.length>0?a[0]:`merged_material_${t.materialId}`,r.castShadow=!Vb(n),r.receiveShadow=!0,r.userData={source:`compute`,name:r.name,layer:i?.layer??``,metadata:i?.metadata??{},members:WN(t)},r}function KN(e,t,n,r,i=null,a=null){let o=[];for(let s of e.meshes){let c=s.vertexStart*3,l=s.vertexCount*3,u=t.slice(c,c+l),d=n.subarray(s.indexStart,s.indexStart+s.indexCount),f=new Uint32Array(d.length),p=s.vertexStart,m=s.vertexStart+s.vertexCount;for(let e=0;e<d.length;e++){let t=d[e];if(t<p||t>=m)throw VM(t,s);f[e]=t-p}let h=s.vertexStart*2,g=YM({positions:u,indices:f,uvs:i?i.slice(h,h+s.vertexCount*2):null,colors:a?a.slice(c,c+l):null},[s]);o.push(qN(UN(g),s,r(e.materialId,g.closed)))}return o}function qN(e,t,n){let r=new Om(e,n);return r.name=t.name,r.userData={source:`compute`,name:t.name,layer:t.layer??``,trackingKey:t.id,metadata:t.metadata??{}},r.castShadow=!Vb(n),r.receiveShadow=!0,r}var JN=268435456,YN=new Map,XN=0;function ZN(e,t){let n=nP(t),r=rP(e,n),i=YN.get(r);return!i||!iP(i.jobShape,n)||!aP(i.geometryBytes,e)?null:(YN.delete(r),YN.set(r,i),i)}function QN(e){let{geometries:t,...n}=e;return{...n,buffers:t.map(UN),closed:t.map(e=>e.closed)}}function $N(e,t,n){let r=QN(n),i=e.byteLength;for(let e of n.geometries)i+=e.positions.byteLength+e.normals.byteLength+e.indices.byteLength,i+=(e.uvs?.byteLength??0)+(e.colors?.byteLength??0)+(e.tangents?.byteLength??0);if(i>JN)return r;let a=nP(t),o=rP(e,a),s=YN.get(o);s&&(YN.delete(o),tP(s)),r.buffers.forEach(sl),YN.set(o,{...r,geometryBytes:e.slice(),jobShape:a,bytes:i}),XN+=i;for(let[e,t]of YN){if(XN<=JN)break;YN.delete(e),tP(t)}return r}function eP(){YN.forEach(tP),YN.clear()}function tP(e){XN-=e.bytes;for(let t of e.buffers)cl(t),t.dispose()}function nP(e){let t=0;for(let n of e)t+=2+4*n.windows.length;let n=new Int32Array(t),r=0;for(let t of e){n[r++]=+(t.kind===`merged`),n[r++]=t.windows.length;for(let e of t.windows)n[r++]=e.vertexStart,n[r++]=e.vertexCount,n[r++]=e.indexStart,n[r++]=e.indexCount}return n}function rP(e,t){let n=e.length,r=Math.max(1,Math.floor(n/1024)),i=2166136261;for(let t=0;t<n;t+=r)i=Math.imul(i^e[t],16777619);let a=2166136261;for(let e=0;e<t.length;e++)a=Math.imul(a^t[e],16777619);return`${n}:${i>>>0}:${t.length}:${a>>>0}`}function iP(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function aP(e,t){if(e.length!==t.length)return!1;let n=0;if(e.byteOffset%4==0&&t.byteOffset%4==0){let r=e.length>>>2,i=new Uint32Array(e.buffer,e.byteOffset,r),a=new Uint32Array(t.buffer,t.byteOffset,r);for(;n<r;n++)if(i[n]!==a[n])return!1;n=r<<2}for(;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}async function oP(e,t,n){let{mergeByMaterial:r=!0,debug:i=!1,material:a}=t??{},{parseTime:o=0,perfStart:s=i?performance.now():0}=n??{};if(!e.compressedData)return[];let c=performance.now(),l={mergeByMaterial:r,debug:i,material:a,fallback:{materials:e.materials,groups:e.groups}},u=await dP(e.compressedData,l);return u.meshes?u.meshes:await gP(u,l)||uP(UM(u.raw),{mergeByMaterial:r,debug:i,material:a,parseTime:o,decodeTime:performance.now()-c,perfStart:s,blobBytes:i?bP(e.compressedData):0,fallback:{materials:e.materials,groups:e.groups}})}var sP=1e3,cP=!1;function lP(e,t){if(e||cP)return;let n=0;for(let e of t)n+=e.meshes.length;n<sP||(cP=!0,Tb().warn(`Parsing ${n} meshes with mergeByMaterial: false — each becomes its own THREE object, and render cost scales with object count. Drop the option to merge by material (the default); per-object identity survives it via userData.members.`))}function uP(e,t){let{mergeByMaterial:n,debug:r,material:i,parseTime:a,decodeTime:o,perfStart:s,blobBytes:c,fallback:l}=t,u=e.metadata.materials??l?.materials??[],d=e.metadata.groups??l?.groups??[],f=!!(e.flags&1);BM(u,d,e.vertices.length/3,e.indices.length);let p=f?e.vertices:HM(e.vertices,e.origin,e.scale);if(r){let t=e.vertices.byteLength+e.indices.byteLength;Tb().debug(`Mesh Batch Stats:`),Tb().debug(` Materials: ${u.length} | Groups: ${d.length}`),Tb().debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),Tb().debug(` Format: ${f?`float32`:`int16 quantized`}`),Tb().debug(` Blob: ${(c/1024/1024).toFixed(2)} MB | Geometry on wire: ${(t/1024/1024).toFixed(2)} MB`)}lP(n,d);let m=performance.now(),h=jN(u,{vertexColors:e.colors!=null,hasUvs:e.uvs!=null,appearance:i}),g=[],_=n?VN(d):d;for(let t of _)if(n&&t.meshes.length>1){let n=HN(t,p,e.indices,h,e.uvs,e.colors);g.push(n)}else{let n=KN(t,p,e.indices,h,e.uvs,e.colors);for(let e of n)g.push(e)}let v=performance.now()-m;if(r){let e=performance.now()-s;Tb().debug(`Performance:`),a>0&&Tb().debug(` Parse JSON: ${a.toFixed(2)}ms`),Tb().debug(` Decode binary: ${o.toFixed(2)}ms`),Tb().debug(` Create Meshes: ${v.toFixed(2)}ms`),Tb().debug(` Total: ${e.toFixed(2)}ms`)}return Promise.resolve(g)}async function dP(e,t){let n=Jj(e);if(!kM(n))return{raw:WM(n),geometryBytes:null,source:n,reparse:()=>WM(n)};let r=AM(n),i=mP(r,t);if(i)return{meshes:i};let a=r.geometryBlob,o=()=>{let e=WM(a);return e.metadata=r.metadata,e},s=await pP(r),c=s?WM(s):o();return c.metadata=r.metadata,{raw:c,geometryBytes:a,source:a,reparse:o}}var fP=4194304;async function pP(e){if(Xj(e.geometryBlob)<fP||!tN())return null;try{return await tM(e.geometryBlob)}catch{return null}}function mP(e,t){let n=e.metadata.materials??t.fallback?.materials??[],r=e.metadata.groups??t.fallback?.groups??[],{jobs:i,jobRefs:a}=hP(r,t.mergeByMaterial),o=ZN(e.geometryBlob,i);return o?(BM(n,r,o.vertexCount,o.indexCount),yP(o,a,n,t.material)):null}function hP(e,t){let n=e=>({vertexStart:e.vertexStart,vertexCount:e.vertexCount,indexStart:e.indexStart,indexCount:e.indexCount,closed:e.closed}),r=[],i=[],a=t?VN(e):e;for(let e of a)if(t&&e.meshes.length>1)r.push({kind:`merged`,windows:e.meshes.map(n)}),i.push({kind:`merged`,group:e});else for(let t of e.meshes)r.push({kind:`single`,windows:[n(t)]}),i.push({kind:`single`,group:e,meshMeta:t});return{jobs:r,jobRefs:i}}async function gP(e,t){let{raw:n,geometryBytes:r}=e,i=n.planarByteSplit?n.indexData.length/(n.uint16Indices?2:4):n.indexData.length;if(i/3<5e4)return null;let a=n.metadata.materials??t.fallback?.materials??[],o=n.metadata.groups??t.fallback?.groups??[];BM(a,o,n.vertexCount,i);let{jobs:s,jobRefs:c}=hP(o,t.mergeByMaterial),l=await vP(n,s,e.source);if(!l)return _P(n,e.source)&&(e.raw=e.reparse()),null;let u={geometries:l,hasUvs:n.uvs!=null,hasColors:n.colors!=null,vertexCount:n.vertexCount,indexCount:i},d=r?$N(r,s,u):QN(u);return t.debug&&Tb().debug(`Mesh batch assembled: ${l.length} geometries, ${i/3} triangles`),yP(d,c,a,t.material)}function _P(e,t){return e.vertexData.buffer!==t.buffer&&e.indexData.buffer!==t.buffer}async function vP(e,t,n){let r=tN(),i={vertexData:e.vertexData,isFloat32:e.isFloat32,deltaEncoded:e.deltaEncoded,planarByteSplit:e.planarByteSplit,uint16Indices:e.uint16Indices,origin:e.origin,scale:e.scale,indexData:e.indexData,uvs:e.uvs,colors:e.colors,jobs:t};if(!r){let e;try{e=XM(i)}catch(e){throw new Cb(e instanceof Error?e.message:String(e),Sb.VALIDATION_ERROR,{originalError:e instanceof Error?e:void 0})}return e.map((e,n)=>YM(e,t[n].windows))}_P(e,n)||(i.vertexData=e.vertexData.slice(),i.indexData=e.indexData.slice(),i.uvs=e.uvs?.slice()??null,i.colors=e.colors?.slice()??null);let a=new Set([i.vertexData.buffer,i.indexData.buffer]);i.uvs&&a.add(i.uvs.buffer),i.colors&&a.add(i.colors.buffer);try{let e=await nN(r,i,[...a]);return e.length===t.length?e:null}catch(e){return Tb().warn(`Mesh assembly worker failed; falling back to main-thread parse.`,e),null}}function yP(e,t,n,r){let i=jN(n,{vertexColors:e.hasColors,hasUvs:e.hasUvs,appearance:r}),a=[];for(let n=0;n<e.buffers.length;n++){let r=e.buffers[n],o=t[n],s=i(o.group.materialId,e.closed[n]),c=o.kind===`merged`?GN(r,o.group,s):qN(r,o.meshMeta,s);a.push(c)}return a}function bP(e){return Math.floor(e.length*3/4)}var xP={Angstroms:1e-10,Nanometers:1e-9,Microns:1e-6,Millimeters:.001,Centimeters:.01,Decimeters:.1,Meters:1,Dekameters:10,Hectometers:100,Kilometers:1e3,Megameters:1e6,Gigameters:1e9,Microinches:2.54e-8,Mils:254e-7,Inches:.0254,Feet:.3048,Yards:.9144,Miles:1609.344,NauticalMiles:1852},SP=`Display`,CP=`DisplayBatch`;function wP(e){let t=e.split(`.`);return t.includes(SP)||t.includes(CP)}var TP=new Set;async function EP(e,t){let n=performance.now(),r=[],{allowScaling:i=!0,allowAutoPosition:a=!1,groundAxis:o=`z`,debug:s=!1,parsing:c={}}=t??{};try{return await OP(e,r,i?DP(e.modelunits):1,c,s),a&&MP(r,o),r}catch(e){throw NP(e,r),e}finally{s&&FP(n)}}function DP(e){let t=xP[e];return t===void 0?(TP.has(e)||(TP.add(e),Tb().warn(`Unknown Rhino model unit "${e}" — geometry will not be scaled (factor 1). Known units: ${Object.keys(xP).join(`, `)}.`)),1):t}async function OP(e,t,n,r,i){for(let a of e.values){let e=a.InnerTree;for(let a in e){let o=e[a];o&&await kP(o,t,n,r,i)}}}async function kP(e,t,n,r,i){for(let a of e){if(!wP(a.type))continue;let e={debug:!1,...r,mergeByMaterial:r.mergeByMaterial??!0},o=AP(a.data);if(!o){Tb().error(`Error parsing display batch envelope: invalid JSON`);continue}let s=await oP(o,e),c=Gj(o.items),l=[...s,...c];if(n!==1)for(let e of l)e.scale.set(n,n,n);for(let e of l)t.push(e);i&&Tb().debug(`Extracted ${s.length} meshes and ${c.length} items from batch`)}}function AP(e){return typeof e==`string`?jP(e):e}function jP(e){try{return JSON.parse(e)}catch{return}}function MP(e,t){e.length!==0&&Pb(e,Fb(e).min[t],t)}function NP(e,t){Tb().error(`An unexpected error occurred:`,e),PP(t)}function PP(e){for(let t of e)Gb(t)}function FP(e){let t=performance.now()-e;Tb().info(`Time to process meshes:`,`${t.toFixed(2)}ms`)}var IP=D(`<button><!></button>`),LP=D(`<div class="gap-1 pl-1 pr-2 group flex h-full items-center transition-colors hover:bg-hover svelte-br1q9x"><button class="p-0.5 shrink-0 rounded-sm text-muted-foreground transition-colors hover:text-muted-foreground"><!></button> <button class="p-1 shrink-0 rounded-sm transition-colors hover:bg-hover"><!></button> <span> </span> <span class="shrink-0 text-2xs text-faint-foreground tabular-nums"> </span></div>`),RP=D(`<div class="ml-3 h-full border-l border-border svelte-br1q9x"><div role="option" tabindex="-1"><button class="p-1 shrink-0 rounded-sm transition-colors hover:bg-hover"><!></button> <span> </span> <span class="px-1 py-0.5 font-medium shrink-0 rounded-sm bg-muted text-2xs text-faint-foreground"> </span></div></div>`),zP=D(`<div class="inset-x-0 absolute top-(--row-top) h-(--row-h) svelte-br1q9x"><!></div>`),BP=D(`<div class="py-12 flex flex-col items-center justify-center text-center svelte-br1q9x"><!> <p class="text-xs text-muted-foreground"> </p></div>`),VP=D(`<div class="flex h-full flex-col bg-card text-card-foreground svelte-br1q9x"><div class="px-3 py-2 gap-2 flex items-center border-b border-border svelte-br1q9x"><!> <input class="min-w-0 text-xs flex-1 bg-transparent text-foreground outline-none placeholder:text-faint-foreground"/> <!> <button class="shrink-0"><!></button></div> <div class="py-1 flex-1 overflow-y-auto svelte-br1q9x"><div role="listbox" aria-multiselectable="true" class="relative h-(--list-h) svelte-br1q9x"></div> <!></div></div>`);function HP(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),o=J(n,`sceneVersion`,3,0),s=e=>{let t=e.length>0&&e.every(e=>I(e));for(let r of e)n.outliner.visibility.setEntryVisible(r,t);n.onVisibilityChange?.()},l=e=>{n.outliner.toggleEntry(e),n.onVisibilityChange?.()};le(()=>(o(),()=>n.onHover?.(null)));let u=T(()=>n.outliner.visibility.hidden),d=T(()=>n.outliner.selection.selected),p=T(()=>n.outliner.collapsed),h=Z(``),g=Z(null),_=!1;le(()=>n.outliner.onAnchorChange(e=>P(g,e,!0)));let v=T(()=>(o(),n.outliner.objects())),y=T(()=>(o(),n.outliner.entryGroups(C(h)))),x=()=>{for(let e of n.outliner.entryGroups().keys())C(p).add(e)};le(()=>{o(),!(_||n.outliner.entryGroups().size===0)&&(_=!0,x())});let S=()=>C(p).clear(),w=T(()=>C(y).size>0&&[...C(y).keys()].every(e=>C(p).has(e))),E=T(()=>{let e=[],t=0;for(let[n,r]of C(y))if(e.push({kind:`layer`,key:`layer:${n}`,top:t,height:30,layerName:n,entries:r}),t+=30,!C(p).has(n))for(let n of r)e.push({kind:`object`,key:`obj:${n.rowKey}`,top:t,height:24,entry:n}),t+=24;return e}),D=T(()=>C(E).length===0?0:C(E)[C(E).length-1].top+C(E)[C(E).length-1].height),k=Z(0),A=Z(0),M=e=>{let t=0,n=C(E).length-1;for(;t<n;){let r=t+n>>1;C(E)[r].top+C(E)[r].height<=e?t=r+1:n=r}return t},F=T(()=>{if(C(E).length===0)return[];let e=C(A)||600,t=Math.max(0,M(C(k))-8),n=Math.min(C(E).length,M(C(k)+e)+1+8);return C(E).slice(t,n)}),I=e=>e.memberIndex===null?tA(e.object).every(e=>C(u).has(e)):C(u).has(e.key),ee=e=>e.filter(e=>I(e)).length,te=(e,t)=>{C(g),n.outliner.select(e,{shiftKey:t.shiftKey,toggleKey:t.ctrlKey||t.metaKey},C(h))};var R=VP(),z=L(R),B=L(z);Nt(B,{class:`h-3.5 w-3.5 shrink-0 text-faint-foreground`});var ne=U(B,2);se(ne);var re=U(ne,2),ie=e=>{var t=IP(),n=L(t);Lt(n,{class:`h-3.5 w-3.5 text-faint-foreground transition-colors hover:text-muted-foreground`}),c(t),G(()=>H(t,`aria-label`,C(i).clearSearch)),f(`click`,t,()=>P(h,``)),O(e,t)};t(re,e=>{C(h)&&e(ie)});var ae=U(re,2),W=L(ae),ce=e=>{dt(e,{class:`h-3.5 w-3.5 text-faint-foreground transition-colors hover:text-muted-foreground`})},q=e=>{Mn(e,{class:`h-3.5 w-3.5 text-faint-foreground transition-colors hover:text-muted-foreground`})};t(W,e=>{C(w)?e(ce):e(q,-1)}),c(ae),c(z);var Y=U(z,2),de=L(Y);let X;a(de,21,()=>C(F),e=>e.key,(e,r)=>{var a=zP();let o;var u=L(a),h=e=>{let a=T(()=>C(r).entries),o=T(()=>ee(C(a))),l=T(()=>C(a).length>0&&C(o)===C(a).length),u=T(()=>C(o)>0&&C(o)<C(a).length),d=T(()=>C(p).has(C(r).layerName));var h=LP(),g=L(h),_=L(g);{let e=T(()=>C(d)?``:`rotate-90`);ut(_,{get class(){return`h-3.5 w-3.5 transition-transform duration-150 ${C(e)??``}`}})}c(g);var v=U(g,2),y=L(v),b=e=>{qn(e,{class:`h-3.5 w-3.5 text-faint-foreground`})},x=e=>{Wn(e,{class:`h-3.5 w-3.5 text-faint-foreground`})},S=e=>{Wn(e,{class:`h-3.5 w-3.5 text-muted-foreground`})};t(y,e=>{C(l)?e(b):C(u)?e(x,1):e(S,-1)}),c(v);var w=U(v,2),E=K(w,!0),D=U(w,2),k=K(D,!0);c(h),G(()=>{H(g,`aria-label`,C(d)?C(i).expandLayer:C(i).collapseLayer),H(v,`title`,C(l)?C(i).showLayer:C(i).hideLayer),H(v,`aria-label`,C(l)?C(i).showLayer:C(i).hideLayer),fe(w,1,`min-w-0 text-xs font-medium flex-1 truncate ${C(l)?`text-faint-foreground line-through`:`text-foreground`}`),m(E,C(r).layerName),m(k,C(a).length)}),f(`click`,g,()=>n.outliner.toggleCollapsed(C(r).layerName)),f(`click`,v,()=>s(C(a))),O(e,h)},g=e=>{let a=T(()=>C(r).entry),o=T(()=>I(C(a))),s=T(()=>C(d).has(C(a).key));var u=RP(),p=L(u),h=L(p),g=L(h),_=e=>{qn(e,{class:`h-3 w-3 text-faint-foreground`})},v=e=>{Wn(e,{class:`h-3 w-3 text-muted-foreground`})};t(g,e=>{C(o)?e(_):e(v,-1)}),c(h);var y=U(h,2),b=K(y,!0),x=U(y,2),S=K(x,!0);c(p),c(u),G(e=>{H(p,`aria-selected`,C(s)),fe(p,1,`gap-1.5 pl-5 pr-2 flex h-full cursor-pointer items-center transition-colors
|
|
6077
|
+
#endif`)})}function HN(e){let t=new Map;for(let n of e.meshes){let e=n.layer??``,r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}return[...t.values()].map(t=>({materialId:e.materialId,meshes:t}))}function UN(e){let t=new Map;for(let n of e){let e=t.get(n.materialId);if(e)for(let t of n.meshes)e.push(t);else t.set(n.materialId,n.meshes.slice())}return[...t].flatMap(([e,t])=>HN({materialId:e,meshes:t}))}function WN(e,t,n,r,i=null,a=null){let o=0,s=0;for(let t of e.meshes)o+=t.vertexCount,s+=t.indexCount;let c=new Float32Array(o*3),l=new Uint32Array(s),u=i?new Float32Array(o*2):null,d=a?new Uint8Array(o*3):null,f=0,p=0;for(let r of e.meshes){let e=r.vertexStart*3,o=r.vertexCount*3;if(c.set(t.subarray(e,e+o),f*3),u&&i){let e=r.vertexStart*2;u.set(i.subarray(e,e+r.vertexCount*2),f*2)}d&&a&&d.set(a.subarray(e,e+o),f*3);let s=n.subarray(r.indexStart,r.indexStart+r.indexCount),m=f-r.vertexStart,h=r.vertexStart,g=r.vertexStart+r.vertexCount;for(let e=0;e<s.length;e++){let t=s[e];if(t<h||t>=g)throw UM(t,r);l[p+e]=t+m}f+=r.vertexCount,p+=r.indexCount}let m=ZM({positions:c,indices:l,uvs:u,colors:d},e.meshes);return qN(GN(m),e,r(e.materialId,m.closed))}function GN(e){let t=new Rp;return t.setAttribute(`position`,new Cp(e.positions,3)),t.setAttribute(`normal`,new Cp(e.normals,3)),t.setIndex(new Cp(e.indices,1)),e.uvs&&t.setAttribute(`uv`,new Cp(e.uvs,2)),e.tangents&&t.setAttribute(`tangent`,new Cp(e.tangents,4)),e.colors&&t.setAttribute(`color`,new Cp(e.colors,3,!0)),t}function KN(e){let t=[],n=0;for(let r of e.meshes)t.push({trackingKey:r.id,name:r.name,layer:r.layer,metadata:r.metadata??{},indexStart:n,indexCount:r.indexCount}),n+=r.indexCount;return t}function qN(e,t,n){let r=new Om(e,n),i=t.meshes[0],a=t.meshes.map(e=>e.name).filter(e=>e&&e.length>0);return r.name=a.length>0?a[0]:`merged_material_${t.materialId}`,r.castShadow=!Vb(n),r.receiveShadow=!0,r.userData={source:`compute`,name:r.name,layer:i?.layer??``,metadata:i?.metadata??{},members:KN(t)},r}function JN(e,t,n,r,i=null,a=null){let o=[];for(let s of e.meshes){let c=s.vertexStart*3,l=s.vertexCount*3,u=t.slice(c,c+l),d=n.subarray(s.indexStart,s.indexStart+s.indexCount),f=new Uint32Array(d.length),p=s.vertexStart,m=s.vertexStart+s.vertexCount;for(let e=0;e<d.length;e++){let t=d[e];if(t<p||t>=m)throw UM(t,s);f[e]=t-p}let h=s.vertexStart*2,g=ZM({positions:u,indices:f,uvs:i?i.slice(h,h+s.vertexCount*2):null,colors:a?a.slice(c,c+l):null},[s]);o.push(YN(GN(g),s,r(e.materialId,g.closed)))}return o}function YN(e,t,n){let r=new Om(e,n);return r.name=t.name,r.userData={source:`compute`,name:t.name,layer:t.layer??``,trackingKey:t.id,metadata:t.metadata??{}},r.castShadow=!Vb(n),r.receiveShadow=!0,r}var XN=268435456,ZN=new Map,QN=0;function $N(e,t){let n=iP(t),r=aP(e,n),i=ZN.get(r);return!i||!oP(i.jobShape,n)||!sP(i.geometryBytes,e)?null:(ZN.delete(r),ZN.set(r,i),i)}function eP(e){let{geometries:t,...n}=e;return{...n,buffers:t.map(GN),closed:t.map(e=>e.closed)}}function tP(e,t,n){let r=eP(n),i=e.byteLength;for(let e of n.geometries)i+=e.positions.byteLength+e.normals.byteLength+e.indices.byteLength,i+=(e.uvs?.byteLength??0)+(e.colors?.byteLength??0)+(e.tangents?.byteLength??0);if(i>XN)return r;let a=iP(t),o=aP(e,a),s=ZN.get(o);s&&(ZN.delete(o),rP(s)),r.buffers.forEach(sl),ZN.set(o,{...r,geometryBytes:e.slice(),jobShape:a,bytes:i}),QN+=i;for(let[e,t]of ZN){if(QN<=XN)break;ZN.delete(e),rP(t)}return r}function nP(){ZN.forEach(rP),ZN.clear()}function rP(e){QN-=e.bytes;for(let t of e.buffers)cl(t),t.dispose()}function iP(e){let t=0;for(let n of e)t+=2+4*n.windows.length;let n=new Int32Array(t),r=0;for(let t of e){n[r++]=+(t.kind===`merged`),n[r++]=t.windows.length;for(let e of t.windows)n[r++]=e.vertexStart,n[r++]=e.vertexCount,n[r++]=e.indexStart,n[r++]=e.indexCount}return n}function aP(e,t){let n=e.length,r=Math.max(1,Math.floor(n/1024)),i=2166136261;for(let t=0;t<n;t+=r)i=Math.imul(i^e[t],16777619);let a=2166136261;for(let e=0;e<t.length;e++)a=Math.imul(a^t[e],16777619);return`${n}:${i>>>0}:${t.length}:${a>>>0}`}function oP(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function sP(e,t){if(e.length!==t.length)return!1;let n=0;if(e.byteOffset%4==0&&t.byteOffset%4==0){let r=e.length>>>2,i=new Uint32Array(e.buffer,e.byteOffset,r),a=new Uint32Array(t.buffer,t.byteOffset,r);for(;n<r;n++)if(i[n]!==a[n])return!1;n=r<<2}for(;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}async function cP(e,t,n){let{mergeByMaterial:r=!0,debug:i=!1,material:a}=t??{},{parseTime:o=0,perfStart:s=i?performance.now():0}=n??{};if(!e.compressedData)return[];let c=performance.now(),l={mergeByMaterial:r,debug:i,material:a,fallback:{materials:e.materials,groups:e.groups}},u=await pP(e.compressedData,l);return u.meshes?u.meshes:await vP(u,l)||fP(GM(u.raw),{mergeByMaterial:r,debug:i,material:a,parseTime:o,decodeTime:performance.now()-c,perfStart:s,blobBytes:i?SP(e.compressedData):0,fallback:{materials:e.materials,groups:e.groups}})}var lP=1e3,uP=!1;function dP(e,t){if(e||uP)return;let n=0;for(let e of t)n+=e.meshes.length;n<lP||(uP=!0,Tb().warn(`Parsing ${n} meshes with mergeByMaterial: false — each becomes its own THREE object, and render cost scales with object count. Drop the option to merge by material (the default); per-object identity survives it via userData.members.`))}function fP(e,t){let{mergeByMaterial:n,debug:r,material:i,parseTime:a,decodeTime:o,perfStart:s,blobBytes:c,fallback:l}=t,u=e.metadata.materials??l?.materials??[],d=e.metadata.groups??l?.groups??[],f=!!(e.flags&1);HM(u,d,e.vertices.length/3,e.indices.length);let p=f?e.vertices:WM(e.vertices,e.origin,e.scale);if(r){let t=e.vertices.byteLength+e.indices.byteLength;Tb().debug(`Mesh Batch Stats:`),Tb().debug(` Materials: ${u.length} | Groups: ${d.length}`),Tb().debug(` Vertices: ${e.vertices.length/3} | Indices: ${e.indices.length}`),Tb().debug(` Format: ${f?`float32`:`int16 quantized`}`),Tb().debug(` Blob: ${(c/1024/1024).toFixed(2)} MB | Geometry on wire: ${(t/1024/1024).toFixed(2)} MB`)}dP(n,d);let m=performance.now(),h=NN(u,{vertexColors:e.colors!=null,hasUvs:e.uvs!=null,appearance:i}),g=[],_=n?UN(d):d;for(let t of _)if(n&&t.meshes.length>1){let n=WN(t,p,e.indices,h,e.uvs,e.colors);g.push(n)}else{let n=JN(t,p,e.indices,h,e.uvs,e.colors);for(let e of n)g.push(e)}let v=performance.now()-m;if(r){let e=performance.now()-s;Tb().debug(`Performance:`),a>0&&Tb().debug(` Parse JSON: ${a.toFixed(2)}ms`),Tb().debug(` Decode binary: ${o.toFixed(2)}ms`),Tb().debug(` Create Meshes: ${v.toFixed(2)}ms`),Tb().debug(` Total: ${e.toFixed(2)}ms`)}return Promise.resolve(g)}async function pP(e,t){let n=Xj(e);if(!jM(n))return{raw:KM(n),geometryBytes:null,source:n,reparse:()=>KM(n)};let r=MM(n),i=gP(r,t);if(i)return{meshes:i};let a=r.geometryBlob,o=()=>{let e=KM(a);return e.metadata=r.metadata,e},s=await hP(r),c=s?KM(s):o();return c.metadata=r.metadata,{raw:c,geometryBytes:a,source:a,reparse:o}}var mP=4194304;async function hP(e){if(Qj(e.geometryBlob)<mP||!rN())return null;try{return await rM(e.geometryBlob)}catch{return null}}function gP(e,t){let n=e.metadata.materials??t.fallback?.materials??[],r=e.metadata.groups??t.fallback?.groups??[],{jobs:i,jobRefs:a}=_P(r,t.mergeByMaterial),o=$N(e.geometryBlob,i);return o?(HM(n,r,o.vertexCount,o.indexCount),xP(o,a,n,t.material)):null}function _P(e,t){let n=e=>({vertexStart:e.vertexStart,vertexCount:e.vertexCount,indexStart:e.indexStart,indexCount:e.indexCount,closed:e.closed}),r=[],i=[],a=t?UN(e):e;for(let e of a)if(t&&e.meshes.length>1)r.push({kind:`merged`,windows:e.meshes.map(n)}),i.push({kind:`merged`,group:e});else for(let t of e.meshes)r.push({kind:`single`,windows:[n(t)]}),i.push({kind:`single`,group:e,meshMeta:t});return{jobs:r,jobRefs:i}}async function vP(e,t){let{raw:n,geometryBytes:r}=e,i=n.planarByteSplit?n.indexData.length/(n.uint16Indices?2:4):n.indexData.length;if(i/3<5e4)return null;let a=n.metadata.materials??t.fallback?.materials??[],o=n.metadata.groups??t.fallback?.groups??[];HM(a,o,n.vertexCount,i);let{jobs:s,jobRefs:c}=_P(o,t.mergeByMaterial),l=await bP(n,s,e.source);if(!l)return yP(n,e.source)&&(e.raw=e.reparse()),null;let u={geometries:l,hasUvs:n.uvs!=null,hasColors:n.colors!=null,vertexCount:n.vertexCount,indexCount:i},d=r?tP(r,s,u):eP(u);return t.debug&&Tb().debug(`Mesh batch assembled: ${l.length} geometries, ${i/3} triangles`),xP(d,c,a,t.material)}function yP(e,t){return e.vertexData.buffer!==t.buffer&&e.indexData.buffer!==t.buffer}async function bP(e,t,n){let r=rN(),i={vertexData:e.vertexData,isFloat32:e.isFloat32,deltaEncoded:e.deltaEncoded,planarByteSplit:e.planarByteSplit,uint16Indices:e.uint16Indices,origin:e.origin,scale:e.scale,indexData:e.indexData,uvs:e.uvs,colors:e.colors,jobs:t};if(!r){let e;try{e=QM(i)}catch(e){throw new Cb(e instanceof Error?e.message:String(e),Sb.VALIDATION_ERROR,{originalError:e instanceof Error?e:void 0})}return e.map((e,n)=>ZM(e,t[n].windows))}yP(e,n)||(i.vertexData=e.vertexData.slice(),i.indexData=e.indexData.slice(),i.uvs=e.uvs?.slice()??null,i.colors=e.colors?.slice()??null);let a=new Set([i.vertexData.buffer,i.indexData.buffer]);i.uvs&&a.add(i.uvs.buffer),i.colors&&a.add(i.colors.buffer);try{let e=await iN(r,i,[...a]);return e.length===t.length?e:null}catch(e){return Tb().warn(`Mesh assembly worker failed; falling back to main-thread parse.`,e),null}}function xP(e,t,n,r){let i=NN(n,{vertexColors:e.hasColors,hasUvs:e.hasUvs,appearance:r}),a=[];for(let n=0;n<e.buffers.length;n++){let r=e.buffers[n],o=t[n],s=i(o.group.materialId,e.closed[n]),c=o.kind===`merged`?qN(r,o.group,s):YN(r,o.meshMeta,s);a.push(c)}return a}function SP(e){return Math.floor(e.length*3/4)}var CP={Angstroms:1e-10,Nanometers:1e-9,Microns:1e-6,Millimeters:.001,Centimeters:.01,Decimeters:.1,Meters:1,Dekameters:10,Hectometers:100,Kilometers:1e3,Megameters:1e6,Gigameters:1e9,Microinches:2.54e-8,Mils:254e-7,Inches:.0254,Feet:.3048,Yards:.9144,Miles:1609.344,NauticalMiles:1852},wP=`Display`,TP=`DisplayBatch`;function EP(e){let t=e.split(`.`);return t.includes(wP)||t.includes(TP)}var DP=new Set;async function OP(e,t){let n=performance.now(),r=[],{allowScaling:i=!0,allowAutoPosition:a=!1,groundAxis:o=`z`,debug:s=!1,parsing:c={}}=t??{};try{return await AP(e,r,i?kP(e.modelunits):1,c,s),a&&PP(r,o),r}catch(e){throw FP(e,r),e}finally{s&&LP(n)}}function kP(e){let t=CP[e];return t===void 0?(DP.has(e)||(DP.add(e),Tb().warn(`Unknown Rhino model unit "${e}" — geometry will not be scaled (factor 1). Known units: ${Object.keys(CP).join(`, `)}.`)),1):t}async function AP(e,t,n,r,i){for(let a of e.values){let e=a.InnerTree;for(let a in e){let o=e[a];o&&await jP(o,t,n,r,i)}}}async function jP(e,t,n,r,i){for(let a of e){if(!EP(a.type))continue;let e={debug:!1,...r,mergeByMaterial:r.mergeByMaterial??!0},o=MP(a.data);if(!o){Tb().error(`Error parsing display batch envelope: invalid JSON`);continue}let s=await cP(o,e),c=qj(o.items),l=[...s,...c];if(n!==1)for(let e of l)e.scale.set(n,n,n);for(let e of l)t.push(e);i&&Tb().debug(`Extracted ${s.length} meshes and ${c.length} items from batch`)}}function MP(e){return typeof e==`string`?NP(e):e}function NP(e){try{return JSON.parse(e)}catch{return}}function PP(e,t){e.length!==0&&Pb(e,Fb(e).min[t],t)}function FP(e,t){Tb().error(`An unexpected error occurred:`,e),IP(t)}function IP(e){for(let t of e)Gb(t)}function LP(e){let t=performance.now()-e;Tb().info(`Time to process meshes:`,`${t.toFixed(2)}ms`)}var RP=D(`<button><!></button>`),zP=D(`<div class="gap-1 pl-1 pr-2 group flex h-full items-center transition-colors hover:bg-hover svelte-br1q9x"><button class="p-0.5 shrink-0 rounded-sm text-muted-foreground transition-colors hover:text-muted-foreground"><!></button> <button class="p-1 shrink-0 rounded-sm transition-colors hover:bg-hover"><!></button> <span> </span> <span class="shrink-0 text-2xs text-faint-foreground tabular-nums"> </span></div>`),BP=D(`<div class="ml-3 h-full border-l border-border svelte-br1q9x"><div role="option" tabindex="-1"><button class="p-1 shrink-0 rounded-sm transition-colors hover:bg-hover"><!></button> <span> </span> <span class="px-1 py-0.5 font-medium shrink-0 rounded-sm bg-muted text-2xs text-faint-foreground"> </span></div></div>`),VP=D(`<div class="inset-x-0 absolute top-(--row-top) h-(--row-h) svelte-br1q9x"><!></div>`),HP=D(`<div class="py-12 flex flex-col items-center justify-center text-center svelte-br1q9x"><!> <p class="text-xs text-muted-foreground"> </p></div>`),UP=D(`<div class="flex h-full flex-col bg-card text-card-foreground svelte-br1q9x"><div class="px-3 py-2 gap-2 flex items-center border-b border-border svelte-br1q9x"><!> <input class="min-w-0 text-xs flex-1 bg-transparent text-foreground outline-none placeholder:text-faint-foreground"/> <!> <button class="shrink-0"><!></button></div> <div class="py-1 flex-1 overflow-y-auto svelte-br1q9x"><div role="listbox" aria-multiselectable="true" class="relative h-(--list-h) svelte-br1q9x"></div> <!></div></div>`);function WP(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),o=J(n,`sceneVersion`,3,0),s=e=>{let t=e.length>0&&e.every(e=>ee(e));for(let r of e)n.outliner.visibility.setEntryVisible(r,t);n.onVisibilityChange?.()},l=e=>{n.outliner.toggleEntry(e),n.onVisibilityChange?.()};le(()=>(o(),()=>n.onHover?.(null)));let u=T(()=>n.outliner.visibility.hidden),d=T(()=>n.outliner.selection.selected),p=T(()=>n.outliner.collapsed),h=Z(``),g=Z(null),_=!1;le(()=>n.outliner.onAnchorChange(e=>P(g,e,!0)));let v=T(()=>(o(),n.outliner.objects())),y=T(()=>(o(),n.outliner.entryGroups(C(h)))),x=()=>{for(let e of n.outliner.entryGroups().keys())C(p).add(e)};le(()=>{o(),!(_||n.outliner.entryGroups().size===0)&&(_=!0,x())});let S=()=>C(p).clear(),w=T(()=>C(y).size>0&&[...C(y).keys()].every(e=>C(p).has(e))),E=T(()=>{let e=[],t=0;for(let[n,r]of C(y))if(e.push({kind:`layer`,key:`layer:${n}`,top:t,height:30,layerName:n,entries:r}),t+=30,!C(p).has(n))for(let n of r)e.push({kind:`object`,key:`obj:${n.rowKey}`,top:t,height:24,entry:n}),t+=24;return e}),D=T(()=>C(E).length===0?0:C(E)[C(E).length-1].top+C(E)[C(E).length-1].height),k=Z(0),A=Z(0),M=e=>{let t=0,n=C(E).length-1;for(;t<n;){let r=t+n>>1;C(E)[r].top+C(E)[r].height<=e?t=r+1:n=r}return t},F=T(()=>{if(C(E).length===0)return[];let e=C(A)||600,t=Math.max(0,M(C(k))-8),n=Math.min(C(E).length,M(C(k)+e)+1+8);return C(E).slice(t,n)}),ee=e=>e.memberIndex===null?rA(e.object).every(e=>C(u).has(e)):C(u).has(e.key),te=e=>e.filter(e=>ee(e)).length,ne=(e,t)=>{C(g),n.outliner.select(e,{shiftKey:t.shiftKey,toggleKey:t.ctrlKey||t.metaKey},C(h))};var L=UP(),R=I(L),z=I(R);Nt(z,{class:`h-3.5 w-3.5 shrink-0 text-faint-foreground`});var re=U(z,2);se(re);var B=U(re,2),ie=e=>{var t=RP(),n=I(t);Lt(n,{class:`h-3.5 w-3.5 text-faint-foreground transition-colors hover:text-muted-foreground`}),c(t),G(()=>H(t,`aria-label`,C(i).clearSearch)),f(`click`,t,()=>P(h,``)),O(e,t)};t(B,e=>{C(h)&&e(ie)});var ae=U(B,2),W=I(ae),ce=e=>{dt(e,{class:`h-3.5 w-3.5 text-faint-foreground transition-colors hover:text-muted-foreground`})},q=e=>{Mn(e,{class:`h-3.5 w-3.5 text-faint-foreground transition-colors hover:text-muted-foreground`})};t(W,e=>{C(w)?e(ce):e(q,-1)}),c(ae),c(R);var Y=U(R,2),de=I(Y);let X;a(de,21,()=>C(F),e=>e.key,(e,r)=>{var a=VP();let o;var u=I(a),h=e=>{let a=T(()=>C(r).entries),o=T(()=>te(C(a))),l=T(()=>C(a).length>0&&C(o)===C(a).length),u=T(()=>C(o)>0&&C(o)<C(a).length),d=T(()=>C(p).has(C(r).layerName));var h=zP(),g=I(h),_=I(g);{let e=T(()=>C(d)?``:`rotate-90`);ut(_,{get class(){return`h-3.5 w-3.5 transition-transform duration-150 ${C(e)??``}`}})}c(g);var v=U(g,2),y=I(v),b=e=>{qn(e,{class:`h-3.5 w-3.5 text-faint-foreground`})},x=e=>{Wn(e,{class:`h-3.5 w-3.5 text-faint-foreground`})},S=e=>{Wn(e,{class:`h-3.5 w-3.5 text-muted-foreground`})};t(y,e=>{C(l)?e(b):C(u)?e(x,1):e(S,-1)}),c(v);var w=U(v,2),E=K(w,!0),D=U(w,2),k=K(D,!0);c(h),G(()=>{H(g,`aria-label`,C(d)?C(i).expandLayer:C(i).collapseLayer),H(v,`title`,C(l)?C(i).showLayer:C(i).hideLayer),H(v,`aria-label`,C(l)?C(i).showLayer:C(i).hideLayer),fe(w,1,`min-w-0 text-xs font-medium flex-1 truncate ${C(l)?`text-faint-foreground line-through`:`text-foreground`}`),m(E,C(r).layerName),m(k,C(a).length)}),f(`click`,g,()=>n.outliner.toggleCollapsed(C(r).layerName)),f(`click`,v,()=>s(C(a))),O(e,h)},g=e=>{let a=T(()=>C(r).entry),o=T(()=>ee(C(a))),s=T(()=>C(d).has(C(a).key));var u=BP(),p=I(u),h=I(p),g=I(h),_=e=>{qn(e,{class:`h-3 w-3 text-faint-foreground`})},v=e=>{Wn(e,{class:`h-3 w-3 text-muted-foreground`})};t(g,e=>{C(o)?e(_):e(v,-1)}),c(h);var y=U(h,2),b=K(y,!0),x=U(y,2),S=K(x,!0);c(p),c(u),G(e=>{H(p,`aria-selected`,C(s)),fe(p,1,`gap-1.5 pl-5 pr-2 flex h-full cursor-pointer items-center transition-colors
|
|
6078
6078
|
${C(s)?`bg-primary/10 hover:bg-primary/15`:`hover:bg-hover`}
|
|
6079
|
-
${C(o)?`opacity-40`:``}`,`svelte-br1q9x`),H(h,`title`,C(o)?C(i).showObject:C(i).hideObject),H(h,`aria-label`,C(o)?C(i).showObject:C(i).hideObject),fe(y,1,`min-w-0 text-xs flex-1 truncate ${C(o)?`text-muted-foreground line-through`:`text-foreground`}`),m(b,C(a).label),m(S,e)},[()=>Zk(C(a).object)]),j(`mouseenter`,p,()=>n.onHover?.(C(a))),j(`mouseleave`,p,()=>n.onHover?.(null)),f(`mousedown`,p,e=>{e.stopPropagation(),e.shiftKey&&e.preventDefault()}),f(`click`,p,e=>te(C(a).key,e)),f(`keydown`,p,e=>e.key===`Enter`&&te(C(a).key,e)),f(`click`,h,e=>{e.stopPropagation(),l(C(a))}),O(e,u)};t(u,e=>{C(r).kind===`layer`?e(h):e(g,-1)}),c(a),G(()=>o=N(a,``,o,{"--row-top":`${C(r).top??``}px`,"--row-h":`${C(r).height??``}px`})),O(e,a)}),c(de);var pe=U(de,2),me=e=>{var t=BP(),n=L(t);qn(n,{class:`mb-2 h-5 w-5 text-faint-foreground`});var r=U(n,2),a=K(r,!0);c(t),G(()=>m(a,C(i).noObjects)),O(e,t)},he=e=>{var t=BP(),n=L(t);Nt(n,{class:`mb-2 h-5 w-5 text-faint-foreground`});var r=U(n,2),a=K(r,!0);c(t),G(e=>m(a,e),[()=>C(i).noResultsFor.replace(`{query}`,C(h))]),O(e,t)};t(pe,e=>{C(v).length===0?e(me):C(y).size===0&&e(he,1)}),c(Y),c(R),G(()=>{H(ne,`placeholder`,C(i).searchObjects),H(ae,`title`,C(w)?C(i).expandAll:C(i).collapseAll),H(ae,`aria-label`,C(w)?C(i).expandAll:C(i).collapseAll),X=N(de,``,X,{"--list-h":`${C(D)??``}px`})}),f(`mousedown`,R,()=>n.outliner.selection.clear()),ue(ne,()=>C(h),e=>P(h,e)),f(`click`,ae,()=>C(w)?S():x()),j(`scroll`,Y,e=>P(k,e.currentTarget.scrollTop,!0)),oe(Y,`clientHeight`,e=>P(A,e)),O(e,R),b()}ce([`mousedown`,`click`,`keydown`]);var UP=D(`<span class="inset-0 pointer-events-none absolute grid place-items-center text-foreground" aria-hidden="true"><!></span>`),WP=D(`<button><!></button>`),GP=D(`<!> <!>`,1),KP=D(`<!> <!> <!>`,1),qP=D(`<div><!></div>`),JP=D(`<div><button><!></button></div>`),YP=D(`<!> `,1),XP=D(`<!> <div class="gap-1 px-1 pb-1 grid grid-cols-4"></div> <!> <!> <!> <!> <!> <!>`,1),ZP=D(`<div role="status" class="text-xs font-medium px-2.5 py-1 shadow-md pointer-events-none absolute left-1/2 z-50 -translate-x-1/2 rounded-md border border-border-strong bg-card text-foreground"> </div>`),QP=D(`<div role="toolbar" tabindex="-1"><!> <div class="gap-0.5 mx-auto flex w-max items-center"><!> <!> <div><button><!></button></div> <div><button><!></button></div> <!> <div><!></div></div></div> <!>`,1);function $P(e,n){V(n,!0);let r=J(n,`hidden`,3,!1),i=new xe(`(pointer: coarse)`),o=new xe(`(prefers-reduced-motion: reduce)`),s=T(()=>i.current?{w:44,h:44}:{w:56,h:5}),l=T(()=>i.current?54:42),d=Z(void 0),h=Z(0),g=Z(!1),_=Z(!1),v=Z(0),y=Z(!1),x,w=T(()=>C(g)||C(v)>0||C(y)),D=T(()=>i.current?`max(1rem,env(safe-area-inset-bottom))`:`0.75rem`),k=T(()=>{let e=C(w)?`width:${C(h)+8+2}px;height:${C(l)}px;border-radius:12px;padding:4px`:`width:${C(s).w}px;height:${C(s).h}px;border-radius:${i.current?22:99}px;padding:0px`,t=`bottom:${C(D)};${e}`;if(o.current)return t;let n=C(w)?420:C(_)?130:170,r=C(w)||C(_)?0:20;return`${t};transition:${[`width`,`height`,`border-radius`,`padding`].map(e=>`${e} ${n}ms cubic-bezier(0.32, 0.72, 0, 1) ${r}ms`).join(`,`)},opacity 200ms ease`}),A=e=>{if(o.current)return`opacity:${+!!C(w)}`;let t=110+e*35;return C(w)?`opacity:1;transform:none;transition:opacity 240ms ease ${t}ms,transform 420ms cubic-bezier(0.34,1.45,0.5,1) ${t}ms`:`opacity:0;transform:translateY(6px) scale(0.85);transition:opacity 100ms ease,transform 100ms ease`},M=T(()=>`opacity:${i.current&&!C(w)?1:0};${o.current?``:`transition:opacity ${C(w),100}ms ease ${C(w)||C(_)?0:60}ms`}`);function I(e=150){clearTimeout(x),x=setTimeout(()=>P(g,!1),e)}function ee(){P(g,!0),P(_,!1),clearTimeout(x)}function te(e){if(!C(d)||i.current||e.pointerType===`touch`||e.buttons)return;let t=C(d).offsetParent;if(!t||!(e.target instanceof Node)||!t.contains(e.target)){C(g)&&I();return}let n=C(d).getBoundingClientRect();e.clientY>n.top-36&&Math.abs(e.clientX-(n.left+n.width/2))<110?ee():C(g)&&I()}function R(e){C(g)&&C(d)&&e.target instanceof Node&&(C(d).contains(e.target)||(clearTimeout(x),P(_,!0),P(g,!1)))}function ne(){C(w)||ee()}let re=Z(null),ie,ae,W=!1;function se(e){if(e.pointerType!==`touch`||!C(w)||!(e.target instanceof Element))return;let t=e.target.closest(`button[aria-label]`);t&&(clearTimeout(ie),ie=setTimeout(()=>{P(re,(t.getAttribute(`aria-label`)??``).replace(/\s*\([A-Z]\)$/,``),!0),W=!0},450))}function ce(){clearTimeout(ie),C(re)&&(clearTimeout(ae),ae=setTimeout(()=>P(re,null),1200))}function q(e){W&&(W=!1,e.preventDefault(),e.stopPropagation())}function le(e){P(v,C(v)+(e?1:-1)),!e&&!i.current&&I(250)}let Y=T(()=>[n.showDisplay&&`look`,n.showSceneManager&&`scene`,`measure`,`fit`,n.showFullscreen&&`full`,`more`].filter(Boolean)),ue=e=>C(Y).indexOf(e),X=`relative grid size-8.5 shrink-0 place-items-center rounded-lg text-foreground outline-none transition-colors hover:bg-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-pressed:text-foreground data-[state=open]:bg-selected data-[state=open]:text-foreground pointer-coarse:size-11`;var pe=QP();j(`pointermove`,de,te),j(`pointerdown`,de,R);var he=B(pe),ge=L(he),_e=e=>{var t=UP();Rr(L(t),{class:`size-5`}),c(t),G(()=>N(t,C(M))),O(e,t)};t(ge,e=>{i.current&&e(_e)});var ve=U(ge,2),ye=L(ve),be=e=>{var t=qP(),r=L(t);E(r,()=>Ge,(e,t)=>{t(e,{onOpenChange:le,children:(e,t)=>{var r=GP(),i=B(r);{let e=(e,t)=>{let r=()=>(t?.()).props;var i=WP();z(i,()=>({...r(),class:X,title:n.t.display,"aria-label":n.t.display})),Er(L(i),{class:`size-4.5`}),c(i),O(e,i)};E(i,()=>Xe,(t,n)=>{n(t,{child:e,$$slots:{child:!0}})})}var o=U(i,2);E(o,()=>Je,(e,t)=>{t(e,{side:`top`,align:`center`,sideOffset:12,variant:`glass`,class:`min-w-52 z-10001 w-auto whitespace-nowrap`,children:(e,t)=>{var r=KP(),i=B(r);E(i,()=>mo,(e,t)=>{t(e,{get value(){return n.renderStyle},onValueChange:e=>n.onSetLook(e),children:(e,t)=>{var r=u(),i=B(r);a(i,17,()=>n.styleOptions,({look:e,label:t})=>e,(e,t)=>{let n=()=>C(t).look,r=()=>C(t).label;var i=u(),a=B(i);E(a,()=>_o,(e,t)=>{t(e,{get value(){return n()},closeOnSelect:!1,children:(e,t)=>{S();var n=p();G(()=>m(n,r())),O(e,n)},$$slots:{default:!0}})}),O(e,i)}),O(e,r)},$$slots:{default:!0}})});var o=U(i,2);E(o,()=>Ve,(e,t)=>{t(e,{})});var s=U(o,2);E(s,()=>co,(e,t)=>{t(e,{switch:!0,get checked(){return n.edgesVisible},get onCheckedChange(){return n.onToggleEdges},children:(e,t)=>{var r=GP(),i=B(r);Vr(i,{});var a=U(i),o=U(a);E(o,()=>bo,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p(`E`);O(e,n)},$$slots:{default:!0}})}),G(()=>m(a,` ${n.t.edges??``} `)),O(e,r)},$$slots:{default:!0}})}),O(e,r)},$$slots:{default:!0}})}),O(e,r)},$$slots:{default:!0}})}),c(t),G(e=>N(t,e),[()=>A(ue(`look`))]),O(e,t)};t(ye,e=>{n.showDisplay&&e(be)});var Se=U(ye,2),Ce=e=>{var t=JP(),r=L(t);fe(r,1,`relative grid size-8.5 shrink-0 place-items-center rounded-lg text-foreground outline-none transition-colors hover:bg-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-pressed:text-foreground data-[state=open]:bg-selected data-[state=open]:text-foreground pointer-coarse:size-11 aria-pressed:after:absolute aria-pressed:after:bottom-0.5 aria-pressed:after:size-1 aria-pressed:after:rounded-full aria-pressed:after:bg-primary`),cr(L(r),{class:`size-4.5`}),c(r),c(t),G(e=>{N(t,e),H(r,`title`,`${n.t.sceneManager??``} (S)`),H(r,`aria-label`,n.t.sceneManager),H(r,`aria-pressed`,n.sceneManagerOpen)},[()=>A(ue(`scene`))]),f(`click`,r,function(...e){n.onToggleSceneManager?.apply(this,e)}),O(e,t)};t(Se,e=>{n.showSceneManager&&e(Ce)});var we=U(Se,2),Te=L(we);fe(Te,1,`relative grid size-8.5 shrink-0 place-items-center rounded-lg text-foreground outline-none transition-colors hover:bg-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-pressed:text-foreground data-[state=open]:bg-selected data-[state=open]:text-foreground pointer-coarse:size-11 aria-pressed:after:absolute aria-pressed:after:bottom-0.5 aria-pressed:after:size-1 aria-pressed:after:rounded-full aria-pressed:after:bg-primary`),Mr(L(Te),{class:`size-4.5`}),c(Te),c(we);var Ee=U(we,2),De=L(Ee);fe(De,1,me(X)),_r(L(De),{class:`size-4.5`}),c(De),c(Ee);var Oe=U(Ee,2),ke=e=>{var r=JP(),i=L(r);fe(i,1,me(X));var a=L(i),o=e=>{Cr(e,{class:`size-4.5`})},s=e=>{br(e,{class:`size-4.5`})};t(a,e=>{n.isFullscreen?e(o):e(s,-1)}),c(i),c(r),G(e=>{N(r,e),H(i,`title`,n.isFullscreen?n.t.exitFullscreen:n.t.fullscreen),H(i,`aria-label`,n.isFullscreen?n.t.exitFullscreen:n.t.fullscreen)},[()=>A(ue(`full`))]),f(`click`,i,function(...e){n.onToggleFullscreen?.apply(this,e)}),O(e,r)};t(Oe,e=>{n.showFullscreen&&e(ke)});var Ae=U(Oe,2),je=L(Ae);E(je,()=>Ge,(e,r)=>{r(e,{onOpenChange:le,children:(e,r)=>{var i=GP(),o=B(i);{let e=(e,t)=>{let r=()=>(t?.()).props;var i=WP();z(i,()=>({...r(),class:X,title:n.t.toolsMenu,"aria-label":n.t.toolsMenu}));var a=L(i);bt(a,{class:`size-4.5`}),c(i),O(e,i)};E(o,()=>Xe,(t,n)=>{n(t,{child:e,$$slots:{child:!0}})})}var s=U(o,2);E(s,()=>Je,(e,r)=>{r(e,{side:`top`,align:`end`,sideOffset:12,variant:`glass`,class:`min-w-60 z-10001 w-auto whitespace-nowrap`,children:(e,r)=>{var i=XP(),o=B(i);E(o,()=>fo,(e,t)=>{t(e,{children:(e,t)=>{S();var r=p();G(()=>m(r,n.t.views)),O(e,r)},$$slots:{default:!0}})});var s=U(o,2);a(s,21,()=>n.viewPresets,({preset:e,label:t})=>e,(e,t)=>{let r=()=>C(t).preset,i=()=>C(t).label;var a=u(),o=B(a);E(o,()=>He,(e,t)=>{t(e,{closeOnSelect:!1,onSelect:()=>n.onSetView(r()),variant:`chip`,children:(e,t)=>{S();var n=p();G(()=>m(n,i())),O(e,n)},$$slots:{default:!0}})}),O(e,a)}),c(s);var l=U(s,2);E(l,()=>Ve,(e,t)=>{t(e,{})});var d=U(l,2);{let e=T(()=>n.projection===`orthographic`);E(d,()=>co,(t,r)=>{r(t,{switch:!0,get checked(){return C(e)},get onCheckedChange(){return n.onToggleProjection},children:(e,t)=>{var r=GP(),i=B(r);Rn(i,{});var a=U(i),o=U(a);E(o,()=>bo,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p(`O`);O(e,n)},$$slots:{default:!0}})}),G(()=>m(a,` ${n.t.switchToOrthographic??``} `)),O(e,r)},$$slots:{default:!0}})})}var f=U(d,2),h=e=>{var t=u(),r=B(t);E(r,()=>co,(e,t)=>{t(e,{switch:!0,get checked(){return n.gridVisible},get onCheckedChange(){return n.onToggleGrid},children:(e,t)=>{var r=GP(),i=B(r);nr(i,{});var a=U(i),o=U(a);E(o,()=>bo,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p(`G`);O(e,n)},$$slots:{default:!0}})}),G(()=>m(a,` ${n.t.grid??``} `)),O(e,r)},$$slots:{default:!0}})}),O(e,t)};t(f,e=>{n.showGrid&&e(h)});var g=U(f,2),_=e=>{var t=u(),r=B(t);E(r,()=>co,(e,t)=>{t(e,{switch:!0,get checked(){return n.nightOn},get onCheckedChange(){return n.onToggleNight},children:(e,t)=>{var r=GP(),i=B(r);Qe(i,{});var a=U(i),o=U(a);E(o,()=>bo,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p(`N`);O(e,n)},$$slots:{default:!0}})}),G(()=>m(a,` ${n.t.nightMode??``} `)),O(e,r)},$$slots:{default:!0}})}),O(e,t)};t(g,e=>{n.showDisplay&&e(_)});var v=U(g,2),y=e=>{var t=u(),n=B(t);E(n,()=>Ve,(e,t)=>{t(e,{})}),O(e,t)};t(v,e=>{n.showScreenshot&&e(y)});var b=U(v,2),x=e=>{var t=u(),r=B(t);E(r,()=>He,(e,t)=>{t(e,{get onSelect(){return n.onScreenshot},children:(e,t)=>{var r=YP(),i=B(r);kn(i,{});var a=U(i);G(()=>m(a,` ${n.t.screenshot??``}`)),O(e,r)},$$slots:{default:!0}})}),O(e,t)};t(b,e=>{n.showScreenshot&&e(x)}),O(e,i)},$$slots:{default:!0}})}),O(e,i)},$$slots:{default:!0}})}),c(Ae),c(ve),c(he),F(he,e=>P(d,e),()=>C(d));var Me=U(he,2),Ne=e=>{var t=ZP(),n=K(t,!0);G(()=>{N(t,`bottom:calc(${C(D)??``} + ${C(l)+8}px)`),m(n,C(re))}),O(e,t)};t(Me,e=>{C(re)&&e(Ne)}),G((e,t,a)=>{H(he,`aria-label`,n.t.toolsMenu),fe(he,1,`backdrop-blur-md absolute left-1/2 z-50 -translate-x-1/2 overflow-hidden transition-colors select-none ${r()?`pointer-events-none opacity-0`:``} ${C(w)?`shadow-md border border-border-strong bg-card/75`:i.current?`shadow-lg cursor-pointer border border-border bg-background/90`:n.nightOn?`border-white/25 bg-white/35 hover:bg-white/70 cursor-pointer border`:`shadow-sm cursor-pointer border border-border-strong bg-card/90 hover:bg-card`}`),N(he,`${C(k)??``};-webkit-touch-callout:none`),ve.inert=!C(w),N(we,e),H(Te,`title`,`${n.t.measure??``} (M)`),H(Te,`aria-label`,n.t.measure),H(Te,`aria-pressed`,n.measureActive),N(Ee,t),H(De,`title`,`${n.t.fitToView??``} (F)`),H(De,`aria-label`,`${n.t.fitToView??``} (F)`),N(Ae,a)},[()=>A(ue(`measure`)),()=>A(ue(`fit`)),()=>A(ue(`more`))]),f(`click`,he,ne),f(`keydown`,he,e=>e.key===`Escape`?P(g,!1):void 0),f(`focusin`,he,()=>P(y,!0)),f(`focusout`,he,e=>{C(d)?.contains(e.relatedTarget)||P(y,!1)}),f(`pointerdown`,he,se),f(`pointerup`,he,ce),j(`pointercancel`,he,ce),j(`click`,he,q,!0),f(`contextmenu`,he,e=>i.current&&e.preventDefault()),f(`click`,Te,function(...e){n.onToggleMeasure?.apply(this,e)}),f(`click`,De,function(...e){n.onFit?.apply(this,e)}),oe(ve,`offsetWidth`,e=>P(h,e)),O(e,pe),b()}ce([`click`,`keydown`,`focusin`,`focusout`,`pointerdown`,`pointerup`,`contextmenu`]);var eF=D(`<p class="px-4 py-3 text-xs text-muted-foreground"> </p>`),tF=D(`<div class="gap-2 flex"><span class="shrink-0 text-muted-foreground"> </span> <span> </span></div>`),nF=D(`<div class="space-y-0.5"></div>`),rF=D(`<div> </div>`),iF=D(`<div class="space-y-1 text-left"></div>`),aF=D(`<div class="space-y-0.5 text-left"></div>`),oF=D(`<span class="font-mono"> </span>`),sF=D(`<span> </span>`),cF=D(`<span class="break-all"> </span>`),lF=D(`<tr class="border-b border-border last:border-b-0"><th scope="row" class="px-4 py-2 font-normal text-left align-top whitespace-nowrap text-muted-foreground"> </th><td class="px-4 py-2 text-right align-top text-foreground"><!></td></tr>`),uF=D(`<table class="text-xs w-full border-collapse"><tbody></tbody></table>`),dF=D(`<section><header class="gap-2 py-1 pr-1 pl-4 flex items-center border-b"><h2 class="text-sm font-semibold min-w-0 flex-1 truncate"> </h2> <!></header> <div class="min-h-0 overflow-y-auto overscroll-contain"><!></div></section>`);function fF(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),o=new Set([`name`,`layer`,`id`]),s=J(n,`class`,3,``),l=T(()=>{let e={};for(let[t,r]of Object.entries(n.metadata))o.has(t)||(t===`metadata`&&typeof r==`object`&&r&&!Array.isArray(r)?Object.assign(e,r):e[t]=r);return e});var d=dF(),f=L(d),p=L(f),h=K(p,!0),g=U(p,2);tt(g,{variant:`ghost`,size:`icon-sm`,class:`pointer-coarse:size-10 shrink-0`,get"aria-label"(){return C(i).close},get title(){return C(i).close},get onclick(){return n.onClose},children:(e,t)=>{Lt(e,{})},$$slots:{default:!0}}),c(f);var _=U(f,2),v=L(_),x=e=>{var t=eF(),n=K(t,!0);G(()=>m(n,C(i).noMetadata)),O(e,t)},S=T(()=>Object.keys(C(l)).length===0),E=e=>{var n=uF(),r=L(n);a(r,21,()=>Object.entries(C(l)),([e,t])=>e,(e,n)=>{var r=T(()=>w(C(n),2));let i=()=>C(r)[0],o=()=>C(r)[1];var s=lF(),l=L(s),d=K(l,!0),f=U(l),p=L(f),h=e=>{var n=u(),r=B(n),i=e=>{var n=iF();a(n,21,o,y,(e,n)=>{var r=u(),i=B(r),o=e=>{var t=nF();a(t,21,()=>Object.entries(C(n)),([e,t])=>e,(e,t)=>{var n=T(()=>w(C(t),2));let r=()=>C(n)[0],i=()=>C(n)[1];var a=tF(),o=L(a),s=K(o),l=U(o,2),u=K(l,!0);c(a),G(()=>{m(s,`${r()??``}:`),m(u,i())}),O(e,a)}),c(t),O(e,t)},s=e=>{var t=rF(),r=K(t,!0);G(()=>m(r,C(n))),O(e,t)};t(i,e=>{typeof C(n)==`object`?e(o):e(s,-1)}),O(e,r)}),c(n),O(e,n)},s=T(()=>Array.isArray(o())),l=e=>{var t=aF();a(t,21,()=>Object.entries(o()),([e,t])=>e,(e,t)=>{var n=T(()=>w(C(t),2));let r=()=>C(n)[0],i=()=>C(n)[1];var a=tF(),o=L(a),s=K(o),l=U(o,2),u=K(l,!0);c(a),G(()=>{m(s,`${r()??``}:`),m(u,i())}),O(e,a)}),c(t),O(e,t)};t(r,e=>{C(s)?e(i):e(l,-1)}),O(e,n)},g=e=>{var t=oF(),n=K(t,!0);G(()=>m(n,o())),O(e,t)},_=e=>{var t=sF(),n=K(t,!0);G(()=>{fe(t,1,me(o()?`text-success`:`text-muted-foreground`)),m(n,o()?`true`:`false`)}),O(e,t)},v=e=>{var t=cF(),n=K(t,!0);G(()=>m(n,o())),O(e,t)};t(p,e=>{typeof o()==`object`&&o()!==null?e(h):typeof o()==`number`?e(g,1):typeof o()==`boolean`?e(_,2):e(v,-1)}),c(f),c(s),G(()=>m(d,i())),O(e,s)}),c(r),c(n),O(e,n)};t(v,e=>{C(S)?e(x):e(E,-1)}),c(_),c(d),G(()=>{H(d,`aria-label`,n.meshName??C(i).objectFallbackName),fe(d,1,`min-h-0 shadow-lg backdrop-blur-sm flex flex-col overflow-hidden rounded-lg border bg-background/95 ${s()??``}`),m(h,n.meshName??C(i).objectFallbackName)}),O(e,d),b()}var pF=_F,mF=vF;function hF(e,t){return pF(e,t)}function gF(e){return mF(e)}async function _F(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);return r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4),!0}function vF({accept:e}){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.style.display=`none`;let r=e=>{n.remove(),t(e)};n.addEventListener(`change`,()=>r(n.files?.[0]??null),{once:!0}),n.addEventListener(`cancel`,()=>r(null),{once:!0}),document.body.appendChild(n),n.click()})}var yF=D(`<div><img alt="" class="h-10 max-w-40 drop-shadow-sm sm:h-14 sm:max-w-56 w-auto object-contain opacity-80"/></div>`),bF=D(`<div class="relative h-full w-full touch-none"><canvas class="viewer-canvas block h-full w-full outline-none select-none svelte-24hiu0" data-testid="viewer-canvas"></canvas> <div></div> <!> <!> <!></div>`),xF=D(`<!> <!>`,1),SF=D(`<div><!></div>`);function CF(e,n){V(n,!0);let r={showScreenshotButton:!0,showFullscreenButton:!0,showSceneManager:!0,showToolsMenu:!0,showGridToggle:!0,showDisplayMenu:!0,enableMeshClick:!0,backgroundColor:`#E6E6E6`,look:`technical`,showEdges:!1},i=J(n,`isFullscreen`,15,!1),a=J(n,`isBlurred`,3,!1),o=J(n,`drawerOpen`,3,!1),s=J(n,`viewerConfig`,19,()=>({})),l=T(()=>({...r,...s()})),u=rt(()=>n.lang),d=T(()=>u.messages),p,m=Z(null),h=null,g=null,v=null,y=null,x=null,S=null,w=null,D=null,k=null,A=null,j=null,M=null,N=null,I=null,te=null,R=null,z=null,ne=!1,ie=Z(0),ae=Z(!1),W=Z(!1),oe=new ye,se=new ye,ce=new ye,q=Z(null),ue=Z(`perspective`),de=Z(!1),X=Z(!1),pe=Y(()=>{let e=s().look;return e&&FT.includes(e)?e:r.look}),me=Eb[pe].requiresEdges===!0,he=Y(()=>s().showEdges)??r.showEdges,ge=Z(re(pe)),_e=Z(re(me||he)),ve=Z(null),be=Z(null),xe=T(()=>({technical:C(d).lookTechnical,studio:C(d).lookStudio,showcase:C(d).lookShowcase,arctic:C(d).lookArctic,xray:C(d).lookXray,lineart:C(d).lookLineart,wireframe:C(d).lookWireframe,night:C(d).lookNight})),Se=T(()=>FT.filter(e=>e!==`night`).map(e=>({look:e,label:C(xe)[e]??e.charAt(0).toUpperCase()+e.slice(1)}))),Ce=T(()=>C(ge)===`night`),we=Z(re(pe===`night`?r.look:pe)),Te=[{preset:`top`,label:()=>C(d).viewTop},{preset:`front`,label:()=>C(d).viewFront},{preset:`right`,label:()=>C(d).viewRight},{preset:`back`,label:()=>C(d).viewBack},{preset:`left`,label:()=>C(d).viewLeft},{preset:`bottom`,label:()=>C(d).viewBottom},{preset:`iso`,label:()=>C(d).viewIso}];le(()=>{if(o())P(ae,!0);else{let e=setTimeout(()=>{P(ae,!1)},rl.TIMEOUTS.DRAWER_ANIMATION_MS);return()=>clearTimeout(e)}}),_(()=>{if(!p)return;let e={look:C(ge),environment:{backgroundColor:C(l).backgroundColor},grid:{enabled:C(l).showToolsMenu&&C(l).showGridToggle},measure:{enabled:C(l).showToolsMenu},events:{onObjectSelected:Le,onBackgroundClicked:Le,onMeshMetadataClicked:C(l).enableMeshClick?e=>{He(e)&&(P(ve,e,!0),P(be,String(e?.name??``)||C(d).objectFallbackName,!0))}:void 0}},t=Gk(p,e);P(m,t.scene,!0),P(q,pA(t.scene,{sets:{hidden:oe,selected:se,collapsed:ce}}),!0),h=t.camera,g=t.controls,v=t.cameraController,y=t.measureTool,x=t.grid,x?.setVisible(C(X)),S=t.applyEdges,w=t.clearEdges,D=t.invalidate,k=t.captureImage,A=t.setLook,j=t.syncEmissiveLights,M=t.updateGridScale,N=t.updateShadowBounds,I=t.fitToView,te=t.clearSelection,R=t.selectEntries,z=t.setHover,P(ue,t.cameraController.getProjection(),!0);let r=Y(()=>n.onViewerReady?.(t));return()=>{r?.(),t.dispose(),eP()}});function Ee(){v&&P(ue,v.toggleProjection(),!0)}function De(e){v?.setView(e)}function Oe(){y&&(P(de,!C(de)),y.setEnabled(C(de)))}function ke(){x&&(P(X,!C(X)),x.setVisible(C(X)),D?.())}let Ae=me?he:null;function je(e){if(!A||e===C(ge))return;let t=Eb[C(ge)].requiresEdges===!0;P(ge,e,!0),e!==`night`&&P(we,e,!0),A(e),Eb[e].requiresEdges?(t||(Ae=C(_e)),C(_e)?!t&&C(m)&&w?.(C(m)):P(_e,!0),Ne()):t&&Ae!==null?(P(_e,Ae,!0),C(_e)&&C(m)&&w?.(C(m)),Ne(),Ae=null):C(_e)&&C(m)&&(w?.(C(m)),Ne())}function Me(){return Eb[C(ge)].requiresEdges?{distanceFade:!1,maxOverlays:2e4,color:1711393}:void 0}function Ne(){C(m)&&(C(_e)?S?.(C(m),Me()):w?.(C(m)))}function Pe(){je(C(Ce)?C(we):`night`)}function Fe(){P(_e,!C(_e)),Eb[C(ge)].requiresEdges&&(Ae=null),Ne()}le(()=>{C(m)&&h&&g&&(jE(C(m),n.meshes,h,g,ne),Y(()=>{A?.(C(ge),{deferEmissiveLights:!0}),C(_e)&&S?.(C(m),Me()),M?.(),N?.(),C(q)?.applyTo(),j?.(),ee(ie),D?.()}),!ne&&n.meshes.length>0&&(ne=!0))});function Ie(){P(ve,null),P(be,null)}function Le(){Ie(),se.clear()}le(()=>{if(se.size===0){R?.([]);return}let e=C(q)?.entries().filter(e=>se.has(e.key))??[];Ie(),R?.(e.flatMap(e=>e.parts))});function Re(){Ie(),te?.(),D?.()}le(()=>{n.meshes,Y(Ie)}),le(()=>(document.body.toggleAttribute(`data-viewer-fullscreen`,i()),()=>document.body.removeAttribute(`data-viewer-fullscreen`)));function ze(){i(!i())}let Be={o:Ee,m:Oe,g:ke,n:Pe,e:Fe,s:()=>P(W,!C(W))};function Ve(e){if(e.ctrlKey||e.metaKey||e.altKey||e.repeat||e.target.closest(`input, textarea, select, [contenteditable]`))return;let t=Be[e.key.toLowerCase()];t&&(e.preventDefault(),t())}function He(e){if(!e)return!1;if(e.metadata&&typeof e.metadata==`object`){let t=e.metadata;return Object.keys(t).length>0}let t=new Set([`name`,`layer`,`id`,`vertexCount`,`faceCount`,`vertexOffset`,`faceOffset`]);return Object.entries(e).filter(([e])=>!t.has(e)).length>0}async function Ue(){let e=await k?.();e&&await hF(e,`viewer-${new Date().toISOString().slice(0,19).replace(/:/g,`-`)}.png`)}var We=SF(),Ge=L(We);E(Ge,()=>Yc,(e,r)=>{r(e,{direction:`horizontal`,class:`h-full w-full`,children:(e,r)=>{var o=xF(),s=B(o);{let e=T(()=>C(W)?85:100);E(s,()=>Vc,(r,o)=>{o(r,{id:`viewport`,order:1,get defaultSize(){return C(e)},minSize:40,children:(e,r)=>{var o=bF(),s=L(o);F(s,e=>p=e,()=>p);var u=U(s,2),f=U(u,2),m=e=>{var t=yF(),r=K(t);G(()=>{fe(t,1,`right-4 bottom-4 pointer-events-none absolute z-20 ${C(ae)?`opacity-0`:``}`),H(r,`src`,n.logoUrl)}),O(e,t)};t(f,e=>{n.logoUrl&&e(m)});var h=U(f,2),g=e=>{fF(e,{get metadata(){return C(ve)},get meshName(){return C(be)},onClose:Re,class:`top-3 right-3 left-3 sm:right-auto sm:max-h-2/3 sm:w-72 absolute z-30 max-h-1/2`})};t(h,e=>{C(ve)&&e(g)});var _=U(h,2),v=e=>{{let t=T(()=>Te.map(({preset:e,label:t})=>({preset:e,label:t()})));$P(e,{get t(){return C(d)},get hidden(){return C(ae)},get showDisplay(){return C(l).showDisplayMenu},get showGrid(){return C(l).showGridToggle},get showSceneManager(){return C(l).showSceneManager},get showScreenshot(){return C(l).showScreenshotButton},get showFullscreen(){return C(l).showFullscreenButton},get styleOptions(){return C(Se)},get viewPresets(){return C(t)},get renderStyle(){return C(ge)},get nightOn(){return C(Ce)},get edgesVisible(){return C(_e)},get measureActive(){return C(de)},get gridVisible(){return C(X)},get sceneManagerOpen(){return C(W)},get projection(){return C(ue)},get isFullscreen(){return i()},onSetLook:je,onToggleNight:Pe,onToggleEdges:Fe,onToggleMeasure:Oe,onToggleGrid:ke,onToggleSceneManager:()=>P(W,!C(W)),onToggleProjection:Ee,onSetView:De,onFit:()=>I?.(),onScreenshot:Ue,onToggleFullscreen:ze})}};t(_,e=>{C(l).showToolsMenu&&e(v)}),c(o),G(()=>{H(s,`data-mesh-count`,n.meshes.length),fe(u,1,`inset-0 blur-overlay absolute z-20 ${a()?`blur-overlay-active`:`blur-overlay-inactive`}`,`svelte-24hiu0`)}),O(e,o)},$$slots:{default:!0}})})}var u=U(s,2),f=e=>{var t=xF(),n=B(t);E(n,()=>qc,(e,t)=>{t(e,{withHandle:!0})});var r=U(n,2);E(r,()=>Vc,(e,t)=>{t(e,{id:`scene-manager`,order:2,defaultSize:15,minSize:8,maxSize:30,children:(e,t)=>{HP(e,{get outliner(){return C(q)},get sceneVersion(){return C(ie)},onVisibilityChange:()=>j?.(),onHover:e=>z?.(e?.parts??null)})},$$slots:{default:!0}})}),O(e,t)};t(u,e=>{C(W)&&C(m)&&C(q)&&e(f)}),O(e,o)},$$slots:{default:!0}})}),c(We),G(()=>fe(We,1,`min-h-64 sm:min-h-96 lg:min-h-125 relative h-full flex-1 border ${i()?`fullscreen-viewer`:`overflow-hidden rounded-lg`}`,`svelte-24hiu0`)),f(`keydown`,We,Ve),O(e,We),b()}ce([`keydown`]);var wF=`[Selva:blocked]`,TF=`[Selva:msg]`,EF=`[Selva:log]`,DF=/:\s*component\s+"([^"]*)"\s*\(([0-9a-fA-F-]{36}|\.\.\.)\)\s*$/,OF=`Message`;function kF(e){let t=e.includes(wF),n=!t&&e.includes(`[Selva:log]`),r=t||n||e.includes(`[Selva:msg]`),i=e,a,o=DF.exec(i);return o&&(a=o[1]||void 0,i=i.slice(0,o.index)),r&&(i=i.replace(wF,``).replace(TF,``).replace(EF,``).replace(/^\s*\d+\.\s*Solution exception:\s*/,``)),{message:i.replace(/\s{2,}/g,` `).trim(),source:a,blocked:t,authored:r,logOnly:n}}function AF(e,t){let n=(e,t)=>{let{message:n,source:r,authored:i,logOnly:a}=kF(e),o=(i||r===OF)&&!a;return{level:t,message:n,...r?{source:r}:{},...o?{isGate:o}:{}}};return[...e.map(e=>n(e,`error`)),...t.map(e=>n(e,`warning`))]}function jF(e){return e===`error`||e===`warning`||e===`remark`}function MF(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.message==`string`?t.message.trim():``;if(!n)return null;let r=typeof t.source==`string`&&t.source?t.source:void 0;return{level:jF(t.level)?t.level:`remark`,message:n,...r?{source:r}:{},...t.isGate===!0?{isGate:!0}:{}}}function NF(e,t,n,r){let i=new Set,a=[];for(let t of e){let e=MF(t);if(!e)continue;let n=`${e.level}\u0000${e.message}\u0000${e.source??``}\u0000${e.isGate===!0}`;i.has(n)||(i.add(n),a.push(e))}return{diagnostics:a,blocked:t||n,aborted:n,...r&&r.length>0?{deferred:r}:{}}}function PF(e){if(!e||typeof e!=`object`)return null;let{diagnostics:t,blocked:n,aborted:r,deferred:i}=e,a=Array.isArray(t);if(!a&&n===void 0&&r===void 0)return null;let o=e=>e===!0||e===`true`,s=Array.isArray(i)?i.filter(e=>typeof e==`string`&&e!==``):void 0;return NF(a?t:[],o(n),o(r),s)}function FF(e,t){let n=e=>e.filter(e=>typeof e==`string`),r=n(e);return NF(AF(r,n(t)),r.some(e=>e.includes(wF)),!1)}function IF(e,t){let n=t.blocked||t.aborted,r=n?[]:e.meshes;return{outputs:n?{}:e.outputs,...r===void 0?{}:{meshes:r},errors:t.diagnostics.filter(e=>e.level===`error`).map(e=>e.message),warnings:t.diagnostics.filter(e=>e.level===`warning`).map(e=>e.message),diagnostics:t.diagnostics,blocked:t.blocked,aborted:t.aborted,...t.deferred&&!n?{deferred:t.deferred}:{},...e.source!==void 0&&!n?{source:e.source}:{}}}function LF(e){return e?.layout?e.layout.type===`tabbed`?e.layout.tabs?.flatMap(e=>e.groups??[])??[]:e.layout.type===`flat`?e.layout.groups??[]:[]:[]}function RF(e){return LF(e).flatMap(e=>e.items??[])}function zF(e){return RF(e).filter(e=>e.type===`input`)}function BF(e){switch(e){case`number`:case`integer`:return 0;case`boolean`:return!1;case`text`:return``;default:return null}}function VF(e){return new Set(zF(e).filter(e=>e.source?.kind===`server`).map(e=>e.paramId))}function HF(e,t){return new Promise((n,r)=>{let i=()=>r(t.reason);t.aborted&&i(),t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}var UF=`selva-keepalive`,WF={NETWORK_ERROR:`NETWORK_ERROR`,AUTH_ERROR:`AUTH_ERROR`,VALIDATION_ERROR:`VALIDATION_ERROR`,COMPUTATION_ERROR:`COMPUTATION_ERROR`,TIMEOUT_ERROR:`TIMEOUT_ERROR`,CORS_ERROR:`CORS_ERROR`,NOT_FOUND:`NOT_FOUND`,RATE_LIMIT:`RATE_LIMIT`,INVALID_RESPONSE:`INVALID_RESPONSE`,RESPONSE_TOO_LARGE:`RESPONSE_TOO_LARGE`,UNKNOWN_ERROR:`UNKNOWN_ERROR`,INVALID_STATE:`INVALID_STATE`,INVALID_INPUT:`INVALID_INPUT`,INVALID_CONFIG:`INVALID_CONFIG`,BROWSER_ONLY:`BROWSER_ONLY`,ENVIRONMENT_ERROR:`ENVIRONMENT_ERROR`,ENCODING_ERROR:`ENCODING_ERROR`,MALFORMED_DEFAULT:`MALFORMED_DEFAULT`,SUPERSEDED:`SUPERSEDED`,ABORTED:`ABORTED`,QUEUE_FULL:`QUEUE_FULL`,QUEUE_TIMEOUT:`QUEUE_TIMEOUT`,DEFINITION_NOT_CACHED:`DEFINITION_NOT_CACHED`},GF=class extends Error{code;statusCode;context;originalError;constructor(e,t=WF.UNKNOWN_ERROR,n){let r=n?.originalError,i=r===void 0||r instanceof Error?r:Error(String(r));super(e,i&&{cause:i}),this.name=`ComputeError`,this.code=t,this.statusCode=n?.statusCode,this.context=n?.context,this.originalError=i}},KF={debug(){},info(){},warn(){},error(){}};function qF(){return KF}function JF(e,t){if(!e||typeof e!=`object`)return;if(Object.hasOwn(e,t))return t;let n=t.toLowerCase();return Object.keys(e).find(e=>e.toLowerCase()===n)}function YF(e,t){let n=JF(e,t);return n===void 0?void 0:e[n]}function XF(e,t){return JF(e,t)!==void 0}var ZF=`<unreadable URL>`;function QF(e){try{let t=new URL(e);return t.host?t:null}catch{return null}}function $F(e){let t=QF(e);return t?(t.username=``,t.password=``,t.search=``,t.hash=``,t.href):ZF}function eI(e){try{return JSON.parse(e)}catch{return}}function tI(){let e=globalThis.Buffer;return typeof e==`function`?e:void 0}function nI(e){let t=e.replace(/[\t\n\f\r ]/g,``);return t.length%4==0&&(t=t.replace(/={1,2}$/,``)),t.length%4==1?null:t}function rI(e){let t=nI(e),n=t===null?null:iI(t);if(n===null)throw new GF(`Invalid base64 input.`,WF.ENCODING_ERROR,{context:{inputLength:e.length}});return n}function iI(e){let t=tI();if(t){if(t.byteLength(e,`utf8`)!==e.length||e.includes(`-`)||e.includes(`_`))return null;let n=t.from(e,`base64`);return n.length===Math.floor(e.length*3/4)?n.byteOffset===0&&n.buffer.byteLength===n.length?new Uint8Array(n.buffer,0,n.length):new Uint8Array(n):null}if(typeof globalThis.atob==`function`){let t;try{t=globalThis.atob(e)}catch{return null}let n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e)&255;return n}throw new GF(`Base64 decoding not supported in this environment.`,WF.ENVIRONMENT_ERROR,{context:{environmentInfo:`atob or Buffer not available`}})}WF.VALIDATION_ERROR,WF.AUTH_ERROR,WF.AUTH_ERROR,WF.NOT_FOUND,WF.VALIDATION_ERROR,WF.RATE_LIMIT,WF.COMPUTATION_ERROR,WF.NETWORK_ERROR,WF.NETWORK_ERROR,WF.NETWORK_ERROR;var aI=e=>(e??``).replace(/::/g,`/`).replace(/\\/g,`/`).split(`/`).map(e=>e.trim()).filter(e=>e!==``),oI=e=>aI(e.subFolder)[0]??``,sI=e=>aI(e.subFolder).slice(1).join(`/`),cI=e=>{let t=new Map;for(let n of e){let e=oI(n),r=t.get(e);r?r.push(n):t.set(e,[n])}return Array.from(t,([e,t])=>({root:e,files:t}))},lI=e=>{let t=e.replace(/[/\\:*?"<>|]/g,`_`).replace(/\s+/g,` `).trim().replace(/^\.+/,``);return t===``?`files`:t},uI=async(e,t=null)=>{let n=gI(e);if(t){let e=Array.isArray(t)?t:[t];n.push(...await vI(e))}let r=new Set;return n.map(e=>{let t=bI(e.path,r);return r.add(t),t===e.path?e:(qF().warn(`Duplicate archive path "${e.path}" — storing as "${t}".`),{...e,path:t,fileName:t.slice(t.lastIndexOf(`/`)+1)})})},dI=async(e,t,n=null,r={})=>{if(typeof document>`u`||typeof Blob>`u`)throw new GF(`File download functionality is only available in browser environments. This function requires the DOM API (document, Blob).`,WF.BROWSER_ONLY,{context:{environment:typeof window<`u`?`browser (SSR)`:`Node.js`,documentAvailable:typeof document<`u`,blobAvailable:typeof Blob<`u`}});try{await yI(await uI(e,n),t,r.saveBlob??xI)}catch(n){throw n instanceof GF?n:new GF(`Failed to download files from compute response`,WF.INVALID_STATE,{context:{fileCount:e.length,zipName:t},originalError:n})}},fI=async(e,t,n=null,r={})=>{let i=cI(e);if(i.length===0){await dI([],t,n,r);return}let a=(i.find(e=>e.root===``)??i[0]).root;for(let{root:e,files:o}of i)await dI(e===``?o:o.map(e=>({...e,subFolder:sI(e)})),e===``?t:lI(e),e===a?n:null,r)},pI=e=>aI(e).filter(e=>e!==`.`&&e!==`..`&&!/^[a-zA-Z]:/.test(e)).join(`/`),mI=e=>e===!0||typeof e==`string`&&e.trim().toLowerCase()===`true`,hI=(e,t)=>e===``?t:`${e}/${t}`,gI=e=>{let t=[];return e.forEach(e=>{let n=YF(e,`fileName`)??``,r=YF(e,`fileType`)??``,i=pI(`${n}${r}`);if(i===``){qF().warn(`Skipping file with unusable name "${n}${r}": no safe archive path remains after sanitization.`);return}let a=YF(e,`subFolder`),o=a?pI(a):``,s=hI(o,i),c=YF(e,`data`);if(typeof c!=`string`||c===``){qF().warn(`Skipping file "${s}": item carries no usable data.`);return}let l=c;if(mI(YF(e,`isBase64Encoded`)))try{l=rI(c)}catch(e){qF().warn(`Skipping file "${s}": base64 decode failed.`,e);return}let u=YF(e,`metadata`);t.push({fileName:i,content:l,path:s,subFolder:o,...u?{metadata:u}:{}})}),t},_I=3e4,vI=async e=>(await Promise.all(e.map(async e=>{try{let t=await fetch(e.filePath,{signal:AbortSignal.timeout(_I)});if(!t.ok)return qF().warn(`Failed to fetch additional file: ${$F(e.filePath)}`),null;let n=await t.arrayBuffer(),r=pI(e.fileName);if(r===``)return qF().warn(`Skipping fetched file with unusable name: ${e.fileName}`),null;let i=e.subFolder?pI(e.subFolder):``;return{fileName:r,content:new Uint8Array(n),path:hI(i,r),subFolder:i}}catch(t){let n=t instanceof Error?t.name:`unknown error`;return qF().error(`Error fetching additional file ${$F(e.filePath)}: ${n}`),null}}))).filter(e=>e!==null);async function yI(t,n,r){let{zip:i,strToU8:a}=await e(async()=>{let{zip:e,strToU8:t}=await import(`./DIMAEw3m.js`);return{zip:e,strToU8:t}},[],import.meta.url),o=new Set(t.map(e=>e.path)),s={};for(let e of t){let t=e.path===`__proto__`?bI(e.path,o):e.path;o.add(t),s[t]=typeof e.content==`string`?a(e.content):e.content}let c=await new Promise((e,t)=>{i(s,{level:6},(n,r)=>n?t(n):e(r))});await r(new Blob([c],{type:`application/zip`}),`${n}.zip`)}function bI(e,t){if(!t.has(e))return e;let n=e.lastIndexOf(`/`),r=e.lastIndexOf(`.`),i=r>n?r:e.length,a=e.slice(0,i),o=e.slice(i);for(let e=2;;e++){let n=`${a}-${e}${o}`;if(!t.has(n))return n}}function xI(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}WF.DEFINITION_NOT_CACHED;function SI(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}var CI=/^\{(-?\d+(?:;-?\d+)*)?\}$/;function wI(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.entries(e);return t.length>0&&t.every(([e,t])=>CI.test(e)&&Array.isArray(t))}var TI=new Set([`System.Double`,`System.Single`,`System.Decimal`,`System.Int32`,`System.Int64`]),EI=new Set([`System.Int32`,`System.Int64`]);function DI(e,t,n){if(e==null)return e;if(Array.isArray(e)){let n=e.map(t).filter(e=>e!==null);return n.length>0?n:void 0}let r=t(e);return r===null?n?void 0:e:r}var OI=e=>{if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`){let t=e.trim();if(t===``||/^[+-]?0[xbo]/i.test(t))return null;let n=Number(t);return Number.isFinite(n)?n:null}return null},kI=e=>{if(typeof e==`boolean`)return e;if(typeof e==`string`){let t=e.trim().toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}return null},AI=e=>typeof e==`string`?e.length>=2&&e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e.startsWith(`"`)?e.slice(1):e:null,jI=e=>{if(typeof e==`string`){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)&&(t=t.slice(1,-1).trim()),t}return null};function MI(e){return t=>{if(typeof t==`object`&&t)return t;if(typeof t==`string`&&t.trim()!==``)try{let n=JSON.parse(t);return typeof n==`object`&&n?n:(qF().warn(`Parsed value for input ${e} is not an object`),null)}catch{return qF().warn(`Failed to parse the object value for input ${e}`),null}return null}}function NI(e,t){let n=Number(e.toFixed(t));return Math.abs(e-n)<1e-8?n:e}var PI=12,FI=15;function II(e){if(!Number.isFinite(e))return 0;let t=Number(Math.abs(e).toPrecision(FI)),[n,r=`0`]=String(t).split(`e`),i=(n.split(`.`)[1]?.length??0)-Number(r);return Math.min(Math.max(i,0),PI)}function LI(e){if(!Number.isFinite(e)||e===0)return .1;let t=II(e);return t===0?Math.abs(e)>=1?1:.1:Number((10**-t).toFixed(t))}function RI(e){return typeof e.stepSize==`number`&&Number.isFinite(e.stepSize)&&e.stepSize>0?e.stepSize:void 0}var zI=e=>e.nickname||`unnamed`,BI=(e,t)=>(e.atMost??1)>1?[t]:t,VI=e=>RI(e)??(e.paramType===`Integer`?1:.1),HI=(e,t)=>Array.isArray(e)?e.map(e=>typeof e==`number`?t(e):e):typeof e==`number`?t(e):e;function UI(e){if(wI(e.default))return{default:e.default,stepSize:VI(e)};if(typeof e.default==`string`&&e.default.trim()!==``&&OI(e.default)===null)throw new GF(`Invalid numeric default "${e.default}" for input "${e.name||`unknown`}"`,WF.VALIDATION_ERROR,{context:{inputName:e.name,default:e.default}});let t=DI(e.default,OI,!0);if(e.paramType===`Integer`)return{default:HI(t,Math.round),stepSize:VI(e)};let n=Array.isArray(t)?t[0]:t,r=[n,e.minimum,e.maximum].find(e=>typeof e==`number`&&Number.isFinite(e)&&e!==0),i=RI(e)??(r===void 0?.1:LI(r)),a=II(i);if(a===0&&typeof n==`number`&&n!==0&&Math.abs(n)<1){let e=Math.ceil(-Math.log10(Math.abs(n)));Number.isFinite(e)&&e>0&&(a=e)}return a=Math.min(Math.max(a,0),12),{default:HI(t,e=>NI(e,a)),stepSize:i}}var WI=(e,t,n)=>({...t,paramType:e.paramType,minimum:e.minimum,maximum:e.maximum,atLeast:e.atLeast,atMost:e.atMost,...n}),GI={parse(e,t){return WI(e,t,UI(e))},fallback(e,t){let n=typeof e.minimum==`number`&&Number.isFinite(e.minimum)&&e.minimum>0?e.minimum:0;return WI(e,t,{stepSize:VI(e),default:BI(e,n)})}},KI={parse(e,t){if(wI(e.default))return{...t,paramType:`Boolean`,default:e.default};let n=DI(e.default,kI,!1);if(n!=null&&typeof n!=`boolean`&&!Array.isArray(n))throw new GF(`Invalid boolean default "${String(n)}" for input "${e.name||`unknown`}"`,WF.VALIDATION_ERROR,{context:{inputName:e.name,default:e.default}});return{...t,paramType:`Boolean`,default:n}},fallback(e,t){return{...t,paramType:`Boolean`,default:BI(e,!1)}}},qI={parse(e,t){let n=DI(e.default,AI,!1);return{...t,paramType:`Text`,default:n}}},JI={parse(e,t,n){if(!e.values||typeof e.values!=`object`||Object.keys(e.values).length===0){let t=zI(e);throw new GF(`Input "${t}" has no values defined (expected ValueList)`,WF.INVALID_INPUT,{context:{inputName:t,expectedType:`ValueList`}})}let r;if(e.default!==void 0&&e.default!==null){if(typeof e.default==`object`)throw new GF(`ValueList input "${zI(e)}" default is not a string-able value`,WF.VALIDATION_ERROR,{context:{inputName:e.name,default:e.default}});let t=String(e.default).toLowerCase(),i=Object.keys(e.values).find(e=>e.toLowerCase()===t);if(r=i??String(e.default),i===void 0){let t=zI(e);qF().warn(`ValueList input "${t}" default is not in available values`),n?.({code:WF.VALIDATION_ERROR,message:`ValueList input "${t}" default value "${e.default}" is not in available values`})}}return{...t,paramType:`ValueList`,values:e.values,default:r}},fallback(e,t){return{...t,paramType:`ValueList`,values:e.values&&typeof e.values==`object`?e.values:{},default:void 0}}},YI=e=>DI(e.default,MI(zI(e)),!0);function XI(e,t){return{...t,paramType:`Geometry`,default:BI(e,null)}}var ZI=e=>({parse(t,n){return{...n,paramType:e,default:YI(t)}},fallback:(t,n)=>({...XI(t,n),paramType:e})}),QI=new Map([[`Number`,GI],[`Integer`,GI],[`Boolean`,KI],[`Text`,qI],[`ValueList`,JI],[`Geometry`,ZI(`Geometry`)],[`Line`,ZI(`Line`)],[`Point`,ZI(`Point`)],[`Plane`,ZI(`Plane`)],[`File`,{parse(e,t){return{...t,paramType:`File`,acceptedFormats:e.acceptedFormats,default:YI(e)}}}],[`Color`,{parse(e,t){let n=DI(e.default,jI,!1);return{...t,paramType:`Color`,default:n}}}]]);new Map([...QI.keys()].map(e=>[e.toLowerCase(),e])),globalThis.process?.getBuiltinModule?.(`node:crypto`),new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function $I(e,t){return{__decodeError:!0,type:e,raw:t}}function eL(e){let t=new WeakSet,n=e=>{if(!e||typeof e!=`object`||t.has(e))return;t.add(e);let r=e.delete;if(typeof r==`function`){let t=e.isDeleted;typeof t==`function`&&t.call(e)||r.call(e);return}if(Array.isArray(e)){for(let t of e)n(t);return}let i=Object.getPrototypeOf(e);if(i===Object.prototype||i===null)for(let t of Object.values(e))n(t)};n(e)}var tL=new Map([[`Rhino.Geometry.Point3d`,(e,t)=>{let n=t;return!n||typeof n.X!=`number`?null:new e.Point([n.X,n.Y,n.Z])}],[`Rhino.Geometry.Line`,(e,t)=>{let n=t;return!n||!n.From||!n.To?null:new e.Line([n.From.X,n.From.Y,n.From.Z],[n.To.X,n.To.Y,n.To.Z])}]]);function nL(e){return!!(e&&typeof e==`object`&&typeof e.data==`string`)}function rL(e,t,n){let r=tL.get(t),i=!1;if(r)try{let t=r(n,e);if(t!=null)return t}catch(e){qF().warn(`Failed to decode Rhino type ${t}:`,e),i=!0}try{if(nL(e))return n.CommonObject.decode(e)}catch(n){return qF().warn(`Failed to decode ${t} with CommonObject:`,n),$I(t,e)}return i?$I(t,e):e}var iL=`Rhino.Geometry.`,aL=`FileData`;function oL(e,t){return e.includes(`WebDisplay`)||t&&e!==`System.String`}var sL=e=>e.startsWith(`{`)||e.startsWith(`[`);function cL(e){if(typeof e!=`string`)return e;let t=e.trim();if(!sL(t)&&!t.startsWith(`"`))return e;let n=eI(t)??e;return typeof n==`string`&&sL(n.trim())?eI(n)??n:n}function lL(e,t,n){if(t===`System.String`)return typeof e==`string`?e.replace(/^"(.*)"$/,`$1`):e;if(EI.has(t)){let t=Number.parseInt(String(e),10);return Number.isNaN(t)||Number.isSafeInteger(t)?t:e}return TI.has(t)?Number.parseFloat(String(e)):t===`System.Boolean`?String(e).toLowerCase()===`true`:n&&t.startsWith(iL)?rL(e,t,n):e}function uL(e,t,n,r){if(typeof e.data!=`string`)return e.data;let i=n?cL(e.data):e.data;return n&&t.includes(aL)?dL(i)??i:lL(i,t,r)}function dL(e){if(!e||typeof e!=`object`)return null;let t=YF(e,`fileName`),n=YF(e,`fileType`),r=YF(e,`subFolder`),i=YF(e,`isBase64Encoded`);if(typeof t!=`string`||typeof n!=`string`||typeof r!=`string`||!XF(e,`data`)||typeof i!=`boolean`&&typeof i!=`string`)return null;let a=YF(e,`metadata`);return{fileName:t,fileType:n,data:YF(e,`data`),isBase64Encoded:mI(i),subFolder:r,...a?{metadata:a}:{}}}function fL(e){let t=YF(e,`values`);return Array.isArray(t)?t:[]}function pL(e){return typeof e.type==`string`?e.type:``}function mL(e,t){if(e&&typeof e==`object`){for(let n of Object.values(e))if(Array.isArray(n))for(let e of n)e&&typeof e==`object`&&t(e)}}function hL(e,t=!1,n={}){let{parseValues:r=!0,rhino:i,stringOnly:a=!1}=n,o={},s=new Set;for(let n of fL(e)){let e=YF(n,`paramName`);mL(YF(n,`innerTree`),n=>{let c=pL(n);if(oL(c,a))return;let l=t?n.id:e;if(!l)return;let u=uL(n,c,r,i);Object.hasOwn(o,l)?s.has(l)?o[l].push(u):(o[l]=[o[l],u],s.add(l)):SI(o,l,u)})}return{values:o,dispose:()=>eL(o)}}function gL(e){let t=[];for(let n of fL(e))mL(YF(n,`innerTree`),e=>{if(!pL(e).includes(aL))return;let n=dL(cL(e.data));n&&t.push(n)});return t}function _L(e,t,n={}){let{parseValues:r=!0,rhino:i,stringOnly:a=!1}=n;for(let n of fL(e)){let e=YF(n,`innerTree`),o=!1;if(`byName`in t){if(YF(n,`paramName`)!==t.byName)continue;o=!0}let s=[];if(mL(e,e=>{if(`byId`in t){if(e.id!==t.byId)return;o=!0}let n=pL(e);oL(n,a)||s.push(uL(e,n,r,i))}),o)return s.length===0?void 0:s.length===1?s[0]:s}}var vL=class{response;constructor(e){this.response=e}getValues(e=!1,t={}){return hL(this.response,e,t)}getValue(e,t){return _L(this.response,e,t)}async getAndDownloadFiles(e,t){await dI(gL(this.response),e,t)}},yL=`external`;function bL(e){if(!e.scopeKey||!e.inputId)return null;try{return typeof sessionStorage>`u`?null:{storage:sessionStorage,key:`${yL}:${e.scopeKey}:${e.inputId}`}}catch{return null}}function xL(e){let t=bL(e);if(!t)return;let n=t.storage.getItem(t.key);if(n!==null)try{return JSON.parse(n)}catch{return}}function SL(e){return zF(e).filter(e=>e.source?.kind===`client`).map(e=>({paramId:e.paramId,displayName:e.displayName??e.paramId}))}var CL={status:`none`};function wL(e){return Array.isArray(e)?e.length>0:e!=null&&e!==``}function TL(e,t){let n=CL,r=null,i=null;function a(e){n=e,t()}function o(){i?.controller.abort(),i=null}async function s(t,n,o){let s=Date.now();a({status:`making`,ids:n,startedAt:s});try{let i=await e(t.values??{},o.signal);if(o.signal.aborted||r!==t)return;if(i.aborted)return a({status:`waiting`,ids:n});if(i.blocked){let e=i.diagnostics??[];return a({status:`failed`,ids:n,error:e.find(e=>e.level===`error`)?.message??i.errors?.[0]??`The definition refused to make the files.`,diagnostics:e})}let c={};for(let e of n)wL(i.outputs[e])&&(c[e]=i.outputs[e]);a(Object.keys(c).length===0?{status:`empty`,ids:n}:{status:`ready`,ids:n,outputs:c,durationMs:Date.now()-s})}catch(e){if(o.signal.aborted||r!==t)return;a({status:`failed`,ids:n,error:e instanceof Error?e.message:String(e),diagnostics:[]})}finally{i?.controller===o&&(i=null)}}return{get state(){return n},show(t){if(t===r)return;o(),r=t;let i=t?.deferred??[];n=i.length>0&&e?{status:`waiting`,ids:i}:CL},make(){if(i)return i.done;if(!r||n.status!==`waiting`&&n.status!==`failed`)return Promise.resolve();let e=new AbortController,t=s(r,n.ids,e);return i={controller:e,done:t},t},cancel(){if(!i||n.status!==`making`)return;let{ids:e}=n;o(),a({status:`waiting`,ids:e})}}}var EL=Object.freeze({solveId:null,running:!1,diagnostics:[],progress:new Map,ended:null,other:[],lastSeq:0});function DL(e){let{kind:t}=e;return t===`ok`||t===`blocked`||t===`aborted`?t:`error`}function OL(e,t){if(t.type===`solveEnded`&&e.solveId!==null&&t.solveId!==e.solveId)return e;let n=t.solveId===e.solveId?e:{...EL,solveId:t.solveId,running:!0};if(t.seq<=n.lastSeq)return e;let r={...n,lastSeq:t.seq},i=t.payload??{};switch(t.type){case`solveStarted`:return{...r,running:!0};case`solveEnded`:return{...r,running:!1,ended:{kind:DL(i)}};case`diagnostic`:{let e=MF(i);return e?{...r,diagnostics:[...r.diagnostics,e]}:r}case`progress`:{let e=typeof i.source==`string`?i.source:``,t=new Map(r.progress),n=kL(i),a=r.progress.get(e)?.fraction;return a!==void 0&&(n.fraction??0)<a&&(n.fraction=a),t.set(e,n),{...r,progress:t}}default:return{...r,other:[...r.other,t]}}}function kL(e){let t=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,n=t(e.fraction),r=t(e.done),i=t(e.total),a=t(e.nextFraction),o=t(e.stepMs),s=e=>Math.min(1,Math.max(0,e));return{...typeof e.source==`string`?{source:e.source}:{},...n===void 0?{}:{fraction:s(n)},...r===void 0?{}:{done:r},...i===void 0?{}:{total:i},...typeof e.label==`string`?{label:e.label}:{},...a===void 0?{}:{nextFraction:s(a)},...o!==void 0&&o>0?{stepMs:o}:{}}}function AL(e){let t=typeof e==`object`&&e&&typeof e.toJSON==`function`?e.toJSON():e;if(typeof t!=`object`||!t)return JSON.stringify(t)??`null`;if(Array.isArray(t))return`[${t.map(AL).join(`,`)}]`;let n=t;return`{${Object.keys(n).filter(e=>n[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${AL(n[e])}`).join(`,`)}}`}var jL=268435456;function ML(e={}){let{max:t=16,maxBytes:n=jL,meshPolicy:r}=e,i=new Map,a=0;function o(e){e.meshes?.length&&r?.release(e.meshes)}function s(e){return!r||!e.meshes?.length?e:{...e,meshes:r.clone(e.meshes)}}function c(e){let t=i.get(e);t!==void 0&&(i.delete(e),a-=t.bytes,o(t.result))}return{get(e){let n=AL(e),r=i.get(n);if(r!==void 0)return i.delete(n),i.set(n,r),console.debug(`[Solve/memo] HIT — served from client memo (${i.size}/${t})`),s(r.result)},set(e,o){let l=AL(e);c(l);let u=o.meshes?.length?r?.byteSize?.(o.meshes)??0:0;if(u>n)console.debug(`[Solve/memo] not memoized: ${(u/1048576).toFixed(0)} MB of meshes exceeds ${(n/1048576).toFixed(0)} MB`);else{i.set(l,{result:s(o),bytes:u}),a+=u;for(let e of i.keys()){if(i.size<=t&&a<=n)break;c(e)}}},clear(){i.forEach(e=>o(e.result)),i.clear(),a=0}}}function NL(e,t,n){let r=new Set(SL(e).map(e=>e.paramId)),i={};for(let a of e.inputs)if(r.has(a.id)){let e=n({scopeKey:t,inputId:a.id});e!==void 0&&(i[a.id]=e)}else i[a.id]=a.default??BF(a.paramType);for(let t of e.outputs)i[t.id]=null;return i}function PL(e,t,n){let r=e.instanceSolve===!1;return{values:NL(e,t,n),error:``,computeErrors:[],computeWarnings:[],diagnostics:[],blocked:!1,heldResult:null,meshes:[],hasPendingChanges:r,hasNeverSolved:r,lastResult:null,unsolved:null}}function FL(e,t,n,r,i=!1){return r===!1&&!i&&IL(e.values[t],n)?!1:(e.values[t]=n,r!==!1||(e.hasPendingChanges=!i,i))}function IL(e,t){return Object.is(e,t)?!0:e===null||t===null||typeof e!=`object`||typeof t!=`object`?!1:AL(e)===AL(t)}function LL(e,t,n){return Object.assign(e.values,t),n!==!1||(e.hasPendingChanges=!0,!1)}var RL=new Set([`dynamicValueList`,`file`]);function zL(e,t,n,r,i){if(!t||!(r in t)||typeof i==`object`&&i||!Object.is(t[r],i)||!Object.is(n[r],i))return!1;let a=e.inputs.find(e=>e.id===r)?.paramType;return!RL.has(a??``)}function BL(e,t){let n=VF(e),r={};for(let i of e.inputs)n.has(i.id)||Object.hasOwn(t,i.id)&&(r[i.id]=t[i.id]);return r}function VL(e,t,n){if(!n)return!1;let r=BL(e,t);return Object.keys(r).some(e=>!Object.hasOwn(n,e)||!Object.is(r[e],n[e]))}function HL(e,t,n){e.error=``,e.computeErrors=t.errors??[],e.computeWarnings=t.warnings??[],e.diagnostics=t.diagnostics??[],e.blocked=t.blocked??!1,e.unsolved=t.aborted?`aborted`:null,!e.blocked&&qL(e.diagnostics)?(e.heldResult=t,e.hasPendingChanges&&=n):(e.heldResult=null,WL(e,t,n))}function UL(e){let t={};for(let n of e.outputs)n.type!==`dynamicValueList`&&(t[n.id]=null);return t}function WL(e,t,n){e.meshes=t.meshes??[];let{meshes:r,...i}=t;e.lastResult=i,Object.assign(e.values,t.outputs),e.hasPendingChanges&&=n,e.hasNeverSolved=!1}function GL(e,t){return t||e.heldResult?`wait`:e.hasPendingChanges?`solve`:e.unsolved===`discarded`?`discarded`:e.unsolved||e.hasNeverSolved||e.error||!e.lastResult?`solve`:e.blocked?`blocked`:`applied`}function KL(e,t){return t?`solving`:e.heldResult?`review`:e.blocked?`blocked`:`idle`}function qL(e){return e.some(e=>e.isGate&&e.level!==`remark`)}function JL(e,t){for(let n of[...e])try{n(t)}catch(e){console.error(`[Solve/session] listener threw:`,e)}}function YL(e){let t=e.schema,n=null,r=null,i=PL(t,e.scopeKey,xL),a=!1,o=new Set,s=()=>JL(o,void 0),c=e.driver.solveFiles,l=TL(c&&((t,n)=>c.call(e.driver,t,n)),s),u=()=>l.show(i.lastResult),d=new Set,f=[],p={status:`aborted`,diagnostics:[]};function m(){return a?Promise.resolve(p):new Promise(e=>f.push(e))}function h(e){let t=f;f=[],t.forEach(t=>t(e)),JL(d,e)}function g(){let e=f;f=[],e.forEach(e=>e(p))}function _(e){let t=i.diagnostics;return e.aborted?{status:`aborted`,diagnostics:t}:e.blocked?{status:`blocked`,diagnostics:t}:{status:`applied`,result:i.lastResult,diagnostics:t}}function v(t){s(),e.driver.hasQueued||h(t())}function y(){i.heldResult&&(i.heldResult=null,JL(d,{status:`discarded`,diagnostics:i.diagnostics}))}function b(){return VL(t,i.values,r)}let x=EL,S=e.driver.onEvent?.(e=>{let t=OL(x,e);t!==x&&(x=t,s())});function C(){let e=m();return w(),e}function w(){a||(y(),n={...BL(t,i.values)},r=n,l.cancel(),e.driver.solve(n,t.previewSolves===!0?{solveMode:`preview`}:void 0),s())}return{get values(){return i.values},get error(){return i.error},get computeErrors(){return i.computeErrors},get computeWarnings(){return i.computeWarnings},get diagnostics(){return i.diagnostics},get blocked(){return i.blocked},get awaitingAck(){return i.heldResult!==null},acknowledge(){let e=i.heldResult;e&&(i.heldResult=null,WL(i,e,b()),u(),v(()=>_(e)))},discard(){i.heldResult&&(i.heldResult=null,i.unsolved=`discarded`,v(()=>({status:`discarded`,diagnostics:i.diagnostics})))},get live(){return x},get phase(){return KL(i,e.driver.isSolving)},abort(){e.driver.cancel()},get meshes(){return i.meshes},get files(){return l.state},makeFiles(){return a?Promise.resolve():l.make()},cancelFiles(){l.cancel()},get lastResult(){return i.lastResult},get hasPendingChanges(){return i.hasPendingChanges},get hasNeverSolved(){return i.hasNeverSolved},get isSolving(){return e.driver.isSolving},setValue(e,r,a=!1){(a||!zL(t,n,i.values,e,r))&&(FL(i,e,r,t.instanceSolve,a)?w():s())},solve:C,ensureSolved(){let t=e.driver.isSolving||e.driver.hasQueued===!0,n=GL(i,t);return n===`wait`?m():n===`solve`?C():n===`applied`?Promise.resolve({status:n,result:i.lastResult,diagnostics:i.diagnostics}):Promise.resolve({status:n,diagnostics:i.diagnostics})},onSettled(e){return d.add(e),()=>d.delete(e)},loadValues(e){LL(i,e,t.instanceSolve)?w():s()},rebuild(o,c){a||(g(),t=o,n=null,r=null,e.driver.reset?.(),Object.assign(i,PL(o,c,xL)),u(),Object.keys(i.values).length>0&&o.instanceSolve!==!1?w():s())},report(r){let a=r.blocked||r.aborted,o=r.aborted===!0||b();if(r.aborted&&(n=null),HL(i,a?{...r,outputs:UL(t),meshes:[]}:r,o),u(),e.driver.hasQueued&&(i.heldResult=null),i.heldResult)return s();v(()=>_(r))},reportError(e){y(),n=null,i.error=e,i.unsolved=null,v(()=>({status:`failed`,error:e}))},reportAborted(){n=null,i.unsolved=`aborted`,v(()=>p)},subscribe(e){return o.add(e),()=>o.delete(e)},notify:s,dispose(){a=!0,S?.(),o.clear(),l.show(null),d.clear(),e.driver.reset?.(),g()}}}function XL(e,t){let{runDeadlineMs:n,onChange:r}=t,i=!1,a=null,o=null;function s(e){if(i!==e){i=e;try{r?.()}catch(e){console.error(`[Solve/throttle] onChange threw:`,e)}}}async function c(t){let r=new AbortController;o=r;let l=setTimeout(()=>{console.warn(`[Solve/throttle] run exceeded ${n}ms — aborting`),r.abort(new DOMException(`Run deadline exceeded`,`TimeoutError`))},n);s(!0);try{await e(t,r.signal)}catch(e){(!(e instanceof Error)||e.name!==`AbortError`&&e.name!==`TimeoutError`)&&console.error(`[Solve/throttle] unhandled error in run:`,e)}finally{if(clearTimeout(l),o===r&&(o=null),s(!1),a!==null&&!i){let e=a;a=null,c(e)}}}function l(e){i?(a!==null&&console.debug(`[Solve/throttle] superseded pending run (latest-wins)`),a=e):c(e)}function u(){a=null,o?.abort(),o=null}return{trigger:l,get isRunning(){return i},get hasPending(){return a!==null},cancel:u}}var ZL=e=>`The solve took longer than ${e} s and was stopped.`;function QL(e,t,n){let{meshPolicy:r,solveDeadlineMs:i,onChange:a,events:o}=n,s=n.timeoutMessage??ZL,c=ML({meshPolicy:r}),l=`full`,u=`full`,d=0;function f(e){console.debug(`[Solve/driver] solve stopped (cancelled or timed out)`),e.reason?.name===`TimeoutError`?t().reportError(s(Math.round(i/1e3))):t().reportAborted()}let p=XL(async(n,r)=>{let i=d,a=u;a!==l&&(c.clear(),l=a);let o;try{let t=c.get(n);t===void 0?(o={...await HF(e(n,r,a===`preview`?{solveMode:a}:void 0),r),values:n},!o.aborted&&i===d&&c.set(n,o)):o=t}catch(e){return i===d?r.aborted?f(r):(console.warn(`[Solve/driver] solve failed:`,e),t().reportError(e instanceof Error?e.message:String(e))):void 0}if(i===d){if(r.aborted)return f(r);t().report(o)}},{runDeadlineMs:i,onChange:a});function m(){p.cancel(),o?.cancelCurrent?.()}return{solve(e,t){u=t?.solveMode??`full`,p.trigger(e)},async solveFiles(t,n){let r=d,a=AbortSignal.any([n,AbortSignal.timeout(i)]),o=await HF(e(t,a,{solveMode:`full`,skipMeshes:!0,liveEvents:!1}),a);return r===d?o:{outputs:{},aborted:!0}},cancel:m,get isSolving(){return p.isRunning},get hasQueued(){return p.hasPending},reset(){d+=1,m(),c.clear()},...o?{onEvent:e=>o.subscribe(e)}:{}}}var $L=1e3,eR=3e4;function tR(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID().replace(/-/g,``):Array.from({length:32},()=>Math.floor(Math.random()*16).toString(16)).join(``)}function nR(e){let t=tR(),n=new Set,r=e.fetch??((...e)=>fetch(...e)),i=null,a=null,o=$L,s=null;function c(){if(i||typeof EventSource>`u`)return;let r=`${e.endpoint}${e.endpoint.includes(`?`)?`&`:`?`}streamId=${t}`,l=new EventSource(r);i=l,l.addEventListener(`open`,()=>{o=$L}),l.addEventListener(`solve`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}t.type===`solveStarted`?a=t.solveId:t.type===`solveEnded`&&a===t.solveId&&(a=null);for(let e of n)e(t)}),l.addEventListener(`error`,()=>{l.readyState===EventSource.CLOSED&&i===l&&(i=null,a=null,s=setTimeout(c,o),o=Math.min(o*2,eR))})}return c(),{streamId:t,get currentSolveId(){return a},subscribe(e){return n.add(e),()=>{n.delete(e)}},cancelCurrent(){let t=a;t&&r(e.cancelEndpoint(t),{method:`POST`,keepalive:!0}).catch(()=>{})},close(){s&&clearTimeout(s),i?.close(),i=null,n.clear(),a=null}}}var rR={Prefer:UF},iR=10,aR=new Set([101,103,204,205,304]);async function oR(e){if(e.headers.get(`Preference-Applied`)!==`selva-keepalive`||!e.body)return e;let t=e.body.getReader(),n=new Uint8Array;for(;;){let{done:e,value:r}=await t.read();if(e)throw Error(`The keep-alive response ended before the solve result.`);n=sR(n,r);let i=n.indexOf(iR);if(i===-1)continue;let a=JSON.parse(new TextDecoder().decode(n.subarray(0,i))),o=new Headers(a.headers),s=cR(n.subarray(i+1),t);return o.get(`Content-Encoding`)===`gzip`&&(s=s.pipeThrough(new DecompressionStream(`gzip`)),o.delete(`Content-Encoding`),o.delete(`Content-Length`)),new Response(aR.has(a.status)?null:s,{status:a.status,headers:o})}}function sR(e,t){let n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e),n.set(t,e.byteLength),n}function cR(e,t){return new ReadableStream({start(t){e.byteLength>0&&t.enqueue(e)},async pull(e){let{done:n,value:r}=await t.read();n?e.close():e.enqueue(r)},cancel(e){return t.cancel(e)}})}function lR(e){let t={};if(!e)return t;for(let n of e.split(`,`)){let[e,...r]=n.split(`;`).map(e=>e.trim()),i=r.find(e=>e.startsWith(`dur=`));if(!e||!i)continue;let a=Number(i.slice(4));Number.isFinite(a)&&(t[e]=a)}return t}function uR(e){let t=lR(e);if(!e||t.solve===void 0)return null;let n=e=>(e??0).toFixed(0),r=`compute ${n(t.solve)}`;if(t.rhino_solve!==void 0){let e=t.rhino_gh===void 0?``:` (grasshopper ${n(t.rhino_gh)})`;r+=`: solve ${n(t.rhino_solve)}${e}, decode ${n(t.rhino_decode)}, encode ${n(t.rhino_encode)}, queue+link ${n(t.compute_link)}`}let i=[r],a=Object.entries(t).filter(([e])=>e.startsWith(`p_`)),o=a.reduce((e,[,t])=>e+t,0);if(o>=1){let e=a.filter(([,e])=>e>=1).sort((e,t)=>t[1]-e[1]).map(([e,t])=>`${e.slice(2)} ${n(t)}`);i.push(`prep ${n(o)}: ${e.join(`, `)}`)}i.push(`tree ${n(t.tree)}`,`serialize ${n(t.serialize)}`,`gzip ${n(t.gzip)}`),t.def_reupload&&i.push(`definition re-sent to Compute`);for(let[,t,n]of e.matchAll(/(\w+);desc="?([^",;]+)"?/g))i.push(`${t.replace(/^rhino_/,``)} ${n}`);return i.join(` | `)}var dR=5,fR=3600,pR=class extends Error{name=`SolveRequestError`;status;body;code;retryAfterSeconds;constructor(e,t){super(e),this.status=t.status,this.body=t.body,this.code=mR(t.body),this.retryAfterSeconds=t.retryAfterSeconds??void 0}};function mR(e){if(yR(e))return typeof e.code==`string`?e.code:typeof e.reason==`string`?e.reason:void 0}function hR(e,t){return new pR(`Rate limit reached. Try again in ${Math.ceil(e)}s.`,{status:429,body:t,retryAfterSeconds:e})}function gR(e){return new pR(`Your session has expired. Sign in again in a new tab, then re-run — your inputs are preserved.`,{status:401,body:e})}function _R(e){if(!e.trim())return null;let t=Number(e);if(!Number.isNaN(t))return Number.isFinite(t)&&t>=0?t:null;let n=Date.parse(e);return Number.isNaN(n)?null:Math.max(0,(n-Date.now())/1e3)}function vR(e,t){let n=(e===null?null:_R(e))??(typeof t==`number`?_R(String(t)):null);return n===null?null:Math.min(n,fR)}function yR(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function bR(e){let t;try{t=JSON.parse(e)}catch{return{}}return yR(t)?{body:t,...typeof t.message==`string`?{message:t.message}:{},retryAfter:t.retryAfter}:{body:t}}function xR(e){let t=e.debug??!1,n=(...e)=>{t&&console.info(...e)},r=0;function i(t,n){return e.onRateLimited?.(t),hR(t,n)}return async(a,o,s={})=>{let c=r-Date.now();if(c>0)throw i(c/1e3);let l=performance.now(),u=e.inputs(),d=e.outputs(),f=e.channel?.(),p=e.versionId?.(),m=s.liveEvents===!1?null:e.streamId?.(),h=e.bearerToken?.(),g=JSON.stringify({inputs:u,values:a,definitionUrl:e.definitionUrl(),...p?{versionId:p}:f===`draft`?{channel:`draft`}:{},...m?{streamId:m}:{},...s.solveMode===`preview`?{mode:`preview`}:{}}),_;try{_=await fetch(e.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`,...h?{Authorization:`Bearer ${h}`}:{},...e.keepalive?rR:{}},body:g,signal:o})}catch(e){if(o.aborted)return n(`[Compute] solve aborted during fetch — empty result discarded`),{outputs:{}};throw Error(`Could not reach the server. Check your connection, or reload the page if your session expired.`,{cause:e})}if(o.aborted)return n(`[Compute] solve aborted after headers — empty result discarded`),{outputs:{}};let v=_.redirected&&new URL(_.url).pathname===(e.loginPath??`/login`);try{_=await oR(_)}catch(e){if(o.aborted)return n(`[Compute] solve aborted while the server held it — empty result discarded`),{outputs:{}};throw Error(`The connection dropped while waiting for the result. Please try again.`,{cause:e})}if(_.status===401||v)throw e.onSessionExpired?.(),gR(v?void 0:bR(await _.text().catch(()=>``)).body);if(!_.ok){let e=await _.text().catch(()=>``),{body:t,message:a,retryAfter:o}=bR(e);e&&a===void 0&&n(`[Compute] unreadable error body (HTTP ${_.status}, ${e.length} chars)`);let s=vR(_.headers.get(`Retry-After`),o);if(s!==null&&(r=Date.now()+s*1e3),_.status===503||_.status===504)throw new pR(a||`Compute server is offline or unreachable. Please try again later.`,{status:_.status,body:t,retryAfterSeconds:s});if(_.status===429){let e=s??dR;throw r=Date.now()+e*1e3,i(e,t)}throw new pR(a||`Compute error (HTTP ${_.status})`,{status:_.status,body:t,retryAfterSeconds:s})}let y=performance.now()-l,b=performance.now(),x;try{x=await _.text()}catch(e){if(o.aborted)return n(`[Compute] solve aborted mid-download — empty result discarded`),{outputs:{}};throw Error(`The connection dropped while receiving the result. Please try again.`,{cause:e})}let S=performance.now()-b,C=x.length,w=e=>Error(`Received an invalid response from the server. Reload the page and try again.`,{cause:e}),T;try{T=JSON.parse(x)}catch(e){throw w(e)}if(!yR(T))throw w();let E=T,D=new vL(E),O=PF(E.selva?.outcome)??FF(E.errors??[],E.warnings??[]),k=O.blocked||O.aborted,A=e.meshes&&!k&&!s.skipMeshes?await e.meshes.extract(D.response,{debug:t,signal:o}):[],j={};for(let e of k?[]:d){let t=D.getValue({byId:e.id},{parseValues:!0});j[e.id]=t??(e.nickname?D.getValue({byName:e.nickname},{parseValues:!0}):void 0)}if(t){let e=JSON.stringify(a).length,t=_.headers.get(`Server-Timing`),r=lR(t),i=r.total??0,o=Math.max(0,y-i),s=C/1048576,c=s>=1?`${s.toFixed(2)} MB`:`${(C/1024).toFixed(0)} KB`,l=S>0?(s/(S/1e3)).toFixed(1):`∞`,u=performance.memory?.usedJSHeapSize,d=u===void 0?``:` | heap=${(u/1048576).toFixed(0)} MB`;n(`[Compute] req=${(g.length/1024).toFixed(0)}KB (values ${(e/1024).toFixed(0)}KB) | ttfb=${y.toFixed(0)}ms (network≈${o.toFixed(0)} + server ${i.toFixed(0)}) | download=${S.toFixed(0)}ms (${c} @ ${l} MB/s)${d}`);let f=uR(t);if(f&&n(`[Compute] └─ server: ${f}`),r.selva_cache!==void 0){let e=r.selva_cache?`HIT — served without calling compute`:r.rhino_cache?`HIT — Rhino.Compute's result cache, solved nothing`:`miss — solved on Rhino.Compute`;n(`[Compute] └─ cache: ${e}`)}}return IF({outputs:j,meshes:A,source:E},O)}}function SR(e){let t=T(()=>[...e().progress.values()]),n=Z({}),r=new Map,i={};le(()=>{let e={},a={},o=Y(()=>C(n)),s=new Map;for(let n of C(t)){if(n.fraction===void 0)continue;let t=n.source??``;s.set(t,n),r.get(t)===n&&o[t]?(e[t]=o[t],i[t]&&o[t]!==i[t]&&(a[t]=i[t])):(e[t]={width:n.fraction,ms:150},n.nextFraction!==void 0&&n.stepMs!==void 0&&(a[t]={width:n.nextFraction,ms:n.stepMs}))}if(r=s,i=a,P(n,e),Object.keys(a).length===0)return;let c=requestAnimationFrame(()=>{c=requestAnimationFrame(()=>P(n,{...e,...a}))});return()=>cancelAnimationFrame(c)});let a=Z(void 0),o=0;return le(()=>{let e=C(t)[0],n=Y(()=>C(a));if(e?.label===n?.label&&e?.done===n?.done){P(a,e);return}let r=()=>{P(a,e),o=performance.now()},i=200-(performance.now()-o);if(!n||i<=0){r();return}let s=setTimeout(r,i);return()=>clearTimeout(s)}),{get progress(){return C(t)},get headline(){return C(a)},get bars(){return C(n)}}}var CR=D(`<span class="text-xs shrink-0 text-muted-foreground tabular-nums"> </span>`),wR=D(`<div class="h-full w-(--bar-width) rounded-full bg-primary transition-all duration-(--bar-ms) ease-linear"></div>`),TR=D(`<div class="animate-pulse h-full w-1/3 rounded-full bg-primary/60"></div>`),ER=D(` <kbd class="px-1 rounded-sm border border-border font-sans text-2xs text-muted-foreground">Esc</kbd>`,1),DR=D(`<div class="px-3 gap-2 flex h-full flex-col justify-center"><div class="gap-2 min-w-0 flex items-center"><!> <span class="text-sm font-medium min-w-0 flex-1 truncate"> </span> <!></div> <div class="h-1 overflow-hidden rounded-full bg-muted" role="progressbar"><!></div> <div class="gap-2 flex items-center"><span class="text-xs text-muted-foreground tabular-nums"> </span> <!></div></div>`),OR=D(`<span class="text-sm font-medium shrink-0"> </span> <span class="text-xs min-w-0 truncate text-muted-foreground" data-testid="solve-esc-hint"> </span>`,1),kR=D(`<span class="text-sm font-medium shrink-0"> </span> <span class="text-xs text-muted-foreground tabular-nums"> </span>`,1),AR=D(`<div class="px-3 gap-2 flex h-full items-center"><!> <!></div>`),jR=D(`<span class="text-sm font-medium min-w-0 truncate"> </span>`),MR=D(`<!> <span class="text-sm font-medium shrink-0"> </span> <span class="text-xs text-muted-foreground tabular-nums"> </span>`,1),NR=D(`<div class="px-3 gap-2 flex h-full items-center"><!></div>`),PR=D(`<span class="solve-ping inset-0 absolute rounded-full border-2 border-success svelte-1o5zv0z"></span>`),FR=D(`<div class="px-3 gap-2 flex h-full items-center"><span class="size-1.5 relative shrink-0 rounded-full bg-success"><!></span> <span class="text-sm min-w-0 truncate text-muted-foreground"> </span></div>`),IR=D(`<div class="h-10 min-w-0 relative flex-1"><div role="status" aria-live="polite" aria-atomic="true" class="sr-only"> </div> <div data-testid="solve-status"><!></div></div>`);function LR(e,n){V(n,!0);let r=J(n,`slow`,3,!1),i=J(n,`freezesDuringSolve`,3,!1),a=at(),o=T(()=>a.messages),s=SR(()=>n.live??EL),l=T(()=>s.headline??s.progress[0]),d=T(()=>C(l)?.fraction===void 0?void 0:s.bars[C(l).source??``]??{width:C(l).fraction,ms:150}),f=0,p=!1,h=Z(0),g=Z(null),_=Z(0),v=0,y=!1;le(()=>{n.show&&(y=!0)}),le(()=>{let e=n.isSolving;Y(()=>{if(e===p)return;if(p=e,e){f=performance.now(),y=n.show,P(h,0),P(g,null);return}let t=performance.now()-f;f=0,y?P(g,{ms:t,aborted:n.live?.ended?.kind===`aborted`},!0):performance.now()-v>500&&(v=performance.now(),ee(_))})}),le(()=>{if(!C(g))return;let e=setTimeout(()=>P(g,null),1400);return()=>clearTimeout(e)}),le(()=>{if(!n.isSolving||!n.show||i())return;let e=()=>P(h,performance.now()-f);e();let t=setInterval(e,100);return()=>clearInterval(t)});let x=T(()=>C(g)?`done`:n.show?r()&&!i()?`card`:`work`:`idle`),w=T(()=>new Intl.NumberFormat(a.locale,{minimumFractionDigits:1,maximumFractionDigits:1})),E=e=>`${C(w).format(e/1e3)} s`,D=T(()=>C(x)===`work`||C(x)===`card`?C(o).solvingEllipsis:C(x)===`done`?C(g)?.aborted?C(o).solveStopped:C(o).solveDone:``);var k=IR(),A=L(k),j=K(A,!0),M=U(A,2),F=L(M),I=e=>{var r=DR(),i=L(r),a=L(i);_t(a,{class:`size-4 animate-spin shrink-0 text-muted-foreground`,"aria-hidden":`true`});var s=U(a,2),u=K(s,!0),f=U(s,2),p=e=>{var t=CR(),n=K(t);G(()=>m(n,`${C(l).done??``} / ${C(l).total??``}`)),O(e,t)};t(f,e=>{C(l)?.done!==void 0&&C(l)?.total!==void 0&&e(p)}),c(i);var g=U(i,2);H(g,`aria-valuemin`,0),H(g,`aria-valuemax`,100);var _=L(g),v=e=>{var t=wR();let n;G(()=>n=N(t,``,n,{"--bar-width":`${C(d).width*100}%`,"--bar-ms":`${C(d).ms??``}ms`})),O(e,t)},y=e=>{var t=TR();O(e,t)};t(_,e=>{C(d)?e(v):e(y,-1)}),c(g);var b=U(g,2),x=L(b),w=K(x,!0),T=U(x,2),D=e=>{tt(e,{variant:`outline`,size:`xs`,class:`ml-auto shrink-0`,get onclick(){return n.onabort},"aria-keyshortcuts":`Escape`,get title(){return C(o).solveMessagesEscHint},children:(e,t)=>{S();var n=ER(),r=B(n);S(),G(()=>m(r,`${C(o).solveMessagesAbort??``} `)),O(e,n)},$$slots:{default:!0}})};t(T,e=>{n.onabort&&e(D)}),c(b),c(r),G((e,t)=>{m(u,C(l)?.label??C(o).solving),H(g,`aria-label`,C(l)?.label??C(o).solving),H(g,`aria-valuenow`,e),m(w,t)},[()=>C(d)?Math.round(C(d).width*100):void 0,()=>E(C(h))]),X(1,r,()=>Tn,()=>({duration:150,delay:80})),O(e,r)},te=e=>{var n=AR(),r=L(n);_t(r,{class:`size-4 animate-spin shrink-0 text-muted-foreground`,"aria-hidden":`true`});var a=U(r,2),s=e=>{var t=OR(),n=B(t),r=K(n,!0),i=U(n,2),a=K(i,!0);G(()=>{m(r,C(o).solvingEllipsis),m(a,C(o).solveMessagesEscHint)}),O(e,t)},l=e=>{var t=kR(),n=B(t),r=K(n,!0),i=U(n,2),a=K(i,!0);G(e=>{m(r,C(o).solving),m(a,e)},[()=>E(C(h))]),O(e,t)};t(a,e=>{i()?e(s):e(l,-1)}),c(n),X(1,n,()=>Tn,()=>({duration:150,delay:80})),O(e,n)},R=e=>{var n=NR(),r=L(n),i=e=>{var t=jR(),n=K(t,!0);G(()=>m(n,C(o).solveStopped)),O(e,t)},a=e=>{var t=MR(),n=B(t);ot(n,{class:`size-4 shrink-0 text-success`,"aria-hidden":`true`});var r=U(n,2),i=K(r,!0),a=U(r,2),s=K(a,!0);G(e=>{m(i,C(o).solveDone),m(s,e)},[()=>E(C(g).ms)]),O(e,t)};t(r,e=>{C(g).aborted?e(i):e(a,-1)}),c(n),X(1,n,()=>Tn,()=>({duration:150,delay:80})),O(e,n)},z=e=>{var n=FR(),r=L(n),i=L(r);ae(i,()=>C(_),e=>{var n=u(),r=B(n),i=e=>{var t=PR();O(e,t)};t(r,e=>{C(_)>0&&e(i)}),O(e,n)}),c(r);var a=U(r,2),s=K(a,!0);c(n),G(()=>m(s,C(o).upToDate)),X(1,n,()=>Tn,()=>({duration:150})),O(e,n)};t(F,e=>{C(x)===`card`?e(I):C(x)===`work`?e(te,1):C(x)===`done`&&C(g)?e(R,2):e(z,-1)}),c(M),c(k),G(()=>{m(j,C(D)),fe(M,1,`inset-x-0 bottom-0 backdrop-blur-md ease-out absolute z-10 overflow-hidden border border-border-strong transition-all duration-300 motion-reduce:transition-none ${C(x)===`card`?`h-24 shadow-md rounded-lg bg-card/75`:C(x)===`idle`?`h-10 shadow-sm rounded-md bg-card/90`:`h-10 shadow-md rounded-md bg-card/75`}`),H(M,`data-state`,C(x))}),O(e,k),b()}var RR=/^[a-z0-9]+(-[a-z0-9]+)*$/,zR=(e,t,n,r=``)=>{let i=e.split(`:`);if(e.slice(0,1)===`@`){if(i.length<2||i.length>3)return null;r=i.shift().slice(1)}if(i.length>3||!i.length)return null;if(i.length>1){let e=i.pop(),n=i.pop(),a={provider:i.length>0?i[0]:r,prefix:n,name:e};return t&&!BR(a)?null:a}let a=i[0],o=a.split(`-`);if(o.length>1){let e={provider:r,prefix:o.shift(),name:o.join(`-`)};return t&&!BR(e)?null:e}if(n&&r===``){let e={provider:r,prefix:``,name:a};return t&&!BR(e,n)?null:e}return null},BR=(e,t)=>e?!!((t&&e.prefix===``||e.prefix)&&e.name):!1;function VR(e,t){let n=e.icons,r=e.aliases||Object.create(null),i=Object.create(null);function a(e){if(n[e])return i[e]=[];if(!(e in i)){i[e]=null;let t=r[e]&&r[e].parent,n=t&&a(t);n&&(i[e]=[t].concat(n))}return i[e]}return Object.keys(n).concat(Object.keys(r)).forEach(a),i}var HR=Object.freeze({left:0,top:0,width:16,height:16}),UR=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),WR=Object.freeze({...HR,...UR}),GR=Object.freeze({...WR,body:``,hidden:!1});function KR(e,t){let n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);let r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function qR(e,t){let n=KR(e,t);for(let r in GR)r in UR?r in e&&!(r in n)&&(n[r]=UR[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function JR(e,t,n){let r=e.icons,i=e.aliases||Object.create(null),a={};function o(e){a=qR(r[e]||i[e],a)}return o(t),n.forEach(o),qR(e,a)}function YR(e,t){let n=[];if(typeof e!=`object`||typeof e.icons!=`object`)return n;e.not_found instanceof Array&&e.not_found.forEach(e=>{t(e,null),n.push(e)});let r=VR(e);for(let i in r){let a=r[i];a&&(t(i,JR(e,i,a)),n.push(i))}return n}var XR={provider:``,aliases:{},not_found:{},...HR};function ZR(e,t){for(let n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function QR(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.prefix!=`string`||!e.icons||typeof e.icons!=`object`||!ZR(e,XR))return null;let n=t.icons;for(let e in n){let t=n[e];if(!e||typeof t.body!=`string`||!ZR(t,GR))return null}let r=t.aliases||Object.create(null);for(let e in r){let t=r[e],i=t.parent;if(!e||typeof i!=`string`||!n[i]&&!r[i]||!ZR(t,GR))return null}return t}var $R=Object.create(null);function ez(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function tz(e,t){let n=$R[e]||($R[e]=Object.create(null));return n[t]||(n[t]=ez(e,t))}function nz(e,t){return QR(t)?YR(t,(t,n)=>{n?e.icons[t]=n:e.missing.add(t)}):[]}function rz(e,t,n){try{if(typeof n.body==`string`)return e.icons[t]={...n},!0}catch{}return!1}var iz=!1;function az(e){return typeof e==`boolean`&&(iz=e),iz}function oz(e){let t=typeof e==`string`?zR(e,!0,iz):e;if(t){let e=tz(t.provider,t.prefix),n=t.name;return e.icons[n]||(e.missing.has(n)?null:void 0)}}function sz(e,t){let n=zR(e,!0,iz);if(!n)return!1;let r=tz(n.provider,n.prefix);return t?rz(r,n.name,t):(r.missing.add(n.name),!0)}function cz(e,t){if(typeof e!=`object`)return!1;if(typeof t!=`string`&&(t=e.provider||``),iz&&!t&&!e.prefix){let t=!1;return QR(e)&&(e.prefix=``,YR(e,(e,n)=>{sz(e,n)&&(t=!0)})),t}let n=e.prefix;return BR({prefix:n,name:`a`})?!!nz(tz(t,n),e):!1}var lz=Object.freeze({width:null,height:null}),uz=Object.freeze({...lz,...UR}),dz=/(-?[0-9.]*[0-9]+[0-9.]*)/g,fz=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function pz(e,t,n){if(t===1)return e;if(n||=100,typeof e==`number`)return Math.ceil(e*t*n)/n;if(typeof e!=`string`)return e;let r=e.split(dz);if(r===null||!r.length)return e;let i=[],a=r.shift(),o=fz.test(a);for(;;){if(o){let e=parseFloat(a);isNaN(e)?i.push(a):i.push(Math.ceil(e*t*n)/n)}else i.push(a);if(a=r.shift(),a===void 0)return i.join(``);o=!o}}function mz(e,t=`defs`){let n=``,r=e.indexOf(`<`+t);for(;r>=0;){let i=e.indexOf(`>`,r),a=e.indexOf(`</`+t);if(i===-1||a===-1)break;let o=e.indexOf(`>`,a);if(o===-1)break;n+=e.slice(i+1,a).trim(),e=e.slice(0,r).trim()+e.slice(o+1)}return{defs:n,content:e}}function hz(e,t){return e?`<defs>`+e+`</defs>`+t:t}function gz(e,t,n){let r=mz(e);return hz(r.defs,t+r.content+n)}var _z=e=>e===`unset`||e===`undefined`||e===`none`;function vz(e,t){let n={...WR,...e},r={...uz,...t},i={left:n.left,top:n.top,width:n.width,height:n.height},a=n.body;[n,r].forEach(e=>{let t=[],n=e.hFlip,r=e.vFlip,o=e.rotate;n?r?o+=2:(t.push(`translate(`+(i.width+i.left).toString()+` `+(0-i.top).toString()+`)`),t.push(`scale(-1 1)`),i.top=i.left=0):r&&(t.push(`translate(`+(0-i.left).toString()+` `+(i.height+i.top).toString()+`)`),t.push(`scale(1 -1)`),i.top=i.left=0);let s;switch(o<0&&(o-=Math.floor(o/4)*4),o%=4,o){case 1:s=i.height/2+i.top,t.unshift(`rotate(90 `+s.toString()+` `+s.toString()+`)`);break;case 2:t.unshift(`rotate(180 `+(i.width/2+i.left).toString()+` `+(i.height/2+i.top).toString()+`)`);break;case 3:s=i.width/2+i.left,t.unshift(`rotate(-90 `+s.toString()+` `+s.toString()+`)`)}o%2==1&&(i.left!==i.top&&(s=i.left,i.left=i.top,i.top=s),i.width!==i.height&&(s=i.width,i.width=i.height,i.height=s)),t.length&&(a=gz(a,`<g transform="`+t.join(` `)+`">`,`</g>`))});let o=r.width,s=r.height,c=i.width,l=i.height,u,d;o===null?(d=s===null?`1em`:s===`auto`?l:s,u=pz(d,c/l)):(u=o===`auto`?c:o,d=s===null?pz(u,l/c):s===`auto`?l:s);let f={},p=(e,t)=>{_z(t)||(f[e]=t.toString())};p(`width`,u),p(`height`,d);let m=[i.left,i.top,c,l];return f.viewBox=m.join(` `),{attributes:f,viewBox:m,body:a}}var yz=/\sid="(\S+)"/g,bz=new Map;function xz(e){e=e.replace(/[0-9]+$/,``)||`a`;let t=bz.get(e)||0;return bz.set(e,t+1),t?`${e}${t}`:e}function Sz(e){let t=[],n;for(;n=yz.exec(e);)t.push(n[1]);if(!t.length)return e;let r=`suffix`+(Math.random()*16777216|Date.now()).toString(16);return t.forEach(t=>{let n=xz(t),i=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);e=e.replace(RegExp(`([#;"])(`+i+`)([")]|\\.[a-z])`,`g`),`$1`+n+r+`$3`)}),e=e.replace(new RegExp(r,`g`),``),e}var Cz=Object.create(null);function wz(e,t){Cz[e]=t}function Tz(e){return Cz[e]||Cz[``]}function Ez(e){let t;if(typeof e.resources==`string`)t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||`/`,maxURL:e.maxURL||500,rotate:e.rotate||2e3,timeout:e.timeout||1e4,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}var Dz=Object.create(null);Dz[``]=Ez({resources:[`https://api.iconify.design`,`https://api2.iconify.design`]});function Oz(e,t){let n=Ez(t);return n!==null&&(Dz[e]=n,!0)}function kz(e){return Dz[e]}var Az=(()=>{let e;try{if(e=fetch,typeof e==`function`)return e}catch{}})();function jz(e,t){let n=kz(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let e=0;n.resources.forEach(t=>{e=Math.max(e,t.length)});let i=t+`.json?icons=`;r=n.maxURL-e-n.path.length-i.length}return r}function Mz(e){return e===404}var Nz=(e,t,n)=>{let r=[],i=jz(e,t),a=`icons`,o={type:a,provider:e,prefix:t,icons:[]},s=0;return n.forEach((n,c)=>{s+=n.length+1,s>=i&&c>0&&(r.push(o),o={type:a,provider:e,prefix:t,icons:[]},s=n.length),o.icons.push(n)}),r.push(o),r};function Pz(e){if(typeof e==`string`){let t=kz(e);if(t)return t.path}return`/`}var Fz={prepare:Nz,send:(e,t,n)=>{if(!Az){n(`abort`,424);return}let r=Pz(t.provider);switch(t.type){case`icons`:{let e=t.prefix,n=t.icons.join(`,`),i=new URLSearchParams({icons:n});r+=e+`.json?`+i.toString();break}case`custom`:{let e=t.uri;r+=e.slice(0,1)===`/`?e.slice(1):e;break}default:n(`abort`,400);return}let i=503;Az(e+r).then(e=>{let t=e.status;if(t!==200)setTimeout(()=>{n(Mz(t)?`abort`:`next`,t)});else return i=501,e.json()}).then(e=>{setTimeout(typeof e!=`object`||!e?()=>{e===404?n(`abort`,e):n(`next`,i)}:()=>{n(`success`,e)})}).catch(()=>{n(`next`,i)})}};function Iz(e,t){e.forEach(e=>{let n=e.loaderCallbacks;n&&(e.loaderCallbacks=n.filter(e=>e.id!==t))})}function Lz(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;let t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1,r=e.provider,i=e.prefix;t.forEach(t=>{let a=t.icons,o=a.pending.length;a.pending=a.pending.filter(t=>{if(t.prefix!==i)return!0;let o=t.name;if(e.icons[o])a.loaded.push({provider:r,prefix:i,name:o});else if(e.missing.has(o))a.missing.push({provider:r,prefix:i,name:o});else return n=!0,!0;return!1}),a.pending.length!==o&&(n||Iz([e],t.id),t.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),t.abort))})}))}var Rz=0;function zz(e,t,n){let r=Rz++,i=Iz.bind(null,n,r);if(!t.pending.length)return i;let a={id:r,icons:t,callback:e,abort:i};return n.forEach(e=>{(e.loaderCallbacks||=[]).push(a)}),i}function Bz(e){let t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((e,t)=>e.provider===t.provider?e.prefix===t.prefix?e.name.localeCompare(t.name):e.prefix.localeCompare(t.prefix):e.provider.localeCompare(t.provider));let r={provider:``,prefix:``,name:``};return e.forEach(e=>{if(r.name===e.name&&r.prefix===e.prefix&&r.provider===e.provider)return;r=e;let i=e.provider,a=e.prefix,o=e.name,s=n[i]||(n[i]=Object.create(null)),c=s[a]||(s[a]=tz(i,a)),l;l=o in c.icons?t.loaded:a===``||c.missing.has(o)?t.missing:t.pending;let u={provider:i,prefix:a,name:o};l.push(u)}),t}function Vz(e,t=!0,n=!1){let r=[];return e.forEach(e=>{let i=typeof e==`string`?zR(e,t,n):e;i&&r.push(i)}),r}var Hz={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Uz(e,t,n,r){let i=e.resources.length,a=e.random?Math.floor(Math.random()*i):e.index,o;if(e.random){let t=e.resources.slice(0);for(o=[];t.length>1;){let e=Math.floor(Math.random()*t.length);o.push(t[e]),t=t.slice(0,e).concat(t.slice(e+1))}o=o.concat(t)}else o=e.resources.slice(a).concat(e.resources.slice(0,a));let s=Date.now(),c=`pending`,l=0,u,d=null,f=[],p=[];typeof r==`function`&&p.push(r);function m(){d&&=(clearTimeout(d),null)}function h(){c===`pending`&&(c=`aborted`),m(),f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function g(e,t){t&&(p=[]),typeof e==`function`&&p.push(e)}function _(){return{startTime:s,payload:t,status:c,queriesSent:l,queriesPending:f.length,subscribe:g,abort:h}}function v(){c=`failed`,p.forEach(e=>{e(void 0,u)})}function y(){f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function b(t,n,r){let i=n!==`success`;switch(f=f.filter(e=>e!==t),c){case`pending`:break;case`failed`:if(i||!e.dataAfterTimeout)return;break;default:return}if(n===`abort`)u=r,v();else if(i)u=r,f.length||(o.length?x():v());else{if(m(),y(),!e.random){let n=e.resources.indexOf(t.resource);n!==-1&&n!==e.index&&(e.index=n)}c=`completed`,p.forEach(e=>{e(r)})}}function x(){if(c!==`pending`)return;m();let r=o.shift();if(r===void 0){if(f.length){d=setTimeout(()=>{m(),c===`pending`&&(y(),v())},e.timeout);return}v();return}let i={status:`pending`,resource:r,callback:(e,t)=>{b(i,e,t)}};f.push(i),l++,d=setTimeout(x,e.rotate),n(r,t,i.callback)}return setTimeout(x),_}function Wz(e){let t={...Hz,...e},n=[];function r(){n=n.filter(e=>e().status===`pending`)}function i(e,i,a){let o=Uz(t,e,i,(e,t)=>{r(),a&&a(e,t)});return n.push(o),o}function a(e){return n.find(t=>e(t))||null}return{query:i,find:a,setIndex:e=>{t.index=e},getIndex:()=>t.index,cleanup:r}}function Gz(){}var Kz=Object.create(null);function qz(e){if(!Kz[e]){let t=kz(e);if(!t)return;Kz[e]={config:t,redundancy:Wz(t)}}return Kz[e]}function Jz(e,t,n){let r,i;if(typeof e==`string`){let t=Tz(e);if(!t)return n(void 0,424),Gz;i=t.send;let a=qz(e);a&&(r=a.redundancy)}else{let t=Ez(e);if(t){r=Wz(t);let n=Tz(e.resources?e.resources[0]:``);n&&(i=n.send)}}return!r||!i?(n(void 0,424),Gz):r.query(t,i,n)().abort}function Yz(){}function Xz(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,Lz(e)}))}function Zz(e){let t=[],n=[];return e.forEach(e=>{(e.match(RR)?t:n).push(e)}),{valid:t,invalid:n}}function Qz(e,t,n){function r(){let n=e.pendingIcons;t.forEach(t=>{n&&n.delete(t),e.icons[t]||e.missing.add(t)})}if(n&&typeof n==`object`)try{if(!nz(e,n).length){r();return}}catch(e){console.error(e)}r(),Xz(e)}function $z(e,t){e instanceof Promise?e.then(e=>{t(e)}).catch(()=>{t(null)}):t(e)}function eB(e,t){e.iconsToLoad=e.iconsToLoad?e.iconsToLoad.concat(t).sort():t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;let{provider:t,prefix:n}=e,r=e.iconsToLoad;if(delete e.iconsToLoad,!r||!r.length)return;let i=e.loadIcon;if(e.loadIcons&&(r.length>1||!i)){$z(e.loadIcons(r,n,t),t=>{Qz(e,r,t)});return}if(i){r.forEach(r=>{$z(i(r,n,t),t=>{Qz(e,[r],t?{prefix:n,icons:{[r]:t}}:null)})});return}let{valid:a,invalid:o}=Zz(r);if(o.length&&Qz(e,o,null),!a.length)return;let s=n.match(RR)?Tz(t):null;s?s.prepare(t,n,a).forEach(n=>{Jz(t,n,t=>{Qz(e,n.icons,t)})}):Qz(e,a,null)}))}var tB=(e,t)=>{let n=Bz(Vz(e,!0,az()));if(!n.pending.length){let e=!0;return t&&setTimeout(()=>{e&&t(n.loaded,n.missing,n.pending,Yz)}),()=>{e=!1}}let r=Object.create(null),i=[],a,o;return n.pending.forEach(e=>{let{provider:t,prefix:n}=e;if(n===o&&t===a)return;a=t,o=n,i.push(tz(t,n));let s=r[t]||(r[t]=Object.create(null));s[n]||(s[n]=[])}),n.pending.forEach(e=>{let{provider:t,prefix:n,name:i}=e,a=tz(t,n),o=a.pendingIcons||=new Set;o.has(i)||(o.add(i),r[t][n].push(i))}),i.forEach(e=>{let t=r[e.provider][e.prefix];t.length&&eB(e,t)}),t?zz(t,n,i):Yz};function nB(e,t){let n={...e};for(let e in t){let r=t[e],i=typeof r;e in lz?(r===null||r&&(i===`string`||i===`number`))&&(n[e]=r):i===typeof n[e]&&(n[e]=e===`rotate`?r%4:r)}return n}var rB=/[\s,]+/;function iB(e,t){t.split(rB).forEach(t=>{switch(t.trim()){case`horizontal`:e.hFlip=!0;break;case`vertical`:e.vFlip=!0}})}function aB(e,t=0){let n=e.replace(/^-?[0-9.]*/,``);function r(e){for(;e<0;)e+=4;return e%4}if(n===``){let t=parseInt(e);return isNaN(t)?0:r(t)}if(n!==e){let t=0;switch(n){case`%`:t=25;break;case`deg`:t=90}if(t){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i/=t,i%1==0?r(i):0)}}return t}function oB(e,t){let n=e.indexOf(`xlink:`)===-1?``:` xmlns:xlink="http://www.w3.org/1999/xlink"`;for(let e in t)n+=` `+e+`="`+t[e]+`"`;return`<svg xmlns="http://www.w3.org/2000/svg"`+n+`>`+e+`</svg>`}function sB(e){return e.replace(/"/g,`'`).replace(/%/g,`%25`).replace(/#/g,`%23`).replace(/</g,`%3C`).replace(/>/g,`%3E`).replace(/\s+/g,` `).replace(/:/g,`%3A`).replace(/\//g,`%2F`)}function cB(e){return`data:image/svg+xml,`+sB(e)}function lB(e){return`url("`+cB(e)+`")`}var uB={...uz,inline:!1},dB={xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,"aria-hidden":!0,role:`img`},fB={display:`inline-block`},pB={"background-color":`currentColor`},mB={"background-color":`transparent`},hB={image:`var(--svg)`,repeat:`no-repeat`,size:`100% 100%`},gB={"-webkit-mask":pB,mask:pB,background:mB};for(let e in gB){let t=gB[e];for(let n in hB)t[e+`-`+n]=hB[n]}function _B(e){return e+(e.match(/^[-0-9.]+$/)?`px`:``)}function vB(e,t){let n=nB(uB,t),r=t.mode||`svg`,i=r===`svg`?{...dB}:{};e.body.indexOf(`xlink:`)===-1&&delete i[`xmlns:xlink`];let a=typeof t.style==`string`?t.style:``;for(let e in t){let r=t[e];if(r!==void 0)switch(e){case`icon`:case`style`:case`onLoad`:case`mode`:case`ssr`:break;case`inline`:case`hFlip`:case`vFlip`:n[e]=r===!0||r===`true`||r===1;break;case`flip`:typeof r==`string`&&iB(n,r);break;case`color`:a=a+(a.length>0&&a.trim().slice(-1)!==`;`?`;`:``)+`color: `+r+`; `;break;case`rotate`:typeof r==`string`?n[e]=aB(r):typeof r==`number`&&(n[e]=r);break;case`ariaHidden`:case`aria-hidden`:r!==!0&&r!==`true`&&delete i[`aria-hidden`];break;default:if(e.slice(0,3)===`on:`)break;uB[e]===void 0&&(i[e]=r)}}let o=vz(e,n),s=o.attributes;if(n.inline&&(a=`vertical-align: -0.125em; `+a),r===`svg`)return Object.assign(i,s),a!==``&&(i.style=a),{svg:!0,attributes:i,body:Sz(o.body)};let{body:c,width:l,height:u}=e,d=r===`mask`||r!==`bg`&&c.indexOf(`currentColor`)!==-1,f={"--svg":lB(oB(c,{...s,width:l+``,height:u+``}))},p=e=>{let t=s[e];t&&(f[e]=_B(t))};p(`width`),p(`height`),Object.assign(f,fB,d?pB:mB);let m=``;for(let e in f)m+=e+`: `+f[e]+`;`;return i.style=m+a,{svg:!1,attributes:i}}if(az(!0),wz(``,Fz),typeof document<`u`&&typeof window<`u`){let e=window;if(e.IconifyPreload!==void 0){let t=e.IconifyPreload,n=`Invalid IconifyPreload syntax.`;typeof t==`object`&&t&&(t instanceof Array?t:[t]).forEach(e=>{try{(typeof e!=`object`||!e||e instanceof Array||typeof e.icons!=`object`||typeof e.prefix!=`string`||!cz(e))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){let t=e.IconifyProviders;if(typeof t==`object`&&t)for(let e in t){let n=`IconifyProviders[`+e+`] is invalid.`;try{let r=t[e];if(typeof r!=`object`||!r||r.resources===void 0)continue;Oz(e,r)||console.error(n)}catch{console.error(n)}}}}function yB(){try{return typeof window!=`object`}catch{return!0}}function bB(e,t,n,r){function i(){t.loading&&=(t.loading.abort(),null)}if(typeof e==`object`&&e&&typeof e.body==`string`)return t.name=``,i(),{data:{...WR,...e}};let a;if(typeof e!=`string`||(a=zR(e,!1,!0))===null)return i(),null;let o=oz(a);if(!o)return yB()||t.loading&&t.loading.name===e||(i(),t.name=``,t.loading={name:e,abort:tB([a],n)}),null;i(),t.name!==e&&(t.name=e,r&&!t.destroyed&&setTimeout(()=>{r(e)}));let s=[`iconify`];return a.prefix!==``&&s.push(`iconify--`+a.prefix),a.provider!==``&&s.push(`iconify--`+a.provider),{data:o,classes:s}}function xB(e,t){return e?vB({...WR,...e},t):null}var SB=new Set([`$$slots`,`$$events`,`$$legacy`]),CB=k(`<svg></svg>`),wB=D(`<span></span>`);function TB(e,n){V(n,!0);let r={name:``,loading:null,destroyed:!1},i=W(n,SB),a=Z(0),s=T(()=>(C(a),bB(n.icon,r,d,n.onload))),l=T(()=>{let e=C(s)?xB(C(s).data,i):null;return e&&C(s).classes&&i.class===void 0&&(e.attributes.class=(typeof i.class==`string`?i.class+` `:``)+C(s).classes.join(` `)),e});function d(){ee(a)}g(()=>{r.destroyed=!0,r.loading&&=(r.loading.abort(),null)});var f=u(),p=B(f),m=e=>{var n=u(),r=B(n),i=e=>{var t=CB();z(t,()=>({...C(l).attributes})),o(t,()=>C(l).body,!0),c(t),O(e,t)},a=e=>{var t=wB();z(t,()=>({...C(l).attributes})),O(e,t)};t(r,e=>{C(l).svg?e(i):e(a,-1)}),O(e,n)};t(p,e=>{C(l)&&e(m)}),O(e,f),b()}var EB=D(`<span> </span>`),DB=D(`<!> `,1),OB=D(`<button type="button" class="scroll-button back svelte-bbimj6"><!></button>`),kB=D(`<button type="button" class="scroll-button forward svelte-bbimj6"><!></button>`),AB=D(`<div><!> <!> <!></div>`);function jB(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),o=J(n,`bare`,3,!1),s=Z(null),l=Z(!1),d=Z(!1);function p(){if(!C(s))return;let{scrollLeft:e,scrollWidth:t,clientWidth:n}=C(s);P(l,e>1),P(d,e+n<t-1)}le(()=>{if(!C(s))return;let e=new ResizeObserver(p);return e.observe(C(s)),p(),()=>e.disconnect()}),le(()=>{if(!C(s))return;let e=C(s).querySelector(`[data-value="${CSS.escape(n.activeTabId)}"]`);if(!e)return;let t=e.offsetLeft-32,r=e.offsetLeft+e.offsetWidth+32;t<C(s).scrollLeft?C(s).scrollLeft=t:r>C(s).scrollLeft+C(s).clientWidth&&(C(s).scrollLeft=r-C(s).clientWidth)});function h(e){C(s)?.scrollBy({left:e*C(s).clientWidth*.7,behavior:`smooth`})}function g(e){C(s)&&(C(l)||C(d))&&(Math.abs(e.deltaX)>Math.abs(e.deltaY)||(e.preventDefault(),C(s).scrollLeft+=e.deltaY))}var _=AB(),v=L(_);E(v,()=>gn,(e,r)=>{r(e,{variant:`line`,onscroll:p,onwheel:g,get ref(){return C(s)},set ref(e){P(s,e,!0)},children:(e,r)=>{var i=u(),o=B(i);a(o,17,()=>n.tabs,e=>e.id,(e,r)=>{var i=u(),a=B(i);E(a,()=>vn,(e,i)=>{i(e,{get value(){return C(r).id},onclick:()=>n.onTabChange(C(r).id),variant:`line`,children:(e,n)=>{var i=DB(),a=B(i),o=e=>{var n=u(),i=B(n),a=e=>{TB(e,{get icon(){return C(r).icon},class:`h-4 w-4`})},o=T(()=>C(r).icon.includes(`:`)),s=e=>{var t=EB(),n=K(t,!0);G(()=>m(n,C(r).icon)),O(e,t)};t(i,e=>{C(o)?e(a):e(s,-1)}),O(e,n)};t(a,e=>{C(r).icon&&e(o)});var s=U(a);G(()=>m(s,` ${C(r).label??``}`)),O(e,i)},$$slots:{default:!0}})}),O(e,i)}),O(e,i)},$$slots:{default:!0}})});var y=U(v,2),x=e=>{var t=OB(),n=L(t);ct(n,{class:`h-4 w-4`}),c(t),G(()=>H(t,`aria-label`,C(i).scrollTabsBack)),f(`click`,t,()=>h(-1)),O(e,t)};t(y,e=>{C(l)&&e(x)});var S=U(y,2),w=e=>{var t=kB(),n=L(t);ut(n,{class:`h-4 w-4`}),c(t),G(()=>H(t,`aria-label`,C(i).scrollTabsForward)),f(`click`,t,()=>h(1)),O(e,t)};t(S,e=>{C(d)&&e(w)}),c(_),G(()=>fe(_,1,`tab-bar relative shrink-0 border-b border-border ${o()?`mx-1`:`mx-3`}`,`svelte-bbimj6`)),O(e,_),b()}ce([`click`]);var MB={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".webp":`image/webp`,".gif":`image/gif`,".svg":`image/svg+xml`,".json":`application/json`,".txt":`text/plain`,".csv":`text/csv`,".xml":`application/xml`,".pdf":`application/pdf`,".3dm":`model/vnd.3dm`,".obj":`model/obj`,".stl":`model/stl`};function NB(e){let t=MB[(e.fileType??``).toLowerCase()]??`application/octet-stream`,n=e.isBase64Encoded?rI(e.data):e.data;return hF(new Blob([n],{type:t}),`${e.fileName}${e.fileType??``}`)}async function PB(e,t=`grasshopper-output`){try{let n=Array.isArray(e)?e:[e];if(n.length===0){console.warn(`[FileDownload] No files to download`);return}if(n.length===1){await NB(n[0]);return}await fI(n,t,null,{saveBlob:hF})}catch(e){throw console.error(`[FileDownload] Error downloading files:`,e),e}}function FB(e){return typeof e==`object`&&!!e&&`fileName`in e&&`data`in e&&`isBase64Encoded`in e}function IB(e){if(e===0)return`0 Bytes`;let t=rl.FILE_SIZE.BYTES_PER_KB,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/t**+r*100)/100+` `+n[r]}function LB(e){return Math.ceil(e.length*3/4)}var RB=e=>Array.isArray(e)?e.map(String):e==null||e===``?[]:[String(e)],zB={equals:(e,t)=>e===t,notEquals:(e,t)=>e!==t,greaterThan:(e,t)=>Number(e)>Number(t),lessThan:(e,t)=>Number(e)<Number(t),greaterThanOrEqual:(e,t)=>Number(e)>=Number(t),lessThanOrEqual:(e,t)=>Number(e)<=Number(t),between:(e,t,n)=>n?.length===2&&Number(e)>=Number(n[0])&&Number(e)<=Number(n[1]),in:(e,t,n)=>n?.includes(String(e))??!1,notIn:(e,t,n)=>!(n?.includes(String(e))??!1),matches:(e,t)=>{try{return new RegExp(String(t)).test(String(e))}catch{return!1}},contains:(e,t)=>RB(e).includes(String(t)),containsAny:(e,t,n)=>{let r=RB(e);return n?.some(e=>r.includes(String(e)))??!1},isEmpty:e=>RB(e).length===0,isNotEmpty:e=>RB(e).length>0};function BB(e,t){let n=zB[e.operator];return n?n(t[e.paramId],e.value,e.values):!1}function VB(e,t){let n=e.rules.map(e=>BB(e,t));return e.mode===`any`?n.some(Boolean):n.every(Boolean)}var HB={show:e=>({visible:e,disabled:!1}),hide:(e,t)=>({visible:!e,disabled:!1,defaultValue:t}),disable:(e,t)=>({visible:!0,disabled:e,defaultValue:e?t:void 0})};function UB(e,t){if(e.type===`linebreak`)return{visible:!0,disabled:!1};if(`visible`in e&&e.visible===!1||e.type===`output`&&WB(e,t[e.paramId]))return{visible:!1,disabled:!1};if(!e.visibilityCondition?.rules)return{visible:!0,disabled:!1};let{action:n=`show`,defaultValue:r}=e.visibilityCondition,i=VB(e.visibilityCondition,t);return(HB[n]??HB.show)(i,r)}function WB(e,t){switch(e.widgetType){case`image`:return!(Array.isArray(t)?t.some(FB):FB(t));case`chart`:return t==null||t===``;case`dynamicValueList`:return!0;default:return!1}}function GB(e){return e.type===`linebreak`?e.id:e.paramId}function KB(e,t){let n={};for(let r of e)n[GB(r)]=UB(r,t);return n}function qB(e,t){if(e.items&&!YB(e.items,t))return!1;if(!e.visibilityCondition?.rules)return!0;let{action:n=`show`}=e.visibilityCondition,r=VB(e.visibilityCondition,t);return n===`hide`?!r:r}function JB(e,t){return e.visible!==!1&&e.groups.some(e=>qB(e,t))}function YB(e,t){return e.some(e=>e.type!==`linebreak`&&UB(e,t).visible)}var XB=D(`<div class="schema-grid svelte-ejp005"></div>`),ZB=D(`<div class="grid-break svelte-ejp005" aria-hidden="true"></div>`),QB=D(`<div><!></div>`),$B=D(`<div class="p-4"><!></div>`),eV=D(`<p class="pl-4 pr-11 pt-0.5 pb-3 text-xs leading-snug text-muted-foreground"> </p>`),tV=D(`<h3><button type="button"><span class="min-w-0 text-sm font-semibold leading-snug flex-1 text-foreground"> </span> <!></button></h3> <!> <div><div class="content-inner svelte-ejp005"><div class="px-4 pt-2 pb-5"><!></div></div></div>`,1),nV=D(`<section class="rounded-xl border bg-card shadow-raised"><!></section>`);function rV(e,n){let r=l();V(n,!0);let i=e=>{var t=XB();a(t,21,()=>n.items,e=>e.type===`linebreak`?e.id:e.paramId,(e,t)=>{o(e,()=>C(t))}),c(t),G(()=>N(t,`--schema-cols: ${C(_)??``}; --column-gap: 16px;`)),oe(t,`clientWidth`,e=>P(g,e)),O(e,t)},o=(e,r=h)=>{var i=u(),a=B(i),o=e=>{var t=ZB();O(e,t)},s=e=>{let i=T(()=>C(d)[GB(r())]),a=T(()=>Math.min(Math.max(1,r().span??1),C(_)));var o=u(),s=B(o),l=e=>{var o=QB();let s;var l=L(o),d=e=>{var t=u(),a=B(t);x(a,()=>n.inputSnippet,r,()=>C(i)),O(e,t)},f=e=>{var t=u(),i=B(t);x(i,()=>n.outputSnippet,r),O(e,t)};t(l,e=>{r().type===`input`?e(d):r().type===`output`&&e(f,1)}),c(o),G(()=>{s=fe(o,1,`grid-cell min-w-0 svelte-ejp005`,null,s,{"opacity-50":C(i).disabled}),N(o,`--span: ${C(a)??``}`)}),O(e,o)};t(s,e=>{C(i).visible&&e(l)}),O(e,o)};t(a,e=>{r().type===`linebreak`?e(o):e(s,-1)}),O(e,i)},s=J(n,`flat`,3,!1),d=T(()=>KB(n.items,n.values)),p=`${r}-description`,g=Z(0),_=T(()=>C(g)===0?n.columns:Math.max(1,Math.min(n.columns,Math.floor((C(g)+16)/176))));var v=nV(),y=L(v),S=e=>{var t=$B(),n=L(t);i(n),c(t),O(e,t)},w=e=>{var r=tV(),a=B(r),o=L(a),s=L(o),l=K(s,!0),u=U(s,2);{let e=T(()=>n.collapsed?`-rotate-90`:``);st(u,{get class(){return`mt-0.5 h-4 w-4 shrink-0 text-faint-foreground transition-transform duration-200 ${C(e)??``}`}})}c(o),c(a);var d=U(a,2),h=e=>{var t=eV(),r=K(t,!0);G(()=>{H(t,`id`,p),m(r,n.description)}),O(e,t)};t(d,e=>{n.description&&e(h)});var g=U(d,2);let _;var v=L(g),y=L(v),b=L(y);i(b),c(y),c(v),c(g),G(()=>{fe(o,1,`gap-3 px-4 pt-4 flex w-full items-start text-left outline-none select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ${n.description?`pb-0`:`pb-3`}`),H(o,`aria-expanded`,!n.collapsed),H(o,`aria-describedby`,n.description?p:void 0),m(l,n.label),_=fe(g,1,`content-wrapper svelte-ejp005`,null,_,{collapsed:n.collapsed}),g.inert=n.collapsed}),f(`click`,o,function(...e){n.onToggle?.apply(this,e)}),O(e,r)};t(y,e=>{s()?e(S):e(w,-1)}),c(v),O(e,v),b()}ce([`click`]);var iV=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`]);function aV(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,iV);{let i=T(()=>Fe(`group/field-label peer/field-label gap-2 leading-snug flex w-fit group-data-[disabled=true]/field:opacity-50`,`[&>*]:data-[slot=field]:p-4 has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border`,`has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10`,t.class));mn(e,q({"data-slot":`field-label`,get class(){return C(i)}},()=>r,{get ref(){return n()},set ref(e){n(e)},children:(e,n)=>{var r=u(),i=B(r);x(i,()=>t.children??h),O(e,r)},$$slots:{default:!0}}))}b()}var oV=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`,`errors`]),sV=D(`<li> </li>`),cV=D(`<ul class="ms-4 gap-1 flex list-disc flex-col"></ul>`),lV=D(`<div><!></div>`);function uV(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=W(n,oV),o=T(()=>n.children?!0:!(!n.errors||n.errors.length===0||n.errors.length===1&&!n.errors[0]?.message)),s=T(()=>n.errors&&n.errors.length>1),l=T(()=>n.errors&&n.errors.length===1&&n.errors[0]?.message);var d=u(),f=B(d),h=e=>{var o=lV();z(o,e=>({role:`alert`,"data-slot":`field-error`,class:e,...i}),[()=>Fe(`text-sm font-normal text-destructive`,n.class)]);var d=L(o),f=e=>{var t=u(),r=B(t);x(r,()=>n.children),O(e,t)},h=e=>{var t=p();G(()=>m(t,C(l))),O(e,t)},g=e=>{var r=cV();a(r,21,()=>n.errors??[],y,(e,n)=>{var r=u(),i=B(r),a=e=>{var t=sV(),r=K(t,!0);G(()=>m(r,C(n).message)),O(e,t)};t(i,e=>{C(n)?.message&&e(a)}),O(e,r)}),c(r),O(e,r)};t(d,e=>{n.children?e(f):C(l)?e(h,1):C(s)&&e(g,2)}),c(o),F(o,e=>r(e),()=>r()),O(e,o)};t(f,e=>{C(o)&&e(h)}),O(e,d),b()}var dV=D(`<button><!></button>`),fV=D(`<!> <!>`,1);function pV(e,t){V(t,!0);let n=J(t,`nameTemplate`,3,`Help for {label}`);var r=u(),i=B(r);E(i,()=>pn,(e,r)=>{r(e,{children:(e,r)=>{var i=fV(),a=B(i);{let e=(e,r)=>{let i=()=>(r?.()).props;var a=dV();z(a,e=>({...i(),class:`-m-1 size-6 pointer-coarse:after:-inset-2.5 relative flex shrink-0 cursor-help items-center justify-center rounded-sm text-muted-foreground transition hover:text-foreground pointer-coarse:after:absolute pointer-fine:opacity-0 pointer-fine:group-focus-within/field:opacity-100 pointer-fine:group-hover/field:opacity-100 pointer-fine:focus-visible:opacity-100`,"aria-label":e}),[()=>nt(n(),{label:t.label})]),Fn(L(a),{class:`size-3.5`}),c(a),O(e,a)};E(a,()=>Re,(t,n)=>{n(t,{child:e,$$slots:{child:!0}})})}var o=U(a,2);E(o,()=>fn,(e,n)=>{n(e,{class:`sm:max-w-md`,children:(e,n)=>{var r=u(),i=B(r);E(i,()=>un,(e,n)=>{n(e,{children:(e,n)=>{var r=fV(),i=B(r);E(i,()=>ln,(e,n)=>{n(e,{children:(e,n)=>{S();var r=p();G(()=>m(r,t.label)),O(e,r)},$$slots:{default:!0}})});var a=U(i,2);E(a,()=>dn,(e,n)=>{n(e,{children:(e,n)=>{S();var r=p();G(()=>m(r,t.description)),O(e,r)},$$slots:{default:!0}})}),O(e,r)},$$slots:{default:!0}})}),O(e,r)},$$slots:{default:!0}})}),O(e,i)},$$slots:{default:!0}})}),O(e,r),b()}var mV=D(`<div class="gap-2.5 min-h-6 min-w-0 flex items-center"><!> <!></div>`);function hV(e,t){V(t,!0);let n=J(t,`value`,15),r=J(t,`disabled`,3,!1);var i=mV(),a=L(i);{let e=T(()=>typeof n()==`boolean`&&n());Co(a,{get id(){return t.inputId},get checked(){return C(e)},onCheckedChange:e=>{n(e===!0),t.onChange(e===!0)},get disabled(){return r()}})}var o=U(a,2);x(o,()=>t.children??h),c(i),O(e,i),b()}var gV=6;function _V(e,t){switch(e){case`checklist`:case`tiles`:return e;case`segmented`:return t<=gV?`segmented`:`dropdown`;default:return`dropdown`}}var vV=/^data:image\/(webp|jpeg|png);base64,[A-Za-z0-9+/=]+$/;function yV(e,t){if(!e||!t)return;if(e.image){let n=t[e.image]?.img;if(n&&vV.test(n))return{kind:`image`,src:n}}let n=e.icon?t[e.icon]?.d:void 0;return n?{kind:`icon`,d:n}:void 0}var bV=k(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path></path></svg>`),xV=D(`<img alt=""/>`);function SV(e,n){V(n,!0);var r=u(),i=B(r),a=e=>{var t=bV(),r=K(t);G(e=>{fe(t,0,e),H(r,`d`,n.glyph.d)},[()=>me(Fe(`size-4 shrink-0`,n.class))]),O(e,t)},o=e=>{var t=xV();G(e=>{H(t,`src`,n.glyph.src),fe(t,1,e)},[()=>me(Fe(`size-4 shrink-0 rounded-sm object-cover`,n.class))]),O(e,t)};t(i,e=>{n.glyph.kind===`icon`?e(a):e(o,-1)}),O(e,r),b()}var CV=D(`<label><!> <!> <span> </span></label>`),wV=D(`<div class="divide-y divide-border overflow-hidden rounded-md border border-input"></div>`);function TV(e,n){V(n,!0);let r=J(n,`disabled`,3,!1),i=T(()=>n.config?.options??{}),o=T(()=>new Set(n.value??[]));function s(e,t){let r=new ye(C(o));t?r.add(e):r.delete(e),n.onChange([...r])}var l=wV();a(l,21,()=>Object.entries(C(i)),([e,t])=>e,(e,i)=>{var a=T(()=>w(C(i),2));let l=()=>C(a)[0],u=()=>C(a)[1],d=T(()=>u()??l()),f=T(()=>`${n.inputId}-${C(d)}`),p=T(()=>C(o).has(C(d))),h=T(()=>yV(n.config?.optionMedia?.[l()],n.assets));var g=CV(),_=L(g);Co(_,{get id(){return C(f)},get checked(){return C(p)},onCheckedChange:e=>s(C(d),e===!0),get disabled(){return r()}});var v=U(_,2),y=e=>{SV(e,{get glyph(){return C(h)},class:`text-muted-foreground`})};t(v,e=>{C(h)&&e(y)});var b=U(v,2);let x;var S=K(b,!0);c(g),G(()=>{H(g,`for`,C(f)),fe(g,1,`gap-3 px-3 py-2 text-sm flex items-center transition-colors select-none hover:bg-hover ${C(p)?`bg-selected`:``} ${r()?`cursor-not-allowed opacity-50`:`cursor-pointer`}`),x=fe(b,1,`flex-1`,null,x,{"font-medium":C(p)}),m(S,l())}),O(e,g)}),c(l),O(e,l),b()}function EV(e,t){let n=null;function r(...r){n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r),n=null},t)}return r.cancel=()=>{n!==null&&(clearTimeout(n),n=null)},r}var DV=(e,t,n)=>Math.min(n,Math.max(t,e));function OV(e){let t=e.trim().replace(/^#/,``);return/^[0-9a-f]{3}$/i.test(t)?`#${t.split(``).map(e=>e+e).join(``).toLowerCase()}`:/^[0-9a-f]{6}$/i.test(t)?`#${t.toLowerCase()}`:null}function kV(e){let t=OV(e);return t?{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16)}:null}function AV({r:e,g:t,b:n}){let r=e=>DV(Math.round(e),0,255).toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`}function jV({r:e,g:t,b:n}){let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=o-Math.min(r,i,a),c=0;return s!==0&&(c=o===r?(i-a)/s%6:o===i?(a-r)/s+2:(r-i)/s+4,c*=60,c<0&&(c+=360)),{h:c,s:o===0?0:s/o,v:o}}function MV({h:e,s:t,v:n}){let r=n*t,i=(e%360+360)%360/60,a=r*(1-Math.abs(i%2-1)),[o,s,c]=i<1?[r,a,0]:i<2?[a,r,0]:i<3?[0,r,a]:i<4?[0,a,r]:i<5?[a,0,r]:[r,0,a],l=n-r;return{r:(o+l)*255,g:(s+l)*255,b:(c+l)*255}}var NV=e=>{let t=kV(e);return t?jV(t):null},PV=e=>AV(MV(e));function FV({r:e,g:t,b:n}){let r=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function IV(e,t){let n=kV(e),r=kV(t);if(!n||!r)return null;let i=FV(n),a=FV(r);return(Math.max(i,a)+.05)/(Math.min(i,a)+.05)}var LV=D(`<button><span class="size-5 shrink-0 rounded-md bg-(--swatch) ring-1 ring-border ring-inset"></span> <span class="font-mono text-sm text-muted-foreground"> </span></button>`),RV=D(`<button type="button" class="size-9 flex shrink-0 cursor-pointer items-center justify-center rounded-md border border-input bg-background outline-none hover:bg-hover focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"><!></button>`),zV=D(`<p role="alert" class="text-xs text-destructive"> </p>`),BV=D(`<button type="button" class="h-6 flex cursor-pointer items-center justify-center rounded-md bg-(--swatch) ring-1 ring-border outline-none ring-inset focus-visible:ring-3 focus-visible:ring-ring disabled:cursor-not-allowed"><!></button>`),VV=D(`<div role="slider" class="color-area h-36 relative w-full cursor-crosshair touch-none rounded-md outline-none focus-visible:ring-3 focus-visible:ring-ring svelte-9colnt"><span class="color-thumb size-4 border-white pointer-events-none absolute -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-(--swatch) svelte-9colnt"></span></div> <input type="range" class="color-hue svelte-9colnt" min="0" max="360" step="1"/> <div class="gap-2 flex items-start"><div class="min-w-0 flex-1"><!></div> <!></div> <!> <div role="group" class="gap-1.5 grid grid-cols-6"></div>`,1),HV=D(`<!> <!>`,1);function UV(e,n){V(n,!0);let r=J(n,`value`,3,`#000000`),i=J(n,`disabled`,3,!1),o=[`#000000`,`#ffffff`,`#9ca3af`,`#ef4444`,`#f97316`,`#eab308`,`#22c55e`,`#14b8a6`,`#3b82f6`,`#8b5cf6`,`#ec4899`,`#78350f`],s=globalThis.EyeDropper,l=at(),d=T(()=>l.messages),p=e=>NV(OV(e)??`#000000`),h=Z(re(Y(()=>p(r())))),g=Z(``),_=Z(!1),v=Z(null),y=T(()=>PV(C(h))),x=T(()=>PV({h:C(h).h,s:1,v:1}));le(()=>{let e=OV(r())??`#000000`;e!==Y(()=>C(y))&&P(h,p(e),!0)}),le(()=>{P(g,C(y),!0),P(_,!1)});function S(){w.cancel(),C(y)!==OV(r())&&n.onChange(C(y))}let w=EV(S,150),D=e=>Math.min(1,Math.max(0,e));function k(e){if(!C(v))return;let t=C(v).getBoundingClientRect();P(h,{h:C(h).h,s:D((e.clientX-t.left)/t.width),v:D(1-(e.clientY-t.top)/t.height)},!0)}function A(e){i()||e.button!==0||(e.preventDefault(),C(v)?.focus(),C(v)?.setPointerCapture(e.pointerId),k(e))}function M(e){C(v)?.hasPointerCapture(e.pointerId)&&k(e)}function I(e){C(v)?.hasPointerCapture(e.pointerId)&&(C(v).releasePointerCapture(e.pointerId),S())}function ee(e){let t=e.shiftKey?.1:.01,{s:n,v:r}=C(h);switch(e.key){case`ArrowLeft`:n-=t;break;case`ArrowRight`:n+=t;break;case`ArrowUp`:r+=t;break;case`ArrowDown`:r-=t;break;case`PageUp`:r+=.1;break;case`PageDown`:r-=.1;break;default:return}e.preventDefault(),P(h,{h:C(h).h,s:D(n),v:D(r)},!0),w()}function te(e){P(h,{...C(h),h:Number(e.currentTarget.value)},!0)}function R(e){P(h,p(e),!0),S()}function ie(){let e=OV(C(g));e?(P(_,!1),R(e),P(g,e,!0)):P(_,!0)}function ae(e){e.key===`Enter`&&(e.preventDefault(),ie())}function W(){OV(C(g))?ie():(P(g,C(y),!0),P(_,!1))}async function oe(){if(s)try{let{sRGBHex:e}=await new s().open();R(e)}catch{}}let ce=e=>(IV(e,`#000000`)??0)>(IV(e,`#ffffff`)??0)?`text-black`:`text-white`;var q=u(),ue=B(q);E(ue,()=>Pt,(e,r)=>{r(e,{children:(e,r)=>{var l=HV(),u=B(l);{let e=(e,t)=>{let r=()=>(t?.()).props;var a=LV();z(a,e=>({...r(),type:`button`,id:n.inputId,disabled:i(),"aria-label":e,class:`h-9 gap-2.5 px-2.5 shadow-xs max-w-48 flex w-full cursor-pointer items-center rounded-md border border-input bg-background text-left outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`}),[()=>nt(C(d).colorPick,{color:C(y)})],void 0,void 0,`svelte-9colnt`);var o=L(a);let s;var l=U(o,2),u=K(l,!0);c(a),G(()=>{s=N(o,``,s,{"--swatch":C(y)}),m(u,C(y))}),O(e,a)};E(u,()=>jt,(t,n)=>{n(t,{child:e,$$slots:{child:!0}})})}var p=U(u,2);E(p,()=>At,(e,r)=>{r(e,{align:`start`,children:(e,r)=>{var l=VV(),u=B(l);H(u,`aria-valuemin`,0),H(u,`aria-valuemax`,100);let p;var b=L(u);let w;c(u),F(u,e=>P(v,e),()=>C(v));var E=U(u,2);se(E);var D=U(E,2),k=L(D),z=L(k);{let e=T(()=>C(_)?`${n.inputId}-hex-error`:void 0);xn(z,{type:`text`,get"aria-label"(){return C(d).colorHex},get"aria-invalid"(){return C(_)},get"aria-describedby"(){return C(e)},autocomplete:`off`,spellcheck:!1,maxlength:7,get disabled(){return i()},onkeydown:ae,onblur:W,get value(){return C(g)},set value(e){P(g,e,!0)}})}c(k);var re=U(k,2),ie=e=>{var t=RV();kr(L(t),{class:`size-4`,"aria-hidden":`true`}),c(t),G(()=>{t.disabled=i(),H(t,`aria-label`,C(d).colorEyedropper),H(t,`title`,C(d).colorEyedropper)}),f(`click`,t,oe),O(e,t)};t(re,e=>{s&&e(ie)}),c(D);var V=U(D,2),q=e=>{var t=zV(),r=K(t,!0);G(()=>{H(t,`id`,`${n.inputId??``}-hex-error`),m(r,C(d).colorHexInvalid)}),O(e,t)};t(V,e=>{C(_)&&e(q)});var le=U(V,2);a(le,20,()=>o,e=>e,(e,n)=>{let r=T(()=>n===C(y));var a=BV();let o;var s=L(a),l=e=>{{let t=T(()=>ce(n));ot(e,{get class(){return`size-3.5 ${C(t)??``}`},"aria-hidden":`true`})}};t(s,e=>{C(r)&&e(l)}),c(a),G(()=>{a.disabled=i(),H(a,`aria-label`,n),H(a,`aria-pressed`,C(r)),o=N(a,``,o,{"--swatch":n})}),f(`click`,a,()=>R(n)),O(e,a)}),c(le),G((e,t,n)=>{H(u,`tabindex`,i()?-1:0),H(u,`aria-label`,C(d).colorArea),H(u,`aria-valuenow`,e),H(u,`aria-valuetext`,t),H(u,`aria-disabled`,i()),p=N(u,``,p,{"--hue":C(x)}),w=N(b,``,w,{"--x":`${C(h).s*100}%`,"--y":`${(1-C(h).v)*100}%`,"--swatch":C(y)}),H(E,`aria-label`,C(d).colorHue),ne(E,n),E.disabled=i(),H(le,`aria-label`,C(d).colorPresets)},[()=>Math.round(C(h).v*100),()=>nt(C(d).colorAreaValue,{s:Math.round(C(h).s*100),v:Math.round(C(h).v*100)}),()=>Math.round(C(h).h)]),f(`pointerdown`,u,A),f(`pointermove`,u,M),f(`pointerup`,u,I),j(`pointercancel`,u,I),f(`keydown`,u,ee),f(`input`,E,te),f(`change`,E,S),O(e,l)},$$slots:{default:!0}})}),O(e,l)},$$slots:{default:!0}})}),O(e,q),b()}ce([`pointerdown`,`pointermove`,`pointerup`,`keydown`,`input`,`change`,`click`]);var WV=D(`<span class="gap-2 min-w-0 flex items-center"><!> <span class="truncate"> </span></span>`),GV=D(`<!> `,1),KV=D(`<!> <!>`,1);function qV(e,n){V(n,!0);let r=J(n,`value`,7),i=J(n,`disabled`,3,!1),o=at(),s=T(()=>n.config?.options||{}),l=T(()=>r()||``),d=T(()=>Object.entries(C(s)).find(([e,t])=>t===C(l))?.[0]??C(l)),f=e=>yV(n.config?.optionMedia?.[e],n.assets),p=T(()=>f(C(d)));var h=u(),g=B(h);E(g,()=>on,(e,h)=>{h(e,{type:`single`,get value(){return C(l)},onValueChange:e=>{e&&(r(e),n.onChange(e))},get disabled(){return i()},children:(e,r)=>{var l=KV(),h=B(l);E(h,()=>rn,(e,r)=>{r(e,{get id(){return n.inputId},class:`w-full`,get disabled(){return i()},children:(e,n)=>{var r=WV(),i=L(r),a=e=>{SV(e,{get glyph(){return C(p)}})};t(i,e=>{C(p)&&e(a)});var s=U(i,2),l=K(s,!0);c(r),G(()=>m(l,C(d)||o.messages.selectOption)),O(e,r)},$$slots:{default:!0}})});var g=U(h,2);E(g,()=>an,(e,n)=>{n(e,{children:(e,n)=>{var r=u(),i=B(r);a(i,17,()=>Object.entries(C(s)),([e,t])=>e,(e,n)=>{var r=T(()=>w(C(n),2));let i=()=>C(r)[0],a=()=>C(r)[1],o=T(()=>f(i()));var s=u(),c=B(s);{let e=T(()=>a()??i());E(c,()=>nn,(n,r)=>{r(n,{get value(){return C(e)},get label(){return i()},children:(e,n)=>{var r=GV(),a=B(r),s=e=>{SV(e,{get glyph(){return C(o)}})};t(a,e=>{C(o)&&e(s)});var c=U(a);G(()=>m(c,` ${i()??``}`)),O(e,r)},$$slots:{default:!0}})})}O(e,s)}),O(e,r)},$$slots:{default:!0}})}),O(e,l)},$$slots:{default:!0}})}),O(e,h),b()}function JV(e,t){return e===`.webp`&&t.includes(`.png`)}function YV(e,t){let n=e.toLowerCase();return t.length===0||t.includes(n)?!0:JV(n,t)}var XV=(e,t,n)=>String.fromCharCode(...e.subarray(t,n));async function ZV(e){if(e.type===`image/webp`)return!0;let t=new Uint8Array(await e.slice(0,12).arrayBuffer());return t.length===12&&XV(t,0,4)===`RIFF`&&XV(t,8,12)===`WEBP`}async function QV(e){let t=await createImageBitmap(e);try{let e=document.createElement(`canvas`);e.width=t.width,e.height=t.height;let n=e.getContext(`2d`);if(!n)throw Error(`Canvas 2D context unavailable`);return n.drawImage(t,0,0),await new Promise((t,n)=>e.toBlob(e=>e?t(e):n(Error(`PNG encoding failed`)),`image/png`))}finally{t.close()}}var $V=D(`<button type="button"> </button>`),eH=D(`<div class="p-0.5 text-xs flex rounded-md bg-muted"></div>`),tH=D(`<!> `,1),nH=D(`<div class="gap-1.5 text-xs flex items-center text-success"><!> </div>`),rH=D(`<p class="text-xs leading-snug pl-5 text-muted-foreground"> </p>`),iH=D(`<div class="p-2.5 gap-1.5 flex flex-col rounded-md border border-destructive/40 bg-destructive/5"><div class="gap-1.5 flex items-start"><!> <p class="text-xs leading-snug text-destructive"> </p></div> <!></div>`),aH=D(`<p class="text-xs text-muted-foreground"> </p>`),oH=D(`<div class="gap-2 flex flex-col"><!> <div class="gap-2 flex"><!> <!></div> <!> <!> <!></div>`),sH=D(`<div class="gap-2 flex flex-col"><!> <!></div>`),cH=D(`<div class="gap-2.5 flex w-full flex-col"><!> <!></div>`);function lH(e,n){V(n,!0);let r=J(n,`value`,15),i=J(n,`acceptedFormats`,19,()=>[]),o=J(n,`defaultInputMode`,3,`upload`),s=at(),l=T(()=>s.messages),u=T(()=>n.allowedInputModes&&n.allowedInputModes.length>0?n.allowedInputModes:[`upload`,`url`]),d=T(()=>C(u).length>1),h=Z(`upload`);le(()=>{let e=o()??`upload`;P(h,C(u).includes(e)?e:C(u)[0],!0)});let g=Z(``),_=Z(``),v=Z(!1),y=Z(!1),x=Z(null),w=Z(``);le(()=>{if(r())try{let e=typeof r()==`string`?JSON.parse(r()):r();if(e.type===`base64`){if(e._isMetadata&&e._fileSize){let t=(e._fileSize/1024/1024).toFixed(2);P(g,nt(C(l).uploadedFileSize,{ext:e.fileEnding,size:t}),!0)}else P(g,nt(C(l).uploadedFile,{ext:e.fileEnding}),!0)}else e.type===`url`&&P(_,e.file,!0)}catch{}});function E(e){return nt(C(l).fileFormatNotAccepted,{ext:e,formats:i().join(`, `)})}function D(e){return nt(C(l).fileTooLarge,{size:(e/1024/1024).toFixed(2),max:rl.FILE_UPLOAD.MAX_SIZE_MB})}function k(e){let t=e.split(`?`)[0];return(t.includes(`.`)?`.`+t.split(`.`).pop():`.tmp`).toLowerCase()}async function A(e,t){return e.size>rl.FILE_UPLOAD.MAX_SIZE_BYTES||!JV(t,i())?{blob:e,fileEnding:t}:{blob:await QV(e),fileEnding:`.png`}}function j(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{let n=e.target?.result;t(n.includes(`,`)?n.split(`,`)[1]:n)},r.onerror=()=>n(Error(C(l).fileReadFailed)),r.readAsDataURL(e)})}function M(e){return e instanceof TypeError&&e.message===`Failed to fetch`}async function N(){if(C(_).trim()){P(y,!0),P(x,null),P(w,``),P(g,``);try{let e;try{e=new URL(C(_))}catch{P(x,{message:C(l).urlInvalid,isCors:!1},!0);return}if(e.protocol!==`https:`&&e.protocol!==`http:`){P(x,{message:C(l).urlProtocolUnsupported,isCors:!1},!0);return}let t=await fetch(C(_));if(!t.ok){P(x,{message:nt(C(l).urlServerError,{status:`${t.status} ${t.statusText}`.trim()}),isCors:!1},!0);return}let a=await t.blob(),o=await ZV(a)?`.webp`:k(C(_));if(!YV(o,i())){P(x,{message:E(o),isCors:!1},!0);return}let{blob:s,fileEnding:c}=await A(a,o),u=rl.FILE_UPLOAD.MAX_SIZE_BYTES;if(s.size>u){P(x,{message:`${D(s.size)} ${C(l).fileTooLargeUseUpload}`,isCors:!1},!0);return}let d=await j(s),f=JSON.stringify({file:d,type:`base64`,fileEnding:c});r(f),P(w,nt(C(l).fileLoaded,{ext:c,size:(s.size/1024).toFixed(0)}),!0),n.onChange(f)}catch(e){if(M(e)){let e=(()=>{try{return new URL(C(_)).hostname}catch{return``}})(),t=C(l).urlUnreachableHint;e.includes(`sharepoint.com`)||e.includes(`onedrive.com`)?t=C(l).urlHintSharePoint:e.includes(`drive.google.com`)?t=C(l).urlHintGoogleDrive:e.includes(`dropbox.com`)&&(t=C(l).urlHintDropbox),P(x,{message:nt(C(l).urlUnreachable,{host:e}),isCors:!0,hint:t},!0)}else P(x,{message:e instanceof Error?e.message:C(l).unknownError,isCors:!1},!0)}finally{P(y,!1)}}}async function F(e){let t=k(e.name);if(!YV(t,i()))Cn.error(E(t));else try{let{blob:i,fileEnding:a}=await A(e,t);if(i.size>rl.FILE_UPLOAD.MAX_SIZE_BYTES){Cn.error(D(i.size));return}P(g,e.name,!0);let o=JSON.stringify({file:await j(i),type:`base64`,fileEnding:a});r(o),n.onChange(o)}catch(e){Cn.error(e instanceof Error?e.message:C(l).fileReadFailed)}}async function I(){let e=await gF({accept:C(z)});e&&F(e)}function ee(e){e.preventDefault(),P(v,!0)}function te(){P(v,!1)}function R(e){e.preventDefault(),P(v,!1);let t=e.dataTransfer?.files?.[0];t&&F(t)}let z=T(()=>i().length>0?i().join(`,`):`*`);var ne=cH(),re=L(ne),ie=e=>{var t=eH();a(t,20,()=>C(u),e=>e,(e,t)=>{var n=$V(),r=K(n,!0);G(()=>{H(n,`aria-pressed`,C(h)===t),fe(n,1,`px-3 py-1 font-medium flex-1 rounded-sm border transition-colors ${C(h)===t?`shadow-xs border-border-strong bg-raised text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`),m(r,t===`upload`?C(l).fileModeUpload:C(l).fileModeUrl)}),f(`click`,n,()=>P(h,t,!0)),O(e,n)}),c(t),O(e,t)};t(re,e=>{C(d)&&e(ie)});var ae=U(re,2),W=e=>{var n=oH(),r=L(n);mn(r,{for:`url-input`,children:(e,t)=>{var n=tH(),r=B(n);dr(r,{size:16});var i=U(r);G(()=>m(i,` ${C(l).fileUrlLabel??``}`)),O(e,n)},$$slots:{default:!0}});var i=U(r,2),a=L(i);{let e=T(()=>C(x)?!0:void 0);xn(a,{id:`url-input`,type:`url`,placeholder:`https://example.com/model.3dm`,get disabled(){return C(y)},get"aria-invalid"(){return C(e)},oninput:()=>{P(x,null),P(w,``)},get value(){return C(_)},set value(e){P(_,e,!0)}})}var o=U(a,2);{let e=T(()=>C(y)||!C(_).trim());tt(o,{type:`button`,variant:`outline`,get disabled(){return C(e)},onclick:N,children:(e,t)=>{S();var n=p();G(()=>m(n,C(y)?C(l).fetchingFile:C(l).fetchFile)),O(e,n)},$$slots:{default:!0}})}c(i);var s=U(i,2),u=e=>{var t=nH(),n=L(t);ft(n,{size:13});var r=U(n);c(t),G(()=>m(r,` ${C(w)??``}`)),O(e,t)};t(s,e=>{C(w)&&e(u)});var d=U(s,2),f=e=>{var n=iH(),r=L(n),i=L(r);pt(i,{size:13,class:`mt-0.5 shrink-0 text-destructive`});var a=U(i,2),o=K(a,!0);c(r);var s=U(r,2),l=e=>{var t=rH(),n=K(t,!0);G(()=>m(n,C(x).hint)),O(e,t)};t(s,e=>{C(x).isCors&&C(x).hint&&e(l)}),c(n),G(()=>m(o,C(x).message)),O(e,n)};t(d,e=>{C(x)&&e(f)});var h=U(d,2),g=e=>{var t=aH(),n=K(t,!0);G(()=>m(n,C(l).fileUrlPublic)),O(e,t)};t(h,e=>{!C(x)&&!C(w)&&e(g)}),c(n),O(e,n)},oe=e=>{var n=sH(),r=L(n);{let e=T(()=>C(v)?`secondary`:`outline`);tt(r,{type:`button`,get variant(){return C(e)},class:`w-full`,onclick:I,ondragover:ee,ondragleave:te,ondrop:R,children:(e,t)=>{var n=tH(),r=B(n);Ct(r,{size:16});var i=U(r);G(()=>m(i,` ${(C(g)||C(l).chooseFile)??``}`)),O(e,n)},$$slots:{default:!0}})}var a=U(r,2),o=e=>{var t=aH(),n=K(t,!0);G(e=>m(n,e),[()=>nt(C(l).acceptedFormats,{formats:i().join(`, `)})]),O(e,t)};t(a,e=>{i().length>0&&e(o)}),c(n),O(e,n)};t(ae,e=>{C(h)===`url`?e(W):e(oe,-1)}),c(ne),O(e,ne),b()}ce([`click`]);var uH=D(`<span class="text-sm min-w-0 text-muted-foreground" role="status"> </span>`),dH=D(`<!> <!>`,1),fH=D(`<output class="text-sm min-w-0 text-muted-foreground"> </output>`),pH=D(`<div class="gap-2 min-w-0 flex flex-wrap items-center"><!> <!></div>`);function mH(e,n){V(n,!0);let r=J(n,`disabled`,3,!1),a=at(),o=T(()=>a.messages),s=[`geometryPickAnyOne`,`geometryPickAnyOther`],l={point:[`geometryPickPointOne`,`geometryPickPointOther`],pointCloud:[`geometryPickPointCloudOne`,`geometryPickPointCloudOther`],curve:[`geometryPickCurveOne`,`geometryPickCurveOther`],line:[`geometryPickLineOne`,`geometryPickLineOther`],plane:[`geometryPickPlaneOne`,`geometryPickPlaneOther`],surface:[`geometryPickSurfaceOne`,`geometryPickSurfaceOther`],polysurface:[`geometryPickPolysurfaceOne`,`geometryPickPolysurfaceOther`],extrusion:[`geometryPickExtrusionOne`,`geometryPickExtrusionOther`],mesh:[`geometryPickMeshOne`,`geometryPickMeshOther`],subd:[`geometryPickSubdOne`,`geometryPickSubdOther`],block:[`geometryPickBlockOne`,`geometryPickBlockOther`]},u=T(()=>{let[e,t]=n.kinds?.length===1?l[n.kinds[0]]:s;return C(o)[n.atMost===1?e:t]}),d=Z(!1),f=Z(void 0),h=T(()=>C(f)===void 0?n.summary??null:C(f));le(()=>n.watchSummary?.(e=>{P(f,e,!0)}));async function g(e){P(d,!0);try{let t=await e();t.outcome===`picked`?P(f,t.summary,!0):t.outcome===`failed`&&n.onError?.(t.error)}finally{P(d,!1)}}let _=T(()=>n.onPick?`span`:`output`);function v(e){P(f,null),e()}var y=pH(),x=L(y),w=e=>{{let t=T(()=>r()||C(d));tt(e,{get id(){return n.inputId},variant:`outline`,size:`sm`,onclick:()=>g(n.onPick),get disabled(){return C(t)},children:(e,t)=>{S();var n=p();G(()=>m(n,C(h)?C(o).geometryPickAgain:C(u))),O(e,n)},$$slots:{default:!0}})}};t(x,e=>{n.onPick&&e(w)});var E=U(x,2),D=e=>{var t=uH(),n=K(t,!0);G(()=>m(n,C(o).geometryPicking)),O(e,t)},k=e=>{var a=dH(),s=B(a);i(s,()=>C(_),!1,(e,t)=>{z(e,()=>({id:n.onPick?void 0:n.inputId,class:`text-sm min-w-0 truncate text-foreground`}));var r=p();G(()=>m(r,C(h))),O(t,r)});var c=U(s,2),l=e=>{tt(e,{variant:`ghost`,size:`sm`,onclick:()=>v(n.onClear),get disabled(){return r()},children:(e,t)=>{S();var n=p();G(()=>m(n,C(o).geometryClear)),O(e,n)},$$slots:{default:!0}})};t(c,e=>{n.onClear&&e(l)}),O(e,a)},A=e=>{var t=fH(),r=K(t,!0);G(()=>{H(t,`id`,n.inputId),m(r,C(o).geometryPickInPanel)}),O(e,t)};t(E,e=>{C(d)?e(D):C(h)?e(k,1):n.onPick||e(A,2)}),c(y),O(e,y),b()}var hH=D(`<span class="pr-2.5 text-sm shrink-0 text-muted-foreground"> </span>`),gH=D(`<!> <!> <!> <div class="px-3.5 min-w-0 flex flex-1 items-center"><!></div>`,1),_H=D(`<div class="relative"><!> <span class="right-3 text-sm inset-y-0 pointer-events-none absolute flex items-center text-muted-foreground"> </span></div>`),vH=D(`<!> <!>`,1);function yH(e,n){V(n,!0);let r=(e,t=h)=>{{let r=T(()=>C(v)?C(y):void 0),o=T(()=>n.config?.minimum),s=T(()=>n.config?.maximum),c=T(()=>n.config?.placeholder),u=T(()=>C(l)?!0:void 0),d=T(()=>C(l)?!0:void 0);xn(e,{get id(){return n.inputId},type:`number`,get class(){return t()},get"aria-describedby"(){return C(r)},get value(){return C(_)},get min(){return C(o)},get max(){return C(s)},get step(){return C(g)},get placeholder(){return C(c)},get"data-invalid"(){return C(u)},get"aria-invalid"(){return C(d)},get disabled(){return a()},oninput:()=>P(l,null),onchange:e=>{let t=parseFloat(e.currentTarget.value);isNaN(t)||k(t)},onblur:e=>{let t=parseFloat(e.currentTarget.value);if(!isNaN(t)){let e=D(t);P(l,e,!0),e||(i(t),x.cancel(),n.onChange(t))}}})}},i=J(n,`value`,15),a=J(n,`disabled`,3,!1),o=at(),s=T(()=>o.messages),l=Z(null),d=T(()=>n.config?.minimum??0),f=T(()=>n.config?.maximum??100),g=T(()=>n.config?.stepSize??1),_=T(()=>typeof i()==`number`?i():C(d)),v=T(()=>n.config?.unit?.trim()||void 0),y=T(()=>`${n.inputId}-unit`),x=EV(e=>n.onChange(e),400),w=EV(e=>n.onChange(e),150);function D(e){return n.config?.minimum!==void 0&&e<n.config.minimum?nt(C(s).minValue,{min:n.config.minimum}):n.config?.maximum!==void 0&&e>n.config.maximum?nt(C(s).maxValue,{max:n.config.maximum}):null}function k(e){let t=D(e);P(l,t,!0),t||(i(e),x(e))}let A=1e3,M=T(()=>(C(f)-C(d))/C(g)),F=T(()=>C(g)>0&&Number.isFinite(C(M))&&C(M)>A),I=T(()=>C(F)?0:C(d)),ee=T(()=>C(F)?A:C(f)),te=T(()=>(String(C(g)).split(`.`)[1]??``).length),R=!1,z=!1,ne=null,re=null;function ie(e){let t=Math.min(C(f),Math.max(C(d),e));if(!(C(g)>0))return t;let n=C(d)+Math.round((t-C(d))/C(g))*C(g);return Math.min(C(f),Number(n.toFixed(C(te))))}function ae(e){return C(F)?Math.round((e-C(d))/(C(f)-C(d))*A):e}function W(e){return e/(C(ee)-C(I))*(C(f)-C(d))}function oe(e){if(C(f)<=C(d))return;let t;R&&z?(re??={track:ne??e,value:C(_)},t=ie(re.value+W(e-re.track)/10)):(re=null,t=ie(C(d)+W(e-C(I)))),ne=e,i(t),w(t)}function se(e){R=!0,z=e.shiftKey,ne=null,re=null}function ce(e){e.key===`Shift`&&(z=e.type===`keydown`)}let q=T(()=>Math.max(0,-Math.floor(Math.log10(C(g)))));function le(e){let t=parseFloat(e.value);if(isNaN(t)){e.value=C(_).toFixed(C(q));return}let r=Math.min(C(f),Math.max(C(d),t));e.value=r.toFixed(C(q)),r!==i()&&(i(r),n.onChange(r))}var Y=vH();j(`keydown`,de,ce),j(`keyup`,de,ce),j(`pointerup`,de,()=>R=!1),j(`blur`,de,()=>z=R=!1);var ue=B(Y),fe=e=>{var r=u(),i=B(r);E(i,()=>Ft,(e,r)=>{r(e,{children:(e,r)=>{var i=gH(),o=B(i);{let e=T(()=>C(_).toFixed(C(q))),t=T(()=>C(v)?C(y):void 0);E(o,()=>Mt,(r,i)=>{i(r,{get id(){return n.inputId},type:`number`,class:`w-18 flex-none`,get value(){return C(e)},get min(){return C(d)},get max(){return C(f)},get step(){return C(g)},get disabled(){return a()},onchange:e=>le(e.currentTarget),onkeydown:e=>{e.key===`Enter`&&e.currentTarget.blur()},get"aria-describedby"(){return C(t)}})})}var l=U(o,2),u=e=>{var t=hH(),n=K(t,!0);G(()=>{H(t,`id`,C(y)),m(n,C(v))}),O(e,t)};t(l,e=>{C(v)&&e(u)});var p=U(l,2);ht(p,{orientation:`vertical`});var h=U(p,2),b=L(h),x=()=>ae(C(_)),S=oe;{let e=T(()=>C(F)?1:C(g));Eo(b,{type:`single`,get value(){return x()},set value(e){S(e)},get min(){return C(I)},get max(){return C(ee)},get step(){return C(e)},get title(){return C(s).fineDragHint},get thumbLabelledby(){return n.labelId},get disabled(){return a()}})}c(h),j(`pointerdown`,h,se,!0),O(e,i)},$$slots:{default:!0}})}),O(e,r)},X=e=>{var t=_H();let n;var i=L(t);r(i,()=>`pr-[calc(var(--unit-len)*1ch+1.5rem)]`);var a=U(i,2),o=K(a,!0);c(t),G(()=>{n=N(t,``,n,{"--unit-len":C(v).length}),H(a,`id`,C(y)),m(o,C(v))}),O(e,t)},pe=e=>{r(e)};t(ue,e=>{n.config?.renderAsSlider?e(fe):C(v)?e(X,1):e(pe,-1)});var me=U(ue,2),he=e=>{var t=u(),n=B(t);E(n,()=>uV,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(l))),O(e,n)},$$slots:{default:!0}})}),O(e,t)};t(me,e=>{C(l)&&e(he)}),O(e,Y),b()}var bH=D(`<!> <span class="max-w-full truncate"> </span>`,1);function xH(e,n){V(n,!0);let r=J(n,`disabled`,3,!1),i=T(()=>Object.entries(n.config.options??{})),o=T(()=>C(i).some(([e])=>yV(n.config.optionMedia?.[e],n.assets)));var s=u(),c=B(s);{let e=T(()=>C(o)?`stacked`:`default`),s=T(()=>n.value??``);E(c,()=>yn,(o,c)=>{c(o,{type:`single`,variant:`outline`,spacing:0,get size(){return C(e)},class:`w-full`,get"aria-labelledby"(){return n.labelId},get value(){return C(s)},onValueChange:e=>{e&&n.onChange(e)},get disabled(){return r()},children:(e,r)=>{var o=u(),s=B(o);a(s,17,()=>C(i),([e,t])=>e,(e,r)=>{var i=T(()=>w(C(r),2));let a=()=>C(i)[0],o=()=>C(i)[1],s=T(()=>yV(n.config.optionMedia?.[a()],n.assets));var c=u(),l=B(c);{let e=T(()=>o()??a());E(l,()=>bn,(n,r)=>{r(n,{get value(){return C(e)},class:`min-w-0 flex-1`,get title(){return a()},children:(e,n)=>{var r=bH(),i=B(r),o=e=>{SV(e,{get glyph(){return C(s)}})};t(i,e=>{C(s)&&e(o)});var c=U(i,2),l=K(c,!0);G(()=>m(l,a())),O(e,r)},$$slots:{default:!0}})})}O(e,c)}),O(e,o)},$$slots:{default:!0}})})}O(e,s),b()}var SH=e=>e.kind===`point`,CH=e=>e.kind!==`point`,wH=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],TH=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],EH=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],DH=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],OH=(e,t)=>Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2]);function kH(e){let t=Math.hypot(e[0],e[1],e[2]);return t>0?EH(e,1/t):null}function AH(e,t){let n=e-t,r=[];for(let e=0;e<=t;e++)r.push(0);for(let e=1;e<n;e++)r.push(e);for(let e=0;e<=t;e++)r.push(n);return r}function jH(e,t=3){let n=Math.max(1,Math.min(t,e.length-1));return{kind:`nurbs`,degree:n,points:[...e],knots:AH(e.length,n)}}function MH(e){let t={};return e.id!==void 0&&(t.id=e.id),e.path!==void 0&&(t.path=e.path),e.attributes!==void 0&&(t.attributes=e.attributes),t}function NH(e){return`{${(e??[0]).join(`;`)}}`}function PH(e){let t=/^\{(-?\d+(?:;-?\d+)*)?\}$/.exec(e.trim());return t?t[1]?t[1].split(`;`).map(Number):[]:null}function FH(e){let t=new Map;for(let n of e){let e=NH(n.path),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function IH(e){return e.kind===`point`?[e.at]:e.kind===`line`?[e.from,e.to]:e.points}function LH(e,t,n){if(e.kind===`point`)return{...e,at:n};if(e.kind===`line`)return t===0?{...e,from:n}:{...e,to:n};let r=e.points.slice();return r[t]=n,{...e,points:r}}function RH(e,t){if(e.kind===`point`||e.kind===`line`)return null;let n=e.points.filter((e,n)=>n!==t);return n.length<2?null:e.kind===`polyline`?{...e,points:n,closed:e.closed&&n.length>2}:{...MH(e),...jH(n,e.degree)}}function zH(e,t){return e.kind===`point`?{...e,at:t(e.at)}:e.kind===`line`?{...e,from:t(e.from),to:t(e.to)}:{...e,points:e.points.map(t)}}function BH(e,t){return t===1?e:zH(e,e=>EH(e,t))}function VH(e){return e.kind===`point`?e.at.every(Number.isFinite):HH(e)}function HH(e){let t=e=>e.every(Number.isFinite);if(e.kind===`line`)return t(e.from)&&t(e.to)&&OH(e.from,e.to)>0;if(!e.points.every(t))return!1;if(e.kind===`polyline`)return e.points.length>=(e.closed?3:2);let{degree:n,points:r,knots:i,weights:a}=e;if(n<1||r.length<n+1||i.length!==r.length+n+1||a&&(a.length!==r.length||a.some(e=>!(e>0))))return!1;for(let e=1;e<i.length;e++)if(!(i[e]>=i[e-1]))return!1;return i[r.length]>i[n]}function UH(e){let t=[];for(let n of e){if(n.kind===`point`)continue;if(n.kind===`line`){OH(n.from,n.to)>0&&t.push(n);continue}if(n.kind===`nurbs`&&n.degree!==1)continue;let{id:e,...r}=MH(n),i=(e,n)=>{OH(e,n)>0&&t.push({...r,kind:`line`,from:e,to:n})},{points:a}=n;for(let e=1;e<a.length;e++)i(a[e-1],a[e]);n.kind===`polyline`&&n.closed&&i(a[a.length-1],a[0])}return t}function WH(e){return[e.knots[e.degree],e.knots[e.points.length]]}function GH(e,t){let{knots:n,degree:r,points:i}=e,a=i.length-1;if(t>=n[a+1]){let e=a;for(;e>r&&n[e]===n[e+1];)e--;return e}let o=r,s=a+1;for(;s-o>1;){let e=o+s>>1;t<n[e]?s=e:o=e}return o}function KH(e,t){let{knots:n,degree:r,points:i,weights:a}=e,[o,s]=WH(e),c=Math.min(Math.max(t,o),s),l=GH(e,c),u=[];for(let e=0;e<=r;e++){let t=l-r+e,n=a?.[t]??1;u.push([i[t][0]*n,i[t][1]*n,i[t][2]*n,n])}for(let e=1;e<=r;e++)for(let t=r;t>=e;t--){let i=l-r+t,a=n[i+r-e+1]-n[i],o=a===0?0:(c-n[i])/a;for(let e=0;e<4;e++)u[t][e]=(1-o)*u[t-1][e]+o*u[t][e]}let[d,f,p,m]=u[r];return[d/m,f/m,p/m]}function qH(e,t=16){if(e.kind===`line`)return[e.from,e.to];if(e.kind===`polyline`)return e.closed?[...e.points,e.points[0]]:[...e.points];let{knots:n,degree:r,points:i}=e,a=r===1?1:t,o=[];for(let t=r;t<i.length;t++){let r=n[t],i=n[t+1];if(i>r)for(let t=0;t<a;t++)o.push(KH(e,r+(i-r)*t/a))}return o.push(KH(e,WH(e)[1])),o}function JH(e,t){return{from:e,middle:EH(wH(e,t),.5),weight:1,to:t}}function YH(e,t,n,r,i,a){let o=Math.max(1,Math.ceil(Math.abs(a)/(Math.PI/2)-1e-9)),s=a/o,c=Math.cos(s/2),l=(r,i)=>wH(e,wH(EH(t,i*Math.cos(r)),EH(n,i*Math.sin(r)))),u=[];for(let e=0;e<o;e++){let t=i+e*s;u.push({from:l(t,r),middle:l(t+s/2,r/c),weight:c,to:l(t+s,r)})}return u}function XH(e,t,n,r){let i=OH(e,t),a=kH(TH(t,e));if(n===0||!a||i===0)return[JH(e,t)];let o=DH(r,a),s=wH(EH(wH(e,t),.5),EH(o,i*(1-n*n)/(4*n))),c=i*(1+n*n)/(4*Math.abs(n)),l=kH(TH(e,s));if(!l)return[JH(e,t)];let u=YH(s,l,DH(r,l),c,0,4*Math.atan(n));return u[0]={...u[0],from:e},u[u.length-1]={...u[u.length-1],to:t},u}function ZH(e){let t=[e[0].from],n=[1],r=[0,0,0];return e.forEach((e,i)=>{t.push(e.middle,e.to),n.push(e.weight,1),r.push(i+1,i+1)}),r.push(e.length),{kind:`nurbs`,degree:2,points:t,knots:r,...n.some(e=>e!==1)?{weights:n}:{}}}function QH(e,t,n,r,i,a){return ZH(YH(e,t,n,r,i,a))}function $H(e){if(e.kind===`nurbs`||e.kind===`point`)return[];let t=qH(e),n=[];for(let e=1;e<t.length;e++)n.push({from:t[e-1],to:t[e],length:OH(t[e-1],t[e])});return n}function eU(e){let t=qH(e,48),n=0;for(let e=1;e<t.length;e++)n+=OH(t[e-1],t[e]);return n}function tU(e,t,n){if(e.kind===`nurbs`||e.kind===`point`||!(n>0)||!Number.isFinite(n))return e;if(e.kind===`line`){let t=kH(TH(e.to,e.from));return t?{...e,to:wH(e.from,EH(t,n))}:e}let{points:r}=e,i=r[t],a=t===r.length-1,o=a?r[0]:r[t+1];if(!i||!o||a&&!e.closed)return e;let s=kH(TH(o,i));if(!s)return e;let c=EH(s,n-OH(i,o));if(a){let n=r.slice();return n[t]=TH(i,c),{...e,points:n}}return{...e,points:r.map((e,n)=>n>t?wH(e,c):e)}}var nU=/^[0-9.,<-]$/;function rU(e){let[t,n,...r]=e.replaceAll(`,`,`.`).split(`<`);if(r.length>0)return null;let i={};if(t!==``){let e=Number(t);if(!(e>0)||!Number.isFinite(e))return null;i.length=e}if(n!==void 0&&n!==``){let e=Number(n);if(!Number.isFinite(e))return null;i.angle=e}return i.length===void 0&&i.angle===void 0?null:i}var iU=Math.PI/4;function aU(e,t){let{last:n,snapped:r,ortho:i,gridStep:a,typed:o}=t,s=e;if(!r&&a>0&&(s=[Math.round(s[0]/a)*a,Math.round(s[1]/a)*a,s[2]]),!r&&i&&n){let e=s[0]-n[0],t=s[1]-n[1],r=Math.round(Math.atan2(t,e)/iU)*iU,i=e*Math.cos(r)+t*Math.sin(r);s=[n[0]+Math.cos(r)*i,n[1]+Math.sin(r)*i,n[2]]}if(!o||!n)return s;if(o.angle!==void 0){let e=o.angle*Math.PI/180,t=o.length??Math.hypot(s[0]-n[0],s[1]-n[1]);return[n[0]+Math.cos(e)*t,n[1]+Math.sin(e)*t,n[2]]}let c=OH(n,s);if(o.length===void 0||c===0)return s;let l=o.length/c;return[n[0]+(s[0]-n[0])*l,n[1]+(s[1]-n[1])*l,n[2]+(s[2]-n[2])*l]}function oU(e,t=``){let n=Math.abs(e),r=n===0?0:Math.min(6,Math.max(0,2-Math.floor(Math.log10(n)))),i=e.toFixed(r);return t?`${i} ${t}`:i}var sU=1929202,cU=1010,lU=1011,uU=1012;function dU(e){let{viewer:t,metersPerUnit:n,colorOf:r}=e,i=`sketch:${e.id}`,a=new Lf(e.color??sU),o=!1,s=e=>new $(e[0]*n,e[1]*n,e[2]*n),c=e=>[e.x/n,e.y/n,e.z/n],l=new Af;l.name=e.name??`Sketch`,l.userData.id=i;let u=(e,t)=>(e.renderOrder=t,e.raycast=()=>{},e.frustumCulled=!1,e),d=(e,t)=>{let n=new fx({color:t?16777215:a,linewidth:2.5,transparent:e<1,opacity:e,vertexColors:t});return n.depthTest=!1,u(new jx(new dx,n),cU)},f=(e,t=1,n=lU)=>u(new $m(new Rp,new Jm({color:a,size:e,sizeAttenuation:!1,depthTest:!1,transparent:t<1,opacity:t})),n),p=d(1,r!==void 0),m=f(7),h=d(.65,!1),g=f(7),_=f(12,1,uU),v=f(7,.6,uU),y=e=>{l.add(e),l.parent||t.addUserGeometry(l,i)},b=e=>{e.removeFromParent(),l.children.length===0&&l.removeFromParent()},x=(e,t,n)=>{let r=[],i=[];t.forEach((e,t)=>{for(let a=1;a<e.length;a++){let o=s(e[a-1]),c=s(e[a]);r.push(o.x,o.y,o.z,c.x,c.y,c.z);let l=n?.[t];l&&i.push(l.r,l.g,l.b,l.r,l.g,l.b)}}),e.geometry.dispose(),e.geometry=new dx,r.length===0?b(e):(e.geometry.setPositions(r),n&&e.geometry.setColors(i),y(e))},S=(e,t)=>{e.geometry.dispose(),e.geometry=new Rp,t.length===0?b(e):(e.geometry.setAttribute(`position`,new Ep(t.flatMap(e=>s(e).toArray()),3)),y(e))},C=[],w=[],T=null,E=!1,D=()=>{C.forEach(e=>e.remove()),C=w.map(e=>{let n=t.labelLayer.addLabel(e.text,s(e.at)),{onEdit:r}=e;if(r){let t=n.object.element;t.style.pointerEvents=`auto`,t.style.cursor=`text`,t.addEventListener(`click`,n=>{n.stopPropagation(),E||O(t,e.editText??e.text,r)})}return n})},O=(e,n,r)=>{E=!0;let i=document.createElement(`input`);i.type=`text`,i.inputMode=`decimal`,i.value=n,Object.assign(i.style,{width:`${Math.max(5,n.length+2)}ch`,font:`inherit`,color:`#111`,background:`#fff`,border:`0`,borderRadius:`2px`,padding:`0 2px`,textAlign:`center`}),e.textContent=``,e.appendChild(i),i.focus(),i.select();let a=e=>{E&&(E=!1,e&&r(i.value),D(),t.invalidate())};i.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`?a(!0):e.key===`Escape`&&a(!1)}),i.addEventListener(`blur`,()=>a(!1))};return{setCurves:(e,n=[])=>{o||(x(p,e.map(e=>qH(e)),r&&e.map(e=>new Lf(r(e)??a))),S(m,n),t.invalidate())},setPreview:e=>{o||(x(h,e?.polylines??[]),S(g,e?.points??[]),t.invalidate())},setCursor:e=>{o||(S(_,e?.snapped?[e.point]:[]),S(v,e&&!e.snapped?[e.point]:[]),t.invalidate())},setLabels:e=>{o||(w=e,E||D())},setPreviewLabel:e=>{o||(e?T?(T.setText(e.text),T.setPosition(s(e.at))):T=t.labelLayer.addLabel(e.text,s(e.at)):(T?.remove(),T=null))},toScene:s,fromScene:c,dispose:()=>{if(!o){o=!0,C.forEach(e=>e.remove()),T?.remove();for(let e of[p,m,h,g,_,v])e.removeFromParent(),e.geometry.dispose(),e.material.dispose();t.removeUserGeometry(l)}}}}var fU=12;function pU(e){let{viewer:t,metersPerUnit:n}=e,r=e.snapPixels??fU,i=t.renderer.domElement,a=new Yg,o=new Kp(new $(0,0,1),0),s=e=>new $(e[0]*n,e[1]*n,e[2]*n),c=e=>[e.x/n,e.y/n,e.z/n],l=(e,t,n)=>{let r=e.clone().project(t);return{x:(r.x+1)/2*n.width,y:(1-r.y)/2*n.height,visible:r.z>-1&&r.z<1}},u=(e,t)=>({x:e.clientX-t.left,y:e.clientY-t.top}),d=(e,n)=>{let a=t.cameraController.getActiveCamera(),o=i.getBoundingClientRect(),c=u(e,o),d=-1,f=r;return n.forEach((e,t)=>{let n=l(s(e),a,o),r=Math.hypot(n.x-c.x,n.y-c.y);n.visible&&r<f&&(f=r,d=t)}),d},f=(e,t,n)=>{let r=n.x-t.x,i=n.y-t.y,a=r*r+i*i,o=a===0?0:Math.min(1,Math.max(0,((e.x-t.x)*r+(e.y-t.y)*i)/a));return Math.hypot(e.x-(t.x+o*r),e.y-(t.y+o*i))},p=(e,n)=>{let a=t.cameraController.getActiveCamera(),o=i.getBoundingClientRect(),c=u(e,o),d=-1,p=r;return n.forEach((e,t)=>{let n=qH(e).map(e=>l(s(e),a,o));for(let e=1;e<n.length;e++){if(!n[e-1].visible||!n[e].visible)continue;let r=f(c,n[e-1],n[e]);r<p&&(p=r,d=t)}}),d},m=(e,n,o)=>{let s=i.getBoundingClientRect(),d=u(e,s),f=bO(n,t.controls.target)*2;a.params.Line.threshold=f,a.params.Points.threshold=f,a.params.Line2={threshold:r/2};for(let e of lO(t.scene,a)){let t=e.pointOnLine??e.point,i=e.object.isMesh&&e.face!=null;if(!i){let e=l(t,n,s);if(Math.hypot(e.x-d.x,e.y-d.y)>r)continue}let a=TO(e,n,{width:s.width,height:s.height},r);return!i||!a.equals(t)?{point:c(a),snapped:!0}:o?null:{point:c(t),snapped:!1}}return null};return{pick:(e,n={})=>{let{snapTo:r=[],last:s=null,planar:l=!0,gridStep:u=0,typed:f=null}=n,p=t.cameraController.getActiveCamera(),h=zO(e,i);a.setFromCamera(new Q(h.x,h.y),p);let g=d(e,r),_=g>=0?{point:r[g],snapped:!0}:m(e,p,l);if(!_){let e=a.ray.intersectPlane(o,new $);if(!e)return null;_={point:c(e),snapped:!1}}return l&&(_={..._,point:[_.point[0],_.point[1],0]}),{snapped:_.snapped,point:aU(_.point,{last:s,snapped:_.snapped,ortho:n.ortho??e.shiftKey,gridStep:u,typed:f})}},nearestPoint:d,nearestCurve:p}}var mU={point:{id:`point`,pointCount:1,build:e=>e.length>=1?[{kind:`point`,at:e[0]}]:null},line:{id:`line`,pointCount:2,build:e=>e.length>=2?[{kind:`line`,from:e[0],to:e[1]}]:null},polyline:{id:`polyline`,closable:!0,build:(e,t)=>e.length>=2?[{kind:`polyline`,points:[...e],closed:t&&e.length>2}]:null},nurbs:{id:`nurbs`,closable:!0,build:(e,t)=>e.length>=2?[jH(t?[...e,e[0]]:e)]:null}},hU=`move`,gU=150;function _U(e){let{viewer:t,unitSuffix:n=``}=e,r=`sketch:${e.id}`,i=Math.max(1,e.maxItems??1/0),a=t.renderer.domElement,o={gridStep:0,planar:!0,showDimensions:!0,...e.settings},s=dU(e),c=pU(e),l=[],u=[],d=[],f=null,p=null,m=[],h=``,g=null,_=null,v=!1,y=0,b=()=>({mode:p,pendingPoints:m.length,typed:h,canUndo:u.length>0,canRedo:d.length>0}),x=()=>e.onStateChange?.(b()),S=t=>{u=[...u,l].slice(-100),d=[],l=t,e.onChange?.(l)},C=(t,n)=>{let r=t[t.length-1];if(!r)return[t,n];let i=[t.slice(0,-1),[...n,l]];return l=r,_=null,e.onChange?.(l),i},w=()=>{[u,d]=C(u,d),N()},T=()=>{[d,u]=C(d,u),N()},E=e=>e.id===void 0?{...e,id:globalThis.crypto?.randomUUID?.()??`${r}:${++y}`}:e,D=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2,(e[2]+t[2])/2],O=()=>m[m.length-1]??null,k=()=>{let e=_;if(!e||!g)return l;let t=LH(e.original,e.vertex,g.point);return l.map((n,r)=>r===e.item?t:n)},A=(e,t,n)=>{let r=Number(n.replace(`,`,`.`)),i=l[e];if(!i||!(r>0)||!Number.isFinite(r))return;let a=tU(i,t,r);a!==i&&VH(a)&&(S(l.map((t,n)=>n===e?a:t)),N())},j=()=>{let e=k();s.setCurves(e.filter(CH),e.flatMap(e=>e.kind===`nurbs`&&p!==hU?[]:IH(e)));let t=o.showDimensions?e.flatMap((e,t)=>$H(e).map((e,n)=>({...e,item:t,segment:n}))):[],r=p===null||p===hU;s.setLabels(t.length>gU?[]:t.filter(e=>e.length>0).map(e=>({text:oU(e.length,n),at:D(e.from,e.to),...r&&{editText:oU(e.length),onEdit:t=>A(e.item,e.segment,t)}})))},M=()=>{let e=f!==null,t=e&&g?[...m,g.point]:m,r=e?f.build(t,!1):null;s.setPreview(e?{polylines:r?r.filter(CH).map(e=>qH(e)):t.length>=2?[t]:[],points:m}:null),s.setCursor(p?g:null);let i=O();if(e&&i&&g&&OH(i,g.point)>0){let e=oU(OH(i,g.point),n);s.setPreviewLabel({text:h?`${h}\n${e}`:e,at:D(i,g.point)})}else s.setPreviewLabel(null)},N=()=>{v||(j(),M(),x())},P=e=>{let t=_,n=[...m,...l.flatMap((e,n)=>IH(e).filter((e,r)=>!(t&&t.item===n&&t.vertex===r)))],r=p===hU;return c.pick(e,{snapTo:n,last:r?t?IH(t.original)[t.vertex]:null:O(),planar:o.planar,gridStep:o.gridStep,typed:r?null:rU(h)})},F=e=>{let t=l.flatMap((e,t)=>IH(e).map((e,n)=>({point:e,item:t,vertex:n}))),n=t[c.nearestPoint(e,t.map(e=>e.point))];return n?{item:n.item,vertex:n.vertex,original:l[n.item]}:null},I=(e=!1)=>{let t=f?.build(m,e)?.filter(VH)??[];return m=[],h=``,t.length!==0&&(S([...l,...t.map(E)].slice(-i)),l.length>=i&&ie(),!0)},ee=(e,t)=>OH(e,t)===0,te=e=>{if(!f)return;let t=O();t&&ee(e,t)?I():f.closable&&m.length>=3&&ee(e,m[0])?I(!0):(m=[...m,e],h=``,m.length===f.pointCount&&I()),N()},L=e=>{if(!_)return;let{item:t,vertex:n,original:r}=_;_=null;let i=LH(r,n,e);VH(i)&&S(l.map((e,n)=>n===t?i:e))},R=()=>{if(!_)return;let{item:e,vertex:t,original:n}=_;_=null;let r=RH(n,t);S(r&&VH(r)?l.map((t,n)=>n===e?r:t):l.filter((t,n)=>n!==e))},z=e=>{if(!p||e.altKey)return;let t=e.target;if(t?.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t?.tagName??``))return;let n=p===hU,r=e.key.toLowerCase(),i=!0;e.ctrlKey||e.metaKey?r===`y`||r===`z`&&e.shiftKey?T():r===`z`&&m.length?m=m.slice(0,-1):r===`z`?w():i=!1:e.key===`Escape`?n&&_?_=null:h?h=``:m.length?m=[]:ie():e.key===`Enter`?n?ie():h&&g&&O()?te(g.point):I()||ie():e.key===`Backspace`||e.key===`Delete`?n?R():h?h=h.slice(0,-1):m=m.slice(0,-1):!n&&nU.test(e.key)?h+=e.key===`,`?`.`:e.key:i=!1,i&&(e.preventDefault(),e.stopPropagation(),p&&(B&&(g=P(B)),N()))},B=null,ne=0,re=(e,n)=>{v||(p&&ie(),p=e,f=n,t.tools.setActive(r),window.addEventListener(`keydown`,z,!0),a.style.cursor=`crosshair`,N())},ie=()=>{p&&(p=null,f=null,m=[],h=``,g=null,B=null,_=null,ne&&cancelAnimationFrame(ne),ne=0,window.removeEventListener(`keydown`,z,!0),a.style.cursor=``,t.tools.getActive()===r&&t.tools.setActive(null),N())},ae=t.tools.register({id:r,tool:{setEnabled:e=>{e||ie()},isEnabled:()=>p!==null,handleClick:e=>{if(!p)return!1;if(p===hU&&!_)_=F(e),_&&(g={point:IH(_.original)[_.vertex],snapped:!0});else{let t=P(e);t&&p===hU?L(t.point):t&&te(t.point)}return N(),!0},handleMove:e=>{p&&(B=e,!ne&&(ne=requestAnimationFrame(()=>{ne=0,p&&B&&(g=P(B),_&&j(),M())})))}},priority:10});return{getItems:()=>l,setItems:e=>{l=[...e],u=[],d=[],_=null,N()},draw:e=>{let t=typeof e==`string`?mU[e]:e;re(t.id,t)},move:()=>re(hU,null),finish:()=>{p&&(I(),ie())},cancel:()=>ie(),undo:w,redo:T,getState:b,configure:e=>{Object.assign(o,e),N()},dispose:()=>{v||(ie(),v=!0,ae(),s.dispose())}}}var vU=2e3,yU=class extends Error{reason;constructor(e){super(`Import failed: ${e}`),this.reason=e}},bU=D(`<span class="text-sm font-mono text-foreground"> </span>`),xU=D(`<span class="text-sm text-muted-foreground"> </span>`),SU=D(`<output class="text-sm min-w-0 text-muted-foreground"> </output> <!> <div class="gap-x-3 gap-y-2 min-w-0 flex flex-wrap items-center"><div class="gap-2 flex items-center"><!> <!> <!></div> <div class="gap-2 flex items-center"><!> <!></div> <!></div>`,1),CU=D(`<!> `,1),wU=D(`<!> <!>`,1),TU=D(`<div class="gap-2 min-w-0 flex flex-wrap items-center"><!> <!></div> <div class="gap-2 min-w-0 flex flex-wrap items-center"><output> </output> <!> <!></div>`,1),EU=D(`<div class="gap-2 min-w-0 flex flex-col"><!></div>`);function DU(e,n){V(n,!0);let r=J(n,`sketch`,7),i=J(n,`disabled`,3,!1),o=at(),s=T(()=>o.messages),l=T(()=>r().view(n.paramId)),u=T(()=>C(l).state.mode),d=T(()=>r().unitSuffix),f=T(()=>r().kinds(n.paramId)),h={line:[`line`],curve:[`line`,`polyline`,`nurbs`],point:[`point`]},g={point:`curveDrawPoint`,line:`curveDrawLine`,polyline:`curveDrawPolyline`,nurbs:`curveDrawCurve`},_={point:`curveHintPoint`,line:`curveHintLine`,polyline:`curveHintPolyline`,nurbs:`curveHintCurve`,move:`curveHintMove`},v=T(()=>[...new Set(C(f).flatMap(e=>h[e]))]),y=T(()=>{let e=C(l).items.filter(CH),t=C(l).items.filter(SH).length,n=[];if(e.length>0){let t=e.reduce((e,t)=>e+eU(t),0),r=C(f).includes(`curve`)?it(e.length,C(s).curveCountOne,C(s).curveCountOther):it(e.length,C(s).curveCountLineOne,C(s).curveCountLineOther);n.push(`${r} · ${oU(t,C(d))}`)}return t>0&&n.push(it(t,C(s).curveCountPointOne,C(s).curveCountPointOther)),n.join(`, `)}),x=Z(re(Y(()=>r().gridStep||null)));le(()=>{r().gridStep=C(x)??0});let w=Z(!1);async function E(){let e=await gF({accept:r().importAccept});if(e){P(w,!0);try{let{items:t,skipped:i,overLimit:a}=await r().importFile(n.paramId,e);t.length===0?Cn.error(C(s).curveImportEmpty):a>0?Cn.warning(nt(t.length===1?C(s).curveImportOverLimitOne:C(s).curveImportOverLimitOther,{max:t.length,count:t.length+a})):i>0&&Cn.warning(it(i,C(s).curveImportSkippedOne,C(s).curveImportSkippedOther))}catch(e){let t=e instanceof yU?e.reason:`unreadable`;Cn.error(t===`tooMany`?nt(C(s).curveImportTooMany,{max:vU}):t===`unsupported`?C(s).curveImportUnsupported:C(s).curveImportFailed)}finally{P(w,!1)}}}function D(e,t){t.currentTarget.blur(),r().draw(n.paramId,e)}var k=EU(),A=L(k),j=e=>{var i=SU(),a=B(i),o=K(a,!0),f=U(a,2),h=e=>{var t=bU(),n=K(t);G(()=>m(n,`${C(l).state.typed??``} ${C(d)??``}`)),O(e,t)};t(f,e=>{C(l).state.typed&&e(h)});var g=U(f,2),v=L(g),y=L(v);mn(y,{get for(){return`${n.inputId??``}-grid`},children:(e,t)=>{S();var n=p();G(()=>m(n,C(s).curveGrid)),O(e,n)},$$slots:{default:!0}});var b=U(y,2);xn(b,{get id(){return`${n.inputId??``}-grid`},type:`number`,min:`0`,step:`any`,class:`w-24`,get placeholder(){return C(s).curveGridOff},get value(){return C(x)},set value(e){P(x,e,!0)}});var w=U(b,2),T=e=>{var t=xU(),n=K(t,!0);G(()=>m(n,C(d))),O(e,t)};t(w,e=>{C(d)&&e(T)}),c(v);var E=U(v,2),D=L(E);Co(D,{get id(){return`${n.inputId??``}-dimensions`},get checked(){return r().showDimensions},onCheckedChange:e=>{r().showDimensions=e===!0}});var k=U(D,2);mn(k,{get for(){return`${n.inputId??``}-dimensions`},children:(e,t)=>{S();var n=p();G(()=>m(n,C(s).curveDimensions)),O(e,n)},$$slots:{default:!0}}),c(E);var A=U(E,2);tt(A,{size:`sm`,onclick:()=>r().finish(n.paramId),children:(e,t)=>{S();var n=p();G(()=>m(n,C(s).curveDone)),O(e,n)},$$slots:{default:!0}}),c(g),G(()=>{H(a,`id`,n.inputId),m(o,C(s)[_[C(u)]??`curveHintDraw`])}),O(e,i)},M=e=>{var o=TU(),u=B(o),d=L(u);a(d,16,()=>C(v),e=>e,(e,t)=>{{let n=T(()=>i()||!r().canDraw);tt(e,{variant:`outline`,size:`sm`,onclick:e=>D(t,e),get disabled(){return C(n)},children:(e,n)=>{S();var r=p();G(()=>m(r,C(s)[g[t]])),O(e,r)},$$slots:{default:!0}})}});var f=U(d,2);{let e=T(()=>i()||!r().canImport||C(w));tt(f,{variant:`outline`,size:`sm`,onclick:E,get disabled(){return C(e)},children:(e,t)=>{var n=CU(),r=B(n);Ct(r,{});var i=U(r);G(()=>m(i,` ${C(s).curveImport??``}`)),O(e,n)},$$slots:{default:!0}})}c(u);var h=U(u,2),_=L(h),b=K(_,!0),x=U(_,2),k=e=>{var t=wU(),a=B(t);{let e=T(()=>i()||!r().canDraw);tt(a,{variant:`ghost`,size:`sm`,onclick:()=>r().move(n.paramId),get disabled(){return C(e)},children:(e,t)=>{S();var n=p();G(()=>m(n,C(s).curveEdit)),O(e,n)},$$slots:{default:!0}})}var o=U(a,2);tt(o,{variant:`ghost`,size:`sm`,onclick:()=>r().reset(n.paramId),get disabled(){return i()},children:(e,t)=>{S();var n=p();G(()=>m(n,C(s).curveReset)),O(e,n)},$$slots:{default:!0}}),O(e,t)};t(x,e=>{C(y)&&e(k)});var A=U(x,2),j=e=>{tt(e,{variant:`ghost`,size:`sm`,onclick:()=>r().undo(n.paramId),get disabled(){return i()},children:(e,t)=>{S();var n=p();G(()=>m(n,C(s).curveUndo)),O(e,n)},$$slots:{default:!0}})};t(A,e=>{C(l).state.canUndo&&e(j)}),c(h),G(()=>{H(_,`id`,n.inputId),fe(_,1,`text-sm min-w-0 truncate ${C(y)?`text-foreground`:`text-muted-foreground`}`),m(b,r().canImport?C(y)||C(s).curveEmpty:C(s).curveNeedsSolve)}),O(e,o)};t(A,e=>{C(u)?e(j):e(M,-1)}),c(k),O(e,k),b()}var OU=D(`<!> <!>`,1);function kU(e,n){V(n,!0);let r=J(n,`value`,15),i=J(n,`disabled`,3,!1),a=at(),o=T(()=>a.messages),s=Z(null),c=Z(re(r()||``)),l=EV(e=>n.onChange(e),400);function d(e){if(n.config?.maxLength&&e.length>n.config.maxLength)return nt(C(o).maxLength,{max:n.config.maxLength});if(n.config?.pattern)try{if(!new RegExp(n.config.pattern).test(e))return n.config.customErrorMessage||C(o).invalidFormat}catch{return C(o).invalidPattern}return null}function f(){let e=d(C(c));P(s,e,!0),e||(r(C(c)),l(C(c)))}var h=OU(),g=B(h);{let e=T(()=>n.config?.placeholder),t=T(()=>n.config?.maxLength),a=T(()=>C(s)?!0:void 0),o=T(()=>C(s)?!0:void 0);xn(g,{get id(){return n.inputId},type:`text`,get placeholder(){return C(e)},get maxlength(){return C(t)},get"data-invalid"(){return C(a)},get"aria-invalid"(){return C(o)},get disabled(){return i()},oninput:()=>{P(s,null),f()},onblur:e=>{let t=e.currentTarget.value,i=d(t);P(s,i,!0),i||(P(c,t,!0),r(t),n.onChange(t))},get value(){return C(c)},set value(e){P(c,e,!0)}})}var _=U(g,2),v=e=>{var t=u(),n=B(t);E(n,()=>uV,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(s))),O(e,n)},$$slots:{default:!0}})}),O(e,t)};t(_,e=>{C(s)&&e(v)}),O(e,h),b()}var AU=D(`<span class="text-lg font-medium" aria-hidden="true"> </span>`),jU=D(`<button type="button" role="radio"><span><!></span> <span> </span></button>`),MU=D(`<div role="radiogroup" class="gap-2 tile-grid grid svelte-15u2gi8"></div>`);function NU(e,n){V(n,!0);let r=J(n,`disabled`,3,!1),i=T(()=>Object.entries(n.config.options??{}).map(([e,t])=>({name:e,value:t??e}))),o=T(()=>Math.max(0,C(i).findIndex(e=>e.value===n.value))),s=re([]);function l(e,t){let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key];if(!r)return;e.preventDefault();let a=(t+r+C(i).length)%C(i).length;n.onChange(C(i)[a].value),s[a]?.focus()}var u=MU();a(u,23,()=>C(i),e=>e.name,(e,i,a)=>{let u=T(()=>yV(n.config.optionMedia?.[C(i).name],n.assets)),d=T(()=>C(i).value===n.value);var p=jU(),h=L(p),g=L(h),_=e=>{SV(e,{get glyph(){return C(u)},class:`size-full`})},v=e=>{SV(e,{get glyph(){return C(u)},class:`size-7`})},y=e=>{var t=AU(),n=K(t,!0);G(e=>m(n,e),[()=>C(i).name.charAt(0)]),O(e,t)};t(g,e=>{C(u)?.kind===`image`?e(_):C(u)?e(v,1):e(y,-1)}),c(h);var b=U(h,2);let x;var S=K(b,!0);c(p),F(p,(e,t)=>s[t]=e,e=>s?.[e],()=>[C(a)]),G(()=>{H(p,`title`,C(i).name),H(p,`aria-checked`,C(d)),H(p,`tabindex`,C(a)===C(o)?0:-1),p.disabled=r(),fe(p,1,`gap-1.5 p-1.5 min-w-0 flex flex-col rounded-lg border text-left transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 ${C(d)?`border-primary bg-primary/10 ring-1 ring-primary`:`border-input hover:bg-hover`}`),fe(h,1,`flex aspect-square w-full items-center justify-center overflow-hidden rounded-md bg-muted ${C(d)?`text-foreground`:`text-muted-foreground`}`),x=fe(b,1,`px-0.5 text-xs leading-tight line-clamp-2`,null,x,{"font-medium":C(d)}),m(S,C(i).name)}),f(`click`,p,()=>n.onChange(C(i).value)),f(`keydown`,p,e=>l(e,C(a))),O(e,p)}),c(u),G(()=>H(u,`aria-labelledby`,n.labelId)),O(e,u),b()}ce([`click`,`keydown`]);var PU=Symbol(`client-slot-context`);function FU(e){n(PU,e)}function IU(){return s(PU)}var LU={host:`selva`},RU=Symbol(`host-context`);function zU(){return s(RU)??LU}var BU=Symbol(`sketch-context`);function VU(e){n(BU,e)}function HU(){return s(BU)}var UU={value:[`rhino`,`selva`],sketch:[`rhino`,`selva`],geometry:[`rhino`],trigger:[`rhino`],unknown:[]},WU=new Set([`geometry`,`point`,`line`,`plane`]),GU={input:new Set(Object.keys({number:!0,text:!0,dropdown:!0,dynamicValueList:!0,checkbox:!0,file:!0,color:!0})),output:new Set(Object.keys({text:!0,number:!0,file:!0,chart:!0,image:!0,dynamicValueList:!0}))};function KU(e){return e!==void 0&&WU.has(e)}var qU={line:[`line`],point:[`point`]},JU=[`curve`,`point`];function YU(e){if(e?.paramType!==`geometry`)return qU[e?.paramType??``]??[];let t=e.geometryTypes;return t?.length?JU.filter(e=>t.includes(e)):JU}function XU(e){return e.type===`input`&&e.widgetType===`checkbox`&&e.config?.displayAs===`button`}function ZU(e,t){if(e.type===`linebreak`)return`value`;if(e.type!==`input`&&e.type!==`output`)return`unknown`;if(e.type===`input`){let n=t.find(t=>t.id===e.paramId);if(YU(n).length>0)return`sketch`;if(KU(n?.paramType))return`geometry`}return GU[e.type].has(e.widgetType)?XU(e)?`trigger`:`value`:`unknown`}function QU(e,t){return UU[t].includes(e)}function $U(e,t){return KU(t?.paramType)||XU(e)}function eW(e){let t=new Set;for(let n of e.inputs)KU(n.paramType)&&t.add(n.id);for(let n of LF(e))for(let e of n.items??[])XU(e)&&t.add(e.paramId);return t}var tW=D(`<span> </span>`),nW=D(`<span class="text-xs pl-2 ml-auto hidden shrink-0 whitespace-nowrap text-muted-foreground tabular-nums group-focus-within/field:inline"> </span>`),rW=D(`<div class="gap-1.5 min-h-5 min-w-0 flex items-center"><!> <!> <!></div>`),iW=D(`<div role="group" class="group/field gap-2 min-w-0 flex flex-col"><!> <!></div>`),aW=D(`<span class="truncate"> </span>`),oW=D(`<div role="group" class="group/field gap-1.5 min-w-0 flex items-center" data-control-line=""><!> <!></div>`),sW=D(`<!> <!>`,1),cW=D(`<p class="text-sm text-muted-foreground"> </p>`);function lW(e,n){V(n,!0);let r=(e,r=h)=>{let i=T(()=>_V(r().displayAs,Object.keys(r().options??{}).length)),a=T(()=>typeof s()==`string`?s():``);var o=u(),c=B(o),d=e=>{{let t=T(()=>Array.isArray(s())?s():typeof s()==`string`&&s()?[s()]:[]);TV(e,{get inputId(){return C(A)},get value(){return C(t)},get config(){return r()},get assets(){return n.assets},onChange:re,get disabled(){return l()}})}},f=e=>{xH(e,{get labelId(){return`${C(A)??``}-label`},get value(){return C(a)},get config(){return r()},get assets(){return n.assets},onChange:re,get disabled(){return l()}})},p=e=>{NU(e,{get labelId(){return`${C(A)??``}-label`},get value(){return C(a)},get config(){return r()},get assets(){return n.assets},onChange:re,get disabled(){return l()}})},m=e=>{qV(e,{get inputId(){return C(A)},get value(){return C(a)},get config(){return r()},get assets(){return n.assets},onChange:re,get disabled(){return l()}})};t(c,e=>{C(i)===`checklist`?e(d):C(i)===`segmented`?e(f,1):C(i)===`tiles`?e(p,2):e(m,-1)}),O(e,o)},i=(e,t=h,n)=>{let r=pe(()=>d(n?.(),`quiet`));var i=u(),a=B(i);{let e=T(()=>t()?`${t()}-label`:void 0);E(a,()=>aV,(n,i)=>{i(n,{get for(){return t()},get id(){return C(e)},class:`min-w-0 block break-words`,children:(e,t)=>{var n=tW(),i=K(n,!0);G(()=>{fe(n,1,me(C(r)===`quiet`?`font-normal text-muted-foreground`:`font-normal text-foreground`)),m(i,C(j))}),O(e,n)},$$slots:{default:!0}})})}O(e,i)},a=e=>{var r=u(),i=B(r),a=e=>{pV(e,{get label(){return C(j)},get description(){return n.item.description},get nameTemplate(){return f.messages.helpFor}})};t(i,e=>{n.item.description&&e(a)}),O(e,r)},o=(e,n=h)=>{var r=rW(),o=L(r);i(o,n);var s=U(o,2);a(s);var l=U(s,2),u=e=>{var t=nW(),n=K(t,!0);G(()=>m(n,C(P))),O(e,t)};t(l,e=>{C(F)&&e(u)}),c(r),O(e,r)},s=J(n,`value`,15,void 0),l=J(n,`disabled`,3,!1),f=at(),p=zU(),{pickGeometry:g,clearGeometry:_,onGeometrySummary:v}=p,y=T(()=>KU(n.paramType)),x=HU(),S=T(()=>p.host===`selva`&&C(y)),w=T(()=>XU(n.item)),D=T(()=>C(y)?p.describeGeometry?.(n.item.paramId):void 0);function k(e){return n.paramType===`point`||n.paramType===`line`||n.paramType===`plane`?[n.paramType]:e?.kinds}let A=T(()=>`input-${n.item.paramId}`),j=T(()=>n.displayName||n.item.displayName||n.item.paramId),M=T(()=>{let e=n.item.source;return e?.kind===`client`&&e.client?.presentation===`slot`}),N=IU(),P=T(()=>{if(!St(n.item))return null;let e=n.item.config;if(e?.hideRange||e?.renderAsSlider)return null;let t=typeof e?.minimum==`number`,r=typeof e?.maximum==`number`;return!t&&!r?null:t&&r?`${e.minimum} – ${e.maximum}`:t?`≥ ${e.minimum}`:`≤ ${e.maximum}`}),F=T(()=>St(n.item)&&C(P)!==null),I=T(()=>vt(n.item)?n.item.config:void 0),ee=T(()=>n.dynamicOptions&&Object.keys(n.dynamicOptions).length>0?n.dynamicOptions:Object.fromEntries(Object.entries(C(I)?.defaultOptions??{}).filter(e=>e[1]!==void 0))),te=T(()=>Object.keys(C(ee)).length>0),R=T(()=>({options:C(ee),displayAs:C(I)?.displayAs??`dropdown`,optionMedia:C(I)?.optionMedia})),z=T(()=>vt(n.item)&&!C(te)&&(C(I)?.emptyBehavior??`hide`)===`hide`),ne=0;le(()=>{if(!vt(n.item)||!C(te))return;let e=new Set(Object.values(C(ee))),t=Object.values(C(ee))[0];if(Array.isArray(s())?s().length>0&&s().every(t=>typeof t==`string`&&e.has(t)):typeof s()==`string`&&s()!==``&&e.has(s()))ne=0;else if(ne>=3)console.warn(`[InputControl] dynamic value list "${n.item.paramId}": options keep invalidating the auto-picked selection (${ne} consecutive system picks) — the definition's options likely depend on the selection. Stopping auto-reconciliation to avoid a solve loop.`);else if(Array.isArray(s())){let r=s().filter(t=>typeof t==`string`&&e.has(t));(r.length!==s().length||s().length===0)&&(ne++,n.onChange(n.item.paramId,r.length>0?r:[t],!0))}else typeof s()==`string`&&s()!==``&&e.has(s())||(ne++,n.onChange(n.item.paramId,t,!0))});function re(e){ne=0,s(e),n.onChange(n.item.paramId,e)}var ie=u(),ae=B(ie),H=e=>{var r=u(),i=B(r),a=e=>{var t=iW(),r=L(t);o(r);var i=U(r,2);N(i,()=>({inputId:n.item.paramId,displayName:C(j),value:s(),onValueChange:re})),c(t),O(e,t)};t(i,e=>{N&&e(a)}),O(e,r)},W=e=>{var r=u(),i=B(r),a=e=>{var t=iW(),r=L(t);o(r,()=>C(A)),DU(U(r,2),{get inputId(){return C(A)},get paramId(){return n.item.paramId},get sketch(){return x},get disabled(){return l()}}),c(t),O(e,t)},s=T(()=>x?.supports(n.item.paramId));t(i,e=>{C(s)&&e(a)}),O(e,r)},oe=e=>{var t=iW(),r=L(t);o(r,()=>C(A));var i=U(r,2);{let e=T(()=>k(C(D))),t=T(()=>C(D)?.atMost),r=T(()=>typeof s()==`string`?s():void 0),a=T(()=>g&&(()=>g(n.item.paramId))),o=T(()=>_&&(()=>_(n.item.paramId))),c=T(()=>v&&(e=>v(n.item.paramId,e)));mH(i,{get inputId(){return C(A)},get kinds(){return C(e)},get atMost(){return C(t)},get summary(){return C(r)},get onPick(){return C(a)},get onClear(){return C(o)},get watchSummary(){return C(c)},onError:e=>Cn.error(e),get disabled(){return l()}})}c(t),O(e,t)},se=e=>{var t=oW(),r=L(t);{let e=T(()=>l()||!p.trigger||p.isSolving?.());tt(r,{get id(){return C(A)},variant:`outline`,class:`min-w-0 flex-1`,onclick:()=>p.trigger?.(n.item.paramId),get disabled(){return C(e)},children:(e,t)=>{var n=aW(),r=K(n,!0);G(()=>m(r,C(j))),O(e,n)},$$slots:{default:!0}})}var i=U(r,2);a(i),c(t),O(e,t)},ce=e=>{var d=iW(),p=L(d),h=e=>{o(e,()=>C(A))},g=T(()=>!Et(n.item));t(p,e=>{C(g)&&e(h)});var _=U(p,2),v=e=>{let t=T(()=>n.item.config);{let n=T(()=>typeof s()==`number`?s():void 0);yH(e,{get inputId(){return C(A)},get labelId(){return`${C(A)??``}-label`},get value(){return C(n)},get config(){return C(t)},onChange:re,get disabled(){return l()}})}},y=T(()=>St(n.item)),b=e=>{{let t=T(()=>typeof s()==`boolean`?s():void 0);hV(e,{get inputId(){return C(A)},get value(){return C(t)},onChange:re,get disabled(){return l()},children:(e,t)=>{var n=sW(),r=B(n);i(r,()=>C(A),()=>`strong`);var o=U(r,2);a(o),O(e,n)},$$slots:{default:!0}})}},x=T(()=>Et(n.item)),S=e=>{let t=T(()=>n.item.config);{let n=T(()=>typeof s()==`string`?s():``);kU(e,{get inputId(){return C(A)},get value(){return C(n)},get config(){return C(t)},onChange:re,get disabled(){return l()}})}},w=T(()=>Tt(n.item)),E=e=>{r(e,()=>n.item.config)},D=T(()=>wt(n.item)),k=e=>{var n=u(),i=B(n),a=e=>{r(e,()=>C(R))},o=e=>{var t=cW(),n=K(t,!0);G(()=>m(n,f.messages.noOptionsYet)),O(e,t)};t(i,e=>{C(te)?e(a):e(o,-1)}),O(e,n)},j=T(()=>vt(n.item)),M=e=>{let t=T(()=>n.item.config);{let n=T(()=>typeof s()==`string`?s():``),r=T(()=>C(t)?.acceptedFormats??[]),i=T(()=>C(t)?.defaultInputMode),a=T(()=>C(t)?.allowedInputModes);lH(e,{get value(){return C(n)},get acceptedFormats(){return C(r)},onChange:e=>re(e),get defaultInputMode(){return C(i)},get allowedInputModes(){return C(a)}})}},N=T(()=>mt(n.item)),P=e=>{{let t=T(()=>typeof s()==`string`?s():`#000000`);UV(e,{get inputId(){return C(A)},get value(){return C(t)},onChange:e=>re(e),get disabled(){return l()}})}},F=T(()=>xt(n.item));t(_,e=>{C(y)?e(v):C(x)?e(b,1):C(w)?e(S,2):C(D)?e(E,3):C(j)?e(k,4):C(N)?e(M,5):C(F)&&e(P,6)}),c(d),O(e,d)};t(ae,e=>{C(M)?e(H):C(S)?e(W,1):C(y)?e(oe,2):C(w)?e(se,3):C(z)||e(ce,4)}),O(e,ie),b()}var uW=new Map;function dW(e,t){if(uW.has(e))return uW.get(e);if(document.querySelector(`script[src="${e}"]`)){let t=Promise.resolve();return uW.set(e,t),t}let n=new Promise((n,r)=>{let i=document.createElement(`script`);i.src=e,t?.crossOrigin&&(i.crossOrigin=t.crossOrigin),t?.integrity&&(i.integrity=t.integrity),t?.async!==void 0&&(i.async=t.async),t?.defer!==void 0&&(i.defer=t.defer),i.onload=()=>n(),i.onerror=()=>{uW.delete(e),r(Error(`Failed to load script: ${e}`))},document.head.appendChild(i)});return uW.set(e,n),n}var fW={scattermapbox:`scattermap`,choroplethmapbox:`choroplethmap`,densitymapbox:`densitymap`},pW=/^mapbox(\d*)$/,mW=/^(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,hW=/^hsva?[\s(]+([-+\d.]+)%?[\s,]+([\d.]+)(%?)[\s,]+([\d.]+)(%?)(?:[\s,/]+([\d.]+)(%?))?[\s)]*$/i,gW=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function _W(e){let t=structuredClone(e),n=t.layout??{};xW(n);let r=!1;for(let e of t.data??[]){if(!gW(e))continue;xW(e);let t=fW[e.type];t?(e.type=t,typeof e.subplot==`string`&&(e.subplot=e.subplot.replace(pW,`map$1`)),r=!0):e.type===`splom`&&vW(e)}r&&yW(n);for(let e of t.frames??[])gW(e)&&xW(e);return{...t,layout:n}}function vW(e){if(Array.isArray(e.dimensions))for(let t of e.dimensions){if(!gW(t))continue;let e=gW(t.axis)?t.axis:t.axis={};`matches`in e||(e.matches=!1)}}function yW(e){for(let t of Object.keys(e)){let n=pW.exec(t);if(!n)continue;let r=e[t];delete e[t];let i=`map${n[1]}`;i in e||!gW(r)||(delete r.accesstoken,typeof r.style==`string`&&/^(stamen|mapbox:\/\/)/.test(r.style)&&(r.style=`open-street-map`),e[i]=r)}}var bW=e=>e.toLowerCase().endsWith(`color`)||e===`colors`||e===`colorway`||e===`colorscale`;function xW(e){for(let[t,n]of Object.entries(e))if(bW(t))e[t]=SW(n,!1);else if(gW(n))xW(n);else if(Array.isArray(n))for(let e of n)gW(e)&&xW(e)}function SW(e,t){return Array.isArray(e)?e.map(e=>SW(e,!0)):typeof e!=`string`||t&&/^\s*\d+\s*$/.test(e)?e:CW(e)}function CW(e){let t=e.trim();if(mW.test(t))return`#${t}`;let n=hW.exec(t);if(!n)return e;let{r,g:i,b:a}=MV({h:Number(n[1]),s:wW(n[2],n[3]===`%`),v:wW(n[4],n[5]===`%`)}),o=`${Math.round(r)},${Math.round(i)},${Math.round(a)}`;return n[6]===void 0?`rgb(${o})`:`rgba(${o},${+wW(n[6],n[7]===`%`).toFixed(3)})`}function wW(e,t){let n=Number(e);return(t||n>1)&&(n/=100),Math.min(1,Math.max(0,n))}var TW=D(`<div class="px-4 py-3 text-sm text-destructive"> </div>`),EW=D(`<div class="px-4 py-8 text-sm text-center text-muted-foreground"> </div>`),DW=D(`<div class="p-1.5 backdrop-blur-sm flex items-center rounded-sm border border-border-strong bg-background/80 text-muted-foreground"><!></div>`),OW=D(`<button class="p-1.5 backdrop-blur-sm flex items-center rounded-sm border border-border-strong bg-background/80 text-foreground transition-colors hover:bg-background disabled:cursor-not-allowed disabled:opacity-50"><!></button>`),kW=D(`<div></div> <div><!> <!></div>`,1),AW=D(`<div><!></div>`);function jW(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),a=new Set([`scattermap`,`choroplethmap`,`densitymap`,`choropleth`,`scattergeo`]),o=T(()=>{if(!n.value)return null;try{return _W(JSON.parse(n.value))}catch{return null}}),s=Z(null),l=Z(null),u=Z(!1),d=Z(null),p=Z(!1),h=!1;async function g(){return window.Plotly||await dW(`https://cdn.plot.ly/plotly-4.1.2.min.js`,{crossOrigin:`anonymous`,integrity:`sha384-hHv6D3tTUUBpp4tVv6t2Dc3oGuRhphmWOTKUR8jWyN0Pnon1g3iebKCNDNmKmxo8`}),window.Plotly}let v=typeof document<`u`&&!!document.fullscreenEnabled;function y(){if(!C(s)||!window.Plotly)return;let{width:e,height:t}=C(s).getBoundingClientRect();e!==0&&t!==0&&window.Plotly.relayout(C(s),{width:e,height:t})}function x(){C(l)&&(document.fullscreenElement?document.exitFullscreen().catch(e=>{P(d,nt(C(i).exitFullscreenFailed,{error:e.message}),!0)}):C(l).requestFullscreen().catch(e=>{P(d,nt(C(i).fullscreenUnavailable,{error:e.message}),!0)}))}le(()=>{function e(){P(p,!!document.fullscreenElement),R().then(y)}return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)});function S(e){let t=document.createElement(`canvas`);t.width=1,t.height=1;let n=t.getContext(`2d`);if(!n)return e;n.fillStyle=e,n.fillRect(0,0,1,1);let[r,i,a,o]=n.getImageData(0,0,1,1).data;return o===255?`rgb(${r}, ${i}, ${a})`:`rgba(${r}, ${i}, ${a}, ${(o/255).toFixed(3)})`}function w(){if(!C(s))return{textColor:`#333`,gridColor:`#eee`,fontFamily:``,colorway:[]};let e=getComputedStyle(C(s)),t=S(e.getPropertyValue(`color`).trim()||`#333`),n=S(e.getPropertyValue(`--border`)?.trim()||e.getPropertyValue(`--color-border`)?.trim()||`rgba(128,128,128,0.2)`),r=[1,2,3,4,5].map(t=>e.getPropertyValue(`--chart-${t}`).trim()).filter(Boolean).map(S);return{textColor:t,gridColor:n,fontFamily:e.fontFamily,colorway:r}}async function E(e,t,n={}){let r=n.format??`png`;try{let i=await e.toImage(t,{...n,format:r});await hF(await(await fetch(i)).blob(),`${n.filename??`chart`}.${r}`)}catch{Cn.error(C(i).downloadFailed)}}async function D(){if(C(s)&&C(o)){P(d,null),P(u,!0);try{let e=await g(),{textColor:t,gridColor:n,fontFamily:r,colorway:c}=w(),l=C(o).data?.some(e=>a.has(e.type)),{title:u,template:d,height:f,width:p,...m}=C(o).layout,h={...m,autosize:!0,margin:{t:24,r:8,b:40,l:60,pad:0},font:{color:t,...r?{family:r}:{}},...c.length&&!m.colorway?{colorway:c}:{},paper_bgcolor:m.paper_bgcolor??`transparent`,plot_bgcolor:m.plot_bgcolor??`transparent`,...l?{}:{xaxis:{...m.xaxis,gridcolor:n,color:t},yaxis:{...m.yaxis,gridcolor:n,color:t}}},_=C(o).config??{};e.react(C(s),{data:C(o).data,layout:h,frames:C(o).frames??[],config:{responsive:!0,displayModeBar:`hover`,displaylogo:!1,showSendToCloud:!1,..._,modeBarButtonsToRemove:[`sendDataToCloud`,`lasso2d`,`select2d`,`toImage`,..._.modeBarButtonsToRemove??[]],modeBarButtonsToAdd:[{name:`toImage`,title:C(i).downloadChartImage,icon:e.Icons.camera,click:t=>E(e,t,_.toImageButtonOptions)},..._.modeBarButtonsToAdd??[]]}})}catch(e){P(d,e instanceof Error?e.message:C(i).chartRenderFailed,!0)}finally{P(u,!1)}}}_(()=>{h=!0;let e=null,t=new ResizeObserver(()=>{e&&clearTimeout(e),e=setTimeout(()=>{y(),e=null},150)});return C(l)&&t.observe(C(l)),()=>{t.disconnect(),e&&clearTimeout(e),C(s)&&window.Plotly&&window.Plotly.purge(C(s))}});let k=null;le(()=>{if(ge.current,n.value&&h&&C(s))return k&&clearTimeout(k),k=setTimeout(()=>{D(),k=null},150),()=>{k&&clearTimeout(k)}});var A=AW(),j=L(A),M=e=>{var t=TW(),n=K(t,!0);G(()=>m(n,C(d))),O(e,t)},N=e=>{var t=EW(),n=K(t,!0);G(()=>m(n,C(i).chartReceiving)),O(e,t)},I=e=>{var n=kW(),r=B(n);F(r,e=>P(s,e),()=>C(s));var a=U(r,2),o=L(a),l=e=>{var t=DW();mr(L(t),{size:14,class:`animate-spin`}),c(t),O(e,t)};t(o,e=>{C(u)&&e(l)});var d=U(o,2),m=e=>{var n=OW(),r=L(n),a=e=>{Cr(e,{size:14})},o=e=>{br(e,{size:14})};t(r,e=>{C(p)?e(a):e(o,-1)}),c(n),G(()=>{n.disabled=C(u),H(n,`title`,C(p)?C(i).exitFullscreen:C(i).fullscreen),H(n,`aria-label`,C(p)?C(i).exitFullscreen:C(i).fullscreen)}),f(`click`,n,x),O(e,n)};t(d,e=>{v&&e(m)}),c(a),G(()=>{fe(r,1,`w-full ${C(p)?`h-dvh`:`h-95`}`),fe(a,1,`gap-1 left-2 top-2 absolute z-10 flex items-center opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100 ${C(p)?`opacity-100`:``}`)}),O(e,n)};t(j,e=>{C(d)?e(M):C(o)?e(I,-1):e(N,1)}),c(A),F(A,e=>P(l,e),()=>C(l)),G(()=>fe(A,1,`group relative overflow-hidden rounded-lg border border-border-strong ${C(p)?`bg-background`:``}`)),O(e,A),b()}ce([`click`]);var MW=D(`<div class="px-4 py-3 text-sm text-destructive"> </div>`),NW=D(`<div class="inset-0 text-sm absolute flex items-center justify-center text-destructive"> </div>`),PW=D(`<div class="inset-0 gap-2 text-sm absolute flex items-center justify-center text-muted-foreground"><!> </div>`),FW=D(`<!> <img alt="" draggable="false"/>`,1),IW=D(`<button class="left-2 p-1.5 backdrop-blur-sm absolute top-1/2 -translate-y-1/2 rounded-full border border-border-strong bg-background/80 text-foreground hover:bg-background"><!></button> <button class="right-2 p-1.5 backdrop-blur-sm absolute top-1/2 -translate-y-1/2 rounded-full border border-border-strong bg-background/80 text-foreground hover:bg-background"><!></button>`,1),LW=D(`<button><img alt="" class="h-full w-full object-contain"/></button>`),RW=D(`<div class="gap-1.5 p-1.5 flex overflow-x-auto border-t border-border"></div>`),zW=D(`<span class="shrink-0 tabular-nums"> </span>`),BW=D(`<div class="mx-1 h-4 w-px bg-border"></div>`),VW=D(`<button><!></button>`),HW=D(`<div role="application" tabindex="0"><!> <!> <div> </div></div> <!> <div class="gap-2 px-2 py-1 text-xs flex items-center border-t border-border"><div class="min-w-0 gap-1.5 flex flex-1 items-center text-muted-foreground"><span class="truncate text-foreground"> </span> <!></div> <div class="gap-0.5 flex shrink-0 items-center"><button><!></button> <span class="w-11 text-center text-muted-foreground tabular-nums"> </span> <button><!></button> <button><!></button> <button>1:1</button> <!> <!> <!></div></div>`,1),UW=D(`<div><!></div>`),WW=D(`<div class="px-3 py-3 text-sm rounded-md border border-border-strong text-muted-foreground"> </div>`);function GW(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),o=new Set([`.png`,`.jpg`,`.jpeg`,`.webp`,`.gif`,`.svg`]),s=1.5,l=e=>(e.fileType??``).toLowerCase(),d=e=>typeof e.data==`string`&&e.data.trim()!==``,p=T(()=>(Array.isArray(n.value)?n.value.filter(FB):FB(n.value)?[n.value]:[]).filter(d)),h=T(()=>C(p).filter(e=>o.has(l(e)))),g=T(()=>C(h).length===0?C(p)[0]:void 0),_=Z(0),v=T(()=>Math.max(0,Math.min(C(_),C(h).length-1))),x=T(()=>C(h)[C(v)]??null),S=T(()=>C(x)?l(C(x))===`.svg`:!1);function w(e){let t=MB[l(e)]??`application/octet-stream`;return e.isBase64Encoded?`data:${t};base64,${e.data}`:`data:${t};utf8,${encodeURIComponent(e.data)}`}let E=T(()=>C(x)?w(C(x)):null),D=T(()=>n.item.config??{}),k=T(()=>C(D).allowDownload??!0),A=typeof document<`u`&&!!document.fullscreenEnabled,I=T(()=>(C(D).allowFullscreen??!0)&&A),ee=T(()=>C(D).backgroundColor??(C(S)?`#ffffff`:void 0)),te=Z(null),R=Z(null),z=Z(!1),ne=Z(!1),re=Z(null),ie=Z(null),ae=T(()=>C(ie)!==null&&C(ie)===C(E)),W=Z(0),oe=Z(0),se=Z(0),ce=Z(0),q=Z(1),J=Z(0),Y=Z(0),ue=Z(!0),de=T(()=>C(se)>0&&C(ce)>0&&C(W)>0&&C(oe)>0),X=T(()=>C(de)?Math.min(C(W)/C(se),C(oe)/C(ce)):1),pe=T(()=>Math.min(C(X),1)),he=T(()=>Math.max(C(X),1)*32),ge=T(()=>Math.round(C(q)*100)),_e=T(()=>C(se)*C(q)>C(W)+1||C(ce)*C(q)>C(oe)+1),ve=T(()=>!C(S)&&C(q)>=2);function ye(e,t,n){return t<=n?(n-t)/2:Math.min(0,Math.max(n-t,e))}function be(e,t,n){P(q,e,!0),P(J,ye(t,C(se)*e,C(W)),!0),P(Y,ye(n,C(ce)*e,C(oe)),!0)}function xe(){P(ue,!0),be(C(X),0,0)}function Se(e,t=C(W)/2,n=C(oe)/2){let r=Math.min(C(he),Math.max(C(pe),e)),i=r/C(q);P(ue,Math.abs(r-C(X))<.001),be(r,t-(t-C(J))*i,n-(n-C(Y))*i)}le(()=>{if(!C(R))return;let e=new ResizeObserver(([e])=>{P(W,e.contentRect.width,!0),P(oe,e.contentRect.height,!0),C(ue)?xe():be(Math.max(C(q),C(pe)),C(J),C(Y))});return e.observe(C(R)),()=>e.disconnect()});function Ce(e){let t=e.currentTarget,n=t.naturalWidth||300,r=t.naturalHeight||150,i=n===C(se)&&r===C(ce);P(se,n,!0),P(ce,r,!0),(!i||C(ue))&&xe()}let we={},Te=()=>Object.values(we),Ee=Z(!1),De=0;function Oe(e){let t=C(R).getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function ke(e){if(e.button!==0||e.target.closest(`button`))return;C(R)?.setPointerCapture(e.pointerId),we[e.pointerId]=Oe(e);let t=Te().length;if(P(Ee,t===1&&C(_e),!0),t===2){let[e,t]=Te();De=Math.hypot(e.x-t.x,e.y-t.y)}}function Ae(e){let t=we[e.pointerId];if(!t)return;let n=Oe(e);if(we[e.pointerId]=n,Te().length===2){let[e,t]=Te(),n=Math.hypot(e.x-t.x,e.y-t.y);De>0&&Se(C(q)*(n/De),(e.x+t.x)/2,(e.y+t.y)/2),De=n}else C(Ee)&&(P(ue,!1),be(C(q),C(J)+n.x-t.x,C(Y)+n.y-t.y))}function je(e){delete we[e.pointerId];let t=Te().length;t<2&&(De=0),t===0&&P(Ee,!1)}function Me(e){if(!C(ue))return xe();let t=Oe(e);Se(C(X)<.8?1:C(X)*3,t.x,t.y)}let Ne=Z(!1),Pe;le(()=>{if(!C(R))return;let e=C(R);function t(e){if(!C(de))return;if(!(e.ctrlKey||e.metaKey||C(z))){P(Ne,!0),clearTimeout(Pe),Pe=setTimeout(()=>P(Ne,!1),1200);return}e.preventDefault(),P(Ne,!1);let t=e.deltaMode===1?e.deltaY*16:e.deltaY,n=Oe(e);Se(C(q)*Math.exp(-t*.002),n.x,n.y)}return e.addEventListener(`wheel`,t,{passive:!1}),()=>{e.removeEventListener(`wheel`,t),clearTimeout(Pe)}});function Fe(e){let t={"+":()=>Se(C(q)*s),"=":()=>Se(C(q)*s),"-":()=>Se(C(q)/s),0:xe,1:()=>Se(1),ArrowLeft:()=>Ie(-1),ArrowRight:()=>Ie(1)};C(I)&&(t.f=Re);let n=t[e.key];n&&(e.preventDefault(),n())}function Ie(e){C(h).length<2||Le((C(v)+e+C(h).length)%C(h).length)}function Le(e){e!==C(v)&&(P(_,e,!0),P(se,0),P(ce,0),P(ue,!0))}function Re(){C(te)&&(document.fullscreenElement?document.exitFullscreen().catch(e=>{P(re,nt(C(i).exitFullscreenFailed,{error:e.message}),!0)}):C(te).requestFullscreen().catch(e=>{P(re,nt(C(i).fullscreenUnavailable,{error:e.message}),!0)}))}le(()=>{function e(){P(z,document.fullscreenElement===C(te))}return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)});async function ze(){if(C(x)){P(ne,!0),P(re,null);try{await PB(C(x),C(x).fileName)}catch(e){P(re,e instanceof Error?e.message:C(i).downloadFailed,!0)}finally{P(ne,!1)}}}let Be=`flex h-7 min-w-7 items-center justify-center rounded-sm px-1.5 text-muted-foreground transition-colors hover:bg-hover hover:text-foreground disabled:pointer-events-none disabled:opacity-40`;var Ve=u(),He=B(Ve),Ue=e=>{var r=UW(),u=L(r),d=e=>{var t=MW(),n=K(t,!0);G(()=>m(n,C(re))),O(e,t)},p=e=>{var t=MW(),n=K(t,!0);G(e=>m(n,e),[()=>nt(C(i).imageUnsupported,{ext:l(C(g))||C(i).imageUnknownFormat,formats:[...o].join(`, `)})]),O(e,t)},_=e=>{var r=HW(),o=B(r);let l;var u=L(o),d=e=>{var t=NW(),n=K(t,!0);G(e=>m(n,e),[()=>nt(C(i).imageDecodeFailed,{file:`${C(x).fileName}${C(x).fileType}`})]),O(e,t)},p=e=>{var n=FW(),r=B(n),a=e=>{var t=PW(),n=L(t);_t(n,{size:16,class:`animate-spin`});var r=U(n);c(t),G(()=>m(r,` ${C(i).imageLoading??``}`)),O(e,t)};t(r,e=>{C(de)||e(a)});var o=U(r,2);let s;G(()=>{H(o,`src`,C(E)),fe(o,1,`absolute top-(--img-y) left-(--img-x) h-(--img-h) w-(--img-w) max-w-none
|
|
6079
|
+
${C(o)?`opacity-40`:``}`,`svelte-br1q9x`),H(h,`title`,C(o)?C(i).showObject:C(i).hideObject),H(h,`aria-label`,C(o)?C(i).showObject:C(i).hideObject),fe(y,1,`min-w-0 text-xs flex-1 truncate ${C(o)?`text-muted-foreground line-through`:`text-foreground`}`),m(b,C(a).label),m(S,e)},[()=>$k(C(a).object)]),j(`mouseenter`,p,()=>n.onHover?.(C(a))),j(`mouseleave`,p,()=>n.onHover?.(null)),f(`mousedown`,p,e=>{e.stopPropagation(),e.shiftKey&&e.preventDefault()}),f(`click`,p,e=>ne(C(a).key,e)),f(`keydown`,p,e=>e.key===`Enter`&&ne(C(a).key,e)),f(`click`,h,e=>{e.stopPropagation(),l(C(a))}),O(e,u)};t(u,e=>{C(r).kind===`layer`?e(h):e(g,-1)}),c(a),G(()=>o=N(a,``,o,{"--row-top":`${C(r).top??``}px`,"--row-h":`${C(r).height??``}px`})),O(e,a)}),c(de);var pe=U(de,2),me=e=>{var t=HP(),n=I(t);qn(n,{class:`mb-2 h-5 w-5 text-faint-foreground`});var r=U(n,2),a=K(r,!0);c(t),G(()=>m(a,C(i).noObjects)),O(e,t)},he=e=>{var t=HP(),n=I(t);Nt(n,{class:`mb-2 h-5 w-5 text-faint-foreground`});var r=U(n,2),a=K(r,!0);c(t),G(e=>m(a,e),[()=>C(i).noResultsFor.replace(`{query}`,C(h))]),O(e,t)};t(pe,e=>{C(v).length===0?e(me):C(y).size===0&&e(he,1)}),c(Y),c(L),G(()=>{H(re,`placeholder`,C(i).searchObjects),H(ae,`title`,C(w)?C(i).expandAll:C(i).collapseAll),H(ae,`aria-label`,C(w)?C(i).expandAll:C(i).collapseAll),X=N(de,``,X,{"--list-h":`${C(D)??``}px`})}),f(`mousedown`,L,()=>n.outliner.selection.clear()),ue(re,()=>C(h),e=>P(h,e)),f(`click`,ae,()=>C(w)?S():x()),j(`scroll`,Y,e=>P(k,e.currentTarget.scrollTop,!0)),oe(Y,`clientHeight`,e=>P(A,e)),O(e,L),b()}ce([`mousedown`,`click`,`keydown`]);var GP=D(`<span class="inset-0 pointer-events-none absolute grid place-items-center text-foreground" aria-hidden="true"><!></span>`),KP=D(`<button><!></button>`),qP=D(`<!> <!>`,1),JP=D(`<!> <!> <!>`,1),YP=D(`<div><!></div>`),XP=D(`<div><button><!></button></div>`),ZP=D(`<!> `,1),QP=D(`<!> <div class="gap-1 px-1 pb-1 grid grid-cols-4"></div> <!> <!> <!> <!> <!> <!>`,1),$P=D(`<div role="status" class="text-xs font-medium px-2.5 py-1 shadow-md pointer-events-none absolute left-1/2 z-50 -translate-x-1/2 rounded-md border border-border-strong bg-card text-foreground"> </div>`),eF=D(`<div role="toolbar" tabindex="-1"><!> <div class="gap-0.5 mx-auto flex w-max items-center"><!> <!> <div><button><!></button></div> <div><button><!></button></div> <!> <div><!></div></div></div> <!>`,1);function tF(e,n){V(n,!0);let r=J(n,`hidden`,3,!1),i=new xe(`(pointer: coarse)`),o=new xe(`(prefers-reduced-motion: reduce)`),s=T(()=>i.current?{w:44,h:44}:{w:56,h:5}),l=T(()=>i.current?54:42),d=Z(void 0),h=Z(0),g=Z(!1),_=Z(!1),v=Z(0),y=Z(!1),x,w=T(()=>C(g)||C(v)>0||C(y)),D=T(()=>i.current?`max(1rem,env(safe-area-inset-bottom))`:`0.75rem`),k=T(()=>{let e=C(w)?`width:${C(h)+8+2}px;height:${C(l)}px;border-radius:12px;padding:4px`:`width:${C(s).w}px;height:${C(s).h}px;border-radius:${i.current?22:99}px;padding:0px`,t=`bottom:${C(D)};${e}`;if(o.current)return t;let n=C(w)?420:C(_)?130:170,r=C(w)||C(_)?0:20;return`${t};transition:${[`width`,`height`,`border-radius`,`padding`].map(e=>`${e} ${n}ms cubic-bezier(0.32, 0.72, 0, 1) ${r}ms`).join(`,`)},opacity 200ms ease`}),A=e=>{if(o.current)return`opacity:${+!!C(w)}`;let t=110+e*35;return C(w)?`opacity:1;transform:none;transition:opacity 240ms ease ${t}ms,transform 420ms cubic-bezier(0.34,1.45,0.5,1) ${t}ms`:`opacity:0;transform:translateY(6px) scale(0.85);transition:opacity 100ms ease,transform 100ms ease`},M=T(()=>`opacity:${i.current&&!C(w)?1:0};${o.current?``:`transition:opacity ${C(w),100}ms ease ${C(w)||C(_)?0:60}ms`}`);function ee(e=150){clearTimeout(x),x=setTimeout(()=>P(g,!1),e)}function te(){P(g,!0),P(_,!1),clearTimeout(x)}function ne(e){if(!C(d)||i.current||e.pointerType===`touch`||e.buttons)return;let t=C(d).offsetParent;if(!t||!(e.target instanceof Node)||!t.contains(e.target)){C(g)&&ee();return}let n=C(d).getBoundingClientRect();e.clientY>n.top-36&&Math.abs(e.clientX-(n.left+n.width/2))<110?te():C(g)&&ee()}function L(e){C(g)&&C(d)&&e.target instanceof Node&&(C(d).contains(e.target)||(clearTimeout(x),P(_,!0),P(g,!1)))}function re(){C(w)||te()}let B=Z(null),ie,ae,W=!1;function se(e){if(e.pointerType!==`touch`||!C(w)||!(e.target instanceof Element))return;let t=e.target.closest(`button[aria-label]`);t&&(clearTimeout(ie),ie=setTimeout(()=>{P(B,(t.getAttribute(`aria-label`)??``).replace(/\s*\([A-Z]\)$/,``),!0),W=!0},450))}function ce(){clearTimeout(ie),C(B)&&(clearTimeout(ae),ae=setTimeout(()=>P(B,null),1200))}function q(e){W&&(W=!1,e.preventDefault(),e.stopPropagation())}function le(e){P(v,C(v)+(e?1:-1)),!e&&!i.current&&ee(250)}let Y=T(()=>[n.showDisplay&&`look`,n.showSceneManager&&`scene`,`measure`,`fit`,n.showFullscreen&&`full`,`more`].filter(Boolean)),ue=e=>C(Y).indexOf(e),X=`relative grid size-8.5 shrink-0 place-items-center rounded-lg text-foreground outline-none transition-colors hover:bg-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-pressed:text-foreground data-[state=open]:bg-selected data-[state=open]:text-foreground pointer-coarse:size-11`;var pe=eF();j(`pointermove`,de,ne),j(`pointerdown`,de,L);var he=z(pe),ge=I(he),_e=e=>{var t=GP();Rr(I(t),{class:`size-5`}),c(t),G(()=>N(t,C(M))),O(e,t)};t(ge,e=>{i.current&&e(_e)});var ve=U(ge,2),ye=I(ve),be=e=>{var t=YP(),r=I(t);E(r,()=>Ge,(e,t)=>{t(e,{onOpenChange:le,children:(e,t)=>{var r=qP(),i=z(r);{let e=(e,t)=>{let r=()=>(t?.()).props;var i=KP();R(i,()=>({...r(),class:X,title:n.t.display,"aria-label":n.t.display})),Er(I(i),{class:`size-4.5`}),c(i),O(e,i)};E(i,()=>Xe,(t,n)=>{n(t,{child:e,$$slots:{child:!0}})})}var o=U(i,2);E(o,()=>Je,(e,t)=>{t(e,{side:`top`,align:`center`,sideOffset:12,variant:`glass`,class:`min-w-52 z-10001 w-auto whitespace-nowrap`,children:(e,t)=>{var r=JP(),i=z(r);E(i,()=>mo,(e,t)=>{t(e,{get value(){return n.renderStyle},onValueChange:e=>n.onSetLook(e),children:(e,t)=>{var r=u(),i=z(r);a(i,17,()=>n.styleOptions,({look:e,label:t})=>e,(e,t)=>{let n=()=>C(t).look,r=()=>C(t).label;var i=u(),a=z(i);E(a,()=>_o,(e,t)=>{t(e,{get value(){return n()},closeOnSelect:!1,children:(e,t)=>{S();var n=p();G(()=>m(n,r())),O(e,n)},$$slots:{default:!0}})}),O(e,i)}),O(e,r)},$$slots:{default:!0}})});var o=U(i,2);E(o,()=>Ve,(e,t)=>{t(e,{})});var s=U(o,2);E(s,()=>co,(e,t)=>{t(e,{switch:!0,get checked(){return n.edgesVisible},get onCheckedChange(){return n.onToggleEdges},children:(e,t)=>{var r=qP(),i=z(r);Vr(i,{});var a=U(i),o=U(a);E(o,()=>bo,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p(`E`);O(e,n)},$$slots:{default:!0}})}),G(()=>m(a,` ${n.t.edges??``} `)),O(e,r)},$$slots:{default:!0}})}),O(e,r)},$$slots:{default:!0}})}),O(e,r)},$$slots:{default:!0}})}),c(t),G(e=>N(t,e),[()=>A(ue(`look`))]),O(e,t)};t(ye,e=>{n.showDisplay&&e(be)});var Se=U(ye,2),Ce=e=>{var t=XP(),r=I(t);fe(r,1,`relative grid size-8.5 shrink-0 place-items-center rounded-lg text-foreground outline-none transition-colors hover:bg-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-pressed:text-foreground data-[state=open]:bg-selected data-[state=open]:text-foreground pointer-coarse:size-11 aria-pressed:after:absolute aria-pressed:after:bottom-0.5 aria-pressed:after:size-1 aria-pressed:after:rounded-full aria-pressed:after:bg-primary`),cr(I(r),{class:`size-4.5`}),c(r),c(t),G(e=>{N(t,e),H(r,`title`,`${n.t.sceneManager??``} (S)`),H(r,`aria-label`,n.t.sceneManager),H(r,`aria-pressed`,n.sceneManagerOpen)},[()=>A(ue(`scene`))]),f(`click`,r,function(...e){n.onToggleSceneManager?.apply(this,e)}),O(e,t)};t(Se,e=>{n.showSceneManager&&e(Ce)});var we=U(Se,2),Te=I(we);fe(Te,1,`relative grid size-8.5 shrink-0 place-items-center rounded-lg text-foreground outline-none transition-colors hover:bg-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring aria-pressed:text-foreground data-[state=open]:bg-selected data-[state=open]:text-foreground pointer-coarse:size-11 aria-pressed:after:absolute aria-pressed:after:bottom-0.5 aria-pressed:after:size-1 aria-pressed:after:rounded-full aria-pressed:after:bg-primary`),Mr(I(Te),{class:`size-4.5`}),c(Te),c(we);var Ee=U(we,2),De=I(Ee);fe(De,1,me(X)),_r(I(De),{class:`size-4.5`}),c(De),c(Ee);var Oe=U(Ee,2),ke=e=>{var r=XP(),i=I(r);fe(i,1,me(X));var a=I(i),o=e=>{Cr(e,{class:`size-4.5`})},s=e=>{br(e,{class:`size-4.5`})};t(a,e=>{n.isFullscreen?e(o):e(s,-1)}),c(i),c(r),G(e=>{N(r,e),H(i,`title`,n.isFullscreen?n.t.exitFullscreen:n.t.fullscreen),H(i,`aria-label`,n.isFullscreen?n.t.exitFullscreen:n.t.fullscreen)},[()=>A(ue(`full`))]),f(`click`,i,function(...e){n.onToggleFullscreen?.apply(this,e)}),O(e,r)};t(Oe,e=>{n.showFullscreen&&e(ke)});var Ae=U(Oe,2),je=I(Ae);E(je,()=>Ge,(e,r)=>{r(e,{onOpenChange:le,children:(e,r)=>{var i=qP(),o=z(i);{let e=(e,t)=>{let r=()=>(t?.()).props;var i=KP();R(i,()=>({...r(),class:X,title:n.t.toolsMenu,"aria-label":n.t.toolsMenu}));var a=I(i);bt(a,{class:`size-4.5`}),c(i),O(e,i)};E(o,()=>Xe,(t,n)=>{n(t,{child:e,$$slots:{child:!0}})})}var s=U(o,2);E(s,()=>Je,(e,r)=>{r(e,{side:`top`,align:`end`,sideOffset:12,variant:`glass`,class:`min-w-60 z-10001 w-auto whitespace-nowrap`,children:(e,r)=>{var i=QP(),o=z(i);E(o,()=>fo,(e,t)=>{t(e,{children:(e,t)=>{S();var r=p();G(()=>m(r,n.t.views)),O(e,r)},$$slots:{default:!0}})});var s=U(o,2);a(s,21,()=>n.viewPresets,({preset:e,label:t})=>e,(e,t)=>{let r=()=>C(t).preset,i=()=>C(t).label;var a=u(),o=z(a);E(o,()=>He,(e,t)=>{t(e,{closeOnSelect:!1,onSelect:()=>n.onSetView(r()),variant:`chip`,children:(e,t)=>{S();var n=p();G(()=>m(n,i())),O(e,n)},$$slots:{default:!0}})}),O(e,a)}),c(s);var l=U(s,2);E(l,()=>Ve,(e,t)=>{t(e,{})});var d=U(l,2);{let e=T(()=>n.projection===`orthographic`);E(d,()=>co,(t,r)=>{r(t,{switch:!0,get checked(){return C(e)},get onCheckedChange(){return n.onToggleProjection},children:(e,t)=>{var r=qP(),i=z(r);Rn(i,{});var a=U(i),o=U(a);E(o,()=>bo,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p(`O`);O(e,n)},$$slots:{default:!0}})}),G(()=>m(a,` ${n.t.switchToOrthographic??``} `)),O(e,r)},$$slots:{default:!0}})})}var f=U(d,2),h=e=>{var t=u(),r=z(t);E(r,()=>co,(e,t)=>{t(e,{switch:!0,get checked(){return n.gridVisible},get onCheckedChange(){return n.onToggleGrid},children:(e,t)=>{var r=qP(),i=z(r);nr(i,{});var a=U(i),o=U(a);E(o,()=>bo,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p(`G`);O(e,n)},$$slots:{default:!0}})}),G(()=>m(a,` ${n.t.grid??``} `)),O(e,r)},$$slots:{default:!0}})}),O(e,t)};t(f,e=>{n.showGrid&&e(h)});var g=U(f,2),_=e=>{var t=u(),r=z(t);E(r,()=>co,(e,t)=>{t(e,{switch:!0,get checked(){return n.nightOn},get onCheckedChange(){return n.onToggleNight},children:(e,t)=>{var r=qP(),i=z(r);Qe(i,{});var a=U(i),o=U(a);E(o,()=>bo,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p(`N`);O(e,n)},$$slots:{default:!0}})}),G(()=>m(a,` ${n.t.nightMode??``} `)),O(e,r)},$$slots:{default:!0}})}),O(e,t)};t(g,e=>{n.showDisplay&&e(_)});var v=U(g,2),y=e=>{var t=u(),n=z(t);E(n,()=>Ve,(e,t)=>{t(e,{})}),O(e,t)};t(v,e=>{n.showScreenshot&&e(y)});var b=U(v,2),x=e=>{var t=u(),r=z(t);E(r,()=>He,(e,t)=>{t(e,{get onSelect(){return n.onScreenshot},children:(e,t)=>{var r=ZP(),i=z(r);kn(i,{});var a=U(i);G(()=>m(a,` ${n.t.screenshot??``}`)),O(e,r)},$$slots:{default:!0}})}),O(e,t)};t(b,e=>{n.showScreenshot&&e(x)}),O(e,i)},$$slots:{default:!0}})}),O(e,i)},$$slots:{default:!0}})}),c(Ae),c(ve),c(he),F(he,e=>P(d,e),()=>C(d));var Me=U(he,2),Ne=e=>{var t=$P(),n=K(t,!0);G(()=>{N(t,`bottom:calc(${C(D)??``} + ${C(l)+8}px)`),m(n,C(B))}),O(e,t)};t(Me,e=>{C(B)&&e(Ne)}),G((e,t,a)=>{H(he,`aria-label`,n.t.toolsMenu),fe(he,1,`backdrop-blur-md absolute left-1/2 z-50 -translate-x-1/2 overflow-hidden transition-colors select-none ${r()?`pointer-events-none opacity-0`:``} ${C(w)?`shadow-md border border-border-strong bg-card/75`:i.current?`shadow-lg cursor-pointer border border-border bg-background/90`:n.nightOn?`border-white/25 bg-white/35 hover:bg-white/70 cursor-pointer border`:`shadow-sm cursor-pointer border border-border-strong bg-card/90 hover:bg-card`}`),N(he,`${C(k)??``};-webkit-touch-callout:none`),ve.inert=!C(w),N(we,e),H(Te,`title`,`${n.t.measure??``} (M)`),H(Te,`aria-label`,n.t.measure),H(Te,`aria-pressed`,n.measureActive),N(Ee,t),H(De,`title`,`${n.t.fitToView??``} (F)`),H(De,`aria-label`,`${n.t.fitToView??``} (F)`),N(Ae,a)},[()=>A(ue(`measure`)),()=>A(ue(`fit`)),()=>A(ue(`more`))]),f(`click`,he,re),f(`keydown`,he,e=>e.key===`Escape`?P(g,!1):void 0),f(`focusin`,he,()=>P(y,!0)),f(`focusout`,he,e=>{C(d)?.contains(e.relatedTarget)||P(y,!1)}),f(`pointerdown`,he,se),f(`pointerup`,he,ce),j(`pointercancel`,he,ce),j(`click`,he,q,!0),f(`contextmenu`,he,e=>i.current&&e.preventDefault()),f(`click`,Te,function(...e){n.onToggleMeasure?.apply(this,e)}),f(`click`,De,function(...e){n.onFit?.apply(this,e)}),oe(ve,`offsetWidth`,e=>P(h,e)),O(e,pe),b()}ce([`click`,`keydown`,`focusin`,`focusout`,`pointerdown`,`pointerup`,`contextmenu`]);var nF=D(`<p class="px-4 py-3 text-xs text-muted-foreground"> </p>`),rF=D(`<div class="gap-2 flex"><span class="shrink-0 text-muted-foreground"> </span> <span> </span></div>`),iF=D(`<div class="space-y-0.5"></div>`),aF=D(`<div> </div>`),oF=D(`<div class="space-y-1 text-left"></div>`),sF=D(`<div class="space-y-0.5 text-left"></div>`),cF=D(`<span class="font-mono"> </span>`),lF=D(`<span> </span>`),uF=D(`<span class="break-all"> </span>`),dF=D(`<tr class="border-b border-border last:border-b-0"><th scope="row" class="px-4 py-2 font-normal text-left align-top whitespace-nowrap text-muted-foreground"> </th><td class="px-4 py-2 text-right align-top text-foreground"><!></td></tr>`),fF=D(`<table class="text-xs w-full border-collapse"><tbody></tbody></table>`),pF=D(`<section><header class="gap-2 py-1 pr-1 pl-4 flex items-center border-b"><h2 class="text-sm font-semibold min-w-0 flex-1 truncate"> </h2> <!></header> <div class="min-h-0 overflow-y-auto overscroll-contain"><!></div></section>`);function mF(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),o=new Set([`name`,`layer`,`id`]),s=J(n,`class`,3,``),l=T(()=>{let e={};for(let[t,r]of Object.entries(n.metadata))o.has(t)||(t===`metadata`&&typeof r==`object`&&r&&!Array.isArray(r)?Object.assign(e,r):e[t]=r);return e});var d=pF(),f=I(d),p=I(f),h=K(p,!0),g=U(p,2);tt(g,{variant:`ghost`,size:`icon-sm`,class:`pointer-coarse:size-10 shrink-0`,get"aria-label"(){return C(i).close},get title(){return C(i).close},get onclick(){return n.onClose},children:(e,t)=>{Lt(e,{})},$$slots:{default:!0}}),c(f);var _=U(f,2),v=I(_),x=e=>{var t=nF(),n=K(t,!0);G(()=>m(n,C(i).noMetadata)),O(e,t)},S=T(()=>Object.keys(C(l)).length===0),E=e=>{var n=fF(),r=I(n);a(r,21,()=>Object.entries(C(l)),([e,t])=>e,(e,n)=>{var r=T(()=>w(C(n),2));let i=()=>C(r)[0],o=()=>C(r)[1];var s=dF(),l=I(s),d=K(l,!0),f=U(l),p=I(f),h=e=>{var n=u(),r=z(n),i=e=>{var n=oF();a(n,21,o,y,(e,n)=>{var r=u(),i=z(r),o=e=>{var t=iF();a(t,21,()=>Object.entries(C(n)),([e,t])=>e,(e,t)=>{var n=T(()=>w(C(t),2));let r=()=>C(n)[0],i=()=>C(n)[1];var a=rF(),o=I(a),s=K(o),l=U(o,2),u=K(l,!0);c(a),G(()=>{m(s,`${r()??``}:`),m(u,i())}),O(e,a)}),c(t),O(e,t)},s=e=>{var t=aF(),r=K(t,!0);G(()=>m(r,C(n))),O(e,t)};t(i,e=>{typeof C(n)==`object`?e(o):e(s,-1)}),O(e,r)}),c(n),O(e,n)},s=T(()=>Array.isArray(o())),l=e=>{var t=sF();a(t,21,()=>Object.entries(o()),([e,t])=>e,(e,t)=>{var n=T(()=>w(C(t),2));let r=()=>C(n)[0],i=()=>C(n)[1];var a=rF(),o=I(a),s=K(o),l=U(o,2),u=K(l,!0);c(a),G(()=>{m(s,`${r()??``}:`),m(u,i())}),O(e,a)}),c(t),O(e,t)};t(r,e=>{C(s)?e(i):e(l,-1)}),O(e,n)},g=e=>{var t=cF(),n=K(t,!0);G(()=>m(n,o())),O(e,t)},_=e=>{var t=lF(),n=K(t,!0);G(()=>{fe(t,1,me(o()?`text-success`:`text-muted-foreground`)),m(n,o()?`true`:`false`)}),O(e,t)},v=e=>{var t=uF(),n=K(t,!0);G(()=>m(n,o())),O(e,t)};t(p,e=>{typeof o()==`object`&&o()!==null?e(h):typeof o()==`number`?e(g,1):typeof o()==`boolean`?e(_,2):e(v,-1)}),c(f),c(s),G(()=>m(d,i())),O(e,s)}),c(r),c(n),O(e,n)};t(v,e=>{C(S)?e(x):e(E,-1)}),c(_),c(d),G(()=>{H(d,`aria-label`,n.meshName??C(i).objectFallbackName),fe(d,1,`min-h-0 shadow-lg backdrop-blur-sm flex flex-col overflow-hidden rounded-lg border bg-background/95 ${s()??``}`),m(h,n.meshName??C(i).objectFallbackName)}),O(e,d),b()}var hF=yF,gF=bF;function _F(e,t){return hF(e,t)}function vF(e){return gF(e)}async function yF(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);return r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4),!0}function bF({accept:e}){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.style.display=`none`;let r=e=>{n.remove(),t(e)};n.addEventListener(`change`,()=>r(n.files?.[0]??null),{once:!0}),n.addEventListener(`cancel`,()=>r(null),{once:!0}),document.body.appendChild(n),n.click()})}var xF=D(`<div><img alt="" class="h-10 max-w-40 drop-shadow-sm sm:h-14 sm:max-w-56 w-auto object-contain opacity-80"/></div>`),SF=D(`<div class="relative h-full w-full touch-none"><canvas class="viewer-canvas block h-full w-full outline-none select-none svelte-24hiu0" data-testid="viewer-canvas"></canvas> <div></div> <!> <!> <!></div>`),CF=D(`<!> <!>`,1),wF=D(`<div><!></div>`);function TF(e,n){V(n,!0);let r={showScreenshotButton:!0,showFullscreenButton:!0,showSceneManager:!0,showToolsMenu:!0,showGridToggle:!0,showDisplayMenu:!0,enableMeshClick:!0,backgroundColor:`#E6E6E6`,look:`technical`,showEdges:!1},i=J(n,`isFullscreen`,15,!1),a=J(n,`isBlurred`,3,!1),o=J(n,`drawerOpen`,3,!1),s=J(n,`viewerConfig`,19,()=>({})),l=T(()=>({...r,...s()})),u=rt(()=>n.lang),d=T(()=>u.messages),p,m=Z(null),h=null,g=null,v=null,y=null,x=null,S=null,w=null,D=null,k=null,A=null,j=null,M=null,N=null,ee=null,ne=null,L=null,R=null,re=!1,ie=Z(0),ae=Z(!1),W=Z(!1),oe=new ye,se=new ye,ce=new ye,q=Z(null),ue=Z(`perspective`),de=Z(!1),X=Z(!1),pe=Y(()=>{let e=s().look;return e&&FT.includes(e)?e:r.look}),me=Eb[pe].requiresEdges===!0,he=Y(()=>s().showEdges)??r.showEdges,ge=Z(B(pe)),_e=Z(B(me||he)),ve=Z(null),be=Z(null),xe=T(()=>({technical:C(d).lookTechnical,studio:C(d).lookStudio,showcase:C(d).lookShowcase,arctic:C(d).lookArctic,xray:C(d).lookXray,lineart:C(d).lookLineart,wireframe:C(d).lookWireframe,night:C(d).lookNight})),Se=T(()=>FT.filter(e=>e!==`night`).map(e=>({look:e,label:C(xe)[e]??e.charAt(0).toUpperCase()+e.slice(1)}))),Ce=T(()=>C(ge)===`night`),we=Z(B(pe===`night`?r.look:pe)),Te=[{preset:`top`,label:()=>C(d).viewTop},{preset:`front`,label:()=>C(d).viewFront},{preset:`right`,label:()=>C(d).viewRight},{preset:`back`,label:()=>C(d).viewBack},{preset:`left`,label:()=>C(d).viewLeft},{preset:`bottom`,label:()=>C(d).viewBottom},{preset:`iso`,label:()=>C(d).viewIso}];le(()=>{if(o())P(ae,!0);else{let e=setTimeout(()=>{P(ae,!1)},rl.TIMEOUTS.DRAWER_ANIMATION_MS);return()=>clearTimeout(e)}}),_(()=>{if(!p)return;let e={look:C(ge),environment:{backgroundColor:C(l).backgroundColor},grid:{enabled:C(l).showToolsMenu&&C(l).showGridToggle},measure:{enabled:C(l).showToolsMenu},events:{onObjectSelected:Le,onBackgroundClicked:Le,onMeshMetadataClicked:C(l).enableMeshClick?e=>{He(e)&&(P(ve,e,!0),P(be,String(e?.name??``)||C(d).objectFallbackName,!0))}:void 0}},t=qk(p,e);P(m,t.scene,!0),P(q,hA(t.scene,{sets:{hidden:oe,selected:se,collapsed:ce}}),!0),h=t.camera,g=t.controls,v=t.cameraController,y=t.measureTool,x=t.grid,x?.setVisible(C(X)),S=t.applyEdges,w=t.clearEdges,D=t.invalidate,k=t.captureImage,A=t.setLook,j=t.syncEmissiveLights,M=t.updateGridScale,N=t.updateShadowBounds,ee=t.fitToView,ne=t.clearSelection,L=t.selectEntries,R=t.setHover,P(ue,t.cameraController.getProjection(),!0);let r=Y(()=>n.onViewerReady?.(t));return()=>{r?.(),t.dispose(),nP()}});function Ee(){v&&P(ue,v.toggleProjection(),!0)}function De(e){v?.setView(e)}function Oe(){y&&(P(de,!C(de)),y.setEnabled(C(de)))}function ke(){x&&(P(X,!C(X)),x.setVisible(C(X)),D?.())}let Ae=me?he:null;function je(e){if(!A||e===C(ge))return;let t=Eb[C(ge)].requiresEdges===!0;P(ge,e,!0),e!==`night`&&P(we,e,!0),A(e),Eb[e].requiresEdges?(t||(Ae=C(_e)),C(_e)?!t&&C(m)&&w?.(C(m)):P(_e,!0),Ne()):t&&Ae!==null?(P(_e,Ae,!0),C(_e)&&C(m)&&w?.(C(m)),Ne(),Ae=null):C(_e)&&C(m)&&(w?.(C(m)),Ne())}function Me(){return Eb[C(ge)].requiresEdges?{distanceFade:!1,maxOverlays:2e4,color:1711393}:void 0}function Ne(){C(m)&&(C(_e)?S?.(C(m),Me()):w?.(C(m)))}function Pe(){je(C(Ce)?C(we):`night`)}function Fe(){P(_e,!C(_e)),Eb[C(ge)].requiresEdges&&(Ae=null),Ne()}le(()=>{if(C(m)&&h&&g&&(jE(C(m),n.meshes,h,g,re),Y(()=>{A?.(C(ge),{deferEmissiveLights:!0}),C(_e)&&S?.(C(m),Me()),M?.(),N?.(),C(q)?.applyTo(),j?.(),te(ie),D?.()}),!re&&n.meshes.length>0)){re=!0;let e=Y(()=>C(l).camera);e&&v?.setCameraView(e)}});function Ie(){P(ve,null),P(be,null)}function Le(){Ie(),se.clear()}le(()=>{if(se.size===0){L?.([]);return}let e=C(q)?.entries().filter(e=>se.has(e.key))??[];Ie(),L?.(e.flatMap(e=>e.parts))});function Re(){Ie(),ne?.(),D?.()}le(()=>{n.meshes,Y(Ie)}),le(()=>(document.body.toggleAttribute(`data-viewer-fullscreen`,i()),()=>document.body.removeAttribute(`data-viewer-fullscreen`)));function ze(){i(!i())}let Be={o:Ee,m:Oe,g:ke,n:Pe,e:Fe,s:()=>P(W,!C(W))};function Ve(e){if(e.ctrlKey||e.metaKey||e.altKey||e.repeat||e.target.closest(`input, textarea, select, [contenteditable]`))return;let t=Be[e.key.toLowerCase()];t&&(e.preventDefault(),t())}function He(e){if(!e)return!1;if(e.metadata&&typeof e.metadata==`object`){let t=e.metadata;return Object.keys(t).length>0}let t=new Set([`name`,`layer`,`id`,`vertexCount`,`faceCount`,`vertexOffset`,`faceOffset`]);return Object.entries(e).filter(([e])=>!t.has(e)).length>0}async function Ue(){let e=await k?.();e&&await _F(e,`viewer-${new Date().toISOString().slice(0,19).replace(/:/g,`-`)}.png`)}var We=wF(),Ge=I(We);E(Ge,()=>Yc,(e,r)=>{r(e,{direction:`horizontal`,class:`h-full w-full`,children:(e,r)=>{var o=CF(),s=z(o);{let e=T(()=>C(W)?85:100);E(s,()=>Vc,(r,o)=>{o(r,{id:`viewport`,order:1,get defaultSize(){return C(e)},minSize:40,children:(e,r)=>{var o=SF(),s=I(o);F(s,e=>p=e,()=>p);var u=U(s,2),f=U(u,2),m=e=>{var t=xF(),r=K(t);G(()=>{fe(t,1,`right-4 bottom-4 pointer-events-none absolute z-20 ${C(ae)?`opacity-0`:``}`),H(r,`src`,n.logoUrl)}),O(e,t)};t(f,e=>{n.logoUrl&&e(m)});var h=U(f,2),g=e=>{mF(e,{get metadata(){return C(ve)},get meshName(){return C(be)},onClose:Re,class:`top-3 right-3 left-3 sm:right-auto sm:max-h-2/3 sm:w-72 absolute z-30 max-h-1/2`})};t(h,e=>{C(ve)&&e(g)});var _=U(h,2),v=e=>{{let t=T(()=>Te.map(({preset:e,label:t})=>({preset:e,label:t()})));tF(e,{get t(){return C(d)},get hidden(){return C(ae)},get showDisplay(){return C(l).showDisplayMenu},get showGrid(){return C(l).showGridToggle},get showSceneManager(){return C(l).showSceneManager},get showScreenshot(){return C(l).showScreenshotButton},get showFullscreen(){return C(l).showFullscreenButton},get styleOptions(){return C(Se)},get viewPresets(){return C(t)},get renderStyle(){return C(ge)},get nightOn(){return C(Ce)},get edgesVisible(){return C(_e)},get measureActive(){return C(de)},get gridVisible(){return C(X)},get sceneManagerOpen(){return C(W)},get projection(){return C(ue)},get isFullscreen(){return i()},onSetLook:je,onToggleNight:Pe,onToggleEdges:Fe,onToggleMeasure:Oe,onToggleGrid:ke,onToggleSceneManager:()=>P(W,!C(W)),onToggleProjection:Ee,onSetView:De,onFit:()=>ee?.(),onScreenshot:Ue,onToggleFullscreen:ze})}};t(_,e=>{C(l).showToolsMenu&&e(v)}),c(o),G(()=>{H(s,`data-mesh-count`,n.meshes.length),fe(u,1,`inset-0 blur-overlay absolute z-20 ${a()?`blur-overlay-active`:`blur-overlay-inactive`}`,`svelte-24hiu0`)}),O(e,o)},$$slots:{default:!0}})})}var u=U(s,2),f=e=>{var t=CF(),n=z(t);E(n,()=>qc,(e,t)=>{t(e,{withHandle:!0})});var r=U(n,2);E(r,()=>Vc,(e,t)=>{t(e,{id:`scene-manager`,order:2,defaultSize:15,minSize:8,maxSize:30,children:(e,t)=>{WP(e,{get outliner(){return C(q)},get sceneVersion(){return C(ie)},onVisibilityChange:()=>j?.(),onHover:e=>R?.(e?.parts??null)})},$$slots:{default:!0}})}),O(e,t)};t(u,e=>{C(W)&&C(m)&&C(q)&&e(f)}),O(e,o)},$$slots:{default:!0}})}),c(We),G(()=>fe(We,1,`min-h-64 sm:min-h-96 lg:min-h-125 relative h-full flex-1 border ${i()?`fullscreen-viewer`:`overflow-hidden rounded-lg`}`,`svelte-24hiu0`)),f(`keydown`,We,Ve),O(e,We),b()}ce([`keydown`]);var EF=`[Selva:blocked]`,DF=`[Selva:msg]`,OF=`[Selva:log]`,kF=/:\s*component\s+"([^"]*)"\s*\(([0-9a-fA-F-]{36}|\.\.\.)\)\s*$/,AF=`Message`;function jF(e){let t=e.includes(EF),n=!t&&e.includes(`[Selva:log]`),r=t||n||e.includes(`[Selva:msg]`),i=e,a,o=kF.exec(i);return o&&(a=o[1]||void 0,i=i.slice(0,o.index)),r&&(i=i.replace(EF,``).replace(DF,``).replace(OF,``).replace(/^\s*\d+\.\s*Solution exception:\s*/,``)),{message:i.replace(/\s{2,}/g,` `).trim(),source:a,blocked:t,authored:r,logOnly:n}}function MF(e,t){let n=(e,t)=>{let{message:n,source:r,authored:i,logOnly:a}=jF(e),o=(i||r===AF)&&!a;return{level:t,message:n,...r?{source:r}:{},...o?{isGate:o}:{}}};return[...e.map(e=>n(e,`error`)),...t.map(e=>n(e,`warning`))]}function NF(e){return e===`error`||e===`warning`||e===`remark`}function PF(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.message==`string`?t.message.trim():``;if(!n)return null;let r=typeof t.source==`string`&&t.source?t.source:void 0;return{level:NF(t.level)?t.level:`remark`,message:n,...r?{source:r}:{},...t.isGate===!0?{isGate:!0}:{}}}function FF(e,t,n,r){let i=new Set,a=[];for(let t of e){let e=PF(t);if(!e)continue;let n=`${e.level}\u0000${e.message}\u0000${e.source??``}\u0000${e.isGate===!0}`;i.has(n)||(i.add(n),a.push(e))}return{diagnostics:a,blocked:t||n,aborted:n,...r&&r.length>0?{deferred:r}:{}}}function IF(e){if(!e||typeof e!=`object`)return null;let{diagnostics:t,blocked:n,aborted:r,deferred:i}=e,a=Array.isArray(t);if(!a&&n===void 0&&r===void 0)return null;let o=e=>e===!0||e===`true`,s=Array.isArray(i)?i.filter(e=>typeof e==`string`&&e!==``):void 0;return FF(a?t:[],o(n),o(r),s)}function LF(e,t){let n=e=>e.filter(e=>typeof e==`string`),r=n(e);return FF(MF(r,n(t)),r.some(e=>e.includes(EF)),!1)}function RF(e,t){let n=t.blocked||t.aborted,r=n?[]:e.meshes;return{outputs:n?{}:e.outputs,...r===void 0?{}:{meshes:r},errors:t.diagnostics.filter(e=>e.level===`error`).map(e=>e.message),warnings:t.diagnostics.filter(e=>e.level===`warning`).map(e=>e.message),diagnostics:t.diagnostics,blocked:t.blocked,aborted:t.aborted,...t.deferred&&!n?{deferred:t.deferred}:{},...e.source!==void 0&&!n?{source:e.source}:{}}}function zF(e){return e?.layout?e.layout.type===`tabbed`?e.layout.tabs?.flatMap(e=>e.groups??[])??[]:e.layout.type===`flat`?e.layout.groups??[]:[]:[]}function BF(e){return zF(e).flatMap(e=>e.items??[])}function VF(e){return BF(e).filter(e=>e.type===`input`)}function HF(e){switch(e){case`number`:case`integer`:return 0;case`boolean`:return!1;case`text`:return``;default:return null}}function UF(e){return new Set(VF(e).filter(e=>e.source?.kind===`server`).map(e=>e.paramId))}function WF(e,t){return new Promise((n,r)=>{let i=()=>r(t.reason);t.aborted&&i(),t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}var GF=`selva-keepalive`,KF={NETWORK_ERROR:`NETWORK_ERROR`,AUTH_ERROR:`AUTH_ERROR`,VALIDATION_ERROR:`VALIDATION_ERROR`,COMPUTATION_ERROR:`COMPUTATION_ERROR`,TIMEOUT_ERROR:`TIMEOUT_ERROR`,CORS_ERROR:`CORS_ERROR`,NOT_FOUND:`NOT_FOUND`,RATE_LIMIT:`RATE_LIMIT`,INVALID_RESPONSE:`INVALID_RESPONSE`,RESPONSE_TOO_LARGE:`RESPONSE_TOO_LARGE`,UNKNOWN_ERROR:`UNKNOWN_ERROR`,INVALID_STATE:`INVALID_STATE`,INVALID_INPUT:`INVALID_INPUT`,INVALID_CONFIG:`INVALID_CONFIG`,BROWSER_ONLY:`BROWSER_ONLY`,ENVIRONMENT_ERROR:`ENVIRONMENT_ERROR`,ENCODING_ERROR:`ENCODING_ERROR`,MALFORMED_DEFAULT:`MALFORMED_DEFAULT`,SUPERSEDED:`SUPERSEDED`,ABORTED:`ABORTED`,QUEUE_FULL:`QUEUE_FULL`,QUEUE_TIMEOUT:`QUEUE_TIMEOUT`,DEFINITION_NOT_CACHED:`DEFINITION_NOT_CACHED`},qF=class extends Error{code;statusCode;context;originalError;constructor(e,t=KF.UNKNOWN_ERROR,n){let r=n?.originalError,i=r===void 0||r instanceof Error?r:Error(String(r));super(e,i&&{cause:i}),this.name=`ComputeError`,this.code=t,this.statusCode=n?.statusCode,this.context=n?.context,this.originalError=i}},JF={debug(){},info(){},warn(){},error(){}};function YF(){return JF}function XF(e,t){if(!e||typeof e!=`object`)return;if(Object.hasOwn(e,t))return t;let n=t.toLowerCase();return Object.keys(e).find(e=>e.toLowerCase()===n)}function ZF(e,t){let n=XF(e,t);return n===void 0?void 0:e[n]}function QF(e,t){return XF(e,t)!==void 0}var $F=`<unreadable URL>`;function eI(e){try{let t=new URL(e);return t.host?t:null}catch{return null}}function tI(e){let t=eI(e);return t?(t.username=``,t.password=``,t.search=``,t.hash=``,t.href):$F}function nI(e){try{return JSON.parse(e)}catch{return}}function rI(){let e=globalThis.Buffer;return typeof e==`function`?e:void 0}function iI(e){let t=e.replace(/[\t\n\f\r ]/g,``);return t.length%4==0&&(t=t.replace(/={1,2}$/,``)),t.length%4==1?null:t}function aI(e){let t=iI(e),n=t===null?null:oI(t);if(n===null)throw new qF(`Invalid base64 input.`,KF.ENCODING_ERROR,{context:{inputLength:e.length}});return n}function oI(e){let t=rI();if(t){if(t.byteLength(e,`utf8`)!==e.length||e.includes(`-`)||e.includes(`_`))return null;let n=t.from(e,`base64`);return n.length===Math.floor(e.length*3/4)?n.byteOffset===0&&n.buffer.byteLength===n.length?new Uint8Array(n.buffer,0,n.length):new Uint8Array(n):null}if(typeof globalThis.atob==`function`){let t;try{t=globalThis.atob(e)}catch{return null}let n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e)&255;return n}throw new qF(`Base64 decoding not supported in this environment.`,KF.ENVIRONMENT_ERROR,{context:{environmentInfo:`atob or Buffer not available`}})}KF.VALIDATION_ERROR,KF.AUTH_ERROR,KF.AUTH_ERROR,KF.NOT_FOUND,KF.VALIDATION_ERROR,KF.RATE_LIMIT,KF.COMPUTATION_ERROR,KF.NETWORK_ERROR,KF.NETWORK_ERROR,KF.NETWORK_ERROR;var sI=e=>(e??``).replace(/::/g,`/`).replace(/\\/g,`/`).split(`/`).map(e=>e.trim()).filter(e=>e!==``),cI=e=>sI(e.subFolder)[0]??``,lI=e=>sI(e.subFolder).slice(1).join(`/`),uI=e=>{let t=new Map;for(let n of e){let e=cI(n),r=t.get(e);r?r.push(n):t.set(e,[n])}return Array.from(t,([e,t])=>({root:e,files:t}))},dI=e=>{let t=e.replace(/[/\\:*?"<>|]/g,`_`).replace(/\s+/g,` `).trim().replace(/^\.+/,``);return t===``?`files`:t},fI=async(e,t=null)=>{let n=vI(e);if(t){let e=Array.isArray(t)?t:[t];n.push(...await bI(e))}let r=new Set;return n.map(e=>{let t=SI(e.path,r);return r.add(t),t===e.path?e:(YF().warn(`Duplicate archive path "${e.path}" — storing as "${t}".`),{...e,path:t,fileName:t.slice(t.lastIndexOf(`/`)+1)})})},pI=async(e,t,n=null,r={})=>{if(typeof document>`u`||typeof Blob>`u`)throw new qF(`File download functionality is only available in browser environments. This function requires the DOM API (document, Blob).`,KF.BROWSER_ONLY,{context:{environment:typeof window<`u`?`browser (SSR)`:`Node.js`,documentAvailable:typeof document<`u`,blobAvailable:typeof Blob<`u`}});try{await xI(await fI(e,n),t,r.saveBlob??CI)}catch(n){throw n instanceof qF?n:new qF(`Failed to download files from compute response`,KF.INVALID_STATE,{context:{fileCount:e.length,zipName:t},originalError:n})}},mI=async(e,t,n=null,r={})=>{let i=uI(e);if(i.length===0){await pI([],t,n,r);return}let a=(i.find(e=>e.root===``)??i[0]).root;for(let{root:e,files:o}of i)await pI(e===``?o:o.map(e=>({...e,subFolder:lI(e)})),e===``?t:dI(e),e===a?n:null,r)},hI=e=>sI(e).filter(e=>e!==`.`&&e!==`..`&&!/^[a-zA-Z]:/.test(e)).join(`/`),gI=e=>e===!0||typeof e==`string`&&e.trim().toLowerCase()===`true`,_I=(e,t)=>e===``?t:`${e}/${t}`,vI=e=>{let t=[];return e.forEach(e=>{let n=ZF(e,`fileName`)??``,r=ZF(e,`fileType`)??``,i=hI(`${n}${r}`);if(i===``){YF().warn(`Skipping file with unusable name "${n}${r}": no safe archive path remains after sanitization.`);return}let a=ZF(e,`subFolder`),o=a?hI(a):``,s=_I(o,i),c=ZF(e,`data`);if(typeof c!=`string`||c===``){YF().warn(`Skipping file "${s}": item carries no usable data.`);return}let l=c;if(gI(ZF(e,`isBase64Encoded`)))try{l=aI(c)}catch(e){YF().warn(`Skipping file "${s}": base64 decode failed.`,e);return}let u=ZF(e,`metadata`);t.push({fileName:i,content:l,path:s,subFolder:o,...u?{metadata:u}:{}})}),t},yI=3e4,bI=async e=>(await Promise.all(e.map(async e=>{try{let t=await fetch(e.filePath,{signal:AbortSignal.timeout(yI)});if(!t.ok)return YF().warn(`Failed to fetch additional file: ${tI(e.filePath)}`),null;let n=await t.arrayBuffer(),r=hI(e.fileName);if(r===``)return YF().warn(`Skipping fetched file with unusable name: ${e.fileName}`),null;let i=e.subFolder?hI(e.subFolder):``;return{fileName:r,content:new Uint8Array(n),path:_I(i,r),subFolder:i}}catch(t){let n=t instanceof Error?t.name:`unknown error`;return YF().error(`Error fetching additional file ${tI(e.filePath)}: ${n}`),null}}))).filter(e=>e!==null);async function xI(t,n,r){let{zip:i,strToU8:a}=await e(async()=>{let{zip:e,strToU8:t}=await import(`./C36Kxzt3.js`);return{zip:e,strToU8:t}},[],import.meta.url),o=new Set(t.map(e=>e.path)),s={};for(let e of t){let t=e.path===`__proto__`?SI(e.path,o):e.path;o.add(t),s[t]=typeof e.content==`string`?a(e.content):e.content}let c=await new Promise((e,t)=>{i(s,{level:6},(n,r)=>n?t(n):e(r))});await r(new Blob([c],{type:`application/zip`}),`${n}.zip`)}function SI(e,t){if(!t.has(e))return e;let n=e.lastIndexOf(`/`),r=e.lastIndexOf(`.`),i=r>n?r:e.length,a=e.slice(0,i),o=e.slice(i);for(let e=2;;e++){let n=`${a}-${e}${o}`;if(!t.has(n))return n}}function CI(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}KF.DEFINITION_NOT_CACHED;function wI(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}var TI=/^\{(-?\d+(?:;-?\d+)*)?\}$/;function EI(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.entries(e);return t.length>0&&t.every(([e,t])=>TI.test(e)&&Array.isArray(t))}var DI=new Set([`System.Double`,`System.Single`,`System.Decimal`,`System.Int32`,`System.Int64`]),OI=new Set([`System.Int32`,`System.Int64`]);function kI(e,t,n){if(e==null)return e;if(Array.isArray(e)){let n=e.map(t).filter(e=>e!==null);return n.length>0?n:void 0}let r=t(e);return r===null?n?void 0:e:r}var AI=e=>{if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e==`string`){let t=e.trim();if(t===``||/^[+-]?0[xbo]/i.test(t))return null;let n=Number(t);return Number.isFinite(n)?n:null}return null},jI=e=>{if(typeof e==`boolean`)return e;if(typeof e==`string`){let t=e.trim().toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1}return null},MI=e=>typeof e==`string`?e.length>=2&&e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e.startsWith(`"`)?e.slice(1):e:null,NI=e=>{if(typeof e==`string`){let t=e.trim();return t.startsWith(`"`)&&t.endsWith(`"`)&&(t=t.slice(1,-1).trim()),t}return null};function PI(e){return t=>{if(typeof t==`object`&&t)return t;if(typeof t==`string`&&t.trim()!==``)try{let n=JSON.parse(t);return typeof n==`object`&&n?n:(YF().warn(`Parsed value for input ${e} is not an object`),null)}catch{return YF().warn(`Failed to parse the object value for input ${e}`),null}return null}}function FI(e,t){let n=Number(e.toFixed(t));return Math.abs(e-n)<1e-8?n:e}var II=12,LI=15;function RI(e){if(!Number.isFinite(e))return 0;let t=Number(Math.abs(e).toPrecision(LI)),[n,r=`0`]=String(t).split(`e`),i=(n.split(`.`)[1]?.length??0)-Number(r);return Math.min(Math.max(i,0),II)}function zI(e){if(!Number.isFinite(e)||e===0)return .1;let t=RI(e);return t===0?Math.abs(e)>=1?1:.1:Number((10**-t).toFixed(t))}function BI(e){return typeof e.stepSize==`number`&&Number.isFinite(e.stepSize)&&e.stepSize>0?e.stepSize:void 0}var VI=e=>e.nickname||`unnamed`,HI=(e,t)=>(e.atMost??1)>1?[t]:t,UI=e=>BI(e)??(e.paramType===`Integer`?1:.1),WI=(e,t)=>Array.isArray(e)?e.map(e=>typeof e==`number`?t(e):e):typeof e==`number`?t(e):e;function GI(e){if(EI(e.default))return{default:e.default,stepSize:UI(e)};if(typeof e.default==`string`&&e.default.trim()!==``&&AI(e.default)===null)throw new qF(`Invalid numeric default "${e.default}" for input "${e.name||`unknown`}"`,KF.VALIDATION_ERROR,{context:{inputName:e.name,default:e.default}});let t=kI(e.default,AI,!0);if(e.paramType===`Integer`)return{default:WI(t,Math.round),stepSize:UI(e)};let n=Array.isArray(t)?t[0]:t,r=[n,e.minimum,e.maximum].find(e=>typeof e==`number`&&Number.isFinite(e)&&e!==0),i=BI(e)??(r===void 0?.1:zI(r)),a=RI(i);if(a===0&&typeof n==`number`&&n!==0&&Math.abs(n)<1){let e=Math.ceil(-Math.log10(Math.abs(n)));Number.isFinite(e)&&e>0&&(a=e)}return a=Math.min(Math.max(a,0),12),{default:WI(t,e=>FI(e,a)),stepSize:i}}var KI=(e,t,n)=>({...t,paramType:e.paramType,minimum:e.minimum,maximum:e.maximum,atLeast:e.atLeast,atMost:e.atMost,...n}),qI={parse(e,t){return KI(e,t,GI(e))},fallback(e,t){let n=typeof e.minimum==`number`&&Number.isFinite(e.minimum)&&e.minimum>0?e.minimum:0;return KI(e,t,{stepSize:UI(e),default:HI(e,n)})}},JI={parse(e,t){if(EI(e.default))return{...t,paramType:`Boolean`,default:e.default};let n=kI(e.default,jI,!1);if(n!=null&&typeof n!=`boolean`&&!Array.isArray(n))throw new qF(`Invalid boolean default "${String(n)}" for input "${e.name||`unknown`}"`,KF.VALIDATION_ERROR,{context:{inputName:e.name,default:e.default}});return{...t,paramType:`Boolean`,default:n}},fallback(e,t){return{...t,paramType:`Boolean`,default:HI(e,!1)}}},YI={parse(e,t){let n=kI(e.default,MI,!1);return{...t,paramType:`Text`,default:n}}},XI={parse(e,t,n){if(!e.values||typeof e.values!=`object`||Object.keys(e.values).length===0){let t=VI(e);throw new qF(`Input "${t}" has no values defined (expected ValueList)`,KF.INVALID_INPUT,{context:{inputName:t,expectedType:`ValueList`}})}let r;if(e.default!==void 0&&e.default!==null){if(typeof e.default==`object`)throw new qF(`ValueList input "${VI(e)}" default is not a string-able value`,KF.VALIDATION_ERROR,{context:{inputName:e.name,default:e.default}});let t=String(e.default).toLowerCase(),i=Object.keys(e.values).find(e=>e.toLowerCase()===t);if(r=i??String(e.default),i===void 0){let t=VI(e);YF().warn(`ValueList input "${t}" default is not in available values`),n?.({code:KF.VALIDATION_ERROR,message:`ValueList input "${t}" default value "${e.default}" is not in available values`})}}return{...t,paramType:`ValueList`,values:e.values,default:r}},fallback(e,t){return{...t,paramType:`ValueList`,values:e.values&&typeof e.values==`object`?e.values:{},default:void 0}}},ZI=e=>kI(e.default,PI(VI(e)),!0);function QI(e,t){return{...t,paramType:`Geometry`,default:HI(e,null)}}var $I=e=>({parse(t,n){return{...n,paramType:e,default:ZI(t)}},fallback:(t,n)=>({...QI(t,n),paramType:e})}),eL=new Map([[`Number`,qI],[`Integer`,qI],[`Boolean`,JI],[`Text`,YI],[`ValueList`,XI],[`Geometry`,$I(`Geometry`)],[`Line`,$I(`Line`)],[`Point`,$I(`Point`)],[`Plane`,$I(`Plane`)],[`File`,{parse(e,t){return{...t,paramType:`File`,acceptedFormats:e.acceptedFormats,default:ZI(e)}}}],[`Color`,{parse(e,t){let n=kI(e.default,NI,!1);return{...t,paramType:`Color`,default:n}}}]]);new Map([...eL.keys()].map(e=>[e.toLowerCase(),e])),globalThis.process?.getBuiltinModule?.(`node:crypto`),new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function tL(e,t){return{__decodeError:!0,type:e,raw:t}}function nL(e){let t=new WeakSet,n=e=>{if(!e||typeof e!=`object`||t.has(e))return;t.add(e);let r=e.delete;if(typeof r==`function`){let t=e.isDeleted;typeof t==`function`&&t.call(e)||r.call(e);return}if(Array.isArray(e)){for(let t of e)n(t);return}let i=Object.getPrototypeOf(e);if(i===Object.prototype||i===null)for(let t of Object.values(e))n(t)};n(e)}var rL=new Map([[`Rhino.Geometry.Point3d`,(e,t)=>{let n=t;return!n||typeof n.X!=`number`?null:new e.Point([n.X,n.Y,n.Z])}],[`Rhino.Geometry.Line`,(e,t)=>{let n=t;return!n||!n.From||!n.To?null:new e.Line([n.From.X,n.From.Y,n.From.Z],[n.To.X,n.To.Y,n.To.Z])}]]);function iL(e){return!!(e&&typeof e==`object`&&typeof e.data==`string`)}function aL(e,t,n){let r=rL.get(t),i=!1;if(r)try{let t=r(n,e);if(t!=null)return t}catch(e){YF().warn(`Failed to decode Rhino type ${t}:`,e),i=!0}try{if(iL(e))return n.CommonObject.decode(e)}catch(n){return YF().warn(`Failed to decode ${t} with CommonObject:`,n),tL(t,e)}return i?tL(t,e):e}var oL=`Rhino.Geometry.`,sL=`FileData`;function cL(e,t){return e.includes(`WebDisplay`)||t&&e!==`System.String`}var lL=e=>e.startsWith(`{`)||e.startsWith(`[`);function uL(e){if(typeof e!=`string`)return e;let t=e.trim();if(!lL(t)&&!t.startsWith(`"`))return e;let n=nI(t)??e;return typeof n==`string`&&lL(n.trim())?nI(n)??n:n}function dL(e,t,n){if(t===`System.String`)return typeof e==`string`?e.replace(/^"(.*)"$/,`$1`):e;if(OI.has(t)){let t=Number.parseInt(String(e),10);return Number.isNaN(t)||Number.isSafeInteger(t)?t:e}return DI.has(t)?Number.parseFloat(String(e)):t===`System.Boolean`?String(e).toLowerCase()===`true`:n&&t.startsWith(oL)?aL(e,t,n):e}function fL(e,t,n,r){if(typeof e.data!=`string`)return e.data;let i=n?uL(e.data):e.data;return n&&t.includes(sL)?pL(i)??i:dL(i,t,r)}function pL(e){if(!e||typeof e!=`object`)return null;let t=ZF(e,`fileName`),n=ZF(e,`fileType`),r=ZF(e,`subFolder`),i=ZF(e,`isBase64Encoded`);if(typeof t!=`string`||typeof n!=`string`||typeof r!=`string`||!QF(e,`data`)||typeof i!=`boolean`&&typeof i!=`string`)return null;let a=ZF(e,`metadata`);return{fileName:t,fileType:n,data:ZF(e,`data`),isBase64Encoded:gI(i),subFolder:r,...a?{metadata:a}:{}}}function mL(e){let t=ZF(e,`values`);return Array.isArray(t)?t:[]}function hL(e){return typeof e.type==`string`?e.type:``}function gL(e,t){if(e&&typeof e==`object`){for(let n of Object.values(e))if(Array.isArray(n))for(let e of n)e&&typeof e==`object`&&t(e)}}function _L(e,t=!1,n={}){let{parseValues:r=!0,rhino:i,stringOnly:a=!1}=n,o={},s=new Set;for(let n of mL(e)){let e=ZF(n,`paramName`);gL(ZF(n,`innerTree`),n=>{let c=hL(n);if(cL(c,a))return;let l=t?n.id:e;if(!l)return;let u=fL(n,c,r,i);Object.hasOwn(o,l)?s.has(l)?o[l].push(u):(o[l]=[o[l],u],s.add(l)):wI(o,l,u)})}return{values:o,dispose:()=>nL(o)}}function vL(e){let t=[];for(let n of mL(e))gL(ZF(n,`innerTree`),e=>{if(!hL(e).includes(sL))return;let n=pL(uL(e.data));n&&t.push(n)});return t}function yL(e,t,n={}){let{parseValues:r=!0,rhino:i,stringOnly:a=!1}=n;for(let n of mL(e)){let e=ZF(n,`innerTree`),o=!1;if(`byName`in t){if(ZF(n,`paramName`)!==t.byName)continue;o=!0}let s=[];if(gL(e,e=>{if(`byId`in t){if(e.id!==t.byId)return;o=!0}let n=hL(e);cL(n,a)||s.push(fL(e,n,r,i))}),o)return s.length===0?void 0:s.length===1?s[0]:s}}var bL=class{response;constructor(e){this.response=e}getValues(e=!1,t={}){return _L(this.response,e,t)}getValue(e,t){return yL(this.response,e,t)}async getAndDownloadFiles(e,t){await pI(vL(this.response),e,t)}},xL=`external`;function SL(e){if(!e.scopeKey||!e.inputId)return null;try{return typeof sessionStorage>`u`?null:{storage:sessionStorage,key:`${xL}:${e.scopeKey}:${e.inputId}`}}catch{return null}}function CL(e){let t=SL(e);if(!t)return;let n=t.storage.getItem(t.key);if(n!==null)try{return JSON.parse(n)}catch{return}}function wL(e){return VF(e).filter(e=>e.source?.kind===`client`).map(e=>({paramId:e.paramId,displayName:e.displayName??e.paramId}))}var TL={status:`none`};function EL(e){return Array.isArray(e)?e.length>0:e!=null&&e!==``}function DL(e,t){let n=TL,r=null,i=null;function a(e){n=e,t()}function o(){i?.controller.abort(),i=null}async function s(t,n,o){let s=Date.now();a({status:`making`,ids:n,startedAt:s});try{let i=await e(t.values??{},o.signal);if(o.signal.aborted||r!==t)return;if(i.aborted)return a({status:`waiting`,ids:n});if(i.blocked){let e=i.diagnostics??[];return a({status:`failed`,ids:n,error:e.find(e=>e.level===`error`)?.message??i.errors?.[0]??`The definition refused to make the files.`,diagnostics:e})}let c={};for(let e of n)EL(i.outputs[e])&&(c[e]=i.outputs[e]);a(Object.keys(c).length===0?{status:`empty`,ids:n}:{status:`ready`,ids:n,outputs:c,durationMs:Date.now()-s})}catch(e){if(o.signal.aborted||r!==t)return;a({status:`failed`,ids:n,error:e instanceof Error?e.message:String(e),diagnostics:[]})}finally{i?.controller===o&&(i=null)}}return{get state(){return n},show(t){if(t===r)return;o(),r=t;let i=t?.deferred??[];n=i.length>0&&e?{status:`waiting`,ids:i}:TL},make(){if(i)return i.done;if(!r||n.status!==`waiting`&&n.status!==`failed`)return Promise.resolve();let e=new AbortController,t=s(r,n.ids,e);return i={controller:e,done:t},t},cancel(){if(!i||n.status!==`making`)return;let{ids:e}=n;o(),a({status:`waiting`,ids:e})}}}var OL=Object.freeze({solveId:null,running:!1,diagnostics:[],progress:new Map,ended:null,other:[],lastSeq:0});function kL(e){let{kind:t}=e;return t===`ok`||t===`blocked`||t===`aborted`?t:`error`}function AL(e,t){if(t.type===`solveEnded`&&e.solveId!==null&&t.solveId!==e.solveId)return e;let n=t.solveId===e.solveId?e:{...OL,solveId:t.solveId,running:!0};if(t.seq<=n.lastSeq)return e;let r={...n,lastSeq:t.seq},i=t.payload??{};switch(t.type){case`solveStarted`:return{...r,running:!0};case`solveEnded`:return{...r,running:!1,ended:{kind:kL(i)}};case`diagnostic`:{let e=PF(i);return e?{...r,diagnostics:[...r.diagnostics,e]}:r}case`progress`:{let e=typeof i.source==`string`?i.source:``,t=new Map(r.progress),n=jL(i),a=r.progress.get(e)?.fraction;return a!==void 0&&(n.fraction??0)<a&&(n.fraction=a),t.set(e,n),{...r,progress:t}}default:return{...r,other:[...r.other,t]}}}function jL(e){let t=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,n=t(e.fraction),r=t(e.done),i=t(e.total),a=t(e.nextFraction),o=t(e.stepMs),s=e=>Math.min(1,Math.max(0,e));return{...typeof e.source==`string`?{source:e.source}:{},...n===void 0?{}:{fraction:s(n)},...r===void 0?{}:{done:r},...i===void 0?{}:{total:i},...typeof e.label==`string`?{label:e.label}:{},...a===void 0?{}:{nextFraction:s(a)},...o!==void 0&&o>0?{stepMs:o}:{}}}function ML(e){let t=typeof e==`object`&&e&&typeof e.toJSON==`function`?e.toJSON():e;if(typeof t!=`object`||!t)return JSON.stringify(t)??`null`;if(Array.isArray(t))return`[${t.map(ML).join(`,`)}]`;let n=t;return`{${Object.keys(n).filter(e=>n[e]!==void 0).sort().map(e=>`${JSON.stringify(e)}:${ML(n[e])}`).join(`,`)}}`}var NL=268435456;function PL(e={}){let{max:t=16,maxBytes:n=NL,meshPolicy:r}=e,i=new Map,a=0;function o(e){e.meshes?.length&&r?.release(e.meshes)}function s(e){return!r||!e.meshes?.length?e:{...e,meshes:r.clone(e.meshes)}}function c(e){let t=i.get(e);t!==void 0&&(i.delete(e),a-=t.bytes,o(t.result))}return{get(e){let n=ML(e),r=i.get(n);if(r!==void 0)return i.delete(n),i.set(n,r),console.debug(`[Solve/memo] HIT — served from client memo (${i.size}/${t})`),s(r.result)},set(e,o){let l=ML(e);c(l);let u=o.meshes?.length?r?.byteSize?.(o.meshes)??0:0;if(u>n)console.debug(`[Solve/memo] not memoized: ${(u/1048576).toFixed(0)} MB of meshes exceeds ${(n/1048576).toFixed(0)} MB`);else{i.set(l,{result:s(o),bytes:u}),a+=u;for(let e of i.keys()){if(i.size<=t&&a<=n)break;c(e)}}},clear(){i.forEach(e=>o(e.result)),i.clear(),a=0}}}function FL(e,t,n){let r=new Set(wL(e).map(e=>e.paramId)),i={};for(let a of e.inputs)if(r.has(a.id)){let e=n({scopeKey:t,inputId:a.id});e!==void 0&&(i[a.id]=e)}else i[a.id]=a.default??HF(a.paramType);for(let t of e.outputs)i[t.id]=null;return i}function IL(e,t,n){let r=e.instanceSolve===!1;return{values:FL(e,t,n),error:``,computeErrors:[],computeWarnings:[],diagnostics:[],blocked:!1,heldResult:null,meshes:[],hasPendingChanges:r,hasNeverSolved:r,lastResult:null,unsolved:null}}function LL(e,t,n,r,i=!1){return r===!1&&!i&&RL(e.values[t],n)?!1:(e.values[t]=n,r!==!1||(e.hasPendingChanges=!i,i))}function RL(e,t){return Object.is(e,t)?!0:e===null||t===null||typeof e!=`object`||typeof t!=`object`?!1:ML(e)===ML(t)}function zL(e,t,n){return Object.assign(e.values,t),n!==!1||(e.hasPendingChanges=!0,!1)}var BL=new Set([`dynamicValueList`,`file`]);function VL(e,t,n,r,i){if(!t||!(r in t)||typeof i==`object`&&i||!Object.is(t[r],i)||!Object.is(n[r],i))return!1;let a=e.inputs.find(e=>e.id===r)?.paramType;return!BL.has(a??``)}function HL(e,t){let n=UF(e),r={};for(let i of e.inputs)n.has(i.id)||Object.hasOwn(t,i.id)&&(r[i.id]=t[i.id]);return r}function UL(e,t,n){if(!n)return!1;let r=HL(e,t);return Object.keys(r).some(e=>!Object.hasOwn(n,e)||!Object.is(r[e],n[e]))}function WL(e,t,n){e.error=``,e.computeErrors=t.errors??[],e.computeWarnings=t.warnings??[],e.diagnostics=t.diagnostics??[],e.blocked=t.blocked??!1,e.unsolved=t.aborted?`aborted`:null,!e.blocked&&YL(e.diagnostics)?(e.heldResult=t,e.hasPendingChanges&&=n):(e.heldResult=null,KL(e,t,n))}function GL(e){let t={};for(let n of e.outputs)n.type!==`dynamicValueList`&&(t[n.id]=null);return t}function KL(e,t,n){e.meshes=t.meshes??[];let{meshes:r,...i}=t;e.lastResult=i,Object.assign(e.values,t.outputs),e.hasPendingChanges&&=n,e.hasNeverSolved=!1}function qL(e,t){return t||e.heldResult?`wait`:e.hasPendingChanges?`solve`:e.unsolved===`discarded`?`discarded`:e.unsolved||e.hasNeverSolved||e.error||!e.lastResult?`solve`:e.blocked?`blocked`:`applied`}function JL(e,t){return t?`solving`:e.heldResult?`review`:e.blocked?`blocked`:`idle`}function YL(e){return e.some(e=>e.isGate&&e.level!==`remark`)}function XL(e,t){for(let n of[...e])try{n(t)}catch(e){console.error(`[Solve/session] listener threw:`,e)}}function ZL(e){let t=e.schema,n=null,r=null,i=IL(t,e.scopeKey,CL),a=!1,o=new Set,s=()=>XL(o,void 0),c=e.driver.solveFiles,l=DL(c&&((t,n)=>c.call(e.driver,t,n)),s),u=()=>l.show(i.lastResult),d=new Set,f=[],p={status:`aborted`,diagnostics:[]};function m(){return a?Promise.resolve(p):new Promise(e=>f.push(e))}function h(e){let t=f;f=[],t.forEach(t=>t(e)),XL(d,e)}function g(){let e=f;f=[],e.forEach(e=>e(p))}function _(e){let t=i.diagnostics;return e.aborted?{status:`aborted`,diagnostics:t}:e.blocked?{status:`blocked`,diagnostics:t}:{status:`applied`,result:i.lastResult,diagnostics:t}}function v(t){s(),e.driver.hasQueued||h(t())}function y(){i.heldResult&&(i.heldResult=null,XL(d,{status:`discarded`,diagnostics:i.diagnostics}))}function b(){return UL(t,i.values,r)}let x=OL,S=e.driver.onEvent?.(e=>{let t=AL(x,e);t!==x&&(x=t,s())});function C(){let e=m();return w(),e}function w(){a||(y(),n={...HL(t,i.values)},r=n,l.cancel(),e.driver.solve(n,t.previewSolves===!0?{solveMode:`preview`}:void 0),s())}return{get values(){return i.values},get error(){return i.error},get computeErrors(){return i.computeErrors},get computeWarnings(){return i.computeWarnings},get diagnostics(){return i.diagnostics},get blocked(){return i.blocked},get awaitingAck(){return i.heldResult!==null},acknowledge(){let e=i.heldResult;e&&(i.heldResult=null,KL(i,e,b()),u(),v(()=>_(e)))},discard(){i.heldResult&&(i.heldResult=null,i.unsolved=`discarded`,v(()=>({status:`discarded`,diagnostics:i.diagnostics})))},get live(){return x},get phase(){return JL(i,e.driver.isSolving)},abort(){e.driver.cancel()},get meshes(){return i.meshes},get files(){return l.state},makeFiles(){return a?Promise.resolve():l.make()},cancelFiles(){l.cancel()},get lastResult(){return i.lastResult},get hasPendingChanges(){return i.hasPendingChanges},get hasNeverSolved(){return i.hasNeverSolved},get isSolving(){return e.driver.isSolving},setValue(e,r,a=!1){(a||!VL(t,n,i.values,e,r))&&(LL(i,e,r,t.instanceSolve,a)?w():s())},solve:C,ensureSolved(){let t=e.driver.isSolving||e.driver.hasQueued===!0,n=qL(i,t);return n===`wait`?m():n===`solve`?C():n===`applied`?Promise.resolve({status:n,result:i.lastResult,diagnostics:i.diagnostics}):Promise.resolve({status:n,diagnostics:i.diagnostics})},onSettled(e){return d.add(e),()=>d.delete(e)},loadValues(e){zL(i,e,t.instanceSolve)?w():s()},rebuild(o,c){a||(g(),t=o,n=null,r=null,e.driver.reset?.(),Object.assign(i,IL(o,c,CL)),u(),Object.keys(i.values).length>0&&o.instanceSolve!==!1?w():s())},report(r){let a=r.blocked||r.aborted,o=r.aborted===!0||b();if(r.aborted&&(n=null),WL(i,a?{...r,outputs:GL(t),meshes:[]}:r,o),u(),e.driver.hasQueued&&(i.heldResult=null),i.heldResult)return s();v(()=>_(r))},reportError(e){y(),n=null,i.error=e,i.unsolved=null,v(()=>({status:`failed`,error:e}))},reportAborted(){n=null,i.unsolved=`aborted`,v(()=>p)},subscribe(e){return o.add(e),()=>o.delete(e)},notify:s,dispose(){a=!0,S?.(),o.clear(),l.show(null),d.clear(),e.driver.reset?.(),g()}}}function QL(e,t){let{runDeadlineMs:n,onChange:r}=t,i=!1,a=null,o=null;function s(e){if(i!==e){i=e;try{r?.()}catch(e){console.error(`[Solve/throttle] onChange threw:`,e)}}}async function c(t){let r=new AbortController;o=r;let l=setTimeout(()=>{console.warn(`[Solve/throttle] run exceeded ${n}ms — aborting`),r.abort(new DOMException(`Run deadline exceeded`,`TimeoutError`))},n);s(!0);try{await e(t,r.signal)}catch(e){(!(e instanceof Error)||e.name!==`AbortError`&&e.name!==`TimeoutError`)&&console.error(`[Solve/throttle] unhandled error in run:`,e)}finally{if(clearTimeout(l),o===r&&(o=null),s(!1),a!==null&&!i){let e=a;a=null,c(e)}}}function l(e){i?(a!==null&&console.debug(`[Solve/throttle] superseded pending run (latest-wins)`),a=e):c(e)}function u(){a=null,o?.abort(),o=null}return{trigger:l,get isRunning(){return i},get hasPending(){return a!==null},cancel:u}}var $L=e=>`The solve took longer than ${e} s and was stopped.`;function eR(e,t,n){let{meshPolicy:r,solveDeadlineMs:i,onChange:a,events:o}=n,s=n.timeoutMessage??$L,c=PL({meshPolicy:r}),l=`full`,u=`full`,d=0;function f(e){console.debug(`[Solve/driver] solve stopped (cancelled or timed out)`),e.reason?.name===`TimeoutError`?t().reportError(s(Math.round(i/1e3))):t().reportAborted()}let p=QL(async(n,r)=>{let i=d,a=u;a!==l&&(c.clear(),l=a);let o;try{let t=c.get(n);t===void 0?(o={...await WF(e(n,r,a===`preview`?{solveMode:a}:void 0),r),values:n},!o.aborted&&i===d&&c.set(n,o)):o=t}catch(e){return i===d?r.aborted?f(r):(console.warn(`[Solve/driver] solve failed:`,e),t().reportError(e instanceof Error?e.message:String(e))):void 0}if(i===d){if(r.aborted)return f(r);t().report(o)}},{runDeadlineMs:i,onChange:a});function m(){p.cancel(),o?.cancelCurrent?.()}return{solve(e,t){u=t?.solveMode??`full`,p.trigger(e)},async solveFiles(t,n){let r=d,a=AbortSignal.any([n,AbortSignal.timeout(i)]),o=await WF(e(t,a,{solveMode:`full`,skipMeshes:!0,liveEvents:!1}),a);return r===d?o:{outputs:{},aborted:!0}},cancel:m,get isSolving(){return p.isRunning},get hasQueued(){return p.hasPending},reset(){d+=1,m(),c.clear()},...o?{onEvent:e=>o.subscribe(e)}:{}}}var tR=1e3,nR=3e4;function rR(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID().replace(/-/g,``):Array.from({length:32},()=>Math.floor(Math.random()*16).toString(16)).join(``)}function iR(e){let t=rR(),n=new Set,r=e.fetch??((...e)=>fetch(...e)),i=null,a=null,o=tR,s=null;function c(){if(i||typeof EventSource>`u`)return;let r=`${e.endpoint}${e.endpoint.includes(`?`)?`&`:`?`}streamId=${t}`,l=new EventSource(r);i=l,l.addEventListener(`open`,()=>{o=tR}),l.addEventListener(`solve`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}t.type===`solveStarted`?a=t.solveId:t.type===`solveEnded`&&a===t.solveId&&(a=null);for(let e of n)e(t)}),l.addEventListener(`error`,()=>{l.readyState===EventSource.CLOSED&&i===l&&(i=null,a=null,s=setTimeout(c,o),o=Math.min(o*2,nR))})}return c(),{streamId:t,get currentSolveId(){return a},subscribe(e){return n.add(e),()=>{n.delete(e)}},cancelCurrent(){let t=a;t&&r(e.cancelEndpoint(t),{method:`POST`,keepalive:!0}).catch(()=>{})},close(){s&&clearTimeout(s),i?.close(),i=null,n.clear(),a=null}}}var aR={Prefer:GF},oR=10,sR=new Set([101,103,204,205,304]);async function cR(e){if(e.headers.get(`Preference-Applied`)!==`selva-keepalive`||!e.body)return e;let t=e.body.getReader(),n=new Uint8Array;for(;;){let{done:e,value:r}=await t.read();if(e)throw Error(`The keep-alive response ended before the solve result.`);n=lR(n,r);let i=n.indexOf(oR);if(i===-1)continue;let a=JSON.parse(new TextDecoder().decode(n.subarray(0,i))),o=new Headers(a.headers),s=uR(n.subarray(i+1),t);return o.get(`Content-Encoding`)===`gzip`&&(s=s.pipeThrough(new DecompressionStream(`gzip`)),o.delete(`Content-Encoding`),o.delete(`Content-Length`)),new Response(sR.has(a.status)?null:s,{status:a.status,headers:o})}}function lR(e,t){let n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e),n.set(t,e.byteLength),n}function uR(e,t){return new ReadableStream({start(t){e.byteLength>0&&t.enqueue(e)},async pull(e){let{done:n,value:r}=await t.read();n?e.close():e.enqueue(r)},cancel(e){return t.cancel(e)}})}function dR(e){let t={};if(!e)return t;for(let n of e.split(`,`)){let[e,...r]=n.split(`;`).map(e=>e.trim()),i=r.find(e=>e.startsWith(`dur=`));if(!e||!i)continue;let a=Number(i.slice(4));Number.isFinite(a)&&(t[e]=a)}return t}function fR(e){let t=dR(e);if(!e||t.solve===void 0)return null;let n=e=>(e??0).toFixed(0),r=`compute ${n(t.solve)}`;if(t.rhino_solve!==void 0){let e=t.rhino_gh===void 0?``:` (grasshopper ${n(t.rhino_gh)})`;r+=`: solve ${n(t.rhino_solve)}${e}, decode ${n(t.rhino_decode)}, encode ${n(t.rhino_encode)}, queue+link ${n(t.compute_link)}`}let i=[r],a=Object.entries(t).filter(([e])=>e.startsWith(`p_`)),o=a.reduce((e,[,t])=>e+t,0);if(o>=1){let e=a.filter(([,e])=>e>=1).sort((e,t)=>t[1]-e[1]).map(([e,t])=>`${e.slice(2)} ${n(t)}`);i.push(`prep ${n(o)}: ${e.join(`, `)}`)}i.push(`tree ${n(t.tree)}`,`serialize ${n(t.serialize)}`,`gzip ${n(t.gzip)}`),t.def_reupload&&i.push(`definition re-sent to Compute`);for(let[,t,n]of e.matchAll(/(\w+);desc="?([^",;]+)"?/g))i.push(`${t.replace(/^rhino_/,``)} ${n}`);return i.join(` | `)}var pR=5,mR=3600,hR=class extends Error{name=`SolveRequestError`;status;body;code;retryAfterSeconds;constructor(e,t){super(e),this.status=t.status,this.body=t.body,this.code=gR(t.body),this.retryAfterSeconds=t.retryAfterSeconds??void 0}};function gR(e){if(xR(e))return typeof e.code==`string`?e.code:typeof e.reason==`string`?e.reason:void 0}function _R(e,t){return new hR(`Rate limit reached. Try again in ${Math.ceil(e)}s.`,{status:429,body:t,retryAfterSeconds:e})}function vR(e){return new hR(`Your session has expired. Sign in again in a new tab, then re-run — your inputs are preserved.`,{status:401,body:e})}function yR(e){if(!e.trim())return null;let t=Number(e);if(!Number.isNaN(t))return Number.isFinite(t)&&t>=0?t:null;let n=Date.parse(e);return Number.isNaN(n)?null:Math.max(0,(n-Date.now())/1e3)}function bR(e,t){let n=(e===null?null:yR(e))??(typeof t==`number`?yR(String(t)):null);return n===null?null:Math.min(n,mR)}function xR(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function SR(e){let t;try{t=JSON.parse(e)}catch{return{}}return xR(t)?{body:t,...typeof t.message==`string`?{message:t.message}:{},retryAfter:t.retryAfter}:{body:t}}function CR(e){let t=e.debug??!1,n=(...e)=>{t&&console.info(...e)},r=0;function i(t,n){return e.onRateLimited?.(t),_R(t,n)}return async(a,o,s={})=>{let c=r-Date.now();if(c>0)throw i(c/1e3);let l=performance.now(),u=e.inputs(),d=e.outputs(),f=e.channel?.(),p=e.versionId?.(),m=s.liveEvents===!1?null:e.streamId?.(),h=e.bearerToken?.(),g=JSON.stringify({inputs:u,values:a,definitionUrl:e.definitionUrl(),...p?{versionId:p}:f===`draft`?{channel:`draft`}:{},...m?{streamId:m}:{},...s.solveMode===`preview`?{mode:`preview`}:{}}),_;try{_=await fetch(e.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`,...h?{Authorization:`Bearer ${h}`}:{},...e.keepalive?aR:{}},body:g,signal:o})}catch(e){if(o.aborted)return n(`[Compute] solve aborted during fetch — empty result discarded`),{outputs:{}};throw Error(`Could not reach the server. Check your connection, or reload the page if your session expired.`,{cause:e})}if(o.aborted)return n(`[Compute] solve aborted after headers — empty result discarded`),{outputs:{}};let v=_.redirected&&new URL(_.url).pathname===(e.loginPath??`/login`);try{_=await cR(_)}catch(e){if(o.aborted)return n(`[Compute] solve aborted while the server held it — empty result discarded`),{outputs:{}};throw Error(`The connection dropped while waiting for the result. Please try again.`,{cause:e})}if(_.status===401||v)throw e.onSessionExpired?.(),vR(v?void 0:SR(await _.text().catch(()=>``)).body);if(!_.ok){let e=await _.text().catch(()=>``),{body:t,message:a,retryAfter:o}=SR(e);e&&a===void 0&&n(`[Compute] unreadable error body (HTTP ${_.status}, ${e.length} chars)`);let s=bR(_.headers.get(`Retry-After`),o);if(s!==null&&(r=Date.now()+s*1e3),_.status===503||_.status===504)throw new hR(a||`Compute server is offline or unreachable. Please try again later.`,{status:_.status,body:t,retryAfterSeconds:s});if(_.status===429){let e=s??pR;throw r=Date.now()+e*1e3,i(e,t)}throw new hR(a||`Compute error (HTTP ${_.status})`,{status:_.status,body:t,retryAfterSeconds:s})}let y=performance.now()-l,b=performance.now(),x;try{x=await _.text()}catch(e){if(o.aborted)return n(`[Compute] solve aborted mid-download — empty result discarded`),{outputs:{}};throw Error(`The connection dropped while receiving the result. Please try again.`,{cause:e})}let S=performance.now()-b,C=x.length,w=e=>Error(`Received an invalid response from the server. Reload the page and try again.`,{cause:e}),T;try{T=JSON.parse(x)}catch(e){throw w(e)}if(!xR(T))throw w();let E=T,D=new bL(E),O=IF(E.selva?.outcome)??LF(E.errors??[],E.warnings??[]),k=O.blocked||O.aborted,A=e.meshes&&!k&&!s.skipMeshes?await e.meshes.extract(D.response,{debug:t,signal:o}):[],j={};for(let e of k?[]:d){let t=D.getValue({byId:e.id},{parseValues:!0});j[e.id]=t??(e.nickname?D.getValue({byName:e.nickname},{parseValues:!0}):void 0)}if(t){let e=JSON.stringify(a).length,t=_.headers.get(`Server-Timing`),r=dR(t),i=r.total??0,o=Math.max(0,y-i),s=C/1048576,c=s>=1?`${s.toFixed(2)} MB`:`${(C/1024).toFixed(0)} KB`,l=S>0?(s/(S/1e3)).toFixed(1):`∞`,u=performance.memory?.usedJSHeapSize,d=u===void 0?``:` | heap=${(u/1048576).toFixed(0)} MB`;n(`[Compute] req=${(g.length/1024).toFixed(0)}KB (values ${(e/1024).toFixed(0)}KB) | ttfb=${y.toFixed(0)}ms (network≈${o.toFixed(0)} + server ${i.toFixed(0)}) | download=${S.toFixed(0)}ms (${c} @ ${l} MB/s)${d}`);let f=fR(t);if(f&&n(`[Compute] └─ server: ${f}`),r.selva_cache!==void 0){let e=r.selva_cache?`HIT — served without calling compute`:r.rhino_cache?`HIT — Rhino.Compute's result cache, solved nothing`:`miss — solved on Rhino.Compute`;n(`[Compute] └─ cache: ${e}`)}}return RF({outputs:j,meshes:A,source:E},O)}}function wR(e){let t=T(()=>[...e().progress.values()]),n=Z({}),r=new Map,i={};le(()=>{let e={},a={},o=Y(()=>C(n)),s=new Map;for(let n of C(t)){if(n.fraction===void 0)continue;let t=n.source??``;s.set(t,n),r.get(t)===n&&o[t]?(e[t]=o[t],i[t]&&o[t]!==i[t]&&(a[t]=i[t])):(e[t]={width:n.fraction,ms:150},n.nextFraction!==void 0&&n.stepMs!==void 0&&(a[t]={width:n.nextFraction,ms:n.stepMs}))}if(r=s,i=a,P(n,e),Object.keys(a).length===0)return;let c=requestAnimationFrame(()=>{c=requestAnimationFrame(()=>P(n,{...e,...a}))});return()=>cancelAnimationFrame(c)});let a=Z(void 0),o=0;return le(()=>{let e=C(t)[0],n=Y(()=>C(a));if(e?.label===n?.label&&e?.done===n?.done){P(a,e);return}let r=()=>{P(a,e),o=performance.now()},i=200-(performance.now()-o);if(!n||i<=0){r();return}let s=setTimeout(r,i);return()=>clearTimeout(s)}),{get progress(){return C(t)},get headline(){return C(a)},get bars(){return C(n)}}}var TR=D(`<span class="text-xs shrink-0 text-muted-foreground tabular-nums"> </span>`),ER=D(`<div class="h-full w-(--bar-width) rounded-full bg-primary transition-all duration-(--bar-ms) ease-linear"></div>`),DR=D(`<div class="animate-pulse h-full w-1/3 rounded-full bg-primary/60"></div>`),OR=D(` <kbd class="px-1 rounded-sm border border-border font-sans text-2xs text-muted-foreground">Esc</kbd>`,1),kR=D(`<div class="px-3 gap-2 flex h-full flex-col justify-center"><div class="gap-2 min-w-0 flex items-center"><!> <span class="text-sm font-medium min-w-0 flex-1 truncate"> </span> <!></div> <div class="h-1 overflow-hidden rounded-full bg-muted" role="progressbar"><!></div> <div class="gap-2 flex items-center"><span class="text-xs text-muted-foreground tabular-nums"> </span> <!></div></div>`),AR=D(`<span class="text-sm font-medium shrink-0"> </span> <span class="text-xs min-w-0 truncate text-muted-foreground" data-testid="solve-esc-hint"> </span>`,1),jR=D(`<span class="text-sm font-medium shrink-0"> </span> <span class="text-xs text-muted-foreground tabular-nums"> </span>`,1),MR=D(`<div class="px-3 gap-2 flex h-full items-center"><!> <!></div>`),NR=D(`<span class="text-sm font-medium min-w-0 truncate"> </span>`),PR=D(`<!> <span class="text-sm font-medium shrink-0"> </span> <span class="text-xs text-muted-foreground tabular-nums"> </span>`,1),FR=D(`<div class="px-3 gap-2 flex h-full items-center"><!></div>`),IR=D(`<span class="solve-ping inset-0 absolute rounded-full border-2 border-success svelte-1o5zv0z"></span>`),LR=D(`<div class="px-3 gap-2 flex h-full items-center"><span class="size-1.5 relative shrink-0 rounded-full bg-success"><!></span> <span class="text-sm min-w-0 truncate text-muted-foreground"> </span></div>`),RR=D(`<div class="h-10 min-w-0 relative flex-1"><div role="status" aria-live="polite" aria-atomic="true" class="sr-only"> </div> <div data-testid="solve-status"><!></div></div>`);function zR(e,n){V(n,!0);let r=J(n,`slow`,3,!1),i=J(n,`freezesDuringSolve`,3,!1),a=at(),o=T(()=>a.messages),s=wR(()=>n.live??OL),l=T(()=>s.headline??s.progress[0]),d=T(()=>C(l)?.fraction===void 0?void 0:s.bars[C(l).source??``]??{width:C(l).fraction,ms:150}),f=0,p=!1,h=Z(0),g=Z(null),_=Z(0),v=0,y=!1;le(()=>{n.show&&(y=!0)}),le(()=>{let e=n.isSolving;Y(()=>{if(e===p)return;if(p=e,e){f=performance.now(),y=n.show,P(h,0),P(g,null);return}let t=performance.now()-f;f=0,y?P(g,{ms:t,aborted:n.live?.ended?.kind===`aborted`},!0):performance.now()-v>500&&(v=performance.now(),te(_))})}),le(()=>{if(!C(g))return;let e=setTimeout(()=>P(g,null),1400);return()=>clearTimeout(e)}),le(()=>{if(!n.isSolving||!n.show||i())return;let e=()=>P(h,performance.now()-f);e();let t=setInterval(e,100);return()=>clearInterval(t)});let x=T(()=>C(g)?`done`:n.show?r()&&!i()?`card`:`work`:`idle`),w=T(()=>new Intl.NumberFormat(a.locale,{minimumFractionDigits:1,maximumFractionDigits:1})),E=e=>`${C(w).format(e/1e3)} s`,D=T(()=>C(x)===`work`||C(x)===`card`?C(o).solvingEllipsis:C(x)===`done`?C(g)?.aborted?C(o).solveStopped:C(o).solveDone:``);var k=RR(),A=I(k),j=K(A,!0),M=U(A,2),F=I(M),ee=e=>{var r=kR(),i=I(r),a=I(i);_t(a,{class:`size-4 animate-spin shrink-0 text-muted-foreground`,"aria-hidden":`true`});var s=U(a,2),u=K(s,!0),f=U(s,2),p=e=>{var t=TR(),n=K(t);G(()=>m(n,`${C(l).done??``} / ${C(l).total??``}`)),O(e,t)};t(f,e=>{C(l)?.done!==void 0&&C(l)?.total!==void 0&&e(p)}),c(i);var g=U(i,2);H(g,`aria-valuemin`,0),H(g,`aria-valuemax`,100);var _=I(g),v=e=>{var t=ER();let n;G(()=>n=N(t,``,n,{"--bar-width":`${C(d).width*100}%`,"--bar-ms":`${C(d).ms??``}ms`})),O(e,t)},y=e=>{var t=DR();O(e,t)};t(_,e=>{C(d)?e(v):e(y,-1)}),c(g);var b=U(g,2),x=I(b),w=K(x,!0),T=U(x,2),D=e=>{tt(e,{variant:`outline`,size:`xs`,class:`ml-auto shrink-0`,get onclick(){return n.onabort},"aria-keyshortcuts":`Escape`,get title(){return C(o).solveMessagesEscHint},children:(e,t)=>{S();var n=OR(),r=z(n);S(),G(()=>m(r,`${C(o).solveMessagesAbort??``} `)),O(e,n)},$$slots:{default:!0}})};t(T,e=>{n.onabort&&e(D)}),c(b),c(r),G((e,t)=>{m(u,C(l)?.label??C(o).solving),H(g,`aria-label`,C(l)?.label??C(o).solving),H(g,`aria-valuenow`,e),m(w,t)},[()=>C(d)?Math.round(C(d).width*100):void 0,()=>E(C(h))]),X(1,r,()=>Tn,()=>({duration:150,delay:80})),O(e,r)},ne=e=>{var n=MR(),r=I(n);_t(r,{class:`size-4 animate-spin shrink-0 text-muted-foreground`,"aria-hidden":`true`});var a=U(r,2),s=e=>{var t=AR(),n=z(t),r=K(n,!0),i=U(n,2),a=K(i,!0);G(()=>{m(r,C(o).solvingEllipsis),m(a,C(o).solveMessagesEscHint)}),O(e,t)},l=e=>{var t=jR(),n=z(t),r=K(n,!0),i=U(n,2),a=K(i,!0);G(e=>{m(r,C(o).solving),m(a,e)},[()=>E(C(h))]),O(e,t)};t(a,e=>{i()?e(s):e(l,-1)}),c(n),X(1,n,()=>Tn,()=>({duration:150,delay:80})),O(e,n)},L=e=>{var n=FR(),r=I(n),i=e=>{var t=NR(),n=K(t,!0);G(()=>m(n,C(o).solveStopped)),O(e,t)},a=e=>{var t=PR(),n=z(t);ot(n,{class:`size-4 shrink-0 text-success`,"aria-hidden":`true`});var r=U(n,2),i=K(r,!0),a=U(r,2),s=K(a,!0);G(e=>{m(i,C(o).solveDone),m(s,e)},[()=>E(C(g).ms)]),O(e,t)};t(r,e=>{C(g).aborted?e(i):e(a,-1)}),c(n),X(1,n,()=>Tn,()=>({duration:150,delay:80})),O(e,n)},R=e=>{var n=LR(),r=I(n),i=I(r);ae(i,()=>C(_),e=>{var n=u(),r=z(n),i=e=>{var t=IR();O(e,t)};t(r,e=>{C(_)>0&&e(i)}),O(e,n)}),c(r);var a=U(r,2),s=K(a,!0);c(n),G(()=>m(s,C(o).upToDate)),X(1,n,()=>Tn,()=>({duration:150})),O(e,n)};t(F,e=>{C(x)===`card`?e(ee):C(x)===`work`?e(ne,1):C(x)===`done`&&C(g)?e(L,2):e(R,-1)}),c(M),c(k),G(()=>{m(j,C(D)),fe(M,1,`inset-x-0 bottom-0 backdrop-blur-md ease-out absolute z-10 overflow-hidden border border-border-strong transition-all duration-300 motion-reduce:transition-none ${C(x)===`card`?`h-24 shadow-md rounded-lg bg-card/75`:C(x)===`idle`?`h-10 shadow-sm rounded-md bg-card/90`:`h-10 shadow-md rounded-md bg-card/75`}`),H(M,`data-state`,C(x))}),O(e,k),b()}var BR=/^[a-z0-9]+(-[a-z0-9]+)*$/,VR=(e,t,n,r=``)=>{let i=e.split(`:`);if(e.slice(0,1)===`@`){if(i.length<2||i.length>3)return null;r=i.shift().slice(1)}if(i.length>3||!i.length)return null;if(i.length>1){let e=i.pop(),n=i.pop(),a={provider:i.length>0?i[0]:r,prefix:n,name:e};return t&&!HR(a)?null:a}let a=i[0],o=a.split(`-`);if(o.length>1){let e={provider:r,prefix:o.shift(),name:o.join(`-`)};return t&&!HR(e)?null:e}if(n&&r===``){let e={provider:r,prefix:``,name:a};return t&&!HR(e,n)?null:e}return null},HR=(e,t)=>e?!!((t&&e.prefix===``||e.prefix)&&e.name):!1;function UR(e,t){let n=e.icons,r=e.aliases||Object.create(null),i=Object.create(null);function a(e){if(n[e])return i[e]=[];if(!(e in i)){i[e]=null;let t=r[e]&&r[e].parent,n=t&&a(t);n&&(i[e]=[t].concat(n))}return i[e]}return Object.keys(n).concat(Object.keys(r)).forEach(a),i}var WR=Object.freeze({left:0,top:0,width:16,height:16}),GR=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),KR=Object.freeze({...WR,...GR}),qR=Object.freeze({...KR,body:``,hidden:!1});function JR(e,t){let n={};!e.hFlip!=!t.hFlip&&(n.hFlip=!0),!e.vFlip!=!t.vFlip&&(n.vFlip=!0);let r=((e.rotate||0)+(t.rotate||0))%4;return r&&(n.rotate=r),n}function YR(e,t){let n=JR(e,t);for(let r in qR)r in GR?r in e&&!(r in n)&&(n[r]=GR[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function XR(e,t,n){let r=e.icons,i=e.aliases||Object.create(null),a={};function o(e){a=YR(r[e]||i[e],a)}return o(t),n.forEach(o),YR(e,a)}function ZR(e,t){let n=[];if(typeof e!=`object`||typeof e.icons!=`object`)return n;e.not_found instanceof Array&&e.not_found.forEach(e=>{t(e,null),n.push(e)});let r=UR(e);for(let i in r){let a=r[i];a&&(t(i,XR(e,i,a)),n.push(i))}return n}var QR={provider:``,aliases:{},not_found:{},...WR};function $R(e,t){for(let n in t)if(n in e&&typeof e[n]!=typeof t[n])return!1;return!0}function ez(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.prefix!=`string`||!e.icons||typeof e.icons!=`object`||!$R(e,QR))return null;let n=t.icons;for(let e in n){let t=n[e];if(!e||typeof t.body!=`string`||!$R(t,qR))return null}let r=t.aliases||Object.create(null);for(let e in r){let t=r[e],i=t.parent;if(!e||typeof i!=`string`||!n[i]&&!r[i]||!$R(t,qR))return null}return t}var tz=Object.create(null);function nz(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}function rz(e,t){let n=tz[e]||(tz[e]=Object.create(null));return n[t]||(n[t]=nz(e,t))}function iz(e,t){return ez(t)?ZR(t,(t,n)=>{n?e.icons[t]=n:e.missing.add(t)}):[]}function az(e,t,n){try{if(typeof n.body==`string`)return e.icons[t]={...n},!0}catch{}return!1}var oz=!1;function sz(e){return typeof e==`boolean`&&(oz=e),oz}function cz(e){let t=typeof e==`string`?VR(e,!0,oz):e;if(t){let e=rz(t.provider,t.prefix),n=t.name;return e.icons[n]||(e.missing.has(n)?null:void 0)}}function lz(e,t){let n=VR(e,!0,oz);if(!n)return!1;let r=rz(n.provider,n.prefix);return t?az(r,n.name,t):(r.missing.add(n.name),!0)}function uz(e,t){if(typeof e!=`object`)return!1;if(typeof t!=`string`&&(t=e.provider||``),oz&&!t&&!e.prefix){let t=!1;return ez(e)&&(e.prefix=``,ZR(e,(e,n)=>{lz(e,n)&&(t=!0)})),t}let n=e.prefix;return HR({prefix:n,name:`a`})?!!iz(rz(t,n),e):!1}var dz=Object.freeze({width:null,height:null}),fz=Object.freeze({...dz,...GR}),pz=/(-?[0-9.]*[0-9]+[0-9.]*)/g,mz=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function hz(e,t,n){if(t===1)return e;if(n||=100,typeof e==`number`)return Math.ceil(e*t*n)/n;if(typeof e!=`string`)return e;let r=e.split(pz);if(r===null||!r.length)return e;let i=[],a=r.shift(),o=mz.test(a);for(;;){if(o){let e=parseFloat(a);isNaN(e)?i.push(a):i.push(Math.ceil(e*t*n)/n)}else i.push(a);if(a=r.shift(),a===void 0)return i.join(``);o=!o}}function gz(e,t=`defs`){let n=``,r=e.indexOf(`<`+t);for(;r>=0;){let i=e.indexOf(`>`,r),a=e.indexOf(`</`+t);if(i===-1||a===-1)break;let o=e.indexOf(`>`,a);if(o===-1)break;n+=e.slice(i+1,a).trim(),e=e.slice(0,r).trim()+e.slice(o+1)}return{defs:n,content:e}}function _z(e,t){return e?`<defs>`+e+`</defs>`+t:t}function vz(e,t,n){let r=gz(e);return _z(r.defs,t+r.content+n)}var yz=e=>e===`unset`||e===`undefined`||e===`none`;function bz(e,t){let n={...KR,...e},r={...fz,...t},i={left:n.left,top:n.top,width:n.width,height:n.height},a=n.body;[n,r].forEach(e=>{let t=[],n=e.hFlip,r=e.vFlip,o=e.rotate;n?r?o+=2:(t.push(`translate(`+(i.width+i.left).toString()+` `+(0-i.top).toString()+`)`),t.push(`scale(-1 1)`),i.top=i.left=0):r&&(t.push(`translate(`+(0-i.left).toString()+` `+(i.height+i.top).toString()+`)`),t.push(`scale(1 -1)`),i.top=i.left=0);let s;switch(o<0&&(o-=Math.floor(o/4)*4),o%=4,o){case 1:s=i.height/2+i.top,t.unshift(`rotate(90 `+s.toString()+` `+s.toString()+`)`);break;case 2:t.unshift(`rotate(180 `+(i.width/2+i.left).toString()+` `+(i.height/2+i.top).toString()+`)`);break;case 3:s=i.width/2+i.left,t.unshift(`rotate(-90 `+s.toString()+` `+s.toString()+`)`)}o%2==1&&(i.left!==i.top&&(s=i.left,i.left=i.top,i.top=s),i.width!==i.height&&(s=i.width,i.width=i.height,i.height=s)),t.length&&(a=vz(a,`<g transform="`+t.join(` `)+`">`,`</g>`))});let o=r.width,s=r.height,c=i.width,l=i.height,u,d;o===null?(d=s===null?`1em`:s===`auto`?l:s,u=hz(d,c/l)):(u=o===`auto`?c:o,d=s===null?hz(u,l/c):s===`auto`?l:s);let f={},p=(e,t)=>{yz(t)||(f[e]=t.toString())};p(`width`,u),p(`height`,d);let m=[i.left,i.top,c,l];return f.viewBox=m.join(` `),{attributes:f,viewBox:m,body:a}}var xz=/\sid="(\S+)"/g,Sz=new Map;function Cz(e){e=e.replace(/[0-9]+$/,``)||`a`;let t=Sz.get(e)||0;return Sz.set(e,t+1),t?`${e}${t}`:e}function wz(e){let t=[],n;for(;n=xz.exec(e);)t.push(n[1]);if(!t.length)return e;let r=`suffix`+(Math.random()*16777216|Date.now()).toString(16);return t.forEach(t=>{let n=Cz(t),i=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);e=e.replace(RegExp(`([#;"])(`+i+`)([")]|\\.[a-z])`,`g`),`$1`+n+r+`$3`)}),e=e.replace(new RegExp(r,`g`),``),e}var Tz=Object.create(null);function Ez(e,t){Tz[e]=t}function Dz(e){return Tz[e]||Tz[``]}function Oz(e){let t;if(typeof e.resources==`string`)t=[e.resources];else if(t=e.resources,!(t instanceof Array)||!t.length)return null;return{resources:t,path:e.path||`/`,maxURL:e.maxURL||500,rotate:e.rotate||2e3,timeout:e.timeout||1e4,random:e.random===!0,index:e.index||0,dataAfterTimeout:e.dataAfterTimeout!==!1}}var kz=Object.create(null);kz[``]=Oz({resources:[`https://api.iconify.design`,`https://api2.iconify.design`]});function Az(e,t){let n=Oz(t);return n!==null&&(kz[e]=n,!0)}function jz(e){return kz[e]}var Mz=(()=>{let e;try{if(e=fetch,typeof e==`function`)return e}catch{}})();function Nz(e,t){let n=jz(e);if(!n)return 0;let r;if(!n.maxURL)r=0;else{let e=0;n.resources.forEach(t=>{e=Math.max(e,t.length)});let i=t+`.json?icons=`;r=n.maxURL-e-n.path.length-i.length}return r}function Pz(e){return e===404}var Fz=(e,t,n)=>{let r=[],i=Nz(e,t),a=`icons`,o={type:a,provider:e,prefix:t,icons:[]},s=0;return n.forEach((n,c)=>{s+=n.length+1,s>=i&&c>0&&(r.push(o),o={type:a,provider:e,prefix:t,icons:[]},s=n.length),o.icons.push(n)}),r.push(o),r};function Iz(e){if(typeof e==`string`){let t=jz(e);if(t)return t.path}return`/`}var Lz={prepare:Fz,send:(e,t,n)=>{if(!Mz){n(`abort`,424);return}let r=Iz(t.provider);switch(t.type){case`icons`:{let e=t.prefix,n=t.icons.join(`,`),i=new URLSearchParams({icons:n});r+=e+`.json?`+i.toString();break}case`custom`:{let e=t.uri;r+=e.slice(0,1)===`/`?e.slice(1):e;break}default:n(`abort`,400);return}let i=503;Mz(e+r).then(e=>{let t=e.status;if(t!==200)setTimeout(()=>{n(Pz(t)?`abort`:`next`,t)});else return i=501,e.json()}).then(e=>{setTimeout(typeof e!=`object`||!e?()=>{e===404?n(`abort`,e):n(`next`,i)}:()=>{n(`success`,e)})}).catch(()=>{n(`next`,i)})}};function Rz(e,t){e.forEach(e=>{let n=e.loaderCallbacks;n&&(e.loaderCallbacks=n.filter(e=>e.id!==t))})}function zz(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout(()=>{e.pendingCallbacksFlag=!1;let t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let n=!1,r=e.provider,i=e.prefix;t.forEach(t=>{let a=t.icons,o=a.pending.length;a.pending=a.pending.filter(t=>{if(t.prefix!==i)return!0;let o=t.name;if(e.icons[o])a.loaded.push({provider:r,prefix:i,name:o});else if(e.missing.has(o))a.missing.push({provider:r,prefix:i,name:o});else return n=!0,!0;return!1}),a.pending.length!==o&&(n||Rz([e],t.id),t.callback(a.loaded.slice(0),a.missing.slice(0),a.pending.slice(0),t.abort))})}))}var Bz=0;function Vz(e,t,n){let r=Bz++,i=Rz.bind(null,n,r);if(!t.pending.length)return i;let a={id:r,icons:t,callback:e,abort:i};return n.forEach(e=>{(e.loaderCallbacks||=[]).push(a)}),i}function Hz(e){let t={loaded:[],missing:[],pending:[]},n=Object.create(null);e.sort((e,t)=>e.provider===t.provider?e.prefix===t.prefix?e.name.localeCompare(t.name):e.prefix.localeCompare(t.prefix):e.provider.localeCompare(t.provider));let r={provider:``,prefix:``,name:``};return e.forEach(e=>{if(r.name===e.name&&r.prefix===e.prefix&&r.provider===e.provider)return;r=e;let i=e.provider,a=e.prefix,o=e.name,s=n[i]||(n[i]=Object.create(null)),c=s[a]||(s[a]=rz(i,a)),l;l=o in c.icons?t.loaded:a===``||c.missing.has(o)?t.missing:t.pending;let u={provider:i,prefix:a,name:o};l.push(u)}),t}function Uz(e,t=!0,n=!1){let r=[];return e.forEach(e=>{let i=typeof e==`string`?VR(e,t,n):e;i&&r.push(i)}),r}var Wz={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function Gz(e,t,n,r){let i=e.resources.length,a=e.random?Math.floor(Math.random()*i):e.index,o;if(e.random){let t=e.resources.slice(0);for(o=[];t.length>1;){let e=Math.floor(Math.random()*t.length);o.push(t[e]),t=t.slice(0,e).concat(t.slice(e+1))}o=o.concat(t)}else o=e.resources.slice(a).concat(e.resources.slice(0,a));let s=Date.now(),c=`pending`,l=0,u,d=null,f=[],p=[];typeof r==`function`&&p.push(r);function m(){d&&=(clearTimeout(d),null)}function h(){c===`pending`&&(c=`aborted`),m(),f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function g(e,t){t&&(p=[]),typeof e==`function`&&p.push(e)}function _(){return{startTime:s,payload:t,status:c,queriesSent:l,queriesPending:f.length,subscribe:g,abort:h}}function v(){c=`failed`,p.forEach(e=>{e(void 0,u)})}function y(){f.forEach(e=>{e.status===`pending`&&(e.status=`aborted`)}),f=[]}function b(t,n,r){let i=n!==`success`;switch(f=f.filter(e=>e!==t),c){case`pending`:break;case`failed`:if(i||!e.dataAfterTimeout)return;break;default:return}if(n===`abort`)u=r,v();else if(i)u=r,f.length||(o.length?x():v());else{if(m(),y(),!e.random){let n=e.resources.indexOf(t.resource);n!==-1&&n!==e.index&&(e.index=n)}c=`completed`,p.forEach(e=>{e(r)})}}function x(){if(c!==`pending`)return;m();let r=o.shift();if(r===void 0){if(f.length){d=setTimeout(()=>{m(),c===`pending`&&(y(),v())},e.timeout);return}v();return}let i={status:`pending`,resource:r,callback:(e,t)=>{b(i,e,t)}};f.push(i),l++,d=setTimeout(x,e.rotate),n(r,t,i.callback)}return setTimeout(x),_}function Kz(e){let t={...Wz,...e},n=[];function r(){n=n.filter(e=>e().status===`pending`)}function i(e,i,a){let o=Gz(t,e,i,(e,t)=>{r(),a&&a(e,t)});return n.push(o),o}function a(e){return n.find(t=>e(t))||null}return{query:i,find:a,setIndex:e=>{t.index=e},getIndex:()=>t.index,cleanup:r}}function qz(){}var Jz=Object.create(null);function Yz(e){if(!Jz[e]){let t=jz(e);if(!t)return;Jz[e]={config:t,redundancy:Kz(t)}}return Jz[e]}function Xz(e,t,n){let r,i;if(typeof e==`string`){let t=Dz(e);if(!t)return n(void 0,424),qz;i=t.send;let a=Yz(e);a&&(r=a.redundancy)}else{let t=Oz(e);if(t){r=Kz(t);let n=Dz(e.resources?e.resources[0]:``);n&&(i=n.send)}}return!r||!i?(n(void 0,424),qz):r.query(t,i,n)().abort}function Zz(){}function Qz(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout(()=>{e.iconsLoaderFlag=!1,zz(e)}))}function $z(e){let t=[],n=[];return e.forEach(e=>{(e.match(BR)?t:n).push(e)}),{valid:t,invalid:n}}function eB(e,t,n){function r(){let n=e.pendingIcons;t.forEach(t=>{n&&n.delete(t),e.icons[t]||e.missing.add(t)})}if(n&&typeof n==`object`)try{if(!iz(e,n).length){r();return}}catch(e){console.error(e)}r(),Qz(e)}function tB(e,t){e instanceof Promise?e.then(e=>{t(e)}).catch(()=>{t(null)}):t(e)}function nB(e,t){e.iconsToLoad=e.iconsToLoad?e.iconsToLoad.concat(t).sort():t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout(()=>{e.iconsQueueFlag=!1;let{provider:t,prefix:n}=e,r=e.iconsToLoad;if(delete e.iconsToLoad,!r||!r.length)return;let i=e.loadIcon;if(e.loadIcons&&(r.length>1||!i)){tB(e.loadIcons(r,n,t),t=>{eB(e,r,t)});return}if(i){r.forEach(r=>{tB(i(r,n,t),t=>{eB(e,[r],t?{prefix:n,icons:{[r]:t}}:null)})});return}let{valid:a,invalid:o}=$z(r);if(o.length&&eB(e,o,null),!a.length)return;let s=n.match(BR)?Dz(t):null;s?s.prepare(t,n,a).forEach(n=>{Xz(t,n,t=>{eB(e,n.icons,t)})}):eB(e,a,null)}))}var rB=(e,t)=>{let n=Hz(Uz(e,!0,sz()));if(!n.pending.length){let e=!0;return t&&setTimeout(()=>{e&&t(n.loaded,n.missing,n.pending,Zz)}),()=>{e=!1}}let r=Object.create(null),i=[],a,o;return n.pending.forEach(e=>{let{provider:t,prefix:n}=e;if(n===o&&t===a)return;a=t,o=n,i.push(rz(t,n));let s=r[t]||(r[t]=Object.create(null));s[n]||(s[n]=[])}),n.pending.forEach(e=>{let{provider:t,prefix:n,name:i}=e,a=rz(t,n),o=a.pendingIcons||=new Set;o.has(i)||(o.add(i),r[t][n].push(i))}),i.forEach(e=>{let t=r[e.provider][e.prefix];t.length&&nB(e,t)}),t?Vz(t,n,i):Zz};function iB(e,t){let n={...e};for(let e in t){let r=t[e],i=typeof r;e in dz?(r===null||r&&(i===`string`||i===`number`))&&(n[e]=r):i===typeof n[e]&&(n[e]=e===`rotate`?r%4:r)}return n}var aB=/[\s,]+/;function oB(e,t){t.split(aB).forEach(t=>{switch(t.trim()){case`horizontal`:e.hFlip=!0;break;case`vertical`:e.vFlip=!0}})}function sB(e,t=0){let n=e.replace(/^-?[0-9.]*/,``);function r(e){for(;e<0;)e+=4;return e%4}if(n===``){let t=parseInt(e);return isNaN(t)?0:r(t)}if(n!==e){let t=0;switch(n){case`%`:t=25;break;case`deg`:t=90}if(t){let i=parseFloat(e.slice(0,e.length-n.length));return isNaN(i)?0:(i/=t,i%1==0?r(i):0)}}return t}function cB(e,t){let n=e.indexOf(`xlink:`)===-1?``:` xmlns:xlink="http://www.w3.org/1999/xlink"`;for(let e in t)n+=` `+e+`="`+t[e]+`"`;return`<svg xmlns="http://www.w3.org/2000/svg"`+n+`>`+e+`</svg>`}function lB(e){return e.replace(/"/g,`'`).replace(/%/g,`%25`).replace(/#/g,`%23`).replace(/</g,`%3C`).replace(/>/g,`%3E`).replace(/\s+/g,` `).replace(/:/g,`%3A`).replace(/\//g,`%2F`)}function uB(e){return`data:image/svg+xml,`+lB(e)}function dB(e){return`url("`+uB(e)+`")`}var fB={...fz,inline:!1},pB={xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,"aria-hidden":!0,role:`img`},mB={display:`inline-block`},hB={"background-color":`currentColor`},gB={"background-color":`transparent`},_B={image:`var(--svg)`,repeat:`no-repeat`,size:`100% 100%`},vB={"-webkit-mask":hB,mask:hB,background:gB};for(let e in vB){let t=vB[e];for(let n in _B)t[e+`-`+n]=_B[n]}function yB(e){return e+(e.match(/^[-0-9.]+$/)?`px`:``)}function bB(e,t){let n=iB(fB,t),r=t.mode||`svg`,i=r===`svg`?{...pB}:{};e.body.indexOf(`xlink:`)===-1&&delete i[`xmlns:xlink`];let a=typeof t.style==`string`?t.style:``;for(let e in t){let r=t[e];if(r!==void 0)switch(e){case`icon`:case`style`:case`onLoad`:case`mode`:case`ssr`:break;case`inline`:case`hFlip`:case`vFlip`:n[e]=r===!0||r===`true`||r===1;break;case`flip`:typeof r==`string`&&oB(n,r);break;case`color`:a=a+(a.length>0&&a.trim().slice(-1)!==`;`?`;`:``)+`color: `+r+`; `;break;case`rotate`:typeof r==`string`?n[e]=sB(r):typeof r==`number`&&(n[e]=r);break;case`ariaHidden`:case`aria-hidden`:r!==!0&&r!==`true`&&delete i[`aria-hidden`];break;default:if(e.slice(0,3)===`on:`)break;fB[e]===void 0&&(i[e]=r)}}let o=bz(e,n),s=o.attributes;if(n.inline&&(a=`vertical-align: -0.125em; `+a),r===`svg`)return Object.assign(i,s),a!==``&&(i.style=a),{svg:!0,attributes:i,body:wz(o.body)};let{body:c,width:l,height:u}=e,d=r===`mask`||r!==`bg`&&c.indexOf(`currentColor`)!==-1,f={"--svg":dB(cB(c,{...s,width:l+``,height:u+``}))},p=e=>{let t=s[e];t&&(f[e]=yB(t))};p(`width`),p(`height`),Object.assign(f,mB,d?hB:gB);let m=``;for(let e in f)m+=e+`: `+f[e]+`;`;return i.style=m+a,{svg:!1,attributes:i}}if(sz(!0),Ez(``,Lz),typeof document<`u`&&typeof window<`u`){let e=window;if(e.IconifyPreload!==void 0){let t=e.IconifyPreload,n=`Invalid IconifyPreload syntax.`;typeof t==`object`&&t&&(t instanceof Array?t:[t]).forEach(e=>{try{(typeof e!=`object`||!e||e instanceof Array||typeof e.icons!=`object`||typeof e.prefix!=`string`||!uz(e))&&console.error(n)}catch{console.error(n)}})}if(e.IconifyProviders!==void 0){let t=e.IconifyProviders;if(typeof t==`object`&&t)for(let e in t){let n=`IconifyProviders[`+e+`] is invalid.`;try{let r=t[e];if(typeof r!=`object`||!r||r.resources===void 0)continue;Az(e,r)||console.error(n)}catch{console.error(n)}}}}function xB(){try{return typeof window!=`object`}catch{return!0}}function SB(e,t,n,r){function i(){t.loading&&=(t.loading.abort(),null)}if(typeof e==`object`&&e&&typeof e.body==`string`)return t.name=``,i(),{data:{...KR,...e}};let a;if(typeof e!=`string`||(a=VR(e,!1,!0))===null)return i(),null;let o=cz(a);if(!o)return xB()||t.loading&&t.loading.name===e||(i(),t.name=``,t.loading={name:e,abort:rB([a],n)}),null;i(),t.name!==e&&(t.name=e,r&&!t.destroyed&&setTimeout(()=>{r(e)}));let s=[`iconify`];return a.prefix!==``&&s.push(`iconify--`+a.prefix),a.provider!==``&&s.push(`iconify--`+a.provider),{data:o,classes:s}}function CB(e,t){return e?bB({...KR,...e},t):null}var wB=new Set([`$$slots`,`$$events`,`$$legacy`]),TB=k(`<svg></svg>`),EB=D(`<span></span>`);function DB(e,n){V(n,!0);let r={name:``,loading:null,destroyed:!1},i=W(n,wB),a=Z(0),s=T(()=>(C(a),SB(n.icon,r,d,n.onload))),l=T(()=>{let e=C(s)?CB(C(s).data,i):null;return e&&C(s).classes&&i.class===void 0&&(e.attributes.class=(typeof i.class==`string`?i.class+` `:``)+C(s).classes.join(` `)),e});function d(){te(a)}g(()=>{r.destroyed=!0,r.loading&&=(r.loading.abort(),null)});var f=u(),p=z(f),m=e=>{var n=u(),r=z(n),i=e=>{var t=TB();R(t,()=>({...C(l).attributes})),o(t,()=>C(l).body,!0),c(t),O(e,t)},a=e=>{var t=EB();R(t,()=>({...C(l).attributes})),O(e,t)};t(r,e=>{C(l).svg?e(i):e(a,-1)}),O(e,n)};t(p,e=>{C(l)&&e(m)}),O(e,f),b()}var OB=D(`<span> </span>`),kB=D(`<!> `,1),AB=D(`<button type="button" class="scroll-button back svelte-bbimj6"><!></button>`),jB=D(`<button type="button" class="scroll-button forward svelte-bbimj6"><!></button>`),MB=D(`<div><!> <!> <!></div>`);function NB(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),o=J(n,`bare`,3,!1),s=Z(null),l=Z(!1),d=Z(!1);function p(){if(!C(s))return;let{scrollLeft:e,scrollWidth:t,clientWidth:n}=C(s);P(l,e>1),P(d,e+n<t-1)}le(()=>{if(!C(s))return;let e=new ResizeObserver(p);return e.observe(C(s)),p(),()=>e.disconnect()}),le(()=>{if(!C(s))return;let e=C(s).querySelector(`[data-value="${CSS.escape(n.activeTabId)}"]`);if(!e)return;let t=e.offsetLeft-32,r=e.offsetLeft+e.offsetWidth+32;t<C(s).scrollLeft?C(s).scrollLeft=t:r>C(s).scrollLeft+C(s).clientWidth&&(C(s).scrollLeft=r-C(s).clientWidth)});function h(e){C(s)?.scrollBy({left:e*C(s).clientWidth*.7,behavior:`smooth`})}function g(e){C(s)&&(C(l)||C(d))&&(Math.abs(e.deltaX)>Math.abs(e.deltaY)||(e.preventDefault(),C(s).scrollLeft+=e.deltaY))}var _=MB(),v=I(_);E(v,()=>gn,(e,r)=>{r(e,{variant:`line`,onscroll:p,onwheel:g,get ref(){return C(s)},set ref(e){P(s,e,!0)},children:(e,r)=>{var i=u(),o=z(i);a(o,17,()=>n.tabs,e=>e.id,(e,r)=>{var i=u(),a=z(i);E(a,()=>vn,(e,i)=>{i(e,{get value(){return C(r).id},onclick:()=>n.onTabChange(C(r).id),variant:`line`,children:(e,n)=>{var i=kB(),a=z(i),o=e=>{var n=u(),i=z(n),a=e=>{DB(e,{get icon(){return C(r).icon},class:`h-4 w-4`})},o=T(()=>C(r).icon.includes(`:`)),s=e=>{var t=OB(),n=K(t,!0);G(()=>m(n,C(r).icon)),O(e,t)};t(i,e=>{C(o)?e(a):e(s,-1)}),O(e,n)};t(a,e=>{C(r).icon&&e(o)});var s=U(a);G(()=>m(s,` ${C(r).label??``}`)),O(e,i)},$$slots:{default:!0}})}),O(e,i)}),O(e,i)},$$slots:{default:!0}})});var y=U(v,2),x=e=>{var t=AB(),n=I(t);ct(n,{class:`h-4 w-4`}),c(t),G(()=>H(t,`aria-label`,C(i).scrollTabsBack)),f(`click`,t,()=>h(-1)),O(e,t)};t(y,e=>{C(l)&&e(x)});var S=U(y,2),w=e=>{var t=jB(),n=I(t);ut(n,{class:`h-4 w-4`}),c(t),G(()=>H(t,`aria-label`,C(i).scrollTabsForward)),f(`click`,t,()=>h(1)),O(e,t)};t(S,e=>{C(d)&&e(w)}),c(_),G(()=>fe(_,1,`tab-bar relative shrink-0 border-b border-border ${o()?`mx-1`:`mx-3`}`,`svelte-bbimj6`)),O(e,_),b()}ce([`click`]);var PB={".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".webp":`image/webp`,".gif":`image/gif`,".svg":`image/svg+xml`,".json":`application/json`,".txt":`text/plain`,".csv":`text/csv`,".xml":`application/xml`,".pdf":`application/pdf`,".3dm":`model/vnd.3dm`,".obj":`model/obj`,".stl":`model/stl`};function FB(e){let t=PB[(e.fileType??``).toLowerCase()]??`application/octet-stream`,n=e.isBase64Encoded?aI(e.data):e.data;return _F(new Blob([n],{type:t}),`${e.fileName}${e.fileType??``}`)}async function IB(e,t=`grasshopper-output`){try{let n=Array.isArray(e)?e:[e];if(n.length===0){console.warn(`[FileDownload] No files to download`);return}if(n.length===1){await FB(n[0]);return}await mI(n,t,null,{saveBlob:_F})}catch(e){throw console.error(`[FileDownload] Error downloading files:`,e),e}}function LB(e){return typeof e==`object`&&!!e&&`fileName`in e&&`data`in e&&`isBase64Encoded`in e}function RB(e){if(e===0)return`0 Bytes`;let t=rl.FILE_SIZE.BYTES_PER_KB,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/t**+r*100)/100+` `+n[r]}function zB(e){return Math.ceil(e.length*3/4)}var BB=e=>Array.isArray(e)?e.map(String):e==null||e===``?[]:[String(e)],VB={equals:(e,t)=>e===t,notEquals:(e,t)=>e!==t,greaterThan:(e,t)=>Number(e)>Number(t),lessThan:(e,t)=>Number(e)<Number(t),greaterThanOrEqual:(e,t)=>Number(e)>=Number(t),lessThanOrEqual:(e,t)=>Number(e)<=Number(t),between:(e,t,n)=>n?.length===2&&Number(e)>=Number(n[0])&&Number(e)<=Number(n[1]),in:(e,t,n)=>n?.includes(String(e))??!1,notIn:(e,t,n)=>!(n?.includes(String(e))??!1),matches:(e,t)=>{try{return new RegExp(String(t)).test(String(e))}catch{return!1}},contains:(e,t)=>BB(e).includes(String(t)),containsAny:(e,t,n)=>{let r=BB(e);return n?.some(e=>r.includes(String(e)))??!1},isEmpty:e=>BB(e).length===0,isNotEmpty:e=>BB(e).length>0};function HB(e,t){let n=VB[e.operator];return n?n(t[e.paramId],e.value,e.values):!1}function UB(e,t){let n=e.rules.map(e=>HB(e,t));return e.mode===`any`?n.some(Boolean):n.every(Boolean)}var WB={show:e=>({visible:e,disabled:!1}),hide:(e,t)=>({visible:!e,disabled:!1,defaultValue:t}),disable:(e,t)=>({visible:!0,disabled:e,defaultValue:e?t:void 0})};function GB(e,t){if(e.type===`linebreak`)return{visible:!0,disabled:!1};if(`visible`in e&&e.visible===!1||e.type===`output`&&KB(e,t[e.paramId]))return{visible:!1,disabled:!1};if(!e.visibilityCondition?.rules)return{visible:!0,disabled:!1};let{action:n=`show`,defaultValue:r}=e.visibilityCondition,i=UB(e.visibilityCondition,t);return(WB[n]??WB.show)(i,r)}function KB(e,t){switch(e.widgetType){case`image`:return!(Array.isArray(t)?t.some(LB):LB(t));case`chart`:return t==null||t===``;case`dynamicValueList`:return!0;default:return!1}}function qB(e){return e.type===`linebreak`?e.id:e.paramId}function JB(e,t){let n={};for(let r of e)n[qB(r)]=GB(r,t);return n}function YB(e,t){if(e.items&&!ZB(e.items,t))return!1;if(!e.visibilityCondition?.rules)return!0;let{action:n=`show`}=e.visibilityCondition,r=UB(e.visibilityCondition,t);return n===`hide`?!r:r}function XB(e,t){return e.visible!==!1&&e.groups.some(e=>YB(e,t))}function ZB(e,t){return e.some(e=>e.type!==`linebreak`&&GB(e,t).visible)}var QB=D(`<div class="schema-grid svelte-ejp005"></div>`),$B=D(`<div class="grid-break svelte-ejp005" aria-hidden="true"></div>`),eV=D(`<div><!></div>`),tV=D(`<div class="p-4"><!></div>`),nV=D(`<p class="pl-4 pr-11 pt-0.5 pb-3 text-xs leading-snug text-muted-foreground"> </p>`),rV=D(`<h3><button type="button"><span class="min-w-0 text-sm font-semibold leading-snug flex-1 text-foreground"> </span> <!></button></h3> <!> <div><div class="content-inner svelte-ejp005"><div class="px-4 pt-2 pb-5"><!></div></div></div>`,1),iV=D(`<section class="rounded-xl border bg-card shadow-raised"><!></section>`);function aV(e,n){let r=l();V(n,!0);let i=e=>{var t=QB();a(t,21,()=>n.items,e=>e.type===`linebreak`?e.id:e.paramId,(e,t)=>{o(e,()=>C(t))}),c(t),G(()=>N(t,`--schema-cols: ${C(_)??``}; --column-gap: 16px;`)),oe(t,`clientWidth`,e=>P(g,e)),O(e,t)},o=(e,r=h)=>{var i=u(),a=z(i),o=e=>{var t=$B();O(e,t)},s=e=>{let i=T(()=>C(d)[qB(r())]),a=T(()=>Math.min(Math.max(1,r().span??1),C(_)));var o=u(),s=z(o),l=e=>{var o=eV();let s;var l=I(o),d=e=>{var t=u(),a=z(t);x(a,()=>n.inputSnippet,r,()=>C(i)),O(e,t)},f=e=>{var t=u(),i=z(t);x(i,()=>n.outputSnippet,r),O(e,t)};t(l,e=>{r().type===`input`?e(d):r().type===`output`&&e(f,1)}),c(o),G(()=>{s=fe(o,1,`grid-cell min-w-0 svelte-ejp005`,null,s,{"opacity-50":C(i).disabled}),N(o,`--span: ${C(a)??``}`)}),O(e,o)};t(s,e=>{C(i).visible&&e(l)}),O(e,o)};t(a,e=>{r().type===`linebreak`?e(o):e(s,-1)}),O(e,i)},s=J(n,`flat`,3,!1),d=T(()=>JB(n.items,n.values)),p=`${r}-description`,g=Z(0),_=T(()=>C(g)===0?n.columns:Math.max(1,Math.min(n.columns,Math.floor((C(g)+16)/176))));var v=iV(),y=I(v),S=e=>{var t=tV(),n=I(t);i(n),c(t),O(e,t)},w=e=>{var r=rV(),a=z(r),o=I(a),s=I(o),l=K(s,!0),u=U(s,2);{let e=T(()=>n.collapsed?`-rotate-90`:``);st(u,{get class(){return`mt-0.5 h-4 w-4 shrink-0 text-faint-foreground transition-transform duration-200 ${C(e)??``}`}})}c(o),c(a);var d=U(a,2),h=e=>{var t=nV(),r=K(t,!0);G(()=>{H(t,`id`,p),m(r,n.description)}),O(e,t)};t(d,e=>{n.description&&e(h)});var g=U(d,2);let _;var v=I(g),y=I(v),b=I(y);i(b),c(y),c(v),c(g),G(()=>{fe(o,1,`gap-3 px-4 pt-4 flex w-full items-start text-left outline-none select-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset ${n.description?`pb-0`:`pb-3`}`),H(o,`aria-expanded`,!n.collapsed),H(o,`aria-describedby`,n.description?p:void 0),m(l,n.label),_=fe(g,1,`content-wrapper svelte-ejp005`,null,_,{collapsed:n.collapsed}),g.inert=n.collapsed}),f(`click`,o,function(...e){n.onToggle?.apply(this,e)}),O(e,r)};t(y,e=>{s()?e(S):e(w,-1)}),c(v),O(e,v),b()}ce([`click`]);var oV=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`]);function sV(e,t){V(t,!0);let n=J(t,`ref`,15,null),r=W(t,oV);{let i=T(()=>Fe(`group/field-label peer/field-label gap-2 leading-snug flex w-fit group-data-[disabled=true]/field:opacity-50`,`[&>*]:data-[slot=field]:p-4 has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border`,`has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10`,t.class));mn(e,q({"data-slot":`field-label`,get class(){return C(i)}},()=>r,{get ref(){return n()},set ref(e){n(e)},children:(e,n)=>{var r=u(),i=z(r);x(i,()=>t.children??h),O(e,r)},$$slots:{default:!0}}))}b()}var cV=new Set([`$$slots`,`$$events`,`$$legacy`,`ref`,`class`,`children`,`errors`]),lV=D(`<li> </li>`),uV=D(`<ul class="ms-4 gap-1 flex list-disc flex-col"></ul>`),dV=D(`<div><!></div>`);function fV(e,n){V(n,!0);let r=J(n,`ref`,15,null),i=W(n,cV),o=T(()=>n.children?!0:!(!n.errors||n.errors.length===0||n.errors.length===1&&!n.errors[0]?.message)),s=T(()=>n.errors&&n.errors.length>1),l=T(()=>n.errors&&n.errors.length===1&&n.errors[0]?.message);var d=u(),f=z(d),h=e=>{var o=dV();R(o,e=>({role:`alert`,"data-slot":`field-error`,class:e,...i}),[()=>Fe(`text-sm font-normal text-destructive`,n.class)]);var d=I(o),f=e=>{var t=u(),r=z(t);x(r,()=>n.children),O(e,t)},h=e=>{var t=p();G(()=>m(t,C(l))),O(e,t)},g=e=>{var r=uV();a(r,21,()=>n.errors??[],y,(e,n)=>{var r=u(),i=z(r),a=e=>{var t=lV(),r=K(t,!0);G(()=>m(r,C(n).message)),O(e,t)};t(i,e=>{C(n)?.message&&e(a)}),O(e,r)}),c(r),O(e,r)};t(d,e=>{n.children?e(f):C(l)?e(h,1):C(s)&&e(g,2)}),c(o),F(o,e=>r(e),()=>r()),O(e,o)};t(f,e=>{C(o)&&e(h)}),O(e,d),b()}var pV=D(`<button><!></button>`),mV=D(`<!> <!>`,1);function hV(e,t){V(t,!0);let n=J(t,`nameTemplate`,3,`Help for {label}`);var r=u(),i=z(r);E(i,()=>pn,(e,r)=>{r(e,{children:(e,r)=>{var i=mV(),a=z(i);{let e=(e,r)=>{let i=()=>(r?.()).props;var a=pV();R(a,e=>({...i(),class:`-m-1 size-6 pointer-coarse:after:-inset-2.5 relative flex shrink-0 cursor-help items-center justify-center rounded-sm text-muted-foreground transition hover:text-foreground pointer-coarse:after:absolute pointer-fine:opacity-0 pointer-fine:group-focus-within/field:opacity-100 pointer-fine:group-hover/field:opacity-100 pointer-fine:focus-visible:opacity-100`,"aria-label":e}),[()=>nt(n(),{label:t.label})]),Fn(I(a),{class:`size-3.5`}),c(a),O(e,a)};E(a,()=>Re,(t,n)=>{n(t,{child:e,$$slots:{child:!0}})})}var o=U(a,2);E(o,()=>fn,(e,n)=>{n(e,{class:`sm:max-w-md`,children:(e,n)=>{var r=u(),i=z(r);E(i,()=>un,(e,n)=>{n(e,{children:(e,n)=>{var r=mV(),i=z(r);E(i,()=>ln,(e,n)=>{n(e,{children:(e,n)=>{S();var r=p();G(()=>m(r,t.label)),O(e,r)},$$slots:{default:!0}})});var a=U(i,2);E(a,()=>dn,(e,n)=>{n(e,{children:(e,n)=>{S();var r=p();G(()=>m(r,t.description)),O(e,r)},$$slots:{default:!0}})}),O(e,r)},$$slots:{default:!0}})}),O(e,r)},$$slots:{default:!0}})}),O(e,i)},$$slots:{default:!0}})}),O(e,r),b()}var gV=D(`<div class="gap-2.5 min-h-6 min-w-0 flex items-center"><!> <!></div>`);function _V(e,t){V(t,!0);let n=J(t,`value`,15),r=J(t,`disabled`,3,!1);var i=gV(),a=I(i);{let e=T(()=>typeof n()==`boolean`&&n());Co(a,{get id(){return t.inputId},get checked(){return C(e)},onCheckedChange:e=>{n(e===!0),t.onChange(e===!0)},get disabled(){return r()}})}var o=U(a,2);x(o,()=>t.children??h),c(i),O(e,i),b()}var vV=6;function yV(e,t){switch(e){case`checklist`:case`tiles`:return e;case`segmented`:return t<=vV?`segmented`:`dropdown`;default:return`dropdown`}}var bV=/^data:image\/(webp|jpeg|png);base64,[A-Za-z0-9+/=]+$/;function xV(e,t){if(!e||!t)return;if(e.image){let n=t[e.image]?.img;if(n&&bV.test(n))return{kind:`image`,src:n}}let n=e.icon?t[e.icon]?.d:void 0;return n?{kind:`icon`,d:n}:void 0}var SV=k(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path></path></svg>`),CV=D(`<img alt=""/>`);function wV(e,n){V(n,!0);var r=u(),i=z(r),a=e=>{var t=SV(),r=K(t);G(e=>{fe(t,0,e),H(r,`d`,n.glyph.d)},[()=>me(Fe(`size-4 shrink-0`,n.class))]),O(e,t)},o=e=>{var t=CV();G(e=>{H(t,`src`,n.glyph.src),fe(t,1,e)},[()=>me(Fe(`size-4 shrink-0 rounded-sm object-cover`,n.class))]),O(e,t)};t(i,e=>{n.glyph.kind===`icon`?e(a):e(o,-1)}),O(e,r),b()}var TV=D(`<label><!> <!> <span> </span></label>`),EV=D(`<div class="divide-y divide-border overflow-hidden rounded-md border border-input"></div>`);function DV(e,n){V(n,!0);let r=J(n,`disabled`,3,!1),i=T(()=>n.config?.options??{}),o=T(()=>new Set(n.value??[]));function s(e,t){let r=new ye(C(o));t?r.add(e):r.delete(e),n.onChange([...r])}var l=EV();a(l,21,()=>Object.entries(C(i)),([e,t])=>e,(e,i)=>{var a=T(()=>w(C(i),2));let l=()=>C(a)[0],u=()=>C(a)[1],d=T(()=>u()??l()),f=T(()=>`${n.inputId}-${C(d)}`),p=T(()=>C(o).has(C(d))),h=T(()=>xV(n.config?.optionMedia?.[l()],n.assets));var g=TV(),_=I(g);Co(_,{get id(){return C(f)},get checked(){return C(p)},onCheckedChange:e=>s(C(d),e===!0),get disabled(){return r()}});var v=U(_,2),y=e=>{wV(e,{get glyph(){return C(h)},class:`text-muted-foreground`})};t(v,e=>{C(h)&&e(y)});var b=U(v,2);let x;var S=K(b,!0);c(g),G(()=>{H(g,`for`,C(f)),fe(g,1,`gap-3 px-3 py-2 text-sm flex items-center transition-colors select-none hover:bg-hover ${C(p)?`bg-selected`:``} ${r()?`cursor-not-allowed opacity-50`:`cursor-pointer`}`),x=fe(b,1,`flex-1`,null,x,{"font-medium":C(p)}),m(S,l())}),O(e,g)}),c(l),O(e,l),b()}function OV(e,t){let n=null;function r(...r){n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...r),n=null},t)}return r.cancel=()=>{n!==null&&(clearTimeout(n),n=null)},r}var kV=(e,t,n)=>Math.min(n,Math.max(t,e));function AV(e){let t=e.trim().replace(/^#/,``);return/^[0-9a-f]{3}$/i.test(t)?`#${t.split(``).map(e=>e+e).join(``).toLowerCase()}`:/^[0-9a-f]{6}$/i.test(t)?`#${t.toLowerCase()}`:null}function jV(e){let t=AV(e);return t?{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16)}:null}function MV({r:e,g:t,b:n}){let r=e=>kV(Math.round(e),0,255).toString(16).padStart(2,`0`);return`#${r(e)}${r(t)}${r(n)}`}function NV({r:e,g:t,b:n}){let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=o-Math.min(r,i,a),c=0;return s!==0&&(c=o===r?(i-a)/s%6:o===i?(a-r)/s+2:(r-i)/s+4,c*=60,c<0&&(c+=360)),{h:c,s:o===0?0:s/o,v:o}}function PV({h:e,s:t,v:n}){let r=n*t,i=(e%360+360)%360/60,a=r*(1-Math.abs(i%2-1)),[o,s,c]=i<1?[r,a,0]:i<2?[a,r,0]:i<3?[0,r,a]:i<4?[0,a,r]:i<5?[a,0,r]:[r,0,a],l=n-r;return{r:(o+l)*255,g:(s+l)*255,b:(c+l)*255}}var FV=e=>{let t=jV(e);return t?NV(t):null},IV=e=>MV(PV(e));function LV({r:e,g:t,b:n}){let r=e=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function RV(e,t){let n=jV(e),r=jV(t);if(!n||!r)return null;let i=LV(n),a=LV(r);return(Math.max(i,a)+.05)/(Math.min(i,a)+.05)}var zV=D(`<button><span class="size-5 shrink-0 rounded-md bg-(--swatch) ring-1 ring-border ring-inset"></span> <span class="font-mono text-sm text-muted-foreground"> </span></button>`),BV=D(`<button type="button" class="size-9 flex shrink-0 cursor-pointer items-center justify-center rounded-md border border-input bg-background outline-none hover:bg-hover focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"><!></button>`),VV=D(`<p role="alert" class="text-xs text-destructive"> </p>`),HV=D(`<button type="button" class="h-6 flex cursor-pointer items-center justify-center rounded-md bg-(--swatch) ring-1 ring-border outline-none ring-inset focus-visible:ring-3 focus-visible:ring-ring disabled:cursor-not-allowed"><!></button>`),UV=D(`<div role="slider" class="color-area h-36 relative w-full cursor-crosshair touch-none rounded-md outline-none focus-visible:ring-3 focus-visible:ring-ring svelte-9colnt"><span class="color-thumb size-4 border-white pointer-events-none absolute -translate-x-1/2 -translate-y-1/2 rounded-full border-2 bg-(--swatch) svelte-9colnt"></span></div> <input type="range" class="color-hue svelte-9colnt" min="0" max="360" step="1"/> <div class="gap-2 flex items-start"><div class="min-w-0 flex-1"><!></div> <!></div> <!> <div role="group" class="gap-1.5 grid grid-cols-6"></div>`,1),WV=D(`<!> <!>`,1);function GV(e,n){V(n,!0);let r=J(n,`value`,3,`#000000`),i=J(n,`disabled`,3,!1),o=[`#000000`,`#ffffff`,`#9ca3af`,`#ef4444`,`#f97316`,`#eab308`,`#22c55e`,`#14b8a6`,`#3b82f6`,`#8b5cf6`,`#ec4899`,`#78350f`],s=globalThis.EyeDropper,l=at(),d=T(()=>l.messages),p=e=>FV(AV(e)??`#000000`),h=Z(B(Y(()=>p(r())))),g=Z(``),_=Z(!1),v=Z(null),y=T(()=>IV(C(h))),x=T(()=>IV({h:C(h).h,s:1,v:1}));le(()=>{let e=AV(r())??`#000000`;e!==Y(()=>C(y))&&P(h,p(e),!0)}),le(()=>{P(g,C(y),!0),P(_,!1)});function S(){w.cancel(),C(y)!==AV(r())&&n.onChange(C(y))}let w=OV(S,150),D=e=>Math.min(1,Math.max(0,e));function k(e){if(!C(v))return;let t=C(v).getBoundingClientRect();P(h,{h:C(h).h,s:D((e.clientX-t.left)/t.width),v:D(1-(e.clientY-t.top)/t.height)},!0)}function A(e){i()||e.button!==0||(e.preventDefault(),C(v)?.focus(),C(v)?.setPointerCapture(e.pointerId),k(e))}function M(e){C(v)?.hasPointerCapture(e.pointerId)&&k(e)}function ee(e){C(v)?.hasPointerCapture(e.pointerId)&&(C(v).releasePointerCapture(e.pointerId),S())}function te(e){let t=e.shiftKey?.1:.01,{s:n,v:r}=C(h);switch(e.key){case`ArrowLeft`:n-=t;break;case`ArrowRight`:n+=t;break;case`ArrowUp`:r+=t;break;case`ArrowDown`:r-=t;break;case`PageUp`:r+=.1;break;case`PageDown`:r-=.1;break;default:return}e.preventDefault(),P(h,{h:C(h).h,s:D(n),v:D(r)},!0),w()}function ne(e){P(h,{...C(h),h:Number(e.currentTarget.value)},!0)}function L(e){P(h,p(e),!0),S()}function ie(){let e=AV(C(g));e?(P(_,!1),L(e),P(g,e,!0)):P(_,!0)}function ae(e){e.key===`Enter`&&(e.preventDefault(),ie())}function W(){AV(C(g))?ie():(P(g,C(y),!0),P(_,!1))}async function oe(){if(s)try{let{sRGBHex:e}=await new s().open();L(e)}catch{}}let ce=e=>(RV(e,`#000000`)??0)>(RV(e,`#ffffff`)??0)?`text-black`:`text-white`;var q=u(),ue=z(q);E(ue,()=>Pt,(e,r)=>{r(e,{children:(e,r)=>{var l=WV(),u=z(l);{let e=(e,t)=>{let r=()=>(t?.()).props;var a=zV();R(a,e=>({...r(),type:`button`,id:n.inputId,disabled:i(),"aria-label":e,class:`h-9 gap-2.5 px-2.5 shadow-xs max-w-48 flex w-full cursor-pointer items-center rounded-md border border-input bg-background text-left outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`}),[()=>nt(C(d).colorPick,{color:C(y)})],void 0,void 0,`svelte-9colnt`);var o=I(a);let s;var l=U(o,2),u=K(l,!0);c(a),G(()=>{s=N(o,``,s,{"--swatch":C(y)}),m(u,C(y))}),O(e,a)};E(u,()=>jt,(t,n)=>{n(t,{child:e,$$slots:{child:!0}})})}var p=U(u,2);E(p,()=>At,(e,r)=>{r(e,{align:`start`,children:(e,r)=>{var l=UV(),u=z(l);H(u,`aria-valuemin`,0),H(u,`aria-valuemax`,100);let p;var b=I(u);let w;c(u),F(u,e=>P(v,e),()=>C(v));var E=U(u,2);se(E);var D=U(E,2),k=I(D),R=I(k);{let e=T(()=>C(_)?`${n.inputId}-hex-error`:void 0);xn(R,{type:`text`,get"aria-label"(){return C(d).colorHex},get"aria-invalid"(){return C(_)},get"aria-describedby"(){return C(e)},autocomplete:`off`,spellcheck:!1,maxlength:7,get disabled(){return i()},onkeydown:ae,onblur:W,get value(){return C(g)},set value(e){P(g,e,!0)}})}c(k);var B=U(k,2),ie=e=>{var t=BV();kr(I(t),{class:`size-4`,"aria-hidden":`true`}),c(t),G(()=>{t.disabled=i(),H(t,`aria-label`,C(d).colorEyedropper),H(t,`title`,C(d).colorEyedropper)}),f(`click`,t,oe),O(e,t)};t(B,e=>{s&&e(ie)}),c(D);var V=U(D,2),q=e=>{var t=VV(),r=K(t,!0);G(()=>{H(t,`id`,`${n.inputId??``}-hex-error`),m(r,C(d).colorHexInvalid)}),O(e,t)};t(V,e=>{C(_)&&e(q)});var le=U(V,2);a(le,20,()=>o,e=>e,(e,n)=>{let r=T(()=>n===C(y));var a=HV();let o;var s=I(a),l=e=>{{let t=T(()=>ce(n));ot(e,{get class(){return`size-3.5 ${C(t)??``}`},"aria-hidden":`true`})}};t(s,e=>{C(r)&&e(l)}),c(a),G(()=>{a.disabled=i(),H(a,`aria-label`,n),H(a,`aria-pressed`,C(r)),o=N(a,``,o,{"--swatch":n})}),f(`click`,a,()=>L(n)),O(e,a)}),c(le),G((e,t,n)=>{H(u,`tabindex`,i()?-1:0),H(u,`aria-label`,C(d).colorArea),H(u,`aria-valuenow`,e),H(u,`aria-valuetext`,t),H(u,`aria-disabled`,i()),p=N(u,``,p,{"--hue":C(x)}),w=N(b,``,w,{"--x":`${C(h).s*100}%`,"--y":`${(1-C(h).v)*100}%`,"--swatch":C(y)}),H(E,`aria-label`,C(d).colorHue),re(E,n),E.disabled=i(),H(le,`aria-label`,C(d).colorPresets)},[()=>Math.round(C(h).v*100),()=>nt(C(d).colorAreaValue,{s:Math.round(C(h).s*100),v:Math.round(C(h).v*100)}),()=>Math.round(C(h).h)]),f(`pointerdown`,u,A),f(`pointermove`,u,M),f(`pointerup`,u,ee),j(`pointercancel`,u,ee),f(`keydown`,u,te),f(`input`,E,ne),f(`change`,E,S),O(e,l)},$$slots:{default:!0}})}),O(e,l)},$$slots:{default:!0}})}),O(e,q),b()}ce([`pointerdown`,`pointermove`,`pointerup`,`keydown`,`input`,`change`,`click`]);var KV=D(`<span class="gap-2 min-w-0 flex items-center"><!> <span class="truncate"> </span></span>`),qV=D(`<!> `,1),JV=D(`<!> <!>`,1);function YV(e,n){V(n,!0);let r=J(n,`value`,7),i=J(n,`disabled`,3,!1),o=at(),s=T(()=>n.config?.options||{}),l=T(()=>r()||``),d=T(()=>Object.entries(C(s)).find(([e,t])=>t===C(l))?.[0]??C(l)),f=e=>xV(n.config?.optionMedia?.[e],n.assets),p=T(()=>f(C(d)));var h=u(),g=z(h);E(g,()=>on,(e,h)=>{h(e,{type:`single`,get value(){return C(l)},onValueChange:e=>{e&&(r(e),n.onChange(e))},get disabled(){return i()},children:(e,r)=>{var l=JV(),h=z(l);E(h,()=>rn,(e,r)=>{r(e,{get id(){return n.inputId},class:`w-full`,get disabled(){return i()},children:(e,n)=>{var r=KV(),i=I(r),a=e=>{wV(e,{get glyph(){return C(p)}})};t(i,e=>{C(p)&&e(a)});var s=U(i,2),l=K(s,!0);c(r),G(()=>m(l,C(d)||o.messages.selectOption)),O(e,r)},$$slots:{default:!0}})});var g=U(h,2);E(g,()=>an,(e,n)=>{n(e,{children:(e,n)=>{var r=u(),i=z(r);a(i,17,()=>Object.entries(C(s)),([e,t])=>e,(e,n)=>{var r=T(()=>w(C(n),2));let i=()=>C(r)[0],a=()=>C(r)[1],o=T(()=>f(i()));var s=u(),c=z(s);{let e=T(()=>a()??i());E(c,()=>nn,(n,r)=>{r(n,{get value(){return C(e)},get label(){return i()},children:(e,n)=>{var r=qV(),a=z(r),s=e=>{wV(e,{get glyph(){return C(o)}})};t(a,e=>{C(o)&&e(s)});var c=U(a);G(()=>m(c,` ${i()??``}`)),O(e,r)},$$slots:{default:!0}})})}O(e,s)}),O(e,r)},$$slots:{default:!0}})}),O(e,l)},$$slots:{default:!0}})}),O(e,h),b()}function XV(e,t){return e===`.webp`&&t.includes(`.png`)}function ZV(e,t){let n=e.toLowerCase();return t.length===0||t.includes(n)?!0:XV(n,t)}var QV=(e,t,n)=>String.fromCharCode(...e.subarray(t,n));async function $V(e){if(e.type===`image/webp`)return!0;let t=new Uint8Array(await e.slice(0,12).arrayBuffer());return t.length===12&&QV(t,0,4)===`RIFF`&&QV(t,8,12)===`WEBP`}async function eH(e){let t=await createImageBitmap(e);try{let e=document.createElement(`canvas`);e.width=t.width,e.height=t.height;let n=e.getContext(`2d`);if(!n)throw Error(`Canvas 2D context unavailable`);return n.drawImage(t,0,0),await new Promise((t,n)=>e.toBlob(e=>e?t(e):n(Error(`PNG encoding failed`)),`image/png`))}finally{t.close()}}var tH=D(`<button type="button"> </button>`),nH=D(`<div class="p-0.5 text-xs flex rounded-md bg-muted"></div>`),rH=D(`<!> `,1),iH=D(`<div class="gap-1.5 text-xs flex items-center text-success"><!> </div>`),aH=D(`<p class="text-xs leading-snug pl-5 text-muted-foreground"> </p>`),oH=D(`<div class="p-2.5 gap-1.5 flex flex-col rounded-md border border-destructive/40 bg-destructive/5"><div class="gap-1.5 flex items-start"><!> <p class="text-xs leading-snug text-destructive"> </p></div> <!></div>`),sH=D(`<p class="text-xs text-muted-foreground"> </p>`),cH=D(`<div class="gap-2 flex flex-col"><!> <div class="gap-2 flex"><!> <!></div> <!> <!> <!></div>`),lH=D(`<div class="gap-2 flex flex-col"><!> <!></div>`),uH=D(`<div class="gap-2.5 flex w-full flex-col"><!> <!></div>`);function dH(e,n){V(n,!0);let r=J(n,`value`,15),i=J(n,`acceptedFormats`,19,()=>[]),o=J(n,`defaultInputMode`,3,`upload`),s=at(),l=T(()=>s.messages),u=T(()=>n.allowedInputModes&&n.allowedInputModes.length>0?n.allowedInputModes:[`upload`,`url`]),d=T(()=>C(u).length>1),h=Z(`upload`);le(()=>{let e=o()??`upload`;P(h,C(u).includes(e)?e:C(u)[0],!0)});let g=Z(``),_=Z(``),v=Z(!1),y=Z(!1),x=Z(null),w=Z(``);le(()=>{if(r())try{let e=typeof r()==`string`?JSON.parse(r()):r();if(e.type===`base64`){if(e._isMetadata&&e._fileSize){let t=(e._fileSize/1024/1024).toFixed(2);P(g,nt(C(l).uploadedFileSize,{ext:e.fileEnding,size:t}),!0)}else P(g,nt(C(l).uploadedFile,{ext:e.fileEnding}),!0)}else e.type===`url`&&P(_,e.file,!0)}catch{}});function E(e){return nt(C(l).fileFormatNotAccepted,{ext:e,formats:i().join(`, `)})}function D(e){return nt(C(l).fileTooLarge,{size:(e/1024/1024).toFixed(2),max:rl.FILE_UPLOAD.MAX_SIZE_MB})}function k(e){let t=e.split(`?`)[0];return(t.includes(`.`)?`.`+t.split(`.`).pop():`.tmp`).toLowerCase()}async function A(e,t){return e.size>rl.FILE_UPLOAD.MAX_SIZE_BYTES||!XV(t,i())?{blob:e,fileEnding:t}:{blob:await eH(e),fileEnding:`.png`}}function j(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{let n=e.target?.result;t(n.includes(`,`)?n.split(`,`)[1]:n)},r.onerror=()=>n(Error(C(l).fileReadFailed)),r.readAsDataURL(e)})}function M(e){return e instanceof TypeError&&e.message===`Failed to fetch`}async function N(){if(C(_).trim()){P(y,!0),P(x,null),P(w,``),P(g,``);try{let e;try{e=new URL(C(_))}catch{P(x,{message:C(l).urlInvalid,isCors:!1},!0);return}if(e.protocol!==`https:`&&e.protocol!==`http:`){P(x,{message:C(l).urlProtocolUnsupported,isCors:!1},!0);return}let t=await fetch(C(_));if(!t.ok){P(x,{message:nt(C(l).urlServerError,{status:`${t.status} ${t.statusText}`.trim()}),isCors:!1},!0);return}let a=await t.blob(),o=await $V(a)?`.webp`:k(C(_));if(!ZV(o,i())){P(x,{message:E(o),isCors:!1},!0);return}let{blob:s,fileEnding:c}=await A(a,o),u=rl.FILE_UPLOAD.MAX_SIZE_BYTES;if(s.size>u){P(x,{message:`${D(s.size)} ${C(l).fileTooLargeUseUpload}`,isCors:!1},!0);return}let d=await j(s),f=JSON.stringify({file:d,type:`base64`,fileEnding:c});r(f),P(w,nt(C(l).fileLoaded,{ext:c,size:(s.size/1024).toFixed(0)}),!0),n.onChange(f)}catch(e){if(M(e)){let e=(()=>{try{return new URL(C(_)).hostname}catch{return``}})(),t=C(l).urlUnreachableHint;e.includes(`sharepoint.com`)||e.includes(`onedrive.com`)?t=C(l).urlHintSharePoint:e.includes(`drive.google.com`)?t=C(l).urlHintGoogleDrive:e.includes(`dropbox.com`)&&(t=C(l).urlHintDropbox),P(x,{message:nt(C(l).urlUnreachable,{host:e}),isCors:!0,hint:t},!0)}else P(x,{message:e instanceof Error?e.message:C(l).unknownError,isCors:!1},!0)}finally{P(y,!1)}}}async function F(e){let t=k(e.name);if(!ZV(t,i()))Cn.error(E(t));else try{let{blob:i,fileEnding:a}=await A(e,t);if(i.size>rl.FILE_UPLOAD.MAX_SIZE_BYTES){Cn.error(D(i.size));return}P(g,e.name,!0);let o=JSON.stringify({file:await j(i),type:`base64`,fileEnding:a});r(o),n.onChange(o)}catch(e){Cn.error(e instanceof Error?e.message:C(l).fileReadFailed)}}async function ee(){let e=await vF({accept:C(R)});e&&F(e)}function te(e){e.preventDefault(),P(v,!0)}function ne(){P(v,!1)}function L(e){e.preventDefault(),P(v,!1);let t=e.dataTransfer?.files?.[0];t&&F(t)}let R=T(()=>i().length>0?i().join(`,`):`*`);var re=uH(),B=I(re),ie=e=>{var t=nH();a(t,20,()=>C(u),e=>e,(e,t)=>{var n=tH(),r=K(n,!0);G(()=>{H(n,`aria-pressed`,C(h)===t),fe(n,1,`px-3 py-1 font-medium flex-1 rounded-sm border transition-colors ${C(h)===t?`shadow-xs border-border-strong bg-raised text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`),m(r,t===`upload`?C(l).fileModeUpload:C(l).fileModeUrl)}),f(`click`,n,()=>P(h,t,!0)),O(e,n)}),c(t),O(e,t)};t(B,e=>{C(d)&&e(ie)});var ae=U(B,2),W=e=>{var n=cH(),r=I(n);mn(r,{for:`url-input`,children:(e,t)=>{var n=rH(),r=z(n);dr(r,{size:16});var i=U(r);G(()=>m(i,` ${C(l).fileUrlLabel??``}`)),O(e,n)},$$slots:{default:!0}});var i=U(r,2),a=I(i);{let e=T(()=>C(x)?!0:void 0);xn(a,{id:`url-input`,type:`url`,placeholder:`https://example.com/model.3dm`,get disabled(){return C(y)},get"aria-invalid"(){return C(e)},oninput:()=>{P(x,null),P(w,``)},get value(){return C(_)},set value(e){P(_,e,!0)}})}var o=U(a,2);{let e=T(()=>C(y)||!C(_).trim());tt(o,{type:`button`,variant:`outline`,get disabled(){return C(e)},onclick:N,children:(e,t)=>{S();var n=p();G(()=>m(n,C(y)?C(l).fetchingFile:C(l).fetchFile)),O(e,n)},$$slots:{default:!0}})}c(i);var s=U(i,2),u=e=>{var t=iH(),n=I(t);ft(n,{size:13});var r=U(n);c(t),G(()=>m(r,` ${C(w)??``}`)),O(e,t)};t(s,e=>{C(w)&&e(u)});var d=U(s,2),f=e=>{var n=oH(),r=I(n),i=I(r);pt(i,{size:13,class:`mt-0.5 shrink-0 text-destructive`});var a=U(i,2),o=K(a,!0);c(r);var s=U(r,2),l=e=>{var t=aH(),n=K(t,!0);G(()=>m(n,C(x).hint)),O(e,t)};t(s,e=>{C(x).isCors&&C(x).hint&&e(l)}),c(n),G(()=>m(o,C(x).message)),O(e,n)};t(d,e=>{C(x)&&e(f)});var h=U(d,2),g=e=>{var t=sH(),n=K(t,!0);G(()=>m(n,C(l).fileUrlPublic)),O(e,t)};t(h,e=>{!C(x)&&!C(w)&&e(g)}),c(n),O(e,n)},oe=e=>{var n=lH(),r=I(n);{let e=T(()=>C(v)?`secondary`:`outline`);tt(r,{type:`button`,get variant(){return C(e)},class:`w-full`,onclick:ee,ondragover:te,ondragleave:ne,ondrop:L,children:(e,t)=>{var n=rH(),r=z(n);Ct(r,{size:16});var i=U(r);G(()=>m(i,` ${(C(g)||C(l).chooseFile)??``}`)),O(e,n)},$$slots:{default:!0}})}var a=U(r,2),o=e=>{var t=sH(),n=K(t,!0);G(e=>m(n,e),[()=>nt(C(l).acceptedFormats,{formats:i().join(`, `)})]),O(e,t)};t(a,e=>{i().length>0&&e(o)}),c(n),O(e,n)};t(ae,e=>{C(h)===`url`?e(W):e(oe,-1)}),c(re),O(e,re),b()}ce([`click`]);var fH=D(`<span class="text-sm min-w-0 text-muted-foreground" role="status"> </span>`),pH=D(`<!> <!>`,1),mH=D(`<output class="text-sm min-w-0 text-muted-foreground"> </output>`),hH=D(`<div class="gap-2 min-w-0 flex flex-wrap items-center"><!> <!></div>`);function gH(e,n){V(n,!0);let r=J(n,`disabled`,3,!1),a=at(),o=T(()=>a.messages),s=[`geometryPickAnyOne`,`geometryPickAnyOther`],l={point:[`geometryPickPointOne`,`geometryPickPointOther`],pointCloud:[`geometryPickPointCloudOne`,`geometryPickPointCloudOther`],curve:[`geometryPickCurveOne`,`geometryPickCurveOther`],line:[`geometryPickLineOne`,`geometryPickLineOther`],plane:[`geometryPickPlaneOne`,`geometryPickPlaneOther`],surface:[`geometryPickSurfaceOne`,`geometryPickSurfaceOther`],polysurface:[`geometryPickPolysurfaceOne`,`geometryPickPolysurfaceOther`],extrusion:[`geometryPickExtrusionOne`,`geometryPickExtrusionOther`],mesh:[`geometryPickMeshOne`,`geometryPickMeshOther`],subd:[`geometryPickSubdOne`,`geometryPickSubdOther`],block:[`geometryPickBlockOne`,`geometryPickBlockOther`]},u=T(()=>{let[e,t]=n.kinds?.length===1?l[n.kinds[0]]:s;return C(o)[n.atMost===1?e:t]}),d=Z(!1),f=Z(void 0),h=T(()=>C(f)===void 0?n.summary??null:C(f));le(()=>n.watchSummary?.(e=>{P(f,e,!0)}));async function g(e){P(d,!0);try{let t=await e();t.outcome===`picked`?P(f,t.summary,!0):t.outcome===`failed`&&n.onError?.(t.error)}finally{P(d,!1)}}let _=T(()=>n.onPick?`span`:`output`);function v(e){P(f,null),e()}var y=hH(),x=I(y),w=e=>{{let t=T(()=>r()||C(d));tt(e,{get id(){return n.inputId},variant:`outline`,size:`sm`,onclick:()=>g(n.onPick),get disabled(){return C(t)},children:(e,t)=>{S();var n=p();G(()=>m(n,C(h)?C(o).geometryPickAgain:C(u))),O(e,n)},$$slots:{default:!0}})}};t(x,e=>{n.onPick&&e(w)});var E=U(x,2),D=e=>{var t=fH(),n=K(t,!0);G(()=>m(n,C(o).geometryPicking)),O(e,t)},k=e=>{var a=pH(),s=z(a);i(s,()=>C(_),!1,(e,t)=>{R(e,()=>({id:n.onPick?void 0:n.inputId,class:`text-sm min-w-0 truncate text-foreground`}));var r=p();G(()=>m(r,C(h))),O(t,r)});var c=U(s,2),l=e=>{tt(e,{variant:`ghost`,size:`sm`,onclick:()=>v(n.onClear),get disabled(){return r()},children:(e,t)=>{S();var n=p();G(()=>m(n,C(o).geometryClear)),O(e,n)},$$slots:{default:!0}})};t(c,e=>{n.onClear&&e(l)}),O(e,a)},A=e=>{var t=mH(),r=K(t,!0);G(()=>{H(t,`id`,n.inputId),m(r,C(o).geometryPickInPanel)}),O(e,t)};t(E,e=>{C(d)?e(D):C(h)?e(k,1):n.onPick||e(A,2)}),c(y),O(e,y),b()}var _H=D(`<span class="pr-2.5 text-sm shrink-0 text-muted-foreground"> </span>`),vH=D(`<!> <!> <!> <div class="px-3.5 min-w-0 flex flex-1 items-center"><!></div>`,1),yH=D(`<div class="relative"><!> <span class="right-3 text-sm inset-y-0 pointer-events-none absolute flex items-center text-muted-foreground"> </span></div>`),bH=D(`<!> <!>`,1);function xH(e,n){V(n,!0);let r=(e,t=h)=>{{let r=T(()=>C(v)?C(y):void 0),o=T(()=>n.config?.minimum),s=T(()=>n.config?.maximum),c=T(()=>n.config?.placeholder),u=T(()=>C(l)?!0:void 0),d=T(()=>C(l)?!0:void 0);xn(e,{get id(){return n.inputId},type:`number`,get class(){return t()},get"aria-describedby"(){return C(r)},get value(){return C(_)},get min(){return C(o)},get max(){return C(s)},get step(){return C(g)},get placeholder(){return C(c)},get"data-invalid"(){return C(u)},get"aria-invalid"(){return C(d)},get disabled(){return a()},oninput:()=>P(l,null),onchange:e=>{let t=parseFloat(e.currentTarget.value);isNaN(t)||k(t)},onblur:e=>{let t=parseFloat(e.currentTarget.value);if(!isNaN(t)){let e=D(t);P(l,e,!0),e||(i(t),x.cancel(),n.onChange(t))}}})}},i=J(n,`value`,15),a=J(n,`disabled`,3,!1),o=at(),s=T(()=>o.messages),l=Z(null),d=T(()=>n.config?.minimum??0),f=T(()=>n.config?.maximum??100),g=T(()=>n.config?.stepSize??1),_=T(()=>typeof i()==`number`?i():C(d)),v=T(()=>n.config?.unit?.trim()||void 0),y=T(()=>`${n.inputId}-unit`),x=OV(e=>n.onChange(e),400),w=OV(e=>n.onChange(e),150);function D(e){return n.config?.minimum!==void 0&&e<n.config.minimum?nt(C(s).minValue,{min:n.config.minimum}):n.config?.maximum!==void 0&&e>n.config.maximum?nt(C(s).maxValue,{max:n.config.maximum}):null}function k(e){let t=D(e);P(l,t,!0),t||(i(e),x(e))}let A=1e3,M=T(()=>(C(f)-C(d))/C(g)),F=T(()=>C(g)>0&&Number.isFinite(C(M))&&C(M)>A),ee=T(()=>C(F)?0:C(d)),te=T(()=>C(F)?A:C(f)),ne=T(()=>(String(C(g)).split(`.`)[1]??``).length),L=!1,R=!1,re=null,B=null;function ie(e){let t=Math.min(C(f),Math.max(C(d),e));if(!(C(g)>0))return t;let n=C(d)+Math.round((t-C(d))/C(g))*C(g);return Math.min(C(f),Number(n.toFixed(C(ne))))}function ae(e){return C(F)?Math.round((e-C(d))/(C(f)-C(d))*A):e}function W(e){return e/(C(te)-C(ee))*(C(f)-C(d))}function oe(e){if(C(f)<=C(d))return;let t;L&&R?(B??={track:re??e,value:C(_)},t=ie(B.value+W(e-B.track)/10)):(B=null,t=ie(C(d)+W(e-C(ee)))),re=e,i(t),w(t)}function se(e){L=!0,R=e.shiftKey,re=null,B=null}function ce(e){e.key===`Shift`&&(R=e.type===`keydown`)}let q=T(()=>Math.max(0,-Math.floor(Math.log10(C(g)))));function le(e){let t=parseFloat(e.value);if(isNaN(t)){e.value=C(_).toFixed(C(q));return}let r=Math.min(C(f),Math.max(C(d),t));e.value=r.toFixed(C(q)),r!==i()&&(i(r),n.onChange(r))}var Y=bH();j(`keydown`,de,ce),j(`keyup`,de,ce),j(`pointerup`,de,()=>L=!1),j(`blur`,de,()=>R=L=!1);var ue=z(Y),fe=e=>{var r=u(),i=z(r);E(i,()=>Ft,(e,r)=>{r(e,{children:(e,r)=>{var i=vH(),o=z(i);{let e=T(()=>C(_).toFixed(C(q))),t=T(()=>C(v)?C(y):void 0);E(o,()=>Mt,(r,i)=>{i(r,{get id(){return n.inputId},type:`number`,class:`w-18 flex-none`,get value(){return C(e)},get min(){return C(d)},get max(){return C(f)},get step(){return C(g)},get disabled(){return a()},onchange:e=>le(e.currentTarget),onkeydown:e=>{e.key===`Enter`&&e.currentTarget.blur()},get"aria-describedby"(){return C(t)}})})}var l=U(o,2),u=e=>{var t=_H(),n=K(t,!0);G(()=>{H(t,`id`,C(y)),m(n,C(v))}),O(e,t)};t(l,e=>{C(v)&&e(u)});var p=U(l,2);ht(p,{orientation:`vertical`});var h=U(p,2),b=I(h),x=()=>ae(C(_)),S=oe;{let e=T(()=>C(F)?1:C(g));Eo(b,{type:`single`,get value(){return x()},set value(e){S(e)},get min(){return C(ee)},get max(){return C(te)},get step(){return C(e)},get title(){return C(s).fineDragHint},get thumbLabelledby(){return n.labelId},get disabled(){return a()}})}c(h),j(`pointerdown`,h,se,!0),O(e,i)},$$slots:{default:!0}})}),O(e,r)},X=e=>{var t=yH();let n;var i=I(t);r(i,()=>`pr-[calc(var(--unit-len)*1ch+1.5rem)]`);var a=U(i,2),o=K(a,!0);c(t),G(()=>{n=N(t,``,n,{"--unit-len":C(v).length}),H(a,`id`,C(y)),m(o,C(v))}),O(e,t)},pe=e=>{r(e)};t(ue,e=>{n.config?.renderAsSlider?e(fe):C(v)?e(X,1):e(pe,-1)});var me=U(ue,2),he=e=>{var t=u(),n=z(t);E(n,()=>fV,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(l))),O(e,n)},$$slots:{default:!0}})}),O(e,t)};t(me,e=>{C(l)&&e(he)}),O(e,Y),b()}var SH=D(`<!> <span class="max-w-full truncate"> </span>`,1);function CH(e,n){V(n,!0);let r=J(n,`disabled`,3,!1),i=T(()=>Object.entries(n.config.options??{})),o=T(()=>C(i).some(([e])=>xV(n.config.optionMedia?.[e],n.assets)));var s=u(),c=z(s);{let e=T(()=>C(o)?`stacked`:`default`),s=T(()=>n.value??``);E(c,()=>yn,(o,c)=>{c(o,{type:`single`,variant:`outline`,spacing:0,get size(){return C(e)},class:`w-full`,get"aria-labelledby"(){return n.labelId},get value(){return C(s)},onValueChange:e=>{e&&n.onChange(e)},get disabled(){return r()},children:(e,r)=>{var o=u(),s=z(o);a(s,17,()=>C(i),([e,t])=>e,(e,r)=>{var i=T(()=>w(C(r),2));let a=()=>C(i)[0],o=()=>C(i)[1],s=T(()=>xV(n.config.optionMedia?.[a()],n.assets));var c=u(),l=z(c);{let e=T(()=>o()??a());E(l,()=>bn,(n,r)=>{r(n,{get value(){return C(e)},class:`min-w-0 flex-1`,get title(){return a()},children:(e,n)=>{var r=SH(),i=z(r),o=e=>{wV(e,{get glyph(){return C(s)}})};t(i,e=>{C(s)&&e(o)});var c=U(i,2),l=K(c,!0);G(()=>m(l,a())),O(e,r)},$$slots:{default:!0}})})}O(e,c)}),O(e,o)},$$slots:{default:!0}})})}O(e,s),b()}var wH=e=>e.kind===`point`,TH=e=>e.kind!==`point`,EH=(e,t)=>[e[0]+t[0],e[1]+t[1],e[2]+t[2]],DH=(e,t)=>[e[0]-t[0],e[1]-t[1],e[2]-t[2]],OH=(e,t)=>[e[0]*t,e[1]*t,e[2]*t],kH=(e,t)=>[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]],AH=(e,t)=>Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2]);function jH(e){let t=Math.hypot(e[0],e[1],e[2]);return t>0?OH(e,1/t):null}function MH(e,t){let n=e-t,r=[];for(let e=0;e<=t;e++)r.push(0);for(let e=1;e<n;e++)r.push(e);for(let e=0;e<=t;e++)r.push(n);return r}function NH(e,t=3){let n=Math.max(1,Math.min(t,e.length-1));return{kind:`nurbs`,degree:n,points:[...e],knots:MH(e.length,n)}}function PH(e){let t={};return e.id!==void 0&&(t.id=e.id),e.path!==void 0&&(t.path=e.path),e.attributes!==void 0&&(t.attributes=e.attributes),t}function FH(e){return`{${(e??[0]).join(`;`)}}`}function IH(e){let t=/^\{(-?\d+(?:;-?\d+)*)?\}$/.exec(e.trim());return t?t[1]?t[1].split(`;`).map(Number):[]:null}function LH(e){let t=new Map;for(let n of e){let e=FH(n.path),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function RH(e){return e.kind===`point`?[e.at]:e.kind===`line`?[e.from,e.to]:e.points}function zH(e,t,n){if(e.kind===`point`)return{...e,at:n};if(e.kind===`line`)return t===0?{...e,from:n}:{...e,to:n};let r=e.points.slice();return r[t]=n,{...e,points:r}}function BH(e,t){if(e.kind===`point`||e.kind===`line`)return null;let n=e.points.filter((e,n)=>n!==t);return n.length<2?null:e.kind===`polyline`?{...e,points:n,closed:e.closed&&n.length>2}:{...PH(e),...NH(n,e.degree)}}function VH(e,t){return e.kind===`point`?{...e,at:t(e.at)}:e.kind===`line`?{...e,from:t(e.from),to:t(e.to)}:{...e,points:e.points.map(t)}}function HH(e,t){return t===1?e:VH(e,e=>OH(e,t))}function UH(e){return e.kind===`point`?e.at.every(Number.isFinite):WH(e)}function WH(e){let t=e=>e.every(Number.isFinite);if(e.kind===`line`)return t(e.from)&&t(e.to)&&AH(e.from,e.to)>0;if(!e.points.every(t))return!1;if(e.kind===`polyline`)return e.points.length>=(e.closed?3:2);let{degree:n,points:r,knots:i,weights:a}=e;if(n<1||r.length<n+1||i.length!==r.length+n+1||a&&(a.length!==r.length||a.some(e=>!(e>0))))return!1;for(let e=1;e<i.length;e++)if(!(i[e]>=i[e-1]))return!1;return i[r.length]>i[n]}function GH(e){let t=[];for(let n of e){if(n.kind===`point`)continue;if(n.kind===`line`){AH(n.from,n.to)>0&&t.push(n);continue}if(n.kind===`nurbs`&&n.degree!==1)continue;let{id:e,...r}=PH(n),i=(e,n)=>{AH(e,n)>0&&t.push({...r,kind:`line`,from:e,to:n})},{points:a}=n;for(let e=1;e<a.length;e++)i(a[e-1],a[e]);n.kind===`polyline`&&n.closed&&i(a[a.length-1],a[0])}return t}function KH(e){return[e.knots[e.degree],e.knots[e.points.length]]}function qH(e,t){let{knots:n,degree:r,points:i}=e,a=i.length-1;if(t>=n[a+1]){let e=a;for(;e>r&&n[e]===n[e+1];)e--;return e}let o=r,s=a+1;for(;s-o>1;){let e=o+s>>1;t<n[e]?s=e:o=e}return o}function JH(e,t){let{knots:n,degree:r,points:i,weights:a}=e,[o,s]=KH(e),c=Math.min(Math.max(t,o),s),l=qH(e,c),u=[];for(let e=0;e<=r;e++){let t=l-r+e,n=a?.[t]??1;u.push([i[t][0]*n,i[t][1]*n,i[t][2]*n,n])}for(let e=1;e<=r;e++)for(let t=r;t>=e;t--){let i=l-r+t,a=n[i+r-e+1]-n[i],o=a===0?0:(c-n[i])/a;for(let e=0;e<4;e++)u[t][e]=(1-o)*u[t-1][e]+o*u[t][e]}let[d,f,p,m]=u[r];return[d/m,f/m,p/m]}function YH(e,t=16){if(e.kind===`line`)return[e.from,e.to];if(e.kind===`polyline`)return e.closed?[...e.points,e.points[0]]:[...e.points];let{knots:n,degree:r,points:i}=e,a=r===1?1:t,o=[];for(let t=r;t<i.length;t++){let r=n[t],i=n[t+1];if(i>r)for(let t=0;t<a;t++)o.push(JH(e,r+(i-r)*t/a))}return o.push(JH(e,KH(e)[1])),o}function XH(e,t){return{from:e,middle:OH(EH(e,t),.5),weight:1,to:t}}function ZH(e,t,n,r,i,a){let o=Math.max(1,Math.ceil(Math.abs(a)/(Math.PI/2)-1e-9)),s=a/o,c=Math.cos(s/2),l=(r,i)=>EH(e,EH(OH(t,i*Math.cos(r)),OH(n,i*Math.sin(r)))),u=[];for(let e=0;e<o;e++){let t=i+e*s;u.push({from:l(t,r),middle:l(t+s/2,r/c),weight:c,to:l(t+s,r)})}return u}function QH(e,t,n,r){let i=AH(e,t),a=jH(DH(t,e));if(n===0||!a||i===0)return[XH(e,t)];let o=kH(r,a),s=EH(OH(EH(e,t),.5),OH(o,i*(1-n*n)/(4*n))),c=i*(1+n*n)/(4*Math.abs(n)),l=jH(DH(e,s));if(!l)return[XH(e,t)];let u=ZH(s,l,kH(r,l),c,0,4*Math.atan(n));return u[0]={...u[0],from:e},u[u.length-1]={...u[u.length-1],to:t},u}function $H(e){let t=[e[0].from],n=[1],r=[0,0,0];return e.forEach((e,i)=>{t.push(e.middle,e.to),n.push(e.weight,1),r.push(i+1,i+1)}),r.push(e.length),{kind:`nurbs`,degree:2,points:t,knots:r,...n.some(e=>e!==1)?{weights:n}:{}}}function eU(e,t,n,r,i,a){return $H(ZH(e,t,n,r,i,a))}function tU(e){if(e.kind===`nurbs`||e.kind===`point`)return[];let t=YH(e),n=[];for(let e=1;e<t.length;e++)n.push({from:t[e-1],to:t[e],length:AH(t[e-1],t[e])});return n}function nU(e){let t=YH(e,48),n=0;for(let e=1;e<t.length;e++)n+=AH(t[e-1],t[e]);return n}function rU(e,t,n){if(e.kind===`nurbs`||e.kind===`point`||!(n>0)||!Number.isFinite(n))return e;if(e.kind===`line`){let t=jH(DH(e.to,e.from));return t?{...e,to:EH(e.from,OH(t,n))}:e}let{points:r}=e,i=r[t],a=t===r.length-1,o=a?r[0]:r[t+1];if(!i||!o||a&&!e.closed)return e;let s=jH(DH(o,i));if(!s)return e;let c=OH(s,n-AH(i,o));if(a){let n=r.slice();return n[t]=DH(i,c),{...e,points:n}}return{...e,points:r.map((e,n)=>n>t?EH(e,c):e)}}var iU=/^[0-9.,<-]$/;function aU(e){let[t,n,...r]=e.replaceAll(`,`,`.`).split(`<`);if(r.length>0)return null;let i={};if(t!==``){let e=Number(t);if(!(e>0)||!Number.isFinite(e))return null;i.length=e}if(n!==void 0&&n!==``){let e=Number(n);if(!Number.isFinite(e))return null;i.angle=e}return i.length===void 0&&i.angle===void 0?null:i}var oU=Math.PI/4;function sU(e,t){let{last:n,snapped:r,ortho:i,gridStep:a,typed:o}=t,s=e;if(!r&&a>0&&(s=[Math.round(s[0]/a)*a,Math.round(s[1]/a)*a,s[2]]),!r&&i&&n){let e=s[0]-n[0],t=s[1]-n[1],r=Math.round(Math.atan2(t,e)/oU)*oU,i=e*Math.cos(r)+t*Math.sin(r);s=[n[0]+Math.cos(r)*i,n[1]+Math.sin(r)*i,n[2]]}if(!o||!n)return s;if(o.angle!==void 0){let e=o.angle*Math.PI/180,t=o.length??Math.hypot(s[0]-n[0],s[1]-n[1]);return[n[0]+Math.cos(e)*t,n[1]+Math.sin(e)*t,n[2]]}let c=AH(n,s);if(o.length===void 0||c===0)return s;let l=o.length/c;return[n[0]+(s[0]-n[0])*l,n[1]+(s[1]-n[1])*l,n[2]+(s[2]-n[2])*l]}function cU(e,t=``){let n=Math.abs(e),r=n===0?0:Math.min(6,Math.max(0,2-Math.floor(Math.log10(n)))),i=e.toFixed(r);return t?`${i} ${t}`:i}var lU=1929202,uU=1010,dU=1011,fU=1012;function pU(e){let{viewer:t,metersPerUnit:n,colorOf:r}=e,i=`sketch:${e.id}`,a=new Lf(e.color??lU),o=!1,s=e=>new $(e[0]*n,e[1]*n,e[2]*n),c=e=>[e.x/n,e.y/n,e.z/n],l=new Af;l.name=e.name??`Sketch`,l.userData.id=i;let u=(e,t)=>(e.renderOrder=t,e.raycast=()=>{},e.frustumCulled=!1,e),d=(e,t)=>{let n=new fx({color:t?16777215:a,linewidth:2.5,transparent:e<1,opacity:e,vertexColors:t});return n.depthTest=!1,u(new jx(new dx,n),uU)},f=(e,t=1,n=dU)=>u(new $m(new Rp,new Jm({color:a,size:e,sizeAttenuation:!1,depthTest:!1,transparent:t<1,opacity:t})),n),p=d(1,r!==void 0),m=f(7),h=d(.65,!1),g=f(7),_=f(12,1,fU),v=f(7,.6,fU),y=e=>{l.add(e),l.parent||t.addUserGeometry(l,i)},b=e=>{e.removeFromParent(),l.children.length===0&&l.removeFromParent()},x=(e,t,n)=>{let r=[],i=[];t.forEach((e,t)=>{for(let a=1;a<e.length;a++){let o=s(e[a-1]),c=s(e[a]);r.push(o.x,o.y,o.z,c.x,c.y,c.z);let l=n?.[t];l&&i.push(l.r,l.g,l.b,l.r,l.g,l.b)}}),e.geometry.dispose(),e.geometry=new dx,r.length===0?b(e):(e.geometry.setPositions(r),n&&e.geometry.setColors(i),y(e))},S=(e,t)=>{e.geometry.dispose(),e.geometry=new Rp,t.length===0?b(e):(e.geometry.setAttribute(`position`,new Ep(t.flatMap(e=>s(e).toArray()),3)),y(e))},C=[],w=[],T=null,E=!1,D=()=>{C.forEach(e=>e.remove()),C=w.map(e=>{let n=t.labelLayer.addLabel(e.text,s(e.at)),{onEdit:r}=e;if(r){let t=n.object.element;t.style.pointerEvents=`auto`,t.style.cursor=`text`,t.addEventListener(`click`,n=>{n.stopPropagation(),E||O(t,e.editText??e.text,r)})}return n})},O=(e,n,r)=>{E=!0;let i=document.createElement(`input`);i.type=`text`,i.inputMode=`decimal`,i.value=n,Object.assign(i.style,{width:`${Math.max(5,n.length+2)}ch`,font:`inherit`,color:`#111`,background:`#fff`,border:`0`,borderRadius:`2px`,padding:`0 2px`,textAlign:`center`}),e.textContent=``,e.appendChild(i),i.focus(),i.select();let a=e=>{E&&(E=!1,e&&r(i.value),D(),t.invalidate())};i.addEventListener(`keydown`,e=>{e.stopPropagation(),e.key===`Enter`?a(!0):e.key===`Escape`&&a(!1)}),i.addEventListener(`blur`,()=>a(!1))};return{setCurves:(e,n=[])=>{o||(x(p,e.map(e=>YH(e)),r&&e.map(e=>new Lf(r(e)??a))),S(m,n),t.invalidate())},setPreview:e=>{o||(x(h,e?.polylines??[]),S(g,e?.points??[]),t.invalidate())},setCursor:e=>{o||(S(_,e?.snapped?[e.point]:[]),S(v,e&&!e.snapped?[e.point]:[]),t.invalidate())},setLabels:e=>{o||(w=e,E||D())},setPreviewLabel:e=>{o||(e?T?(T.setText(e.text),T.setPosition(s(e.at))):T=t.labelLayer.addLabel(e.text,s(e.at)):(T?.remove(),T=null))},toScene:s,fromScene:c,dispose:()=>{if(!o){o=!0,C.forEach(e=>e.remove()),T?.remove();for(let e of[p,m,h,g,_,v])e.removeFromParent(),e.geometry.dispose(),e.material.dispose();t.removeUserGeometry(l)}}}}var mU=12;function hU(e){let{viewer:t,metersPerUnit:n}=e,r=e.snapPixels??mU,i=t.renderer.domElement,a=new Yg,o=new Kp(new $(0,0,1),0),s=e=>new $(e[0]*n,e[1]*n,e[2]*n),c=e=>[e.x/n,e.y/n,e.z/n],l=(e,t,n)=>{let r=e.clone().project(t);return{x:(r.x+1)/2*n.width,y:(1-r.y)/2*n.height,visible:r.z>-1&&r.z<1}},u=(e,t)=>({x:e.clientX-t.left,y:e.clientY-t.top}),d=(e,n)=>{let a=t.cameraController.getActiveCamera(),o=i.getBoundingClientRect(),c=u(e,o),d=-1,f=r;return n.forEach((e,t)=>{let n=l(s(e),a,o),r=Math.hypot(n.x-c.x,n.y-c.y);n.visible&&r<f&&(f=r,d=t)}),d},f=(e,t,n)=>{let r=n.x-t.x,i=n.y-t.y,a=r*r+i*i,o=a===0?0:Math.min(1,Math.max(0,((e.x-t.x)*r+(e.y-t.y)*i)/a));return Math.hypot(e.x-(t.x+o*r),e.y-(t.y+o*i))},p=(e,n)=>{let a=t.cameraController.getActiveCamera(),o=i.getBoundingClientRect(),c=u(e,o),d=-1,p=r;return n.forEach((e,t)=>{let n=YH(e).map(e=>l(s(e),a,o));for(let e=1;e<n.length;e++){if(!n[e-1].visible||!n[e].visible)continue;let r=f(c,n[e-1],n[e]);r<p&&(p=r,d=t)}}),d},m=(e,n,o)=>{let s=i.getBoundingClientRect(),d=u(e,s),f=SO(n,t.controls.target)*2;a.params.Line.threshold=f,a.params.Points.threshold=f,a.params.Line2={threshold:r/2};for(let e of dO(t.scene,a)){let t=e.pointOnLine??e.point,i=e.object.isMesh&&e.face!=null;if(!i){let e=l(t,n,s);if(Math.hypot(e.x-d.x,e.y-d.y)>r)continue}let a=DO(e,n,{width:s.width,height:s.height},r);return!i||!a.equals(t)?{point:c(a),snapped:!0}:o?null:{point:c(t),snapped:!1}}return null};return{pick:(e,n={})=>{let{snapTo:r=[],last:s=null,planar:l=!0,gridStep:u=0,typed:f=null}=n,p=t.cameraController.getActiveCamera(),h=VO(e,i);a.setFromCamera(new Q(h.x,h.y),p);let g=d(e,r),_=g>=0?{point:r[g],snapped:!0}:m(e,p,l);if(!_){let e=a.ray.intersectPlane(o,new $);if(!e)return null;_={point:c(e),snapped:!1}}return l&&(_={..._,point:[_.point[0],_.point[1],0]}),{snapped:_.snapped,point:sU(_.point,{last:s,snapped:_.snapped,ortho:n.ortho??e.shiftKey,gridStep:u,typed:f})}},nearestPoint:d,nearestCurve:p}}var gU={point:{id:`point`,pointCount:1,build:e=>e.length>=1?[{kind:`point`,at:e[0]}]:null},line:{id:`line`,pointCount:2,build:e=>e.length>=2?[{kind:`line`,from:e[0],to:e[1]}]:null},polyline:{id:`polyline`,closable:!0,build:(e,t)=>e.length>=2?[{kind:`polyline`,points:[...e],closed:t&&e.length>2}]:null},nurbs:{id:`nurbs`,closable:!0,build:(e,t)=>e.length>=2?[NH(t?[...e,e[0]]:e)]:null}},_U=`move`,vU=150;function yU(e){let{viewer:t,unitSuffix:n=``}=e,r=`sketch:${e.id}`,i=Math.max(1,e.maxItems??1/0),a=t.renderer.domElement,o={gridStep:0,planar:!0,showDimensions:!0,...e.settings},s=pU(e),c=hU(e),l=[],u=[],d=[],f=null,p=null,m=[],h=``,g=null,_=null,v=!1,y=0,b=()=>({mode:p,pendingPoints:m.length,typed:h,canUndo:u.length>0,canRedo:d.length>0}),x=()=>e.onStateChange?.(b()),S=t=>{u=[...u,l].slice(-100),d=[],l=t,e.onChange?.(l)},C=(t,n)=>{let r=t[t.length-1];if(!r)return[t,n];let i=[t.slice(0,-1),[...n,l]];return l=r,_=null,e.onChange?.(l),i},w=()=>{[u,d]=C(u,d),N()},T=()=>{[d,u]=C(d,u),N()},E=e=>e.id===void 0?{...e,id:globalThis.crypto?.randomUUID?.()??`${r}:${++y}`}:e,D=(e,t)=>[(e[0]+t[0])/2,(e[1]+t[1])/2,(e[2]+t[2])/2],O=()=>m[m.length-1]??null,k=()=>{let e=_;if(!e||!g)return l;let t=zH(e.original,e.vertex,g.point);return l.map((n,r)=>r===e.item?t:n)},A=(e,t,n)=>{let r=Number(n.replace(`,`,`.`)),i=l[e];if(!i||!(r>0)||!Number.isFinite(r))return;let a=rU(i,t,r);a!==i&&UH(a)&&(S(l.map((t,n)=>n===e?a:t)),N())},j=()=>{let e=k();s.setCurves(e.filter(TH),e.flatMap(e=>e.kind===`nurbs`&&p!==_U?[]:RH(e)));let t=o.showDimensions?e.flatMap((e,t)=>tU(e).map((e,n)=>({...e,item:t,segment:n}))):[],r=p===null||p===_U;s.setLabels(t.length>vU?[]:t.filter(e=>e.length>0).map(e=>({text:cU(e.length,n),at:D(e.from,e.to),...r&&{editText:cU(e.length),onEdit:t=>A(e.item,e.segment,t)}})))},M=()=>{let e=f!==null,t=e&&g?[...m,g.point]:m,r=e?f.build(t,!1):null;s.setPreview(e?{polylines:r?r.filter(TH).map(e=>YH(e)):t.length>=2?[t]:[],points:m}:null),s.setCursor(p?g:null);let i=O();if(e&&i&&g&&AH(i,g.point)>0){let e=cU(AH(i,g.point),n);s.setPreviewLabel({text:h?`${h}\n${e}`:e,at:D(i,g.point)})}else s.setPreviewLabel(null)},N=()=>{v||(j(),M(),x())},P=e=>{let t=_,n=[...m,...l.flatMap((e,n)=>RH(e).filter((e,r)=>!(t&&t.item===n&&t.vertex===r)))],r=p===_U;return c.pick(e,{snapTo:n,last:r?t?RH(t.original)[t.vertex]:null:O(),planar:o.planar,gridStep:o.gridStep,typed:r?null:aU(h)})},F=e=>{let t=l.flatMap((e,t)=>RH(e).map((e,n)=>({point:e,item:t,vertex:n}))),n=t[c.nearestPoint(e,t.map(e=>e.point))];return n?{item:n.item,vertex:n.vertex,original:l[n.item]}:null},ee=(e=!1)=>{let t=f?.build(m,e)?.filter(UH)??[];return m=[],h=``,t.length!==0&&(S([...l,...t.map(E)].slice(-i)),l.length>=i&&ie(),!0)},te=(e,t)=>AH(e,t)===0,ne=e=>{if(!f)return;let t=O();t&&te(e,t)?ee():f.closable&&m.length>=3&&te(e,m[0])?ee(!0):(m=[...m,e],h=``,m.length===f.pointCount&&ee()),N()},I=e=>{if(!_)return;let{item:t,vertex:n,original:r}=_;_=null;let i=zH(r,n,e);UH(i)&&S(l.map((e,n)=>n===t?i:e))},L=()=>{if(!_)return;let{item:e,vertex:t,original:n}=_;_=null;let r=BH(n,t);S(r&&UH(r)?l.map((t,n)=>n===e?r:t):l.filter((t,n)=>n!==e))},R=e=>{if(!p||e.altKey)return;let t=e.target;if(t?.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t?.tagName??``))return;let n=p===_U,r=e.key.toLowerCase(),i=!0;e.ctrlKey||e.metaKey?r===`y`||r===`z`&&e.shiftKey?T():r===`z`&&m.length?m=m.slice(0,-1):r===`z`?w():i=!1:e.key===`Escape`?n&&_?_=null:h?h=``:m.length?m=[]:ie():e.key===`Enter`?n?ie():h&&g&&O()?ne(g.point):ee()||ie():e.key===`Backspace`||e.key===`Delete`?n?L():h?h=h.slice(0,-1):m=m.slice(0,-1):!n&&iU.test(e.key)?h+=e.key===`,`?`.`:e.key:i=!1,i&&(e.preventDefault(),e.stopPropagation(),p&&(z&&(g=P(z)),N()))},z=null,re=0,B=(e,n)=>{v||(p&&ie(),p=e,f=n,t.tools.setActive(r),window.addEventListener(`keydown`,R,!0),a.style.cursor=`crosshair`,N())},ie=()=>{p&&(p=null,f=null,m=[],h=``,g=null,z=null,_=null,re&&cancelAnimationFrame(re),re=0,window.removeEventListener(`keydown`,R,!0),a.style.cursor=``,t.tools.getActive()===r&&t.tools.setActive(null),N())},ae=t.tools.register({id:r,tool:{setEnabled:e=>{e||ie()},isEnabled:()=>p!==null,handleClick:e=>{if(!p)return!1;if(p===_U&&!_)_=F(e),_&&(g={point:RH(_.original)[_.vertex],snapped:!0});else{let t=P(e);t&&p===_U?I(t.point):t&&ne(t.point)}return N(),!0},handleMove:e=>{p&&(z=e,!re&&(re=requestAnimationFrame(()=>{re=0,p&&z&&(g=P(z),_&&j(),M())})))}},priority:10});return{getItems:()=>l,setItems:e=>{l=[...e],u=[],d=[],_=null,N()},draw:e=>{let t=typeof e==`string`?gU[e]:e;B(t.id,t)},move:()=>B(_U,null),finish:()=>{p&&(ee(),ie())},cancel:()=>ie(),undo:w,redo:T,getState:b,configure:e=>{Object.assign(o,e),N()},dispose:()=>{v||(ie(),v=!0,ae(),s.dispose())}}}var bU=2e3,xU=class extends Error{reason;constructor(e){super(`Import failed: ${e}`),this.reason=e}},SU=D(`<span class="text-sm font-mono text-foreground"> </span>`),CU=D(`<span class="text-sm text-muted-foreground"> </span>`),wU=D(`<output class="text-sm min-w-0 text-muted-foreground"> </output> <!> <div class="gap-x-3 gap-y-2 min-w-0 flex flex-wrap items-center"><div class="gap-2 flex items-center"><!> <!> <!></div> <div class="gap-2 flex items-center"><!> <!></div> <!></div>`,1),TU=D(`<!> `,1),EU=D(`<!> <!>`,1),DU=D(`<div class="gap-2 min-w-0 flex flex-wrap items-center"><!> <!></div> <div class="gap-2 min-w-0 flex flex-wrap items-center"><output> </output> <!> <!></div>`,1),OU=D(`<div class="gap-2 min-w-0 flex flex-col"><!></div>`);function kU(e,n){V(n,!0);let r=J(n,`sketch`,7),i=J(n,`disabled`,3,!1),o=at(),s=T(()=>o.messages),l=T(()=>r().view(n.paramId)),u=T(()=>C(l).state.mode),d=T(()=>r().unitSuffix),f=T(()=>r().kinds(n.paramId)),h={line:[`line`],curve:[`line`,`polyline`,`nurbs`],point:[`point`]},g={point:`curveDrawPoint`,line:`curveDrawLine`,polyline:`curveDrawPolyline`,nurbs:`curveDrawCurve`},_={point:`curveHintPoint`,line:`curveHintLine`,polyline:`curveHintPolyline`,nurbs:`curveHintCurve`,move:`curveHintMove`},v=T(()=>[...new Set(C(f).flatMap(e=>h[e]))]),y=T(()=>{let e=C(l).items.filter(TH),t=C(l).items.filter(wH).length,n=[];if(e.length>0){let t=e.reduce((e,t)=>e+nU(t),0),r=C(f).includes(`curve`)?it(e.length,C(s).curveCountOne,C(s).curveCountOther):it(e.length,C(s).curveCountLineOne,C(s).curveCountLineOther);n.push(`${r} · ${cU(t,C(d))}`)}return t>0&&n.push(it(t,C(s).curveCountPointOne,C(s).curveCountPointOther)),n.join(`, `)}),x=Z(B(Y(()=>r().gridStep||null)));le(()=>{r().gridStep=C(x)??0});let w=Z(!1);async function E(){let e=await vF({accept:r().importAccept});if(e){P(w,!0);try{let{items:t,skipped:i,overLimit:a}=await r().importFile(n.paramId,e);t.length===0?Cn.error(C(s).curveImportEmpty):a>0?Cn.warning(nt(t.length===1?C(s).curveImportOverLimitOne:C(s).curveImportOverLimitOther,{max:t.length,count:t.length+a})):i>0&&Cn.warning(it(i,C(s).curveImportSkippedOne,C(s).curveImportSkippedOther))}catch(e){let t=e instanceof xU?e.reason:`unreadable`;Cn.error(t===`tooMany`?nt(C(s).curveImportTooMany,{max:bU}):t===`unsupported`?C(s).curveImportUnsupported:C(s).curveImportFailed)}finally{P(w,!1)}}}function D(e,t){t.currentTarget.blur(),r().draw(n.paramId,e)}var k=OU(),A=I(k),j=e=>{var i=wU(),a=z(i),o=K(a,!0),f=U(a,2),h=e=>{var t=SU(),n=K(t);G(()=>m(n,`${C(l).state.typed??``} ${C(d)??``}`)),O(e,t)};t(f,e=>{C(l).state.typed&&e(h)});var g=U(f,2),v=I(g),y=I(v);mn(y,{get for(){return`${n.inputId??``}-grid`},children:(e,t)=>{S();var n=p();G(()=>m(n,C(s).curveGrid)),O(e,n)},$$slots:{default:!0}});var b=U(y,2);xn(b,{get id(){return`${n.inputId??``}-grid`},type:`number`,min:`0`,step:`any`,class:`w-24`,get placeholder(){return C(s).curveGridOff},get value(){return C(x)},set value(e){P(x,e,!0)}});var w=U(b,2),T=e=>{var t=CU(),n=K(t,!0);G(()=>m(n,C(d))),O(e,t)};t(w,e=>{C(d)&&e(T)}),c(v);var E=U(v,2),D=I(E);Co(D,{get id(){return`${n.inputId??``}-dimensions`},get checked(){return r().showDimensions},onCheckedChange:e=>{r().showDimensions=e===!0}});var k=U(D,2);mn(k,{get for(){return`${n.inputId??``}-dimensions`},children:(e,t)=>{S();var n=p();G(()=>m(n,C(s).curveDimensions)),O(e,n)},$$slots:{default:!0}}),c(E);var A=U(E,2);tt(A,{size:`sm`,onclick:()=>r().finish(n.paramId),children:(e,t)=>{S();var n=p();G(()=>m(n,C(s).curveDone)),O(e,n)},$$slots:{default:!0}}),c(g),G(()=>{H(a,`id`,n.inputId),m(o,C(s)[_[C(u)]??`curveHintDraw`])}),O(e,i)},M=e=>{var o=DU(),u=z(o),d=I(u);a(d,16,()=>C(v),e=>e,(e,t)=>{{let n=T(()=>i()||!r().canDraw);tt(e,{variant:`outline`,size:`sm`,onclick:e=>D(t,e),get disabled(){return C(n)},children:(e,n)=>{S();var r=p();G(()=>m(r,C(s)[g[t]])),O(e,r)},$$slots:{default:!0}})}});var f=U(d,2);{let e=T(()=>i()||!r().canImport||C(w));tt(f,{variant:`outline`,size:`sm`,onclick:E,get disabled(){return C(e)},children:(e,t)=>{var n=TU(),r=z(n);Ct(r,{});var i=U(r);G(()=>m(i,` ${C(s).curveImport??``}`)),O(e,n)},$$slots:{default:!0}})}c(u);var h=U(u,2),_=I(h),b=K(_,!0),x=U(_,2),k=e=>{var t=EU(),a=z(t);{let e=T(()=>i()||!r().canDraw);tt(a,{variant:`ghost`,size:`sm`,onclick:()=>r().move(n.paramId),get disabled(){return C(e)},children:(e,t)=>{S();var n=p();G(()=>m(n,C(s).curveEdit)),O(e,n)},$$slots:{default:!0}})}var o=U(a,2);tt(o,{variant:`ghost`,size:`sm`,onclick:()=>r().reset(n.paramId),get disabled(){return i()},children:(e,t)=>{S();var n=p();G(()=>m(n,C(s).curveReset)),O(e,n)},$$slots:{default:!0}}),O(e,t)};t(x,e=>{C(y)&&e(k)});var A=U(x,2),j=e=>{tt(e,{variant:`ghost`,size:`sm`,onclick:()=>r().undo(n.paramId),get disabled(){return i()},children:(e,t)=>{S();var n=p();G(()=>m(n,C(s).curveUndo)),O(e,n)},$$slots:{default:!0}})};t(A,e=>{C(l).state.canUndo&&e(j)}),c(h),G(()=>{H(_,`id`,n.inputId),fe(_,1,`text-sm min-w-0 truncate ${C(y)?`text-foreground`:`text-muted-foreground`}`),m(b,r().canImport?C(y)||C(s).curveEmpty:C(s).curveNeedsSolve)}),O(e,o)};t(A,e=>{C(u)?e(j):e(M,-1)}),c(k),O(e,k),b()}var AU=D(`<!> <!>`,1);function jU(e,n){V(n,!0);let r=J(n,`value`,15),i=J(n,`disabled`,3,!1),a=at(),o=T(()=>a.messages),s=Z(null),c=Z(B(r()||``)),l=OV(e=>n.onChange(e),400);function d(e){if(n.config?.maxLength&&e.length>n.config.maxLength)return nt(C(o).maxLength,{max:n.config.maxLength});if(n.config?.pattern)try{if(!new RegExp(n.config.pattern).test(e))return n.config.customErrorMessage||C(o).invalidFormat}catch{return C(o).invalidPattern}return null}function f(){let e=d(C(c));P(s,e,!0),e||(r(C(c)),l(C(c)))}var h=AU(),g=z(h);{let e=T(()=>n.config?.placeholder),t=T(()=>n.config?.maxLength),a=T(()=>C(s)?!0:void 0),o=T(()=>C(s)?!0:void 0);xn(g,{get id(){return n.inputId},type:`text`,get placeholder(){return C(e)},get maxlength(){return C(t)},get"data-invalid"(){return C(a)},get"aria-invalid"(){return C(o)},get disabled(){return i()},oninput:()=>{P(s,null),f()},onblur:e=>{let t=e.currentTarget.value,i=d(t);P(s,i,!0),i||(P(c,t,!0),r(t),n.onChange(t))},get value(){return C(c)},set value(e){P(c,e,!0)}})}var _=U(g,2),v=e=>{var t=u(),n=z(t);E(n,()=>fV,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(s))),O(e,n)},$$slots:{default:!0}})}),O(e,t)};t(_,e=>{C(s)&&e(v)}),O(e,h),b()}var MU=D(`<span class="text-lg font-medium" aria-hidden="true"> </span>`),NU=D(`<button type="button" role="radio"><span><!></span> <span> </span></button>`),PU=D(`<div role="radiogroup" class="gap-2 tile-grid grid svelte-15u2gi8"></div>`);function FU(e,n){V(n,!0);let r=J(n,`disabled`,3,!1),i=T(()=>Object.entries(n.config.options??{}).map(([e,t])=>({name:e,value:t??e}))),o=T(()=>Math.max(0,C(i).findIndex(e=>e.value===n.value))),s=B([]);function l(e,t){let r={ArrowRight:1,ArrowDown:1,ArrowLeft:-1,ArrowUp:-1}[e.key];if(!r)return;e.preventDefault();let a=(t+r+C(i).length)%C(i).length;n.onChange(C(i)[a].value),s[a]?.focus()}var u=PU();a(u,23,()=>C(i),e=>e.name,(e,i,a)=>{let u=T(()=>xV(n.config.optionMedia?.[C(i).name],n.assets)),d=T(()=>C(i).value===n.value);var p=NU(),h=I(p),g=I(h),_=e=>{wV(e,{get glyph(){return C(u)},class:`size-full`})},v=e=>{wV(e,{get glyph(){return C(u)},class:`size-7`})},y=e=>{var t=MU(),n=K(t,!0);G(e=>m(n,e),[()=>C(i).name.charAt(0)]),O(e,t)};t(g,e=>{C(u)?.kind===`image`?e(_):C(u)?e(v,1):e(y,-1)}),c(h);var b=U(h,2);let x;var S=K(b,!0);c(p),F(p,(e,t)=>s[t]=e,e=>s?.[e],()=>[C(a)]),G(()=>{H(p,`title`,C(i).name),H(p,`aria-checked`,C(d)),H(p,`tabindex`,C(a)===C(o)?0:-1),p.disabled=r(),fe(p,1,`gap-1.5 p-1.5 min-w-0 flex flex-col rounded-lg border text-left transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 ${C(d)?`border-primary bg-primary/10 ring-1 ring-primary`:`border-input hover:bg-hover`}`),fe(h,1,`flex aspect-square w-full items-center justify-center overflow-hidden rounded-md bg-muted ${C(d)?`text-foreground`:`text-muted-foreground`}`),x=fe(b,1,`px-0.5 text-xs leading-tight line-clamp-2`,null,x,{"font-medium":C(d)}),m(S,C(i).name)}),f(`click`,p,()=>n.onChange(C(i).value)),f(`keydown`,p,e=>l(e,C(a))),O(e,p)}),c(u),G(()=>H(u,`aria-labelledby`,n.labelId)),O(e,u),b()}ce([`click`,`keydown`]);var IU=Symbol(`client-slot-context`);function LU(e){n(IU,e)}function RU(){return s(IU)}var zU={host:`selva`},BU=Symbol(`host-context`);function VU(){return s(BU)??zU}var HU=Symbol(`sketch-context`);function UU(e){n(HU,e)}function WU(){return s(HU)}var GU={value:[`rhino`,`selva`],sketch:[`rhino`,`selva`],geometry:[`rhino`],trigger:[`rhino`],unknown:[]},KU=new Set([`geometry`,`point`,`line`,`plane`]),qU={input:new Set(Object.keys({number:!0,text:!0,dropdown:!0,dynamicValueList:!0,checkbox:!0,file:!0,color:!0})),output:new Set(Object.keys({text:!0,number:!0,file:!0,chart:!0,image:!0,dynamicValueList:!0}))};function JU(e){return e!==void 0&&KU.has(e)}var YU={line:[`line`],point:[`point`]},XU=[`curve`,`point`];function ZU(e){if(e?.paramType!==`geometry`)return YU[e?.paramType??``]??[];let t=e.geometryTypes;return t?.length?XU.filter(e=>t.includes(e)):XU}function QU(e){return e.type===`input`&&e.widgetType===`checkbox`&&e.config?.displayAs===`button`}function $U(e,t){if(e.type===`linebreak`)return`value`;if(e.type!==`input`&&e.type!==`output`)return`unknown`;if(e.type===`input`){let n=t.find(t=>t.id===e.paramId);if(ZU(n).length>0)return`sketch`;if(JU(n?.paramType))return`geometry`}return qU[e.type].has(e.widgetType)?QU(e)?`trigger`:`value`:`unknown`}function eW(e,t){return GU[t].includes(e)}function tW(e,t){return JU(t?.paramType)||QU(e)}function nW(e){let t=new Set;for(let n of e.inputs)JU(n.paramType)&&t.add(n.id);for(let n of zF(e))for(let e of n.items??[])QU(e)&&t.add(e.paramId);return t}var rW=D(`<span> </span>`),iW=D(`<span class="text-xs pl-2 ml-auto hidden shrink-0 whitespace-nowrap text-muted-foreground tabular-nums group-focus-within/field:inline"> </span>`),aW=D(`<div class="gap-1.5 min-h-5 min-w-0 flex items-center"><!> <!> <!></div>`),oW=D(`<div role="group" class="group/field gap-2 min-w-0 flex flex-col"><!> <!></div>`),sW=D(`<span class="truncate"> </span>`),cW=D(`<div role="group" class="group/field gap-1.5 min-w-0 flex items-center" data-control-line=""><!> <!></div>`),lW=D(`<!> <!>`,1),uW=D(`<p class="text-sm text-muted-foreground"> </p>`);function dW(e,n){V(n,!0);let r=(e,r=h)=>{let i=T(()=>yV(r().displayAs,Object.keys(r().options??{}).length)),a=T(()=>typeof s()==`string`?s():``);var o=u(),c=z(o),d=e=>{{let t=T(()=>Array.isArray(s())?s():typeof s()==`string`&&s()?[s()]:[]);DV(e,{get inputId(){return C(A)},get value(){return C(t)},get config(){return r()},get assets(){return n.assets},onChange:B,get disabled(){return l()}})}},f=e=>{CH(e,{get labelId(){return`${C(A)??``}-label`},get value(){return C(a)},get config(){return r()},get assets(){return n.assets},onChange:B,get disabled(){return l()}})},p=e=>{FU(e,{get labelId(){return`${C(A)??``}-label`},get value(){return C(a)},get config(){return r()},get assets(){return n.assets},onChange:B,get disabled(){return l()}})},m=e=>{YV(e,{get inputId(){return C(A)},get value(){return C(a)},get config(){return r()},get assets(){return n.assets},onChange:B,get disabled(){return l()}})};t(c,e=>{C(i)===`checklist`?e(d):C(i)===`segmented`?e(f,1):C(i)===`tiles`?e(p,2):e(m,-1)}),O(e,o)},i=(e,t=h,n)=>{let r=pe(()=>d(n?.(),`quiet`));var i=u(),a=z(i);{let e=T(()=>t()?`${t()}-label`:void 0);E(a,()=>sV,(n,i)=>{i(n,{get for(){return t()},get id(){return C(e)},class:`min-w-0 block break-words`,children:(e,t)=>{var n=rW(),i=K(n,!0);G(()=>{fe(n,1,me(C(r)===`quiet`?`font-normal text-muted-foreground`:`font-normal text-foreground`)),m(i,C(j))}),O(e,n)},$$slots:{default:!0}})})}O(e,i)},a=e=>{var r=u(),i=z(r),a=e=>{hV(e,{get label(){return C(j)},get description(){return n.item.description},get nameTemplate(){return f.messages.helpFor}})};t(i,e=>{n.item.description&&e(a)}),O(e,r)},o=(e,n=h)=>{var r=aW(),o=I(r);i(o,n);var s=U(o,2);a(s);var l=U(s,2),u=e=>{var t=iW(),n=K(t,!0);G(()=>m(n,C(P))),O(e,t)};t(l,e=>{C(F)&&e(u)}),c(r),O(e,r)},s=J(n,`value`,15,void 0),l=J(n,`disabled`,3,!1),f=at(),p=VU(),{pickGeometry:g,clearGeometry:_,onGeometrySummary:v}=p,y=T(()=>JU(n.paramType)),x=WU(),S=T(()=>p.host===`selva`&&C(y)),w=T(()=>QU(n.item)),D=T(()=>C(y)?p.describeGeometry?.(n.item.paramId):void 0);function k(e){return n.paramType===`point`||n.paramType===`line`||n.paramType===`plane`?[n.paramType]:e?.kinds}let A=T(()=>`input-${n.item.paramId}`),j=T(()=>n.displayName||n.item.displayName||n.item.paramId),M=T(()=>{let e=n.item.source;return e?.kind===`client`&&e.client?.presentation===`slot`}),N=RU(),P=T(()=>{if(!St(n.item))return null;let e=n.item.config;if(e?.hideRange||e?.renderAsSlider)return null;let t=typeof e?.minimum==`number`,r=typeof e?.maximum==`number`;return!t&&!r?null:t&&r?`${e.minimum} – ${e.maximum}`:t?`≥ ${e.minimum}`:`≤ ${e.maximum}`}),F=T(()=>St(n.item)&&C(P)!==null),ee=T(()=>vt(n.item)?n.item.config:void 0),te=T(()=>n.dynamicOptions&&Object.keys(n.dynamicOptions).length>0?n.dynamicOptions:Object.fromEntries(Object.entries(C(ee)?.defaultOptions??{}).filter(e=>e[1]!==void 0))),ne=T(()=>Object.keys(C(te)).length>0),L=T(()=>({options:C(te),displayAs:C(ee)?.displayAs??`dropdown`,optionMedia:C(ee)?.optionMedia})),R=T(()=>vt(n.item)&&!C(ne)&&(C(ee)?.emptyBehavior??`hide`)===`hide`),re=0;le(()=>{if(!vt(n.item)||!C(ne))return;let e=new Set(Object.values(C(te))),t=Object.values(C(te))[0];if(Array.isArray(s())?s().length>0&&s().every(t=>typeof t==`string`&&e.has(t)):typeof s()==`string`&&s()!==``&&e.has(s()))re=0;else if(re>=3)console.warn(`[InputControl] dynamic value list "${n.item.paramId}": options keep invalidating the auto-picked selection (${re} consecutive system picks) — the definition's options likely depend on the selection. Stopping auto-reconciliation to avoid a solve loop.`);else if(Array.isArray(s())){let r=s().filter(t=>typeof t==`string`&&e.has(t));(r.length!==s().length||s().length===0)&&(re++,n.onChange(n.item.paramId,r.length>0?r:[t],!0))}else typeof s()==`string`&&s()!==``&&e.has(s())||(re++,n.onChange(n.item.paramId,t,!0))});function B(e){re=0,s(e),n.onChange(n.item.paramId,e)}var ie=u(),ae=z(ie),H=e=>{var r=u(),i=z(r),a=e=>{var t=oW(),r=I(t);o(r);var i=U(r,2);N(i,()=>({inputId:n.item.paramId,displayName:C(j),value:s(),onValueChange:B})),c(t),O(e,t)};t(i,e=>{N&&e(a)}),O(e,r)},W=e=>{var r=u(),i=z(r),a=e=>{var t=oW(),r=I(t);o(r,()=>C(A)),kU(U(r,2),{get inputId(){return C(A)},get paramId(){return n.item.paramId},get sketch(){return x},get disabled(){return l()}}),c(t),O(e,t)},s=T(()=>x?.supports(n.item.paramId));t(i,e=>{C(s)&&e(a)}),O(e,r)},oe=e=>{var t=oW(),r=I(t);o(r,()=>C(A));var i=U(r,2);{let e=T(()=>k(C(D))),t=T(()=>C(D)?.atMost),r=T(()=>typeof s()==`string`?s():void 0),a=T(()=>g&&(()=>g(n.item.paramId))),o=T(()=>_&&(()=>_(n.item.paramId))),c=T(()=>v&&(e=>v(n.item.paramId,e)));gH(i,{get inputId(){return C(A)},get kinds(){return C(e)},get atMost(){return C(t)},get summary(){return C(r)},get onPick(){return C(a)},get onClear(){return C(o)},get watchSummary(){return C(c)},onError:e=>Cn.error(e),get disabled(){return l()}})}c(t),O(e,t)},se=e=>{var t=cW(),r=I(t);{let e=T(()=>l()||!p.trigger||p.isSolving?.());tt(r,{get id(){return C(A)},variant:`outline`,class:`min-w-0 flex-1`,onclick:()=>p.trigger?.(n.item.paramId),get disabled(){return C(e)},children:(e,t)=>{var n=sW(),r=K(n,!0);G(()=>m(r,C(j))),O(e,n)},$$slots:{default:!0}})}var i=U(r,2);a(i),c(t),O(e,t)},ce=e=>{var d=oW(),p=I(d),h=e=>{o(e,()=>C(A))},g=T(()=>!Et(n.item));t(p,e=>{C(g)&&e(h)});var _=U(p,2),v=e=>{let t=T(()=>n.item.config);{let n=T(()=>typeof s()==`number`?s():void 0);xH(e,{get inputId(){return C(A)},get labelId(){return`${C(A)??``}-label`},get value(){return C(n)},get config(){return C(t)},onChange:B,get disabled(){return l()}})}},y=T(()=>St(n.item)),b=e=>{{let t=T(()=>typeof s()==`boolean`?s():void 0);_V(e,{get inputId(){return C(A)},get value(){return C(t)},onChange:B,get disabled(){return l()},children:(e,t)=>{var n=lW(),r=z(n);i(r,()=>C(A),()=>`strong`);var o=U(r,2);a(o),O(e,n)},$$slots:{default:!0}})}},x=T(()=>Et(n.item)),S=e=>{let t=T(()=>n.item.config);{let n=T(()=>typeof s()==`string`?s():``);jU(e,{get inputId(){return C(A)},get value(){return C(n)},get config(){return C(t)},onChange:B,get disabled(){return l()}})}},w=T(()=>Tt(n.item)),E=e=>{r(e,()=>n.item.config)},D=T(()=>wt(n.item)),k=e=>{var n=u(),i=z(n),a=e=>{r(e,()=>C(L))},o=e=>{var t=uW(),n=K(t,!0);G(()=>m(n,f.messages.noOptionsYet)),O(e,t)};t(i,e=>{C(ne)?e(a):e(o,-1)}),O(e,n)},j=T(()=>vt(n.item)),M=e=>{let t=T(()=>n.item.config);{let n=T(()=>typeof s()==`string`?s():``),r=T(()=>C(t)?.acceptedFormats??[]),i=T(()=>C(t)?.defaultInputMode),a=T(()=>C(t)?.allowedInputModes);dH(e,{get value(){return C(n)},get acceptedFormats(){return C(r)},onChange:e=>B(e),get defaultInputMode(){return C(i)},get allowedInputModes(){return C(a)}})}},N=T(()=>mt(n.item)),P=e=>{{let t=T(()=>typeof s()==`string`?s():`#000000`);GV(e,{get inputId(){return C(A)},get value(){return C(t)},onChange:e=>B(e),get disabled(){return l()}})}},F=T(()=>xt(n.item));t(_,e=>{C(y)?e(v):C(x)?e(b,1):C(w)?e(S,2):C(D)?e(E,3):C(j)?e(k,4):C(N)?e(M,5):C(F)&&e(P,6)}),c(d),O(e,d)};t(ae,e=>{C(M)?e(H):C(S)?e(W,1):C(y)?e(oe,2):C(w)?e(se,3):C(R)||e(ce,4)}),O(e,ie),b()}var fW=new Map;function pW(e,t){if(fW.has(e))return fW.get(e);if(document.querySelector(`script[src="${e}"]`)){let t=Promise.resolve();return fW.set(e,t),t}let n=new Promise((n,r)=>{let i=document.createElement(`script`);i.src=e,t?.crossOrigin&&(i.crossOrigin=t.crossOrigin),t?.integrity&&(i.integrity=t.integrity),t?.async!==void 0&&(i.async=t.async),t?.defer!==void 0&&(i.defer=t.defer),i.onload=()=>n(),i.onerror=()=>{fW.delete(e),r(Error(`Failed to load script: ${e}`))},document.head.appendChild(i)});return fW.set(e,n),n}var mW={scattermapbox:`scattermap`,choroplethmapbox:`choroplethmap`,densitymapbox:`densitymap`},hW=/^mapbox(\d*)$/,gW=/^(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,_W=/^hsva?[\s(]+([-+\d.]+)%?[\s,]+([\d.]+)(%?)[\s,]+([\d.]+)(%?)(?:[\s,/]+([\d.]+)(%?))?[\s)]*$/i,vW=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function yW(e){let t=structuredClone(e),n=t.layout??{};CW(n);let r=!1;for(let e of t.data??[]){if(!vW(e))continue;CW(e);let t=mW[e.type];t?(e.type=t,typeof e.subplot==`string`&&(e.subplot=e.subplot.replace(hW,`map$1`)),r=!0):e.type===`splom`&&bW(e)}r&&xW(n);for(let e of t.frames??[])vW(e)&&CW(e);return{...t,layout:n}}function bW(e){if(Array.isArray(e.dimensions))for(let t of e.dimensions){if(!vW(t))continue;let e=vW(t.axis)?t.axis:t.axis={};`matches`in e||(e.matches=!1)}}function xW(e){for(let t of Object.keys(e)){let n=hW.exec(t);if(!n)continue;let r=e[t];delete e[t];let i=`map${n[1]}`;i in e||!vW(r)||(delete r.accesstoken,typeof r.style==`string`&&/^(stamen|mapbox:\/\/)/.test(r.style)&&(r.style=`open-street-map`),e[i]=r)}}var SW=e=>e.toLowerCase().endsWith(`color`)||e===`colors`||e===`colorway`||e===`colorscale`;function CW(e){for(let[t,n]of Object.entries(e))if(SW(t))e[t]=wW(n,!1);else if(vW(n))CW(n);else if(Array.isArray(n))for(let e of n)vW(e)&&CW(e)}function wW(e,t){return Array.isArray(e)?e.map(e=>wW(e,!0)):typeof e!=`string`||t&&/^\s*\d+\s*$/.test(e)?e:TW(e)}function TW(e){let t=e.trim();if(gW.test(t))return`#${t}`;let n=_W.exec(t);if(!n)return e;let{r,g:i,b:a}=PV({h:Number(n[1]),s:EW(n[2],n[3]===`%`),v:EW(n[4],n[5]===`%`)}),o=`${Math.round(r)},${Math.round(i)},${Math.round(a)}`;return n[6]===void 0?`rgb(${o})`:`rgba(${o},${+EW(n[6],n[7]===`%`).toFixed(3)})`}function EW(e,t){let n=Number(e);return(t||n>1)&&(n/=100),Math.min(1,Math.max(0,n))}var DW=D(`<div class="px-4 py-3 text-sm text-destructive"> </div>`),OW=D(`<div class="px-4 py-8 text-sm text-center text-muted-foreground"> </div>`),kW=D(`<div class="p-1.5 backdrop-blur-sm flex items-center rounded-sm border border-border-strong bg-background/80 text-muted-foreground"><!></div>`),AW=D(`<button class="p-1.5 backdrop-blur-sm flex items-center rounded-sm border border-border-strong bg-background/80 text-foreground transition-colors hover:bg-background disabled:cursor-not-allowed disabled:opacity-50"><!></button>`),jW=D(`<div></div> <div><!> <!></div>`,1),MW=D(`<div><!></div>`);function NW(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),a=new Set([`scattermap`,`choroplethmap`,`densitymap`,`choropleth`,`scattergeo`]),o=T(()=>{if(!n.value)return null;try{return yW(JSON.parse(n.value))}catch{return null}}),s=Z(null),l=Z(null),u=Z(!1),d=Z(null),p=Z(!1),h=!1;async function g(){return window.Plotly||await pW(`https://cdn.plot.ly/plotly-4.1.2.min.js`,{crossOrigin:`anonymous`,integrity:`sha384-hHv6D3tTUUBpp4tVv6t2Dc3oGuRhphmWOTKUR8jWyN0Pnon1g3iebKCNDNmKmxo8`}),window.Plotly}let v=typeof document<`u`&&!!document.fullscreenEnabled;function y(){if(!C(s)||!window.Plotly)return;let{width:e,height:t}=C(s).getBoundingClientRect();e!==0&&t!==0&&window.Plotly.relayout(C(s),{width:e,height:t})}function x(){C(l)&&(document.fullscreenElement?document.exitFullscreen().catch(e=>{P(d,nt(C(i).exitFullscreenFailed,{error:e.message}),!0)}):C(l).requestFullscreen().catch(e=>{P(d,nt(C(i).fullscreenUnavailable,{error:e.message}),!0)}))}le(()=>{function e(){P(p,!!document.fullscreenElement),L().then(y)}return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)});function S(e){let t=document.createElement(`canvas`);t.width=1,t.height=1;let n=t.getContext(`2d`);if(!n)return e;n.fillStyle=e,n.fillRect(0,0,1,1);let[r,i,a,o]=n.getImageData(0,0,1,1).data;return o===255?`rgb(${r}, ${i}, ${a})`:`rgba(${r}, ${i}, ${a}, ${(o/255).toFixed(3)})`}function w(){if(!C(s))return{textColor:`#333`,gridColor:`#eee`,fontFamily:``,colorway:[]};let e=getComputedStyle(C(s)),t=S(e.getPropertyValue(`color`).trim()||`#333`),n=S(e.getPropertyValue(`--border`)?.trim()||e.getPropertyValue(`--color-border`)?.trim()||`rgba(128,128,128,0.2)`),r=[1,2,3,4,5].map(t=>e.getPropertyValue(`--chart-${t}`).trim()).filter(Boolean).map(S);return{textColor:t,gridColor:n,fontFamily:e.fontFamily,colorway:r}}async function E(e,t,n={}){let r=n.format??`png`;try{let i=await e.toImage(t,{...n,format:r});await _F(await(await fetch(i)).blob(),`${n.filename??`chart`}.${r}`)}catch{Cn.error(C(i).downloadFailed)}}async function D(){if(C(s)&&C(o)){P(d,null),P(u,!0);try{let e=await g(),{textColor:t,gridColor:n,fontFamily:r,colorway:c}=w(),l=C(o).data?.some(e=>a.has(e.type)),{title:u,template:d,height:f,width:p,...m}=C(o).layout,h={...m,autosize:!0,margin:{t:24,r:8,b:40,l:60,pad:0},font:{color:t,...r?{family:r}:{}},...c.length&&!m.colorway?{colorway:c}:{},paper_bgcolor:m.paper_bgcolor??`transparent`,plot_bgcolor:m.plot_bgcolor??`transparent`,...l?{}:{xaxis:{...m.xaxis,gridcolor:n,color:t},yaxis:{...m.yaxis,gridcolor:n,color:t}}},_=C(o).config??{};e.react(C(s),{data:C(o).data,layout:h,frames:C(o).frames??[],config:{responsive:!0,displayModeBar:`hover`,displaylogo:!1,showSendToCloud:!1,..._,modeBarButtonsToRemove:[`sendDataToCloud`,`lasso2d`,`select2d`,`toImage`,..._.modeBarButtonsToRemove??[]],modeBarButtonsToAdd:[{name:`toImage`,title:C(i).downloadChartImage,icon:e.Icons.camera,click:t=>E(e,t,_.toImageButtonOptions)},..._.modeBarButtonsToAdd??[]]}})}catch(e){P(d,e instanceof Error?e.message:C(i).chartRenderFailed,!0)}finally{P(u,!1)}}}_(()=>{h=!0;let e=null,t=new ResizeObserver(()=>{e&&clearTimeout(e),e=setTimeout(()=>{y(),e=null},150)});return C(l)&&t.observe(C(l)),()=>{t.disconnect(),e&&clearTimeout(e),C(s)&&window.Plotly&&window.Plotly.purge(C(s))}});let k=null;le(()=>{if(ge.current,n.value&&h&&C(s))return k&&clearTimeout(k),k=setTimeout(()=>{D(),k=null},150),()=>{k&&clearTimeout(k)}});var A=MW(),j=I(A),M=e=>{var t=DW(),n=K(t,!0);G(()=>m(n,C(d))),O(e,t)},N=e=>{var t=OW(),n=K(t,!0);G(()=>m(n,C(i).chartReceiving)),O(e,t)},ee=e=>{var n=jW(),r=z(n);F(r,e=>P(s,e),()=>C(s));var a=U(r,2),o=I(a),l=e=>{var t=kW();mr(I(t),{size:14,class:`animate-spin`}),c(t),O(e,t)};t(o,e=>{C(u)&&e(l)});var d=U(o,2),m=e=>{var n=AW(),r=I(n),a=e=>{Cr(e,{size:14})},o=e=>{br(e,{size:14})};t(r,e=>{C(p)?e(a):e(o,-1)}),c(n),G(()=>{n.disabled=C(u),H(n,`title`,C(p)?C(i).exitFullscreen:C(i).fullscreen),H(n,`aria-label`,C(p)?C(i).exitFullscreen:C(i).fullscreen)}),f(`click`,n,x),O(e,n)};t(d,e=>{v&&e(m)}),c(a),G(()=>{fe(r,1,`w-full ${C(p)?`h-dvh`:`h-95`}`),fe(a,1,`gap-1 left-2 top-2 absolute z-10 flex items-center opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100 ${C(p)?`opacity-100`:``}`)}),O(e,n)};t(j,e=>{C(d)?e(M):C(o)?e(ee,-1):e(N,1)}),c(A),F(A,e=>P(l,e),()=>C(l)),G(()=>fe(A,1,`group relative overflow-hidden rounded-lg border border-border-strong ${C(p)?`bg-background`:``}`)),O(e,A),b()}ce([`click`]);var PW=D(`<div class="px-4 py-3 text-sm text-destructive"> </div>`),FW=D(`<div class="inset-0 text-sm absolute flex items-center justify-center text-destructive"> </div>`),IW=D(`<div class="inset-0 gap-2 text-sm absolute flex items-center justify-center text-muted-foreground"><!> </div>`),LW=D(`<!> <img alt="" draggable="false"/>`,1),RW=D(`<button class="left-2 p-1.5 backdrop-blur-sm absolute top-1/2 -translate-y-1/2 rounded-full border border-border-strong bg-background/80 text-foreground hover:bg-background"><!></button> <button class="right-2 p-1.5 backdrop-blur-sm absolute top-1/2 -translate-y-1/2 rounded-full border border-border-strong bg-background/80 text-foreground hover:bg-background"><!></button>`,1),zW=D(`<button><img alt="" class="h-full w-full object-contain"/></button>`),BW=D(`<div class="gap-1.5 p-1.5 flex overflow-x-auto border-t border-border"></div>`),VW=D(`<span class="shrink-0 tabular-nums"> </span>`),HW=D(`<div class="mx-1 h-4 w-px bg-border"></div>`),UW=D(`<button><!></button>`),WW=D(`<div role="application" tabindex="0"><!> <!> <div> </div></div> <!> <div class="gap-2 px-2 py-1 text-xs flex items-center border-t border-border"><div class="min-w-0 gap-1.5 flex flex-1 items-center text-muted-foreground"><span class="truncate text-foreground"> </span> <!></div> <div class="gap-0.5 flex shrink-0 items-center"><button><!></button> <span class="w-11 text-center text-muted-foreground tabular-nums"> </span> <button><!></button> <button><!></button> <button>1:1</button> <!> <!> <!></div></div>`,1),GW=D(`<div><!></div>`),KW=D(`<div class="px-3 py-3 text-sm rounded-md border border-border-strong text-muted-foreground"> </div>`);function qW(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),o=new Set([`.png`,`.jpg`,`.jpeg`,`.webp`,`.gif`,`.svg`]),s=1.5,l=e=>(e.fileType??``).toLowerCase(),d=e=>typeof e.data==`string`&&e.data.trim()!==``,p=T(()=>(Array.isArray(n.value)?n.value.filter(LB):LB(n.value)?[n.value]:[]).filter(d)),h=T(()=>C(p).filter(e=>o.has(l(e)))),g=T(()=>C(h).length===0?C(p)[0]:void 0),_=Z(0),v=T(()=>Math.max(0,Math.min(C(_),C(h).length-1))),x=T(()=>C(h)[C(v)]??null),S=T(()=>C(x)?l(C(x))===`.svg`:!1);function w(e){let t=PB[l(e)]??`application/octet-stream`;return e.isBase64Encoded?`data:${t};base64,${e.data}`:`data:${t};utf8,${encodeURIComponent(e.data)}`}let E=T(()=>C(x)?w(C(x)):null),D=T(()=>n.item.config??{}),k=T(()=>C(D).allowDownload??!0),A=typeof document<`u`&&!!document.fullscreenEnabled,ee=T(()=>(C(D).allowFullscreen??!0)&&A),te=T(()=>C(D).backgroundColor??(C(S)?`#ffffff`:void 0)),ne=Z(null),L=Z(null),R=Z(!1),re=Z(!1),B=Z(null),ie=Z(null),ae=T(()=>C(ie)!==null&&C(ie)===C(E)),W=Z(0),oe=Z(0),se=Z(0),ce=Z(0),q=Z(1),J=Z(0),Y=Z(0),ue=Z(!0),de=T(()=>C(se)>0&&C(ce)>0&&C(W)>0&&C(oe)>0),X=T(()=>C(de)?Math.min(C(W)/C(se),C(oe)/C(ce)):1),pe=T(()=>Math.min(C(X),1)),he=T(()=>Math.max(C(X),1)*32),ge=T(()=>Math.round(C(q)*100)),_e=T(()=>C(se)*C(q)>C(W)+1||C(ce)*C(q)>C(oe)+1),ve=T(()=>!C(S)&&C(q)>=2);function ye(e,t,n){return t<=n?(n-t)/2:Math.min(0,Math.max(n-t,e))}function be(e,t,n){P(q,e,!0),P(J,ye(t,C(se)*e,C(W)),!0),P(Y,ye(n,C(ce)*e,C(oe)),!0)}function xe(){P(ue,!0),be(C(X),0,0)}function Se(e,t=C(W)/2,n=C(oe)/2){let r=Math.min(C(he),Math.max(C(pe),e)),i=r/C(q);P(ue,Math.abs(r-C(X))<.001),be(r,t-(t-C(J))*i,n-(n-C(Y))*i)}le(()=>{if(!C(L))return;let e=new ResizeObserver(([e])=>{P(W,e.contentRect.width,!0),P(oe,e.contentRect.height,!0),C(ue)?xe():be(Math.max(C(q),C(pe)),C(J),C(Y))});return e.observe(C(L)),()=>e.disconnect()});function Ce(e){let t=e.currentTarget,n=t.naturalWidth||300,r=t.naturalHeight||150,i=n===C(se)&&r===C(ce);P(se,n,!0),P(ce,r,!0),(!i||C(ue))&&xe()}let we={},Te=()=>Object.values(we),Ee=Z(!1),De=0;function Oe(e){let t=C(L).getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function ke(e){if(e.button!==0||e.target.closest(`button`))return;C(L)?.setPointerCapture(e.pointerId),we[e.pointerId]=Oe(e);let t=Te().length;if(P(Ee,t===1&&C(_e),!0),t===2){let[e,t]=Te();De=Math.hypot(e.x-t.x,e.y-t.y)}}function Ae(e){let t=we[e.pointerId];if(!t)return;let n=Oe(e);if(we[e.pointerId]=n,Te().length===2){let[e,t]=Te(),n=Math.hypot(e.x-t.x,e.y-t.y);De>0&&Se(C(q)*(n/De),(e.x+t.x)/2,(e.y+t.y)/2),De=n}else C(Ee)&&(P(ue,!1),be(C(q),C(J)+n.x-t.x,C(Y)+n.y-t.y))}function je(e){delete we[e.pointerId];let t=Te().length;t<2&&(De=0),t===0&&P(Ee,!1)}function Me(e){if(!C(ue))return xe();let t=Oe(e);Se(C(X)<.8?1:C(X)*3,t.x,t.y)}let Ne=Z(!1),Pe;le(()=>{if(!C(L))return;let e=C(L);function t(e){if(!C(de))return;if(!(e.ctrlKey||e.metaKey||C(R))){P(Ne,!0),clearTimeout(Pe),Pe=setTimeout(()=>P(Ne,!1),1200);return}e.preventDefault(),P(Ne,!1);let t=e.deltaMode===1?e.deltaY*16:e.deltaY,n=Oe(e);Se(C(q)*Math.exp(-t*.002),n.x,n.y)}return e.addEventListener(`wheel`,t,{passive:!1}),()=>{e.removeEventListener(`wheel`,t),clearTimeout(Pe)}});function Fe(e){let t={"+":()=>Se(C(q)*s),"=":()=>Se(C(q)*s),"-":()=>Se(C(q)/s),0:xe,1:()=>Se(1),ArrowLeft:()=>Ie(-1),ArrowRight:()=>Ie(1)};C(ee)&&(t.f=Re);let n=t[e.key];n&&(e.preventDefault(),n())}function Ie(e){C(h).length<2||Le((C(v)+e+C(h).length)%C(h).length)}function Le(e){e!==C(v)&&(P(_,e,!0),P(se,0),P(ce,0),P(ue,!0))}function Re(){C(ne)&&(document.fullscreenElement?document.exitFullscreen().catch(e=>{P(B,nt(C(i).exitFullscreenFailed,{error:e.message}),!0)}):C(ne).requestFullscreen().catch(e=>{P(B,nt(C(i).fullscreenUnavailable,{error:e.message}),!0)}))}le(()=>{function e(){P(R,document.fullscreenElement===C(ne))}return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)});async function ze(){if(C(x)){P(re,!0),P(B,null);try{await IB(C(x),C(x).fileName)}catch(e){P(B,e instanceof Error?e.message:C(i).downloadFailed,!0)}finally{P(re,!1)}}}let Be=`flex h-7 min-w-7 items-center justify-center rounded-sm px-1.5 text-muted-foreground transition-colors hover:bg-hover hover:text-foreground disabled:pointer-events-none disabled:opacity-40`;var Ve=u(),He=z(Ve),Ue=e=>{var r=GW(),u=I(r),d=e=>{var t=PW(),n=K(t,!0);G(()=>m(n,C(B))),O(e,t)},p=e=>{var t=PW(),n=K(t,!0);G(e=>m(n,e),[()=>nt(C(i).imageUnsupported,{ext:l(C(g))||C(i).imageUnknownFormat,formats:[...o].join(`, `)})]),O(e,t)},_=e=>{var r=WW(),o=z(r);let l;var u=I(o),d=e=>{var t=FW(),n=K(t,!0);G(e=>m(n,e),[()=>nt(C(i).imageDecodeFailed,{file:`${C(x).fileName}${C(x).fileType}`})]),O(e,t)},p=e=>{var n=LW(),r=z(n),a=e=>{var t=IW(),n=I(t);_t(n,{size:16,class:`animate-spin`});var r=U(n);c(t),G(()=>m(r,` ${C(i).imageLoading??``}`)),O(e,t)};t(r,e=>{C(de)||e(a)});var o=U(r,2);let s;G(()=>{H(o,`src`,C(E)),fe(o,1,`absolute top-(--img-y) left-(--img-x) h-(--img-h) w-(--img-w) max-w-none
|
|
6080
6080
|
${C(ve)?`pixelated`:``}
|
|
6081
|
-
${C(de)?``:`invisible`}`,`svelte-a62aei`),s=N(o,``,s,{"--img-x":`${C(J)??``}px`,"--img-y":`${C(Y)??``}px`,"--img-w":`${C(se)*C(q)}px`,"--img-h":`${C(ce)*C(q)}px`})}),j(`load`,o,Ce),j(`error`,o,()=>P(ie,C(E),!0)),M(o),O(e,n)};t(u,e=>{C(ae)?e(d):e(p,-1)});var g=U(u,2),_=e=>{var t=
|
|
6082
|
-
${C(
|
|
6081
|
+
${C(de)?``:`invisible`}`,`svelte-a62aei`),s=N(o,``,s,{"--img-x":`${C(J)??``}px`,"--img-y":`${C(Y)??``}px`,"--img-w":`${C(se)*C(q)}px`,"--img-h":`${C(ce)*C(q)}px`})}),j(`load`,o,Ce),j(`error`,o,()=>P(ie,C(E),!0)),M(o),O(e,n)};t(u,e=>{C(ae)?e(d):e(p,-1)});var g=U(u,2),_=e=>{var t=RW(),n=z(t),r=I(n);ct(r,{size:16}),c(n);var a=U(n,2),o=I(a);ut(o,{size:16}),c(a),G(()=>{H(n,`title`,`${C(i).previousImage??``} (←)`),H(n,`aria-label`,C(i).previousImage),H(a,`title`,`${C(i).nextImage??``} (→)`),H(a,`aria-label`,C(i).nextImage)}),f(`click`,n,()=>Ie(-1)),f(`click`,a,()=>Ie(1)),O(e,t)};t(g,e=>{C(h).length>1&&e(_)});var b=U(g,2),S=K(b,!0);c(o),F(o,e=>P(L,e),()=>C(L));var T=U(o,2),D=e=>{var t=BW();a(t,21,()=>C(h),y,(e,t,n)=>{var r=zW(),i=K(r);G(e=>{H(r,`title`,`${C(t).fileName??``}${C(t).fileType??``}`),fe(r,1,`h-12 w-16 shrink-0 overflow-hidden rounded-sm border-2 bg-muted transition-colors ${n===C(v)?`border-primary`:`border-transparent opacity-70 hover:opacity-100`}`),H(i,`src`,e)},[()=>w(C(t))]),f(`click`,r,()=>Le(n)),O(e,r)}),c(t),O(e,t)};t(T,e=>{C(h).length>1&&e(D)});var A=U(T,2),ne=I(A),B=I(ne),V=K(B),W=U(B,2),oe=e=>{var t=VW(),n=K(t);G(()=>m(n,`${C(se)??``}×${C(ce)??``}`)),O(e,t)};t(W,e=>{C(de)&&e(oe)}),c(ne);var le=U(ne,2),X=I(le);fe(X,1,me(Be),`svelte-a62aei`),Xr(I(X),{size:14}),c(X);var Z=U(X,2),ye=K(Z),be=U(Z,2);fe(be,1,me(Be),`svelte-a62aei`),qr(I(be),{size:14}),c(be);var we=U(be,2);fe(we,1,me(Be),`svelte-a62aei`),Fr(I(we),{size:14}),c(we);var Te=U(we,2);fe(Te,1,`flex h-7 min-w-7 items-center justify-center rounded-sm px-1.5 text-muted-foreground transition-colors hover:bg-hover hover:text-foreground disabled:pointer-events-none disabled:opacity-40 font-medium tabular-nums svelte-a62aei`);var De=U(Te,2),Oe=e=>{var t=HW();O(e,t)};t(De,e=>{(C(k)||C(ee))&&e(Oe)});var Pe=U(De,2),Ve=e=>{var t=UW();fe(t,1,me(Be),`svelte-a62aei`),Vn(I(t),{size:14}),c(t),G(()=>{t.disabled=C(re),H(t,`title`,C(i).downloadImage),H(t,`aria-label`,C(i).downloadImage)}),f(`click`,t,ze),O(e,t)};t(Pe,e=>{C(k)&&e(Ve)});var He=U(Pe,2),Ue=e=>{var n=UW();fe(n,1,me(Be),`svelte-a62aei`);var r=I(n),a=e=>{Cr(e,{size:14})},o=e=>{br(e,{size:14})};t(r,e=>{C(R)?e(a):e(o,-1)}),c(n),G(()=>{H(n,`title`,`${(C(R)?C(i).exitFullscreen:C(i).fullscreen)??``} (F)`),H(n,`aria-label`,C(R)?C(i).exitFullscreen:C(i).fullscreen)}),f(`click`,n,Re),O(e,n)};t(He,e=>{C(ee)&&e(Ue)}),c(le),c(A),G(e=>{H(o,`aria-roledescription`,C(i).imageViewer),H(o,`aria-label`,n.item.displayName??C(x).fileName),fe(o,1,`relative w-full overflow-hidden outline-none select-none focus-visible:ring-2 focus-visible:ring-ring
|
|
6082
|
+
${C(R)?`flex-1`:`h-95`}
|
|
6083
6083
|
${C(Ee)?`cursor-grabbing`:C(_e)?`cursor-grab`:`cursor-zoom-in`}
|
|
6084
6084
|
${C(ue)?`touch-pan-y`:`touch-none`}
|
|
6085
|
-
${C(ee)?`bg-(--image-bg)`:`checkerboard`}`,`svelte-a62aei`),l=N(o,``,l,{"--image-bg":C(ee)}),fe(b,1,`px-2.5 py-1 text-xs bottom-2 pointer-events-none absolute left-1/2 -translate-x-1/2 rounded-sm bg-foreground text-background transition-opacity ${C(Ne)?`opacity-100`:`opacity-0`}`),m(S,C(i).zoomHint),m(V,`${C(x).fileName??``}${C(x).fileType??``}`),X.disabled=!C(de)||C(q)<=C(pe)+.001,H(X,`title`,`${C(i).zoomOut??``} (−)`),H(X,`aria-label`,C(i).zoomOut),m(ye,`${C(ge)??``}%`),be.disabled=!C(de)||C(q)>=C(he)-.001,H(be,`title`,`${C(i).zoomIn??``} (+)`),H(be,`aria-label`,C(i).zoomIn),we.disabled=!C(de)||C(ue),H(we,`title`,`${C(i).zoomFit??``} (0)`),H(we,`aria-label`,C(i).zoomFit),Te.disabled=e,H(Te,`title`,`${C(i).zoomActual??``} (1)`),H(Te,`aria-label`,C(i).zoomActual)},[()=>!C(de)||Math.abs(C(q)-1)<.001]),f(`pointerdown`,o,ke),f(`pointermove`,o,Ae),f(`pointerup`,o,je),j(`pointercancel`,o,je),f(`dblclick`,o,Me),f(`keydown`,o,Fe),f(`click`,X,()=>Se(C(q)/s)),f(`click`,be,()=>Se(C(q)*s)),f(`click`,we,xe),f(`click`,Te,()=>Se(1)),O(e,r)};t(u,e=>{C(re)?e(d):C(g)?e(p,1):C(x)&&e(_,2)}),c(r),F(r,e=>P(te,e),()=>C(te)),G(()=>fe(r,1,`flex flex-col overflow-hidden rounded-lg border border-border-strong bg-background ${C(z)?`h-dvh`:``}`)),O(e,r)},We=e=>{var t=WW(),n=K(t,!0);G(()=>m(n,C(i).waitingForData)),O(e,t)};t(He,e=>{C(re)||C(g)||C(x)?e(Ue):e(We,-1)}),O(e,Ve),b()}ce([`pointerdown`,`pointermove`,`pointerup`,`dblclick`,`keydown`,`click`]);var KW=Symbol(`deferred-files-context`);function qW(e){n(KW,e)}function JW(){return s(KW)}var YW=D(`<span> </span>`),XW=D(`<div class="gap-2 flex items-center"><!> <!></div>`),ZW=D(`<span class="text-muted-foreground not-italic"> </span>`),QW=D(`<div class="ml-4 pl-2 border-l border-border-strong"><!></div>`),$W=D(`<div><button class="gap-1.5 py-0.5 text-xs flex w-full items-center text-muted-foreground transition-colors hover:text-foreground"><!> <!> <span class="font-medium"> </span></button> <!></div>`),eG=D(`<div class="gap-1.5 py-0.5 flex items-center justify-between"><div class="gap-1.5 min-w-0 flex items-center"><!> <span class="text-xs truncate text-foreground"> </span></div> <span class="text-xs shrink-0 text-muted-foreground"> </span></div>`),tG=D(`<div class="gap-2 flex flex-col"><div class="px-3 py-3 text-sm rounded-md border border-border-strong bg-muted text-muted-foreground"> </div> <!></div>`),nG=D(`<div class="gap-2 flex flex-col"><div class="gap-2 px-3 py-3 flex flex-col rounded-md border border-border-strong bg-muted" role="status"><div class="gap-2 flex items-center justify-between"><span class="text-sm font-medium text-foreground"> </span> <span class="text-xs shrink-0 text-muted-foreground tabular-nums"> </span></div> <div class="h-1 overflow-hidden rounded-full bg-selected"><div class="animate-pulse h-full w-full rounded-full bg-primary"></div></div></div> <!></div>`),rG=D(`<div class="px-3 py-3 text-sm rounded-md border border-border-strong bg-muted text-muted-foreground"> </div>`),iG=D(`<div class="gap-2 flex flex-col"><div class="px-3 py-2 text-sm rounded-md border border-destructive bg-destructive/10 text-destructive"> </div> <!></div>`),aG=D(`<div class="gap-2 text-xs flex items-center justify-between text-muted-foreground"><span class="min-w-0 truncate"> </span> <span class="shrink-0"> </span></div>`),oG=D(`<div class="gap-1 flex flex-col"></div>`),sG=D(`<div class="mt-2"><!></div>`),cG=D(`<span class="text-xs text-muted-foreground"> </span>`),lG=D(`<li class="truncate"><span class="font-mono"> </span></li>`),uG=D(`<div class="px-3 py-2 text-sm rounded-md border border-destructive bg-destructive/10 text-destructive"><div class="font-medium"> </div> <div class="mt-1 text-xs"> </div> <ul class="mt-1 ml-4 text-xs list-disc"></ul> <div class="mt-1 text-xs"> </div></div>`),dG=D(`<div class="px-3 py-2 text-sm rounded-md border border-destructive bg-destructive/10 text-destructive"> </div>`),fG=D(`<div class="gap-2 flex flex-col"><div class="px-3 py-2 rounded-md border border-border-strong bg-muted"><div class="gap-2 flex items-center justify-between"><span class="min-w-0 text-sm font-medium truncate text-foreground"> </span> <span class="text-xs shrink-0 text-muted-foreground"> </span></div> <!></div> <!> <!> <!> <!></div>`),pG=D(`<span class="text-base font-normal"><!></span>`),mG=D(`<div class="min-h-8 text-2xl font-semibold wrap-break-word text-foreground tabular-nums"><!></div>`),hG=D(`<pre> </pre>`),gG=D(`<div><!></div>`),_G=D(`<div class="group relative"><!> <!></div>`),vG=D(`<div role="group"><!> <!></div>`);function yG(e,n){V(n,!0);let r=e=>{var r=XW(),i=L(r);mn(i,{children:(e,t)=>{var r=YW(),i=K(r,!0);G(()=>{fe(r,1,me(n.item.widgetType===`number`?`text-xs font-normal text-muted-foreground`:``)),m(i,C(y))}),O(e,r)},$$slots:{default:!0}});var a=U(i,2),o=e=>{pV(e,{get label(){return C(y)},get description(){return n.item.description},get nameTemplate(){return d.messages.helpFor}})};t(a,e=>{n.item.description&&e(o)}),c(r),O(e,r)},i=e=>{var t=ZW(),n=K(t,!0);G(()=>m(n,C(g).waitingForData)),O(e,t)},o=(e,n=h,r=h)=>{var i=u(),s=B(i);a(s,17,n,([e,t])=>e,(e,n)=>{var i=T(()=>w(C(n),2));let a=()=>C(i)[1];var s=u(),l=B(s),d=e=>{let n=T(()=>r()?`${r()}/${a().name}`:a().name),i=T(()=>ce.has(C(n)));var s=$W(),l=L(s),u=L(l);{let e=T(()=>C(i)?`rotate-90`:``);ut(u,{size:12,get class(){return`shrink-0 transition-transform duration-150 ${C(e)??``}`}})}var d=U(u,2),p=e=>{Ot(e,{size:13,class:`shrink-0 text-primary/70`})},h=e=>{$n(e,{size:13,class:`shrink-0 text-primary/70`})};t(d,e=>{C(i)?e(p):e(h,-1)});var g=U(d,2),_=K(g,!0);c(l);var v=U(l,2),y=e=>{var t=QW(),r=L(t);o(r,()=>a().children,()=>C(n)),c(t),O(e,t)};t(v,e=>{C(i)&&e(y)}),c(s),G(()=>m(_,a().name)),f(`click`,l,()=>q(C(n))),O(e,s)},p=e=>{var t=eG(),n=L(t),r=L(n);Xn(r,{size:12,class:`shrink-0 text-muted-foreground`});var i=U(r,2),o=K(i);c(n);var s=U(n,2),l=K(s,!0);c(t),G(e=>{m(o,`${a().file.fileName??``}${a().file.fileType??``}`),m(l,e)},[()=>IB(LB(a().file.data))]),O(e,t)};t(l,e=>{a().type===`folder`?e(d):e(p,-1)}),O(e,s)}),O(e,i)},s=e=>{var n=u(),r=B(n),i=e=>{var t=tG(),n=L(t),r=K(n,!0),i=U(n,2);{let e=T(()=>M?.isSolving);tt(i,{onclick:()=>M?.make(),get disabled(){return C(e)},class:`w-full`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(g).download)),O(e,n)},$$slots:{default:!0}})}c(t),G(()=>m(r,C(g).filesMadeOnDownload)),O(e,t)},a=e=>{var t=nG(),n=L(t),r=L(n),i=L(r),a=K(i,!0),o=U(i,2),s=K(o,!0);c(r),S(2),c(n);var l=U(n,2);tt(l,{variant:`outline`,onclick:()=>M?.cancel(),class:`w-full`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(g).cancel)),O(e,n)},$$slots:{default:!0}}),c(t),G(()=>{m(a,C(g).makingFiles),m(s,C(ee))}),O(e,t)},o=e=>{var t=rG(),n=K(t,!0);G(()=>m(n,C(g).noFilesForInputs)),O(e,t)},s=e=>{var t=iG(),n=L(t),r=K(n,!0),i=U(n,2);{let e=T(()=>M?.isSolving);tt(i,{variant:`outline`,onclick:()=>M?.make(),get disabled(){return C(e)},class:`w-full`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(g).tryAgain)),O(e,n)},$$slots:{default:!0}})}c(t),G(()=>m(r,C(N).error)),O(e,t)};t(r,e=>{C(N)?.status===`waiting`?e(i):C(N)?.status===`making`?e(a,1):C(N)?.status===`empty`?e(o,2):C(N)?.status===`failed`&&e(s,3)}),O(e,n)},l=e=>{var n=u(),r=B(n),i=e=>{s(e)},l=e=>{var t=rG(),n=K(t,!0);G(()=>m(n,C(g).waitingForFiles)),O(e,t)},d=e=>{var n=fG(),r=L(n),i=L(r),s=L(i),l=K(s,!0),u=U(s,2),d=K(u,!0);c(i);var f=U(i,2),h=e=>{var n=sG(),r=L(n),i=e=>{o(e,()=>C(H),()=>``)},s=e=>{var t=oG();a(t,23,()=>C(te),(e,t)=>W(e)+`#`+t,(e,t)=>{var n=aG(),r=L(n),i=K(r),a=U(r,2),o=K(a,!0);c(n),G(e=>{m(i,`${C(t).fileName??``}${C(t).fileType??``}`),m(o,e)},[()=>IB(LB(C(t).data))]),O(e,n)}),c(t),O(e,t)};t(r,e=>{C(H)?e(i):e(s,-1)}),c(n),O(e,n)};t(f,e=>{C(R)>1&&e(h)}),c(r);var _=U(r,2),v=e=>{var t=cG(),n=K(t,!0);G(e=>m(n,e),[()=>nt(C(g).filesMadeIn,{seconds:Math.max(1,Math.round(C(N).durationMs/1e3))})]),O(e,t)};t(_,e=>{C(N)?.status===`ready`&&e(v)});var y=U(_,2),b=e=>{var t=uG(),n=L(t),r=K(n,!0),i=U(n,2),o=K(i,!0),s=U(i,2);a(s,20,()=>C(oe),e=>e,(e,t)=>{var n=lG(),r=L(n),i=K(r,!0);c(n),G(()=>m(i,t)),O(e,n)}),c(s);var l=U(s,2),u=K(l,!0);c(t),G(e=>{m(r,C(g).duplicateFilesTitle),m(o,e),m(u,C(g).duplicateFilesHint)},[()=>it(C(oe).length,C(g).duplicatePathsOne,C(g).duplicatePathsOther)]),O(e,t)};t(y,e=>{C(se)&&e(b)});var x=U(y,2),w=e=>{var t=dG(),n=K(t,!0);G(()=>m(n,C(j))),O(e,t)};t(x,e=>{C(j)&&e(w)});var E=U(x,2);{let e=T(()=>C(A)||C(se));tt(E,{onclick:J,get disabled(){return C(e)},class:`w-full`,children:(e,t)=>{S();var n=p();G(e=>m(n,e),[()=>C(A)?C(g).downloading:C(R)===1?C(g).downloadFile:nt(C(g).downloadFiles,{count:C(R)})]),O(e,n)},$$slots:{default:!0}})}c(n),G((e,t)=>{m(l,e),m(d,t)},[()=>C(R)===1?`${C(te)[0].fileName}${C(te)[0].fileType}`:nt(C(g).fileCount,{count:C(R)}),()=>IB(C(z))]),O(e,n)};t(r,e=>{C(N)&&C(N).status!==`ready`?e(i):C(R)===0?e(l,1):e(d,-1)}),O(e,n)},d=at(),g=T(()=>d.messages),_=Z(!1),v,y=T(()=>n.displayName||n.item.displayName||n.item.paramId),x=T(()=>typeof n.value==`object`&&n.value!==null),E=T(()=>n.value==null?``:C(x)?JSON.stringify(n.value,null,2):String(n.value)),D=T(()=>n.value!=null);async function k(){try{await navigator.clipboard.writeText(C(E)),P(_,!0),clearTimeout(v),v=setTimeout(()=>P(_,!1),2e3)}catch(e){console.error(`Failed to copy:`,e)}}let A=Z(!1),j=Z(null),M=JW(),N=T(()=>{let e=M?.files;return e&&e.status!==`none`&&e.ids.includes(n.item.paramId)?e:null}),F=T(()=>C(N)?.status===`ready`?C(N).outputs[n.item.paramId]:n.value),I=Z(re(Date.now()));le(()=>{if(C(N)?.status!==`making`)return;P(I,Date.now(),!0);let e=setInterval(()=>P(I,Date.now(),!0),1e3);return()=>clearInterval(e)});let ee=T(()=>{if(C(N)?.status!==`making`)return``;let e=Math.max(0,Math.floor((C(I)-C(N).startedAt)/1e3));return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}),te=T(()=>C(F)?Array.isArray(C(F))?C(F).filter(FB):FB(C(F))?[C(F)]:[]:[]),R=T(()=>C(te).length),z=T(()=>C(te).reduce((e,t)=>e+LB(t.data),0));function ne(e){let t=new be;for(let n=0;n<e.length;n++){let r=e[n],i=aI(r.subFolder),a=t;for(let e of i){a.has(e)||a.set(e,{type:`folder`,name:e,children:new be});let t=a.get(e);t.type===`folder`&&(a=t.children)}let o=`${r.fileName}${r.fileType??``}`,s=a.has(o)?`${o}#${n}`:o;a.set(s,{type:`file`,file:r})}return t}function ie(e,t=``){let n=[];for(let[r,i]of e)if(i.type===`folder`){let e=t?`${t}/${r}`:r;n.push(e),n.push(...ie(i.children,e))}return n}let ae=T(()=>C(te).some(e=>e.subFolder&&e.subFolder.length>0)),H=T(()=>C(ae)?ne(C(te)):null);function W(e){let t=aI(e.subFolder).join(`/`),n=`${e.fileName}${e.fileType??``}`;return t?`${t}/${n}`:n}let oe=T(()=>{let e={};for(let t of C(te)){let n=W(t);e[n]=(e[n]??0)+1}return Object.entries(e).filter(([,e])=>e>1).map(([e])=>e)}),se=T(()=>C(oe).length>0),ce=new ye;le(()=>{if(C(H)){ce.clear();for(let e of ie(C(H)))ce.add(e)}});function q(e){ce.has(e)?ce.delete(e):ce.add(e)}async function J(){if(C(R)!==0){P(A,!0),P(j,null);try{if(C(R)===1)await PB(C(te)[0],C(te)[0].fileName);else{let e=n.displayName?n.displayName.replace(/[^a-z0-9]/gi,`_`).toLowerCase():`download`;await PB(C(te),e)}}catch(e){P(j,e instanceof Error?e.message:C(g).downloadFailed,!0),console.error(`[OutputDisplayWidget] Download error:`,e)}finally{P(A,!1)}}}var Y=u(),ue=B(Y),de=e=>{var a=vG(),o=L(a);r(o);var s=U(o,2),u=e=>{{let t=T(()=>typeof n.value==`string`?n.value:n.value==null?``:JSON.stringify(n.value));jW(e,{get item(){return n.item},get value(){return C(t)}})}},d=e=>{GW(e,{get item(){return n.item},get value(){return n.value}})},f=e=>{l(e)},h=e=>{var n=mG(),r=L(n),a=e=>{var t=p();G(()=>m(t,C(E))),O(e,t)},o=e=>{var t=pG(),n=L(t);i(n),c(t),O(e,t)};t(r,e=>{C(D)?e(a):e(o,-1)}),c(n),O(e,n)},v=e=>{var r=_G(),a=L(r),o=e=>{var t=hG();fe(t,1,`min-h-12.5 rounded-md px-3 py-3 text-sm border border-border-strong max-h-96 font-mono overflow-auto bg-muted wrap-anywhere text-foreground`);var n=K(t,!0);G(()=>m(n,C(E))),O(e,t)},s=e=>{var r=gG();fe(r,1,`min-h-12.5 rounded-md px-3 py-3 text-sm border border-border-strong bg-muted wrap-anywhere wrap-break-word whitespace-pre-wrap text-foreground`);var a=L(r),o=e=>{var t=p();G(()=>m(t,n.value)),O(e,t)},s=e=>{i(e)};t(a,e=>{C(D)?e(o):e(s,-1)}),c(r),O(e,r)};t(a,e=>{C(x)?e(o):e(s,-1)});var l=U(a,2),u=e=>{var t=gG(),n=L(t);tt(n,{onclick:k,size:`sm`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(_)?C(g).copied:C(g).copy)),O(e,n)},$$slots:{default:!0}}),c(t),G(()=>fe(t,1,`right-2 top-2 absolute transition-opacity ${C(_)?`opacity-100`:`opacity-0 group-hover:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100`}`)),O(e,t)};t(l,e=>{C(D)&&e(u)}),c(r),O(e,r)};t(s,e=>{n.item.widgetType===`chart`?e(u):n.item.widgetType===`image`?e(d,1):n.item.widgetType===`file`?e(f,2):n.item.widgetType===`number`?e(h,3):n.item.widgetType===`text`&&e(v,4)}),c(a),G(()=>fe(a,1,`group/field flex flex-col ${n.item.widgetType===`number`?`gap-0.5`:`gap-2`}`)),O(e,a)};t(ue,e=>{n.item.widgetType!==`dynamicValueList`&&e(de)}),O(e,Y),b()}ce([`click`]);var bG=D(`<h3 class="text-sm font-medium text-foreground"> </h3>`),xG=D(`<span class="text-xs truncate text-muted-foreground"> </span>`),SG=D(`<div role="group"><!></div>`),CG=D(`<div class="gap-1.5 flex flex-col"><span class="text-sm truncate"> </span> <div></div></div>`),wG=D(`<section class="gap-3 flex flex-col"><div class="gap-1 flex flex-col"><!> <div></div></div> <!></section>`),TG=D(`<div class="gap-5 flex flex-col"></div>`);function EG(e,n){V(n,!0);let r=J(n,`memberMedia`,19,()=>({})),i=J(n,`disabled`,3,!1),o=T(()=>{let e=[];return n.repeat.rows.forEach((t,n)=>{let r=t.section??``,i=e.find(e=>e.label===r);i||e.push(i={label:r,rows:[]}),i.rows.push({index:n,key:t.key,label:t.label||t.key})}),e});function s(e,t){let r=n.shown[e];return Array.isArray(r)&&typeof r[t]==`string`?r[t]:void 0}function l(e,t,r){typeof r==`string`&&n.onPick(e,t,r)}let u=(e,t)=>({options:n.rowOptions[e]?.[t]??{},optionMedia:r()[e]}),d=[`grid-cols-1`,`grid-cols-1`,`grid-cols-2`,`grid-cols-3`,`grid-cols-4`],f=T(()=>d[Math.min(n.repeat.members.length,4)]);var p=TG();a(p,21,()=>C(o),e=>e.label,(e,r)=>{var o=wG(),d=L(o),p=L(d),h=e=>{var t=bG(),n=K(t,!0);G(()=>m(n,C(r).label)),O(e,t)};t(p,e=>{C(r).label&&e(h)});var g=U(p,2);a(g,20,()=>n.repeat.members,e=>e,(e,t)=>{var r=xG(),i=K(r,!0);G(()=>m(i,n.memberLabels[t]??t)),O(e,r)}),c(g),c(d);var _=U(d,2);a(_,17,()=>C(r).rows,e=>e.key,(e,t)=>{var r=CG(),o=L(r),d=K(o,!0),p=U(o,2);a(p,20,()=>n.repeat.members,e=>e,(e,r)=>{var a=SG(),o=L(a);{let e=T(()=>s(r,C(t).index)),a=T(()=>u(r,C(t).index));qV(o,{get value(){return C(e)},get config(){return C(a)},onChange:e=>l(r,C(t).key,e),get disabled(){return i()},get assets(){return n.assets}})}c(a),G(()=>H(a,`aria-label`,`${C(t).label??``}: ${n.memberLabels[r]??r??``}`)),O(e,a)}),c(p),c(r),G(()=>{H(o,`title`,C(t).label),m(d,C(t).label),fe(p,1,`gap-2 grid items-center ${C(f)??``}`)}),O(e,r)}),c(o),G(()=>{H(o,`aria-label`,C(r).label||void 0),fe(g,1,`gap-x-2 grid ${C(f)??``}`)}),O(e,o)}),c(p),O(e,p),b()}var DG=D(`<div class="gap-4 py-4 flex flex-col"></div>`),OG=D(`<div><h2 class="sr-only"> </h2> <!></div>`),kG=D(`<div class="h-full"><!></div>`);function AG(e,n){V(n,!0);let r=(e,r=h,i=h)=>{let a=T(()=>x(r().paramId)),o=T(()=>n.formModel?.repeatOf[r().paramId]),s=T(()=>C(o)?n.formModel?.repeats.find(e=>e.id===C(o)):void 0);var c=u(),l=B(c),m=e=>{var r=u(),o=B(r),c=e=>{EG(e,{get repeat(){return C(s)},get memberLabels(){return p()},get memberMedia(){return g()},get shown(){return n.formModel.shown},get rowOptions(){return n.formModel.rowOptions},get onPick(){return n.onRowPick},get disabled(){return i().disabled},get assets(){return n.assets}})};t(o,e=>{f()[C(s).id]===C(a).id&&n.onRowPick&&e(c)}),O(e,r)},_=e=>{lW(e,{get item(){return r()},get value(){return n.values[C(a).id]},get displayName(){return r().displayName},get onChange(){return n.onValueChange},get disabled(){return i().disabled},get dynamicOptions(){return d()[C(a).id]},get paramType(){return C(a).paramType},get assets(){return n.assets}})};t(l,e=>{C(a)&&C(s)&&n.formModel?e(m):C(a)&&e(_,1)}),O(e,c)},i=(e,r=h)=>{let i=T(()=>S(r().paramId));var a=u(),o=B(a),s=e=>{yG(e,{get item(){return r()},get value(){return n.values[r().paramId]},get displayName(){return r().displayName}})};t(o,e=>{C(i)&&e(s)}),O(e,a)},o=e=>{var o=OG(),s=L(o),u=K(s,!0),d=U(s,2),f=e=>{Zc(e,{type:`empty`,size:`medium`,get message(){return C(l).tabNoGroups}})},p=e=>{var t=DG();a(t,21,()=>C(y),e=>e.id,(e,t)=>{{let a=T(()=>C(t).columns??1),o=T(()=>n.collapsedGroups[C(t).id]??!1),s=T(()=>C(y).length===1);rV(e,{get label(){return C(t).label},get description(){return C(t).description},get items(){return C(t).items},get columns(){return C(a)},get collapsed(){return C(o)},get values(){return n.values},onToggle:()=>n.onToggleGroup(C(t).id),get inputSnippet(){return r},get outputSnippet(){return i},get flat(){return C(s)}})}}),c(t),O(e,t)};t(d,e=>{C(y).length===0?e(f):e(p,-1)}),c(o),G(()=>{fe(o,1,me(_()?`px-1`:`px-3`)),m(u,n.tab.label)}),O(e,o)},s=at(),l=T(()=>s.messages),d=J(n,`dynamicOptions`,19,()=>({})),f=J(n,`repeatLeads`,19,()=>({})),p=J(n,`memberLabels`,19,()=>({})),g=J(n,`memberMedia`,19,()=>({})),_=J(n,`bare`,3,!1),{host:v}=zU(),y=T(()=>n.tab.groups.filter(e=>qB(e,n.values)).flatMap(e=>{let t=e.items.filter(e=>QU(v,ZU(e,n.inputs)));return t.length>0||e.items.length===0?[{...e,items:t}]:[]}));function x(e){return n.inputs.find(t=>t.id===e)}function S(e){return n.outputs.find(t=>t.id===e)}var w=u(),D=B(w);E(D,()=>_n,(e,r)=>{r(e,{get value(){return n.tab.id},class:`min-h-0`,children:(e,n)=>{var r=u(),i=B(r),a=e=>{o(e)},s=e=>{var t=kG();Xo(L(t),{class:`h-full`,orientation:`vertical`,type:`auto`,children:(e,t)=>{o(e)},$$slots:{default:!0}}),c(t),O(e,t)};t(i,e=>{_()?e(a):e(s,-1)}),O(e,r)},$$slots:{default:!0}})}),O(e,w),b()}function jG(e){return typeof e==`object`&&!!e&&(`targetInputId`in e||`options`in e)}function MG(e){if(jG(e))return e;let t=e;for(let e=0;e<2&&typeof t==`string`;e++){try{t=JSON.parse(t)}catch{return null}if(jG(t))return t}return null}var NG=new Map,PG=8;function FG(e){if(typeof e!=`string`||e.length<1024)return MG(e);let t=NG.get(e);if(t!==void 0||NG.has(e))return NG.delete(e),NG.set(e,t??null),t??null;let n=performance.now(),r=MG(e);if(e.length>262144){let t=r?.options?Object.keys(r.options).length:0;console.info(`[DVL] parsed ${(e.length/1048576).toFixed(1)} MB options payload (${t} options) in ${(performance.now()-n).toFixed(0)}ms — cache miss`)}if(NG.size>=PG){let e=NG.keys().next().value;e!==void 0&&NG.delete(e)}return NG.set(e,r),r}function IG(e){let t=new Map;for(let n of RF(e)){if(n.type!==`output`||n.widgetType!==`dynamicValueList`)continue;let e=n;typeof e.paramId==`string`&&t.set(e.paramId,{id:e.paramId,targetInputId:e.config?.targetInputId})}for(let n of e.outputs??[])n.type===`dynamicValueList`&&t.set(n.id,{id:n.id,targetInputId:n.targetInputId});return[...t.values()]}function LG(e,t){if(typeof t!=`string`)return-1;let n=t.toLowerCase();return e.findIndex(([e,t])=>t.toLowerCase()===n||e.toLowerCase()===n)}function RG(e,t){let n=Object.entries(e??{});return n.length===0?typeof t==`string`?t:``:n[Math.max(0,LG(n,t))][1]}function zG(e,t){let n=Object.entries(e??{});if(n.length===0)return t.filter(e=>typeof e==`string`);let r=new Set;for(let e of t){let t=LG(n,e);t>=0&&r.add(t)}return r.size>0?[...r].map(e=>n[e][1]):[n[0][1]]}function BG(e,t,n){let r=Object.entries(e??{});if(r.length===0||!Array.isArray(t))return n;let i=t.filter(e=>typeof e==`string`&&LG(r,e)<0&&!n.includes(e));return[...n,...i]}function VG(e){if(typeof e!=`string`||!e.trimStart().startsWith(`{`))return{};try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]==`string`))}catch{return{}}}function HG(e,t,n){return JSON.stringify({...VG(e),[t]:n})}function UG(e,t,n){let r={},i={};for(let{source:a,payload:o}of e){let e=o.targetInputId??a.targetInputId;if(!e||!o.options||typeof o.options!=`object`)continue;let s=t.get(n[e]),c=o.options;s?i[e]=s.rows.map(()=>c):r[e]=c}for(let{source:n,payload:r}of e){let e=t.get(n.id),a=r.options;if(e&&a&&Object.keys(a).length!==0)for(let t of e.members)i[t]??=e.rows.map(()=>a)}return{options:r,rowOptions:i}}var WG=new WeakMap;function GG(e,t,n,r){let i={},a={},o={};for(let{payload:s}of e){let e=s.pickTable;if(!e||!Array.isArray(e.inputs)||!Array.isArray(e.rows))continue;let c=WG.get(e.rows)??new Map;WG.set(e.rows,c);let l=Array.isArray(e.by)?e.by:[],u=l.map(e=>{let n=t[e];return(Array.isArray(n)?n:[n]).filter(e=>e!=null).map(String)}),d=Array.from({length:Math.max(1,...u.map(e=>e.length))},(t,n)=>{let r=u.map(e=>e[Math.min(n,e.length-1)]);return{rows:e.rows.filter(e=>r.every((t,n)=>t===void 0||e[n]?.toLowerCase()===t.toLowerCase())),picked:r.map(e=>e??``)}}),f=[];e.inputs.forEach((s,u)=>{let p=l.length+u,m=e.parents?.[u]??u-1,h=m>=0&&f[m]?f[m]:d,g=n.get(r[s]),_=g?VG(t[s]):void 0,v=g?g.rows.map(e=>_?.[e.key]):[t[s]],y=[],b=[],x=v.map((e,t)=>{let{rows:n,picked:r}=h[Math.min(t,h.length-1)],i=JSON.stringify([p,...r]),a=c.get(i);if(!a){a={};for(let e of n){let t=e[p];typeof t==`string`&&t!==``&&(a[t]=t)}c.set(i,a)}y.push(a);let o=RG(a,e);return b.push(o),{rows:n.filter(e=>e[p]===o),picked:[...r,`${p}:${o}`]}});g?(a[s]=y,o[s]=b):(i[s]=y[0],o[s]=b[0]),f[u]=x.length>0?x:h})}return{options:i,rowOptions:a,shown:o}}function KG(e,t,n){let r=[];for(let n of IG(e)){let e=FG(t[n.id]);e&&r.push({source:n,payload:e})}let i=[],a={};for(let{source:e,payload:t}of r){if(!Array.isArray(t.rows)||!Array.isArray(t.members))continue;let n=t.rows.filter(e=>typeof e?.key==`string`);i.push({id:e.id,rows:n,members:t.members});for(let n of t.members)a[n]=e.id}let o=new Map(i.map(e=>[e.id,e])),s=GG(r,t,o,a),c=UG(r,o,a);Object.assign(c.options,s.options),Object.assign(c.rowOptions,s.rowOptions);let l={...s.shown};for(let{source:e,payload:n}of r){let r=n.targetInputId??e.targetInputId;if(!r||!n.resolvedInSolve||a[r])continue;let i=t[r];l[r]=Array.isArray(i)?zG(c.options[r],i):RG(c.options[r],i)}for(let e of i)for(let n of e.members){let r=VG(t[n]);l[n]=e.rows.map((e,t)=>RG(c.rowOptions[n]?.[t],r[e.key]))}return n&&(JG(l,n.shown),JG(c.rowOptions,n.rowOptions)),{...c,repeats:i,repeatOf:a,shown:l}}function qG(e,t){return e===t?!0:!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function JG(e,t){for(let n of Object.keys(e))n in t&&qG(e[n],t[n])&&(e[n]=t[n])}var YG=D(`<!> <!>`,1),XG=D(`<div class="min-h-0 flex flex-1 flex-col"><!></div>`);function ZG(e,n){V(n,!0);let r=e=>{var r=u(),i=B(r);E(i,()=>hn,(e,r)=>{r(e,{get value(){return C(s)},variant:`line`,class:`min-h-0 flex-1`,children:(e,r)=>{var i=YG(),c=B(i),u=e=>{jB(e,{get tabs(){return C(m)},get activeTabId(){return C(s)},onTabChange:w,get bare(){return o()}})};t(c,e=>{C(h)&&e(u)});var d=U(c,2);a(d,17,()=>C(m),e=>e.id,(e,t)=>{AG(e,{get tab(){return C(t)},get values(){return C(p)},get collapsedGroups(){return l},onToggleGroup:S,onValueChange:y,onRowPick:x,get inputs(){return n.schema.inputs},get outputs(){return n.schema.outputs},get dynamicOptions(){return C(f).options},get formModel(){return C(f)},get repeatLeads(){return C(g)},get memberLabels(){return C(v)},get memberMedia(){return C(_)},get assets(){return n.schema.assets},get bare(){return o()}})}),O(e,i)},$$slots:{default:!0}})}),O(e,r)},i=J(n,`requestedTabId`,3,null),o=J(n,`bare`,3,!1),s=Z(``),l=re({}),d,f=T(()=>d=KG(n.schema,n.values,d)),p=T(()=>({...n.values,...C(f).shown})),m=T(()=>n.schema.layout.type===`tabbed`?n.schema.layout.tabs.filter(e=>JB(e,C(p))?n.panelFilter?n.panelFilter===`right`?e.position===`right`:e.position!==`right`:!0:!1):[]),h=T(()=>C(m).length>1),g=T(()=>{let e=new Set(RF(n.schema).filter(e=>e.type===`input`).map(e=>e.paramId)),t={};for(let n of C(f).repeats){let r=n.members.find(t=>e.has(t));r&&(t[n.id]=r)}return t}),_=T(()=>{let e={};for(let t of RF(n.schema)){if(t.type!==`input`)continue;let n=t.config;n?.optionMedia&&(e[t.paramId]=n.optionMedia)}return e}),v=T(()=>{let e={};for(let t of n.schema.inputs)e[t.id]=t.nickname;for(let t of RF(n.schema))t.type===`input`&&t.displayName&&(e[t.paramId]=t.displayName);return e});function y(e,t,r){let i=Array.isArray(t)&&Array.isArray(C(f).shown[e])?BG(C(f).options[e],n.values[e],t):t;n.onValueChange(e,i,r)}function x(e,t,r){n.onValueChange(e,HG(n.values[e],t,r))}le(()=>{i()&&C(m).some(e=>e.id===i())?P(s,i()):C(m).length>0&&!C(m).some(e=>e.id===C(s))&&P(s,C(m)[0].id,!0)}),le(()=>{if(n.schema.layout.type!==`tabbed`)return;let e={};n.schema.layout.tabs.forEach(t=>t.groups.forEach(t=>{t.id in l||(e[t.id]=t.collapsed??!1)})),Object.keys(e).length>0&&Object.assign(l,e)});function S(e){l[e]=!l[e]}function w(e){P(s,e,!0)}var D=u(),k=B(D),A=e=>{r(e)},j=e=>{var t=XG(),n=L(t);r(n),c(t),O(e,t)};t(k,e=>{o()?e(A):e(j,-1)}),O(e,D),b()}var QG=D(`<span class="text-xs font-semibold"> </span>`),$G=D(`<button type="button"><!></button>`),eK=D(`<div role="button" tabindex="0"></div>`);function tK(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),o=T(()=>[`gap-1 py-2 lg:py-3 lg:flex-col lg:w-auto px-2 lg:px-0`,`flex w-full shrink-0 flex-row items-center`,`backdrop-blur-sm bg-background/90 cursor-pointer`,n.side===`left`?`lg:border-r`:`lg:border-l`,`border-border`].join(` `));var s=eK();a(s,21,()=>n.tabs,e=>e.id,(e,r)=>{var i=$G();fe(i,1,me(`w-8 h-8 rounded-md cursor-pointer flex shrink-0 items-center justify-center text-muted-foreground transition-colors hover:bg-hover hover:text-foreground`));var a=L(i),o=e=>{var n=u(),i=B(n),a=e=>{TB(e,{get icon(){return C(r).icon},class:`h-4 w-4`})},o=T(()=>C(r).icon.includes(`:`)),s=e=>{var t=QG(),n=K(t,!0);G(()=>m(n,C(r).icon)),O(e,t)};t(i,e=>{C(o)?e(a):e(s,-1)}),O(e,n)},s=e=>{var t=QG(),n=K(t,!0);G(e=>m(n,e),[()=>C(r).label[0]?.toUpperCase()??`?`]),O(e,t)};t(a,e=>{C(r).icon?e(o):e(s,-1)}),c(i),G(()=>{H(i,`title`,C(r).label),H(i,`aria-label`,C(r).label)}),f(`click`,i,e=>{e.stopPropagation(),n.onTabClick(C(r).id)}),O(e,i)}),c(s),G(e=>{fe(s,1,me(C(o)),`svelte-t5rp76`),N(s,`--collapsed-w: ${n.collapsedWidth??``}px;`),H(s,`aria-label`,e)},[()=>C(i).expandSidePanel.replace(`{side}`,n.side===`left`?C(i).panelSideLeft:C(i).panelSideRight)]),f(`click`,s,function(...e){n.onExpand?.apply(this,e)}),f(`keydown`,s,e=>(e.key===`Enter`||e.key===` `)&&n.onExpand()),O(e,s),b()}ce([`click`,`keydown`]);function nK(e,t,n){let r=[];for(let n of LF(e))for(let i of n.items??[]){if(i.type!==`input`)continue;let a=t[i.paramId],o=e.inputs.find(e=>e.id===i.paramId);$U(i,o)||a!==void 0&&o&&r.push({paramId:i.paramId,nickname:o.nickname,displayName:i.displayName||o.nickname,paramType:o.paramType,value:a,groupName:n.label})}return{id:En(),name:n.name,description:n.description,timestamp:new Date().toISOString(),schemaId:e.id,documentId:e.documentId??``,projectFileName:e.projectFileName??``,pluginVersion:e.pluginVersion??``,author:n.author,tags:n.tags??[],parameters:r}}function rK(e,t){let n=[];e.documentId!==(t.documentId??``)&&n.push({paramId:`__document__`,severity:`error`,message:`Document ID mismatch - this state was saved for a different document`,details:{expected:t.documentId??``,actual:e.documentId}}),e.schemaId!==t.id&&n.push({paramId:`__schema__`,severity:`warning`,message:`Schema has changed since this state was saved`,details:{expected:t.id,actual:e.schemaId}});for(let r of e.parameters){let e=t.inputs.find(e=>e.id===r.paramId);e?e.nickname!==r.nickname&&n.push({paramId:r.paramId,severity:`warning`,message:`Parameter nickname changed`,details:{expected:r.nickname,actual:e.nickname}}):n.push({paramId:r.paramId,severity:`error`,message:`Parameter "${r.nickname}" no longer exists in the schema`})}let r=n.some(e=>e.severity===`error`);return{isValid:n.length===0,issues:n,canLoad:!r}}function iK(e,t){let n={},r=eW(t);for(let i of e.parameters)t.inputs.some(e=>e.id===i.paramId)&&!r.has(i.paramId)&&(n[i.paramId]=i.value);return n}function aK(e,t){let n=rK(e,t);return{values:iK(e,t),issues:n.issues,isValid:n.isValid,canLoad:n.canLoad}}function oK(e){return hF(new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),`${e.name.replace(/[^a-z0-9]/gi,`_`)}_${e.timestamp.split(`T`)[0].replace(/-/g,`_`)}.slvp`)}async function sK(e){let t=JSON.parse(await e.text());if(!t.id||!t.name||!t.documentId||!t.parameters)throw Error(`Invalid saved state file format`);return t}var cK={saveMenuItem:`Save inputs…`,loadMenuItem:`Load inputs…`,saveDialogTitle:`Save inputs`,saveDialogDescription:`Save the current input values as a .slvp file`,saveNameLabel:`Name *`,saveNamePlaceholder:`e.g., Design Option A`,saveDescriptionLabel:`Description`,saveDescriptionPlaceholder:`Optional description of this state`,saveAuthorLabel:`Author`,saveAuthorPlaceholder:`Your name or email`,saveTagsLabel:`Tags`,saveTagsPlaceholder:`facade, option-a, client-approved (comma-separated)`,saveNameRequired:`Please enter a name for these inputs`,saveConfirmButton:`Save`,loadDialogTitle:`Load inputs`,loadDialogDescription:`Select a .slvp file from your drive to load`,loadFromFileButton:`Select .slvp File`,loadEmptyList:`No saved states found`,loadImportError:`Failed to import state: `,validationTitle:`State Validation Report`,validationValidatingPrefix:`Validating state: `,validationNoIssuesTitle:`No Issues Found`,validationNoIssuesBody:`This state can be loaded safely.`,validationWarningsTitle:`Warnings Detected`,validationWarningsBody:`{count} warning(s) found, but state can still be loaded.`,validationErrorsTitle:`Critical Errors`,validationErrorsBody:`Cannot load this state due to critical incompatibilities.`,validationIssuesHeading:`Issues:`,validationExpected:`Expected:`,validationActual:`Actual:`,cancelButton:`Cancel`,loadAnywayButton:`Load Anyway`},lK=D(`<!> <!>`,1),uK=D(`<!> <div class="gap-4 py-4 grid"><div class="gap-2 grid"><!> <!></div> <div class="gap-2 grid"><!> <!></div> <div class="gap-2 grid"><!> <!></div> <div class="gap-2 grid"><!> <!></div></div> <!>`,1),dK=D(`<p class="text-sm py-8 text-center text-muted-foreground">…</p>`),fK=D(`<p class="text-sm py-8 text-center text-destructive"> </p>`),pK=D(`<p class="text-sm py-8 text-center text-muted-foreground"> </p>`),mK=D(`<div class="text-xs mt-0.5 text-muted-foreground"> </div>`),hK=D(`<button type="button" class="p-3 w-full rounded-lg border text-left transition-colors hover:bg-hover"><div class="text-sm font-medium"> </div> <!> <div class="text-xs mt-1 text-muted-foreground"> </div></button>`),gK=D(`<div class="space-y-2"></div>`),_K=D(`<div class="py-4"><!></div>`),vK=D(`<!> `,1),yK=D(`<div class="py-8"><!></div>`),bK=D(`<!> <!> <!>`,1),xK=D(`<div class="gap-2 flex flex-col"><h4 class="text-sm font-medium"> </h4> <!></div>`),SK=D(`<div class="gap-4 py-4 grid"><!> <!></div>`);function CK(e,n){V(n,!0);let r=T(()=>({...cK,...n.labels})),i=Z(!1),o=Z(``),s=Z(``),l=Z(``),d=Z(``),h=Z(!1),g=Z(!1),_=Z(null),v=Z(``),y=Z(re([])),x=Z(!1),w=Z(``);function D(){P(o,`State ${new Date().toLocaleDateString()}`),P(s,``),P(l,n.schema.author||``,!0),P(d,``),P(i,!0)}async function k(){if(!C(o).trim()){Cn.error(C(r).saveNameRequired);return}let e=nK(n.schema,n.currentValues,{name:C(o).trim(),description:C(s).trim()||void 0,author:C(l).trim()||void 0,tags:C(d).split(`,`).map(e=>e.trim()).filter(e=>e.length>0)});n.onSaveState?await n.onSaveState(e):await oK(e),P(i,!1)}function A(e){let t=aK(e,n.schema);t.isValid?n.onLoadValues(t.values):(P(_,t,!0),P(v,e.name,!0),P(h,!0))}async function j(){let e=await gF({accept:`.slvp,.sps`});if(e)try{A(await sK(e))}catch(e){Cn.error(C(r).loadImportError+e.message)}}function M(){C(_)&&C(_).canLoad&&(n.onLoadValues(C(_).values),P(h,!1),P(_,null))}function N(){P(h,!1),P(_,null)}async function F(){if(P(g,!0),n.onListStates){P(x,!0),P(w,``),P(y,[],!0);try{P(y,await n.onListStates(),!0)}catch(e){P(w,e.message,!0)}finally{P(x,!1)}}}function I(){P(g,!1),j()}function ee(e){A(e),P(g,!1)}var te={openSave:D,openLoad:F},R=bK(),z=B(R);E(z,()=>pn,(e,t)=>{t(e,{get open(){return C(i)},set open(e){P(i,e,!0)},children:(e,t)=>{var n=u(),a=B(n);E(a,()=>fn,(e,t)=>{t(e,{children:(e,t)=>{var n=uK(),a=B(n);E(a,()=>un,(e,t)=>{t(e,{children:(e,t)=>{var n=lK(),i=B(n);E(i,()=>ln,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveDialogTitle)),O(e,n)},$$slots:{default:!0}})});var a=U(i,2);E(a,()=>dn,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveDialogDescription)),O(e,n)},$$slots:{default:!0}})}),O(e,n)},$$slots:{default:!0}})});var u=U(a,2),f=L(u),h=L(f);mn(h,{for:`export-name`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveNameLabel)),O(e,n)},$$slots:{default:!0}});var g=U(h,2);xn(g,{id:`export-name`,get placeholder(){return C(r).saveNamePlaceholder},get value(){return C(o)},set value(e){P(o,e,!0)}}),c(f);var _=U(f,2),v=L(_);mn(v,{for:`export-description`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveDescriptionLabel)),O(e,n)},$$slots:{default:!0}});var y=U(v,2);Sn(y,{id:`export-description`,get placeholder(){return C(r).saveDescriptionPlaceholder},rows:3,get value(){return C(s)},set value(e){P(s,e,!0)}}),c(_);var b=U(_,2),x=L(b);mn(x,{for:`export-author`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveAuthorLabel)),O(e,n)},$$slots:{default:!0}});var w=U(x,2);xn(w,{id:`export-author`,get placeholder(){return C(r).saveAuthorPlaceholder},get value(){return C(l)},set value(e){P(l,e,!0)}}),c(b);var T=U(b,2),D=L(T);mn(D,{for:`export-tags`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveTagsLabel)),O(e,n)},$$slots:{default:!0}});var A=U(D,2);xn(A,{id:`export-tags`,get placeholder(){return C(r).saveTagsPlaceholder},get value(){return C(d)},set value(e){P(d,e,!0)}}),c(T),c(u);var j=U(u,2);E(j,()=>yt,(e,t)=>{t(e,{children:(e,t)=>{var n=lK(),a=B(n);tt(a,{variant:`outline`,onclick:()=>P(i,!1),children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).cancelButton)),O(e,n)},$$slots:{default:!0}});var o=U(a,2);tt(o,{onclick:k,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveConfirmButton)),O(e,n)},$$slots:{default:!0}}),O(e,n)},$$slots:{default:!0}})}),O(e,n)},$$slots:{default:!0}})}),O(e,n)},$$slots:{default:!0}})});var ne=U(z,2);E(ne,()=>pn,(e,i)=>{i(e,{get open(){return C(g)},set open(e){P(g,e,!0)},children:(e,i)=>{var o=u(),s=B(o);E(s,()=>fn,(e,i)=>{i(e,{children:(e,i)=>{var o=bK(),s=B(o);E(s,()=>un,(e,t)=>{t(e,{children:(e,t)=>{var n=lK(),i=B(n);E(i,()=>ln,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).loadDialogTitle)),O(e,n)},$$slots:{default:!0}})});var a=U(i,2);E(a,()=>dn,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).loadDialogDescription)),O(e,n)},$$slots:{default:!0}})}),O(e,n)},$$slots:{default:!0}})});var l=U(s,2),u=e=>{var n=_K(),i=L(n),o=e=>{var t=dK();O(e,t)},s=e=>{var t=fK(),n=K(t,!0);G(()=>m(n,C(w))),O(e,t)},l=e=>{var t=pK(),n=K(t,!0);G(()=>m(n,C(r).loadEmptyList)),O(e,t)},u=e=>{var n=gK();a(n,21,()=>C(y),e=>e.id,(e,n)=>{var r=hK(),i=L(r),a=K(i,!0),o=U(i,2),s=e=>{var t=mK(),r=K(t,!0);G(()=>m(r,C(n).description)),O(e,t)};t(o,e=>{C(n).description&&e(s)});var l=U(o,2),u=K(l,!0);c(r),G(e=>{m(a,C(n).name),m(u,e)},[()=>new Date(C(n).timestamp).toLocaleString()]),f(`click`,r,()=>ee(C(n))),O(e,r)}),c(n),O(e,n)};t(i,e=>{C(x)?e(o):C(w)?e(s,1):C(y).length===0?e(l,2):e(u,-1)}),c(n),O(e,n)},d=e=>{var t=yK(),n=L(t);tt(n,{onclick:I,class:`w-full`,size:`lg`,children:(e,t)=>{var n=vK(),i=B(n);Dt(i,{class:`mr-2 h-4 w-4`});var a=U(i);G(()=>m(a,` ${C(r).loadFromFileButton??``}`)),O(e,n)},$$slots:{default:!0}}),c(t),O(e,t)};t(l,e=>{n.onListStates?e(u):e(d,-1)});var h=U(l,2);E(h,()=>yt,(e,t)=>{t(e,{children:(e,t)=>{tt(e,{variant:`outline`,onclick:()=>P(g,!1),children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).cancelButton)),O(e,n)},$$slots:{default:!0}})},$$slots:{default:!0}})}),O(e,o)},$$slots:{default:!0}})}),O(e,o)},$$slots:{default:!0}})});var ie=U(ne,2);return E(ie,()=>pn,(e,n)=>{n(e,{get open(){return C(h)},set open(e){P(h,e,!0)},children:(e,n)=>{var i=u(),a=B(i);E(a,()=>fn,(e,n)=>{n(e,{class:`max-w-2xl`,children:(e,n)=>{var i=bK(),a=B(i);E(a,()=>un,(e,n)=>{n(e,{children:(e,n)=>{var i=lK(),a=B(i);E(a,()=>ln,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).validationTitle)),O(e,n)},$$slots:{default:!0}})});var o=U(a,2);E(o,()=>dn,(e,n)=>{n(e,{children:(e,n)=>{var i=u(),a=B(i),o=e=>{var t=p();G(()=>m(t,`${C(r).validationValidatingPrefix??``}${C(v)??``}`)),O(e,t)};t(a,e=>{C(v)&&e(o)}),O(e,i)},$$slots:{default:!0}})}),O(e,i)},$$slots:{default:!0}})});var o=U(a,2),s=e=>{var n=SK(),i=L(n),a=e=>{wn(e,{tone:`success`,get title(){return C(r).validationNoIssuesTitle},children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).validationNoIssuesBody)),O(e,n)},$$slots:{default:!0}})},o=e=>{wn(e,{tone:`warning`,get title(){return C(r).validationWarningsTitle},children:(e,t)=>{S();var n=p();G(e=>m(n,e),[()=>C(r).validationWarningsBody.replace(`{count}`,String(C(_).issues.length))]),O(e,n)},$$slots:{default:!0}})},s=e=>{wn(e,{tone:`danger`,get title(){return C(r).validationErrorsTitle},children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).validationErrorsBody)),O(e,n)},$$slots:{default:!0}})};t(i,e=>{C(_).isValid?e(a):C(_).canLoad?e(o,1):e(s,-1)});var l=U(i,2),u=e=>{var t=xK(),n=L(t),i=K(n,!0),a=U(n,2);{let e=T(()=>C(_).issues.map(e=>({severity:e.severity===`error`?`error`:`warning`,message:e.message,detail:e.details?`${C(r).validationExpected} ${e.details.expected} → ${C(r).validationActual} ${e.details.actual}`:void 0})));We(a,{get issues(){return C(e)}})}c(t),G(()=>m(i,C(r).validationIssuesHeading)),O(e,t)};t(l,e=>{C(_).isValid||e(u)}),c(n),O(e,n)};t(o,e=>{C(_)&&e(s)});var l=U(o,2);E(l,()=>yt,(e,n)=>{n(e,{children:(e,n)=>{var i=lK(),a=B(i);tt(a,{variant:`outline`,onclick:N,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).cancelButton)),O(e,n)},$$slots:{default:!0}});var o=U(a,2),s=e=>{tt(e,{onclick:M,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).loadAnywayButton)),O(e,n)},$$slots:{default:!0}})};t(o,e=>{C(_)?.canLoad&&e(s)}),O(e,i)},$$slots:{default:!0}})}),O(e,i)},$$slots:{default:!0}})}),O(e,i)},$$slots:{default:!0}})}),O(e,R),b(te)}ce([`click`]);async function wK(e,t){if(!e.solvesFirst||!t)return e.onclick();let n=await t();n.status===`applied`&&await e.onclick(n)}var TK=D(`<!> `,1),EK=D(`<span class="text-xs leading-snug text-muted-foreground"> </span>`),DK=D(`<!> <span class="flex flex-col"> <!></span>`,1),OK=D(`<!> <!> <!> <!>`,1),kK=D(`<!> <!>`,1),AK=D(`<!> <span class="truncate"> </span>`,1),jK=D(`<div class="mt-3 pb-3 pt-2 px-2 gap-2 flex items-center border-t border-border"><!> <!></div>`),MK=D(`<div class="panel-footer px-1 svelte-1kczbhm"><!></div>`),NK=D(`<div class="panel-content-wrapper svelte-1kczbhm"><!> <!></div>`),PK=D(`<div class="drawer-footer svelte-1kczbhm"><!></div>`),FK=D(`<div class="my-4 gap-2 flex items-center" aria-hidden="true"><div class="h-px flex-1 bg-border"></div> <span class="text-xs font-medium px-1 text-muted-foreground"> </span> <div class="h-px flex-1 bg-border"></div></div> <!>`,1),IK=D(`<div><!></div> <div><button class="drawer-handle-bar touch-none svelte-1kczbhm"><div class="drawer-pill svelte-1kczbhm"></div> <span class="drawer-label text-sm font-medium text-foreground svelte-1kczbhm"> </span> <!></button> <div class="drawer-body svelte-1kczbhm"><div class="drawer-content svelte-1kczbhm"><div class="px-2 pb-4"><!> <!></div></div> <!></div></div>`,1),LK=D(`<div class="flex flex-1 flex-col overflow-hidden"><div class="px-3 pt-3 sm:px-5 flex-1 overflow-y-auto"><!> <!></div> <!></div>`),RK=D(`<div class="min-h-0 p-1 flex h-full flex-1 justify-center"><div class="min-h-0 flex h-full w-4/5 flex-col"><!></div></div>`),zK=D(`<div><!></div>`),BK=D(`<!> <!> <!>`,1),VK=D(`<div class="min-h-0 flex h-full flex-1"><!> <!> <!></div>`),HK=D(`<main data-layout-root=""><!></main> <!>`,1);function UK(e,n){V(n,!0);let r=e=>{var r=u(),i=B(r);E(i,()=>Ge,(e,r)=>{r(e,{children:(e,r)=>{var i=kK(),o=B(i);{let e=(e,t)=>{tt(e,q(()=>(t?.()).props,{variant:`outline`,size:`icon-lg`,class:`shrink-0`,get title(){return C(_).moreActions},get"aria-label"(){return C(_).moreActions},children:(e,t)=>{bt(e,{})},$$slots:{default:!0}}))};E(o,()=>Xe,(t,n)=>{n(t,{child:e,$$slots:{child:!0}})})}var s=U(o,2);E(s,()=>Je,(e,r)=>{r(e,{side:`top`,align:`end`,sideOffset:6,class:`min-w-56 z-10001 w-auto`,children:(e,r)=>{var i=OK(),o=B(i),s=e=>{var t=u(),n=B(t);E(n,()=>He,(e,t)=>{t(e,{onSelect:()=>C(z)?.openSave(),children:(e,t)=>{var n=TK(),r=B(n);Vn(r,{});var i=U(r);G(()=>m(i,` ${C(R).saveMenuItem??``}`)),O(e,n)},$$slots:{default:!0}})}),O(e,t)};t(o,e=>{I()&&e(s)});var l=U(o,2),d=e=>{var t=u(),n=B(t);E(n,()=>He,(e,t)=>{t(e,{onSelect:()=>C(z)?.openLoad(),children:(e,t)=>{var n=TK(),r=B(n);Dt(r,{});var i=U(r);G(()=>m(i,` ${C(R).loadMenuItem??``}`)),O(e,n)},$$slots:{default:!0}})}),O(e,t)};t(l,e=>{ee()&&e(d)});var f=U(l,2),p=e=>{var t=u(),n=B(t);E(n,()=>Ve,(e,t)=>{t(e,{})}),O(e,t)};t(f,e=>{(I()||ee())&&N().length>0&&e(p)});var h=U(f,2);a(h,17,N,e=>e.id,(e,r)=>{let i=T(()=>C(r).hint??(C(r).solvesFirst&&C(ie)?C(_).calculatesFirst:void 0));var a=u(),o=B(a);{let e=T(()=>C(r).variant??`default`);E(o,()=>He,(a,o)=>{o(a,{get disabled(){return C(r).disabled},get variant(){return C(e)},onSelect:()=>wK(C(r),n.ensureSolved),class:`items-start`,children:(e,n)=>{var a=DK(),o=B(a),s=e=>{let t=T(()=>C(r).icon);var n=u(),i=B(n);E(i,()=>C(t),(e,t)=>{t(e,{class:`mt-0.5`})}),O(e,n)};t(o,e=>{C(r).icon&&e(s)});var l=U(o,2),d=L(l),f=U(d),p=e=>{var t=EK(),n=K(t,!0);G(()=>m(n,C(i))),O(e,t)};t(f,e=>{C(i)&&e(p)}),c(l),G(()=>m(d,`${C(r).label??``} `)),O(e,a)},$$slots:{default:!0}})})}O(e,a)}),O(e,i)},$$slots:{default:!0}})}),O(e,i)},$$slots:{default:!0}})}),O(e,r)},i=(e,r=h)=>{let i=T(()=>r().hint??(r().solvesFirst&&C(ie)?C(_).calculatesFirst:void 0));{let a=T(()=>r().variant===`destructive`?`destructive`:C(ie)&&n.schema.instanceSolve===!1?`outline`:`default`),o=T(()=>r().disabled||C(ne));tt(e,{get variant(){return C(a)},size:`lg`,class:`min-w-0 shrink`,get disabled(){return C(o)},get"aria-busy"(){return C(ne)},get title(){return C(i)},onclick:async()=>{P(ne,!0);try{await wK(r(),n.ensureSolved)}finally{P(ne,!1)}},children:(e,n)=>{var i=AK(),a=B(i),o=e=>{let t=T(()=>r().icon);var n=u(),i=B(n);E(i,()=>C(t),(e,t)=>{t(e,{})}),O(e,n)};t(a,e=>{r().icon&&e(o)});var s=U(a,2),c=K(s,!0);G(()=>m(c,r().label)),O(e,i)},$$slots:{default:!0}})}},o=e=>{var a=kK(),o=B(a),s=e=>{i(e,()=>n.primaryAction)};t(o,e=>{n.primaryAction&&e(s)});var c=U(o,2),l=e=>{r(e)};t(c,e=>{C(re)&&e(l)}),O(e,a)},s=e=>{var r=kK(),i=B(r);x(i,()=>n.solveMessages??h);var a=U(i,2),s=e=>{{let t=T(()=>C(re)||n.primaryAction?o:void 0);nl(e,{get hasPendingChanges(){return k()},get hasNeverSolved(){return A()},get isSolving(){return n.isSolving},get oncalculate(){return M()},get trailing(){return C(t)}})}},l=e=>{var t=jK(),r=L(t);LR(r,{get isSolving(){return n.isSolving},get show(){return y()},get slow(){return w()},get live(){return n.live},get onabort(){return n.onabort},get freezesDuringSolve(){return D()}});var i=U(r,2);o(i),c(t),O(e,t)};t(a,e=>{n.schema.instanceSolve===!1?e(s):e(l,-1)}),O(e,r)},l=(e,r=h,i=h,a)=>{let o=pe(()=>d(a?.(),!0));var l=NK(),u=L(l),f=e=>{ZG(e,{get schema(){return n.schema},get values(){return n.values},get onValueChange(){return n.onValueChange},get panelFilter(){return r()},get requestedTabId(){return i()},get bare(){return C(ye)}})};t(u,e=>{n.schema.layout.type===`tabbed`&&e(f)});var p=U(u,2),m=e=>{var t=MK(),n=L(t);s(n),c(t),O(e,t)};t(p,e=>{C(o)&&!C(ye)&&e(m)}),c(l),O(e,l)},p=(e,t=h)=>{var n=PK(),r=L(n);s(r),c(n),G(()=>n.inert=t()),O(e,n)},g=at(),_=T(()=>g.messages),v=J(n,`meshes`,19,()=>[]),y=J(n,`showSolvingIndicator`,3,!1),w=J(n,`solveIsSlow`,3,!1),D=J(n,`freezesDuringSolve`,3,!1),k=J(n,`hasPendingChanges`,3,!1),A=J(n,`hasNeverSolved`,3,!1),j=J(n,`isViewerFullscreen`,15,!1),M=J(n,`oncalculate`,3,()=>{}),N=J(n,`panelActions`,19,()=>[]),I=J(n,`showSaveButton`,3,!0),ee=J(n,`showLoadButton`,3,!0),te=J(n,`viewerConfig`,19,()=>({})),R=T(()=>({...cK,...n.presetLabels})),z=Z(null),ne=Z(!1),re=T(()=>I()||ee()||N().length>0),ie=T(()=>k()||A()),ae=T(()=>n.schema.layout.type===`tabbed`?n.schema.layout.tabs.filter(e=>JB(e,n.values)):[]);le(()=>{if(n.schema.layout.type!==`tabbed`)return;let e={};n.schema.layout.tabs.forEach(t=>t.groups.forEach(t=>{let r=KB(t.items,n.values);t.items.forEach(t=>{if(t.type===`linebreak`)return;let{visible:i,disabled:a,defaultValue:o}=r[GB(t)],s=n.schema.inputs.find(e=>e.id===t.paramId);s&&o!==void 0&&(!i||a)&&n.values[s.id]!==o&&(e[s.id]=o)})})),Object.keys(e).length>0&&Object.assign(n.values,e)});let W=T(()=>C(ae).filter(e=>e.position!==`right`)),se=T(()=>C(ae).filter(e=>e.position===`right`)),ce=T(()=>C(W).length>0),Y=T(()=>C(se).length>0),ue=T(()=>n.showViewer||C(Y)),de=T(()=>!n.showViewer&&C(ce)&&C(Y)),X=Z(!1),me=Z(`closed`),he=[`closed`,`half`,`full`],ge=T(()=>C(W).length===1?C(W)[0].label:C(_).parametersTab),_e=Z(!1);le(()=>{let e=window.matchMedia(`(max-width: 639px)`),t=window.matchMedia(`(pointer: coarse) and (orientation: landscape) and (max-height: 500px)`);function n(){P(_e,t.matches,!0),P(X,e.matches||C(_e),!0)}return n(),e.addEventListener(`change`,n),t.addEventListener(`change`,n),()=>{e.removeEventListener(`change`,n),t.removeEventListener(`change`,n)}});let ve=Z(0),ye=T(()=>C(X)||!n.showViewer&&C(ve)>0&&C(ve)<900),be=Z(!1),xe=Z(!1),Se=Z(null),Ce=Z(null),we=Z(null),Te=Z(null),Ee=Z(null),De=Z(null),Oe=T(()=>C(de)?50:n.showViewer&&C(Y)?22:30),ke=T(()=>C(de)?50:25),Ae=T(()=>100-(C(ce)?C(Oe):0)-(C(Y)?C(ke):0)),je=T(()=>Math.round(C(Se)??C(Oe))),Me=T(()=>Math.round(100-(C(ce)?C(Se)??C(Oe):0)-(C(Ce)??C(ke)))),Ne=T(()=>`${C(ce)?`L`:``}${n.showViewer?`V`:``}${C(Y)?`R`:``}`);async function Pe(e){Object.assign(n.values,e),await n.onLoadValues?.(e)}let Fe={x:0,y:0};function Ie(e){if(C(_e)){P(me,e>0?`full`:`closed`,!0);return}let t=he.indexOf(C(me))+e;P(me,he[Math.max(0,Math.min(he.length-1,t))],!0)}function Le(e){Fe={x:e.touches[0].clientX,y:e.touches[0].clientY}}function Re(e){let t=C(_e)?e.changedTouches[0].clientX-Fe.x:e.changedTouches[0].clientY-Fe.y;Math.abs(t)>40&&(e.preventDefault(),Ie(t<0?1:-1))}function ze(){C(_e)?P(me,C(me)===`closed`?`full`:`closed`,!0):P(me,C(me)===`full`?`closed`:he[he.indexOf(C(me))+1],!0)}var Be=HK(),Ue=B(Be);let We;var Ke=L(Ue),qe=e=>{var r=u(),i=B(r),a=e=>{var r=IK(),i=B(r);let a;var o=L(i);{let e=T(()=>!C(_e)&&C(me)===`full`),t=T(()=>({...te(),backgroundColor:n.schema?.viewerOptions?.backgroundColor??te().backgroundColor,look:n.schema?.viewerOptions?.look??te().look,showSceneManager:!1}));CF(o,{get meshes(){return v()},get drawerOpen(){return C(e)},get logoUrl(){return n.logoUrl},get onViewerReady(){return n.onViewerReady},get viewerConfig(){return C(t)},get isFullscreen(){return j()},set isFullscreen(e){j(e)}})}c(i);var s=U(i,2),u=L(s),d=U(L(u),2),h=K(d,!0),g=U(d,2),y=e=>{{let t=T(()=>C(me)===`closed`?``:`rotate-180`);ct(e,{size:16,get class(){return`text-muted-foreground transition-transform duration-300 ${C(t)??``}`}})}},b=e=>{{let t=T(()=>C(me)===`full`?`rotate-180`:``);lt(e,{size:16,get class(){return`ml-auto text-muted-foreground transition-transform duration-300 ${C(t)??``}`}})}};t(g,e=>{C(_e)?e(y):e(b,-1)}),c(u);var x=U(u,2),w=L(x),E=L(w),D=L(E),k=e=>{l(e,()=>C(Y)?`left`:void 0,()=>C(Ee),()=>!1)};t(D,e=>{C(ce)&&e(k)});var A=U(D,2),M=e=>{var t=FK(),n=B(t),r=U(L(n),2),i=K(r,!0);S(2),c(n);var a=U(n,2);l(a,()=>`right`,()=>C(De),()=>!1),G(()=>m(i,C(se)[0]?.label??C(_).moreTab)),O(e,t)};t(A,e=>{C(Y)&&e(M)}),c(E),c(w);var N=U(w,2);p(N,()=>C(me)===`closed`),c(x),c(s),G(()=>{a=fe(i,1,`viewer-region svelte-1kczbhm`,null,a,{"viewer-region-raised":C(me)!==`closed`}),fe(s,1,`drawer-container z-40 bg-background shadow-sheet drawer-${C(me)??``} ${C(_e)?`rounded-l-xl border-l`:`rounded-t-xl border-t`}`,`svelte-1kczbhm`),H(u,`aria-expanded`,C(me)!==`closed`),m(h,C(ge)),w.inert=C(me)===`closed`}),f(`click`,u,ze),f(`touchstart`,u,Le,void 0,!0),f(`touchend`,u,Re),O(e,r)},o=e=>{var n=LK(),r=L(n),i=L(r),a=e=>{l(e,()=>C(Y)?`left`:void 0,()=>C(Ee),()=>!1)};t(i,e=>{C(ce)&&e(a)});var o=U(i,2),s=e=>{var t=FK(),n=B(t),r=U(L(n),2),i=K(r,!0);S(2),c(n);var a=U(n,2);l(a,()=>`right`,()=>C(De),()=>!1),G(()=>m(i,C(se)[0]?.label??C(_).moreTab)),O(e,t)};t(o,e=>{C(Y)&&e(s)}),c(r);var u=U(r,2);p(u,()=>!1),c(n),O(e,n)};t(i,e=>{C(X)&&n.showViewer?e(a):e(o,-1)}),O(e,r)},Ye=e=>{var t=RK(),n=L(t),r=L(n);l(r,()=>C(Y)?`right`:void 0,()=>C(Y)?C(De):C(Ee)),c(n),c(t),O(e,t)},Ze=e=>{var r=VK(),i=L(r),a=e=>{tK(e,{side:`left`,get tabs(){return C(W)},collapsedWidth:48,onExpand:()=>C(we)?.expand(),onTabClick:e=>{P(Ee,e,!0),C(we)?.expand()}})};t(i,e=>{C(be)&&C(ue)&&C(ce)&&e(a)});var o=U(i,2);E(o,()=>Yc,(e,r)=>{r(e,{direction:`horizontal`,get autoSaveId(){return`selva-layout-${C(Ne)??``}`},class:`min-h-0 m-1 flex-1`,children:(e,r)=>{var i=BK(),a=B(i),o=e=>{var t=kK(),n=B(t);E(n,()=>Vc,(e,t)=>{F(t(e,{order:1,get defaultSize(){return C(Oe)},minSize:15,maxSize:45,collapsible:!0,collapsedSize:0,onCollapse:()=>P(be,!0),onExpand:()=>P(be,!1),onResize:e=>P(Se,e,!0),children:(e,t)=>{var n=zK(),r=L(n);l(r,()=>C(Y)?`left`:void 0,()=>C(Ee)),c(n),G(()=>fe(n,1,`min-h-0 flex h-full flex-col ${j()||C(be)?`hidden`:``}`)),O(e,n)},$$slots:{default:!0}}),e=>P(we,e,!0),()=>C(we))});var r=U(n,2);E(r,()=>qc,(e,t)=>{t(e,{withHandle:!0,line:!1,class:`translate-x-1.5 z-20`,get"data-collapsed"(){return C(be)},get"aria-valuenow"(){return C(je)},"aria-valuemin":0,"aria-valuemax":100,onclick:()=>{C(be)&&C(we)?.expand()}})}),O(e,t)};t(a,e=>{C(ce)&&e(o)});var s=U(a,2),d=e=>{var t=u(),r=B(t);E(r,()=>Vc,(e,t)=>{t(e,{order:2,get defaultSize(){return C(Ae)},minSize:20,class:`min-h-0 flex flex-col`,children:(e,t)=>{{let t=T(()=>({...te(),backgroundColor:n.schema?.viewerOptions?.backgroundColor??te().backgroundColor,look:n.schema?.viewerOptions?.look??te().look}));CF(e,{get meshes(){return v()},get logoUrl(){return n.logoUrl},get onViewerReady(){return n.onViewerReady},get viewerConfig(){return C(t)},get isFullscreen(){return j()},set isFullscreen(e){j(e)}})}},$$slots:{default:!0}})}),O(e,t)};t(s,e=>{n.showViewer&&e(d)});var f=U(s,2),p=e=>{var r=kK(),i=B(r),a=e=>{var t=u(),n=B(t);E(n,()=>qc,(e,t)=>{t(e,{withHandle:!0,line:!1,class:`-translate-x-1.5 z-20`,get"data-collapsed"(){return C(xe)},get"aria-valuenow"(){return C(Me)},"aria-valuemin":0,"aria-valuemax":100,onclick:()=>{C(xe)&&C(Te)?.expand()}})}),O(e,t)};t(i,e=>{(n.showViewer||!C(ce))&&e(a)});var o=U(i,2);E(o,()=>Vc,(e,t)=>{F(t(e,{order:3,get defaultSize(){return C(ke)},minSize:15,maxSize:45,collapsible:!0,collapsedSize:0,onCollapse:()=>P(xe,!0),onExpand:()=>P(xe,!1),onResize:e=>P(Ce,e,!0),children:(e,t)=>{var n=zK(),r=L(n);l(r,()=>`right`,()=>C(De),()=>!C(ce)),c(n),G(()=>fe(n,1,`min-h-0 flex h-full flex-col ${j()||C(xe)?`hidden`:``}`)),O(e,n)},$$slots:{default:!0}}),e=>P(Te,e,!0),()=>C(Te))}),O(e,r)};t(f,e=>{C(Y)&&e(p)}),O(e,i)},$$slots:{default:!0}})});var s=U(o,2),d=e=>{tK(e,{side:`right`,get tabs(){return C(se)},collapsedWidth:48,onExpand:()=>C(Te)?.expand(),onTabClick:e=>{P(De,e,!0),C(Te)?.expand()}})};t(s,e=>{C(xe)&&C(Y)&&e(d)}),c(r),O(e,r)};t(Ke,e=>{C(ye)?e(qe):!n.showViewer&&!C(de)&&C(ce)!==C(Y)?e(Ye,1):e(Ze,-1)}),c(Ue);var Qe=U(Ue,2);F(CK(Qe,{get schema(){return n.schema},get currentValues(){return n.values},onLoadValues:Pe,get onSaveState(){return n.onSaveState},get onListStates(){return n.onListStates},get labels(){return n.presetLabels}}),e=>P(z,e,!0),()=>C(z)),G(()=>We=fe(Ue,1,`min-h-0 flex flex-1 flex-col overflow-hidden ${C(ye)?``:`sm:flex-row sm:py-2 ${C(be)?`sm:pl-0`:`sm:pl-2`} ${C(xe)?`sm:pr-0`:`sm:pr-2`}`}`,`svelte-1kczbhm`,We,{"fullscreen-layout":j(),relative:C(X),"mobile-root":C(ye),"side-sheet":C(X)&&C(_e)})),oe(Ue,`clientWidth`,e=>P(ve,e)),O(e,Be),b()}ce([`click`,`touchstart`,`touchend`]);function WK(e,t={}){let{SHOW_AFTER_MS:n,MIN_VISIBLE_MS:r,SLOW_AFTER_MS:i}=rl.SOLVING_INDICATOR;if(t.freezesDuringSolve)return{get show(){return e()},slow:!1};let a=Z(!1),o=Z(!1),s=0,c=null,l=null,u=null;function d(e){return e&&clearTimeout(e),null}function f(){u=null,P(a,!1),P(o,!1)}return le(()=>{let t=e();Y(()=>{if(t)u=d(u),C(a)||(c??=setTimeout(()=>{c=null,P(a,!0),s=performance.now()},n)),l??=setTimeout(()=>{l=null,P(o,!0)},i);else{if(c=d(c),l=d(l),!C(a))return;let e=r-(performance.now()-s);e>0?u??=setTimeout(f,e):f()}})}),le(()=>()=>{d(c),d(l),d(u)}),{get show(){return C(a)},get slow(){return C(o)}}}function GK(e,t,n){return QL(e,t,{...n,meshPolicy:Rj})}var KK=D(`<p class="bottom-4 text-xs fixed left-1/2 z-50 -translate-x-1/2 text-muted-foreground" data-testid="solve-esc-hint"> </p>`),qK=D(`<span class="text-xs shrink-0 text-muted-foreground tabular-nums"> </span>`),JK=D(` <kbd class="px-1 rounded-sm border border-border font-sans text-2xs opacity-70">Esc</kbd>`,1),YK=D(`<span class="shrink-0 tabular-nums"> </span>`),XK=D(`<div class="mb-1 gap-2 text-xs flex justify-between text-muted-foreground"><span class="truncate"> </span> <!></div>`),ZK=D(`<div class="h-full w-(--bar-width) rounded-full bg-primary transition-all duration-(--bar-ms) ease-linear"></div>`),QK=D(`<div class="animate-pulse h-full w-1/3 rounded-full bg-primary/60"></div>`),$K=D(`<div class="mt-2" data-testid="solve-progress"><!> <div class="h-1 overflow-hidden rounded-full bg-muted" role="progressbar"><!></div></div>`),eq=D(`<div><div><div class="gap-2 flex items-center"><!> <span class="min-w-0 text-sm flex-1 truncate"> </span> <!> <!></div> <!></div></div>`),tq=D(`<!> <!>`,1),nq=D(`<div class="mb-1.5 gap-2 flex items-center"><span> </span> <!></div>`),rq=D(`<!> `,1),iq=D(`<div class="mb-2"><div class="gap-2 text-sm font-medium flex items-center"><!></div> <p class="text-xs text-muted-foreground"> </p></div>`),aq=D(`<div><!></div>`),oq=D(`<div class="mt-3 gap-2 flex justify-end"><!></div>`),sq=D(`<div data-testid="solve-messages"><!> <!> <!></div>`),cq=D(`<div class="sr-only" role="status" aria-live="polite"> </div> <!>`,1);function lq(e,n){V(n,!0);let r=J(n,`diagnostics`,19,()=>[]),i=J(n,`freezesDuringSolve`,3,!1),o=J(n,`placement`,3,`floating`),s=J(n,`progressShownByHost`,3,!1),l=at(),d=T(()=>l.messages),f=SR(()=>n.live),h=T(()=>f.progress),g=T(()=>f.bars),_=T(()=>f.headline),v=T(()=>r().filter(e=>e.isGate)),y=T(()=>C(v).filter(e=>e.level!==`remark`)),x=T(()=>C(v).filter(e=>e.level===`remark`)),w=Z(null),E=T(()=>n.phase===`solving`?`live`:n.phase===`blocked`&&C(w)===r()?`idle`:n.phase),D=Z(!1),k=null,A=new Set,M=Z([]),F=e=>`${e.source??``}\u0000${e.message}`;le(()=>{if(C(E)===`live`){P(D,!1);return}if(k===r())return;k=r();let e=C(x).map(F).filter(e=>A.has(e)),t=C(x).filter(e=>!A.has(F(e))),n=C(E)===`idle`&&t.length>0;if(A=new Set(n?[...e,...t.map(F)]:e),!n)return;P(M,t),P(D,!0);let i=setTimeout(()=>P(D,!1),6e3);return()=>clearTimeout(i)});let I=Z(!1),ee=Z(!1),te=0;le(()=>{if(C(E)===`live`){if(P(ee,!1),i())return;let e=setTimeout(()=>{P(I,!0),te=performance.now()},300);return()=>clearTimeout(e)}if(!Y(()=>C(I))||C(E)!==`idle`){P(I,!1),P(ee,!1);return}P(ee,!0);let e=Math.max(200,400-(performance.now()-te)),t=setTimeout(()=>{P(I,!1),P(ee,!1)},e);return()=>clearTimeout(t)});let R=T(()=>C(ee)?`live`:C(E)),z=T(()=>C(R)===`live`?[...n.live.diagnostics]:C(R)===`idle`?C(M):C(y)),ne=T(()=>C(z).map(e=>({severity:e.level===`remark`?`note`:e.level,message:e.message,source:e.source}))),re=T(()=>C(R)===`review`||C(R)===`blocked`?!0:C(R)===`live`?C(I)&&(C(z).length>0||!s()&&C(h).length>0):C(z).length>0&&C(D)),ie=T(()=>C(re)?C(R)===`live`?(C(_)??C(h)[0])?.label??C(d).solveSolving:C(R)===`idle`?C(z).map(e=>e.message).join(` `):``:``);function ae(){P(w,r())}function W(e){e.key===`Escape`&&(C(E)===`live`?i()||n.onabort():C(E)===`review`?n.ondiscard():C(E)===`blocked`&&ae())}var oe=cq();j(`keydown`,de,W);var se=B(oe),ce=K(se,!0),q=U(se,2),ue=e=>{var n=u(),r=B(n),i=e=>{var t=KK(),n=K(t,!0);G(()=>m(n,C(d).solveMessagesEscHint)),O(e,t)};t(r,e=>{o()===`floating`&&e(i)}),O(e,n)},X=e=>{var r=sq(),i=L(r),l=e=>{let r=T(()=>C(_)??C(h)[0]);var i=eq(),o=L(i),s=L(o),l=L(s);_t(l,{class:`h-4 w-4 animate-spin shrink-0 text-muted-foreground`});var u=U(l,2),f=K(u,!0),p=U(u,2),v=e=>{var t=qK(),n=K(t);G(()=>m(n,`${C(r).done??``} / ${C(r).total??``}`)),O(e,t)};t(p,e=>{C(r)?.done!==void 0&&C(r)?.total!==void 0&&e(v)});var y=U(p,2);tt(y,{variant:`secondary`,size:`xs`,class:`-my-1 shrink-0`,get disabled(){return C(ee)},get onclick(){return n.onabort},"aria-keyshortcuts":`Escape`,get title(){return C(d).solveMessagesEscHint},children:(e,t)=>{S();var n=JK(),r=B(n);S(),G(()=>m(r,`${C(d).solveMessagesAbort??``} `)),O(e,n)},$$slots:{default:!0}}),c(s);var b=U(s,2);a(b,19,()=>C(h),e=>e.source??``,(e,n,r)=>{var i=$K(),a=L(i),o=e=>{var r=XK(),i=L(r),a=K(i,!0),o=U(i,2),s=e=>{var t=YK(),r=K(t);G(()=>m(r,`${C(n).done??``} / ${C(n).total??``}`)),O(e,t)};t(o,e=>{C(n).done!==void 0&&C(n).total!==void 0&&e(s)}),c(r),G(()=>m(a,C(n).label??C(n).source??``)),O(e,r)};t(a,e=>{C(r)>0&&e(o)});var s=U(a,2);H(s,`aria-valuemin`,0),H(s,`aria-valuemax`,100);var l=L(s),u=e=>{let t=T(()=>C(ee)?{width:1,ms:200}:C(g)[C(n).source??``]??{width:C(n).fraction,ms:150});var r=ZK();let i;G(()=>i=N(r,``,i,{"--bar-width":`${C(t).width*100}%`,"--bar-ms":`${C(t).ms??``}ms`})),O(e,r)},f=e=>{var t=QK();O(e,t)};t(l,e=>{C(n).fraction===void 0?e(f,-1):e(u)}),c(s),c(i),G(e=>{H(s,`aria-label`,C(n).label??C(n).source??C(d).solveSolving),H(s,`aria-valuenow`,e)},[()=>C(n).fraction===void 0?void 0:Math.round(C(n).fraction*100)]),O(e,i)}),c(o),c(i),G(()=>m(f,C(r)?.label??C(d).solveSolving)),O(e,i)},u=e=>{var r=nq(),i=L(r),a=K(i,!0),o=U(i,2),s=e=>{tt(e,{variant:`ghost`,size:`xs`,class:`-my-1 shrink-0`,onclick:ae,children:(e,t)=>{S();var n=p();G(()=>m(n,C(d).solveMessagesDismiss)),O(e,n)},$$slots:{default:!0}})},l=e=>{var t=tq(),r=B(t);tt(r,{variant:`ghost`,size:`xs`,class:`-my-1 shrink-0`,get onclick(){return n.ondiscard},children:(e,t)=>{S();var n=p();G(()=>m(n,C(d).solveMessagesDiscard)),O(e,n)},$$slots:{default:!0}});var i=U(r,2);tt(i,{size:`xs`,class:`-my-1 shrink-0`,get onclick(){return n.onconfirm},children:(e,t)=>{S();var n=p();G(()=>m(n,C(d).solveMessagesConfirm)),O(e,n)},$$slots:{default:!0}}),O(e,t)};t(o,e=>{C(R)===`blocked`?e(s):e(l,-1)}),c(r),G(()=>{fe(i,1,`min-w-0 text-xs font-medium flex-1 truncate ${C(R)===`blocked`?`text-destructive`:`text-muted-foreground`}`),m(a,C(R)===`blocked`?C(d).solveBlockedTitle:C(d).solveMessagesTitle)}),O(e,r)},f=e=>{var n=iq(),r=L(n),i=L(r),a=e=>{var t=rq(),n=B(t);Ue(n,{severity:`error`});var r=U(n);G(()=>m(r,` ${C(d).solveBlockedTitle??``}`)),O(e,t)},o=e=>{var t=rq(),n=B(t);Ue(n,{severity:`warning`});var r=U(n);G(()=>m(r,` ${C(d).solveMessagesTitle??``}`)),O(e,t)};t(i,e=>{C(R)===`blocked`?e(a):e(o,-1)}),c(r);var s=U(r,2),l=K(s,!0);c(n),G(()=>m(l,C(R)===`blocked`?C(d).solveBlocked:C(d).solveMessagesDescription)),O(e,n)};t(i,e=>{C(R)===`live`&&!s()?e(l):(C(R)===`review`||C(R)===`blocked`)&&o()===`inline`?e(u,1):(C(R)===`review`||C(R)===`blocked`)&&e(f,2)});var v=U(i,2),y=e=>{var t=aq(),n=L(t);We(n,{get issues(){return C(ne)},variant:`plain`}),c(t),G(()=>fe(t,1,`max-h-40 overflow-y-auto ${C(R)===`live`&&!s()?`mt-3 pt-3 border-t`:``}`)),O(e,t)};t(v,e=>{C(z).length>0&&e(y)});var b=U(v,2),x=e=>{var r=oq(),i=L(r),a=e=>{tt(e,{variant:`outline`,size:`sm`,onclick:ae,children:(e,t)=>{S();var n=p();G(()=>m(n,C(d).solveMessagesDismiss)),O(e,n)},$$slots:{default:!0}})},o=e=>{var t=tq(),r=B(t);tt(r,{variant:`outline`,size:`sm`,get onclick(){return n.ondiscard},children:(e,t)=>{S();var n=p();G(()=>m(n,C(d).solveMessagesDiscard)),O(e,n)},$$slots:{default:!0}});var i=U(r,2);tt(i,{size:`sm`,get onclick(){return n.onconfirm},children:(e,t)=>{S();var n=p();G(()=>m(n,C(d).solveMessagesConfirm)),O(e,n)},$$slots:{default:!0}}),O(e,t)};t(i,e=>{C(R)===`blocked`?e(a):e(o,-1)}),c(r),O(e,r)};t(b,e=>{(C(R)===`review`||C(R)===`blocked`)&&o()===`floating`&&e(x)}),c(r),G(()=>{fe(r,1,me(o()===`inline`?`px-2 py-2 border-t ${C(R)===`blocked`?`border-destructive/40`:`border-border`}`:`p-3 bottom-4 shadow-lg w-lg fixed left-1/2 z-50 max-w-screen-inset -translate-x-1/2 rounded-lg border bg-background ${C(R)===`blocked`?`border-destructive/50`:``}`)),H(r,`role`,C(R)===`review`||C(R)===`blocked`?`alert`:void 0),H(r,`data-view`,C(R))}),O(e,r)};t(q,e=>{i()&&C(R)===`live`?e(ue):C(re)&&e(X,1)}),G(()=>m(ce,C(ie))),O(e,oe),b()}function uq(e){let t=YL(e),n=Z(0);le(()=>{let e=t.subscribe(()=>{P(n,C(n)+1)});return()=>{e(),t.dispose()}});function r(e){return C(n),e()}return{get values(){return r(()=>t.values)},get error(){return r(()=>t.error)},get computeErrors(){return r(()=>t.computeErrors)},get computeWarnings(){return r(()=>t.computeWarnings)},get diagnostics(){return r(()=>t.diagnostics)},get blocked(){return r(()=>t.blocked)},get awaitingAck(){return r(()=>t.awaitingAck)},get live(){return r(()=>t.live)},get phase(){return r(()=>t.phase)},abort:()=>t.abort(),get meshes(){return r(()=>t.meshes)},get files(){return r(()=>t.files)},makeFiles:()=>t.makeFiles(),cancelFiles:()=>t.cancelFiles(),get lastResult(){return r(()=>t.lastResult)},get hasPendingChanges(){return r(()=>t.hasPendingChanges)},get hasNeverSolved(){return r(()=>t.hasNeverSolved)},get isSolving(){return r(()=>t.isSolving)},acknowledge:()=>t.acknowledge(),discard:()=>t.discard(),setValue:(e,n,r)=>t.setValue(e,n,r),solve:()=>t.solve(),ensureSolved:()=>t.ensureSolved(),onSettled:e=>t.onSettled(e),loadValues:e=>t.loadValues(e),rebuild:(e,n)=>t.rebuild(e,n),report:e=>t.report(e),reportError:e=>t.reportError(e),reportAborted:()=>t.reportAborted(),subscribe:e=>t.subscribe(e),notify:()=>t.notify(),dispose:()=>t.dispose()}}function dq(e){_(()=>{let t=s(ve);t&&e.component&&t.register(e)}),g(()=>{try{s(ve)?.unregister(e.id)}catch{}})}var fq=e=>{if(!e)return``;let t=e.replace(/^#/,``);if(!/^[0-9A-Fa-f]{6}$/.test(t))return e;let n=parseInt(t.slice(0,2),16)/255,r=parseInt(t.slice(2,4),16)/255,i=parseInt(t.slice(4,6),16)/255,a=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,o=a(n),s=a(r),c=a(i),l=o*.4124564+s*.3575761+c*.1804375,u=o*.2126729+s*.7151522+c*.072175,d=o*.0193339+s*.119192+c*.9503041,f=Math.cbrt(.8189330101*l+.3618667424*u-.1288597137*d),p=Math.cbrt(.0329845436*l+.9293118715*u+.0361456387*d),m=Math.cbrt(.0482003018*l+.2643662691*u+.633851707*d),h=.2104542553*f+.793617785*p-.0040720468*m,g=1.9779984951*f-2.428592205*p+.4505937099*m,_=.0259040371*f+.7827717662*p-.808675766*m,v=Math.sqrt(g*g+_*_),y=Math.atan2(_,g)*180/Math.PI;return y<0&&(y+=360),`oklch(${h.toFixed(3)} ${v.toFixed(3)} ${y.toFixed(1)})`},pq={1:.0254,2:.3048,3:1609.344,4:.001,5:.01,6:1,7:1e3,8:2.54e-8,9:254e-7,10:.9144,11:1e-10,12:1e-9,13:1e-6,14:.1,15:10,16:100,17:1e9},mq=1,hq=8,gq=80,_q=16;function vq(e){let t=e.split(/\r\n|\r|\n/),n=[];for(let e=0;e+1<t.length;e+=2){let r=Number.parseInt(t[e],10);Number.isNaN(r)||n.push({code:r,value:t[e+1].trim()})}return n}var yq=(e,t)=>e.filter(e=>e.code===t).map(e=>Number.parseFloat(e.value)),bq=(e,t,n=0)=>{let r=yq(e,t)[0];return Number.isFinite(r)?r:n},xq=(e,t)=>[bq(e,t),bq(e,t+10),bq(e,t+20)];function Sq(e){let t=kH([bq(e,210),bq(e,220),bq(e,230,1)])??[0,0,1],n=kH(DH(Math.abs(t[0])<1/64&&Math.abs(t[1])<1/64?[0,1,0]:[0,0,1],t))??[1,0,0];return{x:n,y:DH(t,n),normal:t}}var Cq=(e,[t,n,r])=>wH(wH(EH(e.x,t),EH(e.y,n)),EH(e.normal,r));function wq(e,t,n){if(e.length<2)return null;let r=e.map(e=>e.point);if(!e.some((e,n)=>e.bulge!==0&&(t||n<r.length-1)))return{kind:`polyline`,points:r,closed:t&&r.length>2};let i=[],a=t?r.length:r.length-1;for(let t=0;t<a;t++)i.push(...XH(r[t],r[(t+1)%r.length],e[t].bulge,n));return ZH(i)}function Tq(e){let t=Sq(e),n=bq(e,38),r=[];for(let{code:t,value:n}of e){let e=Number.parseFloat(n);t===10?r.push({x:e,y:0,bulge:0}):t===20&&r.length?r[r.length-1].y=e:t===42&&r.length&&(r[r.length-1].bulge=e)}return wq(r.map(e=>({point:Cq(t,[e.x,e.y,n]),bulge:e.bulge})),(bq(e,70)&mq)!==0,t.normal)}function Eq(e,t){let n=bq(e,70);if(n&gq)return null;let r=(n&hq)!==0,i=Sq(e),a=bq(e,30);return wq(t.filter(e=>(bq(e,70)&_q)===0).map(e=>({point:r?xq(e,10):Cq(i,[bq(e,10),bq(e,20),a]),bulge:r?0:bq(e,42)})),(n&mq)!==0,i.normal)}function Dq(e){let t=yq(e,10),n=yq(e,20),r=yq(e,30),i=t.map((e,t)=>[e,n[t]??0,r[t]??0]),a=bq(e,71,3);if(i.length<a+1||a<1)return null;let o=yq(e,40);o.length!==i.length+a+1&&(o=AH(i.length,a));let s=yq(e,41),c=s.length===i.length&&s.some(e=>e!==1);return{kind:`nurbs`,degree:a,points:i,knots:o,...c?{weights:s}:{}}}function Oq(e,t){let n=Sq(e),r=bq(e,40);if(!(r>0))return null;let i=t?0:bq(e,50)*Math.PI/180,a=t?2*Math.PI:bq(e,51)*Math.PI/180-i;for(;a<=0;)a+=2*Math.PI;return QH(Cq(n,xq(e,10)),n.x,n.y,r,i,a)}function kq(e){if(e.startsWith(`AutoCAD Binary DXF`))throw Error(`Binary DXF is not supported: save the file as ASCII DXF.`);let t=vq(e),n={items:[],metersPerUnit:null,skipped:{}},r=e=>{n.skipped[e]=(n.skipped[e]??0)+1},i=(e,t)=>{t&&VH(t)?n.items.push(t):r(e)},a=``,o=0,s=()=>{let e=o++;for(;o<t.length&&t[o].code!==0;)o++;return t.slice(e,o)};for(;o<t.length;){let e=t[o];if(e.code===9&&e.value===`$INSUNITS`&&a===`HEADER`){n.metersPerUnit=pq[Number.parseInt(t[o+1]?.value??``,10)]??null,o++;continue}if(e.code!==0){o++;continue}if(e.value===`SECTION`){a=t[o+1]?.code===2?t[o+1].value:``,o+=2;continue}if(e.value===`ENDSEC`){a=``,o++;continue}if(a!==`ENTITIES`){o++;continue}let c=s(),l=c[0].value;switch(l){case`POINT`:i(l,{kind:`point`,at:xq(c,10)});break;case`LINE`:i(l,{kind:`line`,from:xq(c,10),to:xq(c,11)});break;case`LWPOLYLINE`:i(l,Tq(c));break;case`POLYLINE`:{let e=[];for(;o<t.length&&t[o].value===`VERTEX`;)e.push(s());t[o]?.value===`SEQEND`&&s(),i(l,Eq(c,e));break}case`SPLINE`:i(l,Dq(c));break;case`ARC`:i(l,Oq(c,!1));break;case`CIRCLE`:i(l,Oq(c,!0));break;default:r(l)}}return n}var Aq=e=>[e[0],e[1],e[2]],jq=e=>[e[0],e[1],e[2]];function Mq(e){return typeof e==`object`&&!!e&&typeof e.data==`string`&&`archive3dm`in e}function Nq(e,t){if(t.kind===`line`)return new e.LineCurve(jq(t.from),jq(t.to));if(t.kind===`polyline`){let n=t.points.map(jq);return t.closed&&n.push(jq(t.points[0])),new e.PolylineCurve(n)}let{degree:n,points:r,weights:i,knots:a}=t,o=new e.NurbsCurve(3,i!==void 0,n+1,r.length),s=o.points();r.forEach((e,t)=>{let n=i?.[t]??1;s.set(t,[e[0]*n,e[1]*n,e[2]*n,n])});let c=o.knots();for(let e=1;e<a.length-1;e++)c.set(e-1,a[e]);return o}function Pq(e,t){if(!VH(t))throw Error(`Cannot encode an invalid ${t.kind}.`);let n=t.kind===`point`?new e.Point(jq(t.at)):Nq(e,t);try{for(let[e,r]of Object.entries(t.attributes??{}))n.setUserString(e,r);return n.encode()}finally{n.delete()}}var Fq=([e,t,n])=>({X:e,Y:t,Z:n});function Iq(e){return Fq(e.at)}function Lq(e){return{From:Fq(e.from),To:Fq(e.to)}}var Rq=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2];function zq(e){let t=e.order-1,n=e.points(),r=[],i=[];for(let e=0;e<n.count;e++){let[t,a,o,s]=n.get(e);r.push([t/s,a/s,o/s]),i.push(s)}if(t===1){let e=r.length>3&&Rq(r[0],r[r.length-1]);return{kind:`polyline`,points:e?r.slice(0,-1):r,closed:e}}let a=e.knots(),o={kind:`nurbs`,degree:t,points:r,knots:[a.superfluousKnot(!0),...a.toList(),a.superfluousKnot(!1)]};return e.isRational?{...o,weights:i}:o}function Bq(e,t){if(t instanceof e.LineCurve){let{from:e,to:n}=t.line;return{kind:`line`,from:Aq(e),to:Aq(n)}}if(t instanceof e.PolylineCurve){let e=[];for(let n=0;n<t.pointCount;n++)e.push(Aq(t.point(n)));let n=e.length>3&&Rq(e[0],e[e.length-1]);return{kind:`polyline`,points:n?e.slice(0,-1):e,closed:n}}if(t instanceof e.NurbsCurve)return zq(t);let n=t.toNurbsCurve();if(!n)return null;try{return zq(n)}finally{n.delete()}}function Vq(e,t){let n=null;if(t instanceof e.Point?n={kind:`point`,at:Aq(t.location)}:t instanceof e.Curve&&(n=Bq(e,t)),!n||!VH(n))return null;let r=t.getUserStrings();return r.length>0?{...n,attributes:Object.fromEntries(r)}:n}function Hq(e,t){let n;try{n=e.CommonObject.decode(t)}catch{return null}if(!n)return null;try{return Vq(e,n)}finally{n.delete?.()}}var Uq=e=>{let{X:t,Y:n,Z:r}=e??{};return[t,n,r].every(e=>typeof e==`number`&&Number.isFinite(e))?[t,n,r]:null};function Wq(e){let t=Uq(e);return t?{kind:`point`,at:t}:null}function Gq(e){let{From:t,To:n}=e??{},r=Uq(t),i=Uq(n),a=r&&i?{kind:`line`,from:r,to:i}:null;return a&&HH(a)?a:null}function Kq(e,t){let n=e.UnitSystem;return[[n.Angstroms,1e-10],[n.Nanometers,1e-9],[n.Microns,1e-6],[n.Millimeters,.001],[n.Centimeters,.01],[n.Decimeters,.1],[n.Meters,1],[n.Dekameters,10],[n.Hectometers,100],[n.Kilometers,1e3],[n.Megameters,1e6],[n.Gigameters,1e9],[n.Microinches,2.54e-8],[n.Mils,254e-7],[n.Inches,.0254],[n.Feet,.3048],[n.Yards,.9144],[n.Miles,1609.344],[n.NauticalMiles,1852]].find(([e])=>e===t)?.[1]??null}function qq(e,t){let n=e.File3dm.fromByteArray(t);if(!n)throw Error(`Not a readable .3dm file.`);try{let t={items:[],metersPerUnit:Kq(e,n.settings().modelUnitSystem),skipped:0},r=n.objects();for(let n=0;n<r.count;n++){let i=Vq(e,r.get(n).geometry());i?t.items.push(i):t.skipped++}return t}finally{n.delete()}}async function Jq(e,t){let n=e.name.slice(e.name.lastIndexOf(`.`)).toLowerCase();if(!(n===`.dxf`||n===`.3dm`&&t!==null))throw new yU(`unsupported`);try{if(n===`.3dm`&&t)return qq(await t(),new Uint8Array(await e.arrayBuffer()));let r=kq(await e.text());return{...r,skipped:Object.values(r.skipped).reduce((e,t)=>e+t,0)}}catch{throw new yU(`unreadable`)}}async function Yq(e,t,n){let{items:r,metersPerUnit:i,skipped:a}=await Jq(e,n);if(r.length>2e3)throw new yU(`tooMany`);let o=i===null?1:i/t;return{items:r.map(e=>BH(e,o)),skipped:a}}var Xq=e=>{if(e==null||e===``)return[];if(typeof e==`string`){let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return[];try{return Xq(JSON.parse(t))}catch{return[]}}return Array.isArray(e)?e.flatMap(Xq):typeof e==`object`?[e]:[]},Zq=e=>!e||e.length===1&&e[0]===0;function Qq(e){if(typeof e==`string`){let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return[];try{return Qq(JSON.parse(t))}catch{return[]}}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=Object.entries(e).map(([e,t])=>[PH(e),t]);if(t.length>0&&t.every(([e])=>e!==null))return t.map(([e,t])=>({path:Zq(e)?void 0:e,items:Xq(t)}))}let t=Xq(e);return t.length>0?[{path:void 0,items:t}]:[]}function $q(e){return Qq(e).some(e=>e.items.some(Mq))}function eJ(e,t){let n=[];for(let{path:r,items:i}of Qq(e))for(let e of i){let i=Mq(e)?t&&Hq(t,e):Gq(e)??Wq(e);i&&n.push(r?{...i,path:r}:i)}return n}function tJ(e,t,n){let r,i;if(t===`line`)r=UH(e),i=e=>Lq(e);else if(t===`point`)r=e.filter(SH),i=e=>Iq(e);else{if(!n)return null;r=e,i=e=>Pq(n,e)}return r.length===0?null:r.every(e=>Zq(e.path))?r.map(i):Object.fromEntries([...FH(r)].map(([e,t])=>[e,t.map(i)]))}var nJ={Microns:`µm`,Millimeters:`mm`,Centimeters:`cm`,Decimeters:`dm`,Meters:`m`,Kilometers:`km`,Inches:`in`,Feet:`ft`,Yards:`yd`,Miles:`mi`};function rJ(e){let t=e?xP[e]:void 0;return t===void 0?null:{metersPerUnit:t,suffix:nJ[e]??``}}var iJ={mode:null,pendingPoints:0,typed:``,canUndo:!1,canRedo:!1},aJ=class{#e=Z([]);get items(){return C(this.#e)}set items(e){P(this.#e,e)}#t=Z(iJ);get state(){return C(this.#t)}set state(e){P(this.#t,e)}tool=null;synced=void 0;revision=0};function oJ(e,t){return t.paramType===`line`?UH(e):e.filter(e=>SH(e)&&t.kinds.includes(`point`)||CH(e)&&t.kinds.includes(`curve`))}function sJ(e){let t=Z(null),n=Z(0),r=Z(!0),i=T(()=>e.modelUnits()),a=T(()=>rJ(C(i))),o=new Map,s=e=>{let t=o.get(e);return t||o.set(e,t=new aJ),t},c=t=>e.inputs().find(e=>e.id===t),l=e.loadRhino,u=null,d=l?()=>(u??=l(),u.catch(()=>{u=null}),u):null;function f(t,n){let r=++n.revision,i=i=>{n.revision===r&&(n.synced=i,e.setValue(t.id,i))};t.paramType!==`geometry`||n.items.length===0?i(tJ(n.items,t.paramType,null)):d&&d().then(e=>i(tJ(n.items,t.paramType,e)),()=>e.onEncodeError?.())}function p(e,t){e.synced=t;let n=++e.revision,r=t=>{e.revision===n&&(e.items=t,e.tool?.setItems(t))};!d||!$q(t)?r(eJ(t,null)):d().then(e=>r(eJ(t,e)),()=>r([]))}function m(e,t){let n=s(e.id);n.tool?.cancel(),n.items=t,n.tool?.setItems(t),f(e,n)}function h(){for(let e of o.values())e.tool?.dispose(),e.tool=null,e.state=iJ}function g(){if(h(),C(t)&&C(a))for(let i of e.inputs()){let e=s(i.id);e.tool=_U({viewer:C(t),id:i.id,metersPerUnit:C(a).metersPerUnit,unitSuffix:C(a).suffix,name:i.name,maxItems:i.atMost,settings:{gridStep:C(n),showDimensions:C(r)},onChange:t=>{e.items=t,f(i,e)},onStateChange:t=>{e.state=t}}),e.tool.setItems(e.items)}}le(()=>(C(a),e.inputs(),Y(g),h)),le(()=>{let e={gridStep:C(n),showDimensions:C(r)};for(let t of o.values())t.tool?.configure(e)}),le(()=>{for(let t of e.inputs()){let n=s(t.id),r=e.getValue(t.id);r!==n.synced&&Y(()=>p(n,r))}});let _=e=>{let t=c(e);return!t||t.kinds.length===0?!1:t.paramType!==`geometry`||d!==null};return{get canDraw(){return C(t)!==null&&C(a)!==null},get canImport(){return C(a)!==null},get unitSuffix(){return C(a)?.suffix??``},get importAccept(){return d?`.dxf,.3dm`:`.dxf`},get gridStep(){return C(n)},set gridStep(e){P(n,Number.isFinite(e)&&e>0?e:0,!0)},get showDimensions(){return C(r)},set showDimensions(e){P(r,e,!0)},supports:_,kinds:e=>c(e)?.kinds??[],view:e=>s(e),getItems:e=>s(e).items,setItems:(e,t)=>{let n=c(e);n&&_(e)&&m(n,oJ(t,n).slice(0,n.atMost))},draw:(e,t)=>{c(e)?.paramType===`geometry`&&d?.().catch(()=>{}),s(e).tool?.draw(t)},move:e=>s(e).tool?.move(),finish:e=>s(e).tool?.finish(),undo:e=>s(e).tool?.undo(),redo:e=>s(e).tool?.redo(),reset:t=>{s(t).tool?.cancel(),e.setValue(t,e.getDefault(t)??null)},importFile:async(e,t)=>{let n=c(e);if(!n||!C(a))throw Error(`The input is not ready for an import.`);let r=await Yq(t,C(a).metersPerUnit,d),i=oJ(r.items,n),o=i.slice(0,n.atMost);return m(n,o),{items:[...o],skipped:r.skipped+(n.paramType===`line`?0:r.items.length-i.length),overLimit:i.length-o.length}},attachViewer:e=>(P(t,e),g(),()=>{C(t)===e&&(h(),P(t,null))})}}var cJ=D(`<div class="min-h-100 p-8 flex items-center justify-center"><!></div>`),lJ=D(`<div class="min-h-100 flex items-center justify-center"><!></div>`),uJ=D(`<div class="contents"><!></div> <!>`,1);function dJ(e,n){V(n,!0);let r=J(n,`definitionKey`,3,``),i=J(n,`showModeToggle`,3,!1),a=J(n,`panelActions`,19,()=>[]),o=J(n,`showSaveButton`,3,!0),s=J(n,`showLoadButton`,3,!0),l=J(n,`footerItemId`,3,`footer-item`),d=J(n,`footerItemPriority`,3,0),f=J(n,`viewerConfig`,19,()=>({}));FU(n.clientSlot);let p=rt(()=>n.lang,()=>n.messages),m=T(()=>p.messages),h=T(()=>n.externalScopeKey||r()||n.schema?.id||``),g=GK(n.onSolve,()=>_,{solveDeadlineMs:n.solveDeadlineMs,onChange:()=>_.notify(),events:n.events,timeoutMessage:e=>nt(C(m).solveTimedOut,{seconds:e})}),_=uq({schema:n.schema,scopeKey:n.externalScopeKey||r()||n.schema?.id||``,driver:g});qW({get files(){return _.files},get isSolving(){return _.isSolving},make:()=>_.makeFiles(),cancel:()=>_.cancelFiles()});let v=T(()=>(n.schema?.inputs??[]).flatMap(e=>{let t=YU(e);return t.length>0?[{id:e.id,paramType:e.paramType,kinds:t,name:e.nickname,atMost:e.atMost}]:[]})),y=sJ({loadRhino:n.loadRhino,inputs:()=>C(v),getValue:e=>_.values[e],setValue:(e,t)=>_.setValue(e,t),getDefault:e=>n.schema?.inputs.find(t=>t.id===e)?.default,modelUnits:()=>_.lastResult?.source?.modelunits,onEncodeError:()=>Cn.error(C(m).curveEncodeFailed)});VU(y);function x(e){let t=y.attachViewer(e),r=n.onViewerReady?.(e);return()=>{r?.(),t()}}let S=Z(!1),w=WK(()=>_.isSolving);le(()=>_.onSettled(e=>n.onSolved?.(e))),le(()=>{n.onReady?.({loadValues:e=>_.loadValues(e),getLastResult:()=>_.lastResult,getSession:()=>_,getSketch:()=>y})});let E=Z(``),D=Z(!0);le(()=>{r(),Y(()=>{C(D)?(P(D,!1),P(E,r()),n.schema?.instanceSolve!==!1&&_.solve()):C(E)!==r()&&(_.rebuild(n.schema,C(h)),P(E,r()))})});function k(e,t,n=!1){_.setValue(e,t,n)}function A(){_.solve()}dq({id:Y(()=>l()),component:Y(()=>n.footerComponent),getProps:()=>n.footerComponentProps?.()??{},position:`left`,priority:Y(()=>d())});let j=T(()=>n.isEmbedded??Pe.url.searchParams.get(`embed`)===`true`),M=T(()=>n.primaryColor??Pe.url.searchParams.get(`primary`)),F=T(()=>C(M)?fq(C(M)):void 0),I=T(()=>n.title??(n.schema?.description||n.schema.name)),ee=T(()=>_.error?[{level:`error`,message:_.error},..._.diagnostics]:_.diagnostics);var te=uJ(),R=B(te);let z;var ne=L(R);{let e=T(()=>!C(j));Ke(ne,{mode:`fixed`,get showHeader(){return C(e)},showFooter:!0,get title(){return C(I)},get showModeToggle(){return i()},get navItems(){return n.navItems},get homeUrl(){return n.homeUrl},get brandName(){return n.brandName},get copyrightName(){return n.copyrightName},get footerText(){return n.footerText},get header(){return n.header},get rightContent(){return n.headerRight},get errors(){return _.computeErrors},get warnings(){return _.computeWarnings},get diagnostics(){return C(ee)},children:(e,i)=>{var l=u(),d=B(l),p=e=>{var t=cJ();Zc(L(t),{type:`error`,size:`medium`,get message(){return _.error}}),c(t),O(e,t)},h=e=>{var t=lJ();Zc(L(t),{type:`loading`,size:`large`,get message(){return C(m).loadingSchema}}),c(t),O(e,t)},g=e=>{var t=u(),i=B(t);ae(i,r,e=>{{let t=T(()=>!!n.schema.viewerOptions?.enableRemote);UK(e,{get schema(){return n.schema},get showViewer(){return C(t)},get meshes(){return _.meshes},get isSolving(){return _.isSolving},get showSolvingIndicator(){return w.show},get solveIsSlow(){return w.slow},get live(){return _.live},onabort:()=>_.abort(),get hasPendingChanges(){return _.hasPendingChanges},get hasNeverSolved(){return _.hasNeverSolved},get values(){return _.values},get logoUrl(){return n.logo},onViewerReady:x,get viewerConfig(){return f()},get panelActions(){return a()},get primaryAction(){return n.primaryAction},get showSaveButton(){return o()},get showLoadButton(){return s()},get onSaveState(){return n.onSaveState},get onListStates(){return n.onListStates},get presetLabels(){return n.presetLabels},onValueChange:k,oncalculate:A,ensureSolved:()=>_.ensureSolved(),onLoadValues:()=>_.loadValues({}),get isViewerFullscreen(){return C(S)},set isViewerFullscreen(e){P(S,e,!0)}})}}),O(e,t)};t(d,e=>{_.error&&!n.schema?e(p):n.schema?e(g,-1):e(h,1)}),O(e,l)},$$slots:{default:!0}})}c(R);var re=U(R,2);{let e=T(()=>n.schema?.instanceSolve!==!1);lq(re,{get live(){return _.live},get phase(){return _.phase},get diagnostics(){return _.diagnostics},onabort:()=>_.abort(),onconfirm:()=>_.acknowledge(),ondiscard:()=>_.discard(),get progressShownByHost(){return C(e)}})}G(()=>z=N(R,``,z,{"--primary":C(F)})),O(e,te),b()}var fJ=`selva:saved-values`,pJ=[2e3,4e3,8e3,15e3,3e4,3e4,3e4];function mJ(e,t,n){let r=new Map(e.inputs.map(e=>[e.id,e])),i={};for(let e of t.inputs){let t=r.get(e.id);if(!t||!(e.id in n)||e.default===void 0||hJ(e.default,t.default))continue;let a=t.default??BF(t.paramType);hJ(n[e.id],a)&&(i[e.id]=e.default)}return i}function hJ(e,t){return JSON.stringify(e)===JSON.stringify(t)}var gJ=D(`<div class="text-muted-foreground flex items-center gap-1.5 text-xs"><!> <span> </span></div>`);function _J(e,n){var r=u(),i=B(r),a=e=>{var t=gJ(),r=L(t);It(r,{class:`h-3 w-3`});var i=U(r,2),a=K(i,!0);c(t),G(()=>m(a,n.label)),O(e,t)};t(i,e=>{n.label&&e(a)}),O(e,r)}async function vJ(){let[{default:t},{default:n}]=await Promise.all([e(()=>import(`./71J-lVIC.js`),__vite__mapDeps([0,1]),import.meta.url),e(()=>import(`./B_4x1b7P.js`),[],import.meta.url)]);return t({locateFile:()=>n})}var yJ=D(`<span class="bg-warning/15 text-warning shrink-0 rounded-full px-2.5 py-1 font-mono text-[11px] font-medium tracking-wide whitespace-nowrap uppercase"> <span class="hidden sm:inline">preview</span></span>`),bJ=D(`<span class="bg-warning/15 text-warning shrink-0 rounded-full px-2.5 py-1 font-mono text-[11px] font-medium tracking-wide whitespace-nowrap uppercase">Draft<span class="hidden sm:inline">preview</span></span>`),xJ=D(`<!> <!>`,1);function SJ(e,n){V(n,!0);let r=T(()=>Pe.data),i=T(()=>!!C(r).user);function a(){return!!n.data.schema.viewerOptions?.enableRemote}let o=Y(()=>C(i)&&!n.data.shareToken)?nR({endpoint:`/api/v1/solve-events`,cancelEndpoint:e=>`/api/v1/solve/${e}/cancel`}):null;le(()=>()=>o?.close());let s=xR({endpoint:`/api/v1/compute`,definitionUrl:()=>n.data.ghDefinition,inputs:()=>n.data.schema.inputs,outputs:()=>n.data.schema.outputs,channel:()=>n.data.channel===`draft`?`draft`:void 0,versionId:()=>n.data.versionId,streamId:()=>o?.streamId??null,bearerToken:()=>n.data.shareToken,keepalive:!0,meshes:a()?{extract:(e,t)=>EP(e,t)}:void 0,debug:!0}),l,d=T(()=>{let e=JSON.stringify(n.data.schema);return l?.json!==e&&(l={json:e,schema:n.data.schema}),l.schema}),f;function p(e){f=e}let h=`saved-values`;le(()=>(n.data.currentDefinition,n.data.channel,n.data.versionId,Y(g)));function g(){if(!n.data.defaultsPending)return;let e=C(d),t=0,r,i=!1;Cn.loading(`Reading the values saved in the file`,{id:h,description:`The form shows stored defaults until they arrive.`,duration:1/0});async function a(){if(await Ne(fJ,!0).catch(()=>{}),!i){if(n.data.defaultsPending)t+=1,t>=pJ.length?Cn.warning(`Saved values not loaded`,{id:h,description:`Rhino.Compute did not answer in time. The form shows stored defaults. Reload the page to try again.`,duration:1/0}):r=setTimeout(a,pJ[t]);else{let t=f?mJ(e,n.data.schema,f.getSession().values):{};if(Object.keys(t).length===0){Cn.dismiss(h);return}f?.loadValues(t),Cn.success(`Saved values loaded`,{id:h,description:`Inputs you had not changed were updated.`,duration:5e3})}}}return r=setTimeout(a,pJ[0]),()=>{i=!0,clearTimeout(r),Cn.dismiss(h)}}{let a=e=>{var n=u(),r=B(n),a=e=>{ze(e,{})};t(r,e=>{C(i)&&e(a)}),O(e,n)},l=e=>{var a=xJ(),o=B(a),s=e=>{var t=yJ(),r=L(t);S(),c(t),G(()=>m(r,`v${n.data.versionNumber??``}`)),O(e,t)},l=e=>{var t=bJ();O(e,t)};t(o,e=>{n.data.versionId?e(s):n.data.channel===`draft`&&e(l,1)});var u=U(o,2),d=e=>{var t=xJ(),n=B(t);qe(n,{});var i=U(n,2);{let e=T(()=>C(r).user?.platformPermissions??[]),t=T(()=>C(r).ctx?.orgPermissions??[]),n=T(()=>C(r).ctx?.mayHoldApiTokens);Ye(i,{get platformPermissions(){return C(e)},get orgPermissions(){return C(t)},get mayHoldApiTokens(){return C(n)}})}O(e,t)};t(u,e=>{C(i)&&e(d)}),O(e,a)},f=T(()=>n.data.schema?.name||n.data.schema.description),h=T(()=>n.data.orgLogoUrl??void 0),g=T(()=>C(r).branding?.name),_=T(()=>o??void 0);dJ(e,{get schema(){return C(d)},onReady:p,get onSolve(){return s},get definitionKey(){return n.data.currentDefinition},get title(){return C(f)},get logo(){return C(h)},showModeToggle:!0,get brandName(){return C(g)},homeUrl:`/`,get solveDeadlineMs(){return n.data.solveDeadlineMs},get events(){return C(_)},get loadRhino(){return vJ},get footerComponent(){return _J},footerComponentProps:()=>({label:n.data.serverLabel}),navItems:a,headerRight:l,$$slots:{navItems:!0,headerRight:!0}})}b()}export{xj as a,bj as i,vj as n,Tj as o,yj as r,kj as s,SJ as t};
|
|
6085
|
+
${C(te)?`bg-(--image-bg)`:`checkerboard`}`,`svelte-a62aei`),l=N(o,``,l,{"--image-bg":C(te)}),fe(b,1,`px-2.5 py-1 text-xs bottom-2 pointer-events-none absolute left-1/2 -translate-x-1/2 rounded-sm bg-foreground text-background transition-opacity ${C(Ne)?`opacity-100`:`opacity-0`}`),m(S,C(i).zoomHint),m(V,`${C(x).fileName??``}${C(x).fileType??``}`),X.disabled=!C(de)||C(q)<=C(pe)+.001,H(X,`title`,`${C(i).zoomOut??``} (−)`),H(X,`aria-label`,C(i).zoomOut),m(ye,`${C(ge)??``}%`),be.disabled=!C(de)||C(q)>=C(he)-.001,H(be,`title`,`${C(i).zoomIn??``} (+)`),H(be,`aria-label`,C(i).zoomIn),we.disabled=!C(de)||C(ue),H(we,`title`,`${C(i).zoomFit??``} (0)`),H(we,`aria-label`,C(i).zoomFit),Te.disabled=e,H(Te,`title`,`${C(i).zoomActual??``} (1)`),H(Te,`aria-label`,C(i).zoomActual)},[()=>!C(de)||Math.abs(C(q)-1)<.001]),f(`pointerdown`,o,ke),f(`pointermove`,o,Ae),f(`pointerup`,o,je),j(`pointercancel`,o,je),f(`dblclick`,o,Me),f(`keydown`,o,Fe),f(`click`,X,()=>Se(C(q)/s)),f(`click`,be,()=>Se(C(q)*s)),f(`click`,we,xe),f(`click`,Te,()=>Se(1)),O(e,r)};t(u,e=>{C(B)?e(d):C(g)?e(p,1):C(x)&&e(_,2)}),c(r),F(r,e=>P(ne,e),()=>C(ne)),G(()=>fe(r,1,`flex flex-col overflow-hidden rounded-lg border border-border-strong bg-background ${C(R)?`h-dvh`:``}`)),O(e,r)},We=e=>{var t=KW(),n=K(t,!0);G(()=>m(n,C(i).waitingForData)),O(e,t)};t(He,e=>{C(B)||C(g)||C(x)?e(Ue):e(We,-1)}),O(e,Ve),b()}ce([`pointerdown`,`pointermove`,`pointerup`,`dblclick`,`keydown`,`click`]);var JW=Symbol(`deferred-files-context`);function YW(e){n(JW,e)}function XW(){return s(JW)}var ZW=D(`<span> </span>`),QW=D(`<div class="gap-2 flex items-center"><!> <!></div>`),$W=D(`<span class="text-muted-foreground not-italic"> </span>`),eG=D(`<div class="ml-4 pl-2 border-l border-border-strong"><!></div>`),tG=D(`<div><button class="gap-1.5 py-0.5 text-xs flex w-full items-center text-muted-foreground transition-colors hover:text-foreground"><!> <!> <span class="font-medium"> </span></button> <!></div>`),nG=D(`<div class="gap-1.5 py-0.5 flex items-center justify-between"><div class="gap-1.5 min-w-0 flex items-center"><!> <span class="text-xs truncate text-foreground"> </span></div> <span class="text-xs shrink-0 text-muted-foreground"> </span></div>`),rG=D(`<div class="gap-2 flex flex-col"><div class="px-3 py-3 text-sm rounded-md border border-border-strong bg-muted text-muted-foreground"> </div> <!></div>`),iG=D(`<div class="gap-2 flex flex-col"><div class="gap-2 px-3 py-3 flex flex-col rounded-md border border-border-strong bg-muted" role="status"><div class="gap-2 flex items-center justify-between"><span class="text-sm font-medium text-foreground"> </span> <span class="text-xs shrink-0 text-muted-foreground tabular-nums"> </span></div> <div class="h-1 overflow-hidden rounded-full bg-selected"><div class="animate-pulse h-full w-full rounded-full bg-primary"></div></div></div> <!></div>`),aG=D(`<div class="px-3 py-3 text-sm rounded-md border border-border-strong bg-muted text-muted-foreground"> </div>`),oG=D(`<div class="gap-2 flex flex-col"><div class="px-3 py-2 text-sm rounded-md border border-destructive bg-destructive/10 text-destructive"> </div> <!></div>`),sG=D(`<div class="gap-2 text-xs flex items-center justify-between text-muted-foreground"><span class="min-w-0 truncate"> </span> <span class="shrink-0"> </span></div>`),cG=D(`<div class="gap-1 flex flex-col"></div>`),lG=D(`<div class="mt-2"><!></div>`),uG=D(`<span class="text-xs text-muted-foreground"> </span>`),dG=D(`<li class="truncate"><span class="font-mono"> </span></li>`),fG=D(`<div class="px-3 py-2 text-sm rounded-md border border-destructive bg-destructive/10 text-destructive"><div class="font-medium"> </div> <div class="mt-1 text-xs"> </div> <ul class="mt-1 ml-4 text-xs list-disc"></ul> <div class="mt-1 text-xs"> </div></div>`),pG=D(`<div class="px-3 py-2 text-sm rounded-md border border-destructive bg-destructive/10 text-destructive"> </div>`),mG=D(`<div class="gap-2 flex flex-col"><div class="px-3 py-2 rounded-md border border-border-strong bg-muted"><div class="gap-2 flex items-center justify-between"><span class="min-w-0 text-sm font-medium truncate text-foreground"> </span> <span class="text-xs shrink-0 text-muted-foreground"> </span></div> <!></div> <!> <!> <!> <!></div>`),hG=D(`<span class="text-base font-normal"><!></span>`),gG=D(`<div class="min-h-8 text-2xl font-semibold wrap-break-word text-foreground tabular-nums"><!></div>`),_G=D(`<pre> </pre>`),vG=D(`<div><!></div>`),yG=D(`<div class="group relative"><!> <!></div>`),bG=D(`<div role="group"><!> <!></div>`);function xG(e,n){V(n,!0);let r=e=>{var r=QW(),i=I(r);mn(i,{children:(e,t)=>{var r=ZW(),i=K(r,!0);G(()=>{fe(r,1,me(n.item.widgetType===`number`?`text-xs font-normal text-muted-foreground`:``)),m(i,C(y))}),O(e,r)},$$slots:{default:!0}});var a=U(i,2),o=e=>{hV(e,{get label(){return C(y)},get description(){return n.item.description},get nameTemplate(){return d.messages.helpFor}})};t(a,e=>{n.item.description&&e(o)}),c(r),O(e,r)},i=e=>{var t=$W(),n=K(t,!0);G(()=>m(n,C(g).waitingForData)),O(e,t)},o=(e,n=h,r=h)=>{var i=u(),s=z(i);a(s,17,n,([e,t])=>e,(e,n)=>{var i=T(()=>w(C(n),2));let a=()=>C(i)[1];var s=u(),l=z(s),d=e=>{let n=T(()=>r()?`${r()}/${a().name}`:a().name),i=T(()=>ce.has(C(n)));var s=tG(),l=I(s),u=I(l);{let e=T(()=>C(i)?`rotate-90`:``);ut(u,{size:12,get class(){return`shrink-0 transition-transform duration-150 ${C(e)??``}`}})}var d=U(u,2),p=e=>{Ot(e,{size:13,class:`shrink-0 text-primary/70`})},h=e=>{$n(e,{size:13,class:`shrink-0 text-primary/70`})};t(d,e=>{C(i)?e(p):e(h,-1)});var g=U(d,2),_=K(g,!0);c(l);var v=U(l,2),y=e=>{var t=eG(),r=I(t);o(r,()=>a().children,()=>C(n)),c(t),O(e,t)};t(v,e=>{C(i)&&e(y)}),c(s),G(()=>m(_,a().name)),f(`click`,l,()=>q(C(n))),O(e,s)},p=e=>{var t=nG(),n=I(t),r=I(n);Xn(r,{size:12,class:`shrink-0 text-muted-foreground`});var i=U(r,2),o=K(i);c(n);var s=U(n,2),l=K(s,!0);c(t),G(e=>{m(o,`${a().file.fileName??``}${a().file.fileType??``}`),m(l,e)},[()=>RB(zB(a().file.data))]),O(e,t)};t(l,e=>{a().type===`folder`?e(d):e(p,-1)}),O(e,s)}),O(e,i)},s=e=>{var n=u(),r=z(n),i=e=>{var t=rG(),n=I(t),r=K(n,!0),i=U(n,2);{let e=T(()=>M?.isSolving);tt(i,{onclick:()=>M?.make(),get disabled(){return C(e)},class:`w-full`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(g).download)),O(e,n)},$$slots:{default:!0}})}c(t),G(()=>m(r,C(g).filesMadeOnDownload)),O(e,t)},a=e=>{var t=iG(),n=I(t),r=I(n),i=I(r),a=K(i,!0),o=U(i,2),s=K(o,!0);c(r),S(2),c(n);var l=U(n,2);tt(l,{variant:`outline`,onclick:()=>M?.cancel(),class:`w-full`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(g).cancel)),O(e,n)},$$slots:{default:!0}}),c(t),G(()=>{m(a,C(g).makingFiles),m(s,C(te))}),O(e,t)},o=e=>{var t=aG(),n=K(t,!0);G(()=>m(n,C(g).noFilesForInputs)),O(e,t)},s=e=>{var t=oG(),n=I(t),r=K(n,!0),i=U(n,2);{let e=T(()=>M?.isSolving);tt(i,{variant:`outline`,onclick:()=>M?.make(),get disabled(){return C(e)},class:`w-full`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(g).tryAgain)),O(e,n)},$$slots:{default:!0}})}c(t),G(()=>m(r,C(N).error)),O(e,t)};t(r,e=>{C(N)?.status===`waiting`?e(i):C(N)?.status===`making`?e(a,1):C(N)?.status===`empty`?e(o,2):C(N)?.status===`failed`&&e(s,3)}),O(e,n)},l=e=>{var n=u(),r=z(n),i=e=>{s(e)},l=e=>{var t=aG(),n=K(t,!0);G(()=>m(n,C(g).waitingForFiles)),O(e,t)},d=e=>{var n=mG(),r=I(n),i=I(r),s=I(i),l=K(s,!0),u=U(s,2),d=K(u,!0);c(i);var f=U(i,2),h=e=>{var n=lG(),r=I(n),i=e=>{o(e,()=>C(H),()=>``)},s=e=>{var t=cG();a(t,23,()=>C(ne),(e,t)=>W(e)+`#`+t,(e,t)=>{var n=sG(),r=I(n),i=K(r),a=U(r,2),o=K(a,!0);c(n),G(e=>{m(i,`${C(t).fileName??``}${C(t).fileType??``}`),m(o,e)},[()=>RB(zB(C(t).data))]),O(e,n)}),c(t),O(e,t)};t(r,e=>{C(H)?e(i):e(s,-1)}),c(n),O(e,n)};t(f,e=>{C(L)>1&&e(h)}),c(r);var _=U(r,2),v=e=>{var t=uG(),n=K(t,!0);G(e=>m(n,e),[()=>nt(C(g).filesMadeIn,{seconds:Math.max(1,Math.round(C(N).durationMs/1e3))})]),O(e,t)};t(_,e=>{C(N)?.status===`ready`&&e(v)});var y=U(_,2),b=e=>{var t=fG(),n=I(t),r=K(n,!0),i=U(n,2),o=K(i,!0),s=U(i,2);a(s,20,()=>C(oe),e=>e,(e,t)=>{var n=dG(),r=I(n),i=K(r,!0);c(n),G(()=>m(i,t)),O(e,n)}),c(s);var l=U(s,2),u=K(l,!0);c(t),G(e=>{m(r,C(g).duplicateFilesTitle),m(o,e),m(u,C(g).duplicateFilesHint)},[()=>it(C(oe).length,C(g).duplicatePathsOne,C(g).duplicatePathsOther)]),O(e,t)};t(y,e=>{C(se)&&e(b)});var x=U(y,2),w=e=>{var t=pG(),n=K(t,!0);G(()=>m(n,C(j))),O(e,t)};t(x,e=>{C(j)&&e(w)});var E=U(x,2);{let e=T(()=>C(A)||C(se));tt(E,{onclick:J,get disabled(){return C(e)},class:`w-full`,children:(e,t)=>{S();var n=p();G(e=>m(n,e),[()=>C(A)?C(g).downloading:C(L)===1?C(g).downloadFile:nt(C(g).downloadFiles,{count:C(L)})]),O(e,n)},$$slots:{default:!0}})}c(n),G((e,t)=>{m(l,e),m(d,t)},[()=>C(L)===1?`${C(ne)[0].fileName}${C(ne)[0].fileType}`:nt(C(g).fileCount,{count:C(L)}),()=>RB(C(R))]),O(e,n)};t(r,e=>{C(N)&&C(N).status!==`ready`?e(i):C(L)===0?e(l,1):e(d,-1)}),O(e,n)},d=at(),g=T(()=>d.messages),_=Z(!1),v,y=T(()=>n.displayName||n.item.displayName||n.item.paramId),x=T(()=>typeof n.value==`object`&&n.value!==null),E=T(()=>n.value==null?``:C(x)?JSON.stringify(n.value,null,2):String(n.value)),D=T(()=>n.value!=null);async function k(){try{await navigator.clipboard.writeText(C(E)),P(_,!0),clearTimeout(v),v=setTimeout(()=>P(_,!1),2e3)}catch(e){console.error(`Failed to copy:`,e)}}let A=Z(!1),j=Z(null),M=XW(),N=T(()=>{let e=M?.files;return e&&e.status!==`none`&&e.ids.includes(n.item.paramId)?e:null}),F=T(()=>C(N)?.status===`ready`?C(N).outputs[n.item.paramId]:n.value),ee=Z(B(Date.now()));le(()=>{if(C(N)?.status!==`making`)return;P(ee,Date.now(),!0);let e=setInterval(()=>P(ee,Date.now(),!0),1e3);return()=>clearInterval(e)});let te=T(()=>{if(C(N)?.status!==`making`)return``;let e=Math.max(0,Math.floor((C(ee)-C(N).startedAt)/1e3));return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}),ne=T(()=>C(F)?Array.isArray(C(F))?C(F).filter(LB):LB(C(F))?[C(F)]:[]:[]),L=T(()=>C(ne).length),R=T(()=>C(ne).reduce((e,t)=>e+zB(t.data),0));function re(e){let t=new be;for(let n=0;n<e.length;n++){let r=e[n],i=sI(r.subFolder),a=t;for(let e of i){a.has(e)||a.set(e,{type:`folder`,name:e,children:new be});let t=a.get(e);t.type===`folder`&&(a=t.children)}let o=`${r.fileName}${r.fileType??``}`,s=a.has(o)?`${o}#${n}`:o;a.set(s,{type:`file`,file:r})}return t}function ie(e,t=``){let n=[];for(let[r,i]of e)if(i.type===`folder`){let e=t?`${t}/${r}`:r;n.push(e),n.push(...ie(i.children,e))}return n}let ae=T(()=>C(ne).some(e=>e.subFolder&&e.subFolder.length>0)),H=T(()=>C(ae)?re(C(ne)):null);function W(e){let t=sI(e.subFolder).join(`/`),n=`${e.fileName}${e.fileType??``}`;return t?`${t}/${n}`:n}let oe=T(()=>{let e={};for(let t of C(ne)){let n=W(t);e[n]=(e[n]??0)+1}return Object.entries(e).filter(([,e])=>e>1).map(([e])=>e)}),se=T(()=>C(oe).length>0),ce=new ye;le(()=>{if(C(H)){ce.clear();for(let e of ie(C(H)))ce.add(e)}});function q(e){ce.has(e)?ce.delete(e):ce.add(e)}async function J(){if(C(L)!==0){P(A,!0),P(j,null);try{if(C(L)===1)await IB(C(ne)[0],C(ne)[0].fileName);else{let e=n.displayName?n.displayName.replace(/[^a-z0-9]/gi,`_`).toLowerCase():`download`;await IB(C(ne),e)}}catch(e){P(j,e instanceof Error?e.message:C(g).downloadFailed,!0),console.error(`[OutputDisplayWidget] Download error:`,e)}finally{P(A,!1)}}}var Y=u(),ue=z(Y),de=e=>{var a=bG(),o=I(a);r(o);var s=U(o,2),u=e=>{{let t=T(()=>typeof n.value==`string`?n.value:n.value==null?``:JSON.stringify(n.value));NW(e,{get item(){return n.item},get value(){return C(t)}})}},d=e=>{qW(e,{get item(){return n.item},get value(){return n.value}})},f=e=>{l(e)},h=e=>{var n=gG(),r=I(n),a=e=>{var t=p();G(()=>m(t,C(E))),O(e,t)},o=e=>{var t=hG(),n=I(t);i(n),c(t),O(e,t)};t(r,e=>{C(D)?e(a):e(o,-1)}),c(n),O(e,n)},v=e=>{var r=yG(),a=I(r),o=e=>{var t=_G();fe(t,1,`min-h-12.5 rounded-md px-3 py-3 text-sm border border-border-strong max-h-96 font-mono overflow-auto bg-muted wrap-anywhere text-foreground`);var n=K(t,!0);G(()=>m(n,C(E))),O(e,t)},s=e=>{var r=vG();fe(r,1,`min-h-12.5 rounded-md px-3 py-3 text-sm border border-border-strong bg-muted wrap-anywhere wrap-break-word whitespace-pre-wrap text-foreground`);var a=I(r),o=e=>{var t=p();G(()=>m(t,n.value)),O(e,t)},s=e=>{i(e)};t(a,e=>{C(D)?e(o):e(s,-1)}),c(r),O(e,r)};t(a,e=>{C(x)?e(o):e(s,-1)});var l=U(a,2),u=e=>{var t=vG(),n=I(t);tt(n,{onclick:k,size:`sm`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(_)?C(g).copied:C(g).copy)),O(e,n)},$$slots:{default:!0}}),c(t),G(()=>fe(t,1,`right-2 top-2 absolute transition-opacity ${C(_)?`opacity-100`:`opacity-0 group-hover:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100`}`)),O(e,t)};t(l,e=>{C(D)&&e(u)}),c(r),O(e,r)};t(s,e=>{n.item.widgetType===`chart`?e(u):n.item.widgetType===`image`?e(d,1):n.item.widgetType===`file`?e(f,2):n.item.widgetType===`number`?e(h,3):n.item.widgetType===`text`&&e(v,4)}),c(a),G(()=>fe(a,1,`group/field flex flex-col ${n.item.widgetType===`number`?`gap-0.5`:`gap-2`}`)),O(e,a)};t(ue,e=>{n.item.widgetType!==`dynamicValueList`&&e(de)}),O(e,Y),b()}ce([`click`]);var SG=D(`<h3 class="text-sm font-medium text-foreground"> </h3>`),CG=D(`<span class="text-xs truncate text-muted-foreground"> </span>`),wG=D(`<div role="group"><!></div>`),TG=D(`<div class="gap-1.5 flex flex-col"><span class="text-sm truncate"> </span> <div></div></div>`),EG=D(`<section class="gap-3 flex flex-col"><div class="gap-1 flex flex-col"><!> <div></div></div> <!></section>`),DG=D(`<div class="gap-5 flex flex-col"></div>`);function OG(e,n){V(n,!0);let r=J(n,`memberMedia`,19,()=>({})),i=J(n,`disabled`,3,!1),o=T(()=>{let e=[];return n.repeat.rows.forEach((t,n)=>{let r=t.section??``,i=e.find(e=>e.label===r);i||e.push(i={label:r,rows:[]}),i.rows.push({index:n,key:t.key,label:t.label||t.key})}),e});function s(e,t){let r=n.shown[e];return Array.isArray(r)&&typeof r[t]==`string`?r[t]:void 0}function l(e,t,r){typeof r==`string`&&n.onPick(e,t,r)}let u=(e,t)=>({options:n.rowOptions[e]?.[t]??{},optionMedia:r()[e]}),d=[`grid-cols-1`,`grid-cols-1`,`grid-cols-2`,`grid-cols-3`,`grid-cols-4`],f=T(()=>d[Math.min(n.repeat.members.length,4)]);var p=DG();a(p,21,()=>C(o),e=>e.label,(e,r)=>{var o=EG(),d=I(o),p=I(d),h=e=>{var t=SG(),n=K(t,!0);G(()=>m(n,C(r).label)),O(e,t)};t(p,e=>{C(r).label&&e(h)});var g=U(p,2);a(g,20,()=>n.repeat.members,e=>e,(e,t)=>{var r=CG(),i=K(r,!0);G(()=>m(i,n.memberLabels[t]??t)),O(e,r)}),c(g),c(d);var _=U(d,2);a(_,17,()=>C(r).rows,e=>e.key,(e,t)=>{var r=TG(),o=I(r),d=K(o,!0),p=U(o,2);a(p,20,()=>n.repeat.members,e=>e,(e,r)=>{var a=wG(),o=I(a);{let e=T(()=>s(r,C(t).index)),a=T(()=>u(r,C(t).index));YV(o,{get value(){return C(e)},get config(){return C(a)},onChange:e=>l(r,C(t).key,e),get disabled(){return i()},get assets(){return n.assets}})}c(a),G(()=>H(a,`aria-label`,`${C(t).label??``}: ${n.memberLabels[r]??r??``}`)),O(e,a)}),c(p),c(r),G(()=>{H(o,`title`,C(t).label),m(d,C(t).label),fe(p,1,`gap-2 grid items-center ${C(f)??``}`)}),O(e,r)}),c(o),G(()=>{H(o,`aria-label`,C(r).label||void 0),fe(g,1,`gap-x-2 grid ${C(f)??``}`)}),O(e,o)}),c(p),O(e,p),b()}var kG=D(`<div class="gap-4 py-4 flex flex-col"></div>`),AG=D(`<div><h2 class="sr-only"> </h2> <!></div>`),jG=D(`<div class="h-full"><!></div>`);function MG(e,n){V(n,!0);let r=(e,r=h,i=h)=>{let a=T(()=>x(r().paramId)),o=T(()=>n.formModel?.repeatOf[r().paramId]),s=T(()=>C(o)?n.formModel?.repeats.find(e=>e.id===C(o)):void 0);var c=u(),l=z(c),m=e=>{var r=u(),o=z(r),c=e=>{OG(e,{get repeat(){return C(s)},get memberLabels(){return p()},get memberMedia(){return g()},get shown(){return n.formModel.shown},get rowOptions(){return n.formModel.rowOptions},get onPick(){return n.onRowPick},get disabled(){return i().disabled},get assets(){return n.assets}})};t(o,e=>{f()[C(s).id]===C(a).id&&n.onRowPick&&e(c)}),O(e,r)},_=e=>{dW(e,{get item(){return r()},get value(){return n.values[C(a).id]},get displayName(){return r().displayName},get onChange(){return n.onValueChange},get disabled(){return i().disabled},get dynamicOptions(){return d()[C(a).id]},get paramType(){return C(a).paramType},get assets(){return n.assets}})};t(l,e=>{C(a)&&C(s)&&n.formModel?e(m):C(a)&&e(_,1)}),O(e,c)},i=(e,r=h)=>{let i=T(()=>S(r().paramId));var a=u(),o=z(a),s=e=>{xG(e,{get item(){return r()},get value(){return n.values[r().paramId]},get displayName(){return r().displayName}})};t(o,e=>{C(i)&&e(s)}),O(e,a)},o=e=>{var o=AG(),s=I(o),u=K(s,!0),d=U(s,2),f=e=>{Zc(e,{type:`empty`,size:`medium`,get message(){return C(l).tabNoGroups}})},p=e=>{var t=kG();a(t,21,()=>C(y),e=>e.id,(e,t)=>{{let a=T(()=>C(t).columns??1),o=T(()=>n.collapsedGroups[C(t).id]??!1),s=T(()=>C(y).length===1);aV(e,{get label(){return C(t).label},get description(){return C(t).description},get items(){return C(t).items},get columns(){return C(a)},get collapsed(){return C(o)},get values(){return n.values},onToggle:()=>n.onToggleGroup(C(t).id),get inputSnippet(){return r},get outputSnippet(){return i},get flat(){return C(s)}})}}),c(t),O(e,t)};t(d,e=>{C(y).length===0?e(f):e(p,-1)}),c(o),G(()=>{fe(o,1,me(_()?`px-1`:`px-3`)),m(u,n.tab.label)}),O(e,o)},s=at(),l=T(()=>s.messages),d=J(n,`dynamicOptions`,19,()=>({})),f=J(n,`repeatLeads`,19,()=>({})),p=J(n,`memberLabels`,19,()=>({})),g=J(n,`memberMedia`,19,()=>({})),_=J(n,`bare`,3,!1),{host:v}=VU(),y=T(()=>n.tab.groups.filter(e=>YB(e,n.values)).flatMap(e=>{let t=e.items.filter(e=>eW(v,$U(e,n.inputs)));return t.length>0||e.items.length===0?[{...e,items:t}]:[]}));function x(e){return n.inputs.find(t=>t.id===e)}function S(e){return n.outputs.find(t=>t.id===e)}var w=u(),D=z(w);E(D,()=>_n,(e,r)=>{r(e,{get value(){return n.tab.id},class:`min-h-0`,children:(e,n)=>{var r=u(),i=z(r),a=e=>{o(e)},s=e=>{var t=jG();Xo(I(t),{class:`h-full`,orientation:`vertical`,type:`auto`,children:(e,t)=>{o(e)},$$slots:{default:!0}}),c(t),O(e,t)};t(i,e=>{_()?e(a):e(s,-1)}),O(e,r)},$$slots:{default:!0}})}),O(e,w),b()}function NG(e){return typeof e==`object`&&!!e&&(`targetInputId`in e||`options`in e)}function PG(e){if(NG(e))return e;let t=e;for(let e=0;e<2&&typeof t==`string`;e++){try{t=JSON.parse(t)}catch{return null}if(NG(t))return t}return null}var FG=new Map,IG=8;function LG(e){if(typeof e!=`string`||e.length<1024)return PG(e);let t=FG.get(e);if(t!==void 0||FG.has(e))return FG.delete(e),FG.set(e,t??null),t??null;let n=performance.now(),r=PG(e);if(e.length>262144){let t=r?.options?Object.keys(r.options).length:0;console.info(`[DVL] parsed ${(e.length/1048576).toFixed(1)} MB options payload (${t} options) in ${(performance.now()-n).toFixed(0)}ms — cache miss`)}if(FG.size>=IG){let e=FG.keys().next().value;e!==void 0&&FG.delete(e)}return FG.set(e,r),r}function RG(e){let t=new Map;for(let n of BF(e)){if(n.type!==`output`||n.widgetType!==`dynamicValueList`)continue;let e=n;typeof e.paramId==`string`&&t.set(e.paramId,{id:e.paramId,targetInputId:e.config?.targetInputId})}for(let n of e.outputs??[])n.type===`dynamicValueList`&&t.set(n.id,{id:n.id,targetInputId:n.targetInputId});return[...t.values()]}function zG(e,t){if(typeof t!=`string`)return-1;let n=t.toLowerCase();return e.findIndex(([e,t])=>t.toLowerCase()===n||e.toLowerCase()===n)}function BG(e,t){let n=Object.entries(e??{});return n.length===0?typeof t==`string`?t:``:n[Math.max(0,zG(n,t))][1]}function VG(e,t){let n=Object.entries(e??{});if(n.length===0)return t.filter(e=>typeof e==`string`);let r=new Set;for(let e of t){let t=zG(n,e);t>=0&&r.add(t)}return r.size>0?[...r].map(e=>n[e][1]):[n[0][1]]}function HG(e,t,n){let r=Object.entries(e??{});if(r.length===0||!Array.isArray(t))return n;let i=t.filter(e=>typeof e==`string`&&zG(r,e)<0&&!n.includes(e));return[...n,...i]}function UG(e){if(typeof e!=`string`||!e.trimStart().startsWith(`{`))return{};try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]==`string`))}catch{return{}}}function WG(e,t,n){return JSON.stringify({...UG(e),[t]:n})}function GG(e,t,n){let r={},i={};for(let{source:a,payload:o}of e){let e=o.targetInputId??a.targetInputId;if(!e||!o.options||typeof o.options!=`object`)continue;let s=t.get(n[e]),c=o.options;s?i[e]=s.rows.map(()=>c):r[e]=c}for(let{source:n,payload:r}of e){let e=t.get(n.id),a=r.options;if(e&&a&&Object.keys(a).length!==0)for(let t of e.members)i[t]??=e.rows.map(()=>a)}return{options:r,rowOptions:i}}var KG=new WeakMap;function qG(e,t,n,r){let i={},a={},o={};for(let{payload:s}of e){let e=s.pickTable;if(!e||!Array.isArray(e.inputs)||!Array.isArray(e.rows))continue;let c=KG.get(e.rows)??new Map;KG.set(e.rows,c);let l=Array.isArray(e.by)?e.by:[],u=l.map(e=>{let n=t[e];return(Array.isArray(n)?n:[n]).filter(e=>e!=null).map(String)}),d=Array.from({length:Math.max(1,...u.map(e=>e.length))},(t,n)=>{let r=u.map(e=>e[Math.min(n,e.length-1)]);return{rows:e.rows.filter(e=>r.every((t,n)=>t===void 0||e[n]?.toLowerCase()===t.toLowerCase())),picked:r.map(e=>e??``)}}),f=[];e.inputs.forEach((s,u)=>{let p=l.length+u,m=e.parents?.[u]??u-1,h=m>=0&&f[m]?f[m]:d,g=n.get(r[s]),_=g?UG(t[s]):void 0,v=g?g.rows.map(e=>_?.[e.key]):[t[s]],y=[],b=[],x=v.map((e,t)=>{let{rows:n,picked:r}=h[Math.min(t,h.length-1)],i=JSON.stringify([p,...r]),a=c.get(i);if(!a){a={};for(let e of n){let t=e[p];typeof t==`string`&&t!==``&&(a[t]=t)}c.set(i,a)}y.push(a);let o=BG(a,e);return b.push(o),{rows:n.filter(e=>e[p]===o),picked:[...r,`${p}:${o}`]}});g?(a[s]=y,o[s]=b):(i[s]=y[0],o[s]=b[0]),f[u]=x.length>0?x:h})}return{options:i,rowOptions:a,shown:o}}function JG(e,t,n){let r=[];for(let n of RG(e)){let e=LG(t[n.id]);e&&r.push({source:n,payload:e})}let i=[],a={};for(let{source:e,payload:t}of r){if(!Array.isArray(t.rows)||!Array.isArray(t.members))continue;let n=t.rows.filter(e=>typeof e?.key==`string`);i.push({id:e.id,rows:n,members:t.members});for(let n of t.members)a[n]=e.id}let o=new Map(i.map(e=>[e.id,e])),s=qG(r,t,o,a),c=GG(r,o,a);Object.assign(c.options,s.options),Object.assign(c.rowOptions,s.rowOptions);let l={...s.shown};for(let{source:e,payload:n}of r){let r=n.targetInputId??e.targetInputId;if(!r||!n.resolvedInSolve||a[r])continue;let i=t[r];l[r]=Array.isArray(i)?VG(c.options[r],i):BG(c.options[r],i)}for(let e of i)for(let n of e.members){let r=UG(t[n]);l[n]=e.rows.map((e,t)=>BG(c.rowOptions[n]?.[t],r[e.key]))}return n&&(XG(l,n.shown),XG(c.rowOptions,n.rowOptions)),{...c,repeats:i,repeatOf:a,shown:l}}function YG(e,t){return e===t?!0:!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function XG(e,t){for(let n of Object.keys(e))n in t&&YG(e[n],t[n])&&(e[n]=t[n])}var ZG=D(`<!> <!>`,1),QG=D(`<div class="min-h-0 flex flex-1 flex-col"><!></div>`);function $G(e,n){V(n,!0);let r=e=>{var r=u(),i=z(r);E(i,()=>hn,(e,r)=>{r(e,{get value(){return C(s)},variant:`line`,class:`min-h-0 flex-1`,children:(e,r)=>{var i=ZG(),c=z(i),u=e=>{NB(e,{get tabs(){return C(m)},get activeTabId(){return C(s)},onTabChange:w,get bare(){return o()}})};t(c,e=>{C(h)&&e(u)});var d=U(c,2);a(d,17,()=>C(m),e=>e.id,(e,t)=>{MG(e,{get tab(){return C(t)},get values(){return C(p)},get collapsedGroups(){return l},onToggleGroup:S,onValueChange:y,onRowPick:x,get inputs(){return n.schema.inputs},get outputs(){return n.schema.outputs},get dynamicOptions(){return C(f).options},get formModel(){return C(f)},get repeatLeads(){return C(g)},get memberLabels(){return C(v)},get memberMedia(){return C(_)},get assets(){return n.schema.assets},get bare(){return o()}})}),O(e,i)},$$slots:{default:!0}})}),O(e,r)},i=J(n,`requestedTabId`,3,null),o=J(n,`bare`,3,!1),s=Z(``),l=B({}),d,f=T(()=>d=JG(n.schema,n.values,d)),p=T(()=>({...n.values,...C(f).shown})),m=T(()=>n.schema.layout.type===`tabbed`?n.schema.layout.tabs.filter(e=>XB(e,C(p))?n.panelFilter?n.panelFilter===`right`?e.position===`right`:e.position!==`right`:!0:!1):[]),h=T(()=>C(m).length>1),g=T(()=>{let e=new Set(BF(n.schema).filter(e=>e.type===`input`).map(e=>e.paramId)),t={};for(let n of C(f).repeats){let r=n.members.find(t=>e.has(t));r&&(t[n.id]=r)}return t}),_=T(()=>{let e={};for(let t of BF(n.schema)){if(t.type!==`input`)continue;let n=t.config;n?.optionMedia&&(e[t.paramId]=n.optionMedia)}return e}),v=T(()=>{let e={};for(let t of n.schema.inputs)e[t.id]=t.nickname;for(let t of BF(n.schema))t.type===`input`&&t.displayName&&(e[t.paramId]=t.displayName);return e});function y(e,t,r){let i=Array.isArray(t)&&Array.isArray(C(f).shown[e])?HG(C(f).options[e],n.values[e],t):t;n.onValueChange(e,i,r)}function x(e,t,r){n.onValueChange(e,WG(n.values[e],t,r))}le(()=>{i()&&C(m).some(e=>e.id===i())?P(s,i()):C(m).length>0&&!C(m).some(e=>e.id===C(s))&&P(s,C(m)[0].id,!0)}),le(()=>{if(n.schema.layout.type!==`tabbed`)return;let e={};n.schema.layout.tabs.forEach(t=>t.groups.forEach(t=>{t.id in l||(e[t.id]=t.collapsed??!1)})),Object.keys(e).length>0&&Object.assign(l,e)});function S(e){l[e]=!l[e]}function w(e){P(s,e,!0)}var D=u(),k=z(D),A=e=>{r(e)},j=e=>{var t=QG(),n=I(t);r(n),c(t),O(e,t)};t(k,e=>{o()?e(A):e(j,-1)}),O(e,D),b()}var eK=D(`<span class="text-xs font-semibold"> </span>`),tK=D(`<button type="button"><!></button>`),nK=D(`<div role="button" tabindex="0"></div>`);function rK(e,n){V(n,!0);let r=at(),i=T(()=>r.messages),o=T(()=>[`gap-1 py-2 lg:py-3 lg:flex-col lg:w-auto px-2 lg:px-0`,`flex w-full shrink-0 flex-row items-center`,`backdrop-blur-sm bg-background/90 cursor-pointer`,n.side===`left`?`lg:border-r`:`lg:border-l`,`border-border`].join(` `));var s=nK();a(s,21,()=>n.tabs,e=>e.id,(e,r)=>{var i=tK();fe(i,1,me(`w-8 h-8 rounded-md cursor-pointer flex shrink-0 items-center justify-center text-muted-foreground transition-colors hover:bg-hover hover:text-foreground`));var a=I(i),o=e=>{var n=u(),i=z(n),a=e=>{DB(e,{get icon(){return C(r).icon},class:`h-4 w-4`})},o=T(()=>C(r).icon.includes(`:`)),s=e=>{var t=eK(),n=K(t,!0);G(()=>m(n,C(r).icon)),O(e,t)};t(i,e=>{C(o)?e(a):e(s,-1)}),O(e,n)},s=e=>{var t=eK(),n=K(t,!0);G(e=>m(n,e),[()=>C(r).label[0]?.toUpperCase()??`?`]),O(e,t)};t(a,e=>{C(r).icon?e(o):e(s,-1)}),c(i),G(()=>{H(i,`title`,C(r).label),H(i,`aria-label`,C(r).label)}),f(`click`,i,e=>{e.stopPropagation(),n.onTabClick(C(r).id)}),O(e,i)}),c(s),G(e=>{fe(s,1,me(C(o)),`svelte-t5rp76`),N(s,`--collapsed-w: ${n.collapsedWidth??``}px;`),H(s,`aria-label`,e)},[()=>C(i).expandSidePanel.replace(`{side}`,n.side===`left`?C(i).panelSideLeft:C(i).panelSideRight)]),f(`click`,s,function(...e){n.onExpand?.apply(this,e)}),f(`keydown`,s,e=>(e.key===`Enter`||e.key===` `)&&n.onExpand()),O(e,s),b()}ce([`click`,`keydown`]);function iK(e,t,n){let r=[];for(let n of zF(e))for(let i of n.items??[]){if(i.type!==`input`)continue;let a=t[i.paramId],o=e.inputs.find(e=>e.id===i.paramId);tW(i,o)||a!==void 0&&o&&r.push({paramId:i.paramId,nickname:o.nickname,displayName:i.displayName||o.nickname,paramType:o.paramType,value:a,groupName:n.label})}return{id:En(),name:n.name,description:n.description,timestamp:new Date().toISOString(),schemaId:e.id,documentId:e.documentId??``,projectFileName:e.projectFileName??``,pluginVersion:e.pluginVersion??``,author:n.author,tags:n.tags??[],parameters:r}}function aK(e,t){let n=[];e.documentId!==(t.documentId??``)&&n.push({paramId:`__document__`,severity:`error`,message:`Document ID mismatch - this state was saved for a different document`,details:{expected:t.documentId??``,actual:e.documentId}}),e.schemaId!==t.id&&n.push({paramId:`__schema__`,severity:`warning`,message:`Schema has changed since this state was saved`,details:{expected:t.id,actual:e.schemaId}});for(let r of e.parameters){let e=t.inputs.find(e=>e.id===r.paramId);e?e.nickname!==r.nickname&&n.push({paramId:r.paramId,severity:`warning`,message:`Parameter nickname changed`,details:{expected:r.nickname,actual:e.nickname}}):n.push({paramId:r.paramId,severity:`error`,message:`Parameter "${r.nickname}" no longer exists in the schema`})}let r=n.some(e=>e.severity===`error`);return{isValid:n.length===0,issues:n,canLoad:!r}}function oK(e,t){let n={},r=nW(t);for(let i of e.parameters)t.inputs.some(e=>e.id===i.paramId)&&!r.has(i.paramId)&&(n[i.paramId]=i.value);return n}function sK(e,t){let n=aK(e,t);return{values:oK(e,t),issues:n.issues,isValid:n.isValid,canLoad:n.canLoad}}function cK(e){return _F(new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),`${e.name.replace(/[^a-z0-9]/gi,`_`)}_${e.timestamp.split(`T`)[0].replace(/-/g,`_`)}.slvp`)}async function lK(e){let t=JSON.parse(await e.text());if(!t.id||!t.name||!t.documentId||!t.parameters)throw Error(`Invalid saved state file format`);return t}var uK={saveMenuItem:`Save inputs…`,loadMenuItem:`Load inputs…`,saveDialogTitle:`Save inputs`,saveDialogDescription:`Save the current input values as a .slvp file`,saveNameLabel:`Name *`,saveNamePlaceholder:`e.g., Design Option A`,saveDescriptionLabel:`Description`,saveDescriptionPlaceholder:`Optional description of this state`,saveAuthorLabel:`Author`,saveAuthorPlaceholder:`Your name or email`,saveTagsLabel:`Tags`,saveTagsPlaceholder:`facade, option-a, client-approved (comma-separated)`,saveNameRequired:`Please enter a name for these inputs`,saveConfirmButton:`Save`,loadDialogTitle:`Load inputs`,loadDialogDescription:`Select a .slvp file from your drive to load`,loadFromFileButton:`Select .slvp File`,loadEmptyList:`No saved states found`,loadImportError:`Failed to import state: `,validationTitle:`State Validation Report`,validationValidatingPrefix:`Validating state: `,validationNoIssuesTitle:`No Issues Found`,validationNoIssuesBody:`This state can be loaded safely.`,validationWarningsTitle:`Warnings Detected`,validationWarningsBody:`{count} warning(s) found, but state can still be loaded.`,validationErrorsTitle:`Critical Errors`,validationErrorsBody:`Cannot load this state due to critical incompatibilities.`,validationIssuesHeading:`Issues:`,validationExpected:`Expected:`,validationActual:`Actual:`,cancelButton:`Cancel`,loadAnywayButton:`Load Anyway`},dK=D(`<!> <!>`,1),fK=D(`<!> <div class="gap-4 py-4 grid"><div class="gap-2 grid"><!> <!></div> <div class="gap-2 grid"><!> <!></div> <div class="gap-2 grid"><!> <!></div> <div class="gap-2 grid"><!> <!></div></div> <!>`,1),pK=D(`<p class="text-sm py-8 text-center text-muted-foreground">…</p>`),mK=D(`<p class="text-sm py-8 text-center text-destructive"> </p>`),hK=D(`<p class="text-sm py-8 text-center text-muted-foreground"> </p>`),gK=D(`<div class="text-xs mt-0.5 text-muted-foreground"> </div>`),_K=D(`<button type="button" class="p-3 w-full rounded-lg border text-left transition-colors hover:bg-hover"><div class="text-sm font-medium"> </div> <!> <div class="text-xs mt-1 text-muted-foreground"> </div></button>`),vK=D(`<div class="space-y-2"></div>`),yK=D(`<div class="py-4"><!></div>`),bK=D(`<!> `,1),xK=D(`<div class="py-8"><!></div>`),SK=D(`<!> <!> <!>`,1),CK=D(`<div class="gap-2 flex flex-col"><h4 class="text-sm font-medium"> </h4> <!></div>`),wK=D(`<div class="gap-4 py-4 grid"><!> <!></div>`);function TK(e,n){V(n,!0);let r=T(()=>({...uK,...n.labels})),i=Z(!1),o=Z(``),s=Z(``),l=Z(``),d=Z(``),h=Z(!1),g=Z(!1),_=Z(null),v=Z(``),y=Z(B([])),x=Z(!1),w=Z(``);function D(){P(o,`State ${new Date().toLocaleDateString()}`),P(s,``),P(l,n.schema.author||``,!0),P(d,``),P(i,!0)}async function k(){if(!C(o).trim()){Cn.error(C(r).saveNameRequired);return}let e=iK(n.schema,n.currentValues,{name:C(o).trim(),description:C(s).trim()||void 0,author:C(l).trim()||void 0,tags:C(d).split(`,`).map(e=>e.trim()).filter(e=>e.length>0)});n.onSaveState?await n.onSaveState(e):await cK(e),P(i,!1)}function A(e){let t=sK(e,n.schema);t.isValid?n.onLoadValues(t.values):(P(_,t,!0),P(v,e.name,!0),P(h,!0))}async function j(){let e=await vF({accept:`.slvp,.sps`});if(e)try{A(await lK(e))}catch(e){Cn.error(C(r).loadImportError+e.message)}}function M(){C(_)&&C(_).canLoad&&(n.onLoadValues(C(_).values),P(h,!1),P(_,null))}function N(){P(h,!1),P(_,null)}async function F(){if(P(g,!0),n.onListStates){P(x,!0),P(w,``),P(y,[],!0);try{P(y,await n.onListStates(),!0)}catch(e){P(w,e.message,!0)}finally{P(x,!1)}}}function ee(){P(g,!1),j()}function te(e){A(e),P(g,!1)}var ne={openSave:D,openLoad:F},L=SK(),R=z(L);E(R,()=>pn,(e,t)=>{t(e,{get open(){return C(i)},set open(e){P(i,e,!0)},children:(e,t)=>{var n=u(),a=z(n);E(a,()=>fn,(e,t)=>{t(e,{children:(e,t)=>{var n=fK(),a=z(n);E(a,()=>un,(e,t)=>{t(e,{children:(e,t)=>{var n=dK(),i=z(n);E(i,()=>ln,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveDialogTitle)),O(e,n)},$$slots:{default:!0}})});var a=U(i,2);E(a,()=>dn,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveDialogDescription)),O(e,n)},$$slots:{default:!0}})}),O(e,n)},$$slots:{default:!0}})});var u=U(a,2),f=I(u),h=I(f);mn(h,{for:`export-name`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveNameLabel)),O(e,n)},$$slots:{default:!0}});var g=U(h,2);xn(g,{id:`export-name`,get placeholder(){return C(r).saveNamePlaceholder},get value(){return C(o)},set value(e){P(o,e,!0)}}),c(f);var _=U(f,2),v=I(_);mn(v,{for:`export-description`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveDescriptionLabel)),O(e,n)},$$slots:{default:!0}});var y=U(v,2);Sn(y,{id:`export-description`,get placeholder(){return C(r).saveDescriptionPlaceholder},rows:3,get value(){return C(s)},set value(e){P(s,e,!0)}}),c(_);var b=U(_,2),x=I(b);mn(x,{for:`export-author`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveAuthorLabel)),O(e,n)},$$slots:{default:!0}});var w=U(x,2);xn(w,{id:`export-author`,get placeholder(){return C(r).saveAuthorPlaceholder},get value(){return C(l)},set value(e){P(l,e,!0)}}),c(b);var T=U(b,2),D=I(T);mn(D,{for:`export-tags`,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveTagsLabel)),O(e,n)},$$slots:{default:!0}});var A=U(D,2);xn(A,{id:`export-tags`,get placeholder(){return C(r).saveTagsPlaceholder},get value(){return C(d)},set value(e){P(d,e,!0)}}),c(T),c(u);var j=U(u,2);E(j,()=>yt,(e,t)=>{t(e,{children:(e,t)=>{var n=dK(),a=z(n);tt(a,{variant:`outline`,onclick:()=>P(i,!1),children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).cancelButton)),O(e,n)},$$slots:{default:!0}});var o=U(a,2);tt(o,{onclick:k,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).saveConfirmButton)),O(e,n)},$$slots:{default:!0}}),O(e,n)},$$slots:{default:!0}})}),O(e,n)},$$slots:{default:!0}})}),O(e,n)},$$slots:{default:!0}})});var re=U(R,2);E(re,()=>pn,(e,i)=>{i(e,{get open(){return C(g)},set open(e){P(g,e,!0)},children:(e,i)=>{var o=u(),s=z(o);E(s,()=>fn,(e,i)=>{i(e,{children:(e,i)=>{var o=SK(),s=z(o);E(s,()=>un,(e,t)=>{t(e,{children:(e,t)=>{var n=dK(),i=z(n);E(i,()=>ln,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).loadDialogTitle)),O(e,n)},$$slots:{default:!0}})});var a=U(i,2);E(a,()=>dn,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).loadDialogDescription)),O(e,n)},$$slots:{default:!0}})}),O(e,n)},$$slots:{default:!0}})});var l=U(s,2),u=e=>{var n=yK(),i=I(n),o=e=>{var t=pK();O(e,t)},s=e=>{var t=mK(),n=K(t,!0);G(()=>m(n,C(w))),O(e,t)},l=e=>{var t=hK(),n=K(t,!0);G(()=>m(n,C(r).loadEmptyList)),O(e,t)},u=e=>{var n=vK();a(n,21,()=>C(y),e=>e.id,(e,n)=>{var r=_K(),i=I(r),a=K(i,!0),o=U(i,2),s=e=>{var t=gK(),r=K(t,!0);G(()=>m(r,C(n).description)),O(e,t)};t(o,e=>{C(n).description&&e(s)});var l=U(o,2),u=K(l,!0);c(r),G(e=>{m(a,C(n).name),m(u,e)},[()=>new Date(C(n).timestamp).toLocaleString()]),f(`click`,r,()=>te(C(n))),O(e,r)}),c(n),O(e,n)};t(i,e=>{C(x)?e(o):C(w)?e(s,1):C(y).length===0?e(l,2):e(u,-1)}),c(n),O(e,n)},d=e=>{var t=xK(),n=I(t);tt(n,{onclick:ee,class:`w-full`,size:`lg`,children:(e,t)=>{var n=bK(),i=z(n);Dt(i,{class:`mr-2 h-4 w-4`});var a=U(i);G(()=>m(a,` ${C(r).loadFromFileButton??``}`)),O(e,n)},$$slots:{default:!0}}),c(t),O(e,t)};t(l,e=>{n.onListStates?e(u):e(d,-1)});var h=U(l,2);E(h,()=>yt,(e,t)=>{t(e,{children:(e,t)=>{tt(e,{variant:`outline`,onclick:()=>P(g,!1),children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).cancelButton)),O(e,n)},$$slots:{default:!0}})},$$slots:{default:!0}})}),O(e,o)},$$slots:{default:!0}})}),O(e,o)},$$slots:{default:!0}})});var ie=U(re,2);return E(ie,()=>pn,(e,n)=>{n(e,{get open(){return C(h)},set open(e){P(h,e,!0)},children:(e,n)=>{var i=u(),a=z(i);E(a,()=>fn,(e,n)=>{n(e,{class:`max-w-2xl`,children:(e,n)=>{var i=SK(),a=z(i);E(a,()=>un,(e,n)=>{n(e,{children:(e,n)=>{var i=dK(),a=z(i);E(a,()=>ln,(e,t)=>{t(e,{children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).validationTitle)),O(e,n)},$$slots:{default:!0}})});var o=U(a,2);E(o,()=>dn,(e,n)=>{n(e,{children:(e,n)=>{var i=u(),a=z(i),o=e=>{var t=p();G(()=>m(t,`${C(r).validationValidatingPrefix??``}${C(v)??``}`)),O(e,t)};t(a,e=>{C(v)&&e(o)}),O(e,i)},$$slots:{default:!0}})}),O(e,i)},$$slots:{default:!0}})});var o=U(a,2),s=e=>{var n=wK(),i=I(n),a=e=>{wn(e,{tone:`success`,get title(){return C(r).validationNoIssuesTitle},children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).validationNoIssuesBody)),O(e,n)},$$slots:{default:!0}})},o=e=>{wn(e,{tone:`warning`,get title(){return C(r).validationWarningsTitle},children:(e,t)=>{S();var n=p();G(e=>m(n,e),[()=>C(r).validationWarningsBody.replace(`{count}`,String(C(_).issues.length))]),O(e,n)},$$slots:{default:!0}})},s=e=>{wn(e,{tone:`danger`,get title(){return C(r).validationErrorsTitle},children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).validationErrorsBody)),O(e,n)},$$slots:{default:!0}})};t(i,e=>{C(_).isValid?e(a):C(_).canLoad?e(o,1):e(s,-1)});var l=U(i,2),u=e=>{var t=CK(),n=I(t),i=K(n,!0),a=U(n,2);{let e=T(()=>C(_).issues.map(e=>({severity:e.severity===`error`?`error`:`warning`,message:e.message,detail:e.details?`${C(r).validationExpected} ${e.details.expected} → ${C(r).validationActual} ${e.details.actual}`:void 0})));We(a,{get issues(){return C(e)}})}c(t),G(()=>m(i,C(r).validationIssuesHeading)),O(e,t)};t(l,e=>{C(_).isValid||e(u)}),c(n),O(e,n)};t(o,e=>{C(_)&&e(s)});var l=U(o,2);E(l,()=>yt,(e,n)=>{n(e,{children:(e,n)=>{var i=dK(),a=z(i);tt(a,{variant:`outline`,onclick:N,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).cancelButton)),O(e,n)},$$slots:{default:!0}});var o=U(a,2),s=e=>{tt(e,{onclick:M,children:(e,t)=>{S();var n=p();G(()=>m(n,C(r).loadAnywayButton)),O(e,n)},$$slots:{default:!0}})};t(o,e=>{C(_)?.canLoad&&e(s)}),O(e,i)},$$slots:{default:!0}})}),O(e,i)},$$slots:{default:!0}})}),O(e,i)},$$slots:{default:!0}})}),O(e,L),b(ne)}ce([`click`]);async function EK(e,t){if(!e.solvesFirst||!t)return e.onclick();let n=await t();n.status===`applied`&&await e.onclick(n)}var DK=D(`<!> `,1),OK=D(`<span class="text-xs leading-snug text-muted-foreground"> </span>`),kK=D(`<!> <span class="flex flex-col"> <!></span>`,1),AK=D(`<!> <!> <!> <!>`,1),jK=D(`<!> <!>`,1),MK=D(`<!> <span class="truncate"> </span>`,1),NK=D(`<div class="mt-3 pb-3 pt-2 px-2 gap-2 flex items-center border-t border-border"><!> <!></div>`),PK=D(`<div class="panel-footer px-1 svelte-1kczbhm"><!></div>`),FK=D(`<div class="panel-content-wrapper svelte-1kczbhm"><!> <!></div>`),IK=D(`<div class="drawer-footer svelte-1kczbhm"><!></div>`),LK=D(`<div class="my-4 gap-2 flex items-center" aria-hidden="true"><div class="h-px flex-1 bg-border"></div> <span class="text-xs font-medium px-1 text-muted-foreground"> </span> <div class="h-px flex-1 bg-border"></div></div> <!>`,1),RK=D(`<div><!></div> <div><button class="drawer-handle-bar touch-none svelte-1kczbhm"><div class="drawer-pill svelte-1kczbhm"></div> <span class="drawer-label text-sm font-medium text-foreground svelte-1kczbhm"> </span> <!></button> <div class="drawer-body svelte-1kczbhm"><div class="drawer-content svelte-1kczbhm"><div class="px-2 pb-4"><!> <!></div></div> <!></div></div>`,1),zK=D(`<div class="flex flex-1 flex-col overflow-hidden"><div class="px-3 pt-3 sm:px-5 flex-1 overflow-y-auto"><!> <!></div> <!></div>`),BK=D(`<div class="min-h-0 p-1 flex h-full flex-1 justify-center"><div class="min-h-0 flex h-full w-4/5 flex-col"><!></div></div>`),VK=D(`<div><!></div>`),HK=D(`<!> <!> <!>`,1),UK=D(`<div class="min-h-0 flex h-full flex-1"><!> <!> <!></div>`),WK=D(`<main data-layout-root=""><!></main> <!>`,1);function GK(e,n){V(n,!0);let r=e=>{var r=u(),i=z(r);E(i,()=>Ge,(e,r)=>{r(e,{children:(e,r)=>{var i=jK(),o=z(i);{let e=(e,t)=>{tt(e,q(()=>(t?.()).props,{variant:`outline`,size:`icon-lg`,class:`shrink-0`,get title(){return C(_).moreActions},get"aria-label"(){return C(_).moreActions},children:(e,t)=>{bt(e,{})},$$slots:{default:!0}}))};E(o,()=>Xe,(t,n)=>{n(t,{child:e,$$slots:{child:!0}})})}var s=U(o,2);E(s,()=>Je,(e,r)=>{r(e,{side:`top`,align:`end`,sideOffset:6,class:`min-w-56 z-10001 w-auto`,children:(e,r)=>{var i=AK(),o=z(i),s=e=>{var t=u(),n=z(t);E(n,()=>He,(e,t)=>{t(e,{onSelect:()=>C(R)?.openSave(),children:(e,t)=>{var n=DK(),r=z(n);Vn(r,{});var i=U(r);G(()=>m(i,` ${C(L).saveMenuItem??``}`)),O(e,n)},$$slots:{default:!0}})}),O(e,t)};t(o,e=>{ee()&&e(s)});var l=U(o,2),d=e=>{var t=u(),n=z(t);E(n,()=>He,(e,t)=>{t(e,{onSelect:()=>C(R)?.openLoad(),children:(e,t)=>{var n=DK(),r=z(n);Dt(r,{});var i=U(r);G(()=>m(i,` ${C(L).loadMenuItem??``}`)),O(e,n)},$$slots:{default:!0}})}),O(e,t)};t(l,e=>{te()&&e(d)});var f=U(l,2),p=e=>{var t=u(),n=z(t);E(n,()=>Ve,(e,t)=>{t(e,{})}),O(e,t)};t(f,e=>{(ee()||te())&&N().length>0&&e(p)});var h=U(f,2);a(h,17,N,e=>e.id,(e,r)=>{let i=T(()=>C(r).hint??(C(r).solvesFirst&&C(ie)?C(_).calculatesFirst:void 0));var a=u(),o=z(a);{let e=T(()=>C(r).variant??`default`);E(o,()=>He,(a,o)=>{o(a,{get disabled(){return C(r).disabled},get variant(){return C(e)},onSelect:()=>EK(C(r),n.ensureSolved),class:`items-start`,children:(e,n)=>{var a=kK(),o=z(a),s=e=>{let t=T(()=>C(r).icon);var n=u(),i=z(n);E(i,()=>C(t),(e,t)=>{t(e,{class:`mt-0.5`})}),O(e,n)};t(o,e=>{C(r).icon&&e(s)});var l=U(o,2),d=I(l),f=U(d),p=e=>{var t=OK(),n=K(t,!0);G(()=>m(n,C(i))),O(e,t)};t(f,e=>{C(i)&&e(p)}),c(l),G(()=>m(d,`${C(r).label??``} `)),O(e,a)},$$slots:{default:!0}})})}O(e,a)}),O(e,i)},$$slots:{default:!0}})}),O(e,i)},$$slots:{default:!0}})}),O(e,r)},i=(e,r=h)=>{let i=T(()=>r().hint??(r().solvesFirst&&C(ie)?C(_).calculatesFirst:void 0));{let a=T(()=>r().variant===`destructive`?`destructive`:C(ie)&&n.schema.instanceSolve===!1?`outline`:`default`),o=T(()=>r().disabled||C(re));tt(e,{get variant(){return C(a)},size:`lg`,class:`min-w-0 shrink`,get disabled(){return C(o)},get"aria-busy"(){return C(re)},get title(){return C(i)},onclick:async()=>{P(re,!0);try{await EK(r(),n.ensureSolved)}finally{P(re,!1)}},children:(e,n)=>{var i=MK(),a=z(i),o=e=>{let t=T(()=>r().icon);var n=u(),i=z(n);E(i,()=>C(t),(e,t)=>{t(e,{})}),O(e,n)};t(a,e=>{r().icon&&e(o)});var s=U(a,2),c=K(s,!0);G(()=>m(c,r().label)),O(e,i)},$$slots:{default:!0}})}},o=e=>{var a=jK(),o=z(a),s=e=>{i(e,()=>n.primaryAction)};t(o,e=>{n.primaryAction&&e(s)});var c=U(o,2),l=e=>{r(e)};t(c,e=>{C(B)&&e(l)}),O(e,a)},s=e=>{var r=jK(),i=z(r);x(i,()=>n.solveMessages??h);var a=U(i,2),s=e=>{{let t=T(()=>C(B)||n.primaryAction?o:void 0);nl(e,{get hasPendingChanges(){return k()},get hasNeverSolved(){return A()},get isSolving(){return n.isSolving},get oncalculate(){return M()},get trailing(){return C(t)}})}},l=e=>{var t=NK(),r=I(t);zR(r,{get isSolving(){return n.isSolving},get show(){return y()},get slow(){return w()},get live(){return n.live},get onabort(){return n.onabort},get freezesDuringSolve(){return D()}});var i=U(r,2);o(i),c(t),O(e,t)};t(a,e=>{n.schema.instanceSolve===!1?e(s):e(l,-1)}),O(e,r)},l=(e,r=h,i=h,a)=>{let o=pe(()=>d(a?.(),!0));var l=FK(),u=I(l),f=e=>{$G(e,{get schema(){return n.schema},get values(){return n.values},get onValueChange(){return n.onValueChange},get panelFilter(){return r()},get requestedTabId(){return i()},get bare(){return C(ye)}})};t(u,e=>{n.schema.layout.type===`tabbed`&&e(f)});var p=U(u,2),m=e=>{var t=PK(),n=I(t);s(n),c(t),O(e,t)};t(p,e=>{C(o)&&!C(ye)&&e(m)}),c(l),O(e,l)},p=(e,t=h)=>{var n=IK(),r=I(n);s(r),c(n),G(()=>n.inert=t()),O(e,n)},g=at(),_=T(()=>g.messages),v=J(n,`meshes`,19,()=>[]),y=J(n,`showSolvingIndicator`,3,!1),w=J(n,`solveIsSlow`,3,!1),D=J(n,`freezesDuringSolve`,3,!1),k=J(n,`hasPendingChanges`,3,!1),A=J(n,`hasNeverSolved`,3,!1),j=J(n,`isViewerFullscreen`,15,!1),M=J(n,`oncalculate`,3,()=>{}),N=J(n,`panelActions`,19,()=>[]),ee=J(n,`showSaveButton`,3,!0),te=J(n,`showLoadButton`,3,!0),ne=J(n,`viewerConfig`,19,()=>({})),L=T(()=>({...uK,...n.presetLabels})),R=Z(null),re=Z(!1),B=T(()=>ee()||te()||N().length>0),ie=T(()=>k()||A()),ae=T(()=>n.schema.layout.type===`tabbed`?n.schema.layout.tabs.filter(e=>XB(e,n.values)):[]);le(()=>{if(n.schema.layout.type!==`tabbed`)return;let e={};n.schema.layout.tabs.forEach(t=>t.groups.forEach(t=>{let r=JB(t.items,n.values);t.items.forEach(t=>{if(t.type===`linebreak`)return;let{visible:i,disabled:a,defaultValue:o}=r[qB(t)],s=n.schema.inputs.find(e=>e.id===t.paramId);s&&o!==void 0&&(!i||a)&&n.values[s.id]!==o&&(e[s.id]=o)})})),Object.keys(e).length>0&&Object.assign(n.values,e)});let W=T(()=>C(ae).filter(e=>e.position!==`right`)),se=T(()=>C(ae).filter(e=>e.position===`right`)),ce=T(()=>C(W).length>0),Y=T(()=>C(se).length>0),ue=T(()=>n.showViewer||C(Y)),de=T(()=>!n.showViewer&&C(ce)&&C(Y)),X=Z(!1),me=Z(`closed`),he=[`closed`,`half`,`full`],ge=T(()=>C(W).length===1?C(W)[0].label:C(_).parametersTab),_e=Z(!1);le(()=>{let e=window.matchMedia(`(max-width: 639px)`),t=window.matchMedia(`(pointer: coarse) and (orientation: landscape) and (max-height: 500px)`);function n(){P(_e,t.matches,!0),P(X,e.matches||C(_e),!0)}return n(),e.addEventListener(`change`,n),t.addEventListener(`change`,n),()=>{e.removeEventListener(`change`,n),t.removeEventListener(`change`,n)}});let ve=Z(0),ye=T(()=>C(X)||!n.showViewer&&C(ve)>0&&C(ve)<900),be=Z(!1),xe=Z(!1),Se=Z(null),Ce=Z(null),we=Z(null),Te=Z(null),Ee=Z(null),De=Z(null),Oe=T(()=>C(de)?50:n.showViewer&&C(Y)?22:30),ke=T(()=>C(de)?50:25),Ae=T(()=>100-(C(ce)?C(Oe):0)-(C(Y)?C(ke):0)),je=T(()=>Math.round(C(Se)??C(Oe))),Me=T(()=>Math.round(100-(C(ce)?C(Se)??C(Oe):0)-(C(Ce)??C(ke)))),Ne=T(()=>`${C(ce)?`L`:``}${n.showViewer?`V`:``}${C(Y)?`R`:``}`);async function Pe(e){Object.assign(n.values,e),await n.onLoadValues?.(e)}let Fe={x:0,y:0};function Ie(e){if(C(_e)){P(me,e>0?`full`:`closed`,!0);return}let t=he.indexOf(C(me))+e;P(me,he[Math.max(0,Math.min(he.length-1,t))],!0)}function Le(e){Fe={x:e.touches[0].clientX,y:e.touches[0].clientY}}function Re(e){let t=C(_e)?e.changedTouches[0].clientX-Fe.x:e.changedTouches[0].clientY-Fe.y;Math.abs(t)>40&&(e.preventDefault(),Ie(t<0?1:-1))}function ze(){C(_e)?P(me,C(me)===`closed`?`full`:`closed`,!0):P(me,C(me)===`full`?`closed`:he[he.indexOf(C(me))+1],!0)}var Be=WK(),Ue=z(Be);let We;var Ke=I(Ue),qe=e=>{var r=u(),i=z(r),a=e=>{var r=RK(),i=z(r);let a;var o=I(i);{let e=T(()=>!C(_e)&&C(me)===`full`),t=T(()=>({...ne(),backgroundColor:n.schema?.viewerOptions?.backgroundColor??ne().backgroundColor,look:n.schema?.viewerOptions?.look??ne().look,camera:n.schema?.viewerOptions?.camera??ne().camera,showSceneManager:!1}));TF(o,{get meshes(){return v()},get drawerOpen(){return C(e)},get logoUrl(){return n.logoUrl},get onViewerReady(){return n.onViewerReady},get viewerConfig(){return C(t)},get isFullscreen(){return j()},set isFullscreen(e){j(e)}})}c(i);var s=U(i,2),u=I(s),d=U(I(u),2),h=K(d,!0),g=U(d,2),y=e=>{{let t=T(()=>C(me)===`closed`?``:`rotate-180`);ct(e,{size:16,get class(){return`text-muted-foreground transition-transform duration-300 ${C(t)??``}`}})}},b=e=>{{let t=T(()=>C(me)===`full`?`rotate-180`:``);lt(e,{size:16,get class(){return`ml-auto text-muted-foreground transition-transform duration-300 ${C(t)??``}`}})}};t(g,e=>{C(_e)?e(y):e(b,-1)}),c(u);var x=U(u,2),w=I(x),E=I(w),D=I(E),k=e=>{l(e,()=>C(Y)?`left`:void 0,()=>C(Ee),()=>!1)};t(D,e=>{C(ce)&&e(k)});var A=U(D,2),M=e=>{var t=LK(),n=z(t),r=U(I(n),2),i=K(r,!0);S(2),c(n);var a=U(n,2);l(a,()=>`right`,()=>C(De),()=>!1),G(()=>m(i,C(se)[0]?.label??C(_).moreTab)),O(e,t)};t(A,e=>{C(Y)&&e(M)}),c(E),c(w);var N=U(w,2);p(N,()=>C(me)===`closed`),c(x),c(s),G(()=>{a=fe(i,1,`viewer-region svelte-1kczbhm`,null,a,{"viewer-region-raised":C(me)!==`closed`}),fe(s,1,`drawer-container z-40 bg-background shadow-sheet drawer-${C(me)??``} ${C(_e)?`rounded-l-xl border-l`:`rounded-t-xl border-t`}`,`svelte-1kczbhm`),H(u,`aria-expanded`,C(me)!==`closed`),m(h,C(ge)),w.inert=C(me)===`closed`}),f(`click`,u,ze),f(`touchstart`,u,Le,void 0,!0),f(`touchend`,u,Re),O(e,r)},o=e=>{var n=zK(),r=I(n),i=I(r),a=e=>{l(e,()=>C(Y)?`left`:void 0,()=>C(Ee),()=>!1)};t(i,e=>{C(ce)&&e(a)});var o=U(i,2),s=e=>{var t=LK(),n=z(t),r=U(I(n),2),i=K(r,!0);S(2),c(n);var a=U(n,2);l(a,()=>`right`,()=>C(De),()=>!1),G(()=>m(i,C(se)[0]?.label??C(_).moreTab)),O(e,t)};t(o,e=>{C(Y)&&e(s)}),c(r);var u=U(r,2);p(u,()=>!1),c(n),O(e,n)};t(i,e=>{C(X)&&n.showViewer?e(a):e(o,-1)}),O(e,r)},Ye=e=>{var t=BK(),n=I(t),r=I(n);l(r,()=>C(Y)?`right`:void 0,()=>C(Y)?C(De):C(Ee)),c(n),c(t),O(e,t)},Ze=e=>{var r=UK(),i=I(r),a=e=>{rK(e,{side:`left`,get tabs(){return C(W)},collapsedWidth:48,onExpand:()=>C(we)?.expand(),onTabClick:e=>{P(Ee,e,!0),C(we)?.expand()}})};t(i,e=>{C(be)&&C(ue)&&C(ce)&&e(a)});var o=U(i,2);E(o,()=>Yc,(e,r)=>{r(e,{direction:`horizontal`,get autoSaveId(){return`selva-layout-${C(Ne)??``}`},class:`min-h-0 m-1 flex-1`,children:(e,r)=>{var i=HK(),a=z(i),o=e=>{var t=jK(),n=z(t);E(n,()=>Vc,(e,t)=>{F(t(e,{order:1,get defaultSize(){return C(Oe)},minSize:15,maxSize:45,collapsible:!0,collapsedSize:0,onCollapse:()=>P(be,!0),onExpand:()=>P(be,!1),onResize:e=>P(Se,e,!0),children:(e,t)=>{var n=VK(),r=I(n);l(r,()=>C(Y)?`left`:void 0,()=>C(Ee)),c(n),G(()=>fe(n,1,`min-h-0 flex h-full flex-col ${j()||C(be)?`hidden`:``}`)),O(e,n)},$$slots:{default:!0}}),e=>P(we,e,!0),()=>C(we))});var r=U(n,2);E(r,()=>qc,(e,t)=>{t(e,{withHandle:!0,line:!1,class:`translate-x-1.5 z-20`,get"data-collapsed"(){return C(be)},get"aria-valuenow"(){return C(je)},"aria-valuemin":0,"aria-valuemax":100,onclick:()=>{C(be)&&C(we)?.expand()}})}),O(e,t)};t(a,e=>{C(ce)&&e(o)});var s=U(a,2),d=e=>{var t=u(),r=z(t);E(r,()=>Vc,(e,t)=>{t(e,{order:2,get defaultSize(){return C(Ae)},minSize:20,class:`min-h-0 flex flex-col`,children:(e,t)=>{{let t=T(()=>({...ne(),backgroundColor:n.schema?.viewerOptions?.backgroundColor??ne().backgroundColor,look:n.schema?.viewerOptions?.look??ne().look,camera:n.schema?.viewerOptions?.camera??ne().camera}));TF(e,{get meshes(){return v()},get logoUrl(){return n.logoUrl},get onViewerReady(){return n.onViewerReady},get viewerConfig(){return C(t)},get isFullscreen(){return j()},set isFullscreen(e){j(e)}})}},$$slots:{default:!0}})}),O(e,t)};t(s,e=>{n.showViewer&&e(d)});var f=U(s,2),p=e=>{var r=jK(),i=z(r),a=e=>{var t=u(),n=z(t);E(n,()=>qc,(e,t)=>{t(e,{withHandle:!0,line:!1,class:`-translate-x-1.5 z-20`,get"data-collapsed"(){return C(xe)},get"aria-valuenow"(){return C(Me)},"aria-valuemin":0,"aria-valuemax":100,onclick:()=>{C(xe)&&C(Te)?.expand()}})}),O(e,t)};t(i,e=>{(n.showViewer||!C(ce))&&e(a)});var o=U(i,2);E(o,()=>Vc,(e,t)=>{F(t(e,{order:3,get defaultSize(){return C(ke)},minSize:15,maxSize:45,collapsible:!0,collapsedSize:0,onCollapse:()=>P(xe,!0),onExpand:()=>P(xe,!1),onResize:e=>P(Ce,e,!0),children:(e,t)=>{var n=VK(),r=I(n);l(r,()=>`right`,()=>C(De),()=>!C(ce)),c(n),G(()=>fe(n,1,`min-h-0 flex h-full flex-col ${j()||C(xe)?`hidden`:``}`)),O(e,n)},$$slots:{default:!0}}),e=>P(Te,e,!0),()=>C(Te))}),O(e,r)};t(f,e=>{C(Y)&&e(p)}),O(e,i)},$$slots:{default:!0}})});var s=U(o,2),d=e=>{rK(e,{side:`right`,get tabs(){return C(se)},collapsedWidth:48,onExpand:()=>C(Te)?.expand(),onTabClick:e=>{P(De,e,!0),C(Te)?.expand()}})};t(s,e=>{C(xe)&&C(Y)&&e(d)}),c(r),O(e,r)};t(Ke,e=>{C(ye)?e(qe):!n.showViewer&&!C(de)&&C(ce)!==C(Y)?e(Ye,1):e(Ze,-1)}),c(Ue);var Qe=U(Ue,2);F(TK(Qe,{get schema(){return n.schema},get currentValues(){return n.values},onLoadValues:Pe,get onSaveState(){return n.onSaveState},get onListStates(){return n.onListStates},get labels(){return n.presetLabels}}),e=>P(R,e,!0),()=>C(R)),G(()=>We=fe(Ue,1,`min-h-0 flex flex-1 flex-col overflow-hidden ${C(ye)?``:`sm:flex-row sm:py-2 ${C(be)?`sm:pl-0`:`sm:pl-2`} ${C(xe)?`sm:pr-0`:`sm:pr-2`}`}`,`svelte-1kczbhm`,We,{"fullscreen-layout":j(),relative:C(X),"mobile-root":C(ye),"side-sheet":C(X)&&C(_e)})),oe(Ue,`clientWidth`,e=>P(ve,e)),O(e,Be),b()}ce([`click`,`touchstart`,`touchend`]);function KK(e,t={}){let{SHOW_AFTER_MS:n,MIN_VISIBLE_MS:r,SLOW_AFTER_MS:i}=rl.SOLVING_INDICATOR;if(t.freezesDuringSolve)return{get show(){return e()},slow:!1};let a=Z(!1),o=Z(!1),s=0,c=null,l=null,u=null;function d(e){return e&&clearTimeout(e),null}function f(){u=null,P(a,!1),P(o,!1)}return le(()=>{let t=e();Y(()=>{if(t)u=d(u),C(a)||(c??=setTimeout(()=>{c=null,P(a,!0),s=performance.now()},n)),l??=setTimeout(()=>{l=null,P(o,!0)},i);else{if(c=d(c),l=d(l),!C(a))return;let e=r-(performance.now()-s);e>0?u??=setTimeout(f,e):f()}})}),le(()=>()=>{d(c),d(l),d(u)}),{get show(){return C(a)},get slow(){return C(o)}}}function qK(e,t,n){return eR(e,t,{...n,meshPolicy:Bj})}var JK=D(`<p class="bottom-4 text-xs fixed left-1/2 z-50 -translate-x-1/2 text-muted-foreground" data-testid="solve-esc-hint"> </p>`),YK=D(`<span class="text-xs shrink-0 text-muted-foreground tabular-nums"> </span>`),XK=D(` <kbd class="px-1 rounded-sm border border-border font-sans text-2xs opacity-70">Esc</kbd>`,1),ZK=D(`<span class="shrink-0 tabular-nums"> </span>`),QK=D(`<div class="mb-1 gap-2 text-xs flex justify-between text-muted-foreground"><span class="truncate"> </span> <!></div>`),$K=D(`<div class="h-full w-(--bar-width) rounded-full bg-primary transition-all duration-(--bar-ms) ease-linear"></div>`),eq=D(`<div class="animate-pulse h-full w-1/3 rounded-full bg-primary/60"></div>`),tq=D(`<div class="mt-2" data-testid="solve-progress"><!> <div class="h-1 overflow-hidden rounded-full bg-muted" role="progressbar"><!></div></div>`),nq=D(`<div><div><div class="gap-2 flex items-center"><!> <span class="min-w-0 text-sm flex-1 truncate"> </span> <!> <!></div> <!></div></div>`),rq=D(`<!> <!>`,1),iq=D(`<div class="mb-1.5 gap-2 flex items-center"><span> </span> <!></div>`),aq=D(`<!> `,1),oq=D(`<div class="mb-2"><div class="gap-2 text-sm font-medium flex items-center"><!></div> <p class="text-xs text-muted-foreground"> </p></div>`),sq=D(`<div><!></div>`),cq=D(`<div class="mt-3 gap-2 flex justify-end"><!></div>`),lq=D(`<div data-testid="solve-messages"><!> <!> <!></div>`),uq=D(`<div class="sr-only" role="status" aria-live="polite"> </div> <!>`,1);function dq(e,n){V(n,!0);let r=J(n,`diagnostics`,19,()=>[]),i=J(n,`freezesDuringSolve`,3,!1),o=J(n,`placement`,3,`floating`),s=J(n,`progressShownByHost`,3,!1),l=at(),d=T(()=>l.messages),f=wR(()=>n.live),h=T(()=>f.progress),g=T(()=>f.bars),_=T(()=>f.headline),v=T(()=>r().filter(e=>e.isGate)),y=T(()=>C(v).filter(e=>e.level!==`remark`)),x=T(()=>C(v).filter(e=>e.level===`remark`)),w=Z(null),E=T(()=>n.phase===`solving`?`live`:n.phase===`blocked`&&C(w)===r()?`idle`:n.phase),D=Z(!1),k=null,A=new Set,M=Z([]),F=e=>`${e.source??``}\u0000${e.message}`;le(()=>{if(C(E)===`live`){P(D,!1);return}if(k===r())return;k=r();let e=C(x).map(F).filter(e=>A.has(e)),t=C(x).filter(e=>!A.has(F(e))),n=C(E)===`idle`&&t.length>0;if(A=new Set(n?[...e,...t.map(F)]:e),!n)return;P(M,t),P(D,!0);let i=setTimeout(()=>P(D,!1),6e3);return()=>clearTimeout(i)});let ee=Z(!1),te=Z(!1),ne=0;le(()=>{if(C(E)===`live`){if(P(te,!1),i())return;let e=setTimeout(()=>{P(ee,!0),ne=performance.now()},300);return()=>clearTimeout(e)}if(!Y(()=>C(ee))||C(E)!==`idle`){P(ee,!1),P(te,!1);return}P(te,!0);let e=Math.max(200,400-(performance.now()-ne)),t=setTimeout(()=>{P(ee,!1),P(te,!1)},e);return()=>clearTimeout(t)});let L=T(()=>C(te)?`live`:C(E)),R=T(()=>C(L)===`live`?[...n.live.diagnostics]:C(L)===`idle`?C(M):C(y)),re=T(()=>C(R).map(e=>({severity:e.level===`remark`?`note`:e.level,message:e.message,source:e.source}))),B=T(()=>C(L)===`review`||C(L)===`blocked`?!0:C(L)===`live`?C(ee)&&(C(R).length>0||!s()&&C(h).length>0):C(R).length>0&&C(D)),ie=T(()=>C(B)?C(L)===`live`?(C(_)??C(h)[0])?.label??C(d).solveSolving:C(L)===`idle`?C(R).map(e=>e.message).join(` `):``:``);function ae(){P(w,r())}function W(e){e.key===`Escape`&&(C(E)===`live`?i()||n.onabort():C(E)===`review`?n.ondiscard():C(E)===`blocked`&&ae())}var oe=uq();j(`keydown`,de,W);var se=z(oe),ce=K(se,!0),q=U(se,2),ue=e=>{var n=u(),r=z(n),i=e=>{var t=JK(),n=K(t,!0);G(()=>m(n,C(d).solveMessagesEscHint)),O(e,t)};t(r,e=>{o()===`floating`&&e(i)}),O(e,n)},X=e=>{var r=lq(),i=I(r),l=e=>{let r=T(()=>C(_)??C(h)[0]);var i=nq(),o=I(i),s=I(o),l=I(s);_t(l,{class:`h-4 w-4 animate-spin shrink-0 text-muted-foreground`});var u=U(l,2),f=K(u,!0),p=U(u,2),v=e=>{var t=YK(),n=K(t);G(()=>m(n,`${C(r).done??``} / ${C(r).total??``}`)),O(e,t)};t(p,e=>{C(r)?.done!==void 0&&C(r)?.total!==void 0&&e(v)});var y=U(p,2);tt(y,{variant:`secondary`,size:`xs`,class:`-my-1 shrink-0`,get disabled(){return C(te)},get onclick(){return n.onabort},"aria-keyshortcuts":`Escape`,get title(){return C(d).solveMessagesEscHint},children:(e,t)=>{S();var n=XK(),r=z(n);S(),G(()=>m(r,`${C(d).solveMessagesAbort??``} `)),O(e,n)},$$slots:{default:!0}}),c(s);var b=U(s,2);a(b,19,()=>C(h),e=>e.source??``,(e,n,r)=>{var i=tq(),a=I(i),o=e=>{var r=QK(),i=I(r),a=K(i,!0),o=U(i,2),s=e=>{var t=ZK(),r=K(t);G(()=>m(r,`${C(n).done??``} / ${C(n).total??``}`)),O(e,t)};t(o,e=>{C(n).done!==void 0&&C(n).total!==void 0&&e(s)}),c(r),G(()=>m(a,C(n).label??C(n).source??``)),O(e,r)};t(a,e=>{C(r)>0&&e(o)});var s=U(a,2);H(s,`aria-valuemin`,0),H(s,`aria-valuemax`,100);var l=I(s),u=e=>{let t=T(()=>C(te)?{width:1,ms:200}:C(g)[C(n).source??``]??{width:C(n).fraction,ms:150});var r=$K();let i;G(()=>i=N(r,``,i,{"--bar-width":`${C(t).width*100}%`,"--bar-ms":`${C(t).ms??``}ms`})),O(e,r)},f=e=>{var t=eq();O(e,t)};t(l,e=>{C(n).fraction===void 0?e(f,-1):e(u)}),c(s),c(i),G(e=>{H(s,`aria-label`,C(n).label??C(n).source??C(d).solveSolving),H(s,`aria-valuenow`,e)},[()=>C(n).fraction===void 0?void 0:Math.round(C(n).fraction*100)]),O(e,i)}),c(o),c(i),G(()=>m(f,C(r)?.label??C(d).solveSolving)),O(e,i)},u=e=>{var r=iq(),i=I(r),a=K(i,!0),o=U(i,2),s=e=>{tt(e,{variant:`ghost`,size:`xs`,class:`-my-1 shrink-0`,onclick:ae,children:(e,t)=>{S();var n=p();G(()=>m(n,C(d).solveMessagesDismiss)),O(e,n)},$$slots:{default:!0}})},l=e=>{var t=rq(),r=z(t);tt(r,{variant:`ghost`,size:`xs`,class:`-my-1 shrink-0`,get onclick(){return n.ondiscard},children:(e,t)=>{S();var n=p();G(()=>m(n,C(d).solveMessagesDiscard)),O(e,n)},$$slots:{default:!0}});var i=U(r,2);tt(i,{size:`xs`,class:`-my-1 shrink-0`,get onclick(){return n.onconfirm},children:(e,t)=>{S();var n=p();G(()=>m(n,C(d).solveMessagesConfirm)),O(e,n)},$$slots:{default:!0}}),O(e,t)};t(o,e=>{C(L)===`blocked`?e(s):e(l,-1)}),c(r),G(()=>{fe(i,1,`min-w-0 text-xs font-medium flex-1 truncate ${C(L)===`blocked`?`text-destructive`:`text-muted-foreground`}`),m(a,C(L)===`blocked`?C(d).solveBlockedTitle:C(d).solveMessagesTitle)}),O(e,r)},f=e=>{var n=oq(),r=I(n),i=I(r),a=e=>{var t=aq(),n=z(t);Ue(n,{severity:`error`});var r=U(n);G(()=>m(r,` ${C(d).solveBlockedTitle??``}`)),O(e,t)},o=e=>{var t=aq(),n=z(t);Ue(n,{severity:`warning`});var r=U(n);G(()=>m(r,` ${C(d).solveMessagesTitle??``}`)),O(e,t)};t(i,e=>{C(L)===`blocked`?e(a):e(o,-1)}),c(r);var s=U(r,2),l=K(s,!0);c(n),G(()=>m(l,C(L)===`blocked`?C(d).solveBlocked:C(d).solveMessagesDescription)),O(e,n)};t(i,e=>{C(L)===`live`&&!s()?e(l):(C(L)===`review`||C(L)===`blocked`)&&o()===`inline`?e(u,1):(C(L)===`review`||C(L)===`blocked`)&&e(f,2)});var v=U(i,2),y=e=>{var t=sq(),n=I(t);We(n,{get issues(){return C(re)},variant:`plain`}),c(t),G(()=>fe(t,1,`max-h-40 overflow-y-auto ${C(L)===`live`&&!s()?`mt-3 pt-3 border-t`:``}`)),O(e,t)};t(v,e=>{C(R).length>0&&e(y)});var b=U(v,2),x=e=>{var r=cq(),i=I(r),a=e=>{tt(e,{variant:`outline`,size:`sm`,onclick:ae,children:(e,t)=>{S();var n=p();G(()=>m(n,C(d).solveMessagesDismiss)),O(e,n)},$$slots:{default:!0}})},o=e=>{var t=rq(),r=z(t);tt(r,{variant:`outline`,size:`sm`,get onclick(){return n.ondiscard},children:(e,t)=>{S();var n=p();G(()=>m(n,C(d).solveMessagesDiscard)),O(e,n)},$$slots:{default:!0}});var i=U(r,2);tt(i,{size:`sm`,get onclick(){return n.onconfirm},children:(e,t)=>{S();var n=p();G(()=>m(n,C(d).solveMessagesConfirm)),O(e,n)},$$slots:{default:!0}}),O(e,t)};t(i,e=>{C(L)===`blocked`?e(a):e(o,-1)}),c(r),O(e,r)};t(b,e=>{(C(L)===`review`||C(L)===`blocked`)&&o()===`floating`&&e(x)}),c(r),G(()=>{fe(r,1,me(o()===`inline`?`px-2 py-2 border-t ${C(L)===`blocked`?`border-destructive/40`:`border-border`}`:`p-3 bottom-4 shadow-lg w-lg fixed left-1/2 z-50 max-w-screen-inset -translate-x-1/2 rounded-lg border bg-background ${C(L)===`blocked`?`border-destructive/50`:``}`)),H(r,`role`,C(L)===`review`||C(L)===`blocked`?`alert`:void 0),H(r,`data-view`,C(L))}),O(e,r)};t(q,e=>{i()&&C(L)===`live`?e(ue):C(B)&&e(X,1)}),G(()=>m(ce,C(ie))),O(e,oe),b()}function fq(e){let t=ZL(e),n=Z(0);le(()=>{let e=t.subscribe(()=>{P(n,C(n)+1)});return()=>{e(),t.dispose()}});function r(e){return C(n),e()}return{get values(){return r(()=>t.values)},get error(){return r(()=>t.error)},get computeErrors(){return r(()=>t.computeErrors)},get computeWarnings(){return r(()=>t.computeWarnings)},get diagnostics(){return r(()=>t.diagnostics)},get blocked(){return r(()=>t.blocked)},get awaitingAck(){return r(()=>t.awaitingAck)},get live(){return r(()=>t.live)},get phase(){return r(()=>t.phase)},abort:()=>t.abort(),get meshes(){return r(()=>t.meshes)},get files(){return r(()=>t.files)},makeFiles:()=>t.makeFiles(),cancelFiles:()=>t.cancelFiles(),get lastResult(){return r(()=>t.lastResult)},get hasPendingChanges(){return r(()=>t.hasPendingChanges)},get hasNeverSolved(){return r(()=>t.hasNeverSolved)},get isSolving(){return r(()=>t.isSolving)},acknowledge:()=>t.acknowledge(),discard:()=>t.discard(),setValue:(e,n,r)=>t.setValue(e,n,r),solve:()=>t.solve(),ensureSolved:()=>t.ensureSolved(),onSettled:e=>t.onSettled(e),loadValues:e=>t.loadValues(e),rebuild:(e,n)=>t.rebuild(e,n),report:e=>t.report(e),reportError:e=>t.reportError(e),reportAborted:()=>t.reportAborted(),subscribe:e=>t.subscribe(e),notify:()=>t.notify(),dispose:()=>t.dispose()}}function pq(e){_(()=>{let t=s(ve);t&&e.component&&t.register(e)}),g(()=>{try{s(ve)?.unregister(e.id)}catch{}})}var mq=e=>{if(!e)return``;let t=e.replace(/^#/,``);if(!/^[0-9A-Fa-f]{6}$/.test(t))return e;let n=parseInt(t.slice(0,2),16)/255,r=parseInt(t.slice(2,4),16)/255,i=parseInt(t.slice(4,6),16)/255,a=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,o=a(n),s=a(r),c=a(i),l=o*.4124564+s*.3575761+c*.1804375,u=o*.2126729+s*.7151522+c*.072175,d=o*.0193339+s*.119192+c*.9503041,f=Math.cbrt(.8189330101*l+.3618667424*u-.1288597137*d),p=Math.cbrt(.0329845436*l+.9293118715*u+.0361456387*d),m=Math.cbrt(.0482003018*l+.2643662691*u+.633851707*d),h=.2104542553*f+.793617785*p-.0040720468*m,g=1.9779984951*f-2.428592205*p+.4505937099*m,_=.0259040371*f+.7827717662*p-.808675766*m,v=Math.sqrt(g*g+_*_),y=Math.atan2(_,g)*180/Math.PI;return y<0&&(y+=360),`oklch(${h.toFixed(3)} ${v.toFixed(3)} ${y.toFixed(1)})`},hq={1:.0254,2:.3048,3:1609.344,4:.001,5:.01,6:1,7:1e3,8:2.54e-8,9:254e-7,10:.9144,11:1e-10,12:1e-9,13:1e-6,14:.1,15:10,16:100,17:1e9},gq=1,_q=8,vq=80,yq=16;function bq(e){let t=e.split(/\r\n|\r|\n/),n=[];for(let e=0;e+1<t.length;e+=2){let r=Number.parseInt(t[e],10);Number.isNaN(r)||n.push({code:r,value:t[e+1].trim()})}return n}var xq=(e,t)=>e.filter(e=>e.code===t).map(e=>Number.parseFloat(e.value)),Sq=(e,t,n=0)=>{let r=xq(e,t)[0];return Number.isFinite(r)?r:n},Cq=(e,t)=>[Sq(e,t),Sq(e,t+10),Sq(e,t+20)];function wq(e){let t=jH([Sq(e,210),Sq(e,220),Sq(e,230,1)])??[0,0,1],n=jH(kH(Math.abs(t[0])<1/64&&Math.abs(t[1])<1/64?[0,1,0]:[0,0,1],t))??[1,0,0];return{x:n,y:kH(t,n),normal:t}}var Tq=(e,[t,n,r])=>EH(EH(OH(e.x,t),OH(e.y,n)),OH(e.normal,r));function Eq(e,t,n){if(e.length<2)return null;let r=e.map(e=>e.point);if(!e.some((e,n)=>e.bulge!==0&&(t||n<r.length-1)))return{kind:`polyline`,points:r,closed:t&&r.length>2};let i=[],a=t?r.length:r.length-1;for(let t=0;t<a;t++)i.push(...QH(r[t],r[(t+1)%r.length],e[t].bulge,n));return $H(i)}function Dq(e){let t=wq(e),n=Sq(e,38),r=[];for(let{code:t,value:n}of e){let e=Number.parseFloat(n);t===10?r.push({x:e,y:0,bulge:0}):t===20&&r.length?r[r.length-1].y=e:t===42&&r.length&&(r[r.length-1].bulge=e)}return Eq(r.map(e=>({point:Tq(t,[e.x,e.y,n]),bulge:e.bulge})),(Sq(e,70)&gq)!==0,t.normal)}function Oq(e,t){let n=Sq(e,70);if(n&vq)return null;let r=(n&_q)!==0,i=wq(e),a=Sq(e,30);return Eq(t.filter(e=>(Sq(e,70)&yq)===0).map(e=>({point:r?Cq(e,10):Tq(i,[Sq(e,10),Sq(e,20),a]),bulge:r?0:Sq(e,42)})),(n&gq)!==0,i.normal)}function kq(e){let t=xq(e,10),n=xq(e,20),r=xq(e,30),i=t.map((e,t)=>[e,n[t]??0,r[t]??0]),a=Sq(e,71,3);if(i.length<a+1||a<1)return null;let o=xq(e,40);o.length!==i.length+a+1&&(o=MH(i.length,a));let s=xq(e,41),c=s.length===i.length&&s.some(e=>e!==1);return{kind:`nurbs`,degree:a,points:i,knots:o,...c?{weights:s}:{}}}function Aq(e,t){let n=wq(e),r=Sq(e,40);if(!(r>0))return null;let i=t?0:Sq(e,50)*Math.PI/180,a=t?2*Math.PI:Sq(e,51)*Math.PI/180-i;for(;a<=0;)a+=2*Math.PI;return eU(Tq(n,Cq(e,10)),n.x,n.y,r,i,a)}function jq(e){if(e.startsWith(`AutoCAD Binary DXF`))throw Error(`Binary DXF is not supported: save the file as ASCII DXF.`);let t=bq(e),n={items:[],metersPerUnit:null,skipped:{}},r=e=>{n.skipped[e]=(n.skipped[e]??0)+1},i=(e,t)=>{t&&UH(t)?n.items.push(t):r(e)},a=``,o=0,s=()=>{let e=o++;for(;o<t.length&&t[o].code!==0;)o++;return t.slice(e,o)};for(;o<t.length;){let e=t[o];if(e.code===9&&e.value===`$INSUNITS`&&a===`HEADER`){n.metersPerUnit=hq[Number.parseInt(t[o+1]?.value??``,10)]??null,o++;continue}if(e.code!==0){o++;continue}if(e.value===`SECTION`){a=t[o+1]?.code===2?t[o+1].value:``,o+=2;continue}if(e.value===`ENDSEC`){a=``,o++;continue}if(a!==`ENTITIES`){o++;continue}let c=s(),l=c[0].value;switch(l){case`POINT`:i(l,{kind:`point`,at:Cq(c,10)});break;case`LINE`:i(l,{kind:`line`,from:Cq(c,10),to:Cq(c,11)});break;case`LWPOLYLINE`:i(l,Dq(c));break;case`POLYLINE`:{let e=[];for(;o<t.length&&t[o].value===`VERTEX`;)e.push(s());t[o]?.value===`SEQEND`&&s(),i(l,Oq(c,e));break}case`SPLINE`:i(l,kq(c));break;case`ARC`:i(l,Aq(c,!1));break;case`CIRCLE`:i(l,Aq(c,!0));break;default:r(l)}}return n}var Mq=e=>[e[0],e[1],e[2]],Nq=e=>[e[0],e[1],e[2]];function Pq(e){return typeof e==`object`&&!!e&&typeof e.data==`string`&&`archive3dm`in e}function Fq(e,t){if(t.kind===`line`)return new e.LineCurve(Nq(t.from),Nq(t.to));if(t.kind===`polyline`){let n=t.points.map(Nq);return t.closed&&n.push(Nq(t.points[0])),new e.PolylineCurve(n)}let{degree:n,points:r,weights:i,knots:a}=t,o=new e.NurbsCurve(3,i!==void 0,n+1,r.length),s=o.points();r.forEach((e,t)=>{let n=i?.[t]??1;s.set(t,[e[0]*n,e[1]*n,e[2]*n,n])});let c=o.knots();for(let e=1;e<a.length-1;e++)c.set(e-1,a[e]);return o}function Iq(e,t){if(!UH(t))throw Error(`Cannot encode an invalid ${t.kind}.`);let n=t.kind===`point`?new e.Point(Nq(t.at)):Fq(e,t);try{for(let[e,r]of Object.entries(t.attributes??{}))n.setUserString(e,r);return n.encode()}finally{n.delete()}}var Lq=([e,t,n])=>({X:e,Y:t,Z:n});function Rq(e){return Lq(e.at)}function zq(e){return{From:Lq(e.from),To:Lq(e.to)}}var Bq=(e,t)=>e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2];function Vq(e){let t=e.order-1,n=e.points(),r=[],i=[];for(let e=0;e<n.count;e++){let[t,a,o,s]=n.get(e);r.push([t/s,a/s,o/s]),i.push(s)}if(t===1){let e=r.length>3&&Bq(r[0],r[r.length-1]);return{kind:`polyline`,points:e?r.slice(0,-1):r,closed:e}}let a=e.knots(),o={kind:`nurbs`,degree:t,points:r,knots:[a.superfluousKnot(!0),...a.toList(),a.superfluousKnot(!1)]};return e.isRational?{...o,weights:i}:o}function Hq(e,t){if(t instanceof e.LineCurve){let{from:e,to:n}=t.line;return{kind:`line`,from:Mq(e),to:Mq(n)}}if(t instanceof e.PolylineCurve){let e=[];for(let n=0;n<t.pointCount;n++)e.push(Mq(t.point(n)));let n=e.length>3&&Bq(e[0],e[e.length-1]);return{kind:`polyline`,points:n?e.slice(0,-1):e,closed:n}}if(t instanceof e.NurbsCurve)return Vq(t);let n=t.toNurbsCurve();if(!n)return null;try{return Vq(n)}finally{n.delete()}}function Uq(e,t){let n=null;if(t instanceof e.Point?n={kind:`point`,at:Mq(t.location)}:t instanceof e.Curve&&(n=Hq(e,t)),!n||!UH(n))return null;let r=t.getUserStrings();return r.length>0?{...n,attributes:Object.fromEntries(r)}:n}function Wq(e,t){let n;try{n=e.CommonObject.decode(t)}catch{return null}if(!n)return null;try{return Uq(e,n)}finally{n.delete?.()}}var Gq=e=>{let{X:t,Y:n,Z:r}=e??{};return[t,n,r].every(e=>typeof e==`number`&&Number.isFinite(e))?[t,n,r]:null};function Kq(e){let t=Gq(e);return t?{kind:`point`,at:t}:null}function qq(e){let{From:t,To:n}=e??{},r=Gq(t),i=Gq(n),a=r&&i?{kind:`line`,from:r,to:i}:null;return a&&WH(a)?a:null}function Jq(e,t){let n=e.UnitSystem;return[[n.Angstroms,1e-10],[n.Nanometers,1e-9],[n.Microns,1e-6],[n.Millimeters,.001],[n.Centimeters,.01],[n.Decimeters,.1],[n.Meters,1],[n.Dekameters,10],[n.Hectometers,100],[n.Kilometers,1e3],[n.Megameters,1e6],[n.Gigameters,1e9],[n.Microinches,2.54e-8],[n.Mils,254e-7],[n.Inches,.0254],[n.Feet,.3048],[n.Yards,.9144],[n.Miles,1609.344],[n.NauticalMiles,1852]].find(([e])=>e===t)?.[1]??null}function Yq(e,t){let n=e.File3dm.fromByteArray(t);if(!n)throw Error(`Not a readable .3dm file.`);try{let t={items:[],metersPerUnit:Jq(e,n.settings().modelUnitSystem),skipped:0},r=n.objects();for(let n=0;n<r.count;n++){let i=Uq(e,r.get(n).geometry());i?t.items.push(i):t.skipped++}return t}finally{n.delete()}}async function Xq(e,t){let n=e.name.slice(e.name.lastIndexOf(`.`)).toLowerCase();if(!(n===`.dxf`||n===`.3dm`&&t!==null))throw new xU(`unsupported`);try{if(n===`.3dm`&&t)return Yq(await t(),new Uint8Array(await e.arrayBuffer()));let r=jq(await e.text());return{...r,skipped:Object.values(r.skipped).reduce((e,t)=>e+t,0)}}catch{throw new xU(`unreadable`)}}async function Zq(e,t,n){let{items:r,metersPerUnit:i,skipped:a}=await Xq(e,n);if(r.length>2e3)throw new xU(`tooMany`);let o=i===null?1:i/t;return{items:r.map(e=>HH(e,o)),skipped:a}}var Qq=e=>{if(e==null||e===``)return[];if(typeof e==`string`){let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return[];try{return Qq(JSON.parse(t))}catch{return[]}}return Array.isArray(e)?e.flatMap(Qq):typeof e==`object`?[e]:[]},$q=e=>!e||e.length===1&&e[0]===0;function eJ(e){if(typeof e==`string`){let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`))return[];try{return eJ(JSON.parse(t))}catch{return[]}}if(e&&typeof e==`object`&&!Array.isArray(e)){let t=Object.entries(e).map(([e,t])=>[IH(e),t]);if(t.length>0&&t.every(([e])=>e!==null))return t.map(([e,t])=>({path:$q(e)?void 0:e,items:Qq(t)}))}let t=Qq(e);return t.length>0?[{path:void 0,items:t}]:[]}function tJ(e){return eJ(e).some(e=>e.items.some(Pq))}function nJ(e,t){let n=[];for(let{path:r,items:i}of eJ(e))for(let e of i){let i=Pq(e)?t&&Wq(t,e):qq(e)??Kq(e);i&&n.push(r?{...i,path:r}:i)}return n}function rJ(e,t,n){let r,i;if(t===`line`)r=GH(e),i=e=>zq(e);else if(t===`point`)r=e.filter(wH),i=e=>Rq(e);else{if(!n)return null;r=e,i=e=>Iq(n,e)}return r.length===0?null:r.every(e=>$q(e.path))?r.map(i):Object.fromEntries([...LH(r)].map(([e,t])=>[e,t.map(i)]))}var iJ={Microns:`µm`,Millimeters:`mm`,Centimeters:`cm`,Decimeters:`dm`,Meters:`m`,Kilometers:`km`,Inches:`in`,Feet:`ft`,Yards:`yd`,Miles:`mi`};function aJ(e){let t=e?CP[e]:void 0;return t===void 0?null:{metersPerUnit:t,suffix:iJ[e]??``}}var oJ={mode:null,pendingPoints:0,typed:``,canUndo:!1,canRedo:!1},sJ=class{#e=Z([]);get items(){return C(this.#e)}set items(e){P(this.#e,e)}#t=Z(oJ);get state(){return C(this.#t)}set state(e){P(this.#t,e)}tool=null;synced=void 0;revision=0};function cJ(e,t){return t.paramType===`line`?GH(e):e.filter(e=>wH(e)&&t.kinds.includes(`point`)||TH(e)&&t.kinds.includes(`curve`))}function lJ(e){let t=Z(null),n=Z(0),r=Z(!0),i=T(()=>e.modelUnits()),a=T(()=>aJ(C(i))),o=new Map,s=e=>{let t=o.get(e);return t||o.set(e,t=new sJ),t},c=t=>e.inputs().find(e=>e.id===t),l=e.loadRhino,u=null,d=l?()=>(u??=l(),u.catch(()=>{u=null}),u):null;function f(t,n){let r=++n.revision,i=i=>{n.revision===r&&(n.synced=i,e.setValue(t.id,i))};t.paramType!==`geometry`||n.items.length===0?i(rJ(n.items,t.paramType,null)):d&&d().then(e=>i(rJ(n.items,t.paramType,e)),()=>e.onEncodeError?.())}function p(e,t){e.synced=t;let n=++e.revision,r=t=>{e.revision===n&&(e.items=t,e.tool?.setItems(t))};!d||!tJ(t)?r(nJ(t,null)):d().then(e=>r(nJ(t,e)),()=>r([]))}function m(e,t){let n=s(e.id);n.tool?.cancel(),n.items=t,n.tool?.setItems(t),f(e,n)}function h(){for(let e of o.values())e.tool?.dispose(),e.tool=null,e.state=oJ}function g(){if(h(),C(t)&&C(a))for(let i of e.inputs()){let e=s(i.id);e.tool=yU({viewer:C(t),id:i.id,metersPerUnit:C(a).metersPerUnit,unitSuffix:C(a).suffix,name:i.name,maxItems:i.atMost,settings:{gridStep:C(n),showDimensions:C(r)},onChange:t=>{e.items=t,f(i,e)},onStateChange:t=>{e.state=t}}),e.tool.setItems(e.items)}}le(()=>(C(a),e.inputs(),Y(g),h)),le(()=>{let e={gridStep:C(n),showDimensions:C(r)};for(let t of o.values())t.tool?.configure(e)}),le(()=>{for(let t of e.inputs()){let n=s(t.id),r=e.getValue(t.id);r!==n.synced&&Y(()=>p(n,r))}});let _=e=>{let t=c(e);return!t||t.kinds.length===0?!1:t.paramType!==`geometry`||d!==null};return{get canDraw(){return C(t)!==null&&C(a)!==null},get canImport(){return C(a)!==null},get unitSuffix(){return C(a)?.suffix??``},get importAccept(){return d?`.dxf,.3dm`:`.dxf`},get gridStep(){return C(n)},set gridStep(e){P(n,Number.isFinite(e)&&e>0?e:0,!0)},get showDimensions(){return C(r)},set showDimensions(e){P(r,e,!0)},supports:_,kinds:e=>c(e)?.kinds??[],view:e=>s(e),getItems:e=>s(e).items,setItems:(e,t)=>{let n=c(e);n&&_(e)&&m(n,cJ(t,n).slice(0,n.atMost))},draw:(e,t)=>{c(e)?.paramType===`geometry`&&d?.().catch(()=>{}),s(e).tool?.draw(t)},move:e=>s(e).tool?.move(),finish:e=>s(e).tool?.finish(),undo:e=>s(e).tool?.undo(),redo:e=>s(e).tool?.redo(),reset:t=>{s(t).tool?.cancel(),e.setValue(t,e.getDefault(t)??null)},importFile:async(e,t)=>{let n=c(e);if(!n||!C(a))throw Error(`The input is not ready for an import.`);let r=await Zq(t,C(a).metersPerUnit,d),i=cJ(r.items,n),o=i.slice(0,n.atMost);return m(n,o),{items:[...o],skipped:r.skipped+(n.paramType===`line`?0:r.items.length-i.length),overLimit:i.length-o.length}},attachViewer:e=>(P(t,e),g(),()=>{C(t)===e&&(h(),P(t,null))})}}var uJ=D(`<div class="min-h-100 p-8 flex items-center justify-center"><!></div>`),dJ=D(`<div class="min-h-100 flex items-center justify-center"><!></div>`),fJ=D(`<div class="contents"><!></div> <!>`,1);function pJ(e,n){V(n,!0);let r=J(n,`definitionKey`,3,``),i=J(n,`showModeToggle`,3,!1),a=J(n,`panelActions`,19,()=>[]),o=J(n,`showSaveButton`,3,!0),s=J(n,`showLoadButton`,3,!0),l=J(n,`footerItemId`,3,`footer-item`),d=J(n,`footerItemPriority`,3,0),f=J(n,`viewerConfig`,19,()=>({}));LU(n.clientSlot);let p=rt(()=>n.lang,()=>n.messages),m=T(()=>p.messages),h=T(()=>n.externalScopeKey||r()||n.schema?.id||``),g=qK(n.onSolve,()=>_,{solveDeadlineMs:n.solveDeadlineMs,onChange:()=>_.notify(),events:n.events,timeoutMessage:e=>nt(C(m).solveTimedOut,{seconds:e})}),_=fq({schema:n.schema,scopeKey:n.externalScopeKey||r()||n.schema?.id||``,driver:g});YW({get files(){return _.files},get isSolving(){return _.isSolving},make:()=>_.makeFiles(),cancel:()=>_.cancelFiles()});let v=T(()=>(n.schema?.inputs??[]).flatMap(e=>{let t=ZU(e);return t.length>0?[{id:e.id,paramType:e.paramType,kinds:t,name:e.nickname,atMost:e.atMost}]:[]})),y=lJ({loadRhino:n.loadRhino,inputs:()=>C(v),getValue:e=>_.values[e],setValue:(e,t)=>_.setValue(e,t),getDefault:e=>n.schema?.inputs.find(t=>t.id===e)?.default,modelUnits:()=>_.lastResult?.source?.modelunits,onEncodeError:()=>Cn.error(C(m).curveEncodeFailed)});UU(y);function x(e){let t=y.attachViewer(e),r=n.onViewerReady?.(e);return()=>{r?.(),t()}}let S=Z(!1),w=KK(()=>_.isSolving);le(()=>_.onSettled(e=>n.onSolved?.(e))),le(()=>{n.onReady?.({loadValues:e=>_.loadValues(e),getLastResult:()=>_.lastResult,getSession:()=>_,getSketch:()=>y})});let E=Z(``),D=Z(!0);le(()=>{r(),Y(()=>{C(D)?(P(D,!1),P(E,r()),n.schema?.instanceSolve!==!1&&_.solve()):C(E)!==r()&&(_.rebuild(n.schema,C(h)),P(E,r()))})});function k(e,t,n=!1){_.setValue(e,t,n)}function A(){_.solve()}pq({id:Y(()=>l()),component:Y(()=>n.footerComponent),getProps:()=>n.footerComponentProps?.()??{},position:`left`,priority:Y(()=>d())});let j=T(()=>n.isEmbedded??Pe.url.searchParams.get(`embed`)===`true`),M=T(()=>n.primaryColor??Pe.url.searchParams.get(`primary`)),F=T(()=>C(M)?mq(C(M)):void 0),ee=T(()=>n.title??(n.schema?.description||n.schema.name)),te=T(()=>_.error?[{level:`error`,message:_.error},..._.diagnostics]:_.diagnostics);var ne=fJ(),L=z(ne);let R;var re=I(L);{let e=T(()=>!C(j));Ke(re,{mode:`fixed`,get showHeader(){return C(e)},showFooter:!0,get title(){return C(ee)},get showModeToggle(){return i()},get navItems(){return n.navItems},get homeUrl(){return n.homeUrl},get brandName(){return n.brandName},get copyrightName(){return n.copyrightName},get footerText(){return n.footerText},get header(){return n.header},get rightContent(){return n.headerRight},get errors(){return _.computeErrors},get warnings(){return _.computeWarnings},get diagnostics(){return C(te)},children:(e,i)=>{var l=u(),d=z(l),p=e=>{var t=uJ();Zc(I(t),{type:`error`,size:`medium`,get message(){return _.error}}),c(t),O(e,t)},h=e=>{var t=dJ();Zc(I(t),{type:`loading`,size:`large`,get message(){return C(m).loadingSchema}}),c(t),O(e,t)},g=e=>{var t=u(),i=z(t);ae(i,r,e=>{{let t=T(()=>!!n.schema.viewerOptions?.enableRemote);GK(e,{get schema(){return n.schema},get showViewer(){return C(t)},get meshes(){return _.meshes},get isSolving(){return _.isSolving},get showSolvingIndicator(){return w.show},get solveIsSlow(){return w.slow},get live(){return _.live},onabort:()=>_.abort(),get hasPendingChanges(){return _.hasPendingChanges},get hasNeverSolved(){return _.hasNeverSolved},get values(){return _.values},get logoUrl(){return n.logo},onViewerReady:x,get viewerConfig(){return f()},get panelActions(){return a()},get primaryAction(){return n.primaryAction},get showSaveButton(){return o()},get showLoadButton(){return s()},get onSaveState(){return n.onSaveState},get onListStates(){return n.onListStates},get presetLabels(){return n.presetLabels},onValueChange:k,oncalculate:A,ensureSolved:()=>_.ensureSolved(),onLoadValues:()=>_.loadValues({}),get isViewerFullscreen(){return C(S)},set isViewerFullscreen(e){P(S,e,!0)}})}}),O(e,t)};t(d,e=>{_.error&&!n.schema?e(p):n.schema?e(g,-1):e(h,1)}),O(e,l)},$$slots:{default:!0}})}c(L);var B=U(L,2);{let e=T(()=>n.schema?.instanceSolve!==!1);dq(B,{get live(){return _.live},get phase(){return _.phase},get diagnostics(){return _.diagnostics},onabort:()=>_.abort(),onconfirm:()=>_.acknowledge(),ondiscard:()=>_.discard(),get progressShownByHost(){return C(e)}})}G(()=>R=N(L,``,R,{"--primary":C(F)})),O(e,ne),b()}var mJ=`selva:saved-values`,hJ=[2e3,4e3,8e3,15e3,3e4,3e4,3e4];function gJ(e,t,n){let r=new Map(e.inputs.map(e=>[e.id,e])),i={};for(let e of t.inputs){let t=r.get(e.id);if(!t||!(e.id in n)||e.default===void 0||_J(e.default,t.default))continue;let a=t.default??HF(t.paramType);_J(n[e.id],a)&&(i[e.id]=e.default)}return i}function _J(e,t){return JSON.stringify(e)===JSON.stringify(t)}var vJ=D(`<div class="text-muted-foreground flex items-center gap-1.5 text-xs"><!> <span> </span></div>`);function yJ(e,n){var r=u(),i=z(r),a=e=>{var t=vJ(),r=I(t);It(r,{class:`h-3 w-3`});var i=U(r,2),a=K(i,!0);c(t),G(()=>m(a,n.label)),O(e,t)};t(i,e=>{n.label&&e(a)}),O(e,r)}async function bJ(){let[{default:t},{default:n}]=await Promise.all([e(()=>import(`./71J-lVIC.js`),__vite__mapDeps([0,1]),import.meta.url),e(()=>import(`./B_4x1b7P.js`),[],import.meta.url)]);return t({locateFile:()=>n})}var xJ=D(`<span class="bg-warning/15 text-warning shrink-0 rounded-full px-2.5 py-1 font-mono text-[11px] font-medium tracking-wide whitespace-nowrap uppercase"> <span class="hidden sm:inline">preview</span></span>`),SJ=D(`<span class="bg-warning/15 text-warning shrink-0 rounded-full px-2.5 py-1 font-mono text-[11px] font-medium tracking-wide whitespace-nowrap uppercase">Draft<span class="hidden sm:inline">preview</span></span>`),CJ=D(`<!> <!>`,1);function wJ(e,n){V(n,!0);let r=T(()=>Pe.data),i=T(()=>!!C(r).user);function a(){return!!n.data.schema.viewerOptions?.enableRemote}let o=Y(()=>C(i)&&!n.data.shareToken)?iR({endpoint:`/api/v1/solve-events`,cancelEndpoint:e=>`/api/v1/solve/${e}/cancel`}):null;le(()=>()=>o?.close());let s=CR({endpoint:`/api/v1/compute`,definitionUrl:()=>n.data.ghDefinition,inputs:()=>n.data.schema.inputs,outputs:()=>n.data.schema.outputs,channel:()=>n.data.channel===`draft`?`draft`:void 0,versionId:()=>n.data.versionId,streamId:()=>o?.streamId??null,bearerToken:()=>n.data.shareToken,keepalive:!0,meshes:a()?{extract:(e,t)=>OP(e,t)}:void 0,debug:!0}),l,d=T(()=>{let e=JSON.stringify(n.data.schema);return l?.json!==e&&(l={json:e,schema:n.data.schema}),l.schema}),f;function p(e){f=e}let h=`saved-values`;le(()=>(n.data.currentDefinition,n.data.channel,n.data.versionId,Y(g)));function g(){if(!n.data.defaultsPending)return;let e=C(d),t=0,r,i=!1;Cn.loading(`Reading the values saved in the file`,{id:h,description:`The form shows stored defaults until they arrive.`,duration:1/0});async function a(){if(await Ne(mJ,!0).catch(()=>{}),!i){if(n.data.defaultsPending)t+=1,t>=hJ.length?Cn.warning(`Saved values not loaded`,{id:h,description:`Rhino.Compute did not answer in time. The form shows stored defaults. Reload the page to try again.`,duration:1/0}):r=setTimeout(a,hJ[t]);else{let t=f?gJ(e,n.data.schema,f.getSession().values):{};if(Object.keys(t).length===0){Cn.dismiss(h);return}f?.loadValues(t),Cn.success(`Saved values loaded`,{id:h,description:`Inputs you had not changed were updated.`,duration:5e3})}}}return r=setTimeout(a,hJ[0]),()=>{i=!0,clearTimeout(r),Cn.dismiss(h)}}{let a=e=>{var n=u(),r=z(n),a=e=>{ze(e,{})};t(r,e=>{C(i)&&e(a)}),O(e,n)},l=e=>{var a=CJ(),o=z(a),s=e=>{var t=xJ(),r=I(t);S(),c(t),G(()=>m(r,`v${n.data.versionNumber??``}`)),O(e,t)},l=e=>{var t=SJ();O(e,t)};t(o,e=>{n.data.versionId?e(s):n.data.channel===`draft`&&e(l,1)});var u=U(o,2),d=e=>{var t=CJ(),n=z(t);qe(n,{});var i=U(n,2);{let e=T(()=>C(r).user?.platformPermissions??[]),t=T(()=>C(r).ctx?.orgPermissions??[]),n=T(()=>C(r).ctx?.mayHoldApiTokens);Ye(i,{get platformPermissions(){return C(e)},get orgPermissions(){return C(t)},get mayHoldApiTokens(){return C(n)}})}O(e,t)};t(u,e=>{C(i)&&e(d)}),O(e,a)},f=T(()=>n.data.schema?.name||n.data.schema.description),h=T(()=>n.data.orgLogoUrl??void 0),g=T(()=>C(r).branding?.name),_=T(()=>o??void 0);pJ(e,{get schema(){return C(d)},onReady:p,get onSolve(){return s},get definitionKey(){return n.data.currentDefinition},get title(){return C(f)},get logo(){return C(h)},showModeToggle:!0,get brandName(){return C(g)},homeUrl:`/`,get solveDeadlineMs(){return n.data.solveDeadlineMs},get events(){return C(_)},get loadRhino(){return bJ},get footerComponent(){return yJ},footerComponentProps:()=>({label:n.data.serverLabel}),navItems:a,headerRight:l,$$slots:{navItems:!0,headerRight:!0}})}b()}export{Cj as a,Sj as i,bj as n,Dj as o,xj as r,jj as s,wJ as t};
|