UNPKG

@wayrisignals/kicad-webview

Version:

Interactive KiCad schematic, PCB and 3D viewer for the web, with Gerber, Excellon, linked views and offline HTML exports

4,885 lines • 1.31 MB
/*! KiCad WebView 1.2.1 | Copyright (c) 2026 wayri | SPDX-License-Identifier: MPL-2.0 | Source: https://github.com/wayri/kicad-webview/tree/v1.2.1 | Keep LICENSE and THIRD-PARTY-NOTICES.md; bundled dependencies retain their licenses. */
var SpikeBoard3D=(()=>{var TS=Object.create;var yd=Object.defineProperty;var AS=Object.getOwnPropertyDescriptor;var wS=Object.getOwnPropertyNames;var RS=Object.getPrototypeOf,CS=Object.prototype.hasOwnProperty;var go=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports),uv=(i,e)=>{for(var t in e)yd(i,t,{get:e[t],enumerable:!0})},hv=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of wS(e))!CS.call(i,r)&&r!==t&&yd(i,r,{get:()=>e[r],enumerable:!(n=AS(e,r))||n.enumerable});return i};var Ra=(i,e,t)=>(t=i!=null?TS(RS(i)):{},hv(e||!i||!i.__esModule?yd(t,"default",{value:i,enumerable:!0}):t,i)),PS=i=>hv(yd({},"__esModule",{value:!0}),i);var vE=go((tN,em)=>{(i=>{"use strict";let r=g=>({quoted:String(g??"")}),s=g=>{let y=Number(g);if(!Number.isFinite(y)||Math.abs(y)>1e8)throw Error("Invalid legacy schematic coordinate.");return Math.round(y*.0254*1e8)/1e8},o=g=>[...g.matchAll(/"((?:\\.|[^"\\])*)"|([^\s]+)/g)].map(y=>y[1]!==void 0?y[1].replace(/\\(["\\])/g,"$1"):y[2]),a=(g,y,f=0)=>["at",s(g),s(y),f],c=(g=50,y=!1)=>["effects",["font",["size",s(g),s(g)]],...y?["hide"]:[]];function l(g){if(typeof g!="string"||new TextEncoder().encode(g).length>8388608)throw Error("Legacy schematic/library exceeds its size limit.");let y=g.replace(/^\uFEFF/,"").split(/\r?\n/);if(y.length>15e4)throw Error("Legacy schematic/library exceeds its line limit.");return y}function u(g,y,f){let p,v=1,b=!1,x=!1,_=0,T=[];for(let w=y;w<f;w++){let A=g[w].trim();if(!A)continue;if(A==="EndData"&&b&&!x){x=!0;continue}if(b&&!x){if(!/^[0-9a-f]{2}(?:\s+[0-9a-f]{2})*$/i.test(A))throw Error("Invalid saved bitmap bytes.");let N=A.match(/[0-9a-f]{2}/gi);if(_+=N.length,_>4*1024*1024)throw Error("Saved bitmap exceeds its 4 MiB limit.");for(let L=0;L<N.length;L+=8192)T.push(String.fromCharCode(...N.slice(L,L+8192).map(D=>parseInt(D,16))));continue}let[E,M,P]=o(A);E==="Pos"&&M!==void 0&&P!==void 0&&(p=a(M,P)),E==="Scale"&&M!==void 0&&(v=Number(M)),E==="Data"&&!b&&(b=!0)}if(!p||!T.length||!x||!Number.isFinite(v)||v<=0)throw Error("Invalid saved bitmap placement or data.");return["image",p,["scale",v],["uuid",r("legacy-bitmap-"+y)],["data",r(btoa(T.join("")))]]}function h(g,y){let f=new Map,p=0;if(!Array.isArray(g))return f;if(g.length>16)throw Error("Too many legacy symbol libraries.");for(let v of g){let b=typeof v=="string"?v:v?.content;if(typeof b!="string")continue;if(p+=b.length,p>16*1024*1024)throw Error("Legacy symbol libraries exceed their combined limit.");let x=null,_=[],T=!1,w=new Map;for(let A of l(b)){let E=o(A),M=E[0];if(!M||M[0]==="#")continue;if(M==="DEF"){x=E,_=[],w=new Map;continue}if(!x)continue;if(M==="ALIAS"){_.push(...E.slice(1));continue}if(M==="DRAW"){T=!0;continue}if(M==="ENDDRAW"){T=!1;continue}if(M==="ENDDEF"){let D=x[1],$=["symbol",r(D),...x[9]==="P"?[["power"]]:[],...x[5]==="N"?[["pin_numbers","hide"]]:[],...x[6]==="N"?[["pin_names","hide"]]:[],...w.values()];for(let U of[D,..._])f.has(U)||f.set(U,$);x=null;continue}if(!T)continue;let P=(D,$,U)=>{let I=D+"_"+$;w.has(I)||w.set(I,["symbol",r(x[1]+"_"+I)]),w.get(I).push(U)},N=D=>["stroke",["width",Math.max(s(D||6),.01)]],L=D=>["fill",["type",D==="F"?"outline":D==="f"?"background":"none"]];if(M==="S")P(E[5],E[6],["rectangle",["start",s(E[1]),s(E[2])],["end",s(E[3]),s(E[4])],N(E[7]),L(E[8])]);else if(M==="C")P(E[4],E[5],["circle",["center",s(E[1]),s(E[2])],["radius",s(E[3])],N(E[6]),L(E[7])]);else if(M==="P"){let D=Number(E[1]);if(!Number.isInteger(D)||D<2||D>1e4||E.length<5+2*D)throw Error("Invalid legacy library polyline.");P(E[2],E[3],["polyline",["pts",...Array.from({length:D},($,U)=>["xy",s(E[5+U*2]),s(E[6+U*2])])],N(E[4]),L(E[5+D*2])])}else if(M==="A"){let D=s(E[1]),$=s(E[2]),U=s(E[3]),I=Number(E[4])*Math.PI/1800,W=Number(E[5])*Math.PI/1800-I;for(;W<0;)W+=Math.PI*2;let Q=se=>[D+U*Math.cos(se),$+U*Math.sin(se)];P(E[6],E[7],["arc",["start",...Q(I)],["mid",...Q(I+W/2)],["end",...Q(I+W)],N(E[8]),L(E[9])])}else if(M==="X"){let D={I:"input",O:"output",B:"bidirectional",T:"tri_state",P:"passive",U:"unspecified",W:"power_in",w:"power_out",C:"open_collector",E:"open_emitter",N:"no_connect"},$={R:0,U:90,L:180,D:270}[E[6]],U={"":"line",I:"inverted",C:"clock",CI:"inverted_clock",L:"input_low",CL:"clock_low",V:"output_low",F:"edge_clock_high",X:"non_logic"},I=E[12]||"",V=I.includes("N"),W=U[I.replace(/N/g,"")];if($===void 0||!W){y("Unsupported legacy pin orientation/style omitted: "+E[1]);continue}P(E[9],E[10],["pin",D[E[11]]||"unspecified",W,a(E[3],E[4],$),["length",s(E[5])],["name",r(E[1]),c(E[8])],["number",r(E[2]),c(E[7])],...V?["hide"]:[]])}else y(M==="T"?"Legacy library text is omitted; convert a copy in KiCad for complete typography.":"Unsupported legacy library graphic "+M+" omitted.")}}return f}function d(g,y={}){let f=l(g);if(!/^EESchema Schematic File Version [24]\b/.test(f[0]))throw Error("Only legacy Eeschema v2/v4 schematics are supported.");let p=new Set(["Restricted legacy schematic preview: only recognized saved records and supplied cache-library graphics are rendered. Convert a separate copy in KiCad for a complete modern preview."]),v=E=>{p.size<200&&p.add(E)},b=h(y.libraries,v),x=["kicad_sch",["version",Number(f[0].match(/\d+$/)[0])],["legacy_source",r(f[0])]],_=["lib_symbols"],T=[],w=(E,M,P,N,L=50,D=!1,$=0)=>["property",r(E),r(M),a(P,N,$),c(L,D)];function A(E,M){let P=[],N=E;for(;N<f.length&&f[N]!==M;N++)P.push(o(f[N]));if(N===f.length)throw Error("Incomplete legacy schematic "+M+" block.");return{records:P,end:N}}for(let E=1;E<f.length;E++){let M=o(f[E]),P=M[0];if(!(!P||P[0]==="#")){if(P==="$Descr"){x.push(["paper",r(M[1])]);continue}if(/^Comment[1-9]$/.test(P)){let N=x.find(L=>Array.isArray(L)&&L[0]==="title_block");N||(N=["title_block"],x.push(N)),N.push(["comment",Number(P.slice(7)),r(M[1])]);continue}if(["Title","Date","Rev","Comp"].includes(P)){let N=x.find(L=>Array.isArray(L)&&L[0]==="title_block");N||(N=["title_block"],x.push(N)),N.push([{Title:"title",Date:"date",Rev:"rev",Comp:"company"}[P],r(M[1])]);continue}if(P==="Wire"||P==="Entry"){let N=o(f[++E]||"");if(N.length!==4)throw Error("Invalid legacy wire record.");if(P==="Entry"){v("Legacy bus-entry geometry omitted.");continue}x.push([M[1]==="Bus"?"bus":"wire",["pts",["xy",s(N[0]),s(N[1])],["xy",s(N[2]),s(N[3])]]]);continue}if(P==="Connection"||P==="NoConn"){x.push([P==="Connection"?"junction":"no_connect",a(M[2],M[3])]);continue}if(P==="Text"){let N=f[++E]??"",L={Label:"label",GLabel:"global_label",HLabel:"hierarchical_label",Notes:"text"}[M[1]];if(!L){v("Unsupported legacy text record "+M[1]+" omitted.");continue}let D=[0,90,180,270],$=D[Number(M[4])];if($===void 0){v("Unsupported legacy text orientation omitted.");continue}let U={Input:"input",Output:"output",BiDi:"bidirectional",TriState:"tri_state",UnSpc:"passive"}[M[6]];!["text","label"].includes(L)&&!U&&v("Unknown legacy label shape "+M[6]+"; passive outline used."),x.push([L,r(N.replace(/\\n/g,`
`)),a(M[2],M[3],$),c(M[5]),...L==="text"||L==="label"?[]:[["shape",U||"passive"]]]);continue}if(P==="$Sheet"){let N=A(E+1,"$EndSheet");E=N.end;let L=N.records,D=L.find(I=>I[0]==="S"),$=L.find(I=>I[0]==="U");if(!D)throw Error("Legacy sheet has no bounds.");let U=["sheet",a(D[1],D[2]),["size",s(D[3]),s(D[4])],["uuid",r($?.[1]||"legacy-sheet-"+E)]];for(let I of L.filter(V=>/^F\d+$/.test(V[0])))if(I[0]==="F0"||I[0]==="F1")U.push(w(I[0]==="F0"?"Sheetname":"Sheetfile",I[1],D[1],D[2],I[2]));else{let V=I[3],W={L:180,R:0,U:90,D:270}[V];U.push(["pin",r(I[1]),{I:"input",O:"output",B:"bidirectional",T:"tri_state",U:"passive"}[I[2]]||"passive",a(I[4],I[5],W??0),c(I[6])])}x.push(U);continue}if(P==="$Comp"){let N=A(E+1,"$EndComp");E=N.end;let L=N.records,D=L.find(oe=>oe[0]==="L"),$=L.find(oe=>oe[0]==="U"),U=L.find(oe=>oe[0]==="P");if(!D||!U)throw Error("Incomplete legacy component.");let I=D[1],V=L.find(oe=>oe.length===4&&oe.every(ge=>/^-?\d+$/.test(ge)))?.map(Number)||[1,0,0,-1],W=null;for(let oe of[0,90,180,270])for(let ge of["","x","y"]){let O=oe*Math.PI/180,S=Math.round(Math.cos(O)),R=Math.round(Math.sin(O)),z=ge==="y"?-1:1,Y=ge==="x"?-1:1,K=[z*S,-z*R,-Y*R,-Y*S];V.every((re,de)=>re===K[de])&&(W={angle:oe,mirror:ge})}if(!W){v("Legacy component "+I+" has an unsupported orientation and is omitted.");continue}let Q=["symbol",["lib_id",r(I)],a(U[1],U[2],W.angle),["unit",Number($?.[1]||1)],["convert",Number($?.[2]||1)],["uuid",r($?.[3]||"legacy-component-"+E)],...W.mirror?[["mirror",W.mirror]]:[]];for(let oe of L.filter(ge=>ge[0]==="F")){let ge=["Reference","Value","Footprint","Datasheet"][Number(oe[1])]||oe[11]||"Field"+oe[1];Q.push(w(ge,oe[2],oe[4],oe[5],oe[6],oe[7]!=="0000",(((oe[3]==="V"?90:0)-W.angle)%180+180)%180))}let se=b.get(I)||b.get(I.split(":").pop());se?T.includes(I)||(_.push(["symbol",r(I),...se.slice(2)]),T.push(I)):v("Missing saved legacy library definition for "+I+": symbol body and pins omitted; fields remain visible."),x.push(Q);continue}if(P==="$Bitmap"){let N=f.indexOf("$EndBitmap",E+1);if(N<0){v("Legacy bitmap omitted: missing block terminator.");break}try{x.push(u(f,E+1,N))}catch(L){v("Legacy bitmap omitted: "+L.message)}E=N}}}if(!f.some(E=>E==="$EndSCHEMATC"))throw Error("Incomplete legacy schematic terminator.");return x.push(_,...[...p].map(E=>["legacy_diagnostic",r(E)])),x}function m(g){let y=l(g),f=[],p=!1;for(let v of y)if(v==="$Sheet")p=!0;else if(v==="$EndSheet")p=!1;else if(p){let b=o(v);b[0]==="F1"&&f.push(b[1])}return f}i.KiCadLegacy={parse:d,sheetFiles:m},typeof em=="object"&&em.exports&&(em.exports=i.KiCadLegacy)})(globalThis)});var _E=go((bE,Vc)=>{(i=>{"use strict";let t=()=>268435456,c=new Set(["symbol","sheet","wire","bus","bus_entry","label","global_label","hierarchical_label","junction","no_connect","text","text_box","polyline","rectangle","circle","arc","image","rule_area","netclass_flag","directive_label"]),l=new Set(["footprint","segment","arc","via","zone","gr_line","gr_rect","gr_circle","gr_arc","gr_poly","gr_curve","gr_text","gr_text_box","gr_bitmap","dimension","target"]),u=new Set(["uuid","tstamp","filled_polygon","fill_segments"]),h=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;function d(O){if(typeof O!="string")throw new TypeError("KiCad source must be a string.");if(!/[^\x00-\x7f]/.test(O))return O.length;let S=O.length;for(let R=0;R<O.length;R++){let z=O.charCodeAt(R);if(!(z<128)){if(z<2048){S++;continue}if(z>=55296&&z<=56319&&R+1<O.length){let Y=O.charCodeAt(R+1);if(Y>=56320&&Y<=57343){S+=2,R++;continue}}S+=2}}return S}let m=O=>O===32||O>=9&&O<=13||O>127&&/\s/.test(String.fromCharCode(O));function g(O){if(!Array.isArray(O)||O.length!==4||O.some(re=>!re||!Number.isFinite(re.x)||!Number.isFinite(re.y)))throw Error("Bezier requires four finite control points.");let S=[{...O[0]}],R=[O],z=.005**2,Y=(re,de,te)=>{let ne=te.x-de.x,H=te.y-de.y,_e=ne*ne+H*H,me=_e?Math.max(0,Math.min(1,((re.x-de.x)*ne+(re.y-de.y)*H)/_e)):0;return(re.x-de.x-me*ne)**2+(re.y-de.y-me*H)**2},K=(re,de)=>({x:re.x/2+de.x/2,y:re.y/2+de.y/2});for(;R.length;){let[re,de,te,ne]=R.pop();if(Math.max(Y(de,re,ne),Y(te,re,ne))<=z){if(S.length>=2049)throw Error("Bezier exceeds the bounded tessellation budget.");S.push({...ne})}else{let H=K(re,de),_e=K(de,te),me=K(te,ne),be=K(H,_e),he=K(_e,me),Ne=K(be,he);if(R.length>32||[H,_e,me,be,he,Ne].some(Me=>!Number.isFinite(Me.x)||!Number.isFinite(Me.y)))throw Error("Bezier exceeds the bounded tessellation budget.");R.push([Ne,he,me,ne],[re,H,be,Ne])}}return S}let y=new Set(["version","generator","generator_version","uuid","paper","title_block","property","sheet","symbol","footprint","module","sheet_instances","legacy_source","legacy_diagnostic"]),f=new Set([...y,"embedded_files"]),p=new Set(["property","uuid","path","instances"]);function v(O,S={}){if(typeof O!="string")throw new TypeError("KiCad source must be a string.");if(/^\s*PCBNEW-BOARD/.test(O))throw Error("Legacy .brd boards are detected but this drawing format is not yet rendered. Open and save a separate .kicad_pcb copy in KiCad.");if(/^\s*EESchema Schematic File Version [24]\b/.test(O)){let _e=i.KiCadLegacy||(typeof Vc=="object"&&Vc.exports?vE():null);if(!_e)throw Error("Legacy schematic adapter is unavailable; reload the extension.");return _e.parse(O,S)}if(O.length>268435456||O.length>268435456/3&&d(O)>268435456)throw new Error("KiCad file exceeds browser parser size limits.");let R=[],z=[],Y=/\(xy[ \t]+([-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?)[ \t]+([-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?)[ \t]*\)/y,K=0,re=0,de=0,te=()=>R.length===3&&R[0][0]==="kicad_pcb"&&R[1][0]==="zone"&&R[2][0]==="filled_polygon";function ne(_e){let me=_e+4,be=0,he=new Float64Array(128);for(;me<O.length;){for(;m(O.charCodeAt(me));)me++;if(O.charCodeAt(me)===41)return be<6?null:(re+=1+be*2,H(["pts",be===he.length?he:he.slice(0,be)]),me+1);Y.lastIndex=me;let Ne=Y.exec(O);if(!Ne)return null;let Me=Number(Ne[1]),Z=Number(Ne[2]);if(!Number.isFinite(Me)||!Number.isFinite(Z))throw new Error("Invalid numeric KiCad value.");if(re+6+be*2>12e6)throw new Error("KiCad file has too many S-expression nodes.");if(be===he.length){let B=new Float64Array(he.length*2);B.set(he),he=B}he[be++]=Me,he[be++]=Z,me=Y.lastIndex}return null}let H=_e=>{if(++re>12e6)throw new Error("KiCad file has too many S-expression nodes.");de||(R.at(-1)||z).push(_e)};for(;K<O.length;){let _e=O[K];if(m(O.charCodeAt(K))){K++;continue}if((_e==="<"||_e===">")&&/^(?:<{7,}|>{7,})(?:\s|$)/.test(O.slice(K,K+120)))throw new Error("Unresolved Git merge conflict at line "+O.slice(0,K).split(`
`).length+". Resolve the conflict in a separate copy before viewing.");if(_e===";"){for(;K<O.length&&O[K]!==`
`;)K++;continue}if(_e==="("){if(R.length>=96)throw new Error("KiCad S-expression is too deep.");if(S.compactCopper&&!S.metadataOnly&&O.startsWith("(pts",K)&&m(O.charCodeAt(K+4))&&te()){let Ne=ne(K);if(Ne!==null){K=Ne;continue}}if(!S.metadataOnly&&R.length&&O.startsWith("(xy",K)){Y.lastIndex=K;let Ne=Y.exec(O);if(Ne){let Me=Number(Ne[1]),Z=Number(Ne[2]);if(!Number.isFinite(Me)||!Number.isFinite(Z))throw new Error("Invalid numeric KiCad value.");re+=3,H(["xy",Me,Z]),K=Y.lastIndex;continue}}if(S.metadataOnly&&!de){let Ne=null;if(R.length===1?Ne=S.includeEmbeddedFonts?f:y:R.length===2&&["symbol","footprint","module"].includes(R.at(-1)?.[0])?Ne=p:R.at(-1)?.[0]==="property"&&(Ne=new Set),Ne){let Me=K+1;for(;Me<O.length&&m(O.charCodeAt(Me));)Me++;let Z=Me;for(;Z<O.length&&!m(O.charCodeAt(Z))&&!["(",")",";"].includes(O[Z]);)Z++;Ne.has(O.slice(Me,Z))||(de=R.length+1)}}let he=[];H(he),R.push(he),K++;continue}if(_e===")"){if(!R.length)throw new Error("Unexpected closing parenthesis in KiCad file.");let he=R.pop();if(!de&&he.length>0&&he.length<=4){let Ne=he.slice(),Me=R.at(-1)||z;Me[Me.length-1]=Ne}de&&R.length<de&&(de=0),K++;continue}if(!R.length)throw new Error("Expected a KiCad S-expression.");if(_e==='"'){let he=null,Ne=++K,Me=!1,Z="";for(;K<O.length;){let B=O[K++];if(B==='"'){if(Me=!0,!de){let k=O.slice(Ne,K-1);he?(he.push(k),Z=he.join("")):Z=k}break}if(B==="\\"){if(K>=O.length)throw new Error("Unterminated KiCad escape sequence.");let k=O[K++];if(!de){he??=[],he.push(O.slice(Ne,K-2));let F={n:`
`,r:"\r",t:"	",'"':'"',"\\":"\\"}[k];he.push(F===void 0?"\\"+k:F)}Ne=K}}if(!Me)throw new Error("Unterminated quoted KiCad string.");H(de?null:{quoted:Z});continue}let me=K;for(;K<O.length;){let he=O.charCodeAt(K);if(he===40||he===41||he===59||he===34||m(he))break;K++}if(me===K)throw new Error("Unexpected KiCad source character.");if(de){H(null);continue}let be=O.slice(me,K);if(h.test(be)){let he=Number(be);if(!Number.isFinite(he))throw new Error("Invalid numeric KiCad value.");H(he)}else H(be==="xy"?"xy":be)}if(R.length||z.length!==1||!Array.isArray(z[0]))throw new Error("Incomplete KiCad S-expression.");return z[0]}let b=O=>O&&typeof O=="object"&&!Array.isArray(O)?O.quoted:O,x=O=>Array.isArray(O)?String(b(O[0])):"",_=(O,S)=>O.filter(R=>Array.isArray(R)&&x(R)===S),T=(O,S)=>O.find(R=>Array.isArray(R)&&x(R)===S),w=(O,S)=>b(T(O,S)?.[1]);function A(O){let S=T(O,"polyline"),R=S&&T(S,"pts");if(!R||R.length<4||R.length>4097)return null;let z=[];for(let re of R.slice(1)){let de=b(re?.[1]),te=b(re?.[2]);if(!Array.isArray(re)||x(re)!=="xy"||!Number.isFinite(de)||!Number.isFinite(te))return null;let ne=z.at(-1);(ne?.x!==de||ne.y!==te)&&z.push({x:de,y:te})}if(z[0].x===z.at(-1).x&&z[0].y===z.at(-1).y&&z.pop(),z.length<3)return null;let Y=z[0],K=0;for(let re=1;re<z.length-1;re++){let de=z[re],te=z[re+1];K+=(de.x-Y.x)*(te.y-Y.y)-(de.y-Y.y)*(te.x-Y.x)}return Number.isFinite(K)&&K!==0?z:null}function E(O){for(let S of["at","start","center","end","xy"]){let R=T(O,S);if(R&&Number.isFinite(b(R[1]))&&Number.isFinite(b(R[2])))return{x:b(R[1]),y:b(R[2])}}for(let S of["pts","polygon"]){let R=T(O,S),z=R&&T(S==="polygon"&&T(R,"pts")||R,"xy");if(z&&Number.isFinite(b(z[1]))&&Number.isFinite(b(z[2])))return{x:b(z[1]),y:b(z[2])}}return null}function M(O,S){let R=[];for(let re of _(O,"property"))re.length>=3&&R.push([String(b(re[1])),String(b(re[2]))]);if(S==="footprint")for(let[re,de]of[["reference","Reference"],["value","Value"]]){let te=_(O,"fp_text").find(ne=>b(ne[1])===re);te&&te.length>=3&&!R.some(([ne])=>ne===de)&&R.push([de,String(b(te[2]))])}for(let re of["lib_id","layer","width","drill","size","unit"]){let de=T(O,re);de&&R.push([re,de.slice(1).map(b).join(", ")])}let z=T(O,"layers");z&&R.push(["Layers",z.slice(1).map(b).join(", ")]);let Y=T(O,"net");Y&&R.push(["Net",String(b(Y[2]??Y[1]))]);let K=T(O,"at");return K&&Number.isFinite(b(K[3]))&&R.push(["Angle",String(b(K[3]))]),["label","global_label","hierarchical_label","text","gr_text","gr_text_box"].includes(S)&&R.push(["Text",String(b(O[1]??""))]),S==="pad"&&(R.push(["Number",String(b(O[1]??""))]),R.push(["Type",String(b(O[2]??""))]),R.push(["Shape",String(b(O[3]??""))])),Object.fromEntries(R)}function P(O){return Array.isArray(O)?O.filter(S=>!Array.isArray(S)||!u.has(x(S))).map(P):O&&typeof O=="object"?["quoted",O.quoted]:O}function N(O){let S=2166136261;for(let R=0;R<O.length;R++)S=Math.imul(S^O.charCodeAt(R),16777619);return(S>>>0).toString(16).padStart(8,"0")}function L(O,S,R,z){let Y=w(O,"uuid")??w(O,"tstamp")??(S==="rule_area"&&T(O,"polyline")?w(T(O,"polyline"),"uuid"):void 0);if(Y!=null&&String(Y))return{key:`uuid:${Y}`,uuid:String(Y)};let K=S==="pad"?R.Number:S==="sheet"?R.Sheetfile:S==="symbol"||S==="footprint"?R.Reference:void 0;return{key:K?`fallback:${String(K)}`:`fallback:${N(typeof z=="function"?z():z)}`,uuid:null}}function D(O,S,R,z){return S==="pad"?`${z||"Footprint"} pad ${R.Number||""}`.trim():R.Reference||R.Sheetname||R["Sheet name"]||R.Text||(S==="footprint"?String(b(O[1]??"Footprint")):S==="symbol"?R.lib_id||"symbol":S==="netclass_flag"||S==="directive_label"?"Directive label":S==="rule_area"?"Rule area":S.replace(/_/g," "))}function $(O,S){if(!O||!S?.position)return null;let R=Number(b(T(S.form,"at")?.[3]??0)),z=(Number.isFinite(R)?R:0)*Math.PI/180,Y=Math.cos(z),K=Math.sin(z),re=S.position.x+O.x*Y+O.y*K,de=S.position.y-O.x*K+O.y*Y,te=ne=>Math.round(ne*1e6)/1e6;return{x:te(re),y:te(de)}}function U(O,S,R=null,z=null,Y=!1){let K=x(S),re=M(S,K),de=E(K==="rule_area"&&T(S,"polyline")||S),te=K==="pad"?$(de,R):de,ne,H=()=>ne??=JSON.stringify([P(S),te,typeof z=="function"?z():z]);Y||(re["Source fingerprint"]=N(H()));let _e=L(S,K,re,H),be=`${R?`${R.scope}/`:`${O}/`}${K}:${_e.key}`,he=D(S,K,re,R?.label);return{key:be,scope:be,signature:Y?null:H(),metadata:{uuid:_e.uuid,position:te,properties:re},path:O,kind:K,label:he,form:S}}function I(O,S,R=null,{forConnectivity:z=!1,parseOnly:Y=!1,compactCopper:K=!1}={},re){let de=re||v(S,{compactCopper:K});R?.(de);let te=x(de);if(te!=="kicad_sch"&&te!=="kicad_pcb")throw new Error("Expected a KiCad schematic or board.");if(Y)return[];let ne=te==="kicad_sch"?c:l,H=new Map;if(te==="kicad_sch"){let me=T(de,"lib_symbols");if(me)for(let be of _(me,"symbol")){let he=b(be[1]);typeof he=="string"&&H.set(he,z?be:JSON.stringify(P(be)))}}let _e=[];for(let me of de){if(!Array.isArray(me)||!ne.has(x(me)))continue;let be=x(me)==="symbol"?H.get(String(w(me,"lib_name")??w(me,"lib_id"))):null,he=U(O,me,null,z&&be?()=>JSON.stringify(P(be)):be,z);if(_e.push(he),te==="kicad_pcb"&&he.kind==="footprint")for(let Ne of _(me,"pad"))_e.push(U(O,Ne,{form:me,position:he.metadata.position,scope:he.scope,label:he.label},null,z))}return _e}function V(O,S={}){return v(O,{...S,metadataOnly:!0}).filter((z,Y)=>Y===0||Array.isArray(z)&&(S.includeEmbeddedFonts?f:y).has(z[0])).map(z=>Array.isArray(z)&&["symbol","footprint","module"].includes(z[0])?z.filter((Y,K)=>K===0||Array.isArray(Y)&&p.has(Y[0])):z)}let W=new WeakMap;function Q(O,{forConnectivity:S=!1,compactCopper:R=!1}={}){let z=new Map,Y=oe(O,(re,de)=>z.set(re.path,de),null,{forConnectivity:S,parseOnly:S,compactCopper:S&&R}),K=Object.freeze({});return W.set(K,{files:O.map(re=>({path:re.path,content:re.content})),parsed:z,records:S?null:Y,forConnectivity:S}),K}function se(O,S,R){let z=W.get(O);if(!z||!z.parsed.has(S))throw new Error("Prepared KiCad file is unavailable.");if(R!==void 0&&!z.files.some(Y=>Y.path===S&&Y.content===R))throw new Error("Prepared KiCad file differs from source.");return z.parsed.get(S)}function oe(O,S=null,R=null,{forConnectivity:z=!1,parseOnly:Y=!1,compactCopper:K=!1}={}){if(R){let ne=W.get(R);if(!ne||!Array.isArray(O)||O.length!==ne.files.length||O.some((H,_e)=>H?.path!==ne.files[_e].path||H?.content!==ne.files[_e].content))throw new Error("Prepared KiCad project differs from source.");if(ne.forConnectivity!==z||!ne.records){let H=[];for(let _e of O)for(let me of I(_e.path,_e.content,be=>S?.(_e,be),{forConnectivity:z},ne.parsed.get(_e.path)))H.push(me);return H}for(let H of O)S?.(H,ne.parsed.get(H.path));return ne.records.map(H=>({...H}))}if(!Array.isArray(O)||O.length>128)throw new Error("Too many KiCad files to compare.");let re=new Set,de=[],te=0;for(let ne of O){if(!ne||typeof ne.path!="string"||typeof ne.content!="string"||!/\.kicad_(?:sch|pcb)$/i.test(ne.path)||re.has(ne.path))throw new Error("Invalid or duplicate KiCad file entry.");re.add(ne.path);let H=d(ne.content);if(te+=H,H>268435456||te>536870912)throw new Error("KiCad project exceeds browser comparison size limits.");for(let _e of I(ne.path,ne.content,me=>S?.(ne,me),{forConnectivity:z,parseOnly:Y,compactCopper:K}))de.push(_e)}return de}function ge(O,S){let R=oe(O),z=oe(S),Y=new Map;for(let te of R)Y.has(te.key)||Y.set(te.key,{before:[],after:[]}),Y.get(te.key).before.push(te);for(let te of z)Y.has(te.key)||Y.set(te.key,{before:[],after:[]}),Y.get(te.key).after.push(te);let K=[],re={added:0,removed:0,modified:0},de=(te,ne,H,_e,me)=>{K.push({id:me,path:te.path,kind:te.kind,label:te.label,status:ne,before:H?.metadata??null,after:_e?.metadata??null}),re[ne]++};for(let[te,ne]of Y){let H=[...ne.before],_e=[...ne.after];for(let be=H.length-1;be>=0;be--){let he=_e.findIndex(Ne=>Ne.signature===H[be].signature);he>=0&&(H.splice(be,1),_e.splice(he,1))}H.sort((be,he)=>be.signature.localeCompare(he.signature)),_e.sort((be,he)=>be.signature.localeCompare(he.signature));let me=Math.max(H.length,_e.length);for(let be=0;be<me;be++){let he=H[be]||null,Ne=_e[be]||null;de(Ne||he,he&&Ne?"modified":he?"removed":"added",he,Ne,me>1?`${te}#${be+1}`:te)}}return K.sort((te,ne)=>te.path.localeCompare(ne.path)||te.id.localeCompare(ne.id)||te.status.localeCompare(ne.status)),{changes:K,counts:re}}i.KiCadDesignDiff={compareProjects:ge,projectObjects:oe,parse:v,parseMetadata:V,sourceByteLimit:t,sourceByteLength:d,prepareProject:Q,preparedFile:se,cubicBezierPoints:g,MAX_FILES:128,MAX_FILE_BYTES:268435456,MAX_PROJECT_BYTES:536870912,MAX_RENDER_PRIMITIVES:15e5,ruleAreaPoints:A},typeof Vc=="object"&&Vc.exports&&(Vc.exports=i.KiCadDesignDiff)})(typeof globalThis=="object"?globalThis:bE)});var ME=go((EE,tm)=>{(i=>{"use strict";let n=f=>f&&typeof f=="object"&&!Array.isArray(f)?f.quoted:f,r=f=>Array.isArray(f)?String(n(f[0])):"",s=(f,p)=>Array.isArray(f)?f.filter(v=>Array.isArray(v)&&r(v)===p):[],o=(f,p)=>s(f,p)[0],a=(f,p)=>n(o(f,p)?.[1]),c=(f,p)=>typeof n(f)=="number"&&Number.isFinite(n(f))?n(f):p,l=(f,p,v)=>{let b=o(o(f,p),"xyz");return b?[c(b[1],NaN),c(b[2],NaN),c(b[3],NaN)]:[...v]},u=f=>typeof f=="string"&&f.length>0&&f.length<=500&&!/[\\\u0000-\u001f\u007f?%]/.test(f)&&!/^[a-z][a-z\d+.-]*:/i.test(f)&&!f.startsWith("/");function h(f,p){if(typeof p=="string"&&(p=p.replace(/\\/g,"/")),!u(f)||!/\.kicad_pcb$/i.test(f)||!u(p))return null;let v=f.split("/");if(v.some(T=>!T||T==="."||T===".."))return null;let b=p.replace(/^(?:\$\{KIPRJMOD\}|\$\(KIPRJMOD\))\//,"");if(b.includes("$(")||b.includes("${")||b.includes("}"))return null;let x=v.slice(0,-1);for(let T of b.split("/"))if(!(!T||T==="."))if(T===".."){if(!x.length)return null;x.pop()}else x.push(T);let _=x.join("/");return _.length<=500&&u(_)?_:null}function d(f){if(r(f)!=="kicad_pcb")throw new Error("Expected a saved KiCad PCB.");let p=new Set(["at","layer","uuid","tstamp","model","embedded_files"]),v=["kicad_pcb"];for(let b of f){if(r(b)==="embedded_files"&&v.push(b),r(b)!=="footprint")continue;let x=["footprint"];if(v.push(x),!!b.some(_=>r(_)==="model"))for(let _ of b){let T=r(_);p.has(T)?x.push(_):(T==="property"&&n(_[1])==="Reference"||T==="fp_text"&&n(_[1])==="reference")&&x.push(_.slice(0,3))}}return v}function m(f,p,v=i.KiCadDesignDiff?.parse,b=[]){if(typeof v!="function")throw new Error("KiCad S-expression parser is unavailable.");return g(v(f),p,b)}function g(f,p,v=[]){if(r(f)!=="kicad_pcb")throw new Error("Expected a saved KiCad PCB.");let b=[],x=[],_=N=>{x.length<48&&x.push(N)},T=Array.isArray(v)?v.slice(0,2e3).filter(N=>u(N)&&N.split("/").every(L=>L&&L!=="."&&L!=="..")):[];function w(N,L){let D=h(p,N),$=/^(?:\$\{(?:KICAD\d+_3DMODEL_DIR|KISYS3DMOD)\}|\$\((?:KICAD\d+_3DMODEL_DIR|KISYS3DMOD)\))[\\/]/,U=typeof N=="string"&&$.test(N)?N.replace($,"").replace(/\\/g,"/"):null,I=D||U;if(D&&(!T.length||T.includes(D)))return D;if(Array.isArray(v)&&v.length>=2e3)return D||_(`${L}: model discovery is incomplete; library recovery is unavailable: ${String(N).slice(0,100)}`),D;if(D){let V=T.filter(W=>W.toLowerCase()===D.toLowerCase());if(V.length===1)return _(`${L}: model path casing corrected to ${V[0]}`),V[0];if(V.length>1)return _(`${L}: model path casing is ambiguous: ${D}`),null}if(I&&u(I)&&I.split("/").every(V=>V&&V!=="."&&V!=="..")){let V=U?T.filter(Q=>Q===U||Q.endsWith("/"+U)):[];if(V.length===1)return V[0];if(V.length>1)return _(`${L}: model library path matches multiple repository files: ${U}`),null;if(U){let Q=U.toLowerCase(),se=T.filter(oe=>oe.toLowerCase()===Q||oe.toLowerCase().endsWith("/"+Q));if(se.length===1)return _(`${L}: model path casing corrected to ${se[0]}`),se[0];if(se.length>1)return _(`${L}: model path casing is ambiguous: ${U}`),null}let W=I.replace(/\.(?:step|stp|wrl|vrml)$/i,"");if(W!==I){let Q=T.filter(se=>{let oe=se.replace(/\.(?:step|stp|wrl|vrml)$/i,"");return oe!==se&&(oe.toLowerCase()===W.toLowerCase()||U&&oe.toLowerCase().endsWith("/"+W.toLowerCase()))});if(Q.length===1)return _(`${L}: using repository model alternative ${Q[0]} for ${N}`),Q[0];if(Q.length>1)return _(`${L}: model alternatives are ambiguous: ${I}`),null}}return D||(!U||!u(U)||U.split("/").some(V=>!V||V==="."||V==="..")||_(`${L}: library model is not included in this project: ${U}. Include the model files with the project to load them offline or in the browser.`),null)}function A(N){let L=new Map;for(let D of s(o(N,"embedded_files"),"file")){let $=a(D,"name");if(!(!u($)||$.split("/").some(U=>!U||U==="."||U===".."))){if(L.has($)){L.set($,null),_(`Duplicate embedded model name: ${$}`);continue}L.set($,D)}}return L}let E=A(f),M=new WeakMap;function P(N){if(!N)return null;if(M.has(N))return M.get(N);let L=o(N,"data"),D=0;for(let I=1;I<(L?.length||0)&&D<=11200002;I++)D+=String(n(L[I])).length;let $=D&&D<=11200002?L.slice(1).map(n).join(""):"",U=$.startsWith("|")&&$.endsWith("|")?{base64:$.slice(1,-1),checksum:String(a(N,"checksum")||"")}:null;return M.set(N,U),U}for(let[N,L]of s(f,"footprint").entries()){let D=s(L,"model");if(!D.length)continue;let $=s(L,"property").find(S=>n(S[1])==="Reference"),U=s(L,"fp_text").find(S=>n(S[1])==="reference"),I=String(n($?.[2])||n(U?.[2])||`REF${N+1}`),V=a(L,"uuid")||a(L,"tstamp")||`component-${I}`,W=o(L,"at"),Q=c(W?.[1],NaN),se=c(W?.[2],NaN),oe=c(W?.[3],0),ge=String(a(L,"layer")||"F.Cu");if(![Q,se,oe].every(Number.isFinite)||!["F.Cu","B.Cu"].includes(ge)){_(`${I}: footprint placement or side is unsupported.`);continue}let O;for(let S of D){if(b.length>=2048)return _("Only the first 2048 footprint model references are loaded."),{models:b,diagnostics:x};let R=n(S[1]),z=typeof R=="string"&&R.startsWith("kicad-embed://")?R.slice(14):null;z!==null&&(O??=A(L));let Y=z!==null?P(O.has(z)?O.get(z):E.get(z)):null;if(z!==null&&!Y){_(`${I}: embedded model is missing or ambiguous: ${z}`);continue}let K=z!==null?R:w(R,I);if(!K){_(`${I}: model path is not a repository-relative file: ${String(R).slice(0,100)}`);continue}let re=/\.([a-z\d]+)$/i.exec(K)?.[1]?.toLowerCase();if(!["wrl","vrml","glb","step","stp"].includes(re)){_(`${I}: ${re==="step"||re==="stp"?"STEP":"model format"} is not supported in the browser: ${K}`);continue}let de=o(S,"hide");if(de&&n(de[1])!=="no"&&n(de[1])!==!1)continue;let te=l(S,"offset",[0,0,0]),ne=l(S,"scale",[1,1,1]),H=l(S,"rotate",[0,0,0]);if(te.some(_e=>!Number.isFinite(_e)||Math.abs(_e)>1e4)||ne.some(_e=>!Number.isFinite(_e)||_e<=0||_e>1e3)||H.some(_e=>!Number.isFinite(_e)||Math.abs(_e)>3600)){_(`${I}: model transform is invalid: ${K}`);continue}b.push({path:K,format:re,footprintId:String(V),reference:I,footprint:{x:Q,y:se,angle:oe,layer:ge},offset:te,scale:ne,rotate:H,...Y?{embeddedAsset:Y,assetKey:`embedded:${O.has(z)?N:"board"}:${z}`}:{}})}}return{models:b,diagnostics:x}}function y(f,p,v,b){let x=f.footprint.layer==="B.Cu",_=f.footprint.angle*Math.PI/180,[T,w,A]=f.offset,E=x?-w:w,M=["glb","step","stp"].includes(f.format)?1:2.54;return{position:[f.footprint.x-p+T*Math.cos(_)-E*Math.sin(_),v-f.footprint.y+T*Math.sin(_)+E*Math.cos(_),(x?-1:1)*(b/2+A)],footprintAngle:_,modelRotation:[(x?180:0)-f.rotate[0],(x?1:-1)*f.rotate[1],(x?1:-1)*f.rotate[2]].map(P=>P*Math.PI/180),scale:f.scale.map(P=>P*M)}}i.KiCadRepoModels={collect:m,collectParsed:g,modelSource:d,resolveModelPath:h,modelPose:y},typeof tm=="object"&&tm.exports&&(tm.exports=i.KiCadRepoModels)})(typeof globalThis=="object"?globalThis:EE)});var TE=go((SE,Gy)=>{(function(i){typeof Gy<"u"&&typeof SE=="object"?Gy.exports=i():typeof define<"u"&&define.amd?define(["fzstd",i]):(typeof self<"u"?self:this).fzstd=i()})(function(){var i={},e=ArrayBuffer,t=Uint8Array,n=Uint16Array,r=Int16Array,s=Uint32Array,o=Int32Array,a=function(U,I,V){if(t.prototype.slice)return t.prototype.slice.call(U,I,V);(I==null||I<0)&&(I=0),(V==null||V>U.length)&&(V=U.length);var W=new t(V-I);return W.set(U.subarray(I,V)),W},c=function(U,I,V,W){if(t.prototype.fill)return t.prototype.fill.call(U,I,V,W);for((V==null||V<0)&&(V=0),(W==null||W>U.length)&&(W=U.length);V<W;++V)U[V]=I;return U},l=function(U,I,V,W){if(t.prototype.copyWithin)return t.prototype.copyWithin.call(U,I,V,W);for((V==null||V<0)&&(V=0),(W==null||W>U.length)&&(W=U.length);V<W;)U[I++]=U[V++]};i.ZstdErrorCode={InvalidData:0,WindowSizeTooLarge:1,InvalidBlockType:2,FSEAccuracyTooHigh:3,DistanceTooFarBack:4,UnexpectedEOF:5};var u=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],h=function(U,I,V){var W=Error(I||u[U]);if(W.code=U,Error.captureStackTrace&&Error.captureStackTrace(W,h),!V)throw W;return W},d=function(U,I,V){for(var W=0,Q=0;W<V;++W)Q|=U[I++]<<(W<<3);return Q},m=function(U,I){return(U[I]|U[I+1]<<8|U[I+2]<<16|U[I+3]<<24)>>>0},g=function(U,I){var V=U[0]|U[1]<<8|U[2]<<16;if(V==3126568&&U[3]==253){var W=U[4],Q=W>>5&1,se=W>>2&1,oe=3&W,ge=W>>6;8&W&&h(0);var O=6-Q,S=oe==3?4:oe,R=d(U,O,S),z=ge?1<<ge:Q,Y=d(U,O+=S,z)+(ge==1&&256),K=Y;if(!Q){var re=1<<10+(U[5]>>3);K=re+(re>>3)*(7&U[5])}K>2145386496&&h(1);var de=new t((I==1?Y||K:I?0:K)+12);return de[0]=1,de[4]=4,de[8]=8,{b:O+z,y:0,l:0,d:R,w:I&&I!=1?I:de.subarray(12),e:K,o:new o(de.buffer,0,3),u:Y,c:se,m:Math.min(131072,K)}}if((V>>4|U[3]<<20)==25481893)return m(U,4)+8;h(0)},y=function(U){for(var I=0;1<<I<=U;++I);return I-1},f=function(U,I,V){var W=4+(I<<3),Q=5+(15&U[I]);Q>V&&h(3);for(var se=1<<Q,oe=se,ge=-1,O=-1,S=-1,R=se,z=new e(512+(se<<2)),Y=new r(z,0,256),K=new n(z,0,256),re=new n(z,512,se),de=512+(se<<1),te=new t(z,de,se),ne=new t(z,de+se);ge<255&&oe>0;){var H=y(oe+1),_e=W>>3,me=(1<<H+1)-1,be=(U[_e]|U[_e+1]<<8|U[_e+2]<<16)>>(7&W)&me,he=(1<<H)-1,Ne=me-oe-1,Me=be&he;if(Me<Ne?(W+=H,be=Me):(W+=H+1,be>he&&(be-=Ne)),Y[++ge]=--be,be==-1?(oe+=be,te[--R]=ge):oe-=be,!be)do{var Z=W>>3;O=(U[Z]|U[Z+1]<<8)>>(7&W)&3,W+=2,ge+=O}while(O==3)}(ge>255||oe)&&h(0);for(var B=0,k=(se>>1)+(se>>3)+3,F=se-1,G=0;G<=ge;++G){var j=Y[G];if(j<1)K[G]=-j;else for(S=0;S<j;++S){te[B]=G;do B=B+k&F;while(B>=R)}}for(B&&h(0),S=0;S<se;++S){var ee=K[te[S]]++,ie=ne[S]=Q-y(ee);re[S]=(ee<<ie)-se}return[W+7>>3,{b:Q,s:te,n:ne,t:re}]},p=function(U,I){var V=0,W=-1,Q=new t(292),se=U[I],oe=Q.subarray(0,256),ge=Q.subarray(256,268),O=new n(Q.buffer,268);if(se<128){var S=f(U,I+1,6),R=S[1],z=S[0]<<3,Y=U[I+=se];Y||h(0);for(var K=0,re=0,de=R.b,te=de,ne=(++I<<3)-8+y(Y);!((ne-=de)<z);){var H=ne>>3;if(oe[++W]=R.s[K+=(U[H]|U[H+1]<<8)>>(7&ne)&(1<<de)-1],(ne-=te)<z)break;oe[++W]=R.s[re+=(U[H=ne>>3]|U[H+1]<<8)>>(7&ne)&(1<<te)-1],de=R.n[K],K=R.t[K],te=R.n[re],re=R.t[re]}++W>255&&h(0)}else{for(W=se-127;V<W;V+=2){var _e=U[++I];oe[V]=_e>>4,oe[V+1]=15&_e}++I}var me=0;for(V=0;V<W;++V)(Me=oe[V])>11&&h(0),me+=Me&&1<<Me-1;var be=y(me)+1,he=1<<be,Ne=he-me;for(Ne&Ne-1&&h(0),oe[W++]=y(Ne)+1,V=0;V<W;++V){var Me;++ge[oe[V]=(Me=oe[V])&&be+1-Me]}var Z=new t(he<<1),B=Z.subarray(0,he),k=Z.subarray(he);for(O[be]=0,V=be;V>0;--V){var F=O[V];c(k,V,F,O[V-1]=F+ge[V]*(1<<be-V))}for(O[0]!=he&&h(0),V=0;V<W;++V){var G=oe[V];if(G){var j=O[G];c(B,V,j,O[G]=j+(1<<be-G))}}return[I,{n:k,b:be,s:B}]},v=f(new t([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],b=f(new t([33,20,196,24,99,140,33,132,16,66,8,33,132,16,66,8,33,68,68,68,68,68,68,68,68,36,9]),0,6)[1],x=f(new t([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],_=function(U,I){for(var V=U.length,W=new o(V),Q=0;Q<V;++Q)W[Q]=I,I+=1<<U[Q];return W},T=new t(new o([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),w=_(T,0),A=new t(new o([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),E=_(A,3),M=function(U,I,V){var W=U.length,Q=I.length,se=U[W-1],oe=(1<<V.b)-1,ge=-V.b;se||h(0);for(var O=0,S=V.b,R=(W<<3)-8+y(se)-S,z=-1;R>ge&&z<Q;){var Y=R>>3;I[++z]=V.s[O=(O<<S|(U[Y]|U[Y+1]<<8|U[Y+2]<<16)>>(7&R))&oe],R-=S=V.n[O]}R==ge&&z+1==Q||h(0)},P=function(U,I,V){var W=6,Q=I.length+3>>2,se=Q<<1,oe=Q+se;M(U.subarray(W,W+=U[0]|U[1]<<8),I.subarray(0,Q),V),M(U.subarray(W,W+=U[2]|U[3]<<8),I.subarray(Q,se),V),M(U.subarray(W,W+=U[4]|U[5]<<8),I.subarray(se,oe),V),M(U.subarray(W),I.subarray(oe),V)},N=function(U,I,V){var W,Q=I.b,se=U[Q],oe=se>>1&3;I.l=1&se;var ge=se>>3|U[Q+1]<<5|U[Q+2]<<13,O=(Q+=3)+ge;if(oe==1)return Q>=U.length?void 0:(I.b=Q+1,V?(c(V,U[Q],I.y,I.y+=ge),V):c(new t(ge),U[Q]));if(!(O>U.length)){if(oe==0)return I.b=O,V?(V.set(U.subarray(Q,O),I.y),I.y+=ge,V):a(U,Q,O);if(oe==2){var S=U[Q],R=3&S,z=S>>2&3,Y=S>>4,K=0,re=0;R<2?1&z?Y|=U[++Q]<<4|(2&z&&U[++Q]<<12):Y=S>>3:(re=z,z<2?(Y|=(63&U[++Q])<<4,K=U[Q]>>6|U[++Q]<<2):z==2?(Y|=U[++Q]<<4|(3&U[++Q])<<12,K=U[Q]>>2|U[++Q]<<6):(Y|=U[++Q]<<4|(63&U[++Q])<<12,K=U[Q]>>6|U[++Q]<<2|U[++Q]<<10)),++Q;var de=V?V.subarray(I.y,I.y+I.m):new t(I.m),te=de.length-Y;if(R==0)de.set(U.subarray(Q,Q+=Y),te);else if(R==1)c(de,U[Q++],te);else{var ne=I.h;if(R==2){var H=p(U,Q);K+=Q-(Q=H[0]),I.h=ne=H[1]}else ne||h(0);(re?P:M)(U.subarray(Q,Q+=K),de.subarray(te),ne)}var _e=U[Q++];if(_e){_e==255?_e=32512+(U[Q++]|U[Q++]<<8):_e>127&&(_e=_e-128<<8|U[Q++]);var me=U[Q++];3&me&&h(0);for(var be=[b,x,v],he=2;he>-1;--he){var Ne=me>>2+(he<<1)&3;if(Ne==1){var Me=new t([0,0,U[Q++]]);be[he]={s:Me.subarray(2,3),n:Me.subarray(0,1),t:new n(Me.buffer,0,1),b:0}}else Ne==2?(Q=(W=f(U,Q,9-(1&he)))[0],be[he]=W[1]):Ne==3&&(I.t||h(0),be[he]=I.t[he])}var Z=I.t=be,B=Z[0],k=Z[1],F=Z[2],G=U[O-1];G||h(0);var j=(O<<3)-8+y(G)-F.b,ee=j>>3,ie=0,ce=(U[ee]|U[ee+1]<<8)>>(7&j)&(1<<F.b)-1,fe=(U[ee=(j-=k.b)>>3]|U[ee+1]<<8)>>(7&j)&(1<<k.b)-1,ue=(U[ee=(j-=B.b)>>3]|U[ee+1]<<8)>>(7&j)&(1<<B.b)-1;for(++_e;--_e;){var Ee=F.s[ce],Se=F.n[ce],De=B.s[ue],ze=B.n[ue],Je=k.s[fe],Fe=k.n[fe],Xe=1<<Je,ae=Xe+((U[ee=(j-=Je)>>3]|U[ee+1]<<8|U[ee+2]<<16|U[ee+3]<<24)>>>(7&j)&Xe-1);ee=(j-=A[De])>>3;var Le=E[De]+((U[ee]|U[ee+1]<<8|U[ee+2]<<16)>>(7&j)&(1<<A[De])-1);ee=(j-=T[Ee])>>3;var xe=w[Ee]+((U[ee]|U[ee+1]<<8|U[ee+2]<<16)>>(7&j)&(1<<T[Ee])-1);if(ee=(j-=Se)>>3,ce=F.t[ce]+((U[ee]|U[ee+1]<<8)>>(7&j)&(1<<Se)-1),ee=(j-=ze)>>3,ue=B.t[ue]+((U[ee]|U[ee+1]<<8)>>(7&j)&(1<<ze)-1),ee=(j-=Fe)>>3,fe=k.t[fe]+((U[ee]|U[ee+1]<<8)>>(7&j)&(1<<Fe)-1),ae>3)I.o[2]=I.o[1],I.o[1]=I.o[0],I.o[0]=ae-=3;else{var ye=ae-(xe!=0);ye?(ae=ye==3?I.o[0]-1:I.o[ye],ye>1&&(I.o[2]=I.o[1]),I.o[1]=I.o[0],I.o[0]=ae):ae=I.o[0]}for(he=0;he<xe;++he)de[ie+he]=de[te+he];te+=xe;var Ue=(ie+=xe)-ae;if(Ue<0){var Oe=-Ue,st=I.e+Ue;for(Oe>Le&&(Oe=Le),he=0;he<Oe;++he)de[ie+he]=I.w[st+he];ie+=Oe,Le-=Oe,Ue=0}for(he=0;he<Le;++he)de[ie+he]=de[Ue+he];ie+=Le}if(ie!=te)for(;te<de.length;)de[ie++]=de[te++];else ie=de.length;V?I.y+=ie:de=a(de,0,ie)}else if(V){if(I.y+=Y,te)for(he=0;he<Y;++he)de[he]=de[te+he]}else te&&(de=a(de,te));return I.b=O,de}h(2)}},L=function(U,I){if(U.length==1)return U[0];for(var V=new t(I),W=0,Q=0;W<U.length;++W){var se=U[W];V.set(se,Q),Q+=se.length}return V};function D(U,I){for(var V=[],W=+!I,Q=0,se=0;U.length;){var oe=g(U,W||I);if(typeof oe=="object"){for(W?(I=null,oe.w.length==oe.u&&(V.push(I=oe.w),se+=oe.u)):(V.push(I),oe.e=0);!oe.l;){var ge=N(U,oe,I);ge||h(5),I?oe.e=oe.y:(V.push(ge),se+=ge.length,l(oe.w,0,ge.length),oe.w.set(ge,oe.w.length-ge.length))}Q=oe.b+4*oe.c}else Q=oe;U=U.subarray(Q)}return L(V,se)}i.decompress=D;var $=(function(){function U(I){this.ondata=I,this.c=[],this.l=0,this.z=0}return U.prototype.push=function(I,V){if(typeof this.s=="number"){var W=Math.min(I.length,this.s);I=I.subarray(W),this.s-=W}var Q=I.length+this.l;if(!this.s){if(V){if(!Q)return void this.ondata(new t(0),!0);Q<5&&h(5)}else if(Q<18)return this.c.push(I),void(this.l=Q);if(this.l&&(this.c.push(I),I=L(this.c,Q),this.c=[],this.l=0),typeof(this.s=g(I))=="number")return this.push(I,V)}if(typeof this.s!="number"){if(Q<(this.z||3))return V&&h(5),this.c.push(I),void(this.l=Q);if(this.l&&(this.c.push(I),I=L(this.c,Q),this.c=[],this.l=0),!this.z&&Q<(this.z=2&I[this.s.b]?4:3+(I[this.s.b]>>3|I[this.s.b+1]<<5|I[this.s.b+2]<<13)))return V&&h(5),this.c.push(I),void(this.l=Q);for(this.z=0;;){var se=N(I,this.s);if(!se){V&&h(5);var oe=I.subarray(this.s.b);return this.s.b=0,this.c.push(oe),void(this.l+=oe.length)}if(this.ondata(se,!1),l(this.s.w,0,se.length),this.s.w.set(se,this.s.w.length-se.length),this.s.l){var ge=I.subarray(this.s.b);return this.s=4*this.s.c,void this.push(ge,V)}}}else V&&h(5)},U})();return i.Decompress=$,i})});var wE=go((AE,nm)=>{(i=>{"use strict";function t(u,{maxBytes:h=8388608,padded:d=!1,host:m=i}={}){if(!Number.isSafeInteger(h)||h<0||h>8388608||typeof u!="string"||u.length>112e5)throw Error("Invalid or oversized model base64.");let g=u.length,y=u.endsWith("==")?2:u.endsWith("=")?1:0;if(g%4===1||(y||d)&&g%4!==0)throw Error("Invalid model base64 padding.");let f=g-y;for(let _=0;_<f;_++){let T=u.charCodeAt(_);if(!(T>=65&&T<=90||T>=97&&T<=122||T>=48&&T<=57||T===43||T===47))throw Error("Invalid model base64.")}let p=Math.floor(g*3/4)-y;if(p>h)throw Error("Model base64 exceeds its decoded byte limit.");let v=m.Uint8Array?.fromBase64;if(typeof v=="function")return v.call(m.Uint8Array,u);let b=m.atob(u),x=new Uint8Array(p);for(let _=0;_<p;_++)x[_]=b.charCodeAt(_);return x}function n(u,h=!1){let d=(1n<<64n)-1n,m=0x87c37b91114253d5n,g=0x4cf5ad432745937fn,y=(A,E)=>(A<<E|A>>64n-E)&d,f=(A,E)=>{let M=0n;for(let P=0;P<E;P++)M|=BigInt(u[A+P]||0)<<BigInt(P*8);return M},p=A=>(A^=A>>33n,A=A*0xff51afd7ed558ccdn&d,A^=A>>33n,A=A*0xc4ceb9fe1a85ec53n&d,A^A>>33n),v=0xabba2345n,b=v,x=new DataView(u.buffer,u.byteOffset,u.byteLength),_=u.length-u.length%16;for(let A=0;A<_;A+=16){let E=x.getBigUint64(A,!0),M=x.getBigUint64(A+8,!0);E=y(E*m&d,31n)*g&d,v^=E,v=(y(v,27n)+b)*5n+0x52dce729n&d,M=y(M*g&d,33n)*m&d,b^=M,b=(y(b,31n)+v)*5n+0x38495ab5n&d}let T=h?Math.ceil(u.length/4)*4:u.length,w=T%16;return w>8&&(b^=y(f(_+8,w-8)*g&d,33n)*m&d),w&&(v^=y(f(_,Math.min(8,w))*m&d,31n)*g&d),v^=BigInt(T),b^=BigInt(T),v=v+b&d,b=b+v&d,v=p(v),b=p(b),v=v+b&d,b=b+v&d,v.toString(16).padStart(16,"0")+b.toString(16).padStart(16,"0")}function r(u){let h=new DataView(u.buffer,u.byteOffset,u.byteLength);if(u.length<6||h.getUint32(0,!0)!==4247762216)throw Error("Embedded model is not Zstandard.");let d=u[4],m=!!(d&32),g=d>>>6;if(d&24)throw Error("Unsupported Zstandard frame flags.");let y=5;if(!m){let x=u[y++];if(2**(10+(x>>>3))*(1+(x&7)/8)>8388608)throw Error("Embedded model window exceeds 8 MiB.")}if([0,1,2,4][d&3])throw Error("Embedded model requires a Zstandard dictionary.");let p=g?[0,2,4,8][g]:m?1:0;if(!p||y+p>u.length)throw Error("Embedded model has no bounded content size.");let v=0;for(let x=0;x<p;x++)v+=u[y++]*2**(8*x);if(g===1&&(v+=256),!Number.isSafeInteger(v)||v<=0||v>8388608)throw Error("Embedded model exceeds 8 MiB.");let b=!1;for(;!b;){if(y+3>u.length)throw Error("Truncated embedded model block.");let x=u[y]|u[y+1]<<8|u[y+2]<<16;y+=3,b=!!(x&1);let _=x>>>1&3,T=x>>>3;if(_===3||T>131072)throw Error("Invalid embedded model block.");if(y+=_===1?1:T,y>u.length)throw Error("Truncated embedded model block.")}if(d&4&&(y+=4),y!==u.length)throw Error("Embedded model has trailing or missing frame data.");return v}async function s(u,h=i.fzstd?.decompress,d=8388608){let m=u?.base64,g=t(m,{padded:!0});if(g.length>8388608)throw Error("Compressed embedded model exceeds 8 MiB.");let y=r(g);if(y>d)throw Error("Embedded asset exceeds its allocation budget.");if(typeof h!="function")throw Error("Embedded model decoder unavailable.");let f=h(g,new Uint8Array(y));if(!(f instanceof Uint8Array)||f.length!==y)throw Error("Embedded model size mismatch.");if(/^[a-f0-9]{64}$/i.test(u.checksum||"")){let p=new Uint8Array(await i.crypto.subtle.digest("SHA-256",f));if(Array.from(p,b=>b.toString(16).padStart(2,"0")).join("")!==u.checksum.toLowerCase())throw Error("Embedded model checksum mismatch.")}else if(/^[a-f0-9]{32}$/i.test(u.checksum||"")){let p=u.checksum.toLowerCase();if(n(f)!==p&&n(f,!0)!==p)throw Error("Embedded model checksum mismatch.")}else throw Error("Embedded model checksum is missing or unsupported.");return f}function o(u){let h=new DataView(u.buffer,u.byteOffset,u.byteLength),d=new Set;if(h.byteLength<12||![65536,1330926671,1953658213].includes(h.getUint32(0)))return d;let m=h.getUint16(4);if(m>256||12+m*16>h.byteLength)return d;for(let g=12;g<12+m*16;g+=16){if(h.getUint32(g)!==1851878757)continue;let y=h.getUint32(g+8),f=h.getUint32(g+12);if(f<6||y+f>h.byteLength)break;let p=h.getUint16(y+2),v=y+h.getUint16(y+4);if(p>2048||v<y+6+p*12||v>y+f)break;let b=new TextDecoder("utf-16be");for(let x=0;x<p;x++){let _=y+6+x*12,T=h.getUint16(_),w=h.getUint16(_+6);if(![0,3].includes(T)||![1,4,6,16].includes(w))continue;let A=h.getUint16(_+8),E=v+h.getUint16(_+10);if(!A||A>512||A%2||E+A>y+f)continue;let M=b.decode(u.subarray(E,E+A)).trim().toLowerCase();M&&!M.includes("\0")&&d.add(M)}break}return d}function a(u){let h=new DataView(u.buffer,u.byteOffset,u.byteLength),d=h.getUint16(4);for(let m=12;m<12+d*16;m+=16){if(h.getUint32(m)!==1751474532)continue;let g=h.getUint32(m+8),y=h.getUint32(m+12);if(y<46||g+y>u.length)break;let f=h.getUint16(g+44);return{weight:f&1?"bold":"normal",style:f&2?"italic":"normal"}}return{weight:"normal",style:"normal"}}let c=0;function l(u,h,d,m,g=i,y){if(!u?.length||!h.size||typeof g.FontFace!="function"||!g.document?.fonts)return null;let f=++c,p=new Map,v=[],b=new Set,x=g.document.fonts,_=!1,T=8*1024*1024,w;async function A(){for(let E of u){if(await new Promise(M=>setTimeout(M,0)),_||T<=0)return;try{if(w??=y?await y():g.fzstd?.decompress,_)return;let M=await s(E,w,Math.min(T,2*1024*1024));if(_)return;T-=M.length;let P=[...o(M)].filter(L=>h.has(L));if(!P.length)continue;let N=a(M);for(let L of P){let D=JSON.stringify([L,N.weight,N.style]);if(b.has(D))continue;let $=p.get(L)||"kivi-embedded-"+f+"-"+p.size,U=await new g.FontFace($,M,N).load();if(_)return;x.add(U),v.push(U),b.add(D),p.set(L,$)}}catch(M){_||m?.(E.name,M.message)}}!_&&v.length&&d()}return A(),{family(E){return typeof E=="string"?p.get(E.trim().toLowerCase()):void 0},dispose(){_=!0;for(let E of v)x.delete(E);v.length=0,p.clear()}}}i.KiCadEmbeddedFonts={mount:l,fontNames:o},i.KiCadEmbeddedModels={decode:s,decodeBase64:t,frameSize:r,murmur:n,MAX_BYTES:8388608,fontNames:o,mountFonts:l},typeof nm=="object"&&nm.exports&&(nm.exports=i.KiCadEmbeddedModels)})(typeof globalThis=="object"?globalThis:AE)});var CE=go((RE,im)=>{(i=>{"use strict";function e(r){if(r?.success!==!0||!Array.isArray(r.meshes)||!r.meshes.length||r.meshes.length>512)throw new Error("STEP did not produce a supported mesh.");let s=0,o=0,a=0;return r.meshes.map((c,l)=>{let u=c.attributes?.position?.array,h=c.index?.array,d=c.attributes?.normal?.array;if(!Array.isArray(u)||u.length%3||!u.length||!Array.isArray(h)||h.length%3||!h.length)throw new Error("STEP returned invalid mesh arrays.");if(s+=u.length/3,o+=h.length/3,s>5e5||o>5e5)throw new Error("STEP tessellation exceeds 500,000 vertices or triangles.");if(u.some(A=>!Number.isFinite(A)||Math.abs(A)>1e6)||h.some(A=>!Number.isSafeInteger(A)||A<0||A>=u.length/3))throw new Error("STEP mesh coordinates or indices are invalid.");if(d&&(!Array.isArray(d)||d.length!==u.length||d.some(A=>!Number.isFinite(A))))throw new Error("STEP returned invalid mesh normals.");let m=Array.isArray(c.color)&&c.color.length===3&&c.color.every(A=>Number.isFinite(A)&&A>=0&&A<=1)?c.color:[.65,.68,.7],g=c.brep_faces;if(g!==void 0&&(!Array.isArray(g)||g.length>h.length/3))throw new Error("STEP returned invalid face ranges.");let y=[m],f=new Map([[JSON.stringify(m),0]]),p=new Uint8Array(h.length/3).fill(255),v=Math.min(8,1024-a-(r.meshes.length-l-1));for(let A of g||[]){let E=A?.first,M=A?.last;if(!Number.isSafeInteger(E)||!Number.isSafeInteger(M)||E<0||M<E||M>=p.length)throw new Error("STEP returned invalid face ranges.");let P=Array.isArray(A.color)&&A.color.length===3&&A.color.every(D=>Number.isFinite(D)&&D>=0&&D<=1),N=P?JSON.stringify(A.color):null,L=P?f.get(N):0;if(L===void 0){if(y.length>=v)throw new Error("STEP face colours exceed the bounded material budget.");L=y.length,y.push(A.color),f.set(N,L)}for(let D=E;D<=M;D++){if(p[D]!==255)throw new Error("STEP returned overlapping face ranges.");p[D]=L}}let b=new Uint32Array(y.length);for(let A=0;A<p.length;A++)p[A]===255&&(p[A]=0),b[p[A]]+=3;let x=[],_=new Uint32Array(y.length),T=0;for(let A=0;A<y.length;A++)_[A]=T,b[A]&&(x.push({start:T,count:b[A],color:y[A]}),T+=b[A]);a+=x.length;let w=new Uint32Array(h.length);for(let A=0;A<p.length;A++){let E=_[p[A]];_[p[A]]+=3,w[E]=h[A*3],w[E+1]=h[A*3+1],w[E+2]=h[A*3+2]}return{positions:new Float32Array(u),normals:d?new Float32Array(d):null,index:w,color:m,groups:x}})}async function t(r,s=i.Worker,o=i,a){let c=await o.fetch(r,{credentials:"omit",redirect:"error",signal:a});if(!c.ok)throw new Error("Bundled STEP worker could not be read.");let l=await c.arrayBuffer();if(l.byteLength>256*1024)throw new Error("Bundled STEP worker exceeds 256 KiB.");let u=o.URL.createObjectURL(new o.Blob([l],{type:"text/javascript"}));try{return new s(u)}finally{o.URL.revokeObjectURL(u)}}class n{constructor(s,o=i.Worker){this.url=s,this.WorkerType=o,this.worker=null,this.queue=Promise.resolve(),this.disposed=!1,this.pending=null,this.loadingAbort=null,this.initialized=!1,this.wasmUrl=i.KiCadVSCodeContext?.stepWasmUrl}decode(s){let o=()=>this.run(s),a=this.queue.then(o,o);return this.queue=a.catch(()=>{}),a}async run(s){if(this.disposed)throw new Error("STEP decoder is closed.");if(!(s instanceof Uint8Array)||!s.byteLength||s.byteLength>8*1024*1024)throw new Error("STEP input exceeds 8 MiB or is empty.");if(!this.worker){this.initialized=!1;let o=new AbortController;this.loadingAbort=o;let a=setTimeout(()=>o.abort(),1e4);try{this.worker=i.KiCadVSCodeContext?.stepWorkerUrl?await t(i.KiCadVSCodeContext.stepWorkerUrl,this.WorkerType,i,o.signal):new this.WorkerType(this.url)}catch(c){throw new Error("STEP worker is unavailable: "+c.message)}finally{clearTimeout(a),this.loadingAbort=null}if(this.disposed)throw this.worker.terminate(),this.worker=null,new Error("STEP decoder is closed.")}return new Promise((o,a)=>{let c=(m,g)=>{clearTimeout(u),this.pending=null,this.worker&&(this.worker.onmessage=this.worker.onerror=null),m?a(m):o(g)},l=m=>{this.worker?.terminate(),this.worker=null,this.initialized=!1,c(new Error(m))},u,h=this.initialized,d=(m,g)=>{clearTimeout(u),u=setTimeout(()=>l(g),m)};d(this.initialized?3e4:6e4,this.initialized?"STEP conversion timed out after 30 seconds.":"STEP initialization timed out after 60 seconds."),this.pending=()=>l("STEP decoder is closed."),this.worker.onmessage=m=>{if(m.data?.stage==="kernel-ready"){h||(h=!0,this.initialized=!0,d(3e4,"STEP conversion timed out after 30 seconds."));return}this.initialized=m.data?.ok===!0,this.initialized?c(null,m.data.meshes):c(new Error(m.data?.error||"STEP conversion failed."))},this.worker.onerror=()=>l("STEP worker failed.");try{let m=s.slice();this.worker.postMessage({bytes:m,reportStages:!0,...this.wasmUrl?{wasmUrl:this.wasmUrl}:{}},[m.buffer])}catch{l("STEP worker could not accept input.")}})}dispose(){this.disposed=!0,this.loadingAbort?.abort(),this.pending?.(),this.worker?.terminate(),this.worker=null}}i.KiCadStepDecoder={meshes:e,Client:n,bundledWorker:t},typeof im=="object"&&im.exports&&(im.exports=i.KiCadStepDecoder)})(typeof globalThis=="object"?globalThis:RE)});var zE=go((uN,om)=>{(i=>{"use strict";let e={"F.Cu":["#c83434",1],"B.Cu":["#4d7fc4",1],"In1.Cu":["#7fc87f",1],"In2.Cu":["#ce7d2c",1],"In3.Cu":["#4fcbcb",1],"In4.Cu":["#db628b",1],"In5.Cu":["#a7a5c6",1],"In6.Cu":["#28ccd9",1],"In7.Cu":["#e8b2a7",1],"In8.Cu":["#f2eda1",1],"In9.Cu":["#8dcb81",1],"In10.Cu":["#ed7c33",1],"In11.Cu":["#5bc3eb",1],"In12.Cu":["#f76f8e",1],"In13.Cu":["#a7a5c6",1],"In14.Cu":["#28ccd9",1],"In15.Cu":["#e8b2a7",1],"In16.Cu":["#f2eda1",1],"In17.Cu":["#ed7c33",1],"In18.Cu":["#5bc3eb",1],"In19.Cu":["#f76f8e",1],"In20.Cu":["#a7a5c6",1],"In21.Cu":["#28ccd9",1],"In22.Cu":["#e8b2a7",1],"In23.Cu":["#f2eda1",1],"In24.Cu":["#ed7c33",1],"In25.Cu":["#5bc3eb",1],"In26.Cu":["#f76f8e",1],"In27.Cu":["#a7a5c6",1],"In28.Cu":["#28ccd9",1],"In29.Cu":["#e8b2a7",1],"In30.Cu":["#f2eda1",1],"F.Adhes":["#840084",1],"B.Adhes":["#000084",1],"F.Paste":["#b4a09a",.9],"B.Paste":["#00c2c2",.9],"F.SilkS":["#f2eda1",1],"B.SilkS":["#e8b2a7",1],"F.Mask":["#d864ff",.4],"B.Mask":["#02ffee",.4],"F.Fab":["#afafaf",1],"B.Fab":["#585d84",1],"F.CrtYd":["#ff26e2",1],"B.CrtYd":["#26e9ff",1],"Edge.Cuts":["#d0d2cd",1],Margin:["#ff26e2",1],"Dwgs.User":["#c2c2c2",1],"Cmts.User":["#5994dc",1],"Eco1.User":["#b4dbd2",1],"Eco2.User":["#d8c852",1],"User.1":["#c2c2c2",1],"User.2":["#5994dc",1],"User.3":["#b4dbd2",1],"User.4":["#d8c852",1],"User.5":["#c2c2c2",1],"User.6":["#5994dc",1],"User.7":["#b4dbd2",1],"User.8":["#d8c852",1],"User.9":["#e8b2a7",1],"User.10":["#5994dc",1],"User.11":["#b4dbd2",1],"User.12":["#d8c852",1],"User.13":["#c2c2c2",1],"User.14":["#5994dc",1],"User.15":["#b4dbd2",1],"User.16":["#d8c852",1],"User.17":["#c2c2c2",1],"User.18":["#5994dc",1],"User.19":["#b4dbd2",1],"User.20":["#d8c852",1],"User.21":["#c2c2c2",1],"User.22":["#5994dc",1],"User.23":["#b4dbd2",1],"User.24":["#d8c852",1],"User.25":["#c2c2c2",1],"User.26":["#5994dc",1],"User.27":["#b4dbd2",1],"User.28":["#d8c852",1],"User.29":["#c2c2c2",1],"User.30":["#5994dc",1],"User.31":["#b4dbd2",1],"User.32":["#d8c852",1],"User.33":["#c2c2c2",1],"User.34":["#5994dc",1],"User.35":["#b4dbd2",1],"User.36":["#d8c852",1],"User.37":["#c2c2c2",1],"User.38":["#5994dc",1],"User.39":["#b4dbd2",1],"User.40":["#d8c852",1],"User.41":["#c2c2c2",1],"User.42":["#5994dc",1],"User.43":["#b4dbd2",1],"User.44":["#d8c852",1],"User.45":["#c2c2c2",1]};for(let u of Object.values(e))Object.freeze(u);Object.freeze(e);let t=u=>e[String(u)]?.[0]||"#c2c2c2",n=u=>e[String(u)]?.[1]??1,r=u=>{let h=t(u),d=n(u);return d===1?h:`rgba(${parseInt(h.slice(1,3),16)},${parseInt(h.slice(3,5),16)},${parseInt(h.slice(5,7),16)},${d})`},s=Object.freeze({"F.Cu":"#fa6f68","B.Cu":"#63a5ff","F.SilkS":"#e8dcae","B.SilkS":"#b5c8df","F.Fab":"#b2bbc9","B.Fab":"#8d9ab0","F.CrtYd":"#c59be0","B.CrtYd":"#7bc6cf","Edge.Cuts":"#d6deea","F.Mask":"#b197d7","B.Mask":"#77bdb5","F.Paste":"#d2afa0","B.Paste":"#98c9ce"}),o=Object.freeze({"F.Cu":"#b9474c","B.Cu":"#3268ae","F.SilkS":"#766126","B.SilkS":"#596a87","F.Fab":"#647086","B.Fab":"#606c83","F.CrtYd":"#8c519e","B.CrtYd":"#257b85","Edge.Cuts":"#465368","F.Mask":"#9279b8","B.Mask":"#4d968a","F.Paste":"#9d796a","B.Paste":"#448b93"});function a(u,h=!0){let d=(h?s:o)[String(u)]||t(u),m=n(u);return m===1?d:`rgba(${parseInt(d.slice(1,3),16)},${parseInt(d.slice(3,5),16)},${parseInt(d.slice(5,7),16)},${m})`}function c(u){let h=String(u||"").toLowerCase(),d=/bottom|\bbot\b/.test(h),m=d?"B.":"F.";if(/drill|plated/.test(h))return null;if(/outline|profile/.test(h))return"Edge.Cuts";if(/copper/.test(h)){if(/inner|inr/.test(h)){let g=/copper,\s*l(\d+),\s*inr/.exec(h),y=/inner copper\s*(\d+)/.exec(h),f=g?Number(g[1])-1:y?Number(y[1]):0;return f>=1&&f<=30?"In"+f+".Cu":null}return m+"Cu"}return/mask/.test(h)?m+"Mask":/silk|legend/.test(h)?m+"SilkS":/paste/.test(h)?m+"Paste":null}let l=Object.freeze({entries:e,hexFor:t,opacityFor:n,colorFor:r,reviewColorFor:a,fabricationLayer:c});i.KiCadLayerColors=l,typeof om=="object"&&om.exports&&(om.exports=l)})(globalThis)});var UI={};uv(UI,{mountBoard3D:()=>FI,mountResultScene:()=>LM,mountSavedResult3D:()=>kM,objectVisibilityPolicy:()=>dx});function dv(i=512){if(!Number.isInteger(i)||i<0||i>4096)throw new TypeError("Choose a bounded geometry cache size.");let e=new Map,t=0,n=0;return{get(r,s){if(e.has(r))return t++,e.get(r);let o=s();return e.size<i?e.set(r,o):n++,o},clear(){e.clear()},stats(){return{entries:e.size,hits:t,uncached:n}}}}function fv(i,e=t=>t.assetKey||t.path){let t=new Map,n=new Map;for(let r of i){let s=e(r);t.set(s,(t.get(s)||0)+1)}return{get(r,s){let o=e(r);return n.has(o)||n.set(o,Promise.resolve().then(s)),n.get(o)},isLastUse(r){return t.get(e(r))===1},release(r){let s=e(r),o=(t.get(s)||0)-1;o>0?t.set(s,o):(t.delete(s),n.delete(s))},clear(){t.clear(),n.clear()},stats:()=>({templates:n.size,remainingAssets:t.size})}}var tg={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},pv={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Wr=(i,e)=>{if(!Number.isSafeInteger(i)||i<0)throw Error("Invalid GLB "+e+".");return i},xd=i=>{throw Object.assign(Error("Linked model "+i+" exceeds its decoded memory budget; saved footprint proxies and identities are retained."),{code:"MODEL_ALLOCATION_BUDGET"})},ng="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function IS(i,e){if(i.bufferView!==void 0){let a=e(i.bufferView);return{length:a.length,at:c=>a[c]}}let t=/^data:([^;,]+);base64,/i.exec(i.uri||"");if(!t)throw Error("Embedded model image has no supported bounded header.");let n=i.uri,r=t[0].length,s=n.length-r,o=n.endsWith("==")?2:n.endsWith("=")?1:0;if(s%4||s<4)throw Error("Invalid embedded image base64.");for(let a=r;a<n.length-o;a++)if(ng.indexOf(n[a])<0)throw Error("Invalid embedded image base64.");return{length:s*3/4-o,at(a){let c=Math.floor(a/3)*4+r,l=a%3,u=ng.indexOf(n[c+l]),h=ng.indexOf(n[c+l+1]);return l===0?(u<<2|h>>4)&255:l===1?(u<<4|h>>2)&255:(u<<6|h)&255}}}function NS(i){let e=i.length,t=i.at,n=s=>t(s)*256+t(s+1),r=s=>t(s)*16777216+t(s+1)*65536+t(s+2)*256+t(s+3);if(e>=24&&t(0)===137&&t(1)===80&&t(2)===78&&t(3)===71&&t(4)===13&&t(5)===10&&t(6)===26&&t(7)===10){if(r(8)!==13||r(12)!==1229472850)throw Error("Invalid embedded PNG header.");let s=r(16),o=r(20);if(!s||!o)throw Error("Invalid embedded PNG dimensions.");return{width:s,height:o}}if(e>=4&&t(0)===255&&t(1)===216){let s=2;for(;s<e;){if(t(s++)!==255)throw Error("Invalid embedded JPEG marker.");for(;s<e&&t(s)===255;)s++;if(s>=e)break;let o=t(s++);if(o===0||o===218||o===217)break;if(o===1||o>=208&&o<=216)continue;if(s+2>e)break;let a=n(s);if(a<2||s+a>e)throw Error("Invalid embedded JPEG segment.");if(o>=192&&o<=207&&![196,200,204].includes(o)){if(a<8)throw Error("Invalid embedded JPEG frame.");let c=n(s+3),l=n(s+5),u=t(s+7);if(!l||!c||!u||a<8+3*u)throw Error("Invalid embedded JPEG dimensions.");return{width:l,height:c}}s+=a}throw Error("Embedded JPEG has no bounded frame dimensions.")}throw Error("Embedded model image format has no bounded PNG/JPEG dimension preflight; saved footprint proxies are retained.")}function mv(i,e,t,{maxAccessorBytes:n=64*1024*1024,maxTextureBytes:r=32*1024*1024,maxTextureDimension:s=8192}={}){for(let[y,f]of[[n,"accessor budget"],[r,"texture budget"],[s,"texture dimension"]])if(!Number.isSafeInteger(y)||y<1)throw TypeError("Invalid GLB "+f+".");let o=null,a=t;for(;a<e.length;){if(a+8>e.length)throw Error("Truncated GLB chunk.");let y=new DataView(e.buffer,e.byteOffset+a,8),f=y.getUint32(0,!0),p=y.getUint32(4,!0);if(a+=8,f>e.length-a)throw Error("Truncated GLB chunk.");if(p===5130562){if(o)throw Error("Duplicate GLB binary chunk.");o=e.subarray(a,a+f)}a+=f}let c=i.buffers||[],l=i.bufferViews||[];function u(y){Wr(y,"buffer view index");let f=l[y];if(!f)throw Error("GLB references an invalid buffer view.");let p=c[Wr(f.buffer,"buffer index")];if(!p)throw Error("GLB references an invalid buffer.");let v=Wr(f.byteOffset??0,"buffer offset"),b=Wr(f.byteLength,"buffer length"),x=Wr(p.byteLength,"buffer length");if(!Number.isSafeInteger(v+b)||v+b>x)throw Error("GLB buffer view exceeds its declared buffer.");if(!p.uri&&(!o||x>o.length))throw Error("GLB buffer exceeds its binary chunk.");return{view:f,start:v,length:b,buffer:p}}let h=y=>{let{buffer:f,start:p,length:v}=u(y);if(f.uri)throw Error("Embedded image buffer uses an unsupported nested data URI.");return o.subarray(p,p+v)},d=0;for(let y=0;y<l.length;y++)d+=u(y).length,(!Number.isSafeInteger(d)||d>n+r)&&xd("buffer view expansion");let m=0;for(let y of i.accessors||[]){let f=Wr(y.count,"accessor count"),p=tg[y.componentType],v=pv[y.type];if(!f||!Number.isInteger(y.componentType)||!p||!Object.hasOwn(tg,y.componentType)||!v||!Object.hasOwn(pv,y.type))throw Error("Invalid GLB accessor component type, shape or count.");let b=y.type.startsWith("MAT")?Number(y.type.at(-1)):1,x=v/b,_=b>1?b*Math.ceil(x*p/4)*4:v*p,T=_,w=Wr(y.byteOffset??0,"accessor offset");if(w%p)throw Error("Misaligned GLB accessor offset.");if(y.bufferView!==void 0){let E=u(y.bufferView);if(T=E.view.byteStride??_,!Number.isSafeInteger(T)||T<_||T%p||E.view.byteStride!==void 0&&(T<4||T>252||T%4))throw Error("Invalid GLB accessor stride.");let M=(f-1)*T+_;if(!Number.isSafeInteger(M)||w+M>E.length)throw Error("GLB accessor exceeds its buffer view.")}else if(w)throw Error("GLB accessor without a buffer view has an offset.");let A=f*T;if(y.sparse){let E=y.sparse,M=Wr(E.count,"sparse count"),P=tg[E.indices?.componentType];if(!M||M>f||![5121,5123,5125].includes(E.indices?.componentType)||!E.values)throw Error("Invalid GLB sparse accessor.");for(let[N,L,D]of[[E.indices,M*P,P],[E.values,M*_,p]]){let $=u(N.bufferView),U=Wr(N.byteOffset??0,"sparse offset");if(U%D||U+L>$.length)throw Error("GLB sparse accessor exceeds its buffer view.")}A+=f*v*p}m+=A,(!Number.isSafeInteger(m)||m>n)&&xd("accessor expansion")}let g=0;for(let y of i.images||[]){let{width:f,height:p}=NS(IS(y,h));(f>s||p>s)&&xd("image dimensions"),g+=Math.ceil(f*p*4*4/3),(!Number.isSafeInteger(g)||g>r)&&xd("image pixels")}return{accessorBytes:m,textureBytes:g}}var gv=(i,e)=>i||e>512?1:3,Ss=()=>Object.assign(Error("Linked model graph exceeds the bounded assembly node budget; saved footprint proxies and identities are retained."),{code:"MODEL_GRAPH_BUDGET"});function yv(i){if(!Number.isSafeInteger(i)||i<1)throw TypeError("Choose a positive model node budget.");let e=new WeakMap,t=0,n=0,r=0;function s(o){if(e.has(o))return e.get(o);let a=[o],c=0;for(;a.length;){let l=a.pop();if(++c>i)throw Ss();for(let u of l.children||[]){if(c+a.length>=i)throw Ss();a.push(u)}}return e.set(o,c),c}return{limit:i,checkTemplate(o,a=0){try{let c=s(o);if(t+c+a>i)throw Ss();return c}catch(c){throw c.code==="MODEL_GRAPH_BUDGET"&&n++,c}},rejectPreflight(){n++},admit(o,a,c){let l=s(o)+a;if(t+l>i)throw r++,Ss();let u=c();return t+=l,u},stats:()=>({limit:i,admittedNodes:t,rejectedTemplates:n,rejectedOccurrences:r})}}function xv(i,e,t){if(i.byteLength<20)throw Error("GLB has an external dependency or invalid header");let n=new DataView(i.buffer,i.byteOffset,i.byteLength),r=n.getUint32(12,!0);if(n.getUint32(0,!0)!==1179937895||n.getUint32(4,!0)!==2||n.getUint32(8,!0)!==i.byteLength||n.getUint32(16,!0)!==1313821514||r>i.byteLength-20)throw Error("GLB has an external dependency or invalid header");let s=JSON.parse(new TextDecoder().decode(i.subarray(20,20+r)));for(let h of[s.buffers||[],s.images||[]])for(let d of h)if(d.uri&&!/^data:/i.test(d.uri))throw Error("GLB has an external dependency or invalid header");mv(s,i,20+r,t);let o=s.nodes||[],a=s.scenes||[],c=s.meshes||[],l=a.length;if(o.length>e||l>e)throw Ss();let u=[];for(let h of a){for(let d of h.nodes||[]){if(l+u.length>=e)throw Ss();u.push(d)}for(;u.length;){let d=u.pop(),m=o[d];if(!Number.isInteger(d)||!m)throw Error("GLB references an invalid node.");let g=1;if(m.mesh!==void 0){let y=c[m.mesh];if(!y||!Array.isArray(y.primitives))throw Error("GLB references an invalid mesh.");y.primitives.length>1&&(g+=y.primitives.length)}if(m.camera!==void 0&&g++,m.extensions?.KHR_lights_punctual&&(g+=2),l+=g,l>e)throw Ss();for(let y of m.children||[]){if(l+u.length>=e)throw Ss();u.push(y)}}}return l}var Wn={};uv(Wn,{ACESFilmicToneMapping:()=>qo,AddEquation:()=>yi,AddOperation:()=>f0,AdditiveAnimationBlendMode:()=>bp,AdditiveBlending:()=>cp,AgXToneMapping:()=>ku,AlphaFormat:()=>pp,AlwaysCompare:()=>R0,AlwaysDepth:()=>Cu,AlwaysStencilFunc:()=>lf,AmbientLight:()=>Xo,AnimationAction:()=>Tu,AnimationClip:()=>Pr,AnimationLoader:()=>Tf,AnimationMixer:()=>Ff,AnimationObjectGroup:()=>Df,AnimationUtils:()=>m_,ArcCurve:()=>Vl,ArrayCamera:()=>Eu,ArrowHelper:()=>np,AttachedBindMode:()=>cf,Audio:()=>Mu,AudioAnalyser:()=>Of,AudioContext:()=>gc,AudioListener:()=>Nf,AudioLoader:()=>Pf,AxesHelper:()=>ip,BackSide:()=>un,BasicDepthPacking:()=>v0,BasicShadowMap:()=>Rb,BatchedMesh:()=>zl,Bone:()=>Gs,BooleanKeyframeTrack:()=>Rr,Box2:()=>Gf,Box3:()=>zt,Box3Helper:()=>ep,BoxGeometry:()=>Qn,BoxHelper:()=>$f,BufferAttribute:()=>gt,BufferGeometry:()=>ot,BufferGeometryLoader:()=>_u,ByteType:()=>hp,Cache:()=>_r,Camera:()=>Lo,CameraHelper:()=>Qf,CanvasTexture:()=>ns,CapsuleGeometry:()=>Yl,CatmullRomCurve3:()=>Hl,CineonToneMapping:()=>Uu,CircleGeometry:()=>jl,ClampToEdgeWrapping:()=>En,Clock:()=>Yo,Color:()=>Be,ColorKeyframeTrack:()=>fc,ColorManagement:()=>bt,CompressedArrayTexture:()=>Ef,CompressedCubeTexture:()=>Mf,CompressedTexture:()=>Uo,CompressedTextureLoader:()=>Af,ConeGeometry:()=>Bo,ConstantAlphaFactor:()=>u0,ConstantColorFactor:()=>c0,Controls:()=>yc,CubeCamera:()=>Dl,CubeReflectionMapping:()=>Nr,CubeRefractionMapping:()=>us,CubeTexture:()=>Vs,CubeTextureLoader:()=>wf,CubeUVReflectionMapping:()=>Ko,CubicBezierCurve:()=>ic,CubicBezierCurve3:()=>Gl,CubicInterpolant:()=>hu,CullFaceBack:()=>op,CullFaceFront:()=>Jg,CullFaceFrontBack:()=>wb,CullFaceNone:()=>Zg,Curve:()=>vi,CurvePath:()=>Xl,CustomBlending:()=>wu,CustomToneMapping:()=>p0,CylinderGeometry:()=>is,Cylindrical:()=>Vf,Data3DTexture:()=>ec,DataArrayTexture:()=>Io,DataTexture:()=>An,DataTextureLoader:()=>Rf,DataUtils:()=>c_,DecrementStencilOp:()=>Bb,DecrementWrapStencilOp:()=>Vb,DefaultLoadingManager:()=>D0,DepthFormat:()=>Ds,DepthStencilFormat:()=>Er,DepthTexture:()=>Xs,DetachedBindMode:()=>m0,DirectionalLight:()=>as,DirectionalLightHelper:()=>Jf,DiscreteInterpolant:()=>du,DodecahedronGeometry:()=>ql,DoubleSide:()=>yn,DstAlphaFactor:()=>xc,DstColorFactor:()=>vc,DynamicCopyUsage:()=>t_,DynamicDrawUsage:()=>Mp,DynamicReadUsage:()=>Qb,EdgesGeometry:()=>ss,EllipseCurve:()=>ko,EqualCompare:()=>S0,EqualDepth:()=>Iu,EqualStencilFunc:()=>Xb,EquirectangularReflectionMapping:()=>_c,EquirectangularRefractionMapping:()=>Ec,Euler:()=>xi,EventDispatcher:()=>ki,ExtrudeGeometry:()=>Ys,FileLoader:()=>Vn,Float16BufferAttribute:()=>yf,Float32BufferAttribute:()=>Ve,FloatType:()=>si,Fog:()=>kl,FogExp2:()=>Ul,FramebufferTexture:()=>_f,FrontSide:()=>Jn,Frustum:()=>Ws,GLBufferAttribute:()=>zf,GLSL1:()=>i_,GLSL3:()=>Sp,GreaterCompare:()=>T0,GreaterDepth:()=>Lu,GreaterEqualCompare:()=>w0,GreaterEqualDepth:()=>Nu,GreaterEqualStencilFunc:()=>Kb,GreaterStencilFunc:()=>jb,GridHelper:()=>Kf,Group:()=>Dt,HalfFloatType:()=>Hn,HemisphereLight:()=>pu,HemisphereLightHelper:()=>qf,IcosahedronGeometry:()=>Ql,ImageBitmapLoader:()=>mc,ImageLoader:()=>js,ImageUtils:()=>Ll,IncrementStencilOp:()=>kb,IncrementWrapStencilOp:()=>zb,InstancedBufferAttribute:()=>Xi,InstancedBufferGeometry:()=>bu,InstancedInterleavedBuffer:()=>Bf,InstancedMesh:()=>$r,Int16BufferAttribute:()=>mf,Int32BufferAttribute:()=>gf,Int8BufferAttribute:()=>df,IntType:()=>Vu,InterleavedBuffer:()=>Mr,InterleavedBufferAttribute:()=>ir,Interpolant:()=>wr,InterpolateDiscrete:()=>Bs,InterpolateLinear:()=>zs,InterpolateSmooth:()=>wl,InvertStencilOp:()=>Hb,KeepStencilOp:()=>Ns,KeyframeTrack:()=>_i,LOD:()=>Bl,LatheGeometry:()=>cc,Layers:()=>No,LessCompare:()=>M0,LessDepth:()=>Pu,LessEqualCompare:()=>Ep,LessEqualDepth:()=>Us,LessEqualStencilFunc:()=>Yb,LessStencilFunc:()=>Wb,Light:()=>ar,LightProbe:()=>xu,Line:()=>ai,Line3:()=>Wf,LineBasicMaterial:()=>Xt,LineCurve:()=>rc,LineCurve3:()=>Wl,LineDashedMaterial:()=>uu,LineLoop:()=>es,LineSegments:()=>ln,LinearFilter:()=>nn,LinearInterpolant:()=>dc,LinearMipMapLinearFilter:()=>Nb,LinearMipMapNearestFilter:()=>Ib,LinearMipmapLinearFilter:()=>Mi,LinearMipmapNearestFilter:()=>Zs,LinearSRGBColorSpace:()=>On,LinearToneMapping:()=>Du,LinearTransfer:()=>Za,Loader:()=>rn,LoaderUtils:()=>Ei,LoadingManager:()=>pc,LoopOnce:()=>g0,LoopPingPong:()=>x0,LoopRepeat:()=>y0,LuminanceAlphaFormat:()=>yp,LuminanceFormat:()=>gp,MOUSE:()=>cs,Material:()=>cn,MaterialLoader:()=>vu,MathUtils:()=>Js,Matrix2:()=>Hf,Matrix3:()=>yt,Matrix4:()=>nt,MaxEquation:()=>t0,Mesh:()=>ct,MeshBasicMaterial:()=>Ht,MeshDepthMaterial:()=>uc,MeshDistanceMaterial:()=>hc,MeshLambertMaterial:()=>cu,MeshMatcapMaterial:()=>lu,MeshNormalMaterial:()=>Go,MeshPhongMaterial:()=>Ho,MeshPhysicalMaterial:()=>Dn,MeshStandardMaterial:()=>Mn,MeshToonMaterial:()=>au,MinEquation:()=>e0,MirroredRepeatWrapping:()=>ks,MixOperation:()=>d0,MultiplyBlending:()=>up,MultiplyOperation:()=>bc,NearestFilter:()=>Jt,NearestMipMapLinearFilter:()=>Pb,NearestMipMapNearestFilter:()=>Cb,NearestMipmapLinearFilter:()=>hs,NearestMipmapNearestFilter:()=>Mc,NeutralToneMapping:()=>Bu,NeverCompare:()=>E0,NeverDepth:()=>Ru,NeverStencilFunc:()=>Gb,NoBlending:()=>xn,NoColorSpace:()=>Dr,NoToneMapping:()=>Ir,NormalAnimationBlendMode:()=>vh,NormalBlending:()=>Fs,NotEqualCompare:()=>A0,NotEqualDepth:()=>Ou,NotEqualStencilFunc:()=>qb,NumberKeyframeTrack:()=>rr,Object3D:()=>St,ObjectLoader:()=>Cf,ObjectSpaceNormalMap:()=>_0,OctahedronGeometry:()=>lc,OneFactor:()=>n0,OneMinusConstantAlphaFactor:()=>h0,OneMinusConstantColorFactor:()=>l0,OneMinusDstAlphaFactor:()=>s0,OneMinusDstColorFactor:()=>o0,OneMinusSrcAlphaFactor:()=>Nl,OneMinusSrcColorFactor:()=>r0,OrthographicCamera:()=>cr,PCFShadowMap:()=>ap,PCFSoftShadowMap:()=>Au,PMREMGenerator:()=>ra,Path:()=>Tr,PerspectiveCamera:()=>jt,Plane:()=>Li,PlaneGeometry:()=>Ar,PlaneHelper:()=>tp,PointLight:()=>os,PointLightHelper:()=>jf,Points:()=>ts,PointsMaterial:()=>Sr,PolarGridHelper:()=>Zf,PolyhedronGeometry:()=>rs,PositionalAudio:()=>Lf,PropertyBinding:()=>Ut,PropertyMixer:()=>Su,QuadraticBezierCurve:()=>sc,QuadraticBezierCurve3:()=>oc,Quaternion:()=>Zt,QuaternionKeyframeTrack:()=>sr,QuaternionLinearInterpolant:()=>fu,RED_GREEN_RGTC2_Format:()=>yh,RED_RGTC1_Format:()=>vp,REVISION:()=>Kg,RGBADepthPacking:()=>b0,RGBAFormat:()=>Ln,RGBAIntegerFormat:()=>Yu,RGBA_ASTC_10x10_Format:()=>hh,RGBA_ASTC_10x5_Format:()=>ch,RGBA_ASTC_10x6_Format:()=>lh,RGBA_ASTC_10x8_Format:()=>uh,RGBA_ASTC_12x10_Format:()=>dh,RGBA_ASTC_12x12_Format:()=>fh,RGBA_ASTC_4x4_Format:()=>eh,RGBA_ASTC_5x4_Format:()=>th,RGBA_ASTC_5x5_Format:()=>nh,RGBA_ASTC_6x5_Format:()=>ih,RGBA_ASTC_6x6_Format:()=>rh,RGBA_ASTC_8x5_Format:()=>sh,RGBA_ASTC_8x6_Format:()=>oh,RGBA_ASTC_8x8_Format:()=>ah,RGBA_BPTC_Format:()=>Cc,RGBA_ETC2_EAC_Format:()=>$u,RGBA_PVRTC_2BPPV1_Format:()=>Zu,RGBA_PVRTC_4BPPV1_Format:()=>Ku,RGBA_S3TC_DXT1_Format:()=>Ac,RGBA_S3TC_DXT3_Format:()=>wc,RGBA_S3TC_DXT5_Format:()=>Rc,RGBDepthPacking:()=>Ob,RGBFormat:()=>mp,RGBIntegerFormat:()=>Lb,RGB_BPTC_SIGNED_Format:()=>ph,RGB_BPTC_UNSIGNED_Format:()=>mh,RGB_ETC1_Format:()=>Ju,RGB_ETC2_Format:()=>Qu,RGB_PVRTC_2BPPV1_Format:()=>qu,RGB_PVRTC_4BPPV1_Format:()=>ju,RGB_S3TC_DXT1_Format:()=>Tc,RGDepthPacking:()=>Db,RGFormat:()=>xp,RGIntegerFormat:()=>Xu,RawShaderMaterial:()=>Vo,Ray:()=>nr,Raycaster:()=>lr,RectAreaLight:()=>gu,RedFormat:()=>Wu,RedIntegerFormat:()=>Sc,ReinhardToneMapping:()=>Fu,RenderTarget:()=>Ol,RepeatWrapping:()=>gn,ReplaceStencilOp:()=>Ub,ReverseSubtractEquation:()=>$g,RingGeometry:()=>$l,SIGNED_RED_GREEN_RGTC2_Format:()=>xh,SIGNED_RED_RGTC1_Format:()=>gh,SRGBColorSpace:()=>wt,SRGBTransfer:()=>kt,Scene:()=>oi,ShaderChunk:()=>Tt,ShaderLib:()=>hr,ShaderMaterial:()=>$t,ShadowMaterial:()=>ou,Shape:()=>Fi,ShapeGeometry:()=>eu,ShapePath:()=>rp,ShapeUtils:()=>Ui,ShortType:()=>dp,Skeleton:()=>Fo,SkeletonHelper:()=>Yf,SkinnedMesh:()=>Do,Source:()=>br,Sphere:()=>qt,SphereGeometry:()=>bi,Spherical:()=>jo,SphericalHarmonics3:()=>yu,SplineCurve:()=>ac,SpotLight:()=>Wo,SpotLightHelper:()=>Xf,Sprite:()=>Oo,SpriteMaterial:()=>Hs,SrcAlphaFactor:()=>Il,SrcAlphaSaturateFactor:()=>a0,SrcColorFactor:()=>i0,StaticCopyUsage:()=>e_,StaticDrawUsage:()=>Ja,StaticReadUsage:()=>Jb,StereoCamera:()=>If,StreamCopyUsage:()=>n_,StreamDrawUsage:()=>Zb,StreamReadUsage:()=>$b,StringKeyframeTrack:()=>Cr,SubtractEquation:()=>Qg,SubtractiveBlending:()=>lp,TOUCH:()=>ls,TangentSpaceNormalMap:()=>ds,TetrahedronGeometry:()=>tu,Texture:()=>Qt,TextureLoader:()=>qs,TextureUtils:()=>y_,TorusGeometry:()=>nu,TorusKnotGeometry:()=>iu,Triangle:()=>Oi,TriangleFanDrawMode:()=>Jo,TriangleStripDrawMode:()=>Pc,TrianglesDrawMode:()=>_p,TubeGeometry:()=>ru,UVMapping:()=>zu,Uint16BufferAttribute:()=>tc,Uint32BufferAttribute:()=>nc,Uint8BufferAttribute:()=>ff,Uint8ClampedBufferAttribute:()=>pf,Uniform:()=>Uf,UniformsGroup:()=>kf,UniformsLib:()=>Ze,UniformsUtils:()=>Gn,UnsignedByteType:()=>ci,UnsignedInt248Type:()=>Or,UnsignedInt5999Type:()=>fp,UnsignedIntType:()=>Lr,UnsignedShort4444Type:()=>Hu,UnsignedShort5551Type:()=>Gu,UnsignedShortType:()=>Zo,VSMShadowMap:()=>ur,Vector2:()=>Ce,Vector3:()=>q,Vector4:()=>It,VectorKeyframeTrack:()=>or,VideoTexture:()=>bf,WebGL3DRenderTarget:()=>hf,WebGLArrayRenderTarget:()=>uf,WebGLCoordinateSystem:()=>tr,WebGLCubeRenderTarget:()=>Fl,WebGLMultipleRenderTargets:()=>sp,WebGLRenderTarget:()=>on,WebGLRenderer:()=>fs,WebGLUtils:()=>Y_,WebGPUCoordinateSystem:()=>Qa,WireframeGeometry:()=>su,WrapAroundEnding:()=>Ka,ZeroCurvatureEnding:()=>Ls,ZeroFactor:()=>Ks,ZeroSlopeEnding:()=>Os,ZeroStencilOp:()=>Fb,createCanvasElement:()=>I0});var Kg="171",cs={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ls={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Zg=0,op=1,Jg=2,wb=3,Rb=0,ap=1,Au=2,ur=3,Jn=0,un=1,yn=2,xn=0,Fs=1,cp=2,lp=3,up=4,wu=5,yi=100,Qg=101,$g=102,e0=103,t0=104,Ks=200,n0=201,i0=202,r0=203,Il=204,Nl=205,xc=206,s0=207,vc=208,o0=209,a0=210,c0=211,l0=212,u0=213,h0=214,Ru=0,Cu=1,Pu=2,Us=3,Iu=4,Nu=5,Lu=6,Ou=7,bc=0,d0=1,f0=2,Ir=0,Du=1,Fu=2,Uu=3,qo=4,p0=5,ku=6,Bu=7,cf="attached",m0="detached",zu=300,Nr=301,us=302,_c=303,Ec=304,Ko=306,gn=1e3,En=1001,ks=1002,Jt=1003,Mc=1004,Cb=1004,hs=1005,Pb=1005,nn=1006,Zs=1007,Ib=1007,Mi=1008,Nb=1008,ci=1009,hp=1010,dp=1011,Zo=1012,Vu=1013,Lr=1014,si=1015,Hn=1016,Hu=1017,Gu=1018,Or=1020,fp=35902,pp=1021,mp=1022,Ln=1023,gp=1024,yp=1025,Ds=1026,Er=1027,Wu=1028,Sc=1029,xp=1030,Xu=1031,Lb=1032,Yu=1033,Tc=33776,Ac=33777,wc=33778,Rc=33779,ju=35840,qu=35841,Ku=35842,Zu=35843,Ju=36196,Qu=37492,$u=37496,eh=37808,th=37809,nh=37810,ih=37811,rh=37812,sh=37813,oh=37814,ah=37815,ch=37816,lh=37817,uh=37818,hh=37819,dh=37820,fh=37821,Cc=36492,ph=36494,mh=36495,vp=36283,gh=36284,yh=36285,xh=36286,g0=2200,y0=2201,x0=2202,Bs=2300,zs=2301,wl=2302,Ls=2400,Os=2401,Ka=2402,vh=2500,bp=2501,_p=0,Pc=1,Jo=2,v0=3200,b0=3201,Ob=3202,Db=3203,ds=0,_0=1,Dr="",wt="srgb",On="srgb-linear",Za="linear",kt="srgb",Fb=0,Ns=7680,Ub=7681,kb=7682,Bb=7683,zb=34055,Vb=34056,Hb=5386,Gb=512,Wb=513,Xb=514,Yb=515,jb=516,qb=517,Kb=518,lf=519,E0=512,M0=513,S0=514,Ep=515,T0=516,A0=517,w0=518,R0=519,Ja=35044,Mp=35048,Zb=35040,Jb=35045,Qb=35049,$b=35041,e_=35046,t_=35050,n_=35042,i_="100",Sp="300 es",tr=2e3,Qa=2001,ki=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){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let r=this._listeners[e];if(r!==void 0){let s=r.indexOf(t);s!==-1&&r.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let n=this._listeners[e.type];if(n!==void 0){e.target=this;let r=n.slice(0);for(let s=0,o=r.length;s<o;s++)r[s].call(this,e);e.target=null}}},qn=["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"],vv=1234567,Co=Math.PI/180,Po=180/Math.PI;function Di(){let i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(qn[i&255]+qn[i>>8&255]+qn[i>>16&255]+qn[i>>24&255]+"-"+qn[e&255]+qn[e>>8&255]+"-"+qn[e>>16&15|64]+qn[e>>24&255]+"-"+qn[t&63|128]+qn[t>>8&255]+"-"+qn[t>>16&255]+qn[t>>24&255]+qn[n&255]+qn[n>>8&255]+qn[n>>16&255]+qn[n>>24&255]).toLowerCase()}function mt(i,e,t){return Math.max(e,Math.min(t,i))}function C0(i,e){return(i%e+e)%e}function LS(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function OS(i,e,t){return i!==e?(t-i)/(e-i):0}function Rl(i,e,t){return(1-t)*i+t*e}function DS(i,e,t,n){return Rl(i,e,1-Math.exp(-t*n))}function FS(i,e=1){return e-Math.abs(C0(i,e*2)-e)}function US(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function kS(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function BS(i,e){return i+Math.floor(Math.random()*(e-i+1))}function zS(i,e){return i+Math.random()*(e-i)}function VS(i){return i*(.5-Math.random())}function HS(i){i!==void 0&&(vv=i);let e=vv+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function GS(i){return i*Co}function WS(i){return i*Po}function XS(i){return(i&i-1)===0&&i!==0}function YS(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function jS(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function qS(i,e,t,n,r){let s=Math.cos,o=Math.sin,a=s(t/2),c=o(t/2),l=s((e+n)/2),u=o((e+n)/2),h=s((e-n)/2),d=o((e-n)/2),m=s((n-e)/2),g=o((n-e)/2);switch(r){case"XYX":i.set(a*u,c*h,c*d,a*l);break;case"YZY":i.set(c*d,a*u,c*h,a*l);break;case"ZXZ":i.set(c*h,c*d,a*u,a*l);break;case"XZX":i.set(a*u,c*g,c*m,a*l);break;case"YXY":i.set(c*m,a*u,c*g,a*l);break;case"ZYZ":i.set(c*g,c*m,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ri(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Et(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}var Js={DEG2RAD:Co,RAD2DEG:Po,generateUUID:Di,clamp:mt,euclideanModulo:C0,mapLinear:LS,inverseLerp:OS,lerp:Rl,damp:DS,pingpong:FS,smoothstep:US,smootherstep:kS,randInt:BS,randFloat:zS,randFloatSpread:VS,seededRandom:HS,degToRad:GS,radToDeg:WS,isPowerOfTwo:XS,ceilPowerOfTwo:YS,floorPowerOfTwo:jS,setQuaternionFromProperEuler:qS,normalize:Et,denormalize:ri},Ce=class i{constructor(e=0,t=0){i.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("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=mt(this.x,e.x,t.x),this.y=mt(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=mt(this.x,e,t),this.y=mt(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(mt(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(mt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,o=this.y-e.y;return this.x=s*n-o*r+e.x,this.y=s*r+o*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},yt=class i{constructor(e,t,n,r,s,o,a,c,l){i.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,o,a,c,l)}set(e,t,n,r,s,o,a,c,l){let u=this.elements;return u[0]=e,u[1]=r,u[2]=a,u[3]=t,u[4]=s,u[5]=c,u[6]=n,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,s=this.elements,o=n[0],a=n[3],c=n[6],l=n[1],u=n[4],h=n[7],d=n[2],m=n[5],g=n[8],y=r[0],f=r[3],p=r[6],v=r[1],b=r[4],x=r[7],_=r[2],T=r[5],w=r[8];return s[0]=o*y+a*v+c*_,s[3]=o*f+a*b+c*T,s[6]=o*p+a*x+c*w,s[1]=l*y+u*v+h*_,s[4]=l*f+u*b+h*T,s[7]=l*p+u*x+h*w,s[2]=d*y+m*v+g*_,s[5]=d*f+m*b+g*T,s[8]=d*p+m*x+g*w,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-n*s*u+n*a*c+r*s*l-r*o*c}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=u*o-a*l,d=a*c-u*s,m=l*s-o*c,g=t*h+n*d+r*m;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);let y=1/g;return e[0]=h*y,e[1]=(r*l-u*n)*y,e[2]=(a*n-r*o)*y,e[3]=d*y,e[4]=(u*t-r*c)*y,e[5]=(r*s-a*t)*y,e[6]=m*y,e[7]=(n*c-l*t)*y,e[8]=(o*t-n*s)*y,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,o,a){let c=Math.cos(s),l=Math.sin(s);return this.set(n*c,n*l,-n*(c*o+l*a)+o+e,-r*l,r*c,-r*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(ig.makeScale(e,t)),this}rotate(e){return this.premultiply(ig.makeRotation(-e)),this}translate(e,t){return this.premultiply(ig.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},ig=new yt;function P0(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}var KS={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Ya(i,e){return new KS[i](e)}function $a(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function I0(){let i=$a("canvas");return i.style.display="block",i}var bv={};function Qo(i){i in bv||(bv[i]=!0,console.warn(i))}function r_(i,e,t){return new Promise(function(n,r){function s(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(s,t);break;default:n()}}setTimeout(s,t)})}function s_(i){let e=i.elements;e[2]=.5*e[2]+.5*e[3],e[6]=.5*e[6]+.5*e[7],e[10]=.5*e[10]+.5*e[11],e[14]=.5*e[14]+.5*e[15]}function o_(i){let e=i.elements;e[11]===-1?(e[10]=-e[10]-1,e[14]=-e[14]):(e[10]=-e[10],e[14]=-e[14]+1)}var _v=new yt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ev=new yt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function ZS(){let i={enabled:!0,workingColorSpace:On,spaces:{},convert:function(r,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===kt&&(r.r=Qr(r.r),r.g=Qr(r.g),r.b=Qr(r.b)),this.spaces[s].primaries!==this.spaces[o].primaries&&(r.applyMatrix3(this.spaces[s].toXYZ),r.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===kt&&(r.r=qa(r.r),r.g=qa(r.g),r.b=qa(r.b))),r},fromWorkingColorSpace:function(r,s){return this.convert(r,this.workingColorSpace,s)},toWorkingColorSpace:function(r,s){return this.convert(r,s,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===Dr?Za:this.spaces[r].transfer},getLuminanceCoefficients:function(r,s=this.workingColorSpace){return r.fromArray(this.spaces[s].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,s,o){return r.copy(this.spaces[s].toXYZ).multiply(this.spaces[o].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[On]:{primaries:e,whitePoint:n,transfer:Za,toXYZ:_v,fromXYZ:Ev,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:wt},outputColorSpaceConfig:{drawingBufferColorSpace:wt}},[wt]:{primaries:e,whitePoint:n,transfer:kt,toXYZ:_v,fromXYZ:Ev,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:wt}}}),i}var bt=ZS();function Qr(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function qa(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}var Ca,Ll=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{Ca===void 0&&(Ca=$a("canvas")),Ca.width=e.width,Ca.height=e.height;let n=Ca.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Ca}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){let t=$a("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),s=r.data;for(let o=0;o<s.length;o++)s[o]=Qr(s[o]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){let t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(Qr(t[n]/255)*255):t[n]=Qr(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},JS=0,br=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:JS++}),this.uuid=Di(),this.data=e,this.dataReady=!0,this.version=0}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 s;if(Array.isArray(r)){s=[];for(let o=0,a=r.length;o<a;o++)r[o].isDataTexture?s.push(rg(r[o].image)):s.push(rg(r[o]))}else s=rg(r);n.url=s}return t||(e.images[this.uuid]=n),n}};function rg(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Ll.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}var QS=0,Qt=class i extends ki{constructor(e=i.DEFAULT_IMAGE,t=i.DEFAULT_MAPPING,n=En,r=En,s=nn,o=Mi,a=Ln,c=ci,l=i.DEFAULT_ANISOTROPY,u=Dr){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:QS++}),this.uuid=Di(),this.name="",this.source=new br(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=s,this.minFilter=o,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=c,this.offset=new Ce(0,0),this.repeat=new Ce(1,1),this.center=new Ce(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new yt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(e=null){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)}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.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.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}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.6,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,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,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!==zu)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case gn:e.x=e.x-Math.floor(e.x);break;case En:e.x=e.x<0?0:1;break;case ks:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case gn:e.y=e.y-Math.floor(e.y);break;case En:e.y=e.y<0?0:1;break;case ks:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Qt.DEFAULT_IMAGE=null;Qt.DEFAULT_MAPPING=zu;Qt.DEFAULT_ANISOTROPY=1;var It=class i{constructor(e=0,t=0,n=0,r=1){i.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,s=this.w,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r+o[12]*s,this.y=o[1]*t+o[5]*n+o[9]*r+o[13]*s,this.z=o[2]*t+o[6]*n+o[10]*r+o[14]*s,this.w=o[3]*t+o[7]*n+o[11]*r+o[15]*s,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,s,c=e.elements,l=c[0],u=c[4],h=c[8],d=c[1],m=c[5],g=c[9],y=c[2],f=c[6],p=c[10];if(Math.abs(u-d)<.01&&Math.abs(h-y)<.01&&Math.abs(g-f)<.01){if(Math.abs(u+d)<.1&&Math.abs(h+y)<.1&&Math.abs(g+f)<.1&&Math.abs(l+m+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;let b=(l+1)/2,x=(m+1)/2,_=(p+1)/2,T=(u+d)/4,w=(h+y)/4,A=(g+f)/4;return b>x&&b>_?b<.01?(n=0,r=.707106781,s=.707106781):(n=Math.sqrt(b),r=T/n,s=w/n):x>_?x<.01?(n=.707106781,r=0,s=.707106781):(r=Math.sqrt(x),n=T/r,s=A/r):_<.01?(n=.707106781,r=.707106781,s=0):(s=Math.sqrt(_),n=w/s,r=A/s),this.set(n,r,s,t),this}let v=Math.sqrt((f-g)*(f-g)+(h-y)*(h-y)+(d-u)*(d-u));return Math.abs(v)<.001&&(v=1),this.x=(f-g)/v,this.y=(h-y)/v,this.z=(d-u)/v,this.w=Math.acos((l+m+p-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=mt(this.x,e.x,t.x),this.y=mt(this.y,e.y,t.y),this.z=mt(this.z,e.z,t.z),this.w=mt(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=mt(this.x,e,t),this.y=mt(this.y,e,t),this.z=mt(this.z,e,t),this.w=mt(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(mt(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}},Ol=class extends ki{constructor(e=1,t=1,n={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new It(0,0,e,t),this.scissorTest=!1,this.viewport=new It(0,0,e,t);let r={width:e,height:t,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:nn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);let s=new Qt(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];let o=n.count;for(let a=0;a<o;a++)this.textures[a]=s.clone(),this.textures[a].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}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,s=this.textures.length;r<s;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n;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 n=0,r=e.textures.length;n<r;n++)this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new br(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}},on=class extends Ol{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}},Io=class extends Qt{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=Jt,this.minFilter=Jt,this.wrapR=En,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},uf=class extends on{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Io(null,e,t,n),this.texture.isRenderTargetTexture=!0}},ec=class extends Qt{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=Jt,this.minFilter=Jt,this.wrapR=En,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},hf=class extends on{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new ec(null,e,t,n),this.texture.isRenderTargetTexture=!0}},Zt=class{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,s,o,a){let c=n[r+0],l=n[r+1],u=n[r+2],h=n[r+3],d=s[o+0],m=s[o+1],g=s[o+2],y=s[o+3];if(a===0){e[t+0]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h;return}if(a===1){e[t+0]=d,e[t+1]=m,e[t+2]=g,e[t+3]=y;return}if(h!==y||c!==d||l!==m||u!==g){let f=1-a,p=c*d+l*m+u*g+h*y,v=p>=0?1:-1,b=1-p*p;if(b>Number.EPSILON){let _=Math.sqrt(b),T=Math.atan2(_,p*v);f=Math.sin(f*T)/_,a=Math.sin(a*T)/_}let x=a*v;if(c=c*f+d*x,l=l*f+m*x,u=u*f+g*x,h=h*f+y*x,f===1-a){let _=1/Math.sqrt(c*c+l*l+u*u+h*h);c*=_,l*=_,u*=_,h*=_}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,r,s,o){let a=n[r],c=n[r+1],l=n[r+2],u=n[r+3],h=s[o],d=s[o+1],m=s[o+2],g=s[o+3];return e[t]=a*g+u*h+c*m-l*d,e[t+1]=c*g+u*d+l*h-a*m,e[t+2]=l*g+u*m+a*d-c*h,e[t+3]=u*g-a*h-c*d-l*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,r=e._y,s=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(n/2),u=a(r/2),h=a(s/2),d=c(n/2),m=c(r/2),g=c(s/2);switch(o){case"XYZ":this._x=d*u*h+l*m*g,this._y=l*m*h-d*u*g,this._z=l*u*g+d*m*h,this._w=l*u*h-d*m*g;break;case"YXZ":this._x=d*u*h+l*m*g,this._y=l*m*h-d*u*g,this._z=l*u*g-d*m*h,this._w=l*u*h+d*m*g;break;case"ZXY":this._x=d*u*h-l*m*g,this._y=l*m*h+d*u*g,this._z=l*u*g+d*m*h,this._w=l*u*h-d*m*g;break;case"ZYX":this._x=d*u*h-l*m*g,this._y=l*m*h+d*u*g,this._z=l*u*g-d*m*h,this._w=l*u*h+d*m*g;break;case"YZX":this._x=d*u*h+l*m*g,this._y=l*m*h+d*u*g,this._z=l*u*g-d*m*h,this._w=l*u*h-d*m*g;break;case"XZY":this._x=d*u*h-l*m*g,this._y=l*m*h-d*u*g,this._z=l*u*g+d*m*h,this._w=l*u*h+d*m*g;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],s=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],h=t[10],d=n+a+h;if(d>0){let m=.5/Math.sqrt(d+1);this._w=.25/m,this._x=(u-c)*m,this._y=(s-l)*m,this._z=(o-r)*m}else if(n>a&&n>h){let m=2*Math.sqrt(1+n-a-h);this._w=(u-c)/m,this._x=.25*m,this._y=(r+o)/m,this._z=(s+l)/m}else if(a>h){let m=2*Math.sqrt(1+a-n-h);this._w=(s-l)/m,this._x=(r+o)/m,this._y=.25*m,this._z=(c+u)/m}else{let m=2*Math.sqrt(1+h-n-a);this._w=(o-r)/m,this._x=(s+l)/m,this._y=(c+u)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(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(mt(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,s=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=n*u+o*a+r*l-s*c,this._y=r*u+o*c+s*a-n*l,this._z=s*u+o*l+n*c-r*a,this._w=o*u-n*a-r*c-s*l,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,s=this._z,o=this._w,a=o*e._w+n*e._x+r*e._y+s*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=o,this._x=n,this._y=r,this._z=s,this;let c=1-a*a;if(c<=Number.EPSILON){let m=1-t;return this._w=m*o+t*this._w,this._x=m*n+t*this._x,this._y=m*r+t*this._y,this._z=m*s+t*this._z,this.normalize(),this}let l=Math.sqrt(c),u=Math.atan2(l,a),h=Math.sin((1-t)*u)/l,d=Math.sin(t*u)/l;return this._w=o*h+this._w*d,this._x=n*h+this._x*d,this._y=r*h+this._y*d,this._z=s*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),s*Math.sin(t),s*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},q=class i{constructor(e=0,t=0,n=0){i.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("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(Mv.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mv.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6]*r,this.y=s[1]*t+s[4]*n+s[7]*r,this.z=s[2]*t+s[5]*n+s[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,s=e.elements,o=1/(s[3]*t+s[7]*n+s[11]*r+s[15]);return this.x=(s[0]*t+s[4]*n+s[8]*r+s[12])*o,this.y=(s[1]*t+s[5]*n+s[9]*r+s[13])*o,this.z=(s[2]*t+s[6]*n+s[10]*r+s[14])*o,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,s=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*r-a*n),u=2*(a*t-s*r),h=2*(s*n-o*t);return this.x=t+c*l+o*h-a*u,this.y=n+c*u+a*l-s*h,this.z=r+c*h+s*u-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*r,this.y=s[1]*t+s[5]*n+s[9]*r,this.z=s[2]*t+s[6]*n+s[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=mt(this.x,e.x,t.x),this.y=mt(this.y,e.y,t.y),this.z=mt(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=mt(this.x,e,t),this.y=mt(this.y,e,t),this.z=mt(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(mt(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,s=e.z,o=t.x,a=t.y,c=t.z;return this.x=r*c-s*a,this.y=s*o-n*c,this.z=n*a-r*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return sg.copy(this).projectOnVector(e),this.sub(sg)}reflect(e){return this.sub(sg.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(mt(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}},sg=new q,Mv=new Zt,zt=class{constructor(e=new q(1/0,1/0,1/0),t=new q(-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(Qi.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Qi.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=Qi.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 s=n.getAttribute("position");if(t===!0&&s!==void 0&&e.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)e.isMesh===!0?e.getVertexPosition(o,Qi):Qi.fromBufferAttribute(s,o),Qi.applyMatrix4(e.matrixWorld),this.expandByPoint(Qi);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),vd.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),vd.copy(n.boundingBox)),vd.applyMatrix4(e.matrixWorld),this.union(vd)}let r=e.children;for(let s=0,o=r.length;s<o;s++)this.expandByObject(r[s],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,Qi),Qi.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(pl),bd.subVectors(this.max,pl),Pa.subVectors(e.a,pl),Ia.subVectors(e.b,pl),Na.subVectors(e.c,pl),Ts.subVectors(Ia,Pa),As.subVectors(Na,Ia),yo.subVectors(Pa,Na);let t=[0,-Ts.z,Ts.y,0,-As.z,As.y,0,-yo.z,yo.y,Ts.z,0,-Ts.x,As.z,0,-As.x,yo.z,0,-yo.x,-Ts.y,Ts.x,0,-As.y,As.x,0,-yo.y,yo.x,0];return!og(t,Pa,Ia,Na,bd)||(t=[1,0,0,0,1,0,0,0,1],!og(t,Pa,Ia,Na,bd))?!1:(_d.crossVectors(Ts,As),t=[_d.x,_d.y,_d.z],og(t,Pa,Ia,Na,bd))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Qi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Qi).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Xr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Xr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Xr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Xr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Xr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Xr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Xr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Xr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Xr),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)}},Xr=[new q,new q,new q,new q,new q,new q,new q,new q],Qi=new q,vd=new zt,Pa=new q,Ia=new q,Na=new q,Ts=new q,As=new q,yo=new q,pl=new q,bd=new q,_d=new q,xo=new q;function og(i,e,t,n,r){for(let s=0,o=i.length-3;s<=o;s+=3){xo.fromArray(i,s);let a=r.x*Math.abs(xo.x)+r.y*Math.abs(xo.y)+r.z*Math.abs(xo.z),c=e.dot(xo),l=t.dot(xo),u=n.dot(xo);if(Math.max(-Math.max(c,l,u),Math.min(c,l,u))>a)return!1}return!0}var $S=new zt,ml=new q,ag=new q,qt=class{constructor(e=new q,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?n.copy(t):$S.setFromPoints(e).getCenter(n);let r=0;for(let s=0,o=e.length;s<o;s++)r=Math.max(r,n.distanceToSquared(e[s]));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=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;ml.subVectors(e,this.center);let t=ml.lengthSq();if(t>this.radius*this.radius){let n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(ml,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(ag.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ml.copy(e.center).add(ag)),this.expandByPoint(ml.copy(e.center).sub(ag))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Yr=new q,cg=new q,Ed=new q,ws=new q,lg=new q,Md=new q,ug=new q,nr=class{constructor(e=new q,t=new q(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,Yr)),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=Yr.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Yr.copy(this.origin).addScaledVector(this.direction,t),Yr.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){cg.copy(e).add(t).multiplyScalar(.5),Ed.copy(t).sub(e).normalize(),ws.copy(this.origin).sub(cg);let s=e.distanceTo(t)*.5,o=-this.direction.dot(Ed),a=ws.dot(this.direction),c=-ws.dot(Ed),l=ws.lengthSq(),u=Math.abs(1-o*o),h,d,m,g;if(u>0)if(h=o*c-a,d=o*a-c,g=s*u,h>=0)if(d>=-g)if(d<=g){let y=1/u;h*=y,d*=y,m=h*(h+o*d+2*a)+d*(o*h+d+2*c)+l}else d=s,h=Math.max(0,-(o*d+a)),m=-h*h+d*(d+2*c)+l;else d=-s,h=Math.max(0,-(o*d+a)),m=-h*h+d*(d+2*c)+l;else d<=-g?(h=Math.max(0,-(-o*s+a)),d=h>0?-s:Math.min(Math.max(-s,-c),s),m=-h*h+d*(d+2*c)+l):d<=g?(h=0,d=Math.min(Math.max(-s,-c),s),m=d*(d+2*c)+l):(h=Math.max(0,-(o*s+a)),d=h>0?s:Math.min(Math.max(-s,-c),s),m=-h*h+d*(d+2*c)+l);else d=o>0?-s:s,h=Math.max(0,-(o*d+a)),m=-h*h+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),r&&r.copy(cg).addScaledVector(Ed,d),m}intersectSphere(e,t){Yr.subVectors(e.center,this.origin);let n=Yr.dot(this.direction),r=Yr.dot(Yr)-n*n,s=e.radius*e.radius;if(r>s)return null;let o=Math.sqrt(s-r),a=n-o,c=n+o;return c<0?null:a<0?this.at(c,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,s,o,a,c,l=1/this.direction.x,u=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,r=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,r=(e.min.x-d.x)*l),u>=0?(s=(e.min.y-d.y)*u,o=(e.max.y-d.y)*u):(s=(e.max.y-d.y)*u,o=(e.min.y-d.y)*u),n>o||s>r||((s>n||isNaN(n))&&(n=s),(o<r||isNaN(r))&&(r=o),h>=0?(a=(e.min.z-d.z)*h,c=(e.max.z-d.z)*h):(a=(e.max.z-d.z)*h,c=(e.min.z-d.z)*h),n>c||a>r)||((a>n||n!==n)&&(n=a),(c<r||r!==r)&&(r=c),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Yr)!==null}intersectTriangle(e,t,n,r,s){lg.subVectors(t,e),Md.subVectors(n,e),ug.crossVectors(lg,Md);let o=this.direction.dot(ug),a;if(o>0){if(r)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ws.subVectors(this.origin,e);let c=a*this.direction.dot(Md.crossVectors(ws,Md));if(c<0)return null;let l=a*this.direction.dot(lg.cross(ws));if(l<0||c+l>o)return null;let u=-a*ws.dot(ug);return u<0?null:this.at(u/o,s)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},nt=class i{constructor(e,t,n,r,s,o,a,c,l,u,h,d,m,g,y,f){i.prototype.isMatrix4=!0,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,s,o,a,c,l,u,h,d,m,g,y,f)}set(e,t,n,r,s,o,a,c,l,u,h,d,m,g,y,f){let p=this.elements;return p[0]=e,p[4]=t,p[8]=n,p[12]=r,p[1]=s,p[5]=o,p[9]=a,p[13]=c,p[2]=l,p[6]=u,p[10]=h,p[14]=d,p[3]=m,p[7]=g,p[11]=y,p[15]=f,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 i().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 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){let t=this.elements,n=e.elements,r=1/La.setFromMatrixColumn(e,0).length(),s=1/La.setFromMatrixColumn(e,1).length(),o=1/La.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]*s,t[5]=n[5]*s,t[6]=n[6]*s,t[7]=0,t[8]=n[8]*o,t[9]=n[9]*o,t[10]=n[10]*o,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,s=e.z,o=Math.cos(n),a=Math.sin(n),c=Math.cos(r),l=Math.sin(r),u=Math.cos(s),h=Math.sin(s);if(e.order==="XYZ"){let d=o*u,m=o*h,g=a*u,y=a*h;t[0]=c*u,t[4]=-c*h,t[8]=l,t[1]=m+g*l,t[5]=d-y*l,t[9]=-a*c,t[2]=y-d*l,t[6]=g+m*l,t[10]=o*c}else if(e.order==="YXZ"){let d=c*u,m=c*h,g=l*u,y=l*h;t[0]=d+y*a,t[4]=g*a-m,t[8]=o*l,t[1]=o*h,t[5]=o*u,t[9]=-a,t[2]=m*a-g,t[6]=y+d*a,t[10]=o*c}else if(e.order==="ZXY"){let d=c*u,m=c*h,g=l*u,y=l*h;t[0]=d-y*a,t[4]=-o*h,t[8]=g+m*a,t[1]=m+g*a,t[5]=o*u,t[9]=y-d*a,t[2]=-o*l,t[6]=a,t[10]=o*c}else if(e.order==="ZYX"){let d=o*u,m=o*h,g=a*u,y=a*h;t[0]=c*u,t[4]=g*l-m,t[8]=d*l+y,t[1]=c*h,t[5]=y*l+d,t[9]=m*l-g,t[2]=-l,t[6]=a*c,t[10]=o*c}else if(e.order==="YZX"){let d=o*c,m=o*l,g=a*c,y=a*l;t[0]=c*u,t[4]=y-d*h,t[8]=g*h+m,t[1]=h,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=m*h+g,t[10]=d-y*h}else if(e.order==="XZY"){let d=o*c,m=o*l,g=a*c,y=a*l;t[0]=c*u,t[4]=-h,t[8]=l*u,t[1]=d*h+y,t[5]=o*u,t[9]=m*h-g,t[2]=g*h-m,t[6]=a*u,t[10]=y*h+d}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(eT,e,tT)}lookAt(e,t,n){let r=this.elements;return Ii.subVectors(e,t),Ii.lengthSq()===0&&(Ii.z=1),Ii.normalize(),Rs.crossVectors(n,Ii),Rs.lengthSq()===0&&(Math.abs(n.z)===1?Ii.x+=1e-4:Ii.z+=1e-4,Ii.normalize(),Rs.crossVectors(n,Ii)),Rs.normalize(),Sd.crossVectors(Ii,Rs),r[0]=Rs.x,r[4]=Sd.x,r[8]=Ii.x,r[1]=Rs.y,r[5]=Sd.y,r[9]=Ii.y,r[2]=Rs.z,r[6]=Sd.z,r[10]=Ii.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,s=this.elements,o=n[0],a=n[4],c=n[8],l=n[12],u=n[1],h=n[5],d=n[9],m=n[13],g=n[2],y=n[6],f=n[10],p=n[14],v=n[3],b=n[7],x=n[11],_=n[15],T=r[0],w=r[4],A=r[8],E=r[12],M=r[1],P=r[5],N=r[9],L=r[13],D=r[2],$=r[6],U=r[10],I=r[14],V=r[3],W=r[7],Q=r[11],se=r[15];return s[0]=o*T+a*M+c*D+l*V,s[4]=o*w+a*P+c*$+l*W,s[8]=o*A+a*N+c*U+l*Q,s[12]=o*E+a*L+c*I+l*se,s[1]=u*T+h*M+d*D+m*V,s[5]=u*w+h*P+d*$+m*W,s[9]=u*A+h*N+d*U+m*Q,s[13]=u*E+h*L+d*I+m*se,s[2]=g*T+y*M+f*D+p*V,s[6]=g*w+y*P+f*$+p*W,s[10]=g*A+y*N+f*U+p*Q,s[14]=g*E+y*L+f*I+p*se,s[3]=v*T+b*M+x*D+_*V,s[7]=v*w+b*P+x*$+_*W,s[11]=v*A+b*N+x*U+_*Q,s[15]=v*E+b*L+x*I+_*se,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],s=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],h=e[6],d=e[10],m=e[14],g=e[3],y=e[7],f=e[11],p=e[15];return g*(+s*c*h-r*l*h-s*a*d+n*l*d+r*a*m-n*c*m)+y*(+t*c*m-t*l*d+s*o*d-r*o*m+r*l*u-s*c*u)+f*(+t*l*h-t*a*m-s*o*h+n*o*m+s*a*u-n*l*u)+p*(-r*a*u-t*c*h+t*a*d+r*o*h-n*o*d+n*c*u)}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],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=e[9],d=e[10],m=e[11],g=e[12],y=e[13],f=e[14],p=e[15],v=h*f*l-y*d*l+y*c*m-a*f*m-h*c*p+a*d*p,b=g*d*l-u*f*l-g*c*m+o*f*m+u*c*p-o*d*p,x=u*y*l-g*h*l+g*a*m-o*y*m-u*a*p+o*h*p,_=g*h*c-u*y*c-g*a*d+o*y*d+u*a*f-o*h*f,T=t*v+n*b+r*x+s*_;if(T===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let w=1/T;return e[0]=v*w,e[1]=(y*d*s-h*f*s-y*r*m+n*f*m+h*r*p-n*d*p)*w,e[2]=(a*f*s-y*c*s+y*r*l-n*f*l-a*r*p+n*c*p)*w,e[3]=(h*c*s-a*d*s-h*r*l+n*d*l+a*r*m-n*c*m)*w,e[4]=b*w,e[5]=(u*f*s-g*d*s+g*r*m-t*f*m-u*r*p+t*d*p)*w,e[6]=(g*c*s-o*f*s-g*r*l+t*f*l+o*r*p-t*c*p)*w,e[7]=(o*d*s-u*c*s+u*r*l-t*d*l-o*r*m+t*c*m)*w,e[8]=x*w,e[9]=(g*h*s-u*y*s-g*n*m+t*y*m+u*n*p-t*h*p)*w,e[10]=(o*y*s-g*a*s+g*n*l-t*y*l-o*n*p+t*a*p)*w,e[11]=(u*a*s-o*h*s-u*n*l+t*h*l+o*n*m-t*a*m)*w,e[12]=_*w,e[13]=(u*y*r-g*h*r+g*n*d-t*y*d-u*n*f+t*h*f)*w,e[14]=(g*a*r-o*y*r-g*n*c+t*y*c+o*n*f-t*a*f)*w,e[15]=(o*h*r-u*a*r+u*n*c-t*h*c-o*n*d+t*a*d)*w,this}scale(e){let t=this.elements,n=e.x,r=e.y,s=e.z;return t[0]*=n,t[4]*=r,t[8]*=s,t[1]*=n,t[5]*=r,t[9]*=s,t[2]*=n,t[6]*=r,t[10]*=s,t[3]*=n,t[7]*=r,t[11]*=s,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),s=1-n,o=e.x,a=e.y,c=e.z,l=s*o,u=s*a;return this.set(l*o+n,l*a-r*c,l*c+r*a,0,l*a+r*c,u*a+n,u*c-r*o,0,l*c-r*a,u*c+r*o,s*c*c+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,s,o){return this.set(1,n,s,0,e,1,o,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,s=t._x,o=t._y,a=t._z,c=t._w,l=s+s,u=o+o,h=a+a,d=s*l,m=s*u,g=s*h,y=o*u,f=o*h,p=a*h,v=c*l,b=c*u,x=c*h,_=n.x,T=n.y,w=n.z;return r[0]=(1-(y+p))*_,r[1]=(m+x)*_,r[2]=(g-b)*_,r[3]=0,r[4]=(m-x)*T,r[5]=(1-(d+p))*T,r[6]=(f+v)*T,r[7]=0,r[8]=(g+b)*w,r[9]=(f-v)*w,r[10]=(1-(d+y))*w,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,s=La.set(r[0],r[1],r[2]).length(),o=La.set(r[4],r[5],r[6]).length(),a=La.set(r[8],r[9],r[10]).length();this.determinant()<0&&(s=-s),e.x=r[12],e.y=r[13],e.z=r[14],$i.copy(this);let l=1/s,u=1/o,h=1/a;return $i.elements[0]*=l,$i.elements[1]*=l,$i.elements[2]*=l,$i.elements[4]*=u,$i.elements[5]*=u,$i.elements[6]*=u,$i.elements[8]*=h,$i.elements[9]*=h,$i.elements[10]*=h,t.setFromRotationMatrix($i),n.x=s,n.y=o,n.z=a,this}makePerspective(e,t,n,r,s,o,a=tr){let c=this.elements,l=2*s/(t-e),u=2*s/(n-r),h=(t+e)/(t-e),d=(n+r)/(n-r),m,g;if(a===tr)m=-(o+s)/(o-s),g=-2*o*s/(o-s);else if(a===Qa)m=-o/(o-s),g=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=l,c[4]=0,c[8]=h,c[12]=0,c[1]=0,c[5]=u,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=g,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,r,s,o,a=tr){let c=this.elements,l=1/(t-e),u=1/(n-r),h=1/(o-s),d=(t+e)*l,m=(n+r)*u,g,y;if(a===tr)g=(o+s)*h,y=-2*h;else if(a===Qa)g=s*h,y=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*l,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*u,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=y,c[14]=-g,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])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}},La=new q,$i=new nt,eT=new q(0,0,0),tT=new q(1,1,1),Rs=new q,Sd=new q,Ii=new q,Sv=new nt,Tv=new Zt,xi=class i{constructor(e=0,t=0,n=0,r=i.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}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,s=r[0],o=r[4],a=r[8],c=r[1],l=r[5],u=r[9],h=r[2],d=r[6],m=r[10];switch(t){case"XYZ":this._y=Math.asin(mt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-mt(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,m),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(mt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-mt(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(mt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(a,m));break;case"XZY":this._z=Math.asin(-mt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-u,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Sv.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Sv,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Tv.setFromEuler(this),this.setFromQuaternion(Tv,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}};xi.DEFAULT_ORDER="XYZ";var No=class{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}},nT=0,Av=new q,Oa=new Zt,jr=new nt,Td=new q,gl=new q,iT=new q,rT=new Zt,wv=new q(1,0,0),Rv=new q(0,1,0),Cv=new q(0,0,1),Pv={type:"added"},sT={type:"removed"},Da={type:"childadded",child:null},hg={type:"childremoved",child:null},St=class i extends ki{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:nT++}),this.uuid=Di(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=i.DEFAULT_UP.clone();let e=new q,t=new xi,n=new Zt,r=new q(1,1,1);function s(){n.setFromEuler(t,!1)}function o(){t.setFromQuaternion(n,void 0,!1)}t._onChange(s),n._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new nt},normalMatrix:{value:new yt}}),this.matrix=new nt,this.matrixWorld=new nt,this.matrixAutoUpdate=i.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=i.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new No,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}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 Oa.setFromAxisAngle(e,t),this.quaternion.multiply(Oa),this}rotateOnWorldAxis(e,t){return Oa.setFromAxisAngle(e,t),this.quaternion.premultiply(Oa),this}rotateX(e){return this.rotateOnAxis(wv,e)}rotateY(e){return this.rotateOnAxis(Rv,e)}rotateZ(e){return this.rotateOnAxis(Cv,e)}translateOnAxis(e,t){return Av.copy(e).applyQuaternion(this.quaternion),this.position.add(Av.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(wv,e)}translateY(e){return this.translateOnAxis(Rv,e)}translateZ(e){return this.translateOnAxis(Cv,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(jr.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Td.copy(e):Td.set(e,t,n);let r=this.parent;this.updateWorldMatrix(!0,!1),gl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?jr.lookAt(gl,Td,this.up):jr.lookAt(Td,gl,this.up),this.quaternion.setFromRotationMatrix(jr),r&&(jr.extractRotation(r.matrixWorld),Oa.setFromRotationMatrix(jr),this.quaternion.premultiply(Oa.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.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(Pv),Da.child=e,this.dispatchEvent(Da),Da.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}let t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(sT),hg.child=e,this.dispatchEvent(hg),hg.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),jr.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),jr.multiply(e.parent.matrixWorld)),e.applyMatrix4(jr),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Pv),Da.child=e,this.dispatchEvent(Da),Da.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 o=this.children[n].getObjectByProperty(e,t);if(o!==void 0)return o}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].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(gl,e,iT),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(gl,rT,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}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),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){let n=this.parent;if(e===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),t===!0){let r=this.children;for(let s=0,o=r.length;s<o;s++)r[s].updateWorldMatrix(!1,!0)}}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.6,type:"Object",generator:"Object3D.toJSON"});let r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),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.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),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.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=s(e.geometries,this.geometry);let a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){let c=a.shapes;if(Array.isArray(c))for(let l=0,u=c.length;l<u;l++){let h=c[l];s(e.shapes,h)}else s(e.shapes,c)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){let a=[];for(let c=0,l=this.material.length;c<l;c++)a.push(s(e.materials,this.material[c]));r.material=a}else r.material=s(e.materials,this.material);if(this.children.length>0){r.children=[];for(let a=0;a<this.children.length;a++)r.children.push(this.children[a].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let a=0;a<this.animations.length;a++){let c=this.animations[a];r.animations.push(s(e.animations,c))}}if(t){let a=o(e.geometries),c=o(e.materials),l=o(e.textures),u=o(e.images),h=o(e.shapes),d=o(e.skeletons),m=o(e.animations),g=o(e.nodes);a.length>0&&(n.geometries=a),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),u.length>0&&(n.images=u),h.length>0&&(n.shapes=h),d.length>0&&(n.skeletons=d),m.length>0&&(n.animations=m),g.length>0&&(n.nodes=g)}return n.object=r,n;function o(a){let c=[];for(let l in a){let u=a[l];delete u.metadata,c.push(u)}return c}}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.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.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){let r=e.children[n];this.add(r.clone())}return this}};St.DEFAULT_UP=new q(0,1,0);St.DEFAULT_MATRIX_AUTO_UPDATE=!0;St.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;var er=new q,qr=new q,dg=new q,Kr=new q,Fa=new q,Ua=new q,Iv=new q,fg=new q,pg=new q,mg=new q,gg=new It,yg=new It,xg=new It,Oi=class i{constructor(e=new q,t=new q,n=new q){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),er.subVectors(e,t),r.cross(er);let s=r.lengthSq();return s>0?r.multiplyScalar(1/Math.sqrt(s)):r.set(0,0,0)}static getBarycoord(e,t,n,r,s){er.subVectors(r,t),qr.subVectors(n,t),dg.subVectors(e,t);let o=er.dot(er),a=er.dot(qr),c=er.dot(dg),l=qr.dot(qr),u=qr.dot(dg),h=o*l-a*a;if(h===0)return s.set(0,0,0),null;let d=1/h,m=(l*c-a*u)*d,g=(o*u-a*c)*d;return s.set(1-m-g,g,m)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Kr)===null?!1:Kr.x>=0&&Kr.y>=0&&Kr.x+Kr.y<=1}static getInterpolation(e,t,n,r,s,o,a,c){return this.getBarycoord(e,t,n,r,Kr)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,Kr.x),c.addScaledVector(o,Kr.y),c.addScaledVector(a,Kr.z),c)}static getInterpolatedAttribute(e,t,n,r,s,o){return gg.setScalar(0),yg.setScalar(0),xg.setScalar(0),gg.fromBufferAttribute(e,t),yg.fromBufferAttribute(e,n),xg.fromBufferAttribute(e,r),o.setScalar(0),o.addScaledVector(gg,s.x),o.addScaledVector(yg,s.y),o.addScaledVector(xg,s.z),o}static isFrontFacing(e,t,n,r){return er.subVectors(n,t),qr.subVectors(e,t),er.cross(qr).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 er.subVectors(this.c,this.b),qr.subVectors(this.a,this.b),er.cross(qr).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return i.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return i.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,s){return i.getInterpolation(e,this.a,this.b,this.c,t,n,r,s)}containsPoint(e){return i.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return i.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,s=this.c,o,a;Fa.subVectors(r,n),Ua.subVectors(s,n),fg.subVectors(e,n);let c=Fa.dot(fg),l=Ua.dot(fg);if(c<=0&&l<=0)return t.copy(n);pg.subVectors(e,r);let u=Fa.dot(pg),h=Ua.dot(pg);if(u>=0&&h<=u)return t.copy(r);let d=c*h-u*l;if(d<=0&&c>=0&&u<=0)return o=c/(c-u),t.copy(n).addScaledVector(Fa,o);mg.subVectors(e,s);let m=Fa.dot(mg),g=Ua.dot(mg);if(g>=0&&m<=g)return t.copy(s);let y=m*l-c*g;if(y<=0&&l>=0&&g<=0)return a=l/(l-g),t.copy(n).addScaledVector(Ua,a);let f=u*g-m*h;if(f<=0&&h-u>=0&&m-g>=0)return Iv.subVectors(s,r),a=(h-u)/(h-u+(m-g)),t.copy(r).addScaledVector(Iv,a);let p=1/(f+y+d);return o=y*p,a=d*p,t.copy(n).addScaledVector(Fa,o).addScaledVector(Ua,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},a_={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},Cs={h:0,s:0,l:0},Ad={h:0,s:0,l:0};function vg(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}var Be=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=wt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,bt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=bt.workingColorSpace){return this.r=e,this.g=t,this.b=n,bt.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=bt.workingColorSpace){if(e=C0(e,1),t=mt(t,0,1),n=mt(n,0,1),t===0)this.r=this.g=this.b=n;else{let s=n<=.5?n*(1+t):n+t-n*t,o=2*n-s;this.r=vg(o,s,e+1/3),this.g=vg(o,s,e),this.b=vg(o,s,e-1/3)}return bt.toWorkingColorSpace(this,r),this}setStyle(e,t=wt){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s,o=r[1],a=r[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let s=r[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=wt){let n=a_[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Qr(e.r),this.g=Qr(e.g),this.b=Qr(e.b),this}copyLinearToSRGB(e){return this.r=qa(e.r),this.g=qa(e.g),this.b=qa(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=wt){return bt.fromWorkingColorSpace(Kn.copy(this),e),Math.round(mt(Kn.r*255,0,255))*65536+Math.round(mt(Kn.g*255,0,255))*256+Math.round(mt(Kn.b*255,0,255))}getHexString(e=wt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=bt.workingColorSpace){bt.fromWorkingColorSpace(Kn.copy(this),t);let n=Kn.r,r=Kn.g,s=Kn.b,o=Math.max(n,r,s),a=Math.min(n,r,s),c,l,u=(a+o)/2;if(a===o)c=0,l=0;else{let h=o-a;switch(l=u<=.5?h/(o+a):h/(2-o-a),o){case n:c=(r-s)/h+(r<s?6:0);break;case r:c=(s-n)/h+2;break;case s:c=(n-r)/h+4;break}c/=6}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=bt.workingColorSpace){return bt.fromWorkingColorSpace(Kn.copy(this),t),e.r=Kn.r,e.g=Kn.g,e.b=Kn.b,e}getStyle(e=wt){bt.fromWorkingColorSpace(Kn.copy(this),e);let t=Kn.r,n=Kn.g,r=Kn.b;return e!==wt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Cs),this.setHSL(Cs.h+e,Cs.s+t,Cs.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(Cs),e.getHSL(Ad);let n=Rl(Cs.h,Ad.h,t),r=Rl(Cs.s,Ad.s,t),s=Rl(Cs.l,Ad.l,t);return this.setHSL(n,r,s),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,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[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}},Kn=new Be;Be.NAMES=a_;var oT=0,cn=class extends ki{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:oT++}),this.uuid=Di(),this.name="",this.type="Material",this.blending=Fs,this.side=Jn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Il,this.blendDst=Nl,this.blendEquation=yi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Be(0,0,0),this.blendAlpha=0,this.depthFunc=Us,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=lf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ns,this.stencilZFail=Ns,this.stencilZPass=Ns,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.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){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):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.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(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&&this.emissiveIntensity!==1&&(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.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.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),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&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Fs&&(n.blending=this.blending),this.side!==Jn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Il&&(n.blendSrc=this.blendSrc),this.blendDst!==Nl&&(n.blendDst=this.blendDst),this.blendEquation!==yi&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Us&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==lf&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ns&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Ns&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Ns&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),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.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(s){let o=[];for(let a in s){let c=s[a];delete c.metadata,o.push(c)}return o}if(t){let s=r(e.textures),o=r(e.images);s.length>0&&(n.textures=s),o.length>0&&(n.images=o)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let r=t.length;n=new Array(r);for(let s=0;s!==r;++s)n[s]=t[s].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.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++}onBuild(){console.warn("Material: onBuild() has been removed.")}},Ht=class extends cn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Be(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 xi,this.combine=bc,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}},Jr=aT();function aT(){let i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let c=0;c<256;++c){let l=c-127;l<-27?(n[c]=0,n[c|256]=32768,r[c]=24,r[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,r[c]=-l-1,r[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,r[c]=13,r[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,r[c]=24,r[c|256]=24):(n[c]=31744,n[c|256]=64512,r[c]=13,r[c|256]=13)}let s=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,u=0;for(;(l&8388608)===0;)l<<=1,u-=8388608;l&=-8388609,u+=947912704,s[c]=l|u}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)o[c]=c<<23;o[31]=1199570944,o[32]=2147483648;for(let c=33;c<63;++c)o[c]=2147483648+(c-32<<23);o[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(a[c]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:s,exponentTable:o,offsetTable:a}}function gi(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=mt(i,-65504,65504),Jr.floatView[0]=i;let e=Jr.uint32View[0],t=e>>23&511;return Jr.baseTable[t]+((e&8388607)>>Jr.shiftTable[t])}function Al(i){let e=i>>10;return Jr.uint32View[0]=Jr.mantissaTable[Jr.offsetTable[e]+(i&1023)]+Jr.exponentTable[e],Jr.floatView[0]}var c_={toHalfFloat:gi,fromHalfFloat:Al},_n=new q,wd=new Ce,gt=class{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Ja,this.updateRanges=[],this.gpuType=si,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,s=this.itemSize;r<s;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++)wd.fromBufferAttribute(this,t),wd.applyMatrix3(e),this.setXY(t,wd.x,wd.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)_n.fromBufferAttribute(this,t),_n.applyMatrix3(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)_n.fromBufferAttribute(this,t),_n.applyMatrix4(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)_n.fromBufferAttribute(this,t),_n.applyNormalMatrix(e),this.setXYZ(t,_n.x,_n.y,_n.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)_n.fromBufferAttribute(this,t),_n.transformDirection(e),this.setXYZ(t,_n.x,_n.y,_n.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=ri(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Et(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ri(t,this.array)),t}setX(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ri(t,this.array)),t}setY(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=ri(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=ri(t,this.array)),t}setW(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Et(t,this.array),n=Et(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Et(t,this.array),n=Et(n,this.array),r=Et(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Et(t,this.array),n=Et(n,this.array),r=Et(r,this.array),s=Et(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=s,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 this.name!==""&&(e.name=this.name),this.usage!==Ja&&(e.usage=this.usage),e}},df=class extends gt{constructor(e,t,n){super(new Int8Array(e),t,n)}},ff=class extends gt{constructor(e,t,n){super(new Uint8Array(e),t,n)}},pf=class extends gt{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}},mf=class extends gt{constructor(e,t,n){super(new Int16Array(e),t,n)}},tc=class extends gt{constructor(e,t,n){super(new Uint16Array(e),t,n)}},gf=class extends gt{constructor(e,t,n){super(new Int32Array(e),t,n)}},nc=class extends gt{constructor(e,t,n){super(new Uint32Array(e),t,n)}},yf=class extends gt{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Al(this.array[e*this.itemSize]);return this.normalized&&(t=ri(t,this.array)),t}setX(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize]=gi(t),this}getY(e){let t=Al(this.array[e*this.itemSize+1]);return this.normalized&&(t=ri(t,this.array)),t}setY(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize+1]=gi(t),this}getZ(e){let t=Al(this.array[e*this.itemSize+2]);return this.normalized&&(t=ri(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize+2]=gi(t),this}getW(e){let t=Al(this.array[e*this.itemSize+3]);return this.normalized&&(t=ri(t,this.array)),t}setW(e,t){return this.normalized&&(t=Et(t,this.array)),this.array[e*this.itemSize+3]=gi(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Et(t,this.array),n=Et(n,this.array)),this.array[e+0]=gi(t),this.array[e+1]=gi(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Et(t,this.array),n=Et(n,this.array),r=Et(r,this.array)),this.array[e+0]=gi(t),this.array[e+1]=gi(n),this.array[e+2]=gi(r),this}setXYZW(e,t,n,r,s){return e*=this.itemSize,this.normalized&&(t=Et(t,this.array),n=Et(n,this.array),r=Et(r,this.array),s=Et(s,this.array)),this.array[e+0]=gi(t),this.array[e+1]=gi(n),this.array[e+2]=gi(r),this.array[e+3]=gi(s),this}},Ve=class extends gt{constructor(e,t,n){super(new Float32Array(e),t,n)}},cT=0,Wi=new nt,bg=new St,ka=new q,Ni=new zt,yl=new zt,Nn=new q,ot=class i extends ki{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:cT++}),this.uuid=Di(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(P0(e)?nc:tc)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){let t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);let n=this.attributes.normal;if(n!==void 0){let s=new yt().getNormalMatrix(e);n.applyNormalMatrix(s),n.needsUpdate=!0}let r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Wi.makeRotationFromQuaternion(e),this.applyMatrix4(Wi),this}rotateX(e){return Wi.makeRotationX(e),this.applyMatrix4(Wi),this}rotateY(e){return Wi.makeRotationY(e),this.applyMatrix4(Wi),this}rotateZ(e){return Wi.makeRotationZ(e),this.applyMatrix4(Wi),this}translate(e,t,n){return Wi.makeTranslation(e,t,n),this.applyMatrix4(Wi),this}scale(e,t,n){return Wi.makeScale(e,t,n),this.applyMatrix4(Wi),this}lookAt(e){return bg.lookAt(e),bg.updateMatrix(),this.applyMatrix4(bg.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ka).negate(),this.translate(ka.x,ka.y,ka.z),this}setFromPoints(e){let t=this.getAttribute("position");if(t===void 0){let n=[];for(let r=0,s=e.length;r<s;r++){let o=e[r];n.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Ve(n,3))}else{let n=Math.min(e.length,t.count);for(let r=0;r<n;r++){let s=e[r];t.setXYZ(r,s.x,s.y,s.z||0)}e.length>t.count&&console.warn("THREE.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 zt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new q(-1/0,-1/0,-1/0),new q(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){let s=t[n];Ni.setFromBufferAttribute(s),this.morphTargetsRelative?(Nn.addVectors(this.boundingBox.min,Ni.min),this.boundingBox.expandByPoint(Nn),Nn.addVectors(this.boundingBox.max,Ni.max),this.boundingBox.expandByPoint(Nn)):(this.boundingBox.expandByPoint(Ni.min),this.boundingBox.expandByPoint(Ni.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.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 qt);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new q,1/0);return}if(e){let n=this.boundingSphere.center;if(Ni.setFromBufferAttribute(e),t)for(let s=0,o=t.length;s<o;s++){let a=t[s];yl.setFromBufferAttribute(a),this.morphTargetsRelative?(Nn.addVectors(Ni.min,yl.min),Ni.expandByPoint(Nn),Nn.addVectors(Ni.max,yl.max),Ni.expandByPoint(Nn)):(Ni.expandByPoint(yl.min),Ni.expandByPoint(yl.max))}Ni.getCenter(n);let r=0;for(let s=0,o=e.count;s<o;s++)Nn.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(Nn));if(t)for(let s=0,o=t.length;s<o;s++){let a=t[s],c=this.morphTargetsRelative;for(let l=0,u=a.count;l<u;l++)Nn.fromBufferAttribute(a,l),c&&(ka.fromBufferAttribute(e,l),Nn.add(ka)),r=Math.max(r,n.distanceToSquared(Nn))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.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){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}let n=t.position,r=t.normal,s=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new gt(new Float32Array(4*n.count),4));let o=this.getAttribute("tangent"),a=[],c=[];for(let A=0;A<n.count;A++)a[A]=new q,c[A]=new q;let l=new q,u=new q,h=new q,d=new Ce,m=new Ce,g=new Ce,y=new q,f=new q;function p(A,E,M){l.fromBufferAttribute(n,A),u.fromBufferAttribute(n,E),h.fromBufferAttribute(n,M),d.fromBufferAttribute(s,A),m.fromBufferAttribute(s,E),g.fromBufferAttribute(s,M),u.sub(l),h.sub(l),m.sub(d),g.sub(d);let P=1/(m.x*g.y-g.x*m.y);isFinite(P)&&(y.copy(u).multiplyScalar(g.y).addScaledVector(h,-m.y).multiplyScalar(P),f.copy(h).multiplyScalar(m.x).addScaledVector(u,-g.x).multiplyScalar(P),a[A].add(y),a[E].add(y),a[M].add(y),c[A].add(f),c[E].add(f),c[M].add(f))}let v=this.groups;v.length===0&&(v=[{start:0,count:e.count}]);for(let A=0,E=v.length;A<E;++A){let M=v[A],P=M.start,N=M.count;for(let L=P,D=P+N;L<D;L+=3)p(e.getX(L+0),e.getX(L+1),e.getX(L+2))}let b=new q,x=new q,_=new q,T=new q;function w(A){_.fromBufferAttribute(r,A),T.copy(_);let E=a[A];b.copy(E),b.sub(_.multiplyScalar(_.dot(E))).normalize(),x.crossVectors(T,E);let P=x.dot(c[A])<0?-1:1;o.setXYZW(A,b.x,b.y,b.z,P)}for(let A=0,E=v.length;A<E;++A){let M=v[A],P=M.start,N=M.count;for(let L=P,D=P+N;L<D;L+=3)w(e.getX(L+0)),w(e.getX(L+1)),w(e.getX(L+2))}}computeVertexNormals(){let e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new gt(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,m=n.count;d<m;d++)n.setXYZ(d,0,0,0);let r=new q,s=new q,o=new q,a=new q,c=new q,l=new q,u=new q,h=new q;if(e)for(let d=0,m=e.count;d<m;d+=3){let g=e.getX(d+0),y=e.getX(d+1),f=e.getX(d+2);r.fromBufferAttribute(t,g),s.fromBufferAttribute(t,y),o.fromBufferAttribute(t,f),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),a.fromBufferAttribute(n,g),c.fromBufferAttribute(n,y),l.fromBufferAttribute(n,f),a.add(u),c.add(u),l.add(u),n.setXYZ(g,a.x,a.y,a.z),n.setXYZ(y,c.x,c.y,c.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let d=0,m=t.count;d<m;d+=3)r.fromBufferAttribute(t,d+0),s.fromBufferAttribute(t,d+1),o.fromBufferAttribute(t,d+2),u.subVectors(o,s),h.subVectors(r,s),u.cross(h),n.setXYZ(d+0,u.x,u.y,u.z),n.setXYZ(d+1,u.x,u.y,u.z),n.setXYZ(d+2,u.x,u.y,u.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){let e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Nn.fromBufferAttribute(e,t),Nn.normalize(),e.setXYZ(t,Nn.x,Nn.y,Nn.z)}toNonIndexed(){function e(a,c){let l=a.array,u=a.itemSize,h=a.normalized,d=new l.constructor(c.length*u),m=0,g=0;for(let y=0,f=c.length;y<f;y++){a.isInterleavedBufferAttribute?m=c[y]*a.data.stride+a.offset:m=c[y]*u;for(let p=0;p<u;p++)d[g++]=l[m++]}return new gt(d,u,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;let t=new i,n=this.index.array,r=this.attributes;for(let a in r){let c=r[a],l=e(c,n);t.setAttribute(a,l)}let s=this.morphAttributes;for(let a in s){let c=[],l=s[a];for(let u=0,h=l.length;u<h;u++){let d=l[u],m=e(d,n);c.push(m)}t.morphAttributes[a]=c}t.morphTargetsRelative=this.morphTargetsRelative;let o=this.groups;for(let a=0,c=o.length;a<c;a++){let l=o[a];t.addGroup(l.start,l.count,l.materialIndex)}return t}toJSON(){let e={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){let c=this.parameters;for(let l in c)c[l]!==void 0&&(e[l]=c[l]);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 c in n){let l=n[c];e.data.attributes[c]=l.toJSON(e.data)}let r={},s=!1;for(let c in this.morphAttributes){let l=this.morphAttributes[c],u=[];for(let h=0,d=l.length;h<d;h++){let m=l[h];u.push(m.toJSON(e.data))}u.length>0&&(r[c]=u,s=!0)}s&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let o=this.groups;o.length>0&&(e.data.groups=JSON.parse(JSON.stringify(o)));let a=this.boundingSphere;return a!==null&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),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(t));let r=e.attributes;for(let l in r){let u=r[l];this.setAttribute(l,u.clone(t))}let s=e.morphAttributes;for(let l in s){let u=[],h=s[l];for(let d=0,m=h.length;d<m;d++)u.push(h[d].clone(t));this.morphAttributes[l]=u}this.morphTargetsRelative=e.morphTargetsRelative;let o=e.groups;for(let l=0,u=o.length;l<u;l++){let h=o[l];this.addGroup(h.start,h.count,h.materialIndex)}let a=e.boundingBox;a!==null&&(this.boundingBox=a.clone());let c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}},Nv=new nt,vo=new nr,Rd=new qt,Lv=new q,Cd=new q,Pd=new q,Id=new q,_g=new q,Nd=new q,Ov=new q,Ld=new q,ct=class extends St{constructor(e=new ot,t=new Ht){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(e,t){let n=this.geometry,r=n.attributes.position,s=n.morphAttributes.position,o=n.morphTargetsRelative;t.fromBufferAttribute(r,e);let a=this.morphTargetInfluences;if(s&&a){Nd.set(0,0,0);for(let c=0,l=s.length;c<l;c++){let u=a[c],h=s[c];u!==0&&(_g.fromBufferAttribute(h,e),o?Nd.addScaledVector(_g,u):Nd.addScaledVector(_g.sub(t),u))}t.add(Nd)}return t}raycast(e,t){let n=this.geometry,r=this.material,s=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Rd.copy(n.boundingSphere),Rd.applyMatrix4(s),vo.copy(e.ray).recast(e.near),!(Rd.containsPoint(vo.origin)===!1&&(vo.intersectSphere(Rd,Lv)===null||vo.origin.distanceToSquared(Lv)>(e.far-e.near)**2))&&(Nv.copy(s).invert(),vo.copy(e.ray).applyMatrix4(Nv),!(n.boundingBox!==null&&vo.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,vo)))}_computeIntersections(e,t,n){let r,s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,l=s.attributes.uv,u=s.attributes.uv1,h=s.attributes.normal,d=s.groups,m=s.drawRange;if(a!==null)if(Array.isArray(o))for(let g=0,y=d.length;g<y;g++){let f=d[g],p=o[f.materialIndex],v=Math.max(f.start,m.start),b=Math.min(a.count,Math.min(f.start+f.count,m.start+m.count));for(let x=v,_=b;x<_;x+=3){let T=a.getX(x),w=a.getX(x+1),A=a.getX(x+2);r=Od(this,p,e,n,l,u,h,T,w,A),r&&(r.faceIndex=Math.floor(x/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{let g=Math.max(0,m.start),y=Math.min(a.count,m.start+m.count);for(let f=g,p=y;f<p;f+=3){let v=a.getX(f),b=a.getX(f+1),x=a.getX(f+2);r=Od(this,o,e,n,l,u,h,v,b,x),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}else if(c!==void 0)if(Array.isArray(o))for(let g=0,y=d.length;g<y;g++){let f=d[g],p=o[f.materialIndex],v=Math.max(f.start,m.start),b=Math.min(c.count,Math.min(f.start+f.count,m.start+m.count));for(let x=v,_=b;x<_;x+=3){let T=x,w=x+1,A=x+2;r=Od(this,p,e,n,l,u,h,T,w,A),r&&(r.faceIndex=Math.floor(x/3),r.face.materialIndex=f.materialIndex,t.push(r))}}else{let g=Math.max(0,m.start),y=Math.min(c.count,m.start+m.count);for(let f=g,p=y;f<p;f+=3){let v=f,b=f+1,x=f+2;r=Od(this,o,e,n,l,u,h,v,b,x),r&&(r.faceIndex=Math.floor(f/3),t.push(r))}}}};function lT(i,e,t,n,r,s,o,a){let c;if(e.side===un?c=n.intersectTriangle(o,s,r,!0,a):c=n.intersectTriangle(r,s,o,e.side===Jn,a),c===null)return null;Ld.copy(a),Ld.applyMatrix4(i.matrixWorld);let l=t.ray.origin.distanceTo(Ld);return l<t.near||l>t.far?null:{distance:l,point:Ld.clone(),object:i}}function Od(i,e,t,n,r,s,o,a,c,l){i.getVertexPosition(a,Cd),i.getVertexPosition(c,Pd),i.getVertexPosition(l,Id);let u=lT(i,e,t,n,Cd,Pd,Id,Ov);if(u){let h=new q;Oi.getBarycoord(Ov,Cd,Pd,Id,h),r&&(u.uv=Oi.getInterpolatedAttribute(r,a,c,l,h,new Ce)),s&&(u.uv1=Oi.getInterpolatedAttribute(s,a,c,l,h,new Ce)),o&&(u.normal=Oi.getInterpolatedAttribute(o,a,c,l,h,new q),u.normal.dot(n.direction)>0&&u.normal.multiplyScalar(-1));let d={a,b:c,c:l,normal:new q,materialIndex:0};Oi.getNormal(Cd,Pd,Id,d.normal),u.face=d,u.barycoord=h}return u}var Qn=class i extends ot{constructor(e=1,t=1,n=1,r=1,s=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:s,depthSegments:o};let a=this;r=Math.floor(r),s=Math.floor(s),o=Math.floor(o);let c=[],l=[],u=[],h=[],d=0,m=0;g("z","y","x",-1,-1,n,t,e,o,s,0),g("z","y","x",1,-1,n,t,-e,o,s,1),g("x","z","y",1,1,e,n,t,r,o,2),g("x","z","y",1,-1,e,n,-t,r,o,3),g("x","y","z",1,-1,e,t,n,r,s,4),g("x","y","z",-1,-1,e,t,-n,r,s,5),this.setIndex(c),this.setAttribute("position",new Ve(l,3)),this.setAttribute("normal",new Ve(u,3)),this.setAttribute("uv",new Ve(h,2));function g(y,f,p,v,b,x,_,T,w,A,E){let M=x/w,P=_/A,N=x/2,L=_/2,D=T/2,$=w+1,U=A+1,I=0,V=0,W=new q;for(let Q=0;Q<U;Q++){let se=Q*P-L;for(let oe=0;oe<$;oe++){let ge=oe*M-N;W[y]=ge*v,W[f]=se*b,W[p]=D,l.push(W.x,W.y,W.z),W[y]=0,W[f]=0,W[p]=T>0?1:-1,u.push(W.x,W.y,W.z),h.push(oe/w),h.push(1-Q/A),I+=1}}for(let Q=0;Q<A;Q++)for(let se=0;se<w;se++){let oe=d+se+$*Q,ge=d+se+$*(Q+1),O=d+(se+1)+$*(Q+1),S=d+(se+1)+$*Q;c.push(oe,ge,S),c.push(ge,O,S),V+=6}a.addGroup(m,V,E),m+=V,d+=I}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function $o(i){let e={};for(let t in i){e[t]={};for(let n in i[t]){let r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function $n(i){let e={};for(let t=0;t<i.length;t++){let n=$o(i[t]);for(let r in n)e[r]=n[r]}return e}function uT(i){let e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function N0(i){let e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:bt.workingColorSpace}var Gn={clone:$o,merge:$n},hT=`void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,dT=`void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`,$t=class extends cn{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=hT,this.fragmentShader=dT,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=$o(e.uniforms),this.uniformsGroups=uT(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let r in this.uniforms){let o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},Lo=class extends St{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new nt,this.projectionMatrix=new nt,this.projectionMatrixInverse=new nt,this.coordinateSystem=tr}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},Ps=new q,Dv=new Ce,Fv=new Ce,jt=class extends Lo{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=Po*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Co*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Po*2*Math.atan(Math.tan(Co*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){Ps.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ps.x,Ps.y).multiplyScalar(-e/Ps.z),Ps.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ps.x,Ps.y).multiplyScalar(-e/Ps.z)}getViewSize(e,t){return this.getViewBounds(e,Dv,Fv),t.subVectors(Fv,Dv)}setViewOffset(e,t,n,r,s,o){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Co*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r,o=this.view;if(this.view!==null&&this.view.enabled){let c=o.fullWidth,l=o.fullHeight;s+=o.offsetX*r/c,t-=o.offsetY*n/l,r*=o.width/c,n*=o.height/l}let a=this.filmOffset;a!==0&&(s+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},Ba=-90,za=1,Dl=class extends St{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new jt(Ba,za,e,t);r.layers=this.layers,this.add(r);let s=new jt(Ba,za,e,t);s.layers=this.layers,this.add(s);let o=new jt(Ba,za,e,t);o.layers=this.layers,this.add(o);let a=new jt(Ba,za,e,t);a.layers=this.layers,this.add(a);let c=new jt(Ba,za,e,t);c.layers=this.layers,this.add(c);let l=new jt(Ba,za,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,s,o,a,c]=t;for(let l of t)this.remove(l);if(e===tr)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),o.up.set(0,0,1),o.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(e===Qa)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),o.up.set(0,0,-1),o.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let l of t)this.add(l),l.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[s,o,a,c,l,u]=this.children,h=e.getRenderTarget(),d=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;let y=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,s),e.setRenderTarget(n,1,r),e.render(t,o),e.setRenderTarget(n,2,r),e.render(t,a),e.setRenderTarget(n,3,r),e.render(t,c),e.setRenderTarget(n,4,r),e.render(t,l),n.texture.generateMipmaps=y,e.setRenderTarget(n,5,r),e.render(t,u),e.setRenderTarget(h,d,m),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}},Vs=class extends Qt{constructor(e,t,n,r,s,o,a,c,l,u){e=e!==void 0?e:[],t=t!==void 0?t:Nr,super(e,t,n,r,s,o,a,c,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Fl=class extends on{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new Vs(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps!==void 0?t.generateMipmaps:!1,this.texture.minFilter=t.minFilter!==void 0?t.minFilter:nn}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:`

				varying vec3 vWorldDirection;

				vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

					return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

				}

				void main() {

					vWorldDirection = transformDirection( position, modelMatrix );

					#include <begin_vertex>
					#include <project_vertex>

				}
			`,fragmentShader:`

				uniform sampler2D tEquirect;

				varying vec3 vWorldDirection;

				#include <common>

				void main() {

					vec3 direction = normalize( vWorldDirection );

					vec2 sampleUV = equirectUv( direction );

					gl_FragColor = texture2D( tEquirect, sampleUV );

				}
			`},r=new Qn(5,5,5),s=new $t({name:"CubemapFromEquirect",uniforms:$o(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:un,blending:xn});s.uniforms.tEquirect.value=t;let o=new ct(r,s),a=t.minFilter;return t.minFilter===Mi&&(t.minFilter=nn),new Dl(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,r){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,r);e.setRenderTarget(s)}},Ul=class i{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Be(e),this.density=t}clone(){return new i(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}},kl=class i{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new Be(e),this.near=t,this.far=n}clone(){return new i(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},oi=class extends St{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 xi,this.environmentIntensity=1,this.environmentRotation=new xi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=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),e.overrideMaterial!==null&&(this.overrideMaterial=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()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}},Mr=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Ja,this.updateRanges=[],this.version=0,this.uuid=Di()}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,s=this.stride;r<s;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={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Di()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);let t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Di()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},ii=new q,ir=class i{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}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++)ii.fromBufferAttribute(this,t),ii.applyMatrix4(e),this.setXYZ(t,ii.x,ii.y,ii.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)ii.fromBufferAttribute(this,t),ii.applyNormalMatrix(e),this.setXYZ(t,ii.x,ii.y,ii.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)ii.fromBufferAttribute(this,t),ii.transformDirection(e),this.setXYZ(t,ii.x,ii.y,ii.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=ri(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Et(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Et(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Et(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Et(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Et(t,this.array)),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=ri(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ri(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ri(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ri(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Et(t,this.array),n=Et(n,this.array)),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=Et(t,this.array),n=Et(n,this.array),r=Et(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=Et(t,this.array),n=Et(n,this.array),r=Et(r,this.array),s=Et(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=s,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return new gt(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new i(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");let t=[];for(let n=0;n<this.count;n++){let r=n*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)t.push(this.data.array[r+s])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else 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}}},Hs=class extends cn{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Be(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}},Va,xl=new q,Ha=new q,Ga=new q,Wa=new Ce,vl=new Ce,l_=new nt,Dd=new q,bl=new q,Fd=new q,Uv=new Ce,Eg=new Ce,kv=new Ce,Oo=class extends St{constructor(e=new Hs){if(super(),this.isSprite=!0,this.type="Sprite",Va===void 0){Va=new ot;let t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Mr(t,5);Va.setIndex([0,1,2,0,2,3]),Va.setAttribute("position",new ir(n,3,0,!1)),Va.setAttribute("uv",new ir(n,2,3,!1))}this.geometry=Va,this.material=e,this.center=new Ce(.5,.5)}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ha.setFromMatrixScale(this.matrixWorld),l_.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ga.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ha.multiplyScalar(-Ga.z);let n=this.material.rotation,r,s;n!==0&&(s=Math.cos(n),r=Math.sin(n));let o=this.center;Ud(Dd.set(-.5,-.5,0),Ga,o,Ha,r,s),Ud(bl.set(.5,-.5,0),Ga,o,Ha,r,s),Ud(Fd.set(.5,.5,0),Ga,o,Ha,r,s),Uv.set(0,0),Eg.set(1,0),kv.set(1,1);let a=e.ray.intersectTriangle(Dd,bl,Fd,!1,xl);if(a===null&&(Ud(bl.set(-.5,.5,0),Ga,o,Ha,r,s),Eg.set(0,1),a=e.ray.intersectTriangle(Dd,Fd,bl,!1,xl),a===null))return;let c=e.ray.origin.distanceTo(xl);c<e.near||c>e.far||t.push({distance:c,point:xl.clone(),uv:Oi.getInterpolation(xl,Dd,bl,Fd,Uv,Eg,kv,new Ce),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}};function Ud(i,e,t,n,r,s){Wa.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(vl.x=s*Wa.x-r*Wa.y,vl.y=r*Wa.x+s*Wa.y):vl.copy(Wa),i.copy(e),i.x+=vl.x,i.y+=vl.y,i.applyMatrix4(l_)}var kd=new q,Bv=new q,Bl=class extends St{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let n=0,r=t.length;n<r;n++){let s=t[n];this.addLevel(s.object.clone(),s.distance,s.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);let r=this.levels,s;for(s=0;s<r.length&&!(t<r[s].distance);s++);return r.splice(s,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){let t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){let r=t.splice(n,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){let t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let s=t[n].distance;if(t[n].object.visible&&(s-=s*t[n].hysteresis),e<s)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){kd.setFromMatrixPosition(this.matrixWorld);let r=e.ray.origin.distanceTo(kd);this.getObjectForDistance(r).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){kd.setFromMatrixPosition(e.matrixWorld),Bv.setFromMatrixPosition(this.matrixWorld);let n=kd.distanceTo(Bv)/e.zoom;t[0].object.visible=!0;let r,s;for(r=1,s=t.length;r<s;r++){let o=t[r].distance;if(t[r].object.visible&&(o-=o*t[r].hysteresis),n>=o)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<s;r++)t[r].object.visible=!1}}toJSON(e){let t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];let n=this.levels;for(let r=0,s=n.length;r<s;r++){let o=n[r];t.object.levels.push({object:o.object.uuid,distance:o.distance,hysteresis:o.hysteresis})}return t}},zv=new q,Vv=new It,Hv=new It,fT=new q,Gv=new nt,Bd=new q,Mg=new qt,Wv=new nt,Sg=new nr,Do=class extends ct{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=cf,this.bindMatrix=new nt,this.bindMatrixInverse=new nt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let e=this.geometry;this.boundingBox===null&&(this.boundingBox=new zt),this.boundingBox.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Bd),this.boundingBox.expandByPoint(Bd)}computeBoundingSphere(){let e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new qt),this.boundingSphere.makeEmpty();let t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Bd),this.boundingSphere.expandByPoint(Bd)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){let n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Mg.copy(this.boundingSphere),Mg.applyMatrix4(r),e.ray.intersectsSphere(Mg)!==!1&&(Wv.copy(r).invert(),Sg.copy(e.ray).applyMatrix4(Wv),!(this.boundingBox!==null&&Sg.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Sg)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){let e=new It,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);let s=1/e.manhattanLength();s!==1/0?e.multiplyScalar(s):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===cf?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===m0?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){let n=this.skeleton,r=this.geometry;Vv.fromBufferAttribute(r.attributes.skinIndex,e),Hv.fromBufferAttribute(r.attributes.skinWeight,e),zv.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let s=0;s<4;s++){let o=Hv.getComponent(s);if(o!==0){let a=Vv.getComponent(s);Gv.multiplyMatrices(n.bones[a].matrixWorld,n.boneInverses[a]),t.addScaledVector(fT.copy(zv).applyMatrix4(Gv),o)}}return t.applyMatrix4(this.bindMatrixInverse)}},Gs=class extends St{constructor(){super(),this.isBone=!0,this.type="Bone"}},An=class extends Qt{constructor(e=null,t=1,n=1,r,s,o,a,c,l=Jt,u=Jt,h,d){super(null,o,a,c,l,u,r,s,h,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},Xv=new nt,pT=new nt,Fo=class i{constructor(e=[],t=[]){this.uuid=Di(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){let e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new nt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){let n=new nt;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){let n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){let e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let s=0,o=e.length;s<o;s++){let a=e[s]?e[s].matrixWorld:pT;Xv.multiplyMatrices(a,t[s]),Xv.toArray(n,s*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new i(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4);t.set(this.boneMatrices);let n=new An(t,e,e,Ln,si);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){let r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){let s=e.bones[n],o=t[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new Gs),this.bones.push(o),this.boneInverses.push(new nt().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){let e={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;let t=this.bones,n=this.boneInverses;for(let r=0,s=t.length;r<s;r++){let o=t[r];e.bones.push(o.uuid);let a=n[r];e.boneInverses.push(a.toArray())}return e}},Xi=class extends gt{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){let e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}},Xa=new nt,Yv=new nt,zd=[],jv=new zt,mT=new nt,_l=new ct,El=new qt,$r=class extends ct{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new Xi(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,mT)}computeBoundingBox(){let e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new zt),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Xa),jv.copy(e.boundingBox).applyMatrix4(Xa),this.boundingBox.union(jv)}computeBoundingSphere(){let e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new qt),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,Xa),El.copy(e.boundingSphere).applyMatrix4(Xa),this.boundingSphere.union(El)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){let n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,s=n.length+1,o=e*s+1;for(let a=0;a<n.length;a++)n[a]=r[o+a]}raycast(e,t){let n=this.matrixWorld,r=this.count;if(_l.geometry=this.geometry,_l.material=this.material,_l.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),El.copy(this.boundingSphere),El.applyMatrix4(n),e.ray.intersectsSphere(El)!==!1))for(let s=0;s<r;s++){this.getMatrixAt(s,Xa),Yv.multiplyMatrices(n,Xa),_l.matrixWorld=Yv,_l.raycast(e,zd);for(let o=0,a=zd.length;o<a;o++){let c=zd[o];c.instanceId=s,c.object=this,t.push(c)}zd.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new Xi(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){let n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new An(new Float32Array(r*this.count),r,this.count,Wu,si));let s=this.morphTexture.source.data.data,o=0;for(let l=0;l<n.length;l++)o+=n[l];let a=this.geometry.morphTargetsRelative?1:1-o,c=r*e;s[c]=a,s.set(n,c+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null),this}},Tg=new q,gT=new q,yT=new yt,Li=class{constructor(e=new q(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=Tg.subVectors(n,t).cross(gT.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){let n=e.delta(Tg),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(e.start).addScaledVector(n,s)}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||yT.getNormalMatrix(e),r=this.coplanarPoint(Tg).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(s),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},bo=new qt,Vd=new q,Ws=class{constructor(e=new Li,t=new Li,n=new Li,r=new Li,s=new Li,o=new Li){this.planes=[e,t,n,r,s,o]}set(e,t,n,r,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(r),a[4].copy(s),a[5].copy(o),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=tr){let n=this.planes,r=e.elements,s=r[0],o=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],d=r[7],m=r[8],g=r[9],y=r[10],f=r[11],p=r[12],v=r[13],b=r[14],x=r[15];if(n[0].setComponents(c-s,d-l,f-m,x-p).normalize(),n[1].setComponents(c+s,d+l,f+m,x+p).normalize(),n[2].setComponents(c+o,d+u,f+g,x+v).normalize(),n[3].setComponents(c-o,d-u,f-g,x-v).normalize(),n[4].setComponents(c-a,d-h,f-y,x-b).normalize(),t===tr)n[5].setComponents(c+a,d+h,f+y,x+b).normalize();else if(t===Qa)n[5].setComponents(a,h,y,b).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),bo.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),bo.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(bo)}intersectsSprite(e){return bo.center.set(0,0,0),bo.radius=.7071067811865476,bo.applyMatrix4(e.matrixWorld),this.intersectsSphere(bo)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].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(Vd.x=r.normal.x>0?e.max.x:e.min.x,Vd.y=r.normal.y>0?e.max.y:e.min.y,Vd.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Vd)<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)}};function Ag(i,e){return i-e}function xT(i,e){return i.z-e.z}function vT(i,e){return e.z-i.z}var kg=class{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,r){let s=this.pool,o=this.list;this.index>=s.length&&s.push({start:-1,count:-1,z:-1,index:-1});let a=s[this.index];o.push(a),this.index++,a.start=e,a.count=t,a.z=n,a.index=r}reset(){this.list.length=0,this.index=0}},mi=new nt,bT=new Be(1,1,1),wg=new Ws,Hd=new zt,_o=new qt,Ml=new q,qv=new q,_T=new q,Rg=new kg,Zn=new ct,Gd=[];function ET(i,e,t=0){let n=e.itemSize;if(i.isInterleavedBufferAttribute||i.array.constructor!==e.array.constructor){let r=i.count;for(let s=0;s<r;s++)for(let o=0;o<n;o++)e.setComponent(s+t,o,i.getComponent(s,o))}else e.array.set(i.array,t*n);e.needsUpdate=!0}function Eo(i,e){if(i.constructor!==e.constructor){let t=Math.min(i.length,e.length);for(let n=0;n<t;n++)e[n]=i[n]}else{let t=Math.min(i.length,e.length);e.set(new i.constructor(i.buffer,0,t))}}var zl=class extends ct{get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}constructor(e,t,n=t*2,r){super(new ot,r),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}_initMatricesTexture(){let e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);let t=new Float32Array(e*e*4),n=new An(t,e,e,Ln,si);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Uint32Array(e*e),n=new An(t,e,e,Sc,Lr);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);let t=new Float32Array(e*e*4).fill(1),n=new An(t,e,e,Ln,si);n.colorSpace=bt.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){let t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(let s in e.attributes){let o=e.getAttribute(s),{array:a,itemSize:c,normalized:l}=o,u=new a.constructor(n*c),h=new gt(u,c,l);t.setAttribute(s,h)}if(e.getIndex()!==null){let s=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new gt(s,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let r=e.getAttribute(n),s=t.getAttribute(n);if(r.itemSize!==s.itemSize||r.normalized!==s.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new zt);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let s=t[n].geometryIndex;this.getMatrixAt(n,mi),this.getBoundingBoxAt(s,Hd).applyMatrix4(mi),e.union(Hd)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new qt);let e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;let s=t[n].geometryIndex;this.getMatrixAt(n,mi),this.getBoundingSphereAt(s,_o).applyMatrix4(mi),e.union(_o)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");let n={visible:!0,active:!0,geometryIndex:e},r=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Ag),r=this._availableInstanceIds.shift(),this._instanceInfo[r]=n):(r=this._instanceInfo.length,this._instanceInfo.push(n));let s=this._matricesTexture;mi.identity().toArray(s.image.data,r*16),s.needsUpdate=!0;let o=this._colorsTexture;return o&&(bT.toArray(o.image.data,r*4),o.needsUpdate=!0),this._visibilityChanged=!0,r}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);let r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},s=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;let o=e.getIndex();if(o!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=n===-1?o.count:n),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let c;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Ag),c=this._availableGeometryIds.shift(),s[c]=r):(c=this._geometryCount,this._geometryCount++,s.push(r)),this.setGeometryAt(c,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,c}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let n=this.geometry,r=n.getIndex()!==null,s=n.getIndex(),o=t.getIndex(),a=this._geometryInfo[e];if(r&&o.count>a.reservedIndexCount||t.attributes.position.count>a.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let c=a.vertexStart,l=a.reservedVertexCount;a.vertexCount=t.getAttribute("position").count;for(let u in n.attributes){let h=t.getAttribute(u),d=n.getAttribute(u);ET(h,d,c);let m=h.itemSize;for(let g=h.count,y=l;g<y;g++){let f=c+g;for(let p=0;p<m;p++)d.setComponent(f,p,0)}d.needsUpdate=!0,d.addUpdateRange(c*m,l*m)}if(r){let u=a.indexStart,h=a.reservedIndexCount;a.indexCount=t.getIndex().count;for(let d=0;d<o.count;d++)s.setX(u+d,c+o.getX(d));for(let d=o.count,m=h;d<m;d++)s.setX(u+d,c);s.needsUpdate=!0,s.addUpdateRange(u,a.reservedIndexCount)}return a.start=r?a.indexStart:a.vertexStart,a.count=r?a.indexCount:a.vertexCount,a.boundingBox=null,t.boundingBox!==null&&(a.boundingBox=t.boundingBox.clone()),a.boundingSphere=null,t.boundingSphere!==null&&(a.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){let t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;let n=this._instanceInfo;for(let r=0,s=n.length;r<s;r++)n[r].geometryIndex===e&&this.deleteInstance(r);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0,n=this._geometryInfo,r=n.map((o,a)=>a).sort((o,a)=>n[o].vertexStart-n[a].vertexStart),s=this.geometry;for(let o=0,a=n.length;o<a;o++){let c=r[o],l=n[c];if(l.active!==!1){if(s.index!==null){if(l.indexStart!==t){let{indexStart:u,vertexStart:h,reservedIndexCount:d}=l,m=s.index,g=m.array,y=e-h;for(let f=u;f<u+d;f++)g[f]=g[f]+y;m.array.copyWithin(t,u,u+d),m.addUpdateRange(t,d),l.indexStart=t}t+=l.reservedIndexCount}if(l.vertexStart!==e){let{vertexStart:u,reservedVertexCount:h}=l,d=s.attributes;for(let m in d){let g=d[m],{array:y,itemSize:f}=g;y.copyWithin(e*f,u*f,(u+h)*f),g.addUpdateRange(e*f,h*f)}l.vertexStart=e}e+=l.reservedVertexCount,l.start=s.index?l.indexStart:l.vertexStart,this._nextIndexStart=s.index?l.indexStart+l.reservedIndexCount:0,this._nextVertexStart=l.vertexStart+l.reservedVertexCount}}return this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){let s=new zt,o=n.index,a=n.attributes.position;for(let c=r.start,l=r.start+r.count;c<l;c++){let u=c;o&&(u=o.getX(u)),s.expandByPoint(Ml.fromBufferAttribute(a,u))}r.boundingBox=s}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;let n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){let s=new qt;this.getBoundingBoxAt(e,Hd),Hd.getCenter(s.center);let o=n.index,a=n.attributes.position,c=0;for(let l=r.start,u=r.start+r.count;l<u;l++){let h=l;o&&(h=o.getX(h)),Ml.fromBufferAttribute(a,h),c=Math.max(c,s.center.distanceToSquared(Ml))}s.radius=Math.sqrt(c),r.boundingSphere=s}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);let n=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);let n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){let t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(Ag);t[t.length-1]===n.length;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);let r=new Int32Array(e),s=new Int32Array(e);Eo(this._multiDrawCounts,r),Eo(this._multiDrawStarts,s),this._multiDrawCounts=r,this._multiDrawStarts=s,this._maxInstanceCount=e;let o=this._indirectTexture,a=this._matricesTexture,c=this._colorsTexture;o.dispose(),this._initIndirectTexture(),Eo(o.image.data,this._indirectTexture.image.data),a.dispose(),this._initMatricesTexture(),Eo(a.image.data,this._matricesTexture.image.data),c&&(c.dispose(),this._initColorsTexture(),Eo(c.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){let n=[...this._geometryInfo].filter(a=>a.active);if(Math.max(...n.map(a=>a.vertexStart+a.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(c=>c.indexStart+c.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let s=this.geometry;s.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new ot,this._initializeGeometry(s));let o=this.geometry;s.index&&Eo(s.index.array,o.index.array);for(let a in s.attributes)Eo(s.attributes[a].array,o.attributes[a].array)}raycast(e,t){let n=this._instanceInfo,r=this._geometryInfo,s=this.matrixWorld,o=this.geometry;Zn.material=this.material,Zn.geometry.index=o.index,Zn.geometry.attributes=o.attributes,Zn.geometry.boundingBox===null&&(Zn.geometry.boundingBox=new zt),Zn.geometry.boundingSphere===null&&(Zn.geometry.boundingSphere=new qt);for(let a=0,c=n.length;a<c;a++){if(!n[a].visible||!n[a].active)continue;let l=n[a].geometryIndex,u=r[l];Zn.geometry.setDrawRange(u.start,u.count),this.getMatrixAt(a,Zn.matrixWorld).premultiply(s),this.getBoundingBoxAt(l,Zn.geometry.boundingBox),this.getBoundingSphereAt(l,Zn.geometry.boundingSphere),Zn.raycast(e,Gd);for(let h=0,d=Gd.length;h<d;h++){let m=Gd[h];m.object=this,m.batchId=a,t.push(m)}Gd.length=0}Zn.material=null,Zn.geometry.index=null,Zn.geometry.attributes={},Zn.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>({...t})),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,n,r,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let o=r.getIndex(),a=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._instanceInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,h=this._geometryInfo,d=this.perObjectFrustumCulled,m=this._indirectTexture,g=m.image.data;d&&(mi.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),wg.setFromProjectionMatrix(mi,e.coordinateSystem));let y=0;if(this.sortObjects){mi.copy(this.matrixWorld).invert(),Ml.setFromMatrixPosition(n.matrixWorld).applyMatrix4(mi),qv.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(mi);for(let v=0,b=c.length;v<b;v++)if(c[v].visible&&c[v].active){let x=c[v].geometryIndex;this.getMatrixAt(v,mi),this.getBoundingSphereAt(x,_o).applyMatrix4(mi);let _=!1;if(d&&(_=!wg.intersectsSphere(_o)),!_){let T=h[x],w=_T.subVectors(_o.center,Ml).dot(qv);Rg.push(T.start,T.count,w,v)}}let f=Rg.list,p=this.customSort;p===null?f.sort(s.transparent?vT:xT):p.call(this,f,n);for(let v=0,b=f.length;v<b;v++){let x=f[v];l[y]=x.start*a,u[y]=x.count,g[y]=x.index,y++}Rg.reset()}else for(let f=0,p=c.length;f<p;f++)if(c[f].visible&&c[f].active){let v=c[f].geometryIndex,b=!1;if(d&&(this.getMatrixAt(f,mi),this.getBoundingSphereAt(v,_o).applyMatrix4(mi),b=!wg.intersectsSphere(_o)),!b){let x=h[v];l[y]=x.start*a,u[y]=x.count,g[y]=f,y++}}m.needsUpdate=!0,this._multiDrawCount=y,this._visibilityChanged=!1}onBeforeShadow(e,t,n,r,s,o){this.onBeforeRender(e,null,r,s,o)}},Xt=class extends cn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Be(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}},xf=new q,vf=new q,Kv=new nt,Sl=new nr,Wd=new qt,Cg=new q,Zv=new q,ai=class extends St{constructor(e=new ot,t=new Xt){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),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 r=1,s=t.count;r<s;r++)xf.fromBufferAttribute(t,r-1),vf.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=xf.distanceTo(vf);e.setAttribute("lineDistance",new Ve(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,s=e.params.Line.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Wd.copy(n.boundingSphere),Wd.applyMatrix4(r),Wd.radius+=s,e.ray.intersectsSphere(Wd)===!1)return;Kv.copy(r).invert(),Sl.copy(e.ray).applyMatrix4(Kv);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=this.isLineSegments?2:1,u=n.index,d=n.attributes.position;if(u!==null){let m=Math.max(0,o.start),g=Math.min(u.count,o.start+o.count);for(let y=m,f=g-1;y<f;y+=l){let p=u.getX(y),v=u.getX(y+1),b=Xd(this,e,Sl,c,p,v);b&&t.push(b)}if(this.isLineLoop){let y=u.getX(g-1),f=u.getX(m),p=Xd(this,e,Sl,c,y,f);p&&t.push(p)}}else{let m=Math.max(0,o.start),g=Math.min(d.count,o.start+o.count);for(let y=m,f=g-1;y<f;y+=l){let p=Xd(this,e,Sl,c,y,y+1);p&&t.push(p)}if(this.isLineLoop){let y=Xd(this,e,Sl,c,g-1,m);y&&t.push(y)}}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};function Xd(i,e,t,n,r,s){let o=i.geometry.attributes.position;if(xf.fromBufferAttribute(o,r),vf.fromBufferAttribute(o,s),t.distanceSqToSegment(xf,vf,Cg,Zv)>n)return;Cg.applyMatrix4(i.matrixWorld);let c=e.ray.origin.distanceTo(Cg);if(!(c<e.near||c>e.far))return{distance:c,point:Zv.clone().applyMatrix4(i.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:i}}var Jv=new q,Qv=new q,ln=class extends ai{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(e.index===null){let t=e.attributes.position,n=[];for(let r=0,s=t.count;r<s;r+=2)Jv.fromBufferAttribute(t,r),Qv.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+Jv.distanceTo(Qv);e.setAttribute("lineDistance",new Ve(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},es=class extends ai{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}},Sr=class extends cn{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Be(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}},$v=new nt,Bg=new nr,Yd=new qt,jd=new q,ts=class extends St{constructor(e=new ot,t=new Sr){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,s=e.params.Points.threshold,o=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Yd.copy(n.boundingSphere),Yd.applyMatrix4(r),Yd.radius+=s,e.ray.intersectsSphere(Yd)===!1)return;$v.copy(r).invert(),Bg.copy(e.ray).applyMatrix4($v);let a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,l=n.index,h=n.attributes.position;if(l!==null){let d=Math.max(0,o.start),m=Math.min(l.count,o.start+o.count);for(let g=d,y=m;g<y;g++){let f=l.getX(g);jd.fromBufferAttribute(h,f),eb(jd,f,c,r,e,t,this)}}else{let d=Math.max(0,o.start),m=Math.min(h.count,o.start+o.count);for(let g=d,y=m;g<y;g++)jd.fromBufferAttribute(h,g),eb(jd,g,c,r,e,t,this)}}updateMorphTargets(){let t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){let r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s<o;s++){let a=r[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}};function eb(i,e,t,n,r,s,o){let a=Bg.distanceSqToPoint(i);if(a<t){let c=new q;Bg.closestPointToPoint(i,c),c.applyMatrix4(n);let l=r.ray.origin.distanceTo(c);if(l<r.near||l>r.far)return;s.push({distance:l,distanceToRay:Math.sqrt(a),point:c,index:e,face:null,faceIndex:null,barycoord:null,object:o})}}var Dt=class extends St{constructor(){super(),this.isGroup=!0,this.type="Group"}},bf=class extends Qt{constructor(e,t,n,r,s,o,a,c,l){super(e,t,n,r,s,o,a,c,l),this.isVideoTexture=!0,this.minFilter=o!==void 0?o:nn,this.magFilter=s!==void 0?s:nn,this.generateMipmaps=!1;let u=this;function h(){u.needsUpdate=!0,e.requestVideoFrameCallback(h)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(h)}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}},_f=class extends Qt{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Jt,this.minFilter=Jt,this.generateMipmaps=!1,this.needsUpdate=!0}},Uo=class extends Qt{constructor(e,t,n,r,s,o,a,c,l,u,h,d){super(null,o,a,c,l,u,r,s,h,d),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}},Ef=class extends Uo{constructor(e,t,n,r,s,o){super(e,t,n,s,o),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=En,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Mf=class extends Uo{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Nr),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}},ns=class extends Qt{constructor(e,t,n,r,s,o,a,c,l){super(e,t,n,r,s,o,a,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},Xs=class extends Qt{constructor(e,t,n,r,s,o,a,c,l,u=Ds){if(u!==Ds&&u!==Er)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");n===void 0&&u===Ds&&(n=Lr),n===void 0&&u===Er&&(n=Or),super(null,r,s,o,a,c,u,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=a!==void 0?a:Jt,this.minFilter=c!==void 0?c:Jt,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}},vi=class{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){let n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){let t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){let e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;let t=[],n,r=this.getPoint(0),s=0;t.push(0);for(let o=1;o<=e;o++)n=this.getPoint(o/e),s+=n.distanceTo(r),t.push(s),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){let n=this.getLengths(),r=0,s=n.length,o;t?o=t:o=e*n[s-1];let a=0,c=s-1,l;for(;a<=c;)if(r=Math.floor(a+(c-a)/2),l=n[r]-o,l<0)a=r+1;else if(l>0)c=r-1;else{c=r;break}if(r=c,n[r]===o)return r/(s-1);let u=n[r],d=n[r+1]-u,m=(o-u)/d;return(r+m)/(s-1)}getTangent(e,t){let r=e-1e-4,s=e+1e-4;r<0&&(r=0),s>1&&(s=1);let o=this.getPoint(r),a=this.getPoint(s),c=t||(o.isVector2?new Ce:new q);return c.copy(a).sub(o).normalize(),c}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){let n=new q,r=[],s=[],o=[],a=new q,c=new nt;for(let m=0;m<=e;m++){let g=m/e;r[m]=this.getTangentAt(g,new q)}s[0]=new q,o[0]=new q;let l=Number.MAX_VALUE,u=Math.abs(r[0].x),h=Math.abs(r[0].y),d=Math.abs(r[0].z);u<=l&&(l=u,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),d<=l&&n.set(0,0,1),a.crossVectors(r[0],n).normalize(),s[0].crossVectors(r[0],a),o[0].crossVectors(r[0],s[0]);for(let m=1;m<=e;m++){if(s[m]=s[m-1].clone(),o[m]=o[m-1].clone(),a.crossVectors(r[m-1],r[m]),a.length()>Number.EPSILON){a.normalize();let g=Math.acos(mt(r[m-1].dot(r[m]),-1,1));s[m].applyMatrix4(c.makeRotationAxis(a,g))}o[m].crossVectors(r[m],s[m])}if(t===!0){let m=Math.acos(mt(s[0].dot(s[e]),-1,1));m/=e,r[0].dot(a.crossVectors(s[0],s[e]))>0&&(m=-m);for(let g=1;g<=e;g++)s[g].applyMatrix4(c.makeRotationAxis(r[g],m*g)),o[g].crossVectors(r[g],s[g])}return{tangents:r,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},ko=class extends vi{constructor(e=0,t=0,n=1,r=1,s=0,o=Math.PI*2,a=!1,c=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=s,this.aEndAngle=o,this.aClockwise=a,this.aRotation=c}getPoint(e,t=new Ce){let n=t,r=Math.PI*2,s=this.aEndAngle-this.aStartAngle,o=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=r;for(;s>r;)s-=r;s<Number.EPSILON&&(o?s=0:s=r),this.aClockwise===!0&&!o&&(s===r?s=-r:s=s-r);let a=this.aStartAngle+e*s,c=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(this.aRotation!==0){let u=Math.cos(this.aRotation),h=Math.sin(this.aRotation),d=c-this.aX,m=l-this.aY;c=d*u-m*h+this.aX,l=d*h+m*u+this.aY}return n.set(c,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){let e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}},Vl=class extends ko{constructor(e,t,n,r,s,o){super(e,t,n,n,r,s,o),this.isArcCurve=!0,this.type="ArcCurve"}};function L0(){let i=0,e=0,t=0,n=0;function r(s,o,a,c){i=s,e=a,t=-3*s+3*o-2*a-c,n=2*s-2*o+a+c}return{initCatmullRom:function(s,o,a,c,l){r(o,a,l*(a-s),l*(c-o))},initNonuniformCatmullRom:function(s,o,a,c,l,u,h){let d=(o-s)/l-(a-s)/(l+u)+(a-o)/u,m=(a-o)/u-(c-o)/(u+h)+(c-a)/h;d*=u,m*=u,r(o,a,d,m)},calc:function(s){let o=s*s,a=o*s;return i+e*s+t*o+n*a}}}var qd=new q,Pg=new L0,Ig=new L0,Ng=new L0,Hl=class extends vi{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new q){let n=t,r=this.points,s=r.length,o=(s-(this.closed?0:1))*e,a=Math.floor(o),c=o-a;this.closed?a+=a>0?0:(Math.floor(Math.abs(a)/s)+1)*s:c===0&&a===s-1&&(a=s-2,c=1);let l,u;this.closed||a>0?l=r[(a-1)%s]:(qd.subVectors(r[0],r[1]).add(r[0]),l=qd);let h=r[a%s],d=r[(a+1)%s];if(this.closed||a+2<s?u=r[(a+2)%s]:(qd.subVectors(r[s-1],r[s-2]).add(r[s-1]),u=qd),this.curveType==="centripetal"||this.curveType==="chordal"){let m=this.curveType==="chordal"?.5:.25,g=Math.pow(l.distanceToSquared(h),m),y=Math.pow(h.distanceToSquared(d),m),f=Math.pow(d.distanceToSquared(u),m);y<1e-4&&(y=1),g<1e-4&&(g=y),f<1e-4&&(f=y),Pg.initNonuniformCatmullRom(l.x,h.x,d.x,u.x,g,y,f),Ig.initNonuniformCatmullRom(l.y,h.y,d.y,u.y,g,y,f),Ng.initNonuniformCatmullRom(l.z,h.z,d.z,u.z,g,y,f)}else this.curveType==="catmullrom"&&(Pg.initCatmullRom(l.x,h.x,d.x,u.x,this.tension),Ig.initCatmullRom(l.y,h.y,d.y,u.y,this.tension),Ng.initCatmullRom(l.z,h.z,d.z,u.z,this.tension));return n.set(Pg.calc(c),Ig.calc(c),Ng.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let r=e.points[t];this.points.push(new q().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}};function tb(i,e,t,n,r){let s=(n-e)*.5,o=(r-t)*.5,a=i*i,c=i*a;return(2*t-2*n+s+o)*c+(-3*t+3*n-2*s-o)*a+s*i+t}function MT(i,e){let t=1-i;return t*t*e}function ST(i,e){return 2*(1-i)*i*e}function TT(i,e){return i*i*e}function Cl(i,e,t,n){return MT(i,e)+ST(i,t)+TT(i,n)}function AT(i,e){let t=1-i;return t*t*t*e}function wT(i,e){let t=1-i;return 3*t*t*i*e}function RT(i,e){return 3*(1-i)*i*i*e}function CT(i,e){return i*i*i*e}function Pl(i,e,t,n,r){return AT(i,e)+wT(i,t)+RT(i,n)+CT(i,r)}var ic=class extends vi{constructor(e=new Ce,t=new Ce,n=new Ce,r=new Ce){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new Ce){let n=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Pl(e,r.x,s.x,o.x,a.x),Pl(e,r.y,s.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},Gl=class extends vi{constructor(e=new q,t=new q,n=new q,r=new q){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new q){let n=t,r=this.v0,s=this.v1,o=this.v2,a=this.v3;return n.set(Pl(e,r.x,s.x,o.x,a.x),Pl(e,r.y,s.y,o.y,a.y),Pl(e,r.z,s.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}},rc=class extends vi{constructor(e=new Ce,t=new Ce){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Ce){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new Ce){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},Wl=class extends vi{constructor(e=new q,t=new q){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new q){let n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new q){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},sc=class extends vi{constructor(e=new Ce,t=new Ce,n=new Ce){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Ce){let n=t,r=this.v0,s=this.v1,o=this.v2;return n.set(Cl(e,r.x,s.x,o.x),Cl(e,r.y,s.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},oc=class extends vi{constructor(e=new q,t=new q,n=new q){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new q){let n=t,r=this.v0,s=this.v1,o=this.v2;return n.set(Cl(e,r.x,s.x,o.x),Cl(e,r.y,s.y,o.y),Cl(e,r.z,s.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){let e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},ac=class extends vi{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Ce){let n=t,r=this.points,s=(r.length-1)*e,o=Math.floor(s),a=s-o,c=r[o===0?o:o-1],l=r[o],u=r[o>r.length-2?r.length-1:o+1],h=r[o>r.length-3?r.length-1:o+2];return n.set(tb(a,c.x,l.x,u.x,h.x),tb(a,c.y,l.y,u.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let r=e.points[t];this.points.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){let r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){let r=e.points[t];this.points.push(new Ce().fromArray(r))}return this}},Sf=Object.freeze({__proto__:null,ArcCurve:Vl,CatmullRomCurve3:Hl,CubicBezierCurve:ic,CubicBezierCurve3:Gl,EllipseCurve:ko,LineCurve:rc,LineCurve3:Wl,QuadraticBezierCurve:sc,QuadraticBezierCurve3:oc,SplineCurve:ac}),Xl=class extends vi{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){let e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){let n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new Sf[n](t,e))}return this}getPoint(e,t){let n=e*this.getLength(),r=this.getCurveLengths(),s=0;for(;s<r.length;){if(r[s]>=n){let o=r[s]-n,a=this.curves[s],c=a.getLength(),l=c===0?0:1-o/c;return a.getPointAt(l,t)}s++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){let t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){let t=[],n;for(let r=0,s=this.curves;r<s.length;r++){let o=s[r],a=o.isEllipseCurve?e*2:o.isLineCurve||o.isLineCurve3?1:o.isSplineCurve?e*o.points.length:e,c=o.getPoints(a);for(let l=0;l<c.length;l++){let u=c[l];n&&n.equals(u)||(t.push(u),n=u)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){let e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){let r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){let r=e.curves[t];this.curves.push(new Sf[r.type]().fromJSON(r))}return this}},Tr=class extends Xl{constructor(e){super(),this.type="Path",this.currentPoint=new Ce,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){let n=new rc(this.currentPoint.clone(),new Ce(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){let s=new sc(this.currentPoint.clone(),new Ce(e,t),new Ce(n,r));return this.curves.push(s),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,s,o){let a=new ic(this.currentPoint.clone(),new Ce(e,t),new Ce(n,r),new Ce(s,o));return this.curves.push(a),this.currentPoint.set(s,o),this}splineThru(e){let t=[this.currentPoint.clone()].concat(e),n=new ac(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,s,o){let a=this.currentPoint.x,c=this.currentPoint.y;return this.absarc(e+a,t+c,n,r,s,o),this}absarc(e,t,n,r,s,o){return this.absellipse(e,t,n,n,r,s,o),this}ellipse(e,t,n,r,s,o,a,c){let l=this.currentPoint.x,u=this.currentPoint.y;return this.absellipse(e+l,t+u,n,r,s,o,a,c),this}absellipse(e,t,n,r,s,o,a,c){let l=new ko(e,t,n,r,s,o,a,c);if(this.curves.length>0){let h=l.getPoint(0);h.equals(this.currentPoint)||this.lineTo(h.x,h.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}},cc=class i extends ot{constructor(e=[new Ce(0,-.5),new Ce(.5,0),new Ce(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=mt(r,0,Math.PI*2);let s=[],o=[],a=[],c=[],l=[],u=1/t,h=new q,d=new Ce,m=new q,g=new q,y=new q,f=0,p=0;for(let v=0;v<=e.length-1;v++)switch(v){case 0:f=e[v+1].x-e[v].x,p=e[v+1].y-e[v].y,m.x=p*1,m.y=-f,m.z=p*0,y.copy(m),m.normalize(),c.push(m.x,m.y,m.z);break;case e.length-1:c.push(y.x,y.y,y.z);break;default:f=e[v+1].x-e[v].x,p=e[v+1].y-e[v].y,m.x=p*1,m.y=-f,m.z=p*0,g.copy(m),m.x+=y.x,m.y+=y.y,m.z+=y.z,m.normalize(),c.push(m.x,m.y,m.z),y.copy(g)}for(let v=0;v<=t;v++){let b=n+v*u*r,x=Math.sin(b),_=Math.cos(b);for(let T=0;T<=e.length-1;T++){h.x=e[T].x*x,h.y=e[T].y,h.z=e[T].x*_,o.push(h.x,h.y,h.z),d.x=v/t,d.y=T/(e.length-1),a.push(d.x,d.y);let w=c[3*T+0]*x,A=c[3*T+1],E=c[3*T+0]*_;l.push(w,A,E)}}for(let v=0;v<t;v++)for(let b=0;b<e.length-1;b++){let x=b+v*e.length,_=x,T=x+e.length,w=x+e.length+1,A=x+1;s.push(_,T,A),s.push(w,A,T)}this.setIndex(s),this.setAttribute("position",new Ve(o,3)),this.setAttribute("uv",new Ve(a,2)),this.setAttribute("normal",new Ve(l,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.points,e.segments,e.phiStart,e.phiLength)}},Yl=class i extends cc{constructor(e=1,t=1,n=4,r=8){let s=new Tr;s.absarc(0,-t/2,e,Math.PI*1.5,0),s.absarc(0,t/2,e,0,Math.PI*.5),super(s.getPoints(n),r),this.type="CapsuleGeometry",this.parameters={radius:e,length:t,capSegments:n,radialSegments:r}}static fromJSON(e){return new i(e.radius,e.length,e.capSegments,e.radialSegments)}},jl=class i extends ot{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);let s=[],o=[],a=[],c=[],l=new q,u=new Ce;o.push(0,0,0),a.push(0,0,1),c.push(.5,.5);for(let h=0,d=3;h<=t;h++,d+=3){let m=n+h/t*r;l.x=e*Math.cos(m),l.y=e*Math.sin(m),o.push(l.x,l.y,l.z),a.push(0,0,1),u.x=(o[d]/e+1)/2,u.y=(o[d+1]/e+1)/2,c.push(u.x,u.y)}for(let h=1;h<=t;h++)s.push(h,h+1,0);this.setIndex(s),this.setAttribute("position",new Ve(o,3)),this.setAttribute("normal",new Ve(a,3)),this.setAttribute("uv",new Ve(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radius,e.segments,e.thetaStart,e.thetaLength)}},is=class i extends ot{constructor(e=1,t=1,n=1,r=32,s=1,o=!1,a=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:s,openEnded:o,thetaStart:a,thetaLength:c};let l=this;r=Math.floor(r),s=Math.floor(s);let u=[],h=[],d=[],m=[],g=0,y=[],f=n/2,p=0;v(),o===!1&&(e>0&&b(!0),t>0&&b(!1)),this.setIndex(u),this.setAttribute("position",new Ve(h,3)),this.setAttribute("normal",new Ve(d,3)),this.setAttribute("uv",new Ve(m,2));function v(){let x=new q,_=new q,T=0,w=(t-e)/n;for(let A=0;A<=s;A++){let E=[],M=A/s,P=M*(t-e)+e;for(let N=0;N<=r;N++){let L=N/r,D=L*c+a,$=Math.sin(D),U=Math.cos(D);_.x=P*$,_.y=-M*n+f,_.z=P*U,h.push(_.x,_.y,_.z),x.set($,w,U).normalize(),d.push(x.x,x.y,x.z),m.push(L,1-M),E.push(g++)}y.push(E)}for(let A=0;A<r;A++)for(let E=0;E<s;E++){let M=y[E][A],P=y[E+1][A],N=y[E+1][A+1],L=y[E][A+1];(e>0||E!==0)&&(u.push(M,P,L),T+=3),(t>0||E!==s-1)&&(u.push(P,N,L),T+=3)}l.addGroup(p,T,0),p+=T}function b(x){let _=g,T=new Ce,w=new q,A=0,E=x===!0?e:t,M=x===!0?1:-1;for(let N=1;N<=r;N++)h.push(0,f*M,0),d.push(0,M,0),m.push(.5,.5),g++;let P=g;for(let N=0;N<=r;N++){let D=N/r*c+a,$=Math.cos(D),U=Math.sin(D);w.x=E*U,w.y=f*M,w.z=E*$,h.push(w.x,w.y,w.z),d.push(0,M,0),T.x=$*.5+.5,T.y=U*.5*M+.5,m.push(T.x,T.y),g++}for(let N=0;N<r;N++){let L=_+N,D=P+N;x===!0?u.push(D,D+1,L):u.push(D+1,D,L),A+=3}l.addGroup(p,A,x===!0?1:2),p+=A}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},Bo=class i extends is{constructor(e=1,t=1,n=32,r=1,s=!1,o=0,a=Math.PI*2){super(0,e,t,n,r,s,o,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:s,thetaStart:o,thetaLength:a}}static fromJSON(e){return new i(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}},rs=class i extends ot{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};let s=[],o=[];a(r),l(n),u(),this.setAttribute("position",new Ve(s,3)),this.setAttribute("normal",new Ve(s.slice(),3)),this.setAttribute("uv",new Ve(o,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function a(v){let b=new q,x=new q,_=new q;for(let T=0;T<t.length;T+=3)m(t[T+0],b),m(t[T+1],x),m(t[T+2],_),c(b,x,_,v)}function c(v,b,x,_){let T=_+1,w=[];for(let A=0;A<=T;A++){w[A]=[];let E=v.clone().lerp(x,A/T),M=b.clone().lerp(x,A/T),P=T-A;for(let N=0;N<=P;N++)N===0&&A===T?w[A][N]=E:w[A][N]=E.clone().lerp(M,N/P)}for(let A=0;A<T;A++)for(let E=0;E<2*(T-A)-1;E++){let M=Math.floor(E/2);E%2===0?(d(w[A][M+1]),d(w[A+1][M]),d(w[A][M])):(d(w[A][M+1]),d(w[A+1][M+1]),d(w[A+1][M]))}}function l(v){let b=new q;for(let x=0;x<s.length;x+=3)b.x=s[x+0],b.y=s[x+1],b.z=s[x+2],b.normalize().multiplyScalar(v),s[x+0]=b.x,s[x+1]=b.y,s[x+2]=b.z}function u(){let v=new q;for(let b=0;b<s.length;b+=3){v.x=s[b+0],v.y=s[b+1],v.z=s[b+2];let x=f(v)/2/Math.PI+.5,_=p(v)/Math.PI+.5;o.push(x,1-_)}g(),h()}function h(){for(let v=0;v<o.length;v+=6){let b=o[v+0],x=o[v+2],_=o[v+4],T=Math.max(b,x,_),w=Math.min(b,x,_);T>.9&&w<.1&&(b<.2&&(o[v+0]+=1),x<.2&&(o[v+2]+=1),_<.2&&(o[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function m(v,b){let x=v*3;b.x=e[x+0],b.y=e[x+1],b.z=e[x+2]}function g(){let v=new q,b=new q,x=new q,_=new q,T=new Ce,w=new Ce,A=new Ce;for(let E=0,M=0;E<s.length;E+=9,M+=6){v.set(s[E+0],s[E+1],s[E+2]),b.set(s[E+3],s[E+4],s[E+5]),x.set(s[E+6],s[E+7],s[E+8]),T.set(o[M+0],o[M+1]),w.set(o[M+2],o[M+3]),A.set(o[M+4],o[M+5]),_.copy(v).add(b).add(x).divideScalar(3);let P=f(_);y(T,M+0,v,P),y(w,M+2,b,P),y(A,M+4,x,P)}}function y(v,b,x,_){_<0&&v.x===1&&(o[b]=v.x-1),x.x===0&&x.z===0&&(o[b]=_/2/Math.PI+.5)}function f(v){return Math.atan2(v.z,-v.x)}function p(v){return Math.atan2(-v.y,Math.sqrt(v.x*v.x+v.z*v.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.vertices,e.indices,e.radius,e.details)}},ql=class i extends rs{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=1/n,s=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],o=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(s,o,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new i(e.radius,e.detail)}},Kd=new q,Zd=new q,Lg=new q,Jd=new Oi,ss=class extends ot{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){let r=Math.pow(10,4),s=Math.cos(Co*t),o=e.getIndex(),a=e.getAttribute("position"),c=o?o.count:a.count,l=[0,0,0],u=["a","b","c"],h=new Array(3),d={},m=[];for(let g=0;g<c;g+=3){o?(l[0]=o.getX(g),l[1]=o.getX(g+1),l[2]=o.getX(g+2)):(l[0]=g,l[1]=g+1,l[2]=g+2);let{a:y,b:f,c:p}=Jd;if(y.fromBufferAttribute(a,l[0]),f.fromBufferAttribute(a,l[1]),p.fromBufferAttribute(a,l[2]),Jd.getNormal(Lg),h[0]=`${Math.round(y.x*r)},${Math.round(y.y*r)},${Math.round(y.z*r)}`,h[1]=`${Math.round(f.x*r)},${Math.round(f.y*r)},${Math.round(f.z*r)}`,h[2]=`${Math.round(p.x*r)},${Math.round(p.y*r)},${Math.round(p.z*r)}`,!(h[0]===h[1]||h[1]===h[2]||h[2]===h[0]))for(let v=0;v<3;v++){let b=(v+1)%3,x=h[v],_=h[b],T=Jd[u[v]],w=Jd[u[b]],A=`${x}_${_}`,E=`${_}_${x}`;E in d&&d[E]?(Lg.dot(d[E].normal)<=s&&(m.push(T.x,T.y,T.z),m.push(w.x,w.y,w.z)),d[E]=null):A in d||(d[A]={index0:l[v],index1:l[b],normal:Lg.clone()})}}for(let g in d)if(d[g]){let{index0:y,index1:f}=d[g];Kd.fromBufferAttribute(a,y),Zd.fromBufferAttribute(a,f),m.push(Kd.x,Kd.y,Kd.z),m.push(Zd.x,Zd.y,Zd.z)}this.setAttribute("position",new Ve(m,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}},Fi=class extends Tr{constructor(e){super(e),this.uuid=Di(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){let e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){let r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){let r=e.holes[t];this.holes.push(new Tr().fromJSON(r))}return this}},PT={triangulate:function(i,e,t=2){let n=e&&e.length,r=n?e[0]*t:i.length,s=u_(i,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,h,d,m;if(n&&(s=DT(i,e,s,t)),i.length>80*t){a=l=i[0],c=u=i[1];for(let g=t;g<r;g+=t)h=i[g],d=i[g+1],h<a&&(a=h),d<c&&(c=d),h>l&&(l=h),d>u&&(u=d);m=Math.max(l-a,u-c),m=m!==0?32767/m:0}return Kl(s,o,t,a,c,m,0),o}};function u_(i,e,t,n,r){let s,o;if(r===YT(i,e,t,n)>0)for(s=e;s<t;s+=n)o=nb(s,i[s],i[s+1],o);else for(s=t-n;s>=e;s-=n)o=nb(s,i[s],i[s+1],o);return o&&Tp(o,o.next)&&(Jl(o),o=o.next),o}function zo(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(Tp(t,t.next)||an(t.prev,t,t.next)===0)){if(Jl(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Kl(i,e,t,n,r,s,o){if(!i)return;!o&&s&&zT(i,n,r,s);let a=i,c,l;for(;i.prev!==i.next;){if(c=i.prev,l=i.next,s?NT(i,n,r,s):IT(i)){e.push(c.i/t|0),e.push(i.i/t|0),e.push(l.i/t|0),Jl(i),i=l.next,a=l.next;continue}if(i=l,i===a){o?o===1?(i=LT(zo(i),e,t),Kl(i,e,t,n,r,s,2)):o===2&&OT(i,e,t,n,r,s):Kl(zo(i),e,t,n,r,s,1);break}}}function IT(i){let e=i.prev,t=i,n=i.next;if(an(e,t,n)>=0)return!1;let r=e.x,s=t.x,o=n.x,a=e.y,c=t.y,l=n.y,u=r<s?r<o?r:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,d=r>s?r>o?r:o:s>o?s:o,m=a>c?a>l?a:l:c>l?c:l,g=n.next;for(;g!==e;){if(g.x>=u&&g.x<=d&&g.y>=h&&g.y<=m&&ja(r,a,s,c,o,l,g.x,g.y)&&an(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function NT(i,e,t,n){let r=i.prev,s=i,o=i.next;if(an(r,s,o)>=0)return!1;let a=r.x,c=s.x,l=o.x,u=r.y,h=s.y,d=o.y,m=a<c?a<l?a:l:c<l?c:l,g=u<h?u<d?u:d:h<d?h:d,y=a>c?a>l?a:l:c>l?c:l,f=u>h?u>d?u:d:h>d?h:d,p=zg(m,g,e,t,n),v=zg(y,f,e,t,n),b=i.prevZ,x=i.nextZ;for(;b&&b.z>=p&&x&&x.z<=v;){if(b.x>=m&&b.x<=y&&b.y>=g&&b.y<=f&&b!==r&&b!==o&&ja(a,u,c,h,l,d,b.x,b.y)&&an(b.prev,b,b.next)>=0||(b=b.prevZ,x.x>=m&&x.x<=y&&x.y>=g&&x.y<=f&&x!==r&&x!==o&&ja(a,u,c,h,l,d,x.x,x.y)&&an(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;b&&b.z>=p;){if(b.x>=m&&b.x<=y&&b.y>=g&&b.y<=f&&b!==r&&b!==o&&ja(a,u,c,h,l,d,b.x,b.y)&&an(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;x&&x.z<=v;){if(x.x>=m&&x.x<=y&&x.y>=g&&x.y<=f&&x!==r&&x!==o&&ja(a,u,c,h,l,d,x.x,x.y)&&an(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function LT(i,e,t){let n=i;do{let r=n.prev,s=n.next.next;!Tp(r,s)&&h_(r,n,n.next,s)&&Zl(r,s)&&Zl(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),Jl(n),Jl(n.next),n=i=s),n=n.next}while(n!==i);return zo(n)}function OT(i,e,t,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&GT(o,a)){let c=d_(o,a);o=zo(o,o.next),c=zo(c,c.next),Kl(o,e,t,n,r,s,0),Kl(c,e,t,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function DT(i,e,t,n){let r=[],s,o,a,c,l;for(s=0,o=e.length;s<o;s++)a=e[s]*n,c=s<o-1?e[s+1]*n:i.length,l=u_(i,a,c,n,!1),l===l.next&&(l.steiner=!0),r.push(HT(l));for(r.sort(FT),s=0;s<r.length;s++)t=UT(r[s],t);return t}function FT(i,e){return i.x-e.x}function UT(i,e){let t=kT(i,e);if(!t)return e;let n=d_(t,i);return zo(n,n.next),zo(t,t.next)}function kT(i,e){let t=e,n=-1/0,r,s=i.x,o=i.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){let d=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>n&&(n=d,r=t.x<t.next.x?t:t.next,d===s))return r}t=t.next}while(t!==e);if(!r)return null;let a=r,c=r.x,l=r.y,u=1/0,h;t=r;do s>=t.x&&t.x>=c&&s!==t.x&&ja(o<l?s:n,o,c,l,o<l?n:s,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(s-t.x),Zl(t,i)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&BT(r,t)))&&(r=t,u=h)),t=t.next;while(t!==a);return r}function BT(i,e){return an(i.prev,i,e.prev)<0&&an(e.next,i,i.next)<0}function zT(i,e,t,n){let r=i;do r.z===0&&(r.z=zg(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,VT(r)}function VT(i){let e,t,n,r,s,o,a,c,l=1;do{for(t=i,i=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<l&&(a++,n=n.nextZ,!!n);e++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,a--):(r=n,n=n.nextZ,c--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,l*=2}while(o>1);return i}function zg(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function HT(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function ja(i,e,t,n,r,s,o,a){return(r-o)*(e-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(n-a)}function GT(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!WT(i,e)&&(Zl(i,e)&&Zl(e,i)&&XT(i,e)&&(an(i.prev,i,e.prev)||an(i,e.prev,e))||Tp(i,e)&&an(i.prev,i,i.next)>0&&an(e.prev,e,e.next)>0)}function an(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function Tp(i,e){return i.x===e.x&&i.y===e.y}function h_(i,e,t,n){let r=$d(an(i,e,t)),s=$d(an(i,e,n)),o=$d(an(t,n,i)),a=$d(an(t,n,e));return!!(r!==s&&o!==a||r===0&&Qd(i,t,e)||s===0&&Qd(i,n,e)||o===0&&Qd(t,i,n)||a===0&&Qd(t,e,n))}function Qd(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function $d(i){return i>0?1:i<0?-1:0}function WT(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&h_(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function Zl(i,e){return an(i.prev,i,i.next)<0?an(i,e,i.next)>=0&&an(i,i.prev,e)>=0:an(i,e,i.prev)<0||an(i,i.next,e)<0}function XT(i,e){let t=i,n=!1,r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function d_(i,e){let t=new Vg(i.i,i.x,i.y),n=new Vg(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function nb(i,e,t,n){let r=new Vg(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Jl(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Vg(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function YT(i,e,t,n){let r=0;for(let s=e,o=t-n;s<t;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}var Ui=class i{static area(e){let t=e.length,n=0;for(let r=t-1,s=0;s<t;r=s++)n+=e[r].x*e[s].y-e[s].x*e[r].y;return n*.5}static isClockWise(e){return i.area(e)<0}static triangulateShape(e,t){let n=[],r=[],s=[];ib(e),rb(n,e);let o=e.length;t.forEach(ib);for(let c=0;c<t.length;c++)r.push(o),o+=t[c].length,rb(n,t[c]);let a=PT.triangulate(n,r);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}};function ib(i){let e=i.length;e>2&&i[e-1].equals(i[0])&&i.pop()}function rb(i,e){for(let t=0;t<e.length;t++)i.push(e[t].x),i.push(e[t].y)}var Ys=class i extends ot{constructor(e=new Fi([new Ce(.5,.5),new Ce(-.5,.5),new Ce(-.5,-.5),new Ce(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];let n=this,r=[],s=[];for(let a=0,c=e.length;a<c;a++){let l=e[a];o(l)}this.setAttribute("position",new Ve(r,3)),this.setAttribute("uv",new Ve(s,2)),this.computeVertexNormals();function o(a){let c=[],l=t.curveSegments!==void 0?t.curveSegments:12,u=t.steps!==void 0?t.steps:1,h=t.depth!==void 0?t.depth:1,d=t.bevelEnabled!==void 0?t.bevelEnabled:!0,m=t.bevelThickness!==void 0?t.bevelThickness:.2,g=t.bevelSize!==void 0?t.bevelSize:m-.1,y=t.bevelOffset!==void 0?t.bevelOffset:0,f=t.bevelSegments!==void 0?t.bevelSegments:3,p=t.extrudePath,v=t.UVGenerator!==void 0?t.UVGenerator:jT,b,x=!1,_,T,w,A;p&&(b=p.getSpacedPoints(u),x=!0,d=!1,_=p.computeFrenetFrames(u,!1),T=new q,w=new q,A=new q),d||(f=0,m=0,g=0,y=0);let E=a.extractPoints(l),M=E.shape,P=E.holes;if(!Ui.isClockWise(M)){M=M.reverse();for(let te=0,ne=P.length;te<ne;te++){let H=P[te];Ui.isClockWise(H)&&(P[te]=H.reverse())}}let L=Ui.triangulateShape(M,P),D=M;for(let te=0,ne=P.length;te<ne;te++){let H=P[te];M=M.concat(H)}function $(te,ne,H){return ne||console.error("THREE.ExtrudeGeometry: vec does not exist"),te.clone().addScaledVector(ne,H)}let U=M.length,I=L.length;function V(te,ne,H){let _e,me,be,he=te.x-ne.x,Ne=te.y-ne.y,Me=H.x-te.x,Z=H.y-te.y,B=he*he+Ne*Ne,k=he*Z-Ne*Me;if(Math.abs(k)>Number.EPSILON){let F=Math.sqrt(B),G=Math.sqrt(Me*Me+Z*Z),j=ne.x-Ne/F,ee=ne.y+he/F,ie=H.x-Z/G,ce=H.y+Me/G,fe=((ie-j)*Z-(ce-ee)*Me)/(he*Z-Ne*Me);_e=j+he*fe-te.x,me=ee+Ne*fe-te.y;let ue=_e*_e+me*me;if(ue<=2)return new Ce(_e,me);be=Math.sqrt(ue/2)}else{let F=!1;he>Number.EPSILON?Me>Number.EPSILON&&(F=!0):he<-Number.EPSILON?Me<-Number.EPSILON&&(F=!0):Math.sign(Ne)===Math.sign(Z)&&(F=!0),F?(_e=-Ne,me=he,be=Math.sqrt(B)):(_e=he,me=Ne,be=Math.sqrt(B/2))}return new Ce(_e/be,me/be)}let W=[];for(let te=0,ne=D.length,H=ne-1,_e=te+1;te<ne;te++,H++,_e++)H===ne&&(H=0),_e===ne&&(_e=0),W[te]=V(D[te],D[H],D[_e]);let Q=[],se,oe=W.concat();for(let te=0,ne=P.length;te<ne;te++){let H=P[te];se=[];for(let _e=0,me=H.length,be=me-1,he=_e+1;_e<me;_e++,be++,he++)be===me&&(be=0),he===me&&(he=0),se[_e]=V(H[_e],H[be],H[he]);Q.push(se),oe=oe.concat(se)}for(let te=0;te<f;te++){let ne=te/f,H=m*Math.cos(ne*Math.PI/2),_e=g*Math.sin(ne*Math.PI/2)+y;for(let me=0,be=D.length;me<be;me++){let he=$(D[me],W[me],_e);z(he.x,he.y,-H)}for(let me=0,be=P.length;me<be;me++){let he=P[me];se=Q[me];for(let Ne=0,Me=he.length;Ne<Me;Ne++){let Z=$(he[Ne],se[Ne],_e);z(Z.x,Z.y,-H)}}}let ge=g+y;for(let te=0;te<U;te++){let ne=d?$(M[te],oe[te],ge):M[te];x?(w.copy(_.normals[0]).multiplyScalar(ne.x),T.copy(_.binormals[0]).multiplyScalar(ne.y),A.copy(b[0]).add(w).add(T),z(A.x,A.y,A.z)):z(ne.x,ne.y,0)}for(let te=1;te<=u;te++)for(let ne=0;ne<U;ne++){let H=d?$(M[ne],oe[ne],ge):M[ne];x?(w.copy(_.normals[te]).multiplyScalar(H.x),T.copy(_.binormals[te]).multiplyScalar(H.y),A.copy(b[te]).add(w).add(T),z(A.x,A.y,A.z)):z(H.x,H.y,h/u*te)}for(let te=f-1;te>=0;te--){let ne=te/f,H=m*Math.cos(ne*Math.PI/2),_e=g*Math.sin(ne*Math.PI/2)+y;for(let me=0,be=D.length;me<be;me++){let he=$(D[me],W[me],_e);z(he.x,he.y,h+H)}for(let me=0,be=P.length;me<be;me++){let he=P[me];se=Q[me];for(let Ne=0,Me=he.length;Ne<Me;Ne++){let Z=$(he[Ne],se[Ne],_e);x?z(Z.x,Z.y+b[u-1].y,b[u-1].x+H):z(Z.x,Z.y,h+H)}}}O(),S();function O(){let te=r.length/3;if(d){let ne=0,H=U*ne;for(let _e=0;_e<I;_e++){let me=L[_e];Y(me[2]+H,me[1]+H,me[0]+H)}ne=u+f*2,H=U*ne;for(let _e=0;_e<I;_e++){let me=L[_e];Y(me[0]+H,me[1]+H,me[2]+H)}}else{for(let ne=0;ne<I;ne++){let H=L[ne];Y(H[2],H[1],H[0])}for(let ne=0;ne<I;ne++){let H=L[ne];Y(H[0]+U*u,H[1]+U*u,H[2]+U*u)}}n.addGroup(te,r.length/3-te,0)}function S(){let te=r.length/3,ne=0;R(D,ne),ne+=D.length;for(let H=0,_e=P.length;H<_e;H++){let me=P[H];R(me,ne),ne+=me.length}n.addGroup(te,r.length/3-te,1)}function R(te,ne){let H=te.length;for(;--H>=0;){let _e=H,me=H-1;me<0&&(me=te.length-1);for(let be=0,he=u+f*2;be<he;be++){let Ne=U*be,Me=U*(be+1),Z=ne+_e+Ne,B=ne+me+Ne,k=ne+me+Me,F=ne+_e+Me;K(Z,B,k,F)}}}function z(te,ne,H){c.push(te),c.push(ne),c.push(H)}function Y(te,ne,H){re(te),re(ne),re(H);let _e=r.length/3,me=v.generateTopUV(n,r,_e-3,_e-2,_e-1);de(me[0]),de(me[1]),de(me[2])}function K(te,ne,H,_e){re(te),re(ne),re(_e),re(ne),re(H),re(_e);let me=r.length/3,be=v.generateSideWallUV(n,r,me-6,me-3,me-2,me-1);de(be[0]),de(be[1]),de(be[3]),de(be[1]),de(be[2]),de(be[3])}function re(te){r.push(c[te*3+0]),r.push(c[te*3+1]),r.push(c[te*3+2])}function de(te){s.push(te.x),s.push(te.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return qT(t,n,e)}static fromJSON(e,t){let n=[];for(let s=0,o=e.shapes.length;s<o;s++){let a=t[e.shapes[s]];n.push(a)}let r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new Sf[r.type]().fromJSON(r)),new i(n,e.options)}},jT={generateTopUV:function(i,e,t,n,r){let s=e[t*3],o=e[t*3+1],a=e[n*3],c=e[n*3+1],l=e[r*3],u=e[r*3+1];return[new Ce(s,o),new Ce(a,c),new Ce(l,u)]},generateSideWallUV:function(i,e,t,n,r,s){let o=e[t*3],a=e[t*3+1],c=e[t*3+2],l=e[n*3],u=e[n*3+1],h=e[n*3+2],d=e[r*3],m=e[r*3+1],g=e[r*3+2],y=e[s*3],f=e[s*3+1],p=e[s*3+2];return Math.abs(a-u)<Math.abs(o-l)?[new Ce(o,1-c),new Ce(l,1-h),new Ce(d,1-g),new Ce(y,1-p)]:[new Ce(a,1-c),new Ce(u,1-h),new Ce(m,1-g),new Ce(f,1-p)]}};function qT(i,e,t){if(t.shapes=[],Array.isArray(i))for(let n=0,r=i.length;n<r;n++){let s=i[n];t.shapes.push(s.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}var Ql=class i extends rs{constructor(e=1,t=0){let n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],s=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(r,s,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new i(e.radius,e.detail)}},lc=class i extends rs{constructor(e=1,t=0){let n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(n,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new i(e.radius,e.detail)}},Ar=class i extends ot{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};let s=e/2,o=t/2,a=Math.floor(n),c=Math.floor(r),l=a+1,u=c+1,h=e/a,d=t/c,m=[],g=[],y=[],f=[];for(let p=0;p<u;p++){let v=p*d-o;for(let b=0;b<l;b++){let x=b*h-s;g.push(x,-v,0),y.push(0,0,1),f.push(b/a),f.push(1-p/c)}}for(let p=0;p<c;p++)for(let v=0;v<a;v++){let b=v+l*p,x=v+l*(p+1),_=v+1+l*(p+1),T=v+1+l*p;m.push(b,x,T),m.push(x,_,T)}this.setIndex(m),this.setAttribute("position",new Ve(g,3)),this.setAttribute("normal",new Ve(y,3)),this.setAttribute("uv",new Ve(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.width,e.height,e.widthSegments,e.heightSegments)}},$l=class i extends ot{constructor(e=.5,t=1,n=32,r=1,s=0,o=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:s,thetaLength:o},n=Math.max(3,n),r=Math.max(1,r);let a=[],c=[],l=[],u=[],h=e,d=(t-e)/r,m=new q,g=new Ce;for(let y=0;y<=r;y++){for(let f=0;f<=n;f++){let p=s+f/n*o;m.x=h*Math.cos(p),m.y=h*Math.sin(p),c.push(m.x,m.y,m.z),l.push(0,0,1),g.x=(m.x/t+1)/2,g.y=(m.y/t+1)/2,u.push(g.x,g.y)}h+=d}for(let y=0;y<r;y++){let f=y*(n+1);for(let p=0;p<n;p++){let v=p+f,b=v,x=v+n+1,_=v+n+2,T=v+1;a.push(b,x,T),a.push(x,_,T)}}this.setIndex(a),this.setAttribute("position",new Ve(c,3)),this.setAttribute("normal",new Ve(l,3)),this.setAttribute("uv",new Ve(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}},eu=class i extends ot{constructor(e=new Fi([new Ce(0,.5),new Ce(-.5,-.5),new Ce(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};let n=[],r=[],s=[],o=[],a=0,c=0;if(Array.isArray(e)===!1)l(e);else for(let u=0;u<e.length;u++)l(e[u]),this.addGroup(a,c,u),a+=c,c=0;this.setIndex(n),this.setAttribute("position",new Ve(r,3)),this.setAttribute("normal",new Ve(s,3)),this.setAttribute("uv",new Ve(o,2));function l(u){let h=r.length/3,d=u.extractPoints(t),m=d.shape,g=d.holes;Ui.isClockWise(m)===!1&&(m=m.reverse());for(let f=0,p=g.length;f<p;f++){let v=g[f];Ui.isClockWise(v)===!0&&(g[f]=v.reverse())}let y=Ui.triangulateShape(m,g);for(let f=0,p=g.length;f<p;f++){let v=g[f];m=m.concat(v)}for(let f=0,p=m.length;f<p;f++){let v=m[f];r.push(v.x,v.y,0),s.push(0,0,1),o.push(v.x,v.y)}for(let f=0,p=y.length;f<p;f++){let v=y[f],b=v[0]+h,x=v[1]+h,_=v[2]+h;n.push(b,x,_),c+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON(),t=this.parameters.shapes;return KT(t,e)}static fromJSON(e,t){let n=[];for(let r=0,s=e.shapes.length;r<s;r++){let o=t[e.shapes[r]];n.push(o)}return new i(n,e.curveSegments)}};function KT(i,e){if(e.shapes=[],Array.isArray(i))for(let t=0,n=i.length;t<n;t++){let r=i[t];e.shapes.push(r.uuid)}else e.shapes.push(i.uuid);return e}var bi=class i extends ot{constructor(e=1,t=32,n=16,r=0,s=Math.PI*2,o=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:s,thetaStart:o,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));let c=Math.min(o+a,Math.PI),l=0,u=[],h=new q,d=new q,m=[],g=[],y=[],f=[];for(let p=0;p<=n;p++){let v=[],b=p/n,x=0;p===0&&o===0?x=.5/t:p===n&&c===Math.PI&&(x=-.5/t);for(let _=0;_<=t;_++){let T=_/t;h.x=-e*Math.cos(r+T*s)*Math.sin(o+b*a),h.y=e*Math.cos(o+b*a),h.z=e*Math.sin(r+T*s)*Math.sin(o+b*a),g.push(h.x,h.y,h.z),d.copy(h).normalize(),y.push(d.x,d.y,d.z),f.push(T+x,1-b),v.push(l++)}u.push(v)}for(let p=0;p<n;p++)for(let v=0;v<t;v++){let b=u[p][v+1],x=u[p][v],_=u[p+1][v],T=u[p+1][v+1];(p!==0||o>0)&&m.push(b,x,T),(p!==n-1||c<Math.PI)&&m.push(x,_,T)}this.setIndex(m),this.setAttribute("position",new Ve(g,3)),this.setAttribute("normal",new Ve(y,3)),this.setAttribute("uv",new Ve(f,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}},tu=class i extends rs{constructor(e=1,t=0){let n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new i(e.radius,e.detail)}},nu=class i extends ot{constructor(e=1,t=.4,n=12,r=48,s=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:s},n=Math.floor(n),r=Math.floor(r);let o=[],a=[],c=[],l=[],u=new q,h=new q,d=new q;for(let m=0;m<=n;m++)for(let g=0;g<=r;g++){let y=g/r*s,f=m/n*Math.PI*2;h.x=(e+t*Math.cos(f))*Math.cos(y),h.y=(e+t*Math.cos(f))*Math.sin(y),h.z=t*Math.sin(f),a.push(h.x,h.y,h.z),u.x=e*Math.cos(y),u.y=e*Math.sin(y),d.subVectors(h,u).normalize(),c.push(d.x,d.y,d.z),l.push(g/r),l.push(m/n)}for(let m=1;m<=n;m++)for(let g=1;g<=r;g++){let y=(r+1)*m+g-1,f=(r+1)*(m-1)+g-1,p=(r+1)*(m-1)+g,v=(r+1)*m+g;o.push(y,f,v),o.push(f,p,v)}this.setIndex(o),this.setAttribute("position",new Ve(a,3)),this.setAttribute("normal",new Ve(c,3)),this.setAttribute("uv",new Ve(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}},iu=class i extends ot{constructor(e=1,t=.4,n=64,r=8,s=2,o=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:s,q:o},n=Math.floor(n),r=Math.floor(r);let a=[],c=[],l=[],u=[],h=new q,d=new q,m=new q,g=new q,y=new q,f=new q,p=new q;for(let b=0;b<=n;++b){let x=b/n*s*Math.PI*2;v(x,s,o,e,m),v(x+.01,s,o,e,g),f.subVectors(g,m),p.addVectors(g,m),y.crossVectors(f,p),p.crossVectors(y,f),y.normalize(),p.normalize();for(let _=0;_<=r;++_){let T=_/r*Math.PI*2,w=-t*Math.cos(T),A=t*Math.sin(T);h.x=m.x+(w*p.x+A*y.x),h.y=m.y+(w*p.y+A*y.y),h.z=m.z+(w*p.z+A*y.z),c.push(h.x,h.y,h.z),d.subVectors(h,m).normalize(),l.push(d.x,d.y,d.z),u.push(b/n),u.push(_/r)}}for(let b=1;b<=n;b++)for(let x=1;x<=r;x++){let _=(r+1)*(b-1)+(x-1),T=(r+1)*b+(x-1),w=(r+1)*b+x,A=(r+1)*(b-1)+x;a.push(_,T,A),a.push(T,w,A)}this.setIndex(a),this.setAttribute("position",new Ve(c,3)),this.setAttribute("normal",new Ve(l,3)),this.setAttribute("uv",new Ve(u,2));function v(b,x,_,T,w){let A=Math.cos(b),E=Math.sin(b),M=_/x*b,P=Math.cos(M);w.x=T*(2+P)*.5*A,w.y=T*(2+P)*E*.5,w.z=T*Math.sin(M)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new i(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}},ru=class i extends ot{constructor(e=new oc(new q(-1,-1,0),new q(-1,1,0),new q(1,1,0)),t=64,n=1,r=8,s=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:s};let o=e.computeFrenetFrames(t,s);this.tangents=o.tangents,this.normals=o.normals,this.binormals=o.binormals;let a=new q,c=new q,l=new Ce,u=new q,h=[],d=[],m=[],g=[];y(),this.setIndex(g),this.setAttribute("position",new Ve(h,3)),this.setAttribute("normal",new Ve(d,3)),this.setAttribute("uv",new Ve(m,2));function y(){for(let b=0;b<t;b++)f(b);f(s===!1?t:0),v(),p()}function f(b){u=e.getPointAt(b/t,u);let x=o.normals[b],_=o.binormals[b];for(let T=0;T<=r;T++){let w=T/r*Math.PI*2,A=Math.sin(w),E=-Math.cos(w);c.x=E*x.x+A*_.x,c.y=E*x.y+A*_.y,c.z=E*x.z+A*_.z,c.normalize(),d.push(c.x,c.y,c.z),a.x=u.x+n*c.x,a.y=u.y+n*c.y,a.z=u.z+n*c.z,h.push(a.x,a.y,a.z)}}function p(){for(let b=1;b<=t;b++)for(let x=1;x<=r;x++){let _=(r+1)*(b-1)+(x-1),T=(r+1)*b+(x-1),w=(r+1)*b+x,A=(r+1)*(b-1)+x;g.push(_,T,A),g.push(T,w,A)}}function v(){for(let b=0;b<=t;b++)for(let x=0;x<=r;x++)l.x=b/t,l.y=x/r,m.push(l.x,l.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){let e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new i(new Sf[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}},su=class extends ot{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){let t=[],n=new Set,r=new q,s=new q;if(e.index!==null){let o=e.attributes.position,a=e.index,c=e.groups;c.length===0&&(c=[{start:0,count:a.count,materialIndex:0}]);for(let l=0,u=c.length;l<u;++l){let h=c[l],d=h.start,m=h.count;for(let g=d,y=d+m;g<y;g+=3)for(let f=0;f<3;f++){let p=a.getX(g+f),v=a.getX(g+(f+1)%3);r.fromBufferAttribute(o,p),s.fromBufferAttribute(o,v),sb(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}}else{let o=e.attributes.position;for(let a=0,c=o.count/3;a<c;a++)for(let l=0;l<3;l++){let u=3*a+l,h=3*a+(l+1)%3;r.fromBufferAttribute(o,u),s.fromBufferAttribute(o,h),sb(r,s,n)===!0&&(t.push(r.x,r.y,r.z),t.push(s.x,s.y,s.z))}}this.setAttribute("position",new Ve(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}};function sb(i,e,t){let n=`${i.x},${i.y},${i.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${i.x},${i.y},${i.z}`;return t.has(n)===!0||t.has(r)===!0?!1:(t.add(n),t.add(r),!0)}var ob=Object.freeze({__proto__:null,BoxGeometry:Qn,CapsuleGeometry:Yl,CircleGeometry:jl,ConeGeometry:Bo,CylinderGeometry:is,DodecahedronGeometry:ql,EdgesGeometry:ss,ExtrudeGeometry:Ys,IcosahedronGeometry:Ql,LatheGeometry:cc,OctahedronGeometry:lc,PlaneGeometry:Ar,PolyhedronGeometry:rs,RingGeometry:$l,ShapeGeometry:eu,SphereGeometry:bi,TetrahedronGeometry:tu,TorusGeometry:nu,TorusKnotGeometry:iu,TubeGeometry:ru,WireframeGeometry:su}),ou=class extends cn{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Be(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}},Vo=class extends $t{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}},Mn=class extends cn{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Be(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},Dn=class extends Mn{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Ce(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return mt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Be(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Be(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Be(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}},Ho=class extends cn{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Be(16777215),this.specular=new Be(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=bc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},au=class extends cn{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Be(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,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.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Go=class extends cn{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}},cu=class extends cn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Be(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Be(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=bc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}},uc=class extends cn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=v0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},hc=class extends cn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},lu=class extends cn{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Be(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ds,this.normalScale=new Ce(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}},uu=class extends Xt{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}};function Ro(i,e,t){return!i||!t&&i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function f_(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function p_(i){function e(r,s){return i[r]-i[s]}let t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function Hg(i,e,t){let n=i.length,r=new i.constructor(n);for(let s=0,o=0;o!==n;++s){let a=t[s]*e;for(let c=0;c!==e;++c)r[o++]=i[a+c]}return r}function O0(i,e,t,n){let r=1,s=i[0];for(;s!==void 0&&s[n]===void 0;)s=i[r++];if(s===void 0)return;let o=s[n];if(o!==void 0)if(Array.isArray(o))do o=s[n],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=i[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[n],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=i[r++];while(s!==void 0);else do o=s[n],o!==void 0&&(e.push(s.time),t.push(o)),s=i[r++];while(s!==void 0)}function ZT(i,e,t,n,r=30){let s=i.clone();s.name=e;let o=[];for(let c=0;c<s.tracks.length;++c){let l=s.tracks[c],u=l.getValueSize(),h=[],d=[];for(let m=0;m<l.times.length;++m){let g=l.times[m]*r;if(!(g<t||g>=n)){h.push(l.times[m]);for(let y=0;y<u;++y)d.push(l.values[m*u+y])}}h.length!==0&&(l.times=Ro(h,l.times.constructor),l.values=Ro(d,l.values.constructor),o.push(l))}s.tracks=o;let a=1/0;for(let c=0;c<s.tracks.length;++c)a>s.tracks[c].times[0]&&(a=s.tracks[c].times[0]);for(let c=0;c<s.tracks.length;++c)s.tracks[c].shift(-1*a);return s.resetDuration(),s}function JT(i,e=0,t=i,n=30){n<=0&&(n=30);let r=t.tracks.length,s=e/n;for(let o=0;o<r;++o){let a=t.tracks[o],c=a.ValueTypeName;if(c==="bool"||c==="string")continue;let l=i.tracks.find(function(p){return p.name===a.name&&p.ValueTypeName===c});if(l===void 0)continue;let u=0,h=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(u=h/3);let d=0,m=l.getValueSize();l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(d=m/3);let g=a.times.length-1,y;if(s<=a.times[0]){let p=u,v=h-u;y=a.values.slice(p,v)}else if(s>=a.times[g]){let p=g*h+u,v=p+h-u;y=a.values.slice(p,v)}else{let p=a.createInterpolant(),v=u,b=h-u;p.evaluate(s),y=p.resultBuffer.slice(v,b)}c==="quaternion"&&new Zt().fromArray(y).normalize().conjugate().toArray(y);let f=l.times.length;for(let p=0;p<f;++p){let v=p*m+d;if(c==="quaternion")Zt.multiplyQuaternionsFlat(l.values,v,y,0,l.values,v);else{let b=m-d*2;for(let x=0;x<b;++x)l.values[v+x]-=y[x]}}}return i.blendMode=bp,i}var m_={convertArray:Ro,isTypedArray:f_,getKeyframeOrder:p_,sortedArray:Hg,flattenJSON:O0,subclip:ZT,makeClipAdditive:JT},wr=class{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){let t=this.parameterPositions,n=this._cachedIndex,r=t[n],s=t[n-1];e:{t:{let o;n:{i:if(!(e<r)){for(let a=n+2;;){if(r===void 0){if(e<s)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===a)break;if(s=r,r=t[++n],e<r)break t}o=t.length;break n}if(!(e>=s)){let a=t[1];e<a&&(n=2,s=a);for(let c=n-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(r=s,s=t[--n-1],e>=s)break t}o=n,n=0;break n}break e}for(;n<o;){let a=n+o>>>1;e<t[a]?o=a:n=a+1}if(r=t[n],s=t[n-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,s,r)}return this.interpolate_(n,s,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r;for(let o=0;o!==r;++o)t[o]=n[s+o];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},hu=class extends wr{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ls,endingEnd:Ls}}intervalChanged_(e,t,n){let r=this.parameterPositions,s=e-2,o=e+1,a=r[s],c=r[o];if(a===void 0)switch(this.getSettings_().endingStart){case Os:s=e,a=2*t-n;break;case Ka:s=r.length-2,a=t+r[s]-r[s+1];break;default:s=e,a=n}if(c===void 0)switch(this.getSettings_().endingEnd){case Os:o=e,c=2*n-t;break;case Ka:o=1,c=n+r[1]-r[0];break;default:o=e-1,c=t}let l=(n-t)*.5,u=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(c-n),this._offsetPrev=s*u,this._offsetNext=o*u}interpolate_(e,t,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=this._offsetPrev,h=this._offsetNext,d=this._weightPrev,m=this._weightNext,g=(n-t)/(r-t),y=g*g,f=y*g,p=-d*f+2*d*y-d*g,v=(1+d)*f+(-1.5-2*d)*y+(-.5+d)*g+1,b=(-1-m)*f+(1.5+m)*y+.5*g,x=m*f-m*y;for(let _=0;_!==a;++_)s[_]=p*o[u+_]+v*o[l+_]+b*o[c+_]+x*o[h+_];return s}},dc=class extends wr{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=e*a,l=c-a,u=(n-t)/(r-t),h=1-u;for(let d=0;d!==a;++d)s[d]=o[l+d]*h+o[c+d]*u;return s}},du=class extends wr{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}},_i=class{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Ro(t,this.TimeBufferType),this.values=Ro(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){let t=e.constructor,n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Ro(e.times,Array),values:Ro(e.values,Array)};let r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new du(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new dc(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new hu(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Bs:t=this.InterpolantFactoryMethodDiscrete;break;case zs:t=this.InterpolantFactoryMethodLinear;break;case wl:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){let n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Bs;case this.InterpolantFactoryMethodLinear:return zs;case this.InterpolantFactoryMethodSmooth:return wl}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){let t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){let n=this.times,r=n.length,s=0,o=r-1;for(;s!==r&&n[s]<e;)++s;for(;o!==-1&&n[o]>t;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);let a=this.getValueSize();this.times=n.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,r=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){let c=n[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),e=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),e=!1;break}o=c}if(r!==void 0&&f_(r))for(let a=0,c=r.length;a!==c;++a){let l=r[a];if(isNaN(l)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,l),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===wl,s=e.length-1,o=1;for(let a=1;a<s;++a){let c=!1,l=e[a],u=e[a+1];if(l!==u&&(a!==1||l!==e[0]))if(r)c=!0;else{let h=a*n,d=h-n,m=h+n;for(let g=0;g!==n;++g){let y=t[h+g];if(y!==t[d+g]||y!==t[m+g]){c=!0;break}}}if(c){if(a!==o){e[o]=e[a];let h=a*n,d=o*n;for(let m=0;m!==n;++m)t[d+m]=t[h+m]}++o}}if(s>0){e[o]=e[s];for(let a=s*n,c=o*n,l=0;l!==n;++l)t[c+l]=t[a+l];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};_i.prototype.TimeBufferType=Float32Array;_i.prototype.ValueBufferType=Float32Array;_i.prototype.DefaultInterpolation=zs;var Rr=class extends _i{constructor(e,t,n){super(e,t,n)}};Rr.prototype.ValueTypeName="bool";Rr.prototype.ValueBufferType=Array;Rr.prototype.DefaultInterpolation=Bs;Rr.prototype.InterpolantFactoryMethodLinear=void 0;Rr.prototype.InterpolantFactoryMethodSmooth=void 0;var fc=class extends _i{};fc.prototype.ValueTypeName="color";var rr=class extends _i{};rr.prototype.ValueTypeName="number";var fu=class extends wr{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(n-t)/(r-t),l=e*a;for(let u=l+a;l!==u;l+=4)Zt.slerpFlat(s,0,o,l-a,o,l,c);return s}},sr=class extends _i{InterpolantFactoryMethodLinear(e){return new fu(this.times,this.values,this.getValueSize(),e)}};sr.prototype.ValueTypeName="quaternion";sr.prototype.InterpolantFactoryMethodSmooth=void 0;var Cr=class extends _i{constructor(e,t,n){super(e,t,n)}};Cr.prototype.ValueTypeName="string";Cr.prototype.ValueBufferType=Array;Cr.prototype.DefaultInterpolation=Bs;Cr.prototype.InterpolantFactoryMethodLinear=void 0;Cr.prototype.InterpolantFactoryMethodSmooth=void 0;var or=class extends _i{};or.prototype.ValueTypeName="vector";var Pr=class{constructor(e="",t=-1,n=[],r=vh){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=Di(),this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,r=1/(e.fps||1);for(let o=0,a=n.length;o!==a;++o)t.push($T(n[o]).scale(r));let s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){let t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=n.length;s!==o;++s)t.push(_i.toJSON(n[s]));return r}static CreateFromMorphTargetSequence(e,t,n,r){let s=t.length,o=[];for(let a=0;a<s;a++){let c=[],l=[];c.push((a+s-1)%s,a,(a+1)%s),l.push(0,1,0);let u=p_(c);c=Hg(c,1,u),l=Hg(l,1,u),!r&&c[0]===0&&(c.push(s),l.push(l[0])),o.push(new rr(".morphTargetInfluences["+t[a].name+"]",c,l).scale(1/n))}return new this(e,-1,o)}static findByName(e,t){let n=e;if(!Array.isArray(e)){let r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){let r={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,c=e.length;a<c;a++){let l=e[a],u=l.name.match(s);if(u&&u.length>1){let h=u[1],d=r[h];d||(r[h]=d=[]),d.push(l)}}let o=[];for(let a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,n));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;let n=function(h,d,m,g,y){if(m.length!==0){let f=[],p=[];O0(m,f,p,g),f.length!==0&&y.push(new h(d,f,p))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode,c=e.length||-1,l=e.hierarchy||[];for(let h=0;h<l.length;h++){let d=l[h].keys;if(!(!d||d.length===0))if(d[0].morphTargets){let m={},g;for(g=0;g<d.length;g++)if(d[g].morphTargets)for(let y=0;y<d[g].morphTargets.length;y++)m[d[g].morphTargets[y]]=-1;for(let y in m){let f=[],p=[];for(let v=0;v!==d[g].morphTargets.length;++v){let b=d[g];f.push(b.time),p.push(b.morphTarget===y?1:0)}r.push(new rr(".morphTargetInfluence["+y+"]",f,p))}c=m.length*o}else{let m=".bones["+t[h].name+"]";n(or,m+".position",d,"pos",r),n(sr,m+".quaternion",d,"rot",r),n(or,m+".scale",d,"scl",r)}}return r.length===0?null:new this(s,c,r,a)}resetDuration(){let e=this.tracks,t=0;for(let n=0,r=e.length;n!==r;++n){let s=this.tracks[n];t=Math.max(t,s.times[s.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){let e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}};function QT(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return rr;case"vector":case"vector2":case"vector3":case"vector4":return or;case"color":return fc;case"quaternion":return sr;case"bool":case"boolean":return Rr;case"string":return Cr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function $T(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=QT(i.type);if(i.times===void 0){let t=[],n=[];O0(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}var _r={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}},pc=class{constructor(e,t,n){let r=this,s=!1,o=0,a=0,c,l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(u){a++,s===!1&&r.onStart!==void 0&&r.onStart(u,o,a),s=!0},this.itemEnd=function(u){o++,r.onProgress!==void 0&&r.onProgress(u,o,a),o===a&&(s=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(u){r.onError!==void 0&&r.onError(u)},this.resolveURL=function(u){return c?c(u):u},this.setURLModifier=function(u){return c=u,this},this.addHandler=function(u,h){return l.push(u,h),this},this.removeHandler=function(u){let h=l.indexOf(u);return h!==-1&&l.splice(h,2),this},this.getHandler=function(u){for(let h=0,d=l.length;h<d;h+=2){let m=l[h],g=l[h+1];if(m.global&&(m.lastIndex=0),m.test(u))return g}return null}}},D0=new pc,rn=class{constructor(e){this.manager=e!==void 0?e:D0,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){let n=this;return new Promise(function(r,s){n.load(e,r,t,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}};rn.DEFAULT_MATERIAL_NAME="__DEFAULT";var Zr={},Gg=class extends Error{constructor(e,t){super(e),this.response=t}},Vn=class extends rn{constructor(e){super(e)}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=_r.get(e);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(s),this.manager.itemEnd(e)},0),s;if(Zr[e]!==void 0){Zr[e].push({onLoad:t,onProgress:n,onError:r});return}Zr[e]=[],Zr[e].push({onLoad:t,onProgress:n,onError:r});let o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;let u=Zr[e],h=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),m=d?parseInt(d):0,g=m!==0,y=0,f=new ReadableStream({start(p){v();function v(){h.read().then(({done:b,value:x})=>{if(b)p.close();else{y+=x.byteLength;let _=new ProgressEvent("progress",{lengthComputable:g,loaded:y,total:m});for(let T=0,w=u.length;T<w;T++){let A=u[T];A.onProgress&&A.onProgress(_)}p.enqueue(x),v()}},b=>{p.error(b)})}}});return new Response(f)}else throw new Gg(`fetch for "${l.url}" responded with ${l.status}: ${l.statusText}`,l)}).then(l=>{switch(c){case"arraybuffer":return l.arrayBuffer();case"blob":return l.blob();case"document":return l.text().then(u=>new DOMParser().parseFromString(u,a));case"json":return l.json();default:if(a===void 0)return l.text();{let h=/charset="?([^;"\s]*)"?/i.exec(a),d=h&&h[1]?h[1].toLowerCase():void 0,m=new TextDecoder(d);return l.arrayBuffer().then(g=>m.decode(g))}}}).then(l=>{_r.add(e,l);let u=Zr[e];delete Zr[e];for(let h=0,d=u.length;h<d;h++){let m=u[h];m.onLoad&&m.onLoad(l)}}).catch(l=>{let u=Zr[e];if(u===void 0)throw this.manager.itemError(e),l;delete Zr[e];for(let h=0,d=u.length;h<d;h++){let m=u[h];m.onError&&m.onError(l)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}},Tf=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=new Vn(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},n,r)}parse(e){let t=[];for(let n=0;n<e.length;n++){let r=Pr.parse(e[n]);t.push(r)}return t}},Af=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=[],a=new Uo,c=new Vn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(s.withCredentials);let l=0;function u(h){c.load(e[h],function(d){let m=s.parse(d,!0);o[h]={width:m.width,height:m.height,format:m.format,mipmaps:m.mipmaps},l+=1,l===6&&(m.mipmapCount===1&&(a.minFilter=nn),a.image=o,a.format=m.format,a.needsUpdate=!0,t&&t(a))},n,r)}if(Array.isArray(e))for(let h=0,d=e.length;h<d;++h)u(h);else c.load(e,function(h){let d=s.parse(h,!0);if(d.isCubemap){let m=d.mipmaps.length/d.mipmapCount;for(let g=0;g<m;g++){o[g]={mipmaps:[]};for(let y=0;y<d.mipmapCount;y++)o[g].mipmaps.push(d.mipmaps[g*d.mipmapCount+y]),o[g].format=d.format,o[g].width=d.width,o[g].height=d.height}a.image=o}else a.image.width=d.width,a.image.height=d.height,a.mipmaps=d.mipmaps;d.mipmapCount===1&&(a.minFilter=nn),a.format=d.format,a.needsUpdate=!0,t&&t(a)},n,r);return a}},js=class extends rn{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=_r.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;let a=$a("img");function c(){u(),_r.add(e,this),t&&t(this),s.manager.itemEnd(e)}function l(h){u(),r&&r(h),s.manager.itemError(e),s.manager.itemEnd(e)}function u(){a.removeEventListener("load",c,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",l,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}},wf=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=new Vs;s.colorSpace=wt;let o=new js(this.manager);o.setCrossOrigin(this.crossOrigin),o.setPath(this.path);let a=0;function c(l){o.load(e[l],function(u){s.images[l]=u,a++,a===6&&(s.needsUpdate=!0,t&&t(s))},void 0,r)}for(let l=0;l<e.length;++l)c(l);return s}},Rf=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=new An,a=new Vn(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(e,function(c){let l;try{l=s.parse(c)}catch(u){if(r!==void 0)r(u);else{console.error(u);return}}l.image!==void 0?o.image=l.image:l.data!==void 0&&(o.image.width=l.width,o.image.height=l.height,o.image.data=l.data),o.wrapS=l.wrapS!==void 0?l.wrapS:En,o.wrapT=l.wrapT!==void 0?l.wrapT:En,o.magFilter=l.magFilter!==void 0?l.magFilter:nn,o.minFilter=l.minFilter!==void 0?l.minFilter:nn,o.anisotropy=l.anisotropy!==void 0?l.anisotropy:1,l.colorSpace!==void 0&&(o.colorSpace=l.colorSpace),l.flipY!==void 0&&(o.flipY=l.flipY),l.format!==void 0&&(o.format=l.format),l.type!==void 0&&(o.type=l.type),l.mipmaps!==void 0&&(o.mipmaps=l.mipmaps,o.minFilter=Mi),l.mipmapCount===1&&(o.minFilter=nn),l.generateMipmaps!==void 0&&(o.generateMipmaps=l.generateMipmaps),o.needsUpdate=!0,t&&t(o,l)},n,r),o}},qs=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=new Qt,o=new js(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},n,r),s}},ar=class extends St{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new Be(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}},pu=class extends ar{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(St.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Be(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}},Og=new nt,ab=new q,cb=new q,mu=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ce(512,512),this.map=null,this.mapPass=null,this.matrix=new nt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ws,this._frameExtents=new Ce(1,1),this._viewportCount=1,this._viewports=[new It(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,n=this.matrix;ab.setFromMatrixPosition(e.matrixWorld),t.position.copy(ab),cb.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(cb),t.updateMatrixWorld(),Og.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Og),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Og)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}},Wg=class extends mu{constructor(){super(new jt(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){let t=this.camera,n=Po*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(n!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=n,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}},Wo=class extends ar{constructor(e,t,n=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(St.DEFAULT_UP),this.updateMatrix(),this.target=new St,this.distance=n,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new Wg}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},lb=new nt,Tl=new q,Dg=new q,Xg=class extends mu{constructor(){super(new jt(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ce(4,2),this._viewportCount=6,this._viewports=[new It(2,1,1,1),new It(0,1,1,1),new It(3,1,1,1),new It(1,1,1,1),new It(3,0,1,1),new It(1,0,1,1)],this._cubeDirections=[new q(1,0,0),new q(-1,0,0),new q(0,0,1),new q(0,0,-1),new q(0,1,0),new q(0,-1,0)],this._cubeUps=[new q(0,1,0),new q(0,1,0),new q(0,1,0),new q(0,1,0),new q(0,0,1),new q(0,0,-1)]}updateMatrices(e,t=0){let n=this.camera,r=this.matrix,s=e.distance||n.far;s!==n.far&&(n.far=s,n.updateProjectionMatrix()),Tl.setFromMatrixPosition(e.matrixWorld),n.position.copy(Tl),Dg.copy(n.position),Dg.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Dg),n.updateMatrixWorld(),r.makeTranslation(-Tl.x,-Tl.y,-Tl.z),lb.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(lb)}},os=class extends ar{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new Xg}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},cr=class extends Lo{constructor(e=-1,t=1,n=1,r=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,s=n-e,o=n+e,a=r+t,c=r-t;if(this.view!==null&&this.view.enabled){let l=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=l*this.view.offsetX,o=s+l*this.view.width,a-=u*this.view.offsetY,c=a-u*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},Yg=class extends mu{constructor(){super(new cr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}},as=class extends ar{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(St.DEFAULT_UP),this.updateMatrix(),this.target=new St,this.shadow=new Yg}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},Xo=class extends ar{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}},gu=class extends ar{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){let t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}},yu=class{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new q)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){let n=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.282095),t.addScaledVector(o[1],.488603*r),t.addScaledVector(o[2],.488603*s),t.addScaledVector(o[3],.488603*n),t.addScaledVector(o[4],1.092548*(n*r)),t.addScaledVector(o[5],1.092548*(r*s)),t.addScaledVector(o[6],.315392*(3*s*s-1)),t.addScaledVector(o[7],1.092548*(n*s)),t.addScaledVector(o[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){let n=e.x,r=e.y,s=e.z,o=this.coefficients;return t.copy(o[0]).multiplyScalar(.886227),t.addScaledVector(o[1],2*.511664*r),t.addScaledVector(o[2],2*.511664*s),t.addScaledVector(o[3],2*.511664*n),t.addScaledVector(o[4],2*.429043*n*r),t.addScaledVector(o[5],2*.429043*r*s),t.addScaledVector(o[6],.743125*s*s-.247708),t.addScaledVector(o[7],2*.429043*n*s),t.addScaledVector(o[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){let n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){let n=e.x,r=e.y,s=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*s,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*s,t[6]=.315392*(3*s*s-1),t[7]=1.092548*n*s,t[8]=.546274*(n*n-r*r)}},xu=class extends ar{constructor(e=new yu,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){let t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}},vu=class i extends rn{constructor(e){super(e),this.textures={}}load(e,t,n,r){let s=this,o=new Vn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},n,r)}parse(e){let t=this.textures;function n(s){return t[s]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",s),t[s]}let r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new Be().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(let s in e.uniforms){let o=e.uniforms[s];switch(r.uniforms[s]={},o.type){case"t":r.uniforms[s].value=n(o.value);break;case"c":r.uniforms[s].value=new Be().setHex(o.value);break;case"v2":r.uniforms[s].value=new Ce().fromArray(o.value);break;case"v3":r.uniforms[s].value=new q().fromArray(o.value);break;case"v4":r.uniforms[s].value=new It().fromArray(o.value);break;case"m3":r.uniforms[s].value=new yt().fromArray(o.value);break;case"m4":r.uniforms[s].value=new nt().fromArray(o.value);break;default:r.uniforms[s].value=o.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(let s in e.extensions)r.extensions[s]=e.extensions[s];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let s=e.normalScale;Array.isArray(s)===!1&&(s=[s,s]),r.normalScale=new Ce().fromArray(s)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new Ce().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return i.createMaterialFromType(e)}static createMaterialFromType(e){let t={ShadowMaterial:ou,SpriteMaterial:Hs,RawShaderMaterial:Vo,ShaderMaterial:$t,PointsMaterial:Sr,MeshPhysicalMaterial:Dn,MeshStandardMaterial:Mn,MeshPhongMaterial:Ho,MeshToonMaterial:au,MeshNormalMaterial:Go,MeshLambertMaterial:cu,MeshDepthMaterial:uc,MeshDistanceMaterial:hc,MeshBasicMaterial:Ht,MeshMatcapMaterial:lu,LineDashedMaterial:uu,LineBasicMaterial:Xt,Material:cn};return new t[e]}},Ei=class{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch{return t}}static extractUrlBase(e){let t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}},bu=class extends ot{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}},_u=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=new Vn(s.manager);o.setPath(s.path),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(a){try{t(s.parse(JSON.parse(a)))}catch(c){r?r(c):console.error(c),s.manager.itemError(e)}},n,r)}parse(e){let t={},n={};function r(m,g){if(t[g]!==void 0)return t[g];let f=m.interleavedBuffers[g],p=s(m,f.buffer),v=Ya(f.type,p),b=new Mr(v,f.stride);return b.uuid=f.uuid,t[g]=b,b}function s(m,g){if(n[g]!==void 0)return n[g];let f=m.arrayBuffers[g],p=new Uint32Array(f).buffer;return n[g]=p,p}let o=e.isInstancedBufferGeometry?new bu:new ot,a=e.data.index;if(a!==void 0){let m=Ya(a.type,a.array);o.setIndex(new gt(m,1))}let c=e.data.attributes;for(let m in c){let g=c[m],y;if(g.isInterleavedBufferAttribute){let f=r(e.data,g.data);y=new ir(f,g.itemSize,g.offset,g.normalized)}else{let f=Ya(g.type,g.array),p=g.isInstancedBufferAttribute?Xi:gt;y=new p(f,g.itemSize,g.normalized)}g.name!==void 0&&(y.name=g.name),g.usage!==void 0&&y.setUsage(g.usage),o.setAttribute(m,y)}let l=e.data.morphAttributes;if(l)for(let m in l){let g=l[m],y=[];for(let f=0,p=g.length;f<p;f++){let v=g[f],b;if(v.isInterleavedBufferAttribute){let x=r(e.data,v.data);b=new ir(x,v.itemSize,v.offset,v.normalized)}else{let x=Ya(v.type,v.array);b=new gt(x,v.itemSize,v.normalized)}v.name!==void 0&&(b.name=v.name),y.push(b)}o.morphAttributes[m]=y}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);let h=e.data.groups||e.data.drawcalls||e.data.offsets;if(h!==void 0)for(let m=0,g=h.length;m!==g;++m){let y=h[m];o.addGroup(y.start,y.count,y.materialIndex)}let d=e.data.boundingSphere;if(d!==void 0){let m=new q;d.center!==void 0&&m.fromArray(d.center),o.boundingSphere=new qt(m,d.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}},Cf=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=this.path===""?Ei.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||o;let a=new Vn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){let l=null;try{l=JSON.parse(c)}catch(h){r!==void 0&&r(h),console.error("THREE:ObjectLoader: Can't parse "+e+".",h.message);return}let u=l.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),console.error("THREE.ObjectLoader: Can't load "+e);return}s.parse(l,t)},n,r)}async loadAsync(e,t){let n=this,r=this.path===""?Ei.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;let s=new Vn(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials);let o=await s.loadAsync(e,t),a=JSON.parse(o),c=a.metadata;if(c===void 0||c.type===void 0||c.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await n.parseAsync(a)}parse(e,t){let n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),s=this.parseGeometries(e.geometries,r),o=this.parseImages(e.images,function(){t!==void 0&&t(l)}),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,s,c,a,n),u=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,u),this.bindLightTargets(l),t!==void 0){let h=!1;for(let d in o)if(o[d].data instanceof HTMLImageElement){h=!0;break}h===!1&&t(l)}return l}async parseAsync(e){let t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),s=await this.parseImagesAsync(e.images),o=this.parseTextures(e.textures,s),a=this.parseMaterials(e.materials,o),c=this.parseObject(e.object,r,a,o,t),l=this.parseSkeletons(e.skeletons,c);return this.bindSkeletons(c,l),this.bindLightTargets(c),c}parseShapes(e){let t={};if(e!==void 0)for(let n=0,r=e.length;n<r;n++){let s=new Fi().fromJSON(e[n]);t[s.uuid]=s}return t}parseSkeletons(e,t){let n={},r={};if(t.traverse(function(s){s.isBone&&(r[s.uuid]=s)}),e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=new Fo().fromJSON(e[s],r);n[a.uuid]=a}return n}parseGeometries(e,t){let n={};if(e!==void 0){let r=new _u;for(let s=0,o=e.length;s<o;s++){let a,c=e[s];switch(c.type){case"BufferGeometry":case"InstancedBufferGeometry":a=r.parse(c);break;default:c.type in ob?a=ob[c.type].fromJSON(c,t):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${c.type}"`)}a.uuid=c.uuid,c.name!==void 0&&(a.name=c.name),c.userData!==void 0&&(a.userData=c.userData),n[c.uuid]=a}}return n}parseMaterials(e,t){let n={},r={};if(e!==void 0){let s=new vu;s.setTextures(t);for(let o=0,a=e.length;o<a;o++){let c=e[o];n[c.uuid]===void 0&&(n[c.uuid]=s.parse(c)),r[c.uuid]=n[c.uuid]}}return r}parseAnimations(e){let t={};if(e!==void 0)for(let n=0;n<e.length;n++){let r=e[n],s=Pr.parse(r);t[s.uuid]=s}return t}parseImages(e,t){let n=this,r={},s;function o(c){return n.manager.itemStart(c),s.load(c,function(){n.manager.itemEnd(c)},void 0,function(){n.manager.itemError(c),n.manager.itemEnd(c)})}function a(c){if(typeof c=="string"){let l=c,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(l)?l:n.resourcePath+l;return o(u)}else return c.data?{data:Ya(c.type,c.data),width:c.width,height:c.height}:null}if(e!==void 0&&e.length>0){let c=new pc(t);s=new js(c),s.setCrossOrigin(this.crossOrigin);for(let l=0,u=e.length;l<u;l++){let h=e[l],d=h.url;if(Array.isArray(d)){let m=[];for(let g=0,y=d.length;g<y;g++){let f=d[g],p=a(f);p!==null&&(p instanceof HTMLImageElement?m.push(p):m.push(new An(p.data,p.width,p.height)))}r[h.uuid]=new br(m)}else{let m=a(h.url);r[h.uuid]=new br(m)}}}return r}async parseImagesAsync(e){let t=this,n={},r;async function s(o){if(typeof o=="string"){let a=o,c=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(a)?a:t.resourcePath+a;return await r.loadAsync(c)}else return o.data?{data:Ya(o.type,o.data),width:o.width,height:o.height}:null}if(e!==void 0&&e.length>0){r=new js(this.manager),r.setCrossOrigin(this.crossOrigin);for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.url;if(Array.isArray(l)){let u=[];for(let h=0,d=l.length;h<d;h++){let m=l[h],g=await s(m);g!==null&&(g instanceof HTMLImageElement?u.push(g):u.push(new An(g.data,g.width,g.height)))}n[c.uuid]=new br(u)}else{let u=await s(c.url);n[c.uuid]=new br(u)}}}return n}parseTextures(e,t){function n(s,o){return typeof s=="number"?s:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",s),o[s])}let r={};if(e!==void 0)for(let s=0,o=e.length;s<o;s++){let a=e[s];a.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',a.uuid),t[a.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",a.image);let c=t[a.image],l=c.data,u;Array.isArray(l)?(u=new Vs,l.length===6&&(u.needsUpdate=!0)):(l&&l.data?u=new An:u=new Qt,l&&(u.needsUpdate=!0)),u.source=c,u.uuid=a.uuid,a.name!==void 0&&(u.name=a.name),a.mapping!==void 0&&(u.mapping=n(a.mapping,eA)),a.channel!==void 0&&(u.channel=a.channel),a.offset!==void 0&&u.offset.fromArray(a.offset),a.repeat!==void 0&&u.repeat.fromArray(a.repeat),a.center!==void 0&&u.center.fromArray(a.center),a.rotation!==void 0&&(u.rotation=a.rotation),a.wrap!==void 0&&(u.wrapS=n(a.wrap[0],ub),u.wrapT=n(a.wrap[1],ub)),a.format!==void 0&&(u.format=a.format),a.internalFormat!==void 0&&(u.internalFormat=a.internalFormat),a.type!==void 0&&(u.type=a.type),a.colorSpace!==void 0&&(u.colorSpace=a.colorSpace),a.minFilter!==void 0&&(u.minFilter=n(a.minFilter,hb)),a.magFilter!==void 0&&(u.magFilter=n(a.magFilter,hb)),a.anisotropy!==void 0&&(u.anisotropy=a.anisotropy),a.flipY!==void 0&&(u.flipY=a.flipY),a.generateMipmaps!==void 0&&(u.generateMipmaps=a.generateMipmaps),a.premultiplyAlpha!==void 0&&(u.premultiplyAlpha=a.premultiplyAlpha),a.unpackAlignment!==void 0&&(u.unpackAlignment=a.unpackAlignment),a.compareFunction!==void 0&&(u.compareFunction=a.compareFunction),a.userData!==void 0&&(u.userData=a.userData),r[a.uuid]=u}return r}parseObject(e,t,n,r,s){let o;function a(d){return t[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",d),t[d]}function c(d){if(d!==void 0){if(Array.isArray(d)){let m=[];for(let g=0,y=d.length;g<y;g++){let f=d[g];n[f]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",f),m.push(n[f])}return m}return n[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",d),n[d]}}function l(d){return r[d]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",d),r[d]}let u,h;switch(e.type){case"Scene":o=new oi,e.background!==void 0&&(Number.isInteger(e.background)?o.background=new Be(e.background):o.background=l(e.background)),e.environment!==void 0&&(o.environment=l(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?o.fog=new kl(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(o.fog=new Ul(e.fog.color,e.fog.density)),e.fog.name!==""&&(o.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(o.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(o.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&o.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(o.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&o.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":o=new jt(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(o.focus=e.focus),e.zoom!==void 0&&(o.zoom=e.zoom),e.filmGauge!==void 0&&(o.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(o.filmOffset=e.filmOffset),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"OrthographicCamera":o=new cr(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(o.zoom=e.zoom),e.view!==void 0&&(o.view=Object.assign({},e.view));break;case"AmbientLight":o=new Xo(e.color,e.intensity);break;case"DirectionalLight":o=new as(e.color,e.intensity),o.target=e.target||"";break;case"PointLight":o=new os(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":o=new gu(e.color,e.intensity,e.width,e.height);break;case"SpotLight":o=new Wo(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),o.target=e.target||"";break;case"HemisphereLight":o=new pu(e.color,e.groundColor,e.intensity);break;case"LightProbe":o=new xu().fromJSON(e);break;case"SkinnedMesh":u=a(e.geometry),h=c(e.material),o=new Do(u,h),e.bindMode!==void 0&&(o.bindMode=e.bindMode),e.bindMatrix!==void 0&&o.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(o.skeleton=e.skeleton);break;case"Mesh":u=a(e.geometry),h=c(e.material),o=new ct(u,h);break;case"InstancedMesh":u=a(e.geometry),h=c(e.material);let d=e.count,m=e.instanceMatrix,g=e.instanceColor;o=new $r(u,h,d),o.instanceMatrix=new Xi(new Float32Array(m.array),16),g!==void 0&&(o.instanceColor=new Xi(new Float32Array(g.array),g.itemSize));break;case"BatchedMesh":u=a(e.geometry),h=c(e.material),o=new zl(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,h),o.geometry=u,o.perObjectFrustumCulled=e.perObjectFrustumCulled,o.sortObjects=e.sortObjects,o._drawRanges=e.drawRanges,o._reservedRanges=e.reservedRanges,o._visibility=e.visibility,o._active=e.active,o._bounds=e.bounds.map(y=>{let f=new zt;f.min.fromArray(y.boxMin),f.max.fromArray(y.boxMax);let p=new qt;return p.radius=y.sphereRadius,p.center.fromArray(y.sphereCenter),{boxInitialized:y.boxInitialized,box:f,sphereInitialized:y.sphereInitialized,sphere:p}}),o._maxInstanceCount=e.maxInstanceCount,o._maxVertexCount=e.maxVertexCount,o._maxIndexCount=e.maxIndexCount,o._geometryInitialized=e.geometryInitialized,o._geometryCount=e.geometryCount,o._matricesTexture=l(e.matricesTexture.uuid),e.colorsTexture!==void 0&&(o._colorsTexture=l(e.colorsTexture.uuid));break;case"LOD":o=new Bl;break;case"Line":o=new ai(a(e.geometry),c(e.material));break;case"LineLoop":o=new es(a(e.geometry),c(e.material));break;case"LineSegments":o=new ln(a(e.geometry),c(e.material));break;case"PointCloud":case"Points":o=new ts(a(e.geometry),c(e.material));break;case"Sprite":o=new Oo(c(e.material));break;case"Group":o=new Dt;break;case"Bone":o=new Gs;break;default:o=new St}if(o.uuid=e.uuid,e.name!==void 0&&(o.name=e.name),e.matrix!==void 0?(o.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(o.matrixAutoUpdate=e.matrixAutoUpdate),o.matrixAutoUpdate&&o.matrix.decompose(o.position,o.quaternion,o.scale)):(e.position!==void 0&&o.position.fromArray(e.position),e.rotation!==void 0&&o.rotation.fromArray(e.rotation),e.quaternion!==void 0&&o.quaternion.fromArray(e.quaternion),e.scale!==void 0&&o.scale.fromArray(e.scale)),e.up!==void 0&&o.up.fromArray(e.up),e.castShadow!==void 0&&(o.castShadow=e.castShadow),e.receiveShadow!==void 0&&(o.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(o.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(o.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(o.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(o.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&o.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(o.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(o.visible=e.visible),e.frustumCulled!==void 0&&(o.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(o.renderOrder=e.renderOrder),e.userData!==void 0&&(o.userData=e.userData),e.layers!==void 0&&(o.layers.mask=e.layers),e.children!==void 0){let d=e.children;for(let m=0;m<d.length;m++)o.add(this.parseObject(d[m],t,n,r,s))}if(e.animations!==void 0){let d=e.animations;for(let m=0;m<d.length;m++){let g=d[m];o.animations.push(s[g])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(o.autoUpdate=e.autoUpdate);let d=e.levels;for(let m=0;m<d.length;m++){let g=d[m],y=o.getObjectByProperty("uuid",g.object);y!==void 0&&o.addLevel(y,g.distance,g.hysteresis)}}return o}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){let r=t[n.skeleton];r===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(r,n.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){let n=t.target,r=e.getObjectByProperty("uuid",n);r!==void 0?t.target=r:t.target=new St}})}},eA={UVMapping:zu,CubeReflectionMapping:Nr,CubeRefractionMapping:us,EquirectangularReflectionMapping:_c,EquirectangularRefractionMapping:Ec,CubeUVReflectionMapping:Ko},ub={RepeatWrapping:gn,ClampToEdgeWrapping:En,MirroredRepeatWrapping:ks},hb={NearestFilter:Jt,NearestMipmapNearestFilter:Mc,NearestMipmapLinearFilter:hs,LinearFilter:nn,LinearMipmapNearestFilter:Zs,LinearMipmapLinearFilter:Mi},mc=class extends rn{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);let s=this,o=_r.get(e);if(o!==void 0){if(s.manager.itemStart(e),o.then){o.then(l=>{t&&t(l),s.manager.itemEnd(e)}).catch(l=>{r&&r(l)});return}return setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o}let a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader;let c=fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){return _r.add(e,l),t&&t(l),s.manager.itemEnd(e),l}).catch(function(l){r&&r(l),_r.remove(e),s.manager.itemError(e),s.manager.itemEnd(e)});_r.add(e,c),s.manager.itemStart(e)}},ef,gc=class{static getContext(){return ef===void 0&&(ef=new(window.AudioContext||window.webkitAudioContext)),ef}static setContext(e){ef=e}},Pf=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=new Vn(this.manager);o.setResponseType("arraybuffer"),o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{let l=c.slice(0);gc.getContext().decodeAudioData(l,function(h){t(h)}).catch(a)}catch(l){a(l)}},n,r);function a(c){r?r(c):console.error(c),s.manager.itemError(e)}}},db=new nt,fb=new nt,Mo=new nt,If=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new jt,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new jt,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Mo.copy(e.projectionMatrix);let r=t.eyeSep/2,s=r*t.near/t.focus,o=t.near*Math.tan(Co*t.fov*.5)/t.zoom,a,c;fb.elements[12]=-r,db.elements[12]=r,a=-o*t.aspect+s,c=o*t.aspect+s,Mo.elements[0]=2*t.near/(c-a),Mo.elements[8]=(c+a)/(c-a),this.cameraL.projectionMatrix.copy(Mo),a=-o*t.aspect-s,c=o*t.aspect-s,Mo.elements[0]=2*t.near/(c-a),Mo.elements[8]=(c+a)/(c-a),this.cameraR.projectionMatrix.copy(Mo)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(fb),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(db)}},Eu=class extends jt{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},Yo=class{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=pb(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=pb();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}};function pb(){return performance.now()}var So=new q,mb=new Zt,tA=new q,To=new q,Nf=class extends St{constructor(){super(),this.type="AudioListener",this.context=gc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Yo}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(So,mb,tA),To.set(0,0,-1).applyQuaternion(mb),t.positionX){let r=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(So.x,r),t.positionY.linearRampToValueAtTime(So.y,r),t.positionZ.linearRampToValueAtTime(So.z,r),t.forwardX.linearRampToValueAtTime(To.x,r),t.forwardY.linearRampToValueAtTime(To.y,r),t.forwardZ.linearRampToValueAtTime(To.z,r),t.upX.linearRampToValueAtTime(n.x,r),t.upY.linearRampToValueAtTime(n.y,r),t.upZ.linearRampToValueAtTime(n.z,r)}else t.setPosition(So.x,So.y,So.z),t.setOrientation(To.x,To.y,To.z,n.x,n.y,n.z)}},Mu=class extends St{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(e=0){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(console.warn("THREE.Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}},Ao=new q,gb=new Zt,nA=new q,wo=new q,Lf=class extends Mu{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){super.connect(),this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Ao,gb,nA),wo.set(0,0,1).applyQuaternion(gb);let t=this.panner;if(t.positionX){let n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Ao.x,n),t.positionY.linearRampToValueAtTime(Ao.y,n),t.positionZ.linearRampToValueAtTime(Ao.z,n),t.orientationX.linearRampToValueAtTime(wo.x,n),t.orientationY.linearRampToValueAtTime(wo.y,n),t.orientationZ.linearRampToValueAtTime(wo.z,n)}else t.setPosition(Ao.x,Ao.y,Ao.z),t.setOrientation(wo.x,wo.y,wo.z)}},Of=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0,t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}},Su=class{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,s,o;switch(t){case"quaternion":r=this._slerp,s=this._slerpAdditive,o=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,s=this._select,o=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,s=this._lerpAdditive,o=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=s,this._setIdentity=o,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){let n=this.buffer,r=this.valueSize,s=e*r+r,o=this.cumulativeWeight;if(o===0){for(let a=0;a!==r;++a)n[s+a]=n[a];o=t}else{o+=t;let a=t/o;this._mixBufferRegion(n,s,0,a,r)}this.cumulativeWeight=o}accumulateAdditive(e){let t=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){let t=this.valueSize,n=this.buffer,r=e*t+t,s=this.cumulativeWeight,o=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){let c=t*this._origIndex;this._mixBufferRegion(n,r,c,1-s,t)}o>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let c=t,l=t+t;c!==l;++c)if(n[c]!==n[c+t]){a.setValue(n,r);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let s=n,o=r;s!==o;++s)t[s]=t[r+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){let e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,r,s){if(r>=.5)for(let o=0;o!==s;++o)e[t+o]=e[n+o]}_slerp(e,t,n,r){Zt.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,s){let o=this._workIndex*s;Zt.multiplyQuaternionsFlat(e,o,e,t,e,n),Zt.slerpFlat(e,t,e,t,e,o,r)}_lerp(e,t,n,r,s){let o=1-r;for(let a=0;a!==s;++a){let c=t+a;e[c]=e[c]*o+e[n+a]*r}}_lerpAdditive(e,t,n,r,s){for(let o=0;o!==s;++o){let a=t+o;e[a]=e[a]+e[n+o]*r}}},F0="\\[\\]\\.:\\/",iA=new RegExp("["+F0+"]","g"),U0="[^"+F0+"]",rA="[^"+F0.replace("\\.","")+"]",sA=/((?:WC+[\/:])*)/.source.replace("WC",U0),oA=/(WCOD+)?/.source.replace("WCOD",rA),aA=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",U0),cA=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",U0),lA=new RegExp("^"+sA+oA+aA+cA+"$"),uA=["material","materials","bones","map"],jg=class{constructor(e,t,n){let r=n||Ut.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();let n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){let n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=n.length;r!==s;++r)n[r].setValue(e,t)}bind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){let e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},Ut=class i{constructor(e,t,n){this.path=t,this.parsedPath=n||i.parseTrackName(t),this.node=i.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new i.Composite(e,t,n):new i(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(iA,"")}static parseTrackName(e){let t=lA.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){let s=n.nodeName.substring(r+1);uA.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){let n=function(s){for(let o=0;o<s.length;o++){let a=s[o];if(a.name===t||a.uuid===t)return a;let c=n(a.children);if(c)return c}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){let n=this.resolvedProperty;for(let r=0,s=n.length;r!==s;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node,t=this.parsedPath,n=t.objectName,r=t.propertyName,s=t.propertyIndex;if(e||(e=i.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let u=0;u<e.length;u++)if(e[u].name===l){l=u;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(l!==void 0){if(e[l]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[l]}}let o=e[r];if(o===void 0){let l=t.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+l+"."+r+" but it wasn't found.",e);return}let a=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[s]!==void 0&&(s=e.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=r;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Ut.Composite=jg;Ut.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Ut.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Ut.prototype.GetterByBindingType=[Ut.prototype._getValue_direct,Ut.prototype._getValue_array,Ut.prototype._getValue_arrayElement,Ut.prototype._getValue_toArray];Ut.prototype.SetterByBindingTypeAndVersioning=[[Ut.prototype._setValue_direct,Ut.prototype._setValue_direct_setNeedsUpdate,Ut.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Ut.prototype._setValue_array,Ut.prototype._setValue_array_setNeedsUpdate,Ut.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Ut.prototype._setValue_arrayElement,Ut.prototype._setValue_arrayElement_setNeedsUpdate,Ut.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Ut.prototype._setValue_fromArray,Ut.prototype._setValue_fromArray_setNeedsUpdate,Ut.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Df=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Di(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;let e={};this._indicesByUUID=e;for(let n=0,r=arguments.length;n!==r;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};let t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){let e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,s=this._bindings,o=s.length,a,c=e.length,l=this.nCachedObjects_;for(let u=0,h=arguments.length;u!==h;++u){let d=arguments[u],m=d.uuid,g=t[m];if(g===void 0){g=c++,t[m]=g,e.push(d);for(let y=0,f=o;y!==f;++y)s[y].push(new Ut(d,n[y],r[y]))}else if(g<l){a=e[g];let y=--l,f=e[y];t[f.uuid]=g,e[g]=f,t[m]=y,e[y]=d;for(let p=0,v=o;p!==v;++p){let b=s[p],x=b[y],_=b[g];b[g]=x,_===void 0&&(_=new Ut(d,n[p],r[p])),b[y]=_}}else e[g]!==a&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,s=this.nCachedObjects_;for(let o=0,a=arguments.length;o!==a;++o){let c=arguments[o],l=c.uuid,u=t[l];if(u!==void 0&&u>=s){let h=s++,d=e[h];t[d.uuid]=u,e[u]=d,t[l]=h,e[h]=c;for(let m=0,g=r;m!==g;++m){let y=n[m],f=y[h],p=y[u];y[u]=f,y[h]=p}}}this.nCachedObjects_=s}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,s=this.nCachedObjects_,o=e.length;for(let a=0,c=arguments.length;a!==c;++a){let l=arguments[a],u=l.uuid,h=t[u];if(h!==void 0)if(delete t[u],h<s){let d=--s,m=e[d],g=--o,y=e[g];t[m.uuid]=h,e[h]=m,t[y.uuid]=d,e[d]=y,e.pop();for(let f=0,p=r;f!==p;++f){let v=n[f],b=v[d],x=v[g];v[h]=b,v[d]=x,v.pop()}}else{let d=--o,m=e[d];d>0&&(t[m.uuid]=h),e[h]=m,e.pop();for(let g=0,y=r;g!==y;++g){let f=n[g];f[h]=f[d],f.pop()}}}this.nCachedObjects_=s}subscribe_(e,t){let n=this._bindingsIndicesByPath,r=n[e],s=this._bindings;if(r!==void 0)return s[r];let o=this._paths,a=this._parsedPaths,c=this._objects,l=c.length,u=this.nCachedObjects_,h=new Array(l);r=s.length,n[e]=r,o.push(e),a.push(t),s.push(h);for(let d=u,m=c.length;d!==m;++d){let g=c[d];h[d]=new Ut(g,e,t)}return h}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){let r=this._paths,s=this._parsedPaths,o=this._bindings,a=o.length-1,c=o[a],l=e[a];t[l]=n,o[n]=c,o.pop(),s[n]=s[a],s.pop(),r[n]=r[a],r.pop()}}},Tu=class{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;let s=t.tracks,o=s.length,a=new Array(o),c={endingStart:Ls,endingEnd:Ls};for(let l=0;l!==o;++l){let u=s[l].createInterpolant(null);a[l]=u,u.settings=c}this._interpolantSettings=c,this._interpolants=a,this._propertyBindings=new Array(o),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=y0,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){let r=this._clip.duration,s=e._clip.duration,o=s/r,a=r/s;e.warp(1,o,t),this.warp(a,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let r=this._mixer,s=r.time,o=this.timeScale,a=this._timeScaleInterpolant;a===null&&(a=r._lendControlInterpolant(),this._timeScaleInterpolant=a);let c=a.parameterPositions,l=a.sampleValues;return c[0]=s,c[1]=s+n,l[0]=e/o,l[1]=t/o,this}stopWarping(){let e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled){this._updateWeight(e);return}let s=this._startTime;if(s!==null){let c=(e-s)*n;c<0||n===0?t=0:(this._startTime=null,t=n*c)}t*=this._updateTimeScale(e);let o=this._updateTime(t),a=this._updateWeight(e);if(a>0){let c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case bp:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulateAdditive(a);break;case vh:default:for(let u=0,h=c.length;u!==h;++u)c[u].evaluate(o),l[u].accumulate(r,a)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;if(n!==null){let r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,r=this.time+e,s=this._loopCount,o=n===x0;if(e===0)return s===-1?r:o&&(s&1)===1?t-r:r;if(n===g0){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(s===-1&&(e>=0?(s=0,this._setEndings(!0,this.repetitions===0,o)):this._setEndings(this.repetitions===0,!0,o)),r>=t||r<0){let a=Math.floor(r/t);r-=t*a,s+=Math.abs(a);let c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(c===1){let l=e<0;this._setEndings(l,!l,o)}else this._setEndings(!1,!1,o);this._loopCount=s,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:a})}}else this.time=r;if(o&&(s&1)===1)return t-r}return r}_setEndings(e,t,n){let r=this._interpolantSettings;n?(r.endingStart=Os,r.endingEnd=Os):(e?r.endingStart=this.zeroSlopeAtStart?Os:Ls:r.endingStart=Ka,t?r.endingEnd=this.zeroSlopeAtEnd?Os:Ls:r.endingEnd=Ka)}_scheduleFading(e,t,n){let r=this._mixer,s=r.time,o=this._weightInterpolant;o===null&&(o=r._lendControlInterpolant(),this._weightInterpolant=o);let a=o.parameterPositions,c=o.sampleValues;return a[0]=s,c[0]=t,a[1]=s+e,c[1]=n,this}},hA=new Float32Array(1),Ff=class extends ki{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let n=e._localRoot||this._root,r=e._clip.tracks,s=r.length,o=e._propertyBindings,a=e._interpolants,c=n.uuid,l=this._bindingsByRootAndName,u=l[c];u===void 0&&(u={},l[c]=u);for(let h=0;h!==s;++h){let d=r[h],m=d.name,g=u[m];if(g!==void 0)++g.referenceCount,o[h]=g;else{if(g=o[h],g!==void 0){g._cacheIndex===null&&(++g.referenceCount,this._addInactiveBinding(g,c,m));continue}let y=t&&t._propertyBindings[h].binding.parsedPath;g=new Su(Ut.create(n,m,y),d.ValueTypeName,d.getValueSize()),++g.referenceCount,this._addInactiveBinding(g,c,m),o[h]=g}a[h].resultBuffer=g.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){let n=(e._localRoot||this._root).uuid,r=e._clip.uuid,s=this._actionsByClip[r];this._bindAction(e,s&&s.knownActions[0]),this._addInactiveAction(e,r,n)}let t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){let s=t[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){let s=t[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){let r=this._actions,s=this._actionsByClip,o=s[t];if(o===void 0)o={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,s[t]=o;else{let a=o.knownActions;e._byClipCacheIndex=a.length,a.push(e)}e._cacheIndex=r.length,r.push(e),o.actionByRoot[n]=e}_removeInactiveAction(e){let t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;let s=e._clip.uuid,o=this._actionsByClip,a=o[s],c=a.knownActions,l=c[c.length-1],u=e._byClipCacheIndex;l._byClipCacheIndex=u,c[u]=l,c.pop(),e._byClipCacheIndex=null;let h=a.actionByRoot,d=(e._localRoot||this._root).uuid;delete h[d],c.length===0&&delete o[s],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){let t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){let s=t[n];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(e){let t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackAction(e){let t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_addInactiveBinding(e,t,n){let r=this._bindingsByRootAndName,s=this._bindings,o=r[t];o===void 0&&(o={},r[t]=o),o[n]=e,e._cacheIndex=s.length,s.push(e)}_removeInactiveBinding(e){let t=this._bindings,n=e.binding,r=n.rootNode.uuid,s=n.path,o=this._bindingsByRootAndName,a=o[r],c=t[t.length-1],l=e._cacheIndex;c._cacheIndex=l,t[l]=c,t.pop(),delete a[s],Object.keys(a).length===0&&delete o[r]}_lendBinding(e){let t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_takeBackBinding(e){let t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,s=t[r];e._cacheIndex=r,t[r]=e,s._cacheIndex=n,t[n]=s}_lendControlInterpolant(){let e=this._controlInterpolants,t=this._nActiveControlInterpolants++,n=e[t];return n===void 0&&(n=new dc(new Float32Array(2),new Float32Array(2),1,hA),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){let t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,s=t[r];e.__cacheIndex=r,t[r]=e,s.__cacheIndex=n,t[n]=s}clipAction(e,t,n){let r=t||this._root,s=r.uuid,o=typeof e=="string"?Pr.findByName(r,e):e,a=o!==null?o.uuid:e,c=this._actionsByClip[a],l=null;if(n===void 0&&(o!==null?n=o.blendMode:n=vh),c!==void 0){let h=c.actionByRoot[s];if(h!==void 0&&h.blendMode===n)return h;l=c.knownActions[0],o===null&&(o=l._clip)}if(o===null)return null;let u=new Tu(this,o,t,n);return this._bindAction(u,l),this._addInactiveAction(u,a,s),u}existingAction(e,t){let n=t||this._root,r=n.uuid,s=typeof e=="string"?Pr.findByName(n,e):e,o=s?s.uuid:e,a=this._actionsByClip[o];return a!==void 0&&a.actionByRoot[r]||null}stopAllAction(){let e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,r=this.time+=e,s=Math.sign(e),o=this._accuIndex^=1;for(let l=0;l!==n;++l)t[l]._update(r,e,s,o);let a=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)a[l].apply(o);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){let t=this._actions,n=e.uuid,r=this._actionsByClip,s=r[n];if(s!==void 0){let o=s.knownActions;for(let a=0,c=o.length;a!==c;++a){let l=o[a];this._deactivateAction(l);let u=l._cacheIndex,h=t[t.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,h._cacheIndex=u,t[u]=h,t.pop(),this._removeInactiveBindingsForAction(l)}delete r[n]}}uncacheRoot(e){let t=e.uuid,n=this._actionsByClip;for(let o in n){let a=n[o].actionByRoot,c=a[t];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}let r=this._bindingsByRootAndName,s=r[t];if(s!==void 0)for(let o in s){let a=s[o];a.restoreOriginalState(),this._removeInactiveBinding(a)}}uncacheAction(e,t){let n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}},Uf=class i{constructor(e){this.value=e}clone(){return new i(this.value.clone===void 0?this.value:this.value.clone())}},dA=0,kf=class extends ki{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:dA++}),this.name="",this.usage=Ja,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){let t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;let t=e.uniforms;this.uniforms.length=0;for(let n=0,r=t.length;n<r;n++){let s=Array.isArray(t[n])?t[n]:[t[n]];for(let o=0;o<s.length;o++)this.uniforms.push(s[o].clone())}return this}clone(){return new this.constructor().copy(this)}},Bf=class extends Mr{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){let t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){let t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},zf=class{constructor(e,t,n,r,s){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=s,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},yb=new nt,lr=class{constructor(e,t,n=0,r=1/0){this.ray=new nr(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new No,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return yb.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(yb),this}intersectObject(e,t=!0,n=[]){return qg(e,this,n,t),n.sort(xb),n}intersectObjects(e,t=!0,n=[]){for(let r=0,s=e.length;r<s;r++)qg(e[r],this,n,t);return n.sort(xb),n}};function xb(i,e){return i.distance-e.distance}function qg(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){let s=i.children;for(let o=0,a=s.length;o<a;o++)qg(s[o],e,t,!0)}}var jo=class{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=mt(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(mt(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}},Vf=class{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}},Hf=class i{constructor(e,t,n,r){i.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){let s=this.elements;return s[0]=e,s[2]=t,s[1]=n,s[3]=r,this}},vb=new Ce,Gf=class{constructor(e=new Ce(1/0,1/0),t=new Ce(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),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=vb.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}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=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(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}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}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}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))}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}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vb).distanceTo(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}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)}},bb=new q,tf=new q,Wf=class{constructor(e=new q,t=new q){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){bb.subVectors(e,this.start),tf.subVectors(this.end,this.start);let n=tf.dot(tf),s=tf.dot(bb)/n;return t&&(s=mt(s,0,1)),s}closestPointToPoint(e,t,n){let r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}},_b=new q,Xf=class extends St{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";let n=new ot,r=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let o=0,a=1,c=32;o<c;o++,a++){let l=o/c*Math.PI*2,u=a/c*Math.PI*2;r.push(Math.cos(l),Math.sin(l),1,Math.cos(u),Math.sin(u),1)}n.setAttribute("position",new Ve(r,3));let s=new Xt({fog:!1,toneMapped:!1});this.cone=new ln(n,s),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),_b.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(_b),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},Is=new q,nf=new nt,Fg=new nt,Yf=class extends ln{constructor(e){let t=g_(e),n=new ot,r=[],s=[],o=new Be(0,0,1),a=new Be(0,1,0);for(let l=0;l<t.length;l++){let u=t[l];u.parent&&u.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),s.push(o.r,o.g,o.b),s.push(a.r,a.g,a.b))}n.setAttribute("position",new Ve(r,3)),n.setAttribute("color",new Ve(s,3));let c=new Xt({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,c),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){let t=this.bones,n=this.geometry,r=n.getAttribute("position");Fg.copy(this.root.matrixWorld).invert();for(let s=0,o=0;s<t.length;s++){let a=t[s];a.parent&&a.parent.isBone&&(nf.multiplyMatrices(Fg,a.matrixWorld),Is.setFromMatrixPosition(nf),r.setXYZ(o,Is.x,Is.y,Is.z),nf.multiplyMatrices(Fg,a.parent.matrixWorld),Is.setFromMatrixPosition(nf),r.setXYZ(o+1,Is.x,Is.y,Is.z),o+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}};function g_(i){let e=[];i.isBone===!0&&e.push(i);for(let t=0;t<i.children.length;t++)e.push.apply(e,g_(i.children[t]));return e}var jf=class extends ct{constructor(e,t,n){let r=new bi(t,4,2),s=new Ht({wireframe:!0,fog:!1,toneMapped:!1});super(r,s),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},fA=new q,Eb=new Be,Mb=new Be,qf=class extends St{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";let r=new lc(t);r.rotateY(Math.PI*.5),this.material=new Ht({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);let s=r.getAttribute("position"),o=new Float32Array(s.count*3);r.setAttribute("color",new gt(o,3)),this.add(new ct(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){let e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{let t=e.geometry.getAttribute("color");Eb.copy(this.light.color),Mb.copy(this.light.groundColor);for(let n=0,r=t.count;n<r;n++){let s=n<r/2?Eb:Mb;t.setXYZ(n,s.r,s.g,s.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(fA.setFromMatrixPosition(this.light.matrixWorld).negate())}},Kf=class extends ln{constructor(e=10,t=10,n=4473924,r=8947848){n=new Be(n),r=new Be(r);let s=t/2,o=e/t,a=e/2,c=[],l=[];for(let d=0,m=0,g=-a;d<=t;d++,g+=o){c.push(-a,0,g,a,0,g),c.push(g,0,-a,g,0,a);let y=d===s?n:r;y.toArray(l,m),m+=3,y.toArray(l,m),m+=3,y.toArray(l,m),m+=3,y.toArray(l,m),m+=3}let u=new ot;u.setAttribute("position",new Ve(c,3)),u.setAttribute("color",new Ve(l,3));let h=new Xt({vertexColors:!0,toneMapped:!1});super(u,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Zf=class extends ln{constructor(e=10,t=16,n=8,r=64,s=4473924,o=8947848){s=new Be(s),o=new Be(o);let a=[],c=[];if(t>1)for(let h=0;h<t;h++){let d=h/t*(Math.PI*2),m=Math.sin(d)*e,g=Math.cos(d)*e;a.push(0,0,0),a.push(m,0,g);let y=h&1?s:o;c.push(y.r,y.g,y.b),c.push(y.r,y.g,y.b)}for(let h=0;h<n;h++){let d=h&1?s:o,m=e-e/n*h;for(let g=0;g<r;g++){let y=g/r*(Math.PI*2),f=Math.sin(y)*m,p=Math.cos(y)*m;a.push(f,0,p),c.push(d.r,d.g,d.b),y=(g+1)/r*(Math.PI*2),f=Math.sin(y)*m,p=Math.cos(y)*m,a.push(f,0,p),c.push(d.r,d.g,d.b)}}let l=new ot;l.setAttribute("position",new Ve(a,3)),l.setAttribute("color",new Ve(c,3));let u=new Xt({vertexColors:!0,toneMapped:!1});super(l,u),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},Sb=new q,rf=new q,Tb=new q,Jf=class extends St{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new ot;r.setAttribute("position",new Ve([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));let s=new Xt({fog:!1,toneMapped:!1});this.lightPlane=new ai(r,s),this.add(this.lightPlane),r=new ot,r.setAttribute("position",new Ve([0,0,0,0,0,1],3)),this.targetLine=new ai(r,s),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Sb.setFromMatrixPosition(this.light.matrixWorld),rf.setFromMatrixPosition(this.light.target.matrixWorld),Tb.subVectors(rf,Sb),this.lightPlane.lookAt(rf),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(rf),this.targetLine.scale.z=Tb.length()}},sf=new q,fn=new Lo,Qf=class extends ln{constructor(e){let t=new ot,n=new Xt({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],s=[],o={};a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4");function a(g,y){c(g),c(y)}function c(g){r.push(0,0,0),s.push(0,0,0),o[g]===void 0&&(o[g]=[]),o[g].push(r.length/3-1)}t.setAttribute("position",new Ve(r,3)),t.setAttribute("color",new Ve(s,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=o,this.update();let l=new Be(16755200),u=new Be(16711680),h=new Be(43775),d=new Be(16777215),m=new Be(3355443);this.setColors(l,u,h,d,m)}setColors(e,t,n,r,s){let a=this.geometry.getAttribute("color");a.setXYZ(0,e.r,e.g,e.b),a.setXYZ(1,e.r,e.g,e.b),a.setXYZ(2,e.r,e.g,e.b),a.setXYZ(3,e.r,e.g,e.b),a.setXYZ(4,e.r,e.g,e.b),a.setXYZ(5,e.r,e.g,e.b),a.setXYZ(6,e.r,e.g,e.b),a.setXYZ(7,e.r,e.g,e.b),a.setXYZ(8,e.r,e.g,e.b),a.setXYZ(9,e.r,e.g,e.b),a.setXYZ(10,e.r,e.g,e.b),a.setXYZ(11,e.r,e.g,e.b),a.setXYZ(12,e.r,e.g,e.b),a.setXYZ(13,e.r,e.g,e.b),a.setXYZ(14,e.r,e.g,e.b),a.setXYZ(15,e.r,e.g,e.b),a.setXYZ(16,e.r,e.g,e.b),a.setXYZ(17,e.r,e.g,e.b),a.setXYZ(18,e.r,e.g,e.b),a.setXYZ(19,e.r,e.g,e.b),a.setXYZ(20,e.r,e.g,e.b),a.setXYZ(21,e.r,e.g,e.b),a.setXYZ(22,e.r,e.g,e.b),a.setXYZ(23,e.r,e.g,e.b),a.setXYZ(24,t.r,t.g,t.b),a.setXYZ(25,t.r,t.g,t.b),a.setXYZ(26,t.r,t.g,t.b),a.setXYZ(27,t.r,t.g,t.b),a.setXYZ(28,t.r,t.g,t.b),a.setXYZ(29,t.r,t.g,t.b),a.setXYZ(30,t.r,t.g,t.b),a.setXYZ(31,t.r,t.g,t.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,r.r,r.g,r.b),a.setXYZ(39,r.r,r.g,r.b),a.setXYZ(40,s.r,s.g,s.b),a.setXYZ(41,s.r,s.g,s.b),a.setXYZ(42,s.r,s.g,s.b),a.setXYZ(43,s.r,s.g,s.b),a.setXYZ(44,s.r,s.g,s.b),a.setXYZ(45,s.r,s.g,s.b),a.setXYZ(46,s.r,s.g,s.b),a.setXYZ(47,s.r,s.g,s.b),a.setXYZ(48,s.r,s.g,s.b),a.setXYZ(49,s.r,s.g,s.b),a.needsUpdate=!0}update(){let e=this.geometry,t=this.pointMap,n=1,r=1;fn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),mn("c",t,e,fn,0,0,-1),mn("t",t,e,fn,0,0,1),mn("n1",t,e,fn,-n,-r,-1),mn("n2",t,e,fn,n,-r,-1),mn("n3",t,e,fn,-n,r,-1),mn("n4",t,e,fn,n,r,-1),mn("f1",t,e,fn,-n,-r,1),mn("f2",t,e,fn,n,-r,1),mn("f3",t,e,fn,-n,r,1),mn("f4",t,e,fn,n,r,1),mn("u1",t,e,fn,n*.7,r*1.1,-1),mn("u2",t,e,fn,-n*.7,r*1.1,-1),mn("u3",t,e,fn,0,r*2,-1),mn("cf1",t,e,fn,-n,0,1),mn("cf2",t,e,fn,n,0,1),mn("cf3",t,e,fn,0,-r,1),mn("cf4",t,e,fn,0,r,1),mn("cn1",t,e,fn,-n,0,-1),mn("cn2",t,e,fn,n,0,-1),mn("cn3",t,e,fn,0,-r,-1),mn("cn4",t,e,fn,0,r,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}};function mn(i,e,t,n,r,s,o){sf.set(r,s,o).unproject(n);let a=e[i];if(a!==void 0){let c=t.getAttribute("position");for(let l=0,u=a.length;l<u;l++)c.setXYZ(a[l],sf.x,sf.y,sf.z)}}var of=new zt,$f=class extends ln{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=new Float32Array(24),s=new ot;s.setIndex(new gt(n,1)),s.setAttribute("position",new gt(r,3)),super(s,new Xt({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&of.setFromObject(this.object),of.isEmpty())return;let t=of.min,n=of.max,r=this.geometry.attributes.position,s=r.array;s[0]=n.x,s[1]=n.y,s[2]=n.z,s[3]=t.x,s[4]=n.y,s[5]=n.z,s[6]=t.x,s[7]=t.y,s[8]=n.z,s[9]=n.x,s[10]=t.y,s[11]=n.z,s[12]=n.x,s[13]=n.y,s[14]=t.z,s[15]=t.x,s[16]=n.y,s[17]=t.z,s[18]=t.x,s[19]=t.y,s[20]=t.z,s[21]=n.x,s[22]=t.y,s[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},ep=class extends ln{constructor(e,t=16776960){let n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],s=new ot;s.setIndex(new gt(n,1)),s.setAttribute("position",new Ve(r,3)),super(s,new Xt({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){let t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},tp=class extends ai{constructor(e,t=1,n=16776960){let r=n,s=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],o=new ot;o.setAttribute("position",new Ve(s,3)),o.computeBoundingSphere(),super(o,new Xt({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;let a=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],c=new ot;c.setAttribute("position",new Ve(a,3)),c.computeBoundingSphere(),this.add(new ct(c,new Ht({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},Ab=new q,af,Ug,np=class extends St{constructor(e=new q(0,0,1),t=new q(0,0,0),n=1,r=16776960,s=n*.2,o=s*.2){super(),this.type="ArrowHelper",af===void 0&&(af=new ot,af.setAttribute("position",new Ve([0,0,0,0,1,0],3)),Ug=new is(0,.5,1,5,1),Ug.translate(0,-.5,0)),this.position.copy(t),this.line=new ai(af,new Xt({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new ct(Ug,new Ht({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,s,o)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Ab.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Ab,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},ip=class extends ln{constructor(e=1){let t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new ot;r.setAttribute("position",new Ve(t,3)),r.setAttribute("color",new Ve(n,3));let s=new Xt({vertexColors:!0,toneMapped:!1});super(r,s),this.type="AxesHelper"}setColors(e,t,n){let r=new Be,s=this.geometry.attributes.color.array;return r.set(e),r.toArray(s,0),r.toArray(s,3),r.set(t),r.toArray(s,6),r.toArray(s,9),r.set(n),r.toArray(s,12),r.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},rp=class{constructor(){this.type="ShapePath",this.color=new Be,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Tr,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,s,o){return this.currentPath.bezierCurveTo(e,t,n,r,s,o),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(p){let v=[];for(let b=0,x=p.length;b<x;b++){let _=p[b],T=new Fi;T.curves=_.curves,v.push(T)}return v}function n(p,v){let b=v.length,x=!1;for(let _=b-1,T=0;T<b;_=T++){let w=v[_],A=v[T],E=A.x-w.x,M=A.y-w.y;if(Math.abs(M)>Number.EPSILON){if(M<0&&(w=v[T],E=-E,A=v[_],M=-M),p.y<w.y||p.y>A.y)continue;if(p.y===w.y){if(p.x===w.x)return!0}else{let P=M*(p.x-w.x)-E*(p.y-w.y);if(P===0)return!0;if(P<0)continue;x=!x}}else{if(p.y!==w.y)continue;if(A.x<=p.x&&p.x<=w.x||w.x<=p.x&&p.x<=A.x)return!0}}return x}let r=Ui.isClockWise,s=this.subPaths;if(s.length===0)return[];let o,a,c,l=[];if(s.length===1)return a=s[0],c=new Fi,c.curves=a.curves,l.push(c),l;let u=!r(s[0].getPoints());u=e?!u:u;let h=[],d=[],m=[],g=0,y;d[g]=void 0,m[g]=[];for(let p=0,v=s.length;p<v;p++)a=s[p],y=a.getPoints(),o=r(y),o=e?!o:o,o?(!u&&d[g]&&g++,d[g]={s:new Fi,p:y},d[g].s.curves=a.curves,u&&g++,m[g]=[]):m[g].push({h:a,p:y[0]});if(!d[0])return t(s);if(d.length>1){let p=!1,v=0;for(let b=0,x=d.length;b<x;b++)h[b]=[];for(let b=0,x=d.length;b<x;b++){let _=m[b];for(let T=0;T<_.length;T++){let w=_[T],A=!0;for(let E=0;E<d.length;E++)n(w.p,d[E].p)&&(b!==E&&v++,A?(A=!1,h[E].push(w)):p=!0);A&&h[b].push(w)}}v>0&&p===!1&&(m=h)}let f;for(let p=0,v=d.length;p<v;p++){c=d[p].s,l.push(c),f=m[p];for(let b=0,x=f.length;b<x;b++)c.holes.push(f[b].h)}return l}},yc=class extends ki{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(){}disconnect(){}dispose(){}update(){}};function pA(i,e){let t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2):(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0),i}function mA(i,e){let t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0):(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2),i}function gA(i){return i.repeat.x=1,i.repeat.y=1,i.offset.x=0,i.offset.y=0,i}function Ap(i,e,t,n){let r=yA(n);switch(t){case pp:return i*e;case gp:return i*e;case yp:return i*e*2;case Wu:return i*e/r.components*r.byteLength;case Sc:return i*e/r.components*r.byteLength;case xp:return i*e*2/r.components*r.byteLength;case Xu:return i*e*2/r.components*r.byteLength;case mp:return i*e*3/r.components*r.byteLength;case Ln:return i*e*4/r.components*r.byteLength;case Yu:return i*e*4/r.components*r.byteLength;case Tc:case Ac:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case wc:case Rc:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case qu:case Zu:return Math.max(i,16)*Math.max(e,8)/4;case ju:case Ku:return Math.max(i,8)*Math.max(e,8)/2;case Ju:case Qu:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case $u:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case eh:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case th:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case nh:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case ih:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case rh:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case sh:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case oh:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case ah:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case ch:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case lh:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case uh:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case hh:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case dh:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case fh:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Cc:case ph:case mh:return Math.ceil(i/4)*Math.ceil(e/4)*16;case vp:case gh:return Math.ceil(i/4)*Math.ceil(e/4)*8;case yh:case xh:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function yA(i){switch(i){case ci:case hp:return{byteLength:1,components:1};case Zo:case dp:case Hn:return{byteLength:2,components:1};case Hu:case Gu:return{byteLength:2,components:4};case Lr:case Vu:case si:return{byteLength:4,components:1};case fp:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}var y_={contain:pA,cover:mA,fill:gA,getByteLength:Ap},sp=class extends on{constructor(e=1,t=1,n=1,r={}){console.warn('THREE.WebGLMultipleRenderTargets has been deprecated and will be removed in r172. Use THREE.WebGLRenderTarget and set the "count" parameter to enable MRT.'),super(e,t,{...r,count:n}),this.isWebGLMultipleRenderTargets=!0}get texture(){return this.textures}};typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"171"}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="171");function V_(){let i=null,e=!1,t=null,n=null;function r(s,o){t(s,o),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(s){t=s},setContext:function(s){i=s}}}function xA(i){let e=new WeakMap;function t(a,c){let l=a.array,u=a.usage,h=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),i.bufferData(c,l,u),a.onUploadCallback();let m;if(l instanceof Float32Array)m=i.FLOAT;else if(l instanceof Uint16Array)a.isFloat16BufferAttribute?m=i.HALF_FLOAT:m=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)m=i.SHORT;else if(l instanceof Uint32Array)m=i.UNSIGNED_INT;else if(l instanceof Int32Array)m=i.INT;else if(l instanceof Int8Array)m=i.BYTE;else if(l instanceof Uint8Array)m=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)m=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:m,bytesPerElement:l.BYTES_PER_ELEMENT,version:a.version,size:h}}function n(a,c,l){let u=c.array,h=c.updateRanges;if(i.bindBuffer(l,a),h.length===0)i.bufferSubData(l,0,u);else{h.sort((m,g)=>m.start-g.start);let d=0;for(let m=1;m<h.length;m++){let g=h[d],y=h[m];y.start<=g.start+g.count+1?g.count=Math.max(g.count,y.start+y.count-g.start):(++d,h[d]=y)}h.length=d+1;for(let m=0,g=h.length;m<g;m++){let y=h[m];i.bufferSubData(l,y.start*u.BYTES_PER_ELEMENT,u,y.start,y.count)}c.clearUpdateRanges()}c.onUploadCallback()}function r(a){return a.isInterleavedBufferAttribute&&(a=a.data),e.get(a)}function s(a){a.isInterleavedBufferAttribute&&(a=a.data);let c=e.get(a);c&&(i.deleteBuffer(c.buffer),e.delete(a))}function o(a,c){if(a.isInterleavedBufferAttribute&&(a=a.data),a.isGLBufferAttribute){let u=e.get(a);(!u||u.version<a.version)&&e.set(a,{buffer:a.buffer,type:a.type,bytesPerElement:a.elementSize,version:a.version});return}let l=e.get(a);if(l===void 0)e.set(a,t(a,c));else if(l.version<a.version){if(l.size!==a.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,a,c),l.version=a.version}}return{get:r,remove:s,update:o}}var vA=`#ifdef USE_ALPHAHASH
	if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,bA=`#ifdef USE_ALPHAHASH
	const float ALPHA_HASH_SCALE = 0.05;
	float hash2D( vec2 value ) {
		return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
	}
	float hash3D( vec3 value ) {
		return hash2D( vec2( hash2D( value.xy ), value.z ) );
	}
	float getAlphaHashThreshold( vec3 position ) {
		float maxDeriv = max(
			length( dFdx( position.xyz ) ),
			length( dFdy( position.xyz ) )
		);
		float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
		vec2 pixScales = vec2(
			exp2( floor( log2( pixScale ) ) ),
			exp2( ceil( log2( pixScale ) ) )
		);
		vec2 alpha = vec2(
			hash3D( floor( pixScales.x * position.xyz ) ),
			hash3D( floor( pixScales.y * position.xyz ) )
		);
		float lerpFactor = fract( log2( pixScale ) );
		float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
		float a = min( lerpFactor, 1.0 - lerpFactor );
		vec3 cases = vec3(
			x * x / ( 2.0 * a * ( 1.0 - a ) ),
			( x - 0.5 * a ) / ( 1.0 - a ),
			1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
		);
		float threshold = ( x < ( 1.0 - a ) )
			? ( ( x < a ) ? cases.x : cases.y )
			: cases.z;
		return clamp( threshold , 1.0e-6, 1.0 );
	}
#endif`,_A=`#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,EA=`#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,MA=`#ifdef USE_ALPHATEST
	#ifdef ALPHA_TO_COVERAGE
	diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
	if ( diffuseColor.a == 0.0 ) discard;
	#else
	if ( diffuseColor.a < alphaTest ) discard;
	#endif
#endif`,SA=`#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`,TA=`#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_CLEARCOAT ) 
		clearcoatSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_SHEEN ) 
		sheenSpecularIndirect *= ambientOcclusion;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
	#endif
#endif`,AA=`#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`,wA=`#ifdef USE_BATCHING
	#if ! defined( GL_ANGLE_multi_draw )
	#define gl_DrawID _gl_DrawID
	uniform int _gl_DrawID;
	#endif
	uniform highp sampler2D batchingTexture;
	uniform highp usampler2D batchingIdTexture;
	mat4 getBatchingMatrix( const in float i ) {
		int size = textureSize( batchingTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
	float getIndirectIndex( const in int i ) {
		int size = textureSize( batchingIdTexture, 0 ).x;
		int x = i % size;
		int y = i / size;
		return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
	}
#endif
#ifdef USE_BATCHING_COLOR
	uniform sampler2D batchingColorTexture;
	vec3 getBatchingColor( const in float i ) {
		int size = textureSize( batchingColorTexture, 0 ).x;
		int j = int( i );
		int x = j % size;
		int y = j / size;
		return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
	}
#endif`,RA=`#ifdef USE_BATCHING
	mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,CA=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
	vPosition = vec3( position );
#endif`,PA=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`,IA=`float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( specularColor, 1.0, dotVH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
} // validated`,NA=`#ifdef USE_IRIDESCENCE
	const mat3 XYZ_TO_REC709 = mat3(
		 3.2404542, -0.9692660,  0.0556434,
		-1.5371385,  1.8760108, -0.2040259,
		-0.4985314,  0.0415560,  1.0572252
	);
	vec3 Fresnel0ToIor( vec3 fresnel0 ) {
		vec3 sqrtF0 = sqrt( fresnel0 );
		return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
	}
	vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
	}
	float IorToFresnel0( float transmittedIor, float incidentIor ) {
		return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
	}
	vec3 evalSensitivity( float OPD, vec3 shift ) {
		float phase = 2.0 * PI * OPD * 1.0e-9;
		vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
		vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
		vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
		vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
		xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
		xyz /= 1.0685e-7;
		vec3 rgb = XYZ_TO_REC709 * xyz;
		return rgb;
	}
	vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
		vec3 I;
		float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
		float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
		float cosTheta2Sq = 1.0 - sinTheta2Sq;
		if ( cosTheta2Sq < 0.0 ) {
			return vec3( 1.0 );
		}
		float cosTheta2 = sqrt( cosTheta2Sq );
		float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
		float R12 = F_Schlick( R0, 1.0, cosTheta1 );
		float T121 = 1.0 - R12;
		float phi12 = 0.0;
		if ( iridescenceIOR < outsideIOR ) phi12 = PI;
		float phi21 = PI - phi12;
		vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );		vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
		vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
		vec3 phi23 = vec3( 0.0 );
		if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
		if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
		if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
		float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
		vec3 phi = vec3( phi21 ) + phi23;
		vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
		vec3 r123 = sqrt( R123 );
		vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
		vec3 C0 = R12 + Rs;
		I = C0;
		vec3 Cm = Rs - T121;
		for ( int m = 1; m <= 2; ++ m ) {
			Cm *= r123;
			vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
			I += Cm * Sm;
		}
		return max( I, vec3( 0.0 ) );
	}
#endif`,LA=`#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vBumpMapUv );
		vec2 dSTdy = dFdy( vBumpMapUv );
		float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
		vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
		vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 ) * faceDirection;
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`,OA=`#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#ifdef ALPHA_TO_COVERAGE
		float distanceToPlane, distanceGradient;
		float clipOpacity = 1.0;
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
			distanceGradient = fwidth( distanceToPlane ) / 2.0;
			clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			if ( clipOpacity == 0.0 ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			float unionClipOpacity = 1.0;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
				distanceGradient = fwidth( distanceToPlane ) / 2.0;
				unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
			}
			#pragma unroll_loop_end
			clipOpacity *= 1.0 - unionClipOpacity;
		#endif
		diffuseColor.a *= clipOpacity;
		if ( diffuseColor.a == 0.0 ) discard;
	#else
		#pragma unroll_loop_start
		for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
		}
		#pragma unroll_loop_end
		#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
			bool clipped = true;
			#pragma unroll_loop_start
			for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
				plane = clippingPlanes[ i ];
				clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
			}
			#pragma unroll_loop_end
			if ( clipped ) discard;
		#endif
	#endif
#endif`,DA=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,FA=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`,UA=`#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`,kA=`#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`,BA=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`,zA=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	varying vec3 vColor;
#endif`,VA=`#if defined( USE_COLOR_ALPHA )
	vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
	vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
	vColor.xyz *= batchingColor.xyz;
#endif`,HA=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
	varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
	mat3 tmp;
	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
	return tmp;
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,GA=`#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_minTileSize 16.0
	float getFace( vec3 direction ) {
		vec3 absDirection = abs( direction );
		float face = - 1.0;
		if ( absDirection.x > absDirection.z ) {
			if ( absDirection.x > absDirection.y )
				face = direction.x > 0.0 ? 0.0 : 3.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		} else {
			if ( absDirection.z > absDirection.y )
				face = direction.z > 0.0 ? 2.0 : 5.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		}
		return face;
	}
	vec2 getUV( vec3 direction, float face ) {
		vec2 uv;
		if ( face == 0.0 ) {
			uv = vec2( direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 1.0 ) {
			uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
		} else if ( face == 2.0 ) {
			uv = vec2( - direction.x, direction.y ) / abs( direction.z );
		} else if ( face == 3.0 ) {
			uv = vec2( - direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 4.0 ) {
			uv = vec2( - direction.x, direction.z ) / abs( direction.y );
		} else {
			uv = vec2( direction.x, direction.y ) / abs( direction.z );
		}
		return 0.5 * ( uv + 1.0 );
	}
	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
		float face = getFace( direction );
		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
		mipInt = max( mipInt, cubeUV_minMipLevel );
		float faceSize = exp2( mipInt );
		highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		uv.x += filterInt * 3.0 * cubeUV_minTileSize;
		uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
		uv.x *= CUBEUV_TEXEL_WIDTH;
		uv.y *= CUBEUV_TEXEL_HEIGHT;
		#ifdef texture2DGradEXT
			return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
		#else
			return texture2D( envMap, uv ).rgb;
		#endif
	}
	#define cubeUV_r0 1.0
	#define cubeUV_m0 - 2.0
	#define cubeUV_r1 0.8
	#define cubeUV_m1 - 1.0
	#define cubeUV_r4 0.4
	#define cubeUV_m4 2.0
	#define cubeUV_r5 0.305
	#define cubeUV_m5 3.0
	#define cubeUV_r6 0.21
	#define cubeUV_m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= cubeUV_r1 ) {
			mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
		} else if ( roughness >= cubeUV_r4 ) {
			mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
		} else if ( roughness >= cubeUV_r5 ) {
			mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
		} else if ( roughness >= cubeUV_r6 ) {
			mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
		float mipF = fract( mip );
		float mipInt = floor( mip );
		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
		if ( mipF == 0.0 ) {
			return vec4( color0, 1.0 );
		} else {
			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
			return vec4( mix( color0, color1, mipF ), 1.0 );
		}
	}
#endif`,WA=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
	vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
	mat3 bm = mat3( batchingMatrix );
	transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
	transformedNormal = bm * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = bm * transformedTangent;
	#endif
#endif
#ifdef USE_INSTANCING
	mat3 im = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
	transformedNormal = im * transformedNormal;
	#ifdef USE_TANGENT
		transformedTangent = im * transformedTangent;
	#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`,XA=`#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`,YA=`#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,jA=`#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
	#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
		emissiveColor = sRGBTransferEOTF( emissiveColor );
	#endif
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,qA=`#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`,KA="gl_FragColor = linearToOutputTexel( gl_FragColor );",ZA=`vec4 LinearTransferOETF( in vec4 value ) {
	return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
	return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
}
vec4 sRGBTransferOETF( in vec4 value ) {
	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}`,JA=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifdef ENVMAP_BLENDING_MULTIPLY
		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_MIX )
		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_ADD )
		outgoingLight += envColor.xyz * specularStrength * reflectivity;
	#endif
#endif`,QA=`#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	uniform mat3 envMapRotation;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif`,$A=`#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`,e1=`#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`,t1=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`,n1=`#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`,i1=`#ifdef USE_FOG
	varying float vFogDepth;
#endif`,r1=`#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,s1=`#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`,o1=`#ifdef USE_GRADIENTMAP
	uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
	#ifdef USE_GRADIENTMAP
		return vec3( texture2D( gradientMap, coord ).r );
	#else
		vec2 fw = fwidth( coord ) * 0.5;
		return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
	#endif
}`,a1=`#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`,c1=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,l1=`varying vec3 vViewPosition;
struct LambertMaterial {
	vec3 diffuseColor;
	float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Lambert
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Lambert`,u1=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
	uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
	float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
	if ( cutoffDistance > 0.0 ) {
		distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
	}
	return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
	return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
		light.color = directionalLight.color;
		light.direction = directionalLight.direction;
		light.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = pointLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float lightDistance = length( lVector );
		light.color = pointLight.color;
		light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
		light.visible = ( light.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
		vec3 lVector = spotLight.position - geometryPosition;
		light.direction = normalize( lVector );
		float angleCos = dot( light.direction, spotLight.direction );
		float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
		if ( spotAttenuation > 0.0 ) {
			float lightDistance = length( lVector );
			light.color = spotLight.color * spotAttenuation;
			light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
			light.visible = ( light.color != vec3( 0.0 ) );
		} else {
			light.color = vec3( 0.0 );
			light.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
		float dotNL = dot( normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		return irradiance;
	}
#endif`,h1=`#ifdef USE_ENVMAP
	vec3 getIBLIrradiance( const in vec3 normal ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
			return PI * envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
		#ifdef ENVMAP_TYPE_CUBE_UV
			vec3 reflectVec = reflect( - viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
			reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
			return envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	#ifdef USE_ANISOTROPY
		vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
			#ifdef ENVMAP_TYPE_CUBE_UV
				vec3 bentNormal = cross( bitangent, viewDir );
				bentNormal = normalize( cross( bentNormal, bitangent ) );
				bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
				return getIBLRadiance( viewDir, bentNormal, roughness );
			#else
				return vec3( 0.0 );
			#endif
		}
	#endif
#endif`,d1=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,f1=`varying vec3 vViewPosition;
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon`,p1=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,m1=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong`,g1=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
	material.ior = ior;
	#ifdef USE_SPECULAR
		float specularIntensityFactor = specularIntensity;
		vec3 specularColorFactor = specularColor;
		#ifdef USE_SPECULAR_COLORMAP
			specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
		#endif
		#ifdef USE_SPECULAR_INTENSITYMAP
			specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
		#endif
		material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
	#else
		float specularIntensityFactor = 1.0;
		vec3 specularColorFactor = vec3( 1.0 );
		material.specularF90 = 1.0;
	#endif
	material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
	material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	material.clearcoatF0 = vec3( 0.04 );
	material.clearcoatF90 = 1.0;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
	#endif
	material.clearcoat = saturate( material.clearcoat );	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
	material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
	material.iridescence = iridescence;
	material.iridescenceIOR = iridescenceIOR;
	#ifdef USE_IRIDESCENCEMAP
		material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
	#endif
	#ifdef USE_IRIDESCENCE_THICKNESSMAP
		material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
	#else
		material.iridescenceThickness = iridescenceThicknessMaximum;
	#endif
#endif
#ifdef USE_SHEEN
	material.sheenColor = sheenColor;
	#ifdef USE_SHEEN_COLORMAP
		material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
	#endif
	material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
	#ifdef USE_SHEEN_ROUGHNESSMAP
		material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
	#endif
#endif
#ifdef USE_ANISOTROPY
	#ifdef USE_ANISOTROPYMAP
		mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
		vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
		vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
	#else
		vec2 anisotropyV = anisotropyVector;
	#endif
	material.anisotropy = length( anisotropyV );
	if( material.anisotropy == 0.0 ) {
		anisotropyV = vec2( 1.0, 0.0 );
	} else {
		anisotropyV /= material.anisotropy;
		material.anisotropy = saturate( material.anisotropy );
	}
	material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
	material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
	material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,y1=`struct PhysicalMaterial {
	vec3 diffuseColor;
	float roughness;
	vec3 specularColor;
	float specularF90;
	float dispersion;
	#ifdef USE_CLEARCOAT
		float clearcoat;
		float clearcoatRoughness;
		vec3 clearcoatF0;
		float clearcoatF90;
	#endif
	#ifdef USE_IRIDESCENCE
		float iridescence;
		float iridescenceIOR;
		float iridescenceThickness;
		vec3 iridescenceFresnel;
		vec3 iridescenceF0;
	#endif
	#ifdef USE_SHEEN
		vec3 sheenColor;
		float sheenRoughness;
	#endif
	#ifdef IOR
		float ior;
	#endif
	#ifdef USE_TRANSMISSION
		float transmission;
		float transmissionAlpha;
		float thickness;
		float attenuationDistance;
		vec3 attenuationColor;
	#endif
	#ifdef USE_ANISOTROPY
		float anisotropy;
		float alphaT;
		vec3 anisotropyT;
		vec3 anisotropyB;
	#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
    float x2 = x * x;
    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
	float a2 = pow2( alpha );
	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
	return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
	float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
		float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
		float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
		float v = 0.5 / ( gv + gl );
		return saturate(v);
	}
	float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
		float a2 = alphaT * alphaB;
		highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
		highp float v2 = dot( v, v );
		float w2 = a2 / v2;
		return RECIPROCAL_PI * a2 * pow2 ( w2 );
	}
#endif
#ifdef USE_CLEARCOAT
	vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
		vec3 f0 = material.clearcoatF0;
		float f90 = material.clearcoatF90;
		float roughness = material.clearcoatRoughness;
		float alpha = pow2( roughness );
		vec3 halfDir = normalize( lightDir + viewDir );
		float dotNL = saturate( dot( normal, lightDir ) );
		float dotNV = saturate( dot( normal, viewDir ) );
		float dotNH = saturate( dot( normal, halfDir ) );
		float dotVH = saturate( dot( viewDir, halfDir ) );
		vec3 F = F_Schlick( f0, f90, dotVH );
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
		return F * ( V * D );
	}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
	vec3 f0 = material.specularColor;
	float f90 = material.specularF90;
	float roughness = material.roughness;
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( f0, f90, dotVH );
	#ifdef USE_IRIDESCENCE
		F = mix( F, material.iridescenceFresnel, material.iridescence );
	#endif
	#ifdef USE_ANISOTROPY
		float dotTL = dot( material.anisotropyT, lightDir );
		float dotTV = dot( material.anisotropyT, viewDir );
		float dotTH = dot( material.anisotropyT, halfDir );
		float dotBL = dot( material.anisotropyB, lightDir );
		float dotBV = dot( material.anisotropyB, viewDir );
		float dotBH = dot( material.anisotropyB, halfDir );
		float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
		float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
	#else
		float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
		float D = D_GGX( alpha, dotNH );
	#endif
	return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;
	float dotNV = saturate( dot( N, V ) );
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
	uv = uv * LUT_SCALE + LUT_BIAS;
	return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
	float l = length( f );
	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
	float x = dot( v1, v2 );
	float y = abs( x );
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;
	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
	return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );
	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 );
	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
	return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
	float alpha = pow2( roughness );
	float invAlpha = 1.0 / alpha;
	float cos2h = dotNH * dotNH;
	float sin2h = max( 1.0 - cos2h, 0.0078125 );
	return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
	return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float D = D_Charlie( sheenRoughness, dotNH );
	float V = V_Neubelt( dotNV, dotNL );
	return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	float r2 = roughness * roughness;
	float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
	float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
	float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
	return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
	vec4 r = roughness * c0 + c1;
	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
	vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
	return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	#ifdef USE_IRIDESCENCE
		vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
	#else
		vec3 Fr = specularColor;
	#endif
	vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
	float Ess = fab.x + fab.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometryNormal;
		vec3 viewDir = geometryViewDir;
		vec3 position = geometryPosition;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.roughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifdef USE_CLEARCOAT
		float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = dotNLcc * directLight.color;
		clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
	#endif
	reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef USE_CLEARCOAT
		clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
	#endif
	#ifdef USE_SHEEN
		sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
	#endif
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	#ifdef USE_IRIDESCENCE
		computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
	#else
		computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
	#endif
	vec3 totalScattering = singleScattering + multiScattering;
	vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
	reflectedLight.indirectSpecular += radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,x1=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
	geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
	float dotNVi = saturate( dot( normal, geometryViewDir ) );
	if ( material.iridescenceThickness == 0.0 ) {
		material.iridescence = 0.0;
	} else {
		material.iridescence = saturate( material.iridescence );
	}
	if ( material.iridescence > 0.0 ) {
		material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
		material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
	}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		pointLight = pointLights[ i ];
		getPointLightInfo( pointLight, geometryPosition, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	vec4 spotColor;
	vec3 spotLightCoord;
	bool inSpotLightMap;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		spotLight = spotLights[ i ];
		getSpotLightInfo( spotLight, geometryPosition, directLight );
		#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
		#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
		#else
		#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
		#endif
		#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
			spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
			inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
			spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
			directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
		#endif
		#undef SPOT_LIGHT_MAP_INDEX
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalLightInfo( directionalLight, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	#if defined( USE_LIGHT_PROBES )
		irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
	#endif
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,v1=`#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getIBLIrradiance( geometryNormal );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	#ifdef USE_ANISOTROPY
		radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
	#else
		radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
	#endif
	#ifdef USE_CLEARCOAT
		clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
	#endif
#endif`,b1=`#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,_1=`#if defined( USE_LOGDEPTHBUF )
	gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,E1=`#if defined( USE_LOGDEPTHBUF )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,M1=`#ifdef USE_LOGDEPTHBUF
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,S1=`#ifdef USE_LOGDEPTHBUF
	vFragDepth = 1.0 + gl_Position.w;
	vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,T1=`#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vMapUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`,A1=`#ifdef USE_MAP
	uniform sampler2D map;
#endif`,w1=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	#if defined( USE_POINTS_UV )
		vec2 uv = vUv;
	#else
		vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
	#endif
#endif
#ifdef USE_MAP
	diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,R1=`#if defined( USE_POINTS_UV )
	varying vec2 vUv;
#else
	#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
		uniform mat3 uvTransform;
	#endif
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,C1=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
	metalnessFactor *= texelMetalness.b;
#endif`,P1=`#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`,I1=`#ifdef USE_INSTANCING_MORPH
	float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		morphTargetInfluences[i] =  texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
	}
#endif`,N1=`#if defined( USE_MORPHCOLORS )
	vColor *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		#if defined( USE_COLOR_ALPHA )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
		#elif defined( USE_COLOR )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
		#endif
	}
#endif`,L1=`#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
	}
#endif`,O1=`#ifdef USE_MORPHTARGETS
	#ifndef USE_INSTANCING_MORPH
		uniform float morphTargetBaseInfluence;
		uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
	#endif
	uniform sampler2DArray morphTargetsTexture;
	uniform ivec2 morphTargetsTextureSize;
	vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
		int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
		int y = texelIndex / morphTargetsTextureSize.x;
		int x = texelIndex - y * morphTargetsTextureSize.x;
		ivec3 morphUV = ivec3( x, y, morphTargetIndex );
		return texelFetch( morphTargetsTexture, morphUV, 0 );
	}
#endif`,D1=`#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
	}
#endif`,F1=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
	vec3 fdx = dFdx( vViewPosition );
	vec3 fdy = dFdy( vViewPosition );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal *= faceDirection;
	#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
	#ifdef USE_TANGENT
		mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn = getTangentFrame( - vViewPosition, normal,
		#if defined( USE_NORMALMAP )
			vNormalMapUv
		#elif defined( USE_CLEARCOAT_NORMALMAP )
			vClearcoatNormalMapUv
		#else
			vUv
		#endif
		);
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn[0] *= faceDirection;
		tbn[1] *= faceDirection;
	#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	#ifdef USE_TANGENT
		mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
	#else
		mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
	#endif
	#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
		tbn2[0] *= faceDirection;
		tbn2[1] *= faceDirection;
	#endif
#endif
vec3 nonPerturbedNormal = normal;`,U1=`#ifdef USE_NORMALMAP_OBJECTSPACE
	normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
	vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,k1=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,B1=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,z1=`#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`,V1=`#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
	mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
		vec3 q0 = dFdx( eye_pos.xyz );
		vec3 q1 = dFdy( eye_pos.xyz );
		vec2 st0 = dFdx( uv.st );
		vec2 st1 = dFdy( uv.st );
		vec3 N = surf_norm;
		vec3 q1perp = cross( q1, N );
		vec3 q0perp = cross( N, q0 );
		vec3 T = q1perp * st0.x + q0perp * st1.x;
		vec3 B = q1perp * st0.y + q0perp * st1.y;
		float det = max( dot( T, T ), dot( B, B ) );
		float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
		return mat3( T * scale, B * scale, N );
	}
#endif`,H1=`#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,G1=`#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,W1=`#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif`,X1=`#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`,Y1=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,j1=`vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
	if( v <= 0.0 )
		return vec4( 0., 0., 0., 0. );
	if( v >= 1.0 )
		return vec4( 1., 1., 1., 1. );
	float vuf;
	float af = modf( v * PackFactors.a, vuf );
	float bf = modf( vuf * ShiftRight8, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
	if( v <= 0.0 )
		return vec3( 0., 0., 0. );
	if( v >= 1.0 )
		return vec3( 1., 1., 1. );
	float vuf;
	float bf = modf( v * PackFactors.b, vuf );
	float gf = modf( vuf * ShiftRight8, vuf );
	return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
	if( v <= 0.0 )
		return vec2( 0., 0. );
	if( v >= 1.0 )
		return vec2( 1., 1. );
	float vuf;
	float gf = modf( v * 256., vuf );
	return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
	return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
	return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * depth - far );
}`,q1=`#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`,K1=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
	mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,Z1=`#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,J1=`#ifdef DITHERING
	vec3 dithering( vec3 color ) {
		float grid_position = rand( gl_FragCoord.xy );
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
		return color + dither_shift_RGB;
	}
#endif`,Q1=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
	roughnessFactor *= texelRoughness.g;
#endif`,$1=`#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`,ew=`#if NUM_SPOT_LIGHT_COORDS > 0
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
	uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		float hard_shadow = step( compare , distribution.x );
		if (hard_shadow != 1.0 ) {
			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
		bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		float shadow = 1.0;
		vec3 lightToPosition = shadowCoord.xyz;
		
		float lightToPositionLength = length( lightToPosition );
		if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
			float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );			dp += shadowBias;
			vec3 bd3D = normalize( lightToPosition );
			vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
			#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
				vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
				shadow = (
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
					texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
				) * ( 1.0 / 9.0 );
			#else
				shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
			#endif
		}
		return mix( 1.0, shadow, shadowIntensity );
	}
#endif`,tw=`#if NUM_SPOT_LIGHT_COORDS > 0
	uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
	varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		struct SpotLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowIntensity;
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`,nw=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
	vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
	vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
	#if NUM_DIR_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
			vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
			shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
			vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
		}
		#pragma unroll_loop_end
	#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
		shadowWorldPosition = worldPosition;
		#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
			shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
		#endif
		vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
#endif`,iw=`float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`,rw=`#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,sw=`#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	uniform highp sampler2D boneTexture;
	mat4 getBoneMatrix( const in float i ) {
		int size = textureSize( boneTexture, 0 ).x;
		int j = int( i ) * 4;
		int x = j % size;
		int y = j / size;
		vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
		vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
		vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
		vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
		return mat4( v1, v2, v3, v4 );
	}
#endif`,ow=`#ifdef USE_SKINNING
	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;
	transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,aw=`#ifdef USE_SKINNING
	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
	#ifdef USE_TANGENT
		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#endif
#endif`,cw=`float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`,lw=`#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`,uw=`#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,hw=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
	vec3( 1.6605, - 0.1246, - 0.0182 ),
	vec3( - 0.5876, 1.1329, - 0.1006 ),
	vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
	vec3( 0.6274, 0.0691, 0.0164 ),
	vec3( 0.3293, 0.9195, 0.0880 ),
	vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
	vec3 x2 = x * x;
	vec3 x4 = x2 * x2;
	return + 15.5 * x4 * x2
		- 40.14 * x4 * x
		+ 31.96 * x4
		- 6.868 * x2 * x
		+ 0.4298 * x2
		+ 0.1191 * x
		- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
	const mat3 AgXInsetMatrix = mat3(
		vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
		vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
		vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
	);
	const mat3 AgXOutsetMatrix = mat3(
		vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
		vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
		vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
	);
	const float AgxMinEv = - 12.47393;	const float AgxMaxEv = 4.026069;
	color *= toneMappingExposure;
	color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
	color = AgXInsetMatrix * color;
	color = max( color, 1e-10 );	color = log2( color );
	color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
	color = clamp( color, 0.0, 1.0 );
	color = agxDefaultContrastApprox( color );
	color = AgXOutsetMatrix * color;
	color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
	color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
	color = clamp( color, 0.0, 1.0 );
	return color;
}
vec3 NeutralToneMapping( vec3 color ) {
	const float StartCompression = 0.8 - 0.04;
	const float Desaturation = 0.15;
	color *= toneMappingExposure;
	float x = min( color.r, min( color.g, color.b ) );
	float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
	color -= offset;
	float peak = max( color.r, max( color.g, color.b ) );
	if ( peak < StartCompression ) return color;
	float d = 1. - StartCompression;
	float newPeak = 1. - d * d / ( peak + d - StartCompression );
	color *= newPeak / peak;
	float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
	return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,dw=`#ifdef USE_TRANSMISSION
	material.transmission = transmission;
	material.transmissionAlpha = 1.0;
	material.thickness = thickness;
	material.attenuationDistance = attenuationDistance;
	material.attenuationColor = attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
	#endif
	#ifdef USE_THICKNESSMAP
		material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
	#endif
	vec3 pos = vWorldPosition;
	vec3 v = normalize( cameraPosition - pos );
	vec3 n = inverseTransformDirection( normal, viewMatrix );
	vec4 transmitted = getIBLVolumeRefraction(
		n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
		pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
		material.attenuationColor, material.attenuationDistance );
	material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
	totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,fw=`#ifdef USE_TRANSMISSION
	uniform float transmission;
	uniform float thickness;
	uniform float attenuationDistance;
	uniform vec3 attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		uniform sampler2D transmissionMap;
	#endif
	#ifdef USE_THICKNESSMAP
		uniform sampler2D thicknessMap;
	#endif
	uniform vec2 transmissionSamplerSize;
	uniform sampler2D transmissionSamplerMap;
	uniform mat4 modelMatrix;
	uniform mat4 projectionMatrix;
	varying vec3 vWorldPosition;
	float w0( float a ) {
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
	}
	float w1( float a ) {
		return ( 1.0 / 6.0 ) * ( a *  a * ( 3.0 * a - 6.0 ) + 4.0 );
	}
	float w2( float a ){
		return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
	}
	float w3( float a ) {
		return ( 1.0 / 6.0 ) * ( a * a * a );
	}
	float g0( float a ) {
		return w0( a ) + w1( a );
	}
	float g1( float a ) {
		return w2( a ) + w3( a );
	}
	float h0( float a ) {
		return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
	}
	float h1( float a ) {
		return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
	}
	vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
		uv = uv * texelSize.zw + 0.5;
		vec2 iuv = floor( uv );
		vec2 fuv = fract( uv );
		float g0x = g0( fuv.x );
		float g1x = g1( fuv.x );
		float h0x = h0( fuv.x );
		float h1x = h1( fuv.x );
		float h0y = h0( fuv.y );
		float h1y = h1( fuv.y );
		vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
		vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
		return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
			g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
	}
	vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
		vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
		vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
		vec2 fLodSizeInv = 1.0 / fLodSize;
		vec2 cLodSizeInv = 1.0 / cLodSize;
		vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
		vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
		return mix( fSample, cSample, fract( lod ) );
	}
	vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
		vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
		vec3 modelScale;
		modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
		modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
		modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
		return normalize( refractionVector ) * thickness * modelScale;
	}
	float applyIorToRoughness( const in float roughness, const in float ior ) {
		return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
	}
	vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
		float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
		return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
	}
	vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
		if ( isinf( attenuationDistance ) ) {
			return vec3( 1.0 );
		} else {
			vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
			vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );			return transmittance;
		}
	}
	vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
		const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
		const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
		const in vec3 attenuationColor, const in float attenuationDistance ) {
		vec4 transmittedLight;
		vec3 transmittance;
		#ifdef USE_DISPERSION
			float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
			vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
			for ( int i = 0; i < 3; i ++ ) {
				vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
				vec3 refractedRayExit = position + transmissionRay;
		
				vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
				vec2 refractionCoords = ndcPos.xy / ndcPos.w;
				refractionCoords += 1.0;
				refractionCoords /= 2.0;
		
				vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
				transmittedLight[ i ] = transmissionSample[ i ];
				transmittedLight.a += transmissionSample.a;
				transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
			}
			transmittedLight.a /= 3.0;
		
		#else
		
			vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
			vec3 refractedRayExit = position + transmissionRay;
			vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
			vec2 refractionCoords = ndcPos.xy / ndcPos.w;
			refractionCoords += 1.0;
			refractionCoords /= 2.0;
			transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
			transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
		
		#endif
		vec3 attenuatedColor = transmittance * transmittedLight.rgb;
		vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
		float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
		return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
	}
#endif`,pw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`,mw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	varying vec2 vUv;
#endif
#ifdef USE_MAP
	uniform mat3 mapTransform;
	varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
	uniform mat3 alphaMapTransform;
	varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
	uniform mat3 lightMapTransform;
	varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
	uniform mat3 aoMapTransform;
	varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
	uniform mat3 bumpMapTransform;
	varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
	uniform mat3 normalMapTransform;
	varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
	uniform mat3 displacementMapTransform;
	varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
	uniform mat3 emissiveMapTransform;
	varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
	uniform mat3 metalnessMapTransform;
	varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
	uniform mat3 roughnessMapTransform;
	varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
	uniform mat3 anisotropyMapTransform;
	varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
	uniform mat3 clearcoatMapTransform;
	varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform mat3 clearcoatNormalMapTransform;
	varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform mat3 clearcoatRoughnessMapTransform;
	varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
	uniform mat3 sheenColorMapTransform;
	varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	uniform mat3 sheenRoughnessMapTransform;
	varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
	uniform mat3 iridescenceMapTransform;
	varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform mat3 iridescenceThicknessMapTransform;
	varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
	uniform mat3 specularMapTransform;
	varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
	uniform mat3 specularColorMapTransform;
	varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	uniform mat3 specularIntensityMapTransform;
	varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
	uniform mat3 transmissionMapTransform;
	varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
	uniform mat3 thicknessMapTransform;
	varying vec2 vThicknessMapUv;
#endif`,gw=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
	vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
	vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
	vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
	vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
	vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
	vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
	vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
	vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
	vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
	vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
	vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
	vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
	vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
	vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
	vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
	vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
	vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
	vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
	vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
	vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
	vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`,yw=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_BATCHING
		worldPosition = batchingMatrix * worldPosition;
	#endif
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`,xw=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,vw=`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
	vec4 texColor = texture2D( t2D, vUv );
	#ifdef DECODE_VIDEO_TEXTURE
		texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,bw=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,_w=`#ifdef ENVMAP_TYPE_CUBE
	uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
	uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	#ifdef ENVMAP_TYPE_CUBE
		vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
	#else
		vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
	#endif
	texColor.rgb *= backgroundIntensity;
	gl_FragColor = texColor;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,Ew=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,Mw=`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
	vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
	gl_FragColor = texColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,Sw=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`,Tw=`#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <logdepthbuf_fragment>
	float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#elif DEPTH_PACKING == 3202
		gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
	#elif DEPTH_PACKING == 3203
		gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
	#endif
}`,Aw=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <skinbase_vertex>
	#include <morphinstance_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`,ww=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	vec4 diffuseColor = vec4( 1.0 );
	#include <clipping_planes_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`,Rw=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`,Cw=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	gl_FragColor = texture2D( tEquirect, sampleUV );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
}`,Pw=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,Iw=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,Nw=`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinbase_vertex>
		#include <skinnormal_vertex>
		#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`,Lw=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
		reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,Ow=`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,Dw=`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_lambert_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,Fw=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`,Uw=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
	#ifdef USE_MATCAP
		vec4 matcapColor = texture2D( matcap, uv );
	#else
		vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,kw=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	vViewPosition = - mvPosition.xyz;
#endif
}`,Bw=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
	varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
	#ifdef OPAQUE
		gl_FragColor.a = 1.0;
	#endif
}`,zw=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,Vw=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,Hw=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
	varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
#ifdef USE_TRANSMISSION
	vWorldPosition = worldPosition.xyz;
#endif
}`,Gw=`#define STANDARD
#ifdef PHYSICAL
	#define IOR
	#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
	uniform float ior;
#endif
#ifdef USE_SPECULAR
	uniform float specularIntensity;
	uniform vec3 specularColor;
	#ifdef USE_SPECULAR_COLORMAP
		uniform sampler2D specularColorMap;
	#endif
	#ifdef USE_SPECULAR_INTENSITYMAP
		uniform sampler2D specularIntensityMap;
	#endif
#endif
#ifdef USE_CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
	uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
	uniform float iridescence;
	uniform float iridescenceIOR;
	uniform float iridescenceThicknessMinimum;
	uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheenColor;
	uniform float sheenRoughness;
	#ifdef USE_SHEEN_COLORMAP
		uniform sampler2D sheenColorMap;
	#endif
	#ifdef USE_SHEEN_ROUGHNESSMAP
		uniform sampler2D sheenRoughnessMap;
	#endif
#endif
#ifdef USE_ANISOTROPY
	uniform vec2 anisotropyVector;
	#ifdef USE_ANISOTROPYMAP
		uniform sampler2D anisotropyMap;
	#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
	vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
	#include <transmission_fragment>
	vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
	#ifdef USE_SHEEN
		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
	#endif
	#ifdef USE_CLEARCOAT
		float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
		vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
		outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
	#endif
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,Ww=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,Xw=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,Yw=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
	varying vec2 vUv;
	uniform mat3 uvTransform;
#endif
void main() {
	#ifdef USE_POINTS_UV
		vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	#endif
	#include <color_vertex>
	#include <morphinstance_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`,jw=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,qw=`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <batching_vertex>
	#include <beginnormal_vertex>
	#include <morphinstance_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,Kw=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	#include <logdepthbuf_fragment>
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`,Zw=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix[ 3 ];
	vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,Jw=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <alphahash_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <opaque_fragment>
	#include <tonemapping_fragment>
	#include <colorspace_fragment>
	#include <fog_fragment>
}`,Tt={alphahash_fragment:vA,alphahash_pars_fragment:bA,alphamap_fragment:_A,alphamap_pars_fragment:EA,alphatest_fragment:MA,alphatest_pars_fragment:SA,aomap_fragment:TA,aomap_pars_fragment:AA,batching_pars_vertex:wA,batching_vertex:RA,begin_vertex:CA,beginnormal_vertex:PA,bsdfs:IA,iridescence_fragment:NA,bumpmap_pars_fragment:LA,clipping_planes_fragment:OA,clipping_planes_pars_fragment:DA,clipping_planes_pars_vertex:FA,clipping_planes_vertex:UA,color_fragment:kA,color_pars_fragment:BA,color_pars_vertex:zA,color_vertex:VA,common:HA,cube_uv_reflection_fragment:GA,defaultnormal_vertex:WA,displacementmap_pars_vertex:XA,displacementmap_vertex:YA,emissivemap_fragment:jA,emissivemap_pars_fragment:qA,colorspace_fragment:KA,colorspace_pars_fragment:ZA,envmap_fragment:JA,envmap_common_pars_fragment:QA,envmap_pars_fragment:$A,envmap_pars_vertex:e1,envmap_physical_pars_fragment:h1,envmap_vertex:t1,fog_vertex:n1,fog_pars_vertex:i1,fog_fragment:r1,fog_pars_fragment:s1,gradientmap_pars_fragment:o1,lightmap_pars_fragment:a1,lights_lambert_fragment:c1,lights_lambert_pars_fragment:l1,lights_pars_begin:u1,lights_toon_fragment:d1,lights_toon_pars_fragment:f1,lights_phong_fragment:p1,lights_phong_pars_fragment:m1,lights_physical_fragment:g1,lights_physical_pars_fragment:y1,lights_fragment_begin:x1,lights_fragment_maps:v1,lights_fragment_end:b1,logdepthbuf_fragment:_1,logdepthbuf_pars_fragment:E1,logdepthbuf_pars_vertex:M1,logdepthbuf_vertex:S1,map_fragment:T1,map_pars_fragment:A1,map_particle_fragment:w1,map_particle_pars_fragment:R1,metalnessmap_fragment:C1,metalnessmap_pars_fragment:P1,morphinstance_vertex:I1,morphcolor_vertex:N1,morphnormal_vertex:L1,morphtarget_pars_vertex:O1,morphtarget_vertex:D1,normal_fragment_begin:F1,normal_fragment_maps:U1,normal_pars_fragment:k1,normal_pars_vertex:B1,normal_vertex:z1,normalmap_pars_fragment:V1,clearcoat_normal_fragment_begin:H1,clearcoat_normal_fragment_maps:G1,clearcoat_pars_fragment:W1,iridescence_pars_fragment:X1,opaque_fragment:Y1,packing:j1,premultiplied_alpha_fragment:q1,project_vertex:K1,dithering_fragment:Z1,dithering_pars_fragment:J1,roughnessmap_fragment:Q1,roughnessmap_pars_fragment:$1,shadowmap_pars_fragment:ew,shadowmap_pars_vertex:tw,shadowmap_vertex:nw,shadowmask_pars_fragment:iw,skinbase_vertex:rw,skinning_pars_vertex:sw,skinning_vertex:ow,skinnormal_vertex:aw,specularmap_fragment:cw,specularmap_pars_fragment:lw,tonemapping_fragment:uw,tonemapping_pars_fragment:hw,transmission_fragment:dw,transmission_pars_fragment:fw,uv_pars_fragment:pw,uv_pars_vertex:mw,uv_vertex:gw,worldpos_vertex:yw,background_vert:xw,background_frag:vw,backgroundCube_vert:bw,backgroundCube_frag:_w,cube_vert:Ew,cube_frag:Mw,depth_vert:Sw,depth_frag:Tw,distanceRGBA_vert:Aw,distanceRGBA_frag:ww,equirect_vert:Rw,equirect_frag:Cw,linedashed_vert:Pw,linedashed_frag:Iw,meshbasic_vert:Nw,meshbasic_frag:Lw,meshlambert_vert:Ow,meshlambert_frag:Dw,meshmatcap_vert:Fw,meshmatcap_frag:Uw,meshnormal_vert:kw,meshnormal_frag:Bw,meshphong_vert:zw,meshphong_frag:Vw,meshphysical_vert:Hw,meshphysical_frag:Gw,meshtoon_vert:Ww,meshtoon_frag:Xw,points_vert:Yw,points_frag:jw,shadow_vert:qw,shadow_frag:Kw,sprite_vert:Zw,sprite_frag:Jw},Ze={common:{diffuse:{value:new Be(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new yt},alphaMap:{value:null},alphaMapTransform:{value:new yt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new yt}},envmap:{envMap:{value:null},envMapRotation:{value:new yt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new yt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new yt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new yt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new yt},normalScale:{value:new Ce(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new yt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new yt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new yt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new yt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Be(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Be(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new yt},alphaTest:{value:0},uvTransform:{value:new yt}},sprite:{diffuse:{value:new Be(16777215)},opacity:{value:1},center:{value:new Ce(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new yt},alphaMap:{value:null},alphaMapTransform:{value:new yt},alphaTest:{value:0}}},hr={basic:{uniforms:$n([Ze.common,Ze.specularmap,Ze.envmap,Ze.aomap,Ze.lightmap,Ze.fog]),vertexShader:Tt.meshbasic_vert,fragmentShader:Tt.meshbasic_frag},lambert:{uniforms:$n([Ze.common,Ze.specularmap,Ze.envmap,Ze.aomap,Ze.lightmap,Ze.emissivemap,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.fog,Ze.lights,{emissive:{value:new Be(0)}}]),vertexShader:Tt.meshlambert_vert,fragmentShader:Tt.meshlambert_frag},phong:{uniforms:$n([Ze.common,Ze.specularmap,Ze.envmap,Ze.aomap,Ze.lightmap,Ze.emissivemap,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.fog,Ze.lights,{emissive:{value:new Be(0)},specular:{value:new Be(1118481)},shininess:{value:30}}]),vertexShader:Tt.meshphong_vert,fragmentShader:Tt.meshphong_frag},standard:{uniforms:$n([Ze.common,Ze.envmap,Ze.aomap,Ze.lightmap,Ze.emissivemap,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.roughnessmap,Ze.metalnessmap,Ze.fog,Ze.lights,{emissive:{value:new Be(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Tt.meshphysical_vert,fragmentShader:Tt.meshphysical_frag},toon:{uniforms:$n([Ze.common,Ze.aomap,Ze.lightmap,Ze.emissivemap,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.gradientmap,Ze.fog,Ze.lights,{emissive:{value:new Be(0)}}]),vertexShader:Tt.meshtoon_vert,fragmentShader:Tt.meshtoon_frag},matcap:{uniforms:$n([Ze.common,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,Ze.fog,{matcap:{value:null}}]),vertexShader:Tt.meshmatcap_vert,fragmentShader:Tt.meshmatcap_frag},points:{uniforms:$n([Ze.points,Ze.fog]),vertexShader:Tt.points_vert,fragmentShader:Tt.points_frag},dashed:{uniforms:$n([Ze.common,Ze.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Tt.linedashed_vert,fragmentShader:Tt.linedashed_frag},depth:{uniforms:$n([Ze.common,Ze.displacementmap]),vertexShader:Tt.depth_vert,fragmentShader:Tt.depth_frag},normal:{uniforms:$n([Ze.common,Ze.bumpmap,Ze.normalmap,Ze.displacementmap,{opacity:{value:1}}]),vertexShader:Tt.meshnormal_vert,fragmentShader:Tt.meshnormal_frag},sprite:{uniforms:$n([Ze.sprite,Ze.fog]),vertexShader:Tt.sprite_vert,fragmentShader:Tt.sprite_frag},background:{uniforms:{uvTransform:{value:new yt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Tt.background_vert,fragmentShader:Tt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new yt}},vertexShader:Tt.backgroundCube_vert,fragmentShader:Tt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Tt.cube_vert,fragmentShader:Tt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Tt.equirect_vert,fragmentShader:Tt.equirect_frag},distanceRGBA:{uniforms:$n([Ze.common,Ze.displacementmap,{referencePosition:{value:new q},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Tt.distanceRGBA_vert,fragmentShader:Tt.distanceRGBA_frag},shadow:{uniforms:$n([Ze.lights,Ze.fog,{color:{value:new Be(0)},opacity:{value:1}}]),vertexShader:Tt.shadow_vert,fragmentShader:Tt.shadow_frag}};hr.physical={uniforms:$n([hr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new yt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new yt},clearcoatNormalScale:{value:new Ce(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new yt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new yt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new yt},sheen:{value:0},sheenColor:{value:new Be(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new yt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new yt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new yt},transmissionSamplerSize:{value:new Ce},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new yt},attenuationDistance:{value:0},attenuationColor:{value:new Be(0)},specularColor:{value:new Be(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new yt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new yt},anisotropyVector:{value:new Ce},anisotropyMap:{value:null},anisotropyMapTransform:{value:new yt}}]),vertexShader:Tt.meshphysical_vert,fragmentShader:Tt.meshphysical_frag};var wp={r:0,b:0,g:0},ea=new xi,Qw=new nt;function $w(i,e,t,n,r,s,o){let a=new Be(0),c=s===!0?0:1,l,u,h=null,d=0,m=null;function g(b){let x=b.isScene===!0?b.background:null;return x&&x.isTexture&&(x=(b.backgroundBlurriness>0?t:e).get(x)),x}function y(b){let x=!1,_=g(b);_===null?p(a,c):_&&_.isColor&&(p(_,1),x=!0);let T=i.xr.getEnvironmentBlendMode();T==="additive"?n.buffers.color.setClear(0,0,0,1,o):T==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,o),(i.autoClear||x)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function f(b,x){let _=g(x);_&&(_.isCubeTexture||_.mapping===Ko)?(u===void 0&&(u=new ct(new Qn(1,1,1),new $t({name:"BackgroundCubeMaterial",uniforms:$o(hr.backgroundCube.uniforms),vertexShader:hr.backgroundCube.vertexShader,fragmentShader:hr.backgroundCube.fragmentShader,side:un,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute("normal"),u.geometry.deleteAttribute("uv"),u.onBeforeRender=function(T,w,A){this.matrixWorld.copyPosition(A.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(u)),ea.copy(x.backgroundRotation),ea.x*=-1,ea.y*=-1,ea.z*=-1,_.isCubeTexture&&_.isRenderTargetTexture===!1&&(ea.y*=-1,ea.z*=-1),u.material.uniforms.envMap.value=_,u.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,u.material.uniforms.backgroundRotation.value.setFromMatrix4(Qw.makeRotationFromEuler(ea)),u.material.toneMapped=bt.getTransfer(_.colorSpace)!==kt,(h!==_||d!==_.version||m!==i.toneMapping)&&(u.material.needsUpdate=!0,h=_,d=_.version,m=i.toneMapping),u.layers.enableAll(),b.unshift(u,u.geometry,u.material,0,0,null)):_&&_.isTexture&&(l===void 0&&(l=new ct(new Ar(2,2),new $t({name:"BackgroundMaterial",uniforms:$o(hr.background.uniforms),vertexShader:hr.background.vertexShader,fragmentShader:hr.background.fragmentShader,side:Jn,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,l.material.toneMapped=bt.getTransfer(_.colorSpace)!==kt,_.matrixAutoUpdate===!0&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(h!==_||d!==_.version||m!==i.toneMapping)&&(l.material.needsUpdate=!0,h=_,d=_.version,m=i.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function p(b,x){b.getRGB(wp,N0(i)),n.buffers.color.setClear(wp.r,wp.g,wp.b,x,o)}function v(){u!==void 0&&(u.geometry.dispose(),u.material.dispose()),l!==void 0&&(l.geometry.dispose(),l.material.dispose())}return{getClearColor:function(){return a},setClearColor:function(b,x=1){a.set(b),c=x,p(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(b){c=b,p(a,c)},render:y,addToRenderList:f,dispose:v}}function eR(i,e){let t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=d(null),s=r,o=!1;function a(M,P,N,L,D){let $=!1,U=h(L,N,P);s!==U&&(s=U,l(s.object)),$=m(M,L,N,D),$&&g(M,L,N,D),D!==null&&e.update(D,i.ELEMENT_ARRAY_BUFFER),($||o)&&(o=!1,x(M,P,N,L),D!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(D).buffer))}function c(){return i.createVertexArray()}function l(M){return i.bindVertexArray(M)}function u(M){return i.deleteVertexArray(M)}function h(M,P,N){let L=N.wireframe===!0,D=n[M.id];D===void 0&&(D={},n[M.id]=D);let $=D[P.id];$===void 0&&($={},D[P.id]=$);let U=$[L];return U===void 0&&(U=d(c()),$[L]=U),U}function d(M){let P=[],N=[],L=[];for(let D=0;D<t;D++)P[D]=0,N[D]=0,L[D]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:N,attributeDivisors:L,object:M,attributes:{},index:null}}function m(M,P,N,L){let D=s.attributes,$=P.attributes,U=0,I=N.getAttributes();for(let V in I)if(I[V].location>=0){let Q=D[V],se=$[V];if(se===void 0&&(V==="instanceMatrix"&&M.instanceMatrix&&(se=M.instanceMatrix),V==="instanceColor"&&M.instanceColor&&(se=M.instanceColor)),Q===void 0||Q.attribute!==se||se&&Q.data!==se.data)return!0;U++}return s.attributesNum!==U||s.index!==L}function g(M,P,N,L){let D={},$=P.attributes,U=0,I=N.getAttributes();for(let V in I)if(I[V].location>=0){let Q=$[V];Q===void 0&&(V==="instanceMatrix"&&M.instanceMatrix&&(Q=M.instanceMatrix),V==="instanceColor"&&M.instanceColor&&(Q=M.instanceColor));let se={};se.attribute=Q,Q&&Q.data&&(se.data=Q.data),D[V]=se,U++}s.attributes=D,s.attributesNum=U,s.index=L}function y(){let M=s.newAttributes;for(let P=0,N=M.length;P<N;P++)M[P]=0}function f(M){p(M,0)}function p(M,P){let N=s.newAttributes,L=s.enabledAttributes,D=s.attributeDivisors;N[M]=1,L[M]===0&&(i.enableVertexAttribArray(M),L[M]=1),D[M]!==P&&(i.vertexAttribDivisor(M,P),D[M]=P)}function v(){let M=s.newAttributes,P=s.enabledAttributes;for(let N=0,L=P.length;N<L;N++)P[N]!==M[N]&&(i.disableVertexAttribArray(N),P[N]=0)}function b(M,P,N,L,D,$,U){U===!0?i.vertexAttribIPointer(M,P,N,D,$):i.vertexAttribPointer(M,P,N,L,D,$)}function x(M,P,N,L){y();let D=L.attributes,$=N.getAttributes(),U=P.defaultAttributeValues;for(let I in $){let V=$[I];if(V.location>=0){let W=D[I];if(W===void 0&&(I==="instanceMatrix"&&M.instanceMatrix&&(W=M.instanceMatrix),I==="instanceColor"&&M.instanceColor&&(W=M.instanceColor)),W!==void 0){let Q=W.normalized,se=W.itemSize,oe=e.get(W);if(oe===void 0)continue;let ge=oe.buffer,O=oe.type,S=oe.bytesPerElement,R=O===i.INT||O===i.UNSIGNED_INT||W.gpuType===Vu;if(W.isInterleavedBufferAttribute){let z=W.data,Y=z.stride,K=W.offset;if(z.isInstancedInterleavedBuffer){for(let re=0;re<V.locationSize;re++)p(V.location+re,z.meshPerAttribute);M.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=z.meshPerAttribute*z.count)}else for(let re=0;re<V.locationSize;re++)f(V.location+re);i.bindBuffer(i.ARRAY_BUFFER,ge);for(let re=0;re<V.locationSize;re++)b(V.location+re,se/V.locationSize,O,Q,Y*S,(K+se/V.locationSize*re)*S,R)}else{if(W.isInstancedBufferAttribute){for(let z=0;z<V.locationSize;z++)p(V.location+z,W.meshPerAttribute);M.isInstancedMesh!==!0&&L._maxInstanceCount===void 0&&(L._maxInstanceCount=W.meshPerAttribute*W.count)}else for(let z=0;z<V.locationSize;z++)f(V.location+z);i.bindBuffer(i.ARRAY_BUFFER,ge);for(let z=0;z<V.locationSize;z++)b(V.location+z,se/V.locationSize,O,Q,se*S,se/V.locationSize*z*S,R)}}else if(U!==void 0){let Q=U[I];if(Q!==void 0)switch(Q.length){case 2:i.vertexAttrib2fv(V.location,Q);break;case 3:i.vertexAttrib3fv(V.location,Q);break;case 4:i.vertexAttrib4fv(V.location,Q);break;default:i.vertexAttrib1fv(V.location,Q)}}}}v()}function _(){A();for(let M in n){let P=n[M];for(let N in P){let L=P[N];for(let D in L)u(L[D].object),delete L[D];delete P[N]}delete n[M]}}function T(M){if(n[M.id]===void 0)return;let P=n[M.id];for(let N in P){let L=P[N];for(let D in L)u(L[D].object),delete L[D];delete P[N]}delete n[M.id]}function w(M){for(let P in n){let N=n[P];if(N[M.id]===void 0)continue;let L=N[M.id];for(let D in L)u(L[D].object),delete L[D];delete N[M.id]}}function A(){E(),o=!0,s!==r&&(s=r,l(s.object))}function E(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:a,reset:A,resetDefaultState:E,dispose:_,releaseStatesOfGeometry:T,releaseStatesOfProgram:w,initAttributes:y,enableAttribute:f,disableUnusedAttributes:v}}function tR(i,e,t){let n;function r(l){n=l}function s(l,u){i.drawArrays(n,l,u),t.update(u,n,1)}function o(l,u,h){h!==0&&(i.drawArraysInstanced(n,l,u,h),t.update(u,n,h))}function a(l,u,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,u,0,h);let m=0;for(let g=0;g<h;g++)m+=u[g];t.update(m,n,1)}function c(l,u,h,d){if(h===0)return;let m=e.get("WEBGL_multi_draw");if(m===null)for(let g=0;g<l.length;g++)o(l[g],u[g],d[g]);else{m.multiDrawArraysInstancedWEBGL(n,l,0,u,0,d,0,h);let g=0;for(let y=0;y<h;y++)g+=u[y]*d[y];t.update(g,n,1)}}this.setMode=r,this.render=s,this.renderInstances=o,this.renderMultiDraw=a,this.renderMultiDrawInstances=c}function nR(i,e,t,n){let r;function s(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){let w=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(w.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function o(w){return!(w!==Ln&&n.convert(w)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function a(w){let A=w===Hn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(w!==ci&&n.convert(w)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&w!==si&&!A)}function c(w){if(w==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=t.precision!==void 0?t.precision:"highp",u=c(l);u!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",u,"instead."),l=u);let h=t.logarithmicDepthBuffer===!0,d=t.reverseDepthBuffer===!0&&e.has("EXT_clip_control"),m=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=i.getParameter(i.MAX_TEXTURE_SIZE),f=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),v=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),b=i.getParameter(i.MAX_VARYING_VECTORS),x=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),_=g>0,T=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:a,precision:l,logarithmicDepthBuffer:h,reverseDepthBuffer:d,maxTextures:m,maxVertexTextures:g,maxTextureSize:y,maxCubemapSize:f,maxAttributes:p,maxVertexUniforms:v,maxVaryings:b,maxFragmentUniforms:x,vertexTextures:_,maxSamples:T}}function iR(i){let e=this,t=null,n=0,r=!1,s=!1,o=new Li,a=new yt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,d){let m=h.length!==0||d||n!==0||r;return r=d,n=h.length,m},this.beginShadows=function(){s=!0,u(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,d){t=u(h,d,0)},this.setState=function(h,d,m){let g=h.clippingPlanes,y=h.clipIntersection,f=h.clipShadows,p=i.get(h);if(!r||g===null||g.length===0||s&&!f)s?u(null):l();else{let v=s?0:n,b=v*4,x=p.clippingState||null;c.value=x,x=u(g,d,b,m);for(let _=0;_!==b;++_)x[_]=t[_];p.clippingState=x,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=v}};function l(){c.value!==t&&(c.value=t,c.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(h,d,m,g){let y=h!==null?h.length:0,f=null;if(y!==0){if(f=c.value,g!==!0||f===null){let p=m+y*4,v=d.matrixWorldInverse;a.getNormalMatrix(v),(f===null||f.length<p)&&(f=new Float32Array(p));for(let b=0,x=m;b!==y;++b,x+=4)o.copy(h[b]).applyMatrix4(v,a),o.normal.toArray(f,x),f[x+3]=o.constant}c.value=f,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,f}}function rR(i){let e=new WeakMap;function t(o,a){return a===_c?o.mapping=Nr:a===Ec&&(o.mapping=us),o}function n(o){if(o&&o.isTexture){let a=o.mapping;if(a===_c||a===Ec)if(e.has(o)){let c=e.get(o).texture;return t(c,o.mapping)}else{let c=o.image;if(c&&c.height>0){let l=new Fl(c.height);return l.fromEquirectangularTexture(i,o),e.set(o,l),o.addEventListener("dispose",r),t(l.texture,o.mapping)}else return null}}return o}function r(o){let a=o.target;a.removeEventListener("dispose",r);let c=e.get(a);c!==void 0&&(e.delete(a),c.dispose())}function s(){e=new WeakMap}return{get:n,dispose:s}}var Nc=4,x_=[.125,.215,.35,.446,.526,.582],ia=20,k0=new cr,v_=new Be,B0=null,z0=0,V0=0,H0=!1,na=(1+Math.sqrt(5))/2,Ic=1/na,b_=[new q(-na,Ic,0),new q(na,Ic,0),new q(-Ic,0,na),new q(Ic,0,na),new q(0,na,-Ic),new q(0,na,Ic),new q(-1,1,-1),new q(1,1,-1),new q(-1,1,1),new q(1,1,1)],ra=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){B0=this._renderer.getRenderTarget(),z0=this._renderer.getActiveCubeFace(),V0=this._renderer.getActiveMipmapLevel(),H0=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);let s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(e,n,r,s),t>0&&this._blur(s,0,0,t),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=M_(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=E_(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(B0,z0,V0),this._renderer.xr.enabled=H0,e.scissorTest=!1,Rp(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Nr||e.mapping===us?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),B0=this._renderer.getRenderTarget(),z0=this._renderer.getActiveCubeFace(),V0=this._renderer.getActiveMipmapLevel(),H0=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;let n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){let e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:nn,minFilter:nn,generateMipmaps:!1,type:Hn,format:Ln,colorSpace:On,depthBuffer:!1},r=__(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=__(e,t,n);let{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=sR(s)),this._blurMaterial=oR(s,e,t)}return r}_compileMaterial(e){let t=new ct(this._lodPlanes[0],e);this._renderer.compile(t,k0)}_sceneToCubeUV(e,t,n,r){let a=new jt(90,1,t,n),c=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],u=this._renderer,h=u.autoClear,d=u.toneMapping;u.getClearColor(v_),u.toneMapping=Ir,u.autoClear=!1;let m=new Ht({name:"PMREM.Background",side:un,depthWrite:!1,depthTest:!1}),g=new ct(new Qn,m),y=!1,f=e.background;f?f.isColor&&(m.color.copy(f),e.background=null,y=!0):(m.color.copy(v_),y=!0);for(let p=0;p<6;p++){let v=p%3;v===0?(a.up.set(0,c[p],0),a.lookAt(l[p],0,0)):v===1?(a.up.set(0,0,c[p]),a.lookAt(0,l[p],0)):(a.up.set(0,c[p],0),a.lookAt(0,0,l[p]));let b=this._cubeSize;Rp(r,v*b,p>2?b:0,b,b),u.setRenderTarget(r),y&&u.render(g,a),u.render(e,a)}g.geometry.dispose(),g.material.dispose(),u.toneMapping=d,u.autoClear=h,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===Nr||e.mapping===us;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=M_()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=E_());let s=r?this._cubemapMaterial:this._equirectMaterial,o=new ct(this._lodPlanes[0],s),a=s.uniforms;a.envMap.value=e;let c=this._cubeSize;Rp(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(o,k0)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let r=this._lodPlanes.length;for(let s=1;s<r;s++){let o=Math.sqrt(this._sigmas[s]*this._sigmas[s]-this._sigmas[s-1]*this._sigmas[s-1]),a=b_[(r-s-1)%b_.length];this._blur(e,s-1,s,o,a)}t.autoClear=n}_blur(e,t,n,r,s){let o=this._pingPongRenderTarget;this._halfBlur(e,o,t,n,r,"latitudinal",s),this._halfBlur(o,e,n,n,r,"longitudinal",s)}_halfBlur(e,t,n,r,s,o,a){let c=this._renderer,l=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");let u=3,h=new ct(this._lodPlanes[r],l),d=l.uniforms,m=this._sizeLods[n]-1,g=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*ia-1),y=s/g,f=isFinite(s)?1+Math.floor(u*y):ia;f>ia&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${f} samples when the maximum is set to ${ia}`);let p=[],v=0;for(let w=0;w<ia;++w){let A=w/y,E=Math.exp(-A*A/2);p.push(E),w===0?v+=E:w<f&&(v+=2*E)}for(let w=0;w<p.length;w++)p[w]=p[w]/v;d.envMap.value=e.texture,d.samples.value=f,d.weights.value=p,d.latitudinal.value=o==="latitudinal",a&&(d.poleAxis.value=a);let{_lodMax:b}=this;d.dTheta.value=g,d.mipInt.value=b-n;let x=this._sizeLods[r],_=3*x*(r>b-Nc?r-b+Nc:0),T=4*(this._cubeSize-x);Rp(t,_,T,3*x,2*x),c.setRenderTarget(t),c.render(h,k0)}};function sR(i){let e=[],t=[],n=[],r=i,s=i-Nc+1+x_.length;for(let o=0;o<s;o++){let a=Math.pow(2,r);t.push(a);let c=1/a;o>i-Nc?c=x_[o-i+Nc-1]:o===0&&(c=0),n.push(c);let l=1/(a-2),u=-l,h=1+l,d=[u,u,h,u,h,h,u,u,h,h,u,h],m=6,g=6,y=3,f=2,p=1,v=new Float32Array(y*g*m),b=new Float32Array(f*g*m),x=new Float32Array(p*g*m);for(let T=0;T<m;T++){let w=T%3*2/3-1,A=T>2?0:-1,E=[w,A,0,w+2/3,A,0,w+2/3,A+1,0,w,A,0,w+2/3,A+1,0,w,A+1,0];v.set(E,y*g*T),b.set(d,f*g*T);let M=[T,T,T,T,T,T];x.set(M,p*g*T)}let _=new ot;_.setAttribute("position",new gt(v,y)),_.setAttribute("uv",new gt(b,f)),_.setAttribute("faceIndex",new gt(x,p)),e.push(_),r>Nc&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function __(i,e,t){let n=new on(i,e,t);return n.texture.mapping=Ko,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Rp(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function oR(i,e,t){let n=new Float32Array(ia),r=new q(0,1,0);return new $t({name:"SphericalGaussianBlur",defines:{n:ia,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Q0(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;
			uniform int samples;
			uniform float weights[ n ];
			uniform bool latitudinal;
			uniform float dTheta;
			uniform float mipInt;
			uniform vec3 poleAxis;

			#define ENVMAP_TYPE_CUBE_UV
			#include <cube_uv_reflection_fragment>

			vec3 getSample( float theta, vec3 axis ) {

				float cosTheta = cos( theta );
				// Rodrigues' axis-angle rotation
				vec3 sampleDirection = vOutputDirection * cosTheta
					+ cross( axis, vOutputDirection ) * sin( theta )
					+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );

				return bilinearCubeUV( envMap, sampleDirection, mipInt );

			}

			void main() {

				vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );

				if ( all( equal( axis, vec3( 0.0 ) ) ) ) {

					axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );

				}

				axis = normalize( axis );

				gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
				gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );

				for ( int i = 1; i < n; i++ ) {

					if ( i >= samples ) {

						break;

					}

					float theta = dTheta * float( i );
					gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
					gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );

				}

			}
		`,blending:xn,depthTest:!1,depthWrite:!1})}function E_(){return new $t({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Q0(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;

			#include <common>

			void main() {

				vec3 outputDirection = normalize( vOutputDirection );
				vec2 uv = equirectUv( outputDirection );

				gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );

			}
		`,blending:xn,depthTest:!1,depthWrite:!1})}function M_(){return new $t({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Q0(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			uniform float flipEnvMap;

			varying vec3 vOutputDirection;

			uniform samplerCube envMap;

			void main() {

				gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );

			}
		`,blending:xn,depthTest:!1,depthWrite:!1})}function Q0(){return`

		precision mediump float;
		precision mediump int;

		attribute float faceIndex;

		varying vec3 vOutputDirection;

		// RH coordinate system; PMREM face-indexing convention
		vec3 getDirection( vec2 uv, float face ) {

			uv = 2.0 * uv - 1.0;

			vec3 direction = vec3( uv, 1.0 );

			if ( face == 0.0 ) {

				direction = direction.zyx; // ( 1, v, u ) pos x

			} else if ( face == 1.0 ) {

				direction = direction.xzy;
				direction.xz *= -1.0; // ( -u, 1, -v ) pos y

			} else if ( face == 2.0 ) {

				direction.x *= -1.0; // ( -u, v, 1 ) pos z

			} else if ( face == 3.0 ) {

				direction = direction.zyx;
				direction.xz *= -1.0; // ( -1, v, -u ) neg x

			} else if ( face == 4.0 ) {

				direction = direction.xzy;
				direction.xy *= -1.0; // ( -u, -1, v ) neg y

			} else if ( face == 5.0 ) {

				direction.z *= -1.0; // ( u, v, -1 ) neg z

			}

			return direction;

		}

		void main() {

			vOutputDirection = getDirection( uv, faceIndex );
			gl_Position = vec4( position, 1.0 );

		}
	`}function aR(i){let e=new WeakMap,t=null;function n(a){if(a&&a.isTexture){let c=a.mapping,l=c===_c||c===Ec,u=c===Nr||c===us;if(l||u){let h=e.get(a),d=h!==void 0?h.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==d)return t===null&&(t=new ra(i)),h=l?t.fromEquirectangular(a,h):t.fromCubemap(a,h),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),h.texture;if(h!==void 0)return h.texture;{let m=a.image;return l&&m&&m.height>0||u&&m&&r(m)?(t===null&&(t=new ra(i)),h=l?t.fromEquirectangular(a):t.fromCubemap(a),h.texture.pmremVersion=a.pmremVersion,e.set(a,h),a.addEventListener("dispose",s),h.texture):null}}}return a}function r(a){let c=0,l=6;for(let u=0;u<l;u++)a[u]!==void 0&&c++;return c===l}function s(a){let c=a.target;c.removeEventListener("dispose",s);let l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function cR(i){let e={};function t(n){if(e[n]!==void 0)return e[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return e[n]=r,r}return{has:function(n){return t(n)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(n){let r=t(n);return r===null&&Qo("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function lR(i,e,t,n){let r={},s=new WeakMap;function o(h){let d=h.target;d.index!==null&&e.remove(d.index);for(let g in d.attributes)e.remove(d.attributes[g]);d.removeEventListener("dispose",o),delete r[d.id];let m=s.get(d);m&&(e.remove(m),s.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(h,d){return r[d.id]===!0||(d.addEventListener("dispose",o),r[d.id]=!0,t.memory.geometries++),d}function c(h){let d=h.attributes;for(let m in d)e.update(d[m],i.ARRAY_BUFFER)}function l(h){let d=[],m=h.index,g=h.attributes.position,y=0;if(m!==null){let v=m.array;y=m.version;for(let b=0,x=v.length;b<x;b+=3){let _=v[b+0],T=v[b+1],w=v[b+2];d.push(_,T,T,w,w,_)}}else if(g!==void 0){let v=g.array;y=g.version;for(let b=0,x=v.length/3-1;b<x;b+=3){let _=b+0,T=b+1,w=b+2;d.push(_,T,T,w,w,_)}}else return;let f=new(P0(d)?nc:tc)(d,1);f.version=y;let p=s.get(h);p&&e.remove(p),s.set(h,f)}function u(h){let d=s.get(h);if(d){let m=h.index;m!==null&&d.version<m.version&&l(h)}else l(h);return s.get(h)}return{get:a,update:c,getWireframeAttribute:u}}function uR(i,e,t){let n;function r(d){n=d}let s,o;function a(d){s=d.type,o=d.bytesPerElement}function c(d,m){i.drawElements(n,m,s,d*o),t.update(m,n,1)}function l(d,m,g){g!==0&&(i.drawElementsInstanced(n,m,s,d*o,g),t.update(m,n,g))}function u(d,m,g){if(g===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,m,0,s,d,0,g);let f=0;for(let p=0;p<g;p++)f+=m[p];t.update(f,n,1)}function h(d,m,g,y){if(g===0)return;let f=e.get("WEBGL_multi_draw");if(f===null)for(let p=0;p<d.length;p++)l(d[p]/o,m[p],y[p]);else{f.multiDrawElementsInstancedWEBGL(n,m,0,s,d,0,y,0,g);let p=0;for(let v=0;v<g;v++)p+=m[v]*y[v];t.update(p,n,1)}}this.setMode=r,this.setIndex=a,this.render=c,this.renderInstances=l,this.renderMultiDraw=u,this.renderMultiDrawInstances=h}function hR(i){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(s,o,a){switch(t.calls++,o){case i.TRIANGLES:t.triangles+=a*(s/3);break;case i.LINES:t.lines+=a*(s/2);break;case i.LINE_STRIP:t.lines+=a*(s-1);break;case i.LINE_LOOP:t.lines+=a*s;break;case i.POINTS:t.points+=a*s;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",o);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function dR(i,e,t){let n=new WeakMap,r=new It;function s(o,a,c){let l=o.morphTargetInfluences,u=a.morphAttributes.position||a.morphAttributes.normal||a.morphAttributes.color,h=u!==void 0?u.length:0,d=n.get(a);if(d===void 0||d.count!==h){let E=function(){w.dispose(),n.delete(a),a.removeEventListener("dispose",E)};d!==void 0&&d.texture.dispose();let m=a.morphAttributes.position!==void 0,g=a.morphAttributes.normal!==void 0,y=a.morphAttributes.color!==void 0,f=a.morphAttributes.position||[],p=a.morphAttributes.normal||[],v=a.morphAttributes.color||[],b=0;m===!0&&(b=1),g===!0&&(b=2),y===!0&&(b=3);let x=a.attributes.position.count*b,_=1;x>e.maxTextureSize&&(_=Math.ceil(x/e.maxTextureSize),x=e.maxTextureSize);let T=new Float32Array(x*_*4*h),w=new Io(T,x,_,h);w.type=si,w.needsUpdate=!0;let A=b*4;for(let M=0;M<h;M++){let P=f[M],N=p[M],L=v[M],D=x*_*4*M;for(let $=0;$<P.count;$++){let U=$*A;m===!0&&(r.fromBufferAttribute(P,$),T[D+U+0]=r.x,T[D+U+1]=r.y,T[D+U+2]=r.z,T[D+U+3]=0),g===!0&&(r.fromBufferAttribute(N,$),T[D+U+4]=r.x,T[D+U+5]=r.y,T[D+U+6]=r.z,T[D+U+7]=0),y===!0&&(r.fromBufferAttribute(L,$),T[D+U+8]=r.x,T[D+U+9]=r.y,T[D+U+10]=r.z,T[D+U+11]=L.itemSize===4?r.w:1)}}d={count:h,texture:w,size:new Ce(x,_)},n.set(a,d),a.addEventListener("dispose",E)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",o.morphTexture,t);else{let m=0;for(let y=0;y<l.length;y++)m+=l[y];let g=a.morphTargetsRelative?1:1-m;c.getUniforms().setValue(i,"morphTargetBaseInfluence",g),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,t),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:s}}function fR(i,e,t,n){let r=new WeakMap;function s(c){let l=n.render.frame,u=c.geometry,h=e.get(c,u);if(r.get(h)!==l&&(e.update(h),r.set(h,l)),c.isInstancedMesh&&(c.hasEventListener("dispose",a)===!1&&c.addEventListener("dispose",a),r.get(c)!==l&&(t.update(c.instanceMatrix,i.ARRAY_BUFFER),c.instanceColor!==null&&t.update(c.instanceColor,i.ARRAY_BUFFER),r.set(c,l))),c.isSkinnedMesh){let d=c.skeleton;r.get(d)!==l&&(d.update(),r.set(d,l))}return h}function o(){r=new WeakMap}function a(c){let l=c.target;l.removeEventListener("dispose",a),t.remove(l.instanceMatrix),l.instanceColor!==null&&t.remove(l.instanceColor)}return{update:s,dispose:o}}var H_=new Qt,S_=new Xs(1,1),G_=new Io,W_=new ec,X_=new Vs,T_=[],A_=[],w_=new Float32Array(16),R_=new Float32Array(9),C_=new Float32Array(4);function Oc(i,e,t){let n=i[0];if(n<=0||n>0)return i;let r=e*t,s=T_[r];if(s===void 0&&(s=new Float32Array(r),T_[r]=s),e!==0){n.toArray(s,0);for(let o=1,a=0;o!==e;++o)a+=t,i[o].toArray(s,a)}return s}function wn(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function Rn(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Pp(i,e){let t=A_[e];t===void 0&&(t=new Int32Array(e),A_[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function pR(i,e){let t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function mR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(wn(t,e))return;i.uniform2fv(this.addr,e),Rn(t,e)}}function gR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(wn(t,e))return;i.uniform3fv(this.addr,e),Rn(t,e)}}function yR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(wn(t,e))return;i.uniform4fv(this.addr,e),Rn(t,e)}}function xR(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(wn(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),Rn(t,e)}else{if(wn(t,n))return;C_.set(n),i.uniformMatrix2fv(this.addr,!1,C_),Rn(t,n)}}function vR(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(wn(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),Rn(t,e)}else{if(wn(t,n))return;R_.set(n),i.uniformMatrix3fv(this.addr,!1,R_),Rn(t,n)}}function bR(i,e){let t=this.cache,n=e.elements;if(n===void 0){if(wn(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),Rn(t,e)}else{if(wn(t,n))return;w_.set(n),i.uniformMatrix4fv(this.addr,!1,w_),Rn(t,n)}}function _R(i,e){let t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function ER(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(wn(t,e))return;i.uniform2iv(this.addr,e),Rn(t,e)}}function MR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(wn(t,e))return;i.uniform3iv(this.addr,e),Rn(t,e)}}function SR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(wn(t,e))return;i.uniform4iv(this.addr,e),Rn(t,e)}}function TR(i,e){let t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function AR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(wn(t,e))return;i.uniform2uiv(this.addr,e),Rn(t,e)}}function wR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(wn(t,e))return;i.uniform3uiv(this.addr,e),Rn(t,e)}}function RR(i,e){let t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(wn(t,e))return;i.uniform4uiv(this.addr,e),Rn(t,e)}}function CR(i,e,t){let n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let s;this.type===i.SAMPLER_2D_SHADOW?(S_.compareFunction=Ep,s=S_):s=H_,t.setTexture2D(e||s,r)}function PR(i,e,t){let n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||W_,r)}function IR(i,e,t){let n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||X_,r)}function NR(i,e,t){let n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||G_,r)}function LR(i){switch(i){case 5126:return pR;case 35664:return mR;case 35665:return gR;case 35666:return yR;case 35674:return xR;case 35675:return vR;case 35676:return bR;case 5124:case 35670:return _R;case 35667:case 35671:return ER;case 35668:case 35672:return MR;case 35669:case 35673:return SR;case 5125:return TR;case 36294:return AR;case 36295:return wR;case 36296:return RR;case 35678:case 36198:case 36298:case 36306:case 35682:return CR;case 35679:case 36299:case 36307:return PR;case 35680:case 36300:case 36308:case 36293:return IR;case 36289:case 36303:case 36311:case 36292:return NR}}function OR(i,e){i.uniform1fv(this.addr,e)}function DR(i,e){let t=Oc(e,this.size,2);i.uniform2fv(this.addr,t)}function FR(i,e){let t=Oc(e,this.size,3);i.uniform3fv(this.addr,t)}function UR(i,e){let t=Oc(e,this.size,4);i.uniform4fv(this.addr,t)}function kR(i,e){let t=Oc(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function BR(i,e){let t=Oc(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function zR(i,e){let t=Oc(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function VR(i,e){i.uniform1iv(this.addr,e)}function HR(i,e){i.uniform2iv(this.addr,e)}function GR(i,e){i.uniform3iv(this.addr,e)}function WR(i,e){i.uniform4iv(this.addr,e)}function XR(i,e){i.uniform1uiv(this.addr,e)}function YR(i,e){i.uniform2uiv(this.addr,e)}function jR(i,e){i.uniform3uiv(this.addr,e)}function qR(i,e){i.uniform4uiv(this.addr,e)}function KR(i,e,t){let n=this.cache,r=e.length,s=Pp(t,r);wn(n,s)||(i.uniform1iv(this.addr,s),Rn(n,s));for(let o=0;o!==r;++o)t.setTexture2D(e[o]||H_,s[o])}function ZR(i,e,t){let n=this.cache,r=e.length,s=Pp(t,r);wn(n,s)||(i.uniform1iv(this.addr,s),Rn(n,s));for(let o=0;o!==r;++o)t.setTexture3D(e[o]||W_,s[o])}function JR(i,e,t){let n=this.cache,r=e.length,s=Pp(t,r);wn(n,s)||(i.uniform1iv(this.addr,s),Rn(n,s));for(let o=0;o!==r;++o)t.setTextureCube(e[o]||X_,s[o])}function QR(i,e,t){let n=this.cache,r=e.length,s=Pp(t,r);wn(n,s)||(i.uniform1iv(this.addr,s),Rn(n,s));for(let o=0;o!==r;++o)t.setTexture2DArray(e[o]||G_,s[o])}function $R(i){switch(i){case 5126:return OR;case 35664:return DR;case 35665:return FR;case 35666:return UR;case 35674:return kR;case 35675:return BR;case 35676:return zR;case 5124:case 35670:return VR;case 35667:case 35671:return HR;case 35668:case 35672:return GR;case 35669:case 35673:return WR;case 5125:return XR;case 36294:return YR;case 36295:return jR;case 36296:return qR;case 35678:case 36198:case 36298:case 36306:case 35682:return KR;case 35679:case 36299:case 36307:return ZR;case 35680:case 36300:case 36308:case 36293:return JR;case 36289:case 36303:case 36311:case 36292:return QR}}var W0=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=LR(t.type)}},X0=class{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=$R(t.type)}},Y0=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){let r=this.seq;for(let s=0,o=r.length;s!==o;++s){let a=r[s];a.setValue(e,t[a.id],n)}}},G0=/(\w+)(\])?(\[|\.)?/g;function P_(i,e){i.seq.push(e),i.map[e.id]=e}function eC(i,e,t){let n=i.name,r=n.length;for(G0.lastIndex=0;;){let s=G0.exec(n),o=G0.lastIndex,a=s[1],c=s[2]==="]",l=s[3];if(c&&(a=a|0),l===void 0||l==="["&&o+2===r){P_(t,l===void 0?new W0(a,i,e):new X0(a,i,e));break}else{let h=t.map[a];h===void 0&&(h=new Y0(a),P_(t,h)),t=h}}}var Lc=class{constructor(e,t){this.seq=[],this.map={};let n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){let s=e.getActiveUniform(t,r),o=e.getUniformLocation(t,s.name);eC(s,o,this)}}setValue(e,t,n,r){let s=this.map[t];s!==void 0&&s.setValue(e,n,r)}setOptional(e,t,n){let r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let s=0,o=t.length;s!==o;++s){let a=t[s],c=n[a.id];c.needsUpdate!==!1&&a.setValue(e,c.value,r)}}static seqWithValue(e,t){let n=[];for(let r=0,s=e.length;r!==s;++r){let o=e[r];o.id in t&&n.push(o)}return n}};function I_(i,e,t){let n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}var tC=37297,nC=0;function iC(i,e){let t=i.split(`
`),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o<s;o++){let a=o+1;n.push(`${a===e?">":" "} ${a}: ${t[o]}`)}return n.join(`
`)}var N_=new yt;function rC(i){bt._getMatrix(N_,bt.workingColorSpace,i);let e=`mat3( ${N_.elements.map(t=>t.toFixed(4))} )`;switch(bt.getTransfer(i)){case Za:return[e,"LinearTransferOETF"];case kt:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function L_(i,e,t){let n=i.getShaderParameter(e,i.COMPILE_STATUS),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";let s=/ERROR: 0:(\d+)/.exec(r);if(s){let o=parseInt(s[1]);return t.toUpperCase()+`

`+r+`

`+iC(i.getShaderSource(e),o)}else return r}function sC(i,e){let t=rC(e);return[`vec4 ${i}( vec4 value ) {`,`	return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
`)}function oC(i,e){let t;switch(e){case Du:t="Linear";break;case Fu:t="Reinhard";break;case Uu:t="Cineon";break;case qo:t="ACESFilmic";break;case ku:t="AgX";break;case Bu:t="Neutral";break;case p0:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}var Cp=new q;function aC(){bt.getLuminanceCoefficients(Cp);let i=Cp.x.toFixed(4),e=Cp.y.toFixed(4),t=Cp.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",`	const vec3 weights = vec3( ${i}, ${e}, ${t} );`,"	return dot( weights, rgb );","}"].join(`
`)}function cC(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(bh).join(`
`)}function lC(i){let e=[];for(let t in i){let n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
`)}function uC(i,e){let t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){let s=i.getActiveAttrib(e,r),o=s.name,a=1;s.type===i.FLOAT_MAT2&&(a=2),s.type===i.FLOAT_MAT3&&(a=3),s.type===i.FLOAT_MAT4&&(a=4),t[o]={type:s.type,location:i.getAttribLocation(e,o),locationSize:a}}return t}function bh(i){return i!==""}function O_(i,e){let t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function D_(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var hC=/^[ \t]*#include +<([\w\d./]+)>/gm;function j0(i){return i.replace(hC,fC)}var dC=new Map;function fC(i,e){let t=Tt[e];if(t===void 0){let n=dC.get(e);if(n!==void 0)t=Tt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return j0(t)}var pC=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function F_(i){return i.replace(pC,mC)}function mC(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function U_(i){let e=`precision ${i.precision} float;
	precision ${i.precision} int;
	precision ${i.precision} sampler2D;
	precision ${i.precision} samplerCube;
	precision ${i.precision} sampler3D;
	precision ${i.precision} sampler2DArray;
	precision ${i.precision} sampler2DShadow;
	precision ${i.precision} samplerCubeShadow;
	precision ${i.precision} sampler2DArrayShadow;
	precision ${i.precision} isampler2D;
	precision ${i.precision} isampler3D;
	precision ${i.precision} isamplerCube;
	precision ${i.precision} isampler2DArray;
	precision ${i.precision} usampler2D;
	precision ${i.precision} usampler3D;
	precision ${i.precision} usamplerCube;
	precision ${i.precision} usampler2DArray;
	`;return i.precision==="highp"?e+=`
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function gC(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===ap?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===Au?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===ur&&(e="SHADOWMAP_TYPE_VSM"),e}function yC(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Nr:case us:e="ENVMAP_TYPE_CUBE";break;case Ko:e="ENVMAP_TYPE_CUBE_UV";break}return e}function xC(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case us:e="ENVMAP_MODE_REFRACTION";break}return e}function vC(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case bc:e="ENVMAP_BLENDING_MULTIPLY";break;case d0:e="ENVMAP_BLENDING_MIX";break;case f0:e="ENVMAP_BLENDING_ADD";break}return e}function bC(i){let e=i.envMapCubeUVHeight;if(e===null)return null;let t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:n,maxMip:t}}function _C(i,e,t,n){let r=i.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,c=gC(t),l=yC(t),u=xC(t),h=vC(t),d=bC(t),m=cC(t),g=lC(s),y=r.createProgram(),f,p,v=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(f=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(bh).join(`
`),f.length>0&&(f+=`
`),p=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g].filter(bh).join(`
`),p.length>0&&(p+=`
`)):(f=[U_(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","	attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","	attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","	uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","	attribute vec2 uv1;","#endif","#ifdef USE_UV2","	attribute vec2 uv2;","#endif","#ifdef USE_UV3","	attribute vec2 uv3;","#endif","#ifdef USE_TANGENT","	attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","	attribute vec4 color;","#elif defined( USE_COLOR )","	attribute vec3 color;","#endif","#ifdef USE_SKINNING","	attribute vec4 skinIndex;","	attribute vec4 skinWeight;","#endif",`
`].filter(bh).join(`
`),p=[U_(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,g,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+u:"",t.envMap?"#define "+h:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.reverseDepthBuffer?"#define USE_REVERSEDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Ir?"#define TONE_MAPPING":"",t.toneMapping!==Ir?Tt.tonemapping_pars_fragment:"",t.toneMapping!==Ir?oC("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Tt.colorspace_pars_fragment,sC("linearToOutputTexel",t.outputColorSpace),aC(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(bh).join(`
`)),o=j0(o),o=O_(o,t),o=D_(o,t),a=j0(a),a=O_(a,t),a=D_(a,t),o=F_(o),a=F_(a),t.isRawShaderMaterial!==!0&&(v=`#version 300 es
`,f=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+f,p=["#define varying in",t.glslVersion===Sp?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Sp?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
`+p);let b=v+f+o,x=v+p+a,_=I_(r,r.VERTEX_SHADER,b),T=I_(r,r.FRAGMENT_SHADER,x);r.attachShader(y,_),r.attachShader(y,T),t.index0AttributeName!==void 0?r.bindAttribLocation(y,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(y,0,"position"),r.linkProgram(y);function w(P){if(i.debug.checkShaderErrors){let N=r.getProgramInfoLog(y).trim(),L=r.getShaderInfoLog(_).trim(),D=r.getShaderInfoLog(T).trim(),$=!0,U=!0;if(r.getProgramParameter(y,r.LINK_STATUS)===!1)if($=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,y,_,T);else{let I=L_(r,_,"vertex"),V=L_(r,T,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(y,r.VALIDATE_STATUS)+`

Material Name: `+P.name+`
Material Type: `+P.type+`

Program Info Log: `+N+`
`+I+`
`+V)}else N!==""?console.warn("THREE.WebGLProgram: Program Info Log:",N):(L===""||D==="")&&(U=!1);U&&(P.diagnostics={runnable:$,programLog:N,vertexShader:{log:L,prefix:f},fragmentShader:{log:D,prefix:p}})}r.deleteShader(_),r.deleteShader(T),A=new Lc(r,y),E=uC(r,y)}let A;this.getUniforms=function(){return A===void 0&&w(this),A};let E;this.getAttributes=function(){return E===void 0&&w(this),E};let M=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=r.getProgramParameter(y,tC)),M},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(y),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=nC++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=_,this.fragmentShader=T,this}var EC=0,q0=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}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 K0(e),t.set(e,n)),n}},K0=class{constructor(e){this.id=EC++,this.code=e,this.usedTimes=0}};function MC(i,e,t,n,r,s,o){let a=new No,c=new q0,l=new Set,u=[],h=r.logarithmicDepthBuffer,d=r.vertexTextures,m=r.precision,g={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",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 y(E){return l.add(E),E===0?"uv":`uv${E}`}function f(E,M,P,N,L){let D=N.fog,$=L.geometry,U=E.isMeshStandardMaterial?N.environment:null,I=(E.isMeshStandardMaterial?t:e).get(E.envMap||U),V=I&&I.mapping===Ko?I.image.height:null,W=g[E.type];E.precision!==null&&(m=r.getMaxPrecision(E.precision),m!==E.precision&&console.warn("THREE.WebGLProgram.getParameters:",E.precision,"not supported, using",m,"instead."));let Q=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,se=Q!==void 0?Q.length:0,oe=0;$.morphAttributes.position!==void 0&&(oe=1),$.morphAttributes.normal!==void 0&&(oe=2),$.morphAttributes.color!==void 0&&(oe=3);let ge,O,S,R;if(W){let We=hr[W];ge=We.vertexShader,O=We.fragmentShader}else ge=E.vertexShader,O=E.fragmentShader,c.update(E),S=c.getVertexShaderID(E),R=c.getFragmentShaderID(E);let z=i.getRenderTarget(),Y=i.state.buffers.depth.getReversed(),K=L.isInstancedMesh===!0,re=L.isBatchedMesh===!0,de=!!E.map,te=!!E.matcap,ne=!!I,H=!!E.aoMap,_e=!!E.lightMap,me=!!E.bumpMap,be=!!E.normalMap,he=!!E.displacementMap,Ne=!!E.emissiveMap,Me=!!E.metalnessMap,Z=!!E.roughnessMap,B=E.anisotropy>0,k=E.clearcoat>0,F=E.dispersion>0,G=E.iridescence>0,j=E.sheen>0,ee=E.transmission>0,ie=B&&!!E.anisotropyMap,ce=k&&!!E.clearcoatMap,fe=k&&!!E.clearcoatNormalMap,ue=k&&!!E.clearcoatRoughnessMap,Ee=G&&!!E.iridescenceMap,Se=G&&!!E.iridescenceThicknessMap,De=j&&!!E.sheenColorMap,ze=j&&!!E.sheenRoughnessMap,Je=!!E.specularMap,Fe=!!E.specularColorMap,Xe=!!E.specularIntensityMap,ae=ee&&!!E.transmissionMap,Le=ee&&!!E.thicknessMap,xe=!!E.gradientMap,ye=!!E.alphaMap,Ue=E.alphaTest>0,Oe=!!E.alphaHash,st=!!E.extensions,pt=Ir;E.toneMapped&&(z===null||z.isXRRenderTarget===!0)&&(pt=i.toneMapping);let lt={shaderID:W,shaderType:E.type,shaderName:E.name,vertexShader:ge,fragmentShader:O,defines:E.defines,customVertexShaderID:S,customFragmentShaderID:R,isRawShaderMaterial:E.isRawShaderMaterial===!0,glslVersion:E.glslVersion,precision:m,batching:re,batchingColor:re&&L._colorsTexture!==null,instancing:K,instancingColor:K&&L.instanceColor!==null,instancingMorph:K&&L.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:z===null?i.outputColorSpace:z.isXRRenderTarget===!0?z.texture.colorSpace:On,alphaToCoverage:!!E.alphaToCoverage,map:de,matcap:te,envMap:ne,envMapMode:ne&&I.mapping,envMapCubeUVHeight:V,aoMap:H,lightMap:_e,bumpMap:me,normalMap:be,displacementMap:d&&he,emissiveMap:Ne,normalMapObjectSpace:be&&E.normalMapType===_0,normalMapTangentSpace:be&&E.normalMapType===ds,metalnessMap:Me,roughnessMap:Z,anisotropy:B,anisotropyMap:ie,clearcoat:k,clearcoatMap:ce,clearcoatNormalMap:fe,clearcoatRoughnessMap:ue,dispersion:F,iridescence:G,iridescenceMap:Ee,iridescenceThicknessMap:Se,sheen:j,sheenColorMap:De,sheenRoughnessMap:ze,specularMap:Je,specularColorMap:Fe,specularIntensityMap:Xe,transmission:ee,transmissionMap:ae,thicknessMap:Le,gradientMap:xe,opaque:E.transparent===!1&&E.blending===Fs&&E.alphaToCoverage===!1,alphaMap:ye,alphaTest:Ue,alphaHash:Oe,combine:E.combine,mapUv:de&&y(E.map.channel),aoMapUv:H&&y(E.aoMap.channel),lightMapUv:_e&&y(E.lightMap.channel),bumpMapUv:me&&y(E.bumpMap.channel),normalMapUv:be&&y(E.normalMap.channel),displacementMapUv:he&&y(E.displacementMap.channel),emissiveMapUv:Ne&&y(E.emissiveMap.channel),metalnessMapUv:Me&&y(E.metalnessMap.channel),roughnessMapUv:Z&&y(E.roughnessMap.channel),anisotropyMapUv:ie&&y(E.anisotropyMap.channel),clearcoatMapUv:ce&&y(E.clearcoatMap.channel),clearcoatNormalMapUv:fe&&y(E.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ue&&y(E.clearcoatRoughnessMap.channel),iridescenceMapUv:Ee&&y(E.iridescenceMap.channel),iridescenceThicknessMapUv:Se&&y(E.iridescenceThicknessMap.channel),sheenColorMapUv:De&&y(E.sheenColorMap.channel),sheenRoughnessMapUv:ze&&y(E.sheenRoughnessMap.channel),specularMapUv:Je&&y(E.specularMap.channel),specularColorMapUv:Fe&&y(E.specularColorMap.channel),specularIntensityMapUv:Xe&&y(E.specularIntensityMap.channel),transmissionMapUv:ae&&y(E.transmissionMap.channel),thicknessMapUv:Le&&y(E.thicknessMap.channel),alphaMapUv:ye&&y(E.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(be||B),vertexColors:E.vertexColors,vertexAlphas:E.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!$.attributes.uv&&(de||ye),fog:!!D,useFog:E.fog===!0,fogExp2:!!D&&D.isFogExp2,flatShading:E.flatShading===!0,sizeAttenuation:E.sizeAttenuation===!0,logarithmicDepthBuffer:h,reverseDepthBuffer:Y,skinning:L.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:se,morphTextureStride:oe,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:E.dithering,shadowMapEnabled:i.shadowMap.enabled&&P.length>0,shadowMapType:i.shadowMap.type,toneMapping:pt,decodeVideoTexture:de&&E.map.isVideoTexture===!0&&bt.getTransfer(E.map.colorSpace)===kt,decodeVideoTextureEmissive:Ne&&E.emissiveMap.isVideoTexture===!0&&bt.getTransfer(E.emissiveMap.colorSpace)===kt,premultipliedAlpha:E.premultipliedAlpha,doubleSided:E.side===yn,flipSided:E.side===un,useDepthPacking:E.depthPacking>=0,depthPacking:E.depthPacking||0,index0AttributeName:E.index0AttributeName,extensionClipCullDistance:st&&E.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(st&&E.extensions.multiDraw===!0||re)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:E.customProgramCacheKey()};return lt.vertexUv1s=l.has(1),lt.vertexUv2s=l.has(2),lt.vertexUv3s=l.has(3),l.clear(),lt}function p(E){let M=[];if(E.shaderID?M.push(E.shaderID):(M.push(E.customVertexShaderID),M.push(E.customFragmentShaderID)),E.defines!==void 0)for(let P in E.defines)M.push(P),M.push(E.defines[P]);return E.isRawShaderMaterial===!1&&(v(M,E),b(M,E),M.push(i.outputColorSpace)),M.push(E.customProgramCacheKey),M.join()}function v(E,M){E.push(M.precision),E.push(M.outputColorSpace),E.push(M.envMapMode),E.push(M.envMapCubeUVHeight),E.push(M.mapUv),E.push(M.alphaMapUv),E.push(M.lightMapUv),E.push(M.aoMapUv),E.push(M.bumpMapUv),E.push(M.normalMapUv),E.push(M.displacementMapUv),E.push(M.emissiveMapUv),E.push(M.metalnessMapUv),E.push(M.roughnessMapUv),E.push(M.anisotropyMapUv),E.push(M.clearcoatMapUv),E.push(M.clearcoatNormalMapUv),E.push(M.clearcoatRoughnessMapUv),E.push(M.iridescenceMapUv),E.push(M.iridescenceThicknessMapUv),E.push(M.sheenColorMapUv),E.push(M.sheenRoughnessMapUv),E.push(M.specularMapUv),E.push(M.specularColorMapUv),E.push(M.specularIntensityMapUv),E.push(M.transmissionMapUv),E.push(M.thicknessMapUv),E.push(M.combine),E.push(M.fogExp2),E.push(M.sizeAttenuation),E.push(M.morphTargetsCount),E.push(M.morphAttributeCount),E.push(M.numDirLights),E.push(M.numPointLights),E.push(M.numSpotLights),E.push(M.numSpotLightMaps),E.push(M.numHemiLights),E.push(M.numRectAreaLights),E.push(M.numDirLightShadows),E.push(M.numPointLightShadows),E.push(M.numSpotLightShadows),E.push(M.numSpotLightShadowsWithMaps),E.push(M.numLightProbes),E.push(M.shadowMapType),E.push(M.toneMapping),E.push(M.numClippingPlanes),E.push(M.numClipIntersection),E.push(M.depthPacking)}function b(E,M){a.disableAll(),M.supportsVertexTextures&&a.enable(0),M.instancing&&a.enable(1),M.instancingColor&&a.enable(2),M.instancingMorph&&a.enable(3),M.matcap&&a.enable(4),M.envMap&&a.enable(5),M.normalMapObjectSpace&&a.enable(6),M.normalMapTangentSpace&&a.enable(7),M.clearcoat&&a.enable(8),M.iridescence&&a.enable(9),M.alphaTest&&a.enable(10),M.vertexColors&&a.enable(11),M.vertexAlphas&&a.enable(12),M.vertexUv1s&&a.enable(13),M.vertexUv2s&&a.enable(14),M.vertexUv3s&&a.enable(15),M.vertexTangents&&a.enable(16),M.anisotropy&&a.enable(17),M.alphaHash&&a.enable(18),M.batching&&a.enable(19),M.dispersion&&a.enable(20),M.batchingColor&&a.enable(21),E.push(a.mask),a.disableAll(),M.fog&&a.enable(0),M.useFog&&a.enable(1),M.flatShading&&a.enable(2),M.logarithmicDepthBuffer&&a.enable(3),M.reverseDepthBuffer&&a.enable(4),M.skinning&&a.enable(5),M.morphTargets&&a.enable(6),M.morphNormals&&a.enable(7),M.morphColors&&a.enable(8),M.premultipliedAlpha&&a.enable(9),M.shadowMapEnabled&&a.enable(10),M.doubleSided&&a.enable(11),M.flipSided&&a.enable(12),M.useDepthPacking&&a.enable(13),M.dithering&&a.enable(14),M.transmission&&a.enable(15),M.sheen&&a.enable(16),M.opaque&&a.enable(17),M.pointsUvs&&a.enable(18),M.decodeVideoTexture&&a.enable(19),M.decodeVideoTextureEmissive&&a.enable(20),M.alphaToCoverage&&a.enable(21),E.push(a.mask)}function x(E){let M=g[E.type],P;if(M){let N=hr[M];P=Gn.clone(N.uniforms)}else P=E.uniforms;return P}function _(E,M){let P;for(let N=0,L=u.length;N<L;N++){let D=u[N];if(D.cacheKey===M){P=D,++P.usedTimes;break}}return P===void 0&&(P=new _C(i,M,E,s),u.push(P)),P}function T(E){if(--E.usedTimes===0){let M=u.indexOf(E);u[M]=u[u.length-1],u.pop(),E.destroy()}}function w(E){c.remove(E)}function A(){c.dispose()}return{getParameters:f,getProgramCacheKey:p,getUniforms:x,acquireProgram:_,releaseProgram:T,releaseShaderCache:w,programs:u,dispose:A}}function SC(){let i=new WeakMap;function e(o){return i.has(o)}function t(o){let a=i.get(o);return a===void 0&&(a={},i.set(o,a)),a}function n(o){i.delete(o)}function r(o,a,c){i.get(o)[a]=c}function s(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:s}}function TC(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function k_(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function B_(){let i=[],e=0,t=[],n=[],r=[];function s(){e=0,t.length=0,n.length=0,r.length=0}function o(h,d,m,g,y,f){let p=i[e];return p===void 0?(p={id:h.id,object:h,geometry:d,material:m,groupOrder:g,renderOrder:h.renderOrder,z:y,group:f},i[e]=p):(p.id=h.id,p.object=h,p.geometry=d,p.material=m,p.groupOrder=g,p.renderOrder=h.renderOrder,p.z=y,p.group=f),e++,p}function a(h,d,m,g,y,f){let p=o(h,d,m,g,y,f);m.transmission>0?n.push(p):m.transparent===!0?r.push(p):t.push(p)}function c(h,d,m,g,y,f){let p=o(h,d,m,g,y,f);m.transmission>0?n.unshift(p):m.transparent===!0?r.unshift(p):t.unshift(p)}function l(h,d){t.length>1&&t.sort(h||TC),n.length>1&&n.sort(d||k_),r.length>1&&r.sort(d||k_)}function u(){for(let h=e,d=i.length;h<d;h++){let m=i[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:t,transmissive:n,transparent:r,init:s,push:a,unshift:c,finish:u,sort:l}}function AC(){let i=new WeakMap;function e(n,r){let s=i.get(n),o;return s===void 0?(o=new B_,i.set(n,[o])):r>=s.length?(o=new B_,s.push(o)):o=s[r],o}function t(){i=new WeakMap}return{get:e,dispose:t}}function wC(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new q,color:new Be};break;case"SpotLight":t={position:new q,direction:new q,color:new Be,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new q,color:new Be,distance:0,decay:0};break;case"HemisphereLight":t={direction:new q,skyColor:new Be,groundColor:new Be};break;case"RectAreaLight":t={color:new Be,position:new q,halfWidth:new q,halfHeight:new q};break}return i[e.id]=t,t}}}function RC(){let i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ce,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}var CC=0;function PC(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function IC(i){let e=new wC,t=RC(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],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 l=0;l<9;l++)n.probe.push(new q);let r=new q,s=new nt,o=new nt;function a(l){let u=0,h=0,d=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let m=0,g=0,y=0,f=0,p=0,v=0,b=0,x=0,_=0,T=0,w=0;l.sort(PC);for(let E=0,M=l.length;E<M;E++){let P=l[E],N=P.color,L=P.intensity,D=P.distance,$=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)u+=N.r*L,h+=N.g*L,d+=N.b*L;else if(P.isLightProbe){for(let U=0;U<9;U++)n.probe[U].addScaledVector(P.sh.coefficients[U],L);w++}else if(P.isDirectionalLight){let U=e.get(P);if(U.color.copy(P.color).multiplyScalar(P.intensity),P.castShadow){let I=P.shadow,V=t.get(P);V.shadowIntensity=I.intensity,V.shadowBias=I.bias,V.shadowNormalBias=I.normalBias,V.shadowRadius=I.radius,V.shadowMapSize=I.mapSize,n.directionalShadow[m]=V,n.directionalShadowMap[m]=$,n.directionalShadowMatrix[m]=P.shadow.matrix,v++}n.directional[m]=U,m++}else if(P.isSpotLight){let U=e.get(P);U.position.setFromMatrixPosition(P.matrixWorld),U.color.copy(N).multiplyScalar(L),U.distance=D,U.coneCos=Math.cos(P.angle),U.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),U.decay=P.decay,n.spot[y]=U;let I=P.shadow;if(P.map&&(n.spotLightMap[_]=P.map,_++,I.updateMatrices(P),P.castShadow&&T++),n.spotLightMatrix[y]=I.matrix,P.castShadow){let V=t.get(P);V.shadowIntensity=I.intensity,V.shadowBias=I.bias,V.shadowNormalBias=I.normalBias,V.shadowRadius=I.radius,V.shadowMapSize=I.mapSize,n.spotShadow[y]=V,n.spotShadowMap[y]=$,x++}y++}else if(P.isRectAreaLight){let U=e.get(P);U.color.copy(N).multiplyScalar(L),U.halfWidth.set(P.width*.5,0,0),U.halfHeight.set(0,P.height*.5,0),n.rectArea[f]=U,f++}else if(P.isPointLight){let U=e.get(P);if(U.color.copy(P.color).multiplyScalar(P.intensity),U.distance=P.distance,U.decay=P.decay,P.castShadow){let I=P.shadow,V=t.get(P);V.shadowIntensity=I.intensity,V.shadowBias=I.bias,V.shadowNormalBias=I.normalBias,V.shadowRadius=I.radius,V.shadowMapSize=I.mapSize,V.shadowCameraNear=I.camera.near,V.shadowCameraFar=I.camera.far,n.pointShadow[g]=V,n.pointShadowMap[g]=$,n.pointShadowMatrix[g]=P.shadow.matrix,b++}n.point[g]=U,g++}else if(P.isHemisphereLight){let U=e.get(P);U.skyColor.copy(P.color).multiplyScalar(L),U.groundColor.copy(P.groundColor).multiplyScalar(L),n.hemi[p]=U,p++}}f>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Ze.LTC_FLOAT_1,n.rectAreaLTC2=Ze.LTC_FLOAT_2):(n.rectAreaLTC1=Ze.LTC_HALF_1,n.rectAreaLTC2=Ze.LTC_HALF_2)),n.ambient[0]=u,n.ambient[1]=h,n.ambient[2]=d;let A=n.hash;(A.directionalLength!==m||A.pointLength!==g||A.spotLength!==y||A.rectAreaLength!==f||A.hemiLength!==p||A.numDirectionalShadows!==v||A.numPointShadows!==b||A.numSpotShadows!==x||A.numSpotMaps!==_||A.numLightProbes!==w)&&(n.directional.length=m,n.spot.length=y,n.rectArea.length=f,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=v,n.directionalShadowMap.length=v,n.pointShadow.length=b,n.pointShadowMap.length=b,n.spotShadow.length=x,n.spotShadowMap.length=x,n.directionalShadowMatrix.length=v,n.pointShadowMatrix.length=b,n.spotLightMatrix.length=x+_-T,n.spotLightMap.length=_,n.numSpotLightShadowsWithMaps=T,n.numLightProbes=w,A.directionalLength=m,A.pointLength=g,A.spotLength=y,A.rectAreaLength=f,A.hemiLength=p,A.numDirectionalShadows=v,A.numPointShadows=b,A.numSpotShadows=x,A.numSpotMaps=_,A.numLightProbes=w,n.version=CC++)}function c(l,u){let h=0,d=0,m=0,g=0,y=0,f=u.matrixWorldInverse;for(let p=0,v=l.length;p<v;p++){let b=l[p];if(b.isDirectionalLight){let x=n.directional[h];x.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),x.direction.sub(r),x.direction.transformDirection(f),h++}else if(b.isSpotLight){let x=n.spot[m];x.position.setFromMatrixPosition(b.matrixWorld),x.position.applyMatrix4(f),x.direction.setFromMatrixPosition(b.matrixWorld),r.setFromMatrixPosition(b.target.matrixWorld),x.direction.sub(r),x.direction.transformDirection(f),m++}else if(b.isRectAreaLight){let x=n.rectArea[g];x.position.setFromMatrixPosition(b.matrixWorld),x.position.applyMatrix4(f),o.identity(),s.copy(b.matrixWorld),s.premultiply(f),o.extractRotation(s),x.halfWidth.set(b.width*.5,0,0),x.halfHeight.set(0,b.height*.5,0),x.halfWidth.applyMatrix4(o),x.halfHeight.applyMatrix4(o),g++}else if(b.isPointLight){let x=n.point[d];x.position.setFromMatrixPosition(b.matrixWorld),x.position.applyMatrix4(f),d++}else if(b.isHemisphereLight){let x=n.hemi[y];x.direction.setFromMatrixPosition(b.matrixWorld),x.direction.transformDirection(f),y++}}}return{setup:a,setupView:c,state:n}}function z_(i){let e=new IC(i),t=[],n=[];function r(u){l.camera=u,t.length=0,n.length=0}function s(u){t.push(u)}function o(u){n.push(u)}function a(){e.setup(t)}function c(u){e.setupView(t,u)}let l={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:l,setupLights:a,setupLightsView:c,pushLight:s,pushShadow:o}}function NC(i){let e=new WeakMap;function t(r,s=0){let o=e.get(r),a;return o===void 0?(a=new z_(i),e.set(r,[a])):s>=o.length?(a=new z_(i),o.push(a)):a=o[s],a}function n(){e=new WeakMap}return{get:t,dispose:n}}var LC=`void main() {
	gl_Position = vec4( position, 1.0 );
}`,OC=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
	const float samples = float( VSM_SAMPLES );
	float mean = 0.0;
	float squared_mean = 0.0;
	float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
	float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
	for ( float i = 0.0; i < samples; i ++ ) {
		float uvOffset = uvStart + i * uvStride;
		#ifdef HORIZONTAL_PASS
			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
			mean += distribution.x;
			squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
		#else
			float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;
		#endif
	}
	mean = mean / samples;
	squared_mean = squared_mean / samples;
	float std_dev = sqrt( squared_mean - mean * mean );
	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;function DC(i,e,t){let n=new Ws,r=new Ce,s=new Ce,o=new It,a=new uc({depthPacking:b0}),c=new hc,l={},u=t.maxTextureSize,h={[Jn]:un,[un]:Jn,[yn]:yn},d=new $t({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ce},radius:{value:4}},vertexShader:LC,fragmentShader:OC}),m=d.clone();m.defines.HORIZONTAL_PASS=1;let g=new ot;g.setAttribute("position",new gt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new ct(g,d),f=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ap;let p=this.type;this.render=function(T,w,A){if(f.enabled===!1||f.autoUpdate===!1&&f.needsUpdate===!1||T.length===0)return;let E=i.getRenderTarget(),M=i.getActiveCubeFace(),P=i.getActiveMipmapLevel(),N=i.state;N.setBlending(xn),N.buffers.color.setClear(1,1,1,1),N.buffers.depth.setTest(!0),N.setScissorTest(!1);let L=p!==ur&&this.type===ur,D=p===ur&&this.type!==ur;for(let $=0,U=T.length;$<U;$++){let I=T[$],V=I.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",I,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;r.copy(V.mapSize);let W=V.getFrameExtents();if(r.multiply(W),s.copy(V.mapSize),(r.x>u||r.y>u)&&(r.x>u&&(s.x=Math.floor(u/W.x),r.x=s.x*W.x,V.mapSize.x=s.x),r.y>u&&(s.y=Math.floor(u/W.y),r.y=s.y*W.y,V.mapSize.y=s.y)),V.map===null||L===!0||D===!0){let se=this.type!==ur?{minFilter:Jt,magFilter:Jt}:{};V.map!==null&&V.map.dispose(),V.map=new on(r.x,r.y,se),V.map.texture.name=I.name+".shadowMap",V.camera.updateProjectionMatrix()}i.setRenderTarget(V.map),i.clear();let Q=V.getViewportCount();for(let se=0;se<Q;se++){let oe=V.getViewport(se);o.set(s.x*oe.x,s.y*oe.y,s.x*oe.z,s.y*oe.w),N.viewport(o),V.updateMatrices(I,se),n=V.getFrustum(),x(w,A,V.camera,I,this.type)}V.isPointLightShadow!==!0&&this.type===ur&&v(V,A),V.needsUpdate=!1}p=this.type,f.needsUpdate=!1,i.setRenderTarget(E,M,P)};function v(T,w){let A=e.update(y);d.defines.VSM_SAMPLES!==T.blurSamples&&(d.defines.VSM_SAMPLES=T.blurSamples,m.defines.VSM_SAMPLES=T.blurSamples,d.needsUpdate=!0,m.needsUpdate=!0),T.mapPass===null&&(T.mapPass=new on(r.x,r.y)),d.uniforms.shadow_pass.value=T.map.texture,d.uniforms.resolution.value=T.mapSize,d.uniforms.radius.value=T.radius,i.setRenderTarget(T.mapPass),i.clear(),i.renderBufferDirect(w,null,A,d,y,null),m.uniforms.shadow_pass.value=T.mapPass.texture,m.uniforms.resolution.value=T.mapSize,m.uniforms.radius.value=T.radius,i.setRenderTarget(T.map),i.clear(),i.renderBufferDirect(w,null,A,m,y,null)}function b(T,w,A,E){let M=null,P=A.isPointLight===!0?T.customDistanceMaterial:T.customDepthMaterial;if(P!==void 0)M=P;else if(M=A.isPointLight===!0?c:a,i.localClippingEnabled&&w.clipShadows===!0&&Array.isArray(w.clippingPlanes)&&w.clippingPlanes.length!==0||w.displacementMap&&w.displacementScale!==0||w.alphaMap&&w.alphaTest>0||w.map&&w.alphaTest>0){let N=M.uuid,L=w.uuid,D=l[N];D===void 0&&(D={},l[N]=D);let $=D[L];$===void 0&&($=M.clone(),D[L]=$,w.addEventListener("dispose",_)),M=$}if(M.visible=w.visible,M.wireframe=w.wireframe,E===ur?M.side=w.shadowSide!==null?w.shadowSide:w.side:M.side=w.shadowSide!==null?w.shadowSide:h[w.side],M.alphaMap=w.alphaMap,M.alphaTest=w.alphaTest,M.map=w.map,M.clipShadows=w.clipShadows,M.clippingPlanes=w.clippingPlanes,M.clipIntersection=w.clipIntersection,M.displacementMap=w.displacementMap,M.displacementScale=w.displacementScale,M.displacementBias=w.displacementBias,M.wireframeLinewidth=w.wireframeLinewidth,M.linewidth=w.linewidth,A.isPointLight===!0&&M.isMeshDistanceMaterial===!0){let N=i.properties.get(M);N.light=A}return M}function x(T,w,A,E,M){if(T.visible===!1)return;if(T.layers.test(w.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&M===ur)&&(!T.frustumCulled||n.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(A.matrixWorldInverse,T.matrixWorld);let L=e.update(T),D=T.material;if(Array.isArray(D)){let $=L.groups;for(let U=0,I=$.length;U<I;U++){let V=$[U],W=D[V.materialIndex];if(W&&W.visible){let Q=b(T,W,E,M);T.onBeforeShadow(i,T,w,A,L,Q,V),i.renderBufferDirect(A,null,L,Q,T,V),T.onAfterShadow(i,T,w,A,L,Q,V)}}}else if(D.visible){let $=b(T,D,E,M);T.onBeforeShadow(i,T,w,A,L,$,null),i.renderBufferDirect(A,null,L,$,T,null),T.onAfterShadow(i,T,w,A,L,$,null)}}let N=T.children;for(let L=0,D=N.length;L<D;L++)x(N[L],w,A,E,M)}function _(T){T.target.removeEventListener("dispose",_);for(let A in l){let E=l[A],M=T.target.uuid;M in E&&(E[M].dispose(),delete E[M])}}}var FC={[Ru]:Cu,[Pu]:Lu,[Iu]:Ou,[Us]:Nu,[Cu]:Ru,[Lu]:Pu,[Ou]:Iu,[Nu]:Us};function UC(i,e){function t(){let ae=!1,Le=new It,xe=null,ye=new It(0,0,0,0);return{setMask:function(Ue){xe!==Ue&&!ae&&(i.colorMask(Ue,Ue,Ue,Ue),xe=Ue)},setLocked:function(Ue){ae=Ue},setClear:function(Ue,Oe,st,pt,lt){lt===!0&&(Ue*=pt,Oe*=pt,st*=pt),Le.set(Ue,Oe,st,pt),ye.equals(Le)===!1&&(i.clearColor(Ue,Oe,st,pt),ye.copy(Le))},reset:function(){ae=!1,xe=null,ye.set(-1,0,0,0)}}}function n(){let ae=!1,Le=!1,xe=null,ye=null,Ue=null;return{setReversed:function(Oe){if(Le!==Oe){let st=e.get("EXT_clip_control");Le?st.clipControlEXT(st.LOWER_LEFT_EXT,st.ZERO_TO_ONE_EXT):st.clipControlEXT(st.LOWER_LEFT_EXT,st.NEGATIVE_ONE_TO_ONE_EXT);let pt=Ue;Ue=null,this.setClear(pt)}Le=Oe},getReversed:function(){return Le},setTest:function(Oe){Oe?z(i.DEPTH_TEST):Y(i.DEPTH_TEST)},setMask:function(Oe){xe!==Oe&&!ae&&(i.depthMask(Oe),xe=Oe)},setFunc:function(Oe){if(Le&&(Oe=FC[Oe]),ye!==Oe){switch(Oe){case Ru:i.depthFunc(i.NEVER);break;case Cu:i.depthFunc(i.ALWAYS);break;case Pu:i.depthFunc(i.LESS);break;case Us:i.depthFunc(i.LEQUAL);break;case Iu:i.depthFunc(i.EQUAL);break;case Nu:i.depthFunc(i.GEQUAL);break;case Lu:i.depthFunc(i.GREATER);break;case Ou:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ye=Oe}},setLocked:function(Oe){ae=Oe},setClear:function(Oe){Ue!==Oe&&(Le&&(Oe=1-Oe),i.clearDepth(Oe),Ue=Oe)},reset:function(){ae=!1,xe=null,ye=null,Ue=null,Le=!1}}}function r(){let ae=!1,Le=null,xe=null,ye=null,Ue=null,Oe=null,st=null,pt=null,lt=null;return{setTest:function(We){ae||(We?z(i.STENCIL_TEST):Y(i.STENCIL_TEST))},setMask:function(We){Le!==We&&!ae&&(i.stencilMask(We),Le=We)},setFunc:function(We,Qe,Ie){(xe!==We||ye!==Qe||Ue!==Ie)&&(i.stencilFunc(We,Qe,Ie),xe=We,ye=Qe,Ue=Ie)},setOp:function(We,Qe,Ie){(Oe!==We||st!==Qe||pt!==Ie)&&(i.stencilOp(We,Qe,Ie),Oe=We,st=Qe,pt=Ie)},setLocked:function(We){ae=We},setClear:function(We){lt!==We&&(i.clearStencil(We),lt=We)},reset:function(){ae=!1,Le=null,xe=null,ye=null,Ue=null,Oe=null,st=null,pt=null,lt=null}}}let s=new t,o=new n,a=new r,c=new WeakMap,l=new WeakMap,u={},h={},d=new WeakMap,m=[],g=null,y=!1,f=null,p=null,v=null,b=null,x=null,_=null,T=null,w=new Be(0,0,0),A=0,E=!1,M=null,P=null,N=null,L=null,D=null,$=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS),U=!1,I=0,V=i.getParameter(i.VERSION);V.indexOf("WebGL")!==-1?(I=parseFloat(/^WebGL (\d)/.exec(V)[1]),U=I>=1):V.indexOf("OpenGL ES")!==-1&&(I=parseFloat(/^OpenGL ES (\d)/.exec(V)[1]),U=I>=2);let W=null,Q={},se=i.getParameter(i.SCISSOR_BOX),oe=i.getParameter(i.VIEWPORT),ge=new It().fromArray(se),O=new It().fromArray(oe);function S(ae,Le,xe,ye){let Ue=new Uint8Array(4),Oe=i.createTexture();i.bindTexture(ae,Oe),i.texParameteri(ae,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(ae,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let st=0;st<xe;st++)ae===i.TEXTURE_3D||ae===i.TEXTURE_2D_ARRAY?i.texImage3D(Le,0,i.RGBA,1,1,ye,0,i.RGBA,i.UNSIGNED_BYTE,Ue):i.texImage2D(Le+st,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,Ue);return Oe}let R={};R[i.TEXTURE_2D]=S(i.TEXTURE_2D,i.TEXTURE_2D,1),R[i.TEXTURE_CUBE_MAP]=S(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),R[i.TEXTURE_2D_ARRAY]=S(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),R[i.TEXTURE_3D]=S(i.TEXTURE_3D,i.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),a.setClear(0),z(i.DEPTH_TEST),o.setFunc(Us),me(!1),be(op),z(i.CULL_FACE),H(xn);function z(ae){u[ae]!==!0&&(i.enable(ae),u[ae]=!0)}function Y(ae){u[ae]!==!1&&(i.disable(ae),u[ae]=!1)}function K(ae,Le){return h[ae]!==Le?(i.bindFramebuffer(ae,Le),h[ae]=Le,ae===i.DRAW_FRAMEBUFFER&&(h[i.FRAMEBUFFER]=Le),ae===i.FRAMEBUFFER&&(h[i.DRAW_FRAMEBUFFER]=Le),!0):!1}function re(ae,Le){let xe=m,ye=!1;if(ae){xe=d.get(Le),xe===void 0&&(xe=[],d.set(Le,xe));let Ue=ae.textures;if(xe.length!==Ue.length||xe[0]!==i.COLOR_ATTACHMENT0){for(let Oe=0,st=Ue.length;Oe<st;Oe++)xe[Oe]=i.COLOR_ATTACHMENT0+Oe;xe.length=Ue.length,ye=!0}}else xe[0]!==i.BACK&&(xe[0]=i.BACK,ye=!0);ye&&i.drawBuffers(xe)}function de(ae){return g!==ae?(i.useProgram(ae),g=ae,!0):!1}let te={[yi]:i.FUNC_ADD,[Qg]:i.FUNC_SUBTRACT,[$g]:i.FUNC_REVERSE_SUBTRACT};te[e0]=i.MIN,te[t0]=i.MAX;let ne={[Ks]:i.ZERO,[n0]:i.ONE,[i0]:i.SRC_COLOR,[Il]:i.SRC_ALPHA,[a0]:i.SRC_ALPHA_SATURATE,[vc]:i.DST_COLOR,[xc]:i.DST_ALPHA,[r0]:i.ONE_MINUS_SRC_COLOR,[Nl]:i.ONE_MINUS_SRC_ALPHA,[o0]:i.ONE_MINUS_DST_COLOR,[s0]:i.ONE_MINUS_DST_ALPHA,[c0]:i.CONSTANT_COLOR,[l0]:i.ONE_MINUS_CONSTANT_COLOR,[u0]:i.CONSTANT_ALPHA,[h0]:i.ONE_MINUS_CONSTANT_ALPHA};function H(ae,Le,xe,ye,Ue,Oe,st,pt,lt,We){if(ae===xn){y===!0&&(Y(i.BLEND),y=!1);return}if(y===!1&&(z(i.BLEND),y=!0),ae!==wu){if(ae!==f||We!==E){if((p!==yi||x!==yi)&&(i.blendEquation(i.FUNC_ADD),p=yi,x=yi),We)switch(ae){case Fs:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case cp:i.blendFunc(i.ONE,i.ONE);break;case lp:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case up:i.blendFuncSeparate(i.ZERO,i.SRC_COLOR,i.ZERO,i.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",ae);break}else switch(ae){case Fs:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case cp:i.blendFunc(i.SRC_ALPHA,i.ONE);break;case lp:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case up:i.blendFunc(i.ZERO,i.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",ae);break}v=null,b=null,_=null,T=null,w.set(0,0,0),A=0,f=ae,E=We}return}Ue=Ue||Le,Oe=Oe||xe,st=st||ye,(Le!==p||Ue!==x)&&(i.blendEquationSeparate(te[Le],te[Ue]),p=Le,x=Ue),(xe!==v||ye!==b||Oe!==_||st!==T)&&(i.blendFuncSeparate(ne[xe],ne[ye],ne[Oe],ne[st]),v=xe,b=ye,_=Oe,T=st),(pt.equals(w)===!1||lt!==A)&&(i.blendColor(pt.r,pt.g,pt.b,lt),w.copy(pt),A=lt),f=ae,E=!1}function _e(ae,Le){ae.side===yn?Y(i.CULL_FACE):z(i.CULL_FACE);let xe=ae.side===un;Le&&(xe=!xe),me(xe),ae.blending===Fs&&ae.transparent===!1?H(xn):H(ae.blending,ae.blendEquation,ae.blendSrc,ae.blendDst,ae.blendEquationAlpha,ae.blendSrcAlpha,ae.blendDstAlpha,ae.blendColor,ae.blendAlpha,ae.premultipliedAlpha),o.setFunc(ae.depthFunc),o.setTest(ae.depthTest),o.setMask(ae.depthWrite),s.setMask(ae.colorWrite);let ye=ae.stencilWrite;a.setTest(ye),ye&&(a.setMask(ae.stencilWriteMask),a.setFunc(ae.stencilFunc,ae.stencilRef,ae.stencilFuncMask),a.setOp(ae.stencilFail,ae.stencilZFail,ae.stencilZPass)),Ne(ae.polygonOffset,ae.polygonOffsetFactor,ae.polygonOffsetUnits),ae.alphaToCoverage===!0?z(i.SAMPLE_ALPHA_TO_COVERAGE):Y(i.SAMPLE_ALPHA_TO_COVERAGE)}function me(ae){M!==ae&&(ae?i.frontFace(i.CW):i.frontFace(i.CCW),M=ae)}function be(ae){ae!==Zg?(z(i.CULL_FACE),ae!==P&&(ae===op?i.cullFace(i.BACK):ae===Jg?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):Y(i.CULL_FACE),P=ae}function he(ae){ae!==N&&(U&&i.lineWidth(ae),N=ae)}function Ne(ae,Le,xe){ae?(z(i.POLYGON_OFFSET_FILL),(L!==Le||D!==xe)&&(i.polygonOffset(Le,xe),L=Le,D=xe)):Y(i.POLYGON_OFFSET_FILL)}function Me(ae){ae?z(i.SCISSOR_TEST):Y(i.SCISSOR_TEST)}function Z(ae){ae===void 0&&(ae=i.TEXTURE0+$-1),W!==ae&&(i.activeTexture(ae),W=ae)}function B(ae,Le,xe){xe===void 0&&(W===null?xe=i.TEXTURE0+$-1:xe=W);let ye=Q[xe];ye===void 0&&(ye={type:void 0,texture:void 0},Q[xe]=ye),(ye.type!==ae||ye.texture!==Le)&&(W!==xe&&(i.activeTexture(xe),W=xe),i.bindTexture(ae,Le||R[ae]),ye.type=ae,ye.texture=Le)}function k(){let ae=Q[W];ae!==void 0&&ae.type!==void 0&&(i.bindTexture(ae.type,null),ae.type=void 0,ae.texture=void 0)}function F(){try{i.compressedTexImage2D.apply(i,arguments)}catch(ae){console.error("THREE.WebGLState:",ae)}}function G(){try{i.compressedTexImage3D.apply(i,arguments)}catch(ae){console.error("THREE.WebGLState:",ae)}}function j(){try{i.texSubImage2D.apply(i,arguments)}catch(ae){console.error("THREE.WebGLState:",ae)}}function ee(){try{i.texSubImage3D.apply(i,arguments)}catch(ae){console.error("THREE.WebGLState:",ae)}}function ie(){try{i.compressedTexSubImage2D.apply(i,arguments)}catch(ae){console.error("THREE.WebGLState:",ae)}}function ce(){try{i.compressedTexSubImage3D.apply(i,arguments)}catch(ae){console.error("THREE.WebGLState:",ae)}}function fe(){try{i.texStorage2D.apply(i,arguments)}catch(ae){console.error("THREE.WebGLState:",ae)}}function ue(){try{i.texStorage3D.apply(i,arguments)}catch(ae){console.error("THREE.WebGLState:",ae)}}function Ee(){try{i.texImage2D.apply(i,arguments)}catch(ae){console.error("THREE.WebGLState:",ae)}}function Se(){try{i.texImage3D.apply(i,arguments)}catch(ae){console.error("THREE.WebGLState:",ae)}}function De(ae){ge.equals(ae)===!1&&(i.scissor(ae.x,ae.y,ae.z,ae.w),ge.copy(ae))}function ze(ae){O.equals(ae)===!1&&(i.viewport(ae.x,ae.y,ae.z,ae.w),O.copy(ae))}function Je(ae,Le){let xe=l.get(Le);xe===void 0&&(xe=new WeakMap,l.set(Le,xe));let ye=xe.get(ae);ye===void 0&&(ye=i.getUniformBlockIndex(Le,ae.name),xe.set(ae,ye))}function Fe(ae,Le){let ye=l.get(Le).get(ae);c.get(Le)!==ye&&(i.uniformBlockBinding(Le,ye,ae.__bindingPointIndex),c.set(Le,ye))}function Xe(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),o.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),u={},W=null,Q={},h={},d=new WeakMap,m=[],g=null,y=!1,f=null,p=null,v=null,b=null,x=null,_=null,T=null,w=new Be(0,0,0),A=0,E=!1,M=null,P=null,N=null,L=null,D=null,ge.set(0,0,i.canvas.width,i.canvas.height),O.set(0,0,i.canvas.width,i.canvas.height),s.reset(),o.reset(),a.reset()}return{buffers:{color:s,depth:o,stencil:a},enable:z,disable:Y,bindFramebuffer:K,drawBuffers:re,useProgram:de,setBlending:H,setMaterial:_e,setFlipSided:me,setCullFace:be,setLineWidth:he,setPolygonOffset:Ne,setScissorTest:Me,activeTexture:Z,bindTexture:B,unbindTexture:k,compressedTexImage2D:F,compressedTexImage3D:G,texImage2D:Ee,texImage3D:Se,updateUBOMapping:Je,uniformBlockBinding:Fe,texStorage2D:fe,texStorage3D:ue,texSubImage2D:j,texSubImage3D:ee,compressedTexSubImage2D:ie,compressedTexSubImage3D:ce,scissor:De,viewport:ze,reset:Xe}}function kC(i,e,t,n,r,s,o){let a=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Ce,u=new WeakMap,h,d=new WeakMap,m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(Z,B){return m?new OffscreenCanvas(Z,B):$a("canvas")}function y(Z,B,k){let F=1,G=Me(Z);if((G.width>k||G.height>k)&&(F=k/Math.max(G.width,G.height)),F<1)if(typeof HTMLImageElement<"u"&&Z instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Z instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Z instanceof ImageBitmap||typeof VideoFrame<"u"&&Z instanceof VideoFrame){let j=Math.floor(F*G.width),ee=Math.floor(F*G.height);h===void 0&&(h=g(j,ee));let ie=B?g(j,ee):h;return ie.width=j,ie.height=ee,ie.getContext("2d").drawImage(Z,0,0,j,ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+G.width+"x"+G.height+") to ("+j+"x"+ee+")."),ie}else return"data"in Z&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+G.width+"x"+G.height+")."),Z;return Z}function f(Z){return Z.generateMipmaps}function p(Z){i.generateMipmap(Z)}function v(Z){return Z.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:Z.isWebGL3DRenderTarget?i.TEXTURE_3D:Z.isWebGLArrayRenderTarget||Z.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function b(Z,B,k,F,G=!1){if(Z!==null){if(i[Z]!==void 0)return i[Z];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Z+"'")}let j=B;if(B===i.RED&&(k===i.FLOAT&&(j=i.R32F),k===i.HALF_FLOAT&&(j=i.R16F),k===i.UNSIGNED_BYTE&&(j=i.R8)),B===i.RED_INTEGER&&(k===i.UNSIGNED_BYTE&&(j=i.R8UI),k===i.UNSIGNED_SHORT&&(j=i.R16UI),k===i.UNSIGNED_INT&&(j=i.R32UI),k===i.BYTE&&(j=i.R8I),k===i.SHORT&&(j=i.R16I),k===i.INT&&(j=i.R32I)),B===i.RG&&(k===i.FLOAT&&(j=i.RG32F),k===i.HALF_FLOAT&&(j=i.RG16F),k===i.UNSIGNED_BYTE&&(j=i.RG8)),B===i.RG_INTEGER&&(k===i.UNSIGNED_BYTE&&(j=i.RG8UI),k===i.UNSIGNED_SHORT&&(j=i.RG16UI),k===i.UNSIGNED_INT&&(j=i.RG32UI),k===i.BYTE&&(j=i.RG8I),k===i.SHORT&&(j=i.RG16I),k===i.INT&&(j=i.RG32I)),B===i.RGB_INTEGER&&(k===i.UNSIGNED_BYTE&&(j=i.RGB8UI),k===i.UNSIGNED_SHORT&&(j=i.RGB16UI),k===i.UNSIGNED_INT&&(j=i.RGB32UI),k===i.BYTE&&(j=i.RGB8I),k===i.SHORT&&(j=i.RGB16I),k===i.INT&&(j=i.RGB32I)),B===i.RGBA_INTEGER&&(k===i.UNSIGNED_BYTE&&(j=i.RGBA8UI),k===i.UNSIGNED_SHORT&&(j=i.RGBA16UI),k===i.UNSIGNED_INT&&(j=i.RGBA32UI),k===i.BYTE&&(j=i.RGBA8I),k===i.SHORT&&(j=i.RGBA16I),k===i.INT&&(j=i.RGBA32I)),B===i.RGB&&k===i.UNSIGNED_INT_5_9_9_9_REV&&(j=i.RGB9_E5),B===i.RGBA){let ee=G?Za:bt.getTransfer(F);k===i.FLOAT&&(j=i.RGBA32F),k===i.HALF_FLOAT&&(j=i.RGBA16F),k===i.UNSIGNED_BYTE&&(j=ee===kt?i.SRGB8_ALPHA8:i.RGBA8),k===i.UNSIGNED_SHORT_4_4_4_4&&(j=i.RGBA4),k===i.UNSIGNED_SHORT_5_5_5_1&&(j=i.RGB5_A1)}return(j===i.R16F||j===i.R32F||j===i.RG16F||j===i.RG32F||j===i.RGBA16F||j===i.RGBA32F)&&e.get("EXT_color_buffer_float"),j}function x(Z,B){let k;return Z?B===null||B===Lr||B===Or?k=i.DEPTH24_STENCIL8:B===si?k=i.DEPTH32F_STENCIL8:B===Zo&&(k=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):B===null||B===Lr||B===Or?k=i.DEPTH_COMPONENT24:B===si?k=i.DEPTH_COMPONENT32F:B===Zo&&(k=i.DEPTH_COMPONENT16),k}function _(Z,B){return f(Z)===!0||Z.isFramebufferTexture&&Z.minFilter!==Jt&&Z.minFilter!==nn?Math.log2(Math.max(B.width,B.height))+1:Z.mipmaps!==void 0&&Z.mipmaps.length>0?Z.mipmaps.length:Z.isCompressedTexture&&Array.isArray(Z.image)?B.mipmaps.length:1}function T(Z){let B=Z.target;B.removeEventListener("dispose",T),A(B),B.isVideoTexture&&u.delete(B)}function w(Z){let B=Z.target;B.removeEventListener("dispose",w),M(B)}function A(Z){let B=n.get(Z);if(B.__webglInit===void 0)return;let k=Z.source,F=d.get(k);if(F){let G=F[B.__cacheKey];G.usedTimes--,G.usedTimes===0&&E(Z),Object.keys(F).length===0&&d.delete(k)}n.remove(Z)}function E(Z){let B=n.get(Z);i.deleteTexture(B.__webglTexture);let k=Z.source,F=d.get(k);delete F[B.__cacheKey],o.memory.textures--}function M(Z){let B=n.get(Z);if(Z.depthTexture&&(Z.depthTexture.dispose(),n.remove(Z.depthTexture)),Z.isWebGLCubeRenderTarget)for(let F=0;F<6;F++){if(Array.isArray(B.__webglFramebuffer[F]))for(let G=0;G<B.__webglFramebuffer[F].length;G++)i.deleteFramebuffer(B.__webglFramebuffer[F][G]);else i.deleteFramebuffer(B.__webglFramebuffer[F]);B.__webglDepthbuffer&&i.deleteRenderbuffer(B.__webglDepthbuffer[F])}else{if(Array.isArray(B.__webglFramebuffer))for(let F=0;F<B.__webglFramebuffer.length;F++)i.deleteFramebuffer(B.__webglFramebuffer[F]);else i.deleteFramebuffer(B.__webglFramebuffer);if(B.__webglDepthbuffer&&i.deleteRenderbuffer(B.__webglDepthbuffer),B.__webglMultisampledFramebuffer&&i.deleteFramebuffer(B.__webglMultisampledFramebuffer),B.__webglColorRenderbuffer)for(let F=0;F<B.__webglColorRenderbuffer.length;F++)B.__webglColorRenderbuffer[F]&&i.deleteRenderbuffer(B.__webglColorRenderbuffer[F]);B.__webglDepthRenderbuffer&&i.deleteRenderbuffer(B.__webglDepthRenderbuffer)}let k=Z.textures;for(let F=0,G=k.length;F<G;F++){let j=n.get(k[F]);j.__webglTexture&&(i.deleteTexture(j.__webglTexture),o.memory.textures--),n.remove(k[F])}n.remove(Z)}let P=0;function N(){P=0}function L(){let Z=P;return Z>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+Z+" texture units while this GPU supports only "+r.maxTextures),P+=1,Z}function D(Z){let B=[];return B.push(Z.wrapS),B.push(Z.wrapT),B.push(Z.wrapR||0),B.push(Z.magFilter),B.push(Z.minFilter),B.push(Z.anisotropy),B.push(Z.internalFormat),B.push(Z.format),B.push(Z.type),B.push(Z.generateMipmaps),B.push(Z.premultiplyAlpha),B.push(Z.flipY),B.push(Z.unpackAlignment),B.push(Z.colorSpace),B.join()}function $(Z,B){let k=n.get(Z);if(Z.isVideoTexture&&he(Z),Z.isRenderTargetTexture===!1&&Z.version>0&&k.__version!==Z.version){let F=Z.image;if(F===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(F.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{O(k,Z,B);return}}t.bindTexture(i.TEXTURE_2D,k.__webglTexture,i.TEXTURE0+B)}function U(Z,B){let k=n.get(Z);if(Z.version>0&&k.__version!==Z.version){O(k,Z,B);return}t.bindTexture(i.TEXTURE_2D_ARRAY,k.__webglTexture,i.TEXTURE0+B)}function I(Z,B){let k=n.get(Z);if(Z.version>0&&k.__version!==Z.version){O(k,Z,B);return}t.bindTexture(i.TEXTURE_3D,k.__webglTexture,i.TEXTURE0+B)}function V(Z,B){let k=n.get(Z);if(Z.version>0&&k.__version!==Z.version){S(k,Z,B);return}t.bindTexture(i.TEXTURE_CUBE_MAP,k.__webglTexture,i.TEXTURE0+B)}let W={[gn]:i.REPEAT,[En]:i.CLAMP_TO_EDGE,[ks]:i.MIRRORED_REPEAT},Q={[Jt]:i.NEAREST,[Mc]:i.NEAREST_MIPMAP_NEAREST,[hs]:i.NEAREST_MIPMAP_LINEAR,[nn]:i.LINEAR,[Zs]:i.LINEAR_MIPMAP_NEAREST,[Mi]:i.LINEAR_MIPMAP_LINEAR},se={[E0]:i.NEVER,[R0]:i.ALWAYS,[M0]:i.LESS,[Ep]:i.LEQUAL,[S0]:i.EQUAL,[w0]:i.GEQUAL,[T0]:i.GREATER,[A0]:i.NOTEQUAL};function oe(Z,B){if(B.type===si&&e.has("OES_texture_float_linear")===!1&&(B.magFilter===nn||B.magFilter===Zs||B.magFilter===hs||B.magFilter===Mi||B.minFilter===nn||B.minFilter===Zs||B.minFilter===hs||B.minFilter===Mi)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(Z,i.TEXTURE_WRAP_S,W[B.wrapS]),i.texParameteri(Z,i.TEXTURE_WRAP_T,W[B.wrapT]),(Z===i.TEXTURE_3D||Z===i.TEXTURE_2D_ARRAY)&&i.texParameteri(Z,i.TEXTURE_WRAP_R,W[B.wrapR]),i.texParameteri(Z,i.TEXTURE_MAG_FILTER,Q[B.magFilter]),i.texParameteri(Z,i.TEXTURE_MIN_FILTER,Q[B.minFilter]),B.compareFunction&&(i.texParameteri(Z,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(Z,i.TEXTURE_COMPARE_FUNC,se[B.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(B.magFilter===Jt||B.minFilter!==hs&&B.minFilter!==Mi||B.type===si&&e.has("OES_texture_float_linear")===!1)return;if(B.anisotropy>1||n.get(B).__currentAnisotropy){let k=e.get("EXT_texture_filter_anisotropic");i.texParameterf(Z,k.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(B.anisotropy,r.getMaxAnisotropy())),n.get(B).__currentAnisotropy=B.anisotropy}}}function ge(Z,B){let k=!1;Z.__webglInit===void 0&&(Z.__webglInit=!0,B.addEventListener("dispose",T));let F=B.source,G=d.get(F);G===void 0&&(G={},d.set(F,G));let j=D(B);if(j!==Z.__cacheKey){G[j]===void 0&&(G[j]={texture:i.createTexture(),usedTimes:0},o.memory.textures++,k=!0),G[j].usedTimes++;let ee=G[Z.__cacheKey];ee!==void 0&&(G[Z.__cacheKey].usedTimes--,ee.usedTimes===0&&E(B)),Z.__cacheKey=j,Z.__webglTexture=G[j].texture}return k}function O(Z,B,k){let F=i.TEXTURE_2D;(B.isDataArrayTexture||B.isCompressedArrayTexture)&&(F=i.TEXTURE_2D_ARRAY),B.isData3DTexture&&(F=i.TEXTURE_3D);let G=ge(Z,B),j=B.source;t.bindTexture(F,Z.__webglTexture,i.TEXTURE0+k);let ee=n.get(j);if(j.version!==ee.__version||G===!0){t.activeTexture(i.TEXTURE0+k);let ie=bt.getPrimaries(bt.workingColorSpace),ce=B.colorSpace===Dr?null:bt.getPrimaries(B.colorSpace),fe=B.colorSpace===Dr||ie===ce?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,B.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,B.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,fe);let ue=y(B.image,!1,r.maxTextureSize);ue=Ne(B,ue);let Ee=s.convert(B.format,B.colorSpace),Se=s.convert(B.type),De=b(B.internalFormat,Ee,Se,B.colorSpace,B.isVideoTexture);oe(F,B);let ze,Je=B.mipmaps,Fe=B.isVideoTexture!==!0,Xe=ee.__version===void 0||G===!0,ae=j.dataReady,Le=_(B,ue);if(B.isDepthTexture)De=x(B.format===Er,B.type),Xe&&(Fe?t.texStorage2D(i.TEXTURE_2D,1,De,ue.width,ue.height):t.texImage2D(i.TEXTURE_2D,0,De,ue.width,ue.height,0,Ee,Se,null));else if(B.isDataTexture)if(Je.length>0){Fe&&Xe&&t.texStorage2D(i.TEXTURE_2D,Le,De,Je[0].width,Je[0].height);for(let xe=0,ye=Je.length;xe<ye;xe++)ze=Je[xe],Fe?ae&&t.texSubImage2D(i.TEXTURE_2D,xe,0,0,ze.width,ze.height,Ee,Se,ze.data):t.texImage2D(i.TEXTURE_2D,xe,De,ze.width,ze.height,0,Ee,Se,ze.data);B.generateMipmaps=!1}else Fe?(Xe&&t.texStorage2D(i.TEXTURE_2D,Le,De,ue.width,ue.height),ae&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,ue.width,ue.height,Ee,Se,ue.data)):t.texImage2D(i.TEXTURE_2D,0,De,ue.width,ue.height,0,Ee,Se,ue.data);else if(B.isCompressedTexture)if(B.isCompressedArrayTexture){Fe&&Xe&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Le,De,Je[0].width,Je[0].height,ue.depth);for(let xe=0,ye=Je.length;xe<ye;xe++)if(ze=Je[xe],B.format!==Ln)if(Ee!==null)if(Fe){if(ae)if(B.layerUpdates.size>0){let Ue=Ap(ze.width,ze.height,B.format,B.type);for(let Oe of B.layerUpdates){let st=ze.data.subarray(Oe*Ue/ze.data.BYTES_PER_ELEMENT,(Oe+1)*Ue/ze.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,xe,0,0,Oe,ze.width,ze.height,1,Ee,st)}B.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,xe,0,0,0,ze.width,ze.height,ue.depth,Ee,ze.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,xe,De,ze.width,ze.height,ue.depth,0,ze.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Fe?ae&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,xe,0,0,0,ze.width,ze.height,ue.depth,Ee,Se,ze.data):t.texImage3D(i.TEXTURE_2D_ARRAY,xe,De,ze.width,ze.height,ue.depth,0,Ee,Se,ze.data)}else{Fe&&Xe&&t.texStorage2D(i.TEXTURE_2D,Le,De,Je[0].width,Je[0].height);for(let xe=0,ye=Je.length;xe<ye;xe++)ze=Je[xe],B.format!==Ln?Ee!==null?Fe?ae&&t.compressedTexSubImage2D(i.TEXTURE_2D,xe,0,0,ze.width,ze.height,Ee,ze.data):t.compressedTexImage2D(i.TEXTURE_2D,xe,De,ze.width,ze.height,0,ze.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Fe?ae&&t.texSubImage2D(i.TEXTURE_2D,xe,0,0,ze.width,ze.height,Ee,Se,ze.data):t.texImage2D(i.TEXTURE_2D,xe,De,ze.width,ze.height,0,Ee,Se,ze.data)}else if(B.isDataArrayTexture)if(Fe){if(Xe&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Le,De,ue.width,ue.height,ue.depth),ae)if(B.layerUpdates.size>0){let xe=Ap(ue.width,ue.height,B.format,B.type);for(let ye of B.layerUpdates){let Ue=ue.data.subarray(ye*xe/ue.data.BYTES_PER_ELEMENT,(ye+1)*xe/ue.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ye,ue.width,ue.height,1,Ee,Se,Ue)}B.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,ue.width,ue.height,ue.depth,Ee,Se,ue.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,De,ue.width,ue.height,ue.depth,0,Ee,Se,ue.data);else if(B.isData3DTexture)Fe?(Xe&&t.texStorage3D(i.TEXTURE_3D,Le,De,ue.width,ue.height,ue.depth),ae&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,ue.width,ue.height,ue.depth,Ee,Se,ue.data)):t.texImage3D(i.TEXTURE_3D,0,De,ue.width,ue.height,ue.depth,0,Ee,Se,ue.data);else if(B.isFramebufferTexture){if(Xe)if(Fe)t.texStorage2D(i.TEXTURE_2D,Le,De,ue.width,ue.height);else{let xe=ue.width,ye=ue.height;for(let Ue=0;Ue<Le;Ue++)t.texImage2D(i.TEXTURE_2D,Ue,De,xe,ye,0,Ee,Se,null),xe>>=1,ye>>=1}}else if(Je.length>0){if(Fe&&Xe){let xe=Me(Je[0]);t.texStorage2D(i.TEXTURE_2D,Le,De,xe.width,xe.height)}for(let xe=0,ye=Je.length;xe<ye;xe++)ze=Je[xe],Fe?ae&&t.texSubImage2D(i.TEXTURE_2D,xe,0,0,Ee,Se,ze):t.texImage2D(i.TEXTURE_2D,xe,De,Ee,Se,ze);B.generateMipmaps=!1}else if(Fe){if(Xe){let xe=Me(ue);t.texStorage2D(i.TEXTURE_2D,Le,De,xe.width,xe.height)}ae&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Ee,Se,ue)}else t.texImage2D(i.TEXTURE_2D,0,De,Ee,Se,ue);f(B)&&p(F),ee.__version=j.version,B.onUpdate&&B.onUpdate(B)}Z.__version=B.version}function S(Z,B,k){if(B.image.length!==6)return;let F=ge(Z,B),G=B.source;t.bindTexture(i.TEXTURE_CUBE_MAP,Z.__webglTexture,i.TEXTURE0+k);let j=n.get(G);if(G.version!==j.__version||F===!0){t.activeTexture(i.TEXTURE0+k);let ee=bt.getPrimaries(bt.workingColorSpace),ie=B.colorSpace===Dr?null:bt.getPrimaries(B.colorSpace),ce=B.colorSpace===Dr||ee===ie?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,B.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,B.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,B.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ce);let fe=B.isCompressedTexture||B.image[0].isCompressedTexture,ue=B.image[0]&&B.image[0].isDataTexture,Ee=[];for(let ye=0;ye<6;ye++)!fe&&!ue?Ee[ye]=y(B.image[ye],!0,r.maxCubemapSize):Ee[ye]=ue?B.image[ye].image:B.image[ye],Ee[ye]=Ne(B,Ee[ye]);let Se=Ee[0],De=s.convert(B.format,B.colorSpace),ze=s.convert(B.type),Je=b(B.internalFormat,De,ze,B.colorSpace),Fe=B.isVideoTexture!==!0,Xe=j.__version===void 0||F===!0,ae=G.dataReady,Le=_(B,Se);oe(i.TEXTURE_CUBE_MAP,B);let xe;if(fe){Fe&&Xe&&t.texStorage2D(i.TEXTURE_CUBE_MAP,Le,Je,Se.width,Se.height);for(let ye=0;ye<6;ye++){xe=Ee[ye].mipmaps;for(let Ue=0;Ue<xe.length;Ue++){let Oe=xe[Ue];B.format!==Ln?De!==null?Fe?ae&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ue,0,0,Oe.width,Oe.height,De,Oe.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ue,Je,Oe.width,Oe.height,0,Oe.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Fe?ae&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ue,0,0,Oe.width,Oe.height,De,ze,Oe.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ue,Je,Oe.width,Oe.height,0,De,ze,Oe.data)}}}else{if(xe=B.mipmaps,Fe&&Xe){xe.length>0&&Le++;let ye=Me(Ee[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Le,Je,ye.width,ye.height)}for(let ye=0;ye<6;ye++)if(ue){Fe?ae&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,Ee[ye].width,Ee[ye].height,De,ze,Ee[ye].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,Je,Ee[ye].width,Ee[ye].height,0,De,ze,Ee[ye].data);for(let Ue=0;Ue<xe.length;Ue++){let st=xe[Ue].image[ye].image;Fe?ae&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ue+1,0,0,st.width,st.height,De,ze,st.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ue+1,Je,st.width,st.height,0,De,ze,st.data)}}else{Fe?ae&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,0,0,De,ze,Ee[ye]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,0,Je,De,ze,Ee[ye]);for(let Ue=0;Ue<xe.length;Ue++){let Oe=xe[Ue];Fe?ae&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ue+1,0,0,De,ze,Oe.image[ye]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ye,Ue+1,Je,De,ze,Oe.image[ye])}}}f(B)&&p(i.TEXTURE_CUBE_MAP),j.__version=G.version,B.onUpdate&&B.onUpdate(B)}Z.__version=B.version}function R(Z,B,k,F,G,j){let ee=s.convert(k.format,k.colorSpace),ie=s.convert(k.type),ce=b(k.internalFormat,ee,ie,k.colorSpace),fe=n.get(B),ue=n.get(k);if(ue.__renderTarget=B,!fe.__hasExternalTextures){let Ee=Math.max(1,B.width>>j),Se=Math.max(1,B.height>>j);G===i.TEXTURE_3D||G===i.TEXTURE_2D_ARRAY?t.texImage3D(G,j,ce,Ee,Se,B.depth,0,ee,ie,null):t.texImage2D(G,j,ce,Ee,Se,0,ee,ie,null)}t.bindFramebuffer(i.FRAMEBUFFER,Z),be(B)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,F,G,ue.__webglTexture,0,me(B)):(G===i.TEXTURE_2D||G>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&G<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,F,G,ue.__webglTexture,j),t.bindFramebuffer(i.FRAMEBUFFER,null)}function z(Z,B,k){if(i.bindRenderbuffer(i.RENDERBUFFER,Z),B.depthBuffer){let F=B.depthTexture,G=F&&F.isDepthTexture?F.type:null,j=x(B.stencilBuffer,G),ee=B.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=me(B);be(B)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ie,j,B.width,B.height):k?i.renderbufferStorageMultisample(i.RENDERBUFFER,ie,j,B.width,B.height):i.renderbufferStorage(i.RENDERBUFFER,j,B.width,B.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ee,i.RENDERBUFFER,Z)}else{let F=B.textures;for(let G=0;G<F.length;G++){let j=F[G],ee=s.convert(j.format,j.colorSpace),ie=s.convert(j.type),ce=b(j.internalFormat,ee,ie,j.colorSpace),fe=me(B);k&&be(B)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,fe,ce,B.width,B.height):be(B)?a.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,fe,ce,B.width,B.height):i.renderbufferStorage(i.RENDERBUFFER,ce,B.width,B.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Y(Z,B){if(B&&B.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,Z),!(B.depthTexture&&B.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");let F=n.get(B.depthTexture);F.__renderTarget=B,(!F.__webglTexture||B.depthTexture.image.width!==B.width||B.depthTexture.image.height!==B.height)&&(B.depthTexture.image.width=B.width,B.depthTexture.image.height=B.height,B.depthTexture.needsUpdate=!0),$(B.depthTexture,0);let G=F.__webglTexture,j=me(B);if(B.depthTexture.format===Ds)be(B)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,G,0,j):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,G,0);else if(B.depthTexture.format===Er)be(B)?a.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,G,0,j):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,G,0);else throw new Error("Unknown depthTexture format")}function K(Z){let B=n.get(Z),k=Z.isWebGLCubeRenderTarget===!0;if(B.__boundDepthTexture!==Z.depthTexture){let F=Z.depthTexture;if(B.__depthDisposeCallback&&B.__depthDisposeCallback(),F){let G=()=>{delete B.__boundDepthTexture,delete B.__depthDisposeCallback,F.removeEventListener("dispose",G)};F.addEventListener("dispose",G),B.__depthDisposeCallback=G}B.__boundDepthTexture=F}if(Z.depthTexture&&!B.__autoAllocateDepthBuffer){if(k)throw new Error("target.depthTexture not supported in Cube render targets");Y(B.__webglFramebuffer,Z)}else if(k){B.__webglDepthbuffer=[];for(let F=0;F<6;F++)if(t.bindFramebuffer(i.FRAMEBUFFER,B.__webglFramebuffer[F]),B.__webglDepthbuffer[F]===void 0)B.__webglDepthbuffer[F]=i.createRenderbuffer(),z(B.__webglDepthbuffer[F],Z,!1);else{let G=Z.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,j=B.__webglDepthbuffer[F];i.bindRenderbuffer(i.RENDERBUFFER,j),i.framebufferRenderbuffer(i.FRAMEBUFFER,G,i.RENDERBUFFER,j)}}else if(t.bindFramebuffer(i.FRAMEBUFFER,B.__webglFramebuffer),B.__webglDepthbuffer===void 0)B.__webglDepthbuffer=i.createRenderbuffer(),z(B.__webglDepthbuffer,Z,!1);else{let F=Z.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,G=B.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,G),i.framebufferRenderbuffer(i.FRAMEBUFFER,F,i.RENDERBUFFER,G)}t.bindFramebuffer(i.FRAMEBUFFER,null)}function re(Z,B,k){let F=n.get(Z);B!==void 0&&R(F.__webglFramebuffer,Z,Z.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),k!==void 0&&K(Z)}function de(Z){let B=Z.texture,k=n.get(Z),F=n.get(B);Z.addEventListener("dispose",w);let G=Z.textures,j=Z.isWebGLCubeRenderTarget===!0,ee=G.length>1;if(ee||(F.__webglTexture===void 0&&(F.__webglTexture=i.createTexture()),F.__version=B.version,o.memory.textures++),j){k.__webglFramebuffer=[];for(let ie=0;ie<6;ie++)if(B.mipmaps&&B.mipmaps.length>0){k.__webglFramebuffer[ie]=[];for(let ce=0;ce<B.mipmaps.length;ce++)k.__webglFramebuffer[ie][ce]=i.createFramebuffer()}else k.__webglFramebuffer[ie]=i.createFramebuffer()}else{if(B.mipmaps&&B.mipmaps.length>0){k.__webglFramebuffer=[];for(let ie=0;ie<B.mipmaps.length;ie++)k.__webglFramebuffer[ie]=i.createFramebuffer()}else k.__webglFramebuffer=i.createFramebuffer();if(ee)for(let ie=0,ce=G.length;ie<ce;ie++){let fe=n.get(G[ie]);fe.__webglTexture===void 0&&(fe.__webglTexture=i.createTexture(),o.memory.textures++)}if(Z.samples>0&&be(Z)===!1){k.__webglMultisampledFramebuffer=i.createFramebuffer(),k.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,k.__webglMultisampledFramebuffer);for(let ie=0;ie<G.length;ie++){let ce=G[ie];k.__webglColorRenderbuffer[ie]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,k.__webglColorRenderbuffer[ie]);let fe=s.convert(ce.format,ce.colorSpace),ue=s.convert(ce.type),Ee=b(ce.internalFormat,fe,ue,ce.colorSpace,Z.isXRRenderTarget===!0),Se=me(Z);i.renderbufferStorageMultisample(i.RENDERBUFFER,Se,Ee,Z.width,Z.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ie,i.RENDERBUFFER,k.__webglColorRenderbuffer[ie])}i.bindRenderbuffer(i.RENDERBUFFER,null),Z.depthBuffer&&(k.__webglDepthRenderbuffer=i.createRenderbuffer(),z(k.__webglDepthRenderbuffer,Z,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(j){t.bindTexture(i.TEXTURE_CUBE_MAP,F.__webglTexture),oe(i.TEXTURE_CUBE_MAP,B);for(let ie=0;ie<6;ie++)if(B.mipmaps&&B.mipmaps.length>0)for(let ce=0;ce<B.mipmaps.length;ce++)R(k.__webglFramebuffer[ie][ce],Z,B,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,ce);else R(k.__webglFramebuffer[ie],Z,B,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+ie,0);f(B)&&p(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ee){for(let ie=0,ce=G.length;ie<ce;ie++){let fe=G[ie],ue=n.get(fe);t.bindTexture(i.TEXTURE_2D,ue.__webglTexture),oe(i.TEXTURE_2D,fe),R(k.__webglFramebuffer,Z,fe,i.COLOR_ATTACHMENT0+ie,i.TEXTURE_2D,0),f(fe)&&p(i.TEXTURE_2D)}t.unbindTexture()}else{let ie=i.TEXTURE_2D;if((Z.isWebGL3DRenderTarget||Z.isWebGLArrayRenderTarget)&&(ie=Z.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ie,F.__webglTexture),oe(ie,B),B.mipmaps&&B.mipmaps.length>0)for(let ce=0;ce<B.mipmaps.length;ce++)R(k.__webglFramebuffer[ce],Z,B,i.COLOR_ATTACHMENT0,ie,ce);else R(k.__webglFramebuffer,Z,B,i.COLOR_ATTACHMENT0,ie,0);f(B)&&p(ie),t.unbindTexture()}Z.depthBuffer&&K(Z)}function te(Z){let B=Z.textures;for(let k=0,F=B.length;k<F;k++){let G=B[k];if(f(G)){let j=v(Z),ee=n.get(G).__webglTexture;t.bindTexture(j,ee),p(j),t.unbindTexture()}}}let ne=[],H=[];function _e(Z){if(Z.samples>0){if(be(Z)===!1){let B=Z.textures,k=Z.width,F=Z.height,G=i.COLOR_BUFFER_BIT,j=Z.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ee=n.get(Z),ie=B.length>1;if(ie)for(let ce=0;ce<B.length;ce++)t.bindFramebuffer(i.FRAMEBUFFER,ee.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ee.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ee.__webglMultisampledFramebuffer),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ee.__webglFramebuffer);for(let ce=0;ce<B.length;ce++){if(Z.resolveDepthBuffer&&(Z.depthBuffer&&(G|=i.DEPTH_BUFFER_BIT),Z.stencilBuffer&&Z.resolveStencilBuffer&&(G|=i.STENCIL_BUFFER_BIT)),ie){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ee.__webglColorRenderbuffer[ce]);let fe=n.get(B[ce]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,fe,0)}i.blitFramebuffer(0,0,k,F,0,0,k,F,G,i.NEAREST),c===!0&&(ne.length=0,H.length=0,ne.push(i.COLOR_ATTACHMENT0+ce),Z.depthBuffer&&Z.resolveDepthBuffer===!1&&(ne.push(j),H.push(j),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,H)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,ne))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),ie)for(let ce=0;ce<B.length;ce++){t.bindFramebuffer(i.FRAMEBUFFER,ee.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.RENDERBUFFER,ee.__webglColorRenderbuffer[ce]);let fe=n.get(B[ce]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ee.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ce,i.TEXTURE_2D,fe,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ee.__webglMultisampledFramebuffer)}else if(Z.depthBuffer&&Z.resolveDepthBuffer===!1&&c){let B=Z.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[B])}}}function me(Z){return Math.min(r.maxSamples,Z.samples)}function be(Z){let B=n.get(Z);return Z.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&B.__useRenderToTexture!==!1}function he(Z){let B=o.render.frame;u.get(Z)!==B&&(u.set(Z,B),Z.update())}function Ne(Z,B){let k=Z.colorSpace,F=Z.format,G=Z.type;return Z.isCompressedTexture===!0||Z.isVideoTexture===!0||k!==On&&k!==Dr&&(bt.getTransfer(k)===kt?(F!==Ln||G!==ci)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",k)),B}function Me(Z){return typeof HTMLImageElement<"u"&&Z instanceof HTMLImageElement?(l.width=Z.naturalWidth||Z.width,l.height=Z.naturalHeight||Z.height):typeof VideoFrame<"u"&&Z instanceof VideoFrame?(l.width=Z.displayWidth,l.height=Z.displayHeight):(l.width=Z.width,l.height=Z.height),l}this.allocateTextureUnit=L,this.resetTextureUnits=N,this.setTexture2D=$,this.setTexture2DArray=U,this.setTexture3D=I,this.setTextureCube=V,this.rebindTextures=re,this.setupRenderTarget=de,this.updateRenderTargetMipmap=te,this.updateMultisampleRenderTarget=_e,this.setupDepthRenderbuffer=K,this.setupFrameBufferTexture=R,this.useMultisampledRTT=be}function Y_(i,e){function t(n,r=Dr){let s,o=bt.getTransfer(r);if(n===ci)return i.UNSIGNED_BYTE;if(n===Hu)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Gu)return i.UNSIGNED_SHORT_5_5_5_1;if(n===fp)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===hp)return i.BYTE;if(n===dp)return i.SHORT;if(n===Zo)return i.UNSIGNED_SHORT;if(n===Vu)return i.INT;if(n===Lr)return i.UNSIGNED_INT;if(n===si)return i.FLOAT;if(n===Hn)return i.HALF_FLOAT;if(n===pp)return i.ALPHA;if(n===mp)return i.RGB;if(n===Ln)return i.RGBA;if(n===gp)return i.LUMINANCE;if(n===yp)return i.LUMINANCE_ALPHA;if(n===Ds)return i.DEPTH_COMPONENT;if(n===Er)return i.DEPTH_STENCIL;if(n===Wu)return i.RED;if(n===Sc)return i.RED_INTEGER;if(n===xp)return i.RG;if(n===Xu)return i.RG_INTEGER;if(n===Yu)return i.RGBA_INTEGER;if(n===Tc||n===Ac||n===wc||n===Rc)if(o===kt)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Tc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ac)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===wc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Rc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Tc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ac)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===wc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Rc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ju||n===qu||n===Ku||n===Zu)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===ju)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===qu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ku)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Zu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ju||n===Qu||n===$u)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(n===Ju||n===Qu)return o===kt?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===$u)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===eh||n===th||n===nh||n===ih||n===rh||n===sh||n===oh||n===ah||n===ch||n===lh||n===uh||n===hh||n===dh||n===fh)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(n===eh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===th)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===nh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===ih)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===rh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===sh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===oh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===ah)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===ch)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===lh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===uh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===hh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===dh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===fh)return o===kt?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Cc||n===ph||n===mh)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(n===Cc)return o===kt?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ph)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===mh)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===vp||n===gh||n===yh||n===xh)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(n===Cc)return s.COMPRESSED_RED_RGTC1_EXT;if(n===gh)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===yh)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===xh)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Or?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}var BC={type:"move"},_h=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Dt,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 Dt,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new q,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new q),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Dt,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new q,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new q),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,s=null,o=null,a=this._targetRay,c=this._grip,l=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(l&&e.hand){o=!0;for(let y of e.hand.values()){let f=t.getJointPose(y,n),p=this._getHandJoint(l,y);f!==null&&(p.matrix.fromArray(f.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=f.radius),p.visible=f!==null}let u=l.joints["index-finger-tip"],h=l.joints["thumb-tip"],d=u.position.distanceTo(h.position),m=.02,g=.005;l.inputState.pinching&&d>m+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&d<=m-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else c!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,n),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(BC)))}return a!==null&&(a.visible=r!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new Dt;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},zC=`
void main() {

	gl_Position = vec4( position, 1.0 );

}`,VC=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;

void main() {

	vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );

	if ( coord.x >= 1.0 ) {

		gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;

	} else {

		gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;

	}

}`,Z0=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t,n){if(this.texture===null){let r=new Qt,s=e.properties.get(r);s.__webglTexture=t.texture,(t.depthNear!=n.depthNear||t.depthFar!=n.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new $t({vertexShader:zC,fragmentShader:VC,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new ct(new Ar(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},J0=class extends ki{constructor(e,t){super();let n=this,r=null,s=1,o=null,a="local-floor",c=1,l=null,u=null,h=null,d=null,m=null,g=null,y=new Z0,f=t.getContextAttributes(),p=null,v=null,b=[],x=[],_=new Ce,T=null,w=new jt;w.viewport=new It;let A=new jt;A.viewport=new It;let E=[w,A],M=new Eu,P=null,N=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(O){let S=b[O];return S===void 0&&(S=new _h,b[O]=S),S.getTargetRaySpace()},this.getControllerGrip=function(O){let S=b[O];return S===void 0&&(S=new _h,b[O]=S),S.getGripSpace()},this.getHand=function(O){let S=b[O];return S===void 0&&(S=new _h,b[O]=S),S.getHandSpace()};function L(O){let S=x.indexOf(O.inputSource);if(S===-1)return;let R=b[S];R!==void 0&&(R.update(O.inputSource,O.frame,l||o),R.dispatchEvent({type:O.type,data:O.inputSource}))}function D(){r.removeEventListener("select",L),r.removeEventListener("selectstart",L),r.removeEventListener("selectend",L),r.removeEventListener("squeeze",L),r.removeEventListener("squeezestart",L),r.removeEventListener("squeezeend",L),r.removeEventListener("end",D),r.removeEventListener("inputsourceschange",$);for(let O=0;O<b.length;O++){let S=x[O];S!==null&&(x[O]=null,b[O].disconnect(S))}P=null,N=null,y.reset(),e.setRenderTarget(p),m=null,d=null,h=null,r=null,v=null,ge.stop(),n.isPresenting=!1,e.setPixelRatio(T),e.setSize(_.width,_.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(O){s=O,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(O){a=O,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||o},this.setReferenceSpace=function(O){l=O},this.getBaseLayer=function(){return d!==null?d:m},this.getBinding=function(){return h},this.getFrame=function(){return g},this.getSession=function(){return r},this.setSession=async function(O){if(r=O,r!==null){if(p=e.getRenderTarget(),r.addEventListener("select",L),r.addEventListener("selectstart",L),r.addEventListener("selectend",L),r.addEventListener("squeeze",L),r.addEventListener("squeezestart",L),r.addEventListener("squeezeend",L),r.addEventListener("end",D),r.addEventListener("inputsourceschange",$),f.xrCompatible!==!0&&await t.makeXRCompatible(),T=e.getPixelRatio(),e.getSize(_),r.renderState.layers===void 0){let S={antialias:f.antialias,alpha:!0,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(r,t,S),r.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),v=new on(m.framebufferWidth,m.framebufferHeight,{format:Ln,type:ci,colorSpace:e.outputColorSpace,stencilBuffer:f.stencil})}else{let S=null,R=null,z=null;f.depth&&(z=f.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,S=f.stencil?Er:Ds,R=f.stencil?Or:Lr);let Y={colorFormat:t.RGBA8,depthFormat:z,scaleFactor:s};h=new XRWebGLBinding(r,t),d=h.createProjectionLayer(Y),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),v=new on(d.textureWidth,d.textureHeight,{format:Ln,type:ci,depthTexture:new Xs(d.textureWidth,d.textureHeight,R,void 0,void 0,void 0,void 0,void 0,void 0,S),stencilBuffer:f.stencil,colorSpace:e.outputColorSpace,samples:f.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1})}v.isXRRenderTarget=!0,this.setFoveation(c),l=null,o=await r.requestReferenceSpace(a),ge.setContext(r),ge.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return y.getDepthTexture()};function $(O){for(let S=0;S<O.removed.length;S++){let R=O.removed[S],z=x.indexOf(R);z>=0&&(x[z]=null,b[z].disconnect(R))}for(let S=0;S<O.added.length;S++){let R=O.added[S],z=x.indexOf(R);if(z===-1){for(let K=0;K<b.length;K++)if(K>=x.length){x.push(R),z=K;break}else if(x[K]===null){x[K]=R,z=K;break}if(z===-1)break}let Y=b[z];Y&&Y.connect(R)}}let U=new q,I=new q;function V(O,S,R){U.setFromMatrixPosition(S.matrixWorld),I.setFromMatrixPosition(R.matrixWorld);let z=U.distanceTo(I),Y=S.projectionMatrix.elements,K=R.projectionMatrix.elements,re=Y[14]/(Y[10]-1),de=Y[14]/(Y[10]+1),te=(Y[9]+1)/Y[5],ne=(Y[9]-1)/Y[5],H=(Y[8]-1)/Y[0],_e=(K[8]+1)/K[0],me=re*H,be=re*_e,he=z/(-H+_e),Ne=he*-H;if(S.matrixWorld.decompose(O.position,O.quaternion,O.scale),O.translateX(Ne),O.translateZ(he),O.matrixWorld.compose(O.position,O.quaternion,O.scale),O.matrixWorldInverse.copy(O.matrixWorld).invert(),Y[10]===-1)O.projectionMatrix.copy(S.projectionMatrix),O.projectionMatrixInverse.copy(S.projectionMatrixInverse);else{let Me=re+he,Z=de+he,B=me-Ne,k=be+(z-Ne),F=te*de/Z*Me,G=ne*de/Z*Me;O.projectionMatrix.makePerspective(B,k,F,G,Me,Z),O.projectionMatrixInverse.copy(O.projectionMatrix).invert()}}function W(O,S){S===null?O.matrixWorld.copy(O.matrix):O.matrixWorld.multiplyMatrices(S.matrixWorld,O.matrix),O.matrixWorldInverse.copy(O.matrixWorld).invert()}this.updateCamera=function(O){if(r===null)return;let S=O.near,R=O.far;y.texture!==null&&(y.depthNear>0&&(S=y.depthNear),y.depthFar>0&&(R=y.depthFar)),M.near=A.near=w.near=S,M.far=A.far=w.far=R,(P!==M.near||N!==M.far)&&(r.updateRenderState({depthNear:M.near,depthFar:M.far}),P=M.near,N=M.far),w.layers.mask=O.layers.mask|2,A.layers.mask=O.layers.mask|4,M.layers.mask=w.layers.mask|A.layers.mask;let z=O.parent,Y=M.cameras;W(M,z);for(let K=0;K<Y.length;K++)W(Y[K],z);Y.length===2?V(M,w,A):M.projectionMatrix.copy(w.projectionMatrix),Q(O,M,z)};function Q(O,S,R){R===null?O.matrix.copy(S.matrixWorld):(O.matrix.copy(R.matrixWorld),O.matrix.invert(),O.matrix.multiply(S.matrixWorld)),O.matrix.decompose(O.position,O.quaternion,O.scale),O.updateMatrixWorld(!0),O.projectionMatrix.copy(S.projectionMatrix),O.projectionMatrixInverse.copy(S.projectionMatrixInverse),O.isPerspectiveCamera&&(O.fov=Po*2*Math.atan(1/O.projectionMatrix.elements[5]),O.zoom=1)}this.getCamera=function(){return M},this.getFoveation=function(){if(!(d===null&&m===null))return c},this.setFoveation=function(O){c=O,d!==null&&(d.fixedFoveation=O),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=O)},this.hasDepthSensing=function(){return y.texture!==null},this.getDepthSensingMesh=function(){return y.getMesh(M)};let se=null;function oe(O,S){if(u=S.getViewerPose(l||o),g=S,u!==null){let R=u.views;m!==null&&(e.setRenderTargetFramebuffer(v,m.framebuffer),e.setRenderTarget(v));let z=!1;R.length!==M.cameras.length&&(M.cameras.length=0,z=!0);for(let K=0;K<R.length;K++){let re=R[K],de=null;if(m!==null)de=m.getViewport(re);else{let ne=h.getViewSubImage(d,re);de=ne.viewport,K===0&&(e.setRenderTargetTextures(v,ne.colorTexture,d.ignoreDepthValues?void 0:ne.depthStencilTexture),e.setRenderTarget(v))}let te=E[K];te===void 0&&(te=new jt,te.layers.enable(K),te.viewport=new It,E[K]=te),te.matrix.fromArray(re.transform.matrix),te.matrix.decompose(te.position,te.quaternion,te.scale),te.projectionMatrix.fromArray(re.projectionMatrix),te.projectionMatrixInverse.copy(te.projectionMatrix).invert(),te.viewport.set(de.x,de.y,de.width,de.height),K===0&&(M.matrix.copy(te.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),z===!0&&M.cameras.push(te)}let Y=r.enabledFeatures;if(Y&&Y.includes("depth-sensing")){let K=h.getDepthInformation(R[0]);K&&K.isValid&&K.texture&&y.init(e,K,r.renderState)}}for(let R=0;R<b.length;R++){let z=x[R],Y=b[R];z!==null&&Y!==void 0&&Y.update(z,S,l||o)}se&&se(O,S),S.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:S}),g=null}let ge=new V_;ge.setAnimationLoop(oe),this.setAnimationLoop=function(O){se=O},this.dispose=function(){}}},ta=new xi,HC=new nt;function GC(i,e){function t(f,p){f.matrixAutoUpdate===!0&&f.updateMatrix(),p.value.copy(f.matrix)}function n(f,p){p.color.getRGB(f.fogColor.value,N0(i)),p.isFog?(f.fogNear.value=p.near,f.fogFar.value=p.far):p.isFogExp2&&(f.fogDensity.value=p.density)}function r(f,p,v,b,x){p.isMeshBasicMaterial||p.isMeshLambertMaterial?s(f,p):p.isMeshToonMaterial?(s(f,p),h(f,p)):p.isMeshPhongMaterial?(s(f,p),u(f,p)):p.isMeshStandardMaterial?(s(f,p),d(f,p),p.isMeshPhysicalMaterial&&m(f,p,x)):p.isMeshMatcapMaterial?(s(f,p),g(f,p)):p.isMeshDepthMaterial?s(f,p):p.isMeshDistanceMaterial?(s(f,p),y(f,p)):p.isMeshNormalMaterial?s(f,p):p.isLineBasicMaterial?(o(f,p),p.isLineDashedMaterial&&a(f,p)):p.isPointsMaterial?c(f,p,v,b):p.isSpriteMaterial?l(f,p):p.isShadowMaterial?(f.color.value.copy(p.color),f.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function s(f,p){f.opacity.value=p.opacity,p.color&&f.diffuse.value.copy(p.color),p.emissive&&f.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(f.map.value=p.map,t(p.map,f.mapTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.bumpMap&&(f.bumpMap.value=p.bumpMap,t(p.bumpMap,f.bumpMapTransform),f.bumpScale.value=p.bumpScale,p.side===un&&(f.bumpScale.value*=-1)),p.normalMap&&(f.normalMap.value=p.normalMap,t(p.normalMap,f.normalMapTransform),f.normalScale.value.copy(p.normalScale),p.side===un&&f.normalScale.value.negate()),p.displacementMap&&(f.displacementMap.value=p.displacementMap,t(p.displacementMap,f.displacementMapTransform),f.displacementScale.value=p.displacementScale,f.displacementBias.value=p.displacementBias),p.emissiveMap&&(f.emissiveMap.value=p.emissiveMap,t(p.emissiveMap,f.emissiveMapTransform)),p.specularMap&&(f.specularMap.value=p.specularMap,t(p.specularMap,f.specularMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest);let v=e.get(p),b=v.envMap,x=v.envMapRotation;b&&(f.envMap.value=b,ta.copy(x),ta.x*=-1,ta.y*=-1,ta.z*=-1,b.isCubeTexture&&b.isRenderTargetTexture===!1&&(ta.y*=-1,ta.z*=-1),f.envMapRotation.value.setFromMatrix4(HC.makeRotationFromEuler(ta)),f.flipEnvMap.value=b.isCubeTexture&&b.isRenderTargetTexture===!1?-1:1,f.reflectivity.value=p.reflectivity,f.ior.value=p.ior,f.refractionRatio.value=p.refractionRatio),p.lightMap&&(f.lightMap.value=p.lightMap,f.lightMapIntensity.value=p.lightMapIntensity,t(p.lightMap,f.lightMapTransform)),p.aoMap&&(f.aoMap.value=p.aoMap,f.aoMapIntensity.value=p.aoMapIntensity,t(p.aoMap,f.aoMapTransform))}function o(f,p){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,p.map&&(f.map.value=p.map,t(p.map,f.mapTransform))}function a(f,p){f.dashSize.value=p.dashSize,f.totalSize.value=p.dashSize+p.gapSize,f.scale.value=p.scale}function c(f,p,v,b){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,f.size.value=p.size*v,f.scale.value=b*.5,p.map&&(f.map.value=p.map,t(p.map,f.uvTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest)}function l(f,p){f.diffuse.value.copy(p.color),f.opacity.value=p.opacity,f.rotation.value=p.rotation,p.map&&(f.map.value=p.map,t(p.map,f.mapTransform)),p.alphaMap&&(f.alphaMap.value=p.alphaMap,t(p.alphaMap,f.alphaMapTransform)),p.alphaTest>0&&(f.alphaTest.value=p.alphaTest)}function u(f,p){f.specular.value.copy(p.specular),f.shininess.value=Math.max(p.shininess,1e-4)}function h(f,p){p.gradientMap&&(f.gradientMap.value=p.gradientMap)}function d(f,p){f.metalness.value=p.metalness,p.metalnessMap&&(f.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,f.metalnessMapTransform)),f.roughness.value=p.roughness,p.roughnessMap&&(f.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,f.roughnessMapTransform)),p.envMap&&(f.envMapIntensity.value=p.envMapIntensity)}function m(f,p,v){f.ior.value=p.ior,p.sheen>0&&(f.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),f.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(f.sheenColorMap.value=p.sheenColorMap,t(p.sheenColorMap,f.sheenColorMapTransform)),p.sheenRoughnessMap&&(f.sheenRoughnessMap.value=p.sheenRoughnessMap,t(p.sheenRoughnessMap,f.sheenRoughnessMapTransform))),p.clearcoat>0&&(f.clearcoat.value=p.clearcoat,f.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(f.clearcoatMap.value=p.clearcoatMap,t(p.clearcoatMap,f.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,t(p.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(f.clearcoatNormalMap.value=p.clearcoatNormalMap,t(p.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===un&&f.clearcoatNormalScale.value.negate())),p.dispersion>0&&(f.dispersion.value=p.dispersion),p.iridescence>0&&(f.iridescence.value=p.iridescence,f.iridescenceIOR.value=p.iridescenceIOR,f.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(f.iridescenceMap.value=p.iridescenceMap,t(p.iridescenceMap,f.iridescenceMapTransform)),p.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=p.iridescenceThicknessMap,t(p.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),p.transmission>0&&(f.transmission.value=p.transmission,f.transmissionSamplerMap.value=v.texture,f.transmissionSamplerSize.value.set(v.width,v.height),p.transmissionMap&&(f.transmissionMap.value=p.transmissionMap,t(p.transmissionMap,f.transmissionMapTransform)),f.thickness.value=p.thickness,p.thicknessMap&&(f.thicknessMap.value=p.thicknessMap,t(p.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=p.attenuationDistance,f.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(f.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(f.anisotropyMap.value=p.anisotropyMap,t(p.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=p.specularIntensity,f.specularColor.value.copy(p.specularColor),p.specularColorMap&&(f.specularColorMap.value=p.specularColorMap,t(p.specularColorMap,f.specularColorMapTransform)),p.specularIntensityMap&&(f.specularIntensityMap.value=p.specularIntensityMap,t(p.specularIntensityMap,f.specularIntensityMapTransform))}function g(f,p){p.matcap&&(f.matcap.value=p.matcap)}function y(f,p){let v=e.get(p).light;f.referencePosition.value.setFromMatrixPosition(v.matrixWorld),f.nearDistance.value=v.shadow.camera.near,f.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function WC(i,e,t,n){let r={},s={},o=[],a=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(v,b){let x=b.program;n.uniformBlockBinding(v,x)}function l(v,b){let x=r[v.id];x===void 0&&(g(v),x=u(v),r[v.id]=x,v.addEventListener("dispose",f));let _=b.program;n.updateUBOMapping(v,_);let T=e.render.frame;s[v.id]!==T&&(d(v),s[v.id]=T)}function u(v){let b=h();v.__bindingPointIndex=b;let x=i.createBuffer(),_=v.__size,T=v.usage;return i.bindBuffer(i.UNIFORM_BUFFER,x),i.bufferData(i.UNIFORM_BUFFER,_,T),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,b,x),x}function h(){for(let v=0;v<a;v++)if(o.indexOf(v)===-1)return o.push(v),v;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(v){let b=r[v.id],x=v.uniforms,_=v.__cache;i.bindBuffer(i.UNIFORM_BUFFER,b);for(let T=0,w=x.length;T<w;T++){let A=Array.isArray(x[T])?x[T]:[x[T]];for(let E=0,M=A.length;E<M;E++){let P=A[E];if(m(P,T,E,_)===!0){let N=P.__offset,L=Array.isArray(P.value)?P.value:[P.value],D=0;for(let $=0;$<L.length;$++){let U=L[$],I=y(U);typeof U=="number"||typeof U=="boolean"?(P.__data[0]=U,i.bufferSubData(i.UNIFORM_BUFFER,N+D,P.__data)):U.isMatrix3?(P.__data[0]=U.elements[0],P.__data[1]=U.elements[1],P.__data[2]=U.elements[2],P.__data[3]=0,P.__data[4]=U.elements[3],P.__data[5]=U.elements[4],P.__data[6]=U.elements[5],P.__data[7]=0,P.__data[8]=U.elements[6],P.__data[9]=U.elements[7],P.__data[10]=U.elements[8],P.__data[11]=0):(U.toArray(P.__data,D),D+=I.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,N,P.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function m(v,b,x,_){let T=v.value,w=b+"_"+x;if(_[w]===void 0)return typeof T=="number"||typeof T=="boolean"?_[w]=T:_[w]=T.clone(),!0;{let A=_[w];if(typeof T=="number"||typeof T=="boolean"){if(A!==T)return _[w]=T,!0}else if(A.equals(T)===!1)return A.copy(T),!0}return!1}function g(v){let b=v.uniforms,x=0,_=16;for(let w=0,A=b.length;w<A;w++){let E=Array.isArray(b[w])?b[w]:[b[w]];for(let M=0,P=E.length;M<P;M++){let N=E[M],L=Array.isArray(N.value)?N.value:[N.value];for(let D=0,$=L.length;D<$;D++){let U=L[D],I=y(U),V=x%_,W=V%I.boundary,Q=V+W;x+=W,Q!==0&&_-Q<I.storage&&(x+=_-Q),N.__data=new Float32Array(I.storage/Float32Array.BYTES_PER_ELEMENT),N.__offset=x,x+=I.storage}}}let T=x%_;return T>0&&(x+=_-T),v.__size=x,v.__cache={},this}function y(v){let b={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(b.boundary=4,b.storage=4):v.isVector2?(b.boundary=8,b.storage=8):v.isVector3||v.isColor?(b.boundary=16,b.storage=12):v.isVector4?(b.boundary=16,b.storage=16):v.isMatrix3?(b.boundary=48,b.storage=48):v.isMatrix4?(b.boundary=64,b.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),b}function f(v){let b=v.target;b.removeEventListener("dispose",f);let x=o.indexOf(b.__bindingPointIndex);o.splice(x,1),i.deleteBuffer(r[b.id]),delete r[b.id],delete s[b.id]}function p(){for(let v in r)i.deleteBuffer(r[v]);o=[],r={},s={}}return{bind:c,update:l,dispose:p}}var fs=class{constructor(e={}){let{canvas:t=I0(),context:n=null,depth:r=!0,stencil:s=!1,alpha:o=!1,antialias:a=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:h=!1,reverseDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=n.getContextAttributes().alpha}else m=o;let g=new Uint32Array(4),y=new Int32Array(4),f=null,p=null,v=[],b=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=wt,this.toneMapping=Ir,this.toneMappingExposure=1;let x=this,_=!1,T=0,w=0,A=null,E=-1,M=null,P=new It,N=new It,L=null,D=new Be(0),$=0,U=t.width,I=t.height,V=1,W=null,Q=null,se=new It(0,0,U,I),oe=new It(0,0,U,I),ge=!1,O=new Ws,S=!1,R=!1,z=new nt,Y=new nt,K=new q,re=new It,de={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},te=!1;function ne(){return A===null?V:1}let H=n;function _e(J,pe){return t.getContext(J,pe)}try{let J={alpha:!0,depth:r,stencil:s,antialias:a,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:u,failIfMajorPerformanceCaveat:h};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${"171"}`),t.addEventListener("webglcontextlost",ye,!1),t.addEventListener("webglcontextrestored",Ue,!1),t.addEventListener("webglcontextcreationerror",Oe,!1),H===null){let pe="webgl2";if(H=_e(pe,J),H===null)throw _e(pe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(J){throw console.error("THREE.WebGLRenderer: "+J.message),J}let me,be,he,Ne,Me,Z,B,k,F,G,j,ee,ie,ce,fe,ue,Ee,Se,De,ze,Je,Fe,Xe,ae;function Le(){me=new cR(H),me.init(),Fe=new Y_(H,me),be=new nR(H,me,e,Fe),he=new UC(H,me),be.reverseDepthBuffer&&d&&he.buffers.depth.setReversed(!0),Ne=new hR(H),Me=new SC,Z=new kC(H,me,he,Me,be,Fe,Ne),B=new rR(x),k=new aR(x),F=new xA(H),Xe=new eR(H,F),G=new lR(H,F,Ne,Xe),j=new fR(H,G,F,Ne),De=new dR(H,be,Z),ue=new iR(Me),ee=new MC(x,B,k,me,be,Xe,ue),ie=new GC(x,Me),ce=new AC,fe=new NC(me),Se=new $w(x,B,k,he,j,m,c),Ee=new DC(x,j,be),ae=new WC(H,Ne,be,he),ze=new tR(H,me,Ne),Je=new uR(H,me,Ne),Ne.programs=ee.programs,x.capabilities=be,x.extensions=me,x.properties=Me,x.renderLists=ce,x.shadowMap=Ee,x.state=he,x.info=Ne}Le();let xe=new J0(x,H);this.xr=xe,this.getContext=function(){return H},this.getContextAttributes=function(){return H.getContextAttributes()},this.forceContextLoss=function(){let J=me.get("WEBGL_lose_context");J&&J.loseContext()},this.forceContextRestore=function(){let J=me.get("WEBGL_lose_context");J&&J.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(J){J!==void 0&&(V=J,this.setSize(U,I,!1))},this.getSize=function(J){return J.set(U,I)},this.setSize=function(J,pe,we=!0){if(xe.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}U=J,I=pe,t.width=Math.floor(J*V),t.height=Math.floor(pe*V),we===!0&&(t.style.width=J+"px",t.style.height=pe+"px"),this.setViewport(0,0,J,pe)},this.getDrawingBufferSize=function(J){return J.set(U*V,I*V).floor()},this.setDrawingBufferSize=function(J,pe,we){U=J,I=pe,V=we,t.width=Math.floor(J*we),t.height=Math.floor(pe*we),this.setViewport(0,0,J,pe)},this.getCurrentViewport=function(J){return J.copy(P)},this.getViewport=function(J){return J.copy(se)},this.setViewport=function(J,pe,we,Re){J.isVector4?se.set(J.x,J.y,J.z,J.w):se.set(J,pe,we,Re),he.viewport(P.copy(se).multiplyScalar(V).round())},this.getScissor=function(J){return J.copy(oe)},this.setScissor=function(J,pe,we,Re){J.isVector4?oe.set(J.x,J.y,J.z,J.w):oe.set(J,pe,we,Re),he.scissor(N.copy(oe).multiplyScalar(V).round())},this.getScissorTest=function(){return ge},this.setScissorTest=function(J){he.setScissorTest(ge=J)},this.setOpaqueSort=function(J){W=J},this.setTransparentSort=function(J){Q=J},this.getClearColor=function(J){return J.copy(Se.getClearColor())},this.setClearColor=function(){Se.setClearColor.apply(Se,arguments)},this.getClearAlpha=function(){return Se.getClearAlpha()},this.setClearAlpha=function(){Se.setClearAlpha.apply(Se,arguments)},this.clear=function(J=!0,pe=!0,we=!0){let Re=0;if(J){let ve=!1;if(A!==null){let He=A.texture.format;ve=He===Yu||He===Xu||He===Sc}if(ve){let He=A.texture.type,Ke=He===ci||He===Lr||He===Zo||He===Or||He===Hu||He===Gu,it=Se.getClearColor(),qe=Se.getClearAlpha(),ft=it.r,Ye=it.g,ut=it.b;Ke?(g[0]=ft,g[1]=Ye,g[2]=ut,g[3]=qe,H.clearBufferuiv(H.COLOR,0,g)):(y[0]=ft,y[1]=Ye,y[2]=ut,y[3]=qe,H.clearBufferiv(H.COLOR,0,y))}else Re|=H.COLOR_BUFFER_BIT}pe&&(Re|=H.DEPTH_BUFFER_BIT),we&&(Re|=H.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H.clear(Re)},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.dispose=function(){t.removeEventListener("webglcontextlost",ye,!1),t.removeEventListener("webglcontextrestored",Ue,!1),t.removeEventListener("webglcontextcreationerror",Oe,!1),Se.dispose(),ce.dispose(),fe.dispose(),Me.dispose(),B.dispose(),k.dispose(),j.dispose(),Xe.dispose(),ae.dispose(),ee.dispose(),xe.dispose(),xe.removeEventListener("sessionstart",tt),xe.removeEventListener("sessionend",at),_t.stop()};function ye(J){J.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),_=!0}function Ue(){console.log("THREE.WebGLRenderer: Context Restored."),_=!1;let J=Ne.autoReset,pe=Ee.enabled,we=Ee.autoUpdate,Re=Ee.needsUpdate,ve=Ee.type;Le(),Ne.autoReset=J,Ee.enabled=pe,Ee.autoUpdate=we,Ee.needsUpdate=Re,Ee.type=ve}function Oe(J){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",J.statusMessage)}function st(J){let pe=J.target;pe.removeEventListener("dispose",st),pt(pe)}function pt(J){lt(J),Me.remove(J)}function lt(J){let pe=Me.get(J).programs;pe!==void 0&&(pe.forEach(function(we){ee.releaseProgram(we)}),J.isShaderMaterial&&ee.releaseShaderCache(J))}this.renderBufferDirect=function(J,pe,we,Re,ve,He){pe===null&&(pe=de);let Ke=ve.isMesh&&ve.matrixWorld.determinant()<0,it=to(J,pe,we,Re,ve);he.setMaterial(Re,Ke);let qe=we.index,ft=1;if(Re.wireframe===!0){if(qe=G.getWireframeAttribute(we),qe===void 0)return;ft=2}let Ye=we.drawRange,ut=we.attributes.position,Nt=Ye.start*ft,At=(Ye.start+Ye.count)*ft;He!==null&&(Nt=Math.max(Nt,He.start*ft),At=Math.min(At,(He.start+He.count)*ft)),qe!==null?(Nt=Math.max(Nt,0),At=Math.min(At,qe.count)):ut!=null&&(Nt=Math.max(Nt,0),At=Math.min(At,ut.count));let en=At-Nt;if(en<0||en===1/0)return;Xe.setup(ve,Re,it,we,qe);let xt,Ct=ze;if(qe!==null&&(xt=F.get(qe),Ct=Je,Ct.setIndex(xt)),ve.isMesh)Re.wireframe===!0?(he.setLineWidth(Re.wireframeLinewidth*ne()),Ct.setMode(H.LINES)):Ct.setMode(H.TRIANGLES);else if(ve.isLine){let ht=Re.linewidth;ht===void 0&&(ht=1),he.setLineWidth(ht*ne()),ve.isLineSegments?Ct.setMode(H.LINES):ve.isLineLoop?Ct.setMode(H.LINE_LOOP):Ct.setMode(H.LINE_STRIP)}else ve.isPoints?Ct.setMode(H.POINTS):ve.isSprite&&Ct.setMode(H.TRIANGLES);if(ve.isBatchedMesh)if(ve._multiDrawInstances!==null)Ct.renderMultiDrawInstances(ve._multiDrawStarts,ve._multiDrawCounts,ve._multiDrawCount,ve._multiDrawInstances);else if(me.get("WEBGL_multi_draw"))Ct.renderMultiDraw(ve._multiDrawStarts,ve._multiDrawCounts,ve._multiDrawCount);else{let ht=ve._multiDrawStarts,pn=ve._multiDrawCounts,Ot=ve._multiDrawCount,ti=qe?F.get(qe).bytesPerElement:1,Ai=Me.get(Re).currentProgram.getUniforms();for(let kn=0;kn<Ot;kn++)Ai.setValue(H,"_gl_DrawID",kn),Ct.render(ht[kn]/ti,pn[kn])}else if(ve.isInstancedMesh)Ct.renderInstances(Nt,en,ve.count);else if(we.isInstancedBufferGeometry){let ht=we._maxInstanceCount!==void 0?we._maxInstanceCount:1/0,pn=Math.min(we.instanceCount,ht);Ct.renderInstances(Nt,en,pn)}else Ct.render(Nt,en)};function We(J,pe,we){J.transparent===!0&&J.side===yn&&J.forceSinglePass===!1?(J.side=un,J.needsUpdate=!0,ui(J,pe,we),J.side=Jn,J.needsUpdate=!0,ui(J,pe,we),J.side=yn):ui(J,pe,we)}this.compile=function(J,pe,we=null){we===null&&(we=J),p=fe.get(we),p.init(pe),b.push(p),we.traverseVisible(function(ve){ve.isLight&&ve.layers.test(pe.layers)&&(p.pushLight(ve),ve.castShadow&&p.pushShadow(ve))}),J!==we&&J.traverseVisible(function(ve){ve.isLight&&ve.layers.test(pe.layers)&&(p.pushLight(ve),ve.castShadow&&p.pushShadow(ve))}),p.setupLights();let Re=new Set;return J.traverse(function(ve){if(!(ve.isMesh||ve.isPoints||ve.isLine||ve.isSprite))return;let He=ve.material;if(He)if(Array.isArray(He))for(let Ke=0;Ke<He.length;Ke++){let it=He[Ke];We(it,we,ve),Re.add(it)}else We(He,we,ve),Re.add(He)}),b.pop(),p=null,Re},this.compileAsync=function(J,pe,we=null){let Re=this.compile(J,pe,we);return new Promise(ve=>{function He(){if(Re.forEach(function(Ke){Me.get(Ke).currentProgram.isReady()&&Re.delete(Ke)}),Re.size===0){ve(J);return}setTimeout(He,10)}me.get("KHR_parallel_shader_compile")!==null?He():setTimeout(He,10)})};let Qe=null;function Ie(J){Qe&&Qe(J)}function tt(){_t.stop()}function at(){_t.start()}let _t=new V_;_t.setAnimationLoop(Ie),typeof self<"u"&&_t.setContext(self),this.setAnimationLoop=function(J){Qe=J,xe.setAnimationLoop(J),J===null?_t.stop():_t.start()},xe.addEventListener("sessionstart",tt),xe.addEventListener("sessionend",at),this.render=function(J,pe){if(pe!==void 0&&pe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(_===!0)return;if(J.matrixWorldAutoUpdate===!0&&J.updateMatrixWorld(),pe.parent===null&&pe.matrixWorldAutoUpdate===!0&&pe.updateMatrixWorld(),xe.enabled===!0&&xe.isPresenting===!0&&(xe.cameraAutoUpdate===!0&&xe.updateCamera(pe),pe=xe.getCamera()),J.isScene===!0&&J.onBeforeRender(x,J,pe,A),p=fe.get(J,b.length),p.init(pe),b.push(p),Y.multiplyMatrices(pe.projectionMatrix,pe.matrixWorldInverse),O.setFromProjectionMatrix(Y),R=this.localClippingEnabled,S=ue.init(this.clippingPlanes,R),f=ce.get(J,v.length),f.init(),v.push(f),xe.enabled===!0&&xe.isPresenting===!0){let He=x.xr.getDepthSensingMesh();He!==null&&Xn(He,pe,-1/0,x.sortObjects)}Xn(J,pe,0,x.sortObjects),f.finish(),x.sortObjects===!0&&f.sort(W,Q),te=xe.enabled===!1||xe.isPresenting===!1||xe.hasDepthSensing()===!1,te&&Se.addToRenderList(f,J),this.info.render.frame++,S===!0&&ue.beginShadows();let we=p.state.shadowsArray;Ee.render(we,J,pe),S===!0&&ue.endShadows(),this.info.autoReset===!0&&this.info.reset();let Re=f.opaque,ve=f.transmissive;if(p.setupLights(),pe.isArrayCamera){let He=pe.cameras;if(ve.length>0)for(let Ke=0,it=He.length;Ke<it;Ke++){let qe=He[Ke];mr(Re,ve,J,qe)}te&&Se.render(J);for(let Ke=0,it=He.length;Ke<it;Ke++){let qe=He[Ke];ei(f,J,qe,qe.viewport)}}else ve.length>0&&mr(Re,ve,J,pe),te&&Se.render(J),ei(f,J,pe);A!==null&&(Z.updateMultisampleRenderTarget(A),Z.updateRenderTargetMipmap(A)),J.isScene===!0&&J.onAfterRender(x,J,pe),Xe.resetDefaultState(),E=-1,M=null,b.pop(),b.length>0?(p=b[b.length-1],S===!0&&ue.setGlobalState(x.clippingPlanes,p.state.camera)):p=null,v.pop(),v.length>0?f=v[v.length-1]:f=null};function Xn(J,pe,we,Re){if(J.visible===!1)return;if(J.layers.test(pe.layers)){if(J.isGroup)we=J.renderOrder;else if(J.isLOD)J.autoUpdate===!0&&J.update(pe);else if(J.isLight)p.pushLight(J),J.castShadow&&p.pushShadow(J);else if(J.isSprite){if(!J.frustumCulled||O.intersectsSprite(J)){Re&&re.setFromMatrixPosition(J.matrixWorld).applyMatrix4(Y);let Ke=j.update(J),it=J.material;it.visible&&f.push(J,Ke,it,we,re.z,null)}}else if((J.isMesh||J.isLine||J.isPoints)&&(!J.frustumCulled||O.intersectsObject(J))){let Ke=j.update(J),it=J.material;if(Re&&(J.boundingSphere!==void 0?(J.boundingSphere===null&&J.computeBoundingSphere(),re.copy(J.boundingSphere.center)):(Ke.boundingSphere===null&&Ke.computeBoundingSphere(),re.copy(Ke.boundingSphere.center)),re.applyMatrix4(J.matrixWorld).applyMatrix4(Y)),Array.isArray(it)){let qe=Ke.groups;for(let ft=0,Ye=qe.length;ft<Ye;ft++){let ut=qe[ft],Nt=it[ut.materialIndex];Nt&&Nt.visible&&f.push(J,Ke,Nt,we,re.z,ut)}}else it.visible&&f.push(J,Ke,it,we,re.z,null)}}let He=J.children;for(let Ke=0,it=He.length;Ke<it;Ke++)Xn(He[Ke],pe,we,Re)}function ei(J,pe,we,Re){let ve=J.opaque,He=J.transmissive,Ke=J.transparent;p.setupLightsView(we),S===!0&&ue.setGlobalState(x.clippingPlanes,we),Re&&he.viewport(P.copy(Re)),ve.length>0&&Ti(ve,pe,we),He.length>0&&Ti(He,pe,we),Ke.length>0&&Ti(Ke,pe,we),he.buffers.depth.setTest(!0),he.buffers.depth.setMask(!0),he.buffers.color.setMask(!0),he.setPolygonOffset(!1)}function mr(J,pe,we,Re){if((we.isScene===!0?we.overrideMaterial:null)!==null)return;p.state.transmissionRenderTarget[Re.id]===void 0&&(p.state.transmissionRenderTarget[Re.id]=new on(1,1,{generateMipmaps:!0,type:me.has("EXT_color_buffer_half_float")||me.has("EXT_color_buffer_float")?Hn:ci,minFilter:Mi,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:bt.workingColorSpace}));let He=p.state.transmissionRenderTarget[Re.id],Ke=Re.viewport||P;He.setSize(Ke.z,Ke.w);let it=x.getRenderTarget();x.setRenderTarget(He),x.getClearColor(D),$=x.getClearAlpha(),$<1&&x.setClearColor(16777215,.5),x.clear(),te&&Se.render(we);let qe=x.toneMapping;x.toneMapping=Ir;let ft=Re.viewport;if(Re.viewport!==void 0&&(Re.viewport=void 0),p.setupLightsView(Re),S===!0&&ue.setGlobalState(x.clippingPlanes,Re),Ti(J,we,Re),Z.updateMultisampleRenderTarget(He),Z.updateRenderTargetMipmap(He),me.has("WEBGL_multisampled_render_to_texture")===!1){let Ye=!1;for(let ut=0,Nt=pe.length;ut<Nt;ut++){let At=pe[ut],en=At.object,xt=At.geometry,Ct=At.material,ht=At.group;if(Ct.side===yn&&en.layers.test(Re.layers)){let pn=Ct.side;Ct.side=un,Ct.needsUpdate=!0,Fn(en,we,Re,xt,Ct,ht),Ct.side=pn,Ct.needsUpdate=!0,Ye=!0}}Ye===!0&&(Z.updateMultisampleRenderTarget(He),Z.updateRenderTargetMipmap(He))}x.setRenderTarget(it),x.setClearColor(D,$),ft!==void 0&&(Re.viewport=ft),x.toneMapping=qe}function Ti(J,pe,we){let Re=pe.isScene===!0?pe.overrideMaterial:null;for(let ve=0,He=J.length;ve<He;ve++){let Ke=J[ve],it=Ke.object,qe=Ke.geometry,ft=Re===null?Ke.material:Re,Ye=Ke.group;it.layers.test(we.layers)&&Fn(it,pe,we,qe,ft,Ye)}}function Fn(J,pe,we,Re,ve,He){J.onBeforeRender(x,pe,we,Re,ve,He),J.modelViewMatrix.multiplyMatrices(we.matrixWorldInverse,J.matrixWorld),J.normalMatrix.getNormalMatrix(J.modelViewMatrix),ve.onBeforeRender(x,pe,we,Re,J,He),ve.transparent===!0&&ve.side===yn&&ve.forceSinglePass===!1?(ve.side=un,ve.needsUpdate=!0,x.renderBufferDirect(we,pe,Re,ve,J,He),ve.side=Jn,ve.needsUpdate=!0,x.renderBufferDirect(we,pe,Re,ve,J,He),ve.side=yn):x.renderBufferDirect(we,pe,Re,ve,J,He),J.onAfterRender(x,pe,we,Re,ve,He)}function ui(J,pe,we){pe.isScene!==!0&&(pe=de);let Re=Me.get(J),ve=p.state.lights,He=p.state.shadowsArray,Ke=ve.state.version,it=ee.getParameters(J,ve.state,He,pe,we),qe=ee.getProgramCacheKey(it),ft=Re.programs;Re.environment=J.isMeshStandardMaterial?pe.environment:null,Re.fog=pe.fog,Re.envMap=(J.isMeshStandardMaterial?k:B).get(J.envMap||Re.environment),Re.envMapRotation=Re.environment!==null&&J.envMap===null?pe.environmentRotation:J.envMapRotation,ft===void 0&&(J.addEventListener("dispose",st),ft=new Map,Re.programs=ft);let Ye=ft.get(qe);if(Ye!==void 0){if(Re.currentProgram===Ye&&Re.lightsStateVersion===Ke)return Un(J,it),Ye}else it.uniforms=ee.getUniforms(J),J.onBeforeCompile(it,x),Ye=ee.acquireProgram(it,qe),ft.set(qe,Ye),Re.uniforms=it.uniforms;let ut=Re.uniforms;return(!J.isShaderMaterial&&!J.isRawShaderMaterial||J.clipping===!0)&&(ut.clippingPlanes=ue.uniform),Un(J,it),Re.needsLights=td(J),Re.lightsStateVersion=Ke,Re.needsLights&&(ut.ambientLightColor.value=ve.state.ambient,ut.lightProbe.value=ve.state.probe,ut.directionalLights.value=ve.state.directional,ut.directionalLightShadows.value=ve.state.directionalShadow,ut.spotLights.value=ve.state.spot,ut.spotLightShadows.value=ve.state.spotShadow,ut.rectAreaLights.value=ve.state.rectArea,ut.ltc_1.value=ve.state.rectAreaLTC1,ut.ltc_2.value=ve.state.rectAreaLTC2,ut.pointLights.value=ve.state.point,ut.pointLightShadows.value=ve.state.pointShadow,ut.hemisphereLights.value=ve.state.hemi,ut.directionalShadowMap.value=ve.state.directionalShadowMap,ut.directionalShadowMatrix.value=ve.state.directionalShadowMatrix,ut.spotShadowMap.value=ve.state.spotShadowMap,ut.spotLightMatrix.value=ve.state.spotLightMatrix,ut.spotLightMap.value=ve.state.spotLightMap,ut.pointShadowMap.value=ve.state.pointShadowMap,ut.pointShadowMatrix.value=ve.state.pointShadowMatrix),Re.currentProgram=Ye,Re.uniformsList=null,Ye}function dn(J){if(J.uniformsList===null){let pe=J.currentProgram.getUniforms();J.uniformsList=Lc.seqWithValue(pe.seq,J.uniforms)}return J.uniformsList}function Un(J,pe){let we=Me.get(J);we.outputColorSpace=pe.outputColorSpace,we.batching=pe.batching,we.batchingColor=pe.batchingColor,we.instancing=pe.instancing,we.instancingColor=pe.instancingColor,we.instancingMorph=pe.instancingMorph,we.skinning=pe.skinning,we.morphTargets=pe.morphTargets,we.morphNormals=pe.morphNormals,we.morphColors=pe.morphColors,we.morphTargetsCount=pe.morphTargetsCount,we.numClippingPlanes=pe.numClippingPlanes,we.numIntersection=pe.numClipIntersection,we.vertexAlphas=pe.vertexAlphas,we.vertexTangents=pe.vertexTangents,we.toneMapping=pe.toneMapping}function to(J,pe,we,Re,ve){pe.isScene!==!0&&(pe=de),Z.resetTextureUnits();let He=pe.fog,Ke=Re.isMeshStandardMaterial?pe.environment:null,it=A===null?x.outputColorSpace:A.isXRRenderTarget===!0?A.texture.colorSpace:On,qe=(Re.isMeshStandardMaterial?k:B).get(Re.envMap||Ke),ft=Re.vertexColors===!0&&!!we.attributes.color&&we.attributes.color.itemSize===4,Ye=!!we.attributes.tangent&&(!!Re.normalMap||Re.anisotropy>0),ut=!!we.morphAttributes.position,Nt=!!we.morphAttributes.normal,At=!!we.morphAttributes.color,en=Ir;Re.toneMapped&&(A===null||A.isXRRenderTarget===!0)&&(en=x.toneMapping);let xt=we.morphAttributes.position||we.morphAttributes.normal||we.morphAttributes.color,Ct=xt!==void 0?xt.length:0,ht=Me.get(Re),pn=p.state.lights;if(S===!0&&(R===!0||J!==M)){let Pn=J===M&&Re.id===E;ue.setState(Re,J,Pn)}let Ot=!1;Re.version===ht.__version?(ht.needsLights&&ht.lightsStateVersion!==pn.state.version||ht.outputColorSpace!==it||ve.isBatchedMesh&&ht.batching===!1||!ve.isBatchedMesh&&ht.batching===!0||ve.isBatchedMesh&&ht.batchingColor===!0&&ve.colorTexture===null||ve.isBatchedMesh&&ht.batchingColor===!1&&ve.colorTexture!==null||ve.isInstancedMesh&&ht.instancing===!1||!ve.isInstancedMesh&&ht.instancing===!0||ve.isSkinnedMesh&&ht.skinning===!1||!ve.isSkinnedMesh&&ht.skinning===!0||ve.isInstancedMesh&&ht.instancingColor===!0&&ve.instanceColor===null||ve.isInstancedMesh&&ht.instancingColor===!1&&ve.instanceColor!==null||ve.isInstancedMesh&&ht.instancingMorph===!0&&ve.morphTexture===null||ve.isInstancedMesh&&ht.instancingMorph===!1&&ve.morphTexture!==null||ht.envMap!==qe||Re.fog===!0&&ht.fog!==He||ht.numClippingPlanes!==void 0&&(ht.numClippingPlanes!==ue.numPlanes||ht.numIntersection!==ue.numIntersection)||ht.vertexAlphas!==ft||ht.vertexTangents!==Ye||ht.morphTargets!==ut||ht.morphNormals!==Nt||ht.morphColors!==At||ht.toneMapping!==en||ht.morphTargetsCount!==Ct)&&(Ot=!0):(Ot=!0,ht.__version=Re.version);let ti=ht.currentProgram;Ot===!0&&(ti=ui(Re,pe,ve));let Ai=!1,kn=!1,Vi=!1,Bt=ti.getUniforms(),Yn=ht.uniforms;if(he.useProgram(ti.program)&&(Ai=!0,kn=!0,Vi=!0),Re.id!==E&&(E=Re.id,kn=!0),Ai||M!==J){he.buffers.depth.getReversed()?(z.copy(J.projectionMatrix),s_(z),o_(z),Bt.setValue(H,"projectionMatrix",z)):Bt.setValue(H,"projectionMatrix",J.projectionMatrix),Bt.setValue(H,"viewMatrix",J.matrixWorldInverse);let Bn=Bt.map.cameraPosition;Bn!==void 0&&Bn.setValue(H,K.setFromMatrixPosition(J.matrixWorld)),be.logarithmicDepthBuffer&&Bt.setValue(H,"logDepthBufFC",2/(Math.log(J.far+1)/Math.LN2)),(Re.isMeshPhongMaterial||Re.isMeshToonMaterial||Re.isMeshLambertMaterial||Re.isMeshBasicMaterial||Re.isMeshStandardMaterial||Re.isShaderMaterial)&&Bt.setValue(H,"isOrthographic",J.isOrthographicCamera===!0),M!==J&&(M=J,kn=!0,Vi=!0)}if(ve.isSkinnedMesh){Bt.setOptional(H,ve,"bindMatrix"),Bt.setOptional(H,ve,"bindMatrixInverse");let Pn=ve.skeleton;Pn&&(Pn.boneTexture===null&&Pn.computeBoneTexture(),Bt.setValue(H,"boneTexture",Pn.boneTexture,Z))}ve.isBatchedMesh&&(Bt.setOptional(H,ve,"batchingTexture"),Bt.setValue(H,"batchingTexture",ve._matricesTexture,Z),Bt.setOptional(H,ve,"batchingIdTexture"),Bt.setValue(H,"batchingIdTexture",ve._indirectTexture,Z),Bt.setOptional(H,ve,"batchingColorTexture"),ve._colorsTexture!==null&&Bt.setValue(H,"batchingColorTexture",ve._colorsTexture,Z));let ni=we.morphAttributes;if((ni.position!==void 0||ni.normal!==void 0||ni.color!==void 0)&&De.update(ve,we,ti),(kn||ht.receiveShadow!==ve.receiveShadow)&&(ht.receiveShadow=ve.receiveShadow,Bt.setValue(H,"receiveShadow",ve.receiveShadow)),Re.isMeshGouraudMaterial&&Re.envMap!==null&&(Yn.envMap.value=qe,Yn.flipEnvMap.value=qe.isCubeTexture&&qe.isRenderTargetTexture===!1?-1:1),Re.isMeshStandardMaterial&&Re.envMap===null&&pe.environment!==null&&(Yn.envMapIntensity.value=pe.environmentIntensity),kn&&(Bt.setValue(H,"toneMappingExposure",x.toneMappingExposure),ht.needsLights&&kr(Yn,Vi),He&&Re.fog===!0&&ie.refreshFogUniforms(Yn,He),ie.refreshMaterialUniforms(Yn,Re,V,I,p.state.transmissionRenderTarget[J.id]),Lc.upload(H,dn(ht),Yn,Z)),Re.isShaderMaterial&&Re.uniformsNeedUpdate===!0&&(Lc.upload(H,dn(ht),Yn,Z),Re.uniformsNeedUpdate=!1),Re.isSpriteMaterial&&Bt.setValue(H,"center",ve.center),Bt.setValue(H,"modelViewMatrix",ve.modelViewMatrix),Bt.setValue(H,"normalMatrix",ve.normalMatrix),Bt.setValue(H,"modelMatrix",ve.matrixWorld),Re.isShaderMaterial||Re.isRawShaderMaterial){let Pn=Re.uniformsGroups;for(let Bn=0,ms=Pn.length;Bn<ms;Bn++){let Br=Pn[Bn];ae.update(Br,ti),ae.bind(Br,ti)}}return ti}function kr(J,pe){J.ambientLightColor.needsUpdate=pe,J.lightProbe.needsUpdate=pe,J.directionalLights.needsUpdate=pe,J.directionalLightShadows.needsUpdate=pe,J.pointLights.needsUpdate=pe,J.pointLightShadows.needsUpdate=pe,J.spotLights.needsUpdate=pe,J.spotLightShadows.needsUpdate=pe,J.rectAreaLights.needsUpdate=pe,J.hemisphereLights.needsUpdate=pe}function td(J){return J.isMeshLambertMaterial||J.isMeshToonMaterial||J.isMeshPhongMaterial||J.isMeshStandardMaterial||J.isShadowMaterial||J.isShaderMaterial&&J.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return w},this.getRenderTarget=function(){return A},this.setRenderTargetTextures=function(J,pe,we){Me.get(J.texture).__webglTexture=pe,Me.get(J.depthTexture).__webglTexture=we;let Re=Me.get(J);Re.__hasExternalTextures=!0,Re.__autoAllocateDepthBuffer=we===void 0,Re.__autoAllocateDepthBuffer||me.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),Re.__useRenderToTexture=!1)},this.setRenderTargetFramebuffer=function(J,pe){let we=Me.get(J);we.__webglFramebuffer=pe,we.__useDefaultFramebuffer=pe===void 0},this.setRenderTarget=function(J,pe=0,we=0){A=J,T=pe,w=we;let Re=!0,ve=null,He=!1,Ke=!1;if(J){let qe=Me.get(J);if(qe.__useDefaultFramebuffer!==void 0)he.bindFramebuffer(H.FRAMEBUFFER,null),Re=!1;else if(qe.__webglFramebuffer===void 0)Z.setupRenderTarget(J);else if(qe.__hasExternalTextures)Z.rebindTextures(J,Me.get(J.texture).__webglTexture,Me.get(J.depthTexture).__webglTexture);else if(J.depthBuffer){let ut=J.depthTexture;if(qe.__boundDepthTexture!==ut){if(ut!==null&&Me.has(ut)&&(J.width!==ut.image.width||J.height!==ut.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Z.setupDepthRenderbuffer(J)}}let ft=J.texture;(ft.isData3DTexture||ft.isDataArrayTexture||ft.isCompressedArrayTexture)&&(Ke=!0);let Ye=Me.get(J).__webglFramebuffer;J.isWebGLCubeRenderTarget?(Array.isArray(Ye[pe])?ve=Ye[pe][we]:ve=Ye[pe],He=!0):J.samples>0&&Z.useMultisampledRTT(J)===!1?ve=Me.get(J).__webglMultisampledFramebuffer:Array.isArray(Ye)?ve=Ye[we]:ve=Ye,P.copy(J.viewport),N.copy(J.scissor),L=J.scissorTest}else P.copy(se).multiplyScalar(V).floor(),N.copy(oe).multiplyScalar(V).floor(),L=ge;if(he.bindFramebuffer(H.FRAMEBUFFER,ve)&&Re&&he.drawBuffers(J,ve),he.viewport(P),he.scissor(N),he.setScissorTest(L),He){let qe=Me.get(J.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+pe,qe.__webglTexture,we)}else if(Ke){let qe=Me.get(J.texture),ft=pe||0;H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,qe.__webglTexture,we||0,ft)}E=-1},this.readRenderTargetPixels=function(J,pe,we,Re,ve,He,Ke){if(!(J&&J.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let it=Me.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&Ke!==void 0&&(it=it[Ke]),it){he.bindFramebuffer(H.FRAMEBUFFER,it);try{let qe=J.texture,ft=qe.format,Ye=qe.type;if(!be.textureFormatReadable(ft)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!be.textureTypeReadable(Ye)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}pe>=0&&pe<=J.width-Re&&we>=0&&we<=J.height-ve&&H.readPixels(pe,we,Re,ve,Fe.convert(ft),Fe.convert(Ye),He)}finally{let qe=A!==null?Me.get(A).__webglFramebuffer:null;he.bindFramebuffer(H.FRAMEBUFFER,qe)}}},this.readRenderTargetPixelsAsync=async function(J,pe,we,Re,ve,He,Ke){if(!(J&&J.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let it=Me.get(J).__webglFramebuffer;if(J.isWebGLCubeRenderTarget&&Ke!==void 0&&(it=it[Ke]),it){let qe=J.texture,ft=qe.format,Ye=qe.type;if(!be.textureFormatReadable(ft))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!be.textureTypeReadable(Ye))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(pe>=0&&pe<=J.width-Re&&we>=0&&we<=J.height-ve){he.bindFramebuffer(H.FRAMEBUFFER,it);let ut=H.createBuffer();H.bindBuffer(H.PIXEL_PACK_BUFFER,ut),H.bufferData(H.PIXEL_PACK_BUFFER,He.byteLength,H.STREAM_READ),H.readPixels(pe,we,Re,ve,Fe.convert(ft),Fe.convert(Ye),0);let Nt=A!==null?Me.get(A).__webglFramebuffer:null;he.bindFramebuffer(H.FRAMEBUFFER,Nt);let At=H.fenceSync(H.SYNC_GPU_COMMANDS_COMPLETE,0);return H.flush(),await r_(H,At,4),H.bindBuffer(H.PIXEL_PACK_BUFFER,ut),H.getBufferSubData(H.PIXEL_PACK_BUFFER,0,He),H.deleteBuffer(ut),H.deleteSync(At),He}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}},this.copyFramebufferToTexture=function(J,pe=null,we=0){J.isTexture!==!0&&(Qo("WebGLRenderer: copyFramebufferToTexture function signature has changed."),pe=arguments[0]||null,J=arguments[1]);let Re=Math.pow(2,-we),ve=Math.floor(J.image.width*Re),He=Math.floor(J.image.height*Re),Ke=pe!==null?pe.x:0,it=pe!==null?pe.y:0;Z.setTexture2D(J,0),H.copyTexSubImage2D(H.TEXTURE_2D,we,0,0,Ke,it,ve,He),he.unbindTexture()};let Pm=H.createFramebuffer(),Im=H.createFramebuffer();this.copyTextureToTexture=function(J,pe,we=null,Re=null,ve=0,He=null){J.isTexture!==!0&&(Qo("WebGLRenderer: copyTextureToTexture function signature has changed."),Re=arguments[0]||null,J=arguments[1],pe=arguments[2],He=arguments[3]||0,we=null),He===null&&(ve!==0?(Qo("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),He=ve,ve=0):He=0);let Ke,it,qe,ft,Ye,ut,Nt,At,en,xt=J.isCompressedTexture?J.mipmaps[He]:J.image;if(we!==null)Ke=we.max.x-we.min.x,it=we.max.y-we.min.y,qe=we.isBox3?we.max.z-we.min.z:1,ft=we.min.x,Ye=we.min.y,ut=we.isBox3?we.min.z:0;else{let ni=Math.pow(2,-ve);Ke=Math.floor(xt.width*ni),it=Math.floor(xt.height*ni),J.isDataArrayTexture?qe=xt.depth:J.isData3DTexture?qe=Math.floor(xt.depth*ni):qe=1,ft=0,Ye=0,ut=0}Re!==null?(Nt=Re.x,At=Re.y,en=Re.z):(Nt=0,At=0,en=0);let Ct=Fe.convert(pe.format),ht=Fe.convert(pe.type),pn;pe.isData3DTexture?(Z.setTexture3D(pe,0),pn=H.TEXTURE_3D):pe.isDataArrayTexture||pe.isCompressedArrayTexture?(Z.setTexture2DArray(pe,0),pn=H.TEXTURE_2D_ARRAY):(Z.setTexture2D(pe,0),pn=H.TEXTURE_2D),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,pe.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,pe.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,pe.unpackAlignment);let Ot=H.getParameter(H.UNPACK_ROW_LENGTH),ti=H.getParameter(H.UNPACK_IMAGE_HEIGHT),Ai=H.getParameter(H.UNPACK_SKIP_PIXELS),kn=H.getParameter(H.UNPACK_SKIP_ROWS),Vi=H.getParameter(H.UNPACK_SKIP_IMAGES);H.pixelStorei(H.UNPACK_ROW_LENGTH,xt.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,xt.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,ft),H.pixelStorei(H.UNPACK_SKIP_ROWS,Ye),H.pixelStorei(H.UNPACK_SKIP_IMAGES,ut);let Bt=J.isDataArrayTexture||J.isData3DTexture,Yn=pe.isDataArrayTexture||pe.isData3DTexture;if(J.isDepthTexture){let ni=Me.get(J),Pn=Me.get(pe),Bn=Me.get(ni.__renderTarget),ms=Me.get(Pn.__renderTarget);he.bindFramebuffer(H.READ_FRAMEBUFFER,Bn.__webglFramebuffer),he.bindFramebuffer(H.DRAW_FRAMEBUFFER,ms.__webglFramebuffer);for(let Br=0;Br<qe;Br++)Bt&&(H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Me.get(J).__webglTexture,ve,ut+Br),H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Me.get(pe).__webglTexture,He,en+Br)),H.blitFramebuffer(ft,Ye,Ke,it,Nt,At,Ke,it,H.DEPTH_BUFFER_BIT,H.NEAREST);he.bindFramebuffer(H.READ_FRAMEBUFFER,null),he.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else if(ve!==0||J.isRenderTargetTexture||Me.has(J)){let ni=Me.get(J),Pn=Me.get(pe);he.bindFramebuffer(H.READ_FRAMEBUFFER,Pm),he.bindFramebuffer(H.DRAW_FRAMEBUFFER,Im);for(let Bn=0;Bn<qe;Bn++)Bt?H.framebufferTextureLayer(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,ni.__webglTexture,ve,ut+Bn):H.framebufferTexture2D(H.READ_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,ni.__webglTexture,ve),Yn?H.framebufferTextureLayer(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,Pn.__webglTexture,He,en+Bn):H.framebufferTexture2D(H.DRAW_FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_2D,Pn.__webglTexture,He),ve!==0?H.blitFramebuffer(ft,Ye,Ke,it,Nt,At,Ke,it,H.COLOR_BUFFER_BIT,H.NEAREST):Yn?H.copyTexSubImage3D(pn,He,Nt,At,en+Bn,ft,Ye,Ke,it):H.copyTexSubImage2D(pn,He,Nt,At,ft,Ye,Ke,it);he.bindFramebuffer(H.READ_FRAMEBUFFER,null),he.bindFramebuffer(H.DRAW_FRAMEBUFFER,null)}else Yn?J.isDataTexture||J.isData3DTexture?H.texSubImage3D(pn,He,Nt,At,en,Ke,it,qe,Ct,ht,xt.data):pe.isCompressedArrayTexture?H.compressedTexSubImage3D(pn,He,Nt,At,en,Ke,it,qe,Ct,xt.data):H.texSubImage3D(pn,He,Nt,At,en,Ke,it,qe,Ct,ht,xt):J.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,He,Nt,At,Ke,it,Ct,ht,xt.data):J.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,He,Nt,At,xt.width,xt.height,Ct,xt.data):H.texSubImage2D(H.TEXTURE_2D,He,Nt,At,Ke,it,Ct,ht,xt);H.pixelStorei(H.UNPACK_ROW_LENGTH,Ot),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,ti),H.pixelStorei(H.UNPACK_SKIP_PIXELS,Ai),H.pixelStorei(H.UNPACK_SKIP_ROWS,kn),H.pixelStorei(H.UNPACK_SKIP_IMAGES,Vi),He===0&&pe.generateMipmaps&&H.generateMipmap(pn),he.unbindTexture()},this.copyTextureToTexture3D=function(J,pe,we=null,Re=null,ve=0){return J.isTexture!==!0&&(Qo("WebGLRenderer: copyTextureToTexture3D function signature has changed."),we=arguments[0]||null,Re=arguments[1]||null,J=arguments[2],pe=arguments[3],ve=arguments[4]||0),Qo('WebGLRenderer: copyTextureToTexture3D function has been deprecated. Use "copyTextureToTexture" instead.'),this.copyTextureToTexture(J,pe,we,Re,ve)},this.initRenderTarget=function(J){Me.get(J).__webglFramebuffer===void 0&&Z.setupRenderTarget(J)},this.initTexture=function(J){J.isCubeTexture?Z.setTextureCube(J,0):J.isData3DTexture?Z.setTexture3D(J,0):J.isDataArrayTexture||J.isCompressedArrayTexture?Z.setTexture2DArray(J,0):Z.setTexture2D(J,0),he.unbindTexture()},this.resetState=function(){T=0,w=0,A=null,he.reset(),Xe.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return tr}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorspace=bt._getDrawingBufferColorSpace(e),t.unpackColorSpace=bt._getUnpackColorSpace()}};var q_={triangulate:function(i,e,t=2){let n=e&&e.length,r=n?e[0]*t:i.length,s=K_(i,0,r,t,!0),o=[];if(!s||s.next===s.prev)return o;let a,c,l,u,h,d,m;if(n&&(s=KC(i,e,s,t)),i.length>80*t){a=l=i[0],c=u=i[1];for(let g=t;g<r;g+=t)h=i[g],d=i[g+1],h<a&&(a=h),d<c&&(c=d),h>l&&(l=h),d>u&&(u=d);m=Math.max(l-a,u-c),m=m!==0?32767/m:0}return Eh(s,o,t,a,c,m,0),o}};function K_(i,e,t,n,r){let s,o;if(r===oP(i,e,t,n)>0)for(s=e;s<t;s+=n)o=j_(s,i[s],i[s+1],o);else for(s=t-n;s>=e;s-=n)o=j_(s,i[s],i[s+1],o);return o&&Lp(o,o.next)&&(Sh(o),o=o.next),o}function sa(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(Lp(t,t.next)||hn(t.prev,t,t.next)===0)){if(Sh(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Eh(i,e,t,n,r,s,o){if(!i)return;!o&&s&&eP(i,n,r,s);let a=i,c,l;for(;i.prev!==i.next;){if(c=i.prev,l=i.next,s?YC(i,n,r,s):XC(i)){e.push(c.i/t|0),e.push(i.i/t|0),e.push(l.i/t|0),Sh(i),i=l.next,a=l.next;continue}if(i=l,i===a){o?o===1?(i=jC(sa(i),e,t),Eh(i,e,t,n,r,s,2)):o===2&&qC(i,e,t,n,r,s):Eh(sa(i),e,t,n,r,s,1);break}}}function XC(i){let e=i.prev,t=i,n=i.next;if(hn(e,t,n)>=0)return!1;let r=e.x,s=t.x,o=n.x,a=e.y,c=t.y,l=n.y,u=r<s?r<o?r:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,d=r>s?r>o?r:o:s>o?s:o,m=a>c?a>l?a:l:c>l?c:l,g=n.next;for(;g!==e;){if(g.x>=u&&g.x<=d&&g.y>=h&&g.y<=m&&Dc(r,a,s,c,o,l,g.x,g.y)&&hn(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function YC(i,e,t,n){let r=i.prev,s=i,o=i.next;if(hn(r,s,o)>=0)return!1;let a=r.x,c=s.x,l=o.x,u=r.y,h=s.y,d=o.y,m=a<c?a<l?a:l:c<l?c:l,g=u<h?u<d?u:d:h<d?h:d,y=a>c?a>l?a:l:c>l?c:l,f=u>h?u>d?u:d:h>d?h:d,p=$0(m,g,e,t,n),v=$0(y,f,e,t,n),b=i.prevZ,x=i.nextZ;for(;b&&b.z>=p&&x&&x.z<=v;){if(b.x>=m&&b.x<=y&&b.y>=g&&b.y<=f&&b!==r&&b!==o&&Dc(a,u,c,h,l,d,b.x,b.y)&&hn(b.prev,b,b.next)>=0||(b=b.prevZ,x.x>=m&&x.x<=y&&x.y>=g&&x.y<=f&&x!==r&&x!==o&&Dc(a,u,c,h,l,d,x.x,x.y)&&hn(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;b&&b.z>=p;){if(b.x>=m&&b.x<=y&&b.y>=g&&b.y<=f&&b!==r&&b!==o&&Dc(a,u,c,h,l,d,b.x,b.y)&&hn(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;x&&x.z<=v;){if(x.x>=m&&x.x<=y&&x.y>=g&&x.y<=f&&x!==r&&x!==o&&Dc(a,u,c,h,l,d,x.x,x.y)&&hn(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function jC(i,e,t){let n=i;do{let r=n.prev,s=n.next.next;!Lp(r,s)&&Z_(r,n,n.next,s)&&Mh(r,s)&&Mh(s,r)&&(e.push(r.i/t|0),e.push(n.i/t|0),e.push(s.i/t|0),Sh(n),Sh(n.next),n=i=s),n=n.next}while(n!==i);return sa(n)}function qC(i,e,t,n,r,s){let o=i;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&iP(o,a)){let c=J_(o,a);o=sa(o,o.next),c=sa(c,c.next),Eh(o,e,t,n,r,s,0),Eh(c,e,t,n,r,s,0);return}a=a.next}o=o.next}while(o!==i)}function KC(i,e,t,n){let r=[],s,o,a,c,l;for(s=0,o=e.length;s<o;s++)a=e[s]*n,c=s<o-1?e[s+1]*n:i.length,l=K_(i,a,c,n,!1),l===l.next&&(l.steiner=!0),r.push(nP(l));for(r.sort(ZC),s=0;s<r.length;s++)t=JC(r[s],t);return t}function ZC(i,e){return i.x-e.x}function JC(i,e){let t=QC(i,e);if(!t)return e;let n=J_(t,i);return sa(n,n.next),sa(t,t.next)}function QC(i,e){let t=e,n=-1/0,r,s=i.x,o=i.y;do{if(o<=t.y&&o>=t.next.y&&t.next.y!==t.y){let d=t.x+(o-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=s&&d>n&&(n=d,r=t.x<t.next.x?t:t.next,d===s))return r}t=t.next}while(t!==e);if(!r)return null;let a=r,c=r.x,l=r.y,u=1/0,h;t=r;do s>=t.x&&t.x>=c&&s!==t.x&&Dc(o<l?s:n,o,c,l,o<l?n:s,o,t.x,t.y)&&(h=Math.abs(o-t.y)/(s-t.x),Mh(t,i)&&(h<u||h===u&&(t.x>r.x||t.x===r.x&&$C(r,t)))&&(r=t,u=h)),t=t.next;while(t!==a);return r}function $C(i,e){return hn(i.prev,i,e.prev)<0&&hn(e.next,i,i.next)<0}function eP(i,e,t,n){let r=i;do r.z===0&&(r.z=$0(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,tP(r)}function tP(i){let e,t,n,r,s,o,a,c,l=1;do{for(t=i,i=null,s=null,o=0;t;){for(o++,n=t,a=0,e=0;e<l&&(a++,n=n.nextZ,!!n);e++);for(c=l;a>0||c>0&&n;)a!==0&&(c===0||!n||t.z<=n.z)?(r=t,t=t.nextZ,a--):(r=n,n=n.nextZ,c--),s?s.nextZ=r:i=r,r.prevZ=s,s=r;t=n}s.nextZ=null,l*=2}while(o>1);return i}function $0(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function nP(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Dc(i,e,t,n,r,s,o,a){return(r-o)*(e-a)>=(i-o)*(s-a)&&(i-o)*(n-a)>=(t-o)*(e-a)&&(t-o)*(s-a)>=(r-o)*(n-a)}function iP(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!rP(i,e)&&(Mh(i,e)&&Mh(e,i)&&sP(i,e)&&(hn(i.prev,i,e.prev)||hn(i,e.prev,e))||Lp(i,e)&&hn(i.prev,i,i.next)>0&&hn(e.prev,e,e.next)>0)}function hn(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function Lp(i,e){return i.x===e.x&&i.y===e.y}function Z_(i,e,t,n){let r=Np(hn(i,e,t)),s=Np(hn(i,e,n)),o=Np(hn(t,n,i)),a=Np(hn(t,n,e));return!!(r!==s&&o!==a||r===0&&Ip(i,t,e)||s===0&&Ip(i,n,e)||o===0&&Ip(t,i,n)||a===0&&Ip(t,e,n))}function Ip(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function Np(i){return i>0?1:i<0?-1:0}function rP(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Z_(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function Mh(i,e){return hn(i.prev,i,i.next)<0?hn(i,e,i.next)>=0&&hn(i,i.prev,e)>=0:hn(i,e,i.prev)<0||hn(i,i.next,e)<0}function sP(i,e){let t=i,n=!1,r=(i.x+e.x)/2,s=(i.y+e.y)/2;do t.y>s!=t.next.y>s&&t.next.y!==t.y&&r<(t.next.x-t.x)*(s-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function J_(i,e){let t=new ey(i.i,i.x,i.y),n=new ey(e.i,e.x,e.y),r=i.next,s=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,s.next=n,n.prev=s,n}function j_(i,e,t,n){let r=new ey(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Sh(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function ey(i,e,t){this.i=i,this.x=e,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function oP(i,e,t,n){let r=0;for(let s=e,o=t-n;s<t;s+=n)r+=(i[o]-i[s])*(i[s+1]+i[o+1]),o=s;return r}var ty=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i;function aP(i){let e=i.size;if(!Number.isSafeInteger(e)||e<3)throw Error("Invalid saved zone point count.");let t=i.filled?e*15+Math.max(0,e-2)*3*(e>65535?4:2):e*12;if(!Number.isSafeInteger(t))throw Error("Invalid saved zone geometry size.");return t}function Q_(i,e,{world:t,triangulate:n,maxBytes:r=64*1024*1024}={}){if(typeof t!="function"||typeof n!="function"||!Number.isSafeInteger(r)||r<0)throw TypeError("Invalid saved zone geometry options.");if(aP(e)>r)throw Object.assign(Error("Saved zone exceeds the remaining typed-geometry byte budget."),{code:"ZONE_GEOMETRY_BUDGET"});let s=new Float64Array(e.size*2),o=0,a=(g,y)=>{let f=t([g,y]);if(!f.every(Number.isFinite)||o>=e.size)throw Error("Invalid saved zone coordinate.");s[o*2]=f[0],s[o*2+1]=f[1],o++},c=e.sourcePoints[1];if(c instanceof Float64Array)for(let g=0;g<c.length;g+=2)a(c[g],c[g+1]);else for(let g of e.sourcePoints)!Array.isArray(g)||ty(g[0])!=="xy"||a(Number(ty(g[1])),Number(ty(g[2])));if(o!==e.size)throw Error("Saved zone point count changed.");o>3&&s[0]===s[(o-1)*2]&&s[1]===s[(o-1)*2+1]&&o--;let l=new Float32Array(o*3),u=e.filled?new Int8Array(o*3):null;for(let g=0;g<o;g++)l[g*3]=s[g*2],l[g*3+1]=s[g*2+1],u&&(u[g*3+2]=127);let h=null;if(e.filled){let g=n(s.subarray(0,o*2),void 0,2);if(!g.length||g.length%3||g.length>(o-2)*3)throw Error("Saved zone could not be triangulated faithfully.");let y=o>65535?Uint32Array:Uint16Array;h=new y(g.length);for(let f=0;f<g.length;f++){let p=g[f];if(!Number.isInteger(p)||p<0||p>=o)throw Error("Invalid saved zone triangulation index.");h[f]=p}}let d=l.byteLength+(u?.byteLength||0)+(h?.byteLength||0);if(d>r)throw Object.assign(Error("Saved zone exceeds its typed-geometry byte budget."),{code:"ZONE_GEOMETRY_BUDGET"});let m=new i.BufferGeometry;return m.setAttribute("position",new i.BufferAttribute(l,3)),u&&m.setAttribute("normal",new i.BufferAttribute(u,3,!0)),h&&m.setIndex(new i.BufferAttribute(h,1)),{geometry:m,bytes:d,vertices:o}}var $_={type:"change"},iy={type:"start"},tE={type:"end"},Op=new nr,eE=new Li,cP=Math.cos(70*Js.DEG2RAD),Cn=new q,Si=2*Math.PI,Kt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},ny=1e-6,Qs=class extends yc{constructor(e,t=null){super(e,t),this.state=Kt.NONE,this.enabled=!0,this.target=new q,this.cursor=new q,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:cs.ROTATE,MIDDLE:cs.DOLLY,RIGHT:cs.PAN},this.touches={ONE:ls.ROTATE,TWO:ls.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new q,this._lastQuaternion=new Zt,this._lastTargetPosition=new q,this._quat=new Zt().setFromUnitVectors(e.up,new q(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new jo,this._sphericalDelta=new jo,this._scale=1,this._panOffset=new q,this._rotateStart=new Ce,this._rotateEnd=new Ce,this._rotateDelta=new Ce,this._panStart=new Ce,this._panEnd=new Ce,this._panDelta=new Ce,this._dollyStart=new Ce,this._dollyEnd=new Ce,this._dollyDelta=new Ce,this._dollyDirection=new q,this._mouse=new Ce,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=uP.bind(this),this._onPointerDown=lP.bind(this),this._onPointerUp=hP.bind(this),this._onContextMenu=xP.bind(this),this._onMouseWheel=pP.bind(this),this._onKeyDown=mP.bind(this),this._onTouchStart=gP.bind(this),this._onTouchMove=yP.bind(this),this._onMouseDown=dP.bind(this),this._onMouseMove=fP.bind(this),this._interceptControlDown=vP.bind(this),this._interceptControlUp=bP.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent($_),this.update(),this.state=Kt.NONE}update(e=null){let t=this.object.position;Cn.copy(t).sub(this.target),Cn.applyQuaternion(this._quat),this._spherical.setFromVector3(Cn),this.autoRotate&&this.state===Kt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=Si:n>Math.PI&&(n-=Si),r<-Math.PI?r+=Si:r>Math.PI&&(r-=Si),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(Cn.setFromSpherical(this._spherical),Cn.applyQuaternion(this._quatInverse),t.copy(this.target).add(Cn),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){let a=Cn.length();o=this._clampDistance(a*this._scale);let c=a-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),s=!!c}else if(this.object.isOrthographicCamera){let a=new q(this._mouse.x,this._mouse.y,0);a.unproject(this.object);let c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=c!==this.object.zoom;let l=new q(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(a),this.object.updateMatrixWorld(),o=Cn.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Op.origin.copy(this.object.position),Op.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Op.direction))<cP?this.object.lookAt(this.target):(eE.setFromNormalAndCoplanarPoint(this.object.up,this.target),Op.intersectPlane(eE,this.target))))}else if(this.object.isOrthographicCamera){let o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>ny||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ny||this._lastTargetPosition.distanceToSquared(this.target)>ny?(this.dispatchEvent($_),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Si/60*this.autoRotateSpeed*e:Si/60/60*this.autoRotateSpeed}_getZoomScale(e){let t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Cn.setFromMatrixColumn(t,0),Cn.multiplyScalar(-e),this._panOffset.add(Cn)}_panUp(e,t){this.screenSpacePanning===!0?Cn.setFromMatrixColumn(t,1):(Cn.setFromMatrixColumn(t,0),Cn.crossVectors(this.object.up,Cn)),Cn.multiplyScalar(e),this._panOffset.add(Cn)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;Cn.copy(r).sub(this.target);let s=Cn.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),r=e-n.left,s=t-n.top,o=n.width,a=n.height;this._mouse.x=r/o*2-1,this._mouse.y=-(s/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Si*this._rotateDelta.x/t.clientHeight),this._rotateUp(Si*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Si*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Si*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Si*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Si*this.rotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(r,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Si*this._rotateDelta.x/t.clientHeight),this._rotateUp(Si*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,s=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Ce,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function lP(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function uP(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function hP(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(tE),this.state=Kt.NONE;break;case 1:let e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function dP(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case cs.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Kt.DOLLY;break;case cs.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Kt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Kt.ROTATE}break;case cs.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Kt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Kt.PAN}break;default:this.state=Kt.NONE}this.state!==Kt.NONE&&this.dispatchEvent(iy)}function fP(i){switch(this.state){case Kt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Kt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Kt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function pP(i){this.enabled===!1||this.enableZoom===!1||this.state!==Kt.NONE||(i.preventDefault(),this.dispatchEvent(iy),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(tE))}function mP(i){this.enabled!==!1&&this._handleKeyDown(i)}function gP(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case ls.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Kt.TOUCH_ROTATE;break;case ls.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Kt.TOUCH_PAN;break;default:this.state=Kt.NONE}break;case 2:switch(this.touches.TWO){case ls.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Kt.TOUCH_DOLLY_PAN;break;case ls.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Kt.TOUCH_DOLLY_ROTATE;break;default:this.state=Kt.NONE}break;default:this.state=Kt.NONE}this.state!==Kt.NONE&&this.dispatchEvent(iy)}function yP(i){switch(this._trackPointer(i),this.state){case Kt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Kt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Kt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Kt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Kt.NONE}}function xP(i){this.enabled!==!1&&i.preventDefault()}function vP(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function bP(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function nE(i){return class extends i{_viewFrame(){let t=this.object.position.clone().sub(this.target),n=t.clone().normalize(),r=this.object.up.clone().addScaledVector(n,-this.object.up.dot(n));return r.lengthSq()<1e-8&&(r.setFromMatrixColumn(this.object.matrix,1),r.addScaledVector(n,-r.dot(n))),r.lengthSq()<1e-8&&(r.set(Math.abs(n.y)<.9?0:1,Math.abs(n.y)<.9?1:0,0),r.addScaledVector(n,-r.dot(n))),r.normalize(),this.object.up.copy(r),{offset:t,up:r,right:r.clone().cross(n).normalize()}}_inputAngle(t){let n=this.domElement?.clientHeight||600,r=this.domElement?.clientWidth||600;return t*n/Math.max(600,r,n)}_rotateLeft(t){let{offset:n,up:r}=this._viewFrame();n.applyAxisAngle(r,-this._inputAngle(t)),this.object.position.copy(this.target).add(n)}_rotateUp(t){let{offset:n,up:r,right:s}=this._viewFrame(),o=-this._inputAngle(t);n.applyAxisAngle(s,o),r.applyAxisAngle(s,o),this.object.up.copy(r),this.object.position.copy(this.target).add(n)}update(t){let{up:n}=this._viewFrame();return this._quat.setFromUnitVectors(n,n.clone().set(0,1,0)),this._quatInverse.copy(this._quat).invert(),super.update(t)}}}function iE(i,e,t){i.mouseButtons.LEFT=t?e.MOUSE.PAN:e.MOUSE.ROTATE,i.touches.ONE=t?e.TOUCH.PAN:e.TOUCH.ROTATE}function ry(i,e){if(e===_p)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===Jo||e===Pc){let t=i.getIndex();if(t===null){let o=[],a=i.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)o.push(c);i.setIndex(o),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}let n=t.count-2,r=[];if(e===Jo)for(let o=1;o<=n;o++)r.push(t.getX(0)),r.push(t.getX(o)),r.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(r.push(t.getX(o)),r.push(t.getX(o+1)),r.push(t.getX(o+2))):(r.push(t.getX(o+2)),r.push(t.getX(o+1)),r.push(t.getX(o)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let s=i.clone();return s.setIndex(r),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}var Dp=class extends rn{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new hy(t)}),this.register(function(t){return new dy(t)}),this.register(function(t){return new _y(t)}),this.register(function(t){return new Ey(t)}),this.register(function(t){return new My(t)}),this.register(function(t){return new py(t)}),this.register(function(t){return new my(t)}),this.register(function(t){return new gy(t)}),this.register(function(t){return new yy(t)}),this.register(function(t){return new uy(t)}),this.register(function(t){return new xy(t)}),this.register(function(t){return new fy(t)}),this.register(function(t){return new by(t)}),this.register(function(t){return new vy(t)}),this.register(function(t){return new cy(t)}),this.register(function(t){return new Sy(t)}),this.register(function(t){return new Ty(t)})}load(e,t,n,r){let s=this,o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){let l=Ei.extractUrlBase(e);o=Ei.resolveURL(l,this.path)}else o=Ei.extractUrlBase(e);this.manager.itemStart(e);let a=function(l){r?r(l):console.error(l),s.manager.itemError(e),s.manager.itemEnd(e)},c=new Vn(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(l){try{s.parse(l,o,function(u){t(u),s.manager.itemEnd(e)},a)}catch(u){a(u)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let s,o={},a={},c=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.decode(new Uint8Array(e,0,4))===cE){try{o[Pt.KHR_BINARY_GLTF]=new Ay(e)}catch(h){r&&r(h);return}s=JSON.parse(o[Pt.KHR_BINARY_GLTF].content)}else s=JSON.parse(c.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let l=new Ly(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){let h=this.pluginCallbacks[u](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[h.name]=h,o[h.name]=!0}if(s.extensionsUsed)for(let u=0;u<s.extensionsUsed.length;++u){let h=s.extensionsUsed[u],d=s.extensionsRequired||[];switch(h){case Pt.KHR_MATERIALS_UNLIT:o[h]=new ly;break;case Pt.KHR_DRACO_MESH_COMPRESSION:o[h]=new wy(s,this.dracoLoader);break;case Pt.KHR_TEXTURE_TRANSFORM:o[h]=new Ry;break;case Pt.KHR_MESH_QUANTIZATION:o[h]=new Cy;break;default:d.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(o),l.setPlugins(a),l.parse(n,r)}parseAsync(e,t){let n=this;return new Promise(function(r,s){n.parse(e,t,r,s)})}};function _P(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}var Pt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},cy=class{constructor(e){this.parser=e,this.name=Pt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){let s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){let t=this.parser,n="light:"+e,r=t.cache.get(n);if(r)return r;let s=t.json,c=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e],l,u=new Be(16777215);c.color!==void 0&&u.setRGB(c.color[0],c.color[1],c.color[2],On);let h=c.range!==void 0?c.range:0;switch(c.type){case"directional":l=new as(u),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new os(u),l.distance=h;break;case"spot":l=new Wo(u),l.distance=h,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,l.angle=c.spot.outerConeAngle,l.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return l.position.set(0,0,0),l.decay=2,ps(l,c),c.intensity!==void 0&&(l.intensity=c.intensity),l.name=t.createUniqueName(c.name||"light_"+e),r=Promise.resolve(l),t.cache.add(n,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(c){return n._getNodeRef(t.cache,a,c)})}},ly=class{constructor(){this.name=Pt.KHR_MATERIALS_UNLIT}getMaterialType(){return Ht}extendParams(e,t,n){let r=[];e.color=new Be(1,1,1),e.opacity=1;let s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){let o=s.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],On),e.opacity=o[3]}s.baseColorTexture!==void 0&&r.push(n.assignTexture(e,"map",s.baseColorTexture,wt))}return Promise.all(r)}},uy=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}},hy=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){let a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Ce(a,a)}return Promise.all(s)}},dy=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_DISPERSION}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}},fy=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(s)}},py=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_SHEEN}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[];t.sheenColor=new Be(0,0,0),t.sheenRoughness=0,t.sheen=1;let o=r.extensions[this.name];if(o.sheenColorFactor!==void 0){let a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],On)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,wt)),o.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}},my=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(s)}},gy=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_VOLUME}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;let a=o.attenuationColor||[1,1,1];return t.attenuationColor=new Be().setRGB(a[0],a[1],a[2],On),Promise.all(s)}},yy=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_IOR}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=r.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}},xy=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_SPECULAR}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));let a=o.specularColorFactor||[1,1,1];return t.specularColor=new Be().setRGB(a[0],a[1],a[2],On),o.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,wt)),Promise.all(s)}},vy=class{constructor(e){this.parser=e,this.name=Pt.EXT_MATERIALS_BUMP}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(s)}},by=class{constructor(e){this.parser=e,this.name=Pt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:Dn}extendMaterialParams(e,t){let n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let s=[],o=r.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(s)}},_y=class{constructor(e){this.parser=e,this.name=Pt.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;let s=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}},Ey=class{constructor(e){this.parser=e,this.name=Pt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=r.images[o.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,o.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},My=class{constructor(e){this.parser=e,this.name=Pt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;let o=s.extensions[t],a=r.images[o.source],c=n.textureLoader;if(a.uri){let l=n.options.manager.getHandler(a.uri);l!==null&&(c=l)}return this.detectSupport().then(function(l){if(l)return n.loadTextureImage(e,o.source,c);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}},Sy=class{constructor(e){this.name=Pt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){let r=n.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){let c=r.byteOffset||0,l=r.byteLength||0,u=r.count,h=r.byteStride,d=new Uint8Array(a,c,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,h,d,r.mode,r.filter).then(function(m){return m.buffer}):o.ready.then(function(){let m=new ArrayBuffer(u*h);return o.decodeGltfBuffer(new Uint8Array(m),u,h,d,r.mode,r.filter),m})})}else return null}},Ty=class{constructor(e){this.name=Pt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;let r=t.meshes[n.mesh];for(let l of r.primitives)if(l.mode!==Yi.TRIANGLES&&l.mode!==Yi.TRIANGLE_STRIP&&l.mode!==Yi.TRIANGLE_FAN&&l.mode!==void 0)return null;let o=n.extensions[this.name].attributes,a=[],c={};for(let l in o)a.push(this.parser.getDependency("accessor",o[l]).then(u=>(c[l]=u,c[l])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(l=>{let u=l.pop(),h=u.isGroup?u.children:[u],d=l[0].count,m=[];for(let g of h){let y=new nt,f=new q,p=new Zt,v=new q(1,1,1),b=new $r(g.geometry,g.material,d);for(let x=0;x<d;x++)c.TRANSLATION&&f.fromBufferAttribute(c.TRANSLATION,x),c.ROTATION&&p.fromBufferAttribute(c.ROTATION,x),c.SCALE&&v.fromBufferAttribute(c.SCALE,x),b.setMatrixAt(x,y.compose(f,p,v));for(let x in c)if(x==="_COLOR_0"){let _=c[x];b.instanceColor=new Xi(_.array,_.itemSize,_.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&g.geometry.setAttribute(x,c[x]);St.prototype.copy.call(b,g),this.parser.assignFinalMaterial(b),m.push(b)}return u.isGroup?(u.clear(),u.add(...m),u):m[0]}))}},cE="glTF",Th=12,rE={JSON:1313821514,BIN:5130562},Ay=class{constructor(e){this.name=Pt.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,Th),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==cE)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let r=this.header.length-Th,s=new DataView(e,Th),o=0;for(;o<r;){let a=s.getUint32(o,!0);o+=4;let c=s.getUint32(o,!0);if(o+=4,c===rE.JSON){let l=new Uint8Array(e,Th+o,a);this.content=n.decode(l)}else if(c===rE.BIN){let l=Th+o;this.body=e.slice(l,l+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},wy=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Pt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let n=this.json,r=this.dracoLoader,s=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},c={},l={};for(let u in o){let h=Iy[u]||u.toLowerCase();a[h]=o[u]}for(let u in e.attributes){let h=Iy[u]||u.toLowerCase();if(o[u]!==void 0){let d=n.accessors[e.attributes[u]],m=Fc[d.componentType];l[h]=m.name,c[h]=d.normalized===!0}}return t.getDependency("bufferView",s).then(function(u){return new Promise(function(h,d){r.decodeDracoFile(u,function(m){for(let g in m.attributes){let y=m.attributes[g],f=c[g];f!==void 0&&(y.normalized=f)}h(m)},a,l,On,d)})})}},Ry=class{constructor(){this.name=Pt.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}},Cy=class{constructor(){this.name=Pt.KHR_MESH_QUANTIZATION}},Fp=class extends wr{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){let t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r*3+r;for(let o=0;o!==r;o++)t[o]=n[s+o];return t}interpolate_(e,t,n,r){let s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=a*2,l=a*3,u=r-t,h=(n-t)/u,d=h*h,m=d*h,g=e*l,y=g-l,f=-2*m+3*d,p=m-d,v=1-f,b=p-d+h;for(let x=0;x!==a;x++){let _=o[y+x+a],T=o[y+x+c]*u,w=o[g+x+a],A=o[g+x]*u;s[x]=v*_+b*T+f*w+p*A}return s}},EP=new Zt,Py=class extends Fp{interpolate_(e,t,n,r){let s=super.interpolate_(e,t,n,r);return EP.fromArray(s).normalize().toArray(s),s}},Yi={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Fc={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},sE={9728:Jt,9729:nn,9984:Mc,9985:Zs,9986:hs,9987:Mi},oE={33071:En,33648:ks,10497:gn},sy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Iy={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},$s={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},MP={CUBICSPLINE:void 0,LINEAR:zs,STEP:Bs},oy={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function SP(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new Mn({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Jn})),i.DefaultMaterial}function oa(i,e,t){for(let n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function ps(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function TP(i,e,t){let n=!1,r=!1,s=!1;for(let l=0,u=e.length;l<u;l++){let h=e[l];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(r=!0),h.COLOR_0!==void 0&&(s=!0),n&&r&&s)break}if(!n&&!r&&!s)return Promise.resolve(i);let o=[],a=[],c=[];for(let l=0,u=e.length;l<u;l++){let h=e[l];if(n){let d=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):i.attributes.position;o.push(d)}if(r){let d=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):i.attributes.normal;a.push(d)}if(s){let d=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):i.attributes.color;c.push(d)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(l){let u=l[0],h=l[1],d=l[2];return n&&(i.morphAttributes.position=u),r&&(i.morphAttributes.normal=h),s&&(i.morphAttributes.color=d),i.morphTargetsRelative=!0,i})}function AP(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function wP(i){let e,t=i.extensions&&i.extensions[Pt.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+ay(t.attributes):e=i.indices+":"+ay(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,r=i.targets.length;n<r;n++)e+=":"+ay(i.targets[n]);return e}function ay(i){let e="",t=Object.keys(i).sort();for(let n=0,r=t.length;n<r;n++)e+=t[n]+":"+i[t[n]]+";";return e}function Ny(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function RP(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":i.search(/\.ktx2($|\?)/i)>0||i.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var CP=new nt,Ly=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new _P,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=-1,s=!1,o=-1;if(typeof navigator<"u"){let a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;let c=a.match(/Version\/(\d+)/);r=n&&c?parseInt(c[1],10):-1,s=a.indexOf("Firefox")>-1,o=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&r<17||s&&o<98?this.textureLoader=new qs(this.options.manager):this.textureLoader=new mc(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Vn(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let n=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){let a={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:n,userData:{}};return oa(s,a,r),ps(a,r),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(let c of a.scenes)c.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,s=t.length;r<s;r++){let o=t[r].joints;for(let a=0,c=o.length;a<c;a++)e[o[a]].isBone=!0}for(let r=0,s=e.length;r<s;r++){let o=e[r];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;let r=n.clone(),s=(o,a)=>{let c=this.associations.get(o);c!=null&&this.associations.set(a,c);for(let[l,u]of o.children.entries())s(u,a.children[l])};return s(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){let r=e(t[n]);if(r)return r}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let n=[];for(let r=0;r<t.length;r++){let s=e(t[r]);s&&n.push(s)}return n}getDependency(e,t){let n=e+":"+t,r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":r=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){let n=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(s,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Pt.KHR_BINARY_GLTF].body);let r=this.options;return new Promise(function(s,o){n.load(Ei.resolveURL(t.uri,r.path),s,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){let r=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+r)})}loadAccessor(e){let t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){let o=sy[r.type],a=Fc[r.componentType],c=r.normalized===!0,l=new a(r.count*o);return Promise.resolve(new gt(l,o,c))}let s=[];return r.bufferView!==void 0?s.push(this.getDependency("bufferView",r.bufferView)):s.push(null),r.sparse!==void 0&&(s.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(s).then(function(o){let a=o[0],c=sy[r.type],l=Fc[r.componentType],u=l.BYTES_PER_ELEMENT,h=u*c,d=r.byteOffset||0,m=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,g=r.normalized===!0,y,f;if(m&&m!==h){let p=Math.floor(d/m),v="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+p+":"+r.count,b=t.cache.get(v);b||(y=new l(a,p*m,r.count*m/u),b=new Mr(y,m/u),t.cache.add(v,b)),f=new ir(b,c,d%m/u,g)}else a===null?y=new l(r.count*c):y=new l(a,d,r.count*c),f=new gt(y,c,g);if(r.sparse!==void 0){let p=sy.SCALAR,v=Fc[r.sparse.indices.componentType],b=r.sparse.indices.byteOffset||0,x=r.sparse.values.byteOffset||0,_=new v(o[1],b,r.sparse.count*p),T=new l(o[2],x,r.sparse.count*c);a!==null&&(f=new gt(f.array.slice(),f.itemSize,f.normalized)),f.normalized=!1;for(let w=0,A=_.length;w<A;w++){let E=_[w];if(f.setX(E,T[w*c]),c>=2&&f.setY(E,T[w*c+1]),c>=3&&f.setZ(E,T[w*c+2]),c>=4&&f.setW(E,T[w*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}f.normalized=g}return f})}loadTexture(e){let t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s],a=this.textureLoader;if(o.uri){let c=n.manager.getHandler(o.uri);c!==null&&(a=c)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){let r=this,s=this.json,o=s.textures[e],a=s.images[t],c=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[c])return this.textureCache[c];let l=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);let d=(s.samplers||{})[o.sampler]||{};return u.magFilter=sE[d.magFilter]||nn,u.minFilter=sE[d.minFilter]||Mi,u.wrapS=oE[d.wrapS]||gn,u.wrapT=oE[d.wrapT]||gn,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==Jt&&u.minFilter!==nn,r.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[c]=l,l}loadImageSource(e,t){let n=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());let o=r.images[e],a=self.URL||self.webkitURL,c=o.uri||"",l=!1;if(o.bufferView!==void 0)c=n.getDependency("bufferView",o.bufferView).then(function(h){l=!0;let d=new Blob([h],{type:o.mimeType});return c=a.createObjectURL(d),c});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let u=Promise.resolve(c).then(function(h){return new Promise(function(d,m){let g=d;t.isImageBitmapLoader===!0&&(g=function(y){let f=new Qt(y);f.needsUpdate=!0,d(f)}),t.load(Ei.resolveURL(h,s.path),g,void 0,m)})}).then(function(h){return l===!0&&a.revokeObjectURL(c),ps(h,o),h.userData.mimeType=o.mimeType||RP(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),h});return this.sourceCache[e]=u,u}assignTexture(e,t,n,r){let s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[Pt.KHR_TEXTURE_TRANSFORM]){let a=n.extensions!==void 0?n.extensions[Pt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let c=s.associations.get(o);o=s.extensions[Pt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,c)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,n=e.material,r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new Sr,cn.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){let a="LineBasicMaterial:"+n.uuid,c=this.cache.get(a);c||(c=new Xt,cn.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(r||s||o){let a="ClonedMaterial:"+n.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),s&&(c.vertexColors=!0),o&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return Mn}loadMaterial(e){let t=this,n=this.json,r=this.extensions,s=n.materials[e],o,a={},c=s.extensions||{},l=[];if(c[Pt.KHR_MATERIALS_UNLIT]){let h=r[Pt.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),l.push(h.extendParams(a,s,t))}else{let h=s.pbrMetallicRoughness||{};if(a.color=new Be(1,1,1),a.opacity=1,Array.isArray(h.baseColorFactor)){let d=h.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],On),a.opacity=d[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(a,"map",h.baseColorTexture,wt)),a.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,a.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(a,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=yn);let u=s.alphaMode||oy.OPAQUE;if(u===oy.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===oy.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==Ht&&(l.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Ce(1,1),s.normalTexture.scale!==void 0)){let h=s.normalTexture.scale;a.normalScale.set(h,h)}if(s.occlusionTexture!==void 0&&o!==Ht&&(l.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==Ht){let h=s.emissiveFactor;a.emissive=new Be().setRGB(h[0],h[1],h[2],On)}return s.emissiveTexture!==void 0&&o!==Ht&&l.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,wt)),Promise.all(l).then(function(){let h=new o(a);return s.name&&(h.name=s.name),ps(h,s),t.associations.set(h,{materials:e}),s.extensions&&oa(r,h,s),h})}createUniqueName(e){let t=Ut.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,n=this.extensions,r=this.primitiveCache;function s(a){return n[Pt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return aE(c,a,t)})}let o=[];for(let a=0,c=e.length;a<c;a++){let l=e[a],u=wP(l),h=r[u];if(h)o.push(h.promise);else{let d;l.extensions&&l.extensions[Pt.KHR_DRACO_MESH_COMPRESSION]?d=s(l):d=aE(new ot,l,t),r[u]={primitive:l,promise:d},o.push(d)}}return Promise.all(o)}loadMesh(e){let t=this,n=this.json,r=this.extensions,s=n.meshes[e],o=s.primitives,a=[];for(let c=0,l=o.length;c<l;c++){let u=o[c].material===void 0?SP(this.cache):this.getDependency("material",o[c].material);a.push(u)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(c){let l=c.slice(0,c.length-1),u=c[c.length-1],h=[];for(let m=0,g=u.length;m<g;m++){let y=u[m],f=o[m],p,v=l[m];if(f.mode===Yi.TRIANGLES||f.mode===Yi.TRIANGLE_STRIP||f.mode===Yi.TRIANGLE_FAN||f.mode===void 0)p=s.isSkinnedMesh===!0?new Do(y,v):new ct(y,v),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),f.mode===Yi.TRIANGLE_STRIP?p.geometry=ry(p.geometry,Pc):f.mode===Yi.TRIANGLE_FAN&&(p.geometry=ry(p.geometry,Jo));else if(f.mode===Yi.LINES)p=new ln(y,v);else if(f.mode===Yi.LINE_STRIP)p=new ai(y,v);else if(f.mode===Yi.LINE_LOOP)p=new es(y,v);else if(f.mode===Yi.POINTS)p=new ts(y,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+f.mode);Object.keys(p.geometry.morphAttributes).length>0&&AP(p,s),p.name=t.createUniqueName(s.name||"mesh_"+e),ps(p,s),f.extensions&&oa(r,p,f),t.assignFinalMaterial(p),h.push(p)}for(let m=0,g=h.length;m<g;m++)t.associations.set(h[m],{meshes:e,primitives:m});if(h.length===1)return s.extensions&&oa(r,h[0],s),h[0];let d=new Dt;s.extensions&&oa(r,d,s),t.associations.set(d,{meshes:e});for(let m=0,g=h.length;m<g;m++)d.add(h[m]);return d})}loadCamera(e){let t,n=this.json.cameras[e],r=n[n.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new jt(Js.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(t=new cr(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),ps(t,n),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],n=[];for(let r=0,s=t.joints.length;r<s;r++)n.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(r){let s=r.pop(),o=r,a=[],c=[];for(let l=0,u=o.length;l<u;l++){let h=o[l];if(h){a.push(h);let d=new nt;s!==null&&d.fromArray(s.array,l*16),c.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new Fo(a,c)})}loadAnimation(e){let t=this.json,n=this,r=t.animations[e],s=r.name?r.name:"animation_"+e,o=[],a=[],c=[],l=[],u=[];for(let h=0,d=r.channels.length;h<d;h++){let m=r.channels[h],g=r.samplers[m.sampler],y=m.target,f=y.node,p=r.parameters!==void 0?r.parameters[g.input]:g.input,v=r.parameters!==void 0?r.parameters[g.output]:g.output;y.node!==void 0&&(o.push(this.getDependency("node",f)),a.push(this.getDependency("accessor",p)),c.push(this.getDependency("accessor",v)),l.push(g),u.push(y))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(h){let d=h[0],m=h[1],g=h[2],y=h[3],f=h[4],p=[];for(let v=0,b=d.length;v<b;v++){let x=d[v],_=m[v],T=g[v],w=y[v],A=f[v];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();let E=n._createAnimationTracks(x,_,T,w,A);if(E)for(let M=0;M<E.length;M++)p.push(E[M])}return new Pr(s,void 0,p)})}createNodeMesh(e){let t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency("mesh",r.mesh).then(function(s){let o=n._getNodeRef(n.meshCache,r.mesh,s);return r.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let c=0,l=r.weights.length;c<l;c++)a.morphTargetInfluences[c]=r.weights[c]}),o})}loadNode(e){let t=this.json,n=this,r=t.nodes[e],s=n._loadNodeShallow(e),o=[],a=r.children||[];for(let l=0,u=a.length;l<u;l++)o.push(n.getDependency("node",a[l]));let c=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([s,Promise.all(o),c]).then(function(l){let u=l[0],h=l[1],d=l[2];d!==null&&u.traverse(function(m){m.isSkinnedMesh&&m.bind(d,CP)});for(let m=0,g=h.length;m<g;m++)u.add(h[m]);return u})}_loadNodeShallow(e){let t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let s=t.nodes[e],o=s.name?r.createUniqueName(s.name):"",a=[],c=r._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return c&&a.push(c),s.camera!==void 0&&a.push(r.getDependency("camera",s.camera).then(function(l){return r._getNodeRef(r.cameraCache,s.camera,l)})),r._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){a.push(l)}),this.nodeCache[e]=Promise.all(a).then(function(l){let u;if(s.isBone===!0?u=new Gs:l.length>1?u=new Dt:l.length===1?u=l[0]:u=new St,u!==l[0])for(let h=0,d=l.length;h<d;h++)u.add(l[h]);if(s.name&&(u.userData.name=s.name,u.name=o),ps(u,s),s.extensions&&oa(n,u,s),s.matrix!==void 0){let h=new nt;h.fromArray(s.matrix),u.applyMatrix4(h)}else s.translation!==void 0&&u.position.fromArray(s.translation),s.rotation!==void 0&&u.quaternion.fromArray(s.rotation),s.scale!==void 0&&u.scale.fromArray(s.scale);return r.associations.has(u)||r.associations.set(u,{}),r.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){let t=this.extensions,n=this.json.scenes[e],r=this,s=new Dt;n.name&&(s.name=r.createUniqueName(n.name)),ps(s,n),n.extensions&&oa(t,s,n);let o=n.nodes||[],a=[];for(let c=0,l=o.length;c<l;c++)a.push(r.getDependency("node",o[c]));return Promise.all(a).then(function(c){for(let u=0,h=c.length;u<h;u++)s.add(c[u]);let l=u=>{let h=new Map;for(let[d,m]of r.associations)(d instanceof cn||d instanceof Qt)&&h.set(d,m);return u.traverse(d=>{let m=r.associations.get(d);m!=null&&h.set(d,m)}),h};return r.associations=l(s),s})}_createAnimationTracks(e,t,n,r,s){let o=[],a=e.name?e.name:e.uuid,c=[];$s[s.path]===$s.weights?e.traverse(function(d){d.morphTargetInfluences&&c.push(d.name?d.name:d.uuid)}):c.push(a);let l;switch($s[s.path]){case $s.weights:l=rr;break;case $s.rotation:l=sr;break;case $s.position:case $s.scale:l=or;break;default:switch(n.itemSize){case 1:l=rr;break;case 2:case 3:default:l=or;break}break}let u=r.interpolation!==void 0?MP[r.interpolation]:zs,h=this._getArrayFromAccessor(n);for(let d=0,m=c.length;d<m;d++){let g=new l(c[d]+"."+$s[s.path],t.array,h,u);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let n=Ny(t.constructor),r=new Float32Array(t.length);for(let s=0,o=t.length;s<o;s++)r[s]=t[s]*n;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){let r=this instanceof sr?Py:Fp;return new r(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function PP(i,e,t){let n=e.attributes,r=new zt;if(n.POSITION!==void 0){let a=t.json.accessors[n.POSITION],c=a.min,l=a.max;if(c!==void 0&&l!==void 0){if(r.set(new q(c[0],c[1],c[2]),new q(l[0],l[1],l[2])),a.normalized){let u=Ny(Fc[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=e.targets;if(s!==void 0){let a=new q,c=new q;for(let l=0,u=s.length;l<u;l++){let h=s[l];if(h.POSITION!==void 0){let d=t.json.accessors[h.POSITION],m=d.min,g=d.max;if(m!==void 0&&g!==void 0){if(c.setX(Math.max(Math.abs(m[0]),Math.abs(g[0]))),c.setY(Math.max(Math.abs(m[1]),Math.abs(g[1]))),c.setZ(Math.max(Math.abs(m[2]),Math.abs(g[2]))),d.normalized){let y=Ny(Fc[d.componentType]);c.multiplyScalar(y)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}i.boundingBox=r;let o=new qt;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,i.boundingSphere=o}function aE(i,e,t){let n=e.attributes,r=[];function s(o,a){return t.getDependency("accessor",o).then(function(c){i.setAttribute(a,c)})}for(let o in n){let a=Iy[o]||o.toLowerCase();a in i.attributes||r.push(s(n[o],a))}if(e.indices!==void 0&&!i.index){let o=t.getDependency("accessor",e.indices).then(function(a){i.setIndex(a)});r.push(o)}return bt.workingColorSpace!==On&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${bt.workingColorSpace}" not supported.`),ps(i,e),PP(i,e,t),Promise.all(r).then(function(){return e.targets!==void 0?TP(i,e.targets,t):i})}var Mt=(i,e)=>()=>(e||(e={exports:{}},i(e.exports,e)),e.exports),lE=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.VERSION=void 0,i.VERSION="9.0.1"}),Vt=Mt((exports,module)=>{"use strict";var __spreadArray=exports&&exports.__spreadArray||function(i,e){for(var t=0,n=e.length,r=i.length;t<n;t++,r++)i[r]=e[t];return i};Object.defineProperty(exports,"__esModule",{value:!0}),exports.toFastProperties=exports.timer=exports.peek=exports.isES2015MapSupported=exports.PRINT_WARNING=exports.PRINT_ERROR=exports.packArray=exports.IDENTITY=exports.NOOP=exports.merge=exports.groupBy=exports.defaults=exports.assignNoOverwrite=exports.assign=exports.zipObject=exports.sortBy=exports.indexOf=exports.some=exports.difference=exports.every=exports.isObject=exports.isRegExp=exports.isArray=exports.partial=exports.uniq=exports.compact=exports.reduce=exports.findAll=exports.find=exports.cloneObj=exports.cloneArr=exports.contains=exports.has=exports.pick=exports.reject=exports.filter=exports.dropRight=exports.drop=exports.isFunction=exports.isUndefined=exports.isString=exports.forEach=exports.last=exports.first=exports.flatten=exports.map=exports.mapValues=exports.values=exports.keys=exports.isEmpty=void 0;function isEmpty(i){return i&&i.length===0}exports.isEmpty=isEmpty;function keys(i){return i==null?[]:Object.keys(i)}exports.keys=keys;function values(i){for(var e=[],t=Object.keys(i),n=0;n<t.length;n++)e.push(i[t[n]]);return e}exports.values=values;function mapValues(i,e){for(var t=[],n=keys(i),r=0;r<n.length;r++){var s=n[r];t.push(e.call(null,i[s],s))}return t}exports.mapValues=mapValues;function map(i,e){for(var t=[],n=0;n<i.length;n++)t.push(e.call(null,i[n],n));return t}exports.map=map;function flatten(i){for(var e=[],t=0;t<i.length;t++){var n=i[t];Array.isArray(n)?e=e.concat(flatten(n)):e.push(n)}return e}exports.flatten=flatten;function first(i){return isEmpty(i)?void 0:i[0]}exports.first=first;function last(i){var e=i&&i.length;return e?i[e-1]:void 0}exports.last=last;function forEach(i,e){if(Array.isArray(i))for(var t=0;t<i.length;t++)e.call(null,i[t],t);else if(isObject(i))for(var n=keys(i),t=0;t<n.length;t++){var r=n[t],s=i[r];e.call(null,s,r)}else throw Error("non exhaustive match")}exports.forEach=forEach;function isString(i){return typeof i=="string"}exports.isString=isString;function isUndefined(i){return i===void 0}exports.isUndefined=isUndefined;function isFunction(i){return i instanceof Function}exports.isFunction=isFunction;function drop(i,e){return e===void 0&&(e=1),i.slice(e,i.length)}exports.drop=drop;function dropRight(i,e){return e===void 0&&(e=1),i.slice(0,i.length-e)}exports.dropRight=dropRight;function filter(i,e){var t=[];if(Array.isArray(i))for(var n=0;n<i.length;n++){var r=i[n];e.call(null,r)&&t.push(r)}return t}exports.filter=filter;function reject(i,e){return filter(i,function(t){return!e(t)})}exports.reject=reject;function pick(i,e){for(var t=Object.keys(i),n={},r=0;r<t.length;r++){var s=t[r],o=i[s];e(o)&&(n[s]=o)}return n}exports.pick=pick;function has(i,e){return isObject(i)?i.hasOwnProperty(e):!1}exports.has=has;function contains(i,e){return find(i,function(t){return t===e})!==void 0}exports.contains=contains;function cloneArr(i){for(var e=[],t=0;t<i.length;t++)e.push(i[t]);return e}exports.cloneArr=cloneArr;function cloneObj(i){var e={};for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[t]=i[t]);return e}exports.cloneObj=cloneObj;function find(i,e){for(var t=0;t<i.length;t++){var n=i[t];if(e.call(null,n))return n}}exports.find=find;function findAll(i,e){for(var t=[],n=0;n<i.length;n++){var r=i[n];e.call(null,r)&&t.push(r)}return t}exports.findAll=findAll;function reduce(i,e,t){for(var n=Array.isArray(i),r=n?i:values(i),s=n?[]:keys(i),o=t,a=0;a<r.length;a++)o=e.call(null,o,r[a],n?a:s[a]);return o}exports.reduce=reduce;function compact(i){return reject(i,function(e){return e==null})}exports.compact=compact;function uniq(i,e){e===void 0&&(e=function(n){return n});var t=[];return reduce(i,function(n,r){var s=e(r);return contains(t,s)?n:(t.push(s),n.concat(r))},[])}exports.uniq=uniq;function partial(i){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];var n=[null],r=n.concat(e);return Function.bind.apply(i,r)}exports.partial=partial;function isArray(i){return Array.isArray(i)}exports.isArray=isArray;function isRegExp(i){return i instanceof RegExp}exports.isRegExp=isRegExp;function isObject(i){return i instanceof Object}exports.isObject=isObject;function every(i,e){for(var t=0;t<i.length;t++)if(!e(i[t],t))return!1;return!0}exports.every=every;function difference(i,e){return reject(i,function(t){return contains(e,t)})}exports.difference=difference;function some(i,e){for(var t=0;t<i.length;t++)if(e(i[t]))return!0;return!1}exports.some=some;function indexOf(i,e){for(var t=0;t<i.length;t++)if(i[t]===e)return t;return-1}exports.indexOf=indexOf;function sortBy(i,e){var t=cloneArr(i);return t.sort(function(n,r){return e(n)-e(r)}),t}exports.sortBy=sortBy;function zipObject(i,e){if(i.length!==e.length)throw Error("can't zipObject with different number of keys and values!");for(var t={},n=0;n<i.length;n++)t[i[n]]=e[n];return t}exports.zipObject=zipObject;function assign(i){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var n=0;n<e.length;n++)for(var r=e[n],s=keys(r),o=0;o<s.length;o++){var a=s[o];i[a]=r[a]}return i}exports.assign=assign;function assignNoOverwrite(i){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var n=0;n<e.length;n++)for(var r=e[n],s=keys(r),o=0;o<s.length;o++){var a=s[o];has(i,a)||(i[a]=r[a])}return i}exports.assignNoOverwrite=assignNoOverwrite;function defaults(){for(var i=[],e=0;e<arguments.length;e++)i[e]=arguments[e];return assignNoOverwrite.apply(void 0,__spreadArray([{}],i))}exports.defaults=defaults;function groupBy(i,e){var t={};return forEach(i,function(n){var r=e(n),s=t[r];s?s.push(n):t[r]=[n]}),t}exports.groupBy=groupBy;function merge(i,e){for(var t=cloneObj(i),n=keys(e),r=0;r<n.length;r++){var s=n[r],o=e[s];t[s]=o}return t}exports.merge=merge;function NOOP(){}exports.NOOP=NOOP;function IDENTITY(i){return i}exports.IDENTITY=IDENTITY;function packArray(i){for(var e=[],t=0;t<i.length;t++){var n=i[t];e.push(n!==void 0?n:void 0)}return e}exports.packArray=packArray;function PRINT_ERROR(i){console&&console.error&&console.error("Error: "+i)}exports.PRINT_ERROR=PRINT_ERROR;function PRINT_WARNING(i){console&&console.warn&&console.warn("Warning: "+i)}exports.PRINT_WARNING=PRINT_WARNING;function isES2015MapSupported(){return typeof Map=="function"}exports.isES2015MapSupported=isES2015MapSupported;function peek(i){return i[i.length-1]}exports.peek=peek;function timer(i){var e=new Date().getTime(),t=i(),n=new Date().getTime(),r=n-e;return{time:r,value:t}}exports.timer=timer;function toFastProperties(toBecomeFast){function FakeConstructor(){}FakeConstructor.prototype=toBecomeFast;var fakeInstance=new FakeConstructor;function fakeAccess(){return typeof fakeInstance.bar}return fakeAccess(),fakeAccess(),toBecomeFast}exports.toFastProperties=toFastProperties}),Oy=Mt((i,e)=>{(function(t,n){typeof define=="function"&&define.amd?define([],n):typeof e=="object"&&e.exports?e.exports=n():t.regexpToAst=n()})(typeof self<"u"?self:i,function(){function t(){}t.prototype.saveState=function(){return{idx:this.idx,input:this.input,groupIdx:this.groupIdx}},t.prototype.restoreState=function(f){this.idx=f.idx,this.input=f.input,this.groupIdx=f.groupIdx},t.prototype.pattern=function(f){this.idx=0,this.input=f,this.groupIdx=0,this.consumeChar("/");var p=this.disjunction();this.consumeChar("/");for(var v={type:"Flags",loc:{begin:this.idx,end:f.length},global:!1,ignoreCase:!1,multiLine:!1,unicode:!1,sticky:!1};this.isRegExpFlag();)switch(this.popChar()){case"g":c(v,"global");break;case"i":c(v,"ignoreCase");break;case"m":c(v,"multiLine");break;case"u":c(v,"unicode");break;case"y":c(v,"sticky");break}if(this.idx!==this.input.length)throw Error("Redundant input: "+this.input.substring(this.idx));return{type:"Pattern",flags:v,value:p,loc:this.loc(0)}},t.prototype.disjunction=function(){var f=[],p=this.idx;for(f.push(this.alternative());this.peekChar()==="|";)this.consumeChar("|"),f.push(this.alternative());return{type:"Disjunction",value:f,loc:this.loc(p)}},t.prototype.alternative=function(){for(var f=[],p=this.idx;this.isTerm();)f.push(this.term());return{type:"Alternative",value:f,loc:this.loc(p)}},t.prototype.term=function(){return this.isAssertion()?this.assertion():this.atom()},t.prototype.assertion=function(){var f=this.idx;switch(this.popChar()){case"^":return{type:"StartAnchor",loc:this.loc(f)};case"$":return{type:"EndAnchor",loc:this.loc(f)};case"\\":switch(this.popChar()){case"b":return{type:"WordBoundary",loc:this.loc(f)};case"B":return{type:"NonWordBoundary",loc:this.loc(f)}}throw Error("Invalid Assertion Escape");case"(":this.consumeChar("?");var p;switch(this.popChar()){case"=":p="Lookahead";break;case"!":p="NegativeLookahead";break}l(p);var v=this.disjunction();return this.consumeChar(")"),{type:p,value:v,loc:this.loc(f)}}u()},t.prototype.quantifier=function(f){var p,v=this.idx;switch(this.popChar()){case"*":p={atLeast:0,atMost:1/0};break;case"+":p={atLeast:1,atMost:1/0};break;case"?":p={atLeast:0,atMost:1};break;case"{":var b=this.integerIncludingZero();switch(this.popChar()){case"}":p={atLeast:b,atMost:b};break;case",":var x;this.isDigit()?(x=this.integerIncludingZero(),p={atLeast:b,atMost:x}):p={atLeast:b,atMost:1/0},this.consumeChar("}");break}if(f===!0&&p===void 0)return;l(p);break}if(!(f===!0&&p===void 0))return l(p),this.peekChar(0)==="?"?(this.consumeChar("?"),p.greedy=!1):p.greedy=!0,p.type="Quantifier",p.loc=this.loc(v),p},t.prototype.atom=function(){var f,p=this.idx;switch(this.peekChar()){case".":f=this.dotAll();break;case"\\":f=this.atomEscape();break;case"[":f=this.characterClass();break;case"(":f=this.group();break}return f===void 0&&this.isPatternCharacter()&&(f=this.patternCharacter()),l(f),f.loc=this.loc(p),this.isQuantifier()&&(f.quantifier=this.quantifier()),f},t.prototype.dotAll=function(){return this.consumeChar("."),{type:"Set",complement:!0,value:[o(`
`),o("\r"),o("\u2028"),o("\u2029")]}},t.prototype.atomEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":return this.decimalEscapeAtom();case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.decimalEscapeAtom=function(){var f=this.positiveInteger();return{type:"GroupBackReference",value:f}},t.prototype.characterClassEscape=function(){var f,p=!1;switch(this.popChar()){case"d":f=d;break;case"D":f=d,p=!0;break;case"s":f=g;break;case"S":f=g,p=!0;break;case"w":f=m;break;case"W":f=m,p=!0;break}return l(f),{type:"Set",value:f,complement:p}},t.prototype.controlEscapeAtom=function(){var f;switch(this.popChar()){case"f":f=o("\f");break;case"n":f=o(`
`);break;case"r":f=o("\r");break;case"t":f=o("	");break;case"v":f=o("\v");break}return l(f),{type:"Character",value:f}},t.prototype.controlLetterEscapeAtom=function(){this.consumeChar("c");var f=this.popChar();if(/[a-zA-Z]/.test(f)===!1)throw Error("Invalid ");var p=f.toUpperCase().charCodeAt(0)-64;return{type:"Character",value:p}},t.prototype.nulCharacterAtom=function(){return this.consumeChar("0"),{type:"Character",value:o("\0")}},t.prototype.hexEscapeSequenceAtom=function(){return this.consumeChar("x"),this.parseHexDigits(2)},t.prototype.regExpUnicodeEscapeSequenceAtom=function(){return this.consumeChar("u"),this.parseHexDigits(4)},t.prototype.identityEscapeAtom=function(){var f=this.popChar();return{type:"Character",value:o(f)}},t.prototype.classPatternCharacterAtom=function(){switch(this.peekChar()){case`
`:case"\r":case"\u2028":case"\u2029":case"\\":case"]":throw Error("TBD");default:var f=this.popChar();return{type:"Character",value:o(f)}}},t.prototype.characterClass=function(){var f=[],p=!1;for(this.consumeChar("["),this.peekChar(0)==="^"&&(this.consumeChar("^"),p=!0);this.isClassAtom();){var v=this.classAtom(),b=v.type==="Character";if(b&&this.isRangeDash()){this.consumeChar("-");var x=this.classAtom(),_=x.type==="Character";if(_){if(x.value<v.value)throw Error("Range out of order in character class");f.push({from:v.value,to:x.value})}else a(v.value,f),f.push(o("-")),a(x.value,f)}else a(v.value,f)}return this.consumeChar("]"),{type:"Set",complement:p,value:f}},t.prototype.classAtom=function(){switch(this.peekChar()){case"]":case`
`:case"\r":case"\u2028":case"\u2029":throw Error("TBD");case"\\":return this.classEscape();default:return this.classPatternCharacterAtom()}},t.prototype.classEscape=function(){switch(this.consumeChar("\\"),this.peekChar()){case"b":return this.consumeChar("b"),{type:"Character",value:o("\b")};case"d":case"D":case"s":case"S":case"w":case"W":return this.characterClassEscape();case"f":case"n":case"r":case"t":case"v":return this.controlEscapeAtom();case"c":return this.controlLetterEscapeAtom();case"0":return this.nulCharacterAtom();case"x":return this.hexEscapeSequenceAtom();case"u":return this.regExpUnicodeEscapeSequenceAtom();default:return this.identityEscapeAtom()}},t.prototype.group=function(){var f=!0;switch(this.consumeChar("("),this.peekChar(0)){case"?":this.consumeChar("?"),this.consumeChar(":"),f=!1;break;default:this.groupIdx++;break}var p=this.disjunction();this.consumeChar(")");var v={type:"Group",capturing:f,value:p};return f&&(v.idx=this.groupIdx),v},t.prototype.positiveInteger=function(){var f=this.popChar();if(s.test(f)===!1)throw Error("Expecting a positive integer");for(;r.test(this.peekChar(0));)f+=this.popChar();return parseInt(f,10)},t.prototype.integerIncludingZero=function(){var f=this.popChar();if(r.test(f)===!1)throw Error("Expecting an integer");for(;r.test(this.peekChar(0));)f+=this.popChar();return parseInt(f,10)},t.prototype.patternCharacter=function(){var f=this.popChar();switch(f){case`
`:case"\r":case"\u2028":case"\u2029":case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":throw Error("TBD");default:return{type:"Character",value:o(f)}}},t.prototype.isRegExpFlag=function(){switch(this.peekChar(0)){case"g":case"i":case"m":case"u":case"y":return!0;default:return!1}},t.prototype.isRangeDash=function(){return this.peekChar()==="-"&&this.isClassAtom(1)},t.prototype.isDigit=function(){return r.test(this.peekChar(0))},t.prototype.isClassAtom=function(f){switch(f===void 0&&(f=0),this.peekChar(f)){case"]":case`
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.isTerm=function(){return this.isAtom()||this.isAssertion()},t.prototype.isAtom=function(){if(this.isPatternCharacter())return!0;switch(this.peekChar(0)){case".":case"\\":case"[":case"(":return!0;default:return!1}},t.prototype.isAssertion=function(){switch(this.peekChar(0)){case"^":case"$":return!0;case"\\":switch(this.peekChar(1)){case"b":case"B":return!0;default:return!1}case"(":return this.peekChar(1)==="?"&&(this.peekChar(2)==="="||this.peekChar(2)==="!");default:return!1}},t.prototype.isQuantifier=function(){var f=this.saveState();try{return this.quantifier(!0)!==void 0}catch{return!1}finally{this.restoreState(f)}},t.prototype.isPatternCharacter=function(){switch(this.peekChar()){case"^":case"$":case"\\":case".":case"*":case"+":case"?":case"(":case")":case"[":case"|":case"/":case`
`:case"\r":case"\u2028":case"\u2029":return!1;default:return!0}},t.prototype.parseHexDigits=function(f){for(var p="",v=0;v<f;v++){var b=this.popChar();if(n.test(b)===!1)throw Error("Expecting a HexDecimal digits");p+=b}var x=parseInt(p,16);return{type:"Character",value:x}},t.prototype.peekChar=function(f){return f===void 0&&(f=0),this.input[this.idx+f]},t.prototype.popChar=function(){var f=this.peekChar(0);return this.consumeChar(),f},t.prototype.consumeChar=function(f){if(f!==void 0&&this.input[this.idx]!==f)throw Error("Expected: '"+f+"' but found: '"+this.input[this.idx]+"' at offset: "+this.idx);if(this.idx>=this.input.length)throw Error("Unexpected end of input");this.idx++},t.prototype.loc=function(f){return{begin:f,end:this.idx}};var n=/[0-9a-fA-F]/,r=/[0-9]/,s=/[1-9]/;function o(f){return f.charCodeAt(0)}function a(f,p){f.length!==void 0?f.forEach(function(v){p.push(v)}):p.push(f)}function c(f,p){if(f[p]===!0)throw"duplicate flag "+p;f[p]=!0}function l(f){if(f===void 0)throw Error("Internal Error - Should never get here!")}function u(){throw Error("Internal Error - Should never get here!")}var h,d=[];for(h=o("0");h<=o("9");h++)d.push(h);var m=[o("_")].concat(d);for(h=o("a");h<=o("z");h++)m.push(h);for(h=o("A");h<=o("Z");h++)m.push(h);var g=[o(" "),o("\f"),o(`
`),o("\r"),o("	"),o("\v"),o("	"),o("\xA0"),o("\u1680"),o("\u2000"),o("\u2001"),o("\u2002"),o("\u2003"),o("\u2004"),o("\u2005"),o("\u2006"),o("\u2007"),o("\u2008"),o("\u2009"),o("\u200A"),o("\u2028"),o("\u2029"),o("\u202F"),o("\u205F"),o("\u3000"),o("\uFEFF")];function y(){}return y.prototype.visitChildren=function(f){for(var p in f){var v=f[p];f.hasOwnProperty(p)&&(v.type!==void 0?this.visit(v):Array.isArray(v)&&v.forEach(function(b){this.visit(b)},this))}},y.prototype.visit=function(f){switch(f.type){case"Pattern":this.visitPattern(f);break;case"Flags":this.visitFlags(f);break;case"Disjunction":this.visitDisjunction(f);break;case"Alternative":this.visitAlternative(f);break;case"StartAnchor":this.visitStartAnchor(f);break;case"EndAnchor":this.visitEndAnchor(f);break;case"WordBoundary":this.visitWordBoundary(f);break;case"NonWordBoundary":this.visitNonWordBoundary(f);break;case"Lookahead":this.visitLookahead(f);break;case"NegativeLookahead":this.visitNegativeLookahead(f);break;case"Character":this.visitCharacter(f);break;case"Set":this.visitSet(f);break;case"Group":this.visitGroup(f);break;case"GroupBackReference":this.visitGroupBackReference(f);break;case"Quantifier":this.visitQuantifier(f);break}this.visitChildren(f)},y.prototype.visitPattern=function(f){},y.prototype.visitFlags=function(f){},y.prototype.visitDisjunction=function(f){},y.prototype.visitAlternative=function(f){},y.prototype.visitStartAnchor=function(f){},y.prototype.visitEndAnchor=function(f){},y.prototype.visitWordBoundary=function(f){},y.prototype.visitNonWordBoundary=function(f){},y.prototype.visitLookahead=function(f){},y.prototype.visitNegativeLookahead=function(f){},y.prototype.visitCharacter=function(f){},y.prototype.visitSet=function(f){},y.prototype.visitGroup=function(f){},y.prototype.visitGroupBackReference=function(f){},y.prototype.visitQuantifier=function(f){},{RegExpParser:t,BaseRegExpVisitor:y,VERSION:"0.5.0"}})}),Dy=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.clearRegExpParserCache=i.getRegExpAst=void 0;var e=Oy(),t={},n=new e.RegExpParser;function r(o){var a=o.toString();if(t.hasOwnProperty(a))return t[a];var c=n.pattern(a);return t[a]=c,c}i.getRegExpAst=r;function s(){t={}}i.clearRegExpParserCache=s}),IP=Mt(i=>{"use strict";var e=i&&i.__extends||(function(){var y=function(f,p){return y=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,b){v.__proto__=b}||function(v,b){for(var x in b)Object.prototype.hasOwnProperty.call(b,x)&&(v[x]=b[x])},y(f,p)};return function(f,p){if(typeof p!="function"&&p!==null)throw new TypeError("Class extends value "+String(p)+" is not a constructor or null");y(f,p);function v(){this.constructor=f}f.prototype=p===null?Object.create(p):(v.prototype=p.prototype,new v)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.canMatchCharCode=i.firstCharOptimizedIndices=i.getOptimizedStartCodesIndices=i.failedOptimizationPrefixMsg=void 0;var t=Oy(),n=Vt(),r=Dy(),s=uE(),o="Complement Sets are not supported for first char optimization";i.failedOptimizationPrefixMsg=`Unable to use "first char" lexer optimizations:
`;function a(y,f){f===void 0&&(f=!1);try{var p=r.getRegExpAst(y),v=c(p.value,{},p.flags.ignoreCase);return v}catch(x){if(x.message===o)f&&n.PRINT_WARNING(""+i.failedOptimizationPrefixMsg+("	Unable to optimize: < "+y.toString()+` >
`)+`	Complement Sets cannot be automatically optimized.
	This will disable the lexer's first char optimizations.
	See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#COMPLEMENT for details.`);else{var b="";f&&(b=`
	This will disable the lexer's first char optimizations.
	See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#REGEXP_PARSING for details.`),n.PRINT_ERROR(i.failedOptimizationPrefixMsg+`
`+("	Failed parsing: < "+y.toString()+` >
`)+("	Using the regexp-to-ast library version: "+t.VERSION+`
`)+"	Please open an issue at: https://github.com/bd82/regexp-to-ast/issues"+b)}}return[]}i.getOptimizedStartCodesIndices=a;function c(y,f,p){switch(y.type){case"Disjunction":for(var v=0;v<y.value.length;v++)c(y.value[v],f,p);break;case"Alternative":for(var b=y.value,v=0;v<b.length;v++){var x=b[v];switch(x.type){case"EndAnchor":case"GroupBackReference":case"Lookahead":case"NegativeLookahead":case"StartAnchor":case"WordBoundary":case"NonWordBoundary":continue}var _=x;switch(_.type){case"Character":l(_.value,f,p);break;case"Set":if(_.complement===!0)throw Error(o);n.forEach(_.value,function(A){if(typeof A=="number")l(A,f,p);else{var E=A;if(p===!0)for(var M=E.from;M<=E.to;M++)l(M,f,p);else{for(var M=E.from;M<=E.to&&M<s.minOptimizationVal;M++)l(M,f,p);if(E.to>=s.minOptimizationVal)for(var P=E.from>=s.minOptimizationVal?E.from:s.minOptimizationVal,N=E.to,L=s.charCodeToOptimizedIndex(P),D=s.charCodeToOptimizedIndex(N),$=L;$<=D;$++)f[$]=$}}});break;case"Group":c(_.value,f,p);break;default:throw Error("Non Exhaustive Match")}var T=_.quantifier!==void 0&&_.quantifier.atLeast===0;if(_.type==="Group"&&d(_)===!1||_.type!=="Group"&&T===!1)break}break;default:throw Error("non exhaustive match!")}return n.values(f)}i.firstCharOptimizedIndices=c;function l(y,f,p){var v=s.charCodeToOptimizedIndex(y);f[v]=v,p===!0&&u(y,f)}function u(y,f){var p=String.fromCharCode(y),v=p.toUpperCase();if(v!==p){var b=s.charCodeToOptimizedIndex(v.charCodeAt(0));f[b]=b}else{var x=p.toLowerCase();if(x!==p){var b=s.charCodeToOptimizedIndex(x.charCodeAt(0));f[b]=b}}}function h(y,f){return n.find(y.value,function(p){if(typeof p=="number")return n.contains(f,p);var v=p;return n.find(f,function(b){return v.from<=b&&b<=v.to})!==void 0})}function d(y){return y.quantifier&&y.quantifier.atLeast===0?!0:y.value?n.isArray(y.value)?n.every(y.value,d):d(y.value):!1}var m=(function(y){e(f,y);function f(p){var v=y.call(this)||this;return v.targetCharCodes=p,v.found=!1,v}return f.prototype.visitChildren=function(p){if(this.found!==!0){switch(p.type){case"Lookahead":this.visitLookahead(p);return;case"NegativeLookahead":this.visitNegativeLookahead(p);return}y.prototype.visitChildren.call(this,p)}},f.prototype.visitCharacter=function(p){n.contains(this.targetCharCodes,p.value)&&(this.found=!0)},f.prototype.visitSet=function(p){p.complement?h(p,this.targetCharCodes)===void 0&&(this.found=!0):h(p,this.targetCharCodes)!==void 0&&(this.found=!0)},f})(t.BaseRegExpVisitor);function g(y,f){if(f instanceof RegExp){var p=r.getRegExpAst(f),v=new m(y);return v.visit(p),v.found}else return n.find(f,function(b){return n.contains(y,b.charCodeAt(0))})!==void 0}i.canMatchCharCode=g}),uE=Mt(i=>{"use strict";var e=i&&i.__extends||(function(){var S=function(R,z){return S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(Y,K){Y.__proto__=K}||function(Y,K){for(var re in K)Object.prototype.hasOwnProperty.call(K,re)&&(Y[re]=K[re])},S(R,z)};return function(R,z){if(typeof z!="function"&&z!==null)throw new TypeError("Class extends value "+String(z)+" is not a constructor or null");S(R,z);function Y(){this.constructor=R}R.prototype=z===null?Object.create(z):(Y.prototype=z.prototype,new Y)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.charCodeToOptimizedIndex=i.minOptimizationVal=i.buildLineBreakIssueMessage=i.LineTerminatorOptimizedTester=i.isShortPattern=i.isCustomPattern=i.cloneEmptyGroups=i.performWarningRuntimeChecks=i.performRuntimeChecks=i.addStickyFlag=i.addStartOfInput=i.findUnreachablePatterns=i.findModesThatDoNotExist=i.findInvalidGroupType=i.findDuplicatePatterns=i.findUnsupportedFlags=i.findStartOfInputAnchor=i.findEmptyMatchRegExps=i.findEndOfInputAnchor=i.findInvalidPatterns=i.findMissingPatterns=i.validatePatterns=i.analyzeTokenTypes=i.enableSticky=i.disableSticky=i.SUPPORT_STICKY=i.MODES=i.DEFAULT_MODE=void 0;var t=Oy(),n=Up(),r=Vt(),s=IP(),o=Dy(),a="PATTERN";i.DEFAULT_MODE="defaultMode",i.MODES="modes",i.SUPPORT_STICKY=typeof new RegExp("(?:)").sticky=="boolean";function c(){i.SUPPORT_STICKY=!1}i.disableSticky=c;function l(){i.SUPPORT_STICKY=!0}i.enableSticky=l;function u(S,R){R=r.defaults(R,{useSticky:i.SUPPORT_STICKY,debug:!1,safeMode:!1,positionTracking:"full",lineTerminatorCharacters:["\r",`
`],tracer:function(k,F){return F()}});var z=R.tracer;z("initCharCodeToOptimizedIndexMap",function(){O()});var Y;z("Reject Lexer.NA",function(){Y=r.reject(S,function(k){return k[a]===n.Lexer.NA})});var K=!1,re;z("Transform Patterns",function(){K=!1,re=r.map(Y,function(k){var F=k[a];if(r.isRegExp(F)){var G=F.source;return G.length===1&&G!=="^"&&G!=="$"&&G!=="."&&!F.ignoreCase?G:G.length===2&&G[0]==="\\"&&!r.contains(["d","D","s","S","t","r","n","t","0","c","b","B","f","v","w","W"],G[1])?G[1]:R.useSticky?N(F):P(F)}else{if(r.isFunction(F))return K=!0,{exec:F};if(r.has(F,"exec"))return K=!0,F;if(typeof F=="string"){if(F.length===1)return F;var j=F.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),ee=new RegExp(j);return R.useSticky?N(ee):P(ee)}else throw Error("non exhaustive match")}})});var de,te,ne,H,_e;z("misc mapping",function(){de=r.map(Y,function(k){return k.tokenTypeIdx}),te=r.map(Y,function(k){var F=k.GROUP;if(F!==n.Lexer.SKIPPED){if(r.isString(F))return F;if(r.isUndefined(F))return!1;throw Error("non exhaustive match")}}),ne=r.map(Y,function(k){var F=k.LONGER_ALT;if(F){var G=r.indexOf(Y,F);return G}}),H=r.map(Y,function(k){return k.PUSH_MODE}),_e=r.map(Y,function(k){return r.has(k,"POP_MODE")})});var me;z("Line Terminator Handling",function(){var k=Q(R.lineTerminatorCharacters);me=r.map(Y,function(F){return!1}),R.positionTracking!=="onlyOffset"&&(me=r.map(Y,function(F){if(r.has(F,"LINE_BREAKS"))return F.LINE_BREAKS;if(V(F,k)===!1)return s.canMatchCharCode(k,F.PATTERN)}))});var be,he,Ne,Me;z("Misc Mapping #2",function(){be=r.map(Y,U),he=r.map(re,I),Ne=r.reduce(Y,function(k,F){var G=F.GROUP;return r.isString(G)&&G!==n.Lexer.SKIPPED&&(k[G]=[]),k},{}),Me=r.map(re,function(k,F){return{pattern:re[F],longerAlt:ne[F],canLineTerminator:me[F],isCustom:be[F],short:he[F],group:te[F],push:H[F],pop:_e[F],tokenTypeIdx:de[F],tokenType:Y[F]}})});var Z=!0,B=[];return R.safeMode||z("First Char Optimization",function(){B=r.reduce(Y,function(k,F,G){if(typeof F.PATTERN=="string"){var j=F.PATTERN.charCodeAt(0),ee=ge(j);se(k,ee,Me[G])}else if(r.isArray(F.START_CHARS_HINT)){var ie;r.forEach(F.START_CHARS_HINT,function(fe){var ue=typeof fe=="string"?fe.charCodeAt(0):fe,Ee=ge(ue);ie!==Ee&&(ie=Ee,se(k,Ee,Me[G]))})}else if(r.isRegExp(F.PATTERN))if(F.PATTERN.unicode)Z=!1,R.ensureOptimizations&&r.PRINT_ERROR(""+s.failedOptimizationPrefixMsg+("	Unable to analyze < "+F.PATTERN.toString()+` > pattern.
`)+`	The regexp unicode flag is not currently supported by the regexp-to-ast library.
	This will disable the lexer's first char optimizations.
	For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNICODE_OPTIMIZE`);else{var ce=s.getOptimizedStartCodesIndices(F.PATTERN,R.ensureOptimizations);r.isEmpty(ce)&&(Z=!1),r.forEach(ce,function(fe){se(k,fe,Me[G])})}else R.ensureOptimizations&&r.PRINT_ERROR(""+s.failedOptimizationPrefixMsg+("	TokenType: <"+F.name+`> is using a custom token pattern without providing <start_chars_hint> parameter.
`)+`	This will disable the lexer's first char optimizations.
	For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_OPTIMIZE`),Z=!1;return k},[])}),z("ArrayPacking",function(){B=r.packArray(B)}),{emptyGroups:Ne,patternIdxToConfig:Me,charCodeToPatternIdxToConfig:B,hasCustom:K,canBeOptimized:Z}}i.analyzeTokenTypes=u;function h(S,R){var z=[],Y=m(S);z=z.concat(Y.errors);var K=g(Y.valid),re=K.valid;return z=z.concat(K.errors),z=z.concat(d(re)),z=z.concat(T(re)),z=z.concat(w(re,R)),z=z.concat(A(re)),z}i.validatePatterns=h;function d(S){var R=[],z=r.filter(S,function(Y){return r.isRegExp(Y[a])});return R=R.concat(f(z)),R=R.concat(b(z)),R=R.concat(x(z)),R=R.concat(_(z)),R=R.concat(p(z)),R}function m(S){var R=r.filter(S,function(K){return!r.has(K,a)}),z=r.map(R,function(K){return{message:"Token Type: ->"+K.name+"<- missing static 'PATTERN' property",type:n.LexerDefinitionErrorType.MISSING_PATTERN,tokenTypes:[K]}}),Y=r.difference(S,R);return{errors:z,valid:Y}}i.findMissingPatterns=m;function g(S){var R=r.filter(S,function(K){var re=K[a];return!r.isRegExp(re)&&!r.isFunction(re)&&!r.has(re,"exec")&&!r.isString(re)}),z=r.map(R,function(K){return{message:"Token Type: ->"+K.name+"<- static 'PATTERN' can only be a RegExp, a Function matching the {CustomPatternMatcherFunc} type or an Object matching the {ICustomPattern} interface.",type:n.LexerDefinitionErrorType.INVALID_PATTERN,tokenTypes:[K]}}),Y=r.difference(S,R);return{errors:z,valid:Y}}i.findInvalidPatterns=g;var y=/[^\\][\$]/;function f(S){var R=(function(K){e(re,K);function re(){var de=K!==null&&K.apply(this,arguments)||this;return de.found=!1,de}return re.prototype.visitEndAnchor=function(de){this.found=!0},re})(t.BaseRegExpVisitor),z=r.filter(S,function(K){var re=K[a];try{var de=o.getRegExpAst(re),te=new R;return te.visit(de),te.found}catch{return y.test(re.source)}}),Y=r.map(z,function(K){return{message:`Unexpected RegExp Anchor Error:
	Token Type: ->`+K.name+`<- static 'PATTERN' cannot contain end of input anchor '$'
	See chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS	for details.`,type:n.LexerDefinitionErrorType.EOI_ANCHOR_FOUND,tokenTypes:[K]}});return Y}i.findEndOfInputAnchor=f;function p(S){var R=r.filter(S,function(Y){var K=Y[a];return K.test("")}),z=r.map(R,function(Y){return{message:"Token Type: ->"+Y.name+"<- static 'PATTERN' must not match an empty string",type:n.LexerDefinitionErrorType.EMPTY_MATCH_PATTERN,tokenTypes:[Y]}});return z}i.findEmptyMatchRegExps=p;var v=/[^\\[][\^]|^\^/;function b(S){var R=(function(K){e(re,K);function re(){var de=K!==null&&K.apply(this,arguments)||this;return de.found=!1,de}return re.prototype.visitStartAnchor=function(de){this.found=!0},re})(t.BaseRegExpVisitor),z=r.filter(S,function(K){var re=K[a];try{var de=o.getRegExpAst(re),te=new R;return te.visit(de),te.found}catch{return v.test(re.source)}}),Y=r.map(z,function(K){return{message:`Unexpected RegExp Anchor Error:
	Token Type: ->`+K.name+`<- static 'PATTERN' cannot contain start of input anchor '^'
	See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#ANCHORS	for details.`,type:n.LexerDefinitionErrorType.SOI_ANCHOR_FOUND,tokenTypes:[K]}});return Y}i.findStartOfInputAnchor=b;function x(S){var R=r.filter(S,function(Y){var K=Y[a];return K instanceof RegExp&&(K.multiline||K.global)}),z=r.map(R,function(Y){return{message:"Token Type: ->"+Y.name+"<- static 'PATTERN' may NOT contain global('g') or multiline('m')",type:n.LexerDefinitionErrorType.UNSUPPORTED_FLAGS_FOUND,tokenTypes:[Y]}});return z}i.findUnsupportedFlags=x;function _(S){var R=[],z=r.map(S,function(re){return r.reduce(S,function(de,te){return re.PATTERN.source===te.PATTERN.source&&!r.contains(R,te)&&te.PATTERN!==n.Lexer.NA&&(R.push(te),de.push(te)),de},[])});z=r.compact(z);var Y=r.filter(z,function(re){return re.length>1}),K=r.map(Y,function(re){var de=r.map(re,function(ne){return ne.name}),te=r.first(re).PATTERN;return{message:"The same RegExp pattern ->"+te+"<-"+("has been used in all of the following Token Types: "+de.join(", ")+" <-"),type:n.LexerDefinitionErrorType.DUPLICATE_PATTERNS_FOUND,tokenTypes:re}});return K}i.findDuplicatePatterns=_;function T(S){var R=r.filter(S,function(Y){if(!r.has(Y,"GROUP"))return!1;var K=Y.GROUP;return K!==n.Lexer.SKIPPED&&K!==n.Lexer.NA&&!r.isString(K)}),z=r.map(R,function(Y){return{message:"Token Type: ->"+Y.name+"<- static 'GROUP' can only be Lexer.SKIPPED/Lexer.NA/A String",type:n.LexerDefinitionErrorType.INVALID_GROUP_TYPE_FOUND,tokenTypes:[Y]}});return z}i.findInvalidGroupType=T;function w(S,R){var z=r.filter(S,function(K){return K.PUSH_MODE!==void 0&&!r.contains(R,K.PUSH_MODE)}),Y=r.map(z,function(K){var re="Token Type: ->"+K.name+"<- static 'PUSH_MODE' value cannot refer to a Lexer Mode ->"+K.PUSH_MODE+"<-which does not exist";return{message:re,type:n.LexerDefinitionErrorType.PUSH_MODE_DOES_NOT_EXIST,tokenTypes:[K]}});return Y}i.findModesThatDoNotExist=w;function A(S){var R=[],z=r.reduce(S,function(Y,K,re){var de=K.PATTERN;return de===n.Lexer.NA||(r.isString(de)?Y.push({str:de,idx:re,tokenType:K}):r.isRegExp(de)&&M(de)&&Y.push({str:de.source,idx:re,tokenType:K})),Y},[]);return r.forEach(S,function(Y,K){r.forEach(z,function(re){var de=re.str,te=re.idx,ne=re.tokenType;if(K<te&&E(de,Y.PATTERN)){var H="Token: ->"+ne.name+`<- can never be matched.
`+("Because it appears AFTER the Token Type ->"+Y.name+"<-")+`in the lexer's definition.
See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#UNREACHABLE`;R.push({message:H,type:n.LexerDefinitionErrorType.UNREACHABLE_PATTERN,tokenTypes:[Y,ne]})}})}),R}i.findUnreachablePatterns=A;function E(S,R){if(r.isRegExp(R)){var z=R.exec(S);return z!==null&&z.index===0}else{if(r.isFunction(R))return R(S,0,[],{});if(r.has(R,"exec"))return R.exec(S,0,[],{});if(typeof R=="string")return R===S;throw Error("non exhaustive match")}}function M(S){var R=[".","\\","[","]","|","^","$","(",")","?","*","+","{"];return r.find(R,function(z){return S.source.indexOf(z)!==-1})===void 0}function P(S){var R=S.ignoreCase?"i":"";return new RegExp("^(?:"+S.source+")",R)}i.addStartOfInput=P;function N(S){var R=S.ignoreCase?"iy":"y";return new RegExp(""+S.source,R)}i.addStickyFlag=N;function L(S,R,z){var Y=[];return r.has(S,i.DEFAULT_MODE)||Y.push({message:"A MultiMode Lexer cannot be initialized without a <"+i.DEFAULT_MODE+`> property in its definition
`,type:n.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE}),r.has(S,i.MODES)||Y.push({message:"A MultiMode Lexer cannot be initialized without a <"+i.MODES+`> property in its definition
`,type:n.LexerDefinitionErrorType.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY}),r.has(S,i.MODES)&&r.has(S,i.DEFAULT_MODE)&&!r.has(S.modes,S.defaultMode)&&Y.push({message:"A MultiMode Lexer cannot be initialized with a "+i.DEFAULT_MODE+": <"+S.defaultMode+`>which does not exist
`,type:n.LexerDefinitionErrorType.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST}),r.has(S,i.MODES)&&r.forEach(S.modes,function(K,re){r.forEach(K,function(de,te){r.isUndefined(de)&&Y.push({message:"A Lexer cannot be initialized using an undefined Token Type. Mode:"+("<"+re+"> at index: <"+te+`>
`),type:n.LexerDefinitionErrorType.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED})})}),Y}i.performRuntimeChecks=L;function D(S,R,z){var Y=[],K=!1,re=r.compact(r.flatten(r.mapValues(S.modes,function(ne){return ne}))),de=r.reject(re,function(ne){return ne[a]===n.Lexer.NA}),te=Q(z);return R&&r.forEach(de,function(ne){var H=V(ne,te);if(H!==!1){var _e=W(ne,H),me={message:_e,type:H.issue,tokenType:ne};Y.push(me)}else r.has(ne,"LINE_BREAKS")?ne.LINE_BREAKS===!0&&(K=!0):s.canMatchCharCode(te,ne.PATTERN)&&(K=!0)}),R&&!K&&Y.push({message:`Warning: No LINE_BREAKS Found.
	This Lexer has been defined to track line and column information,
	But none of the Token Types can be identified as matching a line terminator.
	See https://chevrotain.io/docs/guide/resolving_lexer_errors.html#LINE_BREAKS
	for details.`,type:n.LexerDefinitionErrorType.NO_LINE_BREAKS_FLAGS}),Y}i.performWarningRuntimeChecks=D;function $(S){var R={},z=r.keys(S);return r.forEach(z,function(Y){var K=S[Y];if(r.isArray(K))R[Y]=[];else throw Error("non exhaustive match")}),R}i.cloneEmptyGroups=$;function U(S){var R=S.PATTERN;if(r.isRegExp(R))return!1;if(r.isFunction(R)||r.has(R,"exec"))return!0;if(r.isString(R))return!1;throw Error("non exhaustive match")}i.isCustomPattern=U;function I(S){return r.isString(S)&&S.length===1?S.charCodeAt(0):!1}i.isShortPattern=I,i.LineTerminatorOptimizedTester={test:function(S){for(var R=S.length,z=this.lastIndex;z<R;z++){var Y=S.charCodeAt(z);if(Y===10)return this.lastIndex=z+1,!0;if(Y===13)return S.charCodeAt(z+1)===10?this.lastIndex=z+2:this.lastIndex=z+1,!0}return!1},lastIndex:0};function V(S,R){if(r.has(S,"LINE_BREAKS"))return!1;if(r.isRegExp(S.PATTERN)){try{s.canMatchCharCode(R,S.PATTERN)}catch(z){return{issue:n.LexerDefinitionErrorType.IDENTIFY_TERMINATOR,errMsg:z.message}}return!1}else{if(r.isString(S.PATTERN))return!1;if(U(S))return{issue:n.LexerDefinitionErrorType.CUSTOM_LINE_BREAK};throw Error("non exhaustive match")}}function W(S,R){if(R.issue===n.LexerDefinitionErrorType.IDENTIFY_TERMINATOR)return`Warning: unable to identify line terminator usage in pattern.
`+("	The problem is in the <"+S.name+`> Token Type
`)+("	 Root cause: "+R.errMsg+`.
`)+"	For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#IDENTIFY_TERMINATOR";if(R.issue===n.LexerDefinitionErrorType.CUSTOM_LINE_BREAK)return`Warning: A Custom Token Pattern should specify the <line_breaks> option.
`+("	The problem is in the <"+S.name+`> Token Type
`)+"	For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#CUSTOM_LINE_BREAK";throw Error("non exhaustive match")}i.buildLineBreakIssueMessage=W;function Q(S){var R=r.map(S,function(z){return r.isString(z)&&z.length>0?z.charCodeAt(0):z});return R}function se(S,R,z){S[R]===void 0?S[R]=[z]:S[R].push(z)}i.minOptimizationVal=256;var oe=[];function ge(S){return S<i.minOptimizationVal?S:oe[S]}i.charCodeToOptimizedIndex=ge;function O(){if(r.isEmpty(oe)){oe=new Array(65536);for(var S=0;S<65536;S++)oe[S]=S>255?255+~~(S/255):S}}}),Ah=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.isTokenType=i.hasExtendingTokensTypesMapProperty=i.hasExtendingTokensTypesProperty=i.hasCategoriesProperty=i.hasShortKeyProperty=i.singleAssignCategoriesToksMap=i.assignCategoriesMapProp=i.assignCategoriesTokensProp=i.assignTokenDefaultProps=i.expandCategories=i.augmentTokenTypes=i.tokenIdxToClass=i.tokenShortNameIdx=i.tokenStructuredMatcherNoCategories=i.tokenStructuredMatcher=void 0;var e=Vt();function t(y,f){var p=y.tokenTypeIdx;return p===f.tokenTypeIdx?!0:f.isParent===!0&&f.categoryMatchesMap[p]===!0}i.tokenStructuredMatcher=t;function n(y,f){return y.tokenTypeIdx===f.tokenTypeIdx}i.tokenStructuredMatcherNoCategories=n,i.tokenShortNameIdx=1,i.tokenIdxToClass={};function r(y){var f=s(y);o(f),c(f),a(f),e.forEach(f,function(p){p.isParent=p.categoryMatches.length>0})}i.augmentTokenTypes=r;function s(y){for(var f=e.cloneArr(y),p=y,v=!0;v;){p=e.compact(e.flatten(e.map(p,function(x){return x.CATEGORIES})));var b=e.difference(p,f);f=f.concat(b),e.isEmpty(b)?v=!1:p=b}return f}i.expandCategories=s;function o(y){e.forEach(y,function(f){u(f)||(i.tokenIdxToClass[i.tokenShortNameIdx]=f,f.tokenTypeIdx=i.tokenShortNameIdx++),h(f)&&!e.isArray(f.CATEGORIES)&&(f.CATEGORIES=[f.CATEGORIES]),h(f)||(f.CATEGORIES=[]),d(f)||(f.categoryMatches=[]),m(f)||(f.categoryMatchesMap={})})}i.assignTokenDefaultProps=o;function a(y){e.forEach(y,function(f){f.categoryMatches=[],e.forEach(f.categoryMatchesMap,function(p,v){f.categoryMatches.push(i.tokenIdxToClass[v].tokenTypeIdx)})})}i.assignCategoriesTokensProp=a;function c(y){e.forEach(y,function(f){l([],f)})}i.assignCategoriesMapProp=c;function l(y,f){e.forEach(y,function(p){f.categoryMatchesMap[p.tokenTypeIdx]=!0}),e.forEach(f.CATEGORIES,function(p){var v=y.concat(f);e.contains(v,p)||l(v,p)})}i.singleAssignCategoriesToksMap=l;function u(y){return e.has(y,"tokenTypeIdx")}i.hasShortKeyProperty=u;function h(y){return e.has(y,"CATEGORIES")}i.hasCategoriesProperty=h;function d(y){return e.has(y,"categoryMatches")}i.hasExtendingTokensTypesProperty=d;function m(y){return e.has(y,"categoryMatchesMap")}i.hasExtendingTokensTypesMapProperty=m;function g(y){return e.has(y,"tokenTypeIdx")}i.isTokenType=g}),hE=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.defaultLexerErrorProvider=void 0,i.defaultLexerErrorProvider={buildUnableToPopLexerModeMessage:function(e){return"Unable to pop Lexer Mode after encountering Token ->"+e.image+"<- The Mode Stack is empty"},buildUnexpectedCharactersMessage:function(e,t,n,r,s){return"unexpected character: ->"+e.charAt(t)+"<- at offset: "+t+","+(" skipped "+n+" characters.")}}}),Up=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Lexer=i.LexerDefinitionErrorType=void 0;var e=uE(),t=Vt(),n=Ah(),r=hE(),s=Dy(),o;(function(l){l[l.MISSING_PATTERN=0]="MISSING_PATTERN",l[l.INVALID_PATTERN=1]="INVALID_PATTERN",l[l.EOI_ANCHOR_FOUND=2]="EOI_ANCHOR_FOUND",l[l.UNSUPPORTED_FLAGS_FOUND=3]="UNSUPPORTED_FLAGS_FOUND",l[l.DUPLICATE_PATTERNS_FOUND=4]="DUPLICATE_PATTERNS_FOUND",l[l.INVALID_GROUP_TYPE_FOUND=5]="INVALID_GROUP_TYPE_FOUND",l[l.PUSH_MODE_DOES_NOT_EXIST=6]="PUSH_MODE_DOES_NOT_EXIST",l[l.MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE=7]="MULTI_MODE_LEXER_WITHOUT_DEFAULT_MODE",l[l.MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY=8]="MULTI_MODE_LEXER_WITHOUT_MODES_PROPERTY",l[l.MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST=9]="MULTI_MODE_LEXER_DEFAULT_MODE_VALUE_DOES_NOT_EXIST",l[l.LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED=10]="LEXER_DEFINITION_CANNOT_CONTAIN_UNDEFINED",l[l.SOI_ANCHOR_FOUND=11]="SOI_ANCHOR_FOUND",l[l.EMPTY_MATCH_PATTERN=12]="EMPTY_MATCH_PATTERN",l[l.NO_LINE_BREAKS_FLAGS=13]="NO_LINE_BREAKS_FLAGS",l[l.UNREACHABLE_PATTERN=14]="UNREACHABLE_PATTERN",l[l.IDENTIFY_TERMINATOR=15]="IDENTIFY_TERMINATOR",l[l.CUSTOM_LINE_BREAK=16]="CUSTOM_LINE_BREAK"})(o=i.LexerDefinitionErrorType||(i.LexerDefinitionErrorType={}));var a={deferDefinitionErrorsHandling:!1,positionTracking:"full",lineTerminatorsPattern:/\n|\r\n?/g,lineTerminatorCharacters:[`
`,"\r"],ensureOptimizations:!1,safeMode:!1,errorMessageProvider:r.defaultLexerErrorProvider,traceInitPerf:!1,skipValidations:!1};Object.freeze(a);var c=(function(){function l(u,h){var d=this;if(h===void 0&&(h=a),this.lexerDefinition=u,this.lexerDefinitionErrors=[],this.lexerDefinitionWarning=[],this.patternIdxToConfig={},this.charCodeToPatternIdxToConfig={},this.modes=[],this.emptyGroups={},this.config=void 0,this.trackStartLines=!0,this.trackEndLines=!0,this.hasCustom=!1,this.canModeBeOptimized={},typeof h=="boolean")throw Error(`The second argument to the Lexer constructor is now an ILexerConfig Object.
a boolean 2nd argument is no longer supported`);this.config=t.merge(a,h);var m=this.config.traceInitPerf;m===!0?(this.traceInitMaxIdent=1/0,this.traceInitPerf=!0):typeof m=="number"&&(this.traceInitMaxIdent=m,this.traceInitPerf=!0),this.traceInitIndent=-1,this.TRACE_INIT("Lexer Constructor",function(){var g,y=!0;d.TRACE_INIT("Lexer Config handling",function(){if(d.config.lineTerminatorsPattern===a.lineTerminatorsPattern)d.config.lineTerminatorsPattern=e.LineTerminatorOptimizedTester;else if(d.config.lineTerminatorCharacters===a.lineTerminatorCharacters)throw Error(`Error: Missing <lineTerminatorCharacters> property on the Lexer config.
	For details See: https://chevrotain.io/docs/guide/resolving_lexer_errors.html#MISSING_LINE_TERM_CHARS`);if(h.safeMode&&h.ensureOptimizations)throw Error('"safeMode" and "ensureOptimizations" flags are mutually exclusive.');d.trackStartLines=/full|onlyStart/i.test(d.config.positionTracking),d.trackEndLines=/full/i.test(d.config.positionTracking),t.isArray(u)?(g={modes:{}},g.modes[e.DEFAULT_MODE]=t.cloneArr(u),g[e.DEFAULT_MODE]=e.DEFAULT_MODE):(y=!1,g=t.cloneObj(u))}),d.config.skipValidations===!1&&(d.TRACE_INIT("performRuntimeChecks",function(){d.lexerDefinitionErrors=d.lexerDefinitionErrors.concat(e.performRuntimeChecks(g,d.trackStartLines,d.config.lineTerminatorCharacters))}),d.TRACE_INIT("performWarningRuntimeChecks",function(){d.lexerDefinitionWarning=d.lexerDefinitionWarning.concat(e.performWarningRuntimeChecks(g,d.trackStartLines,d.config.lineTerminatorCharacters))})),g.modes=g.modes?g.modes:{},t.forEach(g.modes,function(b,x){g.modes[x]=t.reject(b,function(_){return t.isUndefined(_)})});var f=t.keys(g.modes);if(t.forEach(g.modes,function(b,x){d.TRACE_INIT("Mode: <"+x+"> processing",function(){if(d.modes.push(x),d.config.skipValidations===!1&&d.TRACE_INIT("validatePatterns",function(){d.lexerDefinitionErrors=d.lexerDefinitionErrors.concat(e.validatePatterns(b,f))}),t.isEmpty(d.lexerDefinitionErrors)){n.augmentTokenTypes(b);var _;d.TRACE_INIT("analyzeTokenTypes",function(){_=e.analyzeTokenTypes(b,{lineTerminatorCharacters:d.config.lineTerminatorCharacters,positionTracking:h.positionTracking,ensureOptimizations:h.ensureOptimizations,safeMode:h.safeMode,tracer:d.TRACE_INIT.bind(d)})}),d.patternIdxToConfig[x]=_.patternIdxToConfig,d.charCodeToPatternIdxToConfig[x]=_.charCodeToPatternIdxToConfig,d.emptyGroups=t.merge(d.emptyGroups,_.emptyGroups),d.hasCustom=_.hasCustom||d.hasCustom,d.canModeBeOptimized[x]=_.canBeOptimized}})}),d.defaultMode=g.defaultMode,!t.isEmpty(d.lexerDefinitionErrors)&&!d.config.deferDefinitionErrorsHandling){var p=t.map(d.lexerDefinitionErrors,function(b){return b.message}),v=p.join(`-----------------------
`);throw new Error(`Errors detected in definition of Lexer:
`+v)}t.forEach(d.lexerDefinitionWarning,function(b){t.PRINT_WARNING(b.message)}),d.TRACE_INIT("Choosing sub-methods implementations",function(){if(e.SUPPORT_STICKY?(d.chopInput=t.IDENTITY,d.match=d.matchWithTest):(d.updateLastIndex=t.NOOP,d.match=d.matchWithExec),y&&(d.handleModes=t.NOOP),d.trackStartLines===!1&&(d.computeNewColumn=t.IDENTITY),d.trackEndLines===!1&&(d.updateTokenEndLineColumnLocation=t.NOOP),/full/i.test(d.config.positionTracking))d.createTokenInstance=d.createFullToken;else if(/onlyStart/i.test(d.config.positionTracking))d.createTokenInstance=d.createStartOnlyToken;else if(/onlyOffset/i.test(d.config.positionTracking))d.createTokenInstance=d.createOffsetOnlyToken;else throw Error('Invalid <positionTracking> config option: "'+d.config.positionTracking+'"');d.hasCustom?(d.addToken=d.addTokenUsingPush,d.handlePayload=d.handlePayloadWithCustom):(d.addToken=d.addTokenUsingMemberAccess,d.handlePayload=d.handlePayloadNoCustom)}),d.TRACE_INIT("Failed Optimization Warnings",function(){var b=t.reduce(d.canModeBeOptimized,function(x,_,T){return _===!1&&x.push(T),x},[]);if(h.ensureOptimizations&&!t.isEmpty(b))throw Error("Lexer Modes: < "+b.join(", ")+` > cannot be optimized.
	 Disable the "ensureOptimizations" lexer config flag to silently ignore this and run the lexer in an un-optimized mode.
	 Or inspect the console log for details on how to resolve these issues.`)}),d.TRACE_INIT("clearRegExpParserCache",function(){s.clearRegExpParserCache()}),d.TRACE_INIT("toFastProperties",function(){t.toFastProperties(d)})})}return l.prototype.tokenize=function(u,h){if(h===void 0&&(h=this.defaultMode),!t.isEmpty(this.lexerDefinitionErrors)){var d=t.map(this.lexerDefinitionErrors,function(y){return y.message}),m=d.join(`-----------------------
`);throw new Error(`Unable to Tokenize because Errors detected in definition of Lexer:
`+m)}var g=this.tokenizeInternal(u,h);return g},l.prototype.tokenizeInternal=function(u,h){var d=this,m,g,y,f,p,v,b,x,_,T,w,A,E,M,P,N=u,L=N.length,D=0,$=0,U=this.hasCustom?0:Math.floor(u.length/10),I=new Array(U),V=[],W=this.trackStartLines?1:void 0,Q=this.trackStartLines?1:void 0,se=e.cloneEmptyGroups(this.emptyGroups),oe=this.trackStartLines,ge=this.config.lineTerminatorsPattern,O=0,S=[],R=[],z=[],Y=[];Object.freeze(Y);var K=void 0;function re(){return S}function de(fe){var ue=e.charCodeToOptimizedIndex(fe),Ee=R[ue];return Ee===void 0?Y:Ee}var te=function(fe){if(z.length===1&&fe.tokenType.PUSH_MODE===void 0){var ue=d.config.errorMessageProvider.buildUnableToPopLexerModeMessage(fe);V.push({offset:fe.startOffset,line:fe.startLine!==void 0?fe.startLine:void 0,column:fe.startColumn!==void 0?fe.startColumn:void 0,length:fe.image.length,message:ue})}else{z.pop();var Ee=t.last(z);S=d.patternIdxToConfig[Ee],R=d.charCodeToPatternIdxToConfig[Ee],O=S.length;var Se=d.canModeBeOptimized[Ee]&&d.config.safeMode===!1;R&&Se?K=de:K=re}};function ne(fe){z.push(fe),R=this.charCodeToPatternIdxToConfig[fe],S=this.patternIdxToConfig[fe],O=S.length,O=S.length;var ue=this.canModeBeOptimized[fe]&&this.config.safeMode===!1;R&&ue?K=de:K=re}ne.call(this,h);for(var H;D<L;){p=null;var _e=N.charCodeAt(D),me=K(_e),be=me.length;for(m=0;m<be;m++){H=me[m];var he=H.pattern;v=null;var Ne=H.short;if(Ne!==!1?_e===Ne&&(p=he):H.isCustom===!0?(P=he.exec(N,D,I,se),P!==null?(p=P[0],P.payload!==void 0&&(v=P.payload)):p=null):(this.updateLastIndex(he,D),p=this.match(he,u,D)),p!==null){if(f=H.longerAlt,f!==void 0){var Me=S[f],Z=Me.pattern;b=null,Me.isCustom===!0?(P=Z.exec(N,D,I,se),P!==null?(y=P[0],P.payload!==void 0&&(b=P.payload)):y=null):(this.updateLastIndex(Z,D),y=this.match(Z,u,D)),y&&y.length>p.length&&(p=y,v=b,H=Me)}break}}if(p!==null){if(x=p.length,_=H.group,_!==void 0&&(T=H.tokenTypeIdx,w=this.createTokenInstance(p,D,T,H.tokenType,W,Q,x),this.handlePayload(w,v),_===!1?$=this.addToken(I,$,w):se[_].push(w)),u=this.chopInput(u,x),D=D+x,Q=this.computeNewColumn(Q,x),oe===!0&&H.canLineTerminator===!0){var B=0,k=void 0,F=void 0;ge.lastIndex=0;do k=ge.test(p),k===!0&&(F=ge.lastIndex-1,B++);while(k===!0);B!==0&&(W=W+B,Q=x-F,this.updateTokenEndLineColumnLocation(w,_,F,B,W,Q,x))}this.handleModes(H,te,ne,w)}else{for(var G=D,j=W,ee=Q,ie=!1;!ie&&D<L;)for(E=N.charCodeAt(D),u=this.chopInput(u,1),D++,g=0;g<O;g++){var ce=S[g],he=ce.pattern,Ne=ce.short;if(Ne!==!1?N.charCodeAt(D)===Ne&&(ie=!0):ce.isCustom===!0?ie=he.exec(N,D,I,se)!==null:(this.updateLastIndex(he,D),ie=he.exec(u)!==null),ie===!0)break}A=D-G,M=this.config.errorMessageProvider.buildUnexpectedCharactersMessage(N,G,A,j,ee),V.push({offset:G,line:j,column:ee,length:A,message:M})}}return this.hasCustom||(I.length=$),{tokens:I,groups:se,errors:V}},l.prototype.handleModes=function(u,h,d,m){if(u.pop===!0){var g=u.push;h(m),g!==void 0&&d.call(this,g)}else u.push!==void 0&&d.call(this,u.push)},l.prototype.chopInput=function(u,h){return u.substring(h)},l.prototype.updateLastIndex=function(u,h){u.lastIndex=h},l.prototype.updateTokenEndLineColumnLocation=function(u,h,d,m,g,y,f){var p,v;h!==void 0&&(p=d===f-1,v=p?-1:0,m===1&&p===!0||(u.endLine=g+v,u.endColumn=y-1+-v))},l.prototype.computeNewColumn=function(u,h){return u+h},l.prototype.createTokenInstance=function(){for(var u=[],h=0;h<arguments.length;h++)u[h]=arguments[h];return null},l.prototype.createOffsetOnlyToken=function(u,h,d,m){return{image:u,startOffset:h,tokenTypeIdx:d,tokenType:m}},l.prototype.createStartOnlyToken=function(u,h,d,m,g,y){return{image:u,startOffset:h,startLine:g,startColumn:y,tokenTypeIdx:d,tokenType:m}},l.prototype.createFullToken=function(u,h,d,m,g,y,f){return{image:u,startOffset:h,endOffset:h+f-1,startLine:g,endLine:g,startColumn:y,endColumn:y+f-1,tokenTypeIdx:d,tokenType:m}},l.prototype.addToken=function(u,h,d){return 666},l.prototype.addTokenUsingPush=function(u,h,d){return u.push(d),h},l.prototype.addTokenUsingMemberAccess=function(u,h,d){return u[h]=d,h++,h},l.prototype.handlePayload=function(u,h){},l.prototype.handlePayloadNoCustom=function(u,h){},l.prototype.handlePayloadWithCustom=function(u,h){h!==null&&(u.payload=h)},l.prototype.match=function(u,h,d){return null},l.prototype.matchWithTest=function(u,h,d){var m=u.test(h);return m===!0?h.substring(d,u.lastIndex):null},l.prototype.matchWithExec=function(u,h){var d=u.exec(h);return d!==null?d[0]:d},l.prototype.TRACE_INIT=function(u,h){if(this.traceInitPerf===!0){this.traceInitIndent++;var d=new Array(this.traceInitIndent+1).join("	");this.traceInitIndent<this.traceInitMaxIdent&&console.log(d+"--> <"+u+">");var m=t.timer(h),g=m.time,y=m.value,f=g>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&f(d+"<-- <"+u+"> time: "+g+"ms"),this.traceInitIndent--,y}else return h()},l.SKIPPED="This marks a skipped Token pattern, this means each token identified by it willbe consumed and then thrown into oblivion, this can be used to for example to completely ignore whitespace.",l.NA=/NOT_APPLICABLE/,l})();i.Lexer=c}),aa=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.tokenMatcher=i.createTokenInstance=i.EOF=i.createToken=i.hasTokenLabel=i.tokenName=i.tokenLabel=void 0;var e=Vt(),t=Up(),n=Ah();function r(x){return o(x)?x.LABEL:x.name}i.tokenLabel=r;function s(x){return x.name}i.tokenName=s;function o(x){return e.isString(x.LABEL)&&x.LABEL!==""}i.hasTokenLabel=o;var a="parent",c="categories",l="label",u="group",h="push_mode",d="pop_mode",m="longer_alt",g="line_breaks",y="start_chars_hint";function f(x){return p(x)}i.createToken=f;function p(x){var _=x.pattern,T={};if(T.name=x.name,e.isUndefined(_)||(T.PATTERN=_),e.has(x,a))throw`The parent property is no longer supported.
See: https://github.com/chevrotain/chevrotain/issues/564#issuecomment-349062346 for details.`;return e.has(x,c)&&(T.CATEGORIES=x[c]),n.augmentTokenTypes([T]),e.has(x,l)&&(T.LABEL=x[l]),e.has(x,u)&&(T.GROUP=x[u]),e.has(x,d)&&(T.POP_MODE=x[d]),e.has(x,h)&&(T.PUSH_MODE=x[h]),e.has(x,m)&&(T.LONGER_ALT=x[m]),e.has(x,g)&&(T.LINE_BREAKS=x[g]),e.has(x,y)&&(T.START_CHARS_HINT=x[y]),T}i.EOF=f({name:"EOF",pattern:t.Lexer.NA}),n.augmentTokenTypes([i.EOF]);function v(x,_,T,w,A,E,M,P){return{image:_,startOffset:T,endOffset:w,startLine:A,endLine:E,startColumn:M,endColumn:P,tokenTypeIdx:x.tokenTypeIdx,tokenType:x}}i.createTokenInstance=v;function b(x,_){return n.tokenStructuredMatcher(x,_)}i.tokenMatcher=b}),Bi=Mt(i=>{"use strict";var e=i&&i.__extends||(function(){var p=function(v,b){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,_){x.__proto__=_}||function(x,_){for(var T in _)Object.prototype.hasOwnProperty.call(_,T)&&(x[T]=_[T])},p(v,b)};return function(v,b){if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");p(v,b);function x(){this.constructor=v}v.prototype=b===null?Object.create(b):(x.prototype=b.prototype,new x)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.serializeProduction=i.serializeGrammar=i.Terminal=i.Alternation=i.RepetitionWithSeparator=i.Repetition=i.RepetitionMandatoryWithSeparator=i.RepetitionMandatory=i.Option=i.Alternative=i.Rule=i.NonTerminal=i.AbstractProduction=void 0;var t=Vt(),n=aa(),r=(function(){function p(v){this._definition=v}return Object.defineProperty(p.prototype,"definition",{get:function(){return this._definition},set:function(v){this._definition=v},enumerable:!1,configurable:!0}),p.prototype.accept=function(v){v.visit(this),t.forEach(this.definition,function(b){b.accept(v)})},p})();i.AbstractProduction=r;var s=(function(p){e(v,p);function v(b){var x=p.call(this,[])||this;return x.idx=1,t.assign(x,t.pick(b,function(_){return _!==void 0})),x}return Object.defineProperty(v.prototype,"definition",{get:function(){return this.referencedRule!==void 0?this.referencedRule.definition:[]},set:function(b){},enumerable:!1,configurable:!0}),v.prototype.accept=function(b){b.visit(this)},v})(r);i.NonTerminal=s;var o=(function(p){e(v,p);function v(b){var x=p.call(this,b.definition)||this;return x.orgText="",t.assign(x,t.pick(b,function(_){return _!==void 0})),x}return v})(r);i.Rule=o;var a=(function(p){e(v,p);function v(b){var x=p.call(this,b.definition)||this;return x.ignoreAmbiguities=!1,t.assign(x,t.pick(b,function(_){return _!==void 0})),x}return v})(r);i.Alternative=a;var c=(function(p){e(v,p);function v(b){var x=p.call(this,b.definition)||this;return x.idx=1,t.assign(x,t.pick(b,function(_){return _!==void 0})),x}return v})(r);i.Option=c;var l=(function(p){e(v,p);function v(b){var x=p.call(this,b.definition)||this;return x.idx=1,t.assign(x,t.pick(b,function(_){return _!==void 0})),x}return v})(r);i.RepetitionMandatory=l;var u=(function(p){e(v,p);function v(b){var x=p.call(this,b.definition)||this;return x.idx=1,t.assign(x,t.pick(b,function(_){return _!==void 0})),x}return v})(r);i.RepetitionMandatoryWithSeparator=u;var h=(function(p){e(v,p);function v(b){var x=p.call(this,b.definition)||this;return x.idx=1,t.assign(x,t.pick(b,function(_){return _!==void 0})),x}return v})(r);i.Repetition=h;var d=(function(p){e(v,p);function v(b){var x=p.call(this,b.definition)||this;return x.idx=1,t.assign(x,t.pick(b,function(_){return _!==void 0})),x}return v})(r);i.RepetitionWithSeparator=d;var m=(function(p){e(v,p);function v(b){var x=p.call(this,b.definition)||this;return x.idx=1,x.ignoreAmbiguities=!1,x.hasPredicates=!1,t.assign(x,t.pick(b,function(_){return _!==void 0})),x}return Object.defineProperty(v.prototype,"definition",{get:function(){return this._definition},set:function(b){this._definition=b},enumerable:!1,configurable:!0}),v})(r);i.Alternation=m;var g=(function(){function p(v){this.idx=1,t.assign(this,t.pick(v,function(b){return b!==void 0}))}return p.prototype.accept=function(v){v.visit(this)},p})();i.Terminal=g;function y(p){return t.map(p,f)}i.serializeGrammar=y;function f(p){function v(_){return t.map(_,f)}if(p instanceof s)return{type:"NonTerminal",name:p.nonTerminalName,idx:p.idx};if(p instanceof a)return{type:"Alternative",definition:v(p.definition)};if(p instanceof c)return{type:"Option",idx:p.idx,definition:v(p.definition)};if(p instanceof l)return{type:"RepetitionMandatory",idx:p.idx,definition:v(p.definition)};if(p instanceof u)return{type:"RepetitionMandatoryWithSeparator",idx:p.idx,separator:f(new g({terminalType:p.separator})),definition:v(p.definition)};if(p instanceof d)return{type:"RepetitionWithSeparator",idx:p.idx,separator:f(new g({terminalType:p.separator})),definition:v(p.definition)};if(p instanceof h)return{type:"Repetition",idx:p.idx,definition:v(p.definition)};if(p instanceof m)return{type:"Alternation",idx:p.idx,definition:v(p.definition)};if(p instanceof g){var b={type:"Terminal",name:p.terminalType.name,label:n.tokenLabel(p.terminalType),idx:p.idx},x=p.terminalType.PATTERN;return p.terminalType.PATTERN&&(b.pattern=t.isRegExp(x)?x.source:x),b}else{if(p instanceof o)return{type:"Rule",name:p.name,orgText:p.orgText,definition:v(p.definition)};throw Error("non exhaustive match")}}i.serializeProduction=f}),Fy=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.RestWalker=void 0;var e=Vt(),t=Bi(),n=(function(){function s(){}return s.prototype.walk=function(o,a){var c=this;a===void 0&&(a=[]),e.forEach(o.definition,function(l,u){var h=e.drop(o.definition,u+1);if(l instanceof t.NonTerminal)c.walkProdRef(l,h,a);else if(l instanceof t.Terminal)c.walkTerminal(l,h,a);else if(l instanceof t.Alternative)c.walkFlat(l,h,a);else if(l instanceof t.Option)c.walkOption(l,h,a);else if(l instanceof t.RepetitionMandatory)c.walkAtLeastOne(l,h,a);else if(l instanceof t.RepetitionMandatoryWithSeparator)c.walkAtLeastOneSep(l,h,a);else if(l instanceof t.RepetitionWithSeparator)c.walkManySep(l,h,a);else if(l instanceof t.Repetition)c.walkMany(l,h,a);else if(l instanceof t.Alternation)c.walkOr(l,h,a);else throw Error("non exhaustive match")})},s.prototype.walkTerminal=function(o,a,c){},s.prototype.walkProdRef=function(o,a,c){},s.prototype.walkFlat=function(o,a,c){var l=a.concat(c);this.walk(o,l)},s.prototype.walkOption=function(o,a,c){var l=a.concat(c);this.walk(o,l)},s.prototype.walkAtLeastOne=function(o,a,c){var l=[new t.Option({definition:o.definition})].concat(a,c);this.walk(o,l)},s.prototype.walkAtLeastOneSep=function(o,a,c){var l=r(o,a,c);this.walk(o,l)},s.prototype.walkMany=function(o,a,c){var l=[new t.Option({definition:o.definition})].concat(a,c);this.walk(o,l)},s.prototype.walkManySep=function(o,a,c){var l=r(o,a,c);this.walk(o,l)},s.prototype.walkOr=function(o,a,c){var l=this,u=a.concat(c);e.forEach(o.definition,function(h){var d=new t.Alternative({definition:[h]});l.walk(d,u)})},s})();i.RestWalker=n;function r(s,o,a){var c=[new t.Option({definition:[new t.Terminal({terminalType:s.separator})].concat(s.definition)})],l=c.concat(o,a);return l}}),wh=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.GAstVisitor=void 0;var e=Bi(),t=(function(){function n(){}return n.prototype.visit=function(r){var s=r;switch(s.constructor){case e.NonTerminal:return this.visitNonTerminal(s);case e.Alternative:return this.visitAlternative(s);case e.Option:return this.visitOption(s);case e.RepetitionMandatory:return this.visitRepetitionMandatory(s);case e.RepetitionMandatoryWithSeparator:return this.visitRepetitionMandatoryWithSeparator(s);case e.RepetitionWithSeparator:return this.visitRepetitionWithSeparator(s);case e.Repetition:return this.visitRepetition(s);case e.Alternation:return this.visitAlternation(s);case e.Terminal:return this.visitTerminal(s);case e.Rule:return this.visitRule(s);default:throw Error("non exhaustive match")}},n.prototype.visitNonTerminal=function(r){},n.prototype.visitAlternative=function(r){},n.prototype.visitOption=function(r){},n.prototype.visitRepetition=function(r){},n.prototype.visitRepetitionMandatory=function(r){},n.prototype.visitRepetitionMandatoryWithSeparator=function(r){},n.prototype.visitRepetitionWithSeparator=function(r){},n.prototype.visitAlternation=function(r){},n.prototype.visitTerminal=function(r){},n.prototype.visitRule=function(r){},n})();i.GAstVisitor=t}),kp=Mt(i=>{"use strict";var e=i&&i.__extends||(function(){var d=function(m,g){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(y,f){y.__proto__=f}||function(y,f){for(var p in f)Object.prototype.hasOwnProperty.call(f,p)&&(y[p]=f[p])},d(m,g)};return function(m,g){if(typeof g!="function"&&g!==null)throw new TypeError("Class extends value "+String(g)+" is not a constructor or null");d(m,g);function y(){this.constructor=m}m.prototype=g===null?Object.create(g):(y.prototype=g.prototype,new y)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.collectMethods=i.DslMethodsCollectorVisitor=i.getProductionDslName=i.isBranchingProd=i.isOptionalProd=i.isSequenceProd=void 0;var t=Vt(),n=Bi(),r=wh();function s(d){return d instanceof n.Alternative||d instanceof n.Option||d instanceof n.Repetition||d instanceof n.RepetitionMandatory||d instanceof n.RepetitionMandatoryWithSeparator||d instanceof n.RepetitionWithSeparator||d instanceof n.Terminal||d instanceof n.Rule}i.isSequenceProd=s;function o(d,m){m===void 0&&(m=[]);var g=d instanceof n.Option||d instanceof n.Repetition||d instanceof n.RepetitionWithSeparator;return g?!0:d instanceof n.Alternation?t.some(d.definition,function(y){return o(y,m)}):d instanceof n.NonTerminal&&t.contains(m,d)?!1:d instanceof n.AbstractProduction?(d instanceof n.NonTerminal&&m.push(d),t.every(d.definition,function(y){return o(y,m)})):!1}i.isOptionalProd=o;function a(d){return d instanceof n.Alternation}i.isBranchingProd=a;function c(d){if(d instanceof n.NonTerminal)return"SUBRULE";if(d instanceof n.Option)return"OPTION";if(d instanceof n.Alternation)return"OR";if(d instanceof n.RepetitionMandatory)return"AT_LEAST_ONE";if(d instanceof n.RepetitionMandatoryWithSeparator)return"AT_LEAST_ONE_SEP";if(d instanceof n.RepetitionWithSeparator)return"MANY_SEP";if(d instanceof n.Repetition)return"MANY";if(d instanceof n.Terminal)return"CONSUME";throw Error("non exhaustive match")}i.getProductionDslName=c;var l=(function(d){e(m,d);function m(){var g=d!==null&&d.apply(this,arguments)||this;return g.separator="-",g.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]},g}return m.prototype.reset=function(){this.dslMethods={option:[],alternation:[],repetition:[],repetitionWithSeparator:[],repetitionMandatory:[],repetitionMandatoryWithSeparator:[]}},m.prototype.visitTerminal=function(g){var y=g.terminalType.name+this.separator+"Terminal";t.has(this.dslMethods,y)||(this.dslMethods[y]=[]),this.dslMethods[y].push(g)},m.prototype.visitNonTerminal=function(g){var y=g.nonTerminalName+this.separator+"Terminal";t.has(this.dslMethods,y)||(this.dslMethods[y]=[]),this.dslMethods[y].push(g)},m.prototype.visitOption=function(g){this.dslMethods.option.push(g)},m.prototype.visitRepetitionWithSeparator=function(g){this.dslMethods.repetitionWithSeparator.push(g)},m.prototype.visitRepetitionMandatory=function(g){this.dslMethods.repetitionMandatory.push(g)},m.prototype.visitRepetitionMandatoryWithSeparator=function(g){this.dslMethods.repetitionMandatoryWithSeparator.push(g)},m.prototype.visitRepetition=function(g){this.dslMethods.repetition.push(g)},m.prototype.visitAlternation=function(g){this.dslMethods.alternation.push(g)},m})(r.GAstVisitor);i.DslMethodsCollectorVisitor=l;var u=new l;function h(d){u.reset(),d.accept(u);var m=u.dslMethods;return u.reset(),m}i.collectMethods=h}),dE=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.firstForTerminal=i.firstForBranching=i.firstForSequence=i.first=void 0;var e=Vt(),t=Bi(),n=kp();function r(c){if(c instanceof t.NonTerminal)return r(c.referencedRule);if(c instanceof t.Terminal)return a(c);if(n.isSequenceProd(c))return s(c);if(n.isBranchingProd(c))return o(c);throw Error("non exhaustive match")}i.first=r;function s(c){for(var l=[],u=c.definition,h=0,d=u.length>h,m,g=!0;d&&g;)m=u[h],g=n.isOptionalProd(m),l=l.concat(r(m)),h=h+1,d=u.length>h;return e.uniq(l)}i.firstForSequence=s;function o(c){var l=e.map(c.definition,function(u){return r(u)});return e.uniq(e.flatten(l))}i.firstForBranching=o;function a(c){return[c.terminalType]}i.firstForTerminal=a}),fE=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.IN=void 0,i.IN="_~IN~_"}),NP=Mt(i=>{"use strict";var e=i&&i.__extends||(function(){var h=function(d,m){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,y){g.__proto__=y}||function(g,y){for(var f in y)Object.prototype.hasOwnProperty.call(y,f)&&(g[f]=y[f])},h(d,m)};return function(d,m){if(typeof m!="function"&&m!==null)throw new TypeError("Class extends value "+String(m)+" is not a constructor or null");h(d,m);function g(){this.constructor=d}d.prototype=m===null?Object.create(m):(g.prototype=m.prototype,new g)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.buildInProdFollowPrefix=i.buildBetweenProdsFollowPrefix=i.computeAllProdsFollows=i.ResyncFollowsWalker=void 0;var t=Fy(),n=dE(),r=Vt(),s=fE(),o=Bi(),a=(function(h){e(d,h);function d(m){var g=h.call(this)||this;return g.topProd=m,g.follows={},g}return d.prototype.startWalking=function(){return this.walk(this.topProd),this.follows},d.prototype.walkTerminal=function(m,g,y){},d.prototype.walkProdRef=function(m,g,y){var f=l(m.referencedRule,m.idx)+this.topProd.name,p=g.concat(y),v=new o.Alternative({definition:p}),b=n.first(v);this.follows[f]=b},d})(t.RestWalker);i.ResyncFollowsWalker=a;function c(h){var d={};return r.forEach(h,function(m){var g=new a(m).startWalking();r.assign(d,g)}),d}i.computeAllProdsFollows=c;function l(h,d){return h.name+d+s.IN}i.buildBetweenProdsFollowPrefix=l;function u(h){var d=h.terminalType.name;return d+h.idx+s.IN}i.buildInProdFollowPrefix=u}),Bp=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.defaultGrammarValidatorErrorProvider=i.defaultGrammarResolverErrorProvider=i.defaultParserErrorProvider=void 0;var e=aa(),t=Vt(),n=Vt(),r=Bi(),s=kp();i.defaultParserErrorProvider={buildMismatchTokenMessage:function(o){var a=o.expected,c=o.actual,l=o.previous,u=o.ruleName,h=e.hasTokenLabel(a),d=h?"--> "+e.tokenLabel(a)+" <--":"token of type --> "+a.name+" <--",m="Expecting "+d+" but found --> '"+c.image+"' <--";return m},buildNotAllInputParsedMessage:function(o){var a=o.firstRedundant,c=o.ruleName;return"Redundant input, expecting EOF but found: "+a.image},buildNoViableAltMessage:function(o){var a=o.expectedPathsPerAlt,c=o.actual,l=o.previous,u=o.customUserDescription,h=o.ruleName,d="Expecting: ",m=n.first(c).image,g=`
but found: '`+m+"'";if(u)return d+u+g;var y=n.reduce(a,function(b,x){return b.concat(x)},[]),f=n.map(y,function(b){return"["+n.map(b,function(x){return e.tokenLabel(x)}).join(", ")+"]"}),p=n.map(f,function(b,x){return"  "+(x+1)+". "+b}),v=`one of these possible Token sequences:
`+p.join(`
`);return d+v+g},buildEarlyExitMessage:function(o){var a=o.expectedIterationPaths,c=o.actual,l=o.customUserDescription,u=o.ruleName,h="Expecting: ",d=n.first(c).image,m=`
but found: '`+d+"'";if(l)return h+l+m;var g=n.map(a,function(f){return"["+n.map(f,function(p){return e.tokenLabel(p)}).join(",")+"]"}),y=`expecting at least one iteration which starts with one of these possible Token sequences::
  `+("<"+g.join(" ,")+">");return h+y+m}},Object.freeze(i.defaultParserErrorProvider),i.defaultGrammarResolverErrorProvider={buildRuleNotFoundError:function(o,a){var c="Invalid grammar, reference to a rule which is not defined: ->"+a.nonTerminalName+`<-
inside top level rule: ->`+o.name+"<-";return c}},i.defaultGrammarValidatorErrorProvider={buildDuplicateFoundError:function(o,a){function c(f){return f instanceof r.Terminal?f.terminalType.name:f instanceof r.NonTerminal?f.nonTerminalName:""}var l=o.name,u=n.first(a),h=u.idx,d=s.getProductionDslName(u),m=c(u),g=h>0,y="->"+d+(g?h:"")+"<- "+(m?"with argument: ->"+m+"<-":"")+`
                  appears more than once (`+a.length+" times) in the top level rule: ->"+l+`<-.
                  For further details see: https://chevrotain.io/docs/FAQ.html#NUMERICAL_SUFFIXES
                  `;return y=y.replace(/[ \t]+/g," "),y=y.replace(/\s\s+/g,`
`),y},buildNamespaceConflictError:function(o){var a=`Namespace conflict found in grammar.
`+("The grammar has both a Terminal(Token) and a Non-Terminal(Rule) named: <"+o.name+`>.
`)+`To resolve this make sure each Terminal and Non-Terminal names are unique
This is easy to accomplish by using the convention that Terminal names start with an uppercase letter
and Non-Terminal names start with a lower case letter.`;return a},buildAlternationPrefixAmbiguityError:function(o){var a=n.map(o.prefixPath,function(u){return e.tokenLabel(u)}).join(", "),c=o.alternation.idx===0?"":o.alternation.idx,l="Ambiguous alternatives: <"+o.ambiguityIndices.join(" ,")+`> due to common lookahead prefix
`+("in <OR"+c+"> inside <"+o.topLevelRule.name+`> Rule,
`)+("<"+a+`> may appears as a prefix path in all these alternatives.
`)+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#COMMON_PREFIX
For Further details.`;return l},buildAlternationAmbiguityError:function(o){var a=n.map(o.prefixPath,function(u){return e.tokenLabel(u)}).join(", "),c=o.alternation.idx===0?"":o.alternation.idx,l="Ambiguous Alternatives Detected: <"+o.ambiguityIndices.join(" ,")+"> in <OR"+c+">"+(" inside <"+o.topLevelRule.name+`> Rule,
`)+("<"+a+`> may appears as a prefix path in all these alternatives.
`);return l=l+`See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#AMBIGUOUS_ALTERNATIVES
For Further details.`,l},buildEmptyRepetitionError:function(o){var a=s.getProductionDslName(o.repetition);o.repetition.idx!==0&&(a+=o.repetition.idx);var c="The repetition <"+a+"> within Rule <"+o.topLevelRule.name+`> can never consume any tokens.
This could lead to an infinite loop.`;return c},buildTokenNameError:function(o){return"deprecated"},buildEmptyAlternationError:function(o){var a="Ambiguous empty alternative: <"+(o.emptyChoiceIdx+1)+">"+(" in <OR"+o.alternation.idx+"> inside <"+o.topLevelRule.name+`> Rule.
`)+"Only the last alternative may be an empty alternative.";return a},buildTooManyAlternativesError:function(o){var a=`An Alternation cannot have more than 256 alternatives:
`+("<OR"+o.alternation.idx+"> inside <"+o.topLevelRule.name+`> Rule.
 has `+(o.alternation.definition.length+1)+" alternatives.");return a},buildLeftRecursionError:function(o){var a=o.topLevelRule.name,c=t.map(o.leftRecursionPath,function(h){return h.name}),l=a+" --> "+c.concat([a]).join(" --> "),u=`Left Recursion found in grammar.
`+("rule: <"+a+`> can be invoked from itself (directly or indirectly)
`)+(`without consuming any Tokens. The grammar path that causes this is:
 `+l+`
`)+` To fix this refactor your grammar to remove the left recursion.
see: https://en.wikipedia.org/wiki/LL_parser#Left_Factoring.`;return u},buildInvalidRuleNameError:function(o){return"deprecated"},buildDuplicateRuleNameError:function(o){var a;o.topLevelRule instanceof r.Rule?a=o.topLevelRule.name:a=o.topLevelRule;var c="Duplicate definition, rule: ->"+a+"<- is already defined in the grammar: ->"+o.grammarName+"<-";return c}}}),LP=Mt(i=>{"use strict";var e=i&&i.__extends||(function(){var a=function(c,l){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,h){u.__proto__=h}||function(u,h){for(var d in h)Object.prototype.hasOwnProperty.call(h,d)&&(u[d]=h[d])},a(c,l)};return function(c,l){if(typeof l!="function"&&l!==null)throw new TypeError("Class extends value "+String(l)+" is not a constructor or null");a(c,l);function u(){this.constructor=c}c.prototype=l===null?Object.create(l):(u.prototype=l.prototype,new u)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.GastRefResolverVisitor=i.resolveGrammar=void 0;var t=ji(),n=Vt(),r=wh();function s(a,c){var l=new o(a,c);return l.resolveRefs(),l.errors}i.resolveGrammar=s;var o=(function(a){e(c,a);function c(l,u){var h=a.call(this)||this;return h.nameToTopRule=l,h.errMsgProvider=u,h.errors=[],h}return c.prototype.resolveRefs=function(){var l=this;n.forEach(n.values(this.nameToTopRule),function(u){l.currTopLevel=u,u.accept(l)})},c.prototype.visitNonTerminal=function(l){var u=this.nameToTopRule[l.nonTerminalName];if(u)l.referencedRule=u;else{var h=this.errMsgProvider.buildRuleNotFoundError(this.currTopLevel,l);this.errors.push({message:h,type:t.ParserDefinitionErrorType.UNRESOLVED_SUBRULE_REF,ruleName:this.currTopLevel.name,unresolvedRefName:l.nonTerminalName})}},c})(r.GAstVisitor);i.GastRefResolverVisitor=o}),zp=Mt(i=>{"use strict";var e=i&&i.__extends||(function(){var f=function(p,v){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(b,x){b.__proto__=x}||function(b,x){for(var _ in x)Object.prototype.hasOwnProperty.call(x,_)&&(b[_]=x[_])},f(p,v)};return function(p,v){if(typeof v!="function"&&v!==null)throw new TypeError("Class extends value "+String(v)+" is not a constructor or null");f(p,v);function b(){this.constructor=p}p.prototype=v===null?Object.create(v):(b.prototype=v.prototype,new b)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.nextPossibleTokensAfter=i.possiblePathsFrom=i.NextTerminalAfterAtLeastOneSepWalker=i.NextTerminalAfterAtLeastOneWalker=i.NextTerminalAfterManySepWalker=i.NextTerminalAfterManyWalker=i.AbstractNextTerminalAfterProductionWalker=i.NextAfterTokenWalker=i.AbstractNextPossibleTokensWalker=void 0;var t=Fy(),n=Vt(),r=dE(),s=Bi(),o=(function(f){e(p,f);function p(v,b){var x=f.call(this)||this;return x.topProd=v,x.path=b,x.possibleTokTypes=[],x.nextProductionName="",x.nextProductionOccurrence=0,x.found=!1,x.isAtEndOfPath=!1,x}return p.prototype.startWalking=function(){if(this.found=!1,this.path.ruleStack[0]!==this.topProd.name)throw Error("The path does not start with the walker's top Rule!");return this.ruleStack=n.cloneArr(this.path.ruleStack).reverse(),this.occurrenceStack=n.cloneArr(this.path.occurrenceStack).reverse(),this.ruleStack.pop(),this.occurrenceStack.pop(),this.updateExpectedNext(),this.walk(this.topProd),this.possibleTokTypes},p.prototype.walk=function(v,b){b===void 0&&(b=[]),this.found||f.prototype.walk.call(this,v,b)},p.prototype.walkProdRef=function(v,b,x){if(v.referencedRule.name===this.nextProductionName&&v.idx===this.nextProductionOccurrence){var _=b.concat(x);this.updateExpectedNext(),this.walk(v.referencedRule,_)}},p.prototype.updateExpectedNext=function(){n.isEmpty(this.ruleStack)?(this.nextProductionName="",this.nextProductionOccurrence=0,this.isAtEndOfPath=!0):(this.nextProductionName=this.ruleStack.pop(),this.nextProductionOccurrence=this.occurrenceStack.pop())},p})(t.RestWalker);i.AbstractNextPossibleTokensWalker=o;var a=(function(f){e(p,f);function p(v,b){var x=f.call(this,v,b)||this;return x.path=b,x.nextTerminalName="",x.nextTerminalOccurrence=0,x.nextTerminalName=x.path.lastTok.name,x.nextTerminalOccurrence=x.path.lastTokOccurrence,x}return p.prototype.walkTerminal=function(v,b,x){if(this.isAtEndOfPath&&v.terminalType.name===this.nextTerminalName&&v.idx===this.nextTerminalOccurrence&&!this.found){var _=b.concat(x),T=new s.Alternative({definition:_});this.possibleTokTypes=r.first(T),this.found=!0}},p})(o);i.NextAfterTokenWalker=a;var c=(function(f){e(p,f);function p(v,b){var x=f.call(this)||this;return x.topRule=v,x.occurrence=b,x.result={token:void 0,occurrence:void 0,isEndOfRule:void 0},x}return p.prototype.startWalking=function(){return this.walk(this.topRule),this.result},p})(t.RestWalker);i.AbstractNextTerminalAfterProductionWalker=c;var l=(function(f){e(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.prototype.walkMany=function(v,b,x){if(v.idx===this.occurrence){var _=n.first(b.concat(x));this.result.isEndOfRule=_===void 0,_ instanceof s.Terminal&&(this.result.token=_.terminalType,this.result.occurrence=_.idx)}else f.prototype.walkMany.call(this,v,b,x)},p})(c);i.NextTerminalAfterManyWalker=l;var u=(function(f){e(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.prototype.walkManySep=function(v,b,x){if(v.idx===this.occurrence){var _=n.first(b.concat(x));this.result.isEndOfRule=_===void 0,_ instanceof s.Terminal&&(this.result.token=_.terminalType,this.result.occurrence=_.idx)}else f.prototype.walkManySep.call(this,v,b,x)},p})(c);i.NextTerminalAfterManySepWalker=u;var h=(function(f){e(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.prototype.walkAtLeastOne=function(v,b,x){if(v.idx===this.occurrence){var _=n.first(b.concat(x));this.result.isEndOfRule=_===void 0,_ instanceof s.Terminal&&(this.result.token=_.terminalType,this.result.occurrence=_.idx)}else f.prototype.walkAtLeastOne.call(this,v,b,x)},p})(c);i.NextTerminalAfterAtLeastOneWalker=h;var d=(function(f){e(p,f);function p(){return f!==null&&f.apply(this,arguments)||this}return p.prototype.walkAtLeastOneSep=function(v,b,x){if(v.idx===this.occurrence){var _=n.first(b.concat(x));this.result.isEndOfRule=_===void 0,_ instanceof s.Terminal&&(this.result.token=_.terminalType,this.result.occurrence=_.idx)}else f.prototype.walkAtLeastOneSep.call(this,v,b,x)},p})(c);i.NextTerminalAfterAtLeastOneSepWalker=d;function m(f,p,v){v===void 0&&(v=[]),v=n.cloneArr(v);var b=[],x=0;function _(E){return E.concat(n.drop(f,x+1))}function T(E){var M=m(_(E),p,v);return b.concat(M)}for(;v.length<p&&x<f.length;){var w=f[x];if(w instanceof s.Alternative||w instanceof s.NonTerminal)return T(w.definition);if(w instanceof s.Option)b=T(w.definition);else if(w instanceof s.RepetitionMandatory){var A=w.definition.concat([new s.Repetition({definition:w.definition})]);return T(A)}else if(w instanceof s.RepetitionMandatoryWithSeparator){var A=[new s.Alternative({definition:w.definition}),new s.Repetition({definition:[new s.Terminal({terminalType:w.separator})].concat(w.definition)})];return T(A)}else if(w instanceof s.RepetitionWithSeparator){var A=w.definition.concat([new s.Repetition({definition:[new s.Terminal({terminalType:w.separator})].concat(w.definition)})]);b=T(A)}else if(w instanceof s.Repetition){var A=w.definition.concat([new s.Repetition({definition:w.definition})]);b=T(A)}else{if(w instanceof s.Alternation)return n.forEach(w.definition,function(E){n.isEmpty(E.definition)===!1&&(b=T(E.definition))}),b;if(w instanceof s.Terminal)v.push(w.terminalType);else throw Error("non exhaustive match")}x++}return b.push({partialPath:v,suffixDef:n.drop(f,x)}),b}i.possiblePathsFrom=m;function g(f,p,v,b){var x="EXIT_NONE_TERMINAL",_=[x],T="EXIT_ALTERNATIVE",w=!1,A=p.length,E=A-b-1,M=[],P=[];for(P.push({idx:-1,def:f,ruleStack:[],occurrenceStack:[]});!n.isEmpty(P);){var N=P.pop();if(N===T){w&&n.last(P).idx<=E&&P.pop();continue}var L=N.def,D=N.idx,$=N.ruleStack,U=N.occurrenceStack;if(!n.isEmpty(L)){var I=L[0];if(I===x){var V={idx:D,def:n.drop(L),ruleStack:n.dropRight($),occurrenceStack:n.dropRight(U)};P.push(V)}else if(I instanceof s.Terminal)if(D<A-1){var W=D+1,Q=p[W];if(v(Q,I.terminalType)){var V={idx:W,def:n.drop(L),ruleStack:$,occurrenceStack:U};P.push(V)}}else if(D===A-1)M.push({nextTokenType:I.terminalType,nextTokenOccurrence:I.idx,ruleStack:$,occurrenceStack:U}),w=!0;else throw Error("non exhaustive match");else if(I instanceof s.NonTerminal){var se=n.cloneArr($);se.push(I.nonTerminalName);var oe=n.cloneArr(U);oe.push(I.idx);var V={idx:D,def:I.definition.concat(_,n.drop(L)),ruleStack:se,occurrenceStack:oe};P.push(V)}else if(I instanceof s.Option){var ge={idx:D,def:n.drop(L),ruleStack:$,occurrenceStack:U};P.push(ge),P.push(T);var O={idx:D,def:I.definition.concat(n.drop(L)),ruleStack:$,occurrenceStack:U};P.push(O)}else if(I instanceof s.RepetitionMandatory){var S=new s.Repetition({definition:I.definition,idx:I.idx}),R=I.definition.concat([S],n.drop(L)),V={idx:D,def:R,ruleStack:$,occurrenceStack:U};P.push(V)}else if(I instanceof s.RepetitionMandatoryWithSeparator){var z=new s.Terminal({terminalType:I.separator}),S=new s.Repetition({definition:[z].concat(I.definition),idx:I.idx}),R=I.definition.concat([S],n.drop(L)),V={idx:D,def:R,ruleStack:$,occurrenceStack:U};P.push(V)}else if(I instanceof s.RepetitionWithSeparator){var ge={idx:D,def:n.drop(L),ruleStack:$,occurrenceStack:U};P.push(ge),P.push(T);var z=new s.Terminal({terminalType:I.separator}),Y=new s.Repetition({definition:[z].concat(I.definition),idx:I.idx}),R=I.definition.concat([Y],n.drop(L)),O={idx:D,def:R,ruleStack:$,occurrenceStack:U};P.push(O)}else if(I instanceof s.Repetition){var ge={idx:D,def:n.drop(L),ruleStack:$,occurrenceStack:U};P.push(ge),P.push(T);var Y=new s.Repetition({definition:I.definition,idx:I.idx}),R=I.definition.concat([Y],n.drop(L)),O={idx:D,def:R,ruleStack:$,occurrenceStack:U};P.push(O)}else if(I instanceof s.Alternation)for(var K=I.definition.length-1;K>=0;K--){var re=I.definition[K],de={idx:D,def:re.definition.concat(n.drop(L)),ruleStack:$,occurrenceStack:U};P.push(de),P.push(T)}else if(I instanceof s.Alternative)P.push({idx:D,def:I.definition.concat(n.drop(L)),ruleStack:$,occurrenceStack:U});else if(I instanceof s.Rule)P.push(y(I,D,$,U));else throw Error("non exhaustive match")}}return M}i.nextPossibleTokensAfter=g;function y(f,p,v,b){var x=n.cloneArr(v);x.push(f.name);var _=n.cloneArr(b);return _.push(1),{idx:p,def:f.definition,ruleStack:x,occurrenceStack:_}}}),Vp=Mt(i=>{"use strict";var e=i&&i.__extends||(function(){var E=function(M,P){return E=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(N,L){N.__proto__=L}||function(N,L){for(var D in L)Object.prototype.hasOwnProperty.call(L,D)&&(N[D]=L[D])},E(M,P)};return function(M,P){if(typeof P!="function"&&P!==null)throw new TypeError("Class extends value "+String(P)+" is not a constructor or null");E(M,P);function N(){this.constructor=M}M.prototype=P===null?Object.create(P):(N.prototype=P.prototype,new N)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.areTokenCategoriesNotUsed=i.isStrictPrefixOfPath=i.containsPath=i.getLookaheadPathsForOptionalProd=i.getLookaheadPathsForOr=i.lookAheadSequenceFromAlternatives=i.buildSingleAlternativeLookaheadFunction=i.buildAlternativesLookAheadFunc=i.buildLookaheadFuncForOptionalProd=i.buildLookaheadFuncForOr=i.getProdType=i.PROD_TYPE=void 0;var t=Vt(),n=zp(),r=Fy(),s=Ah(),o=Bi(),a=wh(),c;(function(E){E[E.OPTION=0]="OPTION",E[E.REPETITION=1]="REPETITION",E[E.REPETITION_MANDATORY=2]="REPETITION_MANDATORY",E[E.REPETITION_MANDATORY_WITH_SEPARATOR=3]="REPETITION_MANDATORY_WITH_SEPARATOR",E[E.REPETITION_WITH_SEPARATOR=4]="REPETITION_WITH_SEPARATOR",E[E.ALTERNATION=5]="ALTERNATION"})(c=i.PROD_TYPE||(i.PROD_TYPE={}));function l(E){if(E instanceof o.Option)return c.OPTION;if(E instanceof o.Repetition)return c.REPETITION;if(E instanceof o.RepetitionMandatory)return c.REPETITION_MANDATORY;if(E instanceof o.RepetitionMandatoryWithSeparator)return c.REPETITION_MANDATORY_WITH_SEPARATOR;if(E instanceof o.RepetitionWithSeparator)return c.REPETITION_WITH_SEPARATOR;if(E instanceof o.Alternation)return c.ALTERNATION;throw Error("non exhaustive match")}i.getProdType=l;function u(E,M,P,N,L,D){var $=x(E,M,P),U=A($)?s.tokenStructuredMatcherNoCategories:s.tokenStructuredMatcher;return D($,N,U,L)}i.buildLookaheadFuncForOr=u;function h(E,M,P,N,L,D){var $=_(E,M,L,P),U=A($)?s.tokenStructuredMatcherNoCategories:s.tokenStructuredMatcher;return D($[0],U,N)}i.buildLookaheadFuncForOptionalProd=h;function d(E,M,P,N){var L=E.length,D=t.every(E,function(I){return t.every(I,function(V){return V.length===1})});if(M)return function(I){for(var V=t.map(I,function(Y){return Y.GATE}),W=0;W<L;W++){var Q=E[W],se=Q.length,oe=V[W];if(!(oe!==void 0&&oe.call(this)===!1))e:for(var ge=0;ge<se;ge++){for(var O=Q[ge],S=O.length,R=0;R<S;R++){var z=this.LA(R+1);if(P(z,O[R])===!1)continue e}return W}}};if(D&&!N){var $=t.map(E,function(I){return t.flatten(I)}),U=t.reduce($,function(I,V,W){return t.forEach(V,function(Q){t.has(I,Q.tokenTypeIdx)||(I[Q.tokenTypeIdx]=W),t.forEach(Q.categoryMatches,function(se){t.has(I,se)||(I[se]=W)})}),I},[]);return function(){var I=this.LA(1);return U[I.tokenTypeIdx]}}else return function(){for(var I=0;I<L;I++){var V=E[I],W=V.length;e:for(var Q=0;Q<W;Q++){for(var se=V[Q],oe=se.length,ge=0;ge<oe;ge++){var O=this.LA(ge+1);if(P(O,se[ge])===!1)continue e}return I}}}}i.buildAlternativesLookAheadFunc=d;function m(E,M,P){var N=t.every(E,function(V){return V.length===1}),L=E.length;if(N&&!P){var D=t.flatten(E);if(D.length===1&&t.isEmpty(D[0].categoryMatches)){var $=D[0],U=$.tokenTypeIdx;return function(){return this.LA(1).tokenTypeIdx===U}}else{var I=t.reduce(D,function(V,W,Q){return V[W.tokenTypeIdx]=!0,t.forEach(W.categoryMatches,function(se){V[se]=!0}),V},[]);return function(){var V=this.LA(1);return I[V.tokenTypeIdx]===!0}}}else return function(){e:for(var V=0;V<L;V++){for(var W=E[V],Q=W.length,se=0;se<Q;se++){var oe=this.LA(se+1);if(M(oe,W[se])===!1)continue e}return!0}return!1}}i.buildSingleAlternativeLookaheadFunction=m;var g=(function(E){e(M,E);function M(P,N,L){var D=E.call(this)||this;return D.topProd=P,D.targetOccurrence=N,D.targetProdType=L,D}return M.prototype.startWalking=function(){return this.walk(this.topProd),this.restDef},M.prototype.checkIsTarget=function(P,N,L,D){return P.idx===this.targetOccurrence&&this.targetProdType===N?(this.restDef=L.concat(D),!0):!1},M.prototype.walkOption=function(P,N,L){this.checkIsTarget(P,c.OPTION,N,L)||E.prototype.walkOption.call(this,P,N,L)},M.prototype.walkAtLeastOne=function(P,N,L){this.checkIsTarget(P,c.REPETITION_MANDATORY,N,L)||E.prototype.walkOption.call(this,P,N,L)},M.prototype.walkAtLeastOneSep=function(P,N,L){this.checkIsTarget(P,c.REPETITION_MANDATORY_WITH_SEPARATOR,N,L)||E.prototype.walkOption.call(this,P,N,L)},M.prototype.walkMany=function(P,N,L){this.checkIsTarget(P,c.REPETITION,N,L)||E.prototype.walkOption.call(this,P,N,L)},M.prototype.walkManySep=function(P,N,L){this.checkIsTarget(P,c.REPETITION_WITH_SEPARATOR,N,L)||E.prototype.walkOption.call(this,P,N,L)},M})(r.RestWalker),y=(function(E){e(M,E);function M(P,N,L){var D=E.call(this)||this;return D.targetOccurrence=P,D.targetProdType=N,D.targetRef=L,D.result=[],D}return M.prototype.checkIsTarget=function(P,N){P.idx===this.targetOccurrence&&this.targetProdType===N&&(this.targetRef===void 0||P===this.targetRef)&&(this.result=P.definition)},M.prototype.visitOption=function(P){this.checkIsTarget(P,c.OPTION)},M.prototype.visitRepetition=function(P){this.checkIsTarget(P,c.REPETITION)},M.prototype.visitRepetitionMandatory=function(P){this.checkIsTarget(P,c.REPETITION_MANDATORY)},M.prototype.visitRepetitionMandatoryWithSeparator=function(P){this.checkIsTarget(P,c.REPETITION_MANDATORY_WITH_SEPARATOR)},M.prototype.visitRepetitionWithSeparator=function(P){this.checkIsTarget(P,c.REPETITION_WITH_SEPARATOR)},M.prototype.visitAlternation=function(P){this.checkIsTarget(P,c.ALTERNATION)},M})(a.GAstVisitor);function f(E){for(var M=new Array(E),P=0;P<E;P++)M[P]=[];return M}function p(E){for(var M=[""],P=0;P<E.length;P++){for(var N=E[P],L=[],D=0;D<M.length;D++){var $=M[D];L.push($+"_"+N.tokenTypeIdx);for(var U=0;U<N.categoryMatches.length;U++){var I="_"+N.categoryMatches[U];L.push($+I)}}M=L}return M}function v(E,M,P){for(var N=0;N<E.length;N++)if(N!==P)for(var L=E[N],D=0;D<M.length;D++){var $=M[D];if(L[$]===!0)return!1}return!0}function b(E,M){for(var P=t.map(E,function(W){return n.possiblePathsFrom([W],1)}),N=f(P.length),L=t.map(P,function(W){var Q={};return t.forEach(W,function(se){var oe=p(se.partialPath);t.forEach(oe,function(ge){Q[ge]=!0})}),Q}),D=P,$=1;$<=M;$++){var U=D;D=f(U.length);for(var I=function(W){for(var Q=U[W],se=0;se<Q.length;se++){var oe=Q[se].partialPath,ge=Q[se].suffixDef,O=p(oe),S=v(L,O,W);if(S||t.isEmpty(ge)||oe.length===M){var R=N[W];if(T(R,oe)===!1){R.push(oe);for(var z=0;z<O.length;z++){var Y=O[z];L[W][Y]=!0}}}else{var K=n.possiblePathsFrom(ge,$+1,oe);D[W]=D[W].concat(K),t.forEach(K,function(re){var de=p(re.partialPath);t.forEach(de,function(te){L[W][te]=!0})})}}},V=0;V<U.length;V++)I(V)}return N}i.lookAheadSequenceFromAlternatives=b;function x(E,M,P,N){var L=new y(E,c.ALTERNATION,N);return M.accept(L),b(L.result,P)}i.getLookaheadPathsForOr=x;function _(E,M,P,N){var L=new y(E,P);M.accept(L);var D=L.result,$=new g(M,E,P),U=$.startWalking(),I=new o.Alternative({definition:D}),V=new o.Alternative({definition:U});return b([I,V],N)}i.getLookaheadPathsForOptionalProd=_;function T(E,M){e:for(var P=0;P<E.length;P++){var N=E[P];if(N.length===M.length){for(var L=0;L<N.length;L++){var D=M[L],$=N[L],U=D===$||$.categoryMatchesMap[D.tokenTypeIdx]!==void 0;if(U===!1)continue e}return!0}}return!1}i.containsPath=T;function w(E,M){return E.length<M.length&&t.every(E,function(P,N){var L=M[N];return P===L||L.categoryMatchesMap[P.tokenTypeIdx]})}i.isStrictPrefixOfPath=w;function A(E){return t.every(E,function(M){return t.every(M,function(P){return t.every(P,function(N){return t.isEmpty(N.categoryMatches)})})})}i.areTokenCategoriesNotUsed=A}),pE=Mt(i=>{"use strict";var e=i&&i.__extends||(function(){var N=function(L,D){return N=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function($,U){$.__proto__=U}||function($,U){for(var I in U)Object.prototype.hasOwnProperty.call(U,I)&&($[I]=U[I])},N(L,D)};return function(L,D){if(typeof D!="function"&&D!==null)throw new TypeError("Class extends value "+String(D)+" is not a constructor or null");N(L,D);function $(){this.constructor=L}L.prototype=D===null?Object.create(D):($.prototype=D.prototype,new $)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.checkPrefixAlternativesAmbiguities=i.validateSomeNonEmptyLookaheadPath=i.validateTooManyAlts=i.RepetionCollector=i.validateAmbiguousAlternationAlternatives=i.validateEmptyOrAlternative=i.getFirstNoneTerminal=i.validateNoLeftRecursion=i.validateRuleIsOverridden=i.validateRuleDoesNotAlreadyExist=i.OccurrenceValidationCollector=i.identifyProductionForDuplicates=i.validateGrammar=void 0;var t=Vt(),n=Vt(),r=ji(),s=kp(),o=Vp(),a=zp(),c=Bi(),l=wh();function u(N,L,D,$,U){var I=t.map(N,function(S){return h(S,$)}),V=t.map(N,function(S){return p(S,S,$)}),W=[],Q=[],se=[];n.every(V,n.isEmpty)&&(W=n.map(N,function(S){return x(S,$)}),Q=n.map(N,function(S){return _(S,L,$)}),se=A(N,L,$));var oe=P(N,D,$),ge=n.map(N,function(S){return w(S,$)}),O=n.map(N,function(S){return y(S,N,U,$)});return t.flatten(I.concat(se,V,W,Q,oe,ge,O))}i.validateGrammar=u;function h(N,L){var D=new g;N.accept(D);var $=D.allProductions,U=t.groupBy($,d),I=t.pick(U,function(W){return W.length>1}),V=t.map(t.values(I),function(W){var Q=t.first(W),se=L.buildDuplicateFoundError(N,W),oe=s.getProductionDslName(Q),ge={message:se,type:r.ParserDefinitionErrorType.DUPLICATE_PRODUCTIONS,ruleName:N.name,dslName:oe,occurrence:Q.idx},O=m(Q);return O&&(ge.parameter=O),ge});return V}function d(N){return s.getProductionDslName(N)+"_#_"+N.idx+"_#_"+m(N)}i.identifyProductionForDuplicates=d;function m(N){return N instanceof c.Terminal?N.terminalType.name:N instanceof c.NonTerminal?N.nonTerminalName:""}var g=(function(N){e(L,N);function L(){var D=N!==null&&N.apply(this,arguments)||this;return D.allProductions=[],D}return L.prototype.visitNonTerminal=function(D){this.allProductions.push(D)},L.prototype.visitOption=function(D){this.allProductions.push(D)},L.prototype.visitRepetitionWithSeparator=function(D){this.allProductions.push(D)},L.prototype.visitRepetitionMandatory=function(D){this.allProductions.push(D)},L.prototype.visitRepetitionMandatoryWithSeparator=function(D){this.allProductions.push(D)},L.prototype.visitRepetition=function(D){this.allProductions.push(D)},L.prototype.visitAlternation=function(D){this.allProductions.push(D)},L.prototype.visitTerminal=function(D){this.allProductions.push(D)},L})(l.GAstVisitor);i.OccurrenceValidationCollector=g;function y(N,L,D,$){var U=[],I=n.reduce(L,function(W,Q){return Q.name===N.name?W+1:W},0);if(I>1){var V=$.buildDuplicateRuleNameError({topLevelRule:N,grammarName:D});U.push({message:V,type:r.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:N.name})}return U}i.validateRuleDoesNotAlreadyExist=y;function f(N,L,D){var $=[],U;return t.contains(L,N)||(U="Invalid rule override, rule: ->"+N+"<- cannot be overridden in the grammar: ->"+D+"<-as it is not defined in any of the super grammars ",$.push({message:U,type:r.ParserDefinitionErrorType.INVALID_RULE_OVERRIDE,ruleName:N})),$}i.validateRuleIsOverridden=f;function p(N,L,D,$){$===void 0&&($=[]);var U=[],I=v(L.definition);if(t.isEmpty(I))return[];var V=N.name,W=t.contains(I,N);W&&U.push({message:D.buildLeftRecursionError({topLevelRule:N,leftRecursionPath:$}),type:r.ParserDefinitionErrorType.LEFT_RECURSION,ruleName:V});var Q=t.difference(I,$.concat([N])),se=t.map(Q,function(oe){var ge=t.cloneArr($);return ge.push(oe),p(N,oe,D,ge)});return U.concat(t.flatten(se))}i.validateNoLeftRecursion=p;function v(N){var L=[];if(t.isEmpty(N))return L;var D=t.first(N);if(D instanceof c.NonTerminal)L.push(D.referencedRule);else if(D instanceof c.Alternative||D instanceof c.Option||D instanceof c.RepetitionMandatory||D instanceof c.RepetitionMandatoryWithSeparator||D instanceof c.RepetitionWithSeparator||D instanceof c.Repetition)L=L.concat(v(D.definition));else if(D instanceof c.Alternation)L=t.flatten(t.map(D.definition,function(V){return v(V.definition)}));else if(!(D instanceof c.Terminal))throw Error("non exhaustive match");var $=s.isOptionalProd(D),U=N.length>1;if($&&U){var I=t.drop(N);return L.concat(v(I))}else return L}i.getFirstNoneTerminal=v;var b=(function(N){e(L,N);function L(){var D=N!==null&&N.apply(this,arguments)||this;return D.alternations=[],D}return L.prototype.visitAlternation=function(D){this.alternations.push(D)},L})(l.GAstVisitor);function x(N,L){var D=new b;N.accept(D);var $=D.alternations,U=t.reduce($,function(I,V){var W=t.dropRight(V.definition),Q=t.map(W,function(se,oe){var ge=a.nextPossibleTokensAfter([se],[],null,1);return t.isEmpty(ge)?{message:L.buildEmptyAlternationError({topLevelRule:N,alternation:V,emptyChoiceIdx:oe}),type:r.ParserDefinitionErrorType.NONE_LAST_EMPTY_ALT,ruleName:N.name,occurrence:V.idx,alternative:oe+1}:null});return I.concat(t.compact(Q))},[]);return U}i.validateEmptyOrAlternative=x;function _(N,L,D){var $=new b;N.accept($);var U=$.alternations;U=n.reject(U,function(V){return V.ignoreAmbiguities===!0});var I=t.reduce(U,function(V,W){var Q=W.idx,se=W.maxLookahead||L,oe=o.getLookaheadPathsForOr(Q,N,se,W),ge=E(oe,W,N,D),O=M(oe,W,N,D);return V.concat(ge,O)},[]);return I}i.validateAmbiguousAlternationAlternatives=_;var T=(function(N){e(L,N);function L(){var D=N!==null&&N.apply(this,arguments)||this;return D.allProductions=[],D}return L.prototype.visitRepetitionWithSeparator=function(D){this.allProductions.push(D)},L.prototype.visitRepetitionMandatory=function(D){this.allProductions.push(D)},L.prototype.visitRepetitionMandatoryWithSeparator=function(D){this.allProductions.push(D)},L.prototype.visitRepetition=function(D){this.allProductions.push(D)},L})(l.GAstVisitor);i.RepetionCollector=T;function w(N,L){var D=new b;N.accept(D);var $=D.alternations,U=t.reduce($,function(I,V){return V.definition.length>255&&I.push({message:L.buildTooManyAlternativesError({topLevelRule:N,alternation:V}),type:r.ParserDefinitionErrorType.TOO_MANY_ALTS,ruleName:N.name,occurrence:V.idx}),I},[]);return U}i.validateTooManyAlts=w;function A(N,L,D){var $=[];return n.forEach(N,function(U){var I=new T;U.accept(I);var V=I.allProductions;n.forEach(V,function(W){var Q=o.getProdType(W),se=W.maxLookahead||L,oe=W.idx,ge=o.getLookaheadPathsForOptionalProd(oe,U,Q,se),O=ge[0];if(n.isEmpty(n.flatten(O))){var S=D.buildEmptyRepetitionError({topLevelRule:U,repetition:W});$.push({message:S,type:r.ParserDefinitionErrorType.NO_NON_EMPTY_LOOKAHEAD,ruleName:U.name})}})}),$}i.validateSomeNonEmptyLookaheadPath=A;function E(N,L,D,$){var U=[],I=n.reduce(N,function(W,Q,se){return L.definition[se].ignoreAmbiguities===!0||n.forEach(Q,function(oe){var ge=[se];n.forEach(N,function(O,S){se!==S&&o.containsPath(O,oe)&&L.definition[S].ignoreAmbiguities!==!0&&ge.push(S)}),ge.length>1&&!o.containsPath(U,oe)&&(U.push(oe),W.push({alts:ge,path:oe}))}),W},[]),V=t.map(I,function(W){var Q=n.map(W.alts,function(oe){return oe+1}),se=$.buildAlternationAmbiguityError({topLevelRule:D,alternation:L,ambiguityIndices:Q,prefixPath:W.path});return{message:se,type:r.ParserDefinitionErrorType.AMBIGUOUS_ALTS,ruleName:D.name,occurrence:L.idx,alternatives:[W.alts]}});return V}function M(N,L,D,$){var U=[],I=n.reduce(N,function(V,W,Q){var se=n.map(W,function(oe){return{idx:Q,path:oe}});return V.concat(se)},[]);return n.forEach(I,function(V){var W=L.definition[V.idx];if(W.ignoreAmbiguities!==!0){var Q=V.idx,se=V.path,oe=n.findAll(I,function(O){return L.definition[O.idx].ignoreAmbiguities!==!0&&O.idx<Q&&o.isStrictPrefixOfPath(O.path,se)}),ge=n.map(oe,function(O){var S=[O.idx+1,Q+1],R=L.idx===0?"":L.idx,z=$.buildAlternationPrefixAmbiguityError({topLevelRule:D,alternation:L,ambiguityIndices:S,prefixPath:O.path});return{message:z,type:r.ParserDefinitionErrorType.AMBIGUOUS_PREFIX_ALTS,ruleName:D.name,occurrence:R,alternatives:S}});U=U.concat(ge)}}),U}i.checkPrefixAlternativesAmbiguities=M;function P(N,L,D){var $=[],U=n.map(L,function(I){return I.name});return n.forEach(N,function(I){var V=I.name;if(n.contains(U,V)){var W=D.buildNamespaceConflictError(I);$.push({message:W,type:r.ParserDefinitionErrorType.CONFLICT_TOKENS_RULES_NAMESPACE,ruleName:V})}}),$}}),OP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateGrammar=i.resolveGrammar=void 0;var e=Vt(),t=LP(),n=pE(),r=Bp();function s(a){a=e.defaults(a,{errMsgProvider:r.defaultGrammarResolverErrorProvider});var c={};return e.forEach(a.rules,function(l){c[l.name]=l}),t.resolveGrammar(c,a.errMsgProvider)}i.resolveGrammar=s;function o(a){return a=e.defaults(a,{errMsgProvider:r.defaultGrammarValidatorErrorProvider}),n.validateGrammar(a.rules,a.maxLookahead,a.tokenTypes,a.errMsgProvider,a.grammarName)}i.validateGrammar=o}),Rh=Mt(i=>{"use strict";var e=i&&i.__extends||(function(){var g=function(y,f){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,v){p.__proto__=v}||function(p,v){for(var b in v)Object.prototype.hasOwnProperty.call(v,b)&&(p[b]=v[b])},g(y,f)};return function(y,f){if(typeof f!="function"&&f!==null)throw new TypeError("Class extends value "+String(f)+" is not a constructor or null");g(y,f);function p(){this.constructor=y}y.prototype=f===null?Object.create(f):(p.prototype=f.prototype,new p)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.EarlyExitException=i.NotAllInputParsedException=i.NoViableAltException=i.MismatchedTokenException=i.isRecognitionException=void 0;var t=Vt(),n="MismatchedTokenException",r="NoViableAltException",s="EarlyExitException",o="NotAllInputParsedException",a=[n,r,s,o];Object.freeze(a);function c(g){return t.contains(a,g.name)}i.isRecognitionException=c;var l=(function(g){e(y,g);function y(f,p){var v=this.constructor,b=g.call(this,f)||this;return b.token=p,b.resyncedTokens=[],Object.setPrototypeOf(b,v.prototype),Error.captureStackTrace&&Error.captureStackTrace(b,b.constructor),b}return y})(Error),u=(function(g){e(y,g);function y(f,p,v){var b=g.call(this,f,p)||this;return b.previousToken=v,b.name=n,b}return y})(l);i.MismatchedTokenException=u;var h=(function(g){e(y,g);function y(f,p,v){var b=g.call(this,f,p)||this;return b.previousToken=v,b.name=r,b}return y})(l);i.NoViableAltException=h;var d=(function(g){e(y,g);function y(f,p){var v=g.call(this,f,p)||this;return v.name=o,v}return y})(l);i.NotAllInputParsedException=d;var m=(function(g){e(y,g);function y(f,p,v){var b=g.call(this,f,p)||this;return b.previousToken=v,b.name=s,b}return y})(l);i.EarlyExitException=m}),mE=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.attemptInRepetitionRecovery=i.Recoverable=i.InRuleRecoveryException=i.IN_RULE_RECOVERY_EXCEPTION=i.EOF_FOLLOW_KEY=void 0;var e=aa(),t=Vt(),n=Rh(),r=fE(),s=ji();i.EOF_FOLLOW_KEY={},i.IN_RULE_RECOVERY_EXCEPTION="InRuleRecoveryException";function o(l){this.name=i.IN_RULE_RECOVERY_EXCEPTION,this.message=l}i.InRuleRecoveryException=o,o.prototype=Error.prototype;var a=(function(){function l(){}return l.prototype.initRecoverable=function(u){this.firstAfterRepMap={},this.resyncFollows={},this.recoveryEnabled=t.has(u,"recoveryEnabled")?u.recoveryEnabled:s.DEFAULT_PARSER_CONFIG.recoveryEnabled,this.recoveryEnabled&&(this.attemptInRepetitionRecovery=c)},l.prototype.getTokenToInsert=function(u){var h=e.createTokenInstance(u,"",NaN,NaN,NaN,NaN,NaN,NaN);return h.isInsertedInRecovery=!0,h},l.prototype.canTokenTypeBeInsertedInRecovery=function(u){return!0},l.prototype.tryInRepetitionRecovery=function(u,h,d,m){for(var g=this,y=this.findReSyncTokenType(),f=this.exportLexerState(),p=[],v=!1,b=this.LA(1),x=this.LA(1),_=function(){var T=g.LA(0),w=g.errorMessageProvider.buildMismatchTokenMessage({expected:m,actual:b,previous:T,ruleName:g.getCurrRuleFullName()}),A=new n.MismatchedTokenException(w,b,g.LA(0));A.resyncedTokens=t.dropRight(p),g.SAVE_ERROR(A)};!v;)if(this.tokenMatcher(x,m)){_();return}else if(d.call(this)){_(),u.apply(this,h);return}else this.tokenMatcher(x,y)?v=!0:(x=this.SKIP_TOKEN(),this.addToResyncTokens(x,p));this.importLexerState(f)},l.prototype.shouldInRepetitionRecoveryBeTried=function(u,h,d){return!(d===!1||u===void 0||h===void 0||this.tokenMatcher(this.LA(1),u)||this.isBackTracking()||this.canPerformInRuleRecovery(u,this.getFollowsForInRuleRecovery(u,h)))},l.prototype.getFollowsForInRuleRecovery=function(u,h){var d=this.getCurrentGrammarPath(u,h),m=this.getNextPossibleTokenTypes(d);return m},l.prototype.tryInRuleRecovery=function(u,h){if(this.canRecoverWithSingleTokenInsertion(u,h)){var d=this.getTokenToInsert(u);return d}if(this.canRecoverWithSingleTokenDeletion(u)){var m=this.SKIP_TOKEN();return this.consumeToken(),m}throw new o("sad sad panda")},l.prototype.canPerformInRuleRecovery=function(u,h){return this.canRecoverWithSingleTokenInsertion(u,h)||this.canRecoverWithSingleTokenDeletion(u)},l.prototype.canRecoverWithSingleTokenInsertion=function(u,h){var d=this;if(!this.canTokenTypeBeInsertedInRecovery(u)||t.isEmpty(h))return!1;var m=this.LA(1),g=t.find(h,function(y){return d.tokenMatcher(m,y)})!==void 0;return g},l.prototype.canRecoverWithSingleTokenDeletion=function(u){var h=this.tokenMatcher(this.LA(2),u);return h},l.prototype.isInCurrentRuleReSyncSet=function(u){var h=this.getCurrFollowKey(),d=this.getFollowSetFromFollowKey(h);return t.contains(d,u)},l.prototype.findReSyncTokenType=function(){for(var u=this.flattenFollowSet(),h=this.LA(1),d=2;;){var m=h.tokenType;if(t.contains(u,m))return m;h=this.LA(d),d++}},l.prototype.getCurrFollowKey=function(){if(this.RULE_STACK.length===1)return i.EOF_FOLLOW_KEY;var u=this.getLastExplicitRuleShortName(),h=this.getLastExplicitRuleOccurrenceIndex(),d=this.getPreviousExplicitRuleShortName();return{ruleName:this.shortRuleNameToFullName(u),idxInCallingRule:h,inRule:this.shortRuleNameToFullName(d)}},l.prototype.buildFullFollowKeyStack=function(){var u=this,h=this.RULE_STACK,d=this.RULE_OCCURRENCE_STACK;return t.map(h,function(m,g){return g===0?i.EOF_FOLLOW_KEY:{ruleName:u.shortRuleNameToFullName(m),idxInCallingRule:d[g],inRule:u.shortRuleNameToFullName(h[g-1])}})},l.prototype.flattenFollowSet=function(){var u=this,h=t.map(this.buildFullFollowKeyStack(),function(d){return u.getFollowSetFromFollowKey(d)});return t.flatten(h)},l.prototype.getFollowSetFromFollowKey=function(u){if(u===i.EOF_FOLLOW_KEY)return[e.EOF];var h=u.ruleName+u.idxInCallingRule+r.IN+u.inRule;return this.resyncFollows[h]},l.prototype.addToResyncTokens=function(u,h){return this.tokenMatcher(u,e.EOF)||h.push(u),h},l.prototype.reSyncTo=function(u){for(var h=[],d=this.LA(1);this.tokenMatcher(d,u)===!1;)d=this.SKIP_TOKEN(),this.addToResyncTokens(d,h);return t.dropRight(h)},l.prototype.attemptInRepetitionRecovery=function(u,h,d,m,g,y,f){},l.prototype.getCurrentGrammarPath=function(u,h){var d=this.getHumanReadableRuleStack(),m=t.cloneArr(this.RULE_OCCURRENCE_STACK),g={ruleStack:d,occurrenceStack:m,lastTok:u,lastTokOccurrence:h};return g},l.prototype.getHumanReadableRuleStack=function(){var u=this;return t.map(this.RULE_STACK,function(h){return u.shortRuleNameToFullName(h)})},l})();i.Recoverable=a;function c(l,u,h,d,m,g,y){var f=this.getKeyForAutomaticLookahead(d,m),p=this.firstAfterRepMap[f];if(p===void 0){var v=this.getCurrRuleFullName(),b=this.getGAstProductions()[v],x=new g(b,m);p=x.startWalking(),this.firstAfterRepMap[f]=p}var _=p.token,T=p.occurrence,w=p.isEndOfRule;this.RULE_STACK.length===1&&w&&_===void 0&&(_=e.EOF,T=1),this.shouldInRepetitionRecoveryBeTried(_,T,y)&&this.tryInRepetitionRecovery(l,u,h,_)}i.attemptInRepetitionRecovery=c}),Uy=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.getKeyForAutomaticLookahead=i.AT_LEAST_ONE_SEP_IDX=i.MANY_SEP_IDX=i.AT_LEAST_ONE_IDX=i.MANY_IDX=i.OPTION_IDX=i.OR_IDX=i.BITS_FOR_ALT_IDX=i.BITS_FOR_RULE_IDX=i.BITS_FOR_OCCURRENCE_IDX=i.BITS_FOR_METHOD_TYPE=void 0,i.BITS_FOR_METHOD_TYPE=4,i.BITS_FOR_OCCURRENCE_IDX=8,i.BITS_FOR_RULE_IDX=12,i.BITS_FOR_ALT_IDX=8,i.OR_IDX=1<<i.BITS_FOR_OCCURRENCE_IDX,i.OPTION_IDX=2<<i.BITS_FOR_OCCURRENCE_IDX,i.MANY_IDX=3<<i.BITS_FOR_OCCURRENCE_IDX,i.AT_LEAST_ONE_IDX=4<<i.BITS_FOR_OCCURRENCE_IDX,i.MANY_SEP_IDX=5<<i.BITS_FOR_OCCURRENCE_IDX,i.AT_LEAST_ONE_SEP_IDX=6<<i.BITS_FOR_OCCURRENCE_IDX;function e(n,r,s){return s|r|n}i.getKeyForAutomaticLookahead=e;var t=32-i.BITS_FOR_ALT_IDX}),DP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.LooksAhead=void 0;var e=Vp(),t=Vt(),n=ji(),r=Uy(),s=kp(),o=(function(){function a(){}return a.prototype.initLooksAhead=function(c){this.dynamicTokensEnabled=t.has(c,"dynamicTokensEnabled")?c.dynamicTokensEnabled:n.DEFAULT_PARSER_CONFIG.dynamicTokensEnabled,this.maxLookahead=t.has(c,"maxLookahead")?c.maxLookahead:n.DEFAULT_PARSER_CONFIG.maxLookahead,this.lookAheadFuncsCache=t.isES2015MapSupported()?new Map:[],t.isES2015MapSupported()?(this.getLaFuncFromCache=this.getLaFuncFromMap,this.setLaFuncCache=this.setLaFuncCacheUsingMap):(this.getLaFuncFromCache=this.getLaFuncFromObj,this.setLaFuncCache=this.setLaFuncUsingObj)},a.prototype.preComputeLookaheadFunctions=function(c){var l=this;t.forEach(c,function(u){l.TRACE_INIT(u.name+" Rule Lookahead",function(){var h=s.collectMethods(u),d=h.alternation,m=h.repetition,g=h.option,y=h.repetitionMandatory,f=h.repetitionMandatoryWithSeparator,p=h.repetitionWithSeparator;t.forEach(d,function(v){var b=v.idx===0?"":v.idx;l.TRACE_INIT(""+s.getProductionDslName(v)+b,function(){var x=e.buildLookaheadFuncForOr(v.idx,u,v.maxLookahead||l.maxLookahead,v.hasPredicates,l.dynamicTokensEnabled,l.lookAheadBuilderForAlternatives),_=r.getKeyForAutomaticLookahead(l.fullRuleNameToShort[u.name],r.OR_IDX,v.idx);l.setLaFuncCache(_,x)})}),t.forEach(m,function(v){l.computeLookaheadFunc(u,v.idx,r.MANY_IDX,e.PROD_TYPE.REPETITION,v.maxLookahead,s.getProductionDslName(v))}),t.forEach(g,function(v){l.computeLookaheadFunc(u,v.idx,r.OPTION_IDX,e.PROD_TYPE.OPTION,v.maxLookahead,s.getProductionDslName(v))}),t.forEach(y,function(v){l.computeLookaheadFunc(u,v.idx,r.AT_LEAST_ONE_IDX,e.PROD_TYPE.REPETITION_MANDATORY,v.maxLookahead,s.getProductionDslName(v))}),t.forEach(f,function(v){l.computeLookaheadFunc(u,v.idx,r.AT_LEAST_ONE_SEP_IDX,e.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,v.maxLookahead,s.getProductionDslName(v))}),t.forEach(p,function(v){l.computeLookaheadFunc(u,v.idx,r.MANY_SEP_IDX,e.PROD_TYPE.REPETITION_WITH_SEPARATOR,v.maxLookahead,s.getProductionDslName(v))})})})},a.prototype.computeLookaheadFunc=function(c,l,u,h,d,m){var g=this;this.TRACE_INIT(""+m+(l===0?"":l),function(){var y=e.buildLookaheadFuncForOptionalProd(l,c,d||g.maxLookahead,g.dynamicTokensEnabled,h,g.lookAheadBuilderForOptional),f=r.getKeyForAutomaticLookahead(g.fullRuleNameToShort[c.name],u,l);g.setLaFuncCache(f,y)})},a.prototype.lookAheadBuilderForOptional=function(c,l,u){return e.buildSingleAlternativeLookaheadFunction(c,l,u)},a.prototype.lookAheadBuilderForAlternatives=function(c,l,u,h){return e.buildAlternativesLookAheadFunc(c,l,u,h)},a.prototype.getKeyForAutomaticLookahead=function(c,l){var u=this.getLastExplicitRuleShortName();return r.getKeyForAutomaticLookahead(u,c,l)},a.prototype.getLaFuncFromCache=function(c){},a.prototype.getLaFuncFromMap=function(c){return this.lookAheadFuncsCache.get(c)},a.prototype.getLaFuncFromObj=function(c){return this.lookAheadFuncsCache[c]},a.prototype.setLaFuncCache=function(c,l){},a.prototype.setLaFuncCacheUsingMap=function(c,l){this.lookAheadFuncsCache.set(c,l)},a.prototype.setLaFuncUsingObj=function(c,l){this.lookAheadFuncsCache[c]=l},a})();i.LooksAhead=o}),FP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.addNoneTerminalToCst=i.addTerminalToCst=i.setNodeLocationFull=i.setNodeLocationOnlyOffset=void 0;function e(s,o){isNaN(s.startOffset)===!0?(s.startOffset=o.startOffset,s.endOffset=o.endOffset):s.endOffset<o.endOffset&&(s.endOffset=o.endOffset)}i.setNodeLocationOnlyOffset=e;function t(s,o){isNaN(s.startOffset)===!0?(s.startOffset=o.startOffset,s.startColumn=o.startColumn,s.startLine=o.startLine,s.endOffset=o.endOffset,s.endColumn=o.endColumn,s.endLine=o.endLine):s.endOffset<o.endOffset&&(s.endOffset=o.endOffset,s.endColumn=o.endColumn,s.endLine=o.endLine)}i.setNodeLocationFull=t;function n(s,o,a){s.children[a]===void 0?s.children[a]=[o]:s.children[a].push(o)}i.addTerminalToCst=n;function r(s,o,a){s.children[o]===void 0?s.children[o]=[a]:s.children[o].push(a)}i.addNoneTerminalToCst=r}),gE=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.defineNameProp=i.functionName=i.classNameFromInstance=void 0;var e=Vt();function t(o){return r(o.constructor)}i.classNameFromInstance=t;var n="name";function r(o){var a=o.name;return a||"anonymous"}i.functionName=r;function s(o,a){var c=Object.getOwnPropertyDescriptor(o,n);return e.isUndefined(c)||c.configurable?(Object.defineProperty(o,n,{enumerable:!1,configurable:!0,writable:!1,value:a}),!0):!1}i.defineNameProp=s}),UP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.validateRedundantMethods=i.validateMissingCstMethods=i.validateVisitor=i.CstVisitorDefinitionError=i.createBaseVisitorConstructorWithDefaults=i.createBaseSemanticVisitorConstructor=i.defaultVisit=void 0;var e=Vt(),t=gE();function n(h,d){for(var m=e.keys(h),g=m.length,y=0;y<g;y++)for(var f=m[y],p=h[f],v=p.length,b=0;b<v;b++){var x=p[b];x.tokenTypeIdx===void 0&&this[x.name](x.children,d)}}i.defaultVisit=n;function r(h,d){var m=function(){};t.defineNameProp(m,h+"BaseSemantics");var g={visit:function(y,f){if(e.isArray(y)&&(y=y[0]),!e.isUndefined(y))return this[y.name](y.children,f)},validateVisitor:function(){var y=a(this,d);if(!e.isEmpty(y)){var f=e.map(y,function(p){return p.msg});throw Error("Errors Detected in CST Visitor <"+t.functionName(this.constructor)+`>:
	`+(""+f.join(`

`).replace(/\n/g,`
	`)))}}};return m.prototype=g,m.prototype.constructor=m,m._RULE_NAMES=d,m}i.createBaseSemanticVisitorConstructor=r;function s(h,d,m){var g=function(){};t.defineNameProp(g,h+"BaseSemanticsWithDefaults");var y=Object.create(m.prototype);return e.forEach(d,function(f){y[f]=n}),g.prototype=y,g.prototype.constructor=g,g}i.createBaseVisitorConstructorWithDefaults=s;var o;(function(h){h[h.REDUNDANT_METHOD=0]="REDUNDANT_METHOD",h[h.MISSING_METHOD=1]="MISSING_METHOD"})(o=i.CstVisitorDefinitionError||(i.CstVisitorDefinitionError={}));function a(h,d){var m=c(h,d),g=u(h,d);return m.concat(g)}i.validateVisitor=a;function c(h,d){var m=e.map(d,function(g){if(!e.isFunction(h[g]))return{msg:"Missing visitor method: <"+g+"> on "+t.functionName(h.constructor)+" CST Visitor.",type:o.MISSING_METHOD,methodName:g}});return e.compact(m)}i.validateMissingCstMethods=c;var l=["constructor","visit","validateVisitor"];function u(h,d){var m=[];for(var g in h)e.isFunction(h[g])&&!e.contains(l,g)&&!e.contains(d,g)&&m.push({msg:"Redundant visitor method: <"+g+"> on "+t.functionName(h.constructor)+` CST Visitor
There is no Grammar Rule corresponding to this method's name.
`,type:o.REDUNDANT_METHOD,methodName:g});return m}i.validateRedundantMethods=u}),kP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.TreeBuilder=void 0;var e=FP(),t=Vt(),n=UP(),r=ji(),s=(function(){function o(){}return o.prototype.initTreeBuilder=function(a){if(this.CST_STACK=[],this.outputCst=a.outputCst,this.nodeLocationTracking=t.has(a,"nodeLocationTracking")?a.nodeLocationTracking:r.DEFAULT_PARSER_CONFIG.nodeLocationTracking,!this.outputCst)this.cstInvocationStateUpdate=t.NOOP,this.cstFinallyStateUpdate=t.NOOP,this.cstPostTerminal=t.NOOP,this.cstPostNonTerminal=t.NOOP,this.cstPostRule=t.NOOP;else if(/full/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationFull,this.setNodeLocationFromNode=e.setNodeLocationFull,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationFullRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleFull,this.setInitialNodeLocation=this.setInitialNodeLocationFullRegular);else if(/onlyOffset/i.test(this.nodeLocationTracking))this.recoveryEnabled?(this.setNodeLocationFromToken=e.setNodeLocationOnlyOffset,this.setNodeLocationFromNode=e.setNodeLocationOnlyOffset,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRecovery):(this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=this.cstPostRuleOnlyOffset,this.setInitialNodeLocation=this.setInitialNodeLocationOnlyOffsetRegular);else if(/none/i.test(this.nodeLocationTracking))this.setNodeLocationFromToken=t.NOOP,this.setNodeLocationFromNode=t.NOOP,this.cstPostRule=t.NOOP,this.setInitialNodeLocation=t.NOOP;else throw Error('Invalid <nodeLocationTracking> config option: "'+a.nodeLocationTracking+'"')},o.prototype.setInitialNodeLocationOnlyOffsetRecovery=function(a){a.location={startOffset:NaN,endOffset:NaN}},o.prototype.setInitialNodeLocationOnlyOffsetRegular=function(a){a.location={startOffset:this.LA(1).startOffset,endOffset:NaN}},o.prototype.setInitialNodeLocationFullRecovery=function(a){a.location={startOffset:NaN,startLine:NaN,startColumn:NaN,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.setInitialNodeLocationFullRegular=function(a){var c=this.LA(1);a.location={startOffset:c.startOffset,startLine:c.startLine,startColumn:c.startColumn,endOffset:NaN,endLine:NaN,endColumn:NaN}},o.prototype.cstInvocationStateUpdate=function(a,c){var l={name:a,children:{}};this.setInitialNodeLocation(l),this.CST_STACK.push(l)},o.prototype.cstFinallyStateUpdate=function(){this.CST_STACK.pop()},o.prototype.cstPostRuleFull=function(a){var c=this.LA(0),l=a.location;l.startOffset<=c.startOffset?(l.endOffset=c.endOffset,l.endLine=c.endLine,l.endColumn=c.endColumn):(l.startOffset=NaN,l.startLine=NaN,l.startColumn=NaN)},o.prototype.cstPostRuleOnlyOffset=function(a){var c=this.LA(0),l=a.location;l.startOffset<=c.startOffset?l.endOffset=c.endOffset:l.startOffset=NaN},o.prototype.cstPostTerminal=function(a,c){var l=this.CST_STACK[this.CST_STACK.length-1];e.addTerminalToCst(l,c,a),this.setNodeLocationFromToken(l.location,c)},o.prototype.cstPostNonTerminal=function(a,c){var l=this.CST_STACK[this.CST_STACK.length-1];e.addNoneTerminalToCst(l,c,a),this.setNodeLocationFromNode(l.location,a.location)},o.prototype.getBaseCstVisitorConstructor=function(){if(t.isUndefined(this.baseCstVisitorConstructor)){var a=n.createBaseSemanticVisitorConstructor(this.className,t.keys(this.gastProductionsCache));return this.baseCstVisitorConstructor=a,a}return this.baseCstVisitorConstructor},o.prototype.getBaseCstVisitorConstructorWithDefaults=function(){if(t.isUndefined(this.baseCstVisitorWithDefaultsConstructor)){var a=n.createBaseVisitorConstructorWithDefaults(this.className,t.keys(this.gastProductionsCache),this.getBaseCstVisitorConstructor());return this.baseCstVisitorWithDefaultsConstructor=a,a}return this.baseCstVisitorWithDefaultsConstructor},o.prototype.getLastExplicitRuleShortName=function(){var a=this.RULE_STACK;return a[a.length-1]},o.prototype.getPreviousExplicitRuleShortName=function(){var a=this.RULE_STACK;return a[a.length-2]},o.prototype.getLastExplicitRuleOccurrenceIndex=function(){var a=this.RULE_OCCURRENCE_STACK;return a[a.length-1]},o})();i.TreeBuilder=s}),BP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.LexerAdapter=void 0;var e=ji(),t=(function(){function n(){}return n.prototype.initLexerAdapter=function(){this.tokVector=[],this.tokVectorLength=0,this.currIdx=-1},Object.defineProperty(n.prototype,"input",{get:function(){return this.tokVector},set:function(r){if(this.selfAnalysisDone!==!0)throw Error("Missing <performSelfAnalysis> invocation at the end of the Parser's constructor.");this.reset(),this.tokVector=r,this.tokVectorLength=r.length},enumerable:!1,configurable:!0}),n.prototype.SKIP_TOKEN=function(){return this.currIdx<=this.tokVector.length-2?(this.consumeToken(),this.LA(1)):e.END_OF_FILE},n.prototype.LA=function(r){var s=this.currIdx+r;return s<0||this.tokVectorLength<=s?e.END_OF_FILE:this.tokVector[s]},n.prototype.consumeToken=function(){this.currIdx++},n.prototype.exportLexerState=function(){return this.currIdx},n.prototype.importLexerState=function(r){this.currIdx=r},n.prototype.resetLexerState=function(){this.currIdx=-1},n.prototype.moveToTerminatedState=function(){this.currIdx=this.tokVector.length-1},n.prototype.getLexerPosition=function(){return this.exportLexerState()},n})();i.LexerAdapter=t}),zP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.RecognizerApi=void 0;var e=Vt(),t=Rh(),n=ji(),r=Bp(),s=pE(),o=Bi(),a=(function(){function c(){}return c.prototype.ACTION=function(l){return l.call(this)},c.prototype.consume=function(l,u,h){return this.consumeInternal(u,l,h)},c.prototype.subrule=function(l,u,h){return this.subruleInternal(u,l,h)},c.prototype.option=function(l,u){return this.optionInternal(u,l)},c.prototype.or=function(l,u){return this.orInternal(u,l)},c.prototype.many=function(l,u){return this.manyInternal(l,u)},c.prototype.atLeastOne=function(l,u){return this.atLeastOneInternal(l,u)},c.prototype.CONSUME=function(l,u){return this.consumeInternal(l,0,u)},c.prototype.CONSUME1=function(l,u){return this.consumeInternal(l,1,u)},c.prototype.CONSUME2=function(l,u){return this.consumeInternal(l,2,u)},c.prototype.CONSUME3=function(l,u){return this.consumeInternal(l,3,u)},c.prototype.CONSUME4=function(l,u){return this.consumeInternal(l,4,u)},c.prototype.CONSUME5=function(l,u){return this.consumeInternal(l,5,u)},c.prototype.CONSUME6=function(l,u){return this.consumeInternal(l,6,u)},c.prototype.CONSUME7=function(l,u){return this.consumeInternal(l,7,u)},c.prototype.CONSUME8=function(l,u){return this.consumeInternal(l,8,u)},c.prototype.CONSUME9=function(l,u){return this.consumeInternal(l,9,u)},c.prototype.SUBRULE=function(l,u){return this.subruleInternal(l,0,u)},c.prototype.SUBRULE1=function(l,u){return this.subruleInternal(l,1,u)},c.prototype.SUBRULE2=function(l,u){return this.subruleInternal(l,2,u)},c.prototype.SUBRULE3=function(l,u){return this.subruleInternal(l,3,u)},c.prototype.SUBRULE4=function(l,u){return this.subruleInternal(l,4,u)},c.prototype.SUBRULE5=function(l,u){return this.subruleInternal(l,5,u)},c.prototype.SUBRULE6=function(l,u){return this.subruleInternal(l,6,u)},c.prototype.SUBRULE7=function(l,u){return this.subruleInternal(l,7,u)},c.prototype.SUBRULE8=function(l,u){return this.subruleInternal(l,8,u)},c.prototype.SUBRULE9=function(l,u){return this.subruleInternal(l,9,u)},c.prototype.OPTION=function(l){return this.optionInternal(l,0)},c.prototype.OPTION1=function(l){return this.optionInternal(l,1)},c.prototype.OPTION2=function(l){return this.optionInternal(l,2)},c.prototype.OPTION3=function(l){return this.optionInternal(l,3)},c.prototype.OPTION4=function(l){return this.optionInternal(l,4)},c.prototype.OPTION5=function(l){return this.optionInternal(l,5)},c.prototype.OPTION6=function(l){return this.optionInternal(l,6)},c.prototype.OPTION7=function(l){return this.optionInternal(l,7)},c.prototype.OPTION8=function(l){return this.optionInternal(l,8)},c.prototype.OPTION9=function(l){return this.optionInternal(l,9)},c.prototype.OR=function(l){return this.orInternal(l,0)},c.prototype.OR1=function(l){return this.orInternal(l,1)},c.prototype.OR2=function(l){return this.orInternal(l,2)},c.prototype.OR3=function(l){return this.orInternal(l,3)},c.prototype.OR4=function(l){return this.orInternal(l,4)},c.prototype.OR5=function(l){return this.orInternal(l,5)},c.prototype.OR6=function(l){return this.orInternal(l,6)},c.prototype.OR7=function(l){return this.orInternal(l,7)},c.prototype.OR8=function(l){return this.orInternal(l,8)},c.prototype.OR9=function(l){return this.orInternal(l,9)},c.prototype.MANY=function(l){this.manyInternal(0,l)},c.prototype.MANY1=function(l){this.manyInternal(1,l)},c.prototype.MANY2=function(l){this.manyInternal(2,l)},c.prototype.MANY3=function(l){this.manyInternal(3,l)},c.prototype.MANY4=function(l){this.manyInternal(4,l)},c.prototype.MANY5=function(l){this.manyInternal(5,l)},c.prototype.MANY6=function(l){this.manyInternal(6,l)},c.prototype.MANY7=function(l){this.manyInternal(7,l)},c.prototype.MANY8=function(l){this.manyInternal(8,l)},c.prototype.MANY9=function(l){this.manyInternal(9,l)},c.prototype.MANY_SEP=function(l){this.manySepFirstInternal(0,l)},c.prototype.MANY_SEP1=function(l){this.manySepFirstInternal(1,l)},c.prototype.MANY_SEP2=function(l){this.manySepFirstInternal(2,l)},c.prototype.MANY_SEP3=function(l){this.manySepFirstInternal(3,l)},c.prototype.MANY_SEP4=function(l){this.manySepFirstInternal(4,l)},c.prototype.MANY_SEP5=function(l){this.manySepFirstInternal(5,l)},c.prototype.MANY_SEP6=function(l){this.manySepFirstInternal(6,l)},c.prototype.MANY_SEP7=function(l){this.manySepFirstInternal(7,l)},c.prototype.MANY_SEP8=function(l){this.manySepFirstInternal(8,l)},c.prototype.MANY_SEP9=function(l){this.manySepFirstInternal(9,l)},c.prototype.AT_LEAST_ONE=function(l){this.atLeastOneInternal(0,l)},c.prototype.AT_LEAST_ONE1=function(l){return this.atLeastOneInternal(1,l)},c.prototype.AT_LEAST_ONE2=function(l){this.atLeastOneInternal(2,l)},c.prototype.AT_LEAST_ONE3=function(l){this.atLeastOneInternal(3,l)},c.prototype.AT_LEAST_ONE4=function(l){this.atLeastOneInternal(4,l)},c.prototype.AT_LEAST_ONE5=function(l){this.atLeastOneInternal(5,l)},c.prototype.AT_LEAST_ONE6=function(l){this.atLeastOneInternal(6,l)},c.prototype.AT_LEAST_ONE7=function(l){this.atLeastOneInternal(7,l)},c.prototype.AT_LEAST_ONE8=function(l){this.atLeastOneInternal(8,l)},c.prototype.AT_LEAST_ONE9=function(l){this.atLeastOneInternal(9,l)},c.prototype.AT_LEAST_ONE_SEP=function(l){this.atLeastOneSepFirstInternal(0,l)},c.prototype.AT_LEAST_ONE_SEP1=function(l){this.atLeastOneSepFirstInternal(1,l)},c.prototype.AT_LEAST_ONE_SEP2=function(l){this.atLeastOneSepFirstInternal(2,l)},c.prototype.AT_LEAST_ONE_SEP3=function(l){this.atLeastOneSepFirstInternal(3,l)},c.prototype.AT_LEAST_ONE_SEP4=function(l){this.atLeastOneSepFirstInternal(4,l)},c.prototype.AT_LEAST_ONE_SEP5=function(l){this.atLeastOneSepFirstInternal(5,l)},c.prototype.AT_LEAST_ONE_SEP6=function(l){this.atLeastOneSepFirstInternal(6,l)},c.prototype.AT_LEAST_ONE_SEP7=function(l){this.atLeastOneSepFirstInternal(7,l)},c.prototype.AT_LEAST_ONE_SEP8=function(l){this.atLeastOneSepFirstInternal(8,l)},c.prototype.AT_LEAST_ONE_SEP9=function(l){this.atLeastOneSepFirstInternal(9,l)},c.prototype.RULE=function(l,u,h){if(h===void 0&&(h=n.DEFAULT_RULE_CONFIG),e.contains(this.definedRulesNames,l)){var d=r.defaultGrammarValidatorErrorProvider.buildDuplicateRuleNameError({topLevelRule:l,grammarName:this.className}),m={message:d,type:n.ParserDefinitionErrorType.DUPLICATE_RULE_NAME,ruleName:l};this.definitionErrors.push(m)}this.definedRulesNames.push(l);var g=this.defineRule(l,u,h);return this[l]=g,g},c.prototype.OVERRIDE_RULE=function(l,u,h){h===void 0&&(h=n.DEFAULT_RULE_CONFIG);var d=[];d=d.concat(s.validateRuleIsOverridden(l,this.definedRulesNames,this.className)),this.definitionErrors=this.definitionErrors.concat(d);var m=this.defineRule(l,u,h);return this[l]=m,m},c.prototype.BACKTRACK=function(l,u){return function(){this.isBackTrackingStack.push(1);var h=this.saveRecogState();try{return l.apply(this,u),!0}catch(d){if(t.isRecognitionException(d))return!1;throw d}finally{this.reloadRecogState(h),this.isBackTrackingStack.pop()}}},c.prototype.getGAstProductions=function(){return this.gastProductionsCache},c.prototype.getSerializedGastProductions=function(){return o.serializeGrammar(e.values(this.gastProductionsCache))},c})();i.RecognizerApi=a}),VP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.RecognizerEngine=void 0;var e=Vt(),t=Uy(),n=Rh(),r=Vp(),s=zp(),o=ji(),a=mE(),c=aa(),l=Ah(),u=gE(),h=(function(){function d(){}return d.prototype.initRecognizerEngine=function(m,g){if(this.className=u.classNameFromInstance(this),this.shortRuleNameToFull={},this.fullRuleNameToShort={},this.ruleShortNameIdx=256,this.tokenMatcher=l.tokenStructuredMatcherNoCategories,this.definedRulesNames=[],this.tokensMap={},this.isBackTrackingStack=[],this.RULE_STACK=[],this.RULE_OCCURRENCE_STACK=[],this.gastProductionsCache={},e.has(g,"serializedGrammar"))throw Error(`The Parser's configuration can no longer contain a <serializedGrammar> property.
	See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_6-0-0
	For Further details.`);if(e.isArray(m)){if(e.isEmpty(m))throw Error(`A Token Vocabulary cannot be empty.
	Note that the first argument for the parser constructor
	is no longer a Token vector (since v4.0).`);if(typeof m[0].startOffset=="number")throw Error(`The Parser constructor no longer accepts a token vector as the first argument.
	See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_4-0-0
	For Further details.`)}if(e.isArray(m))this.tokensMap=e.reduce(m,function(v,b){return v[b.name]=b,v},{});else if(e.has(m,"modes")&&e.every(e.flatten(e.values(m.modes)),l.isTokenType)){var y=e.flatten(e.values(m.modes)),f=e.uniq(y);this.tokensMap=e.reduce(f,function(v,b){return v[b.name]=b,v},{})}else if(e.isObject(m))this.tokensMap=e.cloneObj(m);else throw new Error("<tokensDictionary> argument must be An Array of Token constructors, A dictionary of Token constructors or an IMultiModeLexerDefinition");this.tokensMap.EOF=c.EOF;var p=e.every(e.values(m),function(v){return e.isEmpty(v.categoryMatches)});this.tokenMatcher=p?l.tokenStructuredMatcherNoCategories:l.tokenStructuredMatcher,l.augmentTokenTypes(e.values(this.tokensMap))},d.prototype.defineRule=function(m,g,y){if(this.selfAnalysisDone)throw Error("Grammar rule <"+m+`> may not be defined after the 'performSelfAnalysis' method has been called'
Make sure that all grammar rule definitions are done before 'performSelfAnalysis' is called.`);var f=e.has(y,"resyncEnabled")?y.resyncEnabled:o.DEFAULT_RULE_CONFIG.resyncEnabled,p=e.has(y,"recoveryValueFunc")?y.recoveryValueFunc:o.DEFAULT_RULE_CONFIG.recoveryValueFunc,v=this.ruleShortNameIdx<<t.BITS_FOR_METHOD_TYPE+t.BITS_FOR_OCCURRENCE_IDX;this.ruleShortNameIdx++,this.shortRuleNameToFull[v]=m,this.fullRuleNameToShort[m]=v;function b(T){try{if(this.outputCst===!0){g.apply(this,T);var w=this.CST_STACK[this.CST_STACK.length-1];return this.cstPostRule(w),w}else return g.apply(this,T)}catch(A){return this.invokeRuleCatch(A,f,p)}finally{this.ruleFinallyStateUpdate()}}var x=function(T,w){return T===void 0&&(T=0),this.ruleInvocationStateUpdate(v,m,T),b.call(this,w)},_="ruleName";return x[_]=m,x.originalGrammarAction=g,x},d.prototype.invokeRuleCatch=function(m,g,y){var f=this.RULE_STACK.length===1,p=g&&!this.isBackTracking()&&this.recoveryEnabled;if(n.isRecognitionException(m)){var v=m;if(p){var b=this.findReSyncTokenType();if(this.isInCurrentRuleReSyncSet(b))if(v.resyncedTokens=this.reSyncTo(b),this.outputCst){var x=this.CST_STACK[this.CST_STACK.length-1];return x.recoveredNode=!0,x}else return y();else{if(this.outputCst){var x=this.CST_STACK[this.CST_STACK.length-1];x.recoveredNode=!0,v.partialCstResult=x}throw v}}else{if(f)return this.moveToTerminatedState(),y();throw v}}else throw m},d.prototype.optionInternal=function(m,g){var y=this.getKeyForAutomaticLookahead(t.OPTION_IDX,g);return this.optionInternalLogic(m,g,y)},d.prototype.optionInternalLogic=function(m,g,y){var f=this,p=this.getLaFuncFromCache(y),v,b;if(m.DEF!==void 0){if(v=m.DEF,b=m.GATE,b!==void 0){var x=p;p=function(){return b.call(f)&&x.call(f)}}}else v=m;if(p.call(this)===!0)return v.call(this)},d.prototype.atLeastOneInternal=function(m,g){var y=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_IDX,m);return this.atLeastOneInternalLogic(m,g,y)},d.prototype.atLeastOneInternalLogic=function(m,g,y){var f=this,p=this.getLaFuncFromCache(y),v,b;if(g.DEF!==void 0){if(v=g.DEF,b=g.GATE,b!==void 0){var x=p;p=function(){return b.call(f)&&x.call(f)}}}else v=g;if(p.call(this)===!0)for(var _=this.doSingleRepetition(v);p.call(this)===!0&&_===!0;)_=this.doSingleRepetition(v);else throw this.raiseEarlyExitException(m,r.PROD_TYPE.REPETITION_MANDATORY,g.ERR_MSG);this.attemptInRepetitionRecovery(this.atLeastOneInternal,[m,g],p,t.AT_LEAST_ONE_IDX,m,s.NextTerminalAfterAtLeastOneWalker)},d.prototype.atLeastOneSepFirstInternal=function(m,g){var y=this.getKeyForAutomaticLookahead(t.AT_LEAST_ONE_SEP_IDX,m);this.atLeastOneSepFirstInternalLogic(m,g,y)},d.prototype.atLeastOneSepFirstInternalLogic=function(m,g,y){var f=this,p=g.DEF,v=g.SEP,b=this.getLaFuncFromCache(y);if(b.call(this)===!0){p.call(this);for(var x=function(){return f.tokenMatcher(f.LA(1),v)};this.tokenMatcher(this.LA(1),v)===!0;)this.CONSUME(v),p.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[m,v,x,p,s.NextTerminalAfterAtLeastOneSepWalker],x,t.AT_LEAST_ONE_SEP_IDX,m,s.NextTerminalAfterAtLeastOneSepWalker)}else throw this.raiseEarlyExitException(m,r.PROD_TYPE.REPETITION_MANDATORY_WITH_SEPARATOR,g.ERR_MSG)},d.prototype.manyInternal=function(m,g){var y=this.getKeyForAutomaticLookahead(t.MANY_IDX,m);return this.manyInternalLogic(m,g,y)},d.prototype.manyInternalLogic=function(m,g,y){var f=this,p=this.getLaFuncFromCache(y),v,b;if(g.DEF!==void 0){if(v=g.DEF,b=g.GATE,b!==void 0){var x=p;p=function(){return b.call(f)&&x.call(f)}}}else v=g;for(var _=!0;p.call(this)===!0&&_===!0;)_=this.doSingleRepetition(v);this.attemptInRepetitionRecovery(this.manyInternal,[m,g],p,t.MANY_IDX,m,s.NextTerminalAfterManyWalker,_)},d.prototype.manySepFirstInternal=function(m,g){var y=this.getKeyForAutomaticLookahead(t.MANY_SEP_IDX,m);this.manySepFirstInternalLogic(m,g,y)},d.prototype.manySepFirstInternalLogic=function(m,g,y){var f=this,p=g.DEF,v=g.SEP,b=this.getLaFuncFromCache(y);if(b.call(this)===!0){p.call(this);for(var x=function(){return f.tokenMatcher(f.LA(1),v)};this.tokenMatcher(this.LA(1),v)===!0;)this.CONSUME(v),p.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[m,v,x,p,s.NextTerminalAfterManySepWalker],x,t.MANY_SEP_IDX,m,s.NextTerminalAfterManySepWalker)}},d.prototype.repetitionSepSecondInternal=function(m,g,y,f,p){for(;y();)this.CONSUME(g),f.call(this);this.attemptInRepetitionRecovery(this.repetitionSepSecondInternal,[m,g,y,f,p],y,t.AT_LEAST_ONE_SEP_IDX,m,p)},d.prototype.doSingleRepetition=function(m){var g=this.getLexerPosition();m.call(this);var y=this.getLexerPosition();return y>g},d.prototype.orInternal=function(m,g){var y=this.getKeyForAutomaticLookahead(t.OR_IDX,g),f=e.isArray(m)?m:m.DEF,p=this.getLaFuncFromCache(y),v=p.call(this,f);if(v!==void 0){var b=f[v];return b.ALT.call(this)}this.raiseNoAltException(g,m.ERR_MSG)},d.prototype.ruleFinallyStateUpdate=function(){if(this.RULE_STACK.pop(),this.RULE_OCCURRENCE_STACK.pop(),this.cstFinallyStateUpdate(),this.RULE_STACK.length===0&&this.isAtEndOfInput()===!1){var m=this.LA(1),g=this.errorMessageProvider.buildNotAllInputParsedMessage({firstRedundant:m,ruleName:this.getCurrRuleFullName()});this.SAVE_ERROR(new n.NotAllInputParsedException(g,m))}},d.prototype.subruleInternal=function(m,g,y){var f;try{var p=y!==void 0?y.ARGS:void 0;return f=m.call(this,g,p),this.cstPostNonTerminal(f,y!==void 0&&y.LABEL!==void 0?y.LABEL:m.ruleName),f}catch(v){this.subruleInternalError(v,y,m.ruleName)}},d.prototype.subruleInternalError=function(m,g,y){throw n.isRecognitionException(m)&&m.partialCstResult!==void 0&&(this.cstPostNonTerminal(m.partialCstResult,g!==void 0&&g.LABEL!==void 0?g.LABEL:y),delete m.partialCstResult),m},d.prototype.consumeInternal=function(m,g,y){var f;try{var p=this.LA(1);this.tokenMatcher(p,m)===!0?(this.consumeToken(),f=p):this.consumeInternalError(m,p,y)}catch(v){f=this.consumeInternalRecovery(m,g,v)}return this.cstPostTerminal(y!==void 0&&y.LABEL!==void 0?y.LABEL:m.name,f),f},d.prototype.consumeInternalError=function(m,g,y){var f,p=this.LA(0);throw y!==void 0&&y.ERR_MSG?f=y.ERR_MSG:f=this.errorMessageProvider.buildMismatchTokenMessage({expected:m,actual:g,previous:p,ruleName:this.getCurrRuleFullName()}),this.SAVE_ERROR(new n.MismatchedTokenException(f,g,p))},d.prototype.consumeInternalRecovery=function(m,g,y){if(this.recoveryEnabled&&y.name==="MismatchedTokenException"&&!this.isBackTracking()){var f=this.getFollowsForInRuleRecovery(m,g);try{return this.tryInRuleRecovery(m,f)}catch(p){throw p.name===a.IN_RULE_RECOVERY_EXCEPTION?y:p}}else throw y},d.prototype.saveRecogState=function(){var m=this.errors,g=e.cloneArr(this.RULE_STACK);return{errors:m,lexerState:this.exportLexerState(),RULE_STACK:g,CST_STACK:this.CST_STACK}},d.prototype.reloadRecogState=function(m){this.errors=m.errors,this.importLexerState(m.lexerState),this.RULE_STACK=m.RULE_STACK},d.prototype.ruleInvocationStateUpdate=function(m,g,y){this.RULE_OCCURRENCE_STACK.push(y),this.RULE_STACK.push(m),this.cstInvocationStateUpdate(g,m)},d.prototype.isBackTracking=function(){return this.isBackTrackingStack.length!==0},d.prototype.getCurrRuleFullName=function(){var m=this.getLastExplicitRuleShortName();return this.shortRuleNameToFull[m]},d.prototype.shortRuleNameToFullName=function(m){return this.shortRuleNameToFull[m]},d.prototype.isAtEndOfInput=function(){return this.tokenMatcher(this.LA(1),c.EOF)},d.prototype.reset=function(){this.resetLexerState(),this.isBackTrackingStack=[],this.errors=[],this.RULE_STACK=[],this.CST_STACK=[],this.RULE_OCCURRENCE_STACK=[]},d})();i.RecognizerEngine=h}),HP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ErrorHandler=void 0;var e=Rh(),t=Vt(),n=Vp(),r=ji(),s=(function(){function o(){}return o.prototype.initErrorHandler=function(a){this._errors=[],this.errorMessageProvider=t.has(a,"errorMessageProvider")?a.errorMessageProvider:r.DEFAULT_PARSER_CONFIG.errorMessageProvider},o.prototype.SAVE_ERROR=function(a){if(e.isRecognitionException(a))return a.context={ruleStack:this.getHumanReadableRuleStack(),ruleOccurrenceStack:t.cloneArr(this.RULE_OCCURRENCE_STACK)},this._errors.push(a),a;throw Error("Trying to save an Error which is not a RecognitionException")},Object.defineProperty(o.prototype,"errors",{get:function(){return t.cloneArr(this._errors)},set:function(a){this._errors=a},enumerable:!1,configurable:!0}),o.prototype.raiseEarlyExitException=function(a,c,l){for(var u=this.getCurrRuleFullName(),h=this.getGAstProductions()[u],d=n.getLookaheadPathsForOptionalProd(a,h,c,this.maxLookahead),m=d[0],g=[],y=1;y<=this.maxLookahead;y++)g.push(this.LA(y));var f=this.errorMessageProvider.buildEarlyExitMessage({expectedIterationPaths:m,actual:g,previous:this.LA(0),customUserDescription:l,ruleName:u});throw this.SAVE_ERROR(new e.EarlyExitException(f,this.LA(1),this.LA(0)))},o.prototype.raiseNoAltException=function(a,c){for(var l=this.getCurrRuleFullName(),u=this.getGAstProductions()[l],h=n.getLookaheadPathsForOr(a,u,this.maxLookahead),d=[],m=1;m<=this.maxLookahead;m++)d.push(this.LA(m));var g=this.LA(0),y=this.errorMessageProvider.buildNoViableAltMessage({expectedPathsPerAlt:h,actual:d,previous:g,customUserDescription:c,ruleName:this.getCurrRuleFullName()});throw this.SAVE_ERROR(new e.NoViableAltException(y,this.LA(1),g))},o})();i.ErrorHandler=s}),GP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.ContentAssist=void 0;var e=zp(),t=Vt(),n=(function(){function r(){}return r.prototype.initContentAssist=function(){},r.prototype.computeContentAssist=function(s,o){var a=this.gastProductionsCache[s];if(t.isUndefined(a))throw Error("Rule ->"+s+"<- does not exist in this grammar.");return e.nextPossibleTokensAfter([a],o,this.tokenMatcher,this.maxLookahead)},r.prototype.getNextPossibleTokenTypes=function(s){var o=t.first(s.ruleStack),a=this.getGAstProductions(),c=a[o],l=new e.NextAfterTokenWalker(c,s).startWalking();return l},r})();i.ContentAssist=n}),WP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.GastRecorder=void 0;var e=Vt(),t=Bi(),n=Up(),r=Ah(),s=aa(),o=ji(),a=Uy(),c={description:"This Object indicates the Parser is during Recording Phase"};Object.freeze(c);var l=!0,u=Math.pow(2,a.BITS_FOR_OCCURRENCE_IDX)-1,h=s.createToken({name:"RECORDING_PHASE_TOKEN",pattern:n.Lexer.NA});r.augmentTokenTypes([h]);var d=s.createTokenInstance(h,`This IToken indicates the Parser is in Recording Phase
	See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,-1,-1,-1,-1,-1,-1);Object.freeze(d);var m={name:`This CSTNode indicates the Parser is in Recording Phase
	See: https://chevrotain.io/docs/guide/internals.html#grammar-recording for details`,children:{}},g=(function(){function b(){}return b.prototype.initGastRecorder=function(x){this.recordingProdStack=[],this.RECORDING_PHASE=!1},b.prototype.enableRecording=function(){var x=this;this.RECORDING_PHASE=!0,this.TRACE_INIT("Enable Recording",function(){for(var _=function(w){var A=w>0?w:"";x["CONSUME"+A]=function(E,M){return this.consumeInternalRecord(E,w,M)},x["SUBRULE"+A]=function(E,M){return this.subruleInternalRecord(E,w,M)},x["OPTION"+A]=function(E){return this.optionInternalRecord(E,w)},x["OR"+A]=function(E){return this.orInternalRecord(E,w)},x["MANY"+A]=function(E){this.manyInternalRecord(w,E)},x["MANY_SEP"+A]=function(E){this.manySepFirstInternalRecord(w,E)},x["AT_LEAST_ONE"+A]=function(E){this.atLeastOneInternalRecord(w,E)},x["AT_LEAST_ONE_SEP"+A]=function(E){this.atLeastOneSepFirstInternalRecord(w,E)}},T=0;T<10;T++)_(T);x.consume=function(w,A,E){return this.consumeInternalRecord(A,w,E)},x.subrule=function(w,A,E){return this.subruleInternalRecord(A,w,E)},x.option=function(w,A){return this.optionInternalRecord(A,w)},x.or=function(w,A){return this.orInternalRecord(A,w)},x.many=function(w,A){this.manyInternalRecord(w,A)},x.atLeastOne=function(w,A){this.atLeastOneInternalRecord(w,A)},x.ACTION=x.ACTION_RECORD,x.BACKTRACK=x.BACKTRACK_RECORD,x.LA=x.LA_RECORD})},b.prototype.disableRecording=function(){var x=this;this.RECORDING_PHASE=!1,this.TRACE_INIT("Deleting Recording methods",function(){for(var _=0;_<10;_++){var T=_>0?_:"";delete x["CONSUME"+T],delete x["SUBRULE"+T],delete x["OPTION"+T],delete x["OR"+T],delete x["MANY"+T],delete x["MANY_SEP"+T],delete x["AT_LEAST_ONE"+T],delete x["AT_LEAST_ONE_SEP"+T]}delete x.consume,delete x.subrule,delete x.option,delete x.or,delete x.many,delete x.atLeastOne,delete x.ACTION,delete x.BACKTRACK,delete x.LA})},b.prototype.ACTION_RECORD=function(x){},b.prototype.BACKTRACK_RECORD=function(x,_){return function(){return!0}},b.prototype.LA_RECORD=function(x){return o.END_OF_FILE},b.prototype.topLevelRuleRecord=function(x,_){try{var T=new t.Rule({definition:[],name:x});return T.name=x,this.recordingProdStack.push(T),_.call(this),this.recordingProdStack.pop(),T}catch(w){if(w.KNOWN_RECORDER_ERROR!==!0)try{w.message=w.message+`
	 This error was thrown during the "grammar recording phase" For more info see:
	https://chevrotain.io/docs/guide/internals.html#grammar-recording`}catch{throw w}throw w}},b.prototype.optionInternalRecord=function(x,_){return y.call(this,t.Option,x,_)},b.prototype.atLeastOneInternalRecord=function(x,_){y.call(this,t.RepetitionMandatory,_,x)},b.prototype.atLeastOneSepFirstInternalRecord=function(x,_){y.call(this,t.RepetitionMandatoryWithSeparator,_,x,l)},b.prototype.manyInternalRecord=function(x,_){y.call(this,t.Repetition,_,x)},b.prototype.manySepFirstInternalRecord=function(x,_){y.call(this,t.RepetitionWithSeparator,_,x,l)},b.prototype.orInternalRecord=function(x,_){return f.call(this,x,_)},b.prototype.subruleInternalRecord=function(x,_,T){if(v(_),!x||e.has(x,"ruleName")===!1){var w=new Error("<SUBRULE"+p(_)+"> argument is invalid"+(" expecting a Parser method reference but got: <"+JSON.stringify(x)+">")+(`
 inside top level rule: <`+this.recordingProdStack[0].name+">"));throw w.KNOWN_RECORDER_ERROR=!0,w}var A=e.peek(this.recordingProdStack),E=x.ruleName,M=new t.NonTerminal({idx:_,nonTerminalName:E,referencedRule:void 0});return A.definition.push(M),this.outputCst?m:c},b.prototype.consumeInternalRecord=function(x,_,T){if(v(_),!r.hasShortKeyProperty(x)){var w=new Error("<CONSUME"+p(_)+"> argument is invalid"+(" expecting a TokenType reference but got: <"+JSON.stringify(x)+">")+(`
 inside top level rule: <`+this.recordingProdStack[0].name+">"));throw w.KNOWN_RECORDER_ERROR=!0,w}var A=e.peek(this.recordingProdStack),E=new t.Terminal({idx:_,terminalType:x});return A.definition.push(E),d},b})();i.GastRecorder=g;function y(b,x,_,T){T===void 0&&(T=!1),v(_);var w=e.peek(this.recordingProdStack),A=e.isFunction(x)?x:x.DEF,E=new b({definition:[],idx:_});return T&&(E.separator=x.SEP),e.has(x,"MAX_LOOKAHEAD")&&(E.maxLookahead=x.MAX_LOOKAHEAD),this.recordingProdStack.push(E),A.call(this),w.definition.push(E),this.recordingProdStack.pop(),c}function f(b,x){var _=this;v(x);var T=e.peek(this.recordingProdStack),w=e.isArray(b)===!1,A=w===!1?b:b.DEF,E=new t.Alternation({definition:[],idx:x,ignoreAmbiguities:w&&b.IGNORE_AMBIGUITIES===!0});e.has(b,"MAX_LOOKAHEAD")&&(E.maxLookahead=b.MAX_LOOKAHEAD);var M=e.some(A,function(P){return e.isFunction(P.GATE)});return E.hasPredicates=M,T.definition.push(E),e.forEach(A,function(P){var N=new t.Alternative({definition:[]});E.definition.push(N),e.has(P,"IGNORE_AMBIGUITIES")?N.ignoreAmbiguities=P.IGNORE_AMBIGUITIES:e.has(P,"GATE")&&(N.ignoreAmbiguities=!0),_.recordingProdStack.push(N),P.ALT.call(_),_.recordingProdStack.pop()}),c}function p(b){return b===0?"":""+b}function v(b){if(b<0||b>u){var x=new Error("Invalid DSL Method idx value: <"+b+`>
	`+("Idx value must be a none negative value smaller than "+(u+1)));throw x.KNOWN_RECORDER_ERROR=!0,x}}}),XP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.PerformanceTracer=void 0;var e=Vt(),t=ji(),n=(function(){function r(){}return r.prototype.initPerformanceTracer=function(s){if(e.has(s,"traceInitPerf")){var o=s.traceInitPerf,a=typeof o=="number";this.traceInitMaxIdent=a?o:1/0,this.traceInitPerf=a?o>0:o}else this.traceInitMaxIdent=0,this.traceInitPerf=t.DEFAULT_PARSER_CONFIG.traceInitPerf;this.traceInitIndent=-1},r.prototype.TRACE_INIT=function(s,o){if(this.traceInitPerf===!0){this.traceInitIndent++;var a=new Array(this.traceInitIndent+1).join("	");this.traceInitIndent<this.traceInitMaxIdent&&console.log(a+"--> <"+s+">");var c=e.timer(o),l=c.time,u=c.value,h=l>10?console.warn:console.log;return this.traceInitIndent<this.traceInitMaxIdent&&h(a+"<-- <"+s+"> time: "+l+"ms"),this.traceInitIndent--,u}else return o()},r})();i.PerformanceTracer=n}),YP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.applyMixins=void 0;function e(t,n){n.forEach(function(r){var s=r.prototype;Object.getOwnPropertyNames(s).forEach(function(o){if(o!=="constructor"){var a=Object.getOwnPropertyDescriptor(s,o);a&&(a.get||a.set)?Object.defineProperty(t.prototype,o,a):t.prototype[o]=r.prototype[o]}})})}i.applyMixins=e}),ji=Mt(i=>{"use strict";var e=i&&i.__extends||(function(){var w=function(A,E){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(M,P){M.__proto__=P}||function(M,P){for(var N in P)Object.prototype.hasOwnProperty.call(P,N)&&(M[N]=P[N])},w(A,E)};return function(A,E){if(typeof E!="function"&&E!==null)throw new TypeError("Class extends value "+String(E)+" is not a constructor or null");w(A,E);function M(){this.constructor=A}A.prototype=E===null?Object.create(E):(M.prototype=E.prototype,new M)}})();Object.defineProperty(i,"__esModule",{value:!0}),i.EmbeddedActionsParser=i.CstParser=i.Parser=i.EMPTY_ALT=i.ParserDefinitionErrorType=i.DEFAULT_RULE_CONFIG=i.DEFAULT_PARSER_CONFIG=i.END_OF_FILE=void 0;var t=Vt(),n=NP(),r=aa(),s=Bp(),o=OP(),a=mE(),c=DP(),l=kP(),u=BP(),h=zP(),d=VP(),m=HP(),g=GP(),y=WP(),f=XP(),p=YP();i.END_OF_FILE=r.createTokenInstance(r.EOF,"",NaN,NaN,NaN,NaN,NaN,NaN),Object.freeze(i.END_OF_FILE),i.DEFAULT_PARSER_CONFIG=Object.freeze({recoveryEnabled:!1,maxLookahead:3,dynamicTokensEnabled:!1,outputCst:!0,errorMessageProvider:s.defaultParserErrorProvider,nodeLocationTracking:"none",traceInitPerf:!1,skipValidations:!1}),i.DEFAULT_RULE_CONFIG=Object.freeze({recoveryValueFunc:function(){},resyncEnabled:!0});var v;(function(w){w[w.INVALID_RULE_NAME=0]="INVALID_RULE_NAME",w[w.DUPLICATE_RULE_NAME=1]="DUPLICATE_RULE_NAME",w[w.INVALID_RULE_OVERRIDE=2]="INVALID_RULE_OVERRIDE",w[w.DUPLICATE_PRODUCTIONS=3]="DUPLICATE_PRODUCTIONS",w[w.UNRESOLVED_SUBRULE_REF=4]="UNRESOLVED_SUBRULE_REF",w[w.LEFT_RECURSION=5]="LEFT_RECURSION",w[w.NONE_LAST_EMPTY_ALT=6]="NONE_LAST_EMPTY_ALT",w[w.AMBIGUOUS_ALTS=7]="AMBIGUOUS_ALTS",w[w.CONFLICT_TOKENS_RULES_NAMESPACE=8]="CONFLICT_TOKENS_RULES_NAMESPACE",w[w.INVALID_TOKEN_NAME=9]="INVALID_TOKEN_NAME",w[w.NO_NON_EMPTY_LOOKAHEAD=10]="NO_NON_EMPTY_LOOKAHEAD",w[w.AMBIGUOUS_PREFIX_ALTS=11]="AMBIGUOUS_PREFIX_ALTS",w[w.TOO_MANY_ALTS=12]="TOO_MANY_ALTS"})(v=i.ParserDefinitionErrorType||(i.ParserDefinitionErrorType={}));function b(w){return w===void 0&&(w=void 0),function(){return w}}i.EMPTY_ALT=b;var x=(function(){function w(A,E){this.definitionErrors=[],this.selfAnalysisDone=!1;var M=this;if(M.initErrorHandler(E),M.initLexerAdapter(),M.initLooksAhead(E),M.initRecognizerEngine(A,E),M.initRecoverable(E),M.initTreeBuilder(E),M.initContentAssist(),M.initGastRecorder(E),M.initPerformanceTracer(E),t.has(E,"ignoredIssues"))throw new Error(`The <ignoredIssues> IParserConfig property has been deprecated.
	Please use the <IGNORE_AMBIGUITIES> flag on the relevant DSL method instead.
	See: https://chevrotain.io/docs/guide/resolving_grammar_errors.html#IGNORING_AMBIGUITIES
	For further details.`);this.skipValidations=t.has(E,"skipValidations")?E.skipValidations:i.DEFAULT_PARSER_CONFIG.skipValidations}return w.performSelfAnalysis=function(A){throw Error("The **static** `performSelfAnalysis` method has been deprecated.	\nUse the **instance** method with the same name instead.")},w.prototype.performSelfAnalysis=function(){var A=this;this.TRACE_INIT("performSelfAnalysis",function(){var E;A.selfAnalysisDone=!0;var M=A.className;A.TRACE_INIT("toFastProps",function(){t.toFastProperties(A)}),A.TRACE_INIT("Grammar Recording",function(){try{A.enableRecording(),t.forEach(A.definedRulesNames,function(N){var L=A[N],D=L.originalGrammarAction,$=void 0;A.TRACE_INIT(N+" Rule",function(){$=A.topLevelRuleRecord(N,D)}),A.gastProductionsCache[N]=$})}finally{A.disableRecording()}});var P=[];if(A.TRACE_INIT("Grammar Resolving",function(){P=o.resolveGrammar({rules:t.values(A.gastProductionsCache)}),A.definitionErrors=A.definitionErrors.concat(P)}),A.TRACE_INIT("Grammar Validations",function(){if(t.isEmpty(P)&&A.skipValidations===!1){var N=o.validateGrammar({rules:t.values(A.gastProductionsCache),maxLookahead:A.maxLookahead,tokenTypes:t.values(A.tokensMap),errMsgProvider:s.defaultGrammarValidatorErrorProvider,grammarName:M});A.definitionErrors=A.definitionErrors.concat(N)}}),t.isEmpty(A.definitionErrors)&&(A.recoveryEnabled&&A.TRACE_INIT("computeAllProdsFollows",function(){var N=n.computeAllProdsFollows(t.values(A.gastProductionsCache));A.resyncFollows=N}),A.TRACE_INIT("ComputeLookaheadFunctions",function(){A.preComputeLookaheadFunctions(t.values(A.gastProductionsCache))})),!w.DEFER_DEFINITION_ERRORS_HANDLING&&!t.isEmpty(A.definitionErrors))throw E=t.map(A.definitionErrors,function(N){return N.message}),new Error(`Parser Definition Errors detected:
 `+E.join(`
-------------------------------
`))})},w.DEFER_DEFINITION_ERRORS_HANDLING=!1,w})();i.Parser=x,p.applyMixins(x,[a.Recoverable,c.LooksAhead,l.TreeBuilder,u.LexerAdapter,d.RecognizerEngine,h.RecognizerApi,m.ErrorHandler,g.ContentAssist,y.GastRecorder,f.PerformanceTracer]);var _=(function(w){e(A,w);function A(E,M){M===void 0&&(M=i.DEFAULT_PARSER_CONFIG);var P=this,N=t.cloneObj(M);return N.outputCst=!0,P=w.call(this,E,N)||this,P}return A})(x);i.CstParser=_;var T=(function(w){e(A,w);function A(E,M){M===void 0&&(M=i.DEFAULT_PARSER_CONFIG);var P=this,N=t.cloneObj(M);return N.outputCst=!1,P=w.call(this,E,N)||this,P}return A})(x);i.EmbeddedActionsParser=T}),jP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.createSyntaxDiagramsCode=void 0;var e=lE();function t(n,r){var s=r===void 0?{}:r,o=s.resourceBase,a=o===void 0?"https://unpkg.com/chevrotain@"+e.VERSION+"/diagrams/":o,c=s.css,l=c===void 0?"https://unpkg.com/chevrotain@"+e.VERSION+"/diagrams/diagrams.css":c,u=`
<!-- This is a generated file -->
<!DOCTYPE html>
<meta charset="utf-8">
<style>
  body {
    background-color: hsl(30, 20%, 95%)
  }
</style>

`,h=`
<link rel='stylesheet' href='`+l+`'>
`,d=`
<script src='`+a+`vendor/railroad-diagrams.js'><\/script>
<script src='`+a+`src/diagrams_builder.js'><\/script>
<script src='`+a+`src/diagrams_behavior.js'><\/script>
<script src='`+a+`src/main.js'><\/script>
`,m=`
<div id="diagrams" align="center"></div>
`,g=`
<script>
    window.serializedGrammar = `+JSON.stringify(n,null,"  ")+`;
<\/script>
`,y=`
<script>
    var diagramsDiv = document.getElementById("diagrams");
    main.drawDiagramsFromSerializedGrammar(serializedGrammar, diagramsDiv);
<\/script>
`;return u+h+d+m+g+y}i.createSyntaxDiagramsCode=t}),qP=Mt(i=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.Parser=i.createSyntaxDiagramsCode=i.clearCache=i.GAstVisitor=i.serializeProduction=i.serializeGrammar=i.Terminal=i.Rule=i.RepetitionWithSeparator=i.RepetitionMandatoryWithSeparator=i.RepetitionMandatory=i.Repetition=i.Option=i.NonTerminal=i.Alternative=i.Alternation=i.defaultLexerErrorProvider=i.NoViableAltException=i.NotAllInputParsedException=i.MismatchedTokenException=i.isRecognitionException=i.EarlyExitException=i.defaultParserErrorProvider=i.tokenName=i.tokenMatcher=i.tokenLabel=i.EOF=i.createTokenInstance=i.createToken=i.LexerDefinitionErrorType=i.Lexer=i.EMPTY_ALT=i.ParserDefinitionErrorType=i.EmbeddedActionsParser=i.CstParser=i.VERSION=void 0;var e=lE();Object.defineProperty(i,"VERSION",{enumerable:!0,get:function(){return e.VERSION}});var t=ji();Object.defineProperty(i,"CstParser",{enumerable:!0,get:function(){return t.CstParser}}),Object.defineProperty(i,"EmbeddedActionsParser",{enumerable:!0,get:function(){return t.EmbeddedActionsParser}}),Object.defineProperty(i,"ParserDefinitionErrorType",{enumerable:!0,get:function(){return t.ParserDefinitionErrorType}}),Object.defineProperty(i,"EMPTY_ALT",{enumerable:!0,get:function(){return t.EMPTY_ALT}});var n=Up();Object.defineProperty(i,"Lexer",{enumerable:!0,get:function(){return n.Lexer}}),Object.defineProperty(i,"LexerDefinitionErrorType",{enumerable:!0,get:function(){return n.LexerDefinitionErrorType}});var r=aa();Object.defineProperty(i,"createToken",{enumerable:!0,get:function(){return r.createToken}}),Object.defineProperty(i,"createTokenInstance",{enumerable:!0,get:function(){return r.createTokenInstance}}),Object.defineProperty(i,"EOF",{enumerable:!0,get:function(){return r.EOF}}),Object.defineProperty(i,"tokenLabel",{enumerable:!0,get:function(){return r.tokenLabel}}),Object.defineProperty(i,"tokenMatcher",{enumerable:!0,get:function(){return r.tokenMatcher}}),Object.defineProperty(i,"tokenName",{enumerable:!0,get:function(){return r.tokenName}});var s=Bp();Object.defineProperty(i,"defaultParserErrorProvider",{enumerable:!0,get:function(){return s.defaultParserErrorProvider}});var o=Rh();Object.defineProperty(i,"EarlyExitException",{enumerable:!0,get:function(){return o.EarlyExitException}}),Object.defineProperty(i,"isRecognitionException",{enumerable:!0,get:function(){return o.isRecognitionException}}),Object.defineProperty(i,"MismatchedTokenException",{enumerable:!0,get:function(){return o.MismatchedTokenException}}),Object.defineProperty(i,"NotAllInputParsedException",{enumerable:!0,get:function(){return o.NotAllInputParsedException}}),Object.defineProperty(i,"NoViableAltException",{enumerable:!0,get:function(){return o.NoViableAltException}});var a=hE();Object.defineProperty(i,"defaultLexerErrorProvider",{enumerable:!0,get:function(){return a.defaultLexerErrorProvider}});var c=Bi();Object.defineProperty(i,"Alternation",{enumerable:!0,get:function(){return c.Alternation}}),Object.defineProperty(i,"Alternative",{enumerable:!0,get:function(){return c.Alternative}}),Object.defineProperty(i,"NonTerminal",{enumerable:!0,get:function(){return c.NonTerminal}}),Object.defineProperty(i,"Option",{enumerable:!0,get:function(){return c.Option}}),Object.defineProperty(i,"Repetition",{enumerable:!0,get:function(){return c.Repetition}}),Object.defineProperty(i,"RepetitionMandatory",{enumerable:!0,get:function(){return c.RepetitionMandatory}}),Object.defineProperty(i,"RepetitionMandatoryWithSeparator",{enumerable:!0,get:function(){return c.RepetitionMandatoryWithSeparator}}),Object.defineProperty(i,"RepetitionWithSeparator",{enumerable:!0,get:function(){return c.RepetitionWithSeparator}}),Object.defineProperty(i,"Rule",{enumerable:!0,get:function(){return c.Rule}}),Object.defineProperty(i,"Terminal",{enumerable:!0,get:function(){return c.Terminal}});var l=Bi();Object.defineProperty(i,"serializeGrammar",{enumerable:!0,get:function(){return l.serializeGrammar}}),Object.defineProperty(i,"serializeProduction",{enumerable:!0,get:function(){return l.serializeProduction}});var u=wh();Object.defineProperty(i,"GAstVisitor",{enumerable:!0,get:function(){return u.GAstVisitor}});function h(){console.warn(`The clearCache function was 'soft' removed from the Chevrotain API.
	 It performs no action other than printing this message.
	 Please avoid using it as it will be completely removed in the future`)}i.clearCache=h;var d=jP();Object.defineProperty(i,"createSyntaxDiagramsCode",{enumerable:!0,get:function(){return d.createSyntaxDiagramsCode}});var m=(function(){function g(){throw new Error(`The Parser class has been deprecated, use CstParser or EmbeddedActionsParser instead.
See: https://chevrotain.io/docs/changes/BREAKING_CHANGES.html#_7-0-0`)}return g})();i.Parser=m}),Uc=qP();var Hp=class extends rn{constructor(e){super(e)}load(e,t,n,r){let s=this,o=s.path===""?Ei.extractUrlBase(e):s.path,a=new Vn(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(c){try{t(s.parse(c,o))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}parse(e,t){let n={};function r(k){let F=s(),G=new ky(F.tokens),j=new By(F.tokenVocabulary),ee=o(j.getBaseCstVisitorConstructor()),ie=G.lex(k);j.input=ie.tokens;let ce=j.vrml();if(j.errors.length>0)throw console.error(j.errors),Error("THREE.VRMLLoader: Parsing errors detected.");return ee.visit(ce)}function s(){let k=Uc.createToken,F=k({name:"RouteIdentifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*[\.][^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d][^\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]*/}),G=k({name:"Identifier",pattern:/[^\x30-\x39\0-\x20\x22\x27\x23\x2b\x2c\x2d\x2e\x5b\x5d\x5c\x7b\x7d]([^\0-\x20\x22\x27\x23\x2b\x2c\x2e\x5b\x5d\x5c\x7b\x7d])*/,longer_alt:F}),j=["Anchor","Billboard","Collision","Group","Transform","Inline","LOD","Switch","AudioClip","DirectionalLight","PointLight","Script","Shape","Sound","SpotLight","WorldInfo","CylinderSensor","PlaneSensor","ProximitySensor","SphereSensor","TimeSensor","TouchSensor","VisibilitySensor","Box","Cone","Cylinder","ElevationGrid","Extrusion","IndexedFaceSet","IndexedLineSet","PointSet","Sphere","Color","Coordinate","Normal","TextureCoordinate","Appearance","FontStyle","ImageTexture","Material","MovieTexture","PixelTexture","TextureTransform","ColorInterpolator","CoordinateInterpolator","NormalInterpolator","OrientationInterpolator","PositionInterpolator","ScalarInterpolator","Background","Fog","NavigationInfo","Viewpoint","Text"],ee=k({name:"Version",pattern:/#VRML.*/,longer_alt:G}),ie=k({name:"NodeName",pattern:new RegExp(j.join("|")),longer_alt:G}),ce=k({name:"DEF",pattern:/DEF/,longer_alt:G}),fe=k({name:"USE",pattern:/USE/,longer_alt:G}),ue=k({name:"ROUTE",pattern:/ROUTE/,longer_alt:G}),Ee=k({name:"TO",pattern:/TO/,longer_alt:G}),Se=k({name:"StringLiteral",pattern:/"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/}),De=k({name:"HexLiteral",pattern:/0[xX][0-9a-fA-F]+/}),ze=k({name:"NumberLiteral",pattern:/[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/}),Je=k({name:"TrueLiteral",pattern:/TRUE/}),Fe=k({name:"FalseLiteral",pattern:/FALSE/}),Xe=k({name:"NullLiteral",pattern:/NULL/}),ae=k({name:"LSquare",pattern:/\[/}),Le=k({name:"RSquare",pattern:/]/}),xe=k({name:"LCurly",pattern:/{/}),ye=k({name:"RCurly",pattern:/}/}),Ue=k({name:"Comment",pattern:/#.*/,group:Uc.Lexer.SKIPPED}),st=[k({name:"WhiteSpace",pattern:/[ ,\s]/,group:Uc.Lexer.SKIPPED}),ie,ce,fe,ue,Ee,Je,Fe,Xe,ee,G,F,Se,De,ze,ae,Le,xe,ye,Ue],pt={};for(let lt=0,We=st.length;lt<We;lt++){let Qe=st[lt];pt[Qe.name]=Qe}return{tokens:st,tokenVocabulary:pt}}function o(k){class F extends k{constructor(){super(),this.validateVisitor()}vrml(ee){let ie={version:this.visit(ee.version),nodes:[],routes:[]};for(let ce=0,fe=ee.node.length;ce<fe;ce++){let ue=ee.node[ce];ie.nodes.push(this.visit(ue))}if(ee.route)for(let ce=0,fe=ee.route.length;ce<fe;ce++){let ue=ee.route[ce];ie.routes.push(this.visit(ue))}return ie}version(ee){return ee.Version[0].image}node(ee){let ie={name:ee.NodeName[0].image,fields:[]};if(ee.field)for(let ce=0,fe=ee.field.length;ce<fe;ce++){let ue=ee.field[ce];ie.fields.push(this.visit(ue))}return ee.def&&(ie.DEF=this.visit(ee.def[0])),ie}field(ee){let ie={name:ee.Identifier[0].image,type:null,values:null},ce;return ee.singleFieldValue&&(ce=this.visit(ee.singleFieldValue[0])),ee.multiFieldValue&&(ce=this.visit(ee.multiFieldValue[0])),ie.type=ce.type,ie.values=ce.values,ie}def(ee){return(ee.Identifier||ee.NodeName)[0].image}use(ee){return{USE:(ee.Identifier||ee.NodeName)[0].image}}singleFieldValue(ee){return G(this,ee)}multiFieldValue(ee){return G(this,ee)}route(ee){return{FROM:ee.RouteIdentifier[0].image,TO:ee.RouteIdentifier[1].image}}}function G(j,ee){let ie={type:null,values:[]};if(ee.node){ie.type="node";for(let ce=0,fe=ee.node.length;ce<fe;ce++){let ue=ee.node[ce];ie.values.push(j.visit(ue))}}if(ee.use){ie.type="use";for(let ce=0,fe=ee.use.length;ce<fe;ce++){let ue=ee.use[ce];ie.values.push(j.visit(ue))}}if(ee.StringLiteral){ie.type="string";for(let ce=0,fe=ee.StringLiteral.length;ce<fe;ce++){let ue=ee.StringLiteral[ce];ie.values.push(ue.image.replace(/'|"/g,""))}}if(ee.NumberLiteral){ie.type="number";for(let ce=0,fe=ee.NumberLiteral.length;ce<fe;ce++){let ue=ee.NumberLiteral[ce];ie.values.push(parseFloat(ue.image))}}if(ee.HexLiteral){ie.type="hex";for(let ce=0,fe=ee.HexLiteral.length;ce<fe;ce++){let ue=ee.HexLiteral[ce];ie.values.push(ue.image)}}if(ee.TrueLiteral){ie.type="boolean";for(let ce=0,fe=ee.TrueLiteral.length;ce<fe;ce++)ee.TrueLiteral[ce].image==="TRUE"&&ie.values.push(!0)}if(ee.FalseLiteral){ie.type="boolean";for(let ce=0,fe=ee.FalseLiteral.length;ce<fe;ce++)ee.FalseLiteral[ce].image==="FALSE"&&ie.values.push(!1)}return ee.NullLiteral&&(ie.type="null",ee.NullLiteral.forEach(function(){ie.values.push(null)})),ie}return new F}function a(k){let F=k.nodes,G=new oi;for(let j=0,ee=F.length;j<ee;j++){let ie=F[j];c(ie)}for(let j=0,ee=F.length;j<ee;j++){let ie=F[j],ce=l(ie);ce instanceof St&&G.add(ce),ie.name==="WorldInfo"&&(G.userData.worldInfo=ce)}return G}function c(k){k.DEF&&(n[k.DEF]=k);let F=k.fields;for(let G=0,j=F.length;G<j;G++){let ee=F[G];if(ee.type==="node"){let ie=ee.values;for(let ce=0,fe=ie.length;ce<fe;ce++)c(ie[ce])}}}function l(k){return k.USE?U(k.USE):(k.build!==void 0||(k.build=u(k)),k.build)}function u(k){let F=k.name,G;switch(F){case"Anchor":case"Group":case"Transform":case"Collision":G=h(k);break;case"Background":G=d(k);break;case"Shape":G=m(k);break;case"Appearance":G=g(k);break;case"Material":G=y(k);break;case"ImageTexture":G=b(k);break;case"PixelTexture":G=v(k);break;case"TextureTransform":G=x(k);break;case"IndexedFaceSet":G=w(k);break;case"IndexedLineSet":G=A(k);break;case"PointSet":G=E(k);break;case"Box":G=M(k);break;case"Cone":G=P(k);break;case"Cylinder":G=N(k);break;case"Sphere":G=L(k);break;case"ElevationGrid":G=D(k);break;case"Extrusion":G=$(k);break;case"Color":case"Coordinate":case"Normal":case"TextureCoordinate":G=_(k);break;case"WorldInfo":G=T(k);break;case"Billboard":case"Inline":case"LOD":case"Switch":case"AudioClip":case"DirectionalLight":case"PointLight":case"Script":case"Sound":case"SpotLight":case"CylinderSensor":case"PlaneSensor":case"ProximitySensor":case"SphereSensor":case"TimeSensor":case"TouchSensor":case"VisibilitySensor":case"Text":case"FontStyle":case"MovieTexture":case"ColorInterpolator":case"CoordinateInterpolator":case"NormalInterpolator":case"OrientationInterpolator":case"PositionInterpolator":case"ScalarInterpolator":case"Fog":case"NavigationInfo":case"Viewpoint":break;default:console.warn("THREE.VRMLLoader: Unknown node:",F);break}return G!==void 0&&k.DEF!==void 0&&G.hasOwnProperty("name")===!0&&(G.name=k.DEF),G}function h(k){let F=new Dt,G=k.fields;for(let j=0,ee=G.length;j<ee;j++){let ie=G[j],ce=ie.name,fe=ie.values;switch(ce){case"bboxCenter":break;case"bboxSize":break;case"center":break;case"children":I(fe,F);break;case"description":break;case"collide":break;case"parameter":break;case"rotation":let ue=new q(fe[0],fe[1],fe[2]).normalize(),Ee=fe[3];F.quaternion.setFromAxisAngle(ue,Ee);break;case"scale":F.scale.set(fe[0],fe[1],fe[2]);break;case"scaleOrientation":break;case"translation":F.position.set(fe[0],fe[1],fe[2]);break;case"proxy":break;case"url":break;default:console.warn("THREE.VRMLLoader: Unknown field:",ce);break}}return F}function d(k){let F=new Dt,G,j,ee,ie,ce=k.fields;for(let ue=0,Ee=ce.length;ue<Ee;ue++){let Se=ce[ue],De=Se.name,ze=Se.values;switch(De){case"groundAngle":G=ze;break;case"groundColor":j=ze;break;case"backUrl":break;case"bottomUrl":break;case"frontUrl":break;case"leftUrl":break;case"rightUrl":break;case"topUrl":break;case"skyAngle":ee=ze;break;case"skyColor":ie=ze;break;default:console.warn("THREE.VRMLLoader: Unknown field:",De);break}}let fe=1e4;if(ie){let ue=new bi(fe,32,16),Ee=new Ht({fog:!1,side:un,depthWrite:!1,depthTest:!1});ie.length>3?(Ne(ue,fe,ee,be(ie),!0),Ee.vertexColors=!0):Ee.color.setRGB(ie[0],ie[1],ie[2],wt);let Se=new ct(ue,Ee);F.add(Se)}if(j&&j.length>0){let ue=new bi(fe,32,16,0,2*Math.PI,.5*Math.PI,1.5*Math.PI),Ee=new Ht({fog:!1,side:un,vertexColors:!0,depthWrite:!1,depthTest:!1});Ne(ue,fe,G,be(j),!1);let Se=new ct(ue,Ee);F.add(Se)}return F.renderOrder=-1/0,F}function m(k){let F=k.fields,G=new Ht({name:rn.DEFAULT_MATERIAL_NAME,color:0}),j;for(let ie=0,ce=F.length;ie<ce;ie++){let fe=F[ie],ue=fe.name,Ee=fe.values;switch(ue){case"appearance":Ee[0]!==null&&(G=l(Ee[0]));break;case"geometry":Ee[0]!==null&&(j=l(Ee[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",ue);break}}let ee;if(j&&j.attributes.position){let ie=j._type;if(ie==="points"){let ce=new Sr({name:rn.DEFAULT_MATERIAL_NAME,color:16777215,opacity:G.opacity,transparent:G.transparent});j.attributes.color!==void 0?ce.vertexColors=!0:G.isMeshPhongMaterial&&ce.color.copy(G.emissive),ee=new ts(j,ce)}else if(ie==="line"){let ce=new Xt({name:rn.DEFAULT_MATERIAL_NAME,color:16777215,opacity:G.opacity,transparent:G.transparent});j.attributes.color!==void 0?ce.vertexColors=!0:G.isMeshPhongMaterial&&ce.color.copy(G.emissive),ee=new ln(j,ce)}else j._solid!==void 0&&(G.side=j._solid?Jn:yn),j.attributes.color!==void 0&&(G.vertexColors=!0),ee=new ct(j,G)}else ee=new St,ee.visible=!1;return ee}function g(k){let F=new Ho,G,j=k.fields;for(let ee=0,ie=j.length;ee<ie;ee++){let ce=j[ee],fe=ce.name,ue=ce.values;switch(fe){case"material":if(ue[0]!==null){let Se=l(ue[0]);Se.diffuseColor&&F.color.copy(Se.diffuseColor),Se.emissiveColor&&F.emissive.copy(Se.emissiveColor),Se.shininess&&(F.shininess=Se.shininess),Se.specularColor&&F.specular.copy(Se.specularColor),Se.transparency&&(F.opacity=1-Se.transparency),Se.transparency>0&&(F.transparent=!0)}else F=new Ht({name:rn.DEFAULT_MATERIAL_NAME,color:0});break;case"texture":let Ee=ue[0];Ee!==null&&(Ee.name==="ImageTexture"||Ee.name==="PixelTexture")&&(F.map=l(Ee));break;case"textureTransform":ue[0]!==null&&(G=l(ue[0]));break;default:console.warn("THREE.VRMLLoader: Unknown field:",fe);break}}if(F.map){if(F.map.__type){switch(F.map.__type){case dr.INTENSITY_ALPHA:F.opacity=1;break;case dr.RGB:F.color.set(16777215);break;case dr.RGBA:F.color.set(16777215),F.opacity=1;break;default:}delete F.map.__type}G&&(F.map.center.copy(G.center),F.map.rotation=G.rotation,F.map.repeat.copy(G.scale),F.map.offset.copy(G.translation))}return F}function y(k){let F={},G=k.fields;for(let j=0,ee=G.length;j<ee;j++){let ie=G[j],ce=ie.name,fe=ie.values;switch(ce){case"ambientIntensity":break;case"diffuseColor":F.diffuseColor=new Be().setRGB(fe[0],fe[1],fe[2],wt);break;case"emissiveColor":F.emissiveColor=new Be().setRGB(fe[0],fe[1],fe[2],wt);break;case"shininess":F.shininess=fe[0];break;case"specularColor":F.specularColor=new Be().setRGB(fe[0],fe[1],fe[2],wt);break;case"transparency":F.transparency=fe[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",ce);break}}return F}function f(k,F,G){let j;switch(F){case dr.INTENSITY:j=parseInt(k),G.r=j,G.g=j,G.b=j,G.a=1;break;case dr.INTENSITY_ALPHA:j=parseInt("0x"+k.substring(2,4)),G.r=j,G.g=j,G.b=j,G.a=parseInt("0x"+k.substring(4,6));break;case dr.RGB:G.r=parseInt("0x"+k.substring(2,4)),G.g=parseInt("0x"+k.substring(4,6)),G.b=parseInt("0x"+k.substring(6,8)),G.a=1;break;case dr.RGBA:G.r=parseInt("0x"+k.substring(2,4)),G.g=parseInt("0x"+k.substring(4,6)),G.b=parseInt("0x"+k.substring(6,8)),G.a=parseInt("0x"+k.substring(8,10));break;default:}}function p(k){let F;switch(k){case 1:F=dr.INTENSITY;break;case 2:F=dr.INTENSITY_ALPHA;break;case 3:F=dr.RGB;break;case 4:F=dr.RGBA;break;default:}return F}function v(k){let F,G=gn,j=gn,ee=k.fields;for(let ie=0,ce=ee.length;ie<ce;ie++){let fe=ee[ie],ue=fe.name,Ee=fe.values;switch(ue){case"image":let Se=Ee[0],De=Ee[1],ze=Ee[2],Je=p(ze),Fe=new Uint8Array(4*Se*De),Xe={r:0,g:0,b:0,a:0};for(let ae=3,Le=0,xe=Ee.length;ae<xe;ae++,Le++){f(Ee[ae],Je,Xe);let ye=Le*4;Fe[ye+0]=Xe.r,Fe[ye+1]=Xe.g,Fe[ye+2]=Xe.b,Fe[ye+3]=Xe.a}F=new An(Fe,Se,De),F.colorSpace=wt,F.needsUpdate=!0,F.__type=Je;break;case"repeatS":Ee[0]===!1&&(G=En);break;case"repeatT":Ee[0]===!1&&(j=En);break;default:console.warn("THREE.VRMLLoader: Unknown field:",ue);break}}return F&&(F.wrapS=G,F.wrapT=j),F}function b(k){let F,G=gn,j=gn,ee=k.fields;for(let ie=0,ce=ee.length;ie<ce;ie++){let fe=ee[ie],ue=fe.name,Ee=fe.values;switch(ue){case"url":let Se=Ee[0];Se&&(F=Me.load(Se));break;case"repeatS":Ee[0]===!1&&(G=En);break;case"repeatT":Ee[0]===!1&&(j=En);break;default:console.warn("THREE.VRMLLoader: Unknown field:",ue);break}}return F&&(F.wrapS=G,F.wrapT=j,F.colorSpace=wt),F}function x(k){let F={center:new Ce,rotation:new Ce,scale:new Ce,translation:new Ce},G=k.fields;for(let j=0,ee=G.length;j<ee;j++){let ie=G[j],ce=ie.name,fe=ie.values;switch(ce){case"center":F.center.set(fe[0],fe[1]);break;case"rotation":F.rotation=fe[0];break;case"scale":F.scale.set(fe[0],fe[1]);break;case"translation":F.translation.set(fe[0],fe[1]);break;default:console.warn("THREE.VRMLLoader: Unknown field:",ce);break}}return F}function _(k){return k.fields[0].values}function T(k){let F={},G=k.fields;for(let j=0,ee=G.length;j<ee;j++){let ie=G[j],ce=ie.name,fe=ie.values;switch(ce){case"title":F.title=fe[0];break;case"info":F.info=fe;break;default:console.warn("THREE.VRMLLoader: Unknown field:",ce);break}}return F}function w(k){let F,G,j,ee,ie=!0,ce=!0,fe=0,ue,Ee,Se,De,ze=!0,Je=!0,Fe=k.fields;for(let Oe=0,st=Fe.length;Oe<st;Oe++){let pt=Fe[Oe],lt=pt.name,We=pt.values;switch(lt){case"color":let Qe=We[0];Qe!==null&&(F=l(Qe));break;case"coord":let Ie=We[0];Ie!==null&&(G=l(Ie));break;case"normal":let tt=We[0];tt!==null&&(j=l(tt));break;case"texCoord":let at=We[0];at!==null&&(ee=l(at));break;case"ccw":ie=We[0];break;case"colorIndex":ue=We;break;case"colorPerVertex":ze=We[0];break;case"convex":break;case"coordIndex":Ee=We;break;case"creaseAngle":fe=We[0];break;case"normalIndex":Se=We;break;case"normalPerVertex":Je=We[0];break;case"solid":ce=We[0];break;case"texCoordIndex":De=We;break;default:console.warn("THREE.VRMLLoader: Unknown field:",lt);break}}if(Ee===void 0)return console.warn("THREE.VRMLLoader: Missing coordIndex."),new ot;let Xe=V(Ee,ie),ae,Le,xe;if(F){if(ze===!0)if(ue&&ue.length>0){let Oe=V(ue,ie);ae=K(Xe,Oe,F,3)}else ae=te(Xe,new Ve(F,3));else if(ue&&ue.length>0){let Oe=Q(F,ue),st=W(Oe,Ee);ae=re(Xe,st)}else{let Oe=W(F,Ee);ae=re(Xe,Oe)}he(ae)}if(j)if(Je===!0)if(Se&&Se.length>0){let Oe=V(Se,ie);Le=K(Xe,Oe,j,3)}else Le=te(Xe,new Ve(j,3));else if(Se&&Se.length>0){let Oe=Q(j,Se),st=W(Oe,Ee);Le=re(Xe,st)}else{let Oe=W(j,Ee);Le=re(Xe,Oe)}else Le=_e(Xe,G,fe);if(ee)if(De&&De.length>0){let Oe=V(De,ie);xe=K(Xe,Oe,ee,2)}else xe=te(Xe,new Ve(ee,2));let ye=new ot,Ue=te(Xe,new Ve(G,3));return ye.setAttribute("position",Ue),ye.setAttribute("normal",Le),ae&&ye.setAttribute("color",ae),xe&&ye.setAttribute("uv",xe),ye._solid=ce,ye._type="mesh",ye}function A(k){let F,G,j,ee,ie=!0,ce=k.fields;for(let De=0,ze=ce.length;De<ze;De++){let Je=ce[De],Fe=Je.name,Xe=Je.values;switch(Fe){case"color":let ae=Xe[0];ae!==null&&(F=l(ae));break;case"coord":let Le=Xe[0];Le!==null&&(G=l(Le));break;case"colorIndex":j=Xe;break;case"colorPerVertex":ie=Xe[0];break;case"coordIndex":ee=Xe;break;default:console.warn("THREE.VRMLLoader: Unknown field:",Fe);break}}let fe,ue=se(ee);if(F){if(ie===!0)if(j.length>0){let De=se(j);fe=K(ue,De,F,3)}else fe=te(ue,new Ve(F,3));else if(j.length>0){let De=Q(F,j),ze=oe(De,ee);fe=de(ue,ze)}else{let De=oe(F,ee);fe=de(ue,De)}he(fe)}let Ee=new ot,Se=te(ue,new Ve(G,3));return Ee.setAttribute("position",Se),fe&&Ee.setAttribute("color",fe),Ee._type="line",Ee}function E(k){let F,G,j=k.fields;for(let ie=0,ce=j.length;ie<ce;ie++){let fe=j[ie],ue=fe.name,Ee=fe.values;switch(ue){case"color":let Se=Ee[0];Se!==null&&(F=l(Se));break;case"coord":let De=Ee[0];De!==null&&(G=l(De));break;default:console.warn("THREE.VRMLLoader: Unknown field:",ue);break}}let ee=new ot;if(ee.setAttribute("position",new Ve(G,3)),F){let ie=new Ve(F,3);he(ie),ee.setAttribute("color",ie)}return ee._type="points",ee}function M(k){let F=new q(2,2,2),G=k.fields;for(let ee=0,ie=G.length;ee<ie;ee++){let ce=G[ee],fe=ce.name,ue=ce.values;switch(fe){case"size":F.x=ue[0],F.y=ue[1],F.z=ue[2];break;default:console.warn("THREE.VRMLLoader: Unknown field:",fe);break}}return new Qn(F.x,F.y,F.z)}function P(k){let F=1,G=2,j=!1,ee=k.fields;for(let ce=0,fe=ee.length;ce<fe;ce++){let ue=ee[ce],Ee=ue.name,Se=ue.values;switch(Ee){case"bottom":j=!Se[0];break;case"bottomRadius":F=Se[0];break;case"height":G=Se[0];break;case"side":break;default:console.warn("THREE.VRMLLoader: Unknown field:",Ee);break}}return new Bo(F,G,16,1,j)}function N(k){let F=1,G=2,j=k.fields;for(let ie=0,ce=j.length;ie<ce;ie++){let fe=j[ie],ue=fe.name,Ee=fe.values;switch(ue){case"bottom":break;case"radius":F=Ee[0];break;case"height":G=Ee[0];break;case"side":break;case"top":break;default:console.warn("THREE.VRMLLoader: Unknown field:",ue);break}}return new is(F,F,G,16,1)}function L(k){let F=1,G=k.fields;for(let ee=0,ie=G.length;ee<ie;ee++){let ce=G[ee],fe=ce.name,ue=ce.values;switch(fe){case"radius":F=ue[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",fe);break}}return new bi(F,16,16)}function D(k){let F,G,j,ee,ie=!0,ce=!0,fe=!0,ue=!0,Ee=0,Se=2,De=2,ze=1,Je=1,Fe=k.fields;for(let We=0,Qe=Fe.length;We<Qe;We++){let Ie=Fe[We],tt=Ie.name,at=Ie.values;switch(tt){case"color":let _t=at[0];_t!==null&&(F=l(_t));break;case"normal":let Xn=at[0];Xn!==null&&(G=l(Xn));break;case"texCoord":let ei=at[0];ei!==null&&(j=l(ei));break;case"height":ee=at;break;case"ccw":ue=at[0];break;case"colorPerVertex":ie=at[0];break;case"creaseAngle":Ee=at[0];break;case"normalPerVertex":ce=at[0];break;case"solid":fe=at[0];break;case"xDimension":Se=at[0];break;case"xSpacing":ze=at[0];break;case"zDimension":De=at[0];break;case"zSpacing":Je=at[0];break;default:console.warn("THREE.VRMLLoader: Unknown field:",tt);break}}let Xe=[],ae=[],Le=[],xe=[];for(let We=0;We<De;We++)for(let Qe=0;Qe<Se;Qe++){let Ie=We*Se+Qe,tt=ze*We,at=ee[Ie],_t=Je*Qe;if(Xe.push(tt,at,_t),F&&ie===!0){let Xn=F[Ie*3+0],ei=F[Ie*3+1],mr=F[Ie*3+2];Le.push(Xn,ei,mr)}if(G&&ce===!0){let Xn=G[Ie*3+0],ei=G[Ie*3+1],mr=G[Ie*3+2];ae.push(Xn,ei,mr)}if(j){let Xn=j[Ie*2+0],ei=j[Ie*2+1];xe.push(Xn,ei)}else xe.push(We/(Se-1),Qe/(De-1))}let ye=[];for(let We=0;We<Se-1;We++)for(let Qe=0;Qe<De-1;Qe++){let Ie=We+Qe*Se,tt=We+(Qe+1)*Se,at=We+1+(Qe+1)*Se,_t=We+1+Qe*Se;ue===!0?(ye.push(Ie,at,tt),ye.push(at,Ie,_t)):(ye.push(Ie,tt,at),ye.push(at,_t,Ie))}let Ue=te(ye,new Ve(Xe,3)),Oe=te(ye,new Ve(xe,2)),st,pt;if(F){if(ie===!1){for(let We=0;We<Se-1;We++)for(let Qe=0;Qe<De-1;Qe++){let Ie=We+Qe*(Se-1),tt=F[Ie*3+0],at=F[Ie*3+1],_t=F[Ie*3+2];Le.push(tt,at,_t),Le.push(tt,at,_t),Le.push(tt,at,_t),Le.push(tt,at,_t),Le.push(tt,at,_t),Le.push(tt,at,_t)}st=new Ve(Le,3)}else st=te(ye,new Ve(Le,3));he(st)}if(G)if(ce===!1){for(let We=0;We<Se-1;We++)for(let Qe=0;Qe<De-1;Qe++){let Ie=We+Qe*(Se-1),tt=G[Ie*3+0],at=G[Ie*3+1],_t=G[Ie*3+2];ae.push(tt,at,_t),ae.push(tt,at,_t),ae.push(tt,at,_t),ae.push(tt,at,_t),ae.push(tt,at,_t),ae.push(tt,at,_t)}pt=new Ve(ae,3)}else pt=te(ye,new Ve(ae,3));else pt=_e(ye,Xe,Ee);let lt=new ot;return lt.setAttribute("position",Ue),lt.setAttribute("normal",pt),lt.setAttribute("uv",Oe),st&&lt.setAttribute("color",st),lt._solid=fe,lt._type="mesh",lt}function $(k){let F=[1,1,1,-1,-1,-1,-1,1,1,1],G=[0,0,0,0,1,0],j,ee,ie=!0,ce=!0,fe=0,ue=!0,Ee=!0,Se=k.fields;for(let lt=0,We=Se.length;lt<We;lt++){let Qe=Se[lt],Ie=Qe.name,tt=Qe.values;switch(Ie){case"beginCap":ie=tt[0];break;case"ccw":ce=tt[0];break;case"convex":break;case"creaseAngle":fe=tt[0];break;case"crossSection":F=tt;break;case"endCap":ue=tt[0];break;case"orientation":ee=tt;break;case"scale":j=tt;break;case"solid":Ee=tt[0];break;case"spine":G=tt;break;default:console.warn("THREE.VRMLLoader: Unknown field:",Ie);break}}let De=F[0]===F[F.length-2]&&F[1]===F[F.length-1],ze=[],Je=new q,Fe=new q,Xe=new q,ae=new q,Le=new Zt;for(let lt=0,We=0,Qe=0,Ie=G.length;lt<Ie;lt+=3,We+=2,Qe+=4){Je.fromArray(G,lt),Fe.x=j?j[We+0]:1,Fe.y=1,Fe.z=j?j[We+1]:1,Xe.x=ee?ee[Qe+0]:0,Xe.y=ee?ee[Qe+1]:0,Xe.z=ee?ee[Qe+2]:1;let tt=ee?ee[Qe+3]:0;for(let at=0,_t=F.length;at<_t;at+=2)ae.x=F[at+0],ae.y=0,ae.z=F[at+1],ae.multiply(Fe),Le.setFromAxisAngle(Xe,tt),ae.applyQuaternion(Le),ae.add(Je),ze.push(ae.x,ae.y,ae.z)}let xe=[],ye=G.length/3,Ue=F.length/2;for(let lt=0;lt<ye-1;lt++)for(let We=0;We<Ue-1;We++){let Qe=We+lt*Ue,Ie=We+1+lt*Ue,tt=We+(lt+1)*Ue,at=We+1+(lt+1)*Ue;We===Ue-2&&De===!0&&(Ie=lt*Ue,at=(lt+1)*Ue),ce===!0?(xe.push(Qe,Ie,tt),xe.push(tt,Ie,at)):(xe.push(Qe,tt,Ie),xe.push(tt,at,Ie))}if(ie===!0||ue===!0){let lt=[];for(let Ie=0,tt=F.length;Ie<tt;Ie+=2)lt.push(new Ce(F[Ie],F[Ie+1]));let We=Ui.triangulateShape(lt,[]),Qe=[];for(let Ie=0,tt=We.length;Ie<tt;Ie++){let at=We[Ie];Qe.push(at[0],at[1],at[2])}if(ie===!0)for(let Ie=0,tt=Qe.length;Ie<tt;Ie+=3)ce===!0?xe.push(Qe[Ie+0],Qe[Ie+1],Qe[Ie+2]):xe.push(Qe[Ie+0],Qe[Ie+2],Qe[Ie+1]);if(ue===!0){let Ie=Ue*(ye-1);for(let tt=0,at=Qe.length;tt<at;tt+=3)ce===!0?xe.push(Ie+Qe[tt+0],Ie+Qe[tt+2],Ie+Qe[tt+1]):xe.push(Ie+Qe[tt+0],Ie+Qe[tt+1],Ie+Qe[tt+2])}}let Oe=te(xe,new Ve(ze,3)),st=_e(xe,ze,fe),pt=new ot;return pt.setAttribute("position",Oe),pt.setAttribute("normal",st),pt._solid=Ee,pt._type="mesh",pt}function U(k){let F=n[k],G=l(F);return G.isObject3D||G.isMaterial?G.clone():G}function I(k,F){for(let G=0,j=k.length;G<j;G++){let ee=l(k[G]);ee instanceof St&&F.add(ee)}}function V(k,F){let G=[],j=0;for(let ee=0,ie=k.length;ee<ie;ee++){let ce=k[j],fe=k[ee+(F?1:2)],ue=k[ee+(F?2:1)];G.push(ce,fe,ue),(k[ee+3]===-1||ee+3>=ie)&&(ee+=3,j=ee+1)}return G}function W(k,F){let G=[],j=0;for(let ee=0,ie=F.length;ee<ie;ee++){let ce=j*3,fe=k[ce],ue=k[ce+1],Ee=k[ce+2];G.push(fe,ue,Ee),(F[ee+3]===-1||ee+3>=ie)&&(ee+=3,j++)}return G}function Q(k,F){let G=[];for(let j=0,ee=F.length;j<ee;j++){let ce=F[j]*3,fe=k[ce],ue=k[ce+1],Ee=k[ce+2];G.push(fe,ue,Ee)}return G}function se(k){let F=[];for(let G=0,j=k.length;G<j;G++){let ee=k[G],ie=k[G+1];F.push(ee,ie),(k[G+2]===-1||G+2>=j)&&(G+=2)}return F}function oe(k,F){let G=[],j=0;for(let ee=0,ie=F.length;ee<ie;ee++){let ce=j*3,fe=k[ce],ue=k[ce+1],Ee=k[ce+2];G.push(fe,ue,Ee),(F[ee+2]===-1||ee+2>=ie)&&(ee+=2,j++)}return G}let ge=new q,O=new q,S=new q,R=new Ce,z=new Ce,Y=new Ce;function K(k,F,G,j){let ee=[];for(let ie=0,ce=k.length;ie<ce;ie+=3){let fe=F[ie],ue=F[ie+1],Ee=F[ie+2];j===2?(R.fromArray(G,fe*j),z.fromArray(G,ue*j),Y.fromArray(G,Ee*j),ee.push(R.x,R.y),ee.push(z.x,z.y),ee.push(Y.x,Y.y)):(ge.fromArray(G,fe*j),O.fromArray(G,ue*j),S.fromArray(G,Ee*j),ee.push(ge.x,ge.y,ge.z),ee.push(O.x,O.y,O.z),ee.push(S.x,S.y,S.z))}return new Ve(ee,j)}function re(k,F){let G=[];for(let j=0,ee=0,ie=k.length;j<ie;j+=3,ee++)ge.fromArray(F,ee*3),G.push(ge.x,ge.y,ge.z),G.push(ge.x,ge.y,ge.z),G.push(ge.x,ge.y,ge.z);return new Ve(G,3)}function de(k,F){let G=[];for(let j=0,ee=0,ie=k.length;j<ie;j+=2,ee++)ge.fromArray(F,ee*3),G.push(ge.x,ge.y,ge.z),G.push(ge.x,ge.y,ge.z);return new Ve(G,3)}function te(k,F){let G=F.array,j=F.itemSize,ee=new G.constructor(k.length*j),ie=0,ce=0;for(let fe=0,ue=k.length;fe<ue;fe++){ie=k[fe]*j;for(let Ee=0;Ee<j;Ee++)ee[ce++]=G[ie++]}return new Ve(ee,j)}let ne=new q,H=new q;function _e(k,F,G){let j=[],ee={};for(let ce=0,fe=k.length;ce<fe;ce+=3){let ue=k[ce],Ee=k[ce+1],Se=k[ce+2],De=new zy(ue,Ee,Se);ge.fromArray(F,ue*3),O.fromArray(F,Ee*3),S.fromArray(F,Se*3),H.subVectors(S,O),ne.subVectors(ge,O),H.cross(ne),H.normalize(),De.normal.copy(H),ee[ue]===void 0&&(ee[ue]=[]),ee[Ee]===void 0&&(ee[Ee]=[]),ee[Se]===void 0&&(ee[Se]=[]),ee[ue].push(De.normal),ee[Ee].push(De.normal),ee[Se].push(De.normal),j.push(De)}let ie=[];for(let ce=0,fe=j.length;ce<fe;ce++){let ue=j[ce],Ee=me(ee[ue.a],ue.normal,G),Se=me(ee[ue.b],ue.normal,G),De=me(ee[ue.c],ue.normal,G);ge.fromArray(F,ue.a*3),O.fromArray(F,ue.b*3),S.fromArray(F,ue.c*3),ie.push(Ee.x,Ee.y,Ee.z),ie.push(Se.x,Se.y,Se.z),ie.push(De.x,De.y,De.z)}return new Ve(ie,3)}function me(k,F,G){let j=new q;if(G===0)j.copy(F);else for(let ee=0,ie=k.length;ee<ie;ee++)k[ee].angleTo(F)<G&&j.add(k[ee]);return j.normalize()}function be(k){let F=[];for(let G=0,j=k.length;G<j;G+=3)F.push(new Be(k[G],k[G+1],k[G+2]));return F}function he(k){let F=new Be;for(let G=0;G<k.count;G++)F.fromBufferAttribute(k,G),bt.toWorkingColorSpace(F,wt),k.setXYZ(G,F.r,F.g,F.b)}function Ne(k,F,G,j,ee){let ie=[],ce=ee===!0?0:Math.PI;for(let ze=0,Je=j.length;ze<Je;ze++){let Fe=ze===0?0:G[ze-1];Fe=ee===!0?Fe:ce-Fe;let Xe=new q;Xe.setFromSphericalCoords(F,Fe,0),ie.push(Xe)}let fe=k.index,ue=k.attributes.position,Ee=new gt(new Float32Array(k.attributes.position.count*3),3),Se=new q,De=new Be;for(let ze=0;ze<fe.count;ze++){let Je=fe.getX(ze);Se.fromBufferAttribute(ue,Je);let Fe,Xe,ae=1;for(let ye=1;ye<ie.length;ye++){Fe=ye-1,Xe=ye;let Ue=ie[Fe],Oe=ie[Xe];if(ee===!0){if(Se.y<=Ue.y&&Se.y>Oe.y){ae=Math.abs(Ue.y-Se.y)/Math.abs(Ue.y-Oe.y);break}}else if(Se.y>=Ue.y&&Se.y<Oe.y){ae=Math.abs(Ue.y-Se.y)/Math.abs(Ue.y-Oe.y);break}}let Le=j[Fe],xe=j[Xe];De.copy(Le).lerp(xe,ae),bt.toWorkingColorSpace(De,wt),Ee.setXYZ(Je,De.r,De.g,De.b)}k.setAttribute("color",Ee)}let Me=new qs(this.manager);if(Me.setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin),e.indexOf("#VRML V2.0")===-1)throw Error("THREE.VRMLLexer: Version of VRML asset not supported.");let Z=r(e);return a(Z)}},ky=class{constructor(e){this.lexer=new Uc.Lexer(e)}lex(e){let t=this.lexer.tokenize(e);if(t.errors.length>0)throw console.error(t.errors),Error("THREE.VRMLLexer: Lexing errors detected.");return t}},KP=Uc.CstParser,By=class extends KP{constructor(e){super(e);let t=this,n=e.Version,r=e.LCurly,s=e.RCurly,o=e.LSquare,a=e.RSquare,c=e.Identifier,l=e.RouteIdentifier,u=e.StringLiteral,h=e.HexLiteral,d=e.NumberLiteral,m=e.TrueLiteral,g=e.FalseLiteral,y=e.NullLiteral,f=e.DEF,p=e.USE,v=e.ROUTE,b=e.TO,x=e.NodeName;t.RULE("vrml",function(){t.SUBRULE(t.version),t.AT_LEAST_ONE(function(){t.SUBRULE(t.node)}),t.MANY(function(){t.SUBRULE(t.route)})}),t.RULE("version",function(){t.CONSUME(n)}),t.RULE("node",function(){t.OPTION(function(){t.SUBRULE(t.def)}),t.CONSUME(x),t.CONSUME(r),t.MANY(function(){t.SUBRULE(t.field)}),t.CONSUME(s)}),t.RULE("field",function(){t.CONSUME(c),t.OR2([{ALT:function(){t.SUBRULE(t.singleFieldValue)}},{ALT:function(){t.SUBRULE(t.multiFieldValue)}}])}),t.RULE("def",function(){t.CONSUME(f),t.OR([{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(x)}}])}),t.RULE("use",function(){t.CONSUME(p),t.OR([{ALT:function(){t.CONSUME(c)}},{ALT:function(){t.CONSUME(x)}}])}),t.RULE("singleFieldValue",function(){t.AT_LEAST_ONE(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(d)}},{ALT:function(){t.CONSUME(m)}},{ALT:function(){t.CONSUME(g)}},{ALT:function(){t.CONSUME(y)}}])})}),t.RULE("multiFieldValue",function(){t.CONSUME(o),t.MANY(function(){t.OR([{ALT:function(){t.SUBRULE(t.node)}},{ALT:function(){t.SUBRULE(t.use)}},{ALT:function(){t.CONSUME(u)}},{ALT:function(){t.CONSUME(h)}},{ALT:function(){t.CONSUME(d)}},{ALT:function(){t.CONSUME(y)}}])}),t.CONSUME(a)}),t.RULE("route",function(){t.CONSUME(v),t.CONSUME(l),t.CONSUME(b),t.CONSUME2(l)}),this.performSelfAnalysis()}},zy=class{constructor(e,t,n){this.a=e,this.b=t,this.c=n,this.normal=new q}},dr={INTENSITY:1,INTENSITY_ALPHA:2,RGB:3,RGBA:4};var Gp=class extends oi{constructor(){super();let e=new Qn;e.deleteAttribute("uv");let t=new Mn({side:un}),n=new Mn,r=new os(16777215,900,28,2);r.position.set(.418,16.199,.3),this.add(r);let s=new ct(e,t);s.position.set(-.757,13.219,.717),s.scale.set(31.713,28.305,28.591),this.add(s);let o=new ct(e,n);o.position.set(-10.906,2.009,1.846),o.rotation.set(0,-.195,0),o.scale.set(2.328,7.905,4.651),this.add(o);let a=new ct(e,n);a.position.set(-5.607,-.754,-.758),a.rotation.set(0,.994,0),a.scale.set(1.97,1.534,3.955),this.add(a);let c=new ct(e,n);c.position.set(6.167,.857,7.803),c.rotation.set(0,.561,0),c.scale.set(3.927,6.285,3.687),this.add(c);let l=new ct(e,n);l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),this.add(l);let u=new ct(e,n);u.position.set(2.291,-.756,-2.621),u.rotation.set(0,-.286,0),u.scale.set(1.546,1.552,1.496),this.add(u);let h=new ct(e,n);h.position.set(-2.193,-.369,-5.547),h.rotation.set(0,.516,0),h.scale.set(3.875,3.487,2.986),this.add(h);let d=new ct(e,kc(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),this.add(d);let m=new ct(e,kc(50));m.position.set(-16.109,18.021,-8.207),m.scale.set(.1,2.425,2.751),this.add(m);let g=new ct(e,kc(17));g.position.set(14.904,12.198,-1.832),g.scale.set(.15,4.265,6.331),this.add(g);let y=new ct(e,kc(43));y.position.set(-.462,8.89,14.52),y.scale.set(4.38,5.441,.088),this.add(y);let f=new ct(e,kc(20));f.position.set(3.235,11.486,-12.541),f.scale.set(2.5,2,.1),this.add(f);let p=new ct(e,kc(100));p.position.set(0,20,0),p.scale.set(1,.1,1),this.add(p)}dispose(){let e=new Set;this.traverse(t=>{t.isMesh&&(e.add(t.geometry),e.add(t.material))});for(let t of e)t.dispose()}};function kc(i){let e=new Ht;return e.color.setScalar(i),e}var Ch=new q;function qi(i,e,t,n,r,s){let o=2*Math.PI*r/4,a=Math.max(s-2*r,0),c=Math.PI/4;Ch.copy(e),Ch[n]=0,Ch.normalize();let l=.5*o/(o+a),u=1-Ch.angleTo(i)/c;return Math.sign(Ch[t])===1?u*l:a/(o+a)+l+l*(1-u)}var Wp=class extends Qn{constructor(e=1,t=1,n=1,r=2,s=.1){if(r=r*2+1,s=Math.min(e/2,t/2,n/2,s),super(1,1,1,r,r,r),r===1)return;let o=this.toNonIndexed();this.index=null,this.attributes.position=o.attributes.position,this.attributes.normal=o.attributes.normal,this.attributes.uv=o.attributes.uv;let a=new q,c=new q,l=new q(e,t,n).divideScalar(2).subScalar(s),u=this.attributes.position.array,h=this.attributes.normal.array,d=this.attributes.uv.array,m=u.length/6,g=new q,y=.5/r;for(let f=0,p=0;f<u.length;f+=3,p+=2)switch(a.fromArray(u,f),c.copy(a),c.x-=Math.sign(c.x)*y,c.y-=Math.sign(c.y)*y,c.z-=Math.sign(c.z)*y,c.normalize(),u[f+0]=l.x*Math.sign(a.x)+c.x*s,u[f+1]=l.y*Math.sign(a.y)+c.y*s,u[f+2]=l.z*Math.sign(a.z)+c.z*s,h[f+0]=c.x,h[f+1]=c.y,h[f+2]=c.z,Math.floor(f/m)){case 0:g.set(1,0,0),d[p+0]=qi(g,c,"z","y",s,n),d[p+1]=1-qi(g,c,"y","z",s,t);break;case 1:g.set(-1,0,0),d[p+0]=1-qi(g,c,"z","y",s,n),d[p+1]=1-qi(g,c,"y","z",s,t);break;case 2:g.set(0,1,0),d[p+0]=1-qi(g,c,"x","z",s,e),d[p+1]=qi(g,c,"z","x",s,n);break;case 3:g.set(0,-1,0),d[p+0]=1-qi(g,c,"x","z",s,e),d[p+1]=1-qi(g,c,"z","x",s,n);break;case 4:g.set(0,0,1),d[p+0]=1-qi(g,c,"x","y",s,e),d[p+1]=1-qi(g,c,"y","x",s,t);break;case 5:g.set(0,0,-1),d[p+0]=qi(g,c,"x","y",s,e),d[p+1]=1-qi(g,c,"y","x",s,t);break}}};var Bc={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`

		varying vec2 vUv;

		void main() {

			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

		}`,fragmentShader:`

		uniform float opacity;

		uniform sampler2D tDiffuse;

		varying vec2 vUv;

		void main() {

			vec4 texel = texture2D( tDiffuse, vUv );
			gl_FragColor = opacity * texel;


		}`};var li=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}},ZP=new cr(-1,1,1,-1,0,1),Vy=class extends ot{constructor(){super(),this.setAttribute("position",new Ve([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Ve([0,2,0,0,2,0],2))}},JP=new Vy,Fr=class{constructor(e){this._mesh=new ct(JP,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,ZP)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}};var Xp=class extends li{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof $t?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Gn.clone(e.uniforms),this.material=new $t({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new Fr(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}};var Ph=class extends li{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){let r=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let o,a;this.inverse?(o=0,a=1):(o=1,a=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),s.buffers.stencil.setFunc(r.ALWAYS,o,4294967295),s.buffers.stencil.setClear(a),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(r.EQUAL,1,4294967295),s.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.buffers.stencil.setLocked(!0)}},Yp=class extends li{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}};var jp=class{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){let n=e.getSize(new Ce);this._width=n.width,this._height=n.height,t=new on(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Hn}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new Xp(Bc),this.copyPass.material.blending=xn,this.clock=new Yo}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());let t=this.renderer.getRenderTarget(),n=!1;for(let r=0,s=this.passes.length;r<s;r++){let o=this.passes[r];if(o.enabled!==!1){if(o.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(r),o.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),o.needsSwap){if(n){let a=this.renderer.getContext(),c=this.renderer.state.buffers.stencil;c.setFunc(a.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),c.setFunc(a.EQUAL,1,4294967295)}this.swapBuffers()}Ph!==void 0&&(o instanceof Ph?n=!0:o instanceof Yp&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){let t=this.renderer.getSize(new Ce);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;let n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let s=0;s<this.passes.length;s++)this.passes[s].setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}};var qp=class extends li{constructor(e,t,n=null,r=null,s=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new Be}render(e,t,n){let r=e.autoClear;e.autoClear=!1;let s,o;this.overrideMaterial!==null&&(o=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(s=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(s),this.overrideMaterial!==null&&(this.scene.overrideMaterial=o),e.autoClear=r}};var Ih={name:"GTAOShader",defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new Ce},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new nt},cameraProjectionMatrixInverse:{value:new nt},cameraWorldMatrix:{value:new nt},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new q(-1,-1,-1)},sceneBoxMax:{value:new q(1,1,1)}},vertexShader:`

		varying vec2 vUv;

		void main() {
			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
		}`,fragmentShader:`
		varying vec2 vUv;
		uniform highp sampler2D tNormal;
		uniform highp sampler2D tDepth;
		uniform sampler2D tNoise;
		uniform vec2 resolution;
		uniform float cameraNear;
		uniform float cameraFar;
		uniform mat4 cameraProjectionMatrix;
		uniform mat4 cameraProjectionMatrixInverse;		
		uniform mat4 cameraWorldMatrix;
		uniform float radius;
		uniform float distanceExponent;
		uniform float thickness;
		uniform float distanceFallOff;
		uniform float scale;
		#if SCENE_CLIP_BOX == 1
			uniform vec3 sceneBoxMin;
			uniform vec3 sceneBoxMax;
		#endif
		
		#include <common>
		#include <packing>

		#ifndef FRAGMENT_OUTPUT
		#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)
		#endif

		vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {
			vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);
			vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
			return viewSpacePosition.xyz / viewSpacePosition.w;
		}

		float getDepth(const vec2 uv) {  
			return textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;
		}

		float fetchDepth(const ivec2 uv) {   
			return texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;
		}

		float getViewZ(const in float depth) {
			#if PERSPECTIVE_CAMERA == 1
				return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);
			#else
				return orthographicDepthToViewZ(depth, cameraNear, cameraFar);
			#endif
		}

		vec3 computeNormalFromDepth(const vec2 uv) {
			vec2 size = vec2(textureSize(tDepth, 0));
			ivec2 p = ivec2(uv * size);
			float c0 = fetchDepth(p);
			float l2 = fetchDepth(p - ivec2(2, 0));
			float l1 = fetchDepth(p - ivec2(1, 0));
			float r1 = fetchDepth(p + ivec2(1, 0));
			float r2 = fetchDepth(p + ivec2(2, 0));
			float b2 = fetchDepth(p - ivec2(0, 2));
			float b1 = fetchDepth(p - ivec2(0, 1));
			float t1 = fetchDepth(p + ivec2(0, 1));
			float t2 = fetchDepth(p + ivec2(0, 2));
			float dl = abs((2.0 * l1 - l2) - c0);
			float dr = abs((2.0 * r1 - r2) - c0);
			float db = abs((2.0 * b1 - b2) - c0);
			float dt = abs((2.0 * t1 - t2) - c0);
			vec3 ce = getViewPosition(uv, c0).xyz;
			vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;
			vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;
			return normalize(cross(dpdx, dpdy));
		}

		vec3 getViewNormal(const vec2 uv) {
			#if NORMAL_VECTOR_TYPE == 2
				return normalize(textureLod(tNormal, uv, 0.).rgb);
			#elif NORMAL_VECTOR_TYPE == 1
				return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);
			#else
				return computeNormalFromDepth(uv);
			#endif
		}

		vec3 getSceneUvAndDepth(vec3 sampleViewPos) {
			vec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);
			vec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;
			float sampleSceneDepth = getDepth(sampleUv);
			return vec3(sampleUv, sampleSceneDepth);
		}
		
		void main() {
			float depth = getDepth(vUv.xy);
			if (depth >= 1.0) {
				discard;
				return;
			}
			vec3 viewPos = getViewPosition(vUv, depth);
			vec3 viewNormal = getViewNormal(vUv);

			float radiusToUse = radius;
			float distanceFalloffToUse = thickness;
			#if SCREEN_SPACE_RADIUS == 1
				float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;
				radiusToUse *= radiusScale;
				distanceFalloffToUse *= radiusScale;
			#endif

			#if SCENE_CLIP_BOX == 1
				vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;
				float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));
				if (boxDistance > radiusToUse) {
					discard;
					return;
				}
			#endif
			
			vec2 noiseResolution = vec2(textureSize(tNoise, 0));
			vec2 noiseUv = vUv * resolution / noiseResolution;
			vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);
			vec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;
			vec3 tangent = normalize(vec3(randomVec.xy, 0.));
			vec3 bitangent = vec3(-tangent.y, tangent.x, 0.);
			mat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));

			const int DIRECTIONS = SAMPLES < 30 ? 3 : 5;
			const int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;
			float ao = 0.0;
			for (int i = 0; i < DIRECTIONS; ++i) {
				
				float angle = float(i) / float(DIRECTIONS) * PI;
				vec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w); 
				sampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);

				vec3 viewDir = normalize(-viewPos.xyz);
				vec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));
				vec3 sliceTangent = cross(sliceBitangent, viewDir);
				vec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));
				
				vec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);
				vec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));
				
				for (int j = 0; j < STEPS; ++j) {
					vec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);	

					vec3 sampleSceneUvDepth = getSceneUvAndDepth(viewPos + sampleViewOffset);
					vec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);
					vec3 viewDelta = sampleSceneViewPos - viewPos;
					if (abs(viewDelta.z) < thickness) {
						float sampleCosHorizon = dot(viewDir, normalize(viewDelta));
						cosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));
					}		

					sampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);
					sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);
					viewDelta = sampleSceneViewPos - viewPos;
					if (abs(viewDelta.z) < thickness) {
						float sampleCosHorizon = dot(viewDir, normalize(viewDelta));
						cosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));
					}
				}

				vec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);
				float nx = dot(normalInSlice, sliceTangent);
				float ny = dot(normalInSlice, viewDir);
				float nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);
				float nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);
				float occlusion = nx * nxb + ny * nyb;
				ao += occlusion;
			}

			ao = clamp(ao / float(DIRECTIONS), 0., 1.);		
		#if SCENE_CLIP_BOX == 1
			ao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));
		#endif
			ao = pow(ao, scale);

			gl_FragColor = FRAGMENT_OUTPUT;
		}`},Nh={name:"GTAODepthShader",defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`
		varying vec2 vUv;

		void main() {
			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
		}`,fragmentShader:`
		uniform sampler2D tDepth;
		uniform float cameraNear;
		uniform float cameraFar;
		varying vec2 vUv;

		#include <packing>

		float getLinearDepth( const in vec2 screenPosition ) {
			#if PERSPECTIVE_CAMERA == 1
				float fragCoordZ = texture2D( tDepth, screenPosition ).x;
				float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
				return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
			#else
				return texture2D( tDepth, screenPosition ).x;
			#endif
		}

		void main() {
			float depth = getLinearDepth( vUv );
			gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );

		}`},Kp={name:"GTAOBlendShader",uniforms:{tDiffuse:{value:null},intensity:{value:1}},vertexShader:`
		varying vec2 vUv;

		void main() {
			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
		}`,fragmentShader:`
		uniform float intensity;
		uniform sampler2D tDiffuse;
		varying vec2 vUv;

		void main() {
			vec4 texel = texture2D( tDiffuse, vUv );
			gl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);
		}`};function yE(i=5){let e=Math.floor(i)%2===0?Math.floor(i)+1:Math.floor(i),t=QP(e),n=t.length,r=new Uint8Array(n*4);for(let o=0;o<n;++o){let a=t[o],c=2*Math.PI*a/n,l=new q(Math.cos(c),Math.sin(c),0).normalize();r[o*4]=(l.x*.5+.5)*255,r[o*4+1]=(l.y*.5+.5)*255,r[o*4+2]=127,r[o*4+3]=255}let s=new An(r,e,e);return s.wrapS=gn,s.wrapT=gn,s.needsUpdate=!0,s}function QP(i){let e=Math.floor(i)%2===0?Math.floor(i)+1:Math.floor(i),t=e*e,n=Array(t).fill(0),r=Math.floor(e/2),s=e-1;for(let o=1;o<=t;){if(r===-1&&s===e?(s=e-2,r=0):(s===e&&(s=0),r<0&&(r=e-1)),n[r*e+s]!==0){s-=2,r++;continue}else n[r*e+s]=o++;s++,r--}return n}var Lh={name:"PoissonDenoiseShader",defines:{SAMPLES:16,SAMPLE_VECTORS:Hy(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new Ce},cameraProjectionMatrixInverse:{value:new nt},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`

		varying vec2 vUv;

		void main() {
			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
		}`,fragmentShader:`

		varying vec2 vUv;

		uniform sampler2D tDiffuse;
		uniform sampler2D tNormal;
		uniform sampler2D tDepth;
		uniform sampler2D tNoise;
		uniform vec2 resolution;
		uniform mat4 cameraProjectionMatrixInverse;
		uniform float lumaPhi;
		uniform float depthPhi;
		uniform float normalPhi;
		uniform float radius;
		uniform int index;
		
		#include <common>
		#include <packing>

		#ifndef SAMPLE_LUMINANCE
		#define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)
		#endif

		#ifndef FRAGMENT_OUTPUT
		#define FRAGMENT_OUTPUT vec4(denoised, 1.)
		#endif

		float getLuminance(const in vec3 a) {
			return SAMPLE_LUMINANCE;
		}

		const vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;

		vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {
			vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);
			vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
			return viewSpacePosition.xyz / viewSpacePosition.w;
		}
		
		float getDepth(const vec2 uv) {
		#if DEPTH_VALUE_SOURCE == 1    
			return textureLod(tDepth, uv.xy, 0.0).a;
		#else
			return textureLod(tDepth, uv.xy, 0.0).r;
		#endif
		}

		float fetchDepth(const ivec2 uv) {
			#if DEPTH_VALUE_SOURCE == 1    
				return texelFetch(tDepth, uv.xy, 0).a;
			#else
				return texelFetch(tDepth, uv.xy, 0).r;
			#endif
		}

		vec3 computeNormalFromDepth(const vec2 uv) {
			vec2 size = vec2(textureSize(tDepth, 0));
			ivec2 p = ivec2(uv * size);
			float c0 = fetchDepth(p);
			float l2 = fetchDepth(p - ivec2(2, 0));
			float l1 = fetchDepth(p - ivec2(1, 0));
			float r1 = fetchDepth(p + ivec2(1, 0));
			float r2 = fetchDepth(p + ivec2(2, 0));
			float b2 = fetchDepth(p - ivec2(0, 2));
			float b1 = fetchDepth(p - ivec2(0, 1));
			float t1 = fetchDepth(p + ivec2(0, 1));
			float t2 = fetchDepth(p + ivec2(0, 2));
			float dl = abs((2.0 * l1 - l2) - c0);
			float dr = abs((2.0 * r1 - r2) - c0);
			float db = abs((2.0 * b1 - b2) - c0);
			float dt = abs((2.0 * t1 - t2) - c0);
			vec3 ce = getViewPosition(uv, c0).xyz;
			vec3 dpdx = (dl < dr) ?  ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz
									: -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;
			vec3 dpdy = (db < dt) ?  ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz
									: -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;
			return normalize(cross(dpdx, dpdy));
		}

		vec3 getViewNormal(const vec2 uv) {
		#if NORMAL_VECTOR_TYPE == 2
			return normalize(textureLod(tNormal, uv, 0.).rgb);
		#elif NORMAL_VECTOR_TYPE == 1
			return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);
		#else
			return computeNormalFromDepth(uv);
		#endif
		}

		void denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout float totalWeight) {
			vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);
			float sampleDepth = getDepth(sampleUv);
			vec3 sampleNormal = getViewNormal(sampleUv);
			vec3 neighborColor = sampleTexel.rgb;
			vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);
			
			float normalDiff = dot(viewNormal, sampleNormal);
			float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);
			float lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));
			float lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);
			float depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));
			float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);
			float w = lumaSimilarity * depthSimilarity * normalSimilarity;
		
			denoised += w * neighborColor;
			totalWeight += w;
		}
		
		void main() {
			float depth = getDepth(vUv.xy);	
			vec3 viewNormal = getViewNormal(vUv);	
			if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {
				discard;
				return;
			}
			vec4 texel = textureLod(tDiffuse, vUv, 0.0);
			vec3 center = texel.rgb;
			vec3 viewPos = getViewPosition(vUv, depth);

			vec2 noiseResolution = vec2(textureSize(tNoise, 0));
			vec2 noiseUv = vUv * resolution / noiseResolution;
			vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);
      		vec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));
    		mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);
		
			float totalWeight = 1.0;
			vec3 denoised = texel.rgb;
			for (int i = 0; i < SAMPLES; i++) {
				vec3 sampleDir = poissonDisk[i];
				vec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);
				vec2 sampleUv = vUv + offset;
				denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);
			}
		
			if (totalWeight > 0.) { 
				denoised /= totalWeight;
			}
			gl_FragColor = FRAGMENT_OUTPUT;
		}`};function Hy(i,e,t){let n=$P(i,e,t),r="vec3[SAMPLES](";for(let s=0;s<i;s++){let o=n[s];r+=`vec3(${o.x}, ${o.y}, ${o.z})${s<i-1?",":")"}`}return r}function $P(i,e,t){let n=[];for(let r=0;r<i;r++){let s=2*Math.PI*e*r/i,o=Math.pow(r/(i-1),t);n.push(new q(Math.cos(s),Math.sin(s),o))}return n}var Zp=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 t=0;t<512;t++)this.perm[t]=this.p[t&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]]}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,s){return e[0]*t+e[1]*n+e[2]*r+e[3]*s}noise(e,t){let n,r,s,o=.5*(Math.sqrt(3)-1),a=(e+t)*o,c=Math.floor(e+a),l=Math.floor(t+a),u=(3-Math.sqrt(3))/6,h=(c+l)*u,d=c-h,m=l-h,g=e-d,y=t-m,f,p;g>y?(f=1,p=0):(f=0,p=1);let v=g-f+u,b=y-p+u,x=g-1+2*u,_=y-1+2*u,T=c&255,w=l&255,A=this.perm[T+this.perm[w]]%12,E=this.perm[T+f+this.perm[w+p]]%12,M=this.perm[T+1+this.perm[w+1]]%12,P=.5-g*g-y*y;P<0?n=0:(P*=P,n=P*P*this.dot(this.grad3[A],g,y));let N=.5-v*v-b*b;N<0?r=0:(N*=N,r=N*N*this.dot(this.grad3[E],v,b));let L=.5-x*x-_*_;return L<0?s=0:(L*=L,s=L*L*this.dot(this.grad3[M],x,_)),70*(n+r+s)}noise3d(e,t,n){let r,s,o,a,l=(e+t+n)*.3333333333333333,u=Math.floor(e+l),h=Math.floor(t+l),d=Math.floor(n+l),m=1/6,g=(u+h+d)*m,y=u-g,f=h-g,p=d-g,v=e-y,b=t-f,x=n-p,_,T,w,A,E,M;v>=b?b>=x?(_=1,T=0,w=0,A=1,E=1,M=0):v>=x?(_=1,T=0,w=0,A=1,E=0,M=1):(_=0,T=0,w=1,A=1,E=0,M=1):b<x?(_=0,T=0,w=1,A=0,E=1,M=1):v<x?(_=0,T=1,w=0,A=0,E=1,M=1):(_=0,T=1,w=0,A=1,E=1,M=0);let P=v-_+m,N=b-T+m,L=x-w+m,D=v-A+2*m,$=b-E+2*m,U=x-M+2*m,I=v-1+3*m,V=b-1+3*m,W=x-1+3*m,Q=u&255,se=h&255,oe=d&255,ge=this.perm[Q+this.perm[se+this.perm[oe]]]%12,O=this.perm[Q+_+this.perm[se+T+this.perm[oe+w]]]%12,S=this.perm[Q+A+this.perm[se+E+this.perm[oe+M]]]%12,R=this.perm[Q+1+this.perm[se+1+this.perm[oe+1]]]%12,z=.6-v*v-b*b-x*x;z<0?r=0:(z*=z,r=z*z*this.dot3(this.grad3[ge],v,b,x));let Y=.6-P*P-N*N-L*L;Y<0?s=0:(Y*=Y,s=Y*Y*this.dot3(this.grad3[O],P,N,L));let K=.6-D*D-$*$-U*U;K<0?o=0:(K*=K,o=K*K*this.dot3(this.grad3[S],D,$,U));let re=.6-I*I-V*V-W*W;return re<0?a=0:(re*=re,a=re*re*this.dot3(this.grad3[R],I,V,W)),32*(r+s+o+a)}noise4d(e,t,n,r){let s=this.grad4,o=this.simplex,a=this.perm,c=(Math.sqrt(5)-1)/4,l=(5-Math.sqrt(5))/20,u,h,d,m,g,y=(e+t+n+r)*c,f=Math.floor(e+y),p=Math.floor(t+y),v=Math.floor(n+y),b=Math.floor(r+y),x=(f+p+v+b)*l,_=f-x,T=p-x,w=v-x,A=b-x,E=e-_,M=t-T,P=n-w,N=r-A,L=E>M?32:0,D=E>P?16:0,$=M>P?8:0,U=E>N?4:0,I=M>N?2:0,V=P>N?1:0,W=L+D+$+U+I+V,Q=o[W][0]>=3?1:0,se=o[W][1]>=3?1:0,oe=o[W][2]>=3?1:0,ge=o[W][3]>=3?1:0,O=o[W][0]>=2?1:0,S=o[W][1]>=2?1:0,R=o[W][2]>=2?1:0,z=o[W][3]>=2?1:0,Y=o[W][0]>=1?1:0,K=o[W][1]>=1?1:0,re=o[W][2]>=1?1:0,de=o[W][3]>=1?1:0,te=E-Q+l,ne=M-se+l,H=P-oe+l,_e=N-ge+l,me=E-O+2*l,be=M-S+2*l,he=P-R+2*l,Ne=N-z+2*l,Me=E-Y+3*l,Z=M-K+3*l,B=P-re+3*l,k=N-de+3*l,F=E-1+4*l,G=M-1+4*l,j=P-1+4*l,ee=N-1+4*l,ie=f&255,ce=p&255,fe=v&255,ue=b&255,Ee=a[ie+a[ce+a[fe+a[ue]]]]%32,Se=a[ie+Q+a[ce+se+a[fe+oe+a[ue+ge]]]]%32,De=a[ie+O+a[ce+S+a[fe+R+a[ue+z]]]]%32,ze=a[ie+Y+a[ce+K+a[fe+re+a[ue+de]]]]%32,Je=a[ie+1+a[ce+1+a[fe+1+a[ue+1]]]]%32,Fe=.6-E*E-M*M-P*P-N*N;Fe<0?u=0:(Fe*=Fe,u=Fe*Fe*this.dot4(s[Ee],E,M,P,N));let Xe=.6-te*te-ne*ne-H*H-_e*_e;Xe<0?h=0:(Xe*=Xe,h=Xe*Xe*this.dot4(s[Se],te,ne,H,_e));let ae=.6-me*me-be*be-he*he-Ne*Ne;ae<0?d=0:(ae*=ae,d=ae*ae*this.dot4(s[De],me,be,he,Ne));let Le=.6-Me*Me-Z*Z-B*B-k*k;Le<0?m=0:(Le*=Le,m=Le*Le*this.dot4(s[ze],Me,Z,B,k));let xe=.6-F*F-G*G-j*j-ee*ee;return xe<0?g=0:(xe*=xe,g=xe*xe*this.dot4(s[Je],F,G,j,ee)),27*(u+h+d+m+g)}};var zc=class i extends li{constructor(e,t,n,r,s,o,a){super(),this.width=n!==void 0?n:512,this.height=r!==void 0?r:512,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=new Map,this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=yE(),this.pdNoiseTexture=this.generateNoise(),this.gtaoRenderTarget=new on(this.width,this.height,{type:Hn}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new $t({defines:Object.assign({},Ih.defines),uniforms:Gn.clone(Ih.uniforms),vertexShader:Ih.vertexShader,fragmentShader:Ih.fragmentShader,blending:xn,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,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 Go,this.normalMaterial.blending=xn,this.pdMaterial=new $t({defines:Object.assign({},Lh.defines),uniforms:Gn.clone(Lh.uniforms),vertexShader:Lh.vertexShader,fragmentShader:Lh.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 $t({defines:Object.assign({},Nh.defines),uniforms:Gn.clone(Nh.uniforms),vertexShader:Nh.vertexShader,fragmentShader:Nh.fragmentShader,blending:xn}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new $t({uniforms:Gn.clone(Bc.uniforms),vertexShader:Bc.vertexShader,fragmentShader:Bc.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:vc,blendDst:Ks,blendEquation:yi,blendSrcAlpha:xc,blendDstAlpha:Ks,blendEquationAlpha:yi}),this.blendMaterial=new $t({uniforms:Gn.clone(Kp.uniforms),vertexShader:Kp.vertexShader,fragmentShader:Kp.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:wu,blendSrc:vc,blendDst:Ks,blendEquation:yi,blendSrcAlpha:xc,blendDstAlpha:Ks,blendEquationAlpha:yi}),this.fsQuad=new Fr(null),this.originalClearColor=new Be,this.setGBuffer(s?s.depthTexture:void 0,s?s.normalTexture:void 0),o!==void 0&&this.updateGtaoMaterial(o),a!==void 0&&this.updatePdMaterial(a)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),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){e!==void 0?(this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1):(this.depthTexture=new Xs,this.depthTexture.format=Er,this.depthTexture.type=Or,this.normalRenderTarget=new on(this.width,this.height,{minFilter:Jt,magFilter:Jt,type:Hn,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);let n=this.normalTexture?1:0,r=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.defines.DEPTH_SWIZZLING=r,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.defines.DEPTH_SWIZZLING=r,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.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?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=e.screenSpaceRadius?1:0,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=Hy(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(e,t,n){switch(this._renderGBuffer&&(this.overrideVisibility(),this.renderOverride(e,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(e,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.renderPass(e,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case i.OUTPUT.Off:break;case i.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=xn,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case i.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=xn,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case i.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=xn,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case i.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case i.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=xn,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case i.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=xn,this.renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.renderPass(e,this.blendMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}renderPass(e,t,n,r,s){e.getClearColor(this.originalClearColor);let o=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r!=null&&(e.setClearColor(r),e.setClearAlpha(s||0),e.clear()),this.fsQuad.material=t,this.fsQuad.render(e),e.autoClear=a,e.setClearColor(this.originalClearColor),e.setClearAlpha(o)}renderOverride(e,t,n,r,s){e.getClearColor(this.originalClearColor);let o=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,r=t.clearColor||r,s=t.clearAlpha||s,r!=null&&(e.setClearColor(r),e.setClearAlpha(s||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=a,e.setClearColor(this.originalClearColor),e.setClearAlpha(o)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),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)}overrideVisibility(){let e=this.scene,t=this._visibilityCache;e.traverse(function(n){t.set(n,n.visible),(n.isPoints||n.isLine)&&(n.visible=!1)})}restoreVisibility(){let e=this.scene,t=this._visibilityCache;e.traverse(function(n){let r=t.get(n);n.visible=r}),t.clear()}generateNoise(e=64){let t=new Zp,n=e*e*4,r=new Uint8Array(n);for(let o=0;o<e;o++)for(let a=0;a<e;a++){let c=o,l=a;r[(o*e+a)*4]=(t.noise(c,l)*.5+.5)*255,r[(o*e+a)*4+1]=(t.noise(c+e,l)*.5+.5)*255,r[(o*e+a)*4+2]=(t.noise(c,l+e)*.5+.5)*255,r[(o*e+a)*4+3]=(t.noise(c+e,l+e)*.5+.5)*255}let s=new An(r,e,e,Ln,ci);return s.wrapS=gn,s.wrapT=gn,s.needsUpdate=!0,s}};zc.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};var xE={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
		precision highp float;

		uniform mat4 modelViewMatrix;
		uniform mat4 projectionMatrix;

		attribute vec3 position;
		attribute vec2 uv;

		varying vec2 vUv;

		void main() {

			vUv = uv;
			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

		}`,fragmentShader:`
	
		precision highp float;

		uniform sampler2D tDiffuse;

		#include <tonemapping_pars_fragment>
		#include <colorspace_pars_fragment>

		varying vec2 vUv;

		void main() {

			gl_FragColor = texture2D( tDiffuse, vUv );

			// tone mapping

			#ifdef LINEAR_TONE_MAPPING

				gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );

			#elif defined( REINHARD_TONE_MAPPING )

				gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );

			#elif defined( CINEON_TONE_MAPPING )

				gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );

			#elif defined( ACES_FILMIC_TONE_MAPPING )

				gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );

			#elif defined( AGX_TONE_MAPPING )

				gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );

			#elif defined( NEUTRAL_TONE_MAPPING )

				gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );

			#endif

			// color space

			#ifdef SRGB_TRANSFER

				gl_FragColor = sRGBTransferOETF( gl_FragColor );

			#endif

		}`};var Jp=class extends li{constructor(){super();let e=xE;this.uniforms=Gn.clone(e.uniforms),this.material=new Vo({name:e.name,uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader}),this.fsQuad=new Fr(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},bt.getTransfer(this._outputColorSpace)===kt&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===Du?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===Fu?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===Uu?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===qo?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===ku?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===Bu&&(this.material.defines.NEUTRAL_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}};var Oh={name:"SMAAEdgesShader",defines:{SMAA_THRESHOLD:"0.1"},uniforms:{tDiffuse:{value:null},resolution:{value:new Ce(1/1024,1/512)}},vertexShader:`

		uniform vec2 resolution;

		varying vec2 vUv;
		varying vec4 vOffset[ 3 ];

		void SMAAEdgeDetectionVS( vec2 texcoord ) {
			vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0,  1.0 ); // WebGL port note: Changed sign in W component
			vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4(  1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component
			vOffset[ 2 ] = texcoord.xyxy + resolution.xyxy * vec4( -2.0, 0.0, 0.0,  2.0 ); // WebGL port note: Changed sign in W component
		}

		void main() {

			vUv = uv;

			SMAAEdgeDetectionVS( vUv );

			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

		}`,fragmentShader:`

		uniform sampler2D tDiffuse;

		varying vec2 vUv;
		varying vec4 vOffset[ 3 ];

		vec4 SMAAColorEdgeDetectionPS( vec2 texcoord, vec4 offset[3], sampler2D colorTex ) {
			vec2 threshold = vec2( SMAA_THRESHOLD, SMAA_THRESHOLD );

			// Calculate color deltas:
			vec4 delta;
			vec3 C = texture2D( colorTex, texcoord ).rgb;

			vec3 Cleft = texture2D( colorTex, offset[0].xy ).rgb;
			vec3 t = abs( C - Cleft );
			delta.x = max( max( t.r, t.g ), t.b );

			vec3 Ctop = texture2D( colorTex, offset[0].zw ).rgb;
			t = abs( C - Ctop );
			delta.y = max( max( t.r, t.g ), t.b );

			// We do the usual threshold:
			vec2 edges = step( threshold, delta.xy );

			// Then discard if there is no edge:
			if ( dot( edges, vec2( 1.0, 1.0 ) ) == 0.0 )
				discard;

			// Calculate right and bottom deltas:
			vec3 Cright = texture2D( colorTex, offset[1].xy ).rgb;
			t = abs( C - Cright );
			delta.z = max( max( t.r, t.g ), t.b );

			vec3 Cbottom  = texture2D( colorTex, offset[1].zw ).rgb;
			t = abs( C - Cbottom );
			delta.w = max( max( t.r, t.g ), t.b );

			// Calculate the maximum delta in the direct neighborhood:
			float maxDelta = max( max( max( delta.x, delta.y ), delta.z ), delta.w );

			// Calculate left-left and top-top deltas:
			vec3 Cleftleft  = texture2D( colorTex, offset[2].xy ).rgb;
			t = abs( C - Cleftleft );
			delta.z = max( max( t.r, t.g ), t.b );

			vec3 Ctoptop = texture2D( colorTex, offset[2].zw ).rgb;
			t = abs( C - Ctoptop );
			delta.w = max( max( t.r, t.g ), t.b );

			// Calculate the final maximum delta:
			maxDelta = max( max( maxDelta, delta.z ), delta.w );

			// Local contrast adaptation in action:
			edges.xy *= step( 0.5 * maxDelta, delta.xy );

			return vec4( edges, 0.0, 0.0 );
		}

		void main() {

			gl_FragColor = SMAAColorEdgeDetectionPS( vUv, vOffset, tDiffuse );

		}`},Dh={name:"SMAAWeightsShader",defines:{SMAA_MAX_SEARCH_STEPS:"8",SMAA_AREATEX_MAX_DISTANCE:"16",SMAA_AREATEX_PIXEL_SIZE:"( 1.0 / vec2( 160.0, 560.0 ) )",SMAA_AREATEX_SUBTEX_SIZE:"( 1.0 / 7.0 )"},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new Ce(1/1024,1/512)}},vertexShader:`

		uniform vec2 resolution;

		varying vec2 vUv;
		varying vec4 vOffset[ 3 ];
		varying vec2 vPixcoord;

		void SMAABlendingWeightCalculationVS( vec2 texcoord ) {
			vPixcoord = texcoord / resolution;

			// We will use these offsets for the searches later on (see @PSEUDO_GATHER4):
			vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.25, 0.125, 1.25, 0.125 ); // WebGL port note: Changed sign in Y and W components
			vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( -0.125, 0.25, -0.125, -1.25 ); // WebGL port note: Changed sign in Y and W components

			// And these for the searches, they indicate the ends of the loops:
			vOffset[ 2 ] = vec4( vOffset[ 0 ].xz, vOffset[ 1 ].yw ) + vec4( -2.0, 2.0, -2.0, 2.0 ) * resolution.xxyy * float( SMAA_MAX_SEARCH_STEPS );

		}

		void main() {

			vUv = uv;

			SMAABlendingWeightCalculationVS( vUv );

			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

		}`,fragmentShader:`

		#define SMAASampleLevelZeroOffset( tex, coord, offset ) texture2D( tex, coord + float( offset ) * resolution, 0.0 )

		uniform sampler2D tDiffuse;
		uniform sampler2D tArea;
		uniform sampler2D tSearch;
		uniform vec2 resolution;

		varying vec2 vUv;
		varying vec4 vOffset[3];
		varying vec2 vPixcoord;

		#if __VERSION__ == 100
		vec2 round( vec2 x ) {
			return sign( x ) * floor( abs( x ) + 0.5 );
		}
		#endif

		float SMAASearchLength( sampler2D searchTex, vec2 e, float bias, float scale ) {
			// Not required if searchTex accesses are set to point:
			// float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);
			// e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +
			//     e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;
			e.r = bias + e.r * scale;
			return 255.0 * texture2D( searchTex, e, 0.0 ).r;
		}

		float SMAASearchXLeft( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {
			/**
				* @PSEUDO_GATHER4
				* This texcoord has been offset by (-0.25, -0.125) in the vertex shader to
				* sample between edge, thus fetching four edges in a row.
				* Sampling with different offsets in each direction allows to disambiguate
				* which edges are active from the four fetched ones.
				*/
			vec2 e = vec2( 0.0, 1.0 );

			for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for
				e = texture2D( edgesTex, texcoord, 0.0 ).rg;
				texcoord -= vec2( 2.0, 0.0 ) * resolution;
				if ( ! ( texcoord.x > end && e.g > 0.8281 && e.r == 0.0 ) ) break;
			}

			// We correct the previous (-0.25, -0.125) offset we applied:
			texcoord.x += 0.25 * resolution.x;

			// The searches are bias by 1, so adjust the coords accordingly:
			texcoord.x += resolution.x;

			// Disambiguate the length added by the last step:
			texcoord.x += 2.0 * resolution.x; // Undo last step
			texcoord.x -= resolution.x * SMAASearchLength(searchTex, e, 0.0, 0.5);

			return texcoord.x;
		}

		float SMAASearchXRight( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {
			vec2 e = vec2( 0.0, 1.0 );

			for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for
				e = texture2D( edgesTex, texcoord, 0.0 ).rg;
				texcoord += vec2( 2.0, 0.0 ) * resolution;
				if ( ! ( texcoord.x < end && e.g > 0.8281 && e.r == 0.0 ) ) break;
			}

			texcoord.x -= 0.25 * resolution.x;
			texcoord.x -= resolution.x;
			texcoord.x -= 2.0 * resolution.x;
			texcoord.x += resolution.x * SMAASearchLength( searchTex, e, 0.5, 0.5 );

			return texcoord.x;
		}

		float SMAASearchYUp( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {
			vec2 e = vec2( 1.0, 0.0 );

			for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for
				e = texture2D( edgesTex, texcoord, 0.0 ).rg;
				texcoord += vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign
				if ( ! ( texcoord.y > end && e.r > 0.8281 && e.g == 0.0 ) ) break;
			}

			texcoord.y -= 0.25 * resolution.y; // WebGL port note: Changed sign
			texcoord.y -= resolution.y; // WebGL port note: Changed sign
			texcoord.y -= 2.0 * resolution.y; // WebGL port note: Changed sign
			texcoord.y += resolution.y * SMAASearchLength( searchTex, e.gr, 0.0, 0.5 ); // WebGL port note: Changed sign

			return texcoord.y;
		}

		float SMAASearchYDown( sampler2D edgesTex, sampler2D searchTex, vec2 texcoord, float end ) {
			vec2 e = vec2( 1.0, 0.0 );

			for ( int i = 0; i < SMAA_MAX_SEARCH_STEPS; i ++ ) { // WebGL port note: Changed while to for
				e = texture2D( edgesTex, texcoord, 0.0 ).rg;
				texcoord -= vec2( 0.0, 2.0 ) * resolution; // WebGL port note: Changed sign
				if ( ! ( texcoord.y < end && e.r > 0.8281 && e.g == 0.0 ) ) break;
			}

			texcoord.y += 0.25 * resolution.y; // WebGL port note: Changed sign
			texcoord.y += resolution.y; // WebGL port note: Changed sign
			texcoord.y += 2.0 * resolution.y; // WebGL port note: Changed sign
			texcoord.y -= resolution.y * SMAASearchLength( searchTex, e.gr, 0.5, 0.5 ); // WebGL port note: Changed sign

			return texcoord.y;
		}

		vec2 SMAAArea( sampler2D areaTex, vec2 dist, float e1, float e2, float offset ) {
			// Rounding prevents precision errors of bilinear filtering:
			vec2 texcoord = float( SMAA_AREATEX_MAX_DISTANCE ) * round( 4.0 * vec2( e1, e2 ) ) + dist;

			// We do a scale and bias for mapping to texel space:
			texcoord = SMAA_AREATEX_PIXEL_SIZE * texcoord + ( 0.5 * SMAA_AREATEX_PIXEL_SIZE );

			// Move to proper place, according to the subpixel offset:
			texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;

			return texture2D( areaTex, texcoord, 0.0 ).rg;
		}

		vec4 SMAABlendingWeightCalculationPS( vec2 texcoord, vec2 pixcoord, vec4 offset[ 3 ], sampler2D edgesTex, sampler2D areaTex, sampler2D searchTex, ivec4 subsampleIndices ) {
			vec4 weights = vec4( 0.0, 0.0, 0.0, 0.0 );

			vec2 e = texture2D( edgesTex, texcoord ).rg;

			if ( e.g > 0.0 ) { // Edge at north
				vec2 d;

				// Find the distance to the left:
				vec2 coords;
				coords.x = SMAASearchXLeft( edgesTex, searchTex, offset[ 0 ].xy, offset[ 2 ].x );
				coords.y = offset[ 1 ].y; // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET)
				d.x = coords.x;

				// Now fetch the left crossing edges, two at a time using bilinear
				// filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to
				// discern what value each edge has:
				float e1 = texture2D( edgesTex, coords, 0.0 ).r;

				// Find the distance to the right:
				coords.x = SMAASearchXRight( edgesTex, searchTex, offset[ 0 ].zw, offset[ 2 ].y );
				d.y = coords.x;

				// We want the distances to be in pixel units (doing this here allow to
				// better interleave arithmetic and memory accesses):
				d = d / resolution.x - pixcoord.x;

				// SMAAArea below needs a sqrt, as the areas texture is compressed
				// quadratically:
				vec2 sqrt_d = sqrt( abs( d ) );

				// Fetch the right crossing edges:
				coords.y -= 1.0 * resolution.y; // WebGL port note: Added
				float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 1, 0 ) ).r;

				// Ok, we know how this pattern looks like, now it is time for getting
				// the actual area:
				weights.rg = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.y ) );
			}

			if ( e.r > 0.0 ) { // Edge at west
				vec2 d;

				// Find the distance to the top:
				vec2 coords;

				coords.y = SMAASearchYUp( edgesTex, searchTex, offset[ 1 ].xy, offset[ 2 ].z );
				coords.x = offset[ 0 ].x; // offset[1].x = texcoord.x - 0.25 * resolution.x;
				d.x = coords.y;

				// Fetch the top crossing edges:
				float e1 = texture2D( edgesTex, coords, 0.0 ).g;

				// Find the distance to the bottom:
				coords.y = SMAASearchYDown( edgesTex, searchTex, offset[ 1 ].zw, offset[ 2 ].w );
				d.y = coords.y;

				// We want the distances to be in pixel units:
				d = d / resolution.y - pixcoord.y;

				// SMAAArea below needs a sqrt, as the areas texture is compressed
				// quadratically:
				vec2 sqrt_d = sqrt( abs( d ) );

				// Fetch the bottom crossing edges:
				coords.y -= 1.0 * resolution.y; // WebGL port note: Added
				float e2 = SMAASampleLevelZeroOffset( edgesTex, coords, ivec2( 0, 1 ) ).g;

				// Get the area for this direction:
				weights.ba = SMAAArea( areaTex, sqrt_d, e1, e2, float( subsampleIndices.x ) );
			}

			return weights;
		}

		void main() {

			gl_FragColor = SMAABlendingWeightCalculationPS( vUv, vPixcoord, vOffset, tDiffuse, tArea, tSearch, ivec4( 0.0 ) );

		}`},Qp={name:"SMAABlendShader",uniforms:{tDiffuse:{value:null},tColor:{value:null},resolution:{value:new Ce(1/1024,1/512)}},vertexShader:`

		uniform vec2 resolution;

		varying vec2 vUv;
		varying vec4 vOffset[ 2 ];

		void SMAANeighborhoodBlendingVS( vec2 texcoord ) {
			vOffset[ 0 ] = texcoord.xyxy + resolution.xyxy * vec4( -1.0, 0.0, 0.0, 1.0 ); // WebGL port note: Changed sign in W component
			vOffset[ 1 ] = texcoord.xyxy + resolution.xyxy * vec4( 1.0, 0.0, 0.0, -1.0 ); // WebGL port note: Changed sign in W component
		}

		void main() {

			vUv = uv;

			SMAANeighborhoodBlendingVS( vUv );

			gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );

		}`,fragmentShader:`

		uniform sampler2D tDiffuse;
		uniform sampler2D tColor;
		uniform vec2 resolution;

		varying vec2 vUv;
		varying vec4 vOffset[ 2 ];

		vec4 SMAANeighborhoodBlendingPS( vec2 texcoord, vec4 offset[ 2 ], sampler2D colorTex, sampler2D blendTex ) {
			// Fetch the blending weights for current pixel:
			vec4 a;
			a.xz = texture2D( blendTex, texcoord ).xz;
			a.y = texture2D( blendTex, offset[ 1 ].zw ).g;
			a.w = texture2D( blendTex, offset[ 1 ].xy ).a;

			// Is there any blending weight with a value greater than 0.0?
			if ( dot(a, vec4( 1.0, 1.0, 1.0, 1.0 )) < 1e-5 ) {
				return texture2D( colorTex, texcoord, 0.0 );
			} else {
				// Up to 4 lines can be crossing a pixel (one through each edge). We
				// favor blending by choosing the line with the maximum weight for each
				// direction:
				vec2 offset;
				offset.x = a.a > a.b ? a.a : -a.b; // left vs. right
				offset.y = a.g > a.r ? -a.g : a.r; // top vs. bottom // WebGL port note: Changed signs

				// Then we go in the direction that has the maximum weight:
				if ( abs( offset.x ) > abs( offset.y )) { // horizontal vs. vertical
					offset.y = 0.0;
				} else {
					offset.x = 0.0;
				}

				// Fetch the opposite color and lerp by hand:
				vec4 C = texture2D( colorTex, texcoord, 0.0 );
				texcoord += sign( offset ) * resolution;
				vec4 Cop = texture2D( colorTex, texcoord, 0.0 );
				float s = abs( offset.x ) > abs( offset.y ) ? abs( offset.x ) : abs( offset.y );

				// WebGL port note: Added gamma correction
				C.xyz = pow(C.xyz, vec3(2.2));
				Cop.xyz = pow(Cop.xyz, vec3(2.2));
				vec4 mixed = mix(C, Cop, s);
				mixed.xyz = pow(mixed.xyz, vec3(1.0 / 2.2));

				return mixed;
			}
		}

		void main() {

			gl_FragColor = SMAANeighborhoodBlendingPS( vUv, vOffset, tColor, tDiffuse );

		}`};var $p=class extends li{constructor(e,t){super(),this.edgesRT=new on(e,t,{depthBuffer:!1,type:Hn}),this.edgesRT.texture.name="SMAAPass.edges",this.weightsRT=new on(e,t,{depthBuffer:!1,type:Hn}),this.weightsRT.texture.name="SMAAPass.weights";let n=this,r=new Image;r.src=this.getAreaTexture(),r.onload=function(){n.areaTexture.needsUpdate=!0},this.areaTexture=new Qt,this.areaTexture.name="SMAAPass.area",this.areaTexture.image=r,this.areaTexture.minFilter=nn,this.areaTexture.generateMipmaps=!1,this.areaTexture.flipY=!1;let s=new Image;s.src=this.getSearchTexture(),s.onload=function(){n.searchTexture.needsUpdate=!0},this.searchTexture=new Qt,this.searchTexture.name="SMAAPass.search",this.searchTexture.image=s,this.searchTexture.magFilter=Jt,this.searchTexture.minFilter=Jt,this.searchTexture.generateMipmaps=!1,this.searchTexture.flipY=!1,this.uniformsEdges=Gn.clone(Oh.uniforms),this.uniformsEdges.resolution.value.set(1/e,1/t),this.materialEdges=new $t({defines:Object.assign({},Oh.defines),uniforms:this.uniformsEdges,vertexShader:Oh.vertexShader,fragmentShader:Oh.fragmentShader}),this.uniformsWeights=Gn.clone(Dh.uniforms),this.uniformsWeights.resolution.value.set(1/e,1/t),this.uniformsWeights.tDiffuse.value=this.edgesRT.texture,this.uniformsWeights.tArea.value=this.areaTexture,this.uniformsWeights.tSearch.value=this.searchTexture,this.materialWeights=new $t({defines:Object.assign({},Dh.defines),uniforms:this.uniformsWeights,vertexShader:Dh.vertexShader,fragmentShader:Dh.fragmentShader}),this.uniformsBlend=Gn.clone(Qp.uniforms),this.uniformsBlend.resolution.value.set(1/e,1/t),this.uniformsBlend.tDiffuse.value=this.weightsRT.texture,this.materialBlend=new $t({uniforms:this.uniformsBlend,vertexShader:Qp.vertexShader,fragmentShader:Qp.fragmentShader}),this.fsQuad=new Fr(null)}render(e,t,n){this.uniformsEdges.tDiffuse.value=n.texture,this.fsQuad.material=this.materialEdges,e.setRenderTarget(this.edgesRT),this.clear&&e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.materialWeights,e.setRenderTarget(this.weightsRT),this.clear&&e.clear(),this.fsQuad.render(e),this.uniformsBlend.tColor.value=n.texture,this.fsQuad.material=this.materialBlend,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(),this.fsQuad.render(e))}setSize(e,t){this.edgesRT.setSize(e,t),this.weightsRT.setSize(e,t),this.materialEdges.uniforms.resolution.value.set(1/e,1/t),this.materialWeights.uniforms.resolution.value.set(1/e,1/t),this.materialBlend.uniforms.resolution.value.set(1/e,1/t)}getAreaTexture(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAIAAACOVPcQAACBeklEQVR42u39W4xlWXrnh/3WWvuciIzMrKxrV8/0rWbY0+SQFKcb4owIkSIFCjY9AC1BT/LYBozRi+EX+cV+8IMsYAaCwRcBwjzMiw2jAWtgwC8WR5Q8mDFHZLNHTarZGrLJJllt1W2qKrsumZWZcTvn7L3W54e1vrXX3vuciLPPORFR1XE2EomorB0nVuz//r71re/y/1eMvb4Cb3N11xV/PP/2v4UBAwJG/7H8urx6/25/Gf8O5hypMQ0EEEQwAqLfoN/Z+97f/SW+/NvcgQk4sGBJK6H7N4PFVL+K+e0N11yNfkKvwUdwdlUAXPHHL38oa15f/i/46Ih6SuMSPmLAYAwyRKn7dfMGH97jaMFBYCJUgotIC2YAdu+LyW9vvubxAP8kAL8H/koAuOKP3+q6+xGnd5kdYCeECnGIJViwGJMAkQKfDvB3WZxjLKGh8VSCCzhwEWBpMc5/kBbjawT4HnwJfhr+pPBIu7uu+OOTo9vsmtQcniMBGkKFd4jDWMSCRUpLjJYNJkM+IRzQ+PQvIeAMTrBS2LEiaiR9b/5PuT6Ap/AcfAFO4Y3dA3DFH7/VS+M8k4baEAQfMI4QfbVDDGIRg7GKaIY52qAjTAgTvGBAPGIIghOCYAUrGFNgzA7Q3QhgCwfwAnwe5vDejgG44o/fbm1C5ZlYQvQDARPAIQGxCWBM+wWl37ZQESb4gImexGMDouhGLx1Cst0Saa4b4AqO4Hk4gxo+3DHAV/nx27p3JziPM2pVgoiia5MdEzCGULprIN7gEEeQ5IQxEBBBQnxhsDb5auGmAAYcHMA9eAAz8PBol8/xij9+C4Djlim4gJjWcwZBhCBgMIIYxGAVIkH3ZtcBuLdtRFMWsPGoY9rN+HoBji9VBYdwD2ZQg4cnO7OSq/z4rU5KKdwVbFAjNojCQzTlCLPFSxtamwh2jMUcEgg2Wm/6XgErIBhBckQtGN3CzbVacERgCnfgLswhnvqf7QyAq/z4rRZm1YglYE3affGITaZsdIe2FmMIpnOCap25I6jt2kCwCW0D1uAD9sZctNGXcQIHCkINDQgc78aCr+zjtw3BU/ijdpw3zhCwcaONwBvdeS2YZKkJNJsMPf2JKEvC28RXxxI0ASJyzQCjCEQrO4Q7sFArEzjZhaFc4cdv+/JFdKULM4px0DfUBI2hIsy06BqLhGTQEVdbfAIZXYMPesq6VoCHICzUyjwInO4Y411//LYLs6TDa9wvg2CC2rElgAnpTBziThxaL22MYhzfkghz6GAs2VHbbdM91VZu1MEEpupMMwKyVTb5ij9+u4VJG/5EgEMMmFF01cFai3isRbKbzb+YaU/MQbAm2XSMoUPAmvZzbuKYRIFApbtlrfFuUGd6vq2hXNnH78ZLh/iFhsQG3T4D1ib7k5CC6vY0DCbtrohgLEIClXiGtl10zc0CnEGIhhatLBva7NP58Tvw0qE8yWhARLQ8h4+AhQSP+I4F5xoU+VilGRJs6wnS7ruti/4KvAY/CfdgqjsMy4pf8fodQO8/gnuX3f/3xi3om1/h7THr+co3x93PP9+FBUfbNUjcjEmhcrkT+8K7ml7V10Jo05mpIEFy1NmCJWx9SIKKt+EjAL4Ez8EBVOB6havuT/rByPvHXK+9zUcfcbb254+9fydJknYnRr1oGfdaiAgpxu1Rx/Rek8KISftx3L+DfsLWAANn8Hvw0/AFeAGO9DFV3c6D+CcWbL8Dj9e7f+T1k8AZv/d7+PXWM/Z+VvdCrIvuAKO09RpEEQJM0Ci6+B4xhTWr4cZNOvhktabw0ta0rSJmqz3Yw5/AKXwenod7cAhTmBSPKf6JBdvH8IP17h95pXqw50/+BFnj88fev4NchyaK47OPhhtI8RFSvAfDSNh0Ck0p2gLxGkib5NJj/JWCr90EWQJvwBzO4AHcgztwAFN1evHPUVGwfXON+0debT1YeGON9Yy9/63X+OguiwmhIhQhD7l4sMqlG3D86Suc3qWZ4rWjI1X7u0Ytw6x3rIMeIOPDprfe2XzNgyj6PahhBjO4C3e6puDgXrdg+/5l948vF3bqwZetZ+z9Rx9zdIY5pInPK4Nk0t+l52xdK2B45Qd87nM8fsD5EfUhIcJcERw4RdqqH7Yde5V7m1vhNmtedkz6EDzUMF/2jJYWbC+4fzzA/Y+/8PPH3j9dcBAPIRP8JLXd5BpAu03aziOL3VVHZzz3CXWDPWd+SH2AnxIqQoTZpo9Ckc6HIrFbAbzNmlcg8Ag8NFDDAhbJvTBZXbC94P7t68EXfv6o+21gUtPETU7bbkLxvNKRFG2+KXzvtObonPP4rBvsgmaKj404DlshFole1Glfh02fE7bYR7dZ82oTewIBGn1Md6CG6YUF26X376oevOLzx95vhUmgblI6LBZwTCDY7vMq0op5WVXgsObOXJ+1x3qaBl9j1FeLxbhU9w1F+Wiba6s1X/TBz1LnUfuYDi4r2C69f1f14BWfP+p+W2GFKuC9phcELMYRRLur9DEZTUdEH+iEqWdaM7X4WOoPGI+ZYD2+wcQ+y+ioHUZ9dTDbArzxmi/bJI9BND0Ynd6lBdve/butBw8+f/T9D3ABa3AG8W3VPX4hBin+bj8dMMmSpp5pg7fJ6xrBFE2WQQEWnV8Qg3FbAWzYfM1rREEnmvkN2o1+acG2d/9u68GDzx91v3mAjb1zkpqT21OipPKO0b9TO5W0nTdOmAQm0TObts3aBKgwARtoPDiCT0gHgwnbArzxmtcLc08HgF1asN0C4Ms/fvD5I+7PhfqyXE/b7RbbrGyRQRT9ARZcwAUmgdoz0ehJ9Fn7QAhUjhDAQSw0bV3T3WbNa59jzmiP6GsWbGXDX2ytjy8+f9T97fiBPq9YeLdBmyuizZHaqXITnXiMUEEVcJ7K4j3BFPurtB4bixW8wTpweL8DC95szWMOqucFYGsWbGU7p3TxxxefP+r+oTVktxY0v5hbq3KiOKYnY8ddJVSBxuMMVffNbxwIOERShst73HZ78DZrHpmJmH3K6sGz0fe3UUj0eyRrSCGTTc+rjVNoGzNSv05srAxUBh8IhqChiQgVNIIBH3AVPnrsnXQZbLTm8ammv8eVXn/vWpaTem5IXRlt+U/LA21zhSb9cye6jcOfCnOwhIAYXAMVTUNV0QhVha9xjgA27ODJbLbmitt3tRN80lqG6N/khgot4ZVlOyO4WNg3OIMzhIZQpUEHieg2im6F91hB3I2tubql6BYNN9Hj5S7G0G2tahslBWKDnOiIvuAEDzakDQKDNFQT6gbn8E2y4BBubM230YIpBnDbMa+y3dx0n1S0BtuG62lCCXwcY0F72T1VRR3t2ONcsmDjbmzNt9RFs2LO2hQNyb022JisaI8rAWuw4HI3FuAIhZdOGIcdjLJvvObqlpqvWTJnnQbyi/1M9O8UxWhBs//H42I0q1Yb/XPGONzcmm+ri172mHKvZBpHkJaNJz6v9jxqiklDj3U4CA2ugpAaYMWqNXsdXbmJNd9egCnJEsphXNM+MnK3m0FCJ5S1kmJpa3DgPVbnQnPGWIDspW9ozbcO4K/9LkfaQO2KHuqlfFXSbdNzcEcwoqNEFE9zcIXu9/6n/ym/BC/C3aJLzEKPuYVlbFnfhZ8kcWxV3dbv4bKl28566wD+8C53aw49lTABp9PWbsB+knfc/Li3eVizf5vv/xmvnPKg5ihwKEwlrcHqucuVcVOxEv8aH37E3ZqpZypUulrHEtIWKUr+txHg+ojZDGlwnqmkGlzcVi1dLiNSJiHjfbRNOPwKpx9TVdTn3K05DBx4psIk4Ei8aCkJahRgffk4YnEXe07T4H2RR1u27E6wfQsBDofUgjFUFnwC2AiVtA+05J2zpiDK2Oa0c5fmAecN1iJzmpqFZxqYBCYhFTCsUNEmUnIcZ6aEA5rQVhEywG6w7HSW02XfOoBlQmjwulOFQAg66SvJblrTEX1YtJ3uG15T/BH1OfOQeuR8g/c0gdpT5fx2SKbs9EfHTKdM8A1GaJRHLVIwhcGyydZsbifAFVKl5EMKNU2Hryo+06BeTgqnxzYjThVySDikbtJPieco75lYfKAJOMEZBTjoITuWHXXZVhcUDIS2hpiXHV9Ku4u44bN5OYLDOkJo8w+xJSMbhBRHEdEs9JZUCkQrPMAvaHyLkxgkEHxiNkx/x2YB0mGsQ8EUWj/stW5YLhtS5SMu+/YBbNPDCkGTUybN8krRLBGPlZkVOA0j+a1+rkyQKWGaPHPLZOkJhioQYnVZ2hS3zVxMtgC46KuRwbJNd9nV2PHgb36F194ecf/Yeu2vAFe5nm/bRBFrnY4BauE8ERmZRFUn0k8hbftiVYSKMEme2dJCJSCGYAlNqh87bXOPdUkGy24P6d1ll21MBqqx48Fvv8ZHH8HZFY7j/uAq1xMJUFqCSUlJPmNbIiNsmwuMs/q9CMtsZsFO6SprzCS1Z7QL8xCQClEelpjTduDMsmWD8S1PT152BtvmIGvUeDA/yRn83u/x0/4qxoPHjx+PXY9pqX9bgMvh/Nz9kpP4pOe1/fYf3axUiMdHLlPpZCNjgtNFAhcHEDxTumNONhHrBduW+vOyY++70WWnPXj98eA4kOt/mj/5E05l9+O4o8ePx67HFqyC+qSSnyselqjZGaVK2TadbFLPWAQ4NBhHqDCCV7OTpo34AlSSylPtIdd2AJZlyzYQrDJ5lcWGNceD80CunPLGGzsfD+7wRb95NevJI5docQ3tgCyr5bGnyaPRlmwNsFELViOOx9loebGNq2moDOKpHLVP5al2cymWHbkfzGXL7kfRl44H9wZy33tvt+PB/Xnf93e+nh5ZlU18wCiRUa9m7kib9LYuOk+hudQNbxwm0AQqbfloimaB2lM5fChex+ylMwuTbfmXQtmWlenZljbdXTLuOxjI/fDDHY4Hjx8/Hrse0zXfPFxbUN1kKqSCCSk50m0Ajtx3ub9XHBKHXESb8iO6E+qGytF4nO0OG3SXzbJlhxBnKtKyl0NwybjvYCD30aMdjgePHz8eu56SVTBbgxJMliQ3Oauwg0QHxXE2Ez/EIReLdQj42Gzb4CLS0YJD9xUx7bsi0vJi5mUbW1QzL0h0PFk17rtiIPfJk52MB48fPx67npJJwyrBa2RCCQRTbGZSPCxTPOiND4G2pYyOQ4h4jINIJh5wFU1NFZt+IsZ59LSnDqBjZ2awbOku+yInunLcd8VA7rNnOxkPHj9+PGY9B0MWJJNozOJmlglvDMXDEozdhQWbgs/U6oBanGzLrdSNNnZFjOkmbi5bNt1lX7JLLhn3vXAg9/h4y/Hg8ePHI9dzQMEkWCgdRfYykYKnkP7D4rIujsujaKPBsB54vE2TS00ccvFY/Tth7JXeq1hz+qgVy04sAJawTsvOknHfCwdyT062HA8eP348Zj0vdoXF4pilKa2BROed+9fyw9rWRXeTFXESMOanvDZfJuJaSXouQdMdDJZtekZcLLvEeK04d8m474UDuaenW44Hjx8/Xns9YYqZpszGWB3AN/4VHw+k7WSFtJ3Qicuqb/NlVmgXWsxh570xg2UwxUw3WfO6B5nOuO8aA7lnZxuPB48fPx6znm1i4bsfcbaptF3zNT78eFPtwi1OaCNOqp1x3zUGcs/PN++AGD1+fMXrSVm2baTtPhPahbPhA71wIHd2bXzRa69nG+3CraTtPivahV/55tXWg8fyRY/9AdsY8VbSdp8V7cKrrgdfM//z6ILQFtJ2nxHtwmuoB4/kf74+gLeRtvvMaBdeSz34+vifx0YG20jbfTa0C6+tHrwe//NmOG0L8EbSdp8R7cLrrQe/996O+ai3ujQOskpTNULa7jOjXXj99eCd8lHvoFiwsbTdZ0a78PrrwTvlo966pLuRtB2fFe3Cm6oHP9kNH/W2FryxtN1nTLvwRurBO+Kj3pWXHidtx2dFu/Bm68Fb81HvykuPlrb7LGkX3mw9eGs+6h1Y8MbSdjegXcguQLjmevDpTQLMxtJ2N6NdyBZu9AbrwVvwUW+LbteULUpCdqm0HTelXbhNPe8G68Gb8lFvVfYfSNuxvrTdTWoXbozAzdaDZzfkorOj1oxVxlIMlpSIlpLrt8D4hrQL17z+c3h6hU/wv4Q/utps4+bm+6P/hIcf0JwQ5oQGPBL0eKPTYEXTW+eL/2DKn73J9BTXYANG57hz1cEMviVf/4tf5b/6C5pTQkMIWoAq7hTpOJjtAM4pxKu5vg5vXeUrtI09/Mo/5H+4z+Mp5xULh7cEm2QbRP2tFIKR7WM3fPf/jZ3SWCqLM2l4NxID5zB72HQXv3jj/8mLR5xXNA5v8EbFQEz7PpRfl1+MB/hlAN65qgDn3wTgH13hK7T59bmP+NIx1SHHU84nLOITt3iVz8mNO+lPrjGAnBFqmioNn1mTyk1ta47R6d4MrX7tjrnjYUpdUbv2rVr6YpVfsGG58AG8Ah9eyUN8CX4WfgV+G8LVWPDGb+Zd4cU584CtqSbMKxauxTg+dyn/LkVgA+IR8KHtejeFKRtTmLLpxN6mYVLjYxwXf5x2VofiZcp/lwKk4wGOpYDnoIZPdg/AAbwMfx0+ge9dgZvYjuqKe4HnGnykYo5TvJbG0Vj12JagRhwKa44H95ShkZa5RyLGGdfYvG7aw1TsF6iapPAS29mNS3NmsTQZCmgTzFwgL3upCTgtBTRwvGMAKrgLn4evwin8+afJRcff+8izUGUM63GOOuAs3tJkw7J4kyoNreqrpO6cYLQeFUd7TTpr5YOTLc9RUUogUOVJQ1GYJaFLAW0oTmKyYS46ZooP4S4EON3xQ5zC8/CX4CnM4c1PE8ApexpoYuzqlP3d4S3OJP8ZDK7cKWNaTlqmgDiiHwl1YsE41w1zT4iRTm3DBqxvOUsbMKKDa/EHxagtnta072ejc3DOIh5ojvh8l3tk1JF/AV6FU6jh3U8HwEazLgdCLYSQ+MYiAI2ltomkzttUb0gGHdSUUgsIYjTzLG3mObX4FBRaYtpDVNZrih9TgTeYOBxsEnN1gOCTM8Bsw/ieMc75w9kuAT6A+/AiHGvN/+Gn4KRkiuzpNNDYhDGFndWRpE6SVfm8U5bxnSgVV2jrg6JCKmneqey8VMFgq2+AM/i4L4RUbfSi27lNXZ7R7W9RTcq/q9fk4Xw3AMQd4I5ifAZz8FcVtm9SAom/dyN4lczJQW/kC42ZrHgcCoIf1oVMKkVItmMBi9cOeNHGLqOZk+QqQmrbc5YmYgxELUUN35z2iohstgfLIFmcMV7s4CFmI74L9+EFmGsi+tGnAOD4Yk9gIpo01Y4cA43BWGygMdr4YZekG3OBIUXXNukvJS8tqa06e+lSDCtnqqMFu6hWHXCF+WaYt64m9QBmNxi7Ioy7D+fa1yHw+FMAcPt7SysFLtoG4PXAk7JOA3aAxBRqUiAdU9Yp5lK3HLSRFtOim0sa8euEt08xvKjYjzeJ2GU7YawexrnKI9tmobInjFXCewpwriY9+RR4aaezFhMhGCppKwom0ChrgFlKzyPKkGlTW1YQrE9HJqu8hKGgMc6hVi5QRq0PZxNfrYNgE64utmRv6KKHRpxf6VDUaOvNP5jCEx5q185My/7RKz69UQu2im5k4/eownpxZxNLwiZ1AZTO2ZjWjkU9uaB2HFn6Q3u0JcsSx/qV9hTEApRzeBLDJQXxYmTnq7bdLa3+uqFrxLJ5w1TehnNHx5ECvCh2g2c3hHH5YsfdaSKddztfjQ6imKFGSyFwlLzxEGPp6r5IevVjk1AMx3wMqi1NxDVjLBiPs9tbsCkIY5we5/ML22zrCScFxnNtzsr9Wcc3CnD+pYO+4VXXiDE0oc/vQQ/fDK3oPESJMYXNmJa/DuloJZkcTpcYE8lIH8Dz8DJMiynNC86Mb2lNaaqP/+L7f2fcE/yP7/Lde8xfgSOdMxvOixZf/9p3+M4hT1+F+zApxg9XfUvYjc8qX2lfOOpK2gNRtB4flpFu9FTKCp2XJRgXnX6olp1zyYjTKJSkGmLE2NjUr1bxFM4AeAAHBUFIeSLqXR+NvH/M9fOnfHzOD2vCSyQJKzfgsCh+yi/Mmc35F2fUrw7miW33W9hBD1vpuUojFphIyvg7aTeoymDkIkeW3XLHmguMzbIAJejN6B5MDrhipE2y6SoFRO/AK/AcHHZHNIfiWrEe/C6cr3f/yOvrQKB+zMM55/GQdLDsR+ifr5Fiuu+/y+M78LzOE5dsNuXC3PYvYWd8NXvphLSkJIasrlD2/HOqQ+RjcRdjKTGWYhhVUm4yxlyiGPuMsZR7sMCHUBeTuNWA7if+ifXgc/hovftHXs/DV+Fvwe+f8shzMiMcweFgBly3//vwJfg5AN4450fn1Hd1Rm1aBLu22Dy3y3H2+OqMemkbGZ4jozcDjJf6596xOLpC0eMTHbKnxLxH27uZ/bMTGs2jOaMOY4m87CfQwF0dw53oa1k80JRuz/XgS+8fX3N9Af4qPIMfzKgCp4H5TDGe9GGeFPzSsZz80SlPTxXjgwJmC45njzgt2vbQ4b4OAdUK4/vWhO8d8v6EE8fMUsfakXbPpFJeLs2ubM/qdm/la3WP91uWhxXHjoWhyRUq2iJ/+5mA73zwIIo+LoZ/SgvIRjAd1IMvvn98PfgOvAJfhhm8scAKVWDuaRaK8aQ9f7vuPDH6Bj47ZXau7rqYJ66mTDwEDU6lLbCjCK0qTXyl5mnDoeNRxanj3FJbaksTk0faXxHxLrssgPkWB9LnA/MFleXcJozzjwsUvUG0X/QCve51qkMDXp9mtcyOy3rwBfdvVJK7D6/ACSzg3RoruIq5UDeESfEmVclDxnniU82vxMLtceD0hGZWzBNPMM/jSPne2OVatiTKUpY5vY7gc0LdUAWeWM5tH+O2I66AOWw9xT2BuyRVLGdoDHUsVRXOo/c+ZdRXvFfnxWyIV4upFLCl9eAL7h8Zv0QH8Ry8pA2cHzQpGesctVA37ZtklBTgHjyvdSeKY/RZw/kJMk0Y25cSNRWSigQtlULPTw+kzuJPeYEkXjQRpoGZobYsLF79pyd1dMRHInbgFTZqNLhDqiIsTNpoex2WLcy0/X6rHcdMMQvFSd5dWA++4P7xv89deACnmr36uGlL69bRCL6BSZsS6c0TU2TKK5gtWCzgAOOwQcurqk9j8whvziZSMLcq5hbuwBEsYjopUBkqw1yYBGpLA97SRElEmx5MCInBY5vgLk94iKqSWmhIGmkJ4Bi9m4L645J68LyY4wsFYBfUg5feP/6gWWm58IEmKQM89hq7KsZNaKtP5TxxrUZZVkNmMJtjbKrGxLNEbHPJxhqy7lAmbC32ZqeF6lTaknRWcYaFpfLUBh/rwaQycCCJmW15Kstv6jRHyJFry2C1ahkkIW0LO75s61+owxK1y3XqweX9m5YLM2DPFeOjn/iiqCKJ+yKXF8t5Yl/kNsqaSCryxPq5xWTFIaP8KSW0RYxqupaUf0RcTNSSdJZGcKYdYA6kdtrtmyBckfKXwqk0pHpUHlwWaffjNRBYFPUDWa8e3Lt/o0R0CdisKDM89cX0pvRHEfM8ca4t0s2Xx4kgo91MPQJ/0c9MQYq0co8MBh7bz1fio0UUHLR4aAIOvOmoYO6kwlEVODSSTliWtOtH6sPkrtctF9ZtJ9GIerBskvhdVS5cFNv9s1BU0AbdUgdK4FG+dRnjFmDTzniRMdZO1QhzMK355vigbdkpz9P6qjUGE5J2qAcXmwJ20cZUiAD0z+pGMx6xkzJkmEf40Hr4qZfVg2XzF9YOyoV5BjzVkUJngKf8lgNYwKECEHrCNDrWZzMlflS3yBhr/InyoUgBc/lKT4pxVrrC6g1YwcceK3BmNxZcAtz3j5EIpqguh9H6wc011YN75cKDLpFDxuwkrPQmUwW4KTbj9mZTwBwLq4aQMUZbHm1rylJ46dzR0dua2n3RYCWZsiHROeywyJGR7mXKlpryyCiouY56sFkBWEnkEB/raeh/Sw4162KeuAxMQpEkzy5alMY5wamMsWKKrtW2WpEWNnReZWONKWjrdsKZarpFjqCslq773PLmEhM448Pc3+FKr1+94vv/rfw4tEcu+lKTBe4kZSdijBrykwv9vbCMPcLQTygBjzVckSLPRVGslqdunwJ4oegtFOYb4SwxNgWLCmD7T9kVjTv5YDgpo0XBmN34Z/rEHp0sgyz7lngsrm4lvMm2Mr1zNOJYJ5cuxuQxwMGJq/TP5emlb8fsQBZviK4t8hFL+zbhtlpwaRSxQRWfeETjuauPsdGxsBVdO7nmP4xvzSoT29pRl7kGqz+k26B3Oy0YNV+SXbbQas1ctC/GarskRdFpKczVAF1ZXnLcpaMuzVe6lZ2g/1ndcvOVgRG3sdUAY1bKD6achijMPdMxV4muKVorSpiDHituH7rSTs7n/4y5DhRXo4FVBN4vO/zbAcxhENzGbHCzU/98Mcx5e7a31kWjw9FCe/zNeYyQjZsWb1uc7U33pN4Mji6hCLhivqfa9Ss6xLg031AgfesA/l99m9fgvnaF9JoE6bYKmkGNK3aPbHB96w3+DnxFm4hs0drLsk7U8kf/N/CvwQNtllna0rjq61sH8L80HAuvwH1tvBy2ChqWSCaYTaGN19sTvlfzFD6n+iKTbvtayfrfe9ueWh6GJFoxLdr7V72a5ZpvHcCPDzma0wTO4EgbLyedxstO81n57LYBOBzyfsOhUKsW1J1BB5vr/tz8RyqOFylQP9Tvst2JALsC5lsH8PyQ40DV4ANzYa4dedNiKNR1s+x2wwbR7q4/4cTxqEk4LWDebfisuo36JXLiWFjOtLrlNWh3K1rRS4xvHcDNlFnNmWBBAl5SWaL3oPOfnvbr5pdjVnEaeBJSYjuLEkyLLsWhKccadmOphZkOPgVdalj2QpSmfOsADhMWE2ZBu4+EEJI4wKTAuCoC4xwQbWXBltpxbjkXJtKxxabo9e7tyhlgb6gNlSbUpMh+l/FaqzVwewGu8BW1Zx7pTpQDJUjb8tsUTW6+GDXbMn3mLbXlXJiGdggxFAoUrtPS3wE4Nk02UZG2OOzlk7fRs7i95QCLo3E0jtrjnM7SR3uS1p4qtS2nJ5OwtQVHgOvArLBFijZUV9QtSl8dAY5d0E0hM0w3HS2DpIeB6m/A1+HfhJcGUq4sOxH+x3f5+VO+Ds9rYNI7zPXOYWPrtf8bYMx6fuOAX5jzNR0PdsuON+X1f7EERxMJJoU6GkTEWBvVolVlb5lh3tKCg6Wx1IbaMDdJ+9sUCc5KC46hKGCk3IVOS4TCqdBNfUs7Kd4iXf2RjnT/LLysJy3XDcHLh/vde3x8DoGvwgsa67vBk91G5Pe/HbOe7xwym0NXbtiuuDkGO2IJDh9oQvJ4cY4vdoqLDuoH9Zl2F/ofsekn8lkuhIlhQcffUtSjytFyp++p6NiE7Rqx/lodgKVoceEp/CP4FfjrquZaTtj2AvH5K/ywpn7M34K/SsoYDAdIN448I1/0/wveW289T1/lX5xBzc8N5IaHr0XMOQdHsIkDuJFifj20pBm5jzwUv9e2FhwRsvhAbalCIuIw3bhJihY3p6nTFFIZgiSYjfTf3aXuOjmeGn4bPoGvwl+CFzTRczBIuHBEeImHc37/lGfwZR0cXzVDOvaKfNHvwe+suZ771K/y/XcBlsoN996JpBhoE2toYxOznNEOS5TJc6Id5GEXLjrWo+LEWGNpPDU4WAwsIRROu+1vM+0oW37z/MBN9kqHnSArwPfgFJ7Cq/Ai3Ie7g7ncmI09v8sjzw9mzOAEXoIHxURueaAce5V80f/DOuuZwHM8vsMb5wBzOFWM7wymTXPAEvm4vcFpZ2ut0VZRjkiP2MlmLd6DIpbGSiHOjdnUHN90hRYmhTnmvhzp1iKDNj+b7t5hi79lWGwQ+HN9RsfFMy0FXbEwhfuczKgCbyxYwBmcFhhvo/7a44v+i3XWcwDP86PzpGQYdWh7csP5dBvZ1jNzdxC8pBGuxqSW5vw40nBpj5JhMwvOzN0RWqERHMr4Lv1kWX84xLR830G3j6yqZ1a8UstTlW+qJPOZ+sZ7xZPKTJLhiNOAFd6tk+jrTH31ncLOxid8+nzRb128HhUcru/y0Wn6iT254YPC6FtVSIMoW2sk727AhvTtrWKZTvgsmckfXYZWeNRXx/3YQ2OUxLDrbHtN11IwrgXT6c8dATDwLniYwxzO4RzuQqTKSC5gAofMZ1QBK3zQ4JWobFbcvJm87FK+6JXrKahLn54m3p+McXzzYtP8VF/QpJuh1OwieElEoI1pRxPS09FBrkq2tWCU59+HdhNtTIqKm8EBrw2RTOEDpG3IKo2Y7mFdLm3ZeVjYwVw11o/oznceMve4CgMfNym/utA/d/ILMR7gpXzRy9eDsgLcgbs8O2Va1L0zzIdwGGemTBuwROHeoMShkUc7P+ISY3KH5ZZeWqO8mFTxQYeXTNuzvvK5FGPdQfuu00DwYFY9dyhctEt+OJDdnucfpmyhzUJzfsJjr29l8S0bXBfwRS9ZT26tmMIdZucch5ZboMz3Nio3nIOsYHCGoDT4kUA9MiXEp9Xsui1S8th/kbWIrMBxDGLodWUQIWcvnXy+9M23xPiSMOiRPqM+YMXkUN3gXFrZJwXGzUaMpJfyRS9ZT0lPe8TpScuRlbMHeUmlaKDoNuy62iWNTWNFYjoxFzuJs8oR+RhRx7O4SVNSXpa0ZJQ0K1LAHDQ+D9IepkMXpcsq5EVCvClBUIzDhDoyKwDw1Lc59GbTeORivugw1IcuaEOaGWdNm+Ps5fQ7/tm0DjMegq3yM3vb5j12qUId5UZD2oxDSEWOZMSqFl/W+5oynWDa/aI04tJRQ2eTXusg86SQVu/nwSYwpW6wLjlqIzwLuxGIvoAvul0PS+ZNz0/akp/pniO/8JDnGyaCkzbhl6YcqmK/69prxPqtpx2+Km9al9sjL+rwMgHw4jE/C8/HQ3m1vBuL1fldbzd8mOueVJ92syqdEY4KJjSCde3mcRw2TA6szxedn+zwhZMps0XrqEsiUjnC1hw0TELC2Ek7uAAdzcheXv1BYLagspxpzSAoZZUsIzIq35MnFQ9DOrlNB30jq3L4pkhccKUAA8/ocvN1Rzx9QyOtERs4CVsJRK/DF71kPYrxYsGsm6RMh4cps5g1DOmM54Ly1ii0Hd3Y/BMk8VWFgBVmhqrkJCPBHAolwZaWzLR9Vb7bcWdX9NyUYE+uB2BKfuaeBUcjDljbYVY4DdtsVWvzRZdWnyUzDpjNl1Du3aloAjVJTNDpcIOVVhrHFF66lLfJL1zJr9PQ2nFJSBaKoDe+sAvLufZVHVzYh7W0h/c6AAZ+7Tvj6q9j68G/cTCS/3n1vLKHZwNi+P+pS0WkZNMBMUl+LDLuiE4omZy71r3UFMwNJV+VJ/GC5ixVUkBStsT4gGKh0Gm4Oy3qvq7Lbmq24nPdDuDR9deR11XzP4vFu3TYzfnIyiSVmgizUYGqkIXNdKTY9pgb9D2Ix5t0+NHkVzCdU03suWkkVZAoCONCn0T35gAeW38de43mf97sMOpSvj4aa1KYUm58USI7Wxxes03bAZdRzk6UtbzMaCQ6IxO0dy7X+XsjoD16hpsBeGz9dfzHj+R/Hp8nCxZRqkEDTaCKCSywjiaoMJ1TITE9eg7Jqnq8HL6gDwiZb0u0V0Rr/rmvqjxKuaLCX7ZWXTvAY+uvm3z8CP7nzVpngqrJpZKwWnCUjIviYVlirlGOzPLI3SMVyp/elvBUjjDkNhrtufFFErQ8pmdSlbK16toBHlt/HV8uHMX/vEGALkV3RJREiSlopxwdMXOZPLZ+ix+kAHpMKIk8UtE1ygtquttwxNhphrIZ1IBzjGF3IIGxGcBj6q8bHJBG8T9vdsoWrTFEuebEZuVxhhClH6P5Zo89OG9fwHNjtNQTpD0TG9PJLEYqvEY6Rlxy+ZZGfL0Aj62/bnQCXp//eeM4KzfQVJbgMQbUjlMFIm6TpcfWlZje7NBSV6IsEVmumWIbjiloUzQX9OzYdo8L1wjw2PrrpimONfmfNyzKklrgnEkSzT5QWYQW40YShyzqsRmMXbvVxKtGuYyMKaU1ugenLDm5Ily4iT14fP11Mx+xJv+zZ3MvnfdFqxU3a1W/FTB4m3Qfsyc1XUcdVhDeUDZXSFHHLQj/Y5jtC7ZqM0CXGwB4bP11i3LhOvzPGygYtiUBiwQV/4wFO0majijGsafHyRLu0yG6q35cL1rOpVxr2s5cM2jJYMCdc10Aj6q/blRpWJ//+dmm5psMl0KA2+AFRx9jMe2WbC4jQxnikd4DU8TwUjRVacgdlhmr3bpddzuJ9zXqr2xnxJfzP29RexdtjDVZqzkqa6PyvcojGrfkXiJ8SEtml/nYskicv0ivlxbqjemwUjMw5evdg8fUX9nOiC/lf94Q2i7MURk9nW1MSj5j8eAyV6y5CN2S6qbnw3vdA1Iwq+XOSCl663udN3IzLnrt+us25cI1+Z83SXQUldqQq0b5XOT17bGpLd6ssN1VMPf8c+jG8L3NeCnMdF+Ra3fRa9dft39/LuZ/3vwHoHrqGmQFafmiQw6eyzMxS05K4bL9uA+SKUQzCnSDkqOGokXyJvbgJ/BHI+qvY69//4rl20NsmK2ou2dTsyIALv/91/8n3P2Aao71WFGi8KKv1fRC5+J67Q/507/E/SOshqN5TsmYIjVt+kcjAx98iz/4SaojbIV1rexE7/C29HcYD/DX4a0rBOF5VTu7omsb11L/AWcVlcVZHSsqGuXLLp9ha8I//w3Mv+T4Ew7nTBsmgapoCrNFObIcN4pf/Ob/mrvHTGqqgAupL8qWjWPS9m/31jAe4DjA+4+uCoQoT/zOzlrNd3qd4SdphFxsUvYwGWbTWtISc3wNOWH+kHBMfc6kpmpwPgHWwqaSUG2ZWWheYOGQGaHB+eQ/kn6b3pOgLV+ODSn94wDvr8Bvb70/LLuiPPEr8OGVWfDmr45PZyccEmsVXZGe1pRNX9SU5+AVQkNTIVPCHF/jGmyDC9j4R9LfWcQvfiETmgMMUCMN1uNCakkweZsowdYobiMSlnKA93u7NzTXlSfe+SVbfnPQXmg9LpYAQxpwEtONyEyaueWM4FPjjyjG3uOaFmBTWDNgBXGEiQpsaWhnAqIijB07Dlsy3fUGeP989xbWkyf+FF2SNEtT1E0f4DYYVlxFlbaSMPIRMk/3iMU5pME2SIWJvjckciebkQuIRRyhUvkHg/iUljG5kzVog5hV7vIlCuBrmlhvgPfNHQM8lCf+FEGsYbMIBC0qC9a0uuy2wLXVbLBaP5kjHokCRxapkQyzI4QEcwgYHRZBp+XEFTqXFuNVzMtjXLJgX4gAid24Hjwc4N3dtVSe+NNiwTrzH4WVUOlDobUqr1FuAgYllc8pmzoVrELRHSIW8ViPxNy4xwjBpyR55I6J220qQTZYR4guvUICJiSpr9gFFle4RcF/OMB7BRiX8sSfhpNSO3lvEZCQfLUVTKT78Ek1LRLhWN+yLyTnp8qWUZ46b6vxdRGXfHVqx3eI75YaLa4iNNiK4NOW7wPW6lhbSOF9/M9qw8e/aoB3d156qTzxp8pXx5BKAsYSTOIIiPkp68GmTq7sZtvyzBQaRLNxIZ+paozHWoLFeExIhRBrWitHCAHrCF7/thhD8JhYz84wg93QRV88wLuLY8zF8sQ36qF1J455bOlgnELfshKVxYOXKVuKx0jaj22sczTQqPqtV/XDgpswmGTWWMSDw3ssyUunLLrVPGjYRsH5ggHeHSWiV8kT33ycFSfMgkoOK8apCye0J6VW6GOYvffgU9RWsukEi2kUV2nl4dOYUzRik9p7bcA4ggdJ53LxKcEe17B1R8eqAd7dOepV8sTXf5lhejoL85hUdhDdknPtKHFhljOT+bdq0hxbm35p2nc8+Ja1Iw+tJykgp0EWuAAZYwMVwac5KzYMslhvgHdHRrxKnvhTYcfKsxTxtTETkjHO7rr3zjoV25lAQHrqpV7bTiy2aXMmUhTBnKS91jhtR3GEoF0oLnWhWNnYgtcc4N0FxlcgT7yz3TgNIKkscx9jtV1ZKpWW+Ub1tc1eOv5ucdgpx+FJy9pgbLE7xDyXb/f+hLHVGeitHOi6A7ybo3sF8sS7w7cgdk0nJaOn3hLj3uyD0Zp5pazFIUXUpuTTU18d1EPkDoX8SkmWTnVIozEdbTcZjoqxhNHf1JrSS/AcvHjZ/SMHhL/7i5z+POsTUh/8BvNfYMTA8n+yU/MlTZxSJDRStqvEuLQKWwDctMTQogUDyQRoTQG5Kc6oQRE1yV1jCA7ri7jdZyK0sYTRjCR0Hnnd+y7nHxNgTULqw+8wj0mQKxpYvhjm9uSUxg+TTy7s2GtLUGcywhXSKZN275GsqlclX90J6bRI1aouxmgL7Q0Nen5ziM80SqMIo8cSOo+8XplT/5DHNWsSUr/6lLN/QQ3rDyzLruEW5enpf7KqZoShEduuSFOV7DLX7Ye+GmXb6/hnNNqKsVXuMDFpb9Y9eH3C6NGEzuOuI3gpMH/I6e+zDiH1fXi15t3vA1czsLws0TGEtmPEJdiiFPwlwKbgLHAFk4P6ZyPdymYYHGE0dutsChQBl2JcBFlrEkY/N5bQeXQ18gjunuMfMfsBlxJSx3niO485fwO4fGD5T/+3fPQqkneWVdwnw/3bMPkW9Wbqg+iC765Zk+xcT98ibKZc2EdgHcLoF8cSOo/Oc8fS+OyEULF4g4sJqXVcmfMfsc7A8v1/yfGXmL9I6Fn5pRwZhsPv0TxFNlAfZCvG+Oohi82UC5f/2IsJo0cTOm9YrDoKhFPEUr/LBYTUNht9zelHXDqwfPCIw4owp3mOcIQcLttWXFe3VZ/j5H3cIc0G6oPbCR+6Y2xF2EC5cGUm6wKC5tGEzhsWqw5hNidUiKX5gFWE1GXh4/Qplw4sVzOmx9QxU78g3EF6wnZlEN4FzJ1QPSLEZz1KfXC7vd8ssGdIbNUYpVx4UapyFUHzJoTOo1McSkeNn1M5MDQfs4qQuhhX5vQZFw8suwWTcyYTgioISk2YdmkhehG4PkE7w51inyAGGaU+uCXADabGzJR1fn3lwkty0asIo8cROm9Vy1g0yDxxtPvHDAmpu+PKnM8Ix1wwsGw91YJqhteaWgjYBmmQiebmSpwKKzE19hx7jkzSWOm66oPbzZ8Yj6kxVSpYjVAuvLzYMCRo3oTQecOOjjgi3NQ4l9K5/hOGhNTdcWVOTrlgYNkEXINbpCkBRyqhp+LdRB3g0OU6rMfW2HPCFFMV9nSp+uB2woepdbLBuJQyaw/ZFysXrlXwHxI0b0LovEkiOpXGA1Ijagf+KUNC6rKNa9bQnLFqYNkEnMc1uJrg2u64ELPBHpkgWbmwKpJoDhMwNbbGzAp7Yg31wS2T5rGtzit59PrKhesWG550CZpHEzpv2NGRaxlNjbMqpmEIzygJqQfjypycs2pg2cS2RY9r8HUqkqdEgKTWtWTKoRvOBPDYBltja2SO0RGjy9UHtxwRjA11ujbKF+ti5cIR9eCnxUg6owidtyoU5tK4NLji5Q3HCtiyF2IqLGYsHViOXTXOYxucDqG0HyttqYAKqYo3KTY1ekyDXRAm2AWh9JmsVh/ccg9WJ2E8YjG201sPq5ULxxX8n3XLXuMInbft2mk80rRGjCGctJ8/GFdmEQ9Ug4FlE1ll1Y7jtiraqm5Fe04VV8lvSVBL8hiPrfFVd8+7QH3Qbu2ipTVi8cvSGivc9cj8yvH11YMHdNSERtuOslM97feYFOPKzGcsI4zW0YGAbTAOaxCnxdfiYUmVWslxiIblCeAYr9VYR1gM7GmoPrilunSxxeT3DN/2eBQ9H11+nk1adn6VK71+5+Jfct4/el10/7KBZfNryUunWSCPxPECk1rdOv1WVSrQmpC+Tl46YD3ikQYcpunSQgzVB2VHFhxHVGKDgMEY5GLlQnP7FMDzw7IacAWnO6sBr12u+XanW2AO0wQ8pknnFhsL7KYIqhkEPmEXFkwaN5KQphbkUmG72wgw7WSm9RiL9QT925hkjiVIIhphFS9HKI6/8QAjlpXqg9W2C0apyaVDwKQwrwLY3j6ADR13ZyUNByQXHQu6RY09Hu6zMqXRaNZGS/KEJs0cJEe9VH1QdvBSJv9h09eiRmy0V2uJcqHcShcdvbSNg5fxkenkVprXM9rDVnX24/y9MVtncvbKY706anNl3ASll9a43UiacVquXGhvq4s2FP62NGKfQLIQYu9q1WmdMfmUrDGt8eDS0cXozH/fjmUH6Jruvm50hBDSaEU/2Ru2LEN/dl006TSc/g7tfJERxGMsgDUEr104pfWH9lQaN+M4KWQjwZbVc2rZVNHsyHal23wZtIs2JJqtIc/WLXXRFCpJkfE9jvWlfFbsNQ9pP5ZBS0zKh4R0aMFj1IjTcTnvi0Zz2rt7NdvQb2mgbju1plsH8MmbnEk7KbK0b+wC2iy3aX3szW8xeZvDwET6hWZYwqTXSSG+wMETKum0Dq/q+x62gt2ua2ppAo309TRk9TPazfV3qL9H8z7uhGqGqxNVg/FKx0HBl9OVUORn8Q8Jx9gFttGQUDr3tzcXX9xGgN0EpzN9mdZ3GATtPhL+CjxFDmkeEU6x56kqZRusLzALXVqkCN7zMEcqwjmywDQ6OhyUe0Xao1Qpyncrg6wKp9XfWDsaZplElvQ/b3sdweeghorwBDlHzgk1JmMc/wiERICVy2VJFdMjFuLQSp3S0W3+sngt2njwNgLssFGVQdJ0tu0KH4ky1LW4yrbkuaA6Iy9oz/qEMMXMMDWyIHhsAyFZc2peV9hc7kiKvfULxCl9iddfRK1f8kk9qvbdOoBtOg7ZkOZ5MsGrSHsokgLXUp9y88smniwWyuFSIRVmjplga3yD8Uij5QS1ZiM4U3Qw5QlSm2bXjFe6jzzBFtpg+/YBbLAWG7OPynNjlCw65fukGNdkJRf7yM1fOxVzbxOJVocFoYIaGwH22mIQkrvu1E2nGuebxIgW9U9TSiukPGU+Lt++c3DJPKhyhEEbXCQLUpae2exiKy6tMPe9mDRBFCEMTWrtwxN8qvuGnt6MoihKWS5NSyBhbH8StXoAz8PLOrRgLtOT/+4vcu+7vDLnqNvztOq7fmd8sMmY9Xzn1zj8Dq8+XVdu2Nv0IIySgEdQo3xVHps3Q5i3fLFsV4aiqzAiBhbgMDEd1uh8qZZ+lwhjkgokkOIv4xNJmyncdfUUzgB4oFMBtiu71Xumpz/P+cfUP+SlwFExwWW62r7b+LSPxqxn/gvMZ5z9C16t15UbNlq+jbGJtco7p8wbYlL4alSyfWdeuu0j7JA3JFNuVAwtst7F7FhWBbPFNKIUORndWtLraFLmMu7KFVDDOzqkeaiN33YAW/r76wR4XDN/yN1z7hejPau06EddkS/6XThfcz1fI/4K736fO48vlxt2PXJYFaeUkFS8U15XE3428xdtn2kc8GQlf1vkIaNRRnOMvLTWrZbElEHeLWi1o0dlKPAh1MVgbbVquPJ5+Cr8LU5/H/+I2QlHIU2ClXM9G8v7Rr7oc/hozfUUgsPnb3D+I+7WF8kNO92GY0SNvuxiE+2Bt8prVJTkzE64sfOstxuwfxUUoyk8VjcTlsqe2qITSFoSj6Epd4KsT6BZOWmtgE3hBfir8IzZDwgV4ZTZvD8VvPHERo8v+vL1DASHTz/i9OlKueHDjK5Rnx/JB1Vb1ioXdBra16dmt7dgik10yA/FwJSVY6XjA3oy4SqM2frqDPPSRMex9qs3XQtoWxMj7/Er8GWYsXgjaVz4OYumP2+9kbxvny/6kvWsEBw+fcb5bInc8APdhpOSs01tEqIkoiZjbAqKMruLbJYddHuHFRIyJcbdEdbl2sVLaySygunutBg96Y2/JjKRCdyHV+AEFtTvIpbKIXOamknYSiB6KV/0JetZITgcjjk5ZdaskBtWO86UF0ap6ozGXJk2WNiRUlCPFir66lzdm/SLSuK7EUdPz8f1z29Skq6F1fXg8+5UVR6bszncP4Tn4KUkkdJ8UFCY1zR1i8RmL/qQL3rlei4THG7OODlnKko4oI01kd3CaM08Ia18kC3GNoVaO9iDh+hWxSyTXFABXoau7Q6q9OxYg/OVEMw6jdbtSrJ9cBcewGmaZmg+bvkUnUUaGr+ZfnMH45Ivevl61hMcXsxYLFTu1hTm2zViCp7u0o5l+2PSUh9bDj6FgYypufBDhqK2+oXkiuHFHR3zfj+9PtA8oR0xnqX8qn+sx3bFODSbbF0X8EUvWQ8jBIcjo5bRmLOljDNtcqNtOe756h3l0VhKa9hDd2l1eqmsnh0MNMT/Cqnx6BInumhLT8luljzQ53RiJeA/0dxe5NK0o2fA1+GLXr6eNQWHNUOJssQaTRlGpLHKL9fD+IrQzTOMZS9fNQD4AnRNVxvTdjC+fJdcDDWQcyB00B0t9BDwTxXgaAfzDZ/DBXzRnfWMFRwuNqocOmX6OKNkY63h5n/fFcB28McVHqnXZVI27K0i4rDLNE9lDKV/rT+udVbD8dFFu2GGZ8mOt0kAXcoX3ZkIWVtw+MNf5NjR2FbivROHmhV1/pj2egv/fMGIOWTIWrV3Av8N9imV9IWml36H6cUjqEWNv9aNc+veb2sH46PRaHSuMBxvtW+twxctq0z+QsHhux8Q7rCY4Ct8lqsx7c6Sy0dl5T89rIeEuZKoVctIk1hNpfavER6yyH1Vvm3MbsUHy4ab4hWr/OZPcsRBphnaV65/ZcdYPNNwsjN/djlf9NqCw9U5ExCPcdhKxUgLSmfROpLp4WSUr8ojdwbncbvCf+a/YzRaEc6QOvXcGO256TXc5Lab9POvB+AWY7PigWYjzhifbovuunzRawsO24ZqQQAqguBtmpmPB7ysXJfyDDaV/aPGillgz1MdQg4u5MYaEtBNNHFjkRlSpd65lp4hd2AVPTfbV7FGpyIOfmNc/XVsPfg7vzaS/3nkvLL593ANLvMuRMGpQIhiF7kUEW9QDpAUbTWYBcbp4WpacHHY1aacqQyjGZS9HI3yCBT9kUZJhVOD+zUDvEH9ddR11fzPcTDQ5TlgB0KwqdXSavk9BC0pKp0WmcuowSw07VXmXC5guzSa4p0UvRw2lbDiYUx0ExJJRzWzi6Gm8cnEkfXXsdcG/M/jAJa0+bmCgdmQ9CYlNlSYZOKixmRsgiFxkrmW4l3KdFKv1DM8tk6WxPYJZhUUzcd8Kdtgrw/gkfXXDT7+avmfVak32qhtkg6NVdUS5wgkru1YzIkSduTW1FDwVWV3JQVJVuieTc0y4iDpFwc7/BvSalvKdQM8sv662cevz/+8sQVnjVAT0W2wLllw1JiMhJRxgDjCjLQsOzSFSgZqx7lAW1JW0e03yAD3asC+GD3NbQhbe+mN5GXH1F83KDOM4n/e5JIuH4NpdQARrFPBVptUNcjj4cVMcFSRTE2NpR1LEYbYMmfWpXgP9KejaPsLUhuvLCsVXznAG9dfx9SR1ud/3hZdCLHb1GMdPqRJgqDmm76mHbvOXDtiO2QPUcKo/TWkQ0i2JFXpBoo7vij1i1Lp3ADAo+qvG3V0rM//vFnnTE4hxd5Ka/Cor5YEdsLVJyKtDgVoHgtW11pWSjolPNMnrlrVj9Fv2Qn60twMwKPqr+N/wvr8z5tZcDsDrv06tkqyzESM85Ycv6XBWA2birlNCXrI6VbD2lx2L0vQO0QVTVVLH4SE67fgsfVXv8n7sz7/85Z7cMtbE6f088wSaR4kCkCm10s6pKbJhfqiUNGLq+0gLWC6eUAZFPnLjwqtKd8EwGvWX59t7iPW4X/eAN1svgRVSY990YZg06BD1ohLMtyFTI4pKTJsS9xREq9EOaPWiO2gpms7397x6nQJkbh+Fz2q/rqRROX6/M8bJrqlVW4l6JEptKeUFuMYUbtCQ7CIttpGc6MY93x1r1vgAnRXvY5cvwWPqb9uWQm+lP95QxdNMeWhOq1x0Db55C7GcUv2ZUuN6n8iKzsvOxibC//Yfs9Na8r2Rlz02vXXDT57FP/zJi66/EJSmsJKa8QxnoqW3VLQ+jZVUtJwJ8PNX1NQCwfNgdhhHD9on7PdRdrdGPF28rJr1F+3LBdeyv+8yYfLoMYet1vX4upNAjVvwOUWnlNXJXlkzk5Il6kqeoiL0C07qno+/CYBXq/+utlnsz7/Mzvy0tmI4zm4ag23PRN3t/CWryoUVJGm+5+K8RJ0V8Hc88/XHUX/HfiAq7t+BH+x6v8t438enWmdJwFA6ZINriLGKv/95f8lT9/FnyA1NMVEvQyaXuu+gz36f/DD73E4pwqpLcvm/o0Vle78n//+L/NPvoefp1pTJye6e4A/D082FERa5/opeH9zpvh13cNm19/4v/LDe5xMWTi8I0Ta0qKlK27AS/v3/r+/x/2GO9K2c7kVMonDpq7//jc5PKCxeNPpFVzaRr01wF8C4Pu76hXuX18H4LduTr79guuFD3n5BHfI+ZRFhY8w29TYhbbLi/bvBdqKE4fUgg1pBKnV3FEaCWOWyA+m3WpORZr/j+9TKJtW8yBTF2/ZEODI9/QavHkVdGFp/Pjn4Q+u5hXapsP5sOH+OXXA1LiKuqJxiMNbhTkbdJTCy4llEt6NnqRT4dhg1V3nbdrm6dYMecA1yTOL4PWTE9L5VzPFlLBCvlG58AhehnN4uHsAYinyJ+AZ/NkVvELbfOBUuOO5syBIEtiqHU1k9XeISX5bsimrkUUhnGDxourN8SgUsCZVtKyGbyGzHXdjOhsAvOAswSRyIBddRdEZWP6GZhNK/yjwew9ehBo+3jEADu7Ay2n8mDc+TS7awUHg0OMzR0LABhqLD4hJEh/BEGyBdGlSJoXYXtr+3HS4ijzVpgi0paWXtdruGTknXBz+11qT1Q2inxaTzQCO46P3lfLpyS4fou2PH/PupwZgCxNhGlj4IvUuWEsTkqMWm6i4xCSMc9N1RDQoCVcuGItJ/MRWefais+3synowi/dESgJjkilnWnBTGvRWmaw8oR15257t7CHmCf8HOn7cwI8+NQBXMBEmAa8PMRemrNCEhLGEhDQKcGZWS319BX9PFBEwGTbRBhLbDcaV3drFcDqk5kCTd2JF1Wp0HraqBx8U0wwBTnbpCadwBA/gTH/CDrcCs93LV8E0YlmmcyQRQnjBa8JESmGUfIjK/7fkaDJpmD2QptFNVJU1bbtIAjjWQizepOKptRjbzR9Kag6xZmMLLjHOtcLT3Tx9o/0EcTT1XN3E45u24AiwEypDJXihKjQxjLprEwcmRKclaDNZCVqr/V8mYWyFADbusiY5hvgFoU2vio49RgJLn5OsReRFN6tabeetiiy0V7KFHT3HyZLx491u95sn4K1QQSPKM9hNT0wMVvAWbzDSVdrKw4zRjZMyJIHkfq1VAVCDl/bUhNKlGq0zGr05+YAceXVPCttVk0oqjVwMPt+BBefx4yPtGVkUsqY3CHDPiCM5ngupUwCdbkpd8kbPrCWHhkmtIKLEetF2499eS1jZlIPGYnlcPXeM2KD9vLS0bW3ktYNqUllpKLn5ZrsxlIzxvDu5eHxzGLctkZLEY4PgSOg2IUVVcUONzUDBEpRaMoXNmUc0tFZrTZquiLyKxrSm3DvIW9Fil+AkhXu5PhEPx9mUNwqypDvZWdKlhIJQY7vn2OsnmBeOWnYZ0m1iwbbw1U60by5om47iHRV6fOgzjMf/DAZrlP40Z7syxpLK0lJ0gqaAK1c2KQKu7tabTXkLFz0sCftuwX++MyNeNn68k5Buq23YQhUh0SNTJa1ioQ0p4nUG2y0XilF1JqODqdImloPS4Bp111DEWT0jJjVv95uX9BBV7eB3bUWcu0acSVM23YZdd8R8UbQUxJ9wdu3oMuhdt929ME+mh6JXJ8di2RxbTi6TbrDquqV4aUKR2iwT6aZbyOwEXN3DUsWr8Hn4EhwNyHuXHh7/pdaUjtR7vnDh/d8c9xD/s5f501eQ1+CuDiCvGhk1AN/4Tf74RfxPwD3toLarR0zNtsnPzmS64KIRk861dMWCU8ArasG9T9H0ZBpsDGnjtAOM2+/LuIb2iIUGXNgl5ZmKD/Tw8TlaAuihaFP5yrw18v4x1898zIdP+DDAX1bM3GAMvPgRP/cJn3zCW013nrhHkrITyvYuwOUkcHuKlRSW5C6rzIdY4ppnF7J8aAJbQepgbJYBjCY9usGXDKQxq7RZfh9eg5d1UHMVATRaD/4BHK93/1iAgYZ/+jqPn8Dn4UExmWrpa3+ZOK6MvM3bjwfzxNWA2dhs8+51XHSPJiaAhGSpWevEs5xHLXcEGFXYiCONySH3fPWq93JIsBiSWvWyc3CAN+EcXoT7rCSANloPPoa31rt/5PUA/gp8Q/jDD3hyrjzlR8VkanfOvB1XPubt17vzxAfdSVbD1pzAnfgyF3ycadOTOTXhpEUoLC1HZyNGW3dtmjeXgr2r56JNmRwdNNWaQVBddd6rh4MhviEB9EFRD/7RGvePvCbwAL4Mx/D6M541hHO4D3e7g6PafdcZVw689z7NGTwo5om7A8sPhccT6qKcl9NJl9aM/9kX+e59Hh1yPqGuCCZxuITcsmNaJ5F7d0q6J3H48TO1/+M57085q2icdu2U+W36Ldllz9Agiv4YGljoEN908EzvDOrBF98/vtJwCC/BF2AG75xxEmjmMIcjxbjoaxqOK3/4hPOZzhMPBpYPG44CM0dTVm1LjLtUWWVz1Bcf8tEx0zs8O2A2YVHRxKYOiy/aOVoAaMu0i7ubu43njjmd4ibMHU1sIDHaQNKrZND/FZYdk54oCXetjq7E7IVl9eAL7t+oHnwXXtLx44czzoRFHBztYVwtH1d+NOMkupZ5MTM+gUmq90X+Bh9zjRlmaQ+m7YMqUL/veemcecAtOJ0yq1JnVlN27di2E0+Klp1tAJ4KRw1eMI7aJjsO3R8kPSI3fUFXnIOfdQe86sIIVtWDL7h//Ok6vj8vwDk08NEcI8zz7OhBy+WwalzZeZ4+0XniRfst9pAJqQHDGLzVQ2pheZnnv1OWhwO43/AgcvAEXEVVpa4db9sGvNK8wjaENHkfFQ4Ci5i7dqnQlPoLQrHXZDvO3BIXZbJOBrOaEbML6sFL798I4FhKihjHMsPjBUZYCMFr6nvaArxqXPn4lCa+cHfSa2cP27g3Z3ziYTRrcbQNGLQmGF3F3cBdzzzX7AILx0IB9rbwn9kx2G1FW3Inic+ZLIsVvKR8Zwfj0l1fkqo8LWY1M3IX14OX3r9RKTIO+d9XzAI8qRPGPn/4NC2n6o4rN8XJ82TOIvuVA8zLKUHRFgBCetlDZlqR1gLKjS39xoE7Bt8UvA6BxuEDjU3tFsEijgA+615tmZkXKqiEENrh41iLDDZNq4pKTWR3LZfnos81LOuNa15cD956vLMsJd1rqYp51gDUQqMYm2XsxnUhD2jg1DM7SeuJxxgrmpfISSXVIJIS5qJJSvJPEQ49DQTVIbYWJ9QWa/E2+c/oPK1drmC7WSfJRNKBO5Yjvcp7Gc3dmmI/Xh1kDTEuiSnWqQf37h+fTMhGnDf6dsS8SQfQWlqqwXXGlc/PEZ/SC5mtzIV0nAshlQdM/LvUtYutrEZ/Y+EAFtq1k28zQhOwLr1AIeANzhF8t9qzTdZf2qRKO6MWE9ohBYwibbOmrFtNmg3mcS+tB28xv2uKd/agYCvOP+GkSc+0lr7RXzyufL7QbkUpjLjEWFLqOIkAGu2B0tNlO9Eau2W1qcOUvVRgKzypKIQZ5KI3q0MLzqTNRYqiZOqmtqloIRlmkBHVpHmRYV6/HixbO6UC47KOFJnoMrVyr7wYz+SlW6GUaghYbY1I6kkxA2W1fSJokUdSh2LQ1GAimRGm0MT+uu57H5l7QgOWxERpO9moLRPgTtquWCfFlGlIjQaRly9odmzMOWY+IBO5tB4sW/0+VWGUh32qYk79EidWKrjWuiLpiVNGFWFRJVktyeXWmbgBBzVl8anPuXyNJlBJOlKLTgAbi/EYHVHxWiDaVR06GnHQNpJcWcK2jJtiCfG2sEHLzuI66sGrMK47nPIInPnu799935aOK2cvmvubrE38ZzZjrELCmXM2hM7UcpXD2oC3+ECVp7xtIuxptJ0jUr3sBmBS47TVxlvJ1Sqb/E0uLdvLj0lLr29ypdd/eMX3f6lrxGlKwKQxEGvw0qHbkbwrF3uHKwVENbIV2wZ13kNEF6zD+x24aLNMfDTCbDPnEikZFyTNttxWBXDaBuM8KtI2rmaMdUY7cXcUPstqTGvBGSrFWIpNMfbdea990bvAOC1YX0qbc6smDS1mPxSJoW4fwEXvjMmhlijDRq6qale6aJEuFGoppYDoBELQzLBuh/mZNx7jkinv0EtnUp50lO9hbNK57lZaMAWuWR5Yo9/kYwcYI0t4gWM47Umnl3YmpeBPqSyNp3K7s2DSAS/39KRuEN2bS4xvowV3dFRMx/VFcp2Yp8w2nTO9hCXtHG1kF1L4KlrJr2wKfyq77R7MKpFKzWlY9UkhYxyHWW6nBWPaudvEAl3CGcNpSXPZ6R9BbBtIl6cHL3gIBi+42CYXqCx1gfGWe7Ap0h3luyXdt1MKy4YUT9xSF01G16YEdWsouW9mgDHd3veyA97H+Ya47ZmEbqMY72oPztCGvK0onL44AvgC49saZKkWRz4veWljE1FHjbRJaWv6ZKKtl875h4CziFCZhG5rx7tefsl0aRT1bMHZjm8dwL/6u7wCRysaQblQoG5yAQN5zpatMNY/+yf8z+GLcH/Qn0iX2W2oEfXP4GvwQHuIL9AYGnaO3zqAX6946nkgqZNnUhx43DIdQtMFeOPrgy/y3Yd85HlJWwjLFkU3kFwq28xPnuPhMWeS+tDLV9Otllq7pQCf3uXJDN9wFDiUTgefHaiYbdfi3b3u8+iY6TnzhgehI1LTe8lcd7s1wJSzKbahCRxKKztTLXstGAiu3a6rPuQs5pk9TWAan5f0BZmGf7Ylxzzk/A7PAs4QPPPAHeFQ2hbFHszlgZuKZsJcUmbDC40sEU403cEjczstOEypa+YxevL4QBC8oRYqWdK6b7sK25tfE+oDZgtOQ2Jg8T41HGcBE6fTWHn4JtHcu9S7uYgU5KSCkl/mcnq+5/YBXOEr6lCUCwOTOM1taOI8mSxx1NsCXBEmLKbMAg5MkwbLmpBaFOPrNSlO2HnLiEqW3tHEwd8AeiQLmn+2gxjC3k6AxREqvKcJbTEzlpLiw4rNZK6oJdidbMMGX9FULKr0AkW+2qDEPBNNm5QAt2Ik2nftNWHetubosHLo2nG4vQA7GkcVCgVCgaDixHqo9UUn1A6OshapaNR/LPRYFV8siT1cCtJE0k/3WtaNSuUZYKPnsVIW0xXWnMUxq5+En4Kvw/MqQmVXnAXj9Z+9zM98zM/Agy7F/qqj2Nh67b8HjFnPP3iBn/tkpdzwEJX/whIcQUXOaikeliCRGUk7tiwF0rItwMEhjkZ309hikFoRAmLTpEXWuHS6y+am/KB/fM50aLEhGnSMwkpxzOov4H0AvgovwJ1iGzDLtJn/9BU+fAINfwUe6FHSLhu83viV/+/HrOePX+STT2B9uWGbrMHHLldRBlhS/CJQmcRxJFqZica01XixAZsYiH1uolZxLrR/SgxVIJjkpQP4PE9sE59LKLr7kltSBogS5tyszzH8Fvw8/AS8rNOg0xUS9fIaHwb+6et8Q/gyvKRjf5OusOzGx8evA/BP4IP11uN/grca5O0lcsPLJ5YjwI4QkJBOHa0WdMZYGxPbh2W2nR9v3WxEWqgp/G3+6VZbRLSAAZ3BhdhAaUL33VUSw9yjEsvbaQ9u4A/gGXwZXoEHOuU1GSj2chf+Mo+f8IcfcAxfIKVmyunRbYQVnoevwgfw3TXXcw++xNuP4fhyueEUNttEduRVaDttddoP0eSxLe2LENk6itYxlrxBNBYrNNKSQmeaLcm9c8UsaB5WyO6675yyQIAWSDpBVoA/gxmcwEvwoDv0m58UE7gHn+fJOa8/Ywan8EKRfjsopF83eCglX/Sfr7OeaRoQfvt1CGvIDccH5BCvw1sWIzRGC/66t0VTcLZQZtm6PlAasbOJ9iwWtUo7biktTSIPxnR24jxP1ZKaqq+2RcXM9OrBAm/AAs7hDJ5bNmGb+KIfwCs8a3jnjBrOFeMjHSCdbKr+2uOLfnOd9eiA8Hvvwwq54VbP2OqwkB48Ytc4YEOiH2vTXqodabfWEOzso4qxdbqD5L6tbtNPECqbhnA708DZH4QOJUXqScmUlks7Ot6FBuZw3n2mEbaUX7kDzxHOOQk8nKWMzAzu6ZZ8sOFw4RK+6PcuXo9tB4SbMz58ApfKDXf3szjNIIbGpD5TKTRxGkEMLjLl+K3wlWXBsCUxIDU+jbOiysESqAy1MGUJpXgwbTWzNOVEziIXZrJ+VIztl1PUBxTSo0dwn2bOmfDRPD3TRTGlfbCJvO9KvuhL1hMHhB9wPuPRLGHcdOWG2xc0U+5bQtAJT0nRTewXL1pgk2+rZAdeWmz3jxAqfNQQdzTlbF8uJ5ecEIWvTkevAHpwz7w78QujlD/Lr491bD8/1vhM2yrUQRrWXNQY4fGilfctMWYjL72UL/qS9eiA8EmN88nbNdour+PBbbAjOjIa4iBhfFg6rxeKdEGcL6p3EWR1Qq2Qkhs2DrnkRnmN9tG2EAqmgPw6hoL7Oza7B+3SCrR9tRftko+Lsf2F/mkTndN2LmzuMcKTuj/mX2+4Va3ki16+nnJY+S7MefpkidxwnV+4wkXH8TKnX0tsYzYp29DOOoSW1nf7nTh2akYiWmcJOuTidSaqESrTYpwjJJNVGQr+rLI7WsqerHW6Kp/oM2pKuV7T1QY9gjqlZp41/WfKpl56FV/0kvXQFRyeQ83xaTu5E8p5dNP3dUF34ihyI3GSpeCsywSh22ZJdWto9winhqifb7VRvgktxp13vyjrS0EjvrRfZ62uyqddSWaWYlwTPAtJZ2oZ3j/Sgi/mi+6vpzesfAcWNA0n8xVyw90GVFGuZjTXEQy+6GfLGLMLL523f5E0OmxVjDoOuRiH91RKU+vtoCtH7TgmvBLvtFXWLW15H9GTdVw8ow4IlRLeHECN9ym1e9K0I+Cbnhgv4Yu+aD2HaQJ80XDqOzSGAV4+4yCqBxrsJAX6ZTIoX36QnvzhhzzMfFW2dZVLOJfo0zbce5OvwXMFaZ81mOnlTVXpDZsQNuoYWveketKb5+6JOOsgX+NTm7H49fUTlx+WLuWL7qxnOFh4BxpmJx0p2gDzA/BUARuS6phR+pUsY7MMboAHx5xNsSVfVZcYSwqCKrqon7zM+8ecCkeS4nm3rINuaWvVNnMRI1IRpxTqx8PZUZ0Br/UEduo3B3hNvmgZfs9gQPj8vIOxd2kndir3awvJ6BLvoUuOfFWNYB0LR1OQJoUySKb9IlOBx74q1+ADC2G6rOdmFdJcD8BkfualA+BdjOOzP9uUhGUEX/TwhZsUduwRr8wNuXKurCixLBgpQI0mDbJr9dIqUuV+92ngkJZ7xduCk2yZKbfWrH1VBiTg9VdzsgRjW3CVXCvAwDd+c1z9dWw9+B+8MJL/eY15ZQ/HqvTwVdsZn5WQsgRRnMaWaecu3jFvMBEmgg+FJFZsnSl0zjB9OqPYaBD7qmoVyImFvzi41usesV0julaAR9dfR15Xzv9sEruRDyk1nb+QaLU67T885GTls6YgcY+UiMa25M/pwGrbCfzkvR3e0jjtuaFtnwuagHTSb5y7boBH119HXhvwP487jJLsLJ4XnUkHX5sLbS61dpiAXRoZSCrFJ+EjpeU3puVfitngYNo6PJrAigKktmwjyQdZpfq30mmtulaAx9Zfx15Xzv+cyeuiBFUs9zq8Kq+XB9a4PVvph3GV4E3y8HENJrN55H1X2p8VyqSKwVusJDKzXOZzplWdzBUFK9e+B4+uv468xvI/b5xtSAkBHQaPvtqWzllVvEOxPbuiE6+j2pvjcKsbvI7txnRErgfH7LdXqjq0IokKzga14GzQ23SSbCQvO6r+Or7SMIr/efOkkqSdMnj9mBx2DRsiY29Uj6+qK9ZrssCKaptR6HKURdwUYeUWA2kPzVKQO8ku2nU3Anhs/XWkBx3F/7wJtCTTTIKftthue1ty9xvNYLY/zo5KSbIuKbXpbEdSyeRyYdAIwKY2neyoc3+k1XUaufYga3T9daMUx/r8z1s10ITknIO0kuoMt+TB8jK0lpayqqjsJ2qtXAYwBU932zinimgmd6mTRDnQfr88q36NAI+tv24E8Pr8zxtasBqx0+xHH9HhlrwsxxNUfKOHQaZBITNf0uccj8GXiVmXAuPEAKSdN/4GLHhs/XWj92dN/uetNuBMnVR+XWDc25JLjo5Mg5IZIq226tmCsip2zZliL213YrTlL2hcFjpCduyim3M7/eB16q/blQsv5X/esDRbtJeabLIosWy3ycavwLhtxdWzbMmHiBTiVjJo6lCLjXZsi7p9PEPnsq6X6wd4bP11i0rD5fzPm/0A6brrIsllenZs0lCJlU4abakR59enZKrKe3BZihbTxlyZ2zl1+g0wvgmA166/bhwDrcn/7Ddz0eWZuJvfSESug6NzZsox3Z04FIxz0mUjMwVOOVTq1CQ0AhdbBGVdjG/CgsfUX7esJl3K/7ytWHRv683praW/8iDOCqWLLhpljDY1ZpzK75QiaZoOTpLKl60auHS/97oBXrv+umU9+FL+5+NtLFgjqVLCdbmj7pY5zPCPLOHNCwXGOcLquOhi8CmCWvbcuO73XmMUPab+ug3A6/A/78Bwe0bcS2+tgHn4J5pyS2WbOck0F51Vq3LcjhLvZ67p1ABbaL2H67bg78BfjKi/jr3+T/ABV3ilLmNXTI2SpvxWBtt6/Z//D0z/FXaGbSBgylzlsEGp+5//xrd4/ae4d8DUUjlslfIYS3t06HZpvfQtvv0N7AHWqtjP2pW08QD/FLy//da38vo8PNlKHf5y37Dxdfe/oj4kVIgFq3koLReSR76W/bx//n9k8jonZxzWTANVwEniDsg87sOSd/z7//PvMp3jQiptGVWFX2caezzAXwfgtzYUvbr0iozs32c3Uge7varH+CNE6cvEYmzbPZ9hMaYDdjK4V2iecf6EcEbdUDVUARda2KzO/JtCuDbNQB/iTeL0EG1JSO1jbXS+nLxtPMDPw1fh5+EPrgSEKE/8Gry5A73ui87AmxwdatyMEBCPNOCSKUeRZ2P6Myb5MRvgCHmA9ywsMifU+AYXcB6Xa5GibUC5TSyerxyh0j6QgLVpdyhfArRTTLqQjwe4HOD9s92D4Ap54odXAPBWLAwB02igG5Kkc+piN4lvODIFGAZgT+EO4Si1s7fjSR7vcQETUkRm9O+MXyo9OYhfe4xt9STQ2pcZRLayCV90b4D3jR0DYAfyxJ+eywg2IL7NTMXna7S/RpQ63JhWEM8U41ZyQGjwsVS0QBrEKLu8xwZsbi4wLcCT+OGidPIOCe1PiSc9Qt+go+vYqB7cG+B9d8cAD+WJPz0Am2gxXgU9IneOqDpAAXOsOltVuMzpdakJXrdPCzXiNVUpCeOos5cxnpQT39G+XVLhs1osQVvJKPZyNq8HDwd4d7pNDuWJPxVX7MSzqUDU6gfadKiNlUFTzLeFHHDlzO4kpa7aiKhBPGKwOqxsBAmYkOIpipyXcQSPlRTf+Tii0U3EJGaZsDER2qoB3h2hu0qe+NNwUooYU8y5mILbJe6OuX+2FTKy7bieTDAemaQyQ0CPthljSWO+xmFDIYiESjM5xKd6Ik5lvLq5GrQ3aCMLvmCA9wowLuWJb9xF59hVVP6O0CrBi3ZjZSNOvRy+I6klNVRJYRBaEzdN+imiUXQ8iVF8fsp+W4JXw7WISW7fDh7lptWkCwZ4d7QTXyBPfJMYK7SijjFppGnlIVJBJBYj7eUwtiP1IBXGI1XCsjNpbjENVpSAJ2hq2LTywEly3hUYazt31J8w2+aiLx3g3fohXixPfOMYm6zCGs9LVo9MoW3MCJE7R5u/WsOIjrqBoHUO0bJE9vxBpbhsd3+Nb4/vtPCZ4oZYCitNeYuC/8UDvDvy0qvkiW/cgqNqRyzqSZa/s0mqNGjtKOoTm14zZpUauiQgVfqtQiZjq7Q27JNaSK5ExRcrGCXO1FJYh6jR6CFqK7bZdQZ4t8g0rSlPfP1RdBtqaa9diqtzJkQ9duSryi2brQXbxDwbRUpFMBHjRj8+Nt7GDKgvph9okW7LX47gu0SpGnnFQ1S1lYldOsC7hYteR574ZuKs7Ei1lBsfdz7IZoxzzCVmmVqaSySzQbBVAWDek+N4jh9E/4VqZrJjPwiv9BC1XcvOWgO8275CVyBPvAtTVlDJfZkaZGU7NpqBogAj/xEHkeAuJihWYCxGN6e8+9JtSegFXF1TrhhLGP1fak3pebgPz192/8gB4d/6WT7+GdYnpH7hH/DJzzFiYPn/vjW0SgNpTNuPIZoAEZv8tlGw4+RLxy+ZjnKa5NdFoC7UaW0aduoYse6+bXg1DLg6UfRYwmhGEjqPvF75U558SANrElK/+MdpXvmqBpaXOa/MTZaa1DOcSiLaw9j0NNNst3c+63c7EKTpkvKHzu6bPbP0RkuHAVcbRY8ijP46MIbQeeT1mhA+5PV/inyDdQipf8LTvMXbwvoDy7IruDNVZKTfV4CTSRUYdybUCnGU7KUTDxLgCknqUm5aAW6/1p6eMsOYsphLzsHrE0Y/P5bQedx1F/4yPHnMB3/IOoTU9+BL8PhtjuFKBpZXnYNJxTuv+2XqolKR2UQgHhS5novuxVySJhBNRF3SoKK1XZbbXjVwWNyOjlqWJjrWJIy+P5bQedyldNScP+HZ61xKSK3jyrz+NiHG1hcOLL/+P+PDF2gOkekKGiNWKgJ+8Z/x8Iv4DdQHzcpZyF4v19I27w9/yPGDFQvmEpKtqv/TLiWMfn4sofMm9eAH8Ao0zzh7h4sJqYtxZd5/D7hkYPneDzl5idlzNHcIB0jVlQ+8ULzw/nc5/ojzl2juE0apD7LRnJxe04dMz2iOCFNtGFpTuXA5AhcTRo8mdN4kz30nVjEC4YTZQy4gpC7GlTlrePKhGsKKgeXpCYeO0MAd/GH7yKQUlXPLOasOH3FnSphjHuDvEu4gB8g66oNbtr6eMbFIA4fIBJkgayoXriw2XEDQPJrQeROAlY6aeYOcMf+IVYTU3XFlZufMHinGywaW3YLpObVBAsbjF4QJMsVUSayjk4voPsHJOQfPWDhCgDnmDl6XIRerD24HsGtw86RMHOLvVSHrKBdeVE26gKB5NKHzaIwLOmrqBWJYZDLhASG16c0Tn+CdRhWDgWXnqRZUTnPIHuMJTfLVpkoYy5CzylHVTGZMTwkGAo2HBlkQplrJX6U+uF1wZz2uwS1SQ12IqWaPuO4baZaEFBdukksJmkcTOm+YJSvoqPFzxFA/YUhIvWxcmSdPWTWwbAKVp6rxTtPFUZfKIwpzm4IoMfaYQLWgmlG5FME2gdBgm+J7J+rtS/XBbaVLsR7bpPQnpMFlo2doWaVceHk9+MkyguZNCJ1He+kuHTWyQAzNM5YSUg/GlTk9ZunAsg1qELVOhUSAK0LABIJHLKbqaEbHZLL1VA3VgqoiOKXYiS+HRyaEKgsfIqX64HYWbLRXy/qWoylIV9gudL1OWBNgBgTNmxA6b4txDT4gi3Ri7xFSLxtXpmmYnzAcWDZgY8d503LFogz5sbonDgkKcxGsWsE1OI+rcQtlgBBCSOKD1mtqYpIU8cTvBmAT0yZe+zUzeY92fYjTtGipXLhuR0ePoHk0ofNWBX+lo8Z7pAZDk8mEw5L7dVyZZoE/pTewbI6SNbiAL5xeygW4xPRuLCGbhcO4RIeTMFYHEJkYyEO9HmJfXMDEj/LaH781wHHZEtqSQ/69UnGpzH7LKIAZEDSPJnTesJTUa+rwTepI9dLJEawYV+ZkRn9g+QirD8vF8Mq0jFQ29js6kCS3E1+jZIhgPNanHdHFqFvPJLHqFwQqbIA4jhDxcNsOCCQLDomaL/dr5lyJaJU6FxPFjO3JOh3kVMcROo8u+C+jo05GjMF3P3/FuDLn5x2M04xXULPwaS6hBYki+MrMdZJSgPHlcB7nCR5bJ9Kr5ACUn9jk5kivdd8tk95SOGrtqu9lr2IhK65ZtEl7ZKrp7DrqwZfRUSN1el7+7NJxZbywOC8neNKTch5vsTEMNsoCCqHBCqIPRjIPkm0BjvFODGtto99rCl+d3wmHkW0FPdpZtC7MMcVtGFQjJLX5bdQ2+x9ypdc313uj8xlsrfuLgWXz1cRhZvJYX0iNVBRcVcmCXZs6aEf3RQF2WI/TcCbKmGU3IOoDJGDdDub0+hYckt6PlGu2BcxmhbTdj/klhccLGJMcqRjMJP1jW2ETqLSWJ/29MAoORluJ+6LPffBZbi5gqi5h6catQpmOT7/OFf5UorRpLzCqcMltBLhwd1are3kztrSzXO0LUbXRQcdLh/RdSZ+swRm819REDrtqzC4es6Gw4JCKlSnjYVpo0xeq33PrADbFLL3RuCmObVmPN+24kfa+AojDuM4umKe2QwCf6EN906HwjujaitDs5o0s1y+k3lgbT2W2i7FJdnwbLXhJUBq/9liTctSmFC/0OqUinb0QddTWamtjbHRFuWJJ6NpqZ8vO3fZJ37Db+2GkaPYLGHs7XTTdiFQJ68SkVJFVmY6McR5UycflNCsccHFaV9FNbR4NttLxw4pQ7wJd066Z0ohVbzihaxHVExd/ay04oxUKWt+AsdiQ9OUyZ2krzN19IZIwafSTFgIBnMV73ADj7V/K8u1MaY2sJp2HWm0f41tqwajEvdHWOJs510MaAqN4aoSiPCXtN2KSi46dUxHdaMquar82O1x5jqhDGvqmoE9LfxcY3zqA7/x3HA67r9ZG4O6Cuxu12/+TP+eLP+I+HErqDDCDVmBDO4larujNe7x8om2rMug0MX0rL1+IWwdwfR+p1TNTyNmVJ85ljWzbWuGv8/C7HD/izjkHNZNYlhZcUOKVzKFUxsxxN/kax+8zPWPSFKw80rJr9Tizyj3o1gEsdwgWGoxPezDdZ1TSENE1dLdNvuKL+I84nxKesZgxXVA1VA1OcL49dFlpFV5yJMhzyCmNQ+a4BqusPJ2bB+xo8V9u3x48VVIEPS/mc3DvAbXyoYr6VgDfh5do5hhHOCXMqBZUPhWYbWZECwVJljLgMUWOCB4MUuMaxGNUQDVI50TQ+S3kFgIcu2qKkNSHVoM0SHsgoZxP2d5HH8B9woOk4x5bPkKtAHucZsdykjxuIpbUrSILgrT8G7G5oCW+K0990o7E3T6AdW4TilH5kDjds+H64kS0mz24grtwlzDHBJqI8YJQExotPvoC4JBq0lEjjQkyBZ8oH2LnRsQ4Hu1QsgDTJbO8fQDnllitkxuVskoiKbRF9VwzMDvxHAdwB7mD9yCplhHFEyUWHx3WtwCbSMMTCUCcEmSGlg4gTXkHpZXWQ7kpznK3EmCHiXInqndkQjunG5kxTKEeGye7jWz9cyMR2mGiFQ15ENRBTbCp+Gh86vAyASdgmJq2MC6hoADQ3GosP0QHbnMHjyBQvQqfhy/BUbeHd5WY/G/9LK/8Ka8Jd7UFeNWEZvzPb458Dn8DGLOe3/wGL/4xP+HXlRt+M1PE2iLhR8t+lfgxsuh7AfO2AOf+owWhSZRYQbd622hbpKWKuU+XuvNzP0OseRDa+mObgDHJUSc/pKx31QdKffQ5OIJpt8GWjlgTwMc/w5MPCR/yl1XC2a2Yut54SvOtMev55Of45BOat9aWG27p2ZVORRvnEk1hqWMVUmqa7S2YtvlIpspuF1pt0syuZS2NV14mUidCSfzQzg+KqvIYCMljIx2YK2AO34fX4GWdu5xcIAb8MzTw+j/lyWM+Dw/gjs4GD6ehNgA48kX/AI7XXM/XAN4WHr+9ntywqoCakCqmKP0rmQrJJEErG2Upg1JObr01lKQy4jskWalKYfJ/EDLMpjNSHFEUAde2fltaDgmrNaWQ9+AAb8I5vKjz3L1n1LriB/BXkG/wwR9y/oRX4LlioHA4LzP2inzRx/DWmutRweFjeP3tNeSGlaE1Fde0OS11yOpmbIp2u/jF1n2RRZviJM0yBT3IZl2HWImKjQOxIyeU325b/qWyU9Moj1o07tS0G7qJDoGHg5m8yeCxMoEH8GU45tnrNM84D2l297DQ9t1YP7jki/7RmutRweEA77/HWXOh3HCxkRgldDQkAjNTMl2Iloc1qN5JfJeeTlyTRzxURTdn1Ixv2uKjs12AbdEWlBtmVdk2k7FFwj07PCZ9XAwW3dG+8xKzNFr4EnwBZpy9Qzhh3jDXebBpYcpuo4fQ44u+fD1dweEnHzI7v0xuuOALRUV8rXpFyfSTQYkhd7IHm07jpyhlkCmI0ALYqPTpUxXS+z4jgDj1Pflvmz5ecuItpIBxyTHpSTGWd9g1ApfD/bvwUhL4nT1EzqgX7cxfCcNmb3mPL/qi9SwTHJ49oj5ZLjccbTG3pRmlYi6JCG0mQrAt1+i2UXTZ2dv9IlQpN5naMYtviaXlTrFpoMsl3bOAFEa8sqPj2WCMrx3Yjx99qFwO59Aw/wgx+HlqNz8oZvA3exRDvuhL1jMQHPaOJ0+XyA3fp1OfM3qObEVdhxjvynxNMXQV4+GJyvOEFqeQBaIbbO7i63rpxCltdZShPFxkjM2FPVkn3TG+Rp9pO3l2RzFegGfxGDHIAh8SteR0C4HopXzRF61nheDw6TFN05Ebvq8M3VKKpGjjO6r7nhudTEGMtYM92HTDaR1FDMXJ1eThsbKfywyoWwrzRSXkc51flG3vIid62h29bIcFbTGhfV+faaB+ohj7dPN0C2e2lC96+XouFByen9AsunLDJZ9z7NExiUc0OuoYW6UZkIyx2YUR2z6/TiRjyKMx5GbbjLHvHuf7YmtKghf34LJfx63Yg8vrvN2zC7lY0x0tvKezo4HmGYDU+Gab6dFL+KI761lDcNifcjLrrr9LWZJctG1FfU1uwhoQE22ObjdfkSzY63CbU5hzs21WeTddH2BaL11Gi7lVdlxP1nkxqhnKhVY6knS3EPgVGg1JpN5cP/hivujOelhXcPj8HC/LyI6MkteVjlolBdMmF3a3DbsuAYhL44dxzthWSN065xxUd55Lmf0wRbOYOqH09/o9WbO2VtFdaMb4qBgtFJoT1SqoN8wPXMoXLb3p1PUEhxfnnLzGzBI0Ku7FxrKsNJj/8bn/H8fPIVOd3rfrklUB/DOeO+nkghgSPzrlPxluCMtOnDL4Yml6dK1r3vsgMxgtPOrMFUZbEUbTdIzii5beq72G4PD0DKnwjmBULUVFmy8t+k7fZ3pKc0Q4UC6jpVRqS9Umv8bxw35flZVOU1X7qkjnhZlsMbk24qQ6Hz7QcuL6sDC0iHHki96Uh2UdvmgZnjIvExy2TeJdMDZNSbdZyAHe/Yd1xsQhHiKzjh7GxQ4yqMPaywPkjMamvqrYpmO7Knad+ZQC5msCuAPWUoxrxVhrGv7a+KLXFhyONdTMrZ7ke23qiO40ZJUyzgYyX5XyL0mV7NiUzEs9mjtbMN0dERqwyAJpigad0B3/zRV7s4PIfXSu6YV/MK7+OrYe/JvfGMn/PHJe2fyUdtnFrKRNpXV0Y2559aWPt/G4BlvjTMtXlVIWCnNyA3YQBDmYIodFz41PvXPSa6rq9lWZawZ4dP115HXV/M/tnFkkrBOdzg6aP4pID+MZnTJ1SuuB6iZlyiox4HT2y3YBtkUKWooacBQUDTpjwaDt5poBHl1/HXltwP887lKKXxNUEyPqpGTyA699UqY/lt9yGdlUKra0fFWS+36iylVWrAyd7Uw0CZM0z7xKTOduznLIjG2Hx8cDPLb+OvK6Bv7n1DYci4CxUuRxrjBc0bb4vD3rN5Zz36ntLb83eVJIB8LiIzCmn6SMPjlX+yNlTjvIGjs+QzHPf60Aj62/jrzG8j9vYMFtm1VoRWCJdmw7z9N0t+c8cxZpPeK4aTRicS25QhrVtUp7U578chk4q04Wx4YoQSjFryUlpcQ1AbxZ/XVMknIU//OGl7Q6z9Zpxi0+3yFhSkjUDpnCIUhLWVX23KQ+L9vKvFKI0ZWFQgkDLvBoylrHNVmaw10zwCPrr5tlodfnf94EWnQ0lFRWy8pW9LbkLsyUVDc2NSTHGDtnD1uMtchjbCeb1mpxFP0YbcClhzdLu6lfO8Bj6q+bdT2sz/+8SZCV7VIxtt0DUn9L7r4cLYWDSXnseEpOGFuty0qbOVlS7NNzs5FOGJUqQpl2Q64/yBpZf90sxbE+//PGdZ02HSipCbmD6NItmQ4Lk5XUrGpDMkhbMm2ZVheNYV+VbUWTcv99+2NyX1VoafSuC+AN6q9bFIMv5X/eagNWXZxEa9JjlMwNWb00akGUkSoepp1/yRuuqHGbUn3UdBSTxBU6SEVklzWRUkPndVvw2PrrpjvxOvzPmwHc0hpmq82npi7GRro8dXp0KXnUQmhZbRL7NEVp1uuZmO45vuzKsHrktS3GLWXODVjw+vXXLYx4Hf7njRPd0i3aoAGX6W29GnaV5YdyDj9TFkakje7GHYzDoObfddHtOSpoi2SmzJHrB3hM/XUDDEbxP2/oosszcRlehWXUvzHv4TpBVktHqwenFo8uLVmy4DKLa5d3RtLrmrM3aMFr1183E4sewf+85VWeg1c5ag276NZrM9IJVNcmLEvDNaV62aq+14IAOGFsBt973Ra8Xv11YzXwNfmft7Jg2oS+XOyoC8/cwzi66Dhmgk38kUmP1CUiYWOX1bpD2zWXt2FCp7uq8703APAa9dfNdscR/M/bZLIyouVxqJfeWvG9Je+JVckHQ9+CI9NWxz+blX/KYYvO5n2tAP/vrlZ7+8/h9y+9qeB/Hnt967e5mevX10rALDWK//FaAT5MXdBXdP0C/BAes792c40H+AiAp1e1oH8HgH94g/Lttx1gp63op1eyoM/Bvw5/G/7xFbqJPcCXnmBiwDPb/YKO4FX4OjyCb289db2/Noqicw4i7N6TVtoz8tNwDH+8x/i6Ae7lmaQVENzJFb3Di/BFeAwz+Is9SjeQySpPqbLFlNmyz47z5a/AF+AYFvDmHqibSXTEzoT4Gc3OALaqAP4KPFUJ6n+1x+rGAM6Zd78bgJ0a8QN4GU614vxwD9e1Amy6CcskNrczLx1JIp6HE5UZD/DBHrFr2oNlgG4Odv226BodoryjGJ9q2T/AR3vQrsOCS0ctXZi3ruLlhpFDJYl4HmYtjQCP9rhdn4suySLKDt6wLcC52h8xPlcjju1fn+yhuw4LZsAGUuo2b4Fx2UwQu77uqRHXGtg92aN3tQCbFexc0uk93vhTXbct6y7MulLycoUljx8ngDMBg1tvJjAazpEmOtxlzclvj1vQf1Tx7QlPDpGpqgtdSKz/d9/hdy1vTfFHSmC9dGDZbLiezz7Ac801HirGZsWjydfZyPvHXL/Y8Mjzg8BxTZiuwKz4Eb8sBE9zznszmjvFwHKPIWUnwhqfVRcd4Ck0K6ate48m1oOfrX3/yOtvAsJ8zsPAM89sjnddmuLuDPjX9Bu/L7x7xpMzFk6nWtyQfPg278Gn4Aekz2ZgOmU9eJ37R14vwE/BL8G3aibCiWMWWDQ0ZtkPMnlcGeAu/Ag+8ZyecU5BPuy2ILD+sQqyZhAKmn7XZd+jIMTN9eBL7x95xVLSX4On8EcNlXDqmBlqS13jG4LpmGbkF/0CnOi3H8ETOIXzmnmtb0a16Tzxj1sUvQCBiXZGDtmB3KAefPH94xcUa/6vwRn80GOFyjEXFpba4A1e8KQfFF+259tx5XS4egYn8fQsLGrqGrHbztr+uByTahWuL1NUGbDpsnrwBfePPwHHIf9X4RnM4Z2ABWdxUBlqQ2PwhuDxoS0vvqB1JzS0P4h2nA/QgTrsJFn+Y3AOjs9JFC07CGWX1oNX3T/yHOzgDjwPn1PM3g9Jk9lZrMEpxnlPmBbjyo2+KFXRU52TJM/2ALcY57RUzjObbjqxVw++4P6RAOf58pcVsw9Daje3htriYrpDOonre3CudSe6bfkTEgHBHuDiyu5MCsc7BHhYDx7ePxLjqigXZsw+ijMHFhuwBmtoTPtOxOrTvYJDnC75dnUbhfwu/ZW9AgYd+peL68HD+0emKquiXHhWjJg/UrkJYzuiaL3E9aI/ytrCvAd4GcYZMCkSQxfUg3v3j8c4e90j5ZTPdvmJJGHnOCI2nHS8081X013pHuBlV1gB2MX1YNmWLHqqGN/TWmG0y6clJWthxNUl48q38Bi8vtMKyzzpFdSDhxZ5WBA5ZLt8Jv3895DduBlgbPYAj8C4B8hO68FDkoh5lydC4FiWvBOVqjYdqjiLv92t8yPDjrDaiHdUD15qkSURSGmXJwOMSxWAXYwr3zaAufJ66l+94vv3AO+vPcD7aw/w/toDvL/2AO+vPcD7aw/wHuD9tQd4f+0B3l97gPfXHuD9tQd4f+0B3l97gG8LwP8G/AL8O/A5OCq0Ys2KIdv/qOIXG/4mvFAMF16gZD+2Xvu/B8as5+8bfllWyg0zaNO5bfXj6vfhhwD86/Aq3NfRS9t9WPnhfnvCIw/CT8GLcFTMnpntdF/z9V+PWc/vWoIH+FL3Znv57PitcdGP4R/C34avw5fgRVUInCwbsn1yyA8C8zm/BH8NXoXnVE6wVPjdeCI38kX/3+Ct9dbz1pTmHFRu+Hm4O9Ch3clr99negxfwj+ER/DR8EV6B5+DuQOnTgUw5rnkY+FbNU3gNXh0o/JYTuWOvyBf9FvzX663HH/HejO8LwAl8Hl5YLTd8q7sqA3wbjuExfAFegQdwfyDoSkWY8swzEf6o4Qyewefg+cHNbqMQruSL/u/WWc+E5g7vnnEXgDmcDeSGb/F4cBcCgT+GGRzDU3hZYburAt9TEtHgbM6JoxJ+6NMzzTcf6c2bycv2+KK/f+l6LBzw5IwfqZJhA3M472pWT/ajKxnjv4AFnMEpnBTPND6s2J7qHbPAqcMK74T2mZ4VGB9uJA465It+/eL1WKhYOD7xHOkr1ajK7d0C4+ke4Hy9qXZwpgLr+Znm/uNFw8xQOSy8H9IzjUrd9+BIfenYaylf9FsXr8fBAadnPIEDna8IBcwlxnuA0/Wv6GAWPd7dDIKjMdSWueAsBj4M7TOd06qBbwDwKr7oleuxMOEcTuEZTHWvDYUO7aHqAe0Bbq+HEFRzOz7WVoTDQkVds7A4sIIxfCQdCefFRoIOF/NFL1mPab/nvOakSL/Q1aFtNpUb/nFOVX6gzyg/1nISyDfUhsokIzaBR9Kxm80s5mK+6P56il1jXic7nhQxsxSm3OwBHl4fFdLqi64nDQZvqE2at7cWAp/IVvrN6/BFL1mPhYrGMBfOi4PyjuSGf6wBBh7p/FZTghCNWGgMzlBbrNJoPJX2mW5mwZfyRffXo7OFi5pZcS4qZUrlViptrXtw+GQoyhDPS+ANjcGBNRiLCQDPZPMHuiZfdFpPSTcQwwKYdRNqpkjm7AFeeT0pJzALgo7g8YYGrMHS0iocy+YTm2vyRUvvpXCIpQ5pe666TJrcygnScUf/p0NDs/iAI/nqDHC8TmQT8x3NF91l76oDdQGwu61Z6E0ABv7uO1dbf/37Zlv+Zw/Pbh8f1s4Avur6657/+YYBvur6657/+YYBvur6657/+YYBvur6657/+aYBvuL6657/+VMA8FXWX/f8zzcN8BXXX/f8zzcNMFdbf93zP38KLPiK6697/uebtuArrr/u+Z9vGmCusP6653/+1FjwVdZf9/zPN7oHX339dc//fNMu+irrr3v+50+Bi+Zq6697/uebA/jz8Pudf9ht/fWv517J/XUzAP8C/BAeX9WCDrUpZ3/dEMBxgPcfbtTVvsYV5Yn32u03B3Ac4P3b8I+vxNBKeeL9dRMAlwO83959qGO78sT769oB7g3w/vGVYFzKE++v6wV4OMD7F7tckFkmT7y/rhHgpQO8b+4Y46XyxPvrugBeNcB7BRiX8sT767oAvmCA9woAHsoT76+rBJjLBnh3txOvkifeX1dswZcO8G6N7sXyxPvr6i340gHe3TnqVfLE++uKAb50gHcXLnrX8sR7gNdPRqwzwLu7Y/FO5Yn3AK9jXCMGeHdgxDuVJ75VAI8ljP7PAb3/RfjcZfePHBB+79dpfpH1CanN30d+mT1h9GqAxxJGM5LQeeQ1+Tb+EQJrElLb38VHQ94TRq900aMIo8cSOo+8Dp8QfsB8zpqE1NO3OI9Zrj1h9EV78PqE0WMJnUdeU6E+Jjyk/hbrEFIfeWbvId8H9oTRFwdZaxJGvziW0Hn0gqYB/wyZ0PwRlxJST+BOw9m77Amj14ii1yGM/txYQudN0qDzGe4EqfA/5GJCagsHcPaEPWH0esekSwmjRxM6b5JEcZ4ww50ilvAOFxBSx4yLW+A/YU8YvfY5+ALC6NGEzhtmyZoFZoarwBLeZxUhtY4rc3bKnjB6TKJjFUHzJoTOozF2YBpsjcyxDgzhQ1YRUse8+J4wenwmaylB82hC5w0zoRXUNXaRBmSMQUqiWSWkLsaVqc/ZE0aPTFUuJWgeTei8SfLZQeMxNaZSIzbII4aE1Nmr13P2hNHjc9E9guYNCZ032YlNwESMLcZiLQHkE4aE1BFg0yAR4z1h9AiAGRA0jyZ03tyIxWMajMPWBIsxYJCnlITU5ShiHYdZ94TR4wCmSxg9jtB5KyPGYzymAYexWEMwAPIsAdYdV6aObmNPGD0aYLoEzaMJnTc0Ygs+YDw0GAtqxBjkuP38bMRWCHn73xNGjz75P73WenCEJnhwyVe3AEe8TtKdJcYhBl97wuhNAObK66lvD/9J9NS75v17wuitAN5fe4D31x7g/bUHeH/tAd5fe4D3AO+vPcD7aw/w/toDvL/2AO+vPcD7aw/w/toDvAd4f/24ABzZ8o+KLsSLS+Pv/TqTb3P4hKlQrTGh+fbIBT0Axqznnb+L/V2mb3HkN5Mb/nEHeK7d4IcDld6lmDW/iH9E+AH1MdOw/Jlu2T1xNmY98sv4wHnD7D3uNHu54WUuOsBTbQuvBsPT/UfzNxGYzwkP8c+Yz3C+r/i6DcyRL/rZ+utRwWH5PmfvcvYEt9jLDS/bg0/B64DWKrQM8AL8FPwS9beQCe6EMKNZYJol37jBMy35otdaz0Bw2H/C2Smc7+WGB0HWDELBmOByA3r5QONo4V+DpzR/hFS4U8wMW1PXNB4TOqYz9urxRV++ntWCw/U59Ty9ebdWbrgfRS9AYKKN63ZokZVygr8GZ/gfIhZXIXPsAlNjPOLBby5c1eOLvmQ9lwkOy5x6QV1j5TYqpS05JtUgUHUp5toHGsVfn4NX4RnMCe+AxTpwmApTYxqMxwfCeJGjpXzRF61nbcHhUBPqWze9svwcHJ+S6NPscKrEjug78Dx8Lj3T8D4YxGIdxmJcwhi34fzZUr7olevZCw5vkOhoClq5zBPZAnygD/Tl9EzDh6kl3VhsHYcDEb+hCtJSvuiV69kLDm+WycrOTArHmB5/VYyP6jOVjwgGawk2zQOaTcc1L+aLXrKeveDwZqlKrw8U9Y1p66uK8dEzdYwBeUQAY7DbyYNezBfdWQ97weEtAKYQg2xJIkuveAT3dYeLGH+ShrWNwZgN0b2YL7qznr3g8JYAo5bQBziPjx7BPZ0d9RCQp4UZbnFdzBddor4XHN4KYMrB2qHFRIzzcLAHQZ5the5ovui94PCWAPefaYnxIdzRwdHCbuR4B+tbiy96Lzi8E4D7z7S0mEPd+eqO3cT53Z0Y8SV80XvB4Z0ADJi/f7X113f+7p7/+UYBvur6657/+YYBvur6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+aYBvuL6657/+VMA8FXWX/f8z58OgK+y/rrnf75RgLna+uue//lTA/CV1V/3/M837aKvvv6653++UQvmauuve/7nTwfAV1N/3fM/fzr24Cuuv+75nz8FFnxl9dc9//MOr/8/glixwRuUfM4AAAAASUVORK5CYII="}getSearchTexture(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII="}dispose(){this.edgesRT.dispose(),this.weightsRT.dispose(),this.areaTexture.dispose(),this.searchTexture.dispose(),this.materialEdges.dispose(),this.materialWeights.dispose(),this.materialBlend.dispose(),this.fsQuad.dispose()}};var CL=Ra(_E()),PL=Ra(ME()),iS=Ra(TE()),IL=Ra(wE()),NL=Ra(CE());function Wy(i,e){if(!(i>0)||!Number.isFinite(i)||!Number.isFinite(e))return{steps:1,limited:!1};let t=Math.min(Math.PI/48,2*Math.acos(Math.max(-1,1-Math.min(.005,i)/i))),n=Math.max(8,Math.ceil(Math.abs(e)/Math.max(t,1e-8)));return{steps:Math.min(512,n),limited:n>512}}var nN=Object.freeze({side:2,depthWrite:!0,transparent:!1,opacity:1});var PE=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i;function rm(i,e,t,n){for(let r of["uuid","tstamp"]){let s=PE(i.find(o=>Array.isArray(o)&&PE(o[0])===r)?.[1]);if(typeof s=="string"&&s||typeof s=="number"&&Number.isFinite(s))return String(s)}if(!Number.isSafeInteger(t)||t<0||!Number.isSafeInteger(n)||n<0)throw TypeError("Choose bounded source pad occurrences.");return`display-pad:${t}:${n}`}function Xy(i,e=0,t=e){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=0;for(let o of i)Number.isFinite(o)&&(o<n&&(n=o),o>r&&(r=o),s+=1);return s?{minimum:n,maximum:r,count:s}:{minimum:e,maximum:t,count:0}}var eI=new Set(["signal","power","mixed","jumper"]);function tI(i){return!i.name||i.name.includes("*")?!1:i.name.endsWith(".Cu")||eI.has(i.kind.toLowerCase())}function nI(i,e){return i==="F.Cu"?-1:e==="F.Cu"||i==="B.Cu"?1:e==="B.Cu"?-1:i.localeCompare(e,void 0,{numeric:!0})}function iI(i,e=[],t=[]){let n=[...i].filter(tI).map(l=>l.name),r=[...new Set(t)].filter(l=>l.endsWith(".Cu")&&!l.includes("*")),s=new Set(r),o=n.length>0&&n.every(l=>s.has(l))?[...r,...n.filter(l=>!s.has(l))]:n,a=new Set(o),c=[...new Set(e)].filter(l=>l.endsWith(".Cu")&&!l.includes("*")&&!a.has(l)).sort(nI);return[...o,...c]}var rI=.015;function la(i){return Array.isArray(i)}function*sI(i){let e="",t=!1,n=!1;for(let r of i)n?(e+=r,n=!1):t&&r==="\\"?n=!0:r==='"'?t=!t:t?e+=r:r==="("||r===")"?(e&&(yield e,e=""),yield r):/\s/.test(r)?e&&(yield e,e=""):e+=r;e&&(yield e)}function oI(i){let e=[],t=[e];for(let r of i)if(r==="("){let s=[];t[t.length-1].push(s),t.push(s)}else r===")"?t.length>1&&t.pop():t[t.length-1].push(r);return e.find(la)??[]}function Yt(i,e){return i.find(t=>la(t)&&t[0]===e)}function Ur(i,e){return i.filter(t=>la(t)&&t[0]===e)}function vn(i,e,t=0){let n=Number(sm(i?.[e]));return Number.isFinite(n)?n:t}function sm(i){return i&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Float64Array)?i.quoted:typeof i=="string"||typeof i=="number"?i:void 0}function Gt(i,e,t=""){let n=sm(i?.[e]);return typeof n=="string"?n:typeof n=="number"?String(n):t}function Sn(i,e){let t=i?Yt(i,e):void 0;if(!(!t||t.length<3))return[vn(t,1),vn(t,2)]}function Yy(i,e,t){let n=Yt(Yt(i??[],e)??[],"xyz");return n?[vn(n,1,t[0]),vn(n,2,t[1]),vn(n,3,t[2])]:t}function FE(i){let e=i?Yt(i,"pts"):void 0;if(!e)return[];let t=e[1];if(t instanceof Float64Array){let n=[];for(let r=0;r<t.length;r+=2)n.push([t[r],t[r+1]]);return n}return Ur(e,"xy").map(n=>[vn(n,1),vn(n,2)])}function Fh(i,e){return Gt(Yt(i,"uuid"),1,Gt(Yt(i,"tstamp"),1,e))}function Uh(i,e="F.Cu"){return Gt(Yt(i,"layer"),1,Gt(Yt(i,"layers"),1,e))}function IE(i,e){return Gt(Ur(i,"property").find(t=>Gt(t,1).toLowerCase()===e.toLowerCase()),2)}function aI(i,e,t){let n=i[0],r=-t*Math.PI/180,s=Math.cos(r),o=Math.sin(r);return[e[0]+n*s-i[1]*o,e[1]+n*o+i[1]*s]}function UE(i,e,t){let[n,r]=i,[s,o]=e,[a,c]=t,l=2*(n*(o-c)+s*(c-r)+a*(r-o));if(Math.abs(l)<1e-9)return null;let u=((n*n+r*r)*(o-c)+(s*s+o*o)*(c-r)+(a*a+c*c)*(r-o))/l,h=((n*n+r*r)*(a-s)+(s*s+o*o)*(n-a)+(a*a+c*c)*(s-n))/l,d=Math.atan2(r-h,n-u),m=Math.atan2(o-h,s-u),g=Math.atan2(c-h,a-u),y=Math.PI*2,f=x=>(x%y+y)%y,p=f(m-d),v=f(g-d),b=p<=v?v:v-y;return{center:[u,h],radius:Math.hypot(n-u,r-h),sweep:b,startAngle:d}}function kE(i,e,t){let n=UE(i,e,t);if(!n)return[i,t];let{steps:r}=Wy(n.radius,n.sweep);return Array.from({length:r+1},(s,o)=>{let a=n.startAngle+n.sweep*o/r;return[n.center[0]+n.radius*Math.cos(a),n.center[1]+n.radius*Math.sin(a)]})}function cI(i,e){let t=Math.hypot(e[0]-i[0],e[1]-i[1]);return Array.from({length:65},(n,r)=>{let s=Math.PI*2*r/64;return[i[0]+t*Math.cos(s),i[1]+t*Math.sin(s)]})}function NE(i,e,t,n){let r=Gt(i,0),s=Uh(i,"Dwgs.User"),o=Yt(i,"stroke"),a=vn(Yt(o??i,"width"),1,.12),c=t??(h=>h),l,u;if(r.endsWith("_line")){let h=Sn(i,"start"),d=Sn(i,"end");if(!h||!d)return null;l="line",u=[c(h),c(d)]}else if(r.endsWith("_arc")){let h=Sn(i,"start"),d=Sn(i,"mid"),m=Sn(i,"end");if(!h||!d||!m)return null;l="arc",u=kE(h,d,m).map(c)}else if(r.endsWith("_circle")){let h=Sn(i,"center"),d=Sn(i,"end");if(!h||!d)return null;l="circle",u=cI(h,d).map(c)}else if(r.endsWith("_rect")){let h=Sn(i,"start"),d=Sn(i,"end");if(!h||!d)return null;l="rect",u=[c(h),c([d[0],h[1]]),c(d),c([h[0],d[1]]),c(h)]}else if(r.endsWith("_poly"))l="poly",u=FE(i).map(c),u.length>2&&u.push(u[0]);else return null;return{id:e,type:l,points:u,layer:s,width:a,ref:n}}function ca(i,e){return Math.hypot(i[0]-e[0],i[1]-e[1])<=rI}function kh(i){let e=0;for(let t=0;t<i.length-1;t+=1)e+=i[t][0]*i[t+1][1]-i[t+1][0]*i[t][1];return e/2}function LE(i,e="Edge.Cuts"){let t=[],n=[];for(i.filter(r=>r.layer===e).forEach(r=>{let s=r.points;s.length>2&&ca(s[0],s[s.length-1])?t.push(s):s.length>1&&n.push([...s])});n.length;){let r=n.shift(),s=!0;for(;s&&!ca(r[0],r[r.length-1]);){s=!1;for(let o=0;o<n.length;o+=1){let a=n[o];if(ca(r[r.length-1],a[0]))r.push(...a.slice(1));else if(ca(r[r.length-1],a[a.length-1]))r.push(...a.slice(0,-1).reverse());else if(ca(r[0],a[a.length-1]))r.unshift(...a.slice(0,-1));else if(ca(r[0],a[0]))r.unshift(...a.slice(1).reverse());else continue;n.splice(o,1),s=!0;break}}r.length>2&&ca(r[0],r[r.length-1])&&(r[r.length-1]=r[0],t.push(r))}return t.sort((r,s)=>Math.abs(kh(s))-Math.abs(kh(r)))}function lI(i){let e=`${i.name} ${i.userName??""}`.trim().toLowerCase();return/rigid[ ._-]*flex/.test(e)?null:/(^|[ ._-])bend(?:[ ._-]|\d|$)/.test(e)?"bend":/(^|[ ._-])stiffener(?:[ ._-]|\d|$)/.test(e)?"stiffener":/(^|[ ._-])transition(?:[ ._-]|\d|$)/.test(e)?"transition":/(^|[ ._-])flex(?:ible)?(?:[ ._-]*(?:region|outline|area))?(?:[ ._-]|\d|$)/.test(e)?"flex":/(^|[ ._-])rigid(?:[ ._-]*(?:region|outline|area))?(?:[ ._-]|\d|$)/.test(e)?"rigid":null}function OE(i,e){let t=e==="r"||e==="radius"?/(?:^|[ _.-])(?:r|radius)\s*=?\s*(-?\d+(?:\.\d+)?)\s*(?:mm)?(?:$|[ _.-])/i:/(?:^|[ _.-])(?:a|angle)\s*=?\s*(-?\d+(?:\.\d+)?)\s*(?:deg)?(?:$|[ _.-])/i,n=Number(i.match(t)?.[1]);return Number.isFinite(n)?n:void 0}function DE(i){if(!i.length)return{minX:0,minY:0,maxX:100,maxY:70};let e=Xy(i.map(n=>n[0])),t=Xy(i.map(n=>n[1]));return{minX:e.minimum,minY:t.minimum,maxX:e.maximum,maxY:t.maximum}}function BE(i,e,t={}){let n=e||oI(sI(i));if(n[0]!=="kicad_pcb")throw new Error("The selected file is not a KiCad PCB document.");let r=[],s=[],o=[],a=[],c=[],l=[],u=new Set,h=[],d=new Set,m=[],g=[],y={};for(let I of n)la(I)&&I[0]==="net"&&(y[Gt(I,1)]=Gt(I,2));let f=I=>{let V=Yt(I,"net"),W=Gt(V,1),se=Gt(V,2)||Gt(Yt(I,"net_name"),1)||y[W]||(/^\d+$/.test(W)?"":W);return se&&(y[W||se]=se),se||void 0},p=-1;for(let I of n){if(!la(I)||!I.length)continue;let V=Gt(I,0);if((V==="footprint"||V==="module")&&p++,V==="layers")I.slice(1).filter(la).forEach(W=>{let Q=Gt(W,1);Q&&!Q.includes("*")&&m.push({id:vn(W,0,m.length),name:Q,kind:Gt(W,2)||"user",userName:Gt(W,3)||void 0}),Q.endsWith(".Cu")&&!Q.includes("*")&&d.add(Q)});else if(V==="setup"){let W=Yt(I,"stackup");Ur(W??[],"layer").forEach(Q=>{let se=Gt(Q,1);if(!se)return;let oe=Yt(Q,"thickness"),ge=Yt(Q,"epsilon_r"),O=Yt(Q,"loss_tangent");g.push({name:se,type:Gt(Yt(Q,"type"),1,"unknown"),thickness:oe?vn(oe,1):void 0,material:Gt(Yt(Q,"material"),1)||void 0,epsilonR:ge?vn(ge,1):void 0,lossTangent:O?vn(O,1):void 0}),se.endsWith(".Cu")&&d.add(se)})}else if(V==="segment"||V==="arc"){let W=vn(Yt(I,"width"),1,.25),Q=Uh(I),se=f(I),oe=Fh(I,`track-${r.length+1}`);if(V==="arc"){let O=Sn(I,"start"),S=Sn(I,"mid"),R=Sn(I,"end"),z=O&&S&&R?UE(O,S,R):null;z&&Wy(z.radius,z.sweep).limited&&s.length<100&&s.push("Saved copper arc "+oe+" exceeds the 512-segment/5 \xC2\xB5m chord budget and is shown approximately.")}let ge=V==="arc"?kE(Sn(I,"start")??[0,0],Sn(I,"mid")??[0,0],Sn(I,"end")??[0,0]):[Sn(I,"start"),Sn(I,"end")].filter(Boolean);for(let O=0;O<ge.length-1;O+=1)r.push({id:ge.length>2?`${oe}:${O}`:oe,start:ge[O],end:ge[O+1],width:W,layer:Q,net:se});d.add(Q)}else if(V==="via"){let W=Sn(I,"at");if(!W)continue;let Q=Yt(I,"layers")?.slice(1).map(sm).filter(se=>typeof se=="string")??["F.Cu","B.Cu"];o.push({id:Fh(I,`via-${o.length+1}`),at:W,size:vn(Yt(I,"size"),1,.8),drill:vn(Yt(I,"drill"),1,.4),layers:Q,net:f(I)})}else if(V==="zone"){let W=Uh(I),Q=Ur(I,"filled_polygon");(Q.length?Q:Ur(I,"polygon")).forEach((oe,ge)=>{let O=Yt(oe,"pts"),S=O?.[1]instanceof Float64Array?O[1].length/2:0;for(let K of O||[])la(K)&&Gt(K,0)==="xy"&&S++;if(S<3)return;let R=Uh(oe,W),z=f(I);if(d.add(R),u.add(R),t.zonePoints===!1)return;let Y=FE(oe);l.push({id:`${Fh(I,`zone-${l.length+1}`)}:${ge}`,points:Y,layer:R,net:z})})}else if(V.startsWith("gr_")){let W=NE(I,Fh(I,`drawing-${h.length+1}`));W&&h.push(W)}else if(V==="footprint"||V==="module"){let W=Sn(I,"at")??[0,0],Q=Yt(I,"at"),se=vn(Q,3),oe=Uh(I),ge=oe.startsWith("B."),O=ne=>aI(ne,W,se),S=IE(I,"Reference")||Gt(Ur(I,"fp_text").find(ne=>Gt(ne,1)==="reference"),2)||`REF${c.length+1}`,R=IE(I,"Value")||Gt(Ur(I,"fp_text").find(ne=>Gt(ne,1)==="value"),2)||"",z=[],Y=[];Ur(I,"pad").forEach((ne,H)=>{let _e=Sn(ne,"at")??[0,0];Y.push(_e);let me=Yt(ne,"size"),be=Yt(ne,"layers")?.slice(1).map(sm).filter(B=>typeof B=="string")??[oe],he=be.includes("F.Cu")||be.includes("*.Cu")?ge?"B.Cu":"F.Cu":be.find(B=>B.endsWith(".Cu"))??oe,Ne=Yt(ne,"drill"),Me=Gt(Ne,1)==="oval"?vn(Ne,2):vn(Ne,1),Z={id:rm(ne,S,p,H),name:Gt(ne,1,String(H+1)),at:O(_e),width:vn(me,1,1),height:vn(me,2,1),rotation:vn(Yt(ne,"at"),3),shape:Gt(ne,3,"rect"),drill:Me,layers:be,layer:he,net:f(ne),ref:S};a.push(Z),z.push(Z),be.filter(B=>B.endsWith(".Cu")&&!B.includes("*")).forEach(B=>d.add(B))});for(let ne of["fp_line","fp_arc","fp_circle","fp_rect","fp_poly"])Ur(I,ne).forEach((H,_e)=>{let me=NE(H,`${S}:${ne}:${_e}`,O,S);me&&h.push(me)});let K=DE(Y),re=Y.length?Math.max(K.maxX-K.minX+2.5,2.5):5,de=Y.length?Math.max(K.maxY-K.minY+2.5,2.5):5,te=Yt(I,"model");c.push({id:Fh(I,`component-${S}`),ref:S,value:R,library:Gt(I,1),at:W,width:re,height:de,rotation:se,layer:oe,model:!!te,modelPath:Gt(te,1),modelPaths:Ur(I,"model").map(ne=>Gt(ne,1)).filter(Boolean),modelOffset:Yy(te,"offset",[0,0,0]),modelScale:Yy(te,"scale",[1,1,1]),modelRotation:Yy(te,"rotate",[0,0,0])}),d.add(oe==="B.Cu"?"B.Cu":"F.Cu")}}let v=LE(h),b=v[0]??r.flatMap(I=>[I.start,I.end]).concat(a.map(I=>I.at)),x=DE(b),_=new Set(m.map(I=>I.name)),T=Math.max(-1,...m.map(I=>I.id))+1;[...r.map(I=>I.layer),...a.flatMap(I=>I.layers),...u,...h.map(I=>I.layer)].forEach(I=>{!I||I.includes("*")||_.has(I)||(_.add(I),m.push({id:T++,name:I,kind:I.endsWith(".Cu")?"signal":"user"}))});let w=iI(m,d,g.map(I=>I.name)),A=[],E=[];m.forEach(I=>{let V=lI(I);if(!V)return;let W=I.userName||I.name;if(V==="bend"){h.filter(Q=>Q.layer===I.name&&Q.points.length>=2).forEach((Q,se)=>{E.push({id:`bend:${Q.id}`,name:`${W} ${se+1}`,points:Q.points,sourceLayer:I.name,radiusMm:OE(W,"radius"),angleDeg:OE(W,"angle")})});return}LE(h,I.name).forEach((Q,se)=>{A.push({id:`region:${I.id}:${se}`,name:`${W}${se?` ${se+1}`:""}`,kind:V,outline:Q,sourceLayer:I.name,source:"kicad-user-layer"})})});let M=v[0]??[],P=Math.abs(kh(M)),N=A.filter(I=>I.kind==="flex").reduce((I,V)=>I+Math.abs(kh(V.outline)),0),L=N>0,D=A.some(I=>I.kind==="rigid"),$=L?!D&&P>0&&N>=P*.92?"flex":"rigid-flex":"rigid",U=[...A];return M.length&&$!=="flex"&&!U.some(I=>I.kind==="rigid"&&Math.abs(kh(I.outline))>=P*.92)&&U.unshift({id:"region:implicit-rigid-board",name:"Rigid board",kind:"rigid",outline:M,sourceLayer:"Edge.Cuts",source:"implicit-board-outline"}),{width:Math.max(x.maxX-x.minX,1),height:Math.max(x.maxY-x.minY,1),bounds:x,outlineLoops:v,tracks:r,geometryWarnings:s,vias:o,pads:a,components:c,zones:l,drawings:h,layers:w,layerDefinitions:m,stackup:g,nets:y,technology:$,regions:U,bendLines:E}}var OL=Ra(zE());var VE=i=>i&&(i.type==="Component"||typeof i.library=="string"),Hc=i=>{for(let e=i;e;e=e.parent)if(!e.visible)return!1;return!0},jy=(i,e)=>{if(typeof i!="string"||!i||i.length>128||/[\x00-\x1f\x7f]/.test(i))throw new TypeError("Choose a bounded "+e+".");return i},HE={top:[0,0,1],bottom:[0,0,-1],front:[0,-1,0],back:[0,1,0],left:[-1,0,0],right:[1,0,0]};function uI(i,e,t){let n=e?.getAttribute?.("position"),r=e?.index;if(!n||n.itemSize<3||e.morphAttributes?.position?.length)throw new Error("Demo faces require a static triangle mesh.");let s=Math.floor((r?r.count:n.count)/3);if(!s||s>5e4)throw new Error("Selected mesh exceeds the 50,000-triangle face-selection budget.");let o=Math.ceil((e.drawRange?.start||0)/3),a=Math.min(s,Math.floor(((e.drawRange?.start||0)+(Number.isFinite(e.drawRange?.count)?e.drawRange.count:s*3))/3));if(!Number.isInteger(t)||t<o||t>=a)throw new Error("Choose a visible triangle face.");let c=S=>new i.Vector3().fromBufferAttribute(n,r?r.getX(S):S),l=[c(t*3),c(t*3+1),c(t*3+2)],u=new i.Vector3().subVectors(l[1],l[0]).cross(new i.Vector3().subVectors(l[2],l[0]));if(u.lengthSq()<1e-20)throw new Error("The selected triangle has no usable planar area.");u.normalize(),e.computeBoundingBox();let h=e.boundingBox.getSize(new i.Vector3).length(),d=Math.max(1e-7,h*1e-7),m=u.dot(l[0]),g=e.groups||[];if(g.length>256)throw new Error("Selected mesh exceeds the 256 material-group face budget.");let y=new Int32Array(s);y.fill(-1);for(let S of g){if(!Number.isInteger(S.start)||!Number.isInteger(S.count)||S.start<0||S.count<0||S.start%3||S.count%3||!Number.isInteger(S.materialIndex)||S.materialIndex<0||S.materialIndex>1e6)throw new Error("Unsupported triangle material groups.");for(let R=S.start/3;R<Math.min(s,(S.start+S.count)/3);R++){if(y[R]!==-1)throw new Error("Overlapping material groups make the selected face ambiguous.");y[R]=S.materialIndex}}let f=S=>y[S],p=f(t);if(g.length&&p===-1)throw new Error("The selected face has no supported material group.");let v=S=>[S.x,S.y,S.z].map(R=>Math.round(R/d)).join(","),b=(S,R)=>S<R?S+"|"+R:R+"|"+S,x=new Map,_=new Map,T=new i.Vector3,w=new i.Vector3;for(let S=o;S<a;S++){if(f(S)!==p)continue;let R=[c(S*3),c(S*3+1),c(S*3+2)];if(R.some(re=>!Number.isFinite(re.x)||!Number.isFinite(re.y)||!Number.isFinite(re.z)||Math.abs(u.dot(re)-m)>d))continue;let z=T.subVectors(R[1],R[0]).cross(w.subVectors(R[2],R[0]));if(z.lengthSq()<1e-20||z.normalize().dot(u)<.99999)continue;let Y=R.map(v),K=[b(Y[0],Y[1]),b(Y[1],Y[2]),b(Y[2],Y[0])];x.set(S,{points:R,edges:K});for(let re of K){let de=_.get(re)||[];de.push(S),_.set(re,de)}}let A=[t],E=new Set(A),M=new Set,P=new Set;for(let S=0;S<A.length;S++){let R=A[S],z=x.get(R);if(z){M.add(R);for(let Y of z.edges)if(!P.has(Y)){P.add(Y);for(let K of _.get(Y)||[])E.has(K)||(E.add(K),A.push(K))}}}if(!M.size)throw new Error("No connected planar face was found.");let N=new i.Vector3(Math.abs(u.x)<.9?1:0,Math.abs(u.x)<.9?0:1,0);N.addScaledVector(u,-N.dot(u)).normalize();let L=new i.Vector3().crossVectors(u,N).normalize(),D=1/0,$=-1/0,U=1/0,I=-1/0,V=0,W=[];for(let S of M){let R=x.get(S).points;V+=new i.Vector3().subVectors(R[1],R[0]).cross(new i.Vector3().subVectors(R[2],R[0])).length()/2;for(let z of R){let Y=z.dot(N),K=z.dot(L);D=Math.min(D,Y),$=Math.max($,Y),U=Math.min(U,K),I=Math.max(I,K),W.push(z)}}let Q=$-D,se=I-U;if(!(Q>d&&se>d&&V>d*d))throw new Error("The selected face is too small for a display.");let oe=new Float32Array(W.length*3),ge=new Float32Array(W.length*2);W.forEach((S,R)=>{oe.set([S.x,S.y,S.z],R*3),ge.set([(S.dot(N)-D)/Q,(S.dot(L)-U)/se],R*2)});let O=u.clone().multiplyScalar(m).addScaledVector(N,(D+$)/2).addScaledVector(L,(U+I)/2);return{positions:oe,uvs:ge,normal:u,u:N,v:L,center:O,width:Q,height:se,area:V,triangles:M.size,faceIndex:Math.min(...M),faceIndices:[...M]}}function GE(i,{scene:e,objects:t,document:n=globalThis.document,invalidate:r=()=>{},onError:s=()=>{}}){if(!e?.add||typeof t!="function"||!n?.createElement)throw new TypeError("Choose a 3D scene, saved component meshes and document.");let o=new i.Group;o.name="Scripted demo surfaces",e.add(o);let a="demo-face-"+Math.random().toString(36).slice(2)+"-",c=new Map,l=new Map,u=0,h=!1,d=null,m=null,g=0,y=0,f=()=>{if(h)throw new Error("Demo surfaces have been disposed.")};function p(S,R){S.updateWorldMatrix(!0,!1);let z=S.matrixWorld.clone();if(S.isInstancedMesh){if(!Number.isInteger(R)||R<0||R>=S.count)return null;let Y=new i.Matrix4;if(S.getMatrixAt(R,Y),Math.abs(Y.determinant())<1e-15)return null;z.multiply(Y)}return Math.abs(z.determinant())<1e-15?null:z}function v(S,R){return S?.isInstancedMesh?S.userData.records?.[R]:S?.userData.record}function b(S,R,z){if(!t().includes(S)||!Hc(S)||S.isSkinnedMesh)throw new Error("Choose a visible static component face.");let Y=v(S,R),K=p(S,R);if(!VE(Y)||!K)throw new Error("Choose a visible component body, not a pad or board surface.");let re=uI(i,S.geometry,z),de=re.normal.clone().applyMatrix3(new i.Matrix3().getNormalMatrix(K)).normalize(),te=new i.Vector3().applyMatrix4(K),ne=re.u.clone().multiplyScalar(re.width).applyMatrix4(K).sub(te),H=re.v.clone().multiplyScalar(re.height).applyMatrix4(K).sub(te);return{object:S,instanceId:R,record:Y,geometry:S.geometry,patch:re,normal:de,width:ne.length(),height:H.length(),key:S.uuid+":"+R+":"+re.faceIndex}}function x(S){let R=[...c.values()].reduce((Y,K)=>Y+K.patch.triangles,0);for(;c.size>=128||R+S.patch.triangles>1e5;){let Y=[...c].find(([,K])=>![...l.values()].some(re=>re.face===K));if(!Y)throw new Error("Selected demo faces exceed the geometry budget.");R-=Y[1].patch.triangles,c.delete(Y[0])}let z=a+ ++u;return S.token=z,c.set(z,S),_(S)}function _(S){let R=p(S.object,S.instanceId);return R?Object.freeze({token:S.token,shape:"face",uuid:String(S.record.uuid||S.record.id||""),reference:String(S.record.ref||""),center:S.patch.center.clone().applyMatrix4(R).toArray(),normal:S.patch.normal.clone().applyMatrix3(new i.Matrix3().getNormalMatrix(R)).normalize().toArray(),up:S.patch.v.clone().transformDirection(R).toArray(),right:S.patch.u.clone().transformDirection(R).toArray(),width:S.width,height:S.height,triangles:S.patch.triangles}):null}function T(S){if(f(),!S||!Number.isInteger(S.faceIndex))throw new Error("Select a component triangle face.");return x(b(S.object,S.instanceId,S.faceIndex))}function w(S){if(!S||typeof S!="object"||!HE[S.face||"top"])throw new TypeError("Choose a saved component and top/bottom/front/back/left/right face.");let R=S.uuid===void 0?null:jy(S.uuid,"component UUID"),z=S.reference===void 0?null:jy(S.reference,"component reference");if(!R&&!z)throw new TypeError("A demo face needs a component UUID or unique reference.");let Y=[],K=new Set,re=0;for(let de of t()){let te=de.userData.records||[de.userData.record];for(let ne=0;ne<te.length;ne++){if(++re>2e5)throw new Error("Component face lookup exceeds its record budget.");let H=te[ne];if(!VE(H)||R&&R!==(H.uuid||H.id)||z&&z!==H.ref)continue;let _e=de.isInstancedMesh?ne:void 0;if(!Hc(de)||!p(de,_e))continue;let me=String(H.uuid||H.id||"")+"|"+String(H.ref||"")+"|"+JSON.stringify(H.at||[]);K.add(me),Y.push({object:de,instanceId:_e})}}if(K.size!==1)throw new Error("The component anchor is absent or ambiguous.");return Y}function A(S){let R=w(S),z=new i.Vector3(...HE[S.face||"top"]),Y=null,K=25e4;for(let re of R){let de=re.object.geometry,te=de?.getAttribute?.("position"),ne=de?.index;if(!te||re.object.isSkinnedMesh||de.morphAttributes?.position?.length)continue;let H=Math.floor((ne?ne.count:te.count)/3);if(H>5e4)throw new Error("Selected mesh exceeds the 50,000-triangle face-selection budget.");let _e=p(re.object,re.instanceId),me=new i.Matrix3().getNormalMatrix(_e),be=new Set,he=Math.ceil((de.drawRange?.start||0)/3),Ne=Math.min(H,Math.floor(((de.drawRange?.start||0)+(Number.isFinite(de.drawRange?.count)?de.drawRange.count:H*3))/3));for(let Me=he;Me<Ne;Me++){if(be.has(Me))continue;let Z=new i.Vector3().fromBufferAttribute(te,ne?ne.getX(Me*3):Me*3),B=new i.Vector3().fromBufferAttribute(te,ne?ne.getX(Me*3+1):Me*3+1),k=new i.Vector3().fromBufferAttribute(te,ne?ne.getX(Me*3+2):Me*3+2);if(B.sub(Z).cross(k.sub(Z)).normalize().applyMatrix3(me).normalize().dot(z)<.9999)continue;if((K-=H)<0)throw new Error("Automatic face selection exceeds its triangle-work budget. Select an actual face manually.");let G=b(re.object,re.instanceId,Me);for(let fe of G.patch.faceIndices)be.add(fe);let j=p(G.object,G.instanceId),ee=new i.Vector3().applyMatrix4(j),ie=G.patch.u.clone().multiplyScalar(G.patch.width).applyMatrix4(j).sub(ee),ce=G.patch.v.clone().multiplyScalar(G.patch.height).applyMatrix4(j).sub(ee);G.worldArea=G.patch.area*ie.cross(ce).length()/(G.patch.width*G.patch.height),G.depth=G.patch.center.clone().applyMatrix4(j).dot(z),(!Y||G.depth>Y.depth+1e-5||Math.abs(G.depth-Y.depth)<=1e-5&&G.worldArea>Y.worldArea)&&(Y=G)}}if(!Y)throw new Error("This component has no supported planar face in that direction. Select an actual face instead.");return x(Y)}function E(S){let R=S.face||S.anchor&&A(S.anchor),z=typeof R=="string"?R:R?.token,Y=c.get(z);if(!Y)throw new Error("The selected face belongs to another or closed 3D view. Select it again.");if(!t().includes(Y.object)||!Hc(Y.object)||Y.object.geometry!==Y.geometry||!p(Y.object,Y.instanceId))throw new Error("The selected source geometry is no longer available. Select it again.");return Y}function M(S,R,z,Y,K={}){if(typeof d=="function")try{d({id:S.id,type:R,...R==="change"?{value:S.value}:{},...Y?{uv:{x:Y.x,y:Y.y}}:{},source:"pointer",originalEvent:z,...K})}catch(re){d=null;try{s(re)}catch{}}}function P(S){let R=S.width??(S.kind==="led"?32:128),z=S.height??(S.kind==="led"?32:S.kind==="button"?64:128);if(!Number.isInteger(R)||!Number.isInteger(z)||R<1||z<1||R>1024||z>1024)throw new TypeError("Demo canvases need integer dimensions from 1 to 1024.");return{width:R,height:z}}function N(S){if(S.kind==="led"&&!S.canvas){S.material.color.set(S.color).multiplyScalar(S.on?S.brightness:.025);return}let R=S.canvas.getContext("2d");if(!R)throw new Error("Canvas drawing is unavailable.");S.kind!=="display"&&(R.clearRect(0,0,S.canvas.width,S.canvas.height),S.kind==="led"?(R.fillStyle=S.color,R.fillRect(0,0,S.canvas.width,S.canvas.height),S.material.color.setScalar(S.on?S.brightness:.025)):(R.fillStyle=S.pressed?"#77d4df":"#182f3e",R.fillRect(0,0,S.canvas.width,S.canvas.height),R.fillStyle=S.pressed?"#10202c":"#e1eaf3",R.textAlign="center",R.textBaseline="middle",R.font="600 "+Math.max(9,Math.round(S.canvas.height*.22))+"px system-ui",R.fillText(S.kind==="knob"?String(S.value):S.label,S.canvas.width/2,S.canvas.height/2,S.canvas.width-8)),S.texture.needsUpdate=!0)}function L(S){if(S.bindings){let Y=!1;for(let K of S.bindings){let re=p(K.object,K.instanceId);K.mesh.visible=t().includes(K.object)&&K.object.geometry===K.geometry&&Hc(K.object)&&!!re,K.mesh.visible&&(K.mesh.matrix.copy(re),K.mesh.matrixWorldNeedsUpdate=!0,Y=!0)}return Y}let R=S.face,z=p(R.object,R.instanceId);if(S.mesh.visible=t().includes(R.object)&&R.object.geometry===R.geometry&&Hc(R.object)&&!!z,S.mesh.visible){let Y=R.patch.normal.clone().applyMatrix3(new i.Matrix3().getNormalMatrix(z)).normalize(),K=Math.max(1e-5,Math.min(.006,Math.min(R.width,R.height)*.002));S.mesh.matrix.copy(z),S.mesh.matrix.elements[12]+=Y.x*K,S.mesh.matrix.elements[13]+=Y.y*K,S.mesh.matrix.elements[14]+=Y.z*K,S.mesh.matrixWorldNeedsUpdate=!0}return!S.mesh.visible&&m?.entry===S&&se("cancel",null),S.mesh.visible}function D(S){if(!(!l.has(S.id)||l.get(S.id)!==S)&&(m?.entry===S&&se("cancel",null),l.get(S.id)===S)){l.delete(S.id),g-=S.pixels,y-=S.triangles;for(let R of S.meshes||[S.mesh])R.removeFromParent();S.texture?.dispose(),S.material.dispose(),S.bindings||S.mesh.geometry.dispose(),r()}}function $(S){if(typeof S!="string"||S.length>64||!/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(S)&&!Object.hasOwn(i.Color.NAMES,S.toLowerCase()))throw new TypeError("Choose a hex or named LED color.");return"#"+new i.Color(S).getHexString()}function U(S,R={}){let z={on:R.on===void 0?S.on:!!R.on,color:R.color===void 0?S.color:$(R.color),brightness:R.brightness===void 0?S.brightness:R.brightness};if(!Number.isFinite(z.brightness)||z.brightness<0||z.brightness>1)throw new TypeError("Choose LED brightness from 0 to 1.");Object.assign(S,z),N(S),r()}function I(S){let R=new i.Box3;for(let K of S.bindings){let re=p(K.object,K.instanceId);re&&(K.geometry.boundingBox||K.geometry.computeBoundingBox(),R.union(K.geometry.boundingBox.clone().applyMatrix4(re)))}if(R.isEmpty())return null;let z=R.getSize(new i.Vector3),Y=S.bindings[0].record;return{shape:"component",uuid:String(Y.uuid||Y.id||""),reference:String(Y.ref||""),center:R.getCenter(new i.Vector3).toArray(),normal:null,width:z.x,height:z.y,triangles:S.triangles}}function V(S,R){let z=w(R.anchor),Y=l.get(S),K=z.reduce((ne,H)=>{let _e=H.object.geometry;if(H.object.isSkinnedMesh||_e.morphAttributes?.position?.length)throw new Error("LED body binding requires static geometry.");return ne+Math.floor((_e.index?.count||_e.getAttribute("position")?.count||0)/3)},0);if(!K||K>5e4||l.size-(Y?1:0)>=64||y-(Y?.triangles||0)+K>1e5)throw new Error("LED component geometry exceeds the demo surface budget.");let re=$(R.color||"#59f3a5");if(R.brightness!==void 0&&(!Number.isFinite(R.brightness)||R.brightness<0||R.brightness>1))throw new TypeError("Choose LED brightness from 0 to 1.");let de=new i.MeshBasicMaterial({color:16777215,depthTest:!0,depthWrite:!0,toneMapped:!1,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-2}),te={id:S,kind:"led",bindings:z,material:de,pixels:0,triangles:K,on:!1,brightness:1,color:re};for(let ne of z)ne.geometry=ne.object.geometry,ne.record=v(ne.object,ne.instanceId),ne.mesh=new i.Mesh(ne.geometry,de),ne.mesh.matrixAutoUpdate=!1,ne.mesh.userData.demoSurface=S,ne.mesh.renderOrder=10;te.meshes=z.map(ne=>ne.mesh),U(te,R),Y&&D(Y),l.set(S,te),y+=K;for(let ne of te.meshes)o.add(ne);return L(te),r(),{get face(){return I(te)},getFace(){return I(te)},setLED(ne){if(f(),l.get(S)!==te)throw new Error("LED surface is closed.");U(te,ne)},update(){return f(),L(te)},setValue(){throw new Error("An LED uses setLED().")},isAvailable(){return!h&&l.get(S)===te&&L(te)},dispose(){D(te)}}}function W(S,R={}){if(f(),jy(S,"demo surface ID"),!["led","display","button","knob"].includes(R.kind))throw new TypeError("Choose an LED, display, button or knob.");if(R.kind==="led"&&!R.face&&R.anchor&&!R.anchor.face)return V(S,R);let z=E(R),Y=l.get(S),K=P(R),re=K.width*K.height;if(l.size-(Y?1:0)>=64||g-(Y?.pixels||0)+re>4194304||y-(Y?.triangles||0)+z.patch.triangles>1e5)throw new Error("Demo surfaces exceed their canvas or geometry budget.");if([...l.values()].some(k=>k!==Y&&k.face?.key===z.key))throw new Error("This geometry face already has a demo surface.");let de=R.kind==="led"?$(R.color||"#59f3a5"):"#59f3a5";if(R.brightness!==void 0&&(!Number.isFinite(R.brightness)||R.brightness<0||R.brightness>1))throw new TypeError("Choose LED brightness from 0 to 1.");let te=n.createElement("canvas");te.width=K.width,te.height=K.height;let ne=R.kind==="display"?n.createElement("canvas"):te;ne.width=K.width,ne.height=K.height;let H=new i.CanvasTexture(ne);H.colorSpace=i.SRGBColorSpace,H.minFilter=i.LinearFilter,H.magFilter=R.mode==="matrix"?i.NearestFilter:i.LinearFilter,H.generateMipmaps=!1;let _e=new i.BufferGeometry;_e.setAttribute("position",new i.BufferAttribute(z.patch.positions.slice(),3)),_e.setAttribute("uv",new i.BufferAttribute(z.patch.uvs.slice(),2)),_e.computeVertexNormals();let me=new i.MeshBasicMaterial({map:H,color:16777215,side:i.FrontSide,depthTest:!0,depthWrite:!0,toneMapped:!1,polygonOffset:!0,polygonOffsetFactor:-1,polygonOffsetUnits:-2}),be=new i.Mesh(_e,me);be.matrixAutoUpdate=!1,be.userData.demoSurface=S,be.renderOrder=10;let he=R.min??0,Ne=R.max??100,Me=R.step??1;if(![he,Ne,Me].every(Number.isFinite)||Ne<=he||Me<=0)throw H.dispose(),me.dispose(),_e.dispose(),new TypeError("Choose a finite increasing knob range and positive step.");let Z=k=>Math.max(he,Math.min(Ne,he+Math.round((k-he)/Me)*Me)),B={id:S,kind:R.kind,face:z,canvas:te,uploadCanvas:ne,texture:H,material:me,mesh:be,pixels:re,triangles:z.patch.triangles,min:he,max:Ne,step:Me,clamp:Z,value:Z(Number.isFinite(R.value)?R.value:he),pressed:!1,color:de,on:!!R.on,brightness:Number.isFinite(R.brightness)?Math.max(0,Math.min(1,R.brightness)):1,label:typeof R.label=="string"?R.label.slice(0,64):S};try{N(B)}catch(k){throw H.dispose(),me.dispose(),_e.dispose(),k}return Y&&D(Y),l.set(S,B),g+=re,y+=z.patch.triangles,o.add(be),L(B),r(),{canvas:te,get face(){return _(z)},getFace(){return _(z)},update(){if(f(),l.get(S)!==B)throw new Error("Demo surface is closed.");let k=P({width:te.width,height:te.height}),F=k.width*k.height;if(g-B.pixels+F>4194304)throw new Error("Demo surfaces exceed their canvas budget.");if(B.kind==="display"){let G=te.getContext("2d");if(!G)throw new Error("Canvas drawing is unavailable.");try{G.getImageData(0,0,1,1)}catch(ee){let ie=new Error("Display graphics must be CORS-enabled and origin-clean before upload.");throw ie.cause=ee,ie}let j=ne.getContext("2d");if(!j)throw new Error("Canvas upload is unavailable.");ne.width!==te.width&&(ne.width=te.width),ne.height!==te.height&&(ne.height=te.height),j.clearRect(0,0,ne.width,ne.height),j.drawImage(te,0,0)}return g+=F-B.pixels,B.pixels=F,H.needsUpdate=!0,r(),L(B)},setLED(k={}){if(f(),B.kind!=="led"||l.get(S)!==B)throw new Error("Choose an active LED surface.");U(B,k)},setValue(k){if(f(),!Number.isFinite(k)||l.get(S)!==B)throw new TypeError("Choose a finite active control value.");return B.value=B.clamp(k),B.kind==="button"&&(B.pressed=!!B.value),N(B),r(),B.value},isAvailable(){return!h&&l.get(S)===B&&L(B)},dispose(){D(B)}}}function Q(S){let R=S?.object?.userData?.demoSurface&&l.get(S.object.userData.demoSurface);return R&&Hc(S.object)&&(R.mesh===S.object||R.meshes?.includes(S.object))&&L(R)?R:null}function se(S,R){let z=m;return z?(m=null,z.entry.pressed=!1,N(z.entry),r(),M(z.entry,"release",R,z.uv,{cancelled:S==="cancel"}),!0):!1}function oe(S,R,z={}){if(h)return!1;if(R==="release"||R==="cancel")return!m||z.pointerId!==void 0&&z.pointerId!==m.pointerId?!1:se(R,z);if(R==="move"){if(!m||z.pointerId!==void 0&&z.pointerId!==m.pointerId)return!1;let K=m.entry;if(K.kind==="knob"&&Number.isFinite(z.clientY)){let re=K.clamp(m.startValue+(m.startY-z.clientY)*K.step);re!==K.value&&(K.value=re,N(K),r(),M(K,"change",z,S?.uv||m.uv))}return!0}if(R!=="press"||m)return!1;let Y=Q(S);return!Y||Y.kind==="led"?!1:(m={entry:Y,pointerId:z.pointerId,startY:Number.isFinite(z.clientY)?z.clientY:0,startValue:Y.value,uv:S.uv?{x:S.uv.x,y:S.uv.y}:void 0},Y.pressed=!0,N(Y),r(),M(Y,"press",z,m.uv),!0)}function ge(){if(!h)for(let S of l.values())L(S)}function O(){if(!h){se("cancel",null);for(let S of[...l.values()])D(S);h=!0,c.clear(),d=null,o.removeFromParent()}}return{selectFace:T,createSurface:W,setInputHandler(S){if(h&&S===null){d=null;return}if(f(),S!==null&&typeof S!="function")throw new TypeError("Choose an input callback or null.");S===null&&se("cancel",null),d=S},getPickables(){return ge(),[...l.values()].flatMap(S=>S.meshes||[S.mesh]).filter(S=>S.visible)},getFace(S){let R=l.get(S);return R?R.bindings?I(R):_(R.face):null},objects(){return this.getPickables()},isHit(S){return!!Q(S)},pointer:oe,sync:ge,get hasActivePointer(){return!!m},dispose:O}}function WE(i){let e=l=>{let u=i?.[l];if(!Array.isArray(u)||u.length!==3||!u.every(h=>typeof h=="number"&&Number.isFinite(h)&&Math.abs(h)<=1e7))throw new TypeError("Choose finite bounded 3D camera vectors.");return[...u]},t=e("position"),n=e("target"),r=e("up"),s=t.map((l,u)=>l-n[u]),o=Math.hypot(...s),a=Math.hypot(...r),c=[s[1]*r[2]-s[2]*r[1],s[2]*r[0]-s[0]*r[2],s[0]*r[1]-s[1]*r[0]];if(o<1e-4||a<1e-8||Math.hypot(...c)<o*a*1e-6)throw new TypeError("Choose a nondegenerate 3D camera direction and up vector.");return{position:t,target:n,up:r}}function am(i,e,t,n=1.1){if(!(i>0)||!Number.isFinite(i)||!(t>0)||!Number.isFinite(t)||!(e>0&&e<180))return null;let r=e*Math.PI/360,s=Math.atan(Math.tan(r)*t);return i*Math.max(1,n)/Math.sin(Math.min(r,s))}function cm(i,e,t,n,r=.85,s=[0,1,0]){if(!Array.isArray(i)||i.length!==3||i.some(f=>!Number.isFinite(f)||f<0)||!Array.isArray(e)||e.length!==3||e.some(f=>!Number.isFinite(f))||!Array.isArray(s)||s.length!==3||s.some(f=>!Number.isFinite(f))||Math.hypot(...s)<1e-10||!(n>0&&Number.isFinite(n))||!(t>0&&t<180)||!(r>0&&r<1))return null;let o=Math.hypot(...e);if(o<1e-10)return null;let a=e.map(f=>f/o),c=(f,p)=>[f[1]*p[2]-f[2]*p[1],f[2]*p[0]-f[0]*p[2],f[0]*p[1]-f[1]*p[0]],l=(f,p)=>f.reduce((v,b,x)=>v+b*p[x],0),u=c(s,a);Math.hypot(...u)<1e-8&&(u=c(Math.abs(a[2])<.9?[0,0,1]:[0,1,0],a));let h=Math.hypot(...u);u=u.map(f=>f/h);let d=c(a,u),m=Math.tan(t*Math.PI/360)*r,g=m*n,y=.01;for(let f of[-1,1])for(let p of[-1,1])for(let v of[-1,1]){let b=[f*i[0]/2,p*i[1]/2,v*i[2]/2],x=l(b,a);y=Math.max(y,x+Math.abs(l(b,u))/g,x+Math.abs(l(b,d))/m,x+.01)}return y}function XE(i,e,t,n,r){if(!["F.Cu","B.Cu"].includes(t)||![i,e].every(u=>Array.isArray(u)&&u.length===3&&u.every(Number.isFinite))||i.some((u,h)=>u>e[h]))return null;let s=i.map((u,h)=>(u+e[h])/2),o=i.map((u,h)=>Math.max(h===2?1:8,e[h]-u)),a=t==="B.Cu"?-1:1,c=[0,1,0],l=cm(o,[0,0,a],n,r,.55,c);return l===null?null:{target:s,position:[s[0],s[1],s[2]+a*l],up:c}}var Bh=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i,hI=i=>Array.isArray(i)?Bh(i[0]):void 0,Ky=(i,e)=>(Array.isArray(i)?i:[]).filter(t=>hI(t)===e),qy=(i,e)=>Ky(i,e)[0],Gc=i=>Number.isFinite(i)&&i>0;function YE(i={},e=[],t=1.6){let n=[],r=new Map,s=0,o=w=>{n.length<64?n.push(w):s++},a=[...new Set((i.layers||[]).filter(w=>typeof w=="string"&&/^(?:F|B|In[1-9]\d*)\.Cu$/.test(w)))],c=a.slice(0,64);a.length>64&&o("Copper layer display is limited to 64 layers; additional source layers are omitted.");let l=new Set(c),u=Array.isArray(i.stackup)?i.stackup:[],h=Gc(t)?t:1.6;Gc(t)||o("Board thickness is unavailable; copper elevation uses an estimated 1.6 mm board depth.");let d=u.filter(w=>l.has(w.name)),m=new Map(d.filter(w=>Gc(w.thickness)).map(w=>[w.name,w.thickness])),g=c.filter(w=>!m.has(w));g.length&&o(`Saved copper thickness is unavailable for ${g.join(", ")}; 0.035 mm is used for display only.`);let y=w=>/^dielectric\b/i.test(w.name||"")||/^(core|prepreg|dielectric)$/i.test(w.type||""),f=c.length>0&&d.length===c.length&&d.every((w,A)=>w.name===c[A]&&Gc(w.thickness))&&u.every(w=>!(l.has(w.name)||y(w))||Gc(w.thickness)),p;if(f){let w=0,A=new Map;for(let E of u){let M=Gc(E.thickness)?E.thickness:0;l.has(E.name)&&A.set(E.name,h/2-w-M/2),w+=M}Math.abs(w-h)>Math.max(1e-6,h*1e-6)?o("Saved stackup thickness differs from board depth; copper elevations are estimated uniformly."):p=c.map(E=>({name:E,z:A.get(E),thickness:m.get(E)}))}let v=!!p;if(!p){f||o("Complete saved stackup depths are unavailable; copper elevations are estimated uniformly across the board.");let w=m.get(c[0])||.035,A=m.get(c.at(-1))||.035;p=c.map((E,M)=>({name:E,thickness:m.get(E)||.035,z:c.length<2?0:h/2-w/2-M/(c.length-1)*(h-(w+A)/2)}))}let b=new Map(p.map(w=>[w.name,w])),x=new Map,_=new Set,T=0;for(let w of Ky(e,"via")){if((qy(w,"at")?.length||0)<3)continue;T++;let A=String(Bh(qy(w,"uuid")?.[1])||Bh(qy(w,"tstamp")?.[1])||`via-${T}`);x.has(A)&&_.add(A),x.set(A,w)}for(let w of i.vias||[]){let A=x.get(w.id),E=Ky(A,"layers"),M=E.length===1?E[0].slice(1).map(Bh):[],P=oe=>o(`Via ${w.id}: ${oe}; span omitted.`);if(!A||_.has(w.id)||M.length!==2||M.some(oe=>typeof oe!="string"||!b.has(oe))||M[0]===M[1]){P("saved copper endpoint pair is absent, ambiguous or unknown");continue}let N=A.slice(1).filter(oe=>!Array.isArray(oe)).map(Bh),L=N.filter(oe=>["through","blind","buried","micro"].includes(oe));if(L.length>1||N.some(oe=>!["through","blind","buried","micro","locked"].includes(oe))){P("saved via type is ambiguous or unsupported");continue}let D=M.map(oe=>c.indexOf(oe)).sort((oe,ge)=>oe-ge),$=c[D[0]],U=c[D[1]],I=$==="F.Cu"&&U==="B.Cu",V=L[0]||"through",W=[$,U].filter(oe=>oe==="F.Cu"||oe==="B.Cu").length;if(V==="through"&&!I||V!=="through"&&I||V==="micro"&&D[1]-D[0]!==1||V==="buried"&&W!==0){P("saved via type does not agree with its layer endpoints");continue}let Q=b.get($),se=b.get(U);r.set(w.id,{zMin:Math.min(Q.z,se.z),zMax:Math.max(Q.z,se.z),from:$,to:U,through:I,type:V==="blind"&&W===0?"buried":V})}return s&&n.push(`${s} additional saved-geometry diagnostics omitted.`),{layers:p,byLayer:b,viaSpans:r,warnings:n,savedDepths:v}}var zh=i=>typeof i=="number"&&Number.isFinite(i)&&Math.abs(i)<=1e4,fr=(i,e)=>Math.abs(i-e)<=1e-9;function jE(i){let e=i.customPrimitives;if(i.customAnchor!=="rect"||!Array.isArray(e)||e.length!==3||!zh(i.width)||!zh(i.height)||i.width<=0||i.height<=0)return null;let t=e.filter(f=>f?.shape==="circle"),n=e.filter(f=>f?.shape==="polygon");if(t.length!==2||n.length!==1)return null;let r=i.width/2,s=i.height/2;for(let f of t)if(!Array.isArray(f.center)||f.center.length!==2||!f.center.every(zh)||!zh(f.radius)||!fr(f.radius,r)||!fr(f.center[0],0))return null;if(!(fr(t[0].center[1],s)&&fr(t[1].center[1],-s)||fr(t[1].center[1],s)&&fr(t[0].center[1],-s)))return null;let o=n[0].points;if(!Array.isArray(o)||o.length<4||o.length>5||!o.every(f=>Array.isArray(f)&&f.length===2&&f.every(zh)))return null;if(o.length===5){if(!o[0].every((f,p)=>fr(f,o[4][p])))return null;o=o.slice(0,4)}let a=o.some(f=>fr(f[0],r))?1:o.some(f=>fr(f[0],-r))?-1:0;if(!a)return null;let c=[[0,-s-r],[a*r,-s-r],[a*r,s+r],[0,s+r]],l=new Set;for(let f of o){let p=c.findIndex(v=>v.every((b,x)=>fr(b,f[x])));if(p<0||l.has(p))return null;l.add(p)}let u=o.map(f=>c.findIndex(p=>p.every((v,b)=>fr(v,f[b]))));if(!u.every((f,p)=>(u[(p+1)%4]-f+4)%4===(u[1]-u[0]+4)%4)||![1,3].includes((u[1]-u[0]+4)%4))return null;let h=Math.ceil(Math.PI/Math.acos(Math.max(-1,1-.0025/r))),d=Math.min(128,Math.max(64,Math.ceil(h/4)*4)),m=d/4,g=[];for(let f=0;f<=m;f++){let p=Math.PI/2+f*Math.PI/2/m;g.push([r*Math.cos(p),s+r*Math.sin(p)])}for(let f=0;f<=m;f++){let p=Math.PI+f*Math.PI/2/m;g.push([r*Math.cos(p),-s+r*Math.sin(p)])}if(g.push([r,-s-r],[r,s+r]),a<0){for(let f of g)f[0]=-f[0];g.reverse()}g.push([...g[0]]);let y=r*(1-Math.cos(Math.PI/d));return{outline:g,tessellation:{error:y,limited:y>.0025*(1+1e-10),tolerance:.0025}}}var ZE=1e4,qE=16,um=1e-10,KE=i=>typeof i=="number"&&Number.isFinite(i)&&i>0&&i<=ZE,hm=i=>typeof i=="number"&&Number.isFinite(i)&&Math.abs(i)<=ZE;function dI(i){let e=[];for(let t of i){let n=e.at(-1);(!n||Math.hypot(t[0]-n[0],t[1]-n[1])>um)&&e.push(t)}return e.length>1&&Math.hypot(e[0][0]-e.at(-1)[0],e[0][1]-e.at(-1)[1])<=um&&e.pop(),e.push([...e[0]]),e}function lm(i,e,t){let n=i/2,r=e/2;if(t===0)return[[-n,-r],[n,-r],[n,r],[-n,r],[-n,-r]];let s=[],o=[[n-t,-r+t],[n-t,r-t],[-n+t,r-t],[-n+t,-r+t]];for(let a=0;a<4;a++)for(let c=0;c<=qE;c++){let l=(-.5+a*.5+c*.5/qE)*Math.PI;s.push([o[a][0]+t*Math.cos(l),o[a][1]+t*Math.sin(l)])}return dI(s)}function Zy(i,e,t,n){return!KE(e)||!KE(t)?null:i==="rect"?lm(e,t,0):i==="oval"?lm(e,t,Math.min(e,t)/2):i==="circle"?Math.abs(e-t)<=um*Math.max(1,e,t)?lm(e,t,e/2):null:i==="roundrect"&&typeof n=="number"&&Number.isFinite(n)&&n>=0&&n<=.5?lm(e,t,Math.min(e,t)*n):null}function dm(i){if(!i||typeof i!="object"||!["circle","oval"].includes(i.drillShape))return null;let e=i.drillWidth??i.drill,t=i.drillHeight??(i.drillShape==="circle"?e:void 0),n=Zy(i.drillShape,e,t);if(!n)return null;let r=i.drillOffset??[0,0];if(!Array.isArray(r)||r.length!==2||!r.every(hm))return null;let s=n.map(([o,a])=>[o+r[0],a+r[1]]).reverse();return s.every(o=>o.every(hm))?s:null}function JE(i){if(!i||typeof i!="object")return null;let e=i.shape,t=e==="custom"?jE(i):null,n=t?.outline||Zy(e,i.width,i.height,i.roundrectRatio??i.roundrect_rratio);if(!n)return null;let r=null;return(i.drill!==void 0&&i.drill!==0||i.drillWidth!==void 0||i.drillHeight!==void 0)&&(r=dm(i),!r||!r.every(o=>QE(n,o)))?null:{shape:e,outline:n,drill:r,...t?{tessellation:t.tessellation}:{}}}function QE(i,[e,t],n=!1){let r=!1;for(let s=0,o=i.length-2;s<i.length-1;o=s++){let[a,c]=i[o],[l,u]=i[s],h=l-a,d=u-c,m=((e-a)*h+(t-c)*d)/(h*h+d*d),g=Math.max(0,Math.min(1,m));if(Math.hypot(e-(a+g*h),t-(c+g*d))<=um)return n;c>t!=u>t&&e<(l-a)*(t-c)/(u-c)+a&&(r=!r)}return r}function $E(i){if(i?.padType!=="np_thru_hole")return!1;let e=Zy(i.shape,i.width,i.height,i.roundrectRatio??i.roundrect_rratio),t=dm(i);return!!(e&&t&&e.every(n=>QE(t,n,!0)))}var bn=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i,zi=(i,e)=>i.find(t=>Array.isArray(t)&&bn(t[0])===e);function fI(i){let e=zi(i,"primitives");if(!e||e.length>17)return null;let t=[],n=(r,s)=>{let o=zi(r,s)?.slice(1).map(bn);return o?.length===2&&o.every(hm)?o:null};for(let r of e.slice(1)){if(!Array.isArray(r)||bn(zi(r,"fill")?.[1])!=="yes"||bn(zi(r,"width")?.[1])!==0)return null;if(bn(r[0])==="gr_circle"){let s=n(r,"center"),o=n(r,"end");if(!s||!o)return null;t.push({shape:"circle",center:s,radius:Math.hypot(o[0]-s[0],o[1]-s[1])})}else if(bn(r[0])==="gr_poly"){let s=zi(r,"pts");if(!s||s.length<4||s.length>17)return null;let o=[];for(let a of s.slice(1)){if(!Array.isArray(a)||bn(a[0])!=="xy")return null;let c=a.slice(1).map(bn);if(c.length!==2||!c.every(hm))return null;o.push(c)}t.push({shape:"polygon",points:o})}else return null}return t}function eM(i){let e=new Map,t=new Set,n=0;if(!Array.isArray(i)||bn(i[0])!=="kicad_pcb"||i.length>1e6)return e;let r=-1;for(let s of i){if(!Array.isArray(s)||!["footprint","module"].includes(bn(s[0]))||(r++,s.length>1e6))continue;let o=s.find(c=>Array.isArray(c)&&bn(c[0])==="property"&&bn(c[1])==="Reference")?.[2],a=-1;for(let c of s){if(!Array.isArray(c)||bn(c[0])!=="pad"||(a++,c.length>1e4))continue;if(++n>2e5)return e;let l=rm(c,bn(o),r,a);if(typeof l!="string"||!l||l.length>128)continue;if(t.has(l)){e.delete(l);continue}t.add(l);let u=zi(c,"roundrect_rratio")?.[1],h=zi(c,"drill"),d={type:"Pad",padType:String(bn(c[2])||""),uuid:l,ownerUuid:bn(zi(s,"uuid")?.[1]??zi(s,"tstamp")?.[1]),pinNumber:String(bn(c[1])??""),pinName:String(bn(zi(c,"pinfunction")?.[1])??"")};if(typeof u=="number"&&(d.roundrectRatio=u),bn(c[3])==="custom"&&(d.customAnchor=bn(zi(zi(c,"options")||[],"anchor")?.[1]),d.customPrimitives=fI(c)),h){let m=bn(h[1])==="oval";d.drillShape=m?"oval":"circle",d.drillWidth=h[m?2:1],d.drillHeight=m?h[3]:d.drillWidth;let g=zi(h,"offset");g&&(d.drillOffset=[g[1],g[2]])}if(e.set(l,d),e.size>=2e5)return e}}return e}var Wc=Math.PI*2,Qy=1e-9,Hh=.0025,Tn=i=>typeof i=="number"&&Number.isFinite(i);function fm(i,{tolerance:e=Hh,min:t=24,max:n=128}={}){if(!Tn(i)||i<=0||!Tn(e)||e<=0||!Number.isInteger(t)||!Number.isInteger(n)||t<4||n<t||n>4096)throw Error("Invalid circular tessellation parameters.");let r=2*Math.acos(Math.max(-1,Math.min(1,1-e/i))),s=r>0?Math.ceil(Wc/r):n,o=Math.min(n,Math.max(t,Math.ceil(s/4)*4)),a=i*(1-Math.cos(Math.PI/o));return{segments:o,error:a,limited:a>e*(1+1e-10),tolerance:e}}function tM(i,e,{world:t,z:n,thickness:r}){if(!Array.isArray(e)||typeof t!="function"||!Tn(n)||!Tn(r)||r<=0)throw Error("Invalid copper stroke batch parameters.");let s=e.filter(y=>Tn(y.width)&&y.width>0&&Array.isArray(y.start)&&Array.isArray(y.end)&&y.start.length===2&&y.end.length===2&&[...y.start,...y.end].every(Tn)),o=e.length-s.length;if(!s.length)return{batches:[],tracks:s,invalid:o,plan:null,triangles:0};let a=[12,16,24,32,48,64,96,128],c=new Map,l=new Map,u=[],h=0,d=!1;for(let y of s){let f=l.get(y.width);if(!f){let v=fm(y.width/2,{min:12});f=a.find(b=>b>=v.segments)||128,l.set(y.width,f)}let p=y.width/2*(1-Math.cos(Math.PI/f));h=Math.max(h,p),d||=p>Hh*(1+1e-10),c.has(f)||c.set(f,[]),c.get(f).push(y)}let m=s.filter(y=>Math.hypot(y.end[0]-y.start[0],y.end[1]-y.start[1])>1e-12);m.length&&u.push({part:"core",records:m,geometry:new i.BoxGeometry(1,1,1),place(y,f){let p=t(f.start),v=t(f.end);y.position.set((p[0]+v[0])/2,(p[1]+v[1])/2,n),y.rotation.set(0,0,Math.atan2(v[1]-p[1],v[0]-p[0])),y.scale.set(Math.hypot(v[0]-p[0],v[1]-p[1]),f.width,r)}});for(let[y,f]of[...c].sort((p,v)=>p[0]-v[0])){let p=new i.CylinderGeometry(1,1,1,y/2,1,!1,0,Math.PI);p.rotateX(Math.PI/2);for(let v of["start","end"])u.push({part:v+"-"+y,records:f,geometry:p,place(b,x){let[_,T]=t(x[v]),w=t(x.start),A=t(x.end);b.position.set(_,T,n),b.rotation.set(0,0,Math.atan2(A[1]-w[1],A[0]-w[0])+(v==="start"?Math.PI:0)),b.scale.set(x.width/2,x.width/2,r)}})}let g={segments:Math.max(...c.keys()),error:h,limited:d,tolerance:Hh};return{batches:u,tracks:s,invalid:o,plan:g,triangles:u.reduce((y,f)=>y+(f.geometry.index?.count||f.geometry.getAttribute("position").count)/3*f.records.length,0)}}function pI(i,e,t){if(!t)return[[-i/2,-e/2],[i/2,-e/2],[i/2,e/2],[-i/2,e/2],[-i/2,-e/2]];let n=fm(t,{min:64}),r=n.segments/4,s=[],o=i/2,a=e/2,c=[[o-t,-a+t],[o-t,a-t],[-o+t,a-t],[-o+t,-a+t]];for(let l=0;l<4;l++)for(let u=0;u<=r;u++){let h=(-.5+l*.5+u*.5/r)*Math.PI,d=[c[l][0]+t*Math.cos(h),c[l][1]+t*Math.sin(h)],m=s.at(-1);(!m||Math.hypot(d[0]-m[0],d[1]-m[1])>Qy)&&s.push(d)}return Math.hypot(s[0][0]-s.at(-1)[0],s[0][1]-s.at(-1)[1])<Qy&&s.pop(),s.push([...s[0]]),s}function nM(i,e,t,n){return pI(e,t,i==="rect"?0:i==="roundrect"?Math.min(e,t)*n:Math.min(e,t)/2)}function pm(i){if(!dm(i))return null;let e=i.drillWidth??i.drill,t=i.drillHeight??(i.drillShape==="circle"?e:void 0),n=i.drillOffset||[0,0];return nM(i.drillShape,e,t,0).map(([r,s])=>[r+n[0],s+n[1]]).reverse()}function mI(i,e){let t=0;for(let n=0;n<i.length-1;n++){let r=i[n],s=i[n+1],o=(s[0]-r[0])*(e[1]-r[1])-(s[1]-r[1])*(e[0]-r[0]);if(Math.abs(o)<1e-12)return!1;let a=Math.sign(o);if(t&&a!==t)return!1;t=a}return!0}function $y(i){let e=JE(i);if(!e)return null;if(i.shape==="custom"){let a=e.drill?Math.min(i.drillWidth??i.drill,i.drillHeight??i.drill)/2:0,c=Math.max(e.tessellation.error,a*(1-Math.cos(Math.PI/64)));return{...e,tessellation:{...e.tessellation,error:c,limited:c>Hh*(1+1e-10)}}}let t=i.roundrectRatio??i.roundrect_rratio,n=nM(i.shape,i.width,i.height,t),r=i.drill||i.drillWidth||i.drillHeight?pm(i):null,s=[i.shape==="rect"?0:i.shape==="roundrect"?Math.min(i.width,i.height)*t:Math.min(i.width,i.height)/2,r?Math.min(i.drillWidth??i.drill,i.drillHeight??i.drill)/2:0].filter(a=>a>0),o=s.map(a=>fm(a,{min:64}));return r&&r.some(a=>!mI(n,a))?{...e,tessellation:{error:Math.max(0,...s.map(a=>a*(1-Math.cos(Math.PI/64)))),limited:!0,reason:"Refined hole containment requires retaining the validated contour resolution."}}:{shape:i.shape,outline:n,drill:r,tessellation:{error:Math.max(0,...o.map(a=>a.error)),limited:o.some(a=>a.limited)}}}function iM(i,e,t){if(!Array.isArray(e)||e.length<4||!e.every(a=>Array.isArray(a)&&a.length===2&&a.every(Tn))||!Tn(t)||t<=0||Math.hypot(e[0][0]-e.at(-1)[0],e[0][1]-e.at(-1)[1])>Qy)throw Error("Invalid saved drill wall.");let n=e.length-1,r=[],s=[];for(let a=0;a<n;a++){let[c,l]=e[a];r.push(c,-l,0,c,-l,t);let u=(a+1)%n;s.push(a*2,u*2,a*2+1,u*2,u*2+1,a*2+1)}let o=new i.BufferGeometry;return o.setAttribute("position",new i.Float32BufferAttribute(r,3)),o.setIndex(s),o.computeVertexNormals(),o}function rM(i,e,t=.035,n){if(!["F.Cu","B.Cu"].includes(i)||!Tn(e)||e<=0||!Tn(t)||t<=0||n!==void 0&&!Tn(n))throw Error("Invalid outer copper placement.");let r=i==="F.Cu"?1:-1,s=.001,o=n??r*(e/2-t/2),a=o+r*s;return{center:a,sourceCenter:o,base:a-t/2,thickness:t,displayOffset:s}}function sM(i,e){if(!["F.Cu","B.Cu"].includes(i)||!Tn(e?.base)||!Tn(e?.thickness)||e.thickness<=0)throw Error("Invalid zone display placement.");let t=Math.min(.005,e.thickness/4);return i==="F.Cu"?e.base+e.thickness-t:e.base+t}function oM(i,e){if(!Tn(i)||i<=0||!e?.get)throw Error("Invalid substrate depth plan.");let t=e.get("F.Cu"),n=e.get("B.Cu"),r=a=>a&&Tn(a.z)&&Tn(a.thickness)&&a.thickness>0,s=r(t)?t.z-t.thickness/2:i/2,o=r(n)?n.z+n.thickness/2:-i/2;if(!Tn(s-o)||s<=o)throw Error("Outer copper inner faces do not enclose a valid substrate.");return{top:s,bottom:o,depth:s-o,missingOuterDepths:!r(t)||!r(n)}}var ua=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i,Vh=(i,e)=>i.find(t=>Array.isArray(t)&&ua(t[0])===e),Jy=(i,e)=>{let t=Vh(i,e),n=t?.slice(1,3).map(ua);return n?.length===2&&n.every(Tn)?n:null};function gI(i,e,t){let n=e[0]-i[0],r=e[1]-i[1],s=t[0]-i[0],o=t[1]-i[1],a=2*(n*o-r*s);if(Math.abs(a)<1e-12)return null;let c=n*n+r*r,l=s*s+o*o,u=[i[0]+(c*o-l*r)/a,i[1]+(l*n-c*s)/a],h=Math.atan2(i[1]-u[1],i[0]-u[0]),d=f=>(f%Wc+Wc)%Wc,m=d(Math.atan2(t[1]-u[1],t[0]-u[0])-h),g=d(Math.atan2(e[1]-u[1],e[0]-u[0])-h),y=Math.hypot(i[0]-u[0],i[1]-u[1]);return u.every(Tn)&&Tn(y)?{center:u,radius:y,start:h,sweep:g<=m?m:m-Wc}:null}function aM(i,e,{maxSegments:t=2e5}={}){if(!Array.isArray(i)||!Array.isArray(e)||!Number.isInteger(t)||t<1||t>1e6)throw Error("Invalid saved track refinement input.");let n=[],r=new Map,s=new Map,o=new Set,a=Math.max(0,t-i.length);for(let h of i){let d=String(h.id||"").replace(/:\d+$/,"");r.has(d)||r.set(d,[]),r.get(d).push(h)}let c=(h,d)=>h&&d&&Math.hypot(h[0]-d[0],h[1]-d[1])<1e-6;for(let h of e){if(!Array.isArray(h)||ua(h[0])!=="arc")continue;let d=Jy(h,"start"),m=Jy(h,"mid"),g=Jy(h,"end"),y=ua(Vh(h,"uuid")?.[1])??ua(Vh(h,"tstamp")?.[1]),f=ua(Vh(h,"layer")?.[1]),p=ua(Vh(h,"width")?.[1]);if(!d||!m||!g)continue;let v=typeof y=="string"&&r.has(y)?[[y,r.get(y)]]:[...r].filter(([,M])=>M[0].layer===f&&M[0].width===p&&c(M[0].start,d)&&c(M.at(-1).end,g));if(v.length!==1){n.push("A saved copper arc could not be matched unambiguously; existing parsed segments are retained.");continue}let[b,x]=v[0];if(o.has(b)){s.delete(b),n.push("Duplicate saved copper arc identity retained without refinement.");continue}o.add(b);let _=gI(d,m,g);if(!_){n.push("Degenerate saved copper arc retained without refinement.");continue}let T=fm(_.radius,{min:24,max:4096}),w=Math.max(x.length,2,Math.ceil(T.segments*Math.abs(_.sweep)/Wc)),A=Math.max(0,w-x.length);if(T.limited||A>a){n.push("Saved copper arc refinement reached its geometric error or segment budget; parsed segments are retained.");continue}a-=A;let E=Array.from({length:w+1},(M,P)=>{let N=_.start+_.sweep*P/w;return[_.center[0]+_.radius*Math.cos(N),_.center[1]+_.radius*Math.sin(N)]});E[0]=d,E[w]=g,s.set(b,Array.from({length:w},(M,P)=>({...x[Math.min(x.length-1,Math.floor(P*x.length/w))],...typeof y=="string"?{uuid:y}:{},start:E[P],end:E[P+1]})))}let l=[],u=new Set;for(let h of i){let d=String(h.id||"").replace(/:\d+$/,"");s.has(d)?u.has(d)||(l.push(...s.get(d)),u.add(d)):l.push(h)}return{tracks:l,warnings:[...new Set(n)],tolerance:Hh}}var cM=i=>encodeURIComponent(i?.trim()||"global");function ha(i,e,t){return`spike:${i}:${cM(e)}:${cM(t)}`}function ex(i){let e=new Map;return i.forEach((t,n)=>{let r=t?.ref;typeof r!="string"||!r||e.set(r,e.has(r)?null:n)}),e}function lM(i,e){let t=i.map(()=>!0),n=ex(i);if(!Array.isArray(e))return t;let r=new Map;for(let s of e)typeof s?.reference!="string"||!s.reference||typeof s.populated!="boolean"||r.set(s.reference,r.has(s.reference)?null:s.populated);for(let[s,o]of r){let a=n.get(s);a!=null&&o!=null&&(t[a]=o)}return t}function hM(i){let e=new Map,t=new Map,n=new Map;for(let r of i.components)t.set(r.ref,(t.get(r.ref)||0)+1);for(let r of[...i.drawings,...i.pads])r.ref&&(e.has(r.ref)||e.set(r.ref,[]),e.get(r.ref).push(r));for(let r of i.components){if(t.get(r.ref)!==1)continue;let s=e.get(r.ref)||[],o=r.layer?.startsWith("B.")?"B":"F",a=[],c=null;for(let _ of[o+".Fab",o+".CrtYd"]){let T=s.filter(w=>w.layer===_&&w.points).map(w=>w.points);if(a=T.flat(),c=yI(T),a.length)break}if(!a.length)for(let _ of s.filter(T=>T.at&&T.width>0&&T.height>0)){let T=-(_.rotation||0)*Math.PI/180,w=Math.cos(T),A=Math.sin(T);for(let E of[-_.width/2,_.width/2])for(let M of[-_.height/2,_.height/2])a.push([_.at[0]+E*w-M*A,_.at[1]+E*A+M*w])}let l=(r.rotation||0)*Math.PI/180,u=Math.cos(l),h=Math.sin(l),d=a.filter(_=>_?.length>=2&&_.every(Number.isFinite)).map(([_,T])=>(_-=r.at[0],T-=r.at[1],[_*u-T*h,_*h+T*u]));if(!d.length)continue;let m=1/0,g=1/0,y=-1/0,f=-1/0;for(let[_,T]of d)m=Math.min(m,_),g=Math.min(g,T),y=Math.max(y,_),f=Math.max(f,T);let p=y-m,v=f-g;if(!(p>1e-6&&v>1e-6))continue;let b=(m+y)/2,x=(g+f)/2;if(c){let _=c.map(([A,E])=>(A-=r.at[0],E-=r.at[1],[A*u-E*h,A*h+E*u]));if(!uM([b,x],_))continue;let T=0,w=1;for(let A=0;A<30;A++){let E=(T+w)/2,M=[[-1,-1],[1,-1],[1,1],[-1,1]].map(([N,L])=>[b+N*p*E/2,x+L*v*E/2]);M.every(N=>uM(N,_))&&!M.some((N,L)=>_.some((D,$)=>xI(N,M[(L+1)%4],D,_[($+1)%_.length])))?T=E:w=E}if(p*=T,v*=T,!(p>1e-6&&v>1e-6))continue}n.set(r,{at:[r.at[0]+b*u+x*h,r.at[1]-b*h+x*u],width:p,height:v,rotation:l})}return n}var Gh=(i,e)=>Math.hypot(i[0]-e[0],i[1]-e[1])<1e-5;function yI(i){if(i.length>512)return[];let e=i.filter(n=>n.length>1).map(n=>[...n]),t=[];for(;e.length;){let n=e.shift();for(;!Gh(n[0],n.at(-1));){let r=e.findIndex(o=>Gh(n.at(-1),o[0])||Gh(n.at(-1),o.at(-1)));if(r<0)break;let s=e.splice(r,1)[0];Gh(n.at(-1),s[0])||s.reverse(),n.push(...s.slice(1))}n.length>3&&Gh(n[0],n.at(-1))&&t.push(n.slice(0,-1))}return t.length===1?t[0]:t.length?[]:null}function uM(i,e){let t=!1;for(let n=0,r=e.length-1;n<e.length;r=n++){let s=e[n],o=e[r];s[1]>i[1]!=o[1]>i[1]&&i[0]<(o[0]-s[0])*(i[1]-s[1])/(o[1]-s[1])+s[0]&&(t=!t)}return t}function xI(i,e,t,n){let r=(s,o,a)=>(o[0]-s[0])*(a[1]-s[1])-(o[1]-s[1])*(a[0]-s[0]);return r(i,e,t)*r(i,e,n)<-1e-12&&r(t,n,i)*r(t,n,e)<-1e-12}function dM(i,{objects:e,camera:t,rect:n,positionToWorld:r}){let s=o=>o?.type==="Component"||typeof o?.library=="string";return function(a){if(!a||typeof a!="object")return null;let c=n();if(!(c.width>0&&c.height>0))return null;let l=y=>(y.project(t),![y.x,y.y,y.z].every(Number.isFinite)||Math.abs(y.x)>1||Math.abs(y.y)>1||y.z<-1||y.z>1?null:{x:c.left+(y.x+1)*c.width/2,y:c.top+(1-y.y)*c.height/2,visible:!0});if(a.position){let{x:y,y:f}=a.position;return![y,f].every(p=>typeof p=="number"&&Number.isFinite(p)&&Math.abs(p)<=1e6)||!["front","back",void 0].includes(a.side)?null:l(r({x:y,y:f},a.side))}let u=y=>typeof y=="string"&&y.length>0&&y.length<=500&&!/[\x00-\x1f\x7f]/.test(y);if(!["uuid","reference","pinNumber","net"].some(y=>u(a[y]))||["uuid","reference","pinNumber","net"].some(y=>a[y]!==void 0&&!u(a[y]))||a.pinNumber&&!a.uuid&&!a.reference)return null;let h=new Map,d=new i.Matrix4,m=new i.Matrix4;for(let y of e()){let f=!0;for(let v=y;v;v=v.parent)v.visible||(f=!1);if(!f)continue;let p=y.userData.records||[y.userData.record];for(let v=0;v<p.length;v++){let b=p[v];if(!b)continue;let x=b.uuid||b.id;if(a.uuid&&a.uuid!==x&&!(a.pinNumber&&a.uuid===b.ownerUuid)&&!(typeof x=="string"&&x.replace(/:\d+$/,"")===a.uuid)||a.reference&&b.ref!==a.reference||a.pinNumber&&String(b.pinNumber??b.name??"")!==a.pinNumber||a.net&&b.net!==a.net||a.reference&&!a.uuid&&!a.pinNumber&&!a.net&&!s(b)||(y.updateWorldMatrix(!0,!1),y.geometry?.boundingBox||y.geometry?.computeBoundingBox(),!y.geometry?.boundingBox))continue;let _=y.geometry.boundingBox.clone();if(y.isInstancedMesh){if(y.getMatrixAt(v,m),m.determinant()===0)continue;d.multiplyMatrices(y.matrixWorld,m),_.applyMatrix4(d)}else _.applyMatrix4(y.matrixWorld);if(_.isEmpty())continue;let T=x||b.ref;T&&(h.has(T)?h.get(T).union(_):h.set(T,_))}}if(!a.net&&h.size!==1)return null;let g=[...h.values()].map(y=>l(y.getCenter(new i.Vector3))).filter(Boolean);return g.sort((y,f)=>Math.hypot(y.x-c.left-c.width/2,y.y-c.top-c.height/2)-Math.hypot(f.x-c.left-c.width/2,f.y-c.top-c.height/2)),g[0]||null}}function mm(i={}){if(!i||typeof i!="object"||Array.isArray(i))throw new TypeError("Selection style must be an object.");let{mode:e="dim",color:t="accent"}=i;if(!["dim","bright","isolate"].includes(e))throw new TypeError("Choose dim, bright or isolate selection mode.");if(!["accent","source"].includes(t))throw new TypeError("Choose accent or source selection color.");return{mode:e,color:t}}function fM(i,e){let t=new Map,n=new Map,r=new Map,s=new Map,o={owned:[]},a="",c=v=>Array.isArray(v)?v:[v];function l(){for(let[v,b]of t){v.material=b.material,v.isInstancedMesh&&(v.instanceColor!==b.instanceColor&&v.dispose?.(),v.instanceColor=b.instanceColor,v.customDepthMaterial=b.depth,v.customDistanceMaterial=b.distance);for(let x of b.owned)x.dispose()}for(let v of o.owned)v.dispose();o.owned.length=0,n.clear(),r.clear(),s.clear(),t.clear(),a=""}function u(v){if(t.has(v))return t.get(v);let b={material:v.material,instanceColor:v.instanceColor,depth:v.customDepthMaterial,distance:v.customDistanceMaterial,owned:[]};return t.set(v,b),b}function h(v,b){let x=v.clone();return x.onBeforeCompile=v.onBeforeCompile,x.customProgramCacheKey=()=>v.customProgramCacheKey(),b.owned.push(x),x}function d(v,b,x){if(v.has(b))return v.get(b);let _=h(b,o);return x(_),v.set(b,_),_}function m(v,b,x=!1){if(x&&n.has(v))return n.get(v);let _=h(v,x?o:b),T=v.onBeforeCompile;return _.userData??={},_.userData.selectionOpacityCap=.24,_.opacity=Math.min(v.opacity??1,.24),_.transparent=!0,_.depthWrite=!1,_.onBeforeCompile=(w,A)=>{T?.call(_,w,A),w.fragmentShader=w.fragmentShader.replace("#include <opaque_fragment>",`outgoingLight = vec3(dot(outgoingLight, vec3(0.2126, 0.7152, 0.0722))) * 0.24;
#include <opaque_fragment>`)},_.customProgramCacheKey=()=>v.customProgramCacheKey()+":selection-grey",x&&n.set(v,_),_}function g(v){return v.accent||(v.accent=c(v.material).map(b=>d(s,b,x=>{x.color?.setHex(6547182),x.emissive?.setHex(1201756),x.metalness=0,x.roughness=.55}))),Array.isArray(v.material)?v.accent:v.accent[0]}function y(v,b,x=!1,_=!1){let T=v.onBeforeCompile,w=v.customProgramCacheKey(),A=x?v:h(v,b);return x&&b.owned.push(A),_&&(A.transparent=!0,A.depthWrite=!1),A.onBeforeCompile=(E,M)=>{T?.call(A,E,M),E.vertexShader=E.vertexShader.replace("#include <common>",`#include <common>
varying float vSelectionStyle;`).replace("#include <begin_vertex>",`#include <begin_vertex>
vSelectionStyle = 0.0;
#ifdef USE_INSTANCING_COLOR
  if (instanceColor.r < -1.0e25) { vSelectionStyle = 3.0; }
  else if (instanceColor.r < -1.0e15) { vSelectionStyle = 2.0; }
  else if (instanceColor.r < 0.0) { vSelectionStyle = 1.0; }
#endif`),E.vertexShader=E.vertexShader.replace("#include <color_vertex>",`#ifdef USE_INSTANCING_COLOR
vec3 selectionDecodedColor = instanceColor.r < -1.0e15 ? vec3(1.0) : instanceColor.r < 0.0 ? -instanceColor - vec3(1.0) : instanceColor;
#endif
`+i.ShaderChunk.color_vertex.replace(/\binstanceColor\b/g,"selectionDecodedColor")),E.fragmentShader=E.fragmentShader.replace("#include <common>",`#include <common>
varying float vSelectionStyle;`).replace("#include <clipping_planes_fragment>",`#include <clipping_planes_fragment>
if (vSelectionStyle > 2.5) discard;`).replace("#include <color_fragment>",`#include <color_fragment>
if (vSelectionStyle > 1.5 && vSelectionStyle < 2.5) diffuseColor.rgb = vec3(0.1247718, 0.7912979, 0.8549926);`).replace("#include <opaque_fragment>","if (vSelectionStyle > 0.5 && vSelectionStyle < 1.5) { outgoingLight = vec3(dot(outgoingLight, vec3(0.2126, 0.7152, 0.0722))) * 0.24;"+(_?" diffuseColor.a *= 0.24;":"")+` }
#include <opaque_fragment>`)},A.customProgramCacheKey=()=>w+":selection-instances-v1"+(_?":translucent-context":""),A}function f(v,b,x=null,_={}){let T=mm(_),w=_.expanded===!0,A=_.netContext===!0,E=T.mode+":"+T.color+":"+w+":"+A,M=T.mode==="dim"&&A,P=L=>v(L)&&!(M&&(L?.type==="Component"||typeof L?.library=="string"));if(!b){l();return}a&&a!==E&&l(),a=E;let N=T.mode==="dim"&&T.color==="accent";for(let L of e()){if(!L.material)continue;let D=u(L),$=L.userData.records,U=L.userData.identity?.startsWith("spike:via-barrel:"),I=N&&!U&&!M;if(U&&T.mode!=="isolate"&&!((w||A)&&T.mode==="dim")){L.material=D.material,L.instanceColor!==D.instanceColor&&(L.instanceColor=D.instanceColor);continue}if(L.isInstancedMesh&&$){if(I){D.white||(D.white=c(D.material).map(Q=>{let se=h(Q,D);return se.color?.setHex(16777215),se}),L.instanceColor=D.instanceColor?.clone()||null),L.material=Array.isArray(D.material)?D.white:D.white[0];let V=c(D.material)[0].color||new i.Color(16777215),W=new i.Color;for(let Q=0;Q<$.length;Q++){if(D.instanceColor?W.fromArray(D.instanceColor.array,Q*3).multiply(V):W.copy(V),x?.($[Q]))W.setHex(6547182);else if(!v($[Q])){let se=(W.r*.2126+W.g*.7152+W.b*.0722)*.24;W.setRGB(se,se,se)}L.setColorAt(Q,W)}}else{D.instances||(D.instances=c(D.material).map(W=>y(W,D,!1,T.mode==="dim"&&(A||U&&w))),L.instanceColor=D.instanceColor?.clone()||null,T.mode==="isolate"&&(L.customDepthMaterial=y(D.depth||new i.MeshDepthMaterial({depthPacking:i.RGBADepthPacking}),D,!D.depth),L.customDistanceMaterial=y(D.distance||new i.MeshDistanceMaterial,D,!D.distance))),L.material=Array.isArray(D.material)?D.instances:D.instances[0];let V=new i.Color;for(let W=0;W<$.length;W++){D.instanceColor?V.fromArray(D.instanceColor.array,W*3):V.setHex(16777215);let Q=$[W],se=P(Q);!se&&T.mode==="isolate"?V.setRGB(-1e30,-1e30,-1e30):!U&&T.color==="accent"&&x?.(Q)?V.setRGB(-1e20,-1e20,-1e20):!se&&T.mode==="dim"&&V.setRGB(-V.r-1,-V.g-1,-V.b-1),L.setColorAt(W,V)}}L.instanceColor&&(L.instanceColor.needsUpdate=!0)}else T.mode==="isolate"&&L.userData.record&&L.userData.record.type!=="Board"&&!v(L.userData.record)?(D.hidden||(D.hidden=c(D.material).map(V=>d(r,V,W=>{W.visible=!1}))),L.material=Array.isArray(D.material)?D.hidden:D.hidden[0]):!U&&T.color==="accent"&&x?.(L.userData.record)?L.material=g(D):P(L.userData.record)||T.mode!=="dim"?L.material=D.material:(D.dim||(D.dim=c(D.material).map(V=>m(V,D,!L.isInstancedMesh))),L.material=Array.isArray(D.material)?D.dim:D.dim[0])}}function p(v,b){let x=v.isInstancedMesh&&v.instanceColor;return x&&Number.isInteger(b)&&x.array[b*3]<-1e25?!1:c(v.material).some(_=>_&&_.visible!==!1)}return{update:f,restore:l,dispose:l,isVisible:p,stats:()=>({capturedObjects:t.size,sharedDimMaterials:n.size})}}var vI=Object.freeze(["realistic","layers","translucent"]);function tx(i){if(!vI.includes(i))throw new TypeError("Choose realistic, layers or translucent appearance.");return i}function pM(){let i=new Map,e=new Map,t=!1,n=!1,r={substrate:.12,component:.22,zone:.08,silkscreen:.45};function s(l){return Array.isArray(l)?l:[l]}function o(l,u){if(!l||!l.clone)return l;let h=e.get(l);if(h||(h=new Map,e.set(l,h)),h.has(u))return h.get(u);let d=l.clone();return d.onBeforeCompile=l.onBeforeCompile,d.customProgramCacheKey=()=>l.customProgramCacheKey(),d.transparent=!0,d.opacity=(Number.isFinite(l.opacity)?l.opacity:1)*r[u],d.depthWrite=!1,d.forceSinglePass=!0,d.needsUpdate=!0,h.set(u,d),d}function a(l,u){let h=s(u.material).map(d=>o(d,u.role));l.material=Array.isArray(u.material)?h:h[0]}function c(){for(let[l,u]of i)l.material=u.material;for(let l of e.values())for(let u of l.values())u.dispose();e.clear()}return{add(l,u){if(n||!l?.material||!Object.hasOwn(r,u)||i.has(l))return;let h={material:l.material,role:u};i.set(l,h),t&&a(l,h)},setEnabled(l){if(n)return!1;let u=!!l;if(u===t)return t;if(u||c(),t=u,t)for(let[h,d]of i)a(h,d);return t},stats(){return{enabled:t,objects:i.size,materials:[...e.values()].reduce((l,u)=>l+u.size,0)}},dispose(){n||(c(),i.clear(),t=!1,n=!0)}}}function gm(i,e,t){if(t==="translucent"&&i===e)return!1;for(let n=i;n;n=n.parent)if(!n.visible)return!1;return!0}function mM(i,e){if(!(e>0)||!Number.isFinite(e))throw new TypeError("A positive board thickness is required.");let n=["F.Cu",...[...new Set(i.layers||[])].filter(h=>typeof h=="string"&&/^In(?:[1-9]|[1-5][0-9]|6[0-2])\.Cu$/.test(h)).slice(0,62),"B.Cu"],r=Array.isArray(i.stackup)?i.stackup:[],s=new Map,o=0,a=r.findIndex(h=>h.name==="F.Cu"),c=r.findIndex(h=>h.name==="B.Cu"),l=a>=0&&c>a&&r.slice(a,c+1).every(h=>Number.isFinite(h.thickness)&&h.thickness>=0);if(l)for(let h of r){let d=Number.isFinite(h.thickness)&&h.thickness>=0?h.thickness:0;if(n.includes(h.name)){if(s.has(h.name)){s.clear();break}s.set(h.name,e/2-o-d/2)}o+=d}let u=l&&n.every(h=>s.has(h))&&Math.abs(o-e)<1e-6&&n.every((h,d)=>!d||s.get(n[d-1])>s.get(h));return n.map((h,d)=>({name:h,internal:d>0&&d<n.length-1,z:d===0?e/2+.025:d===n.length-1?-e/2-.025:u?s.get(h):e/2-d*e/(n.length-1),basis:d===0||d===n.length-1?"outer-surface":u?"saved-stackup":"illustrative"}))}function gM(i,e){let t=!1,n=!1,r=0,s=0;return{request(){if(!n&&(r++,!t)){t=!0;try{e()}catch(o){throw t=!1,o}}},flush(){n||!t||(t=!1,s++,i())},dispose(){n=!0,t=!1},stats(){return{requestCount:r,flushCount:s,pending:t}}}}function ym({request:i,cancel:e,render:t,canRender:n=()=>!0,state:r={}}){let s={documentVisible:!0,intersecting:!0,hasSize:!0,contextAvailable:!0,...r},o=null,a=!1,c=!1,l=0,u=0,h=0,d=0,m=0,g=0,y=0,f=()=>!c&&s.documentVisible&&s.intersecting&&s.hasSize&&s.contextAvailable&&n();function p(){o!==null&&(e(o),o=null,m++)}function v(){!a||o!==null||!f()||(u++,o=i(()=>{if(o=null,!f()){g++;return}a&&(a=!1,h++,t())}))}return{invalidate(){c||(l++,a=!0,f()?v():d++)},setState(b){if(c)return;let x=f();Object.assign(s,b),f()?(x||(y++,a=!0),v()):p()},stats(){return{...s,paused:!f(),dirty:a,pending:o!==null,requestCount:l,scheduledFrames:u,renderCallbacks:h,suppressedInvalidations:d,cancelledFrames:m,skippedFrames:g,resumeCount:y}},dispose(){c||(c=!0,p(),a=!1)}}}function xm(i,e,t=globalThis.IntersectionObserver){if(typeof t!="function")return null;let n;try{return n=new t(r=>{let s=r.find(o=>o.target===e);s&&i.setState({intersecting:!!s.isIntersecting&&s.intersectionRatio!==0})}),n.observe(e),n}catch{return n?.disconnect(),i.setState({intersecting:!0}),null}}function yM(i){let e=!0,t=0;return{invalidate(){e=!0},check(){return e?(e=!1,t++,i.getError()===i.NO_ERROR):!0},stats:()=>({checks:t,pending:e})}}function xM(i,e={}){let t=new Set((Array.isArray(i.netNames)?i.netNames:[]).filter(n=>typeof n=="string"&&n));for(let n of Array.isArray(i.netCodes)?i.netCodes:[]){if(n===0||n==="0"||n==null||n==="")continue;let r=e.nets?.[String(n)];r?t.add(r):typeof n=="string"&&!/^\d+$/.test(n)&&t.add(n)}return t}function vM(i,e){return e.size>0&&!["references","uuids"].some(t=>Array.isArray(i[t])&&i[t].some(n=>typeof n=="string"&&n))}function bI(i,e){let t=i.instanceMatrix?.array,n=e*16;if(!t||n+15>=t.length)return!1;let r=t[n]*(t[n+5]*t[n+10]-t[n+9]*t[n+6])-t[n+4]*(t[n+1]*t[n+10]-t[n+9]*t[n+2])+t[n+8]*(t[n+1]*t[n+6]-t[n+5]*t[n+2]);return Number.isFinite(r)&&r!==0}function bM(i,e){let t=new Set,n=0,r=0,s=0;for(let o of i){let a=!0;for(let l=o;l;l=l.parent)if(!l.visible){a=!1;break}if(!a||!o.geometry?.attributes?.position?.count)continue;s++;let c=(l,u)=>{n++,!(!e(l)||o.isInstancedMesh&&Number.isInteger(u)&&!bI(o,u))&&(r++,t.add(l?.ref?"part:"+l.ref:l?.uuid||l?.id||o.uuid+":"+u))};Array.isArray(o.userData.records)?o.userData.records.forEach(c):c(o.userData.record)}return{matched:t.size,matchedRecords:r,visitedRecords:n,visibleObjects:s}}function Wh(i={}){return["references","uuids","netNames"].some(e=>Array.isArray(i[e])&&i[e].some(t=>typeof t=="string"&&t.length>0))||Array.isArray(i.netCodes)&&i.netCodes.some(e=>typeof e=="number"&&Number.isFinite(e)&&e!==0||typeof e=="string"&&e!==""&&e!=="0")}function _M(i={},e={}){let t=a=>new Set(Array.isArray(a)?a.filter(c=>typeof c=="string"&&c):[]),n=t(i.references),r=t(i.uuids),s=t(i.netNames);for(let a of Array.isArray(i.netCodes)?i.netCodes:[]){if(a===0||a==="0"||a==null||a==="")continue;let c=e.nets?.[String(a)];c?s.add(c):typeof a=="string"&&!/^\d+$/.test(a)&&s.add(a)}let o=new Set;for(let a of e.pads||[])s.has(a.net)&&a.ref&&o.add(a.ref);return a=>!!(a&&(n.has(a.ref)||s.has(a.net)||r.has(a.uuid)||r.has(a.id)||typeof a.id=="string"&&r.has(a.id.split(":")[0])||o.has(a.ref)&&(a.type==="Component"||typeof a.library=="string")))}function vm(i=6){let e=new Map,t=!1;return{down(n){e.size||(t=!1),e.set(n.pointerId,[n.clientX,n.clientY]),e.size>1&&(t=!0)},move(n){let r=e.get(n.pointerId);r&&Math.hypot(n.clientX-r[0],n.clientY-r[1])>=i&&(t=!0)},up(n){let r=e.get(n.pointerId),s=!!(r&&!t&&e.size===1&&Math.hypot(n.clientX-r[0],n.clientY-r[1])<i);return e.delete(n.pointerId),s},cancel(n){e.delete(n.pointerId),t=!0}}}function EM(i,{later:e=setTimeout,clear:t=clearTimeout,delay:n=550,limit:r=8}={}){let s=new Set,o=null,a=null,c=!1,l=()=>{o!==null&&t(o),o=null};return{down(u){s.size||(c=!1),s.add(u.pointerId),l(),!(u.pointerType!=="touch"||s.size!==1)&&(a={pointerId:u.pointerId,clientX:u.clientX,clientY:u.clientY},o=e(()=>{o=null,c=!0,i(a)},n))},move(u){a?.pointerId===u.pointerId&&Math.hypot(u.clientX-a.clientX,u.clientY-a.clientY)>=r&&l()},up(u){return l(),s.delete(u.pointerId),c},isHeld(){return c},dispose(){l(),s.clear(),a=null}}}function MM(i,e="all"){if(!i)return!1;let t=i.type==="Pad"||typeof i.ref=="string"&&typeof i.name=="string"&&Array.isArray(i.at)&&Number.isFinite(i.width)&&Number.isFinite(i.height);return e==="pin"?t:e==="part"?!t&&(i.type==="Component"||typeof i.library=="string"):e==="net"?typeof i.net=="string"&&!!i.net:!0}function SM(i,{scene:e,renderer:t,extent:n,bottom:r,constrained:s=!1}){let o=new i.ShadowMaterial({color:0,opacity:.18,depthWrite:!1}),a=new i.Mesh(new i.PlaneGeometry(n*6,n*6),o);a.name="Presentation stage",a.position.z=r-Math.max(3,n*.035),a.receiveShadow=!0,a.visible=!1,e.add(a);let c=new Map,l=[];e.traverse(h=>{h.isDirectionalLight&&h.castShadow&&l.push(h)});function u(h,{fast:d=!1}={}){for(let[g,y]of c)g.castShadow=h||y;a.visible=h,e.environmentIntensity=h?1:.65,t.toneMappingExposure=h?1.05:1;let m=h&&!s&&!d?2048:1024;for(let g of l)g.shadow.mapSize.x!==m&&(g.shadow.map?.dispose(),g.shadow.map=null,g.shadow.mapSize.set(m,m),g.shadow.needsUpdate=!0);t.shadowMap.needsUpdate=!0}return{apply:u,addCaster(h){c.set(h,h.castShadow),h.castShadow=a.visible||h.castShadow},get enabled(){return a.visible},dispose(){for(let[h,d]of c)h.castShadow=d;c.clear(),e.remove(a),a.geometry.dispose(),o.dispose()}}}function Xh(i,e,t=1,n=4096){let r=Number.isFinite(i)&&i>0?i:1,s=Number.isFinite(e)&&e>0?e:1,o=Number.isFinite(t)&&t>0?t:1,a=Number.isFinite(n)&&n>0?n:4096;return Math.min(o,3,Math.sqrt(4e6/r/s),a/r,a/s)}function bm(i){return["low","balanced","high","presentation","photoreal-fast"].includes(i)?i:"balanced"}function TM({maxTextureSize:i=4096,maxRenderbufferSize:e=i,deviceMemory:t,hardwareConcurrency:n=0,floatTargets:r=!1,android:s=!1}={}){let o=Math.min(...[i,e].map(u=>Number.isFinite(u)&&u>0?u:4096)),a=Number.isFinite(t)&&t>0?t:null,c=o<=4096||a!==null&&a<=2,l=!c&&r&&o>=8192&&(a!==null?a>=6:o>=16384&&n>=8);return{tier:c?"constrained":l?"premium":"standard",constrained:c,premium:l,maxDimension:o,defaultQuality:s&&l?"high":"balanced",highMaxPixels:c?1e6:l?3e6:2e6}}function nx(i,e,t=1,n=4096,r="balanced",s=!1){let o=bm(r),a=Number.isFinite(i)&&i>0?i:1,c=Number.isFinite(e)&&e>0?e:1,l=s&&typeof s=="object"?s:null,u=l?l.constrained:s,h=o==="high"||o==="presentation",d=o==="photoreal-fast"?1e6:o==="presentation"?u?1e6:l?.premium?4e6:3e6:o==="high"?l?l.highMaxPixels:u?1e6:2e6:o==="low"||u?1e6:2e6,m=Math.min(Xh(a,c,o==="presentation"&&!u?Math.max(1.5,t):t,n),Math.sqrt(d/a/c)),g=Math.floor(a*m)*Math.floor(c*m),y=h?96:o==="low"?12:48;return{quality:o,ratio:m,width:Math.max(1,Math.floor(a*m)),height:Math.max(1,Math.floor(c*m)),pixels:g,maxPixels:d,estimatedBytes:g*y+(o==="low"?0:2*(o==="presentation"&&!u?2048:1024)**2*4)}}function AM(i=1.6,e="high"){let t=Number.isFinite(i)&&i>0?i:1.6;return{radius:Math.max(.35,Math.min(3,t*.85)),thickness:Math.max(.12,Math.min(1,t*.3)),distanceExponent:2,distanceFallOff:1,scale:1,samples:e==="presentation"?24:12,screenSpaceRadius:!1}}function wM(i,e){let t=e==="B.Cu"?"B.Mask":"F.Mask";return Array.isArray(i?.layers)&&(i.layers.includes(t)||i.layers.includes("*.Mask"))}var Xc=Object.freeze({coatedCopper:1459761,exposedCopper:12954220});function RM(i,e,t,n){let r=0,s=0;for(let o=0;o<3;o++)r+=((t[o]+n[o])/2-i[o])*e[o],s+=(n[o]-t[o])/2*Math.abs(e[o]);return r-s}function CM(i,e,t){let n=Number.isFinite(i)&&i>0?i:1,r=Number.isFinite(e)&&e>0?e:1,s=Number.isFinite(t)?t:n-r,o=Math.max(.005,s*.5);return{near:o,far:Math.max(10,n+r*4,o+1)}}var PM=Object.freeze([{x:.65,y:-.45,z:1,intensity:1.25,color:16774632},{x:.65,y:-.45,z:-1,intensity:1.25,color:16774632},{x:-.8,y:.35,z:.6,intensity:.65,color:15069183},{x:-.8,y:.35,z:-.6,intensity:.65,color:15069183}].map(Object.freeze)),pr=Object.freeze({solderMask:Object.freeze({color:870709,roughness:.46,metalness:.04,clearcoat:.3,clearcoatRoughness:.5}),substrateEdge:Object.freeze({color:11049070,roughness:.92,metalness:0}),copper:Object.freeze({metalness:.62,roughness:.38}),proxy:Object.freeze({color:3489097,metalness:.06,roughness:.66})});function IM(i){let e=i.onBeforeCompile;i.onBeforeCompile=function(n,r){e?.call(this,n,r);let s="#include <logdepthbuf_fragment>";if(!n.fragmentShader.includes(s))throw Error("Unsupported occlusion depth shader.");n.fragmentShader=n.fragmentShader.replace(s,"")};let t=i.customProgramCacheKey;i.customProgramCacheKey=function(){return t.call(this)+"|perspective-occlusion-depth-v1"}}var _I=2e5,EI=6e5;function Yh(i){if(!i||!Array.isArray(i.points)||!Array.isArray(i.triangles)||!Array.isArray(i.values))throw new Error("A saved triangular result surface is required.");if(i.points.length>EI||i.triangles.length>_I)throw new Error("Saved surface exceeds the 200,000 triangle / 600,000 point limit.");let e=i.nodal!==!1;if(i.values.length!==(e?i.points.length:i.triangles.length))throw new Error("Saved result values do not match the surface.");for(let t of i.points)if(!Array.isArray(t)||t.length!==3||!t.every(n=>Number.isFinite(n)&&Number.isFinite(Math.fround(n))))throw new Error("Saved surface contains an invalid coordinate.");for(let t of i.triangles)if(!Array.isArray(t)||t.length!==3||!t.every(n=>Number.isSafeInteger(n)&&n>=0&&n<i.points.length))throw new Error("Saved surface contains an invalid triangle index.");for(let t of i.values)if(t!==null&&!Number.isFinite(t))throw new Error("Saved surface contains an invalid result value.");return{...i,nodal:e}}function NM(i){i.traverse(e=>{e.geometry?.dispose(),(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{n?.map?.dispose(),n?.dispose()})}),i.clear()}function jh(i,e=n=>n,t={}){let n=Yh(i),r=t.palette;if(r!==void 0&&(!Array.isArray(r)||r.length!==4||r.some(_=>!Array.isArray(_)||_.length!==3||_.some(T=>!Number.isFinite(T)||T<0||T>255))))throw new TypeError("Choose four finite RGB palette stops.");if(t.range!==void 0&&(!Array.isArray(t.range)||t.range.length!==2||!t.range.every(Number.isFinite)||t.range[1]<=t.range[0]))throw new TypeError("Choose an increasing finite result range.");let s=new Dt,o=new Dt,a=1/0,c=-1/0;for(let _ of n.values)_!==null&&(a=Math.min(a,_),c=Math.max(c,_));t.range&&(a=t.range[0],c=t.range[1]);let l=[],u=[],h=[],d=[],m=[new Be(2639291),new Be(52179),new Be(16769114),new Be(15154225)],g=_=>Number.isFinite(c-a)?(_-a)/(c-a):(_/2-a/2)/(c/2-a/2),y=_=>c>a?Math.max(0,Math.min(1,g(_))):.5,f=_=>{let T=y(_)*3,w=Math.min(2,Math.floor(T)),A=T-w;if(r){let E=r[w].map((M,P)=>Math.round(M+(r[w+1][P]-M)*A)/255);return new Be().setRGB(...E,wt)}return m[w].clone().lerp(m[w+1],A)};n.triangles.forEach((_,T)=>{let w=n.nodal?_.map(N=>n.values[N]):_.map(()=>n.values[T]);if(w.some(N=>N===null))return;let A=_.map(N=>e(n.points[N]));if(A.some(N=>!Array.isArray(N)||N.length!==3||!N.every(L=>Number.isFinite(L)&&Number.isFinite(Math.fround(L)))))throw new Error("Invalid result coordinate mapping.");let E=new q(...A[0]),M=new q(...A[1]),P=new q(...A[2]);M.clone().sub(E).cross(P.clone().sub(E)).lengthSq()!==0&&(A.forEach((N,L)=>{l.push(...N);let D=f(w[L]);u.push(D.r,D.g,D.b),t.range&&d.push(g(w[L]))}),h.push(T))});let p=new ot;p.setAttribute("position",new Ve(l,3)),p.setAttribute("color",new Ve(u,3)),t.range&&p.setAttribute("resultScalar",new Ve(d,1)),p.computeBoundingSphere();let v=new Ht({vertexColors:!0,toneMapped:!1,side:yn,transparent:!0,opacity:.85,depthWrite:!1,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),b=new ct(p,v);s.add(b,o);function x(_){if(!_||_.object!==b||_.faceIndex==null)return null;let T=h[_.faceIndex],w=n.triangles[T];if(!w)return null;let A=w.map(L=>new q(...e(n.points[L]))),E=new q;if(Oi.getBarycoord(_.point,...A,E),![E.x,E.y,E.z].every(Number.isFinite))return null;let M=w.map(L=>n.points[L]),P=L=>M[0][L]*E.x+M[1][L]*E.y+M[2][L]*E.z,N=n.nodal?n.values[w[0]]*E.x+n.values[w[1]]*E.y+n.values[w[2]]*E.z:n.values[T];return{x:P(0),y:P(1),z:P(2),value:N,unit:String(n.unit||""),method:n.nodal?"nodal barycentric interpolation":"saved cell value",triangle:T}}return{group:s,mesh:b,surface:n,min:a,max:c,range:Number.isFinite(a)&&Number.isFinite(c)?[a,c]:null,sample:x,setOpacity(_){Number.isFinite(_)&&(v.opacity=Math.max(0,Math.min(1,_)),b.visible=v.opacity>0)},setProbes(_=[]){if(NM(o),!Array.isArray(_))return;let T=Math.max((p.boundingSphere?.radius||1)*.012,.001);for(let w of _.slice(0,100)){if(![w.x,w.y,w.z].every(Number.isFinite))continue;let A=new ct(new bi(T,12,8),new Ht({color:16777215,depthTest:!1}));if(A.position.set(...e([w.x,w.y,w.z])),A.renderOrder=10,A.userData.label=String(w.label||""),o.add(A),w.label){let E=document.createElement("canvas");E.width=256,E.height=64;let M=E.getContext("2d");if(M){M.fillStyle="#101d28",M.fillRect(0,0,256,64),M.fillStyle="#fff",M.font="bold 32px system-ui",M.textBaseline="middle",M.fillText(String(w.label).slice(0,12),8,32,240);let P=new ns(E);P.colorSpace=wt;let N=new Oo(new Hs({map:P,depthTest:!1}));N.position.copy(A.position).add(new q(0,0,T*4)),N.scale.set(T*12,T*3,1),N.renderOrder=11,o.add(N)}}}},dispose(){NM(s),s.removeFromParent()}}}function LM(i,e={}){let t=document.createElement("div");t.style.cssText="height:100%;min-height:240px;display:flex;flex-direction:column;position:relative";let n=t.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent=":host{font:12px system-ui}*{box-sizing:border-box}.shell{height:100%;min-height:240px;display:flex;flex-direction:column}.bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;padding:8px}button{padding:5px 10px;border-radius:4px;border:1px solid #819597;background:transparent;color:inherit;cursor:pointer}button:focus-visible,input:focus-visible{outline:2px solid #42bd95}.stage{position:relative;flex:1;min-height:200px;overflow:hidden}.stage canvas{display:block;width:100%;height:100%;touch-action:none}.notice{padding:6px 8px}.value{padding:6px 8px;min-height:28px}label{display:flex;gap:4px;align-items:center}.title{font-weight:700}";let s=document.createElement("div");s.className="shell";let o=document.createElement("div");o.className="bar";let a=document.createElement("span");a.className="title",o.append(a);let c=document.createElement("div");c.className="stage";let l=document.createElement("div");l.className="notice";let u=document.createElement("div");u.className="value",u.setAttribute("aria-live","polite"),s.append(o,c,l,u),n.append(r,s),i.append(t);let h;try{h=new fs({antialias:!0,alpha:!1})}catch{return l.textContent="3D rendering is unavailable on this device. Use the 2D result view.",{host:t,unavailable:!0,setSurface(){},setOpacity(){},setTheme(){},setProbes(){},fit(){},dispose(){t.remove()}}}h.outputColorSpace=wt,h.domElement.setAttribute("role","img"),h.domElement.setAttribute("aria-label","3D saved result surface"),c.append(h.domElement);let d=new oi;d.background=new Be(1056040);let m=new jt(45,1,.001,1e6);m.up.set(0,0,1);let g=new Qs(m,h.domElement);g.enableDamping=!0;let y=null,f=!0,p=0,v=.85,b=[],x=new Ce,_=new lr;function T(O=!1){if(!f||!y)return;let S=new zt().setFromObject(y.mesh),R=S.getBoundingSphere(new qt);if(S.isEmpty())return;let z=Math.max(R.radius,.001),Y=z/Math.sin(Js.degToRad(m.fov/2))*1.25/Math.min(m.aspect,1);g.target.copy(R.center),m.position.copy(R.center).add(new q(...O?[0,-1e-6,1]:[1,-1,1]).normalize().multiplyScalar(Y)),m.near=Math.max(z*1e-5,1e-6),m.far=Y+z*1e3,m.updateProjectionMatrix(),g.minDistance=z*.005,g.maxDistance=z*1e3,g.update()}function w(O){if(!f)return;let S=jh(O,([R,z,Y])=>[R,-z,Y]);y?.dispose(),y=S,d.add(S.group),S.setOpacity(v),S.setProbes(b),a.textContent=String(O.title||"Saved result surface"),l.textContent=`${O.zKnown?"Saved surface geometry":"No saved layer elevation; flat field"} \xB7 drag to orbit \xB7 right-drag / two fingers to pan \xB7 pinch / wheel to zoom${Number.isFinite(S.min)?` \xB7 ${S.min.toPrecision(5)}\u2013${S.max.toPrecision(5)} ${O.unit||""}`:" \xB7 no valid samples"}`,u.textContent="Click a colored surface to probe.",T()}let A=(O,S)=>{let R=document.createElement("button");R.textContent=O,R.type="button",R.addEventListener("click",S),o.append(R)};A("Fit",()=>T()),A("Top",()=>T(!0));let E=document.createElement("label");E.textContent="Opacity";let M=document.createElement("input");M.type="range",M.min="0",M.max="1",M.step=".05",M.value=String(v),M.setAttribute("aria-label","Result surface opacity"),E.append(M),o.append(E);let P=O=>{!f||!Number.isFinite(O)||(v=Math.max(0,Math.min(1,O)),M.value=String(v),y?.setOpacity(v))};M.addEventListener("input",()=>P(Number(M.value)));function N(O){if(!y||!y.mesh.visible)return null;let S=h.domElement.getBoundingClientRect();return!S.width||!S.height?null:(x.set((O.clientX-S.left)/S.width*2-1,-(O.clientY-S.top)/S.height*2+1),_.setFromCamera(x,m),y.sample(_.intersectObject(y.mesh,!1)[0]))}let L=null,D=O=>{L={id:O.pointerId,x:O.clientX,y:O.clientY,moved:!1}},$=O=>{L&&(L.id!==O.pointerId||Math.hypot(O.clientX-L.x,O.clientY-L.y)>5)&&(L.moved=!0),e.onHover?.(N(O))},U=O=>{let S=L&&L.id===O.pointerId&&!L.moved&&(O.button===0||O.pointerType==="touch");if(L=null,!S)return;let R=N(O);R&&(u.textContent=`${R.value.toPrecision(6)} ${R.unit} at (${R.x.toFixed(3)}, ${R.y.toFixed(3)}, ${R.z.toFixed(3)}) \xB7 ${R.method}`,e.onProbe?.(R))},I=()=>{L=null},V=()=>e.onHover?.(null);for(let[O,S]of[["pointerdown",D],["pointermove",$],["pointerup",U],["pointercancel",I],["pointerleave",V]])h.domElement.addEventListener(O,S);let W=()=>{if(!f)return;let O=Math.max(c.clientWidth,1),S=Math.max(c.clientHeight,1),R=Xh(O,S,globalThis.devicePixelRatio,h.capabilities.maxTextureSize);h.getPixelRatio()!==R&&h.setPixelRatio(R),h.setSize(O,S,!1),m.aspect=O/S,m.updateProjectionMatrix()},Q=new ResizeObserver(W);Q.observe(c),W();let se=O=>{O.preventDefault(),l.textContent="3D graphics context lost. Reopen this view to restore rendering.",f=!1,cancelAnimationFrame(p)};h.domElement.addEventListener("webglcontextlost",se);let oe=O=>{t.style.background=O?"#101d28":"#f3f7f5",t.style.color=O?"#e7f3ef":"#172e36",d.background.setHex(O?1056040:15988725)};oe(e.dark!==!1);try{w(e.surface)}catch(O){throw Q.disconnect(),g.dispose(),h.dispose(),t.remove(),O}let ge=()=>{f&&(p=requestAnimationFrame(ge),g.update(),h.render(d,m))};return ge(),{host:t,setSurface:w,setOpacity:P,setTheme:oe,fit:T,setProbes(O){b=Array.isArray(O)?O:[],y?.setProbes(b)},dispose(){f=!1,cancelAnimationFrame(p),Q.disconnect(),g.dispose(),y?.dispose(),h.domElement.removeEventListener("webglcontextlost",se);for(let[O,S]of[["pointerdown",D],["pointermove",$],["pointerup",U],["pointercancel",I],["pointerleave",V]])h.domElement.removeEventListener(O,S);h.dispose(),t.remove()}}}var ix=Object.freeze([[26,64,115],[20,136,156],[107,196,151],[255,225,112]].map(i=>Object.freeze(i))),OM=Object.freeze({wayricad:ix,viridis:Object.freeze([[68,1,84],[49,104,142],[53,183,121],[253,231,37]].map(i=>Object.freeze(i))),inferno:Object.freeze([[0,0,4],[120,28,109],[237,105,37],[252,255,164]].map(i=>Object.freeze(i))),grayscale:Object.freeze([[0,0,0],[85,85,85],[170,170,170],[255,255,255]].map(i=>Object.freeze(i)))});function qh(i="wayricad"){if(typeof i!="string"||!Object.hasOwn(OM,i))throw new TypeError("Choose wayricad, viridis, inferno or grayscale palette.");return OM[i]}function _m(i){let e=1/0,t=-1/0;for(let n of i)Number.isFinite(n)&&(e=Math.min(e,n),t=Math.max(t,n));if(!Number.isFinite(e))return null;if(e===t){let n=.5*Math.max(1,Math.abs(e));return[Math.max(-Number.MAX_VALUE,e-n),Math.min(Number.MAX_VALUE,t+n)]}return[e,t]}var MI=1e4,SI=2e5,sx="Source XYZ translated by the saved bounds center; +Z up; no PCB registration",UM=i=>Array.isArray(i)&&i.length===3&&i.every(e=>Number.isFinite(e)&&Number.isFinite(Math.fround(e)));function rx(i,e){return Object.assign(new Error(i),{code:e,fallback:"2d"})}function DM(){return new DOMException("Saved result view was aborted.","AbortError")}function FM(i,e){for(let t=0;t<3;t++)i.min[t]=Math.min(i.min[t],e[t]),i.max[t]=Math.max(i.max[t],e[t])}function TI(i){let[e,t,n]=i,r=t.map((o,a)=>o-e[a]),s=n.map((o,a)=>o-e[a]);return Math.hypot(r[1]*s[2]-r[2]*s[1],r[2]*s[0]-r[0]*s[2],r[0]*s[1]-r[1]*s[0])>0}function ox(i,{contextPrimitives:e=[],coordinateUnit:t="source units",range:n,palette:r="wayricad"}={}){let s=qh(r),o=Yh(i);if(n!==void 0&&(!Array.isArray(n)||n.length!==2||!n.every(Number.isFinite)||n[1]<=n[0]))throw new TypeError("Choose an increasing finite saved-field range.");if(o.zKnown!==!0)throw rx("No saved Z coordinates or layer elevation. Use the 2D field view.","SAVED_Z_REQUIRED");if(typeof t!="string"||t.length>80||/[\x00-\x1f]/.test(t))throw new TypeError("Choose a bounded source coordinate unit label.");if(!Array.isArray(e)||e.length>MI)throw new TypeError("Saved context exceeds 10,000 primitives.");let a={min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]},c=[],l=[],u=0,h=0,d=0,m=0;if(o.triangles.forEach((y,f)=>{if((o.nodal?y.map(p=>o.values[p]):[o.values[f]]).some(p=>p===null)||!TI(y.map(p=>o.points[p]))){h++;return}u++;for(let p of y)FM(a,o.points[p])}),!u)throw rx("No valid saved triangles with known field values. Missing samples remain holes in the 2D field view.","NO_SAVED_FIELD_VALUES");for(let y of e){let f=y?.points;if(!["line","polygon"].includes(y?.type)||!Array.isArray(f)||f.length<(y.type==="polygon"?3:2)||!f.every(UM)){m++;continue}if(d+=f.length,d>SI)throw new TypeError("Saved context exceeds 200,000 explicit XYZ points.");let p=f.map(v=>[...v]);c.push({type:y.type,points:p}),p.forEach(v=>FM(a,v))}m&&l.push(m+" context primitives without supported explicit XYZ geometry were omitted; no elevation was invented."),h&&l.push(h+" triangles with missing values or degenerate geometry remain unrendered.");let g=a.min.map((y,f)=>y/2+a.max[f]/2);if(a.max.some((y,f)=>y-a.min[f]>1e7))throw rx("Saved geometry exceeds the bounded 3D coordinate span. Use the 2D field view.","SAVED_GEOMETRY_RANGE");return{surface:o,context:c,bounds:a,origin:g,palette:r,stops:s,range:n?[...n]:_m(o.values),coordinateUnit:t||"source units",coordinateConvention:sx,renderedTriangles:u,omittedTriangles:h,diagnostics:l}}function ax(i,e=ix){let t=i.mesh.material,n=t.clone(),r=t.onBeforeCompile,s=t.customProgramCacheKey(),o=!1,a=n;n.vertexColors=!1,n.onBeforeCompile=(u,h)=>{if(r.call(n,u,h),!u.vertexShader.includes("#include <begin_vertex>")||!u.fragmentShader.includes("#include <color_fragment>"))throw new Error("Unsupported saved-field color shader.");u.uniforms.savedFieldPalette={value:e.map(d=>new q(...d.map(m=>m/255)))},u.vertexShader=u.vertexShader.replace("#include <common>",`#include <common>
attribute float resultScalar;
varying float vSavedResultScalar;`).replace("#include <begin_vertex>",`#include <begin_vertex>
vSavedResultScalar = resultScalar;`),u.fragmentShader=u.fragmentShader.replace("#include <common>",`#include <common>
varying float vSavedResultScalar;
uniform vec3 savedFieldPalette[4];`).replace("#include <color_fragment>",`#include <color_fragment>
float fieldBand = clamp(vSavedResultScalar, 0.0, 1.0) * 3.0;
vec3 fieldRGB = fieldBand < 1.0 ? mix(savedFieldPalette[0], savedFieldPalette[1], fieldBand) : fieldBand < 2.0 ? mix(savedFieldPalette[1], savedFieldPalette[2], fieldBand - 1.0) : mix(savedFieldPalette[2], savedFieldPalette[3], fieldBand - 2.0);
fieldRGB = floor(fieldRGB * 255.0 + 0.5) / 255.0;
diffuseColor.rgb = sRGBTransferEOTF(vec4(fieldRGB, 1.0)).rgb;`)},n.customProgramCacheKey=()=>s+":wayricad-scalar-palette-v1",i.mesh.material=n;let c=i.setOpacity;i.setOpacity=u=>{c(u),a&&(a.opacity=t.opacity)};let l={material:n,fallbackMaterial:t,get mode(){return a?"scalar":"vertex-color"},useFallback(){return o||!a?!1:(i.mesh.material=t,a.dispose(),a=null,!0)},dispose(){o||(o=!0,a&&t.dispose())}};return i.mesh.geometry.getAttribute("resultScalar").array.every(Number.isFinite)||l.useFallback(),l}function AI(i,e={}){let t=ox(i,e),n=u=>u.map((h,d)=>h-t.origin[d]),r=jh(t.surface,n,{palette:t.stops,range:t.range}),s=ax(r,t.stops),o=new Dt,a=[];s.mode==="vertex-color"&&t.diagnostics.push("Scalar values exceed the GPU normalization range; vertex-color interpolation is active. Probe values remain exact.");let c=null,l=!1;try{for(let u of t.context){let h=u.points;for(let d=1;d<h.length;d++)a.push(...n(h[d-1]),...n(h[d]));u.type==="polygon"&&a.push(...n(h.at(-1)),...n(h[0]))}if(a.length){let u=new ot;u.setAttribute("position",new Ve(a,3)),c=new ln(u,new Xt({color:8886951,transparent:!0,opacity:.65})),o.add(c)}o.add(r.group)}catch(u){throw s.dispose(),r.dispose(),c?.geometry.dispose(),c?.material.dispose(),u}return{group:o,overlay:r,prepared:t,contextMesh:c,scalarAppearance:s,dispose(){l||(l=!0,s.dispose(),r.dispose(),c?.geometry.dispose(),c?.material.dispose(),o.clear(),o.removeFromParent())}}}function wI(i){let e=u=>{let h=i?.[u];if(!UM(h)||h.some(d=>Math.abs(d)>1e12))throw new TypeError("Choose finite bounded source-view camera vectors.");return[...h]},t=e("position"),n=e("target"),r=e("up"),s=t.map((u,h)=>u-n[h]),o=Math.hypot(...s),a=Math.hypot(...r);if(!(o>0)||!(a>0))throw new TypeError("Choose a nondegenerate source-view camera.");let c=s.map(u=>u/o),l=r.map(u=>u/a);if(Math.hypot(c[1]*l[2]-c[2]*l[1],c[2]*l[0]-c[0]*l[2],c[0]*l[1]-c[1]*l[0])<1e-6)throw new TypeError("Choose a camera up vector independent of its direction.");return{position:t,target:n,up:r}}function kM(i,e,t={}){if(t.signal?.aborted)throw DM();let n=i?.ownerDocument;if(!n||typeof i.append!="function")throw new TypeError("Choose a saved result viewer container.");let r,s;try{r=ox(e,t)}catch(O){if(O.fallback!=="2d")throw O;s=O}r&&t.range!==void 0&&(t={...t,range:[...r.range]});let o=n.createElement("div"),a=n.createElement("div"),c=n.createElement("div"),l=n.createElement("div");o.style.cssText="height:100%;min-height:240px;display:flex;flex-direction:column;position:relative;font:12px/1.5 system-ui",a.style.cssText="position:relative;flex:1;min-height:180px;overflow:hidden",c.style.cssText=l.style.cssText="padding:6px 8px;overflow-wrap:anywhere",c.setAttribute("role","status"),l.setAttribute("aria-live","polite"),o.append(a,c,l),i.append(o);let u=O=>{o.style.background=O?"#101d28":"#f3f7f5",o.style.color=O?"#e7f3ef":"#172e36"};u(t.dark!==!1);let h=O=>{let S=!1;c.textContent=O.message,a.hidden=!0;let R=()=>{S||(S=!0,t.signal?.removeEventListener("abort",R),o.remove())};t.signal?.addEventListener("abort",R,{once:!0});let z={host:o,unavailable:!0,diagnostic:{code:O.code||"WEBGL_UNAVAILABLE",message:O.message,fallback:"2d"},setSurface(Y){return ox(Y,t),!1},setTheme:u,setOpacity(){},fit(){return!1},getCameraState(){return null},setCameraState(){return!1},getRenderStats(){return{unavailable:!0,renderCount:0,coordinateConvention:sx,coordinateUnit:t.coordinateUnit||"source units"}},dispose:R};try{t.onDiagnostics?.([O.message])}catch(Y){throw R(),Y}return z};if(s)return h(s);let d;try{d=new fs({antialias:!0,alpha:!1})}catch{return h(new Error("3D graphics are unavailable on this device. Use the 2D field view."))}let m=!0,g=null,y=.85,f=0,p=0,v=!1,b=null,x=null,_=null,T=null,w=new oi,A=new jt(45,1,.001,1e3);A.up.set(0,0,1),d.outputColorSpace=wt,d.domElement.style.cssText="display:block;width:100%;height:100%;touch-action:none",d.domElement.setAttribute("role","img"),d.domElement.setAttribute("aria-label","3D saved field in source XYZ coordinates"),a.append(d.domElement);let E=[],M=new Ce,P=new lr,N=vm(),L=(O,S,R)=>{O.addEventListener(S,R),E.push(()=>O.removeEventListener(S,R))},D=()=>a.clientWidth>0&&a.clientHeight>0,$=()=>{m&&(_.setState({documentVisible:!n.hidden,hasSize:D()}),_.invalidate())};d.debug.onShaderError=()=>{v=!0};function U(){if(m){T.update(),v=!1;try{if(d.render(w,A),v)throw new Error("Saved scalar color shader failed.");f++}catch(O){if(g?.scalarAppearance.useFallback()){p++,g.prepared.diagnostics.push("Scalar color mapping is unavailable; vertex-color interpolation is active. Probe values remain exact."),W(g.prepared),t.onDiagnostics?.([...g.prepared.diagnostics]),v=!1;try{if(d.render(w,A),v)throw O;f++}catch{c.textContent="3D graphics could not draw this field. Use the 2D field view."}}else c.textContent="3D graphics could not draw this field. Use the 2D field view."}}}function I(){if(!g)return;let O=Math.max(g.sphere.radius,1e-12),S=A.position.distanceTo(g.sphere.center);A.near=Math.max(O*1e-7,(S-O)*.5,1e-15),A.far=Math.max(S+O*4,A.near*2),A.updateProjectionMatrix()}function V(O=!1){if(!m||!g||new zt().setFromObject(g.group).isEmpty())return!1;let R=g.sphere,z=Math.max(R.radius,1e-12),Y=am(z,A.fov,A.aspect,1.2);return T.target.copy(R.center),A.position.copy(R.center).add(new q(...O?[0,-1e-6,1]:[1,-1,1]).normalize().multiplyScalar(Y)),I(),T.minDistance=z*1e-4,T.maxDistance=z*100,T.update(),$(),!0}function W(O){c.textContent="Independent saved field \xB7 "+O.coordinateUnit+" \xB7 source XYZ, +Z up \xB7 saved Z"+(O.surface.zBasis?" ("+String(O.surface.zBasis).slice(0,160)+")":"")+" \xB7 no PCB registration"+(O.context.length?" \xB7 retained source context":"")+" \xB7 "+O.renderedTriangles+" colored triangles \xB7 "+O.range.map(S=>Number(S.toPrecision(6))).join(" \u2013 ")+(O.surface.unit?" "+String(O.surface.unit).slice(0,80):"")+(g?.scalarAppearance.mode==="vertex-color"?" \xB7 vertex-color interpolation fallback":""),l.textContent="Drag to orbit \xB7 right-drag or two fingers to pan \xB7 pinch or wheel to zoom \xB7 tap a colored triangle to probe."}function Q(O,{retainCamera:S=!1}={}){if(!m)return!1;let R=AI(O,t);R.overlay.setOpacity(y),w.add(R.group),R.sphere=new zt().setFromObject(R.group).getBoundingSphere(new qt);let z=g;return g=R,z?.dispose(),W(g.prepared),S?I():V(),t.onDiagnostics?.([...g.prepared.diagnostics]),$(),!0}function se(){if(!m)return;let O=D();if(_.setState({hasSize:O}),!O){$();return}let S=a.clientWidth,R=a.clientHeight,z=Xh(S,R,globalThis.devicePixelRatio,d.capabilities.maxTextureSize);d.getPixelRatio()!==z&&d.setPixelRatio(z),d.setSize(S,R,!1),A.aspect=S/R,A.updateProjectionMatrix(),$()}function oe(O){if(!g?.overlay.mesh.visible)return null;let S=d.domElement.getBoundingClientRect();return!S.width||!S.height?null:(M.set((O.clientX-S.left)/S.width*2-1,-(O.clientY-S.top)/S.height*2+1),P.setFromCamera(M,A),g.overlay.sample(P.intersectObject(g.overlay.mesh,!1)[0]))}function ge(){if(m){m=!1,_?.dispose(),b?.disconnect(),x?.disconnect();for(let O of E)O();E.length=0,t.signal?.removeEventListener("abort",ge),T?.dispose(),g?.dispose(),g=null,w.clear(),d.dispose(),d.domElement.width=d.domElement.height=1,o.remove()}}try{if(T=new Qs(A,d.domElement),T.enableDamping=!1,_=ym({request:O=>requestAnimationFrame(O),cancel:O=>cancelAnimationFrame(O),render:U,canRender:()=>m&&!n.hidden&&D(),state:{documentVisible:!n.hidden,hasSize:D()}}),L(T,"change",()=>{I(),$()}),L(n,"visibilitychange",()=>{_.setState({documentVisible:!n.hidden}),n.hidden||$()}),L(d.domElement,"pointerdown",O=>N.down(O)),L(d.domElement,"pointermove",O=>{N.move(O),t.onHover&&t.onHover(oe(O))}),L(d.domElement,"pointerup",O=>{if(!N.up(O)||O.button!==0&&O.pointerType!=="touch")return;let S=oe(O);S&&(l.textContent=S.value.toPrecision(6)+" "+S.unit+" at source XYZ ("+[S.x,S.y,S.z].map(R=>Number(R.toPrecision(7))).join(", ")+") "+g.prepared.coordinateUnit+" \xB7 "+S.method,t.onProbe?.(S))}),L(d.domElement,"pointercancel",O=>N.cancel(O)),L(d.domElement,"pointerleave",()=>t.onHover?.(null)),L(d.domElement,"webglcontextlost",O=>{O.preventDefault(),_.setState({contextAvailable:!1}),c.textContent="3D graphics context interrupted. Saved field geometry is retained."}),L(d.domElement,"webglcontextrestored",()=>{_.setState({contextAvailable:!0}),g&&W(g.prepared),$()}),typeof ResizeObserver=="function"?(b=new ResizeObserver(se),b.observe(a)):n.defaultView&&L(n.defaultView,"resize",se),x=xm(_,a),t.signal?.addEventListener("abort",ge,{once:!0}),w.background=new Be(t.dark!==!1?1056040:15988725),se(),Q(r.surface),t.signal?.aborted)throw ge(),DM()}catch(O){throw ge(),O}return{host:o,unavailable:!1,setSurface:Q,setPalette(O){if(qh(O),!m)return!1;let S=t;t={...t,palette:O};try{return Q(g.prepared.surface,{retainCamera:!0})}catch(R){throw t=S,R}},setProbes(O){g?.overlay.setProbes(O),$()},setTheme(O){m&&(u(!!O),w.background.setHex(O?1056040:15988725),$())},setOpacity(O){if(m){if(!Number.isFinite(O)||O<0||O>1)throw new TypeError("Choose result opacity between 0 and 1.");y=O,g.overlay.setOpacity(O),$()}},fit:V,getCameraState(){return{position:A.position.toArray(),target:T.target.toArray(),up:A.up.toArray()}},setCameraState(O){if(!m)return!1;let S=wI(O);A.position.fromArray(S.position),T.target.fromArray(S.target),A.up.fromArray(S.up);let R=A.position.distanceTo(T.target);return T.minDistance=Math.min(T.minDistance,R),T.maxDistance=Math.max(T.maxDistance,R),T.update(),$(),!0},getRenderStats(){let O=g?.prepared;return{unavailable:!1,renderCount:f,renderActivity:{..._.stats(),observesIntersection:!!x},drawCalls:d.info.render.calls,gpuTextures:d.info.memory.textures,renderedTriangles:O?.renderedTriangles||0,omittedTriangles:O?.omittedTriangles||0,contextPrimitives:O?.context.length||0,range:O?[...O.range]:null,palette:O?.palette||"wayricad",colorInterpolation:g?.scalarAppearance.mode||null,scalarColorFallbacks:p,coordinateUnit:O?.coordinateUnit||t.coordinateUnit||"source units",coordinateConvention:sx,sourceOrigin:O?[...O.origin]:null,sourceBounds:O?{min:[...O.bounds.min],max:[...O.bounds.max]}:null}},dispose:ge}}function Kh(i){return Object.assign(new Error(i),{code:"UNSUPPORTED_RESULT_REGISTRATION"})}function RI(i,{bounds:e,thickness:t,layers:n=[]},r={}){let s=Yh(i),o=s.zBasis,a=s.layer??r.layer??null;if(r.layer!==void 0&&s.layer!==void 0&&r.layer!==s.layer)throw Kh("Selected layer does not match the saved result layer.");if(a!==null&&(typeof a!="string"||!n.includes(a)))throw Kh("Saved result layer is not present on this board.");if(o!=null&&!["front-depth","board-center"].includes(o))throw Kh("Saved result elevation basis is unsupported; use the standalone result scene.");if(s.zKnown===!0?!["front-depth","board-center"].includes(o):!["F.Cu","B.Cu"].includes(s.layer))throw Kh("Saved elevation requires front-depth or board-center; without saved Z only saved F.Cu/B.Cu layers can be placed.");if(!e||![e.minX,e.minY,e.maxX,e.maxY,t].every(Number.isFinite)||e.minX>e.maxX||e.minY>e.maxY||t<=0)throw new TypeError("Choose finite board bounds and a positive thickness.");let c=r.palette===void 0?null:qh(r.palette);if(r.range!==void 0&&(!Array.isArray(r.range)||r.range.length!==2||!r.range.every(Number.isFinite)||r.range[1]<=r.range[0]))throw new TypeError("Choose an increasing finite result range.");let l=e.minX/2+e.maxX/2,u=e.minY/2+e.maxY/2,h=([m,g,y])=>[m-l,u-g,s.zKnown===!0?o==="front-depth"?t/2-y:y:s.layer==="F.Cu"?t/2:-t/2],d=r.range?[...r.range]:c?_m(s.values):null;if(c&&!d)throw Kh("No known saved field values are available for placement.");return{surface:s,transform:h,stops:c,palette:r.palette??null,layer:a,basis:s.zKnown===!0?o:s.layer,flat:s.zKnown!==!0,range:d,throughBoard:r.throughBoard!==!1}}function CI(i,e,t={}){let n=RI(i,e,t),r=jh(n.surface,n.transform,{...n.range?{range:n.range}:{},...n.stops?{palette:n.stops}:{}}),s=r.sample;r.sample=l=>{let u=s(l);return u?{...u,overlayOwner:t.owner}:null};let o=null,a=!1;try{r.mesh.material.depthTest=!n.throughBoard,r.mesh.renderOrder=n.throughBoard?20:0,n.stops&&(o=ax(r,n.stops))}catch(l){throw o?.dispose(),r.dispose(),l}let c=[];return o?.mode==="vertex-color"&&c.push("Scalar values exceed the GPU normalization range; vertex-color interpolation is active. Probe values remain exact."),{overlay:r,prepared:n,scalarAppearance:o,diagnostics:c,state(){return{placed:!0,palette:n.palette,layer:n.layer,basis:n.basis,flat:n.flat,throughBoard:n.throughBoard,triangles:r.mesh.geometry.getAttribute("position").count/3,range:r.range?[...r.range]:null,diagnostics:[...c]}},useColorFallback(){return o?.useFallback()?(c.push("Scalar color mapping is unavailable; vertex-color interpolation is active. Probe values remain exact."),!0):!1},dispose(){a||(a=!0,o?.dispose(),r.dispose())}}}function BM(i,{scene:e,invalidate:t=()=>{},isActive:n=()=>!0}={}){let r=null,s,o=c=>c?.owner===void 0||c.owner===s,a=c=>({placed:!1,layer:null,basis:null,throughBoard:!1,triangles:0,range:null,diagnostics:[],...c?{reason:c}:{}});return{get overlay(){return r?.overlay||null},getAnalysisOverlayState(){return r?r.state():a()},setAnalysisOverlay(c,l={}){if(!n())return a("3D viewer is closed.");if(!c)return o(l)?(r?.dispose(),r=null,s=void 0,t(),a("Overlay cleared.")):a("Overlay belongs to another owner.");let u;try{u=CI(c,i,l)}catch(d){if(d.code==="UNSUPPORTED_RESULT_REGISTRATION")return a(d.message);throw d}e.add(u.overlay.group);let h=r;return r=u,s=l.owner,h?.dispose(),t(),r.state()},setAnalysisProbes(c,l={}){return!r||!o(l)?!1:(r.overlay.setProbes(c),t(),!0)},setAnalysisOpacity(c,l={}){return!r||!o(l)?!1:(r.overlay.setOpacity(c),t(),!0)},useColorFallback(){return r?.useColorFallback()||!1},dispose(){r?.dispose(),r=null,s=void 0}}}var Ki=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i,Em=i=>Array.isArray(i)?String(Ki(i[0])):"",cx=(i,e)=>i.filter(t=>Em(t)===e),eo=(i,e)=>cx(i,e)[0],Zh=(i,e,t)=>(e[0]-i[0])*(t[1]-i[1])-(e[1]-i[1])*(t[0]-i[0]),Jh=(i,e,t)=>Math.abs(Zh(i,e,t))<1e-8&&t[0]>=Math.min(i[0],e[0])-1e-8&&t[0]<=Math.max(i[0],e[0])+1e-8&&t[1]>=Math.min(i[1],e[1])-1e-8&&t[1]<=Math.max(i[1],e[1])+1e-8;function PI(i,e,t,n){let r=Zh(i,e,t),s=Zh(i,e,n),o=Zh(t,n,i),a=Zh(t,n,e);return r*s<0&&o*a<0||Jh(i,e,t)||Jh(i,e,n)||Jh(t,n,i)||Jh(t,n,e)}function zM(i,e){let t=!1;for(let n=0,r=e.length-1;n<e.length;r=n++){let s=e[n],o=e[r];if(Jh(s,o,i))return!1;s[1]>i[1]!=o[1]>i[1]&&i[0]<(o[0]-s[0])*(i[1]-s[1])/(o[1]-s[1])+s[0]&&(t=!t)}return t}function VM(i,e,t=[]){if(!Array.isArray(i)||i.length<3||!Array.isArray(e)||e.length<3||i.some(n=>!n.every(Number.isFinite)||!zM(n,e)||t.some(r=>zM(n,r))))return!1;for(let n of[e,...t])for(let r=0;r<i.length;r++)for(let s=0;s<n.length;s++)if(PI(i[r],i[(r+1)%i.length],n[s],n[(s+1)%n.length]))return!1;return!0}function HM(i,{maxContours:e=1e5}={}){if(!Number.isSafeInteger(e)||e<1)throw TypeError("Invalid zone contour index limit.");let t=new Map;for(let h of i)Em(h)==="net"&&t.set(Ki(h[1]),String(Ki(h[2])||""));let n=new Map,r=0,s=0,o=0,a=0,c=0,l=0,u=0;for(let h of i){if(Em(h)!=="zone")continue;let d=cx(h,"filled_polygon"),m=d.length>0;m||r++;let g=eo(h,"layers")?.slice(1).map(Ki)??[Ki(eo(h,"layer")?.[1])],y=Ki(eo(h,"uuid")?.[1])||Ki(eo(h,"tstamp")?.[1]),f=Ki(eo(h,"net")?.[1]),p=String(Ki(eo(h,"net_name")?.[1])||t.get(f)||(typeof f=="string"?f:""));for(let v of m?d:cx(h,"polygon")){let b=eo(v,"pts")||[],x=b[1]instanceof Float64Array?b[1].length/2:0,_=!1;for(let w of b)Em(w)==="xy"&&((!Number.isFinite(Number(Ki(w[1])))||!Number.isFinite(Number(Ki(w[2]))))&&(_=!0),x++);if(_||x<3){a++;continue}let T=Ki(eo(v,"layer")?.[1]);for(let w of T?[T]:g){if(typeof w!="string")continue;if(s>=e){c++;continue}let A={id:String(y||"saved-zone-"+s),net:p,layer:w,filled:m,size:x,contour:s,sourcePoints:b};n.has(w)||n.set(w,[]),n.get(w).push(A),s++,o+=x,w.endsWith(".Cu")?l++:u++}}}return{forLayer:h=>n.get(h)||[],stats:()=>({contours:s,copperContours:l,nonCopperContours:u,points:o,unfilled:r,invalid:a,omitted:c,layers:n.size,retainsCoordinateCopies:!1})}}var Mm=i=>i&&["x","y","z"].every(e=>typeof i[e]=="number"&&Number.isFinite(i[e])),Yc=i=>({x:i.x,y:i.y,z:i.z,approximate:!!i.approximate});function II(i,e){if(!Mm(i)||!Mm(e))return null;let t={x:e.x-i.x,y:e.y-i.y,z:e.z-i.z},n=Math.hypot(t.x,t.y,t.z);return Number.isFinite(n)?{from:Yc(i),to:Yc(e),delta:t,distance:n,approximate:!!(i.approximate||e.approximate)}:null}function Tm(i,e="mm"){return typeof i!="number"||!Number.isFinite(i)||i<0?"\u2014":e==="mil"?(i/.0254).toFixed(2)+" mil":i.toFixed(3)+" mm"}var Sm=class{constructor(){this.pending=null,this.records=[],this.selected=null,this.nextId=1}add(e){if(!Mm(e))return null;if(!this.pending)return this.pending=Yc(e),this.selected=null,{pending:this.pending};let t=II(this.pending,e);return t?(t.id=this.nextId++,this.pending=null,this.records.unshift(t),this.records.length>5&&(this.records.length=5),this.selected=t,t):null}replay(e){let t=this.records.find(n=>n.id===Number(e));return t?(this.pending=null,this.selected=t,t):null}clear(){this.pending=null,this.records=[],this.selected=null}snapshot(){return{pending:this.pending?Yc(this.pending):null,records:this.records.map(e=>({...e,from:Yc(e.from),to:Yc(e.to),delta:{...e.delta}})),selected:this.selected?.id??null}}};function GM(i,e,t,{mode:n="edges",tolerance:r=12}={}){if(!i||![i.x,i.y,r].every(Number.isFinite)||r<=0||!["edges","corners"].includes(n)||!Array.isArray(e))return null;let s=null,o=(a,c,l)=>{let u=Math.hypot(c.x-i.x,c.y-i.y);u<=r&&(!s||u<s.distance)&&(s={point:{x:a.x,y:a.y,z:a.z},screen:{x:c.x,y:c.y},kind:l,distance:u})};for(let a of e.slice(0,1e4)){if(!Array.isArray(a)||a.length!==2||!a.every(Mm))continue;let[c,l]=a,u=t(c),h=t(l);if(!u||!h||![u.x,u.y,u.z,h.x,h.y,h.z].every(Number.isFinite)||u.z<-1||u.z>1||h.z<-1||h.z>1)continue;if(n==="corners"){o(c,u,"mesh vertex"),o(l,h,"mesh vertex");continue}let d=h.x-u.x,m=h.y-u.y,g=d*d+m*m;if(g<1e-10)continue;let y=Math.max(0,Math.min(1,((i.x-u.x)*d+(i.y-u.y)*m)/g)),f=Number.isFinite(u.w)&&u.w>0?u.w:1,p=Number.isFinite(h.w)&&h.w>0?h.w:1,v=y*f/((1-y)*p+y*f);o({x:c.x+(l.x-c.x)*v,y:c.y+(l.y-c.y)*v,z:c.z+(l.z-c.z)*v},{x:u.x+d*y,y:u.y+m*y},"mesh edge")}return s}var Qh=[{id:"top",label:"Top",direction:[0,0,1],up:[0,1,0]},{id:"bottom",label:"Bottom",direction:[0,0,-1],up:[0,-1,0]},{id:"front",label:"Front",direction:[0,-1,0],up:[0,0,1]},{id:"back",label:"Back",direction:[0,1,0],up:[0,0,1]},{id:"left",label:"Left",direction:[-1,0,0],up:[0,0,1]},{id:"right",label:"Right",direction:[1,0,0],up:[0,0,1]},{id:"isometric",label:"Isometric",direction:[.45,-.38,1],up:[0,0,1]}];function WM(i){let e=i===!0?"top":i===!1?"iso":i;return Qh.find(t=>t.id===e)||Qh.at(-1)}function XM({onChange:i=()=>{}}={}){let e=!1,t=0,n=-1,r=null,s=new Set,o=new WeakSet,a=new Map;function c(p){let v=p.source?.data,b=0,x=_=>{Number.isFinite(_?.width)&&Number.isFinite(_?.height)&&(b+=Math.ceil(_.width*_.height*4*(_.data?.BYTES_PER_ELEMENT||1)*(p.generateMipmaps?4/3:1)))};if(Array.isArray(v))for(let _ of v)x(_);else x(v);return b}function l(){for(let[p,v]of a)if(p.instanceMatrix?.array!==v.matrix||p.instanceColor?.array!==v.color||p.boneMatrices!==v.bones||p.isTexture&&c(p)!==v.textureBytes)return!1;return!0}function u(p){return!p||typeof p!="object"||typeof p.dispose!="function"||(e?h(p):s.has(p)||(s.add(p),t++,i())),p}function h(p){o.has(p)||(o.add(p),p.dispose(),p.isTexture&&p.source?.data?.close?.())}function d(p,v=!1){let b=new Set,x=T=>{T&&typeof T.dispose=="function"&&!s.has(T)&&b.add(T)},_=T=>{if(!(!T||v&&s.has(T))){for(let w in T)Object.hasOwn(T,w)&&T[w]?.isTexture&&x(T[w]);x(T)}};return p?.traverse?.(T=>{if(T.isInstancedMesh&&x(T),x(T.geometry),Array.isArray(T.material))for(let w of T.material)_(w);else _(T.material);T.skeleton&&x(T.skeleton)}),b}function m(p,v=1/0,b=1/0,x=!1){let _=d(p,x),T=x&&!_.size&&n===t&&l()?r:f(_);if(!e&&(T.retainedGeometryBytes>v||T.retainedTextureBytes>b)){for(let w of _)h(w);throw Error("Decoded model geometry or textures exceed this device\u2019s memory budget.")}for(let w of _)u(w);return e||(T!==r&&g(),r=T,n=t),p}function g(){for(let p of s)if(p.isInstancedMesh||p.boneMatrices||p.isTexture){let v=a.get(p);v||(v={},a.set(p,v)),v.matrix=p.instanceMatrix?.array,v.color=p.instanceColor?.array,v.bones=p.boneMatrices,p.isTexture&&(v.textureBytes=c(p))}}function y(){if(!e){e=!0;for(let p of s)h(p);s.clear(),a.clear(),r=null,n=-1}}function f(p){let v=new Set,b=0,x=0,_=0,T=A=>{let E=A?.buffer;E&&!v.has(E)&&(v.add(E),b+=E.byteLength)},w=A=>{if(A.isTexture&&(x++,_+=c(A)),A.isInstancedMesh&&(T(A.instanceMatrix?.array),T(A.instanceColor?.array)),A.boneMatrices&&T(A.boneMatrices),A.isBufferGeometry){let E=M=>T(M?.array||M?.data?.array);for(let M in A.attributes)Object.hasOwn(A.attributes,M)&&E(A.attributes[M]);for(let M in A.morphAttributes)if(Object.hasOwn(A.morphAttributes,M))for(let P of A.morphAttributes[M])E(P);E(A.index)}};for(let A of s)w(A);if(p)for(let A of p)w(A);return{retainedResources:s.size+(p?.size||0),retainedGeometryBytes:b,retainedTextures:x,retainedTextureBytes:_}}return{track:u,retain:m,dispose:y,stats:()=>f(),discard(p){for(let v of d(p))h(v)},retainClone:(p,v,b)=>m(p,v,b,!0)}}function YM({onPick:i,onContextMenu:e,isHeld:t=()=>!1},n=6){let r=vm(n);return{down:s=>r.down(s),move:s=>r.move(s),cancel:s=>r.cancel(s),up(s,{select:o=!0}={}){let a=r.up(s);return o&&a&&!t()&&(s.button===0?i(s):s.button===2&&e(s)),a},context(s){s.preventDefault?.(),s.button!==2&&!t()&&e(s)}}}var jM=i=>{let e=Math.max(0,Math.min(1,i));return e*e*(3-2*e)};function da(i){if(!Number.isFinite(i))throw new TypeError("Expand amount must be finite.");let e=Math.max(0,Math.min(100,i));return{amount:e,components:jM(e/35),layers:jM((e-35)/65)}}function qM({request:i,cancel:e,now:t=()=>performance.now(),update:n,canRun:r=()=>!0,reducedMotion:s=()=>!1,settle:o=()=>{}}){let a=0,c=0,l=null,u=0,h=!1;function d(){!h&&l===null&&a!==c&&r()&&(u=t(),l=i(m))}function m(g){if(l=null,h||!r())return;let y=Math.max(1,Math.min(64,g-u));u=g,a+=(c-a)*(1-Math.exp(-y/85)),Math.abs(c-a)<.04&&(a=c),n(a),!h&&(a!==c?l=i(m):o(a))}return{set(g,{immediate:y=!1}={}){return h||(c=da(g).amount,y||s()?(l!==null&&e(l),l=null,a=c,n(a),h||o(a)):d()),c},resume:d,get:()=>a,target:()=>c,running:()=>l!==null,dispose(){h=!0,l!==null&&e(l),l=null}}}function KM(i,e,{maxGap:t=4,componentLift:n=8}={}){let r=[...e.layers||[]].filter(f=>typeof f.name=="string"&&Number.isFinite(f.z)).sort((f,p)=>p.z-f.z).slice(0,64),s=new Map(r.map((f,p)=>[f.name,(r.length-1)/2-p])),o=new WeakMap,a=new WeakMap,c=0,l=f=>{let p=da(c).layers;return p===0?0:(s.get(f)||0)*t*p},u=f=>l(f)+(f==="B.Cu"?-1:1)*n*da(c).components,h=f=>r.reduce((p,v)=>!p||Math.abs(v.z-f)<Math.abs(p.z-f)?v:p,null)?.name;function d(f,p){o.has(f)||o.set(f,f.position.z),f.position.z=o.get(f)+l(p),f.updateMatrix?.()}function m(f,p){o.has(f)||o.set(f,f.position.z),f.position.z=o.get(f)+u(p),f.updateMatrix?.()}function g(f,p){if(!f?.isInstancedMesh||!p||!(p.zMax>p.zMin))return;a.has(f)||a.set(f,f.instanceMatrix.array.slice());let v=a.get(f),b=l(h(p.zMin)),x=l(h(p.zMax)),_=(p.zMax-p.zMin+x-b)/(p.zMax-p.zMin),T=new i.Matrix4,w=new i.Vector3(1,1,_);for(let A=0;A<f.count;A++)T.fromArray(v,A*16),T.elements[14]+=b,T.scale(w),f.setMatrixAt(A,T);f.instanceMatrix.needsUpdate=!0,f.computeBoundingSphere?.(),f.computeBoundingBox?.()}function y(f){f.traverse(p=>{p.geometry&&(p.userData.explodeSpan?g(p,p.userData.explodeSpan):d(p,p.userData.layer||p.userData.record?.layer))})}return{offset:l,componentOffset:u,component:m,layer:d,barrels:g,overlay:y,set(f){return c=da(f).amount,c},get:()=>c,phases:()=>da(c),span:()=>t*da(c).layers*Math.max(0,r.length-1),layers:r.map(f=>f.name)}}function ZM(){let i=new WeakMap;return{sync(e,t){let n=e?.group;return n?t>0?(i.has(n)||i.set(n,n.visible),n.visible=!1,!0):(i.has(n)&&(n.visible=i.get(n),i.delete(n)),!1):!1}}}function JM(i,{scene:e,objects:t,visible:n=()=>!0,colorForLayer:r=()=>7534079,maxInstances:s=5e4,maxMeshes:o=2048}){let a=new i.Group;a.name="Selected net shine-through",e.add(a);let c=new Map,l=new Map,u=new i.Matrix4,h="",d=0,m=0,g=!1,y={sourceScans:0,recordScans:0,transformSyncs:0};function f(_,T=!1,w=!1,A="accent",E=!1){let M=[_,T,w,A,E].join("|");if(l.has(M))return l.get(M);let P={color:E||_==="through"?12954220:A==="source"?r(_):7534079,transparent:!0,opacity:T?.14:.95,depthTest:!1,depthWrite:!1,toneMapped:!1},N=w?new i.LineBasicMaterial(P):new i.MeshBasicMaterial({...P,side:i.DoubleSide});return l.set(M,N),N}function p(){for(let _ of c.values())a.remove(_.mesh),_.mesh.dispose?.(),_.edge&&(a.remove(_.edge),_.edge.geometry.dispose());c.clear();for(let _ of l.values())_.dispose();l.clear(),d=0,m=0,g=!1,h=""}function v(_,{color:T="accent"}={}){let w=JSON.stringify([[..._].sort(),T]);if(!_.size){c.size&&p();return}w!==h&&(p(),h=w);for(let A of c.values())A.mesh.visible=!1,A.edge&&(A.edge.visible=!1);for(let A of t()){if(y.sourceScans++,A.userData?.record?.type==="Component")continue;let E=A.userData?.identity||"",M=A.userData?.record?.type==="Zone",P=E.startsWith("spike:via-barrel:");if(!A.geometry?.attributes?.position||!M&&!/^spike:(copper-track|copper-pad|via-barrel):/.test(E))continue;let N=M?A.userData.record.layer:decodeURIComponent(E.split(":")[2]||"");if(!n(A,N))continue;let L=c.get(A);if(!L){if(c.size>=o){g=!0;continue}let D=A.userData.records,$=[],U=Math.max(0,s-d);if(A.isInstancedMesh&&D){for(let W=0;W<Math.min(D.length,A.count);W++)if(y.recordScans++,_.has(D[W].net)){if($.length>=U){g=!0;break}$.push(W)}}else _.has(A.userData.record?.net)&&$.push(null);if(!$.length)continue;let I=Math.max(0,s-d);if($.length>I&&($.length=I,g=!0),!$.length)continue;let V=A.isInstancedMesh?new i.InstancedMesh(A.geometry,f(N,!1,!1,T,P),$.length):new i.Mesh(A.geometry,f(N,M,!1,T,P));if(V.matrixAutoUpdate=!1,V.renderOrder=201,V.frustumCulled=!1,a.add(V),L={mesh:V,indices:$,edge:null,layer:N},M)if(A.geometry.attributes.position.count*6+m<=2e5){let W=new i.LineSegments(new i.EdgesGeometry(A.geometry,1),f(N,!1,!0,T));m+=W.geometry.attributes.position.count,W.matrixAutoUpdate=!1,W.renderOrder=202,W.frustumCulled=!1,a.add(W),L.edge=W}else g=!0;c.set(A,L),d+=$.length}b(A,L)}}function b(_,T){if(y.transformSyncs++,_.updateWorldMatrix(!0,!1),T.mesh.matrix.copy(_.matrixWorld),T.mesh.matrixWorldNeedsUpdate=!0,T.mesh.visible=!0,_.isInstancedMesh){for(let w=0;w<T.indices.length;w++)_.getMatrixAt(T.indices[w],u),T.mesh.setMatrixAt(w,u);T.mesh.instanceMatrix.needsUpdate=!0}T.edge&&(T.edge.matrix.copy(_.matrixWorld),T.edge.matrixWorldNeedsUpdate=!0,T.edge.visible=!0)}function x(){for(let[_,T]of c)T.mesh.visible=n(_,T.layer),T.edge&&(T.edge.visible=T.mesh.visible),T.mesh.visible&&b(_,T)}return{update:v,syncTransforms:x,clear:p,stats:()=>{let _=0,T=0;for(let w of c.values())w.mesh.visible&&(_++,T+=w.indices.length);return{meshes:_,instances:T,retainedMeshes:c.size,limited:g,throughBoard:!0,...y}},dispose(){p(),e.remove(a)}}}function jc(i,e="all"){let t={zone:1,track:-1,pad:-2,via:-3}[i];if(typeof t!="number")throw Error("Unknown copper surface role.");if(!["all","cap","wall"].includes(e))throw Error("Unknown copper surface kind.");return{polygonOffset:e!=="wall",polygonOffsetFactor:e==="cap"?t/2:0,polygonOffsetUnits:e==="wall"?0:t*2}}function lx(i,e,t){return["cap","wall"].map(n=>Am(new i.MeshStandardMaterial({...t,...jc(e,n)}),e,n))}function Am(i,e,t="all"){let n=jc(e,t);if(!n.polygonOffset)return i;let r=i.onBeforeCompile,s=i.customProgramCacheKey();return i.onBeforeCompile=function(o,a){r?.call(this,o,a),this.polygonOffset=!a?.capabilities?.logarithmicDepthBuffer;let c="#include <logdepthbuf_fragment>";if(!o.fragmentShader.includes(c))throw Error("Unsupported copper depth shader.");o.fragmentShader=o.fragmentShader.replace(c,c+`
#ifdef USE_LOGDEPTHBUF
 gl_FragDepth = clamp(gl_FragDepth + `+(n.polygonOffsetUnits*4/16777215).toPrecision(12)+`, 0.0, 1.0);
#endif`)},i.customProgramCacheKey=()=>s+"|copper-log-depth-v1:"+e+":"+t,i}var QM=i=>i&&typeof i=="object"&&!Array.isArray(i)?i.quoted:i,wm=i=>Array.isArray(i)?String(QM(i[0])):"",NI=(i,e)=>Array.isArray(i)?i.find(t=>wm(t)===e):void 0,ux=i=>["F.SilkS","B.SilkS"].includes(QM(NI(i,"layer")?.[1]));function $M(i){let e=[i[0]];for(let t of i.slice(1)){let n=wm(t);if(["version","generator","layers"].includes(n)||ux(t)&&n.startsWith("gr_"))e.push(t);else if(n==="footprint"){let r=t.filter((s,o)=>o<2||["at","layer","uuid","tstamp"].includes(wm(s))||ux(s)&&["fp_line","fp_arc","fp_rect","fp_circle","fp_poly","fp_text","fp_curve","property"].includes(wm(s)));r.some(s=>ux(s))&&e.push(r)}}return e}function eS(i,e,t=2048,n=!1){if(![i,e,t].every(Number.isFinite)||i<=0||e<=0||t<1)return null;let r=Math.min(2048,t),s=n?524288:1048576,o=Math.min(16,r/i,r/e,Math.sqrt(s/i/e)),a=Math.max(1,Math.floor(i*o)),c=Math.max(1,Math.floor(e*o));return{width:a,height:c,scale:Math.min(a/i,c/e),pixels:a*c,maxPixels:s}}function Rm(i,e,t,n,r,s){let o=c=>({x:(c.x-t.minX)*n.width/(t.maxX-t.minX),y:(c.y-t.minY)*n.height/(t.maxY-t.minY)}),a=n.scale;if(i.clearRect(0,0,n.width,n.height),i.save(),r?.length){i.beginPath();for(let c of r)c.forEach((l,u)=>{let h=o({x:l[0],y:l[1]});u?i.lineTo(h.x,h.y):i.moveTo(h.x,h.y)}),i.closePath();i.clip("evenodd")}for(let c of e){if(i.save(),i.strokeStyle=i.fillStyle="#f2efda",i.lineWidth=Math.max(.6,(c.width||.15)*a),i.lineCap=i.lineJoin="round",c.type==="text"){let l=o(c),u=(c.fontHeight||c.size||1)*a;i.translate(l.x,l.y),i.rotate((c.angle||0)*Math.PI/180),(c.mirror||c.mirrored)&&i.scale(-1,1),i.font=`${c.bold?"bold ":""}${c.italic?"italic ":""}${u*4/3}px Arial,sans-serif`,i.textAlign=c.align||"center",i.textBaseline=c.baseline||"middle",c.fontWidth&&c.fontHeight&&i.scale(c.fontWidth/c.fontHeight,1),String(c.text||"").split(`
`).forEach((h,d,m)=>i.fillText(h,0,(d-(m.length-1)/2)*u*(c.lineSpacing||1.5))),i.restore();continue}if(i.beginPath(),c.type==="arc"){let l=s?.(c.start,c.mid,c.end);if(l){let u=o(l);i.arc(u.x,u.y,l.r*a,l.start,l.end,l.ccw)}}else if(c.type==="circle"){let l=o(c);i.arc(l.x,l.y,c.r*a,0,2*Math.PI)}else{for(let[l,u]of(c.points||[]).entries()){let h=o(u);l?i.lineTo(h.x,h.y):i.moveTo(h.x,h.y)}c.type==="polygon"&&i.closePath()}c.fill&&i.fill(),c.stroke!==!1&&i.stroke(),i.restore()}i.restore()}function hx(i,e,t,n,r,s,o=.2){e.updateMatrixWorld();let a=[];for(let y of[-1,1])for(let f of[-1,1])for(let p of[-1,1])a.push(new i.Vector3(p,f,y).unproject(e));let c=[];for(let y=0;y<8;y++)for(let f of[1,2,4]){let p=y^f;if(p<y)continue;let v=a[y],b=a[p],x=b.z-v.z;if(Math.abs(x)<1e-12)continue;let _=(t-v.z)/x;_>=0&&_<=1&&c.push({x:v.x+(b.x-v.x)*_+r,y:s-v.y-(b.y-v.y)*_})}if(!c.length)return null;let l=Math.max(n.minX,Math.min(...c.map(y=>y.x))),u=Math.min(n.maxX,Math.max(...c.map(y=>y.x))),h=Math.max(n.minY,Math.min(...c.map(y=>y.y))),d=Math.min(n.maxY,Math.max(...c.map(y=>y.y)));if(u-l<1e-6||d-h<1e-6)return null;let m=(u-l)*o,g=(d-h)*o;return{minX:Math.max(n.minX,l-m),maxX:Math.min(n.maxX,u+m),minY:Math.max(n.minY,h-g),maxY:Math.min(n.maxY,d+g)}}function tS(i,e,t=4096,n=!1){if(![i,e,t].every(Number.isFinite)||i<=0||e<=0||t<1)return null;let r=Math.min(n?1024:2048,t),s=n?1048576:4194304,o=Math.min(r/i,r/e,Math.sqrt(s/i/e)),a=Math.max(1,Math.floor(i*o)),c=Math.max(1,Math.floor(e*o));return{width:a,height:c,scale:Math.min(a/i,c/e),pixels:a*c,maxPixels:s}}function nS(i,{camera:e,document:t,bounds:n,centerX:r,centerY:s,graphics:o,resources:a,invalidate:c,arcThrough:l,setTimer:u=setTimeout,clearTimer:h=clearTimeout,onError:d=()=>{}}){let m=[],g=!1,y=null,f=null,p=!1,v=0;function b(_){_.crop=null,_.scale=null,_.mesh.material.map=_.base,_.mesh.position.set(0,0,_.z),_.mesh.scale.set(1,1,1)}function x(){if(y=null,!(g||p)){if(t.hidden){f=null;return}for(let _ of m){if(!_.mesh.visible||!_.mesh.parent?.visible||(_.front?e.position.z<=_.z:e.position.z>=_.z))continue;let T=hx(i,e,_.z,n,r,s);if(!T)continue;let w=T.maxX-T.minX,A=T.maxY-T.minY,E=tS(w,A,o.maxDimension,o.constrained);if(E)try{let M=Math.floor(Math.min(o.constrained?1024:2048,o.maxDimension));_.texture||(_.canvas.width=_.canvas.height=M);let P=_.canvas.getContext("2d");if(!P)continue;P.clearRect(0,0,M,M),Rm(P,_.primitives,T,E,_.clips,l),v++,_.texture||(_.texture=a.track(new i.CanvasTexture(_.canvas)),_.texture.colorSpace=i.SRGBColorSpace,_.texture.anisotropy=_.base.anisotropy),_.texture.repeat.set(E.width/M,E.height/M),_.texture.offset.set(0,1-E.height/M),_.texture.needsUpdate=!0,_.mesh.material.map=_.texture,_.crop=T,_.scale=E.scale,_.mesh.scale.set(w/(n.maxX-n.minX),A/(n.maxY-n.minY),1),_.mesh.position.set((T.minX+T.maxX)/2-r,s-(T.minY+T.maxY)/2,_.z)}catch(M){b(_),d(M)}}c()}}return{add(_,T,w,A){m.push({mesh:_,primitives:T,clips:w,front:A,z:_.position.z,base:_.material.map,canvas:t.createElement("canvas"),texture:null})},sync({moving:_=!1}={}){if(g)return;for(let A of m)A.z=A.mesh.position.z;if(_){y!==null&&h(y),y=null;for(let A of m){if(A.crop){let E=hx(i,e,A.z,n,r,s,0),M=A.crop;(!E||E.minX<M.minX||E.maxX>M.maxX||E.minY<M.minY||E.maxY>M.maxY)&&b(A)}A.mesh.material.map=A.crop?A.texture:A.base}p=!0,f=null;return}p=!1;for(let A of m){let E=A.crop?A.texture:A.base;A.mesh.material.map!==E&&(A.mesh.material.map=E)}e.updateMatrixWorld();let T=[...e.matrixWorld.elements,...e.projectionMatrix.elements,...m.flatMap(A=>[A.mesh.visible&&A.mesh.parent?.visible?1:0,A.z])];if(f&&T.every((A,E)=>Math.abs(A-f[E])<=1e-5*Math.max(1,Math.abs(A),Math.abs(f[E]))))return;f=T;let w=!1;for(let A of m){if(!A.mesh.visible||!A.mesh.parent?.visible||(A.front?e.position.z<=A.z:e.position.z>=A.z))continue;let E=hx(i,e,A.z,n,r,s,0),M=A.crop;if(!(E&&M&&E.minX>=M.minX&&E.maxX<=M.maxX&&E.minY>=M.minY&&E.maxY<=M.maxY)){b(A),w=!0;continue}let N=tS(E.maxX-E.minX,E.maxY-E.minY,o.maxDimension,o.constrained);N&&N.scale>A.scale*1.5&&(w=!0)}w&&y===null&&(y=u(x,100))},stats:()=>({repaints:v,moving:p,pending:y!==null,detailTextures:m.filter(_=>_.texture).length}),dispose(){if(!g){g=!0,y!==null&&h(y),y=null;for(let _ of m)b(_),_.canvas.width=_.canvas.height=1;m.length=0}}}}var LI=nE(Qs),Cm=i=>Number.parseInt(globalThis.KiCadLayerColors.hexFor(i).slice(1),16),OI=`
  :host{display:block;width:100%;height:100%;container-type:inline-size;font:12px/1.4 system-ui,-apple-system,"Segoe UI",sans-serif;
    --ink:#e6e9ef;--surface:#151820;--bar:#1e2128;--border:#343944;--accent:#91b9ff;
    --muted:#9ca5b5;--button:#292d36;--button-border:#343944;--button-ink:#e6e9ef;
    --hint:#1e2128e8;--panel:#1e2128f2;--menu:#252a34;--notice:#1e2128;color:var(--ink);color-scheme:dark;--tools-bottom:58px}
  :host([data-theme="light"]){--ink:#252c38;--surface:#e7ebf1;--bar:#fff;--border:#d9dee7;
    --accent:#336ac2;--muted:#616d80;--button:#edf0f5;--button-border:#d9dee7;--button-ink:#252c38;
    --hint:#ffffffed;--panel:#fffffff2;--menu:#fff;--notice:#fff;color-scheme:light}
  *{box-sizing:border-box}.shell{display:flex;flex-direction:column;width:100%;height:100%;min-height:0;background:var(--surface)}
  .bar{display:flex;align-items:center;gap:6px;min-height:40px;padding:5px 10px;background:var(--bar);border-bottom:1px solid var(--border);flex-wrap:nowrap;flex-shrink:0;min-width:0}
  .title{font-size:10px;font-weight:650;letter-spacing:.07em;color:var(--muted);white-space:nowrap}.detail{font-size:11px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted)}.spacer{flex:1;min-width:0}
  button,select{background:var(--button);border:1px solid var(--button-border);color:var(--button-ink);padding:4px 8px;border-radius:5px;font:500 11px/1.4 system-ui;min-height:28px;cursor:pointer;flex-shrink:0}
  select{color-scheme:dark}select option{background:var(--menu);color:var(--ink)}select option:disabled{color:var(--muted)}:host([data-theme="light"]) select{color-scheme:light}
  button:hover,select:hover{border-color:var(--accent)}button:focus-visible,select:focus-visible,input:focus-visible,summary:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
  .bar button{display:inline-flex;align-items:center;justify-content:center;gap:5px;background:transparent;border-color:transparent}.bar button:hover,.bar button[aria-expanded=true]{background:var(--button);border-color:var(--button-border)}.bar svg{width:15px;height:15px;flex-shrink:0}.view-select{max-width:105px;background:transparent}.bar .divider{width:1px;height:18px;background:var(--border);flex-shrink:0}
  label{display:flex;align-items:center;gap:7px;white-space:nowrap;color:var(--muted);font-size:11px}input{accent-color:var(--accent)}.visibility-options{position:absolute;right:10px;top:10px;z-index:6;width:min(260px,calc(100% - 20px));max-height:calc(100% - 20px);overflow:auto;padding:12px;background:var(--menu);border:1px solid var(--border);border-radius:8px;box-shadow:0 8px 24px #0004;display:grid;gap:12px}.visibility-options[hidden]{display:none}.visibility-options fieldset{min-width:0;margin:0;padding:0;border:0;display:grid;gap:9px}.visibility-options fieldset+fieldset{border-top:1px solid var(--border);padding-top:12px}.visibility-options legend{padding:0 0 8px;color:var(--muted);font-size:10px;font-weight:650;letter-spacing:.06em;text-transform:uppercase}.visibility-options label{white-space:normal;min-width:0}.visibility-options select{min-width:0;width:130px;max-width:65%;margin-left:auto;flex-shrink:1}.visibility-options label>span{min-width:0}.visibility-options{overscroll-behavior:contain;scrollbar-gutter:stable}.display-heading{position:sticky;top:-12px;z-index:1;margin:-12px -12px 0;padding:10px 12px;background:var(--menu);border-bottom:1px solid var(--border)}.visibility-options input{width:16px;height:16px;margin:0}.display-heading{display:flex;align-items:center;justify-content:space-between;font-weight:600}.display-heading button{min-height:24px;padding:1px 6px}.quality-help{margin:0;color:var(--muted);font-size:10px;line-height:1.5}
  .stage{position:relative;flex:1;min-height:0;overflow:hidden}.canvas{position:absolute;inset:0}.canvas canvas{display:block;width:100%;height:100%}
  .hint{padding:4px 10px;color:var(--muted);background:var(--bar);font-size:10px;border-top:1px solid var(--border);flex-shrink:0}
  .inspector{position:absolute;right:12px;bottom:12px;width:min(280px,45%);max-height:50%;overflow:auto;background:var(--panel);border:1px solid var(--border);border-radius:7px;padding:10px;box-shadow:0 8px 28px #0005}
  .inspector[hidden],.menu[hidden]{display:none}.inspector h2{font-size:13px;margin:0 0 6px;color:var(--accent)}.inspector dl{display:grid;grid-template-columns:auto 1fr;gap:3px 8px;margin:0}.inspector dt{color:var(--muted)}.inspector dd{margin:0;overflow-wrap:anywhere}
  .menu{position:absolute;z-index:4;display:grid;gap:3px;padding:5px;border:1px solid var(--border);border-radius:5px;background:var(--menu);box-shadow:0 7px 25px #0005}
  .notice{padding:3px 9px;background:var(--notice);color:var(--muted);font-size:10px;border-top:1px solid var(--border);flex-shrink:0}.notice details{display:inline;margin-left:8px}.notice summary{display:inline;cursor:pointer;color:var(--accent)}.notice details[open]{display:block;margin:6px 0 0}.notice ul{max-height:120px;overflow:auto;margin:6px 0;padding-left:16px;line-height:1.6}.quality-notice{position:absolute;left:12px;right:12px;top:10px;z-index:7;padding:10px 12px;border:1px solid #bf725c;border-radius:7px;background:var(--panel);color:var(--ink);font-size:12px;max-width:560px;max-height:calc(100% - 20px);overflow:auto}.quality-notice[hidden]{display:none}.quality-notice button{margin:6px 0 0 8px}
  button[aria-pressed=true]{border-color:var(--accent);color:var(--accent)}.measurement-panel{position:absolute;bottom:10px;left:10px;z-index:5;width:min(350px,calc(100% - 20px));padding:10px 12px;border:1px solid var(--border);border-radius:8px;background:var(--panel);box-shadow:0 4px 18px #0003;display:grid;gap:6px;max-height:calc(100% - 20px);overflow:auto;overscroll-behavior:contain}.measurement-panel[hidden],.measurement-label[hidden]{display:none}.measurement-heading{display:flex;align-items:center;gap:6px}.measurement-heading strong{font-size:12px;margin-right:auto}.measurement-panel output{font:600 18px/1.3 system-ui;color:var(--ink);font-variant-numeric:tabular-nums}.measurement-panel small{color:var(--muted);font-size:10px}.measurement-panel .measurement-tools{display:flex;align-items:center;gap:6px}.measurement-panel .measurement-tools select{min-width:0;flex:1}.measurement-panel p{margin:0;color:var(--muted);font-size:11px}.measurement-label{position:absolute;z-index:4;pointer-events:none;padding:4px 7px;border:1px solid #c5a35f;border-radius:5px;background:var(--panel);color:var(--ink);font:600 12px/1.4 system-ui;white-space:nowrap;box-shadow:0 2px 8px #0004}:host([data-measuring=true]) .hint{display:none}
  @media(max-width:700px){.detail{display:none}.bar{gap:4px;padding-inline:6px}.hint{display:none}.inspector{width:min(260px,65%)}}@media(max-width:380px){.title{display:none}.bar{gap:2px}.bar button{padding-inline:5px}.view-select{max-width:90px}}
  @media(pointer:coarse){button,select{min-height:40px}.bar{min-height:50px}.visibility-options label{min-height:32px}}
  :host([data-embedded="true"]) .shell{position:relative}
  :host([data-embedded="true"]) .bar{position:absolute;z-index:5;top:12px;left:12px;right:auto;max-width:calc(100% - 24px);flex-wrap:wrap;gap:3px;min-height:36px;padding:4px;border:1px solid var(--border);border-radius:9px;box-shadow:0 4px 16px #0002;background:var(--bar)}
  :host([data-embedded="true"]) .bar .title,:host([data-embedded="true"]) .bar .detail,:host([data-embedded="true"]) .bar .spacer,:host([data-embedded="true"]) .bar .divider,:host([data-embedded="true"]) .bar .fit-action,:host([data-embedded="true"]) .hint,:host([data-embedded="true"]) .notice{display:none}
  :host([data-embedded="true"]) .bar button{min-height:28px;padding:5px 7px}
  :host([data-embedded="true"]) .visibility-options{top:var(--tools-bottom);max-height:calc(100% - var(--tools-bottom) - 10px)}
  :host([data-embedded="true"]) .quality-notice{top:calc(var(--tools-bottom) + 4px);max-height:calc(100% - var(--tools-bottom) - 16px)}
  .bar{gap:3px;min-height:34px;height:34px;padding:2px 5px}.bar .title,.bar .detail,.bar .spacer,.bar .divider{display:none}
  .bar button,.bar select,.bar summary{appearance:none;box-sizing:border-box;min-height:28px;height:28px;margin:0;padding:3px 6px;font:600 11px/1 system-ui}
  .bar .view-select{max-width:86px}.bar .tools-more{position:relative;flex:0 0 auto}.bar .tools-more>summary{display:inline-flex;align-items:center;justify-content:center;min-width:42px;border:1px solid transparent;border-radius:5px;color:var(--button-ink);cursor:pointer;list-style:none}.bar .tools-more>summary::-webkit-details-marker{display:none}.bar .tools-more[open]>summary{background:var(--button);border-color:var(--button-border)}
  .bar .tools-panel{position:absolute;z-index:9;right:0;top:calc(100% + 4px);display:grid;gap:4px;width:min(230px,calc(100cqw - 12px));max-height:var(--tools-panel-height,240px);overflow:auto;overscroll-behavior:contain;padding:6px;border:1px solid var(--border);border-radius:7px;background:var(--menu);box-shadow:0 8px 24px #0004}
  .bar .tools-panel>button{justify-content:flex-start;width:100%;min-height:30px;height:30px}.bar .tools-panel .explode-control{display:grid!important;grid-template-columns:auto 1fr auto;gap:5px;min-width:0;white-space:nowrap}.bar .tools-panel .explode-control input{width:100%!important;min-width:0!important}
  :host([data-embedded="true"]) .bar{top:6px;left:6px;right:auto;max-width:calc(100% - 12px);min-height:34px;height:34px;padding:2px 4px;flex-wrap:nowrap}
  :host([data-embedded="true"]) .bar button,:host([data-embedded="true"]) .bar select,:host([data-embedded="true"]) .bar summary{min-height:28px;height:28px;padding:3px 5px}
  :host([data-embedded="true"]) .bar .tools-panel{left:0;right:auto}
  @media(pointer:coarse){.bar{min-height:34px;height:34px}.bar button,.bar select,.bar summary{min-height:28px;height:28px}}

`;function dx(i={}){let e=["arcs","pads","vias","tracks","fills","polygons","bodies","silkscreen"],t=[...new Set((Array.isArray(i.hiddenTypes)?i.hiddenTypes:[]).filter(r=>typeof r=="string"&&r.length<=40).slice(0,64))],n=["top","bottom"].includes(i.side)?i.side:"all";return{hiddenTypes:t,side:n,supportedTypes:e,unsupportedTypes:t.filter(r=>!e.includes(r)),visible(r,s){return!t.includes(r)&&!(n==="top"&&s?.startsWith("B."))&&!(n==="bottom"&&s?.startsWith("F."))}}}function ed(i,e){let t=new Tr;return i.forEach((n,r)=>{let[s,o]=e(n);r===0?t.moveTo(s,o):t.lineTo(s,o)}),t}function DI(i,e){let t=i.outlineLoops?.filter(s=>s.length>=3)||[],n=t[0]||[[i.bounds.minX,i.bounds.minY],[i.bounds.maxX,i.bounds.minY],[i.bounds.maxX,i.bounds.maxY],[i.bounds.minX,i.bounds.maxY]],r=new Fi;ed(n,e).getPoints().forEach((s,o)=>{o===0?r.moveTo(s.x,s.y):r.lineTo(s.x,s.y)});for(let s of t.slice(1))r.holes.push(ed(s,e));return r}function $h(i,e,t,n,r,s){if(!n.length)return null;let o=new $r(e,t,n.length),a=new St;return n.forEach((c,l)=>{r(a,c),a.updateMatrix(),o.setMatrixAt(l,a.matrix)}),o.instanceMatrix.needsUpdate=!0,o.userData.records=n,o.userData.identity=s,i.add(o),o}function FI(i,e,t={}){t||={};let n=tx(t.appearance??"realistic"),r=t.dark!==!1,s=t.sourceSnapshot?(t.sourceParser||globalThis.KiCadDesignDiff).preparedFile(t.sourceSnapshot,t.sourceKey,e):globalThis.KiCadDesignDiff.parse(e),o=HM(s),a=BE(e,s,{zonePoints:!1}),c=eM(s),l=a.pads.map(C=>({...C,...c.get(C.id)})),u=[...a.geometryWarnings||[]];if(!a?.bounds||!Number.isFinite(a.width)||!Number.isFinite(a.height))throw new Error("SPIKE could not parse this PCB layout.");let h=document.createElement("div");h.dataset.theme=r?"dark":"light",h.dataset.embedded=t.embedded===!0&&typeof t.onDiagnostics=="function"?"true":"false";let d=h.attachShadow({mode:"open"}),m=document.createElement("style");m.textContent=OI;let g=document.createElement("div");g.className="shell";let y=document.createElement("div");y.className="bar",y.setAttribute("role","toolbar"),y.setAttribute("aria-label","3D tools");let f=document.createElement("div");f.className="stage";let p=document.createElement("div");p.className="canvas";let v=document.createElement("div");v.className="hint",v.textContent="Drag to orbit \xB7 right-drag to pan \xB7 wheel to zoom \xB7 click to inspect";let b=document.createElement("div");b.className="inspector",b.hidden=!0;let x=document.createElement("div");x.className="menu",x.hidden=!0;let _=document.createElement("div");_.className="notice",_.textContent="Material preview \xB7 mask openings follow saved pad layer flags \xB7 footprint stand-ins where linked models are unavailable.";let T=document.createElement("div");T.className="quality-notice",T.hidden=!0,T.setAttribute("role","status"),f.append(T),f.append(p,b,x),g.append(y,f,v,_),d.append(m,g),i.append(h);let w=document.createElement("strong");w.className="title",w.textContent="3D VIEW";let A=document.createElement("span");A.className="detail",A.textContent=`${a.width.toFixed(1)} \xD7 ${a.height.toFixed(1)} mm \xB7 ${a.components.length} parts \xB7 ${a.tracks.length} tracks`;let E=document.createElement("span");E.className="spacer";function M(C,X,le,Te=C){let Ae=document.createElement("button");if(Ae.type="button",Ae.title=Te,Ae.setAttribute("aria-label",Te),le){let Ge=document.createElementNS("http://www.w3.org/2000/svg","svg"),je=document.createElementNS("http://www.w3.org/2000/svg","path");Ge.setAttribute("viewBox","0 0 24 24"),Ge.setAttribute("fill","none"),Ge.setAttribute("stroke","currentColor"),Ge.setAttribute("stroke-width","1.6"),Ge.setAttribute("stroke-linecap","round"),Ge.setAttribute("stroke-linejoin","round"),Ge.setAttribute("aria-hidden","true"),je.setAttribute("d",le),Ge.append(je),Ae.append(Ge)}let Pe=document.createElement("span");return Pe.textContent=C,Ae.append(Pe),Ae.addEventListener("click",()=>{X(),ye()}),y.append(Ae),Ae}let P=document.createElement("section");P.className="visibility-options",P.id="display-options",P.hidden=!0,P.setAttribute("aria-label","3D display settings"),f.append(P);let N=document.createElement("div");N.className="display-heading",N.append(document.createTextNode("Display"));let L=document.createElement("button");L.type="button",L.textContent="\xD7",L.title="Close display settings",L.setAttribute("aria-label","Close display settings"),L.onclick=()=>W(!1,!0),N.append(L);let D=document.createElement("fieldset"),$=document.createElement("legend");$.textContent="Rendering",D.append($);let U=document.createElement("fieldset"),I=document.createElement("legend");I.textContent="Visible geometry",U.append(I),P.append(N,D,U);function V(){if(g.clientHeight&&h.style.setProperty("--tools-panel-height",Math.max(72,Math.min(280,g.clientHeight-50))+"px"),h.dataset.embedded!=="true")return;let C=f.getBoundingClientRect(),X=y.getBoundingClientRect(),le=Math.min(Math.max(8,Math.ceil(X.bottom-C.top+6)),Math.max(8,C.height-180));h.style.setProperty("--tools-bottom",le+"px")}function W(C,X=!1){C&&(V(),typeof ro<"u"&&(ro.open=!1)),P.hidden=!C,ya.setAttribute("aria-expanded",String(C)),X&&ya.focus()}function Q(C,X,le){let Te=document.createElement("label"),Ae=document.createElement("input");return Ae.type="checkbox",Ae.checked=X,Ae.addEventListener("change",()=>{le(Ae.checked),ye()}),Te.append(Ae,document.createTextNode(C)),U.append(Te),Ae}y.append(w,A,E);let se="pocket-kivi:3d-quality:v1",oe="balanced",ge=!1;try{let C=localStorage.getItem(se);["low","balanced","high"].includes(C)&&(oe=C,ge=!0)}catch{}t.quality&&(oe=bm(t.quality));let O=document.createElement("label");O.className="quality-label";let S=document.createElement("span");S.textContent="Quality";let R=document.createElement("select");R.setAttribute("aria-label","3D rendering quality"),R.title="Photoreal Fast: studio stage, reflections and cached shadows, without screen-space effects. Presentation: studio stage, dense occlusion and enhanced shadows. High: ambient occlusion and enhanced antialiasing. Balanced: responsive studio lighting. Low: reduced memory.";for(let[C,X]of[["low","Low"],["balanced","Balanced"],["high","High"],["photoreal-fast","Photoreal Fast"],["presentation","Presentation"]]){let le=document.createElement("option");le.value=C,le.textContent=X,R.append(le)}R.value=oe,O.append(S,R);let z=(a.bounds.minX+a.bounds.maxX)/2,Y=(a.bounds.minY+a.bounds.maxY)/2,K=([C,X])=>[C-z,Y-X],re=([C,X])=>[C,-X],de=dv(),te=(C,X)=>de.get(JSON.stringify([C.outline,C.drill||null,X]),()=>new Ys(ne(C),{depth:X,bevelEnabled:!1,curveSegments:8})),ne=C=>{let X=new Fi;return ed(C.outline,re).getPoints().forEach((le,Te)=>Te?X.lineTo(le.x,le.y):X.moveTo(le.x,le.y)),C.drill&&X.holes.push(ed(C.drill,re)),X},H=Math.max(1,a.width),_e=Math.max(1,a.height),me=Math.max(H,_e),be=a.stackup?.filter(C=>Number.isFinite(C.thickness)).reduce((C,X)=>C+X.thickness,0)||1.6,he=be/2,Ne=-he,Me=new oi;Me.background=new Be(r?1382432:15199217);let Z=null,B=XM({onChange:()=>Z?.invalidate()}),k=new jt(45,1,.1,Math.max(3e3,me*30));k.up.set(0,0,1);let F=new fs({antialias:!1,logarithmicDepthBuffer:!0,alpha:!1,powerPreference:"high-performance"}),G=F.getContext(),j=TM({maxTextureSize:F.capabilities.maxTextureSize,maxRenderbufferSize:G.getParameter(G.MAX_RENDERBUFFER_SIZE),deviceMemory:globalThis.navigator?.deviceMemory,hardwareConcurrency:globalThis.navigator?.hardwareConcurrency,floatTargets:F.extensions.has("EXT_color_buffer_float"),android:/Android/i.test(globalThis.navigator?.userAgent||"")});Z=yM(G);let ee=(j.constrained?32:j.premium?96:64)*1024*1024,ie=(j.constrained?32:64)*1024*1024,ce={budgetBytes:ie,retainedBytes:0,renderedContours:0,vertices:0,rejected:0},fe=(j.constrained?16:j.premium?64:32)*1024*1024,ue=yv(j.constrained?8192:32768),Ee=gv(j.constrained,a.components.length);!ge&&!t.quality&&(oe=j.defaultQuality);let Se=!0,De=!1,ze=0,Je=null,Fe=oe,Xe=!1;function ae(){Me.background.setHex(h.dataset.theme==="dark"?1513237:16250350)}let Le=()=>p.clientWidth>0&&p.clientHeight>0,xe=ym({request:C=>requestAnimationFrame(C),cancel:C=>cancelAnimationFrame(C),render:SS,canRender:()=>Se&&!De&&!document.hidden&&Le(),state:{documentVisible:!document.hidden,hasSize:Le()}});function ye(){Se&&(xe.setState({documentVisible:!document.hidden,hasSize:Le()}),xe.invalidate())}function Ue(C,X=!1){T.replaceChildren(document.createTextNode(C)),T.hidden=!1;let le=document.createElement("button");if(le.type="button",le.textContent="Dismiss",le.onclick=()=>{T.hidden=!0},T.append(le),X){let Te=document.createElement("button");Te.type="button",Te.textContent="Retry graphics",Te.onclick=()=>F.forceContextRestore(),T.append(Te)}}function Oe(){if(Je){for(let C of Je.passes)C.dispose?.(),C instanceof zc&&(C.gtaoMaterial.dispose(),C.blendMaterial.dispose(),C.depthTexture?.dispose());Je.composer.dispose(),Je=null}}function st(){if(Oe(),Z.invalidate(),Fe==="low")return;let C=["high","presentation"].includes(Fe)&&xt!=="translucent"&&Ye.get()===0,X=F.extensions.has("EXT_color_buffer_float");if(C&&!X)throw Error("Floating-point render targets are unavailable.");let le=new on(1,1,{type:X?Hn:ci,depthBuffer:!0,stencilBuffer:!1}),Te=new jp(F,le),Ae=[];Je={composer:Te,passes:Ae,occlusion:C};let Pe=new qp(Me,k);if(Ae.push(Pe),C){let $e=new zc(Me,k,1,1,void 0,AM(be,Fe));IM($e.normalMaterial),$e.blendIntensity=.65,$e.updatePdMaterial({radius:4,rings:2,samples:Fe==="presentation"?24:12});let rt=$e.overrideVisibility.bind($e);$e.overrideVisibility=()=>{rt(),Me.traverse(ke=>{(Array.isArray(ke.material)?ke.material:[ke.material]).some(et=>et&&(et.transparent||et.depthTest===!1))&&(ke.visible=!1)})},Ae.push($e)}let Ge=new Jp,je=new $p(1,1);for(let $e of[je.areaTexture,je.searchTexture])$e.image?.addEventListener?.("load",()=>{Z.invalidate(),ye()},{once:!0});Ae.push(Ge,je);for(let $e of Ae)Te.addPass($e)}function pt(C){Oe(),Fe="balanced",R.value=Fe,h.dataset.quality=Fe,Xe=!1,F.setRenderTarget(null),Ti.apply(!1),ae(),Ue(C),gs()}function lt(C,X=!0){if(Fe=bm(C),R.value=Fe,h.dataset.quality=Fe,T.hidden=!0,Xe=!1,ae(),X)try{localStorage.setItem(se,Fe==="presentation"?"high":Fe==="photoreal-fast"?"balanced":Fe)}catch{}Ti.apply(["presentation","photoreal-fast"].includes(Fe)&&xt!=="translucent",{fast:Fe==="photoreal-fast"}),F.shadowMap.enabled=Fe!=="low"&&xt!=="translucent"&&Ye.get()===0,F.shadowMap.needsUpdate=!0;try{st()}catch{pt("Enhanced quality is unavailable on this graphics device. Balanced rendering is active.")}return ga(),gs(),ye(),Fe}R.onchange=()=>lt(R.value),F.debug.onShaderError=()=>{Xe=!0},F.outputColorSpace=wt,F.toneMapping=qo,F.toneMappingExposure=1,F.shadowMap.enabled=!0,F.shadowMap.type=Au,F.shadowMap.autoUpdate=!1,F.shadowMap.needsUpdate=!0;function We(){if(!F.extensions.has("EXT_color_buffer_float"))return null;let C,X;try{return C=new Gp,X=new ra(F),X.fromScene(C,.04,.1,100)}catch{return Ue("Studio reflections are unavailable on this graphics device. Direct lighting remains active."),null}finally{C?.dispose(),X?.dispose()}}let Qe=We();Me.environment=Qe?.texture||null,Me.environmentIntensity=.65,p.append(F.domElement);let Ie=new LI(k,F.domElement),tt=!1,at=!1,_t=null,Xn=null,ei=()=>{tt=!0,at=!0,_t!==null&&clearTimeout(_t),_t=null},mr=()=>{_t!==null&&clearTimeout(_t),_t=setTimeout(()=>{_t=null,at=!1,ye()},100)};Ie.addEventListener("start",ei),Ie.addEventListener("end",mr),Ie.addEventListener("change",ye),Ie.enableDamping=!1,Ie.dampingFactor=.1,Ie.screenSpacePanning=!0,Ie.minDistance=.1,Ie.maxDistance=me*8,Me.add(new Xo(16777215,.35));for(let C of PM){let X=new as(C.color,C.intensity);Math.abs(C.z)===1&&(X.castShadow=!0,X.shadow.mapSize.set(1024,1024),X.shadow.camera.left=X.shadow.camera.bottom=-me,X.shadow.camera.right=X.shadow.camera.top=me,X.shadow.camera.near=.1,X.shadow.camera.far=me*5,X.shadow.normalBias=.02,X.shadow.bias=-1e-4),X.position.set(me*C.x,me*C.y,me*C.z),Me.add(X)}let Ti=SM(Wn,{scene:Me,renderer:F,extent:me,bottom:Ne,constrained:j.constrained}),Fn=new Dt;Me.add(Fn);let ui=new Map,dn=[],Un=dx(),to=[],kr=(C,X,le)=>(to.push({mesh:C,type:X,layer:le}),C.visible=Un.visible(X,le),C),td=new Set(s.filter(C=>Array.isArray(C)&&C[0]==="arc").map(C=>{let X=C.find(le=>Array.isArray(le)&&["uuid","tstamp"].includes(le[0]))?.[1];return typeof X=="object"?X?.quoted:X}).filter(Boolean)),Pm=C=>td.has(C.id)||td.has(C.id?.replace(/:\d+$/,""))||/^track-\d+:\d+$/.test(C.id||""),Im=mM(a,be).map(C=>C.name),J=YE({...a,layers:Im},s,be),pe=J.layers.map(C=>{let X=!["F.Cu","B.Cu"].includes(C.name);return{...C,internal:X,basis:X?J.savedDepths?"saved-stackup":"illustrative":"outer-surface"}}),we=new Set,Re=new Map(pe.map(C=>[C.name,!0])),ve=a.vias.filter(C=>J.viaSpans.get(C.id)?.through);ve.length<J.viaSpans.size&&u.push("Blind and buried via walls follow saved endpoint layers. Partial-depth dielectric cavities are not cut.");let He=aM(a.tracks,s),Ke;try{Ke=oM(be,J.byLayer)}catch{Ke={bottom:Ne,depth:be},u.push("Outer copper depths do not enclose a valid substrate. The nominal board envelope is shown.")}u.push(...J.warnings,...He.warnings);function it(C){let X=J.byLayer.get(C);return C==="F.Cu"||C==="B.Cu"?rM(C,be,X.thickness,X.z):{center:X.z,base:X.z-X.thickness/2,thickness:X.thickness}}let qe=null;function ft(C){return qe?C.name===qe:Re.get(C.name)&&(!C.internal||xt==="translucent"||Ye.get()>0)}let Ye=KM(Wn,{layers:pe},{maxGap:Math.max(.8,Math.min(8,me*.45/Math.max(1,pe.length-1))),componentLift:Math.max(6,Math.min(40,me*.15))}),ut=[],Nt=ZM(),At=pM(),en=[],xt="realistic",Ct=!1,ht=!1,pn=!1,Ot=!1,ti=document.createElement("label");ti.append(document.createTextNode("Appearance"));let Ai=document.createElement("select");Ai.setAttribute("aria-label","3D board appearance");for(let[C,X]of[["realistic","Realistic"],["layers","Layer colors"],["translucent","Translucent"]]){let le=document.createElement("option");le.value=C,le.textContent=X,Ai.append(le)}ti.append(Ai);let kn=document.createElement("p");kn.className="quality-help",kn.textContent="Translucent reveals copper in layer colors through the board and models. Fills stay faint; shadows and screen-space occlusion are disabled in this inspection mode. Photoreal Fast adds studio reflections and cached shadows without a visible floor, using a bounded framebuffer, without ambient occlusion or supersampling. Presentation adds enhanced shadows and screen-space effects. Both render only when needed; source model fidelity is unchanged.",D.append(ti,O,kn);function Vi(C=xt){let X=tx(C),le=xt;Ct&&xr.restore(),At.setEnabled(!1),xt=X,Ai.value=X,h.dataset.appearance=X,(qe||X==="translucent"||Ye.get()>0)&&sd();let Te=!qe&&X==="realistic"&&Ye.get()===0;for(let{mesh:Ae,role:Pe,layer:Ge,pads:je}of en){let $e=Array.isArray(Ae.material)?Ae.material:[Ae.material];if(Pe==="pads"){for(let ke of $e)ke.color.setHex(16777215);let rt=new Be;je.forEach((ke,vt)=>Ae.setColorAt(vt,rt.setHex(Te?wM(ke,Ge)?Xc.exposedCopper:Xc.coatedCopper:Cm(Ge)))),Ae.instanceColor&&(Ae.instanceColor.needsUpdate=!0)}else for(let rt of $e)rt.color.setHex(Te?Xc.coatedCopper:Cm(Ge));for(let rt of $e)rt.metalness=Te&&Pe!=="pads"?.08:pr.copper.metalness,rt.roughness=Te&&Pe!=="pads"?.52:pr.copper.roughness}for(let Ae of pe){let Pe=ui.get(Ae.name);Pe&&(Pe.visible=ft(Ae))}if(At.setEnabled(X==="translucent"),Ti.apply(["presentation","photoreal-fast"].includes(Fe)&&X!=="translucent",{fast:Fe==="photoreal-fast"}),F.shadowMap.enabled=Fe!=="low"&&X!=="translucent"&&Ye.get()===0,F.shadowMap.needsUpdate=!0,le==="translucent"!=(X==="translucent"))try{st()}catch{pt("Enhanced quality is unavailable. Balanced rendering is active.")}return qc(),Ct&&Hi(zn),t.onAppearanceChange?.(X),ye(),X}Ai.onchange=()=>Vi(Ai.value);let Bt=C=>{if(!ui.has(C)){let X=new Dt;X.name=C,Fn.add(X),ui.set(C,X)}return ui.get(C)},Yn=DI(a,K),ni=new Set,Pn=0,Bn=0,ms=0,Br=(C,X)=>{let le=!1;for(let Te=0,Ae=X.length-1;Te<X.length;Ae=Te++){let[Pe,Ge]=[X[Te],X[Ae]];Pe[1]>C[1]!=Ge[1]>C[1]&&C[0]<(Ge[0]-Pe[0])*(C[1]-Pe[1])/(Ge[1]-Pe[1])+Pe[0]&&(le=!le)}return le},fx=a.outlineLoops?.[0],px=a.outlineLoops?.slice(1)||[];for(let C of[...l,...ve.map(X=>({...X,shape:"circle",width:X.size,height:X.size,drillShape:"circle",rotation:0}))]){if(!(C.drill>0))continue;let X=pm(C);if(!X){ms++;continue}let le=(C.rotation||0)*Math.PI/180,Te=Math.cos(le),Ae=Math.sin(le),[Pe,Ge]=K(C.at);if(px.some(rt=>Br(C.at,rt)))continue;let je=X.map(([rt,ke])=>[Pe+rt*Te+ke*Ae,Ge+rt*Ae-ke*Te]),$e=JSON.stringify(je.map(rt=>rt.map(ke=>Math.round(ke*1e4)/1e4)));if(!ni.has($e)){if(Pn>=1024||Bn+je.length>1e5||!fx||!VM(je.map(([rt,ke])=>[rt+z,Y-ke]),fx,px)){ms++;continue}ni.add($e),Pn++,Bn+=je.length,Yn.holes.push(ed(je,rt=>rt))}}ms&&u.push(`${ms} drill loops could not be cut within the saved-geometry/triangulation budget.`);let In=new ct(new Ys(Yn,{depth:Ke.depth,bevelEnabled:!1,curveSegments:8}),[new Dn(pr.solderMask),new Mn(pr.substrateEdge)]);In.position.z=Ke.bottom,In.receiveShadow=!0,Ti.addCaster(In),In.userData.record={type:"Board",name:"Substrate",layer:"Edge.Cuts",id:"board"},In.userData.identity=ha("substrate","Edge.Cuts","board"),Fn.add(In),dn.push(In),At.add(In,"substrate");let nd=new ln(new ss(In.geometry,20),new Xt({color:10205100,transparent:!0,opacity:.42}));nd.position.z=Ke.bottom,Fn.add(nd);let fa=new Dt;Fn.add(fa);function qc(){let C=Math.min(1-Ye.phases().layers*.98,qe?.08:1),X=(xt==="translucent"?.12:1)*C,le=Ct&&ao.mode==="isolate"&&Wh(zn)&&!ht;for(let Te of Array.isArray(In.material)?In.material:[In.material]){let Ae=le?0:Math.min(X,Te.userData.selectionOpacityCap??1),Pe=Ae<1;Te.transparent!==Pe&&(Te.transparent=Pe,Te.needsUpdate=!0),Te.opacity=Ae,Te.depthWrite=!Pe}nd.material.opacity=Math.min(.42*C,nd.material.userData.selectionOpacityCap??1),In.castShadow=!qe&&Ye.get()===0&&Ti.enabled}let id=nS(Wn,{camera:k,document,bounds:a.bounds,centerX:z,centerY:Y,graphics:j,resources:B,invalidate:ye,arcThrough:globalThis.KiCadOwnedCanvas?.arcThrough,onError:C=>Ue("Silkscreen detail could not be refreshed: "+C.message)});if(globalThis.KiCadPCBRenderer&&globalThis.KiCadOwnedCanvas?.arcThrough)try{let C=globalThis.KiCadPCBRenderer.build($M(s),t.boardPath||"").primitives.filter(Ae=>!Ae.frame&&!Ae.hidden&&["F.SilkS","B.SilkS"].includes(Ae.layer)),X=eS(H,_e,j.maxDimension,j.constrained),le=Yn.extractPoints(8),Te=[le.shape,...le.holes].map(Ae=>Ae.map(Pe=>[Pe.x+z,Y-Pe.y]));for(let Ae of["F.SilkS","B.SilkS"]){let Pe=C.filter(ke=>ke.layer===Ae);if(!Pe.length||!X)continue;let Ge=document.createElement("canvas");Ge.width=X.width,Ge.height=X.height;let je=Ge.getContext("2d");if(!je)continue;Rm(je,Pe,a.bounds,X,Te,globalThis.KiCadOwnedCanvas.arcThrough);let $e=B.track(new ns(Ge));$e.colorSpace=wt,$e.anisotropy=Math.min(16,F.capabilities.getMaxAnisotropy());let rt=new ct(new Ar(H,_e),new Mn({map:$e,color:16777215,roughness:.85,metalness:0,side:Ae==="F.SilkS"?Jn:un,transparent:!0,alphaTest:.05,depthWrite:!1}));rt.position.z=Ae==="F.SilkS"?he+.055:Ne-.055,rt.renderOrder=1,fa.add(rt),At.add(rt,"silkscreen"),kr(rt,"silkscreen",Ae),id.add(rt,Pe,Te,Ae==="F.SilkS")}}catch(C){u.push("Saved silkscreen could not be prepared: "+C.message)}let no=new Map,rd=0;for(let C of a.vias){let X=J.viaSpans.get(C.id),le=$y({shape:"circle",width:C.size,height:C.size,drill:C.drill,drillShape:"circle"});if(!le||!X){rd++;continue}let Te=JSON.stringify([C.size,C.drill,X.zMin,X.zMax]);if(!no.has(Te)){if(no.size>=128){rd++;continue}no.set(Te,{outline:le,span:X,vias:[]})}no.get(Te).vias.push(C)}rd&&u.push(`${rd} via bodies with unsupported annuli or unknown saved spans omitted.`);let Nm=new Dt;Fn.add(Nm);for(let[C,X]of no){let le=iM(Wn,pm({drill:X.vias[0].drill,drillShape:"circle"}),X.span.zMax-X.span.zMin),Te=new Mn({color:Xc.exposedCopper,...pr.copper,side:yn,...jc("via","wall")}),Ae=$h(Nm,le,Te,X.vias,(Pe,Ge)=>{let[je,$e]=K(Ge.at);Pe.position.set(je,$e,X.span.zMin)},ha("via-barrel",X.span.through?"through":X.span.from+"-"+X.span.to,C));Ae&&(kr(Ae,"vias",X.span.through?"through":X.span.from+"-"+X.span.to),dn.push(Ae),ut.push({mesh:Ae,span:X.span}))}u.push("Outer copper uses saved plan centers/thickness (or the disclosed stackup fallback) with a 0.001 mm outward display offset; the substrate spans the outer copper inner faces. Saved zone fills are opaque zero-height display films inset by the smaller of 0.005 mm or one quarter of the copper thickness. Via bodies show the saved drill wall; plating thickness is not inferred.");let rS=no.size?lx(Wn,"via",{color:Xc.exposedCopper,...pr.copper}):null;function mx(C){if(we.has(C))return;we.add(C);let X=Cm(C),le=it(C),Te=le.center;for(let ke of["tracks","arcs"]){let vt=He.tracks.filter(Lt=>Lt.layer===C&&(Pm(Lt)?"arcs":"tracks")===ke),et=tM(Wn,vt,{world:K,z:Te,thickness:le.thickness});et.invalid&&u.push(`${C}: invalid saved track widths or positions omitted.`),et.plan?.limited&&u.push(`${C}: large track caps exceed the ${et.plan.tolerance} mm tessellation tolerance at the 128-segment display limit.`);let dt=Am(new Mn({color:X,...pr.copper,...jc("track")}),"track");for(let Lt of et.batches){let Rt=$h(Bt(C),Lt.geometry,dt,Lt.records,Lt.place,ha("copper-track",C,ke+"-"+Lt.part));Rt&&(kr(Rt,ke,C),dn.push(Rt),en.push({mesh:Rt,role:"tracks",layer:C}))}et.batches.length||dt.dispose()}let Ae=l.filter(ke=>!$E(ke)&&(ke.layer===C||ke.layers?.includes(C)||ke.layers?.includes("*.Cu"))),Pe=new Map,Ge=0;for(let ke of Ae){let vt=JSON.stringify([ke.shape,ke.width,ke.height,ke.roundrectRatio,ke.drill,ke.drillShape,ke.drillWidth,ke.drillHeight,ke.drillOffset,ke.customAnchor,ke.customPrimitives]);if(!Pe.has(vt)){let et=$y(ke);if(!et||Pe.size>=256){Ge++;continue}et.tessellation.limited&&u.push(`${C}: a pad contour retains validated geometry because the 0.0025 mm tolerance could not be met within hole-containment/display limits.`),Pe.set(vt,{outline:et,pads:[]})}Pe.get(vt).pads.push(ke)}Ge&&u.push(`${C}: ${Ge} unsupported/ambiguous pad shapes omitted; no rectangular stand-ins were substituted.`);let je=Pe.size?lx(Wn,"pad",{color:16777215,...pr.copper}):null;for(let[ke,vt]of Pe){let et=te(vt.outline,le.thickness),dt=$h(Bt(C),et,je,vt.pads,(Lt,Rt)=>{let[Wt,Ft]=K(Rt.at);Lt.position.set(Wt,Ft,le.base),Lt.rotation.z=(Rt.rotation||0)*Math.PI/180},ha("copper-pad",C,ke));dt&&(kr(dt,"pads",C),dn.push(dt),en.push({mesh:dt,role:"pads",layer:C,pads:vt.pads}))}let $e=Am(new Mn({color:X,...pr.copper,side:yn,...jc("zone")}),"zone"),rt=!1;for(let ke of o.forLayer(C)){let vt;try{let dt=Q_(Wn,ke,{world:K,triangulate:q_.triangulate,maxBytes:ie-ce.retainedBytes});vt=dt.geometry,ce.retainedBytes+=dt.bytes,ce.renderedContours++,ce.vertices+=dt.vertices}catch(dt){ce.rejected++,u.push(`${C}: saved zone ${ke.id} contour ${ke.contour}: ${dt.message}`);continue}if(!ke.filled){let dt=new es(vt,new Xt({color:X,transparent:!0,opacity:.6}));dt.position.z=Te,Bt(C).add(dt),kr(dt,"polygons",C);continue}rt=!0;let et=new ct(vt,$e);et.position.z=["F.Cu","B.Cu"].includes(C)?sM(C,le):Te,et.userData.record={id:ke.id,net:ke.net,layer:C,filled:!0,contour:ke.contour,type:"Zone"},Bt(C).add(et),kr(et,"fills",C),dn.push(et),en.push({mesh:et,role:"zone",layer:C}),At.add(et,"zone")}rt||$e.dispose();for(let[ke,vt]of no){if(vt.span.from!==C&&vt.span.to!==C)continue;let et=te(vt.outline,le.thickness),dt=$h(Bt(C),et,rS,vt.vias,(Lt,Rt)=>{let[Wt,Ft]=K(Rt.at);Lt.position.set(Wt,Ft,le.base)},ha("via-barrel",C,"annulus-"+ke));dt&&(kr(dt,"vias",C),dn.push(dt))}}for(let C of pe.filter(X=>!X.internal))mx(C.name);function sd(){let C=pe.filter(le=>le.internal&&!we.has(le.name));if(!C.length)return;let X=u.length;for(let le of C)mx(le.name),B.retain(ui.get(le.name));wi.push(...u.slice(X)),C.some(le=>le.basis==="illustrative")&&wi.push("Internal copper has saved XY coordinates and layer order; elevations are illustrative because a complete saved stackup is unavailable."),Qc()}let pa=new Dt;Fn.add(pa);let sS=hM(a),sn=$h(pa,new Wp(1,1,1,2,.06),new Mn(pr.proxy),a.components,(C,X)=>{let le=sS.get(X),[Te,Ae]=K(le?.at||X.at),Pe=X.layer?.startsWith("B.");C.position.set(Te,Ae,Pe?Ne-1.1:he+1.1),C.rotation.set(0,0,le?.rotation||0),C.scale.set(le?.width||0,le?.height||0,le?2.1:0)},ha("component","F.Fab","proxies"));sn&&(dn.push(sn),At.add(sn,"component")),sn&&(sn.castShadow=!0,sn.receiveShadow=!0);let gx=ex(a.components),od=a.components.map((C,X)=>{let le=new nt;return sn?.getMatrixAt(X,le),le}),oS=new nt().makeScale(0,0,0),zr=new Map,Kc=new Set,Zc=null,ma=a.components.map(()=>!0);function ad(){let C=new nt;a.components.forEach((X,le)=>{C.copy(od[le]),C.elements[14]+=Ye.componentOffset(X.layer?.startsWith("B.")?"B.Cu":"F.Cu"),sn?.setMatrixAt(le,ma[le]&&Un.visible("bodies",X.layer)&&!Kc.has(le)?C:oS)}),sn&&(sn.instanceMatrix.needsUpdate=!0,sn.computeBoundingSphere());for(let[X,le]of zr)le.visible=ma[X]&&Un.visible("bodies",a.components[X].layer),Ye.component(le,a.components[X].layer?.startsWith("B.")?"B.Cu":"F.Cu");F.shadowMap.needsUpdate=!0,ye()}let wi=Array.isArray(t.assetWarnings)?t.assetWarnings.filter(C=>typeof C=="string").slice(0,48).map(C=>C.slice(0,500)):[];o.stats().unfilled&&wi.push(`${o.stats().unfilled} zones have no saved copper fill; only their boundaries are shown.`),(o.stats().omitted||o.stats().invalid)&&wi.push("Saved zone index: "+o.stats().omitted+" contours exceed the descriptor budget; "+o.stats().invalid+" invalid contours were rejected."),wi.push(...u),Qc();let yx=0,Jc=gM(()=>{if(!Se)return;Z.invalidate();let C=performance.now();try{ad(),Fm(),Hi(zn),Qc()}finally{yx+=performance.now()-C}},ye);function Qc(){let C=Kc.size,X=wi.length;_.replaceChildren(document.createTextNode(`Material preview \xB7 linked models ${C}/${a.components.length}`));let le=document.createElement("details"),Te=document.createElement("summary"),Ae=document.createElement("ul");Te.textContent=X?`${X} rendering notes`:"Rendering details";let Pe=["Mask openings follow saved pad layer flags; this is not a reconstructed solder-mask solid.",a.components.length-C+" footprints have no linked model; bounded stand-ins are used only where usable saved footprint bounds exist.",...wi];for(let Ge of Pe){let je=document.createElement("li");je.textContent=Ge,Ae.append(je)}le.append(Te,Ae),_.append(le),t.onDiagnostics?.(["Linked component models: "+C+"/"+a.components.length,...Pe]),_.title=wi.join(`
`)}function Lm(C,X){try{return ue.checkTemplate(C,2+(zr.has(X)?0:1)),B.retain(C,ee,fe)}catch(le){throw B.discard(C),le}}async function aS(C,X,le,Te){let Ae=X?.base64,Pe=C.embeddedAsset?await globalThis.KiCadEmbeddedModels.decode(X,iS.default.decompress):globalThis.KiCadEmbeddedModels.decodeBase64(Ae);if(Pe.byteLength>8*1024*1024)throw new Error("model asset exceeds 8 MiB");if(le(Pe.byteLength),["step","stp"].includes(C.format)){Zc||=new globalThis.KiCadStepDecoder.Client(new URL("step-worker.js",location.href).href);let je=await Zc.decode(Pe),$e=new Dt;for(let rt of je){let ke=new ot;ke.setAttribute("position",new gt(rt.positions,3)),ke.setIndex(new gt(rt.index,1)),rt.normals?ke.setAttribute("normal",new gt(rt.normals,3)):ke.computeVertexNormals();let vt=rt.groups.map((dt,Lt)=>(ke.addGroup(dt.start,dt.count,Lt),new Mn({color:new Be(...dt.color),roughness:.65,metalness:.1}))),et=vt.length===1?vt[0]:vt;$e.add(new ct(ke,et))}return Lm($e,Te)}if(C.format==="glb"){try{xv(Pe,ue.limit,{maxAccessorBytes:ee,maxTextureBytes:fe,maxTextureDimension:j.maxDimension})}catch(je){throw["MODEL_GRAPH_BUDGET","MODEL_ALLOCATION_BUDGET"].includes(je.code)&&ue.rejectPreflight(),je}return Lm((await new Dp().parseAsync(Pe.buffer,"")).scene,Te)}let Ge=new TextDecoder("utf-8",{fatal:!0}).decode(Pe);if(/\b(?:Inline|ImageTexture|MovieTexture|AudioClip)\b|\burl\s*(?:\[|\")/i.test(Ge))throw new Error("VRML has an external resource reference");return Lm(new Hp().parse(Ge),Te)}async function cS(C){if(!t.boardPath)return;let X;try{X=globalThis.KiCadRepoModels.collectParsed(C,t.boardPath,t.assetPaths),C=null}catch(je){wi.push(`Cannot read model references: ${je.message}`),Qc();return}wi.push(...X.diagnostics),Qc();let le=fv(X.models),Te=new Map(a.components.map((je,$e)=>[je.id,$e])),Ae=0,Pe=0;async function Ge(je){let $e=Te.get(je.footprintId);if($e===void 0){wi.push(`${je.reference}: footprint identity not found`),le.release(je);return}try{let rt=await le.get(je,async()=>{let ke=je.embeddedAsset||await t.loadAsset?.(je.path);if(!Se)throw Error("3D viewer closed before model decoding.");return aS(je,ke,vt=>{if(Ae+=vt,Ae>25165824)throw new Error("Decoded 3D model assets exceed 24 MiB in this viewer")},$e)});if(!Se)return;ue.admit(rt,2+(zr.has($e)?0:1),()=>{let ke=le.isLastUse(je)?rt:rt.clone(!0);B.retainClone(ke,ee,fe);let vt=0;if(ke.traverse(Rt=>{Rt.isMesh&&Rt.geometry?.attributes?.position?.count&&(vt++,Rt.castShadow=!0,Rt.receiveShadow=!0,Rt.userData.record={...a.components[$e],type:"Component",modelPath:je.path},At.add(Rt,"component"),dn.push(Rt))}),!vt)throw new Error("asset has no drawable mesh");let et=globalThis.KiCadRepoModels.modelPose(je,z,Y,be),dt=new Dt;dt.position.set(...et.position),dt.rotation.z=et.footprintAngle;let Lt=new Dt;if(Lt.rotation.set(...et.modelRotation,"ZYX"),Lt.scale.set(...et.scale),Lt.add(ke),dt.add(Lt),!zr.has($e)){let Rt=new Dt;zr.set($e,Rt),pa.add(Rt)}zr.get($e).add(dt),Kc.add($e),je.format==="glb"&&wi.push(`${je.reference}: GLB geometry is interpreted in millimetres.`)})}catch(rt){wi.push(`${je.reference}: ${je.path}: ${rt?.message||String(rt)}`)}finally{le.release(je)}Jc.request()}await Promise.all(Array.from({length:Math.min(Ee,X.models.length)},async()=>{for(;Pe<X.models.length&&Se;)await Ge(X.models[Pe++])})),le.clear(),Zc?.dispose(),Zc=null,Se&&(Jc.flush(),!tt&&Kc.size&&io())}let Om=Math.hypot(H,_e,be+5)/2,Dm=new q,lS=new q,$c=new zt().setFromObject(Fn);function ga(){let C=RM(k.position.toArray(),k.getWorldDirection(lS).toArray(),$c.min.toArray(),$c.max.toArray()),X=CM(k.position.distanceTo(Ie.target),Om+Ie.target.distanceTo(Dm),C);k.near=X.near,k.far=Ti.enabled?Math.max(X.far,me*10):X.far,k.updateProjectionMatrix()}function Fm(){$c.setFromObject(Fn);let C=$c.getBoundingSphere(new qt);Number.isFinite(C.radius)&&C.radius>0&&(Om=C.radius,Dm.copy(C.center)),ga()}Ie.addEventListener("change",ga);function xx(C){if(!Xn)return;let{width:X,height:le,ratio:Te}=Xn,Ae=C?Math.min(Te,Math.sqrt(6e5/X/le),Te*.78):Te;(F.domElement.width!==Math.floor(X*Ae)||F.domElement.height!==Math.floor(le*Ae)||F.getPixelRatio()!==Ae)&&F.setDrawingBufferSize(X,le,Ae)}function gs(){let C=Le();if(xe.setState({hasSize:C}),!C){ye();return}let X=Math.max(1,p.clientWidth),le=Math.max(1,p.clientHeight),Te=nx(X,le,globalThis.devicePixelRatio,j.maxDimension,xs.running()?"low":Fe,j),Ae=Te.ratio;(F.domElement.width!==Math.floor(X*Ae)||F.domElement.height!==Math.floor(le*Ae))&&Z.invalidate(),Xn={width:X,height:le,ratio:Ae},xx(at),k.aspect=X/le,Je&&(Je.composer.setPixelRatio(Ae),Je.composer.setSize(X,le)),k.updateProjectionMatrix(),ye()}function io(C="iso"){gs(),Fn.updateWorldMatrix(!0,!0);let X=new zt().setFromObject(Fn),le=X.getBoundingSphere(new qt),Te=Number.isFinite(le.radius)&&le.radius>0?le.radius:Math.hypot(H,_e,be+5)/2,Ae=le.radius>0?le.center:new q,Pe=WM(C),Ge=new q(...Pe.direction).normalize(),je=cm(X.getSize(new q).toArray(),Ge.toArray(),k.fov,k.aspect,.85,Pe.up)||am(Te,k.fov,k.aspect)||me*3;Om=Te,Dm.copy(Ae),$c.copy(X),Ie.maxDistance=Math.max(me*8,je*4),k.position.copy(Ae).addScaledVector(Ge,je),k.up.fromArray(Pe.up),Ie.target.copy(Ae),Ie.update(),ga()}M("Fit",()=>{tt=!0,io()},"M8 3H3v5M16 3h5v5M21 16v5h-5M8 21H3v-5M8 8h8v8H8Z","Fit board to viewport").classList.add("fit-action");let gr=document.createElement("select");gr.className="view-select",gr.title="Choose a board viewing side",gr.setAttribute("aria-label","3D camera view");let cd=document.createElement("option");cd.value="",cd.disabled=!0,cd.textContent="View",gr.append(cd);for(let{id:C,label:X}of Qh){let le=document.createElement("option");le.value=C,le.textContent=X,gr.append(le)}gr.value="",gr.onchange=()=>{tt=!0,io(gr.value),gr.value=""},y.append(gr);let Um=document.createElement("span");Um.className="divider",Um.setAttribute("aria-hidden","true"),y.append(Um);let ys=!1;function vx(C){return ys=!!C,iE(Ie,Wn,ys),km.setAttribute("aria-pressed",String(ys)),F.domElement.style.cursor=ys?"grab":"",ys}let km=M("Pan",()=>{oo(!1),vx(!ys)},"M12 3v18M3 12h18M8 7l4-4 4 4M8 17l4 4 4-4M7 8l-4 4 4 4M17 8l4 4-4 4","Pan view with left drag");km.setAttribute("aria-pressed","false");let ld=M("Measure",()=>oo(!tn),"M3 17 17 3l4 4L7 21ZM7 13l3 3M10 10l2 2M13 7l3 3","Measure distance between 3D surfaces");ld.setAttribute("aria-pressed","false");let ya=M("Display",()=>W(P.hidden),"M3 6h18M3 12h18M3 18h18M7 3v6M17 9v6M10 15v6","3D display settings");ya.setAttribute("aria-expanded","false"),ya.setAttribute("aria-controls",P.id);let el=document.createElement("label");el.className="explode-control",el.style.cssText="display:inline-flex;align-items:center;gap:5px;font-size:11px",el.title="Expand mode: components lift first, then copper layers separate, the substrate fades and vias stretch. Saved identities remain linked.";let bx=document.createElement("span");bx.textContent="Expand mode";let Ri=document.createElement("input");Ri.type="range",Ri.min="0",Ri.max="100",Ri.step="1",Ri.value="0",Ri.style.cssText="width:80px;min-width:50px",Ri.setAttribute("aria-label","Expand assembly");let Bm=document.createElement("output");Bm.textContent="0%",el.append(bx,Ri,Bm);let ro=document.createElement("details");ro.className="tools-more";let tl=document.createElement("summary");tl.textContent="3D tools",tl.title="More 3D tools",tl.setAttribute("aria-label","More 3D tools");let zm=document.createElement("div");zm.className="tools-panel",zm.append(km,ld,ya,el),ro.append(tl,zm),y.append(ro);let so=document.createElement("p");so.className="quality-help",so.setAttribute("role","status"),so.hidden=!0,so.style.cssText="position:absolute;left:10px;bottom:10px;z-index:5;max-width:calc(100% - 20px);margin:0;padding:6px 9px;background:var(--panel);border:1px solid var(--border);border-radius:5px;pointer-events:none",f.append(so);function _x(){Nt.sync(Gr.overlay,Ye.get())}function Ex(C=Gr.getAnalysisOverlayState()){return Ye.get()>0&&C.placed?{...C,displaySuspended:!0,diagnostics:[...C.diagnostics,"Registered result and probes are hidden while Expand mode is active; restore Expand mode to 0% to view them."]}:C}let Mx=0,Sx=0,Vm=0;function uS(C){let X=performance.now();if(!Se)return Ye.get();let le=Ye.get(),Te=Ye.set(C);if(le===0!=(Te===0)&&(Te>0&&Oe(),Vi(xt)),F.shadowMap.enabled=!1,Te>0){let Pe=we.size;sd(),we.size!==Pe&&Vi(xt)}Te!==le&&(tt=!0,vr(),tn&&oo(!1));for(let Pe of pe){let Ge=ui.get(Pe.name);Ge&&(Ye.layer(Ge,Pe.name),Ge.visible=ft(Pe))}for(let Pe of fa.children){let Ge=to.find(je=>je.mesh===Pe)?.layer;Ye.layer(Pe,Ge==="B.SilkS"?"B.Cu":"F.Cu")}for(let{mesh:Pe,span:Ge}of ut)Ye.barrels(Pe,Ge);ad(),Ot?Ma.syncTransforms():Wh(zn)&&Hi(zn),hi?.object&&!pn&&(jx(hi.object,hi.instanceId),ho.getCenter(hi.point)),qc(),_x(),Fm(),Px(),Bm.textContent=Math.round(Te)+"%",Ri.setAttribute("aria-valuetext",Math.round(Te)+" percent expanded"),so.hidden=Te===0,so.textContent="Display-only expansion: components lift first, then copper separates and substrate fades. "+(pe.some(Pe=>Pe.basis==="illustrative")?"Internal elevations are illustrative. ":"")+"Registered results and measurements resume at 0%.",Mx++;let Ae=performance.now()-X;return Sx+=Ae,Vm=Math.max(Vm,Ae),t.onExplodeChange?.(Te),ye(),Te}let xs=qM({request:C=>requestAnimationFrame(C),cancel:C=>cancelAnimationFrame(C),update:uS,canRun:()=>Se&&!De&&!xe.stats().paused,reducedMotion:()=>globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches===!0,settle:C=>{if(F.shadowMap.enabled=C===0&&Fe!=="low"&&xt!=="translucent",F.shadowMap.needsUpdate=!0,C===0)try{st()}catch{pt("Enhanced quality is unavailable. Balanced rendering is active.")}gs(),ye()}});function ud(C,X=!1){if(!Se)return Ye.get();if(!Number.isFinite(C)||C<0||C>100)throw new TypeError("Expand amount must be between 0 and 100.");C>0&&sd(),Ri.value=String(C);let le=xs.set(C,{immediate:X});return gs(),le}Ri.oninput=()=>ud(Number(Ri.value));let Tx=new Map,Hm=()=>pe.filter(C=>Re.get(C.name)).map(C=>C.name);function Ax(C){if(!Array.isArray(C)||C.some(Ae=>typeof Ae!="string"||!Re.has(Ae))||new Set(C).size!==C.length)throw new TypeError("Choose saved physical copper layer names.");let X=new Set(C),le=!1;for(let Ae of pe){let Pe=X.has(Ae.name);Re.get(Ae.name)!==Pe&&(le=!0),Re.set(Ae.name,Pe);let Ge=Tx.get(Ae.name);Ge&&(Ge.checked=Pe);let je=ui.get(Ae.name);je&&(je.visible=ft(Ae))}Hi(zn),ye();let Te=Hm();return le&&t.onLayersChange?.([...Te]),Te}for(let C of pe)Tx.set(C.name,Q(C.name==="F.Cu"?"Front copper":C.name==="B.Cu"?"Back copper":C.name+" copper",!0,X=>{let le=new Set(Hm());X?le.add(C.name):le.delete(C.name),Ax([...le])}));let wx=document.createElement("label"),nl=document.createElement("select");wx.append(document.createTextNode("Inspect copper layer"),nl),nl.setAttribute("aria-label","Inspect copper layer");for(let[C,X]of[["","Assembled board"],...pe.map(le=>[le.name,le.name])]){let le=document.createElement("option");le.value=C,le.textContent=X,nl.append(le)}U.append(wx);let hS=Q("Parts",!0,C=>{pa.visible=!qe&&C,Wh(zn)&&Hi(zn),F.shadowMap.needsUpdate=!0}),dS=Q("Silkscreen",!0,C=>{fa.visible=!qe&&C});nl.onchange=()=>{qe=nl.value||null,pa.visible=!qe&&hS.checked,fa.visible=!qe&&dS.checked,Nm.visible=!qe,Vi(xt)};let Rx=!1,il=new Dt,yr=new Map;Me.add(il);let Cx=new Ar(1,1),fS=l.filter(C=>C.name&&C.net&&C.name.length<=40&&C.net.length<=48).slice(0,1e4).map(C=>{let[X,le]=K(C.at);return{pad:C,x:X,y:le}}),xa=[],hd=new Set;function pS(C){let X=JSON.stringify([C.name,C.net]);if(yr.has(X)){let Pe=yr.get(X);return yr.delete(X),yr.set(X,Pe),hd.add(Pe),Pe}if(yr.size>=150){let Pe=[...yr].find(([,Ge])=>!hd.has(Ge));if(!Pe)return null;yr.delete(Pe[0]),Pe[1].dispose()}let le=document.createElement("canvas");le.width=512,le.height=48;let Te=le.getContext("2d");Te.font="600 14px monospace",Te.textAlign="center",Te.textBaseline="middle",Te.lineJoin="round",Te.lineWidth=5,Te.strokeStyle="#101820",Te.fillStyle="#f3f8fa";for(let[Pe,Ge]of[[C.name,13],[C.net,34]])Te.strokeText(Pe,256,Ge),Te.fillText(Pe,256,Ge);let Ae=new ns(le);return Ae.colorSpace=wt,yr.set(X,Ae),hd.add(Ae),Ae}let rl=new q,mS=new q;function Px(){let C=0;if(hd.clear(),il.visible=Rx&&!tn,!il.visible)return;if(!Un.visible("pads"))return void xa.forEach(Pe=>Pe.visible=!1);let X=Math.max(1,p.clientHeight),le=Math.max(1,p.clientWidth),Te=[],Ae=k.position.z>=Ie.target.z?"F.Cu":"B.Cu";if(!Bt(Ae).visible||!Un.visible("pads",Ae))return void xa.forEach(Pe=>Pe.visible=!1);for(let{pad:Pe,x:Ge,y:je}of fS){if(C>=150)break;if(!(Pe.layers?.includes(Ae)||Pe.layers?.includes("*.Cu")||Pe.layer===Ae))continue;let $e=(Ae==="F.Cu"?he+.055:Ne-.055)+Ye.offset(Ae),rt=k.position.distanceTo(mS.set(Ge,je,$e)),ke=X/(2*Math.tan(k.fov*Math.PI/360)*rt),vt=Math.min(Pe.width,Pe.height)*ke;if(!Number.isFinite(vt)||vt<32||(rl.set(Ge,je,$e).project(k),rl.z<-1||rl.z>1))continue;let et=Math.min(16,Math.max(10,vt*.22)),dt=(Math.max(Pe.name.length,Pe.net.length)*.63+1)*et,Lt=et*2.8,Rt=(rl.x+1)*le/2,Wt=(1-rl.y)*X/2,Ft={x:Rt-dt/2,y:Wt-Lt/2,w:dt,h:Lt};if(Ft.x<0||Ft.y<0||Ft.x+dt>le||Ft.y+Lt>X||Te.some(wa=>Ft.x<wa.x+wa.w&&Ft.x+dt>wa.x&&Ft.y<wa.y+wa.h&&Ft.y+Lt>wa.y))continue;let jn=pS(Pe);if(!jn)continue;let Gi=xa[C];Gi||(Gi=new ct(Cx,new Ht({transparent:!0,depthTest:!0,depthWrite:!1,side:yn})),Gi.renderOrder=5,il.add(Gi),xa.push(Gi)),Gi.material.map!==jn&&(Gi.material.map=jn,Gi.material.needsUpdate=!0),Gi.position.set(Ge,je,$e),Gi.quaternion.copy(k.quaternion),Gi.scale.set(512/14*et/ke,48/14*et/ke,1),Gi.visible=!0,Te.push(Ft),C++}for(let Pe=C;Pe<xa.length;Pe++)xa[Pe].visible=!1}Q("Pad and net names (close zoom)",!1,C=>{Rx=C}),io();let vs=new lr,bs=new Ce,Ci=new Sm,tn=!1,_s="mm",va=document.createElement("section");va.className="measurement-panel",va.hidden=!0,va.setAttribute("aria-label","3D surface measurement");let Gm=document.createElement("div");Gm.className="measurement-heading";let Ix=document.createElement("strong");Ix.textContent="Surface distance";let sl=document.createElement("select");sl.setAttribute("aria-label","3D measurement units");for(let C of["mm","mil"]){let X=document.createElement("option");X.value=C,X.textContent=C,sl.append(X)}let ol=document.createElement("button");ol.type="button",ol.textContent="Done",ol.title="Exit measurement mode",ol.onclick=()=>oo(!1),Gm.append(Ix,sl,ol);let al=document.createElement("select"),cl=document.createElement("select"),Wm=document.createElement("div");Wm.className="measurement-tools",al.setAttribute("aria-label","3D measurement snap"),cl.setAttribute("aria-label","3D measurement selection filter");for(let[C,X]of[["surface","Surface"],["edges","Snap to edges"],["corners","Snap to corners"]]){let le=document.createElement("option");le.value=C,le.textContent=X,al.append(le)}for(let[C,X]of[["all","All geometry"],["board","Board outline/body"],["models","Component models"],["pads","Pads"],["tracks","Tracks"],["vias","Vias"]]){let le=document.createElement("option");le.value=C,le.textContent=X,cl.append(le)}Wm.append(al,cl);let Nx=new WeakMap,Vr=null,ll=null,Es=new Set,Pi=document.createElement("canvas");Pi.width=Pi.height=240,Pi.className="measurement-label",Pi.hidden=!0,Pi.setAttribute("aria-label","3D measurement magnifier"),Pi.style.cssText="width:120px;height:120px;position:absolute;right:12px;top:50px;left:auto;pointer-events:none;border-radius:50%;z-index:8;padding:0",f.append(Pi);function gS(){if(!tn||!Vr){Pi.hidden=!0;return}let C=F.domElement.getBoundingClientRect(),X=Vr.x-C.left,le=Vr.y-C.top;Pi.hidden=!1;let Te=Pi.getContext("2d");if(!Te)return;let Ae=F.domElement.width/C.width,Pe=F.domElement.height/C.height;Te.clearRect(0,0,240,240),Te.drawImage(F.domElement,(X-20)*Ae,(le-20)*Pe,40*Ae,40*Pe,0,0,240,240),Te.strokeStyle="#ffcf66",Te.lineWidth=2,Te.beginPath(),Te.moveTo(110,120),Te.lineTo(130,120),Te.moveTo(120,110),Te.lineTo(120,130),Te.stroke()}let Xm=document.createElement("output");Xm.setAttribute("aria-live","polite");let Ym=document.createElement("p");Ym.setAttribute("role","status");let Lx=document.createElement("small"),Ox=document.createElement("small");Ox.textContent="Model surfaces \xB7 footprint stand-ins are approximate.";let jm=document.createElement("div");jm.className="measurement-tools";let Hr=document.createElement("select");Hr.setAttribute("aria-label","Recent 3D measurements");let ul=document.createElement("button");ul.type="button",ul.textContent="Clear",ul.title="Clear all 3D measurements",ul.onclick=Bx,jm.append(Hr,ul),va.append(Gm,Wm,Xm,Ym,Lx,jm,Ox),f.append(va);let Zi=document.createElement("div");Zi.className="measurement-label",Zi.hidden=!0,Zi.setAttribute("aria-hidden","true"),f.append(Zi);let ba=new Dt;ba.visible=!1,Me.add(ba);let qm=new ot;qm.setAttribute("position",new gt(new Float32Array(6),3));let yS=new Xt({color:16765818,transparent:!0,opacity:.95,depthTest:!1,depthWrite:!1,toneMapped:!1}),dd=new ai(qm,yS);dd.frustumCulled=!1,dd.renderOrder=201,ba.add(dd);let Dx=new bi(1,12,8),Fx=new Ht({color:16765818,transparent:!0,opacity:.95,depthTest:!1,depthWrite:!1,toneMapped:!1}),hl=[new ct(Dx,Fx),new ct(Dx,Fx)];for(let C of hl)C.renderOrder=202,ba.add(C);let Ux=C=>new q(C.x-z,Y-C.y,C.z);function _a(C){let X=Ci.selected,le=Ci.pending;Xm.textContent=X?(X.approximate?"\u2248 ":"")+Tm(X.distance,_s):"\u2014",Ym.textContent=C||(le?"Choose the second surface point.":X?"Choose a point to start another measurement.":"Choose the first surface point.");let Te=Pe=>(_s==="mil"?Pe/.0254:Pe).toFixed(_s==="mil"?2:3);Lx.textContent=X?`\u0394X ${Te(X.delta.x)} \xB7 \u0394Y ${Te(X.delta.y)} \xB7 \u0394Z ${Te(X.delta.z)} ${_s}`:"",Hr.replaceChildren();let Ae=document.createElement("option");Ae.value="",Ae.textContent=Ci.records.length?"Recent measurements":"No measurements yet",Hr.append(Ae);for(let Pe of Ci.records){let Ge=document.createElement("option");Ge.value=String(Pe.id),Ge.textContent=`#${Pe.id} \xB7 ${Pe.approximate?"\u2248 ":""}${Tm(Pe.distance,_s)}`,Hr.append(Ge)}Hr.value=X?String(X.id):"",Hr.disabled=!Ci.records.length,Zi.textContent=X?(X.approximate?"\u2248 ":"")+Tm(X.distance,_s):"",kx(),ye()}function kx(){let C=Ci.selected,X=Ci.pending;if(ba.visible=tn&&!!(C||X),Zi.hidden=!tn||!C,!ba.visible)return;let le=Ux(C?.from||X),Te=C?Ux(C.to):null;if(hl[0].position.copy(le),hl[1].visible=!!Te,dd.visible=!!Te,Te){hl[1].position.copy(Te);let Ae=qm.getAttribute("position");Ae.setXYZ(0,le.x,le.y,le.z),Ae.setXYZ(1,Te.x,Te.y,Te.z),Ae.needsUpdate=!0;let Pe=le.clone().add(Te).multiplyScalar(.5).project(k);Zi.hidden=Pe.z<-1||Pe.z>1,Zi.style.left=Math.max(8,Math.min(p.clientWidth-Zi.offsetWidth-8,(Pe.x+1)*p.clientWidth/2+8))+"px",Zi.style.top=Math.max(8,Math.min(p.clientHeight-Zi.offsetHeight-8,(1-Pe.y)*p.clientHeight/2-24))+"px"}for(let Ae of hl){let Pe=Math.max(.005,k.position.distanceTo(Ae.position)*2*Math.tan(k.fov*Math.PI/360)/Math.max(1,p.clientHeight)*3.5);Ae.scale.setScalar(Pe)}}function oo(C){return Se?C&&Ye.get()>0?(Ue("Restore Expand mode to 0% before measuring saved geometry."),!1):(tn=!!C,tn&&vx(!1),h.dataset.measuring=String(tn),ld.setAttribute("aria-pressed",String(tn)),va.hidden=!tn,tn||(Ci.pending=null,Vr=null,ll=null,Es.clear(),Ie.enabled=!0,Pi.hidden=!0),_a(),t.onMeasurementMode?.(tn),tn):!1}function Bx(){Ci.clear(),_a(),t.onMeasurement?.(null)}sl.onchange=()=>{_s=sl.value==="mil"?"mil":"mm",_a()},Hr.onchange=()=>{let C=Ci.replay(Hr.value);C&&(_a(),t.onMeasurement?.(C))};let zx=C=>{C.key==="Escape"&&tn&&(C.preventDefault(),C.stopPropagation(),oo(!1),ld.focus())};d.addEventListener("keydown",zx);function xS(){let C=Wt=>gm(Wt,In,qe||Ye.get()>0?"translucent":xt),X=vs.intersectObjects(dn.filter(C),!1).find(Wt=>xr.isVisible(Wt.object,Wt.instanceId));if(!X)return null;let le=X.object===In?"board":to.find(Wt=>Wt.mesh===X.object)?.type||"models",Te=le==="arcs"?"tracks":le;if(cl.value!=="all"&&cl.value!==Te)return null;if(al.value==="surface")return{point:X.point,approximate:X.object===sn,kind:"surface"};let Ae=X.object.geometry,Pe=Ae?.getAttribute("position");if(!Pe||Pe.count>2e5)return null;let Ge=Nx.get(Ae);if(!Ge){let Wt=new ss(Ae,25),Ft=Wt.getAttribute("position");Ge=[];for(let jn=0;jn+1<Ft.count&&Ge.length<1e4;jn+=2)Ge.push([[Ft.getX(jn),Ft.getY(jn),Ft.getZ(jn)],[Ft.getX(jn+1),Ft.getY(jn+1),Ft.getZ(jn+1)]]);Wt.dispose(),Nx.set(Ae,Ge)}let je=X.object.matrixWorld.clone();if(Number.isInteger(X.instanceId)){let Wt=new nt;X.object.getMatrixAt(X.instanceId,Wt),je.multiply(Wt)}let $e=Ge.map(Wt=>Wt.map(Ft=>{let jn=new q(...Ft).applyMatrix4(je);return{x:jn.x,y:jn.y,z:jn.z}})),rt=F.domElement.getBoundingClientRect(),ke=Wt=>{let Ft=new It(Wt.x,Wt.y,Wt.z,1).applyMatrix4(k.matrixWorldInverse).applyMatrix4(k.projectionMatrix);return Ft.w<=0?null:{x:(Ft.x/Ft.w+1)*rt.width/2,y:(1-Ft.y/Ft.w)*rt.height/2,z:Ft.z/Ft.w,w:Ft.w}},vt=GM({x:(bs.x+1)*rt.width/2,y:(1-bs.y)*rt.height/2},$e,ke,{mode:al.value,tolerance:Vr?18:12});if(!vt)return null;let et=new q(vt.point.x,vt.point.y,vt.point.z),dt=et.clone().project(k),Lt=new lr;Lt.setFromCamera(new Ce(dt.x,dt.y),k);let Rt=Lt.intersectObjects(dn.filter(C),!1).find(Wt=>xr.isVisible(Wt.object,Wt.instanceId));return!Rt||Rt.object!==X.object||Rt.instanceId!==X.instanceId||Rt.point.distanceTo(et)>Math.max(.002,k.position.distanceTo(et)*5e-5)?null:{point:et,approximate:X.object===sn,kind:vt.kind}}function vS(){let C=xS();if(!C){_a("No visible feature within snap range. Adjust snap/filter or zoom in.");return}let X=Ci.add({x:C.point.x+z,y:Y-C.point.y,z:C.point.z,approximate:C.approximate});_a(C.kind+" selected. "+(Ci.pending?"Choose the second point.":"Measurement complete.")),X?.distance!==void 0&&t.onMeasurement?.(X)}let hi=null,dl=YM({onPick:C=>{ys||Qm(C)},onContextMenu:$x,isHeld:()=>Aa.isHeld()}),Ea=!0,ao=mm(),xr=fM(Wn,()=>{let C=[];return Fn.traverse(X=>{X.material&&C.push(X)}),C});Ct=!0;let co=2e3,Vx=new ss(new Qn(1,1,1)),Ms=Vx.getAttribute("position"),lo=new ot,fd=new gt(new Float32Array(co*Ms.count*3),3);fd.setUsage(Mp),lo.setAttribute("position",fd),lo.setDrawRange(0,0);let Hx=()=>new Xt({color:r?16768893:10179840,depthTest:!0,depthWrite:!1,toneMapped:!1}),uo=new ln(lo,Hx());uo.frustumCulled=!1,uo.renderOrder=101,Me.add(uo);let zn={},Ma=JM(Wn,{scene:Me,objects:()=>dn,colorForLayer:Cm,visible:(C,X)=>{if(qe?X!==qe:Re.has(X)&&!Re.get(X))return!1;for(let le=C;le;le=le.parent)if(!le.visible&&le!==ui.get(X))return!1;return!0}});function Gx(C){Ma.update(C,ao),Ma.stats().limited&&(di.hidden=!1,di.style.display="",di.textContent="Net shine-through reached its display budget; native selection is retained.")}let Sa={netOnlyUpdates:0,netRecordsScanned:0,netBoundsAvoided:0,boundsEvaluations:0,outlineVerticesWritten:0},di=document.createElement("div");di.className="hint",di.style.bottom="42px",di.hidden=!0,f.append(di);function Hi(C={}){if(Z.invalidate(),ye(),zn=C||{},Ot=!1,ht=!1,pn=!1,!Wh(zn))return Ma.clear(),lo.setDrawRange(0,0),di.hidden=!0,di.style.display="none",fi.visible=!1,uo.visible=!1,xr.restore(),qc(),{highlighted:0,matched:0,limited:!1};let X=xM(zn,a);X.size&&sd();let le=_M(zn,a);if(ht=le(In.userData.record),pn=X.size>0,vM(zn,X)){Ot=!0;let et=bM(dn,le);return Sa.netOnlyUpdates++,Sa.netRecordsScanned+=et.visitedRecords,Sa.netBoundsAvoided+=et.matchedRecords,lo.setDrawRange(0,0),di.hidden=!0,di.style.display="none",fi.visible=!1,uo.visible=!1,xr.update(le,et.matched>0&&Ea,dt=>X.has(dt?.net),{...ao,expanded:Ye.get()>0,netContext:X.size>0}),qc(),Gx(X),{highlighted:Math.min(et.matched,co),matched:et.matched,limited:et.matched>co}}let Te=new nt,Ae=new nt,Pe=new zt,Ge=new q,je=new q,$e=0,rt=0,ke=new Map,vt=(et,dt,Lt)=>{if(Number.isInteger(dt)&&(et.getMatrixAt(dt,Ae),Ae.determinant()===0)||(Sa.boundsEvaluations++,et.updateWorldMatrix(!0,!1),Number.isInteger(dt)?(et.geometry.boundingBox||et.geometry.computeBoundingBox(),Pe.copy(et.geometry.boundingBox),Te.multiplyMatrices(et.matrixWorld,Ae),Pe.applyMatrix4(Te)):Pe.setFromObject(et),Pe.isEmpty()))return;let Rt=Lt?.ref?"part:"+Lt.ref:Lt?.uuid||Lt?.id||et.uuid+":"+dt;ke.has(Rt)?ke.get(Rt).union(Pe):ke.size<co?ke.set(Rt,Pe.clone()):rt++};for(let et of dn){let dt=!0;for(let Rt=et;Rt;Rt=Rt.parent)Rt.visible||(dt=!1);if(!dt)continue;let Lt=et.userData.records;Lt?Lt.forEach((Rt,Wt)=>{le(Rt)&&vt(et,Wt,Rt)}):le(et.userData.record)&&vt(et,void 0,et.userData.record)}for(let et of ke.values()){et.expandByScalar(.035),et.getCenter(Ge),et.getSize(je);for(let dt=0;dt<Ms.count;dt++)fd.setXYZ($e*Ms.count+dt,Ge.x+Ms.getX(dt)*je.x,Ge.y+Ms.getY(dt)*je.y,Ge.z+Ms.getZ(dt)*je.z);$e++}return rt+=ke.size,lo.setDrawRange(0,$e*Ms.count),fd.needsUpdate=!0,Sa.outlineVerticesWritten+=$e*Ms.count,di.hidden=rt<=co,di.textContent=`Showing ${$e} of ${rt} selected 3D objects`,di.style.display=rt>co?"block":"none",fi.visible=!1,uo.visible=!X.size,xr.update(le,rt>0&&Ea,X.size?et=>X.has(et?.net):null,{...ao,expanded:Ye.get()>0,netContext:X.size>0}),qc(),Gx(X),{highlighted:$e,matched:rt,limited:rt>co}}let fi=new ln(Vx,Hx());fi.matrixAutoUpdate=!1,fi.renderOrder=100,fi.visible=!1,Me.add(fi);let Wx=new nt,ho=new zt,Xx=new q,Yx=new q;function jx(C,X){if(ye(),C.updateWorldMatrix(!0,!1),Number.isInteger(X)?(C.getMatrixAt(X,Wx),C.geometry.boundingBox||C.geometry.computeBoundingBox(),ho.copy(C.geometry.boundingBox).applyMatrix4(Wx).applyMatrix4(C.matrixWorld)):ho.setFromObject(C),ho.isEmpty()){fi.visible=!1;return}ho.expandByScalar(.035),ho.getCenter(Xx),ho.getSize(Yx),fi.matrix.compose(Xx,new Zt,Yx),fi.matrixWorldNeedsUpdate=!0,fi.visible=!0}function Km(){hi=null,b.hidden=!0,x.hidden=!0,fi.visible=!1,Hi({}),t.onSelect?.(null)}function Zm(C,X,le,Te){let Ae=t.getSelectionMode?.()||$m;Hi(Ae==="net"&&C.net?{netNames:[C.net]}:C.type==="Component"||typeof C.library=="string"?{references:[C.ref]}:{uuids:[C.uuid||C.id]}),hi={record:C,point:X.clone(),object:le,instanceId:Te},lo.setDrawRange(0,0),Ae!=="net"||!C.net?jx(le,Te):fi.visible=!1,t.onSelect?.(C),b.replaceChildren();let Pe=document.createElement("h2");Pe.textContent=C.ref||C.name||C.type||"Board object";let Ge=document.createElement("dl");for(let[je,$e]of Object.entries({Type:C.type||(C.ref?"Component":"Copper"),Reference:C.ref,Value:C.value,Layer:C.layer||C.layers?.join(", "),Net:C.net,Model:C.modelPath||C.modelPaths?.join(", ")})){if($e==null||$e==="")continue;let rt=document.createElement("dt"),ke=document.createElement("dd");rt.textContent=je,ke.textContent=String($e),Ge.append(rt,ke)}b.append(Pe,Ge),b.hidden=!!t.externalInspector}let pi=GE(Wn,{scene:Me,objects:()=>dn,document,invalidate:ye}),fo=document.createElement("div");fo.hidden=!0,fo.setAttribute("role","status"),fo.style.cssText="position:absolute;left:12px;right:12px;bottom:12px;z-index:8;padding:9px 12px;border:1px solid var(--accent);border-radius:7px;background:var(--menu);color:var(--ink);font:12px/1.4 system-ui;max-height:calc(100% - 24px);overflow:auto;pointer-events:none",f.append(fo);let Jm=document.createElement("span"),Ta=document.createElement("button");Ta.type="button",Ta.textContent="Cancel",Ta.setAttribute("aria-label","Cancel demo face selection"),Ta.style.cssText="pointer-events:auto;margin-left:10px",Ta.onclick=()=>mo(new DOMException("Face selection was cancelled.","AbortError")),fo.append(Jm,Ta);let po=null,Ji=null,bS=C=>gm(C,In,qe||Ye.get()>0?"translucent":xt);function pd(C,X=!0){pi.sync();let le=F.domElement.getBoundingClientRect();return!le.width||!le.height?null:(bs.set((C.clientX-le.left)/le.width*2-1,-((C.clientY-le.top)/le.height)*2+1),vs.setFromCamera(bs,k),vs.intersectObjects((X?[...dn,...pi.objects()]:dn).filter(bS),!1).find(Te=>xr.isVisible(Te.object,Te.instanceId))||null)}function mo(C,X){let le=po;le&&(po=null,le.signal?.removeEventListener("abort",le.abort),fo.hidden=!0,F.domElement.style.cursor="",C?le.reject(C):le.resolve(X))}function _S({signal:C}={}){return Se?C?.aborted?Promise.reject(new DOMException("Face selection was aborted.","AbortError")):(mo(new DOMException("Face selection was replaced.","AbortError")),vr(),oo(!1),new Promise((X,le)=>{let Te=()=>mo(new DOMException("Face selection was aborted.","AbortError"));po={resolve:X,reject:le,signal:C,abort:Te},C?.addEventListener("abort",Te,{once:!0}),Jm.textContent="Choose a flat component face for the demo display. Drag to orbit; press Escape to cancel.",fo.hidden=!1,F.domElement.style.cursor="crosshair",F.domElement.tabIndex=0,F.domElement.focus({preventScroll:!0})})):Promise.reject(new Error("The 3D view is closed."))}function vr(C){if(Ji===null)return;let X=Ji;Ji=null,pi.pointer(null,"cancel",{pointerId:X,clientY:C?.clientY||0,cancelled:!0}),Ie.enabled=!0;try{F.domElement.releasePointerCapture(X)}catch{}}function qx(C){if(Ji!==null){C.preventDefault(),C.stopImmediatePropagation();return}if(tn||ys||po||C.button!==0)return;let X=pd(C);if(pi.isHit(X)&&pi.pointer(X,"press",C)&&(C.preventDefault(),C.stopImmediatePropagation(),!(!Se||!pi.isHit(X)))){Ji=C.pointerId,Ie.enabled=!1,F.domElement.tabIndex=0,F.domElement.focus({preventScroll:!0});try{F.domElement.setPointerCapture(C.pointerId)}catch{}}}function Kx(C){Ji===C.pointerId&&(pi.pointer(pd(C),"move",C),C.preventDefault(),C.stopImmediatePropagation())}function Zx(C){if(Ji!==C.pointerId)return;let X=Ji;Ji=null,pi.pointer(pd(C),"release",C),Ie.enabled=!0;try{F.domElement.releasePointerCapture(X)}catch{}C.preventDefault(),C.stopImmediatePropagation()}function md(C){Ji===C.pointerId&&(vr(C),C.preventDefault(),C.stopImmediatePropagation())}let Jx=C=>{C.key==="Escape"&&po&&(mo(new DOMException("Face selection was cancelled.","AbortError")),C.preventDefault(),C.stopImmediatePropagation())};for(let[C,X]of[["pointerdown",qx],["pointermove",Kx],["pointerup",Zx],["pointercancel",md],["lostpointercapture",md]])F.domElement.addEventListener(C,X,!0);d.addEventListener("keydown",Jx,!0),document.defaultView?.addEventListener("blur",vr);function Qm(C){if(po){try{let ke=pd(C,!1);mo(null,pi.selectFace(ke))}catch(ke){Jm.textContent=ke.message+" Choose another flat component face, or press Escape."}return}let X=F.domElement.getBoundingClientRect();if(bs.set((C.clientX-X.left)/X.width*2-1,-((C.clientY-X.top)/X.height)*2+1),vs.setFromCamera(bs,k),tn){vS();return}let le=null,Te=Gr.overlay;if(Te?.group?.visible!==!1&&Te?.mesh.visible){let ke=Te.sample(vs.intersectObject(Te.mesh,!1)[0]);ke&&(le=ke)}let Ae=ke=>gm(ke,In,qe||Ye.get()>0?"translucent":xt),Pe=vs.intersectObjects(dn.filter(Ae),!1).filter(ke=>xr.isVisible(ke.object,ke.instanceId)),Ge=t.getSelectionMode?.()||$m,je=ke=>MM(ke.object.userData.records?.[ke.instanceId]||ke.object.userData.record,Ge),$e=xt==="translucent"&&Pe.find(ke=>je(ke)&&(ke.object.userData.records?.[ke.instanceId]||ke.object.userData.record)?.type!=="Zone")||Pe.find(je);if(!$e){le?t.onAnalysisProbe?.(le):Km();return}let rt=$e.object.userData.records?.[$e.instanceId]||$e.object.userData.record;rt&&Zm(rt,$e.point,$e.object,$e.instanceId),le&&t.onAnalysisProbe?.(le)}let $m="all",Aa=EM(C=>$x(C)),Qx=C=>{tn&&C.pointerType==="touch"&&Es.size&&(Ie.enabled=!0)};F.domElement.addEventListener("pointerdown",Qx,!0),F.domElement.addEventListener("pointerdown",C=>{dl.down(C),Aa.down(C),x.hidden=!0,tn&&C.pointerType==="touch"&&(Es.add(C.pointerId),ll=Es.size===1?C.pointerId:null,Ie.enabled=Es.size!==1,Vr={x:C.clientX,y:C.clientY},ye())}),F.domElement.addEventListener("pointermove",C=>{dl.move(C),Aa.move(C),tn&&C.pointerType==="touch"&&(Vr={x:C.clientX,y:C.clientY},ye());let X=Gr.overlay;if(X&&t.onAnalysisHover){let le=F.domElement.getBoundingClientRect();bs.set((C.clientX-le.left)/le.width*2-1,-((C.clientY-le.top)/le.height)*2+1),vs.setFromCamera(bs,k),t.onAnalysisHover(X.group.visible&&X.mesh.visible?X.sample(vs.intersectObject(X.mesh,!1)[0]):null)}}),F.domElement.addEventListener("pointercancel",C=>{dl.cancel(C),Aa.up(C),Es.delete(C.pointerId),ll=null,Ie.enabled=!0,Vr=null,Pi.hidden=!0}),F.domElement.addEventListener("pointerup",C=>{Aa.up(C),dl.up(C,{select:!(tn&&C.pointerType==="touch")}),tn&&C.pointerType==="touch"&&(ll===C.pointerId&&Es.size===1&&Qm(C),Es.delete(C.pointerId),ll=null,Ie.enabled=!0),Vr=null,Pi.hidden=!0});function $x(C){if(C.preventDefault?.(),tn||po||(Qm(C),!hi))return;x.replaceChildren();let X=[["Focus object",()=>{Ie.target.copy(hi.point),Ie.update()}],["Copy reference",()=>navigator.clipboard.writeText(hi.record.ref||hi.record.name||"")]];typeof t.onInspect=="function"&&X.unshift(["Properties",()=>t.onInspect(hi.record)]),typeof t.onComment=="function"&&X.push(["Comment on object",()=>t.onComment(hi.record)]);for(let[Ae,Pe]of X){let Ge=document.createElement("button");Ge.textContent=Ae,Ge.type="button",Ge.addEventListener("click",()=>{Pe(),x.hidden=!0}),x.append(Ge)}let le=f.getBoundingClientRect();x.hidden=!1,x.style.maxWidth="calc(100% - 16px)",x.style.maxHeight="calc(100% - 16px)",x.style.overflowY="auto";let Te=x.getBoundingClientRect();x.style.left=`${Math.max(8,Math.min(C.clientX-le.left,le.width-Te.width-8))}px`,x.style.top=`${Math.max(8,Math.min(C.clientY-le.top,le.height-Te.height-8))}px`}F.domElement.addEventListener("contextmenu",C=>{dl.context(C)});let gd=gs,ev=new ResizeObserver(()=>{gd(),V()});ev.observe(p);let tv=xm(xe,p);gd(),V();let Gr=BM({bounds:a.bounds,thickness:be,layers:a.layers||[]},{scene:Me,invalidate:ye,isActive:()=>Se}),ES=requestAnimationFrame(()=>{Se&&(gd(),tt||io())}),nv=dM(Wn,{objects:()=>dn,camera:k,rect:()=>F.domElement.getBoundingClientRect(),positionToWorld:(C,X)=>{let[le,Te]=K([C.x,C.y]);return new q(le,Te,X==="back"?Ne+Ye.offset("B.Cu"):he+Ye.offset("F.Cu"))}}),fl=null,eg="",iv="";function rv(){if(!fl)return;let C=nv(fl),X=JSON.stringify(C);X!==eg&&(eg=X,t.onAnchor?.({anchor:fl,point:C}))}function MS(){let C=F.domElement.getBoundingClientRect(),X=JSON.stringify([k.matrixWorld.elements,k.projectionMatrix.elements,C.left,C.top,C.width,C.height]);X!==iv&&(iv=X,t.onViewChange?.()),rv()}function SS(){if(xs.resume(),!Se||De||document.hidden)return;let C=at&&!tn;C||Jc.flush(),Ie.update(),xx(C),id.sync({moving:at||xs.running()}),pi.sync(),Ji!==null&&!pi.hasActivePointer&&vr(),kx(),C?il.visible=!1:Px();let X=!1;Xe=!1;try{if(Je&&!C){if(Je.composer.render(),Xe||!Z.check())throw Error("Enhanced rendering failed.")}else if(F.render(Me,k),Xe)throw Error("Board rendering shader failed.");ze++,X=!0}catch{Xe&&Gr.useColorFallback()?(Xe=!1,ye()):Je&&!C?(pt("Enhanced rendering could not complete. Balanced rendering is active."),ye()):Ue("The graphics device could not draw this view. Try Low quality or reopen 3D.")}X&&(gS(),MS())}let sv=C=>{vr(),mo(new DOMException("The graphics context was interrupted.","AbortError")),C.preventDefault(),De=!0,xe.setState({contextAvailable:!1}),R.disabled=!0,Ue("The graphics context was interrupted. The board and selection are retained while the browser recovers.",!0)},ov=()=>{Se&&(De=!1,xe.setState({contextAvailable:!0}),R.disabled=!1,Oe(),Qe?.dispose(),Qe=We(),Me.environment=Qe?.texture||null,F.shadowMap.needsUpdate=!0,Fe="balanced",Ti.apply(!1),ae(),R.value=Fe,h.dataset.quality=Fe,Ue("Graphics restored. Balanced rendering is active; High quality can be selected again."),gs(),ye())};F.domElement.addEventListener("webglcontextlost",sv),F.domElement.addEventListener("webglcontextrestored",ov);let av=()=>{document.hidden&&vr(),xe.setState({documentVisible:!document.hidden}),document.hidden||(xs.resume(),ye())};document.addEventListener("visibilitychange",av);let cv=C=>{let X=C.composedPath();!X.includes(ya)&&!X.includes(P)&&W(!1)},lv=C=>{C.key==="Escape"&&!P.hidden?(W(!1,!0),C.preventDefault(),C.stopImmediatePropagation()):C.key==="Escape"&&ro.open&&(ro.open=!1,tl.focus(),C.preventDefault(),C.stopImmediatePropagation())};return document.addEventListener("pointerdown",cv),d.addEventListener("keydown",lv,!0),B.retain(Me),Vi(n),lt(oe,!1),cS(t.boardPath?globalThis.KiCadRepoModels.modelSource(s):null),{host:h,board:a,pickDemoFace:_S,createDemoSurface(C,X){if(Z.invalidate(),!Se)throw new Error("The 3D view is closed.");return pi.createSurface(C,X)},setDemoInputHandler(C){C===null&&vr(),pi.setInputHandler(C)},objectVisibilityCapabilities(){return{supportedTypes:[...Un.supportedTypes],unsupportedTypes:["graphics","texts","regions","dimensions","rooms","footprints"]}},setObjectVisibility(C={}){let X=dx(C||{});(X.side!==Un.side||JSON.stringify(X.hiddenTypes)!==JSON.stringify(Un.hiddenTypes))&&(tt=!0),Un=X;for(let{mesh:le,type:Te,layer:Ae}of to)le.visible=Un.visible(Te,Ae);return ad(),Hi(zn),{hiddenTypes:[...Un.hiddenTypes],side:Un.side,supportedTypes:[...Un.supportedTypes],unsupportedTypes:[...Un.unsupportedTypes]}},setMeasurementMode:oo,clearMeasurements:Bx,measurementState(){return{mode:tn,unit:_s,...Ci.snapshot()}},setQuality(C){return Se?lt(C):Fe},setAppearance(C){return Se?Vi(C):xt},getAppearance(){return xt},getCopperLayers(){return pe.map(C=>C.name)},getVisibleCopperLayers(){return Hm()},setVisibleCopperLayers:Ax,getRenderStats(){return{...nx(p.clientWidth,p.clientHeight,globalThis.devicePixelRatio,j.maxDimension,Fe,j),...B.stats(),zones:{...o.stats(),...ce},modelGraph:{...ue.stats(),decodeConcurrency:Ee,imagePreflight:"png-jpeg"},padGeometryCache:de.stats(),selectionMaterials:xr.stats(),appearance:xt,netGlow:Ma.stats(),effectiveLayerColors:!!qe||Ye.get()>0||xt!=="realistic",renderedPixels:F.domElement.width*F.domElement.height,expansion:{amount:Ye.get(),target:xs.target(),running:xs.running(),...Ye.phases(),frames:Mx,cpuMilliseconds:Sx,maxFrameMilliseconds:Vm,frontComponentOffset:Ye.componentOffset("F.Cu"),backComponentOffset:Ye.componentOffset("B.Cu"),layerOffsets:pe.map(X=>({name:X.name,offset:Ye.offset(X.name)}))},renderActivity:{...xe.stats(),observesIntersection:!!tv},selectionWorkload:{...Sa},modelUpdates:{...Jc.stats(),cpuMilliseconds:yx},copperLayers:[...we],translucency:At.stats(),graphicsTier:j.tier,defaultQuality:j.defaultQuality,maxDimension:j.maxDimension,antialias:G.getContextAttributes()?.antialias===!0,logarithmicDepth:F.capabilities.logarithmicDepthBuffer,floatTargets:j.premium||F.extensions.has("EXT_color_buffer_float"),presentationStage:Ti.enabled,environmentLighting:!!Me.environment,ambientOcclusion:!!Je?.occlusion,graphicsHealth:Z.stats(),silkscreenDetail:id.stats(),antialiasMethod:Je?"smaa":"none",renderCount:ze,contextLost:De,gpuTextures:F.info.memory.textures,drawCalls:F.info.render.calls,loadedModelCount:Kc.size,componentCount:a.components.length}},restoreExpand:C=>ud(C,!0),setExplode:ud,getExplode:()=>Ye.get(),setExpand:ud,getExpand:()=>Ye.get(),setAnalysisOverlay(C,X){Z.invalidate();let le=Gr.setAnalysisOverlay(C,X);return _x(),Ex(le)},getAnalysisOverlayState:()=>Ex(),setAnalysisProbes:Gr.setAnalysisProbes,setAnalysisOpacity:Gr.setAnalysisOpacity,setSelection:Hi,focusPart(C){if(!Se||typeof C!="string")return!1;let X=a.components.flatMap((je,$e)=>je.id===C?[$e]:[]);if(X.length!==1)return!1;let le=X[0];if(!ma[le]||!sn||!od[le])return!1;Fn.updateWorldMatrix(!0,!0);let Te=zr.get(le),Ae=new zt;if(Te?.children.length)Ae.setFromObject(Te);else{let je=new nt;if(sn.getMatrixAt(le,je),je.determinant()===0)return!1;sn.geometry.boundingBox||sn.geometry.computeBoundingBox(),Ae.copy(sn.geometry.boundingBox).applyMatrix4(new nt().multiplyMatrices(sn.matrixWorld,je))}if(Ae.isEmpty())return!1;gs();let Pe=XE(Ae.min.toArray(),Ae.max.toArray(),a.components[le].layer,k.fov,k.aspect);if(!Pe)return!1;k.position.fromArray(Pe.position),Ie.target.fromArray(Pe.target),k.up.fromArray(Pe.up);let Ge=k.position.distanceTo(Ie.target);return Ie.minDistance=Math.min(Ie.minDistance,Ge),Ie.maxDistance=Math.max(Ie.maxDistance,Ge),tt=!0,Ie.update(),Fm(),ye(),!0},clearSelection:Km,projectAnchor:nv,setAnchor(C){fl=C&&typeof C=="object"?C:null,eg="",fl?rv():t.onAnchor?.({anchor:null,point:null})},setSelectionDim(C){return Ea=!!C,Hi(zn),Ea},setSelectionStyle(C){let X=mm(C);return Ea&&X.mode===ao.mode&&X.color===ao.color?{...X}:(Ea=!0,ao=X,Hi(zn),{...X})},selectionAppearanceCapabilities(){return{dim:!0,bright:!0,isolate:!0,sourceColors:!0,instanceColors:!0,desaturatesTextures:!0}},setSelectionMode(C){$m=["all","part","net","pin"].includes(C)?C:"all"},fit(C=!1){Se&&io(C)},getCameraState(){return{position:k.position.toArray(),target:Ie.target.toArray(),up:k.up.toArray()}},setCameraState(C){if(!Se)return!1;let X=WE(C),le=Ie.enableDamping;ei(),mr(),Ie.enableDamping=!1,Ie.update(),k.position.fromArray(X.position),Ie.target.fromArray(X.target),k.up.fromArray(X.up);let Te=k.position.distanceTo(Ie.target);return Ie.minDistance=Math.min(Ie.minDistance,Te),Ie.maxDistance=Math.max(Ie.maxDistance,Te),Ie.update(),Ie.enableDamping=le,tt=!0,ga(),ye(),!0},setView(C){return!Se||!Qh.some(X=>X.id===C)?!1:(tt=!0,io(C),!0)},zoom(C){if(!Se||!Number.isFinite(C)||C<=0)return;let X=k.position.clone().sub(Ie.target),le=Math.max(Ie.minDistance,Math.min(Ie.maxDistance,X.length()/C));X.length()>0&&k.position.copy(Ie.target).add(X.setLength(le)),Ie.update()},setTheme(C){Se&&(h.dataset.theme=C?"dark":"light",ae(),fi.material.color.setHex(C?16768893:10179840),uo.material.color.setHex(C?16768893:10179840),gd(),ye())},selectReference(C){let X=gx.get(C);if(X==null||!sn||!od[X]||!Se||!ma[X])return!1;let le=zr.get(X);if(le?.children.length){let $e=a.components[X],[rt,ke]=K($e.at);return Zm($e,new q(rt,ke,($e.layer?.startsWith("B.")?Ne:he)+Ye.componentOffset($e.layer?.startsWith("B.")?"B.Cu":"F.Cu")),le),!0}let Te=new nt;if(sn.getMatrixAt(X,Te),Te.determinant()===0)return!1;let Ae=a.components[X],[Pe,Ge]=K(Ae.at),je=new q(Pe,Ge,(Ae.layer?.startsWith("B.")?Ne-1.1:he+1.1)+Ye.componentOffset(Ae.layer?.startsWith("B.")?"B.Cu":"F.Cu"));return sn.localToWorld(je),Zm(Ae,je,sn,X),!0},setPopulation(C){if(!(!sn||!Se)&&(ma=lM(a.components,C),ad(),Hi(zn),hi?.record?.ref)){let X=gx.get(hi.record.ref);X!=null&&!ma[X]&&Km()}},dispose(){id.dispose(),vr(),mo(new DOMException("The 3D view was closed.","AbortError")),pi.dispose();for(let[C,X]of[["pointerdown",qx],["pointermove",Kx],["pointerup",Zx],["pointercancel",md],["lostpointercapture",md]])F.domElement.removeEventListener(C,X,!0);d.removeEventListener("keydown",Jx,!0),document.defaultView?.removeEventListener("blur",vr),tn&&t.onMeasurementMode?.(!1),Se=!1,xs.dispose(),Ri.oninput=null,Jc.dispose(),Gr.dispose(),Zc?.dispose(),xe.dispose(),cancelAnimationFrame(ES),ev.disconnect(),tv?.disconnect(),Ie.removeEventListener("change",ye),Ie.removeEventListener("change",ga),Ie.removeEventListener("start",ei),Ie.removeEventListener("end",mr),_t!==null&&clearTimeout(_t),_t=null,Ie.dispose(),Oe(),Qe?.dispose(),F.domElement.removeEventListener("webglcontextlost",sv),F.domElement.removeEventListener("webglcontextrestored",ov),document.removeEventListener("pointerdown",cv),d.removeEventListener("keydown",lv,!0),d.removeEventListener("keydown",zx),F.domElement.removeEventListener("pointerdown",Qx,!0),document.removeEventListener("visibilitychange",av),Ma.dispose(),xr.dispose(),At.dispose(),Me.traverse(C=>C.shadow?.dispose?.()),B.retain(Me),yr.forEach(C=>B.track(C)),B.track(Cx),B.dispose(),Me.clear(),Fn.clear(),pa.clear(),fa.clear(),ui.clear(),dn.length=0,to.length=0,en.length=0,od.length=0,zr.clear(),yr.clear(),de.clear(),Aa.dispose(),F.dispose(),F.domElement.width=1,F.domElement.height=1,h.remove()}}}return PS(UI);})();