hytopia 0.6.33 → 0.6.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/node-server.mjs CHANGED
@@ -411,7 +411,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
411
411
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
412
412
  if (condition) { yield value; }`)};import{Buffer as HF1}from"node:buffer";import{StringDecoder as zF1}from"node:string_decoder";var UL=(Z,J,X)=>{if(X)return;if(Z)return{transform:FF1.bind(void 0,new TextEncoder)};let Y=new zF1(J);return{transform:qF1.bind(void 0,Y),final:UF1.bind(void 0,Y)}},FF1=function*(Z,J){if(HF1.isBuffer(J))yield WZ(J);else if(typeof J==="string")yield Z.encode(J);else yield J},qF1=function*(Z,J){yield b8(J)?Z.write(J):J},UF1=function*(Z){let J=Z.end();if(J!=="")yield J};import{callbackify as Dd}from"node:util";var RP=Dd(async(Z,J,X,Y)=>{J.currentIterable=Z(...X);try{for await(let $ of J.currentIterable)Y.push($)}finally{delete J.currentIterable}}),LL=async function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:Y=BF1}=J[X];for await(let $ of Y(Z))yield*LL($,J,X+1)},Cd=async function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*LF1(X,Number(J),Z)},LF1=async function*(Z,J,X){if(Z===void 0)return;for await(let Y of Z())yield*LL(Y,X,J+1)},Td=Dd(async({currentIterable:Z},J)=>{if(Z!==void 0){await(J?Z.throw(J):Z.return());return}if(J)throw J}),BF1=function*(Z){yield Z};var MP=(Z,J,X,Y)=>{try{for(let $ of Z(...J))X.push($);Y()}catch($){Y($)}},Ed=(Z,J)=>[...J.flatMap((X)=>[...FY(X,Z,0)]),...v3(Z)],FY=function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:Y=jF1}=J[X];for(let $ of Y(Z))yield*FY($,J,X+1)},v3=function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*wF1(X,Number(J),Z)},wF1=function*(Z,J,X){if(Z===void 0)return;for(let Y of Z())yield*FY(Y,X,J+1)},jF1=function*(Z){yield Z};var PP=({value:Z,value:{transform:J,final:X,writableObjectMode:Y,readableObjectMode:$},optionName:Q},{encoding:K})=>{let W={},G=Id(Z,K,Q),V=zY(J),H=zY(X),F=V?RP.bind(void 0,LL,W):MP.bind(void 0,FY),z=V||H?RP.bind(void 0,Cd,W):MP.bind(void 0,v3),q=V||H?Td.bind(void 0,W):void 0;return{stream:new OF1({writableObjectMode:Y,writableHighWaterMark:kd(Y),readableObjectMode:$,readableHighWaterMark:kd($),transform(L,B,w){F([L,G,0],this,w)},flush(L){z([G],this,L)},destroy:q})}},BL=(Z,J,X,Y)=>{let $=J.filter(({type:K})=>K==="generator"),Q=Y?$.reverse():$;for(let{value:K,optionName:W}of Q){let G=Id(K,X,W);Z=Ed(G,Z)}return Z},Id=({transform:Z,final:J,binary:X,writableObjectMode:Y,readableObjectMode:$,preserveNewlines:Q},K,W)=>{let G={};return[{transform:Rd(Y,W)},UL(X,K,Y),qL(X,Q,Y,G),{transform:Z,final:J},{transform:Md($,W)},Nd({binary:X,preserveNewlines:Q,readableObjectMode:$,state:G})].filter(Boolean)};var _d=(Z,J)=>{for(let X of NF1(Z))RF1(Z,X,J)},NF1=(Z)=>new Set(Object.entries(Z).filter(([,{direction:J}])=>J==="input").map(([J])=>Number(J))),RF1=(Z,J,X)=>{let{stdioItems:Y}=Z[J],$=Y.filter(({contents:W})=>W!==void 0);if($.length===0)return;if(J!==0){let[{type:W,optionName:G}]=$;throw new TypeError(`Only the \`stdin\` option, not \`${G}\`, can be ${MJ[W]} with synchronous methods.`)}let K=$.map(({contents:W})=>W).map((W)=>MF1(W,Y));X.input=P3(K)},MF1=(Z,J)=>{let X=BL(Z,J,"utf8",!0);return PF1(X),P3(X)},PF1=(Z)=>{let J=Z.find((X)=>typeof X!=="string"&&!b8(X));if(J!==void 0)throw new TypeError(`The \`stdin\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${J}.`)};import{writeFileSync as EF1,appendFileSync as kF1}from"node:fs";var wL=({stdioItems:Z,encoding:J,verboseInfo:X,fdNumber:Y})=>Y!=="all"&&dQ(X,Y)&&!p5.has(J)&&DF1(Y)&&(Z.some(({type:$,value:Q})=>$==="native"&&CF1.has(Q))||Z.every(({type:$})=>M9.has($))),DF1=(Z)=>Z===1||Z===2,CF1=new Set(["pipe","overlapped"]),vd=async(Z,J,X,Y)=>{for await(let $ of Z)if(!TF1(J))Ad($,X,Y)},Sd=(Z,J,X)=>{for(let Y of Z)Ad(Y,J,X)},TF1=(Z)=>Z._readableState.pipes.length>0,Ad=(Z,J,X)=>{let Y=kU(Z);Z7({type:"output",verboseMessage:Y,fdNumber:J,verboseInfo:X})};var xd=({fileDescriptors:Z,syncResult:{output:J},options:X,isMaxBuffer:Y,verboseInfo:$})=>{if(J===null)return{output:Array.from({length:3})};let Q={},K=new Set([]);return{output:J.map((G,V)=>IF1({result:G,fileDescriptors:Z,fdNumber:V,state:Q,outputFiles:K,isMaxBuffer:Y,verboseInfo:$},X)),...Q}},IF1=({result:Z,fileDescriptors:J,fdNumber:X,state:Y,outputFiles:$,isMaxBuffer:Q,verboseInfo:K},{buffer:W,encoding:G,lines:V,stripFinalNewline:H,maxBuffer:F})=>{if(Z===null)return;let z=hu(Z,Q,F),q=WZ(z),{stdioItems:U,objectMode:L}=J[X],B=_F1([q],U,G,Y),{serializedResult:w,finalResult:O=w}=vF1({chunks:B,objectMode:L,encoding:G,lines:V,stripFinalNewline:H,fdNumber:X});SF1({serializedResult:w,fdNumber:X,state:Y,verboseInfo:K,encoding:G,stdioItems:U,objectMode:L});let N=W[X]?O:void 0;try{if(Y.error===void 0)AF1(w,U,$);return N}catch(R){return Y.error=R,N}},_F1=(Z,J,X,Y)=>{try{return BL(Z,J,X,!1)}catch($){return Y.error=$,Z}},vF1=({chunks:Z,objectMode:J,encoding:X,lines:Y,stripFinalNewline:$,fdNumber:Q})=>{if(J)return{serializedResult:Z};if(X==="buffer")return{serializedResult:P3(Z)};let K=sb(Z,X);if(Y[Q])return{serializedResult:K,finalResult:NP(K,!$[Q],J)};return{serializedResult:K}},SF1=({serializedResult:Z,fdNumber:J,state:X,verboseInfo:Y,encoding:$,stdioItems:Q,objectMode:K})=>{if(!wL({stdioItems:Q,encoding:$,verboseInfo:Y,fdNumber:J}))return;let W=NP(Z,!1,K);try{Sd(W,J,Y)}catch(G){X.error??=G}},AF1=(Z,J,X)=>{for(let{path:Y,append:$}of J.filter(({type:Q})=>zL.has(Q))){let Q=typeof Y==="string"?Y:Y.toString();if($||X.has(Q))kF1(Y,Z);else X.add(Q),EF1(Y,Z)}};var hd=([,Z,J],X)=>{if(!X.all)return;if(Z===void 0)return J;if(J===void 0)return Z;if(Array.isArray(Z))return Array.isArray(J)?[...Z,...J]:[...Z,zZ(J,X,"all")];if(Array.isArray(J))return[zZ(Z,X,"all"),...J];if(b8(Z)&&b8(J))return IM([Z,J]);return`${Z}${J}`};import{once as DP}from"node:events";var fd=async(Z,J)=>{let[X,Y]=await xF1(Z);return J.isForcefullyTerminated??=!1,[X,Y]},xF1=async(Z)=>{let[J,X]=await Promise.allSettled([DP(Z,"spawn"),DP(Z,"exit")]);if(J.status==="rejected")return[];return X.status==="rejected"?yd(Z):X.value},yd=async(Z)=>{try{return await DP(Z,"exit")}catch{return yd(Z)}},bd=async(Z)=>{let[J,X]=await Z;if(!hF1(J,X)&&CP(J,X))throw new J7;return[J,X]},hF1=(Z,J)=>Z===void 0&&J===void 0,CP=(Z,J)=>Z!==0||J!==null;var gd=({error:Z,status:J,signal:X,output:Y},{maxBuffer:$})=>{let Q=fF1(Z,J,X),K=Q?.code==="ETIMEDOUT",W=xu(Q,Y,$);return{resultError:Q,exitCode:J,signal:X,timedOut:K,isMaxBuffer:W}},fF1=(Z,J,X)=>{if(Z!==void 0)return Z;return CP(J,X)?new J7:void 0};var md=(Z,J,X)=>{let{file:Y,commandArguments:$,command:Q,escapedCommand:K,startTime:W,verboseInfo:G,options:V,fileDescriptors:H}=bF1(Z,J,X),F=uF1({file:Y,commandArguments:$,options:V,command:Q,escapedCommand:K,verboseInfo:G,fileDescriptors:H,startTime:W});return rQ(F,G,V)},bF1=(Z,J,X)=>{let{command:Y,escapedCommand:$,startTime:Q,verboseInfo:K}=_U(Z,J,X),W=gF1(X),{file:G,commandArguments:V,options:H}=eU(Z,J,W);mF1(H);let F=Bd(H,K);return{file:G,commandArguments:V,command:Y,escapedCommand:$,startTime:Q,verboseInfo:K,options:H,fileDescriptors:F}},gF1=(Z)=>Z.node&&!Z.ipc?{...Z,ipc:!1}:Z,mF1=({ipc:Z,ipcInput:J,detached:X,cancelSignal:Y})=>{if(J)jL("ipcInput");if(Z)jL("ipc: true");if(X)jL("detached: true");if(Y)jL("cancelSignal")},jL=(Z)=>{throw new TypeError(`The "${Z}" option cannot be used with synchronous methods.`)},uF1=({file:Z,commandArguments:J,options:X,command:Y,escapedCommand:$,verboseInfo:Q,fileDescriptors:K,startTime:W})=>{let G=dF1({file:Z,commandArguments:J,options:X,command:Y,escapedCommand:$,fileDescriptors:K,startTime:W});if(G.failed)return G;let{resultError:V,exitCode:H,signal:F,timedOut:z,isMaxBuffer:q}=gd(G,X),{output:U,error:L=V}=xd({fileDescriptors:K,syncResult:G,options:X,isMaxBuffer:q,verboseInfo:Q}),B=U.map((O,N)=>zZ(O,X,N)),w=zZ(hd(U,X),X,"all");return lF1({error:L,exitCode:H,signal:F,timedOut:z,isMaxBuffer:q,stdio:B,all:w,options:X,command:Y,escapedCommand:$,startTime:W})},dF1=({file:Z,commandArguments:J,options:X,command:Y,escapedCommand:$,fileDescriptors:Q,startTime:K})=>{try{_d(Q,X);let W=cF1(X);return yF1(Z,J,W)}catch(W){return oQ({error:W,command:Y,escapedCommand:$,fileDescriptors:Q,options:X,startTime:K,isSync:!0})}},cF1=({encoding:Z,maxBuffer:J,...X})=>({...X,encoding:"buffer",maxBuffer:WL(J)}),lF1=({error:Z,exitCode:J,signal:X,timedOut:Y,isMaxBuffer:$,stdio:Q,all:K,options:W,command:G,escapedCommand:V,startTime:H})=>Z===void 0?GL({command:G,escapedCommand:V,stdio:Q,all:K,ipcOutput:[],options:W,startTime:H}):_3({error:Z,command:G,escapedCommand:V,timedOut:Y,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:$,isForcefullyTerminated:!1,exitCode:J,signal:X,stdio:Q,all:K,ipcOutput:[],options:W,startTime:H,isSync:!0});import{setMaxListeners as vU1}from"node:events";import{spawn as SU1}from"node:child_process";import pd from"node:process";import{once as TP,on as pF1}from"node:events";var ud=({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y},{reference:$=!0,filter:Q}={})=>{return pQ({methodName:"getOneMessage",isSubprocess:X,ipc:Y,isConnected:nU(Z)}),iF1({anyProcess:Z,channel:J,isSubprocess:X,filter:Q,reference:$})},iF1=async({anyProcess:Z,channel:J,isSubprocess:X,filter:Y,reference:$})=>{cU(J,$);let Q=RJ(Z,J,X),K=new AbortController;try{return await Promise.race([nF1(Q,Y,K),aF1(Q,X,K),sF1(Q,X,K)])}catch(W){throw iQ(Z),W}finally{K.abort(),lU(J,$)}},nF1=async(Z,J,{signal:X})=>{if(J===void 0){let[Y]=await TP(Z,"message",{signal:X});return Y}for await(let[Y]of pF1(Z,"message",{signal:X}))if(J(Y))return Y},aF1=async(Z,J,{signal:X})=>{await TP(Z,"disconnect",{signal:X}),Tm(J)},sF1=async(Z,J,{signal:X})=>{let[Y]=await TP(Z,"strict:error",{signal:X});throw mU(Y,J)};import{once as cd,on as oF1}from"node:events";var ld=({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y},{reference:$=!0}={})=>EP({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y,shouldAwait:!X,reference:$}),EP=({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y,shouldAwait:$,reference:Q})=>{pQ({methodName:"getEachMessage",isSubprocess:X,ipc:Y,isConnected:nU(Z)}),cU(J,Q);let K=RJ(Z,J,X),W=new AbortController,G={};return rF1(Z,K,W),tF1({ipcEmitter:K,isSubprocess:X,controller:W,state:G}),eF1({anyProcess:Z,channel:J,ipcEmitter:K,isSubprocess:X,shouldAwait:$,controller:W,state:G,reference:Q})},rF1=async(Z,J,X)=>{try{await cd(J,"disconnect",{signal:X.signal}),X.abort()}catch{}},tF1=async({ipcEmitter:Z,isSubprocess:J,controller:X,state:Y})=>{try{let[$]=await cd(Z,"strict:error",{signal:X.signal});Y.error=mU($,J),X.abort()}catch{}},eF1=async function*({anyProcess:Z,channel:J,ipcEmitter:X,isSubprocess:Y,shouldAwait:$,controller:Q,state:K,reference:W}){try{for await(let[G]of oF1(X,"message",{signal:Q.signal}))dd(K),yield G}catch{dd(K)}finally{if(Q.abort(),lU(J,W),!Y)iQ(Z);if($)await Z}},dd=({error:Z})=>{if(Z)throw Z};var id=(Z,{ipc:J})=>{Object.assign(Z,ad(Z,!1,J))},nd=()=>{let Z=pd,J=!0,X=pd.channel!==void 0;return{...ad(Z,!0,X),getCancelSignal:em.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:!0,ipc:X})}},ad=(Z,J,X)=>({sendMessage:rU.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getOneMessage:ud.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getEachMessage:ld.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X})});import{ChildProcess as Zq1}from"node:child_process";import{PassThrough as Jq1,Readable as Xq1,Writable as Yq1,Duplex as $q1}from"node:stream";var sd=({error:Z,command:J,escapedCommand:X,fileDescriptors:Y,options:$,startTime:Q,verboseInfo:K})=>{wP(Y);let W=new Zq1;Qq1(W,Y),Object.assign(W,{readable:Kq1,writable:Wq1,duplex:Gq1});let G=oQ({error:Z,command:J,escapedCommand:X,fileDescriptors:Y,options:$,startTime:Q,isSync:!1}),V=Vq1(G,K,$);return{subprocess:W,promise:V}},Qq1=(Z,J)=>{let X=S3(),Y=S3(),$=S3(),Q=Array.from({length:J.length-3},S3),K=S3(),W=[X,Y,$,...Q];Object.assign(Z,{stdin:X,stdout:Y,stderr:$,all:K,stdio:W})},S3=()=>{let Z=new Jq1;return Z.end(),Z},Kq1=()=>new Xq1({read(){}}),Wq1=()=>new Yq1({write(){}}),Gq1=()=>new $q1({read(){},write(){}}),Vq1=async(Z,J,X)=>rQ(Z,J,X);import{createReadStream as od,createWriteStream as rd}from"node:fs";import{Buffer as Hq1}from"node:buffer";import{Readable as A3,Writable as zq1,Duplex as Fq1}from"node:stream";var ed=(Z,J)=>FL(qq1,Z,J,!1),x3=({type:Z,optionName:J})=>{throw new TypeError(`The \`${J}\` option cannot be ${MJ[Z]}.`)},td={fileNumber:x3,generator:PP,asyncGenerator:PP,nodeStream:({value:Z})=>({stream:Z}),webTransform({value:{transform:Z,writableObjectMode:J,readableObjectMode:X}}){let Y=J||X;return{stream:Fq1.fromWeb(Z,{objectMode:Y})}},duplex:({value:{transform:Z}})=>({stream:Z}),native(){}},qq1={input:{...td,fileUrl:({value:Z})=>({stream:od(Z)}),filePath:({value:{file:Z}})=>({stream:od(Z)}),webStream:({value:Z})=>({stream:A3.fromWeb(Z)}),iterable:({value:Z})=>({stream:A3.from(Z)}),asyncIterable:({value:Z})=>({stream:A3.from(Z)}),string:({value:Z})=>({stream:A3.from(Z)}),uint8Array:({value:Z})=>({stream:A3.from(Hq1.from(Z))})},output:{...td,fileUrl:({value:Z})=>({stream:rd(Z)}),filePath:({value:{file:Z,append:J}})=>({stream:rd(Z,J?{flags:"a"}:{})}),webStream:({value:Z})=>({stream:zq1.fromWeb(Z)}),iterable:x3,asyncIterable:x3,string:x3,uint8Array:x3}};import{on as Uq1,once as Zc}from"node:events";import{PassThrough as Lq1,getDefaultHighWaterMark as Bq1}from"node:stream";import{finished as Yc}from"node:stream/promises";function qY(Z){if(!Array.isArray(Z))throw new TypeError(`Expected an array, got \`${typeof Z}\`.`);for(let $ of Z)kP($);let J=Z.some(({readableObjectMode:$})=>$),X=wq1(Z,J),Y=new $c({objectMode:J,writableHighWaterMark:X,readableHighWaterMark:X});for(let $ of Z)Y.add($);return Y}var wq1=(Z,J)=>{if(Z.length===0)return Bq1(J);let X=Z.filter(({readableObjectMode:Y})=>Y===J).map(({readableHighWaterMark:Y})=>Y);return Math.max(...X)};class $c extends Lq1{#Z=new Set([]);#J=new Set([]);#Y=new Set([]);#X;#$=Symbol("unpipe");#H=new WeakMap;add(Z){if(kP(Z),this.#Z.has(Z))return;this.#Z.add(Z),this.#X??=jq1(this,this.#Z,this.#$);let J=Rq1({passThroughStream:this,stream:Z,streams:this.#Z,ended:this.#J,aborted:this.#Y,onFinished:this.#X,unpipeEvent:this.#$});this.#H.set(Z,J),Z.pipe(this,{end:!1})}async remove(Z){if(kP(Z),!this.#Z.has(Z))return!1;let J=this.#H.get(Z);if(J===void 0)return!1;return this.#H.delete(Z),Z.unpipe(this),await J,!0}}var jq1=async(Z,J,X)=>{OL(Z,Jc);let Y=new AbortController;try{await Promise.race([Oq1(Z,Y),Nq1(Z,J,X,Y)])}finally{Y.abort(),OL(Z,-Jc)}},Oq1=async(Z,{signal:J})=>{try{await Yc(Z,{signal:J,cleanup:!0})}catch(X){throw Qc(Z,X),X}},Nq1=async(Z,J,X,{signal:Y})=>{for await(let[$]of Uq1(Z,"unpipe",{signal:Y}))if(J.has($))$.emit(X)},kP=(Z)=>{if(typeof Z?.pipe!=="function")throw new TypeError(`Expected a readable stream, got: \`${typeof Z}\`.`)},Rq1=async({passThroughStream:Z,stream:J,streams:X,ended:Y,aborted:$,onFinished:Q,unpipeEvent:K})=>{OL(Z,Xc);let W=new AbortController;try{await Promise.race([Mq1(Q,J,W),Pq1({passThroughStream:Z,stream:J,streams:X,ended:Y,aborted:$,controller:W}),Dq1({stream:J,streams:X,ended:Y,aborted:$,unpipeEvent:K,controller:W})])}finally{W.abort(),OL(Z,-Xc)}if(X.size>0&&X.size===Y.size+$.size)if(Y.size===0&&$.size>0)IP(Z);else Cq1(Z)},Mq1=async(Z,J,{signal:X})=>{try{if(await Z,!X.aborted)IP(J)}catch(Y){if(!X.aborted)Qc(J,Y)}},Pq1=async({passThroughStream:Z,stream:J,streams:X,ended:Y,aborted:$,controller:{signal:Q}})=>{try{if(await Yc(J,{signal:Q,cleanup:!0,readable:!0,writable:!1}),X.has(J))Y.add(J)}catch(K){if(Q.aborted||!X.has(J))return;if(Kc(K))$.add(J);else Wc(Z,K)}},Dq1=async({stream:Z,streams:J,ended:X,aborted:Y,unpipeEvent:$,controller:{signal:Q}})=>{if(await Zc(Z,$,{signal:Q}),!Z.readable)return Zc(Q,"abort",{signal:Q});J.delete(Z),X.delete(Z),Y.delete(Z)},Cq1=(Z)=>{if(Z.writable)Z.end()},Qc=(Z,J)=>{if(Kc(J))IP(Z);else Wc(Z,J)},Kc=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",IP=(Z)=>{if(Z.readable||Z.writable)Z.destroy()},Wc=(Z,J)=>{if(!Z.destroyed)Z.once("error",Tq1),Z.destroy(J)},Tq1=()=>{},OL=(Z,J)=>{let X=Z.getMaxListeners();if(X!==0&&X!==Number.POSITIVE_INFINITY)Z.setMaxListeners(X+J)},Jc=2,Xc=1;import{finished as Gc}from"node:stream/promises";var eQ=(Z,J)=>{Z.pipe(J),Eq1(Z,J),kq1(Z,J)},Eq1=async(Z,J)=>{if(F4(Z)||F4(J))return;try{await Gc(Z,{cleanup:!0,readable:!0,writable:!1})}catch{}_P(J)},_P=(Z)=>{if(Z.writable)Z.end()},kq1=async(Z,J)=>{if(F4(Z)||F4(J))return;try{await Gc(J,{cleanup:!0,readable:!1,writable:!0})}catch{}vP(Z)},vP=(Z)=>{if(Z.readable)Z.destroy()};var Vc=(Z,J,X)=>{let Y=new Map;for(let[$,{stdioItems:Q,direction:K}]of Object.entries(J)){for(let{stream:W}of Q.filter(({type:G})=>M9.has(G)))Iq1(Z,W,K,$);for(let{stream:W}of Q.filter(({type:G})=>!M9.has(G)))vq1({subprocess:Z,stream:W,direction:K,fdNumber:$,pipeGroups:Y,controller:X})}for(let[$,Q]of Y.entries()){let K=Q.length===1?Q[0]:qY(Q);eQ(K,$)}},Iq1=(Z,J,X,Y)=>{if(X==="output")eQ(Z.stdio[Y],J);else eQ(J,Z.stdio[Y]);let $=_q1[Y];if($!==void 0)Z[$]=J;Z.stdio[Y]=J},_q1=["stdin","stdout","stderr"],vq1=({subprocess:Z,stream:J,direction:X,fdNumber:Y,pipeGroups:$,controller:Q})=>{if(J===void 0)return;Sq1(J,Q);let[K,W]=X==="output"?[J,Z.stdio[Y]]:[Z.stdio[Y],J],G=$.get(K)??[];$.set(K,[...G,W])},Sq1=(Z,{signal:J})=>{if(F4(Z))VY(Z,Aq1,J)},Aq1=2;import{addAbortListener as fq1}from"node:events";var UY=[];UY.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")UY.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")UY.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var NL=(Z)=>!!Z&&typeof Z==="object"&&typeof Z.removeListener==="function"&&typeof Z.emit==="function"&&typeof Z.reallyExit==="function"&&typeof Z.listeners==="function"&&typeof Z.kill==="function"&&typeof Z.pid==="number"&&typeof Z.on==="function",SP=Symbol.for("signal-exit emitter"),AP=globalThis,xq1=Object.defineProperty.bind(Object);class Hc{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(AP[SP])return AP[SP];xq1(AP,SP,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Z,J){this.listeners[Z].push(J)}removeListener(Z,J){let X=this.listeners[Z],Y=X.indexOf(J);if(Y===-1)return;if(Y===0&&X.length===1)X.length=0;else X.splice(Y,1)}emit(Z,J,X){if(this.emitted[Z])return!1;this.emitted[Z]=!0;let Y=!1;for(let $ of this.listeners[Z])Y=$(J,X)===!0||Y;if(Z==="exit")Y=this.emit("afterExit",J,X)||Y;return Y}}class hP{}var hq1=(Z)=>{return{onExit(J,X){return Z.onExit(J,X)},load(){return Z.load()},unload(){return Z.unload()}}};class zc extends hP{onExit(){return()=>{}}load(){}unload(){}}class Fc extends hP{#Z=xP.platform==="win32"?"SIGINT":"SIGHUP";#J=new Hc;#Y;#X;#$;#H={};#F=!1;constructor(Z){super();this.#Y=Z,this.#H={};for(let J of UY)this.#H[J]=()=>{let X=this.#Y.listeners(J),{count:Y}=this.#J,$=Z;if(typeof $.__signal_exit_emitter__==="object"&&typeof $.__signal_exit_emitter__.count==="number")Y+=$.__signal_exit_emitter__.count;if(X.length===Y){this.unload();let Q=this.#J.emit("exit",null,J),K=J==="SIGHUP"?this.#Z:J;if(!Q)Z.kill(Z.pid,K)}};this.#$=Z.reallyExit,this.#X=Z.emit}onExit(Z,J){if(!NL(this.#Y))return()=>{};if(this.#F===!1)this.load();let X=J?.alwaysLast?"afterExit":"exit";return this.#J.on(X,Z),()=>{if(this.#J.removeListener(X,Z),this.#J.listeners.exit.length===0&&this.#J.listeners.afterExit.length===0)this.unload()}}load(){if(this.#F)return;this.#F=!0,this.#J.count+=1;for(let Z of UY)try{let J=this.#H[Z];if(J)this.#Y.on(Z,J)}catch(J){}this.#Y.emit=(Z,...J)=>{return this.#G(Z,...J)},this.#Y.reallyExit=(Z)=>{return this.#W(Z)}}unload(){if(!this.#F)return;this.#F=!1,UY.forEach((Z)=>{let J=this.#H[Z];if(!J)throw new Error("Listener not defined for signal: "+Z);try{this.#Y.removeListener(Z,J)}catch(X){}}),this.#Y.emit=this.#X,this.#Y.reallyExit=this.#$,this.#J.count-=1}#W(Z){if(!NL(this.#Y))return 0;return this.#Y.exitCode=Z||0,this.#J.emit("exit",this.#Y.exitCode,null),this.#$.call(this.#Y,this.#Y.exitCode)}#G(Z,...J){let X=this.#X;if(Z==="exit"&&NL(this.#Y)){if(typeof J[0]==="number")this.#Y.exitCode=J[0];let Y=X.call(this.#Y,Z,...J);return this.#J.emit("exit",this.#Y.exitCode,null),Y}else return X.call(this.#Y,Z,...J)}}var xP=globalThis.process,{onExit:qc,load:CR6,unload:TR6}=hq1(NL(xP)?new Fc(xP):new zc);var Uc=(Z,{cleanup:J,detached:X},{signal:Y})=>{if(!J||X)return;let $=qc(()=>{Z.kill()});fq1(Y,()=>{$()})};var Bc=({source:Z,sourcePromise:J,boundOptions:X,createNested:Y},...$)=>{let Q=IU(),{destination:K,destinationStream:W,destinationError:G,from:V,unpipeSignal:H}=yq1(X,Y,$),{sourceStream:F,sourceError:z}=gq1(Z,V),{options:q,fileDescriptors:U}=Y7.get(Z);return{sourcePromise:J,sourceStream:F,sourceOptions:q,sourceError:z,destination:K,destinationStream:W,destinationError:G,unpipeSignal:H,fileDescriptors:U,startTime:Q}},yq1=(Z,J,X)=>{try{let{destination:Y,pipeOptions:{from:$,to:Q,unpipeSignal:K}={}}=bq1(Z,J,...X),W=dU(Y,Q);return{destination:Y,destinationStream:W,from:$,unpipeSignal:K}}catch(Y){return{destinationError:Y}}},bq1=(Z,J,X,...Y)=>{if(Array.isArray(X))return{destination:J(Lc,Z)(X,...Y),pipeOptions:Z};if(typeof X==="string"||X instanceof URL||EM(X)){if(Object.keys(Z).length>0)throw new TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[$,Q,K]=OU(X,...Y);return{destination:J(Lc)($,Q,K),pipeOptions:K}}if(Y7.has(X)){if(Object.keys(Z).length>0)throw new TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:X,pipeOptions:Y[0]}}throw new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${X}`)},Lc=({options:Z})=>({options:{...Z,stdin:"pipe",piped:!0}}),gq1=(Z,J)=>{try{return{sourceStream:nQ(Z,J)}}catch(X){return{sourceError:X}}};var jc=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:Y,fileDescriptors:$,sourceOptions:Q,startTime:K})=>{let W=mq1({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:Y});if(W!==void 0)throw fP({error:W,fileDescriptors:$,sourceOptions:Q,startTime:K})},mq1=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:Y})=>{if(J!==void 0&&Y!==void 0)return Y;if(Y!==void 0)return vP(Z),Y;if(J!==void 0)return _P(X),J},fP=({error:Z,fileDescriptors:J,sourceOptions:X,startTime:Y})=>oQ({error:Z,command:wc,escapedCommand:wc,fileDescriptors:J,options:X,startTime:Y,isSync:!1}),wc="source.pipe(destination)";var Oc=async(Z)=>{let[{status:J,reason:X,value:Y=X},{status:$,reason:Q,value:K=Q}]=await Z;if(!K.pipedFrom.includes(Y))K.pipedFrom.push(Y);if($==="rejected")throw K;if(J==="rejected")throw Y;return K};import{finished as uq1}from"node:stream/promises";var Nc=(Z,J,X)=>{let Y=RL.has(J)?cq1(Z,J):dq1(Z,J);return VY(Z,pq1,X.signal),VY(J,iq1,X.signal),lq1(J),Y},dq1=(Z,J)=>{let X=qY([Z]);return eQ(X,J),RL.set(J,X),X},cq1=(Z,J)=>{let X=RL.get(J);return X.add(Z),X},lq1=async(Z)=>{try{await uq1(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}RL.delete(Z)},RL=new WeakMap,pq1=2,iq1=1;import{aborted as nq1}from"node:util";var Rc=(Z,J)=>Z===void 0?[]:[aq1(Z,J)],aq1=async(Z,{sourceStream:J,mergedStream:X,fileDescriptors:Y,sourceOptions:$,startTime:Q})=>{await nq1(Z,J),await X.remove(J);let K=new Error("Pipe canceled by `unpipeSignal` option.");throw fP({error:K,fileDescriptors:Y,sourceOptions:$,startTime:Q})};var ML=(Z,...J)=>{if(B8(J[0]))return ML.bind(void 0,{...Z,boundOptions:{...Z.boundOptions,...J[0]}});let{destination:X,...Y}=Bc(Z,...J),$=sq1({...Y,destination:X});return $.pipe=ML.bind(void 0,{...Z,source:X,sourcePromise:$,boundOptions:{}}),$},sq1=async({sourcePromise:Z,sourceStream:J,sourceOptions:X,sourceError:Y,destination:$,destinationStream:Q,destinationError:K,unpipeSignal:W,fileDescriptors:G,startTime:V})=>{let H=oq1(Z,$);jc({sourceStream:J,sourceError:Y,destinationStream:Q,destinationError:K,fileDescriptors:G,sourceOptions:X,startTime:V});let F=new AbortController;try{let z=Nc(J,Q,F);return await Promise.race([Oc(H),...Rc(W,{sourceStream:J,mergedStream:z,sourceOptions:X,fileDescriptors:G,startTime:V})])}finally{F.abort()}},oq1=(Z,J)=>Promise.allSettled([Z,J]);import{setImmediate as YU1}from"node:timers/promises";import{on as rq1}from"node:events";import{getDefaultHighWaterMark as tq1}from"node:stream";var PL=({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:Y,encoding:$,preserveNewlines:Q})=>{let K=new AbortController;return eq1(J,K),Pc({stream:Z,controller:K,binary:X,shouldEncode:!Z.readableObjectMode&&Y,encoding:$,shouldSplit:!Z.readableObjectMode,preserveNewlines:Q})},eq1=async(Z,J)=>{try{await Z}catch{}finally{J.abort()}},yP=({stream:Z,onStreamEnd:J,lines:X,encoding:Y,stripFinalNewline:$,allMixed:Q})=>{let K=new AbortController;ZU1(J,K,Z);let W=Z.readableObjectMode&&!Q;return Pc({stream:Z,controller:K,binary:Y==="buffer",shouldEncode:!W,encoding:Y,shouldSplit:!W&&X,preserveNewlines:!$})},ZU1=async(Z,J,X)=>{try{await Z}catch{X.destroy()}finally{J.abort()}},Pc=({stream:Z,controller:J,binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K})=>{let W=rq1(Z,"data",{signal:J.signal,highWaterMark:Mc,highWatermark:Mc});return JU1({onStdoutChunk:W,controller:J,binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K})},bP=tq1(!0),Mc=bP,JU1=async function*({onStdoutChunk:Z,controller:J,binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K}){let W=XU1({binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K});try{for await(let[G]of Z)yield*FY(G,W,0)}catch(G){if(!J.signal.aborted)throw G}finally{yield*v3(W)}},XU1=({binary:Z,shouldEncode:J,encoding:X,shouldSplit:Y,preserveNewlines:$})=>[UL(Z,X,!J),qL(Z,$,!Y,{})].filter(Boolean);var Dc=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:Y,buffer:$,maxBuffer:Q,lines:K,allMixed:W,stripFinalNewline:G,verboseInfo:V,streamInfo:H})=>{let F=$U1({stream:Z,onStreamEnd:J,fdNumber:X,encoding:Y,allMixed:W,verboseInfo:V,streamInfo:H});if(!$){await Promise.all([QU1(Z),F]);return}let z=jP(G,X),q=yP({stream:Z,onStreamEnd:J,lines:K,encoding:Y,stripFinalNewline:z,allMixed:W}),[U]=await Promise.all([KU1({stream:Z,iterable:q,fdNumber:X,encoding:Y,maxBuffer:Q,lines:K}),F]);return U},$U1=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:Y,allMixed:$,verboseInfo:Q,streamInfo:{fileDescriptors:K}})=>{if(!wL({stdioItems:K[X]?.stdioItems,encoding:Y,verboseInfo:Q,fdNumber:X}))return;let W=yP({stream:Z,onStreamEnd:J,lines:!0,encoding:Y,stripFinalNewline:!0,allMixed:$});await vd(W,Z,X,Q)},QU1=async(Z)=>{if(await YU1(),Z.readableFlowing===null)Z.resume()},KU1=async({stream:Z,stream:{readableObjectMode:J},iterable:X,fdNumber:Y,encoding:$,maxBuffer:Q,lines:K})=>{try{if(J||K)return await YL(X,{maxBuffer:Q});if($==="buffer")return new Uint8Array(await $L(X,{maxBuffer:Q}));return await KL(X,{maxBuffer:Q})}catch(W){return Cc(vu({error:W,stream:Z,readableObjectMode:J,lines:K,encoding:$,fdNumber:Y}))}},gP=async(Z)=>{try{return await Z}catch(J){return Cc(J)}},Cc=({bufferedData:Z})=>nb(Z)?new Uint8Array(Z):Z;import{finished as WU1}from"node:stream/promises";var h3=async(Z,J,X,{isSameDirection:Y,stopOnExit:$=!1}={})=>{let Q=GU1(Z,X),K=new AbortController;try{await Promise.race([...$?[X.exitPromise]:[],WU1(Z,{cleanup:!0,signal:K.signal})])}catch(W){if(!Q.stdinCleanedUp)zU1(W,J,X,Y)}finally{K.abort()}},GU1=(Z,{originalStreams:[J],subprocess:X})=>{let Y={stdinCleanedUp:!1};if(Z===J)VU1(Z,X,Y);return Y},VU1=(Z,J,X)=>{let{_destroy:Y}=Z;Z._destroy=(...$)=>{HU1(J,X),Y.call(Z,...$)}},HU1=({exitCode:Z,signalCode:J},X)=>{if(Z!==null||J!==null)X.stdinCleanedUp=!0},zU1=(Z,J,X,Y)=>{if(!FU1(Z,J,X,Y))throw Z},FU1=(Z,J,X,Y=!0)=>{if(X.propagating)return Tc(Z)||DL(Z);return X.propagating=!0,mP(X,J)===Y?Tc(Z):DL(Z)},mP=({fileDescriptors:Z},J)=>J!=="all"&&Z[J].direction==="input",DL=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",Tc=(Z)=>Z?.code==="EPIPE";var Ec=({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>Z.stdio.map((G,V)=>uP({stream:G,fdNumber:V,encoding:J,buffer:X[V],maxBuffer:Y[V],lines:$[V],allMixed:!1,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})),uP=async({stream:Z,fdNumber:J,encoding:X,buffer:Y,maxBuffer:$,lines:Q,allMixed:K,stripFinalNewline:W,verboseInfo:G,streamInfo:V})=>{if(!Z)return;let H=h3(Z,J,V);if(mP(V,J)){await H;return}let[F]=await Promise.all([Dc({stream:Z,onStreamEnd:H,fdNumber:J,encoding:X,buffer:Y,maxBuffer:$,lines:Q,allMixed:K,stripFinalNewline:W,verboseInfo:G,streamInfo:V}),H]);return F};var kc=({stdout:Z,stderr:J},{all:X})=>X&&(Z||J)?qY([Z,J].filter(Boolean)):void 0,Ic=({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>uP({...qU1(Z,X),fdNumber:"all",encoding:J,maxBuffer:Y[1]+Y[2],lines:$[1]||$[2],allMixed:UU1(Z),stripFinalNewline:Q,verboseInfo:K,streamInfo:W}),qU1=({stdout:Z,stderr:J,all:X},[,Y,$])=>{let Q=Y||$;if(!Q)return{stream:X,buffer:Q};if(!Y)return{stream:J,buffer:Q};if(!$)return{stream:Z,buffer:Q};return{stream:X,buffer:Q}},UU1=({all:Z,stdout:J,stderr:X})=>Z&&J&&X&&J.readableObjectMode!==X.readableObjectMode;import{once as LU1}from"node:events";var _c=(Z)=>dQ(Z,"ipc"),vc=(Z,J)=>{let X=kU(Z);Z7({type:"ipc",verboseMessage:X,fdNumber:"ipc",verboseInfo:J})};var Sc=async({subprocess:Z,buffer:J,maxBuffer:X,ipc:Y,ipcOutput:$,verboseInfo:Q})=>{if(!Y)return $;let K=_c(Q),W=GZ(J,"ipc"),G=GZ(X,"ipc");for await(let V of EP({anyProcess:Z,channel:Z.channel,isSubprocess:!1,ipc:Y,shouldAwait:!1,reference:!0})){if(W)Su(Z,$,G),$.push(V);if(K)vc(V,Q)}return $},Ac=async(Z,J)=>{return await Promise.allSettled([Z]),J};var xc=async({subprocess:Z,options:{encoding:J,buffer:X,maxBuffer:Y,lines:$,timeoutDuration:Q,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,stripFinalNewline:V,ipc:H,ipcInput:F},context:z,verboseInfo:q,fileDescriptors:U,originalStreams:L,onInternalError:B,controller:w})=>{let O=fd(Z,z),N={originalStreams:L,fileDescriptors:U,subprocess:Z,exitPromise:O,propagating:!1},R=Ec({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:V,verboseInfo:q,streamInfo:N}),D=Ic({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:V,verboseInfo:q,streamInfo:N}),M=[],C=Sc({subprocess:Z,buffer:X,maxBuffer:Y,ipc:H,ipcOutput:M,verboseInfo:q}),T=BU1(L,Z,N),E=wU1(U,N);try{return await Promise.race([Promise.all([{},bd(O),Promise.all(R),D,C,Vu(Z,F),...T,...E]),B,jU1(Z,w),...$u(Z,Q,z,w),...Cm({subprocess:Z,cancelSignal:K,gracefulCancel:W,context:z,controller:w}),...Xu({subprocess:Z,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,context:z,controller:w})])}catch(x){return z.terminationReason??="other",Promise.all([{error:x},O,Promise.all(R.map((v)=>gP(v))),gP(D),Ac(C,M),Promise.allSettled(T),Promise.allSettled(E)])}},BU1=(Z,J,X)=>Z.map((Y,$)=>Y===J.stdio[$]?void 0:h3(Y,$,X)),wU1=(Z,J)=>Z.flatMap(({stdioItems:X},Y)=>X.filter(({value:$,stream:Q=$})=>U4(Q,{checkOpen:!1})&&!F4(Q)).map(({type:$,value:Q,stream:K=Q})=>h3(K,Y,J,{isSameDirection:M9.has($),stopOnExit:$==="native"}))),jU1=async(Z,{signal:J})=>{let[X]=await LU1(Z,"error",{signal:J});throw X};var hc=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),f3=(Z,J,X)=>{let Y=Z[X];if(!Y.has(J))Y.set(J,[]);let $=Y.get(J),Q=X7();return $.push(Q),{resolve:Q.resolve.bind(Q),promises:$}},ZK=async({resolve:Z,promises:J},X)=>{Z();let[Y]=await Promise.race([Promise.allSettled([!0,X]),Promise.all([!1,...J])]);return!Y};import{Readable as OU1}from"node:stream";import{callbackify as NU1}from"node:util";import{finished as fc}from"node:stream/promises";var dP=async(Z)=>{if(Z===void 0)return;try{await cP(Z)}catch{}},yc=async(Z)=>{if(Z===void 0)return;try{await lP(Z)}catch{}},cP=async(Z)=>{await fc(Z,{cleanup:!0,readable:!1,writable:!0})},lP=async(Z)=>{await fc(Z,{cleanup:!0,readable:!0,writable:!1})},CL=async(Z,J)=>{if(await Z,J)throw J},TL=(Z,J,X)=>{if(X&&!DL(X))Z.destroy(X);else if(J)Z.destroy()};var bc=({subprocess:Z,concurrentStreams:J,encoding:X},{from:Y,binary:$=!0,preserveNewlines:Q=!0}={})=>{let K=$||p5.has(X),{subprocessStdout:W,waitReadableDestroy:G}=pP(Z,Y,J),{readableEncoding:V,readableObjectMode:H,readableHighWaterMark:F}=iP(W,K),{read:z,onStdoutDataDone:q}=nP({subprocessStdout:W,subprocess:Z,binary:K,encoding:X,preserveNewlines:Q}),U=new OU1({read:z,destroy:NU1(sP.bind(void 0,{subprocessStdout:W,subprocess:Z,waitReadableDestroy:G})),highWaterMark:F,objectMode:H,encoding:V});return aP({subprocessStdout:W,onStdoutDataDone:q,readable:U,subprocess:Z}),U},pP=(Z,J,X)=>{let Y=nQ(Z,J),$=f3(X,Y,"readableDestroy");return{subprocessStdout:Y,waitReadableDestroy:$}},iP=({readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X},Y)=>Y?{readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X}:{readableEncoding:Z,readableObjectMode:!0,readableHighWaterMark:bP},nP=({subprocessStdout:Z,subprocess:J,binary:X,encoding:Y,preserveNewlines:$})=>{let Q=X7(),K=PL({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:!X,encoding:Y,preserveNewlines:$});return{read(){RU1(this,K,Q)},onStdoutDataDone:Q}},RU1=async(Z,J,X)=>{try{let{value:Y,done:$}=await J.next();if($)X.resolve();else Z.push(Y)}catch{}},aP=async({subprocessStdout:Z,onStdoutDataDone:J,readable:X,subprocess:Y,subprocessStdin:$})=>{try{if(await lP(Z),await Y,await dP($),await J,X.readable)X.push(null)}catch(Q){await dP($),gc(X,Q)}},sP=async({subprocessStdout:Z,subprocess:J,waitReadableDestroy:X},Y)=>{if(await ZK(X,J))gc(Z,Y),await CL(J,Y)},gc=(Z,J)=>{TL(Z,Z.readable,J)};import{Writable as MU1}from"node:stream";import{callbackify as mc}from"node:util";var uc=({subprocess:Z,concurrentStreams:J},{to:X}={})=>{let{subprocessStdin:Y,waitWritableFinal:$,waitWritableDestroy:Q}=oP(Z,X,J),K=new MU1({...rP(Y,Z,$),destroy:mc(eP.bind(void 0,{subprocessStdin:Y,subprocess:Z,waitWritableFinal:$,waitWritableDestroy:Q})),highWaterMark:Y.writableHighWaterMark,objectMode:Y.writableObjectMode});return tP(Y,K),K},oP=(Z,J,X)=>{let Y=dU(Z,J),$=f3(X,Y,"writableFinal"),Q=f3(X,Y,"writableDestroy");return{subprocessStdin:Y,waitWritableFinal:$,waitWritableDestroy:Q}},rP=(Z,J,X)=>({write:PU1.bind(void 0,Z),final:mc(DU1.bind(void 0,Z,J,X))}),PU1=(Z,J,X,Y)=>{if(Z.write(J,X))Y();else Z.once("drain",Y)},DU1=async(Z,J,X)=>{if(await ZK(X,J)){if(Z.writable)Z.end();await J}},tP=async(Z,J,X)=>{try{if(await cP(Z),J.writable)J.end()}catch(Y){await yc(X),dc(J,Y)}},eP=async({subprocessStdin:Z,subprocess:J,waitWritableFinal:X,waitWritableDestroy:Y},$)=>{if(await ZK(X,J),await ZK(Y,J))dc(Z,$),await CL(J,$)},dc=(Z,J)=>{TL(Z,Z.writable,J)};import{Duplex as CU1}from"node:stream";import{callbackify as TU1}from"node:util";var cc=({subprocess:Z,concurrentStreams:J,encoding:X},{from:Y,to:$,binary:Q=!0,preserveNewlines:K=!0}={})=>{let W=Q||p5.has(X),{subprocessStdout:G,waitReadableDestroy:V}=pP(Z,Y,J),{subprocessStdin:H,waitWritableFinal:F,waitWritableDestroy:z}=oP(Z,$,J),{readableEncoding:q,readableObjectMode:U,readableHighWaterMark:L}=iP(G,W),{read:B,onStdoutDataDone:w}=nP({subprocessStdout:G,subprocess:Z,binary:W,encoding:X,preserveNewlines:K}),O=new CU1({read:B,...rP(H,Z,F),destroy:TU1(EU1.bind(void 0,{subprocessStdout:G,subprocessStdin:H,subprocess:Z,waitReadableDestroy:V,waitWritableFinal:F,waitWritableDestroy:z})),readableHighWaterMark:L,writableHighWaterMark:H.writableHighWaterMark,readableObjectMode:U,writableObjectMode:H.writableObjectMode,encoding:q});return aP({subprocessStdout:G,onStdoutDataDone:w,readable:O,subprocess:Z,subprocessStdin:H}),tP(H,O,G),O},EU1=async({subprocessStdout:Z,subprocessStdin:J,subprocess:X,waitReadableDestroy:Y,waitWritableFinal:$,waitWritableDestroy:Q},K)=>{await Promise.all([sP({subprocessStdout:Z,subprocess:X,waitReadableDestroy:Y},K),eP({subprocessStdin:J,subprocess:X,waitWritableFinal:$,waitWritableDestroy:Q},K)])};var ZD=(Z,J,{from:X,binary:Y=!1,preserveNewlines:$=!1}={})=>{let Q=Y||p5.has(J),K=nQ(Z,X),W=PL({subprocessStdout:K,subprocess:Z,binary:Q,shouldEncode:!0,encoding:J,preserveNewlines:$});return kU1(W,K,Z)},kU1=async function*(Z,J,X){try{yield*Z}finally{if(J.readable)J.destroy();await X}};var lc=(Z,{encoding:J})=>{let X=hc();Z.readable=bc.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.writable=uc.bind(void 0,{subprocess:Z,concurrentStreams:X}),Z.duplex=cc.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.iterable=ZD.bind(void 0,Z,J),Z[Symbol.asyncIterator]=ZD.bind(void 0,Z,J,{})};var pc=(Z,J)=>{for(let[X,Y]of _U1){let $=Y.value.bind(J);Reflect.defineProperty(Z,X,{...Y,value:$})}},IU1=(async()=>{})().constructor.prototype,_U1=["then","catch","finally"].map((Z)=>[Z,Reflect.getOwnPropertyDescriptor(IU1,Z)]);var ic=(Z,J,X,Y)=>{let{file:$,commandArguments:Q,command:K,escapedCommand:W,startTime:G,verboseInfo:V,options:H,fileDescriptors:F}=AU1(Z,J,X),{subprocess:z,promise:q}=hU1({file:$,commandArguments:Q,options:H,startTime:G,verboseInfo:V,command:K,escapedCommand:W,fileDescriptors:F});return z.pipe=ML.bind(void 0,{source:z,sourcePromise:q,boundOptions:{},createNested:Y}),pc(z,q),Y7.set(z,{options:H,fileDescriptors:F}),z},AU1=(Z,J,X)=>{let{command:Y,escapedCommand:$,startTime:Q,verboseInfo:K}=_U(Z,J,X),{file:W,commandArguments:G,options:V}=eU(Z,J,X),H=xU1(V),F=ed(H,K);return{file:W,commandArguments:G,command:Y,escapedCommand:$,startTime:Q,verboseInfo:K,options:H,fileDescriptors:F}},xU1=({timeout:Z,signal:J,...X})=>{if(J!==void 0)throw new TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...X,timeoutDuration:Z}},hU1=({file:Z,commandArguments:J,options:X,startTime:Y,verboseInfo:$,command:Q,escapedCommand:K,fileDescriptors:W})=>{let G;try{G=SU1(Z,J,X)}catch(U){return sd({error:U,command:Q,escapedCommand:K,fileDescriptors:W,options:X,startTime:Y,verboseInfo:$})}let V=new AbortController;vU1(Number.POSITIVE_INFINITY,V.signal);let H=[...G.stdio];Vc(G,W,V),Uc(G,X,V);let F={},z=X7();G.kill=Pm.bind(void 0,{kill:G.kill.bind(G),options:X,onInternalError:z,context:F,controller:V}),G.all=kc(G,X),lc(G,X),id(G,X);let q=fU1({subprocess:G,options:X,startTime:Y,verboseInfo:$,fileDescriptors:W,originalStreams:H,command:Q,escapedCommand:K,context:F,onInternalError:z,controller:V});return{subprocess:G,promise:q}},fU1=async({subprocess:Z,options:J,startTime:X,verboseInfo:Y,fileDescriptors:$,originalStreams:Q,command:K,escapedCommand:W,context:G,onInternalError:V,controller:H})=>{let[F,[z,q],U,L,B]=await xc({subprocess:Z,options:J,context:G,verboseInfo:Y,fileDescriptors:$,originalStreams:Q,onInternalError:V,controller:H});H.abort(),V.resolve();let w=U.map((R,D)=>zZ(R,J,D)),O=zZ(L,J,"all"),N=yU1({errorInfo:F,exitCode:z,signal:q,stdio:w,all:O,ipcOutput:B,context:G,options:J,command:K,escapedCommand:W,startTime:X});return rQ(N,Y,J)},yU1=({errorInfo:Z,exitCode:J,signal:X,stdio:Y,all:$,ipcOutput:Q,context:K,options:W,command:G,escapedCommand:V,startTime:H})=>("error"in Z)?_3({error:Z.error,command:G,escapedCommand:V,timedOut:K.terminationReason==="timeout",isCanceled:K.terminationReason==="cancel"||K.terminationReason==="gracefulCancel",isGracefullyCanceled:K.terminationReason==="gracefulCancel",isMaxBuffer:Z.error instanceof VZ,isForcefullyTerminated:K.isForcefullyTerminated,exitCode:J,signal:X,stdio:Y,all:$,ipcOutput:Q,options:W,startTime:H,isSync:!1}):GL({command:G,escapedCommand:V,stdio:Y,all:$,ipcOutput:Q,options:W,startTime:H});var EL=(Z,J)=>{let X=Object.fromEntries(Object.entries(J).map(([Y,$])=>[Y,bU1(Y,Z[Y],$)]));return{...Z,...X}},bU1=(Z,J,X)=>{if(gU1.has(Z)&&B8(J)&&B8(X))return{...J,...X};return X},gU1=new Set(["env",...AM]);var PJ=(Z,J,X,Y)=>{let $=(K,W,G)=>PJ(K,W,X,G),Q=(...K)=>mU1({mapArguments:Z,deepOptions:X,boundOptions:J,setBoundExeca:Y,createNested:$},...K);if(Y!==void 0)Y(Q,$,J);return Q},mU1=({mapArguments:Z,deepOptions:J={},boundOptions:X={},setBoundExeca:Y,createNested:$},Q,...K)=>{if(B8(Q))return $(Z,EL(X,Q),Y);let{file:W,commandArguments:G,options:V,isSync:H}=uU1({mapArguments:Z,firstArgument:Q,nextArguments:K,deepOptions:J,boundOptions:X});return H?md(W,G,V):ic(W,G,V,$)},uU1=({mapArguments:Z,firstArgument:J,nextArguments:X,deepOptions:Y,boundOptions:$})=>{let Q=eb(J)?Zg(J,X):[J,...X],[K,W,G]=OU(...Q),V=EL(EL(Y,$),G),{file:H=K,commandArguments:F=W,options:z=V,isSync:q=!1}=Z({file:K,commandArguments:W,options:V});return{file:H,commandArguments:F,options:z,isSync:q}};var nc=({file:Z,commandArguments:J})=>sc(Z,J),ac=({file:Z,commandArguments:J})=>({...sc(Z,J),isSync:!0}),sc=(Z,J)=>{if(J.length>0)throw new TypeError(`The command and its arguments must be passed as a single string: ${Z} ${J}.`);let[X,...Y]=dU1(Z);return{file:X,commandArguments:Y}},dU1=(Z)=>{if(typeof Z!=="string")throw new TypeError(`The command must be a string: ${String(Z)}.`);let J=Z.trim();if(J==="")return[];let X=[];for(let Y of J.split(cU1)){let $=X.at(-1);if($&&$.endsWith("\\"))X[X.length-1]=`${$.slice(0,-1)} ${Y}`;else X.push(Y)}return X},cU1=/ +/g;var oc=(Z,J,X)=>{Z.sync=J(lU1,X),Z.s=Z.sync},rc=({options:Z})=>tc(Z),lU1=({options:Z})=>({...tc(Z),isSync:!0}),tc=(Z)=>({options:{...pU1(Z),...Z}}),pU1=({input:Z,inputFile:J,stdio:X})=>Z===void 0&&J===void 0&&X===void 0?{stdin:"inherit"}:{},ec={preferLocal:!0};var Zl=PJ(()=>({})),UD6=PJ(()=>({isSync:!0})),LD6=PJ(nc),BD6=PJ(ac),wD6=PJ(Ku),jD6=PJ(rc,{},ec,oc),{sendMessage:OD6,getOneMessage:ND6,getEachMessage:RD6,getCancelSignal:MD6}=nd();var Nl=r(Fl(),1);var b3=(Z)=>{if(typeof Z!=="string")throw new TypeError("invalid pattern");if(Z.length>65536)throw new TypeError("pattern is too long")};var eU1={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},g3=(Z)=>Z.replace(/[[\]\\-]/g,"\\$&"),ZL1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ql=(Z)=>Z.join(""),Ul=(Z,J)=>{let X=J;if(Z.charAt(X)!=="[")throw new Error("not in a brace expression");let Y=[],$=[],Q=X+1,K=!1,W=!1,G=!1,V=!1,H=X,F="";Z:while(Q<Z.length){let L=Z.charAt(Q);if((L==="!"||L==="^")&&Q===X+1){V=!0,Q++;continue}if(L==="]"&&K&&!G){H=Q+1;break}if(K=!0,L==="\\"){if(!G){G=!0,Q++;continue}}if(L==="["&&!G){for(let[B,[w,O,N]]of Object.entries(eU1))if(Z.startsWith(B,Q)){if(F)return["$.",!1,Z.length-X,!0];if(Q+=B.length,N)$.push(w);else Y.push(w);W=W||O;continue Z}}if(G=!1,F){if(L>F)Y.push(g3(F)+"-"+g3(L));else if(L===F)Y.push(g3(L));F="",Q++;continue}if(Z.startsWith("-]",Q+1)){Y.push(g3(L+"-")),Q+=2;continue}if(Z.startsWith("-",Q+1)){F=L,Q+=2;continue}Y.push(g3(L)),Q++}if(H<Q)return["",!1,0,!1];if(!Y.length&&!$.length)return["$.",!1,Z.length-X,!0];if($.length===0&&Y.length===1&&/^\\?.$/.test(Y[0])&&!V){let L=Y[0].length===2?Y[0].slice(-1):Y[0];return[ZL1(L),!1,H-X,!1]}let z="["+(V?"^":"")+ql(Y)+"]",q="["+(V?"":"^")+ql($)+"]";return[Y.length&&$.length?"("+z+"|"+q+")":Y.length?z:q,W,H-X,!0]};var L4=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/\[([^\/\\])\]/g,"$1"):Z.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var JL1=new Set(["!","?","+","*","@"]),Ll=(Z)=>JL1.has(Z),XL1="(?!(?:^|/)\\.\\.?(?:$|/))",kL="(?!\\.)",YL1=new Set(["[","."]),$L1=new Set(["..","."]),QL1=new Set("().*{}+?[]^$\\!"),KL1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),$D="[^/]",Bl=$D+"*?",wl=$D+"+?";class U6{type;#Z;#J;#Y=!1;#X=[];#$;#H;#F;#W=!1;#G;#V;#z=!1;constructor(Z,J,X={}){if(this.type=Z,Z)this.#J=!0;if(this.#$=J,this.#Z=this.#$?this.#$.#Z:this,this.#G=this.#Z===this?X:this.#Z.#G,this.#F=this.#Z===this?[]:this.#Z.#F,Z==="!"&&!this.#Z.#W)this.#F.push(this);this.#H=this.#$?this.#$.#X.length:0}get hasMagic(){if(this.#J!==void 0)return this.#J;for(let Z of this.#X){if(typeof Z==="string")continue;if(Z.type||Z.hasMagic)return this.#J=!0}return this.#J}toString(){if(this.#V!==void 0)return this.#V;if(!this.type)return this.#V=this.#X.map((Z)=>String(Z)).join("");else return this.#V=this.type+"("+this.#X.map((Z)=>String(Z)).join("|")+")"}#Q(){if(this!==this.#Z)throw new Error("should only call on root");if(this.#W)return this;this.toString(),this.#W=!0;let Z;while(Z=this.#F.pop()){if(Z.type!=="!")continue;let J=Z,X=J.#$;while(X){for(let Y=J.#H+1;!X.type&&Y<X.#X.length;Y++)for(let $ of Z.#X){if(typeof $==="string")throw new Error("string part in extglob AST??");$.copyIn(X.#X[Y])}J=X,X=J.#$}}return this}push(...Z){for(let J of Z){if(J==="")continue;if(typeof J!=="string"&&!(J instanceof U6&&J.#$===this))throw new Error("invalid part: "+J);this.#X.push(J)}}toJSON(){let Z=this.type===null?this.#X.slice().map((J)=>typeof J==="string"?J:J.toJSON()):[this.type,...this.#X.map((J)=>J.toJSON())];if(this.isStart()&&!this.type)Z.unshift([]);if(this.isEnd()&&(this===this.#Z||this.#Z.#W&&this.#$?.type==="!"))Z.push({});return Z}isStart(){if(this.#Z===this)return!0;if(!this.#$?.isStart())return!1;if(this.#H===0)return!0;let Z=this.#$;for(let J=0;J<this.#H;J++){let X=Z.#X[J];if(!(X instanceof U6&&X.type==="!"))return!1}return!0}isEnd(){if(this.#Z===this)return!0;if(this.#$?.type==="!")return!0;if(!this.#$?.isEnd())return!1;if(!this.type)return this.#$?.isEnd();let Z=this.#$?this.#$.#X.length:0;return this.#H===Z-1}copyIn(Z){if(typeof Z==="string")this.push(Z);else this.push(Z.clone(this))}clone(Z){let J=new U6(this.type,Z);for(let X of this.#X)J.copyIn(X);return J}static#U(Z,J,X,Y){let $=!1,Q=!1,K=-1,W=!1;if(J.type===null){let z=X,q="";while(z<Z.length){let U=Z.charAt(z++);if($||U==="\\"){$=!$,q+=U;continue}if(Q){if(z===K+1){if(U==="^"||U==="!")W=!0}else if(U==="]"&&!(z===K+2&&W))Q=!1;q+=U;continue}else if(U==="["){Q=!0,K=z,W=!1,q+=U;continue}if(!Y.noext&&Ll(U)&&Z.charAt(z)==="("){J.push(q),q="";let L=new U6(U,J);z=U6.#U(Z,L,z,Y),J.push(L);continue}q+=U}return J.push(q),z}let G=X+1,V=new U6(null,J),H=[],F="";while(G<Z.length){let z=Z.charAt(G++);if($||z==="\\"){$=!$,F+=z;continue}if(Q){if(G===K+1){if(z==="^"||z==="!")W=!0}else if(z==="]"&&!(G===K+2&&W))Q=!1;F+=z;continue}else if(z==="["){Q=!0,K=G,W=!1,F+=z;continue}if(Ll(z)&&Z.charAt(G)==="("){V.push(F),F="";let q=new U6(z,V);V.push(q),G=U6.#U(Z,q,G,Y);continue}if(z==="|"){V.push(F),F="",H.push(V),V=new U6(null,J);continue}if(z===")"){if(F===""&&J.#X.length===0)J.#z=!0;return V.push(F),F="",J.push(...H,V),G}F+=z}return J.type=null,J.#J=void 0,J.#X=[Z.substring(X-1)],G}static fromGlob(Z,J={}){let X=new U6(null,void 0,J);return U6.#U(Z,X,0,J),X}toMMPattern(){if(this!==this.#Z)return this.#Z.toMMPattern();let Z=this.toString(),[J,X,Y,$]=this.toRegExpSource();if(!(Y||this.#J||this.#G.nocase&&!this.#G.nocaseMagicOnly&&Z.toUpperCase()!==Z.toLowerCase()))return X;let K=(this.#G.nocase?"i":"")+($?"u":"");return Object.assign(new RegExp(`^${J}$`,K),{_src:J,_glob:Z})}get options(){return this.#G}toRegExpSource(Z){let J=Z??!!this.#G.dot;if(this.#Z===this)this.#Q();if(!this.type){let W=this.isStart()&&this.isEnd(),G=this.#X.map((z)=>{let[q,U,L,B]=typeof z==="string"?U6.#L(z,this.#J,W):z.toRegExpSource(Z);return this.#J=this.#J||L,this.#Y=this.#Y||B,q}).join(""),V="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&$L1.has(this.#X[0]))){let q=YL1,U=J&&q.has(G.charAt(0))||G.startsWith("\\.")&&q.has(G.charAt(2))||G.startsWith("\\.\\.")&&q.has(G.charAt(4)),L=!J&&!Z&&q.has(G.charAt(0));V=U?XL1:L?kL:""}}}let H="";if(this.isEnd()&&this.#Z.#W&&this.#$?.type==="!")H="(?:$|\\/)";return[V+G+H,L4(G),this.#J=!!this.#J,this.#Y]}let X=this.type==="*"||this.type==="+",Y=this.type==="!"?"(?:(?!(?:":"(?:",$=this.#B(J);if(this.isStart()&&this.isEnd()&&!$&&this.type!=="!"){let W=this.toString();return this.#X=[W],this.type=null,this.#J=void 0,[W,L4(this.toString()),!1,!1]}let Q=!X||Z||J||!kL?"":this.#B(!0);if(Q===$)Q="";if(Q)$=`(?:${$})(?:${Q})*?`;let K="";if(this.type==="!"&&this.#z)K=(this.isStart()&&!J?kL:"")+wl;else{let W=this.type==="!"?"))"+(this.isStart()&&!J&&!Z?kL:"")+Bl+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&Q?")":this.type==="*"&&Q?")?":`)${this.type}`;K=Y+$+W}return[K,L4($),this.#J=!!this.#J,this.#Y]}#B(Z){return this.#X.map((J)=>{if(typeof J==="string")throw new Error("string type in extglob ast??");let[X,Y,$,Q]=J.toRegExpSource(Z);return this.#Y=this.#Y||Q,X}).filter((J)=>!(this.isStart()&&this.isEnd())||!!J).join("|")}static#L(Z,J,X=!1){let Y=!1,$="",Q=!1;for(let K=0;K<Z.length;K++){let W=Z.charAt(K);if(Y){Y=!1,$+=(QL1.has(W)?"\\":"")+W;continue}if(W==="\\"){if(K===Z.length-1)$+="\\\\";else Y=!0;continue}if(W==="["){let[G,V,H,F]=Ul(Z,K);if(H){$+=G,Q=Q||V,K+=H-1,J=J||F;continue}}if(W==="*"){if(X&&Z==="*")$+=wl;else $+=Bl;J=!0;continue}if(W==="?"){$+=$D,J=!0;continue}$+=KL1(W)}return[$,L4(Z),!!J,Q]}}var JK=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/[?*()[\]]/g,"[$&]"):Z.replace(/[?*()[\]\\]/g,"\\$&")};var p6=(Z,J,X={})=>{if(b3(J),!X.nocomment&&J.charAt(0)==="#")return!1;return new D9(J,X).match(Z)},WL1=/^\*+([^+@!?\*\[\(]*)$/,GL1=(Z)=>(J)=>!J.startsWith(".")&&J.endsWith(Z),VL1=(Z)=>(J)=>J.endsWith(Z),HL1=(Z)=>{return Z=Z.toLowerCase(),(J)=>!J.startsWith(".")&&J.toLowerCase().endsWith(Z)},zL1=(Z)=>{return Z=Z.toLowerCase(),(J)=>J.toLowerCase().endsWith(Z)},FL1=/^\*+\.\*+$/,qL1=(Z)=>!Z.startsWith(".")&&Z.includes("."),UL1=(Z)=>Z!=="."&&Z!==".."&&Z.includes("."),LL1=/^\.\*+$/,BL1=(Z)=>Z!=="."&&Z!==".."&&Z.startsWith("."),wL1=/^\*+$/,jL1=(Z)=>Z.length!==0&&!Z.startsWith("."),OL1=(Z)=>Z.length!==0&&Z!=="."&&Z!=="..",NL1=/^\?+([^+@!?\*\[\(]*)?$/,RL1=([Z,J=""])=>{let X=Rl([Z]);if(!J)return X;return J=J.toLowerCase(),(Y)=>X(Y)&&Y.toLowerCase().endsWith(J)},ML1=([Z,J=""])=>{let X=Ml([Z]);if(!J)return X;return J=J.toLowerCase(),(Y)=>X(Y)&&Y.toLowerCase().endsWith(J)},PL1=([Z,J=""])=>{let X=Ml([Z]);return!J?X:(Y)=>X(Y)&&Y.endsWith(J)},DL1=([Z,J=""])=>{let X=Rl([Z]);return!J?X:(Y)=>X(Y)&&Y.endsWith(J)},Rl=([Z])=>{let J=Z.length;return(X)=>X.length===J&&!X.startsWith(".")},Ml=([Z])=>{let J=Z.length;return(X)=>X.length===J&&X!=="."&&X!==".."},Pl=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",jl={win32:{sep:"\\"},posix:{sep:"/"}},CL1=Pl==="win32"?jl.win32.sep:jl.posix.sep;p6.sep=CL1;var L6=Symbol("globstar **");p6.GLOBSTAR=L6;var TL1="[^/]",EL1=TL1+"*?",kL1="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",IL1="(?:(?!(?:\\/|^)\\.).)*?",_L1=(Z,J={})=>(X)=>p6(X,Z,J);p6.filter=_L1;var P9=(Z,J={})=>Object.assign({},Z,J),vL1=(Z)=>{if(!Z||typeof Z!=="object"||!Object.keys(Z).length)return p6;let J=p6;return Object.assign((Y,$,Q={})=>J(Y,$,P9(Z,Q)),{Minimatch:class Y extends J.Minimatch{constructor($,Q={}){super($,P9(Z,Q))}static defaults($){return J.defaults(P9(Z,$)).Minimatch}},AST:class Y extends J.AST{constructor($,Q,K={}){super($,Q,P9(Z,K))}static fromGlob($,Q={}){return J.AST.fromGlob($,P9(Z,Q))}},unescape:(Y,$={})=>J.unescape(Y,P9(Z,$)),escape:(Y,$={})=>J.escape(Y,P9(Z,$)),filter:(Y,$={})=>J.filter(Y,P9(Z,$)),defaults:(Y)=>J.defaults(P9(Z,Y)),makeRe:(Y,$={})=>J.makeRe(Y,P9(Z,$)),braceExpand:(Y,$={})=>J.braceExpand(Y,P9(Z,$)),match:(Y,$,Q={})=>J.match(Y,$,P9(Z,Q)),sep:J.sep,GLOBSTAR:L6})};p6.defaults=vL1;var Dl=(Z,J={})=>{if(b3(Z),J.nobrace||!/\{(?:(?!\{).)*\}/.test(Z))return[Z];return Nl.default(Z)};p6.braceExpand=Dl;var SL1=(Z,J={})=>new D9(Z,J).makeRe();p6.makeRe=SL1;var AL1=(Z,J,X={})=>{let Y=new D9(J,X);if(Z=Z.filter(($)=>Y.match($)),Y.options.nonull&&!Z.length)Z.push(J);return Z};p6.match=AL1;var Ol=/[?*]|[+@!]\(.*?\)|\[|\]/,xL1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class D9{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Z,J={}){if(b3(Z),J=J||{},this.options=J,this.pattern=Z,this.platform=J.platform||Pl,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!J.windowsPathsNoEscape||J.allowWindowsEscape===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!J.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!J.nonegate,this.comment=!1,this.empty=!1,this.partial=!!J.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=J.windowsNoMagicRoot!==void 0?J.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let Z of this.set)for(let J of Z)if(typeof J!=="string")return!0;return!1}debug(...Z){}make(){let Z=this.pattern,J=this.options;if(!J.nocomment&&Z.charAt(0)==="#"){this.comment=!0;return}if(!Z){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],J.debug)this.debug=(...$)=>console.error(...$);this.debug(this.pattern,this.globSet);let X=this.globSet.map(($)=>this.slashSplit($));this.globParts=this.preprocess(X),this.debug(this.pattern,this.globParts);let Y=this.globParts.map(($,Q,K)=>{if(this.isWindows&&this.windowsNoMagicRoot){let W=$[0]===""&&$[1]===""&&($[2]==="?"||!Ol.test($[2]))&&!Ol.test($[3]),G=/^[a-z]:/i.test($[0]);if(W)return[...$.slice(0,4),...$.slice(4).map((V)=>this.parse(V))];else if(G)return[$[0],...$.slice(1).map((V)=>this.parse(V))]}return $.map((W)=>this.parse(W))});if(this.debug(this.pattern,Y),this.set=Y.filter(($)=>$.indexOf(!1)===-1),this.isWindows)for(let $=0;$<this.set.length;$++){let Q=this.set[$];if(Q[0]===""&&Q[1]===""&&this.globParts[$][2]==="?"&&typeof Q[3]==="string"&&/^[a-z]:$/i.test(Q[3]))Q[2]="?"}this.debug(this.pattern,this.set)}preprocess(Z){if(this.options.noglobstar){for(let X=0;X<Z.length;X++)for(let Y=0;Y<Z[X].length;Y++)if(Z[X][Y]==="**")Z[X][Y]="*"}let{optimizationLevel:J=1}=this.options;if(J>=2)Z=this.firstPhasePreProcess(Z),Z=this.secondPhasePreProcess(Z);else if(J>=1)Z=this.levelOneOptimize(Z);else Z=this.adjascentGlobstarOptimize(Z);return Z}adjascentGlobstarOptimize(Z){return Z.map((J)=>{let X=-1;while((X=J.indexOf("**",X+1))!==-1){let Y=X;while(J[Y+1]==="**")Y++;if(Y!==X)J.splice(X,Y-X)}return J})}levelOneOptimize(Z){return Z.map((J)=>{return J=J.reduce((X,Y)=>{let $=X[X.length-1];if(Y==="**"&&$==="**")return X;if(Y===".."){if($&&$!==".."&&$!=="."&&$!=="**")return X.pop(),X}return X.push(Y),X},[]),J.length===0?[""]:J})}levelTwoFileOptimize(Z){if(!Array.isArray(Z))Z=this.slashSplit(Z);let J=!1;do{if(J=!1,!this.preserveMultipleSlashes){for(let Y=1;Y<Z.length-1;Y++){let $=Z[Y];if(Y===1&&$===""&&Z[0]==="")continue;if($==="."||$==="")J=!0,Z.splice(Y,1),Y--}if(Z[0]==="."&&Z.length===2&&(Z[1]==="."||Z[1]===""))J=!0,Z.pop()}let X=0;while((X=Z.indexOf("..",X+1))!==-1){let Y=Z[X-1];if(Y&&Y!=="."&&Y!==".."&&Y!=="**")J=!0,Z.splice(X-1,2),X-=2}}while(J);return Z.length===0?[""]:Z}firstPhasePreProcess(Z){let J=!1;do{J=!1;for(let X of Z){let Y=-1;while((Y=X.indexOf("**",Y+1))!==-1){let Q=Y;while(X[Q+1]==="**")Q++;if(Q>Y)X.splice(Y+1,Q-Y);let K=X[Y+1],W=X[Y+2],G=X[Y+3];if(K!=="..")continue;if(!W||W==="."||W===".."||!G||G==="."||G==="..")continue;J=!0,X.splice(Y,1);let V=X.slice(0);V[Y]="**",Z.push(V),Y--}if(!this.preserveMultipleSlashes){for(let Q=1;Q<X.length-1;Q++){let K=X[Q];if(Q===1&&K===""&&X[0]==="")continue;if(K==="."||K==="")J=!0,X.splice(Q,1),Q--}if(X[0]==="."&&X.length===2&&(X[1]==="."||X[1]===""))J=!0,X.pop()}let $=0;while(($=X.indexOf("..",$+1))!==-1){let Q=X[$-1];if(Q&&Q!=="."&&Q!==".."&&Q!=="**"){J=!0;let W=$===1&&X[$+1]==="**"?["."]:[];if(X.splice($-1,2,...W),X.length===0)X.push("");$-=2}}}}while(J);return Z}secondPhasePreProcess(Z){for(let J=0;J<Z.length-1;J++)for(let X=J+1;X<Z.length;X++){let Y=this.partsMatch(Z[J],Z[X],!this.preserveMultipleSlashes);if(Y){Z[J]=[],Z[X]=Y;break}}return Z.filter((J)=>J.length)}partsMatch(Z,J,X=!1){let Y=0,$=0,Q=[],K="";while(Y<Z.length&&$<J.length)if(Z[Y]===J[$])Q.push(K==="b"?J[$]:Z[Y]),Y++,$++;else if(X&&Z[Y]==="**"&&J[$]===Z[Y+1])Q.push(Z[Y]),Y++;else if(X&&J[$]==="**"&&Z[Y]===J[$+1])Q.push(J[$]),$++;else if(Z[Y]==="*"&&J[$]&&(this.options.dot||!J[$].startsWith("."))&&J[$]!=="**"){if(K==="b")return!1;K="a",Q.push(Z[Y]),Y++,$++}else if(J[$]==="*"&&Z[Y]&&(this.options.dot||!Z[Y].startsWith("."))&&Z[Y]!=="**"){if(K==="a")return!1;K="b",Q.push(J[$]),Y++,$++}else return!1;return Z.length===J.length&&Q}parseNegate(){if(this.nonegate)return;let Z=this.pattern,J=!1,X=0;for(let Y=0;Y<Z.length&&Z.charAt(Y)==="!";Y++)J=!J,X++;if(X)this.pattern=Z.slice(X);this.negate=J}matchOne(Z,J,X=!1){let Y=this.options;if(this.isWindows){let U=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),L=!U&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&/^[a-z]:$/i.test(Z[3]),B=typeof J[0]==="string"&&/^[a-z]:$/i.test(J[0]),w=!B&&J[0]===""&&J[1]===""&&J[2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]),O=L?3:U?0:void 0,N=w?3:B?0:void 0;if(typeof O==="number"&&typeof N==="number"){let[R,D]=[Z[O],J[N]];if(R.toLowerCase()===D.toLowerCase()){if(J[N]=R,N>O)J=J.slice(N);else if(O>N)Z=Z.slice(O)}}}let{optimizationLevel:$=1}=this.options;if($>=2)Z=this.levelTwoFileOptimize(Z);this.debug("matchOne",this,{file:Z,pattern:J}),this.debug("matchOne",Z.length,J.length);for(var Q=0,K=0,W=Z.length,G=J.length;Q<W&&K<G;Q++,K++){this.debug("matchOne loop");var V=J[K],H=Z[Q];if(this.debug(J,V,H),V===!1)return!1;if(V===L6){this.debug("GLOBSTAR",[J,V,H]);var F=Q,z=K+1;if(z===G){this.debug("** at the end");for(;Q<W;Q++)if(Z[Q]==="."||Z[Q]===".."||!Y.dot&&Z[Q].charAt(0)===".")return!1;return!0}while(F<W){var q=Z[F];if(this.debug(`
413
413
  globstar while`,Z,F,J,z,q),this.matchOne(Z.slice(F),J.slice(z),X))return this.debug("globstar found match!",F,W,q),!0;else{if(q==="."||q===".."||!Y.dot&&q.charAt(0)==="."){this.debug("dot detected!",Z,F,J,z);break}this.debug("globstar swallow a segment, and continue"),F++}}if(X){if(this.debug(`
414
- >>> no match, partial?`,Z,F,J,z),F===W)return!0}return!1}let U;if(typeof V==="string")U=H===V,this.debug("string match",V,H,U);else U=V.test(H),this.debug("pattern match",V,H,U);if(!U)return!1}if(Q===W&&K===G)return!0;else if(Q===W)return X;else if(K===G)return Q===W-1&&Z[Q]==="";else throw new Error("wtf?")}braceExpand(){return Dl(this.pattern,this.options)}parse(Z){b3(Z);let J=this.options;if(Z==="**")return L6;if(Z==="")return"";let X,Y=null;if(X=Z.match(wL1))Y=J.dot?OL1:jL1;else if(X=Z.match(WL1))Y=(J.nocase?J.dot?zL1:HL1:J.dot?VL1:GL1)(X[1]);else if(X=Z.match(NL1))Y=(J.nocase?J.dot?ML1:RL1:J.dot?PL1:DL1)(X);else if(X=Z.match(FL1))Y=J.dot?UL1:qL1;else if(X=Z.match(LL1))Y=BL1;let $=U6.fromGlob(Z,this.options).toMMPattern();if(Y&&typeof $==="object")Reflect.defineProperty($,"test",{value:Y});return $}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Z=this.set;if(!Z.length)return this.regexp=!1,this.regexp;let J=this.options,X=J.noglobstar?EL1:J.dot?kL1:IL1,Y=new Set(J.nocase?["i"]:[]),$=Z.map((W)=>{let G=W.map((V)=>{if(V instanceof RegExp)for(let H of V.flags.split(""))Y.add(H);return typeof V==="string"?xL1(V):V===L6?L6:V._src});return G.forEach((V,H)=>{let F=G[H+1],z=G[H-1];if(V!==L6||z===L6)return;if(z===void 0)if(F!==void 0&&F!==L6)G[H+1]="(?:\\/|"+X+"\\/)?"+F;else G[H]=X;else if(F===void 0)G[H-1]=z+"(?:\\/|"+X+")?";else if(F!==L6)G[H-1]=z+"(?:\\/|\\/"+X+"\\/)"+F,G[H+1]=L6}),G.filter((V)=>V!==L6).join("/")}).join("|"),[Q,K]=Z.length>1?["(?:",")"]:["",""];if($="^"+Q+$+K+"$",this.negate)$="^(?!"+$+").+$";try{this.regexp=new RegExp($,[...Y].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit(Z){if(this.preserveMultipleSlashes)return Z.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Z))return["",...Z.split(/\/+/)];else return Z.split(/\/+/)}match(Z,J=this.partial){if(this.debug("match",Z,this.pattern),this.comment)return!1;if(this.empty)return Z==="";if(Z==="/"&&J)return!0;let X=this.options;if(this.isWindows)Z=Z.split("\\").join("/");let Y=this.slashSplit(Z);this.debug(this.pattern,"split",Y);let $=this.set;this.debug(this.pattern,"set",$);let Q=Y[Y.length-1];if(!Q)for(let K=Y.length-2;!Q&&K>=0;K--)Q=Y[K];for(let K=0;K<$.length;K++){let W=$[K],G=Y;if(X.matchBase&&W.length===1)G=[Q];if(this.matchOne(G,W,J)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Z){return p6.defaults(Z).Minimatch}}p6.AST=U6;p6.Minimatch=D9;p6.escape=JK;p6.unescape=L4;import{fileURLToPath as FB1}from"node:url";var XK=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,Tl=new Set,QD=typeof process==="object"&&!!process?process:{},El=(Z,J,X,Y)=>{typeof QD.emitWarning==="function"?QD.emitWarning(Z,J,X,Y):console.error(`[${X}] ${J}: ${Z}`)},IL=globalThis.AbortController,Cl=globalThis.AbortSignal;if(typeof IL==="undefined"){Cl=class X{onabort;_onabort=[];reason;aborted=!1;addEventListener(Y,$){this._onabort.push($)}},IL=class X{constructor(){J()}signal=new Cl;abort(Y){if(this.signal.aborted)return;this.signal.reason=Y,this.signal.aborted=!0;for(let $ of this.signal._onabort)$(Y);this.signal.onabort?.(Y)}};let Z=QD.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,El("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",J)}}var hL1=(Z)=>!Tl.has(Z),uD6=Symbol("type"),DJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),kl=(Z)=>!DJ(Z)?null:Z<=Math.pow(2,8)?Uint8Array:Z<=Math.pow(2,16)?Uint16Array:Z<=Math.pow(2,32)?Uint32Array:Z<=Number.MAX_SAFE_INTEGER?m3:null;class m3 extends Array{constructor(Z){super(Z);this.fill(0)}}class YK{heap;length;static#Z=!1;static create(Z){let J=kl(Z);if(!J)return[];YK.#Z=!0;let X=new YK(Z,J);return YK.#Z=!1,X}constructor(Z,J){if(!YK.#Z)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new J(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}}class u3{#Z;#J;#Y;#X;#$;#H;#F;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#V;#z;#Q;#U;#B;#L;#j;#E;#O;#k;#M;#R;#N;#C;#w;#_;static unsafeExposeInternals(Z){return{starts:Z.#M,ttls:Z.#R,sizes:Z.#k,keyMap:Z.#V,keyList:Z.#z,valList:Z.#Q,next:Z.#U,prev:Z.#B,get head(){return Z.#L},get tail(){return Z.#j},free:Z.#E,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,Y,$)=>Z.#h(J,X,Y,$),moveToTail:(J)=>Z.#b(J),indexes:(J)=>Z.#T(J),rindexes:(J)=>Z.#I(J),isStale:(J)=>Z.#D(J)}}get max(){return this.#Z}get maxSize(){return this.#J}get calculatedSize(){return this.#G}get size(){return this.#W}get fetchMethod(){return this.#H}get memoMethod(){return this.#F}get dispose(){return this.#Y}get onInsert(){return this.#X}get disposeAfter(){return this.#$}constructor(Z){let{max:J=0,ttl:X,ttlResolution:Y=1,ttlAutopurge:$,updateAgeOnGet:Q,updateAgeOnHas:K,allowStale:W,dispose:G,onInsert:V,disposeAfter:H,noDisposeOnSet:F,noUpdateTTL:z,maxSize:q=0,maxEntrySize:U=0,sizeCalculation:L,fetchMethod:B,memoMethod:w,noDeleteOnFetchRejection:O,noDeleteOnStaleGet:N,allowStaleOnFetchRejection:R,allowStaleOnFetchAbort:D,ignoreFetchAbort:M}=Z;if(J!==0&&!DJ(J))throw new TypeError("max option must be a nonnegative integer");let C=J?kl(J):Array;if(!C)throw new Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=U||this.#J,this.sizeCalculation=L,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw new TypeError("sizeCalculation set to non-function")}if(w!==void 0&&typeof w!=="function")throw new TypeError("memoMethod must be a function if defined");if(this.#F=w,B!==void 0&&typeof B!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#H=B,this.#C=!!B,this.#V=new Map,this.#z=new Array(J).fill(void 0),this.#Q=new Array(J).fill(void 0),this.#U=new C(J),this.#B=new C(J),this.#L=0,this.#j=0,this.#E=YK.create(J),this.#W=0,this.#G=0,typeof G==="function")this.#Y=G;if(typeof V==="function")this.#X=V;if(typeof H==="function")this.#$=H,this.#O=[];else this.#$=void 0,this.#O=void 0;if(this.#N=!!this.#Y,this.#_=!!this.#X,this.#w=!!this.#$,this.noDisposeOnSet=!!F,this.noUpdateTTL=!!z,this.noDeleteOnFetchRejection=!!O,this.allowStaleOnFetchRejection=!!R,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#J!==0){if(!DJ(this.#J))throw new TypeError("maxSize must be a positive integer if specified")}if(!DJ(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#m()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!N,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=DJ(Y)||Y===0?Y:1,this.ttlAutopurge=!!$,this.ttl=X||0,this.ttl){if(!DJ(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#K()}if(this.#Z===0&&this.ttl===0&&this.#J===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#J){if(hL1("LRU_CACHE_UNBOUNDED"))Tl.add("LRU_CACHE_UNBOUNDED"),El("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",u3)}}getRemainingTTL(Z){return this.#V.has(Z)?1/0:0}#K(){let Z=new m3(this.#Z),J=new m3(this.#Z);this.#R=Z,this.#M=J,this.#v=($,Q,K=XK.now())=>{if(J[$]=Q!==0?K:0,Z[$]=Q,Q!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#D($))this.#S(this.#z[$],"expire")},Q+1);if(W.unref)W.unref()}},this.#A=($)=>{J[$]=Z[$]!==0?XK.now():0},this.#P=($,Q)=>{if(Z[Q]){let K=Z[Q],W=J[Q];if(!K||!W)return;$.ttl=K,$.start=W,$.now=X||Y();let G=$.now-W;$.remainingTTL=K-G}};let X=0,Y=()=>{let $=XK.now();if(this.ttlResolution>0){X=$;let Q=setTimeout(()=>X=0,this.ttlResolution);if(Q.unref)Q.unref()}return $};this.getRemainingTTL=($)=>{let Q=this.#V.get($);if(Q===void 0)return 0;let K=Z[Q],W=J[Q];if(!K||!W)return 1/0;let G=(X||Y())-W;return K-G},this.#D=($)=>{let Q=J[$],K=Z[$];return!!K&&!!Q&&(X||Y())-Q>K}}#A=()=>{};#P=()=>{};#v=()=>{};#D=()=>!1;#m(){let Z=new m3(this.#Z);this.#G=0,this.#k=Z,this.#x=(J)=>{this.#G-=Z[J],Z[J]=0},this.#u=(J,X,Y,$)=>{if(this.#q(X))return 0;if(!DJ(Y))if($){if(typeof $!=="function")throw new TypeError("sizeCalculation must be a function");if(Y=$(X,J),!DJ(Y))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return Y},this.#f=(J,X,Y)=>{if(Z[J]=X,this.#J){let $=this.#J-Z[J];while(this.#G>$)this.#y(!0)}if(this.#G+=Z[J],Y)Y.entrySize=X,Y.totalCalculatedSize=this.#G}}#x=(Z)=>{};#f=(Z,J,X)=>{};#u=(Z,J,X,Y)=>{if(X||Y)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#T({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#j;;){if(!this.#d(J))break;if(Z||!this.#D(J))yield J;if(J===this.#L)break;else J=this.#B[J]}}*#I({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#L;;){if(!this.#d(J))break;if(Z||!this.#D(J))yield J;if(J===this.#j)break;else J=this.#U[J]}}#d(Z){return Z!==void 0&&this.#V.get(this.#z[Z])===Z}*entries(){for(let Z of this.#T())if(this.#Q[Z]!==void 0&&this.#z[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#z[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#I())if(this.#Q[Z]!==void 0&&this.#z[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#z[Z],this.#Q[Z]]}*keys(){for(let Z of this.#T()){let J=this.#z[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#I()){let J=this.#z[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*values(){for(let Z of this.#T())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}*rvalues(){for(let Z of this.#I())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Z,J={}){for(let X of this.#T()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;if(Z($,this.#z[X],this))return this.get(this.#z[X],J)}}forEach(Z,J=this){for(let X of this.#T()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;Z.call(J,$,this.#z[X],this)}}rforEach(Z,J=this){for(let X of this.#I()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;Z.call(J,$,this.#z[X],this)}}purgeStale(){let Z=!1;for(let J of this.#I({allowStale:!0}))if(this.#D(J))this.#S(this.#z[J],"expire"),Z=!0;return Z}info(Z){let J=this.#V.get(Z);if(J===void 0)return;let X=this.#Q[J],Y=this.#q(X)?X.__staleWhileFetching:X;if(Y===void 0)return;let $={value:Y};if(this.#R&&this.#M){let Q=this.#R[J],K=this.#M[J];if(Q&&K){let W=Q-(XK.now()-K);$.ttl=W,$.start=Date.now()}}if(this.#k)$.size=this.#k[J];return $}dump(){let Z=[];for(let J of this.#T({allowStale:!0})){let X=this.#z[J],Y=this.#Q[J],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0||X===void 0)continue;let Q={value:$};if(this.#R&&this.#M){Q.ttl=this.#R[J];let K=XK.now()-this.#M[J];Q.start=Math.floor(Date.now()-K)}if(this.#k)Q.size=this.#k[J];Z.unshift([X,Q])}return Z}load(Z){this.clear();for(let[J,X]of Z){if(X.start){let Y=Date.now()-X.start;X.start=XK.now()-Y}this.set(J,X.value,X)}}set(Z,J,X={}){if(J===void 0)return this.delete(Z),this;let{ttl:Y=this.ttl,start:$,noDisposeOnSet:Q=this.noDisposeOnSet,sizeCalculation:K=this.sizeCalculation,status:W}=X,{noUpdateTTL:G=this.noUpdateTTL}=X,V=this.#u(Z,J,X.size||0,K);if(this.maxEntrySize&&V>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#S(Z,"set"),this}let H=this.#W===0?void 0:this.#V.get(Z);if(H===void 0){if(H=this.#W===0?this.#j:this.#E.length!==0?this.#E.pop():this.#W===this.#Z?this.#y(!1):this.#W,this.#z[H]=Z,this.#Q[H]=J,this.#V.set(Z,H),this.#U[this.#j]=H,this.#B[H]=this.#j,this.#j=H,this.#W++,this.#f(H,V,W),W)W.set="add";if(G=!1,this.#_)this.#X?.(J,Z,"add")}else{this.#b(H);let F=this.#Q[H];if(J!==F){if(this.#C&&this.#q(F)){F.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:z}=F;if(z!==void 0&&!Q){if(this.#N)this.#Y?.(z,Z,"set");if(this.#w)this.#O?.push([z,Z,"set"])}}else if(!Q){if(this.#N)this.#Y?.(F,Z,"set");if(this.#w)this.#O?.push([F,Z,"set"])}if(this.#x(H),this.#f(H,V,W),this.#Q[H]=J,W){W.set="replace";let z=F&&this.#q(F)?F.__staleWhileFetching:F;if(z!==void 0)W.oldValue=z}}else if(W)W.set="update";if(this.#_)this.onInsert?.(J,Z,J===F?"update":"replace")}if(Y!==0&&!this.#R)this.#K();if(this.#R){if(!G)this.#v(H,Y,$);if(W)this.#P(W,H)}if(!Q&&this.#w&&this.#O){let F=this.#O,z;while(z=F?.shift())this.#$?.(...z)}return this}pop(){try{while(this.#W){let Z=this.#Q[this.#L];if(this.#y(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#w&&this.#O){let Z=this.#O,J;while(J=Z?.shift())this.#$?.(...J)}}}#y(Z){let J=this.#L,X=this.#z[J],Y=this.#Q[J];if(this.#C&&this.#q(Y))Y.__abortController.abort(new Error("evicted"));else if(this.#N||this.#w){if(this.#N)this.#Y?.(Y,X,"evict");if(this.#w)this.#O?.push([Y,X,"evict"])}if(this.#x(J),Z)this.#z[J]=void 0,this.#Q[J]=void 0,this.#E.push(J);if(this.#W===1)this.#L=this.#j=0,this.#E.length=0;else this.#L=this.#U[J];return this.#V.delete(X),this.#W--,J}has(Z,J={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:Y}=J,$=this.#V.get(Z);if($!==void 0){let Q=this.#Q[$];if(this.#q(Q)&&Q.__staleWhileFetching===void 0)return!1;if(!this.#D($)){if(X)this.#A($);if(Y)Y.has="hit",this.#P(Y,$);return!0}else if(Y)Y.has="stale",this.#P(Y,$)}else if(Y)Y.has="miss";return!1}peek(Z,J={}){let{allowStale:X=this.allowStale}=J,Y=this.#V.get(Z);if(Y===void 0||!X&&this.#D(Y))return;let $=this.#Q[Y];return this.#q($)?$.__staleWhileFetching:$}#h(Z,J,X,Y){let $=J===void 0?void 0:this.#Q[J];if(this.#q($))return $;let Q=new IL,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:Y},G=(U,L=!1)=>{let{aborted:B}=Q.signal,w=X.ignoreFetchAbort&&U!==void 0;if(X.status)if(B&&!L){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,w)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(B&&!w&&!L)return H(Q.signal.reason);let O=z;if(this.#Q[J]===z)if(U===void 0)if(O.__staleWhileFetching)this.#Q[J]=O.__staleWhileFetching;else this.#S(Z,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Z,U,W.options)}return U},V=(U)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=U;return H(U)},H=(U)=>{let{aborted:L}=Q.signal,B=L&&X.allowStaleOnFetchAbort,w=B||X.allowStaleOnFetchRejection,O=w||X.noDeleteOnFetchRejection,N=z;if(this.#Q[J]===z){if(!O||N.__staleWhileFetching===void 0)this.#S(Z,"fetch");else if(!B)this.#Q[J]=N.__staleWhileFetching}if(w){if(X.status&&N.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return N.__staleWhileFetching}else if(N.__returned===N)throw U},F=(U,L)=>{let B=this.#H?.(Z,$,W);if(B&&B instanceof Promise)B.then((w)=>U(w===void 0?void 0:w),L);Q.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if(U(void 0),X.allowStaleOnFetchAbort)U=(w)=>G(w,!0)}})};if(X.status)X.status.fetchDispatched=!0;let z=new Promise(F).then(G,V),q=Object.assign(z,{__abortController:Q,__staleWhileFetching:$,__returned:void 0});if(J===void 0)this.set(Z,q,{...W.options,status:void 0}),J=this.#V.get(Z);else this.#Q[J]=q;return q}#q(Z){if(!this.#C)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof IL}async fetch(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:Y=this.updateAgeOnGet,noDeleteOnStaleGet:$=this.noDeleteOnStaleGet,ttl:Q=this.ttl,noDisposeOnSet:K=this.noDisposeOnSet,size:W=0,sizeCalculation:G=this.sizeCalculation,noUpdateTTL:V=this.noUpdateTTL,noDeleteOnFetchRejection:H=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:F=this.allowStaleOnFetchRejection,ignoreFetchAbort:z=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:U,forceRefresh:L=!1,status:B,signal:w}=J;if(!this.#C){if(B)B.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,status:B})}let O={allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:V,noDeleteOnFetchRejection:H,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:q,ignoreFetchAbort:z,status:B,signal:w},N=this.#V.get(Z);if(N===void 0){if(B)B.fetch="miss";let R=this.#h(Z,N,O,U);return R.__returned=R}else{let R=this.#Q[N];if(this.#q(R)){let E=X&&R.__staleWhileFetching!==void 0;if(B){if(B.fetch="inflight",E)B.returnedStale=!0}return E?R.__staleWhileFetching:R.__returned=R}let D=this.#D(N);if(!L&&!D){if(B)B.fetch="hit";if(this.#b(N),Y)this.#A(N);if(B)this.#P(B,N);return R}let M=this.#h(Z,N,O,U),T=M.__staleWhileFetching!==void 0&&X;if(B){if(B.fetch=D?"stale":"refresh",T&&D)B.returnedStale=!0}return T?M.__staleWhileFetching:M.__returned=M}}async forceFetch(Z,J={}){let X=await this.fetch(Z,J);if(X===void 0)throw new Error("fetch() returned undefined");return X}memo(Z,J={}){let X=this.#F;if(!X)throw new Error("no memoMethod provided to constructor");let{context:Y,forceRefresh:$,...Q}=J,K=this.get(Z,Q);if(!$&&K!==void 0)return K;let W=X(Z,K,{options:Q,context:Y});return this.set(Z,W,Q),W}get(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:Y=this.updateAgeOnGet,noDeleteOnStaleGet:$=this.noDeleteOnStaleGet,status:Q}=J,K=this.#V.get(Z);if(K!==void 0){let W=this.#Q[K],G=this.#q(W);if(Q)this.#P(Q,K);if(this.#D(K)){if(Q)Q.get="stale";if(!G){if(!$)this.#S(Z,"expire");if(Q&&X)Q.returnedStale=!0;return X?W:void 0}else{if(Q&&X&&W.__staleWhileFetching!==void 0)Q.returnedStale=!0;return X?W.__staleWhileFetching:void 0}}else{if(Q)Q.get="hit";if(G)return W.__staleWhileFetching;if(this.#b(K),Y)this.#A(K);return W}}else if(Q)Q.get="miss"}#c(Z,J){this.#B[J]=Z,this.#U[Z]=J}#b(Z){if(Z!==this.#j){if(Z===this.#L)this.#L=this.#U[Z];else this.#c(this.#B[Z],this.#U[Z]);this.#c(this.#j,Z),this.#j=Z}}delete(Z){return this.#S(Z,"delete")}#S(Z,J){let X=!1;if(this.#W!==0){let Y=this.#V.get(Z);if(Y!==void 0)if(X=!0,this.#W===1)this.#g(J);else{this.#x(Y);let $=this.#Q[Y];if(this.#q($))$.__abortController.abort(new Error("deleted"));else if(this.#N||this.#w){if(this.#N)this.#Y?.($,Z,J);if(this.#w)this.#O?.push([$,Z,J])}if(this.#V.delete(Z),this.#z[Y]=void 0,this.#Q[Y]=void 0,Y===this.#j)this.#j=this.#B[Y];else if(Y===this.#L)this.#L=this.#U[Y];else{let Q=this.#B[Y];this.#U[Q]=this.#U[Y];let K=this.#U[Y];this.#B[K]=this.#B[Y]}this.#W--,this.#E.push(Y)}}if(this.#w&&this.#O?.length){let Y=this.#O,$;while($=Y?.shift())this.#$?.(...$)}return X}clear(){return this.#g("delete")}#g(Z){for(let J of this.#I({allowStale:!0})){let X=this.#Q[J];if(this.#q(X))X.__abortController.abort(new Error("deleted"));else{let Y=this.#z[J];if(this.#N)this.#Y?.(X,Y,Z);if(this.#w)this.#O?.push([X,Y,Z])}}if(this.#V.clear(),this.#Q.fill(void 0),this.#z.fill(void 0),this.#R&&this.#M)this.#R.fill(0),this.#M.fill(0);if(this.#k)this.#k.fill(0);if(this.#L=0,this.#j=0,this.#E.length=0,this.#G=0,this.#W=0,this.#w&&this.#O){let J=this.#O,X;while(X=J?.shift())this.#$?.(...X)}}}import{posix as iL1,win32 as LD}from"node:path";import{fileURLToPath as nL1}from"node:url";import{lstatSync as aL1,readdir as sL1,readdirSync as oL1,readlinkSync as rL1,realpathSync as tL1}from"fs";import*as eL1 from"node:fs";import{lstat as JB1,readdir as XB1,readlink as YB1,realpath as $B1}from"node:fs/promises";import{EventEmitter as zD}from"node:events";import Al from"node:stream";import{StringDecoder as fL1}from"node:string_decoder";var Il=typeof process==="object"&&process?process:{stdout:null,stderr:null},yL1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof BY||Z instanceof Al||bL1(Z)||gL1(Z)),bL1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof zD&&typeof Z.pipe==="function"&&Z.pipe!==Al.Writable.prototype.pipe,gL1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof zD&&typeof Z.write==="function"&&typeof Z.end==="function",FZ=Symbol("EOF"),qZ=Symbol("maybeEmitEnd"),CJ=Symbol("emittedEnd"),_L=Symbol("emittingEnd"),d3=Symbol("emittedError"),vL=Symbol("closed"),_l=Symbol("read"),SL=Symbol("flush"),vl=Symbol("flushChunk"),B4=Symbol("encoding"),$K=Symbol("decoder"),s8=Symbol("flowing"),c3=Symbol("paused"),QK=Symbol("resume"),o8=Symbol("buffer"),i6=Symbol("pipes"),r8=Symbol("bufferLength"),KD=Symbol("bufferPush"),AL=Symbol("bufferShift"),T6=Symbol("objectMode"),w8=Symbol("destroyed"),WD=Symbol("error"),GD=Symbol("emitData"),Sl=Symbol("emitEnd"),VD=Symbol("emitEnd2"),Q7=Symbol("async"),HD=Symbol("abort"),xL=Symbol("aborted"),l3=Symbol("signal"),LY=Symbol("dataListeners"),i5=Symbol("discarded"),p3=(Z)=>Promise.resolve().then(Z),mL1=(Z)=>Z(),uL1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",dL1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,cL1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class FD{src;dest;opts;ondrain;constructor(Z,J,X){this.src=Z,this.dest=J,this.opts=X,this.ondrain=()=>Z[QK](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(Z){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class xl extends FD{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Z,J,X){super(Z,J,X);this.proxyErrors=(Y)=>J.emit("error",Y),Z.on("error",this.proxyErrors)}}var lL1=(Z)=>!!Z.objectMode,pL1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class BY extends zD{[s8]=!1;[c3]=!1;[i6]=[];[o8]=[];[T6];[B4];[Q7];[$K];[FZ]=!1;[CJ]=!1;[_L]=!1;[vL]=!1;[d3]=null;[r8]=0;[w8]=!1;[l3];[xL]=!1;[LY]=0;[i5]=!1;writable=!0;readable=!0;constructor(...Z){let J=Z[0]||{};super();if(J.objectMode&&typeof J.encoding==="string")throw new TypeError("Encoding and objectMode may not be used together");if(lL1(J))this[T6]=!0,this[B4]=null;else if(pL1(J))this[B4]=J.encoding,this[T6]=!1;else this[T6]=!1,this[B4]=null;if(this[Q7]=!!J.async,this[$K]=this[B4]?new fL1(this[B4]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[o8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[i6]});let{signal:X}=J;if(X)if(this[l3]=X,X.aborted)this[HD]();else X.addEventListener("abort",()=>this[HD]())}get bufferLength(){return this[r8]}get encoding(){return this[B4]}set encoding(Z){throw new Error("Encoding must be set at instantiation time")}setEncoding(Z){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[T6]}set objectMode(Z){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[Q7]}set["async"](Z){this[Q7]=this[Q7]||!!Z}[HD](){this[xL]=!0,this.emit("abort",this[l3]?.reason),this.destroy(this[l3]?.reason)}get aborted(){return this[xL]}set aborted(Z){}write(Z,J,X){if(this[xL])return!1;if(this[FZ])throw new Error("write after end");if(this[w8])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof J==="function")X=J,J="utf8";if(!J)J="utf8";let Y=this[Q7]?p3:mL1;if(!this[T6]&&!Buffer.isBuffer(Z)){if(cL1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(dL1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[T6]){if(this[s8]&&this[r8]!==0)this[SL](!0);if(this[s8])this.emit("data",Z);else this[KD](Z);if(this[r8]!==0)this.emit("readable");if(X)Y(X);return this[s8]}if(!Z.length){if(this[r8]!==0)this.emit("readable");if(X)Y(X);return this[s8]}if(typeof Z==="string"&&!(J===this[B4]&&!this[$K]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[B4])Z=this[$K].write(Z);if(this[s8]&&this[r8]!==0)this[SL](!0);if(this[s8])this.emit("data",Z);else this[KD](Z);if(this[r8]!==0)this.emit("readable");if(X)Y(X);return this[s8]}read(Z){if(this[w8])return null;if(this[i5]=!1,this[r8]===0||Z===0||Z&&Z>this[r8])return this[qZ](),null;if(this[T6])Z=null;if(this[o8].length>1&&!this[T6])this[o8]=[this[B4]?this[o8].join(""):Buffer.concat(this[o8],this[r8])];let J=this[_l](Z||null,this[o8][0]);return this[qZ](),J}[_l](Z,J){if(this[T6])this[AL]();else{let X=J;if(Z===X.length||Z===null)this[AL]();else if(typeof X==="string")this[o8][0]=X.slice(Z),J=X.slice(0,Z),this[r8]-=Z;else this[o8][0]=X.subarray(Z),J=X.subarray(0,Z),this[r8]-=Z}if(this.emit("data",J),!this[o8].length&&!this[FZ])this.emit("drain");return J}end(Z,J,X){if(typeof Z==="function")X=Z,Z=void 0;if(typeof J==="function")X=J,J="utf8";if(Z!==void 0)this.write(Z,J);if(X)this.once("end",X);if(this[FZ]=!0,this.writable=!1,this[s8]||!this[c3])this[qZ]();return this}[QK](){if(this[w8])return;if(!this[LY]&&!this[i6].length)this[i5]=!0;if(this[c3]=!1,this[s8]=!0,this.emit("resume"),this[o8].length)this[SL]();else if(this[FZ])this[qZ]();else this.emit("drain")}resume(){return this[QK]()}pause(){this[s8]=!1,this[c3]=!0,this[i5]=!1}get destroyed(){return this[w8]}get flowing(){return this[s8]}get paused(){return this[c3]}[KD](Z){if(this[T6])this[r8]+=1;else this[r8]+=Z.length;this[o8].push(Z)}[AL](){if(this[T6])this[r8]-=1;else this[r8]-=this[o8][0].length;return this[o8].shift()}[SL](Z=!1){do;while(this[vl](this[AL]())&&this[o8].length);if(!Z&&!this[o8].length&&!this[FZ])this.emit("drain")}[vl](Z){return this.emit("data",Z),this[s8]}pipe(Z,J){if(this[w8])return Z;this[i5]=!1;let X=this[CJ];if(J=J||{},Z===Il.stdout||Z===Il.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[i6].push(!J.proxyErrors?new FD(this,Z,J):new xl(this,Z,J)),this[Q7])p3(()=>this[QK]());else this[QK]();return Z}unpipe(Z){let J=this[i6].find((X)=>X.dest===Z);if(J){if(this[i6].length===1){if(this[s8]&&this[LY]===0)this[s8]=!1;this[i6]=[]}else this[i6].splice(this[i6].indexOf(J),1);J.unpipe()}}addListener(Z,J){return this.on(Z,J)}on(Z,J){let X=super.on(Z,J);if(Z==="data"){if(this[i5]=!1,this[LY]++,!this[i6].length&&!this[s8])this[QK]()}else if(Z==="readable"&&this[r8]!==0)super.emit("readable");else if(uL1(Z)&&this[CJ])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[d3]){let Y=J;if(this[Q7])p3(()=>Y.call(this,this[d3]));else Y.call(this,this[d3])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[LY]=this.listeners("data").length,this[LY]===0&&!this[i5]&&!this[i6].length)this[s8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[LY]=0,!this[i5]&&!this[i6].length)this[s8]=!1}return J}get emittedEnd(){return this[CJ]}[qZ](){if(!this[_L]&&!this[CJ]&&!this[w8]&&this[o8].length===0&&this[FZ]){if(this[_L]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[vL])this.emit("close");this[_L]=!1}}emit(Z,...J){let X=J[0];if(Z!=="error"&&Z!=="close"&&Z!==w8&&this[w8])return!1;else if(Z==="data")return!this[T6]&&!X?!1:this[Q7]?(p3(()=>this[GD](X)),!0):this[GD](X);else if(Z==="end")return this[Sl]();else if(Z==="close"){if(this[vL]=!0,!this[CJ]&&!this[w8])return!1;let $=super.emit("close");return this.removeAllListeners("close"),$}else if(Z==="error"){this[d3]=X,super.emit(WD,X);let $=!this[l3]||this.listeners("error").length?super.emit("error",X):!1;return this[qZ](),$}else if(Z==="resume"){let $=super.emit("resume");return this[qZ](),$}else if(Z==="finish"||Z==="prefinish"){let $=super.emit(Z);return this.removeAllListeners(Z),$}let Y=super.emit(Z,...J);return this[qZ](),Y}[GD](Z){for(let X of this[i6])if(X.dest.write(Z)===!1)this.pause();let J=this[i5]?!1:super.emit("data",Z);return this[qZ](),J}[Sl](){if(this[CJ])return!1;return this[CJ]=!0,this.readable=!1,this[Q7]?(p3(()=>this[VD]()),!0):this[VD]()}[VD](){if(this[$K]){let J=this[$K].end();if(J){for(let X of this[i6])X.dest.write(J);if(!this[i5])super.emit("data",J)}}for(let J of this[i6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[T6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[T6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[T6])throw new Error("cannot concat in objectMode");let Z=await this.collect();return this[B4]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(w8,()=>J(new Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[i5]=!1;let Z=!1,J=async()=>{return this.pause(),Z=!0,{value:void 0,done:!0}};return{next:()=>{if(Z)return J();let Y=this.read();if(Y!==null)return Promise.resolve({done:!1,value:Y});if(this[FZ])return J();let $,Q,K=(H)=>{this.off("data",W),this.off("end",G),this.off(w8,V),J(),Q(H)},W=(H)=>{this.off("error",K),this.off("end",G),this.off(w8,V),this.pause(),$({value:H,done:!!this[FZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(w8,V),J(),$({done:!0,value:void 0})},V=()=>K(new Error("stream destroyed"));return new Promise((H,F)=>{Q=F,$=H,this.once(w8,V),this.once("error",K),this.once("end",G),this.once("data",W)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[i5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(WD,J),this.off(w8,J),this.off("end",J),Z=!0,{done:!0,value:void 0}},X=()=>{if(Z)return J();let Y=this.read();return Y===null?J():{done:!1,value:Y}};return this.once("end",J),this.once(WD,J),this.once(w8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[w8]){if(Z)this.emit("error",Z);else this.emit(w8);return this}this[w8]=!0,this[i5]=!0,this[o8].length=0,this[r8]=0;let J=this;if(typeof J.close==="function"&&!this[vL])J.close();if(Z)this.emit("error",Z);else this.emit(w8);return this}static get isStream(){return yL1}}var ZB1=tL1.native,n3={lstatSync:aL1,readdir:sL1,readdirSync:oL1,readlinkSync:rL1,realpathSync:ZB1,promises:{lstat:JB1,readdir:XB1,readlink:YB1,realpath:$B1}},gl=(Z)=>!Z||Z===n3||Z===eL1?n3:{...n3,...Z,promises:{...n3.promises,...Z.promises||{}}},ml=/^\\\\\?\\([a-z]:)\\?$/i,QB1=(Z)=>Z.replace(/\//g,"\\").replace(ml,"$1\\"),KB1=/[\\\/]/,T9=0,ul=1,dl=2,K7=4,cl=6,ll=8,wY=10,pl=12,C9=15,i3=~C9,qD=16,hl=32,a3=64,w4=128,hL=256,yL=512,fl=a3|w4|yL,WB1=1023,UD=(Z)=>Z.isFile()?ll:Z.isDirectory()?K7:Z.isSymbolicLink()?wY:Z.isCharacterDevice()?dl:Z.isBlockDevice()?cl:Z.isSocket()?pl:Z.isFIFO()?ul:T9,yl=new Map,s3=(Z)=>{let J=yl.get(Z);if(J)return J;let X=Z.normalize("NFKD");return yl.set(Z,X),X},bl=new Map,fL=(Z)=>{let J=bl.get(Z);if(J)return J;let X=s3(Z.toLowerCase());return bl.set(Z,X),X};class BD extends u3{constructor(){super({max:256})}}class il extends u3{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var nl=Symbol("PathScurry setAsCwd");class n6{name;root;roots;parent;nocase;isCWD=!1;#Z;#J;get dev(){return this.#J}#Y;get mode(){return this.#Y}#X;get nlink(){return this.#X}#$;get uid(){return this.#$}#H;get gid(){return this.#H}#F;get rdev(){return this.#F}#W;get blksize(){return this.#W}#G;get ino(){return this.#G}#V;get size(){return this.#V}#z;get blocks(){return this.#z}#Q;get atimeMs(){return this.#Q}#U;get mtimeMs(){return this.#U}#B;get ctimeMs(){return this.#B}#L;get birthtimeMs(){return this.#L}#j;get atime(){return this.#j}#E;get mtime(){return this.#E}#O;get ctime(){return this.#O}#k;get birthtime(){return this.#k}#M;#R;#N;#C;#w;#_;#K;#A;#P;#v;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=T9,X,Y,$,Q,K){if(this.name=Z,this.#M=$?fL(Z):s3(Z),this.#K=J&WB1,this.nocase=$,this.roots=Y,this.root=X||this,this.#A=Q,this.#N=K.fullpath,this.#w=K.relative,this.#_=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=gl(K.fs)}depth(){if(this.#R!==void 0)return this.#R;if(!this.parent)return this.#R=0;return this.#R=this.parent.depth()+1}childrenCache(){return this.#A}resolve(Z){if(!Z)return this;let J=this.getRootString(Z),Y=Z.substring(J.length).split(this.splitSep);return J?this.getRoot(J).#D(Y):this.#D(Y)}#D(Z){let J=this;for(let X of Z)J=J.child(X);return J}children(){let Z=this.#A.get(this);if(Z)return Z;let J=Object.assign([],{provisional:0});return this.#A.set(this,J),this.#K&=~qD,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),Y=this.nocase?fL(Z):s3(Z);for(let W of X)if(W.#M===Y)return W;let $=this.parent?this.sep:"",Q=this.#N?this.#N+$+Z:void 0,K=this.newChild(Z,T9,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=w4;return X.push(K),K}relative(){if(this.isCWD)return"";if(this.#w!==void 0)return this.#w;let Z=this.name,J=this.parent;if(!J)return this.#w=this.name;let X=J.relative();return X+(!X||!J.parent?"":this.sep)+Z}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#_!==void 0)return this.#_;let Z=this.name,J=this.parent;if(!J)return this.#_=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#N!==void 0)return this.#N;let Z=this.name,J=this.parent;if(!J)return this.#N=this.name;let Y=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#N=Y}fullpathPosix(){if(this.#C!==void 0)return this.#C;if(this.sep==="/")return this.#C=this.fullpath();if(!this.parent){let Y=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(Y))return this.#C=`//?/${Y}`;else return this.#C=Y}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#C=X}isUnknown(){return(this.#K&C9)===T9}isType(Z){return this[`is${Z}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#K&C9)===ll}isDirectory(){return(this.#K&C9)===K7}isCharacterDevice(){return(this.#K&C9)===dl}isBlockDevice(){return(this.#K&C9)===cl}isFIFO(){return(this.#K&C9)===ul}isSocket(){return(this.#K&C9)===pl}isSymbolicLink(){return(this.#K&wY)===wY}lstatCached(){return this.#K&hl?this:void 0}readlinkCached(){return this.#P}realpathCached(){return this.#v}readdirCached(){let Z=this.children();return Z.slice(0,Z.provisional)}canReadlink(){if(this.#P)return!0;if(!this.parent)return!1;let Z=this.#K&C9;return!(Z!==T9&&Z!==wY||this.#K&hL||this.#K&w4)}calledReaddir(){return!!(this.#K&qD)}isENOENT(){return!!(this.#K&w4)}isNamed(Z){return!this.nocase?this.#M===s3(Z):this.#M===fL(Z)}async readlink(){let Z=this.#P;if(Z)return Z;if(!this.canReadlink())return;if(!this.parent)return;try{let J=await this.#Z.promises.readlink(this.fullpath()),X=(await this.parent.realpath())?.resolve(J);if(X)return this.#P=X}catch(J){this.#y(J.code);return}}readlinkSync(){let Z=this.#P;if(Z)return Z;if(!this.canReadlink())return;if(!this.parent)return;try{let J=this.#Z.readlinkSync(this.fullpath()),X=this.parent.realpathSync()?.resolve(J);if(X)return this.#P=X}catch(J){this.#y(J.code);return}}#m(Z){this.#K|=qD;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#x()}}#x(){if(this.#K&w4)return;this.#K=(this.#K|w4)&i3,this.#f()}#f(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#x()}#u(){this.#K|=yL,this.#T()}#T(){if(this.#K&a3)return;let Z=this.#K;if((Z&C9)===K7)Z&=i3;this.#K=Z|a3,this.#f()}#I(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#T();else if(Z==="ENOENT")this.#x();else this.children().provisional=0}#d(Z=""){if(Z==="ENOTDIR")this.parent.#T();else if(Z==="ENOENT")this.#x()}#y(Z=""){let J=this.#K;if(J|=hL,Z==="ENOENT")J|=w4;if(Z==="EINVAL"||Z==="UNKNOWN")J&=i3;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#T()}#h(Z,J){return this.#c(Z,J)||this.#q(Z,J)}#q(Z,J){let X=UD(Z),Y=this.newChild(Z.name,X,{parent:this}),$=Y.#K&C9;if($!==K7&&$!==wY&&$!==T9)Y.#K|=a3;return J.unshift(Y),J.provisional++,Y}#c(Z,J){for(let X=J.provisional;X<J.length;X++){let Y=J[X];if((this.nocase?fL(Z.name):s3(Z.name))!==Y.#M)continue;return this.#b(Z,Y,X,J)}}#b(Z,J,X,Y){let $=J.name;if(J.#K=J.#K&i3|UD(Z),$!==Z.name)J.name=Z.name;if(X!==Y.provisional){if(X===Y.length-1)Y.pop();else Y.splice(X,1);Y.unshift(J)}return Y.provisional++,J}async lstat(){if((this.#K&w4)===0)try{return this.#S(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#d(Z.code)}}lstatSync(){if((this.#K&w4)===0)try{return this.#S(this.#Z.lstatSync(this.fullpath())),this}catch(Z){this.#d(Z.code)}}#S(Z){let{atime:J,atimeMs:X,birthtime:Y,birthtimeMs:$,blksize:Q,blocks:K,ctime:W,ctimeMs:G,dev:V,gid:H,ino:F,mode:z,mtime:q,mtimeMs:U,nlink:L,rdev:B,size:w,uid:O}=Z;this.#j=J,this.#Q=X,this.#k=Y,this.#L=$,this.#W=Q,this.#z=K,this.#O=W,this.#B=G,this.#J=V,this.#H=H,this.#G=F,this.#Y=z,this.#E=q,this.#U=U,this.#X=L,this.#F=B,this.#V=w,this.#$=O;let N=UD(Z);if(this.#K=this.#K&i3|N|hl,N!==T9&&N!==K7&&N!==wY)this.#K|=a3}#g=[];#p=!1;#i(Z){this.#p=!1;let J=this.#g.slice();this.#g.length=0,J.forEach((X)=>X(null,Z))}readdirCB(Z,J=!1){if(!this.canReaddir()){if(J)Z(null,[]);else queueMicrotask(()=>Z(null,[]));return}let X=this.children();if(this.calledReaddir()){let $=X.slice(0,X.provisional);if(J)Z(null,$);else queueMicrotask(()=>Z(null,$));return}if(this.#g.push(Z),this.#p)return;this.#p=!0;let Y=this.fullpath();this.#Z.readdir(Y,{withFileTypes:!0},($,Q)=>{if($)this.#I($.code),X.provisional=0;else{for(let K of Q)this.#h(K,X);this.#m(X)}this.#i(X.slice(0,X.provisional));return})}#l;async readdir(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();if(this.#l)await this.#l;else{let X=()=>{};this.#l=new Promise((Y)=>X=Y);try{for(let Y of await this.#Z.promises.readdir(J,{withFileTypes:!0}))this.#h(Y,Z);this.#m(Z)}catch(Y){this.#I(Y.code),Z.provisional=0}this.#l=void 0,X()}return Z.slice(0,Z.provisional)}readdirSync(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();try{for(let X of this.#Z.readdirSync(J,{withFileTypes:!0}))this.#h(X,Z);this.#m(Z)}catch(X){this.#I(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&fl)return!1;let Z=C9&this.#K;if(!(Z===T9||Z===K7||Z===wY))return!1;return!0}shouldWalk(Z,J){return(this.#K&K7)===K7&&!(this.#K&fl)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#v)return this.#v;if((yL|hL|w4)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#v=this.resolve(Z)}catch(Z){this.#u()}}realpathSync(){if(this.#v)return this.#v;if((yL|hL|w4)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#v=this.resolve(Z)}catch(Z){this.#u()}}[nl](Z){if(Z===this)return;Z.isCWD=!1,this.isCWD=!0;let J=new Set([]),X=[],Y=this;while(Y&&Y.parent)J.add(Y),Y.#w=X.join(this.sep),Y.#_=X.join("/"),Y=Y.parent,X.push("..");Y=Z;while(Y&&Y.parent&&!J.has(Y))Y.#w=void 0,Y.#_=void 0,Y=Y.parent}}class bL extends n6{sep="\\";splitSep=KB1;constructor(Z,J=T9,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}newChild(Z,J=T9,X={}){return new bL(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return LD.parse(Z).root}getRoot(Z){if(Z=QB1(Z.toUpperCase()),Z===this.root.name)return this.root;for(let[J,X]of Object.entries(this.roots))if(this.sameRoot(Z,J))return this.roots[Z]=X;return this.roots[Z]=new o3(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(ml,"$1\\"),Z===J}}class gL extends n6{splitSep="/";sep="/";constructor(Z,J=T9,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=T9,X={}){return new gL(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class wD{root;rootPath;roots;cwd;#Z;#J;#Y;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:Y,childrenCacheSize:$=16384,fs:Q=n3}={}){if(this.#X=gl(Q),Z instanceof URL||Z.startsWith("file://"))Z=nL1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new BD,this.#J=new BD,this.#Y=new il($);let W=K.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if(Y===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=Y,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let G=this.root,V=W.length-1,H=J.sep,F=this.rootPath,z=!1;for(let q of W){let U=V--;G=G.child(q,{relative:new Array(U).fill("..").join(H),relativePosix:new Array(U).fill("..").join("/"),fullpath:F+=(z?"":H)+q}),z=!0}this.cwd=G}depth(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.depth()}childrenCache(){return this.#Y}resolve(...Z){let J="";for(let $=Z.length-1;$>=0;$--){let Q=Z[$];if(!Q||Q===".")continue;if(J=J?`${Q}/${J}`:Q,this.isAbsolute(Q))break}let X=this.#Z.get(J);if(X!==void 0)return X;let Y=this.cwd.resolve(J).fullpath();return this.#Z.set(J,Y),Y}resolvePosix(...Z){let J="";for(let $=Z.length-1;$>=0;$--){let Q=Z[$];if(!Q||Q===".")continue;if(J=J?`${Q}/${J}`:Q,this.isAbsolute(Q))break}let X=this.#J.get(J);if(X!==void 0)return X;let Y=this.cwd.resolve(J).fullpathPosix();return this.#J.set(J,Y),Y}relative(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.relative()}relativePosix(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.relativePosix()}basename(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.name}dirname(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return(Z.parent||Z).fullpath()}async readdir(Z=this.cwd,J={withFileTypes:!0}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X}=J;if(!Z.canReaddir())return[];else{let Y=await Z.readdir();return X?Y:Y.map(($)=>$.name)}}readdirSync(Z=this.cwd,J={withFileTypes:!0}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X=!0}=J;if(!Z.canReaddir())return[];else if(X)return Z.readdirSync();else return Z.readdirSync().map((Y)=>Y.name)}async lstat(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.lstat()}lstatSync(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.lstatSync()}async readlink(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z.withFileTypes,Z=this.cwd;let X=await Z.readlink();return J?X:X?.fullpath()}readlinkSync(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z.withFileTypes,Z=this.cwd;let X=Z.readlinkSync();return J?X:X?.fullpath()}async realpath(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z.withFileTypes,Z=this.cwd;let X=await Z.realpath();return J?X:X?.fullpath()}realpathSync(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z.withFileTypes,Z=this.cwd;let X=Z.realpathSync();return J?X:X?.fullpath()}async walk(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=[];if(!$||$(Z))K.push(X?Z:Z.fullpath());let W=new Set,G=(H,F)=>{W.add(H),H.readdirCB((z,q)=>{if(z)return F(z);let U=q.length;if(!U)return F();let L=()=>{if(--U===0)F()};for(let B of q){if(!$||$(B))K.push(X?B:B.fullpath());if(Y&&B.isSymbolicLink())B.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(W,Q)?G(w,L):L());else if(B.shouldWalk(W,Q))G(B,L);else L()}},!0)},V=Z;return new Promise((H,F)=>{G(V,(z)=>{if(z)return F(z);H(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=[];if(!$||$(Z))K.push(X?Z:Z.fullpath());let W=new Set([Z]);for(let G of W){let V=G.readdirSync();for(let H of V){if(!$||$(H))K.push(X?H:H.fullpath());let F=H;if(H.isSymbolicLink()){if(!(Y&&(F=H.realpathSync())))continue;if(F.isUnknown())F.lstatSync()}if(F.shouldWalk(W,Q))W.add(F)}}return K}[Symbol.asyncIterator](){return this.iterate()}iterate(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;return this.stream(Z,J)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J;if(!$||$(Z))yield X?Z:Z.fullpath();let K=new Set([Z]);for(let W of K){let G=W.readdirSync();for(let V of G){if(!$||$(V))yield X?V:V.fullpath();let H=V;if(V.isSymbolicLink()){if(!(Y&&(H=V.realpathSync())))continue;if(H.isUnknown())H.lstatSync()}if(H.shouldWalk(K,Q))K.add(H)}}}stream(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new BY({objectMode:!0});if(!$||$(Z))K.write(X?Z:Z.fullpath());let W=new Set,G=[Z],V=0,H=()=>{let F=!1;while(!F){let z=G.shift();if(!z){if(V===0)K.end();return}V++,W.add(z);let q=(L,B,w=!1)=>{if(L)return K.emit("error",L);if(Y&&!w){let O=[];for(let N of B)if(N.isSymbolicLink())O.push(N.realpath().then((R)=>R?.isUnknown()?R.lstat():R));if(O.length){Promise.all(O).then(()=>q(null,B,!0));return}}for(let O of B)if(O&&(!$||$(O))){if(!K.write(X?O:O.fullpath()))F=!0}V--;for(let O of B){let N=O.realpathCached()||O;if(N.shouldWalk(W,Q))G.push(N)}if(F&&!K.flowing)K.once("drain",H);else if(!U)H()},U=!0;z.readdirCB(q,!0),U=!1}};return H(),K}streamSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new BY({objectMode:!0}),W=new Set;if(!$||$(Z))K.write(X?Z:Z.fullpath());let G=[Z],V=0,H=()=>{let F=!1;while(!F){let z=G.shift();if(!z){if(V===0)K.end();return}V++,W.add(z);let q=z.readdirSync();for(let U of q)if(!$||$(U)){if(!K.write(X?U:U.fullpath()))F=!0}V--;for(let U of q){let L=U;if(U.isSymbolicLink()){if(!(Y&&(L=U.realpathSync())))continue;if(L.isUnknown())L.lstatSync()}if(L.shouldWalk(W,Q))G.push(L)}}if(F&&!K.flowing)K.once("drain",H)};return H(),K}chdir(Z=this.cwd){let J=this.cwd;this.cwd=typeof Z==="string"?this.cwd.resolve(Z):Z,this.cwd[nl](J)}}class o3 extends wD{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,LD,"\\",{...J,nocase:X});this.nocase=X;for(let Y=this.cwd;Y;Y=Y.parent)Y.nocase=this.nocase}parseRootPath(Z){return LD.parse(Z).root.toUpperCase()}newRoot(Z){return new bL(this.rootPath,K7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class r3 extends wD{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,iL1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new gL(this.rootPath,K7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class mL extends r3{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var eD6=process.platform==="win32"?bL:gL,al=process.platform==="win32"?o3:process.platform==="darwin"?mL:r3;var GB1=(Z)=>Z.length>=1,VB1=(Z)=>Z.length>=1;class KK{#Z;#J;#Y;length;#X;#$;#H;#F;#W;#G;#V=!0;constructor(Z,J,X,Y){if(!GB1(Z))throw new TypeError("empty pattern list");if(!VB1(J))throw new TypeError("empty glob list");if(J.length!==Z.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=Z.length,X<0||X>=this.length)throw new TypeError("index out of range");if(this.#Z=Z,this.#J=J,this.#Y=X,this.#X=Y,this.#Y===0){if(this.isUNC()){let[$,Q,K,W,...G]=this.#Z,[V,H,F,z,...q]=this.#J;if(G[0]==="")G.shift(),q.shift();let U=[$,Q,K,W,""].join("/"),L=[V,H,F,z,""].join("/");this.#Z=[U,...G],this.#J=[L,...q],this.length=this.#Z.length}else if(this.isDrive()||this.isAbsolute()){let[$,...Q]=this.#Z,[K,...W]=this.#J;if(Q[0]==="")Q.shift(),W.shift();let G=$+"/",V=K+"/";this.#Z=[G,...Q],this.#J=[V,...W],this.length=this.#Z.length}}}pattern(){return this.#Z[this.#Y]}isString(){return typeof this.#Z[this.#Y]==="string"}isGlobstar(){return this.#Z[this.#Y]===L6}isRegExp(){return this.#Z[this.#Y]instanceof RegExp}globString(){return this.#H=this.#H||(this.#Y===0?this.isAbsolute()?this.#J[0]+this.#J.slice(1).join("/"):this.#J.join("/"):this.#J.slice(this.#Y).join("/"))}hasMore(){return this.length>this.#Y+1}rest(){if(this.#$!==void 0)return this.#$;if(!this.hasMore())return this.#$=null;return this.#$=new KK(this.#Z,this.#J,this.#Y+1,this.#X),this.#$.#G=this.#G,this.#$.#W=this.#W,this.#$.#F=this.#F,this.#$}isUNC(){let Z=this.#Z;return this.#W!==void 0?this.#W:this.#W=this.#X==="win32"&&this.#Y===0&&Z[0]===""&&Z[1]===""&&typeof Z[2]==="string"&&!!Z[2]&&typeof Z[3]==="string"&&!!Z[3]}isDrive(){let Z=this.#Z;return this.#F!==void 0?this.#F:this.#F=this.#X==="win32"&&this.#Y===0&&this.length>1&&typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0])}isAbsolute(){let Z=this.#Z;return this.#G!==void 0?this.#G:this.#G=Z[0]===""&&Z.length>1||this.isDrive()||this.isUNC()}root(){let Z=this.#Z[0];return typeof Z==="string"&&this.isAbsolute()&&this.#Y===0?Z:""}checkFollowGlobstar(){return!(this.#Y===0||!this.isGlobstar()||!this.#V)}markFollowGlobstar(){if(this.#Y===0||!this.isGlobstar()||!this.#V)return!1;return this.#V=!1,!0}}var HB1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class t3{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:Y,noglobstar:$,platform:Q=HB1}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=Q,this.mmopts={dot:!0,nobrace:J,nocase:X,noext:Y,noglobstar:$,optimizationLevel:2,platform:Q,nocomment:!0,nonegate:!0};for(let K of Z)this.add(K)}add(Z){let J=new D9(Z,this.mmopts);for(let X=0;X<J.set.length;X++){let Y=J.set[X],$=J.globParts[X];if(!Y||!$)throw new Error("invalid pattern object");while(Y[0]==="."&&$[0]===".")Y.shift(),$.shift();let Q=new KK(Y,$,0,this.platform),K=new D9(Q.globString(),this.mmopts),W=$[$.length-1]==="**",G=Q.isAbsolute();if(G)this.absolute.push(K);else this.relative.push(K);if(W)if(G)this.absoluteChildren.push(K);else this.relativeChildren.push(K)}}ignored(Z){let J=Z.fullpath(),X=`${J}/`,Y=Z.relative()||".",$=`${Y}/`;for(let Q of this.relative)if(Q.match(Y)||Q.match($))return!0;for(let Q of this.absolute)if(Q.match(J)||Q.match(X))return!0;return!1}childrenIgnored(Z){let J=Z.fullpath()+"/",X=(Z.relative()||".")+"/";for(let Y of this.relativeChildren)if(Y.match(X))return!0;for(let Y of this.absoluteChildren)if(Y.match(J))return!0;return!1}}class jD{store;constructor(Z=new Map){this.store=Z}copy(){return new jD(new Map(this.store))}hasWalked(Z,J){return this.store.get(Z.fullpath())?.has(J.globString())}storeWalked(Z,J){let X=Z.fullpath(),Y=this.store.get(X);if(Y)Y.add(J.globString());else this.store.set(X,new Set([J.globString()]))}}class sl{store=new Map;add(Z,J,X){let Y=(J?2:0)|(X?1:0),$=this.store.get(Z);this.store.set(Z,$===void 0?Y:Y&$)}entries(){return[...this.store.entries()].map(([Z,J])=>[Z,!!(J&2),!!(J&1)])}}class ol{store=new Map;add(Z,J){if(!Z.canReaddir())return;let X=this.store.get(Z);if(X){if(!X.find((Y)=>Y.globString()===J.globString()))X.push(J)}else this.store.set(Z,[J])}get(Z){let J=this.store.get(Z);if(!J)throw new Error("attempting to walk unknown path");return J}entries(){return this.keys().map((Z)=>[Z,this.store.get(Z)])}keys(){return[...this.store.keys()].filter((Z)=>Z.canReaddir())}}class e3{hasWalkedCache;matches=new sl;subwalks=new ol;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new jD}processPatterns(Z,J){this.patterns=J;let X=J.map((Y)=>[Z,Y]);for(let[Y,$]of X){this.hasWalkedCache.storeWalked(Y,$);let Q=$.root(),K=$.isAbsolute()&&this.opts.absolute!==!1;if(Q){Y=Y.resolve(Q==="/"&&this.opts.root!==void 0?this.opts.root:Q);let H=$.rest();if(!H){this.matches.add(Y,!0,!1);continue}else $=H}if(Y.isENOENT())continue;let W,G,V=!1;while(typeof(W=$.pattern())==="string"&&(G=$.rest()))Y=Y.resolve(W),$=G,V=!0;if(W=$.pattern(),G=$.rest(),V){if(this.hasWalkedCache.hasWalked(Y,$))continue;this.hasWalkedCache.storeWalked(Y,$)}if(typeof W==="string"){let H=W===".."||W===""||W===".";this.matches.add(Y.resolve(W),K,H);continue}else if(W===L6){if(!Y.isSymbolicLink()||this.follow||$.checkFollowGlobstar())this.subwalks.add(Y,$);let H=G?.pattern(),F=G?.rest();if(!G||(H===""||H===".")&&!F)this.matches.add(Y,K,H===""||H===".");else if(H===".."){let z=Y.parent||Y;if(!F)this.matches.add(z,K,!0);else if(!this.hasWalkedCache.hasWalked(z,F))this.subwalks.add(z,F)}}else if(W instanceof RegExp)this.subwalks.add(Y,$)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new e3(this.opts,this.hasWalkedCache)}filterEntries(Z,J){let X=this.subwalks.get(Z),Y=this.child();for(let $ of J)for(let Q of X){let K=Q.isAbsolute(),W=Q.pattern(),G=Q.rest();if(W===L6)Y.testGlobstar($,Q,G,K);else if(W instanceof RegExp)Y.testRegExp($,W,G,K);else Y.testString($,W,G,K)}return Y}testGlobstar(Z,J,X,Y){if(this.dot||!Z.name.startsWith(".")){if(!J.hasMore())this.matches.add(Z,Y,!1);if(Z.canReaddir()){if(this.follow||!Z.isSymbolicLink())this.subwalks.add(Z,J);else if(Z.isSymbolicLink()){if(X&&J.checkFollowGlobstar())this.subwalks.add(Z,X);else if(J.markFollowGlobstar())this.subwalks.add(Z,J)}}}if(X){let $=X.pattern();if(typeof $==="string"&&$!==".."&&$!==""&&$!==".")this.testString(Z,$,X.rest(),Y);else if($===".."){let Q=Z.parent||Z;this.subwalks.add(Q,X)}else if($ instanceof RegExp)this.testRegExp(Z,$,X.rest(),Y)}}testRegExp(Z,J,X,Y){if(!J.test(Z.name))return;if(!X)this.matches.add(Z,Y,!1);else this.subwalks.add(Z,X)}testString(Z,J,X,Y){if(!Z.isNamed(J))return;if(!X)this.matches.add(Z,Y,!1);else this.subwalks.add(Z,X)}}var zB1=(Z,J)=>typeof Z==="string"?new t3([Z],J):Array.isArray(Z)?new t3(Z,J):Z;class OD{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#J;#Y;signal;maxDepth;includeChildMatches;constructor(Z,J,X){if(this.patterns=Z,this.path=J,this.opts=X,this.#Y=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#J=zB1(X.ignore??[],X),!this.includeChildMatches&&typeof this.#J.add!=="function")throw new Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Z.length=0})}#X(Z){return this.seen.has(Z)||!!this.#J?.ignored?.(Z)}#$(Z){return!!this.#J?.childrenIgnored?.(Z)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Z=void 0;while(!this.paused&&(Z=this.#Z.shift()))Z()}onResume(Z){if(this.signal?.aborted)return;if(!this.paused)Z();else this.#Z.push(Z)}async matchCheck(Z,J){if(J&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Z.realpathCached()||await Z.realpath(),!X)return;Z=X}let $=Z.isUnknown()||this.opts.stat?await Z.lstat():Z;if(this.opts.follow&&this.opts.nodir&&$?.isSymbolicLink()){let Q=await $.realpath();if(Q&&(Q.isUnknown()||this.opts.stat))await Q.lstat()}return this.matchCheckTest($,J)}matchCheckTest(Z,J){return Z&&(this.maxDepth===1/0||Z.depth()<=this.maxDepth)&&(!J||Z.canReaddir())&&(!this.opts.nodir||!Z.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Z.isSymbolicLink()||!Z.realpathCached()?.isDirectory())&&!this.#X(Z)?Z:void 0}matchCheckSync(Z,J){if(J&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Z.realpathCached()||Z.realpathSync(),!X)return;Z=X}let $=Z.isUnknown()||this.opts.stat?Z.lstatSync():Z;if(this.opts.follow&&this.opts.nodir&&$?.isSymbolicLink()){let Q=$.realpathSync();if(Q&&(Q?.isUnknown()||this.opts.stat))Q.lstatSync()}return this.matchCheckTest($,J)}matchFinish(Z,J){if(this.#X(Z))return;if(!this.includeChildMatches&&this.#J?.add){let $=`${Z.relativePosix()}/**`;this.#J.add($)}let X=this.opts.absolute===void 0?J:this.opts.absolute;this.seen.add(Z);let Y=this.opts.mark&&Z.isDirectory()?this.#Y:"";if(this.opts.withFileTypes)this.matchEmit(Z);else if(X){let $=this.opts.posix?Z.fullpathPosix():Z.fullpath();this.matchEmit($+Y)}else{let $=this.opts.posix?Z.relativePosix():Z.relative(),Q=this.opts.dotRelative&&!$.startsWith(".."+this.#Y)?"."+this.#Y:"";this.matchEmit(!$?"."+Y:Q+$+Y)}}async match(Z,J,X){let Y=await this.matchCheck(Z,X);if(Y)this.matchFinish(Y,J)}matchSync(Z,J,X){let Y=this.matchCheckSync(Z,X);if(Y)this.matchFinish(Y,J)}walkCB(Z,J,X){if(this.signal?.aborted)X();this.walkCB2(Z,J,new e3(this.opts),X)}walkCB2(Z,J,X,Y){if(this.#$(Z))return Y();if(this.signal?.aborted)Y();if(this.paused){this.onResume(()=>this.walkCB2(Z,J,X,Y));return}X.processPatterns(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;$++,this.match(K,W,G).then(()=>Q())}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;$++;let W=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,W,X,Q);else K.readdirCB((G,V)=>this.walkCB3(K,V,X,Q),!0)}Q()}walkCB3(Z,J,X,Y){X=X.filterEntries(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;$++,this.match(K,W,G).then(()=>Q())}for(let[K,W]of X.subwalks.entries())$++,this.walkCB2(K,W,X.child(),Q);Q()}walkCBSync(Z,J,X){if(this.signal?.aborted)X();this.walkCB2Sync(Z,J,new e3(this.opts),X)}walkCB2Sync(Z,J,X,Y){if(this.#$(Z))return Y();if(this.signal?.aborted)Y();if(this.paused){this.onResume(()=>this.walkCB2Sync(Z,J,X,Y));return}X.processPatterns(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,W,G)}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;$++;let W=K.readdirSync();this.walkCB3Sync(K,W,X,Q)}Q()}walkCB3Sync(Z,J,X,Y){X=X.filterEntries(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,W,G)}for(let[K,W]of X.subwalks.entries())$++,this.walkCB2Sync(K,W,X.child(),Q);Q()}}class uL extends OD{matches=new Set;constructor(Z,J,X){super(Z,J,X)}matchEmit(Z){this.matches.add(Z)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Z,J)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)J(this.signal.reason);else Z(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class dL extends OD{results;constructor(Z,J,X){super(Z,J,X);this.results=new BY({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(Z){if(this.results.write(Z),!this.results.flowing)this.pause()}stream(){let Z=this.path;if(Z.isUnknown())Z.lstat().then(()=>{this.walkCB(Z,this.patterns,()=>this.results.end())});else this.walkCB(Z,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var qB1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class W7{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Z,J){if(!J)throw new TypeError("glob options required");if(this.withFileTypes=!!J.withFileTypes,this.signal=J.signal,this.follow=!!J.follow,this.dot=!!J.dot,this.dotRelative=!!J.dotRelative,this.nodir=!!J.nodir,this.mark=!!J.mark,!J.cwd)this.cwd="";else if(J.cwd instanceof URL||J.cwd.startsWith("file://"))J.cwd=FB1(J.cwd);if(this.cwd=J.cwd||"",this.root=J.root,this.magicalBraces=!!J.magicalBraces,this.nobrace=!!J.nobrace,this.noext=!!J.noext,this.realpath=!!J.realpath,this.absolute=J.absolute,this.includeChildMatches=J.includeChildMatches!==!1,this.noglobstar=!!J.noglobstar,this.matchBase=!!J.matchBase,this.maxDepth=typeof J.maxDepth==="number"?J.maxDepth:1/0,this.stat=!!J.stat,this.ignore=J.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof Z==="string")Z=[Z];if(this.windowsPathsNoEscape=!!J.windowsPathsNoEscape||J.allowWindowsEscape===!1,this.windowsPathsNoEscape)Z=Z.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(J.noglobstar)throw new TypeError("base matching requires globstar");Z=Z.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Z,this.platform=J.platform||qB1,this.opts={...J,platform:this.platform},J.scurry){if(this.scurry=J.scurry,J.nocase!==void 0&&J.nocase!==J.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let W=J.platform==="win32"?o3:J.platform==="darwin"?mL:J.platform?r3:al;this.scurry=new W(this.cwd,{nocase:J.nocase,fs:J.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",Y={...J,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:X,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},$=this.pattern.map((W)=>new D9(W,Y)),[Q,K]=$.reduce((W,G)=>{return W[0].push(...G.set),W[1].push(...G.globParts),W},[[],[]]);this.patterns=Q.map((W,G)=>{let V=K[G];if(!V)throw new Error("invalid pattern object");return new KK(W,V,0,this.platform)})}async walk(){return[...await new uL(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new uL(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new dL(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new dL(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var ND=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new D9(X,J).hasMagic())return!0;return!1};function lL(Z,J={}){return new W7(Z,J).streamSync()}function tl(Z,J={}){return new W7(Z,J).stream()}function el(Z,J={}){return new W7(Z,J).walkSync()}async function rl(Z,J={}){return new W7(Z,J).walk()}function pL(Z,J={}){return new W7(Z,J).iterateSync()}function Zp(Z,J={}){return new W7(Z,J).iterate()}var UB1=lL,LB1=Object.assign(tl,{sync:lL}),BB1=pL,wB1=Object.assign(Zp,{sync:pL}),jB1=Object.assign(el,{stream:lL,iterate:pL}),cL=Object.assign(rl,{glob:rl,globSync:el,sync:jB1,globStream:tl,stream:LB1,globStreamSync:lL,streamSync:UB1,globIterate:Zp,iterate:wB1,globIterateSync:pL,iterateSync:BB1,Glob:W7,hasMagic:ND,escape:JK,unescape:L4});cL.glob=cL;class RD{constructor(){this._listeners={}}addEventListener(Z,J){let X=this._listeners;if(X[Z]===void 0)X[Z]=[];if(X[Z].indexOf(J)===-1)X[Z].push(J);return this}removeEventListener(Z,J){let Y=this._listeners[Z];if(Y!==void 0){let $=Y.indexOf(J);if($!==-1)Y.splice($,1)}return this}dispatchEvent(Z){let X=this._listeners[Z.type];if(X!==void 0){let Y=X.slice(0);for(let $=0,Q=Y.length;$<Q;$++)Y[$].call(this,Z)}return this}dispose(){for(let Z in this._listeners)delete this._listeners[Z]}}class M5{constructor(Z,J,X,Y={}){if(this._name=void 0,this._parent=void 0,this._child=void 0,this._attributes=void 0,this._disposed=!1,this._name=Z,this._parent=J,this._child=X,this._attributes=Y,!J.isOnGraph(X))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(Z){return this._child=Z,this}getAttributes(){return this._attributes}dispose(){if(this._disposed)return;this._parent._destroyRef(this),this._disposed=!0}isDisposed(){return this._disposed}}class WK extends RD{constructor(...Z){super(...Z);this._emptySet=new Set,this._edges=new Set,this._parentEdges=new Map,this._childEdges=new Map}listEdges(){return Array.from(this._edges)}listParentEdges(Z){return Array.from(this._childEdges.get(Z)||this._emptySet)}listParents(Z){let J=new Set;for(let X of this.listParentEdges(Z))J.add(X.getParent());return Array.from(J)}listChildEdges(Z){return Array.from(this._parentEdges.get(Z)||this._emptySet)}listChildren(Z){let J=new Set;for(let X of this.listChildEdges(Z))J.add(X.getChild());return Array.from(J)}disconnectParents(Z,J){for(let X of this.listParentEdges(Z))if(!J||J(X.getParent()))X.dispose();return this}_createEdge(Z,J,X,Y){let $=new M5(Z,J,X,Y);this._edges.add($);let Q=$.getParent();if(!this._parentEdges.has(Q))this._parentEdges.set(Q,new Set);this._parentEdges.get(Q).add($);let K=$.getChild();if(!this._childEdges.has(K))this._childEdges.set(K,new Set);return this._childEdges.get(K).add($),$}_destroyEdge(Z){return this._edges.delete(Z),this._parentEdges.get(Z.getParent()).delete(Z),this._childEdges.get(Z.getChild()).delete(Z),this}}function ZV(){return ZV=Object.assign||function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)if(Object.prototype.hasOwnProperty.call(X,Y))Z[Y]=X[Y]}return Z},ZV.apply(this,arguments)}class E6{constructor(Z){if(this.list=[],Z)for(let J of Z)this.list.push(J)}add(Z){this.list.push(Z)}remove(Z){let J=this.list.indexOf(Z);if(J>=0)this.list.splice(J,1)}removeChild(Z){let J=[];for(let X of this.list)if(X.getChild()===Z)J.push(X);for(let X of J)this.remove(X);return J}listRefsByChild(Z){let J=[];for(let X of this.list)if(X.getChild()===Z)J.push(X);return J}values(){return this.list}}class D0{constructor(Z){if(this.set=new Set,this.map=new Map,Z)for(let J of Z)this.add(J)}add(Z){let J=Z.getChild();this.removeChild(J),this.set.add(Z),this.map.set(J,Z)}remove(Z){this.set.delete(Z),this.map.delete(Z.getChild())}removeChild(Z){let J=this.map.get(Z)||null;if(J)this.remove(J);return J}getRefByChild(Z){return this.map.get(Z)||null}values(){return Array.from(this.set)}}class s1{constructor(Z){if(this.map={},Z)Object.assign(this.map,Z)}set(Z,J){this.map[Z]=J}delete(Z){delete this.map[Z]}get(Z){return this.map[Z]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}}var x0=Symbol("attributes"),j4=Symbol("immutableKeys");class GK extends RD{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[x0]=void 0,this[j4]=void 0,this.graph=Z,this[j4]=new Set,this[x0]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let Y=Z[X];if(Y instanceof GK){let $=this.graph._createEdge(X,this,Y);this[j4].add(X),J[X]=$}else J[X]=Y}return J}isOnGraph(Z){return this.graph===Z.graph}isDisposed(){return this._disposed}dispose(){if(this._disposed)return;this.graph.listChildEdges(this).forEach((Z)=>Z.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"})}detach(){return this.graph.disconnectParents(this),this}swap(Z,J){for(let X in this[x0]){let Y=this[x0][X];if(Y instanceof M5){let $=Y;if($.getChild()===Z)this.setRef(X,J,$.getAttributes())}else if(Y instanceof E6)for(let $ of Y.listRefsByChild(Z)){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if(Y instanceof D0){let $=Y.getRefByChild(Z);if($){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if(Y instanceof s1)for(let $ of Y.keys()){let Q=Y.get($);if(Q.getChild()===Z)this.setRefMap(X,$,J,Q.getAttributes())}}return this}get(Z){return this[x0][Z]}set(Z,J){return this[x0][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[x0][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[j4].has(Z))throw new Error(`Cannot overwrite immutable attribute, "${Z}".`);let Y=this[x0][Z];if(Y)Y.dispose();if(!J)return this;let $=this.graph._createEdge(Z,this,J,X);return this[x0][Z]=$,this.dispatchEvent({type:"change",attribute:Z})}listRefs(Z){return this.assertRefList(Z).values().map((X)=>X.getChild())}addRef(Z,J,X){let Y=this.graph._createEdge(Z,this,J,X);return this.assertRefList(Z).add(Y),this.dispatchEvent({type:"change",attribute:Z})}removeRef(Z,J){let X=this.assertRefList(Z);if(X instanceof E6)for(let Y of X.listRefsByChild(J))Y.dispose();else{let Y=X.getRefByChild(J);if(Y)Y.dispose()}return this}assertRefList(Z){let J=this[x0][Z];if(J instanceof E6||J instanceof D0)return J;throw new Error(`Expected RefList or RefSet for attribute "${Z}"`)}listRefMapKeys(Z){return this.assertRefMap(Z).keys()}listRefMapValues(Z){return this.assertRefMap(Z).values().map((J)=>J.getChild())}getRefMap(Z,J){let Y=this.assertRefMap(Z).get(J);return Y?Y.getChild():null}setRefMap(Z,J,X,Y){let $=this.assertRefMap(Z),Q=$.get(J);if(Q)Q.dispose();if(!X)return this;Y=Object.assign(Y||{},{key:J});let K=this.graph._createEdge(Z,this,X,ZV({},Y,{key:J}));return $.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[x0][Z];if(J instanceof s1)return J;throw new Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(ZV({},Z,{target:this})),this.graph.dispatchEvent(ZV({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[x0][J]===Z){if(this[x0][J]=null,this[j4].has(J))Z.getChild().dispose()}else if(this[x0][J]instanceof E6)this[x0][J].remove(Z);else if(this[x0][J]instanceof D0)this[x0][J].remove(Z);else if(this[x0][J]instanceof s1){let X=this[x0][J];for(let Y of X.keys())if(X.get(Y)===Z)X.delete(Y)}else return;this.graph._destroyEdge(Z),this.dispatchEvent({type:"change",attribute:J})}}var Wp="v4.1.1",rL="@glb.bin",a;(function(Z){Z.ACCESSOR="Accessor",Z.ANIMATION="Animation",Z.ANIMATION_CHANNEL="AnimationChannel",Z.ANIMATION_SAMPLER="AnimationSampler",Z.BUFFER="Buffer",Z.CAMERA="Camera",Z.MATERIAL="Material",Z.MESH="Mesh",Z.PRIMITIVE="Primitive",Z.PRIMITIVE_TARGET="PrimitiveTarget",Z.NODE="Node",Z.ROOT="Root",Z.SCENE="Scene",Z.SKIN="Skin",Z.TEXTURE="Texture",Z.TEXTURE_INFO="TextureInfo"})(a||(a={}));var tL;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(tL||(tL={}));var n5;(function(Z){Z.ARRAY_BUFFER="ARRAY_BUFFER",Z.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",Z.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",Z.OTHER="OTHER",Z.SPARSE="SPARSE"})(n5||(n5={}));var eL;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(eL||(eL={}));var UZ;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(UZ||(UZ={}));var kJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array},PD=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function OB1(){var Z=new PD(3);if(PD!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function MD(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function NB1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=X[3]*Y+X[7]*$+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*Y+X[4]*$+X[8]*Q+X[12])/K,Z[1]=(X[1]*Y+X[5]*$+X[9]*Q+X[13])/K,Z[2]=(X[2]*Y+X[6]*$+X[10]*Q+X[14])/K,Z}(function(){var Z=OB1();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=3;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();function ED(Z){let J=Gp(),X=Z.propertyType===a.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=RB1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))DD(K.min,J),DD(K.max,J)});return J}function RB1(Z,J){let X=Gp();for(let Y of Z.listPrimitives()){let $=Y.getAttribute("POSITION"),Q=Y.getIndices();if(!$)continue;let K=[0,0,0],W=[0,0,0];for(let G=0,V=Q?Q.getCount():$.getCount();G<V;G++){let H=Q?Q.getScalar(G):G;K=$.getElement(H,K),W=NB1(W,K,J),DD(W,X)}}return X}function DD(Z,J){for(let X=0;X<3;X++)J.min[X]=Math.min(Z[X],J.min[X]),J.max[X]=Math.max(Z[X],J.max[X])}function Gp(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class n0{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let Y=0;Y<J.length;Y++)X[Y]=J.charCodeAt(Y);return X}else{let J=Z.split(",")[1],X=Z.indexOf("base64")>=0;return Buffer.from(J,X?"base64":"utf8")}}static encodeText(Z){return new TextEncoder().encode(Z)}static decodeText(Z){return new TextDecoder().decode(Z)}static concat(Z){let J=0;for(let $ of Z)J+=$.byteLength;let X=new Uint8Array(J),Y=0;for(let $ of Z)X.set($,Y),Y+=$.byteLength;return X}static pad(Z,J=0){let X=this.padNumber(Z.byteLength);if(X===Z.byteLength)return Z;let Y=new Uint8Array(X);if(Y.set(Z),J!==0)for(let $=Z.byteLength;$<X;$++)Y[$]=J;return Y}static padNumber(Z){return Math.ceil(Z/4)*4}static equals(Z,J){if(Z===J)return!0;if(Z.byteLength!==J.byteLength)return!1;let X=Z.byteLength;while(X--)if(Z[X]!==J[X])return!1;return!0}static toView(Z,J=0,X=1/0){return new Uint8Array(Z.buffer,Z.byteOffset+J,Math.min(Z.byteLength,X))}static assertView(Z){if(Z&&!ArrayBuffer.isView(Z))throw new Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class kD{static hexToFactor(Z,J){Z=Math.floor(Z);let X=J;return X[0]=(Z>>16&255)/255,X[1]=(Z>>8&255)/255,X[2]=(Z&255)/255,this.convertSRGBToLinear(J,J)}static factorToHex(Z){let J=[...Z],[X,Y,$]=this.convertLinearToSRGB(Z,J);return X*255<<16^Y*255<<8^$*255<<0}static convertSRGBToLinear(Z,J){let X=Z,Y=J;for(let $=0;$<3;$++)Y[$]=X[$]<0.04045?X[$]*0.0773993808:Math.pow(X[$]*0.9478672986+0.0521327014,2.4);return J}static convertLinearToSRGB(Z,J){let X=Z,Y=J;for(let $=0;$<3;$++)Y[$]=X[$]<0.0031308?X[$]*12.92:1.055*Math.pow(X[$],0.41666)-0.055;return J}}class Vp{match(Z){return Z.length>=3&&Z[0]===255&&Z[1]===216&&Z[2]===255}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset+4),X,Y;while(J.byteLength){if(X=J.getUint16(0,!1),MB1(J,X),Y=J.getUint8(X+1),Y===192||Y===193||Y===194)return[J.getUint16(X+7,!1),J.getUint16(X+5,!1)];J=new DataView(Z.buffer,J.byteOffset+X+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class XB{match(Z){return Z.length>=8&&Z[0]===137&&Z[1]===80&&Z[2]===78&&Z[3]===71&&Z[4]===13&&Z[5]===10&&Z[6]===26&&Z[7]===10}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset);if(n0.decodeText(Z.slice(12,16))===XB.PNG_FRIED_CHUNK_NAME)return[J.getUint32(32,!1),J.getUint32(36,!1)];return[J.getUint32(16,!1),J.getUint32(20,!1)]}getChannels(Z){return 4}}XB.PNG_FRIED_CHUNK_NAME="CgBI";class LZ{static registerFormat(Z,J){this.impls[Z]=J}static getMimeType(Z){for(let J in this.impls)if(this.impls[J].match(Z))return J;return null}static getSize(Z,J){if(!this.impls[J])return null;return this.impls[J].getSize(Z)}static getChannels(Z,J){if(!this.impls[J])return null;return this.impls[J].getChannels(Z)}static getVRAMByteLength(Z,J){if(!this.impls[J])return null;if(this.impls[J].getVRAMByteLength)return this.impls[J].getVRAMByteLength(Z);let X=0,Y=4,$=this.getSize(Z,J);if(!$)return null;while($[0]>1||$[1]>1)X+=$[0]*$[1]*Y,$[0]=Math.max(Math.floor($[0]/2),1),$[1]=Math.max(Math.floor($[1]/2),1);return X+=1*Y,X}static mimeTypeToExtension(Z){if(Z==="image/jpeg")return"jpg";return Z.split("/").pop()}static extensionToMimeType(Z){if(Z==="jpg")return"image/jpeg";if(!Z)return"";return`image/${Z}`}}LZ.impls={"image/jpeg":new Vp,"image/png":new XB};function MB1(Z,J){if(J>Z.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return Z}class BZ{static basename(Z){let J=Z.split(/[\\/]/).pop();return J.substring(0,J.lastIndexOf("."))}static extension(Z){if(Z.startsWith("data:image/")){let J=Z.match(/data:(image\/\w+)/)[1];return LZ.mimeTypeToExtension(J)}else if(Z.startsWith("data:model/gltf+json"))return"gltf";else if(Z.startsWith("data:model/gltf-binary"))return"glb";else if(Z.startsWith("data:application/"))return"bin";return Z.split(/[\\/]/).pop().split(/[.]/).pop()}}function Jp(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function jY(Z){if(Jp(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(Jp(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var CD,JV;(function(Z){Z[Z.SILENT=4]="SILENT",Z[Z.ERROR=3]="ERROR",Z[Z.WARN=2]="WARN",Z[Z.INFO=1]="INFO",Z[Z.DEBUG=0]="DEBUG"})(JV||(JV={}));class D5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=D5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=D5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=D5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=D5.Verbosity.ERROR)console.error(Z)}}CD=D5;D5.Verbosity=JV;D5.DEFAULT_INSTANCE=new CD(CD.Verbosity.INFO);function PB1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],V=Z[8],H=Z[9],F=Z[10],z=Z[11],q=Z[12],U=Z[13],L=Z[14],B=Z[15],w=J*K-X*Q,O=J*W-Y*Q,N=J*G-$*Q,R=X*W-Y*K,D=X*G-$*K,M=Y*G-$*W,C=V*U-H*q,T=V*L-F*q,E=V*B-z*q,x=H*L-F*U,v=H*B-z*U,S=F*B-z*L;return w*S-O*v+N*x+R*E-D*T+M*C}function DB1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],V=J[6],H=J[7],F=J[8],z=J[9],q=J[10],U=J[11],L=J[12],B=J[13],w=J[14],O=J[15],N=X[0],R=X[1],D=X[2],M=X[3];return Z[0]=N*Y+R*W+D*F+M*L,Z[1]=N*$+R*G+D*z+M*B,Z[2]=N*Q+R*V+D*q+M*w,Z[3]=N*K+R*H+D*U+M*O,N=X[4],R=X[5],D=X[6],M=X[7],Z[4]=N*Y+R*W+D*F+M*L,Z[5]=N*$+R*G+D*z+M*B,Z[6]=N*Q+R*V+D*q+M*w,Z[7]=N*K+R*H+D*U+M*O,N=X[8],R=X[9],D=X[10],M=X[11],Z[8]=N*Y+R*W+D*F+M*L,Z[9]=N*$+R*G+D*z+M*B,Z[10]=N*Q+R*V+D*q+M*w,Z[11]=N*K+R*H+D*U+M*O,N=X[12],R=X[13],D=X[14],M=X[15],Z[12]=N*Y+R*W+D*F+M*L,Z[13]=N*$+R*G+D*z+M*B,Z[14]=N*Q+R*V+D*q+M*w,Z[15]=N*K+R*H+D*U+M*O,Z}function CB1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],V=J[9],H=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,V,H),Z}function TB1(Z,J){var X=new PD(3);CB1(X,J);var Y=1/X[0],$=1/X[1],Q=1/X[2],K=J[0]*Y,W=J[1]*$,G=J[2]*Q,V=J[4]*Y,H=J[5]*$,F=J[6]*Q,z=J[8]*Y,q=J[9]*$,U=J[10]*Q,L=K+H+U,B=0;if(L>0)B=Math.sqrt(L+1)*2,Z[3]=0.25*B,Z[0]=(F-q)/B,Z[1]=(z-G)/B,Z[2]=(W-V)/B;else if(K>H&&K>U)B=Math.sqrt(1+K-H-U)*2,Z[3]=(F-q)/B,Z[0]=0.25*B,Z[1]=(W+V)/B,Z[2]=(z+G)/B;else if(H>U)B=Math.sqrt(1+H-K-U)*2,Z[3]=(z-G)/B,Z[0]=(W+V)/B,Z[1]=0.25*B,Z[2]=(F+q)/B;else B=Math.sqrt(1+U-K-H)*2,Z[3]=(W-V)/B,Z[0]=(z+G)/B,Z[1]=(F+q)/B,Z[2]=0.25*B;return Z}class c0{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let Y=0;Y<Z.length;Y++)if(Math.abs(Z[Y]-J[Y])>X)return!1;return!0}static clamp(Z,J,X){if(Z<J)return J;if(Z>X)return X;return Z}static decodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Z/65535;case 5121:return Z/255;case 5122:return Math.max(Z/32767,-1);case 5120:return Math.max(Z/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(c0.clamp(Z,0,1)*65535);case 5121:return Math.round(c0.clamp(Z,0,1)*255);case 5122:return Math.round(c0.clamp(Z,-1,1)*32767);case 5120:return Math.round(c0.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,Y){let $=MD([Z[0],Z[1],Z[2]]),Q=MD([Z[4],Z[5],Z[6]]),K=MD([Z[8],Z[9],Z[10]]);if(PB1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),V=1/$,H=1/Q,F=1/K;G[0]*=V,G[1]*=V,G[2]*=V,G[4]*=H,G[5]*=H,G[6]*=H,G[8]*=F,G[9]*=F,G[10]*=F,TB1(X,G),Y[0]=$,Y[1]=Q,Y[2]=K}static compose(Z,J,X,Y){let $=Y,Q=J[0],K=J[1],W=J[2],G=J[3],V=Q+Q,H=K+K,F=W+W,z=Q*V,q=Q*H,U=Q*F,L=K*H,B=K*F,w=W*F,O=G*V,N=G*H,R=G*F,D=X[0],M=X[1],C=X[2];return $[0]=(1-(L+w))*D,$[1]=(q+R)*D,$[2]=(U-N)*D,$[3]=0,$[4]=(q-R)*M,$[5]=(1-(z+w))*M,$[6]=(B+O)*M,$[7]=0,$[8]=(U+N)*C,$[9]=(B-O)*C,$[10]=(1-(z+L))*C,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function EB1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function kB1(Z,J){if(!!Z!==!!J)return!1;let X=Z.values(),Y=J.values();if(X.length!==Y.length)return!1;for(let $=0;$<X.length;$++){let Q=X[$],K=Y[$];if(Q.getChild()===K.getChild())continue;if(!Q.getChild().equals(K.getChild()))return!1}return!0}function IB1(Z,J){if(!!Z!==!!J)return!1;let X=Z.keys(),Y=J.keys();if(X.length!==Y.length)return!1;for(let $ of X){let Q=Z.get($),K=J.get($);if(!!Q!==!!K)return!1;let W=Q.getChild(),G=K.getChild();if(W===G)continue;if(!W.equals(G))return!1}return!0}function Hp(Z,J){if(Z===J)return!0;if(!!Z!==!!J||!Z||!J)return!1;if(Z.length!==J.length)return!1;for(let X=0;X<Z.length;X++)if(Z[X]!==J[X])return!1;return!0}function zp(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!jY(Z)||!jY(J))return Z===J;let X=Z,Y=J,$=0,Q=0,K;for(K in X)$++;for(K in Y)Q++;if($!==Q)return!1;for(K in X){let W=X[K],G=Y[K];if(ZB(W)&&ZB(G)){if(!Hp(W,G))return!1}else if(jY(W)&&jY(G)){if(!zp(W,G))return!1}else if(W!==G)return!1}return!0}function ZB(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Xp="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",_B1=999,vB1=6,Yp=new Set,SB1=function Z(){let J="";for(let X=0;X<vB1;X++)J+=Xp.charAt(Math.floor(Math.random()*Xp.length));return J},Fp=function Z(){for(let J=0;J<_B1;J++){let X=SB1();if(!Yp.has(X))return Yp.add(X),X}return""},$p="https://null.example";class E9{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return BZ.basename(new URL(Z,$p).pathname)}static extension(Z){return BZ.extension(new URL(Z,$p).pathname)}static resolve(Z,J){if(!this.isRelativePath(J))return J;let X=Z.split("/"),Y=J.split("/");X.pop();for(let $=0;$<Y.length;$++){if(Y[$]===".")continue;if(Y[$]==="..")X.pop();else X.push(Y[$])}return X.join("/")}static isAbsoluteURL(Z){return this.PROTOCOL_REGEXP.test(Z)}static isRelativePath(Z){return!/^(?:[a-zA-Z]+:)?\//.test(Z)}}E9.DEFAULT_INIT={};E9.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var EJ=(Z)=>Z,AB1=new Set;class YB extends GK{constructor(Z,J=""){super(Z);this[x0].name=J,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(Z,J){if(Array.isArray(J))J=J.slice();return super.set(Z,J)}getName(){return this.get("name")}setName(Z){return this.set("name",Z)}getExtras(){return this.get("extras")}setExtras(Z){return this.set("extras",Z)}clone(){return new this.constructor(this.graph).copy(this,EJ)}copy(Z,J=EJ){for(let X in this[x0]){let Y=this[x0][X];if(Y instanceof M5){if(!this[j4].has(X))Y.dispose()}else if(Y instanceof E6||Y instanceof D0)for(let $ of Y.values())$.dispose();else if(Y instanceof s1)for(let $ of Y.values())$.dispose()}for(let X in Z[x0]){let Y=this[x0][X],$=Z[x0][X];if($ instanceof M5)if(this[j4].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof D0||$ instanceof E6)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof s1)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(jY($))this[x0][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[x0][X]=$.slice();else this[x0][X]=$}return this}equals(Z,J=AB1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[x0]){if(J.has(X))continue;let Y=this[x0][X],$=Z[x0][X];if(Y instanceof M5||$ instanceof M5){if(!EB1(Y,$))return!1}else if(Y instanceof D0||$ instanceof D0||Y instanceof E6||$ instanceof E6){if(!kB1(Y,$))return!1}else if(Y instanceof s1||$ instanceof s1){if(!IB1(Y,$))return!1}else if(jY(Y)||jY($)){if(!zp(Y,$))return!1}else if(ZB(Y)||ZB($)){if(!Hp(Y,$))return!1}else if(Y!==$)return!1}return!0}detach(){return this.graph.disconnectParents(this,(Z)=>Z.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}}class I6 extends YB{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new s1})}getExtension(Z){return this.getRefMap("extensions",Z)}setExtension(Z,J){if(J)J._validateParent(this);return this.setRefMap("extensions",Z,J)}listExtensions(){return this.listRefMapValues("extensions")}}class I0 extends I6{init(){this.propertyType=a.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:I0.Type.SCALAR,componentType:I0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case I0.Type.SCALAR:return 1;case I0.Type.VEC2:return 2;case I0.Type.VEC3:return 3;case I0.Type.VEC4:return 4;case I0.Type.MAT2:return 4;case I0.Type.MAT3:return 9;case I0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case I0.ComponentType.BYTE:return 1;case I0.ComponentType.UNSIGNED_BYTE:return 1;case I0.ComponentType.SHORT:return 2;case I0.ComponentType.UNSIGNED_SHORT:return 2;case I0.ComponentType.UNSIGNED_INT:return 4;case I0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMin(Z),J)for(let $=0;$<X;$++)Z[$]=c0.decodeNormalizedInt(Z[$],Y);return Z}getMin(Z){let J=this.getArray(),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+Q];if(Number.isFinite(K))Z[Q]=Math.min(Z[Q],K)}return Z}getMaxNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMax(Z),J)for(let $=0;$<X;$++)Z[$]=c0.decodeNormalizedInt(Z[$],Y);return Z}getMax(Z){let J=this.get("array"),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=-1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+Q];if(Number.isFinite(K))Z[Q]=Math.max(Z[Q],K)}return Z}getCount(){let Z=this.get("array");return Z?Z.length/this.getElementSize():0}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getElementSize(){return I0.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(Z){return this.set("normalized",Z)}getScalar(Z){let J=this.getElementSize(),X=this.getComponentType(),Y=this.getArray();if(this.getNormalized())return c0.decodeNormalizedInt(Y[Z*J],X);return Y[Z*J]}setScalar(Z,J){let X=this.getElementSize(),Y=this.getComponentType(),$=this.getArray();if(this.getNormalized())$[Z*X]=c0.encodeNormalizedInt(J,Y);else $[Z*X]=J;return this}getElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)J[K]=c0.decodeNormalizedInt(Q[Z*Y+K],$);else J[K]=Q[Z*Y+K];return J}setElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)Q[Z*Y+K]=c0.encodeNormalizedInt(J[K],$);else Q[Z*Y+K]=J[K];return this}getSparse(){return this.get("sparse")}setSparse(Z){return this.set("sparse",Z)}getBuffer(){return this.getRef("buffer")}setBuffer(Z){return this.setRef("buffer",Z)}getArray(){return this.get("array")}setArray(Z){return this.set("componentType",Z?xB1(Z):I0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}I0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};I0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function xB1(Z){switch(Z.constructor){case Float32Array:return I0.ComponentType.FLOAT;case Uint32Array:return I0.ComponentType.UNSIGNED_INT;case Uint16Array:return I0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return I0.ComponentType.UNSIGNED_BYTE;case Int16Array:return I0.ComponentType.SHORT;case Int8Array:return I0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class ID extends I6{init(){this.propertyType=a.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new D0,samplers:new D0})}addChannel(Z){return this.addRef("channels",Z)}removeChannel(Z){return this.removeRef("channels",Z)}listChannels(){return this.listRefs("channels")}addSampler(Z){return this.addRef("samplers",Z)}removeSampler(Z){return this.removeRef("samplers",Z)}listSamplers(){return this.listRefs("samplers")}}class OY extends I6{init(){this.propertyType=a.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(Z){return this.set("targetPath",Z)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(Z){return this.setRef("targetNode",Z)}getSampler(){return this.getRef("sampler")}setSampler(Z){return this.setRef("sampler",Z)}}OY.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class VK extends I6{init(){this.propertyType=a.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:VK.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(Z){return this.set("interpolation",Z)}getInput(){return this.getRef("input")}setInput(Z){return this.setRef("input",Z,{usage:n5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:n5.OTHER})}}VK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class _D extends I6{init(){this.propertyType=a.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class NY extends I6{init(){this.propertyType=a.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:NY.Type.PERSPECTIVE,znear:0.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getZNear(){return this.get("znear")}setZNear(Z){return this.set("znear",Z)}getZFar(){return this.get("zfar")}setZFar(Z){return this.set("zfar",Z)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(Z){return this.set("aspectRatio",Z)}getYFov(){return this.get("yfov")}setYFov(Z){return this.set("yfov",Z)}getXMag(){return this.get("xmag")}setXMag(Z){return this.set("xmag",Z)}getYMag(){return this.get("ymag")}setYMag(Z){return this.set("ymag",Z)}}NY.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class HK extends YB{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}HK.EXTENSION_NAME=void 0;class P5 extends I6{init(){this.propertyType=a.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:P5.WrapMode.REPEAT,wrapT:P5.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}getMagFilter(){return this.get("magFilter")}setMagFilter(Z){return this.set("magFilter",Z)}getMinFilter(){return this.get("minFilter")}setMinFilter(Z){return this.set("minFilter",Z)}getWrapS(){return this.get("wrapS")}setWrapS(Z){return this.set("wrapS",Z)}getWrapT(){return this.get("wrapT")}setWrapT(Z){return this.set("wrapT",Z)}}P5.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};P5.MagFilter={NEAREST:9728,LINEAR:9729};P5.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:iL,G:nL,B:aL,A:hB1}=eL;class G7 extends I6{init(){this.propertyType=a.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:G7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new P5(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new P5(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new P5(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new P5(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new P5(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(Z){return this.set("doubleSided",Z)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(Z){let J=this.get("baseColorFactor").slice();return J[3]=Z,this.set("baseColorFactor",J)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(Z){return this.set("alphaMode",Z)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(Z){return this.set("alphaCutoff",Z)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(Z){return this.set("baseColorFactor",Z)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(Z){return this.setRef("baseColorTexture",Z,{channels:iL|nL|aL|hB1,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(Z){return this.set("emissiveFactor",Z)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(Z){return this.setRef("emissiveTexture",Z,{channels:iL|nL|aL,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(Z){return this.set("normalScale",Z)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(Z){return this.setRef("normalTexture",Z,{channels:iL|nL|aL})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(Z){return this.set("occlusionStrength",Z)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(Z){return this.setRef("occlusionTexture",Z,{channels:iL})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(Z){return this.set("roughnessFactor",Z)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(Z){return this.set("metallicFactor",Z)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(Z){return this.setRef("metallicRoughnessTexture",Z,{channels:nL|aL})}}G7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class YV extends I6{init(){this.propertyType=a.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new D0})}addPrimitive(Z){return this.addRef("primitives",Z)}removePrimitive(Z){return this.removeRef("primitives",Z)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}}class $B extends I6{init(){this.propertyType=a.NODE}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new D0})}copy(Z,J=EJ){if(J===EJ)throw new Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return c0.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),Y=this.get("scale").slice();return c0.decompose(Z,J,X,Y),this.set("translation",J).set("rotation",X).set("scale",Y)}getWorldTranslation(){let Z=[0,0,0];return c0.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return c0.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return c0.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],Z),Z}getWorldMatrix(){let Z=[];for(let Y=this;Y!=null;Y=Y.getParentNode())Z.push(Y);let J,X=Z.pop().getMatrix();while(J=Z.pop())DB1(X,X,J.getMatrix());return X}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);for(let X of Z.listParents())if(X.propertyType===a.SCENE)X.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}getParentNode(){for(let Z of this.listParents())if(Z.propertyType===a.NODE)return Z;return null}getMesh(){return this.getRef("mesh")}setMesh(Z){return this.setRef("mesh",Z)}getCamera(){return this.getRef("camera")}setCamera(Z){return this.setRef("camera",Z)}getSkin(){return this.getRef("skin")}setSkin(Z){return this.setRef("skin",Z)}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}traverse(Z){Z(this);for(let J of this.listChildren())J.traverse(Z);return this}}class j8 extends I6{init(){this.propertyType=a.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:j8.Mode.TRIANGLES,material:null,indices:null,attributes:new s1,targets:new D0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:n5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:n5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(Z){return this.setRef("material",Z)}getMode(){return this.get("mode")}setMode(Z){return this.set("mode",Z)}listTargets(){return this.listRefs("targets")}addTarget(Z){return this.addRef("targets",Z)}removeTarget(Z){return this.removeRef("targets",Z)}}j8.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class vD extends YB{init(){this.propertyType=a.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new s1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:n5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function a6(){return a6=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},a6.apply(null,arguments)}class zK extends I6{init(){this.propertyType=a.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new D0})}copy(Z,J=EJ){if(J===EJ)throw new Error("Scene cannot be copied.");return super.copy(Z,J)}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}traverse(Z){for(let J of this.listChildren())J.traverse(Z);return this}}class SD extends I6{init(){this.propertyType=a.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new D0})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(Z){return this.setRef("skeleton",Z)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(Z){return this.setRef("inverseBindMatrices",Z,{usage:n5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class RY extends I6{init(){this.propertyType=a.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||LZ.extensionToMimeType(BZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=LZ.extensionToMimeType(BZ.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",n0.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return LZ.getSize(Z,this.getMimeType())}}class MY extends I6{init(){this.propertyType=a.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Wp}`,version:"2.0"},defaultScene:null,accessors:new D0,animations:new D0,buffers:new D0,cameras:new D0,materials:new D0,meshes:new D0,nodes:new D0,scenes:new D0,skins:new D0,textures:new D0})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(Z,J=EJ){if(J===EJ)throw new Error("Root cannot be copied.");this.set("asset",a6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(a6({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let Y=Z.getExtension(X);this.setExtension(X,J(Y))}return this}_addChildOfRoot(Z){if(Z instanceof zK)this.addRef("scenes",Z);else if(Z instanceof $B)this.addRef("nodes",Z);else if(Z instanceof NY)this.addRef("cameras",Z);else if(Z instanceof SD)this.addRef("skins",Z);else if(Z instanceof YV)this.addRef("meshes",Z);else if(Z instanceof G7)this.addRef("materials",Z);else if(Z instanceof RY)this.addRef("textures",Z);else if(Z instanceof ID)this.addRef("animations",Z);else if(Z instanceof I0)this.addRef("accessors",Z);else if(Z instanceof _D)this.addRef("buffers",Z);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((Z)=>Z.isRequired())}_enableExtension(Z){return this._extensions.add(Z),this}_disableExtension(Z){return this._extensions.delete(Z),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(Z){return this.setRef("defaultScene",Z)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class k6{static fromGraph(Z){return k6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new WK,this._root=new MY(this._graph),this._logger=D5.DEFAULT_INSTANCE,k6._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(Z){return this._logger=Z,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...Z){let J=Z.map((X)=>X.name);for(let X of Z)await X(this,{stack:J});return this}createExtension(Z){let J=Z.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find((Y)=>Y.extensionName===J)||new Z(this)}createScene(Z=""){return new zK(this._graph,Z)}createNode(Z=""){return new $B(this._graph,Z)}createCamera(Z=""){return new NY(this._graph,Z)}createSkin(Z=""){return new SD(this._graph,Z)}createMesh(Z=""){return new YV(this._graph,Z)}createPrimitive(){return new j8(this._graph)}createPrimitiveTarget(Z=""){return new vD(this._graph,Z)}createMaterial(Z=""){return new G7(this._graph,Z)}createTexture(Z=""){return new RY(this._graph,Z)}createAnimation(Z=""){return new ID(this._graph,Z)}createAnimationChannel(Z=""){return new OY(this._graph,Z)}createAnimationSampler(Z=""){return new VK(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new I0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new _D(this._graph,Z)}}k6._GRAPH_DOCUMENTS=new WeakMap;class qp{constructor(Z){this.extensionName="",this.prereadTypes=[],this.prewriteTypes=[],this.readDependencies=[],this.writeDependencies=[],this.document=void 0,this.required=!1,this.properties=new Set,this._listener=void 0,this.document=Z,Z.getRoot()._enableExtension(this),this._listener=(X)=>{let Y=X,$=Y.target;if($ instanceof HK&&$.extensionName===this.extensionName){if(Y.type==="node:create")this._addExtensionProperty($);if(Y.type==="node:dispose")this._removeExtensionProperty($)}};let J=Z.getGraph();J.addEventListener("node:create",this._listener),J.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);let Z=this.document.getGraph();Z.removeEventListener("node:create",this._listener),Z.removeEventListener("node:dispose",this._listener);for(let J of this.properties)J.dispose()}static register(){}isRequired(){return this.required}setRequired(Z){return this.required=Z,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(Z){return this.properties.add(Z),this}_removeExtensionProperty(Z){return this.properties.delete(Z),this}install(Z,J){return this}preread(Z,J){return this}prewrite(Z,J){return this}}qp.EXTENSION_NAME=void 0;class Up{constructor(Z){this.jsonDoc=void 0,this.buffers=[],this.bufferViews=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.textureInfos=new Map,this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[],this.jsonDoc=Z}setTextureInfo(Z,J){if(this.textureInfos.set(Z,J),J.texCoord!==void 0)Z.setTexCoord(J.texCoord);if(J.extras!==void 0)Z.setExtras(J.extras);let X=this.jsonDoc.json.textures[J.index];if(X.sampler===void 0)return;let Y=this.jsonDoc.json.samplers[X.sampler];if(Y.magFilter!==void 0)Z.setMagFilter(Y.magFilter);if(Y.minFilter!==void 0)Z.setMinFilter(Y.minFilter);if(Y.wrapS!==void 0)Z.setWrapS(Y.wrapS);if(Y.wrapT!==void 0)Z.setWrapT(Y.wrapT)}}var Qp={logger:D5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},fB1=new Set([a.BUFFER,a.TEXTURE,a.MATERIAL,a.MESH,a.PRIMITIVE,a.NODE,a.SCENE]);class Lp{static read(Z,J=Qp){let X=a6({},Qp,J),{json:Y}=Z,$=new k6().setLogger(X.logger);this.validate(Z,X);let Q=new Up(Z),K=Y.asset,W=$.getRoot().getAsset();if(K.copyright)W.copyright=K.copyright;if(K.extras)W.extras=K.extras;if(Y.extras!==void 0)$.getRoot().setExtras(a6({},Y.extras));let G=Y.extensionsUsed||[],V=Y.extensionsRequired||[];X.extensions.sort((M,C)=>M.EXTENSION_NAME>C.EXTENSION_NAME?1:-1);for(let M of X.extensions)if(G.includes(M.EXTENSION_NAME)){let C=$.createExtension(M).setRequired(V.includes(M.EXTENSION_NAME)),T=C.prereadTypes.filter((E)=>!fB1.has(E));if(T.length)X.logger.warn(`Preread hooks for some types (${T.join()}), requested by extension ${C.extensionName}, are unsupported. Please file an issue or a PR.`);for(let E of C.readDependencies)C.install(E,X.dependencies[E])}let H=Y.buffers||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.BUFFER)).forEach((M)=>M.preread(Q,a.BUFFER)),Q.buffers=H.map((M)=>{let C=$.createBuffer(M.name);if(M.extras)C.setExtras(M.extras);if(M.uri&&M.uri.indexOf("__")!==0)C.setURI(M.uri);return C});let F=Y.bufferViews||[];Q.bufferViewBuffers=F.map((M,C)=>{if(!Q.bufferViews[C]){let T=Z.json.buffers[M.buffer],E=T.uri?Z.resources[T.uri]:Z.resources[rL],x=M.byteOffset||0;Q.bufferViews[C]=n0.toView(E,x,M.byteLength)}return Q.buffers[M.buffer]});let z=Y.accessors||[];Q.accessors=z.map((M)=>{let C=Q.bufferViewBuffers[M.bufferView],T=$.createAccessor(M.name,C).setType(M.type);if(M.extras)T.setExtras(M.extras);if(M.normalized!==void 0)T.setNormalized(M.normalized);if(M.bufferView===void 0)return T;return T.setArray(oL(M,Q)),T});let q=Y.images||[],U=Y.textures||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.TEXTURE)).forEach((M)=>M.preread(Q,a.TEXTURE)),Q.textures=q.map((M)=>{let C=$.createTexture(M.name);if(M.extras)C.setExtras(M.extras);if(M.bufferView!==void 0){let T=Y.bufferViews[M.bufferView],E=Z.json.buffers[T.buffer],x=E.uri?Z.resources[E.uri]:Z.resources[rL],v=T.byteOffset||0,S=T.byteLength,I=x.slice(v,v+S);C.setImage(I)}else if(M.uri!==void 0){if(C.setImage(Z.resources[M.uri]),M.uri.indexOf("__")!==0)C.setURI(M.uri)}if(M.mimeType!==void 0)C.setMimeType(M.mimeType);else if(M.uri){let T=BZ.extension(M.uri);C.setMimeType(LZ.extensionToMimeType(T))}return C}),$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.MATERIAL)).forEach((M)=>M.preread(Q,a.MATERIAL));let L=Y.materials||[];Q.materials=L.map((M)=>{let C=$.createMaterial(M.name);if(M.extras)C.setExtras(M.extras);if(M.alphaMode!==void 0)C.setAlphaMode(M.alphaMode);if(M.alphaCutoff!==void 0)C.setAlphaCutoff(M.alphaCutoff);if(M.doubleSided!==void 0)C.setDoubleSided(M.doubleSided);let T=M.pbrMetallicRoughness||{};if(T.baseColorFactor!==void 0)C.setBaseColorFactor(T.baseColorFactor);if(M.emissiveFactor!==void 0)C.setEmissiveFactor(M.emissiveFactor);if(T.metallicFactor!==void 0)C.setMetallicFactor(T.metallicFactor);if(T.roughnessFactor!==void 0)C.setRoughnessFactor(T.roughnessFactor);if(T.baseColorTexture!==void 0){let E=T.baseColorTexture,x=Q.textures[U[E.index].source];C.setBaseColorTexture(x),Q.setTextureInfo(C.getBaseColorTextureInfo(),E)}if(M.emissiveTexture!==void 0){let E=M.emissiveTexture,x=Q.textures[U[E.index].source];C.setEmissiveTexture(x),Q.setTextureInfo(C.getEmissiveTextureInfo(),E)}if(M.normalTexture!==void 0){let E=M.normalTexture,x=Q.textures[U[E.index].source];if(C.setNormalTexture(x),Q.setTextureInfo(C.getNormalTextureInfo(),E),M.normalTexture.scale!==void 0)C.setNormalScale(M.normalTexture.scale)}if(M.occlusionTexture!==void 0){let E=M.occlusionTexture,x=Q.textures[U[E.index].source];if(C.setOcclusionTexture(x),Q.setTextureInfo(C.getOcclusionTextureInfo(),E),M.occlusionTexture.strength!==void 0)C.setOcclusionStrength(M.occlusionTexture.strength)}if(T.metallicRoughnessTexture!==void 0){let E=T.metallicRoughnessTexture,x=Q.textures[U[E.index].source];C.setMetallicRoughnessTexture(x),Q.setTextureInfo(C.getMetallicRoughnessTextureInfo(),E)}return C}),$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.MESH)).forEach((M)=>M.preread(Q,a.MESH));let B=Y.meshes||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.PRIMITIVE)).forEach((M)=>M.preread(Q,a.PRIMITIVE)),Q.meshes=B.map((M)=>{let C=$.createMesh(M.name);if(M.extras)C.setExtras(M.extras);if(M.weights!==void 0)C.setWeights(M.weights);return(M.primitives||[]).forEach((E)=>{let x=$.createPrimitive();if(E.extras)x.setExtras(E.extras);if(E.material!==void 0)x.setMaterial(Q.materials[E.material]);if(E.mode!==void 0)x.setMode(E.mode);for(let[I,_]of Object.entries(E.attributes||{}))x.setAttribute(I,Q.accessors[_]);if(E.indices!==void 0)x.setIndices(Q.accessors[E.indices]);let v=M.extras&&M.extras.targetNames||[];(E.targets||[]).forEach((I,_)=>{let y=v[_]||_.toString(),p=$.createPrimitiveTarget(y);for(let[n,o]of Object.entries(I))p.setAttribute(n,Q.accessors[o]);x.addTarget(p)}),C.addPrimitive(x)}),C});let w=Y.cameras||[];Q.cameras=w.map((M)=>{let C=$.createCamera(M.name).setType(M.type);if(M.extras)C.setExtras(M.extras);if(M.type===NY.Type.PERSPECTIVE){let T=M.perspective;if(C.setYFov(T.yfov),C.setZNear(T.znear),T.zfar!==void 0)C.setZFar(T.zfar);if(T.aspectRatio!==void 0)C.setAspectRatio(T.aspectRatio)}else{let T=M.orthographic;C.setZNear(T.znear).setZFar(T.zfar).setXMag(T.xmag).setYMag(T.ymag)}return C});let O=Y.nodes||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.NODE)).forEach((M)=>M.preread(Q,a.NODE)),Q.nodes=O.map((M)=>{let C=$.createNode(M.name);if(M.extras)C.setExtras(M.extras);if(M.translation!==void 0)C.setTranslation(M.translation);if(M.rotation!==void 0)C.setRotation(M.rotation);if(M.scale!==void 0)C.setScale(M.scale);if(M.matrix!==void 0){let T=[0,0,0],E=[0,0,0,1],x=[1,1,1];c0.decompose(M.matrix,T,E,x),C.setTranslation(T),C.setRotation(E),C.setScale(x)}if(M.weights!==void 0)C.setWeights(M.weights);return C});let N=Y.skins||[];Q.skins=N.map((M)=>{let C=$.createSkin(M.name);if(M.extras)C.setExtras(M.extras);if(M.inverseBindMatrices!==void 0)C.setInverseBindMatrices(Q.accessors[M.inverseBindMatrices]);if(M.skeleton!==void 0)C.setSkeleton(Q.nodes[M.skeleton]);for(let T of M.joints)C.addJoint(Q.nodes[T]);return C}),O.map((M,C)=>{let T=Q.nodes[C];if((M.children||[]).forEach((x)=>T.addChild(Q.nodes[x])),M.mesh!==void 0)T.setMesh(Q.meshes[M.mesh]);if(M.camera!==void 0)T.setCamera(Q.cameras[M.camera]);if(M.skin!==void 0)T.setSkin(Q.skins[M.skin])});let R=Y.animations||[];Q.animations=R.map((M)=>{let C=$.createAnimation(M.name);if(M.extras)C.setExtras(M.extras);let E=(M.samplers||[]).map((v)=>{let S=$.createAnimationSampler().setInput(Q.accessors[v.input]).setOutput(Q.accessors[v.output]).setInterpolation(v.interpolation||VK.Interpolation.LINEAR);if(v.extras)S.setExtras(v.extras);return C.addSampler(S),S});return(M.channels||[]).forEach((v)=>{let S=$.createAnimationChannel().setSampler(E[v.sampler]).setTargetPath(v.target.path);if(v.target.node!==void 0)S.setTargetNode(Q.nodes[v.target.node]);if(v.extras)S.setExtras(v.extras);C.addChannel(S)}),C});let D=Y.scenes||[];if($.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.SCENE)).forEach((M)=>M.preread(Q,a.SCENE)),Q.scenes=D.map((M)=>{let C=$.createScene(M.name);if(M.extras)C.setExtras(M.extras);return(M.nodes||[]).map((E)=>Q.nodes[E]).forEach((E)=>C.addChild(E)),C}),Y.scene!==void 0)$.getRoot().setDefaultScene(Q.scenes[Y.scene]);return $.getRoot().listExtensionsUsed().forEach((M)=>M.read(Q)),z.forEach((M,C)=>{let T=Q.accessors[C],E=!!M.sparse,x=!M.bufferView&&!T.getArray();if(E||x)T.setSparse(!0).setArray(bB1(M,Q))}),$}static validate(Z,J){let X=Z.json;if(X.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${X.asset.version}".`);if(X.extensionsRequired){for(let Y of X.extensionsRequired)if(!J.extensions.find(($)=>$.EXTENSION_NAME===Y))throw new Error(`Missing required extension, "${Y}".`)}if(X.extensionsUsed){for(let Y of X.extensionsUsed)if(!J.extensions.find(($)=>$.EXTENSION_NAME===Y))J.logger.warn(`Missing optional extension, "${Y}".`)}}}function yB1(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=kJ[Z.componentType],K=I0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=Z.byteOffset||0,V=new Q(Z.count*K),H=new DataView(Y.buffer,Y.byteOffset,Y.byteLength),F=$.byteStride;for(let z=0;z<Z.count;z++)for(let q=0;q<K;q++){let U=G+z*F+q*W,L;switch(Z.componentType){case I0.ComponentType.FLOAT:L=H.getFloat32(U,!0);break;case I0.ComponentType.UNSIGNED_INT:L=H.getUint32(U,!0);break;case I0.ComponentType.UNSIGNED_SHORT:L=H.getUint16(U,!0);break;case I0.ComponentType.UNSIGNED_BYTE:L=H.getUint8(U);break;case I0.ComponentType.SHORT:L=H.getInt16(U,!0);break;case I0.ComponentType.BYTE:L=H.getInt8(U);break;default:throw new Error(`Unexpected componentType "${Z.componentType}".`)}V[z*K+q]=L}return V}function oL(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=kJ[Z.componentType],K=I0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if($.byteStride!==void 0&&$.byteStride!==G)return yB1(Z,J);let V=Y.byteOffset+(Z.byteOffset||0),H=Z.count*K*W;return new Q(Y.buffer.slice(V,V+H))}function bB1(Z,J){let X=kJ[Z.componentType],Y=I0.getElementSize(Z.type),$;if(Z.bufferView!==void 0)$=oL(Z,J);else $=new X(Z.count*Y);let Q=Z.sparse;if(!Q)return $;let K=Q.count,W=a6({},Z,Q.indices,{count:K,type:"SCALAR"}),G=a6({},Z,Q.values,{count:K}),V=oL(W,J),H=oL(G,J);for(let F=0;F<W.count;F++)for(let z=0;z<Y;z++)$[V[F]*Y+z]=H[F*Y+z];return $}var XV;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(XV||(XV={}));class TJ{constructor(Z,J,X){this._doc=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this._accessorUsageMap=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this._doc=Z,this.jsonDoc=J,this.options=X;let Y=Z.getRoot(),$=Y.listBuffers().length,Q=Y.listTextures().length;this.bufferURIGenerator=new TD($>1,()=>X.basename||"buffer"),this.imageURIGenerator=new TD(Q>1,(K)=>gB1(Z,K)||X.basename||"texture"),this.logger=Z.getLogger()}createTextureInfoDef(Z,J){let X={magFilter:J.getMagFilter()||void 0,minFilter:J.getMinFilter()||void 0,wrapS:J.getWrapS(),wrapT:J.getWrapT()},Y=JSON.stringify(X);if(!this.samplerDefIndexMap.has(Y))this.samplerDefIndexMap.set(Y,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(X);let $={source:this.imageIndexMap.get(Z),sampler:this.samplerDefIndexMap.get(Y)},Q=JSON.stringify($);if(!this.textureDefIndexMap.has(Q))this.textureDefIndexMap.set(Q,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push($);let K={index:this.textureDefIndexMap.get(Q)};if(J.getTexCoord()!==0)K.texCoord=J.getTexCoord();if(Object.keys(J.getExtras()).length>0)K.extras=J.getExtras();return this.textureInfoDefMap.set(J,K),K}createPropertyDef(Z){let J={};if(Z.getName())J.name=Z.getName();if(Object.keys(Z.getExtras()).length>0)J.extras=Z.getExtras();return J}createAccessorDef(Z){let J=this.createPropertyDef(Z);if(J.type=Z.getType(),J.componentType=Z.getComponentType(),J.count=Z.getCount(),this._doc.getGraph().listParentEdges(Z).some((Y)=>Y.getName()==="attributes"&&Y.getAttributes().key==="POSITION"||Y.getName()==="input"))J.max=Z.getMax([]).map(Math.fround),J.min=Z.getMin([]).map(Math.fround);if(Z.getNormalized())J.normalized=Z.getNormalized();return J}createImageData(Z,J,X){if(this.options.format===UZ.GLB)this.imageBufferViews.push(J),Z.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:J.byteLength});else{let Y=LZ.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,Y),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let Y=this.jsonDoc.resources;if(!(Z in Y)){Y[Z]=J;return}if(J===Y[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let $=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn($);return}throw new Error($)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return n5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:Y}=X.getAttributes();if(Y)return Y;if(X.getParent().propertyType!==a.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return n5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw new Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}TJ.BufferViewTarget=XV;TJ.BufferViewUsage=n5;TJ.USAGE_TO_TARGET={[n5.ARRAY_BUFFER]:XV.ARRAY_BUFFER,[n5.ELEMENT_ARRAY_BUFFER]:XV.ELEMENT_ARRAY_BUFFER};class TD{constructor(Z,J){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=Z,this.basename=J}createURI(Z,J){if(Z.getURI())return Z.getURI();else if(!this.multiple)return`${this.basename(Z)}.${J}`;else{let X=this.basename(Z);return this.counter[X]=this.counter[X]||1,`${X}_${this.counter[X]++}.${J}`}}}function gB1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:sL}=TJ,{UNSIGNED_INT:mB1,UNSIGNED_SHORT:uB1,UNSIGNED_BYTE:dB1}=I0.ComponentType,cB1=new Set([a.ACCESSOR,a.BUFFER,a.MATERIAL,a.MESH]);class Bp{static write(Z,J){let X=Z.getGraph(),Y=Z.getRoot(),$={asset:a6({generator:`glTF-Transform ${Wp}`},Y.getAsset()),extras:a6({},Y.getExtras())},Q={json:$,resources:{}},K=new TJ(Z,Q,J),W=J.logger||D5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((B)=>B.EXTENSION_NAME)),V=Z.getRoot().listExtensionsUsed().filter((B)=>G.has(B.extensionName)).sort((B,w)=>B.extensionName>w.extensionName?1:-1),H=Z.getRoot().listExtensionsRequired().filter((B)=>G.has(B.extensionName)).sort((B,w)=>B.extensionName>w.extensionName?1:-1);if(V.length<Z.getRoot().listExtensionsUsed().length)W.warn("Some extensions were not registered for I/O, and will not be written.");for(let B of V){let w=B.prewriteTypes.filter((O)=>!cB1.has(O));if(w.length)W.warn(`Prewrite hooks for some types (${w.join()}), requested by extension ${B.extensionName}, are unsupported. Please file an issue or a PR.`);for(let O of B.writeDependencies)B.install(O,J.dependencies[O])}function F(B,w,O,N){let R=[],D=0;for(let T of B){let E=K.createAccessorDef(T);E.bufferView=$.bufferViews.length;let x=T.getArray(),v=n0.pad(n0.toView(x));E.byteOffset=D,D+=v.byteLength,R.push(v),K.accessorIndexMap.set(T,$.accessors.length),$.accessors.push(E)}let M=n0.concat(R),C={buffer:w,byteOffset:O,byteLength:M.byteLength};if(N)C.target=N;return $.bufferViews.push(C),{buffers:R,byteLength:D}}function z(B,w,O){let N=B[0].getCount(),R=0;for(let E of B){let x=K.createAccessorDef(E);x.bufferView=$.bufferViews.length,x.byteOffset=R;let v=E.getElementSize(),S=E.getComponentSize();R+=n0.padNumber(v*S),K.accessorIndexMap.set(E,$.accessors.length),$.accessors.push(x)}let D=N*R,M=new ArrayBuffer(D),C=new DataView(M);for(let E=0;E<N;E++){let x=0;for(let v of B){let S=v.getElementSize(),I=v.getComponentSize(),_=v.getComponentType(),y=v.getArray();for(let p=0;p<S;p++){let n=E*R+x+p*I,o=y[E*S+p];switch(_){case I0.ComponentType.FLOAT:C.setFloat32(n,o,!0);break;case I0.ComponentType.BYTE:C.setInt8(n,o);break;case I0.ComponentType.SHORT:C.setInt16(n,o,!0);break;case I0.ComponentType.UNSIGNED_BYTE:C.setUint8(n,o);break;case I0.ComponentType.UNSIGNED_SHORT:C.setUint16(n,o,!0);break;case I0.ComponentType.UNSIGNED_INT:C.setUint32(n,o,!0);break;default:throw new Error("Unexpected component type: "+_)}}x+=n0.padNumber(S*I)}}let T={buffer:w,byteOffset:O,byteLength:D,byteStride:R,target:TJ.BufferViewTarget.ARRAY_BUFFER};return $.bufferViews.push(T),{byteLength:D,buffers:[new Uint8Array(M)]}}function q(B,w,O){let N=[],R=0,D=new Map,M=-1/0,C=!1;for(let _ of B){let y=K.createAccessorDef(_);$.accessors.push(y),K.accessorIndexMap.set(_,$.accessors.length-1);let p=[],n=[],o=[],X0=new Array(_.getElementSize()).fill(0);for(let a0=0,k8=_.getCount();a0<k8;a0++){if(_.getElement(a0,o),c0.eq(o,X0,0))continue;M=Math.max(a0,M),p.push(a0);for(let n1=0;n1<o.length;n1++)n.push(o[n1])}let Q0=p.length,E0={accessorDef:y,count:Q0};if(D.set(_,E0),Q0===0)continue;if(Q0>_.getCount()/2)C=!0;let k0=kJ[_.getComponentType()];E0.indices=p,E0.values=new k0(n)}if(!Number.isFinite(M))return{buffers:N,byteLength:R};if(C)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let T=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,E=M<255?dB1:M<65535?uB1:mB1,x={buffer:w,byteOffset:O+R,byteLength:0};for(let _ of B){let y=D.get(_);if(y.count===0)continue;y.indicesByteOffset=x.byteLength;let p=n0.pad(n0.toView(new T(y.indices)));N.push(p),R+=p.byteLength,x.byteLength+=p.byteLength}$.bufferViews.push(x);let v=$.bufferViews.length-1,S={buffer:w,byteOffset:O+R,byteLength:0};for(let _ of B){let y=D.get(_);if(y.count===0)continue;y.valuesByteOffset=S.byteLength;let p=n0.pad(n0.toView(y.values));N.push(p),R+=p.byteLength,S.byteLength+=p.byteLength}$.bufferViews.push(S);let I=$.bufferViews.length-1;for(let _ of B){let y=D.get(_);if(y.count===0)continue;y.accessorDef.sparse={count:y.count,indices:{bufferView:v,byteOffset:y.indicesByteOffset,componentType:E},values:{bufferView:I,byteOffset:y.valuesByteOffset}}}return{buffers:N,byteLength:R}}if($.accessors=[],$.bufferViews=[],$.samplers=[],$.textures=[],$.images=Y.listTextures().map((B,w)=>{let O=K.createPropertyDef(B);if(B.getMimeType())O.mimeType=B.getMimeType();let N=B.getImage();if(N)K.createImageData(O,N,B);return K.imageIndexMap.set(B,w),O}),V.filter((B)=>B.prewriteTypes.includes(a.ACCESSOR)).forEach((B)=>B.prewrite(K,a.ACCESSOR)),Y.listAccessors().forEach((B)=>{let{accessorUsageGroupedByParent:w,accessorParents:O}=K;if(K.accessorIndexMap.has(B))return;let N=K.getAccessorUsage(B);if(K.addAccessorToUsageGroup(B,N),w.has(N)){let R=X.listParents(B).find((D)=>D.propertyType!==a.ROOT);O.set(B,R)}}),V.filter((B)=>B.prewriteTypes.includes(a.BUFFER)).forEach((B)=>B.prewrite(K,a.BUFFER)),(Y.listAccessors().length>0||K.otherBufferViews.size>0||Y.listTextures().length>0&&J.format===UZ.GLB)&&Y.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");if($.buffers=[],Y.listBuffers().forEach((B,w)=>{let O=K.createPropertyDef(B),N=K.accessorUsageGroupedByParent,R=B.listParents().filter((S)=>S instanceof I0),D=new Set(R.map((S)=>K.accessorParents.get(S))),M=new Map(Array.from(D).map((S,I)=>[S,I])),C={};for(let S of R){var T;if(K.accessorIndexMap.has(S))continue;let I=K.getAccessorUsage(S),_=I;if(N.has(I)){let y=K.accessorParents.get(S);_+=`:${M.get(y)}`}C[T=_]||(C[T]={usage:I,accessors:[]}),C[_].accessors.push(S)}let E=[],x=$.buffers.length,v=0;for(let{usage:S,accessors:I}of Object.values(C))if(S===sL.ARRAY_BUFFER&&J.vertexLayout===tL.INTERLEAVED){let _=z(I,x,v);v+=_.byteLength;for(let y of _.buffers)E.push(y)}else if(S===sL.ARRAY_BUFFER)for(let _ of I){let y=z([_],x,v);v+=y.byteLength;for(let p of y.buffers)E.push(p)}else if(S===sL.SPARSE){let _=q(I,x,v);v+=_.byteLength;for(let y of _.buffers)E.push(y)}else if(S===sL.ELEMENT_ARRAY_BUFFER){let _=TJ.BufferViewTarget.ELEMENT_ARRAY_BUFFER,y=F(I,x,v,_);v+=y.byteLength;for(let p of y.buffers)E.push(p)}else{let _=F(I,x,v);v+=_.byteLength;for(let y of _.buffers)E.push(y)}if(K.imageBufferViews.length&&w===0){for(let S=0;S<K.imageBufferViews.length;S++)if($.bufferViews[$.images[S].bufferView].byteOffset=v,v+=K.imageBufferViews[S].byteLength,E.push(K.imageBufferViews[S]),v%8){let I=8-v%8;v+=I,E.push(new Uint8Array(I))}}if(K.otherBufferViews.has(B))for(let S of K.otherBufferViews.get(B))$.bufferViews.push({buffer:x,byteOffset:v,byteLength:S.byteLength}),K.otherBufferViewsIndexMap.set(S,$.bufferViews.length-1),v+=S.byteLength,E.push(S);if(v){let S;if(J.format===UZ.GLB)S=rL;else S=K.bufferURIGenerator.createURI(B,"bin"),O.uri=S;O.byteLength=v,K.assignResourceURI(S,n0.concat(E),!0)}$.buffers.push(O),K.bufferIndexMap.set(B,w)}),Y.listAccessors().find((B)=>!B.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");V.filter((B)=>B.prewriteTypes.includes(a.MATERIAL)).forEach((B)=>B.prewrite(K,a.MATERIAL)),$.materials=Y.listMaterials().map((B,w)=>{let O=K.createPropertyDef(B);if(B.getAlphaMode()!==G7.AlphaMode.OPAQUE)O.alphaMode=B.getAlphaMode();if(B.getAlphaMode()===G7.AlphaMode.MASK)O.alphaCutoff=B.getAlphaCutoff();if(B.getDoubleSided())O.doubleSided=!0;if(O.pbrMetallicRoughness={},!c0.eq(B.getBaseColorFactor(),[1,1,1,1]))O.pbrMetallicRoughness.baseColorFactor=B.getBaseColorFactor();if(!c0.eq(B.getEmissiveFactor(),[0,0,0]))O.emissiveFactor=B.getEmissiveFactor();if(B.getRoughnessFactor()!==1)O.pbrMetallicRoughness.roughnessFactor=B.getRoughnessFactor();if(B.getMetallicFactor()!==1)O.pbrMetallicRoughness.metallicFactor=B.getMetallicFactor();if(B.getBaseColorTexture()){let N=B.getBaseColorTexture(),R=B.getBaseColorTextureInfo();O.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(N,R)}if(B.getEmissiveTexture()){let N=B.getEmissiveTexture(),R=B.getEmissiveTextureInfo();O.emissiveTexture=K.createTextureInfoDef(N,R)}if(B.getNormalTexture()){let N=B.getNormalTexture(),R=B.getNormalTextureInfo(),D=K.createTextureInfoDef(N,R);if(B.getNormalScale()!==1)D.scale=B.getNormalScale();O.normalTexture=D}if(B.getOcclusionTexture()){let N=B.getOcclusionTexture(),R=B.getOcclusionTextureInfo(),D=K.createTextureInfoDef(N,R);if(B.getOcclusionStrength()!==1)D.strength=B.getOcclusionStrength();O.occlusionTexture=D}if(B.getMetallicRoughnessTexture()){let N=B.getMetallicRoughnessTexture(),R=B.getMetallicRoughnessTextureInfo();O.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(N,R)}return K.materialIndexMap.set(B,w),O}),V.filter((B)=>B.prewriteTypes.includes(a.MESH)).forEach((B)=>B.prewrite(K,a.MESH)),$.meshes=Y.listMeshes().map((B,w)=>{let O=K.createPropertyDef(B),N=null;if(O.primitives=B.listPrimitives().map((R)=>{let D={attributes:{}};D.mode=R.getMode();let M=R.getMaterial();if(M)D.material=K.materialIndexMap.get(M);if(Object.keys(R.getExtras()).length)D.extras=R.getExtras();let C=R.getIndices();if(C)D.indices=K.accessorIndexMap.get(C);for(let T of R.listSemantics())D.attributes[T]=K.accessorIndexMap.get(R.getAttribute(T));for(let T of R.listTargets()){let E={};for(let x of T.listSemantics())E[x]=K.accessorIndexMap.get(T.getAttribute(x));D.targets=D.targets||[],D.targets.push(E)}if(R.listTargets().length&&!N)N=R.listTargets().map((T)=>T.getName());return D}),B.getWeights().length)O.weights=B.getWeights();if(N)O.extras=O.extras||{},O.extras.targetNames=N;return K.meshIndexMap.set(B,w),O}),$.cameras=Y.listCameras().map((B,w)=>{let O=K.createPropertyDef(B);if(O.type=B.getType(),O.type===NY.Type.PERSPECTIVE){O.perspective={znear:B.getZNear(),zfar:B.getZFar(),yfov:B.getYFov()};let N=B.getAspectRatio();if(N!==null)O.perspective.aspectRatio=N}else O.orthographic={znear:B.getZNear(),zfar:B.getZFar(),xmag:B.getXMag(),ymag:B.getYMag()};return K.cameraIndexMap.set(B,w),O}),$.nodes=Y.listNodes().map((B,w)=>{let O=K.createPropertyDef(B);if(!c0.eq(B.getTranslation(),[0,0,0]))O.translation=B.getTranslation();if(!c0.eq(B.getRotation(),[0,0,0,1]))O.rotation=B.getRotation();if(!c0.eq(B.getScale(),[1,1,1]))O.scale=B.getScale();if(B.getWeights().length)O.weights=B.getWeights();return K.nodeIndexMap.set(B,w),O}),$.skins=Y.listSkins().map((B,w)=>{let O=K.createPropertyDef(B),N=B.getInverseBindMatrices();if(N)O.inverseBindMatrices=K.accessorIndexMap.get(N);let R=B.getSkeleton();if(R)O.skeleton=K.nodeIndexMap.get(R);return O.joints=B.listJoints().map((D)=>K.nodeIndexMap.get(D)),K.skinIndexMap.set(B,w),O}),Y.listNodes().forEach((B,w)=>{let O=$.nodes[w],N=B.getMesh();if(N)O.mesh=K.meshIndexMap.get(N);let R=B.getCamera();if(R)O.camera=K.cameraIndexMap.get(R);let D=B.getSkin();if(D)O.skin=K.skinIndexMap.get(D);if(B.listChildren().length>0)O.children=B.listChildren().map((M)=>K.nodeIndexMap.get(M))}),$.animations=Y.listAnimations().map((B,w)=>{let O=K.createPropertyDef(B),N=new Map;return O.samplers=B.listSamplers().map((R,D)=>{let M=K.createPropertyDef(R);return M.input=K.accessorIndexMap.get(R.getInput()),M.output=K.accessorIndexMap.get(R.getOutput()),M.interpolation=R.getInterpolation(),N.set(R,D),M}),O.channels=B.listChannels().map((R)=>{let D=K.createPropertyDef(R);return D.sampler=N.get(R.getSampler()),D.target={node:K.nodeIndexMap.get(R.getTargetNode()),path:R.getTargetPath()},D}),K.animationIndexMap.set(B,w),O}),$.scenes=Y.listScenes().map((B,w)=>{let O=K.createPropertyDef(B);return O.nodes=B.listChildren().map((N)=>K.nodeIndexMap.get(N)),K.sceneIndexMap.set(B,w),O});let L=Y.getDefaultScene();if(L)$.scene=Y.listScenes().indexOf(L);return $.extensionsUsed=V.map((B)=>B.extensionName),$.extensionsRequired=H.map((B)=>B.extensionName),V.forEach((B)=>B.write(K)),lB1($),Q}}function lB1(Z){let J=[];for(let X in Z){let Y=Z[X];if(Array.isArray(Y)&&Y.length===0)J.push(X);else if(Y===null||Y==="")J.push(X);else if(Y&&typeof Y==="object"&&Object.keys(Y).length===0)J.push(X)}for(let X of J)delete Z[X]}var JB;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(JB||(JB={}));class wp{constructor(){this._logger=D5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=tL.INTERLEAVED,this.lastReadBytes=0,this.lastWriteBytes=0}setLogger(Z){return this._logger=Z,this}registerExtensions(Z){for(let J of Z)this._extensions.add(J),J.register();return this}registerDependencies(Z){return Object.assign(this._dependencies,Z),this}setVertexLayout(Z){return this._vertexLayout=Z,this}async read(Z){return await this.readJSON(await this.readAsJSON(Z))}async readAsJSON(Z){let J=await this.readURI(Z,"view");this.lastReadBytes=J.byteLength;let X=Kp(J)?this._binaryToJSON(J):{json:JSON.parse(n0.decodeText(J)),resources:{}};return await this._readResourcesExternal(X,this.dirname(Z)),this._readResourcesInternal(X),X}async readJSON(Z){return Z=this._copyJSON(Z),this._readResourcesInternal(Z),Lp.read(Z,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(Z){let J=this._binaryToJSON(n0.assertView(Z));this._readResourcesInternal(J);let X=J.json;if(X.buffers&&X.buffers.some((Y)=>pB1(J,Y)))throw new Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some((Y)=>iB1(J,Y)))throw new Error("Cannot resolve external images with binaryToJSON().");return J}async readBinary(Z){return this.readJSON(await this.binaryToJSON(n0.assertView(Z)))}async writeJSON(Z,J={}){if(J.format===UZ.GLB&&Z.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Bp.write(Z,{format:J.format||UZ.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:a6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:UZ.GLB}),Y=new Uint32Array([1179937895,2,12]),$=JSON.stringify(J),Q=n0.pad(n0.encodeText($),32),K=n0.toView(new Uint32Array([Q.byteLength,1313821514])),W=n0.concat([K,Q]);Y[Y.length-1]+=W.byteLength;let G=Object.values(X)[0];if(!G||!G.byteLength)return n0.concat([n0.toView(Y),W]);let V=n0.pad(G,0),H=n0.toView(new Uint32Array([V.byteLength,5130562])),F=n0.concat([H,V]);return Y[Y.length-1]+=F.byteLength,n0.concat([n0.toView(Y),W,F])}async _readResourcesExternal(Z,J){var X=this;let Y=Z.json.images||[],$=Z.json.buffers||[],Q=[...Y,...$].map(async function(K){let W=K.uri;if(!W||W.match(/data:/))return Promise.resolve();Z.resources[W]=await X.readURI(X.resolve(J,W),"view"),X.lastReadBytes+=Z.resources[W].byteLength});await Promise.all(Q)}_readResourcesInternal(Z){function J($){if(!$.uri)return;if($.uri in Z.resources){n0.assertView(Z.resources[$.uri]);return}if($.uri.match(/data:/)){let Q=`__${Fp()}.${BZ.extension($.uri)}`;Z.resources[Q]=n0.createBufferFromDataURI($.uri),$.uri=Q}}(Z.json.images||[]).forEach(($)=>{if($.bufferView===void 0&&$.uri===void 0)throw new Error("Missing resource URI or buffer view.");J($)}),(Z.json.buffers||[]).forEach(J)}_copyJSON(Z){let{images:J,buffers:X}=Z.json;if(Z={json:a6({},Z.json),resources:a6({},Z.resources)},J)Z.json.images=J.map((Y)=>a6({},Y));if(X)Z.json.buffers=X.map((Y)=>a6({},Y));return Z}_binaryToJSON(Z){if(!Kp(Z))throw new Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==JB.JSON)throw new Error("Missing required GLB JSON chunk.");let X=20,Y=J[0],$=n0.decodeText(n0.toView(Z,X,Y)),Q=JSON.parse($),K=X+Y;if(Z.byteLength<=K)return{json:Q,resources:{}};let W=new Uint32Array(Z.buffer,Z.byteOffset+K,2);if(W[1]!==JB.BIN)return{json:Q,resources:{}};let G=W[0],V=n0.toView(Z,K+8,G);return{json:Q,resources:{[rL]:V}}}}function pB1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function iB1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function Kp(Z){if(Z.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;let J=new Uint32Array(Z.buffer,Z.byteOffset,3);return J[0]===1179937895&&J[1]===2}class AD extends wp{constructor(Z=null,J=E9.DEFAULT_INIT){super();this._fetch=void 0,this._fetchConfig=void 0,this._init=void 0,this._fetchEnabled=!1,this._fetch=Z,this._fetchConfig=J,this._init=this.init()}async init(){if(this._init)return this._init;return Promise.all([import("fs"),import("path")]).then(([Z,J])=>{this._fs=Z.promises,this._path=J})}setAllowNetwork(Z){if(Z&&!this._fetch)throw new Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=Z,this}async readURI(Z,J){if(await this.init(),E9.isAbsoluteURL(Z)){if(!this._fetchEnabled||!this._fetch)throw new Error("Network request blocked. Allow HTTP requests explicitly, if needed.");let X=await this._fetch(Z,this._fetchConfig);switch(J){case"view":return new Uint8Array(await X.arrayBuffer());case"text":return X.text()}}else switch(J){case"view":return this._fs.readFile(Z);case"text":return this._fs.readFile(Z,"utf8")}}resolve(Z,J){if(E9.isAbsoluteURL(Z)||E9.isAbsoluteURL(J))return E9.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(E9.isAbsoluteURL(Z))return E9.dirname(Z);return this._path.dirname(Z)}async write(Z,J){await this.init(),await(!!Z.match(/\.glb$/)?this._writeGLB(Z,J):this._writeGLTF(Z,J))}async _writeGLTF(Z,J){var X=this;this.lastWriteBytes=0;let{json:Y,resources:$}=await this.writeJSON(J,{format:UZ.GLTF,basename:BZ.basename(Z)}),{_fs:Q,_path:K}=this,W=K.dirname(Z),G=JSON.stringify(Y,null,2);await Q.writeFile(Z,G),this.lastWriteBytes+=G.length;for(let V of nB1(Object.keys($),10))await Promise.all(V.map(async function(H){if(E9.isAbsoluteURL(H)){if(E9.extension(H)==="bin")throw new Error(`Cannot write buffer to path "${H}".`);return}let F=K.join(W,decodeURIComponent(H));await Q.mkdir(K.dirname(F),{recursive:!0}),await Q.writeFile(F,$[H]),X.lastWriteBytes+=$[H].byteLength}))}async _writeGLB(Z,J){let X=await this.writeBinary(J);await this._fs.writeFile(Z,X),this.lastWriteBytes=X.byteLength}}function nB1(Z,J){let X=[];for(let Y=0,$=Z.length;Y<$;Y+=J){let Q=[];for(let K=0;K<J&&Y+K<$;K++)Q.push(Z[Y+K]);X.push(Q)}return X}var Ua=r(xD(),1),La=r(rn(),1),bN1=r(qa(),1);async function gN1(Z,J){if(!(Z instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:Y}=await La.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return Ua.default(new Uint8Array(X),[Y.width,Y.height,4],[4,4*Y.width|0,1],0)}async function Ba(Z,J){return gN1(Z)}var mN1="v4.1.3",FC="@glb.bin",s;(function(Z){Z.ACCESSOR="Accessor",Z.ANIMATION="Animation",Z.ANIMATION_CHANNEL="AnimationChannel",Z.ANIMATION_SAMPLER="AnimationSampler",Z.BUFFER="Buffer",Z.CAMERA="Camera",Z.MATERIAL="Material",Z.MESH="Mesh",Z.PRIMITIVE="Primitive",Z.PRIMITIVE_TARGET="PrimitiveTarget",Z.NODE="Node",Z.ROOT="Root",Z.SCENE="Scene",Z.SKIN="Skin",Z.TEXTURE="Texture",Z.TEXTURE_INFO="TextureInfo"})(s||(s={}));var wa;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(wa||(wa={}));var o5;(function(Z){Z.ARRAY_BUFFER="ARRAY_BUFFER",Z.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",Z.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",Z.OTHER="OTHER",Z.SPARSE="SPARSE"})(o5||(o5={}));var r5;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(r5||(r5={}));var KC;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(KC||(KC={}));var WC=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function uN1(){var Z=new WC(3);if(WC!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function QC(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function dN1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=X[3]*Y+X[7]*$+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*Y+X[4]*$+X[8]*Q+X[12])/K,Z[1]=(X[1]*Y+X[5]*$+X[9]*Q+X[13])/K,Z[2]=(X[2]*Y+X[6]*$+X[10]*Q+X[14])/K,Z}(function(){var Z=uN1();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=3;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();function Ra(Z){let J=Ma(),X=Z.propertyType===s.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=cN1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))GC(K.min,J),GC(K.max,J)});return J}function cN1(Z,J){let X=Ma();for(let Y of Z.listPrimitives()){let $=Y.getAttribute("POSITION"),Q=Y.getIndices();if(!$)continue;let K=[0,0,0],W=[0,0,0];for(let G=0,V=Q?Q.getCount():$.getCount();G<V;G++){let H=Q?Q.getScalar(G):G;K=$.getElement(H,K),W=dN1(W,K,J),GC(W,X)}}return X}function GC(Z,J){for(let X=0;X<3;X++)J.min[X]=Math.min(Z[X],J.min[X]),J.max[X]=Math.max(Z[X],J.max[X])}function Ma(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class _6{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let Y=0;Y<J.length;Y++)X[Y]=J.charCodeAt(Y);return X}else{let J=Z.split(",")[1],X=Z.indexOf("base64")>=0;return Buffer.from(J,X?"base64":"utf8")}}static encodeText(Z){return new TextEncoder().encode(Z)}static decodeText(Z){return new TextDecoder().decode(Z)}static concat(Z){let J=0;for(let $ of Z)J+=$.byteLength;let X=new Uint8Array(J),Y=0;for(let $ of Z)X.set($,Y),Y+=$.byteLength;return X}static pad(Z,J=0){let X=this.padNumber(Z.byteLength);if(X===Z.byteLength)return Z;let Y=new Uint8Array(X);if(Y.set(Z),J!==0)for(let $=Z.byteLength;$<X;$++)Y[$]=J;return Y}static padNumber(Z){return Math.ceil(Z/4)*4}static equals(Z,J){if(Z===J)return!0;if(Z.byteLength!==J.byteLength)return!1;let X=Z.byteLength;while(X--)if(Z[X]!==J[X])return!1;return!0}static toView(Z,J=0,X=1/0){return new Uint8Array(Z.buffer,Z.byteOffset+J,Math.min(Z.byteLength,X))}static assertView(Z){if(Z&&!ArrayBuffer.isView(Z))throw new Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class Pa{match(Z){return Z.length>=3&&Z[0]===255&&Z[1]===216&&Z[2]===255}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset+4),X,Y;while(J.byteLength){if(X=J.getUint16(0,!1),lN1(J,X),Y=J.getUint8(X+1),Y===192||Y===193||Y===194)return[J.getUint16(X+7,!1),J.getUint16(X+5,!1)];J=new DataView(Z.buffer,J.byteOffset+X+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class AB{match(Z){return Z.length>=8&&Z[0]===137&&Z[1]===80&&Z[2]===78&&Z[3]===71&&Z[4]===13&&Z[5]===10&&Z[6]===26&&Z[7]===10}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset);if(_6.decodeText(Z.slice(12,16))===AB.PNG_FRIED_CHUNK_NAME)return[J.getUint32(32,!1),J.getUint32(36,!1)];return[J.getUint32(16,!1),J.getUint32(20,!1)]}getChannels(Z){return 4}}AB.PNG_FRIED_CHUNK_NAME="CgBI";class N4{static registerFormat(Z,J){this.impls[Z]=J}static getMimeType(Z){for(let J in this.impls)if(this.impls[J].match(Z))return J;return null}static getSize(Z,J){if(!this.impls[J])return null;return this.impls[J].getSize(Z)}static getChannels(Z,J){if(!this.impls[J])return null;return this.impls[J].getChannels(Z)}static getVRAMByteLength(Z,J){if(!this.impls[J])return null;if(this.impls[J].getVRAMByteLength)return this.impls[J].getVRAMByteLength(Z);let X=0,Y=4,$=this.getSize(Z,J);if(!$)return null;while($[0]>1||$[1]>1)X+=$[0]*$[1]*Y,$[0]=Math.max(Math.floor($[0]/2),1),$[1]=Math.max(Math.floor($[1]/2),1);return X+=1*Y,X}static mimeTypeToExtension(Z){if(Z==="image/jpeg")return"jpg";return Z.split("/").pop()}static extensionToMimeType(Z){if(Z==="jpg")return"image/jpeg";if(!Z)return"";return`image/${Z}`}}N4.impls={"image/jpeg":new Pa,"image/png":new AB};function lN1(Z,J){if(J>Z.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return Z}class qV{static basename(Z){let J=Z.split(/[\\/]/).pop();return J.substring(0,J.lastIndexOf("."))}static extension(Z){if(Z.startsWith("data:image/")){let J=Z.match(/data:(image\/\w+)/)[1];return N4.mimeTypeToExtension(J)}else if(Z.startsWith("data:model/gltf+json"))return"gltf";else if(Z.startsWith("data:model/gltf-binary"))return"glb";else if(Z.startsWith("data:application/"))return"bin";return Z.split(/[\\/]/).pop().split(/[.]/).pop()}}function ja(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function TY(Z){if(ja(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(ja(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var VC,HC;(function(Z){Z[Z.SILENT=4]="SILENT",Z[Z.ERROR=3]="ERROR",Z[Z.WARN=2]="WARN",Z[Z.INFO=1]="INFO",Z[Z.DEBUG=0]="DEBUG"})(HC||(HC={}));class U7{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=U7.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=U7.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=U7.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=U7.Verbosity.ERROR)console.error(Z)}}VC=U7;U7.Verbosity=HC;U7.DEFAULT_INSTANCE=new VC(VC.Verbosity.INFO);function pN1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],V=Z[8],H=Z[9],F=Z[10],z=Z[11],q=Z[12],U=Z[13],L=Z[14],B=Z[15],w=J*K-X*Q,O=J*W-Y*Q,N=J*G-$*Q,R=X*W-Y*K,D=X*G-$*K,M=Y*G-$*W,C=V*U-H*q,T=V*L-F*q,E=V*B-z*q,x=H*L-F*U,v=H*B-z*U,S=F*B-z*L;return w*S-O*v+N*x+R*E-D*T+M*C}function iN1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],V=J[6],H=J[7],F=J[8],z=J[9],q=J[10],U=J[11],L=J[12],B=J[13],w=J[14],O=J[15],N=X[0],R=X[1],D=X[2],M=X[3];return Z[0]=N*Y+R*W+D*F+M*L,Z[1]=N*$+R*G+D*z+M*B,Z[2]=N*Q+R*V+D*q+M*w,Z[3]=N*K+R*H+D*U+M*O,N=X[4],R=X[5],D=X[6],M=X[7],Z[4]=N*Y+R*W+D*F+M*L,Z[5]=N*$+R*G+D*z+M*B,Z[6]=N*Q+R*V+D*q+M*w,Z[7]=N*K+R*H+D*U+M*O,N=X[8],R=X[9],D=X[10],M=X[11],Z[8]=N*Y+R*W+D*F+M*L,Z[9]=N*$+R*G+D*z+M*B,Z[10]=N*Q+R*V+D*q+M*w,Z[11]=N*K+R*H+D*U+M*O,N=X[12],R=X[13],D=X[14],M=X[15],Z[12]=N*Y+R*W+D*F+M*L,Z[13]=N*$+R*G+D*z+M*B,Z[14]=N*Q+R*V+D*q+M*w,Z[15]=N*K+R*H+D*U+M*O,Z}function nN1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],V=J[9],H=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,V,H),Z}function aN1(Z,J){var X=new WC(3);nN1(X,J);var Y=1/X[0],$=1/X[1],Q=1/X[2],K=J[0]*Y,W=J[1]*$,G=J[2]*Q,V=J[4]*Y,H=J[5]*$,F=J[6]*Q,z=J[8]*Y,q=J[9]*$,U=J[10]*Q,L=K+H+U,B=0;if(L>0)B=Math.sqrt(L+1)*2,Z[3]=0.25*B,Z[0]=(F-q)/B,Z[1]=(z-G)/B,Z[2]=(W-V)/B;else if(K>H&&K>U)B=Math.sqrt(1+K-H-U)*2,Z[3]=(F-q)/B,Z[0]=0.25*B,Z[1]=(W+V)/B,Z[2]=(z+G)/B;else if(H>U)B=Math.sqrt(1+H-K-U)*2,Z[3]=(z-G)/B,Z[0]=(W+V)/B,Z[1]=0.25*B,Z[2]=(F+q)/B;else B=Math.sqrt(1+U-K-H)*2,Z[3]=(W-V)/B,Z[0]=(z+G)/B,Z[1]=(F+q)/B,Z[2]=0.25*B;return Z}class K8{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let Y=0;Y<Z.length;Y++)if(Math.abs(Z[Y]-J[Y])>X)return!1;return!0}static clamp(Z,J,X){if(Z<J)return J;if(Z>X)return X;return Z}static decodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Z/65535;case 5121:return Z/255;case 5122:return Math.max(Z/32767,-1);case 5120:return Math.max(Z/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(K8.clamp(Z,0,1)*65535);case 5121:return Math.round(K8.clamp(Z,0,1)*255);case 5122:return Math.round(K8.clamp(Z,-1,1)*32767);case 5120:return Math.round(K8.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,Y){let $=QC([Z[0],Z[1],Z[2]]),Q=QC([Z[4],Z[5],Z[6]]),K=QC([Z[8],Z[9],Z[10]]);if(pN1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),V=1/$,H=1/Q,F=1/K;G[0]*=V,G[1]*=V,G[2]*=V,G[4]*=H,G[5]*=H,G[6]*=H,G[8]*=F,G[9]*=F,G[10]*=F,aN1(X,G),Y[0]=$,Y[1]=Q,Y[2]=K}static compose(Z,J,X,Y){let $=Y,Q=J[0],K=J[1],W=J[2],G=J[3],V=Q+Q,H=K+K,F=W+W,z=Q*V,q=Q*H,U=Q*F,L=K*H,B=K*F,w=W*F,O=G*V,N=G*H,R=G*F,D=X[0],M=X[1],C=X[2];return $[0]=(1-(L+w))*D,$[1]=(q+R)*D,$[2]=(U-N)*D,$[3]=0,$[4]=(q-R)*M,$[5]=(1-(z+w))*M,$[6]=(B+O)*M,$[7]=0,$[8]=(U+N)*C,$[9]=(B-O)*C,$[10]=(1-(z+L))*C,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function sN1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function oN1(Z,J){if(!!Z!==!!J)return!1;let X=Z.values(),Y=J.values();if(X.length!==Y.length)return!1;for(let $=0;$<X.length;$++){let Q=X[$],K=Y[$];if(Q.getChild()===K.getChild())continue;if(!Q.getChild().equals(K.getChild()))return!1}return!0}function rN1(Z,J){if(!!Z!==!!J)return!1;let X=Z.keys(),Y=J.keys();if(X.length!==Y.length)return!1;for(let $ of X){let Q=Z.get($),K=J.get($);if(!!Q!==!!K)return!1;let W=Q.getChild(),G=K.getChild();if(W===G)continue;if(!W.equals(G))return!1}return!0}function Da(Z,J){if(Z===J)return!0;if(!!Z!==!!J||!Z||!J)return!1;if(Z.length!==J.length)return!1;for(let X=0;X<Z.length;X++)if(Z[X]!==J[X])return!1;return!0}function Ca(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!TY(Z)||!TY(J))return Z===J;let X=Z,Y=J,$=0,Q=0,K;for(K in X)$++;for(K in Y)Q++;if($!==Q)return!1;for(K in X){let W=X[K],G=Y[K];if(_B(W)&&_B(G)){if(!Da(W,G))return!1}else if(TY(W)&&TY(G)){if(!Ca(W,G))return!1}else if(W!==G)return!1}return!0}function _B(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Oa="https://null.example";class qC{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return qV.basename(new URL(Z,Oa).pathname)}static extension(Z){return qV.extension(new URL(Z,Oa).pathname)}static resolve(Z,J){if(!this.isRelativePath(J))return J;let X=Z.split("/"),Y=J.split("/");X.pop();for(let $=0;$<Y.length;$++){if(Y[$]===".")continue;if(Y[$]==="..")X.pop();else X.push(Y[$])}return X.join("/")}static isAbsoluteURL(Z){return this.PROTOCOL_REGEXP.test(Z)}static isRelativePath(Z){return!/^(?:[a-zA-Z]+:)?\//.test(Z)}}qC.DEFAULT_INIT={};qC.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var xJ=(Z)=>Z,tN1=new Set;class xB extends GK{constructor(Z,J=""){super(Z);this[x0].name=J,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(Z,J){if(Array.isArray(J))J=J.slice();return super.set(Z,J)}getName(){return this.get("name")}setName(Z){return this.set("name",Z)}getExtras(){return this.get("extras")}setExtras(Z){return this.set("extras",Z)}clone(){return new this.constructor(this.graph).copy(this,xJ)}copy(Z,J=xJ){for(let X in this[x0]){let Y=this[x0][X];if(Y instanceof M5){if(!this[j4].has(X))Y.dispose()}else if(Y instanceof E6||Y instanceof D0)for(let $ of Y.values())$.dispose();else if(Y instanceof s1)for(let $ of Y.values())$.dispose()}for(let X in Z[x0]){let Y=this[x0][X],$=Z[x0][X];if($ instanceof M5)if(this[j4].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof D0||$ instanceof E6)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof s1)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(TY($))this[x0][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[x0][X]=$.slice();else this[x0][X]=$}return this}equals(Z,J=tN1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[x0]){if(J.has(X))continue;let Y=this[x0][X],$=Z[x0][X];if(Y instanceof M5||$ instanceof M5){if(!sN1(Y,$))return!1}else if(Y instanceof D0||$ instanceof D0||Y instanceof E6||$ instanceof E6){if(!oN1(Y,$))return!1}else if(Y instanceof s1||$ instanceof s1){if(!rN1(Y,$))return!1}else if(TY(Y)||TY($)){if(!Ca(Y,$))return!1}else if(_B(Y)||_B($)){if(!Da(Y,$))return!1}else if(Y!==$)return!1}return!0}detach(){return this.graph.disconnectParents(this,(Z)=>Z.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}}class v6 extends xB{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new s1})}getExtension(Z){return this.getRefMap("extensions",Z)}setExtension(Z,J){if(J)J._validateParent(this);return this.setRefMap("extensions",Z,J)}listExtensions(){return this.listRefMapValues("extensions")}}class N0 extends v6{init(){this.propertyType=s.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:N0.Type.SCALAR,componentType:N0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case N0.Type.SCALAR:return 1;case N0.Type.VEC2:return 2;case N0.Type.VEC3:return 3;case N0.Type.VEC4:return 4;case N0.Type.MAT2:return 4;case N0.Type.MAT3:return 9;case N0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case N0.ComponentType.BYTE:return 1;case N0.ComponentType.UNSIGNED_BYTE:return 1;case N0.ComponentType.SHORT:return 2;case N0.ComponentType.UNSIGNED_SHORT:return 2;case N0.ComponentType.UNSIGNED_INT:return 4;case N0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMin(Z),J)for(let $=0;$<X;$++)Z[$]=K8.decodeNormalizedInt(Z[$],Y);return Z}getMin(Z){let J=this.getArray(),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+Q];if(Number.isFinite(K))Z[Q]=Math.min(Z[Q],K)}return Z}getMaxNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMax(Z),J)for(let $=0;$<X;$++)Z[$]=K8.decodeNormalizedInt(Z[$],Y);return Z}getMax(Z){let J=this.get("array"),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=-1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+Q];if(Number.isFinite(K))Z[Q]=Math.max(Z[Q],K)}return Z}getCount(){let Z=this.get("array");return Z?Z.length/this.getElementSize():0}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getElementSize(){return N0.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(Z){return this.set("normalized",Z)}getScalar(Z){let J=this.getElementSize(),X=this.getComponentType(),Y=this.getArray();if(this.getNormalized())return K8.decodeNormalizedInt(Y[Z*J],X);return Y[Z*J]}setScalar(Z,J){let X=this.getElementSize(),Y=this.getComponentType(),$=this.getArray();if(this.getNormalized())$[Z*X]=K8.encodeNormalizedInt(J,Y);else $[Z*X]=J;return this}getElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)J[K]=K8.decodeNormalizedInt(Q[Z*Y+K],$);else J[K]=Q[Z*Y+K];return J}setElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)Q[Z*Y+K]=K8.encodeNormalizedInt(J[K],$);else Q[Z*Y+K]=J[K];return this}getSparse(){return this.get("sparse")}setSparse(Z){return this.set("sparse",Z)}getBuffer(){return this.getRef("buffer")}setBuffer(Z){return this.setRef("buffer",Z)}getArray(){return this.get("array")}setArray(Z){return this.set("componentType",Z?eN1(Z):N0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}N0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};N0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function eN1(Z){switch(Z.constructor){case Float32Array:return N0.ComponentType.FLOAT;case Uint32Array:return N0.ComponentType.UNSIGNED_INT;case Uint16Array:return N0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return N0.ComponentType.UNSIGNED_BYTE;case Int16Array:return N0.ComponentType.SHORT;case Int8Array:return N0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class UC extends v6{init(){this.propertyType=s.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new D0,samplers:new D0})}addChannel(Z){return this.addRef("channels",Z)}removeChannel(Z){return this.removeRef("channels",Z)}listChannels(){return this.listRefs("channels")}addSampler(Z){return this.addRef("samplers",Z)}removeSampler(Z){return this.removeRef("samplers",Z)}listSamplers(){return this.listRefs("samplers")}}class LV extends v6{init(){this.propertyType=s.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(Z){return this.set("targetPath",Z)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(Z){return this.setRef("targetNode",Z)}getSampler(){return this.getRef("sampler")}setSampler(Z){return this.setRef("sampler",Z)}}LV.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class RK extends v6{init(){this.propertyType=s.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:RK.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(Z){return this.set("interpolation",Z)}getInput(){return this.getRef("input")}setInput(Z){return this.setRef("input",Z,{usage:o5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:o5.OTHER})}}RK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class LC extends v6{init(){this.propertyType=s.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class BV extends v6{init(){this.propertyType=s.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:BV.Type.PERSPECTIVE,znear:0.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getZNear(){return this.get("znear")}setZNear(Z){return this.set("znear",Z)}getZFar(){return this.get("zfar")}setZFar(Z){return this.set("zfar",Z)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(Z){return this.set("aspectRatio",Z)}getYFov(){return this.get("yfov")}setYFov(Z){return this.set("yfov",Z)}getXMag(){return this.get("xmag")}setXMag(Z){return this.set("xmag",Z)}getYMag(){return this.get("ymag")}setYMag(Z){return this.set("ymag",Z)}}BV.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class i1 extends xB{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}i1.EXTENSION_NAME=void 0;class D1 extends v6{init(){this.propertyType=s.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:D1.WrapMode.REPEAT,wrapT:D1.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}getMagFilter(){return this.get("magFilter")}setMagFilter(Z){return this.set("magFilter",Z)}getMinFilter(){return this.get("minFilter")}setMinFilter(Z){return this.set("minFilter",Z)}getWrapS(){return this.get("wrapS")}setWrapS(Z){return this.set("wrapS",Z)}getWrapT(){return this.get("wrapT")}setWrapT(Z){return this.set("wrapT",Z)}}D1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};D1.MagFilter={NEAREST:9728,LINEAR:9729};D1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:EB,G:kB,B:IB,A:ZR1}=r5;class wV extends v6{init(){this.propertyType=s.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:wV.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new D1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new D1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new D1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new D1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new D1(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(Z){return this.set("doubleSided",Z)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(Z){let J=this.get("baseColorFactor").slice();return J[3]=Z,this.set("baseColorFactor",J)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(Z){return this.set("alphaMode",Z)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(Z){return this.set("alphaCutoff",Z)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(Z){return this.set("baseColorFactor",Z)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(Z){return this.setRef("baseColorTexture",Z,{channels:EB|kB|IB|ZR1,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(Z){return this.set("emissiveFactor",Z)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(Z){return this.setRef("emissiveTexture",Z,{channels:EB|kB|IB,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(Z){return this.set("normalScale",Z)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(Z){return this.setRef("normalTexture",Z,{channels:EB|kB|IB})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(Z){return this.set("occlusionStrength",Z)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(Z){return this.setRef("occlusionTexture",Z,{channels:EB})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(Z){return this.set("roughnessFactor",Z)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(Z){return this.set("metallicFactor",Z)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(Z){return this.setRef("metallicRoughnessTexture",Z,{channels:kB|IB})}}wV.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class BC extends v6{init(){this.propertyType=s.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new D0})}addPrimitive(Z){return this.addRef("primitives",Z)}removePrimitive(Z){return this.removeRef("primitives",Z)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}}class wC extends v6{init(){this.propertyType=s.NODE}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new D0})}copy(Z,J=xJ){if(J===xJ)throw new Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return K8.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),Y=this.get("scale").slice();return K8.decompose(Z,J,X,Y),this.set("translation",J).set("rotation",X).set("scale",Y)}getWorldTranslation(){let Z=[0,0,0];return K8.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return K8.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return K8.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],Z),Z}getWorldMatrix(){let Z=[];for(let Y=this;Y!=null;Y=Y.getParentNode())Z.push(Y);let J,X=Z.pop().getMatrix();while(J=Z.pop())iN1(X,X,J.getMatrix());return X}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);for(let X of Z.listParents())if(X.propertyType===s.SCENE)X.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}getParentNode(){for(let Z of this.listParents())if(Z.propertyType===s.NODE)return Z;return null}getMesh(){return this.getRef("mesh")}setMesh(Z){return this.setRef("mesh",Z)}getCamera(){return this.getRef("camera")}setCamera(Z){return this.setRef("camera",Z)}getSkin(){return this.getRef("skin")}setSkin(Z){return this.setRef("skin",Z)}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}traverse(Z){Z(this);for(let J of this.listChildren())J.traverse(Z);return this}}class hJ extends v6{init(){this.propertyType=s.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:hJ.Mode.TRIANGLES,material:null,indices:null,attributes:new s1,targets:new D0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:o5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:o5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(Z){return this.setRef("material",Z)}getMode(){return this.get("mode")}setMode(Z){return this.set("mode",Z)}listTargets(){return this.listRefs("targets")}addTarget(Z){return this.addRef("targets",Z)}removeTarget(Z){return this.removeRef("targets",Z)}}hJ.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class Ta extends xB{init(){this.propertyType=s.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new s1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:o5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function vB(){return vB=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},vB.apply(null,arguments)}class jC extends v6{init(){this.propertyType=s.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new D0})}copy(Z,J=xJ){if(J===xJ)throw new Error("Scene cannot be copied.");return super.copy(Z,J)}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}traverse(Z){for(let J of this.listChildren())J.traverse(Z);return this}}class OC extends v6{init(){this.propertyType=s.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new D0})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(Z){return this.setRef("skeleton",Z)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(Z){return this.setRef("inverseBindMatrices",Z,{usage:o5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class NC extends v6{init(){this.propertyType=s.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||N4.extensionToMimeType(qV.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=N4.extensionToMimeType(qV.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",_6.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return N4.getSize(Z,this.getMimeType())}}class hB extends v6{init(){this.propertyType=s.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${mN1}`,version:"2.0"},defaultScene:null,accessors:new D0,animations:new D0,buffers:new D0,cameras:new D0,materials:new D0,meshes:new D0,nodes:new D0,scenes:new D0,skins:new D0,textures:new D0})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(Z,J=xJ){if(J===xJ)throw new Error("Root cannot be copied.");this.set("asset",vB({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(vB({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let Y=Z.getExtension(X);this.setExtension(X,J(Y))}return this}_addChildOfRoot(Z){if(Z instanceof jC)this.addRef("scenes",Z);else if(Z instanceof wC)this.addRef("nodes",Z);else if(Z instanceof BV)this.addRef("cameras",Z);else if(Z instanceof OC)this.addRef("skins",Z);else if(Z instanceof BC)this.addRef("meshes",Z);else if(Z instanceof wV)this.addRef("materials",Z);else if(Z instanceof NC)this.addRef("textures",Z);else if(Z instanceof UC)this.addRef("animations",Z);else if(Z instanceof N0)this.addRef("accessors",Z);else if(Z instanceof LC)this.addRef("buffers",Z);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((Z)=>Z.isRequired())}_enableExtension(Z){return this._extensions.add(Z),this}_disableExtension(Z){return this._extensions.delete(Z),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(Z){return this.setRef("defaultScene",Z)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class SB{static fromGraph(Z){return SB._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new WK,this._root=new hB(this._graph),this._logger=U7.DEFAULT_INSTANCE,SB._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(Z){return this._logger=Z,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...Z){let J=Z.map((X)=>X.name);for(let X of Z)await X(this,{stack:J});return this}createExtension(Z){let J=Z.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find((Y)=>Y.extensionName===J)||new Z(this)}createScene(Z=""){return new jC(this._graph,Z)}createNode(Z=""){return new wC(this._graph,Z)}createCamera(Z=""){return new BV(this._graph,Z)}createSkin(Z=""){return new OC(this._graph,Z)}createMesh(Z=""){return new BC(this._graph,Z)}createPrimitive(){return new hJ(this._graph)}createPrimitiveTarget(Z=""){return new Ta(this._graph,Z)}createMaterial(Z=""){return new wV(this._graph,Z)}createTexture(Z=""){return new NC(this._graph,Z)}createAnimation(Z=""){return new UC(this._graph,Z)}createAnimationChannel(Z=""){return new LV(this._graph,Z)}createAnimationSampler(Z=""){return new RK(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new N0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new LC(this._graph,Z)}}SB._GRAPH_DOCUMENTS=new WeakMap;class E1{constructor(Z){this.extensionName="",this.prereadTypes=[],this.prewriteTypes=[],this.readDependencies=[],this.writeDependencies=[],this.document=void 0,this.required=!1,this.properties=new Set,this._listener=void 0,this.document=Z,Z.getRoot()._enableExtension(this),this._listener=(X)=>{let Y=X,$=Y.target;if($ instanceof i1&&$.extensionName===this.extensionName){if(Y.type==="node:create")this._addExtensionProperty($);if(Y.type==="node:dispose")this._removeExtensionProperty($)}};let J=Z.getGraph();J.addEventListener("node:create",this._listener),J.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);let Z=this.document.getGraph();Z.removeEventListener("node:create",this._listener),Z.removeEventListener("node:dispose",this._listener);for(let J of this.properties)J.dispose()}static register(){}isRequired(){return this.required}setRequired(Z){return this.required=Z,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(Z){return this.properties.add(Z),this}_removeExtensionProperty(Z){return this.properties.delete(Z),this}install(Z,J){return this}preread(Z,J){return this}prewrite(Z,J){return this}}E1.EXTENSION_NAME=void 0;var xT6={logger:U7.DEFAULT_INSTANCE,extensions:[],dependencies:{}},hT6=new Set([s.BUFFER,s.TEXTURE,s.MATERIAL,s.MESH,s.PRIMITIVE,s.NODE,s.SCENE]);var UV;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(UV||(UV={}));class fJ{constructor(Z,J,X){this._doc=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this._accessorUsageMap=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this._doc=Z,this.jsonDoc=J,this.options=X;let Y=Z.getRoot(),$=Y.listBuffers().length,Q=Y.listTextures().length;this.bufferURIGenerator=new zC($>1,()=>X.basename||"buffer"),this.imageURIGenerator=new zC(Q>1,(K)=>JR1(Z,K)||X.basename||"texture"),this.logger=Z.getLogger()}createTextureInfoDef(Z,J){let X={magFilter:J.getMagFilter()||void 0,minFilter:J.getMinFilter()||void 0,wrapS:J.getWrapS(),wrapT:J.getWrapT()},Y=JSON.stringify(X);if(!this.samplerDefIndexMap.has(Y))this.samplerDefIndexMap.set(Y,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(X);let $={source:this.imageIndexMap.get(Z),sampler:this.samplerDefIndexMap.get(Y)},Q=JSON.stringify($);if(!this.textureDefIndexMap.has(Q))this.textureDefIndexMap.set(Q,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push($);let K={index:this.textureDefIndexMap.get(Q)};if(J.getTexCoord()!==0)K.texCoord=J.getTexCoord();if(Object.keys(J.getExtras()).length>0)K.extras=J.getExtras();return this.textureInfoDefMap.set(J,K),K}createPropertyDef(Z){let J={};if(Z.getName())J.name=Z.getName();if(Object.keys(Z.getExtras()).length>0)J.extras=Z.getExtras();return J}createAccessorDef(Z){let J=this.createPropertyDef(Z);if(J.type=Z.getType(),J.componentType=Z.getComponentType(),J.count=Z.getCount(),this._doc.getGraph().listParentEdges(Z).some((Y)=>Y.getName()==="attributes"&&Y.getAttributes().key==="POSITION"||Y.getName()==="input"))J.max=Z.getMax([]).map(Math.fround),J.min=Z.getMin([]).map(Math.fround);if(Z.getNormalized())J.normalized=Z.getNormalized();return J}createImageData(Z,J,X){if(this.options.format===KC.GLB)this.imageBufferViews.push(J),Z.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:J.byteLength});else{let Y=N4.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,Y),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let Y=this.jsonDoc.resources;if(!(Z in Y)){Y[Z]=J;return}if(J===Y[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let $=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn($);return}throw new Error($)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return o5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:Y}=X.getAttributes();if(Y)return Y;if(X.getParent().propertyType!==s.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return o5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw new Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}fJ.BufferViewTarget=UV;fJ.BufferViewUsage=o5;fJ.USAGE_TO_TARGET={[o5.ARRAY_BUFFER]:UV.ARRAY_BUFFER,[o5.ELEMENT_ARRAY_BUFFER]:UV.ELEMENT_ARRAY_BUFFER};class zC{constructor(Z,J){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=Z,this.basename=J}createURI(Z,J){if(Z.getURI())return Z.getURI();else if(!this.multiple)return`${this.basename(Z)}.${J}`;else{let X=this.basename(Z);return this.counter[X]=this.counter[X]||1,`${X}_${this.counter[X]++}.${J}`}}}function JR1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{UNSIGNED_INT:fT6,UNSIGNED_SHORT:yT6,UNSIGNED_BYTE:bT6}=N0.ComponentType,gT6=new Set([s.ACCESSOR,s.BUFFER,s.MATERIAL,s.MESH]);var Na;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(Na||(Na={}));var ka=163,Ia=166;function XR1(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}class MK{constructor(Z,J,X,Y){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(Z.buffer,Z.byteOffset+J,X),this._littleEndian=Y,this._offset=0}_nextUint8(){let Z=this._dataView.getUint8(this._offset);return this._offset+=1,Z}_nextUint16(){let Z=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,Z}_nextUint32(){let Z=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,Z}_nextUint64(){let Z=this._dataView.getUint32(this._offset,this._littleEndian),J=this._dataView.getUint32(this._offset+4,this._littleEndian),X=Z+4294967296*J;return this._offset+=8,X}_nextInt32(){let Z=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,Z}_nextUint8Array(Z){let J=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,Z);return this._offset+=Z,J}_skip(Z){return this._offset+=Z,this}_scan(Z,J=0){let X=this._offset,Y=0;while(this._dataView.getUint8(this._offset)!==J&&Y<Z)Y++,this._offset++;if(Y<Z)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+X,Y)}}var dT6=new Uint8Array([0]),t6=[171,75,84,88,32,50,48,187,13,10,26,10];function Ea(Z){return new TextDecoder().decode(Z)}function fB(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,t6.length);if(J[0]!==t6[0]||J[1]!==t6[1]||J[2]!==t6[2]||J[3]!==t6[3]||J[4]!==t6[4]||J[5]!==t6[5]||J[6]!==t6[6]||J[7]!==t6[7]||J[8]!==t6[8]||J[9]!==t6[9]||J[10]!==t6[10]||J[11]!==t6[11])throw new Error("Missing KTX 2.0 identifier.");let X=XR1(),Y=17*Uint32Array.BYTES_PER_ELEMENT,$=new MK(Z,t6.length,Y,!0);X.vkFormat=$._nextUint32(),X.typeSize=$._nextUint32(),X.pixelWidth=$._nextUint32(),X.pixelHeight=$._nextUint32(),X.pixelDepth=$._nextUint32(),X.layerCount=$._nextUint32(),X.faceCount=$._nextUint32();let Q=$._nextUint32();X.supercompressionScheme=$._nextUint32();let K=$._nextUint32(),W=$._nextUint32(),G=$._nextUint32(),V=$._nextUint32(),H=$._nextUint64(),F=$._nextUint64(),z=Q*3*8,q=new MK(Z,t6.length+Y,z,!0);for(let F6=0;F6<Q;F6++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+q._nextUint64(),q._nextUint64()),uncompressedByteLength:q._nextUint64()});let U=new MK(Z,K,W,!0);U._skip(4);let L=U._nextUint16(),B=U._nextUint16(),w=U._nextUint16(),O=U._nextUint16(),N=U._nextUint8(),R=U._nextUint8(),D=U._nextUint8(),M=U._nextUint8(),C=[U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8()],T=[U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8()],x={vendorId:L,descriptorType:B,versionNumber:w,colorModel:N,colorPrimaries:R,transferFunction:D,flags:M,texelBlockDimension:C,bytesPlane:T,samples:[]},v=6,S=4,I=(O/4-v)/S;for(let F6=0;F6<I;F6++){let XZ={bitOffset:U._nextUint16(),bitLength:U._nextUint8(),channelType:U._nextUint8(),samplePosition:[U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(XZ.channelType&64)XZ.sampleLower=U._nextInt32(),XZ.sampleUpper=U._nextInt32();else XZ.sampleLower=U._nextUint32(),XZ.sampleUpper=U._nextUint32();x.samples[F6]=XZ}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(x);let _=new MK(Z,G,V,!0);while(_._offset<V){let F6=_._nextUint32(),XZ=_._scan(F6),Mq=Ea(XZ);if(X.keyValue[Mq]=_._nextUint8Array(F6-XZ.byteLength-1),Mq.match(/^ktx/i)){let ry=Ea(X.keyValue[Mq]);X.keyValue[Mq]=ry.substring(0,ry.lastIndexOf("\x00"))}let KG1=F6%4?4-F6%4:0;_._skip(KG1)}if(F<=0)return X;let y=new MK(Z,H,F,!0),p=y._nextUint16(),n=y._nextUint16(),o=y._nextUint32(),X0=y._nextUint32(),Q0=y._nextUint32(),E0=y._nextUint32(),k0=[];for(let F6=0;F6<Q;F6++)k0.push({imageFlags:y._nextUint32(),rgbSliceByteOffset:y._nextUint32(),rgbSliceByteLength:y._nextUint32(),alphaSliceByteOffset:y._nextUint32(),alphaSliceByteLength:y._nextUint32()});let a0=H+y._offset,k8=a0+o,n1=k8+X0,t4=n1+Q0,W4=new Uint8Array(Z.buffer,Z.byteOffset+a0,o),CQ=new Uint8Array(Z.buffer,Z.byteOffset+k8,X0),TQ=new Uint8Array(Z.buffer,Z.byteOffset+n1,Q0),ZY=new Uint8Array(Z.buffer,Z.byteOffset+t4,E0);return X.globalData={endpointCount:p,selectorCount:n,imageDescs:k0,endpointsData:W4,selectorsData:CQ,tablesData:TQ,extendedData:ZY},X}var CC="EXT_mesh_gpu_instancing",MC="EXT_meshopt_compression",YR1="EXT_texture_webp",$R1="EXT_texture_avif",ca="KHR_draco_mesh_compression",TC="KHR_lights_punctual",EC="KHR_materials_anisotropy",kC="KHR_materials_clearcoat",IC="KHR_materials_diffuse_transmission",_C="KHR_materials_dispersion",vC="KHR_materials_emissive_strength",SC="KHR_materials_ior",AC="KHR_materials_iridescence",xC="KHR_materials_pbrSpecularGlossiness",hC="KHR_materials_sheen",fC="KHR_materials_specular",yC="KHR_materials_transmission",bC="KHR_materials_unlit",gC="KHR_materials_volume",uY="KHR_materials_variants",QR1="KHR_mesh_quantization",KR1="KHR_texture_basisu",mC="KHR_texture_transform",yB="KHR_xmp_json_ld",PC="INSTANCE_ATTRIBUTE";class uC extends i1{init(){this.extensionName=CC,this.propertyType="InstancedMesh",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new s1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:PC})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}uC.EXTENSION_NAME=CC;var EY=CC;class mB extends E1{constructor(...Z){super(...Z);this.extensionName=EY,this.provideTypes=[s.NODE],this.prewriteTypes=[s.ACCESSOR]}createInstancedMesh(){return new uC(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach((Y,$)=>{if(!Y.extensions||!Y.extensions[EY])return;let Q=Y.extensions[EY],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[$].setExtension(EY,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(PC);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,PC);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let Y=X.getExtension(EY);if(Y){let $=Z.nodeIndexMap.get(X),Q=J.json.nodes[$],K={attributes:{}};Y.listSemantics().forEach((W)=>{let G=Y.getAttribute(W);K.attributes[W]=Z.accessorIndexMap.get(G)}),Q.extensions=Q.extensions||{},Q.extensions[EY]=K}}),this}}mB.EXTENSION_NAME=EY;function NZ(){return NZ=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},NZ.apply(null,arguments)}var RV;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(RV||(RV={}));var DK;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(DK||(DK={}));var W8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})(W8||(W8={}));var{BYTE:WR1,SHORT:_a,FLOAT:GR1}=N0.ComponentType,{encodeNormalizedInt:va,decodeNormalizedInt:DC}=K8;function VR1(Z,J,X,Y){let{filter:$,bits:Q}=Y,K={array:Z.getArray(),byteStride:Z.getElementSize()*Z.getComponentSize(),componentType:Z.getComponentType(),normalized:Z.getNormalized()};if(X!==DK.ATTRIBUTES)return K;if($!==W8.NONE){let W=Z.getNormalized()?HR1(Z):new Float32Array(K.array);switch($){case W8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=GR1,K.normalized=!1,K.array=J.encodeFilterExp(W,Z.getCount(),K.byteStride,Q);break;case W8.OCTAHEDRAL:K.byteStride=Q>8?8:4,K.componentType=Q>8?_a:WR1,K.normalized=!0,W=Z.getElementSize()===3?FR1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case W8.QUATERNION:K.byteStride=8,K.componentType=_a,K.normalized=!0,K.array=J.encodeFilterQuat(W,Z.getCount(),K.byteStride,Q);break;default:throw new Error("Invalid filter.")}if(K.min=Z.getMin([]),K.max=Z.getMax([]),Z.getNormalized())K.min=K.min.map((G)=>DC(G,Z.getComponentType())),K.max=K.max.map((G)=>DC(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>va(G,K.componentType)),K.max=K.max.map((G)=>va(G,K.componentType))}else if(K.byteStride%4)K.array=zR1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function HR1(Z){let J=Z.getComponentType(),X=Z.getArray(),Y=new Float32Array(X.length);for(let $=0;$<X.length;$++)Y[$]=DC(X[$],J);return Y}function zR1(Z,J){let Y=_6.padNumber(Z.BYTES_PER_ELEMENT*J)/Z.BYTES_PER_ELEMENT,$=Z.length/J,Q=new Z.constructor($*Y);for(let K=0;K*J<Z.length;K++)for(let W=0;W<J;W++)Q[K*Y+W]=Z[K*J+W];return Q}function FR1(Z){let J=new Float32Array(Z.length*4/3);for(let X=0,Y=Z.length/3;X<Y;X++)J[X*4]=Z[X*3],J[X*4+1]=Z[X*3+1],J[X*4+2]=Z[X*3+2];return J}function qR1(Z,J){if(J===fJ.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some((Y)=>{return Y instanceof hJ&&Y.getMode()===hJ.Mode.TRIANGLES})?DK.TRIANGLES:DK.INDICES;return DK.ATTRIBUTES}function UR1(Z,J){let X=J.getGraph().listParentEdges(Z).filter((Y)=>!(Y.getParent()instanceof hB));for(let Y of X){let $=Y.getName(),Q=Y.getAttributes().key||"",K=Y.getParent().propertyType===s.PRIMITIVE_TARGET;if($==="indices")return{filter:W8.NONE};if($==="attributes"){if(Q==="POSITION")return{filter:W8.NONE};if(Q==="TEXCOORD_0")return{filter:W8.NONE};if(Q.startsWith("JOINTS_"))return{filter:W8.NONE};if(Q.startsWith("WEIGHTS_"))return{filter:W8.NONE};if(Q==="NORMAL"||Q==="TANGENT")return K?{filter:W8.NONE}:{filter:W8.OCTAHEDRAL,bits:8}}if($==="output"){let W=la(Z);if(W==="rotation")return{filter:W8.QUATERNION,bits:16};if(W==="translation")return{filter:W8.EXPONENTIAL,bits:12};if(W==="scale")return{filter:W8.EXPONENTIAL,bits:12};return{filter:W8.NONE}}if($==="input")return{filter:W8.NONE};if($==="inverseBindMatrices")return{filter:W8.NONE}}return{filter:W8.NONE}}function la(Z){for(let J of Z.listParents()){if(!(J instanceof RK))continue;for(let X of J.listParents()){if(!(X instanceof LV))continue;return X.getTargetPath()}}return null}function LR1(Z){if(!Z.extensions||!Z.extensions[MC])return!1;return!!Z.extensions[MC].fallback}var e6=MC,Sa={method:RV.QUANTIZE};class PV extends E1{constructor(...Z){super(...Z);this.extensionName=e6,this.prereadTypes=[s.BUFFER,s.PRIMITIVE],this.prewriteTypes=[s.BUFFER,s.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=Sa,this._encoderFallbackBuffer=null,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={}}install(Z,J){if(Z==="meshopt.decoder")this._decoder=J;if(Z==="meshopt.encoder")this._encoder=J;return this}setEncoderOptions(Z){return this._encoderOptions=NZ({},Sa,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${e6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${e6}]: Missing WASM support.`)}if(J===s.BUFFER)this._prereadBuffers(Z);else if(J===s.PRIMITIVE)this._prereadPrimitives(Z);return this}_prereadBuffers(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach((Y,$)=>{if(!Y.extensions||!Y.extensions[e6])return;let Q=Y.extensions[e6],K=Q.byteOffset||0,W=Q.byteLength||0,G=Q.count,V=Q.byteStride,H=new Uint8Array(G*V),F=J.json.buffers[Q.buffer],z=F.uri?J.resources[F.uri]:J.resources[FC],q=_6.toView(z,K,W);this._decoder.decodeGltfBuffer(H,G,V,q,Q.mode,Q.filter),Z.bufferViews[$]=H})}_prereadPrimitives(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach((Y)=>{if(!Y.extensions||!Y.extensions[e6])return;let $=Y.extensions[e6],Q=Z.buffers[$.buffer],K=Z.buffers[Y.buffer],W=J.json.buffers[Y.buffer];if(LR1(W))this._decoderFallbackBufferMap.set(K,Q)})}read(Z){if(!this.isRequired())return this;for(let[J,X]of this._decoderFallbackBufferMap){for(let Y of J.listParents())if(Y instanceof N0)Y.swap(J,X);J.dispose()}return this}prewrite(Z,J){if(J===s.ACCESSOR)this._prewriteAccessors(Z);else if(J===s.BUFFER)this._prewriteBuffers(Z);return this}_prewriteAccessors(Z){let J=Z.jsonDoc.json,X=this._encoder,Y=this._encoderOptions,$=this.document.getGraph(),Q=this.document.createBuffer(),K=this.document.getRoot().listBuffers().indexOf(Q),W=1,G=new Map,V=(H)=>{for(let F of $.listParents(H)){if(F.propertyType===s.ROOT)continue;let z=G.get(H);if(z===void 0)G.set(H,z=W++);return z}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let H of this.document.getRoot().listAccessors()){if(la(H)==="weights")continue;if(H.getSparse())continue;let F=Z.getAccessorUsage(H),z=Z.accessorUsageGroupedByParent.has(F)?V(H):null,q=qR1(H,F),U=Y.method===RV.FILTER?UR1(H,this.document):{filter:W8.NONE},L=VR1(H,X,q,U),{array:B,byteStride:w}=L,O=H.getBuffer();if(!O)throw new Error(`${e6}: Missing buffer for accessor.`);let N=this.document.getRoot().listBuffers().indexOf(O),R=[F,z,q,U.filter,w,N].join(":"),D=this._encoderBufferViews[R],M=this._encoderBufferViewData[R],C=this._encoderBufferViewAccessors[R];if(!D||!M)C=this._encoderBufferViewAccessors[R]=[],M=this._encoderBufferViewData[R]=[],D=this._encoderBufferViews[R]={buffer:K,target:fJ.USAGE_TO_TARGET[F],byteOffset:0,byteLength:0,byteStride:F===fJ.BufferViewUsage.ARRAY_BUFFER?w:void 0,extensions:{[e6]:{buffer:N,byteOffset:0,byteLength:0,mode:q,filter:U.filter!==W8.NONE?U.filter:void 0,byteStride:w,count:0}}};let T=Z.createAccessorDef(H);if(T.componentType=L.componentType,T.normalized=L.normalized,T.byteOffset=D.byteLength,T.min&&L.min)T.min=L.min;if(T.max&&L.max)T.max=L.max;Z.accessorIndexMap.set(H,J.accessors.length),J.accessors.push(T),C.push(T),M.push(new Uint8Array(B.buffer,B.byteOffset,B.byteLength)),D.byteLength+=B.byteLength,D.extensions.EXT_meshopt_compression.count+=H.getCount()}}_prewriteBuffers(Z){let J=this._encoder;for(let X in this._encoderBufferViews){let Y=this._encoderBufferViews[X],$=this._encoderBufferViewData[X],Q=this.document.getRoot().listBuffers()[Y.extensions[e6].buffer],K=Z.otherBufferViews.get(Q)||[],{count:W,byteStride:G,mode:V}=Y.extensions[e6],H=_6.concat($),F=J.encodeGltfBuffer(H,W,G,V),z=_6.pad(F);Y.extensions[e6].byteLength=F.byteLength,$.length=0,$.push(z),K.push(z),Z.otherBufferViews.set(Q,K)}}write(Z){let J=0;for(let Q in this._encoderBufferViews){let K=this._encoderBufferViews[Q],W=this._encoderBufferViewData[Q][0],G=Z.otherBufferViewsIndexMap.get(W),V=this._encoderBufferViewAccessors[Q];for(let q of V)q.bufferView=G;let H=Z.jsonDoc.json.bufferViews[G],F=H.byteOffset||0;Object.assign(H,K),H.byteOffset=J;let z=H.extensions[e6];z.byteOffset=F,J+=_6.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,Y=Z.bufferIndexMap.get(X),$=Z.jsonDoc.json.buffers[Y];return $.byteLength=J,$.extensions={[e6]:{fallback:!0}},X.dispose(),this}}PV.EXTENSION_NAME=e6;PV.EncoderMethod=RV;var jV=$R1;class pa{match(Z){return Z.length>=12&&_6.decodeText(Z.slice(4,12))==="ftypavif"}getSize(Z){if(!this.match(Z))return null;let J=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),X=Aa(J,0);if(!X)return null;let Y=X.end;while(X=Aa(J,Y))if(X.type==="meta")Y=X.start+4;else if(X.type==="iprp"||X.type==="ipco")Y=X.start;else if(X.type==="ispe")return[J.getUint32(X.start+4),J.getUint32(X.start+8)];else if(X.type==="mdat")break;else Y=X.end;return null}getChannels(Z){return 4}}class uB extends E1{constructor(...Z){super(...Z);this.extensionName=jV,this.prereadTypes=[s.TEXTURE]}static register(){N4.registerFormat("image/avif",new pa)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[jV])X.source=X.extensions[jV].source}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/avif"){let Y=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===Y)Q.extensions=Q.extensions||{},Q.extensions[jV]={source:Q.source},delete Q.source})}}),this}}uB.EXTENSION_NAME=jV;function Aa(Z,J){if(Z.byteLength<4+J)return null;let X=Z.getUint32(J);if(Z.byteLength<X+J||X<8)return null;return{type:_6.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}var OV=YR1;class ia{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=_6.decodeText(Z.slice(0,4)),X=_6.decodeText(Z.slice(8,12));if(J!=="RIFF"||X!=="WEBP")return null;let Y=new DataView(Z.buffer,Z.byteOffset),$=12;while($<Y.byteLength){let Q=_6.decodeText(new Uint8Array([Y.getUint8($),Y.getUint8($+1),Y.getUint8($+2),Y.getUint8($+3)])),K=Y.getUint32($+4,!0);if(Q==="VP8 "){let W=Y.getInt16($+14,!0)&16383,G=Y.getInt16($+16,!0)&16383;return[W,G]}else if(Q==="VP8L"){let W=Y.getUint8($+9),G=Y.getUint8($+10),V=Y.getUint8($+11),H=Y.getUint8($+12),F=1+((G&63)<<8|W),z=1+((H&15)<<10|V<<2|(G&192)>>6);return[F,z]}$+=8+K+K%2}return null}getChannels(Z){return 4}}class dB extends E1{constructor(...Z){super(...Z);this.extensionName=OV,this.prereadTypes=[s.TEXTURE]}static register(){N4.registerFormat("image/webp",new ia)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[OV])X.source=X.extensions[OV].source}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/webp"){let Y=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===Y)Q.extensions=Q.extensions||{},Q.extensions[OV]={source:Q.source},delete Q.source})}}),this}}dB.EXTENSION_NAME=OV;var xa=ca,m8,na,aa;function BR1(Z,J){let X=new m8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==m8.TRIANGULAR_MESH)throw new Error(`[${xa}] Unknown geometry type.`);let $=new m8.Mesh;if(!Z.DecodeBufferToMesh(X,$).ok()||$.ptr===0)throw new Error(`[${xa}] Decoding failure.`);return $}finally{m8.destroy(X)}}function wR1(Z,J){let Y=J.num_faces()*3,$,Q;if(J.num_points()<=65534){let K=Y*Uint16Array.BYTES_PER_ELEMENT;$=m8._malloc(K),Z.GetTrianglesUInt16Array(J,K,$),Q=new Uint16Array(m8.HEAPU16.buffer,$,Y).slice()}else{let K=Y*Uint32Array.BYTES_PER_ELEMENT;$=m8._malloc(K),Z.GetTrianglesUInt32Array(J,K,$),Q=new Uint32Array(m8.HEAPU32.buffer,$,Y).slice()}return m8._free($),Q}function jR1(Z,J,X,Y){let $=aa[Y.componentType],Q=na[Y.componentType],K=X.num_components(),G=J.num_points()*K,V=G*Q.BYTES_PER_ELEMENT,H=m8._malloc(V);Z.GetAttributeDataArrayForAllPoints(J,X,$,V,H);let F=new Q(m8.HEAPF32.buffer,H,G).slice();return m8._free(H),F}function OR1(Z){m8=Z,na={[N0.ComponentType.FLOAT]:Float32Array,[N0.ComponentType.UNSIGNED_INT]:Uint32Array,[N0.ComponentType.UNSIGNED_SHORT]:Uint16Array,[N0.ComponentType.UNSIGNED_BYTE]:Uint8Array,[N0.ComponentType.SHORT]:Int16Array,[N0.ComponentType.BYTE]:Int8Array},aa={[N0.ComponentType.FLOAT]:m8.DT_FLOAT32,[N0.ComponentType.UNSIGNED_INT]:m8.DT_UINT32,[N0.ComponentType.UNSIGNED_SHORT]:m8.DT_UINT16,[N0.ComponentType.UNSIGNED_BYTE]:m8.DT_UINT8,[N0.ComponentType.SHORT]:m8.DT_INT16,[N0.ComponentType.BYTE]:m8.DT_INT8}}var I9,MV;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(MV||(MV={}));var _9;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(_9||(_9={}));var sa={[_9.POSITION]:14,[_9.NORMAL]:10,[_9.COLOR]:8,[_9.TEX_COORD]:12,[_9.GENERIC]:12},ha={decodeSpeed:5,encodeSpeed:5,method:MV.EDGEBREAKER,quantizationBits:sa,quantizationVolume:"mesh"};function NR1(Z){I9=Z}function RR1(Z,J=ha){let X=NZ({},ha,J);X.quantizationBits=NZ({},sa,J.quantizationBits);let Y=new I9.MeshBuilder,$=new I9.Mesh,Q=new I9.ExpertEncoder($),K={},W=new I9.DracoInt8Array,G=Z.listTargets().length>0,V=!1;for(let L of Z.listSemantics()){let B=Z.getAttribute(L);if(B.getSparse()){V=!0;continue}let w=MR1(L),O=PR1(Y,B.getComponentType(),$,I9[w],B.getCount(),B.getElementSize(),B.getArray());if(O===-1)throw new Error(`Error compressing "${L}" attribute.`);if(K[L]=O,X.quantizationVolume==="mesh"||L!=="POSITION")Q.SetAttributeQuantization(O,X.quantizationBits[w]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:N}=X,R=Math.max(N.max[0]-N.min[0],N.max[1]-N.min[1],N.max[2]-N.min[2]);Q.SetAttributeExplicitQuantization(O,X.quantizationBits[w],B.getElementSize(),N.min,R)}else throw new Error("Invalid quantization volume state.")}let H=Z.getIndices();if(!H)throw new bB("Primitive must have indices.");if(Y.AddFacesToMesh($,H.getCount()/3,H.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===MV.SEQUENTIAL||G||V)Q.SetEncodingMethod(I9.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(I9.MESH_EDGEBREAKER_ENCODING);let F=Q.EncodeToDracoBuffer(!(G||V),W);if(F<=0)throw new bB("Error applying Draco compression.");let z=new Uint8Array(F);for(let L=0;L<F;++L)z[L]=W.GetValue(L);let q=Q.GetNumberOfEncodedPoints(),U=Q.GetNumberOfEncodedFaces()*3;return I9.destroy(W),I9.destroy($),I9.destroy(Y),I9.destroy(Q),{numVertices:q,numIndices:U,data:z,attributeIDs:K}}function MR1(Z){if(Z==="POSITION")return _9.POSITION;else if(Z==="NORMAL")return _9.NORMAL;else if(Z.startsWith("COLOR_"))return _9.COLOR;else if(Z.startsWith("TEXCOORD_"))return _9.TEX_COORD;return _9.GENERIC}function PR1(Z,J,X,Y,$,Q,K){switch(J){case N0.ComponentType.UNSIGNED_BYTE:return Z.AddUInt8Attribute(X,Y,$,Q,K);case N0.ComponentType.BYTE:return Z.AddInt8Attribute(X,Y,$,Q,K);case N0.ComponentType.UNSIGNED_SHORT:return Z.AddUInt16Attribute(X,Y,$,Q,K);case N0.ComponentType.SHORT:return Z.AddInt16Attribute(X,Y,$,Q,K);case N0.ComponentType.UNSIGNED_INT:return Z.AddUInt32Attribute(X,Y,$,Q,K);case N0.ComponentType.FLOAT:return Z.AddFloatAttribute(X,Y,$,Q,K);default:throw new Error(`Unexpected component type, "${J}".`)}}class bB extends Error{}var N8=ca;class DV extends E1{constructor(...Z){super(...Z);this.extensionName=N8,this.prereadTypes=[s.PRIMITIVE],this.prewriteTypes=[s.ACCESSOR],this.readDependencies=["draco3d.decoder"],this.writeDependencies=["draco3d.encoder"],this._decoderModule=null,this._encoderModule=null,this._encoderOptions={}}install(Z,J){if(Z==="draco3d.decoder")this._decoderModule=J,OR1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,NR1(this._encoderModule);return this}setEncoderOptions(Z){return this._encoderOptions=Z,this}preread(Z){if(!this._decoderModule)throw new Error(`[${N8}] Please install extension dependency, "draco3d.decoder".`);let J=this.document.getLogger(),X=Z.jsonDoc,Y=new Map;try{let $=X.json.meshes||[];for(let Q of $)for(let K of Q.primitives){if(!K.extensions||!K.extensions[N8])continue;let W=K.extensions[N8],[G,V]=Y.get(W.bufferView)||[];if(!V||!G){let H=X.json.bufferViews[W.bufferView],F=X.json.buffers[H.buffer],z=F.uri?X.resources[F.uri]:X.resources[FC],q=H.byteOffset||0,U=H.byteLength,L=_6.toView(z,q,U);G=new this._decoderModule.Decoder,V=BR1(G,L),Y.set(W.bufferView,[G,V]),J.debug(`[${N8}] Decompressed ${L.byteLength} bytes.`)}for(let H in W.attributes){let F=Z.jsonDoc.json.accessors[K.attributes[H]],z=G.GetAttributeByUniqueId(V,W.attributes[H]),q=jR1(G,V,z,F);Z.accessors[K.attributes[H]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(wR1(G,V))}}finally{for(let[$,Q]of Array.from(Y.values()))this._decoderModule.destroy($),this._decoderModule.destroy(Q)}return this}read(Z){return this}prewrite(Z,J){if(!this._encoderModule)throw new Error(`[${N8}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${N8}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let Y=DR1(this.document),$=new Map,Q="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)X.warn(`[${N8}]: quantizationVolume=scene requires exactly 1 scene.`);else Q=Ra(this.document.getRoot().listScenes().pop());for(let K of Array.from(Y.keys())){let W=Y.get(K);if(!W)throw new Error("Unexpected primitive.");if($.has(W)){$.set(W,$.get(W));continue}let G=K.getIndices(),V=Z.jsonDoc.json.accessors,H;try{H=RR1(K,NZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof bB){X.warn(`[${N8}]: ${q.message} Skipping primitive compression.`);continue}throw q}$.set(W,H);let F=Z.createAccessorDef(G);if(F.count=H.numIndices,Z.accessorIndexMap.set(G,V.length),V.push(F),H.numVertices>65534&&N0.getComponentSize(F.componentType)<=2)F.componentType=N0.ComponentType.UNSIGNED_INT;else if(H.numVertices>254&&N0.getComponentSize(F.componentType)<=1)F.componentType=N0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let U=K.getAttribute(q);if(H.attributeIDs[q]===void 0)continue;let L=Z.createAccessorDef(U);L.count=H.numVertices,Z.accessorIndexMap.set(U,V.length),V.push(L)}let z=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(z))Z.otherBufferViews.set(z,[]);Z.otherBufferViews.get(z).push(H.data)}return X.debug(`[${N8}] Compressed ${Y.size} primitives.`),Z.extensionData[N8]={primitiveHashMap:Y,primitiveEncodingMap:$},this}write(Z){let J=Z.extensionData[N8];for(let X of this.document.getRoot().listMeshes()){let Y=Z.jsonDoc.json.meshes[Z.meshIndexMap.get(X)];for(let $=0;$<X.listPrimitives().length;$++){let Q=X.listPrimitives()[$],K=Y.primitives[$],W=J.primitiveHashMap.get(Q);if(!W)continue;let G=J.primitiveEncodingMap.get(W);if(!G)continue;K.extensions=K.extensions||{},K.extensions[N8]={bufferView:Z.otherBufferViewsIndexMap.get(G.data),attributes:G.attributeIDs}}}if(!J.primitiveHashMap.size){let X=Z.jsonDoc.json;X.extensionsUsed=(X.extensionsUsed||[]).filter((Y)=>Y!==N8),X.extensionsRequired=(X.extensionsRequired||[]).filter((Y)=>Y!==N8)}return this}}DV.EXTENSION_NAME=N8;DV.EncoderMethod=MV;function DR1(Z){let J=Z.getLogger(),X=new Set,Y=new Set,$=0,Q=0;for(let F of Z.getRoot().listMeshes())for(let z of F.listPrimitives())if(!z.getIndices())Y.add(z),$++;else if(z.getMode()!==hJ.Mode.TRIANGLES)Y.add(z),Q++;else X.add(z);if($>0)J.warn(`[${N8}] Skipping Draco compression of ${$} non-indexed primitives.`);if(Q>0)J.warn(`[${N8}] Skipping Draco compression of ${Q} non-TRIANGLES primitives.`);let K=Z.getRoot().listAccessors(),W=new Map;for(let F=0;F<K.length;F++)W.set(K[F],F);let G=new Map,V=new Set,H=new Map;for(let F of Array.from(X)){let z=fa(F,W);if(V.has(z)){H.set(F,z);continue}if(G.has(F.getIndices())){let q=F.getIndices(),U=q.clone();W.set(U,Z.getRoot().listAccessors().length-1),F.swap(q,U)}for(let q of F.listAttributes())if(G.has(q)){let U=q.clone();W.set(U,Z.getRoot().listAccessors().length-1),F.swap(q,U)}z=fa(F,W),V.add(z),H.set(F,z),G.set(F.getIndices(),z);for(let q of F.listAttributes())G.set(q,z)}for(let F of Array.from(G.keys())){let z=new Set(F.listParents().map((q)=>q.propertyType));if(z.size!==2||!z.has(s.PRIMITIVE)||!z.has(s.ROOT))throw new Error(`[${N8}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let F of Array.from(X)){let z=H.get(F),q=F.getIndices();if(G.get(q)!==z||F.listAttributes().some((U)=>G.get(U)!==z))throw new Error(`[${N8}] Draco primitives must share all, or no, accessors.`)}for(let F of Array.from(Y)){let z=F.getIndices();if(G.has(z)||F.listAttributes().some((q)=>G.has(q)))throw new Error(`[${N8}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return H}function fa(Z,J){let X=[],Y=Z.getIndices();X.push(J.get(Y));for(let $ of Z.listAttributes())X.push(J.get($));return X.sort().join("|")}class CK extends i1{init(){this.extensionName=TC,this.propertyType="Light",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:CK.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(Z){return this.set("color",Z)}getIntensity(){return this.get("intensity")}setIntensity(Z){return this.set("intensity",Z)}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getRange(){return this.get("range")}setRange(Z){return this.set("range",Z)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(Z){return this.set("innerConeAngle",Z)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(Z){return this.set("outerConeAngle",Z)}}CK.EXTENSION_NAME=TC;CK.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};var L7=TC;class dC extends E1{constructor(...Z){super(...Z);this.extensionName=L7}createLight(Z=""){return new CK(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[L7])return this;let $=(J.json.extensions[L7].lights||[]).map((Q)=>{var K,W;let G=this.createLight().setName(Q.name||"").setType(Q.type);if(Q.color!==void 0)G.setColor(Q.color);if(Q.intensity!==void 0)G.setIntensity(Q.intensity);if(Q.range!==void 0)G.setRange(Q.range);if(((K=Q.spot)==null?void 0:K.innerConeAngle)!==void 0)G.setInnerConeAngle(Q.spot.innerConeAngle);if(((W=Q.spot)==null?void 0:W.outerConeAngle)!==void 0)G.setOuterConeAngle(Q.spot.outerConeAngle);return G});return J.json.nodes.forEach((Q,K)=>{if(!Q.extensions||!Q.extensions[L7])return;let W=Q.extensions[L7];Z.nodes[K].setExtension(L7,$[W.light])}),this}write(Z){let J=Z.jsonDoc;if(this.properties.size===0)return this;let X=[],Y=new Map;for(let $ of this.properties){let Q=$,K={type:Q.getType()};if(!K8.eq(Q.getColor(),[1,1,1]))K.color=Q.getColor();if(Q.getIntensity()!==1)K.intensity=Q.getIntensity();if(Q.getRange()!=null)K.range=Q.getRange();if(Q.getName())K.name=Q.getName();if(Q.getType()===CK.Type.SPOT)K.spot={innerConeAngle:Q.getInnerConeAngle(),outerConeAngle:Q.getOuterConeAngle()};X.push(K),Y.set(Q,X.length-1)}return this.document.getRoot().listNodes().forEach(($)=>{let Q=$.getExtension(L7);if(Q){let K=Z.nodeIndexMap.get($),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[L7]={light:Y.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[L7]={lights:X},this}}dC.EXTENSION_NAME=L7;var{R:CR1,G:TR1,B:ER1}=r5;class cC extends i1{init(){this.extensionName=EC,this.propertyType="Anisotropy",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new D1(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(Z){return this.set("anisotropyStrength",Z)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(Z){return this.set("anisotropyRotation",Z)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(Z){return this.setRef("anisotropyTexture",Z,{channels:CR1|TR1|ER1})}}cC.EXTENSION_NAME=EC;var kY=EC;class lC extends E1{constructor(...Z){super(...Z);this.extensionName=kY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createAnisotropy(){return new cC(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[kY]){let K=this.createAnisotropy();Z.materials[Q].setExtension(kY,K);let W=$.extensions[kY];if(W.anisotropyStrength!==void 0)K.setAnisotropyStrength(W.anisotropyStrength);if(W.anisotropyRotation!==void 0)K.setAnisotropyRotation(W.anisotropyRotation);if(W.anisotropyTexture!==void 0){let G=W.anisotropyTexture,V=Z.textures[Y[G.index].source];K.setAnisotropyTexture(V),Z.setTextureInfo(K.getAnisotropyTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(kY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[kY]={};if(Y.getAnisotropyStrength()>0)K.anisotropyStrength=Y.getAnisotropyStrength();if(Y.getAnisotropyRotation()!==0)K.anisotropyRotation=Y.getAnisotropyRotation();if(Y.getAnisotropyTexture()){let W=Y.getAnisotropyTexture(),G=Y.getAnisotropyTextureInfo();K.anisotropyTexture=Z.createTextureInfoDef(W,G)}}}),this}}lC.EXTENSION_NAME=kY;var{R:ya,G:ba,B:kR1}=r5;class pC extends i1{init(){this.extensionName=kC,this.propertyType="Clearcoat",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new D1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new D1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new D1(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(Z){return this.set("clearcoatFactor",Z)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(Z){return this.setRef("clearcoatTexture",Z,{channels:ya})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(Z){return this.set("clearcoatRoughnessFactor",Z)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(Z){return this.setRef("clearcoatRoughnessTexture",Z,{channels:ba})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(Z){return this.set("clearcoatNormalScale",Z)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(Z){return this.setRef("clearcoatNormalTexture",Z,{channels:ya|ba|kR1})}}pC.EXTENSION_NAME=kC;var IY=kC;class iC extends E1{constructor(...Z){super(...Z);this.extensionName=IY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createClearcoat(){return new pC(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[IY]){let K=this.createClearcoat();Z.materials[Q].setExtension(IY,K);let W=$.extensions[IY];if(W.clearcoatFactor!==void 0)K.setClearcoatFactor(W.clearcoatFactor);if(W.clearcoatRoughnessFactor!==void 0)K.setClearcoatRoughnessFactor(W.clearcoatRoughnessFactor);if(W.clearcoatTexture!==void 0){let G=W.clearcoatTexture,V=Z.textures[Y[G.index].source];K.setClearcoatTexture(V),Z.setTextureInfo(K.getClearcoatTextureInfo(),G)}if(W.clearcoatRoughnessTexture!==void 0){let G=W.clearcoatRoughnessTexture,V=Z.textures[Y[G.index].source];K.setClearcoatRoughnessTexture(V),Z.setTextureInfo(K.getClearcoatRoughnessTextureInfo(),G)}if(W.clearcoatNormalTexture!==void 0){let G=W.clearcoatNormalTexture,V=Z.textures[Y[G.index].source];if(K.setClearcoatNormalTexture(V),Z.setTextureInfo(K.getClearcoatNormalTextureInfo(),G),G.scale!==void 0)K.setClearcoatNormalScale(G.scale)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(IY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[IY]={clearcoatFactor:Y.getClearcoatFactor(),clearcoatRoughnessFactor:Y.getClearcoatRoughnessFactor()};if(Y.getClearcoatTexture()){let W=Y.getClearcoatTexture(),G=Y.getClearcoatTextureInfo();K.clearcoatTexture=Z.createTextureInfoDef(W,G)}if(Y.getClearcoatRoughnessTexture()){let W=Y.getClearcoatRoughnessTexture(),G=Y.getClearcoatRoughnessTextureInfo();K.clearcoatRoughnessTexture=Z.createTextureInfoDef(W,G)}if(Y.getClearcoatNormalTexture()){let W=Y.getClearcoatNormalTexture(),G=Y.getClearcoatNormalTextureInfo();if(K.clearcoatNormalTexture=Z.createTextureInfoDef(W,G),Y.getClearcoatNormalScale()!==1)K.clearcoatNormalTexture.scale=Y.getClearcoatNormalScale()}}}),this}}iC.EXTENSION_NAME=IY;var{R:IR1,G:_R1,B:vR1,A:SR1}=r5;class nC extends i1{init(){this.extensionName=IC,this.propertyType="DiffuseTransmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new D1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new D1(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(Z){return this.set("diffuseTransmissionFactor",Z)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(Z){return this.setRef("diffuseTransmissionTexture",Z,{channels:SR1})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(Z){return this.set("diffuseTransmissionColorFactor",Z)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(Z){return this.setRef("diffuseTransmissionColorTexture",Z,{channels:IR1|_R1|vR1})}}nC.EXTENSION_NAME=IC;var _Y=IC;class aC extends E1{constructor(...Z){super(...Z);this.extensionName=_Y}createDiffuseTransmission(){return new nC(this.document.getGraph())}read(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[_Y]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(_Y,K);let W=$.extensions[_Y];if(W.diffuseTransmissionFactor!==void 0)K.setDiffuseTransmissionFactor(W.diffuseTransmissionFactor);if(W.diffuseTransmissionColorFactor!==void 0)K.setDiffuseTransmissionColorFactor(W.diffuseTransmissionColorFactor);if(W.diffuseTransmissionTexture!==void 0){let G=W.diffuseTransmissionTexture,V=Z.textures[Y[G.index].source];K.setDiffuseTransmissionTexture(V),Z.setTextureInfo(K.getDiffuseTransmissionTextureInfo(),G)}if(W.diffuseTransmissionColorTexture!==void 0){let G=W.diffuseTransmissionColorTexture,V=Z.textures[Y[G.index].source];K.setDiffuseTransmissionColorTexture(V),Z.setTextureInfo(K.getDiffuseTransmissionColorTextureInfo(),G)}}}),this}write(Z){let J=Z.jsonDoc;for(let X of this.document.getRoot().listMaterials()){let Y=X.getExtension(_Y);if(!Y)continue;let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[_Y]={diffuseTransmissionFactor:Y.getDiffuseTransmissionFactor(),diffuseTransmissionColorFactor:Y.getDiffuseTransmissionColorFactor()};if(Y.getDiffuseTransmissionTexture()){let W=Y.getDiffuseTransmissionTexture(),G=Y.getDiffuseTransmissionTextureInfo();K.diffuseTransmissionTexture=Z.createTextureInfoDef(W,G)}if(Y.getDiffuseTransmissionColorTexture()){let W=Y.getDiffuseTransmissionColorTexture(),G=Y.getDiffuseTransmissionColorTextureInfo();K.diffuseTransmissionColorTexture=Z.createTextureInfoDef(W,G)}}return this}}aC.EXTENSION_NAME=_Y;class sC extends i1{init(){this.extensionName=_C,this.propertyType="Dispersion",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(Z){return this.set("dispersion",Z)}}sC.EXTENSION_NAME=_C;var vY=_C;class oC extends E1{constructor(...Z){super(...Z);this.extensionName=vY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createDispersion(){return new sC(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[vY]){let Q=this.createDispersion();Z.materials[$].setExtension(vY,Q);let K=Y.extensions[vY];if(K.dispersion!==void 0)Q.setDispersion(K.dispersion)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(vY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[vY]={dispersion:Y.getDispersion()}}}),this}}oC.EXTENSION_NAME=vY;class rC extends i1{init(){this.extensionName=vC,this.propertyType="EmissiveStrength",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(Z){return this.set("emissiveStrength",Z)}}rC.EXTENSION_NAME=vC;var SY=vC;class tC extends E1{constructor(...Z){super(...Z);this.extensionName=SY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createEmissiveStrength(){return new rC(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[SY]){let Q=this.createEmissiveStrength();Z.materials[$].setExtension(SY,Q);let K=Y.extensions[SY];if(K.emissiveStrength!==void 0)Q.setEmissiveStrength(K.emissiveStrength)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(SY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[SY]={emissiveStrength:Y.getEmissiveStrength()}}}),this}}tC.EXTENSION_NAME=SY;class eC extends i1{init(){this.extensionName=SC,this.propertyType="IOR",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(Z){return this.set("ior",Z)}}eC.EXTENSION_NAME=SC;var AY=SC;class cB extends E1{constructor(...Z){super(...Z);this.extensionName=AY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIOR(){return new eC(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[AY]){let Q=this.createIOR();Z.materials[$].setExtension(AY,Q);let K=Y.extensions[AY];if(K.ior!==void 0)Q.setIOR(K.ior)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(AY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[AY]={ior:Y.getIOR()}}}),this}}cB.EXTENSION_NAME=AY;var{R:AR1,G:xR1}=r5;class ZT extends i1{init(){this.extensionName=AC,this.propertyType="Iridescence",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new D1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new D1(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(Z){return this.set("iridescenceFactor",Z)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(Z){return this.setRef("iridescenceTexture",Z,{channels:AR1})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(Z){return this.set("iridescenceIOR",Z)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(Z){return this.set("iridescenceThicknessMinimum",Z)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(Z){return this.set("iridescenceThicknessMaximum",Z)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(Z){return this.setRef("iridescenceThicknessTexture",Z,{channels:xR1})}}ZT.EXTENSION_NAME=AC;var xY=AC;class JT extends E1{constructor(...Z){super(...Z);this.extensionName=xY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIridescence(){return new ZT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[xY]){let K=this.createIridescence();Z.materials[Q].setExtension(xY,K);let W=$.extensions[xY];if(W.iridescenceFactor!==void 0)K.setIridescenceFactor(W.iridescenceFactor);if(W.iridescenceIor!==void 0)K.setIridescenceIOR(W.iridescenceIor);if(W.iridescenceThicknessMinimum!==void 0)K.setIridescenceThicknessMinimum(W.iridescenceThicknessMinimum);if(W.iridescenceThicknessMaximum!==void 0)K.setIridescenceThicknessMaximum(W.iridescenceThicknessMaximum);if(W.iridescenceTexture!==void 0){let G=W.iridescenceTexture,V=Z.textures[Y[G.index].source];K.setIridescenceTexture(V),Z.setTextureInfo(K.getIridescenceTextureInfo(),G)}if(W.iridescenceThicknessTexture!==void 0){let G=W.iridescenceThicknessTexture,V=Z.textures[Y[G.index].source];K.setIridescenceThicknessTexture(V),Z.setTextureInfo(K.getIridescenceThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(xY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[xY]={};if(Y.getIridescenceFactor()>0)K.iridescenceFactor=Y.getIridescenceFactor();if(Y.getIridescenceIOR()!==1.3)K.iridescenceIor=Y.getIridescenceIOR();if(Y.getIridescenceThicknessMinimum()!==100)K.iridescenceThicknessMinimum=Y.getIridescenceThicknessMinimum();if(Y.getIridescenceThicknessMaximum()!==400)K.iridescenceThicknessMaximum=Y.getIridescenceThicknessMaximum();if(Y.getIridescenceTexture()){let W=Y.getIridescenceTexture(),G=Y.getIridescenceTextureInfo();K.iridescenceTexture=Z.createTextureInfoDef(W,G)}if(Y.getIridescenceThicknessTexture()){let W=Y.getIridescenceThicknessTexture(),G=Y.getIridescenceThicknessTextureInfo();K.iridescenceThicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}JT.EXTENSION_NAME=xY;var{R:ga,G:ma,B:ua,A:da}=r5;class XT extends i1{init(){this.extensionName=xC,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new D1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new D1(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(Z){return this.set("diffuseFactor",Z)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(Z){return this.setRef("diffuseTexture",Z,{channels:ga|ma|ua|da,isColor:!0})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(Z){return this.set("specularFactor",Z)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(Z){return this.set("glossinessFactor",Z)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(Z){return this.setRef("specularGlossinessTexture",Z,{channels:ga|ma|ua|da})}}XT.EXTENSION_NAME=xC;var hY=xC;class lB extends E1{constructor(...Z){super(...Z);this.extensionName=hY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createPBRSpecularGlossiness(){return new XT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[hY]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(hY,K);let W=$.extensions[hY];if(W.diffuseFactor!==void 0)K.setDiffuseFactor(W.diffuseFactor);if(W.specularFactor!==void 0)K.setSpecularFactor(W.specularFactor);if(W.glossinessFactor!==void 0)K.setGlossinessFactor(W.glossinessFactor);if(W.diffuseTexture!==void 0){let G=W.diffuseTexture,V=Z.textures[Y[G.index].source];K.setDiffuseTexture(V),Z.setTextureInfo(K.getDiffuseTextureInfo(),G)}if(W.specularGlossinessTexture!==void 0){let G=W.specularGlossinessTexture,V=Z.textures[Y[G.index].source];K.setSpecularGlossinessTexture(V),Z.setTextureInfo(K.getSpecularGlossinessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(hY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[hY]={diffuseFactor:Y.getDiffuseFactor(),specularFactor:Y.getSpecularFactor(),glossinessFactor:Y.getGlossinessFactor()};if(Y.getDiffuseTexture()){let W=Y.getDiffuseTexture(),G=Y.getDiffuseTextureInfo();K.diffuseTexture=Z.createTextureInfoDef(W,G)}if(Y.getSpecularGlossinessTexture()){let W=Y.getSpecularGlossinessTexture(),G=Y.getSpecularGlossinessTextureInfo();K.specularGlossinessTexture=Z.createTextureInfoDef(W,G)}}}),this}}lB.EXTENSION_NAME=hY;var{R:hR1,G:fR1,B:yR1,A:bR1}=r5;class YT extends i1{init(){this.extensionName=hC,this.propertyType="Sheen",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new D1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new D1(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(Z){return this.set("sheenColorFactor",Z)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(Z){return this.setRef("sheenColorTexture",Z,{channels:hR1|fR1|yR1,isColor:!0})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(Z){return this.set("sheenRoughnessFactor",Z)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(Z){return this.setRef("sheenRoughnessTexture",Z,{channels:bR1})}}YT.EXTENSION_NAME=hC;var fY=hC;class $T extends E1{constructor(...Z){super(...Z);this.extensionName=fY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSheen(){return new YT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[fY]){let K=this.createSheen();Z.materials[Q].setExtension(fY,K);let W=$.extensions[fY];if(W.sheenColorFactor!==void 0)K.setSheenColorFactor(W.sheenColorFactor);if(W.sheenRoughnessFactor!==void 0)K.setSheenRoughnessFactor(W.sheenRoughnessFactor);if(W.sheenColorTexture!==void 0){let G=W.sheenColorTexture,V=Z.textures[Y[G.index].source];K.setSheenColorTexture(V),Z.setTextureInfo(K.getSheenColorTextureInfo(),G)}if(W.sheenRoughnessTexture!==void 0){let G=W.sheenRoughnessTexture,V=Z.textures[Y[G.index].source];K.setSheenRoughnessTexture(V),Z.setTextureInfo(K.getSheenRoughnessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(fY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[fY]={sheenColorFactor:Y.getSheenColorFactor(),sheenRoughnessFactor:Y.getSheenRoughnessFactor()};if(Y.getSheenColorTexture()){let W=Y.getSheenColorTexture(),G=Y.getSheenColorTextureInfo();K.sheenColorTexture=Z.createTextureInfoDef(W,G)}if(Y.getSheenRoughnessTexture()){let W=Y.getSheenRoughnessTexture(),G=Y.getSheenRoughnessTextureInfo();K.sheenRoughnessTexture=Z.createTextureInfoDef(W,G)}}}),this}}$T.EXTENSION_NAME=fY;var{R:gR1,G:mR1,B:uR1,A:dR1}=r5;class QT extends i1{init(){this.extensionName=fC,this.propertyType="Specular",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new D1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new D1(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(Z){return this.set("specularFactor",Z)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(Z){return this.set("specularColorFactor",Z)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(Z){return this.setRef("specularTexture",Z,{channels:dR1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:gR1|mR1|uR1,isColor:!0})}}QT.EXTENSION_NAME=fC;var yY=fC;class pB extends E1{constructor(...Z){super(...Z);this.extensionName=yY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSpecular(){return new QT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[yY]){let K=this.createSpecular();Z.materials[Q].setExtension(yY,K);let W=$.extensions[yY];if(W.specularFactor!==void 0)K.setSpecularFactor(W.specularFactor);if(W.specularColorFactor!==void 0)K.setSpecularColorFactor(W.specularColorFactor);if(W.specularTexture!==void 0){let G=W.specularTexture,V=Z.textures[Y[G.index].source];K.setSpecularTexture(V),Z.setTextureInfo(K.getSpecularTextureInfo(),G)}if(W.specularColorTexture!==void 0){let G=W.specularColorTexture,V=Z.textures[Y[G.index].source];K.setSpecularColorTexture(V),Z.setTextureInfo(K.getSpecularColorTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(yY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[yY]={};if(Y.getSpecularFactor()!==1)K.specularFactor=Y.getSpecularFactor();if(!K8.eq(Y.getSpecularColorFactor(),[1,1,1]))K.specularColorFactor=Y.getSpecularColorFactor();if(Y.getSpecularTexture()){let W=Y.getSpecularTexture(),G=Y.getSpecularTextureInfo();K.specularTexture=Z.createTextureInfoDef(W,G)}if(Y.getSpecularColorTexture()){let W=Y.getSpecularColorTexture(),G=Y.getSpecularColorTextureInfo();K.specularColorTexture=Z.createTextureInfoDef(W,G)}}}),this}}pB.EXTENSION_NAME=yY;var{R:cR1}=r5;class KT extends i1{init(){this.extensionName=yC,this.propertyType="Transmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new D1(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(Z){return this.set("transmissionFactor",Z)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(Z){return this.setRef("transmissionTexture",Z,{channels:cR1})}}KT.EXTENSION_NAME=yC;var bY=yC;class WT extends E1{constructor(...Z){super(...Z);this.extensionName=bY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createTransmission(){return new KT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[bY]){let K=this.createTransmission();Z.materials[Q].setExtension(bY,K);let W=$.extensions[bY];if(W.transmissionFactor!==void 0)K.setTransmissionFactor(W.transmissionFactor);if(W.transmissionTexture!==void 0){let G=W.transmissionTexture,V=Z.textures[Y[G.index].source];K.setTransmissionTexture(V),Z.setTextureInfo(K.getTransmissionTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(bY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[bY]={transmissionFactor:Y.getTransmissionFactor()};if(Y.getTransmissionTexture()){let W=Y.getTransmissionTexture(),G=Y.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(W,G)}}}),this}}WT.EXTENSION_NAME=bY;class GT extends i1{init(){this.extensionName=bC,this.propertyType="Unlit",this.parentTypes=[s.MATERIAL]}}GT.EXTENSION_NAME=bC;var PK=bC;class iB extends E1{constructor(...Z){super(...Z);this.extensionName=PK,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createUnlit(){return new GT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((X,Y)=>{if(X.extensions&&X.extensions[PK])Z.materials[Y].setExtension(PK,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(PK)){let Y=Z.materialIndexMap.get(X),$=J.json.materials[Y];$.extensions=$.extensions||{},$.extensions[PK]={}}}),this}}iB.EXTENSION_NAME=PK;class VT extends i1{init(){this.extensionName=uY,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new D0})}getMaterial(){return this.getRef("material")}setMaterial(Z){return this.setRef("material",Z)}addVariant(Z){return this.addRef("variants",Z)}removeVariant(Z){return this.removeRef("variants",Z)}listVariants(){return this.listRefs("variants")}}VT.EXTENSION_NAME=uY;class HT extends i1{init(){this.extensionName=uY,this.propertyType="MappingList",this.parentTypes=[s.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new D0})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}HT.EXTENSION_NAME=uY;class gB extends i1{init(){this.extensionName=uY,this.propertyType="Variant",this.parentTypes=["MappingList"]}}gB.EXTENSION_NAME=uY;var B7=uY;class zT extends E1{constructor(...Z){super(...Z);this.extensionName=B7}createMappingList(){return new HT(this.document.getGraph())}createVariant(Z=""){return new gB(this.document.getGraph(),Z)}createMapping(){return new VT(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof gB)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[B7])return this;let $=(J.json.extensions[B7].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,W)=>{let G=Z.meshes[W];(K.primitives||[]).forEach((H,F)=>{if(!H.extensions||!H.extensions[B7])return;let z=this.createMappingList(),q=H.extensions[B7];for(let U of q.mappings){let L=this.createMapping();if(U.material!==void 0)L.setMaterial(Z.materials[U.material]);for(let B of U.variants||[])L.addVariant($[B]);z.addMapping(L)}G.listPrimitives()[F].setExtension(B7,z)})}),this}write(Z){let J=Z.jsonDoc,X=this.listVariants();if(!X.length)return this;let Y=[],$=new Map;for(let Q of X)$.set(Q,Y.length),Y.push(Z.createPropertyDef(Q));for(let Q of this.document.getRoot().listMeshes()){let K=Z.meshIndexMap.get(Q);Q.listPrimitives().forEach((W,G)=>{let V=W.getExtension(B7);if(!V)return;let H=Z.jsonDoc.json.meshes[K].primitives[G],F=V.listMappings().map((z)=>{let q=Z.createPropertyDef(z),U=z.getMaterial();if(U)q.material=Z.materialIndexMap.get(U);return q.variants=z.listVariants().map((L)=>$.get(L)),q});H.extensions=H.extensions||{},H.extensions[B7]={mappings:F}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[B7]={variants:Y},this}}zT.EXTENSION_NAME=B7;var{G:lR1}=r5;class FT extends i1{init(){this.extensionName=gC,this.propertyType="Volume",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new D1(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(Z){return this.set("thicknessFactor",Z)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(Z){return this.setRef("thicknessTexture",Z,{channels:lR1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}FT.EXTENSION_NAME=gC;var gY=gC;class qT extends E1{constructor(...Z){super(...Z);this.extensionName=gY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createVolume(){return new FT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[gY]){let K=this.createVolume();Z.materials[Q].setExtension(gY,K);let W=$.extensions[gY];if(W.thicknessFactor!==void 0)K.setThicknessFactor(W.thicknessFactor);if(W.attenuationDistance!==void 0)K.setAttenuationDistance(W.attenuationDistance);if(W.attenuationColor!==void 0)K.setAttenuationColor(W.attenuationColor);if(W.thicknessTexture!==void 0){let G=W.thicknessTexture,V=Z.textures[Y[G.index].source];K.setThicknessTexture(V),Z.setTextureInfo(K.getThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(gY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[gY]={};if(Y.getThicknessFactor()>0)K.thicknessFactor=Y.getThicknessFactor();if(Number.isFinite(Y.getAttenuationDistance()))K.attenuationDistance=Y.getAttenuationDistance();if(!K8.eq(Y.getAttenuationColor(),[1,1,1]))K.attenuationColor=Y.getAttenuationColor();if(Y.getThicknessTexture()){let W=Y.getThicknessTexture(),G=Y.getThicknessTextureInfo();K.thicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}qT.EXTENSION_NAME=gY;var oa=QR1;class CV extends E1{constructor(...Z){super(...Z);this.extensionName=oa}read(Z){return this}write(Z){return this}}CV.EXTENSION_NAME=oa;var NV=KR1;class ra{match(Z){return Z[0]===171&&Z[1]===75&&Z[2]===84&&Z[3]===88&&Z[4]===32&&Z[5]===50&&Z[6]===48&&Z[7]===187&&Z[8]===13&&Z[9]===10&&Z[10]===26&&Z[11]===10}getSize(Z){let J=fB(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=fB(Z).dataFormatDescriptor[0];if(X.colorModel===ka)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===Ia)return(X.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=fB(Z),X=this.getChannels(Z)>3,Y=0;for(let $=0;$<J.levels.length;$++){let Q=J.levels[$];if(Q.uncompressedByteLength)Y+=Q.uncompressedByteLength;else{let K=Math.max(1,Math.floor(J.pixelWidth/Math.pow(2,$))),W=Math.max(1,Math.floor(J.pixelHeight/Math.pow(2,$))),G=X?16:8;Y+=K/4*(W/4)*G}}return Y}}class UT extends E1{constructor(...Z){super(...Z);this.extensionName=NV,this.prereadTypes=[s.TEXTURE]}static register(){N4.registerFormat("image/ktx2",new ra)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[NV]){let X=J.extensions[NV];J.source=X.source}}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/ktx2"){let Y=Z.imageIndexMap.get(X);J.json.textures.forEach(($)=>{if($.source===Y)$.extensions=$.extensions||{},$.extensions[NV]={source:$.source},delete $.source})}}),this}}UT.EXTENSION_NAME=NV;class LT extends i1{init(){this.extensionName=mC,this.propertyType="Transform",this.parentTypes=[s.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(Z){return this.set("offset",Z)}getRotation(){return this.get("rotation")}setRotation(Z){return this.set("rotation",Z)}getScale(){return this.get("scale")}setScale(Z){return this.set("scale",Z)}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}}LT.EXTENSION_NAME=mC;var mY=mC;class BT extends E1{constructor(...Z){super(...Z);this.extensionName=mY}createTransform(){return new LT(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[mY])continue;let Y=this.createTransform(),$=X.extensions[mY];if($.offset!==void 0)Y.setOffset($.offset);if($.rotation!==void 0)Y.setRotation($.rotation);if($.scale!==void 0)Y.setScale($.scale);if($.texCoord!==void 0)Y.setTexCoord($.texCoord);J.setExtension(mY,Y)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,Y]of J){let $=X.getExtension(mY);if(!$)continue;Y.extensions=Y.extensions||{};let Q={},K=K8.eq;if(!K($.getOffset(),[0,0]))Q.offset=$.getOffset();if($.getRotation()!==0)Q.rotation=$.getRotation();if(!K($.getScale(),[1,1]))Q.scale=$.getScale();if($.getTexCoord()!=null)Q.texCoord=$.getTexCoord();Y.extensions[mY]=Q}return this}}BT.EXTENSION_NAME=mY;var pR1=[s.ROOT,s.SCENE,s.NODE,s.MESH,s.MATERIAL,s.TEXTURE,s.ANIMATION];class wT extends i1{init(){this.extensionName=yB,this.propertyType="Packet",this.parentTypes=pR1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",NZ({},Z))}listProperties(){return Object.keys(this.get("properties"))}getProperty(Z){let J=this.get("properties");return Z in J?J[Z]:null}setProperty(Z,J){this._assertContext(Z);let X=NZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=RC(this.get("context")),J=RC(this.get("properties"));return NZ({"@context":Z},J)}fromJSONLD(Z){Z=RC(Z);let J=Z["@context"];if(J)this.set("context",J);return delete Z["@context"],this.set("properties",Z)}_assertContext(Z){if(!(Z.split(":")[0]in this.get("context")))throw new Error(`${yB}: Missing context for term, "${Z}".`)}}wT.EXTENSION_NAME=yB;function RC(Z){return JSON.parse(JSON.stringify(Z))}var OZ=yB;class jT extends E1{constructor(...Z){super(...Z);this.extensionName=OZ}createPacket(){return new wT(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[OZ];if(!X||!X.packets)return this;let Y=Z.jsonDoc.json,$=this.document.getRoot(),Q=X.packets.map((G)=>this.createPacket().fromJSONLD(G)),K=[[Y.asset],Y.scenes,Y.nodes,Y.meshes,Y.materials,Y.images,Y.animations],W=[[$],$.listScenes(),$.listNodes(),$.listMeshes(),$.listMaterials(),$.listTextures(),$.listAnimations()];for(let G=0;G<K.length;G++){let V=K[G]||[];for(let H=0;H<V.length;H++){let F=V[H];if(F.extensions&&F.extensions[OZ]){let z=F.extensions[OZ];W[G][H].setExtension(OZ,Q[z.packet])}}}return this}write(Z){let{json:J}=Z.jsonDoc,X=[];for(let Y of this.properties){X.push(Y.toJSONLD());for(let $ of Y.listParents()){let Q;switch($.propertyType){case s.ROOT:Q=J.asset;break;case s.SCENE:Q=J.scenes[Z.sceneIndexMap.get($)];break;case s.NODE:Q=J.nodes[Z.nodeIndexMap.get($)];break;case s.MESH:Q=J.meshes[Z.meshIndexMap.get($)];break;case s.MATERIAL:Q=J.materials[Z.materialIndexMap.get($)];break;case s.TEXTURE:Q=J.images[Z.imageIndexMap.get($)];break;case s.ANIMATION:Q=J.animations[Z.animationIndexMap.get($)];break;default:Q=null,this.document.getLogger().warn(`[${OZ}]: Unsupported parent property, "${$.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[OZ]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[OZ]={packets:X};return this}}jT.EXTENSION_NAME=OZ;var iR1=[DV,dC,lC,iC,aC,oC,tC,cB,JT,lB,pB,$T,WT,iB,zT,qT,CV,UT,BT,jT],iT6=[mB,PV,uB,dB,...iR1];var nR1=r(xD(),1);function kK(){return kK=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},kK.apply(null,arguments)}var{POINTS:ta,LINES:nB,LINE_STRIP:aR1,LINE_LOOP:sR1,TRIANGLES:aB,TRIANGLE_STRIP:oR1,TRIANGLE_FAN:rR1}=j8.Mode;function mJ(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function w7(Z,J){let X=kK({},Z);for(let Y in J)if(J[Y]!==void 0)X[Y]=J[Y];return X}function js(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case j8.Mode.POINTS:return J?J.getCount():X.getCount();case j8.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case j8.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case j8.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case j8.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case j8.Mode.TRIANGLE_STRIP:case j8.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw new Error("Unexpected mode: "+Z.getMode())}}var tR1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function MT(Z){return tR1.format(Z)}function eR1(Z,J,X=2){let Y=Z>J?"–":"+",$="%";return Y+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function eB(Z,J){return`${MT(Z)} → ${MT(J)} (${eR1(Z,J)})`}function IT(Z){let J=[];for(let X of Z.listAttributes())J.push(X);for(let X of Z.listTargets())for(let Y of X.listAttributes())J.push(Y);return Array.from(new Set(J))}function ZM1(Z,J,X){Z.swap(J,X);for(let Y of Z.listTargets())Y.swap(J,X)}function JM1(Z,J){if(Z==null&&J==null)return!0;if(Z==null||J==null)return!1;if(Z.length!==J.length)return!1;for(let X=0;X<Z.length;X++)if(Z[X]!==J[X])return!1;return!0}function RZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function XM1(Z,J=Z){let X=_T(Z,J);for(let Y=0;Y<X.length;Y++)X[Y]=Y;return X}function _T(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function YM1(Z){return Z.listParents().some((J)=>J.propertyType!==a.ROOT)}function Os(Z){for(let J in Z)return!1;return!0}function Ns(Z){let J=k6.fromGraph(Z.getGraph()),X=Z.getMaterial(),Y=J.getRoot().listMaterials().indexOf(X),$=QM1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((G)=>{let V=Z.getAttribute(G),H=V.getElementSize(),F=V.getComponentType();return`${G}:${H}:${F}`}).join("+"),W=Z.listTargets().map((G)=>{return G.listSemantics().sort().map((V)=>{let H=Z.getAttribute(V),F=H.getElementSize(),z=H.getComponentType();return`${V}:${F}:${z}`}).join("+")}).join("~");return`${Y}|${$}|${Q}|${K}|${W}`}function $M1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var QM1={[ta]:ta,[nB]:nB,[aR1]:nB,[sR1]:nB,[aB]:aB,[oR1]:aB,[rR1]:aB},TK="center",ea={pivot:"center"};function Rs(Z=ea){let J=w7(ea,Z);return mJ(TK,(X)=>{let Y=X.getLogger(),$=X.getRoot(),Q=$.listAnimations().length>0||$.listSkins().length>0;X.getRoot().listScenes().forEach((K,W)=>{Y.debug(`${TK}: Scene ${W+1} / ${$.listScenes().length}.`);let G;if(typeof J.pivot==="string"){let H=ED(K);if(G=[(H.max[0]-H.min[0])/2+H.min[0],(H.max[1]-H.min[1])/2+H.min[1],(H.max[2]-H.min[2])/2+H.min[2]],J.pivot==="above")G[1]=H.max[1];if(J.pivot==="below")G[1]=H.min[1]}else G=J.pivot;Y.debug(`${TK}: Pivot "${G.join(", ")}".`);let V=[-1*G[0],-1*G[1],-1*G[2]];if(Q){Y.debug(`${TK}: Model contains animation or skin. Adding a wrapper node.`);let H=X.createNode("Pivot").setTranslation(V);K.listChildren().forEach((F)=>H.addChild(F)),K.addChild(H)}else Y.debug(`${TK}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((H)=>{let F=H.getTranslation();H.setTranslation([F[0]+V[0],F[1]+V[1],F[2]+V[2]])})}),Y.debug(`${TK}: Complete.`)})}function KM1(Z){let J=new Set,X=Z,Y;while(Y=X.getParentNode()){if(J.has(Y))throw new Error("Circular dependency in scene graph.");J.add(Y),X=Y}return X.listParents().filter(($)=>$ instanceof zK)}function WM1(Z){let J=KM1(Z),X=Z.getParentNode();if(!X)return Z;Z.setMatrix(Z.getWorldMatrix()),X.removeChild(Z);for(let Y of J)Y.addChild(Z);return Z}var IK=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function GM1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],V=J[7],H=J[8],F=J[9],z=J[10],q=J[11],U=J[12],L=J[13],B=J[14],w=J[15],O=X*W-Y*K,N=X*G-$*K,R=X*V-Q*K,D=Y*G-$*W,M=Y*V-Q*W,C=$*V-Q*G,T=H*L-F*U,E=H*B-z*U,x=H*w-q*U,v=F*B-z*L,S=F*w-q*L,I=z*w-q*B,_=O*I-N*S+R*v+D*x-M*E+C*T;if(!_)return null;return _=1/_,Z[0]=(W*I-G*S+V*v)*_,Z[1]=($*S-Y*I-Q*v)*_,Z[2]=(L*C-B*M+w*D)*_,Z[3]=(z*M-F*C-q*D)*_,Z[4]=(G*x-K*I-V*E)*_,Z[5]=(X*I-$*x+Q*E)*_,Z[6]=(B*R-U*C-w*N)*_,Z[7]=(H*C-z*R+q*N)*_,Z[8]=(K*S-W*x+V*T)*_,Z[9]=(Y*x-X*S-Q*T)*_,Z[10]=(U*M-L*R+w*O)*_,Z[11]=(F*R-H*M-q*O)*_,Z[12]=(W*E-K*v-G*T)*_,Z[13]=(X*v-Y*E+$*T)*_,Z[14]=(L*N-U*D-B*O)*_,Z[15]=(H*D-F*N+z*O)*_,Z}function VM1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],V=Z[8],H=Z[9],F=Z[10],z=Z[11],q=Z[12],U=Z[13],L=Z[14],B=Z[15],w=J*K-X*Q,O=J*W-Y*Q,N=J*G-$*Q,R=X*W-Y*K,D=X*G-$*K,M=Y*G-$*W,C=V*U-H*q,T=V*L-F*q,E=V*B-z*q,x=H*L-F*U,v=H*B-z*U,S=F*B-z*L;return w*S-O*v+N*x+R*E-D*T+M*C}function Ms(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],V=J[6],H=J[7],F=J[8],z=J[9],q=J[10],U=J[11],L=J[12],B=J[13],w=J[14],O=J[15],N=X[0],R=X[1],D=X[2],M=X[3];return Z[0]=N*Y+R*W+D*F+M*L,Z[1]=N*$+R*G+D*z+M*B,Z[2]=N*Q+R*V+D*q+M*w,Z[3]=N*K+R*H+D*U+M*O,N=X[4],R=X[5],D=X[6],M=X[7],Z[4]=N*Y+R*W+D*F+M*L,Z[5]=N*$+R*G+D*z+M*B,Z[6]=N*Q+R*V+D*q+M*w,Z[7]=N*K+R*H+D*U+M*O,N=X[8],R=X[9],D=X[10],M=X[11],Z[8]=N*Y+R*W+D*F+M*L,Z[9]=N*$+R*G+D*z+M*B,Z[10]=N*Q+R*V+D*q+M*w,Z[11]=N*K+R*H+D*U+M*O,N=X[12],R=X[13],D=X[14],M=X[15],Z[12]=N*Y+R*W+D*F+M*L,Z[13]=N*$+R*G+D*z+M*B,Z[14]=N*Q+R*V+D*q+M*w,Z[15]=N*K+R*H+D*U+M*O,Z}function HM1(){var Z=new IK(9);if(IK!=Float32Array)Z[1]=0,Z[2]=0,Z[3]=0,Z[5]=0,Z[6]=0,Z[7]=0;return Z[0]=1,Z[4]=1,Z[8]=1,Z}function zM1(Z,J){return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[4],Z[4]=J[5],Z[5]=J[6],Z[6]=J[8],Z[7]=J[9],Z[8]=J[10],Z}function FM1(Z,J){if(Z===J){var X=J[1],Y=J[2],$=J[5];Z[1]=J[3],Z[2]=J[6],Z[3]=X,Z[5]=J[7],Z[6]=Y,Z[7]=$}else Z[0]=J[0],Z[1]=J[3],Z[2]=J[6],Z[3]=J[1],Z[4]=J[4],Z[5]=J[7],Z[6]=J[2],Z[7]=J[5],Z[8]=J[8];return Z}function qM1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],V=J[7],H=J[8],F=H*K-W*V,z=-H*Q+W*G,q=V*Q-K*G,U=X*F+Y*z+$*q;if(!U)return null;return U=1/U,Z[0]=F*U,Z[1]=(-H*Y+$*V)*U,Z[2]=(W*Y-$*K)*U,Z[3]=z*U,Z[4]=(H*X-$*G)*U,Z[5]=(-W*X+$*Q)*U,Z[6]=q*U,Z[7]=(-V*X+Y*G)*U,Z[8]=(K*X-Y*Q)*U,Z}function Z2(){var Z=new IK(3);if(IK!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function UM1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function Ps(Z,J){var X=J[0],Y=J[1],$=J[2],Q=X*X+Y*Y+$*$;if(Q>0)Q=1/Math.sqrt(Q);return Z[0]=J[0]*Q,Z[1]=J[1]*Q,Z[2]=J[2]*Q,Z}function LM1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=X[3]*Y+X[7]*$+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*Y+X[4]*$+X[8]*Q+X[12])/K,Z[1]=(X[1]*Y+X[5]*$+X[9]*Q+X[13])/K,Z[2]=(X[2]*Y+X[6]*$+X[10]*Q+X[14])/K,Z}function BM1(Z,J,X){var Y=J[0],$=J[1],Q=J[2];return Z[0]=Y*X[0]+$*X[3]+Q*X[6],Z[1]=Y*X[1]+$*X[4]+Q*X[7],Z[2]=Y*X[2]+$*X[5]+Q*X[8],Z}var wM1=UM1;(function(){var Z=Z2();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=3;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();var bJ="dedup",OT={keepUniqueNames:!1,propertyTypes:[a.ACCESSOR,a.MESH,a.TEXTURE,a.MATERIAL,a.SKIN]};function Ds(Z=OT){let J=w7(OT,Z),X=new Set(J.propertyTypes);for(let Y of J.propertyTypes)if(!OT.propertyTypes.includes(Y))throw new Error(`${bJ}: Unsupported deduplication on type "${Y}".`);return mJ(bJ,(Y)=>{let $=Y.getLogger();if(X.has(a.ACCESSOR))jM1(Y);if(X.has(a.TEXTURE))NM1(Y,J);if(X.has(a.MATERIAL))RM1(Y,J);if(X.has(a.MESH))OM1(Y,J);if(X.has(a.SKIN))MM1(Y,J);$.debug(`${bJ}: Complete.`)})}function jM1(Z){let J=Z.getLogger(),X=new Map,Y=new Map,$=new Map,Q=new Map,K=Z.getRoot().listMeshes();K.forEach((F)=>{F.listPrimitives().forEach((z)=>{z.listAttributes().forEach((q)=>W(q,Y)),W(z.getIndices(),X)})});for(let F of Z.getRoot().listAnimations())for(let z of F.listSamplers())W(z.getInput(),$),W(z.getOutput(),Q);function W(F,z){if(!F)return;let q=[F.getCount(),F.getType(),F.getComponentType(),F.getNormalized(),F.getSparse()].join(":"),U=z.get(q);if(!U)z.set(q,U=new Set);U.add(F)}function G(F,z){for(let q=0;q<F.length;q++){let U=F[q],L=n0.toView(U.getArray());if(z.has(U))continue;for(let B=q+1;B<F.length;B++){let w=F[B];if(z.has(w))continue;if(n0.equals(L,n0.toView(w.getArray())))z.set(w,U)}}}let V=0,H=new Map;for(let F of[Y,X,$,Q])for(let z of F.values())V+=z.size,G(Array.from(z),H);J.debug(`${bJ}: Merged ${H.size} of ${V} accessors.`),K.forEach((F)=>{F.listPrimitives().forEach((z)=>{z.listAttributes().forEach((U)=>{if(H.has(U))z.swap(U,H.get(U))});let q=z.getIndices();if(q&&H.has(q))z.swap(q,H.get(q))})});for(let F of Z.getRoot().listAnimations())for(let z of F.listSamplers()){let q=z.getInput(),U=z.getOutput();if(q&&H.has(q))z.swap(q,H.get(q));if(U&&H.has(U))z.swap(U,H.get(U))}Array.from(H.keys()).forEach((F)=>F.dispose())}function OM1(Z,J){let X=Z.getLogger(),Y=Z.getRoot(),$=new Map;Y.listAccessors().forEach((W,G)=>$.set(W,G)),Y.listMaterials().forEach((W,G)=>$.set(W,G));let Q=Y.listMeshes().length,K=new Map;for(let W of Y.listMeshes()){let G=[];for(let H of W.listPrimitives())G.push(Cs(H,$));let V="";if(J.keepUniqueNames)V+=W.getName()+";";if(V+=G.join(";"),K.has(V)){let H=K.get(V);W.listParents().forEach((F)=>{if(F.propertyType!==a.ROOT)F.swap(W,H)}),W.dispose()}else K.set(V,W)}X.debug(`${bJ}: Merged ${Q-K.size} of ${Q} meshes.`)}function NM1(Z,J){let X=Z.getLogger(),Y=Z.getRoot(),$=Y.listTextures(),Q=new Map;for(let K=0;K<$.length;K++){let W=$[K],G=W.getImage();if(Q.has(W))continue;for(let V=K+1;V<$.length;V++){let H=$[V],F=H.getImage();if(Q.has(H))continue;if(W.getMimeType()!==H.getMimeType())continue;if(J.keepUniqueNames&&W.getName()!==H.getName())continue;let z=W.getSize(),q=H.getSize();if(!z||!q)continue;if(z[0]!==q[0])continue;if(z[1]!==q[1])continue;if(!G||!F)continue;if(n0.equals(G,F))Q.set(H,W)}}X.debug(`${bJ}: Merged ${Q.size} of ${Y.listTextures().length} textures.`),Array.from(Q.entries()).forEach(([K,W])=>{K.listParents().forEach((G)=>{if(!(G instanceof MY))G.swap(K,W)}),K.dispose()})}function RM1(Z,J){let X=Z.getLogger(),$=Z.getRoot().listMaterials(),Q=new Map,K=new Map,W=new Set;if(!J.keepUniqueNames)W.add("name");for(let G=0;G<$.length;G++){let V=$[G];if(Q.has(V))continue;if(Zs(V,K))continue;for(let H=G+1;H<$.length;H++){let F=$[H];if(Q.has(F))continue;if(Zs(F,K))continue;if(V.equals(F,W))Q.set(F,V)}}X.debug(`${bJ}: Merged ${Q.size} of ${$.length} materials.`),Array.from(Q.entries()).forEach(([G,V])=>{G.listParents().forEach((H)=>{if(!(H instanceof MY))H.swap(G,V)}),G.dispose()})}function MM1(Z,J){let X=Z.getLogger(),$=Z.getRoot().listSkins(),Q=new Map,K=new Set(["joints"]);if(!J.keepUniqueNames)K.add("name");for(let W=0;W<$.length;W++){let G=$[W];if(Q.has(G))continue;for(let V=W+1;V<$.length;V++){let H=$[V];if(Q.has(H))continue;if(G.equals(H,K)&&JM1(G.listJoints(),H.listJoints()))Q.set(H,G)}}X.debug(`${bJ}: Merged ${Q.size} of ${$.length} skins.`),Array.from(Q.entries()).forEach(([W,G])=>{W.listParents().forEach((V)=>{if(!(V instanceof MY))V.swap(W,G)}),W.dispose()})}function Cs(Z,J){let X=[];for(let Y of Z.listSemantics()){let $=Z.getAttribute(Y);X.push(Y+":"+J.get($))}if(Z instanceof j8){let Y=Z.getIndices();if(Y)X.push("indices:"+J.get(Y));let $=Z.getMaterial();if($)X.push("material:"+J.get($));X.push("mode:"+Z.getMode());for(let Q of Z.listTargets())X.push("target:"+Cs(Q,J))}return X.join(",")}function Zs(Z,J){if(J.has(Z))return J.get(Z);let X=Z.getGraph(),Y=new Set,$=X.listParentEdges(Z);while($.length>0){let Q=$.pop();if(Q.getAttributes().modifyChild===!0)return J.set(Z,!0),!0;let K=Q.getChild();if(Y.has(K))continue;for(let W of X.listChildEdges(K))$.push(W)}return J.set(Z,!1),!1}function Ts(){var Z=new IK(4);if(IK!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function PM1(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z[3]=J[3]+X[3],Z}function DM1(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z[2]=J[2]-X[2],Z[3]=J[3]-X[3],Z}function CM1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z[3]=J[3]*X[3],Z}function TM1(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z[3]=J[3]*X,Z}function EM1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3];return Math.hypot(J,X,Y,$)}var Es=DM1,kM1=CM1,ks=EM1;(function(){var Z=Ts();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=4;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Z[3]=J[W+3],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2],J[W+3]=Z[3];return J}})();var IM1=/color|emissive|diffuse/i;function _M1(Z){return Z.getGraph().listParentEdges(Z).some(($)=>{return $.getAttributes().isColor||IM1.test($.getName())})?"srgb":null}function vM1(Z){let J=Z.getGraph(),X=new Set,Y=new Set;function $(Q){let K=new Set;for(let W of J.listChildEdges(Q))if(W.getChild()instanceof RY)K.add(W.getName()+"Info");for(let W of J.listChildEdges(Q)){let G=W.getChild();if(X.has(G))continue;if(X.add(G),G instanceof P5&&K.has(W.getName()))Y.add(G);else if(G instanceof HK)$(G)}}return $(Z),Array.from(Y)}function SM1(Z){let X=k6.fromGraph(Z.getGraph()).getRoot(),Y=Z.getGraph().listParentEdges(Z).filter(($)=>$.getParent()!==X).map(($)=>$.getName());return Array.from(new Set(Y))}var EK="prune",PT=0.011764705882352941,Js={propertyTypes:[a.NODE,a.SKIN,a.MESH,a.CAMERA,a.PRIMITIVE,a.PRIMITIVE_TARGET,a.ANIMATION,a.MATERIAL,a.TEXTURE,a.ACCESSOR,a.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function J2(Z=Js){let J=w7(Js,Z),X=new Set(J.propertyTypes),Y=J.keepExtras;return mJ(EK,async($)=>{let Q=$.getLogger(),K=$.getRoot(),W=$.getGraph(),G=new Is,V=(H)=>G.dispose(H.target);if(W.addEventListener("node:dispose",V),X.has(a.MESH))for(let H of K.listMeshes()){if(H.listPrimitives().length>0)continue;H.dispose()}if(X.has(a.NODE)){if(!J.keepLeaves)for(let H of K.listScenes())_s(W,H,Y);for(let H of K.listNodes())v9(H,Y)}if(X.has(a.SKIN))for(let H of K.listSkins())v9(H,Y);if(X.has(a.MESH))for(let H of K.listMeshes())v9(H,Y);if(X.has(a.CAMERA))for(let H of K.listCameras())v9(H,Y);if(X.has(a.PRIMITIVE))Xs(W,a.PRIMITIVE,Y);if(X.has(a.PRIMITIVE_TARGET))Xs(W,a.PRIMITIVE_TARGET,Y);if(!J.keepAttributes&&X.has(a.ACCESSOR)){let H=new Map;for(let F of K.listMeshes())for(let z of F.listPrimitives()){let q=z.getMaterial();if(!q)continue;let U=vs($,z,q),L=xM1(z,U);Ys(z,L),z.listTargets().forEach((B)=>Ys(B,L)),H.has(q)?H.get(q).add(z):H.set(q,new Set([z]))}for(let[F,z]of H)hM1(F,Array.from(z))}if(!J.keepIndices&&X.has(a.ACCESSOR))for(let H of K.listMeshes())for(let F of H.listPrimitives())AM1(F);if(X.has(a.ANIMATION))for(let H of K.listAnimations()){for(let F of H.listChannels())if(!F.getTargetNode())F.dispose();if(!H.listChannels().length){let F=H.listSamplers();v9(H,Y),F.forEach((z)=>v9(z,Y))}else H.listSamplers().forEach((F)=>v9(F,Y))}if(X.has(a.MATERIAL))K.listMaterials().forEach((H)=>v9(H,Y));if(X.has(a.TEXTURE)){if(K.listTextures().forEach((H)=>v9(H,Y)),!J.keepSolidTextures)await fM1($)}if(X.has(a.ACCESSOR))K.listAccessors().forEach((H)=>v9(H,Y));if(X.has(a.BUFFER))K.listBuffers().forEach((H)=>v9(H,Y));if(W.removeEventListener("node:dispose",V),!G.empty()){let H=G.entries().map(([F,z])=>`${F} (${z})`).join(", ");Q.info(`${EK}: Removed types... ${H}`)}else Q.debug(`${EK}: No unused properties found.`);Q.debug(`${EK}: Complete.`)})}class Is{constructor(){this.disposed={}}empty(){for(let Z in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(Z){this.disposed[Z.propertyType]=this.disposed[Z.propertyType]||0,this.disposed[Z.propertyType]++}}function v9(Z,J){let X=Z.listParents().filter(($)=>!($ instanceof MY||$ instanceof OY)),Y=J&&!Os(Z.getExtras());if(!X.length&&!Y)Z.dispose()}function Xs(Z,J,X){for(let Y of Z.listEdges()){let $=Y.getParent();if($.propertyType===J)v9($,X)}}function _s(Z,J,X){if(J.listChildren().forEach((K)=>_s(Z,K,X)),J instanceof zK)return;let Y=Z.listParentEdges(J).some((K)=>{let W=K.getParent().propertyType;return W!==a.ROOT&&W!==a.SCENE&&W!==a.NODE}),$=Z.listChildren(J).length===0,Q=X&&!Os(J.getExtras());if($&&!Y&&!Q)J.dispose()}function Ys(Z,J){for(let X of J)Z.setAttribute(X,null)}function AM1(Z){let J=Z.getIndices(),X=J&&J.getArray(),Y=Z.listAttributes()[0];if(!X||!Y)return;if(J.getCount()!==Y.getCount())return;for(let $=0,Q=X.length;$<Q;$++)if($!==X[$])return;Z.setIndices(null)}function xM1(Z,J){let X=[];for(let Y of Z.listSemantics())if(Y==="NORMAL"&&!J.has(Y))X.push(Y);else if(Y==="TANGENT"&&!J.has(Y))X.push(Y);else if(Y.startsWith("TEXCOORD_")&&!J.has(Y))X.push(Y);else if(Y.startsWith("COLOR_")&&Y!=="COLOR_0")X.push(Y);return X}function vs(Z,J,X,Y=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let V of Q)if(V.getChild()instanceof RY)K.add(V.getName());for(let V of Q){let H=V.getName(),F=V.getChild();if(F instanceof P5){if(K.has(H.replace(/Info$/,"")))Y.add(`TEXCOORD_${F.getTexCoord()}`)}if(F instanceof RY&&H.match(/normalTexture/i))Y.add("TANGENT");if(F instanceof HK)vs(Z,J,F,Y)}let W=X instanceof G7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===j8.Mode.POINTS;if(W&&!G)Y.add("NORMAL");return Y}function hM1(Z,J){let X=vM1(Z),Y=new Set(X.map((G)=>G.getTexCoord())),$=Array.from(Y).sort(),Q=new Map($.map((G,V)=>[G,V])),K=new Map($.map((G,V)=>[`TEXCOORD_${G}`,`TEXCOORD_${V}`]));for(let G of X){let V=G.getTexCoord();G.setTexCoord(Q.get(V))}for(let G of J){let V=G.listSemantics().filter((H)=>H.startsWith("TEXCOORD_")).sort();W(G,V),G.listTargets().forEach((H)=>W(H,V))}function W(G,V){for(let H of V){let F=G.getAttribute(H);if(!F)continue;let z=K.get(H);if(z===H)continue;G.setAttribute(z,F),G.setAttribute(H,null)}}}async function fM1(Z){let J=Z.getRoot(),X=Z.getGraph(),Y=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await bM1(K);if(!G)return;if(_M1(K)==="srgb")kD.convertSRGBToLinear(G,G);let V=K.getName()||K.getURI(),H=(W=K.getSize())==null?void 0:W.join("x"),F=SM1(K);for(let z of X.listParentEdges(K)){let q=z.getParent();if(q!==J&&yM1(q,G,z.getName(),Y))z.dispose()}if(K.listParents().length===1)K.dispose(),Y.debug(`${EK}: Removed solid-color texture "${V}" (${H}px ${F.join(", ")})`)});await Promise.all(Q)}function yM1(Z,J,X,Y){if(Z instanceof G7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(kM1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(wM1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=PT;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return ks(Es(Ts(),J,[0.5,0.5,1,1]))<=PT}return Y.warn(`${EK}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function bM1(Z){let J=await gM1(Z);if(!J)return null;let X=[1/0,1/0,1/0,1/0],Y=[-1/0,-1/0,-1/0,-1/0],$=[0,0,0,0],[Q,K]=J.shape;for(let W=0;W<Q;W++){for(let G=0;G<K;G++)for(let V=0;V<4;V++)X[V]=Math.min(X[V],J.get(W,G,V)),Y[V]=Math.max(Y[V],J.get(W,G,V));if(ks(Es($,Y,X))/255>PT)return null}return TM1($,PM1($,Y,X),0.00196078431372549)}async function gM1(Z){try{return await Ba(Z.getImage(),Z.getMimeType())}catch(J){return null}}var yJ=4294967295;class Ss{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of IT(Z))J+=this._initAttribute(X);this.u8=new Uint8Array(J),this.u32=new Uint32Array(this.u8.buffer)}_initAttribute(Z){let J=Z.getArray(),X=new Uint8Array(J.buffer,J.byteOffset,J.byteLength),Y=Z.getElementSize()*Z.getComponentSize(),$=n0.padNumber(Y);return this.attributes.push({u8:X,byteStride:Y,paddedByteStride:$}),$}hash(Z){let J=0;for(let{u8:X,byteStride:Y,paddedByteStride:$}of this.attributes){for(let Q=0;Q<$;Q++)if(Q<Y)this.u8[J+Q]=X[Z*Y+Q];else this.u8[J+Q]=0;J+=$}return mM1(0,this.u32)}equal(Z,J){for(let{u8:X,byteStride:Y}of this.attributes)for(let $=0;$<Y;$++)if(X[Z*Y+$]!==X[J*Y+$])return!1;return!0}}function mM1(Z,J){for(let $=0,Q=J.length;$<Q;$++){let K=J[$];K=Math.imul(K,1540483477)>>>0,K=(K^K>>24)>>>0,K=Math.imul(K,1540483477)>>>0,Z=Math.imul(Z,1540483477)>>>0,Z=(Z^K)>>>0}return Z}function uM1(Z,J,X,Y,$=yJ){let Q=J-1,W=X.hash(Y)&Q;for(let G=0;G<=Q;G++){let V=Z[W];if(V===$||X.equal(V,Y))return W;W=W+G+1&Q}throw new Error("Hash table full.")}var B6;(function(Z){Z.RENDER="render",Z.RENDER_CACHED="render-cached",Z.UPLOAD="upload",Z.UPLOAD_NAIVE="upload-naive",Z.DISTINCT="distinct",Z.DISTINCT_POSITION="distinct-position",Z.UNUSED="unused"})(B6||(B6={}));function gJ(Z,J){let X=Z.getAttribute("POSITION"),Y=Z.getIndices();switch(J){case B6.RENDER:return Y?Y.getCount():X.getCount();case B6.RENDER_CACHED:return Y?new Set(Y.getArray()).size:X.getCount();case B6.UPLOAD_NAIVE:case B6.UPLOAD:return X.getCount();case B6.DISTINCT:case B6.DISTINCT_POSITION:return dM1(J);case B6.UNUSED:return Y?X.getCount()-new Set(Y.getArray()).size:0;default:return cM1(J)}}function dM1(Z){throw new Error(`Not implemented: ${Z}`)}function cM1(Z){throw new Error(`Unexpected value: ${Z}`)}function EV(Z,J,X){let Y=k6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=lM1(Z);let $=Z.getIndices(),Q=$?$.getArray():null,K=gJ(Z,B6.RENDER),W=Y.createAccessor(),G=K,V=_T(G,X);for(let F=0;F<G;F++)V[F]=J[Q?Q[F]:F];Z.setIndices(W.setArray(V));let H=IT(Z);for(let F of Z.listAttributes()){let z=RZ(Y,F);DT(F,$,J,z,X),Z.swap(F,z)}for(let F of Z.listTargets())for(let z of F.listAttributes()){let q=RZ(Y,z);DT(z,$,J,q,X),F.swap(z,q)}if($&&$.listParents().length===1)$.dispose();for(let F of H)if(F.listParents().length===1)F.dispose();return Z}function DT(Z,J,X,Y,$){let Q=Z.getElementSize(),K=Z.getArray(),W=J?J.getArray():null,G=J?J.getCount():Z.getCount(),V=new K.constructor($*Q),H=new Uint8Array($);for(let F=0;F<G;F++){let z=W?W[F]:F,q=X[z];if(H[q])continue;for(let U=0;U<Q;U++)V[q*Q+U]=K[z*Q+U];H[q]=1}return Y.setArray(V)}function lM1(Z){let J=gJ(Z,B6.UPLOAD),X=Z.getIndices(),Y=X?X.getArray():null;if(!X||!Y)return[XM1(J,1e6),J];let $=new Uint32Array(J).fill(yJ),Q=0;for(let K=0;K<Y.length;K++){let W=Y[K];if($[W]===yJ)$[W]=Q++}return[$,Q]}var CT="weld",oB={overwrite:!0,cleanup:!0};function vT(Z=oB){let J=w7(oB,Z);return mJ(CT,async(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes()){for(let Q of $.listPrimitives())if(X2(Q,J),gJ(Q,B6.RENDER)===0)Q.dispose();if($.listPrimitives().length===0)$.dispose()}if(J.cleanup)await X.transform(J2({propertyTypes:[a.ACCESSOR,a.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),Ds({propertyTypes:[a.ACCESSOR]}));Y.debug(`${CT}: Complete.`)})}function X2(Z,J=oB){let X=Z.getGraph(),$=k6.fromGraph(X).getLogger(),Q=kK({},oB,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===j8.Mode.POINTS)return;let K=Z.getAttribute("POSITION").getCount(),W=Z.getIndices(),G=W==null?void 0:W.getArray(),V=W?W.getCount():K,H=new Ss(Z),F=$M1(K+K/4),z=new Uint32Array(F).fill(yJ),q=new Uint32Array(K).fill(yJ),U=0;for(let L=0;L<V;L++){let B=G?G[L]:L;if(q[B]!==yJ)continue;let w=uM1(z,F,H,B,yJ),O=z[w];if(O===yJ)z[w]=B,q[B]=U++;else q[B]=q[O]}$.debug(`${CT}: ${eB(K,U)} vertices.`),EV(Z,q,U)}var{FLOAT:pM1}=I0.ComponentType;function As(Z,J){let X=Z.getAttribute("POSITION");if(X)$s(J,X);let Y=Z.getAttribute("NORMAL");if(Y)Qs(J,Y);let $=Z.getAttribute("TANGENT");if($)Ks(J,$);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)$s(J,K);let W=Q.getAttribute("NORMAL");if(W)Qs(J,W);let G=Q.getAttribute("TANGENT");if(G)Ks(J,G)}if(VM1(J)<0)iM1(Z)}function $s(Z,J){let X=J.getComponentType(),Y=J.getNormalized(),$=J.getArray(),Q=X===pM1?$:new Float32Array($.length),K=Z2();for(let W=0,G=J.getCount();W<G;W++){if(Y)K[0]=c0.decodeNormalizedInt($[W*3],X),K[1]=c0.decodeNormalizedInt($[W*3+1],X),K[2]=c0.decodeNormalizedInt($[W*3+2],X);else K[0]=$[W*3],K[1]=$[W*3+1],K[2]=$[W*3+2];LM1(K,K,Z),Q[W*3]=K[0],Q[W*3+1]=K[1],Q[W*3+2]=K[2]}J.setArray(Q).setNormalized(!1)}function Qs(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=HM1();zM1(Q,Z),qM1(Q,Q),FM1(Q,Q);let K=Z2();for(let W=0,G=J.getCount();W<G;W++){if(Y)K[0]=c0.decodeNormalizedInt(X[W*3],$),K[1]=c0.decodeNormalizedInt(X[W*3+1],$),K[2]=c0.decodeNormalizedInt(X[W*3+2],$);else K[0]=X[W*3],K[1]=X[W*3+1],K[2]=X[W*3+2];if(BM1(K,K,Q),Ps(K,K),Y)X[W*3]=c0.decodeNormalizedInt(K[0],$),X[W*3+1]=c0.decodeNormalizedInt(K[1],$),X[W*3+2]=c0.decodeNormalizedInt(K[2],$);else X[W*3]=K[0],X[W*3+1]=K[1],X[W*3+2]=K[2]}}function Ks(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=Z2();for(let K=0,W=J.getCount();K<W;K++){if(Y)Q[0]=c0.decodeNormalizedInt(X[K*4],$),Q[1]=c0.decodeNormalizedInt(X[K*4+1],$),Q[2]=c0.decodeNormalizedInt(X[K*4+2],$);else Q[0]=X[K*4],Q[1]=X[K*4+1],Q[2]=X[K*4+2];if(Q[0]=Z[0]*Q[0]+Z[4]*Q[1]+Z[8]*Q[2],Q[1]=Z[1]*Q[0]+Z[5]*Q[1]+Z[9]*Q[2],Q[2]=Z[2]*Q[0]+Z[6]*Q[1]+Z[10]*Q[2],Ps(Q,Q),Y)X[K*4]=c0.decodeNormalizedInt(Q[0],$),X[K*4+1]=c0.decodeNormalizedInt(Q[1],$),X[K*4+2]=c0.decodeNormalizedInt(Q[2],$);else X[K*4]=Q[0],X[K*4+1]=Q[1],X[K*4+2]=Q[2]}}function iM1(Z){if(Z.getMode()!==j8.Mode.TRIANGLES)return;if(!Z.getIndices())X2(Z);let J=Z.getIndices();for(let X=0,Y=J.getCount();X<Y;X+=3){let $=J.getScalar(X),Q=J.getScalar(X+2);J.setScalar(X,Q),J.setScalar(X+2,$)}}function nM1(Z,J){for(let X of Z.listPrimitives()){let Y=aM1(X,Z);if(X!==Y)Z.removePrimitive(X).addPrimitive(Y)}for(let X of Z.listPrimitives())EV(X),As(X,J)}function aM1(Z,J){if(Z.listParents().some((Y)=>Y instanceof YV&&Y!==J))Z=Z.clone();for(let Y of Z.listTargets())if(Y.listParents().some((Q)=>Q instanceof j8&&Q!==Z))Z.removeTarget(Y).addTarget(Y.clone());return Z}var Ws=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function xs(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!c0.eq(X,Ws))nM1(J,X);for(let Y of Z.listChildren()){let $=Y.getMatrix();Ms($,$,X),Y.setMatrix($)}return Z.setMatrix(Ws)}var{LINES:sM1,LINE_STRIP:oM1,LINE_LOOP:rM1,TRIANGLES:tM1,TRIANGLE_STRIP:eM1,TRIANGLE_FAN:ZP1}=j8.Mode;function JP1(Z){let J=Z.getGraph(),X=k6.fromGraph(J);if(!Z.getIndices())X2(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=js(Z),W=new kJ[Y.getComponentType()](Q*2),G=Z.getMode();if(G===oM1)for(let H=0;H<Q;H++)W[H*2]=$[H],W[H*2+1]=$[H+1];else if(G===rM1)for(let H=0;H<Q;H++)if(H<Q-1)W[H*2]=$[H],W[H*2+1]=$[H+1];else W[H*2]=$[H],W[H*2+1]=$[0];else throw new Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(sM1);let V=X.getRoot();if(Y.listParents().some((H)=>H!==V&&H!==Z))Z.setIndices(RZ(X,Y).setArray(W));else Y.setArray(W)}function hs(Z){let J=Z.getGraph(),X=k6.fromGraph(J);if(!Z.getIndices())X2(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=js(Z),W=new kJ[Y.getComponentType()](Q*3),G=Z.getMode();if(G===eM1)for(let H=0,F=$.length;H<F-2;H++)if(H%2)W[H*3]=$[H+1],W[H*3+1]=$[H],W[H*3+2]=$[H+2];else W[H*3]=$[H],W[H*3+1]=$[H+1],W[H*3+2]=$[H+2];else if(G===ZP1)for(let H=0;H<Q;H++)W[H*3]=$[0],W[H*3+1]=$[H+1],W[H*3+2]=$[H+2];else throw new Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(tM1);let V=X.getRoot();if(Y.listParents().some((H)=>H!==V&&H!==Z))Z.setIndices(RZ(X,Y).setArray(W));else Y.setArray(W)}var Gs="dequantize",rB={pattern:/^((?!JOINTS_).)*$/};function fs(Z=rB){let J=w7(rB,Z);return mJ(Gs,(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes())for(let Q of $.listPrimitives())XP1(Q,J);X.createExtension(CV).dispose(),Y.debug(`${Gs}: Complete.`)})}function XP1(Z,J=rB){let X=w7(rB,J);for(let Y of Z.listSemantics())if(X.pattern.test(Y))TT(Z.getAttribute(Y));for(let Y of Z.listTargets())for(let $ of Y.listSemantics())if(X.pattern.test($))TT(Y.getAttribute($))}function TT(Z){let J=Z.getArray();if(!J)return;let X=tB(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function tB(Z,J,X){let Y=new Float32Array(Z.length);for(let $=0,Q=Z.length;$<Q;$++)if(X)Y[$]=c0.decodeNormalizedInt(Z[$],J);else Y[$]=Z[$];return Y}var{TEXTURE_INFO:ys,ROOT:tT6}=a;function bs(Z){let J=new k6().setLogger(Z.getLogger()),X=ST(J,Z);return YP1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function YP1(Z,J,X){X||(X=ST(Z,J));for(let Y of J.getRoot().listExtensionsUsed()){let $=Z.createExtension(Y.constructor);if(Y.isRequired())$.setRequired(!0)}return $P1(Z,J,QP1(J),X)}function $P1(Z,J,X,Y){Y||(Y=ST(Z,J));let $=new Map;for(let Q of X)if(!$.has(Q)&&Q.propertyType!==ys)$.set(Q,Y(Q));for(let[Q,K]of $.entries())K.copy(Q,Y);return $}function ST(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return(Y)=>{if(Y.propertyType===ys)return Y;let $=X.get(Y);if(!$)$=new Y.constructor(Z.getGraph()),X.set(Y,$);return $}}function QP1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}var NT="flatten",Vs={cleanup:!0};function gs(Z=Vs){let J=w7(Vs,Z);return mJ(NT,async(X)=>{let Y=X.getRoot(),$=X.getLogger(),Q=new Set;for(let V of Y.listSkins())for(let H of V.listJoints())Q.add(H);let K=new Set;for(let V of Y.listAnimations())for(let H of V.listChannels()){let F=H.getTargetNode();if(F&&H.getTargetPath()!=="weights")K.add(F)}let W=new Set,G=new Set;for(let V of Y.listScenes())V.traverse((H)=>{let F=H.getParentNode();if(!F)return;if(Q.has(F)||W.has(F))W.add(H);if(K.has(F)||G.has(F))G.add(H)});for(let V of Y.listScenes())V.traverse((H)=>{if(K.has(H))return;if(W.has(H))return;if(G.has(H))return;WM1(H)});if(K.size)$.debug(`${NT}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(J2({propertyTypes:[a.NODE],keepLeaves:!1}));$.debug(`${NT}: Complete.`)})}function ms(Z){return ED(Z)}var KP1={skipValidation:!1},Hs=4294967295,{LINE_STRIP:WP1,LINE_LOOP:GP1,TRIANGLE_STRIP:VP1,TRIANGLE_FAN:HP1}=j8.Mode;function zP1(Z,J={}){let X=w7(KP1,J),Y=Z[0],$=k6.fromGraph(Y.getGraph());if(!X.skipValidation&&new Set(Z.map(Ns)).size>1)throw new Error("Requires >=2 Primitives, sharing the same Material and Mode, with compatible vertex attributes and indices.");for(let q of Z)switch(q.getMode()){case WP1:case GP1:JP1(q);break;case VP1:case HP1:hs(q);break}let Q=[],K=new Uint32Array(Z.length),W=0,G=0;for(let q=0;q<Z.length;q++){let U=Z[q],L=U.getIndices(),B=U.getAttribute("POSITION").getCount(),w=L?L.getArray():null,O=L?L.getCount():B,N=new Uint32Array(B).fill(Hs);for(let R=0;R<O;R++){let D=w?w[R]:R;if(N[D]===Hs)N[D]=W++,K[q]++}Q.push(N),G+=O}let V=$.createPrimitive().setMode(Y.getMode()).setMaterial(Y.getMaterial());for(let q of Y.listSemantics()){let U=Y.getAttribute(q),L=kJ[U.getComponentType()],B=RZ($,U).setArray(new L(W*U.getElementSize()));V.setAttribute(q,B)}let H=Y.getIndices(),F=H?RZ($,H).setArray(_T(G,W)):null;V.setIndices(F);let z=0;for(let q=0;q<Q.length;q++){let U=Z[q],L=U.getIndices(),B=L?L.getCount():-1,w=Q[q];if(L&&F)qP1(L,w,F,z),z+=B;for(let O of V.listSemantics()){let N=U.getAttribute(O),R=V.getAttribute(O);FP1(N,L,w,R)}}return V}function FP1(Z,J,X,Y){let $=Z.getElementSize(),Q=J?J.getArray():null,K=Z.getCount(),W=Z.getArray(),G=Y.getArray(),V=new Uint8Array(Z.getCount());for(let H=0,F=J?J.getCount():K;H<F;H++){let z=Q?Q[H]:H,q=X[z];if(V[q])continue;for(let U=0;U<$;U++)G[q*$+U]=W[z*$+U];V[q]=1}}function qP1(Z,J,X,Y){let $=Z.getCount(),Q=Z.getArray(),K=X.getArray();for(let W=0;W<$;W++){let G=Q[W],V=J[G];K[Y+W]=V}}var ET="join",{ROOT:UP1,NODE:LP1,MESH:BP1,PRIMITIVE:wP1,ACCESSOR:jP1}=a,RT=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],zs={keepMeshes:!1,keepNamed:!1,cleanup:!0};function us(Z=zs){let J=w7(zs,Z);return mJ(ET,async(X)=>{let Y=X.getRoot(),$=X.getLogger();for(let Q of Y.listScenes())Fs(X,Q,J),Q.traverse((K)=>Fs(X,K,J));if(J.cleanup)await X.transform(J2({propertyTypes:[LP1,BP1,wP1,jP1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));$.debug(`${ET}: Complete.`)})}function Fs(Z,J,X){let Y=Z.getLogger(),$={},Q=J.listChildren();for(let G=0;G<Q.length;G++){let V=Q[G];if(V.listParents().some((z)=>z instanceof OY))continue;let F=V.getMesh();if(!F)continue;if(V.getExtension("EXT_mesh_gpu_instancing"))continue;if(V.getSkin())continue;for(let z of F.listPrimitives()){if(z.listTargets().length>0)continue;let q=z.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;EV(z),NP1(z);let U=Ns(z),L=F.getName()||V.getName();if(X.keepMeshes||X.keepNamed&&L)U+=`|${G}`;if(!(U in $))$[U]={prims:[],primMeshes:[],primNodes:[],dstNode:V,dstMesh:void 0};let B=$[U];B.prims.push(z),B.primNodes.push(V)}}let K=Object.values($).filter(({prims:G})=>G.length>1),W=new Set(K.flatMap((G)=>G.primNodes));for(let G of W){let V=G.getMesh();if(V.listParents().some((F)=>{return F.propertyType!==UP1&&G!==F}))G.setMesh(V.clone())}for(let G of K){let{dstNode:V,primNodes:H}=G;G.dstMesh=V.getMesh(),G.primMeshes=H.map((F)=>F.getMesh())}for(let G of K){let{prims:V,primNodes:H,primMeshes:F,dstNode:z,dstMesh:q}=G,U=z.getMatrix();for(let w=0;w<V.length;w++){let O=H[w],N=F[w],R=V[w];if(N.removePrimitive(R),YM1(R))R=V[w]=OP1(V[w]);if(O!==z)Ms(RT,GM1(RT,U),O.getMatrix()),As(R,RT)}let L=zP1(V),B=L.listAttributes()[0].getCount();q.addPrimitive(L),Y.debug(`${ET}: Joined Primitives (${V.length}) containing ${MT(B)} vertices under Node "${z.getName()}".`)}}function OP1(Z){let J=Z.clone();for(let Y of J.listSemantics())J.setAttribute(Y,J.getAttribute(Y).clone());let X=J.getIndices();if(X)J.setIndices(X.clone());return J}function NP1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)TT(X)}}var{TRANSLATION:eT6,ROTATION:ZE6,SCALE:JE6,WEIGHTS:XE6}=OY.TargetPath;var RP1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var YE6=kK({level:"high"},RP1);var MP1="unweld";function PP1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let Y=Z.getGraph(),$=k6.fromGraph(Y),Q=$.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,qs($,G,X,J)),G.listParents().length===1)G.dispose();for(let G of Z.listTargets())for(let V of G.listAttributes())if(G.swap(V,qs($,V,X,J)),V.listParents().length===1)V.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${MP1}: ${eB(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function qs(Z,J,X,Y){if(Y.has(J)&&Y.get(J).has(X))return Y.get(J).get(X);let $=J.getArray(),K=new $.constructor(X.getCount()*J.getElementSize()),W=X.getArray(),G=J.getElementSize();for(let H=0,F=X.getCount();H<F;H++)for(let z=0;z<G;z++)K[H*G+z]=$[W[H]*G+z];if(!Y.has(J))Y.set(J,new Map);let V=RZ(Z,J).setArray(K);return Y.get(J).set(X,V),V}var Us;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(Us||(Us={}));var DP1=0.000001;function CP1(Z,J,X,Y=0.0001){let $=J.length/Z.length,Q=new Array($).fill(0),K=new Array($).fill(0),W=new Array($).fill(0),G=new Array($).fill(0),V=Z.length-1,H=1;for(let F=1;F<V;++F){let z=Z[H-1],q=Z[F],U=Z[F+1],L=(q-z)/(U-z),B=!1;if(q!==U&&(F!==1||q!==Z[0])){if(TV(J,H-1,G),TV(J,F,K),TV(J,F+1,W),X==="slerp"){let w=kP1(Q,G,W,L),O=Bs(G,K)+Bs(K,W);B=!sB(K,w,Y)||O+Number.EPSILON>=Math.PI}else if(X==="lerp"){let w=EP1(Q,G,W,L);B=!sB(K,w,Y)}else if(X==="step")B=!sB(K,G)||!sB(K,W)}if(B){if(F!==H)Z[H]=Z[F],Ls(J,H,TV(J,F,Q));H++}}if(V>0)Z[H]=Z[V],Ls(J,H,TV(J,V,Q)),H++;return H}function TV(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)X[Y]=Z[J*$+Y];return X}function Ls(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)Z[J*$+Y]=X[Y]}function sB(Z,J,X=0){if(Z.length!==J.length)return!1;for(let Y=0;Y<Z.length;Y++)if(Math.abs(Z[Y]-J[Y])>X)return!1;return!0}function TP1(Z,J,X){return Z*(1-X)+J*X}function EP1(Z,J,X,Y){for(let $=0;$<J.length;$++)Z[$]=TP1(J[$],X[$],Y);return Z}function kP1(Z,J,X,Y){let $=J[0],Q=J[1],K=J[2],W=J[3],G=X[0],V=X[1],H=X[2],F=X[3],z,q,U,L,B;if(q=$*G+Q*V+K*H+W*F,q<0)q=-q,G=-G,V=-V,H=-H,F=-F;if(1-q>DP1)z=Math.acos(q),U=Math.sin(z),L=Math.sin((1-Y)*z)/U,B=Math.sin(Y*z)/U;else L=1-Y,B=Y;return Z[0]=L*$+B*G,Z[1]=L*Q+B*V,Z[2]=L*K+B*H,Z[3]=L*W+B*F,Z}function Bs(Z,J){let X=IP1(Z,J);return Math.acos(2*X*X-1)}function IP1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var $E6=new Float32Array(0),QE6={ready:Promise.resolve(),resample:CP1,tolerance:0.0001,cleanup:!0};var dY="simplify",{POINTS:ds,LINES:_P1,LINE_STRIP:vP1,LINE_LOOP:SP1,TRIANGLES:AP1,TRIANGLE_STRIP:cs,TRIANGLE_FAN:ls}=j8.Mode,ps={ratio:0,error:0.0001,lockBorder:!1,cleanup:!0};function is(Z){let J=w7(ps,Z),X=J.simplifier;if(!X)throw new Error(`${dY}: simplifier dependency required — install "meshoptimizer".`);return mJ(dY,async(Y)=>{let $=Y.getLogger();await X.ready,await Y.transform(vT({overwrite:!1,cleanup:J.cleanup}));let Q=0;for(let K of Y.getRoot().listMeshes()){for(let W of K.listPrimitives()){let G=W.getMode();if(G===AP1||G===cs||G===ls){if(ws(W,J),gJ(W,B6.RENDER)===0)W.dispose()}else if(W.getMode()===ds&&!!X.simplifyPoints){if(ws(W,J),gJ(W,B6.RENDER)===0)W.dispose()}else Q++}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)$.warn(`${dY}: Skipping simplification of ${Q} primitives: Unsupported draw mode.`);if(J.cleanup)await Y.transform(J2({propertyTypes:[a.ACCESSOR,a.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),Ds({propertyTypes:[a.ACCESSOR]}));$.debug(`${dY}: Complete.`)})}function ws(Z,J){let X=kK({},ps,J),Y=X.simplifier,$=Z.getGraph(),Q=k6.fromGraph($),K=Q.getLogger();switch(Z.getMode()){case ds:return xP1(Q,Z,X);case _P1:case vP1:case SP1:return K.warn(`${dY}: Skipping primitive simplification: Unsupported draw mode.`),Z;case cs:case ls:hs(Z);break}let W=gJ(Z,B6.UPLOAD),G=gJ(Z,B6.RENDER);if(G<W/2)EV(Z);let V=Z.getAttribute("POSITION"),H=Z.getIndices(),F=V.getArray(),z=H.getArray();if(!(F instanceof Float32Array))F=tB(F,V.getComponentType(),V.getNormalized());if(!(z instanceof Uint32Array))z=new Uint32Array(z);let q=Math.floor(X.ratio*G/3)*3,U=X.lockBorder?["LockBorder"]:[],[L,B]=Y.simplify(z,F,3,q,X.error,U);if(Z.setIndices(RZ(Q,H).setArray(L)),H.listParents().length===1)H.dispose();EV(Z);let w=gJ(Z,B6.UPLOAD);if(w<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${dY}: ${eB(W,w)} vertices, error: ${B.toFixed(4)}.`),Z}function xP1(Z,J,X){let Y=X.simplifier,$=Z.getLogger();if(J.getIndices())PP1(J);let K=J.getAttribute("POSITION"),W=J.getAttribute("COLOR_0"),G=K.getCount(),V=K.getArray(),H=W?W.getArray():void 0,F=W?W.getComponentSize():void 0;if(!(V instanceof Float32Array))V=tB(V,K.getComponentType(),K.getNormalized());if(H&&!(H instanceof Float32Array))H=tB(H,K.getComponentType(),K.getNormalized());Y.useExperimentalFeatures=!0;let z=Math.floor(X.ratio*G),q=Y.simplifyPoints(V,3,z,H,F);Y.useExperimentalFeatures=!1;let[U,L]=Y.compactMesh(q);$.debug(`${dY}: ${eB(K.getCount(),L)} vertices.`);for(let B of IT(J)){let w=RZ(Z,B);if(DT(B,null,U,w,L),ZM1(J,B,w),B.listParents().length===1)B.dispose()}return J}var kT;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(kT||(kT={}));var KE6={resizeFilter:kT.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var es=r(ts(),1);var _K={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DIRECTORIES:[(()=>{try{return t5.dirname(g.resolve("@hytopia.com/assets"))}catch{return null}})(),t5.resolve(process.cwd(),"assets")].filter(Boolean),OPTIMIZER_RUNS:[{suffix:"",options:["--compress","false","--instance","false","--simplify","false"]},{suffix:"-named-nodes",options:["--compress","false","--instance","false","--simplify","false","--join","true","--join-named","false"]}]};class E5{static instance=new E5;optimize=!0;optimizeEveryStart=!1;_modelUriDocuments=new Map;_modelUriBoundingBoxes=new Map;_modelUriNodeNames=new Map;_modelUriTrimeshes=new Map;constructor(){}async preloadModels(){let Z=await this._getAbsoluteModelPaths();console.log(`ModelRegistry.preloadModels(): Preloading ${Z.length} models...`);for(let J of Z){if(this.optimize)await this._resolveOptimizedModelPath(J);await this._loadModelData(J)}console.log(`ModelRegistry.preloadModels(): Preloaded ${Z.length} models!`)}getAnimationNames(Z){let J=this._modelUriDocuments.get(Z);if(!J)u.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J.getRoot().listAnimations().map((Y)=>Y.getName())}getBoundingBox(Z){let J=this._modelUriBoundingBoxes.get(Z);if(!J)u.fatalError(`ModelRegistry.getBoundingBox(): Model ${Z} not found!`);return J}getDepth(Z){let J=this.getBoundingBox(Z);return J.max.z-J.min.z}getHeight(Z){let J=this.getBoundingBox(Z);return J.max.y-J.min.y}getNodeNames(Z){let J=this._modelUriNodeNames.get(Z);if(!J)u.fatalError(`ModelRegistry.getNodeNames(): Model ${Z} not found!`);return J}getTrimesh(Z,J=1){let X=this._modelUriTrimeshes.get(Z);if(!X){u.error(`ModelRegistry.getTrimesh(): Model ${Z} not found!`);return}let Y=X.vertices;if(J!==1){Y=new Float32Array(Y.length);for(let $=0;$<Y.length;$++)Y[$]=X.vertices[$]*J}return{vertices:Y,indices:X.indices}}getWidth(Z){let J=this.getBoundingBox(Z);return J.max.x-J.min.x}modelHasNode(Z,J){let X=this._modelUriNodeNames.get(Z);if(!X)u.fatalError(`ModelRegistry.modelHasNode(): Model ${Z} not found!`);return X.includes(J)}_absoluteModelPathToModelUri(Z){let J=t5.normalize(Z);for(let X of _K.DIRECTORIES){let Y=t5.normalize(X);if(J.startsWith(Y))return t5.relative(Y,J).replace(/\\/g,"/")}return t5.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of _K.DIRECTORIES){let X=t5.resolve(process.cwd(),J);if(!uJ.existsSync(X))continue;let Y=await cL("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let $ of Y)Z.push(t5.join(X,$))}return Z}async _loadModelData(Z){let J=await new AD().read(Z),X=ms(J.getRoot().listScenes()[0]),Y=J.getRoot().listNodes().map((Q)=>Q.getName()),$=this._absoluteModelPathToModelUri(Z);this._modelUriDocuments.set($,J),this._modelUriBoundingBoxes.set($,{min:{x:X.min[0],y:X.min[1],z:X.min[2]},max:{x:X.max[0],y:X.max[1],z:X.max[2]}}),this._modelUriNodeNames.set($,Y),this._modelUriTrimeshes.set($,await this._buildTrimesh($))}async _resolveOptimizedModelPath(Z){let J=this._buildOptimizedModelPath(Z);if(!this.optimizeEveryStart&&this._isOptimizedVersionValid(Z))return J;return await this._optimizeModel(Z,J)}_isOptimizedVersionValid(Z){let J=`${this._buildOptimizedModelPath(Z)}${_K.CHECKSUM_EXT}`;if(!uJ.existsSync(J))return!1;let X=this._calculateChecksum(Z),Y=uJ.readFileSync(J,"utf8");return X===Y}_calculateChecksum(Z){if(!uJ.existsSync(Z))return"";let J=uJ.readFileSync(Z);return gP1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=t5.basename(Z),X=J.replace(/\.[^/.]+$/,""),Y=t5.dirname(Z),$=t5.join(Y,_K.OPTIMIZED_DIR,X);return t5.join($,J)}async _buildTrimesh(Z,J=1,X=0.001){let Y=this._modelUriDocuments.get(Z);if(!Y)u.fatalError(`ModelRegistry._buildTrimesh(): Model ${Z} not found!`);let $=bs(Y);$.setLogger(new D5(JV.WARN)),await $.transform(Rs({pivot:"center"}),gs(),us(),vT(),is({simplifier:es.MeshoptSimplifier,ratio:J,error:X}),fs());for(let V of $.getRoot().listScenes())for(let H of V.listChildren())xs(H);let Q=$.getRoot().listMeshes()[0];if(!Q){u.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root mesh!`);return}let K=Q.listPrimitives()[0];if(!K){u.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root primitive!`);return}let W=K.getAttribute("POSITION"),G=K.getIndices();if(!W||!G){u.error(`ModelRegistry._buildTrimesh(): Model ${Z} missing required geometry data!`);return}return{vertices:W.getArray(),indices:G.getArray()}}async _optimizeModel(Z,J){let X=t5.dirname(J);uJ.rmSync(X,{recursive:!0,force:!0}),uJ.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let Y of _K.OPTIMIZER_RUNS){let $=J.replace(/(\.[^/.]+)$/,`${Y.suffix}$1`),{stderr:Q}=await Zl("npx",["gltf-transform","optimize",Z,$,...Y.options]);if(Q)return u.warning(`ModelRegistry._optimizeModel(): Error optimizing model ${this._absoluteModelPathToModelUri(Z)}, defaulting to unoptimized model. Error: ${Q}`),Z}return uJ.writeFileSync(`${J}${_K.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var MZ=r(gQ(),1);var SV;(($)=>{$.DYNAMIC="dynamic";$.FIXED="fixed";$.KINEMATIC_POSITION="kinematic_position";$.KINEMATIC_VELOCITY="kinematic_velocity"})(SV||={});var yT=0.001,Zo="dynamic";class cY extends B0{_additionalMass=0;_colliders=new Set;_explicitSleep=!1;_enabledPositions={x:!0,y:!0,z:!0};_enabledRotations={x:!0,y:!0,z:!0};_rigidBody;_rigidBodyDesc;_rigidBodyType;_simulation;constructor(Z){super();Z.type??=Zo,this._rigidBodyDesc=this._createRigidBodyDesc(Z),this._rigidBodyType=Z.type,this._applyRigidBodyOptions(Z),this._autoAddToSimulation(Z)}get additionalMass(){if(!this._requireNotRemoved("additionalMass"))return 0;return this._additionalMass}get additionalSolverIterations(){if(!this._requireNotRemoved("additionalSolverIterations"))return 0;return this._rigidBody?this._rigidBody.additionalSolverIterations():this._rigidBodyDesc.additionalSolverIterations}get angularDamping(){if(!this._requireNotRemoved("angularDamping"))return 0;return this._rigidBody?this._rigidBody.angularDamping():this._rigidBodyDesc.angularDamping}get angularVelocity(){if(!this._requireNotRemoved("angularVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.angvel():this._rigidBodyDesc.angvel}get colliders(){return this._colliders}get dominanceGroup(){if(!this._requireNotRemoved("dominanceGroup"))return 0;return this._rigidBody?this._rigidBody.dominanceGroup():this._rigidBodyDesc.dominanceGroup}get directionFromRotation(){let{x:Z,y:J,z:X,w:Y}=this.rotation;return{x:-2*(Z*X+Y*J),y:-2*(J*X-Y*Z),z:-(1-2*(Z*Z+J*J))}}get effectiveAngularInertia(){if(!this._requireNotRemoved("effectiveAngularInertia"))return;return this._rigidBody?this._rigidBody.effectiveAngularInertia():void 0}get effectiveInverseMass(){if(!this._requireNotRemoved("effectiveInverseMass"))return;return this._rigidBody?this._rigidBody.effectiveInvMass():void 0}get effectiveWorldInversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("effectiveWorldInversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.effectiveWorldInvInertiaSqrt():void 0}get enabledRotations(){if(!this._requireNotRemoved("enabledRotations"))return{x:!0,y:!0,z:!0};return this._enabledRotations}get enabledPositions(){if(!this._requireNotRemoved("enabledPositions"))return{x:!0,y:!0,z:!0};return this._enabledPositions}get gravityScale(){if(!this._requireNotRemoved("gravityScale"))return 0;return this._rigidBody?this._rigidBody.gravityScale():this._rigidBodyDesc.gravityScale}get inverseMass(){if(!this._requireNotRemoved("inverseMass"))return;return this._rigidBody?this._rigidBody.invMass():void 0}get inversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("inversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.invPrincipalInertiaSqrt():void 0}get isCcdEnabled(){if(!this._requireNotRemoved("isCcdEnabled"))return!1;return this._rigidBody?this._rigidBody.isCcdEnabled():this._rigidBodyDesc.ccdEnabled}get isDynamic(){if(!this._requireNotRemoved("isDynamic"))return!1;return this._rigidBodyType==="dynamic"}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._rigidBody?this._rigidBody.isEnabled():this._rigidBodyDesc.enabled}get isFixed(){if(!this._requireNotRemoved("isFixed"))return!1;return this._rigidBodyType==="fixed"}get isKinematic(){if(!this._requireNotRemoved("isKinematic"))return!1;return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType)}get isKinematicPositionBased(){if(!this._requireNotRemoved("isKinematicPositionBased"))return!1;return this._rigidBodyType==="kinematic_position"}get isKinematicVelocityBased(){if(!this._requireNotRemoved("isKinematicVelocityBased"))return!1;return this._rigidBodyType==="kinematic_velocity"}get isMoving(){if(!this._requireNotRemoved("isMoving"))return!1;return this._rigidBody?this._rigidBody.isMoving():!1}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return this._rigidBody?!0:!1}get isSleeping(){if(!this._requireNotRemoved("isSleeping"))return!1;return this._rigidBody?this._rigidBody.isSleeping():this._rigidBodyDesc.sleeping}get linearDamping(){if(!this._requireNotRemoved("linearDamping"))return 0;return this._rigidBody?this._rigidBody.linearDamping():this._rigidBodyDesc.linearDamping}get linearVelocity(){if(!this._requireNotRemoved("linearVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.linvel():this._rigidBodyDesc.linvel}get localCenterOfMass(){if(!this._requireNotRemoved("localCenterOfMass"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.localCom():this._rigidBodyDesc.centerOfMass}get mass(){if(!this._requireNotRemoved("mass"))return 0;return this._rigidBody?this._rigidBody.mass():this._rigidBodyDesc.mass}get nextKinematicRotation(){if(!this._requireNotRemoved("nextKinematicRotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.nextRotation():this._rigidBodyDesc.rotation}get nextKinematicPosition(){if(!this._requireNotRemoved("nextKinematicPosition"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.nextTranslation():this._rigidBodyDesc.translation}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(!this._requireNotRemoved("principalAngularInertia"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.principalInertia():this._rigidBodyDesc.principalAngularInertia}get principalAngularInertiaLocalFrame(){if(!this._requireNotRemoved("principalAngularInertiaLocalFrame"))return;return this._rigidBody?this._rigidBody.principalInertiaLocalFrame():void 0}get position(){if(!this._requireNotRemoved("position"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.translation():this._rigidBodyDesc.translation}get rawRigidBody(){if(!this._requireNotRemoved("rawRigidBody"))return;return this._rigidBody}get rotation(){if(!this._requireNotRemoved("rotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.rotation():this._rigidBodyDesc.rotation}get softCcdPrediction(){if(!this._requireNotRemoved("softCcdPrediction"))return 0;return this._rigidBody?this._rigidBody.softCcdPrediction():this._rigidBodyDesc.softCcdPrediction}get type(){if(!this._requireNotRemoved("type"))return"dynamic";return this._rigidBodyType}get worldCenterOfMass(){if(!this._requireNotRemoved("worldCenterOfMass"))return;return this._rigidBody?this._rigidBody.worldCom():void 0}setAdditionalMass(Z){if(!this._requireDynamic("setAdditionalMass"))return;if(!this._requireNotRemoved("setAdditionalMass"))return;this._rigidBody?this._rigidBody.setAdditionalMass(Z,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMass(Z)}setAdditionalMassProperties(Z){if(!this._requireDynamic("setAdditionalMassProperties"))return;if(!this._requireNotRemoved("setAdditionalMassProperties"))return;let{additionalMass:J,centerOfMass:X,principalAngularInertia:Y,principalAngularInertiaLocalFrame:$}=Z;this._rigidBody?this._rigidBody.setAdditionalMassProperties(J,X,Y,$,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMassProperties(J,X,Y,$)}setAdditionalSolverIterations(Z){if(!this._requireDynamic("setAdditionalSolverIterations"))return;if(!this._requireNotRemoved("setAdditionalSolverIterations"))return;this._rigidBody?this._rigidBody.setAdditionalSolverIterations(Z):this._rigidBodyDesc.setAdditionalSolverIterations(Z)}setAngularDamping(Z){if(!this._requireDynamic("setAngularDamping"))return;if(!this._requireNotRemoved("setAngularDamping"))return;this._rigidBody?this._rigidBody.setAngularDamping(Z):this._rigidBodyDesc.setAngularDamping(Z)}setAngularVelocity(Z){if(!this._requireNotKinematicPositionBased("setAngularVelocity"))return;if(!this._requireNotRemoved("setAngularVelocity"))return;this._rigidBody?this._rigidBody.setAngvel(Z,!this._explicitSleep):this._rigidBodyDesc.setAngvel(Z)}setCcdEnabled(Z){if(!this._requireDynamic("setCcdEnabled"))return;if(!this._requireNotRemoved("setCcdEnabled"))return;this._rigidBody?this._rigidBody.enableCcd(Z):this._rigidBodyDesc.setCcdEnabled(Z)}setDominanceGroup(Z){if(!this._requireDynamic("setDominanceGroup"))return;if(!this._requireNotRemoved("setDominanceGroup"))return;this._rigidBody?this._rigidBody.setDominanceGroup(Z):this._rigidBodyDesc.setDominanceGroup(Z)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._rigidBody?this._rigidBody.setEnabled(Z):this._rigidBodyDesc.setEnabled(Z)}setEnabledPositions(Z){if(!this._requireDynamic("setEnabledPositions"))return;if(!this._requireNotRemoved("setEnabledPositions"))return;this._rigidBody?this._rigidBody.setEnabledTranslations(Z.x,Z.y,Z.z,!this._explicitSleep):this._rigidBodyDesc.enabledTranslations(Z.x,Z.y,Z.z),this._enabledPositions=Z}setEnabledRotations(Z){if(!this._requireDynamic("setEnabledRotations"))return;if(!this._requireNotRemoved("setEnabledRotations"))return;this._rigidBody?this._rigidBody.setEnabledRotations(Z.x,Z.y,Z.z,!this._explicitSleep):this._rigidBodyDesc.enabledRotations(Z.x,Z.y,Z.z),this._enabledRotations=Z}setGravityScale(Z){if(!this._requireDynamic("setGravityScale"))return;if(!this._requireNotRemoved("setGravityScale"))return;this._rigidBody?this._rigidBody.setGravityScale(Z,!this._explicitSleep):this._rigidBodyDesc.setGravityScale(Z)}setLinearDamping(Z){if(!this._requireDynamic("setLinearDamping"))return;if(!this._requireNotRemoved("setLinearDamping"))return;this._rigidBody?this._rigidBody.setLinearDamping(Z):this._rigidBodyDesc.setLinearDamping(Z)}setLinearVelocity(Z){if(!this._requireNotKinematicPositionBased("setLinearVelocity"))return;if(!this._requireNotRemoved("setLinearVelocity"))return;this._rigidBody?this._rigidBody.setLinvel(Z,!this._explicitSleep):this._rigidBodyDesc.setLinvel(Z.x,Z.y,Z.z)}setNextKinematicRotation(Z){if(!this._requireKinematic("setNextKinematicRotation"))return;if(!this._requireNotRemoved("setNextKinematicRotation"))return;this._rigidBody?this._rigidBody.setNextKinematicRotation(Z):this._rigidBodyDesc.setRotation(Z)}setNextKinematicPosition(Z){if(!this._requireKinematic("setNextKinematicPosition"))return;if(!this._requireNotRemoved("setNextKinematicPosition"))return;this._rigidBody?this._rigidBody.setNextKinematicTranslation(Z):this._rigidBodyDesc.setTranslation(Z.x,Z.y,Z.z)}setPosition(Z){if(!this._requireNotRemoved("setPosition"))return;this._rigidBody?this._rigidBody.setTranslation(Z,!this._explicitSleep):this._rigidBodyDesc.setTranslation(Z.x,Z.y,Z.z)}setRotation(Z){if(!this._requireNotRemoved("setRotation"))return;this._rigidBody?this._rigidBody.setRotation(Z,!this._explicitSleep):this._rigidBodyDesc.setRotation(Z)}setSleeping(Z){if(!this._requireDynamic("setSleeping"))return;if(!this._requireNotRemoved("setSleeping"))return;this._rigidBody?Z?this._rigidBody.sleep():this._rigidBody.wakeUp():this._rigidBodyDesc.sleeping=Z,this._explicitSleep=Z}setSoftCcdPrediction(Z){if(!this._requireDynamic("setSoftCcdPrediction"))return;if(!this._requireNotRemoved("setSoftCcdPrediction"))return;this._rigidBody?this._rigidBody.setSoftCcdPrediction(Z):this._rigidBodyDesc.setSoftCcdPrediction(Z)}setCollisionGroupsForSolidColliders(Z){if(!this._requireNotRemoved("setCollisionGroupsForSolidColliders"))return;this._colliders.forEach((J)=>{if(J.isSensor)return;J.setCollisionGroups(Z)})}setCollisionGroupsForSensorColliders(Z){if(!this._requireNotRemoved("setCollisionGroupsForSensorColliders"))return;this._colliders.forEach((J)=>{if(!J.isSensor)return;J.setCollisionGroups(Z)})}setType(Z){if(!this._requireNotRemoved("setType"))return;let X={["dynamic"]:MZ.default.RigidBodyType.Dynamic,["fixed"]:MZ.default.RigidBodyType.Fixed,["kinematic_position"]:MZ.default.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:MZ.default.RigidBodyType.KinematicVelocityBased}[Z];if(X===void 0)return u.error(`Invalid RigidBodyType: ${Z}`);this._rigidBody?this._rigidBody.setBodyType(X,!this._explicitSleep):this._rigidBodyDesc.status=X,this._rigidBodyType=Z}addForce(Z){if(!this._requireNotRemoved("addForce"))return;if(!this._requireCreated("addForce"))return;if(!this._requireDynamic("addForce"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.addForce(Z,!this._explicitSleep)}addTorque(Z){if(!this._requireNotRemoved("addTorque"))return;if(!this._requireCreated("addTorque"))return;if(!this._requireDynamic("addTorque"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.addTorque(Z,!this._explicitSleep)}addChildColliderToSimulation(Z){if(!this._requireNotRemoved("addChildColliderToSimulation"))return;if(!this._requireCreated("addChildColliderToSimulation"))return;Z.addToSimulation(this._simulation,this)}addToSimulation(Z){if(!this._requireNotRemoved("addToSimulation"))return;if(this._rigidBody)return u.error("RigidBody.addToSimulation(): Rigid body already exists in the simulation!");this._simulation=Z,this._rigidBody=this._simulation.createRawRigidBody(this._rigidBodyDesc),this._colliders.forEach((J)=>{if(!J.isSimulated)J.addToSimulation(Z,this)})}applyImpulse(Z){if(!this._requireNotRemoved("applyImpulse"))return;if(!this._requireCreated("applyImpulse"))return;if(!this._requireDynamic("applyImpulse"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.applyImpulse(Z,!this._explicitSleep)}applyImpulseAtPoint(Z,J){if(!this._requireNotRemoved("applyImpulseAtPoint"))return;if(!this._requireCreated("applyImpulseAtPoint"))return;if(!this._requireDynamic("applyImpulseAtPoint"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.applyImpulseAtPoint(Z,J,!this._explicitSleep)}applyTorqueImpulse(Z){if(!this._requireNotRemoved("applyTorqueImpulse"))return;if(!this._requireCreated("applyTorqueImpulse"))return;if(!this._requireDynamic("applyTorqueImpulse"))return;this._rigidBody.applyTorqueImpulse(Z,!this._explicitSleep)}createAndAddChildCollider(Z){if(!this._requireNotRemoved("createAndAddChildCollider"))return null;return this._simulation?new e5({...Z,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(Z)}createAndAddChildColliders(Z){let J=[];return Z.forEach((X)=>{let Y=this.createAndAddChildCollider(X);if(Y)J.push(Y)}),J}getCollidersByTag(Z){let J=[];for(let X of this._colliders)if(X.tag===Z)J.push(X);return J}linkCollider(Z){if(!this._requireNotRemoved("linkCollider"))return;if(Z.parentRigidBody!==this)return u.error("RigidBody.linkCollider(): Collider cannot be linked because it is not a child of this rigid body!");this._colliders.add(Z)}lockAllRotations(){if(!this._requireNotRemoved("lockAllRotations"))return;this.setEnabledRotations({x:!1,y:!1,z:!1})}lockAllPositions(){if(!this._requireNotRemoved("lockAllPositions"))return;this.setEnabledPositions({x:!1,y:!1,z:!1})}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._rigidBody)return u.error("RigidBody.removeFromSimulation(): Rigid body does not exist in the simulation!");this._colliders.forEach((Z)=>{Z.removeFromSimulation()}),this._simulation.removeRawRigidBody(this._rigidBody),this._simulation=void 0,this._rigidBody=void 0}unlinkCollider(Z){if(!this._requireNotRemoved("unlinkCollider"))return;if(!Z.isRemoved)return u.error("RigidBody.unlinkCollider(): Collider is still simulated and therefore cannot be unlinked from this rigid body!");this._colliders.delete(Z)}resetAngularVelocity(){if(!this._requireNotRemoved("resetAngularVelocity"))return;if(!this._requireCreated("resetAngularVelocity"))return;this.setAngularVelocity({x:0,y:0,z:0})}resetForces(){if(!this._requireNotRemoved("resetForces"))return;if(!this._requireCreated("resetForces"))return;this._rigidBody.resetForces(!this._explicitSleep)}resetLinearVelocity(){if(!this._requireNotRemoved("resetLinearVelocity"))return;if(!this._requireCreated("resetLinearVelocity"))return;this.setLinearVelocity({x:0,y:0,z:0})}resetTorques(){if(!this._requireNotRemoved("resetTorques"))return;if(!this._requireCreated("resetTorques"))return;this._rigidBody.resetTorques(!this._explicitSleep)}sleep(){if(!this._requireNotRemoved("sleep"))return;this.setSleeping(!0)}wakeUp(){if(!this._requireNotRemoved("wakeUp"))return;this.setSleeping(!1)}_applyRigidBodyOptions(Z){[["additionalMass",this.setAdditionalMass.bind(this)],["additionalMassProperties",this.setAdditionalMassProperties.bind(this)],["additionalSolverIterations",this.setAdditionalSolverIterations.bind(this)],["angularDamping",this.setAngularDamping.bind(this)],["angularVelocity",this.setAngularVelocity.bind(this)],["dominanceGroup",this.setDominanceGroup.bind(this)],["ccdEnabled",this.setCcdEnabled.bind(this)],["enabled",this.setEnabled.bind(this)],["enabledPositions",this.setEnabledPositions.bind(this)],["enabledRotations",this.setEnabledRotations.bind(this)],["gravityScale",this.setGravityScale.bind(this)],["linearDamping",this.setLinearDamping.bind(this)],["linearVelocity",this.setLinearVelocity.bind(this)],["position",this.setPosition.bind(this)],["rotation",this.setRotation.bind(this)],["sleeping",this.setSleeping.bind(this)],["softCcdPrediction",this.setSoftCcdPrediction.bind(this)]].forEach(([X,Y])=>{if(X in Z)Y(Z[X])})}_autoAddToSimulation(Z){if(Z.colliders)this._createAndAddPendingChildColliders(Z.colliders);if(Z.simulation)this.addToSimulation(Z.simulation)}_createAndAddPendingChildCollider(Z){if(!this._requireNotRemoved("createAndAddPendingChildCollider"))return null;if(!this._requireNotSimulated("createAndAddPendingChildCollider"))return null;let J=new e5(Z);return this._colliders.add(J),J}_createAndAddPendingChildColliders(Z){let J=[];return Z.forEach((X)=>{let Y=this._createAndAddPendingChildCollider(X);if(Y)J.push(Y)}),J}_createRigidBodyDesc(Z){let J=Z.type??Zo;return{["dynamic"]:()=>MZ.default.RigidBodyDesc.dynamic(),["fixed"]:()=>MZ.default.RigidBodyDesc.fixed(),["kinematic_position"]:()=>MZ.default.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>MZ.default.RigidBodyDesc.kinematicVelocityBased()}[J]()}_requireCreated(Z){if(!this._rigidBody||!this._simulation)u.error(`RigidBody._requireCreated(): Rigid body has not been created and therefore does not support the invoked method: ${Z}()`);return!!this._rigidBody&&!!this._simulation}_requireDynamic(Z){if(!this.isDynamic)u.error(`RigidBody._requireDynamic(): Rigid body is not dynamic and therefore does not support the invoked method: ${Z}()`);return this.isDynamic}_requireKinematic(Z){if(!this.isKinematic)u.error(`RigidBody._requireKinematic(): Rigid body is not kinematic and therefore does not support the invoked method: ${Z}()`);return this.isKinematic}_requireNotKinematicPositionBased(Z){if(this.isKinematicPositionBased)u.error(`RigidBody._requireNotKinematicPositionBased(): Rigid body is kinematic position based and therefore does not support the invoked method: ${Z}()`);return!this.isKinematicPositionBased}_requireNotRemoved(Z){if(!this._rigidBody&&!this._rigidBodyDesc)u.error(`RigidBody._requireNotRemoved(): Rigid body has been removed and therefore does not support the invoked method: ${Z}()`);return!!this._rigidBody||!!this._rigidBodyDesc}_requireNotSimulated(Z){if(this.isSimulated)u.error(`RigidBody._requireNotSimulated(): Rigid body is simulated and therefore does not support the invoked method: ${Z}()`);return!this.isSimulated}_isNegligibleVector(Z){return Math.abs(Z.x)<yT&&Math.abs(Z.y)<yT&&Math.abs(Z.z)<yT}}var bT;(($)=>{$[$.Average=0]="Average";$[$.Min=1]="Min";$[$.Multiply=2]="Multiply";$[$.Max=3]="Max"})(bT||={});var AV;((V)=>{V.NONE="none";V.BALL="ball";V.BLOCK="block";V.CAPSULE="capsule";V.CONE="cone";V.CYLINDER="cylinder";V.ROUND_CYLINDER="round-cylinder";V.TRIMESH="trimesh";V.WEDGE="wedge"})(AV||={});class e5 extends B0{_collider;_colliderDesc;_onCollision;_parentRigidBody;_relativePosition={x:0,y:0,z:0};_relativeRotation={x:0,y:0,z:0,w:1};_shape;_simulation;_tag;constructor(Z){super();this._colliderDesc=this._createColliderDesc(Z),this._shape=Z.shape,this._applyColliderOptions(Z),this._autoAddToSimulation(Z)}static optionsFromBlockHalfExtents(Z){return{shape:"block",halfExtents:Z}}static optionsFromModelUri(Z,J=1,X){let Y=E5.instance.getBoundingBox(Z),$=Y.max.x-Y.min.x,Q=Y.max.y-Y.min.y,K=Y.max.z-Y.min.z,W=Math.max($,K),G=Math.min($,K),V=W/G,H=W/Q,F=W*J/2,z=(O)=>Math.max(0.01,O),q=()=>({shape:"block",halfExtents:{x:z($*J/2),y:z(Q*J/2),z:z(K*J/2)}}),U=()=>({shape:"round-cylinder",radius:z(F),halfHeight:z(Q*J/2),borderRadius:z(F*0.1)}),L=()=>{let O=E5.instance.getTrimesh(Z,J);if(!O)return;return{shape:"trimesh",vertices:O.vertices,indices:O.indices}},B=()=>({shape:"wedge",extents:{x:$*J,y:Q*J,z:K*J}}),w=()=>({shape:"capsule",radius:z(F),halfHeight:z(Q*J/2-F)});if(X)switch(X){case"block":return q();case"capsule":return w();case"round-cylinder":return U();case"trimesh":{let O=L();if(!O){u.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return O}case"wedge":return B();default:u.warning(`Collider.optionsFromModelUri(): Preferred shape ${X} is not yet supported with Collider.optionsFromModelUri(), defaulting to generic shape!`)}if(V>2)return q();if(H>1.5)return U();return w()}get bounciness(){if(!this._requireNotRemoved("bounciness"))return 0;return this._collider?this._collider.restitution():this._colliderDesc.restitution}get bouncinessCombineRule(){if(!this._requireNotRemoved("bouncinessCombineRule"))return 0;return this._collider?this._collider.restitutionCombineRule():this._colliderDesc.restitutionCombineRule}get collisionGroups(){if(!this._requireNotRemoved("collisionGroups"))return{belongsTo:[],collidesWith:[]};return this._collider?z4.decodeRawCollisionGroups(this._collider.collisionGroups()):z4.decodeRawCollisionGroups(this._colliderDesc.collisionGroups)}get friction(){if(!this._requireNotRemoved("friction"))return 0;return this._collider?this._collider.friction():this._colliderDesc.friction}get frictionCombineRule(){if(!this._requireNotRemoved("frictionCombineRule"))return 0;return this._collider?this._collider.frictionCombineRule():this._colliderDesc.frictionCombineRule}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._collider?this._collider.isEnabled():this._colliderDesc.enabled}get isRemoved(){return!this._collider&&!this._colliderDesc}get isSensor(){if(!this._requireNotRemoved("isSensor"))return!1;return this._collider?this._collider.isSensor():this._colliderDesc.isSensor}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return!!this._collider}get parentRigidBody(){if(!this._requireNotRemoved("parentRigidBody"))return;return this._parentRigidBody}get rawCollider(){if(!this._requireNotRemoved("rawCollider"))return;return this._collider}get rawShape(){if(!this._requireNotRemoved("rawShape"))return;return this._collider?this._collider.shape:this._colliderDesc.shape}get relativePosition(){if(!this._requireNotRemoved("relativePosition"))return{x:0,y:0,z:0};return this._relativePosition}get relativeRotation(){if(!this._requireNotRemoved("relativeRotation"))return{x:0,y:0,z:0,w:1};return this._relativeRotation}get shape(){if(!this._requireNotRemoved("shape"))return"none";return this._shape}get tag(){if(!this._requireNotRemoved("tag"))return;return this._tag}setBounciness(Z){if(!this._requireNotRemoved("setBounciness"))return;this._collider?this._collider.setRestitution(Z):this._colliderDesc.setRestitution(Z)}setBouncinessCombineRule(Z){if(!this._requireNotRemoved("setBouncinessCombineRule"))return;this._collider?this._collider.setRestitutionCombineRule(Z):this._colliderDesc.setRestitutionCombineRule(Z)}setCollisionGroups(Z){if(!this._requireNotRemoved("setCollisionGroups"))return;let J=z4.buildRawCollisionGroups(Z);this._collider?this._collider.setCollisionGroups(J):this._colliderDesc.setCollisionGroups(J)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._collider?this._collider.setEnabled(Z):this._colliderDesc.setEnabled(Z)}setFriction(Z){if(!this._requireNotRemoved("setFriction"))return;this._collider?this._collider.setFriction(Z):this._colliderDesc.setFriction(Z)}setFrictionCombineRule(Z){if(!this._requireNotRemoved("setFrictionCombineRule"))return;this._collider?this._collider.setFrictionCombineRule(Z):this._colliderDesc.setFrictionCombineRule(Z)}setMass(Z){if(!this._requireNotRemoved("setMass"))return;this._collider?this._collider.setMass(Z):this._colliderDesc.setMass(Z)}setOnCollision(Z){if(!this._requireNotRemoved("setOnCollision"))return;if(this._onCollision=Z,this.isSimulated)if(this.enableCollisionEvents(!!Z),Z)this._simulation.colliderMap.setColliderCollisionCallback(this,Z);else this._simulation.colliderMap.removeColliderCollisionCallback(this)}setRelativeRotation(Z){if(!this._requireNotRemoved("setRelativeRotation"))return;this._relativeRotation=Z,this._collider?this._collider.parent()?this._collider.setRotationWrtParent(Z):this._collider.setRotation(Z):this._colliderDesc.setRotation(Z)}setRelativePosition(Z){if(!this._requireNotRemoved("setRelativePosition"))return;this._relativePosition=Z,this._collider?this._collider.parent()?this._collider.setTranslationWrtParent(Z):this._collider.setTranslation(Z):this._colliderDesc.setTranslation(Z.x,Z.y,Z.z)}setSensor(Z){if(!this._requireNotRemoved("setSensor"))return;this._collider?this._collider.setSensor(Z):this._colliderDesc.setSensor(Z)}setTag(Z){if(!this._requireNotRemoved("setTag"))return;this._tag=Z}addToSimulation(Z,J){if(!this._requireNotRemoved("addToSimulation"))return;if(!this._requireUnsimulated("addToSimulation"))return;if(J){if(!J.isSimulated)return u.error("Collider.addToSimulation(): Rigid body must be simulated before adding a collider to it!");if(J.type==="dynamic"&&this.shape==="trimesh")u.warning("Collider.addToSimulation(): Trimesh colliders are strongly discouraged to be used with dynamic rigid bodies, they will not contribute any mass!")}if(this._simulation=Z,this._parentRigidBody=J,this._collider=this._simulation.createRawCollider(this._colliderDesc,J?.rawRigidBody),this._colliderDesc=void 0,J)J.linkCollider(this);if(this._onCollision)this.setOnCollision(this._onCollision)}scale(Z){if(!this._requireNotRemoved("scale"))return;switch(this.setRelativePosition({x:this.relativePosition.x*Z,y:this.relativePosition.y*Z,z:this.relativePosition.z*Z}),this._shape){case"ball":{if(this._collider)this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.radius*=Z;return}case"block":{if(this._collider){let J=this._collider.halfExtents();this._collider.setHalfExtents({x:J.x*Z,y:J.y*Z,z:J.z*Z})}else this._colliderDesc.shape.halfExtents.x*=Z,this._colliderDesc.shape.halfExtents.y*=Z,this._colliderDesc.shape.halfExtents.z*=Z;return}case"capsule":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cone":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"round-cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRoundRadius(this._collider.roundRadius()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight=this._colliderDesc.shape.halfHeight*Z,this._colliderDesc.shape.borderRadius=this._colliderDesc.shape.borderRadius*Z,this._colliderDesc.shape.radius=this._colliderDesc.shape.radius*Z;return}case"trimesh":{u.error("Collider.setScale(): Trimesh colliders cannot be scaled!");return}case"wedge":{u.error("Collider.setScale(): Wedge colliders cannot be scaled!");return}default:u.fatalError(`Collider.setScale(): ${this._shape} is not a valid collider shape!`)}}enableCollisionEvents(Z){if(!this._requireNotRemoved("enableCollisionEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|e8.default.ActiveEvents.COLLISION_EVENTS:J&~e8.default.ActiveEvents.COLLISION_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}enableContactForceEvents(Z){if(!this._requireNotRemoved("enableContactForceEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|e8.default.ActiveEvents.CONTACT_FORCE_EVENTS:J&~e8.default.ActiveEvents.CONTACT_FORCE_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._requireSimulated("removeFromSimulation"))return;if(this._simulation.removeRawCollider(this._collider),this._simulation=void 0,this._collider=void 0,this._parentRigidBody)this._parentRigidBody.unlinkCollider(this);this._parentRigidBody=void 0}_applyColliderOptions(Z){[["bounciness",this.setBounciness.bind(this)],["bouncinessCombineRule",this.setBouncinessCombineRule.bind(this)],["collisionGroups",this.setCollisionGroups.bind(this)],["enabled",this.setEnabled.bind(this)],["friction",this.setFriction.bind(this)],["frictionCombineRule",this.setFrictionCombineRule.bind(this)],["isSensor",this.setSensor.bind(this)],["mass",this.setMass.bind(this)],["onCollision",this.setOnCollision.bind(this)],["relativePosition",this.setRelativePosition.bind(this)],["relativeRotation",this.setRelativeRotation.bind(this)],["tag",this.setTag.bind(this)]].forEach(([X,Y])=>{if(Z[X]!==void 0)Y.call(this,Z[X])})}_autoAddToSimulation(Z){if(Z.simulation)this.addToSimulation(Z.simulation,Z.parentRigidBody)}_buildWedgeConvexHullVertices(Z){let{x:J,y:X,z:Y}=Z,$=J/2,Q=Y/2,K=X/2;return new Float32Array([-$,0-K,-Q,$,0-K,-Q,$,0-K,Q,-$,0-K,Q,-$,X-K,-Q,$,X-K,-Q])}_createColliderDesc(Z){let{shape:J,flags:X}=Z;switch(J){case"ball":{if(!Z.radius)u.fatalError("Ball collider must have a radius!");return e8.default.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)u.fatalError("Block collider must have halfExtents!");return e8.default.ColliderDesc.cuboid(Z.halfExtents.x,Z.halfExtents.y,Z.halfExtents.z)}case"capsule":{if(!Z.halfHeight||!Z.radius)u.fatalError("Capsule collider must have halfHeight and radius!");return e8.default.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)u.fatalError("Cone collider must have radius and halfHeight!");return e8.default.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)u.fatalError("Cylinder collider must have radius and halfHeight!");return e8.default.ColliderDesc.cylinder(Z.halfHeight,Z.radius)}case"round-cylinder":{if(!Z.radius||!Z.halfHeight||!Z.borderRadius)u.fatalError("Round cylinder collider must have radius, halfHeight, and borderRadius!");return e8.default.ColliderDesc.roundCylinder(Z.halfHeight,Z.radius,Z.borderRadius)}case"trimesh":{if(!Z.indices||!Z.vertices)u.fatalError("Trimesh collider must have vertices and indices!");return e8.default.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"wedge":{if(!Z.extents)u.fatalError("Wedge collider must have extents!");let Y=this._buildWedgeConvexHullVertices(Z.extents),$=e8.default.ColliderDesc.convexHull(Y);if(!$)throw u.fatalError("Failed to create convex hull for wedge collider!"),new Error("Convex hull creation failed");return $}default:u.fatalError(`Collider._createColliderDesc(): ${J} is not a valid collider shape!`)}}_requireSimulated(Z){if(!this.isSimulated)u.error(`Collider._requireSimulated(): Collider is not simulated, invoked method: ${Z}()`);return this.isSimulated}_requireUnsimulated(Z){if(this.isSimulated)u.error(`Collider._requireUnsimulated(): Collider is already simulated, invoked method: ${Z}()`);return!this.isSimulated}_requireNotRemoved(Z){if(this.isRemoved)u.error(`Collider._requireNotRemoved(): Collider is removed, invoked method: ${Z}()`);return!this.isRemoved}_setActiveCollisionTypes(){(this._collider??this._colliderDesc).setActiveCollisionTypes(e8.default.ActiveCollisionTypes.DYNAMIC_DYNAMIC|e8.default.ActiveCollisionTypes.DYNAMIC_KINEMATIC|e8.default.ActiveCollisionTypes.DYNAMIC_FIXED|e8.default.ActiveCollisionTypes.KINEMATIC_KINEMATIC|e8.default.ActiveCollisionTypes.KINEMATIC_FIXED)}}var mP1={shape:"trimesh",flags:Jo.TriMeshFlags.FIX_INTERNAL_EDGES},uP1=new Uint32Array([0,1,2,2,3,0,4,5,6,6,7,4,8,9,10,10,11,8,12,13,14,14,15,12,16,17,18,18,19,16,20,21,22,22,23,20]),dP1=new Float32Array([-0.5,-0.5,0.5,0.5,-0.5,0.5,0.5,0.5,0.5,-0.5,0.5,0.5,-0.5,-0.5,-0.5,0.5,-0.5,-0.5,0.5,0.5,-0.5,-0.5,0.5,-0.5,-0.5,0.5,-0.5,0.5,0.5,-0.5,0.5,0.5,0.5,-0.5,0.5,0.5,-0.5,-0.5,-0.5,0.5,-0.5,-0.5,0.5,-0.5,0.5,-0.5,-0.5,0.5,0.5,-0.5,-0.5,0.5,0.5,-0.5,0.5,0.5,0.5,0.5,-0.5,0.5,-0.5,-0.5,-0.5,-0.5,0.5,-0.5,-0.5,0.5,0.5,-0.5,-0.5,0.5]),gT;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(gT||={});class Z9 extends B0{_id;_customColliderOptions;_isLiquid;_name;_textureUri;constructor(Z={id:-1,textureUri:"textures/missing.png",name:"Unknown"}){if(Z.id<0)u.fatalError("BlockType.constructor(): BlockType id not set.");super();this._id=Z.id,this._customColliderOptions=Z.customColliderOptions,this._isLiquid=Z.isLiquid??!1,this._name=Z.name,this._textureUri=Z.textureUri}get id(){return this._id}get colliderOptions(){return{...this._customColliderOptions,...mP1}}get isLiquid(){return this._isLiquid}get isMeshable(){return!this._customColliderOptions}get name(){return this._name}get textureUri(){return this._textureUri}createCollider(Z=uP1,J=dP1){let X=new e5({...this.colliderOptions,indices:Z,vertices:J});if(this.isLiquid)X.setSensor(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_COLLISION")||this.isLiquid)X.enableCollisionEvents(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))X.enableContactForceEvents(!0);if(z4.isDefaultCollisionGroups(X.collisionGroups))X.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return X}serialize(){return M0.serializeBlockType(this)}}var mT;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(mT||={});class xV extends B0{_blockTypes=new Map;_world;constructor(Z){super();this._world=Z}get world(){return this._world}getAllBlockTypes(){return Array.from(this._blockTypes.values())}getBlockType(Z){let J=this._blockTypes.get(Z);if(!J)u.fatalError(`BlockTypeRegistry.getBlockType(): BlockType with id ${Z} not found.`);return J}registerGenericBlockType(Z){let X=new class extends Z9{constructor(Y=Z){super(Y)}};return this.registerBlockType(X),X}registerBlockType(Z){this._blockTypes.set(Z.id,Z),this.emitWithWorld(this._world,"BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE",{blockTypeRegistry:this,id:Z.id,blockType:Z})}serialize(){return M0.serializeBlockTypeRegistry(this)}}var wk={};Pq(wk,{worldSchema:()=>Bk,worldPacketDefinition:()=>s00,vectorSchema:()=>$1,vectorBooleanSchema:()=>mv1,uiSchema:()=>Uk,uiPacketDefinition:()=>n00,uiDatasSchema:()=>Lk,uiDatasPacketDefinition:()=>a00,uiDataSendPacketDefinition:()=>S00,uiDataSchema:()=>$H,syncResponseSchema:()=>qk,syncResponsePacketDefinition:()=>i00,syncRequestSchema:()=>uE,syncRequestPacketDefinition:()=>v00,stateRequestSchema:()=>mE,stateRequestPacketDefinition:()=>_00,sceneUIsSchema:()=>Fk,sceneUIsPacketDefinition:()=>p00,sceneUISchema:()=>zk,rgbColorSchema:()=>A6,registeredPackets:()=>i2,quaternionSchema:()=>eE,playersSchema:()=>Hk,playersPacketDefinition:()=>l00,playerSchema:()=>Vk,physicsDebugRenderSchema:()=>Gk,physicsDebugRenderPacketDefinition:()=>d00,physicsDebugRaycastsSchema:()=>Wk,physicsDebugRaycastsPacketDefinition:()=>c00,physicsDebugRaycastSchema:()=>Kk,particleEmittersSchema:()=>Qk,particleEmittersPacketDefinition:()=>u00,particleEmitterSchema:()=>$k,outboundPackets:()=>p2,modelNodeOverrideSchema:()=>tE,lightsSchema:()=>Yk,lightsPacketDefinition:()=>m00,lightSchema:()=>Xk,isValidPacket:()=>dv1,inputSchema:()=>gE,inputPacketDefinition:()=>I00,inboundPackets:()=>l2,hexColorSchema:()=>yE,heartbeatSchema:()=>fE,heartbeatPacketDefinition:()=>T00,entitySchema:()=>Zk,entitiesSchema:()=>Jk,entitiesPacketDefinition:()=>g00,definePacket:()=>C0,debugConfigSchema:()=>bE,debugConfigPacketDefinition:()=>k00,createPacket:()=>_v1,connectionSchema:()=>hE,connectionPacketDefinition:()=>C00,chunksSchema:()=>rE,chunksPacketDefinition:()=>b00,chunkSchema:()=>oE,chatMessagesSchema:()=>sE,chatMessagesPacketDefinition:()=>y00,chatMessageSendPacketDefinition:()=>E00,chatMessageSchema:()=>YH,cameraSchema:()=>aE,cameraPacketDefinition:()=>f00,blocksSchema:()=>pE,blocksPacketDefinition:()=>x00,blockTypesSchema:()=>nE,blockTypesPacketDefinition:()=>h00,blockTypeSchema:()=>iE,blockSchema:()=>lE,bidirectionalPackets:()=>c2,audiosSchema:()=>cE,audiosPacketDefinition:()=>A00,audioSchema:()=>dE,PacketId:()=>I1});var c2={};Pq(c2,{heartbeatPacketDefinition:()=>T00,connectionPacketDefinition:()=>C00});var AE=r(P00(),1);class xE extends AE.default{static instance=new AE.default}var I1;((E)=>{E[E.SYNC_REQUEST=0]="SYNC_REQUEST";E[E.INPUT=1]="INPUT";E[E.STATE_REQUEST=2]="STATE_REQUEST";E[E.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";E[E.UI_DATA_SEND=4]="UI_DATA_SEND";E[E.SYNC_RESPONSE=32]="SYNC_RESPONSE";E[E.AUDIOS=33]="AUDIOS";E[E.BLOCKS=34]="BLOCKS";E[E.BLOCK_TYPES=35]="BLOCK_TYPES";E[E.CHAT_MESSAGES=36]="CHAT_MESSAGES";E[E.CHUNKS=37]="CHUNKS";E[E.ENTITIES=38]="ENTITIES";E[E.WORLD=39]="WORLD";E[E.CAMERA=40]="CAMERA";E[E.UI=41]="UI";E[E.UI_DATAS=42]="UI_DATAS";E[E.SCENE_UIS=43]="SCENE_UIS";E[E.LIGHTS=44]="LIGHTS";E[E.PLAYERS=45]="PLAYERS";E[E.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";E[E.CONNECTION=116]="CONNECTION";E[E.HEARTBEAT=117]="HEARTBEAT";E[E.DEBUG_CONFIG=128]="DEBUG_CONFIG";E[E.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";E[E.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(I1||={});function _v1(Z,J,X){if(!Z.validate(J))throw new Error(`Invalid payload for packet with id ${Z.id}. Error: ${xE.instance.errorsText(Z.validate.errors)}`);let Y=[Z.id,J];if(typeof X==="number")Y.push(X);return Y}function C0(Z,J){return{id:Z,schema:J,validate:xE.instance.compile(J)}}var vv1={type:"object",properties:{i:{type:"string"}},required:["i"],additionalProperties:!1},D00={type:"object",properties:{role:{type:"string",enum:["auto","client","server"],nullable:!0},fingerprints:{type:"array",items:{type:"object",properties:{algorithm:{type:"string",enum:["sha-1","sha-224","sha-256","sha-384","sha-512"]},value:{type:"string"}},required:["algorithm","value"]}}},required:["fingerprints"],additionalProperties:!1},Sv1={type:"object",properties:{foundation:{type:"string"},priority:{type:"number"},ip:{type:"string"},address:{type:"string"},protocol:{type:"string",enum:["udp","tcp"]},port:{type:"number"},type:{type:"string",enum:["host"]},tcpType:{type:"string",enum:["passive"],nullable:!0}},required:["foundation","priority","ip","address","protocol","port","type"],additionalProperties:!1},Av1={type:"object",properties:{usernameFragment:{type:"string"},password:{type:"string"},iceLite:{type:"boolean",nullable:!0}},required:["usernameFragment","password"],additionalProperties:!1},xv1={type:"object",properties:{i:{type:"string"},l:{type:"string"}},required:["i","l"],additionalProperties:!1},hv1={type:"object",properties:{port:{type:"number"},OS:{type:"number"},MIS:{type:"number"},maxMessageSize:{type:"number"}},required:["port","OS","MIS","maxMessageSize"],additionalProperties:!0},fv1={type:"object",properties:{streamId:{type:"number"},ordered:{type:"boolean",nullable:!0},maxPacketLifeTime:{type:"number",nullable:!0},maxRetransmits:{type:"number",nullable:!0}},required:["streamId"],additionalProperties:!1},yv1={type:"object",properties:{i:{type:"string"},f:{type:"string",enum:["cs","sc"]},ip:Av1,ic:{type:"array",items:Sv1},d:D00,s:hv1},required:["i","f","ip","ic","d","s"],additionalProperties:!1},bv1={type:"object",properties:{i:{type:"string"},d:D00},required:["i","d"],additionalProperties:!1},gv1={type:"object",properties:{i:{type:"string",nullable:!0},pi:{type:"string",nullable:!0},l:{type:"string"},s:fv1},required:["l","s"],additionalProperties:!1},hE={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},c:{...bv1,nullable:!0},ca:{...vv1,nullable:!0},d:{type:"array",items:{...gv1},nullable:!0},pa:{...xv1,nullable:!0},t:{type:"array",items:{...yv1},nullable:!0}},additionalProperties:!1};var C00=C0(116,hE);var fE={type:"null",nullable:!0};var T00=C0(117,fE);var l2={};Pq(l2,{uiDataSendPacketDefinition:()=>S00,syncRequestPacketDefinition:()=>v00,stateRequestPacketDefinition:()=>_00,inputPacketDefinition:()=>I00,debugConfigPacketDefinition:()=>k00,chatMessageSendPacketDefinition:()=>E00});var yE={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var YH={type:"object",properties:{m:{type:"string"},c:{...yE,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var E00=C0(3,YH);var bE={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var k00=C0(128,bE);var gE={type:"object",properties:{"1":{type:"boolean",nullable:!0},"2":{type:"boolean",nullable:!0},"3":{type:"boolean",nullable:!0},"4":{type:"boolean",nullable:!0},"5":{type:"boolean",nullable:!0},"6":{type:"boolean",nullable:!0},"7":{type:"boolean",nullable:!0},"8":{type:"boolean",nullable:!0},"9":{type:"boolean",nullable:!0},"0":{type:"boolean",nullable:!0},w:{type:"boolean",nullable:!0},a:{type:"boolean",nullable:!0},s:{type:"boolean",nullable:!0},d:{type:"boolean",nullable:!0},q:{type:"boolean",nullable:!0},e:{type:"boolean",nullable:!0},r:{type:"boolean",nullable:!0},f:{type:"boolean",nullable:!0},z:{type:"boolean",nullable:!0},x:{type:"boolean",nullable:!0},c:{type:"boolean",nullable:!0},v:{type:"boolean",nullable:!0},u:{type:"boolean",nullable:!0},i:{type:"boolean",nullable:!0},o:{type:"boolean",nullable:!0},j:{type:"boolean",nullable:!0},k:{type:"boolean",nullable:!0},l:{type:"boolean",nullable:!0},n:{type:"boolean",nullable:!0},m:{type:"boolean",nullable:!0},sp:{type:"boolean",nullable:!0},sh:{type:"boolean",nullable:!0},tb:{type:"boolean",nullable:!0},ml:{type:"boolean",nullable:!0},mr:{type:"boolean",nullable:!0},cp:{type:"number",nullable:!0},cy:{type:"number",nullable:!0},sq:{type:"number",nullable:!0}},additionalProperties:!1};var I00=C0(1,gE);var mE={type:"object",properties:{},additionalProperties:!1};var _00=C0(2,mE);var uE={type:"null",nullable:!0};var v00=C0(0,uE);var $H={type:"object",properties:{},additionalProperties:!0};var S00=C0(4,$H);var p2={};Pq(p2,{worldPacketDefinition:()=>s00,uiPacketDefinition:()=>n00,uiDatasPacketDefinition:()=>a00,syncResponsePacketDefinition:()=>i00,sceneUIsPacketDefinition:()=>p00,playersPacketDefinition:()=>l00,physicsDebugRenderPacketDefinition:()=>d00,physicsDebugRaycastsPacketDefinition:()=>c00,particleEmittersPacketDefinition:()=>u00,lightsPacketDefinition:()=>m00,entitiesPacketDefinition:()=>g00,chunksPacketDefinition:()=>b00,chatMessagesPacketDefinition:()=>y00,cameraPacketDefinition:()=>f00,blocksPacketDefinition:()=>x00,blockTypesPacketDefinition:()=>h00,audiosPacketDefinition:()=>A00});var $1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var dE={type:"object",properties:{i:{type:"number"},a:{type:"string",nullable:!0},cd:{type:"number",nullable:!0},d:{type:"number",nullable:!0},de:{type:"number",nullable:!0},di:{type:"number",minimum:0,nullable:!0},e:{type:"number",nullable:!0},l:{type:"boolean",nullable:!0},o:{type:"number",nullable:!0},p:{...$1,nullable:!0},pa:{type:"boolean",nullable:!0},pl:{type:"boolean",nullable:!0},pr:{type:"number",minimum:0,nullable:!0},r:{type:"boolean",nullable:!0},rd:{type:"number",nullable:!0},s:{type:"number",nullable:!0},v:{type:"number",minimum:0,maximum:1,nullable:!0}},required:["i"],additionalProperties:!1};var cE={type:"array",items:{...dE}};var A00=C0(33,cE);var lE={type:"object",properties:{i:{type:"number"},c:$1},required:["i","c"],additionalProperties:!1};var pE={type:"array",items:{...lE}};var x00=C0(34,pE);var iE={type:"object",properties:{i:{type:"number"},l:{type:"boolean",nullable:!0},n:{type:"string",nullable:!0},t:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var nE={type:"array",items:{...iE}};var h00=C0(35,nE);var aE={type:"object",properties:{m:{type:"number",nullable:!0},e:{type:"number",nullable:!0},et:{type:"number",nullable:!0},fo:{type:"number",nullable:!0},ffo:{type:"number",nullable:!0},fv:{type:"number",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},o:{...$1,nullable:!0},p:{...$1,nullable:!0},pt:{...$1,nullable:!0},pl:{...$1,nullable:!0},s:{type:"array",items:{type:"string"},nullable:!0},sa:{type:"number",nullable:!0},z:{type:"number",nullable:!0}},additionalProperties:!1};var sE={type:"array",items:{...YH}};var oE={type:"object",properties:{c:$1,b:{type:"array",items:{type:"number",minimum:0,maximum:255},minItems:4096,maxItems:4096,nullable:!0},rm:{type:"boolean",nullable:!0}},required:["c"],additionalProperties:!1};var rE={type:"array",items:{...oE}};var A6={type:"array",items:[{type:"number",minimum:0,maximum:255},{type:"number",minimum:0,maximum:255},{type:"number",minimum:0,maximum:255}],minItems:3,maxItems:3};var tE={type:"object",properties:{n:{type:"string"},h:{type:"boolean",nullable:!0},o:{type:"number",minimum:0,maximum:1,nullable:!0},r:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},t:{...A6,nullable:!0}},required:["n"],additionalProperties:!1};var eE={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var Zk={type:"object",properties:{i:{type:"number"},al:{type:"array",items:{type:"string"},nullable:!0},ao:{type:"array",items:{type:"string"},nullable:!0},ap:{type:"number",nullable:!0},as:{type:"array",items:{type:"string"},nullable:!0},bh:{...$1,nullable:!0},bt:{type:"string",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},m:{type:"string",nullable:!0},mo:{type:"array",items:{...tE},nullable:!0},mt:{type:"string",nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...$1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{...eE,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sn:{type:"array",items:{type:"string"},nullable:!0},t:{...A6,nullable:!0}},required:["i"],additionalProperties:!1};var Jk={type:"array",items:{...Zk}};var Xk={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...A6,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...$1,nullable:!0},p:{...$1,nullable:!0},pe:{type:"number",minimum:0,maximum:1,nullable:!0},rm:{type:"boolean",nullable:!0},t:{type:"number",nullable:!0},te:{type:"number",nullable:!0},tp:{...$1,nullable:!0}},required:["i"],additionalProperties:!1};var Yk={type:"array",items:{...Xk}};var $k={type:"object",properties:{i:{type:"number"},at:{type:"number",nullable:!0},ce:{...A6,nullable:!0},cev:{...A6,nullable:!0},cs:{...A6,nullable:!0},csv:{...A6,nullable:!0},e:{type:"number",nullable:!0},en:{type:"string",nullable:!0},g:{...$1,nullable:!0},l:{type:"number",nullable:!0},lv:{type:"number",nullable:!0},mp:{type:"number",nullable:!0},o:{...$1,nullable:!0},oe:{type:"number",nullable:!0},oev:{type:"number",nullable:!0},os:{type:"number",nullable:!0},osv:{type:"number",nullable:!0},p:{...$1,nullable:!0},pv:{...$1,nullable:!0},r:{type:"number",nullable:!0},rv:{type:"number",nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sv:{type:"number",nullable:!0},t:{type:"boolean",nullable:!0},tu:{type:"string",nullable:!0},v:{...$1,nullable:!0},vv:{...$1,nullable:!0}},required:["i"],additionalProperties:!1};var Qk={type:"array",items:{...$k}};var Kk={type:"object",properties:{o:{...$1},d:{...$1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var Wk={type:"array",items:{...Kk}};var Gk={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var Vk={type:"object",properties:{i:{type:"string"},p:{type:"string",nullable:!0},rm:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var Hk={type:"array",items:{...Vk}};var zk={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...$1,nullable:!0},p:{...$1,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"object",nullable:!0},t:{type:"string",nullable:!0},v:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var Fk={type:"array",items:{...zk}};var qk={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var Uk={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var Lk={type:"array",items:{...$H}};var mv1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var Bk={type:"object",properties:{i:{type:"number"},ac:{...A6,nullable:!0},ai:{type:"number",nullable:!0},dc:{...A6,nullable:!0},di:{type:"number",nullable:!0},dp:{...$1,nullable:!0},fc:{...A6,nullable:!0},ff:{type:"number",nullable:!0},fn:{type:"number",nullable:!0},n:{type:"string",nullable:!0},s:{type:"string",nullable:!0},si:{type:"number",nullable:!0},t:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var f00=C0(40,aE);var y00=C0(36,sE);var b00=C0(37,rE);var g00=C0(38,Jk);var m00=C0(44,Yk);var u00=C0(46,Qk);var d00=C0(192,Gk);var c00=C0(193,Wk);var l00=C0(45,Hk);var p00=C0(43,Fk);var i00=C0(32,qk);var n00=C0(41,Uk);var a00=C0(42,Lk);var s00=C0(39,Bk);var i2=new Map,uv1={...c2,...l2,...p2};for(let Z of Object.values(uv1))if("id"in Z&&"schema"in Z){let J=Z;if(i2.has(J.id))throw new Error(`Packet with id ${J.id} is already registered.`);i2.set(J.id,J)}function dv1(Z){if(typeof Z!=="object"||Z===null||typeof Z[0]!=="number"||Z[0]<0||Z[1]===void 0||Z[2]!==void 0&&(typeof Z[2]!=="number"||Z[2]<0))return!1;let J=i2.get(Z[0]);return!!J&&J.validate(Z[1])}var Z0=wk;var N10=r(j10(),1);import oY from"fs";import O10 from"path";var KH="./dev/persistence";class N7{static instance=new N7;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;constructor(){try{this._creativeGateway=new N10.CreativeGateway}catch{console.warn(["━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","\uD83D\uDEA8 HYTOPIA PLATFORM GATEWAY IS NOT INITIALIZED \uD83D\uDEA8","","\uD83D\uDD27 Local development is still possible, but these features will be disabled:"," • \uD83D\uDC64 Player Accounts"," • \uD83C\uDFAD Player Cosmetics"," • \uD83D\uDC1B Crash Analytics & Debug Logs","","\uD83D\uDCA1 These features will be enabled but modified:"," • \uD83D\uDCBE Player & Global Persisted Data - Data will be persisted"," locally in the ./dev/persistence directory of your project."," Player ids for data persistence will begin at 1 for the first "," player to join your local server, and increments for each"," additional player. This means that if you restart your"," server, the first player id will be 1 again. This is to ensure"," that data persistence across server restarts can be easily"," tested and debugged in local development.","","To enable the HYTOPIA Platform Gateway locally:"," 1. Set these environment variables:"," HYTOPIA_API_KEY, HYTOPIA_GAME_ID, HYTOPIA_LOBBY_ID"," 2. You can find these values at: https://create.hytopia.com","","Note: In production, these environment variables will be auto-populated ","& the HYTOPIA Platform Gateway will automatically be initialized \uD83D\uDE80","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",""].join(`
414
+ >>> no match, partial?`,Z,F,J,z),F===W)return!0}return!1}let U;if(typeof V==="string")U=H===V,this.debug("string match",V,H,U);else U=V.test(H),this.debug("pattern match",V,H,U);if(!U)return!1}if(Q===W&&K===G)return!0;else if(Q===W)return X;else if(K===G)return Q===W-1&&Z[Q]==="";else throw new Error("wtf?")}braceExpand(){return Dl(this.pattern,this.options)}parse(Z){b3(Z);let J=this.options;if(Z==="**")return L6;if(Z==="")return"";let X,Y=null;if(X=Z.match(wL1))Y=J.dot?OL1:jL1;else if(X=Z.match(WL1))Y=(J.nocase?J.dot?zL1:HL1:J.dot?VL1:GL1)(X[1]);else if(X=Z.match(NL1))Y=(J.nocase?J.dot?ML1:RL1:J.dot?PL1:DL1)(X);else if(X=Z.match(FL1))Y=J.dot?UL1:qL1;else if(X=Z.match(LL1))Y=BL1;let $=U6.fromGlob(Z,this.options).toMMPattern();if(Y&&typeof $==="object")Reflect.defineProperty($,"test",{value:Y});return $}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let Z=this.set;if(!Z.length)return this.regexp=!1,this.regexp;let J=this.options,X=J.noglobstar?EL1:J.dot?kL1:IL1,Y=new Set(J.nocase?["i"]:[]),$=Z.map((W)=>{let G=W.map((V)=>{if(V instanceof RegExp)for(let H of V.flags.split(""))Y.add(H);return typeof V==="string"?xL1(V):V===L6?L6:V._src});return G.forEach((V,H)=>{let F=G[H+1],z=G[H-1];if(V!==L6||z===L6)return;if(z===void 0)if(F!==void 0&&F!==L6)G[H+1]="(?:\\/|"+X+"\\/)?"+F;else G[H]=X;else if(F===void 0)G[H-1]=z+"(?:\\/|"+X+")?";else if(F!==L6)G[H-1]=z+"(?:\\/|\\/"+X+"\\/)"+F,G[H+1]=L6}),G.filter((V)=>V!==L6).join("/")}).join("|"),[Q,K]=Z.length>1?["(?:",")"]:["",""];if($="^"+Q+$+K+"$",this.negate)$="^(?!"+$+").+$";try{this.regexp=new RegExp($,[...Y].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit(Z){if(this.preserveMultipleSlashes)return Z.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test(Z))return["",...Z.split(/\/+/)];else return Z.split(/\/+/)}match(Z,J=this.partial){if(this.debug("match",Z,this.pattern),this.comment)return!1;if(this.empty)return Z==="";if(Z==="/"&&J)return!0;let X=this.options;if(this.isWindows)Z=Z.split("\\").join("/");let Y=this.slashSplit(Z);this.debug(this.pattern,"split",Y);let $=this.set;this.debug(this.pattern,"set",$);let Q=Y[Y.length-1];if(!Q)for(let K=Y.length-2;!Q&&K>=0;K--)Q=Y[K];for(let K=0;K<$.length;K++){let W=$[K],G=Y;if(X.matchBase&&W.length===1)G=[Q];if(this.matchOne(G,W,J)){if(X.flipNegate)return!0;return!this.negate}}if(X.flipNegate)return!1;return this.negate}static defaults(Z){return p6.defaults(Z).Minimatch}}p6.AST=U6;p6.Minimatch=D9;p6.escape=JK;p6.unescape=L4;import{fileURLToPath as FB1}from"node:url";var XK=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,Tl=new Set,QD=typeof process==="object"&&!!process?process:{},El=(Z,J,X,Y)=>{typeof QD.emitWarning==="function"?QD.emitWarning(Z,J,X,Y):console.error(`[${X}] ${J}: ${Z}`)},IL=globalThis.AbortController,Cl=globalThis.AbortSignal;if(typeof IL==="undefined"){Cl=class X{onabort;_onabort=[];reason;aborted=!1;addEventListener(Y,$){this._onabort.push($)}},IL=class X{constructor(){J()}signal=new Cl;abort(Y){if(this.signal.aborted)return;this.signal.reason=Y,this.signal.aborted=!0;for(let $ of this.signal._onabort)$(Y);this.signal.onabort?.(Y)}};let Z=QD.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,El("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",J)}}var hL1=(Z)=>!Tl.has(Z),uD6=Symbol("type"),DJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),kl=(Z)=>!DJ(Z)?null:Z<=Math.pow(2,8)?Uint8Array:Z<=Math.pow(2,16)?Uint16Array:Z<=Math.pow(2,32)?Uint32Array:Z<=Number.MAX_SAFE_INTEGER?m3:null;class m3 extends Array{constructor(Z){super(Z);this.fill(0)}}class YK{heap;length;static#Z=!1;static create(Z){let J=kl(Z);if(!J)return[];YK.#Z=!0;let X=new YK(Z,J);return YK.#Z=!1,X}constructor(Z,J){if(!YK.#Z)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new J(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}}class u3{#Z;#J;#Y;#X;#$;#H;#F;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#V;#z;#Q;#U;#B;#L;#j;#E;#O;#k;#M;#R;#N;#C;#w;#_;static unsafeExposeInternals(Z){return{starts:Z.#M,ttls:Z.#R,sizes:Z.#k,keyMap:Z.#V,keyList:Z.#z,valList:Z.#Q,next:Z.#U,prev:Z.#B,get head(){return Z.#L},get tail(){return Z.#j},free:Z.#E,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,Y,$)=>Z.#h(J,X,Y,$),moveToTail:(J)=>Z.#b(J),indexes:(J)=>Z.#T(J),rindexes:(J)=>Z.#I(J),isStale:(J)=>Z.#D(J)}}get max(){return this.#Z}get maxSize(){return this.#J}get calculatedSize(){return this.#G}get size(){return this.#W}get fetchMethod(){return this.#H}get memoMethod(){return this.#F}get dispose(){return this.#Y}get onInsert(){return this.#X}get disposeAfter(){return this.#$}constructor(Z){let{max:J=0,ttl:X,ttlResolution:Y=1,ttlAutopurge:$,updateAgeOnGet:Q,updateAgeOnHas:K,allowStale:W,dispose:G,onInsert:V,disposeAfter:H,noDisposeOnSet:F,noUpdateTTL:z,maxSize:q=0,maxEntrySize:U=0,sizeCalculation:L,fetchMethod:B,memoMethod:w,noDeleteOnFetchRejection:O,noDeleteOnStaleGet:N,allowStaleOnFetchRejection:R,allowStaleOnFetchAbort:D,ignoreFetchAbort:M}=Z;if(J!==0&&!DJ(J))throw new TypeError("max option must be a nonnegative integer");let C=J?kl(J):Array;if(!C)throw new Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=U||this.#J,this.sizeCalculation=L,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw new TypeError("sizeCalculation set to non-function")}if(w!==void 0&&typeof w!=="function")throw new TypeError("memoMethod must be a function if defined");if(this.#F=w,B!==void 0&&typeof B!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#H=B,this.#C=!!B,this.#V=new Map,this.#z=new Array(J).fill(void 0),this.#Q=new Array(J).fill(void 0),this.#U=new C(J),this.#B=new C(J),this.#L=0,this.#j=0,this.#E=YK.create(J),this.#W=0,this.#G=0,typeof G==="function")this.#Y=G;if(typeof V==="function")this.#X=V;if(typeof H==="function")this.#$=H,this.#O=[];else this.#$=void 0,this.#O=void 0;if(this.#N=!!this.#Y,this.#_=!!this.#X,this.#w=!!this.#$,this.noDisposeOnSet=!!F,this.noUpdateTTL=!!z,this.noDeleteOnFetchRejection=!!O,this.allowStaleOnFetchRejection=!!R,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#J!==0){if(!DJ(this.#J))throw new TypeError("maxSize must be a positive integer if specified")}if(!DJ(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#m()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!N,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=DJ(Y)||Y===0?Y:1,this.ttlAutopurge=!!$,this.ttl=X||0,this.ttl){if(!DJ(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#K()}if(this.#Z===0&&this.ttl===0&&this.#J===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#J){if(hL1("LRU_CACHE_UNBOUNDED"))Tl.add("LRU_CACHE_UNBOUNDED"),El("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",u3)}}getRemainingTTL(Z){return this.#V.has(Z)?1/0:0}#K(){let Z=new m3(this.#Z),J=new m3(this.#Z);this.#R=Z,this.#M=J,this.#v=($,Q,K=XK.now())=>{if(J[$]=Q!==0?K:0,Z[$]=Q,Q!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#D($))this.#S(this.#z[$],"expire")},Q+1);if(W.unref)W.unref()}},this.#A=($)=>{J[$]=Z[$]!==0?XK.now():0},this.#P=($,Q)=>{if(Z[Q]){let K=Z[Q],W=J[Q];if(!K||!W)return;$.ttl=K,$.start=W,$.now=X||Y();let G=$.now-W;$.remainingTTL=K-G}};let X=0,Y=()=>{let $=XK.now();if(this.ttlResolution>0){X=$;let Q=setTimeout(()=>X=0,this.ttlResolution);if(Q.unref)Q.unref()}return $};this.getRemainingTTL=($)=>{let Q=this.#V.get($);if(Q===void 0)return 0;let K=Z[Q],W=J[Q];if(!K||!W)return 1/0;let G=(X||Y())-W;return K-G},this.#D=($)=>{let Q=J[$],K=Z[$];return!!K&&!!Q&&(X||Y())-Q>K}}#A=()=>{};#P=()=>{};#v=()=>{};#D=()=>!1;#m(){let Z=new m3(this.#Z);this.#G=0,this.#k=Z,this.#x=(J)=>{this.#G-=Z[J],Z[J]=0},this.#u=(J,X,Y,$)=>{if(this.#q(X))return 0;if(!DJ(Y))if($){if(typeof $!=="function")throw new TypeError("sizeCalculation must be a function");if(Y=$(X,J),!DJ(Y))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return Y},this.#f=(J,X,Y)=>{if(Z[J]=X,this.#J){let $=this.#J-Z[J];while(this.#G>$)this.#y(!0)}if(this.#G+=Z[J],Y)Y.entrySize=X,Y.totalCalculatedSize=this.#G}}#x=(Z)=>{};#f=(Z,J,X)=>{};#u=(Z,J,X,Y)=>{if(X||Y)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#T({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#j;;){if(!this.#d(J))break;if(Z||!this.#D(J))yield J;if(J===this.#L)break;else J=this.#B[J]}}*#I({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#L;;){if(!this.#d(J))break;if(Z||!this.#D(J))yield J;if(J===this.#j)break;else J=this.#U[J]}}#d(Z){return Z!==void 0&&this.#V.get(this.#z[Z])===Z}*entries(){for(let Z of this.#T())if(this.#Q[Z]!==void 0&&this.#z[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#z[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#I())if(this.#Q[Z]!==void 0&&this.#z[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#z[Z],this.#Q[Z]]}*keys(){for(let Z of this.#T()){let J=this.#z[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#I()){let J=this.#z[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*values(){for(let Z of this.#T())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}*rvalues(){for(let Z of this.#I())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Z,J={}){for(let X of this.#T()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;if(Z($,this.#z[X],this))return this.get(this.#z[X],J)}}forEach(Z,J=this){for(let X of this.#T()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;Z.call(J,$,this.#z[X],this)}}rforEach(Z,J=this){for(let X of this.#I()){let Y=this.#Q[X],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0)continue;Z.call(J,$,this.#z[X],this)}}purgeStale(){let Z=!1;for(let J of this.#I({allowStale:!0}))if(this.#D(J))this.#S(this.#z[J],"expire"),Z=!0;return Z}info(Z){let J=this.#V.get(Z);if(J===void 0)return;let X=this.#Q[J],Y=this.#q(X)?X.__staleWhileFetching:X;if(Y===void 0)return;let $={value:Y};if(this.#R&&this.#M){let Q=this.#R[J],K=this.#M[J];if(Q&&K){let W=Q-(XK.now()-K);$.ttl=W,$.start=Date.now()}}if(this.#k)$.size=this.#k[J];return $}dump(){let Z=[];for(let J of this.#T({allowStale:!0})){let X=this.#z[J],Y=this.#Q[J],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0||X===void 0)continue;let Q={value:$};if(this.#R&&this.#M){Q.ttl=this.#R[J];let K=XK.now()-this.#M[J];Q.start=Math.floor(Date.now()-K)}if(this.#k)Q.size=this.#k[J];Z.unshift([X,Q])}return Z}load(Z){this.clear();for(let[J,X]of Z){if(X.start){let Y=Date.now()-X.start;X.start=XK.now()-Y}this.set(J,X.value,X)}}set(Z,J,X={}){if(J===void 0)return this.delete(Z),this;let{ttl:Y=this.ttl,start:$,noDisposeOnSet:Q=this.noDisposeOnSet,sizeCalculation:K=this.sizeCalculation,status:W}=X,{noUpdateTTL:G=this.noUpdateTTL}=X,V=this.#u(Z,J,X.size||0,K);if(this.maxEntrySize&&V>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#S(Z,"set"),this}let H=this.#W===0?void 0:this.#V.get(Z);if(H===void 0){if(H=this.#W===0?this.#j:this.#E.length!==0?this.#E.pop():this.#W===this.#Z?this.#y(!1):this.#W,this.#z[H]=Z,this.#Q[H]=J,this.#V.set(Z,H),this.#U[this.#j]=H,this.#B[H]=this.#j,this.#j=H,this.#W++,this.#f(H,V,W),W)W.set="add";if(G=!1,this.#_)this.#X?.(J,Z,"add")}else{this.#b(H);let F=this.#Q[H];if(J!==F){if(this.#C&&this.#q(F)){F.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:z}=F;if(z!==void 0&&!Q){if(this.#N)this.#Y?.(z,Z,"set");if(this.#w)this.#O?.push([z,Z,"set"])}}else if(!Q){if(this.#N)this.#Y?.(F,Z,"set");if(this.#w)this.#O?.push([F,Z,"set"])}if(this.#x(H),this.#f(H,V,W),this.#Q[H]=J,W){W.set="replace";let z=F&&this.#q(F)?F.__staleWhileFetching:F;if(z!==void 0)W.oldValue=z}}else if(W)W.set="update";if(this.#_)this.onInsert?.(J,Z,J===F?"update":"replace")}if(Y!==0&&!this.#R)this.#K();if(this.#R){if(!G)this.#v(H,Y,$);if(W)this.#P(W,H)}if(!Q&&this.#w&&this.#O){let F=this.#O,z;while(z=F?.shift())this.#$?.(...z)}return this}pop(){try{while(this.#W){let Z=this.#Q[this.#L];if(this.#y(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#w&&this.#O){let Z=this.#O,J;while(J=Z?.shift())this.#$?.(...J)}}}#y(Z){let J=this.#L,X=this.#z[J],Y=this.#Q[J];if(this.#C&&this.#q(Y))Y.__abortController.abort(new Error("evicted"));else if(this.#N||this.#w){if(this.#N)this.#Y?.(Y,X,"evict");if(this.#w)this.#O?.push([Y,X,"evict"])}if(this.#x(J),Z)this.#z[J]=void 0,this.#Q[J]=void 0,this.#E.push(J);if(this.#W===1)this.#L=this.#j=0,this.#E.length=0;else this.#L=this.#U[J];return this.#V.delete(X),this.#W--,J}has(Z,J={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:Y}=J,$=this.#V.get(Z);if($!==void 0){let Q=this.#Q[$];if(this.#q(Q)&&Q.__staleWhileFetching===void 0)return!1;if(!this.#D($)){if(X)this.#A($);if(Y)Y.has="hit",this.#P(Y,$);return!0}else if(Y)Y.has="stale",this.#P(Y,$)}else if(Y)Y.has="miss";return!1}peek(Z,J={}){let{allowStale:X=this.allowStale}=J,Y=this.#V.get(Z);if(Y===void 0||!X&&this.#D(Y))return;let $=this.#Q[Y];return this.#q($)?$.__staleWhileFetching:$}#h(Z,J,X,Y){let $=J===void 0?void 0:this.#Q[J];if(this.#q($))return $;let Q=new IL,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:Y},G=(U,L=!1)=>{let{aborted:B}=Q.signal,w=X.ignoreFetchAbort&&U!==void 0;if(X.status)if(B&&!L){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,w)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(B&&!w&&!L)return H(Q.signal.reason);let O=z;if(this.#Q[J]===z)if(U===void 0)if(O.__staleWhileFetching)this.#Q[J]=O.__staleWhileFetching;else this.#S(Z,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Z,U,W.options)}return U},V=(U)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=U;return H(U)},H=(U)=>{let{aborted:L}=Q.signal,B=L&&X.allowStaleOnFetchAbort,w=B||X.allowStaleOnFetchRejection,O=w||X.noDeleteOnFetchRejection,N=z;if(this.#Q[J]===z){if(!O||N.__staleWhileFetching===void 0)this.#S(Z,"fetch");else if(!B)this.#Q[J]=N.__staleWhileFetching}if(w){if(X.status&&N.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return N.__staleWhileFetching}else if(N.__returned===N)throw U},F=(U,L)=>{let B=this.#H?.(Z,$,W);if(B&&B instanceof Promise)B.then((w)=>U(w===void 0?void 0:w),L);Q.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if(U(void 0),X.allowStaleOnFetchAbort)U=(w)=>G(w,!0)}})};if(X.status)X.status.fetchDispatched=!0;let z=new Promise(F).then(G,V),q=Object.assign(z,{__abortController:Q,__staleWhileFetching:$,__returned:void 0});if(J===void 0)this.set(Z,q,{...W.options,status:void 0}),J=this.#V.get(Z);else this.#Q[J]=q;return q}#q(Z){if(!this.#C)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof IL}async fetch(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:Y=this.updateAgeOnGet,noDeleteOnStaleGet:$=this.noDeleteOnStaleGet,ttl:Q=this.ttl,noDisposeOnSet:K=this.noDisposeOnSet,size:W=0,sizeCalculation:G=this.sizeCalculation,noUpdateTTL:V=this.noUpdateTTL,noDeleteOnFetchRejection:H=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:F=this.allowStaleOnFetchRejection,ignoreFetchAbort:z=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:U,forceRefresh:L=!1,status:B,signal:w}=J;if(!this.#C){if(B)B.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,status:B})}let O={allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:V,noDeleteOnFetchRejection:H,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:q,ignoreFetchAbort:z,status:B,signal:w},N=this.#V.get(Z);if(N===void 0){if(B)B.fetch="miss";let R=this.#h(Z,N,O,U);return R.__returned=R}else{let R=this.#Q[N];if(this.#q(R)){let E=X&&R.__staleWhileFetching!==void 0;if(B){if(B.fetch="inflight",E)B.returnedStale=!0}return E?R.__staleWhileFetching:R.__returned=R}let D=this.#D(N);if(!L&&!D){if(B)B.fetch="hit";if(this.#b(N),Y)this.#A(N);if(B)this.#P(B,N);return R}let M=this.#h(Z,N,O,U),T=M.__staleWhileFetching!==void 0&&X;if(B){if(B.fetch=D?"stale":"refresh",T&&D)B.returnedStale=!0}return T?M.__staleWhileFetching:M.__returned=M}}async forceFetch(Z,J={}){let X=await this.fetch(Z,J);if(X===void 0)throw new Error("fetch() returned undefined");return X}memo(Z,J={}){let X=this.#F;if(!X)throw new Error("no memoMethod provided to constructor");let{context:Y,forceRefresh:$,...Q}=J,K=this.get(Z,Q);if(!$&&K!==void 0)return K;let W=X(Z,K,{options:Q,context:Y});return this.set(Z,W,Q),W}get(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:Y=this.updateAgeOnGet,noDeleteOnStaleGet:$=this.noDeleteOnStaleGet,status:Q}=J,K=this.#V.get(Z);if(K!==void 0){let W=this.#Q[K],G=this.#q(W);if(Q)this.#P(Q,K);if(this.#D(K)){if(Q)Q.get="stale";if(!G){if(!$)this.#S(Z,"expire");if(Q&&X)Q.returnedStale=!0;return X?W:void 0}else{if(Q&&X&&W.__staleWhileFetching!==void 0)Q.returnedStale=!0;return X?W.__staleWhileFetching:void 0}}else{if(Q)Q.get="hit";if(G)return W.__staleWhileFetching;if(this.#b(K),Y)this.#A(K);return W}}else if(Q)Q.get="miss"}#c(Z,J){this.#B[J]=Z,this.#U[Z]=J}#b(Z){if(Z!==this.#j){if(Z===this.#L)this.#L=this.#U[Z];else this.#c(this.#B[Z],this.#U[Z]);this.#c(this.#j,Z),this.#j=Z}}delete(Z){return this.#S(Z,"delete")}#S(Z,J){let X=!1;if(this.#W!==0){let Y=this.#V.get(Z);if(Y!==void 0)if(X=!0,this.#W===1)this.#g(J);else{this.#x(Y);let $=this.#Q[Y];if(this.#q($))$.__abortController.abort(new Error("deleted"));else if(this.#N||this.#w){if(this.#N)this.#Y?.($,Z,J);if(this.#w)this.#O?.push([$,Z,J])}if(this.#V.delete(Z),this.#z[Y]=void 0,this.#Q[Y]=void 0,Y===this.#j)this.#j=this.#B[Y];else if(Y===this.#L)this.#L=this.#U[Y];else{let Q=this.#B[Y];this.#U[Q]=this.#U[Y];let K=this.#U[Y];this.#B[K]=this.#B[Y]}this.#W--,this.#E.push(Y)}}if(this.#w&&this.#O?.length){let Y=this.#O,$;while($=Y?.shift())this.#$?.(...$)}return X}clear(){return this.#g("delete")}#g(Z){for(let J of this.#I({allowStale:!0})){let X=this.#Q[J];if(this.#q(X))X.__abortController.abort(new Error("deleted"));else{let Y=this.#z[J];if(this.#N)this.#Y?.(X,Y,Z);if(this.#w)this.#O?.push([X,Y,Z])}}if(this.#V.clear(),this.#Q.fill(void 0),this.#z.fill(void 0),this.#R&&this.#M)this.#R.fill(0),this.#M.fill(0);if(this.#k)this.#k.fill(0);if(this.#L=0,this.#j=0,this.#E.length=0,this.#G=0,this.#W=0,this.#w&&this.#O){let J=this.#O,X;while(X=J?.shift())this.#$?.(...X)}}}import{posix as iL1,win32 as LD}from"node:path";import{fileURLToPath as nL1}from"node:url";import{lstatSync as aL1,readdir as sL1,readdirSync as oL1,readlinkSync as rL1,realpathSync as tL1}from"fs";import*as eL1 from"node:fs";import{lstat as JB1,readdir as XB1,readlink as YB1,realpath as $B1}from"node:fs/promises";import{EventEmitter as zD}from"node:events";import Al from"node:stream";import{StringDecoder as fL1}from"node:string_decoder";var Il=typeof process==="object"&&process?process:{stdout:null,stderr:null},yL1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof BY||Z instanceof Al||bL1(Z)||gL1(Z)),bL1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof zD&&typeof Z.pipe==="function"&&Z.pipe!==Al.Writable.prototype.pipe,gL1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof zD&&typeof Z.write==="function"&&typeof Z.end==="function",FZ=Symbol("EOF"),qZ=Symbol("maybeEmitEnd"),CJ=Symbol("emittedEnd"),_L=Symbol("emittingEnd"),d3=Symbol("emittedError"),vL=Symbol("closed"),_l=Symbol("read"),SL=Symbol("flush"),vl=Symbol("flushChunk"),B4=Symbol("encoding"),$K=Symbol("decoder"),s8=Symbol("flowing"),c3=Symbol("paused"),QK=Symbol("resume"),o8=Symbol("buffer"),i6=Symbol("pipes"),r8=Symbol("bufferLength"),KD=Symbol("bufferPush"),AL=Symbol("bufferShift"),T6=Symbol("objectMode"),w8=Symbol("destroyed"),WD=Symbol("error"),GD=Symbol("emitData"),Sl=Symbol("emitEnd"),VD=Symbol("emitEnd2"),Q7=Symbol("async"),HD=Symbol("abort"),xL=Symbol("aborted"),l3=Symbol("signal"),LY=Symbol("dataListeners"),i5=Symbol("discarded"),p3=(Z)=>Promise.resolve().then(Z),mL1=(Z)=>Z(),uL1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",dL1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,cL1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class FD{src;dest;opts;ondrain;constructor(Z,J,X){this.src=Z,this.dest=J,this.opts=X,this.ondrain=()=>Z[QK](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(Z){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class xl extends FD{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Z,J,X){super(Z,J,X);this.proxyErrors=(Y)=>J.emit("error",Y),Z.on("error",this.proxyErrors)}}var lL1=(Z)=>!!Z.objectMode,pL1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class BY extends zD{[s8]=!1;[c3]=!1;[i6]=[];[o8]=[];[T6];[B4];[Q7];[$K];[FZ]=!1;[CJ]=!1;[_L]=!1;[vL]=!1;[d3]=null;[r8]=0;[w8]=!1;[l3];[xL]=!1;[LY]=0;[i5]=!1;writable=!0;readable=!0;constructor(...Z){let J=Z[0]||{};super();if(J.objectMode&&typeof J.encoding==="string")throw new TypeError("Encoding and objectMode may not be used together");if(lL1(J))this[T6]=!0,this[B4]=null;else if(pL1(J))this[B4]=J.encoding,this[T6]=!1;else this[T6]=!1,this[B4]=null;if(this[Q7]=!!J.async,this[$K]=this[B4]?new fL1(this[B4]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[o8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[i6]});let{signal:X}=J;if(X)if(this[l3]=X,X.aborted)this[HD]();else X.addEventListener("abort",()=>this[HD]())}get bufferLength(){return this[r8]}get encoding(){return this[B4]}set encoding(Z){throw new Error("Encoding must be set at instantiation time")}setEncoding(Z){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[T6]}set objectMode(Z){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[Q7]}set["async"](Z){this[Q7]=this[Q7]||!!Z}[HD](){this[xL]=!0,this.emit("abort",this[l3]?.reason),this.destroy(this[l3]?.reason)}get aborted(){return this[xL]}set aborted(Z){}write(Z,J,X){if(this[xL])return!1;if(this[FZ])throw new Error("write after end");if(this[w8])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof J==="function")X=J,J="utf8";if(!J)J="utf8";let Y=this[Q7]?p3:mL1;if(!this[T6]&&!Buffer.isBuffer(Z)){if(cL1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(dL1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[T6]){if(this[s8]&&this[r8]!==0)this[SL](!0);if(this[s8])this.emit("data",Z);else this[KD](Z);if(this[r8]!==0)this.emit("readable");if(X)Y(X);return this[s8]}if(!Z.length){if(this[r8]!==0)this.emit("readable");if(X)Y(X);return this[s8]}if(typeof Z==="string"&&!(J===this[B4]&&!this[$K]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[B4])Z=this[$K].write(Z);if(this[s8]&&this[r8]!==0)this[SL](!0);if(this[s8])this.emit("data",Z);else this[KD](Z);if(this[r8]!==0)this.emit("readable");if(X)Y(X);return this[s8]}read(Z){if(this[w8])return null;if(this[i5]=!1,this[r8]===0||Z===0||Z&&Z>this[r8])return this[qZ](),null;if(this[T6])Z=null;if(this[o8].length>1&&!this[T6])this[o8]=[this[B4]?this[o8].join(""):Buffer.concat(this[o8],this[r8])];let J=this[_l](Z||null,this[o8][0]);return this[qZ](),J}[_l](Z,J){if(this[T6])this[AL]();else{let X=J;if(Z===X.length||Z===null)this[AL]();else if(typeof X==="string")this[o8][0]=X.slice(Z),J=X.slice(0,Z),this[r8]-=Z;else this[o8][0]=X.subarray(Z),J=X.subarray(0,Z),this[r8]-=Z}if(this.emit("data",J),!this[o8].length&&!this[FZ])this.emit("drain");return J}end(Z,J,X){if(typeof Z==="function")X=Z,Z=void 0;if(typeof J==="function")X=J,J="utf8";if(Z!==void 0)this.write(Z,J);if(X)this.once("end",X);if(this[FZ]=!0,this.writable=!1,this[s8]||!this[c3])this[qZ]();return this}[QK](){if(this[w8])return;if(!this[LY]&&!this[i6].length)this[i5]=!0;if(this[c3]=!1,this[s8]=!0,this.emit("resume"),this[o8].length)this[SL]();else if(this[FZ])this[qZ]();else this.emit("drain")}resume(){return this[QK]()}pause(){this[s8]=!1,this[c3]=!0,this[i5]=!1}get destroyed(){return this[w8]}get flowing(){return this[s8]}get paused(){return this[c3]}[KD](Z){if(this[T6])this[r8]+=1;else this[r8]+=Z.length;this[o8].push(Z)}[AL](){if(this[T6])this[r8]-=1;else this[r8]-=this[o8][0].length;return this[o8].shift()}[SL](Z=!1){do;while(this[vl](this[AL]())&&this[o8].length);if(!Z&&!this[o8].length&&!this[FZ])this.emit("drain")}[vl](Z){return this.emit("data",Z),this[s8]}pipe(Z,J){if(this[w8])return Z;this[i5]=!1;let X=this[CJ];if(J=J||{},Z===Il.stdout||Z===Il.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[i6].push(!J.proxyErrors?new FD(this,Z,J):new xl(this,Z,J)),this[Q7])p3(()=>this[QK]());else this[QK]();return Z}unpipe(Z){let J=this[i6].find((X)=>X.dest===Z);if(J){if(this[i6].length===1){if(this[s8]&&this[LY]===0)this[s8]=!1;this[i6]=[]}else this[i6].splice(this[i6].indexOf(J),1);J.unpipe()}}addListener(Z,J){return this.on(Z,J)}on(Z,J){let X=super.on(Z,J);if(Z==="data"){if(this[i5]=!1,this[LY]++,!this[i6].length&&!this[s8])this[QK]()}else if(Z==="readable"&&this[r8]!==0)super.emit("readable");else if(uL1(Z)&&this[CJ])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[d3]){let Y=J;if(this[Q7])p3(()=>Y.call(this,this[d3]));else Y.call(this,this[d3])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[LY]=this.listeners("data").length,this[LY]===0&&!this[i5]&&!this[i6].length)this[s8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[LY]=0,!this[i5]&&!this[i6].length)this[s8]=!1}return J}get emittedEnd(){return this[CJ]}[qZ](){if(!this[_L]&&!this[CJ]&&!this[w8]&&this[o8].length===0&&this[FZ]){if(this[_L]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[vL])this.emit("close");this[_L]=!1}}emit(Z,...J){let X=J[0];if(Z!=="error"&&Z!=="close"&&Z!==w8&&this[w8])return!1;else if(Z==="data")return!this[T6]&&!X?!1:this[Q7]?(p3(()=>this[GD](X)),!0):this[GD](X);else if(Z==="end")return this[Sl]();else if(Z==="close"){if(this[vL]=!0,!this[CJ]&&!this[w8])return!1;let $=super.emit("close");return this.removeAllListeners("close"),$}else if(Z==="error"){this[d3]=X,super.emit(WD,X);let $=!this[l3]||this.listeners("error").length?super.emit("error",X):!1;return this[qZ](),$}else if(Z==="resume"){let $=super.emit("resume");return this[qZ](),$}else if(Z==="finish"||Z==="prefinish"){let $=super.emit(Z);return this.removeAllListeners(Z),$}let Y=super.emit(Z,...J);return this[qZ](),Y}[GD](Z){for(let X of this[i6])if(X.dest.write(Z)===!1)this.pause();let J=this[i5]?!1:super.emit("data",Z);return this[qZ](),J}[Sl](){if(this[CJ])return!1;return this[CJ]=!0,this.readable=!1,this[Q7]?(p3(()=>this[VD]()),!0):this[VD]()}[VD](){if(this[$K]){let J=this[$K].end();if(J){for(let X of this[i6])X.dest.write(J);if(!this[i5])super.emit("data",J)}}for(let J of this[i6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[T6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[T6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[T6])throw new Error("cannot concat in objectMode");let Z=await this.collect();return this[B4]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(w8,()=>J(new Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[i5]=!1;let Z=!1,J=async()=>{return this.pause(),Z=!0,{value:void 0,done:!0}};return{next:()=>{if(Z)return J();let Y=this.read();if(Y!==null)return Promise.resolve({done:!1,value:Y});if(this[FZ])return J();let $,Q,K=(H)=>{this.off("data",W),this.off("end",G),this.off(w8,V),J(),Q(H)},W=(H)=>{this.off("error",K),this.off("end",G),this.off(w8,V),this.pause(),$({value:H,done:!!this[FZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(w8,V),J(),$({done:!0,value:void 0})},V=()=>K(new Error("stream destroyed"));return new Promise((H,F)=>{Q=F,$=H,this.once(w8,V),this.once("error",K),this.once("end",G),this.once("data",W)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[i5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(WD,J),this.off(w8,J),this.off("end",J),Z=!0,{done:!0,value:void 0}},X=()=>{if(Z)return J();let Y=this.read();return Y===null?J():{done:!1,value:Y}};return this.once("end",J),this.once(WD,J),this.once(w8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[w8]){if(Z)this.emit("error",Z);else this.emit(w8);return this}this[w8]=!0,this[i5]=!0,this[o8].length=0,this[r8]=0;let J=this;if(typeof J.close==="function"&&!this[vL])J.close();if(Z)this.emit("error",Z);else this.emit(w8);return this}static get isStream(){return yL1}}var ZB1=tL1.native,n3={lstatSync:aL1,readdir:sL1,readdirSync:oL1,readlinkSync:rL1,realpathSync:ZB1,promises:{lstat:JB1,readdir:XB1,readlink:YB1,realpath:$B1}},gl=(Z)=>!Z||Z===n3||Z===eL1?n3:{...n3,...Z,promises:{...n3.promises,...Z.promises||{}}},ml=/^\\\\\?\\([a-z]:)\\?$/i,QB1=(Z)=>Z.replace(/\//g,"\\").replace(ml,"$1\\"),KB1=/[\\\/]/,T9=0,ul=1,dl=2,K7=4,cl=6,ll=8,wY=10,pl=12,C9=15,i3=~C9,qD=16,hl=32,a3=64,w4=128,hL=256,yL=512,fl=a3|w4|yL,WB1=1023,UD=(Z)=>Z.isFile()?ll:Z.isDirectory()?K7:Z.isSymbolicLink()?wY:Z.isCharacterDevice()?dl:Z.isBlockDevice()?cl:Z.isSocket()?pl:Z.isFIFO()?ul:T9,yl=new Map,s3=(Z)=>{let J=yl.get(Z);if(J)return J;let X=Z.normalize("NFKD");return yl.set(Z,X),X},bl=new Map,fL=(Z)=>{let J=bl.get(Z);if(J)return J;let X=s3(Z.toLowerCase());return bl.set(Z,X),X};class BD extends u3{constructor(){super({max:256})}}class il extends u3{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var nl=Symbol("PathScurry setAsCwd");class n6{name;root;roots;parent;nocase;isCWD=!1;#Z;#J;get dev(){return this.#J}#Y;get mode(){return this.#Y}#X;get nlink(){return this.#X}#$;get uid(){return this.#$}#H;get gid(){return this.#H}#F;get rdev(){return this.#F}#W;get blksize(){return this.#W}#G;get ino(){return this.#G}#V;get size(){return this.#V}#z;get blocks(){return this.#z}#Q;get atimeMs(){return this.#Q}#U;get mtimeMs(){return this.#U}#B;get ctimeMs(){return this.#B}#L;get birthtimeMs(){return this.#L}#j;get atime(){return this.#j}#E;get mtime(){return this.#E}#O;get ctime(){return this.#O}#k;get birthtime(){return this.#k}#M;#R;#N;#C;#w;#_;#K;#A;#P;#v;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=T9,X,Y,$,Q,K){if(this.name=Z,this.#M=$?fL(Z):s3(Z),this.#K=J&WB1,this.nocase=$,this.roots=Y,this.root=X||this,this.#A=Q,this.#N=K.fullpath,this.#w=K.relative,this.#_=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=gl(K.fs)}depth(){if(this.#R!==void 0)return this.#R;if(!this.parent)return this.#R=0;return this.#R=this.parent.depth()+1}childrenCache(){return this.#A}resolve(Z){if(!Z)return this;let J=this.getRootString(Z),Y=Z.substring(J.length).split(this.splitSep);return J?this.getRoot(J).#D(Y):this.#D(Y)}#D(Z){let J=this;for(let X of Z)J=J.child(X);return J}children(){let Z=this.#A.get(this);if(Z)return Z;let J=Object.assign([],{provisional:0});return this.#A.set(this,J),this.#K&=~qD,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),Y=this.nocase?fL(Z):s3(Z);for(let W of X)if(W.#M===Y)return W;let $=this.parent?this.sep:"",Q=this.#N?this.#N+$+Z:void 0,K=this.newChild(Z,T9,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=w4;return X.push(K),K}relative(){if(this.isCWD)return"";if(this.#w!==void 0)return this.#w;let Z=this.name,J=this.parent;if(!J)return this.#w=this.name;let X=J.relative();return X+(!X||!J.parent?"":this.sep)+Z}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#_!==void 0)return this.#_;let Z=this.name,J=this.parent;if(!J)return this.#_=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#N!==void 0)return this.#N;let Z=this.name,J=this.parent;if(!J)return this.#N=this.name;let Y=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#N=Y}fullpathPosix(){if(this.#C!==void 0)return this.#C;if(this.sep==="/")return this.#C=this.fullpath();if(!this.parent){let Y=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(Y))return this.#C=`//?/${Y}`;else return this.#C=Y}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#C=X}isUnknown(){return(this.#K&C9)===T9}isType(Z){return this[`is${Z}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#K&C9)===ll}isDirectory(){return(this.#K&C9)===K7}isCharacterDevice(){return(this.#K&C9)===dl}isBlockDevice(){return(this.#K&C9)===cl}isFIFO(){return(this.#K&C9)===ul}isSocket(){return(this.#K&C9)===pl}isSymbolicLink(){return(this.#K&wY)===wY}lstatCached(){return this.#K&hl?this:void 0}readlinkCached(){return this.#P}realpathCached(){return this.#v}readdirCached(){let Z=this.children();return Z.slice(0,Z.provisional)}canReadlink(){if(this.#P)return!0;if(!this.parent)return!1;let Z=this.#K&C9;return!(Z!==T9&&Z!==wY||this.#K&hL||this.#K&w4)}calledReaddir(){return!!(this.#K&qD)}isENOENT(){return!!(this.#K&w4)}isNamed(Z){return!this.nocase?this.#M===s3(Z):this.#M===fL(Z)}async readlink(){let Z=this.#P;if(Z)return Z;if(!this.canReadlink())return;if(!this.parent)return;try{let J=await this.#Z.promises.readlink(this.fullpath()),X=(await this.parent.realpath())?.resolve(J);if(X)return this.#P=X}catch(J){this.#y(J.code);return}}readlinkSync(){let Z=this.#P;if(Z)return Z;if(!this.canReadlink())return;if(!this.parent)return;try{let J=this.#Z.readlinkSync(this.fullpath()),X=this.parent.realpathSync()?.resolve(J);if(X)return this.#P=X}catch(J){this.#y(J.code);return}}#m(Z){this.#K|=qD;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#x()}}#x(){if(this.#K&w4)return;this.#K=(this.#K|w4)&i3,this.#f()}#f(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#x()}#u(){this.#K|=yL,this.#T()}#T(){if(this.#K&a3)return;let Z=this.#K;if((Z&C9)===K7)Z&=i3;this.#K=Z|a3,this.#f()}#I(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#T();else if(Z==="ENOENT")this.#x();else this.children().provisional=0}#d(Z=""){if(Z==="ENOTDIR")this.parent.#T();else if(Z==="ENOENT")this.#x()}#y(Z=""){let J=this.#K;if(J|=hL,Z==="ENOENT")J|=w4;if(Z==="EINVAL"||Z==="UNKNOWN")J&=i3;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#T()}#h(Z,J){return this.#c(Z,J)||this.#q(Z,J)}#q(Z,J){let X=UD(Z),Y=this.newChild(Z.name,X,{parent:this}),$=Y.#K&C9;if($!==K7&&$!==wY&&$!==T9)Y.#K|=a3;return J.unshift(Y),J.provisional++,Y}#c(Z,J){for(let X=J.provisional;X<J.length;X++){let Y=J[X];if((this.nocase?fL(Z.name):s3(Z.name))!==Y.#M)continue;return this.#b(Z,Y,X,J)}}#b(Z,J,X,Y){let $=J.name;if(J.#K=J.#K&i3|UD(Z),$!==Z.name)J.name=Z.name;if(X!==Y.provisional){if(X===Y.length-1)Y.pop();else Y.splice(X,1);Y.unshift(J)}return Y.provisional++,J}async lstat(){if((this.#K&w4)===0)try{return this.#S(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#d(Z.code)}}lstatSync(){if((this.#K&w4)===0)try{return this.#S(this.#Z.lstatSync(this.fullpath())),this}catch(Z){this.#d(Z.code)}}#S(Z){let{atime:J,atimeMs:X,birthtime:Y,birthtimeMs:$,blksize:Q,blocks:K,ctime:W,ctimeMs:G,dev:V,gid:H,ino:F,mode:z,mtime:q,mtimeMs:U,nlink:L,rdev:B,size:w,uid:O}=Z;this.#j=J,this.#Q=X,this.#k=Y,this.#L=$,this.#W=Q,this.#z=K,this.#O=W,this.#B=G,this.#J=V,this.#H=H,this.#G=F,this.#Y=z,this.#E=q,this.#U=U,this.#X=L,this.#F=B,this.#V=w,this.#$=O;let N=UD(Z);if(this.#K=this.#K&i3|N|hl,N!==T9&&N!==K7&&N!==wY)this.#K|=a3}#g=[];#p=!1;#i(Z){this.#p=!1;let J=this.#g.slice();this.#g.length=0,J.forEach((X)=>X(null,Z))}readdirCB(Z,J=!1){if(!this.canReaddir()){if(J)Z(null,[]);else queueMicrotask(()=>Z(null,[]));return}let X=this.children();if(this.calledReaddir()){let $=X.slice(0,X.provisional);if(J)Z(null,$);else queueMicrotask(()=>Z(null,$));return}if(this.#g.push(Z),this.#p)return;this.#p=!0;let Y=this.fullpath();this.#Z.readdir(Y,{withFileTypes:!0},($,Q)=>{if($)this.#I($.code),X.provisional=0;else{for(let K of Q)this.#h(K,X);this.#m(X)}this.#i(X.slice(0,X.provisional));return})}#l;async readdir(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();if(this.#l)await this.#l;else{let X=()=>{};this.#l=new Promise((Y)=>X=Y);try{for(let Y of await this.#Z.promises.readdir(J,{withFileTypes:!0}))this.#h(Y,Z);this.#m(Z)}catch(Y){this.#I(Y.code),Z.provisional=0}this.#l=void 0,X()}return Z.slice(0,Z.provisional)}readdirSync(){if(!this.canReaddir())return[];let Z=this.children();if(this.calledReaddir())return Z.slice(0,Z.provisional);let J=this.fullpath();try{for(let X of this.#Z.readdirSync(J,{withFileTypes:!0}))this.#h(X,Z);this.#m(Z)}catch(X){this.#I(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&fl)return!1;let Z=C9&this.#K;if(!(Z===T9||Z===K7||Z===wY))return!1;return!0}shouldWalk(Z,J){return(this.#K&K7)===K7&&!(this.#K&fl)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#v)return this.#v;if((yL|hL|w4)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#v=this.resolve(Z)}catch(Z){this.#u()}}realpathSync(){if(this.#v)return this.#v;if((yL|hL|w4)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#v=this.resolve(Z)}catch(Z){this.#u()}}[nl](Z){if(Z===this)return;Z.isCWD=!1,this.isCWD=!0;let J=new Set([]),X=[],Y=this;while(Y&&Y.parent)J.add(Y),Y.#w=X.join(this.sep),Y.#_=X.join("/"),Y=Y.parent,X.push("..");Y=Z;while(Y&&Y.parent&&!J.has(Y))Y.#w=void 0,Y.#_=void 0,Y=Y.parent}}class bL extends n6{sep="\\";splitSep=KB1;constructor(Z,J=T9,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}newChild(Z,J=T9,X={}){return new bL(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return LD.parse(Z).root}getRoot(Z){if(Z=QB1(Z.toUpperCase()),Z===this.root.name)return this.root;for(let[J,X]of Object.entries(this.roots))if(this.sameRoot(Z,J))return this.roots[Z]=X;return this.roots[Z]=new o3(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(ml,"$1\\"),Z===J}}class gL extends n6{splitSep="/";sep="/";constructor(Z,J=T9,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=T9,X={}){return new gL(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class wD{root;rootPath;roots;cwd;#Z;#J;#Y;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:Y,childrenCacheSize:$=16384,fs:Q=n3}={}){if(this.#X=gl(Q),Z instanceof URL||Z.startsWith("file://"))Z=nL1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new BD,this.#J=new BD,this.#Y=new il($);let W=K.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if(Y===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=Y,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let G=this.root,V=W.length-1,H=J.sep,F=this.rootPath,z=!1;for(let q of W){let U=V--;G=G.child(q,{relative:new Array(U).fill("..").join(H),relativePosix:new Array(U).fill("..").join("/"),fullpath:F+=(z?"":H)+q}),z=!0}this.cwd=G}depth(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.depth()}childrenCache(){return this.#Y}resolve(...Z){let J="";for(let $=Z.length-1;$>=0;$--){let Q=Z[$];if(!Q||Q===".")continue;if(J=J?`${Q}/${J}`:Q,this.isAbsolute(Q))break}let X=this.#Z.get(J);if(X!==void 0)return X;let Y=this.cwd.resolve(J).fullpath();return this.#Z.set(J,Y),Y}resolvePosix(...Z){let J="";for(let $=Z.length-1;$>=0;$--){let Q=Z[$];if(!Q||Q===".")continue;if(J=J?`${Q}/${J}`:Q,this.isAbsolute(Q))break}let X=this.#J.get(J);if(X!==void 0)return X;let Y=this.cwd.resolve(J).fullpathPosix();return this.#J.set(J,Y),Y}relative(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.relative()}relativePosix(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.relativePosix()}basename(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.name}dirname(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return(Z.parent||Z).fullpath()}async readdir(Z=this.cwd,J={withFileTypes:!0}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X}=J;if(!Z.canReaddir())return[];else{let Y=await Z.readdir();return X?Y:Y.map(($)=>$.name)}}readdirSync(Z=this.cwd,J={withFileTypes:!0}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X=!0}=J;if(!Z.canReaddir())return[];else if(X)return Z.readdirSync();else return Z.readdirSync().map((Y)=>Y.name)}async lstat(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.lstat()}lstatSync(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.lstatSync()}async readlink(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z.withFileTypes,Z=this.cwd;let X=await Z.readlink();return J?X:X?.fullpath()}readlinkSync(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z.withFileTypes,Z=this.cwd;let X=Z.readlinkSync();return J?X:X?.fullpath()}async realpath(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z.withFileTypes,Z=this.cwd;let X=await Z.realpath();return J?X:X?.fullpath()}realpathSync(Z=this.cwd,{withFileTypes:J}={withFileTypes:!1}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z.withFileTypes,Z=this.cwd;let X=Z.realpathSync();return J?X:X?.fullpath()}async walk(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=[];if(!$||$(Z))K.push(X?Z:Z.fullpath());let W=new Set,G=(H,F)=>{W.add(H),H.readdirCB((z,q)=>{if(z)return F(z);let U=q.length;if(!U)return F();let L=()=>{if(--U===0)F()};for(let B of q){if(!$||$(B))K.push(X?B:B.fullpath());if(Y&&B.isSymbolicLink())B.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(W,Q)?G(w,L):L());else if(B.shouldWalk(W,Q))G(B,L);else L()}},!0)},V=Z;return new Promise((H,F)=>{G(V,(z)=>{if(z)return F(z);H(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=[];if(!$||$(Z))K.push(X?Z:Z.fullpath());let W=new Set([Z]);for(let G of W){let V=G.readdirSync();for(let H of V){if(!$||$(H))K.push(X?H:H.fullpath());let F=H;if(H.isSymbolicLink()){if(!(Y&&(F=H.realpathSync())))continue;if(F.isUnknown())F.lstatSync()}if(F.shouldWalk(W,Q))W.add(F)}}return K}[Symbol.asyncIterator](){return this.iterate()}iterate(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;return this.stream(Z,J)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J;if(!$||$(Z))yield X?Z:Z.fullpath();let K=new Set([Z]);for(let W of K){let G=W.readdirSync();for(let V of G){if(!$||$(V))yield X?V:V.fullpath();let H=V;if(V.isSymbolicLink()){if(!(Y&&(H=V.realpathSync())))continue;if(H.isUnknown())H.lstatSync()}if(H.shouldWalk(K,Q))K.add(H)}}}stream(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new BY({objectMode:!0});if(!$||$(Z))K.write(X?Z:Z.fullpath());let W=new Set,G=[Z],V=0,H=()=>{let F=!1;while(!F){let z=G.shift();if(!z){if(V===0)K.end();return}V++,W.add(z);let q=(L,B,w=!1)=>{if(L)return K.emit("error",L);if(Y&&!w){let O=[];for(let N of B)if(N.isSymbolicLink())O.push(N.realpath().then((R)=>R?.isUnknown()?R.lstat():R));if(O.length){Promise.all(O).then(()=>q(null,B,!0));return}}for(let O of B)if(O&&(!$||$(O))){if(!K.write(X?O:O.fullpath()))F=!0}V--;for(let O of B){let N=O.realpathCached()||O;if(N.shouldWalk(W,Q))G.push(N)}if(F&&!K.flowing)K.once("drain",H);else if(!U)H()},U=!0;z.readdirCB(q,!0),U=!1}};return H(),K}streamSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof n6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new BY({objectMode:!0}),W=new Set;if(!$||$(Z))K.write(X?Z:Z.fullpath());let G=[Z],V=0,H=()=>{let F=!1;while(!F){let z=G.shift();if(!z){if(V===0)K.end();return}V++,W.add(z);let q=z.readdirSync();for(let U of q)if(!$||$(U)){if(!K.write(X?U:U.fullpath()))F=!0}V--;for(let U of q){let L=U;if(U.isSymbolicLink()){if(!(Y&&(L=U.realpathSync())))continue;if(L.isUnknown())L.lstatSync()}if(L.shouldWalk(W,Q))G.push(L)}}if(F&&!K.flowing)K.once("drain",H)};return H(),K}chdir(Z=this.cwd){let J=this.cwd;this.cwd=typeof Z==="string"?this.cwd.resolve(Z):Z,this.cwd[nl](J)}}class o3 extends wD{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,LD,"\\",{...J,nocase:X});this.nocase=X;for(let Y=this.cwd;Y;Y=Y.parent)Y.nocase=this.nocase}parseRootPath(Z){return LD.parse(Z).root.toUpperCase()}newRoot(Z){return new bL(this.rootPath,K7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class r3 extends wD{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,iL1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new gL(this.rootPath,K7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class mL extends r3{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var eD6=process.platform==="win32"?bL:gL,al=process.platform==="win32"?o3:process.platform==="darwin"?mL:r3;var GB1=(Z)=>Z.length>=1,VB1=(Z)=>Z.length>=1;class KK{#Z;#J;#Y;length;#X;#$;#H;#F;#W;#G;#V=!0;constructor(Z,J,X,Y){if(!GB1(Z))throw new TypeError("empty pattern list");if(!VB1(J))throw new TypeError("empty glob list");if(J.length!==Z.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=Z.length,X<0||X>=this.length)throw new TypeError("index out of range");if(this.#Z=Z,this.#J=J,this.#Y=X,this.#X=Y,this.#Y===0){if(this.isUNC()){let[$,Q,K,W,...G]=this.#Z,[V,H,F,z,...q]=this.#J;if(G[0]==="")G.shift(),q.shift();let U=[$,Q,K,W,""].join("/"),L=[V,H,F,z,""].join("/");this.#Z=[U,...G],this.#J=[L,...q],this.length=this.#Z.length}else if(this.isDrive()||this.isAbsolute()){let[$,...Q]=this.#Z,[K,...W]=this.#J;if(Q[0]==="")Q.shift(),W.shift();let G=$+"/",V=K+"/";this.#Z=[G,...Q],this.#J=[V,...W],this.length=this.#Z.length}}}pattern(){return this.#Z[this.#Y]}isString(){return typeof this.#Z[this.#Y]==="string"}isGlobstar(){return this.#Z[this.#Y]===L6}isRegExp(){return this.#Z[this.#Y]instanceof RegExp}globString(){return this.#H=this.#H||(this.#Y===0?this.isAbsolute()?this.#J[0]+this.#J.slice(1).join("/"):this.#J.join("/"):this.#J.slice(this.#Y).join("/"))}hasMore(){return this.length>this.#Y+1}rest(){if(this.#$!==void 0)return this.#$;if(!this.hasMore())return this.#$=null;return this.#$=new KK(this.#Z,this.#J,this.#Y+1,this.#X),this.#$.#G=this.#G,this.#$.#W=this.#W,this.#$.#F=this.#F,this.#$}isUNC(){let Z=this.#Z;return this.#W!==void 0?this.#W:this.#W=this.#X==="win32"&&this.#Y===0&&Z[0]===""&&Z[1]===""&&typeof Z[2]==="string"&&!!Z[2]&&typeof Z[3]==="string"&&!!Z[3]}isDrive(){let Z=this.#Z;return this.#F!==void 0?this.#F:this.#F=this.#X==="win32"&&this.#Y===0&&this.length>1&&typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0])}isAbsolute(){let Z=this.#Z;return this.#G!==void 0?this.#G:this.#G=Z[0]===""&&Z.length>1||this.isDrive()||this.isUNC()}root(){let Z=this.#Z[0];return typeof Z==="string"&&this.isAbsolute()&&this.#Y===0?Z:""}checkFollowGlobstar(){return!(this.#Y===0||!this.isGlobstar()||!this.#V)}markFollowGlobstar(){if(this.#Y===0||!this.isGlobstar()||!this.#V)return!1;return this.#V=!1,!0}}var HB1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class t3{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:Y,noglobstar:$,platform:Q=HB1}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=Q,this.mmopts={dot:!0,nobrace:J,nocase:X,noext:Y,noglobstar:$,optimizationLevel:2,platform:Q,nocomment:!0,nonegate:!0};for(let K of Z)this.add(K)}add(Z){let J=new D9(Z,this.mmopts);for(let X=0;X<J.set.length;X++){let Y=J.set[X],$=J.globParts[X];if(!Y||!$)throw new Error("invalid pattern object");while(Y[0]==="."&&$[0]===".")Y.shift(),$.shift();let Q=new KK(Y,$,0,this.platform),K=new D9(Q.globString(),this.mmopts),W=$[$.length-1]==="**",G=Q.isAbsolute();if(G)this.absolute.push(K);else this.relative.push(K);if(W)if(G)this.absoluteChildren.push(K);else this.relativeChildren.push(K)}}ignored(Z){let J=Z.fullpath(),X=`${J}/`,Y=Z.relative()||".",$=`${Y}/`;for(let Q of this.relative)if(Q.match(Y)||Q.match($))return!0;for(let Q of this.absolute)if(Q.match(J)||Q.match(X))return!0;return!1}childrenIgnored(Z){let J=Z.fullpath()+"/",X=(Z.relative()||".")+"/";for(let Y of this.relativeChildren)if(Y.match(X))return!0;for(let Y of this.absoluteChildren)if(Y.match(J))return!0;return!1}}class jD{store;constructor(Z=new Map){this.store=Z}copy(){return new jD(new Map(this.store))}hasWalked(Z,J){return this.store.get(Z.fullpath())?.has(J.globString())}storeWalked(Z,J){let X=Z.fullpath(),Y=this.store.get(X);if(Y)Y.add(J.globString());else this.store.set(X,new Set([J.globString()]))}}class sl{store=new Map;add(Z,J,X){let Y=(J?2:0)|(X?1:0),$=this.store.get(Z);this.store.set(Z,$===void 0?Y:Y&$)}entries(){return[...this.store.entries()].map(([Z,J])=>[Z,!!(J&2),!!(J&1)])}}class ol{store=new Map;add(Z,J){if(!Z.canReaddir())return;let X=this.store.get(Z);if(X){if(!X.find((Y)=>Y.globString()===J.globString()))X.push(J)}else this.store.set(Z,[J])}get(Z){let J=this.store.get(Z);if(!J)throw new Error("attempting to walk unknown path");return J}entries(){return this.keys().map((Z)=>[Z,this.store.get(Z)])}keys(){return[...this.store.keys()].filter((Z)=>Z.canReaddir())}}class e3{hasWalkedCache;matches=new sl;subwalks=new ol;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new jD}processPatterns(Z,J){this.patterns=J;let X=J.map((Y)=>[Z,Y]);for(let[Y,$]of X){this.hasWalkedCache.storeWalked(Y,$);let Q=$.root(),K=$.isAbsolute()&&this.opts.absolute!==!1;if(Q){Y=Y.resolve(Q==="/"&&this.opts.root!==void 0?this.opts.root:Q);let H=$.rest();if(!H){this.matches.add(Y,!0,!1);continue}else $=H}if(Y.isENOENT())continue;let W,G,V=!1;while(typeof(W=$.pattern())==="string"&&(G=$.rest()))Y=Y.resolve(W),$=G,V=!0;if(W=$.pattern(),G=$.rest(),V){if(this.hasWalkedCache.hasWalked(Y,$))continue;this.hasWalkedCache.storeWalked(Y,$)}if(typeof W==="string"){let H=W===".."||W===""||W===".";this.matches.add(Y.resolve(W),K,H);continue}else if(W===L6){if(!Y.isSymbolicLink()||this.follow||$.checkFollowGlobstar())this.subwalks.add(Y,$);let H=G?.pattern(),F=G?.rest();if(!G||(H===""||H===".")&&!F)this.matches.add(Y,K,H===""||H===".");else if(H===".."){let z=Y.parent||Y;if(!F)this.matches.add(z,K,!0);else if(!this.hasWalkedCache.hasWalked(z,F))this.subwalks.add(z,F)}}else if(W instanceof RegExp)this.subwalks.add(Y,$)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new e3(this.opts,this.hasWalkedCache)}filterEntries(Z,J){let X=this.subwalks.get(Z),Y=this.child();for(let $ of J)for(let Q of X){let K=Q.isAbsolute(),W=Q.pattern(),G=Q.rest();if(W===L6)Y.testGlobstar($,Q,G,K);else if(W instanceof RegExp)Y.testRegExp($,W,G,K);else Y.testString($,W,G,K)}return Y}testGlobstar(Z,J,X,Y){if(this.dot||!Z.name.startsWith(".")){if(!J.hasMore())this.matches.add(Z,Y,!1);if(Z.canReaddir()){if(this.follow||!Z.isSymbolicLink())this.subwalks.add(Z,J);else if(Z.isSymbolicLink()){if(X&&J.checkFollowGlobstar())this.subwalks.add(Z,X);else if(J.markFollowGlobstar())this.subwalks.add(Z,J)}}}if(X){let $=X.pattern();if(typeof $==="string"&&$!==".."&&$!==""&&$!==".")this.testString(Z,$,X.rest(),Y);else if($===".."){let Q=Z.parent||Z;this.subwalks.add(Q,X)}else if($ instanceof RegExp)this.testRegExp(Z,$,X.rest(),Y)}}testRegExp(Z,J,X,Y){if(!J.test(Z.name))return;if(!X)this.matches.add(Z,Y,!1);else this.subwalks.add(Z,X)}testString(Z,J,X,Y){if(!Z.isNamed(J))return;if(!X)this.matches.add(Z,Y,!1);else this.subwalks.add(Z,X)}}var zB1=(Z,J)=>typeof Z==="string"?new t3([Z],J):Array.isArray(Z)?new t3(Z,J):Z;class OD{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#J;#Y;signal;maxDepth;includeChildMatches;constructor(Z,J,X){if(this.patterns=Z,this.path=J,this.opts=X,this.#Y=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#J=zB1(X.ignore??[],X),!this.includeChildMatches&&typeof this.#J.add!=="function")throw new Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=X.maxDepth||1/0,X.signal)this.signal=X.signal,this.signal.addEventListener("abort",()=>{this.#Z.length=0})}#X(Z){return this.seen.has(Z)||!!this.#J?.ignored?.(Z)}#$(Z){return!!this.#J?.childrenIgnored?.(Z)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let Z=void 0;while(!this.paused&&(Z=this.#Z.shift()))Z()}onResume(Z){if(this.signal?.aborted)return;if(!this.paused)Z();else this.#Z.push(Z)}async matchCheck(Z,J){if(J&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Z.realpathCached()||await Z.realpath(),!X)return;Z=X}let $=Z.isUnknown()||this.opts.stat?await Z.lstat():Z;if(this.opts.follow&&this.opts.nodir&&$?.isSymbolicLink()){let Q=await $.realpath();if(Q&&(Q.isUnknown()||this.opts.stat))await Q.lstat()}return this.matchCheckTest($,J)}matchCheckTest(Z,J){return Z&&(this.maxDepth===1/0||Z.depth()<=this.maxDepth)&&(!J||Z.canReaddir())&&(!this.opts.nodir||!Z.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!Z.isSymbolicLink()||!Z.realpathCached()?.isDirectory())&&!this.#X(Z)?Z:void 0}matchCheckSync(Z,J){if(J&&this.opts.nodir)return;let X;if(this.opts.realpath){if(X=Z.realpathCached()||Z.realpathSync(),!X)return;Z=X}let $=Z.isUnknown()||this.opts.stat?Z.lstatSync():Z;if(this.opts.follow&&this.opts.nodir&&$?.isSymbolicLink()){let Q=$.realpathSync();if(Q&&(Q?.isUnknown()||this.opts.stat))Q.lstatSync()}return this.matchCheckTest($,J)}matchFinish(Z,J){if(this.#X(Z))return;if(!this.includeChildMatches&&this.#J?.add){let $=`${Z.relativePosix()}/**`;this.#J.add($)}let X=this.opts.absolute===void 0?J:this.opts.absolute;this.seen.add(Z);let Y=this.opts.mark&&Z.isDirectory()?this.#Y:"";if(this.opts.withFileTypes)this.matchEmit(Z);else if(X){let $=this.opts.posix?Z.fullpathPosix():Z.fullpath();this.matchEmit($+Y)}else{let $=this.opts.posix?Z.relativePosix():Z.relative(),Q=this.opts.dotRelative&&!$.startsWith(".."+this.#Y)?"."+this.#Y:"";this.matchEmit(!$?"."+Y:Q+$+Y)}}async match(Z,J,X){let Y=await this.matchCheck(Z,X);if(Y)this.matchFinish(Y,J)}matchSync(Z,J,X){let Y=this.matchCheckSync(Z,X);if(Y)this.matchFinish(Y,J)}walkCB(Z,J,X){if(this.signal?.aborted)X();this.walkCB2(Z,J,new e3(this.opts),X)}walkCB2(Z,J,X,Y){if(this.#$(Z))return Y();if(this.signal?.aborted)Y();if(this.paused){this.onResume(()=>this.walkCB2(Z,J,X,Y));return}X.processPatterns(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;$++,this.match(K,W,G).then(()=>Q())}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;$++;let W=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,W,X,Q);else K.readdirCB((G,V)=>this.walkCB3(K,V,X,Q),!0)}Q()}walkCB3(Z,J,X,Y){X=X.filterEntries(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;$++,this.match(K,W,G).then(()=>Q())}for(let[K,W]of X.subwalks.entries())$++,this.walkCB2(K,W,X.child(),Q);Q()}walkCBSync(Z,J,X){if(this.signal?.aborted)X();this.walkCB2Sync(Z,J,new e3(this.opts),X)}walkCB2Sync(Z,J,X,Y){if(this.#$(Z))return Y();if(this.signal?.aborted)Y();if(this.paused){this.onResume(()=>this.walkCB2Sync(Z,J,X,Y));return}X.processPatterns(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,W,G)}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;$++;let W=K.readdirSync();this.walkCB3Sync(K,W,X,Q)}Q()}walkCB3Sync(Z,J,X,Y){X=X.filterEntries(Z,J);let $=1,Q=()=>{if(--$===0)Y()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;this.matchSync(K,W,G)}for(let[K,W]of X.subwalks.entries())$++,this.walkCB2Sync(K,W,X.child(),Q);Q()}}class uL extends OD{matches=new Set;constructor(Z,J,X){super(Z,J,X)}matchEmit(Z){this.matches.add(Z)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise((Z,J)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)J(this.signal.reason);else Z(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class dL extends OD{results;constructor(Z,J,X){super(Z,J,X);this.results=new BY({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(Z){if(this.results.write(Z),!this.results.flowing)this.pause()}stream(){let Z=this.path;if(Z.isUnknown())Z.lstat().then(()=>{this.walkCB(Z,this.patterns,()=>this.results.end())});else this.walkCB(Z,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var qB1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class W7{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(Z,J){if(!J)throw new TypeError("glob options required");if(this.withFileTypes=!!J.withFileTypes,this.signal=J.signal,this.follow=!!J.follow,this.dot=!!J.dot,this.dotRelative=!!J.dotRelative,this.nodir=!!J.nodir,this.mark=!!J.mark,!J.cwd)this.cwd="";else if(J.cwd instanceof URL||J.cwd.startsWith("file://"))J.cwd=FB1(J.cwd);if(this.cwd=J.cwd||"",this.root=J.root,this.magicalBraces=!!J.magicalBraces,this.nobrace=!!J.nobrace,this.noext=!!J.noext,this.realpath=!!J.realpath,this.absolute=J.absolute,this.includeChildMatches=J.includeChildMatches!==!1,this.noglobstar=!!J.noglobstar,this.matchBase=!!J.matchBase,this.maxDepth=typeof J.maxDepth==="number"?J.maxDepth:1/0,this.stat=!!J.stat,this.ignore=J.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof Z==="string")Z=[Z];if(this.windowsPathsNoEscape=!!J.windowsPathsNoEscape||J.allowWindowsEscape===!1,this.windowsPathsNoEscape)Z=Z.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(J.noglobstar)throw new TypeError("base matching requires globstar");Z=Z.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Z,this.platform=J.platform||qB1,this.opts={...J,platform:this.platform},J.scurry){if(this.scurry=J.scurry,J.nocase!==void 0&&J.nocase!==J.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let W=J.platform==="win32"?o3:J.platform==="darwin"?mL:J.platform?r3:al;this.scurry=new W(this.cwd,{nocase:J.nocase,fs:J.fs})}this.nocase=this.scurry.nocase;let X=this.platform==="darwin"||this.platform==="win32",Y={...J,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:X,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},$=this.pattern.map((W)=>new D9(W,Y)),[Q,K]=$.reduce((W,G)=>{return W[0].push(...G.set),W[1].push(...G.globParts),W},[[],[]]);this.patterns=Q.map((W,G)=>{let V=K[G];if(!V)throw new Error("invalid pattern object");return new KK(W,V,0,this.platform)})}async walk(){return[...await new uL(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new uL(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new dL(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new dL(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var ND=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new D9(X,J).hasMagic())return!0;return!1};function lL(Z,J={}){return new W7(Z,J).streamSync()}function tl(Z,J={}){return new W7(Z,J).stream()}function el(Z,J={}){return new W7(Z,J).walkSync()}async function rl(Z,J={}){return new W7(Z,J).walk()}function pL(Z,J={}){return new W7(Z,J).iterateSync()}function Zp(Z,J={}){return new W7(Z,J).iterate()}var UB1=lL,LB1=Object.assign(tl,{sync:lL}),BB1=pL,wB1=Object.assign(Zp,{sync:pL}),jB1=Object.assign(el,{stream:lL,iterate:pL}),cL=Object.assign(rl,{glob:rl,globSync:el,sync:jB1,globStream:tl,stream:LB1,globStreamSync:lL,streamSync:UB1,globIterate:Zp,iterate:wB1,globIterateSync:pL,iterateSync:BB1,Glob:W7,hasMagic:ND,escape:JK,unescape:L4});cL.glob=cL;class RD{constructor(){this._listeners={}}addEventListener(Z,J){let X=this._listeners;if(X[Z]===void 0)X[Z]=[];if(X[Z].indexOf(J)===-1)X[Z].push(J);return this}removeEventListener(Z,J){let Y=this._listeners[Z];if(Y!==void 0){let $=Y.indexOf(J);if($!==-1)Y.splice($,1)}return this}dispatchEvent(Z){let X=this._listeners[Z.type];if(X!==void 0){let Y=X.slice(0);for(let $=0,Q=Y.length;$<Q;$++)Y[$].call(this,Z)}return this}dispose(){for(let Z in this._listeners)delete this._listeners[Z]}}class M5{constructor(Z,J,X,Y={}){if(this._name=void 0,this._parent=void 0,this._child=void 0,this._attributes=void 0,this._disposed=!1,this._name=Z,this._parent=J,this._child=X,this._attributes=Y,!J.isOnGraph(X))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(Z){return this._child=Z,this}getAttributes(){return this._attributes}dispose(){if(this._disposed)return;this._parent._destroyRef(this),this._disposed=!0}isDisposed(){return this._disposed}}class WK extends RD{constructor(...Z){super(...Z);this._emptySet=new Set,this._edges=new Set,this._parentEdges=new Map,this._childEdges=new Map}listEdges(){return Array.from(this._edges)}listParentEdges(Z){return Array.from(this._childEdges.get(Z)||this._emptySet)}listParents(Z){let J=new Set;for(let X of this.listParentEdges(Z))J.add(X.getParent());return Array.from(J)}listChildEdges(Z){return Array.from(this._parentEdges.get(Z)||this._emptySet)}listChildren(Z){let J=new Set;for(let X of this.listChildEdges(Z))J.add(X.getChild());return Array.from(J)}disconnectParents(Z,J){for(let X of this.listParentEdges(Z))if(!J||J(X.getParent()))X.dispose();return this}_createEdge(Z,J,X,Y){let $=new M5(Z,J,X,Y);this._edges.add($);let Q=$.getParent();if(!this._parentEdges.has(Q))this._parentEdges.set(Q,new Set);this._parentEdges.get(Q).add($);let K=$.getChild();if(!this._childEdges.has(K))this._childEdges.set(K,new Set);return this._childEdges.get(K).add($),$}_destroyEdge(Z){return this._edges.delete(Z),this._parentEdges.get(Z.getParent()).delete(Z),this._childEdges.get(Z.getChild()).delete(Z),this}}function ZV(){return ZV=Object.assign||function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)if(Object.prototype.hasOwnProperty.call(X,Y))Z[Y]=X[Y]}return Z},ZV.apply(this,arguments)}class E6{constructor(Z){if(this.list=[],Z)for(let J of Z)this.list.push(J)}add(Z){this.list.push(Z)}remove(Z){let J=this.list.indexOf(Z);if(J>=0)this.list.splice(J,1)}removeChild(Z){let J=[];for(let X of this.list)if(X.getChild()===Z)J.push(X);for(let X of J)this.remove(X);return J}listRefsByChild(Z){let J=[];for(let X of this.list)if(X.getChild()===Z)J.push(X);return J}values(){return this.list}}class D0{constructor(Z){if(this.set=new Set,this.map=new Map,Z)for(let J of Z)this.add(J)}add(Z){let J=Z.getChild();this.removeChild(J),this.set.add(Z),this.map.set(J,Z)}remove(Z){this.set.delete(Z),this.map.delete(Z.getChild())}removeChild(Z){let J=this.map.get(Z)||null;if(J)this.remove(J);return J}getRefByChild(Z){return this.map.get(Z)||null}values(){return Array.from(this.set)}}class s1{constructor(Z){if(this.map={},Z)Object.assign(this.map,Z)}set(Z,J){this.map[Z]=J}delete(Z){delete this.map[Z]}get(Z){return this.map[Z]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}}var x0=Symbol("attributes"),j4=Symbol("immutableKeys");class GK extends RD{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[x0]=void 0,this[j4]=void 0,this.graph=Z,this[j4]=new Set,this[x0]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let Y=Z[X];if(Y instanceof GK){let $=this.graph._createEdge(X,this,Y);this[j4].add(X),J[X]=$}else J[X]=Y}return J}isOnGraph(Z){return this.graph===Z.graph}isDisposed(){return this._disposed}dispose(){if(this._disposed)return;this.graph.listChildEdges(this).forEach((Z)=>Z.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"})}detach(){return this.graph.disconnectParents(this),this}swap(Z,J){for(let X in this[x0]){let Y=this[x0][X];if(Y instanceof M5){let $=Y;if($.getChild()===Z)this.setRef(X,J,$.getAttributes())}else if(Y instanceof E6)for(let $ of Y.listRefsByChild(Z)){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if(Y instanceof D0){let $=Y.getRefByChild(Z);if($){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if(Y instanceof s1)for(let $ of Y.keys()){let Q=Y.get($);if(Q.getChild()===Z)this.setRefMap(X,$,J,Q.getAttributes())}}return this}get(Z){return this[x0][Z]}set(Z,J){return this[x0][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[x0][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[j4].has(Z))throw new Error(`Cannot overwrite immutable attribute, "${Z}".`);let Y=this[x0][Z];if(Y)Y.dispose();if(!J)return this;let $=this.graph._createEdge(Z,this,J,X);return this[x0][Z]=$,this.dispatchEvent({type:"change",attribute:Z})}listRefs(Z){return this.assertRefList(Z).values().map((X)=>X.getChild())}addRef(Z,J,X){let Y=this.graph._createEdge(Z,this,J,X);return this.assertRefList(Z).add(Y),this.dispatchEvent({type:"change",attribute:Z})}removeRef(Z,J){let X=this.assertRefList(Z);if(X instanceof E6)for(let Y of X.listRefsByChild(J))Y.dispose();else{let Y=X.getRefByChild(J);if(Y)Y.dispose()}return this}assertRefList(Z){let J=this[x0][Z];if(J instanceof E6||J instanceof D0)return J;throw new Error(`Expected RefList or RefSet for attribute "${Z}"`)}listRefMapKeys(Z){return this.assertRefMap(Z).keys()}listRefMapValues(Z){return this.assertRefMap(Z).values().map((J)=>J.getChild())}getRefMap(Z,J){let Y=this.assertRefMap(Z).get(J);return Y?Y.getChild():null}setRefMap(Z,J,X,Y){let $=this.assertRefMap(Z),Q=$.get(J);if(Q)Q.dispose();if(!X)return this;Y=Object.assign(Y||{},{key:J});let K=this.graph._createEdge(Z,this,X,ZV({},Y,{key:J}));return $.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[x0][Z];if(J instanceof s1)return J;throw new Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(ZV({},Z,{target:this})),this.graph.dispatchEvent(ZV({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[x0][J]===Z){if(this[x0][J]=null,this[j4].has(J))Z.getChild().dispose()}else if(this[x0][J]instanceof E6)this[x0][J].remove(Z);else if(this[x0][J]instanceof D0)this[x0][J].remove(Z);else if(this[x0][J]instanceof s1){let X=this[x0][J];for(let Y of X.keys())if(X.get(Y)===Z)X.delete(Y)}else return;this.graph._destroyEdge(Z),this.dispatchEvent({type:"change",attribute:J})}}var Wp="v4.1.1",rL="@glb.bin",a;(function(Z){Z.ACCESSOR="Accessor",Z.ANIMATION="Animation",Z.ANIMATION_CHANNEL="AnimationChannel",Z.ANIMATION_SAMPLER="AnimationSampler",Z.BUFFER="Buffer",Z.CAMERA="Camera",Z.MATERIAL="Material",Z.MESH="Mesh",Z.PRIMITIVE="Primitive",Z.PRIMITIVE_TARGET="PrimitiveTarget",Z.NODE="Node",Z.ROOT="Root",Z.SCENE="Scene",Z.SKIN="Skin",Z.TEXTURE="Texture",Z.TEXTURE_INFO="TextureInfo"})(a||(a={}));var tL;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(tL||(tL={}));var n5;(function(Z){Z.ARRAY_BUFFER="ARRAY_BUFFER",Z.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",Z.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",Z.OTHER="OTHER",Z.SPARSE="SPARSE"})(n5||(n5={}));var eL;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(eL||(eL={}));var UZ;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(UZ||(UZ={}));var kJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array},PD=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function OB1(){var Z=new PD(3);if(PD!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function MD(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function NB1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=X[3]*Y+X[7]*$+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*Y+X[4]*$+X[8]*Q+X[12])/K,Z[1]=(X[1]*Y+X[5]*$+X[9]*Q+X[13])/K,Z[2]=(X[2]*Y+X[6]*$+X[10]*Q+X[14])/K,Z}(function(){var Z=OB1();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=3;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();function ED(Z){let J=Gp(),X=Z.propertyType===a.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=RB1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))DD(K.min,J),DD(K.max,J)});return J}function RB1(Z,J){let X=Gp();for(let Y of Z.listPrimitives()){let $=Y.getAttribute("POSITION"),Q=Y.getIndices();if(!$)continue;let K=[0,0,0],W=[0,0,0];for(let G=0,V=Q?Q.getCount():$.getCount();G<V;G++){let H=Q?Q.getScalar(G):G;K=$.getElement(H,K),W=NB1(W,K,J),DD(W,X)}}return X}function DD(Z,J){for(let X=0;X<3;X++)J.min[X]=Math.min(Z[X],J.min[X]),J.max[X]=Math.max(Z[X],J.max[X])}function Gp(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class n0{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let Y=0;Y<J.length;Y++)X[Y]=J.charCodeAt(Y);return X}else{let J=Z.split(",")[1],X=Z.indexOf("base64")>=0;return Buffer.from(J,X?"base64":"utf8")}}static encodeText(Z){return new TextEncoder().encode(Z)}static decodeText(Z){return new TextDecoder().decode(Z)}static concat(Z){let J=0;for(let $ of Z)J+=$.byteLength;let X=new Uint8Array(J),Y=0;for(let $ of Z)X.set($,Y),Y+=$.byteLength;return X}static pad(Z,J=0){let X=this.padNumber(Z.byteLength);if(X===Z.byteLength)return Z;let Y=new Uint8Array(X);if(Y.set(Z),J!==0)for(let $=Z.byteLength;$<X;$++)Y[$]=J;return Y}static padNumber(Z){return Math.ceil(Z/4)*4}static equals(Z,J){if(Z===J)return!0;if(Z.byteLength!==J.byteLength)return!1;let X=Z.byteLength;while(X--)if(Z[X]!==J[X])return!1;return!0}static toView(Z,J=0,X=1/0){return new Uint8Array(Z.buffer,Z.byteOffset+J,Math.min(Z.byteLength,X))}static assertView(Z){if(Z&&!ArrayBuffer.isView(Z))throw new Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class kD{static hexToFactor(Z,J){Z=Math.floor(Z);let X=J;return X[0]=(Z>>16&255)/255,X[1]=(Z>>8&255)/255,X[2]=(Z&255)/255,this.convertSRGBToLinear(J,J)}static factorToHex(Z){let J=[...Z],[X,Y,$]=this.convertLinearToSRGB(Z,J);return X*255<<16^Y*255<<8^$*255<<0}static convertSRGBToLinear(Z,J){let X=Z,Y=J;for(let $=0;$<3;$++)Y[$]=X[$]<0.04045?X[$]*0.0773993808:Math.pow(X[$]*0.9478672986+0.0521327014,2.4);return J}static convertLinearToSRGB(Z,J){let X=Z,Y=J;for(let $=0;$<3;$++)Y[$]=X[$]<0.0031308?X[$]*12.92:1.055*Math.pow(X[$],0.41666)-0.055;return J}}class Vp{match(Z){return Z.length>=3&&Z[0]===255&&Z[1]===216&&Z[2]===255}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset+4),X,Y;while(J.byteLength){if(X=J.getUint16(0,!1),MB1(J,X),Y=J.getUint8(X+1),Y===192||Y===193||Y===194)return[J.getUint16(X+7,!1),J.getUint16(X+5,!1)];J=new DataView(Z.buffer,J.byteOffset+X+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class XB{match(Z){return Z.length>=8&&Z[0]===137&&Z[1]===80&&Z[2]===78&&Z[3]===71&&Z[4]===13&&Z[5]===10&&Z[6]===26&&Z[7]===10}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset);if(n0.decodeText(Z.slice(12,16))===XB.PNG_FRIED_CHUNK_NAME)return[J.getUint32(32,!1),J.getUint32(36,!1)];return[J.getUint32(16,!1),J.getUint32(20,!1)]}getChannels(Z){return 4}}XB.PNG_FRIED_CHUNK_NAME="CgBI";class LZ{static registerFormat(Z,J){this.impls[Z]=J}static getMimeType(Z){for(let J in this.impls)if(this.impls[J].match(Z))return J;return null}static getSize(Z,J){if(!this.impls[J])return null;return this.impls[J].getSize(Z)}static getChannels(Z,J){if(!this.impls[J])return null;return this.impls[J].getChannels(Z)}static getVRAMByteLength(Z,J){if(!this.impls[J])return null;if(this.impls[J].getVRAMByteLength)return this.impls[J].getVRAMByteLength(Z);let X=0,Y=4,$=this.getSize(Z,J);if(!$)return null;while($[0]>1||$[1]>1)X+=$[0]*$[1]*Y,$[0]=Math.max(Math.floor($[0]/2),1),$[1]=Math.max(Math.floor($[1]/2),1);return X+=1*Y,X}static mimeTypeToExtension(Z){if(Z==="image/jpeg")return"jpg";return Z.split("/").pop()}static extensionToMimeType(Z){if(Z==="jpg")return"image/jpeg";if(!Z)return"";return`image/${Z}`}}LZ.impls={"image/jpeg":new Vp,"image/png":new XB};function MB1(Z,J){if(J>Z.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return Z}class BZ{static basename(Z){let J=Z.split(/[\\/]/).pop();return J.substring(0,J.lastIndexOf("."))}static extension(Z){if(Z.startsWith("data:image/")){let J=Z.match(/data:(image\/\w+)/)[1];return LZ.mimeTypeToExtension(J)}else if(Z.startsWith("data:model/gltf+json"))return"gltf";else if(Z.startsWith("data:model/gltf-binary"))return"glb";else if(Z.startsWith("data:application/"))return"bin";return Z.split(/[\\/]/).pop().split(/[.]/).pop()}}function Jp(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function jY(Z){if(Jp(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(Jp(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var CD,JV;(function(Z){Z[Z.SILENT=4]="SILENT",Z[Z.ERROR=3]="ERROR",Z[Z.WARN=2]="WARN",Z[Z.INFO=1]="INFO",Z[Z.DEBUG=0]="DEBUG"})(JV||(JV={}));class D5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=D5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=D5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=D5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=D5.Verbosity.ERROR)console.error(Z)}}CD=D5;D5.Verbosity=JV;D5.DEFAULT_INSTANCE=new CD(CD.Verbosity.INFO);function PB1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],V=Z[8],H=Z[9],F=Z[10],z=Z[11],q=Z[12],U=Z[13],L=Z[14],B=Z[15],w=J*K-X*Q,O=J*W-Y*Q,N=J*G-$*Q,R=X*W-Y*K,D=X*G-$*K,M=Y*G-$*W,C=V*U-H*q,T=V*L-F*q,E=V*B-z*q,x=H*L-F*U,v=H*B-z*U,S=F*B-z*L;return w*S-O*v+N*x+R*E-D*T+M*C}function DB1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],V=J[6],H=J[7],F=J[8],z=J[9],q=J[10],U=J[11],L=J[12],B=J[13],w=J[14],O=J[15],N=X[0],R=X[1],D=X[2],M=X[3];return Z[0]=N*Y+R*W+D*F+M*L,Z[1]=N*$+R*G+D*z+M*B,Z[2]=N*Q+R*V+D*q+M*w,Z[3]=N*K+R*H+D*U+M*O,N=X[4],R=X[5],D=X[6],M=X[7],Z[4]=N*Y+R*W+D*F+M*L,Z[5]=N*$+R*G+D*z+M*B,Z[6]=N*Q+R*V+D*q+M*w,Z[7]=N*K+R*H+D*U+M*O,N=X[8],R=X[9],D=X[10],M=X[11],Z[8]=N*Y+R*W+D*F+M*L,Z[9]=N*$+R*G+D*z+M*B,Z[10]=N*Q+R*V+D*q+M*w,Z[11]=N*K+R*H+D*U+M*O,N=X[12],R=X[13],D=X[14],M=X[15],Z[12]=N*Y+R*W+D*F+M*L,Z[13]=N*$+R*G+D*z+M*B,Z[14]=N*Q+R*V+D*q+M*w,Z[15]=N*K+R*H+D*U+M*O,Z}function CB1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],V=J[9],H=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,V,H),Z}function TB1(Z,J){var X=new PD(3);CB1(X,J);var Y=1/X[0],$=1/X[1],Q=1/X[2],K=J[0]*Y,W=J[1]*$,G=J[2]*Q,V=J[4]*Y,H=J[5]*$,F=J[6]*Q,z=J[8]*Y,q=J[9]*$,U=J[10]*Q,L=K+H+U,B=0;if(L>0)B=Math.sqrt(L+1)*2,Z[3]=0.25*B,Z[0]=(F-q)/B,Z[1]=(z-G)/B,Z[2]=(W-V)/B;else if(K>H&&K>U)B=Math.sqrt(1+K-H-U)*2,Z[3]=(F-q)/B,Z[0]=0.25*B,Z[1]=(W+V)/B,Z[2]=(z+G)/B;else if(H>U)B=Math.sqrt(1+H-K-U)*2,Z[3]=(z-G)/B,Z[0]=(W+V)/B,Z[1]=0.25*B,Z[2]=(F+q)/B;else B=Math.sqrt(1+U-K-H)*2,Z[3]=(W-V)/B,Z[0]=(z+G)/B,Z[1]=(F+q)/B,Z[2]=0.25*B;return Z}class c0{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let Y=0;Y<Z.length;Y++)if(Math.abs(Z[Y]-J[Y])>X)return!1;return!0}static clamp(Z,J,X){if(Z<J)return J;if(Z>X)return X;return Z}static decodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Z/65535;case 5121:return Z/255;case 5122:return Math.max(Z/32767,-1);case 5120:return Math.max(Z/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(c0.clamp(Z,0,1)*65535);case 5121:return Math.round(c0.clamp(Z,0,1)*255);case 5122:return Math.round(c0.clamp(Z,-1,1)*32767);case 5120:return Math.round(c0.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,Y){let $=MD([Z[0],Z[1],Z[2]]),Q=MD([Z[4],Z[5],Z[6]]),K=MD([Z[8],Z[9],Z[10]]);if(PB1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),V=1/$,H=1/Q,F=1/K;G[0]*=V,G[1]*=V,G[2]*=V,G[4]*=H,G[5]*=H,G[6]*=H,G[8]*=F,G[9]*=F,G[10]*=F,TB1(X,G),Y[0]=$,Y[1]=Q,Y[2]=K}static compose(Z,J,X,Y){let $=Y,Q=J[0],K=J[1],W=J[2],G=J[3],V=Q+Q,H=K+K,F=W+W,z=Q*V,q=Q*H,U=Q*F,L=K*H,B=K*F,w=W*F,O=G*V,N=G*H,R=G*F,D=X[0],M=X[1],C=X[2];return $[0]=(1-(L+w))*D,$[1]=(q+R)*D,$[2]=(U-N)*D,$[3]=0,$[4]=(q-R)*M,$[5]=(1-(z+w))*M,$[6]=(B+O)*M,$[7]=0,$[8]=(U+N)*C,$[9]=(B-O)*C,$[10]=(1-(z+L))*C,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function EB1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function kB1(Z,J){if(!!Z!==!!J)return!1;let X=Z.values(),Y=J.values();if(X.length!==Y.length)return!1;for(let $=0;$<X.length;$++){let Q=X[$],K=Y[$];if(Q.getChild()===K.getChild())continue;if(!Q.getChild().equals(K.getChild()))return!1}return!0}function IB1(Z,J){if(!!Z!==!!J)return!1;let X=Z.keys(),Y=J.keys();if(X.length!==Y.length)return!1;for(let $ of X){let Q=Z.get($),K=J.get($);if(!!Q!==!!K)return!1;let W=Q.getChild(),G=K.getChild();if(W===G)continue;if(!W.equals(G))return!1}return!0}function Hp(Z,J){if(Z===J)return!0;if(!!Z!==!!J||!Z||!J)return!1;if(Z.length!==J.length)return!1;for(let X=0;X<Z.length;X++)if(Z[X]!==J[X])return!1;return!0}function zp(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!jY(Z)||!jY(J))return Z===J;let X=Z,Y=J,$=0,Q=0,K;for(K in X)$++;for(K in Y)Q++;if($!==Q)return!1;for(K in X){let W=X[K],G=Y[K];if(ZB(W)&&ZB(G)){if(!Hp(W,G))return!1}else if(jY(W)&&jY(G)){if(!zp(W,G))return!1}else if(W!==G)return!1}return!0}function ZB(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Xp="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",_B1=999,vB1=6,Yp=new Set,SB1=function Z(){let J="";for(let X=0;X<vB1;X++)J+=Xp.charAt(Math.floor(Math.random()*Xp.length));return J},Fp=function Z(){for(let J=0;J<_B1;J++){let X=SB1();if(!Yp.has(X))return Yp.add(X),X}return""},$p="https://null.example";class E9{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return BZ.basename(new URL(Z,$p).pathname)}static extension(Z){return BZ.extension(new URL(Z,$p).pathname)}static resolve(Z,J){if(!this.isRelativePath(J))return J;let X=Z.split("/"),Y=J.split("/");X.pop();for(let $=0;$<Y.length;$++){if(Y[$]===".")continue;if(Y[$]==="..")X.pop();else X.push(Y[$])}return X.join("/")}static isAbsoluteURL(Z){return this.PROTOCOL_REGEXP.test(Z)}static isRelativePath(Z){return!/^(?:[a-zA-Z]+:)?\//.test(Z)}}E9.DEFAULT_INIT={};E9.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var EJ=(Z)=>Z,AB1=new Set;class YB extends GK{constructor(Z,J=""){super(Z);this[x0].name=J,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(Z,J){if(Array.isArray(J))J=J.slice();return super.set(Z,J)}getName(){return this.get("name")}setName(Z){return this.set("name",Z)}getExtras(){return this.get("extras")}setExtras(Z){return this.set("extras",Z)}clone(){return new this.constructor(this.graph).copy(this,EJ)}copy(Z,J=EJ){for(let X in this[x0]){let Y=this[x0][X];if(Y instanceof M5){if(!this[j4].has(X))Y.dispose()}else if(Y instanceof E6||Y instanceof D0)for(let $ of Y.values())$.dispose();else if(Y instanceof s1)for(let $ of Y.values())$.dispose()}for(let X in Z[x0]){let Y=this[x0][X],$=Z[x0][X];if($ instanceof M5)if(this[j4].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof D0||$ instanceof E6)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof s1)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(jY($))this[x0][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[x0][X]=$.slice();else this[x0][X]=$}return this}equals(Z,J=AB1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[x0]){if(J.has(X))continue;let Y=this[x0][X],$=Z[x0][X];if(Y instanceof M5||$ instanceof M5){if(!EB1(Y,$))return!1}else if(Y instanceof D0||$ instanceof D0||Y instanceof E6||$ instanceof E6){if(!kB1(Y,$))return!1}else if(Y instanceof s1||$ instanceof s1){if(!IB1(Y,$))return!1}else if(jY(Y)||jY($)){if(!zp(Y,$))return!1}else if(ZB(Y)||ZB($)){if(!Hp(Y,$))return!1}else if(Y!==$)return!1}return!0}detach(){return this.graph.disconnectParents(this,(Z)=>Z.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}}class I6 extends YB{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new s1})}getExtension(Z){return this.getRefMap("extensions",Z)}setExtension(Z,J){if(J)J._validateParent(this);return this.setRefMap("extensions",Z,J)}listExtensions(){return this.listRefMapValues("extensions")}}class I0 extends I6{init(){this.propertyType=a.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:I0.Type.SCALAR,componentType:I0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case I0.Type.SCALAR:return 1;case I0.Type.VEC2:return 2;case I0.Type.VEC3:return 3;case I0.Type.VEC4:return 4;case I0.Type.MAT2:return 4;case I0.Type.MAT3:return 9;case I0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case I0.ComponentType.BYTE:return 1;case I0.ComponentType.UNSIGNED_BYTE:return 1;case I0.ComponentType.SHORT:return 2;case I0.ComponentType.UNSIGNED_SHORT:return 2;case I0.ComponentType.UNSIGNED_INT:return 4;case I0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMin(Z),J)for(let $=0;$<X;$++)Z[$]=c0.decodeNormalizedInt(Z[$],Y);return Z}getMin(Z){let J=this.getArray(),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+Q];if(Number.isFinite(K))Z[Q]=Math.min(Z[Q],K)}return Z}getMaxNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMax(Z),J)for(let $=0;$<X;$++)Z[$]=c0.decodeNormalizedInt(Z[$],Y);return Z}getMax(Z){let J=this.get("array"),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=-1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+Q];if(Number.isFinite(K))Z[Q]=Math.max(Z[Q],K)}return Z}getCount(){let Z=this.get("array");return Z?Z.length/this.getElementSize():0}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getElementSize(){return I0.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(Z){return this.set("normalized",Z)}getScalar(Z){let J=this.getElementSize(),X=this.getComponentType(),Y=this.getArray();if(this.getNormalized())return c0.decodeNormalizedInt(Y[Z*J],X);return Y[Z*J]}setScalar(Z,J){let X=this.getElementSize(),Y=this.getComponentType(),$=this.getArray();if(this.getNormalized())$[Z*X]=c0.encodeNormalizedInt(J,Y);else $[Z*X]=J;return this}getElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)J[K]=c0.decodeNormalizedInt(Q[Z*Y+K],$);else J[K]=Q[Z*Y+K];return J}setElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)Q[Z*Y+K]=c0.encodeNormalizedInt(J[K],$);else Q[Z*Y+K]=J[K];return this}getSparse(){return this.get("sparse")}setSparse(Z){return this.set("sparse",Z)}getBuffer(){return this.getRef("buffer")}setBuffer(Z){return this.setRef("buffer",Z)}getArray(){return this.get("array")}setArray(Z){return this.set("componentType",Z?xB1(Z):I0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}I0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};I0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function xB1(Z){switch(Z.constructor){case Float32Array:return I0.ComponentType.FLOAT;case Uint32Array:return I0.ComponentType.UNSIGNED_INT;case Uint16Array:return I0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return I0.ComponentType.UNSIGNED_BYTE;case Int16Array:return I0.ComponentType.SHORT;case Int8Array:return I0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class ID extends I6{init(){this.propertyType=a.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new D0,samplers:new D0})}addChannel(Z){return this.addRef("channels",Z)}removeChannel(Z){return this.removeRef("channels",Z)}listChannels(){return this.listRefs("channels")}addSampler(Z){return this.addRef("samplers",Z)}removeSampler(Z){return this.removeRef("samplers",Z)}listSamplers(){return this.listRefs("samplers")}}class OY extends I6{init(){this.propertyType=a.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(Z){return this.set("targetPath",Z)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(Z){return this.setRef("targetNode",Z)}getSampler(){return this.getRef("sampler")}setSampler(Z){return this.setRef("sampler",Z)}}OY.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class VK extends I6{init(){this.propertyType=a.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:VK.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(Z){return this.set("interpolation",Z)}getInput(){return this.getRef("input")}setInput(Z){return this.setRef("input",Z,{usage:n5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:n5.OTHER})}}VK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class _D extends I6{init(){this.propertyType=a.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class NY extends I6{init(){this.propertyType=a.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:NY.Type.PERSPECTIVE,znear:0.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getZNear(){return this.get("znear")}setZNear(Z){return this.set("znear",Z)}getZFar(){return this.get("zfar")}setZFar(Z){return this.set("zfar",Z)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(Z){return this.set("aspectRatio",Z)}getYFov(){return this.get("yfov")}setYFov(Z){return this.set("yfov",Z)}getXMag(){return this.get("xmag")}setXMag(Z){return this.set("xmag",Z)}getYMag(){return this.get("ymag")}setYMag(Z){return this.set("ymag",Z)}}NY.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class HK extends YB{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}HK.EXTENSION_NAME=void 0;class P5 extends I6{init(){this.propertyType=a.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:P5.WrapMode.REPEAT,wrapT:P5.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}getMagFilter(){return this.get("magFilter")}setMagFilter(Z){return this.set("magFilter",Z)}getMinFilter(){return this.get("minFilter")}setMinFilter(Z){return this.set("minFilter",Z)}getWrapS(){return this.get("wrapS")}setWrapS(Z){return this.set("wrapS",Z)}getWrapT(){return this.get("wrapT")}setWrapT(Z){return this.set("wrapT",Z)}}P5.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};P5.MagFilter={NEAREST:9728,LINEAR:9729};P5.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:iL,G:nL,B:aL,A:hB1}=eL;class G7 extends I6{init(){this.propertyType=a.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:G7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new P5(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new P5(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new P5(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new P5(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new P5(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(Z){return this.set("doubleSided",Z)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(Z){let J=this.get("baseColorFactor").slice();return J[3]=Z,this.set("baseColorFactor",J)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(Z){return this.set("alphaMode",Z)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(Z){return this.set("alphaCutoff",Z)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(Z){return this.set("baseColorFactor",Z)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(Z){return this.setRef("baseColorTexture",Z,{channels:iL|nL|aL|hB1,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(Z){return this.set("emissiveFactor",Z)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(Z){return this.setRef("emissiveTexture",Z,{channels:iL|nL|aL,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(Z){return this.set("normalScale",Z)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(Z){return this.setRef("normalTexture",Z,{channels:iL|nL|aL})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(Z){return this.set("occlusionStrength",Z)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(Z){return this.setRef("occlusionTexture",Z,{channels:iL})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(Z){return this.set("roughnessFactor",Z)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(Z){return this.set("metallicFactor",Z)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(Z){return this.setRef("metallicRoughnessTexture",Z,{channels:nL|aL})}}G7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class YV extends I6{init(){this.propertyType=a.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new D0})}addPrimitive(Z){return this.addRef("primitives",Z)}removePrimitive(Z){return this.removeRef("primitives",Z)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}}class $B extends I6{init(){this.propertyType=a.NODE}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new D0})}copy(Z,J=EJ){if(J===EJ)throw new Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return c0.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),Y=this.get("scale").slice();return c0.decompose(Z,J,X,Y),this.set("translation",J).set("rotation",X).set("scale",Y)}getWorldTranslation(){let Z=[0,0,0];return c0.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return c0.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return c0.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],Z),Z}getWorldMatrix(){let Z=[];for(let Y=this;Y!=null;Y=Y.getParentNode())Z.push(Y);let J,X=Z.pop().getMatrix();while(J=Z.pop())DB1(X,X,J.getMatrix());return X}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);for(let X of Z.listParents())if(X.propertyType===a.SCENE)X.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}getParentNode(){for(let Z of this.listParents())if(Z.propertyType===a.NODE)return Z;return null}getMesh(){return this.getRef("mesh")}setMesh(Z){return this.setRef("mesh",Z)}getCamera(){return this.getRef("camera")}setCamera(Z){return this.setRef("camera",Z)}getSkin(){return this.getRef("skin")}setSkin(Z){return this.setRef("skin",Z)}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}traverse(Z){Z(this);for(let J of this.listChildren())J.traverse(Z);return this}}class j8 extends I6{init(){this.propertyType=a.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:j8.Mode.TRIANGLES,material:null,indices:null,attributes:new s1,targets:new D0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:n5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:n5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(Z){return this.setRef("material",Z)}getMode(){return this.get("mode")}setMode(Z){return this.set("mode",Z)}listTargets(){return this.listRefs("targets")}addTarget(Z){return this.addRef("targets",Z)}removeTarget(Z){return this.removeRef("targets",Z)}}j8.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class vD extends YB{init(){this.propertyType=a.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new s1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:n5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function a6(){return a6=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},a6.apply(null,arguments)}class zK extends I6{init(){this.propertyType=a.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new D0})}copy(Z,J=EJ){if(J===EJ)throw new Error("Scene cannot be copied.");return super.copy(Z,J)}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}traverse(Z){for(let J of this.listChildren())J.traverse(Z);return this}}class SD extends I6{init(){this.propertyType=a.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new D0})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(Z){return this.setRef("skeleton",Z)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(Z){return this.setRef("inverseBindMatrices",Z,{usage:n5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class RY extends I6{init(){this.propertyType=a.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||LZ.extensionToMimeType(BZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=LZ.extensionToMimeType(BZ.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",n0.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return LZ.getSize(Z,this.getMimeType())}}class MY extends I6{init(){this.propertyType=a.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Wp}`,version:"2.0"},defaultScene:null,accessors:new D0,animations:new D0,buffers:new D0,cameras:new D0,materials:new D0,meshes:new D0,nodes:new D0,scenes:new D0,skins:new D0,textures:new D0})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(Z,J=EJ){if(J===EJ)throw new Error("Root cannot be copied.");this.set("asset",a6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(a6({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let Y=Z.getExtension(X);this.setExtension(X,J(Y))}return this}_addChildOfRoot(Z){if(Z instanceof zK)this.addRef("scenes",Z);else if(Z instanceof $B)this.addRef("nodes",Z);else if(Z instanceof NY)this.addRef("cameras",Z);else if(Z instanceof SD)this.addRef("skins",Z);else if(Z instanceof YV)this.addRef("meshes",Z);else if(Z instanceof G7)this.addRef("materials",Z);else if(Z instanceof RY)this.addRef("textures",Z);else if(Z instanceof ID)this.addRef("animations",Z);else if(Z instanceof I0)this.addRef("accessors",Z);else if(Z instanceof _D)this.addRef("buffers",Z);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((Z)=>Z.isRequired())}_enableExtension(Z){return this._extensions.add(Z),this}_disableExtension(Z){return this._extensions.delete(Z),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(Z){return this.setRef("defaultScene",Z)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class k6{static fromGraph(Z){return k6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new WK,this._root=new MY(this._graph),this._logger=D5.DEFAULT_INSTANCE,k6._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(Z){return this._logger=Z,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...Z){let J=Z.map((X)=>X.name);for(let X of Z)await X(this,{stack:J});return this}createExtension(Z){let J=Z.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find((Y)=>Y.extensionName===J)||new Z(this)}createScene(Z=""){return new zK(this._graph,Z)}createNode(Z=""){return new $B(this._graph,Z)}createCamera(Z=""){return new NY(this._graph,Z)}createSkin(Z=""){return new SD(this._graph,Z)}createMesh(Z=""){return new YV(this._graph,Z)}createPrimitive(){return new j8(this._graph)}createPrimitiveTarget(Z=""){return new vD(this._graph,Z)}createMaterial(Z=""){return new G7(this._graph,Z)}createTexture(Z=""){return new RY(this._graph,Z)}createAnimation(Z=""){return new ID(this._graph,Z)}createAnimationChannel(Z=""){return new OY(this._graph,Z)}createAnimationSampler(Z=""){return new VK(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new I0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new _D(this._graph,Z)}}k6._GRAPH_DOCUMENTS=new WeakMap;class qp{constructor(Z){this.extensionName="",this.prereadTypes=[],this.prewriteTypes=[],this.readDependencies=[],this.writeDependencies=[],this.document=void 0,this.required=!1,this.properties=new Set,this._listener=void 0,this.document=Z,Z.getRoot()._enableExtension(this),this._listener=(X)=>{let Y=X,$=Y.target;if($ instanceof HK&&$.extensionName===this.extensionName){if(Y.type==="node:create")this._addExtensionProperty($);if(Y.type==="node:dispose")this._removeExtensionProperty($)}};let J=Z.getGraph();J.addEventListener("node:create",this._listener),J.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);let Z=this.document.getGraph();Z.removeEventListener("node:create",this._listener),Z.removeEventListener("node:dispose",this._listener);for(let J of this.properties)J.dispose()}static register(){}isRequired(){return this.required}setRequired(Z){return this.required=Z,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(Z){return this.properties.add(Z),this}_removeExtensionProperty(Z){return this.properties.delete(Z),this}install(Z,J){return this}preread(Z,J){return this}prewrite(Z,J){return this}}qp.EXTENSION_NAME=void 0;class Up{constructor(Z){this.jsonDoc=void 0,this.buffers=[],this.bufferViews=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.textureInfos=new Map,this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[],this.jsonDoc=Z}setTextureInfo(Z,J){if(this.textureInfos.set(Z,J),J.texCoord!==void 0)Z.setTexCoord(J.texCoord);if(J.extras!==void 0)Z.setExtras(J.extras);let X=this.jsonDoc.json.textures[J.index];if(X.sampler===void 0)return;let Y=this.jsonDoc.json.samplers[X.sampler];if(Y.magFilter!==void 0)Z.setMagFilter(Y.magFilter);if(Y.minFilter!==void 0)Z.setMinFilter(Y.minFilter);if(Y.wrapS!==void 0)Z.setWrapS(Y.wrapS);if(Y.wrapT!==void 0)Z.setWrapT(Y.wrapT)}}var Qp={logger:D5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},fB1=new Set([a.BUFFER,a.TEXTURE,a.MATERIAL,a.MESH,a.PRIMITIVE,a.NODE,a.SCENE]);class Lp{static read(Z,J=Qp){let X=a6({},Qp,J),{json:Y}=Z,$=new k6().setLogger(X.logger);this.validate(Z,X);let Q=new Up(Z),K=Y.asset,W=$.getRoot().getAsset();if(K.copyright)W.copyright=K.copyright;if(K.extras)W.extras=K.extras;if(Y.extras!==void 0)$.getRoot().setExtras(a6({},Y.extras));let G=Y.extensionsUsed||[],V=Y.extensionsRequired||[];X.extensions.sort((M,C)=>M.EXTENSION_NAME>C.EXTENSION_NAME?1:-1);for(let M of X.extensions)if(G.includes(M.EXTENSION_NAME)){let C=$.createExtension(M).setRequired(V.includes(M.EXTENSION_NAME)),T=C.prereadTypes.filter((E)=>!fB1.has(E));if(T.length)X.logger.warn(`Preread hooks for some types (${T.join()}), requested by extension ${C.extensionName}, are unsupported. Please file an issue or a PR.`);for(let E of C.readDependencies)C.install(E,X.dependencies[E])}let H=Y.buffers||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.BUFFER)).forEach((M)=>M.preread(Q,a.BUFFER)),Q.buffers=H.map((M)=>{let C=$.createBuffer(M.name);if(M.extras)C.setExtras(M.extras);if(M.uri&&M.uri.indexOf("__")!==0)C.setURI(M.uri);return C});let F=Y.bufferViews||[];Q.bufferViewBuffers=F.map((M,C)=>{if(!Q.bufferViews[C]){let T=Z.json.buffers[M.buffer],E=T.uri?Z.resources[T.uri]:Z.resources[rL],x=M.byteOffset||0;Q.bufferViews[C]=n0.toView(E,x,M.byteLength)}return Q.buffers[M.buffer]});let z=Y.accessors||[];Q.accessors=z.map((M)=>{let C=Q.bufferViewBuffers[M.bufferView],T=$.createAccessor(M.name,C).setType(M.type);if(M.extras)T.setExtras(M.extras);if(M.normalized!==void 0)T.setNormalized(M.normalized);if(M.bufferView===void 0)return T;return T.setArray(oL(M,Q)),T});let q=Y.images||[],U=Y.textures||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.TEXTURE)).forEach((M)=>M.preread(Q,a.TEXTURE)),Q.textures=q.map((M)=>{let C=$.createTexture(M.name);if(M.extras)C.setExtras(M.extras);if(M.bufferView!==void 0){let T=Y.bufferViews[M.bufferView],E=Z.json.buffers[T.buffer],x=E.uri?Z.resources[E.uri]:Z.resources[rL],v=T.byteOffset||0,S=T.byteLength,I=x.slice(v,v+S);C.setImage(I)}else if(M.uri!==void 0){if(C.setImage(Z.resources[M.uri]),M.uri.indexOf("__")!==0)C.setURI(M.uri)}if(M.mimeType!==void 0)C.setMimeType(M.mimeType);else if(M.uri){let T=BZ.extension(M.uri);C.setMimeType(LZ.extensionToMimeType(T))}return C}),$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.MATERIAL)).forEach((M)=>M.preread(Q,a.MATERIAL));let L=Y.materials||[];Q.materials=L.map((M)=>{let C=$.createMaterial(M.name);if(M.extras)C.setExtras(M.extras);if(M.alphaMode!==void 0)C.setAlphaMode(M.alphaMode);if(M.alphaCutoff!==void 0)C.setAlphaCutoff(M.alphaCutoff);if(M.doubleSided!==void 0)C.setDoubleSided(M.doubleSided);let T=M.pbrMetallicRoughness||{};if(T.baseColorFactor!==void 0)C.setBaseColorFactor(T.baseColorFactor);if(M.emissiveFactor!==void 0)C.setEmissiveFactor(M.emissiveFactor);if(T.metallicFactor!==void 0)C.setMetallicFactor(T.metallicFactor);if(T.roughnessFactor!==void 0)C.setRoughnessFactor(T.roughnessFactor);if(T.baseColorTexture!==void 0){let E=T.baseColorTexture,x=Q.textures[U[E.index].source];C.setBaseColorTexture(x),Q.setTextureInfo(C.getBaseColorTextureInfo(),E)}if(M.emissiveTexture!==void 0){let E=M.emissiveTexture,x=Q.textures[U[E.index].source];C.setEmissiveTexture(x),Q.setTextureInfo(C.getEmissiveTextureInfo(),E)}if(M.normalTexture!==void 0){let E=M.normalTexture,x=Q.textures[U[E.index].source];if(C.setNormalTexture(x),Q.setTextureInfo(C.getNormalTextureInfo(),E),M.normalTexture.scale!==void 0)C.setNormalScale(M.normalTexture.scale)}if(M.occlusionTexture!==void 0){let E=M.occlusionTexture,x=Q.textures[U[E.index].source];if(C.setOcclusionTexture(x),Q.setTextureInfo(C.getOcclusionTextureInfo(),E),M.occlusionTexture.strength!==void 0)C.setOcclusionStrength(M.occlusionTexture.strength)}if(T.metallicRoughnessTexture!==void 0){let E=T.metallicRoughnessTexture,x=Q.textures[U[E.index].source];C.setMetallicRoughnessTexture(x),Q.setTextureInfo(C.getMetallicRoughnessTextureInfo(),E)}return C}),$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.MESH)).forEach((M)=>M.preread(Q,a.MESH));let B=Y.meshes||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.PRIMITIVE)).forEach((M)=>M.preread(Q,a.PRIMITIVE)),Q.meshes=B.map((M)=>{let C=$.createMesh(M.name);if(M.extras)C.setExtras(M.extras);if(M.weights!==void 0)C.setWeights(M.weights);return(M.primitives||[]).forEach((E)=>{let x=$.createPrimitive();if(E.extras)x.setExtras(E.extras);if(E.material!==void 0)x.setMaterial(Q.materials[E.material]);if(E.mode!==void 0)x.setMode(E.mode);for(let[I,_]of Object.entries(E.attributes||{}))x.setAttribute(I,Q.accessors[_]);if(E.indices!==void 0)x.setIndices(Q.accessors[E.indices]);let v=M.extras&&M.extras.targetNames||[];(E.targets||[]).forEach((I,_)=>{let y=v[_]||_.toString(),p=$.createPrimitiveTarget(y);for(let[n,o]of Object.entries(I))p.setAttribute(n,Q.accessors[o]);x.addTarget(p)}),C.addPrimitive(x)}),C});let w=Y.cameras||[];Q.cameras=w.map((M)=>{let C=$.createCamera(M.name).setType(M.type);if(M.extras)C.setExtras(M.extras);if(M.type===NY.Type.PERSPECTIVE){let T=M.perspective;if(C.setYFov(T.yfov),C.setZNear(T.znear),T.zfar!==void 0)C.setZFar(T.zfar);if(T.aspectRatio!==void 0)C.setAspectRatio(T.aspectRatio)}else{let T=M.orthographic;C.setZNear(T.znear).setZFar(T.zfar).setXMag(T.xmag).setYMag(T.ymag)}return C});let O=Y.nodes||[];$.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.NODE)).forEach((M)=>M.preread(Q,a.NODE)),Q.nodes=O.map((M)=>{let C=$.createNode(M.name);if(M.extras)C.setExtras(M.extras);if(M.translation!==void 0)C.setTranslation(M.translation);if(M.rotation!==void 0)C.setRotation(M.rotation);if(M.scale!==void 0)C.setScale(M.scale);if(M.matrix!==void 0){let T=[0,0,0],E=[0,0,0,1],x=[1,1,1];c0.decompose(M.matrix,T,E,x),C.setTranslation(T),C.setRotation(E),C.setScale(x)}if(M.weights!==void 0)C.setWeights(M.weights);return C});let N=Y.skins||[];Q.skins=N.map((M)=>{let C=$.createSkin(M.name);if(M.extras)C.setExtras(M.extras);if(M.inverseBindMatrices!==void 0)C.setInverseBindMatrices(Q.accessors[M.inverseBindMatrices]);if(M.skeleton!==void 0)C.setSkeleton(Q.nodes[M.skeleton]);for(let T of M.joints)C.addJoint(Q.nodes[T]);return C}),O.map((M,C)=>{let T=Q.nodes[C];if((M.children||[]).forEach((x)=>T.addChild(Q.nodes[x])),M.mesh!==void 0)T.setMesh(Q.meshes[M.mesh]);if(M.camera!==void 0)T.setCamera(Q.cameras[M.camera]);if(M.skin!==void 0)T.setSkin(Q.skins[M.skin])});let R=Y.animations||[];Q.animations=R.map((M)=>{let C=$.createAnimation(M.name);if(M.extras)C.setExtras(M.extras);let E=(M.samplers||[]).map((v)=>{let S=$.createAnimationSampler().setInput(Q.accessors[v.input]).setOutput(Q.accessors[v.output]).setInterpolation(v.interpolation||VK.Interpolation.LINEAR);if(v.extras)S.setExtras(v.extras);return C.addSampler(S),S});return(M.channels||[]).forEach((v)=>{let S=$.createAnimationChannel().setSampler(E[v.sampler]).setTargetPath(v.target.path);if(v.target.node!==void 0)S.setTargetNode(Q.nodes[v.target.node]);if(v.extras)S.setExtras(v.extras);C.addChannel(S)}),C});let D=Y.scenes||[];if($.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(a.SCENE)).forEach((M)=>M.preread(Q,a.SCENE)),Q.scenes=D.map((M)=>{let C=$.createScene(M.name);if(M.extras)C.setExtras(M.extras);return(M.nodes||[]).map((E)=>Q.nodes[E]).forEach((E)=>C.addChild(E)),C}),Y.scene!==void 0)$.getRoot().setDefaultScene(Q.scenes[Y.scene]);return $.getRoot().listExtensionsUsed().forEach((M)=>M.read(Q)),z.forEach((M,C)=>{let T=Q.accessors[C],E=!!M.sparse,x=!M.bufferView&&!T.getArray();if(E||x)T.setSparse(!0).setArray(bB1(M,Q))}),$}static validate(Z,J){let X=Z.json;if(X.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${X.asset.version}".`);if(X.extensionsRequired){for(let Y of X.extensionsRequired)if(!J.extensions.find(($)=>$.EXTENSION_NAME===Y))throw new Error(`Missing required extension, "${Y}".`)}if(X.extensionsUsed){for(let Y of X.extensionsUsed)if(!J.extensions.find(($)=>$.EXTENSION_NAME===Y))J.logger.warn(`Missing optional extension, "${Y}".`)}}}function yB1(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=kJ[Z.componentType],K=I0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=Z.byteOffset||0,V=new Q(Z.count*K),H=new DataView(Y.buffer,Y.byteOffset,Y.byteLength),F=$.byteStride;for(let z=0;z<Z.count;z++)for(let q=0;q<K;q++){let U=G+z*F+q*W,L;switch(Z.componentType){case I0.ComponentType.FLOAT:L=H.getFloat32(U,!0);break;case I0.ComponentType.UNSIGNED_INT:L=H.getUint32(U,!0);break;case I0.ComponentType.UNSIGNED_SHORT:L=H.getUint16(U,!0);break;case I0.ComponentType.UNSIGNED_BYTE:L=H.getUint8(U);break;case I0.ComponentType.SHORT:L=H.getInt16(U,!0);break;case I0.ComponentType.BYTE:L=H.getInt8(U);break;default:throw new Error(`Unexpected componentType "${Z.componentType}".`)}V[z*K+q]=L}return V}function oL(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=kJ[Z.componentType],K=I0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if($.byteStride!==void 0&&$.byteStride!==G)return yB1(Z,J);let V=Y.byteOffset+(Z.byteOffset||0),H=Z.count*K*W;return new Q(Y.buffer.slice(V,V+H))}function bB1(Z,J){let X=kJ[Z.componentType],Y=I0.getElementSize(Z.type),$;if(Z.bufferView!==void 0)$=oL(Z,J);else $=new X(Z.count*Y);let Q=Z.sparse;if(!Q)return $;let K=Q.count,W=a6({},Z,Q.indices,{count:K,type:"SCALAR"}),G=a6({},Z,Q.values,{count:K}),V=oL(W,J),H=oL(G,J);for(let F=0;F<W.count;F++)for(let z=0;z<Y;z++)$[V[F]*Y+z]=H[F*Y+z];return $}var XV;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(XV||(XV={}));class TJ{constructor(Z,J,X){this._doc=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this._accessorUsageMap=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this._doc=Z,this.jsonDoc=J,this.options=X;let Y=Z.getRoot(),$=Y.listBuffers().length,Q=Y.listTextures().length;this.bufferURIGenerator=new TD($>1,()=>X.basename||"buffer"),this.imageURIGenerator=new TD(Q>1,(K)=>gB1(Z,K)||X.basename||"texture"),this.logger=Z.getLogger()}createTextureInfoDef(Z,J){let X={magFilter:J.getMagFilter()||void 0,minFilter:J.getMinFilter()||void 0,wrapS:J.getWrapS(),wrapT:J.getWrapT()},Y=JSON.stringify(X);if(!this.samplerDefIndexMap.has(Y))this.samplerDefIndexMap.set(Y,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(X);let $={source:this.imageIndexMap.get(Z),sampler:this.samplerDefIndexMap.get(Y)},Q=JSON.stringify($);if(!this.textureDefIndexMap.has(Q))this.textureDefIndexMap.set(Q,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push($);let K={index:this.textureDefIndexMap.get(Q)};if(J.getTexCoord()!==0)K.texCoord=J.getTexCoord();if(Object.keys(J.getExtras()).length>0)K.extras=J.getExtras();return this.textureInfoDefMap.set(J,K),K}createPropertyDef(Z){let J={};if(Z.getName())J.name=Z.getName();if(Object.keys(Z.getExtras()).length>0)J.extras=Z.getExtras();return J}createAccessorDef(Z){let J=this.createPropertyDef(Z);if(J.type=Z.getType(),J.componentType=Z.getComponentType(),J.count=Z.getCount(),this._doc.getGraph().listParentEdges(Z).some((Y)=>Y.getName()==="attributes"&&Y.getAttributes().key==="POSITION"||Y.getName()==="input"))J.max=Z.getMax([]).map(Math.fround),J.min=Z.getMin([]).map(Math.fround);if(Z.getNormalized())J.normalized=Z.getNormalized();return J}createImageData(Z,J,X){if(this.options.format===UZ.GLB)this.imageBufferViews.push(J),Z.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:J.byteLength});else{let Y=LZ.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,Y),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let Y=this.jsonDoc.resources;if(!(Z in Y)){Y[Z]=J;return}if(J===Y[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let $=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn($);return}throw new Error($)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return n5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:Y}=X.getAttributes();if(Y)return Y;if(X.getParent().propertyType!==a.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return n5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw new Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}TJ.BufferViewTarget=XV;TJ.BufferViewUsage=n5;TJ.USAGE_TO_TARGET={[n5.ARRAY_BUFFER]:XV.ARRAY_BUFFER,[n5.ELEMENT_ARRAY_BUFFER]:XV.ELEMENT_ARRAY_BUFFER};class TD{constructor(Z,J){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=Z,this.basename=J}createURI(Z,J){if(Z.getURI())return Z.getURI();else if(!this.multiple)return`${this.basename(Z)}.${J}`;else{let X=this.basename(Z);return this.counter[X]=this.counter[X]||1,`${X}_${this.counter[X]++}.${J}`}}}function gB1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:sL}=TJ,{UNSIGNED_INT:mB1,UNSIGNED_SHORT:uB1,UNSIGNED_BYTE:dB1}=I0.ComponentType,cB1=new Set([a.ACCESSOR,a.BUFFER,a.MATERIAL,a.MESH]);class Bp{static write(Z,J){let X=Z.getGraph(),Y=Z.getRoot(),$={asset:a6({generator:`glTF-Transform ${Wp}`},Y.getAsset()),extras:a6({},Y.getExtras())},Q={json:$,resources:{}},K=new TJ(Z,Q,J),W=J.logger||D5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((B)=>B.EXTENSION_NAME)),V=Z.getRoot().listExtensionsUsed().filter((B)=>G.has(B.extensionName)).sort((B,w)=>B.extensionName>w.extensionName?1:-1),H=Z.getRoot().listExtensionsRequired().filter((B)=>G.has(B.extensionName)).sort((B,w)=>B.extensionName>w.extensionName?1:-1);if(V.length<Z.getRoot().listExtensionsUsed().length)W.warn("Some extensions were not registered for I/O, and will not be written.");for(let B of V){let w=B.prewriteTypes.filter((O)=>!cB1.has(O));if(w.length)W.warn(`Prewrite hooks for some types (${w.join()}), requested by extension ${B.extensionName}, are unsupported. Please file an issue or a PR.`);for(let O of B.writeDependencies)B.install(O,J.dependencies[O])}function F(B,w,O,N){let R=[],D=0;for(let T of B){let E=K.createAccessorDef(T);E.bufferView=$.bufferViews.length;let x=T.getArray(),v=n0.pad(n0.toView(x));E.byteOffset=D,D+=v.byteLength,R.push(v),K.accessorIndexMap.set(T,$.accessors.length),$.accessors.push(E)}let M=n0.concat(R),C={buffer:w,byteOffset:O,byteLength:M.byteLength};if(N)C.target=N;return $.bufferViews.push(C),{buffers:R,byteLength:D}}function z(B,w,O){let N=B[0].getCount(),R=0;for(let E of B){let x=K.createAccessorDef(E);x.bufferView=$.bufferViews.length,x.byteOffset=R;let v=E.getElementSize(),S=E.getComponentSize();R+=n0.padNumber(v*S),K.accessorIndexMap.set(E,$.accessors.length),$.accessors.push(x)}let D=N*R,M=new ArrayBuffer(D),C=new DataView(M);for(let E=0;E<N;E++){let x=0;for(let v of B){let S=v.getElementSize(),I=v.getComponentSize(),_=v.getComponentType(),y=v.getArray();for(let p=0;p<S;p++){let n=E*R+x+p*I,o=y[E*S+p];switch(_){case I0.ComponentType.FLOAT:C.setFloat32(n,o,!0);break;case I0.ComponentType.BYTE:C.setInt8(n,o);break;case I0.ComponentType.SHORT:C.setInt16(n,o,!0);break;case I0.ComponentType.UNSIGNED_BYTE:C.setUint8(n,o);break;case I0.ComponentType.UNSIGNED_SHORT:C.setUint16(n,o,!0);break;case I0.ComponentType.UNSIGNED_INT:C.setUint32(n,o,!0);break;default:throw new Error("Unexpected component type: "+_)}}x+=n0.padNumber(S*I)}}let T={buffer:w,byteOffset:O,byteLength:D,byteStride:R,target:TJ.BufferViewTarget.ARRAY_BUFFER};return $.bufferViews.push(T),{byteLength:D,buffers:[new Uint8Array(M)]}}function q(B,w,O){let N=[],R=0,D=new Map,M=-1/0,C=!1;for(let _ of B){let y=K.createAccessorDef(_);$.accessors.push(y),K.accessorIndexMap.set(_,$.accessors.length-1);let p=[],n=[],o=[],X0=new Array(_.getElementSize()).fill(0);for(let a0=0,k8=_.getCount();a0<k8;a0++){if(_.getElement(a0,o),c0.eq(o,X0,0))continue;M=Math.max(a0,M),p.push(a0);for(let n1=0;n1<o.length;n1++)n.push(o[n1])}let Q0=p.length,E0={accessorDef:y,count:Q0};if(D.set(_,E0),Q0===0)continue;if(Q0>_.getCount()/2)C=!0;let k0=kJ[_.getComponentType()];E0.indices=p,E0.values=new k0(n)}if(!Number.isFinite(M))return{buffers:N,byteLength:R};if(C)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let T=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,E=M<255?dB1:M<65535?uB1:mB1,x={buffer:w,byteOffset:O+R,byteLength:0};for(let _ of B){let y=D.get(_);if(y.count===0)continue;y.indicesByteOffset=x.byteLength;let p=n0.pad(n0.toView(new T(y.indices)));N.push(p),R+=p.byteLength,x.byteLength+=p.byteLength}$.bufferViews.push(x);let v=$.bufferViews.length-1,S={buffer:w,byteOffset:O+R,byteLength:0};for(let _ of B){let y=D.get(_);if(y.count===0)continue;y.valuesByteOffset=S.byteLength;let p=n0.pad(n0.toView(y.values));N.push(p),R+=p.byteLength,S.byteLength+=p.byteLength}$.bufferViews.push(S);let I=$.bufferViews.length-1;for(let _ of B){let y=D.get(_);if(y.count===0)continue;y.accessorDef.sparse={count:y.count,indices:{bufferView:v,byteOffset:y.indicesByteOffset,componentType:E},values:{bufferView:I,byteOffset:y.valuesByteOffset}}}return{buffers:N,byteLength:R}}if($.accessors=[],$.bufferViews=[],$.samplers=[],$.textures=[],$.images=Y.listTextures().map((B,w)=>{let O=K.createPropertyDef(B);if(B.getMimeType())O.mimeType=B.getMimeType();let N=B.getImage();if(N)K.createImageData(O,N,B);return K.imageIndexMap.set(B,w),O}),V.filter((B)=>B.prewriteTypes.includes(a.ACCESSOR)).forEach((B)=>B.prewrite(K,a.ACCESSOR)),Y.listAccessors().forEach((B)=>{let{accessorUsageGroupedByParent:w,accessorParents:O}=K;if(K.accessorIndexMap.has(B))return;let N=K.getAccessorUsage(B);if(K.addAccessorToUsageGroup(B,N),w.has(N)){let R=X.listParents(B).find((D)=>D.propertyType!==a.ROOT);O.set(B,R)}}),V.filter((B)=>B.prewriteTypes.includes(a.BUFFER)).forEach((B)=>B.prewrite(K,a.BUFFER)),(Y.listAccessors().length>0||K.otherBufferViews.size>0||Y.listTextures().length>0&&J.format===UZ.GLB)&&Y.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");if($.buffers=[],Y.listBuffers().forEach((B,w)=>{let O=K.createPropertyDef(B),N=K.accessorUsageGroupedByParent,R=B.listParents().filter((S)=>S instanceof I0),D=new Set(R.map((S)=>K.accessorParents.get(S))),M=new Map(Array.from(D).map((S,I)=>[S,I])),C={};for(let S of R){var T;if(K.accessorIndexMap.has(S))continue;let I=K.getAccessorUsage(S),_=I;if(N.has(I)){let y=K.accessorParents.get(S);_+=`:${M.get(y)}`}C[T=_]||(C[T]={usage:I,accessors:[]}),C[_].accessors.push(S)}let E=[],x=$.buffers.length,v=0;for(let{usage:S,accessors:I}of Object.values(C))if(S===sL.ARRAY_BUFFER&&J.vertexLayout===tL.INTERLEAVED){let _=z(I,x,v);v+=_.byteLength;for(let y of _.buffers)E.push(y)}else if(S===sL.ARRAY_BUFFER)for(let _ of I){let y=z([_],x,v);v+=y.byteLength;for(let p of y.buffers)E.push(p)}else if(S===sL.SPARSE){let _=q(I,x,v);v+=_.byteLength;for(let y of _.buffers)E.push(y)}else if(S===sL.ELEMENT_ARRAY_BUFFER){let _=TJ.BufferViewTarget.ELEMENT_ARRAY_BUFFER,y=F(I,x,v,_);v+=y.byteLength;for(let p of y.buffers)E.push(p)}else{let _=F(I,x,v);v+=_.byteLength;for(let y of _.buffers)E.push(y)}if(K.imageBufferViews.length&&w===0){for(let S=0;S<K.imageBufferViews.length;S++)if($.bufferViews[$.images[S].bufferView].byteOffset=v,v+=K.imageBufferViews[S].byteLength,E.push(K.imageBufferViews[S]),v%8){let I=8-v%8;v+=I,E.push(new Uint8Array(I))}}if(K.otherBufferViews.has(B))for(let S of K.otherBufferViews.get(B))$.bufferViews.push({buffer:x,byteOffset:v,byteLength:S.byteLength}),K.otherBufferViewsIndexMap.set(S,$.bufferViews.length-1),v+=S.byteLength,E.push(S);if(v){let S;if(J.format===UZ.GLB)S=rL;else S=K.bufferURIGenerator.createURI(B,"bin"),O.uri=S;O.byteLength=v,K.assignResourceURI(S,n0.concat(E),!0)}$.buffers.push(O),K.bufferIndexMap.set(B,w)}),Y.listAccessors().find((B)=>!B.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");V.filter((B)=>B.prewriteTypes.includes(a.MATERIAL)).forEach((B)=>B.prewrite(K,a.MATERIAL)),$.materials=Y.listMaterials().map((B,w)=>{let O=K.createPropertyDef(B);if(B.getAlphaMode()!==G7.AlphaMode.OPAQUE)O.alphaMode=B.getAlphaMode();if(B.getAlphaMode()===G7.AlphaMode.MASK)O.alphaCutoff=B.getAlphaCutoff();if(B.getDoubleSided())O.doubleSided=!0;if(O.pbrMetallicRoughness={},!c0.eq(B.getBaseColorFactor(),[1,1,1,1]))O.pbrMetallicRoughness.baseColorFactor=B.getBaseColorFactor();if(!c0.eq(B.getEmissiveFactor(),[0,0,0]))O.emissiveFactor=B.getEmissiveFactor();if(B.getRoughnessFactor()!==1)O.pbrMetallicRoughness.roughnessFactor=B.getRoughnessFactor();if(B.getMetallicFactor()!==1)O.pbrMetallicRoughness.metallicFactor=B.getMetallicFactor();if(B.getBaseColorTexture()){let N=B.getBaseColorTexture(),R=B.getBaseColorTextureInfo();O.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(N,R)}if(B.getEmissiveTexture()){let N=B.getEmissiveTexture(),R=B.getEmissiveTextureInfo();O.emissiveTexture=K.createTextureInfoDef(N,R)}if(B.getNormalTexture()){let N=B.getNormalTexture(),R=B.getNormalTextureInfo(),D=K.createTextureInfoDef(N,R);if(B.getNormalScale()!==1)D.scale=B.getNormalScale();O.normalTexture=D}if(B.getOcclusionTexture()){let N=B.getOcclusionTexture(),R=B.getOcclusionTextureInfo(),D=K.createTextureInfoDef(N,R);if(B.getOcclusionStrength()!==1)D.strength=B.getOcclusionStrength();O.occlusionTexture=D}if(B.getMetallicRoughnessTexture()){let N=B.getMetallicRoughnessTexture(),R=B.getMetallicRoughnessTextureInfo();O.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(N,R)}return K.materialIndexMap.set(B,w),O}),V.filter((B)=>B.prewriteTypes.includes(a.MESH)).forEach((B)=>B.prewrite(K,a.MESH)),$.meshes=Y.listMeshes().map((B,w)=>{let O=K.createPropertyDef(B),N=null;if(O.primitives=B.listPrimitives().map((R)=>{let D={attributes:{}};D.mode=R.getMode();let M=R.getMaterial();if(M)D.material=K.materialIndexMap.get(M);if(Object.keys(R.getExtras()).length)D.extras=R.getExtras();let C=R.getIndices();if(C)D.indices=K.accessorIndexMap.get(C);for(let T of R.listSemantics())D.attributes[T]=K.accessorIndexMap.get(R.getAttribute(T));for(let T of R.listTargets()){let E={};for(let x of T.listSemantics())E[x]=K.accessorIndexMap.get(T.getAttribute(x));D.targets=D.targets||[],D.targets.push(E)}if(R.listTargets().length&&!N)N=R.listTargets().map((T)=>T.getName());return D}),B.getWeights().length)O.weights=B.getWeights();if(N)O.extras=O.extras||{},O.extras.targetNames=N;return K.meshIndexMap.set(B,w),O}),$.cameras=Y.listCameras().map((B,w)=>{let O=K.createPropertyDef(B);if(O.type=B.getType(),O.type===NY.Type.PERSPECTIVE){O.perspective={znear:B.getZNear(),zfar:B.getZFar(),yfov:B.getYFov()};let N=B.getAspectRatio();if(N!==null)O.perspective.aspectRatio=N}else O.orthographic={znear:B.getZNear(),zfar:B.getZFar(),xmag:B.getXMag(),ymag:B.getYMag()};return K.cameraIndexMap.set(B,w),O}),$.nodes=Y.listNodes().map((B,w)=>{let O=K.createPropertyDef(B);if(!c0.eq(B.getTranslation(),[0,0,0]))O.translation=B.getTranslation();if(!c0.eq(B.getRotation(),[0,0,0,1]))O.rotation=B.getRotation();if(!c0.eq(B.getScale(),[1,1,1]))O.scale=B.getScale();if(B.getWeights().length)O.weights=B.getWeights();return K.nodeIndexMap.set(B,w),O}),$.skins=Y.listSkins().map((B,w)=>{let O=K.createPropertyDef(B),N=B.getInverseBindMatrices();if(N)O.inverseBindMatrices=K.accessorIndexMap.get(N);let R=B.getSkeleton();if(R)O.skeleton=K.nodeIndexMap.get(R);return O.joints=B.listJoints().map((D)=>K.nodeIndexMap.get(D)),K.skinIndexMap.set(B,w),O}),Y.listNodes().forEach((B,w)=>{let O=$.nodes[w],N=B.getMesh();if(N)O.mesh=K.meshIndexMap.get(N);let R=B.getCamera();if(R)O.camera=K.cameraIndexMap.get(R);let D=B.getSkin();if(D)O.skin=K.skinIndexMap.get(D);if(B.listChildren().length>0)O.children=B.listChildren().map((M)=>K.nodeIndexMap.get(M))}),$.animations=Y.listAnimations().map((B,w)=>{let O=K.createPropertyDef(B),N=new Map;return O.samplers=B.listSamplers().map((R,D)=>{let M=K.createPropertyDef(R);return M.input=K.accessorIndexMap.get(R.getInput()),M.output=K.accessorIndexMap.get(R.getOutput()),M.interpolation=R.getInterpolation(),N.set(R,D),M}),O.channels=B.listChannels().map((R)=>{let D=K.createPropertyDef(R);return D.sampler=N.get(R.getSampler()),D.target={node:K.nodeIndexMap.get(R.getTargetNode()),path:R.getTargetPath()},D}),K.animationIndexMap.set(B,w),O}),$.scenes=Y.listScenes().map((B,w)=>{let O=K.createPropertyDef(B);return O.nodes=B.listChildren().map((N)=>K.nodeIndexMap.get(N)),K.sceneIndexMap.set(B,w),O});let L=Y.getDefaultScene();if(L)$.scene=Y.listScenes().indexOf(L);return $.extensionsUsed=V.map((B)=>B.extensionName),$.extensionsRequired=H.map((B)=>B.extensionName),V.forEach((B)=>B.write(K)),lB1($),Q}}function lB1(Z){let J=[];for(let X in Z){let Y=Z[X];if(Array.isArray(Y)&&Y.length===0)J.push(X);else if(Y===null||Y==="")J.push(X);else if(Y&&typeof Y==="object"&&Object.keys(Y).length===0)J.push(X)}for(let X of J)delete Z[X]}var JB;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(JB||(JB={}));class wp{constructor(){this._logger=D5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=tL.INTERLEAVED,this.lastReadBytes=0,this.lastWriteBytes=0}setLogger(Z){return this._logger=Z,this}registerExtensions(Z){for(let J of Z)this._extensions.add(J),J.register();return this}registerDependencies(Z){return Object.assign(this._dependencies,Z),this}setVertexLayout(Z){return this._vertexLayout=Z,this}async read(Z){return await this.readJSON(await this.readAsJSON(Z))}async readAsJSON(Z){let J=await this.readURI(Z,"view");this.lastReadBytes=J.byteLength;let X=Kp(J)?this._binaryToJSON(J):{json:JSON.parse(n0.decodeText(J)),resources:{}};return await this._readResourcesExternal(X,this.dirname(Z)),this._readResourcesInternal(X),X}async readJSON(Z){return Z=this._copyJSON(Z),this._readResourcesInternal(Z),Lp.read(Z,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(Z){let J=this._binaryToJSON(n0.assertView(Z));this._readResourcesInternal(J);let X=J.json;if(X.buffers&&X.buffers.some((Y)=>pB1(J,Y)))throw new Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some((Y)=>iB1(J,Y)))throw new Error("Cannot resolve external images with binaryToJSON().");return J}async readBinary(Z){return this.readJSON(await this.binaryToJSON(n0.assertView(Z)))}async writeJSON(Z,J={}){if(J.format===UZ.GLB&&Z.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Bp.write(Z,{format:J.format||UZ.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:a6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:UZ.GLB}),Y=new Uint32Array([1179937895,2,12]),$=JSON.stringify(J),Q=n0.pad(n0.encodeText($),32),K=n0.toView(new Uint32Array([Q.byteLength,1313821514])),W=n0.concat([K,Q]);Y[Y.length-1]+=W.byteLength;let G=Object.values(X)[0];if(!G||!G.byteLength)return n0.concat([n0.toView(Y),W]);let V=n0.pad(G,0),H=n0.toView(new Uint32Array([V.byteLength,5130562])),F=n0.concat([H,V]);return Y[Y.length-1]+=F.byteLength,n0.concat([n0.toView(Y),W,F])}async _readResourcesExternal(Z,J){var X=this;let Y=Z.json.images||[],$=Z.json.buffers||[],Q=[...Y,...$].map(async function(K){let W=K.uri;if(!W||W.match(/data:/))return Promise.resolve();Z.resources[W]=await X.readURI(X.resolve(J,W),"view"),X.lastReadBytes+=Z.resources[W].byteLength});await Promise.all(Q)}_readResourcesInternal(Z){function J($){if(!$.uri)return;if($.uri in Z.resources){n0.assertView(Z.resources[$.uri]);return}if($.uri.match(/data:/)){let Q=`__${Fp()}.${BZ.extension($.uri)}`;Z.resources[Q]=n0.createBufferFromDataURI($.uri),$.uri=Q}}(Z.json.images||[]).forEach(($)=>{if($.bufferView===void 0&&$.uri===void 0)throw new Error("Missing resource URI or buffer view.");J($)}),(Z.json.buffers||[]).forEach(J)}_copyJSON(Z){let{images:J,buffers:X}=Z.json;if(Z={json:a6({},Z.json),resources:a6({},Z.resources)},J)Z.json.images=J.map((Y)=>a6({},Y));if(X)Z.json.buffers=X.map((Y)=>a6({},Y));return Z}_binaryToJSON(Z){if(!Kp(Z))throw new Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==JB.JSON)throw new Error("Missing required GLB JSON chunk.");let X=20,Y=J[0],$=n0.decodeText(n0.toView(Z,X,Y)),Q=JSON.parse($),K=X+Y;if(Z.byteLength<=K)return{json:Q,resources:{}};let W=new Uint32Array(Z.buffer,Z.byteOffset+K,2);if(W[1]!==JB.BIN)return{json:Q,resources:{}};let G=W[0],V=n0.toView(Z,K+8,G);return{json:Q,resources:{[rL]:V}}}}function pB1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function iB1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function Kp(Z){if(Z.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;let J=new Uint32Array(Z.buffer,Z.byteOffset,3);return J[0]===1179937895&&J[1]===2}class AD extends wp{constructor(Z=null,J=E9.DEFAULT_INIT){super();this._fetch=void 0,this._fetchConfig=void 0,this._init=void 0,this._fetchEnabled=!1,this._fetch=Z,this._fetchConfig=J,this._init=this.init()}async init(){if(this._init)return this._init;return Promise.all([import("fs"),import("path")]).then(([Z,J])=>{this._fs=Z.promises,this._path=J})}setAllowNetwork(Z){if(Z&&!this._fetch)throw new Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=Z,this}async readURI(Z,J){if(await this.init(),E9.isAbsoluteURL(Z)){if(!this._fetchEnabled||!this._fetch)throw new Error("Network request blocked. Allow HTTP requests explicitly, if needed.");let X=await this._fetch(Z,this._fetchConfig);switch(J){case"view":return new Uint8Array(await X.arrayBuffer());case"text":return X.text()}}else switch(J){case"view":return this._fs.readFile(Z);case"text":return this._fs.readFile(Z,"utf8")}}resolve(Z,J){if(E9.isAbsoluteURL(Z)||E9.isAbsoluteURL(J))return E9.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(E9.isAbsoluteURL(Z))return E9.dirname(Z);return this._path.dirname(Z)}async write(Z,J){await this.init(),await(!!Z.match(/\.glb$/)?this._writeGLB(Z,J):this._writeGLTF(Z,J))}async _writeGLTF(Z,J){var X=this;this.lastWriteBytes=0;let{json:Y,resources:$}=await this.writeJSON(J,{format:UZ.GLTF,basename:BZ.basename(Z)}),{_fs:Q,_path:K}=this,W=K.dirname(Z),G=JSON.stringify(Y,null,2);await Q.writeFile(Z,G),this.lastWriteBytes+=G.length;for(let V of nB1(Object.keys($),10))await Promise.all(V.map(async function(H){if(E9.isAbsoluteURL(H)){if(E9.extension(H)==="bin")throw new Error(`Cannot write buffer to path "${H}".`);return}let F=K.join(W,decodeURIComponent(H));await Q.mkdir(K.dirname(F),{recursive:!0}),await Q.writeFile(F,$[H]),X.lastWriteBytes+=$[H].byteLength}))}async _writeGLB(Z,J){let X=await this.writeBinary(J);await this._fs.writeFile(Z,X),this.lastWriteBytes=X.byteLength}}function nB1(Z,J){let X=[];for(let Y=0,$=Z.length;Y<$;Y+=J){let Q=[];for(let K=0;K<J&&Y+K<$;K++)Q.push(Z[Y+K]);X.push(Q)}return X}var Ua=r(xD(),1),La=r(rn(),1),bN1=r(qa(),1);async function gN1(Z,J){if(!(Z instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:Y}=await La.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return Ua.default(new Uint8Array(X),[Y.width,Y.height,4],[4,4*Y.width|0,1],0)}async function Ba(Z,J){return gN1(Z)}var mN1="v4.1.3",FC="@glb.bin",s;(function(Z){Z.ACCESSOR="Accessor",Z.ANIMATION="Animation",Z.ANIMATION_CHANNEL="AnimationChannel",Z.ANIMATION_SAMPLER="AnimationSampler",Z.BUFFER="Buffer",Z.CAMERA="Camera",Z.MATERIAL="Material",Z.MESH="Mesh",Z.PRIMITIVE="Primitive",Z.PRIMITIVE_TARGET="PrimitiveTarget",Z.NODE="Node",Z.ROOT="Root",Z.SCENE="Scene",Z.SKIN="Skin",Z.TEXTURE="Texture",Z.TEXTURE_INFO="TextureInfo"})(s||(s={}));var wa;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(wa||(wa={}));var o5;(function(Z){Z.ARRAY_BUFFER="ARRAY_BUFFER",Z.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",Z.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",Z.OTHER="OTHER",Z.SPARSE="SPARSE"})(o5||(o5={}));var r5;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(r5||(r5={}));var KC;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(KC||(KC={}));var WC=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function uN1(){var Z=new WC(3);if(WC!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function QC(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function dN1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=X[3]*Y+X[7]*$+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*Y+X[4]*$+X[8]*Q+X[12])/K,Z[1]=(X[1]*Y+X[5]*$+X[9]*Q+X[13])/K,Z[2]=(X[2]*Y+X[6]*$+X[10]*Q+X[14])/K,Z}(function(){var Z=uN1();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=3;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();function Ra(Z){let J=Ma(),X=Z.propertyType===s.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=cN1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))GC(K.min,J),GC(K.max,J)});return J}function cN1(Z,J){let X=Ma();for(let Y of Z.listPrimitives()){let $=Y.getAttribute("POSITION"),Q=Y.getIndices();if(!$)continue;let K=[0,0,0],W=[0,0,0];for(let G=0,V=Q?Q.getCount():$.getCount();G<V;G++){let H=Q?Q.getScalar(G):G;K=$.getElement(H,K),W=dN1(W,K,J),GC(W,X)}}return X}function GC(Z,J){for(let X=0;X<3;X++)J.min[X]=Math.min(Z[X],J.min[X]),J.max[X]=Math.max(Z[X],J.max[X])}function Ma(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class _6{static createBufferFromDataURI(Z){if(typeof Buffer==="undefined"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let Y=0;Y<J.length;Y++)X[Y]=J.charCodeAt(Y);return X}else{let J=Z.split(",")[1],X=Z.indexOf("base64")>=0;return Buffer.from(J,X?"base64":"utf8")}}static encodeText(Z){return new TextEncoder().encode(Z)}static decodeText(Z){return new TextDecoder().decode(Z)}static concat(Z){let J=0;for(let $ of Z)J+=$.byteLength;let X=new Uint8Array(J),Y=0;for(let $ of Z)X.set($,Y),Y+=$.byteLength;return X}static pad(Z,J=0){let X=this.padNumber(Z.byteLength);if(X===Z.byteLength)return Z;let Y=new Uint8Array(X);if(Y.set(Z),J!==0)for(let $=Z.byteLength;$<X;$++)Y[$]=J;return Y}static padNumber(Z){return Math.ceil(Z/4)*4}static equals(Z,J){if(Z===J)return!0;if(Z.byteLength!==J.byteLength)return!1;let X=Z.byteLength;while(X--)if(Z[X]!==J[X])return!1;return!0}static toView(Z,J=0,X=1/0){return new Uint8Array(Z.buffer,Z.byteOffset+J,Math.min(Z.byteLength,X))}static assertView(Z){if(Z&&!ArrayBuffer.isView(Z))throw new Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class Pa{match(Z){return Z.length>=3&&Z[0]===255&&Z[1]===216&&Z[2]===255}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset+4),X,Y;while(J.byteLength){if(X=J.getUint16(0,!1),lN1(J,X),Y=J.getUint8(X+1),Y===192||Y===193||Y===194)return[J.getUint16(X+7,!1),J.getUint16(X+5,!1)];J=new DataView(Z.buffer,J.byteOffset+X+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class AB{match(Z){return Z.length>=8&&Z[0]===137&&Z[1]===80&&Z[2]===78&&Z[3]===71&&Z[4]===13&&Z[5]===10&&Z[6]===26&&Z[7]===10}getSize(Z){let J=new DataView(Z.buffer,Z.byteOffset);if(_6.decodeText(Z.slice(12,16))===AB.PNG_FRIED_CHUNK_NAME)return[J.getUint32(32,!1),J.getUint32(36,!1)];return[J.getUint32(16,!1),J.getUint32(20,!1)]}getChannels(Z){return 4}}AB.PNG_FRIED_CHUNK_NAME="CgBI";class N4{static registerFormat(Z,J){this.impls[Z]=J}static getMimeType(Z){for(let J in this.impls)if(this.impls[J].match(Z))return J;return null}static getSize(Z,J){if(!this.impls[J])return null;return this.impls[J].getSize(Z)}static getChannels(Z,J){if(!this.impls[J])return null;return this.impls[J].getChannels(Z)}static getVRAMByteLength(Z,J){if(!this.impls[J])return null;if(this.impls[J].getVRAMByteLength)return this.impls[J].getVRAMByteLength(Z);let X=0,Y=4,$=this.getSize(Z,J);if(!$)return null;while($[0]>1||$[1]>1)X+=$[0]*$[1]*Y,$[0]=Math.max(Math.floor($[0]/2),1),$[1]=Math.max(Math.floor($[1]/2),1);return X+=1*Y,X}static mimeTypeToExtension(Z){if(Z==="image/jpeg")return"jpg";return Z.split("/").pop()}static extensionToMimeType(Z){if(Z==="jpg")return"image/jpeg";if(!Z)return"";return`image/${Z}`}}N4.impls={"image/jpeg":new Pa,"image/png":new AB};function lN1(Z,J){if(J>Z.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return Z}class qV{static basename(Z){let J=Z.split(/[\\/]/).pop();return J.substring(0,J.lastIndexOf("."))}static extension(Z){if(Z.startsWith("data:image/")){let J=Z.match(/data:(image\/\w+)/)[1];return N4.mimeTypeToExtension(J)}else if(Z.startsWith("data:model/gltf+json"))return"gltf";else if(Z.startsWith("data:model/gltf-binary"))return"glb";else if(Z.startsWith("data:application/"))return"bin";return Z.split(/[\\/]/).pop().split(/[.]/).pop()}}function ja(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function TY(Z){if(ja(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(ja(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var VC,HC;(function(Z){Z[Z.SILENT=4]="SILENT",Z[Z.ERROR=3]="ERROR",Z[Z.WARN=2]="WARN",Z[Z.INFO=1]="INFO",Z[Z.DEBUG=0]="DEBUG"})(HC||(HC={}));class U7{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=U7.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=U7.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=U7.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=U7.Verbosity.ERROR)console.error(Z)}}VC=U7;U7.Verbosity=HC;U7.DEFAULT_INSTANCE=new VC(VC.Verbosity.INFO);function pN1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],V=Z[8],H=Z[9],F=Z[10],z=Z[11],q=Z[12],U=Z[13],L=Z[14],B=Z[15],w=J*K-X*Q,O=J*W-Y*Q,N=J*G-$*Q,R=X*W-Y*K,D=X*G-$*K,M=Y*G-$*W,C=V*U-H*q,T=V*L-F*q,E=V*B-z*q,x=H*L-F*U,v=H*B-z*U,S=F*B-z*L;return w*S-O*v+N*x+R*E-D*T+M*C}function iN1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],V=J[6],H=J[7],F=J[8],z=J[9],q=J[10],U=J[11],L=J[12],B=J[13],w=J[14],O=J[15],N=X[0],R=X[1],D=X[2],M=X[3];return Z[0]=N*Y+R*W+D*F+M*L,Z[1]=N*$+R*G+D*z+M*B,Z[2]=N*Q+R*V+D*q+M*w,Z[3]=N*K+R*H+D*U+M*O,N=X[4],R=X[5],D=X[6],M=X[7],Z[4]=N*Y+R*W+D*F+M*L,Z[5]=N*$+R*G+D*z+M*B,Z[6]=N*Q+R*V+D*q+M*w,Z[7]=N*K+R*H+D*U+M*O,N=X[8],R=X[9],D=X[10],M=X[11],Z[8]=N*Y+R*W+D*F+M*L,Z[9]=N*$+R*G+D*z+M*B,Z[10]=N*Q+R*V+D*q+M*w,Z[11]=N*K+R*H+D*U+M*O,N=X[12],R=X[13],D=X[14],M=X[15],Z[12]=N*Y+R*W+D*F+M*L,Z[13]=N*$+R*G+D*z+M*B,Z[14]=N*Q+R*V+D*q+M*w,Z[15]=N*K+R*H+D*U+M*O,Z}function nN1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],V=J[9],H=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,V,H),Z}function aN1(Z,J){var X=new WC(3);nN1(X,J);var Y=1/X[0],$=1/X[1],Q=1/X[2],K=J[0]*Y,W=J[1]*$,G=J[2]*Q,V=J[4]*Y,H=J[5]*$,F=J[6]*Q,z=J[8]*Y,q=J[9]*$,U=J[10]*Q,L=K+H+U,B=0;if(L>0)B=Math.sqrt(L+1)*2,Z[3]=0.25*B,Z[0]=(F-q)/B,Z[1]=(z-G)/B,Z[2]=(W-V)/B;else if(K>H&&K>U)B=Math.sqrt(1+K-H-U)*2,Z[3]=(F-q)/B,Z[0]=0.25*B,Z[1]=(W+V)/B,Z[2]=(z+G)/B;else if(H>U)B=Math.sqrt(1+H-K-U)*2,Z[3]=(z-G)/B,Z[0]=(W+V)/B,Z[1]=0.25*B,Z[2]=(F+q)/B;else B=Math.sqrt(1+U-K-H)*2,Z[3]=(W-V)/B,Z[0]=(z+G)/B,Z[1]=(F+q)/B,Z[2]=0.25*B;return Z}class K8{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let Y=0;Y<Z.length;Y++)if(Math.abs(Z[Y]-J[Y])>X)return!1;return!0}static clamp(Z,J,X){if(Z<J)return J;if(Z>X)return X;return Z}static decodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Z/65535;case 5121:return Z/255;case 5122:return Math.max(Z/32767,-1);case 5120:return Math.max(Z/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(K8.clamp(Z,0,1)*65535);case 5121:return Math.round(K8.clamp(Z,0,1)*255);case 5122:return Math.round(K8.clamp(Z,-1,1)*32767);case 5120:return Math.round(K8.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,Y){let $=QC([Z[0],Z[1],Z[2]]),Q=QC([Z[4],Z[5],Z[6]]),K=QC([Z[8],Z[9],Z[10]]);if(pN1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),V=1/$,H=1/Q,F=1/K;G[0]*=V,G[1]*=V,G[2]*=V,G[4]*=H,G[5]*=H,G[6]*=H,G[8]*=F,G[9]*=F,G[10]*=F,aN1(X,G),Y[0]=$,Y[1]=Q,Y[2]=K}static compose(Z,J,X,Y){let $=Y,Q=J[0],K=J[1],W=J[2],G=J[3],V=Q+Q,H=K+K,F=W+W,z=Q*V,q=Q*H,U=Q*F,L=K*H,B=K*F,w=W*F,O=G*V,N=G*H,R=G*F,D=X[0],M=X[1],C=X[2];return $[0]=(1-(L+w))*D,$[1]=(q+R)*D,$[2]=(U-N)*D,$[3]=0,$[4]=(q-R)*M,$[5]=(1-(z+w))*M,$[6]=(B+O)*M,$[7]=0,$[8]=(U+N)*C,$[9]=(B-O)*C,$[10]=(1-(z+L))*C,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function sN1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function oN1(Z,J){if(!!Z!==!!J)return!1;let X=Z.values(),Y=J.values();if(X.length!==Y.length)return!1;for(let $=0;$<X.length;$++){let Q=X[$],K=Y[$];if(Q.getChild()===K.getChild())continue;if(!Q.getChild().equals(K.getChild()))return!1}return!0}function rN1(Z,J){if(!!Z!==!!J)return!1;let X=Z.keys(),Y=J.keys();if(X.length!==Y.length)return!1;for(let $ of X){let Q=Z.get($),K=J.get($);if(!!Q!==!!K)return!1;let W=Q.getChild(),G=K.getChild();if(W===G)continue;if(!W.equals(G))return!1}return!0}function Da(Z,J){if(Z===J)return!0;if(!!Z!==!!J||!Z||!J)return!1;if(Z.length!==J.length)return!1;for(let X=0;X<Z.length;X++)if(Z[X]!==J[X])return!1;return!0}function Ca(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!TY(Z)||!TY(J))return Z===J;let X=Z,Y=J,$=0,Q=0,K;for(K in X)$++;for(K in Y)Q++;if($!==Q)return!1;for(K in X){let W=X[K],G=Y[K];if(_B(W)&&_B(G)){if(!Da(W,G))return!1}else if(TY(W)&&TY(G)){if(!Ca(W,G))return!1}else if(W!==G)return!1}return!0}function _B(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Oa="https://null.example";class qC{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return qV.basename(new URL(Z,Oa).pathname)}static extension(Z){return qV.extension(new URL(Z,Oa).pathname)}static resolve(Z,J){if(!this.isRelativePath(J))return J;let X=Z.split("/"),Y=J.split("/");X.pop();for(let $=0;$<Y.length;$++){if(Y[$]===".")continue;if(Y[$]==="..")X.pop();else X.push(Y[$])}return X.join("/")}static isAbsoluteURL(Z){return this.PROTOCOL_REGEXP.test(Z)}static isRelativePath(Z){return!/^(?:[a-zA-Z]+:)?\//.test(Z)}}qC.DEFAULT_INIT={};qC.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var xJ=(Z)=>Z,tN1=new Set;class xB extends GK{constructor(Z,J=""){super(Z);this[x0].name=J,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(Z,J){if(Array.isArray(J))J=J.slice();return super.set(Z,J)}getName(){return this.get("name")}setName(Z){return this.set("name",Z)}getExtras(){return this.get("extras")}setExtras(Z){return this.set("extras",Z)}clone(){return new this.constructor(this.graph).copy(this,xJ)}copy(Z,J=xJ){for(let X in this[x0]){let Y=this[x0][X];if(Y instanceof M5){if(!this[j4].has(X))Y.dispose()}else if(Y instanceof E6||Y instanceof D0)for(let $ of Y.values())$.dispose();else if(Y instanceof s1)for(let $ of Y.values())$.dispose()}for(let X in Z[x0]){let Y=this[x0][X],$=Z[x0][X];if($ instanceof M5)if(this[j4].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof D0||$ instanceof E6)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof s1)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(TY($))this[x0][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[x0][X]=$.slice();else this[x0][X]=$}return this}equals(Z,J=tN1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[x0]){if(J.has(X))continue;let Y=this[x0][X],$=Z[x0][X];if(Y instanceof M5||$ instanceof M5){if(!sN1(Y,$))return!1}else if(Y instanceof D0||$ instanceof D0||Y instanceof E6||$ instanceof E6){if(!oN1(Y,$))return!1}else if(Y instanceof s1||$ instanceof s1){if(!rN1(Y,$))return!1}else if(TY(Y)||TY($)){if(!Ca(Y,$))return!1}else if(_B(Y)||_B($)){if(!Da(Y,$))return!1}else if(Y!==$)return!1}return!0}detach(){return this.graph.disconnectParents(this,(Z)=>Z.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}}class v6 extends xB{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new s1})}getExtension(Z){return this.getRefMap("extensions",Z)}setExtension(Z,J){if(J)J._validateParent(this);return this.setRefMap("extensions",Z,J)}listExtensions(){return this.listRefMapValues("extensions")}}class N0 extends v6{init(){this.propertyType=s.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:N0.Type.SCALAR,componentType:N0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case N0.Type.SCALAR:return 1;case N0.Type.VEC2:return 2;case N0.Type.VEC3:return 3;case N0.Type.VEC4:return 4;case N0.Type.MAT2:return 4;case N0.Type.MAT3:return 9;case N0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case N0.ComponentType.BYTE:return 1;case N0.ComponentType.UNSIGNED_BYTE:return 1;case N0.ComponentType.SHORT:return 2;case N0.ComponentType.UNSIGNED_SHORT:return 2;case N0.ComponentType.UNSIGNED_INT:return 4;case N0.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMin(Z),J)for(let $=0;$<X;$++)Z[$]=K8.decodeNormalizedInt(Z[$],Y);return Z}getMin(Z){let J=this.getArray(),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+Q];if(Number.isFinite(K))Z[Q]=Math.min(Z[Q],K)}return Z}getMaxNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),Y=this.getComponentType();if(this.getMax(Z),J)for(let $=0;$<X;$++)Z[$]=K8.decodeNormalizedInt(Z[$],Y);return Z}getMax(Z){let J=this.get("array"),X=this.getCount(),Y=this.getElementSize();for(let $=0;$<Y;$++)Z[$]=-1/0;for(let $=0;$<X*Y;$+=Y)for(let Q=0;Q<Y;Q++){let K=J[$+Q];if(Number.isFinite(K))Z[Q]=Math.max(Z[Q],K)}return Z}getCount(){let Z=this.get("array");return Z?Z.length/this.getElementSize():0}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getElementSize(){return N0.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(Z){return this.set("normalized",Z)}getScalar(Z){let J=this.getElementSize(),X=this.getComponentType(),Y=this.getArray();if(this.getNormalized())return K8.decodeNormalizedInt(Y[Z*J],X);return Y[Z*J]}setScalar(Z,J){let X=this.getElementSize(),Y=this.getComponentType(),$=this.getArray();if(this.getNormalized())$[Z*X]=K8.encodeNormalizedInt(J,Y);else $[Z*X]=J;return this}getElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)J[K]=K8.decodeNormalizedInt(Q[Z*Y+K],$);else J[K]=Q[Z*Y+K];return J}setElement(Z,J){let X=this.getNormalized(),Y=this.getElementSize(),$=this.getComponentType(),Q=this.getArray();for(let K=0;K<Y;K++)if(X)Q[Z*Y+K]=K8.encodeNormalizedInt(J[K],$);else Q[Z*Y+K]=J[K];return this}getSparse(){return this.get("sparse")}setSparse(Z){return this.set("sparse",Z)}getBuffer(){return this.getRef("buffer")}setBuffer(Z){return this.setRef("buffer",Z)}getArray(){return this.get("array")}setArray(Z){return this.set("componentType",Z?eN1(Z):N0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}N0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};N0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function eN1(Z){switch(Z.constructor){case Float32Array:return N0.ComponentType.FLOAT;case Uint32Array:return N0.ComponentType.UNSIGNED_INT;case Uint16Array:return N0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return N0.ComponentType.UNSIGNED_BYTE;case Int16Array:return N0.ComponentType.SHORT;case Int8Array:return N0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class UC extends v6{init(){this.propertyType=s.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new D0,samplers:new D0})}addChannel(Z){return this.addRef("channels",Z)}removeChannel(Z){return this.removeRef("channels",Z)}listChannels(){return this.listRefs("channels")}addSampler(Z){return this.addRef("samplers",Z)}removeSampler(Z){return this.removeRef("samplers",Z)}listSamplers(){return this.listRefs("samplers")}}class LV extends v6{init(){this.propertyType=s.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(Z){return this.set("targetPath",Z)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(Z){return this.setRef("targetNode",Z)}getSampler(){return this.getRef("sampler")}setSampler(Z){return this.setRef("sampler",Z)}}LV.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class RK extends v6{init(){this.propertyType=s.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:RK.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(Z){return this.set("interpolation",Z)}getInput(){return this.getRef("input")}setInput(Z){return this.setRef("input",Z,{usage:o5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:o5.OTHER})}}RK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class LC extends v6{init(){this.propertyType=s.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class BV extends v6{init(){this.propertyType=s.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:BV.Type.PERSPECTIVE,znear:0.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getZNear(){return this.get("znear")}setZNear(Z){return this.set("znear",Z)}getZFar(){return this.get("zfar")}setZFar(Z){return this.set("zfar",Z)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(Z){return this.set("aspectRatio",Z)}getYFov(){return this.get("yfov")}setYFov(Z){return this.set("yfov",Z)}getXMag(){return this.get("xmag")}setXMag(Z){return this.set("xmag",Z)}getYMag(){return this.get("ymag")}setYMag(Z){return this.set("ymag",Z)}}BV.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class i1 extends xB{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}i1.EXTENSION_NAME=void 0;class D1 extends v6{init(){this.propertyType=s.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:D1.WrapMode.REPEAT,wrapT:D1.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}getMagFilter(){return this.get("magFilter")}setMagFilter(Z){return this.set("magFilter",Z)}getMinFilter(){return this.get("minFilter")}setMinFilter(Z){return this.set("minFilter",Z)}getWrapS(){return this.get("wrapS")}setWrapS(Z){return this.set("wrapS",Z)}getWrapT(){return this.get("wrapT")}setWrapT(Z){return this.set("wrapT",Z)}}D1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};D1.MagFilter={NEAREST:9728,LINEAR:9729};D1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:EB,G:kB,B:IB,A:ZR1}=r5;class wV extends v6{init(){this.propertyType=s.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:wV.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new D1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new D1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new D1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new D1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new D1(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(Z){return this.set("doubleSided",Z)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(Z){let J=this.get("baseColorFactor").slice();return J[3]=Z,this.set("baseColorFactor",J)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(Z){return this.set("alphaMode",Z)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(Z){return this.set("alphaCutoff",Z)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(Z){return this.set("baseColorFactor",Z)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(Z){return this.setRef("baseColorTexture",Z,{channels:EB|kB|IB|ZR1,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(Z){return this.set("emissiveFactor",Z)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(Z){return this.setRef("emissiveTexture",Z,{channels:EB|kB|IB,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(Z){return this.set("normalScale",Z)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(Z){return this.setRef("normalTexture",Z,{channels:EB|kB|IB})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(Z){return this.set("occlusionStrength",Z)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(Z){return this.setRef("occlusionTexture",Z,{channels:EB})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(Z){return this.set("roughnessFactor",Z)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(Z){return this.set("metallicFactor",Z)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(Z){return this.setRef("metallicRoughnessTexture",Z,{channels:kB|IB})}}wV.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class BC extends v6{init(){this.propertyType=s.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new D0})}addPrimitive(Z){return this.addRef("primitives",Z)}removePrimitive(Z){return this.removeRef("primitives",Z)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}}class wC extends v6{init(){this.propertyType=s.NODE}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new D0})}copy(Z,J=xJ){if(J===xJ)throw new Error("Node cannot be copied.");return super.copy(Z,J)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(Z){return this.set("translation",Z)}setRotation(Z){return this.set("rotation",Z)}setScale(Z){return this.set("scale",Z)}getMatrix(){return K8.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),Y=this.get("scale").slice();return K8.decompose(Z,J,X,Y),this.set("translation",J).set("rotation",X).set("scale",Y)}getWorldTranslation(){let Z=[0,0,0];return K8.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return K8.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return K8.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],Z),Z}getWorldMatrix(){let Z=[];for(let Y=this;Y!=null;Y=Y.getParentNode())Z.push(Y);let J,X=Z.pop().getMatrix();while(J=Z.pop())iN1(X,X,J.getMatrix());return X}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);for(let X of Z.listParents())if(X.propertyType===s.SCENE)X.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}getParentNode(){for(let Z of this.listParents())if(Z.propertyType===s.NODE)return Z;return null}getMesh(){return this.getRef("mesh")}setMesh(Z){return this.setRef("mesh",Z)}getCamera(){return this.getRef("camera")}setCamera(Z){return this.setRef("camera",Z)}getSkin(){return this.getRef("skin")}setSkin(Z){return this.setRef("skin",Z)}getWeights(){return this.get("weights")}setWeights(Z){return this.set("weights",Z)}traverse(Z){Z(this);for(let J of this.listChildren())J.traverse(Z);return this}}class hJ extends v6{init(){this.propertyType=s.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:hJ.Mode.TRIANGLES,material:null,indices:null,attributes:new s1,targets:new D0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:o5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:o5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(Z){return this.setRef("material",Z)}getMode(){return this.get("mode")}setMode(Z){return this.set("mode",Z)}listTargets(){return this.listRefs("targets")}addTarget(Z){return this.addRef("targets",Z)}removeTarget(Z){return this.removeRef("targets",Z)}}hJ.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class Ta extends xB{init(){this.propertyType=s.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new s1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:o5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function vB(){return vB=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},vB.apply(null,arguments)}class jC extends v6{init(){this.propertyType=s.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new D0})}copy(Z,J=xJ){if(J===xJ)throw new Error("Scene cannot be copied.");return super.copy(Z,J)}addChild(Z){let J=Z.getParentNode();if(J)J.removeChild(Z);return this.addRef("children",Z)}removeChild(Z){return this.removeRef("children",Z)}listChildren(){return this.listRefs("children")}traverse(Z){for(let J of this.listChildren())J.traverse(Z);return this}}class OC extends v6{init(){this.propertyType=s.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new D0})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(Z){return this.setRef("skeleton",Z)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(Z){return this.setRef("inverseBindMatrices",Z,{usage:o5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class NC extends v6{init(){this.propertyType=s.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||N4.extensionToMimeType(qV.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=N4.extensionToMimeType(qV.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",_6.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return N4.getSize(Z,this.getMimeType())}}class hB extends v6{init(){this.propertyType=s.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${mN1}`,version:"2.0"},defaultScene:null,accessors:new D0,animations:new D0,buffers:new D0,cameras:new D0,materials:new D0,meshes:new D0,nodes:new D0,scenes:new D0,skins:new D0,textures:new D0})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(Z,J=xJ){if(J===xJ)throw new Error("Root cannot be copied.");this.set("asset",vB({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(vB({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let Y=Z.getExtension(X);this.setExtension(X,J(Y))}return this}_addChildOfRoot(Z){if(Z instanceof jC)this.addRef("scenes",Z);else if(Z instanceof wC)this.addRef("nodes",Z);else if(Z instanceof BV)this.addRef("cameras",Z);else if(Z instanceof OC)this.addRef("skins",Z);else if(Z instanceof BC)this.addRef("meshes",Z);else if(Z instanceof wV)this.addRef("materials",Z);else if(Z instanceof NC)this.addRef("textures",Z);else if(Z instanceof UC)this.addRef("animations",Z);else if(Z instanceof N0)this.addRef("accessors",Z);else if(Z instanceof LC)this.addRef("buffers",Z);return this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter((Z)=>Z.isRequired())}_enableExtension(Z){return this._extensions.add(Z),this}_disableExtension(Z){return this._extensions.delete(Z),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(Z){return this.setRef("defaultScene",Z)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class SB{static fromGraph(Z){return SB._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new WK,this._root=new hB(this._graph),this._logger=U7.DEFAULT_INSTANCE,SB._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(Z){return this._logger=Z,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...Z){let J=Z.map((X)=>X.name);for(let X of Z)await X(this,{stack:J});return this}createExtension(Z){let J=Z.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find((Y)=>Y.extensionName===J)||new Z(this)}createScene(Z=""){return new jC(this._graph,Z)}createNode(Z=""){return new wC(this._graph,Z)}createCamera(Z=""){return new BV(this._graph,Z)}createSkin(Z=""){return new OC(this._graph,Z)}createMesh(Z=""){return new BC(this._graph,Z)}createPrimitive(){return new hJ(this._graph)}createPrimitiveTarget(Z=""){return new Ta(this._graph,Z)}createMaterial(Z=""){return new wV(this._graph,Z)}createTexture(Z=""){return new NC(this._graph,Z)}createAnimation(Z=""){return new UC(this._graph,Z)}createAnimationChannel(Z=""){return new LV(this._graph,Z)}createAnimationSampler(Z=""){return new RK(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new N0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new LC(this._graph,Z)}}SB._GRAPH_DOCUMENTS=new WeakMap;class E1{constructor(Z){this.extensionName="",this.prereadTypes=[],this.prewriteTypes=[],this.readDependencies=[],this.writeDependencies=[],this.document=void 0,this.required=!1,this.properties=new Set,this._listener=void 0,this.document=Z,Z.getRoot()._enableExtension(this),this._listener=(X)=>{let Y=X,$=Y.target;if($ instanceof i1&&$.extensionName===this.extensionName){if(Y.type==="node:create")this._addExtensionProperty($);if(Y.type==="node:dispose")this._removeExtensionProperty($)}};let J=Z.getGraph();J.addEventListener("node:create",this._listener),J.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);let Z=this.document.getGraph();Z.removeEventListener("node:create",this._listener),Z.removeEventListener("node:dispose",this._listener);for(let J of this.properties)J.dispose()}static register(){}isRequired(){return this.required}setRequired(Z){return this.required=Z,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(Z){return this.properties.add(Z),this}_removeExtensionProperty(Z){return this.properties.delete(Z),this}install(Z,J){return this}preread(Z,J){return this}prewrite(Z,J){return this}}E1.EXTENSION_NAME=void 0;var xT6={logger:U7.DEFAULT_INSTANCE,extensions:[],dependencies:{}},hT6=new Set([s.BUFFER,s.TEXTURE,s.MATERIAL,s.MESH,s.PRIMITIVE,s.NODE,s.SCENE]);var UV;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(UV||(UV={}));class fJ{constructor(Z,J,X){this._doc=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this._accessorUsageMap=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this._doc=Z,this.jsonDoc=J,this.options=X;let Y=Z.getRoot(),$=Y.listBuffers().length,Q=Y.listTextures().length;this.bufferURIGenerator=new zC($>1,()=>X.basename||"buffer"),this.imageURIGenerator=new zC(Q>1,(K)=>JR1(Z,K)||X.basename||"texture"),this.logger=Z.getLogger()}createTextureInfoDef(Z,J){let X={magFilter:J.getMagFilter()||void 0,minFilter:J.getMinFilter()||void 0,wrapS:J.getWrapS(),wrapT:J.getWrapT()},Y=JSON.stringify(X);if(!this.samplerDefIndexMap.has(Y))this.samplerDefIndexMap.set(Y,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(X);let $={source:this.imageIndexMap.get(Z),sampler:this.samplerDefIndexMap.get(Y)},Q=JSON.stringify($);if(!this.textureDefIndexMap.has(Q))this.textureDefIndexMap.set(Q,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push($);let K={index:this.textureDefIndexMap.get(Q)};if(J.getTexCoord()!==0)K.texCoord=J.getTexCoord();if(Object.keys(J.getExtras()).length>0)K.extras=J.getExtras();return this.textureInfoDefMap.set(J,K),K}createPropertyDef(Z){let J={};if(Z.getName())J.name=Z.getName();if(Object.keys(Z.getExtras()).length>0)J.extras=Z.getExtras();return J}createAccessorDef(Z){let J=this.createPropertyDef(Z);if(J.type=Z.getType(),J.componentType=Z.getComponentType(),J.count=Z.getCount(),this._doc.getGraph().listParentEdges(Z).some((Y)=>Y.getName()==="attributes"&&Y.getAttributes().key==="POSITION"||Y.getName()==="input"))J.max=Z.getMax([]).map(Math.fround),J.min=Z.getMin([]).map(Math.fround);if(Z.getNormalized())J.normalized=Z.getNormalized();return J}createImageData(Z,J,X){if(this.options.format===KC.GLB)this.imageBufferViews.push(J),Z.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:J.byteLength});else{let Y=N4.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,Y),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let Y=this.jsonDoc.resources;if(!(Z in Y)){Y[Z]=J;return}if(J===Y[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let $=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn($);return}throw new Error($)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return o5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:Y}=X.getAttributes();if(Y)return Y;if(X.getParent().propertyType!==s.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return o5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw new Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}fJ.BufferViewTarget=UV;fJ.BufferViewUsage=o5;fJ.USAGE_TO_TARGET={[o5.ARRAY_BUFFER]:UV.ARRAY_BUFFER,[o5.ELEMENT_ARRAY_BUFFER]:UV.ELEMENT_ARRAY_BUFFER};class zC{constructor(Z,J){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=Z,this.basename=J}createURI(Z,J){if(Z.getURI())return Z.getURI();else if(!this.multiple)return`${this.basename(Z)}.${J}`;else{let X=this.basename(Z);return this.counter[X]=this.counter[X]||1,`${X}_${this.counter[X]++}.${J}`}}}function JR1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{UNSIGNED_INT:fT6,UNSIGNED_SHORT:yT6,UNSIGNED_BYTE:bT6}=N0.ComponentType,gT6=new Set([s.ACCESSOR,s.BUFFER,s.MATERIAL,s.MESH]);var Na;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(Na||(Na={}));var ka=163,Ia=166;function XR1(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}class MK{constructor(Z,J,X,Y){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(Z.buffer,Z.byteOffset+J,X),this._littleEndian=Y,this._offset=0}_nextUint8(){let Z=this._dataView.getUint8(this._offset);return this._offset+=1,Z}_nextUint16(){let Z=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,Z}_nextUint32(){let Z=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,Z}_nextUint64(){let Z=this._dataView.getUint32(this._offset,this._littleEndian),J=this._dataView.getUint32(this._offset+4,this._littleEndian),X=Z+4294967296*J;return this._offset+=8,X}_nextInt32(){let Z=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,Z}_nextUint8Array(Z){let J=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,Z);return this._offset+=Z,J}_skip(Z){return this._offset+=Z,this}_scan(Z,J=0){let X=this._offset,Y=0;while(this._dataView.getUint8(this._offset)!==J&&Y<Z)Y++,this._offset++;if(Y<Z)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+X,Y)}}var dT6=new Uint8Array([0]),t6=[171,75,84,88,32,50,48,187,13,10,26,10];function Ea(Z){return new TextDecoder().decode(Z)}function fB(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,t6.length);if(J[0]!==t6[0]||J[1]!==t6[1]||J[2]!==t6[2]||J[3]!==t6[3]||J[4]!==t6[4]||J[5]!==t6[5]||J[6]!==t6[6]||J[7]!==t6[7]||J[8]!==t6[8]||J[9]!==t6[9]||J[10]!==t6[10]||J[11]!==t6[11])throw new Error("Missing KTX 2.0 identifier.");let X=XR1(),Y=17*Uint32Array.BYTES_PER_ELEMENT,$=new MK(Z,t6.length,Y,!0);X.vkFormat=$._nextUint32(),X.typeSize=$._nextUint32(),X.pixelWidth=$._nextUint32(),X.pixelHeight=$._nextUint32(),X.pixelDepth=$._nextUint32(),X.layerCount=$._nextUint32(),X.faceCount=$._nextUint32();let Q=$._nextUint32();X.supercompressionScheme=$._nextUint32();let K=$._nextUint32(),W=$._nextUint32(),G=$._nextUint32(),V=$._nextUint32(),H=$._nextUint64(),F=$._nextUint64(),z=Q*3*8,q=new MK(Z,t6.length+Y,z,!0);for(let F6=0;F6<Q;F6++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+q._nextUint64(),q._nextUint64()),uncompressedByteLength:q._nextUint64()});let U=new MK(Z,K,W,!0);U._skip(4);let L=U._nextUint16(),B=U._nextUint16(),w=U._nextUint16(),O=U._nextUint16(),N=U._nextUint8(),R=U._nextUint8(),D=U._nextUint8(),M=U._nextUint8(),C=[U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8()],T=[U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8()],x={vendorId:L,descriptorType:B,versionNumber:w,colorModel:N,colorPrimaries:R,transferFunction:D,flags:M,texelBlockDimension:C,bytesPlane:T,samples:[]},v=6,S=4,I=(O/4-v)/S;for(let F6=0;F6<I;F6++){let XZ={bitOffset:U._nextUint16(),bitLength:U._nextUint8(),channelType:U._nextUint8(),samplePosition:[U._nextUint8(),U._nextUint8(),U._nextUint8(),U._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(XZ.channelType&64)XZ.sampleLower=U._nextInt32(),XZ.sampleUpper=U._nextInt32();else XZ.sampleLower=U._nextUint32(),XZ.sampleUpper=U._nextUint32();x.samples[F6]=XZ}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(x);let _=new MK(Z,G,V,!0);while(_._offset<V){let F6=_._nextUint32(),XZ=_._scan(F6),Mq=Ea(XZ);if(X.keyValue[Mq]=_._nextUint8Array(F6-XZ.byteLength-1),Mq.match(/^ktx/i)){let ry=Ea(X.keyValue[Mq]);X.keyValue[Mq]=ry.substring(0,ry.lastIndexOf("\x00"))}let KG1=F6%4?4-F6%4:0;_._skip(KG1)}if(F<=0)return X;let y=new MK(Z,H,F,!0),p=y._nextUint16(),n=y._nextUint16(),o=y._nextUint32(),X0=y._nextUint32(),Q0=y._nextUint32(),E0=y._nextUint32(),k0=[];for(let F6=0;F6<Q;F6++)k0.push({imageFlags:y._nextUint32(),rgbSliceByteOffset:y._nextUint32(),rgbSliceByteLength:y._nextUint32(),alphaSliceByteOffset:y._nextUint32(),alphaSliceByteLength:y._nextUint32()});let a0=H+y._offset,k8=a0+o,n1=k8+X0,t4=n1+Q0,W4=new Uint8Array(Z.buffer,Z.byteOffset+a0,o),CQ=new Uint8Array(Z.buffer,Z.byteOffset+k8,X0),TQ=new Uint8Array(Z.buffer,Z.byteOffset+n1,Q0),ZY=new Uint8Array(Z.buffer,Z.byteOffset+t4,E0);return X.globalData={endpointCount:p,selectorCount:n,imageDescs:k0,endpointsData:W4,selectorsData:CQ,tablesData:TQ,extendedData:ZY},X}var CC="EXT_mesh_gpu_instancing",MC="EXT_meshopt_compression",YR1="EXT_texture_webp",$R1="EXT_texture_avif",ca="KHR_draco_mesh_compression",TC="KHR_lights_punctual",EC="KHR_materials_anisotropy",kC="KHR_materials_clearcoat",IC="KHR_materials_diffuse_transmission",_C="KHR_materials_dispersion",vC="KHR_materials_emissive_strength",SC="KHR_materials_ior",AC="KHR_materials_iridescence",xC="KHR_materials_pbrSpecularGlossiness",hC="KHR_materials_sheen",fC="KHR_materials_specular",yC="KHR_materials_transmission",bC="KHR_materials_unlit",gC="KHR_materials_volume",uY="KHR_materials_variants",QR1="KHR_mesh_quantization",KR1="KHR_texture_basisu",mC="KHR_texture_transform",yB="KHR_xmp_json_ld",PC="INSTANCE_ATTRIBUTE";class uC extends i1{init(){this.extensionName=CC,this.propertyType="InstancedMesh",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new s1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:PC})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}uC.EXTENSION_NAME=CC;var EY=CC;class mB extends E1{constructor(...Z){super(...Z);this.extensionName=EY,this.provideTypes=[s.NODE],this.prewriteTypes=[s.ACCESSOR]}createInstancedMesh(){return new uC(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach((Y,$)=>{if(!Y.extensions||!Y.extensions[EY])return;let Q=Y.extensions[EY],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[$].setExtension(EY,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(PC);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,PC);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let Y=X.getExtension(EY);if(Y){let $=Z.nodeIndexMap.get(X),Q=J.json.nodes[$],K={attributes:{}};Y.listSemantics().forEach((W)=>{let G=Y.getAttribute(W);K.attributes[W]=Z.accessorIndexMap.get(G)}),Q.extensions=Q.extensions||{},Q.extensions[EY]=K}}),this}}mB.EXTENSION_NAME=EY;function NZ(){return NZ=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},NZ.apply(null,arguments)}var RV;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(RV||(RV={}));var DK;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(DK||(DK={}));var W8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})(W8||(W8={}));var{BYTE:WR1,SHORT:_a,FLOAT:GR1}=N0.ComponentType,{encodeNormalizedInt:va,decodeNormalizedInt:DC}=K8;function VR1(Z,J,X,Y){let{filter:$,bits:Q}=Y,K={array:Z.getArray(),byteStride:Z.getElementSize()*Z.getComponentSize(),componentType:Z.getComponentType(),normalized:Z.getNormalized()};if(X!==DK.ATTRIBUTES)return K;if($!==W8.NONE){let W=Z.getNormalized()?HR1(Z):new Float32Array(K.array);switch($){case W8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=GR1,K.normalized=!1,K.array=J.encodeFilterExp(W,Z.getCount(),K.byteStride,Q);break;case W8.OCTAHEDRAL:K.byteStride=Q>8?8:4,K.componentType=Q>8?_a:WR1,K.normalized=!0,W=Z.getElementSize()===3?FR1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case W8.QUATERNION:K.byteStride=8,K.componentType=_a,K.normalized=!0,K.array=J.encodeFilterQuat(W,Z.getCount(),K.byteStride,Q);break;default:throw new Error("Invalid filter.")}if(K.min=Z.getMin([]),K.max=Z.getMax([]),Z.getNormalized())K.min=K.min.map((G)=>DC(G,Z.getComponentType())),K.max=K.max.map((G)=>DC(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>va(G,K.componentType)),K.max=K.max.map((G)=>va(G,K.componentType))}else if(K.byteStride%4)K.array=zR1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function HR1(Z){let J=Z.getComponentType(),X=Z.getArray(),Y=new Float32Array(X.length);for(let $=0;$<X.length;$++)Y[$]=DC(X[$],J);return Y}function zR1(Z,J){let Y=_6.padNumber(Z.BYTES_PER_ELEMENT*J)/Z.BYTES_PER_ELEMENT,$=Z.length/J,Q=new Z.constructor($*Y);for(let K=0;K*J<Z.length;K++)for(let W=0;W<J;W++)Q[K*Y+W]=Z[K*J+W];return Q}function FR1(Z){let J=new Float32Array(Z.length*4/3);for(let X=0,Y=Z.length/3;X<Y;X++)J[X*4]=Z[X*3],J[X*4+1]=Z[X*3+1],J[X*4+2]=Z[X*3+2];return J}function qR1(Z,J){if(J===fJ.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some((Y)=>{return Y instanceof hJ&&Y.getMode()===hJ.Mode.TRIANGLES})?DK.TRIANGLES:DK.INDICES;return DK.ATTRIBUTES}function UR1(Z,J){let X=J.getGraph().listParentEdges(Z).filter((Y)=>!(Y.getParent()instanceof hB));for(let Y of X){let $=Y.getName(),Q=Y.getAttributes().key||"",K=Y.getParent().propertyType===s.PRIMITIVE_TARGET;if($==="indices")return{filter:W8.NONE};if($==="attributes"){if(Q==="POSITION")return{filter:W8.NONE};if(Q==="TEXCOORD_0")return{filter:W8.NONE};if(Q.startsWith("JOINTS_"))return{filter:W8.NONE};if(Q.startsWith("WEIGHTS_"))return{filter:W8.NONE};if(Q==="NORMAL"||Q==="TANGENT")return K?{filter:W8.NONE}:{filter:W8.OCTAHEDRAL,bits:8}}if($==="output"){let W=la(Z);if(W==="rotation")return{filter:W8.QUATERNION,bits:16};if(W==="translation")return{filter:W8.EXPONENTIAL,bits:12};if(W==="scale")return{filter:W8.EXPONENTIAL,bits:12};return{filter:W8.NONE}}if($==="input")return{filter:W8.NONE};if($==="inverseBindMatrices")return{filter:W8.NONE}}return{filter:W8.NONE}}function la(Z){for(let J of Z.listParents()){if(!(J instanceof RK))continue;for(let X of J.listParents()){if(!(X instanceof LV))continue;return X.getTargetPath()}}return null}function LR1(Z){if(!Z.extensions||!Z.extensions[MC])return!1;return!!Z.extensions[MC].fallback}var e6=MC,Sa={method:RV.QUANTIZE};class PV extends E1{constructor(...Z){super(...Z);this.extensionName=e6,this.prereadTypes=[s.BUFFER,s.PRIMITIVE],this.prewriteTypes=[s.BUFFER,s.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=Sa,this._encoderFallbackBuffer=null,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={}}install(Z,J){if(Z==="meshopt.decoder")this._decoder=J;if(Z==="meshopt.encoder")this._encoder=J;return this}setEncoderOptions(Z){return this._encoderOptions=NZ({},Sa,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${e6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${e6}]: Missing WASM support.`)}if(J===s.BUFFER)this._prereadBuffers(Z);else if(J===s.PRIMITIVE)this._prereadPrimitives(Z);return this}_prereadBuffers(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach((Y,$)=>{if(!Y.extensions||!Y.extensions[e6])return;let Q=Y.extensions[e6],K=Q.byteOffset||0,W=Q.byteLength||0,G=Q.count,V=Q.byteStride,H=new Uint8Array(G*V),F=J.json.buffers[Q.buffer],z=F.uri?J.resources[F.uri]:J.resources[FC],q=_6.toView(z,K,W);this._decoder.decodeGltfBuffer(H,G,V,q,Q.mode,Q.filter),Z.bufferViews[$]=H})}_prereadPrimitives(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach((Y)=>{if(!Y.extensions||!Y.extensions[e6])return;let $=Y.extensions[e6],Q=Z.buffers[$.buffer],K=Z.buffers[Y.buffer],W=J.json.buffers[Y.buffer];if(LR1(W))this._decoderFallbackBufferMap.set(K,Q)})}read(Z){if(!this.isRequired())return this;for(let[J,X]of this._decoderFallbackBufferMap){for(let Y of J.listParents())if(Y instanceof N0)Y.swap(J,X);J.dispose()}return this}prewrite(Z,J){if(J===s.ACCESSOR)this._prewriteAccessors(Z);else if(J===s.BUFFER)this._prewriteBuffers(Z);return this}_prewriteAccessors(Z){let J=Z.jsonDoc.json,X=this._encoder,Y=this._encoderOptions,$=this.document.getGraph(),Q=this.document.createBuffer(),K=this.document.getRoot().listBuffers().indexOf(Q),W=1,G=new Map,V=(H)=>{for(let F of $.listParents(H)){if(F.propertyType===s.ROOT)continue;let z=G.get(H);if(z===void 0)G.set(H,z=W++);return z}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let H of this.document.getRoot().listAccessors()){if(la(H)==="weights")continue;if(H.getSparse())continue;let F=Z.getAccessorUsage(H),z=Z.accessorUsageGroupedByParent.has(F)?V(H):null,q=qR1(H,F),U=Y.method===RV.FILTER?UR1(H,this.document):{filter:W8.NONE},L=VR1(H,X,q,U),{array:B,byteStride:w}=L,O=H.getBuffer();if(!O)throw new Error(`${e6}: Missing buffer for accessor.`);let N=this.document.getRoot().listBuffers().indexOf(O),R=[F,z,q,U.filter,w,N].join(":"),D=this._encoderBufferViews[R],M=this._encoderBufferViewData[R],C=this._encoderBufferViewAccessors[R];if(!D||!M)C=this._encoderBufferViewAccessors[R]=[],M=this._encoderBufferViewData[R]=[],D=this._encoderBufferViews[R]={buffer:K,target:fJ.USAGE_TO_TARGET[F],byteOffset:0,byteLength:0,byteStride:F===fJ.BufferViewUsage.ARRAY_BUFFER?w:void 0,extensions:{[e6]:{buffer:N,byteOffset:0,byteLength:0,mode:q,filter:U.filter!==W8.NONE?U.filter:void 0,byteStride:w,count:0}}};let T=Z.createAccessorDef(H);if(T.componentType=L.componentType,T.normalized=L.normalized,T.byteOffset=D.byteLength,T.min&&L.min)T.min=L.min;if(T.max&&L.max)T.max=L.max;Z.accessorIndexMap.set(H,J.accessors.length),J.accessors.push(T),C.push(T),M.push(new Uint8Array(B.buffer,B.byteOffset,B.byteLength)),D.byteLength+=B.byteLength,D.extensions.EXT_meshopt_compression.count+=H.getCount()}}_prewriteBuffers(Z){let J=this._encoder;for(let X in this._encoderBufferViews){let Y=this._encoderBufferViews[X],$=this._encoderBufferViewData[X],Q=this.document.getRoot().listBuffers()[Y.extensions[e6].buffer],K=Z.otherBufferViews.get(Q)||[],{count:W,byteStride:G,mode:V}=Y.extensions[e6],H=_6.concat($),F=J.encodeGltfBuffer(H,W,G,V),z=_6.pad(F);Y.extensions[e6].byteLength=F.byteLength,$.length=0,$.push(z),K.push(z),Z.otherBufferViews.set(Q,K)}}write(Z){let J=0;for(let Q in this._encoderBufferViews){let K=this._encoderBufferViews[Q],W=this._encoderBufferViewData[Q][0],G=Z.otherBufferViewsIndexMap.get(W),V=this._encoderBufferViewAccessors[Q];for(let q of V)q.bufferView=G;let H=Z.jsonDoc.json.bufferViews[G],F=H.byteOffset||0;Object.assign(H,K),H.byteOffset=J;let z=H.extensions[e6];z.byteOffset=F,J+=_6.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,Y=Z.bufferIndexMap.get(X),$=Z.jsonDoc.json.buffers[Y];return $.byteLength=J,$.extensions={[e6]:{fallback:!0}},X.dispose(),this}}PV.EXTENSION_NAME=e6;PV.EncoderMethod=RV;var jV=$R1;class pa{match(Z){return Z.length>=12&&_6.decodeText(Z.slice(4,12))==="ftypavif"}getSize(Z){if(!this.match(Z))return null;let J=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),X=Aa(J,0);if(!X)return null;let Y=X.end;while(X=Aa(J,Y))if(X.type==="meta")Y=X.start+4;else if(X.type==="iprp"||X.type==="ipco")Y=X.start;else if(X.type==="ispe")return[J.getUint32(X.start+4),J.getUint32(X.start+8)];else if(X.type==="mdat")break;else Y=X.end;return null}getChannels(Z){return 4}}class uB extends E1{constructor(...Z){super(...Z);this.extensionName=jV,this.prereadTypes=[s.TEXTURE]}static register(){N4.registerFormat("image/avif",new pa)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[jV])X.source=X.extensions[jV].source}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/avif"){let Y=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===Y)Q.extensions=Q.extensions||{},Q.extensions[jV]={source:Q.source},delete Q.source})}}),this}}uB.EXTENSION_NAME=jV;function Aa(Z,J){if(Z.byteLength<4+J)return null;let X=Z.getUint32(J);if(Z.byteLength<X+J||X<8)return null;return{type:_6.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}var OV=YR1;class ia{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=_6.decodeText(Z.slice(0,4)),X=_6.decodeText(Z.slice(8,12));if(J!=="RIFF"||X!=="WEBP")return null;let Y=new DataView(Z.buffer,Z.byteOffset),$=12;while($<Y.byteLength){let Q=_6.decodeText(new Uint8Array([Y.getUint8($),Y.getUint8($+1),Y.getUint8($+2),Y.getUint8($+3)])),K=Y.getUint32($+4,!0);if(Q==="VP8 "){let W=Y.getInt16($+14,!0)&16383,G=Y.getInt16($+16,!0)&16383;return[W,G]}else if(Q==="VP8L"){let W=Y.getUint8($+9),G=Y.getUint8($+10),V=Y.getUint8($+11),H=Y.getUint8($+12),F=1+((G&63)<<8|W),z=1+((H&15)<<10|V<<2|(G&192)>>6);return[F,z]}$+=8+K+K%2}return null}getChannels(Z){return 4}}class dB extends E1{constructor(...Z){super(...Z);this.extensionName=OV,this.prereadTypes=[s.TEXTURE]}static register(){N4.registerFormat("image/webp",new ia)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[OV])X.source=X.extensions[OV].source}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/webp"){let Y=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===Y)Q.extensions=Q.extensions||{},Q.extensions[OV]={source:Q.source},delete Q.source})}}),this}}dB.EXTENSION_NAME=OV;var xa=ca,m8,na,aa;function BR1(Z,J){let X=new m8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==m8.TRIANGULAR_MESH)throw new Error(`[${xa}] Unknown geometry type.`);let $=new m8.Mesh;if(!Z.DecodeBufferToMesh(X,$).ok()||$.ptr===0)throw new Error(`[${xa}] Decoding failure.`);return $}finally{m8.destroy(X)}}function wR1(Z,J){let Y=J.num_faces()*3,$,Q;if(J.num_points()<=65534){let K=Y*Uint16Array.BYTES_PER_ELEMENT;$=m8._malloc(K),Z.GetTrianglesUInt16Array(J,K,$),Q=new Uint16Array(m8.HEAPU16.buffer,$,Y).slice()}else{let K=Y*Uint32Array.BYTES_PER_ELEMENT;$=m8._malloc(K),Z.GetTrianglesUInt32Array(J,K,$),Q=new Uint32Array(m8.HEAPU32.buffer,$,Y).slice()}return m8._free($),Q}function jR1(Z,J,X,Y){let $=aa[Y.componentType],Q=na[Y.componentType],K=X.num_components(),G=J.num_points()*K,V=G*Q.BYTES_PER_ELEMENT,H=m8._malloc(V);Z.GetAttributeDataArrayForAllPoints(J,X,$,V,H);let F=new Q(m8.HEAPF32.buffer,H,G).slice();return m8._free(H),F}function OR1(Z){m8=Z,na={[N0.ComponentType.FLOAT]:Float32Array,[N0.ComponentType.UNSIGNED_INT]:Uint32Array,[N0.ComponentType.UNSIGNED_SHORT]:Uint16Array,[N0.ComponentType.UNSIGNED_BYTE]:Uint8Array,[N0.ComponentType.SHORT]:Int16Array,[N0.ComponentType.BYTE]:Int8Array},aa={[N0.ComponentType.FLOAT]:m8.DT_FLOAT32,[N0.ComponentType.UNSIGNED_INT]:m8.DT_UINT32,[N0.ComponentType.UNSIGNED_SHORT]:m8.DT_UINT16,[N0.ComponentType.UNSIGNED_BYTE]:m8.DT_UINT8,[N0.ComponentType.SHORT]:m8.DT_INT16,[N0.ComponentType.BYTE]:m8.DT_INT8}}var I9,MV;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(MV||(MV={}));var _9;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(_9||(_9={}));var sa={[_9.POSITION]:14,[_9.NORMAL]:10,[_9.COLOR]:8,[_9.TEX_COORD]:12,[_9.GENERIC]:12},ha={decodeSpeed:5,encodeSpeed:5,method:MV.EDGEBREAKER,quantizationBits:sa,quantizationVolume:"mesh"};function NR1(Z){I9=Z}function RR1(Z,J=ha){let X=NZ({},ha,J);X.quantizationBits=NZ({},sa,J.quantizationBits);let Y=new I9.MeshBuilder,$=new I9.Mesh,Q=new I9.ExpertEncoder($),K={},W=new I9.DracoInt8Array,G=Z.listTargets().length>0,V=!1;for(let L of Z.listSemantics()){let B=Z.getAttribute(L);if(B.getSparse()){V=!0;continue}let w=MR1(L),O=PR1(Y,B.getComponentType(),$,I9[w],B.getCount(),B.getElementSize(),B.getArray());if(O===-1)throw new Error(`Error compressing "${L}" attribute.`);if(K[L]=O,X.quantizationVolume==="mesh"||L!=="POSITION")Q.SetAttributeQuantization(O,X.quantizationBits[w]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:N}=X,R=Math.max(N.max[0]-N.min[0],N.max[1]-N.min[1],N.max[2]-N.min[2]);Q.SetAttributeExplicitQuantization(O,X.quantizationBits[w],B.getElementSize(),N.min,R)}else throw new Error("Invalid quantization volume state.")}let H=Z.getIndices();if(!H)throw new bB("Primitive must have indices.");if(Y.AddFacesToMesh($,H.getCount()/3,H.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===MV.SEQUENTIAL||G||V)Q.SetEncodingMethod(I9.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(I9.MESH_EDGEBREAKER_ENCODING);let F=Q.EncodeToDracoBuffer(!(G||V),W);if(F<=0)throw new bB("Error applying Draco compression.");let z=new Uint8Array(F);for(let L=0;L<F;++L)z[L]=W.GetValue(L);let q=Q.GetNumberOfEncodedPoints(),U=Q.GetNumberOfEncodedFaces()*3;return I9.destroy(W),I9.destroy($),I9.destroy(Y),I9.destroy(Q),{numVertices:q,numIndices:U,data:z,attributeIDs:K}}function MR1(Z){if(Z==="POSITION")return _9.POSITION;else if(Z==="NORMAL")return _9.NORMAL;else if(Z.startsWith("COLOR_"))return _9.COLOR;else if(Z.startsWith("TEXCOORD_"))return _9.TEX_COORD;return _9.GENERIC}function PR1(Z,J,X,Y,$,Q,K){switch(J){case N0.ComponentType.UNSIGNED_BYTE:return Z.AddUInt8Attribute(X,Y,$,Q,K);case N0.ComponentType.BYTE:return Z.AddInt8Attribute(X,Y,$,Q,K);case N0.ComponentType.UNSIGNED_SHORT:return Z.AddUInt16Attribute(X,Y,$,Q,K);case N0.ComponentType.SHORT:return Z.AddInt16Attribute(X,Y,$,Q,K);case N0.ComponentType.UNSIGNED_INT:return Z.AddUInt32Attribute(X,Y,$,Q,K);case N0.ComponentType.FLOAT:return Z.AddFloatAttribute(X,Y,$,Q,K);default:throw new Error(`Unexpected component type, "${J}".`)}}class bB extends Error{}var N8=ca;class DV extends E1{constructor(...Z){super(...Z);this.extensionName=N8,this.prereadTypes=[s.PRIMITIVE],this.prewriteTypes=[s.ACCESSOR],this.readDependencies=["draco3d.decoder"],this.writeDependencies=["draco3d.encoder"],this._decoderModule=null,this._encoderModule=null,this._encoderOptions={}}install(Z,J){if(Z==="draco3d.decoder")this._decoderModule=J,OR1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,NR1(this._encoderModule);return this}setEncoderOptions(Z){return this._encoderOptions=Z,this}preread(Z){if(!this._decoderModule)throw new Error(`[${N8}] Please install extension dependency, "draco3d.decoder".`);let J=this.document.getLogger(),X=Z.jsonDoc,Y=new Map;try{let $=X.json.meshes||[];for(let Q of $)for(let K of Q.primitives){if(!K.extensions||!K.extensions[N8])continue;let W=K.extensions[N8],[G,V]=Y.get(W.bufferView)||[];if(!V||!G){let H=X.json.bufferViews[W.bufferView],F=X.json.buffers[H.buffer],z=F.uri?X.resources[F.uri]:X.resources[FC],q=H.byteOffset||0,U=H.byteLength,L=_6.toView(z,q,U);G=new this._decoderModule.Decoder,V=BR1(G,L),Y.set(W.bufferView,[G,V]),J.debug(`[${N8}] Decompressed ${L.byteLength} bytes.`)}for(let H in W.attributes){let F=Z.jsonDoc.json.accessors[K.attributes[H]],z=G.GetAttributeByUniqueId(V,W.attributes[H]),q=jR1(G,V,z,F);Z.accessors[K.attributes[H]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(wR1(G,V))}}finally{for(let[$,Q]of Array.from(Y.values()))this._decoderModule.destroy($),this._decoderModule.destroy(Q)}return this}read(Z){return this}prewrite(Z,J){if(!this._encoderModule)throw new Error(`[${N8}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${N8}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let Y=DR1(this.document),$=new Map,Q="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)X.warn(`[${N8}]: quantizationVolume=scene requires exactly 1 scene.`);else Q=Ra(this.document.getRoot().listScenes().pop());for(let K of Array.from(Y.keys())){let W=Y.get(K);if(!W)throw new Error("Unexpected primitive.");if($.has(W)){$.set(W,$.get(W));continue}let G=K.getIndices(),V=Z.jsonDoc.json.accessors,H;try{H=RR1(K,NZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof bB){X.warn(`[${N8}]: ${q.message} Skipping primitive compression.`);continue}throw q}$.set(W,H);let F=Z.createAccessorDef(G);if(F.count=H.numIndices,Z.accessorIndexMap.set(G,V.length),V.push(F),H.numVertices>65534&&N0.getComponentSize(F.componentType)<=2)F.componentType=N0.ComponentType.UNSIGNED_INT;else if(H.numVertices>254&&N0.getComponentSize(F.componentType)<=1)F.componentType=N0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let U=K.getAttribute(q);if(H.attributeIDs[q]===void 0)continue;let L=Z.createAccessorDef(U);L.count=H.numVertices,Z.accessorIndexMap.set(U,V.length),V.push(L)}let z=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(z))Z.otherBufferViews.set(z,[]);Z.otherBufferViews.get(z).push(H.data)}return X.debug(`[${N8}] Compressed ${Y.size} primitives.`),Z.extensionData[N8]={primitiveHashMap:Y,primitiveEncodingMap:$},this}write(Z){let J=Z.extensionData[N8];for(let X of this.document.getRoot().listMeshes()){let Y=Z.jsonDoc.json.meshes[Z.meshIndexMap.get(X)];for(let $=0;$<X.listPrimitives().length;$++){let Q=X.listPrimitives()[$],K=Y.primitives[$],W=J.primitiveHashMap.get(Q);if(!W)continue;let G=J.primitiveEncodingMap.get(W);if(!G)continue;K.extensions=K.extensions||{},K.extensions[N8]={bufferView:Z.otherBufferViewsIndexMap.get(G.data),attributes:G.attributeIDs}}}if(!J.primitiveHashMap.size){let X=Z.jsonDoc.json;X.extensionsUsed=(X.extensionsUsed||[]).filter((Y)=>Y!==N8),X.extensionsRequired=(X.extensionsRequired||[]).filter((Y)=>Y!==N8)}return this}}DV.EXTENSION_NAME=N8;DV.EncoderMethod=MV;function DR1(Z){let J=Z.getLogger(),X=new Set,Y=new Set,$=0,Q=0;for(let F of Z.getRoot().listMeshes())for(let z of F.listPrimitives())if(!z.getIndices())Y.add(z),$++;else if(z.getMode()!==hJ.Mode.TRIANGLES)Y.add(z),Q++;else X.add(z);if($>0)J.warn(`[${N8}] Skipping Draco compression of ${$} non-indexed primitives.`);if(Q>0)J.warn(`[${N8}] Skipping Draco compression of ${Q} non-TRIANGLES primitives.`);let K=Z.getRoot().listAccessors(),W=new Map;for(let F=0;F<K.length;F++)W.set(K[F],F);let G=new Map,V=new Set,H=new Map;for(let F of Array.from(X)){let z=fa(F,W);if(V.has(z)){H.set(F,z);continue}if(G.has(F.getIndices())){let q=F.getIndices(),U=q.clone();W.set(U,Z.getRoot().listAccessors().length-1),F.swap(q,U)}for(let q of F.listAttributes())if(G.has(q)){let U=q.clone();W.set(U,Z.getRoot().listAccessors().length-1),F.swap(q,U)}z=fa(F,W),V.add(z),H.set(F,z),G.set(F.getIndices(),z);for(let q of F.listAttributes())G.set(q,z)}for(let F of Array.from(G.keys())){let z=new Set(F.listParents().map((q)=>q.propertyType));if(z.size!==2||!z.has(s.PRIMITIVE)||!z.has(s.ROOT))throw new Error(`[${N8}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let F of Array.from(X)){let z=H.get(F),q=F.getIndices();if(G.get(q)!==z||F.listAttributes().some((U)=>G.get(U)!==z))throw new Error(`[${N8}] Draco primitives must share all, or no, accessors.`)}for(let F of Array.from(Y)){let z=F.getIndices();if(G.has(z)||F.listAttributes().some((q)=>G.has(q)))throw new Error(`[${N8}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return H}function fa(Z,J){let X=[],Y=Z.getIndices();X.push(J.get(Y));for(let $ of Z.listAttributes())X.push(J.get($));return X.sort().join("|")}class CK extends i1{init(){this.extensionName=TC,this.propertyType="Light",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:CK.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(Z){return this.set("color",Z)}getIntensity(){return this.get("intensity")}setIntensity(Z){return this.set("intensity",Z)}getType(){return this.get("type")}setType(Z){return this.set("type",Z)}getRange(){return this.get("range")}setRange(Z){return this.set("range",Z)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(Z){return this.set("innerConeAngle",Z)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(Z){return this.set("outerConeAngle",Z)}}CK.EXTENSION_NAME=TC;CK.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};var L7=TC;class dC extends E1{constructor(...Z){super(...Z);this.extensionName=L7}createLight(Z=""){return new CK(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[L7])return this;let $=(J.json.extensions[L7].lights||[]).map((Q)=>{var K,W;let G=this.createLight().setName(Q.name||"").setType(Q.type);if(Q.color!==void 0)G.setColor(Q.color);if(Q.intensity!==void 0)G.setIntensity(Q.intensity);if(Q.range!==void 0)G.setRange(Q.range);if(((K=Q.spot)==null?void 0:K.innerConeAngle)!==void 0)G.setInnerConeAngle(Q.spot.innerConeAngle);if(((W=Q.spot)==null?void 0:W.outerConeAngle)!==void 0)G.setOuterConeAngle(Q.spot.outerConeAngle);return G});return J.json.nodes.forEach((Q,K)=>{if(!Q.extensions||!Q.extensions[L7])return;let W=Q.extensions[L7];Z.nodes[K].setExtension(L7,$[W.light])}),this}write(Z){let J=Z.jsonDoc;if(this.properties.size===0)return this;let X=[],Y=new Map;for(let $ of this.properties){let Q=$,K={type:Q.getType()};if(!K8.eq(Q.getColor(),[1,1,1]))K.color=Q.getColor();if(Q.getIntensity()!==1)K.intensity=Q.getIntensity();if(Q.getRange()!=null)K.range=Q.getRange();if(Q.getName())K.name=Q.getName();if(Q.getType()===CK.Type.SPOT)K.spot={innerConeAngle:Q.getInnerConeAngle(),outerConeAngle:Q.getOuterConeAngle()};X.push(K),Y.set(Q,X.length-1)}return this.document.getRoot().listNodes().forEach(($)=>{let Q=$.getExtension(L7);if(Q){let K=Z.nodeIndexMap.get($),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[L7]={light:Y.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[L7]={lights:X},this}}dC.EXTENSION_NAME=L7;var{R:CR1,G:TR1,B:ER1}=r5;class cC extends i1{init(){this.extensionName=EC,this.propertyType="Anisotropy",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new D1(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(Z){return this.set("anisotropyStrength",Z)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(Z){return this.set("anisotropyRotation",Z)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(Z){return this.setRef("anisotropyTexture",Z,{channels:CR1|TR1|ER1})}}cC.EXTENSION_NAME=EC;var kY=EC;class lC extends E1{constructor(...Z){super(...Z);this.extensionName=kY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createAnisotropy(){return new cC(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[kY]){let K=this.createAnisotropy();Z.materials[Q].setExtension(kY,K);let W=$.extensions[kY];if(W.anisotropyStrength!==void 0)K.setAnisotropyStrength(W.anisotropyStrength);if(W.anisotropyRotation!==void 0)K.setAnisotropyRotation(W.anisotropyRotation);if(W.anisotropyTexture!==void 0){let G=W.anisotropyTexture,V=Z.textures[Y[G.index].source];K.setAnisotropyTexture(V),Z.setTextureInfo(K.getAnisotropyTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(kY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[kY]={};if(Y.getAnisotropyStrength()>0)K.anisotropyStrength=Y.getAnisotropyStrength();if(Y.getAnisotropyRotation()!==0)K.anisotropyRotation=Y.getAnisotropyRotation();if(Y.getAnisotropyTexture()){let W=Y.getAnisotropyTexture(),G=Y.getAnisotropyTextureInfo();K.anisotropyTexture=Z.createTextureInfoDef(W,G)}}}),this}}lC.EXTENSION_NAME=kY;var{R:ya,G:ba,B:kR1}=r5;class pC extends i1{init(){this.extensionName=kC,this.propertyType="Clearcoat",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new D1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new D1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new D1(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(Z){return this.set("clearcoatFactor",Z)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(Z){return this.setRef("clearcoatTexture",Z,{channels:ya})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(Z){return this.set("clearcoatRoughnessFactor",Z)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(Z){return this.setRef("clearcoatRoughnessTexture",Z,{channels:ba})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(Z){return this.set("clearcoatNormalScale",Z)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(Z){return this.setRef("clearcoatNormalTexture",Z,{channels:ya|ba|kR1})}}pC.EXTENSION_NAME=kC;var IY=kC;class iC extends E1{constructor(...Z){super(...Z);this.extensionName=IY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createClearcoat(){return new pC(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[IY]){let K=this.createClearcoat();Z.materials[Q].setExtension(IY,K);let W=$.extensions[IY];if(W.clearcoatFactor!==void 0)K.setClearcoatFactor(W.clearcoatFactor);if(W.clearcoatRoughnessFactor!==void 0)K.setClearcoatRoughnessFactor(W.clearcoatRoughnessFactor);if(W.clearcoatTexture!==void 0){let G=W.clearcoatTexture,V=Z.textures[Y[G.index].source];K.setClearcoatTexture(V),Z.setTextureInfo(K.getClearcoatTextureInfo(),G)}if(W.clearcoatRoughnessTexture!==void 0){let G=W.clearcoatRoughnessTexture,V=Z.textures[Y[G.index].source];K.setClearcoatRoughnessTexture(V),Z.setTextureInfo(K.getClearcoatRoughnessTextureInfo(),G)}if(W.clearcoatNormalTexture!==void 0){let G=W.clearcoatNormalTexture,V=Z.textures[Y[G.index].source];if(K.setClearcoatNormalTexture(V),Z.setTextureInfo(K.getClearcoatNormalTextureInfo(),G),G.scale!==void 0)K.setClearcoatNormalScale(G.scale)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(IY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[IY]={clearcoatFactor:Y.getClearcoatFactor(),clearcoatRoughnessFactor:Y.getClearcoatRoughnessFactor()};if(Y.getClearcoatTexture()){let W=Y.getClearcoatTexture(),G=Y.getClearcoatTextureInfo();K.clearcoatTexture=Z.createTextureInfoDef(W,G)}if(Y.getClearcoatRoughnessTexture()){let W=Y.getClearcoatRoughnessTexture(),G=Y.getClearcoatRoughnessTextureInfo();K.clearcoatRoughnessTexture=Z.createTextureInfoDef(W,G)}if(Y.getClearcoatNormalTexture()){let W=Y.getClearcoatNormalTexture(),G=Y.getClearcoatNormalTextureInfo();if(K.clearcoatNormalTexture=Z.createTextureInfoDef(W,G),Y.getClearcoatNormalScale()!==1)K.clearcoatNormalTexture.scale=Y.getClearcoatNormalScale()}}}),this}}iC.EXTENSION_NAME=IY;var{R:IR1,G:_R1,B:vR1,A:SR1}=r5;class nC extends i1{init(){this.extensionName=IC,this.propertyType="DiffuseTransmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new D1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new D1(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(Z){return this.set("diffuseTransmissionFactor",Z)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(Z){return this.setRef("diffuseTransmissionTexture",Z,{channels:SR1})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(Z){return this.set("diffuseTransmissionColorFactor",Z)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(Z){return this.setRef("diffuseTransmissionColorTexture",Z,{channels:IR1|_R1|vR1})}}nC.EXTENSION_NAME=IC;var _Y=IC;class aC extends E1{constructor(...Z){super(...Z);this.extensionName=_Y}createDiffuseTransmission(){return new nC(this.document.getGraph())}read(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[_Y]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(_Y,K);let W=$.extensions[_Y];if(W.diffuseTransmissionFactor!==void 0)K.setDiffuseTransmissionFactor(W.diffuseTransmissionFactor);if(W.diffuseTransmissionColorFactor!==void 0)K.setDiffuseTransmissionColorFactor(W.diffuseTransmissionColorFactor);if(W.diffuseTransmissionTexture!==void 0){let G=W.diffuseTransmissionTexture,V=Z.textures[Y[G.index].source];K.setDiffuseTransmissionTexture(V),Z.setTextureInfo(K.getDiffuseTransmissionTextureInfo(),G)}if(W.diffuseTransmissionColorTexture!==void 0){let G=W.diffuseTransmissionColorTexture,V=Z.textures[Y[G.index].source];K.setDiffuseTransmissionColorTexture(V),Z.setTextureInfo(K.getDiffuseTransmissionColorTextureInfo(),G)}}}),this}write(Z){let J=Z.jsonDoc;for(let X of this.document.getRoot().listMaterials()){let Y=X.getExtension(_Y);if(!Y)continue;let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[_Y]={diffuseTransmissionFactor:Y.getDiffuseTransmissionFactor(),diffuseTransmissionColorFactor:Y.getDiffuseTransmissionColorFactor()};if(Y.getDiffuseTransmissionTexture()){let W=Y.getDiffuseTransmissionTexture(),G=Y.getDiffuseTransmissionTextureInfo();K.diffuseTransmissionTexture=Z.createTextureInfoDef(W,G)}if(Y.getDiffuseTransmissionColorTexture()){let W=Y.getDiffuseTransmissionColorTexture(),G=Y.getDiffuseTransmissionColorTextureInfo();K.diffuseTransmissionColorTexture=Z.createTextureInfoDef(W,G)}}return this}}aC.EXTENSION_NAME=_Y;class sC extends i1{init(){this.extensionName=_C,this.propertyType="Dispersion",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(Z){return this.set("dispersion",Z)}}sC.EXTENSION_NAME=_C;var vY=_C;class oC extends E1{constructor(...Z){super(...Z);this.extensionName=vY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createDispersion(){return new sC(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[vY]){let Q=this.createDispersion();Z.materials[$].setExtension(vY,Q);let K=Y.extensions[vY];if(K.dispersion!==void 0)Q.setDispersion(K.dispersion)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(vY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[vY]={dispersion:Y.getDispersion()}}}),this}}oC.EXTENSION_NAME=vY;class rC extends i1{init(){this.extensionName=vC,this.propertyType="EmissiveStrength",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(Z){return this.set("emissiveStrength",Z)}}rC.EXTENSION_NAME=vC;var SY=vC;class tC extends E1{constructor(...Z){super(...Z);this.extensionName=SY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createEmissiveStrength(){return new rC(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[SY]){let Q=this.createEmissiveStrength();Z.materials[$].setExtension(SY,Q);let K=Y.extensions[SY];if(K.emissiveStrength!==void 0)Q.setEmissiveStrength(K.emissiveStrength)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(SY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[SY]={emissiveStrength:Y.getEmissiveStrength()}}}),this}}tC.EXTENSION_NAME=SY;class eC extends i1{init(){this.extensionName=SC,this.propertyType="IOR",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(Z){return this.set("ior",Z)}}eC.EXTENSION_NAME=SC;var AY=SC;class cB extends E1{constructor(...Z){super(...Z);this.extensionName=AY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIOR(){return new eC(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((Y,$)=>{if(Y.extensions&&Y.extensions[AY]){let Q=this.createIOR();Z.materials[$].setExtension(AY,Q);let K=Y.extensions[AY];if(K.ior!==void 0)Q.setIOR(K.ior)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(AY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[AY]={ior:Y.getIOR()}}}),this}}cB.EXTENSION_NAME=AY;var{R:AR1,G:xR1}=r5;class ZT extends i1{init(){this.extensionName=AC,this.propertyType="Iridescence",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new D1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new D1(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(Z){return this.set("iridescenceFactor",Z)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(Z){return this.setRef("iridescenceTexture",Z,{channels:AR1})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(Z){return this.set("iridescenceIOR",Z)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(Z){return this.set("iridescenceThicknessMinimum",Z)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(Z){return this.set("iridescenceThicknessMaximum",Z)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(Z){return this.setRef("iridescenceThicknessTexture",Z,{channels:xR1})}}ZT.EXTENSION_NAME=AC;var xY=AC;class JT extends E1{constructor(...Z){super(...Z);this.extensionName=xY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIridescence(){return new ZT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[xY]){let K=this.createIridescence();Z.materials[Q].setExtension(xY,K);let W=$.extensions[xY];if(W.iridescenceFactor!==void 0)K.setIridescenceFactor(W.iridescenceFactor);if(W.iridescenceIor!==void 0)K.setIridescenceIOR(W.iridescenceIor);if(W.iridescenceThicknessMinimum!==void 0)K.setIridescenceThicknessMinimum(W.iridescenceThicknessMinimum);if(W.iridescenceThicknessMaximum!==void 0)K.setIridescenceThicknessMaximum(W.iridescenceThicknessMaximum);if(W.iridescenceTexture!==void 0){let G=W.iridescenceTexture,V=Z.textures[Y[G.index].source];K.setIridescenceTexture(V),Z.setTextureInfo(K.getIridescenceTextureInfo(),G)}if(W.iridescenceThicknessTexture!==void 0){let G=W.iridescenceThicknessTexture,V=Z.textures[Y[G.index].source];K.setIridescenceThicknessTexture(V),Z.setTextureInfo(K.getIridescenceThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(xY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[xY]={};if(Y.getIridescenceFactor()>0)K.iridescenceFactor=Y.getIridescenceFactor();if(Y.getIridescenceIOR()!==1.3)K.iridescenceIor=Y.getIridescenceIOR();if(Y.getIridescenceThicknessMinimum()!==100)K.iridescenceThicknessMinimum=Y.getIridescenceThicknessMinimum();if(Y.getIridescenceThicknessMaximum()!==400)K.iridescenceThicknessMaximum=Y.getIridescenceThicknessMaximum();if(Y.getIridescenceTexture()){let W=Y.getIridescenceTexture(),G=Y.getIridescenceTextureInfo();K.iridescenceTexture=Z.createTextureInfoDef(W,G)}if(Y.getIridescenceThicknessTexture()){let W=Y.getIridescenceThicknessTexture(),G=Y.getIridescenceThicknessTextureInfo();K.iridescenceThicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}JT.EXTENSION_NAME=xY;var{R:ga,G:ma,B:ua,A:da}=r5;class XT extends i1{init(){this.extensionName=xC,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new D1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new D1(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(Z){return this.set("diffuseFactor",Z)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(Z){return this.setRef("diffuseTexture",Z,{channels:ga|ma|ua|da,isColor:!0})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(Z){return this.set("specularFactor",Z)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(Z){return this.set("glossinessFactor",Z)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(Z){return this.setRef("specularGlossinessTexture",Z,{channels:ga|ma|ua|da})}}XT.EXTENSION_NAME=xC;var hY=xC;class lB extends E1{constructor(...Z){super(...Z);this.extensionName=hY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createPBRSpecularGlossiness(){return new XT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[hY]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(hY,K);let W=$.extensions[hY];if(W.diffuseFactor!==void 0)K.setDiffuseFactor(W.diffuseFactor);if(W.specularFactor!==void 0)K.setSpecularFactor(W.specularFactor);if(W.glossinessFactor!==void 0)K.setGlossinessFactor(W.glossinessFactor);if(W.diffuseTexture!==void 0){let G=W.diffuseTexture,V=Z.textures[Y[G.index].source];K.setDiffuseTexture(V),Z.setTextureInfo(K.getDiffuseTextureInfo(),G)}if(W.specularGlossinessTexture!==void 0){let G=W.specularGlossinessTexture,V=Z.textures[Y[G.index].source];K.setSpecularGlossinessTexture(V),Z.setTextureInfo(K.getSpecularGlossinessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(hY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[hY]={diffuseFactor:Y.getDiffuseFactor(),specularFactor:Y.getSpecularFactor(),glossinessFactor:Y.getGlossinessFactor()};if(Y.getDiffuseTexture()){let W=Y.getDiffuseTexture(),G=Y.getDiffuseTextureInfo();K.diffuseTexture=Z.createTextureInfoDef(W,G)}if(Y.getSpecularGlossinessTexture()){let W=Y.getSpecularGlossinessTexture(),G=Y.getSpecularGlossinessTextureInfo();K.specularGlossinessTexture=Z.createTextureInfoDef(W,G)}}}),this}}lB.EXTENSION_NAME=hY;var{R:hR1,G:fR1,B:yR1,A:bR1}=r5;class YT extends i1{init(){this.extensionName=hC,this.propertyType="Sheen",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new D1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new D1(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(Z){return this.set("sheenColorFactor",Z)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(Z){return this.setRef("sheenColorTexture",Z,{channels:hR1|fR1|yR1,isColor:!0})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(Z){return this.set("sheenRoughnessFactor",Z)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(Z){return this.setRef("sheenRoughnessTexture",Z,{channels:bR1})}}YT.EXTENSION_NAME=hC;var fY=hC;class $T extends E1{constructor(...Z){super(...Z);this.extensionName=fY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSheen(){return new YT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[fY]){let K=this.createSheen();Z.materials[Q].setExtension(fY,K);let W=$.extensions[fY];if(W.sheenColorFactor!==void 0)K.setSheenColorFactor(W.sheenColorFactor);if(W.sheenRoughnessFactor!==void 0)K.setSheenRoughnessFactor(W.sheenRoughnessFactor);if(W.sheenColorTexture!==void 0){let G=W.sheenColorTexture,V=Z.textures[Y[G.index].source];K.setSheenColorTexture(V),Z.setTextureInfo(K.getSheenColorTextureInfo(),G)}if(W.sheenRoughnessTexture!==void 0){let G=W.sheenRoughnessTexture,V=Z.textures[Y[G.index].source];K.setSheenRoughnessTexture(V),Z.setTextureInfo(K.getSheenRoughnessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(fY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[fY]={sheenColorFactor:Y.getSheenColorFactor(),sheenRoughnessFactor:Y.getSheenRoughnessFactor()};if(Y.getSheenColorTexture()){let W=Y.getSheenColorTexture(),G=Y.getSheenColorTextureInfo();K.sheenColorTexture=Z.createTextureInfoDef(W,G)}if(Y.getSheenRoughnessTexture()){let W=Y.getSheenRoughnessTexture(),G=Y.getSheenRoughnessTextureInfo();K.sheenRoughnessTexture=Z.createTextureInfoDef(W,G)}}}),this}}$T.EXTENSION_NAME=fY;var{R:gR1,G:mR1,B:uR1,A:dR1}=r5;class QT extends i1{init(){this.extensionName=fC,this.propertyType="Specular",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new D1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new D1(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(Z){return this.set("specularFactor",Z)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(Z){return this.set("specularColorFactor",Z)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(Z){return this.setRef("specularTexture",Z,{channels:dR1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:gR1|mR1|uR1,isColor:!0})}}QT.EXTENSION_NAME=fC;var yY=fC;class pB extends E1{constructor(...Z){super(...Z);this.extensionName=yY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSpecular(){return new QT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[yY]){let K=this.createSpecular();Z.materials[Q].setExtension(yY,K);let W=$.extensions[yY];if(W.specularFactor!==void 0)K.setSpecularFactor(W.specularFactor);if(W.specularColorFactor!==void 0)K.setSpecularColorFactor(W.specularColorFactor);if(W.specularTexture!==void 0){let G=W.specularTexture,V=Z.textures[Y[G.index].source];K.setSpecularTexture(V),Z.setTextureInfo(K.getSpecularTextureInfo(),G)}if(W.specularColorTexture!==void 0){let G=W.specularColorTexture,V=Z.textures[Y[G.index].source];K.setSpecularColorTexture(V),Z.setTextureInfo(K.getSpecularColorTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(yY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[yY]={};if(Y.getSpecularFactor()!==1)K.specularFactor=Y.getSpecularFactor();if(!K8.eq(Y.getSpecularColorFactor(),[1,1,1]))K.specularColorFactor=Y.getSpecularColorFactor();if(Y.getSpecularTexture()){let W=Y.getSpecularTexture(),G=Y.getSpecularTextureInfo();K.specularTexture=Z.createTextureInfoDef(W,G)}if(Y.getSpecularColorTexture()){let W=Y.getSpecularColorTexture(),G=Y.getSpecularColorTextureInfo();K.specularColorTexture=Z.createTextureInfoDef(W,G)}}}),this}}pB.EXTENSION_NAME=yY;var{R:cR1}=r5;class KT extends i1{init(){this.extensionName=yC,this.propertyType="Transmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new D1(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(Z){return this.set("transmissionFactor",Z)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(Z){return this.setRef("transmissionTexture",Z,{channels:cR1})}}KT.EXTENSION_NAME=yC;var bY=yC;class WT extends E1{constructor(...Z){super(...Z);this.extensionName=bY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createTransmission(){return new KT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[bY]){let K=this.createTransmission();Z.materials[Q].setExtension(bY,K);let W=$.extensions[bY];if(W.transmissionFactor!==void 0)K.setTransmissionFactor(W.transmissionFactor);if(W.transmissionTexture!==void 0){let G=W.transmissionTexture,V=Z.textures[Y[G.index].source];K.setTransmissionTexture(V),Z.setTextureInfo(K.getTransmissionTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(bY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[bY]={transmissionFactor:Y.getTransmissionFactor()};if(Y.getTransmissionTexture()){let W=Y.getTransmissionTexture(),G=Y.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(W,G)}}}),this}}WT.EXTENSION_NAME=bY;class GT extends i1{init(){this.extensionName=bC,this.propertyType="Unlit",this.parentTypes=[s.MATERIAL]}}GT.EXTENSION_NAME=bC;var PK=bC;class iB extends E1{constructor(...Z){super(...Z);this.extensionName=PK,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createUnlit(){return new GT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((X,Y)=>{if(X.extensions&&X.extensions[PK])Z.materials[Y].setExtension(PK,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(PK)){let Y=Z.materialIndexMap.get(X),$=J.json.materials[Y];$.extensions=$.extensions||{},$.extensions[PK]={}}}),this}}iB.EXTENSION_NAME=PK;class VT extends i1{init(){this.extensionName=uY,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new D0})}getMaterial(){return this.getRef("material")}setMaterial(Z){return this.setRef("material",Z)}addVariant(Z){return this.addRef("variants",Z)}removeVariant(Z){return this.removeRef("variants",Z)}listVariants(){return this.listRefs("variants")}}VT.EXTENSION_NAME=uY;class HT extends i1{init(){this.extensionName=uY,this.propertyType="MappingList",this.parentTypes=[s.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new D0})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}HT.EXTENSION_NAME=uY;class gB extends i1{init(){this.extensionName=uY,this.propertyType="Variant",this.parentTypes=["MappingList"]}}gB.EXTENSION_NAME=uY;var B7=uY;class zT extends E1{constructor(...Z){super(...Z);this.extensionName=B7}createMappingList(){return new HT(this.document.getGraph())}createVariant(Z=""){return new gB(this.document.getGraph(),Z)}createMapping(){return new VT(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof gB)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[B7])return this;let $=(J.json.extensions[B7].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,W)=>{let G=Z.meshes[W];(K.primitives||[]).forEach((H,F)=>{if(!H.extensions||!H.extensions[B7])return;let z=this.createMappingList(),q=H.extensions[B7];for(let U of q.mappings){let L=this.createMapping();if(U.material!==void 0)L.setMaterial(Z.materials[U.material]);for(let B of U.variants||[])L.addVariant($[B]);z.addMapping(L)}G.listPrimitives()[F].setExtension(B7,z)})}),this}write(Z){let J=Z.jsonDoc,X=this.listVariants();if(!X.length)return this;let Y=[],$=new Map;for(let Q of X)$.set(Q,Y.length),Y.push(Z.createPropertyDef(Q));for(let Q of this.document.getRoot().listMeshes()){let K=Z.meshIndexMap.get(Q);Q.listPrimitives().forEach((W,G)=>{let V=W.getExtension(B7);if(!V)return;let H=Z.jsonDoc.json.meshes[K].primitives[G],F=V.listMappings().map((z)=>{let q=Z.createPropertyDef(z),U=z.getMaterial();if(U)q.material=Z.materialIndexMap.get(U);return q.variants=z.listVariants().map((L)=>$.get(L)),q});H.extensions=H.extensions||{},H.extensions[B7]={mappings:F}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[B7]={variants:Y},this}}zT.EXTENSION_NAME=B7;var{G:lR1}=r5;class FT extends i1{init(){this.extensionName=gC,this.propertyType="Volume",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new D1(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(Z){return this.set("thicknessFactor",Z)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(Z){return this.setRef("thicknessTexture",Z,{channels:lR1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}FT.EXTENSION_NAME=gC;var gY=gC;class qT extends E1{constructor(...Z){super(...Z);this.extensionName=gY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createVolume(){return new FT(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[gY]){let K=this.createVolume();Z.materials[Q].setExtension(gY,K);let W=$.extensions[gY];if(W.thicknessFactor!==void 0)K.setThicknessFactor(W.thicknessFactor);if(W.attenuationDistance!==void 0)K.setAttenuationDistance(W.attenuationDistance);if(W.attenuationColor!==void 0)K.setAttenuationColor(W.attenuationColor);if(W.thicknessTexture!==void 0){let G=W.thicknessTexture,V=Z.textures[Y[G.index].source];K.setThicknessTexture(V),Z.setTextureInfo(K.getThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(gY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[gY]={};if(Y.getThicknessFactor()>0)K.thicknessFactor=Y.getThicknessFactor();if(Number.isFinite(Y.getAttenuationDistance()))K.attenuationDistance=Y.getAttenuationDistance();if(!K8.eq(Y.getAttenuationColor(),[1,1,1]))K.attenuationColor=Y.getAttenuationColor();if(Y.getThicknessTexture()){let W=Y.getThicknessTexture(),G=Y.getThicknessTextureInfo();K.thicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}qT.EXTENSION_NAME=gY;var oa=QR1;class CV extends E1{constructor(...Z){super(...Z);this.extensionName=oa}read(Z){return this}write(Z){return this}}CV.EXTENSION_NAME=oa;var NV=KR1;class ra{match(Z){return Z[0]===171&&Z[1]===75&&Z[2]===84&&Z[3]===88&&Z[4]===32&&Z[5]===50&&Z[6]===48&&Z[7]===187&&Z[8]===13&&Z[9]===10&&Z[10]===26&&Z[11]===10}getSize(Z){let J=fB(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=fB(Z).dataFormatDescriptor[0];if(X.colorModel===ka)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===Ia)return(X.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=fB(Z),X=this.getChannels(Z)>3,Y=0;for(let $=0;$<J.levels.length;$++){let Q=J.levels[$];if(Q.uncompressedByteLength)Y+=Q.uncompressedByteLength;else{let K=Math.max(1,Math.floor(J.pixelWidth/Math.pow(2,$))),W=Math.max(1,Math.floor(J.pixelHeight/Math.pow(2,$))),G=X?16:8;Y+=K/4*(W/4)*G}}return Y}}class UT extends E1{constructor(...Z){super(...Z);this.extensionName=NV,this.prereadTypes=[s.TEXTURE]}static register(){N4.registerFormat("image/ktx2",new ra)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[NV]){let X=J.extensions[NV];J.source=X.source}}),this}read(Z){return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listTextures().forEach((X)=>{if(X.getMimeType()==="image/ktx2"){let Y=Z.imageIndexMap.get(X);J.json.textures.forEach(($)=>{if($.source===Y)$.extensions=$.extensions||{},$.extensions[NV]={source:$.source},delete $.source})}}),this}}UT.EXTENSION_NAME=NV;class LT extends i1{init(){this.extensionName=mC,this.propertyType="Transform",this.parentTypes=[s.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(Z){return this.set("offset",Z)}getRotation(){return this.get("rotation")}setRotation(Z){return this.set("rotation",Z)}getScale(){return this.get("scale")}setScale(Z){return this.set("scale",Z)}getTexCoord(){return this.get("texCoord")}setTexCoord(Z){return this.set("texCoord",Z)}}LT.EXTENSION_NAME=mC;var mY=mC;class BT extends E1{constructor(...Z){super(...Z);this.extensionName=mY}createTransform(){return new LT(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[mY])continue;let Y=this.createTransform(),$=X.extensions[mY];if($.offset!==void 0)Y.setOffset($.offset);if($.rotation!==void 0)Y.setRotation($.rotation);if($.scale!==void 0)Y.setScale($.scale);if($.texCoord!==void 0)Y.setTexCoord($.texCoord);J.setExtension(mY,Y)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,Y]of J){let $=X.getExtension(mY);if(!$)continue;Y.extensions=Y.extensions||{};let Q={},K=K8.eq;if(!K($.getOffset(),[0,0]))Q.offset=$.getOffset();if($.getRotation()!==0)Q.rotation=$.getRotation();if(!K($.getScale(),[1,1]))Q.scale=$.getScale();if($.getTexCoord()!=null)Q.texCoord=$.getTexCoord();Y.extensions[mY]=Q}return this}}BT.EXTENSION_NAME=mY;var pR1=[s.ROOT,s.SCENE,s.NODE,s.MESH,s.MATERIAL,s.TEXTURE,s.ANIMATION];class wT extends i1{init(){this.extensionName=yB,this.propertyType="Packet",this.parentTypes=pR1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",NZ({},Z))}listProperties(){return Object.keys(this.get("properties"))}getProperty(Z){let J=this.get("properties");return Z in J?J[Z]:null}setProperty(Z,J){this._assertContext(Z);let X=NZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=RC(this.get("context")),J=RC(this.get("properties"));return NZ({"@context":Z},J)}fromJSONLD(Z){Z=RC(Z);let J=Z["@context"];if(J)this.set("context",J);return delete Z["@context"],this.set("properties",Z)}_assertContext(Z){if(!(Z.split(":")[0]in this.get("context")))throw new Error(`${yB}: Missing context for term, "${Z}".`)}}wT.EXTENSION_NAME=yB;function RC(Z){return JSON.parse(JSON.stringify(Z))}var OZ=yB;class jT extends E1{constructor(...Z){super(...Z);this.extensionName=OZ}createPacket(){return new wT(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[OZ];if(!X||!X.packets)return this;let Y=Z.jsonDoc.json,$=this.document.getRoot(),Q=X.packets.map((G)=>this.createPacket().fromJSONLD(G)),K=[[Y.asset],Y.scenes,Y.nodes,Y.meshes,Y.materials,Y.images,Y.animations],W=[[$],$.listScenes(),$.listNodes(),$.listMeshes(),$.listMaterials(),$.listTextures(),$.listAnimations()];for(let G=0;G<K.length;G++){let V=K[G]||[];for(let H=0;H<V.length;H++){let F=V[H];if(F.extensions&&F.extensions[OZ]){let z=F.extensions[OZ];W[G][H].setExtension(OZ,Q[z.packet])}}}return this}write(Z){let{json:J}=Z.jsonDoc,X=[];for(let Y of this.properties){X.push(Y.toJSONLD());for(let $ of Y.listParents()){let Q;switch($.propertyType){case s.ROOT:Q=J.asset;break;case s.SCENE:Q=J.scenes[Z.sceneIndexMap.get($)];break;case s.NODE:Q=J.nodes[Z.nodeIndexMap.get($)];break;case s.MESH:Q=J.meshes[Z.meshIndexMap.get($)];break;case s.MATERIAL:Q=J.materials[Z.materialIndexMap.get($)];break;case s.TEXTURE:Q=J.images[Z.imageIndexMap.get($)];break;case s.ANIMATION:Q=J.animations[Z.animationIndexMap.get($)];break;default:Q=null,this.document.getLogger().warn(`[${OZ}]: Unsupported parent property, "${$.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[OZ]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[OZ]={packets:X};return this}}jT.EXTENSION_NAME=OZ;var iR1=[DV,dC,lC,iC,aC,oC,tC,cB,JT,lB,pB,$T,WT,iB,zT,qT,CV,UT,BT,jT],iT6=[mB,PV,uB,dB,...iR1];var nR1=r(xD(),1);function kK(){return kK=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var Y in X)({}).hasOwnProperty.call(X,Y)&&(Z[Y]=X[Y])}return Z},kK.apply(null,arguments)}var{POINTS:ta,LINES:nB,LINE_STRIP:aR1,LINE_LOOP:sR1,TRIANGLES:aB,TRIANGLE_STRIP:oR1,TRIANGLE_FAN:rR1}=j8.Mode;function mJ(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function w7(Z,J){let X=kK({},Z);for(let Y in J)if(J[Y]!==void 0)X[Y]=J[Y];return X}function js(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case j8.Mode.POINTS:return J?J.getCount():X.getCount();case j8.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case j8.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case j8.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case j8.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case j8.Mode.TRIANGLE_STRIP:case j8.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw new Error("Unexpected mode: "+Z.getMode())}}var tR1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function MT(Z){return tR1.format(Z)}function eR1(Z,J,X=2){let Y=Z>J?"–":"+",$="%";return Y+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function eB(Z,J){return`${MT(Z)} → ${MT(J)} (${eR1(Z,J)})`}function IT(Z){let J=[];for(let X of Z.listAttributes())J.push(X);for(let X of Z.listTargets())for(let Y of X.listAttributes())J.push(Y);return Array.from(new Set(J))}function ZM1(Z,J,X){Z.swap(J,X);for(let Y of Z.listTargets())Y.swap(J,X)}function JM1(Z,J){if(Z==null&&J==null)return!0;if(Z==null||J==null)return!1;if(Z.length!==J.length)return!1;for(let X=0;X<Z.length;X++)if(Z[X]!==J[X])return!1;return!0}function RZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function XM1(Z,J=Z){let X=_T(Z,J);for(let Y=0;Y<X.length;Y++)X[Y]=Y;return X}function _T(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function YM1(Z){return Z.listParents().some((J)=>J.propertyType!==a.ROOT)}function Os(Z){for(let J in Z)return!1;return!0}function Ns(Z){let J=k6.fromGraph(Z.getGraph()),X=Z.getMaterial(),Y=J.getRoot().listMaterials().indexOf(X),$=QM1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((G)=>{let V=Z.getAttribute(G),H=V.getElementSize(),F=V.getComponentType();return`${G}:${H}:${F}`}).join("+"),W=Z.listTargets().map((G)=>{return G.listSemantics().sort().map((V)=>{let H=Z.getAttribute(V),F=H.getElementSize(),z=H.getComponentType();return`${V}:${F}:${z}`}).join("+")}).join("~");return`${Y}|${$}|${Q}|${K}|${W}`}function $M1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var QM1={[ta]:ta,[nB]:nB,[aR1]:nB,[sR1]:nB,[aB]:aB,[oR1]:aB,[rR1]:aB},TK="center",ea={pivot:"center"};function Rs(Z=ea){let J=w7(ea,Z);return mJ(TK,(X)=>{let Y=X.getLogger(),$=X.getRoot(),Q=$.listAnimations().length>0||$.listSkins().length>0;X.getRoot().listScenes().forEach((K,W)=>{Y.debug(`${TK}: Scene ${W+1} / ${$.listScenes().length}.`);let G;if(typeof J.pivot==="string"){let H=ED(K);if(G=[(H.max[0]-H.min[0])/2+H.min[0],(H.max[1]-H.min[1])/2+H.min[1],(H.max[2]-H.min[2])/2+H.min[2]],J.pivot==="above")G[1]=H.max[1];if(J.pivot==="below")G[1]=H.min[1]}else G=J.pivot;Y.debug(`${TK}: Pivot "${G.join(", ")}".`);let V=[-1*G[0],-1*G[1],-1*G[2]];if(Q){Y.debug(`${TK}: Model contains animation or skin. Adding a wrapper node.`);let H=X.createNode("Pivot").setTranslation(V);K.listChildren().forEach((F)=>H.addChild(F)),K.addChild(H)}else Y.debug(`${TK}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((H)=>{let F=H.getTranslation();H.setTranslation([F[0]+V[0],F[1]+V[1],F[2]+V[2]])})}),Y.debug(`${TK}: Complete.`)})}function KM1(Z){let J=new Set,X=Z,Y;while(Y=X.getParentNode()){if(J.has(Y))throw new Error("Circular dependency in scene graph.");J.add(Y),X=Y}return X.listParents().filter(($)=>$ instanceof zK)}function WM1(Z){let J=KM1(Z),X=Z.getParentNode();if(!X)return Z;Z.setMatrix(Z.getWorldMatrix()),X.removeChild(Z);for(let Y of J)Y.addChild(Z);return Z}var IK=typeof Float32Array!=="undefined"?Float32Array:Array;if(!Math.hypot)Math.hypot=function(){var Z=0,J=arguments.length;while(J--)Z+=arguments[J]*arguments[J];return Math.sqrt(Z)};function GM1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],V=J[7],H=J[8],F=J[9],z=J[10],q=J[11],U=J[12],L=J[13],B=J[14],w=J[15],O=X*W-Y*K,N=X*G-$*K,R=X*V-Q*K,D=Y*G-$*W,M=Y*V-Q*W,C=$*V-Q*G,T=H*L-F*U,E=H*B-z*U,x=H*w-q*U,v=F*B-z*L,S=F*w-q*L,I=z*w-q*B,_=O*I-N*S+R*v+D*x-M*E+C*T;if(!_)return null;return _=1/_,Z[0]=(W*I-G*S+V*v)*_,Z[1]=($*S-Y*I-Q*v)*_,Z[2]=(L*C-B*M+w*D)*_,Z[3]=(z*M-F*C-q*D)*_,Z[4]=(G*x-K*I-V*E)*_,Z[5]=(X*I-$*x+Q*E)*_,Z[6]=(B*R-U*C-w*N)*_,Z[7]=(H*C-z*R+q*N)*_,Z[8]=(K*S-W*x+V*T)*_,Z[9]=(Y*x-X*S-Q*T)*_,Z[10]=(U*M-L*R+w*O)*_,Z[11]=(F*R-H*M-q*O)*_,Z[12]=(W*E-K*v-G*T)*_,Z[13]=(X*v-Y*E+$*T)*_,Z[14]=(L*N-U*D-B*O)*_,Z[15]=(H*D-F*N+z*O)*_,Z}function VM1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],V=Z[8],H=Z[9],F=Z[10],z=Z[11],q=Z[12],U=Z[13],L=Z[14],B=Z[15],w=J*K-X*Q,O=J*W-Y*Q,N=J*G-$*Q,R=X*W-Y*K,D=X*G-$*K,M=Y*G-$*W,C=V*U-H*q,T=V*L-F*q,E=V*B-z*q,x=H*L-F*U,v=H*B-z*U,S=F*B-z*L;return w*S-O*v+N*x+R*E-D*T+M*C}function Ms(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],V=J[6],H=J[7],F=J[8],z=J[9],q=J[10],U=J[11],L=J[12],B=J[13],w=J[14],O=J[15],N=X[0],R=X[1],D=X[2],M=X[3];return Z[0]=N*Y+R*W+D*F+M*L,Z[1]=N*$+R*G+D*z+M*B,Z[2]=N*Q+R*V+D*q+M*w,Z[3]=N*K+R*H+D*U+M*O,N=X[4],R=X[5],D=X[6],M=X[7],Z[4]=N*Y+R*W+D*F+M*L,Z[5]=N*$+R*G+D*z+M*B,Z[6]=N*Q+R*V+D*q+M*w,Z[7]=N*K+R*H+D*U+M*O,N=X[8],R=X[9],D=X[10],M=X[11],Z[8]=N*Y+R*W+D*F+M*L,Z[9]=N*$+R*G+D*z+M*B,Z[10]=N*Q+R*V+D*q+M*w,Z[11]=N*K+R*H+D*U+M*O,N=X[12],R=X[13],D=X[14],M=X[15],Z[12]=N*Y+R*W+D*F+M*L,Z[13]=N*$+R*G+D*z+M*B,Z[14]=N*Q+R*V+D*q+M*w,Z[15]=N*K+R*H+D*U+M*O,Z}function HM1(){var Z=new IK(9);if(IK!=Float32Array)Z[1]=0,Z[2]=0,Z[3]=0,Z[5]=0,Z[6]=0,Z[7]=0;return Z[0]=1,Z[4]=1,Z[8]=1,Z}function zM1(Z,J){return Z[0]=J[0],Z[1]=J[1],Z[2]=J[2],Z[3]=J[4],Z[4]=J[5],Z[5]=J[6],Z[6]=J[8],Z[7]=J[9],Z[8]=J[10],Z}function FM1(Z,J){if(Z===J){var X=J[1],Y=J[2],$=J[5];Z[1]=J[3],Z[2]=J[6],Z[3]=X,Z[5]=J[7],Z[6]=Y,Z[7]=$}else Z[0]=J[0],Z[1]=J[3],Z[2]=J[6],Z[3]=J[1],Z[4]=J[4],Z[5]=J[7],Z[6]=J[2],Z[7]=J[5],Z[8]=J[8];return Z}function qM1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],V=J[7],H=J[8],F=H*K-W*V,z=-H*Q+W*G,q=V*Q-K*G,U=X*F+Y*z+$*q;if(!U)return null;return U=1/U,Z[0]=F*U,Z[1]=(-H*Y+$*V)*U,Z[2]=(W*Y-$*K)*U,Z[3]=z*U,Z[4]=(H*X-$*G)*U,Z[5]=(-W*X+$*Q)*U,Z[6]=q*U,Z[7]=(-V*X+Y*G)*U,Z[8]=(K*X-Y*Q)*U,Z}function Z2(){var Z=new IK(3);if(IK!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function UM1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function Ps(Z,J){var X=J[0],Y=J[1],$=J[2],Q=X*X+Y*Y+$*$;if(Q>0)Q=1/Math.sqrt(Q);return Z[0]=J[0]*Q,Z[1]=J[1]*Q,Z[2]=J[2]*Q,Z}function LM1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=X[3]*Y+X[7]*$+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*Y+X[4]*$+X[8]*Q+X[12])/K,Z[1]=(X[1]*Y+X[5]*$+X[9]*Q+X[13])/K,Z[2]=(X[2]*Y+X[6]*$+X[10]*Q+X[14])/K,Z}function BM1(Z,J,X){var Y=J[0],$=J[1],Q=J[2];return Z[0]=Y*X[0]+$*X[3]+Q*X[6],Z[1]=Y*X[1]+$*X[4]+Q*X[7],Z[2]=Y*X[2]+$*X[5]+Q*X[8],Z}var wM1=UM1;(function(){var Z=Z2();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=3;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2];return J}})();var bJ="dedup",OT={keepUniqueNames:!1,propertyTypes:[a.ACCESSOR,a.MESH,a.TEXTURE,a.MATERIAL,a.SKIN]};function Ds(Z=OT){let J=w7(OT,Z),X=new Set(J.propertyTypes);for(let Y of J.propertyTypes)if(!OT.propertyTypes.includes(Y))throw new Error(`${bJ}: Unsupported deduplication on type "${Y}".`);return mJ(bJ,(Y)=>{let $=Y.getLogger();if(X.has(a.ACCESSOR))jM1(Y);if(X.has(a.TEXTURE))NM1(Y,J);if(X.has(a.MATERIAL))RM1(Y,J);if(X.has(a.MESH))OM1(Y,J);if(X.has(a.SKIN))MM1(Y,J);$.debug(`${bJ}: Complete.`)})}function jM1(Z){let J=Z.getLogger(),X=new Map,Y=new Map,$=new Map,Q=new Map,K=Z.getRoot().listMeshes();K.forEach((F)=>{F.listPrimitives().forEach((z)=>{z.listAttributes().forEach((q)=>W(q,Y)),W(z.getIndices(),X)})});for(let F of Z.getRoot().listAnimations())for(let z of F.listSamplers())W(z.getInput(),$),W(z.getOutput(),Q);function W(F,z){if(!F)return;let q=[F.getCount(),F.getType(),F.getComponentType(),F.getNormalized(),F.getSparse()].join(":"),U=z.get(q);if(!U)z.set(q,U=new Set);U.add(F)}function G(F,z){for(let q=0;q<F.length;q++){let U=F[q],L=n0.toView(U.getArray());if(z.has(U))continue;for(let B=q+1;B<F.length;B++){let w=F[B];if(z.has(w))continue;if(n0.equals(L,n0.toView(w.getArray())))z.set(w,U)}}}let V=0,H=new Map;for(let F of[Y,X,$,Q])for(let z of F.values())V+=z.size,G(Array.from(z),H);J.debug(`${bJ}: Merged ${H.size} of ${V} accessors.`),K.forEach((F)=>{F.listPrimitives().forEach((z)=>{z.listAttributes().forEach((U)=>{if(H.has(U))z.swap(U,H.get(U))});let q=z.getIndices();if(q&&H.has(q))z.swap(q,H.get(q))})});for(let F of Z.getRoot().listAnimations())for(let z of F.listSamplers()){let q=z.getInput(),U=z.getOutput();if(q&&H.has(q))z.swap(q,H.get(q));if(U&&H.has(U))z.swap(U,H.get(U))}Array.from(H.keys()).forEach((F)=>F.dispose())}function OM1(Z,J){let X=Z.getLogger(),Y=Z.getRoot(),$=new Map;Y.listAccessors().forEach((W,G)=>$.set(W,G)),Y.listMaterials().forEach((W,G)=>$.set(W,G));let Q=Y.listMeshes().length,K=new Map;for(let W of Y.listMeshes()){let G=[];for(let H of W.listPrimitives())G.push(Cs(H,$));let V="";if(J.keepUniqueNames)V+=W.getName()+";";if(V+=G.join(";"),K.has(V)){let H=K.get(V);W.listParents().forEach((F)=>{if(F.propertyType!==a.ROOT)F.swap(W,H)}),W.dispose()}else K.set(V,W)}X.debug(`${bJ}: Merged ${Q-K.size} of ${Q} meshes.`)}function NM1(Z,J){let X=Z.getLogger(),Y=Z.getRoot(),$=Y.listTextures(),Q=new Map;for(let K=0;K<$.length;K++){let W=$[K],G=W.getImage();if(Q.has(W))continue;for(let V=K+1;V<$.length;V++){let H=$[V],F=H.getImage();if(Q.has(H))continue;if(W.getMimeType()!==H.getMimeType())continue;if(J.keepUniqueNames&&W.getName()!==H.getName())continue;let z=W.getSize(),q=H.getSize();if(!z||!q)continue;if(z[0]!==q[0])continue;if(z[1]!==q[1])continue;if(!G||!F)continue;if(n0.equals(G,F))Q.set(H,W)}}X.debug(`${bJ}: Merged ${Q.size} of ${Y.listTextures().length} textures.`),Array.from(Q.entries()).forEach(([K,W])=>{K.listParents().forEach((G)=>{if(!(G instanceof MY))G.swap(K,W)}),K.dispose()})}function RM1(Z,J){let X=Z.getLogger(),$=Z.getRoot().listMaterials(),Q=new Map,K=new Map,W=new Set;if(!J.keepUniqueNames)W.add("name");for(let G=0;G<$.length;G++){let V=$[G];if(Q.has(V))continue;if(Zs(V,K))continue;for(let H=G+1;H<$.length;H++){let F=$[H];if(Q.has(F))continue;if(Zs(F,K))continue;if(V.equals(F,W))Q.set(F,V)}}X.debug(`${bJ}: Merged ${Q.size} of ${$.length} materials.`),Array.from(Q.entries()).forEach(([G,V])=>{G.listParents().forEach((H)=>{if(!(H instanceof MY))H.swap(G,V)}),G.dispose()})}function MM1(Z,J){let X=Z.getLogger(),$=Z.getRoot().listSkins(),Q=new Map,K=new Set(["joints"]);if(!J.keepUniqueNames)K.add("name");for(let W=0;W<$.length;W++){let G=$[W];if(Q.has(G))continue;for(let V=W+1;V<$.length;V++){let H=$[V];if(Q.has(H))continue;if(G.equals(H,K)&&JM1(G.listJoints(),H.listJoints()))Q.set(H,G)}}X.debug(`${bJ}: Merged ${Q.size} of ${$.length} skins.`),Array.from(Q.entries()).forEach(([W,G])=>{W.listParents().forEach((V)=>{if(!(V instanceof MY))V.swap(W,G)}),W.dispose()})}function Cs(Z,J){let X=[];for(let Y of Z.listSemantics()){let $=Z.getAttribute(Y);X.push(Y+":"+J.get($))}if(Z instanceof j8){let Y=Z.getIndices();if(Y)X.push("indices:"+J.get(Y));let $=Z.getMaterial();if($)X.push("material:"+J.get($));X.push("mode:"+Z.getMode());for(let Q of Z.listTargets())X.push("target:"+Cs(Q,J))}return X.join(",")}function Zs(Z,J){if(J.has(Z))return J.get(Z);let X=Z.getGraph(),Y=new Set,$=X.listParentEdges(Z);while($.length>0){let Q=$.pop();if(Q.getAttributes().modifyChild===!0)return J.set(Z,!0),!0;let K=Q.getChild();if(Y.has(K))continue;for(let W of X.listChildEdges(K))$.push(W)}return J.set(Z,!1),!1}function Ts(){var Z=new IK(4);if(IK!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function PM1(Z,J,X){return Z[0]=J[0]+X[0],Z[1]=J[1]+X[1],Z[2]=J[2]+X[2],Z[3]=J[3]+X[3],Z}function DM1(Z,J,X){return Z[0]=J[0]-X[0],Z[1]=J[1]-X[1],Z[2]=J[2]-X[2],Z[3]=J[3]-X[3],Z}function CM1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z[3]=J[3]*X[3],Z}function TM1(Z,J,X){return Z[0]=J[0]*X,Z[1]=J[1]*X,Z[2]=J[2]*X,Z[3]=J[3]*X,Z}function EM1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3];return Math.hypot(J,X,Y,$)}var Es=DM1,kM1=CM1,ks=EM1;(function(){var Z=Ts();return function(J,X,Y,$,Q,K){var W,G;if(!X)X=4;if(!Y)Y=0;if($)G=Math.min($*X+Y,J.length);else G=J.length;for(W=Y;W<G;W+=X)Z[0]=J[W],Z[1]=J[W+1],Z[2]=J[W+2],Z[3]=J[W+3],Q(Z,Z,K),J[W]=Z[0],J[W+1]=Z[1],J[W+2]=Z[2],J[W+3]=Z[3];return J}})();var IM1=/color|emissive|diffuse/i;function _M1(Z){return Z.getGraph().listParentEdges(Z).some(($)=>{return $.getAttributes().isColor||IM1.test($.getName())})?"srgb":null}function vM1(Z){let J=Z.getGraph(),X=new Set,Y=new Set;function $(Q){let K=new Set;for(let W of J.listChildEdges(Q))if(W.getChild()instanceof RY)K.add(W.getName()+"Info");for(let W of J.listChildEdges(Q)){let G=W.getChild();if(X.has(G))continue;if(X.add(G),G instanceof P5&&K.has(W.getName()))Y.add(G);else if(G instanceof HK)$(G)}}return $(Z),Array.from(Y)}function SM1(Z){let X=k6.fromGraph(Z.getGraph()).getRoot(),Y=Z.getGraph().listParentEdges(Z).filter(($)=>$.getParent()!==X).map(($)=>$.getName());return Array.from(new Set(Y))}var EK="prune",PT=0.011764705882352941,Js={propertyTypes:[a.NODE,a.SKIN,a.MESH,a.CAMERA,a.PRIMITIVE,a.PRIMITIVE_TARGET,a.ANIMATION,a.MATERIAL,a.TEXTURE,a.ACCESSOR,a.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function J2(Z=Js){let J=w7(Js,Z),X=new Set(J.propertyTypes),Y=J.keepExtras;return mJ(EK,async($)=>{let Q=$.getLogger(),K=$.getRoot(),W=$.getGraph(),G=new Is,V=(H)=>G.dispose(H.target);if(W.addEventListener("node:dispose",V),X.has(a.MESH))for(let H of K.listMeshes()){if(H.listPrimitives().length>0)continue;H.dispose()}if(X.has(a.NODE)){if(!J.keepLeaves)for(let H of K.listScenes())_s(W,H,Y);for(let H of K.listNodes())v9(H,Y)}if(X.has(a.SKIN))for(let H of K.listSkins())v9(H,Y);if(X.has(a.MESH))for(let H of K.listMeshes())v9(H,Y);if(X.has(a.CAMERA))for(let H of K.listCameras())v9(H,Y);if(X.has(a.PRIMITIVE))Xs(W,a.PRIMITIVE,Y);if(X.has(a.PRIMITIVE_TARGET))Xs(W,a.PRIMITIVE_TARGET,Y);if(!J.keepAttributes&&X.has(a.ACCESSOR)){let H=new Map;for(let F of K.listMeshes())for(let z of F.listPrimitives()){let q=z.getMaterial();if(!q)continue;let U=vs($,z,q),L=xM1(z,U);Ys(z,L),z.listTargets().forEach((B)=>Ys(B,L)),H.has(q)?H.get(q).add(z):H.set(q,new Set([z]))}for(let[F,z]of H)hM1(F,Array.from(z))}if(!J.keepIndices&&X.has(a.ACCESSOR))for(let H of K.listMeshes())for(let F of H.listPrimitives())AM1(F);if(X.has(a.ANIMATION))for(let H of K.listAnimations()){for(let F of H.listChannels())if(!F.getTargetNode())F.dispose();if(!H.listChannels().length){let F=H.listSamplers();v9(H,Y),F.forEach((z)=>v9(z,Y))}else H.listSamplers().forEach((F)=>v9(F,Y))}if(X.has(a.MATERIAL))K.listMaterials().forEach((H)=>v9(H,Y));if(X.has(a.TEXTURE)){if(K.listTextures().forEach((H)=>v9(H,Y)),!J.keepSolidTextures)await fM1($)}if(X.has(a.ACCESSOR))K.listAccessors().forEach((H)=>v9(H,Y));if(X.has(a.BUFFER))K.listBuffers().forEach((H)=>v9(H,Y));if(W.removeEventListener("node:dispose",V),!G.empty()){let H=G.entries().map(([F,z])=>`${F} (${z})`).join(", ");Q.info(`${EK}: Removed types... ${H}`)}else Q.debug(`${EK}: No unused properties found.`);Q.debug(`${EK}: Complete.`)})}class Is{constructor(){this.disposed={}}empty(){for(let Z in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(Z){this.disposed[Z.propertyType]=this.disposed[Z.propertyType]||0,this.disposed[Z.propertyType]++}}function v9(Z,J){let X=Z.listParents().filter(($)=>!($ instanceof MY||$ instanceof OY)),Y=J&&!Os(Z.getExtras());if(!X.length&&!Y)Z.dispose()}function Xs(Z,J,X){for(let Y of Z.listEdges()){let $=Y.getParent();if($.propertyType===J)v9($,X)}}function _s(Z,J,X){if(J.listChildren().forEach((K)=>_s(Z,K,X)),J instanceof zK)return;let Y=Z.listParentEdges(J).some((K)=>{let W=K.getParent().propertyType;return W!==a.ROOT&&W!==a.SCENE&&W!==a.NODE}),$=Z.listChildren(J).length===0,Q=X&&!Os(J.getExtras());if($&&!Y&&!Q)J.dispose()}function Ys(Z,J){for(let X of J)Z.setAttribute(X,null)}function AM1(Z){let J=Z.getIndices(),X=J&&J.getArray(),Y=Z.listAttributes()[0];if(!X||!Y)return;if(J.getCount()!==Y.getCount())return;for(let $=0,Q=X.length;$<Q;$++)if($!==X[$])return;Z.setIndices(null)}function xM1(Z,J){let X=[];for(let Y of Z.listSemantics())if(Y==="NORMAL"&&!J.has(Y))X.push(Y);else if(Y==="TANGENT"&&!J.has(Y))X.push(Y);else if(Y.startsWith("TEXCOORD_")&&!J.has(Y))X.push(Y);else if(Y.startsWith("COLOR_")&&Y!=="COLOR_0")X.push(Y);return X}function vs(Z,J,X,Y=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let V of Q)if(V.getChild()instanceof RY)K.add(V.getName());for(let V of Q){let H=V.getName(),F=V.getChild();if(F instanceof P5){if(K.has(H.replace(/Info$/,"")))Y.add(`TEXCOORD_${F.getTexCoord()}`)}if(F instanceof RY&&H.match(/normalTexture/i))Y.add("TANGENT");if(F instanceof HK)vs(Z,J,F,Y)}let W=X instanceof G7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===j8.Mode.POINTS;if(W&&!G)Y.add("NORMAL");return Y}function hM1(Z,J){let X=vM1(Z),Y=new Set(X.map((G)=>G.getTexCoord())),$=Array.from(Y).sort(),Q=new Map($.map((G,V)=>[G,V])),K=new Map($.map((G,V)=>[`TEXCOORD_${G}`,`TEXCOORD_${V}`]));for(let G of X){let V=G.getTexCoord();G.setTexCoord(Q.get(V))}for(let G of J){let V=G.listSemantics().filter((H)=>H.startsWith("TEXCOORD_")).sort();W(G,V),G.listTargets().forEach((H)=>W(H,V))}function W(G,V){for(let H of V){let F=G.getAttribute(H);if(!F)continue;let z=K.get(H);if(z===H)continue;G.setAttribute(z,F),G.setAttribute(H,null)}}}async function fM1(Z){let J=Z.getRoot(),X=Z.getGraph(),Y=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await bM1(K);if(!G)return;if(_M1(K)==="srgb")kD.convertSRGBToLinear(G,G);let V=K.getName()||K.getURI(),H=(W=K.getSize())==null?void 0:W.join("x"),F=SM1(K);for(let z of X.listParentEdges(K)){let q=z.getParent();if(q!==J&&yM1(q,G,z.getName(),Y))z.dispose()}if(K.listParents().length===1)K.dispose(),Y.debug(`${EK}: Removed solid-color texture "${V}" (${H}px ${F.join(", ")})`)});await Promise.all(Q)}function yM1(Z,J,X,Y){if(Z instanceof G7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(kM1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(wM1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=PT;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return ks(Es(Ts(),J,[0.5,0.5,1,1]))<=PT}return Y.warn(`${EK}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function bM1(Z){let J=await gM1(Z);if(!J)return null;let X=[1/0,1/0,1/0,1/0],Y=[-1/0,-1/0,-1/0,-1/0],$=[0,0,0,0],[Q,K]=J.shape;for(let W=0;W<Q;W++){for(let G=0;G<K;G++)for(let V=0;V<4;V++)X[V]=Math.min(X[V],J.get(W,G,V)),Y[V]=Math.max(Y[V],J.get(W,G,V));if(ks(Es($,Y,X))/255>PT)return null}return TM1($,PM1($,Y,X),0.00196078431372549)}async function gM1(Z){try{return await Ba(Z.getImage(),Z.getMimeType())}catch(J){return null}}var yJ=4294967295;class Ss{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of IT(Z))J+=this._initAttribute(X);this.u8=new Uint8Array(J),this.u32=new Uint32Array(this.u8.buffer)}_initAttribute(Z){let J=Z.getArray(),X=new Uint8Array(J.buffer,J.byteOffset,J.byteLength),Y=Z.getElementSize()*Z.getComponentSize(),$=n0.padNumber(Y);return this.attributes.push({u8:X,byteStride:Y,paddedByteStride:$}),$}hash(Z){let J=0;for(let{u8:X,byteStride:Y,paddedByteStride:$}of this.attributes){for(let Q=0;Q<$;Q++)if(Q<Y)this.u8[J+Q]=X[Z*Y+Q];else this.u8[J+Q]=0;J+=$}return mM1(0,this.u32)}equal(Z,J){for(let{u8:X,byteStride:Y}of this.attributes)for(let $=0;$<Y;$++)if(X[Z*Y+$]!==X[J*Y+$])return!1;return!0}}function mM1(Z,J){for(let $=0,Q=J.length;$<Q;$++){let K=J[$];K=Math.imul(K,1540483477)>>>0,K=(K^K>>24)>>>0,K=Math.imul(K,1540483477)>>>0,Z=Math.imul(Z,1540483477)>>>0,Z=(Z^K)>>>0}return Z}function uM1(Z,J,X,Y,$=yJ){let Q=J-1,W=X.hash(Y)&Q;for(let G=0;G<=Q;G++){let V=Z[W];if(V===$||X.equal(V,Y))return W;W=W+G+1&Q}throw new Error("Hash table full.")}var B6;(function(Z){Z.RENDER="render",Z.RENDER_CACHED="render-cached",Z.UPLOAD="upload",Z.UPLOAD_NAIVE="upload-naive",Z.DISTINCT="distinct",Z.DISTINCT_POSITION="distinct-position",Z.UNUSED="unused"})(B6||(B6={}));function gJ(Z,J){let X=Z.getAttribute("POSITION"),Y=Z.getIndices();switch(J){case B6.RENDER:return Y?Y.getCount():X.getCount();case B6.RENDER_CACHED:return Y?new Set(Y.getArray()).size:X.getCount();case B6.UPLOAD_NAIVE:case B6.UPLOAD:return X.getCount();case B6.DISTINCT:case B6.DISTINCT_POSITION:return dM1(J);case B6.UNUSED:return Y?X.getCount()-new Set(Y.getArray()).size:0;default:return cM1(J)}}function dM1(Z){throw new Error(`Not implemented: ${Z}`)}function cM1(Z){throw new Error(`Unexpected value: ${Z}`)}function EV(Z,J,X){let Y=k6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=lM1(Z);let $=Z.getIndices(),Q=$?$.getArray():null,K=gJ(Z,B6.RENDER),W=Y.createAccessor(),G=K,V=_T(G,X);for(let F=0;F<G;F++)V[F]=J[Q?Q[F]:F];Z.setIndices(W.setArray(V));let H=IT(Z);for(let F of Z.listAttributes()){let z=RZ(Y,F);DT(F,$,J,z,X),Z.swap(F,z)}for(let F of Z.listTargets())for(let z of F.listAttributes()){let q=RZ(Y,z);DT(z,$,J,q,X),F.swap(z,q)}if($&&$.listParents().length===1)$.dispose();for(let F of H)if(F.listParents().length===1)F.dispose();return Z}function DT(Z,J,X,Y,$){let Q=Z.getElementSize(),K=Z.getArray(),W=J?J.getArray():null,G=J?J.getCount():Z.getCount(),V=new K.constructor($*Q),H=new Uint8Array($);for(let F=0;F<G;F++){let z=W?W[F]:F,q=X[z];if(H[q])continue;for(let U=0;U<Q;U++)V[q*Q+U]=K[z*Q+U];H[q]=1}return Y.setArray(V)}function lM1(Z){let J=gJ(Z,B6.UPLOAD),X=Z.getIndices(),Y=X?X.getArray():null;if(!X||!Y)return[XM1(J,1e6),J];let $=new Uint32Array(J).fill(yJ),Q=0;for(let K=0;K<Y.length;K++){let W=Y[K];if($[W]===yJ)$[W]=Q++}return[$,Q]}var CT="weld",oB={overwrite:!0,cleanup:!0};function vT(Z=oB){let J=w7(oB,Z);return mJ(CT,async(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes()){for(let Q of $.listPrimitives())if(X2(Q,J),gJ(Q,B6.RENDER)===0)Q.dispose();if($.listPrimitives().length===0)$.dispose()}if(J.cleanup)await X.transform(J2({propertyTypes:[a.ACCESSOR,a.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),Ds({propertyTypes:[a.ACCESSOR]}));Y.debug(`${CT}: Complete.`)})}function X2(Z,J=oB){let X=Z.getGraph(),$=k6.fromGraph(X).getLogger(),Q=kK({},oB,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===j8.Mode.POINTS)return;let K=Z.getAttribute("POSITION").getCount(),W=Z.getIndices(),G=W==null?void 0:W.getArray(),V=W?W.getCount():K,H=new Ss(Z),F=$M1(K+K/4),z=new Uint32Array(F).fill(yJ),q=new Uint32Array(K).fill(yJ),U=0;for(let L=0;L<V;L++){let B=G?G[L]:L;if(q[B]!==yJ)continue;let w=uM1(z,F,H,B,yJ),O=z[w];if(O===yJ)z[w]=B,q[B]=U++;else q[B]=q[O]}$.debug(`${CT}: ${eB(K,U)} vertices.`),EV(Z,q,U)}var{FLOAT:pM1}=I0.ComponentType;function As(Z,J){let X=Z.getAttribute("POSITION");if(X)$s(J,X);let Y=Z.getAttribute("NORMAL");if(Y)Qs(J,Y);let $=Z.getAttribute("TANGENT");if($)Ks(J,$);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)$s(J,K);let W=Q.getAttribute("NORMAL");if(W)Qs(J,W);let G=Q.getAttribute("TANGENT");if(G)Ks(J,G)}if(VM1(J)<0)iM1(Z)}function $s(Z,J){let X=J.getComponentType(),Y=J.getNormalized(),$=J.getArray(),Q=X===pM1?$:new Float32Array($.length),K=Z2();for(let W=0,G=J.getCount();W<G;W++){if(Y)K[0]=c0.decodeNormalizedInt($[W*3],X),K[1]=c0.decodeNormalizedInt($[W*3+1],X),K[2]=c0.decodeNormalizedInt($[W*3+2],X);else K[0]=$[W*3],K[1]=$[W*3+1],K[2]=$[W*3+2];LM1(K,K,Z),Q[W*3]=K[0],Q[W*3+1]=K[1],Q[W*3+2]=K[2]}J.setArray(Q).setNormalized(!1)}function Qs(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=HM1();zM1(Q,Z),qM1(Q,Q),FM1(Q,Q);let K=Z2();for(let W=0,G=J.getCount();W<G;W++){if(Y)K[0]=c0.decodeNormalizedInt(X[W*3],$),K[1]=c0.decodeNormalizedInt(X[W*3+1],$),K[2]=c0.decodeNormalizedInt(X[W*3+2],$);else K[0]=X[W*3],K[1]=X[W*3+1],K[2]=X[W*3+2];if(BM1(K,K,Q),Ps(K,K),Y)X[W*3]=c0.decodeNormalizedInt(K[0],$),X[W*3+1]=c0.decodeNormalizedInt(K[1],$),X[W*3+2]=c0.decodeNormalizedInt(K[2],$);else X[W*3]=K[0],X[W*3+1]=K[1],X[W*3+2]=K[2]}}function Ks(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=Z2();for(let K=0,W=J.getCount();K<W;K++){if(Y)Q[0]=c0.decodeNormalizedInt(X[K*4],$),Q[1]=c0.decodeNormalizedInt(X[K*4+1],$),Q[2]=c0.decodeNormalizedInt(X[K*4+2],$);else Q[0]=X[K*4],Q[1]=X[K*4+1],Q[2]=X[K*4+2];if(Q[0]=Z[0]*Q[0]+Z[4]*Q[1]+Z[8]*Q[2],Q[1]=Z[1]*Q[0]+Z[5]*Q[1]+Z[9]*Q[2],Q[2]=Z[2]*Q[0]+Z[6]*Q[1]+Z[10]*Q[2],Ps(Q,Q),Y)X[K*4]=c0.decodeNormalizedInt(Q[0],$),X[K*4+1]=c0.decodeNormalizedInt(Q[1],$),X[K*4+2]=c0.decodeNormalizedInt(Q[2],$);else X[K*4]=Q[0],X[K*4+1]=Q[1],X[K*4+2]=Q[2]}}function iM1(Z){if(Z.getMode()!==j8.Mode.TRIANGLES)return;if(!Z.getIndices())X2(Z);let J=Z.getIndices();for(let X=0,Y=J.getCount();X<Y;X+=3){let $=J.getScalar(X),Q=J.getScalar(X+2);J.setScalar(X,Q),J.setScalar(X+2,$)}}function nM1(Z,J){for(let X of Z.listPrimitives()){let Y=aM1(X,Z);if(X!==Y)Z.removePrimitive(X).addPrimitive(Y)}for(let X of Z.listPrimitives())EV(X),As(X,J)}function aM1(Z,J){if(Z.listParents().some((Y)=>Y instanceof YV&&Y!==J))Z=Z.clone();for(let Y of Z.listTargets())if(Y.listParents().some((Q)=>Q instanceof j8&&Q!==Z))Z.removeTarget(Y).addTarget(Y.clone());return Z}var Ws=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function xs(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!c0.eq(X,Ws))nM1(J,X);for(let Y of Z.listChildren()){let $=Y.getMatrix();Ms($,$,X),Y.setMatrix($)}return Z.setMatrix(Ws)}var{LINES:sM1,LINE_STRIP:oM1,LINE_LOOP:rM1,TRIANGLES:tM1,TRIANGLE_STRIP:eM1,TRIANGLE_FAN:ZP1}=j8.Mode;function JP1(Z){let J=Z.getGraph(),X=k6.fromGraph(J);if(!Z.getIndices())X2(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=js(Z),W=new kJ[Y.getComponentType()](Q*2),G=Z.getMode();if(G===oM1)for(let H=0;H<Q;H++)W[H*2]=$[H],W[H*2+1]=$[H+1];else if(G===rM1)for(let H=0;H<Q;H++)if(H<Q-1)W[H*2]=$[H],W[H*2+1]=$[H+1];else W[H*2]=$[H],W[H*2+1]=$[0];else throw new Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(sM1);let V=X.getRoot();if(Y.listParents().some((H)=>H!==V&&H!==Z))Z.setIndices(RZ(X,Y).setArray(W));else Y.setArray(W)}function hs(Z){let J=Z.getGraph(),X=k6.fromGraph(J);if(!Z.getIndices())X2(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=js(Z),W=new kJ[Y.getComponentType()](Q*3),G=Z.getMode();if(G===eM1)for(let H=0,F=$.length;H<F-2;H++)if(H%2)W[H*3]=$[H+1],W[H*3+1]=$[H],W[H*3+2]=$[H+2];else W[H*3]=$[H],W[H*3+1]=$[H+1],W[H*3+2]=$[H+2];else if(G===ZP1)for(let H=0;H<Q;H++)W[H*3]=$[0],W[H*3+1]=$[H+1],W[H*3+2]=$[H+2];else throw new Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(tM1);let V=X.getRoot();if(Y.listParents().some((H)=>H!==V&&H!==Z))Z.setIndices(RZ(X,Y).setArray(W));else Y.setArray(W)}var Gs="dequantize",rB={pattern:/^((?!JOINTS_).)*$/};function fs(Z=rB){let J=w7(rB,Z);return mJ(Gs,(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes())for(let Q of $.listPrimitives())XP1(Q,J);X.createExtension(CV).dispose(),Y.debug(`${Gs}: Complete.`)})}function XP1(Z,J=rB){let X=w7(rB,J);for(let Y of Z.listSemantics())if(X.pattern.test(Y))TT(Z.getAttribute(Y));for(let Y of Z.listTargets())for(let $ of Y.listSemantics())if(X.pattern.test($))TT(Y.getAttribute($))}function TT(Z){let J=Z.getArray();if(!J)return;let X=tB(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function tB(Z,J,X){let Y=new Float32Array(Z.length);for(let $=0,Q=Z.length;$<Q;$++)if(X)Y[$]=c0.decodeNormalizedInt(Z[$],J);else Y[$]=Z[$];return Y}var{TEXTURE_INFO:ys,ROOT:tT6}=a;function bs(Z){let J=new k6().setLogger(Z.getLogger()),X=ST(J,Z);return YP1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function YP1(Z,J,X){X||(X=ST(Z,J));for(let Y of J.getRoot().listExtensionsUsed()){let $=Z.createExtension(Y.constructor);if(Y.isRequired())$.setRequired(!0)}return $P1(Z,J,QP1(J),X)}function $P1(Z,J,X,Y){Y||(Y=ST(Z,J));let $=new Map;for(let Q of X)if(!$.has(Q)&&Q.propertyType!==ys)$.set(Q,Y(Q));for(let[Q,K]of $.entries())K.copy(Q,Y);return $}function ST(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return(Y)=>{if(Y.propertyType===ys)return Y;let $=X.get(Y);if(!$)$=new Y.constructor(Z.getGraph()),X.set(Y,$);return $}}function QP1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}var NT="flatten",Vs={cleanup:!0};function gs(Z=Vs){let J=w7(Vs,Z);return mJ(NT,async(X)=>{let Y=X.getRoot(),$=X.getLogger(),Q=new Set;for(let V of Y.listSkins())for(let H of V.listJoints())Q.add(H);let K=new Set;for(let V of Y.listAnimations())for(let H of V.listChannels()){let F=H.getTargetNode();if(F&&H.getTargetPath()!=="weights")K.add(F)}let W=new Set,G=new Set;for(let V of Y.listScenes())V.traverse((H)=>{let F=H.getParentNode();if(!F)return;if(Q.has(F)||W.has(F))W.add(H);if(K.has(F)||G.has(F))G.add(H)});for(let V of Y.listScenes())V.traverse((H)=>{if(K.has(H))return;if(W.has(H))return;if(G.has(H))return;WM1(H)});if(K.size)$.debug(`${NT}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(J2({propertyTypes:[a.NODE],keepLeaves:!1}));$.debug(`${NT}: Complete.`)})}function ms(Z){return ED(Z)}var KP1={skipValidation:!1},Hs=4294967295,{LINE_STRIP:WP1,LINE_LOOP:GP1,TRIANGLE_STRIP:VP1,TRIANGLE_FAN:HP1}=j8.Mode;function zP1(Z,J={}){let X=w7(KP1,J),Y=Z[0],$=k6.fromGraph(Y.getGraph());if(!X.skipValidation&&new Set(Z.map(Ns)).size>1)throw new Error("Requires >=2 Primitives, sharing the same Material and Mode, with compatible vertex attributes and indices.");for(let q of Z)switch(q.getMode()){case WP1:case GP1:JP1(q);break;case VP1:case HP1:hs(q);break}let Q=[],K=new Uint32Array(Z.length),W=0,G=0;for(let q=0;q<Z.length;q++){let U=Z[q],L=U.getIndices(),B=U.getAttribute("POSITION").getCount(),w=L?L.getArray():null,O=L?L.getCount():B,N=new Uint32Array(B).fill(Hs);for(let R=0;R<O;R++){let D=w?w[R]:R;if(N[D]===Hs)N[D]=W++,K[q]++}Q.push(N),G+=O}let V=$.createPrimitive().setMode(Y.getMode()).setMaterial(Y.getMaterial());for(let q of Y.listSemantics()){let U=Y.getAttribute(q),L=kJ[U.getComponentType()],B=RZ($,U).setArray(new L(W*U.getElementSize()));V.setAttribute(q,B)}let H=Y.getIndices(),F=H?RZ($,H).setArray(_T(G,W)):null;V.setIndices(F);let z=0;for(let q=0;q<Q.length;q++){let U=Z[q],L=U.getIndices(),B=L?L.getCount():-1,w=Q[q];if(L&&F)qP1(L,w,F,z),z+=B;for(let O of V.listSemantics()){let N=U.getAttribute(O),R=V.getAttribute(O);FP1(N,L,w,R)}}return V}function FP1(Z,J,X,Y){let $=Z.getElementSize(),Q=J?J.getArray():null,K=Z.getCount(),W=Z.getArray(),G=Y.getArray(),V=new Uint8Array(Z.getCount());for(let H=0,F=J?J.getCount():K;H<F;H++){let z=Q?Q[H]:H,q=X[z];if(V[q])continue;for(let U=0;U<$;U++)G[q*$+U]=W[z*$+U];V[q]=1}}function qP1(Z,J,X,Y){let $=Z.getCount(),Q=Z.getArray(),K=X.getArray();for(let W=0;W<$;W++){let G=Q[W],V=J[G];K[Y+W]=V}}var ET="join",{ROOT:UP1,NODE:LP1,MESH:BP1,PRIMITIVE:wP1,ACCESSOR:jP1}=a,RT=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],zs={keepMeshes:!1,keepNamed:!1,cleanup:!0};function us(Z=zs){let J=w7(zs,Z);return mJ(ET,async(X)=>{let Y=X.getRoot(),$=X.getLogger();for(let Q of Y.listScenes())Fs(X,Q,J),Q.traverse((K)=>Fs(X,K,J));if(J.cleanup)await X.transform(J2({propertyTypes:[LP1,BP1,wP1,jP1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));$.debug(`${ET}: Complete.`)})}function Fs(Z,J,X){let Y=Z.getLogger(),$={},Q=J.listChildren();for(let G=0;G<Q.length;G++){let V=Q[G];if(V.listParents().some((z)=>z instanceof OY))continue;let F=V.getMesh();if(!F)continue;if(V.getExtension("EXT_mesh_gpu_instancing"))continue;if(V.getSkin())continue;for(let z of F.listPrimitives()){if(z.listTargets().length>0)continue;let q=z.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;EV(z),NP1(z);let U=Ns(z),L=F.getName()||V.getName();if(X.keepMeshes||X.keepNamed&&L)U+=`|${G}`;if(!(U in $))$[U]={prims:[],primMeshes:[],primNodes:[],dstNode:V,dstMesh:void 0};let B=$[U];B.prims.push(z),B.primNodes.push(V)}}let K=Object.values($).filter(({prims:G})=>G.length>1),W=new Set(K.flatMap((G)=>G.primNodes));for(let G of W){let V=G.getMesh();if(V.listParents().some((F)=>{return F.propertyType!==UP1&&G!==F}))G.setMesh(V.clone())}for(let G of K){let{dstNode:V,primNodes:H}=G;G.dstMesh=V.getMesh(),G.primMeshes=H.map((F)=>F.getMesh())}for(let G of K){let{prims:V,primNodes:H,primMeshes:F,dstNode:z,dstMesh:q}=G,U=z.getMatrix();for(let w=0;w<V.length;w++){let O=H[w],N=F[w],R=V[w];if(N.removePrimitive(R),YM1(R))R=V[w]=OP1(V[w]);if(O!==z)Ms(RT,GM1(RT,U),O.getMatrix()),As(R,RT)}let L=zP1(V),B=L.listAttributes()[0].getCount();q.addPrimitive(L),Y.debug(`${ET}: Joined Primitives (${V.length}) containing ${MT(B)} vertices under Node "${z.getName()}".`)}}function OP1(Z){let J=Z.clone();for(let Y of J.listSemantics())J.setAttribute(Y,J.getAttribute(Y).clone());let X=J.getIndices();if(X)J.setIndices(X.clone());return J}function NP1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)TT(X)}}var{TRANSLATION:eT6,ROTATION:ZE6,SCALE:JE6,WEIGHTS:XE6}=OY.TargetPath;var RP1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var YE6=kK({level:"high"},RP1);var MP1="unweld";function PP1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let Y=Z.getGraph(),$=k6.fromGraph(Y),Q=$.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,qs($,G,X,J)),G.listParents().length===1)G.dispose();for(let G of Z.listTargets())for(let V of G.listAttributes())if(G.swap(V,qs($,V,X,J)),V.listParents().length===1)V.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${MP1}: ${eB(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function qs(Z,J,X,Y){if(Y.has(J)&&Y.get(J).has(X))return Y.get(J).get(X);let $=J.getArray(),K=new $.constructor(X.getCount()*J.getElementSize()),W=X.getArray(),G=J.getElementSize();for(let H=0,F=X.getCount();H<F;H++)for(let z=0;z<G;z++)K[H*G+z]=$[W[H]*G+z];if(!Y.has(J))Y.set(J,new Map);let V=RZ(Z,J).setArray(K);return Y.get(J).set(X,V),V}var Us;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(Us||(Us={}));var DP1=0.000001;function CP1(Z,J,X,Y=0.0001){let $=J.length/Z.length,Q=new Array($).fill(0),K=new Array($).fill(0),W=new Array($).fill(0),G=new Array($).fill(0),V=Z.length-1,H=1;for(let F=1;F<V;++F){let z=Z[H-1],q=Z[F],U=Z[F+1],L=(q-z)/(U-z),B=!1;if(q!==U&&(F!==1||q!==Z[0])){if(TV(J,H-1,G),TV(J,F,K),TV(J,F+1,W),X==="slerp"){let w=kP1(Q,G,W,L),O=Bs(G,K)+Bs(K,W);B=!sB(K,w,Y)||O+Number.EPSILON>=Math.PI}else if(X==="lerp"){let w=EP1(Q,G,W,L);B=!sB(K,w,Y)}else if(X==="step")B=!sB(K,G)||!sB(K,W)}if(B){if(F!==H)Z[H]=Z[F],Ls(J,H,TV(J,F,Q));H++}}if(V>0)Z[H]=Z[V],Ls(J,H,TV(J,V,Q)),H++;return H}function TV(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)X[Y]=Z[J*$+Y];return X}function Ls(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)Z[J*$+Y]=X[Y]}function sB(Z,J,X=0){if(Z.length!==J.length)return!1;for(let Y=0;Y<Z.length;Y++)if(Math.abs(Z[Y]-J[Y])>X)return!1;return!0}function TP1(Z,J,X){return Z*(1-X)+J*X}function EP1(Z,J,X,Y){for(let $=0;$<J.length;$++)Z[$]=TP1(J[$],X[$],Y);return Z}function kP1(Z,J,X,Y){let $=J[0],Q=J[1],K=J[2],W=J[3],G=X[0],V=X[1],H=X[2],F=X[3],z,q,U,L,B;if(q=$*G+Q*V+K*H+W*F,q<0)q=-q,G=-G,V=-V,H=-H,F=-F;if(1-q>DP1)z=Math.acos(q),U=Math.sin(z),L=Math.sin((1-Y)*z)/U,B=Math.sin(Y*z)/U;else L=1-Y,B=Y;return Z[0]=L*$+B*G,Z[1]=L*Q+B*V,Z[2]=L*K+B*H,Z[3]=L*W+B*F,Z}function Bs(Z,J){let X=IP1(Z,J);return Math.acos(2*X*X-1)}function IP1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var $E6=new Float32Array(0),QE6={ready:Promise.resolve(),resample:CP1,tolerance:0.0001,cleanup:!0};var dY="simplify",{POINTS:ds,LINES:_P1,LINE_STRIP:vP1,LINE_LOOP:SP1,TRIANGLES:AP1,TRIANGLE_STRIP:cs,TRIANGLE_FAN:ls}=j8.Mode,ps={ratio:0,error:0.0001,lockBorder:!1,cleanup:!0};function is(Z){let J=w7(ps,Z),X=J.simplifier;if(!X)throw new Error(`${dY}: simplifier dependency required — install "meshoptimizer".`);return mJ(dY,async(Y)=>{let $=Y.getLogger();await X.ready,await Y.transform(vT({overwrite:!1,cleanup:J.cleanup}));let Q=0;for(let K of Y.getRoot().listMeshes()){for(let W of K.listPrimitives()){let G=W.getMode();if(G===AP1||G===cs||G===ls){if(ws(W,J),gJ(W,B6.RENDER)===0)W.dispose()}else if(W.getMode()===ds&&!!X.simplifyPoints){if(ws(W,J),gJ(W,B6.RENDER)===0)W.dispose()}else Q++}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)$.warn(`${dY}: Skipping simplification of ${Q} primitives: Unsupported draw mode.`);if(J.cleanup)await Y.transform(J2({propertyTypes:[a.ACCESSOR,a.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),Ds({propertyTypes:[a.ACCESSOR]}));$.debug(`${dY}: Complete.`)})}function ws(Z,J){let X=kK({},ps,J),Y=X.simplifier,$=Z.getGraph(),Q=k6.fromGraph($),K=Q.getLogger();switch(Z.getMode()){case ds:return xP1(Q,Z,X);case _P1:case vP1:case SP1:return K.warn(`${dY}: Skipping primitive simplification: Unsupported draw mode.`),Z;case cs:case ls:hs(Z);break}let W=gJ(Z,B6.UPLOAD),G=gJ(Z,B6.RENDER);if(G<W/2)EV(Z);let V=Z.getAttribute("POSITION"),H=Z.getIndices(),F=V.getArray(),z=H.getArray();if(!(F instanceof Float32Array))F=tB(F,V.getComponentType(),V.getNormalized());if(!(z instanceof Uint32Array))z=new Uint32Array(z);let q=Math.floor(X.ratio*G/3)*3,U=X.lockBorder?["LockBorder"]:[],[L,B]=Y.simplify(z,F,3,q,X.error,U);if(Z.setIndices(RZ(Q,H).setArray(L)),H.listParents().length===1)H.dispose();EV(Z);let w=gJ(Z,B6.UPLOAD);if(w<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${dY}: ${eB(W,w)} vertices, error: ${B.toFixed(4)}.`),Z}function xP1(Z,J,X){let Y=X.simplifier,$=Z.getLogger();if(J.getIndices())PP1(J);let K=J.getAttribute("POSITION"),W=J.getAttribute("COLOR_0"),G=K.getCount(),V=K.getArray(),H=W?W.getArray():void 0,F=W?W.getComponentSize():void 0;if(!(V instanceof Float32Array))V=tB(V,K.getComponentType(),K.getNormalized());if(H&&!(H instanceof Float32Array))H=tB(H,K.getComponentType(),K.getNormalized());Y.useExperimentalFeatures=!0;let z=Math.floor(X.ratio*G),q=Y.simplifyPoints(V,3,z,H,F);Y.useExperimentalFeatures=!1;let[U,L]=Y.compactMesh(q);$.debug(`${dY}: ${eB(K.getCount(),L)} vertices.`);for(let B of IT(J)){let w=RZ(Z,B);if(DT(B,null,U,w,L),ZM1(J,B,w),B.listParents().length===1)B.dispose()}return J}var kT;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(kT||(kT={}));var KE6={resizeFilter:kT.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var es=r(ts(),1);var _K={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DIRECTORIES:[(()=>{try{return t5.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))}catch{return null}})(),t5.resolve(process.cwd(),"assets")].filter(Boolean),OPTIMIZER_RUNS:[{suffix:"",options:["--compress","false","--instance","false","--simplify","false"]},{suffix:"-named-nodes",options:["--compress","false","--instance","false","--simplify","false","--join","true","--join-named","false"]}]};class E5{static instance=new E5;optimize=!0;optimizeEveryStart=!1;_modelUriDocuments=new Map;_modelUriBoundingBoxes=new Map;_modelUriNodeNames=new Map;_modelUriTrimeshes=new Map;constructor(){}async preloadModels(){let Z=await this._getAbsoluteModelPaths();console.log(`ModelRegistry.preloadModels(): Preloading ${Z.length} models...`);for(let J of Z){if(this.optimize)await this._resolveOptimizedModelPath(J);await this._loadModelData(J)}console.log(`ModelRegistry.preloadModels(): Preloaded ${Z.length} models!`)}getAnimationNames(Z){let J=this._modelUriDocuments.get(Z);if(!J)u.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J.getRoot().listAnimations().map((Y)=>Y.getName())}getBoundingBox(Z){let J=this._modelUriBoundingBoxes.get(Z);if(!J)u.fatalError(`ModelRegistry.getBoundingBox(): Model ${Z} not found!`);return J}getDepth(Z){let J=this.getBoundingBox(Z);return J.max.z-J.min.z}getHeight(Z){let J=this.getBoundingBox(Z);return J.max.y-J.min.y}getNodeNames(Z){let J=this._modelUriNodeNames.get(Z);if(!J)u.fatalError(`ModelRegistry.getNodeNames(): Model ${Z} not found!`);return J}getTrimesh(Z,J=1){let X=this._modelUriTrimeshes.get(Z);if(!X){u.error(`ModelRegistry.getTrimesh(): Model ${Z} not found!`);return}let Y=X.vertices;if(J!==1){Y=new Float32Array(Y.length);for(let $=0;$<Y.length;$++)Y[$]=X.vertices[$]*J}return{vertices:Y,indices:X.indices}}getWidth(Z){let J=this.getBoundingBox(Z);return J.max.x-J.min.x}modelHasNode(Z,J){let X=this._modelUriNodeNames.get(Z);if(!X)u.fatalError(`ModelRegistry.modelHasNode(): Model ${Z} not found!`);return X.includes(J)}_absoluteModelPathToModelUri(Z){let J=t5.normalize(Z);for(let X of _K.DIRECTORIES){let Y=t5.normalize(X);if(J.startsWith(Y))return t5.relative(Y,J).replace(/\\/g,"/")}return t5.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of _K.DIRECTORIES){let X=t5.resolve(process.cwd(),J);if(!uJ.existsSync(X))continue;let Y=await cL("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let $ of Y)Z.push(t5.join(X,$))}return Z}async _loadModelData(Z){let J=await new AD().read(Z),X=ms(J.getRoot().listScenes()[0]),Y=J.getRoot().listNodes().map((Q)=>Q.getName()),$=this._absoluteModelPathToModelUri(Z);this._modelUriDocuments.set($,J),this._modelUriBoundingBoxes.set($,{min:{x:X.min[0],y:X.min[1],z:X.min[2]},max:{x:X.max[0],y:X.max[1],z:X.max[2]}}),this._modelUriNodeNames.set($,Y),this._modelUriTrimeshes.set($,await this._buildTrimesh($))}async _resolveOptimizedModelPath(Z){let J=this._buildOptimizedModelPath(Z);if(!this.optimizeEveryStart&&this._isOptimizedVersionValid(Z))return J;return await this._optimizeModel(Z,J)}_isOptimizedVersionValid(Z){let J=`${this._buildOptimizedModelPath(Z)}${_K.CHECKSUM_EXT}`;if(!uJ.existsSync(J))return!1;let X=this._calculateChecksum(Z),Y=uJ.readFileSync(J,"utf8");return X===Y}_calculateChecksum(Z){if(!uJ.existsSync(Z))return"";let J=uJ.readFileSync(Z);return gP1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=t5.basename(Z),X=J.replace(/\.[^/.]+$/,""),Y=t5.dirname(Z),$=t5.join(Y,_K.OPTIMIZED_DIR,X);return t5.join($,J)}async _buildTrimesh(Z,J=1,X=0.001){let Y=this._modelUriDocuments.get(Z);if(!Y)u.fatalError(`ModelRegistry._buildTrimesh(): Model ${Z} not found!`);let $=bs(Y);$.setLogger(new D5(JV.WARN)),await $.transform(Rs({pivot:"center"}),gs(),us(),vT(),is({simplifier:es.MeshoptSimplifier,ratio:J,error:X}),fs());for(let V of $.getRoot().listScenes())for(let H of V.listChildren())xs(H);let Q=$.getRoot().listMeshes()[0];if(!Q){u.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root mesh!`);return}let K=Q.listPrimitives()[0];if(!K){u.error(`ModelRegistry._buildTrimesh(): Model ${Z} has no root primitive!`);return}let W=K.getAttribute("POSITION"),G=K.getIndices();if(!W||!G){u.error(`ModelRegistry._buildTrimesh(): Model ${Z} missing required geometry data!`);return}return{vertices:W.getArray(),indices:G.getArray()}}async _optimizeModel(Z,J){let X=t5.dirname(J);uJ.rmSync(X,{recursive:!0,force:!0}),uJ.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let Y of _K.OPTIMIZER_RUNS){let $=J.replace(/(\.[^/.]+)$/,`${Y.suffix}$1`),{stderr:Q}=await Zl("npx",["gltf-transform","optimize",Z,$,...Y.options]);if(Q)return u.warning(`ModelRegistry._optimizeModel(): Error optimizing model ${this._absoluteModelPathToModelUri(Z)}, defaulting to unoptimized model. Error: ${Q}`),Z}return uJ.writeFileSync(`${J}${_K.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var MZ=r(gQ(),1);var SV;(($)=>{$.DYNAMIC="dynamic";$.FIXED="fixed";$.KINEMATIC_POSITION="kinematic_position";$.KINEMATIC_VELOCITY="kinematic_velocity"})(SV||={});var yT=0.001,Zo="dynamic";class cY extends B0{_additionalMass=0;_colliders=new Set;_explicitSleep=!1;_enabledPositions={x:!0,y:!0,z:!0};_enabledRotations={x:!0,y:!0,z:!0};_rigidBody;_rigidBodyDesc;_rigidBodyType;_simulation;constructor(Z){super();Z.type??=Zo,this._rigidBodyDesc=this._createRigidBodyDesc(Z),this._rigidBodyType=Z.type,this._applyRigidBodyOptions(Z),this._autoAddToSimulation(Z)}get additionalMass(){if(!this._requireNotRemoved("additionalMass"))return 0;return this._additionalMass}get additionalSolverIterations(){if(!this._requireNotRemoved("additionalSolverIterations"))return 0;return this._rigidBody?this._rigidBody.additionalSolverIterations():this._rigidBodyDesc.additionalSolverIterations}get angularDamping(){if(!this._requireNotRemoved("angularDamping"))return 0;return this._rigidBody?this._rigidBody.angularDamping():this._rigidBodyDesc.angularDamping}get angularVelocity(){if(!this._requireNotRemoved("angularVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.angvel():this._rigidBodyDesc.angvel}get colliders(){return this._colliders}get dominanceGroup(){if(!this._requireNotRemoved("dominanceGroup"))return 0;return this._rigidBody?this._rigidBody.dominanceGroup():this._rigidBodyDesc.dominanceGroup}get directionFromRotation(){let{x:Z,y:J,z:X,w:Y}=this.rotation;return{x:-2*(Z*X+Y*J),y:-2*(J*X-Y*Z),z:-(1-2*(Z*Z+J*J))}}get effectiveAngularInertia(){if(!this._requireNotRemoved("effectiveAngularInertia"))return;return this._rigidBody?this._rigidBody.effectiveAngularInertia():void 0}get effectiveInverseMass(){if(!this._requireNotRemoved("effectiveInverseMass"))return;return this._rigidBody?this._rigidBody.effectiveInvMass():void 0}get effectiveWorldInversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("effectiveWorldInversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.effectiveWorldInvInertiaSqrt():void 0}get enabledRotations(){if(!this._requireNotRemoved("enabledRotations"))return{x:!0,y:!0,z:!0};return this._enabledRotations}get enabledPositions(){if(!this._requireNotRemoved("enabledPositions"))return{x:!0,y:!0,z:!0};return this._enabledPositions}get gravityScale(){if(!this._requireNotRemoved("gravityScale"))return 0;return this._rigidBody?this._rigidBody.gravityScale():this._rigidBodyDesc.gravityScale}get inverseMass(){if(!this._requireNotRemoved("inverseMass"))return;return this._rigidBody?this._rigidBody.invMass():void 0}get inversePrincipalAngularInertiaSqrt(){if(!this._requireNotRemoved("inversePrincipalAngularInertiaSqrt"))return;return this._rigidBody?this._rigidBody.invPrincipalInertiaSqrt():void 0}get isCcdEnabled(){if(!this._requireNotRemoved("isCcdEnabled"))return!1;return this._rigidBody?this._rigidBody.isCcdEnabled():this._rigidBodyDesc.ccdEnabled}get isDynamic(){if(!this._requireNotRemoved("isDynamic"))return!1;return this._rigidBodyType==="dynamic"}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._rigidBody?this._rigidBody.isEnabled():this._rigidBodyDesc.enabled}get isFixed(){if(!this._requireNotRemoved("isFixed"))return!1;return this._rigidBodyType==="fixed"}get isKinematic(){if(!this._requireNotRemoved("isKinematic"))return!1;return["kinematic_position","kinematic_velocity"].includes(this._rigidBodyType)}get isKinematicPositionBased(){if(!this._requireNotRemoved("isKinematicPositionBased"))return!1;return this._rigidBodyType==="kinematic_position"}get isKinematicVelocityBased(){if(!this._requireNotRemoved("isKinematicVelocityBased"))return!1;return this._rigidBodyType==="kinematic_velocity"}get isMoving(){if(!this._requireNotRemoved("isMoving"))return!1;return this._rigidBody?this._rigidBody.isMoving():!1}get isRemoved(){return!this._rigidBody&&!this._rigidBodyDesc}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return this._rigidBody?!0:!1}get isSleeping(){if(!this._requireNotRemoved("isSleeping"))return!1;return this._rigidBody?this._rigidBody.isSleeping():this._rigidBodyDesc.sleeping}get linearDamping(){if(!this._requireNotRemoved("linearDamping"))return 0;return this._rigidBody?this._rigidBody.linearDamping():this._rigidBodyDesc.linearDamping}get linearVelocity(){if(!this._requireNotRemoved("linearVelocity"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.linvel():this._rigidBodyDesc.linvel}get localCenterOfMass(){if(!this._requireNotRemoved("localCenterOfMass"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.localCom():this._rigidBodyDesc.centerOfMass}get mass(){if(!this._requireNotRemoved("mass"))return 0;return this._rigidBody?this._rigidBody.mass():this._rigidBodyDesc.mass}get nextKinematicRotation(){if(!this._requireNotRemoved("nextKinematicRotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.nextRotation():this._rigidBodyDesc.rotation}get nextKinematicPosition(){if(!this._requireNotRemoved("nextKinematicPosition"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.nextTranslation():this._rigidBodyDesc.translation}get numColliders(){return this._colliders.size}get principalAngularInertia(){if(!this._requireNotRemoved("principalAngularInertia"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.principalInertia():this._rigidBodyDesc.principalAngularInertia}get principalAngularInertiaLocalFrame(){if(!this._requireNotRemoved("principalAngularInertiaLocalFrame"))return;return this._rigidBody?this._rigidBody.principalInertiaLocalFrame():void 0}get position(){if(!this._requireNotRemoved("position"))return{x:0,y:0,z:0};return this._rigidBody?this._rigidBody.translation():this._rigidBodyDesc.translation}get rawRigidBody(){if(!this._requireNotRemoved("rawRigidBody"))return;return this._rigidBody}get rotation(){if(!this._requireNotRemoved("rotation"))return{x:0,y:0,z:0,w:1};return this._rigidBody?this._rigidBody.rotation():this._rigidBodyDesc.rotation}get softCcdPrediction(){if(!this._requireNotRemoved("softCcdPrediction"))return 0;return this._rigidBody?this._rigidBody.softCcdPrediction():this._rigidBodyDesc.softCcdPrediction}get type(){if(!this._requireNotRemoved("type"))return"dynamic";return this._rigidBodyType}get worldCenterOfMass(){if(!this._requireNotRemoved("worldCenterOfMass"))return;return this._rigidBody?this._rigidBody.worldCom():void 0}setAdditionalMass(Z){if(!this._requireDynamic("setAdditionalMass"))return;if(!this._requireNotRemoved("setAdditionalMass"))return;this._rigidBody?this._rigidBody.setAdditionalMass(Z,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMass(Z)}setAdditionalMassProperties(Z){if(!this._requireDynamic("setAdditionalMassProperties"))return;if(!this._requireNotRemoved("setAdditionalMassProperties"))return;let{additionalMass:J,centerOfMass:X,principalAngularInertia:Y,principalAngularInertiaLocalFrame:$}=Z;this._rigidBody?this._rigidBody.setAdditionalMassProperties(J,X,Y,$,!this._explicitSleep):this._rigidBodyDesc.setAdditionalMassProperties(J,X,Y,$)}setAdditionalSolverIterations(Z){if(!this._requireDynamic("setAdditionalSolverIterations"))return;if(!this._requireNotRemoved("setAdditionalSolverIterations"))return;this._rigidBody?this._rigidBody.setAdditionalSolverIterations(Z):this._rigidBodyDesc.setAdditionalSolverIterations(Z)}setAngularDamping(Z){if(!this._requireDynamic("setAngularDamping"))return;if(!this._requireNotRemoved("setAngularDamping"))return;this._rigidBody?this._rigidBody.setAngularDamping(Z):this._rigidBodyDesc.setAngularDamping(Z)}setAngularVelocity(Z){if(!this._requireNotKinematicPositionBased("setAngularVelocity"))return;if(!this._requireNotRemoved("setAngularVelocity"))return;this._rigidBody?this._rigidBody.setAngvel(Z,!this._explicitSleep):this._rigidBodyDesc.setAngvel(Z)}setCcdEnabled(Z){if(!this._requireDynamic("setCcdEnabled"))return;if(!this._requireNotRemoved("setCcdEnabled"))return;this._rigidBody?this._rigidBody.enableCcd(Z):this._rigidBodyDesc.setCcdEnabled(Z)}setDominanceGroup(Z){if(!this._requireDynamic("setDominanceGroup"))return;if(!this._requireNotRemoved("setDominanceGroup"))return;this._rigidBody?this._rigidBody.setDominanceGroup(Z):this._rigidBodyDesc.setDominanceGroup(Z)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._rigidBody?this._rigidBody.setEnabled(Z):this._rigidBodyDesc.setEnabled(Z)}setEnabledPositions(Z){if(!this._requireDynamic("setEnabledPositions"))return;if(!this._requireNotRemoved("setEnabledPositions"))return;this._rigidBody?this._rigidBody.setEnabledTranslations(Z.x,Z.y,Z.z,!this._explicitSleep):this._rigidBodyDesc.enabledTranslations(Z.x,Z.y,Z.z),this._enabledPositions=Z}setEnabledRotations(Z){if(!this._requireDynamic("setEnabledRotations"))return;if(!this._requireNotRemoved("setEnabledRotations"))return;this._rigidBody?this._rigidBody.setEnabledRotations(Z.x,Z.y,Z.z,!this._explicitSleep):this._rigidBodyDesc.enabledRotations(Z.x,Z.y,Z.z),this._enabledRotations=Z}setGravityScale(Z){if(!this._requireDynamic("setGravityScale"))return;if(!this._requireNotRemoved("setGravityScale"))return;this._rigidBody?this._rigidBody.setGravityScale(Z,!this._explicitSleep):this._rigidBodyDesc.setGravityScale(Z)}setLinearDamping(Z){if(!this._requireDynamic("setLinearDamping"))return;if(!this._requireNotRemoved("setLinearDamping"))return;this._rigidBody?this._rigidBody.setLinearDamping(Z):this._rigidBodyDesc.setLinearDamping(Z)}setLinearVelocity(Z){if(!this._requireNotKinematicPositionBased("setLinearVelocity"))return;if(!this._requireNotRemoved("setLinearVelocity"))return;this._rigidBody?this._rigidBody.setLinvel(Z,!this._explicitSleep):this._rigidBodyDesc.setLinvel(Z.x,Z.y,Z.z)}setNextKinematicRotation(Z){if(!this._requireKinematic("setNextKinematicRotation"))return;if(!this._requireNotRemoved("setNextKinematicRotation"))return;this._rigidBody?this._rigidBody.setNextKinematicRotation(Z):this._rigidBodyDesc.setRotation(Z)}setNextKinematicPosition(Z){if(!this._requireKinematic("setNextKinematicPosition"))return;if(!this._requireNotRemoved("setNextKinematicPosition"))return;this._rigidBody?this._rigidBody.setNextKinematicTranslation(Z):this._rigidBodyDesc.setTranslation(Z.x,Z.y,Z.z)}setPosition(Z){if(!this._requireNotRemoved("setPosition"))return;this._rigidBody?this._rigidBody.setTranslation(Z,!this._explicitSleep):this._rigidBodyDesc.setTranslation(Z.x,Z.y,Z.z)}setRotation(Z){if(!this._requireNotRemoved("setRotation"))return;this._rigidBody?this._rigidBody.setRotation(Z,!this._explicitSleep):this._rigidBodyDesc.setRotation(Z)}setSleeping(Z){if(!this._requireDynamic("setSleeping"))return;if(!this._requireNotRemoved("setSleeping"))return;this._rigidBody?Z?this._rigidBody.sleep():this._rigidBody.wakeUp():this._rigidBodyDesc.sleeping=Z,this._explicitSleep=Z}setSoftCcdPrediction(Z){if(!this._requireDynamic("setSoftCcdPrediction"))return;if(!this._requireNotRemoved("setSoftCcdPrediction"))return;this._rigidBody?this._rigidBody.setSoftCcdPrediction(Z):this._rigidBodyDesc.setSoftCcdPrediction(Z)}setCollisionGroupsForSolidColliders(Z){if(!this._requireNotRemoved("setCollisionGroupsForSolidColliders"))return;this._colliders.forEach((J)=>{if(J.isSensor)return;J.setCollisionGroups(Z)})}setCollisionGroupsForSensorColliders(Z){if(!this._requireNotRemoved("setCollisionGroupsForSensorColliders"))return;this._colliders.forEach((J)=>{if(!J.isSensor)return;J.setCollisionGroups(Z)})}setType(Z){if(!this._requireNotRemoved("setType"))return;let X={["dynamic"]:MZ.default.RigidBodyType.Dynamic,["fixed"]:MZ.default.RigidBodyType.Fixed,["kinematic_position"]:MZ.default.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:MZ.default.RigidBodyType.KinematicVelocityBased}[Z];if(X===void 0)return u.error(`Invalid RigidBodyType: ${Z}`);this._rigidBody?this._rigidBody.setBodyType(X,!this._explicitSleep):this._rigidBodyDesc.status=X,this._rigidBodyType=Z}addForce(Z){if(!this._requireNotRemoved("addForce"))return;if(!this._requireCreated("addForce"))return;if(!this._requireDynamic("addForce"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.addForce(Z,!this._explicitSleep)}addTorque(Z){if(!this._requireNotRemoved("addTorque"))return;if(!this._requireCreated("addTorque"))return;if(!this._requireDynamic("addTorque"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.addTorque(Z,!this._explicitSleep)}addChildColliderToSimulation(Z){if(!this._requireNotRemoved("addChildColliderToSimulation"))return;if(!this._requireCreated("addChildColliderToSimulation"))return;Z.addToSimulation(this._simulation,this)}addToSimulation(Z){if(!this._requireNotRemoved("addToSimulation"))return;if(this._rigidBody)return u.error("RigidBody.addToSimulation(): Rigid body already exists in the simulation!");this._simulation=Z,this._rigidBody=this._simulation.createRawRigidBody(this._rigidBodyDesc),this._colliders.forEach((J)=>{if(!J.isSimulated)J.addToSimulation(Z,this)})}applyImpulse(Z){if(!this._requireNotRemoved("applyImpulse"))return;if(!this._requireCreated("applyImpulse"))return;if(!this._requireDynamic("applyImpulse"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.applyImpulse(Z,!this._explicitSleep)}applyImpulseAtPoint(Z,J){if(!this._requireNotRemoved("applyImpulseAtPoint"))return;if(!this._requireCreated("applyImpulseAtPoint"))return;if(!this._requireDynamic("applyImpulseAtPoint"))return;if(this._isNegligibleVector(Z))return;this._rigidBody.applyImpulseAtPoint(Z,J,!this._explicitSleep)}applyTorqueImpulse(Z){if(!this._requireNotRemoved("applyTorqueImpulse"))return;if(!this._requireCreated("applyTorqueImpulse"))return;if(!this._requireDynamic("applyTorqueImpulse"))return;this._rigidBody.applyTorqueImpulse(Z,!this._explicitSleep)}createAndAddChildCollider(Z){if(!this._requireNotRemoved("createAndAddChildCollider"))return null;return this._simulation?new e5({...Z,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(Z)}createAndAddChildColliders(Z){let J=[];return Z.forEach((X)=>{let Y=this.createAndAddChildCollider(X);if(Y)J.push(Y)}),J}getCollidersByTag(Z){let J=[];for(let X of this._colliders)if(X.tag===Z)J.push(X);return J}linkCollider(Z){if(!this._requireNotRemoved("linkCollider"))return;if(Z.parentRigidBody!==this)return u.error("RigidBody.linkCollider(): Collider cannot be linked because it is not a child of this rigid body!");this._colliders.add(Z)}lockAllRotations(){if(!this._requireNotRemoved("lockAllRotations"))return;this.setEnabledRotations({x:!1,y:!1,z:!1})}lockAllPositions(){if(!this._requireNotRemoved("lockAllPositions"))return;this.setEnabledPositions({x:!1,y:!1,z:!1})}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._rigidBody)return u.error("RigidBody.removeFromSimulation(): Rigid body does not exist in the simulation!");this._colliders.forEach((Z)=>{Z.removeFromSimulation()}),this._simulation.removeRawRigidBody(this._rigidBody),this._simulation=void 0,this._rigidBody=void 0}unlinkCollider(Z){if(!this._requireNotRemoved("unlinkCollider"))return;if(!Z.isRemoved)return u.error("RigidBody.unlinkCollider(): Collider is still simulated and therefore cannot be unlinked from this rigid body!");this._colliders.delete(Z)}resetAngularVelocity(){if(!this._requireNotRemoved("resetAngularVelocity"))return;if(!this._requireCreated("resetAngularVelocity"))return;this.setAngularVelocity({x:0,y:0,z:0})}resetForces(){if(!this._requireNotRemoved("resetForces"))return;if(!this._requireCreated("resetForces"))return;this._rigidBody.resetForces(!this._explicitSleep)}resetLinearVelocity(){if(!this._requireNotRemoved("resetLinearVelocity"))return;if(!this._requireCreated("resetLinearVelocity"))return;this.setLinearVelocity({x:0,y:0,z:0})}resetTorques(){if(!this._requireNotRemoved("resetTorques"))return;if(!this._requireCreated("resetTorques"))return;this._rigidBody.resetTorques(!this._explicitSleep)}sleep(){if(!this._requireNotRemoved("sleep"))return;this.setSleeping(!0)}wakeUp(){if(!this._requireNotRemoved("wakeUp"))return;this.setSleeping(!1)}_applyRigidBodyOptions(Z){[["additionalMass",this.setAdditionalMass.bind(this)],["additionalMassProperties",this.setAdditionalMassProperties.bind(this)],["additionalSolverIterations",this.setAdditionalSolverIterations.bind(this)],["angularDamping",this.setAngularDamping.bind(this)],["angularVelocity",this.setAngularVelocity.bind(this)],["dominanceGroup",this.setDominanceGroup.bind(this)],["ccdEnabled",this.setCcdEnabled.bind(this)],["enabled",this.setEnabled.bind(this)],["enabledPositions",this.setEnabledPositions.bind(this)],["enabledRotations",this.setEnabledRotations.bind(this)],["gravityScale",this.setGravityScale.bind(this)],["linearDamping",this.setLinearDamping.bind(this)],["linearVelocity",this.setLinearVelocity.bind(this)],["position",this.setPosition.bind(this)],["rotation",this.setRotation.bind(this)],["sleeping",this.setSleeping.bind(this)],["softCcdPrediction",this.setSoftCcdPrediction.bind(this)]].forEach(([X,Y])=>{if(X in Z)Y(Z[X])})}_autoAddToSimulation(Z){if(Z.colliders)this._createAndAddPendingChildColliders(Z.colliders);if(Z.simulation)this.addToSimulation(Z.simulation)}_createAndAddPendingChildCollider(Z){if(!this._requireNotRemoved("createAndAddPendingChildCollider"))return null;if(!this._requireNotSimulated("createAndAddPendingChildCollider"))return null;let J=new e5(Z);return this._colliders.add(J),J}_createAndAddPendingChildColliders(Z){let J=[];return Z.forEach((X)=>{let Y=this._createAndAddPendingChildCollider(X);if(Y)J.push(Y)}),J}_createRigidBodyDesc(Z){let J=Z.type??Zo;return{["dynamic"]:()=>MZ.default.RigidBodyDesc.dynamic(),["fixed"]:()=>MZ.default.RigidBodyDesc.fixed(),["kinematic_position"]:()=>MZ.default.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>MZ.default.RigidBodyDesc.kinematicVelocityBased()}[J]()}_requireCreated(Z){if(!this._rigidBody||!this._simulation)u.error(`RigidBody._requireCreated(): Rigid body has not been created and therefore does not support the invoked method: ${Z}()`);return!!this._rigidBody&&!!this._simulation}_requireDynamic(Z){if(!this.isDynamic)u.error(`RigidBody._requireDynamic(): Rigid body is not dynamic and therefore does not support the invoked method: ${Z}()`);return this.isDynamic}_requireKinematic(Z){if(!this.isKinematic)u.error(`RigidBody._requireKinematic(): Rigid body is not kinematic and therefore does not support the invoked method: ${Z}()`);return this.isKinematic}_requireNotKinematicPositionBased(Z){if(this.isKinematicPositionBased)u.error(`RigidBody._requireNotKinematicPositionBased(): Rigid body is kinematic position based and therefore does not support the invoked method: ${Z}()`);return!this.isKinematicPositionBased}_requireNotRemoved(Z){if(!this._rigidBody&&!this._rigidBodyDesc)u.error(`RigidBody._requireNotRemoved(): Rigid body has been removed and therefore does not support the invoked method: ${Z}()`);return!!this._rigidBody||!!this._rigidBodyDesc}_requireNotSimulated(Z){if(this.isSimulated)u.error(`RigidBody._requireNotSimulated(): Rigid body is simulated and therefore does not support the invoked method: ${Z}()`);return!this.isSimulated}_isNegligibleVector(Z){return Math.abs(Z.x)<yT&&Math.abs(Z.y)<yT&&Math.abs(Z.z)<yT}}var bT;(($)=>{$[$.Average=0]="Average";$[$.Min=1]="Min";$[$.Multiply=2]="Multiply";$[$.Max=3]="Max"})(bT||={});var AV;((V)=>{V.NONE="none";V.BALL="ball";V.BLOCK="block";V.CAPSULE="capsule";V.CONE="cone";V.CYLINDER="cylinder";V.ROUND_CYLINDER="round-cylinder";V.TRIMESH="trimesh";V.WEDGE="wedge"})(AV||={});class e5 extends B0{_collider;_colliderDesc;_onCollision;_parentRigidBody;_relativePosition={x:0,y:0,z:0};_relativeRotation={x:0,y:0,z:0,w:1};_shape;_simulation;_tag;constructor(Z){super();this._colliderDesc=this._createColliderDesc(Z),this._shape=Z.shape,this._applyColliderOptions(Z),this._autoAddToSimulation(Z)}static optionsFromBlockHalfExtents(Z){return{shape:"block",halfExtents:Z}}static optionsFromModelUri(Z,J=1,X){let Y=E5.instance.getBoundingBox(Z),$=Y.max.x-Y.min.x,Q=Y.max.y-Y.min.y,K=Y.max.z-Y.min.z,W=Math.max($,K),G=Math.min($,K),V=W/G,H=W/Q,F=W*J/2,z=(O)=>Math.max(0.01,O),q=()=>({shape:"block",halfExtents:{x:z($*J/2),y:z(Q*J/2),z:z(K*J/2)}}),U=()=>({shape:"round-cylinder",radius:z(F),halfHeight:z(Q*J/2),borderRadius:z(F*0.1)}),L=()=>{let O=E5.instance.getTrimesh(Z,J);if(!O)return;return{shape:"trimesh",vertices:O.vertices,indices:O.indices}},B=()=>({shape:"wedge",extents:{x:$*J,y:Q*J,z:K*J}}),w=()=>({shape:"capsule",radius:z(F),halfHeight:z(Q*J/2-F)});if(X)switch(X){case"block":return q();case"capsule":return w();case"round-cylinder":return U();case"trimesh":{let O=L();if(!O){u.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return O}case"wedge":return B();default:u.warning(`Collider.optionsFromModelUri(): Preferred shape ${X} is not yet supported with Collider.optionsFromModelUri(), defaulting to generic shape!`)}if(V>2)return q();if(H>1.5)return U();return w()}get bounciness(){if(!this._requireNotRemoved("bounciness"))return 0;return this._collider?this._collider.restitution():this._colliderDesc.restitution}get bouncinessCombineRule(){if(!this._requireNotRemoved("bouncinessCombineRule"))return 0;return this._collider?this._collider.restitutionCombineRule():this._colliderDesc.restitutionCombineRule}get collisionGroups(){if(!this._requireNotRemoved("collisionGroups"))return{belongsTo:[],collidesWith:[]};return this._collider?z4.decodeRawCollisionGroups(this._collider.collisionGroups()):z4.decodeRawCollisionGroups(this._colliderDesc.collisionGroups)}get friction(){if(!this._requireNotRemoved("friction"))return 0;return this._collider?this._collider.friction():this._colliderDesc.friction}get frictionCombineRule(){if(!this._requireNotRemoved("frictionCombineRule"))return 0;return this._collider?this._collider.frictionCombineRule():this._colliderDesc.frictionCombineRule}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._collider?this._collider.isEnabled():this._colliderDesc.enabled}get isRemoved(){return!this._collider&&!this._colliderDesc}get isSensor(){if(!this._requireNotRemoved("isSensor"))return!1;return this._collider?this._collider.isSensor():this._colliderDesc.isSensor}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return!!this._collider}get parentRigidBody(){if(!this._requireNotRemoved("parentRigidBody"))return;return this._parentRigidBody}get rawCollider(){if(!this._requireNotRemoved("rawCollider"))return;return this._collider}get rawShape(){if(!this._requireNotRemoved("rawShape"))return;return this._collider?this._collider.shape:this._colliderDesc.shape}get relativePosition(){if(!this._requireNotRemoved("relativePosition"))return{x:0,y:0,z:0};return this._relativePosition}get relativeRotation(){if(!this._requireNotRemoved("relativeRotation"))return{x:0,y:0,z:0,w:1};return this._relativeRotation}get shape(){if(!this._requireNotRemoved("shape"))return"none";return this._shape}get tag(){if(!this._requireNotRemoved("tag"))return;return this._tag}setBounciness(Z){if(!this._requireNotRemoved("setBounciness"))return;this._collider?this._collider.setRestitution(Z):this._colliderDesc.setRestitution(Z)}setBouncinessCombineRule(Z){if(!this._requireNotRemoved("setBouncinessCombineRule"))return;this._collider?this._collider.setRestitutionCombineRule(Z):this._colliderDesc.setRestitutionCombineRule(Z)}setCollisionGroups(Z){if(!this._requireNotRemoved("setCollisionGroups"))return;let J=z4.buildRawCollisionGroups(Z);this._collider?this._collider.setCollisionGroups(J):this._colliderDesc.setCollisionGroups(J)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._collider?this._collider.setEnabled(Z):this._colliderDesc.setEnabled(Z)}setFriction(Z){if(!this._requireNotRemoved("setFriction"))return;this._collider?this._collider.setFriction(Z):this._colliderDesc.setFriction(Z)}setFrictionCombineRule(Z){if(!this._requireNotRemoved("setFrictionCombineRule"))return;this._collider?this._collider.setFrictionCombineRule(Z):this._colliderDesc.setFrictionCombineRule(Z)}setMass(Z){if(!this._requireNotRemoved("setMass"))return;this._collider?this._collider.setMass(Z):this._colliderDesc.setMass(Z)}setOnCollision(Z){if(!this._requireNotRemoved("setOnCollision"))return;if(this._onCollision=Z,this.isSimulated)if(this.enableCollisionEvents(!!Z),Z)this._simulation.colliderMap.setColliderCollisionCallback(this,Z);else this._simulation.colliderMap.removeColliderCollisionCallback(this)}setRelativeRotation(Z){if(!this._requireNotRemoved("setRelativeRotation"))return;this._relativeRotation=Z,this._collider?this._collider.parent()?this._collider.setRotationWrtParent(Z):this._collider.setRotation(Z):this._colliderDesc.setRotation(Z)}setRelativePosition(Z){if(!this._requireNotRemoved("setRelativePosition"))return;this._relativePosition=Z,this._collider?this._collider.parent()?this._collider.setTranslationWrtParent(Z):this._collider.setTranslation(Z):this._colliderDesc.setTranslation(Z.x,Z.y,Z.z)}setSensor(Z){if(!this._requireNotRemoved("setSensor"))return;this._collider?this._collider.setSensor(Z):this._colliderDesc.setSensor(Z)}setTag(Z){if(!this._requireNotRemoved("setTag"))return;this._tag=Z}addToSimulation(Z,J){if(!this._requireNotRemoved("addToSimulation"))return;if(!this._requireUnsimulated("addToSimulation"))return;if(J){if(!J.isSimulated)return u.error("Collider.addToSimulation(): Rigid body must be simulated before adding a collider to it!");if(J.type==="dynamic"&&this.shape==="trimesh")u.warning("Collider.addToSimulation(): Trimesh colliders are strongly discouraged to be used with dynamic rigid bodies, they will not contribute any mass!")}if(this._simulation=Z,this._parentRigidBody=J,this._collider=this._simulation.createRawCollider(this._colliderDesc,J?.rawRigidBody),this._colliderDesc=void 0,J)J.linkCollider(this);if(this._onCollision)this.setOnCollision(this._onCollision)}scale(Z){if(!this._requireNotRemoved("scale"))return;switch(this.setRelativePosition({x:this.relativePosition.x*Z,y:this.relativePosition.y*Z,z:this.relativePosition.z*Z}),this._shape){case"ball":{if(this._collider)this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.radius*=Z;return}case"block":{if(this._collider){let J=this._collider.halfExtents();this._collider.setHalfExtents({x:J.x*Z,y:J.y*Z,z:J.z*Z})}else this._colliderDesc.shape.halfExtents.x*=Z,this._colliderDesc.shape.halfExtents.y*=Z,this._colliderDesc.shape.halfExtents.z*=Z;return}case"capsule":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cone":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"round-cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRoundRadius(this._collider.roundRadius()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight=this._colliderDesc.shape.halfHeight*Z,this._colliderDesc.shape.borderRadius=this._colliderDesc.shape.borderRadius*Z,this._colliderDesc.shape.radius=this._colliderDesc.shape.radius*Z;return}case"trimesh":{u.error("Collider.setScale(): Trimesh colliders cannot be scaled!");return}case"wedge":{u.error("Collider.setScale(): Wedge colliders cannot be scaled!");return}default:u.fatalError(`Collider.setScale(): ${this._shape} is not a valid collider shape!`)}}enableCollisionEvents(Z){if(!this._requireNotRemoved("enableCollisionEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|e8.default.ActiveEvents.COLLISION_EVENTS:J&~e8.default.ActiveEvents.COLLISION_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}enableContactForceEvents(Z){if(!this._requireNotRemoved("enableContactForceEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|e8.default.ActiveEvents.CONTACT_FORCE_EVENTS:J&~e8.default.ActiveEvents.CONTACT_FORCE_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}removeFromSimulation(){if(!this._requireNotRemoved("removeFromSimulation"))return;if(!this._requireSimulated("removeFromSimulation"))return;if(this._simulation.removeRawCollider(this._collider),this._simulation=void 0,this._collider=void 0,this._parentRigidBody)this._parentRigidBody.unlinkCollider(this);this._parentRigidBody=void 0}_applyColliderOptions(Z){[["bounciness",this.setBounciness.bind(this)],["bouncinessCombineRule",this.setBouncinessCombineRule.bind(this)],["collisionGroups",this.setCollisionGroups.bind(this)],["enabled",this.setEnabled.bind(this)],["friction",this.setFriction.bind(this)],["frictionCombineRule",this.setFrictionCombineRule.bind(this)],["isSensor",this.setSensor.bind(this)],["mass",this.setMass.bind(this)],["onCollision",this.setOnCollision.bind(this)],["relativePosition",this.setRelativePosition.bind(this)],["relativeRotation",this.setRelativeRotation.bind(this)],["tag",this.setTag.bind(this)]].forEach(([X,Y])=>{if(Z[X]!==void 0)Y.call(this,Z[X])})}_autoAddToSimulation(Z){if(Z.simulation)this.addToSimulation(Z.simulation,Z.parentRigidBody)}_buildWedgeConvexHullVertices(Z){let{x:J,y:X,z:Y}=Z,$=J/2,Q=Y/2,K=X/2;return new Float32Array([-$,0-K,-Q,$,0-K,-Q,$,0-K,Q,-$,0-K,Q,-$,X-K,-Q,$,X-K,-Q])}_createColliderDesc(Z){let{shape:J,flags:X}=Z;switch(J){case"ball":{if(!Z.radius)u.fatalError("Ball collider must have a radius!");return e8.default.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)u.fatalError("Block collider must have halfExtents!");return e8.default.ColliderDesc.cuboid(Z.halfExtents.x,Z.halfExtents.y,Z.halfExtents.z)}case"capsule":{if(!Z.halfHeight||!Z.radius)u.fatalError("Capsule collider must have halfHeight and radius!");return e8.default.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)u.fatalError("Cone collider must have radius and halfHeight!");return e8.default.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)u.fatalError("Cylinder collider must have radius and halfHeight!");return e8.default.ColliderDesc.cylinder(Z.halfHeight,Z.radius)}case"round-cylinder":{if(!Z.radius||!Z.halfHeight||!Z.borderRadius)u.fatalError("Round cylinder collider must have radius, halfHeight, and borderRadius!");return e8.default.ColliderDesc.roundCylinder(Z.halfHeight,Z.radius,Z.borderRadius)}case"trimesh":{if(!Z.indices||!Z.vertices)u.fatalError("Trimesh collider must have vertices and indices!");return e8.default.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"wedge":{if(!Z.extents)u.fatalError("Wedge collider must have extents!");let Y=this._buildWedgeConvexHullVertices(Z.extents),$=e8.default.ColliderDesc.convexHull(Y);if(!$)throw u.fatalError("Failed to create convex hull for wedge collider!"),new Error("Convex hull creation failed");return $}default:u.fatalError(`Collider._createColliderDesc(): ${J} is not a valid collider shape!`)}}_requireSimulated(Z){if(!this.isSimulated)u.error(`Collider._requireSimulated(): Collider is not simulated, invoked method: ${Z}()`);return this.isSimulated}_requireUnsimulated(Z){if(this.isSimulated)u.error(`Collider._requireUnsimulated(): Collider is already simulated, invoked method: ${Z}()`);return!this.isSimulated}_requireNotRemoved(Z){if(this.isRemoved)u.error(`Collider._requireNotRemoved(): Collider is removed, invoked method: ${Z}()`);return!this.isRemoved}_setActiveCollisionTypes(){(this._collider??this._colliderDesc).setActiveCollisionTypes(e8.default.ActiveCollisionTypes.DYNAMIC_DYNAMIC|e8.default.ActiveCollisionTypes.DYNAMIC_KINEMATIC|e8.default.ActiveCollisionTypes.DYNAMIC_FIXED|e8.default.ActiveCollisionTypes.KINEMATIC_KINEMATIC|e8.default.ActiveCollisionTypes.KINEMATIC_FIXED)}}var mP1={shape:"trimesh",flags:Jo.TriMeshFlags.FIX_INTERNAL_EDGES},uP1=new Uint32Array([0,1,2,2,3,0,4,5,6,6,7,4,8,9,10,10,11,8,12,13,14,14,15,12,16,17,18,18,19,16,20,21,22,22,23,20]),dP1=new Float32Array([-0.5,-0.5,0.5,0.5,-0.5,0.5,0.5,0.5,0.5,-0.5,0.5,0.5,-0.5,-0.5,-0.5,0.5,-0.5,-0.5,0.5,0.5,-0.5,-0.5,0.5,-0.5,-0.5,0.5,-0.5,0.5,0.5,-0.5,0.5,0.5,0.5,-0.5,0.5,0.5,-0.5,-0.5,-0.5,0.5,-0.5,-0.5,0.5,-0.5,0.5,-0.5,-0.5,0.5,0.5,-0.5,-0.5,0.5,0.5,-0.5,0.5,0.5,0.5,0.5,-0.5,0.5,-0.5,-0.5,-0.5,-0.5,0.5,-0.5,-0.5,0.5,0.5,-0.5,-0.5,0.5]),gT;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(gT||={});class Z9 extends B0{_id;_customColliderOptions;_isLiquid;_name;_textureUri;constructor(Z={id:-1,textureUri:"textures/missing.png",name:"Unknown"}){if(Z.id<0)u.fatalError("BlockType.constructor(): BlockType id not set.");super();this._id=Z.id,this._customColliderOptions=Z.customColliderOptions,this._isLiquid=Z.isLiquid??!1,this._name=Z.name,this._textureUri=Z.textureUri}get id(){return this._id}get colliderOptions(){return{...this._customColliderOptions,...mP1}}get isLiquid(){return this._isLiquid}get isMeshable(){return!this._customColliderOptions}get name(){return this._name}get textureUri(){return this._textureUri}createCollider(Z=uP1,J=dP1){let X=new e5({...this.colliderOptions,indices:Z,vertices:J});if(this.isLiquid)X.setSensor(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_COLLISION")||this.isLiquid)X.enableCollisionEvents(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))X.enableContactForceEvents(!0);if(z4.isDefaultCollisionGroups(X.collisionGroups))X.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return X}serialize(){return M0.serializeBlockType(this)}}var mT;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(mT||={});class xV extends B0{_blockTypes=new Map;_world;constructor(Z){super();this._world=Z}get world(){return this._world}getAllBlockTypes(){return Array.from(this._blockTypes.values())}getBlockType(Z){let J=this._blockTypes.get(Z);if(!J)u.fatalError(`BlockTypeRegistry.getBlockType(): BlockType with id ${Z} not found.`);return J}registerGenericBlockType(Z){let X=new class extends Z9{constructor(Y=Z){super(Y)}};return this.registerBlockType(X),X}registerBlockType(Z){this._blockTypes.set(Z.id,Z),this.emitWithWorld(this._world,"BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE",{blockTypeRegistry:this,id:Z.id,blockType:Z})}serialize(){return M0.serializeBlockTypeRegistry(this)}}var wk={};Pq(wk,{worldSchema:()=>Bk,worldPacketDefinition:()=>s00,vectorSchema:()=>$1,vectorBooleanSchema:()=>mv1,uiSchema:()=>Uk,uiPacketDefinition:()=>n00,uiDatasSchema:()=>Lk,uiDatasPacketDefinition:()=>a00,uiDataSendPacketDefinition:()=>S00,uiDataSchema:()=>$H,syncResponseSchema:()=>qk,syncResponsePacketDefinition:()=>i00,syncRequestSchema:()=>uE,syncRequestPacketDefinition:()=>v00,stateRequestSchema:()=>mE,stateRequestPacketDefinition:()=>_00,sceneUIsSchema:()=>Fk,sceneUIsPacketDefinition:()=>p00,sceneUISchema:()=>zk,rgbColorSchema:()=>A6,registeredPackets:()=>i2,quaternionSchema:()=>eE,playersSchema:()=>Hk,playersPacketDefinition:()=>l00,playerSchema:()=>Vk,physicsDebugRenderSchema:()=>Gk,physicsDebugRenderPacketDefinition:()=>d00,physicsDebugRaycastsSchema:()=>Wk,physicsDebugRaycastsPacketDefinition:()=>c00,physicsDebugRaycastSchema:()=>Kk,particleEmittersSchema:()=>Qk,particleEmittersPacketDefinition:()=>u00,particleEmitterSchema:()=>$k,outboundPackets:()=>p2,modelNodeOverrideSchema:()=>tE,lightsSchema:()=>Yk,lightsPacketDefinition:()=>m00,lightSchema:()=>Xk,isValidPacket:()=>dv1,inputSchema:()=>gE,inputPacketDefinition:()=>I00,inboundPackets:()=>l2,hexColorSchema:()=>yE,heartbeatSchema:()=>fE,heartbeatPacketDefinition:()=>T00,entitySchema:()=>Zk,entitiesSchema:()=>Jk,entitiesPacketDefinition:()=>g00,definePacket:()=>C0,debugConfigSchema:()=>bE,debugConfigPacketDefinition:()=>k00,createPacket:()=>_v1,connectionSchema:()=>hE,connectionPacketDefinition:()=>C00,chunksSchema:()=>rE,chunksPacketDefinition:()=>b00,chunkSchema:()=>oE,chatMessagesSchema:()=>sE,chatMessagesPacketDefinition:()=>y00,chatMessageSendPacketDefinition:()=>E00,chatMessageSchema:()=>YH,cameraSchema:()=>aE,cameraPacketDefinition:()=>f00,blocksSchema:()=>pE,blocksPacketDefinition:()=>x00,blockTypesSchema:()=>nE,blockTypesPacketDefinition:()=>h00,blockTypeSchema:()=>iE,blockSchema:()=>lE,bidirectionalPackets:()=>c2,audiosSchema:()=>cE,audiosPacketDefinition:()=>A00,audioSchema:()=>dE,PacketId:()=>I1});var c2={};Pq(c2,{heartbeatPacketDefinition:()=>T00,connectionPacketDefinition:()=>C00});var AE=r(P00(),1);class xE extends AE.default{static instance=new AE.default}var I1;((E)=>{E[E.SYNC_REQUEST=0]="SYNC_REQUEST";E[E.INPUT=1]="INPUT";E[E.STATE_REQUEST=2]="STATE_REQUEST";E[E.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";E[E.UI_DATA_SEND=4]="UI_DATA_SEND";E[E.SYNC_RESPONSE=32]="SYNC_RESPONSE";E[E.AUDIOS=33]="AUDIOS";E[E.BLOCKS=34]="BLOCKS";E[E.BLOCK_TYPES=35]="BLOCK_TYPES";E[E.CHAT_MESSAGES=36]="CHAT_MESSAGES";E[E.CHUNKS=37]="CHUNKS";E[E.ENTITIES=38]="ENTITIES";E[E.WORLD=39]="WORLD";E[E.CAMERA=40]="CAMERA";E[E.UI=41]="UI";E[E.UI_DATAS=42]="UI_DATAS";E[E.SCENE_UIS=43]="SCENE_UIS";E[E.LIGHTS=44]="LIGHTS";E[E.PLAYERS=45]="PLAYERS";E[E.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";E[E.CONNECTION=116]="CONNECTION";E[E.HEARTBEAT=117]="HEARTBEAT";E[E.DEBUG_CONFIG=128]="DEBUG_CONFIG";E[E.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";E[E.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(I1||={});function _v1(Z,J,X){if(!Z.validate(J))throw new Error(`Invalid payload for packet with id ${Z.id}. Error: ${xE.instance.errorsText(Z.validate.errors)}`);let Y=[Z.id,J];if(typeof X==="number")Y.push(X);return Y}function C0(Z,J){return{id:Z,schema:J,validate:xE.instance.compile(J)}}var vv1={type:"object",properties:{i:{type:"string"}},required:["i"],additionalProperties:!1},D00={type:"object",properties:{role:{type:"string",enum:["auto","client","server"],nullable:!0},fingerprints:{type:"array",items:{type:"object",properties:{algorithm:{type:"string",enum:["sha-1","sha-224","sha-256","sha-384","sha-512"]},value:{type:"string"}},required:["algorithm","value"]}}},required:["fingerprints"],additionalProperties:!1},Sv1={type:"object",properties:{foundation:{type:"string"},priority:{type:"number"},ip:{type:"string"},address:{type:"string"},protocol:{type:"string",enum:["udp","tcp"]},port:{type:"number"},type:{type:"string",enum:["host"]},tcpType:{type:"string",enum:["passive"],nullable:!0}},required:["foundation","priority","ip","address","protocol","port","type"],additionalProperties:!1},Av1={type:"object",properties:{usernameFragment:{type:"string"},password:{type:"string"},iceLite:{type:"boolean",nullable:!0}},required:["usernameFragment","password"],additionalProperties:!1},xv1={type:"object",properties:{i:{type:"string"},l:{type:"string"}},required:["i","l"],additionalProperties:!1},hv1={type:"object",properties:{port:{type:"number"},OS:{type:"number"},MIS:{type:"number"},maxMessageSize:{type:"number"}},required:["port","OS","MIS","maxMessageSize"],additionalProperties:!0},fv1={type:"object",properties:{streamId:{type:"number"},ordered:{type:"boolean",nullable:!0},maxPacketLifeTime:{type:"number",nullable:!0},maxRetransmits:{type:"number",nullable:!0}},required:["streamId"],additionalProperties:!1},yv1={type:"object",properties:{i:{type:"string"},f:{type:"string",enum:["cs","sc"]},ip:Av1,ic:{type:"array",items:Sv1},d:D00,s:hv1},required:["i","f","ip","ic","d","s"],additionalProperties:!1},bv1={type:"object",properties:{i:{type:"string"},d:D00},required:["i","d"],additionalProperties:!1},gv1={type:"object",properties:{i:{type:"string",nullable:!0},pi:{type:"string",nullable:!0},l:{type:"string"},s:fv1},required:["l","s"],additionalProperties:!1},hE={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},c:{...bv1,nullable:!0},ca:{...vv1,nullable:!0},d:{type:"array",items:{...gv1},nullable:!0},pa:{...xv1,nullable:!0},t:{type:"array",items:{...yv1},nullable:!0}},additionalProperties:!1};var C00=C0(116,hE);var fE={type:"null",nullable:!0};var T00=C0(117,fE);var l2={};Pq(l2,{uiDataSendPacketDefinition:()=>S00,syncRequestPacketDefinition:()=>v00,stateRequestPacketDefinition:()=>_00,inputPacketDefinition:()=>I00,debugConfigPacketDefinition:()=>k00,chatMessageSendPacketDefinition:()=>E00});var yE={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var YH={type:"object",properties:{m:{type:"string"},c:{...yE,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var E00=C0(3,YH);var bE={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var k00=C0(128,bE);var gE={type:"object",properties:{"1":{type:"boolean",nullable:!0},"2":{type:"boolean",nullable:!0},"3":{type:"boolean",nullable:!0},"4":{type:"boolean",nullable:!0},"5":{type:"boolean",nullable:!0},"6":{type:"boolean",nullable:!0},"7":{type:"boolean",nullable:!0},"8":{type:"boolean",nullable:!0},"9":{type:"boolean",nullable:!0},"0":{type:"boolean",nullable:!0},w:{type:"boolean",nullable:!0},a:{type:"boolean",nullable:!0},s:{type:"boolean",nullable:!0},d:{type:"boolean",nullable:!0},q:{type:"boolean",nullable:!0},e:{type:"boolean",nullable:!0},r:{type:"boolean",nullable:!0},f:{type:"boolean",nullable:!0},z:{type:"boolean",nullable:!0},x:{type:"boolean",nullable:!0},c:{type:"boolean",nullable:!0},v:{type:"boolean",nullable:!0},u:{type:"boolean",nullable:!0},i:{type:"boolean",nullable:!0},o:{type:"boolean",nullable:!0},j:{type:"boolean",nullable:!0},k:{type:"boolean",nullable:!0},l:{type:"boolean",nullable:!0},n:{type:"boolean",nullable:!0},m:{type:"boolean",nullable:!0},sp:{type:"boolean",nullable:!0},sh:{type:"boolean",nullable:!0},tb:{type:"boolean",nullable:!0},ml:{type:"boolean",nullable:!0},mr:{type:"boolean",nullable:!0},cp:{type:"number",nullable:!0},cy:{type:"number",nullable:!0},sq:{type:"number",nullable:!0}},additionalProperties:!1};var I00=C0(1,gE);var mE={type:"object",properties:{},additionalProperties:!1};var _00=C0(2,mE);var uE={type:"null",nullable:!0};var v00=C0(0,uE);var $H={type:"object",properties:{},additionalProperties:!0};var S00=C0(4,$H);var p2={};Pq(p2,{worldPacketDefinition:()=>s00,uiPacketDefinition:()=>n00,uiDatasPacketDefinition:()=>a00,syncResponsePacketDefinition:()=>i00,sceneUIsPacketDefinition:()=>p00,playersPacketDefinition:()=>l00,physicsDebugRenderPacketDefinition:()=>d00,physicsDebugRaycastsPacketDefinition:()=>c00,particleEmittersPacketDefinition:()=>u00,lightsPacketDefinition:()=>m00,entitiesPacketDefinition:()=>g00,chunksPacketDefinition:()=>b00,chatMessagesPacketDefinition:()=>y00,cameraPacketDefinition:()=>f00,blocksPacketDefinition:()=>x00,blockTypesPacketDefinition:()=>h00,audiosPacketDefinition:()=>A00});var $1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var dE={type:"object",properties:{i:{type:"number"},a:{type:"string",nullable:!0},cd:{type:"number",nullable:!0},d:{type:"number",nullable:!0},de:{type:"number",nullable:!0},di:{type:"number",minimum:0,nullable:!0},e:{type:"number",nullable:!0},l:{type:"boolean",nullable:!0},o:{type:"number",nullable:!0},p:{...$1,nullable:!0},pa:{type:"boolean",nullable:!0},pl:{type:"boolean",nullable:!0},pr:{type:"number",minimum:0,nullable:!0},r:{type:"boolean",nullable:!0},rd:{type:"number",nullable:!0},s:{type:"number",nullable:!0},v:{type:"number",minimum:0,maximum:1,nullable:!0}},required:["i"],additionalProperties:!1};var cE={type:"array",items:{...dE}};var A00=C0(33,cE);var lE={type:"object",properties:{i:{type:"number"},c:$1},required:["i","c"],additionalProperties:!1};var pE={type:"array",items:{...lE}};var x00=C0(34,pE);var iE={type:"object",properties:{i:{type:"number"},l:{type:"boolean",nullable:!0},n:{type:"string",nullable:!0},t:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var nE={type:"array",items:{...iE}};var h00=C0(35,nE);var aE={type:"object",properties:{m:{type:"number",nullable:!0},e:{type:"number",nullable:!0},et:{type:"number",nullable:!0},fo:{type:"number",nullable:!0},ffo:{type:"number",nullable:!0},fv:{type:"number",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},o:{...$1,nullable:!0},p:{...$1,nullable:!0},pt:{...$1,nullable:!0},pl:{...$1,nullable:!0},s:{type:"array",items:{type:"string"},nullable:!0},sa:{type:"number",nullable:!0},z:{type:"number",nullable:!0}},additionalProperties:!1};var sE={type:"array",items:{...YH}};var oE={type:"object",properties:{c:$1,b:{type:"array",items:{type:"number",minimum:0,maximum:255},minItems:4096,maxItems:4096,nullable:!0},rm:{type:"boolean",nullable:!0}},required:["c"],additionalProperties:!1};var rE={type:"array",items:{...oE}};var A6={type:"array",items:[{type:"number",minimum:0,maximum:255},{type:"number",minimum:0,maximum:255},{type:"number",minimum:0,maximum:255}],minItems:3,maxItems:3};var tE={type:"object",properties:{n:{type:"string"},h:{type:"boolean",nullable:!0},o:{type:"number",minimum:0,maximum:1,nullable:!0},r:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},t:{...A6,nullable:!0}},required:["n"],additionalProperties:!1};var eE={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var Zk={type:"object",properties:{i:{type:"number"},al:{type:"array",items:{type:"string"},nullable:!0},ao:{type:"array",items:{type:"string"},nullable:!0},ap:{type:"number",nullable:!0},as:{type:"array",items:{type:"string"},nullable:!0},bh:{...$1,nullable:!0},bt:{type:"string",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},m:{type:"string",nullable:!0},mo:{type:"array",items:{...tE},nullable:!0},mt:{type:"string",nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...$1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{...eE,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sn:{type:"array",items:{type:"string"},nullable:!0},t:{...A6,nullable:!0}},required:["i"],additionalProperties:!1};var Jk={type:"array",items:{...Zk}};var Xk={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...A6,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...$1,nullable:!0},p:{...$1,nullable:!0},pe:{type:"number",minimum:0,maximum:1,nullable:!0},rm:{type:"boolean",nullable:!0},t:{type:"number",nullable:!0},te:{type:"number",nullable:!0},tp:{...$1,nullable:!0}},required:["i"],additionalProperties:!1};var Yk={type:"array",items:{...Xk}};var $k={type:"object",properties:{i:{type:"number"},at:{type:"number",nullable:!0},ce:{...A6,nullable:!0},cev:{...A6,nullable:!0},cs:{...A6,nullable:!0},csv:{...A6,nullable:!0},e:{type:"number",nullable:!0},en:{type:"string",nullable:!0},g:{...$1,nullable:!0},l:{type:"number",nullable:!0},lv:{type:"number",nullable:!0},mp:{type:"number",nullable:!0},o:{...$1,nullable:!0},oe:{type:"number",nullable:!0},oev:{type:"number",nullable:!0},os:{type:"number",nullable:!0},osv:{type:"number",nullable:!0},p:{...$1,nullable:!0},pv:{...$1,nullable:!0},r:{type:"number",nullable:!0},rv:{type:"number",nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sv:{type:"number",nullable:!0},t:{type:"boolean",nullable:!0},tu:{type:"string",nullable:!0},v:{...$1,nullable:!0},vv:{...$1,nullable:!0}},required:["i"],additionalProperties:!1};var Qk={type:"array",items:{...$k}};var Kk={type:"object",properties:{o:{...$1},d:{...$1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var Wk={type:"array",items:{...Kk}};var Gk={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var Vk={type:"object",properties:{i:{type:"string"},p:{type:"string",nullable:!0},rm:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var Hk={type:"array",items:{...Vk}};var zk={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...$1,nullable:!0},p:{...$1,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"object",nullable:!0},t:{type:"string",nullable:!0},v:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var Fk={type:"array",items:{...zk}};var qk={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var Uk={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var Lk={type:"array",items:{...$H}};var mv1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var Bk={type:"object",properties:{i:{type:"number"},ac:{...A6,nullable:!0},ai:{type:"number",nullable:!0},dc:{...A6,nullable:!0},di:{type:"number",nullable:!0},dp:{...$1,nullable:!0},fc:{...A6,nullable:!0},ff:{type:"number",nullable:!0},fn:{type:"number",nullable:!0},n:{type:"string",nullable:!0},s:{type:"string",nullable:!0},si:{type:"number",nullable:!0},t:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var f00=C0(40,aE);var y00=C0(36,sE);var b00=C0(37,rE);var g00=C0(38,Jk);var m00=C0(44,Yk);var u00=C0(46,Qk);var d00=C0(192,Gk);var c00=C0(193,Wk);var l00=C0(45,Hk);var p00=C0(43,Fk);var i00=C0(32,qk);var n00=C0(41,Uk);var a00=C0(42,Lk);var s00=C0(39,Bk);var i2=new Map,uv1={...c2,...l2,...p2};for(let Z of Object.values(uv1))if("id"in Z&&"schema"in Z){let J=Z;if(i2.has(J.id))throw new Error(`Packet with id ${J.id} is already registered.`);i2.set(J.id,J)}function dv1(Z){if(typeof Z!=="object"||Z===null||typeof Z[0]!=="number"||Z[0]<0||Z[1]===void 0||Z[2]!==void 0&&(typeof Z[2]!=="number"||Z[2]<0))return!1;let J=i2.get(Z[0]);return!!J&&J.validate(Z[1])}var Z0=wk;var N10=r(j10(),1);import oY from"fs";import O10 from"path";var KH="./dev/persistence";class N7{static instance=new N7;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;constructor(){try{this._creativeGateway=new N10.CreativeGateway}catch{console.warn(["━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","\uD83D\uDEA8 HYTOPIA PLATFORM GATEWAY IS NOT INITIALIZED \uD83D\uDEA8","","\uD83D\uDD27 Local development is still possible, but these features will be disabled:"," • \uD83D\uDC64 Player Accounts"," • \uD83C\uDFAD Player Cosmetics"," • \uD83D\uDC1B Crash Analytics & Debug Logs","","\uD83D\uDCA1 These features will be enabled but modified:"," • \uD83D\uDCBE Player & Global Persisted Data - Data will be persisted"," locally in the ./dev/persistence directory of your project."," Player ids for data persistence will begin at 1 for the first "," player to join your local server, and increments for each"," additional player. This means that if you restart your"," server, the first player id will be 1 again. This is to ensure"," that data persistence across server restarts can be easily"," tested and debugged in local development.","","To enable the HYTOPIA Platform Gateway locally:"," 1. Set these environment variables:"," HYTOPIA_API_KEY, HYTOPIA_GAME_ID, HYTOPIA_LOBBY_ID"," 2. You can find these values at: https://create.hytopia.com","","Note: In production, these environment variables will be auto-populated ","& the HYTOPIA Platform Gateway will automatically be initialized \uD83D\uDE80","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━",""].join(`
415
415
  `))}}get isGatewayAvailable(){return!!this._creativeGateway}async getData(Z){if(!this._creativeGateway&&process.env.NODE_ENV==="production")return u.warning("PlatformGateway.getData(): You are running in production mode, but the Platform Gateway is not initialized! No data will be returned.");return this._creativeGateway?await this._creativeGateway.kv.get(Z):this._readDevDataLocally(Z)}async getPlayerLoadout(Z){if(!this._creativeGateway)return;return await this._creativeGateway.getLoadout(Z)}async getPlayerSession(Z){if(!this._creativeGateway)return;return await this._creativeGateway.getSession(Z)}async setData(Z,J){if(J.error)return u.warning("PlatformGateway.setData(): Cannot set data with an error property.");if(!this._creativeGateway&&process.env.NODE_ENV==="production")return u.warning("PlatformGateway.setData(): You are running in production mode, but the Platform Gateway is not initialized! No data will be set.");return this._creativeGateway?await this._creativeGateway.kv.set(Z,J):this._writeDevDataLocally(Z,J)}_readDevDataLocally(Z){try{if(!oY.existsSync(KH))return;let J=O10.join(KH,`${Z}.json`);return JSON.parse(oY.readFileSync(J,"utf8"))}catch(J){u.warning(`PlatformGateway._readDevDataLocally(): Failed to read data for key "${Z}": ${J}`)}}_writeDevDataLocally(Z,J){try{if(!oY.existsSync(KH))oY.mkdirSync(KH,{recursive:!0});let X=O10.join(KH,`${Z}.json`),Y={};if(oY.existsSync(X))Y=JSON.parse(oY.readFileSync(X,"utf8"));let $={...Y,...J};oY.writeFileSync(X,JSON.stringify($,null,2),"utf8")}catch(X){u.warning(`PlatformGateway._writeDevDataLocally(): Failed to write data for key "${Z}": ${X}`)}}}class rY{static instance=new rY;constructor(){}async getGlobalData(Z){let J=await N7.instance.getData(Z);if(!J||J.error){if(J?.error)u.warning(`PersistenceManager.getGlobalData(): ${J.error.message}`);return}return J}async getPlayerData(Z){let J=await N7.instance.getData(this._getPlayerKey(Z));if(!J||J.error){if(J?.error)u.warning(`PersistenceManager.getPlayerData(): ${J.error.message}`);return}return J}async setGlobalData(Z,J){let X=await N7.instance.setData(Z,J);if(!X||X.error){if(X?.error)u.warning(`PersistenceManager.setGlobalData(): ${X.error.message}`);return}return X}async setPlayerData(Z,J){let X=await N7.instance.setData(this._getPlayerKey(Z),J);if(!X||X.error){if(X?.error)u.warning(`PersistenceManager.setPlayerData(): ${X.error.message}`);return}return X}_getPlayerKey(Z){return`player-${Z.id}`}}var R10;((Y)=>{Y[Y.FIRST_PERSON=0]="FIRST_PERSON";Y[Y.THIRD_PERSON=1]="THIRD_PERSON";Y[Y.SPECTATOR=2]="SPECTATOR"})(R10||={});var Ok;((L)=>{L.LOOK_AT_ENTITY="PLAYER_CAMERA.LOOK_AT_ENTITY";L.LOOK_AT_POSITION="PLAYER_CAMERA.LOOK_AT_POSITION";L.SET_ATTACHED_TO_ENTITY="PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY";L.SET_ATTACHED_TO_POSITION="PLAYER_CAMERA.SET_ATTACHED_TO_POSITION";L.SET_FILM_OFFSET="PLAYER_CAMERA.SET_FILM_OFFSET";L.SET_FORWARD_OFFSET="PLAYER_CAMERA.SET_FORWARD_OFFSET";L.SET_FOV="PLAYER_CAMERA.SET_FOV";L.SET_MODEL_HIDDEN_NODES="PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES";L.SET_MODEL_SHOWN_NODES="PLAYER_CAMERA.SET_MODEL_SHOWN_NODES";L.SET_MODE="PLAYER_CAMERA.SET_MODE";L.SET_OFFSET="PLAYER_CAMERA.SET_OFFSET";L.SET_SHOULDER_ANGLE="PLAYER_CAMERA.SET_SHOULDER_ANGLE";L.SET_TRACKED_ENTITY="PLAYER_CAMERA.SET_TRACKED_ENTITY";L.SET_TRACKED_POSITION="PLAYER_CAMERA.SET_TRACKED_POSITION";L.SET_ZOOM="PLAYER_CAMERA.SET_ZOOM"})(Ok||={});class WH extends B0{player;_attachedToEntity;_attachedToPosition;_filmOffset=0;_forwardOffset=0;_fov=75;_modelHiddenNodes=new Set;_modelShownNodes=new Set;_mode=1;_offset={x:0,y:0,z:0};_orientation={pitch:0,yaw:0};_shoulderAngle=0;_trackedEntity;_trackedPosition;_zoom=1;constructor(Z){super();this.player=Z}get attachedToEntity(){return this._attachedToEntity}get attachedToPosition(){return this._attachedToPosition}get facingDirection(){return{x:-Math.sin(this._orientation.yaw)*Math.cos(this._orientation.pitch),y:Math.sin(this._orientation.pitch),z:-Math.cos(this._orientation.yaw)*Math.cos(this._orientation.pitch)}}get facingQuaternion(){let Z=this._orientation.pitch*0.5,J=this._orientation.yaw*0.5,X=Math.cos(Z),Y=Math.sin(Z),$=Math.cos(J),Q=Math.sin(J);return{x:Y*$,y:X*Q,z:-Y*Q,w:X*$}}get filmOffset(){return this._filmOffset}get forwardOffset(){return this._forwardOffset}get fov(){return this._fov}get modelHiddenNodes(){return this._modelHiddenNodes}get modelShownNodes(){return this._modelShownNodes}get mode(){return this._mode}get offset(){return this._offset}get orientation(){return this._orientation}get shoulderAngle(){return this._shoulderAngle}get trackedEntity(){return this._trackedEntity}get trackedPosition(){return this._trackedPosition}get zoom(){return this._zoom}lookAtEntity(Z){if(!this._requirePlayerWorld("lookAtEntity"))return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_ENTITY",{playerCamera:this,entity:Z})}lookAtPosition(Z){if(!this._requirePlayerWorld("lookAtPosition"))return;this.emitWithWorld(this.player.world,"PLAYER_CAMERA.LOOK_AT_POSITION",{playerCamera:this,position:Z})}reset(){this._attachedToEntity=void 0,this._attachedToPosition=void 0,this._orientation={pitch:0,yaw:0},this._trackedEntity=void 0,this._trackedPosition=void 0}setAttachedToEntity(Z){if(!this._requirePlayerWorld("setAttachedToEntity"))return;if(!Z.isSpawned)return u.error(`PlayerCamera.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);this._attachedToEntity=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_ENTITY",{playerCamera:this,entity:Z})}setAttachedToPosition(Z){if(!this._requirePlayerWorld("setAttachedToPosition"))return;this._attachedToPosition=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ATTACHED_TO_POSITION",{playerCamera:this,position:Z})}setFilmOffset(Z){if(!this._requirePlayerWorld("setFilmOffset"))return;this._filmOffset=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FILM_OFFSET",{playerCamera:this,filmOffset:Z})}setForwardOffset(Z){if(!this._requirePlayerWorld("setForwardOffset"))return;this._forwardOffset=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FORWARD_OFFSET",{playerCamera:this,forwardOffset:Z})}setFov(Z){if(!this._requirePlayerWorld("setFov"))return;this._fov=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_FOV",{playerCamera:this,fov:Z})}setModelHiddenNodes(Z){if(!this._requirePlayerWorld("setModelHiddenNodes"))return;this._modelHiddenNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODEL_HIDDEN_NODES",{playerCamera:this,modelHiddenNodes:this._modelHiddenNodes})}setModelShownNodes(Z){if(!this._requirePlayerWorld("setModelShownNodes"))return;this._modelShownNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODEL_SHOWN_NODES",{playerCamera:this,modelShownNodes:this._modelShownNodes})}setMode(Z){if(!this._requirePlayerWorld("setMode"))return;this._mode=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_MODE",{playerCamera:this,mode:Z})}setOffset(Z){if(!this._requirePlayerWorld("setOffset"))return;this._offset=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_OFFSET",{playerCamera:this,offset:Z})}setOrientationPitch(Z){this._orientation.pitch=Z}setOrientationYaw(Z){this._orientation.yaw=Z}setShoulderAngle(Z){if(!this._requirePlayerWorld("setShoulderAngle"))return;this._shoulderAngle=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_SHOULDER_ANGLE",{playerCamera:this,shoulderAngle:Z})}setTrackedEntity(Z){if(!this._requirePlayerWorld("setTrackedEntity"))return;this._trackedEntity=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_ENTITY",{playerCamera:this,entity:Z})}setTrackedPosition(Z){if(!this._requirePlayerWorld("setTrackedPosition"))return;this._trackedPosition=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_TRACKED_POSITION",{playerCamera:this,position:Z})}setZoom(Z){if(!this._requirePlayerWorld("setZoom"))return;this._zoom=Z,this.emitWithWorld(this.player.world,"PLAYER_CAMERA.SET_ZOOM",{playerCamera:this,zoom:Z})}serialize(){return M0.serializePlayerCamera(this)}_requirePlayerWorld(Z){if(!this.player.world)u.error(`PlayerCamera._requirePlayerWorld(): Player ${this.player.id} is not in a world, invoked method: ${Z}()`);return!!this.player.world}}var a2;(($)=>{$.DATA="PLAYER_UI.DATA";$.LOAD="PLAYER_UI.LOAD";$.LOCK_POINTER="PLAYER_UI.LOCK_POINTER";$.SEND_DATA="PLAYER_UI.SEND_DATA"})(a2||={});class GH extends B0{player;constructor(Z){super();this.player=Z}load(Z){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOAD",{playerUI:this,htmlUri:Z})}lockPointer(Z){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.LOCK_POINTER",{playerUI:this,lock:Z})}sendData(Z){if(!this.player.world)return;this.emitWithWorld(this.player.world,"PLAYER_UI.SEND_DATA",{playerUI:this,data:Z})}}var M10=["w","a","s","d","sp","sh","tb","ml","mr","q","e","r","f","z","x","c","v","u","i","o","j","k","l","n","m","1","2","3","4","5","6","7","8","9","0"],VH;((Q)=>{Q.CHAT_MESSAGE_SEND="PLAYER.CHAT_MESSAGE_SEND";Q.JOINED_WORLD="PLAYER.JOINED_WORLD";Q.LEFT_WORLD="PLAYER.LEFT_WORLD";Q.RECONNECTED_WORLD="PLAYER.RECONNECTED_WORLD";Q.REQUEST_SYNC="PLAYER.REQUEST_SYNC"})(VH||={});class uK extends B0{static _devNextPlayerId=1;id;username;profilePictureUrl;camera;connection;ui;_input={};_lastUnreliableInputSequenceNumber=0;_persistedData;_world;_worldSwitched=!1;constructor(Z,J){super();this.id=J?.user.id??`player-${uK._devNextPlayerId++}`,this.username=J?.user.username??this.id,this.profilePictureUrl=J?.user.profilePictureURL??void 0,this.camera=new WH(this),this.connection=Z,this.ui=new GH(this),Z.onPacket(Z0.PacketId.CHAT_MESSAGE_SEND,this._onChatMessageSendPacket),Z.onPacket(Z0.PacketId.DEBUG_CONFIG,this._onDebugConfigPacket),Z.onPacket(Z0.PacketId.INPUT,this._onInputPacket),Z.onPacket(Z0.PacketId.SYNC_REQUEST,this._onSyncRequestPacket),Z.onPacket(Z0.PacketId.UI_DATA_SEND,this._onUIDataSendPacket)}get input(){return this._input}get world(){return this._world}disconnect(){this._leaveWorld(),this.connection.disconnect()}getPersistedData(){return this._persistedData}joinWorld(Z){if(this._world===Z)return;if(!this._world)this._world=Z,this.emitWithWorld(this._world,"PLAYER.JOINED_WORLD",{player:this,world:this._world});else{for(let J of this._world.entityManager.getPlayerEntitiesByPlayer(this))if(J.isSpawned)J.despawn();this.disconnect(),this._world=Z,this._worldSwitched=!0}}async loadInitialPersistedData(){if(this._persistedData)return;this._persistedData=await rY.instance.getPlayerData(this)??void 0}reconnected(){if(!this._world)return;if(this._lastUnreliableInputSequenceNumber=0,!this._worldSwitched)this.emitWithWorld(this._world,"PLAYER.RECONNECTED_WORLD",{player:this,world:this._world});else this._worldSwitched=!1,this.emitWithWorld(this._world,"PLAYER.JOINED_WORLD",{player:this,world:this._world})}resetInputs(){this._input={}}setPersistedData(Z){return this._persistedData={...this._persistedData,...Z},rY.instance.setPlayerData(this,Z).catch((J)=>{}),this._persistedData}serialize(){return M0.serializePlayer(this)}_leaveWorld(){if(!this._world)return;this.emitWithWorld(this._world,"PLAYER.LEFT_WORLD",{player:this,world:this._world}),this._world=void 0}_onChatMessageSendPacket=(Z)=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.CHAT_MESSAGE_SEND",{player:this,message:Z[1].m})};_onDebugConfigPacket=(Z)=>{console.log(Z)};_onInputPacket=(Z)=>{let J=Z[1];if(J.sq!==void 0){if(J.sq<this._lastUnreliableInputSequenceNumber)return;this._lastUnreliableInputSequenceNumber=J.sq}if(M10.forEach((X)=>{let Y=X;if(J[Y]!==void 0)this._input[Y]=Boolean(J[Y])}),J.cp!==void 0)this.camera.setOrientationPitch(J.cp);if(J.cy!==void 0)this.camera.setOrientationYaw(J.cy)};_onSyncRequestPacket=()=>{if(this._world)this.emitWithWorld(this._world,"PLAYER.REQUEST_SYNC",{player:this,receivedAt:Date.now(),receivedAtMs:performance.now()})};_onUIDataSendPacket=(Z)=>{this.ui.emit("PLAYER_UI.DATA",{playerUI:this.ui,data:Z[1]})}}var Nk;((X)=>{X.BROADCAST_MESSAGE="CHAT.BROADCAST_MESSAGE";X.PLAYER_MESSAGE="CHAT.PLAYER_MESSAGE"})(Nk||={});class HH extends B0{_commandCallbacks={};_world;constructor(Z){super();this._world=Z,this._subscribeToPlayerEvents()}registerCommand(Z,J){this._commandCallbacks[Z]=J}unregisterCommand(Z){delete this._commandCallbacks[Z]}sendBroadcastMessage(Z,J){this._sendBroadcastMessage(void 0,Z,J)}sendPlayerMessage(Z,J,X){this.emitWithWorld(this._world,"CHAT.PLAYER_MESSAGE",{player:Z,message:J,color:X})}_subscribeToPlayerEvents(){this._world.on("PLAYER.CHAT_MESSAGE_SEND",(Z)=>{let{player:J,message:X}=Z,[Y,...$]=X.split(" "),Q=this._commandCallbacks[Y];if(Q){Q(J,$,X);return}this._sendBroadcastMessage(J,X)})}_sendBroadcastMessage(Z,J,X){this.emitWithWorld(this._world,"CHAT.BROADCAST_MESSAGE",{player:Z,message:J,color:X})}}var M8=16,dK=M8-1,P10=M8**3,qS1=[{neighborOffset:[-1,0,0],generateVertices:(Z,J,X)=>[Z+0,J+0,X+0,Z+0,J+0,X+1,Z+0,J+1,X+0,Z+0,J+1,X+0,Z+0,J+0,X+1,Z+0,J+1,X+1]},{neighborOffset:[1,0,0],generateVertices:(Z,J,X)=>[Z+1,J+0,X+0,Z+1,J+1,X+0,Z+1,J+0,X+1,Z+1,J+1,X+0,Z+1,J+1,X+1,Z+1,J+0,X+1]},{neighborOffset:[0,-1,0],generateVertices:(Z,J,X)=>[Z+0,J+0,X+0,Z+1,J+0,X+0,Z+0,J+0,X+1,Z+1,J+0,X+0,Z+1,J+0,X+1,Z+0,J+0,X+1]},{neighborOffset:[0,1,0],generateVertices:(Z,J,X)=>[Z+0,J+1,X+0,Z+0,J+1,X+1,Z+1,J+1,X+0,Z+1,J+1,X+0,Z+0,J+1,X+1,Z+1,J+1,X+1]},{neighborOffset:[0,0,-1],generateVertices:(Z,J,X)=>[Z+0,J+0,X+0,Z+0,J+1,X+0,Z+1,J+0,X+0,Z+0,J+1,X+0,Z+1,J+1,X+0,Z+1,J+0,X+0]},{neighborOffset:[0,0,1],generateVertices:(Z,J,X)=>[Z+0,J+0,X+1,Z+1,J+0,X+1,Z+0,J+1,X+1,Z+0,J+1,X+1,Z+1,J+0,X+1,Z+1,J+1,X+1]}],Rk;((Y)=>{Y.DESPAWN="CHUNK.DESPAWN";Y.SET_BLOCK="CHUNK.SET_BLOCK";Y.SPAWN="CHUNK.SPAWN"})(Rk||={});class x6 extends B0{_blocks;_originCoordinate;_requiresUpdate=!1;_rigidBody;_world;constructor(){super();this._blocks=new Uint8Array(P10)}get blocks(){return this._blocks}get requiresUpdate(){return this._requiresUpdate}get isSimulated(){return!!this._rigidBody}get isSpawned(){return!!this._originCoordinate&&!!this._world}get originCoordinate(){return this._originCoordinate}get world(){return this._world}static blockIndexToLocalCoordinate(Z){return{x:Z%M8,y:(Z/M8|0)%M8,z:Z/(M8*M8)|0}}static globalCoordinateToLocalCoordinate(Z){return{x:Z.x&M8-1,y:Z.y&M8-1,z:Z.z&M8-1}}static globalCoordinateToOriginCoordinate(Z){return{x:Z.x&~(M8-1),y:Z.y&~(M8-1),z:Z.z&~(M8-1)}}static isValidOriginCoordinate(Z){return Z.x%M8===0&&Z.y%M8===0&&Z.z%M8===0}spawn(Z,J){if(this.isSpawned){let{x:X,y:Y,z:$}=this.originCoordinate;return u.error(`Chunk.spawn(): Chunk is already spawned at origin ${X}, ${Y}, ${$}!`)}if(!x6.isValidOriginCoordinate(J))return u.error(`Chunk.spawn(): Chunk coordinates must be divisible by ${M8}`);this._originCoordinate=J,this._world=Z,this._world.chunkLattice.registerChunk(this),this._requiresUpdate=!0}despawn(){if(!this.isSpawned)return u.error("Chunk.despawn(): Chunk has not been spawned and cannot be despawned!");this.emitWithWorld(this._world,"CHUNK.DESPAWN",{chunk:this}),this._removeFromSimulation(),this._world.chunkLattice.unregisterChunk(this),this._originCoordinate=void 0,this._world=void 0}getBlockId(Z){return this._blocks[this._getIndex(Z)]}hasBlock(Z){return this._blocks[this._getIndex(Z)]!==0}setBlock(Z,J){if(!this._isValidLocalCoordinate(Z))return u.error("Chunk.setBlock(): Block local coordinate is out of bounds");if(this._blocks[this._getIndex(Z)]===J)return;if(this._blocks[this._getIndex(Z)]=J,this.isSpawned&&this.isSimulated){this.emitWithWorld(this._world,"CHUNK.SET_BLOCK",{chunk:this,globalCoordinate:this._getGlobalCoordinate(Z),localCoordinate:Z,blockTypeId:J});let X=this._getGlobalCoordinate(Z),Y=[];if(Z.x===0)Y.push({x:-1,y:0,z:0});if(Z.y===0)Y.push({x:0,y:-1,z:0});if(Z.z===0)Y.push({x:0,y:0,z:-1});if(Z.x===dK)Y.push({x:1,y:0,z:0});if(Z.y===dK)Y.push({x:0,y:1,z:0});if(Z.z===dK)Y.push({x:0,y:0,z:1});for(let $ of Y){let Q={x:X.x+$.x,y:X.y+$.y,z:X.z+$.z},K=x6.globalCoordinateToOriginCoordinate(Q),W=this._world?.chunkLattice.getChunk(K);if(!W?.hasBlock(x6.globalCoordinateToLocalCoordinate(Q)))continue;W.setRequiresUpdate(!0)}}this._requiresUpdate=!0}setRequiresUpdate(Z){this._requiresUpdate=Z}update(){if(!this._requiresUpdate)return;if(!this.isSpawned)return u.error("Chunk.update(): Chunk is not spawned and cannot be updated.");let Z=!this._rigidBody,J=this._world.simulation;if(this._removeFromSimulation(),this._rigidBody=new cY({type:"fixed",position:this._originCoordinate,simulation:this._world.simulation}),this._meshColliders().map(([X,Y])=>{if(!X.isSimulated)X.addToSimulation(J,this._rigidBody);J.colliderMap.setColliderBlockType(X,Y)}),this._requiresUpdate=!1,Z)this.emitWithWorld(this._world,"CHUNK.SPAWN",{chunk:this})}serialize(){return M0.serializeChunk(this)}_meshColliders(){if(!this._world)return u.error("Chunk._meshColliders(): Chunk is not spawned and cannot be meshed."),[];let Z=new Map,J=[];for(let Y=0;Y<P10;Y++){if(this._blocks[Y]===0)continue;let $=this._blocks[Y],Q=this._world.blockTypeRegistry.getBlockType($),{x:K,y:W,z:G}=x6.blockIndexToLocalCoordinate(Y);if(!Q.isMeshable){let H=Q.createCollider();H.setRelativePosition({x:K,y:W,z:G}),J.push([H,Q]);continue}let V=Z.get(Q)??{indices:[],vertices:[]};Z.set(Q,V);for(let H of qS1){let[F,z,q]=H.neighborOffset,U={x:K+F,y:W+z,z:G+q},L=this._getGlobalCoordinate(U),B=this._world.chunkLattice.getBlockType(L);if(B&&!B.isLiquid)continue;let w=V.indices.length;V.indices.push(w,w+1,w+2,w+3,w+4,w+5),V.vertices.push(...H.generateVertices(K,W,G))}}let X=[];return Z.forEach((Y,$)=>{if(!Y.indices.length)return;let Q=$.createCollider(new Uint32Array(Y.indices),new Float32Array(Y.vertices));X.push([Q,$])}),[...J,...X]}_removeFromSimulation(){if(!this._rigidBody||!this._world)return;this._rigidBody.removeFromSimulation(),this._rigidBody=void 0}_getGlobalCoordinate(Z){if(!this.originCoordinate)u.fatalError("Chunk._getGlobalCoordinate(): Chunk is not spawned, calculating global coordinate is impossible.");return{x:this.originCoordinate.x+Z.x,y:this.originCoordinate.y+Z.y,z:this.originCoordinate.z+Z.z}}_getIndex(Z){return Z.x+M8*(Z.y+M8*Z.z)}_isValidLocalCoordinate(Z){return Z.x>=0&&Z.x<=dK&&Z.y>=0&&Z.y<=dK&&Z.z>=0&&Z.z<=dK}}class zH{_chunks=new Map;_world;constructor(Z){this._world=Z}get chunkCount(){return this._chunks.size}registerChunk(Z){if(!Z.isSpawned)return u.error("ChunkLattice.registerChunk(): Chunk is not spawned.");if(this.hasChunk(Z.originCoordinate)){let{x:J,y:X,z:Y}=Z.originCoordinate;return u.error(`ChunkLattice.registerChunk(): Chunk exists at origin (${J}, ${X}, ${Y}), despawn the current chunk before registering another at the same origin.`)}if(Z.world.id!==this._world.id)return u.error("ChunkLattice.registerChunk(): Chunk world does not match lattice world.");this._chunks.set(this._getChunkKey(Z.originCoordinate),Z)}unregisterChunk(Z){if(!Z.isSpawned)return u.error("ChunkLattice.unregisterChunk(): Chunk is not spawned.");if(Z.world.id!==this._world.id)return u.error("ChunkLattice.unregisterChunk(): Chunk world does not match lattice world.");this._chunks.delete(this._getChunkKey(Z.originCoordinate))}clear(){this._chunks.forEach((Z)=>Z.despawn()),this._chunks.clear()}getBlockId(Z){let J=this.getChunk(x6.globalCoordinateToOriginCoordinate(Z));if(!J)return 0;return J.getBlockId(x6.globalCoordinateToLocalCoordinate(Z))}getBlockType(Z){let J=this.getBlockId(Z);return J?this._world.blockTypeRegistry.getBlockType(J):null}getChunk(Z){if(!x6.isValidOriginCoordinate(Z)){u.error(`ChunkLattice.getChunk(): Chunk coordinates must be divisible by CHUNK_SIZE (${M8})`);return}return this._chunks.get(this._getChunkKey(Z))}getAllChunks(){return Array.from(this._chunks.values())}hasBlock(Z){let J=this.getChunk(x6.globalCoordinateToOriginCoordinate(Z));if(!J)return!1;return J.hasBlock(x6.globalCoordinateToLocalCoordinate(Z))}hasChunk(Z){return this._chunks.has(this._getChunkKey(Z))}setBlock(Z,J){let X=x6.globalCoordinateToLocalCoordinate(Z),Y=x6.globalCoordinateToOriginCoordinate(Z),$=this.getChunk(Y);if(!$)$=new x6,$.spawn(this._world,Y);$.setBlock(X,J)}updateChunks(){this._chunks.forEach((Z)=>{if(Z.requiresUpdate)Z.update()})}_getChunkKey(Z){return`${Z.x},${Z.y},${Z.z}`}}class FH{_colliderHandleBlockTypeMap=new Map;_colliderHandleCollisionCallbackMap=new Map;_colliderHandleEntityMap=new Map;_cleanupBlockTypeColliderHandles=new Set;_pendingCleanupBlockTypeColliderHandles=new Set;_cleanupCollisionCallbackColliderHandles=new Set;_pendingCleanupCollisionCallbackColliderHandles=new Set;_cleanupEntityColliderHandles=new Set;_pendingCleanupEntityColliderHandles=new Set;getColliderBlockType(Z){if(!this._requireSimulatedCollider(Z))return;return this._colliderHandleBlockTypeMap.get(Z.rawCollider.handle)}getColliderCollisionCallback(Z){if(!this._requireSimulatedCollider(Z))return;return this._colliderHandleCollisionCallbackMap.get(Z.rawCollider.handle)}getColliderEntity(Z){if(!this._requireSimulatedCollider(Z))return;return this._colliderHandleEntityMap.get(Z.rawCollider.handle)}getColliderHandleBlockType(Z){return this._colliderHandleBlockTypeMap.get(Z)}getColliderHandleCollisionCallback(Z){return this._colliderHandleCollisionCallbackMap.get(Z)}getColliderHandleEntity(Z){return this._colliderHandleEntityMap.get(Z)}removeColliderBlockType(Z){if(!this._requireSimulatedCollider(Z))return;this.removeColliderHandleBlockType(Z.rawCollider.handle)}removeColliderCollisionCallback(Z){if(!this._requireSimulatedCollider(Z))return;this.removeColliderHandleCollisionCallback(Z.rawCollider.handle)}removeColliderEntity(Z){if(!this._requireSimulatedCollider(Z))return;this.removeColliderHandleEntity(Z.rawCollider.handle)}removeColliderHandleBlockType(Z){this._colliderHandleBlockTypeMap.delete(Z)}removeColliderHandleCollisionCallback(Z){this._colliderHandleCollisionCallbackMap.delete(Z)}removeColliderHandleEntity(Z){this._colliderHandleEntityMap.delete(Z)}setColliderBlockType(Z,J){if(!this._requireSimulatedCollider(Z))return;this.setColliderHandleBlockType(Z.rawCollider.handle,J)}setColliderCollisionCallback(Z,J){if(!this._requireSimulatedCollider(Z))return;this.setColliderHandleCollisionCallback(Z.rawCollider.handle,J)}setColliderEntity(Z,J){if(!this._requireSimulatedCollider(Z))return;this.setColliderHandleEntity(Z.rawCollider.handle,J)}setColliderHandleBlockType(Z,J){this._colliderHandleBlockTypeMap.set(Z,J),this._cleanupBlockTypeColliderHandles.delete(Z),this._pendingCleanupBlockTypeColliderHandles.delete(Z)}setColliderHandleCollisionCallback(Z,J){this._colliderHandleCollisionCallbackMap.set(Z,J),this._cleanupCollisionCallbackColliderHandles.delete(Z),this._pendingCleanupCollisionCallbackColliderHandles.delete(Z)}setColliderHandleEntity(Z,J){this._colliderHandleEntityMap.set(Z,J),this._cleanupEntityColliderHandles.delete(Z),this._pendingCleanupEntityColliderHandles.delete(Z)}queueColliderHandleForCleanup(Z){if(this._colliderHandleBlockTypeMap.has(Z))this._pendingCleanupBlockTypeColliderHandles.add(Z);if(this._colliderHandleCollisionCallbackMap.has(Z))this._pendingCleanupCollisionCallbackColliderHandles.add(Z);if(this._colliderHandleEntityMap.has(Z))this._pendingCleanupEntityColliderHandles.add(Z)}cleanup(){for(let Z of this._cleanupBlockTypeColliderHandles)this._colliderHandleBlockTypeMap.delete(Z);if(this._cleanupBlockTypeColliderHandles.size>0)this._cleanupBlockTypeColliderHandles.clear();for(let Z of this._cleanupCollisionCallbackColliderHandles)this._colliderHandleCollisionCallbackMap.delete(Z);if(this._cleanupCollisionCallbackColliderHandles.size>0)this._cleanupCollisionCallbackColliderHandles.clear();for(let Z of this._cleanupEntityColliderHandles)this._colliderHandleEntityMap.delete(Z);if(this._cleanupEntityColliderHandles.size>0)this._cleanupEntityColliderHandles.clear();for(let Z of this._pendingCleanupBlockTypeColliderHandles)this._cleanupBlockTypeColliderHandles.add(Z);if(this._pendingCleanupBlockTypeColliderHandles.size>0)this._pendingCleanupBlockTypeColliderHandles.clear();for(let Z of this._pendingCleanupCollisionCallbackColliderHandles)this._cleanupCollisionCallbackColliderHandles.add(Z);if(this._pendingCleanupCollisionCallbackColliderHandles.size>0)this._pendingCleanupCollisionCallbackColliderHandles.clear();for(let Z of this._pendingCleanupEntityColliderHandles)this._cleanupEntityColliderHandles.add(Z);if(this._pendingCleanupEntityColliderHandles.size>0)this._pendingCleanupEntityColliderHandles.clear()}_requireSimulatedCollider(Z){if(!Z.rawCollider)u.error("ColliderMap._requireSimulatedCollider(): Collider is not in the simulation.");return!!Z.rawCollider}}var D10={type:"dynamic",softCcdPrediction:1},C10=0.015625,T10=Math.cos(0.026),qH;((R)=>{R.BLOCK_COLLISION="ENTITY.BLOCK_COLLISION";R.BLOCK_CONTACT_FORCE="ENTITY.BLOCK_CONTACT_FORCE";R.DESPAWN="ENTITY.DESPAWN";R.ENTITY_COLLISION="ENTITY.ENTITY_COLLISION";R.ENTITY_CONTACT_FORCE="ENTITY.ENTITY_CONTACT_FORCE";R.SET_MODEL_ANIMATIONS_PLAYBACK_RATE="ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE";R.SET_MODEL_HIDDEN_NODES="ENTITY.SET_MODEL_HIDDEN_NODES";R.SET_MODEL_SCALE="ENTITY.SET_MODEL_SCALE";R.SET_MODEL_SHOWN_NODES="ENTITY.SET_MODEL_SHOWN_NODES";R.SET_MODEL_TEXTURE_URI="ENTITY.SET_MODEL_TEXTURE_URI";R.SET_OPACITY="ENTITY.SET_OPACITY";R.SET_PARENT="ENTITY.SET_PARENT";R.SET_TINT_COLOR="ENTITY.SET_TINT_COLOR";R.SPAWN="ENTITY.SPAWN";R.START_MODEL_LOOPED_ANIMATIONS="ENTITY.START_MODEL_LOOPED_ANIMATIONS";R.START_MODEL_ONESHOT_ANIMATIONS="ENTITY.START_MODEL_ONESHOT_ANIMATIONS";R.STOP_MODEL_ANIMATIONS="ENTITY.STOP_MODEL_ANIMATIONS";R.TICK="ENTITY.TICK";R.UPDATE_POSITION="ENTITY.UPDATE_POSITION";R.UPDATE_ROTATION="ENTITY.UPDATE_ROTATION"})(qH||={});class u8 extends cY{_id;_blockHalfExtents;_blockTextureUri;_controller;_isEnvironmental=!1;_modelAnimationsPlaybackRate=1;_modelHiddenNodes=new Set;_modelLoopedAnimations=new Set;_modelOneshotAnimations=new Set;_modelPreferredShape;_modelScale=1;_modelShownNodes=new Set;_modelTextureUri;_modelUri;_name;_opacity;_parent;_parentNodeName;_tag;_tintColor;_lastUpdatedPosition={x:0,y:0,z:0};_lastUpdatedRotation={x:0,y:0,z:0,w:1};_lastParentlessType="dynamic";_world;_positionUpdateThresholdSq;_rotationUpdateThreshold;constructor(Z){let J="blockTextureUri"in Z,X="modelUri"in Z;if(!J===!X)u.fatalError("Entity.constructor(): Entity data must include a blockTextureUri or modelUri, but not both.");if(J&&!Z.blockHalfExtents)u.fatalError("Entity.constructor(): Block entity must have blockHalfExtents!");if(Z.parent&&!Z.parent.isSpawned)u.fatalError("Entity.constructor(): Parent entity must be spawned before child entity!");if(Z.parent?.modelUri&&Z.parentNodeName&&!E5.instance.modelHasNode(Z.parent.modelUri,Z.parentNodeName))u.fatalError(`Entity.constructor(): Parent node name ${Z.parentNodeName} not found in parent model ${Z.parent.modelUri}!`);super(Z.rigidBodyOptions??D10);if(J)this._blockHalfExtents=Z.blockHalfExtents,this._blockTextureUri=Z.blockTextureUri;if(X)this._modelAnimationsPlaybackRate=Z.modelAnimationsPlaybackRate??1,this._modelPreferredShape=Z.modelPreferredShape,this._modelScale=Z.modelScale??1,this._modelTextureUri=Z.modelTextureUri,this._modelUri=Z.modelUri,Z.modelHiddenNodes?.forEach((Y)=>this._modelHiddenNodes.add(Y.toLowerCase())),Z.modelLoopedAnimations?.forEach((Y)=>this._modelLoopedAnimations.add(Y)),Z.modelShownNodes?.forEach((Y)=>this._modelShownNodes.add(Y.toLowerCase()));if(this._isEnvironmental=Z.isEnvironmental??!1,this._name=Z.name??"Nameless",this._opacity=Z.opacity??1,this._parent=Z.parent,this._parentNodeName=Z.parentNodeName,this._tag=Z.tag,this._tintColor=Z.tintColor,this._positionUpdateThresholdSq=C10,this._rotationUpdateThreshold=T10,Z.controller)this.setController(Z.controller)}get id(){return this._id}get blockHalfExtents(){return this._blockHalfExtents}get blockTextureUri(){return this._blockTextureUri}get controller(){return this._controller}get depth(){return this.isModelEntity?E5.instance.getDepth(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.z*2}get height(){return this.isModelEntity?E5.instance.getHeight(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.y*2}get modelAnimationsPlaybackRate(){return this._modelAnimationsPlaybackRate}get modelHiddenNodes(){return this._modelHiddenNodes}get modelLoopedAnimations(){return this._modelLoopedAnimations}get modelPreferredShape(){return this._modelPreferredShape}get modelScale(){return this._modelScale}get modelShownNodes(){return this._modelShownNodes}get modelTextureUri(){return this._modelTextureUri}get modelUri(){return this._modelUri}get name(){return this._name}get opacity(){return this._opacity}get parent(){return this._parent}get parentNodeName(){return this._parentNodeName}get tag(){return this._tag}get tintColor(){return this._tintColor}get isBlockEntity(){return!!this._blockTextureUri}get isEnvironmental(){return this._isEnvironmental}get isModelEntity(){return!!this._modelUri}get isSpawned(){return!!this._world}get width(){return this.isModelEntity?E5.instance.getWidth(this._modelUri)*(this._modelScale??1):this._blockHalfExtents.x*2}get world(){return this._world}spawn(Z,J,X){if(this.isSpawned)return u.error(`Entity.spawn(): Entity ${this._name} is already spawned with id ${this._id}!`);if(!this.isSimulated)this.addToSimulation(Z.simulation);if(this._blockTextureUri&&this._blockHalfExtents&&this.numColliders===0)this.addChildColliderToSimulation(new e5(e5.optionsFromBlockHalfExtents(this._blockHalfExtents)));if(this._modelUri&&this.numColliders===0&&this._modelPreferredShape!=="none")this.addChildColliderToSimulation(new e5(e5.optionsFromModelUri(this._modelUri,this._modelScale,this._modelPreferredShape)));if(this.colliders.forEach((Y)=>{if(this.hasListeners("ENTITY.BLOCK_COLLISION")||this.hasListeners("ENTITY.ENTITY_COLLISION"))Y.enableCollisionEvents(!0);if(this.hasListeners("ENTITY.BLOCK_CONTACT_FORCE")||this.hasListeners("ENTITY.ENTITY_CONTACT_FORCE"))Y.enableContactForceEvents(!0);if(z4.isDefaultCollisionGroups(Y.collisionGroups))Y.setCollisionGroups({belongsTo:[Y.isSensor?4:2],collidesWith:[65535]})}),this.setPosition(J),X)this.setRotation(X);if(this._id=Z.entityManager.registerEntity(this),this._world=Z,this._controller)this._controller.spawn(this);if(this._parent)this.setParent(this._parent,this._parentNodeName,J,X);this.colliders.forEach((Y)=>{Z.simulation.colliderMap.setColliderEntity(Y,this)}),this.emitWithWorld(Z,"ENTITY.SPAWN",{entity:this})}despawn(){if(!this._requireSpawned("despawn"))return;if(this._world.entityManager.getEntityChildren(this).forEach((Z)=>{Z.despawn()}),this._controller)this._controller.detach(this),this._controller.despawn(this);if(this.emitWithWorld(this._world,"ENTITY.DESPAWN",{entity:this}),this.isSimulated)this.removeFromSimulation();this._world.entityManager.unregisterEntity(this),this._world.audioManager.unregisterEntityAttachedAudios(this),this._world.lightManager.despawnEntityAttachedLights(this),this._world.particleEmitterManager.despawnEntityAttachedParticleEmitters(this),this._world.sceneUIManager.unloadEntityAttachedSceneUIs(this),this._id=void 0,this._world=void 0}setController(Z){if(this._controller===Z)return;if(this._controller)this._controller.detach(this);if(this._controller=Z,this._controller)this._controller.attach(this)}setModelAnimationsPlaybackRate(Z){if(!this._requireSpawned("setModelAnimationsPlaybackRate"))return;if(!this.isModelEntity||this._modelAnimationsPlaybackRate===Z)return;this._modelAnimationsPlaybackRate=Z,this.emitWithWorld(this._world,"ENTITY.SET_MODEL_ANIMATIONS_PLAYBACK_RATE",{entity:this,playbackRate:Z})}setModelHiddenNodes(Z){if(!this._requireSpawned("setModelHiddenNodes"))return;if(!this.isModelEntity)return;this._modelHiddenNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_HIDDEN_NODES",{entity:this,modelHiddenNodes:this._modelHiddenNodes})}setModelScale(Z){if(!this._requireSpawned("setModelScale"))return;if(!this.isModelEntity||this._modelScale===Z)return;let J=Z/this._modelScale;this._modelScale=Z,this.colliders.forEach((X)=>X.scale(J)),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_SCALE",{entity:this,modelScale:Z})}setModelShownNodes(Z){if(!this._requireSpawned("setModelShownNodes"))return;if(!this.isModelEntity)return;this._modelShownNodes=new Set(Z.map((J)=>J.toLowerCase())),this.emitWithWorld(this._world,"ENTITY.SET_MODEL_SHOWN_NODES",{entity:this,modelShownNodes:this._modelShownNodes})}setModelTextureUri(Z){if(!this._requireSpawned("setModelTextureUri"))return;if(!this.isModelEntity||this._modelTextureUri===Z)return;this._modelTextureUri=Z,this.emitWithWorld(this._world,"ENTITY.SET_MODEL_TEXTURE_URI",{entity:this,modelTextureUri:Z})}setOpacity(Z){if(!this._requireSpawned("setOpacity"))return;if(this._opacity===Z)return;this._opacity=Z,this.emitWithWorld(this._world,"ENTITY.SET_OPACITY",{entity:this,opacity:Z})}setParent(Z,J,X,Y){if(!this._requireSpawned("setParent"))return;if(Z&&!Z.isSpawned)return u.error("Entity.setParent(): Parent entity is not spawned, cannot set parent!");if(!this._parent&&Z)this._lastParentlessType=this.type;if(this._parent=Z,this._parentNodeName=J,this.colliders.forEach(($)=>$.setEnabled(!Z)),this.setType(!Z?this._lastParentlessType:"kinematic_velocity"),this.setPosition(X??{x:0,y:0,z:0}),this.setRotation(Y??{x:0,y:0,z:0,w:1}),!this.isKinematicPositionBased)this.resetAngularVelocity(),this.resetForces(),this.resetLinearVelocity(),this.resetTorques();this.emitWithWorld(this._world,"ENTITY.SET_PARENT",{entity:this,parent:Z,parentNodeName:J})}setTintColor(Z){if(!this._requireSpawned("setTintColor"))return;if(!Z&&!this._tintColor||Z&&this._tintColor&&Z.r===this._tintColor.r&&Z.g===this._tintColor.g&&Z.b===this._tintColor.b)return;this._tintColor=Z,this.emitWithWorld(this._world,"ENTITY.SET_TINT_COLOR",{entity:this,tintColor:Z})}startModelLoopedAnimations(Z){if(!this._requireSpawned("startModelLoopedAnimations"))return;if(!this.isModelEntity||!Z.length)return;if(!Z.some((J)=>!this._modelLoopedAnimations.has(J)))return;Z.forEach((J)=>{this._modelLoopedAnimations.add(J)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_LOOPED_ANIMATIONS",{entity:this,animations:new Set(Z)})}startModelOneshotAnimations(Z){if(!this._requireSpawned("startModelOneshotAnimations"))return;if(!this.isModelEntity||!Z.length)return;Z.forEach((J)=>{this._modelOneshotAnimations.add(J)}),this.emitWithWorld(this._world,"ENTITY.START_MODEL_ONESHOT_ANIMATIONS",{entity:this,animations:new Set(Z)})}stopAllModelAnimations(Z=[]){if(!this._requireSpawned("stopAllModelAnimations"))return;this._stopAnimationsFromSets([this._modelLoopedAnimations,this._modelOneshotAnimations],Z)}stopAllModelLoopedAnimations(Z=[]){if(!this._requireSpawned("stopAllModelLoopedAnimations"))return;this._stopAnimationsFromSets([this._modelLoopedAnimations],Z)}stopAllModelOneshotAnimations(Z=[]){if(!this._requireSpawned("stopAllModelOneshotAnimations"))return;this._stopAnimationsFromSets([this._modelOneshotAnimations],Z)}stopModelAnimations(Z){if(!this._requireSpawned("stopModelAnimations"))return;if(!this.isModelEntity||!Z.length)return;if(!Z.some((J)=>this._modelLoopedAnimations.has(J))&&!Z.some((J)=>this._modelOneshotAnimations.has(J)))return;Z.forEach((J)=>{this._modelLoopedAnimations.delete(J),this._modelOneshotAnimations.delete(J)}),this.emitWithWorld(this._world,"ENTITY.STOP_MODEL_ANIMATIONS",{entity:this,animations:new Set(Z)})}serialize(){return M0.serializeEntity(this)}tick(Z){if(this.emit("ENTITY.TICK",{entity:this,tickDeltaMs:Z}),this._controller)this._controller.tick(this,Z)}checkAndEmitUpdates(){if(!this._requireSpawned("checkAndEmitUpdates"))return;let Z=this.position,J=this.rotation;if(this._rotationExceedsThreshold(J,this._lastUpdatedRotation))this._lastUpdatedRotation=J,this.emitWithWorld(this._world,"ENTITY.UPDATE_ROTATION",{entity:this,rotation:J});if(this._positionExceedsThreshold(Z,this._lastUpdatedPosition))this._lastUpdatedPosition=Z,this.emitWithWorld(this._world,"ENTITY.UPDATE_POSITION",{entity:this,position:Z})}_positionExceedsThreshold(Z,J){let X=Z.x-J.x,Y=Z.y-J.y,$=Z.z-J.z;return X*X+Y*Y+$*$>this._positionUpdateThresholdSq}_requireSpawned(Z){if(!this.isSpawned)u.error(`Entity._requireSpawned(): Entity ${this._name} is not spawned, cannot invoke ${Z}()!`);return this.isSpawned}_rotationExceedsThreshold(Z,J){return Math.abs(Z.x*J.x+Z.y*J.y+Z.z*J.z+Z.w*J.w)<this._rotationUpdateThreshold}_stopAnimationsFromSets(Z,J=[]){if(!this.isModelEntity)return;let X=new Set(J),Y=[];for(let $ of Z)for(let Q of $)if(!X.has(Q))Y.push(Q);if(Y.length>0)this.stopModelAnimations(Y)}}class h1 extends JY{static BASE_ENTITY_HEIGHT=1.5;static GROUND_SENSOR_HEIGHT_SCALE=0.125;static GROUND_SENSOR_RADIUS_SCALE=0.23;static JUMP_LAND_HEAVY_VELOCITY_THRESHOLD=-12;static WALL_COLLIDER_HEIGHT_SCALE=0.33;static WALL_COLLIDER_RADIUS_SCALE=0.4;static MOVEMENT_ROTATIONS={wa:Math.PI/4,wd:-Math.PI/4,sa:Math.PI-Math.PI/4,sd:Math.PI+Math.PI/4,s:Math.PI,asd:Math.PI,a:Math.PI/2,d:-Math.PI/2};static EXTERNAL_IMPULSE_DECAY_RATE=0.253;static SWIM_UPWARD_COOLDOWN_MS=600;static SWIMMING_DRAG_FACTOR=0.05;static WATER_ENTRY_SINKING_FACTOR=0.8;static WATER_ENTRY_SINKING_MS=250;applyDirectionalMovementRotations=!0;autoCancelMouseLeftClick=!0;canJump=()=>!0;canRun=()=>!0;canSwim=()=>!0;canWalk=()=>!0;faceForwardOnStop=!0;idleLoopedAnimations=["idle-upper","idle-lower"];interactOneshotAnimations=["simple-interact"];jumpLandHeavyOneshotAnimations=["jump-post-heavy"];jumpLandLightOneshotAnimations=["jump-post-light"];jumpOneshotAnimations=["jump-loop"];jumpVelocity=10;runLoopedAnimations=["run-upper","run-lower"];runVelocity=8;sticksToPlatforms=!0;swimFastVelocity=5;swimGravity=0;swimIdleLoopedAnimations=["swim-idle"];swimLoopedAnimations=["swim-forward"];swimMaxGravityVelocity=-1;swimSlowVelocity=3;swimUpwardVelocity=2;walkLoopedAnimations=["walk-upper","walk-lower"];walkVelocity=4;_externalVelocity={x:0,y:0,z:0};_magnitudeYTracker=0;_groundContactCount=0;_internalApplyImpulse=()=>{};_isActivelyMoving=!1;_isFullySubmerged=!1;_justSubmergedUntil=0;_liquidContactCount=0;_platform;_reusableImpulse={x:0,y:0,z:0};_reusablePlatformVelocity={x:0,y:0,z:0};_reusableTargetVelocities={x:0,y:0,z:0};_reusableVelocityClamp={x:0,y:0,z:0};_stepAudio;_swimUpwardCooldownAt=0;constructor(Z={}){super();this.applyDirectionalMovementRotations=Z.applyDirectionalMovementRotations??this.applyDirectionalMovementRotations,this.autoCancelMouseLeftClick=Z.autoCancelMouseLeftClick??this.autoCancelMouseLeftClick,this.faceForwardOnStop=Z.faceForwardOnStop??this.faceForwardOnStop,this.sticksToPlatforms=Z.sticksToPlatforms??this.sticksToPlatforms,this.canJump=Z.canJump??this.canJump,this.canRun=Z.canRun??this.canRun,this.canSwim=Z.canSwim??this.canSwim,this.canWalk=Z.canWalk??this.canWalk,this.jumpVelocity=Z.jumpVelocity??this.jumpVelocity,this.runVelocity=Z.runVelocity??this.runVelocity,this.walkVelocity=Z.walkVelocity??this.walkVelocity,this.swimFastVelocity=Z.swimFastVelocity??this.swimFastVelocity,this.swimSlowVelocity=Z.swimSlowVelocity??this.swimSlowVelocity,this.swimUpwardVelocity=Z.swimUpwardVelocity??this.swimUpwardVelocity,this.swimGravity=Z.swimGravity??this.swimGravity,this.swimMaxGravityVelocity=Z.swimMaxGravityVelocity??this.swimMaxGravityVelocity,this.idleLoopedAnimations=Z.idleLoopedAnimations??this.idleLoopedAnimations,this.interactOneshotAnimations=Z.interactOneshotAnimations??this.interactOneshotAnimations,this.jumpOneshotAnimations=Z.jumpOneshotAnimations??this.jumpOneshotAnimations,this.jumpLandHeavyOneshotAnimations=Z.jumpLandHeavyOneshotAnimations??this.jumpLandHeavyOneshotAnimations,this.jumpLandLightOneshotAnimations=Z.jumpLandLightOneshotAnimations??this.jumpLandLightOneshotAnimations,this.runLoopedAnimations=Z.runLoopedAnimations??this.runLoopedAnimations,this.swimLoopedAnimations=Z.swimLoopedAnimations??this.swimLoopedAnimations,this.swimIdleLoopedAnimations=Z.swimIdleLoopedAnimations??this.swimIdleLoopedAnimations,this.walkLoopedAnimations=Z.walkLoopedAnimations??this.walkLoopedAnimations}get isActivelyMoving(){return this._isActivelyMoving}get isGrounded(){return this._groundContactCount>0}get isOnPlatform(){return!!this._platform}get isSwimming(){return this._liquidContactCount>0}get platform(){return this._platform}attach(Z){super.attach(Z),this._internalApplyImpulse=Z.applyImpulse.bind(Z),Z.applyImpulse=(J)=>{let X=Z.mass||1;this._externalVelocity.x+=J.x/X,this._externalVelocity.y+=J.y/X,this._externalVelocity.z+=J.z/X},this._stepAudio=new mG({uri:"audio/sfx/step/stone/stone-step-04.mp3",loop:!0,volume:0.1,referenceDistance:2,cutoffDistance:15,attachedToEntity:Z}),Z.setCcdEnabled(!0),Z.lockAllRotations(),Z.on("ENTITY.BLOCK_COLLISION",({blockType:J,started:X})=>{if(!J.isLiquid||!this.canSwim(this))return;if(this._liquidContactCount<=0&&X){let Y=Z.linearVelocity;Z.setLinearVelocity({x:Y.x*this.swimGravity,y:Y.y*this.swimGravity,z:Y.z*this.swimGravity})}if(this._liquidContactCount+=X?1:-1,this._liquidContactCount>0)Z.setGravityScale(this.swimGravity),Z.stopAllModelLoopedAnimations(this.swimLoopedAnimations),this._swimUpwardCooldownAt=performance.now()+h1.SWIM_UPWARD_COOLDOWN_MS;else Z.setGravityScale(1),Z.stopModelAnimations(this.swimLoopedAnimations)})}spawn(Z){if(!Z.isSpawned)return u.error("DefaultPlayerEntityController.spawn(): Entity is not spawned!");Z.createAndAddChildCollider({shape:"cylinder",radius:h1.GROUND_SENSOR_RADIUS_SCALE*(Z.height/h1.BASE_ENTITY_HEIGHT),halfHeight:h1.GROUND_SENSOR_HEIGHT_SCALE*(Z.height/h1.BASE_ENTITY_HEIGHT),collisionGroups:{belongsTo:[4],collidesWith:[1,2]},isSensor:!0,relativePosition:{x:0,y:-Z.height/2,z:0},tag:"groundSensor",onCollision:(J,X)=>{if(!Z.isSpawned)return;if(!(J instanceof Z9)||!J.isLiquid){if(X&&this._groundContactCount===0&&Z.linearVelocity.y<-1)if(Z.linearVelocity.y<h1.JUMP_LAND_HEAVY_VELOCITY_THRESHOLD)Z.startModelOneshotAnimations(this.jumpLandHeavyOneshotAnimations);else Z.startModelOneshotAnimations(this.jumpLandLightOneshotAnimations);this._groundContactCount+=X?1:-1}if(!this._groundContactCount&&!this.isSwimming)Z.startModelOneshotAnimations(this.jumpOneshotAnimations);else Z.stopModelAnimations(this.jumpOneshotAnimations);if(!(J instanceof u8))return;if(X&&this.sticksToPlatforms)this._platform=J;else if(J===this._platform&&!X)this._platform=void 0}}),Z.createAndAddChildCollider({shape:"capsule",halfHeight:h1.WALL_COLLIDER_HEIGHT_SCALE*(Z.height/h1.BASE_ENTITY_HEIGHT),radius:h1.WALL_COLLIDER_RADIUS_SCALE*(Z.height/h1.BASE_ENTITY_HEIGHT),collisionGroups:{belongsTo:[4],collidesWith:[1,2]},friction:0,frictionCombineRule:1,tag:"wallCollider"})}tickWithPlayerInput(Z,J,X,Y){if(!Z.isSpawned||!Z.world)return;if(super.tickWithPlayerInput(Z,J,X,Y),Z.parent)return;let{w:$,a:Q,s:K,d:W,c:G,sp:V,sh:H,ml:F}=J,{yaw:z}=X,q=Z.linearVelocity;this._reusableTargetVelocities.x=0,this._reusableTargetVelocities.y=0,this._reusableTargetVelocities.z=0,this._isActivelyMoving=!!($||Q||K||W);let U=H,L=Q&&W&&!$&&!K||$&&K&&!Q&&!W,B=U&&this.canRun(this)||!U&&this.canWalk(this);if(this.isSwimming&&!this._isFullySubmerged)this._isFullySubmerged=!0,this._justSubmergedUntil=performance.now()+h1.WATER_ENTRY_SINKING_MS;else if(!this.isSwimming)this._isFullySubmerged=!1,this._justSubmergedUntil=0;if(this.isGrounded&&!this.isSwimming&&this._isActivelyMoving&&!L&&B){let M=U?this.runLoopedAnimations:this.walkLoopedAnimations;Z.stopAllModelLoopedAnimations(M),Z.startModelLoopedAnimations(M),this._stepAudio?.setPlaybackRate(U?0.75:0.51),this._stepAudio?.play(Z.world,!this._stepAudio?.isPlaying)}else if(this._isFullySubmerged&&this.canSwim(this))if(this._stepAudio?.pause(),this._isActivelyMoving)Z.stopAllModelLoopedAnimations(this.swimLoopedAnimations),Z.startModelLoopedAnimations(this.swimLoopedAnimations);else Z.stopAllModelLoopedAnimations(this.swimIdleLoopedAnimations),Z.startModelLoopedAnimations(this.swimIdleLoopedAnimations);else this._stepAudio?.pause(),Z.stopAllModelLoopedAnimations(this.idleLoopedAnimations),Z.startModelLoopedAnimations(this.idleLoopedAnimations);let w;if(this.applyDirectionalMovementRotations&&B){if($&&Q&&!W&&!K)w=h1.MOVEMENT_ROTATIONS.wa;else if($&&W&&!Q&&!K)w=h1.MOVEMENT_ROTATIONS.wd;else if(K&&Q&&!$&&!W)w=h1.MOVEMENT_ROTATIONS.sa;else if(K&&W&&!$&&!Q)w=h1.MOVEMENT_ROTATIONS.sd;else if(K&&!$&&!Q&&!W||Q&&K&&W&&!$)w=h1.MOVEMENT_ROTATIONS.s;else if(Q&&!$&&!K&&!W)w=h1.MOVEMENT_ROTATIONS.a;else if(W&&!$&&!Q&&!K)w=h1.MOVEMENT_ROTATIONS.d}if(F)Z.startModelOneshotAnimations(this.interactOneshotAnimations),J.ml=!this.autoCancelMouseLeftClick;if(B){let M=!this.isSwimming?U?this.runVelocity:this.walkVelocity:U?this.swimFastVelocity:this.swimSlowVelocity,C=Math.sin(z),T=Math.cos(z);if($)this._reusableTargetVelocities.x-=M*C,this._reusableTargetVelocities.z-=M*T;if(K)this._reusableTargetVelocities.x+=M*C,this._reusableTargetVelocities.z+=M*T;if(Q)this._reusableTargetVelocities.x-=M*T,this._reusableTargetVelocities.z+=M*C;if(W)this._reusableTargetVelocities.x+=M*T,this._reusableTargetVelocities.z-=M*C;let E=Math.sqrt(this._reusableTargetVelocities.x*this._reusableTargetVelocities.x+this._reusableTargetVelocities.z*this._reusableTargetVelocities.z);if(E>M){let x=M/E;this._reusableTargetVelocities.x*=x,this._reusableTargetVelocities.z*=x}}if(this.isSwimming){if(q.y<this.swimMaxGravityVelocity)this._reusableVelocityClamp.x=q.x,this._reusableVelocityClamp.y=this.swimMaxGravityVelocity,this._reusableVelocityClamp.z=q.z,Z.setLinearVelocity(this._reusableVelocityClamp);if(q.y>this.swimUpwardVelocity*2)this._reusableVelocityClamp.x=q.x,this._reusableVelocityClamp.y=this.swimUpwardVelocity*2,this._reusableVelocityClamp.z=q.z,Z.setLinearVelocity(this._reusableVelocityClamp);if(G)this._reusableTargetVelocities.y=-this.swimUpwardVelocity;else if(performance.now()<this._justSubmergedUntil)this._reusableTargetVelocities.y=-this.swimUpwardVelocity*h1.WATER_ENTRY_SINKING_FACTOR;else if(!V)this._reusableTargetVelocities.y=-q.y*h1.SWIMMING_DRAG_FACTOR}if(V&&this.canJump(this)){if(this.isGrounded&&!this.isSwimming&&q.y>-0.001&&q.y<=3)this._reusableTargetVelocities.y=this.jumpVelocity;else if(this.isSwimming&&performance.now()>this._swimUpwardCooldownAt)this._reusableTargetVelocities.y=this.swimUpwardVelocity}let O=this._platform?.linearVelocity??this._reusablePlatformVelocity;if(this._externalVelocity.y!==0)this._magnitudeYTracker+=this._externalVelocity.y;if(this._externalVelocity.x!==0||this._externalVelocity.y!==0||this._externalVelocity.z!==0){if(this.isGrounded){let M=Math.sqrt(this._externalVelocity.x*this._externalVelocity.x+this._magnitudeYTracker*this._magnitudeYTracker+this._externalVelocity.z*this._externalVelocity.z);if(M>0.01){let T=Math.max(0,M-h1.EXTERNAL_IMPULSE_DECAY_RATE)/M;this._externalVelocity.x*=T,this._magnitudeYTracker*=T,this._externalVelocity.z*=T}else this._externalVelocity.x=0,this._externalVelocity.y=0,this._magnitudeYTracker=0,this._externalVelocity.z=0}}let N=this._reusableTargetVelocities.x+this._externalVelocity.x-q.x+O.x,R=this._reusableTargetVelocities.y+this._externalVelocity.y+O.y,D=this._reusableTargetVelocities.z+this._externalVelocity.z-q.z+O.z;if(this._externalVelocity.y=0,N!==0||R!==0||D!==0){let M=Z.mass;this._reusableImpulse.x=N*M,this._reusableImpulse.y=R*M,this._reusableImpulse.z=D*M,this._internalApplyImpulse(this._reusableImpulse)}if(z!==void 0&&(this.faceForwardOnStop||this.isActivelyMoving)){let C=(w!==void 0?z+w:z)*0.5;Z.setRotation({x:0,y:Math.sin(C),z:0,w:Math.cos(C)})}}}var Mk;((W)=>{W.LOAD="SCENE_UI.LOAD";W.SET_ATTACHED_TO_ENTITY="SCENE_UI.SET_ATTACHED_TO_ENTITY";W.SET_OFFSET="SCENE_UI.SET_OFFSET";W.SET_POSITION="SCENE_UI.SET_POSITION";W.SET_STATE="SCENE_UI.SET_STATE";W.SET_VIEW_DISTANCE="SCENE_UI.SET_VIEW_DISTANCE";W.UNLOAD="SCENE_UI.UNLOAD"})(Mk||={});class UH extends B0{_id;_attachedToEntity;_offset;_position;_state={};_templateId;_viewDistance;_world;constructor(Z){if(!!Z.attachedToEntity===!!Z.position)u.fatalError("Either attachedToEntity or position must be set, but not both");super();this._attachedToEntity=Z.attachedToEntity,this._offset=Z.offset,this._position=Z.position,this._state=Z.state??{},this._templateId=Z.templateId,this._viewDistance=Z.viewDistance}get id(){return this._id}get attachedToEntity(){return this._attachedToEntity}get isLoaded(){return this._id!==void 0}get offset(){return this._offset}get position(){return this._position}get state(){return this._state}get templateId(){return this._templateId}get viewDistance(){return this._viewDistance}get world(){return this._world}load(Z){if(this.isLoaded)return;if(this._attachedToEntity&&!this._attachedToEntity.isSpawned)return u.error(`SceneUI.load(): Attached entity ${this._attachedToEntity.id} must be spawned before loading SceneUI!`);this._id=Z.sceneUIManager.registerSceneUI(this),this._world=Z,this.emitWithWorld(Z,"SCENE_UI.LOAD",{sceneUI:this})}setAttachedToEntity(Z){if(!Z.isSpawned)return u.error(`SceneUI.setAttachedToEntity(): Entity ${Z.id} is not spawned!`);if(this._attachedToEntity===Z)return;if(this._attachedToEntity=Z,this._position=void 0,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_ATTACHED_TO_ENTITY",{sceneUI:this,entity:Z})}setOffset(Z){if(this._offset===Z)return;if(this._offset=Z,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_OFFSET",{sceneUI:this,offset:Z})}setPosition(Z){if(this._position===Z)return;if(this._attachedToEntity=void 0,this._position=Z,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_POSITION",{sceneUI:this,position:Z})}setState(Z){if(this._state={...this._state,...Z},this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_STATE",{sceneUI:this,state:this._state})}setViewDistance(Z){if(this._viewDistance=Z,this.isLoaded)this.emitWithWorld(this._world,"SCENE_UI.SET_VIEW_DISTANCE",{sceneUI:this,viewDistance:Z})}unload(){if(!this.isLoaded||!this._world)return;this._world.sceneUIManager.unregisterSceneUI(this),this.emitWithWorld(this._world,"SCENE_UI.UNLOAD",{sceneUI:this}),this._id=void 0,this._world=void 0}serialize(){return M0.serializeSceneUI(this)}}var E10=0.010000000000000002,k10=Math.cos(0.026);class R7 extends u8{player;nametagSceneUI;constructor(Z){super(Z);this._positionUpdateThresholdSq=E10,this._rotationUpdateThreshold=k10,this.player=Z.player,this.nametagSceneUI=new UH({templateId:"hytopia:nametag",attachedToEntity:this,offset:{x:0,y:1,z:0},viewDistance:15,state:{username:this.player.username,profilePictureUrl:this.player.profilePictureUrl}})}spawn(Z,J,X){super.spawn(Z,J,X),this.nametagSceneUI.load(Z),this.player.on("PLAYER.CHAT_MESSAGE_SEND",({message:Y})=>{this.nametagSceneUI.setState({chat:Y})})}tick(Z){if(!this.isSpawned||!this.world)return;if(!this.controller)return u.error(`PlayerEntity.tick(): PlayerEntity "${this.name}" must have a controller.`);let{input:J,camera:X}=this.player;this.controller.tickWithPlayerInput(this,J,X.orientation,Z),super.tick(Z)}}class Pk extends R7{constructor(Z){super({modelUri:"models/players/player.gltf",modelLoopedAnimations:["idle_lower","idle_upper"],modelHiddenNodes:["hair-"],modelShownNodes:["hair-0003"],...Z});if(!Z.controller)this.setController(new h1)}}class LH{_activeEntities=new Set;_entities=new Map;_nextEntityId=1;_world;constructor(Z){this._world=Z}get entityCount(){return this._entities.size}get world(){return this._world}registerEntity(Z){if(Z.id!==void 0)u.fatalError(`EntityManager.registerEntity(): Entity ${Z.name} is already assigned the id ${Z.id}!`);let J=this._nextEntityId;if(this._entities.set(J,Z),this._nextEntityId++,!Z.isEnvironmental)this._activeEntities.add(Z);return J}unregisterEntity(Z){if(Z.id===void 0)return u.error(`EntityManager.unregisterEntity(): Entity ${Z.name} is not assigned an id!`);if(this._entities.delete(Z.id),!Z.isEnvironmental)this._activeEntities.delete(Z)}getAllEntities(){return Array.from(this._entities.values())}getAllPlayerEntities(){let Z=[];return this._entities.forEach((J)=>{if(J instanceof R7)Z.push(J)}),Z}getPlayerEntitiesByPlayer(Z){let J=[];return this._entities.forEach((X)=>{if(X instanceof R7&&X.player===Z)J.push(X)}),J}getEntity(Z){return this._entities.get(Z)}getEntitiesByTag(Z){let J=[];return this._entities.forEach((X)=>{if(X.tag===Z)J.push(X)}),J}getEntitiesByTagSubstring(Z){let J=[];return this._entities.forEach((X)=>{if(X.tag?.includes(Z))J.push(X)}),J}getEntityChildren(Z){let J=[];return this._entities.forEach((X)=>{if(X.parent===Z)J.push(X)}),J}tickEntities(Z){for(let J of this._activeEntities)J.tick(Z)}checkAndEmitUpdates(){for(let Z of this._activeEntities)Z.checkAndEmitUpdates()}}var BK1=r(gQ(),1);var vA1=r(P80(),1),SA1=r(Ik(),1),AA1=r(vk(),1),bk=r(Qw(),1),gk=r(_80(),1);var X5=r(x60(),1),Qf6=X5.default.v1,Kf6=X5.default.v1ToV6,Wf6=X5.default.v3,h60=X5.default.v4,Gf6=X5.default.v5,Vf6=X5.default.v6,Hf6=X5.default.v6ToV1,zf6=X5.default.v7,Ff6=X5.default.NIL,qf6=X5.default.MAX,Uf6=X5.default.version,Lf6=X5.default.validate,Bf6=X5.default.stringify,wf6=X5.default.parse;var nk;try{nk=new TextDecoder}catch(Z){}var e,Y9,b=0;var rk=[],Y$=rk,TH=0,_1={},X1,SZ,X9=0,h9=0,d8,AZ,A5=[],t0,f60={useRecords:!1,mapsAsObjects:!0};class Uw{}var tk=new Uw;tk.name="MessagePack 0xC1";var tJ=!1,l60=2,ak,sk,ok;try{new Function("")}catch(Z){l60=1/0}class xZ{constructor(Z){if(Z){if(Z.useRecords===!1&&Z.mapsAsObjects===void 0)Z.mapsAsObjects=!0;if(Z.sequential&&Z.trusted!==!1){if(Z.trusted=!0,!Z.structures&&Z.useRecords!=!1){if(Z.structures=[],!Z.maxSharedStructures)Z.maxSharedStructures=0}}if(Z.structures)Z.structures.sharedLength=Z.structures.length;else if(Z.getStructures)(Z.structures=[]).uninitialized=!0,Z.structures.sharedLength=0;if(Z.int64AsNumber)Z.int64AsType="number"}Object.assign(this,Z)}unpack(Z,J){if(e)return J50(()=>{return qw(),this?this.unpack(Z,J):xZ.prototype.unpack.call(f60,Z,J)});if(!Z.buffer&&Z.constructor===ArrayBuffer)Z=typeof Buffer!=="undefined"?Buffer.from(Z):new Uint8Array(Z);if(typeof J==="object")Y9=J.end||Z.length,b=J.start||0;else b=0,Y9=J>-1?J:Z.length;TH=0,h9=0,SZ=null,Y$=rk,d8=null,e=Z;try{t0=Z.dataView||(Z.dataView=new DataView(Z.buffer,Z.byteOffset,Z.byteLength))}catch(X){if(e=null,Z instanceof Uint8Array)throw X;throw new Error("Source must be a Uint8Array or Buffer but was a "+(Z&&typeof Z=="object"?Z.constructor.name:typeof Z))}if(this instanceof xZ){if(_1=this,this.structures)return X1=this.structures,zw(J);else if(!X1||X1.length>0)X1=[]}else if(_1=f60,!X1||X1.length>0)X1=[];return zw(J)}unpackMultiple(Z,J){let X,Y=0;try{tJ=!0;let $=Z.length,Q=this?this.unpack(Z,$):Lw.unpack(Z,$);if(J){if(J(Q,Y,b)===!1)return;while(b<$)if(Y=b,J(zw(),Y,b)===!1)return}else{X=[Q];while(b<$)Y=b,X.push(zw());return X}}catch($){throw $.lastPosition=Y,$.values=X,$}finally{tJ=!1,qw()}}_mergeStructures(Z,J){if(sk)Z=sk.call(this,Z);if(Z=Z||[],Object.isFrozen(Z))Z=Z.map((X)=>X.slice(0));for(let X=0,Y=Z.length;X<Y;X++){let $=Z[X];if($){if($.isShared=!0,X>=32)$.highByte=X-32>>5}}Z.sharedLength=Z.length;for(let X in J||[])if(X>=0){let Y=Z[X],$=J[X];if($){if(Y)(Z.restoreStructures||(Z.restoreStructures=[]))[X]=Y;Z[X]=$}}return this.structures=Z}decode(Z,J){return this.unpack(Z,J)}}function zw(Z){try{if(!_1.trusted&&!tJ){let X=X1.sharedLength||0;if(X<X1.length)X1.length=X}let J;if(_1.randomAccessStructure&&e[b]<64&&e[b]>=32&&ak){if(J=ak(e,b,Y9,_1),e=null,!(Z&&Z.lazy)&&J)J=J.toJSON();b=Y9}else J=P8();if(d8)b=d8.postBundlePosition,d8=null;if(tJ)X1.restoreStructures=null;if(b==Y9){if(X1&&X1.restoreStructures)y60();if(X1=null,e=null,AZ)AZ=null}else if(b>Y9)throw new Error("Unexpected end of MessagePack data");else if(!tJ){let X;try{X=JSON.stringify(J,(Y,$)=>typeof $==="bigint"?`${$}n`:$).slice(0,100)}catch(Y){X="(JSON view not available "+Y+")"}throw new Error("Data read, but end of buffer not reached "+X)}return J}catch(J){if(X1&&X1.restoreStructures)y60();if(qw(),J instanceof RangeError||J.message.startsWith("Unexpected end of buffer")||b>Y9)J.incomplete=!0;throw J}}function y60(){for(let Z in X1.restoreStructures)X1[Z]=X1.restoreStructures[Z];X1.restoreStructures=null}function P8(){let Z=e[b++];if(Z<160)if(Z<128)if(Z<64)return Z;else{let J=X1[Z&63]||_1.getStructures&&p60()[Z&63];if(J){if(!J.read)J.read=ek(J,Z&63);return J.read()}else return Z}else if(Z<144)if(Z-=128,_1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let Y=e60();if(Y==="__proto__")Y="__proto_";J[Y]=P8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(P8(),P8());return J}else{Z-=144;let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=P8();if(_1.freezeData)return Object.freeze(J);return J}else if(Z<192){let J=Z-160;if(h9>=b)return SZ.slice(b-X9,(b+=J)-X9);if(h9==0&&Y9<140){let X=J<16?ZI(J):t60(J);if(X!=null)return X}return Fw(J)}else{let J;switch(Z){case 192:return null;case 193:if(d8)if(J=P8(),J>0)return d8[1].slice(d8.position1,d8.position1+=J);else return d8[0].slice(d8.position0,d8.position0-=J);return tk;case 194:return!1;case 195:return!0;case 196:if(J=e[b++],J===void 0)throw new Error("Unexpected end of buffer");return ik(J);case 197:return J=t0.getUint16(b),b+=2,ik(J);case 198:return J=t0.getUint32(b),b+=4,ik(J);case 199:return X$(e[b++]);case 200:return J=t0.getUint16(b),b+=2,X$(J);case 201:return J=t0.getUint32(b),b+=4,X$(J);case 202:if(J=t0.getFloat32(b),_1.useFloat32>2){let X=Q$[(e[b]&127)<<1|e[b+1]>>7];return b+=4,(X*J+(J>0?0.5:-0.5)>>0)/X}return b+=4,J;case 203:return J=t0.getFloat64(b),b+=8,J;case 204:return e[b++];case 205:return J=t0.getUint16(b),b+=2,J;case 206:return J=t0.getUint32(b),b+=4,J;case 207:if(_1.int64AsType==="number")J=t0.getUint32(b)*4294967296,J+=t0.getUint32(b+4);else if(_1.int64AsType==="string")J=t0.getBigUint64(b).toString();else if(_1.int64AsType==="auto"){if(J=t0.getBigUint64(b),J<=BigInt(2)<<BigInt(52))J=Number(J)}else J=t0.getBigUint64(b);return b+=8,J;case 208:return t0.getInt8(b++);case 209:return J=t0.getInt16(b),b+=2,J;case 210:return J=t0.getInt32(b),b+=4,J;case 211:if(_1.int64AsType==="number")J=t0.getInt32(b)*4294967296,J+=t0.getUint32(b+4);else if(_1.int64AsType==="string")J=t0.getBigInt64(b).toString();else if(_1.int64AsType==="auto"){if(J=t0.getBigInt64(b),J>=BigInt(-2)<<BigInt(52)&&J<=BigInt(2)<<BigInt(52))J=Number(J)}else J=t0.getBigInt64(b);return b+=8,J;case 212:if(J=e[b++],J==114)return c60(e[b++]&63);else{let X=A5[J];if(X)if(X.read)return b++,X.read(P8());else if(X.noBuffer)return b++,X();else return X(e.subarray(b,++b));else throw new Error("Unknown extension "+J)}case 213:if(J=e[b],J==114)return b++,c60(e[b++]&63,e[b++]);else return X$(2);case 214:return X$(4);case 215:return X$(8);case 216:return X$(16);case 217:if(J=e[b++],h9>=b)return SZ.slice(b-X9,(b+=J)-X9);return i60(J);case 218:if(J=t0.getUint16(b),b+=2,h9>=b)return SZ.slice(b-X9,(b+=J)-X9);return n60(J);case 219:if(J=t0.getUint32(b),b+=4,h9>=b)return SZ.slice(b-X9,(b+=J)-X9);return a60(J);case 220:return J=t0.getUint16(b),b+=2,g60(J);case 221:return J=t0.getUint32(b),b+=4,g60(J);case 222:return J=t0.getUint16(b),b+=2,m60(J);case 223:return J=t0.getUint32(b),b+=4,m60(J);default:if(Z>=224)return Z-256;if(Z===void 0){let X=new Error("Unexpected end of MessagePack data");throw X.incomplete=!0,X}throw new Error("Unknown MessagePack token "+Z)}}}var Gh1=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ek(Z,J){function X(){if(X.count++>l60){let $=Z.read=new Function("r","return function(){return "+(_1.freezeData?"Object.freeze":"")+"({"+Z.map((Q)=>Q==="__proto__"?"__proto_:r()":Gh1.test(Q)?Q+":r()":"["+JSON.stringify(Q)+"]:r()").join(",")+"})}")(P8);if(Z.highByte===0)Z.read=b60(J,Z.read);return $()}let Y={};for(let $=0,Q=Z.length;$<Q;$++){let K=Z[$];if(K==="__proto__")K="__proto_";Y[K]=P8()}if(_1.freezeData)return Object.freeze(Y);return Y}if(X.count=0,Z.highByte===0)return b60(J,X);return X}var b60=(Z,J)=>{return function(){let X=e[b++];if(X===0)return J();let Y=Z<32?-(Z+(X<<5)):Z+(X<<5),$=X1[Y]||p60()[Y];if(!$)throw new Error("Record id is not defined for "+Y);if(!$.read)$.read=ek($,Z);return $.read()}};function p60(){let Z=J50(()=>{return e=null,_1.getStructures()});return X1=_1._mergeStructures(Z,X1)}var Fw=$$,i60=$$,n60=$$,a60=$$,s60=!1;function o60(Z){s60=!0,Fw=J(1),i60=J(2),n60=J(3),a60=J(5);function J(X){return function Y($){let Q=Y$[TH++];if(Q==null){if(d8)return $$($);let W=e.byteOffset,G=Z(b-X+W,Y9+W,e.buffer);if(typeof G=="string")Q=G,Y$=rk;else if(Y$=G,TH=1,h9=1,Q=Y$[0],Q===void 0)throw new Error("Unexpected end of buffer")}let K=Q.length;if(K<=$)return b+=$,Q;return SZ=Q,X9=b,h9=b+K,b+=$,Q.slice(0,$)}}}function $$(Z){let J;if(Z<16){if(J=ZI(Z))return J}if(Z>64&&nk)return nk.decode(e.subarray(b,b+=Z));let X=b+Z,Y=[];J="";while(b<X){let $=e[b++];if(($&128)===0)Y.push($);else if(($&224)===192){let Q=e[b++]&63;Y.push(($&31)<<6|Q)}else if(($&240)===224){let Q=e[b++]&63,K=e[b++]&63;Y.push(($&31)<<12|Q<<6|K)}else if(($&248)===240){let Q=e[b++]&63,K=e[b++]&63,W=e[b++]&63,G=($&7)<<18|Q<<12|K<<6|W;if(G>65535)G-=65536,Y.push(G>>>10&1023|55296),G=56320|G&1023;Y.push(G)}else Y.push($);if(Y.length>=4096)J+=J6.apply(String,Y),Y.length=0}if(Y.length>0)J+=J6.apply(String,Y);return J}function r60(Z,J,X){let Y=e;e=Z,b=J;try{return $$(X)}finally{e=Y}}function g60(Z){let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=P8();if(_1.freezeData)return Object.freeze(J);return J}function m60(Z){if(_1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let Y=e60();if(Y==="__proto__")Y="__proto_";J[Y]=P8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(P8(),P8());return J}}var J6=String.fromCharCode;function t60(Z){let J=b,X=new Array(Z);for(let Y=0;Y<Z;Y++){let $=e[b++];if(($&128)>0){b=J;return}X[Y]=$}return J6.apply(String,X)}function ZI(Z){if(Z<4)if(Z<2)if(Z===0)return"";else{let J=e[b++];if((J&128)>1){b-=1;return}return J6(J)}else{let J=e[b++],X=e[b++];if((J&128)>0||(X&128)>0){b-=2;return}if(Z<3)return J6(J,X);let Y=e[b++];if((Y&128)>0){b-=3;return}return J6(J,X,Y)}else{let J=e[b++],X=e[b++],Y=e[b++],$=e[b++];if((J&128)>0||(X&128)>0||(Y&128)>0||($&128)>0){b-=4;return}if(Z<6)if(Z===4)return J6(J,X,Y,$);else{let Q=e[b++];if((Q&128)>0){b-=5;return}return J6(J,X,Y,$,Q)}else if(Z<8){let Q=e[b++],K=e[b++];if((Q&128)>0||(K&128)>0){b-=6;return}if(Z<7)return J6(J,X,Y,$,Q,K);let W=e[b++];if((W&128)>0){b-=7;return}return J6(J,X,Y,$,Q,K,W)}else{let Q=e[b++],K=e[b++],W=e[b++],G=e[b++];if((Q&128)>0||(K&128)>0||(W&128)>0||(G&128)>0){b-=8;return}if(Z<10)if(Z===8)return J6(J,X,Y,$,Q,K,W,G);else{let V=e[b++];if((V&128)>0){b-=9;return}return J6(J,X,Y,$,Q,K,W,G,V)}else if(Z<12){let V=e[b++],H=e[b++];if((V&128)>0||(H&128)>0){b-=10;return}if(Z<11)return J6(J,X,Y,$,Q,K,W,G,V,H);let F=e[b++];if((F&128)>0){b-=11;return}return J6(J,X,Y,$,Q,K,W,G,V,H,F)}else{let V=e[b++],H=e[b++],F=e[b++],z=e[b++];if((V&128)>0||(H&128)>0||(F&128)>0||(z&128)>0){b-=12;return}if(Z<14)if(Z===12)return J6(J,X,Y,$,Q,K,W,G,V,H,F,z);else{let q=e[b++];if((q&128)>0){b-=13;return}return J6(J,X,Y,$,Q,K,W,G,V,H,F,z,q)}else{let q=e[b++],U=e[b++];if((q&128)>0||(U&128)>0){b-=14;return}if(Z<15)return J6(J,X,Y,$,Q,K,W,G,V,H,F,z,q,U);let L=e[b++];if((L&128)>0){b-=15;return}return J6(J,X,Y,$,Q,K,W,G,V,H,F,z,q,U,L)}}}}}function u60(){let Z=e[b++],J;if(Z<192)J=Z-160;else switch(Z){case 217:J=e[b++];break;case 218:J=t0.getUint16(b),b+=2;break;case 219:J=t0.getUint32(b),b+=4;break;default:throw new Error("Expected string")}return $$(J)}function ik(Z){return _1.copyBuffers?Uint8Array.prototype.slice.call(e,b,b+=Z):e.subarray(b,b+=Z)}function X$(Z){let J=e[b++];if(A5[J]){let X;return A5[J](e.subarray(b,X=b+=Z),(Y)=>{b=Y;try{return P8()}finally{b=X}})}else throw new Error("Unknown extension type "+J)}var d60=new Array(4096);function e60(){let Z=e[b++];if(Z>=160&&Z<192){if(Z=Z-160,h9>=b)return SZ.slice(b-X9,(b+=Z)-X9);else if(!(h9==0&&Y9<180))return Fw(Z)}else return b--,Z50(P8());let J=(Z<<5^(Z>1?t0.getUint16(b):Z>0?e[b]:0))&4095,X=d60[J],Y=b,$=b+Z-3,Q,K=0;if(X&&X.bytes==Z){while(Y<$){if(Q=t0.getUint32(Y),Q!=X[K++]){Y=1879048192;break}Y+=4}$+=3;while(Y<$)if(Q=e[Y++],Q!=X[K++]){Y=1879048192;break}if(Y===$)return b=Y,X.string;$-=3,Y=b}X=[],d60[J]=X,X.bytes=Z;while(Y<$)Q=t0.getUint32(Y),X.push(Q),Y+=4;$+=3;while(Y<$)Q=e[Y++],X.push(Q);let W=Z<16?ZI(Z):t60(Z);if(W!=null)return X.string=W;return X.string=Fw(Z)}function Z50(Z){if(typeof Z==="string")return Z;if(typeof Z==="number"||typeof Z==="boolean"||typeof Z==="bigint")return Z.toString();if(Z==null)return Z+"";if(_1.allowArraysInMapKeys&&Array.isArray(Z)&&Z.flat().every((J)=>["string","number","boolean","bigint"].includes(typeof J)))return Z.flat().toString();throw new Error(`Invalid property type for record: ${typeof Z}`)}var c60=(Z,J)=>{let X=P8().map(Z50),Y=Z;if(J!==void 0)Z=Z<32?-((J<<5)+Z):(J<<5)+Z,X.highByte=J;let $=X1[Z];if($&&($.isShared||tJ))(X1.restoreStructures||(X1.restoreStructures=[]))[Z]=$;return X1[Z]=X,X.read=ek(X,Y),X.read()};A5[0]=()=>{};A5[0].noBuffer=!0;A5[66]=(Z)=>{let J=Z.length,X=BigInt(Z[0]&128?Z[0]-256:Z[0]);for(let Y=1;Y<J;Y++)X<<=BigInt(8),X+=BigInt(Z[Y]);return X};var Vh1={Error,TypeError,ReferenceError};A5[101]=()=>{let Z=P8();return(Vh1[Z[0]]||Error)(Z[1],{cause:Z[2]})};A5[105]=(Z)=>{if(_1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=t0.getUint32(b-4);if(!AZ)AZ=new Map;let X=e[b],Y;if(X>=144&&X<160||X==220||X==221)Y=[];else if(X>=128&&X<144||X==222||X==223)Y=new Map;else if((X>=199&&X<=201||X>=212&&X<=216)&&e[b+1]===115)Y=new Set;else Y={};let $={target:Y};AZ.set(J,$);let Q=P8();if(!$.used)return $.target=Q;else Object.assign(Y,Q);if(Y instanceof Map)for(let[K,W]of Q.entries())Y.set(K,W);if(Y instanceof Set)for(let K of Array.from(Q))Y.add(K);return Y};A5[112]=(Z)=>{if(_1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=t0.getUint32(b-4),X=AZ.get(J);return X.used=!0,X.target};A5[115]=()=>new Set(P8());var JI=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((Z)=>Z+"Array"),Hh1=typeof globalThis==="object"?globalThis:window;A5[116]=(Z)=>{let J=Z[0],X=Uint8Array.prototype.slice.call(Z,1).buffer,Y=JI[J];if(!Y){if(J===16)return X;if(J===17)return new DataView(X);throw new Error("Could not find typed array for code "+J)}return new Hh1[Y](X)};A5[120]=()=>{let Z=P8();return new RegExp(Z[0],Z[1])};var zh1=[];A5[98]=(Z)=>{let J=(Z[0]<<24)+(Z[1]<<16)+(Z[2]<<8)+Z[3],X=b;return b+=J-Z.length,d8=zh1,d8=[u60(),u60()],d8.position0=0,d8.position1=0,d8.postBundlePosition=b,b=X,P8()};A5[255]=(Z)=>{if(Z.length==4)return new Date((Z[0]*16777216+(Z[1]<<16)+(Z[2]<<8)+Z[3])*1000);else if(Z.length==8)return new Date(((Z[0]<<22)+(Z[1]<<14)+(Z[2]<<6)+(Z[3]>>2))/1e6+((Z[3]&3)*4294967296+Z[4]*16777216+(Z[5]<<16)+(Z[6]<<8)+Z[7])*1000);else if(Z.length==12)return new Date(((Z[0]<<24)+(Z[1]<<16)+(Z[2]<<8)+Z[3])/1e6+((Z[4]&128?-281474976710656:0)+Z[6]*1099511627776+Z[7]*4294967296+Z[8]*16777216+(Z[9]<<16)+(Z[10]<<8)+Z[11])*1000);else return new Date("invalid")};function J50(Z){if(ok)ok();let J=Y9,X=b,Y=TH,$=X9,Q=h9,K=SZ,W=Y$,G=AZ,V=d8,H=new Uint8Array(e.slice(0,Y9)),F=X1,z=X1.slice(0,X1.length),q=_1,U=tJ,L=Z();return Y9=J,b=X,TH=Y,X9=$,h9=Q,SZ=K,Y$=W,AZ=G,d8=V,e=H,tJ=U,X1=F,X1.splice(0,X1.length,...z),_1=q,t0=new DataView(e.buffer,e.byteOffset,e.byteLength),L}function qw(){e=null,AZ=null,X1=null}var Q$=new Array(147);for(let Z=0;Z<256;Z++)Q$[Z]=+("1e"+Math.floor(45.15-Z*0.30103));var Lw=new xZ({useRecords:!1}),Fh1=Lw.unpack,qh1=Lw.unpackMultiple,Uh1=Lw.unpack;var Lh1=new Float32Array(1),Of6=new Uint8Array(Lh1.buffer,0,4);function X50(Z,J,X){ak=Z,sk=J,ok=X}var ww;try{ww=new TextEncoder}catch(Z){}var $I,K50,kH=typeof Buffer!=="undefined",Bw=kH?function(Z){return Buffer.allocUnsafeSlow(Z)}:Uint8Array,W50=kH?Buffer:Uint8Array,Y50=kH?4294967296:2144337920,c,EH,f1,m=0,Y5,r1=null,G50,Bh1=21760,wh1=/[\u0080-\uFFFF]/,P7=Symbol("record-id");class K$ extends xZ{constructor(Z){super(Z);this.offset=0;let J,X,Y,$,Q,K=W50.prototype.utf8Write?function(I,_){return c.utf8Write(I,_,c.byteLength-_)}:ww&&ww.encodeInto?function(I,_){return ww.encodeInto(I,c.subarray(_)).written}:!1,W=this;if(!Z)Z={};let G=Z&&Z.sequential,V=Z.structures||Z.saveStructures,H=Z.maxSharedStructures;if(H==null)H=V?32:0;if(H>8160)throw new Error("Maximum maxSharedStructure is 8160");if(Z.structuredClone&&Z.moreTypes==null)this.moreTypes=!0;let F=Z.maxOwnStructures;if(F==null)F=V?32:64;if(!this.structures&&Z.useRecords!=!1)this.structures=[];let z=H>32||F+H>64,q=H+64,U=H+F+64;if(U>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let L=[],B=0,w=0;this.pack=this.encode=function(I,_){if(!c)c=new Bw(8192),f1=c.dataView||(c.dataView=new DataView(c.buffer,0,8192)),m=0;if(Y5=c.length-10,Y5-m<2048)c=new Bw(c.length),f1=c.dataView||(c.dataView=new DataView(c.buffer,0,c.length)),Y5=c.length-10,m=0;else m=m+7&2147483640;if(X=m,_&Dh1)m+=_&255;if(Q=W.structuredClone?new Map:null,W.bundleStrings&&typeof I!=="string")r1=[],r1.size=1/0;else r1=null;if($=W.structures,$){if($.uninitialized)$=W._mergeStructures(W.getStructures());let p=$.sharedLength||0;if(p>H)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+$.sharedLength);if(!$.transitions){$.transitions=Object.create(null);for(let n=0;n<p;n++){let o=$[n];if(!o)continue;let X0,Q0=$.transitions;for(let E0=0,k0=o.length;E0<k0;E0++){let a0=o[E0];if(X0=Q0[a0],!X0)X0=Q0[a0]=Object.create(null);Q0=X0}Q0[P7]=n+64}this.lastNamedStructuresLength=p}if(!G)$.nextId=p+64}if(Y)Y=!1;let y;try{if(W.randomAccessStructure&&I&&I.constructor&&I.constructor===Object)S(I);else R(I);let p=r1;if(r1)$50(X,R,0);if(Q&&Q.idsToInsert){let n=Q.idsToInsert.sort((E0,k0)=>E0.offset>k0.offset?1:-1),o=n.length,X0=-1;while(p&&o>0){let E0=n[--o].offset+X;if(E0<p.stringsPosition+X&&X0===-1)X0=0;if(E0>p.position+X){if(X0>=0)X0+=6}else{if(X0>=0)f1.setUint32(p.position+X,f1.getUint32(p.position+X)+X0),X0=-1;p=p.previous,o++}}if(X0>=0&&p)f1.setUint32(p.position+X,f1.getUint32(p.position+X)+X0);if(m+=n.length*6,m>Y5)E(m);W.offset=m;let Q0=Oh1(c.subarray(X,m),n);return Q=null,Q0}if(W.offset=m,_&Mh1)return c.start=X,c.end=m,c;return c.subarray(X,m)}catch(p){throw y=p,p}finally{if($){if(O(),Y&&W.saveStructures){let p=$.sharedLength||0,n=c.subarray(X,m),o=V50($,W);if(!y){if(W.saveStructures(o,o.isCompatible)===!1)return W.pack(I,_);if(W.lastNamedStructuresLength=p,c.length>1073741824)c=null;return n}}}if(c.length>1073741824)c=null;if(_&Ph1)m=X}};let O=()=>{if(w<10)w++;let I=$.sharedLength||0;if($.length>I&&!G)$.length=I;if(B>1e4){if($.transitions=null,w=0,B=0,L.length>0)L=[]}else if(L.length>0&&!G){for(let _=0,y=L.length;_<y;_++)L[_][P7]=0;L=[]}},N=(I)=>{var _=I.length;if(_<16)c[m++]=144|_;else if(_<65536)c[m++]=220,c[m++]=_>>8,c[m++]=_&255;else c[m++]=221,f1.setUint32(m,_),m+=4;for(let y=0;y<_;y++)R(I[y])},R=(I)=>{if(m>Y5)c=E(m);var _=typeof I,y;if(_==="string"){let p=I.length;if(r1&&p>=4&&p<4096){if((r1.size+=p)>Bh1){let Q0,E0=(r1[0]?r1[0].length*3+r1[1].length:0)+10;if(m+E0>Y5)c=E(m+E0);let k0;if(r1.position)k0=r1,c[m]=200,m+=3,c[m++]=98,Q0=m-X,m+=4,$50(X,R,0),f1.setUint16(Q0+X-3,m-X-Q0);else c[m++]=214,c[m++]=98,Q0=m-X,m+=4;r1=["",""],r1.previous=k0,r1.size=0,r1.position=Q0}let X0=wh1.test(I);r1[X0?0:1]+=I,c[m++]=193,R(X0?-p:p);return}let n;if(p<32)n=1;else if(p<256)n=2;else if(p<65536)n=3;else n=5;let o=p*3;if(m+o>Y5)c=E(m+o);if(p<64||!K){let X0,Q0,E0,k0=m+n;for(X0=0;X0<p;X0++)if(Q0=I.charCodeAt(X0),Q0<128)c[k0++]=Q0;else if(Q0<2048)c[k0++]=Q0>>6|192,c[k0++]=Q0&63|128;else if((Q0&64512)===55296&&((E0=I.charCodeAt(X0+1))&64512)===56320)Q0=65536+((Q0&1023)<<10)+(E0&1023),X0++,c[k0++]=Q0>>18|240,c[k0++]=Q0>>12&63|128,c[k0++]=Q0>>6&63|128,c[k0++]=Q0&63|128;else c[k0++]=Q0>>12|224,c[k0++]=Q0>>6&63|128,c[k0++]=Q0&63|128;y=k0-m-n}else y=K(I,m+n);if(y<32)c[m++]=160|y;else if(y<256){if(n<2)c.copyWithin(m+2,m+1,m+1+y);c[m++]=217,c[m++]=y}else if(y<65536){if(n<3)c.copyWithin(m+3,m+2,m+2+y);c[m++]=218,c[m++]=y>>8,c[m++]=y&255}else{if(n<5)c.copyWithin(m+5,m+3,m+3+y);c[m++]=219,f1.setUint32(m,y),m+=4}m+=y}else if(_==="number")if(I>>>0===I)if(I<32||I<128&&this.useRecords===!1||I<64&&!this.randomAccessStructure)c[m++]=I;else if(I<256)c[m++]=204,c[m++]=I;else if(I<65536)c[m++]=205,c[m++]=I>>8,c[m++]=I&255;else c[m++]=206,f1.setUint32(m,I),m+=4;else if(I>>0===I)if(I>=-32)c[m++]=256+I;else if(I>=-128)c[m++]=208,c[m++]=I+256;else if(I>=-32768)c[m++]=209,f1.setInt16(m,I),m+=2;else c[m++]=210,f1.setInt32(m,I),m+=4;else{let p;if((p=this.useFloat32)>0&&I<4294967296&&I>=-2147483648){c[m++]=202,f1.setFloat32(m,I);let n;if(p<4||(n=I*Q$[(c[m]&127)<<1|c[m+1]>>7])>>0===n){m+=4;return}else m--}c[m++]=203,f1.setFloat64(m,I),m+=8}else if(_==="object"||_==="function")if(!I)c[m++]=192;else{if(Q){let n=Q.get(I);if(n){if(!n.id){let o=Q.idsToInsert||(Q.idsToInsert=[]);n.id=o.push(n)}c[m++]=214,c[m++]=112,f1.setUint32(m,n.id),m+=4;return}else Q.set(I,{offset:m-X})}let p=I.constructor;if(p===Object)T(I);else if(p===Array)N(I);else if(p===Map)if(this.mapAsEmptyObject)c[m++]=128;else{if(y=I.size,y<16)c[m++]=128|y;else if(y<65536)c[m++]=222,c[m++]=y>>8,c[m++]=y&255;else c[m++]=223,f1.setUint32(m,y),m+=4;for(let[n,o]of I)R(n),R(o)}else{for(let n=0,o=$I.length;n<o;n++){let X0=K50[n];if(I instanceof X0){let Q0=$I[n];if(Q0.write){if(Q0.type)c[m++]=212,c[m++]=Q0.type,c[m++]=0;let n1=Q0.write.call(this,I);if(n1===I)if(Array.isArray(I))N(I);else T(I);else R(n1);return}let E0=c,k0=f1,a0=m;c=null;let k8;try{k8=Q0.pack.call(this,I,(n1)=>{if(c=E0,E0=null,m+=n1,m>Y5)E(m);return{target:c,targetView:f1,position:m-n1}},R)}finally{if(E0)c=E0,f1=k0,m=a0,Y5=c.length-10}if(k8){if(k8.length+m>Y5)E(k8.length+m);m=jh1(k8,c,m,Q0.type)}return}}if(Array.isArray(I))N(I);else{if(I.toJSON){let n=I.toJSON();if(n!==I)return R(n)}if(_==="function")return R(this.writeFunction&&this.writeFunction(I));T(I)}}}else if(_==="boolean")c[m++]=I?195:194;else if(_==="bigint"){if(I<9223372036854776000&&I>=-9223372036854776000)c[m++]=211,f1.setBigInt64(m,I);else if(I<18446744073709552000&&I>0)c[m++]=207,f1.setBigUint64(m,I);else if(this.largeBigIntToFloat)c[m++]=203,f1.setFloat64(m,Number(I));else if(this.largeBigIntToString)return R(I.toString());else if((this.useBigIntExtension||this.moreTypes)&&I<BigInt(2)**BigInt(1023)&&I>-(BigInt(2)**BigInt(1023))){c[m++]=199,m++,c[m++]=66;let p=[],n;do{let o=I&BigInt(255);n=(o&BigInt(128))===(I<BigInt(0)?BigInt(128):BigInt(0)),p.push(o),I>>=BigInt(8)}while(!((I===BigInt(0)||I===BigInt(-1))&&n));c[m-2]=p.length;for(let o=p.length;o>0;)c[m++]=Number(p[--o]);return}else throw new RangeError(I+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string");m+=8}else if(_==="undefined")if(this.encodeUndefinedAsNil)c[m++]=192;else c[m++]=212,c[m++]=0,c[m++]=0;else throw new Error("Unknown type: "+_)},D=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?(I)=>{let _;if(this.skipValues){_=[];for(let n in I)if((typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(n))&&!this.skipValues.includes(I[n]))_.push(n)}else _=Object.keys(I);let y=_.length;if(y<16)c[m++]=128|y;else if(y<65536)c[m++]=222,c[m++]=y>>8,c[m++]=y&255;else c[m++]=223,f1.setUint32(m,y),m+=4;let p;if(this.coercibleKeyAsNumber)for(let n=0;n<y;n++){p=_[n];let o=Number(p);R(isNaN(o)?p:o),R(I[p])}else for(let n=0;n<y;n++)R(p=_[n]),R(I[p])}:(I)=>{c[m++]=222;let _=m-X;m+=2;let y=0;for(let p in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(p))R(p),R(I[p]),y++;if(y>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');c[_+++X]=y>>8,c[_+X]=y&255},M=this.useRecords===!1?D:Z.progressiveRecords&&!z?(I)=>{let _,y=$.transitions||($.transitions=Object.create(null)),p=m++-X,n;for(let o in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(o)){if(_=y[o],_)y=_;else{let X0=Object.keys(I),Q0=y;y=$.transitions;let E0=0;for(let k0=0,a0=X0.length;k0<a0;k0++){let k8=X0[k0];if(_=y[k8],!_)_=y[k8]=Object.create(null),E0++;y=_}if(p+X+1==m)m--,x(y,X0,E0);else v(y,X0,p,E0);n=!0,y=Q0[o]}R(I[o])}if(!n){let o=y[P7];if(o)c[p+X]=o;else v(y,Object.keys(I),p,0)}}:(I)=>{let _,y=$.transitions||($.transitions=Object.create(null)),p=0;for(let o in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(o)){if(_=y[o],!_)_=y[o]=Object.create(null),p++;y=_}let n=y[P7];if(n)if(n>=96&&z)c[m++]=((n-=96)&31)+96,c[m++]=n>>5;else c[m++]=n;else x(y,y.__keys__||Object.keys(I),p);for(let o in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(o))R(I[o])},C=typeof this.useRecords=="function"&&this.useRecords,T=C?(I)=>{C(I)?M(I):D(I)}:M,E=(I)=>{let _;if(I>16777216){if(I-X>Y50)throw new Error("Packed buffer would be larger than maximum buffer size");_=Math.min(Y50,Math.round(Math.max((I-X)*(I>67108864?1.25:2),4194304)/4096)*4096)}else _=(Math.max(I-X<<2,c.length-1)>>12)+1<<12;let y=new Bw(_);if(f1=y.dataView||(y.dataView=new DataView(y.buffer,0,_)),I=Math.min(I,c.length),c.copy)c.copy(y,0,X,I);else y.set(c.slice(X,I));return m-=X,X=0,Y5=y.length-10,c=y},x=(I,_,y)=>{let p=$.nextId;if(!p)p=64;if(p<q&&this.shouldShareStructure&&!this.shouldShareStructure(_)){if(p=$.nextOwnId,!(p<U))p=q;$.nextOwnId=p+1}else{if(p>=U)p=q;$.nextId=p+1}let n=_.highByte=p>=96&&z?p-96>>5:-1;if(I[P7]=p,I.__keys__=_,$[p-64]=_,p<q)if(_.isShared=!0,$.sharedLength=p-63,Y=!0,n>=0)c[m++]=(p&31)+96,c[m++]=n;else c[m++]=p;else{if(n>=0)c[m++]=213,c[m++]=114,c[m++]=(p&31)+96,c[m++]=n;else c[m++]=212,c[m++]=114,c[m++]=p;if(y)B+=w*y;if(L.length>=F)L.shift()[P7]=0;L.push(I),R(_)}},v=(I,_,y,p)=>{let n=c,o=m,X0=Y5,Q0=X;if(c=EH,m=0,X=0,!c)EH=c=new Bw(8192);Y5=c.length-10,x(I,_,p),EH=c;let E0=m;if(c=n,m=o,Y5=X0,X=Q0,E0>1){let k0=m+E0-1;if(k0>Y5)E(k0);let a0=y+X;c.copyWithin(a0+E0,a0+1,m),c.set(EH.slice(0,E0),a0),m=k0}else c[y+X]=EH[0]},S=(I)=>{let _=G50(I,c,X,m,$,E,(y,p,n)=>{if(n)return Y=!0;m=p;let o=c;if(R(y),O(),o!==c)return{position:m,targetView:f1,target:c};return m},this);if(_===0)return T(I);m=_}}useBuffer(Z){c=Z,c.dataView||(c.dataView=new DataView(c.buffer,c.byteOffset,c.byteLength)),m=0}set position(Z){m=Z}get position(){return m}clearSharedData(){if(this.structures)this.structures=[];if(this.typedStructs)this.typedStructs=[]}}K50=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,Uw];$I=[{pack(Z,J,X){let Y=Z.getTime()/1000;if((this.useTimestamp32||Z.getMilliseconds()===0)&&Y>=0&&Y<4294967296){let{target:$,targetView:Q,position:K}=J(6);$[K++]=214,$[K++]=255,Q.setUint32(K,Y)}else if(Y>0&&Y<4294967296){let{target:$,targetView:Q,position:K}=J(10);$[K++]=215,$[K++]=255,Q.setUint32(K,Z.getMilliseconds()*4000000+(Y/1000/4294967296>>0)),Q.setUint32(K+4,Y)}else if(isNaN(Y)){if(this.onInvalidDate)return J(0),X(this.onInvalidDate());let{target:$,targetView:Q,position:K}=J(3);$[K++]=212,$[K++]=255,$[K++]=255}else{let{target:$,targetView:Q,position:K}=J(15);$[K++]=199,$[K++]=12,$[K++]=255,Q.setUint32(K,Z.getMilliseconds()*1e6),Q.setBigInt64(K+4,BigInt(Math.floor(Y)))}}},{pack(Z,J,X){if(this.setAsEmptyObject)return J(0),X({});let Y=Array.from(Z),{target:$,position:Q}=J(this.moreTypes?3:0);if(this.moreTypes)$[Q++]=212,$[Q++]=115,$[Q++]=0;X(Y)}},{pack(Z,J,X){let{target:Y,position:$}=J(this.moreTypes?3:0);if(this.moreTypes)Y[$++]=212,Y[$++]=101,Y[$++]=0;X([Z.name,Z.message,Z.cause])}},{pack(Z,J,X){let{target:Y,position:$}=J(this.moreTypes?3:0);if(this.moreTypes)Y[$++]=212,Y[$++]=120,Y[$++]=0;X([Z.source,Z.flags])}},{pack(Z,J){if(this.moreTypes)XI(Z,16,J);else YI(kH?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let X=Z.constructor;if(X!==W50&&this.moreTypes)XI(Z,JI.indexOf(X.name),J);else YI(Z,J)}},{pack(Z,J){if(this.moreTypes)XI(Z,17,J);else YI(kH?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let{target:X,position:Y}=J(1);X[Y]=193}}];function XI(Z,J,X,Y){let $=Z.byteLength;if($+1<256){var{target:Q,position:K}=X(4+$);Q[K++]=199,Q[K++]=$+1}else if($+1<65536){var{target:Q,position:K}=X(5+$);Q[K++]=200,Q[K++]=$+1>>8,Q[K++]=$+1&255}else{var{target:Q,position:K,targetView:W}=X(7+$);Q[K++]=201,W.setUint32(K,$+1),K+=4}if(Q[K++]=116,Q[K++]=J,!Z.buffer)Z=new Uint8Array(Z);Q.set(new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength),K)}function YI(Z,J){let X=Z.byteLength;var Y,$;if(X<256){var{target:Y,position:$}=J(X+2);Y[$++]=196,Y[$++]=X}else if(X<65536){var{target:Y,position:$}=J(X+3);Y[$++]=197,Y[$++]=X>>8,Y[$++]=X&255}else{var{target:Y,position:$,targetView:Q}=J(X+5);Y[$++]=198,Q.setUint32($,X),$+=4}Y.set(Z,$)}function jh1(Z,J,X,Y){let $=Z.length;switch($){case 1:J[X++]=212;break;case 2:J[X++]=213;break;case 4:J[X++]=214;break;case 8:J[X++]=215;break;case 16:J[X++]=216;break;default:if($<256)J[X++]=199,J[X++]=$;else if($<65536)J[X++]=200,J[X++]=$>>8,J[X++]=$&255;else J[X++]=201,J[X++]=$>>24,J[X++]=$>>16&255,J[X++]=$>>8&255,J[X++]=$&255}return J[X++]=Y,J.set(Z,X),X+=$,X}function Oh1(Z,J){let X,Y=J.length*6,$=Z.length-Y;while(X=J.pop()){let{offset:Q,id:K}=X;Z.copyWithin(Q+Y,Q,$),Y-=6;let W=Q+Y;Z[W++]=214,Z[W++]=105,Z[W++]=K>>24,Z[W++]=K>>16&255,Z[W++]=K>>8&255,Z[W++]=K&255,$=Q}return Z}function $50(Z,J,X){if(r1.length>0){f1.setUint32(r1.position+Z,m+X-r1.position-Z),r1.stringsPosition=m-Z;let Y=r1;r1=null,J(Y[0]),J(Y[1])}}function V50(Z,J){return Z.isCompatible=(X)=>{let Y=!X||(J.lastNamedStructuresLength||0)===X.length;if(!Y)J._mergeStructures(X);return Y},Z}function H50(Z,J){G50=Z,V50=J}var z50=new K$({useRecords:!1}),Nh1=z50.pack,Rh1=z50.pack;var Mh1=512,Ph1=1024,Dh1=2048;var QI=3,rK=0,IH=2,jw=1,WI=16,q50=["num","object","string","ascii"];q50[WI]="date";var Th1=[!1,!0,!0,!1,!1,!0,!0,!1],U50;try{new Function(""),U50=!0}catch(Z){}var W$,Eh1=typeof Buffer!=="undefined",Ow,D7;try{Ow=new TextEncoder}catch(Z){}var kh1=Eh1?function(Z,J,X){return Z.utf8Write(J,X,Z.byteLength-X)}:Ow&&Ow.encodeInto?function(Z,J,X){return Ow.encodeInto(J,Z.subarray(X)).written}:!1,kf6=Symbol("type"),If6=Symbol("parent");H50(L50,Ah1);function L50(Z,J,X,Y,$,Q,K,W){let G=W.typedStructs||(W.typedStructs=[]),V=J.dataView,H=(G.lastStringStart||100)+Y,F=J.length-10,z=Y;if(Y>F)J=Q(Y),V=J.dataView,Y-=X,z-=X,H-=X,X=0,F=J.length-10;let q,U=H,L=G.transitions||(G.transitions=Object.create(null)),B=G.nextId||G.length,w=B<15?1:B<240?2:B<61440?3:B<15728640?4:0;if(w===0)return 0;Y+=w;let O=[],N,R=0;for(let M in Z){let C=Z[M],T=L[M];if(!T)L[M]=T={key:M,parent:L,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};if(Y>F)J=Q(Y),V=J.dataView,Y-=X,z-=X,H-=X,U-=X,X=0,F=J.length-10;switch(typeof C){case"number":let E=C;if(B<200||!T.num64){if(E>>0===E&&E<536870912&&E>-520093696){if(E<246&&E>=0&&(T.num8&&!(B>200&&T.num32)||E<32&&!T.num32))L=T.num8||x5(T,rK,1),J[Y++]=E;else L=T.num32||x5(T,rK,4),V.setUint32(Y,E,!0),Y+=4;break}else if(E<4294967296&&E>=-2147483648){if(V.setFloat32(Y,E,!0),Th1[J[Y+3]>>>5]){let I;if((I=E*Q$[(J[Y+3]&127)<<1|J[Y+2]>>7])>>0===I){L=T.num32||x5(T,rK,4),Y+=4;break}}}}L=T.num64||x5(T,rK,8),V.setFloat64(Y,E,!0),Y+=8;break;case"string":let x=C.length;if(q=U-H,(x<<2)+U>F)J=Q((x<<2)+U),V=J.dataView,Y-=X,z-=X,H-=X,U-=X,X=0,F=J.length-10;if(x>65280+q>>2){O.push(M,C,Y-z);break}let v,S=U;if(x<64){let I,_,y;for(I=0;I<x;I++)if(_=C.charCodeAt(I),_<128)J[U++]=_;else if(_<2048)v=!0,J[U++]=_>>6|192,J[U++]=_&63|128;else if((_&64512)===55296&&((y=C.charCodeAt(I+1))&64512)===56320)v=!0,_=65536+((_&1023)<<10)+(y&1023),I++,J[U++]=_>>18|240,J[U++]=_>>12&63|128,J[U++]=_>>6&63|128,J[U++]=_&63|128;else v=!0,J[U++]=_>>12|224,J[U++]=_>>6&63|128,J[U++]=_&63|128}else U+=kh1(J,C,U),v=U-S>x;if(q<160||q<246&&(T.ascii8||T.string8)){if(v){if(!(L=T.string8))if(G.length>10&&(L=T.ascii8))L.__type=IH,T.ascii8=null,T.string8=L,K(null,0,!0);else L=x5(T,IH,1)}else if(q===0&&!N){N=!0,L=T.ascii0||x5(T,QI,0);break}else if(!(L=T.ascii8)&&!(G.length>10&&(L=T.string8)))L=x5(T,QI,1);J[Y++]=q}else L=T.string16||x5(T,IH,2),V.setUint16(Y,q,!0),Y+=2;break;case"object":if(C){if(C.constructor===Date)L=T.date64||x5(T,WI,8),V.setFloat64(Y,C.getTime(),!0),Y+=8;else O.push(M,C,R);break}else if(T=F50(T,Y,V,-10),T)L=T,Y=W$;else O.push(M,C,R);break;case"boolean":L=T.num8||T.ascii8||x5(T,rK,1),J[Y++]=C?249:248;break;case"undefined":if(T=F50(T,Y,V,-9),T)L=T,Y=W$;else O.push(M,C,R);break;default:O.push(M,C,R)}R++}for(let M=0,C=O.length;M<C;){let T=O[M++],E=O[M++],x=O[M++],v=L[T];if(!v)L[T]=v={key:T,parent:L,enumerationOffset:x-R,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null};let S;if(E){let I;if(q=U-H,q<65280)if(L=v.object16,L)I=2;else if(L=v.object32)I=4;else L=x5(v,jw,2),I=2;else L=v.object32||x5(v,jw,4),I=4;if(S=K(E,U),typeof S==="object")U=S.position,V=S.targetView,J=S.target,H-=X,Y-=X,z-=X,X=0;else U=S;if(I===2)V.setUint16(Y,q,!0),Y+=2;else V.setUint32(Y,q,!0),Y+=4}else L=v.object16||x5(v,jw,2),V.setInt16(Y,E===null?-10:-9,!0),Y+=2;R++}let D=L[P7];if(D==null){D=W.typedStructs.length;let M=[],C=L,T,E;while((E=C.__type)!==void 0){let x=C.__size;C=C.__parent,T=C.key;let v=[E,x,T];if(C.enumerationOffset)v.push(C.enumerationOffset);M.push(v),C=C.parent}M.reverse(),L[P7]=D,W.typedStructs[D]=M,K(null,0,!0)}switch(w){case 1:if(D>=16)return 0;J[z]=D+32;break;case 2:if(D>=256)return 0;J[z]=56,J[z+1]=D;break;case 3:if(D>=65536)return 0;J[z]=57,V.setUint16(z+1,D,!0);break;case 4:if(D>=16777216)return 0;V.setUint32(z,(D<<8)+58,!0);break}if(Y<H){if(H===U)return Y;J.copyWithin(Y,H,U),U+=Y-H,G.lastStringStart=Y-z}else if(Y>H){if(H===U)return Y;return G.lastStringStart=Y-z,L50(Z,J,X,z,$,Q,K,W)}return U}function F50(Z,J,X,Y){let $;if($=Z.ascii8||Z.num8)return X.setInt8(J,Y,!0),W$=J+1,$;if($=Z.string16||Z.object16)return X.setInt16(J,Y,!0),W$=J+2,$;if($=Z.num32)return X.setUint32(J,3758096640+Y,!0),W$=J+4,$;if($=Z.num64)return X.setFloat64(J,NaN,!0),X.setInt8(J,Y),W$=J+8,$;W$=J;return}function x5(Z,J,X){let Y=q50[J]+(X<<3),$=Z[Y]||(Z[Y]=Object.create(null));return $.__type=J,$.__size=X,$.__parent=Z,$}function Ih1(Z){if(!(Z instanceof Map))return Z;let J=Z.get("typed")||[];if(Object.isFrozen(J))J=J.map(($)=>$.slice(0));let X=Z.get("named"),Y=Object.create(null);for(let $=0,Q=J.length;$<Q;$++){let K=J[$],W=Y;for(let[G,V,H]of K){let F=W[H];if(!F)W[H]=F={key:H,parent:W,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};W=x5(F,G,V)}W[P7]=$}return J.transitions=Y,this.typedStructs=J,this.lastTypedStructuresLength=J.length,X}var KI=Symbol.for("source");function _h1(Z,J,X,Y){let $=Z[J++]-32;if($>=24)switch($){case 24:$=Z[J++];break;case 25:$=Z[J++]+(Z[J++]<<8);break;case 26:$=Z[J++]+(Z[J++]<<8)+(Z[J++]<<16);break;case 27:$=Z[J++]+(Z[J++]<<8)+(Z[J++]<<16)+(Z[J++]<<24);break}let Q=Y.typedStructs&&Y.typedStructs[$];if(!Q){if(Z=Uint8Array.prototype.slice.call(Z,J,X),X-=J,J=0,!Y.getStructures)throw new Error(`Reference to shared structure ${$} without getStructures method`);if(Y._mergeStructures(Y.getStructures()),!Y.typedStructs)throw new Error("Could not find any shared typed structures");if(Y.lastTypedStructuresLength=Y.typedStructs.length,Q=Y.typedStructs[$],!Q)throw new Error("Could not find typed structure "+$)}var{construct:K,fullConstruct:W}=Q;if(!K){K=Q.construct=function q(){},W=Q.fullConstruct=function q(){},W.prototype=Y.structPrototype??{};var G=K.prototype=Y.structPrototype?Object.create(Y.structPrototype):{};let H=[],F=0,z;for(let q=0,U=Q.length;q<U;q++){let L=Q[q],[B,w,O,N]=L;if(O==="__proto__")O="__proto_";let R={key:O,offset:F};if(N)H.splice(q+N,0,R);else H.push(R);let D;switch(w){case 0:D=()=>0;break;case 1:D=(C,T)=>{let E=C.bytes[T+R.offset];return E>=246?oK(E):E};break;case 2:D=(C,T)=>{let E=C.bytes,v=(E.dataView||(E.dataView=new DataView(E.buffer,E.byteOffset,E.byteLength))).getUint16(T+R.offset,!0);return v>=65280?oK(v&255):v};break;case 4:D=(C,T)=>{let E=C.bytes,v=(E.dataView||(E.dataView=new DataView(E.buffer,E.byteOffset,E.byteLength))).getUint32(T+R.offset,!0);return v>=4294967040?oK(v&255):v};break}R.getRef=D,F+=w;let M;switch(B){case QI:if(z&&!z.next)z.next=R;z=R,R.multiGetCount=0,M=function(C){let{bytes:T,position:E}=C,x=F+E,v=D(C,E);if(typeof v!=="number")return v;let S,I=R.next;while(I){if(S=I.getRef(C,E),typeof S==="number")break;else S=null;I=I.next}if(S==null)S=C.bytesEnd-x;if(C.srcString)return C.srcString.slice(v,S);return r60(T,v+x,S-v)};break;case IH:case jw:if(z&&!z.next)z.next=R;z=R,M=function(C){let T=C.position,E=F+T,x=D(C,T);if(typeof x!=="number")return x;let v=C.bytes,S,I=R.next;while(I){if(S=I.getRef(C,T),typeof S==="number")break;else S=null;I=I.next}if(S==null)S=C.bytesEnd-E;if(B===IH)return v.toString("utf8",x+E,S+E);else{D7=C;try{return Y.unpack(v,{start:x+E,end:S+E})}finally{D7=null}}};break;case rK:switch(w){case 4:M=function(C){let T=C.bytes,E=T.dataView||(T.dataView=new DataView(T.buffer,T.byteOffset,T.byteLength)),x=C.position+R.offset,v=E.getInt32(x,!0);if(v<536870912){if(v>-520093696)return v;if(v>-536870912)return oK(v&255)}let S=E.getFloat32(x,!0),I=Q$[(T[x+3]&127)<<1|T[x+2]>>7];return(I*S+(S>0?0.5:-0.5)>>0)/I};break;case 8:M=function(C){let T=C.bytes,x=(T.dataView||(T.dataView=new DataView(T.buffer,T.byteOffset,T.byteLength))).getFloat64(C.position+R.offset,!0);if(isNaN(x)){let v=T[C.position+R.offset];if(v>=246)return oK(v)}return x};break;case 1:M=function(C){let E=C.bytes[C.position+R.offset];return E<246?E:oK(E)};break}break;case WI:M=function(C){let T=C.bytes,E=T.dataView||(T.dataView=new DataView(T.buffer,T.byteOffset,T.byteLength));return new Date(E.getFloat64(C.position+R.offset,!0))};break}R.get=M}if(U50){let q=[],U=[],L=0,B;for(let O of H){if(Y.alwaysLazyProperty&&Y.alwaysLazyProperty(O.key)){B=!0;continue}Object.defineProperty(G,O.key,{get:vh1(O.get),enumerable:!0});let N="v"+L++;U.push(N),q.push("o["+JSON.stringify(O.key)+"]="+N+"(s)")}if(B)q.push("__proto__:this");let w=new Function(...U,"var c=this;return function(s){var o=new c();"+q.join(";")+";return o;}").apply(W,H.map((O)=>O.get));Object.defineProperty(G,"toJSON",{value(O){return w.call(this,this[KI])}})}else Object.defineProperty(G,"toJSON",{value(q){let U={};for(let L=0,B=H.length;L<B;L++){let w=H[L].key;U[w]=this[w]}return U}})}var V=new K;return V[KI]={bytes:Z,position:J,srcString:"",bytesEnd:X},V}function oK(Z){switch(Z){case 246:return null;case 247:return;case 248:return!1;case 249:return!0}throw new Error("Unknown constant")}function vh1(Z){return function(){return Z(this[KI])}}function Sh1(){if(D7)D7.bytes=Uint8Array.prototype.slice.call(D7.bytes,D7.position,D7.bytesEnd),D7.position=0,D7.bytesEnd=D7.bytes.length}function Ah1(Z,J){if(J.typedStructs){let Y=new Map;Y.set("named",Z),Y.set("typed",J.typedStructs),Z=Y}let X=J.lastTypedStructuresLength||0;return Z.isCompatible=(Y)=>{let $=!0;if(Y instanceof Map){if((Y.get("named")||[]).length!==(J.lastNamedStructuresLength||0))$=!1;if((Y.get("typed")||[]).length!==X)$=!1}else if(Y instanceof Array||Array.isArray(Y)){if(Y.length!==(J.lastNamedStructuresLength||0))$=!1}if(!$)J._mergeStructures(Y);return $},J.lastTypedStructuresLength=J.typedStructs&&J.typedStructs.length,Z}X50(_h1,Ih1,Sh1);var fh1=process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED!==void 0&&process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED.toLowerCase()==="true";if(!fh1){let Z;try{if(Z=g("msgpackr-extract"),Z)o60(Z.extractStrings)}catch(J){}}import An1 from"mediasoup";var Tj=r(sY0(),1);import In1 from"http";import _n1 from"https";import Cj from"fs";import vn1 from"path";import Sn1 from"url";var oY0=`-----BEGIN CERTIFICATE-----
416
416
  MIIDRjCCAi6gAwIBAgIFOTEzNTIwDQYJKoZIhvcNAQELBQAwWDEQMA4GA1UEAxMH
417
417
  SFlUT1BJQTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNV
@@ -457,7 +457,7 @@ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
457
457
  xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
458
458
  6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
459
459
  0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
460
- -----END RSA PRIVATE KEY-----`;var wv=process.env.PORT??8080,jv="0.6.33",Ov;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(Ov||={});class IW extends B0{static instance=new IW;_webserver=Tj.default();_internalHttpServer;constructor(){super();this._webserver.use((Z,J,X)=>{J.header("Access-Control-Allow-Origin","*"),X()}),this._webserver.get("/",(Z,J)=>{J.json({status:"OK",version:jv,runtime:typeof Bun!=="undefined"?"bun":"node"})}),this._webserver.use(Tj.default.static("assets"));try{this._webserver.use(Tj.default.static(vn1.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?In1.createServer(this._webserver):_n1.createServer({key:Cj.existsSync("assets/certs/localhost.key")?Cj.readFileSync("assets/certs/localhost.key"):rY0,cert:Cj.existsSync("assets/certs/localhost.crt")?Cj.readFileSync("assets/certs/localhost.crt"):oY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else u.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(wv,this._onStarted),console.info(`WebServer.start(): Server running on port ${wv}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return u.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let Y=Sn1.parse(Z.url??"",!0).query,$=Y.connectionId?.toString(),Q=Y.sessionToken?.toString()??"";if($&&S7.instance.isValidConnectionId($))Z.connectionId=$;else{let K=await N7.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
460
+ -----END RSA PRIVATE KEY-----`;var wv=process.env.PORT??8080,jv="0.6.34",Ov;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(Ov||={});class IW extends B0{static instance=new IW;_webserver=Tj.default();_internalHttpServer;constructor(){super();this._webserver.use((Z,J,X)=>{J.header("Access-Control-Allow-Origin","*"),X()}),this._webserver.get("/",(Z,J)=>{J.json({status:"OK",version:jv,runtime:typeof Bun!=="undefined"?"bun":"node"})}),this._webserver.use(Tj.default.static("assets"));try{this._webserver.use(Tj.default.static(vn1.dirname(g.resolve("@hytopia.com/assets"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?In1.createServer(this._webserver):_n1.createServer({key:Cj.existsSync("assets/certs/localhost.key")?Cj.readFileSync("assets/certs/localhost.key"):rY0,cert:Cj.existsSync("assets/certs/localhost.crt")?Cj.readFileSync("assets/certs/localhost.crt"):oY0},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else u.warning("WebServer.start(): server already started!");this._internalHttpServer.listen(wv,this._onStarted),console.info(`WebServer.start(): Server running on port ${wv}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return u.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let Y=Sn1.parse(Z.url??"",!0).query,$=Y.connectionId?.toString(),Q=Y.sessionToken?.toString()??"";if($&&S7.instance.isValidConnectionId($))Z.connectionId=$;else{let K=await N7.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
461
461
  Content-Type: text/plain\r
462
462
  Content-Length: ${W.length}\r
463
463
  Connection: close\r