hytopia 0.5.19 → 0.5.20

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 JV1}from"node:buffer";import{StringDecoder as XV1}from"node:string_decoder";var VL=(Z,J,X)=>{if(X)return;if(Z)return{transform:YV1.bind(void 0,new TextEncoder)};let Y=new XV1(J);return{transform:$V1.bind(void 0,Y),final:QV1.bind(void 0,Y)}},YV1=function*(Z,J){if(JV1.isBuffer(J))yield YZ(J);else if(typeof J==="string")yield Z.encode(J);else yield J},$V1=function*(Z,J){yield y8(J)?Z.write(J):J},QV1=function*(Z){let J=Z.end();if(J!=="")yield J};import{callbackify as Nd}from"node:util";var Rj=Nd(async(Z,J,X,Y)=>{J.currentIterable=Z(...X);try{for await(let $ of J.currentIterable)Y.push($)}finally{delete J.currentIterable}}),qL=async function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:Y=WV1}=J[X];for await(let $ of Y(Z))yield*qL($,J,X+1)},Rd=async function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*KV1(X,Number(J),Z)},KV1=async function*(Z,J,X){if(Z===void 0)return;for await(let Y of Z())yield*qL(Y,X,J+1)},Md=Nd(async({currentIterable:Z},J)=>{if(Z!==void 0){await(J?Z.throw(J):Z.return());return}if(J)throw J}),WV1=function*(Z){yield Z};var Mj=(Z,J,X,Y)=>{try{for(let $ of Z(...J))X.push($);Y()}catch($){Y($)}},Pd=(Z,J)=>[...J.flatMap((X)=>[...HY(X,Z,0)]),...v3(Z)],HY=function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:Y=HV1}=J[X];for(let $ of Y(Z))yield*HY($,J,X+1)},v3=function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*GV1(X,Number(J),Z)},GV1=function*(Z,J,X){if(Z===void 0)return;for(let Y of Z())yield*HY(Y,X,J+1)},HV1=function*(Z){yield Z};var Pj=({value:Z,value:{transform:J,final:X,writableObjectMode:Y,readableObjectMode:$},optionName:Q},{encoding:K})=>{let W={},G=Dd(Z,K,Q),H=GY(J),z=GY(X),V=H?Rj.bind(void 0,qL,W):Mj.bind(void 0,HY),F=H||z?Rj.bind(void 0,Rd,W):Mj.bind(void 0,v3),q=H||z?Md.bind(void 0,W):void 0;return{stream:new zV1({writableObjectMode:Y,writableHighWaterMark:jd(Y),readableObjectMode:$,readableHighWaterMark:jd($),transform(B,L,w){V([B,G,0],this,w)},flush(B){F([G],this,B)},destroy:q})}},UL=(Z,J,X,Y)=>{let $=J.filter(({type:K})=>K==="generator"),Q=Y?$.reverse():$;for(let{value:K,optionName:W}of Q){let G=Dd(K,X,W);Z=Pd(G,Z)}return Z},Dd=({transform:Z,final:J,binary:X,writableObjectMode:Y,readableObjectMode:$,preserveNewlines:Q},K,W)=>{let G={};return[{transform:Bd(Y,W)},VL(X,K,Y),FL(X,Q,Y,G),{transform:Z,final:J},{transform:wd($,W)},Ld({binary:X,preserveNewlines:Q,readableObjectMode:$,state:G})].filter(Boolean)};var Cd=(Z,J)=>{for(let X of FV1(Z))VV1(Z,X,J)},FV1=(Z)=>new Set(Object.entries(Z).filter(([,{direction:J}])=>J==="input").map(([J])=>Number(J))),VV1=(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 ${OJ[W]} with synchronous methods.`)}let K=$.map(({contents:W})=>W).map((W)=>qV1(W,Y));X.input=P3(K)},qV1=(Z,J)=>{let X=UL(Z,J,"utf8",!0);return UV1(X),P3(X)},UV1=(Z)=>{let J=Z.find((X)=>typeof X!=="string"&&!y8(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 OV1,appendFileSync as NV1}from"node:fs";var LL=({stdioItems:Z,encoding:J,verboseInfo:X,fdNumber:Y})=>Y!=="all"&&gQ(X,Y)&&!d5.has(J)&&LV1(Y)&&(Z.some(({type:$,value:Q})=>$==="native"&&BV1.has(Q))||Z.every(({type:$})=>O9.has($))),LV1=(Z)=>Z===1||Z===2,BV1=new Set(["pipe","overlapped"]),Td=async(Z,J,X,Y)=>{for await(let $ of Z)if(!wV1(J))kd($,X,Y)},Ed=(Z,J,X)=>{for(let Y of Z)kd(Y,J,X)},wV1=(Z)=>Z._readableState.pipes.length>0,kd=(Z,J,X)=>{let Y=TU(Z);o4({type:"output",verboseMessage:Y,fdNumber:J,verboseInfo:X})};var Id=({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,H)=>RV1({result:G,fileDescriptors:Z,fdNumber:H,state:Q,outputFiles:K,isMaxBuffer:Y,verboseInfo:$},X)),...Q}},RV1=({result:Z,fileDescriptors:J,fdNumber:X,state:Y,outputFiles:$,isMaxBuffer:Q,verboseInfo:K},{buffer:W,encoding:G,lines:H,stripFinalNewline:z,maxBuffer:V})=>{if(Z===null)return;let F=vu(Z,Q,V),q=YZ(F),{stdioItems:U,objectMode:B}=J[X],L=MV1([q],U,G,Y),{serializedResult:w,finalResult:N=w}=PV1({chunks:L,objectMode:B,encoding:G,lines:H,stripFinalNewline:z,fdNumber:X});jV1({serializedResult:w,fdNumber:X,state:Y,verboseInfo:K,encoding:G,stdioItems:U,objectMode:B});let R=W[X]?N:void 0;try{if(Y.error===void 0)DV1(w,U,$);return R}catch(M){return Y.error=M,R}},MV1=(Z,J,X,Y)=>{try{return UL(Z,J,X,!1)}catch($){return Y.error=$,Z}},PV1=({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=cb(Z,X);if(Y[Q])return{serializedResult:K,finalResult:Nj(K,!$[Q],J)};return{serializedResult:K}},jV1=({serializedResult:Z,fdNumber:J,state:X,verboseInfo:Y,encoding:$,stdioItems:Q,objectMode:K})=>{if(!LL({stdioItems:Q,encoding:$,verboseInfo:Y,fdNumber:J}))return;let W=Nj(Z,!1,K);try{Ed(W,J,Y)}catch(G){X.error??=G}},DV1=(Z,J,X)=>{for(let{path:Y,append:$}of J.filter(({type:Q})=>HL.has(Q))){let Q=typeof Y==="string"?Y:Y.toString();if($||X.has(Q))NV1(Y,Z);else X.add(Q),OV1(Y,Z)}};var vd=([,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,WZ(J,X,"all")];if(Array.isArray(J))return[WZ(Z,X,"all"),...J];if(y8(Z)&&y8(J))return kP([Z,J]);return`${Z}${J}`};import{once as jj}from"node:events";var _d=async(Z,J)=>{let[X,Y]=await CV1(Z);return J.isForcefullyTerminated??=!1,[X,Y]},CV1=async(Z)=>{let[J,X]=await Promise.allSettled([jj(Z,"spawn"),jj(Z,"exit")]);if(J.status==="rejected")return[];return X.status==="rejected"?Sd(Z):X.value},Sd=async(Z)=>{try{return await jj(Z,"exit")}catch{return Sd(Z)}},Ad=async(Z)=>{let[J,X]=await Z;if(!TV1(J,X)&&Dj(J,X))throw new r4;return[J,X]},TV1=(Z,J)=>Z===void 0&&J===void 0,Dj=(Z,J)=>Z!==0||J!==null;var xd=({error:Z,status:J,signal:X,output:Y},{maxBuffer:$})=>{let Q=EV1(Z,J,X),K=Q?.code==="ETIMEDOUT",W=Iu(Q,Y,$);return{resultError:Q,exitCode:J,signal:X,timedOut:K,isMaxBuffer:W}},EV1=(Z,J,X)=>{if(Z!==void 0)return Z;return Dj(J,X)?new r4:void 0};var hd=(Z,J,X)=>{let{file:Y,commandArguments:$,command:Q,escapedCommand:K,startTime:W,verboseInfo:G,options:H,fileDescriptors:z}=IV1(Z,J,X),V=SV1({file:Y,commandArguments:$,options:H,command:Q,escapedCommand:K,verboseInfo:G,fileDescriptors:z,startTime:W});return aQ(V,G,H)},IV1=(Z,J,X)=>{let{command:Y,escapedCommand:$,startTime:Q,verboseInfo:K}=kU(Z,J,X),W=vV1(X),{file:G,commandArguments:H,options:z}=rU(Z,J,W);_V1(z);let V=Fd(z,K);return{file:G,commandArguments:H,command:Y,escapedCommand:$,startTime:Q,verboseInfo:K,options:z,fileDescriptors:V}},vV1=(Z)=>Z.node&&!Z.ipc?{...Z,ipc:!1}:Z,_V1=({ipc:Z,ipcInput:J,detached:X,cancelSignal:Y})=>{if(J)BL("ipcInput");if(Z)BL("ipc: true");if(X)BL("detached: true");if(Y)BL("cancelSignal")},BL=(Z)=>{throw new TypeError(`The "${Z}" option cannot be used with synchronous methods.`)},SV1=({file:Z,commandArguments:J,options:X,command:Y,escapedCommand:$,verboseInfo:Q,fileDescriptors:K,startTime:W})=>{let G=AV1({file:Z,commandArguments:J,options:X,command:Y,escapedCommand:$,fileDescriptors:K,startTime:W});if(G.failed)return G;let{resultError:H,exitCode:z,signal:V,timedOut:F,isMaxBuffer:q}=xd(G,X),{output:U,error:B=H}=Id({fileDescriptors:K,syncResult:G,options:X,isMaxBuffer:q,verboseInfo:Q}),L=U.map((N,R)=>WZ(N,X,R)),w=WZ(vd(U,X),X,"all");return hV1({error:B,exitCode:z,signal:V,timedOut:F,isMaxBuffer:q,stdio:L,all:w,options:X,command:Y,escapedCommand:$,startTime:W})},AV1=({file:Z,commandArguments:J,options:X,command:Y,escapedCommand:$,fileDescriptors:Q,startTime:K})=>{try{Cd(Q,X);let W=xV1(X);return kV1(Z,J,W)}catch(W){return nQ({error:W,command:Y,escapedCommand:$,fileDescriptors:Q,options:X,startTime:K,isSync:!0})}},xV1=({encoding:Z,maxBuffer:J,...X})=>({...X,encoding:"buffer",maxBuffer:QL(J)}),hV1=({error:Z,exitCode:J,signal:X,timedOut:Y,isMaxBuffer:$,stdio:Q,all:K,options:W,command:G,escapedCommand:H,startTime:z})=>Z===void 0?KL({command:G,escapedCommand:H,stdio:Q,all:K,ipcOutput:[],options:W,startTime:z}):I3({error:Z,command:G,escapedCommand:H,timedOut:Y,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:$,isForcefullyTerminated:!1,exitCode:J,signal:X,stdio:Q,all:K,ipcOutput:[],options:W,startTime:z,isSync:!0});import{setMaxListeners as PU1}from"node:events";import{spawn as jU1}from"node:child_process";import md from"node:process";import{once as Cj,on as fV1}from"node:events";var fd=({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y},{reference:$=!0,filter:Q}={})=>{return dQ({methodName:"getOneMessage",isSubprocess:X,ipc:Y,isConnected:pU(Z)}),yV1({anyProcess:Z,channel:J,isSubprocess:X,filter:Q,reference:$})},yV1=async({anyProcess:Z,channel:J,isSubprocess:X,filter:Y,reference:$})=>{uU(J,$);let Q=wJ(Z,J,X),K=new AbortController;try{return await Promise.race([bV1(Q,Y,K),gV1(Q,X,K),mV1(Q,X,K)])}catch(W){throw lQ(Z),W}finally{K.abort(),dU(J,$)}},bV1=async(Z,J,{signal:X})=>{if(J===void 0){let[Y]=await Cj(Z,"message",{signal:X});return Y}for await(let[Y]of fV1(Z,"message",{signal:X}))if(J(Y))return Y},gV1=async(Z,J,{signal:X})=>{await Cj(Z,"disconnect",{signal:X}),Mm(J)},mV1=async(Z,J,{signal:X})=>{let[Y]=await Cj(Z,"strict:error",{signal:X});throw bU(Y,J)};import{once as bd,on as uV1}from"node:events";var gd=({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y},{reference:$=!0}={})=>Tj({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y,shouldAwait:!X,reference:$}),Tj=({anyProcess:Z,channel:J,isSubprocess:X,ipc:Y,shouldAwait:$,reference:Q})=>{dQ({methodName:"getEachMessage",isSubprocess:X,ipc:Y,isConnected:pU(Z)}),uU(J,Q);let K=wJ(Z,J,X),W=new AbortController,G={};return dV1(Z,K,W),lV1({ipcEmitter:K,isSubprocess:X,controller:W,state:G}),cV1({anyProcess:Z,channel:J,ipcEmitter:K,isSubprocess:X,shouldAwait:$,controller:W,state:G,reference:Q})},dV1=async(Z,J,X)=>{try{await bd(J,"disconnect",{signal:X.signal}),X.abort()}catch{}},lV1=async({ipcEmitter:Z,isSubprocess:J,controller:X,state:Y})=>{try{let[$]=await bd(Z,"strict:error",{signal:X.signal});Y.error=bU($,J),X.abort()}catch{}},cV1=async function*({anyProcess:Z,channel:J,ipcEmitter:X,isSubprocess:Y,shouldAwait:$,controller:Q,state:K,reference:W}){try{for await(let[G]of uV1(X,"message",{signal:Q.signal}))yd(K),yield G}catch{yd(K)}finally{if(Q.abort(),dU(J,W),!Y)lQ(Z);if($)await Z}},yd=({error:Z})=>{if(Z)throw Z};var ud=(Z,{ipc:J})=>{Object.assign(Z,ld(Z,!1,J))},dd=()=>{let Z=md,J=!0,X=md.channel!==void 0;return{...ld(Z,!0,X),getCancelSignal:am.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:!0,ipc:X})}},ld=(Z,J,X)=>({sendMessage:sU.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getOneMessage:fd.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getEachMessage:gd.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X})});import{ChildProcess as pV1}from"node:child_process";import{PassThrough as iV1,Readable as nV1,Writable as aV1,Duplex as sV1}from"node:stream";var cd=({error:Z,command:J,escapedCommand:X,fileDescriptors:Y,options:$,startTime:Q,verboseInfo:K})=>{Bj(Y);let W=new pV1;oV1(W,Y),Object.assign(W,{readable:rV1,writable:tV1,duplex:eV1});let G=nQ({error:Z,command:J,escapedCommand:X,fileDescriptors:Y,options:$,startTime:Q,isSync:!1}),H=Zq1(G,K,$);return{subprocess:W,promise:H}},oV1=(Z,J)=>{let X=_3(),Y=_3(),$=_3(),Q=Array.from({length:J.length-3},_3),K=_3(),W=[X,Y,$,...Q];Object.assign(Z,{stdin:X,stdout:Y,stderr:$,all:K,stdio:W})},_3=()=>{let Z=new iV1;return Z.end(),Z},rV1=()=>new nV1({read(){}}),tV1=()=>new aV1({write(){}}),eV1=()=>new sV1({read(){},write(){}}),Zq1=async(Z,J,X)=>aQ(Z,J,X);import{createReadStream as pd,createWriteStream as id}from"node:fs";import{Buffer as Jq1}from"node:buffer";import{Readable as S3,Writable as Xq1,Duplex as Yq1}from"node:stream";var ad=(Z,J)=>zL($q1,Z,J,!1),A3=({type:Z,optionName:J})=>{throw new TypeError(`The \`${J}\` option cannot be ${OJ[Z]}.`)},nd={fileNumber:A3,generator:Pj,asyncGenerator:Pj,nodeStream:({value:Z})=>({stream:Z}),webTransform({value:{transform:Z,writableObjectMode:J,readableObjectMode:X}}){let Y=J||X;return{stream:Yq1.fromWeb(Z,{objectMode:Y})}},duplex:({value:{transform:Z}})=>({stream:Z}),native(){}},$q1={input:{...nd,fileUrl:({value:Z})=>({stream:pd(Z)}),filePath:({value:{file:Z}})=>({stream:pd(Z)}),webStream:({value:Z})=>({stream:S3.fromWeb(Z)}),iterable:({value:Z})=>({stream:S3.from(Z)}),asyncIterable:({value:Z})=>({stream:S3.from(Z)}),string:({value:Z})=>({stream:S3.from(Z)}),uint8Array:({value:Z})=>({stream:S3.from(Jq1.from(Z))})},output:{...nd,fileUrl:({value:Z})=>({stream:id(Z)}),filePath:({value:{file:Z,append:J}})=>({stream:id(Z,J?{flags:"a"}:{})}),webStream:({value:Z})=>({stream:Xq1.fromWeb(Z)}),iterable:A3,asyncIterable:A3,string:A3,uint8Array:A3}};import{on as Qq1,once as sd}from"node:events";import{PassThrough as Kq1,getDefaultHighWaterMark as Wq1}from"node:stream";import{finished as td}from"node:stream/promises";function zY(Z){if(!Array.isArray(Z))throw new TypeError(`Expected an array, got \`${typeof Z}\`.`);for(let $ of Z)Ej($);let J=Z.some(({readableObjectMode:$})=>$),X=Gq1(Z,J),Y=new ed({objectMode:J,writableHighWaterMark:X,readableHighWaterMark:X});for(let $ of Z)Y.add($);return Y}var Gq1=(Z,J)=>{if(Z.length===0)return Wq1(J);let X=Z.filter(({readableObjectMode:Y})=>Y===J).map(({readableHighWaterMark:Y})=>Y);return Math.max(...X)};class ed extends Kq1{#Z=new Set([]);#J=new Set([]);#Y=new Set([]);#X;#$=Symbol("unpipe");#z=new WeakMap;add(Z){if(Ej(Z),this.#Z.has(Z))return;this.#Z.add(Z),this.#X??=Hq1(this,this.#Z,this.#$);let J=Vq1({passThroughStream:this,stream:Z,streams:this.#Z,ended:this.#J,aborted:this.#Y,onFinished:this.#X,unpipeEvent:this.#$});this.#z.set(Z,J),Z.pipe(this,{end:!1})}async remove(Z){if(Ej(Z),!this.#Z.has(Z))return!1;let J=this.#z.get(Z);if(J===void 0)return!1;return this.#z.delete(Z),Z.unpipe(this),await J,!0}}var Hq1=async(Z,J,X)=>{wL(Z,od);let Y=new AbortController;try{await Promise.race([zq1(Z,Y),Fq1(Z,J,X,Y)])}finally{Y.abort(),wL(Z,-od)}},zq1=async(Z,{signal:J})=>{try{await td(Z,{signal:J,cleanup:!0})}catch(X){throw Zl(Z,X),X}},Fq1=async(Z,J,X,{signal:Y})=>{for await(let[$]of Qq1(Z,"unpipe",{signal:Y}))if(J.has($))$.emit(X)},Ej=(Z)=>{if(typeof Z?.pipe!=="function")throw new TypeError(`Expected a readable stream, got: \`${typeof Z}\`.`)},Vq1=async({passThroughStream:Z,stream:J,streams:X,ended:Y,aborted:$,onFinished:Q,unpipeEvent:K})=>{wL(Z,rd);let W=new AbortController;try{await Promise.race([qq1(Q,J,W),Uq1({passThroughStream:Z,stream:J,streams:X,ended:Y,aborted:$,controller:W}),Lq1({stream:J,streams:X,ended:Y,aborted:$,unpipeEvent:K,controller:W})])}finally{W.abort(),wL(Z,-rd)}if(X.size>0&&X.size===Y.size+$.size)if(Y.size===0&&$.size>0)kj(Z);else Bq1(Z)},qq1=async(Z,J,{signal:X})=>{try{if(await Z,!X.aborted)kj(J)}catch(Y){if(!X.aborted)Zl(J,Y)}},Uq1=async({passThroughStream:Z,stream:J,streams:X,ended:Y,aborted:$,controller:{signal:Q}})=>{try{if(await td(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(Jl(K))$.add(J);else Xl(Z,K)}},Lq1=async({stream:Z,streams:J,ended:X,aborted:Y,unpipeEvent:$,controller:{signal:Q}})=>{if(await sd(Z,$,{signal:Q}),!Z.readable)return sd(Q,"abort",{signal:Q});J.delete(Z),X.delete(Z),Y.delete(Z)},Bq1=(Z)=>{if(Z.writable)Z.end()},Zl=(Z,J)=>{if(Jl(J))kj(Z);else Xl(Z,J)},Jl=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",kj=(Z)=>{if(Z.readable||Z.writable)Z.destroy()},Xl=(Z,J)=>{if(!Z.destroyed)Z.once("error",wq1),Z.destroy(J)},wq1=()=>{},wL=(Z,J)=>{let X=Z.getMaxListeners();if(X!==0&&X!==Number.POSITIVE_INFINITY)Z.setMaxListeners(X+J)},od=2,rd=1;import{finished as Yl}from"node:stream/promises";var oQ=(Z,J)=>{Z.pipe(J),Oq1(Z,J),Nq1(Z,J)},Oq1=async(Z,J)=>{if(H4(Z)||H4(J))return;try{await Yl(Z,{cleanup:!0,readable:!0,writable:!1})}catch{}Ij(J)},Ij=(Z)=>{if(Z.writable)Z.end()},Nq1=async(Z,J)=>{if(H4(Z)||H4(J))return;try{await Yl(J,{cleanup:!0,readable:!1,writable:!0})}catch{}vj(Z)},vj=(Z)=>{if(Z.readable)Z.destroy()};var $l=(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})=>O9.has(G)))Rq1(Z,W,K,$);for(let{stream:W}of Q.filter(({type:G})=>!O9.has(G)))Pq1({subprocess:Z,stream:W,direction:K,fdNumber:$,pipeGroups:Y,controller:X})}for(let[$,Q]of Y.entries()){let K=Q.length===1?Q[0]:zY(Q);oQ(K,$)}},Rq1=(Z,J,X,Y)=>{if(X==="output")oQ(Z.stdio[Y],J);else oQ(J,Z.stdio[Y]);let $=Mq1[Y];if($!==void 0)Z[$]=J;Z.stdio[Y]=J},Mq1=["stdin","stdout","stderr"],Pq1=({subprocess:Z,stream:J,direction:X,fdNumber:Y,pipeGroups:$,controller:Q})=>{if(J===void 0)return;jq1(J,Q);let[K,W]=X==="output"?[J,Z.stdio[Y]]:[Z.stdio[Y],J],G=$.get(K)??[];$.set(K,[...G,W])},jq1=(Z,{signal:J})=>{if(H4(Z))KY(Z,Dq1,J)},Dq1=2;import{addAbortListener as Eq1}from"node:events";var FY=[];FY.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")FY.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")FY.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var OL=(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",_j=Symbol.for("signal-exit emitter"),Sj=globalThis,Cq1=Object.defineProperty.bind(Object);class Ql{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Sj[_j])return Sj[_j];Cq1(Sj,_j,{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 xj{}var Tq1=(Z)=>{return{onExit(J,X){return Z.onExit(J,X)},load(){return Z.load()},unload(){return Z.unload()}}};class Kl extends xj{onExit(){return()=>{}}load(){}unload(){}}class Wl extends xj{#Z=Aj.platform==="win32"?"SIGINT":"SIGHUP";#J=new Ql;#Y;#X;#$;#z={};#V=!1;constructor(Z){super();this.#Y=Z,this.#z={};for(let J of FY)this.#z[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(!OL(this.#Y))return()=>{};if(this.#V===!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.#V)return;this.#V=!0,this.#J.count+=1;for(let Z of FY)try{let J=this.#z[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.#V)return;this.#V=!1,FY.forEach((Z)=>{let J=this.#z[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(!OL(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"&&OL(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 Aj=globalThis.process,{onExit:Gl,load:BM6,unload:wM6}=Tq1(OL(Aj)?new Wl(Aj):new Kl);var Hl=(Z,{cleanup:J,detached:X},{signal:Y})=>{if(!J||X)return;let $=Gl(()=>{Z.kill()});Eq1(Y,()=>{$()})};var Fl=({source:Z,sourcePromise:J,boundOptions:X,createNested:Y},...$)=>{let Q=EU(),{destination:K,destinationStream:W,destinationError:G,from:H,unpipeSignal:z}=kq1(X,Y,$),{sourceStream:V,sourceError:F}=vq1(Z,H),{options:q,fileDescriptors:U}=e4.get(Z);return{sourcePromise:J,sourceStream:V,sourceOptions:q,sourceError:F,destination:K,destinationStream:W,destinationError:G,unpipeSignal:z,fileDescriptors:U,startTime:Q}},kq1=(Z,J,X)=>{try{let{destination:Y,pipeOptions:{from:$,to:Q,unpipeSignal:K}={}}=Iq1(Z,J,...X),W=mU(Y,Q);return{destination:Y,destinationStream:W,from:$,unpipeSignal:K}}catch(Y){return{destinationError:Y}}},Iq1=(Z,J,X,...Y)=>{if(Array.isArray(X))return{destination:J(zl,Z)(X,...Y),pipeOptions:Z};if(typeof X==="string"||X instanceof URL||TP(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]=wU(X,...Y);return{destination:J(zl)($,Q,K),pipeOptions:K}}if(e4.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}`)},zl=({options:Z})=>({options:{...Z,stdin:"pipe",piped:!0}}),vq1=(Z,J)=>{try{return{sourceStream:cQ(Z,J)}}catch(X){return{sourceError:X}}};var ql=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:Y,fileDescriptors:$,sourceOptions:Q,startTime:K})=>{let W=_q1({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:Y});if(W!==void 0)throw hj({error:W,fileDescriptors:$,sourceOptions:Q,startTime:K})},_q1=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:Y})=>{if(J!==void 0&&Y!==void 0)return Y;if(Y!==void 0)return vj(Z),Y;if(J!==void 0)return Ij(X),J},hj=({error:Z,fileDescriptors:J,sourceOptions:X,startTime:Y})=>nQ({error:Z,command:Vl,escapedCommand:Vl,fileDescriptors:J,options:X,startTime:Y,isSync:!1}),Vl="source.pipe(destination)";var Ul=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 Sq1}from"node:stream/promises";var Ll=(Z,J,X)=>{let Y=NL.has(J)?xq1(Z,J):Aq1(Z,J);return KY(Z,fq1,X.signal),KY(J,yq1,X.signal),hq1(J),Y},Aq1=(Z,J)=>{let X=zY([Z]);return oQ(X,J),NL.set(J,X),X},xq1=(Z,J)=>{let X=NL.get(J);return X.add(Z),X},hq1=async(Z)=>{try{await Sq1(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}NL.delete(Z)},NL=new WeakMap,fq1=2,yq1=1;import{aborted as bq1}from"node:util";var Bl=(Z,J)=>Z===void 0?[]:[gq1(Z,J)],gq1=async(Z,{sourceStream:J,mergedStream:X,fileDescriptors:Y,sourceOptions:$,startTime:Q})=>{await bq1(Z,J),await X.remove(J);let K=new Error("Pipe canceled by `unpipeSignal` option.");throw hj({error:K,fileDescriptors:Y,sourceOptions:$,startTime:Q})};var RL=(Z,...J)=>{if(L8(J[0]))return RL.bind(void 0,{...Z,boundOptions:{...Z.boundOptions,...J[0]}});let{destination:X,...Y}=Fl(Z,...J),$=mq1({...Y,destination:X});return $.pipe=RL.bind(void 0,{...Z,source:X,sourcePromise:$,boundOptions:{}}),$},mq1=async({sourcePromise:Z,sourceStream:J,sourceOptions:X,sourceError:Y,destination:$,destinationStream:Q,destinationError:K,unpipeSignal:W,fileDescriptors:G,startTime:H})=>{let z=uq1(Z,$);ql({sourceStream:J,sourceError:Y,destinationStream:Q,destinationError:K,fileDescriptors:G,sourceOptions:X,startTime:H});let V=new AbortController;try{let F=Ll(J,Q,V);return await Promise.race([Ul(z),...Bl(W,{sourceStream:J,mergedStream:F,sourceOptions:X,fileDescriptors:G,startTime:H})])}finally{V.abort()}},uq1=(Z,J)=>Promise.allSettled([Z,J]);import{setImmediate as aq1}from"node:timers/promises";import{on as dq1}from"node:events";import{getDefaultHighWaterMark as lq1}from"node:stream";var ML=({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:Y,encoding:$,preserveNewlines:Q})=>{let K=new AbortController;return cq1(J,K),Ol({stream:Z,controller:K,binary:X,shouldEncode:!Z.readableObjectMode&&Y,encoding:$,shouldSplit:!Z.readableObjectMode,preserveNewlines:Q})},cq1=async(Z,J)=>{try{await Z}catch{}finally{J.abort()}},fj=({stream:Z,onStreamEnd:J,lines:X,encoding:Y,stripFinalNewline:$,allMixed:Q})=>{let K=new AbortController;pq1(J,K,Z);let W=Z.readableObjectMode&&!Q;return Ol({stream:Z,controller:K,binary:Y==="buffer",shouldEncode:!W,encoding:Y,shouldSplit:!W&&X,preserveNewlines:!$})},pq1=async(Z,J,X)=>{try{await Z}catch{X.destroy()}finally{J.abort()}},Ol=({stream:Z,controller:J,binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K})=>{let W=dq1(Z,"data",{signal:J.signal,highWaterMark:wl,highWatermark:wl});return iq1({onStdoutChunk:W,controller:J,binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K})},yj=lq1(!0),wl=yj,iq1=async function*({onStdoutChunk:Z,controller:J,binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K}){let W=nq1({binary:X,shouldEncode:Y,encoding:$,shouldSplit:Q,preserveNewlines:K});try{for await(let[G]of Z)yield*HY(G,W,0)}catch(G){if(!J.signal.aborted)throw G}finally{yield*v3(W)}},nq1=({binary:Z,shouldEncode:J,encoding:X,shouldSplit:Y,preserveNewlines:$})=>[VL(Z,X,!J),FL(Z,$,!Y,{})].filter(Boolean);var Nl=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:Y,buffer:$,maxBuffer:Q,lines:K,allMixed:W,stripFinalNewline:G,verboseInfo:H,streamInfo:z})=>{let V=sq1({stream:Z,onStreamEnd:J,fdNumber:X,encoding:Y,allMixed:W,verboseInfo:H,streamInfo:z});if(!$){await Promise.all([oq1(Z),V]);return}let F=wj(G,X),q=fj({stream:Z,onStreamEnd:J,lines:K,encoding:Y,stripFinalNewline:F,allMixed:W}),[U]=await Promise.all([rq1({stream:Z,iterable:q,fdNumber:X,encoding:Y,maxBuffer:Q,lines:K}),V]);return U},sq1=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:Y,allMixed:$,verboseInfo:Q,streamInfo:{fileDescriptors:K}})=>{if(!LL({stdioItems:K[X]?.stdioItems,encoding:Y,verboseInfo:Q,fdNumber:X}))return;let W=fj({stream:Z,onStreamEnd:J,lines:!0,encoding:Y,stripFinalNewline:!0,allMixed:$});await Td(W,Z,X,Q)},oq1=async(Z)=>{if(await aq1(),Z.readableFlowing===null)Z.resume()},rq1=async({stream:Z,stream:{readableObjectMode:J},iterable:X,fdNumber:Y,encoding:$,maxBuffer:Q,lines:K})=>{try{if(J||K)return await JL(X,{maxBuffer:Q});if($==="buffer")return new Uint8Array(await XL(X,{maxBuffer:Q}));return await $L(X,{maxBuffer:Q})}catch(W){return Rl(Tu({error:W,stream:Z,readableObjectMode:J,lines:K,encoding:$,fdNumber:Y}))}},bj=async(Z)=>{try{return await Z}catch(J){return Rl(J)}},Rl=({bufferedData:Z})=>db(Z)?new Uint8Array(Z):Z;import{finished as tq1}from"node:stream/promises";var x3=async(Z,J,X,{isSameDirection:Y,stopOnExit:$=!1}={})=>{let Q=eq1(Z,X),K=new AbortController;try{await Promise.race([...$?[X.exitPromise]:[],tq1(Z,{cleanup:!0,signal:K.signal})])}catch(W){if(!Q.stdinCleanedUp)XU1(W,J,X,Y)}finally{K.abort()}},eq1=(Z,{originalStreams:[J],subprocess:X})=>{let Y={stdinCleanedUp:!1};if(Z===J)ZU1(Z,X,Y);return Y},ZU1=(Z,J,X)=>{let{_destroy:Y}=Z;Z._destroy=(...$)=>{JU1(J,X),Y.call(Z,...$)}},JU1=({exitCode:Z,signalCode:J},X)=>{if(Z!==null||J!==null)X.stdinCleanedUp=!0},XU1=(Z,J,X,Y)=>{if(!YU1(Z,J,X,Y))throw Z},YU1=(Z,J,X,Y=!0)=>{if(X.propagating)return Ml(Z)||PL(Z);return X.propagating=!0,gj(X,J)===Y?Ml(Z):PL(Z)},gj=({fileDescriptors:Z},J)=>J!=="all"&&Z[J].direction==="input",PL=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",Ml=(Z)=>Z?.code==="EPIPE";var Pl=({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>Z.stdio.map((G,H)=>mj({stream:G,fdNumber:H,encoding:J,buffer:X[H],maxBuffer:Y[H],lines:$[H],allMixed:!1,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})),mj=async({stream:Z,fdNumber:J,encoding:X,buffer:Y,maxBuffer:$,lines:Q,allMixed:K,stripFinalNewline:W,verboseInfo:G,streamInfo:H})=>{if(!Z)return;let z=x3(Z,J,H);if(gj(H,J)){await z;return}let[V]=await Promise.all([Nl({stream:Z,onStreamEnd:z,fdNumber:J,encoding:X,buffer:Y,maxBuffer:$,lines:Q,allMixed:K,stripFinalNewline:W,verboseInfo:G,streamInfo:H}),z]);return V};var jl=({stdout:Z,stderr:J},{all:X})=>X&&(Z||J)?zY([Z,J].filter(Boolean)):void 0,Dl=({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>mj({...$U1(Z,X),fdNumber:"all",encoding:J,maxBuffer:Y[1]+Y[2],lines:$[1]||$[2],allMixed:QU1(Z),stripFinalNewline:Q,verboseInfo:K,streamInfo:W}),$U1=({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}},QU1=({all:Z,stdout:J,stderr:X})=>Z&&J&&X&&J.readableObjectMode!==X.readableObjectMode;import{once as KU1}from"node:events";var Cl=(Z)=>gQ(Z,"ipc"),Tl=(Z,J)=>{let X=TU(Z);o4({type:"ipc",verboseMessage:X,fdNumber:"ipc",verboseInfo:J})};var El=async({subprocess:Z,buffer:J,maxBuffer:X,ipc:Y,ipcOutput:$,verboseInfo:Q})=>{if(!Y)return $;let K=Cl(Q),W=$Z(J,"ipc"),G=$Z(X,"ipc");for await(let H of Tj({anyProcess:Z,channel:Z.channel,isSubprocess:!1,ipc:Y,shouldAwait:!1,reference:!0})){if(W)Eu(Z,$,G),$.push(H);if(K)Tl(H,Q)}return $},kl=async(Z,J)=>{return await Promise.allSettled([Z]),J};var Il=async({subprocess:Z,options:{encoding:J,buffer:X,maxBuffer:Y,lines:$,timeoutDuration:Q,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,stripFinalNewline:H,ipc:z,ipcInput:V},context:F,verboseInfo:q,fileDescriptors:U,originalStreams:B,onInternalError:L,controller:w})=>{let N=_d(Z,F),R={originalStreams:B,fileDescriptors:U,subprocess:Z,exitPromise:N,propagating:!1},M=Pl({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:H,verboseInfo:q,streamInfo:R}),D=Dl({subprocess:Z,encoding:J,buffer:X,maxBuffer:Y,lines:$,stripFinalNewline:H,verboseInfo:q,streamInfo:R}),j=[],C=El({subprocess:Z,buffer:X,maxBuffer:Y,ipc:z,ipcOutput:j,verboseInfo:q}),T=WU1(B,Z,R),E=GU1(U,R);try{return await Promise.race([Promise.all([{},Ad(N),Promise.all(M),D,C,$u(Z,V),...T,...E]),L,HU1(Z,w),...em(Z,Q,F,w),...Rm({subprocess:Z,cancelSignal:K,gracefulCancel:W,context:F,controller:w}),...rm({subprocess:Z,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,context:F,controller:w})])}catch(A){return F.terminationReason??="other",Promise.all([{error:A},N,Promise.all(M.map((_)=>bj(_))),bj(D),kl(C,j),Promise.allSettled(T),Promise.allSettled(E)])}},WU1=(Z,J,X)=>Z.map((Y,$)=>Y===J.stdio[$]?void 0:x3(Y,$,X)),GU1=(Z,J)=>Z.flatMap(({stdioItems:X},Y)=>X.filter(({value:$,stream:Q=$})=>F4(Q,{checkOpen:!1})&&!H4(Q)).map(({type:$,value:Q,stream:K=Q})=>x3(K,Y,J,{isSameDirection:O9.has($),stopOnExit:$==="native"}))),HU1=async(Z,{signal:J})=>{let[X]=await KU1(Z,"error",{signal:J});throw X};var vl=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),h3=(Z,J,X)=>{let Y=Z[X];if(!Y.has(J))Y.set(J,[]);let $=Y.get(J),Q=t4();return $.push(Q),{resolve:Q.resolve.bind(Q),promises:$}},rQ=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 zU1}from"node:stream";import{callbackify as FU1}from"node:util";import{finished as _l}from"node:stream/promises";var uj=async(Z)=>{if(Z===void 0)return;try{await dj(Z)}catch{}},Sl=async(Z)=>{if(Z===void 0)return;try{await lj(Z)}catch{}},dj=async(Z)=>{await _l(Z,{cleanup:!0,readable:!1,writable:!0})},lj=async(Z)=>{await _l(Z,{cleanup:!0,readable:!0,writable:!1})},jL=async(Z,J)=>{if(await Z,J)throw J},DL=(Z,J,X)=>{if(X&&!PL(X))Z.destroy(X);else if(J)Z.destroy()};var Al=({subprocess:Z,concurrentStreams:J,encoding:X},{from:Y,binary:$=!0,preserveNewlines:Q=!0}={})=>{let K=$||d5.has(X),{subprocessStdout:W,waitReadableDestroy:G}=cj(Z,Y,J),{readableEncoding:H,readableObjectMode:z,readableHighWaterMark:V}=pj(W,K),{read:F,onStdoutDataDone:q}=ij({subprocessStdout:W,subprocess:Z,binary:K,encoding:X,preserveNewlines:Q}),U=new zU1({read:F,destroy:FU1(aj.bind(void 0,{subprocessStdout:W,subprocess:Z,waitReadableDestroy:G})),highWaterMark:V,objectMode:z,encoding:H});return nj({subprocessStdout:W,onStdoutDataDone:q,readable:U,subprocess:Z}),U},cj=(Z,J,X)=>{let Y=cQ(Z,J),$=h3(X,Y,"readableDestroy");return{subprocessStdout:Y,waitReadableDestroy:$}},pj=({readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X},Y)=>Y?{readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X}:{readableEncoding:Z,readableObjectMode:!0,readableHighWaterMark:yj},ij=({subprocessStdout:Z,subprocess:J,binary:X,encoding:Y,preserveNewlines:$})=>{let Q=t4(),K=ML({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:!X,encoding:Y,preserveNewlines:$});return{read(){VU1(this,K,Q)},onStdoutDataDone:Q}},VU1=async(Z,J,X)=>{try{let{value:Y,done:$}=await J.next();if($)X.resolve();else Z.push(Y)}catch{}},nj=async({subprocessStdout:Z,onStdoutDataDone:J,readable:X,subprocess:Y,subprocessStdin:$})=>{try{if(await lj(Z),await Y,await uj($),await J,X.readable)X.push(null)}catch(Q){await uj($),xl(X,Q)}},aj=async({subprocessStdout:Z,subprocess:J,waitReadableDestroy:X},Y)=>{if(await rQ(X,J))xl(Z,Y),await jL(J,Y)},xl=(Z,J)=>{DL(Z,Z.readable,J)};import{Writable as qU1}from"node:stream";import{callbackify as hl}from"node:util";var fl=({subprocess:Z,concurrentStreams:J},{to:X}={})=>{let{subprocessStdin:Y,waitWritableFinal:$,waitWritableDestroy:Q}=sj(Z,X,J),K=new qU1({...oj(Y,Z,$),destroy:hl(tj.bind(void 0,{subprocessStdin:Y,subprocess:Z,waitWritableFinal:$,waitWritableDestroy:Q})),highWaterMark:Y.writableHighWaterMark,objectMode:Y.writableObjectMode});return rj(Y,K),K},sj=(Z,J,X)=>{let Y=mU(Z,J),$=h3(X,Y,"writableFinal"),Q=h3(X,Y,"writableDestroy");return{subprocessStdin:Y,waitWritableFinal:$,waitWritableDestroy:Q}},oj=(Z,J,X)=>({write:UU1.bind(void 0,Z),final:hl(LU1.bind(void 0,Z,J,X))}),UU1=(Z,J,X,Y)=>{if(Z.write(J,X))Y();else Z.once("drain",Y)},LU1=async(Z,J,X)=>{if(await rQ(X,J)){if(Z.writable)Z.end();await J}},rj=async(Z,J,X)=>{try{if(await dj(Z),J.writable)J.end()}catch(Y){await Sl(X),yl(J,Y)}},tj=async({subprocessStdin:Z,subprocess:J,waitWritableFinal:X,waitWritableDestroy:Y},$)=>{if(await rQ(X,J),await rQ(Y,J))yl(Z,$),await jL(J,$)},yl=(Z,J)=>{DL(Z,Z.writable,J)};import{Duplex as BU1}from"node:stream";import{callbackify as wU1}from"node:util";var bl=({subprocess:Z,concurrentStreams:J,encoding:X},{from:Y,to:$,binary:Q=!0,preserveNewlines:K=!0}={})=>{let W=Q||d5.has(X),{subprocessStdout:G,waitReadableDestroy:H}=cj(Z,Y,J),{subprocessStdin:z,waitWritableFinal:V,waitWritableDestroy:F}=sj(Z,$,J),{readableEncoding:q,readableObjectMode:U,readableHighWaterMark:B}=pj(G,W),{read:L,onStdoutDataDone:w}=ij({subprocessStdout:G,subprocess:Z,binary:W,encoding:X,preserveNewlines:K}),N=new BU1({read:L,...oj(z,Z,V),destroy:wU1(OU1.bind(void 0,{subprocessStdout:G,subprocessStdin:z,subprocess:Z,waitReadableDestroy:H,waitWritableFinal:V,waitWritableDestroy:F})),readableHighWaterMark:B,writableHighWaterMark:z.writableHighWaterMark,readableObjectMode:U,writableObjectMode:z.writableObjectMode,encoding:q});return nj({subprocessStdout:G,onStdoutDataDone:w,readable:N,subprocess:Z,subprocessStdin:z}),rj(z,N,G),N},OU1=async({subprocessStdout:Z,subprocessStdin:J,subprocess:X,waitReadableDestroy:Y,waitWritableFinal:$,waitWritableDestroy:Q},K)=>{await Promise.all([aj({subprocessStdout:Z,subprocess:X,waitReadableDestroy:Y},K),tj({subprocessStdin:J,subprocess:X,waitWritableFinal:$,waitWritableDestroy:Q},K)])};var ej=(Z,J,{from:X,binary:Y=!1,preserveNewlines:$=!1}={})=>{let Q=Y||d5.has(J),K=cQ(Z,X),W=ML({subprocessStdout:K,subprocess:Z,binary:Q,shouldEncode:!0,encoding:J,preserveNewlines:$});return NU1(W,K,Z)},NU1=async function*(Z,J,X){try{yield*Z}finally{if(J.readable)J.destroy();await X}};var gl=(Z,{encoding:J})=>{let X=vl();Z.readable=Al.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.writable=fl.bind(void 0,{subprocess:Z,concurrentStreams:X}),Z.duplex=bl.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.iterable=ej.bind(void 0,Z,J),Z[Symbol.asyncIterator]=ej.bind(void 0,Z,J,{})};var ml=(Z,J)=>{for(let[X,Y]of MU1){let $=Y.value.bind(J);Reflect.defineProperty(Z,X,{...Y,value:$})}},RU1=(async()=>{})().constructor.prototype,MU1=["then","catch","finally"].map((Z)=>[Z,Reflect.getOwnPropertyDescriptor(RU1,Z)]);var ul=(Z,J,X,Y)=>{let{file:$,commandArguments:Q,command:K,escapedCommand:W,startTime:G,verboseInfo:H,options:z,fileDescriptors:V}=DU1(Z,J,X),{subprocess:F,promise:q}=TU1({file:$,commandArguments:Q,options:z,startTime:G,verboseInfo:H,command:K,escapedCommand:W,fileDescriptors:V});return F.pipe=RL.bind(void 0,{source:F,sourcePromise:q,boundOptions:{},createNested:Y}),ml(F,q),e4.set(F,{options:z,fileDescriptors:V}),F},DU1=(Z,J,X)=>{let{command:Y,escapedCommand:$,startTime:Q,verboseInfo:K}=kU(Z,J,X),{file:W,commandArguments:G,options:H}=rU(Z,J,X),z=CU1(H),V=ad(z,K);return{file:W,commandArguments:G,command:Y,escapedCommand:$,startTime:Q,verboseInfo:K,options:z,fileDescriptors:V}},CU1=({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}},TU1=({file:Z,commandArguments:J,options:X,startTime:Y,verboseInfo:$,command:Q,escapedCommand:K,fileDescriptors:W})=>{let G;try{G=jU1(Z,J,X)}catch(U){return cd({error:U,command:Q,escapedCommand:K,fileDescriptors:W,options:X,startTime:Y,verboseInfo:$})}let H=new AbortController;PU1(Number.POSITIVE_INFINITY,H.signal);let z=[...G.stdio];$l(G,W,H),Hl(G,X,H);let V={},F=t4();G.kill=Om.bind(void 0,{kill:G.kill.bind(G),options:X,onInternalError:F,context:V,controller:H}),G.all=jl(G,X),gl(G,X),ud(G,X);let q=EU1({subprocess:G,options:X,startTime:Y,verboseInfo:$,fileDescriptors:W,originalStreams:z,command:Q,escapedCommand:K,context:V,onInternalError:F,controller:H});return{subprocess:G,promise:q}},EU1=async({subprocess:Z,options:J,startTime:X,verboseInfo:Y,fileDescriptors:$,originalStreams:Q,command:K,escapedCommand:W,context:G,onInternalError:H,controller:z})=>{let[V,[F,q],U,B,L]=await Il({subprocess:Z,options:J,context:G,verboseInfo:Y,fileDescriptors:$,originalStreams:Q,onInternalError:H,controller:z});z.abort(),H.resolve();let w=U.map((M,D)=>WZ(M,J,D)),N=WZ(B,J,"all"),R=kU1({errorInfo:V,exitCode:F,signal:q,stdio:w,all:N,ipcOutput:L,context:G,options:J,command:K,escapedCommand:W,startTime:X});return aQ(R,Y,J)},kU1=({errorInfo:Z,exitCode:J,signal:X,stdio:Y,all:$,ipcOutput:Q,context:K,options:W,command:G,escapedCommand:H,startTime:z})=>("error"in Z)?I3({error:Z.error,command:G,escapedCommand:H,timedOut:K.terminationReason==="timeout",isCanceled:K.terminationReason==="cancel"||K.terminationReason==="gracefulCancel",isGracefullyCanceled:K.terminationReason==="gracefulCancel",isMaxBuffer:Z.error instanceof QZ,isForcefullyTerminated:K.isForcefullyTerminated,exitCode:J,signal:X,stdio:Y,all:$,ipcOutput:Q,options:W,startTime:z,isSync:!1}):KL({command:G,escapedCommand:H,stdio:Y,all:$,ipcOutput:Q,options:W,startTime:z});var CL=(Z,J)=>{let X=Object.fromEntries(Object.entries(J).map(([Y,$])=>[Y,IU1(Y,Z[Y],$)]));return{...Z,...X}},IU1=(Z,J,X)=>{if(vU1.has(Z)&&L8(J)&&L8(X))return{...J,...X};return X},vU1=new Set(["env",...SP]);var NJ=(Z,J,X,Y)=>{let $=(K,W,G)=>NJ(K,W,X,G),Q=(...K)=>_U1({mapArguments:Z,deepOptions:X,boundOptions:J,setBoundExeca:Y,createNested:$},...K);if(Y!==void 0)Y(Q,$,J);return Q},_U1=({mapArguments:Z,deepOptions:J={},boundOptions:X={},setBoundExeca:Y,createNested:$},Q,...K)=>{if(L8(Q))return $(Z,CL(X,Q),Y);let{file:W,commandArguments:G,options:H,isSync:z}=SU1({mapArguments:Z,firstArgument:Q,nextArguments:K,deepOptions:J,boundOptions:X});return z?hd(W,G,H):ul(W,G,H,$)},SU1=({mapArguments:Z,firstArgument:J,nextArguments:X,deepOptions:Y,boundOptions:$})=>{let Q=ab(J)?sb(J,X):[J,...X],[K,W,G]=wU(...Q),H=CL(CL(Y,$),G),{file:z=K,commandArguments:V=W,options:F=H,isSync:q=!1}=Z({file:K,commandArguments:W,options:H});return{file:z,commandArguments:V,options:F,isSync:q}};var dl=({file:Z,commandArguments:J})=>cl(Z,J),ll=({file:Z,commandArguments:J})=>({...cl(Z,J),isSync:!0}),cl=(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]=AU1(Z);return{file:X,commandArguments:Y}},AU1=(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(xU1)){let $=X.at(-1);if($&&$.endsWith("\\"))X[X.length-1]=`${$.slice(0,-1)} ${Y}`;else X.push(Y)}return X},xU1=/ +/g;var pl=(Z,J,X)=>{Z.sync=J(hU1,X),Z.s=Z.sync},il=({options:Z})=>nl(Z),hU1=({options:Z})=>({...nl(Z),isSync:!0}),nl=(Z)=>({options:{...fU1(Z),...Z}}),fU1=({input:Z,inputFile:J,stdio:X})=>Z===void 0&&J===void 0&&X===void 0?{stdin:"inherit"}:{},al={preferLocal:!0};var sl=NJ(()=>({})),QD6=NJ(()=>({isSync:!0})),KD6=NJ(dl),WD6=NJ(ll),GD6=NJ(Ju),HD6=NJ(il,{},al,pl),{sendMessage:zD6,getOneMessage:FD6,getEachMessage:VD6,getCancelSignal:qD6}=dd();var Lc=r(Wc(),1);var y3=(Z)=>{if(typeof Z!=="string")throw new TypeError("invalid pattern");if(Z.length>65536)throw new TypeError("pattern is too long")};var cU1={"[: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]},b3=(Z)=>Z.replace(/[[\]\\-]/g,"\\$&"),pU1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Gc=(Z)=>Z.join(""),Hc=(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,H=!1,z=X,V="";Z:while(Q<Z.length){let B=Z.charAt(Q);if((B==="!"||B==="^")&&Q===X+1){H=!0,Q++;continue}if(B==="]"&&K&&!G){z=Q+1;break}if(K=!0,B==="\\"){if(!G){G=!0,Q++;continue}}if(B==="["&&!G){for(let[L,[w,N,R]]of Object.entries(cU1))if(Z.startsWith(L,Q)){if(V)return["$.",!1,Z.length-X,!0];if(Q+=L.length,R)$.push(w);else Y.push(w);W=W||N;continue Z}}if(G=!1,V){if(B>V)Y.push(b3(V)+"-"+b3(B));else if(B===V)Y.push(b3(B));V="",Q++;continue}if(Z.startsWith("-]",Q+1)){Y.push(b3(B+"-")),Q+=2;continue}if(Z.startsWith("-",Q+1)){V=B,Q+=2;continue}Y.push(b3(B)),Q++}if(z<Q)return["",!1,0,!1];if(!Y.length&&!$.length)return["$.",!1,Z.length-X,!0];if($.length===0&&Y.length===1&&/^\\?.$/.test(Y[0])&&!H){let B=Y[0].length===2?Y[0].slice(-1):Y[0];return[pU1(B),!1,z-X,!1]}let F="["+(H?"^":"")+Gc(Y)+"]",q="["+(H?"":"^")+Gc($)+"]";return[Y.length&&$.length?"("+F+"|"+q+")":Y.length?F:q,W,z-X,!0]};var V4=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/\[([^\/\\])\]/g,"$1"):Z.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var iU1=new Set(["!","?","+","*","@"]),zc=(Z)=>iU1.has(Z),nU1="(?!(?:^|/)\\.\\.?(?:$|/))",TL="(?!\\.)",aU1=new Set(["[","."]),sU1=new Set(["..","."]),oU1=new Set("().*{}+?[]^$\\!"),rU1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),YD="[^/]",Fc=YD+"*?",Vc=YD+"+?";class q6{type;#Z;#J;#Y=!1;#X=[];#$;#z;#V;#W=!1;#G;#H;#F=!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.#V=this.#Z===this?[]:this.#Z.#V,Z==="!"&&!this.#Z.#W)this.#V.push(this);this.#z=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.#H!==void 0)return this.#H;if(!this.type)return this.#H=this.#X.map((Z)=>String(Z)).join("");else return this.#H=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.#V.pop()){if(Z.type!=="!")continue;let J=Z,X=J.#$;while(X){for(let Y=J.#z+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 q6&&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.#z===0)return!0;let Z=this.#$;for(let J=0;J<this.#z;J++){let X=Z.#X[J];if(!(X instanceof q6&&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.#z===Z-1}copyIn(Z){if(typeof Z==="string")this.push(Z);else this.push(Z.clone(this))}clone(Z){let J=new q6(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 F=X,q="";while(F<Z.length){let U=Z.charAt(F++);if($||U==="\\"){$=!$,q+=U;continue}if(Q){if(F===K+1){if(U==="^"||U==="!")W=!0}else if(U==="]"&&!(F===K+2&&W))Q=!1;q+=U;continue}else if(U==="["){Q=!0,K=F,W=!1,q+=U;continue}if(!Y.noext&&zc(U)&&Z.charAt(F)==="("){J.push(q),q="";let B=new q6(U,J);F=q6.#U(Z,B,F,Y),J.push(B);continue}q+=U}return J.push(q),F}let G=X+1,H=new q6(null,J),z=[],V="";while(G<Z.length){let F=Z.charAt(G++);if($||F==="\\"){$=!$,V+=F;continue}if(Q){if(G===K+1){if(F==="^"||F==="!")W=!0}else if(F==="]"&&!(G===K+2&&W))Q=!1;V+=F;continue}else if(F==="["){Q=!0,K=G,W=!1,V+=F;continue}if(zc(F)&&Z.charAt(G)==="("){H.push(V),V="";let q=new q6(F,H);H.push(q),G=q6.#U(Z,q,G,Y);continue}if(F==="|"){H.push(V),V="",z.push(H),H=new q6(null,J);continue}if(F===")"){if(V===""&&J.#X.length===0)J.#F=!0;return H.push(V),V="",J.push(...z,H),G}V+=F}return J.type=null,J.#J=void 0,J.#X=[Z.substring(X-1)],G}static fromGlob(Z,J={}){let X=new q6(null,void 0,J);return q6.#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((F)=>{let[q,U,B,L]=typeof F==="string"?q6.#L(F,this.#J,W):F.toRegExpSource(Z);return this.#J=this.#J||B,this.#Y=this.#Y||L,q}).join(""),H="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&sU1.has(this.#X[0]))){let q=aU1,U=J&&q.has(G.charAt(0))||G.startsWith("\\.")&&q.has(G.charAt(2))||G.startsWith("\\.\\.")&&q.has(G.charAt(4)),B=!J&&!Z&&q.has(G.charAt(0));H=U?nU1:B?TL:""}}}let z="";if(this.isEnd()&&this.#Z.#W&&this.#$?.type==="!")z="(?:$|\\/)";return[H+G+z,V4(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,V4(this.toString()),!1,!1]}let Q=!X||Z||J||!TL?"":this.#B(!0);if(Q===$)Q="";if(Q)$=`(?:${$})(?:${Q})*?`;let K="";if(this.type==="!"&&this.#F)K=(this.isStart()&&!J?TL:"")+Vc;else{let W=this.type==="!"?"))"+(this.isStart()&&!J&&!Z?TL:"")+Fc+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&Q?")":this.type==="*"&&Q?")?":`)${this.type}`;K=Y+$+W}return[K,V4($),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,$+=(oU1.has(W)?"\\":"")+W;continue}if(W==="\\"){if(K===Z.length-1)$+="\\\\";else Y=!0;continue}if(W==="["){let[G,H,z,V]=Hc(Z,K);if(z){$+=G,Q=Q||H,K+=z-1,J=J||V;continue}}if(W==="*"){if(X&&Z==="*")$+=Vc;else $+=Fc;J=!0;continue}if(W==="?"){$+=YD,J=!0;continue}$+=rU1(W)}return[$,V4(Z),!!J,Q]}}var tQ=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/[?*()[\]]/g,"[$&]"):Z.replace(/[?*()[\]\\]/g,"\\$&")};var l6=(Z,J,X={})=>{if(y3(J),!X.nocomment&&J.charAt(0)==="#")return!1;return new R9(J,X).match(Z)},tU1=/^\*+([^+@!?\*\[\(]*)$/,eU1=(Z)=>(J)=>!J.startsWith(".")&&J.endsWith(Z),ZL1=(Z)=>(J)=>J.endsWith(Z),JL1=(Z)=>{return Z=Z.toLowerCase(),(J)=>!J.startsWith(".")&&J.toLowerCase().endsWith(Z)},XL1=(Z)=>{return Z=Z.toLowerCase(),(J)=>J.toLowerCase().endsWith(Z)},YL1=/^\*+\.\*+$/,$L1=(Z)=>!Z.startsWith(".")&&Z.includes("."),QL1=(Z)=>Z!=="."&&Z!==".."&&Z.includes("."),KL1=/^\.\*+$/,WL1=(Z)=>Z!=="."&&Z!==".."&&Z.startsWith("."),GL1=/^\*+$/,HL1=(Z)=>Z.length!==0&&!Z.startsWith("."),zL1=(Z)=>Z.length!==0&&Z!=="."&&Z!=="..",FL1=/^\?+([^+@!?\*\[\(]*)?$/,VL1=([Z,J=""])=>{let X=Bc([Z]);if(!J)return X;return J=J.toLowerCase(),(Y)=>X(Y)&&Y.toLowerCase().endsWith(J)},qL1=([Z,J=""])=>{let X=wc([Z]);if(!J)return X;return J=J.toLowerCase(),(Y)=>X(Y)&&Y.toLowerCase().endsWith(J)},UL1=([Z,J=""])=>{let X=wc([Z]);return!J?X:(Y)=>X(Y)&&Y.endsWith(J)},LL1=([Z,J=""])=>{let X=Bc([Z]);return!J?X:(Y)=>X(Y)&&Y.endsWith(J)},Bc=([Z])=>{let J=Z.length;return(X)=>X.length===J&&!X.startsWith(".")},wc=([Z])=>{let J=Z.length;return(X)=>X.length===J&&X!=="."&&X!==".."},Oc=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",qc={win32:{sep:"\\"},posix:{sep:"/"}},BL1=Oc==="win32"?qc.win32.sep:qc.posix.sep;l6.sep=BL1;var U6=Symbol("globstar **");l6.GLOBSTAR=U6;var wL1="[^/]",OL1=wL1+"*?",NL1="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",RL1="(?:(?!(?:\\/|^)\\.).)*?",ML1=(Z,J={})=>(X)=>l6(X,Z,J);l6.filter=ML1;var N9=(Z,J={})=>Object.assign({},Z,J),PL1=(Z)=>{if(!Z||typeof Z!=="object"||!Object.keys(Z).length)return l6;let J=l6;return Object.assign((Y,$,Q={})=>J(Y,$,N9(Z,Q)),{Minimatch:class Y extends J.Minimatch{constructor($,Q={}){super($,N9(Z,Q))}static defaults($){return J.defaults(N9(Z,$)).Minimatch}},AST:class Y extends J.AST{constructor($,Q,K={}){super($,Q,N9(Z,K))}static fromGlob($,Q={}){return J.AST.fromGlob($,N9(Z,Q))}},unescape:(Y,$={})=>J.unescape(Y,N9(Z,$)),escape:(Y,$={})=>J.escape(Y,N9(Z,$)),filter:(Y,$={})=>J.filter(Y,N9(Z,$)),defaults:(Y)=>J.defaults(N9(Z,Y)),makeRe:(Y,$={})=>J.makeRe(Y,N9(Z,$)),braceExpand:(Y,$={})=>J.braceExpand(Y,N9(Z,$)),match:(Y,$,Q={})=>J.match(Y,$,N9(Z,Q)),sep:J.sep,GLOBSTAR:U6})};l6.defaults=PL1;var Nc=(Z,J={})=>{if(y3(Z),J.nobrace||!/\{(?:(?!\{).)*\}/.test(Z))return[Z];return Lc.default(Z)};l6.braceExpand=Nc;var jL1=(Z,J={})=>new R9(Z,J).makeRe();l6.makeRe=jL1;var DL1=(Z,J,X={})=>{let Y=new R9(J,X);if(Z=Z.filter(($)=>Y.match($)),Y.options.nonull&&!Z.length)Z.push(J);return Z};l6.match=DL1;var Uc=/[?*]|[+@!]\(.*?\)|\[|\]/,CL1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class R9{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Z,J={}){if(y3(Z),J=J||{},this.options=J,this.pattern=Z,this.platform=J.platform||Oc,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]==="?"||!Uc.test($[2]))&&!Uc.test($[3]),G=/^[a-z]:/i.test($[0]);if(W)return[...$.slice(0,4),...$.slice(4).map((H)=>this.parse(H))];else if(G)return[$[0],...$.slice(1).map((H)=>this.parse(H))]}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 H=X.slice(0);H[Y]="**",Z.push(H),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]),B=!U&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&/^[a-z]:$/i.test(Z[3]),L=typeof J[0]==="string"&&/^[a-z]:$/i.test(J[0]),w=!L&&J[0]===""&&J[1]===""&&J[2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]),N=B?3:U?0:void 0,R=w?3:L?0:void 0;if(typeof N==="number"&&typeof R==="number"){let[M,D]=[Z[N],J[R]];if(M.toLowerCase()===D.toLowerCase()){if(J[R]=M,R>N)J=J.slice(R);else if(N>R)Z=Z.slice(N)}}}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 H=J[K],z=Z[Q];if(this.debug(J,H,z),H===!1)return!1;if(H===U6){this.debug("GLOBSTAR",[J,H,z]);var V=Q,F=K+1;if(F===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(V<W){var q=Z[V];if(this.debug(`
413
413
  globstar while`,Z,V,J,F,q),this.matchOne(Z.slice(V),J.slice(F),X))return this.debug("globstar found match!",V,W,q),!0;else{if(q==="."||q===".."||!Y.dot&&q.charAt(0)==="."){this.debug("dot detected!",Z,V,J,F);break}this.debug("globstar swallow a segment, and continue"),V++}}if(X){if(this.debug(`
414
- >>> no match, partial?`,Z,V,J,F),V===W)return!0}return!1}let U;if(typeof H==="string")U=z===H,this.debug("string match",H,z,U);else U=H.test(z),this.debug("pattern match",H,z,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 Nc(this.pattern,this.options)}parse(Z){y3(Z);let J=this.options;if(Z==="**")return U6;if(Z==="")return"";let X,Y=null;if(X=Z.match(GL1))Y=J.dot?zL1:HL1;else if(X=Z.match(tU1))Y=(J.nocase?J.dot?XL1:JL1:J.dot?ZL1:eU1)(X[1]);else if(X=Z.match(FL1))Y=(J.nocase?J.dot?qL1:VL1:J.dot?UL1:LL1)(X);else if(X=Z.match(YL1))Y=J.dot?QL1:$L1;else if(X=Z.match(KL1))Y=WL1;let $=q6.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?OL1:J.dot?NL1:RL1,Y=new Set(J.nocase?["i"]:[]),$=Z.map((W)=>{let G=W.map((H)=>{if(H instanceof RegExp)for(let z of H.flags.split(""))Y.add(z);return typeof H==="string"?CL1(H):H===U6?U6:H._src});return G.forEach((H,z)=>{let V=G[z+1],F=G[z-1];if(H!==U6||F===U6)return;if(F===void 0)if(V!==void 0&&V!==U6)G[z+1]="(?:\\/|"+X+"\\/)?"+V;else G[z]=X;else if(V===void 0)G[z-1]=F+"(?:\\/|"+X+")?";else if(V!==U6)G[z-1]=F+"(?:\\/|\\/"+X+"\\/)"+V,G[z+1]=U6}),G.filter((H)=>H!==U6).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 l6.defaults(Z).Minimatch}}l6.AST=q6;l6.Minimatch=R9;l6.escape=tQ;l6.unescape=V4;import{fileURLToPath as YB1}from"node:url";var eQ=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,Mc=new Set,$D=typeof process==="object"&&!!process?process:{},Pc=(Z,J,X,Y)=>{typeof $D.emitWarning==="function"?$D.emitWarning(Z,J,X,Y):console.error(`[${X}] ${J}: ${Z}`)},EL=globalThis.AbortController,Rc=globalThis.AbortSignal;if(typeof EL==="undefined"){Rc=class X{onabort;_onabort=[];reason;aborted=!1;addEventListener(Y,$){this._onabort.push($)}},EL=class X{constructor(){J()}signal=new Rc;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=$D.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,Pc("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 TL1=(Z)=>!Mc.has(Z),SD6=Symbol("type"),RJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),jc=(Z)=>!RJ(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?g3:null;class g3 extends Array{constructor(Z){super(Z);this.fill(0)}}class ZK{heap;length;static#Z=!1;static create(Z){let J=jc(Z);if(!J)return[];ZK.#Z=!0;let X=new ZK(Z,J);return ZK.#Z=!1,X}constructor(Z,J){if(!ZK.#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 m3{#Z;#J;#Y;#X;#$;#z;#V;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#H;#F;#Q;#U;#B;#L;#O;#E;#N;#k;#P;#M;#R;#C;#w;#v;static unsafeExposeInternals(Z){return{starts:Z.#P,ttls:Z.#M,sizes:Z.#k,keyMap:Z.#H,keyList:Z.#F,valList:Z.#Q,next:Z.#U,prev:Z.#B,get head(){return Z.#L},get tail(){return Z.#O},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.#z}get memoMethod(){return this.#V}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:H,disposeAfter:z,noDisposeOnSet:V,noUpdateTTL:F,maxSize:q=0,maxEntrySize:U=0,sizeCalculation:B,fetchMethod:L,memoMethod:w,noDeleteOnFetchRejection:N,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:D,ignoreFetchAbort:j}=Z;if(J!==0&&!RJ(J))throw new TypeError("max option must be a nonnegative integer");let C=J?jc(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=B,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.#V=w,L!==void 0&&typeof L!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#z=L,this.#C=!!L,this.#H=new Map,this.#F=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.#O=0,this.#E=ZK.create(J),this.#W=0,this.#G=0,typeof G==="function")this.#Y=G;if(typeof H==="function")this.#X=H;if(typeof z==="function")this.#$=z,this.#N=[];else this.#$=void 0,this.#N=void 0;if(this.#R=!!this.#Y,this.#v=!!this.#X,this.#w=!!this.#$,this.noDisposeOnSet=!!V,this.noUpdateTTL=!!F,this.noDeleteOnFetchRejection=!!N,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!j,this.maxEntrySize!==0){if(this.#J!==0){if(!RJ(this.#J))throw new TypeError("maxSize must be a positive integer if specified")}if(!RJ(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#m()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=RJ(Y)||Y===0?Y:1,this.ttlAutopurge=!!$,this.ttl=X||0,this.ttl){if(!RJ(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(TL1("LRU_CACHE_UNBOUNDED"))Mc.add("LRU_CACHE_UNBOUNDED"),Pc("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",m3)}}getRemainingTTL(Z){return this.#H.has(Z)?1/0:0}#K(){let Z=new g3(this.#Z),J=new g3(this.#Z);this.#M=Z,this.#P=J,this.#_=($,Q,K=eQ.now())=>{if(J[$]=Q!==0?K:0,Z[$]=Q,Q!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#D($))this.#S(this.#F[$],"expire")},Q+1);if(W.unref)W.unref()}},this.#A=($)=>{J[$]=Z[$]!==0?eQ.now():0},this.#j=($,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 $=eQ.now();if(this.ttlResolution>0){X=$;let Q=setTimeout(()=>X=0,this.ttlResolution);if(Q.unref)Q.unref()}return $};this.getRemainingTTL=($)=>{let Q=this.#H.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=()=>{};#j=()=>{};#_=()=>{};#D=()=>!1;#m(){let Z=new g3(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(!RJ(Y))if($){if(typeof $!=="function")throw new TypeError("sizeCalculation must be a function");if(Y=$(X,J),!RJ(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.#O;;){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.#O)break;else J=this.#U[J]}}#d(Z){return Z!==void 0&&this.#H.get(this.#F[Z])===Z}*entries(){for(let Z of this.#T())if(this.#Q[Z]!==void 0&&this.#F[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#F[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#I())if(this.#Q[Z]!==void 0&&this.#F[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#F[Z],this.#Q[Z]]}*keys(){for(let Z of this.#T()){let J=this.#F[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#I()){let J=this.#F[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.#F[X],this))return this.get(this.#F[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.#F[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.#F[X],this)}}purgeStale(){let Z=!1;for(let J of this.#I({allowStale:!0}))if(this.#D(J))this.#S(this.#F[J],"expire"),Z=!0;return Z}info(Z){let J=this.#H.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.#M&&this.#P){let Q=this.#M[J],K=this.#P[J];if(Q&&K){let W=Q-(eQ.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.#F[J],Y=this.#Q[J],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0||X===void 0)continue;let Q={value:$};if(this.#M&&this.#P){Q.ttl=this.#M[J];let K=eQ.now()-this.#P[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=eQ.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,H=this.#u(Z,J,X.size||0,K);if(this.maxEntrySize&&H>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#S(Z,"set"),this}let z=this.#W===0?void 0:this.#H.get(Z);if(z===void 0){if(z=this.#W===0?this.#O:this.#E.length!==0?this.#E.pop():this.#W===this.#Z?this.#y(!1):this.#W,this.#F[z]=Z,this.#Q[z]=J,this.#H.set(Z,z),this.#U[this.#O]=z,this.#B[z]=this.#O,this.#O=z,this.#W++,this.#f(z,H,W),W)W.set="add";if(G=!1,this.#v)this.#X?.(J,Z,"add")}else{this.#b(z);let V=this.#Q[z];if(J!==V){if(this.#C&&this.#q(V)){V.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:F}=V;if(F!==void 0&&!Q){if(this.#R)this.#Y?.(F,Z,"set");if(this.#w)this.#N?.push([F,Z,"set"])}}else if(!Q){if(this.#R)this.#Y?.(V,Z,"set");if(this.#w)this.#N?.push([V,Z,"set"])}if(this.#x(z),this.#f(z,H,W),this.#Q[z]=J,W){W.set="replace";let F=V&&this.#q(V)?V.__staleWhileFetching:V;if(F!==void 0)W.oldValue=F}}else if(W)W.set="update";if(this.#v)this.onInsert?.(J,Z,J===V?"update":"replace")}if(Y!==0&&!this.#M)this.#K();if(this.#M){if(!G)this.#_(z,Y,$);if(W)this.#j(W,z)}if(!Q&&this.#w&&this.#N){let V=this.#N,F;while(F=V?.shift())this.#$?.(...F)}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.#N){let Z=this.#N,J;while(J=Z?.shift())this.#$?.(...J)}}}#y(Z){let J=this.#L,X=this.#F[J],Y=this.#Q[J];if(this.#C&&this.#q(Y))Y.__abortController.abort(new Error("evicted"));else if(this.#R||this.#w){if(this.#R)this.#Y?.(Y,X,"evict");if(this.#w)this.#N?.push([Y,X,"evict"])}if(this.#x(J),Z)this.#F[J]=void 0,this.#Q[J]=void 0,this.#E.push(J);if(this.#W===1)this.#L=this.#O=0,this.#E.length=0;else this.#L=this.#U[J];return this.#H.delete(X),this.#W--,J}has(Z,J={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:Y}=J,$=this.#H.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.#j(Y,$);return!0}else if(Y)Y.has="stale",this.#j(Y,$)}else if(Y)Y.has="miss";return!1}peek(Z,J={}){let{allowStale:X=this.allowStale}=J,Y=this.#H.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 EL,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:Y},G=(U,B=!1)=>{let{aborted:L}=Q.signal,w=X.ignoreFetchAbort&&U!==void 0;if(X.status)if(L&&!B){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,w)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(L&&!w&&!B)return z(Q.signal.reason);let N=F;if(this.#Q[J]===F)if(U===void 0)if(N.__staleWhileFetching)this.#Q[J]=N.__staleWhileFetching;else this.#S(Z,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Z,U,W.options)}return U},H=(U)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=U;return z(U)},z=(U)=>{let{aborted:B}=Q.signal,L=B&&X.allowStaleOnFetchAbort,w=L||X.allowStaleOnFetchRejection,N=w||X.noDeleteOnFetchRejection,R=F;if(this.#Q[J]===F){if(!N||R.__staleWhileFetching===void 0)this.#S(Z,"fetch");else if(!L)this.#Q[J]=R.__staleWhileFetching}if(w){if(X.status&&R.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return R.__staleWhileFetching}else if(R.__returned===R)throw U},V=(U,B)=>{let L=this.#z?.(Z,$,W);if(L&&L instanceof Promise)L.then((w)=>U(w===void 0?void 0:w),B);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 F=new Promise(V).then(G,H),q=Object.assign(F,{__abortController:Q,__staleWhileFetching:$,__returned:void 0});if(J===void 0)this.set(Z,q,{...W.options,status:void 0}),J=this.#H.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 EL}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:H=this.noUpdateTTL,noDeleteOnFetchRejection:z=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:V=this.allowStaleOnFetchRejection,ignoreFetchAbort:F=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:U,forceRefresh:B=!1,status:L,signal:w}=J;if(!this.#C){if(L)L.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,status:L})}let N={allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:H,noDeleteOnFetchRejection:z,allowStaleOnFetchRejection:V,allowStaleOnFetchAbort:q,ignoreFetchAbort:F,status:L,signal:w},R=this.#H.get(Z);if(R===void 0){if(L)L.fetch="miss";let M=this.#h(Z,R,N,U);return M.__returned=M}else{let M=this.#Q[R];if(this.#q(M)){let E=X&&M.__staleWhileFetching!==void 0;if(L){if(L.fetch="inflight",E)L.returnedStale=!0}return E?M.__staleWhileFetching:M.__returned=M}let D=this.#D(R);if(!B&&!D){if(L)L.fetch="hit";if(this.#b(R),Y)this.#A(R);if(L)this.#j(L,R);return M}let j=this.#h(Z,R,N,U),T=j.__staleWhileFetching!==void 0&&X;if(L){if(L.fetch=D?"stale":"refresh",T&&D)L.returnedStale=!0}return T?j.__staleWhileFetching:j.__returned=j}}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.#V;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.#H.get(Z);if(K!==void 0){let W=this.#Q[K],G=this.#q(W);if(Q)this.#j(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"}#l(Z,J){this.#B[J]=Z,this.#U[Z]=J}#b(Z){if(Z!==this.#O){if(Z===this.#L)this.#L=this.#U[Z];else this.#l(this.#B[Z],this.#U[Z]);this.#l(this.#O,Z),this.#O=Z}}delete(Z){return this.#S(Z,"delete")}#S(Z,J){let X=!1;if(this.#W!==0){let Y=this.#H.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.#R||this.#w){if(this.#R)this.#Y?.($,Z,J);if(this.#w)this.#N?.push([$,Z,J])}if(this.#H.delete(Z),this.#F[Y]=void 0,this.#Q[Y]=void 0,Y===this.#O)this.#O=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.#N?.length){let Y=this.#N,$;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.#F[J];if(this.#R)this.#Y?.(X,Y,Z);if(this.#w)this.#N?.push([X,Y,Z])}}if(this.#H.clear(),this.#Q.fill(void 0),this.#F.fill(void 0),this.#M&&this.#P)this.#M.fill(0),this.#P.fill(0);if(this.#k)this.#k.fill(0);if(this.#L=0,this.#O=0,this.#E.length=0,this.#G=0,this.#W=0,this.#w&&this.#N){let J=this.#N,X;while(X=J?.shift())this.#$?.(...X)}}}import{posix as yL1,win32 as UD}from"node:path";import{fileURLToPath as bL1}from"node:url";import{lstatSync as gL1,readdir as mL1,readdirSync as uL1,readlinkSync as dL1,realpathSync as lL1}from"fs";import*as cL1 from"node:fs";import{lstat as iL1,readdir as nL1,readlink as aL1,realpath as sL1}from"node:fs/promises";import{EventEmitter as zD}from"node:events";import kc from"node:stream";import{StringDecoder as EL1}from"node:string_decoder";var Dc=typeof process==="object"&&process?process:{stdout:null,stderr:null},kL1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof qY||Z instanceof kc||IL1(Z)||vL1(Z)),IL1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof zD&&typeof Z.pipe==="function"&&Z.pipe!==kc.Writable.prototype.pipe,vL1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof zD&&typeof Z.write==="function"&&typeof Z.end==="function",GZ=Symbol("EOF"),HZ=Symbol("maybeEmitEnd"),MJ=Symbol("emittedEnd"),kL=Symbol("emittingEnd"),u3=Symbol("emittedError"),IL=Symbol("closed"),Cc=Symbol("read"),vL=Symbol("flush"),Tc=Symbol("flushChunk"),q4=Symbol("encoding"),JK=Symbol("decoder"),a8=Symbol("flowing"),d3=Symbol("paused"),XK=Symbol("resume"),s8=Symbol("buffer"),c6=Symbol("pipes"),o8=Symbol("bufferLength"),QD=Symbol("bufferPush"),_L=Symbol("bufferShift"),C6=Symbol("objectMode"),B8=Symbol("destroyed"),KD=Symbol("error"),WD=Symbol("emitData"),Ec=Symbol("emitEnd"),GD=Symbol("emitEnd2"),J7=Symbol("async"),HD=Symbol("abort"),SL=Symbol("aborted"),l3=Symbol("signal"),VY=Symbol("dataListeners"),l5=Symbol("discarded"),c3=(Z)=>Promise.resolve().then(Z),_L1=(Z)=>Z(),SL1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",AL1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,xL1=(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[XK](),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 Ic 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 hL1=(Z)=>!!Z.objectMode,fL1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class qY extends zD{[a8]=!1;[d3]=!1;[c6]=[];[s8]=[];[C6];[q4];[J7];[JK];[GZ]=!1;[MJ]=!1;[kL]=!1;[IL]=!1;[u3]=null;[o8]=0;[B8]=!1;[l3];[SL]=!1;[VY]=0;[l5]=!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(hL1(J))this[C6]=!0,this[q4]=null;else if(fL1(J))this[q4]=J.encoding,this[C6]=!1;else this[C6]=!1,this[q4]=null;if(this[J7]=!!J.async,this[JK]=this[q4]?new EL1(this[q4]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[s8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[c6]});let{signal:X}=J;if(X)if(this[l3]=X,X.aborted)this[HD]();else X.addEventListener("abort",()=>this[HD]())}get bufferLength(){return this[o8]}get encoding(){return this[q4]}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[C6]}set objectMode(Z){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[J7]}set["async"](Z){this[J7]=this[J7]||!!Z}[HD](){this[SL]=!0,this.emit("abort",this[l3]?.reason),this.destroy(this[l3]?.reason)}get aborted(){return this[SL]}set aborted(Z){}write(Z,J,X){if(this[SL])return!1;if(this[GZ])throw new Error("write after end");if(this[B8])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[J7]?c3:_L1;if(!this[C6]&&!Buffer.isBuffer(Z)){if(xL1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(AL1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[C6]){if(this[a8]&&this[o8]!==0)this[vL](!0);if(this[a8])this.emit("data",Z);else this[QD](Z);if(this[o8]!==0)this.emit("readable");if(X)Y(X);return this[a8]}if(!Z.length){if(this[o8]!==0)this.emit("readable");if(X)Y(X);return this[a8]}if(typeof Z==="string"&&!(J===this[q4]&&!this[JK]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[q4])Z=this[JK].write(Z);if(this[a8]&&this[o8]!==0)this[vL](!0);if(this[a8])this.emit("data",Z);else this[QD](Z);if(this[o8]!==0)this.emit("readable");if(X)Y(X);return this[a8]}read(Z){if(this[B8])return null;if(this[l5]=!1,this[o8]===0||Z===0||Z&&Z>this[o8])return this[HZ](),null;if(this[C6])Z=null;if(this[s8].length>1&&!this[C6])this[s8]=[this[q4]?this[s8].join(""):Buffer.concat(this[s8],this[o8])];let J=this[Cc](Z||null,this[s8][0]);return this[HZ](),J}[Cc](Z,J){if(this[C6])this[_L]();else{let X=J;if(Z===X.length||Z===null)this[_L]();else if(typeof X==="string")this[s8][0]=X.slice(Z),J=X.slice(0,Z),this[o8]-=Z;else this[s8][0]=X.subarray(Z),J=X.subarray(0,Z),this[o8]-=Z}if(this.emit("data",J),!this[s8].length&&!this[GZ])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[GZ]=!0,this.writable=!1,this[a8]||!this[d3])this[HZ]();return this}[XK](){if(this[B8])return;if(!this[VY]&&!this[c6].length)this[l5]=!0;if(this[d3]=!1,this[a8]=!0,this.emit("resume"),this[s8].length)this[vL]();else if(this[GZ])this[HZ]();else this.emit("drain")}resume(){return this[XK]()}pause(){this[a8]=!1,this[d3]=!0,this[l5]=!1}get destroyed(){return this[B8]}get flowing(){return this[a8]}get paused(){return this[d3]}[QD](Z){if(this[C6])this[o8]+=1;else this[o8]+=Z.length;this[s8].push(Z)}[_L](){if(this[C6])this[o8]-=1;else this[o8]-=this[s8][0].length;return this[s8].shift()}[vL](Z=!1){do;while(this[Tc](this[_L]())&&this[s8].length);if(!Z&&!this[s8].length&&!this[GZ])this.emit("drain")}[Tc](Z){return this.emit("data",Z),this[a8]}pipe(Z,J){if(this[B8])return Z;this[l5]=!1;let X=this[MJ];if(J=J||{},Z===Dc.stdout||Z===Dc.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[c6].push(!J.proxyErrors?new FD(this,Z,J):new Ic(this,Z,J)),this[J7])c3(()=>this[XK]());else this[XK]();return Z}unpipe(Z){let J=this[c6].find((X)=>X.dest===Z);if(J){if(this[c6].length===1){if(this[a8]&&this[VY]===0)this[a8]=!1;this[c6]=[]}else this[c6].splice(this[c6].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[l5]=!1,this[VY]++,!this[c6].length&&!this[a8])this[XK]()}else if(Z==="readable"&&this[o8]!==0)super.emit("readable");else if(SL1(Z)&&this[MJ])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[u3]){let Y=J;if(this[J7])c3(()=>Y.call(this,this[u3]));else Y.call(this,this[u3])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[VY]=this.listeners("data").length,this[VY]===0&&!this[l5]&&!this[c6].length)this[a8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[VY]=0,!this[l5]&&!this[c6].length)this[a8]=!1}return J}get emittedEnd(){return this[MJ]}[HZ](){if(!this[kL]&&!this[MJ]&&!this[B8]&&this[s8].length===0&&this[GZ]){if(this[kL]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[IL])this.emit("close");this[kL]=!1}}emit(Z,...J){let X=J[0];if(Z!=="error"&&Z!=="close"&&Z!==B8&&this[B8])return!1;else if(Z==="data")return!this[C6]&&!X?!1:this[J7]?(c3(()=>this[WD](X)),!0):this[WD](X);else if(Z==="end")return this[Ec]();else if(Z==="close"){if(this[IL]=!0,!this[MJ]&&!this[B8])return!1;let $=super.emit("close");return this.removeAllListeners("close"),$}else if(Z==="error"){this[u3]=X,super.emit(KD,X);let $=!this[l3]||this.listeners("error").length?super.emit("error",X):!1;return this[HZ](),$}else if(Z==="resume"){let $=super.emit("resume");return this[HZ](),$}else if(Z==="finish"||Z==="prefinish"){let $=super.emit(Z);return this.removeAllListeners(Z),$}let Y=super.emit(Z,...J);return this[HZ](),Y}[WD](Z){for(let X of this[c6])if(X.dest.write(Z)===!1)this.pause();let J=this[l5]?!1:super.emit("data",Z);return this[HZ](),J}[Ec](){if(this[MJ])return!1;return this[MJ]=!0,this.readable=!1,this[J7]?(c3(()=>this[GD]()),!0):this[GD]()}[GD](){if(this[JK]){let J=this[JK].end();if(J){for(let X of this[c6])X.dest.write(J);if(!this[l5])super.emit("data",J)}}for(let J of this[c6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[C6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[C6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[C6])throw new Error("cannot concat in objectMode");let Z=await this.collect();return this[q4]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(B8,()=>J(new Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[l5]=!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[GZ])return J();let $,Q,K=(z)=>{this.off("data",W),this.off("end",G),this.off(B8,H),J(),Q(z)},W=(z)=>{this.off("error",K),this.off("end",G),this.off(B8,H),this.pause(),$({value:z,done:!!this[GZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(B8,H),J(),$({done:!0,value:void 0})},H=()=>K(new Error("stream destroyed"));return new Promise((z,V)=>{Q=V,$=z,this.once(B8,H),this.once("error",K),this.once("end",G),this.once("data",W)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[l5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(KD,J),this.off(B8,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(KD,J),this.once(B8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[B8]){if(Z)this.emit("error",Z);else this.emit(B8);return this}this[B8]=!0,this[l5]=!0,this[s8].length=0,this[o8]=0;let J=this;if(typeof J.close==="function"&&!this[IL])J.close();if(Z)this.emit("error",Z);else this.emit(B8);return this}static get isStream(){return kL1}}var pL1=lL1.native,i3={lstatSync:gL1,readdir:mL1,readdirSync:uL1,readlinkSync:dL1,realpathSync:pL1,promises:{lstat:iL1,readdir:nL1,readlink:aL1,realpath:sL1}},xc=(Z)=>!Z||Z===i3||Z===cL1?i3:{...i3,...Z,promises:{...i3.promises,...Z.promises||{}}},hc=/^\\\\\?\\([a-z]:)\\?$/i,oL1=(Z)=>Z.replace(/\//g,"\\").replace(hc,"$1\\"),rL1=/[\\\/]/,P9=0,fc=1,yc=2,X7=4,bc=6,gc=8,UY=10,mc=12,M9=15,p3=~M9,VD=16,vc=32,n3=64,U4=128,AL=256,hL=512,_c=n3|U4|hL,tL1=1023,qD=(Z)=>Z.isFile()?gc:Z.isDirectory()?X7:Z.isSymbolicLink()?UY:Z.isCharacterDevice()?yc:Z.isBlockDevice()?bc:Z.isSocket()?mc:Z.isFIFO()?fc:P9,Sc=new Map,a3=(Z)=>{let J=Sc.get(Z);if(J)return J;let X=Z.normalize("NFKD");return Sc.set(Z,X),X},Ac=new Map,xL=(Z)=>{let J=Ac.get(Z);if(J)return J;let X=a3(Z.toLowerCase());return Ac.set(Z,X),X};class LD extends m3{constructor(){super({max:256})}}class uc extends m3{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var dc=Symbol("PathScurry setAsCwd");class p6{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.#$}#z;get gid(){return this.#z}#V;get rdev(){return this.#V}#W;get blksize(){return this.#W}#G;get ino(){return this.#G}#H;get size(){return this.#H}#F;get blocks(){return this.#F}#Q;get atimeMs(){return this.#Q}#U;get mtimeMs(){return this.#U}#B;get ctimeMs(){return this.#B}#L;get birthtimeMs(){return this.#L}#O;get atime(){return this.#O}#E;get mtime(){return this.#E}#N;get ctime(){return this.#N}#k;get birthtime(){return this.#k}#P;#M;#R;#C;#w;#v;#K;#A;#j;#_;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=P9,X,Y,$,Q,K){if(this.name=Z,this.#P=$?xL(Z):a3(Z),this.#K=J&tL1,this.nocase=$,this.roots=Y,this.root=X||this,this.#A=Q,this.#R=K.fullpath,this.#w=K.relative,this.#v=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=xc(K.fs)}depth(){if(this.#M!==void 0)return this.#M;if(!this.parent)return this.#M=0;return this.#M=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&=~VD,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),Y=this.nocase?xL(Z):a3(Z);for(let W of X)if(W.#P===Y)return W;let $=this.parent?this.sep:"",Q=this.#R?this.#R+$+Z:void 0,K=this.newChild(Z,P9,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=U4;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.#v!==void 0)return this.#v;let Z=this.name,J=this.parent;if(!J)return this.#v=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#R!==void 0)return this.#R;let Z=this.name,J=this.parent;if(!J)return this.#R=this.name;let Y=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#R=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&M9)===P9}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&M9)===gc}isDirectory(){return(this.#K&M9)===X7}isCharacterDevice(){return(this.#K&M9)===yc}isBlockDevice(){return(this.#K&M9)===bc}isFIFO(){return(this.#K&M9)===fc}isSocket(){return(this.#K&M9)===mc}isSymbolicLink(){return(this.#K&UY)===UY}lstatCached(){return this.#K&vc?this:void 0}readlinkCached(){return this.#j}realpathCached(){return this.#_}readdirCached(){let Z=this.children();return Z.slice(0,Z.provisional)}canReadlink(){if(this.#j)return!0;if(!this.parent)return!1;let Z=this.#K&M9;return!(Z!==P9&&Z!==UY||this.#K&AL||this.#K&U4)}calledReaddir(){return!!(this.#K&VD)}isENOENT(){return!!(this.#K&U4)}isNamed(Z){return!this.nocase?this.#P===a3(Z):this.#P===xL(Z)}async readlink(){let Z=this.#j;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.#j=X}catch(J){this.#y(J.code);return}}readlinkSync(){let Z=this.#j;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.#j=X}catch(J){this.#y(J.code);return}}#m(Z){this.#K|=VD;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#x()}}#x(){if(this.#K&U4)return;this.#K=(this.#K|U4)&p3,this.#f()}#f(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#x()}#u(){this.#K|=hL,this.#T()}#T(){if(this.#K&n3)return;let Z=this.#K;if((Z&M9)===X7)Z&=p3;this.#K=Z|n3,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|=AL,Z==="ENOENT")J|=U4;if(Z==="EINVAL"||Z==="UNKNOWN")J&=p3;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#T()}#h(Z,J){return this.#l(Z,J)||this.#q(Z,J)}#q(Z,J){let X=qD(Z),Y=this.newChild(Z.name,X,{parent:this}),$=Y.#K&M9;if($!==X7&&$!==UY&&$!==P9)Y.#K|=n3;return J.unshift(Y),J.provisional++,Y}#l(Z,J){for(let X=J.provisional;X<J.length;X++){let Y=J[X];if((this.nocase?xL(Z.name):a3(Z.name))!==Y.#P)continue;return this.#b(Z,Y,X,J)}}#b(Z,J,X,Y){let $=J.name;if(J.#K=J.#K&p3|qD(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&U4)===0)try{return this.#S(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#d(Z.code)}}lstatSync(){if((this.#K&U4)===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:H,gid:z,ino:V,mode:F,mtime:q,mtimeMs:U,nlink:B,rdev:L,size:w,uid:N}=Z;this.#O=J,this.#Q=X,this.#k=Y,this.#L=$,this.#W=Q,this.#F=K,this.#N=W,this.#B=G,this.#J=H,this.#z=z,this.#G=V,this.#Y=F,this.#E=q,this.#U=U,this.#X=B,this.#V=L,this.#H=w,this.#$=N;let R=qD(Z);if(this.#K=this.#K&p3|R|vc,R!==P9&&R!==X7&&R!==UY)this.#K|=n3}#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})}#c;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.#c)await this.#c;else{let X=()=>{};this.#c=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.#c=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&_c)return!1;let Z=M9&this.#K;if(!(Z===P9||Z===X7||Z===UY))return!1;return!0}shouldWalk(Z,J){return(this.#K&X7)===X7&&!(this.#K&_c)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#_)return this.#_;if((hL|AL|U4)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#_=this.resolve(Z)}catch(Z){this.#u()}}realpathSync(){if(this.#_)return this.#_;if((hL|AL|U4)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#_=this.resolve(Z)}catch(Z){this.#u()}}[dc](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.#v=X.join("/"),Y=Y.parent,X.push("..");Y=Z;while(Y&&Y.parent&&!J.has(Y))Y.#w=void 0,Y.#v=void 0,Y=Y.parent}}class fL extends p6{sep="\\";splitSep=rL1;constructor(Z,J=P9,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}newChild(Z,J=P9,X={}){return new fL(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return UD.parse(Z).root}getRoot(Z){if(Z=oL1(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 s3(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(hc,"$1\\"),Z===J}}class yL extends p6{splitSep="/";sep="/";constructor(Z,J=P9,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=P9,X={}){return new yL(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class BD{root;rootPath;roots;cwd;#Z;#J;#Y;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:Y,childrenCacheSize:$=16384,fs:Q=i3}={}){if(this.#X=xc(Q),Z instanceof URL||Z.startsWith("file://"))Z=bL1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new LD,this.#J=new LD,this.#Y=new uc($);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,H=W.length-1,z=J.sep,V=this.rootPath,F=!1;for(let q of W){let U=H--;G=G.child(q,{relative:new Array(U).fill("..").join(z),relativePosix:new Array(U).fill("..").join("/"),fullpath:V+=(F?"":z)+q}),F=!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 p6))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 p6))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 p6))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 p6))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 p6))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 p6))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 p6))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=(z,V)=>{W.add(z),z.readdirCB((F,q)=>{if(F)return V(F);let U=q.length;if(!U)return V();let B=()=>{if(--U===0)V()};for(let L of q){if(!$||$(L))K.push(X?L:L.fullpath());if(Y&&L.isSymbolicLink())L.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(W,Q)?G(w,B):B());else if(L.shouldWalk(W,Q))G(L,B);else B()}},!0)},H=Z;return new Promise((z,V)=>{G(H,(F)=>{if(F)return V(F);z(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof p6))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 H=G.readdirSync();for(let z of H){if(!$||$(z))K.push(X?z:z.fullpath());let V=z;if(z.isSymbolicLink()){if(!(Y&&(V=z.realpathSync())))continue;if(V.isUnknown())V.lstatSync()}if(V.shouldWalk(W,Q))W.add(V)}}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 p6))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 p6))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 H of G){if(!$||$(H))yield X?H:H.fullpath();let z=H;if(H.isSymbolicLink()){if(!(Y&&(z=H.realpathSync())))continue;if(z.isUnknown())z.lstatSync()}if(z.shouldWalk(K,Q))K.add(z)}}}stream(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof p6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new qY({objectMode:!0});if(!$||$(Z))K.write(X?Z:Z.fullpath());let W=new Set,G=[Z],H=0,z=()=>{let V=!1;while(!V){let F=G.shift();if(!F){if(H===0)K.end();return}H++,W.add(F);let q=(B,L,w=!1)=>{if(B)return K.emit("error",B);if(Y&&!w){let N=[];for(let R of L)if(R.isSymbolicLink())N.push(R.realpath().then((M)=>M?.isUnknown()?M.lstat():M));if(N.length){Promise.all(N).then(()=>q(null,L,!0));return}}for(let N of L)if(N&&(!$||$(N))){if(!K.write(X?N:N.fullpath()))V=!0}H--;for(let N of L){let R=N.realpathCached()||N;if(R.shouldWalk(W,Q))G.push(R)}if(V&&!K.flowing)K.once("drain",z);else if(!U)z()},U=!0;F.readdirCB(q,!0),U=!1}};return z(),K}streamSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof p6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new qY({objectMode:!0}),W=new Set;if(!$||$(Z))K.write(X?Z:Z.fullpath());let G=[Z],H=0,z=()=>{let V=!1;while(!V){let F=G.shift();if(!F){if(H===0)K.end();return}H++,W.add(F);let q=F.readdirSync();for(let U of q)if(!$||$(U)){if(!K.write(X?U:U.fullpath()))V=!0}H--;for(let U of q){let B=U;if(U.isSymbolicLink()){if(!(Y&&(B=U.realpathSync())))continue;if(B.isUnknown())B.lstatSync()}if(B.shouldWalk(W,Q))G.push(B)}}if(V&&!K.flowing)K.once("drain",z)};return z(),K}chdir(Z=this.cwd){let J=this.cwd;this.cwd=typeof Z==="string"?this.cwd.resolve(Z):Z,this.cwd[dc](J)}}class s3 extends BD{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,UD,"\\",{...J,nocase:X});this.nocase=X;for(let Y=this.cwd;Y;Y=Y.parent)Y.nocase=this.nocase}parseRootPath(Z){return UD.parse(Z).root.toUpperCase()}newRoot(Z){return new fL(this.rootPath,X7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class o3 extends BD{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,yL1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new yL(this.rootPath,X7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class bL extends o3{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var cD6=process.platform==="win32"?fL:yL,lc=process.platform==="win32"?s3:process.platform==="darwin"?bL:o3;var eL1=(Z)=>Z.length>=1,ZB1=(Z)=>Z.length>=1;class YK{#Z;#J;#Y;length;#X;#$;#z;#V;#W;#G;#H=!0;constructor(Z,J,X,Y){if(!eL1(Z))throw new TypeError("empty pattern list");if(!ZB1(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,[H,z,V,F,...q]=this.#J;if(G[0]==="")G.shift(),q.shift();let U=[$,Q,K,W,""].join("/"),B=[H,z,V,F,""].join("/");this.#Z=[U,...G],this.#J=[B,...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=$+"/",H=K+"/";this.#Z=[G,...Q],this.#J=[H,...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]===U6}isRegExp(){return this.#Z[this.#Y]instanceof RegExp}globString(){return this.#z=this.#z||(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 YK(this.#Z,this.#J,this.#Y+1,this.#X),this.#$.#G=this.#G,this.#$.#W=this.#W,this.#$.#V=this.#V,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.#V!==void 0?this.#V:this.#V=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.#H)}markFollowGlobstar(){if(this.#Y===0||!this.isGlobstar()||!this.#H)return!1;return this.#H=!1,!0}}var JB1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class r3{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:Y,noglobstar:$,platform:Q=JB1}){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 R9(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 YK(Y,$,0,this.platform),K=new R9(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 wD{store;constructor(Z=new Map){this.store=Z}copy(){return new wD(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 cc{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 pc{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 t3{hasWalkedCache;matches=new cc;subwalks=new pc;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new wD}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 z=$.rest();if(!z){this.matches.add(Y,!0,!1);continue}else $=z}if(Y.isENOENT())continue;let W,G,H=!1;while(typeof(W=$.pattern())==="string"&&(G=$.rest()))Y=Y.resolve(W),$=G,H=!0;if(W=$.pattern(),G=$.rest(),H){if(this.hasWalkedCache.hasWalked(Y,$))continue;this.hasWalkedCache.storeWalked(Y,$)}if(typeof W==="string"){let z=W===".."||W===""||W===".";this.matches.add(Y.resolve(W),K,z);continue}else if(W===U6){if(!Y.isSymbolicLink()||this.follow||$.checkFollowGlobstar())this.subwalks.add(Y,$);let z=G?.pattern(),V=G?.rest();if(!G||(z===""||z===".")&&!V)this.matches.add(Y,K,z===""||z===".");else if(z===".."){let F=Y.parent||Y;if(!V)this.matches.add(F,K,!0);else if(!this.hasWalkedCache.hasWalked(F,V))this.subwalks.add(F,V)}}else if(W instanceof RegExp)this.subwalks.add(Y,$)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new t3(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===U6)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 XB1=(Z,J)=>typeof Z==="string"?new r3([Z],J):Array.isArray(Z)?new r3(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=XB1(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 t3(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,H)=>this.walkCB3(K,H,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 t3(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 gL 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 mL extends OD{results;constructor(Z,J,X){super(Z,J,X);this.results=new qY({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 $B1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Y7{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=YB1(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||$B1,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"?s3:J.platform==="darwin"?bL:J.platform?o3:lc;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 R9(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 H=K[G];if(!H)throw new Error("invalid pattern object");return new YK(W,H,0,this.platform)})}async walk(){return[...await new gL(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 gL(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 mL(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 mL(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 R9(X,J).hasMagic())return!0;return!1};function dL(Z,J={}){return new Y7(Z,J).streamSync()}function nc(Z,J={}){return new Y7(Z,J).stream()}function ac(Z,J={}){return new Y7(Z,J).walkSync()}async function ic(Z,J={}){return new Y7(Z,J).walk()}function lL(Z,J={}){return new Y7(Z,J).iterateSync()}function sc(Z,J={}){return new Y7(Z,J).iterate()}var QB1=dL,KB1=Object.assign(nc,{sync:dL}),WB1=lL,GB1=Object.assign(sc,{sync:lL}),HB1=Object.assign(ac,{stream:dL,iterate:lL}),uL=Object.assign(ic,{glob:ic,globSync:ac,sync:HB1,globStream:nc,stream:KB1,globStreamSync:dL,streamSync:QB1,globIterate:sc,iterate:GB1,globIterateSync:lL,iterateSync:WB1,Glob:Y7,hasMagic:ND,escape:tQ,unescape:V4});uL.glob=uL;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 R5{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 $K 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 R5(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 e3(){return e3=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},e3.apply(this,arguments)}class T6{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 P0{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 a1{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 S0=Symbol("attributes"),L4=Symbol("immutableKeys");class QK extends RD{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[S0]=void 0,this[L4]=void 0,this.graph=Z,this[L4]=new Set,this[S0]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let Y=Z[X];if(Y instanceof QK){let $=this.graph._createEdge(X,this,Y);this[L4].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[S0]){let Y=this[S0][X];if(Y instanceof R5){let $=Y;if($.getChild()===Z)this.setRef(X,J,$.getAttributes())}else if(Y instanceof T6)for(let $ of Y.listRefsByChild(Z)){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if(Y instanceof P0){let $=Y.getRefByChild(Z);if($){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if(Y instanceof a1)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[S0][Z]}set(Z,J){return this[S0][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[S0][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[L4].has(Z))throw new Error(`Cannot overwrite immutable attribute, "${Z}".`);let Y=this[S0][Z];if(Y)Y.dispose();if(!J)return this;let $=this.graph._createEdge(Z,this,J,X);return this[S0][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 T6)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[S0][Z];if(J instanceof T6||J instanceof P0)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,e3({},Y,{key:J}));return $.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[S0][Z];if(J instanceof a1)return J;throw new Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(e3({},Z,{target:this})),this.graph.dispatchEvent(e3({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[S0][J]===Z){if(this[S0][J]=null,this[L4].has(J))Z.getChild().dispose()}else if(this[S0][J]instanceof T6)this[S0][J].remove(Z);else if(this[S0][J]instanceof P0)this[S0][J].remove(Z);else if(this[S0][J]instanceof a1){let X=this[S0][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 Xp="v4.1.1",sL="@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 oL;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(oL||(oL={}));var c5;(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"})(c5||(c5={}));var rL;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(rL||(rL={}));var zZ;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(zZ||(zZ={}));var DJ={"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 zB1(){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 FB1(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=zB1();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 TD(Z){let J=Yp(),X=Z.propertyType===a.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=VB1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))jD(K.min,J),jD(K.max,J)});return J}function VB1(Z,J){let X=Yp();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,H=Q?Q.getCount():$.getCount();G<H;G++){let z=Q?Q.getScalar(G):G;K=$.getElement(z,K),W=FB1(W,K,J),jD(W,X)}}return X}function jD(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 Yp(){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 ED{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 $p{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),qB1(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 ZB{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))===ZB.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}}ZB.PNG_FRIED_CHUNK_NAME="CgBI";class FZ{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}`}}FZ.impls={"image/jpeg":new $p,"image/png":new ZB};function qB1(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 VZ{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 FZ.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 oc(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function LY(Z){if(oc(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(oc(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var DD,ZH;(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"})(ZH||(ZH={}));class P5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=P5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=P5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=P5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=P5.Verbosity.ERROR)console.error(Z)}}DD=P5;P5.Verbosity=ZH;P5.DEFAULT_INSTANCE=new DD(DD.Verbosity.INFO);function UB1(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],H=Z[8],z=Z[9],V=Z[10],F=Z[11],q=Z[12],U=Z[13],B=Z[14],L=Z[15],w=J*K-X*Q,N=J*W-Y*Q,R=J*G-$*Q,M=X*W-Y*K,D=X*G-$*K,j=Y*G-$*W,C=H*U-z*q,T=H*B-V*q,E=H*L-F*q,A=z*B-V*U,_=z*L-F*U,x=V*L-F*B;return w*x-N*_+R*A+M*E-D*T+j*C}function LB1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],H=J[6],z=J[7],V=J[8],F=J[9],q=J[10],U=J[11],B=J[12],L=J[13],w=J[14],N=J[15],R=X[0],M=X[1],D=X[2],j=X[3];return Z[0]=R*Y+M*W+D*V+j*B,Z[1]=R*$+M*G+D*F+j*L,Z[2]=R*Q+M*H+D*q+j*w,Z[3]=R*K+M*z+D*U+j*N,R=X[4],M=X[5],D=X[6],j=X[7],Z[4]=R*Y+M*W+D*V+j*B,Z[5]=R*$+M*G+D*F+j*L,Z[6]=R*Q+M*H+D*q+j*w,Z[7]=R*K+M*z+D*U+j*N,R=X[8],M=X[9],D=X[10],j=X[11],Z[8]=R*Y+M*W+D*V+j*B,Z[9]=R*$+M*G+D*F+j*L,Z[10]=R*Q+M*H+D*q+j*w,Z[11]=R*K+M*z+D*U+j*N,R=X[12],M=X[13],D=X[14],j=X[15],Z[12]=R*Y+M*W+D*V+j*B,Z[13]=R*$+M*G+D*F+j*L,Z[14]=R*Q+M*H+D*q+j*w,Z[15]=R*K+M*z+D*U+j*N,Z}function BB1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],H=J[9],z=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,H,z),Z}function wB1(Z,J){var X=new PD(3);BB1(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,H=J[4]*Y,z=J[5]*$,V=J[6]*Q,F=J[8]*Y,q=J[9]*$,U=J[10]*Q,B=K+z+U,L=0;if(B>0)L=Math.sqrt(B+1)*2,Z[3]=0.25*L,Z[0]=(V-q)/L,Z[1]=(F-G)/L,Z[2]=(W-H)/L;else if(K>z&&K>U)L=Math.sqrt(1+K-z-U)*2,Z[3]=(V-q)/L,Z[0]=0.25*L,Z[1]=(W+H)/L,Z[2]=(F+G)/L;else if(z>U)L=Math.sqrt(1+z-K-U)*2,Z[3]=(F-G)/L,Z[0]=(W+H)/L,Z[1]=0.25*L,Z[2]=(V+q)/L;else L=Math.sqrt(1+U-K-z)*2,Z[3]=(W-H)/L,Z[0]=(F+G)/L,Z[1]=(V+q)/L,Z[2]=0.25*L;return Z}class d0{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(d0.clamp(Z,0,1)*65535);case 5121:return Math.round(d0.clamp(Z,0,1)*255);case 5122:return Math.round(d0.clamp(Z,-1,1)*32767);case 5120:return Math.round(d0.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(UB1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),H=1/$,z=1/Q,V=1/K;G[0]*=H,G[1]*=H,G[2]*=H,G[4]*=z,G[5]*=z,G[6]*=z,G[8]*=V,G[9]*=V,G[10]*=V,wB1(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],H=Q+Q,z=K+K,V=W+W,F=Q*H,q=Q*z,U=Q*V,B=K*z,L=K*V,w=W*V,N=G*H,R=G*z,M=G*V,D=X[0],j=X[1],C=X[2];return $[0]=(1-(B+w))*D,$[1]=(q+M)*D,$[2]=(U-R)*D,$[3]=0,$[4]=(q-M)*j,$[5]=(1-(F+w))*j,$[6]=(L+N)*j,$[7]=0,$[8]=(U+R)*C,$[9]=(L-N)*C,$[10]=(1-(F+B))*C,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function OB1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function NB1(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 RB1(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 Qp(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 Kp(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!LY(Z)||!LY(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(tL(W)&&tL(G)){if(!Qp(W,G))return!1}else if(LY(W)&&LY(G)){if(!Kp(W,G))return!1}else if(W!==G)return!1}return!0}function tL(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var rc="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",MB1=999,PB1=6,tc=new Set,jB1=function Z(){let J="";for(let X=0;X<PB1;X++)J+=rc.charAt(Math.floor(Math.random()*rc.length));return J},Wp=function Z(){for(let J=0;J<MB1;J++){let X=jB1();if(!tc.has(X))return tc.add(X),X}return""},ec="https://null.example";class j9{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return VZ.basename(new URL(Z,ec).pathname)}static extension(Z){return VZ.extension(new URL(Z,ec).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)}}j9.DEFAULT_INIT={};j9.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var jJ=(Z)=>Z,DB1=new Set;class JB extends QK{constructor(Z,J=""){super(Z);this[S0].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,jJ)}copy(Z,J=jJ){for(let X in this[S0]){let Y=this[S0][X];if(Y instanceof R5){if(!this[L4].has(X))Y.dispose()}else if(Y instanceof T6||Y instanceof P0)for(let $ of Y.values())$.dispose();else if(Y instanceof a1)for(let $ of Y.values())$.dispose()}for(let X in Z[S0]){let Y=this[S0][X],$=Z[S0][X];if($ instanceof R5)if(this[L4].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof P0||$ instanceof T6)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof a1)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(LY($))this[S0][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[S0][X]=$.slice();else this[S0][X]=$}return this}equals(Z,J=DB1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[S0]){if(J.has(X))continue;let Y=this[S0][X],$=Z[S0][X];if(Y instanceof R5||$ instanceof R5){if(!OB1(Y,$))return!1}else if(Y instanceof P0||$ instanceof P0||Y instanceof T6||$ instanceof T6){if(!NB1(Y,$))return!1}else if(Y instanceof a1||$ instanceof a1){if(!RB1(Y,$))return!1}else if(LY(Y)||LY($)){if(!Kp(Y,$))return!1}else if(tL(Y)||tL($)){if(!Qp(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 k6 extends JB{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new a1})}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 E0 extends k6{init(){this.propertyType=a.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:E0.Type.SCALAR,componentType:E0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case E0.Type.SCALAR:return 1;case E0.Type.VEC2:return 2;case E0.Type.VEC3:return 3;case E0.Type.VEC4:return 4;case E0.Type.MAT2:return 4;case E0.Type.MAT3:return 9;case E0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case E0.ComponentType.BYTE:return 1;case E0.ComponentType.UNSIGNED_BYTE:return 1;case E0.ComponentType.SHORT:return 2;case E0.ComponentType.UNSIGNED_SHORT:return 2;case E0.ComponentType.UNSIGNED_INT:return 4;case E0.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[$]=d0.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[$]=d0.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 E0.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 d0.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]=d0.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]=d0.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]=d0.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?CB1(Z):E0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}E0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};E0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function CB1(Z){switch(Z.constructor){case Float32Array:return E0.ComponentType.FLOAT;case Uint32Array:return E0.ComponentType.UNSIGNED_INT;case Uint16Array:return E0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return E0.ComponentType.UNSIGNED_BYTE;case Int16Array:return E0.ComponentType.SHORT;case Int8Array:return E0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class kD extends k6{init(){this.propertyType=a.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new P0,samplers:new P0})}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 BY extends k6{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)}}BY.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class KK extends k6{init(){this.propertyType=a.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:KK.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:c5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:c5.OTHER})}}KK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class ID extends k6{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 wY extends k6{init(){this.propertyType=a.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:wY.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)}}wY.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class WK extends JB{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}WK.EXTENSION_NAME=void 0;class M5 extends k6{init(){this.propertyType=a.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:M5.WrapMode.REPEAT,wrapT:M5.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)}}M5.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};M5.MagFilter={NEAREST:9728,LINEAR:9729};M5.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:cL,G:pL,B:iL,A:TB1}=rL;class $7 extends k6{init(){this.propertyType=a.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:$7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new M5(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new M5(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new M5(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new M5(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new M5(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:cL|pL|iL|TB1,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:cL|pL|iL,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:cL|pL|iL})}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:cL})}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:pL|iL})}}$7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class XH extends k6{init(){this.propertyType=a.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new P0})}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 XB extends k6{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 P0})}copy(Z,J=jJ){if(J===jJ)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 d0.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 d0.decompose(Z,J,X,Y),this.set("translation",J).set("rotation",X).set("scale",Y)}getWorldTranslation(){let Z=[0,0,0];return d0.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return d0.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return d0.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())LB1(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 w8 extends k6{init(){this.propertyType=a.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:w8.Mode.TRIANGLES,material:null,indices:null,attributes:new a1,targets:new P0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:c5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:c5.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)}}w8.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class vD extends JB{init(){this.propertyType=a.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new a1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:c5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function i6(){return i6=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},i6.apply(null,arguments)}class GK extends k6{init(){this.propertyType=a.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new P0})}copy(Z,J=jJ){if(J===jJ)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 _D extends k6{init(){this.propertyType=a.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new P0})}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:c5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class OY extends k6{init(){this.propertyType=a.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||FZ.extensionToMimeType(VZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=FZ.extensionToMimeType(VZ.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 FZ.getSize(Z,this.getMimeType())}}class NY extends k6{init(){this.propertyType=a.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Xp}`,version:"2.0"},defaultScene:null,accessors:new P0,animations:new P0,buffers:new P0,cameras:new P0,materials:new P0,meshes:new P0,nodes:new P0,scenes:new P0,skins:new P0,textures:new P0})}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=jJ){if(J===jJ)throw new Error("Root cannot be copied.");this.set("asset",i6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(i6({},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 GK)this.addRef("scenes",Z);else if(Z instanceof XB)this.addRef("nodes",Z);else if(Z instanceof wY)this.addRef("cameras",Z);else if(Z instanceof _D)this.addRef("skins",Z);else if(Z instanceof XH)this.addRef("meshes",Z);else if(Z instanceof $7)this.addRef("materials",Z);else if(Z instanceof OY)this.addRef("textures",Z);else if(Z instanceof kD)this.addRef("animations",Z);else if(Z instanceof E0)this.addRef("accessors",Z);else if(Z instanceof ID)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 E6{static fromGraph(Z){return E6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new $K,this._root=new NY(this._graph),this._logger=P5.DEFAULT_INSTANCE,E6._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 GK(this._graph,Z)}createNode(Z=""){return new XB(this._graph,Z)}createCamera(Z=""){return new wY(this._graph,Z)}createSkin(Z=""){return new _D(this._graph,Z)}createMesh(Z=""){return new XH(this._graph,Z)}createPrimitive(){return new w8(this._graph)}createPrimitiveTarget(Z=""){return new vD(this._graph,Z)}createMaterial(Z=""){return new $7(this._graph,Z)}createTexture(Z=""){return new OY(this._graph,Z)}createAnimation(Z=""){return new kD(this._graph,Z)}createAnimationChannel(Z=""){return new BY(this._graph,Z)}createAnimationSampler(Z=""){return new KK(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new E0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new ID(this._graph,Z)}}E6._GRAPH_DOCUMENTS=new WeakMap;class Gp{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 WK&&$.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}}Gp.EXTENSION_NAME=void 0;class Hp{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 Zp={logger:P5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},EB1=new Set([a.BUFFER,a.TEXTURE,a.MATERIAL,a.MESH,a.PRIMITIVE,a.NODE,a.SCENE]);class zp{static read(Z,J=Zp){let X=i6({},Zp,J),{json:Y}=Z,$=new E6().setLogger(X.logger);this.validate(Z,X);let Q=new Hp(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(i6({},Y.extras));let G=Y.extensionsUsed||[],H=Y.extensionsRequired||[];X.extensions.sort((j,C)=>j.EXTENSION_NAME>C.EXTENSION_NAME?1:-1);for(let j of X.extensions)if(G.includes(j.EXTENSION_NAME)){let C=$.createExtension(j).setRequired(H.includes(j.EXTENSION_NAME)),T=C.prereadTypes.filter((E)=>!EB1.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 z=Y.buffers||[];$.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.BUFFER)).forEach((j)=>j.preread(Q,a.BUFFER)),Q.buffers=z.map((j)=>{let C=$.createBuffer(j.name);if(j.extras)C.setExtras(j.extras);if(j.uri&&j.uri.indexOf("__")!==0)C.setURI(j.uri);return C});let V=Y.bufferViews||[];Q.bufferViewBuffers=V.map((j,C)=>{if(!Q.bufferViews[C]){let T=Z.json.buffers[j.buffer],E=T.uri?Z.resources[T.uri]:Z.resources[sL],A=j.byteOffset||0;Q.bufferViews[C]=n0.toView(E,A,j.byteLength)}return Q.buffers[j.buffer]});let F=Y.accessors||[];Q.accessors=F.map((j)=>{let C=Q.bufferViewBuffers[j.bufferView],T=$.createAccessor(j.name,C).setType(j.type);if(j.extras)T.setExtras(j.extras);if(j.normalized!==void 0)T.setNormalized(j.normalized);if(j.bufferView===void 0)return T;return T.setArray(aL(j,Q)),T});let q=Y.images||[],U=Y.textures||[];$.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.TEXTURE)).forEach((j)=>j.preread(Q,a.TEXTURE)),Q.textures=q.map((j)=>{let C=$.createTexture(j.name);if(j.extras)C.setExtras(j.extras);if(j.bufferView!==void 0){let T=Y.bufferViews[j.bufferView],E=Z.json.buffers[T.buffer],A=E.uri?Z.resources[E.uri]:Z.resources[sL],_=T.byteOffset||0,x=T.byteLength,I=A.slice(_,_+x);C.setImage(I)}else if(j.uri!==void 0){if(C.setImage(Z.resources[j.uri]),j.uri.indexOf("__")!==0)C.setURI(j.uri)}if(j.mimeType!==void 0)C.setMimeType(j.mimeType);else if(j.uri){let T=VZ.extension(j.uri);C.setMimeType(FZ.extensionToMimeType(T))}return C}),$.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.MATERIAL)).forEach((j)=>j.preread(Q,a.MATERIAL));let B=Y.materials||[];Q.materials=B.map((j)=>{let C=$.createMaterial(j.name);if(j.extras)C.setExtras(j.extras);if(j.alphaMode!==void 0)C.setAlphaMode(j.alphaMode);if(j.alphaCutoff!==void 0)C.setAlphaCutoff(j.alphaCutoff);if(j.doubleSided!==void 0)C.setDoubleSided(j.doubleSided);let T=j.pbrMetallicRoughness||{};if(T.baseColorFactor!==void 0)C.setBaseColorFactor(T.baseColorFactor);if(j.emissiveFactor!==void 0)C.setEmissiveFactor(j.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,A=Q.textures[U[E.index].source];C.setBaseColorTexture(A),Q.setTextureInfo(C.getBaseColorTextureInfo(),E)}if(j.emissiveTexture!==void 0){let E=j.emissiveTexture,A=Q.textures[U[E.index].source];C.setEmissiveTexture(A),Q.setTextureInfo(C.getEmissiveTextureInfo(),E)}if(j.normalTexture!==void 0){let E=j.normalTexture,A=Q.textures[U[E.index].source];if(C.setNormalTexture(A),Q.setTextureInfo(C.getNormalTextureInfo(),E),j.normalTexture.scale!==void 0)C.setNormalScale(j.normalTexture.scale)}if(j.occlusionTexture!==void 0){let E=j.occlusionTexture,A=Q.textures[U[E.index].source];if(C.setOcclusionTexture(A),Q.setTextureInfo(C.getOcclusionTextureInfo(),E),j.occlusionTexture.strength!==void 0)C.setOcclusionStrength(j.occlusionTexture.strength)}if(T.metallicRoughnessTexture!==void 0){let E=T.metallicRoughnessTexture,A=Q.textures[U[E.index].source];C.setMetallicRoughnessTexture(A),Q.setTextureInfo(C.getMetallicRoughnessTextureInfo(),E)}return C}),$.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.MESH)).forEach((j)=>j.preread(Q,a.MESH));let L=Y.meshes||[];$.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.PRIMITIVE)).forEach((j)=>j.preread(Q,a.PRIMITIVE)),Q.meshes=L.map((j)=>{let C=$.createMesh(j.name);if(j.extras)C.setExtras(j.extras);if(j.weights!==void 0)C.setWeights(j.weights);return(j.primitives||[]).forEach((E)=>{let A=$.createPrimitive();if(E.extras)A.setExtras(E.extras);if(E.material!==void 0)A.setMaterial(Q.materials[E.material]);if(E.mode!==void 0)A.setMode(E.mode);for(let[I,v]of Object.entries(E.attributes||{}))A.setAttribute(I,Q.accessors[v]);if(E.indices!==void 0)A.setIndices(Q.accessors[E.indices]);let _=j.extras&&j.extras.targetNames||[];(E.targets||[]).forEach((I,v)=>{let y=_[v]||v.toString(),p=$.createPrimitiveTarget(y);for(let[n,o]of Object.entries(I))p.setAttribute(n,Q.accessors[o]);A.addTarget(p)}),C.addPrimitive(A)}),C});let w=Y.cameras||[];Q.cameras=w.map((j)=>{let C=$.createCamera(j.name).setType(j.type);if(j.extras)C.setExtras(j.extras);if(j.type===wY.Type.PERSPECTIVE){let T=j.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=j.orthographic;C.setZNear(T.znear).setZFar(T.zfar).setXMag(T.xmag).setYMag(T.ymag)}return C});let N=Y.nodes||[];$.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.NODE)).forEach((j)=>j.preread(Q,a.NODE)),Q.nodes=N.map((j)=>{let C=$.createNode(j.name);if(j.extras)C.setExtras(j.extras);if(j.translation!==void 0)C.setTranslation(j.translation);if(j.rotation!==void 0)C.setRotation(j.rotation);if(j.scale!==void 0)C.setScale(j.scale);if(j.matrix!==void 0){let T=[0,0,0],E=[0,0,0,1],A=[1,1,1];d0.decompose(j.matrix,T,E,A),C.setTranslation(T),C.setRotation(E),C.setScale(A)}if(j.weights!==void 0)C.setWeights(j.weights);return C});let R=Y.skins||[];Q.skins=R.map((j)=>{let C=$.createSkin(j.name);if(j.extras)C.setExtras(j.extras);if(j.inverseBindMatrices!==void 0)C.setInverseBindMatrices(Q.accessors[j.inverseBindMatrices]);if(j.skeleton!==void 0)C.setSkeleton(Q.nodes[j.skeleton]);for(let T of j.joints)C.addJoint(Q.nodes[T]);return C}),N.map((j,C)=>{let T=Q.nodes[C];if((j.children||[]).forEach((A)=>T.addChild(Q.nodes[A])),j.mesh!==void 0)T.setMesh(Q.meshes[j.mesh]);if(j.camera!==void 0)T.setCamera(Q.cameras[j.camera]);if(j.skin!==void 0)T.setSkin(Q.skins[j.skin])});let M=Y.animations||[];Q.animations=M.map((j)=>{let C=$.createAnimation(j.name);if(j.extras)C.setExtras(j.extras);let E=(j.samplers||[]).map((_)=>{let x=$.createAnimationSampler().setInput(Q.accessors[_.input]).setOutput(Q.accessors[_.output]).setInterpolation(_.interpolation||KK.Interpolation.LINEAR);if(_.extras)x.setExtras(_.extras);return C.addSampler(x),x});return(j.channels||[]).forEach((_)=>{let x=$.createAnimationChannel().setSampler(E[_.sampler]).setTargetPath(_.target.path);if(_.target.node!==void 0)x.setTargetNode(Q.nodes[_.target.node]);if(_.extras)x.setExtras(_.extras);C.addChannel(x)}),C});let D=Y.scenes||[];if($.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.SCENE)).forEach((j)=>j.preread(Q,a.SCENE)),Q.scenes=D.map((j)=>{let C=$.createScene(j.name);if(j.extras)C.setExtras(j.extras);return(j.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((j)=>j.read(Q)),F.forEach((j,C)=>{let T=Q.accessors[C],E=!!j.sparse,A=!j.bufferView&&!T.getArray();if(E||A)T.setSparse(!0).setArray(IB1(j,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 kB1(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=DJ[Z.componentType],K=E0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=Z.byteOffset||0,H=new Q(Z.count*K),z=new DataView(Y.buffer,Y.byteOffset,Y.byteLength),V=$.byteStride;for(let F=0;F<Z.count;F++)for(let q=0;q<K;q++){let U=G+F*V+q*W,B;switch(Z.componentType){case E0.ComponentType.FLOAT:B=z.getFloat32(U,!0);break;case E0.ComponentType.UNSIGNED_INT:B=z.getUint32(U,!0);break;case E0.ComponentType.UNSIGNED_SHORT:B=z.getUint16(U,!0);break;case E0.ComponentType.UNSIGNED_BYTE:B=z.getUint8(U);break;case E0.ComponentType.SHORT:B=z.getInt16(U,!0);break;case E0.ComponentType.BYTE:B=z.getInt8(U);break;default:throw new Error(`Unexpected componentType "${Z.componentType}".`)}H[F*K+q]=B}return H}function aL(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=DJ[Z.componentType],K=E0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if($.byteStride!==void 0&&$.byteStride!==G)return kB1(Z,J);let H=Y.byteOffset+(Z.byteOffset||0),z=Z.count*K*W;return new Q(Y.buffer.slice(H,H+z))}function IB1(Z,J){let X=DJ[Z.componentType],Y=E0.getElementSize(Z.type),$;if(Z.bufferView!==void 0)$=aL(Z,J);else $=new X(Z.count*Y);let Q=Z.sparse;if(!Q)return $;let K=Q.count,W=i6({},Z,Q.indices,{count:K,type:"SCALAR"}),G=i6({},Z,Q.values,{count:K}),H=aL(W,J),z=aL(G,J);for(let V=0;V<W.count;V++)for(let F=0;F<Y;F++)$[H[V]*Y+F]=z[V*Y+F];return $}var JH;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(JH||(JH={}));class PJ{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 CD($>1,()=>X.basename||"buffer"),this.imageURIGenerator=new CD(Q>1,(K)=>vB1(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===zZ.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=FZ.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 c5.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 c5.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}}PJ.BufferViewTarget=JH;PJ.BufferViewUsage=c5;PJ.USAGE_TO_TARGET={[c5.ARRAY_BUFFER]:JH.ARRAY_BUFFER,[c5.ELEMENT_ARRAY_BUFFER]:JH.ELEMENT_ARRAY_BUFFER};class CD{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 vB1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:nL}=PJ,{UNSIGNED_INT:_B1,UNSIGNED_SHORT:SB1,UNSIGNED_BYTE:AB1}=E0.ComponentType,xB1=new Set([a.ACCESSOR,a.BUFFER,a.MATERIAL,a.MESH]);class Fp{static write(Z,J){let X=Z.getGraph(),Y=Z.getRoot(),$={asset:i6({generator:`glTF-Transform ${Xp}`},Y.getAsset()),extras:i6({},Y.getExtras())},Q={json:$,resources:{}},K=new PJ(Z,Q,J),W=J.logger||P5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((L)=>L.EXTENSION_NAME)),H=Z.getRoot().listExtensionsUsed().filter((L)=>G.has(L.extensionName)).sort((L,w)=>L.extensionName>w.extensionName?1:-1),z=Z.getRoot().listExtensionsRequired().filter((L)=>G.has(L.extensionName)).sort((L,w)=>L.extensionName>w.extensionName?1:-1);if(H.length<Z.getRoot().listExtensionsUsed().length)W.warn("Some extensions were not registered for I/O, and will not be written.");for(let L of H){let w=L.prewriteTypes.filter((N)=>!xB1.has(N));if(w.length)W.warn(`Prewrite hooks for some types (${w.join()}), requested by extension ${L.extensionName}, are unsupported. Please file an issue or a PR.`);for(let N of L.writeDependencies)L.install(N,J.dependencies[N])}function V(L,w,N,R){let M=[],D=0;for(let T of L){let E=K.createAccessorDef(T);E.bufferView=$.bufferViews.length;let A=T.getArray(),_=n0.pad(n0.toView(A));E.byteOffset=D,D+=_.byteLength,M.push(_),K.accessorIndexMap.set(T,$.accessors.length),$.accessors.push(E)}let j=n0.concat(M),C={buffer:w,byteOffset:N,byteLength:j.byteLength};if(R)C.target=R;return $.bufferViews.push(C),{buffers:M,byteLength:D}}function F(L,w,N){let R=L[0].getCount(),M=0;for(let E of L){let A=K.createAccessorDef(E);A.bufferView=$.bufferViews.length,A.byteOffset=M;let _=E.getElementSize(),x=E.getComponentSize();M+=n0.padNumber(_*x),K.accessorIndexMap.set(E,$.accessors.length),$.accessors.push(A)}let D=R*M,j=new ArrayBuffer(D),C=new DataView(j);for(let E=0;E<R;E++){let A=0;for(let _ of L){let x=_.getElementSize(),I=_.getComponentSize(),v=_.getComponentType(),y=_.getArray();for(let p=0;p<x;p++){let n=E*M+A+p*I,o=y[E*x+p];switch(v){case E0.ComponentType.FLOAT:C.setFloat32(n,o,!0);break;case E0.ComponentType.BYTE:C.setInt8(n,o);break;case E0.ComponentType.SHORT:C.setInt16(n,o,!0);break;case E0.ComponentType.UNSIGNED_BYTE:C.setUint8(n,o);break;case E0.ComponentType.UNSIGNED_SHORT:C.setUint16(n,o,!0);break;case E0.ComponentType.UNSIGNED_INT:C.setUint32(n,o,!0);break;default:throw new Error("Unexpected component type: "+v)}}A+=n0.padNumber(x*I)}}let T={buffer:w,byteOffset:N,byteLength:D,byteStride:M,target:PJ.BufferViewTarget.ARRAY_BUFFER};return $.bufferViews.push(T),{byteLength:D,buffers:[new Uint8Array(j)]}}function q(L,w,N){let R=[],M=0,D=new Map,j=-1/0,C=!1;for(let v of L){let y=K.createAccessorDef(v);$.accessors.push(y),K.accessorIndexMap.set(v,$.accessors.length-1);let p=[],n=[],o=[],J0=new Array(v.getElementSize()).fill(0);for(let a0=0,E8=v.getCount();a0<E8;a0++){if(v.getElement(a0,o),d0.eq(o,J0,0))continue;j=Math.max(a0,j),p.push(a0);for(let i1=0;i1<o.length;i1++)n.push(o[i1])}let Q0=p.length,D0={accessorDef:y,count:Q0};if(D.set(v,D0),Q0===0)continue;if(Q0>v.getCount()/2)C=!0;let C0=DJ[v.getComponentType()];D0.indices=p,D0.values=new C0(n)}if(!Number.isFinite(j))return{buffers:R,byteLength:M};if(C)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let T=j<255?Uint8Array:j<65535?Uint16Array:Uint32Array,E=j<255?AB1:j<65535?SB1:_B1,A={buffer:w,byteOffset:N+M,byteLength:0};for(let v of L){let y=D.get(v);if(y.count===0)continue;y.indicesByteOffset=A.byteLength;let p=n0.pad(n0.toView(new T(y.indices)));R.push(p),M+=p.byteLength,A.byteLength+=p.byteLength}$.bufferViews.push(A);let _=$.bufferViews.length-1,x={buffer:w,byteOffset:N+M,byteLength:0};for(let v of L){let y=D.get(v);if(y.count===0)continue;y.valuesByteOffset=x.byteLength;let p=n0.pad(n0.toView(y.values));R.push(p),M+=p.byteLength,x.byteLength+=p.byteLength}$.bufferViews.push(x);let I=$.bufferViews.length-1;for(let v of L){let y=D.get(v);if(y.count===0)continue;y.accessorDef.sparse={count:y.count,indices:{bufferView:_,byteOffset:y.indicesByteOffset,componentType:E},values:{bufferView:I,byteOffset:y.valuesByteOffset}}}return{buffers:R,byteLength:M}}if($.accessors=[],$.bufferViews=[],$.samplers=[],$.textures=[],$.images=Y.listTextures().map((L,w)=>{let N=K.createPropertyDef(L);if(L.getMimeType())N.mimeType=L.getMimeType();let R=L.getImage();if(R)K.createImageData(N,R,L);return K.imageIndexMap.set(L,w),N}),H.filter((L)=>L.prewriteTypes.includes(a.ACCESSOR)).forEach((L)=>L.prewrite(K,a.ACCESSOR)),Y.listAccessors().forEach((L)=>{let{accessorUsageGroupedByParent:w,accessorParents:N}=K;if(K.accessorIndexMap.has(L))return;let R=K.getAccessorUsage(L);if(K.addAccessorToUsageGroup(L,R),w.has(R)){let M=X.listParents(L).find((D)=>D.propertyType!==a.ROOT);N.set(L,M)}}),H.filter((L)=>L.prewriteTypes.includes(a.BUFFER)).forEach((L)=>L.prewrite(K,a.BUFFER)),(Y.listAccessors().length>0||K.otherBufferViews.size>0||Y.listTextures().length>0&&J.format===zZ.GLB)&&Y.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");if($.buffers=[],Y.listBuffers().forEach((L,w)=>{let N=K.createPropertyDef(L),R=K.accessorUsageGroupedByParent,M=L.listParents().filter((x)=>x instanceof E0),D=new Set(M.map((x)=>K.accessorParents.get(x))),j=new Map(Array.from(D).map((x,I)=>[x,I])),C={};for(let x of M){var T;if(K.accessorIndexMap.has(x))continue;let I=K.getAccessorUsage(x),v=I;if(R.has(I)){let y=K.accessorParents.get(x);v+=`:${j.get(y)}`}C[T=v]||(C[T]={usage:I,accessors:[]}),C[v].accessors.push(x)}let E=[],A=$.buffers.length,_=0;for(let{usage:x,accessors:I}of Object.values(C))if(x===nL.ARRAY_BUFFER&&J.vertexLayout===oL.INTERLEAVED){let v=F(I,A,_);_+=v.byteLength;for(let y of v.buffers)E.push(y)}else if(x===nL.ARRAY_BUFFER)for(let v of I){let y=F([v],A,_);_+=y.byteLength;for(let p of y.buffers)E.push(p)}else if(x===nL.SPARSE){let v=q(I,A,_);_+=v.byteLength;for(let y of v.buffers)E.push(y)}else if(x===nL.ELEMENT_ARRAY_BUFFER){let v=PJ.BufferViewTarget.ELEMENT_ARRAY_BUFFER,y=V(I,A,_,v);_+=y.byteLength;for(let p of y.buffers)E.push(p)}else{let v=V(I,A,_);_+=v.byteLength;for(let y of v.buffers)E.push(y)}if(K.imageBufferViews.length&&w===0){for(let x=0;x<K.imageBufferViews.length;x++)if($.bufferViews[$.images[x].bufferView].byteOffset=_,_+=K.imageBufferViews[x].byteLength,E.push(K.imageBufferViews[x]),_%8){let I=8-_%8;_+=I,E.push(new Uint8Array(I))}}if(K.otherBufferViews.has(L))for(let x of K.otherBufferViews.get(L))$.bufferViews.push({buffer:A,byteOffset:_,byteLength:x.byteLength}),K.otherBufferViewsIndexMap.set(x,$.bufferViews.length-1),_+=x.byteLength,E.push(x);if(_){let x;if(J.format===zZ.GLB)x=sL;else x=K.bufferURIGenerator.createURI(L,"bin"),N.uri=x;N.byteLength=_,K.assignResourceURI(x,n0.concat(E),!0)}$.buffers.push(N),K.bufferIndexMap.set(L,w)}),Y.listAccessors().find((L)=>!L.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");H.filter((L)=>L.prewriteTypes.includes(a.MATERIAL)).forEach((L)=>L.prewrite(K,a.MATERIAL)),$.materials=Y.listMaterials().map((L,w)=>{let N=K.createPropertyDef(L);if(L.getAlphaMode()!==$7.AlphaMode.OPAQUE)N.alphaMode=L.getAlphaMode();if(L.getAlphaMode()===$7.AlphaMode.MASK)N.alphaCutoff=L.getAlphaCutoff();if(L.getDoubleSided())N.doubleSided=!0;if(N.pbrMetallicRoughness={},!d0.eq(L.getBaseColorFactor(),[1,1,1,1]))N.pbrMetallicRoughness.baseColorFactor=L.getBaseColorFactor();if(!d0.eq(L.getEmissiveFactor(),[0,0,0]))N.emissiveFactor=L.getEmissiveFactor();if(L.getRoughnessFactor()!==1)N.pbrMetallicRoughness.roughnessFactor=L.getRoughnessFactor();if(L.getMetallicFactor()!==1)N.pbrMetallicRoughness.metallicFactor=L.getMetallicFactor();if(L.getBaseColorTexture()){let R=L.getBaseColorTexture(),M=L.getBaseColorTextureInfo();N.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(R,M)}if(L.getEmissiveTexture()){let R=L.getEmissiveTexture(),M=L.getEmissiveTextureInfo();N.emissiveTexture=K.createTextureInfoDef(R,M)}if(L.getNormalTexture()){let R=L.getNormalTexture(),M=L.getNormalTextureInfo(),D=K.createTextureInfoDef(R,M);if(L.getNormalScale()!==1)D.scale=L.getNormalScale();N.normalTexture=D}if(L.getOcclusionTexture()){let R=L.getOcclusionTexture(),M=L.getOcclusionTextureInfo(),D=K.createTextureInfoDef(R,M);if(L.getOcclusionStrength()!==1)D.strength=L.getOcclusionStrength();N.occlusionTexture=D}if(L.getMetallicRoughnessTexture()){let R=L.getMetallicRoughnessTexture(),M=L.getMetallicRoughnessTextureInfo();N.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(R,M)}return K.materialIndexMap.set(L,w),N}),H.filter((L)=>L.prewriteTypes.includes(a.MESH)).forEach((L)=>L.prewrite(K,a.MESH)),$.meshes=Y.listMeshes().map((L,w)=>{let N=K.createPropertyDef(L),R=null;if(N.primitives=L.listPrimitives().map((M)=>{let D={attributes:{}};D.mode=M.getMode();let j=M.getMaterial();if(j)D.material=K.materialIndexMap.get(j);if(Object.keys(M.getExtras()).length)D.extras=M.getExtras();let C=M.getIndices();if(C)D.indices=K.accessorIndexMap.get(C);for(let T of M.listSemantics())D.attributes[T]=K.accessorIndexMap.get(M.getAttribute(T));for(let T of M.listTargets()){let E={};for(let A of T.listSemantics())E[A]=K.accessorIndexMap.get(T.getAttribute(A));D.targets=D.targets||[],D.targets.push(E)}if(M.listTargets().length&&!R)R=M.listTargets().map((T)=>T.getName());return D}),L.getWeights().length)N.weights=L.getWeights();if(R)N.extras=N.extras||{},N.extras.targetNames=R;return K.meshIndexMap.set(L,w),N}),$.cameras=Y.listCameras().map((L,w)=>{let N=K.createPropertyDef(L);if(N.type=L.getType(),N.type===wY.Type.PERSPECTIVE){N.perspective={znear:L.getZNear(),zfar:L.getZFar(),yfov:L.getYFov()};let R=L.getAspectRatio();if(R!==null)N.perspective.aspectRatio=R}else N.orthographic={znear:L.getZNear(),zfar:L.getZFar(),xmag:L.getXMag(),ymag:L.getYMag()};return K.cameraIndexMap.set(L,w),N}),$.nodes=Y.listNodes().map((L,w)=>{let N=K.createPropertyDef(L);if(!d0.eq(L.getTranslation(),[0,0,0]))N.translation=L.getTranslation();if(!d0.eq(L.getRotation(),[0,0,0,1]))N.rotation=L.getRotation();if(!d0.eq(L.getScale(),[1,1,1]))N.scale=L.getScale();if(L.getWeights().length)N.weights=L.getWeights();return K.nodeIndexMap.set(L,w),N}),$.skins=Y.listSkins().map((L,w)=>{let N=K.createPropertyDef(L),R=L.getInverseBindMatrices();if(R)N.inverseBindMatrices=K.accessorIndexMap.get(R);let M=L.getSkeleton();if(M)N.skeleton=K.nodeIndexMap.get(M);return N.joints=L.listJoints().map((D)=>K.nodeIndexMap.get(D)),K.skinIndexMap.set(L,w),N}),Y.listNodes().forEach((L,w)=>{let N=$.nodes[w],R=L.getMesh();if(R)N.mesh=K.meshIndexMap.get(R);let M=L.getCamera();if(M)N.camera=K.cameraIndexMap.get(M);let D=L.getSkin();if(D)N.skin=K.skinIndexMap.get(D);if(L.listChildren().length>0)N.children=L.listChildren().map((j)=>K.nodeIndexMap.get(j))}),$.animations=Y.listAnimations().map((L,w)=>{let N=K.createPropertyDef(L),R=new Map;return N.samplers=L.listSamplers().map((M,D)=>{let j=K.createPropertyDef(M);return j.input=K.accessorIndexMap.get(M.getInput()),j.output=K.accessorIndexMap.get(M.getOutput()),j.interpolation=M.getInterpolation(),R.set(M,D),j}),N.channels=L.listChannels().map((M)=>{let D=K.createPropertyDef(M);return D.sampler=R.get(M.getSampler()),D.target={node:K.nodeIndexMap.get(M.getTargetNode()),path:M.getTargetPath()},D}),K.animationIndexMap.set(L,w),N}),$.scenes=Y.listScenes().map((L,w)=>{let N=K.createPropertyDef(L);return N.nodes=L.listChildren().map((R)=>K.nodeIndexMap.get(R)),K.sceneIndexMap.set(L,w),N});let B=Y.getDefaultScene();if(B)$.scene=Y.listScenes().indexOf(B);return $.extensionsUsed=H.map((L)=>L.extensionName),$.extensionsRequired=z.map((L)=>L.extensionName),H.forEach((L)=>L.write(K)),hB1($),Q}}function hB1(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 eL;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(eL||(eL={}));class Vp{constructor(){this._logger=P5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=oL.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=Jp(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),zp.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)=>fB1(J,Y)))throw new Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some((Y)=>yB1(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===zZ.GLB&&Z.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Fp.write(Z,{format:J.format||zZ.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:i6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:zZ.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 H=n0.pad(G,0),z=n0.toView(new Uint32Array([H.byteLength,5130562])),V=n0.concat([z,H]);return Y[Y.length-1]+=V.byteLength,n0.concat([n0.toView(Y),W,V])}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=`__${Wp()}.${VZ.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:i6({},Z.json),resources:i6({},Z.resources)},J)Z.json.images=J.map((Y)=>i6({},Y));if(X)Z.json.buffers=X.map((Y)=>i6({},Y));return Z}_binaryToJSON(Z){if(!Jp(Z))throw new Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==eL.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]!==eL.BIN)return{json:Q,resources:{}};let G=W[0],H=n0.toView(Z,K+8,G);return{json:Q,resources:{[sL]:H}}}}function fB1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function yB1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function Jp(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 SD extends Vp{constructor(Z=null,J=j9.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(),j9.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(j9.isAbsoluteURL(Z)||j9.isAbsoluteURL(J))return j9.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(j9.isAbsoluteURL(Z))return j9.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:zZ.GLTF,basename:VZ.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 H of bB1(Object.keys($),10))await Promise.all(H.map(async function(z){if(j9.isAbsoluteURL(z)){if(j9.extension(z)==="bin")throw new Error(`Cannot write buffer to path "${z}".`);return}let V=K.join(W,decodeURIComponent(z));await Q.mkdir(K.dirname(V),{recursive:!0}),await Q.writeFile(V,$[z]),X.lastWriteBytes+=$[z].byteLength}))}async _writeGLB(Z,J){let X=await this.writeBinary(J);await this._fs.writeFile(Z,X),this.lastWriteBytes=X.byteLength}}function bB1(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 Ha=r(AD(),1),za=r(pn(),1),IR1=r(Ga(),1);async function vR1(Z,J){if(!(Z instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:Y}=await za.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return Ha.default(new Uint8Array(X),[Y.width,Y.height,4],[4,4*Y.width|0,1],0)}async function Fa(Z,J){return vR1(Z)}var _R1="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 Va;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(Va||(Va={}));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 a5;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(a5||(a5={}));var QC;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(QC||(QC={}));var KC=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 SR1(){var Z=new KC(3);if(KC!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function $C(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function AR1(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=SR1();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 Ba(Z){let J=wa(),X=Z.propertyType===s.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=xR1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))WC(K.min,J),WC(K.max,J)});return J}function xR1(Z,J){let X=wa();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,H=Q?Q.getCount():$.getCount();G<H;G++){let z=Q?Q.getScalar(G):G;K=$.getElement(z,K),W=AR1(W,K,J),WC(W,X)}}return X}function WC(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 wa(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class I6{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 Oa{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),hR1(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 _B{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(I6.decodeText(Z.slice(12,16))===_B.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}}_B.PNG_FRIED_CHUNK_NAME="CgBI";class w4{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}`}}w4.impls={"image/jpeg":new Oa,"image/png":new _B};function hR1(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 VH{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 w4.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 qa(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function jY(Z){if(qa(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(qa(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var GC,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 z7{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=z7.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=z7.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=z7.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=z7.Verbosity.ERROR)console.error(Z)}}GC=z7;z7.Verbosity=HC;z7.DEFAULT_INSTANCE=new GC(GC.Verbosity.INFO);function fR1(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],H=Z[8],z=Z[9],V=Z[10],F=Z[11],q=Z[12],U=Z[13],B=Z[14],L=Z[15],w=J*K-X*Q,N=J*W-Y*Q,R=J*G-$*Q,M=X*W-Y*K,D=X*G-$*K,j=Y*G-$*W,C=H*U-z*q,T=H*B-V*q,E=H*L-F*q,A=z*B-V*U,_=z*L-F*U,x=V*L-F*B;return w*x-N*_+R*A+M*E-D*T+j*C}function yR1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],H=J[6],z=J[7],V=J[8],F=J[9],q=J[10],U=J[11],B=J[12],L=J[13],w=J[14],N=J[15],R=X[0],M=X[1],D=X[2],j=X[3];return Z[0]=R*Y+M*W+D*V+j*B,Z[1]=R*$+M*G+D*F+j*L,Z[2]=R*Q+M*H+D*q+j*w,Z[3]=R*K+M*z+D*U+j*N,R=X[4],M=X[5],D=X[6],j=X[7],Z[4]=R*Y+M*W+D*V+j*B,Z[5]=R*$+M*G+D*F+j*L,Z[6]=R*Q+M*H+D*q+j*w,Z[7]=R*K+M*z+D*U+j*N,R=X[8],M=X[9],D=X[10],j=X[11],Z[8]=R*Y+M*W+D*V+j*B,Z[9]=R*$+M*G+D*F+j*L,Z[10]=R*Q+M*H+D*q+j*w,Z[11]=R*K+M*z+D*U+j*N,R=X[12],M=X[13],D=X[14],j=X[15],Z[12]=R*Y+M*W+D*V+j*B,Z[13]=R*$+M*G+D*F+j*L,Z[14]=R*Q+M*H+D*q+j*w,Z[15]=R*K+M*z+D*U+j*N,Z}function bR1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],H=J[9],z=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,H,z),Z}function gR1(Z,J){var X=new KC(3);bR1(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,H=J[4]*Y,z=J[5]*$,V=J[6]*Q,F=J[8]*Y,q=J[9]*$,U=J[10]*Q,B=K+z+U,L=0;if(B>0)L=Math.sqrt(B+1)*2,Z[3]=0.25*L,Z[0]=(V-q)/L,Z[1]=(F-G)/L,Z[2]=(W-H)/L;else if(K>z&&K>U)L=Math.sqrt(1+K-z-U)*2,Z[3]=(V-q)/L,Z[0]=0.25*L,Z[1]=(W+H)/L,Z[2]=(F+G)/L;else if(z>U)L=Math.sqrt(1+z-K-U)*2,Z[3]=(F-G)/L,Z[0]=(W+H)/L,Z[1]=0.25*L,Z[2]=(V+q)/L;else L=Math.sqrt(1+U-K-z)*2,Z[3]=(W-H)/L,Z[0]=(F+G)/L,Z[1]=(V+q)/L,Z[2]=0.25*L;return Z}class Q8{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(Q8.clamp(Z,0,1)*65535);case 5121:return Math.round(Q8.clamp(Z,0,1)*255);case 5122:return Math.round(Q8.clamp(Z,-1,1)*32767);case 5120:return Math.round(Q8.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,Y){let $=$C([Z[0],Z[1],Z[2]]),Q=$C([Z[4],Z[5],Z[6]]),K=$C([Z[8],Z[9],Z[10]]);if(fR1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),H=1/$,z=1/Q,V=1/K;G[0]*=H,G[1]*=H,G[2]*=H,G[4]*=z,G[5]*=z,G[6]*=z,G[8]*=V,G[9]*=V,G[10]*=V,gR1(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],H=Q+Q,z=K+K,V=W+W,F=Q*H,q=Q*z,U=Q*V,B=K*z,L=K*V,w=W*V,N=G*H,R=G*z,M=G*V,D=X[0],j=X[1],C=X[2];return $[0]=(1-(B+w))*D,$[1]=(q+M)*D,$[2]=(U-R)*D,$[3]=0,$[4]=(q-M)*j,$[5]=(1-(F+w))*j,$[6]=(L+N)*j,$[7]=0,$[8]=(U+R)*C,$[9]=(L-N)*C,$[10]=(1-(F+B))*C,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function mR1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function uR1(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 dR1(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 Na(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 Ra(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(kB(W)&&kB(G)){if(!Na(W,G))return!1}else if(jY(W)&&jY(G)){if(!Ra(W,G))return!1}else if(W!==G)return!1}return!0}function kB(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Ua="https://null.example";class VC{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return VH.basename(new URL(Z,Ua).pathname)}static extension(Z){return VH.extension(new URL(Z,Ua).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)}}VC.DEFAULT_INIT={};VC.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var vJ=(Z)=>Z,lR1=new Set;class SB extends QK{constructor(Z,J=""){super(Z);this[S0].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,vJ)}copy(Z,J=vJ){for(let X in this[S0]){let Y=this[S0][X];if(Y instanceof R5){if(!this[L4].has(X))Y.dispose()}else if(Y instanceof T6||Y instanceof P0)for(let $ of Y.values())$.dispose();else if(Y instanceof a1)for(let $ of Y.values())$.dispose()}for(let X in Z[S0]){let Y=this[S0][X],$=Z[S0][X];if($ instanceof R5)if(this[L4].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof P0||$ instanceof T6)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof a1)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(jY($))this[S0][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[S0][X]=$.slice();else this[S0][X]=$}return this}equals(Z,J=lR1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[S0]){if(J.has(X))continue;let Y=this[S0][X],$=Z[S0][X];if(Y instanceof R5||$ instanceof R5){if(!mR1(Y,$))return!1}else if(Y instanceof P0||$ instanceof P0||Y instanceof T6||$ instanceof T6){if(!uR1(Y,$))return!1}else if(Y instanceof a1||$ instanceof a1){if(!dR1(Y,$))return!1}else if(jY(Y)||jY($)){if(!Ra(Y,$))return!1}else if(kB(Y)||kB($)){if(!Na(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 SB{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new a1})}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[$]=Q8.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[$]=Q8.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 Q8.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]=Q8.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]=Q8.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]=Q8.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?cR1(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 cR1(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 qC extends v6{init(){this.propertyType=s.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new P0,samplers:new P0})}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 UH 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)}}UH.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class OK extends v6{init(){this.propertyType=s.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:OK.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})}}OK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class UC 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 LH extends v6{init(){this.propertyType=s.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:LH.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)}}LH.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class p1 extends SB{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}p1.EXTENSION_NAME=void 0;class P1 extends v6{init(){this.propertyType=s.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:P1.WrapMode.REPEAT,wrapT:P1.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)}}P1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};P1.MagFilter={NEAREST:9728,LINEAR:9729};P1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:CB,G:TB,B:EB,A:pR1}=a5;class BH extends v6{init(){this.propertyType=s.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:BH.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new P1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new P1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new P1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new P1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new P1(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:CB|TB|EB|pR1,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:CB|TB|EB,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:CB|TB|EB})}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:CB})}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:TB|EB})}}BH.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class LC extends v6{init(){this.propertyType=s.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new P0})}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 BC 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 P0})}copy(Z,J=vJ){if(J===vJ)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 Q8.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 Q8.decompose(Z,J,X,Y),this.set("translation",J).set("rotation",X).set("scale",Y)}getWorldTranslation(){let Z=[0,0,0];return Q8.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return Q8.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return Q8.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())yR1(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 _J extends v6{init(){this.propertyType=s.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:_J.Mode.TRIANGLES,material:null,indices:null,attributes:new a1,targets:new P0})}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)}}_J.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class Ma extends SB{init(){this.propertyType=s.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new a1})}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 IB(){return IB=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},IB.apply(null,arguments)}class wC extends v6{init(){this.propertyType=s.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new P0})}copy(Z,J=vJ){if(J===vJ)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 P0})}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 NC extends v6{init(){this.propertyType=s.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||w4.extensionToMimeType(VH.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=w4.extensionToMimeType(VH.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",I6.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return w4.getSize(Z,this.getMimeType())}}class AB extends v6{init(){this.propertyType=s.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${_R1}`,version:"2.0"},defaultScene:null,accessors:new P0,animations:new P0,buffers:new P0,cameras:new P0,materials:new P0,meshes:new P0,nodes:new P0,scenes:new P0,skins:new P0,textures:new P0})}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=vJ){if(J===vJ)throw new Error("Root cannot be copied.");this.set("asset",IB({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(IB({},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 wC)this.addRef("scenes",Z);else if(Z instanceof BC)this.addRef("nodes",Z);else if(Z instanceof LH)this.addRef("cameras",Z);else if(Z instanceof OC)this.addRef("skins",Z);else if(Z instanceof LC)this.addRef("meshes",Z);else if(Z instanceof BH)this.addRef("materials",Z);else if(Z instanceof NC)this.addRef("textures",Z);else if(Z instanceof qC)this.addRef("animations",Z);else if(Z instanceof N0)this.addRef("accessors",Z);else if(Z instanceof UC)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 vB{static fromGraph(Z){return vB._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new $K,this._root=new AB(this._graph),this._logger=z7.DEFAULT_INSTANCE,vB._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 wC(this._graph,Z)}createNode(Z=""){return new BC(this._graph,Z)}createCamera(Z=""){return new LH(this._graph,Z)}createSkin(Z=""){return new OC(this._graph,Z)}createMesh(Z=""){return new LC(this._graph,Z)}createPrimitive(){return new _J(this._graph)}createPrimitiveTarget(Z=""){return new Ma(this._graph,Z)}createMaterial(Z=""){return new BH(this._graph,Z)}createTexture(Z=""){return new NC(this._graph,Z)}createAnimation(Z=""){return new qC(this._graph,Z)}createAnimationChannel(Z=""){return new UH(this._graph,Z)}createAnimationSampler(Z=""){return new OK(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 UC(this._graph,Z)}}vB._GRAPH_DOCUMENTS=new WeakMap;class T1{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 p1&&$.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}}T1.EXTENSION_NAME=void 0;var CT6={logger:z7.DEFAULT_INSTANCE,extensions:[],dependencies:{}},TT6=new Set([s.BUFFER,s.TEXTURE,s.MATERIAL,s.MESH,s.PRIMITIVE,s.NODE,s.SCENE]);var qH;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(qH||(qH={}));class SJ{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)=>iR1(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===QC.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=w4.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!==s.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}}SJ.BufferViewTarget=qH;SJ.BufferViewUsage=n5;SJ.USAGE_TO_TARGET={[n5.ARRAY_BUFFER]:qH.ARRAY_BUFFER,[n5.ELEMENT_ARRAY_BUFFER]:qH.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 iR1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{UNSIGNED_INT:ET6,UNSIGNED_SHORT:kT6,UNSIGNED_BYTE:IT6}=N0.ComponentType,vT6=new Set([s.ACCESSOR,s.BUFFER,s.MATERIAL,s.MESH]);var La;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(La||(La={}));var ja=163,Da=166;function nR1(){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 NK{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 AT6=new Uint8Array([0]),o6=[171,75,84,88,32,50,48,187,13,10,26,10];function Pa(Z){return new TextDecoder().decode(Z)}function xB(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,o6.length);if(J[0]!==o6[0]||J[1]!==o6[1]||J[2]!==o6[2]||J[3]!==o6[3]||J[4]!==o6[4]||J[5]!==o6[5]||J[6]!==o6[6]||J[7]!==o6[7]||J[8]!==o6[8]||J[9]!==o6[9]||J[10]!==o6[10]||J[11]!==o6[11])throw new Error("Missing KTX 2.0 identifier.");let X=nR1(),Y=17*Uint32Array.BYTES_PER_ELEMENT,$=new NK(Z,o6.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(),H=$._nextUint32(),z=$._nextUint64(),V=$._nextUint64(),F=Q*3*8,q=new NK(Z,o6.length+Y,F,!0);for(let z6=0;z6<Q;z6++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+q._nextUint64(),q._nextUint64()),uncompressedByteLength:q._nextUint64()});let U=new NK(Z,K,W,!0);U._skip(4);let B=U._nextUint16(),L=U._nextUint16(),w=U._nextUint16(),N=U._nextUint16(),R=U._nextUint8(),M=U._nextUint8(),D=U._nextUint8(),j=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()],A={vendorId:B,descriptorType:L,versionNumber:w,colorModel:R,colorPrimaries:M,transferFunction:D,flags:j,texelBlockDimension:C,bytesPlane:T,samples:[]},_=6,x=4,I=(N/4-_)/x;for(let z6=0;z6<I;z6++){let t7={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(t7.channelType&64)t7.sampleLower=U._nextInt32(),t7.sampleUpper=U._nextInt32();else t7.sampleLower=U._nextUint32(),t7.sampleUpper=U._nextUint32();A.samples[z6]=t7}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(A);let v=new NK(Z,G,H,!0);while(v._offset<H){let z6=v._nextUint32(),t7=v._scan(z6),Rq=Pa(t7);if(X.keyValue[Rq]=v._nextUint8Array(z6-t7.byteLength-1),Rq.match(/^ktx/i)){let iy=Pa(X.keyValue[Rq]);X.keyValue[Rq]=iy.substring(0,iy.lastIndexOf("\x00"))}let rW1=z6%4?4-z6%4:0;v._skip(rW1)}if(V<=0)return X;let y=new NK(Z,z,V,!0),p=y._nextUint16(),n=y._nextUint16(),o=y._nextUint32(),J0=y._nextUint32(),Q0=y._nextUint32(),D0=y._nextUint32(),C0=[];for(let z6=0;z6<Q;z6++)C0.push({imageFlags:y._nextUint32(),rgbSliceByteOffset:y._nextUint32(),rgbSliceByteLength:y._nextUint32(),alphaSliceByteOffset:y._nextUint32(),alphaSliceByteLength:y._nextUint32()});let a0=z+y._offset,E8=a0+o,i1=E8+J0,a4=i1+Q0,$4=new Uint8Array(Z.buffer,Z.byteOffset+a0,o),PQ=new Uint8Array(Z.buffer,Z.byteOffset+E8,J0),jQ=new Uint8Array(Z.buffer,Z.byteOffset+i1,Q0),oX=new Uint8Array(Z.buffer,Z.byteOffset+a4,D0);return X.globalData={endpointCount:p,selectorCount:n,imageDescs:C0,endpointsData:$4,selectorsData:PQ,tablesData:jQ,extendedData:oX},X}var DC="EXT_mesh_gpu_instancing",MC="EXT_meshopt_compression",aR1="EXT_texture_webp",sR1="EXT_texture_avif",ba="KHR_draco_mesh_compression",CC="KHR_lights_punctual",TC="KHR_materials_anisotropy",EC="KHR_materials_clearcoat",kC="KHR_materials_diffuse_transmission",IC="KHR_materials_dispersion",vC="KHR_materials_emissive_strength",_C="KHR_materials_ior",SC="KHR_materials_iridescence",AC="KHR_materials_pbrSpecularGlossiness",xC="KHR_materials_sheen",hC="KHR_materials_specular",fC="KHR_materials_transmission",yC="KHR_materials_unlit",bC="KHR_materials_volume",bY="KHR_materials_variants",oR1="KHR_mesh_quantization",rR1="KHR_texture_basisu",gC="KHR_texture_transform",hB="KHR_xmp_json_ld",PC="INSTANCE_ATTRIBUTE";class mC extends p1{init(){this.extensionName=DC,this.propertyType="InstancedMesh",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new a1})}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")}}mC.EXTENSION_NAME=DC;var DY=DC;class bB extends T1{constructor(...Z){super(...Z);this.extensionName=DY,this.provideTypes=[s.NODE],this.prewriteTypes=[s.ACCESSOR]}createInstancedMesh(){return new mC(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach((Y,$)=>{if(!Y.extensions||!Y.extensions[DY])return;let Q=Y.extensions[DY],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[$].setExtension(DY,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(DY);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[DY]=K}}),this}}bB.EXTENSION_NAME=DY;function BZ(){return BZ=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},BZ.apply(null,arguments)}var RH;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(RH||(RH={}));var MK;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(MK||(MK={}));var K8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})(K8||(K8={}));var{BYTE:tR1,SHORT:Ca,FLOAT:eR1}=N0.ComponentType,{encodeNormalizedInt:Ta,decodeNormalizedInt:jC}=Q8;function ZM1(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!==MK.ATTRIBUTES)return K;if($!==K8.NONE){let W=Z.getNormalized()?JM1(Z):new Float32Array(K.array);switch($){case K8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=eR1,K.normalized=!1,K.array=J.encodeFilterExp(W,Z.getCount(),K.byteStride,Q);break;case K8.OCTAHEDRAL:K.byteStride=Q>8?8:4,K.componentType=Q>8?Ca:tR1,K.normalized=!0,W=Z.getElementSize()===3?YM1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case K8.QUATERNION:K.byteStride=8,K.componentType=Ca,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)=>jC(G,Z.getComponentType())),K.max=K.max.map((G)=>jC(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>Ta(G,K.componentType)),K.max=K.max.map((G)=>Ta(G,K.componentType))}else if(K.byteStride%4)K.array=XM1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function JM1(Z){let J=Z.getComponentType(),X=Z.getArray(),Y=new Float32Array(X.length);for(let $=0;$<X.length;$++)Y[$]=jC(X[$],J);return Y}function XM1(Z,J){let Y=I6.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 YM1(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 $M1(Z,J){if(J===SJ.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some((Y)=>{return Y instanceof _J&&Y.getMode()===_J.Mode.TRIANGLES})?MK.TRIANGLES:MK.INDICES;return MK.ATTRIBUTES}function QM1(Z,J){let X=J.getGraph().listParentEdges(Z).filter((Y)=>!(Y.getParent()instanceof AB));for(let Y of X){let $=Y.getName(),Q=Y.getAttributes().key||"",K=Y.getParent().propertyType===s.PRIMITIVE_TARGET;if($==="indices")return{filter:K8.NONE};if($==="attributes"){if(Q==="POSITION")return{filter:K8.NONE};if(Q==="TEXCOORD_0")return{filter:K8.NONE};if(Q.startsWith("JOINTS_"))return{filter:K8.NONE};if(Q.startsWith("WEIGHTS_"))return{filter:K8.NONE};if(Q==="NORMAL"||Q==="TANGENT")return K?{filter:K8.NONE}:{filter:K8.OCTAHEDRAL,bits:8}}if($==="output"){let W=ga(Z);if(W==="rotation")return{filter:K8.QUATERNION,bits:16};if(W==="translation")return{filter:K8.EXPONENTIAL,bits:12};if(W==="scale")return{filter:K8.EXPONENTIAL,bits:12};return{filter:K8.NONE}}if($==="input")return{filter:K8.NONE};if($==="inverseBindMatrices")return{filter:K8.NONE}}return{filter:K8.NONE}}function ga(Z){for(let J of Z.listParents()){if(!(J instanceof OK))continue;for(let X of J.listParents()){if(!(X instanceof UH))continue;return X.getTargetPath()}}return null}function KM1(Z){if(!Z.extensions||!Z.extensions[MC])return!1;return!!Z.extensions[MC].fallback}var r6=MC,Ea={method:RH.QUANTIZE};class PH extends T1{constructor(...Z){super(...Z);this.extensionName=r6,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=Ea,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=BZ({},Ea,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${r6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${r6}]: 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[r6])return;let Q=Y.extensions[r6],K=Q.byteOffset||0,W=Q.byteLength||0,G=Q.count,H=Q.byteStride,z=new Uint8Array(G*H),V=J.json.buffers[Q.buffer],F=V.uri?J.resources[V.uri]:J.resources[FC],q=I6.toView(F,K,W);this._decoder.decodeGltfBuffer(z,G,H,q,Q.mode,Q.filter),Z.bufferViews[$]=z})}_prereadPrimitives(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach((Y)=>{if(!Y.extensions||!Y.extensions[r6])return;let $=Y.extensions[r6],Q=Z.buffers[$.buffer],K=Z.buffers[Y.buffer],W=J.json.buffers[Y.buffer];if(KM1(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,H=(z)=>{for(let V of $.listParents(z)){if(V.propertyType===s.ROOT)continue;let F=G.get(z);if(F===void 0)G.set(z,F=W++);return F}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let z of this.document.getRoot().listAccessors()){if(ga(z)==="weights")continue;if(z.getSparse())continue;let V=Z.getAccessorUsage(z),F=Z.accessorUsageGroupedByParent.has(V)?H(z):null,q=$M1(z,V),U=Y.method===RH.FILTER?QM1(z,this.document):{filter:K8.NONE},B=ZM1(z,X,q,U),{array:L,byteStride:w}=B,N=z.getBuffer();if(!N)throw new Error(`${r6}: Missing buffer for accessor.`);let R=this.document.getRoot().listBuffers().indexOf(N),M=[V,F,q,U.filter,w,R].join(":"),D=this._encoderBufferViews[M],j=this._encoderBufferViewData[M],C=this._encoderBufferViewAccessors[M];if(!D||!j)C=this._encoderBufferViewAccessors[M]=[],j=this._encoderBufferViewData[M]=[],D=this._encoderBufferViews[M]={buffer:K,target:SJ.USAGE_TO_TARGET[V],byteOffset:0,byteLength:0,byteStride:V===SJ.BufferViewUsage.ARRAY_BUFFER?w:void 0,extensions:{[r6]:{buffer:R,byteOffset:0,byteLength:0,mode:q,filter:U.filter!==K8.NONE?U.filter:void 0,byteStride:w,count:0}}};let T=Z.createAccessorDef(z);if(T.componentType=B.componentType,T.normalized=B.normalized,T.byteOffset=D.byteLength,T.min&&B.min)T.min=B.min;if(T.max&&B.max)T.max=B.max;Z.accessorIndexMap.set(z,J.accessors.length),J.accessors.push(T),C.push(T),j.push(new Uint8Array(L.buffer,L.byteOffset,L.byteLength)),D.byteLength+=L.byteLength,D.extensions.EXT_meshopt_compression.count+=z.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[r6].buffer],K=Z.otherBufferViews.get(Q)||[],{count:W,byteStride:G,mode:H}=Y.extensions[r6],z=I6.concat($),V=J.encodeGltfBuffer(z,W,G,H),F=I6.pad(V);Y.extensions[r6].byteLength=V.byteLength,$.length=0,$.push(F),K.push(F),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),H=this._encoderBufferViewAccessors[Q];for(let q of H)q.bufferView=G;let z=Z.jsonDoc.json.bufferViews[G],V=z.byteOffset||0;Object.assign(z,K),z.byteOffset=J;let F=z.extensions[r6];F.byteOffset=V,J+=I6.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,Y=Z.bufferIndexMap.get(X),$=Z.jsonDoc.json.buffers[Y];return $.byteLength=J,$.extensions={[r6]:{fallback:!0}},X.dispose(),this}}PH.EXTENSION_NAME=r6;PH.EncoderMethod=RH;var wH=sR1;class ma{match(Z){return Z.length>=12&&I6.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=ka(J,0);if(!X)return null;let Y=X.end;while(X=ka(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 gB extends T1{constructor(...Z){super(...Z);this.extensionName=wH,this.prereadTypes=[s.TEXTURE]}static register(){w4.registerFormat("image/avif",new ma)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[wH])X.source=X.extensions[wH].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[wH]={source:Q.source},delete Q.source})}}),this}}gB.EXTENSION_NAME=wH;function ka(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:I6.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}var OH=aR1;class ua{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=I6.decodeText(Z.slice(0,4)),X=I6.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=I6.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),H=Y.getUint8($+11),z=Y.getUint8($+12),V=1+((G&63)<<8|W),F=1+((z&15)<<10|H<<2|(G&192)>>6);return[V,F]}$+=8+K+K%2}return null}getChannels(Z){return 4}}class mB extends T1{constructor(...Z){super(...Z);this.extensionName=OH,this.prereadTypes=[s.TEXTURE]}static register(){w4.registerFormat("image/webp",new ua)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[OH])X.source=X.extensions[OH].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[OH]={source:Q.source},delete Q.source})}}),this}}mB.EXTENSION_NAME=OH;var Ia=ba,g8,da,la;function WM1(Z,J){let X=new g8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==g8.TRIANGULAR_MESH)throw new Error(`[${Ia}] Unknown geometry type.`);let $=new g8.Mesh;if(!Z.DecodeBufferToMesh(X,$).ok()||$.ptr===0)throw new Error(`[${Ia}] Decoding failure.`);return $}finally{g8.destroy(X)}}function GM1(Z,J){let Y=J.num_faces()*3,$,Q;if(J.num_points()<=65534){let K=Y*Uint16Array.BYTES_PER_ELEMENT;$=g8._malloc(K),Z.GetTrianglesUInt16Array(J,K,$),Q=new Uint16Array(g8.HEAPU16.buffer,$,Y).slice()}else{let K=Y*Uint32Array.BYTES_PER_ELEMENT;$=g8._malloc(K),Z.GetTrianglesUInt32Array(J,K,$),Q=new Uint32Array(g8.HEAPU32.buffer,$,Y).slice()}return g8._free($),Q}function HM1(Z,J,X,Y){let $=la[Y.componentType],Q=da[Y.componentType],K=X.num_components(),G=J.num_points()*K,H=G*Q.BYTES_PER_ELEMENT,z=g8._malloc(H);Z.GetAttributeDataArrayForAllPoints(J,X,$,H,z);let V=new Q(g8.HEAPF32.buffer,z,G).slice();return g8._free(z),V}function zM1(Z){g8=Z,da={[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},la={[N0.ComponentType.FLOAT]:g8.DT_FLOAT32,[N0.ComponentType.UNSIGNED_INT]:g8.DT_UINT32,[N0.ComponentType.UNSIGNED_SHORT]:g8.DT_UINT16,[N0.ComponentType.UNSIGNED_BYTE]:g8.DT_UINT8,[N0.ComponentType.SHORT]:g8.DT_INT16,[N0.ComponentType.BYTE]:g8.DT_INT8}}var C9,MH;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(MH||(MH={}));var T9;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(T9||(T9={}));var ca={[T9.POSITION]:14,[T9.NORMAL]:10,[T9.COLOR]:8,[T9.TEX_COORD]:12,[T9.GENERIC]:12},va={decodeSpeed:5,encodeSpeed:5,method:MH.EDGEBREAKER,quantizationBits:ca,quantizationVolume:"mesh"};function FM1(Z){C9=Z}function VM1(Z,J=va){let X=BZ({},va,J);X.quantizationBits=BZ({},ca,J.quantizationBits);let Y=new C9.MeshBuilder,$=new C9.Mesh,Q=new C9.ExpertEncoder($),K={},W=new C9.DracoInt8Array,G=Z.listTargets().length>0,H=!1;for(let B of Z.listSemantics()){let L=Z.getAttribute(B);if(L.getSparse()){H=!0;continue}let w=qM1(B),N=UM1(Y,L.getComponentType(),$,C9[w],L.getCount(),L.getElementSize(),L.getArray());if(N===-1)throw new Error(`Error compressing "${B}" attribute.`);if(K[B]=N,X.quantizationVolume==="mesh"||B!=="POSITION")Q.SetAttributeQuantization(N,X.quantizationBits[w]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:R}=X,M=Math.max(R.max[0]-R.min[0],R.max[1]-R.min[1],R.max[2]-R.min[2]);Q.SetAttributeExplicitQuantization(N,X.quantizationBits[w],L.getElementSize(),R.min,M)}else throw new Error("Invalid quantization volume state.")}let z=Z.getIndices();if(!z)throw new fB("Primitive must have indices.");if(Y.AddFacesToMesh($,z.getCount()/3,z.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===MH.SEQUENTIAL||G||H)Q.SetEncodingMethod(C9.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(C9.MESH_EDGEBREAKER_ENCODING);let V=Q.EncodeToDracoBuffer(!(G||H),W);if(V<=0)throw new fB("Error applying Draco compression.");let F=new Uint8Array(V);for(let B=0;B<V;++B)F[B]=W.GetValue(B);let q=Q.GetNumberOfEncodedPoints(),U=Q.GetNumberOfEncodedFaces()*3;return C9.destroy(W),C9.destroy($),C9.destroy(Y),C9.destroy(Q),{numVertices:q,numIndices:U,data:F,attributeIDs:K}}function qM1(Z){if(Z==="POSITION")return T9.POSITION;else if(Z==="NORMAL")return T9.NORMAL;else if(Z.startsWith("COLOR_"))return T9.COLOR;else if(Z.startsWith("TEXCOORD_"))return T9.TEX_COORD;return T9.GENERIC}function UM1(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 fB extends Error{}var N8=ba;class jH extends T1{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,zM1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,FM1(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,H]=Y.get(W.bufferView)||[];if(!H||!G){let z=X.json.bufferViews[W.bufferView],V=X.json.buffers[z.buffer],F=V.uri?X.resources[V.uri]:X.resources[FC],q=z.byteOffset||0,U=z.byteLength,B=I6.toView(F,q,U);G=new this._decoderModule.Decoder,H=WM1(G,B),Y.set(W.bufferView,[G,H]),J.debug(`[${N8}] Decompressed ${B.byteLength} bytes.`)}for(let z in W.attributes){let V=Z.jsonDoc.json.accessors[K.attributes[z]],F=G.GetAttributeByUniqueId(H,W.attributes[z]),q=HM1(G,H,F,V);Z.accessors[K.attributes[z]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(GM1(G,H))}}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=LM1(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=Ba(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(),H=Z.jsonDoc.json.accessors,z;try{z=VM1(K,BZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof fB){X.warn(`[${N8}]: ${q.message} Skipping primitive compression.`);continue}throw q}$.set(W,z);let V=Z.createAccessorDef(G);if(V.count=z.numIndices,Z.accessorIndexMap.set(G,H.length),H.push(V),z.numVertices>65534&&N0.getComponentSize(V.componentType)<=2)V.componentType=N0.ComponentType.UNSIGNED_INT;else if(z.numVertices>254&&N0.getComponentSize(V.componentType)<=1)V.componentType=N0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let U=K.getAttribute(q);if(z.attributeIDs[q]===void 0)continue;let B=Z.createAccessorDef(U);B.count=z.numVertices,Z.accessorIndexMap.set(U,H.length),H.push(B)}let F=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(F))Z.otherBufferViews.set(F,[]);Z.otherBufferViews.get(F).push(z.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}}jH.EXTENSION_NAME=N8;jH.EncoderMethod=MH;function LM1(Z){let J=Z.getLogger(),X=new Set,Y=new Set,$=0,Q=0;for(let V of Z.getRoot().listMeshes())for(let F of V.listPrimitives())if(!F.getIndices())Y.add(F),$++;else if(F.getMode()!==_J.Mode.TRIANGLES)Y.add(F),Q++;else X.add(F);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 V=0;V<K.length;V++)W.set(K[V],V);let G=new Map,H=new Set,z=new Map;for(let V of Array.from(X)){let F=_a(V,W);if(H.has(F)){z.set(V,F);continue}if(G.has(V.getIndices())){let q=V.getIndices(),U=q.clone();W.set(U,Z.getRoot().listAccessors().length-1),V.swap(q,U)}for(let q of V.listAttributes())if(G.has(q)){let U=q.clone();W.set(U,Z.getRoot().listAccessors().length-1),V.swap(q,U)}F=_a(V,W),H.add(F),z.set(V,F),G.set(V.getIndices(),F);for(let q of V.listAttributes())G.set(q,F)}for(let V of Array.from(G.keys())){let F=new Set(V.listParents().map((q)=>q.propertyType));if(F.size!==2||!F.has(s.PRIMITIVE)||!F.has(s.ROOT))throw new Error(`[${N8}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let V of Array.from(X)){let F=z.get(V),q=V.getIndices();if(G.get(q)!==F||V.listAttributes().some((U)=>G.get(U)!==F))throw new Error(`[${N8}] Draco primitives must share all, or no, accessors.`)}for(let V of Array.from(Y)){let F=V.getIndices();if(G.has(F)||V.listAttributes().some((q)=>G.has(q)))throw new Error(`[${N8}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return z}function _a(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 PK extends p1{init(){this.extensionName=CC,this.propertyType="Light",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:PK.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)}}PK.EXTENSION_NAME=CC;PK.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};var F7=CC;class uC extends T1{constructor(...Z){super(...Z);this.extensionName=F7}createLight(Z=""){return new PK(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[F7])return this;let $=(J.json.extensions[F7].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[F7])return;let W=Q.extensions[F7];Z.nodes[K].setExtension(F7,$[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(!Q8.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()===PK.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(F7);if(Q){let K=Z.nodeIndexMap.get($),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[F7]={light:Y.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[F7]={lights:X},this}}uC.EXTENSION_NAME=F7;var{R:BM1,G:wM1,B:OM1}=a5;class dC extends p1{init(){this.extensionName=TC,this.propertyType="Anisotropy",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new P1(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:BM1|wM1|OM1})}}dC.EXTENSION_NAME=TC;var CY=TC;class lC extends T1{constructor(...Z){super(...Z);this.extensionName=CY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createAnisotropy(){return new dC(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[CY]){let K=this.createAnisotropy();Z.materials[Q].setExtension(CY,K);let W=$.extensions[CY];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,H=Z.textures[Y[G.index].source];K.setAnisotropyTexture(H),Z.setTextureInfo(K.getAnisotropyTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(CY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[CY]={};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=CY;var{R:Sa,G:Aa,B:NM1}=a5;class cC extends p1{init(){this.extensionName=EC,this.propertyType="Clearcoat",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new P1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new P1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new P1(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:Sa})}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:Aa})}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:Sa|Aa|NM1})}}cC.EXTENSION_NAME=EC;var TY=EC;class pC extends T1{constructor(...Z){super(...Z);this.extensionName=TY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createClearcoat(){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[TY]){let K=this.createClearcoat();Z.materials[Q].setExtension(TY,K);let W=$.extensions[TY];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,H=Z.textures[Y[G.index].source];K.setClearcoatTexture(H),Z.setTextureInfo(K.getClearcoatTextureInfo(),G)}if(W.clearcoatRoughnessTexture!==void 0){let G=W.clearcoatRoughnessTexture,H=Z.textures[Y[G.index].source];K.setClearcoatRoughnessTexture(H),Z.setTextureInfo(K.getClearcoatRoughnessTextureInfo(),G)}if(W.clearcoatNormalTexture!==void 0){let G=W.clearcoatNormalTexture,H=Z.textures[Y[G.index].source];if(K.setClearcoatNormalTexture(H),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(TY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[TY]={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}}pC.EXTENSION_NAME=TY;var{R:RM1,G:MM1,B:PM1,A:jM1}=a5;class iC extends p1{init(){this.extensionName=kC,this.propertyType="DiffuseTransmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new P1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new P1(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:jM1})}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:RM1|MM1|PM1})}}iC.EXTENSION_NAME=kC;var EY=kC;class nC extends T1{constructor(...Z){super(...Z);this.extensionName=EY}createDiffuseTransmission(){return new iC(this.document.getGraph())}read(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[EY]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(EY,K);let W=$.extensions[EY];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,H=Z.textures[Y[G.index].source];K.setDiffuseTransmissionTexture(H),Z.setTextureInfo(K.getDiffuseTransmissionTextureInfo(),G)}if(W.diffuseTransmissionColorTexture!==void 0){let G=W.diffuseTransmissionColorTexture,H=Z.textures[Y[G.index].source];K.setDiffuseTransmissionColorTexture(H),Z.setTextureInfo(K.getDiffuseTransmissionColorTextureInfo(),G)}}}),this}write(Z){let J=Z.jsonDoc;for(let X of this.document.getRoot().listMaterials()){let Y=X.getExtension(EY);if(!Y)continue;let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[EY]={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}}nC.EXTENSION_NAME=EY;class aC extends p1{init(){this.extensionName=IC,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)}}aC.EXTENSION_NAME=IC;var kY=IC;class sC extends T1{constructor(...Z){super(...Z);this.extensionName=kY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createDispersion(){return new aC(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[kY]){let Q=this.createDispersion();Z.materials[$].setExtension(kY,Q);let K=Y.extensions[kY];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(kY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[kY]={dispersion:Y.getDispersion()}}}),this}}sC.EXTENSION_NAME=kY;class oC extends p1{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)}}oC.EXTENSION_NAME=vC;var IY=vC;class rC extends T1{constructor(...Z){super(...Z);this.extensionName=IY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createEmissiveStrength(){return new oC(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[IY]){let Q=this.createEmissiveStrength();Z.materials[$].setExtension(IY,Q);let K=Y.extensions[IY];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(IY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[IY]={emissiveStrength:Y.getEmissiveStrength()}}}),this}}rC.EXTENSION_NAME=IY;class tC extends p1{init(){this.extensionName=_C,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)}}tC.EXTENSION_NAME=_C;var vY=_C;class uB extends T1{constructor(...Z){super(...Z);this.extensionName=vY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIOR(){return new tC(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.createIOR();Z.materials[$].setExtension(vY,Q);let K=Y.extensions[vY];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(vY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[vY]={ior:Y.getIOR()}}}),this}}uB.EXTENSION_NAME=vY;var{R:DM1,G:CM1}=a5;class eC extends p1{init(){this.extensionName=SC,this.propertyType="Iridescence",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new P1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new P1(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:DM1})}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:CM1})}}eC.EXTENSION_NAME=SC;var _Y=SC;class ZT extends T1{constructor(...Z){super(...Z);this.extensionName=_Y,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIridescence(){return new eC(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[_Y]){let K=this.createIridescence();Z.materials[Q].setExtension(_Y,K);let W=$.extensions[_Y];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,H=Z.textures[Y[G.index].source];K.setIridescenceTexture(H),Z.setTextureInfo(K.getIridescenceTextureInfo(),G)}if(W.iridescenceThicknessTexture!==void 0){let G=W.iridescenceThicknessTexture,H=Z.textures[Y[G.index].source];K.setIridescenceThicknessTexture(H),Z.setTextureInfo(K.getIridescenceThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(_Y);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[_Y]={};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}}ZT.EXTENSION_NAME=_Y;var{R:xa,G:ha,B:fa,A:ya}=a5;class JT extends p1{init(){this.extensionName=AC,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new P1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new P1(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:xa|ha|fa|ya,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:xa|ha|fa|ya})}}JT.EXTENSION_NAME=AC;var SY=AC;class dB extends T1{constructor(...Z){super(...Z);this.extensionName=SY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createPBRSpecularGlossiness(){return new JT(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[SY]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(SY,K);let W=$.extensions[SY];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,H=Z.textures[Y[G.index].source];K.setDiffuseTexture(H),Z.setTextureInfo(K.getDiffuseTextureInfo(),G)}if(W.specularGlossinessTexture!==void 0){let G=W.specularGlossinessTexture,H=Z.textures[Y[G.index].source];K.setSpecularGlossinessTexture(H),Z.setTextureInfo(K.getSpecularGlossinessTextureInfo(),G)}}}),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||{};let K=Q.extensions[SY]={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}}dB.EXTENSION_NAME=SY;var{R:TM1,G:EM1,B:kM1,A:IM1}=a5;class XT extends p1{init(){this.extensionName=xC,this.propertyType="Sheen",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new P1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new P1(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:TM1|EM1|kM1,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:IM1})}}XT.EXTENSION_NAME=xC;var AY=xC;class YT extends T1{constructor(...Z){super(...Z);this.extensionName=AY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSheen(){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[AY]){let K=this.createSheen();Z.materials[Q].setExtension(AY,K);let W=$.extensions[AY];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,H=Z.textures[Y[G.index].source];K.setSheenColorTexture(H),Z.setTextureInfo(K.getSheenColorTextureInfo(),G)}if(W.sheenRoughnessTexture!==void 0){let G=W.sheenRoughnessTexture,H=Z.textures[Y[G.index].source];K.setSheenRoughnessTexture(H),Z.setTextureInfo(K.getSheenRoughnessTextureInfo(),G)}}}),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||{};let K=Q.extensions[AY]={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}}YT.EXTENSION_NAME=AY;var{R:vM1,G:_M1,B:SM1,A:AM1}=a5;class $T extends p1{init(){this.extensionName=hC,this.propertyType="Specular",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new P1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new P1(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:AM1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:vM1|_M1|SM1,isColor:!0})}}$T.EXTENSION_NAME=hC;var xY=hC;class lB extends T1{constructor(...Z){super(...Z);this.extensionName=xY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSpecular(){return new $T(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.createSpecular();Z.materials[Q].setExtension(xY,K);let W=$.extensions[xY];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,H=Z.textures[Y[G.index].source];K.setSpecularTexture(H),Z.setTextureInfo(K.getSpecularTextureInfo(),G)}if(W.specularColorTexture!==void 0){let G=W.specularColorTexture,H=Z.textures[Y[G.index].source];K.setSpecularColorTexture(H),Z.setTextureInfo(K.getSpecularColorTextureInfo(),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.getSpecularFactor()!==1)K.specularFactor=Y.getSpecularFactor();if(!Q8.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}}lB.EXTENSION_NAME=xY;var{R:xM1}=a5;class QT extends p1{init(){this.extensionName=fC,this.propertyType="Transmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new P1(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:xM1})}}QT.EXTENSION_NAME=fC;var hY=fC;class KT extends T1{constructor(...Z){super(...Z);this.extensionName=hY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createTransmission(){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[hY]){let K=this.createTransmission();Z.materials[Q].setExtension(hY,K);let W=$.extensions[hY];if(W.transmissionFactor!==void 0)K.setTransmissionFactor(W.transmissionFactor);if(W.transmissionTexture!==void 0){let G=W.transmissionTexture,H=Z.textures[Y[G.index].source];K.setTransmissionTexture(H),Z.setTextureInfo(K.getTransmissionTextureInfo(),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]={transmissionFactor:Y.getTransmissionFactor()};if(Y.getTransmissionTexture()){let W=Y.getTransmissionTexture(),G=Y.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(W,G)}}}),this}}KT.EXTENSION_NAME=hY;class WT extends p1{init(){this.extensionName=yC,this.propertyType="Unlit",this.parentTypes=[s.MATERIAL]}}WT.EXTENSION_NAME=yC;var RK=yC;class cB extends T1{constructor(...Z){super(...Z);this.extensionName=RK,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createUnlit(){return new WT(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[RK])Z.materials[Y].setExtension(RK,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(RK)){let Y=Z.materialIndexMap.get(X),$=J.json.materials[Y];$.extensions=$.extensions||{},$.extensions[RK]={}}}),this}}cB.EXTENSION_NAME=RK;class GT extends p1{init(){this.extensionName=bY,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new P0})}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")}}GT.EXTENSION_NAME=bY;class HT extends p1{init(){this.extensionName=bY,this.propertyType="MappingList",this.parentTypes=[s.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new P0})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}HT.EXTENSION_NAME=bY;class yB extends p1{init(){this.extensionName=bY,this.propertyType="Variant",this.parentTypes=["MappingList"]}}yB.EXTENSION_NAME=bY;var V7=bY;class zT extends T1{constructor(...Z){super(...Z);this.extensionName=V7}createMappingList(){return new HT(this.document.getGraph())}createVariant(Z=""){return new yB(this.document.getGraph(),Z)}createMapping(){return new GT(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof yB)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[V7])return this;let $=(J.json.extensions[V7].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,W)=>{let G=Z.meshes[W];(K.primitives||[]).forEach((z,V)=>{if(!z.extensions||!z.extensions[V7])return;let F=this.createMappingList(),q=z.extensions[V7];for(let U of q.mappings){let B=this.createMapping();if(U.material!==void 0)B.setMaterial(Z.materials[U.material]);for(let L of U.variants||[])B.addVariant($[L]);F.addMapping(B)}G.listPrimitives()[V].setExtension(V7,F)})}),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 H=W.getExtension(V7);if(!H)return;let z=Z.jsonDoc.json.meshes[K].primitives[G],V=H.listMappings().map((F)=>{let q=Z.createPropertyDef(F),U=F.getMaterial();if(U)q.material=Z.materialIndexMap.get(U);return q.variants=F.listVariants().map((B)=>$.get(B)),q});z.extensions=z.extensions||{},z.extensions[V7]={mappings:V}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[V7]={variants:Y},this}}zT.EXTENSION_NAME=V7;var{G:hM1}=a5;class FT extends p1{init(){this.extensionName=bC,this.propertyType="Volume",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new P1(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:hM1})}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=bC;var fY=bC;class VT extends T1{constructor(...Z){super(...Z);this.extensionName=fY,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[fY]){let K=this.createVolume();Z.materials[Q].setExtension(fY,K);let W=$.extensions[fY];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,H=Z.textures[Y[G.index].source];K.setThicknessTexture(H),Z.setTextureInfo(K.getThicknessTextureInfo(),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]={};if(Y.getThicknessFactor()>0)K.thicknessFactor=Y.getThicknessFactor();if(Number.isFinite(Y.getAttenuationDistance()))K.attenuationDistance=Y.getAttenuationDistance();if(!Q8.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}}VT.EXTENSION_NAME=fY;var pa=oR1;class DH extends T1{constructor(...Z){super(...Z);this.extensionName=pa}read(Z){return this}write(Z){return this}}DH.EXTENSION_NAME=pa;var NH=rR1;class ia{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=xB(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=xB(Z).dataFormatDescriptor[0];if(X.colorModel===ja)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===Da)return(X.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=xB(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 qT extends T1{constructor(...Z){super(...Z);this.extensionName=NH,this.prereadTypes=[s.TEXTURE]}static register(){w4.registerFormat("image/ktx2",new ia)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[NH]){let X=J.extensions[NH];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[NH]={source:$.source},delete $.source})}}),this}}qT.EXTENSION_NAME=NH;class UT extends p1{init(){this.extensionName=gC,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)}}UT.EXTENSION_NAME=gC;var yY=gC;class LT extends T1{constructor(...Z){super(...Z);this.extensionName=yY}createTransform(){return new UT(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[yY])continue;let Y=this.createTransform(),$=X.extensions[yY];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(yY,Y)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,Y]of J){let $=X.getExtension(yY);if(!$)continue;Y.extensions=Y.extensions||{};let Q={},K=Q8.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[yY]=Q}return this}}LT.EXTENSION_NAME=yY;var fM1=[s.ROOT,s.SCENE,s.NODE,s.MESH,s.MATERIAL,s.TEXTURE,s.ANIMATION];class BT extends p1{init(){this.extensionName=hB,this.propertyType="Packet",this.parentTypes=fM1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",BZ({},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=BZ({},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 BZ({"@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(`${hB}: Missing context for term, "${Z}".`)}}BT.EXTENSION_NAME=hB;function RC(Z){return JSON.parse(JSON.stringify(Z))}var LZ=hB;class wT extends T1{constructor(...Z){super(...Z);this.extensionName=LZ}createPacket(){return new BT(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[LZ];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 H=K[G]||[];for(let z=0;z<H.length;z++){let V=H[z];if(V.extensions&&V.extensions[LZ]){let F=V.extensions[LZ];W[G][z].setExtension(LZ,Q[F.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(`[${LZ}]: Unsupported parent property, "${$.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[LZ]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[LZ]={packets:X};return this}}wT.EXTENSION_NAME=LZ;var yM1=[jH,uC,lC,pC,nC,sC,rC,uB,ZT,dB,lB,YT,KT,cB,zT,VT,DH,qT,LT,wT],yT6=[bB,PH,gB,mB,...yM1];var bM1=r(AD(),1);function CK(){return CK=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},CK.apply(null,arguments)}var{POINTS:na,LINES:pB,LINE_STRIP:gM1,LINE_LOOP:mM1,TRIANGLES:iB,TRIANGLE_STRIP:uM1,TRIANGLE_FAN:dM1}=w8.Mode;function fJ(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function q7(Z,J){let X=CK({},Z);for(let Y in J)if(J[Y]!==void 0)X[Y]=J[Y];return X}function qs(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case w8.Mode.POINTS:return J?J.getCount():X.getCount();case w8.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case w8.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case w8.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case w8.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case w8.Mode.TRIANGLE_STRIP:case w8.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw new Error("Unexpected mode: "+Z.getMode())}}var lM1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function MT(Z){return lM1.format(Z)}function cM1(Z,J,X=2){let Y=Z>J?"–":"+",$="%";return Y+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function rB(Z,J){return`${MT(Z)} → ${MT(J)} (${cM1(Z,J)})`}function kT(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 pM1(Z,J,X){Z.swap(J,X);for(let Y of Z.listTargets())Y.swap(J,X)}function iM1(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 wZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function nM1(Z,J=Z){let X=IT(Z,J);for(let Y=0;Y<X.length;Y++)X[Y]=Y;return X}function IT(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function aM1(Z){return Z.listParents().some((J)=>J.propertyType!==a.ROOT)}function Us(Z){for(let J in Z)return!1;return!0}function Ls(Z){let J=E6.fromGraph(Z.getGraph()),X=Z.getMaterial(),Y=J.getRoot().listMaterials().indexOf(X),$=oM1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((G)=>{let H=Z.getAttribute(G),z=H.getElementSize(),V=H.getComponentType();return`${G}:${z}:${V}`}).join("+"),W=Z.listTargets().map((G)=>{return G.listSemantics().sort().map((H)=>{let z=Z.getAttribute(H),V=z.getElementSize(),F=z.getComponentType();return`${H}:${V}:${F}`}).join("+")}).join("~");return`${Y}|${$}|${Q}|${K}|${W}`}function sM1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var oM1={[na]:na,[pB]:pB,[gM1]:pB,[mM1]:pB,[iB]:iB,[uM1]:iB,[dM1]:iB},jK="center",aa={pivot:"center"};function Bs(Z=aa){let J=q7(aa,Z);return fJ(jK,(X)=>{let Y=X.getLogger(),$=X.getRoot(),Q=$.listAnimations().length>0||$.listSkins().length>0;X.getRoot().listScenes().forEach((K,W)=>{Y.debug(`${jK}: Scene ${W+1} / ${$.listScenes().length}.`);let G;if(typeof J.pivot==="string"){let z=TD(K);if(G=[(z.max[0]-z.min[0])/2+z.min[0],(z.max[1]-z.min[1])/2+z.min[1],(z.max[2]-z.min[2])/2+z.min[2]],J.pivot==="above")G[1]=z.max[1];if(J.pivot==="below")G[1]=z.min[1]}else G=J.pivot;Y.debug(`${jK}: Pivot "${G.join(", ")}".`);let H=[-1*G[0],-1*G[1],-1*G[2]];if(Q){Y.debug(`${jK}: Model contains animation or skin. Adding a wrapper node.`);let z=X.createNode("Pivot").setTranslation(H);K.listChildren().forEach((V)=>z.addChild(V)),K.addChild(z)}else Y.debug(`${jK}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((z)=>{let V=z.getTranslation();z.setTranslation([V[0]+H[0],V[1]+H[1],V[2]+H[2]])})}),Y.debug(`${jK}: Complete.`)})}function rM1(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 GK)}function tM1(Z){let J=rM1(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 TK=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 eM1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],H=J[7],z=J[8],V=J[9],F=J[10],q=J[11],U=J[12],B=J[13],L=J[14],w=J[15],N=X*W-Y*K,R=X*G-$*K,M=X*H-Q*K,D=Y*G-$*W,j=Y*H-Q*W,C=$*H-Q*G,T=z*B-V*U,E=z*L-F*U,A=z*w-q*U,_=V*L-F*B,x=V*w-q*B,I=F*w-q*L,v=N*I-R*x+M*_+D*A-j*E+C*T;if(!v)return null;return v=1/v,Z[0]=(W*I-G*x+H*_)*v,Z[1]=($*x-Y*I-Q*_)*v,Z[2]=(B*C-L*j+w*D)*v,Z[3]=(F*j-V*C-q*D)*v,Z[4]=(G*A-K*I-H*E)*v,Z[5]=(X*I-$*A+Q*E)*v,Z[6]=(L*M-U*C-w*R)*v,Z[7]=(z*C-F*M+q*R)*v,Z[8]=(K*x-W*A+H*T)*v,Z[9]=(Y*A-X*x-Q*T)*v,Z[10]=(U*j-B*M+w*N)*v,Z[11]=(V*M-z*j-q*N)*v,Z[12]=(W*E-K*_-G*T)*v,Z[13]=(X*_-Y*E+$*T)*v,Z[14]=(B*R-U*D-L*N)*v,Z[15]=(z*D-V*R+F*N)*v,Z}function ZP1(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],H=Z[8],z=Z[9],V=Z[10],F=Z[11],q=Z[12],U=Z[13],B=Z[14],L=Z[15],w=J*K-X*Q,N=J*W-Y*Q,R=J*G-$*Q,M=X*W-Y*K,D=X*G-$*K,j=Y*G-$*W,C=H*U-z*q,T=H*B-V*q,E=H*L-F*q,A=z*B-V*U,_=z*L-F*U,x=V*L-F*B;return w*x-N*_+R*A+M*E-D*T+j*C}function ws(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],H=J[6],z=J[7],V=J[8],F=J[9],q=J[10],U=J[11],B=J[12],L=J[13],w=J[14],N=J[15],R=X[0],M=X[1],D=X[2],j=X[3];return Z[0]=R*Y+M*W+D*V+j*B,Z[1]=R*$+M*G+D*F+j*L,Z[2]=R*Q+M*H+D*q+j*w,Z[3]=R*K+M*z+D*U+j*N,R=X[4],M=X[5],D=X[6],j=X[7],Z[4]=R*Y+M*W+D*V+j*B,Z[5]=R*$+M*G+D*F+j*L,Z[6]=R*Q+M*H+D*q+j*w,Z[7]=R*K+M*z+D*U+j*N,R=X[8],M=X[9],D=X[10],j=X[11],Z[8]=R*Y+M*W+D*V+j*B,Z[9]=R*$+M*G+D*F+j*L,Z[10]=R*Q+M*H+D*q+j*w,Z[11]=R*K+M*z+D*U+j*N,R=X[12],M=X[13],D=X[14],j=X[15],Z[12]=R*Y+M*W+D*V+j*B,Z[13]=R*$+M*G+D*F+j*L,Z[14]=R*Q+M*H+D*q+j*w,Z[15]=R*K+M*z+D*U+j*N,Z}function JP1(){var Z=new TK(9);if(TK!=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 XP1(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 YP1(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 $P1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],H=J[7],z=J[8],V=z*K-W*H,F=-z*Q+W*G,q=H*Q-K*G,U=X*V+Y*F+$*q;if(!U)return null;return U=1/U,Z[0]=V*U,Z[1]=(-z*Y+$*H)*U,Z[2]=(W*Y-$*K)*U,Z[3]=F*U,Z[4]=(z*X-$*G)*U,Z[5]=(-W*X+$*Q)*U,Z[6]=q*U,Z[7]=(-H*X+Y*G)*U,Z[8]=(K*X-Y*Q)*U,Z}function tB(){var Z=new TK(3);if(TK!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function QP1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function Os(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 KP1(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 WP1(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 GP1=QP1;(function(){var Z=tB();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 xJ="dedup",OT={keepUniqueNames:!1,propertyTypes:[a.ACCESSOR,a.MESH,a.TEXTURE,a.MATERIAL,a.SKIN]};function Ns(Z=OT){let J=q7(OT,Z),X=new Set(J.propertyTypes);for(let Y of J.propertyTypes)if(!OT.propertyTypes.includes(Y))throw new Error(`${xJ}: Unsupported deduplication on type "${Y}".`);return fJ(xJ,(Y)=>{let $=Y.getLogger();if(X.has(a.ACCESSOR))HP1(Y);if(X.has(a.TEXTURE))FP1(Y,J);if(X.has(a.MATERIAL))VP1(Y,J);if(X.has(a.MESH))zP1(Y,J);if(X.has(a.SKIN))qP1(Y,J);$.debug(`${xJ}: Complete.`)})}function HP1(Z){let J=Z.getLogger(),X=new Map,Y=new Map,$=new Map,Q=new Map,K=Z.getRoot().listMeshes();K.forEach((V)=>{V.listPrimitives().forEach((F)=>{F.listAttributes().forEach((q)=>W(q,Y)),W(F.getIndices(),X)})});for(let V of Z.getRoot().listAnimations())for(let F of V.listSamplers())W(F.getInput(),$),W(F.getOutput(),Q);function W(V,F){if(!V)return;let q=[V.getCount(),V.getType(),V.getComponentType(),V.getNormalized(),V.getSparse()].join(":"),U=F.get(q);if(!U)F.set(q,U=new Set);U.add(V)}function G(V,F){for(let q=0;q<V.length;q++){let U=V[q],B=n0.toView(U.getArray());if(F.has(U))continue;for(let L=q+1;L<V.length;L++){let w=V[L];if(F.has(w))continue;if(n0.equals(B,n0.toView(w.getArray())))F.set(w,U)}}}let H=0,z=new Map;for(let V of[Y,X,$,Q])for(let F of V.values())H+=F.size,G(Array.from(F),z);J.debug(`${xJ}: Merged ${z.size} of ${H} accessors.`),K.forEach((V)=>{V.listPrimitives().forEach((F)=>{F.listAttributes().forEach((U)=>{if(z.has(U))F.swap(U,z.get(U))});let q=F.getIndices();if(q&&z.has(q))F.swap(q,z.get(q))})});for(let V of Z.getRoot().listAnimations())for(let F of V.listSamplers()){let q=F.getInput(),U=F.getOutput();if(q&&z.has(q))F.swap(q,z.get(q));if(U&&z.has(U))F.swap(U,z.get(U))}Array.from(z.keys()).forEach((V)=>V.dispose())}function zP1(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 z of W.listPrimitives())G.push(Rs(z,$));let H="";if(J.keepUniqueNames)H+=W.getName()+";";if(H+=G.join(";"),K.has(H)){let z=K.get(H);W.listParents().forEach((V)=>{if(V.propertyType!==a.ROOT)V.swap(W,z)}),W.dispose()}else K.set(H,W)}X.debug(`${xJ}: Merged ${Q-K.size} of ${Q} meshes.`)}function FP1(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 H=K+1;H<$.length;H++){let z=$[H],V=z.getImage();if(Q.has(z))continue;if(W.getMimeType()!==z.getMimeType())continue;if(J.keepUniqueNames&&W.getName()!==z.getName())continue;let F=W.getSize(),q=z.getSize();if(!F||!q)continue;if(F[0]!==q[0])continue;if(F[1]!==q[1])continue;if(!G||!V)continue;if(n0.equals(G,V))Q.set(z,W)}}X.debug(`${xJ}: Merged ${Q.size} of ${Y.listTextures().length} textures.`),Array.from(Q.entries()).forEach(([K,W])=>{K.listParents().forEach((G)=>{if(!(G instanceof NY))G.swap(K,W)}),K.dispose()})}function VP1(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 H=$[G];if(Q.has(H))continue;if(sa(H,K))continue;for(let z=G+1;z<$.length;z++){let V=$[z];if(Q.has(V))continue;if(sa(V,K))continue;if(H.equals(V,W))Q.set(V,H)}}X.debug(`${xJ}: Merged ${Q.size} of ${$.length} materials.`),Array.from(Q.entries()).forEach(([G,H])=>{G.listParents().forEach((z)=>{if(!(z instanceof NY))z.swap(G,H)}),G.dispose()})}function qP1(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 H=W+1;H<$.length;H++){let z=$[H];if(Q.has(z))continue;if(G.equals(z,K)&&iM1(G.listJoints(),z.listJoints()))Q.set(z,G)}}X.debug(`${xJ}: Merged ${Q.size} of ${$.length} skins.`),Array.from(Q.entries()).forEach(([W,G])=>{W.listParents().forEach((H)=>{if(!(H instanceof NY))H.swap(W,G)}),W.dispose()})}function Rs(Z,J){let X=[];for(let Y of Z.listSemantics()){let $=Z.getAttribute(Y);X.push(Y+":"+J.get($))}if(Z instanceof w8){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:"+Rs(Q,J))}return X.join(",")}function sa(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 Ms(){var Z=new TK(4);if(TK!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function UP1(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 LP1(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 BP1(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 wP1(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 OP1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3];return Math.hypot(J,X,Y,$)}var Ps=LP1,NP1=BP1,js=OP1;(function(){var Z=Ms();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 RP1=/color|emissive|diffuse/i;function MP1(Z){return Z.getGraph().listParentEdges(Z).some(($)=>{return $.getAttributes().isColor||RP1.test($.getName())})?"srgb":null}function PP1(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 OY)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 M5&&K.has(W.getName()))Y.add(G);else if(G instanceof WK)$(G)}}return $(Z),Array.from(Y)}function jP1(Z){let X=E6.fromGraph(Z.getGraph()).getRoot(),Y=Z.getGraph().listParentEdges(Z).filter(($)=>$.getParent()!==X).map(($)=>$.getName());return Array.from(new Set(Y))}var DK="prune",PT=0.011764705882352941,oa={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 eB(Z=oa){let J=q7(oa,Z),X=new Set(J.propertyTypes),Y=J.keepExtras;return fJ(DK,async($)=>{let Q=$.getLogger(),K=$.getRoot(),W=$.getGraph(),G=new Ds,H=(z)=>G.dispose(z.target);if(W.addEventListener("node:dispose",H),X.has(a.MESH))for(let z of K.listMeshes()){if(z.listPrimitives().length>0)continue;z.dispose()}if(X.has(a.NODE)){if(!J.keepLeaves)for(let z of K.listScenes())Cs(W,z,Y);for(let z of K.listNodes())E9(z,Y)}if(X.has(a.SKIN))for(let z of K.listSkins())E9(z,Y);if(X.has(a.MESH))for(let z of K.listMeshes())E9(z,Y);if(X.has(a.CAMERA))for(let z of K.listCameras())E9(z,Y);if(X.has(a.PRIMITIVE))ra(W,a.PRIMITIVE,Y);if(X.has(a.PRIMITIVE_TARGET))ra(W,a.PRIMITIVE_TARGET,Y);if(!J.keepAttributes&&X.has(a.ACCESSOR)){let z=new Map;for(let V of K.listMeshes())for(let F of V.listPrimitives()){let q=F.getMaterial();if(!q)continue;let U=Ts($,F,q),B=CP1(F,U);ta(F,B),F.listTargets().forEach((L)=>ta(L,B)),z.has(q)?z.get(q).add(F):z.set(q,new Set([F]))}for(let[V,F]of z)TP1(V,Array.from(F))}if(!J.keepIndices&&X.has(a.ACCESSOR))for(let z of K.listMeshes())for(let V of z.listPrimitives())DP1(V);if(X.has(a.ANIMATION))for(let z of K.listAnimations()){for(let V of z.listChannels())if(!V.getTargetNode())V.dispose();if(!z.listChannels().length){let V=z.listSamplers();E9(z,Y),V.forEach((F)=>E9(F,Y))}else z.listSamplers().forEach((V)=>E9(V,Y))}if(X.has(a.MATERIAL))K.listMaterials().forEach((z)=>E9(z,Y));if(X.has(a.TEXTURE)){if(K.listTextures().forEach((z)=>E9(z,Y)),!J.keepSolidTextures)await EP1($)}if(X.has(a.ACCESSOR))K.listAccessors().forEach((z)=>E9(z,Y));if(X.has(a.BUFFER))K.listBuffers().forEach((z)=>E9(z,Y));if(W.removeEventListener("node:dispose",H),!G.empty()){let z=G.entries().map(([V,F])=>`${V} (${F})`).join(", ");Q.info(`${DK}: Removed types... ${z}`)}else Q.debug(`${DK}: No unused properties found.`);Q.debug(`${DK}: Complete.`)})}class Ds{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 E9(Z,J){let X=Z.listParents().filter(($)=>!($ instanceof NY||$ instanceof BY)),Y=J&&!Us(Z.getExtras());if(!X.length&&!Y)Z.dispose()}function ra(Z,J,X){for(let Y of Z.listEdges()){let $=Y.getParent();if($.propertyType===J)E9($,X)}}function Cs(Z,J,X){if(J.listChildren().forEach((K)=>Cs(Z,K,X)),J instanceof GK)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&&!Us(J.getExtras());if($&&!Y&&!Q)J.dispose()}function ta(Z,J){for(let X of J)Z.setAttribute(X,null)}function DP1(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 CP1(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 Ts(Z,J,X,Y=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let H of Q)if(H.getChild()instanceof OY)K.add(H.getName());for(let H of Q){let z=H.getName(),V=H.getChild();if(V instanceof M5){if(K.has(z.replace(/Info$/,"")))Y.add(`TEXCOORD_${V.getTexCoord()}`)}if(V instanceof OY&&z.match(/normalTexture/i))Y.add("TANGENT");if(V instanceof WK)Ts(Z,J,V,Y)}let W=X instanceof $7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===w8.Mode.POINTS;if(W&&!G)Y.add("NORMAL");return Y}function TP1(Z,J){let X=PP1(Z),Y=new Set(X.map((G)=>G.getTexCoord())),$=Array.from(Y).sort(),Q=new Map($.map((G,H)=>[G,H])),K=new Map($.map((G,H)=>[`TEXCOORD_${G}`,`TEXCOORD_${H}`]));for(let G of X){let H=G.getTexCoord();G.setTexCoord(Q.get(H))}for(let G of J){let H=G.listSemantics().filter((z)=>z.startsWith("TEXCOORD_")).sort();W(G,H),G.listTargets().forEach((z)=>W(z,H))}function W(G,H){for(let z of H){let V=G.getAttribute(z);if(!V)continue;let F=K.get(z);if(F===z)continue;G.setAttribute(F,V),G.setAttribute(z,null)}}}async function EP1(Z){let J=Z.getRoot(),X=Z.getGraph(),Y=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await IP1(K);if(!G)return;if(MP1(K)==="srgb")ED.convertSRGBToLinear(G,G);let H=K.getName()||K.getURI(),z=(W=K.getSize())==null?void 0:W.join("x"),V=jP1(K);for(let F of X.listParentEdges(K)){let q=F.getParent();if(q!==J&&kP1(q,G,F.getName(),Y))F.dispose()}if(K.listParents().length===1)K.dispose(),Y.debug(`${DK}: Removed solid-color texture "${H}" (${z}px ${V.join(", ")})`)});await Promise.all(Q)}function kP1(Z,J,X,Y){if(Z instanceof $7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(NP1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(GP1([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 js(Ps(Ms(),J,[0.5,0.5,1,1]))<=PT}return Y.warn(`${DK}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function IP1(Z){let J=await vP1(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 H=0;H<4;H++)X[H]=Math.min(X[H],J.get(W,G,H)),Y[H]=Math.max(Y[H],J.get(W,G,H));if(js(Ps($,Y,X))/255>PT)return null}return wP1($,UP1($,Y,X),0.00196078431372549)}async function vP1(Z){try{return await Fa(Z.getImage(),Z.getMimeType())}catch(J){return null}}var AJ=4294967295;class Es{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of kT(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 _P1(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 _P1(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 SP1(Z,J,X,Y,$=AJ){let Q=J-1,W=X.hash(Y)&Q;for(let G=0;G<=Q;G++){let H=Z[W];if(H===$||X.equal(H,Y))return W;W=W+G+1&Q}throw new Error("Hash table full.")}var L6;(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"})(L6||(L6={}));function hJ(Z,J){let X=Z.getAttribute("POSITION"),Y=Z.getIndices();switch(J){case L6.RENDER:return Y?Y.getCount():X.getCount();case L6.RENDER_CACHED:return Y?new Set(Y.getArray()).size:X.getCount();case L6.UPLOAD_NAIVE:case L6.UPLOAD:return X.getCount();case L6.DISTINCT:case L6.DISTINCT_POSITION:return AP1(J);case L6.UNUSED:return Y?X.getCount()-new Set(Y.getArray()).size:0;default:return xP1(J)}}function AP1(Z){throw new Error(`Not implemented: ${Z}`)}function xP1(Z){throw new Error(`Unexpected value: ${Z}`)}function TH(Z,J,X){let Y=E6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=hP1(Z);let $=Z.getIndices(),Q=$?$.getArray():null,K=hJ(Z,L6.RENDER),W=Y.createAccessor(),G=K,H=IT(G,X);for(let V=0;V<G;V++)H[V]=J[Q?Q[V]:V];Z.setIndices(W.setArray(H));let z=kT(Z);for(let V of Z.listAttributes()){let F=wZ(Y,V);jT(V,$,J,F,X),Z.swap(V,F)}for(let V of Z.listTargets())for(let F of V.listAttributes()){let q=wZ(Y,F);jT(F,$,J,q,X),V.swap(F,q)}if($&&$.listParents().length===1)$.dispose();for(let V of z)if(V.listParents().length===1)V.dispose();return Z}function jT(Z,J,X,Y,$){let Q=Z.getElementSize(),K=Z.getArray(),W=J?J.getArray():null,G=J?J.getCount():Z.getCount(),H=new K.constructor($*Q),z=new Uint8Array($);for(let V=0;V<G;V++){let F=W?W[V]:V,q=X[F];if(z[q])continue;for(let U=0;U<Q;U++)H[q*Q+U]=K[F*Q+U];z[q]=1}return Y.setArray(H)}function hP1(Z){let J=hJ(Z,L6.UPLOAD),X=Z.getIndices(),Y=X?X.getArray():null;if(!X||!Y)return[nM1(J,1e6),J];let $=new Uint32Array(J).fill(AJ),Q=0;for(let K=0;K<Y.length;K++){let W=Y[K];if($[W]===AJ)$[W]=Q++}return[$,Q]}var DT="weld",aB={overwrite:!0,cleanup:!0};function vT(Z=aB){let J=q7(aB,Z);return fJ(DT,async(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes()){for(let Q of $.listPrimitives())if(Z2(Q,J),hJ(Q,L6.RENDER)===0)Q.dispose();if($.listPrimitives().length===0)$.dispose()}if(J.cleanup)await X.transform(eB({propertyTypes:[a.ACCESSOR,a.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),Ns({propertyTypes:[a.ACCESSOR]}));Y.debug(`${DT}: Complete.`)})}function Z2(Z,J=aB){let X=Z.getGraph(),$=E6.fromGraph(X).getLogger(),Q=CK({},aB,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===w8.Mode.POINTS)return;let K=Z.getAttribute("POSITION").getCount(),W=Z.getIndices(),G=W==null?void 0:W.getArray(),H=W?W.getCount():K,z=new Es(Z),V=sM1(K+K/4),F=new Uint32Array(V).fill(AJ),q=new Uint32Array(K).fill(AJ),U=0;for(let B=0;B<H;B++){let L=G?G[B]:B;if(q[L]!==AJ)continue;let w=SP1(F,V,z,L,AJ),N=F[w];if(N===AJ)F[w]=L,q[L]=U++;else q[L]=q[N]}$.debug(`${DT}: ${rB(K,U)} vertices.`),TH(Z,q,U)}var{FLOAT:fP1}=E0.ComponentType;function ks(Z,J){let X=Z.getAttribute("POSITION");if(X)ea(J,X);let Y=Z.getAttribute("NORMAL");if(Y)Zs(J,Y);let $=Z.getAttribute("TANGENT");if($)Js(J,$);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)ea(J,K);let W=Q.getAttribute("NORMAL");if(W)Zs(J,W);let G=Q.getAttribute("TANGENT");if(G)Js(J,G)}if(ZP1(J)<0)yP1(Z)}function ea(Z,J){let X=J.getComponentType(),Y=J.getNormalized(),$=J.getArray(),Q=X===fP1?$:new Float32Array($.length),K=tB();for(let W=0,G=J.getCount();W<G;W++){if(Y)K[0]=d0.decodeNormalizedInt($[W*3],X),K[1]=d0.decodeNormalizedInt($[W*3+1],X),K[2]=d0.decodeNormalizedInt($[W*3+2],X);else K[0]=$[W*3],K[1]=$[W*3+1],K[2]=$[W*3+2];KP1(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 Zs(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=JP1();XP1(Q,Z),$P1(Q,Q),YP1(Q,Q);let K=tB();for(let W=0,G=J.getCount();W<G;W++){if(Y)K[0]=d0.decodeNormalizedInt(X[W*3],$),K[1]=d0.decodeNormalizedInt(X[W*3+1],$),K[2]=d0.decodeNormalizedInt(X[W*3+2],$);else K[0]=X[W*3],K[1]=X[W*3+1],K[2]=X[W*3+2];if(WP1(K,K,Q),Os(K,K),Y)X[W*3]=d0.decodeNormalizedInt(K[0],$),X[W*3+1]=d0.decodeNormalizedInt(K[1],$),X[W*3+2]=d0.decodeNormalizedInt(K[2],$);else X[W*3]=K[0],X[W*3+1]=K[1],X[W*3+2]=K[2]}}function Js(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=tB();for(let K=0,W=J.getCount();K<W;K++){if(Y)Q[0]=d0.decodeNormalizedInt(X[K*4],$),Q[1]=d0.decodeNormalizedInt(X[K*4+1],$),Q[2]=d0.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],Os(Q,Q),Y)X[K*4]=d0.decodeNormalizedInt(Q[0],$),X[K*4+1]=d0.decodeNormalizedInt(Q[1],$),X[K*4+2]=d0.decodeNormalizedInt(Q[2],$);else X[K*4]=Q[0],X[K*4+1]=Q[1],X[K*4+2]=Q[2]}}function yP1(Z){if(Z.getMode()!==w8.Mode.TRIANGLES)return;if(!Z.getIndices())Z2(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 bP1(Z,J){for(let X of Z.listPrimitives()){let Y=gP1(X,Z);if(X!==Y)Z.removePrimitive(X).addPrimitive(Y)}for(let X of Z.listPrimitives())TH(X),ks(X,J)}function gP1(Z,J){if(Z.listParents().some((Y)=>Y instanceof XH&&Y!==J))Z=Z.clone();for(let Y of Z.listTargets())if(Y.listParents().some((Q)=>Q instanceof w8&&Q!==Z))Z.removeTarget(Y).addTarget(Y.clone());return Z}var Xs=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function Is(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!d0.eq(X,Xs))bP1(J,X);for(let Y of Z.listChildren()){let $=Y.getMatrix();ws($,$,X),Y.setMatrix($)}return Z.setMatrix(Xs)}var{LINES:mP1,LINE_STRIP:uP1,LINE_LOOP:dP1,TRIANGLES:lP1,TRIANGLE_STRIP:cP1,TRIANGLE_FAN:pP1}=w8.Mode;function iP1(Z){let J=Z.getGraph(),X=E6.fromGraph(J);if(!Z.getIndices())Z2(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=qs(Z),W=new DJ[Y.getComponentType()](Q*2),G=Z.getMode();if(G===uP1)for(let z=0;z<Q;z++)W[z*2]=$[z],W[z*2+1]=$[z+1];else if(G===dP1)for(let z=0;z<Q;z++)if(z<Q-1)W[z*2]=$[z],W[z*2+1]=$[z+1];else W[z*2]=$[z],W[z*2+1]=$[0];else throw new Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(mP1);let H=X.getRoot();if(Y.listParents().some((z)=>z!==H&&z!==Z))Z.setIndices(wZ(X,Y).setArray(W));else Y.setArray(W)}function vs(Z){let J=Z.getGraph(),X=E6.fromGraph(J);if(!Z.getIndices())Z2(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=qs(Z),W=new DJ[Y.getComponentType()](Q*3),G=Z.getMode();if(G===cP1)for(let z=0,V=$.length;z<V-2;z++)if(z%2)W[z*3]=$[z+1],W[z*3+1]=$[z],W[z*3+2]=$[z+2];else W[z*3]=$[z],W[z*3+1]=$[z+1],W[z*3+2]=$[z+2];else if(G===pP1)for(let z=0;z<Q;z++)W[z*3]=$[0],W[z*3+1]=$[z+1],W[z*3+2]=$[z+2];else throw new Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(lP1);let H=X.getRoot();if(Y.listParents().some((z)=>z!==H&&z!==Z))Z.setIndices(wZ(X,Y).setArray(W));else Y.setArray(W)}var Ys="dequantize",sB={pattern:/^((?!JOINTS_).)*$/};function _s(Z=sB){let J=q7(sB,Z);return fJ(Ys,(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes())for(let Q of $.listPrimitives())nP1(Q,J);X.createExtension(DH).dispose(),Y.debug(`${Ys}: Complete.`)})}function nP1(Z,J=sB){let X=q7(sB,J);for(let Y of Z.listSemantics())if(X.pattern.test(Y))CT(Z.getAttribute(Y));for(let Y of Z.listTargets())for(let $ of Y.listSemantics())if(X.pattern.test($))CT(Y.getAttribute($))}function CT(Z){let J=Z.getArray();if(!J)return;let X=oB(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function oB(Z,J,X){let Y=new Float32Array(Z.length);for(let $=0,Q=Z.length;$<Q;$++)if(X)Y[$]=d0.decodeNormalizedInt(Z[$],J);else Y[$]=Z[$];return Y}var{TEXTURE_INFO:Ss,ROOT:lT6}=a;function As(Z){let J=new E6().setLogger(Z.getLogger()),X=_T(J,Z);return aP1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function aP1(Z,J,X){X||(X=_T(Z,J));for(let Y of J.getRoot().listExtensionsUsed()){let $=Z.createExtension(Y.constructor);if(Y.isRequired())$.setRequired(!0)}return sP1(Z,J,oP1(J),X)}function sP1(Z,J,X,Y){Y||(Y=_T(Z,J));let $=new Map;for(let Q of X)if(!$.has(Q)&&Q.propertyType!==Ss)$.set(Q,Y(Q));for(let[Q,K]of $.entries())K.copy(Q,Y);return $}function _T(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return(Y)=>{if(Y.propertyType===Ss)return Y;let $=X.get(Y);if(!$)$=new Y.constructor(Z.getGraph()),X.set(Y,$);return $}}function oP1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}var NT="flatten",$s={cleanup:!0};function xs(Z=$s){let J=q7($s,Z);return fJ(NT,async(X)=>{let Y=X.getRoot(),$=X.getLogger(),Q=new Set;for(let H of Y.listSkins())for(let z of H.listJoints())Q.add(z);let K=new Set;for(let H of Y.listAnimations())for(let z of H.listChannels()){let V=z.getTargetNode();if(V&&z.getTargetPath()!=="weights")K.add(V)}let W=new Set,G=new Set;for(let H of Y.listScenes())H.traverse((z)=>{let V=z.getParentNode();if(!V)return;if(Q.has(V)||W.has(V))W.add(z);if(K.has(V)||G.has(V))G.add(z)});for(let H of Y.listScenes())H.traverse((z)=>{if(K.has(z))return;if(W.has(z))return;if(G.has(z))return;tM1(z)});if(K.size)$.debug(`${NT}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(eB({propertyTypes:[a.NODE],keepLeaves:!1}));$.debug(`${NT}: Complete.`)})}function hs(Z){return TD(Z)}var rP1={skipValidation:!1},Qs=4294967295,{LINE_STRIP:tP1,LINE_LOOP:eP1,TRIANGLE_STRIP:Zj1,TRIANGLE_FAN:Jj1}=w8.Mode;function Xj1(Z,J={}){let X=q7(rP1,J),Y=Z[0],$=E6.fromGraph(Y.getGraph());if(!X.skipValidation&&new Set(Z.map(Ls)).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 tP1:case eP1:iP1(q);break;case Zj1:case Jj1:vs(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],B=U.getIndices(),L=U.getAttribute("POSITION").getCount(),w=B?B.getArray():null,N=B?B.getCount():L,R=new Uint32Array(L).fill(Qs);for(let M=0;M<N;M++){let D=w?w[M]:M;if(R[D]===Qs)R[D]=W++,K[q]++}Q.push(R),G+=N}let H=$.createPrimitive().setMode(Y.getMode()).setMaterial(Y.getMaterial());for(let q of Y.listSemantics()){let U=Y.getAttribute(q),B=DJ[U.getComponentType()],L=wZ($,U).setArray(new B(W*U.getElementSize()));H.setAttribute(q,L)}let z=Y.getIndices(),V=z?wZ($,z).setArray(IT(G,W)):null;H.setIndices(V);let F=0;for(let q=0;q<Q.length;q++){let U=Z[q],B=U.getIndices(),L=B?B.getCount():-1,w=Q[q];if(B&&V)$j1(B,w,V,F),F+=L;for(let N of H.listSemantics()){let R=U.getAttribute(N),M=H.getAttribute(N);Yj1(R,B,w,M)}}return H}function Yj1(Z,J,X,Y){let $=Z.getElementSize(),Q=J?J.getArray():null,K=Z.getCount(),W=Z.getArray(),G=Y.getArray(),H=new Uint8Array(Z.getCount());for(let z=0,V=J?J.getCount():K;z<V;z++){let F=Q?Q[z]:z,q=X[F];if(H[q])continue;for(let U=0;U<$;U++)G[q*$+U]=W[F*$+U];H[q]=1}}function $j1(Z,J,X,Y){let $=Z.getCount(),Q=Z.getArray(),K=X.getArray();for(let W=0;W<$;W++){let G=Q[W],H=J[G];K[Y+W]=H}}var TT="join",{ROOT:Qj1,NODE:Kj1,MESH:Wj1,PRIMITIVE:Gj1,ACCESSOR:Hj1}=a,RT=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ks={keepMeshes:!1,keepNamed:!1,cleanup:!0};function fs(Z=Ks){let J=q7(Ks,Z);return fJ(TT,async(X)=>{let Y=X.getRoot(),$=X.getLogger();for(let Q of Y.listScenes())Ws(X,Q,J),Q.traverse((K)=>Ws(X,K,J));if(J.cleanup)await X.transform(eB({propertyTypes:[Kj1,Wj1,Gj1,Hj1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));$.debug(`${TT}: Complete.`)})}function Ws(Z,J,X){let Y=Z.getLogger(),$={},Q=J.listChildren();for(let G=0;G<Q.length;G++){let H=Q[G];if(H.listParents().some((F)=>F instanceof BY))continue;let V=H.getMesh();if(!V)continue;if(H.getExtension("EXT_mesh_gpu_instancing"))continue;if(H.getSkin())continue;for(let F of V.listPrimitives()){if(F.listTargets().length>0)continue;let q=F.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;TH(F),Fj1(F);let U=Ls(F),B=V.getName()||H.getName();if(X.keepMeshes||X.keepNamed&&B)U+=`|${G}`;if(!(U in $))$[U]={prims:[],primMeshes:[],primNodes:[],dstNode:H,dstMesh:void 0};let L=$[U];L.prims.push(F),L.primNodes.push(H)}}let K=Object.values($).filter(({prims:G})=>G.length>1),W=new Set(K.flatMap((G)=>G.primNodes));for(let G of W){let H=G.getMesh();if(H.listParents().some((V)=>{return V.propertyType!==Qj1&&G!==V}))G.setMesh(H.clone())}for(let G of K){let{dstNode:H,primNodes:z}=G;G.dstMesh=H.getMesh(),G.primMeshes=z.map((V)=>V.getMesh())}for(let G of K){let{prims:H,primNodes:z,primMeshes:V,dstNode:F,dstMesh:q}=G,U=F.getMatrix();for(let w=0;w<H.length;w++){let N=z[w],R=V[w],M=H[w];if(R.removePrimitive(M),aM1(M))M=H[w]=zj1(H[w]);if(N!==F)ws(RT,eM1(RT,U),N.getMatrix()),ks(M,RT)}let B=Xj1(H),L=B.listAttributes()[0].getCount();q.addPrimitive(B),Y.debug(`${TT}: Joined Primitives (${H.length}) containing ${MT(L)} vertices under Node "${F.getName()}".`)}}function zj1(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 Fj1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)CT(X)}}var{TRANSLATION:cT6,ROTATION:pT6,SCALE:iT6,WEIGHTS:nT6}=BY.TargetPath;var Vj1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var aT6=CK({level:"high"},Vj1);var qj1="unweld";function Uj1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let Y=Z.getGraph(),$=E6.fromGraph(Y),Q=$.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,Gs($,G,X,J)),G.listParents().length===1)G.dispose();for(let G of Z.listTargets())for(let H of G.listAttributes())if(G.swap(H,Gs($,H,X,J)),H.listParents().length===1)H.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${qj1}: ${rB(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function Gs(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 z=0,V=X.getCount();z<V;z++)for(let F=0;F<G;F++)K[z*G+F]=$[W[z]*G+F];if(!Y.has(J))Y.set(J,new Map);let H=wZ(Z,J).setArray(K);return Y.get(J).set(X,H),H}var Hs;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(Hs||(Hs={}));var Lj1=0.000001;function Bj1(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),H=Z.length-1,z=1;for(let V=1;V<H;++V){let F=Z[z-1],q=Z[V],U=Z[V+1],B=(q-F)/(U-F),L=!1;if(q!==U&&(V!==1||q!==Z[0])){if(CH(J,z-1,G),CH(J,V,K),CH(J,V+1,W),X==="slerp"){let w=Nj1(Q,G,W,B),N=Fs(G,K)+Fs(K,W);L=!nB(K,w,Y)||N+Number.EPSILON>=Math.PI}else if(X==="lerp"){let w=Oj1(Q,G,W,B);L=!nB(K,w,Y)}else if(X==="step")L=!nB(K,G)||!nB(K,W)}if(L){if(V!==z)Z[z]=Z[V],zs(J,z,CH(J,V,Q));z++}}if(H>0)Z[z]=Z[H],zs(J,z,CH(J,H,Q)),z++;return z}function CH(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)X[Y]=Z[J*$+Y];return X}function zs(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)Z[J*$+Y]=X[Y]}function nB(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 wj1(Z,J,X){return Z*(1-X)+J*X}function Oj1(Z,J,X,Y){for(let $=0;$<J.length;$++)Z[$]=wj1(J[$],X[$],Y);return Z}function Nj1(Z,J,X,Y){let $=J[0],Q=J[1],K=J[2],W=J[3],G=X[0],H=X[1],z=X[2],V=X[3],F,q,U,B,L;if(q=$*G+Q*H+K*z+W*V,q<0)q=-q,G=-G,H=-H,z=-z,V=-V;if(1-q>Lj1)F=Math.acos(q),U=Math.sin(F),B=Math.sin((1-Y)*F)/U,L=Math.sin(Y*F)/U;else B=1-Y,L=Y;return Z[0]=B*$+L*G,Z[1]=B*Q+L*H,Z[2]=B*K+L*z,Z[3]=B*W+L*V,Z}function Fs(Z,J){let X=Rj1(Z,J);return Math.acos(2*X*X-1)}function Rj1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var sT6=new Float32Array(0),oT6={ready:Promise.resolve(),resample:Bj1,tolerance:0.0001,cleanup:!0};var gY="simplify",{POINTS:ys,LINES:Mj1,LINE_STRIP:Pj1,LINE_LOOP:jj1,TRIANGLES:Dj1,TRIANGLE_STRIP:bs,TRIANGLE_FAN:gs}=w8.Mode,ms={ratio:0,error:0.0001,lockBorder:!1,cleanup:!0};function us(Z){let J=q7(ms,Z),X=J.simplifier;if(!X)throw new Error(`${gY}: simplifier dependency required — install "meshoptimizer".`);return fJ(gY,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===Dj1||G===bs||G===gs){if(Vs(W,J),hJ(W,L6.RENDER)===0)W.dispose()}else if(W.getMode()===ys&&!!X.simplifyPoints){if(Vs(W,J),hJ(W,L6.RENDER)===0)W.dispose()}else Q++}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)$.warn(`${gY}: Skipping simplification of ${Q} primitives: Unsupported draw mode.`);if(J.cleanup)await Y.transform(eB({propertyTypes:[a.ACCESSOR,a.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),Ns({propertyTypes:[a.ACCESSOR]}));$.debug(`${gY}: Complete.`)})}function Vs(Z,J){let X=CK({},ms,J),Y=X.simplifier,$=Z.getGraph(),Q=E6.fromGraph($),K=Q.getLogger();switch(Z.getMode()){case ys:return Cj1(Q,Z,X);case Mj1:case Pj1:case jj1:return K.warn(`${gY}: Skipping primitive simplification: Unsupported draw mode.`),Z;case bs:case gs:vs(Z);break}let W=hJ(Z,L6.UPLOAD),G=hJ(Z,L6.RENDER);if(G<W/2)TH(Z);let H=Z.getAttribute("POSITION"),z=Z.getIndices(),V=H.getArray(),F=z.getArray();if(!(V instanceof Float32Array))V=oB(V,H.getComponentType(),H.getNormalized());if(!(F instanceof Uint32Array))F=new Uint32Array(F);let q=Math.floor(X.ratio*G/3)*3,U=X.lockBorder?["LockBorder"]:[],[B,L]=Y.simplify(F,V,3,q,X.error,U);if(Z.setIndices(wZ(Q,z).setArray(B)),z.listParents().length===1)z.dispose();TH(Z);let w=hJ(Z,L6.UPLOAD);if(w<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${gY}: ${rB(W,w)} vertices, error: ${L.toFixed(4)}.`),Z}function Cj1(Z,J,X){let Y=X.simplifier,$=Z.getLogger();if(J.getIndices())Uj1(J);let K=J.getAttribute("POSITION"),W=J.getAttribute("COLOR_0"),G=K.getCount(),H=K.getArray(),z=W?W.getArray():void 0,V=W?W.getComponentSize():void 0;if(!(H instanceof Float32Array))H=oB(H,K.getComponentType(),K.getNormalized());if(z&&!(z instanceof Float32Array))z=oB(z,K.getComponentType(),K.getNormalized());Y.useExperimentalFeatures=!0;let F=Math.floor(X.ratio*G),q=Y.simplifyPoints(H,3,F,z,V);Y.useExperimentalFeatures=!1;let[U,B]=Y.compactMesh(q);$.debug(`${gY}: ${rB(K.getCount(),B)} vertices.`);for(let L of kT(J)){let w=wZ(Z,L);if(jT(L,null,U,w,B),pM1(J,L,w),L.listParents().length===1)L.dispose()}return J}var ET;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(ET||(ET={}));var rT6={resizeFilter:ET.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var as=r(ns(),1);var EK={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DIRECTORIES:[(()=>{try{return kK.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))}catch{return null}})(),kK.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 k9{static instance=new k9;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}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}}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){for(let J of EK.DIRECTORIES)Z=Z.replace(J,"");if(Z.startsWith("/"))Z=Z.slice(1);return Z}async _getAbsoluteModelPaths(){let Z=[];for(let J of EK.DIRECTORIES){let X=kK.resolve(process.cwd(),J);if(!yJ.existsSync(X))continue;let Y=await uL("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let $ of Y)Z.push(kK.join(X,$))}return Z}async _loadModelData(Z){let J=await new SD().read(Z),X=hs(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)}${EK.CHECKSUM_EXT}`;if(!yJ.existsSync(J))return!1;let X=this._calculateChecksum(Z),Y=yJ.readFileSync(J,"utf8");return X===Y}_calculateChecksum(Z){if(!yJ.existsSync(Z))return"";let J=yJ.readFileSync(Z);return vj1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=kK.basename(Z),X=J.replace(/\.[^/.]+$/,""),Y=`${EK.OPTIMIZED_DIR}/${X}`;return Z.replace(/[^/\\]+$/,`${Y}/${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 $=As(Y);$.setLogger(new P5(ZH.WARN)),await $.transform(Bs({pivot:"center"}),xs(),fs(),vT(),us({simplifier:as.MeshoptSimplifier,ratio:J,error:X}),_s());for(let H of $.getRoot().listScenes())for(let z of H.listChildren())Is(z);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=kK.dirname(J);yJ.rmSync(X,{recursive:!0,force:!0}),yJ.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let Y of EK.OPTIMIZER_RUNS){let $=J.replace(/(\.[^/.]+)$/,`${Y.suffix}$1`),{stderr:Q}=await sl("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 yJ.writeFileSync(`${J}${EK.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var OZ=r(fQ(),1);var _H;(($)=>{$.DYNAMIC="dynamic";$.FIXED="fixed";$.KINEMATIC_POSITION="kinematic_position";$.KINEMATIC_VELOCITY="kinematic_velocity"})(_H||={});var fT=0.001,ss="dynamic";class mY extends g0{_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??=ss,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"]:OZ.default.RigidBodyType.Dynamic,["fixed"]:OZ.default.RigidBodyType.Fixed,["kinematic_position"]:OZ.default.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:OZ.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 s5({...Z,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(Z)}createAndAddChildCollidersToSimulation(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 s5(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??ss;return{["dynamic"]:()=>OZ.default.RigidBodyDesc.dynamic(),["fixed"]:()=>OZ.default.RigidBodyDesc.fixed(),["kinematic_position"]:()=>OZ.default.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>OZ.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)<fT&&Math.abs(Z.y)<fT&&Math.abs(Z.z)<fT}}var yT;(($)=>{$[$.Average=0]="Average";$[$.Min=1]="Min";$[$.Multiply=2]="Multiply";$[$.Max=3]="Max"})(yT||={});var SH;((H)=>{H.NONE="none";H.BALL="ball";H.BLOCK="block";H.CAPSULE="capsule";H.CONE="cone";H.CYLINDER="cylinder";H.ROUND_CYLINDER="round-cylinder";H.TRIMESH="trimesh";H.WEDGE="wedge"})(SH||={});class s5 extends g0{_collider;_colliderDesc;_onCollision;_parentRigidBody;_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=k9.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),H=W/G,z=W/Q,V=W*J/2,F=(N)=>Math.max(0.01,N),q=()=>({shape:"block",halfExtents:{x:F($*J/2),y:F(Q*J/2),z:F(K*J/2)}}),U=()=>({shape:"round-cylinder",radius:F(V),halfHeight:F(Q*J/2),borderRadius:F(V*0.1)}),B=()=>{let N=k9.instance.getTrimesh(Z,J);if(!N)return;return{shape:"trimesh",vertices:N.vertices,indices:N.indices}},L=()=>({shape:"wedge",extents:{x:$*J,y:Q*J,z:K*J}}),w=()=>({shape:"capsule",radius:F(V),halfHeight:F(Q*J/2-V)});if(X)switch(X){case"block":return q();case"capsule":return w();case"round-cylinder":return U();case"trimesh":{let N=B();if(!N){u.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return N}case"wedge":return L();default:u.warning(`Collider.optionsFromModelUri(): Preferred shape ${X} is not yet supported with Collider.optionsFromModelUri(), defaulting to generic shape!`)}if(H>2)return q();if(z>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?G4.decodeRawCollisionGroups(this._collider.collisionGroups()):G4.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 relativePosition(){if(!this._requireNotRemoved("relativePosition"))return{x:0,y:0,z:0};return this._collider?this._collider.translation():this._colliderDesc.translation}get relativeRotation(){if(!this._requireNotRemoved("relativeRotation"))return{x:0,y:0,z:0,w:1};return this._collider?this._collider.rotation():this._colliderDesc.rotation}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=G4.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._collider?this._collider.setRotation(Z):this._colliderDesc.setRotation(Z)}setRelativePosition(Z){if(!this._requireNotRemoved("setRelativePosition"))return;this._collider?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)}enableCollisionEvents(Z){if(!this._requireNotRemoved("enableCollisionEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|t8.default.ActiveEvents.COLLISION_EVENTS:J&~t8.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|t8.default.ActiveEvents.CONTACT_FORCE_EVENTS:J&~t8.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 t8.default.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)u.fatalError("Block collider must have halfExtents!");return t8.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 t8.default.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)u.fatalError("Cone collider must have radius and halfHeight!");return t8.default.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)u.fatalError("Cylinder collider must have radius and halfHeight!");return t8.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 t8.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 t8.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),$=t8.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(t8.default.ActiveCollisionTypes.DYNAMIC_DYNAMIC|t8.default.ActiveCollisionTypes.DYNAMIC_KINEMATIC|t8.default.ActiveCollisionTypes.DYNAMIC_FIXED|t8.default.ActiveCollisionTypes.KINEMATIC_KINEMATIC|t8.default.ActiveCollisionTypes.KINEMATIC_FIXED)}}var _j1={shape:"trimesh",flags:os.TriMeshFlags.FIX_INTERNAL_EDGES},Sj1=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]),Aj1=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]),bT;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(bT||={});class o5 extends g0{_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,..._j1}}get isLiquid(){return this._isLiquid}get isMeshable(){return!this._customColliderOptions}get name(){return this._name}get textureUri(){return this._textureUri}createCollider(Z=Sj1,J=Aj1){let X=new s5({...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(G4.isDefaultCollisionGroups(X.collisionGroups))X.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return X}serialize(){return p0.serializeBlockType(this)}}var gT;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(gT||={});class AH extends g0{_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 o5{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 p0.serializeBlockTypeRegistry(this)}}var Uk={};Mq(Uk,{worldSchema:()=>qk,worldPacketDefinition:()=>l00,vectorSchema:()=>k1,vectorBooleanSchema:()=>__1,uiSchema:()=>Fk,uiPacketDefinition:()=>u00,uiDatasSchema:()=>Vk,uiDatasPacketDefinition:()=>d00,uiDataSendPacketDefinition:()=>E00,uiDataSchema:()=>Yz,syncResponseSchema:()=>zk,syncResponsePacketDefinition:()=>m00,syncRequestSchema:()=>mE,syncRequestPacketDefinition:()=>T00,stateRequestSchema:()=>gE,stateRequestPacketDefinition:()=>C00,sceneUIsSchema:()=>Hk,sceneUIsPacketDefinition:()=>g00,sceneUISchema:()=>Gk,rgbColorSchema:()=>B7,registeredPackets:()=>c2,quaternionSchema:()=>tE,playersSchema:()=>Wk,playersPacketDefinition:()=>b00,playerSchema:()=>Kk,physicsDebugRenderSchema:()=>Qk,physicsDebugRenderPacketDefinition:()=>f00,physicsDebugRaycastsSchema:()=>$k,physicsDebugRaycastsPacketDefinition:()=>y00,physicsDebugRaycastSchema:()=>Yk,outboundPackets:()=>l2,modelNodeOverrideSchema:()=>rE,lightsSchema:()=>Xk,lightsPacketDefinition:()=>h00,lightSchema:()=>Jk,isValidPacket:()=>A_1,inputSchema:()=>bE,inputPacketDefinition:()=>D00,inboundPackets:()=>d2,hexColorSchema:()=>fE,heartbeatSchema:()=>hE,heartbeatPacketDefinition:()=>M00,entitySchema:()=>eE,entitiesSchema:()=>Zk,entitiesPacketDefinition:()=>x00,definePacket:()=>T0,debugConfigSchema:()=>yE,debugConfigPacketDefinition:()=>j00,createPacket:()=>M_1,connectionSchema:()=>xE,connectionPacketDefinition:()=>R00,chunksSchema:()=>oE,chunksPacketDefinition:()=>A00,chunkSchema:()=>sE,chatMessagesSchema:()=>aE,chatMessagesPacketDefinition:()=>S00,chatMessageSendPacketDefinition:()=>P00,chatMessageSchema:()=>Xz,cameraSchema:()=>nE,cameraPacketDefinition:()=>_00,blocksSchema:()=>cE,blocksPacketDefinition:()=>I00,blockTypesSchema:()=>iE,blockTypesPacketDefinition:()=>v00,blockTypeSchema:()=>pE,blockSchema:()=>lE,bidirectionalPackets:()=>u2,audiosSchema:()=>dE,audiosPacketDefinition:()=>k00,audioSchema:()=>uE,PacketId:()=>h1});var u2={};Mq(u2,{heartbeatPacketDefinition:()=>M00,connectionPacketDefinition:()=>R00});var SE=r(O00(),1);class AE extends SE.default{static instance=new SE.default}var h1;((T)=>{T[T.SYNC_REQUEST=0]="SYNC_REQUEST";T[T.INPUT=1]="INPUT";T[T.STATE_REQUEST=2]="STATE_REQUEST";T[T.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";T[T.UI_DATA_SEND=4]="UI_DATA_SEND";T[T.SYNC_RESPONSE=32]="SYNC_RESPONSE";T[T.AUDIOS=33]="AUDIOS";T[T.BLOCKS=34]="BLOCKS";T[T.BLOCK_TYPES=35]="BLOCK_TYPES";T[T.CHAT_MESSAGES=36]="CHAT_MESSAGES";T[T.CHUNKS=37]="CHUNKS";T[T.ENTITIES=38]="ENTITIES";T[T.WORLD=39]="WORLD";T[T.CAMERA=40]="CAMERA";T[T.UI=41]="UI";T[T.UI_DATAS=42]="UI_DATAS";T[T.SCENE_UIS=43]="SCENE_UIS";T[T.LIGHTS=44]="LIGHTS";T[T.PLAYERS=45]="PLAYERS";T[T.CONNECTION=116]="CONNECTION";T[T.HEARTBEAT=117]="HEARTBEAT";T[T.DEBUG_CONFIG=128]="DEBUG_CONFIG";T[T.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";T[T.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(h1||={});function M_1(Z,J,X){if(!Z.validate(J))throw new Error(`Invalid payload for packet with id ${Z.id}. Error: ${AE.instance.errorsText(Z.validate.errors)}`);let Y=[Z.id,J];if(typeof X==="number")Y.push(X);return Y}function T0(Z,J){return{id:Z,schema:J,validate:AE.instance.compile(J)}}var P_1={type:"object",properties:{i:{type:"string"}},required:["i"],additionalProperties:!1},N00={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},j_1={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},D_1={type:"object",properties:{usernameFragment:{type:"string"},password:{type:"string"},iceLite:{type:"boolean",nullable:!0}},required:["usernameFragment","password"],additionalProperties:!1},C_1={type:"object",properties:{i:{type:"string"},l:{type:"string"}},required:["i","l"],additionalProperties:!1},T_1={type:"object",properties:{port:{type:"number"},OS:{type:"number"},MIS:{type:"number"},maxMessageSize:{type:"number"}},required:["port","OS","MIS","maxMessageSize"],additionalProperties:!0},E_1={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},k_1={type:"object",properties:{i:{type:"string"},f:{type:"string",enum:["cs","sc"]},ip:D_1,ic:{type:"array",items:j_1},d:N00,s:T_1},required:["i","f","ip","ic","d","s"],additionalProperties:!1},I_1={type:"object",properties:{i:{type:"string"},d:N00},required:["i","d"],additionalProperties:!1},v_1={type:"object",properties:{i:{type:"string",nullable:!0},pi:{type:"string",nullable:!0},l:{type:"string"},s:E_1},required:["l","s"],additionalProperties:!1},xE={type:"object",properties:{i:{type:"string",nullable:!0},c:{...I_1,nullable:!0},ca:{...P_1,nullable:!0},d:{type:"array",items:{...v_1},nullable:!0},pa:{...C_1,nullable:!0},t:{type:"array",items:{...k_1},nullable:!0}},additionalProperties:!1};var R00=T0(116,xE);var hE={type:"null",nullable:!0};var M00=T0(117,hE);var d2={};Mq(d2,{uiDataSendPacketDefinition:()=>E00,syncRequestPacketDefinition:()=>T00,stateRequestPacketDefinition:()=>C00,inputPacketDefinition:()=>D00,debugConfigPacketDefinition:()=>j00,chatMessageSendPacketDefinition:()=>P00});var fE={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var Xz={type:"object",properties:{m:{type:"string"},c:{...fE,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var P00=T0(3,Xz);var yE={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var j00=T0(128,yE);var bE={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},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 D00=T0(1,bE);var gE={type:"object",properties:{},additionalProperties:!1};var C00=T0(2,gE);var mE={type:"null",nullable:!0};var T00=T0(0,mE);var Yz={type:"object",properties:{},additionalProperties:!0};var E00=T0(4,Yz);var l2={};Mq(l2,{worldPacketDefinition:()=>l00,uiPacketDefinition:()=>u00,uiDatasPacketDefinition:()=>d00,syncResponsePacketDefinition:()=>m00,sceneUIsPacketDefinition:()=>g00,playersPacketDefinition:()=>b00,physicsDebugRenderPacketDefinition:()=>f00,physicsDebugRaycastsPacketDefinition:()=>y00,lightsPacketDefinition:()=>h00,entitiesPacketDefinition:()=>x00,chunksPacketDefinition:()=>A00,chatMessagesPacketDefinition:()=>S00,cameraPacketDefinition:()=>_00,blocksPacketDefinition:()=>I00,blockTypesPacketDefinition:()=>v00,audiosPacketDefinition:()=>k00});var k1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var uE={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:{...k1,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 dE={type:"array",items:{...uE}};var k00=T0(33,dE);var lE={type:"object",properties:{i:{type:"number"},c:k1},required:["i","c"],additionalProperties:!1};var cE={type:"array",items:{...lE}};var I00=T0(34,cE);var pE={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 iE={type:"array",items:{...pE}};var v00=T0(35,iE);var nE={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},p:{...k1,nullable:!0},pt:{...k1,nullable:!0},pl:{...k1,nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},o:{...k1,nullable:!0},z:{type:"number",nullable:!0}},additionalProperties:!1};var aE={type:"array",items:{...Xz}};var sE={type:"object",properties:{c:k1,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 oE={type:"array",items:{...sE}};var B7={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 rE={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:{...B7,nullable:!0}},required:["n"],additionalProperties:!1};var tE={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var eE={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:{...k1,nullable:!0},bt:{type:"string",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},m:{type:"string",nullable:!0},mo:{type:"array",items:{...rE},nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...k1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{...tE,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},t:{...B7,nullable:!0}},required:["i"],additionalProperties:!1};var Zk={type:"array",items:{...eE}};var Jk={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...B7,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...k1,nullable:!0},p:{...k1,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:{...k1,nullable:!0}},required:["i"],additionalProperties:!1};var Xk={type:"array",items:{...Jk}};var Yk={type:"object",properties:{o:{...k1},d:{...k1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var $k={type:"array",items:{...Yk}};var Qk={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var Kk={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 Wk={type:"array",items:{...Kk}};var Gk={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...k1,nullable:!0},p:{...k1,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 Hk={type:"array",items:{...Gk}};var zk={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var Fk={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var Vk={type:"array",items:{...Yz}};var __1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var qk={type:"object",properties:{i:{type:"number"},ac:{...B7,nullable:!0},ai:{type:"number",nullable:!0},dc:{...B7,nullable:!0},di:{type:"number",nullable:!0},dp:{...k1,nullable:!0},n:{type:"string",nullable:!0},s:{type:"string",nullable:!0},t:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var _00=T0(40,nE);var S00=T0(36,aE);var A00=T0(37,oE);var x00=T0(38,Zk);var h00=T0(44,Xk);var f00=T0(192,Qk);var y00=T0(193,$k);var b00=T0(45,Wk);var g00=T0(43,Hk);var m00=T0(32,zk);var u00=T0(41,Fk);var d00=T0(42,Vk);var l00=T0(39,qk);var c2=new Map,S_1={...u2,...d2,...l2};for(let Z of Object.values(S_1))if("id"in Z&&"schema"in Z){let J=Z;if(c2.has(J.id))throw new Error(`Packet with id ${J.id} is already registered.`);c2.set(J.id,J)}function A_1(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=c2.get(Z[0]);return!!J&&J.validate(Z[1])}var X0=Uk;var WK1=r(fQ(),1);var rS1=r(b10(),1),tS1=r(Rk(),1),eS1=r(Pk(),1),Ik=r(Jw(),1),vk=r(p10(),1);var Z5=r(s80(),1),Ox6=Z5.default.v1,Nx6=Z5.default.v1ToV6,Rx6=Z5.default.v3,o80=Z5.default.v4,Mx6=Z5.default.v5,Px6=Z5.default.v6,jx6=Z5.default.v6ToV1,Dx6=Z5.default.v7,Cx6=Z5.default.NIL,Tx6=Z5.default.MAX,Ex6=Z5.default.version,kx6=Z5.default.validate,Ix6=Z5.default.stringify,vx6=Z5.default.parse;var bk;try{bk=new TextDecoder}catch(Z){}var e,e5,b=0;var dk=[],tY=dk,Uz=0,I1={},J1,kZ,t5=0,S9=0,m8,IZ,v5=[],t0,r80={useRecords:!1,mapsAsObjects:!0};class zw{}var lk=new zw;lk.name="MessagePack 0xC1";var aJ=!1,Q60=2,gk,mk,uk;try{new Function("")}catch(Z){Q60=1/0}class vZ{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 B60(()=>{return Hw(),this?this.unpack(Z,J):vZ.prototype.unpack.call(r80,Z,J)});if(!Z.buffer&&Z.constructor===ArrayBuffer)Z=typeof Buffer!=="undefined"?Buffer.from(Z):new Uint8Array(Z);if(typeof J==="object")e5=J.end||Z.length,b=J.start||0;else b=0,e5=J>-1?J:Z.length;Uz=0,S9=0,kZ=null,tY=dk,m8=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 vZ){if(I1=this,this.structures)return J1=this.structures,Ww(J);else if(!J1||J1.length>0)J1=[]}else if(I1=r80,!J1||J1.length>0)J1=[];return Ww(J)}unpackMultiple(Z,J){let X,Y=0;try{aJ=!0;let $=Z.length,Q=this?this.unpack(Z,$):Fw.unpack(Z,$);if(J){if(J(Q,Y,b)===!1)return;while(b<$)if(Y=b,J(Ww(),Y,b)===!1)return}else{X=[Q];while(b<$)Y=b,X.push(Ww());return X}}catch($){throw $.lastPosition=Y,$.values=X,$}finally{aJ=!1,Hw()}}_mergeStructures(Z,J){if(mk)Z=mk.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 Ww(Z){try{if(!I1.trusted&&!aJ){let X=J1.sharedLength||0;if(X<J1.length)J1.length=X}let J;if(I1.randomAccessStructure&&e[b]<64&&e[b]>=32&&gk){if(J=gk(e,b,e5,I1),e=null,!(Z&&Z.lazy)&&J)J=J.toJSON();b=e5}else J=M8();if(m8)b=m8.postBundlePosition,m8=null;if(aJ)J1.restoreStructures=null;if(b==e5){if(J1&&J1.restoreStructures)t80();if(J1=null,e=null,IZ)IZ=null}else if(b>e5)throw new Error("Unexpected end of MessagePack data");else if(!aJ){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(J1&&J1.restoreStructures)t80();if(Hw(),J instanceof RangeError||J.message.startsWith("Unexpected end of buffer")||b>e5)J.incomplete=!0;throw J}}function t80(){for(let Z in J1.restoreStructures)J1[Z]=J1.restoreStructures[Z];J1.restoreStructures=null}function M8(){let Z=e[b++];if(Z<160)if(Z<128)if(Z<64)return Z;else{let J=J1[Z&63]||I1.getStructures&&K60()[Z&63];if(J){if(!J.read)J.read=ck(J,Z&63);return J.read()}else return Z}else if(Z<144)if(Z-=128,I1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let Y=U60();if(Y==="__proto__")Y="__proto_";J[Y]=M8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(M8(),M8());return J}else{Z-=144;let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=M8();if(I1.freezeData)return Object.freeze(J);return J}else if(Z<192){let J=Z-160;if(S9>=b)return kZ.slice(b-t5,(b+=J)-t5);if(S9==0&&e5<140){let X=J<16?pk(J):q60(J);if(X!=null)return X}return Gw(J)}else{let J;switch(Z){case 192:return null;case 193:if(m8)if(J=M8(),J>0)return m8[1].slice(m8.position1,m8.position1+=J);else return m8[0].slice(m8.position0,m8.position0-=J);return lk;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 yk(J);case 197:return J=t0.getUint16(b),b+=2,yk(J);case 198:return J=t0.getUint32(b),b+=4,yk(J);case 199:return rY(e[b++]);case 200:return J=t0.getUint16(b),b+=2,rY(J);case 201:return J=t0.getUint32(b),b+=4,rY(J);case 202:if(J=t0.getFloat32(b),I1.useFloat32>2){let X=Z$[(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(I1.int64AsType==="number")J=t0.getUint32(b)*4294967296,J+=t0.getUint32(b+4);else if(I1.int64AsType==="string")J=t0.getBigUint64(b).toString();else if(I1.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(I1.int64AsType==="number")J=t0.getInt32(b)*4294967296,J+=t0.getUint32(b+4);else if(I1.int64AsType==="string")J=t0.getBigInt64(b).toString();else if(I1.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 $60(e[b++]&63);else{let X=v5[J];if(X)if(X.read)return b++,X.read(M8());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++,$60(e[b++]&63,e[b++]);else return rY(2);case 214:return rY(4);case 215:return rY(8);case 216:return rY(16);case 217:if(J=e[b++],S9>=b)return kZ.slice(b-t5,(b+=J)-t5);return W60(J);case 218:if(J=t0.getUint16(b),b+=2,S9>=b)return kZ.slice(b-t5,(b+=J)-t5);return G60(J);case 219:if(J=t0.getUint32(b),b+=4,S9>=b)return kZ.slice(b-t5,(b+=J)-t5);return H60(J);case 220:return J=t0.getUint16(b),b+=2,Z60(J);case 221:return J=t0.getUint32(b),b+=4,Z60(J);case 222:return J=t0.getUint16(b),b+=2,J60(J);case 223:return J=t0.getUint32(b),b+=4,J60(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 kx1=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ck(Z,J){function X(){if(X.count++>Q60){let $=Z.read=new Function("r","return function(){return "+(I1.freezeData?"Object.freeze":"")+"({"+Z.map((Q)=>Q==="__proto__"?"__proto_:r()":kx1.test(Q)?Q+":r()":"["+JSON.stringify(Q)+"]:r()").join(",")+"})}")(M8);if(Z.highByte===0)Z.read=e80(J,Z.read);return $()}let Y={};for(let $=0,Q=Z.length;$<Q;$++){let K=Z[$];if(K==="__proto__")K="__proto_";Y[K]=M8()}if(I1.freezeData)return Object.freeze(Y);return Y}if(X.count=0,Z.highByte===0)return e80(J,X);return X}var e80=(Z,J)=>{return function(){let X=e[b++];if(X===0)return J();let Y=Z<32?-(Z+(X<<5)):Z+(X<<5),$=J1[Y]||K60()[Y];if(!$)throw new Error("Record id is not defined for "+Y);if(!$.read)$.read=ck($,Z);return $.read()}};function K60(){let Z=B60(()=>{return e=null,I1.getStructures()});return J1=I1._mergeStructures(Z,J1)}var Gw=eY,W60=eY,G60=eY,H60=eY,z60=!1;function F60(Z){z60=!0,Gw=J(1),W60=J(2),G60=J(3),H60=J(5);function J(X){return function Y($){let Q=tY[Uz++];if(Q==null){if(m8)return eY($);let W=e.byteOffset,G=Z(b-X+W,e5+W,e.buffer);if(typeof G=="string")Q=G,tY=dk;else if(tY=G,Uz=1,S9=1,Q=tY[0],Q===void 0)throw new Error("Unexpected end of buffer")}let K=Q.length;if(K<=$)return b+=$,Q;return kZ=Q,t5=b,S9=b+K,b+=$,Q.slice(0,$)}}}function eY(Z){let J;if(Z<16){if(J=pk(Z))return J}if(Z>64&&bk)return bk.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+=Z6.apply(String,Y),Y.length=0}if(Y.length>0)J+=Z6.apply(String,Y);return J}function V60(Z,J,X){let Y=e;e=Z,b=J;try{return eY(X)}finally{e=Y}}function Z60(Z){let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=M8();if(I1.freezeData)return Object.freeze(J);return J}function J60(Z){if(I1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let Y=U60();if(Y==="__proto__")Y="__proto_";J[Y]=M8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(M8(),M8());return J}}var Z6=String.fromCharCode;function q60(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 Z6.apply(String,X)}function pk(Z){if(Z<4)if(Z<2)if(Z===0)return"";else{let J=e[b++];if((J&128)>1){b-=1;return}return Z6(J)}else{let J=e[b++],X=e[b++];if((J&128)>0||(X&128)>0){b-=2;return}if(Z<3)return Z6(J,X);let Y=e[b++];if((Y&128)>0){b-=3;return}return Z6(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 Z6(J,X,Y,$);else{let Q=e[b++];if((Q&128)>0){b-=5;return}return Z6(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 Z6(J,X,Y,$,Q,K);let W=e[b++];if((W&128)>0){b-=7;return}return Z6(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 Z6(J,X,Y,$,Q,K,W,G);else{let H=e[b++];if((H&128)>0){b-=9;return}return Z6(J,X,Y,$,Q,K,W,G,H)}else if(Z<12){let H=e[b++],z=e[b++];if((H&128)>0||(z&128)>0){b-=10;return}if(Z<11)return Z6(J,X,Y,$,Q,K,W,G,H,z);let V=e[b++];if((V&128)>0){b-=11;return}return Z6(J,X,Y,$,Q,K,W,G,H,z,V)}else{let H=e[b++],z=e[b++],V=e[b++],F=e[b++];if((H&128)>0||(z&128)>0||(V&128)>0||(F&128)>0){b-=12;return}if(Z<14)if(Z===12)return Z6(J,X,Y,$,Q,K,W,G,H,z,V,F);else{let q=e[b++];if((q&128)>0){b-=13;return}return Z6(J,X,Y,$,Q,K,W,G,H,z,V,F,q)}else{let q=e[b++],U=e[b++];if((q&128)>0||(U&128)>0){b-=14;return}if(Z<15)return Z6(J,X,Y,$,Q,K,W,G,H,z,V,F,q,U);let B=e[b++];if((B&128)>0){b-=15;return}return Z6(J,X,Y,$,Q,K,W,G,H,z,V,F,q,U,B)}}}}}function X60(){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 eY(J)}function yk(Z){return I1.copyBuffers?Uint8Array.prototype.slice.call(e,b,b+=Z):e.subarray(b,b+=Z)}function rY(Z){let J=e[b++];if(v5[J]){let X;return v5[J](e.subarray(b,X=b+=Z),(Y)=>{b=Y;try{return M8()}finally{b=X}})}else throw new Error("Unknown extension type "+J)}var Y60=new Array(4096);function U60(){let Z=e[b++];if(Z>=160&&Z<192){if(Z=Z-160,S9>=b)return kZ.slice(b-t5,(b+=Z)-t5);else if(!(S9==0&&e5<180))return Gw(Z)}else return b--,L60(M8());let J=(Z<<5^(Z>1?t0.getUint16(b):Z>0?e[b]:0))&4095,X=Y60[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=[],Y60[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?pk(Z):q60(Z);if(W!=null)return X.string=W;return X.string=Gw(Z)}function L60(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(I1.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 $60=(Z,J)=>{let X=M8().map(L60),Y=Z;if(J!==void 0)Z=Z<32?-((J<<5)+Z):(J<<5)+Z,X.highByte=J;let $=J1[Z];if($&&($.isShared||aJ))(J1.restoreStructures||(J1.restoreStructures=[]))[Z]=$;return J1[Z]=X,X.read=ck(X,Y),X.read()};v5[0]=()=>{};v5[0].noBuffer=!0;v5[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 Ix1={Error,TypeError,ReferenceError};v5[101]=()=>{let Z=M8();return(Ix1[Z[0]]||Error)(Z[1],{cause:Z[2]})};v5[105]=(Z)=>{if(I1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=t0.getUint32(b-4);if(!IZ)IZ=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};IZ.set(J,$);let Q=M8();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};v5[112]=(Z)=>{if(I1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=t0.getUint32(b-4),X=IZ.get(J);return X.used=!0,X.target};v5[115]=()=>new Set(M8());var ik=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((Z)=>Z+"Array"),vx1=typeof globalThis==="object"?globalThis:window;v5[116]=(Z)=>{let J=Z[0],X=Uint8Array.prototype.slice.call(Z,1).buffer,Y=ik[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 vx1[Y](X)};v5[120]=()=>{let Z=M8();return new RegExp(Z[0],Z[1])};var _x1=[];v5[98]=(Z)=>{let J=(Z[0]<<24)+(Z[1]<<16)+(Z[2]<<8)+Z[3],X=b;return b+=J-Z.length,m8=_x1,m8=[X60(),X60()],m8.position0=0,m8.position1=0,m8.postBundlePosition=b,b=X,M8()};v5[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 B60(Z){if(uk)uk();let J=e5,X=b,Y=Uz,$=t5,Q=S9,K=kZ,W=tY,G=IZ,H=m8,z=new Uint8Array(e.slice(0,e5)),V=J1,F=J1.slice(0,J1.length),q=I1,U=aJ,B=Z();return e5=J,b=X,Uz=Y,t5=$,S9=Q,kZ=K,tY=W,IZ=G,m8=H,e=z,aJ=U,J1=V,J1.splice(0,J1.length,...F),I1=q,t0=new DataView(e.buffer,e.byteOffset,e.byteLength),B}function Hw(){e=null,IZ=null,J1=null}var Z$=new Array(147);for(let Z=0;Z<256;Z++)Z$[Z]=+("1e"+Math.floor(45.15-Z*0.30103));var Fw=new vZ({useRecords:!1}),Sx1=Fw.unpack,Ax1=Fw.unpackMultiple,xx1=Fw.unpack;var hx1=new Float32Array(1),Sx6=new Uint8Array(hx1.buffer,0,4);function w60(Z,J,X){gk=Z,mk=J,uk=X}var qw;try{qw=new TextEncoder}catch(Z){}var sk,M60,Bz=typeof Buffer!=="undefined",Vw=Bz?function(Z){return Buffer.allocUnsafeSlow(Z)}:Uint8Array,P60=Bz?Buffer:Uint8Array,O60=Bz?4294967296:2144337920,l,Lz,v1,m=0,J5,o1=null,j60,fx1=21760,yx1=/[\u0080-\uFFFF]/,O7=Symbol("record-id");class J$ extends vZ{constructor(Z){super(Z);this.offset=0;let J,X,Y,$,Q,K=P60.prototype.utf8Write?function(I,v){return l.utf8Write(I,v,l.byteLength-v)}:qw&&qw.encodeInto?function(I,v){return qw.encodeInto(I,l.subarray(v)).written}:!1,W=this;if(!Z)Z={};let G=Z&&Z.sequential,H=Z.structures||Z.saveStructures,z=Z.maxSharedStructures;if(z==null)z=H?32:0;if(z>8160)throw new Error("Maximum maxSharedStructure is 8160");if(Z.structuredClone&&Z.moreTypes==null)this.moreTypes=!0;let V=Z.maxOwnStructures;if(V==null)V=H?32:64;if(!this.structures&&Z.useRecords!=!1)this.structures=[];let F=z>32||V+z>64,q=z+64,U=z+V+64;if(U>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let B=[],L=0,w=0;this.pack=this.encode=function(I,v){if(!l)l=new Vw(8192),v1=l.dataView||(l.dataView=new DataView(l.buffer,0,8192)),m=0;if(J5=l.length-10,J5-m<2048)l=new Vw(l.length),v1=l.dataView||(l.dataView=new DataView(l.buffer,0,l.length)),J5=l.length-10,m=0;else m=m+7&2147483640;if(X=m,v&cx1)m+=v&255;if(Q=W.structuredClone?new Map:null,W.bundleStrings&&typeof I!=="string")o1=[],o1.size=1/0;else o1=null;if($=W.structures,$){if($.uninitialized)$=W._mergeStructures(W.getStructures());let p=$.sharedLength||0;if(p>z)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 J0,Q0=$.transitions;for(let D0=0,C0=o.length;D0<C0;D0++){let a0=o[D0];if(J0=Q0[a0],!J0)J0=Q0[a0]=Object.create(null);Q0=J0}Q0[O7]=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)x(I);else M(I);let p=o1;if(o1)N60(X,M,0);if(Q&&Q.idsToInsert){let n=Q.idsToInsert.sort((D0,C0)=>D0.offset>C0.offset?1:-1),o=n.length,J0=-1;while(p&&o>0){let D0=n[--o].offset+X;if(D0<p.stringsPosition+X&&J0===-1)J0=0;if(D0>p.position+X){if(J0>=0)J0+=6}else{if(J0>=0)v1.setUint32(p.position+X,v1.getUint32(p.position+X)+J0),J0=-1;p=p.previous,o++}}if(J0>=0&&p)v1.setUint32(p.position+X,v1.getUint32(p.position+X)+J0);if(m+=n.length*6,m>J5)E(m);W.offset=m;let Q0=gx1(l.subarray(X,m),n);return Q=null,Q0}if(W.offset=m,v&dx1)return l.start=X,l.end=m,l;return l.subarray(X,m)}catch(p){throw y=p,p}finally{if($){if(N(),Y&&W.saveStructures){let p=$.sharedLength||0,n=l.subarray(X,m),o=D60($,W);if(!y){if(W.saveStructures(o,o.isCompatible)===!1)return W.pack(I,v);if(W.lastNamedStructuresLength=p,l.length>1073741824)l=null;return n}}}if(l.length>1073741824)l=null;if(v&lx1)m=X}};let N=()=>{if(w<10)w++;let I=$.sharedLength||0;if($.length>I&&!G)$.length=I;if(L>1e4){if($.transitions=null,w=0,L=0,B.length>0)B=[]}else if(B.length>0&&!G){for(let v=0,y=B.length;v<y;v++)B[v][O7]=0;B=[]}},R=(I)=>{var v=I.length;if(v<16)l[m++]=144|v;else if(v<65536)l[m++]=220,l[m++]=v>>8,l[m++]=v&255;else l[m++]=221,v1.setUint32(m,v),m+=4;for(let y=0;y<v;y++)M(I[y])},M=(I)=>{if(m>J5)l=E(m);var v=typeof I,y;if(v==="string"){let p=I.length;if(o1&&p>=4&&p<4096){if((o1.size+=p)>fx1){let Q0,D0=(o1[0]?o1[0].length*3+o1[1].length:0)+10;if(m+D0>J5)l=E(m+D0);let C0;if(o1.position)C0=o1,l[m]=200,m+=3,l[m++]=98,Q0=m-X,m+=4,N60(X,M,0),v1.setUint16(Q0+X-3,m-X-Q0);else l[m++]=214,l[m++]=98,Q0=m-X,m+=4;o1=["",""],o1.previous=C0,o1.size=0,o1.position=Q0}let J0=yx1.test(I);o1[J0?0:1]+=I,l[m++]=193,M(J0?-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>J5)l=E(m+o);if(p<64||!K){let J0,Q0,D0,C0=m+n;for(J0=0;J0<p;J0++)if(Q0=I.charCodeAt(J0),Q0<128)l[C0++]=Q0;else if(Q0<2048)l[C0++]=Q0>>6|192,l[C0++]=Q0&63|128;else if((Q0&64512)===55296&&((D0=I.charCodeAt(J0+1))&64512)===56320)Q0=65536+((Q0&1023)<<10)+(D0&1023),J0++,l[C0++]=Q0>>18|240,l[C0++]=Q0>>12&63|128,l[C0++]=Q0>>6&63|128,l[C0++]=Q0&63|128;else l[C0++]=Q0>>12|224,l[C0++]=Q0>>6&63|128,l[C0++]=Q0&63|128;y=C0-m-n}else y=K(I,m+n);if(y<32)l[m++]=160|y;else if(y<256){if(n<2)l.copyWithin(m+2,m+1,m+1+y);l[m++]=217,l[m++]=y}else if(y<65536){if(n<3)l.copyWithin(m+3,m+2,m+2+y);l[m++]=218,l[m++]=y>>8,l[m++]=y&255}else{if(n<5)l.copyWithin(m+5,m+3,m+3+y);l[m++]=219,v1.setUint32(m,y),m+=4}m+=y}else if(v==="number")if(I>>>0===I)if(I<32||I<128&&this.useRecords===!1||I<64&&!this.randomAccessStructure)l[m++]=I;else if(I<256)l[m++]=204,l[m++]=I;else if(I<65536)l[m++]=205,l[m++]=I>>8,l[m++]=I&255;else l[m++]=206,v1.setUint32(m,I),m+=4;else if(I>>0===I)if(I>=-32)l[m++]=256+I;else if(I>=-128)l[m++]=208,l[m++]=I+256;else if(I>=-32768)l[m++]=209,v1.setInt16(m,I),m+=2;else l[m++]=210,v1.setInt32(m,I),m+=4;else{let p;if((p=this.useFloat32)>0&&I<4294967296&&I>=-2147483648){l[m++]=202,v1.setFloat32(m,I);let n;if(p<4||(n=I*Z$[(l[m]&127)<<1|l[m+1]>>7])>>0===n){m+=4;return}else m--}l[m++]=203,v1.setFloat64(m,I),m+=8}else if(v==="object"||v==="function")if(!I)l[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)}l[m++]=214,l[m++]=112,v1.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)R(I);else if(p===Map)if(this.mapAsEmptyObject)l[m++]=128;else{if(y=I.size,y<16)l[m++]=128|y;else if(y<65536)l[m++]=222,l[m++]=y>>8,l[m++]=y&255;else l[m++]=223,v1.setUint32(m,y),m+=4;for(let[n,o]of I)M(n),M(o)}else{for(let n=0,o=sk.length;n<o;n++){let J0=M60[n];if(I instanceof J0){let Q0=sk[n];if(Q0.write){if(Q0.type)l[m++]=212,l[m++]=Q0.type,l[m++]=0;let i1=Q0.write.call(this,I);if(i1===I)if(Array.isArray(I))R(I);else T(I);else M(i1);return}let D0=l,C0=v1,a0=m;l=null;let E8;try{E8=Q0.pack.call(this,I,(i1)=>{if(l=D0,D0=null,m+=i1,m>J5)E(m);return{target:l,targetView:v1,position:m-i1}},M)}finally{if(D0)l=D0,v1=C0,m=a0,J5=l.length-10}if(E8){if(E8.length+m>J5)E(E8.length+m);m=bx1(E8,l,m,Q0.type)}return}}if(Array.isArray(I))R(I);else{if(I.toJSON){let n=I.toJSON();if(n!==I)return M(n)}if(v==="function")return M(this.writeFunction&&this.writeFunction(I));T(I)}}}else if(v==="boolean")l[m++]=I?195:194;else if(v==="bigint"){if(I<9223372036854776000&&I>=-9223372036854776000)l[m++]=211,v1.setBigInt64(m,I);else if(I<18446744073709552000&&I>0)l[m++]=207,v1.setBigUint64(m,I);else if(this.largeBigIntToFloat)l[m++]=203,v1.setFloat64(m,Number(I));else if(this.largeBigIntToString)return M(I.toString());else if((this.useBigIntExtension||this.moreTypes)&&I<BigInt(2)**BigInt(1023)&&I>-(BigInt(2)**BigInt(1023))){l[m++]=199,m++,l[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));l[m-2]=p.length;for(let o=p.length;o>0;)l[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(v==="undefined")if(this.encodeUndefinedAsNil)l[m++]=192;else l[m++]=212,l[m++]=0,l[m++]=0;else throw new Error("Unknown type: "+v)},D=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?(I)=>{let v;if(this.skipValues){v=[];for(let n in I)if((typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(n))&&!this.skipValues.includes(I[n]))v.push(n)}else v=Object.keys(I);let y=v.length;if(y<16)l[m++]=128|y;else if(y<65536)l[m++]=222,l[m++]=y>>8,l[m++]=y&255;else l[m++]=223,v1.setUint32(m,y),m+=4;let p;if(this.coercibleKeyAsNumber)for(let n=0;n<y;n++){p=v[n];let o=Number(p);M(isNaN(o)?p:o),M(I[p])}else for(let n=0;n<y;n++)M(p=v[n]),M(I[p])}:(I)=>{l[m++]=222;let v=m-X;m+=2;let y=0;for(let p in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(p))M(p),M(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');l[v+++X]=y>>8,l[v+X]=y&255},j=this.useRecords===!1?D:Z.progressiveRecords&&!F?(I)=>{let v,y=$.transitions||($.transitions=Object.create(null)),p=m++-X,n;for(let o in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(o)){if(v=y[o],v)y=v;else{let J0=Object.keys(I),Q0=y;y=$.transitions;let D0=0;for(let C0=0,a0=J0.length;C0<a0;C0++){let E8=J0[C0];if(v=y[E8],!v)v=y[E8]=Object.create(null),D0++;y=v}if(p+X+1==m)m--,A(y,J0,D0);else _(y,J0,p,D0);n=!0,y=Q0[o]}M(I[o])}if(!n){let o=y[O7];if(o)l[p+X]=o;else _(y,Object.keys(I),p,0)}}:(I)=>{let v,y=$.transitions||($.transitions=Object.create(null)),p=0;for(let o in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(o)){if(v=y[o],!v)v=y[o]=Object.create(null),p++;y=v}let n=y[O7];if(n)if(n>=96&&F)l[m++]=((n-=96)&31)+96,l[m++]=n>>5;else l[m++]=n;else A(y,y.__keys__||Object.keys(I),p);for(let o in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(o))M(I[o])},C=typeof this.useRecords=="function"&&this.useRecords,T=C?(I)=>{C(I)?j(I):D(I)}:j,E=(I)=>{let v;if(I>16777216){if(I-X>O60)throw new Error("Packed buffer would be larger than maximum buffer size");v=Math.min(O60,Math.round(Math.max((I-X)*(I>67108864?1.25:2),4194304)/4096)*4096)}else v=(Math.max(I-X<<2,l.length-1)>>12)+1<<12;let y=new Vw(v);if(v1=y.dataView||(y.dataView=new DataView(y.buffer,0,v)),I=Math.min(I,l.length),l.copy)l.copy(y,0,X,I);else y.set(l.slice(X,I));return m-=X,X=0,J5=y.length-10,l=y},A=(I,v,y)=>{let p=$.nextId;if(!p)p=64;if(p<q&&this.shouldShareStructure&&!this.shouldShareStructure(v)){if(p=$.nextOwnId,!(p<U))p=q;$.nextOwnId=p+1}else{if(p>=U)p=q;$.nextId=p+1}let n=v.highByte=p>=96&&F?p-96>>5:-1;if(I[O7]=p,I.__keys__=v,$[p-64]=v,p<q)if(v.isShared=!0,$.sharedLength=p-63,Y=!0,n>=0)l[m++]=(p&31)+96,l[m++]=n;else l[m++]=p;else{if(n>=0)l[m++]=213,l[m++]=114,l[m++]=(p&31)+96,l[m++]=n;else l[m++]=212,l[m++]=114,l[m++]=p;if(y)L+=w*y;if(B.length>=V)B.shift()[O7]=0;B.push(I),M(v)}},_=(I,v,y,p)=>{let n=l,o=m,J0=J5,Q0=X;if(l=Lz,m=0,X=0,!l)Lz=l=new Vw(8192);J5=l.length-10,A(I,v,p),Lz=l;let D0=m;if(l=n,m=o,J5=J0,X=Q0,D0>1){let C0=m+D0-1;if(C0>J5)E(C0);let a0=y+X;l.copyWithin(a0+D0,a0+1,m),l.set(Lz.slice(0,D0),a0),m=C0}else l[y+X]=Lz[0]},x=(I)=>{let v=j60(I,l,X,m,$,E,(y,p,n)=>{if(n)return Y=!0;m=p;let o=l;if(M(y),N(),o!==l)return{position:m,targetView:v1,target:l};return m},this);if(v===0)return T(I);m=v}}useBuffer(Z){l=Z,l.dataView||(l.dataView=new DataView(l.buffer,l.byteOffset,l.byteLength)),v1=l.dataView,m=0}set position(Z){m=Z}get position(){return m}clearSharedData(){if(this.structures)this.structures=[];if(this.typedStructs)this.typedStructs=[]}}M60=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,zw];sk=[{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)nk(Z,16,J);else ak(Bz?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let X=Z.constructor;if(X!==P60&&this.moreTypes)nk(Z,ik.indexOf(X.name),J);else ak(Z,J)}},{pack(Z,J){if(this.moreTypes)nk(Z,17,J);else ak(Bz?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let{target:X,position:Y}=J(1);X[Y]=193}}];function nk(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 ak(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 bx1(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 gx1(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 N60(Z,J,X){if(o1.length>0){v1.setUint32(o1.position+Z,m+X-o1.position-Z),o1.stringsPosition=m-Z;let Y=o1;o1=null,J(Y[0]),J(Y[1])}}function D60(Z,J){return Z.isCompatible=(X)=>{let Y=!X||(J.lastNamedStructuresLength||0)===X.length;if(!Y)J._mergeStructures(X);return Y},Z}function C60(Z,J){j60=Z,D60=J}var T60=new J$({useRecords:!1}),mx1=T60.pack,ux1=T60.pack;var dx1=512,lx1=1024,cx1=2048;var ok=3,nK=0,wz=2,Uw=1,tk=16,k60=["num","object","string","ascii"];k60[tk]="date";var ix1=[!1,!0,!0,!1,!1,!0,!0,!1],I60;try{new Function(""),I60=!0}catch(Z){}var X$,nx1=typeof Buffer!=="undefined",Lw,N7;try{Lw=new TextEncoder}catch(Z){}var ax1=nx1?function(Z,J,X){return Z.utf8Write(J,X,Z.byteLength-X)}:Lw&&Lw.encodeInto?function(Z,J,X){return Lw.encodeInto(J,Z.subarray(X)).written}:!1,ux6=Symbol("type"),dx6=Symbol("parent");C60(v60,ex1);function v60(Z,J,X,Y,$,Q,K,W){let G=W.typedStructs||(W.typedStructs=[]),H=J.dataView,z=(G.lastStringStart||100)+Y,V=J.length-10,F=Y;if(Y>V)J=Q(Y),H=J.dataView,Y-=X,F-=X,z-=X,X=0,V=J.length-10;let q,U=z,B=G.transitions||(G.transitions=Object.create(null)),L=G.nextId||G.length,w=L<15?1:L<240?2:L<61440?3:L<15728640?4:0;if(w===0)return 0;Y+=w;let N=[],R,M=0;for(let j in Z){let C=Z[j],T=B[j];if(!T)B[j]=T={key:j,parent:B,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};if(Y>V)J=Q(Y),H=J.dataView,Y-=X,F-=X,z-=X,U-=X,X=0,V=J.length-10;switch(typeof C){case"number":let E=C;if(L<200||!T.num64){if(E>>0===E&&E<536870912&&E>-520093696){if(E<246&&E>=0&&(T.num8&&!(L>200&&T.num32)||E<32&&!T.num32))B=T.num8||_5(T,nK,1),J[Y++]=E;else B=T.num32||_5(T,nK,4),H.setUint32(Y,E,!0),Y+=4;break}else if(E<4294967296&&E>=-2147483648){if(H.setFloat32(Y,E,!0),ix1[J[Y+3]>>>5]){let I;if((I=E*Z$[(J[Y+3]&127)<<1|J[Y+2]>>7])>>0===I){B=T.num32||_5(T,nK,4),Y+=4;break}}}}B=T.num64||_5(T,nK,8),H.setFloat64(Y,E,!0),Y+=8;break;case"string":let A=C.length;if(q=U-z,(A<<2)+U>V)J=Q((A<<2)+U),H=J.dataView,Y-=X,F-=X,z-=X,U-=X,X=0,V=J.length-10;if(A>65280+q>>2){N.push(j,C,Y-F);break}let _,x=U;if(A<64){let I,v,y;for(I=0;I<A;I++)if(v=C.charCodeAt(I),v<128)J[U++]=v;else if(v<2048)_=!0,J[U++]=v>>6|192,J[U++]=v&63|128;else if((v&64512)===55296&&((y=C.charCodeAt(I+1))&64512)===56320)_=!0,v=65536+((v&1023)<<10)+(y&1023),I++,J[U++]=v>>18|240,J[U++]=v>>12&63|128,J[U++]=v>>6&63|128,J[U++]=v&63|128;else _=!0,J[U++]=v>>12|224,J[U++]=v>>6&63|128,J[U++]=v&63|128}else U+=ax1(J,C,U),_=U-x>A;if(q<160||q<246&&(T.ascii8||T.string8)){if(_){if(!(B=T.string8))if(G.length>10&&(B=T.ascii8))B.__type=wz,T.ascii8=null,T.string8=B,K(null,0,!0);else B=_5(T,wz,1)}else if(q===0&&!R){R=!0,B=T.ascii0||_5(T,ok,0);break}else if(!(B=T.ascii8)&&!(G.length>10&&(B=T.string8)))B=_5(T,ok,1);J[Y++]=q}else B=T.string16||_5(T,wz,2),H.setUint16(Y,q,!0),Y+=2;break;case"object":if(C){if(C.constructor===Date)B=T.date64||_5(T,tk,8),H.setFloat64(Y,C.getTime(),!0),Y+=8;else N.push(j,C,M);break}else if(T=E60(T,Y,H,-10),T)B=T,Y=X$;else N.push(j,C,M);break;case"boolean":B=T.num8||T.ascii8||_5(T,nK,1),J[Y++]=C?249:248;break;case"undefined":if(T=E60(T,Y,H,-9),T)B=T,Y=X$;else N.push(j,C,M);break;default:N.push(j,C,M)}M++}for(let j=0,C=N.length;j<C;){let T=N[j++],E=N[j++],A=N[j++],_=B[T];if(!_)B[T]=_={key:T,parent:B,enumerationOffset:A-M,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null};let x;if(E){let I;if(q=U-z,q<65280)if(B=_.object16,B)I=2;else if(B=_.object32)I=4;else B=_5(_,Uw,2),I=2;else B=_.object32||_5(_,Uw,4),I=4;if(x=K(E,U),typeof x==="object")U=x.position,H=x.targetView,J=x.target,z-=X,Y-=X,F-=X,X=0;else U=x;if(I===2)H.setUint16(Y,q,!0),Y+=2;else H.setUint32(Y,q,!0),Y+=4}else B=_.object16||_5(_,Uw,2),H.setInt16(Y,E===null?-10:-9,!0),Y+=2;M++}let D=B[O7];if(D==null){D=W.typedStructs.length;let j=[],C=B,T,E;while((E=C.__type)!==void 0){let A=C.__size;C=C.__parent,T=C.key;let _=[E,A,T];if(C.enumerationOffset)_.push(C.enumerationOffset);j.push(_),C=C.parent}j.reverse(),B[O7]=D,W.typedStructs[D]=j,K(null,0,!0)}switch(w){case 1:if(D>=16)return 0;J[F]=D+32;break;case 2:if(D>=256)return 0;J[F]=56,J[F+1]=D;break;case 3:if(D>=65536)return 0;J[F]=57,H.setUint16(F+1,D,!0);break;case 4:if(D>=16777216)return 0;H.setUint32(F,(D<<8)+58,!0);break}if(Y<z){if(z===U)return Y;J.copyWithin(Y,z,U),U+=Y-z,G.lastStringStart=Y-F}else if(Y>z){if(z===U)return Y;return G.lastStringStart=Y-F,v60(Z,J,X,F,$,Q,K,W)}return U}function E60(Z,J,X,Y){let $;if($=Z.ascii8||Z.num8)return X.setInt8(J,Y,!0),X$=J+1,$;if($=Z.string16||Z.object16)return X.setInt16(J,Y,!0),X$=J+2,$;if($=Z.num32)return X.setUint32(J,3758096640+Y,!0),X$=J+4,$;if($=Z.num64)return X.setFloat64(J,NaN,!0),X.setInt8(J,Y),X$=J+8,$;X$=J;return}function _5(Z,J,X){let Y=k60[J]+(X<<3),$=Z[Y]||(Z[Y]=Object.create(null));return $.__type=J,$.__size=X,$.__parent=Z,$}function sx1(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,H,z]of K){let V=W[z];if(!V)W[z]=V={key:z,parent:W,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};W=_5(V,G,H)}W[O7]=$}return J.transitions=Y,this.typedStructs=J,this.lastTypedStructuresLength=J.length,X}var rk=Symbol.for("source");function ox1(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 z=[],V=0,F;for(let q=0,U=Q.length;q<U;q++){let B=Q[q],[L,w,N,R]=B;if(N==="__proto__")N="__proto_";let M={key:N,offset:V};if(R)z.splice(q+R,0,M);else z.push(M);let D;switch(w){case 0:D=()=>0;break;case 1:D=(C,T)=>{let E=C.bytes[T+M.offset];return E>=246?iK(E):E};break;case 2:D=(C,T)=>{let E=C.bytes,_=(E.dataView||(E.dataView=new DataView(E.buffer,E.byteOffset,E.byteLength))).getUint16(T+M.offset,!0);return _>=65280?iK(_&255):_};break;case 4:D=(C,T)=>{let E=C.bytes,_=(E.dataView||(E.dataView=new DataView(E.buffer,E.byteOffset,E.byteLength))).getUint32(T+M.offset,!0);return _>=4294967040?iK(_&255):_};break}M.getRef=D,V+=w;let j;switch(L){case ok:if(F&&!F.next)F.next=M;F=M,M.multiGetCount=0,j=function(C){let{bytes:T,position:E}=C,A=V+E,_=D(C,E);if(typeof _!=="number")return _;let x,I=M.next;while(I){if(x=I.getRef(C,E),typeof x==="number")break;else x=null;I=I.next}if(x==null)x=C.bytesEnd-A;if(C.srcString)return C.srcString.slice(_,x);return V60(T,_+A,x-_)};break;case wz:case Uw:if(F&&!F.next)F.next=M;F=M,j=function(C){let T=C.position,E=V+T,A=D(C,T);if(typeof A!=="number")return A;let _=C.bytes,x,I=M.next;while(I){if(x=I.getRef(C,T),typeof x==="number")break;else x=null;I=I.next}if(x==null)x=C.bytesEnd-E;if(L===wz)return _.toString("utf8",A+E,x+E);else{N7=C;try{return Y.unpack(_,{start:A+E,end:x+E})}finally{N7=null}}};break;case nK:switch(w){case 4:j=function(C){let T=C.bytes,E=T.dataView||(T.dataView=new DataView(T.buffer,T.byteOffset,T.byteLength)),A=C.position+M.offset,_=E.getInt32(A,!0);if(_<536870912){if(_>-520093696)return _;if(_>-536870912)return iK(_&255)}let x=E.getFloat32(A,!0),I=Z$[(T[A+3]&127)<<1|T[A+2]>>7];return(I*x+(x>0?0.5:-0.5)>>0)/I};break;case 8:j=function(C){let T=C.bytes,A=(T.dataView||(T.dataView=new DataView(T.buffer,T.byteOffset,T.byteLength))).getFloat64(C.position+M.offset,!0);if(isNaN(A)){let _=T[C.position+M.offset];if(_>=246)return iK(_)}return A};break;case 1:j=function(C){let E=C.bytes[C.position+M.offset];return E<246?E:iK(E)};break}break;case tk:j=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+M.offset,!0))};break}M.get=j}if(I60){let q=[],U=[],B=0,L;for(let N of z){if(Y.alwaysLazyProperty&&Y.alwaysLazyProperty(N.key)){L=!0;continue}Object.defineProperty(G,N.key,{get:rx1(N.get),enumerable:!0});let R="v"+B++;U.push(R),q.push("o["+JSON.stringify(N.key)+"]="+R+"(s)")}if(L)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,z.map((N)=>N.get));Object.defineProperty(G,"toJSON",{value(N){return w.call(this,this[rk])}})}else Object.defineProperty(G,"toJSON",{value(q){let U={};for(let B=0,L=z.length;B<L;B++){let w=z[B].key;U[w]=this[w]}return U}})}var H=new K;return H[rk]={bytes:Z,position:J,srcString:"",bytesEnd:X},H}function iK(Z){switch(Z){case 246:return null;case 247:return;case 248:return!1;case 249:return!0}throw new Error("Unknown constant")}function rx1(Z){return function(){return Z(this[rk])}}function tx1(){if(N7)N7.bytes=Uint8Array.prototype.slice.call(N7.bytes,N7.position,N7.bytesEnd),N7.position=0,N7.bytesEnd=N7.bytes.length}function ex1(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}w60(ox1,sx1,tx1);var Xh1=process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED!==void 0&&process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED.toLowerCase()==="true";if(!Xh1){let Z;try{if(Z=g("msgpackr-extract"),Z)F60(Z.extractStrings)}catch(J){}}import Pn1 from"mediasoup";var jO=r(zY0(),1);import Nn1 from"http";import Rn1 from"https";import PO from"fs";import Mn1 from"path";var hY0=r(AY0(),1);import N$ from"fs";import xY0 from"path";var wF="./dev/persistence";class E7{static instance=new E7;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;constructor(){try{this._creativeGateway=new hY0.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,V,J,F),V===W)return!0}return!1}let U;if(typeof H==="string")U=z===H,this.debug("string match",H,z,U);else U=H.test(z),this.debug("pattern match",H,z,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 Nc(this.pattern,this.options)}parse(Z){y3(Z);let J=this.options;if(Z==="**")return U6;if(Z==="")return"";let X,Y=null;if(X=Z.match(GL1))Y=J.dot?zL1:HL1;else if(X=Z.match(tU1))Y=(J.nocase?J.dot?XL1:JL1:J.dot?ZL1:eU1)(X[1]);else if(X=Z.match(FL1))Y=(J.nocase?J.dot?qL1:VL1:J.dot?UL1:LL1)(X);else if(X=Z.match(YL1))Y=J.dot?QL1:$L1;else if(X=Z.match(KL1))Y=WL1;let $=q6.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?OL1:J.dot?NL1:RL1,Y=new Set(J.nocase?["i"]:[]),$=Z.map((W)=>{let G=W.map((H)=>{if(H instanceof RegExp)for(let z of H.flags.split(""))Y.add(z);return typeof H==="string"?CL1(H):H===U6?U6:H._src});return G.forEach((H,z)=>{let V=G[z+1],F=G[z-1];if(H!==U6||F===U6)return;if(F===void 0)if(V!==void 0&&V!==U6)G[z+1]="(?:\\/|"+X+"\\/)?"+V;else G[z]=X;else if(V===void 0)G[z-1]=F+"(?:\\/|"+X+")?";else if(V!==U6)G[z-1]=F+"(?:\\/|\\/"+X+"\\/)"+V,G[z+1]=U6}),G.filter((H)=>H!==U6).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 l6.defaults(Z).Minimatch}}l6.AST=q6;l6.Minimatch=R9;l6.escape=tQ;l6.unescape=V4;import{fileURLToPath as YB1}from"node:url";var eQ=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,Mc=new Set,$D=typeof process==="object"&&!!process?process:{},Pc=(Z,J,X,Y)=>{typeof $D.emitWarning==="function"?$D.emitWarning(Z,J,X,Y):console.error(`[${X}] ${J}: ${Z}`)},EL=globalThis.AbortController,Rc=globalThis.AbortSignal;if(typeof EL==="undefined"){Rc=class X{onabort;_onabort=[];reason;aborted=!1;addEventListener(Y,$){this._onabort.push($)}},EL=class X{constructor(){J()}signal=new Rc;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=$D.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,Pc("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 TL1=(Z)=>!Mc.has(Z),SD6=Symbol("type"),RJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),jc=(Z)=>!RJ(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?g3:null;class g3 extends Array{constructor(Z){super(Z);this.fill(0)}}class ZK{heap;length;static#Z=!1;static create(Z){let J=jc(Z);if(!J)return[];ZK.#Z=!0;let X=new ZK(Z,J);return ZK.#Z=!1,X}constructor(Z,J){if(!ZK.#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 m3{#Z;#J;#Y;#X;#$;#z;#V;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#H;#F;#Q;#U;#B;#L;#O;#E;#N;#k;#P;#M;#R;#C;#w;#v;static unsafeExposeInternals(Z){return{starts:Z.#P,ttls:Z.#M,sizes:Z.#k,keyMap:Z.#H,keyList:Z.#F,valList:Z.#Q,next:Z.#U,prev:Z.#B,get head(){return Z.#L},get tail(){return Z.#O},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.#z}get memoMethod(){return this.#V}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:H,disposeAfter:z,noDisposeOnSet:V,noUpdateTTL:F,maxSize:q=0,maxEntrySize:U=0,sizeCalculation:B,fetchMethod:L,memoMethod:w,noDeleteOnFetchRejection:N,noDeleteOnStaleGet:R,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:D,ignoreFetchAbort:j}=Z;if(J!==0&&!RJ(J))throw new TypeError("max option must be a nonnegative integer");let C=J?jc(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=B,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.#V=w,L!==void 0&&typeof L!=="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#z=L,this.#C=!!L,this.#H=new Map,this.#F=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.#O=0,this.#E=ZK.create(J),this.#W=0,this.#G=0,typeof G==="function")this.#Y=G;if(typeof H==="function")this.#X=H;if(typeof z==="function")this.#$=z,this.#N=[];else this.#$=void 0,this.#N=void 0;if(this.#R=!!this.#Y,this.#v=!!this.#X,this.#w=!!this.#$,this.noDisposeOnSet=!!V,this.noUpdateTTL=!!F,this.noDeleteOnFetchRejection=!!N,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!j,this.maxEntrySize!==0){if(this.#J!==0){if(!RJ(this.#J))throw new TypeError("maxSize must be a positive integer if specified")}if(!RJ(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#m()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!R,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=RJ(Y)||Y===0?Y:1,this.ttlAutopurge=!!$,this.ttl=X||0,this.ttl){if(!RJ(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(TL1("LRU_CACHE_UNBOUNDED"))Mc.add("LRU_CACHE_UNBOUNDED"),Pc("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",m3)}}getRemainingTTL(Z){return this.#H.has(Z)?1/0:0}#K(){let Z=new g3(this.#Z),J=new g3(this.#Z);this.#M=Z,this.#P=J,this.#_=($,Q,K=eQ.now())=>{if(J[$]=Q!==0?K:0,Z[$]=Q,Q!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#D($))this.#S(this.#F[$],"expire")},Q+1);if(W.unref)W.unref()}},this.#A=($)=>{J[$]=Z[$]!==0?eQ.now():0},this.#j=($,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 $=eQ.now();if(this.ttlResolution>0){X=$;let Q=setTimeout(()=>X=0,this.ttlResolution);if(Q.unref)Q.unref()}return $};this.getRemainingTTL=($)=>{let Q=this.#H.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=()=>{};#j=()=>{};#_=()=>{};#D=()=>!1;#m(){let Z=new g3(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(!RJ(Y))if($){if(typeof $!=="function")throw new TypeError("sizeCalculation must be a function");if(Y=$(X,J),!RJ(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.#O;;){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.#O)break;else J=this.#U[J]}}#d(Z){return Z!==void 0&&this.#H.get(this.#F[Z])===Z}*entries(){for(let Z of this.#T())if(this.#Q[Z]!==void 0&&this.#F[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#F[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#I())if(this.#Q[Z]!==void 0&&this.#F[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#F[Z],this.#Q[Z]]}*keys(){for(let Z of this.#T()){let J=this.#F[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#I()){let J=this.#F[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.#F[X],this))return this.get(this.#F[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.#F[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.#F[X],this)}}purgeStale(){let Z=!1;for(let J of this.#I({allowStale:!0}))if(this.#D(J))this.#S(this.#F[J],"expire"),Z=!0;return Z}info(Z){let J=this.#H.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.#M&&this.#P){let Q=this.#M[J],K=this.#P[J];if(Q&&K){let W=Q-(eQ.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.#F[J],Y=this.#Q[J],$=this.#q(Y)?Y.__staleWhileFetching:Y;if($===void 0||X===void 0)continue;let Q={value:$};if(this.#M&&this.#P){Q.ttl=this.#M[J];let K=eQ.now()-this.#P[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=eQ.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,H=this.#u(Z,J,X.size||0,K);if(this.maxEntrySize&&H>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#S(Z,"set"),this}let z=this.#W===0?void 0:this.#H.get(Z);if(z===void 0){if(z=this.#W===0?this.#O:this.#E.length!==0?this.#E.pop():this.#W===this.#Z?this.#y(!1):this.#W,this.#F[z]=Z,this.#Q[z]=J,this.#H.set(Z,z),this.#U[this.#O]=z,this.#B[z]=this.#O,this.#O=z,this.#W++,this.#f(z,H,W),W)W.set="add";if(G=!1,this.#v)this.#X?.(J,Z,"add")}else{this.#b(z);let V=this.#Q[z];if(J!==V){if(this.#C&&this.#q(V)){V.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:F}=V;if(F!==void 0&&!Q){if(this.#R)this.#Y?.(F,Z,"set");if(this.#w)this.#N?.push([F,Z,"set"])}}else if(!Q){if(this.#R)this.#Y?.(V,Z,"set");if(this.#w)this.#N?.push([V,Z,"set"])}if(this.#x(z),this.#f(z,H,W),this.#Q[z]=J,W){W.set="replace";let F=V&&this.#q(V)?V.__staleWhileFetching:V;if(F!==void 0)W.oldValue=F}}else if(W)W.set="update";if(this.#v)this.onInsert?.(J,Z,J===V?"update":"replace")}if(Y!==0&&!this.#M)this.#K();if(this.#M){if(!G)this.#_(z,Y,$);if(W)this.#j(W,z)}if(!Q&&this.#w&&this.#N){let V=this.#N,F;while(F=V?.shift())this.#$?.(...F)}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.#N){let Z=this.#N,J;while(J=Z?.shift())this.#$?.(...J)}}}#y(Z){let J=this.#L,X=this.#F[J],Y=this.#Q[J];if(this.#C&&this.#q(Y))Y.__abortController.abort(new Error("evicted"));else if(this.#R||this.#w){if(this.#R)this.#Y?.(Y,X,"evict");if(this.#w)this.#N?.push([Y,X,"evict"])}if(this.#x(J),Z)this.#F[J]=void 0,this.#Q[J]=void 0,this.#E.push(J);if(this.#W===1)this.#L=this.#O=0,this.#E.length=0;else this.#L=this.#U[J];return this.#H.delete(X),this.#W--,J}has(Z,J={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:Y}=J,$=this.#H.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.#j(Y,$);return!0}else if(Y)Y.has="stale",this.#j(Y,$)}else if(Y)Y.has="miss";return!1}peek(Z,J={}){let{allowStale:X=this.allowStale}=J,Y=this.#H.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 EL,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:Y},G=(U,B=!1)=>{let{aborted:L}=Q.signal,w=X.ignoreFetchAbort&&U!==void 0;if(X.status)if(L&&!B){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,w)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(L&&!w&&!B)return z(Q.signal.reason);let N=F;if(this.#Q[J]===F)if(U===void 0)if(N.__staleWhileFetching)this.#Q[J]=N.__staleWhileFetching;else this.#S(Z,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Z,U,W.options)}return U},H=(U)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=U;return z(U)},z=(U)=>{let{aborted:B}=Q.signal,L=B&&X.allowStaleOnFetchAbort,w=L||X.allowStaleOnFetchRejection,N=w||X.noDeleteOnFetchRejection,R=F;if(this.#Q[J]===F){if(!N||R.__staleWhileFetching===void 0)this.#S(Z,"fetch");else if(!L)this.#Q[J]=R.__staleWhileFetching}if(w){if(X.status&&R.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return R.__staleWhileFetching}else if(R.__returned===R)throw U},V=(U,B)=>{let L=this.#z?.(Z,$,W);if(L&&L instanceof Promise)L.then((w)=>U(w===void 0?void 0:w),B);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 F=new Promise(V).then(G,H),q=Object.assign(F,{__abortController:Q,__staleWhileFetching:$,__returned:void 0});if(J===void 0)this.set(Z,q,{...W.options,status:void 0}),J=this.#H.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 EL}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:H=this.noUpdateTTL,noDeleteOnFetchRejection:z=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:V=this.allowStaleOnFetchRejection,ignoreFetchAbort:F=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:U,forceRefresh:B=!1,status:L,signal:w}=J;if(!this.#C){if(L)L.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,status:L})}let N={allowStale:X,updateAgeOnGet:Y,noDeleteOnStaleGet:$,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:H,noDeleteOnFetchRejection:z,allowStaleOnFetchRejection:V,allowStaleOnFetchAbort:q,ignoreFetchAbort:F,status:L,signal:w},R=this.#H.get(Z);if(R===void 0){if(L)L.fetch="miss";let M=this.#h(Z,R,N,U);return M.__returned=M}else{let M=this.#Q[R];if(this.#q(M)){let E=X&&M.__staleWhileFetching!==void 0;if(L){if(L.fetch="inflight",E)L.returnedStale=!0}return E?M.__staleWhileFetching:M.__returned=M}let D=this.#D(R);if(!B&&!D){if(L)L.fetch="hit";if(this.#b(R),Y)this.#A(R);if(L)this.#j(L,R);return M}let j=this.#h(Z,R,N,U),T=j.__staleWhileFetching!==void 0&&X;if(L){if(L.fetch=D?"stale":"refresh",T&&D)L.returnedStale=!0}return T?j.__staleWhileFetching:j.__returned=j}}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.#V;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.#H.get(Z);if(K!==void 0){let W=this.#Q[K],G=this.#q(W);if(Q)this.#j(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"}#l(Z,J){this.#B[J]=Z,this.#U[Z]=J}#b(Z){if(Z!==this.#O){if(Z===this.#L)this.#L=this.#U[Z];else this.#l(this.#B[Z],this.#U[Z]);this.#l(this.#O,Z),this.#O=Z}}delete(Z){return this.#S(Z,"delete")}#S(Z,J){let X=!1;if(this.#W!==0){let Y=this.#H.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.#R||this.#w){if(this.#R)this.#Y?.($,Z,J);if(this.#w)this.#N?.push([$,Z,J])}if(this.#H.delete(Z),this.#F[Y]=void 0,this.#Q[Y]=void 0,Y===this.#O)this.#O=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.#N?.length){let Y=this.#N,$;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.#F[J];if(this.#R)this.#Y?.(X,Y,Z);if(this.#w)this.#N?.push([X,Y,Z])}}if(this.#H.clear(),this.#Q.fill(void 0),this.#F.fill(void 0),this.#M&&this.#P)this.#M.fill(0),this.#P.fill(0);if(this.#k)this.#k.fill(0);if(this.#L=0,this.#O=0,this.#E.length=0,this.#G=0,this.#W=0,this.#w&&this.#N){let J=this.#N,X;while(X=J?.shift())this.#$?.(...X)}}}import{posix as yL1,win32 as UD}from"node:path";import{fileURLToPath as bL1}from"node:url";import{lstatSync as gL1,readdir as mL1,readdirSync as uL1,readlinkSync as dL1,realpathSync as lL1}from"fs";import*as cL1 from"node:fs";import{lstat as iL1,readdir as nL1,readlink as aL1,realpath as sL1}from"node:fs/promises";import{EventEmitter as zD}from"node:events";import kc from"node:stream";import{StringDecoder as EL1}from"node:string_decoder";var Dc=typeof process==="object"&&process?process:{stdout:null,stderr:null},kL1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof qY||Z instanceof kc||IL1(Z)||vL1(Z)),IL1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof zD&&typeof Z.pipe==="function"&&Z.pipe!==kc.Writable.prototype.pipe,vL1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof zD&&typeof Z.write==="function"&&typeof Z.end==="function",GZ=Symbol("EOF"),HZ=Symbol("maybeEmitEnd"),MJ=Symbol("emittedEnd"),kL=Symbol("emittingEnd"),u3=Symbol("emittedError"),IL=Symbol("closed"),Cc=Symbol("read"),vL=Symbol("flush"),Tc=Symbol("flushChunk"),q4=Symbol("encoding"),JK=Symbol("decoder"),a8=Symbol("flowing"),d3=Symbol("paused"),XK=Symbol("resume"),s8=Symbol("buffer"),c6=Symbol("pipes"),o8=Symbol("bufferLength"),QD=Symbol("bufferPush"),_L=Symbol("bufferShift"),C6=Symbol("objectMode"),B8=Symbol("destroyed"),KD=Symbol("error"),WD=Symbol("emitData"),Ec=Symbol("emitEnd"),GD=Symbol("emitEnd2"),J7=Symbol("async"),HD=Symbol("abort"),SL=Symbol("aborted"),l3=Symbol("signal"),VY=Symbol("dataListeners"),l5=Symbol("discarded"),c3=(Z)=>Promise.resolve().then(Z),_L1=(Z)=>Z(),SL1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",AL1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,xL1=(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[XK](),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 Ic 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 hL1=(Z)=>!!Z.objectMode,fL1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class qY extends zD{[a8]=!1;[d3]=!1;[c6]=[];[s8]=[];[C6];[q4];[J7];[JK];[GZ]=!1;[MJ]=!1;[kL]=!1;[IL]=!1;[u3]=null;[o8]=0;[B8]=!1;[l3];[SL]=!1;[VY]=0;[l5]=!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(hL1(J))this[C6]=!0,this[q4]=null;else if(fL1(J))this[q4]=J.encoding,this[C6]=!1;else this[C6]=!1,this[q4]=null;if(this[J7]=!!J.async,this[JK]=this[q4]?new EL1(this[q4]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[s8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[c6]});let{signal:X}=J;if(X)if(this[l3]=X,X.aborted)this[HD]();else X.addEventListener("abort",()=>this[HD]())}get bufferLength(){return this[o8]}get encoding(){return this[q4]}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[C6]}set objectMode(Z){throw new Error("objectMode must be set at instantiation time")}get["async"](){return this[J7]}set["async"](Z){this[J7]=this[J7]||!!Z}[HD](){this[SL]=!0,this.emit("abort",this[l3]?.reason),this.destroy(this[l3]?.reason)}get aborted(){return this[SL]}set aborted(Z){}write(Z,J,X){if(this[SL])return!1;if(this[GZ])throw new Error("write after end");if(this[B8])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[J7]?c3:_L1;if(!this[C6]&&!Buffer.isBuffer(Z)){if(xL1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(AL1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw new Error("Non-contiguous data written to non-objectMode stream")}if(this[C6]){if(this[a8]&&this[o8]!==0)this[vL](!0);if(this[a8])this.emit("data",Z);else this[QD](Z);if(this[o8]!==0)this.emit("readable");if(X)Y(X);return this[a8]}if(!Z.length){if(this[o8]!==0)this.emit("readable");if(X)Y(X);return this[a8]}if(typeof Z==="string"&&!(J===this[q4]&&!this[JK]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[q4])Z=this[JK].write(Z);if(this[a8]&&this[o8]!==0)this[vL](!0);if(this[a8])this.emit("data",Z);else this[QD](Z);if(this[o8]!==0)this.emit("readable");if(X)Y(X);return this[a8]}read(Z){if(this[B8])return null;if(this[l5]=!1,this[o8]===0||Z===0||Z&&Z>this[o8])return this[HZ](),null;if(this[C6])Z=null;if(this[s8].length>1&&!this[C6])this[s8]=[this[q4]?this[s8].join(""):Buffer.concat(this[s8],this[o8])];let J=this[Cc](Z||null,this[s8][0]);return this[HZ](),J}[Cc](Z,J){if(this[C6])this[_L]();else{let X=J;if(Z===X.length||Z===null)this[_L]();else if(typeof X==="string")this[s8][0]=X.slice(Z),J=X.slice(0,Z),this[o8]-=Z;else this[s8][0]=X.subarray(Z),J=X.subarray(0,Z),this[o8]-=Z}if(this.emit("data",J),!this[s8].length&&!this[GZ])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[GZ]=!0,this.writable=!1,this[a8]||!this[d3])this[HZ]();return this}[XK](){if(this[B8])return;if(!this[VY]&&!this[c6].length)this[l5]=!0;if(this[d3]=!1,this[a8]=!0,this.emit("resume"),this[s8].length)this[vL]();else if(this[GZ])this[HZ]();else this.emit("drain")}resume(){return this[XK]()}pause(){this[a8]=!1,this[d3]=!0,this[l5]=!1}get destroyed(){return this[B8]}get flowing(){return this[a8]}get paused(){return this[d3]}[QD](Z){if(this[C6])this[o8]+=1;else this[o8]+=Z.length;this[s8].push(Z)}[_L](){if(this[C6])this[o8]-=1;else this[o8]-=this[s8][0].length;return this[s8].shift()}[vL](Z=!1){do;while(this[Tc](this[_L]())&&this[s8].length);if(!Z&&!this[s8].length&&!this[GZ])this.emit("drain")}[Tc](Z){return this.emit("data",Z),this[a8]}pipe(Z,J){if(this[B8])return Z;this[l5]=!1;let X=this[MJ];if(J=J||{},Z===Dc.stdout||Z===Dc.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[c6].push(!J.proxyErrors?new FD(this,Z,J):new Ic(this,Z,J)),this[J7])c3(()=>this[XK]());else this[XK]();return Z}unpipe(Z){let J=this[c6].find((X)=>X.dest===Z);if(J){if(this[c6].length===1){if(this[a8]&&this[VY]===0)this[a8]=!1;this[c6]=[]}else this[c6].splice(this[c6].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[l5]=!1,this[VY]++,!this[c6].length&&!this[a8])this[XK]()}else if(Z==="readable"&&this[o8]!==0)super.emit("readable");else if(SL1(Z)&&this[MJ])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[u3]){let Y=J;if(this[J7])c3(()=>Y.call(this,this[u3]));else Y.call(this,this[u3])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[VY]=this.listeners("data").length,this[VY]===0&&!this[l5]&&!this[c6].length)this[a8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[VY]=0,!this[l5]&&!this[c6].length)this[a8]=!1}return J}get emittedEnd(){return this[MJ]}[HZ](){if(!this[kL]&&!this[MJ]&&!this[B8]&&this[s8].length===0&&this[GZ]){if(this[kL]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[IL])this.emit("close");this[kL]=!1}}emit(Z,...J){let X=J[0];if(Z!=="error"&&Z!=="close"&&Z!==B8&&this[B8])return!1;else if(Z==="data")return!this[C6]&&!X?!1:this[J7]?(c3(()=>this[WD](X)),!0):this[WD](X);else if(Z==="end")return this[Ec]();else if(Z==="close"){if(this[IL]=!0,!this[MJ]&&!this[B8])return!1;let $=super.emit("close");return this.removeAllListeners("close"),$}else if(Z==="error"){this[u3]=X,super.emit(KD,X);let $=!this[l3]||this.listeners("error").length?super.emit("error",X):!1;return this[HZ](),$}else if(Z==="resume"){let $=super.emit("resume");return this[HZ](),$}else if(Z==="finish"||Z==="prefinish"){let $=super.emit(Z);return this.removeAllListeners(Z),$}let Y=super.emit(Z,...J);return this[HZ](),Y}[WD](Z){for(let X of this[c6])if(X.dest.write(Z)===!1)this.pause();let J=this[l5]?!1:super.emit("data",Z);return this[HZ](),J}[Ec](){if(this[MJ])return!1;return this[MJ]=!0,this.readable=!1,this[J7]?(c3(()=>this[GD]()),!0):this[GD]()}[GD](){if(this[JK]){let J=this[JK].end();if(J){for(let X of this[c6])X.dest.write(J);if(!this[l5])super.emit("data",J)}}for(let J of this[c6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[C6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[C6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[C6])throw new Error("cannot concat in objectMode");let Z=await this.collect();return this[q4]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(B8,()=>J(new Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[l5]=!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[GZ])return J();let $,Q,K=(z)=>{this.off("data",W),this.off("end",G),this.off(B8,H),J(),Q(z)},W=(z)=>{this.off("error",K),this.off("end",G),this.off(B8,H),this.pause(),$({value:z,done:!!this[GZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(B8,H),J(),$({done:!0,value:void 0})},H=()=>K(new Error("stream destroyed"));return new Promise((z,V)=>{Q=V,$=z,this.once(B8,H),this.once("error",K),this.once("end",G),this.once("data",W)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[l5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(KD,J),this.off(B8,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(KD,J),this.once(B8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[B8]){if(Z)this.emit("error",Z);else this.emit(B8);return this}this[B8]=!0,this[l5]=!0,this[s8].length=0,this[o8]=0;let J=this;if(typeof J.close==="function"&&!this[IL])J.close();if(Z)this.emit("error",Z);else this.emit(B8);return this}static get isStream(){return kL1}}var pL1=lL1.native,i3={lstatSync:gL1,readdir:mL1,readdirSync:uL1,readlinkSync:dL1,realpathSync:pL1,promises:{lstat:iL1,readdir:nL1,readlink:aL1,realpath:sL1}},xc=(Z)=>!Z||Z===i3||Z===cL1?i3:{...i3,...Z,promises:{...i3.promises,...Z.promises||{}}},hc=/^\\\\\?\\([a-z]:)\\?$/i,oL1=(Z)=>Z.replace(/\//g,"\\").replace(hc,"$1\\"),rL1=/[\\\/]/,P9=0,fc=1,yc=2,X7=4,bc=6,gc=8,UY=10,mc=12,M9=15,p3=~M9,VD=16,vc=32,n3=64,U4=128,AL=256,hL=512,_c=n3|U4|hL,tL1=1023,qD=(Z)=>Z.isFile()?gc:Z.isDirectory()?X7:Z.isSymbolicLink()?UY:Z.isCharacterDevice()?yc:Z.isBlockDevice()?bc:Z.isSocket()?mc:Z.isFIFO()?fc:P9,Sc=new Map,a3=(Z)=>{let J=Sc.get(Z);if(J)return J;let X=Z.normalize("NFKD");return Sc.set(Z,X),X},Ac=new Map,xL=(Z)=>{let J=Ac.get(Z);if(J)return J;let X=a3(Z.toLowerCase());return Ac.set(Z,X),X};class LD extends m3{constructor(){super({max:256})}}class uc extends m3{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var dc=Symbol("PathScurry setAsCwd");class p6{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.#$}#z;get gid(){return this.#z}#V;get rdev(){return this.#V}#W;get blksize(){return this.#W}#G;get ino(){return this.#G}#H;get size(){return this.#H}#F;get blocks(){return this.#F}#Q;get atimeMs(){return this.#Q}#U;get mtimeMs(){return this.#U}#B;get ctimeMs(){return this.#B}#L;get birthtimeMs(){return this.#L}#O;get atime(){return this.#O}#E;get mtime(){return this.#E}#N;get ctime(){return this.#N}#k;get birthtime(){return this.#k}#P;#M;#R;#C;#w;#v;#K;#A;#j;#_;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=P9,X,Y,$,Q,K){if(this.name=Z,this.#P=$?xL(Z):a3(Z),this.#K=J&tL1,this.nocase=$,this.roots=Y,this.root=X||this,this.#A=Q,this.#R=K.fullpath,this.#w=K.relative,this.#v=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=xc(K.fs)}depth(){if(this.#M!==void 0)return this.#M;if(!this.parent)return this.#M=0;return this.#M=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&=~VD,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),Y=this.nocase?xL(Z):a3(Z);for(let W of X)if(W.#P===Y)return W;let $=this.parent?this.sep:"",Q=this.#R?this.#R+$+Z:void 0,K=this.newChild(Z,P9,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=U4;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.#v!==void 0)return this.#v;let Z=this.name,J=this.parent;if(!J)return this.#v=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#R!==void 0)return this.#R;let Z=this.name,J=this.parent;if(!J)return this.#R=this.name;let Y=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#R=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&M9)===P9}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&M9)===gc}isDirectory(){return(this.#K&M9)===X7}isCharacterDevice(){return(this.#K&M9)===yc}isBlockDevice(){return(this.#K&M9)===bc}isFIFO(){return(this.#K&M9)===fc}isSocket(){return(this.#K&M9)===mc}isSymbolicLink(){return(this.#K&UY)===UY}lstatCached(){return this.#K&vc?this:void 0}readlinkCached(){return this.#j}realpathCached(){return this.#_}readdirCached(){let Z=this.children();return Z.slice(0,Z.provisional)}canReadlink(){if(this.#j)return!0;if(!this.parent)return!1;let Z=this.#K&M9;return!(Z!==P9&&Z!==UY||this.#K&AL||this.#K&U4)}calledReaddir(){return!!(this.#K&VD)}isENOENT(){return!!(this.#K&U4)}isNamed(Z){return!this.nocase?this.#P===a3(Z):this.#P===xL(Z)}async readlink(){let Z=this.#j;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.#j=X}catch(J){this.#y(J.code);return}}readlinkSync(){let Z=this.#j;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.#j=X}catch(J){this.#y(J.code);return}}#m(Z){this.#K|=VD;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#x()}}#x(){if(this.#K&U4)return;this.#K=(this.#K|U4)&p3,this.#f()}#f(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#x()}#u(){this.#K|=hL,this.#T()}#T(){if(this.#K&n3)return;let Z=this.#K;if((Z&M9)===X7)Z&=p3;this.#K=Z|n3,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|=AL,Z==="ENOENT")J|=U4;if(Z==="EINVAL"||Z==="UNKNOWN")J&=p3;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#T()}#h(Z,J){return this.#l(Z,J)||this.#q(Z,J)}#q(Z,J){let X=qD(Z),Y=this.newChild(Z.name,X,{parent:this}),$=Y.#K&M9;if($!==X7&&$!==UY&&$!==P9)Y.#K|=n3;return J.unshift(Y),J.provisional++,Y}#l(Z,J){for(let X=J.provisional;X<J.length;X++){let Y=J[X];if((this.nocase?xL(Z.name):a3(Z.name))!==Y.#P)continue;return this.#b(Z,Y,X,J)}}#b(Z,J,X,Y){let $=J.name;if(J.#K=J.#K&p3|qD(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&U4)===0)try{return this.#S(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#d(Z.code)}}lstatSync(){if((this.#K&U4)===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:H,gid:z,ino:V,mode:F,mtime:q,mtimeMs:U,nlink:B,rdev:L,size:w,uid:N}=Z;this.#O=J,this.#Q=X,this.#k=Y,this.#L=$,this.#W=Q,this.#F=K,this.#N=W,this.#B=G,this.#J=H,this.#z=z,this.#G=V,this.#Y=F,this.#E=q,this.#U=U,this.#X=B,this.#V=L,this.#H=w,this.#$=N;let R=qD(Z);if(this.#K=this.#K&p3|R|vc,R!==P9&&R!==X7&&R!==UY)this.#K|=n3}#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})}#c;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.#c)await this.#c;else{let X=()=>{};this.#c=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.#c=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&_c)return!1;let Z=M9&this.#K;if(!(Z===P9||Z===X7||Z===UY))return!1;return!0}shouldWalk(Z,J){return(this.#K&X7)===X7&&!(this.#K&_c)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#_)return this.#_;if((hL|AL|U4)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#_=this.resolve(Z)}catch(Z){this.#u()}}realpathSync(){if(this.#_)return this.#_;if((hL|AL|U4)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#_=this.resolve(Z)}catch(Z){this.#u()}}[dc](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.#v=X.join("/"),Y=Y.parent,X.push("..");Y=Z;while(Y&&Y.parent&&!J.has(Y))Y.#w=void 0,Y.#v=void 0,Y=Y.parent}}class fL extends p6{sep="\\";splitSep=rL1;constructor(Z,J=P9,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}newChild(Z,J=P9,X={}){return new fL(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return UD.parse(Z).root}getRoot(Z){if(Z=oL1(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 s3(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(hc,"$1\\"),Z===J}}class yL extends p6{splitSep="/";sep="/";constructor(Z,J=P9,X,Y,$,Q,K){super(Z,J,X,Y,$,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=P9,X={}){return new yL(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class BD{root;rootPath;roots;cwd;#Z;#J;#Y;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:Y,childrenCacheSize:$=16384,fs:Q=i3}={}){if(this.#X=xc(Q),Z instanceof URL||Z.startsWith("file://"))Z=bL1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new LD,this.#J=new LD,this.#Y=new uc($);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,H=W.length-1,z=J.sep,V=this.rootPath,F=!1;for(let q of W){let U=H--;G=G.child(q,{relative:new Array(U).fill("..").join(z),relativePosix:new Array(U).fill("..").join("/"),fullpath:V+=(F?"":z)+q}),F=!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 p6))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 p6))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 p6))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 p6))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 p6))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 p6))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 p6))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=(z,V)=>{W.add(z),z.readdirCB((F,q)=>{if(F)return V(F);let U=q.length;if(!U)return V();let B=()=>{if(--U===0)V()};for(let L of q){if(!$||$(L))K.push(X?L:L.fullpath());if(Y&&L.isSymbolicLink())L.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(W,Q)?G(w,B):B());else if(L.shouldWalk(W,Q))G(L,B);else B()}},!0)},H=Z;return new Promise((z,V)=>{G(H,(F)=>{if(F)return V(F);z(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof p6))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 H=G.readdirSync();for(let z of H){if(!$||$(z))K.push(X?z:z.fullpath());let V=z;if(z.isSymbolicLink()){if(!(Y&&(V=z.realpathSync())))continue;if(V.isUnknown())V.lstatSync()}if(V.shouldWalk(W,Q))W.add(V)}}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 p6))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 p6))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 H of G){if(!$||$(H))yield X?H:H.fullpath();let z=H;if(H.isSymbolicLink()){if(!(Y&&(z=H.realpathSync())))continue;if(z.isUnknown())z.lstatSync()}if(z.shouldWalk(K,Q))K.add(z)}}}stream(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof p6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new qY({objectMode:!0});if(!$||$(Z))K.write(X?Z:Z.fullpath());let W=new Set,G=[Z],H=0,z=()=>{let V=!1;while(!V){let F=G.shift();if(!F){if(H===0)K.end();return}H++,W.add(F);let q=(B,L,w=!1)=>{if(B)return K.emit("error",B);if(Y&&!w){let N=[];for(let R of L)if(R.isSymbolicLink())N.push(R.realpath().then((M)=>M?.isUnknown()?M.lstat():M));if(N.length){Promise.all(N).then(()=>q(null,L,!0));return}}for(let N of L)if(N&&(!$||$(N))){if(!K.write(X?N:N.fullpath()))V=!0}H--;for(let N of L){let R=N.realpathCached()||N;if(R.shouldWalk(W,Q))G.push(R)}if(V&&!K.flowing)K.once("drain",z);else if(!U)z()},U=!0;F.readdirCB(q,!0),U=!1}};return z(),K}streamSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof p6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:Y=!1,filter:$,walkFilter:Q}=J,K=new qY({objectMode:!0}),W=new Set;if(!$||$(Z))K.write(X?Z:Z.fullpath());let G=[Z],H=0,z=()=>{let V=!1;while(!V){let F=G.shift();if(!F){if(H===0)K.end();return}H++,W.add(F);let q=F.readdirSync();for(let U of q)if(!$||$(U)){if(!K.write(X?U:U.fullpath()))V=!0}H--;for(let U of q){let B=U;if(U.isSymbolicLink()){if(!(Y&&(B=U.realpathSync())))continue;if(B.isUnknown())B.lstatSync()}if(B.shouldWalk(W,Q))G.push(B)}}if(V&&!K.flowing)K.once("drain",z)};return z(),K}chdir(Z=this.cwd){let J=this.cwd;this.cwd=typeof Z==="string"?this.cwd.resolve(Z):Z,this.cwd[dc](J)}}class s3 extends BD{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,UD,"\\",{...J,nocase:X});this.nocase=X;for(let Y=this.cwd;Y;Y=Y.parent)Y.nocase=this.nocase}parseRootPath(Z){return UD.parse(Z).root.toUpperCase()}newRoot(Z){return new fL(this.rootPath,X7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class o3 extends BD{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,yL1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new yL(this.rootPath,X7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class bL extends o3{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var cD6=process.platform==="win32"?fL:yL,lc=process.platform==="win32"?s3:process.platform==="darwin"?bL:o3;var eL1=(Z)=>Z.length>=1,ZB1=(Z)=>Z.length>=1;class YK{#Z;#J;#Y;length;#X;#$;#z;#V;#W;#G;#H=!0;constructor(Z,J,X,Y){if(!eL1(Z))throw new TypeError("empty pattern list");if(!ZB1(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,[H,z,V,F,...q]=this.#J;if(G[0]==="")G.shift(),q.shift();let U=[$,Q,K,W,""].join("/"),B=[H,z,V,F,""].join("/");this.#Z=[U,...G],this.#J=[B,...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=$+"/",H=K+"/";this.#Z=[G,...Q],this.#J=[H,...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]===U6}isRegExp(){return this.#Z[this.#Y]instanceof RegExp}globString(){return this.#z=this.#z||(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 YK(this.#Z,this.#J,this.#Y+1,this.#X),this.#$.#G=this.#G,this.#$.#W=this.#W,this.#$.#V=this.#V,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.#V!==void 0?this.#V:this.#V=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.#H)}markFollowGlobstar(){if(this.#Y===0||!this.isGlobstar()||!this.#H)return!1;return this.#H=!1,!0}}var JB1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class r3{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:Y,noglobstar:$,platform:Q=JB1}){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 R9(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 YK(Y,$,0,this.platform),K=new R9(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 wD{store;constructor(Z=new Map){this.store=Z}copy(){return new wD(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 cc{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 pc{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 t3{hasWalkedCache;matches=new cc;subwalks=new pc;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new wD}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 z=$.rest();if(!z){this.matches.add(Y,!0,!1);continue}else $=z}if(Y.isENOENT())continue;let W,G,H=!1;while(typeof(W=$.pattern())==="string"&&(G=$.rest()))Y=Y.resolve(W),$=G,H=!0;if(W=$.pattern(),G=$.rest(),H){if(this.hasWalkedCache.hasWalked(Y,$))continue;this.hasWalkedCache.storeWalked(Y,$)}if(typeof W==="string"){let z=W===".."||W===""||W===".";this.matches.add(Y.resolve(W),K,z);continue}else if(W===U6){if(!Y.isSymbolicLink()||this.follow||$.checkFollowGlobstar())this.subwalks.add(Y,$);let z=G?.pattern(),V=G?.rest();if(!G||(z===""||z===".")&&!V)this.matches.add(Y,K,z===""||z===".");else if(z===".."){let F=Y.parent||Y;if(!V)this.matches.add(F,K,!0);else if(!this.hasWalkedCache.hasWalked(F,V))this.subwalks.add(F,V)}}else if(W instanceof RegExp)this.subwalks.add(Y,$)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new t3(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===U6)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 XB1=(Z,J)=>typeof Z==="string"?new r3([Z],J):Array.isArray(Z)?new r3(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=XB1(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 t3(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,H)=>this.walkCB3(K,H,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 t3(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 gL 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 mL extends OD{results;constructor(Z,J,X){super(Z,J,X);this.results=new qY({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 $B1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Y7{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=YB1(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||$B1,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"?s3:J.platform==="darwin"?bL:J.platform?o3:lc;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 R9(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 H=K[G];if(!H)throw new Error("invalid pattern object");return new YK(W,H,0,this.platform)})}async walk(){return[...await new gL(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 gL(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 mL(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 mL(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 R9(X,J).hasMagic())return!0;return!1};function dL(Z,J={}){return new Y7(Z,J).streamSync()}function nc(Z,J={}){return new Y7(Z,J).stream()}function ac(Z,J={}){return new Y7(Z,J).walkSync()}async function ic(Z,J={}){return new Y7(Z,J).walk()}function lL(Z,J={}){return new Y7(Z,J).iterateSync()}function sc(Z,J={}){return new Y7(Z,J).iterate()}var QB1=dL,KB1=Object.assign(nc,{sync:dL}),WB1=lL,GB1=Object.assign(sc,{sync:lL}),HB1=Object.assign(ac,{stream:dL,iterate:lL}),uL=Object.assign(ic,{glob:ic,globSync:ac,sync:HB1,globStream:nc,stream:KB1,globStreamSync:dL,streamSync:QB1,globIterate:sc,iterate:GB1,globIterateSync:lL,iterateSync:WB1,Glob:Y7,hasMagic:ND,escape:tQ,unescape:V4});uL.glob=uL;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 R5{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 $K 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 R5(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 e3(){return e3=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},e3.apply(this,arguments)}class T6{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 P0{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 a1{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 S0=Symbol("attributes"),L4=Symbol("immutableKeys");class QK extends RD{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[S0]=void 0,this[L4]=void 0,this.graph=Z,this[L4]=new Set,this[S0]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let Y=Z[X];if(Y instanceof QK){let $=this.graph._createEdge(X,this,Y);this[L4].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[S0]){let Y=this[S0][X];if(Y instanceof R5){let $=Y;if($.getChild()===Z)this.setRef(X,J,$.getAttributes())}else if(Y instanceof T6)for(let $ of Y.listRefsByChild(Z)){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if(Y instanceof P0){let $=Y.getRefByChild(Z);if($){let Q=$.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if(Y instanceof a1)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[S0][Z]}set(Z,J){return this[S0][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[S0][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[L4].has(Z))throw new Error(`Cannot overwrite immutable attribute, "${Z}".`);let Y=this[S0][Z];if(Y)Y.dispose();if(!J)return this;let $=this.graph._createEdge(Z,this,J,X);return this[S0][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 T6)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[S0][Z];if(J instanceof T6||J instanceof P0)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,e3({},Y,{key:J}));return $.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[S0][Z];if(J instanceof a1)return J;throw new Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(e3({},Z,{target:this})),this.graph.dispatchEvent(e3({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[S0][J]===Z){if(this[S0][J]=null,this[L4].has(J))Z.getChild().dispose()}else if(this[S0][J]instanceof T6)this[S0][J].remove(Z);else if(this[S0][J]instanceof P0)this[S0][J].remove(Z);else if(this[S0][J]instanceof a1){let X=this[S0][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 Xp="v4.1.1",sL="@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 oL;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(oL||(oL={}));var c5;(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"})(c5||(c5={}));var rL;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(rL||(rL={}));var zZ;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(zZ||(zZ={}));var DJ={"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 zB1(){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 FB1(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=zB1();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 TD(Z){let J=Yp(),X=Z.propertyType===a.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=VB1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))jD(K.min,J),jD(K.max,J)});return J}function VB1(Z,J){let X=Yp();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,H=Q?Q.getCount():$.getCount();G<H;G++){let z=Q?Q.getScalar(G):G;K=$.getElement(z,K),W=FB1(W,K,J),jD(W,X)}}return X}function jD(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 Yp(){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 ED{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 $p{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),qB1(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 ZB{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))===ZB.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}}ZB.PNG_FRIED_CHUNK_NAME="CgBI";class FZ{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}`}}FZ.impls={"image/jpeg":new $p,"image/png":new ZB};function qB1(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 VZ{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 FZ.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 oc(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function LY(Z){if(oc(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(oc(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var DD,ZH;(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"})(ZH||(ZH={}));class P5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=P5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=P5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=P5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=P5.Verbosity.ERROR)console.error(Z)}}DD=P5;P5.Verbosity=ZH;P5.DEFAULT_INSTANCE=new DD(DD.Verbosity.INFO);function UB1(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],H=Z[8],z=Z[9],V=Z[10],F=Z[11],q=Z[12],U=Z[13],B=Z[14],L=Z[15],w=J*K-X*Q,N=J*W-Y*Q,R=J*G-$*Q,M=X*W-Y*K,D=X*G-$*K,j=Y*G-$*W,C=H*U-z*q,T=H*B-V*q,E=H*L-F*q,A=z*B-V*U,_=z*L-F*U,x=V*L-F*B;return w*x-N*_+R*A+M*E-D*T+j*C}function LB1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],H=J[6],z=J[7],V=J[8],F=J[9],q=J[10],U=J[11],B=J[12],L=J[13],w=J[14],N=J[15],R=X[0],M=X[1],D=X[2],j=X[3];return Z[0]=R*Y+M*W+D*V+j*B,Z[1]=R*$+M*G+D*F+j*L,Z[2]=R*Q+M*H+D*q+j*w,Z[3]=R*K+M*z+D*U+j*N,R=X[4],M=X[5],D=X[6],j=X[7],Z[4]=R*Y+M*W+D*V+j*B,Z[5]=R*$+M*G+D*F+j*L,Z[6]=R*Q+M*H+D*q+j*w,Z[7]=R*K+M*z+D*U+j*N,R=X[8],M=X[9],D=X[10],j=X[11],Z[8]=R*Y+M*W+D*V+j*B,Z[9]=R*$+M*G+D*F+j*L,Z[10]=R*Q+M*H+D*q+j*w,Z[11]=R*K+M*z+D*U+j*N,R=X[12],M=X[13],D=X[14],j=X[15],Z[12]=R*Y+M*W+D*V+j*B,Z[13]=R*$+M*G+D*F+j*L,Z[14]=R*Q+M*H+D*q+j*w,Z[15]=R*K+M*z+D*U+j*N,Z}function BB1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],H=J[9],z=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,H,z),Z}function wB1(Z,J){var X=new PD(3);BB1(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,H=J[4]*Y,z=J[5]*$,V=J[6]*Q,F=J[8]*Y,q=J[9]*$,U=J[10]*Q,B=K+z+U,L=0;if(B>0)L=Math.sqrt(B+1)*2,Z[3]=0.25*L,Z[0]=(V-q)/L,Z[1]=(F-G)/L,Z[2]=(W-H)/L;else if(K>z&&K>U)L=Math.sqrt(1+K-z-U)*2,Z[3]=(V-q)/L,Z[0]=0.25*L,Z[1]=(W+H)/L,Z[2]=(F+G)/L;else if(z>U)L=Math.sqrt(1+z-K-U)*2,Z[3]=(F-G)/L,Z[0]=(W+H)/L,Z[1]=0.25*L,Z[2]=(V+q)/L;else L=Math.sqrt(1+U-K-z)*2,Z[3]=(W-H)/L,Z[0]=(F+G)/L,Z[1]=(V+q)/L,Z[2]=0.25*L;return Z}class d0{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(d0.clamp(Z,0,1)*65535);case 5121:return Math.round(d0.clamp(Z,0,1)*255);case 5122:return Math.round(d0.clamp(Z,-1,1)*32767);case 5120:return Math.round(d0.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(UB1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),H=1/$,z=1/Q,V=1/K;G[0]*=H,G[1]*=H,G[2]*=H,G[4]*=z,G[5]*=z,G[6]*=z,G[8]*=V,G[9]*=V,G[10]*=V,wB1(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],H=Q+Q,z=K+K,V=W+W,F=Q*H,q=Q*z,U=Q*V,B=K*z,L=K*V,w=W*V,N=G*H,R=G*z,M=G*V,D=X[0],j=X[1],C=X[2];return $[0]=(1-(B+w))*D,$[1]=(q+M)*D,$[2]=(U-R)*D,$[3]=0,$[4]=(q-M)*j,$[5]=(1-(F+w))*j,$[6]=(L+N)*j,$[7]=0,$[8]=(U+R)*C,$[9]=(L-N)*C,$[10]=(1-(F+B))*C,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function OB1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function NB1(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 RB1(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 Qp(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 Kp(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!LY(Z)||!LY(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(tL(W)&&tL(G)){if(!Qp(W,G))return!1}else if(LY(W)&&LY(G)){if(!Kp(W,G))return!1}else if(W!==G)return!1}return!0}function tL(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var rc="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",MB1=999,PB1=6,tc=new Set,jB1=function Z(){let J="";for(let X=0;X<PB1;X++)J+=rc.charAt(Math.floor(Math.random()*rc.length));return J},Wp=function Z(){for(let J=0;J<MB1;J++){let X=jB1();if(!tc.has(X))return tc.add(X),X}return""},ec="https://null.example";class j9{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return VZ.basename(new URL(Z,ec).pathname)}static extension(Z){return VZ.extension(new URL(Z,ec).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)}}j9.DEFAULT_INIT={};j9.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var jJ=(Z)=>Z,DB1=new Set;class JB extends QK{constructor(Z,J=""){super(Z);this[S0].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,jJ)}copy(Z,J=jJ){for(let X in this[S0]){let Y=this[S0][X];if(Y instanceof R5){if(!this[L4].has(X))Y.dispose()}else if(Y instanceof T6||Y instanceof P0)for(let $ of Y.values())$.dispose();else if(Y instanceof a1)for(let $ of Y.values())$.dispose()}for(let X in Z[S0]){let Y=this[S0][X],$=Z[S0][X];if($ instanceof R5)if(this[L4].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof P0||$ instanceof T6)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof a1)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(LY($))this[S0][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[S0][X]=$.slice();else this[S0][X]=$}return this}equals(Z,J=DB1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[S0]){if(J.has(X))continue;let Y=this[S0][X],$=Z[S0][X];if(Y instanceof R5||$ instanceof R5){if(!OB1(Y,$))return!1}else if(Y instanceof P0||$ instanceof P0||Y instanceof T6||$ instanceof T6){if(!NB1(Y,$))return!1}else if(Y instanceof a1||$ instanceof a1){if(!RB1(Y,$))return!1}else if(LY(Y)||LY($)){if(!Kp(Y,$))return!1}else if(tL(Y)||tL($)){if(!Qp(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 k6 extends JB{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new a1})}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 E0 extends k6{init(){this.propertyType=a.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:E0.Type.SCALAR,componentType:E0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case E0.Type.SCALAR:return 1;case E0.Type.VEC2:return 2;case E0.Type.VEC3:return 3;case E0.Type.VEC4:return 4;case E0.Type.MAT2:return 4;case E0.Type.MAT3:return 9;case E0.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case E0.ComponentType.BYTE:return 1;case E0.ComponentType.UNSIGNED_BYTE:return 1;case E0.ComponentType.SHORT:return 2;case E0.ComponentType.UNSIGNED_SHORT:return 2;case E0.ComponentType.UNSIGNED_INT:return 4;case E0.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[$]=d0.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[$]=d0.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 E0.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 d0.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]=d0.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]=d0.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]=d0.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?CB1(Z):E0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}E0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};E0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function CB1(Z){switch(Z.constructor){case Float32Array:return E0.ComponentType.FLOAT;case Uint32Array:return E0.ComponentType.UNSIGNED_INT;case Uint16Array:return E0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return E0.ComponentType.UNSIGNED_BYTE;case Int16Array:return E0.ComponentType.SHORT;case Int8Array:return E0.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class kD extends k6{init(){this.propertyType=a.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new P0,samplers:new P0})}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 BY extends k6{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)}}BY.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class KK extends k6{init(){this.propertyType=a.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:KK.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:c5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:c5.OTHER})}}KK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class ID extends k6{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 wY extends k6{init(){this.propertyType=a.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:wY.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)}}wY.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class WK extends JB{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}WK.EXTENSION_NAME=void 0;class M5 extends k6{init(){this.propertyType=a.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:M5.WrapMode.REPEAT,wrapT:M5.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)}}M5.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};M5.MagFilter={NEAREST:9728,LINEAR:9729};M5.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:cL,G:pL,B:iL,A:TB1}=rL;class $7 extends k6{init(){this.propertyType=a.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:$7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new M5(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new M5(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new M5(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new M5(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new M5(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:cL|pL|iL|TB1,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:cL|pL|iL,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:cL|pL|iL})}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:cL})}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:pL|iL})}}$7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class XH extends k6{init(){this.propertyType=a.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new P0})}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 XB extends k6{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 P0})}copy(Z,J=jJ){if(J===jJ)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 d0.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 d0.decompose(Z,J,X,Y),this.set("translation",J).set("rotation",X).set("scale",Y)}getWorldTranslation(){let Z=[0,0,0];return d0.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return d0.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return d0.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())LB1(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 w8 extends k6{init(){this.propertyType=a.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:w8.Mode.TRIANGLES,material:null,indices:null,attributes:new a1,targets:new P0})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:c5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:c5.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)}}w8.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class vD extends JB{init(){this.propertyType=a.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new a1})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:c5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function i6(){return i6=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},i6.apply(null,arguments)}class GK extends k6{init(){this.propertyType=a.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new P0})}copy(Z,J=jJ){if(J===jJ)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 _D extends k6{init(){this.propertyType=a.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new P0})}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:c5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class OY extends k6{init(){this.propertyType=a.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||FZ.extensionToMimeType(VZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=FZ.extensionToMimeType(VZ.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 FZ.getSize(Z,this.getMimeType())}}class NY extends k6{init(){this.propertyType=a.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Xp}`,version:"2.0"},defaultScene:null,accessors:new P0,animations:new P0,buffers:new P0,cameras:new P0,materials:new P0,meshes:new P0,nodes:new P0,scenes:new P0,skins:new P0,textures:new P0})}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=jJ){if(J===jJ)throw new Error("Root cannot be copied.");this.set("asset",i6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(i6({},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 GK)this.addRef("scenes",Z);else if(Z instanceof XB)this.addRef("nodes",Z);else if(Z instanceof wY)this.addRef("cameras",Z);else if(Z instanceof _D)this.addRef("skins",Z);else if(Z instanceof XH)this.addRef("meshes",Z);else if(Z instanceof $7)this.addRef("materials",Z);else if(Z instanceof OY)this.addRef("textures",Z);else if(Z instanceof kD)this.addRef("animations",Z);else if(Z instanceof E0)this.addRef("accessors",Z);else if(Z instanceof ID)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 E6{static fromGraph(Z){return E6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new $K,this._root=new NY(this._graph),this._logger=P5.DEFAULT_INSTANCE,E6._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 GK(this._graph,Z)}createNode(Z=""){return new XB(this._graph,Z)}createCamera(Z=""){return new wY(this._graph,Z)}createSkin(Z=""){return new _D(this._graph,Z)}createMesh(Z=""){return new XH(this._graph,Z)}createPrimitive(){return new w8(this._graph)}createPrimitiveTarget(Z=""){return new vD(this._graph,Z)}createMaterial(Z=""){return new $7(this._graph,Z)}createTexture(Z=""){return new OY(this._graph,Z)}createAnimation(Z=""){return new kD(this._graph,Z)}createAnimationChannel(Z=""){return new BY(this._graph,Z)}createAnimationSampler(Z=""){return new KK(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new E0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new ID(this._graph,Z)}}E6._GRAPH_DOCUMENTS=new WeakMap;class Gp{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 WK&&$.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}}Gp.EXTENSION_NAME=void 0;class Hp{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 Zp={logger:P5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},EB1=new Set([a.BUFFER,a.TEXTURE,a.MATERIAL,a.MESH,a.PRIMITIVE,a.NODE,a.SCENE]);class zp{static read(Z,J=Zp){let X=i6({},Zp,J),{json:Y}=Z,$=new E6().setLogger(X.logger);this.validate(Z,X);let Q=new Hp(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(i6({},Y.extras));let G=Y.extensionsUsed||[],H=Y.extensionsRequired||[];X.extensions.sort((j,C)=>j.EXTENSION_NAME>C.EXTENSION_NAME?1:-1);for(let j of X.extensions)if(G.includes(j.EXTENSION_NAME)){let C=$.createExtension(j).setRequired(H.includes(j.EXTENSION_NAME)),T=C.prereadTypes.filter((E)=>!EB1.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 z=Y.buffers||[];$.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.BUFFER)).forEach((j)=>j.preread(Q,a.BUFFER)),Q.buffers=z.map((j)=>{let C=$.createBuffer(j.name);if(j.extras)C.setExtras(j.extras);if(j.uri&&j.uri.indexOf("__")!==0)C.setURI(j.uri);return C});let V=Y.bufferViews||[];Q.bufferViewBuffers=V.map((j,C)=>{if(!Q.bufferViews[C]){let T=Z.json.buffers[j.buffer],E=T.uri?Z.resources[T.uri]:Z.resources[sL],A=j.byteOffset||0;Q.bufferViews[C]=n0.toView(E,A,j.byteLength)}return Q.buffers[j.buffer]});let F=Y.accessors||[];Q.accessors=F.map((j)=>{let C=Q.bufferViewBuffers[j.bufferView],T=$.createAccessor(j.name,C).setType(j.type);if(j.extras)T.setExtras(j.extras);if(j.normalized!==void 0)T.setNormalized(j.normalized);if(j.bufferView===void 0)return T;return T.setArray(aL(j,Q)),T});let q=Y.images||[],U=Y.textures||[];$.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.TEXTURE)).forEach((j)=>j.preread(Q,a.TEXTURE)),Q.textures=q.map((j)=>{let C=$.createTexture(j.name);if(j.extras)C.setExtras(j.extras);if(j.bufferView!==void 0){let T=Y.bufferViews[j.bufferView],E=Z.json.buffers[T.buffer],A=E.uri?Z.resources[E.uri]:Z.resources[sL],_=T.byteOffset||0,x=T.byteLength,I=A.slice(_,_+x);C.setImage(I)}else if(j.uri!==void 0){if(C.setImage(Z.resources[j.uri]),j.uri.indexOf("__")!==0)C.setURI(j.uri)}if(j.mimeType!==void 0)C.setMimeType(j.mimeType);else if(j.uri){let T=VZ.extension(j.uri);C.setMimeType(FZ.extensionToMimeType(T))}return C}),$.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.MATERIAL)).forEach((j)=>j.preread(Q,a.MATERIAL));let B=Y.materials||[];Q.materials=B.map((j)=>{let C=$.createMaterial(j.name);if(j.extras)C.setExtras(j.extras);if(j.alphaMode!==void 0)C.setAlphaMode(j.alphaMode);if(j.alphaCutoff!==void 0)C.setAlphaCutoff(j.alphaCutoff);if(j.doubleSided!==void 0)C.setDoubleSided(j.doubleSided);let T=j.pbrMetallicRoughness||{};if(T.baseColorFactor!==void 0)C.setBaseColorFactor(T.baseColorFactor);if(j.emissiveFactor!==void 0)C.setEmissiveFactor(j.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,A=Q.textures[U[E.index].source];C.setBaseColorTexture(A),Q.setTextureInfo(C.getBaseColorTextureInfo(),E)}if(j.emissiveTexture!==void 0){let E=j.emissiveTexture,A=Q.textures[U[E.index].source];C.setEmissiveTexture(A),Q.setTextureInfo(C.getEmissiveTextureInfo(),E)}if(j.normalTexture!==void 0){let E=j.normalTexture,A=Q.textures[U[E.index].source];if(C.setNormalTexture(A),Q.setTextureInfo(C.getNormalTextureInfo(),E),j.normalTexture.scale!==void 0)C.setNormalScale(j.normalTexture.scale)}if(j.occlusionTexture!==void 0){let E=j.occlusionTexture,A=Q.textures[U[E.index].source];if(C.setOcclusionTexture(A),Q.setTextureInfo(C.getOcclusionTextureInfo(),E),j.occlusionTexture.strength!==void 0)C.setOcclusionStrength(j.occlusionTexture.strength)}if(T.metallicRoughnessTexture!==void 0){let E=T.metallicRoughnessTexture,A=Q.textures[U[E.index].source];C.setMetallicRoughnessTexture(A),Q.setTextureInfo(C.getMetallicRoughnessTextureInfo(),E)}return C}),$.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.MESH)).forEach((j)=>j.preread(Q,a.MESH));let L=Y.meshes||[];$.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.PRIMITIVE)).forEach((j)=>j.preread(Q,a.PRIMITIVE)),Q.meshes=L.map((j)=>{let C=$.createMesh(j.name);if(j.extras)C.setExtras(j.extras);if(j.weights!==void 0)C.setWeights(j.weights);return(j.primitives||[]).forEach((E)=>{let A=$.createPrimitive();if(E.extras)A.setExtras(E.extras);if(E.material!==void 0)A.setMaterial(Q.materials[E.material]);if(E.mode!==void 0)A.setMode(E.mode);for(let[I,v]of Object.entries(E.attributes||{}))A.setAttribute(I,Q.accessors[v]);if(E.indices!==void 0)A.setIndices(Q.accessors[E.indices]);let _=j.extras&&j.extras.targetNames||[];(E.targets||[]).forEach((I,v)=>{let y=_[v]||v.toString(),p=$.createPrimitiveTarget(y);for(let[n,o]of Object.entries(I))p.setAttribute(n,Q.accessors[o]);A.addTarget(p)}),C.addPrimitive(A)}),C});let w=Y.cameras||[];Q.cameras=w.map((j)=>{let C=$.createCamera(j.name).setType(j.type);if(j.extras)C.setExtras(j.extras);if(j.type===wY.Type.PERSPECTIVE){let T=j.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=j.orthographic;C.setZNear(T.znear).setZFar(T.zfar).setXMag(T.xmag).setYMag(T.ymag)}return C});let N=Y.nodes||[];$.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.NODE)).forEach((j)=>j.preread(Q,a.NODE)),Q.nodes=N.map((j)=>{let C=$.createNode(j.name);if(j.extras)C.setExtras(j.extras);if(j.translation!==void 0)C.setTranslation(j.translation);if(j.rotation!==void 0)C.setRotation(j.rotation);if(j.scale!==void 0)C.setScale(j.scale);if(j.matrix!==void 0){let T=[0,0,0],E=[0,0,0,1],A=[1,1,1];d0.decompose(j.matrix,T,E,A),C.setTranslation(T),C.setRotation(E),C.setScale(A)}if(j.weights!==void 0)C.setWeights(j.weights);return C});let R=Y.skins||[];Q.skins=R.map((j)=>{let C=$.createSkin(j.name);if(j.extras)C.setExtras(j.extras);if(j.inverseBindMatrices!==void 0)C.setInverseBindMatrices(Q.accessors[j.inverseBindMatrices]);if(j.skeleton!==void 0)C.setSkeleton(Q.nodes[j.skeleton]);for(let T of j.joints)C.addJoint(Q.nodes[T]);return C}),N.map((j,C)=>{let T=Q.nodes[C];if((j.children||[]).forEach((A)=>T.addChild(Q.nodes[A])),j.mesh!==void 0)T.setMesh(Q.meshes[j.mesh]);if(j.camera!==void 0)T.setCamera(Q.cameras[j.camera]);if(j.skin!==void 0)T.setSkin(Q.skins[j.skin])});let M=Y.animations||[];Q.animations=M.map((j)=>{let C=$.createAnimation(j.name);if(j.extras)C.setExtras(j.extras);let E=(j.samplers||[]).map((_)=>{let x=$.createAnimationSampler().setInput(Q.accessors[_.input]).setOutput(Q.accessors[_.output]).setInterpolation(_.interpolation||KK.Interpolation.LINEAR);if(_.extras)x.setExtras(_.extras);return C.addSampler(x),x});return(j.channels||[]).forEach((_)=>{let x=$.createAnimationChannel().setSampler(E[_.sampler]).setTargetPath(_.target.path);if(_.target.node!==void 0)x.setTargetNode(Q.nodes[_.target.node]);if(_.extras)x.setExtras(_.extras);C.addChannel(x)}),C});let D=Y.scenes||[];if($.getRoot().listExtensionsUsed().filter((j)=>j.prereadTypes.includes(a.SCENE)).forEach((j)=>j.preread(Q,a.SCENE)),Q.scenes=D.map((j)=>{let C=$.createScene(j.name);if(j.extras)C.setExtras(j.extras);return(j.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((j)=>j.read(Q)),F.forEach((j,C)=>{let T=Q.accessors[C],E=!!j.sparse,A=!j.bufferView&&!T.getArray();if(E||A)T.setSparse(!0).setArray(IB1(j,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 kB1(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=DJ[Z.componentType],K=E0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=Z.byteOffset||0,H=new Q(Z.count*K),z=new DataView(Y.buffer,Y.byteOffset,Y.byteLength),V=$.byteStride;for(let F=0;F<Z.count;F++)for(let q=0;q<K;q++){let U=G+F*V+q*W,B;switch(Z.componentType){case E0.ComponentType.FLOAT:B=z.getFloat32(U,!0);break;case E0.ComponentType.UNSIGNED_INT:B=z.getUint32(U,!0);break;case E0.ComponentType.UNSIGNED_SHORT:B=z.getUint16(U,!0);break;case E0.ComponentType.UNSIGNED_BYTE:B=z.getUint8(U);break;case E0.ComponentType.SHORT:B=z.getInt16(U,!0);break;case E0.ComponentType.BYTE:B=z.getInt8(U);break;default:throw new Error(`Unexpected componentType "${Z.componentType}".`)}H[F*K+q]=B}return H}function aL(Z,J){let X=J.jsonDoc,Y=J.bufferViews[Z.bufferView],$=X.json.bufferViews[Z.bufferView],Q=DJ[Z.componentType],K=E0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if($.byteStride!==void 0&&$.byteStride!==G)return kB1(Z,J);let H=Y.byteOffset+(Z.byteOffset||0),z=Z.count*K*W;return new Q(Y.buffer.slice(H,H+z))}function IB1(Z,J){let X=DJ[Z.componentType],Y=E0.getElementSize(Z.type),$;if(Z.bufferView!==void 0)$=aL(Z,J);else $=new X(Z.count*Y);let Q=Z.sparse;if(!Q)return $;let K=Q.count,W=i6({},Z,Q.indices,{count:K,type:"SCALAR"}),G=i6({},Z,Q.values,{count:K}),H=aL(W,J),z=aL(G,J);for(let V=0;V<W.count;V++)for(let F=0;F<Y;F++)$[H[V]*Y+F]=z[V*Y+F];return $}var JH;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(JH||(JH={}));class PJ{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 CD($>1,()=>X.basename||"buffer"),this.imageURIGenerator=new CD(Q>1,(K)=>vB1(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===zZ.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=FZ.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 c5.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 c5.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}}PJ.BufferViewTarget=JH;PJ.BufferViewUsage=c5;PJ.USAGE_TO_TARGET={[c5.ARRAY_BUFFER]:JH.ARRAY_BUFFER,[c5.ELEMENT_ARRAY_BUFFER]:JH.ELEMENT_ARRAY_BUFFER};class CD{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 vB1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:nL}=PJ,{UNSIGNED_INT:_B1,UNSIGNED_SHORT:SB1,UNSIGNED_BYTE:AB1}=E0.ComponentType,xB1=new Set([a.ACCESSOR,a.BUFFER,a.MATERIAL,a.MESH]);class Fp{static write(Z,J){let X=Z.getGraph(),Y=Z.getRoot(),$={asset:i6({generator:`glTF-Transform ${Xp}`},Y.getAsset()),extras:i6({},Y.getExtras())},Q={json:$,resources:{}},K=new PJ(Z,Q,J),W=J.logger||P5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((L)=>L.EXTENSION_NAME)),H=Z.getRoot().listExtensionsUsed().filter((L)=>G.has(L.extensionName)).sort((L,w)=>L.extensionName>w.extensionName?1:-1),z=Z.getRoot().listExtensionsRequired().filter((L)=>G.has(L.extensionName)).sort((L,w)=>L.extensionName>w.extensionName?1:-1);if(H.length<Z.getRoot().listExtensionsUsed().length)W.warn("Some extensions were not registered for I/O, and will not be written.");for(let L of H){let w=L.prewriteTypes.filter((N)=>!xB1.has(N));if(w.length)W.warn(`Prewrite hooks for some types (${w.join()}), requested by extension ${L.extensionName}, are unsupported. Please file an issue or a PR.`);for(let N of L.writeDependencies)L.install(N,J.dependencies[N])}function V(L,w,N,R){let M=[],D=0;for(let T of L){let E=K.createAccessorDef(T);E.bufferView=$.bufferViews.length;let A=T.getArray(),_=n0.pad(n0.toView(A));E.byteOffset=D,D+=_.byteLength,M.push(_),K.accessorIndexMap.set(T,$.accessors.length),$.accessors.push(E)}let j=n0.concat(M),C={buffer:w,byteOffset:N,byteLength:j.byteLength};if(R)C.target=R;return $.bufferViews.push(C),{buffers:M,byteLength:D}}function F(L,w,N){let R=L[0].getCount(),M=0;for(let E of L){let A=K.createAccessorDef(E);A.bufferView=$.bufferViews.length,A.byteOffset=M;let _=E.getElementSize(),x=E.getComponentSize();M+=n0.padNumber(_*x),K.accessorIndexMap.set(E,$.accessors.length),$.accessors.push(A)}let D=R*M,j=new ArrayBuffer(D),C=new DataView(j);for(let E=0;E<R;E++){let A=0;for(let _ of L){let x=_.getElementSize(),I=_.getComponentSize(),v=_.getComponentType(),y=_.getArray();for(let p=0;p<x;p++){let n=E*M+A+p*I,o=y[E*x+p];switch(v){case E0.ComponentType.FLOAT:C.setFloat32(n,o,!0);break;case E0.ComponentType.BYTE:C.setInt8(n,o);break;case E0.ComponentType.SHORT:C.setInt16(n,o,!0);break;case E0.ComponentType.UNSIGNED_BYTE:C.setUint8(n,o);break;case E0.ComponentType.UNSIGNED_SHORT:C.setUint16(n,o,!0);break;case E0.ComponentType.UNSIGNED_INT:C.setUint32(n,o,!0);break;default:throw new Error("Unexpected component type: "+v)}}A+=n0.padNumber(x*I)}}let T={buffer:w,byteOffset:N,byteLength:D,byteStride:M,target:PJ.BufferViewTarget.ARRAY_BUFFER};return $.bufferViews.push(T),{byteLength:D,buffers:[new Uint8Array(j)]}}function q(L,w,N){let R=[],M=0,D=new Map,j=-1/0,C=!1;for(let v of L){let y=K.createAccessorDef(v);$.accessors.push(y),K.accessorIndexMap.set(v,$.accessors.length-1);let p=[],n=[],o=[],J0=new Array(v.getElementSize()).fill(0);for(let a0=0,E8=v.getCount();a0<E8;a0++){if(v.getElement(a0,o),d0.eq(o,J0,0))continue;j=Math.max(a0,j),p.push(a0);for(let i1=0;i1<o.length;i1++)n.push(o[i1])}let Q0=p.length,D0={accessorDef:y,count:Q0};if(D.set(v,D0),Q0===0)continue;if(Q0>v.getCount()/2)C=!0;let C0=DJ[v.getComponentType()];D0.indices=p,D0.values=new C0(n)}if(!Number.isFinite(j))return{buffers:R,byteLength:M};if(C)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let T=j<255?Uint8Array:j<65535?Uint16Array:Uint32Array,E=j<255?AB1:j<65535?SB1:_B1,A={buffer:w,byteOffset:N+M,byteLength:0};for(let v of L){let y=D.get(v);if(y.count===0)continue;y.indicesByteOffset=A.byteLength;let p=n0.pad(n0.toView(new T(y.indices)));R.push(p),M+=p.byteLength,A.byteLength+=p.byteLength}$.bufferViews.push(A);let _=$.bufferViews.length-1,x={buffer:w,byteOffset:N+M,byteLength:0};for(let v of L){let y=D.get(v);if(y.count===0)continue;y.valuesByteOffset=x.byteLength;let p=n0.pad(n0.toView(y.values));R.push(p),M+=p.byteLength,x.byteLength+=p.byteLength}$.bufferViews.push(x);let I=$.bufferViews.length-1;for(let v of L){let y=D.get(v);if(y.count===0)continue;y.accessorDef.sparse={count:y.count,indices:{bufferView:_,byteOffset:y.indicesByteOffset,componentType:E},values:{bufferView:I,byteOffset:y.valuesByteOffset}}}return{buffers:R,byteLength:M}}if($.accessors=[],$.bufferViews=[],$.samplers=[],$.textures=[],$.images=Y.listTextures().map((L,w)=>{let N=K.createPropertyDef(L);if(L.getMimeType())N.mimeType=L.getMimeType();let R=L.getImage();if(R)K.createImageData(N,R,L);return K.imageIndexMap.set(L,w),N}),H.filter((L)=>L.prewriteTypes.includes(a.ACCESSOR)).forEach((L)=>L.prewrite(K,a.ACCESSOR)),Y.listAccessors().forEach((L)=>{let{accessorUsageGroupedByParent:w,accessorParents:N}=K;if(K.accessorIndexMap.has(L))return;let R=K.getAccessorUsage(L);if(K.addAccessorToUsageGroup(L,R),w.has(R)){let M=X.listParents(L).find((D)=>D.propertyType!==a.ROOT);N.set(L,M)}}),H.filter((L)=>L.prewriteTypes.includes(a.BUFFER)).forEach((L)=>L.prewrite(K,a.BUFFER)),(Y.listAccessors().length>0||K.otherBufferViews.size>0||Y.listTextures().length>0&&J.format===zZ.GLB)&&Y.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");if($.buffers=[],Y.listBuffers().forEach((L,w)=>{let N=K.createPropertyDef(L),R=K.accessorUsageGroupedByParent,M=L.listParents().filter((x)=>x instanceof E0),D=new Set(M.map((x)=>K.accessorParents.get(x))),j=new Map(Array.from(D).map((x,I)=>[x,I])),C={};for(let x of M){var T;if(K.accessorIndexMap.has(x))continue;let I=K.getAccessorUsage(x),v=I;if(R.has(I)){let y=K.accessorParents.get(x);v+=`:${j.get(y)}`}C[T=v]||(C[T]={usage:I,accessors:[]}),C[v].accessors.push(x)}let E=[],A=$.buffers.length,_=0;for(let{usage:x,accessors:I}of Object.values(C))if(x===nL.ARRAY_BUFFER&&J.vertexLayout===oL.INTERLEAVED){let v=F(I,A,_);_+=v.byteLength;for(let y of v.buffers)E.push(y)}else if(x===nL.ARRAY_BUFFER)for(let v of I){let y=F([v],A,_);_+=y.byteLength;for(let p of y.buffers)E.push(p)}else if(x===nL.SPARSE){let v=q(I,A,_);_+=v.byteLength;for(let y of v.buffers)E.push(y)}else if(x===nL.ELEMENT_ARRAY_BUFFER){let v=PJ.BufferViewTarget.ELEMENT_ARRAY_BUFFER,y=V(I,A,_,v);_+=y.byteLength;for(let p of y.buffers)E.push(p)}else{let v=V(I,A,_);_+=v.byteLength;for(let y of v.buffers)E.push(y)}if(K.imageBufferViews.length&&w===0){for(let x=0;x<K.imageBufferViews.length;x++)if($.bufferViews[$.images[x].bufferView].byteOffset=_,_+=K.imageBufferViews[x].byteLength,E.push(K.imageBufferViews[x]),_%8){let I=8-_%8;_+=I,E.push(new Uint8Array(I))}}if(K.otherBufferViews.has(L))for(let x of K.otherBufferViews.get(L))$.bufferViews.push({buffer:A,byteOffset:_,byteLength:x.byteLength}),K.otherBufferViewsIndexMap.set(x,$.bufferViews.length-1),_+=x.byteLength,E.push(x);if(_){let x;if(J.format===zZ.GLB)x=sL;else x=K.bufferURIGenerator.createURI(L,"bin"),N.uri=x;N.byteLength=_,K.assignResourceURI(x,n0.concat(E),!0)}$.buffers.push(N),K.bufferIndexMap.set(L,w)}),Y.listAccessors().find((L)=>!L.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");H.filter((L)=>L.prewriteTypes.includes(a.MATERIAL)).forEach((L)=>L.prewrite(K,a.MATERIAL)),$.materials=Y.listMaterials().map((L,w)=>{let N=K.createPropertyDef(L);if(L.getAlphaMode()!==$7.AlphaMode.OPAQUE)N.alphaMode=L.getAlphaMode();if(L.getAlphaMode()===$7.AlphaMode.MASK)N.alphaCutoff=L.getAlphaCutoff();if(L.getDoubleSided())N.doubleSided=!0;if(N.pbrMetallicRoughness={},!d0.eq(L.getBaseColorFactor(),[1,1,1,1]))N.pbrMetallicRoughness.baseColorFactor=L.getBaseColorFactor();if(!d0.eq(L.getEmissiveFactor(),[0,0,0]))N.emissiveFactor=L.getEmissiveFactor();if(L.getRoughnessFactor()!==1)N.pbrMetallicRoughness.roughnessFactor=L.getRoughnessFactor();if(L.getMetallicFactor()!==1)N.pbrMetallicRoughness.metallicFactor=L.getMetallicFactor();if(L.getBaseColorTexture()){let R=L.getBaseColorTexture(),M=L.getBaseColorTextureInfo();N.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(R,M)}if(L.getEmissiveTexture()){let R=L.getEmissiveTexture(),M=L.getEmissiveTextureInfo();N.emissiveTexture=K.createTextureInfoDef(R,M)}if(L.getNormalTexture()){let R=L.getNormalTexture(),M=L.getNormalTextureInfo(),D=K.createTextureInfoDef(R,M);if(L.getNormalScale()!==1)D.scale=L.getNormalScale();N.normalTexture=D}if(L.getOcclusionTexture()){let R=L.getOcclusionTexture(),M=L.getOcclusionTextureInfo(),D=K.createTextureInfoDef(R,M);if(L.getOcclusionStrength()!==1)D.strength=L.getOcclusionStrength();N.occlusionTexture=D}if(L.getMetallicRoughnessTexture()){let R=L.getMetallicRoughnessTexture(),M=L.getMetallicRoughnessTextureInfo();N.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(R,M)}return K.materialIndexMap.set(L,w),N}),H.filter((L)=>L.prewriteTypes.includes(a.MESH)).forEach((L)=>L.prewrite(K,a.MESH)),$.meshes=Y.listMeshes().map((L,w)=>{let N=K.createPropertyDef(L),R=null;if(N.primitives=L.listPrimitives().map((M)=>{let D={attributes:{}};D.mode=M.getMode();let j=M.getMaterial();if(j)D.material=K.materialIndexMap.get(j);if(Object.keys(M.getExtras()).length)D.extras=M.getExtras();let C=M.getIndices();if(C)D.indices=K.accessorIndexMap.get(C);for(let T of M.listSemantics())D.attributes[T]=K.accessorIndexMap.get(M.getAttribute(T));for(let T of M.listTargets()){let E={};for(let A of T.listSemantics())E[A]=K.accessorIndexMap.get(T.getAttribute(A));D.targets=D.targets||[],D.targets.push(E)}if(M.listTargets().length&&!R)R=M.listTargets().map((T)=>T.getName());return D}),L.getWeights().length)N.weights=L.getWeights();if(R)N.extras=N.extras||{},N.extras.targetNames=R;return K.meshIndexMap.set(L,w),N}),$.cameras=Y.listCameras().map((L,w)=>{let N=K.createPropertyDef(L);if(N.type=L.getType(),N.type===wY.Type.PERSPECTIVE){N.perspective={znear:L.getZNear(),zfar:L.getZFar(),yfov:L.getYFov()};let R=L.getAspectRatio();if(R!==null)N.perspective.aspectRatio=R}else N.orthographic={znear:L.getZNear(),zfar:L.getZFar(),xmag:L.getXMag(),ymag:L.getYMag()};return K.cameraIndexMap.set(L,w),N}),$.nodes=Y.listNodes().map((L,w)=>{let N=K.createPropertyDef(L);if(!d0.eq(L.getTranslation(),[0,0,0]))N.translation=L.getTranslation();if(!d0.eq(L.getRotation(),[0,0,0,1]))N.rotation=L.getRotation();if(!d0.eq(L.getScale(),[1,1,1]))N.scale=L.getScale();if(L.getWeights().length)N.weights=L.getWeights();return K.nodeIndexMap.set(L,w),N}),$.skins=Y.listSkins().map((L,w)=>{let N=K.createPropertyDef(L),R=L.getInverseBindMatrices();if(R)N.inverseBindMatrices=K.accessorIndexMap.get(R);let M=L.getSkeleton();if(M)N.skeleton=K.nodeIndexMap.get(M);return N.joints=L.listJoints().map((D)=>K.nodeIndexMap.get(D)),K.skinIndexMap.set(L,w),N}),Y.listNodes().forEach((L,w)=>{let N=$.nodes[w],R=L.getMesh();if(R)N.mesh=K.meshIndexMap.get(R);let M=L.getCamera();if(M)N.camera=K.cameraIndexMap.get(M);let D=L.getSkin();if(D)N.skin=K.skinIndexMap.get(D);if(L.listChildren().length>0)N.children=L.listChildren().map((j)=>K.nodeIndexMap.get(j))}),$.animations=Y.listAnimations().map((L,w)=>{let N=K.createPropertyDef(L),R=new Map;return N.samplers=L.listSamplers().map((M,D)=>{let j=K.createPropertyDef(M);return j.input=K.accessorIndexMap.get(M.getInput()),j.output=K.accessorIndexMap.get(M.getOutput()),j.interpolation=M.getInterpolation(),R.set(M,D),j}),N.channels=L.listChannels().map((M)=>{let D=K.createPropertyDef(M);return D.sampler=R.get(M.getSampler()),D.target={node:K.nodeIndexMap.get(M.getTargetNode()),path:M.getTargetPath()},D}),K.animationIndexMap.set(L,w),N}),$.scenes=Y.listScenes().map((L,w)=>{let N=K.createPropertyDef(L);return N.nodes=L.listChildren().map((R)=>K.nodeIndexMap.get(R)),K.sceneIndexMap.set(L,w),N});let B=Y.getDefaultScene();if(B)$.scene=Y.listScenes().indexOf(B);return $.extensionsUsed=H.map((L)=>L.extensionName),$.extensionsRequired=z.map((L)=>L.extensionName),H.forEach((L)=>L.write(K)),hB1($),Q}}function hB1(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 eL;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(eL||(eL={}));class Vp{constructor(){this._logger=P5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=oL.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=Jp(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),zp.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)=>fB1(J,Y)))throw new Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some((Y)=>yB1(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===zZ.GLB&&Z.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return Fp.write(Z,{format:J.format||zZ.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:i6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:zZ.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 H=n0.pad(G,0),z=n0.toView(new Uint32Array([H.byteLength,5130562])),V=n0.concat([z,H]);return Y[Y.length-1]+=V.byteLength,n0.concat([n0.toView(Y),W,V])}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=`__${Wp()}.${VZ.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:i6({},Z.json),resources:i6({},Z.resources)},J)Z.json.images=J.map((Y)=>i6({},Y));if(X)Z.json.buffers=X.map((Y)=>i6({},Y));return Z}_binaryToJSON(Z){if(!Jp(Z))throw new Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==eL.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]!==eL.BIN)return{json:Q,resources:{}};let G=W[0],H=n0.toView(Z,K+8,G);return{json:Q,resources:{[sL]:H}}}}function fB1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function yB1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function Jp(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 SD extends Vp{constructor(Z=null,J=j9.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(),j9.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(j9.isAbsoluteURL(Z)||j9.isAbsoluteURL(J))return j9.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(j9.isAbsoluteURL(Z))return j9.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:zZ.GLTF,basename:VZ.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 H of bB1(Object.keys($),10))await Promise.all(H.map(async function(z){if(j9.isAbsoluteURL(z)){if(j9.extension(z)==="bin")throw new Error(`Cannot write buffer to path "${z}".`);return}let V=K.join(W,decodeURIComponent(z));await Q.mkdir(K.dirname(V),{recursive:!0}),await Q.writeFile(V,$[z]),X.lastWriteBytes+=$[z].byteLength}))}async _writeGLB(Z,J){let X=await this.writeBinary(J);await this._fs.writeFile(Z,X),this.lastWriteBytes=X.byteLength}}function bB1(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 Ha=r(AD(),1),za=r(pn(),1),IR1=r(Ga(),1);async function vR1(Z,J){if(!(Z instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:Y}=await za.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return Ha.default(new Uint8Array(X),[Y.width,Y.height,4],[4,4*Y.width|0,1],0)}async function Fa(Z,J){return vR1(Z)}var _R1="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 Va;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(Va||(Va={}));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 a5;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(a5||(a5={}));var QC;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})(QC||(QC={}));var KC=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 SR1(){var Z=new KC(3);if(KC!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function $C(Z){var J=Z[0],X=Z[1],Y=Z[2];return Math.hypot(J,X,Y)}function AR1(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=SR1();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 Ba(Z){let J=wa(),X=Z.propertyType===s.NODE?[Z]:Z.listChildren();for(let Y of X)Y.traverse(($)=>{let Q=$.getMesh();if(!Q)return;let K=xR1(Q,$.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))WC(K.min,J),WC(K.max,J)});return J}function xR1(Z,J){let X=wa();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,H=Q?Q.getCount():$.getCount();G<H;G++){let z=Q?Q.getScalar(G):G;K=$.getElement(z,K),W=AR1(W,K,J),WC(W,X)}}return X}function WC(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 wa(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class I6{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 Oa{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),hR1(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 _B{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(I6.decodeText(Z.slice(12,16))===_B.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}}_B.PNG_FRIED_CHUNK_NAME="CgBI";class w4{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}`}}w4.impls={"image/jpeg":new Oa,"image/png":new _B};function hR1(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 VH{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 w4.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 qa(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function jY(Z){if(qa(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(qa(X)===!1)return!1;if(Object.prototype.hasOwnProperty.call(X,"isPrototypeOf")===!1)return!1;return!0}var GC,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 z7{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=z7.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=z7.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=z7.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=z7.Verbosity.ERROR)console.error(Z)}}GC=z7;z7.Verbosity=HC;z7.DEFAULT_INSTANCE=new GC(GC.Verbosity.INFO);function fR1(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],H=Z[8],z=Z[9],V=Z[10],F=Z[11],q=Z[12],U=Z[13],B=Z[14],L=Z[15],w=J*K-X*Q,N=J*W-Y*Q,R=J*G-$*Q,M=X*W-Y*K,D=X*G-$*K,j=Y*G-$*W,C=H*U-z*q,T=H*B-V*q,E=H*L-F*q,A=z*B-V*U,_=z*L-F*U,x=V*L-F*B;return w*x-N*_+R*A+M*E-D*T+j*C}function yR1(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],H=J[6],z=J[7],V=J[8],F=J[9],q=J[10],U=J[11],B=J[12],L=J[13],w=J[14],N=J[15],R=X[0],M=X[1],D=X[2],j=X[3];return Z[0]=R*Y+M*W+D*V+j*B,Z[1]=R*$+M*G+D*F+j*L,Z[2]=R*Q+M*H+D*q+j*w,Z[3]=R*K+M*z+D*U+j*N,R=X[4],M=X[5],D=X[6],j=X[7],Z[4]=R*Y+M*W+D*V+j*B,Z[5]=R*$+M*G+D*F+j*L,Z[6]=R*Q+M*H+D*q+j*w,Z[7]=R*K+M*z+D*U+j*N,R=X[8],M=X[9],D=X[10],j=X[11],Z[8]=R*Y+M*W+D*V+j*B,Z[9]=R*$+M*G+D*F+j*L,Z[10]=R*Q+M*H+D*q+j*w,Z[11]=R*K+M*z+D*U+j*N,R=X[12],M=X[13],D=X[14],j=X[15],Z[12]=R*Y+M*W+D*V+j*B,Z[13]=R*$+M*G+D*F+j*L,Z[14]=R*Q+M*H+D*q+j*w,Z[15]=R*K+M*z+D*U+j*N,Z}function bR1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],H=J[9],z=J[10];return Z[0]=Math.hypot(X,Y,$),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,H,z),Z}function gR1(Z,J){var X=new KC(3);bR1(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,H=J[4]*Y,z=J[5]*$,V=J[6]*Q,F=J[8]*Y,q=J[9]*$,U=J[10]*Q,B=K+z+U,L=0;if(B>0)L=Math.sqrt(B+1)*2,Z[3]=0.25*L,Z[0]=(V-q)/L,Z[1]=(F-G)/L,Z[2]=(W-H)/L;else if(K>z&&K>U)L=Math.sqrt(1+K-z-U)*2,Z[3]=(V-q)/L,Z[0]=0.25*L,Z[1]=(W+H)/L,Z[2]=(F+G)/L;else if(z>U)L=Math.sqrt(1+z-K-U)*2,Z[3]=(F-G)/L,Z[0]=(W+H)/L,Z[1]=0.25*L,Z[2]=(V+q)/L;else L=Math.sqrt(1+U-K-z)*2,Z[3]=(W-H)/L,Z[0]=(F+G)/L,Z[1]=(V+q)/L,Z[2]=0.25*L;return Z}class Q8{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(Q8.clamp(Z,0,1)*65535);case 5121:return Math.round(Q8.clamp(Z,0,1)*255);case 5122:return Math.round(Q8.clamp(Z,-1,1)*32767);case 5120:return Math.round(Q8.clamp(Z,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(Z,J,X,Y){let $=$C([Z[0],Z[1],Z[2]]),Q=$C([Z[4],Z[5],Z[6]]),K=$C([Z[8],Z[9],Z[10]]);if(fR1(Z)<0)$=-$;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),H=1/$,z=1/Q,V=1/K;G[0]*=H,G[1]*=H,G[2]*=H,G[4]*=z,G[5]*=z,G[6]*=z,G[8]*=V,G[9]*=V,G[10]*=V,gR1(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],H=Q+Q,z=K+K,V=W+W,F=Q*H,q=Q*z,U=Q*V,B=K*z,L=K*V,w=W*V,N=G*H,R=G*z,M=G*V,D=X[0],j=X[1],C=X[2];return $[0]=(1-(B+w))*D,$[1]=(q+M)*D,$[2]=(U-R)*D,$[3]=0,$[4]=(q-M)*j,$[5]=(1-(F+w))*j,$[6]=(L+N)*j,$[7]=0,$[8]=(U+R)*C,$[9]=(L-N)*C,$[10]=(1-(F+B))*C,$[11]=0,$[12]=Z[0],$[13]=Z[1],$[14]=Z[2],$[15]=1,$}}function mR1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),Y=J.getChild();return X===Y||X.equals(Y)}function uR1(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 dR1(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 Na(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 Ra(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(kB(W)&&kB(G)){if(!Na(W,G))return!1}else if(jY(W)&&jY(G)){if(!Ra(W,G))return!1}else if(W!==G)return!1}return!0}function kB(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Ua="https://null.example";class VC{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return VH.basename(new URL(Z,Ua).pathname)}static extension(Z){return VH.extension(new URL(Z,Ua).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)}}VC.DEFAULT_INIT={};VC.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;var vJ=(Z)=>Z,lR1=new Set;class SB extends QK{constructor(Z,J=""){super(Z);this[S0].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,vJ)}copy(Z,J=vJ){for(let X in this[S0]){let Y=this[S0][X];if(Y instanceof R5){if(!this[L4].has(X))Y.dispose()}else if(Y instanceof T6||Y instanceof P0)for(let $ of Y.values())$.dispose();else if(Y instanceof a1)for(let $ of Y.values())$.dispose()}for(let X in Z[S0]){let Y=this[S0][X],$=Z[S0][X];if($ instanceof R5)if(this[L4].has(X))Y.getChild().copy(J($.getChild()),J);else this.setRef(X,J($.getChild()),$.getAttributes());else if($ instanceof P0||$ instanceof T6)for(let Q of $.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if($ instanceof a1)for(let Q of $.keys()){let K=$.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(jY($))this[S0][X]=JSON.parse(JSON.stringify($));else if(Array.isArray($)||$ instanceof ArrayBuffer||ArrayBuffer.isView($))this[S0][X]=$.slice();else this[S0][X]=$}return this}equals(Z,J=lR1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[S0]){if(J.has(X))continue;let Y=this[S0][X],$=Z[S0][X];if(Y instanceof R5||$ instanceof R5){if(!mR1(Y,$))return!1}else if(Y instanceof P0||$ instanceof P0||Y instanceof T6||$ instanceof T6){if(!uR1(Y,$))return!1}else if(Y instanceof a1||$ instanceof a1){if(!dR1(Y,$))return!1}else if(jY(Y)||jY($)){if(!Ra(Y,$))return!1}else if(kB(Y)||kB($)){if(!Na(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 SB{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new a1})}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[$]=Q8.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[$]=Q8.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 Q8.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]=Q8.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]=Q8.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]=Q8.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?cR1(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 cR1(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 qC extends v6{init(){this.propertyType=s.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new P0,samplers:new P0})}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 UH 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)}}UH.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class OK extends v6{init(){this.propertyType=s.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:OK.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})}}OK.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class UC 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 LH extends v6{init(){this.propertyType=s.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:LH.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)}}LH.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class p1 extends SB{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw new Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}p1.EXTENSION_NAME=void 0;class P1 extends v6{init(){this.propertyType=s.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:P1.WrapMode.REPEAT,wrapT:P1.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)}}P1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};P1.MagFilter={NEAREST:9728,LINEAR:9729};P1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:CB,G:TB,B:EB,A:pR1}=a5;class BH extends v6{init(){this.propertyType=s.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:BH.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new P1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new P1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new P1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new P1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new P1(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:CB|TB|EB|pR1,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:CB|TB|EB,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:CB|TB|EB})}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:CB})}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:TB|EB})}}BH.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class LC extends v6{init(){this.propertyType=s.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new P0})}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 BC 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 P0})}copy(Z,J=vJ){if(J===vJ)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 Q8.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 Q8.decompose(Z,J,X,Y),this.set("translation",J).set("rotation",X).set("scale",Y)}getWorldTranslation(){let Z=[0,0,0];return Q8.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return Q8.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return Q8.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())yR1(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 _J extends v6{init(){this.propertyType=s.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:_J.Mode.TRIANGLES,material:null,indices:null,attributes:new a1,targets:new P0})}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)}}_J.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class Ma extends SB{init(){this.propertyType=s.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new a1})}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 IB(){return IB=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},IB.apply(null,arguments)}class wC extends v6{init(){this.propertyType=s.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new P0})}copy(Z,J=vJ){if(J===vJ)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 P0})}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 NC extends v6{init(){this.propertyType=s.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||w4.extensionToMimeType(VH.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=w4.extensionToMimeType(VH.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",I6.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return w4.getSize(Z,this.getMimeType())}}class AB extends v6{init(){this.propertyType=s.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${_R1}`,version:"2.0"},defaultScene:null,accessors:new P0,animations:new P0,buffers:new P0,cameras:new P0,materials:new P0,meshes:new P0,nodes:new P0,scenes:new P0,skins:new P0,textures:new P0})}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=vJ){if(J===vJ)throw new Error("Root cannot be copied.");this.set("asset",IB({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(IB({},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 wC)this.addRef("scenes",Z);else if(Z instanceof BC)this.addRef("nodes",Z);else if(Z instanceof LH)this.addRef("cameras",Z);else if(Z instanceof OC)this.addRef("skins",Z);else if(Z instanceof LC)this.addRef("meshes",Z);else if(Z instanceof BH)this.addRef("materials",Z);else if(Z instanceof NC)this.addRef("textures",Z);else if(Z instanceof qC)this.addRef("animations",Z);else if(Z instanceof N0)this.addRef("accessors",Z);else if(Z instanceof UC)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 vB{static fromGraph(Z){return vB._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new $K,this._root=new AB(this._graph),this._logger=z7.DEFAULT_INSTANCE,vB._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 wC(this._graph,Z)}createNode(Z=""){return new BC(this._graph,Z)}createCamera(Z=""){return new LH(this._graph,Z)}createSkin(Z=""){return new OC(this._graph,Z)}createMesh(Z=""){return new LC(this._graph,Z)}createPrimitive(){return new _J(this._graph)}createPrimitiveTarget(Z=""){return new Ma(this._graph,Z)}createMaterial(Z=""){return new BH(this._graph,Z)}createTexture(Z=""){return new NC(this._graph,Z)}createAnimation(Z=""){return new qC(this._graph,Z)}createAnimationChannel(Z=""){return new UH(this._graph,Z)}createAnimationSampler(Z=""){return new OK(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 UC(this._graph,Z)}}vB._GRAPH_DOCUMENTS=new WeakMap;class T1{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 p1&&$.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}}T1.EXTENSION_NAME=void 0;var CT6={logger:z7.DEFAULT_INSTANCE,extensions:[],dependencies:{}},TT6=new Set([s.BUFFER,s.TEXTURE,s.MATERIAL,s.MESH,s.PRIMITIVE,s.NODE,s.SCENE]);var qH;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(qH||(qH={}));class SJ{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)=>iR1(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===QC.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=w4.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!==s.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}}SJ.BufferViewTarget=qH;SJ.BufferViewUsage=n5;SJ.USAGE_TO_TARGET={[n5.ARRAY_BUFFER]:qH.ARRAY_BUFFER,[n5.ELEMENT_ARRAY_BUFFER]:qH.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 iR1(Z,J){let X=Z.getGraph().listParentEdges(J).find((Y)=>Y.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{UNSIGNED_INT:ET6,UNSIGNED_SHORT:kT6,UNSIGNED_BYTE:IT6}=N0.ComponentType,vT6=new Set([s.ACCESSOR,s.BUFFER,s.MATERIAL,s.MESH]);var La;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(La||(La={}));var ja=163,Da=166;function nR1(){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 NK{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 AT6=new Uint8Array([0]),o6=[171,75,84,88,32,50,48,187,13,10,26,10];function Pa(Z){return new TextDecoder().decode(Z)}function xB(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,o6.length);if(J[0]!==o6[0]||J[1]!==o6[1]||J[2]!==o6[2]||J[3]!==o6[3]||J[4]!==o6[4]||J[5]!==o6[5]||J[6]!==o6[6]||J[7]!==o6[7]||J[8]!==o6[8]||J[9]!==o6[9]||J[10]!==o6[10]||J[11]!==o6[11])throw new Error("Missing KTX 2.0 identifier.");let X=nR1(),Y=17*Uint32Array.BYTES_PER_ELEMENT,$=new NK(Z,o6.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(),H=$._nextUint32(),z=$._nextUint64(),V=$._nextUint64(),F=Q*3*8,q=new NK(Z,o6.length+Y,F,!0);for(let z6=0;z6<Q;z6++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+q._nextUint64(),q._nextUint64()),uncompressedByteLength:q._nextUint64()});let U=new NK(Z,K,W,!0);U._skip(4);let B=U._nextUint16(),L=U._nextUint16(),w=U._nextUint16(),N=U._nextUint16(),R=U._nextUint8(),M=U._nextUint8(),D=U._nextUint8(),j=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()],A={vendorId:B,descriptorType:L,versionNumber:w,colorModel:R,colorPrimaries:M,transferFunction:D,flags:j,texelBlockDimension:C,bytesPlane:T,samples:[]},_=6,x=4,I=(N/4-_)/x;for(let z6=0;z6<I;z6++){let t7={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(t7.channelType&64)t7.sampleLower=U._nextInt32(),t7.sampleUpper=U._nextInt32();else t7.sampleLower=U._nextUint32(),t7.sampleUpper=U._nextUint32();A.samples[z6]=t7}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(A);let v=new NK(Z,G,H,!0);while(v._offset<H){let z6=v._nextUint32(),t7=v._scan(z6),Rq=Pa(t7);if(X.keyValue[Rq]=v._nextUint8Array(z6-t7.byteLength-1),Rq.match(/^ktx/i)){let iy=Pa(X.keyValue[Rq]);X.keyValue[Rq]=iy.substring(0,iy.lastIndexOf("\x00"))}let rW1=z6%4?4-z6%4:0;v._skip(rW1)}if(V<=0)return X;let y=new NK(Z,z,V,!0),p=y._nextUint16(),n=y._nextUint16(),o=y._nextUint32(),J0=y._nextUint32(),Q0=y._nextUint32(),D0=y._nextUint32(),C0=[];for(let z6=0;z6<Q;z6++)C0.push({imageFlags:y._nextUint32(),rgbSliceByteOffset:y._nextUint32(),rgbSliceByteLength:y._nextUint32(),alphaSliceByteOffset:y._nextUint32(),alphaSliceByteLength:y._nextUint32()});let a0=z+y._offset,E8=a0+o,i1=E8+J0,a4=i1+Q0,$4=new Uint8Array(Z.buffer,Z.byteOffset+a0,o),PQ=new Uint8Array(Z.buffer,Z.byteOffset+E8,J0),jQ=new Uint8Array(Z.buffer,Z.byteOffset+i1,Q0),oX=new Uint8Array(Z.buffer,Z.byteOffset+a4,D0);return X.globalData={endpointCount:p,selectorCount:n,imageDescs:C0,endpointsData:$4,selectorsData:PQ,tablesData:jQ,extendedData:oX},X}var DC="EXT_mesh_gpu_instancing",MC="EXT_meshopt_compression",aR1="EXT_texture_webp",sR1="EXT_texture_avif",ba="KHR_draco_mesh_compression",CC="KHR_lights_punctual",TC="KHR_materials_anisotropy",EC="KHR_materials_clearcoat",kC="KHR_materials_diffuse_transmission",IC="KHR_materials_dispersion",vC="KHR_materials_emissive_strength",_C="KHR_materials_ior",SC="KHR_materials_iridescence",AC="KHR_materials_pbrSpecularGlossiness",xC="KHR_materials_sheen",hC="KHR_materials_specular",fC="KHR_materials_transmission",yC="KHR_materials_unlit",bC="KHR_materials_volume",bY="KHR_materials_variants",oR1="KHR_mesh_quantization",rR1="KHR_texture_basisu",gC="KHR_texture_transform",hB="KHR_xmp_json_ld",PC="INSTANCE_ATTRIBUTE";class mC extends p1{init(){this.extensionName=DC,this.propertyType="InstancedMesh",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new a1})}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")}}mC.EXTENSION_NAME=DC;var DY=DC;class bB extends T1{constructor(...Z){super(...Z);this.extensionName=DY,this.provideTypes=[s.NODE],this.prewriteTypes=[s.ACCESSOR]}createInstancedMesh(){return new mC(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach((Y,$)=>{if(!Y.extensions||!Y.extensions[DY])return;let Q=Y.extensions[DY],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[$].setExtension(DY,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(DY);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[DY]=K}}),this}}bB.EXTENSION_NAME=DY;function BZ(){return BZ=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},BZ.apply(null,arguments)}var RH;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(RH||(RH={}));var MK;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(MK||(MK={}));var K8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})(K8||(K8={}));var{BYTE:tR1,SHORT:Ca,FLOAT:eR1}=N0.ComponentType,{encodeNormalizedInt:Ta,decodeNormalizedInt:jC}=Q8;function ZM1(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!==MK.ATTRIBUTES)return K;if($!==K8.NONE){let W=Z.getNormalized()?JM1(Z):new Float32Array(K.array);switch($){case K8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=eR1,K.normalized=!1,K.array=J.encodeFilterExp(W,Z.getCount(),K.byteStride,Q);break;case K8.OCTAHEDRAL:K.byteStride=Q>8?8:4,K.componentType=Q>8?Ca:tR1,K.normalized=!0,W=Z.getElementSize()===3?YM1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case K8.QUATERNION:K.byteStride=8,K.componentType=Ca,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)=>jC(G,Z.getComponentType())),K.max=K.max.map((G)=>jC(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>Ta(G,K.componentType)),K.max=K.max.map((G)=>Ta(G,K.componentType))}else if(K.byteStride%4)K.array=XM1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function JM1(Z){let J=Z.getComponentType(),X=Z.getArray(),Y=new Float32Array(X.length);for(let $=0;$<X.length;$++)Y[$]=jC(X[$],J);return Y}function XM1(Z,J){let Y=I6.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 YM1(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 $M1(Z,J){if(J===SJ.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some((Y)=>{return Y instanceof _J&&Y.getMode()===_J.Mode.TRIANGLES})?MK.TRIANGLES:MK.INDICES;return MK.ATTRIBUTES}function QM1(Z,J){let X=J.getGraph().listParentEdges(Z).filter((Y)=>!(Y.getParent()instanceof AB));for(let Y of X){let $=Y.getName(),Q=Y.getAttributes().key||"",K=Y.getParent().propertyType===s.PRIMITIVE_TARGET;if($==="indices")return{filter:K8.NONE};if($==="attributes"){if(Q==="POSITION")return{filter:K8.NONE};if(Q==="TEXCOORD_0")return{filter:K8.NONE};if(Q.startsWith("JOINTS_"))return{filter:K8.NONE};if(Q.startsWith("WEIGHTS_"))return{filter:K8.NONE};if(Q==="NORMAL"||Q==="TANGENT")return K?{filter:K8.NONE}:{filter:K8.OCTAHEDRAL,bits:8}}if($==="output"){let W=ga(Z);if(W==="rotation")return{filter:K8.QUATERNION,bits:16};if(W==="translation")return{filter:K8.EXPONENTIAL,bits:12};if(W==="scale")return{filter:K8.EXPONENTIAL,bits:12};return{filter:K8.NONE}}if($==="input")return{filter:K8.NONE};if($==="inverseBindMatrices")return{filter:K8.NONE}}return{filter:K8.NONE}}function ga(Z){for(let J of Z.listParents()){if(!(J instanceof OK))continue;for(let X of J.listParents()){if(!(X instanceof UH))continue;return X.getTargetPath()}}return null}function KM1(Z){if(!Z.extensions||!Z.extensions[MC])return!1;return!!Z.extensions[MC].fallback}var r6=MC,Ea={method:RH.QUANTIZE};class PH extends T1{constructor(...Z){super(...Z);this.extensionName=r6,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=Ea,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=BZ({},Ea,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${r6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${r6}]: 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[r6])return;let Q=Y.extensions[r6],K=Q.byteOffset||0,W=Q.byteLength||0,G=Q.count,H=Q.byteStride,z=new Uint8Array(G*H),V=J.json.buffers[Q.buffer],F=V.uri?J.resources[V.uri]:J.resources[FC],q=I6.toView(F,K,W);this._decoder.decodeGltfBuffer(z,G,H,q,Q.mode,Q.filter),Z.bufferViews[$]=z})}_prereadPrimitives(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach((Y)=>{if(!Y.extensions||!Y.extensions[r6])return;let $=Y.extensions[r6],Q=Z.buffers[$.buffer],K=Z.buffers[Y.buffer],W=J.json.buffers[Y.buffer];if(KM1(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,H=(z)=>{for(let V of $.listParents(z)){if(V.propertyType===s.ROOT)continue;let F=G.get(z);if(F===void 0)G.set(z,F=W++);return F}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let z of this.document.getRoot().listAccessors()){if(ga(z)==="weights")continue;if(z.getSparse())continue;let V=Z.getAccessorUsage(z),F=Z.accessorUsageGroupedByParent.has(V)?H(z):null,q=$M1(z,V),U=Y.method===RH.FILTER?QM1(z,this.document):{filter:K8.NONE},B=ZM1(z,X,q,U),{array:L,byteStride:w}=B,N=z.getBuffer();if(!N)throw new Error(`${r6}: Missing buffer for accessor.`);let R=this.document.getRoot().listBuffers().indexOf(N),M=[V,F,q,U.filter,w,R].join(":"),D=this._encoderBufferViews[M],j=this._encoderBufferViewData[M],C=this._encoderBufferViewAccessors[M];if(!D||!j)C=this._encoderBufferViewAccessors[M]=[],j=this._encoderBufferViewData[M]=[],D=this._encoderBufferViews[M]={buffer:K,target:SJ.USAGE_TO_TARGET[V],byteOffset:0,byteLength:0,byteStride:V===SJ.BufferViewUsage.ARRAY_BUFFER?w:void 0,extensions:{[r6]:{buffer:R,byteOffset:0,byteLength:0,mode:q,filter:U.filter!==K8.NONE?U.filter:void 0,byteStride:w,count:0}}};let T=Z.createAccessorDef(z);if(T.componentType=B.componentType,T.normalized=B.normalized,T.byteOffset=D.byteLength,T.min&&B.min)T.min=B.min;if(T.max&&B.max)T.max=B.max;Z.accessorIndexMap.set(z,J.accessors.length),J.accessors.push(T),C.push(T),j.push(new Uint8Array(L.buffer,L.byteOffset,L.byteLength)),D.byteLength+=L.byteLength,D.extensions.EXT_meshopt_compression.count+=z.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[r6].buffer],K=Z.otherBufferViews.get(Q)||[],{count:W,byteStride:G,mode:H}=Y.extensions[r6],z=I6.concat($),V=J.encodeGltfBuffer(z,W,G,H),F=I6.pad(V);Y.extensions[r6].byteLength=V.byteLength,$.length=0,$.push(F),K.push(F),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),H=this._encoderBufferViewAccessors[Q];for(let q of H)q.bufferView=G;let z=Z.jsonDoc.json.bufferViews[G],V=z.byteOffset||0;Object.assign(z,K),z.byteOffset=J;let F=z.extensions[r6];F.byteOffset=V,J+=I6.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,Y=Z.bufferIndexMap.get(X),$=Z.jsonDoc.json.buffers[Y];return $.byteLength=J,$.extensions={[r6]:{fallback:!0}},X.dispose(),this}}PH.EXTENSION_NAME=r6;PH.EncoderMethod=RH;var wH=sR1;class ma{match(Z){return Z.length>=12&&I6.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=ka(J,0);if(!X)return null;let Y=X.end;while(X=ka(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 gB extends T1{constructor(...Z){super(...Z);this.extensionName=wH,this.prereadTypes=[s.TEXTURE]}static register(){w4.registerFormat("image/avif",new ma)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[wH])X.source=X.extensions[wH].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[wH]={source:Q.source},delete Q.source})}}),this}}gB.EXTENSION_NAME=wH;function ka(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:I6.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}var OH=aR1;class ua{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=I6.decodeText(Z.slice(0,4)),X=I6.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=I6.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),H=Y.getUint8($+11),z=Y.getUint8($+12),V=1+((G&63)<<8|W),F=1+((z&15)<<10|H<<2|(G&192)>>6);return[V,F]}$+=8+K+K%2}return null}getChannels(Z){return 4}}class mB extends T1{constructor(...Z){super(...Z);this.extensionName=OH,this.prereadTypes=[s.TEXTURE]}static register(){w4.registerFormat("image/webp",new ua)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[OH])X.source=X.extensions[OH].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[OH]={source:Q.source},delete Q.source})}}),this}}mB.EXTENSION_NAME=OH;var Ia=ba,g8,da,la;function WM1(Z,J){let X=new g8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==g8.TRIANGULAR_MESH)throw new Error(`[${Ia}] Unknown geometry type.`);let $=new g8.Mesh;if(!Z.DecodeBufferToMesh(X,$).ok()||$.ptr===0)throw new Error(`[${Ia}] Decoding failure.`);return $}finally{g8.destroy(X)}}function GM1(Z,J){let Y=J.num_faces()*3,$,Q;if(J.num_points()<=65534){let K=Y*Uint16Array.BYTES_PER_ELEMENT;$=g8._malloc(K),Z.GetTrianglesUInt16Array(J,K,$),Q=new Uint16Array(g8.HEAPU16.buffer,$,Y).slice()}else{let K=Y*Uint32Array.BYTES_PER_ELEMENT;$=g8._malloc(K),Z.GetTrianglesUInt32Array(J,K,$),Q=new Uint32Array(g8.HEAPU32.buffer,$,Y).slice()}return g8._free($),Q}function HM1(Z,J,X,Y){let $=la[Y.componentType],Q=da[Y.componentType],K=X.num_components(),G=J.num_points()*K,H=G*Q.BYTES_PER_ELEMENT,z=g8._malloc(H);Z.GetAttributeDataArrayForAllPoints(J,X,$,H,z);let V=new Q(g8.HEAPF32.buffer,z,G).slice();return g8._free(z),V}function zM1(Z){g8=Z,da={[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},la={[N0.ComponentType.FLOAT]:g8.DT_FLOAT32,[N0.ComponentType.UNSIGNED_INT]:g8.DT_UINT32,[N0.ComponentType.UNSIGNED_SHORT]:g8.DT_UINT16,[N0.ComponentType.UNSIGNED_BYTE]:g8.DT_UINT8,[N0.ComponentType.SHORT]:g8.DT_INT16,[N0.ComponentType.BYTE]:g8.DT_INT8}}var C9,MH;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(MH||(MH={}));var T9;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(T9||(T9={}));var ca={[T9.POSITION]:14,[T9.NORMAL]:10,[T9.COLOR]:8,[T9.TEX_COORD]:12,[T9.GENERIC]:12},va={decodeSpeed:5,encodeSpeed:5,method:MH.EDGEBREAKER,quantizationBits:ca,quantizationVolume:"mesh"};function FM1(Z){C9=Z}function VM1(Z,J=va){let X=BZ({},va,J);X.quantizationBits=BZ({},ca,J.quantizationBits);let Y=new C9.MeshBuilder,$=new C9.Mesh,Q=new C9.ExpertEncoder($),K={},W=new C9.DracoInt8Array,G=Z.listTargets().length>0,H=!1;for(let B of Z.listSemantics()){let L=Z.getAttribute(B);if(L.getSparse()){H=!0;continue}let w=qM1(B),N=UM1(Y,L.getComponentType(),$,C9[w],L.getCount(),L.getElementSize(),L.getArray());if(N===-1)throw new Error(`Error compressing "${B}" attribute.`);if(K[B]=N,X.quantizationVolume==="mesh"||B!=="POSITION")Q.SetAttributeQuantization(N,X.quantizationBits[w]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:R}=X,M=Math.max(R.max[0]-R.min[0],R.max[1]-R.min[1],R.max[2]-R.min[2]);Q.SetAttributeExplicitQuantization(N,X.quantizationBits[w],L.getElementSize(),R.min,M)}else throw new Error("Invalid quantization volume state.")}let z=Z.getIndices();if(!z)throw new fB("Primitive must have indices.");if(Y.AddFacesToMesh($,z.getCount()/3,z.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===MH.SEQUENTIAL||G||H)Q.SetEncodingMethod(C9.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(C9.MESH_EDGEBREAKER_ENCODING);let V=Q.EncodeToDracoBuffer(!(G||H),W);if(V<=0)throw new fB("Error applying Draco compression.");let F=new Uint8Array(V);for(let B=0;B<V;++B)F[B]=W.GetValue(B);let q=Q.GetNumberOfEncodedPoints(),U=Q.GetNumberOfEncodedFaces()*3;return C9.destroy(W),C9.destroy($),C9.destroy(Y),C9.destroy(Q),{numVertices:q,numIndices:U,data:F,attributeIDs:K}}function qM1(Z){if(Z==="POSITION")return T9.POSITION;else if(Z==="NORMAL")return T9.NORMAL;else if(Z.startsWith("COLOR_"))return T9.COLOR;else if(Z.startsWith("TEXCOORD_"))return T9.TEX_COORD;return T9.GENERIC}function UM1(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 fB extends Error{}var N8=ba;class jH extends T1{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,zM1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,FM1(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,H]=Y.get(W.bufferView)||[];if(!H||!G){let z=X.json.bufferViews[W.bufferView],V=X.json.buffers[z.buffer],F=V.uri?X.resources[V.uri]:X.resources[FC],q=z.byteOffset||0,U=z.byteLength,B=I6.toView(F,q,U);G=new this._decoderModule.Decoder,H=WM1(G,B),Y.set(W.bufferView,[G,H]),J.debug(`[${N8}] Decompressed ${B.byteLength} bytes.`)}for(let z in W.attributes){let V=Z.jsonDoc.json.accessors[K.attributes[z]],F=G.GetAttributeByUniqueId(H,W.attributes[z]),q=HM1(G,H,F,V);Z.accessors[K.attributes[z]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(GM1(G,H))}}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=LM1(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=Ba(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(),H=Z.jsonDoc.json.accessors,z;try{z=VM1(K,BZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof fB){X.warn(`[${N8}]: ${q.message} Skipping primitive compression.`);continue}throw q}$.set(W,z);let V=Z.createAccessorDef(G);if(V.count=z.numIndices,Z.accessorIndexMap.set(G,H.length),H.push(V),z.numVertices>65534&&N0.getComponentSize(V.componentType)<=2)V.componentType=N0.ComponentType.UNSIGNED_INT;else if(z.numVertices>254&&N0.getComponentSize(V.componentType)<=1)V.componentType=N0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let U=K.getAttribute(q);if(z.attributeIDs[q]===void 0)continue;let B=Z.createAccessorDef(U);B.count=z.numVertices,Z.accessorIndexMap.set(U,H.length),H.push(B)}let F=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(F))Z.otherBufferViews.set(F,[]);Z.otherBufferViews.get(F).push(z.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}}jH.EXTENSION_NAME=N8;jH.EncoderMethod=MH;function LM1(Z){let J=Z.getLogger(),X=new Set,Y=new Set,$=0,Q=0;for(let V of Z.getRoot().listMeshes())for(let F of V.listPrimitives())if(!F.getIndices())Y.add(F),$++;else if(F.getMode()!==_J.Mode.TRIANGLES)Y.add(F),Q++;else X.add(F);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 V=0;V<K.length;V++)W.set(K[V],V);let G=new Map,H=new Set,z=new Map;for(let V of Array.from(X)){let F=_a(V,W);if(H.has(F)){z.set(V,F);continue}if(G.has(V.getIndices())){let q=V.getIndices(),U=q.clone();W.set(U,Z.getRoot().listAccessors().length-1),V.swap(q,U)}for(let q of V.listAttributes())if(G.has(q)){let U=q.clone();W.set(U,Z.getRoot().listAccessors().length-1),V.swap(q,U)}F=_a(V,W),H.add(F),z.set(V,F),G.set(V.getIndices(),F);for(let q of V.listAttributes())G.set(q,F)}for(let V of Array.from(G.keys())){let F=new Set(V.listParents().map((q)=>q.propertyType));if(F.size!==2||!F.has(s.PRIMITIVE)||!F.has(s.ROOT))throw new Error(`[${N8}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let V of Array.from(X)){let F=z.get(V),q=V.getIndices();if(G.get(q)!==F||V.listAttributes().some((U)=>G.get(U)!==F))throw new Error(`[${N8}] Draco primitives must share all, or no, accessors.`)}for(let V of Array.from(Y)){let F=V.getIndices();if(G.has(F)||V.listAttributes().some((q)=>G.has(q)))throw new Error(`[${N8}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return z}function _a(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 PK extends p1{init(){this.extensionName=CC,this.propertyType="Light",this.parentTypes=[s.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:PK.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)}}PK.EXTENSION_NAME=CC;PK.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};var F7=CC;class uC extends T1{constructor(...Z){super(...Z);this.extensionName=F7}createLight(Z=""){return new PK(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[F7])return this;let $=(J.json.extensions[F7].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[F7])return;let W=Q.extensions[F7];Z.nodes[K].setExtension(F7,$[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(!Q8.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()===PK.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(F7);if(Q){let K=Z.nodeIndexMap.get($),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[F7]={light:Y.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[F7]={lights:X},this}}uC.EXTENSION_NAME=F7;var{R:BM1,G:wM1,B:OM1}=a5;class dC extends p1{init(){this.extensionName=TC,this.propertyType="Anisotropy",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new P1(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:BM1|wM1|OM1})}}dC.EXTENSION_NAME=TC;var CY=TC;class lC extends T1{constructor(...Z){super(...Z);this.extensionName=CY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createAnisotropy(){return new dC(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[CY]){let K=this.createAnisotropy();Z.materials[Q].setExtension(CY,K);let W=$.extensions[CY];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,H=Z.textures[Y[G.index].source];K.setAnisotropyTexture(H),Z.setTextureInfo(K.getAnisotropyTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(CY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[CY]={};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=CY;var{R:Sa,G:Aa,B:NM1}=a5;class cC extends p1{init(){this.extensionName=EC,this.propertyType="Clearcoat",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new P1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new P1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new P1(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:Sa})}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:Aa})}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:Sa|Aa|NM1})}}cC.EXTENSION_NAME=EC;var TY=EC;class pC extends T1{constructor(...Z){super(...Z);this.extensionName=TY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createClearcoat(){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[TY]){let K=this.createClearcoat();Z.materials[Q].setExtension(TY,K);let W=$.extensions[TY];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,H=Z.textures[Y[G.index].source];K.setClearcoatTexture(H),Z.setTextureInfo(K.getClearcoatTextureInfo(),G)}if(W.clearcoatRoughnessTexture!==void 0){let G=W.clearcoatRoughnessTexture,H=Z.textures[Y[G.index].source];K.setClearcoatRoughnessTexture(H),Z.setTextureInfo(K.getClearcoatRoughnessTextureInfo(),G)}if(W.clearcoatNormalTexture!==void 0){let G=W.clearcoatNormalTexture,H=Z.textures[Y[G.index].source];if(K.setClearcoatNormalTexture(H),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(TY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[TY]={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}}pC.EXTENSION_NAME=TY;var{R:RM1,G:MM1,B:PM1,A:jM1}=a5;class iC extends p1{init(){this.extensionName=kC,this.propertyType="DiffuseTransmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new P1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new P1(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:jM1})}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:RM1|MM1|PM1})}}iC.EXTENSION_NAME=kC;var EY=kC;class nC extends T1{constructor(...Z){super(...Z);this.extensionName=EY}createDiffuseTransmission(){return new iC(this.document.getGraph())}read(Z){let J=Z.jsonDoc,X=J.json.materials||[],Y=J.json.textures||[];return X.forEach(($,Q)=>{if($.extensions&&$.extensions[EY]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(EY,K);let W=$.extensions[EY];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,H=Z.textures[Y[G.index].source];K.setDiffuseTransmissionTexture(H),Z.setTextureInfo(K.getDiffuseTransmissionTextureInfo(),G)}if(W.diffuseTransmissionColorTexture!==void 0){let G=W.diffuseTransmissionColorTexture,H=Z.textures[Y[G.index].source];K.setDiffuseTransmissionColorTexture(H),Z.setTextureInfo(K.getDiffuseTransmissionColorTextureInfo(),G)}}}),this}write(Z){let J=Z.jsonDoc;for(let X of this.document.getRoot().listMaterials()){let Y=X.getExtension(EY);if(!Y)continue;let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[EY]={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}}nC.EXTENSION_NAME=EY;class aC extends p1{init(){this.extensionName=IC,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)}}aC.EXTENSION_NAME=IC;var kY=IC;class sC extends T1{constructor(...Z){super(...Z);this.extensionName=kY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createDispersion(){return new aC(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[kY]){let Q=this.createDispersion();Z.materials[$].setExtension(kY,Q);let K=Y.extensions[kY];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(kY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[kY]={dispersion:Y.getDispersion()}}}),this}}sC.EXTENSION_NAME=kY;class oC extends p1{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)}}oC.EXTENSION_NAME=vC;var IY=vC;class rC extends T1{constructor(...Z){super(...Z);this.extensionName=IY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createEmissiveStrength(){return new oC(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[IY]){let Q=this.createEmissiveStrength();Z.materials[$].setExtension(IY,Q);let K=Y.extensions[IY];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(IY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[IY]={emissiveStrength:Y.getEmissiveStrength()}}}),this}}rC.EXTENSION_NAME=IY;class tC extends p1{init(){this.extensionName=_C,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)}}tC.EXTENSION_NAME=_C;var vY=_C;class uB extends T1{constructor(...Z){super(...Z);this.extensionName=vY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIOR(){return new tC(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.createIOR();Z.materials[$].setExtension(vY,Q);let K=Y.extensions[vY];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(vY);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{},Q.extensions[vY]={ior:Y.getIOR()}}}),this}}uB.EXTENSION_NAME=vY;var{R:DM1,G:CM1}=a5;class eC extends p1{init(){this.extensionName=SC,this.propertyType="Iridescence",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new P1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new P1(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:DM1})}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:CM1})}}eC.EXTENSION_NAME=SC;var _Y=SC;class ZT extends T1{constructor(...Z){super(...Z);this.extensionName=_Y,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createIridescence(){return new eC(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[_Y]){let K=this.createIridescence();Z.materials[Q].setExtension(_Y,K);let W=$.extensions[_Y];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,H=Z.textures[Y[G.index].source];K.setIridescenceTexture(H),Z.setTextureInfo(K.getIridescenceTextureInfo(),G)}if(W.iridescenceThicknessTexture!==void 0){let G=W.iridescenceThicknessTexture,H=Z.textures[Y[G.index].source];K.setIridescenceThicknessTexture(H),Z.setTextureInfo(K.getIridescenceThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let Y=X.getExtension(_Y);if(Y){let $=Z.materialIndexMap.get(X),Q=J.json.materials[$];Q.extensions=Q.extensions||{};let K=Q.extensions[_Y]={};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}}ZT.EXTENSION_NAME=_Y;var{R:xa,G:ha,B:fa,A:ya}=a5;class JT extends p1{init(){this.extensionName=AC,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new P1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new P1(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:xa|ha|fa|ya,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:xa|ha|fa|ya})}}JT.EXTENSION_NAME=AC;var SY=AC;class dB extends T1{constructor(...Z){super(...Z);this.extensionName=SY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createPBRSpecularGlossiness(){return new JT(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[SY]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(SY,K);let W=$.extensions[SY];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,H=Z.textures[Y[G.index].source];K.setDiffuseTexture(H),Z.setTextureInfo(K.getDiffuseTextureInfo(),G)}if(W.specularGlossinessTexture!==void 0){let G=W.specularGlossinessTexture,H=Z.textures[Y[G.index].source];K.setSpecularGlossinessTexture(H),Z.setTextureInfo(K.getSpecularGlossinessTextureInfo(),G)}}}),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||{};let K=Q.extensions[SY]={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}}dB.EXTENSION_NAME=SY;var{R:TM1,G:EM1,B:kM1,A:IM1}=a5;class XT extends p1{init(){this.extensionName=xC,this.propertyType="Sheen",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new P1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new P1(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:TM1|EM1|kM1,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:IM1})}}XT.EXTENSION_NAME=xC;var AY=xC;class YT extends T1{constructor(...Z){super(...Z);this.extensionName=AY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSheen(){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[AY]){let K=this.createSheen();Z.materials[Q].setExtension(AY,K);let W=$.extensions[AY];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,H=Z.textures[Y[G.index].source];K.setSheenColorTexture(H),Z.setTextureInfo(K.getSheenColorTextureInfo(),G)}if(W.sheenRoughnessTexture!==void 0){let G=W.sheenRoughnessTexture,H=Z.textures[Y[G.index].source];K.setSheenRoughnessTexture(H),Z.setTextureInfo(K.getSheenRoughnessTextureInfo(),G)}}}),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||{};let K=Q.extensions[AY]={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}}YT.EXTENSION_NAME=AY;var{R:vM1,G:_M1,B:SM1,A:AM1}=a5;class $T extends p1{init(){this.extensionName=hC,this.propertyType="Specular",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new P1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new P1(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:AM1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:vM1|_M1|SM1,isColor:!0})}}$T.EXTENSION_NAME=hC;var xY=hC;class lB extends T1{constructor(...Z){super(...Z);this.extensionName=xY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createSpecular(){return new $T(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.createSpecular();Z.materials[Q].setExtension(xY,K);let W=$.extensions[xY];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,H=Z.textures[Y[G.index].source];K.setSpecularTexture(H),Z.setTextureInfo(K.getSpecularTextureInfo(),G)}if(W.specularColorTexture!==void 0){let G=W.specularColorTexture,H=Z.textures[Y[G.index].source];K.setSpecularColorTexture(H),Z.setTextureInfo(K.getSpecularColorTextureInfo(),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.getSpecularFactor()!==1)K.specularFactor=Y.getSpecularFactor();if(!Q8.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}}lB.EXTENSION_NAME=xY;var{R:xM1}=a5;class QT extends p1{init(){this.extensionName=fC,this.propertyType="Transmission",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new P1(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:xM1})}}QT.EXTENSION_NAME=fC;var hY=fC;class KT extends T1{constructor(...Z){super(...Z);this.extensionName=hY,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createTransmission(){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[hY]){let K=this.createTransmission();Z.materials[Q].setExtension(hY,K);let W=$.extensions[hY];if(W.transmissionFactor!==void 0)K.setTransmissionFactor(W.transmissionFactor);if(W.transmissionTexture!==void 0){let G=W.transmissionTexture,H=Z.textures[Y[G.index].source];K.setTransmissionTexture(H),Z.setTextureInfo(K.getTransmissionTextureInfo(),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]={transmissionFactor:Y.getTransmissionFactor()};if(Y.getTransmissionTexture()){let W=Y.getTransmissionTexture(),G=Y.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(W,G)}}}),this}}KT.EXTENSION_NAME=hY;class WT extends p1{init(){this.extensionName=yC,this.propertyType="Unlit",this.parentTypes=[s.MATERIAL]}}WT.EXTENSION_NAME=yC;var RK=yC;class cB extends T1{constructor(...Z){super(...Z);this.extensionName=RK,this.prereadTypes=[s.MESH],this.prewriteTypes=[s.MESH]}createUnlit(){return new WT(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[RK])Z.materials[Y].setExtension(RK,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(RK)){let Y=Z.materialIndexMap.get(X),$=J.json.materials[Y];$.extensions=$.extensions||{},$.extensions[RK]={}}}),this}}cB.EXTENSION_NAME=RK;class GT extends p1{init(){this.extensionName=bY,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new P0})}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")}}GT.EXTENSION_NAME=bY;class HT extends p1{init(){this.extensionName=bY,this.propertyType="MappingList",this.parentTypes=[s.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new P0})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}HT.EXTENSION_NAME=bY;class yB extends p1{init(){this.extensionName=bY,this.propertyType="Variant",this.parentTypes=["MappingList"]}}yB.EXTENSION_NAME=bY;var V7=bY;class zT extends T1{constructor(...Z){super(...Z);this.extensionName=V7}createMappingList(){return new HT(this.document.getGraph())}createVariant(Z=""){return new yB(this.document.getGraph(),Z)}createMapping(){return new GT(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof yB)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[V7])return this;let $=(J.json.extensions[V7].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,W)=>{let G=Z.meshes[W];(K.primitives||[]).forEach((z,V)=>{if(!z.extensions||!z.extensions[V7])return;let F=this.createMappingList(),q=z.extensions[V7];for(let U of q.mappings){let B=this.createMapping();if(U.material!==void 0)B.setMaterial(Z.materials[U.material]);for(let L of U.variants||[])B.addVariant($[L]);F.addMapping(B)}G.listPrimitives()[V].setExtension(V7,F)})}),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 H=W.getExtension(V7);if(!H)return;let z=Z.jsonDoc.json.meshes[K].primitives[G],V=H.listMappings().map((F)=>{let q=Z.createPropertyDef(F),U=F.getMaterial();if(U)q.material=Z.materialIndexMap.get(U);return q.variants=F.listVariants().map((B)=>$.get(B)),q});z.extensions=z.extensions||{},z.extensions[V7]={mappings:V}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[V7]={variants:Y},this}}zT.EXTENSION_NAME=V7;var{G:hM1}=a5;class FT extends p1{init(){this.extensionName=bC,this.propertyType="Volume",this.parentTypes=[s.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new P1(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:hM1})}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=bC;var fY=bC;class VT extends T1{constructor(...Z){super(...Z);this.extensionName=fY,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[fY]){let K=this.createVolume();Z.materials[Q].setExtension(fY,K);let W=$.extensions[fY];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,H=Z.textures[Y[G.index].source];K.setThicknessTexture(H),Z.setTextureInfo(K.getThicknessTextureInfo(),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]={};if(Y.getThicknessFactor()>0)K.thicknessFactor=Y.getThicknessFactor();if(Number.isFinite(Y.getAttenuationDistance()))K.attenuationDistance=Y.getAttenuationDistance();if(!Q8.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}}VT.EXTENSION_NAME=fY;var pa=oR1;class DH extends T1{constructor(...Z){super(...Z);this.extensionName=pa}read(Z){return this}write(Z){return this}}DH.EXTENSION_NAME=pa;var NH=rR1;class ia{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=xB(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=xB(Z).dataFormatDescriptor[0];if(X.colorModel===ja)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===Da)return(X.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=xB(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 qT extends T1{constructor(...Z){super(...Z);this.extensionName=NH,this.prereadTypes=[s.TEXTURE]}static register(){w4.registerFormat("image/ktx2",new ia)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[NH]){let X=J.extensions[NH];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[NH]={source:$.source},delete $.source})}}),this}}qT.EXTENSION_NAME=NH;class UT extends p1{init(){this.extensionName=gC,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)}}UT.EXTENSION_NAME=gC;var yY=gC;class LT extends T1{constructor(...Z){super(...Z);this.extensionName=yY}createTransform(){return new UT(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[yY])continue;let Y=this.createTransform(),$=X.extensions[yY];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(yY,Y)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,Y]of J){let $=X.getExtension(yY);if(!$)continue;Y.extensions=Y.extensions||{};let Q={},K=Q8.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[yY]=Q}return this}}LT.EXTENSION_NAME=yY;var fM1=[s.ROOT,s.SCENE,s.NODE,s.MESH,s.MATERIAL,s.TEXTURE,s.ANIMATION];class BT extends p1{init(){this.extensionName=hB,this.propertyType="Packet",this.parentTypes=fM1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",BZ({},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=BZ({},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 BZ({"@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(`${hB}: Missing context for term, "${Z}".`)}}BT.EXTENSION_NAME=hB;function RC(Z){return JSON.parse(JSON.stringify(Z))}var LZ=hB;class wT extends T1{constructor(...Z){super(...Z);this.extensionName=LZ}createPacket(){return new BT(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[LZ];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 H=K[G]||[];for(let z=0;z<H.length;z++){let V=H[z];if(V.extensions&&V.extensions[LZ]){let F=V.extensions[LZ];W[G][z].setExtension(LZ,Q[F.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(`[${LZ}]: Unsupported parent property, "${$.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[LZ]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[LZ]={packets:X};return this}}wT.EXTENSION_NAME=LZ;var yM1=[jH,uC,lC,pC,nC,sC,rC,uB,ZT,dB,lB,YT,KT,cB,zT,VT,DH,qT,LT,wT],yT6=[bB,PH,gB,mB,...yM1];var bM1=r(AD(),1);function CK(){return CK=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},CK.apply(null,arguments)}var{POINTS:na,LINES:pB,LINE_STRIP:gM1,LINE_LOOP:mM1,TRIANGLES:iB,TRIANGLE_STRIP:uM1,TRIANGLE_FAN:dM1}=w8.Mode;function fJ(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function q7(Z,J){let X=CK({},Z);for(let Y in J)if(J[Y]!==void 0)X[Y]=J[Y];return X}function qs(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case w8.Mode.POINTS:return J?J.getCount():X.getCount();case w8.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case w8.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case w8.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case w8.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case w8.Mode.TRIANGLE_STRIP:case w8.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw new Error("Unexpected mode: "+Z.getMode())}}var lM1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function MT(Z){return lM1.format(Z)}function cM1(Z,J,X=2){let Y=Z>J?"–":"+",$="%";return Y+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function rB(Z,J){return`${MT(Z)} → ${MT(J)} (${cM1(Z,J)})`}function kT(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 pM1(Z,J,X){Z.swap(J,X);for(let Y of Z.listTargets())Y.swap(J,X)}function iM1(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 wZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function nM1(Z,J=Z){let X=IT(Z,J);for(let Y=0;Y<X.length;Y++)X[Y]=Y;return X}function IT(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function aM1(Z){return Z.listParents().some((J)=>J.propertyType!==a.ROOT)}function Us(Z){for(let J in Z)return!1;return!0}function Ls(Z){let J=E6.fromGraph(Z.getGraph()),X=Z.getMaterial(),Y=J.getRoot().listMaterials().indexOf(X),$=oM1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((G)=>{let H=Z.getAttribute(G),z=H.getElementSize(),V=H.getComponentType();return`${G}:${z}:${V}`}).join("+"),W=Z.listTargets().map((G)=>{return G.listSemantics().sort().map((H)=>{let z=Z.getAttribute(H),V=z.getElementSize(),F=z.getComponentType();return`${H}:${V}:${F}`}).join("+")}).join("~");return`${Y}|${$}|${Q}|${K}|${W}`}function sM1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var oM1={[na]:na,[pB]:pB,[gM1]:pB,[mM1]:pB,[iB]:iB,[uM1]:iB,[dM1]:iB},jK="center",aa={pivot:"center"};function Bs(Z=aa){let J=q7(aa,Z);return fJ(jK,(X)=>{let Y=X.getLogger(),$=X.getRoot(),Q=$.listAnimations().length>0||$.listSkins().length>0;X.getRoot().listScenes().forEach((K,W)=>{Y.debug(`${jK}: Scene ${W+1} / ${$.listScenes().length}.`);let G;if(typeof J.pivot==="string"){let z=TD(K);if(G=[(z.max[0]-z.min[0])/2+z.min[0],(z.max[1]-z.min[1])/2+z.min[1],(z.max[2]-z.min[2])/2+z.min[2]],J.pivot==="above")G[1]=z.max[1];if(J.pivot==="below")G[1]=z.min[1]}else G=J.pivot;Y.debug(`${jK}: Pivot "${G.join(", ")}".`);let H=[-1*G[0],-1*G[1],-1*G[2]];if(Q){Y.debug(`${jK}: Model contains animation or skin. Adding a wrapper node.`);let z=X.createNode("Pivot").setTranslation(H);K.listChildren().forEach((V)=>z.addChild(V)),K.addChild(z)}else Y.debug(`${jK}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((z)=>{let V=z.getTranslation();z.setTranslation([V[0]+H[0],V[1]+H[1],V[2]+H[2]])})}),Y.debug(`${jK}: Complete.`)})}function rM1(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 GK)}function tM1(Z){let J=rM1(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 TK=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 eM1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],H=J[7],z=J[8],V=J[9],F=J[10],q=J[11],U=J[12],B=J[13],L=J[14],w=J[15],N=X*W-Y*K,R=X*G-$*K,M=X*H-Q*K,D=Y*G-$*W,j=Y*H-Q*W,C=$*H-Q*G,T=z*B-V*U,E=z*L-F*U,A=z*w-q*U,_=V*L-F*B,x=V*w-q*B,I=F*w-q*L,v=N*I-R*x+M*_+D*A-j*E+C*T;if(!v)return null;return v=1/v,Z[0]=(W*I-G*x+H*_)*v,Z[1]=($*x-Y*I-Q*_)*v,Z[2]=(B*C-L*j+w*D)*v,Z[3]=(F*j-V*C-q*D)*v,Z[4]=(G*A-K*I-H*E)*v,Z[5]=(X*I-$*A+Q*E)*v,Z[6]=(L*M-U*C-w*R)*v,Z[7]=(z*C-F*M+q*R)*v,Z[8]=(K*x-W*A+H*T)*v,Z[9]=(Y*A-X*x-Q*T)*v,Z[10]=(U*j-B*M+w*N)*v,Z[11]=(V*M-z*j-q*N)*v,Z[12]=(W*E-K*_-G*T)*v,Z[13]=(X*_-Y*E+$*T)*v,Z[14]=(B*R-U*D-L*N)*v,Z[15]=(z*D-V*R+F*N)*v,Z}function ZP1(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],H=Z[8],z=Z[9],V=Z[10],F=Z[11],q=Z[12],U=Z[13],B=Z[14],L=Z[15],w=J*K-X*Q,N=J*W-Y*Q,R=J*G-$*Q,M=X*W-Y*K,D=X*G-$*K,j=Y*G-$*W,C=H*U-z*q,T=H*B-V*q,E=H*L-F*q,A=z*B-V*U,_=z*L-F*U,x=V*L-F*B;return w*x-N*_+R*A+M*E-D*T+j*C}function ws(Z,J,X){var Y=J[0],$=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],H=J[6],z=J[7],V=J[8],F=J[9],q=J[10],U=J[11],B=J[12],L=J[13],w=J[14],N=J[15],R=X[0],M=X[1],D=X[2],j=X[3];return Z[0]=R*Y+M*W+D*V+j*B,Z[1]=R*$+M*G+D*F+j*L,Z[2]=R*Q+M*H+D*q+j*w,Z[3]=R*K+M*z+D*U+j*N,R=X[4],M=X[5],D=X[6],j=X[7],Z[4]=R*Y+M*W+D*V+j*B,Z[5]=R*$+M*G+D*F+j*L,Z[6]=R*Q+M*H+D*q+j*w,Z[7]=R*K+M*z+D*U+j*N,R=X[8],M=X[9],D=X[10],j=X[11],Z[8]=R*Y+M*W+D*V+j*B,Z[9]=R*$+M*G+D*F+j*L,Z[10]=R*Q+M*H+D*q+j*w,Z[11]=R*K+M*z+D*U+j*N,R=X[12],M=X[13],D=X[14],j=X[15],Z[12]=R*Y+M*W+D*V+j*B,Z[13]=R*$+M*G+D*F+j*L,Z[14]=R*Q+M*H+D*q+j*w,Z[15]=R*K+M*z+D*U+j*N,Z}function JP1(){var Z=new TK(9);if(TK!=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 XP1(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 YP1(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 $P1(Z,J){var X=J[0],Y=J[1],$=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],H=J[7],z=J[8],V=z*K-W*H,F=-z*Q+W*G,q=H*Q-K*G,U=X*V+Y*F+$*q;if(!U)return null;return U=1/U,Z[0]=V*U,Z[1]=(-z*Y+$*H)*U,Z[2]=(W*Y-$*K)*U,Z[3]=F*U,Z[4]=(z*X-$*G)*U,Z[5]=(-W*X+$*Q)*U,Z[6]=q*U,Z[7]=(-H*X+Y*G)*U,Z[8]=(K*X-Y*Q)*U,Z}function tB(){var Z=new TK(3);if(TK!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function QP1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function Os(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 KP1(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 WP1(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 GP1=QP1;(function(){var Z=tB();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 xJ="dedup",OT={keepUniqueNames:!1,propertyTypes:[a.ACCESSOR,a.MESH,a.TEXTURE,a.MATERIAL,a.SKIN]};function Ns(Z=OT){let J=q7(OT,Z),X=new Set(J.propertyTypes);for(let Y of J.propertyTypes)if(!OT.propertyTypes.includes(Y))throw new Error(`${xJ}: Unsupported deduplication on type "${Y}".`);return fJ(xJ,(Y)=>{let $=Y.getLogger();if(X.has(a.ACCESSOR))HP1(Y);if(X.has(a.TEXTURE))FP1(Y,J);if(X.has(a.MATERIAL))VP1(Y,J);if(X.has(a.MESH))zP1(Y,J);if(X.has(a.SKIN))qP1(Y,J);$.debug(`${xJ}: Complete.`)})}function HP1(Z){let J=Z.getLogger(),X=new Map,Y=new Map,$=new Map,Q=new Map,K=Z.getRoot().listMeshes();K.forEach((V)=>{V.listPrimitives().forEach((F)=>{F.listAttributes().forEach((q)=>W(q,Y)),W(F.getIndices(),X)})});for(let V of Z.getRoot().listAnimations())for(let F of V.listSamplers())W(F.getInput(),$),W(F.getOutput(),Q);function W(V,F){if(!V)return;let q=[V.getCount(),V.getType(),V.getComponentType(),V.getNormalized(),V.getSparse()].join(":"),U=F.get(q);if(!U)F.set(q,U=new Set);U.add(V)}function G(V,F){for(let q=0;q<V.length;q++){let U=V[q],B=n0.toView(U.getArray());if(F.has(U))continue;for(let L=q+1;L<V.length;L++){let w=V[L];if(F.has(w))continue;if(n0.equals(B,n0.toView(w.getArray())))F.set(w,U)}}}let H=0,z=new Map;for(let V of[Y,X,$,Q])for(let F of V.values())H+=F.size,G(Array.from(F),z);J.debug(`${xJ}: Merged ${z.size} of ${H} accessors.`),K.forEach((V)=>{V.listPrimitives().forEach((F)=>{F.listAttributes().forEach((U)=>{if(z.has(U))F.swap(U,z.get(U))});let q=F.getIndices();if(q&&z.has(q))F.swap(q,z.get(q))})});for(let V of Z.getRoot().listAnimations())for(let F of V.listSamplers()){let q=F.getInput(),U=F.getOutput();if(q&&z.has(q))F.swap(q,z.get(q));if(U&&z.has(U))F.swap(U,z.get(U))}Array.from(z.keys()).forEach((V)=>V.dispose())}function zP1(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 z of W.listPrimitives())G.push(Rs(z,$));let H="";if(J.keepUniqueNames)H+=W.getName()+";";if(H+=G.join(";"),K.has(H)){let z=K.get(H);W.listParents().forEach((V)=>{if(V.propertyType!==a.ROOT)V.swap(W,z)}),W.dispose()}else K.set(H,W)}X.debug(`${xJ}: Merged ${Q-K.size} of ${Q} meshes.`)}function FP1(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 H=K+1;H<$.length;H++){let z=$[H],V=z.getImage();if(Q.has(z))continue;if(W.getMimeType()!==z.getMimeType())continue;if(J.keepUniqueNames&&W.getName()!==z.getName())continue;let F=W.getSize(),q=z.getSize();if(!F||!q)continue;if(F[0]!==q[0])continue;if(F[1]!==q[1])continue;if(!G||!V)continue;if(n0.equals(G,V))Q.set(z,W)}}X.debug(`${xJ}: Merged ${Q.size} of ${Y.listTextures().length} textures.`),Array.from(Q.entries()).forEach(([K,W])=>{K.listParents().forEach((G)=>{if(!(G instanceof NY))G.swap(K,W)}),K.dispose()})}function VP1(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 H=$[G];if(Q.has(H))continue;if(sa(H,K))continue;for(let z=G+1;z<$.length;z++){let V=$[z];if(Q.has(V))continue;if(sa(V,K))continue;if(H.equals(V,W))Q.set(V,H)}}X.debug(`${xJ}: Merged ${Q.size} of ${$.length} materials.`),Array.from(Q.entries()).forEach(([G,H])=>{G.listParents().forEach((z)=>{if(!(z instanceof NY))z.swap(G,H)}),G.dispose()})}function qP1(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 H=W+1;H<$.length;H++){let z=$[H];if(Q.has(z))continue;if(G.equals(z,K)&&iM1(G.listJoints(),z.listJoints()))Q.set(z,G)}}X.debug(`${xJ}: Merged ${Q.size} of ${$.length} skins.`),Array.from(Q.entries()).forEach(([W,G])=>{W.listParents().forEach((H)=>{if(!(H instanceof NY))H.swap(W,G)}),W.dispose()})}function Rs(Z,J){let X=[];for(let Y of Z.listSemantics()){let $=Z.getAttribute(Y);X.push(Y+":"+J.get($))}if(Z instanceof w8){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:"+Rs(Q,J))}return X.join(",")}function sa(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 Ms(){var Z=new TK(4);if(TK!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function UP1(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 LP1(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 BP1(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 wP1(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 OP1(Z){var J=Z[0],X=Z[1],Y=Z[2],$=Z[3];return Math.hypot(J,X,Y,$)}var Ps=LP1,NP1=BP1,js=OP1;(function(){var Z=Ms();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 RP1=/color|emissive|diffuse/i;function MP1(Z){return Z.getGraph().listParentEdges(Z).some(($)=>{return $.getAttributes().isColor||RP1.test($.getName())})?"srgb":null}function PP1(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 OY)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 M5&&K.has(W.getName()))Y.add(G);else if(G instanceof WK)$(G)}}return $(Z),Array.from(Y)}function jP1(Z){let X=E6.fromGraph(Z.getGraph()).getRoot(),Y=Z.getGraph().listParentEdges(Z).filter(($)=>$.getParent()!==X).map(($)=>$.getName());return Array.from(new Set(Y))}var DK="prune",PT=0.011764705882352941,oa={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 eB(Z=oa){let J=q7(oa,Z),X=new Set(J.propertyTypes),Y=J.keepExtras;return fJ(DK,async($)=>{let Q=$.getLogger(),K=$.getRoot(),W=$.getGraph(),G=new Ds,H=(z)=>G.dispose(z.target);if(W.addEventListener("node:dispose",H),X.has(a.MESH))for(let z of K.listMeshes()){if(z.listPrimitives().length>0)continue;z.dispose()}if(X.has(a.NODE)){if(!J.keepLeaves)for(let z of K.listScenes())Cs(W,z,Y);for(let z of K.listNodes())E9(z,Y)}if(X.has(a.SKIN))for(let z of K.listSkins())E9(z,Y);if(X.has(a.MESH))for(let z of K.listMeshes())E9(z,Y);if(X.has(a.CAMERA))for(let z of K.listCameras())E9(z,Y);if(X.has(a.PRIMITIVE))ra(W,a.PRIMITIVE,Y);if(X.has(a.PRIMITIVE_TARGET))ra(W,a.PRIMITIVE_TARGET,Y);if(!J.keepAttributes&&X.has(a.ACCESSOR)){let z=new Map;for(let V of K.listMeshes())for(let F of V.listPrimitives()){let q=F.getMaterial();if(!q)continue;let U=Ts($,F,q),B=CP1(F,U);ta(F,B),F.listTargets().forEach((L)=>ta(L,B)),z.has(q)?z.get(q).add(F):z.set(q,new Set([F]))}for(let[V,F]of z)TP1(V,Array.from(F))}if(!J.keepIndices&&X.has(a.ACCESSOR))for(let z of K.listMeshes())for(let V of z.listPrimitives())DP1(V);if(X.has(a.ANIMATION))for(let z of K.listAnimations()){for(let V of z.listChannels())if(!V.getTargetNode())V.dispose();if(!z.listChannels().length){let V=z.listSamplers();E9(z,Y),V.forEach((F)=>E9(F,Y))}else z.listSamplers().forEach((V)=>E9(V,Y))}if(X.has(a.MATERIAL))K.listMaterials().forEach((z)=>E9(z,Y));if(X.has(a.TEXTURE)){if(K.listTextures().forEach((z)=>E9(z,Y)),!J.keepSolidTextures)await EP1($)}if(X.has(a.ACCESSOR))K.listAccessors().forEach((z)=>E9(z,Y));if(X.has(a.BUFFER))K.listBuffers().forEach((z)=>E9(z,Y));if(W.removeEventListener("node:dispose",H),!G.empty()){let z=G.entries().map(([V,F])=>`${V} (${F})`).join(", ");Q.info(`${DK}: Removed types... ${z}`)}else Q.debug(`${DK}: No unused properties found.`);Q.debug(`${DK}: Complete.`)})}class Ds{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 E9(Z,J){let X=Z.listParents().filter(($)=>!($ instanceof NY||$ instanceof BY)),Y=J&&!Us(Z.getExtras());if(!X.length&&!Y)Z.dispose()}function ra(Z,J,X){for(let Y of Z.listEdges()){let $=Y.getParent();if($.propertyType===J)E9($,X)}}function Cs(Z,J,X){if(J.listChildren().forEach((K)=>Cs(Z,K,X)),J instanceof GK)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&&!Us(J.getExtras());if($&&!Y&&!Q)J.dispose()}function ta(Z,J){for(let X of J)Z.setAttribute(X,null)}function DP1(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 CP1(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 Ts(Z,J,X,Y=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let H of Q)if(H.getChild()instanceof OY)K.add(H.getName());for(let H of Q){let z=H.getName(),V=H.getChild();if(V instanceof M5){if(K.has(z.replace(/Info$/,"")))Y.add(`TEXCOORD_${V.getTexCoord()}`)}if(V instanceof OY&&z.match(/normalTexture/i))Y.add("TANGENT");if(V instanceof WK)Ts(Z,J,V,Y)}let W=X instanceof $7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===w8.Mode.POINTS;if(W&&!G)Y.add("NORMAL");return Y}function TP1(Z,J){let X=PP1(Z),Y=new Set(X.map((G)=>G.getTexCoord())),$=Array.from(Y).sort(),Q=new Map($.map((G,H)=>[G,H])),K=new Map($.map((G,H)=>[`TEXCOORD_${G}`,`TEXCOORD_${H}`]));for(let G of X){let H=G.getTexCoord();G.setTexCoord(Q.get(H))}for(let G of J){let H=G.listSemantics().filter((z)=>z.startsWith("TEXCOORD_")).sort();W(G,H),G.listTargets().forEach((z)=>W(z,H))}function W(G,H){for(let z of H){let V=G.getAttribute(z);if(!V)continue;let F=K.get(z);if(F===z)continue;G.setAttribute(F,V),G.setAttribute(z,null)}}}async function EP1(Z){let J=Z.getRoot(),X=Z.getGraph(),Y=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await IP1(K);if(!G)return;if(MP1(K)==="srgb")ED.convertSRGBToLinear(G,G);let H=K.getName()||K.getURI(),z=(W=K.getSize())==null?void 0:W.join("x"),V=jP1(K);for(let F of X.listParentEdges(K)){let q=F.getParent();if(q!==J&&kP1(q,G,F.getName(),Y))F.dispose()}if(K.listParents().length===1)K.dispose(),Y.debug(`${DK}: Removed solid-color texture "${H}" (${z}px ${V.join(", ")})`)});await Promise.all(Q)}function kP1(Z,J,X,Y){if(Z instanceof $7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(NP1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(GP1([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 js(Ps(Ms(),J,[0.5,0.5,1,1]))<=PT}return Y.warn(`${DK}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function IP1(Z){let J=await vP1(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 H=0;H<4;H++)X[H]=Math.min(X[H],J.get(W,G,H)),Y[H]=Math.max(Y[H],J.get(W,G,H));if(js(Ps($,Y,X))/255>PT)return null}return wP1($,UP1($,Y,X),0.00196078431372549)}async function vP1(Z){try{return await Fa(Z.getImage(),Z.getMimeType())}catch(J){return null}}var AJ=4294967295;class Es{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of kT(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 _P1(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 _P1(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 SP1(Z,J,X,Y,$=AJ){let Q=J-1,W=X.hash(Y)&Q;for(let G=0;G<=Q;G++){let H=Z[W];if(H===$||X.equal(H,Y))return W;W=W+G+1&Q}throw new Error("Hash table full.")}var L6;(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"})(L6||(L6={}));function hJ(Z,J){let X=Z.getAttribute("POSITION"),Y=Z.getIndices();switch(J){case L6.RENDER:return Y?Y.getCount():X.getCount();case L6.RENDER_CACHED:return Y?new Set(Y.getArray()).size:X.getCount();case L6.UPLOAD_NAIVE:case L6.UPLOAD:return X.getCount();case L6.DISTINCT:case L6.DISTINCT_POSITION:return AP1(J);case L6.UNUSED:return Y?X.getCount()-new Set(Y.getArray()).size:0;default:return xP1(J)}}function AP1(Z){throw new Error(`Not implemented: ${Z}`)}function xP1(Z){throw new Error(`Unexpected value: ${Z}`)}function TH(Z,J,X){let Y=E6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=hP1(Z);let $=Z.getIndices(),Q=$?$.getArray():null,K=hJ(Z,L6.RENDER),W=Y.createAccessor(),G=K,H=IT(G,X);for(let V=0;V<G;V++)H[V]=J[Q?Q[V]:V];Z.setIndices(W.setArray(H));let z=kT(Z);for(let V of Z.listAttributes()){let F=wZ(Y,V);jT(V,$,J,F,X),Z.swap(V,F)}for(let V of Z.listTargets())for(let F of V.listAttributes()){let q=wZ(Y,F);jT(F,$,J,q,X),V.swap(F,q)}if($&&$.listParents().length===1)$.dispose();for(let V of z)if(V.listParents().length===1)V.dispose();return Z}function jT(Z,J,X,Y,$){let Q=Z.getElementSize(),K=Z.getArray(),W=J?J.getArray():null,G=J?J.getCount():Z.getCount(),H=new K.constructor($*Q),z=new Uint8Array($);for(let V=0;V<G;V++){let F=W?W[V]:V,q=X[F];if(z[q])continue;for(let U=0;U<Q;U++)H[q*Q+U]=K[F*Q+U];z[q]=1}return Y.setArray(H)}function hP1(Z){let J=hJ(Z,L6.UPLOAD),X=Z.getIndices(),Y=X?X.getArray():null;if(!X||!Y)return[nM1(J,1e6),J];let $=new Uint32Array(J).fill(AJ),Q=0;for(let K=0;K<Y.length;K++){let W=Y[K];if($[W]===AJ)$[W]=Q++}return[$,Q]}var DT="weld",aB={overwrite:!0,cleanup:!0};function vT(Z=aB){let J=q7(aB,Z);return fJ(DT,async(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes()){for(let Q of $.listPrimitives())if(Z2(Q,J),hJ(Q,L6.RENDER)===0)Q.dispose();if($.listPrimitives().length===0)$.dispose()}if(J.cleanup)await X.transform(eB({propertyTypes:[a.ACCESSOR,a.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),Ns({propertyTypes:[a.ACCESSOR]}));Y.debug(`${DT}: Complete.`)})}function Z2(Z,J=aB){let X=Z.getGraph(),$=E6.fromGraph(X).getLogger(),Q=CK({},aB,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===w8.Mode.POINTS)return;let K=Z.getAttribute("POSITION").getCount(),W=Z.getIndices(),G=W==null?void 0:W.getArray(),H=W?W.getCount():K,z=new Es(Z),V=sM1(K+K/4),F=new Uint32Array(V).fill(AJ),q=new Uint32Array(K).fill(AJ),U=0;for(let B=0;B<H;B++){let L=G?G[B]:B;if(q[L]!==AJ)continue;let w=SP1(F,V,z,L,AJ),N=F[w];if(N===AJ)F[w]=L,q[L]=U++;else q[L]=q[N]}$.debug(`${DT}: ${rB(K,U)} vertices.`),TH(Z,q,U)}var{FLOAT:fP1}=E0.ComponentType;function ks(Z,J){let X=Z.getAttribute("POSITION");if(X)ea(J,X);let Y=Z.getAttribute("NORMAL");if(Y)Zs(J,Y);let $=Z.getAttribute("TANGENT");if($)Js(J,$);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)ea(J,K);let W=Q.getAttribute("NORMAL");if(W)Zs(J,W);let G=Q.getAttribute("TANGENT");if(G)Js(J,G)}if(ZP1(J)<0)yP1(Z)}function ea(Z,J){let X=J.getComponentType(),Y=J.getNormalized(),$=J.getArray(),Q=X===fP1?$:new Float32Array($.length),K=tB();for(let W=0,G=J.getCount();W<G;W++){if(Y)K[0]=d0.decodeNormalizedInt($[W*3],X),K[1]=d0.decodeNormalizedInt($[W*3+1],X),K[2]=d0.decodeNormalizedInt($[W*3+2],X);else K[0]=$[W*3],K[1]=$[W*3+1],K[2]=$[W*3+2];KP1(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 Zs(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=JP1();XP1(Q,Z),$P1(Q,Q),YP1(Q,Q);let K=tB();for(let W=0,G=J.getCount();W<G;W++){if(Y)K[0]=d0.decodeNormalizedInt(X[W*3],$),K[1]=d0.decodeNormalizedInt(X[W*3+1],$),K[2]=d0.decodeNormalizedInt(X[W*3+2],$);else K[0]=X[W*3],K[1]=X[W*3+1],K[2]=X[W*3+2];if(WP1(K,K,Q),Os(K,K),Y)X[W*3]=d0.decodeNormalizedInt(K[0],$),X[W*3+1]=d0.decodeNormalizedInt(K[1],$),X[W*3+2]=d0.decodeNormalizedInt(K[2],$);else X[W*3]=K[0],X[W*3+1]=K[1],X[W*3+2]=K[2]}}function Js(Z,J){let X=J.getArray(),Y=J.getNormalized(),$=J.getComponentType(),Q=tB();for(let K=0,W=J.getCount();K<W;K++){if(Y)Q[0]=d0.decodeNormalizedInt(X[K*4],$),Q[1]=d0.decodeNormalizedInt(X[K*4+1],$),Q[2]=d0.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],Os(Q,Q),Y)X[K*4]=d0.decodeNormalizedInt(Q[0],$),X[K*4+1]=d0.decodeNormalizedInt(Q[1],$),X[K*4+2]=d0.decodeNormalizedInt(Q[2],$);else X[K*4]=Q[0],X[K*4+1]=Q[1],X[K*4+2]=Q[2]}}function yP1(Z){if(Z.getMode()!==w8.Mode.TRIANGLES)return;if(!Z.getIndices())Z2(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 bP1(Z,J){for(let X of Z.listPrimitives()){let Y=gP1(X,Z);if(X!==Y)Z.removePrimitive(X).addPrimitive(Y)}for(let X of Z.listPrimitives())TH(X),ks(X,J)}function gP1(Z,J){if(Z.listParents().some((Y)=>Y instanceof XH&&Y!==J))Z=Z.clone();for(let Y of Z.listTargets())if(Y.listParents().some((Q)=>Q instanceof w8&&Q!==Z))Z.removeTarget(Y).addTarget(Y.clone());return Z}var Xs=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function Is(Z){let J=Z.getMesh(),X=Z.getMatrix();if(J&&!d0.eq(X,Xs))bP1(J,X);for(let Y of Z.listChildren()){let $=Y.getMatrix();ws($,$,X),Y.setMatrix($)}return Z.setMatrix(Xs)}var{LINES:mP1,LINE_STRIP:uP1,LINE_LOOP:dP1,TRIANGLES:lP1,TRIANGLE_STRIP:cP1,TRIANGLE_FAN:pP1}=w8.Mode;function iP1(Z){let J=Z.getGraph(),X=E6.fromGraph(J);if(!Z.getIndices())Z2(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=qs(Z),W=new DJ[Y.getComponentType()](Q*2),G=Z.getMode();if(G===uP1)for(let z=0;z<Q;z++)W[z*2]=$[z],W[z*2+1]=$[z+1];else if(G===dP1)for(let z=0;z<Q;z++)if(z<Q-1)W[z*2]=$[z],W[z*2+1]=$[z+1];else W[z*2]=$[z],W[z*2+1]=$[0];else throw new Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(mP1);let H=X.getRoot();if(Y.listParents().some((z)=>z!==H&&z!==Z))Z.setIndices(wZ(X,Y).setArray(W));else Y.setArray(W)}function vs(Z){let J=Z.getGraph(),X=E6.fromGraph(J);if(!Z.getIndices())Z2(Z);let Y=Z.getIndices(),$=Y.getArray(),Q=qs(Z),W=new DJ[Y.getComponentType()](Q*3),G=Z.getMode();if(G===cP1)for(let z=0,V=$.length;z<V-2;z++)if(z%2)W[z*3]=$[z+1],W[z*3+1]=$[z],W[z*3+2]=$[z+2];else W[z*3]=$[z],W[z*3+1]=$[z+1],W[z*3+2]=$[z+2];else if(G===pP1)for(let z=0;z<Q;z++)W[z*3]=$[0],W[z*3+1]=$[z+1],W[z*3+2]=$[z+2];else throw new Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(lP1);let H=X.getRoot();if(Y.listParents().some((z)=>z!==H&&z!==Z))Z.setIndices(wZ(X,Y).setArray(W));else Y.setArray(W)}var Ys="dequantize",sB={pattern:/^((?!JOINTS_).)*$/};function _s(Z=sB){let J=q7(sB,Z);return fJ(Ys,(X)=>{let Y=X.getLogger();for(let $ of X.getRoot().listMeshes())for(let Q of $.listPrimitives())nP1(Q,J);X.createExtension(DH).dispose(),Y.debug(`${Ys}: Complete.`)})}function nP1(Z,J=sB){let X=q7(sB,J);for(let Y of Z.listSemantics())if(X.pattern.test(Y))CT(Z.getAttribute(Y));for(let Y of Z.listTargets())for(let $ of Y.listSemantics())if(X.pattern.test($))CT(Y.getAttribute($))}function CT(Z){let J=Z.getArray();if(!J)return;let X=oB(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function oB(Z,J,X){let Y=new Float32Array(Z.length);for(let $=0,Q=Z.length;$<Q;$++)if(X)Y[$]=d0.decodeNormalizedInt(Z[$],J);else Y[$]=Z[$];return Y}var{TEXTURE_INFO:Ss,ROOT:lT6}=a;function As(Z){let J=new E6().setLogger(Z.getLogger()),X=_T(J,Z);return aP1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function aP1(Z,J,X){X||(X=_T(Z,J));for(let Y of J.getRoot().listExtensionsUsed()){let $=Z.createExtension(Y.constructor);if(Y.isRequired())$.setRequired(!0)}return sP1(Z,J,oP1(J),X)}function sP1(Z,J,X,Y){Y||(Y=_T(Z,J));let $=new Map;for(let Q of X)if(!$.has(Q)&&Q.propertyType!==Ss)$.set(Q,Y(Q));for(let[Q,K]of $.entries())K.copy(Q,Y);return $}function _T(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return(Y)=>{if(Y.propertyType===Ss)return Y;let $=X.get(Y);if(!$)$=new Y.constructor(Z.getGraph()),X.set(Y,$);return $}}function oP1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}var NT="flatten",$s={cleanup:!0};function xs(Z=$s){let J=q7($s,Z);return fJ(NT,async(X)=>{let Y=X.getRoot(),$=X.getLogger(),Q=new Set;for(let H of Y.listSkins())for(let z of H.listJoints())Q.add(z);let K=new Set;for(let H of Y.listAnimations())for(let z of H.listChannels()){let V=z.getTargetNode();if(V&&z.getTargetPath()!=="weights")K.add(V)}let W=new Set,G=new Set;for(let H of Y.listScenes())H.traverse((z)=>{let V=z.getParentNode();if(!V)return;if(Q.has(V)||W.has(V))W.add(z);if(K.has(V)||G.has(V))G.add(z)});for(let H of Y.listScenes())H.traverse((z)=>{if(K.has(z))return;if(W.has(z))return;if(G.has(z))return;tM1(z)});if(K.size)$.debug(`${NT}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(eB({propertyTypes:[a.NODE],keepLeaves:!1}));$.debug(`${NT}: Complete.`)})}function hs(Z){return TD(Z)}var rP1={skipValidation:!1},Qs=4294967295,{LINE_STRIP:tP1,LINE_LOOP:eP1,TRIANGLE_STRIP:Zj1,TRIANGLE_FAN:Jj1}=w8.Mode;function Xj1(Z,J={}){let X=q7(rP1,J),Y=Z[0],$=E6.fromGraph(Y.getGraph());if(!X.skipValidation&&new Set(Z.map(Ls)).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 tP1:case eP1:iP1(q);break;case Zj1:case Jj1:vs(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],B=U.getIndices(),L=U.getAttribute("POSITION").getCount(),w=B?B.getArray():null,N=B?B.getCount():L,R=new Uint32Array(L).fill(Qs);for(let M=0;M<N;M++){let D=w?w[M]:M;if(R[D]===Qs)R[D]=W++,K[q]++}Q.push(R),G+=N}let H=$.createPrimitive().setMode(Y.getMode()).setMaterial(Y.getMaterial());for(let q of Y.listSemantics()){let U=Y.getAttribute(q),B=DJ[U.getComponentType()],L=wZ($,U).setArray(new B(W*U.getElementSize()));H.setAttribute(q,L)}let z=Y.getIndices(),V=z?wZ($,z).setArray(IT(G,W)):null;H.setIndices(V);let F=0;for(let q=0;q<Q.length;q++){let U=Z[q],B=U.getIndices(),L=B?B.getCount():-1,w=Q[q];if(B&&V)$j1(B,w,V,F),F+=L;for(let N of H.listSemantics()){let R=U.getAttribute(N),M=H.getAttribute(N);Yj1(R,B,w,M)}}return H}function Yj1(Z,J,X,Y){let $=Z.getElementSize(),Q=J?J.getArray():null,K=Z.getCount(),W=Z.getArray(),G=Y.getArray(),H=new Uint8Array(Z.getCount());for(let z=0,V=J?J.getCount():K;z<V;z++){let F=Q?Q[z]:z,q=X[F];if(H[q])continue;for(let U=0;U<$;U++)G[q*$+U]=W[F*$+U];H[q]=1}}function $j1(Z,J,X,Y){let $=Z.getCount(),Q=Z.getArray(),K=X.getArray();for(let W=0;W<$;W++){let G=Q[W],H=J[G];K[Y+W]=H}}var TT="join",{ROOT:Qj1,NODE:Kj1,MESH:Wj1,PRIMITIVE:Gj1,ACCESSOR:Hj1}=a,RT=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ks={keepMeshes:!1,keepNamed:!1,cleanup:!0};function fs(Z=Ks){let J=q7(Ks,Z);return fJ(TT,async(X)=>{let Y=X.getRoot(),$=X.getLogger();for(let Q of Y.listScenes())Ws(X,Q,J),Q.traverse((K)=>Ws(X,K,J));if(J.cleanup)await X.transform(eB({propertyTypes:[Kj1,Wj1,Gj1,Hj1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));$.debug(`${TT}: Complete.`)})}function Ws(Z,J,X){let Y=Z.getLogger(),$={},Q=J.listChildren();for(let G=0;G<Q.length;G++){let H=Q[G];if(H.listParents().some((F)=>F instanceof BY))continue;let V=H.getMesh();if(!V)continue;if(H.getExtension("EXT_mesh_gpu_instancing"))continue;if(H.getSkin())continue;for(let F of V.listPrimitives()){if(F.listTargets().length>0)continue;let q=F.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;TH(F),Fj1(F);let U=Ls(F),B=V.getName()||H.getName();if(X.keepMeshes||X.keepNamed&&B)U+=`|${G}`;if(!(U in $))$[U]={prims:[],primMeshes:[],primNodes:[],dstNode:H,dstMesh:void 0};let L=$[U];L.prims.push(F),L.primNodes.push(H)}}let K=Object.values($).filter(({prims:G})=>G.length>1),W=new Set(K.flatMap((G)=>G.primNodes));for(let G of W){let H=G.getMesh();if(H.listParents().some((V)=>{return V.propertyType!==Qj1&&G!==V}))G.setMesh(H.clone())}for(let G of K){let{dstNode:H,primNodes:z}=G;G.dstMesh=H.getMesh(),G.primMeshes=z.map((V)=>V.getMesh())}for(let G of K){let{prims:H,primNodes:z,primMeshes:V,dstNode:F,dstMesh:q}=G,U=F.getMatrix();for(let w=0;w<H.length;w++){let N=z[w],R=V[w],M=H[w];if(R.removePrimitive(M),aM1(M))M=H[w]=zj1(H[w]);if(N!==F)ws(RT,eM1(RT,U),N.getMatrix()),ks(M,RT)}let B=Xj1(H),L=B.listAttributes()[0].getCount();q.addPrimitive(B),Y.debug(`${TT}: Joined Primitives (${H.length}) containing ${MT(L)} vertices under Node "${F.getName()}".`)}}function zj1(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 Fj1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)CT(X)}}var{TRANSLATION:cT6,ROTATION:pT6,SCALE:iT6,WEIGHTS:nT6}=BY.TargetPath;var Vj1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var aT6=CK({level:"high"},Vj1);var qj1="unweld";function Uj1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let Y=Z.getGraph(),$=E6.fromGraph(Y),Q=$.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,Gs($,G,X,J)),G.listParents().length===1)G.dispose();for(let G of Z.listTargets())for(let H of G.listAttributes())if(G.swap(H,Gs($,H,X,J)),H.listParents().length===1)H.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${qj1}: ${rB(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function Gs(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 z=0,V=X.getCount();z<V;z++)for(let F=0;F<G;F++)K[z*G+F]=$[W[z]*G+F];if(!Y.has(J))Y.set(J,new Map);let H=wZ(Z,J).setArray(K);return Y.get(J).set(X,H),H}var Hs;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(Hs||(Hs={}));var Lj1=0.000001;function Bj1(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),H=Z.length-1,z=1;for(let V=1;V<H;++V){let F=Z[z-1],q=Z[V],U=Z[V+1],B=(q-F)/(U-F),L=!1;if(q!==U&&(V!==1||q!==Z[0])){if(CH(J,z-1,G),CH(J,V,K),CH(J,V+1,W),X==="slerp"){let w=Nj1(Q,G,W,B),N=Fs(G,K)+Fs(K,W);L=!nB(K,w,Y)||N+Number.EPSILON>=Math.PI}else if(X==="lerp"){let w=Oj1(Q,G,W,B);L=!nB(K,w,Y)}else if(X==="step")L=!nB(K,G)||!nB(K,W)}if(L){if(V!==z)Z[z]=Z[V],zs(J,z,CH(J,V,Q));z++}}if(H>0)Z[z]=Z[H],zs(J,z,CH(J,H,Q)),z++;return z}function CH(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)X[Y]=Z[J*$+Y];return X}function zs(Z,J,X){for(let Y=0,$=X.length;Y<$;Y++)Z[J*$+Y]=X[Y]}function nB(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 wj1(Z,J,X){return Z*(1-X)+J*X}function Oj1(Z,J,X,Y){for(let $=0;$<J.length;$++)Z[$]=wj1(J[$],X[$],Y);return Z}function Nj1(Z,J,X,Y){let $=J[0],Q=J[1],K=J[2],W=J[3],G=X[0],H=X[1],z=X[2],V=X[3],F,q,U,B,L;if(q=$*G+Q*H+K*z+W*V,q<0)q=-q,G=-G,H=-H,z=-z,V=-V;if(1-q>Lj1)F=Math.acos(q),U=Math.sin(F),B=Math.sin((1-Y)*F)/U,L=Math.sin(Y*F)/U;else B=1-Y,L=Y;return Z[0]=B*$+L*G,Z[1]=B*Q+L*H,Z[2]=B*K+L*z,Z[3]=B*W+L*V,Z}function Fs(Z,J){let X=Rj1(Z,J);return Math.acos(2*X*X-1)}function Rj1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var sT6=new Float32Array(0),oT6={ready:Promise.resolve(),resample:Bj1,tolerance:0.0001,cleanup:!0};var gY="simplify",{POINTS:ys,LINES:Mj1,LINE_STRIP:Pj1,LINE_LOOP:jj1,TRIANGLES:Dj1,TRIANGLE_STRIP:bs,TRIANGLE_FAN:gs}=w8.Mode,ms={ratio:0,error:0.0001,lockBorder:!1,cleanup:!0};function us(Z){let J=q7(ms,Z),X=J.simplifier;if(!X)throw new Error(`${gY}: simplifier dependency required — install "meshoptimizer".`);return fJ(gY,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===Dj1||G===bs||G===gs){if(Vs(W,J),hJ(W,L6.RENDER)===0)W.dispose()}else if(W.getMode()===ys&&!!X.simplifyPoints){if(Vs(W,J),hJ(W,L6.RENDER)===0)W.dispose()}else Q++}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)$.warn(`${gY}: Skipping simplification of ${Q} primitives: Unsupported draw mode.`);if(J.cleanup)await Y.transform(eB({propertyTypes:[a.ACCESSOR,a.NODE],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}),Ns({propertyTypes:[a.ACCESSOR]}));$.debug(`${gY}: Complete.`)})}function Vs(Z,J){let X=CK({},ms,J),Y=X.simplifier,$=Z.getGraph(),Q=E6.fromGraph($),K=Q.getLogger();switch(Z.getMode()){case ys:return Cj1(Q,Z,X);case Mj1:case Pj1:case jj1:return K.warn(`${gY}: Skipping primitive simplification: Unsupported draw mode.`),Z;case bs:case gs:vs(Z);break}let W=hJ(Z,L6.UPLOAD),G=hJ(Z,L6.RENDER);if(G<W/2)TH(Z);let H=Z.getAttribute("POSITION"),z=Z.getIndices(),V=H.getArray(),F=z.getArray();if(!(V instanceof Float32Array))V=oB(V,H.getComponentType(),H.getNormalized());if(!(F instanceof Uint32Array))F=new Uint32Array(F);let q=Math.floor(X.ratio*G/3)*3,U=X.lockBorder?["LockBorder"]:[],[B,L]=Y.simplify(F,V,3,q,X.error,U);if(Z.setIndices(wZ(Q,z).setArray(B)),z.listParents().length===1)z.dispose();TH(Z);let w=hJ(Z,L6.UPLOAD);if(w<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${gY}: ${rB(W,w)} vertices, error: ${L.toFixed(4)}.`),Z}function Cj1(Z,J,X){let Y=X.simplifier,$=Z.getLogger();if(J.getIndices())Uj1(J);let K=J.getAttribute("POSITION"),W=J.getAttribute("COLOR_0"),G=K.getCount(),H=K.getArray(),z=W?W.getArray():void 0,V=W?W.getComponentSize():void 0;if(!(H instanceof Float32Array))H=oB(H,K.getComponentType(),K.getNormalized());if(z&&!(z instanceof Float32Array))z=oB(z,K.getComponentType(),K.getNormalized());Y.useExperimentalFeatures=!0;let F=Math.floor(X.ratio*G),q=Y.simplifyPoints(H,3,F,z,V);Y.useExperimentalFeatures=!1;let[U,B]=Y.compactMesh(q);$.debug(`${gY}: ${rB(K.getCount(),B)} vertices.`);for(let L of kT(J)){let w=wZ(Z,L);if(jT(L,null,U,w,B),pM1(J,L,w),L.listParents().length===1)L.dispose()}return J}var ET;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(ET||(ET={}));var rT6={resizeFilter:ET.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var as=r(ns(),1);var EK={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DIRECTORIES:[(()=>{try{return kK.dirname(g.resolve("@hytopia.com/assets"))}catch{return null}})(),kK.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 k9{static instance=new k9;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}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}}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){for(let J of EK.DIRECTORIES)Z=Z.replace(J,"");if(Z.startsWith("/"))Z=Z.slice(1);return Z}async _getAbsoluteModelPaths(){let Z=[];for(let J of EK.DIRECTORIES){let X=kK.resolve(process.cwd(),J);if(!yJ.existsSync(X))continue;let Y=await uL("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let $ of Y)Z.push(kK.join(X,$))}return Z}async _loadModelData(Z){let J=await new SD().read(Z),X=hs(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)}${EK.CHECKSUM_EXT}`;if(!yJ.existsSync(J))return!1;let X=this._calculateChecksum(Z),Y=yJ.readFileSync(J,"utf8");return X===Y}_calculateChecksum(Z){if(!yJ.existsSync(Z))return"";let J=yJ.readFileSync(Z);return vj1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=kK.basename(Z),X=J.replace(/\.[^/.]+$/,""),Y=`${EK.OPTIMIZED_DIR}/${X}`;return Z.replace(/[^/\\]+$/,`${Y}/${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 $=As(Y);$.setLogger(new P5(ZH.WARN)),await $.transform(Bs({pivot:"center"}),xs(),fs(),vT(),us({simplifier:as.MeshoptSimplifier,ratio:J,error:X}),_s());for(let H of $.getRoot().listScenes())for(let z of H.listChildren())Is(z);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=kK.dirname(J);yJ.rmSync(X,{recursive:!0,force:!0}),yJ.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let Y of EK.OPTIMIZER_RUNS){let $=J.replace(/(\.[^/.]+)$/,`${Y.suffix}$1`),{stderr:Q}=await sl("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 yJ.writeFileSync(`${J}${EK.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var OZ=r(fQ(),1);var _H;(($)=>{$.DYNAMIC="dynamic";$.FIXED="fixed";$.KINEMATIC_POSITION="kinematic_position";$.KINEMATIC_VELOCITY="kinematic_velocity"})(_H||={});var fT=0.001,ss="dynamic";class mY extends g0{_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??=ss,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"]:OZ.default.RigidBodyType.Dynamic,["fixed"]:OZ.default.RigidBodyType.Fixed,["kinematic_position"]:OZ.default.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:OZ.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 s5({...Z,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(Z)}createAndAddChildCollidersToSimulation(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 s5(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??ss;return{["dynamic"]:()=>OZ.default.RigidBodyDesc.dynamic(),["fixed"]:()=>OZ.default.RigidBodyDesc.fixed(),["kinematic_position"]:()=>OZ.default.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>OZ.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)<fT&&Math.abs(Z.y)<fT&&Math.abs(Z.z)<fT}}var yT;(($)=>{$[$.Average=0]="Average";$[$.Min=1]="Min";$[$.Multiply=2]="Multiply";$[$.Max=3]="Max"})(yT||={});var SH;((H)=>{H.NONE="none";H.BALL="ball";H.BLOCK="block";H.CAPSULE="capsule";H.CONE="cone";H.CYLINDER="cylinder";H.ROUND_CYLINDER="round-cylinder";H.TRIMESH="trimesh";H.WEDGE="wedge"})(SH||={});class s5 extends g0{_collider;_colliderDesc;_onCollision;_parentRigidBody;_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=k9.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),H=W/G,z=W/Q,V=W*J/2,F=(N)=>Math.max(0.01,N),q=()=>({shape:"block",halfExtents:{x:F($*J/2),y:F(Q*J/2),z:F(K*J/2)}}),U=()=>({shape:"round-cylinder",radius:F(V),halfHeight:F(Q*J/2),borderRadius:F(V*0.1)}),B=()=>{let N=k9.instance.getTrimesh(Z,J);if(!N)return;return{shape:"trimesh",vertices:N.vertices,indices:N.indices}},L=()=>({shape:"wedge",extents:{x:$*J,y:Q*J,z:K*J}}),w=()=>({shape:"capsule",radius:F(V),halfHeight:F(Q*J/2-V)});if(X)switch(X){case"block":return q();case"capsule":return w();case"round-cylinder":return U();case"trimesh":{let N=B();if(!N){u.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return N}case"wedge":return L();default:u.warning(`Collider.optionsFromModelUri(): Preferred shape ${X} is not yet supported with Collider.optionsFromModelUri(), defaulting to generic shape!`)}if(H>2)return q();if(z>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?G4.decodeRawCollisionGroups(this._collider.collisionGroups()):G4.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 relativePosition(){if(!this._requireNotRemoved("relativePosition"))return{x:0,y:0,z:0};return this._collider?this._collider.translation():this._colliderDesc.translation}get relativeRotation(){if(!this._requireNotRemoved("relativeRotation"))return{x:0,y:0,z:0,w:1};return this._collider?this._collider.rotation():this._colliderDesc.rotation}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=G4.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._collider?this._collider.setRotation(Z):this._colliderDesc.setRotation(Z)}setRelativePosition(Z){if(!this._requireNotRemoved("setRelativePosition"))return;this._collider?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)}enableCollisionEvents(Z){if(!this._requireNotRemoved("enableCollisionEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|t8.default.ActiveEvents.COLLISION_EVENTS:J&~t8.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|t8.default.ActiveEvents.CONTACT_FORCE_EVENTS:J&~t8.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 t8.default.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)u.fatalError("Block collider must have halfExtents!");return t8.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 t8.default.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)u.fatalError("Cone collider must have radius and halfHeight!");return t8.default.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)u.fatalError("Cylinder collider must have radius and halfHeight!");return t8.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 t8.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 t8.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),$=t8.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(t8.default.ActiveCollisionTypes.DYNAMIC_DYNAMIC|t8.default.ActiveCollisionTypes.DYNAMIC_KINEMATIC|t8.default.ActiveCollisionTypes.DYNAMIC_FIXED|t8.default.ActiveCollisionTypes.KINEMATIC_KINEMATIC|t8.default.ActiveCollisionTypes.KINEMATIC_FIXED)}}var _j1={shape:"trimesh",flags:os.TriMeshFlags.FIX_INTERNAL_EDGES},Sj1=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]),Aj1=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]),bT;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(bT||={});class o5 extends g0{_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,..._j1}}get isLiquid(){return this._isLiquid}get isMeshable(){return!this._customColliderOptions}get name(){return this._name}get textureUri(){return this._textureUri}createCollider(Z=Sj1,J=Aj1){let X=new s5({...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(G4.isDefaultCollisionGroups(X.collisionGroups))X.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return X}serialize(){return p0.serializeBlockType(this)}}var gT;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(gT||={});class AH extends g0{_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 o5{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 p0.serializeBlockTypeRegistry(this)}}var Uk={};Mq(Uk,{worldSchema:()=>qk,worldPacketDefinition:()=>l00,vectorSchema:()=>k1,vectorBooleanSchema:()=>__1,uiSchema:()=>Fk,uiPacketDefinition:()=>u00,uiDatasSchema:()=>Vk,uiDatasPacketDefinition:()=>d00,uiDataSendPacketDefinition:()=>E00,uiDataSchema:()=>Yz,syncResponseSchema:()=>zk,syncResponsePacketDefinition:()=>m00,syncRequestSchema:()=>mE,syncRequestPacketDefinition:()=>T00,stateRequestSchema:()=>gE,stateRequestPacketDefinition:()=>C00,sceneUIsSchema:()=>Hk,sceneUIsPacketDefinition:()=>g00,sceneUISchema:()=>Gk,rgbColorSchema:()=>B7,registeredPackets:()=>c2,quaternionSchema:()=>tE,playersSchema:()=>Wk,playersPacketDefinition:()=>b00,playerSchema:()=>Kk,physicsDebugRenderSchema:()=>Qk,physicsDebugRenderPacketDefinition:()=>f00,physicsDebugRaycastsSchema:()=>$k,physicsDebugRaycastsPacketDefinition:()=>y00,physicsDebugRaycastSchema:()=>Yk,outboundPackets:()=>l2,modelNodeOverrideSchema:()=>rE,lightsSchema:()=>Xk,lightsPacketDefinition:()=>h00,lightSchema:()=>Jk,isValidPacket:()=>A_1,inputSchema:()=>bE,inputPacketDefinition:()=>D00,inboundPackets:()=>d2,hexColorSchema:()=>fE,heartbeatSchema:()=>hE,heartbeatPacketDefinition:()=>M00,entitySchema:()=>eE,entitiesSchema:()=>Zk,entitiesPacketDefinition:()=>x00,definePacket:()=>T0,debugConfigSchema:()=>yE,debugConfigPacketDefinition:()=>j00,createPacket:()=>M_1,connectionSchema:()=>xE,connectionPacketDefinition:()=>R00,chunksSchema:()=>oE,chunksPacketDefinition:()=>A00,chunkSchema:()=>sE,chatMessagesSchema:()=>aE,chatMessagesPacketDefinition:()=>S00,chatMessageSendPacketDefinition:()=>P00,chatMessageSchema:()=>Xz,cameraSchema:()=>nE,cameraPacketDefinition:()=>_00,blocksSchema:()=>cE,blocksPacketDefinition:()=>I00,blockTypesSchema:()=>iE,blockTypesPacketDefinition:()=>v00,blockTypeSchema:()=>pE,blockSchema:()=>lE,bidirectionalPackets:()=>u2,audiosSchema:()=>dE,audiosPacketDefinition:()=>k00,audioSchema:()=>uE,PacketId:()=>h1});var u2={};Mq(u2,{heartbeatPacketDefinition:()=>M00,connectionPacketDefinition:()=>R00});var SE=r(O00(),1);class AE extends SE.default{static instance=new SE.default}var h1;((T)=>{T[T.SYNC_REQUEST=0]="SYNC_REQUEST";T[T.INPUT=1]="INPUT";T[T.STATE_REQUEST=2]="STATE_REQUEST";T[T.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";T[T.UI_DATA_SEND=4]="UI_DATA_SEND";T[T.SYNC_RESPONSE=32]="SYNC_RESPONSE";T[T.AUDIOS=33]="AUDIOS";T[T.BLOCKS=34]="BLOCKS";T[T.BLOCK_TYPES=35]="BLOCK_TYPES";T[T.CHAT_MESSAGES=36]="CHAT_MESSAGES";T[T.CHUNKS=37]="CHUNKS";T[T.ENTITIES=38]="ENTITIES";T[T.WORLD=39]="WORLD";T[T.CAMERA=40]="CAMERA";T[T.UI=41]="UI";T[T.UI_DATAS=42]="UI_DATAS";T[T.SCENE_UIS=43]="SCENE_UIS";T[T.LIGHTS=44]="LIGHTS";T[T.PLAYERS=45]="PLAYERS";T[T.CONNECTION=116]="CONNECTION";T[T.HEARTBEAT=117]="HEARTBEAT";T[T.DEBUG_CONFIG=128]="DEBUG_CONFIG";T[T.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";T[T.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(h1||={});function M_1(Z,J,X){if(!Z.validate(J))throw new Error(`Invalid payload for packet with id ${Z.id}. Error: ${AE.instance.errorsText(Z.validate.errors)}`);let Y=[Z.id,J];if(typeof X==="number")Y.push(X);return Y}function T0(Z,J){return{id:Z,schema:J,validate:AE.instance.compile(J)}}var P_1={type:"object",properties:{i:{type:"string"}},required:["i"],additionalProperties:!1},N00={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},j_1={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},D_1={type:"object",properties:{usernameFragment:{type:"string"},password:{type:"string"},iceLite:{type:"boolean",nullable:!0}},required:["usernameFragment","password"],additionalProperties:!1},C_1={type:"object",properties:{i:{type:"string"},l:{type:"string"}},required:["i","l"],additionalProperties:!1},T_1={type:"object",properties:{port:{type:"number"},OS:{type:"number"},MIS:{type:"number"},maxMessageSize:{type:"number"}},required:["port","OS","MIS","maxMessageSize"],additionalProperties:!0},E_1={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},k_1={type:"object",properties:{i:{type:"string"},f:{type:"string",enum:["cs","sc"]},ip:D_1,ic:{type:"array",items:j_1},d:N00,s:T_1},required:["i","f","ip","ic","d","s"],additionalProperties:!1},I_1={type:"object",properties:{i:{type:"string"},d:N00},required:["i","d"],additionalProperties:!1},v_1={type:"object",properties:{i:{type:"string",nullable:!0},pi:{type:"string",nullable:!0},l:{type:"string"},s:E_1},required:["l","s"],additionalProperties:!1},xE={type:"object",properties:{i:{type:"string",nullable:!0},c:{...I_1,nullable:!0},ca:{...P_1,nullable:!0},d:{type:"array",items:{...v_1},nullable:!0},pa:{...C_1,nullable:!0},t:{type:"array",items:{...k_1},nullable:!0}},additionalProperties:!1};var R00=T0(116,xE);var hE={type:"null",nullable:!0};var M00=T0(117,hE);var d2={};Mq(d2,{uiDataSendPacketDefinition:()=>E00,syncRequestPacketDefinition:()=>T00,stateRequestPacketDefinition:()=>C00,inputPacketDefinition:()=>D00,debugConfigPacketDefinition:()=>j00,chatMessageSendPacketDefinition:()=>P00});var fE={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var Xz={type:"object",properties:{m:{type:"string"},c:{...fE,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var P00=T0(3,Xz);var yE={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var j00=T0(128,yE);var bE={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},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 D00=T0(1,bE);var gE={type:"object",properties:{},additionalProperties:!1};var C00=T0(2,gE);var mE={type:"null",nullable:!0};var T00=T0(0,mE);var Yz={type:"object",properties:{},additionalProperties:!0};var E00=T0(4,Yz);var l2={};Mq(l2,{worldPacketDefinition:()=>l00,uiPacketDefinition:()=>u00,uiDatasPacketDefinition:()=>d00,syncResponsePacketDefinition:()=>m00,sceneUIsPacketDefinition:()=>g00,playersPacketDefinition:()=>b00,physicsDebugRenderPacketDefinition:()=>f00,physicsDebugRaycastsPacketDefinition:()=>y00,lightsPacketDefinition:()=>h00,entitiesPacketDefinition:()=>x00,chunksPacketDefinition:()=>A00,chatMessagesPacketDefinition:()=>S00,cameraPacketDefinition:()=>_00,blocksPacketDefinition:()=>I00,blockTypesPacketDefinition:()=>v00,audiosPacketDefinition:()=>k00});var k1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var uE={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:{...k1,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 dE={type:"array",items:{...uE}};var k00=T0(33,dE);var lE={type:"object",properties:{i:{type:"number"},c:k1},required:["i","c"],additionalProperties:!1};var cE={type:"array",items:{...lE}};var I00=T0(34,cE);var pE={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 iE={type:"array",items:{...pE}};var v00=T0(35,iE);var nE={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},p:{...k1,nullable:!0},pt:{...k1,nullable:!0},pl:{...k1,nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},o:{...k1,nullable:!0},z:{type:"number",nullable:!0}},additionalProperties:!1};var aE={type:"array",items:{...Xz}};var sE={type:"object",properties:{c:k1,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 oE={type:"array",items:{...sE}};var B7={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 rE={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:{...B7,nullable:!0}},required:["n"],additionalProperties:!1};var tE={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var eE={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:{...k1,nullable:!0},bt:{type:"string",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},m:{type:"string",nullable:!0},mo:{type:"array",items:{...rE},nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...k1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{...tE,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},t:{...B7,nullable:!0}},required:["i"],additionalProperties:!1};var Zk={type:"array",items:{...eE}};var Jk={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...B7,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...k1,nullable:!0},p:{...k1,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:{...k1,nullable:!0}},required:["i"],additionalProperties:!1};var Xk={type:"array",items:{...Jk}};var Yk={type:"object",properties:{o:{...k1},d:{...k1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var $k={type:"array",items:{...Yk}};var Qk={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var Kk={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 Wk={type:"array",items:{...Kk}};var Gk={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...k1,nullable:!0},p:{...k1,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 Hk={type:"array",items:{...Gk}};var zk={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var Fk={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var Vk={type:"array",items:{...Yz}};var __1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var qk={type:"object",properties:{i:{type:"number"},ac:{...B7,nullable:!0},ai:{type:"number",nullable:!0},dc:{...B7,nullable:!0},di:{type:"number",nullable:!0},dp:{...k1,nullable:!0},n:{type:"string",nullable:!0},s:{type:"string",nullable:!0},t:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var _00=T0(40,nE);var S00=T0(36,aE);var A00=T0(37,oE);var x00=T0(38,Zk);var h00=T0(44,Xk);var f00=T0(192,Qk);var y00=T0(193,$k);var b00=T0(45,Wk);var g00=T0(43,Hk);var m00=T0(32,zk);var u00=T0(41,Fk);var d00=T0(42,Vk);var l00=T0(39,qk);var c2=new Map,S_1={...u2,...d2,...l2};for(let Z of Object.values(S_1))if("id"in Z&&"schema"in Z){let J=Z;if(c2.has(J.id))throw new Error(`Packet with id ${J.id} is already registered.`);c2.set(J.id,J)}function A_1(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=c2.get(Z[0]);return!!J&&J.validate(Z[1])}var X0=Uk;var WK1=r(fQ(),1);var rS1=r(b10(),1),tS1=r(Rk(),1),eS1=r(Pk(),1),Ik=r(Jw(),1),vk=r(p10(),1);var Z5=r(s80(),1),Ox6=Z5.default.v1,Nx6=Z5.default.v1ToV6,Rx6=Z5.default.v3,o80=Z5.default.v4,Mx6=Z5.default.v5,Px6=Z5.default.v6,jx6=Z5.default.v6ToV1,Dx6=Z5.default.v7,Cx6=Z5.default.NIL,Tx6=Z5.default.MAX,Ex6=Z5.default.version,kx6=Z5.default.validate,Ix6=Z5.default.stringify,vx6=Z5.default.parse;var bk;try{bk=new TextDecoder}catch(Z){}var e,e5,b=0;var dk=[],tY=dk,Uz=0,I1={},J1,kZ,t5=0,S9=0,m8,IZ,v5=[],t0,r80={useRecords:!1,mapsAsObjects:!0};class zw{}var lk=new zw;lk.name="MessagePack 0xC1";var aJ=!1,Q60=2,gk,mk,uk;try{new Function("")}catch(Z){Q60=1/0}class vZ{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 B60(()=>{return Hw(),this?this.unpack(Z,J):vZ.prototype.unpack.call(r80,Z,J)});if(!Z.buffer&&Z.constructor===ArrayBuffer)Z=typeof Buffer!=="undefined"?Buffer.from(Z):new Uint8Array(Z);if(typeof J==="object")e5=J.end||Z.length,b=J.start||0;else b=0,e5=J>-1?J:Z.length;Uz=0,S9=0,kZ=null,tY=dk,m8=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 vZ){if(I1=this,this.structures)return J1=this.structures,Ww(J);else if(!J1||J1.length>0)J1=[]}else if(I1=r80,!J1||J1.length>0)J1=[];return Ww(J)}unpackMultiple(Z,J){let X,Y=0;try{aJ=!0;let $=Z.length,Q=this?this.unpack(Z,$):Fw.unpack(Z,$);if(J){if(J(Q,Y,b)===!1)return;while(b<$)if(Y=b,J(Ww(),Y,b)===!1)return}else{X=[Q];while(b<$)Y=b,X.push(Ww());return X}}catch($){throw $.lastPosition=Y,$.values=X,$}finally{aJ=!1,Hw()}}_mergeStructures(Z,J){if(mk)Z=mk.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 Ww(Z){try{if(!I1.trusted&&!aJ){let X=J1.sharedLength||0;if(X<J1.length)J1.length=X}let J;if(I1.randomAccessStructure&&e[b]<64&&e[b]>=32&&gk){if(J=gk(e,b,e5,I1),e=null,!(Z&&Z.lazy)&&J)J=J.toJSON();b=e5}else J=M8();if(m8)b=m8.postBundlePosition,m8=null;if(aJ)J1.restoreStructures=null;if(b==e5){if(J1&&J1.restoreStructures)t80();if(J1=null,e=null,IZ)IZ=null}else if(b>e5)throw new Error("Unexpected end of MessagePack data");else if(!aJ){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(J1&&J1.restoreStructures)t80();if(Hw(),J instanceof RangeError||J.message.startsWith("Unexpected end of buffer")||b>e5)J.incomplete=!0;throw J}}function t80(){for(let Z in J1.restoreStructures)J1[Z]=J1.restoreStructures[Z];J1.restoreStructures=null}function M8(){let Z=e[b++];if(Z<160)if(Z<128)if(Z<64)return Z;else{let J=J1[Z&63]||I1.getStructures&&K60()[Z&63];if(J){if(!J.read)J.read=ck(J,Z&63);return J.read()}else return Z}else if(Z<144)if(Z-=128,I1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let Y=U60();if(Y==="__proto__")Y="__proto_";J[Y]=M8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(M8(),M8());return J}else{Z-=144;let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=M8();if(I1.freezeData)return Object.freeze(J);return J}else if(Z<192){let J=Z-160;if(S9>=b)return kZ.slice(b-t5,(b+=J)-t5);if(S9==0&&e5<140){let X=J<16?pk(J):q60(J);if(X!=null)return X}return Gw(J)}else{let J;switch(Z){case 192:return null;case 193:if(m8)if(J=M8(),J>0)return m8[1].slice(m8.position1,m8.position1+=J);else return m8[0].slice(m8.position0,m8.position0-=J);return lk;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 yk(J);case 197:return J=t0.getUint16(b),b+=2,yk(J);case 198:return J=t0.getUint32(b),b+=4,yk(J);case 199:return rY(e[b++]);case 200:return J=t0.getUint16(b),b+=2,rY(J);case 201:return J=t0.getUint32(b),b+=4,rY(J);case 202:if(J=t0.getFloat32(b),I1.useFloat32>2){let X=Z$[(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(I1.int64AsType==="number")J=t0.getUint32(b)*4294967296,J+=t0.getUint32(b+4);else if(I1.int64AsType==="string")J=t0.getBigUint64(b).toString();else if(I1.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(I1.int64AsType==="number")J=t0.getInt32(b)*4294967296,J+=t0.getUint32(b+4);else if(I1.int64AsType==="string")J=t0.getBigInt64(b).toString();else if(I1.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 $60(e[b++]&63);else{let X=v5[J];if(X)if(X.read)return b++,X.read(M8());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++,$60(e[b++]&63,e[b++]);else return rY(2);case 214:return rY(4);case 215:return rY(8);case 216:return rY(16);case 217:if(J=e[b++],S9>=b)return kZ.slice(b-t5,(b+=J)-t5);return W60(J);case 218:if(J=t0.getUint16(b),b+=2,S9>=b)return kZ.slice(b-t5,(b+=J)-t5);return G60(J);case 219:if(J=t0.getUint32(b),b+=4,S9>=b)return kZ.slice(b-t5,(b+=J)-t5);return H60(J);case 220:return J=t0.getUint16(b),b+=2,Z60(J);case 221:return J=t0.getUint32(b),b+=4,Z60(J);case 222:return J=t0.getUint16(b),b+=2,J60(J);case 223:return J=t0.getUint32(b),b+=4,J60(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 kx1=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function ck(Z,J){function X(){if(X.count++>Q60){let $=Z.read=new Function("r","return function(){return "+(I1.freezeData?"Object.freeze":"")+"({"+Z.map((Q)=>Q==="__proto__"?"__proto_:r()":kx1.test(Q)?Q+":r()":"["+JSON.stringify(Q)+"]:r()").join(",")+"})}")(M8);if(Z.highByte===0)Z.read=e80(J,Z.read);return $()}let Y={};for(let $=0,Q=Z.length;$<Q;$++){let K=Z[$];if(K==="__proto__")K="__proto_";Y[K]=M8()}if(I1.freezeData)return Object.freeze(Y);return Y}if(X.count=0,Z.highByte===0)return e80(J,X);return X}var e80=(Z,J)=>{return function(){let X=e[b++];if(X===0)return J();let Y=Z<32?-(Z+(X<<5)):Z+(X<<5),$=J1[Y]||K60()[Y];if(!$)throw new Error("Record id is not defined for "+Y);if(!$.read)$.read=ck($,Z);return $.read()}};function K60(){let Z=B60(()=>{return e=null,I1.getStructures()});return J1=I1._mergeStructures(Z,J1)}var Gw=eY,W60=eY,G60=eY,H60=eY,z60=!1;function F60(Z){z60=!0,Gw=J(1),W60=J(2),G60=J(3),H60=J(5);function J(X){return function Y($){let Q=tY[Uz++];if(Q==null){if(m8)return eY($);let W=e.byteOffset,G=Z(b-X+W,e5+W,e.buffer);if(typeof G=="string")Q=G,tY=dk;else if(tY=G,Uz=1,S9=1,Q=tY[0],Q===void 0)throw new Error("Unexpected end of buffer")}let K=Q.length;if(K<=$)return b+=$,Q;return kZ=Q,t5=b,S9=b+K,b+=$,Q.slice(0,$)}}}function eY(Z){let J;if(Z<16){if(J=pk(Z))return J}if(Z>64&&bk)return bk.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+=Z6.apply(String,Y),Y.length=0}if(Y.length>0)J+=Z6.apply(String,Y);return J}function V60(Z,J,X){let Y=e;e=Z,b=J;try{return eY(X)}finally{e=Y}}function Z60(Z){let J=new Array(Z);for(let X=0;X<Z;X++)J[X]=M8();if(I1.freezeData)return Object.freeze(J);return J}function J60(Z){if(I1.mapsAsObjects){let J={};for(let X=0;X<Z;X++){let Y=U60();if(Y==="__proto__")Y="__proto_";J[Y]=M8()}return J}else{let J=new Map;for(let X=0;X<Z;X++)J.set(M8(),M8());return J}}var Z6=String.fromCharCode;function q60(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 Z6.apply(String,X)}function pk(Z){if(Z<4)if(Z<2)if(Z===0)return"";else{let J=e[b++];if((J&128)>1){b-=1;return}return Z6(J)}else{let J=e[b++],X=e[b++];if((J&128)>0||(X&128)>0){b-=2;return}if(Z<3)return Z6(J,X);let Y=e[b++];if((Y&128)>0){b-=3;return}return Z6(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 Z6(J,X,Y,$);else{let Q=e[b++];if((Q&128)>0){b-=5;return}return Z6(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 Z6(J,X,Y,$,Q,K);let W=e[b++];if((W&128)>0){b-=7;return}return Z6(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 Z6(J,X,Y,$,Q,K,W,G);else{let H=e[b++];if((H&128)>0){b-=9;return}return Z6(J,X,Y,$,Q,K,W,G,H)}else if(Z<12){let H=e[b++],z=e[b++];if((H&128)>0||(z&128)>0){b-=10;return}if(Z<11)return Z6(J,X,Y,$,Q,K,W,G,H,z);let V=e[b++];if((V&128)>0){b-=11;return}return Z6(J,X,Y,$,Q,K,W,G,H,z,V)}else{let H=e[b++],z=e[b++],V=e[b++],F=e[b++];if((H&128)>0||(z&128)>0||(V&128)>0||(F&128)>0){b-=12;return}if(Z<14)if(Z===12)return Z6(J,X,Y,$,Q,K,W,G,H,z,V,F);else{let q=e[b++];if((q&128)>0){b-=13;return}return Z6(J,X,Y,$,Q,K,W,G,H,z,V,F,q)}else{let q=e[b++],U=e[b++];if((q&128)>0||(U&128)>0){b-=14;return}if(Z<15)return Z6(J,X,Y,$,Q,K,W,G,H,z,V,F,q,U);let B=e[b++];if((B&128)>0){b-=15;return}return Z6(J,X,Y,$,Q,K,W,G,H,z,V,F,q,U,B)}}}}}function X60(){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 eY(J)}function yk(Z){return I1.copyBuffers?Uint8Array.prototype.slice.call(e,b,b+=Z):e.subarray(b,b+=Z)}function rY(Z){let J=e[b++];if(v5[J]){let X;return v5[J](e.subarray(b,X=b+=Z),(Y)=>{b=Y;try{return M8()}finally{b=X}})}else throw new Error("Unknown extension type "+J)}var Y60=new Array(4096);function U60(){let Z=e[b++];if(Z>=160&&Z<192){if(Z=Z-160,S9>=b)return kZ.slice(b-t5,(b+=Z)-t5);else if(!(S9==0&&e5<180))return Gw(Z)}else return b--,L60(M8());let J=(Z<<5^(Z>1?t0.getUint16(b):Z>0?e[b]:0))&4095,X=Y60[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=[],Y60[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?pk(Z):q60(Z);if(W!=null)return X.string=W;return X.string=Gw(Z)}function L60(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(I1.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 $60=(Z,J)=>{let X=M8().map(L60),Y=Z;if(J!==void 0)Z=Z<32?-((J<<5)+Z):(J<<5)+Z,X.highByte=J;let $=J1[Z];if($&&($.isShared||aJ))(J1.restoreStructures||(J1.restoreStructures=[]))[Z]=$;return J1[Z]=X,X.read=ck(X,Y),X.read()};v5[0]=()=>{};v5[0].noBuffer=!0;v5[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 Ix1={Error,TypeError,ReferenceError};v5[101]=()=>{let Z=M8();return(Ix1[Z[0]]||Error)(Z[1],{cause:Z[2]})};v5[105]=(Z)=>{if(I1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=t0.getUint32(b-4);if(!IZ)IZ=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};IZ.set(J,$);let Q=M8();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};v5[112]=(Z)=>{if(I1.structuredClone===!1)throw new Error("Structured clone extension is disabled");let J=t0.getUint32(b-4),X=IZ.get(J);return X.used=!0,X.target};v5[115]=()=>new Set(M8());var ik=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map((Z)=>Z+"Array"),vx1=typeof globalThis==="object"?globalThis:window;v5[116]=(Z)=>{let J=Z[0],X=Uint8Array.prototype.slice.call(Z,1).buffer,Y=ik[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 vx1[Y](X)};v5[120]=()=>{let Z=M8();return new RegExp(Z[0],Z[1])};var _x1=[];v5[98]=(Z)=>{let J=(Z[0]<<24)+(Z[1]<<16)+(Z[2]<<8)+Z[3],X=b;return b+=J-Z.length,m8=_x1,m8=[X60(),X60()],m8.position0=0,m8.position1=0,m8.postBundlePosition=b,b=X,M8()};v5[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 B60(Z){if(uk)uk();let J=e5,X=b,Y=Uz,$=t5,Q=S9,K=kZ,W=tY,G=IZ,H=m8,z=new Uint8Array(e.slice(0,e5)),V=J1,F=J1.slice(0,J1.length),q=I1,U=aJ,B=Z();return e5=J,b=X,Uz=Y,t5=$,S9=Q,kZ=K,tY=W,IZ=G,m8=H,e=z,aJ=U,J1=V,J1.splice(0,J1.length,...F),I1=q,t0=new DataView(e.buffer,e.byteOffset,e.byteLength),B}function Hw(){e=null,IZ=null,J1=null}var Z$=new Array(147);for(let Z=0;Z<256;Z++)Z$[Z]=+("1e"+Math.floor(45.15-Z*0.30103));var Fw=new vZ({useRecords:!1}),Sx1=Fw.unpack,Ax1=Fw.unpackMultiple,xx1=Fw.unpack;var hx1=new Float32Array(1),Sx6=new Uint8Array(hx1.buffer,0,4);function w60(Z,J,X){gk=Z,mk=J,uk=X}var qw;try{qw=new TextEncoder}catch(Z){}var sk,M60,Bz=typeof Buffer!=="undefined",Vw=Bz?function(Z){return Buffer.allocUnsafeSlow(Z)}:Uint8Array,P60=Bz?Buffer:Uint8Array,O60=Bz?4294967296:2144337920,l,Lz,v1,m=0,J5,o1=null,j60,fx1=21760,yx1=/[\u0080-\uFFFF]/,O7=Symbol("record-id");class J$ extends vZ{constructor(Z){super(Z);this.offset=0;let J,X,Y,$,Q,K=P60.prototype.utf8Write?function(I,v){return l.utf8Write(I,v,l.byteLength-v)}:qw&&qw.encodeInto?function(I,v){return qw.encodeInto(I,l.subarray(v)).written}:!1,W=this;if(!Z)Z={};let G=Z&&Z.sequential,H=Z.structures||Z.saveStructures,z=Z.maxSharedStructures;if(z==null)z=H?32:0;if(z>8160)throw new Error("Maximum maxSharedStructure is 8160");if(Z.structuredClone&&Z.moreTypes==null)this.moreTypes=!0;let V=Z.maxOwnStructures;if(V==null)V=H?32:64;if(!this.structures&&Z.useRecords!=!1)this.structures=[];let F=z>32||V+z>64,q=z+64,U=z+V+64;if(U>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let B=[],L=0,w=0;this.pack=this.encode=function(I,v){if(!l)l=new Vw(8192),v1=l.dataView||(l.dataView=new DataView(l.buffer,0,8192)),m=0;if(J5=l.length-10,J5-m<2048)l=new Vw(l.length),v1=l.dataView||(l.dataView=new DataView(l.buffer,0,l.length)),J5=l.length-10,m=0;else m=m+7&2147483640;if(X=m,v&cx1)m+=v&255;if(Q=W.structuredClone?new Map:null,W.bundleStrings&&typeof I!=="string")o1=[],o1.size=1/0;else o1=null;if($=W.structures,$){if($.uninitialized)$=W._mergeStructures(W.getStructures());let p=$.sharedLength||0;if(p>z)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 J0,Q0=$.transitions;for(let D0=0,C0=o.length;D0<C0;D0++){let a0=o[D0];if(J0=Q0[a0],!J0)J0=Q0[a0]=Object.create(null);Q0=J0}Q0[O7]=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)x(I);else M(I);let p=o1;if(o1)N60(X,M,0);if(Q&&Q.idsToInsert){let n=Q.idsToInsert.sort((D0,C0)=>D0.offset>C0.offset?1:-1),o=n.length,J0=-1;while(p&&o>0){let D0=n[--o].offset+X;if(D0<p.stringsPosition+X&&J0===-1)J0=0;if(D0>p.position+X){if(J0>=0)J0+=6}else{if(J0>=0)v1.setUint32(p.position+X,v1.getUint32(p.position+X)+J0),J0=-1;p=p.previous,o++}}if(J0>=0&&p)v1.setUint32(p.position+X,v1.getUint32(p.position+X)+J0);if(m+=n.length*6,m>J5)E(m);W.offset=m;let Q0=gx1(l.subarray(X,m),n);return Q=null,Q0}if(W.offset=m,v&dx1)return l.start=X,l.end=m,l;return l.subarray(X,m)}catch(p){throw y=p,p}finally{if($){if(N(),Y&&W.saveStructures){let p=$.sharedLength||0,n=l.subarray(X,m),o=D60($,W);if(!y){if(W.saveStructures(o,o.isCompatible)===!1)return W.pack(I,v);if(W.lastNamedStructuresLength=p,l.length>1073741824)l=null;return n}}}if(l.length>1073741824)l=null;if(v&lx1)m=X}};let N=()=>{if(w<10)w++;let I=$.sharedLength||0;if($.length>I&&!G)$.length=I;if(L>1e4){if($.transitions=null,w=0,L=0,B.length>0)B=[]}else if(B.length>0&&!G){for(let v=0,y=B.length;v<y;v++)B[v][O7]=0;B=[]}},R=(I)=>{var v=I.length;if(v<16)l[m++]=144|v;else if(v<65536)l[m++]=220,l[m++]=v>>8,l[m++]=v&255;else l[m++]=221,v1.setUint32(m,v),m+=4;for(let y=0;y<v;y++)M(I[y])},M=(I)=>{if(m>J5)l=E(m);var v=typeof I,y;if(v==="string"){let p=I.length;if(o1&&p>=4&&p<4096){if((o1.size+=p)>fx1){let Q0,D0=(o1[0]?o1[0].length*3+o1[1].length:0)+10;if(m+D0>J5)l=E(m+D0);let C0;if(o1.position)C0=o1,l[m]=200,m+=3,l[m++]=98,Q0=m-X,m+=4,N60(X,M,0),v1.setUint16(Q0+X-3,m-X-Q0);else l[m++]=214,l[m++]=98,Q0=m-X,m+=4;o1=["",""],o1.previous=C0,o1.size=0,o1.position=Q0}let J0=yx1.test(I);o1[J0?0:1]+=I,l[m++]=193,M(J0?-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>J5)l=E(m+o);if(p<64||!K){let J0,Q0,D0,C0=m+n;for(J0=0;J0<p;J0++)if(Q0=I.charCodeAt(J0),Q0<128)l[C0++]=Q0;else if(Q0<2048)l[C0++]=Q0>>6|192,l[C0++]=Q0&63|128;else if((Q0&64512)===55296&&((D0=I.charCodeAt(J0+1))&64512)===56320)Q0=65536+((Q0&1023)<<10)+(D0&1023),J0++,l[C0++]=Q0>>18|240,l[C0++]=Q0>>12&63|128,l[C0++]=Q0>>6&63|128,l[C0++]=Q0&63|128;else l[C0++]=Q0>>12|224,l[C0++]=Q0>>6&63|128,l[C0++]=Q0&63|128;y=C0-m-n}else y=K(I,m+n);if(y<32)l[m++]=160|y;else if(y<256){if(n<2)l.copyWithin(m+2,m+1,m+1+y);l[m++]=217,l[m++]=y}else if(y<65536){if(n<3)l.copyWithin(m+3,m+2,m+2+y);l[m++]=218,l[m++]=y>>8,l[m++]=y&255}else{if(n<5)l.copyWithin(m+5,m+3,m+3+y);l[m++]=219,v1.setUint32(m,y),m+=4}m+=y}else if(v==="number")if(I>>>0===I)if(I<32||I<128&&this.useRecords===!1||I<64&&!this.randomAccessStructure)l[m++]=I;else if(I<256)l[m++]=204,l[m++]=I;else if(I<65536)l[m++]=205,l[m++]=I>>8,l[m++]=I&255;else l[m++]=206,v1.setUint32(m,I),m+=4;else if(I>>0===I)if(I>=-32)l[m++]=256+I;else if(I>=-128)l[m++]=208,l[m++]=I+256;else if(I>=-32768)l[m++]=209,v1.setInt16(m,I),m+=2;else l[m++]=210,v1.setInt32(m,I),m+=4;else{let p;if((p=this.useFloat32)>0&&I<4294967296&&I>=-2147483648){l[m++]=202,v1.setFloat32(m,I);let n;if(p<4||(n=I*Z$[(l[m]&127)<<1|l[m+1]>>7])>>0===n){m+=4;return}else m--}l[m++]=203,v1.setFloat64(m,I),m+=8}else if(v==="object"||v==="function")if(!I)l[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)}l[m++]=214,l[m++]=112,v1.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)R(I);else if(p===Map)if(this.mapAsEmptyObject)l[m++]=128;else{if(y=I.size,y<16)l[m++]=128|y;else if(y<65536)l[m++]=222,l[m++]=y>>8,l[m++]=y&255;else l[m++]=223,v1.setUint32(m,y),m+=4;for(let[n,o]of I)M(n),M(o)}else{for(let n=0,o=sk.length;n<o;n++){let J0=M60[n];if(I instanceof J0){let Q0=sk[n];if(Q0.write){if(Q0.type)l[m++]=212,l[m++]=Q0.type,l[m++]=0;let i1=Q0.write.call(this,I);if(i1===I)if(Array.isArray(I))R(I);else T(I);else M(i1);return}let D0=l,C0=v1,a0=m;l=null;let E8;try{E8=Q0.pack.call(this,I,(i1)=>{if(l=D0,D0=null,m+=i1,m>J5)E(m);return{target:l,targetView:v1,position:m-i1}},M)}finally{if(D0)l=D0,v1=C0,m=a0,J5=l.length-10}if(E8){if(E8.length+m>J5)E(E8.length+m);m=bx1(E8,l,m,Q0.type)}return}}if(Array.isArray(I))R(I);else{if(I.toJSON){let n=I.toJSON();if(n!==I)return M(n)}if(v==="function")return M(this.writeFunction&&this.writeFunction(I));T(I)}}}else if(v==="boolean")l[m++]=I?195:194;else if(v==="bigint"){if(I<9223372036854776000&&I>=-9223372036854776000)l[m++]=211,v1.setBigInt64(m,I);else if(I<18446744073709552000&&I>0)l[m++]=207,v1.setBigUint64(m,I);else if(this.largeBigIntToFloat)l[m++]=203,v1.setFloat64(m,Number(I));else if(this.largeBigIntToString)return M(I.toString());else if((this.useBigIntExtension||this.moreTypes)&&I<BigInt(2)**BigInt(1023)&&I>-(BigInt(2)**BigInt(1023))){l[m++]=199,m++,l[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));l[m-2]=p.length;for(let o=p.length;o>0;)l[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(v==="undefined")if(this.encodeUndefinedAsNil)l[m++]=192;else l[m++]=212,l[m++]=0,l[m++]=0;else throw new Error("Unknown type: "+v)},D=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?(I)=>{let v;if(this.skipValues){v=[];for(let n in I)if((typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(n))&&!this.skipValues.includes(I[n]))v.push(n)}else v=Object.keys(I);let y=v.length;if(y<16)l[m++]=128|y;else if(y<65536)l[m++]=222,l[m++]=y>>8,l[m++]=y&255;else l[m++]=223,v1.setUint32(m,y),m+=4;let p;if(this.coercibleKeyAsNumber)for(let n=0;n<y;n++){p=v[n];let o=Number(p);M(isNaN(o)?p:o),M(I[p])}else for(let n=0;n<y;n++)M(p=v[n]),M(I[p])}:(I)=>{l[m++]=222;let v=m-X;m+=2;let y=0;for(let p in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(p))M(p),M(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');l[v+++X]=y>>8,l[v+X]=y&255},j=this.useRecords===!1?D:Z.progressiveRecords&&!F?(I)=>{let v,y=$.transitions||($.transitions=Object.create(null)),p=m++-X,n;for(let o in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(o)){if(v=y[o],v)y=v;else{let J0=Object.keys(I),Q0=y;y=$.transitions;let D0=0;for(let C0=0,a0=J0.length;C0<a0;C0++){let E8=J0[C0];if(v=y[E8],!v)v=y[E8]=Object.create(null),D0++;y=v}if(p+X+1==m)m--,A(y,J0,D0);else _(y,J0,p,D0);n=!0,y=Q0[o]}M(I[o])}if(!n){let o=y[O7];if(o)l[p+X]=o;else _(y,Object.keys(I),p,0)}}:(I)=>{let v,y=$.transitions||($.transitions=Object.create(null)),p=0;for(let o in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(o)){if(v=y[o],!v)v=y[o]=Object.create(null),p++;y=v}let n=y[O7];if(n)if(n>=96&&F)l[m++]=((n-=96)&31)+96,l[m++]=n>>5;else l[m++]=n;else A(y,y.__keys__||Object.keys(I),p);for(let o in I)if(typeof I.hasOwnProperty!=="function"||I.hasOwnProperty(o))M(I[o])},C=typeof this.useRecords=="function"&&this.useRecords,T=C?(I)=>{C(I)?j(I):D(I)}:j,E=(I)=>{let v;if(I>16777216){if(I-X>O60)throw new Error("Packed buffer would be larger than maximum buffer size");v=Math.min(O60,Math.round(Math.max((I-X)*(I>67108864?1.25:2),4194304)/4096)*4096)}else v=(Math.max(I-X<<2,l.length-1)>>12)+1<<12;let y=new Vw(v);if(v1=y.dataView||(y.dataView=new DataView(y.buffer,0,v)),I=Math.min(I,l.length),l.copy)l.copy(y,0,X,I);else y.set(l.slice(X,I));return m-=X,X=0,J5=y.length-10,l=y},A=(I,v,y)=>{let p=$.nextId;if(!p)p=64;if(p<q&&this.shouldShareStructure&&!this.shouldShareStructure(v)){if(p=$.nextOwnId,!(p<U))p=q;$.nextOwnId=p+1}else{if(p>=U)p=q;$.nextId=p+1}let n=v.highByte=p>=96&&F?p-96>>5:-1;if(I[O7]=p,I.__keys__=v,$[p-64]=v,p<q)if(v.isShared=!0,$.sharedLength=p-63,Y=!0,n>=0)l[m++]=(p&31)+96,l[m++]=n;else l[m++]=p;else{if(n>=0)l[m++]=213,l[m++]=114,l[m++]=(p&31)+96,l[m++]=n;else l[m++]=212,l[m++]=114,l[m++]=p;if(y)L+=w*y;if(B.length>=V)B.shift()[O7]=0;B.push(I),M(v)}},_=(I,v,y,p)=>{let n=l,o=m,J0=J5,Q0=X;if(l=Lz,m=0,X=0,!l)Lz=l=new Vw(8192);J5=l.length-10,A(I,v,p),Lz=l;let D0=m;if(l=n,m=o,J5=J0,X=Q0,D0>1){let C0=m+D0-1;if(C0>J5)E(C0);let a0=y+X;l.copyWithin(a0+D0,a0+1,m),l.set(Lz.slice(0,D0),a0),m=C0}else l[y+X]=Lz[0]},x=(I)=>{let v=j60(I,l,X,m,$,E,(y,p,n)=>{if(n)return Y=!0;m=p;let o=l;if(M(y),N(),o!==l)return{position:m,targetView:v1,target:l};return m},this);if(v===0)return T(I);m=v}}useBuffer(Z){l=Z,l.dataView||(l.dataView=new DataView(l.buffer,l.byteOffset,l.byteLength)),v1=l.dataView,m=0}set position(Z){m=Z}get position(){return m}clearSharedData(){if(this.structures)this.structures=[];if(this.typedStructs)this.typedStructs=[]}}M60=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,zw];sk=[{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)nk(Z,16,J);else ak(Bz?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let X=Z.constructor;if(X!==P60&&this.moreTypes)nk(Z,ik.indexOf(X.name),J);else ak(Z,J)}},{pack(Z,J){if(this.moreTypes)nk(Z,17,J);else ak(Bz?Buffer.from(Z):new Uint8Array(Z),J)}},{pack(Z,J){let{target:X,position:Y}=J(1);X[Y]=193}}];function nk(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 ak(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 bx1(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 gx1(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 N60(Z,J,X){if(o1.length>0){v1.setUint32(o1.position+Z,m+X-o1.position-Z),o1.stringsPosition=m-Z;let Y=o1;o1=null,J(Y[0]),J(Y[1])}}function D60(Z,J){return Z.isCompatible=(X)=>{let Y=!X||(J.lastNamedStructuresLength||0)===X.length;if(!Y)J._mergeStructures(X);return Y},Z}function C60(Z,J){j60=Z,D60=J}var T60=new J$({useRecords:!1}),mx1=T60.pack,ux1=T60.pack;var dx1=512,lx1=1024,cx1=2048;var ok=3,nK=0,wz=2,Uw=1,tk=16,k60=["num","object","string","ascii"];k60[tk]="date";var ix1=[!1,!0,!0,!1,!1,!0,!0,!1],I60;try{new Function(""),I60=!0}catch(Z){}var X$,nx1=typeof Buffer!=="undefined",Lw,N7;try{Lw=new TextEncoder}catch(Z){}var ax1=nx1?function(Z,J,X){return Z.utf8Write(J,X,Z.byteLength-X)}:Lw&&Lw.encodeInto?function(Z,J,X){return Lw.encodeInto(J,Z.subarray(X)).written}:!1,ux6=Symbol("type"),dx6=Symbol("parent");C60(v60,ex1);function v60(Z,J,X,Y,$,Q,K,W){let G=W.typedStructs||(W.typedStructs=[]),H=J.dataView,z=(G.lastStringStart||100)+Y,V=J.length-10,F=Y;if(Y>V)J=Q(Y),H=J.dataView,Y-=X,F-=X,z-=X,X=0,V=J.length-10;let q,U=z,B=G.transitions||(G.transitions=Object.create(null)),L=G.nextId||G.length,w=L<15?1:L<240?2:L<61440?3:L<15728640?4:0;if(w===0)return 0;Y+=w;let N=[],R,M=0;for(let j in Z){let C=Z[j],T=B[j];if(!T)B[j]=T={key:j,parent:B,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};if(Y>V)J=Q(Y),H=J.dataView,Y-=X,F-=X,z-=X,U-=X,X=0,V=J.length-10;switch(typeof C){case"number":let E=C;if(L<200||!T.num64){if(E>>0===E&&E<536870912&&E>-520093696){if(E<246&&E>=0&&(T.num8&&!(L>200&&T.num32)||E<32&&!T.num32))B=T.num8||_5(T,nK,1),J[Y++]=E;else B=T.num32||_5(T,nK,4),H.setUint32(Y,E,!0),Y+=4;break}else if(E<4294967296&&E>=-2147483648){if(H.setFloat32(Y,E,!0),ix1[J[Y+3]>>>5]){let I;if((I=E*Z$[(J[Y+3]&127)<<1|J[Y+2]>>7])>>0===I){B=T.num32||_5(T,nK,4),Y+=4;break}}}}B=T.num64||_5(T,nK,8),H.setFloat64(Y,E,!0),Y+=8;break;case"string":let A=C.length;if(q=U-z,(A<<2)+U>V)J=Q((A<<2)+U),H=J.dataView,Y-=X,F-=X,z-=X,U-=X,X=0,V=J.length-10;if(A>65280+q>>2){N.push(j,C,Y-F);break}let _,x=U;if(A<64){let I,v,y;for(I=0;I<A;I++)if(v=C.charCodeAt(I),v<128)J[U++]=v;else if(v<2048)_=!0,J[U++]=v>>6|192,J[U++]=v&63|128;else if((v&64512)===55296&&((y=C.charCodeAt(I+1))&64512)===56320)_=!0,v=65536+((v&1023)<<10)+(y&1023),I++,J[U++]=v>>18|240,J[U++]=v>>12&63|128,J[U++]=v>>6&63|128,J[U++]=v&63|128;else _=!0,J[U++]=v>>12|224,J[U++]=v>>6&63|128,J[U++]=v&63|128}else U+=ax1(J,C,U),_=U-x>A;if(q<160||q<246&&(T.ascii8||T.string8)){if(_){if(!(B=T.string8))if(G.length>10&&(B=T.ascii8))B.__type=wz,T.ascii8=null,T.string8=B,K(null,0,!0);else B=_5(T,wz,1)}else if(q===0&&!R){R=!0,B=T.ascii0||_5(T,ok,0);break}else if(!(B=T.ascii8)&&!(G.length>10&&(B=T.string8)))B=_5(T,ok,1);J[Y++]=q}else B=T.string16||_5(T,wz,2),H.setUint16(Y,q,!0),Y+=2;break;case"object":if(C){if(C.constructor===Date)B=T.date64||_5(T,tk,8),H.setFloat64(Y,C.getTime(),!0),Y+=8;else N.push(j,C,M);break}else if(T=E60(T,Y,H,-10),T)B=T,Y=X$;else N.push(j,C,M);break;case"boolean":B=T.num8||T.ascii8||_5(T,nK,1),J[Y++]=C?249:248;break;case"undefined":if(T=E60(T,Y,H,-9),T)B=T,Y=X$;else N.push(j,C,M);break;default:N.push(j,C,M)}M++}for(let j=0,C=N.length;j<C;){let T=N[j++],E=N[j++],A=N[j++],_=B[T];if(!_)B[T]=_={key:T,parent:B,enumerationOffset:A-M,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null};let x;if(E){let I;if(q=U-z,q<65280)if(B=_.object16,B)I=2;else if(B=_.object32)I=4;else B=_5(_,Uw,2),I=2;else B=_.object32||_5(_,Uw,4),I=4;if(x=K(E,U),typeof x==="object")U=x.position,H=x.targetView,J=x.target,z-=X,Y-=X,F-=X,X=0;else U=x;if(I===2)H.setUint16(Y,q,!0),Y+=2;else H.setUint32(Y,q,!0),Y+=4}else B=_.object16||_5(_,Uw,2),H.setInt16(Y,E===null?-10:-9,!0),Y+=2;M++}let D=B[O7];if(D==null){D=W.typedStructs.length;let j=[],C=B,T,E;while((E=C.__type)!==void 0){let A=C.__size;C=C.__parent,T=C.key;let _=[E,A,T];if(C.enumerationOffset)_.push(C.enumerationOffset);j.push(_),C=C.parent}j.reverse(),B[O7]=D,W.typedStructs[D]=j,K(null,0,!0)}switch(w){case 1:if(D>=16)return 0;J[F]=D+32;break;case 2:if(D>=256)return 0;J[F]=56,J[F+1]=D;break;case 3:if(D>=65536)return 0;J[F]=57,H.setUint16(F+1,D,!0);break;case 4:if(D>=16777216)return 0;H.setUint32(F,(D<<8)+58,!0);break}if(Y<z){if(z===U)return Y;J.copyWithin(Y,z,U),U+=Y-z,G.lastStringStart=Y-F}else if(Y>z){if(z===U)return Y;return G.lastStringStart=Y-F,v60(Z,J,X,F,$,Q,K,W)}return U}function E60(Z,J,X,Y){let $;if($=Z.ascii8||Z.num8)return X.setInt8(J,Y,!0),X$=J+1,$;if($=Z.string16||Z.object16)return X.setInt16(J,Y,!0),X$=J+2,$;if($=Z.num32)return X.setUint32(J,3758096640+Y,!0),X$=J+4,$;if($=Z.num64)return X.setFloat64(J,NaN,!0),X.setInt8(J,Y),X$=J+8,$;X$=J;return}function _5(Z,J,X){let Y=k60[J]+(X<<3),$=Z[Y]||(Z[Y]=Object.create(null));return $.__type=J,$.__size=X,$.__parent=Z,$}function sx1(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,H,z]of K){let V=W[z];if(!V)W[z]=V={key:z,parent:W,enumerationOffset:0,ascii0:null,ascii8:null,num8:null,string16:null,object16:null,num32:null,float64:null,date64:null};W=_5(V,G,H)}W[O7]=$}return J.transitions=Y,this.typedStructs=J,this.lastTypedStructuresLength=J.length,X}var rk=Symbol.for("source");function ox1(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 z=[],V=0,F;for(let q=0,U=Q.length;q<U;q++){let B=Q[q],[L,w,N,R]=B;if(N==="__proto__")N="__proto_";let M={key:N,offset:V};if(R)z.splice(q+R,0,M);else z.push(M);let D;switch(w){case 0:D=()=>0;break;case 1:D=(C,T)=>{let E=C.bytes[T+M.offset];return E>=246?iK(E):E};break;case 2:D=(C,T)=>{let E=C.bytes,_=(E.dataView||(E.dataView=new DataView(E.buffer,E.byteOffset,E.byteLength))).getUint16(T+M.offset,!0);return _>=65280?iK(_&255):_};break;case 4:D=(C,T)=>{let E=C.bytes,_=(E.dataView||(E.dataView=new DataView(E.buffer,E.byteOffset,E.byteLength))).getUint32(T+M.offset,!0);return _>=4294967040?iK(_&255):_};break}M.getRef=D,V+=w;let j;switch(L){case ok:if(F&&!F.next)F.next=M;F=M,M.multiGetCount=0,j=function(C){let{bytes:T,position:E}=C,A=V+E,_=D(C,E);if(typeof _!=="number")return _;let x,I=M.next;while(I){if(x=I.getRef(C,E),typeof x==="number")break;else x=null;I=I.next}if(x==null)x=C.bytesEnd-A;if(C.srcString)return C.srcString.slice(_,x);return V60(T,_+A,x-_)};break;case wz:case Uw:if(F&&!F.next)F.next=M;F=M,j=function(C){let T=C.position,E=V+T,A=D(C,T);if(typeof A!=="number")return A;let _=C.bytes,x,I=M.next;while(I){if(x=I.getRef(C,T),typeof x==="number")break;else x=null;I=I.next}if(x==null)x=C.bytesEnd-E;if(L===wz)return _.toString("utf8",A+E,x+E);else{N7=C;try{return Y.unpack(_,{start:A+E,end:x+E})}finally{N7=null}}};break;case nK:switch(w){case 4:j=function(C){let T=C.bytes,E=T.dataView||(T.dataView=new DataView(T.buffer,T.byteOffset,T.byteLength)),A=C.position+M.offset,_=E.getInt32(A,!0);if(_<536870912){if(_>-520093696)return _;if(_>-536870912)return iK(_&255)}let x=E.getFloat32(A,!0),I=Z$[(T[A+3]&127)<<1|T[A+2]>>7];return(I*x+(x>0?0.5:-0.5)>>0)/I};break;case 8:j=function(C){let T=C.bytes,A=(T.dataView||(T.dataView=new DataView(T.buffer,T.byteOffset,T.byteLength))).getFloat64(C.position+M.offset,!0);if(isNaN(A)){let _=T[C.position+M.offset];if(_>=246)return iK(_)}return A};break;case 1:j=function(C){let E=C.bytes[C.position+M.offset];return E<246?E:iK(E)};break}break;case tk:j=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+M.offset,!0))};break}M.get=j}if(I60){let q=[],U=[],B=0,L;for(let N of z){if(Y.alwaysLazyProperty&&Y.alwaysLazyProperty(N.key)){L=!0;continue}Object.defineProperty(G,N.key,{get:rx1(N.get),enumerable:!0});let R="v"+B++;U.push(R),q.push("o["+JSON.stringify(N.key)+"]="+R+"(s)")}if(L)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,z.map((N)=>N.get));Object.defineProperty(G,"toJSON",{value(N){return w.call(this,this[rk])}})}else Object.defineProperty(G,"toJSON",{value(q){let U={};for(let B=0,L=z.length;B<L;B++){let w=z[B].key;U[w]=this[w]}return U}})}var H=new K;return H[rk]={bytes:Z,position:J,srcString:"",bytesEnd:X},H}function iK(Z){switch(Z){case 246:return null;case 247:return;case 248:return!1;case 249:return!0}throw new Error("Unknown constant")}function rx1(Z){return function(){return Z(this[rk])}}function tx1(){if(N7)N7.bytes=Uint8Array.prototype.slice.call(N7.bytes,N7.position,N7.bytesEnd),N7.position=0,N7.bytesEnd=N7.bytes.length}function ex1(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}w60(ox1,sx1,tx1);var Xh1=process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED!==void 0&&process.env.MSGPACKR_NATIVE_ACCELERATION_DISABLED.toLowerCase()==="true";if(!Xh1){let Z;try{if(Z=g("msgpackr-extract"),Z)F60(Z.extractStrings)}catch(J){}}import Pn1 from"mediasoup";var jO=r(zY0(),1);import Nn1 from"http";import Rn1 from"https";import PO from"fs";import Mn1 from"path";var hY0=r(AY0(),1);import N$ from"fs";import xY0 from"path";var wF="./dev/persistence";class E7{static instance=new E7;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;constructor(){try{this._creativeGateway=new hY0.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(!N$.existsSync(wF))return;let J=xY0.join(wF,`${Z}.json`);return JSON.parse(N$.readFileSync(J,"utf8"))}catch(J){u.warning(`PlatformGateway._readDevDataLocally(): Failed to read data for key "${Z}": ${J}`)}}_writeDevDataLocally(Z,J){try{if(!N$.existsSync(wF))N$.mkdirSync(wF,{recursive:!0});let X=xY0.join(wF,`${Z}.json`),Y={};if(N$.existsSync(X))Y=JSON.parse(N$.readFileSync(X,"utf8"));let $={...Y,...J};N$.writeFileSync(X,JSON.stringify($,null,2),"utf8")}catch(X){u.warning(`PlatformGateway._writeDevDataLocally(): Failed to write data for key "${Z}": ${X}`)}}}var fY0=`-----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 H_=process.env.PORT??8080,z_="0.5.19",F_;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(F_||={});class CW extends g0{static instance=new CW;_webserver=jO.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:z_})}),this._webserver.use(jO.default.static("assets"));try{this._webserver.use(jO.default.static(Mn1.dirname(g.resolve("@hytopia.com/assets"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Nn1.createServer(this._webserver):Rn1.createServer({key:PO.existsSync("assets/certs/localhost.key")?PO.readFileSync("assets/certs/localhost.key"):yY0,cert:PO.existsSync("assets/certs/localhost.crt")?PO.readFileSync("assets/certs/localhost.crt"):fY0},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(H_,this._onStarted),console.info(`WebServer.start(): Server running on port ${H_}.`)}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=new URL(Z.url??"",`https://${Z.headers.host}`),$=Y.searchParams.get("connectionId")??void 0,Q=Y.searchParams.get("sessionToken")??"",K=await E7.instance.getPlayerSession(Q);if($)Z.connectionId=$;if(K)if(!K.error)Z.session=K;else{let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
460
+ -----END RSA PRIVATE KEY-----`;var H_=process.env.PORT??8080,z_="0.5.20",F_;(($)=>{$.READY="WEBSERVER.READY";$.STOPPED="WEBSERVER.STOPPED";$.ERROR="WEBSERVER.ERROR";$.UPGRADE="WEBSERVER.UPGRADE"})(F_||={});class CW extends g0{static instance=new CW;_webserver=jO.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:z_})}),this._webserver.use(jO.default.static("assets"));try{this._webserver.use(jO.default.static(Mn1.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?Nn1.createServer(this._webserver):Rn1.createServer({key:PO.existsSync("assets/certs/localhost.key")?PO.readFileSync("assets/certs/localhost.key"):yY0,cert:PO.existsSync("assets/certs/localhost.crt")?PO.readFileSync("assets/certs/localhost.crt"):fY0},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(H_,this._onStarted),console.info(`WebServer.start(): Server running on port ${H_}.`)}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=new URL(Z.url??"",`https://${Z.headers.host}`),$=Y.searchParams.get("connectionId")??void 0,Q=Y.searchParams.get("sessionToken")??"",K=await E7.instance.getPlayerSession(Q);if($)Z.connectionId=$;if(K)if(!K.error)Z.session=K;else{let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
461
461
  `),J.write(`Content-Type: text/plain\r
462
462
  `),J.write(`Content-Length: ${W.length}\r
463
463
  `),J.write(`Connection: close\r