hytopia 0.10.38-notifications-prerelease → 0.10.38-notifications-prerelease-2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server.mjs +2 -2
package/server.mjs CHANGED
@@ -396,7 +396,7 @@ For example, you can use the \`pathToFileURL()\` method of the \`url\` core modu
396
396
  Instead, \`yield\` should either be called with a value, or not be called at all. For example:
397
397
  if (condition) { yield value; }`)};import{Buffer as Cq1}from"node:buffer";import{StringDecoder as fq1}from"node:string_decoder";var VF=(Z,J,X)=>{if(X)return;if(Z)return{transform:kq1.bind(void 0,new TextEncoder)};let $=new fq1(J);return{transform:Eq1.bind(void 0,$),final:Iq1.bind(void 0,$)}},kq1=function*(Z,J){if(Cq1.isBuffer(J))yield s7(J);else if(typeof J==="string")yield Z.encode(J);else yield J},Eq1=function*(Z,J){yield _8(J)?Z.write(J):J},Iq1=function*(Z){let J=Z.end();if(J!=="")yield J};import{callbackify as iy}from"node:util";var KM=iy(async(Z,J,X,$)=>{J.currentIterable=Z(...X);try{for await(let Y of J.currentIterable)$.push(Y)}finally{delete J.currentIterable}}),HF=async function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:$=hq1}=J[X];for await(let Y of $(Z))yield*HF(Y,J,X+1)},gy=async function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*_q1(X,Number(J),Z)},_q1=async function*(Z,J,X){if(Z===void 0)return;for await(let $ of Z())yield*HF($,X,J+1)},dy=iy(async({currentIterable:Z},J)=>{if(Z!==void 0){await(J?Z.throw(J):Z.return());return}if(J)throw J}),hq1=function*(Z){yield Z};var WM=(Z,J,X,$)=>{try{for(let Y of Z(...J))X.push(Y);$()}catch(Y){$(Y)}},ay=(Z,J)=>[...J.flatMap((X)=>[...P$(X,Z,0)]),...eW(Z)],P$=function*(Z,J,X){if(X===J.length){yield Z;return}let{transform:$=bq1}=J[X];for(let Y of $(Z))yield*P$(Y,J,X+1)},eW=function*(Z){for(let[J,{final:X}]of Object.entries(Z))yield*Sq1(X,Number(J),Z)},Sq1=function*(Z,J,X){if(Z===void 0)return;for(let $ of Z())yield*P$($,X,J+1)},bq1=function*(Z){yield Z};var GM=({value:Z,value:{transform:J,final:X,writableObjectMode:$,readableObjectMode:Y},optionName:Q},{encoding:K})=>{let W={},G=sy(Z,K,Q),z=R$(J),v=R$(X),H=z?KM.bind(void 0,HF,W):WM.bind(void 0,P$),V=z||v?KM.bind(void 0,gy,W):WM.bind(void 0,eW),q=z||v?dy.bind(void 0,W):void 0;return{stream:new Aq1({writableObjectMode:$,writableHighWaterMark:ny($),readableObjectMode:Y,readableHighWaterMark:ny(Y),transform(w,c,x){H([w,G,0],this,x)},flush(w){V([G],this,w)},destroy:q})}},qF=(Z,J,X,$)=>{let Y=J.filter(({type:K})=>K==="generator"),Q=$?Y.reverse():Y;for(let{value:K,optionName:W}of Q){let G=sy(K,X,W);Z=ay(G,Z)}return Z},sy=({transform:Z,final:J,binary:X,writableObjectMode:$,readableObjectMode:Y,preserveNewlines:Q},K,W)=>{let G={};return[{transform:ly($,W)},VF(X,K,$),vF(X,Q,$,G),{transform:Z,final:J},{transform:yy(Y,W)},uy({binary:X,preserveNewlines:Q,readableObjectMode:Y,state:G})].filter(Boolean)};var oy=(Z,J)=>{for(let X of mq1(Z))uq1(Z,X,J)},mq1=(Z)=>new Set(Object.entries(Z).filter(([,{direction:J}])=>J==="input").map(([J])=>Number(J))),uq1=(Z,J,X)=>{let{stdioItems:$}=Z[J],Y=$.filter(({contents:W})=>W!==void 0);if(Y.length===0)return;if(J!==0){let[{type:W,optionName:G}]=Y;throw TypeError(`Only the \`stdin\` option, not \`${G}\`, can be ${kJ[W]} with synchronous methods.`)}let K=Y.map(({contents:W})=>W).map((W)=>lq1(W,$));X.input=gW(K)},lq1=(Z,J)=>{let X=qF(Z,J,"utf8",!0);return yq1(X),gW(X)},yq1=(Z)=>{let J=Z.find((X)=>typeof X!=="string"&&!_8(X));if(J!==void 0)throw 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 dq1,appendFileSync as aq1}from"node:fs";var FF=({stdioItems:Z,encoding:J,verboseInfo:X,fdNumber:$})=>$!=="all"&&lQ(X,$)&&!E5.has(J)&&pq1($)&&(Z.some(({type:Y,value:Q})=>Y==="native"&&iq1.has(Q))||Z.every(({type:Y})=>z4.has(Y))),pq1=(Z)=>Z===1||Z===2,iq1=new Set(["pipe","overlapped"]),ry=async(Z,J,X,$)=>{for await(let Y of Z)if(!gq1(J))ey(Y,X,$)},ty=(Z,J,X)=>{for(let $ of Z)ey($,J,X)},gq1=(Z)=>Z._readableState.pipes.length>0,ey=(Z,J,X)=>{let $=Pq(Z);t9({type:"output",verboseMessage:$,fdNumber:J,verboseInfo:X})};var Zp=({fileDescriptors:Z,syncResult:{output:J},options:X,isMaxBuffer:$,verboseInfo:Y})=>{if(J===null)return{output:Array.from({length:3})};let Q={},K=new Set([]);return{output:J.map((G,z)=>nq1({result:G,fileDescriptors:Z,fdNumber:z,state:Q,outputFiles:K,isMaxBuffer:$,verboseInfo:Y},X)),...Q}},nq1=({result:Z,fileDescriptors:J,fdNumber:X,state:$,outputFiles:Y,isMaxBuffer:Q,verboseInfo:K},{buffer:W,encoding:G,lines:z,stripFinalNewline:v,maxBuffer:H})=>{if(Z===null)return;let V=Jy(Z,Q,H),q=s7(V),{stdioItems:F,objectMode:w}=J[X],c=sq1([q],F,G,$),{serializedResult:x,finalResult:j=x}=oq1({chunks:c,objectMode:w,encoding:G,lines:z,stripFinalNewline:v,fdNumber:X});rq1({serializedResult:x,fdNumber:X,state:$,verboseInfo:K,encoding:G,stdioItems:F,objectMode:w});let B=W[X]?j:void 0;try{if($.error===void 0)tq1(x,F,Y);return B}catch(L){return $.error=L,B}},sq1=(Z,J,X,$)=>{try{return qF(Z,J,X,!1)}catch(Y){return $.error=Y,Z}},oq1=({chunks:Z,objectMode:J,encoding:X,lines:$,stripFinalNewline:Y,fdNumber:Q})=>{if(J)return{serializedResult:Z};if(X==="buffer")return{serializedResult:gW(Z)};let K=wm(Z,X);if($[Q])return{serializedResult:K,finalResult:QM(K,!Y[Q],J)};return{serializedResult:K}},rq1=({serializedResult:Z,fdNumber:J,state:X,verboseInfo:$,encoding:Y,stdioItems:Q,objectMode:K})=>{if(!FF({stdioItems:Q,encoding:Y,verboseInfo:$,fdNumber:J}))return;let W=QM(Z,!1,K);try{ty(W,J,$)}catch(G){X.error??=G}},tq1=(Z,J,X)=>{for(let{path:$,append:Y}of J.filter(({type:Q})=>GF.has(Q))){let Q=typeof $==="string"?$:$.toString();if(Y||X.has(Q))aq1($,Z);else X.add(Q),dq1($,Z)}};var Jp=([,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,e7(J,X,"all")];if(Array.isArray(J))return[e7(Z,X,"all"),...J];if(_8(Z)&&_8(J))return FD([Z,J]);return`${Z}${J}`};import{once as zM}from"node:events";var Xp=async(Z,J)=>{let[X,$]=await eq1(Z);return J.isForcefullyTerminated??=!1,[X,$]},eq1=async(Z)=>{let[J,X]=await Promise.allSettled([zM(Z,"spawn"),zM(Z,"exit")]);if(J.status==="rejected")return[];return X.status==="rejected"?$p(Z):X.value},$p=async(Z)=>{try{return await zM(Z,"exit")}catch{return $p(Z)}},Yp=async(Z)=>{let[J,X]=await Z;if(!ZF1(J,X)&&vM(J,X))throw new e9;return[J,X]},ZF1=(Z,J)=>Z===void 0&&J===void 0,vM=(Z,J)=>Z!==0||J!==null;var Qp=({error:Z,status:J,signal:X,output:$},{maxBuffer:Y})=>{let Q=JF1(Z,J,X),K=Q?.code==="ETIMEDOUT",W=Zy(Q,$,Y);return{resultError:Q,exitCode:J,signal:X,timedOut:K,isMaxBuffer:W}},JF1=(Z,J,X)=>{if(Z!==void 0)return Z;return vM(J,X)?new e9:void 0};var Kp=(Z,J,X)=>{let{file:$,commandArguments:Y,command:Q,escapedCommand:K,startTime:W,verboseInfo:G,options:z,fileDescriptors:v}=$F1(Z,J,X),H=KF1({file:$,commandArguments:Y,options:z,command:Q,escapedCommand:K,verboseInfo:G,fileDescriptors:v,startTime:W});return oQ(H,G,z)},$F1=(Z,J,X)=>{let{command:$,escapedCommand:Y,startTime:Q,verboseInfo:K}=Oq(Z,J,X),W=YF1(X),{file:G,commandArguments:z,options:v}=oq(Z,J,W);QF1(v);let H=Sy(v,K);return{file:G,commandArguments:z,command:$,escapedCommand:Y,startTime:Q,verboseInfo:K,options:v,fileDescriptors:H}},YF1=(Z)=>Z.node&&!Z.ipc?{...Z,ipc:!1}:Z,QF1=({ipc:Z,ipcInput:J,detached:X,cancelSignal:$})=>{if(J)wF("ipcInput");if(Z)wF("ipc: true");if(X)wF("detached: true");if($)wF("cancelSignal")},wF=(Z)=>{throw TypeError(`The "${Z}" option cannot be used with synchronous methods.`)},KF1=({file:Z,commandArguments:J,options:X,command:$,escapedCommand:Y,verboseInfo:Q,fileDescriptors:K,startTime:W})=>{let G=WF1({file:Z,commandArguments:J,options:X,command:$,escapedCommand:Y,fileDescriptors:K,startTime:W});if(G.failed)return G;let{resultError:z,exitCode:v,signal:H,timedOut:V,isMaxBuffer:q}=Qp(G,X),{output:F,error:w=z}=Zp({fileDescriptors:K,syncResult:G,options:X,isMaxBuffer:q,verboseInfo:Q}),c=F.map((j,B)=>e7(j,X,B)),x=e7(Jp(F,X),X,"all");return zF1({error:w,exitCode:v,signal:H,timedOut:V,isMaxBuffer:q,stdio:c,all:x,options:X,command:$,escapedCommand:Y,startTime:W})},WF1=({file:Z,commandArguments:J,options:X,command:$,escapedCommand:Y,fileDescriptors:Q,startTime:K})=>{try{oy(Q,X);let W=GF1(X);return XF1(Z,J,W)}catch(W){return sQ({error:W,command:$,escapedCommand:Y,fileDescriptors:Q,options:X,startTime:K,isSync:!0})}},GF1=({encoding:Z,maxBuffer:J,...X})=>({...X,encoding:"buffer",maxBuffer:YF(J)}),zF1=({error:Z,exitCode:J,signal:X,timedOut:$,isMaxBuffer:Y,stdio:Q,all:K,options:W,command:G,escapedCommand:z,startTime:v})=>Z===void 0?QF({command:G,escapedCommand:z,stdio:Q,all:K,ipcOutput:[],options:W,startTime:v}):tW({error:Z,command:G,escapedCommand:z,timedOut:$,isCanceled:!1,isGracefullyCanceled:!1,isMaxBuffer:Y,isForcefullyTerminated:!1,exitCode:J,signal:X,stdio:Q,all:K,ipcOutput:[],options:W,startTime:v,isSync:!0});import{setMaxListeners as ow1}from"node:events";import{spawn as rw1}from"node:child_process";import Vp from"node:process";import{once as VM,on as vF1}from"node:events";var Wp=({anyProcess:Z,channel:J,isSubprocess:X,ipc:$},{reference:Y=!0,filter:Q}={})=>{return iQ({methodName:"getOneMessage",isSubprocess:X,ipc:$,isConnected:iq(Z)}),VF1({anyProcess:Z,channel:J,isSubprocess:X,filter:Q,reference:Y})},VF1=async({anyProcess:Z,channel:J,isSubprocess:X,filter:$,reference:Y})=>{uq(J,Y);let Q=fJ(Z,J,X),K=new AbortController;try{return await Promise.race([HF1(Q,$,K),qF1(Q,X,K),FF1(Q,X,K)])}catch(W){throw gQ(Z),W}finally{K.abort(),lq(J,Y)}},HF1=async(Z,J,{signal:X})=>{if(J===void 0){let[$]=await VM(Z,"message",{signal:X});return $}for await(let[$]of vF1(Z,"message",{signal:X}))if(J($))return $},qF1=async(Z,J,{signal:X})=>{await VM(Z,"disconnect",{signal:X}),du(J)},FF1=async(Z,J,{signal:X})=>{let[$]=await VM(Z,"strict:error",{signal:X});throw bq($,J)};import{once as zp,on as wF1}from"node:events";var vp=({anyProcess:Z,channel:J,isSubprocess:X,ipc:$},{reference:Y=!0}={})=>HM({anyProcess:Z,channel:J,isSubprocess:X,ipc:$,shouldAwait:!X,reference:Y}),HM=({anyProcess:Z,channel:J,isSubprocess:X,ipc:$,shouldAwait:Y,reference:Q})=>{iQ({methodName:"getEachMessage",isSubprocess:X,ipc:$,isConnected:iq(Z)}),uq(J,Q);let K=fJ(Z,J,X),W=new AbortController,G={};return cF1(Z,K,W),xF1({ipcEmitter:K,isSubprocess:X,controller:W,state:G}),UF1({anyProcess:Z,channel:J,ipcEmitter:K,isSubprocess:X,shouldAwait:Y,controller:W,state:G,reference:Q})},cF1=async(Z,J,X)=>{try{await zp(J,"disconnect",{signal:X.signal}),X.abort()}catch{}},xF1=async({ipcEmitter:Z,isSubprocess:J,controller:X,state:$})=>{try{let[Y]=await zp(Z,"strict:error",{signal:X.signal});$.error=bq(Y,J),X.abort()}catch{}},UF1=async function*({anyProcess:Z,channel:J,ipcEmitter:X,isSubprocess:$,shouldAwait:Y,controller:Q,state:K,reference:W}){try{for await(let[G]of wF1(X,"message",{signal:Q.signal}))Gp(K),yield G}catch{Gp(K)}finally{if(Q.abort(),lq(J,W),!$)gQ(Z);if(Y)await Z}},Gp=({error:Z})=>{if(Z)throw Z};var Hp=(Z,{ipc:J})=>{Object.assign(Z,Fp(Z,!1,J))},qp=()=>{let Z=Vp,J=!0,X=Vp.channel!==void 0;return{...Fp(Z,!0,X),getCancelSignal:jl.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:!0,ipc:X})}},Fp=(Z,J,X)=>({sendMessage:nq.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getOneMessage:Wp.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X}),getEachMessage:vp.bind(void 0,{anyProcess:Z,channel:Z.channel,isSubprocess:J,ipc:X})});import{ChildProcess as jF1}from"node:child_process";import{PassThrough as BF1,Readable as LF1,Writable as DF1,Duplex as MF1}from"node:stream";var wp=({error:Z,command:J,escapedCommand:X,fileDescriptors:$,options:Y,startTime:Q,verboseInfo:K})=>{XM($);let W=new jF1;RF1(W,$),Object.assign(W,{readable:PF1,writable:NF1,duplex:OF1});let G=sQ({error:Z,command:J,escapedCommand:X,fileDescriptors:$,options:Y,startTime:Q,isSync:!1}),z=TF1(G,K,Y);return{subprocess:W,promise:z}},RF1=(Z,J)=>{let X=ZG(),$=ZG(),Y=ZG(),Q=Array.from({length:J.length-3},ZG),K=ZG(),W=[X,$,Y,...Q];Object.assign(Z,{stdin:X,stdout:$,stderr:Y,all:K,stdio:W})},ZG=()=>{let Z=new BF1;return Z.end(),Z},PF1=()=>new LF1({read(){}}),NF1=()=>new DF1({write(){}}),OF1=()=>new MF1({read(){},write(){}}),TF1=async(Z,J,X)=>oQ(Z,J,X);import{createReadStream as cp,createWriteStream as xp}from"node:fs";import{Buffer as CF1}from"node:buffer";import{Readable as JG,Writable as fF1,Duplex as kF1}from"node:stream";var jp=(Z,J)=>zF(EF1,Z,J,!1),XG=({type:Z,optionName:J})=>{throw TypeError(`The \`${J}\` option cannot be ${kJ[Z]}.`)},Up={fileNumber:XG,generator:GM,asyncGenerator:GM,nodeStream:({value:Z})=>({stream:Z}),webTransform({value:{transform:Z,writableObjectMode:J,readableObjectMode:X}}){let $=J||X;return{stream:kF1.fromWeb(Z,{objectMode:$})}},duplex:({value:{transform:Z}})=>({stream:Z}),native(){}},EF1={input:{...Up,fileUrl:({value:Z})=>({stream:cp(Z)}),filePath:({value:{file:Z}})=>({stream:cp(Z)}),webStream:({value:Z})=>({stream:JG.fromWeb(Z)}),iterable:({value:Z})=>({stream:JG.from(Z)}),asyncIterable:({value:Z})=>({stream:JG.from(Z)}),string:({value:Z})=>({stream:JG.from(Z)}),uint8Array:({value:Z})=>({stream:JG.from(CF1.from(Z))})},output:{...Up,fileUrl:({value:Z})=>({stream:xp(Z)}),filePath:({value:{file:Z,append:J}})=>({stream:xp(Z,J?{flags:"a"}:{})}),webStream:({value:Z})=>({stream:fF1.fromWeb(Z)}),iterable:XG,asyncIterable:XG,string:XG,uint8Array:XG}};import{on as IF1,once as Bp}from"node:events";import{PassThrough as _F1,getDefaultHighWaterMark as hF1}from"node:stream";import{finished as Mp}from"node:stream/promises";function N$(Z){if(!Array.isArray(Z))throw TypeError(`Expected an array, got \`${typeof Z}\`.`);for(let Y of Z)qM(Y);let J=Z.some(({readableObjectMode:Y})=>Y),X=SF1(Z,J),$=new Rp({objectMode:J,writableHighWaterMark:X,readableHighWaterMark:X});for(let Y of Z)$.add(Y);return $}var SF1=(Z,J)=>{if(Z.length===0)return hF1(J);let X=Z.filter(({readableObjectMode:$})=>$===J).map(({readableHighWaterMark:$})=>$);return Math.max(...X)};class Rp extends _F1{#Z=new Set([]);#J=new Set([]);#$=new Set([]);#X;#Y=Symbol("unpipe");#v=new WeakMap;add(Z){if(qM(Z),this.#Z.has(Z))return;this.#Z.add(Z),this.#X??=bF1(this,this.#Z,this.#Y);let J=uF1({passThroughStream:this,stream:Z,streams:this.#Z,ended:this.#J,aborted:this.#$,onFinished:this.#X,unpipeEvent:this.#Y});this.#v.set(Z,J),Z.pipe(this,{end:!1})}async remove(Z){if(qM(Z),!this.#Z.has(Z))return!1;let J=this.#v.get(Z);if(J===void 0)return!1;return this.#v.delete(Z),Z.unpipe(this),await J,!0}}var bF1=async(Z,J,X)=>{cF(Z,Lp);let $=new AbortController;try{await Promise.race([AF1(Z,$),mF1(Z,J,X,$)])}finally{$.abort(),cF(Z,-Lp)}},AF1=async(Z,{signal:J})=>{try{await Mp(Z,{signal:J,cleanup:!0})}catch(X){throw Pp(Z,X),X}},mF1=async(Z,J,X,{signal:$})=>{for await(let[Y]of IF1(Z,"unpipe",{signal:$}))if(J.has(Y))Y.emit(X)},qM=(Z)=>{if(typeof Z?.pipe!=="function")throw TypeError(`Expected a readable stream, got: \`${typeof Z}\`.`)},uF1=async({passThroughStream:Z,stream:J,streams:X,ended:$,aborted:Y,onFinished:Q,unpipeEvent:K})=>{cF(Z,Dp);let W=new AbortController;try{await Promise.race([lF1(Q,J,W),yF1({passThroughStream:Z,stream:J,streams:X,ended:$,aborted:Y,controller:W}),pF1({stream:J,streams:X,ended:$,aborted:Y,unpipeEvent:K,controller:W})])}finally{W.abort(),cF(Z,-Dp)}if(X.size>0&&X.size===$.size+Y.size)if($.size===0&&Y.size>0)FM(Z);else iF1(Z)},lF1=async(Z,J,{signal:X})=>{try{if(await Z,!X.aborted)FM(J)}catch($){if(!X.aborted)Pp(J,$)}},yF1=async({passThroughStream:Z,stream:J,streams:X,ended:$,aborted:Y,controller:{signal:Q}})=>{try{if(await Mp(J,{signal:Q,cleanup:!0,readable:!0,writable:!1}),X.has(J))$.add(J)}catch(K){if(Q.aborted||!X.has(J))return;if(Np(K))Y.add(J);else Op(Z,K)}},pF1=async({stream:Z,streams:J,ended:X,aborted:$,unpipeEvent:Y,controller:{signal:Q}})=>{if(await Bp(Z,Y,{signal:Q}),!Z.readable)return Bp(Q,"abort",{signal:Q});J.delete(Z),X.delete(Z),$.delete(Z)},iF1=(Z)=>{if(Z.writable)Z.end()},Pp=(Z,J)=>{if(Np(J))FM(Z);else Op(Z,J)},Np=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",FM=(Z)=>{if(Z.readable||Z.writable)Z.destroy()},Op=(Z,J)=>{if(!Z.destroyed)Z.once("error",gF1),Z.destroy(J)},gF1=()=>{},cF=(Z,J)=>{let X=Z.getMaxListeners();if(X!==0&&X!==Number.POSITIVE_INFINITY)Z.setMaxListeners(X+J)},Lp=2,Dp=1;import{finished as Tp}from"node:stream/promises";var tQ=(Z,J)=>{Z.pipe(J),dF1(Z,J),aF1(Z,J)},dF1=async(Z,J)=>{if(V9(Z)||V9(J))return;try{await Tp(Z,{cleanup:!0,readable:!0,writable:!1})}catch{}wM(J)},wM=(Z)=>{if(Z.writable)Z.end()},aF1=async(Z,J)=>{if(V9(Z)||V9(J))return;try{await Tp(J,{cleanup:!0,readable:!1,writable:!0})}catch{}cM(Z)},cM=(Z)=>{if(Z.readable)Z.destroy()};var Cp=(Z,J,X)=>{let $=new Map;for(let[Y,{stdioItems:Q,direction:K}]of Object.entries(J)){for(let{stream:W}of Q.filter(({type:G})=>z4.has(G)))nF1(Z,W,K,Y);for(let{stream:W}of Q.filter(({type:G})=>!z4.has(G)))oF1({subprocess:Z,stream:W,direction:K,fdNumber:Y,pipeGroups:$,controller:X})}for(let[Y,Q]of $.entries()){let K=Q.length===1?Q[0]:N$(Q);tQ(K,Y)}},nF1=(Z,J,X,$)=>{if(X==="output")tQ(Z.stdio[$],J);else tQ(J,Z.stdio[$]);let Y=sF1[$];if(Y!==void 0)Z[Y]=J;Z.stdio[$]=J},sF1=["stdin","stdout","stderr"],oF1=({subprocess:Z,stream:J,direction:X,fdNumber:$,pipeGroups:Y,controller:Q})=>{if(J===void 0)return;rF1(J,Q);let[K,W]=X==="output"?[J,Z.stdio[$]]:[Z.stdio[$],J],G=Y.get(K)??[];Y.set(K,[...G,W])},rF1=(Z,{signal:J})=>{if(V9(Z))D$(Z,tF1,J)},tF1=2;import{addAbortListener as Jw1}from"node:events";var O$=[];O$.push("SIGHUP","SIGINT","SIGTERM");if(process.platform!=="win32")O$.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");if(process.platform==="linux")O$.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var xF=(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",xM=Symbol.for("signal-exit emitter"),UM=globalThis,eF1=Object.defineProperty.bind(Object);class fp{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(UM[xM])return UM[xM];eF1(UM,xM,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(Z,J){this.listeners[Z].push(J)}removeListener(Z,J){let X=this.listeners[Z],$=X.indexOf(J);if($===-1)return;if($===0&&X.length===1)X.length=0;else X.splice($,1)}emit(Z,J,X){if(this.emitted[Z])return!1;this.emitted[Z]=!0;let $=!1;for(let Y of this.listeners[Z])$=Y(J,X)===!0||$;if(Z==="exit")$=this.emit("afterExit",J,X)||$;return $}}class BM{}var Zw1=(Z)=>{return{onExit(J,X){return Z.onExit(J,X)},load(){return Z.load()},unload(){return Z.unload()}}};class kp extends BM{onExit(){return()=>{}}load(){}unload(){}}class Ep extends BM{#Z=jM.platform==="win32"?"SIGINT":"SIGHUP";#J=new fp;#$;#X;#Y;#v={};#H=!1;constructor(Z){super();this.#$=Z,this.#v={};for(let J of O$)this.#v[J]=()=>{let X=this.#$.listeners(J),{count:$}=this.#J,Y=Z;if(typeof Y.__signal_exit_emitter__==="object"&&typeof Y.__signal_exit_emitter__.count==="number")$+=Y.__signal_exit_emitter__.count;if(X.length===$){this.unload();let Q=this.#J.emit("exit",null,J),K=J==="SIGHUP"?this.#Z:J;if(!Q)Z.kill(Z.pid,K)}};this.#Y=Z.reallyExit,this.#X=Z.emit}onExit(Z,J){if(!xF(this.#$))return()=>{};if(this.#H===!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.#H)return;this.#H=!0,this.#J.count+=1;for(let Z of O$)try{let J=this.#v[Z];if(J)this.#$.on(Z,J)}catch(J){}this.#$.emit=(Z,...J)=>{return this.#G(Z,...J)},this.#$.reallyExit=(Z)=>{return this.#W(Z)}}unload(){if(!this.#H)return;this.#H=!1,O$.forEach((Z)=>{let J=this.#v[Z];if(!J)throw Error("Listener not defined for signal: "+Z);try{this.#$.removeListener(Z,J)}catch(X){}}),this.#$.emit=this.#X,this.#$.reallyExit=this.#Y,this.#J.count-=1}#W(Z){if(!xF(this.#$))return 0;return this.#$.exitCode=Z||0,this.#J.emit("exit",this.#$.exitCode,null),this.#Y.call(this.#$,this.#$.exitCode)}#G(Z,...J){let X=this.#X;if(Z==="exit"&&xF(this.#$)){if(typeof J[0]==="number")this.#$.exitCode=J[0];let $=X.call(this.#$,Z,...J);return this.#J.emit("exit",this.#$.exitCode,null),$}else return X.call(this.#$,Z,...J)}}var jM=globalThis.process,{onExit:Ip,load:EL6,unload:IL6}=Zw1(xF(jM)?new Ep(jM):new kp);var _p=(Z,{cleanup:J,detached:X},{signal:$})=>{if(!J||X)return;let Y=Ip(()=>{Z.kill()});Jw1($,()=>{Y()})};var Sp=({source:Z,sourcePromise:J,boundOptions:X,createNested:$},...Y)=>{let Q=Nq(),{destination:K,destinationStream:W,destinationError:G,from:z,unpipeSignal:v}=Xw1(X,$,Y),{sourceStream:H,sourceError:V}=Yw1(Z,z),{options:q,fileDescriptors:F}=J7.get(Z);return{sourcePromise:J,sourceStream:H,sourceOptions:q,sourceError:V,destination:K,destinationStream:W,destinationError:G,unpipeSignal:v,fileDescriptors:F,startTime:Q}},Xw1=(Z,J,X)=>{try{let{destination:$,pipeOptions:{from:Y,to:Q,unpipeSignal:K}={}}=$w1(Z,J,...X),W=mq($,Q);return{destination:$,destinationStream:W,from:Y,unpipeSignal:K}}catch($){return{destinationError:$}}},$w1=(Z,J,X,...$)=>{if(Array.isArray(X))return{destination:J(hp,Z)(X,...$),pipeOptions:Z};if(typeof X==="string"||X instanceof URL||HD(X)){if(Object.keys(Z).length>0)throw TypeError('Please use .pipe("file", ..., options) or .pipe(execa("file", ..., options)) instead of .pipe(options)("file", ...).');let[Y,Q,K]=cq(X,...$);return{destination:J(hp)(Y,Q,K),pipeOptions:K}}if(J7.has(X)){if(Object.keys(Z).length>0)throw TypeError("Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).");return{destination:X,pipeOptions:$[0]}}throw TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${X}`)},hp=({options:Z})=>({options:{...Z,stdin:"pipe",piped:!0}}),Yw1=(Z,J)=>{try{return{sourceStream:dQ(Z,J)}}catch(X){return{sourceError:X}}};var Ap=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:$,fileDescriptors:Y,sourceOptions:Q,startTime:K})=>{let W=Qw1({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:$});if(W!==void 0)throw LM({error:W,fileDescriptors:Y,sourceOptions:Q,startTime:K})},Qw1=({sourceStream:Z,sourceError:J,destinationStream:X,destinationError:$})=>{if(J!==void 0&&$!==void 0)return $;if($!==void 0)return cM(Z),$;if(J!==void 0)return wM(X),J},LM=({error:Z,fileDescriptors:J,sourceOptions:X,startTime:$})=>sQ({error:Z,command:bp,escapedCommand:bp,fileDescriptors:J,options:X,startTime:$,isSync:!1}),bp="source.pipe(destination)";var mp=async(Z)=>{let[{status:J,reason:X,value:$=X},{status:Y,reason:Q,value:K=Q}]=await Z;if(!K.pipedFrom.includes($))K.pipedFrom.push($);if(Y==="rejected")throw K;if(J==="rejected")throw $;return K};import{finished as Kw1}from"node:stream/promises";var up=(Z,J,X)=>{let $=UF.has(J)?Gw1(Z,J):Ww1(Z,J);return D$(Z,vw1,X.signal),D$(J,Vw1,X.signal),zw1(J),$},Ww1=(Z,J)=>{let X=N$([Z]);return tQ(X,J),UF.set(J,X),X},Gw1=(Z,J)=>{let X=UF.get(J);return X.add(Z),X},zw1=async(Z)=>{try{await Kw1(Z,{cleanup:!0,readable:!1,writable:!0})}catch{}UF.delete(Z)},UF=new WeakMap,vw1=2,Vw1=1;import{aborted as Hw1}from"node:util";var lp=(Z,J)=>Z===void 0?[]:[qw1(Z,J)],qw1=async(Z,{sourceStream:J,mergedStream:X,fileDescriptors:$,sourceOptions:Y,startTime:Q})=>{await Hw1(Z,J),await X.remove(J);let K=Error("Pipe canceled by `unpipeSignal` option.");throw LM({error:K,fileDescriptors:$,sourceOptions:Y,startTime:Q})};var jF=(Z,...J)=>{if(c8(J[0]))return jF.bind(void 0,{...Z,boundOptions:{...Z.boundOptions,...J[0]}});let{destination:X,...$}=Sp(Z,...J),Y=Fw1({...$,destination:X});return Y.pipe=jF.bind(void 0,{...Z,source:X,sourcePromise:Y,boundOptions:{}}),Y},Fw1=async({sourcePromise:Z,sourceStream:J,sourceOptions:X,sourceError:$,destination:Y,destinationStream:Q,destinationError:K,unpipeSignal:W,fileDescriptors:G,startTime:z})=>{let v=ww1(Z,Y);Ap({sourceStream:J,sourceError:$,destinationStream:Q,destinationError:K,fileDescriptors:G,sourceOptions:X,startTime:z});let H=new AbortController;try{let V=up(J,Q,H);return await Promise.race([mp(v),...lp(W,{sourceStream:J,mergedStream:V,sourceOptions:X,fileDescriptors:G,startTime:z})])}finally{H.abort()}},ww1=(Z,J)=>Promise.allSettled([Z,J]);import{setImmediate as Dw1}from"node:timers/promises";import{on as cw1}from"node:events";import{getDefaultHighWaterMark as xw1}from"node:stream";var BF=({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:$,encoding:Y,preserveNewlines:Q})=>{let K=new AbortController;return Uw1(J,K),pp({stream:Z,controller:K,binary:X,shouldEncode:!Z.readableObjectMode&&$,encoding:Y,shouldSplit:!Z.readableObjectMode,preserveNewlines:Q})},Uw1=async(Z,J)=>{try{await Z}catch{}finally{J.abort()}},DM=({stream:Z,onStreamEnd:J,lines:X,encoding:$,stripFinalNewline:Y,allMixed:Q})=>{let K=new AbortController;jw1(J,K,Z);let W=Z.readableObjectMode&&!Q;return pp({stream:Z,controller:K,binary:$==="buffer",shouldEncode:!W,encoding:$,shouldSplit:!W&&X,preserveNewlines:!Y})},jw1=async(Z,J,X)=>{try{await Z}catch{X.destroy()}finally{J.abort()}},pp=({stream:Z,controller:J,binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K})=>{let W=cw1(Z,"data",{signal:J.signal,highWaterMark:yp,highWatermark:yp});return Bw1({onStdoutChunk:W,controller:J,binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K})},MM=xw1(!0),yp=MM,Bw1=async function*({onStdoutChunk:Z,controller:J,binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K}){let W=Lw1({binary:X,shouldEncode:$,encoding:Y,shouldSplit:Q,preserveNewlines:K});try{for await(let[G]of Z)yield*P$(G,W,0)}catch(G){if(!J.signal.aborted)throw G}finally{yield*eW(W)}},Lw1=({binary:Z,shouldEncode:J,encoding:X,shouldSplit:$,preserveNewlines:Y})=>[VF(Z,X,!J),vF(Z,Y,!$,{})].filter(Boolean);var ip=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:$,buffer:Y,maxBuffer:Q,lines:K,allMixed:W,stripFinalNewline:G,verboseInfo:z,streamInfo:v})=>{let H=Mw1({stream:Z,onStreamEnd:J,fdNumber:X,encoding:$,allMixed:W,verboseInfo:z,streamInfo:v});if(!Y){await Promise.all([Rw1(Z),H]);return}let V=$M(G,X),q=DM({stream:Z,onStreamEnd:J,lines:K,encoding:$,stripFinalNewline:V,allMixed:W}),[F]=await Promise.all([Pw1({stream:Z,iterable:q,fdNumber:X,encoding:$,maxBuffer:Q,lines:K}),H]);return F},Mw1=async({stream:Z,onStreamEnd:J,fdNumber:X,encoding:$,allMixed:Y,verboseInfo:Q,streamInfo:{fileDescriptors:K}})=>{if(!FF({stdioItems:K[X]?.stdioItems,encoding:$,verboseInfo:Q,fdNumber:X}))return;let W=DM({stream:Z,onStreamEnd:J,lines:!0,encoding:$,stripFinalNewline:!0,allMixed:Y});await ry(W,Z,X,Q)},Rw1=async(Z)=>{if(await Dw1(),Z.readableFlowing===null)Z.resume()},Pw1=async({stream:Z,stream:{readableObjectMode:J},iterable:X,fdNumber:$,encoding:Y,maxBuffer:Q,lines:K})=>{try{if(J||K)return await ZF(X,{maxBuffer:Q});if(Y==="buffer")return new Uint8Array(await JF(X,{maxBuffer:Q}));return await $F(X,{maxBuffer:Q})}catch(W){return gp(rl({error:W,stream:Z,readableObjectMode:J,lines:K,encoding:Y,fdNumber:$}))}},RM=async(Z)=>{try{return await Z}catch(J){return gp(J)}},gp=({bufferedData:Z})=>qm(Z)?new Uint8Array(Z):Z;import{finished as Nw1}from"node:stream/promises";var $G=async(Z,J,X,{isSameDirection:$,stopOnExit:Y=!1}={})=>{let Q=Ow1(Z,X),K=new AbortController;try{await Promise.race([...Y?[X.exitPromise]:[],Nw1(Z,{cleanup:!0,signal:K.signal})])}catch(W){if(!Q.stdinCleanedUp)fw1(W,J,X,$)}finally{K.abort()}},Ow1=(Z,{originalStreams:[J],subprocess:X})=>{let $={stdinCleanedUp:!1};if(Z===J)Tw1(Z,X,$);return $},Tw1=(Z,J,X)=>{let{_destroy:$}=Z;Z._destroy=(...Y)=>{Cw1(J,X),$.call(Z,...Y)}},Cw1=({exitCode:Z,signalCode:J},X)=>{if(Z!==null||J!==null)X.stdinCleanedUp=!0},fw1=(Z,J,X,$)=>{if(!kw1(Z,J,X,$))throw Z},kw1=(Z,J,X,$=!0)=>{if(X.propagating)return dp(Z)||LF(Z);return X.propagating=!0,PM(X,J)===$?dp(Z):LF(Z)},PM=({fileDescriptors:Z},J)=>J!=="all"&&Z[J].direction==="input",LF=(Z)=>Z?.code==="ERR_STREAM_PREMATURE_CLOSE",dp=(Z)=>Z?.code==="EPIPE";var ap=({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>Z.stdio.map((G,z)=>NM({stream:G,fdNumber:z,encoding:J,buffer:X[z],maxBuffer:$[z],lines:Y[z],allMixed:!1,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})),NM=async({stream:Z,fdNumber:J,encoding:X,buffer:$,maxBuffer:Y,lines:Q,allMixed:K,stripFinalNewline:W,verboseInfo:G,streamInfo:z})=>{if(!Z)return;let v=$G(Z,J,z);if(PM(z,J)){await v;return}let[H]=await Promise.all([ip({stream:Z,onStreamEnd:v,fdNumber:J,encoding:X,buffer:$,maxBuffer:Y,lines:Q,allMixed:K,stripFinalNewline:W,verboseInfo:G,streamInfo:z}),v]);return H};var np=({stdout:Z,stderr:J},{all:X})=>X&&(Z||J)?N$([Z,J].filter(Boolean)):void 0,sp=({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:Q,verboseInfo:K,streamInfo:W})=>NM({...Ew1(Z,X),fdNumber:"all",encoding:J,maxBuffer:$[1]+$[2],lines:Y[1]||Y[2],allMixed:Iw1(Z),stripFinalNewline:Q,verboseInfo:K,streamInfo:W}),Ew1=({stdout:Z,stderr:J,all:X},[,$,Y])=>{let Q=$||Y;if(!Q)return{stream:X,buffer:Q};if(!$)return{stream:J,buffer:Q};if(!Y)return{stream:Z,buffer:Q};return{stream:X,buffer:Q}},Iw1=({all:Z,stdout:J,stderr:X})=>Z&&J&&X&&J.readableObjectMode!==X.readableObjectMode;import{once as _w1}from"node:events";var op=(Z)=>lQ(Z,"ipc"),rp=(Z,J)=>{let X=Pq(Z);t9({type:"ipc",verboseMessage:X,fdNumber:"ipc",verboseInfo:J})};var tp=async({subprocess:Z,buffer:J,maxBuffer:X,ipc:$,ipcOutput:Y,verboseInfo:Q})=>{if(!$)return Y;let K=op(Q),W=o7(J,"ipc"),G=o7(X,"ipc");for await(let z of HM({anyProcess:Z,channel:Z.channel,isSubprocess:!1,ipc:$,shouldAwait:!1,reference:!0})){if(W)tl(Z,Y,G),Y.push(z);if(K)rp(z,Q)}return Y},ep=async(Z,J)=>{return await Promise.allSettled([Z]),J};var Zi=async({subprocess:Z,options:{encoding:J,buffer:X,maxBuffer:$,lines:Y,timeoutDuration:Q,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,stripFinalNewline:z,ipc:v,ipcInput:H},context:V,verboseInfo:q,fileDescriptors:F,originalStreams:w,onInternalError:c,controller:x})=>{let j=Xp(Z,V),B={originalStreams:w,fileDescriptors:F,subprocess:Z,exitPromise:j,propagating:!1},L=ap({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:z,verboseInfo:q,streamInfo:B}),R=sp({subprocess:Z,encoding:J,buffer:X,maxBuffer:$,lines:Y,stripFinalNewline:z,verboseInfo:q,streamInfo:B}),M=[],P=tp({subprocess:Z,buffer:X,maxBuffer:$,ipc:v,ipcOutput:M,verboseInfo:q}),N=hw1(w,Z,B),O=Sw1(F,B);try{return await Promise.race([Promise.all([{},Yp(j),Promise.all(L),R,P,Cl(Z,H),...N,...O]),c,bw1(Z,x),...Rl(Z,Q,V,x),...gu({subprocess:Z,cancelSignal:K,gracefulCancel:W,context:V,controller:x}),...Dl({subprocess:Z,cancelSignal:K,gracefulCancel:W,forceKillAfterDelay:G,context:V,controller:x})])}catch(k){return V.terminationReason??="other",Promise.all([{error:k},j,Promise.all(L.map((E)=>RM(E))),RM(R),ep(P,M),Promise.allSettled(N),Promise.allSettled(O)])}},hw1=(Z,J,X)=>Z.map(($,Y)=>$===J.stdio[Y]?void 0:$G($,Y,X)),Sw1=(Z,J)=>Z.flatMap(({stdioItems:X},$)=>X.filter(({value:Y,stream:Q=Y})=>q9(Q,{checkOpen:!1})&&!V9(Q)).map(({type:Y,value:Q,stream:K=Q})=>$G(K,$,J,{isSameDirection:z4.has(Y),stopOnExit:Y==="native"}))),bw1=async(Z,{signal:J})=>{let[X]=await _w1(Z,"error",{signal:J});throw X};var Ji=()=>({readableDestroy:new WeakMap,writableFinal:new WeakMap,writableDestroy:new WeakMap}),YG=(Z,J,X)=>{let $=Z[X];if(!$.has(J))$.set(J,[]);let Y=$.get(J),Q=Z7();return Y.push(Q),{resolve:Q.resolve.bind(Q),promises:Y}},eQ=async({resolve:Z,promises:J},X)=>{Z();let[$]=await Promise.race([Promise.allSettled([!0,X]),Promise.all([!1,...J])]);return!$};import{Readable as Aw1}from"node:stream";import{callbackify as mw1}from"node:util";import{finished as Xi}from"node:stream/promises";var OM=async(Z)=>{if(Z===void 0)return;try{await TM(Z)}catch{}},$i=async(Z)=>{if(Z===void 0)return;try{await CM(Z)}catch{}},TM=async(Z)=>{await Xi(Z,{cleanup:!0,readable:!1,writable:!0})},CM=async(Z)=>{await Xi(Z,{cleanup:!0,readable:!0,writable:!1})},DF=async(Z,J)=>{if(await Z,J)throw J},MF=(Z,J,X)=>{if(X&&!LF(X))Z.destroy(X);else if(J)Z.destroy()};var Yi=({subprocess:Z,concurrentStreams:J,encoding:X},{from:$,binary:Y=!0,preserveNewlines:Q=!0}={})=>{let K=Y||E5.has(X),{subprocessStdout:W,waitReadableDestroy:G}=fM(Z,$,J),{readableEncoding:z,readableObjectMode:v,readableHighWaterMark:H}=kM(W,K),{read:V,onStdoutDataDone:q}=EM({subprocessStdout:W,subprocess:Z,binary:K,encoding:X,preserveNewlines:Q}),F=new Aw1({read:V,destroy:mw1(_M.bind(void 0,{subprocessStdout:W,subprocess:Z,waitReadableDestroy:G})),highWaterMark:H,objectMode:v,encoding:z});return IM({subprocessStdout:W,onStdoutDataDone:q,readable:F,subprocess:Z}),F},fM=(Z,J,X)=>{let $=dQ(Z,J),Y=YG(X,$,"readableDestroy");return{subprocessStdout:$,waitReadableDestroy:Y}},kM=({readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X},$)=>$?{readableEncoding:Z,readableObjectMode:J,readableHighWaterMark:X}:{readableEncoding:Z,readableObjectMode:!0,readableHighWaterMark:MM},EM=({subprocessStdout:Z,subprocess:J,binary:X,encoding:$,preserveNewlines:Y})=>{let Q=Z7(),K=BF({subprocessStdout:Z,subprocess:J,binary:X,shouldEncode:!X,encoding:$,preserveNewlines:Y});return{read(){uw1(this,K,Q)},onStdoutDataDone:Q}},uw1=async(Z,J,X)=>{try{let{value:$,done:Y}=await J.next();if(Y)X.resolve();else Z.push($)}catch{}},IM=async({subprocessStdout:Z,onStdoutDataDone:J,readable:X,subprocess:$,subprocessStdin:Y})=>{try{if(await CM(Z),await $,await OM(Y),await J,X.readable)X.push(null)}catch(Q){await OM(Y),Qi(X,Q)}},_M=async({subprocessStdout:Z,subprocess:J,waitReadableDestroy:X},$)=>{if(await eQ(X,J))Qi(Z,$),await DF(J,$)},Qi=(Z,J)=>{MF(Z,Z.readable,J)};import{Writable as lw1}from"node:stream";import{callbackify as Ki}from"node:util";var Wi=({subprocess:Z,concurrentStreams:J},{to:X}={})=>{let{subprocessStdin:$,waitWritableFinal:Y,waitWritableDestroy:Q}=hM(Z,X,J),K=new lw1({...SM($,Z,Y),destroy:Ki(AM.bind(void 0,{subprocessStdin:$,subprocess:Z,waitWritableFinal:Y,waitWritableDestroy:Q})),highWaterMark:$.writableHighWaterMark,objectMode:$.writableObjectMode});return bM($,K),K},hM=(Z,J,X)=>{let $=mq(Z,J),Y=YG(X,$,"writableFinal"),Q=YG(X,$,"writableDestroy");return{subprocessStdin:$,waitWritableFinal:Y,waitWritableDestroy:Q}},SM=(Z,J,X)=>({write:yw1.bind(void 0,Z),final:Ki(pw1.bind(void 0,Z,J,X))}),yw1=(Z,J,X,$)=>{if(Z.write(J,X))$();else Z.once("drain",$)},pw1=async(Z,J,X)=>{if(await eQ(X,J)){if(Z.writable)Z.end();await J}},bM=async(Z,J,X)=>{try{if(await TM(Z),J.writable)J.end()}catch($){await $i(X),Gi(J,$)}},AM=async({subprocessStdin:Z,subprocess:J,waitWritableFinal:X,waitWritableDestroy:$},Y)=>{if(await eQ(X,J),await eQ($,J))Gi(Z,Y),await DF(J,Y)},Gi=(Z,J)=>{MF(Z,Z.writable,J)};import{Duplex as iw1}from"node:stream";import{callbackify as gw1}from"node:util";var zi=({subprocess:Z,concurrentStreams:J,encoding:X},{from:$,to:Y,binary:Q=!0,preserveNewlines:K=!0}={})=>{let W=Q||E5.has(X),{subprocessStdout:G,waitReadableDestroy:z}=fM(Z,$,J),{subprocessStdin:v,waitWritableFinal:H,waitWritableDestroy:V}=hM(Z,Y,J),{readableEncoding:q,readableObjectMode:F,readableHighWaterMark:w}=kM(G,W),{read:c,onStdoutDataDone:x}=EM({subprocessStdout:G,subprocess:Z,binary:W,encoding:X,preserveNewlines:K}),j=new iw1({read:c,...SM(v,Z,H),destroy:gw1(dw1.bind(void 0,{subprocessStdout:G,subprocessStdin:v,subprocess:Z,waitReadableDestroy:z,waitWritableFinal:H,waitWritableDestroy:V})),readableHighWaterMark:w,writableHighWaterMark:v.writableHighWaterMark,readableObjectMode:F,writableObjectMode:v.writableObjectMode,encoding:q});return IM({subprocessStdout:G,onStdoutDataDone:x,readable:j,subprocess:Z,subprocessStdin:v}),bM(v,j,G),j},dw1=async({subprocessStdout:Z,subprocessStdin:J,subprocess:X,waitReadableDestroy:$,waitWritableFinal:Y,waitWritableDestroy:Q},K)=>{await Promise.all([_M({subprocessStdout:Z,subprocess:X,waitReadableDestroy:$},K),AM({subprocessStdin:J,subprocess:X,waitWritableFinal:Y,waitWritableDestroy:Q},K)])};var mM=(Z,J,{from:X,binary:$=!1,preserveNewlines:Y=!1}={})=>{let Q=$||E5.has(J),K=dQ(Z,X),W=BF({subprocessStdout:K,subprocess:Z,binary:Q,shouldEncode:!0,encoding:J,preserveNewlines:Y});return aw1(W,K,Z)},aw1=async function*(Z,J,X){try{yield*Z}finally{if(J.readable)J.destroy();await X}};var vi=(Z,{encoding:J})=>{let X=Ji();Z.readable=Yi.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.writable=Wi.bind(void 0,{subprocess:Z,concurrentStreams:X}),Z.duplex=zi.bind(void 0,{subprocess:Z,concurrentStreams:X,encoding:J}),Z.iterable=mM.bind(void 0,Z,J),Z[Symbol.asyncIterator]=mM.bind(void 0,Z,J,{})};var Vi=(Z,J)=>{for(let[X,$]of sw1){let Y=$.value.bind(J);Reflect.defineProperty(Z,X,{...$,value:Y})}},nw1=(async()=>{})().constructor.prototype,sw1=["then","catch","finally"].map((Z)=>[Z,Reflect.getOwnPropertyDescriptor(nw1,Z)]);var Hi=(Z,J,X,$)=>{let{file:Y,commandArguments:Q,command:K,escapedCommand:W,startTime:G,verboseInfo:z,options:v,fileDescriptors:H}=tw1(Z,J,X),{subprocess:V,promise:q}=Zc1({file:Y,commandArguments:Q,options:v,startTime:G,verboseInfo:z,command:K,escapedCommand:W,fileDescriptors:H});return V.pipe=jF.bind(void 0,{source:V,sourcePromise:q,boundOptions:{},createNested:$}),Vi(V,q),J7.set(V,{options:v,fileDescriptors:H}),V},tw1=(Z,J,X)=>{let{command:$,escapedCommand:Y,startTime:Q,verboseInfo:K}=Oq(Z,J,X),{file:W,commandArguments:G,options:z}=oq(Z,J,X),v=ew1(z),H=jp(v,K);return{file:W,commandArguments:G,command:$,escapedCommand:Y,startTime:Q,verboseInfo:K,options:v,fileDescriptors:H}},ew1=({timeout:Z,signal:J,...X})=>{if(J!==void 0)throw TypeError('The "signal" option has been renamed to "cancelSignal" instead.');return{...X,timeoutDuration:Z}},Zc1=({file:Z,commandArguments:J,options:X,startTime:$,verboseInfo:Y,command:Q,escapedCommand:K,fileDescriptors:W})=>{let G;try{G=rw1(Z,J,X)}catch(F){return wp({error:F,command:Q,escapedCommand:K,fileDescriptors:W,options:X,startTime:$,verboseInfo:Y})}let z=new AbortController;ow1(Number.POSITIVE_INFINITY,z.signal);let v=[...G.stdio];Cp(G,W,z),_p(G,X,z);let H={},V=Z7();G.kill=pu.bind(void 0,{kill:G.kill.bind(G),options:X,onInternalError:V,context:H,controller:z}),G.all=np(G,X),vi(G,X),Hp(G,X);let q=Jc1({subprocess:G,options:X,startTime:$,verboseInfo:Y,fileDescriptors:W,originalStreams:v,command:Q,escapedCommand:K,context:H,onInternalError:V,controller:z});return{subprocess:G,promise:q}},Jc1=async({subprocess:Z,options:J,startTime:X,verboseInfo:$,fileDescriptors:Y,originalStreams:Q,command:K,escapedCommand:W,context:G,onInternalError:z,controller:v})=>{let[H,[V,q],F,w,c]=await Zi({subprocess:Z,options:J,context:G,verboseInfo:$,fileDescriptors:Y,originalStreams:Q,onInternalError:z,controller:v});v.abort(),z.resolve();let x=F.map((L,R)=>e7(L,J,R)),j=e7(w,J,"all"),B=Xc1({errorInfo:H,exitCode:V,signal:q,stdio:x,all:j,ipcOutput:c,context:G,options:J,command:K,escapedCommand:W,startTime:X});return oQ(B,$,J)},Xc1=({errorInfo:Z,exitCode:J,signal:X,stdio:$,all:Y,ipcOutput:Q,context:K,options:W,command:G,escapedCommand:z,startTime:v})=>("error"in Z)?tW({error:Z.error,command:G,escapedCommand:z,timedOut:K.terminationReason==="timeout",isCanceled:K.terminationReason==="cancel"||K.terminationReason==="gracefulCancel",isGracefullyCanceled:K.terminationReason==="gracefulCancel",isMaxBuffer:Z.error instanceof r7,isForcefullyTerminated:K.isForcefullyTerminated,exitCode:J,signal:X,stdio:$,all:Y,ipcOutput:Q,options:W,startTime:v,isSync:!1}):QF({command:G,escapedCommand:z,stdio:$,all:Y,ipcOutput:Q,options:W,startTime:v});var RF=(Z,J)=>{let X=Object.fromEntries(Object.entries(J).map(([$,Y])=>[$,$c1($,Z[$],Y)]));return{...Z,...X}},$c1=(Z,J,X)=>{if(Yc1.has(Z)&&c8(J)&&c8(X))return{...J,...X};return X},Yc1=new Set(["env",...UD]);var EJ=(Z,J,X,$)=>{let Y=(K,W,G)=>EJ(K,W,X,G),Q=(...K)=>Qc1({mapArguments:Z,deepOptions:X,boundOptions:J,setBoundExeca:$,createNested:Y},...K);if($!==void 0)$(Q,Y,J);return Q},Qc1=({mapArguments:Z,deepOptions:J={},boundOptions:X={},setBoundExeca:$,createNested:Y},Q,...K)=>{if(c8(Q))return Y(Z,RF(X,Q),$);let{file:W,commandArguments:G,options:z,isSync:v}=Kc1({mapArguments:Z,firstArgument:Q,nextArguments:K,deepOptions:J,boundOptions:X});return v?Kp(W,G,z):Hi(W,G,z,Y)},Kc1=({mapArguments:Z,firstArgument:J,nextArguments:X,deepOptions:$,boundOptions:Y})=>{let Q=jm(J)?Bm(J,X):[J,...X],[K,W,G]=cq(...Q),z=RF(RF($,Y),G),{file:v=K,commandArguments:H=W,options:V=z,isSync:q=!1}=Z({file:K,commandArguments:W,options:z});return{file:v,commandArguments:H,options:V,isSync:q}};var qi=({file:Z,commandArguments:J})=>wi(Z,J),Fi=({file:Z,commandArguments:J})=>({...wi(Z,J),isSync:!0}),wi=(Z,J)=>{if(J.length>0)throw TypeError(`The command and its arguments must be passed as a single string: ${Z} ${J}.`);let[X,...$]=Wc1(Z);return{file:X,commandArguments:$}},Wc1=(Z)=>{if(typeof Z!=="string")throw TypeError(`The command must be a string: ${String(Z)}.`);let J=Z.trim();if(J==="")return[];let X=[];for(let $ of J.split(Gc1)){let Y=X.at(-1);if(Y&&Y.endsWith("\\"))X[X.length-1]=`${Y.slice(0,-1)} ${$}`;else X.push($)}return X},Gc1=/ +/g;var ci=(Z,J,X)=>{Z.sync=J(zc1,X),Z.s=Z.sync},xi=({options:Z})=>Ui(Z),zc1=({options:Z})=>({...Ui(Z),isSync:!0}),Ui=(Z)=>({options:{...vc1(Z),...Z}}),vc1=({input:Z,inputFile:J,stdio:X})=>Z===void 0&&J===void 0&&X===void 0?{stdin:"inherit"}:{},ji={preferLocal:!0};var Bi=EJ(()=>({})),LR6=EJ(()=>({isSync:!0})),DR6=EJ(qi),MR6=EJ(Fi),RR6=EJ(Nl),PR6=EJ(xi,{},ji,ci),{sendMessage:NR6,getOneMessage:OR6,getEachMessage:TR6,getCancelSignal:CR6}=qp();var ui=t(Ei(),1);var KG=(Z)=>{if(typeof Z!=="string")throw TypeError("invalid pattern");if(Z.length>65536)throw TypeError("pattern is too long")};var Uc1={"[: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]},WG=(Z)=>Z.replace(/[[\]\\-]/g,"\\$&"),jc1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ii=(Z)=>Z.join(""),_i=(Z,J)=>{let X=J;if(Z.charAt(X)!=="[")throw Error("not in a brace expression");let $=[],Y=[],Q=X+1,K=!1,W=!1,G=!1,z=!1,v=X,H="";Z:while(Q<Z.length){let w=Z.charAt(Q);if((w==="!"||w==="^")&&Q===X+1){z=!0,Q++;continue}if(w==="]"&&K&&!G){v=Q+1;break}if(K=!0,w==="\\"){if(!G){G=!0,Q++;continue}}if(w==="["&&!G){for(let[c,[x,j,B]]of Object.entries(Uc1))if(Z.startsWith(c,Q)){if(H)return["$.",!1,Z.length-X,!0];if(Q+=c.length,B)Y.push(x);else $.push(x);W=W||j;continue Z}}if(G=!1,H){if(w>H)$.push(WG(H)+"-"+WG(w));else if(w===H)$.push(WG(w));H="",Q++;continue}if(Z.startsWith("-]",Q+1)){$.push(WG(w+"-")),Q+=2;continue}if(Z.startsWith("-",Q+1)){H=w,Q+=2;continue}$.push(WG(w)),Q++}if(v<Q)return["",!1,0,!1];if(!$.length&&!Y.length)return["$.",!1,Z.length-X,!0];if(Y.length===0&&$.length===1&&/^\\?.$/.test($[0])&&!z){let w=$[0].length===2?$[0].slice(-1):$[0];return[jc1(w),!1,v-X,!1]}let V="["+(z?"^":"")+Ii($)+"]",q="["+(z?"":"^")+Ii(Y)+"]";return[$.length&&Y.length?"("+V+"|"+q+")":$.length?V:q,W,v-X,!0]};var F9=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/\[([^\/\\])\]/g,"$1"):Z.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")};var Bc1=new Set(["!","?","+","*","@"]),hi=(Z)=>Bc1.has(Z),Lc1="(?!(?:^|/)\\.\\.?(?:$|/))",PF="(?!\\.)",Dc1=new Set(["[","."]),Mc1=new Set(["..","."]),Rc1=new Set("().*{}+?[]^$\\!"),Pc1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),pM="[^/]",Si=pM+"*?",bi=pM+"+?";class Z6{type;#Z;#J;#$=!1;#X=[];#Y;#v;#H;#W=!1;#G;#z;#V=!1;constructor(Z,J,X={}){if(this.type=Z,Z)this.#J=!0;if(this.#Y=J,this.#Z=this.#Y?this.#Y.#Z:this,this.#G=this.#Z===this?X:this.#Z.#G,this.#H=this.#Z===this?[]:this.#Z.#H,Z==="!"&&!this.#Z.#W)this.#H.push(this);this.#v=this.#Y?this.#Y.#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.#z!==void 0)return this.#z;if(!this.type)return this.#z=this.#X.map((Z)=>String(Z)).join("");else return this.#z=this.type+"("+this.#X.map((Z)=>String(Z)).join("|")+")"}#Q(){if(this!==this.#Z)throw Error("should only call on root");if(this.#W)return this;this.toString(),this.#W=!0;let Z;while(Z=this.#H.pop()){if(Z.type!=="!")continue;let J=Z,X=J.#Y;while(X){for(let $=J.#v+1;!X.type&&$<X.#X.length;$++)for(let Y of Z.#X){if(typeof Y==="string")throw Error("string part in extglob AST??");Y.copyIn(X.#X[$])}J=X,X=J.#Y}}return this}push(...Z){for(let J of Z){if(J==="")continue;if(typeof J!=="string"&&!(J instanceof Z6&&J.#Y===this))throw 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.#Y?.type==="!"))Z.push({});return Z}isStart(){if(this.#Z===this)return!0;if(!this.#Y?.isStart())return!1;if(this.#v===0)return!0;let Z=this.#Y;for(let J=0;J<this.#v;J++){let X=Z.#X[J];if(!(X instanceof Z6&&X.type==="!"))return!1}return!0}isEnd(){if(this.#Z===this)return!0;if(this.#Y?.type==="!")return!0;if(!this.#Y?.isEnd())return!1;if(!this.type)return this.#Y?.isEnd();let Z=this.#Y?this.#Y.#X.length:0;return this.#v===Z-1}copyIn(Z){if(typeof Z==="string")this.push(Z);else this.push(Z.clone(this))}clone(Z){let J=new Z6(this.type,Z);for(let X of this.#X)J.copyIn(X);return J}static#F(Z,J,X,$){let Y=!1,Q=!1,K=-1,W=!1;if(J.type===null){let V=X,q="";while(V<Z.length){let F=Z.charAt(V++);if(Y||F==="\\"){Y=!Y,q+=F;continue}if(Q){if(V===K+1){if(F==="^"||F==="!")W=!0}else if(F==="]"&&!(V===K+2&&W))Q=!1;q+=F;continue}else if(F==="["){Q=!0,K=V,W=!1,q+=F;continue}if(!$.noext&&hi(F)&&Z.charAt(V)==="("){J.push(q),q="";let w=new Z6(F,J);V=Z6.#F(Z,w,V,$),J.push(w);continue}q+=F}return J.push(q),V}let G=X+1,z=new Z6(null,J),v=[],H="";while(G<Z.length){let V=Z.charAt(G++);if(Y||V==="\\"){Y=!Y,H+=V;continue}if(Q){if(G===K+1){if(V==="^"||V==="!")W=!0}else if(V==="]"&&!(G===K+2&&W))Q=!1;H+=V;continue}else if(V==="["){Q=!0,K=G,W=!1,H+=V;continue}if(hi(V)&&Z.charAt(G)==="("){z.push(H),H="";let q=new Z6(V,z);z.push(q),G=Z6.#F(Z,q,G,$);continue}if(V==="|"){z.push(H),H="",v.push(z),z=new Z6(null,J);continue}if(V===")"){if(H===""&&J.#X.length===0)J.#V=!0;return z.push(H),H="",J.push(...v,z),G}H+=V}return J.type=null,J.#J=void 0,J.#X=[Z.substring(X-1)],G}static fromGlob(Z,J={}){let X=new Z6(null,void 0,J);return Z6.#F(Z,X,0,J),X}toMMPattern(){if(this!==this.#Z)return this.#Z.toMMPattern();let Z=this.toString(),[J,X,$,Y]=this.toRegExpSource();if(!($||this.#J||this.#G.nocase&&!this.#G.nocaseMagicOnly&&Z.toUpperCase()!==Z.toLowerCase()))return X;let K=(this.#G.nocase?"i":"")+(Y?"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((V)=>{let[q,F,w,c]=typeof V==="string"?Z6.#w(V,this.#J,W):V.toRegExpSource(Z);return this.#J=this.#J||w,this.#$=this.#$||c,q}).join(""),z="";if(this.isStart()){if(typeof this.#X[0]==="string"){if(!(this.#X.length===1&&Mc1.has(this.#X[0]))){let q=Dc1,F=J&&q.has(G.charAt(0))||G.startsWith("\\.")&&q.has(G.charAt(2))||G.startsWith("\\.\\.")&&q.has(G.charAt(4)),w=!J&&!Z&&q.has(G.charAt(0));z=F?Lc1:w?PF:""}}}let v="";if(this.isEnd()&&this.#Z.#W&&this.#Y?.type==="!")v="(?:$|\\/)";return[z+G+v,F9(G),this.#J=!!this.#J,this.#$]}let X=this.type==="*"||this.type==="+",$=this.type==="!"?"(?:(?!(?:":"(?:",Y=this.#c(J);if(this.isStart()&&this.isEnd()&&!Y&&this.type!=="!"){let W=this.toString();return this.#X=[W],this.type=null,this.#J=void 0,[W,F9(this.toString()),!1,!1]}let Q=!X||Z||J||!PF?"":this.#c(!0);if(Q===Y)Q="";if(Q)Y=`(?:${Y})(?:${Q})*?`;let K="";if(this.type==="!"&&this.#V)K=(this.isStart()&&!J?PF:"")+bi;else{let W=this.type==="!"?"))"+(this.isStart()&&!J&&!Z?PF:"")+Si+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&Q?")":this.type==="*"&&Q?")?":`)${this.type}`;K=$+Y+W}return[K,F9(Y),this.#J=!!this.#J,this.#$]}#c(Z){return this.#X.map((J)=>{if(typeof J==="string")throw Error("string type in extglob ast??");let[X,$,Y,Q]=J.toRegExpSource(Z);return this.#$=this.#$||Q,X}).filter((J)=>!(this.isStart()&&this.isEnd())||!!J).join("|")}static#w(Z,J,X=!1){let $=!1,Y="",Q=!1;for(let K=0;K<Z.length;K++){let W=Z.charAt(K);if($){$=!1,Y+=(Rc1.has(W)?"\\":"")+W;continue}if(W==="\\"){if(K===Z.length-1)Y+="\\\\";else $=!0;continue}if(W==="["){let[G,z,v,H]=_i(Z,K);if(v){Y+=G,Q=Q||z,K+=v-1,J=J||H;continue}}if(W==="*"){if(X&&Z==="*")Y+=bi;else Y+=Si;J=!0;continue}if(W==="?"){Y+=pM,J=!0;continue}Y+=Pc1(W)}return[Y,F9(Z),!!J,Q]}}var Z3=(Z,{windowsPathsNoEscape:J=!1}={})=>{return J?Z.replace(/[?*()[\]]/g,"[$&]"):Z.replace(/[?*()[\]\\]/g,"\\$&")};var h6=(Z,J,X={})=>{if(KG(J),!X.nocomment&&J.charAt(0)==="#")return!1;return new V4(J,X).match(Z)},Nc1=/^\*+([^+@!?\*\[\(]*)$/,Oc1=(Z)=>(J)=>!J.startsWith(".")&&J.endsWith(Z),Tc1=(Z)=>(J)=>J.endsWith(Z),Cc1=(Z)=>{return Z=Z.toLowerCase(),(J)=>!J.startsWith(".")&&J.toLowerCase().endsWith(Z)},fc1=(Z)=>{return Z=Z.toLowerCase(),(J)=>J.toLowerCase().endsWith(Z)},kc1=/^\*+\.\*+$/,Ec1=(Z)=>!Z.startsWith(".")&&Z.includes("."),Ic1=(Z)=>Z!=="."&&Z!==".."&&Z.includes("."),_c1=/^\.\*+$/,hc1=(Z)=>Z!=="."&&Z!==".."&&Z.startsWith("."),Sc1=/^\*+$/,bc1=(Z)=>Z.length!==0&&!Z.startsWith("."),Ac1=(Z)=>Z.length!==0&&Z!=="."&&Z!=="..",mc1=/^\?+([^+@!?\*\[\(]*)?$/,uc1=([Z,J=""])=>{let X=li([Z]);if(!J)return X;return J=J.toLowerCase(),($)=>X($)&&$.toLowerCase().endsWith(J)},lc1=([Z,J=""])=>{let X=yi([Z]);if(!J)return X;return J=J.toLowerCase(),($)=>X($)&&$.toLowerCase().endsWith(J)},yc1=([Z,J=""])=>{let X=yi([Z]);return!J?X:($)=>X($)&&$.endsWith(J)},pc1=([Z,J=""])=>{let X=li([Z]);return!J?X:($)=>X($)&&$.endsWith(J)},li=([Z])=>{let J=Z.length;return(X)=>X.length===J&&!X.startsWith(".")},yi=([Z])=>{let J=Z.length;return(X)=>X.length===J&&X!=="."&&X!==".."},pi=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Ai={win32:{sep:"\\"},posix:{sep:"/"}},ic1=pi==="win32"?Ai.win32.sep:Ai.posix.sep;h6.sep=ic1;var J6=Symbol("globstar **");h6.GLOBSTAR=J6;var gc1="[^/]",dc1=gc1+"*?",ac1="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",nc1="(?:(?!(?:\\/|^)\\.).)*?",sc1=(Z,J={})=>(X)=>h6(X,Z,J);h6.filter=sc1;var v4=(Z,J={})=>Object.assign({},Z,J),oc1=(Z)=>{if(!Z||typeof Z!=="object"||!Object.keys(Z).length)return h6;let J=h6;return Object.assign(($,Y,Q={})=>J($,Y,v4(Z,Q)),{Minimatch:class extends J.Minimatch{constructor(Y,Q={}){super(Y,v4(Z,Q))}static defaults(Y){return J.defaults(v4(Z,Y)).Minimatch}},AST:class extends J.AST{constructor(Y,Q,K={}){super(Y,Q,v4(Z,K))}static fromGlob(Y,Q={}){return J.AST.fromGlob(Y,v4(Z,Q))}},unescape:($,Y={})=>J.unescape($,v4(Z,Y)),escape:($,Y={})=>J.escape($,v4(Z,Y)),filter:($,Y={})=>J.filter($,v4(Z,Y)),defaults:($)=>J.defaults(v4(Z,$)),makeRe:($,Y={})=>J.makeRe($,v4(Z,Y)),braceExpand:($,Y={})=>J.braceExpand($,v4(Z,Y)),match:($,Y,Q={})=>J.match($,Y,v4(Z,Q)),sep:J.sep,GLOBSTAR:J6})};h6.defaults=oc1;var ii=(Z,J={})=>{if(KG(Z),J.nobrace||!/\{(?:(?!\{).)*\}/.test(Z))return[Z];return ui.default(Z)};h6.braceExpand=ii;var rc1=(Z,J={})=>new V4(Z,J).makeRe();h6.makeRe=rc1;var tc1=(Z,J,X={})=>{let $=new V4(J,X);if(Z=Z.filter((Y)=>$.match(Y)),$.options.nonull&&!Z.length)Z.push(J);return Z};h6.match=tc1;var mi=/[?*]|[+@!]\(.*?\)|\[|\]/,ec1=(Z)=>Z.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class V4{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(Z,J={}){if(KG(Z),J=J||{},this.options=J,this.pattern=Z,this.platform=J.platform||pi,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=(...Y)=>console.error(...Y);this.debug(this.pattern,this.globSet);let X=this.globSet.map((Y)=>this.slashSplit(Y));this.globParts=this.preprocess(X),this.debug(this.pattern,this.globParts);let $=this.globParts.map((Y,Q,K)=>{if(this.isWindows&&this.windowsNoMagicRoot){let W=Y[0]===""&&Y[1]===""&&(Y[2]==="?"||!mi.test(Y[2]))&&!mi.test(Y[3]),G=/^[a-z]:/i.test(Y[0]);if(W)return[...Y.slice(0,4),...Y.slice(4).map((z)=>this.parse(z))];else if(G)return[Y[0],...Y.slice(1).map((z)=>this.parse(z))]}return Y.map((W)=>this.parse(W))});if(this.debug(this.pattern,$),this.set=$.filter((Y)=>Y.indexOf(!1)===-1),this.isWindows)for(let Y=0;Y<this.set.length;Y++){let Q=this.set[Y];if(Q[0]===""&&Q[1]===""&&this.globParts[Y][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 $=0;$<Z[X].length;$++)if(Z[X][$]==="**")Z[X][$]="*"}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 $=X;while(J[$+1]==="**")$++;if($!==X)J.splice(X,$-X)}return J})}levelOneOptimize(Z){return Z.map((J)=>{return J=J.reduce((X,$)=>{let Y=X[X.length-1];if($==="**"&&Y==="**")return X;if($===".."){if(Y&&Y!==".."&&Y!=="."&&Y!=="**")return X.pop(),X}return X.push($),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 $=1;$<Z.length-1;$++){let Y=Z[$];if($===1&&Y===""&&Z[0]==="")continue;if(Y==="."||Y==="")J=!0,Z.splice($,1),$--}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 $=Z[X-1];if($&&$!=="."&&$!==".."&&$!=="**")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 $=-1;while(($=X.indexOf("**",$+1))!==-1){let Q=$;while(X[Q+1]==="**")Q++;if(Q>$)X.splice($+1,Q-$);let K=X[$+1],W=X[$+2],G=X[$+3];if(K!=="..")continue;if(!W||W==="."||W===".."||!G||G==="."||G==="..")continue;J=!0,X.splice($,1);let z=X.slice(0);z[$]="**",Z.push(z),$--}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 Y=0;while((Y=X.indexOf("..",Y+1))!==-1){let Q=X[Y-1];if(Q&&Q!=="."&&Q!==".."&&Q!=="**"){J=!0;let W=Y===1&&X[Y+1]==="**"?["."]:[];if(X.splice(Y-1,2,...W),X.length===0)X.push("");Y-=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 $=this.partsMatch(Z[J],Z[X],!this.preserveMultipleSlashes);if($){Z[J]=[],Z[X]=$;break}}return Z.filter((J)=>J.length)}partsMatch(Z,J,X=!1){let $=0,Y=0,Q=[],K="";while($<Z.length&&Y<J.length)if(Z[$]===J[Y])Q.push(K==="b"?J[Y]:Z[$]),$++,Y++;else if(X&&Z[$]==="**"&&J[Y]===Z[$+1])Q.push(Z[$]),$++;else if(X&&J[Y]==="**"&&Z[$]===J[Y+1])Q.push(J[Y]),Y++;else if(Z[$]==="*"&&J[Y]&&(this.options.dot||!J[Y].startsWith("."))&&J[Y]!=="**"){if(K==="b")return!1;K="a",Q.push(Z[$]),$++,Y++}else if(J[Y]==="*"&&Z[$]&&(this.options.dot||!Z[$].startsWith("."))&&Z[$]!=="**"){if(K==="a")return!1;K="b",Q.push(J[Y]),$++,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 $=0;$<Z.length&&Z.charAt($)==="!";$++)J=!J,X++;if(X)this.pattern=Z.slice(X);this.negate=J}matchOne(Z,J,X=!1){let $=this.options;if(this.isWindows){let F=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),w=!F&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&/^[a-z]:$/i.test(Z[3]),c=typeof J[0]==="string"&&/^[a-z]:$/i.test(J[0]),x=!c&&J[0]===""&&J[1]===""&&J[2]==="?"&&typeof J[3]==="string"&&/^[a-z]:$/i.test(J[3]),j=w?3:F?0:void 0,B=x?3:c?0:void 0;if(typeof j==="number"&&typeof B==="number"){let[L,R]=[Z[j],J[B]];if(L.toLowerCase()===R.toLowerCase()){if(J[B]=L,B>j)J=J.slice(B);else if(j>B)Z=Z.slice(j)}}}let{optimizationLevel:Y=1}=this.options;if(Y>=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 z=J[K],v=Z[Q];if(this.debug(J,z,v),z===!1)return!1;if(z===J6){this.debug("GLOBSTAR",[J,z,v]);var H=Q,V=K+1;if(V===G){this.debug("** at the end");for(;Q<W;Q++)if(Z[Q]==="."||Z[Q]===".."||!$.dot&&Z[Q].charAt(0)===".")return!1;return!0}while(H<W){var q=Z[H];if(this.debug(`
398
398
  globstar while`,Z,H,J,V,q),this.matchOne(Z.slice(H),J.slice(V),X))return this.debug("globstar found match!",H,W,q),!0;else{if(q==="."||q===".."||!$.dot&&q.charAt(0)==="."){this.debug("dot detected!",Z,H,J,V);break}this.debug("globstar swallow a segment, and continue"),H++}}if(X){if(this.debug(`
399
- >>> no match, partial?`,Z,H,J,V),H===W)return!0}return!1}let F;if(typeof z==="string")F=v===z,this.debug("string match",z,v,F);else F=z.test(v),this.debug("pattern match",z,v,F);if(!F)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 Error("wtf?")}braceExpand(){return ii(this.pattern,this.options)}parse(Z){KG(Z);let J=this.options;if(Z==="**")return J6;if(Z==="")return"";let X,$=null;if(X=Z.match(Sc1))$=J.dot?Ac1:bc1;else if(X=Z.match(Nc1))$=(J.nocase?J.dot?fc1:Cc1:J.dot?Tc1:Oc1)(X[1]);else if(X=Z.match(mc1))$=(J.nocase?J.dot?lc1:uc1:J.dot?yc1:pc1)(X);else if(X=Z.match(kc1))$=J.dot?Ic1:Ec1;else if(X=Z.match(_c1))$=hc1;let Y=Z6.fromGlob(Z,this.options).toMMPattern();if($&&typeof Y==="object")Reflect.defineProperty(Y,"test",{value:$});return Y}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?dc1:J.dot?ac1:nc1,$=new Set(J.nocase?["i"]:[]),Y=Z.map((W)=>{let G=W.map((z)=>{if(z instanceof RegExp)for(let v of z.flags.split(""))$.add(v);return typeof z==="string"?ec1(z):z===J6?J6:z._src});return G.forEach((z,v)=>{let H=G[v+1],V=G[v-1];if(z!==J6||V===J6)return;if(V===void 0)if(H!==void 0&&H!==J6)G[v+1]="(?:\\/|"+X+"\\/)?"+H;else G[v]=X;else if(H===void 0)G[v-1]=V+"(?:\\/|"+X+")?";else if(H!==J6)G[v-1]=V+"(?:\\/|\\/"+X+"\\/)"+H,G[v+1]=J6}),G.filter((z)=>z!==J6).join("/")}).join("|"),[Q,K]=Z.length>1?["(?:",")"]:["",""];if(Y="^"+Q+Y+K+"$",this.negate)Y="^(?!"+Y+").+$";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 $=this.slashSplit(Z);this.debug(this.pattern,"split",$);let Y=this.set;this.debug(this.pattern,"set",Y);let Q=$[$.length-1];if(!Q)for(let K=$.length-2;!Q&&K>=0;K--)Q=$[K];for(let K=0;K<Y.length;K++){let W=Y[K],G=$;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 h6.defaults(Z).Minimatch}}h6.AST=Z6;h6.Minimatch=V4;h6.escape=Z3;h6.unescape=F9;import{fileURLToPath as kx1}from"node:url";var J3=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,di=new Set,iM=typeof process==="object"&&!!process?process:{},ai=(Z,J,X,$)=>{typeof iM.emitWarning==="function"?iM.emitWarning(Z,J,X,$):console.error(`[${X}] ${J}: ${Z}`)},NF=globalThis.AbortController,gi=globalThis.AbortSignal;if(typeof NF>"u"){gi=class{onabort;_onabort=[];reason;aborted=!1;addEventListener($,Y){this._onabort.push(Y)}},NF=class{constructor(){J()}signal=new gi;abort($){if(this.signal.aborted)return;this.signal.reason=$,this.signal.aborted=!0;for(let Y of this.signal._onabort)Y($);this.signal.onabort?.($)}};let Z=iM.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,ai("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 Zx1=(Z)=>!di.has(Z),nR6=Symbol("type"),IJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),ni=(Z)=>!IJ(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?GG:null;class GG extends Array{constructor(Z){super(Z);this.fill(0)}}class X3{heap;length;static#Z=!1;static create(Z){let J=ni(Z);if(!J)return[];X3.#Z=!0;let X=new X3(Z,J);return X3.#Z=!1,X}constructor(Z,J){if(!X3.#Z)throw 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 zG{#Z;#J;#$;#X;#Y;#v;#H;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#z;#V;#Q;#F;#c;#w;#U;#O;#j;#T;#D;#L;#B;#P;#x;#f;static unsafeExposeInternals(Z){return{starts:Z.#D,ttls:Z.#L,sizes:Z.#T,keyMap:Z.#z,keyList:Z.#V,valList:Z.#Q,next:Z.#F,prev:Z.#c,get head(){return Z.#w},get tail(){return Z.#U},free:Z.#O,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,$,Y)=>Z.#h(J,X,$,Y),moveToTail:(J)=>Z.#A(J),indexes:(J)=>Z.#N(J),rindexes:(J)=>Z.#C(J),isStale:(J)=>Z.#R(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.#v}get memoMethod(){return this.#H}get dispose(){return this.#$}get onInsert(){return this.#X}get disposeAfter(){return this.#Y}constructor(Z){let{max:J=0,ttl:X,ttlResolution:$=1,ttlAutopurge:Y,updateAgeOnGet:Q,updateAgeOnHas:K,allowStale:W,dispose:G,onInsert:z,disposeAfter:v,noDisposeOnSet:H,noUpdateTTL:V,maxSize:q=0,maxEntrySize:F=0,sizeCalculation:w,fetchMethod:c,memoMethod:x,noDeleteOnFetchRejection:j,noDeleteOnStaleGet:B,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:R,ignoreFetchAbort:M}=Z;if(J!==0&&!IJ(J))throw TypeError("max option must be a nonnegative integer");let P=J?ni(J):Array;if(!P)throw Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=F||this.#J,this.sizeCalculation=w,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#H=x,c!==void 0&&typeof c!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#v=c,this.#P=!!c,this.#z=new Map,this.#V=Array(J).fill(void 0),this.#Q=Array(J).fill(void 0),this.#F=new P(J),this.#c=new P(J),this.#w=0,this.#U=0,this.#O=X3.create(J),this.#W=0,this.#G=0,typeof G==="function")this.#$=G;if(typeof z==="function")this.#X=z;if(typeof v==="function")this.#Y=v,this.#j=[];else this.#Y=void 0,this.#j=void 0;if(this.#B=!!this.#$,this.#f=!!this.#X,this.#x=!!this.#Y,this.noDisposeOnSet=!!H,this.noUpdateTTL=!!V,this.noDeleteOnFetchRejection=!!j,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#J!==0){if(!IJ(this.#J))throw TypeError("maxSize must be a positive integer if specified")}if(!IJ(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#u()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!B,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=IJ($)||$===0?$:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!IJ(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#K()}if(this.#Z===0&&this.ttl===0&&this.#J===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#J){if(Zx1("LRU_CACHE_UNBOUNDED"))di.add("LRU_CACHE_UNBOUNDED"),ai("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",zG)}}getRemainingTTL(Z){return this.#z.has(Z)?1/0:0}#K(){let Z=new GG(this.#Z),J=new GG(this.#Z);this.#L=Z,this.#D=J,this.#k=(Y,Q,K=J3.now())=>{if(J[Y]=Q!==0?K:0,Z[Y]=Q,Q!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#R(Y))this.#E(this.#V[Y],"expire")},Q+1);if(W.unref)W.unref()}},this.#I=(Y)=>{J[Y]=Z[Y]!==0?J3.now():0},this.#M=(Y,Q)=>{if(Z[Q]){let K=Z[Q],W=J[Q];if(!K||!W)return;Y.ttl=K,Y.start=W,Y.now=X||$();let G=Y.now-W;Y.remainingTTL=K-G}};let X=0,$=()=>{let Y=J3.now();if(this.ttlResolution>0){X=Y;let Q=setTimeout(()=>X=0,this.ttlResolution);if(Q.unref)Q.unref()}return Y};this.getRemainingTTL=(Y)=>{let Q=this.#z.get(Y);if(Q===void 0)return 0;let K=Z[Q],W=J[Q];if(!K||!W)return 1/0;let G=(X||$())-W;return K-G},this.#R=(Y)=>{let Q=J[Y],K=Z[Y];return!!K&&!!Q&&(X||$())-Q>K}}#I=()=>{};#M=()=>{};#k=()=>{};#R=()=>!1;#u(){let Z=new GG(this.#Z);this.#G=0,this.#T=Z,this.#_=(J)=>{this.#G-=Z[J],Z[J]=0},this.#l=(J,X,$,Y)=>{if(this.#q(X))return 0;if(!IJ($))if(Y){if(typeof Y!=="function")throw TypeError("sizeCalculation must be a function");if($=Y(X,J),!IJ($))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return $},this.#S=(J,X,$)=>{if(Z[J]=X,this.#J){let Y=this.#J-Z[J];while(this.#G>Y)this.#b(!0)}if(this.#G+=Z[J],$)$.entrySize=X,$.totalCalculatedSize=this.#G}}#_=(Z)=>{};#S=(Z,J,X)=>{};#l=(Z,J,X,$)=>{if(X||$)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#U;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#w)break;else J=this.#c[J]}}*#C({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#w;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#U)break;else J=this.#F[J]}}#y(Z){return Z!==void 0&&this.#z.get(this.#V[Z])===Z}*entries(){for(let Z of this.#N())if(this.#Q[Z]!==void 0&&this.#V[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#V[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#C())if(this.#Q[Z]!==void 0&&this.#V[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#V[Z],this.#Q[Z]]}*keys(){for(let Z of this.#N()){let J=this.#V[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#C()){let J=this.#V[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*values(){for(let Z of this.#N())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}*rvalues(){for(let Z of this.#C())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.#N()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;if(Z(Y,this.#V[X],this))return this.get(this.#V[X],J)}}forEach(Z,J=this){for(let X of this.#N()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;Z.call(J,Y,this.#V[X],this)}}rforEach(Z,J=this){for(let X of this.#C()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;Z.call(J,Y,this.#V[X],this)}}purgeStale(){let Z=!1;for(let J of this.#C({allowStale:!0}))if(this.#R(J))this.#E(this.#V[J],"expire"),Z=!0;return Z}info(Z){let J=this.#z.get(Z);if(J===void 0)return;let X=this.#Q[J],$=this.#q(X)?X.__staleWhileFetching:X;if($===void 0)return;let Y={value:$};if(this.#L&&this.#D){let Q=this.#L[J],K=this.#D[J];if(Q&&K){let W=Q-(J3.now()-K);Y.ttl=W,Y.start=Date.now()}}if(this.#T)Y.size=this.#T[J];return Y}dump(){let Z=[];for(let J of this.#N({allowStale:!0})){let X=this.#V[J],$=this.#Q[J],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0||X===void 0)continue;let Q={value:Y};if(this.#L&&this.#D){Q.ttl=this.#L[J];let K=J3.now()-this.#D[J];Q.start=Math.floor(Date.now()-K)}if(this.#T)Q.size=this.#T[J];Z.unshift([X,Q])}return Z}load(Z){this.clear();for(let[J,X]of Z){if(X.start){let $=Date.now()-X.start;X.start=J3.now()-$}this.set(J,X.value,X)}}set(Z,J,X={}){if(J===void 0)return this.delete(Z),this;let{ttl:$=this.ttl,start:Y,noDisposeOnSet:Q=this.noDisposeOnSet,sizeCalculation:K=this.sizeCalculation,status:W}=X,{noUpdateTTL:G=this.noUpdateTTL}=X,z=this.#l(Z,J,X.size||0,K);if(this.maxEntrySize&&z>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#E(Z,"set"),this}let v=this.#W===0?void 0:this.#z.get(Z);if(v===void 0){if(v=this.#W===0?this.#U:this.#O.length!==0?this.#O.pop():this.#W===this.#Z?this.#b(!1):this.#W,this.#V[v]=Z,this.#Q[v]=J,this.#z.set(Z,v),this.#F[this.#U]=v,this.#c[v]=this.#U,this.#U=v,this.#W++,this.#S(v,z,W),W)W.set="add";if(G=!1,this.#f)this.#X?.(J,Z,"add")}else{this.#A(v);let H=this.#Q[v];if(J!==H){if(this.#P&&this.#q(H)){H.__abortController.abort(Error("replaced"));let{__staleWhileFetching:V}=H;if(V!==void 0&&!Q){if(this.#B)this.#$?.(V,Z,"set");if(this.#x)this.#j?.push([V,Z,"set"])}}else if(!Q){if(this.#B)this.#$?.(H,Z,"set");if(this.#x)this.#j?.push([H,Z,"set"])}if(this.#_(v),this.#S(v,z,W),this.#Q[v]=J,W){W.set="replace";let V=H&&this.#q(H)?H.__staleWhileFetching:H;if(V!==void 0)W.oldValue=V}}else if(W)W.set="update";if(this.#f)this.onInsert?.(J,Z,J===H?"update":"replace")}if($!==0&&!this.#L)this.#K();if(this.#L){if(!G)this.#k(v,$,Y);if(W)this.#M(W,v)}if(!Q&&this.#x&&this.#j){let H=this.#j,V;while(V=H?.shift())this.#Y?.(...V)}return this}pop(){try{while(this.#W){let Z=this.#Q[this.#w];if(this.#b(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#x&&this.#j){let Z=this.#j,J;while(J=Z?.shift())this.#Y?.(...J)}}}#b(Z){let J=this.#w,X=this.#V[J],$=this.#Q[J];if(this.#P&&this.#q($))$.__abortController.abort(Error("evicted"));else if(this.#B||this.#x){if(this.#B)this.#$?.($,X,"evict");if(this.#x)this.#j?.push([$,X,"evict"])}if(this.#_(J),Z)this.#V[J]=void 0,this.#Q[J]=void 0,this.#O.push(J);if(this.#W===1)this.#w=this.#U=0,this.#O.length=0;else this.#w=this.#F[J];return this.#z.delete(X),this.#W--,J}has(Z,J={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:$}=J,Y=this.#z.get(Z);if(Y!==void 0){let Q=this.#Q[Y];if(this.#q(Q)&&Q.__staleWhileFetching===void 0)return!1;if(!this.#R(Y)){if(X)this.#I(Y);if($)$.has="hit",this.#M($,Y);return!0}else if($)$.has="stale",this.#M($,Y)}else if($)$.has="miss";return!1}peek(Z,J={}){let{allowStale:X=this.allowStale}=J,$=this.#z.get(Z);if($===void 0||!X&&this.#R($))return;let Y=this.#Q[$];return this.#q(Y)?Y.__staleWhileFetching:Y}#h(Z,J,X,$){let Y=J===void 0?void 0:this.#Q[J];if(this.#q(Y))return Y;let Q=new NF,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:$},G=(F,w=!1)=>{let{aborted:c}=Q.signal,x=X.ignoreFetchAbort&&F!==void 0;if(X.status)if(c&&!w){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,x)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(c&&!x&&!w)return v(Q.signal.reason);let j=V;if(this.#Q[J]===V)if(F===void 0)if(j.__staleWhileFetching)this.#Q[J]=j.__staleWhileFetching;else this.#E(Z,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Z,F,W.options)}return F},z=(F)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=F;return v(F)},v=(F)=>{let{aborted:w}=Q.signal,c=w&&X.allowStaleOnFetchAbort,x=c||X.allowStaleOnFetchRejection,j=x||X.noDeleteOnFetchRejection,B=V;if(this.#Q[J]===V){if(!j||B.__staleWhileFetching===void 0)this.#E(Z,"fetch");else if(!c)this.#Q[J]=B.__staleWhileFetching}if(x){if(X.status&&B.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return B.__staleWhileFetching}else if(B.__returned===B)throw F},H=(F,w)=>{let c=this.#v?.(Z,Y,W);if(c&&c instanceof Promise)c.then((x)=>F(x===void 0?void 0:x),w);Q.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if(F(void 0),X.allowStaleOnFetchAbort)F=(x)=>G(x,!0)}})};if(X.status)X.status.fetchDispatched=!0;let V=new Promise(H).then(G,z),q=Object.assign(V,{__abortController:Q,__staleWhileFetching:Y,__returned:void 0});if(J===void 0)this.set(Z,q,{...W.options,status:void 0}),J=this.#z.get(Z);else this.#Q[J]=q;return q}#q(Z){if(!this.#P)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof NF}async fetch(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,ttl:Q=this.ttl,noDisposeOnSet:K=this.noDisposeOnSet,size:W=0,sizeCalculation:G=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:v=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:H=this.allowStaleOnFetchRejection,ignoreFetchAbort:V=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:F,forceRefresh:w=!1,status:c,signal:x}=J;if(!this.#P){if(c)c.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,status:c})}let j={allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:z,noDeleteOnFetchRejection:v,allowStaleOnFetchRejection:H,allowStaleOnFetchAbort:q,ignoreFetchAbort:V,status:c,signal:x},B=this.#z.get(Z);if(B===void 0){if(c)c.fetch="miss";let L=this.#h(Z,B,j,F);return L.__returned=L}else{let L=this.#Q[B];if(this.#q(L)){let O=X&&L.__staleWhileFetching!==void 0;if(c){if(c.fetch="inflight",O)c.returnedStale=!0}return O?L.__staleWhileFetching:L.__returned=L}let R=this.#R(B);if(!w&&!R){if(c)c.fetch="hit";if(this.#A(B),$)this.#I(B);if(c)this.#M(c,B);return L}let M=this.#h(Z,B,j,F),N=M.__staleWhileFetching!==void 0&&X;if(c){if(c.fetch=R?"stale":"refresh",N&&R)c.returnedStale=!0}return N?M.__staleWhileFetching:M.__returned=M}}async forceFetch(Z,J={}){let X=await this.fetch(Z,J);if(X===void 0)throw Error("fetch() returned undefined");return X}memo(Z,J={}){let X=this.#H;if(!X)throw Error("no memoMethod provided to constructor");let{context:$,forceRefresh:Y,...Q}=J,K=this.get(Z,Q);if(!Y&&K!==void 0)return K;let W=X(Z,K,{options:Q,context:$});return this.set(Z,W,Q),W}get(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,status:Q}=J,K=this.#z.get(Z);if(K!==void 0){let W=this.#Q[K],G=this.#q(W);if(Q)this.#M(Q,K);if(this.#R(K)){if(Q)Q.get="stale";if(!G){if(!Y)this.#E(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.#A(K),$)this.#I(K);return W}}else if(Q)Q.get="miss"}#p(Z,J){this.#c[J]=Z,this.#F[Z]=J}#A(Z){if(Z!==this.#U){if(Z===this.#w)this.#w=this.#F[Z];else this.#p(this.#c[Z],this.#F[Z]);this.#p(this.#U,Z),this.#U=Z}}delete(Z){return this.#E(Z,"delete")}#E(Z,J){let X=!1;if(this.#W!==0){let $=this.#z.get(Z);if($!==void 0)if(X=!0,this.#W===1)this.#m(J);else{this.#_($);let Y=this.#Q[$];if(this.#q(Y))Y.__abortController.abort(Error("deleted"));else if(this.#B||this.#x){if(this.#B)this.#$?.(Y,Z,J);if(this.#x)this.#j?.push([Y,Z,J])}if(this.#z.delete(Z),this.#V[$]=void 0,this.#Q[$]=void 0,$===this.#U)this.#U=this.#c[$];else if($===this.#w)this.#w=this.#F[$];else{let Q=this.#c[$];this.#F[Q]=this.#F[$];let K=this.#F[$];this.#c[K]=this.#c[$]}this.#W--,this.#O.push($)}}if(this.#x&&this.#j?.length){let $=this.#j,Y;while(Y=$?.shift())this.#Y?.(...Y)}return X}clear(){return this.#m("delete")}#m(Z){for(let J of this.#C({allowStale:!0})){let X=this.#Q[J];if(this.#q(X))X.__abortController.abort(Error("deleted"));else{let $=this.#V[J];if(this.#B)this.#$?.(X,$,Z);if(this.#x)this.#j?.push([X,$,Z])}}if(this.#z.clear(),this.#Q.fill(void 0),this.#V.fill(void 0),this.#L&&this.#D)this.#L.fill(0),this.#D.fill(0);if(this.#T)this.#T.fill(0);if(this.#w=0,this.#U=0,this.#O.length=0,this.#G=0,this.#W=0,this.#x&&this.#j){let J=this.#j,X;while(X=J?.shift())this.#Y?.(...X)}}}import{posix as Vx1,win32 as ZR}from"node:path";import{fileURLToPath as Hx1}from"node:url";import{lstatSync as qx1,readdir as Fx1,readdirSync as wx1,readlinkSync as cx1,realpathSync as xx1}from"fs";import*as Ux1 from"node:fs";import{lstat as Bx1,readdir as Lx1,readlink as Dx1,realpath as Mx1}from"node:fs/promises";import{EventEmitter as oM}from"node:events";import ei from"node:stream";import{StringDecoder as Jx1}from"node:string_decoder";var si=typeof process==="object"&&process?process:{stdout:null,stderr:null},Xx1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof C$||Z instanceof ei||$x1(Z)||Yx1(Z)),$x1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof oM&&typeof Z.pipe==="function"&&Z.pipe!==ei.Writable.prototype.pipe,Yx1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof oM&&typeof Z.write==="function"&&typeof Z.end==="function",ZZ=Symbol("EOF"),JZ=Symbol("maybeEmitEnd"),_J=Symbol("emittedEnd"),OF=Symbol("emittingEnd"),vG=Symbol("emittedError"),TF=Symbol("closed"),oi=Symbol("read"),CF=Symbol("flush"),ri=Symbol("flushChunk"),w9=Symbol("encoding"),$3=Symbol("decoder"),y8=Symbol("flowing"),VG=Symbol("paused"),Y3=Symbol("resume"),p8=Symbol("buffer"),S6=Symbol("pipes"),i8=Symbol("bufferLength"),gM=Symbol("bufferPush"),fF=Symbol("bufferShift"),w6=Symbol("objectMode"),x8=Symbol("destroyed"),dM=Symbol("error"),aM=Symbol("emitData"),ti=Symbol("emitEnd"),nM=Symbol("emitEnd2"),$7=Symbol("async"),sM=Symbol("abort"),kF=Symbol("aborted"),HG=Symbol("signal"),T$=Symbol("dataListeners"),I5=Symbol("discarded"),qG=(Z)=>Promise.resolve().then(Z),Qx1=(Z)=>Z(),Kx1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",Wx1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,Gx1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class rM{src;dest;opts;ondrain;constructor(Z,J,X){this.src=Z,this.dest=J,this.opts=X,this.ondrain=()=>Z[Y3](),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 Zg extends rM{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Z,J,X){super(Z,J,X);this.proxyErrors=($)=>J.emit("error",$),Z.on("error",this.proxyErrors)}}var zx1=(Z)=>!!Z.objectMode,vx1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class C$ extends oM{[y8]=!1;[VG]=!1;[S6]=[];[p8]=[];[w6];[w9];[$7];[$3];[ZZ]=!1;[_J]=!1;[OF]=!1;[TF]=!1;[vG]=null;[i8]=0;[x8]=!1;[HG];[kF]=!1;[T$]=0;[I5]=!1;writable=!0;readable=!0;constructor(...Z){let J=Z[0]||{};super();if(J.objectMode&&typeof J.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(zx1(J))this[w6]=!0,this[w9]=null;else if(vx1(J))this[w9]=J.encoding,this[w6]=!1;else this[w6]=!1,this[w9]=null;if(this[$7]=!!J.async,this[$3]=this[w9]?new Jx1(this[w9]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[p8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[S6]});let{signal:X}=J;if(X)if(this[HG]=X,X.aborted)this[sM]();else X.addEventListener("abort",()=>this[sM]())}get bufferLength(){return this[i8]}get encoding(){return this[w9]}set encoding(Z){throw Error("Encoding must be set at instantiation time")}setEncoding(Z){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[w6]}set objectMode(Z){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[$7]}set["async"](Z){this[$7]=this[$7]||!!Z}[sM](){this[kF]=!0,this.emit("abort",this[HG]?.reason),this.destroy(this[HG]?.reason)}get aborted(){return this[kF]}set aborted(Z){}write(Z,J,X){if(this[kF])return!1;if(this[ZZ])throw Error("write after end");if(this[x8])return this.emit("error",Object.assign(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 $=this[$7]?qG:Qx1;if(!this[w6]&&!Buffer.isBuffer(Z)){if(Gx1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(Wx1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[w6]){if(this[y8]&&this[i8]!==0)this[CF](!0);if(this[y8])this.emit("data",Z);else this[gM](Z);if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}if(!Z.length){if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}if(typeof Z==="string"&&!(J===this[w9]&&!this[$3]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[w9])Z=this[$3].write(Z);if(this[y8]&&this[i8]!==0)this[CF](!0);if(this[y8])this.emit("data",Z);else this[gM](Z);if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}read(Z){if(this[x8])return null;if(this[I5]=!1,this[i8]===0||Z===0||Z&&Z>this[i8])return this[JZ](),null;if(this[w6])Z=null;if(this[p8].length>1&&!this[w6])this[p8]=[this[w9]?this[p8].join(""):Buffer.concat(this[p8],this[i8])];let J=this[oi](Z||null,this[p8][0]);return this[JZ](),J}[oi](Z,J){if(this[w6])this[fF]();else{let X=J;if(Z===X.length||Z===null)this[fF]();else if(typeof X==="string")this[p8][0]=X.slice(Z),J=X.slice(0,Z),this[i8]-=Z;else this[p8][0]=X.subarray(Z),J=X.subarray(0,Z),this[i8]-=Z}if(this.emit("data",J),!this[p8].length&&!this[ZZ])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[ZZ]=!0,this.writable=!1,this[y8]||!this[VG])this[JZ]();return this}[Y3](){if(this[x8])return;if(!this[T$]&&!this[S6].length)this[I5]=!0;if(this[VG]=!1,this[y8]=!0,this.emit("resume"),this[p8].length)this[CF]();else if(this[ZZ])this[JZ]();else this.emit("drain")}resume(){return this[Y3]()}pause(){this[y8]=!1,this[VG]=!0,this[I5]=!1}get destroyed(){return this[x8]}get flowing(){return this[y8]}get paused(){return this[VG]}[gM](Z){if(this[w6])this[i8]+=1;else this[i8]+=Z.length;this[p8].push(Z)}[fF](){if(this[w6])this[i8]-=1;else this[i8]-=this[p8][0].length;return this[p8].shift()}[CF](Z=!1){do;while(this[ri](this[fF]())&&this[p8].length);if(!Z&&!this[p8].length&&!this[ZZ])this.emit("drain")}[ri](Z){return this.emit("data",Z),this[y8]}pipe(Z,J){if(this[x8])return Z;this[I5]=!1;let X=this[_J];if(J=J||{},Z===si.stdout||Z===si.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[S6].push(!J.proxyErrors?new rM(this,Z,J):new Zg(this,Z,J)),this[$7])qG(()=>this[Y3]());else this[Y3]();return Z}unpipe(Z){let J=this[S6].find((X)=>X.dest===Z);if(J){if(this[S6].length===1){if(this[y8]&&this[T$]===0)this[y8]=!1;this[S6]=[]}else this[S6].splice(this[S6].indexOf(J),1);J.unpipe()}}addListener(Z,J){return this.on(Z,J)}on(Z,J){let X=super.on(Z,J);if(Z==="data"){if(this[I5]=!1,this[T$]++,!this[S6].length&&!this[y8])this[Y3]()}else if(Z==="readable"&&this[i8]!==0)super.emit("readable");else if(Kx1(Z)&&this[_J])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[vG]){let $=J;if(this[$7])qG(()=>$.call(this,this[vG]));else $.call(this,this[vG])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[T$]=this.listeners("data").length,this[T$]===0&&!this[I5]&&!this[S6].length)this[y8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[T$]=0,!this[I5]&&!this[S6].length)this[y8]=!1}return J}get emittedEnd(){return this[_J]}[JZ](){if(!this[OF]&&!this[_J]&&!this[x8]&&this[p8].length===0&&this[ZZ]){if(this[OF]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[TF])this.emit("close");this[OF]=!1}}emit(Z,...J){let X=J[0];if(Z!=="error"&&Z!=="close"&&Z!==x8&&this[x8])return!1;else if(Z==="data")return!this[w6]&&!X?!1:this[$7]?(qG(()=>this[aM](X)),!0):this[aM](X);else if(Z==="end")return this[ti]();else if(Z==="close"){if(this[TF]=!0,!this[_J]&&!this[x8])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Z==="error"){this[vG]=X,super.emit(dM,X);let Y=!this[HG]||this.listeners("error").length?super.emit("error",X):!1;return this[JZ](),Y}else if(Z==="resume"){let Y=super.emit("resume");return this[JZ](),Y}else if(Z==="finish"||Z==="prefinish"){let Y=super.emit(Z);return this.removeAllListeners(Z),Y}let $=super.emit(Z,...J);return this[JZ](),$}[aM](Z){for(let X of this[S6])if(X.dest.write(Z)===!1)this.pause();let J=this[I5]?!1:super.emit("data",Z);return this[JZ](),J}[ti](){if(this[_J])return!1;return this[_J]=!0,this.readable=!1,this[$7]?(qG(()=>this[nM]()),!0):this[nM]()}[nM](){if(this[$3]){let J=this[$3].end();if(J){for(let X of this[S6])X.dest.write(J);if(!this[I5])super.emit("data",J)}}for(let J of this[S6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[w6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[w6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[w6])throw Error("cannot concat in objectMode");let Z=await this.collect();return this[w9]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(x8,()=>J(Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[I5]=!1;let Z=!1,J=async()=>{return this.pause(),Z=!0,{value:void 0,done:!0}};return{next:()=>{if(Z)return J();let $=this.read();if($!==null)return Promise.resolve({done:!1,value:$});if(this[ZZ])return J();let Y,Q,K=(v)=>{this.off("data",W),this.off("end",G),this.off(x8,z),J(),Q(v)},W=(v)=>{this.off("error",K),this.off("end",G),this.off(x8,z),this.pause(),Y({value:v,done:!!this[ZZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(x8,z),J(),Y({done:!0,value:void 0})},z=()=>K(Error("stream destroyed"));return new Promise((v,H)=>{Q=H,Y=v,this.once(x8,z),this.once("error",K),this.once("end",G),this.once("data",W)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[I5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(dM,J),this.off(x8,J),this.off("end",J),Z=!0,{done:!0,value:void 0}},X=()=>{if(Z)return J();let $=this.read();return $===null?J():{done:!1,value:$}};return this.once("end",J),this.once(dM,J),this.once(x8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[x8]){if(Z)this.emit("error",Z);else this.emit(x8);return this}this[x8]=!0,this[I5]=!0,this[p8].length=0,this[i8]=0;let J=this;if(typeof J.close==="function"&&!this[TF])J.close();if(Z)this.emit("error",Z);else this.emit(x8);return this}static get isStream(){return Xx1}}var jx1=xx1.native,wG={lstatSync:qx1,readdir:Fx1,readdirSync:wx1,readlinkSync:cx1,realpathSync:jx1,promises:{lstat:Bx1,readdir:Lx1,readlink:Dx1,realpath:Mx1}},Qg=(Z)=>!Z||Z===wG||Z===Ux1?wG:{...wG,...Z,promises:{...wG.promises,...Z.promises||{}}},Kg=/^\\\\\?\\([a-z]:)\\?$/i,Rx1=(Z)=>Z.replace(/\//g,"\\").replace(Kg,"$1\\"),Px1=/[\\\/]/,q4=0,Wg=1,Gg=2,Y7=4,zg=6,vg=8,f$=10,Vg=12,H4=15,FG=~H4,tM=16,Jg=32,cG=64,c9=128,EF=256,_F=512,Xg=cG|c9|_F,Nx1=1023,eM=(Z)=>Z.isFile()?vg:Z.isDirectory()?Y7:Z.isSymbolicLink()?f$:Z.isCharacterDevice()?Gg:Z.isBlockDevice()?zg:Z.isSocket()?Vg:Z.isFIFO()?Wg:q4,$g=new Map,xG=(Z)=>{let J=$g.get(Z);if(J)return J;let X=Z.normalize("NFKD");return $g.set(Z,X),X},Yg=new Map,IF=(Z)=>{let J=Yg.get(Z);if(J)return J;let X=xG(Z.toLowerCase());return Yg.set(Z,X),X};class JR extends zG{constructor(){super({max:256})}}class Hg extends zG{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var qg=Symbol("PathScurry setAsCwd");class b6{name;root;roots;parent;nocase;isCWD=!1;#Z;#J;get dev(){return this.#J}#$;get mode(){return this.#$}#X;get nlink(){return this.#X}#Y;get uid(){return this.#Y}#v;get gid(){return this.#v}#H;get rdev(){return this.#H}#W;get blksize(){return this.#W}#G;get ino(){return this.#G}#z;get size(){return this.#z}#V;get blocks(){return this.#V}#Q;get atimeMs(){return this.#Q}#F;get mtimeMs(){return this.#F}#c;get ctimeMs(){return this.#c}#w;get birthtimeMs(){return this.#w}#U;get atime(){return this.#U}#O;get mtime(){return this.#O}#j;get ctime(){return this.#j}#T;get birthtime(){return this.#T}#D;#L;#B;#P;#x;#f;#K;#I;#M;#k;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=q4,X,$,Y,Q,K){if(this.name=Z,this.#D=Y?IF(Z):xG(Z),this.#K=J&Nx1,this.nocase=Y,this.roots=$,this.root=X||this,this.#I=Q,this.#B=K.fullpath,this.#x=K.relative,this.#f=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=Qg(K.fs)}depth(){if(this.#L!==void 0)return this.#L;if(!this.parent)return this.#L=0;return this.#L=this.parent.depth()+1}childrenCache(){return this.#I}resolve(Z){if(!Z)return this;let J=this.getRootString(Z),$=Z.substring(J.length).split(this.splitSep);return J?this.getRoot(J).#R($):this.#R($)}#R(Z){let J=this;for(let X of Z)J=J.child(X);return J}children(){let Z=this.#I.get(this);if(Z)return Z;let J=Object.assign([],{provisional:0});return this.#I.set(this,J),this.#K&=~tM,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),$=this.nocase?IF(Z):xG(Z);for(let W of X)if(W.#D===$)return W;let Y=this.parent?this.sep:"",Q=this.#B?this.#B+Y+Z:void 0,K=this.newChild(Z,q4,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=c9;return X.push(K),K}relative(){if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let Z=this.name,J=this.parent;if(!J)return this.#x=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.#f!==void 0)return this.#f;let Z=this.name,J=this.parent;if(!J)return this.#f=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#B!==void 0)return this.#B;let Z=this.name,J=this.parent;if(!J)return this.#B=this.name;let $=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#B=$}fullpathPosix(){if(this.#P!==void 0)return this.#P;if(this.sep==="/")return this.#P=this.fullpath();if(!this.parent){let $=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test($))return this.#P=`//?/${$}`;else return this.#P=$}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#P=X}isUnknown(){return(this.#K&H4)===q4}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&H4)===vg}isDirectory(){return(this.#K&H4)===Y7}isCharacterDevice(){return(this.#K&H4)===Gg}isBlockDevice(){return(this.#K&H4)===zg}isFIFO(){return(this.#K&H4)===Wg}isSocket(){return(this.#K&H4)===Vg}isSymbolicLink(){return(this.#K&f$)===f$}lstatCached(){return this.#K&Jg?this:void 0}readlinkCached(){return this.#M}realpathCached(){return this.#k}readdirCached(){let Z=this.children();return Z.slice(0,Z.provisional)}canReadlink(){if(this.#M)return!0;if(!this.parent)return!1;let Z=this.#K&H4;return!(Z!==q4&&Z!==f$||this.#K&EF||this.#K&c9)}calledReaddir(){return!!(this.#K&tM)}isENOENT(){return!!(this.#K&c9)}isNamed(Z){return!this.nocase?this.#D===xG(Z):this.#D===IF(Z)}async readlink(){let Z=this.#M;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.#M=X}catch(J){this.#b(J.code);return}}readlinkSync(){let Z=this.#M;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.#M=X}catch(J){this.#b(J.code);return}}#u(Z){this.#K|=tM;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#_()}}#_(){if(this.#K&c9)return;this.#K=(this.#K|c9)&FG,this.#S()}#S(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#_()}#l(){this.#K|=_F,this.#N()}#N(){if(this.#K&cG)return;let Z=this.#K;if((Z&H4)===Y7)Z&=FG;this.#K=Z|cG,this.#S()}#C(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#N();else if(Z==="ENOENT")this.#_();else this.children().provisional=0}#y(Z=""){if(Z==="ENOTDIR")this.parent.#N();else if(Z==="ENOENT")this.#_()}#b(Z=""){let J=this.#K;if(J|=EF,Z==="ENOENT")J|=c9;if(Z==="EINVAL"||Z==="UNKNOWN")J&=FG;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#N()}#h(Z,J){return this.#p(Z,J)||this.#q(Z,J)}#q(Z,J){let X=eM(Z),$=this.newChild(Z.name,X,{parent:this}),Y=$.#K&H4;if(Y!==Y7&&Y!==f$&&Y!==q4)$.#K|=cG;return J.unshift($),J.provisional++,$}#p(Z,J){for(let X=J.provisional;X<J.length;X++){let $=J[X];if((this.nocase?IF(Z.name):xG(Z.name))!==$.#D)continue;return this.#A(Z,$,X,J)}}#A(Z,J,X,$){let Y=J.name;if(J.#K=J.#K&FG|eM(Z),Y!==Z.name)J.name=Z.name;if(X!==$.provisional){if(X===$.length-1)$.pop();else $.splice(X,1);$.unshift(J)}return $.provisional++,J}async lstat(){if((this.#K&c9)===0)try{return this.#E(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#y(Z.code)}}lstatSync(){if((this.#K&c9)===0)try{return this.#E(this.#Z.lstatSync(this.fullpath())),this}catch(Z){this.#y(Z.code)}}#E(Z){let{atime:J,atimeMs:X,birthtime:$,birthtimeMs:Y,blksize:Q,blocks:K,ctime:W,ctimeMs:G,dev:z,gid:v,ino:H,mode:V,mtime:q,mtimeMs:F,nlink:w,rdev:c,size:x,uid:j}=Z;this.#U=J,this.#Q=X,this.#T=$,this.#w=Y,this.#W=Q,this.#V=K,this.#j=W,this.#c=G,this.#J=z,this.#v=v,this.#G=H,this.#$=V,this.#O=q,this.#F=F,this.#X=w,this.#H=c,this.#z=x,this.#Y=j;let B=eM(Z);if(this.#K=this.#K&FG|B|Jg,B!==q4&&B!==Y7&&B!==f$)this.#K|=cG}#m=[];#g=!1;#d(Z){this.#g=!1;let J=this.#m.slice();this.#m.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 Y=X.slice(0,X.provisional);if(J)Z(null,Y);else queueMicrotask(()=>Z(null,Y));return}if(this.#m.push(Z),this.#g)return;this.#g=!0;let $=this.fullpath();this.#Z.readdir($,{withFileTypes:!0},(Y,Q)=>{if(Y)this.#C(Y.code),X.provisional=0;else{for(let K of Q)this.#h(K,X);this.#u(X)}this.#d(X.slice(0,X.provisional));return})}#i;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.#i)await this.#i;else{let X=()=>{};this.#i=new Promise(($)=>X=$);try{for(let $ of await this.#Z.promises.readdir(J,{withFileTypes:!0}))this.#h($,Z);this.#u(Z)}catch($){this.#C($.code),Z.provisional=0}this.#i=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.#u(Z)}catch(X){this.#C(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&Xg)return!1;let Z=H4&this.#K;if(!(Z===q4||Z===Y7||Z===f$))return!1;return!0}shouldWalk(Z,J){return(this.#K&Y7)===Y7&&!(this.#K&Xg)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#k)return this.#k;if((_F|EF|c9)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#k=this.resolve(Z)}catch(Z){this.#l()}}realpathSync(){if(this.#k)return this.#k;if((_F|EF|c9)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#k=this.resolve(Z)}catch(Z){this.#l()}}[qg](Z){if(Z===this)return;Z.isCWD=!1,this.isCWD=!0;let J=new Set([]),X=[],$=this;while($&&$.parent)J.add($),$.#x=X.join(this.sep),$.#f=X.join("/"),$=$.parent,X.push("..");$=Z;while($&&$.parent&&!J.has($))$.#x=void 0,$.#f=void 0,$=$.parent}}class hF extends b6{sep="\\";splitSep=Px1;constructor(Z,J=q4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}newChild(Z,J=q4,X={}){return new hF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return ZR.parse(Z).root}getRoot(Z){if(Z=Rx1(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 UG(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(Kg,"$1\\"),Z===J}}class SF extends b6{splitSep="/";sep="/";constructor(Z,J=q4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=q4,X={}){return new SF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class XR{root;rootPath;roots;cwd;#Z;#J;#$;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:$,childrenCacheSize:Y=16384,fs:Q=wG}={}){if(this.#X=Qg(Q),Z instanceof URL||Z.startsWith("file://"))Z=Hx1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new JR,this.#J=new JR,this.#$=new Hg(Y);let W=K.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if($===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=$,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let G=this.root,z=W.length-1,v=J.sep,H=this.rootPath,V=!1;for(let q of W){let F=z--;G=G.child(q,{relative:Array(F).fill("..").join(v),relativePosix:Array(F).fill("..").join("/"),fullpath:H+=(V?"":v)+q}),V=!0}this.cwd=G}depth(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.depth()}childrenCache(){return this.#$}resolve(...Z){let J="";for(let Y=Z.length-1;Y>=0;Y--){let Q=Z[Y];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 $=this.cwd.resolve(J).fullpath();return this.#Z.set(J,$),$}resolvePosix(...Z){let J="";for(let Y=Z.length-1;Y>=0;Y--){let Q=Z[Y];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 $=this.cwd.resolve(J).fullpathPosix();return this.#J.set(J,$),$}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 b6))J=Z,Z=this.cwd;let{withFileTypes:X}=J;if(!Z.canReaddir())return[];else{let $=await Z.readdir();return X?$:$.map((Y)=>Y.name)}}readdirSync(Z=this.cwd,J={withFileTypes:!0}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))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(($)=>$.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 b6))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 b6))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 b6))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 b6))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 b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=[];if(!Y||Y(Z))K.push(X?Z:Z.fullpath());let W=new Set,G=(v,H)=>{W.add(v),v.readdirCB((V,q)=>{if(V)return H(V);let F=q.length;if(!F)return H();let w=()=>{if(--F===0)H()};for(let c of q){if(!Y||Y(c))K.push(X?c:c.fullpath());if($&&c.isSymbolicLink())c.realpath().then((x)=>x?.isUnknown()?x.lstat():x).then((x)=>x?.shouldWalk(W,Q)?G(x,w):w());else if(c.shouldWalk(W,Q))G(c,w);else w()}},!0)},z=Z;return new Promise((v,H)=>{G(z,(V)=>{if(V)return H(V);v(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=[];if(!Y||Y(Z))K.push(X?Z:Z.fullpath());let W=new Set([Z]);for(let G of W){let z=G.readdirSync();for(let v of z){if(!Y||Y(v))K.push(X?v:v.fullpath());let H=v;if(v.isSymbolicLink()){if(!($&&(H=v.realpathSync())))continue;if(H.isUnknown())H.lstatSync()}if(H.shouldWalk(W,Q))W.add(H)}}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 b6))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 b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J;if(!Y||Y(Z))yield X?Z:Z.fullpath();let K=new Set([Z]);for(let W of K){let G=W.readdirSync();for(let z of G){if(!Y||Y(z))yield X?z:z.fullpath();let v=z;if(z.isSymbolicLink()){if(!($&&(v=z.realpathSync())))continue;if(v.isUnknown())v.lstatSync()}if(v.shouldWalk(K,Q))K.add(v)}}}stream(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new C$({objectMode:!0});if(!Y||Y(Z))K.write(X?Z:Z.fullpath());let W=new Set,G=[Z],z=0,v=()=>{let H=!1;while(!H){let V=G.shift();if(!V){if(z===0)K.end();return}z++,W.add(V);let q=(w,c,x=!1)=>{if(w)return K.emit("error",w);if($&&!x){let j=[];for(let B of c)if(B.isSymbolicLink())j.push(B.realpath().then((L)=>L?.isUnknown()?L.lstat():L));if(j.length){Promise.all(j).then(()=>q(null,c,!0));return}}for(let j of c)if(j&&(!Y||Y(j))){if(!K.write(X?j:j.fullpath()))H=!0}z--;for(let j of c){let B=j.realpathCached()||j;if(B.shouldWalk(W,Q))G.push(B)}if(H&&!K.flowing)K.once("drain",v);else if(!F)v()},F=!0;V.readdirCB(q,!0),F=!1}};return v(),K}streamSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new C$({objectMode:!0}),W=new Set;if(!Y||Y(Z))K.write(X?Z:Z.fullpath());let G=[Z],z=0,v=()=>{let H=!1;while(!H){let V=G.shift();if(!V){if(z===0)K.end();return}z++,W.add(V);let q=V.readdirSync();for(let F of q)if(!Y||Y(F)){if(!K.write(X?F:F.fullpath()))H=!0}z--;for(let F of q){let w=F;if(F.isSymbolicLink()){if(!($&&(w=F.realpathSync())))continue;if(w.isUnknown())w.lstatSync()}if(w.shouldWalk(W,Q))G.push(w)}}if(H&&!K.flowing)K.once("drain",v)};return v(),K}chdir(Z=this.cwd){let J=this.cwd;this.cwd=typeof Z==="string"?this.cwd.resolve(Z):Z,this.cwd[qg](J)}}class UG extends XR{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,ZR,"\\",{...J,nocase:X});this.nocase=X;for(let $=this.cwd;$;$=$.parent)$.nocase=this.nocase}parseRootPath(Z){return ZR.parse(Z).root.toUpperCase()}newRoot(Z){return new hF(this.rootPath,Y7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class jG extends XR{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,Vx1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new SF(this.rootPath,Y7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class bF extends jG{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var KP6=process.platform==="win32"?hF:SF,Fg=process.platform==="win32"?UG:process.platform==="darwin"?bF:jG;var Ox1=(Z)=>Z.length>=1,Tx1=(Z)=>Z.length>=1;class Q3{#Z;#J;#$;length;#X;#Y;#v;#H;#W;#G;#z=!0;constructor(Z,J,X,$){if(!Ox1(Z))throw TypeError("empty pattern list");if(!Tx1(J))throw TypeError("empty glob list");if(J.length!==Z.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=Z.length,X<0||X>=this.length)throw TypeError("index out of range");if(this.#Z=Z,this.#J=J,this.#$=X,this.#X=$,this.#$===0){if(this.isUNC()){let[Y,Q,K,W,...G]=this.#Z,[z,v,H,V,...q]=this.#J;if(G[0]==="")G.shift(),q.shift();let F=[Y,Q,K,W,""].join("/"),w=[z,v,H,V,""].join("/");this.#Z=[F,...G],this.#J=[w,...q],this.length=this.#Z.length}else if(this.isDrive()||this.isAbsolute()){let[Y,...Q]=this.#Z,[K,...W]=this.#J;if(Q[0]==="")Q.shift(),W.shift();let G=Y+"/",z=K+"/";this.#Z=[G,...Q],this.#J=[z,...W],this.length=this.#Z.length}}}pattern(){return this.#Z[this.#$]}isString(){return typeof this.#Z[this.#$]==="string"}isGlobstar(){return this.#Z[this.#$]===J6}isRegExp(){return this.#Z[this.#$]instanceof RegExp}globString(){return this.#v=this.#v||(this.#$===0?this.isAbsolute()?this.#J[0]+this.#J.slice(1).join("/"):this.#J.join("/"):this.#J.slice(this.#$).join("/"))}hasMore(){return this.length>this.#$+1}rest(){if(this.#Y!==void 0)return this.#Y;if(!this.hasMore())return this.#Y=null;return this.#Y=new Q3(this.#Z,this.#J,this.#$+1,this.#X),this.#Y.#G=this.#G,this.#Y.#W=this.#W,this.#Y.#H=this.#H,this.#Y}isUNC(){let Z=this.#Z;return this.#W!==void 0?this.#W:this.#W=this.#X==="win32"&&this.#$===0&&Z[0]===""&&Z[1]===""&&typeof Z[2]==="string"&&!!Z[2]&&typeof Z[3]==="string"&&!!Z[3]}isDrive(){let Z=this.#Z;return this.#H!==void 0?this.#H:this.#H=this.#X==="win32"&&this.#$===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.#$===0?Z:""}checkFollowGlobstar(){return!(this.#$===0||!this.isGlobstar()||!this.#z)}markFollowGlobstar(){if(this.#$===0||!this.isGlobstar()||!this.#z)return!1;return this.#z=!1,!0}}var Cx1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class BG{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:$,noglobstar:Y,platform:Q=Cx1}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=Q,this.mmopts={dot:!0,nobrace:J,nocase:X,noext:$,noglobstar:Y,optimizationLevel:2,platform:Q,nocomment:!0,nonegate:!0};for(let K of Z)this.add(K)}add(Z){let J=new V4(Z,this.mmopts);for(let X=0;X<J.set.length;X++){let $=J.set[X],Y=J.globParts[X];if(!$||!Y)throw Error("invalid pattern object");while($[0]==="."&&Y[0]===".")$.shift(),Y.shift();let Q=new Q3($,Y,0,this.platform),K=new V4(Q.globString(),this.mmopts),W=Y[Y.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}/`,$=Z.relative()||".",Y=`${$}/`;for(let Q of this.relative)if(Q.match($)||Q.match(Y))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 $ of this.relativeChildren)if($.match(X))return!0;for(let $ of this.absoluteChildren)if($.match(J))return!0;return!1}}class $R{store;constructor(Z=new Map){this.store=Z}copy(){return new $R(new Map(this.store))}hasWalked(Z,J){return this.store.get(Z.fullpath())?.has(J.globString())}storeWalked(Z,J){let X=Z.fullpath(),$=this.store.get(X);if($)$.add(J.globString());else this.store.set(X,new Set([J.globString()]))}}class wg{store=new Map;add(Z,J,X){let $=(J?2:0)|(X?1:0),Y=this.store.get(Z);this.store.set(Z,Y===void 0?$:$&Y)}entries(){return[...this.store.entries()].map(([Z,J])=>[Z,!!(J&2),!!(J&1)])}}class cg{store=new Map;add(Z,J){if(!Z.canReaddir())return;let X=this.store.get(Z);if(X){if(!X.find(($)=>$.globString()===J.globString()))X.push(J)}else this.store.set(Z,[J])}get(Z){let J=this.store.get(Z);if(!J)throw 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 LG{hasWalkedCache;matches=new wg;subwalks=new cg;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new $R}processPatterns(Z,J){this.patterns=J;let X=J.map(($)=>[Z,$]);for(let[$,Y]of X){this.hasWalkedCache.storeWalked($,Y);let Q=Y.root(),K=Y.isAbsolute()&&this.opts.absolute!==!1;if(Q){$=$.resolve(Q==="/"&&this.opts.root!==void 0?this.opts.root:Q);let v=Y.rest();if(!v){this.matches.add($,!0,!1);continue}else Y=v}if($.isENOENT())continue;let W,G,z=!1;while(typeof(W=Y.pattern())==="string"&&(G=Y.rest()))$=$.resolve(W),Y=G,z=!0;if(W=Y.pattern(),G=Y.rest(),z){if(this.hasWalkedCache.hasWalked($,Y))continue;this.hasWalkedCache.storeWalked($,Y)}if(typeof W==="string"){let v=W===".."||W===""||W===".";this.matches.add($.resolve(W),K,v);continue}else if(W===J6){if(!$.isSymbolicLink()||this.follow||Y.checkFollowGlobstar())this.subwalks.add($,Y);let v=G?.pattern(),H=G?.rest();if(!G||(v===""||v===".")&&!H)this.matches.add($,K,v===""||v===".");else if(v===".."){let V=$.parent||$;if(!H)this.matches.add(V,K,!0);else if(!this.hasWalkedCache.hasWalked(V,H))this.subwalks.add(V,H)}}else if(W instanceof RegExp)this.subwalks.add($,Y)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new LG(this.opts,this.hasWalkedCache)}filterEntries(Z,J){let X=this.subwalks.get(Z),$=this.child();for(let Y of J)for(let Q of X){let K=Q.isAbsolute(),W=Q.pattern(),G=Q.rest();if(W===J6)$.testGlobstar(Y,Q,G,K);else if(W instanceof RegExp)$.testRegExp(Y,W,G,K);else $.testString(Y,W,G,K)}return $}testGlobstar(Z,J,X,$){if(this.dot||!Z.name.startsWith(".")){if(!J.hasMore())this.matches.add(Z,$,!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 Y=X.pattern();if(typeof Y==="string"&&Y!==".."&&Y!==""&&Y!==".")this.testString(Z,Y,X.rest(),$);else if(Y===".."){let Q=Z.parent||Z;this.subwalks.add(Q,X)}else if(Y instanceof RegExp)this.testRegExp(Z,Y,X.rest(),$)}}testRegExp(Z,J,X,$){if(!J.test(Z.name))return;if(!X)this.matches.add(Z,$,!1);else this.subwalks.add(Z,X)}testString(Z,J,X,$){if(!Z.isNamed(J))return;if(!X)this.matches.add(Z,$,!1);else this.subwalks.add(Z,X)}}var fx1=(Z,J)=>typeof Z==="string"?new BG([Z],J):Array.isArray(Z)?new BG(Z,J):Z;class YR{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#J;#$;signal;maxDepth;includeChildMatches;constructor(Z,J,X){if(this.patterns=Z,this.path=J,this.opts=X,this.#$=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#J=fx1(X.ignore??[],X),!this.includeChildMatches&&typeof this.#J.add!=="function")throw 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)}#Y(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 Y=Z.isUnknown()||this.opts.stat?await Z.lstat():Z;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let Q=await Y.realpath();if(Q&&(Q.isUnknown()||this.opts.stat))await Q.lstat()}return this.matchCheckTest(Y,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 Y=Z.isUnknown()||this.opts.stat?Z.lstatSync():Z;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let Q=Y.realpathSync();if(Q&&(Q?.isUnknown()||this.opts.stat))Q.lstatSync()}return this.matchCheckTest(Y,J)}matchFinish(Z,J){if(this.#X(Z))return;if(!this.includeChildMatches&&this.#J?.add){let Y=`${Z.relativePosix()}/**`;this.#J.add(Y)}let X=this.opts.absolute===void 0?J:this.opts.absolute;this.seen.add(Z);let $=this.opts.mark&&Z.isDirectory()?this.#$:"";if(this.opts.withFileTypes)this.matchEmit(Z);else if(X){let Y=this.opts.posix?Z.fullpathPosix():Z.fullpath();this.matchEmit(Y+$)}else{let Y=this.opts.posix?Z.relativePosix():Z.relative(),Q=this.opts.dotRelative&&!Y.startsWith(".."+this.#$)?"."+this.#$:"";this.matchEmit(!Y?"."+$:Q+Y+$)}}async match(Z,J,X){let $=await this.matchCheck(Z,X);if($)this.matchFinish($,J)}matchSync(Z,J,X){let $=this.matchCheckSync(Z,X);if($)this.matchFinish($,J)}walkCB(Z,J,X){if(this.signal?.aborted)X();this.walkCB2(Z,J,new LG(this.opts),X)}walkCB2(Z,J,X,$){if(this.#Y(Z))return $();if(this.signal?.aborted)$();if(this.paused){this.onResume(()=>this.walkCB2(Z,J,X,$));return}X.processPatterns(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;Y++,this.match(K,W,G).then(()=>Q())}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;Y++;let W=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,W,X,Q);else K.readdirCB((G,z)=>this.walkCB3(K,z,X,Q),!0)}Q()}walkCB3(Z,J,X,$){X=X.filterEntries(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;Y++,this.match(K,W,G).then(()=>Q())}for(let[K,W]of X.subwalks.entries())Y++,this.walkCB2(K,W,X.child(),Q);Q()}walkCBSync(Z,J,X){if(this.signal?.aborted)X();this.walkCB2Sync(Z,J,new LG(this.opts),X)}walkCB2Sync(Z,J,X,$){if(this.#Y(Z))return $();if(this.signal?.aborted)$();if(this.paused){this.onResume(()=>this.walkCB2Sync(Z,J,X,$));return}X.processPatterns(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};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;Y++;let W=K.readdirSync();this.walkCB3Sync(K,W,X,Q)}Q()}walkCB3Sync(Z,J,X,$){X=X.filterEntries(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};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())Y++,this.walkCB2Sync(K,W,X.child(),Q);Q()}}class AF extends YR{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 mF extends YR{results;constructor(Z,J,X){super(Z,J,X);this.results=new C$({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 Ex1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Q7{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 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=kx1(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 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 TypeError("base matching requires globstar");Z=Z.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Z,this.platform=J.platform||Ex1,this.opts={...J,platform:this.platform},J.scurry){if(this.scurry=J.scurry,J.nocase!==void 0&&J.nocase!==J.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=J.platform==="win32"?UG:J.platform==="darwin"?bF:J.platform?jG:Fg;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",$={...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},Y=this.pattern.map((W)=>new V4(W,$)),[Q,K]=Y.reduce((W,G)=>{return W[0].push(...G.set),W[1].push(...G.globParts),W},[[],[]]);this.patterns=Q.map((W,G)=>{let z=K[G];if(!z)throw Error("invalid pattern object");return new Q3(W,z,0,this.platform)})}async walk(){return[...await new AF(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 AF(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 mF(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 mF(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 QR=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new V4(X,J).hasMagic())return!0;return!1};function lF(Z,J={}){return new Q7(Z,J).streamSync()}function Ug(Z,J={}){return new Q7(Z,J).stream()}function jg(Z,J={}){return new Q7(Z,J).walkSync()}async function xg(Z,J={}){return new Q7(Z,J).walk()}function yF(Z,J={}){return new Q7(Z,J).iterateSync()}function Bg(Z,J={}){return new Q7(Z,J).iterate()}var Ix1=lF,_x1=Object.assign(Ug,{sync:lF}),hx1=yF,Sx1=Object.assign(Bg,{sync:yF}),bx1=Object.assign(jg,{stream:lF,iterate:yF}),uF=Object.assign(xg,{glob:xg,globSync:jg,sync:bx1,globStream:Ug,stream:_x1,globStreamSync:lF,streamSync:Ix1,globIterate:Bg,iterate:Sx1,globIterateSync:yF,iterateSync:hx1,Glob:Q7,hasMagic:QR,escape:Z3,unescape:F9});uF.glob=uF;class KR{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 $=this._listeners[Z];if($!==void 0){let Y=$.indexOf(J);if(Y!==-1)$.splice(Y,1)}return this}dispatchEvent(Z){let X=this._listeners[Z.type];if(X!==void 0){let $=X.slice(0);for(let Y=0,Q=$.length;Y<Q;Y++)$[Y].call(this,Z)}return this}dispose(){for(let Z in this._listeners)delete this._listeners[Z]}}class XZ{constructor(Z,J,X,$={}){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=$,!J.isOnGraph(X))throw 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 pF extends KR{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,$){let Y=new XZ(Z,J,X,$);this._edges.add(Y);let Q=Y.getParent();if(!this._parentEdges.has(Q))this._parentEdges.set(Q,new Set);this._parentEdges.get(Q).add(Y);let K=Y.getChild();if(!this._childEdges.has(K))this._childEdges.set(K,new Set);return this._childEdges.get(K).add(Y),Y}_destroyEdge(Z){return this._edges.delete(Z),this._parentEdges.get(Z.getParent()).delete(Z),this._childEdges.get(Z.getChild()).delete(Z),this}}function DG(){return DG=Object.assign||function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)if(Object.prototype.hasOwnProperty.call(X,$))Z[$]=X[$]}return Z},DG.apply(this,arguments)}class x9{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 w1{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 A6{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 H1=Symbol("attributes"),hJ=Symbol("immutableKeys");class iF extends KR{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[H1]=void 0,this[hJ]=void 0,this.graph=Z,this[hJ]=new Set,this[H1]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let $=Z[X];if($ instanceof iF){let Y=this.graph._createEdge(X,this,$);this[hJ].add(X),J[X]=Y}else J[X]=$}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[H1]){let $=this[H1][X];if($ instanceof XZ){let Y=$;if(Y.getChild()===Z)this.setRef(X,J,Y.getAttributes())}else if($ instanceof x9)for(let Y of $.listRefsByChild(Z)){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if($ instanceof w1){let Y=$.getRefByChild(Z);if(Y){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if($ instanceof A6)for(let Y of $.keys()){let Q=$.get(Y);if(Q.getChild()===Z)this.setRefMap(X,Y,J,Q.getAttributes())}}return this}get(Z){return this[H1][Z]}set(Z,J){return this[H1][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[H1][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[hJ].has(Z))throw Error(`Cannot overwrite immutable attribute, "${Z}".`);let $=this[H1][Z];if($)$.dispose();if(!J)return this;let Y=this.graph._createEdge(Z,this,J,X);return this[H1][Z]=Y,this.dispatchEvent({type:"change",attribute:Z})}listRefs(Z){return this.assertRefList(Z).values().map((X)=>X.getChild())}addRef(Z,J,X){let $=this.graph._createEdge(Z,this,J,X);return this.assertRefList(Z).add($),this.dispatchEvent({type:"change",attribute:Z})}removeRef(Z,J){let X=this.assertRefList(Z);if(X instanceof x9)for(let $ of X.listRefsByChild(J))$.dispose();else{let $=X.getRefByChild(J);if($)$.dispose()}return this}assertRefList(Z){let J=this[H1][Z];if(J instanceof x9||J instanceof w1)return J;throw 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 $=this.assertRefMap(Z).get(J);return $?$.getChild():null}setRefMap(Z,J,X,$){let Y=this.assertRefMap(Z),Q=Y.get(J);if(Q)Q.dispose();if(!X)return this;$=Object.assign($||{},{key:J});let K=this.graph._createEdge(Z,this,X,DG({},$,{key:J}));return Y.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[H1][Z];if(J instanceof A6)return J;throw Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(DG({},Z,{target:this})),this.graph.dispatchEvent(DG({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[H1][J]===Z){if(this[H1][J]=null,this[hJ].has(J))Z.getChild().dispose()}else if(this[H1][J]instanceof x9)this[H1][J].remove(Z);else if(this[H1][J]instanceof w1)this[H1][J].remove(Z);else if(this[H1][J]instanceof A6){let X=this[H1][J];for(let $ of X.keys())if(X.get($)===Z)X.delete($)}else return;this.graph._destroyEdge(Z),this.dispatchEvent({type:"change",attribute:J})}}var Og="v4.2.1",E$="@glb.bin",i;(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"})(i||(i={}));var oF;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(oF||(oF={}));var h5;(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"})(h5||(h5={}));var v5;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(v5||(v5={}));var $Z;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})($Z||($Z={}));var bJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array};class E0{static createBufferFromDataURI(Z){if(typeof Buffer>"u"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let $=0;$<J.length;$++)X[$]=J.charCodeAt($);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 Y of Z)J+=Y.byteLength;let X=new Uint8Array(J),$=0;for(let Y 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 $=new Uint8Array(X);if($.set(Z),J!==0)for(let Y=Z.byteLength;Y<X;Y++)$[Y]=J;return $}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 Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class HR{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^$*255<<8^Y*255<<0}static convertSRGBToLinear(Z,J){let X=Z,$=J;for(let Y=0;Y<3;Y++)$[Y]=X[Y]<0.04045?X[Y]*0.0773993808:Math.pow(X[Y]*0.9478672986+0.0521327014,2.4);return J}static convertLinearToSRGB(Z,J){let X=Z,$=J;for(let Y=0;Y<3;Y++)$[Y]=X[Y]<0.0031308?X[Y]*12.92:1.055*Math.pow(X[Y],0.41666)-0.055;return J}}class Tg{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,$;while(J.byteLength){if(X=J.getUint16(0,!1),Ax1(J,X),$=J.getUint8(X+1),$===192||$===193||$===194)return[J.getUint16(X+7,!1),J.getUint16(X+5,!1)];J=new DataView(Z.buffer,J.byteOffset+X+2)}throw TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class eF{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(E0.decodeText(Z.slice(12,16))===eF.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}}eF.PNG_FRIED_CHUNK_NAME="CgBI";class _5{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,$=4,Y=this.getSize(Z,J);if(!Y)return null;while(Y[0]>1||Y[1]>1)X+=Y[0]*Y[1]*$,Y[0]=Math.max(Math.floor(Y[0]/2),1),Y[1]=Math.max(Math.floor(Y[1]/2),1);return X+=1*$,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}`}}_5.impls={"image/jpeg":new Tg,"image/png":new eF};function Ax1(Z,J){if(J>Z.byteLength)throw TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw TypeError("Invalid JPG, marker table corrupted");return Z}class YZ{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 _5.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()}}var GR=typeof Float32Array<"u"?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 mx1(){var Z=new GR(3);if(GR!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function WR(Z){var J=Z[0],X=Z[1],$=Z[2];return Math.hypot(J,X,$)}function ux1(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=X[3]*$+X[7]*Y+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*$+X[4]*Y+X[8]*Q+X[12])/K,Z[1]=(X[1]*$+X[5]*Y+X[9]*Q+X[13])/K,Z[2]=(X[2]*$+X[6]*Y+X[10]*Q+X[14])/K,Z}(function(){var Z=mx1();return function(J,X,$,Y,Q,K){var W,G;if(!X)X=3;if(!$)$=0;if(Y)G=Math.min(Y*X+$,J.length);else G=J.length;for(W=$;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 PG(Z){let J=Cg(),X=Z.propertyType===i.NODE?[Z]:Z.listChildren();for(let $ of X)$.traverse((Y)=>{let Q=Y.getMesh();if(!Q)return;let K=lx1(Q,Y.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))zR(K.min,J),zR(K.max,J)});return J}function lx1(Z,J){let X=Cg();for(let $ of Z.listPrimitives()){let Y=$.getAttribute("POSITION"),Q=$.getIndices();if(!Y)continue;let K=[0,0,0],W=[0,0,0];for(let G=0,z=Q?Q.getCount():Y.getCount();G<z;G++){let v=Q?Q.getScalar(G):G;K=Y.getElement(v,K),W=ux1(W,K,J),zR(W,X)}}return X}function zR(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 Cg(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}var Lg="https://null.example";class F4{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return YZ.basename(new URL(Z,Lg).pathname)}static extension(Z){return YZ.extension(new URL(Z,Lg).pathname)}static resolve(Z,J){if(!this.isRelativePath(J))return J;let X=Z.split("/"),$=J.split("/");X.pop();for(let Y=0;Y<$.length;Y++){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)}}F4.DEFAULT_INIT={};F4.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;function Dg(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function k$(Z){if(Dg(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(Dg(X)===!1)return!1;if(Object.hasOwn(X,"isPrototypeOf")===!1)return!1;return!0}var vR,MG;(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"})(MG||(MG={}));class z5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=z5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=z5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=z5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=z5.Verbosity.ERROR)console.error(Z)}}vR=z5;z5.Verbosity=MG;z5.DEFAULT_INSTANCE=new vR(vR.Verbosity.INFO);function yx1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],z=Z[8],v=Z[9],H=Z[10],V=Z[11],q=Z[12],F=Z[13],w=Z[14],c=Z[15],x=J*K-X*Q,j=J*W-$*Q,B=J*G-Y*Q,L=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,P=z*F-v*q,N=z*w-H*q,O=z*c-V*q,k=v*w-H*F,E=v*c-V*F,S=H*c-V*w;return x*S-j*E+B*k+L*O-R*N+M*P}function px1(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],z=J[6],v=J[7],H=J[8],V=J[9],q=J[10],F=J[11],w=J[12],c=J[13],x=J[14],j=J[15],B=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=B*$+L*W+R*H+M*w,Z[1]=B*Y+L*G+R*V+M*c,Z[2]=B*Q+L*z+R*q+M*x,Z[3]=B*K+L*v+R*F+M*j,B=X[4],L=X[5],R=X[6],M=X[7],Z[4]=B*$+L*W+R*H+M*w,Z[5]=B*Y+L*G+R*V+M*c,Z[6]=B*Q+L*z+R*q+M*x,Z[7]=B*K+L*v+R*F+M*j,B=X[8],L=X[9],R=X[10],M=X[11],Z[8]=B*$+L*W+R*H+M*w,Z[9]=B*Y+L*G+R*V+M*c,Z[10]=B*Q+L*z+R*q+M*x,Z[11]=B*K+L*v+R*F+M*j,B=X[12],L=X[13],R=X[14],M=X[15],Z[12]=B*$+L*W+R*H+M*w,Z[13]=B*Y+L*G+R*V+M*c,Z[14]=B*Q+L*z+R*q+M*x,Z[15]=B*K+L*v+R*F+M*j,Z}function ix1(Z,J){var X=J[0],$=J[1],Y=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],z=J[9],v=J[10];return Z[0]=Math.hypot(X,$,Y),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,z,v),Z}function gx1(Z,J){var X=new GR(3);ix1(X,J);var $=1/X[0],Y=1/X[1],Q=1/X[2],K=J[0]*$,W=J[1]*Y,G=J[2]*Q,z=J[4]*$,v=J[5]*Y,H=J[6]*Q,V=J[8]*$,q=J[9]*Y,F=J[10]*Q,w=K+v+F,c=0;if(w>0)c=Math.sqrt(w+1)*2,Z[3]=0.25*c,Z[0]=(H-q)/c,Z[1]=(V-G)/c,Z[2]=(W-z)/c;else if(K>v&&K>F)c=Math.sqrt(1+K-v-F)*2,Z[3]=(H-q)/c,Z[0]=0.25*c,Z[1]=(W+z)/c,Z[2]=(V+G)/c;else if(v>F)c=Math.sqrt(1+v-K-F)*2,Z[3]=(V-G)/c,Z[0]=(W+z)/c,Z[1]=0.25*c,Z[2]=(H+q)/c;else c=Math.sqrt(1+F-K-v)*2,Z[3]=(W-z)/c,Z[0]=(V+G)/c,Z[1]=(H+q)/c,Z[2]=0.25*c;return Z}class I0{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let $=0;$<Z.length;$++)if(Math.abs(Z[$]-J[$])>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 Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(I0.clamp(Z,0,1)*65535);case 5121:return Math.round(I0.clamp(Z,0,1)*255);case 5122:return Math.round(I0.clamp(Z,-1,1)*32767);case 5120:return Math.round(I0.clamp(Z,-1,1)*127);default:throw Error("Invalid component type.")}}static decompose(Z,J,X,$){let Y=WR([Z[0],Z[1],Z[2]]),Q=WR([Z[4],Z[5],Z[6]]),K=WR([Z[8],Z[9],Z[10]]);if(yx1(Z)<0)Y=-Y;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),z=1/Y,v=1/Q,H=1/K;G[0]*=z,G[1]*=z,G[2]*=z,G[4]*=v,G[5]*=v,G[6]*=v,G[8]*=H,G[9]*=H,G[10]*=H,gx1(X,G),$[0]=Y,$[1]=Q,$[2]=K}static compose(Z,J,X,$){let Y=$,Q=J[0],K=J[1],W=J[2],G=J[3],z=Q+Q,v=K+K,H=W+W,V=Q*z,q=Q*v,F=Q*H,w=K*v,c=K*H,x=W*H,j=G*z,B=G*v,L=G*H,R=X[0],M=X[1],P=X[2];return Y[0]=(1-(w+x))*R,Y[1]=(q+L)*R,Y[2]=(F-B)*R,Y[3]=0,Y[4]=(q-L)*M,Y[5]=(1-(V+x))*M,Y[6]=(c+j)*M,Y[7]=0,Y[8]=(F+B)*P,Y[9]=(c-j)*P,Y[10]=(1-(V+w))*P,Y[11]=0,Y[12]=Z[0],Y[13]=Z[1],Y[14]=Z[2],Y[15]=1,Y}}function dx1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),$=J.getChild();return X===$||X.equals($)}function ax1(Z,J){if(!!Z!==!!J)return!1;let X=Z.values(),$=J.values();if(X.length!==$.length)return!1;for(let Y=0;Y<X.length;Y++){let Q=X[Y],K=$[Y];if(Q.getChild()===K.getChild())continue;if(!Q.getChild().equals(K.getChild()))return!1}return!0}function nx1(Z,J){if(!!Z!==!!J)return!1;let X=Z.keys(),$=J.keys();if(X.length!==$.length)return!1;for(let Y of X){let Q=Z.get(Y),K=J.get(Y);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 fg(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 kg(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!k$(Z)||!k$(J))return Z===J;let X=Z,$=J,Y=0,Q=0,K;for(K in X)Y++;for(K in $)Q++;if(Y!==Q)return!1;for(K in X){let W=X[K],G=$[K];if(rF(W)&&rF(G)){if(!fg(W,G))return!1}else if(k$(W)&&k$(G)){if(!kg(W,G))return!1}else if(W!==G)return!1}return!0}function rF(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Mg="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",sx1=999,ox1=6,Rg=new Set,rx1=function(){let J="";for(let X=0;X<ox1;X++)J+=Mg.charAt(Math.floor(Math.random()*Mg.length));return J},Eg=function(){for(let J=0;J<sx1;J++){let X=rx1();if(!Rg.has(X))return Rg.add(X),X}return""},SJ=(Z)=>Z,tx1=new Set;class Zw extends iF{constructor(Z,J=""){super(Z);this[H1].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,SJ)}copy(Z,J=SJ){for(let X in this[H1]){let $=this[H1][X];if($ instanceof XZ){if(!this[hJ].has(X))$.dispose()}else if($ instanceof x9||$ instanceof w1)for(let Y of $.values())Y.dispose();else if($ instanceof A6)for(let Y of $.values())Y.dispose()}for(let X in Z[H1]){let $=this[H1][X],Y=Z[H1][X];if(Y instanceof XZ)if(this[hJ].has(X))$.getChild().copy(J(Y.getChild()),J);else this.setRef(X,J(Y.getChild()),Y.getAttributes());else if(Y instanceof w1||Y instanceof x9)for(let Q of Y.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if(Y instanceof A6)for(let Q of Y.keys()){let K=Y.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(k$(Y))this[H1][X]=JSON.parse(JSON.stringify(Y));else if(Array.isArray(Y)||Y instanceof ArrayBuffer||ArrayBuffer.isView(Y))this[H1][X]=Y.slice();else this[H1][X]=Y}return this}equals(Z,J=tx1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[H1]){if(J.has(X))continue;let $=this[H1][X],Y=Z[H1][X];if($ instanceof XZ||Y instanceof XZ){if(!dx1($,Y))return!1}else if($ instanceof w1||Y instanceof w1||$ instanceof x9||Y instanceof x9){if(!ax1($,Y))return!1}else if($ instanceof A6||Y instanceof A6){if(!nx1($,Y))return!1}else if(k$($)||k$(Y)){if(!kg($,Y))return!1}else if(rF($)||rF(Y)){if(!fg($,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 x6 extends Zw{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new A6})}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 K0 extends x6{init(){this.propertyType=i.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:K0.Type.SCALAR,componentType:K0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case K0.Type.SCALAR:return 1;case K0.Type.VEC2:return 2;case K0.Type.VEC3:return 3;case K0.Type.VEC4:return 4;case K0.Type.MAT2:return 4;case K0.Type.MAT3:return 9;case K0.Type.MAT4:return 16;default:throw Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case K0.ComponentType.BYTE:return 1;case K0.ComponentType.UNSIGNED_BYTE:return 1;case K0.ComponentType.SHORT:return 2;case K0.ComponentType.UNSIGNED_SHORT:return 2;case K0.ComponentType.UNSIGNED_INT:return 4;case K0.ComponentType.FLOAT:return 4;default:throw Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),$=this.getComponentType();if(this.getMin(Z),J)for(let Y=0;Y<X;Y++)Z[Y]=I0.decodeNormalizedInt(Z[Y],$);return Z}getMin(Z){let J=this.getArray(),X=this.getCount(),$=this.getElementSize();for(let Y=0;Y<$;Y++)Z[Y]=1/0;for(let Y=0;Y<X*$;Y+=$)for(let Q=0;Q<$;Q++){let K=J[Y+Q];if(Number.isFinite(K))Z[Q]=Math.min(Z[Q],K)}return Z}getMaxNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),$=this.getComponentType();if(this.getMax(Z),J)for(let Y=0;Y<X;Y++)Z[Y]=I0.decodeNormalizedInt(Z[Y],$);return Z}getMax(Z){let J=this.get("array"),X=this.getCount(),$=this.getElementSize();for(let Y=0;Y<$;Y++)Z[Y]=-1/0;for(let Y=0;Y<X*$;Y+=$)for(let Q=0;Q<$;Q++){let K=J[Y+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 K0.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(),$=this.getArray();if(this.getNormalized())return I0.decodeNormalizedInt($[Z*J],X);return $[Z*J]}setScalar(Z,J){let X=this.getElementSize(),$=this.getComponentType(),Y=this.getArray();if(this.getNormalized())Y[Z*X]=I0.encodeNormalizedInt(J,$);else Y[Z*X]=J;return this}getElement(Z,J){let X=this.getNormalized(),$=this.getElementSize(),Y=this.getComponentType(),Q=this.getArray();for(let K=0;K<$;K++)if(X)J[K]=I0.decodeNormalizedInt(Q[Z*$+K],Y);else J[K]=Q[Z*$+K];return J}setElement(Z,J){let X=this.getNormalized(),$=this.getElementSize(),Y=this.getComponentType(),Q=this.getArray();for(let K=0;K<$;K++)if(X)Q[Z*$+K]=I0.encodeNormalizedInt(J[K],Y);else Q[Z*$+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?ex1(Z):K0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}K0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};K0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function ex1(Z){switch(Z.constructor){case Float32Array:return K0.ComponentType.FLOAT;case Uint32Array:return K0.ComponentType.UNSIGNED_INT;case Uint16Array:return K0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return K0.ComponentType.UNSIGNED_BYTE;case Int16Array:return K0.ComponentType.SHORT;case Int8Array:return K0.ComponentType.BYTE;default:throw Error("Unknown accessor componentType.")}}class qR extends x6{init(){this.propertyType=i.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new w1,samplers:new w1})}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 QZ extends x6{init(){this.propertyType=i.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)}}QZ.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class AJ extends x6{init(){this.propertyType=i.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:AJ.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:h5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:h5.OTHER})}}AJ.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class FR extends x6{init(){this.propertyType=i.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class I$ extends x6{init(){this.propertyType=i.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:I$.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)}}I$.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class O1 extends Zw{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}O1.EXTENSION_NAME=void 0;class F1 extends x6{init(){this.propertyType=i.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:F1.WrapMode.REPEAT,wrapT:F1.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)}}F1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};F1.MagFilter={NEAREST:9728,LINEAR:9729};F1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:gF,G:dF,B:aF,A:ZU1}=v5;class K7 extends x6{init(){this.propertyType=i.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:K7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new F1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new F1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new F1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new F1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new F1(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:gF|dF|aF|ZU1,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:gF|dF|aF,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:gF|dF|aF})}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:gF})}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:dF|aF})}}K7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class NG extends x6{init(){this.propertyType=i.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new w1})}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 Jw extends x6{init(){this.propertyType=i.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 w1})}copy(Z,J=SJ){if(J===SJ)throw 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 I0.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),$=this.get("scale").slice();return I0.decompose(Z,J,X,$),this.set("translation",J).set("rotation",X).set("scale",$)}getWorldTranslation(){let Z=[0,0,0];return I0.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return I0.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return I0.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],Z),Z}getWorldMatrix(){let Z=[];for(let $=this;$!=null;$=$.getParentNode())Z.push($);let J,X=Z.pop().getMatrix();while(J=Z.pop())px1(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===i.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===i.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 g1 extends x6{init(){this.propertyType=i.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:g1.Mode.TRIANGLES,material:null,indices:null,attributes:new A6,targets:new w1})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:h5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:h5.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)}}g1.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class wR extends Zw{init(){this.propertyType=i.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new A6})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:h5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function m6(){return m6=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)({}).hasOwnProperty.call(X,$)&&(Z[$]=X[$])}return Z},m6.apply(null,arguments)}class K3 extends x6{init(){this.propertyType=i.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new w1})}copy(Z,J=SJ){if(J===SJ)throw 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 cR extends x6{init(){this.propertyType=i.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new w1})}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:h5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class _$ extends x6{init(){this.propertyType=i.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||_5.extensionToMimeType(YZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=_5.extensionToMimeType(YZ.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",E0.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return _5.getSize(Z,this.getMimeType())}}class W3 extends x6{init(){this.propertyType=i.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Og}`,version:"2.0"},defaultScene:null,accessors:new w1,animations:new w1,buffers:new w1,cameras:new w1,materials:new w1,meshes:new w1,nodes:new w1,scenes:new w1,skins:new w1,textures:new w1})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw Error("Root cannot be cloned.")}copy(Z,J=SJ){if(J===SJ)throw Error("Root cannot be copied.");this.set("asset",m6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(m6({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let $=Z.getExtension(X);this.setExtension(X,J($))}return this}_addChildOfRoot(Z){if(Z instanceof K3)this.addRef("scenes",Z);else if(Z instanceof Jw)this.addRef("nodes",Z);else if(Z instanceof I$)this.addRef("cameras",Z);else if(Z instanceof cR)this.addRef("skins",Z);else if(Z instanceof NG)this.addRef("meshes",Z);else if(Z instanceof K7)this.addRef("materials",Z);else if(Z instanceof _$)this.addRef("textures",Z);else if(Z instanceof qR)this.addRef("animations",Z);else if(Z instanceof K0)this.addRef("accessors",Z);else if(Z instanceof FR)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 c6{static fromGraph(Z){return c6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new pF,this._root=new W3(this._graph),this._logger=z5.DEFAULT_INSTANCE,c6._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 Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw 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(($)=>$.extensionName===J)||new Z(this)}createScene(Z=""){return new K3(this._graph,Z)}createNode(Z=""){return new Jw(this._graph,Z)}createCamera(Z=""){return new I$(this._graph,Z)}createSkin(Z=""){return new cR(this._graph,Z)}createMesh(Z=""){return new NG(this._graph,Z)}createPrimitive(){return new g1(this._graph)}createPrimitiveTarget(Z=""){return new wR(this._graph,Z)}createMaterial(Z=""){return new K7(this._graph,Z)}createTexture(Z=""){return new _$(this._graph,Z)}createAnimation(Z=""){return new qR(this._graph,Z)}createAnimationChannel(Z=""){return new QZ(this._graph,Z)}createAnimationSampler(Z=""){return new AJ(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new K0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new FR(this._graph,Z)}}c6._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 $=X,Y=$.target;if(Y instanceof O1&&Y.extensionName===this.extensionName){if($.type==="node:create")this._addExtensionProperty(Y);if($.type==="node:dispose")this._removeExtensionProperty(Y)}};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;class Ig{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 $=this.jsonDoc.json.samplers[X.sampler];if($.magFilter!==void 0)Z.setMagFilter($.magFilter);if($.minFilter!==void 0)Z.setMinFilter($.minFilter);if($.wrapS!==void 0)Z.setWrapS($.wrapS);if($.wrapT!==void 0)Z.setWrapT($.wrapT)}}var Pg={logger:z5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},JU1=new Set([i.BUFFER,i.TEXTURE,i.MATERIAL,i.MESH,i.PRIMITIVE,i.NODE,i.SCENE]);class _g{static read(Z,J=Pg){let X=m6({},Pg,J),{json:$}=Z,Y=new c6().setLogger(X.logger);this.validate(Z,X);let Q=new Ig(Z),K=$.asset,W=Y.getRoot().getAsset();if(K.copyright)W.copyright=K.copyright;if(K.extras)W.extras=K.extras;if($.extras!==void 0)Y.getRoot().setExtras(m6({},$.extras));let G=$.extensionsUsed||[],z=$.extensionsRequired||[];X.extensions.sort((M,P)=>M.EXTENSION_NAME>P.EXTENSION_NAME?1:-1);for(let M of X.extensions)if(G.includes(M.EXTENSION_NAME)){let P=Y.createExtension(M).setRequired(z.includes(M.EXTENSION_NAME)),N=P.prereadTypes.filter((O)=>!JU1.has(O));if(N.length)X.logger.warn(`Preread hooks for some types (${N.join()}), requested by extension ${P.extensionName}, are unsupported. Please file an issue or a PR.`);for(let O of P.readDependencies)P.install(O,X.dependencies[O])}let v=$.buffers||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.BUFFER)).forEach((M)=>M.preread(Q,i.BUFFER)),Q.buffers=v.map((M)=>{let P=Y.createBuffer(M.name);if(M.extras)P.setExtras(M.extras);if(M.uri&&M.uri.indexOf("__")!==0)P.setURI(M.uri);return P});let H=$.bufferViews||[];Q.bufferViewBuffers=H.map((M,P)=>{if(!Q.bufferViews[P]){let N=Z.json.buffers[M.buffer],O=N.uri?Z.resources[N.uri]:Z.resources[E$],k=M.byteOffset||0;Q.bufferViews[P]=E0.toView(O,k,M.byteLength)}return Q.buffers[M.buffer]});let V=$.accessors||[];Q.accessors=V.map((M)=>{let P=Q.bufferViewBuffers[M.bufferView],N=Y.createAccessor(M.name,P).setType(M.type);if(M.extras)N.setExtras(M.extras);if(M.normalized!==void 0)N.setNormalized(M.normalized);if(M.bufferView===void 0)return N;return N.setArray(sF(M,Q)),N});let q=$.images||[],F=$.textures||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.TEXTURE)).forEach((M)=>M.preread(Q,i.TEXTURE)),Q.textures=q.map((M)=>{let P=Y.createTexture(M.name);if(M.extras)P.setExtras(M.extras);if(M.bufferView!==void 0){let N=$.bufferViews[M.bufferView],O=Z.json.buffers[N.buffer],k=O.uri?Z.resources[O.uri]:Z.resources[E$],E=N.byteOffset||0,S=N.byteLength,f=k.slice(E,E+S);P.setImage(f)}else if(M.uri!==void 0){if(P.setImage(Z.resources[M.uri]),M.uri.indexOf("__")!==0)P.setURI(M.uri)}if(M.mimeType!==void 0)P.setMimeType(M.mimeType);else if(M.uri){let N=YZ.extension(M.uri);P.setMimeType(_5.extensionToMimeType(N))}return P}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.MATERIAL)).forEach((M)=>M.preread(Q,i.MATERIAL));let w=$.materials||[];Q.materials=w.map((M)=>{let P=Y.createMaterial(M.name);if(M.extras)P.setExtras(M.extras);if(M.alphaMode!==void 0)P.setAlphaMode(M.alphaMode);if(M.alphaCutoff!==void 0)P.setAlphaCutoff(M.alphaCutoff);if(M.doubleSided!==void 0)P.setDoubleSided(M.doubleSided);let N=M.pbrMetallicRoughness||{};if(N.baseColorFactor!==void 0)P.setBaseColorFactor(N.baseColorFactor);if(M.emissiveFactor!==void 0)P.setEmissiveFactor(M.emissiveFactor);if(N.metallicFactor!==void 0)P.setMetallicFactor(N.metallicFactor);if(N.roughnessFactor!==void 0)P.setRoughnessFactor(N.roughnessFactor);if(N.baseColorTexture!==void 0){let O=N.baseColorTexture,k=Q.textures[F[O.index].source];P.setBaseColorTexture(k),Q.setTextureInfo(P.getBaseColorTextureInfo(),O)}if(M.emissiveTexture!==void 0){let O=M.emissiveTexture,k=Q.textures[F[O.index].source];P.setEmissiveTexture(k),Q.setTextureInfo(P.getEmissiveTextureInfo(),O)}if(M.normalTexture!==void 0){let O=M.normalTexture,k=Q.textures[F[O.index].source];if(P.setNormalTexture(k),Q.setTextureInfo(P.getNormalTextureInfo(),O),M.normalTexture.scale!==void 0)P.setNormalScale(M.normalTexture.scale)}if(M.occlusionTexture!==void 0){let O=M.occlusionTexture,k=Q.textures[F[O.index].source];if(P.setOcclusionTexture(k),Q.setTextureInfo(P.getOcclusionTextureInfo(),O),M.occlusionTexture.strength!==void 0)P.setOcclusionStrength(M.occlusionTexture.strength)}if(N.metallicRoughnessTexture!==void 0){let O=N.metallicRoughnessTexture,k=Q.textures[F[O.index].source];P.setMetallicRoughnessTexture(k),Q.setTextureInfo(P.getMetallicRoughnessTextureInfo(),O)}return P}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.MESH)).forEach((M)=>M.preread(Q,i.MESH));let c=$.meshes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.PRIMITIVE)).forEach((M)=>M.preread(Q,i.PRIMITIVE)),Q.meshes=c.map((M)=>{let P=Y.createMesh(M.name);if(M.extras)P.setExtras(M.extras);if(M.weights!==void 0)P.setWeights(M.weights);return(M.primitives||[]).forEach((O)=>{let k=Y.createPrimitive();if(O.extras)k.setExtras(O.extras);if(O.material!==void 0)k.setMaterial(Q.materials[O.material]);if(O.mode!==void 0)k.setMode(O.mode);for(let[f,C]of Object.entries(O.attributes||{}))k.setAttribute(f,Q.accessors[C]);if(O.indices!==void 0)k.setIndices(Q.accessors[O.indices]);let E=M.extras&&M.extras.targetNames||[];(O.targets||[]).forEach((f,C)=>{let h=E[C]||C.toString(),_=Y.createPrimitiveTarget(h);for(let[a,s]of Object.entries(f))_.setAttribute(a,Q.accessors[s]);k.addTarget(_)}),P.addPrimitive(k)}),P});let x=$.cameras||[];Q.cameras=x.map((M)=>{let P=Y.createCamera(M.name).setType(M.type);if(M.extras)P.setExtras(M.extras);if(M.type===I$.Type.PERSPECTIVE){let N=M.perspective;if(P.setYFov(N.yfov),P.setZNear(N.znear),N.zfar!==void 0)P.setZFar(N.zfar);if(N.aspectRatio!==void 0)P.setAspectRatio(N.aspectRatio)}else{let N=M.orthographic;P.setZNear(N.znear).setZFar(N.zfar).setXMag(N.xmag).setYMag(N.ymag)}return P});let j=$.nodes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.NODE)).forEach((M)=>M.preread(Q,i.NODE)),Q.nodes=j.map((M)=>{let P=Y.createNode(M.name);if(M.extras)P.setExtras(M.extras);if(M.translation!==void 0)P.setTranslation(M.translation);if(M.rotation!==void 0)P.setRotation(M.rotation);if(M.scale!==void 0)P.setScale(M.scale);if(M.matrix!==void 0){let N=[0,0,0],O=[0,0,0,1],k=[1,1,1];I0.decompose(M.matrix,N,O,k),P.setTranslation(N),P.setRotation(O),P.setScale(k)}if(M.weights!==void 0)P.setWeights(M.weights);return P});let B=$.skins||[];Q.skins=B.map((M)=>{let P=Y.createSkin(M.name);if(M.extras)P.setExtras(M.extras);if(M.inverseBindMatrices!==void 0)P.setInverseBindMatrices(Q.accessors[M.inverseBindMatrices]);if(M.skeleton!==void 0)P.setSkeleton(Q.nodes[M.skeleton]);for(let N of M.joints)P.addJoint(Q.nodes[N]);return P}),j.map((M,P)=>{let N=Q.nodes[P];if((M.children||[]).forEach((k)=>N.addChild(Q.nodes[k])),M.mesh!==void 0)N.setMesh(Q.meshes[M.mesh]);if(M.camera!==void 0)N.setCamera(Q.cameras[M.camera]);if(M.skin!==void 0)N.setSkin(Q.skins[M.skin])});let L=$.animations||[];Q.animations=L.map((M)=>{let P=Y.createAnimation(M.name);if(M.extras)P.setExtras(M.extras);let O=(M.samplers||[]).map((E)=>{let S=Y.createAnimationSampler().setInput(Q.accessors[E.input]).setOutput(Q.accessors[E.output]).setInterpolation(E.interpolation||AJ.Interpolation.LINEAR);if(E.extras)S.setExtras(E.extras);return P.addSampler(S),S});return(M.channels||[]).forEach((E)=>{let S=Y.createAnimationChannel().setSampler(O[E.sampler]).setTargetPath(E.target.path);if(E.target.node!==void 0)S.setTargetNode(Q.nodes[E.target.node]);if(E.extras)S.setExtras(E.extras);P.addChannel(S)}),P});let R=$.scenes||[];if(Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.SCENE)).forEach((M)=>M.preread(Q,i.SCENE)),Q.scenes=R.map((M)=>{let P=Y.createScene(M.name);if(M.extras)P.setExtras(M.extras);return(M.nodes||[]).map((O)=>Q.nodes[O]).forEach((O)=>P.addChild(O)),P}),$.scene!==void 0)Y.getRoot().setDefaultScene(Q.scenes[$.scene]);return Y.getRoot().listExtensionsUsed().forEach((M)=>M.read(Q)),V.forEach((M,P)=>{let N=Q.accessors[P],O=!!M.sparse,k=!M.bufferView&&!N.getArray();if(O||k)N.setSparse(!0).setArray($U1(M,Q))}),Y}static validate(Z,J){let X=Z.json;if(X.asset.version!=="2.0")throw Error(`Unsupported glTF version, "${X.asset.version}".`);if(X.extensionsRequired){for(let $ of X.extensionsRequired)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))throw Error(`Missing required extension, "${$}".`)}if(X.extensionsUsed){for(let $ of X.extensionsUsed)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))J.logger.warn(`Missing optional extension, "${$}".`)}}}function XU1(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=bJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=Z.byteOffset||0,z=new Q(Z.count*K),v=new DataView($.buffer,$.byteOffset,$.byteLength),H=Y.byteStride;for(let V=0;V<Z.count;V++)for(let q=0;q<K;q++){let F=G+V*H+q*W,w;switch(Z.componentType){case K0.ComponentType.FLOAT:w=v.getFloat32(F,!0);break;case K0.ComponentType.UNSIGNED_INT:w=v.getUint32(F,!0);break;case K0.ComponentType.UNSIGNED_SHORT:w=v.getUint16(F,!0);break;case K0.ComponentType.UNSIGNED_BYTE:w=v.getUint8(F);break;case K0.ComponentType.SHORT:w=v.getInt16(F,!0);break;case K0.ComponentType.BYTE:w=v.getInt8(F);break;default:throw Error(`Unexpected componentType "${Z.componentType}".`)}z[V*K+q]=w}return z}function sF(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=bJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if(Y.byteStride!==void 0&&Y.byteStride!==G)return XU1(Z,J);let z=$.byteOffset+(Z.byteOffset||0),v=Z.count*K*W;return new Q($.buffer.slice(z,z+v))}function $U1(Z,J){let X=bJ[Z.componentType],$=K0.getElementSize(Z.type),Y;if(Z.bufferView!==void 0)Y=sF(Z,J);else Y=new X(Z.count*$);let Q=Z.sparse;if(!Q)return Y;let K=Q.count,W=m6({},Z,Q.indices,{count:K,type:"SCALAR"}),G=m6({},Z,Q.values,{count:K}),z=sF(W,J),v=sF(G,J);for(let H=0;H<W.count;H++)for(let V=0;V<$;V++)Y[z[H]*$+V]=v[H*$+V];return Y}var RG;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(RG||(RG={}));class w4{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 $=Z.getRoot(),Y=$.listBuffers().length,Q=$.listTextures().length;this.bufferURIGenerator=new VR(Y>1,()=>X.basename||"buffer"),this.imageURIGenerator=new VR(Q>1,(K)=>YU1(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()},$=JSON.stringify(X);if(!this.samplerDefIndexMap.has($))this.samplerDefIndexMap.set($,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(X);let Y={source:this.imageIndexMap.get(Z),sampler:this.samplerDefIndexMap.get($)},Q=JSON.stringify(Y);if(!this.textureDefIndexMap.has(Q))this.textureDefIndexMap.set(Q,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(Y);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(($)=>$.getName()==="attributes"&&$.getAttributes().key==="POSITION"||$.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===$Z.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 $=_5.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,$),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let $=this.jsonDoc.resources;if(!(Z in $)){$[Z]=J;return}if(J===$[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let Y=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn(Y);return}throw Error(Y)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return h5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:$}=X.getAttributes();if($)return $;if(X.getParent().propertyType!==i.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return h5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}w4.BufferViewTarget=RG;w4.BufferViewUsage=h5;w4.USAGE_TO_TARGET={[h5.ARRAY_BUFFER]:RG.ARRAY_BUFFER,[h5.ELEMENT_ARRAY_BUFFER]:RG.ELEMENT_ARRAY_BUFFER};class VR{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 YU1(Z,J){let X=Z.getGraph().listParentEdges(J).find(($)=>$.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:nF}=w4,{UNSIGNED_INT:QU1,UNSIGNED_SHORT:KU1,UNSIGNED_BYTE:WU1}=K0.ComponentType,GU1=new Set([i.ACCESSOR,i.BUFFER,i.MATERIAL,i.MESH]);class hg{static write(Z,J){let X=Z.getGraph(),$=Z.getRoot(),Y={asset:m6({generator:`glTF-Transform ${Og}`},$.getAsset()),extras:m6({},$.getExtras())},Q={json:Y,resources:{}},K=new w4(Z,Q,J),W=J.logger||z5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((c)=>c.EXTENSION_NAME)),z=Z.getRoot().listExtensionsUsed().filter((c)=>G.has(c.extensionName)).sort((c,x)=>c.extensionName>x.extensionName?1:-1),v=Z.getRoot().listExtensionsRequired().filter((c)=>G.has(c.extensionName)).sort((c,x)=>c.extensionName>x.extensionName?1:-1);if(z.length<Z.getRoot().listExtensionsUsed().length)W.warn("Some extensions were not registered for I/O, and will not be written.");for(let c of z){let x=c.prewriteTypes.filter((j)=>!GU1.has(j));if(x.length)W.warn(`Prewrite hooks for some types (${x.join()}), requested by extension ${c.extensionName}, are unsupported. Please file an issue or a PR.`);for(let j of c.writeDependencies)c.install(j,J.dependencies[j])}function H(c,x,j,B){let L=[],R=0;for(let N of c){let O=K.createAccessorDef(N);O.bufferView=Y.bufferViews.length;let k=N.getArray(),E=E0.pad(E0.toView(k));O.byteOffset=R,R+=E.byteLength,L.push(E),K.accessorIndexMap.set(N,Y.accessors.length),Y.accessors.push(O)}let M=E0.concat(L),P={buffer:x,byteOffset:j,byteLength:M.byteLength};if(B)P.target=B;return Y.bufferViews.push(P),{buffers:L,byteLength:R}}function V(c,x,j){let B=c[0].getCount(),L=0;for(let O of c){let k=K.createAccessorDef(O);k.bufferView=Y.bufferViews.length,k.byteOffset=L;let E=O.getElementSize(),S=O.getComponentSize();L+=E0.padNumber(E*S),K.accessorIndexMap.set(O,Y.accessors.length),Y.accessors.push(k)}let R=B*L,M=new ArrayBuffer(R),P=new DataView(M);for(let O=0;O<B;O++){let k=0;for(let E of c){let S=E.getElementSize(),f=E.getComponentSize(),C=E.getComponentType(),h=E.getArray();for(let _=0;_<S;_++){let a=O*L+k+_*f,s=h[O*S+_];switch(C){case K0.ComponentType.FLOAT:P.setFloat32(a,s,!0);break;case K0.ComponentType.BYTE:P.setInt8(a,s);break;case K0.ComponentType.SHORT:P.setInt16(a,s,!0);break;case K0.ComponentType.UNSIGNED_BYTE:P.setUint8(a,s);break;case K0.ComponentType.UNSIGNED_SHORT:P.setUint16(a,s,!0);break;case K0.ComponentType.UNSIGNED_INT:P.setUint32(a,s,!0);break;default:throw Error("Unexpected component type: "+C)}}k+=E0.padNumber(S*f)}}let N={buffer:x,byteOffset:j,byteLength:R,byteStride:L,target:w4.BufferViewTarget.ARRAY_BUFFER};return Y.bufferViews.push(N),{byteLength:R,buffers:[new Uint8Array(M)]}}function q(c,x,j){let B=[],L=0,R=new Map,M=-1/0,P=!1;for(let C of c){let h=K.createAccessorDef(C);Y.accessors.push(h),K.accessorIndexMap.set(C,Y.accessors.length-1);let _=[],a=[],s=[],Z0=Array(C.getElementSize()).fill(0);for(let m0=0,N1=C.getCount();m0<N1;m0++){if(C.getElement(m0,s),I0.eq(s,Z0,0))continue;M=Math.max(m0,M),_.push(m0);for(let s0=0;s0<s.length;s0++)a.push(s[s0])}let o=_.length,M0={accessorDef:h,count:o};if(R.set(C,M0),o===0)continue;if(o>C.getCount()/2)P=!0;let R0=bJ[C.getComponentType()];M0.indices=_,M0.values=new R0(a)}if(!Number.isFinite(M))return{buffers:B,byteLength:L};if(P)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let N=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,O=M<255?WU1:M<65535?KU1:QU1,k={buffer:x,byteOffset:j+L,byteLength:0};for(let C of c){let h=R.get(C);if(h.count===0)continue;h.indicesByteOffset=k.byteLength;let _=E0.pad(E0.toView(new N(h.indices)));B.push(_),L+=_.byteLength,k.byteLength+=_.byteLength}Y.bufferViews.push(k);let E=Y.bufferViews.length-1,S={buffer:x,byteOffset:j+L,byteLength:0};for(let C of c){let h=R.get(C);if(h.count===0)continue;h.valuesByteOffset=S.byteLength;let _=E0.pad(E0.toView(h.values));B.push(_),L+=_.byteLength,S.byteLength+=_.byteLength}Y.bufferViews.push(S);let f=Y.bufferViews.length-1;for(let C of c){let h=R.get(C);if(h.count===0)continue;h.accessorDef.sparse={count:h.count,indices:{bufferView:E,byteOffset:h.indicesByteOffset,componentType:O},values:{bufferView:f,byteOffset:h.valuesByteOffset}}}return{buffers:B,byteLength:L}}if(Y.accessors=[],Y.bufferViews=[],Y.samplers=[],Y.textures=[],Y.images=$.listTextures().map((c,x)=>{let j=K.createPropertyDef(c);if(c.getMimeType())j.mimeType=c.getMimeType();let B=c.getImage();if(B)K.createImageData(j,B,c);return K.imageIndexMap.set(c,x),j}),z.filter((c)=>c.prewriteTypes.includes(i.ACCESSOR)).forEach((c)=>c.prewrite(K,i.ACCESSOR)),$.listAccessors().forEach((c)=>{let{accessorUsageGroupedByParent:x,accessorParents:j}=K;if(K.accessorIndexMap.has(c))return;let B=K.getAccessorUsage(c);if(K.addAccessorToUsageGroup(c,B),x.has(B)){let L=X.listParents(c).find((R)=>R.propertyType!==i.ROOT);j.set(c,L)}}),z.filter((c)=>c.prewriteTypes.includes(i.BUFFER)).forEach((c)=>c.prewrite(K,i.BUFFER)),($.listAccessors().length>0||K.otherBufferViews.size>0||$.listTextures().length>0&&J.format===$Z.GLB)&&$.listBuffers().length===0)throw Error("Buffer required for Document resources, but none was found.");if(Y.buffers=[],$.listBuffers().forEach((c,x)=>{let j=K.createPropertyDef(c),B=K.accessorUsageGroupedByParent,L=c.listParents().filter((S)=>S instanceof K0),R=new Set(L.map((S)=>K.accessorParents.get(S))),M=new Map(Array.from(R).map((S,f)=>[S,f])),P={};for(let S of L){var N;if(K.accessorIndexMap.has(S))continue;let f=K.getAccessorUsage(S),C=f;if(B.has(f)){let h=K.accessorParents.get(S);C+=`:${M.get(h)}`}P[N=C]||(P[N]={usage:f,accessors:[]}),P[C].accessors.push(S)}let O=[],k=Y.buffers.length,E=0;for(let{usage:S,accessors:f}of Object.values(P))if(S===nF.ARRAY_BUFFER&&J.vertexLayout===oF.INTERLEAVED){let C=V(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}else if(S===nF.ARRAY_BUFFER)for(let C of f){let h=V([C],k,E);E+=h.byteLength;for(let _ of h.buffers)O.push(_)}else if(S===nF.SPARSE){let C=q(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}else if(S===nF.ELEMENT_ARRAY_BUFFER){let C=w4.BufferViewTarget.ELEMENT_ARRAY_BUFFER,h=H(f,k,E,C);E+=h.byteLength;for(let _ of h.buffers)O.push(_)}else{let C=H(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}if(K.imageBufferViews.length&&x===0){for(let S=0;S<K.imageBufferViews.length;S++)if(Y.bufferViews[Y.images[S].bufferView].byteOffset=E,E+=K.imageBufferViews[S].byteLength,O.push(K.imageBufferViews[S]),E%8){let f=8-E%8;E+=f,O.push(new Uint8Array(f))}}if(K.otherBufferViews.has(c))for(let S of K.otherBufferViews.get(c))Y.bufferViews.push({buffer:k,byteOffset:E,byteLength:S.byteLength}),K.otherBufferViewsIndexMap.set(S,Y.bufferViews.length-1),E+=S.byteLength,O.push(S);if(E){let S;if(J.format===$Z.GLB)S=E$;else S=K.bufferURIGenerator.createURI(c,"bin"),j.uri=S;j.byteLength=E,K.assignResourceURI(S,E0.concat(O),!0)}Y.buffers.push(j),K.bufferIndexMap.set(c,x)}),$.listAccessors().find((c)=>!c.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");z.filter((c)=>c.prewriteTypes.includes(i.MATERIAL)).forEach((c)=>c.prewrite(K,i.MATERIAL)),Y.materials=$.listMaterials().map((c,x)=>{let j=K.createPropertyDef(c);if(c.getAlphaMode()!==K7.AlphaMode.OPAQUE)j.alphaMode=c.getAlphaMode();if(c.getAlphaMode()===K7.AlphaMode.MASK)j.alphaCutoff=c.getAlphaCutoff();if(c.getDoubleSided())j.doubleSided=!0;if(j.pbrMetallicRoughness={},!I0.eq(c.getBaseColorFactor(),[1,1,1,1]))j.pbrMetallicRoughness.baseColorFactor=c.getBaseColorFactor();if(!I0.eq(c.getEmissiveFactor(),[0,0,0]))j.emissiveFactor=c.getEmissiveFactor();if(c.getRoughnessFactor()!==1)j.pbrMetallicRoughness.roughnessFactor=c.getRoughnessFactor();if(c.getMetallicFactor()!==1)j.pbrMetallicRoughness.metallicFactor=c.getMetallicFactor();if(c.getBaseColorTexture()){let B=c.getBaseColorTexture(),L=c.getBaseColorTextureInfo();j.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(B,L)}if(c.getEmissiveTexture()){let B=c.getEmissiveTexture(),L=c.getEmissiveTextureInfo();j.emissiveTexture=K.createTextureInfoDef(B,L)}if(c.getNormalTexture()){let B=c.getNormalTexture(),L=c.getNormalTextureInfo(),R=K.createTextureInfoDef(B,L);if(c.getNormalScale()!==1)R.scale=c.getNormalScale();j.normalTexture=R}if(c.getOcclusionTexture()){let B=c.getOcclusionTexture(),L=c.getOcclusionTextureInfo(),R=K.createTextureInfoDef(B,L);if(c.getOcclusionStrength()!==1)R.strength=c.getOcclusionStrength();j.occlusionTexture=R}if(c.getMetallicRoughnessTexture()){let B=c.getMetallicRoughnessTexture(),L=c.getMetallicRoughnessTextureInfo();j.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(B,L)}return K.materialIndexMap.set(c,x),j}),z.filter((c)=>c.prewriteTypes.includes(i.MESH)).forEach((c)=>c.prewrite(K,i.MESH)),Y.meshes=$.listMeshes().map((c,x)=>{let j=K.createPropertyDef(c),B=null;if(j.primitives=c.listPrimitives().map((L)=>{let R={attributes:{}};R.mode=L.getMode();let M=L.getMaterial();if(M)R.material=K.materialIndexMap.get(M);if(Object.keys(L.getExtras()).length)R.extras=L.getExtras();let P=L.getIndices();if(P)R.indices=K.accessorIndexMap.get(P);for(let N of L.listSemantics())R.attributes[N]=K.accessorIndexMap.get(L.getAttribute(N));for(let N of L.listTargets()){let O={};for(let k of N.listSemantics())O[k]=K.accessorIndexMap.get(N.getAttribute(k));R.targets=R.targets||[],R.targets.push(O)}if(L.listTargets().length&&!B)B=L.listTargets().map((N)=>N.getName());return R}),c.getWeights().length)j.weights=c.getWeights();if(B)j.extras=j.extras||{},j.extras.targetNames=B;return K.meshIndexMap.set(c,x),j}),Y.cameras=$.listCameras().map((c,x)=>{let j=K.createPropertyDef(c);if(j.type=c.getType(),j.type===I$.Type.PERSPECTIVE){j.perspective={znear:c.getZNear(),zfar:c.getZFar(),yfov:c.getYFov()};let B=c.getAspectRatio();if(B!==null)j.perspective.aspectRatio=B}else j.orthographic={znear:c.getZNear(),zfar:c.getZFar(),xmag:c.getXMag(),ymag:c.getYMag()};return K.cameraIndexMap.set(c,x),j}),Y.nodes=$.listNodes().map((c,x)=>{let j=K.createPropertyDef(c);if(!I0.eq(c.getTranslation(),[0,0,0]))j.translation=c.getTranslation();if(!I0.eq(c.getRotation(),[0,0,0,1]))j.rotation=c.getRotation();if(!I0.eq(c.getScale(),[1,1,1]))j.scale=c.getScale();if(c.getWeights().length)j.weights=c.getWeights();return K.nodeIndexMap.set(c,x),j}),Y.skins=$.listSkins().map((c,x)=>{let j=K.createPropertyDef(c),B=c.getInverseBindMatrices();if(B)j.inverseBindMatrices=K.accessorIndexMap.get(B);let L=c.getSkeleton();if(L)j.skeleton=K.nodeIndexMap.get(L);return j.joints=c.listJoints().map((R)=>K.nodeIndexMap.get(R)),K.skinIndexMap.set(c,x),j}),$.listNodes().forEach((c,x)=>{let j=Y.nodes[x],B=c.getMesh();if(B)j.mesh=K.meshIndexMap.get(B);let L=c.getCamera();if(L)j.camera=K.cameraIndexMap.get(L);let R=c.getSkin();if(R)j.skin=K.skinIndexMap.get(R);if(c.listChildren().length>0)j.children=c.listChildren().map((M)=>K.nodeIndexMap.get(M))}),Y.animations=$.listAnimations().map((c,x)=>{let j=K.createPropertyDef(c),B=new Map;return j.samplers=c.listSamplers().map((L,R)=>{let M=K.createPropertyDef(L);return M.input=K.accessorIndexMap.get(L.getInput()),M.output=K.accessorIndexMap.get(L.getOutput()),M.interpolation=L.getInterpolation(),B.set(L,R),M}),j.channels=c.listChannels().map((L)=>{let R=K.createPropertyDef(L);return R.sampler=B.get(L.getSampler()),R.target={node:K.nodeIndexMap.get(L.getTargetNode()),path:L.getTargetPath()},R}),K.animationIndexMap.set(c,x),j}),Y.scenes=$.listScenes().map((c,x)=>{let j=K.createPropertyDef(c);return j.nodes=c.listChildren().map((B)=>K.nodeIndexMap.get(B)),K.sceneIndexMap.set(c,x),j});let w=$.getDefaultScene();if(w)Y.scene=$.listScenes().indexOf(w);return Y.extensionsUsed=z.map((c)=>c.extensionName),Y.extensionsRequired=v.map((c)=>c.extensionName),z.forEach((c)=>c.write(K)),zU1(Y),Q}}function zU1(Z){let J=[];for(let X in Z){let $=Z[X];if(Array.isArray($)&&$.length===0)J.push(X);else if($===null||$==="")J.push(X);else if($&&typeof $==="object"&&Object.keys($).length===0)J.push(X)}for(let X of J)delete Z[X]}var tF;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(tF||(tF={}));class Sg{constructor(){this._logger=z5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=oF.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=Ng(J)?this._binaryToJSON(J):{json:JSON.parse(E0.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),_g.read(Z,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(Z){let J=this._binaryToJSON(E0.assertView(Z));this._readResourcesInternal(J);let X=J.json;if(X.buffers&&X.buffers.some(($)=>vU1(J,$)))throw Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some(($)=>VU1(J,$)))throw Error("Cannot resolve external images with binaryToJSON().");return J}async readBinary(Z){return this.readJSON(await this.binaryToJSON(E0.assertView(Z)))}async writeJSON(Z,J={}){if(J.format===$Z.GLB&&Z.getRoot().listBuffers().length>1)throw Error("GLB must have 0–1 buffers.");return hg.write(Z,{format:J.format||$Z.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:m6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:$Z.GLB}),$=new Uint32Array([1179937895,2,12]),Y=JSON.stringify(J),Q=E0.pad(E0.encodeText(Y),32),K=E0.toView(new Uint32Array([Q.byteLength,1313821514])),W=E0.concat([K,Q]);$[$.length-1]+=W.byteLength;let G=Object.values(X)[0];if(!G||!G.byteLength)return E0.concat([E0.toView($),W]);let z=E0.pad(G,0),v=E0.toView(new Uint32Array([z.byteLength,5130562])),H=E0.concat([v,z]);return $[$.length-1]+=H.byteLength,E0.concat([E0.toView($),W,H])}async _readResourcesExternal(Z,J){var X=this;let $=Z.json.images||[],Y=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(Y){if(!Y.uri)return;if(Y.uri in Z.resources){E0.assertView(Z.resources[Y.uri]);return}if(Y.uri.match(/data:/)){let Q=`__${Eg()}.${YZ.extension(Y.uri)}`;Z.resources[Q]=E0.createBufferFromDataURI(Y.uri),Y.uri=Q}}(Z.json.images||[]).forEach((Y)=>{if(Y.bufferView===void 0&&Y.uri===void 0)throw Error("Missing resource URI or buffer view.");J(Y)}),(Z.json.buffers||[]).forEach(J)}_copyJSON(Z){let{images:J,buffers:X}=Z.json;if(Z={json:m6({},Z.json),resources:m6({},Z.resources)},J)Z.json.images=J.map(($)=>m6({},$));if(X)Z.json.buffers=X.map(($)=>m6({},$));return Z}_binaryToJSON(Z){if(!Ng(Z))throw Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==tF.JSON)throw Error("Missing required GLB JSON chunk.");let X=20,$=J[0],Y=E0.decodeText(E0.toView(Z,X,$)),Q=JSON.parse(Y),K=X+$;if(Z.byteLength<=K)return{json:Q,resources:{}};let W=new Uint32Array(Z.buffer,Z.byteOffset+K,2);if(W[1]!==tF.BIN)return{json:Q,resources:{}};let G=W[0],z=E0.toView(Z,K+8,G);return{json:Q,resources:{[E$]:z}}}}function vU1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function VU1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function Ng(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 xR extends Sg{constructor(Z=null,J=F4.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 Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=Z,this}async readURI(Z,J){if(await this.init(),F4.isAbsoluteURL(Z)){if(!this._fetchEnabled||!this._fetch)throw 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(F4.isAbsoluteURL(Z)||F4.isAbsoluteURL(J))return F4.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(F4.isAbsoluteURL(Z))return F4.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:$,resources:Y}=await this.writeJSON(J,{format:$Z.GLTF,basename:YZ.basename(Z)}),{_fs:Q,_path:K}=this,W=K.dirname(Z),G=JSON.stringify($,null,2);await Q.writeFile(Z,G),this.lastWriteBytes+=G.length;for(let z of HU1(Object.keys(Y),10))await Promise.all(z.map(async function(v){if(F4.isAbsoluteURL(v)){if(F4.extension(v)==="bin")throw Error(`Cannot write buffer to path "${v}".`);return}let H=K.join(W,decodeURIComponent(v));await Q.mkdir(K.dirname(H),{recursive:!0}),await Q.writeFile(H,Y[v]),X.lastWriteBytes+=Y[v].byteLength}))}async _writeGLB(Z,J){let X=await this.writeBinary(J);await this._fs.writeFile(Z,X),this.lastWriteBytes=X.byteLength}}function HU1(Z,J){let X=[];for(let $=0,Y=Z.length;$<Y;$+=J){let Q=[];for(let K=0;K<J&&$+K<Y;K++)Q.push(Z[$+K]);X.push(Q)}return X}var In=t(UR(),1),_n=t(cn(),1),QD1=t(En(),1);async function KD1(Z,J){if(!(Z instanceof Uint8Array))throw Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:$}=await _n.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return In.default(new Uint8Array(X),[$.width,$.height,4],[4,4*$.width|0,1],0)}async function hn(Z,J){return KD1(Z)}var bn=163,An=166;function WD1(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,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 U3{constructor(Z,J,X,$){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(Z.buffer,Z.byteOffset+J,X),this._littleEndian=$,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,$=0;while(this._dataView.getUint8(this._offset)!==J&&$<Z)$++,this._offset++;if($<Z)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+X,$)}}var lN6=new Uint8Array([0]),p6=[171,75,84,88,32,50,48,187,13,10,26,10];function Sn(Z){return new TextDecoder().decode(Z)}function Mw(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,p6.length);if(J[0]!==p6[0]||J[1]!==p6[1]||J[2]!==p6[2]||J[3]!==p6[3]||J[4]!==p6[4]||J[5]!==p6[5]||J[6]!==p6[6]||J[7]!==p6[7]||J[8]!==p6[8]||J[9]!==p6[9]||J[10]!==p6[10]||J[11]!==p6[11])throw Error("Missing KTX 2.0 identifier.");let X=WD1(),$=17*Uint32Array.BYTES_PER_ELEMENT,Y=new U3(Z,p6.length,$,!0);X.vkFormat=Y._nextUint32(),X.typeSize=Y._nextUint32(),X.pixelWidth=Y._nextUint32(),X.pixelHeight=Y._nextUint32(),X.pixelDepth=Y._nextUint32(),X.layerCount=Y._nextUint32(),X.faceCount=Y._nextUint32(),X.levelCount=Y._nextUint32(),X.supercompressionScheme=Y._nextUint32();let Q=Y._nextUint32(),K=Y._nextUint32(),W=Y._nextUint32(),G=Y._nextUint32(),z=Y._nextUint64(),v=Y._nextUint64(),H=Math.max(X.levelCount,1)*3*8,V=new U3(Z,p6.length+$,H,!0);for(let O8=0,q6=Math.max(X.levelCount,1);O8<q6;O8++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+V._nextUint64(),V._nextUint64()),uncompressedByteLength:V._nextUint64()});let q=new U3(Z,Q,K,!0);q._skip(4);let F=q._nextUint16(),w=q._nextUint16(),c=q._nextUint16(),x=q._nextUint16(),j=q._nextUint8(),B=q._nextUint8(),L=q._nextUint8(),R=q._nextUint8(),M=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],P=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],O={vendorId:F,descriptorType:w,versionNumber:c,colorModel:j,colorPrimaries:B,transferFunction:L,flags:R,texelBlockDimension:M,bytesPlane:P,samples:[]},k=6,E=4,S=(x/4-k)/E;for(let O8=0;O8<S;O8++){let q6={bitOffset:q._nextUint16(),bitLength:q._nextUint8(),channelType:q._nextUint8(),samplePosition:[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(q6.channelType&64)q6.sampleLower=q._nextInt32(),q6.sampleUpper=q._nextInt32();else q6.sampleLower=q._nextUint32(),q6.sampleUpper=q._nextUint32();O.samples[O8]=q6}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(O);let f=new U3(Z,W,G,!0);while(f._offset<G){let O8=f._nextUint32(),q6=f._scan(O8),kH=Sn(q6);if(X.keyValue[kH]=f._nextUint8Array(O8-q6.byteLength-1),kH.match(/^ktx/i)){let LA=Sn(X.keyValue[kH]);X.keyValue[kH]=LA.substring(0,LA.lastIndexOf("\x00"))}let MG1=O8%4?4-O8%4:0;f._skip(MG1)}if(v<=0)return X;let C=new U3(Z,z,v,!0),h=C._nextUint16(),_=C._nextUint16(),a=C._nextUint32(),s=C._nextUint32(),Z0=C._nextUint32(),o=C._nextUint32(),M0=[];for(let O8=0,q6=Math.max(X.levelCount,1);O8<q6;O8++)M0.push({imageFlags:C._nextUint32(),rgbSliceByteOffset:C._nextUint32(),rgbSliceByteLength:C._nextUint32(),alphaSliceByteOffset:C._nextUint32(),alphaSliceByteLength:C._nextUint32()});let R0=z+C._offset,m0=R0+a,N1=m0+s,s0=N1+Z0,j1=new Uint8Array(Z.buffer,Z.byteOffset+R0,a),K4=new Uint8Array(Z.buffer,Z.byteOffset+m0,s),PJ=new Uint8Array(Z.buffer,Z.byteOffset+N1,Z0),IQ=new Uint8Array(Z.buffer,Z.byteOffset+s0,o);return X.globalData={endpointCount:h,selectorCount:_,imageDescs:M0,endpointsData:j1,selectorsData:K4,tablesData:PJ,extendedData:IQ},X}var GZ="EXT_mesh_gpu_instancing",X6="EXT_meshopt_compression",bG="EXT_texture_webp",AG="EXT_texture_avif",s1="KHR_draco_mesh_compression",U4="KHR_lights_punctual",zZ="KHR_materials_anisotropy",vZ="KHR_materials_clearcoat",VZ="KHR_materials_diffuse_transmission",HZ="KHR_materials_dispersion",qZ="KHR_materials_emissive_strength",FZ="KHR_materials_ior",wZ="KHR_materials_iridescence",cZ="KHR_materials_pbrSpecularGlossiness",xZ="KHR_materials_sheen",UZ="KHR_materials_specular",jZ="KHR_materials_transmission",iJ="KHR_materials_unlit",BZ="KHR_materials_volume",U6="KHR_materials_variants",tn="KHR_mesh_quantization",mG="KHR_texture_basisu",LZ="KHR_texture_transform",j4="KHR_xmp_json_ld",gR="INSTANCE_ATTRIBUTE";class aR extends O1{init(){this.extensionName=GZ,this.propertyType="InstancedMesh",this.parentTypes=[i.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new A6})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:gR})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}aR.EXTENSION_NAME=GZ;class Nw extends T1{constructor(...Z){super(...Z);this.extensionName=GZ,this.provideTypes=[i.NODE],this.prewriteTypes=[i.ACCESSOR]}createInstancedMesh(){return new aR(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[GZ])return;let Q=$.extensions[GZ],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[Y].setExtension(GZ,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(gR);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,gR);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let $=X.getExtension(GZ);if($){let Y=Z.nodeIndexMap.get(X),Q=J.json.nodes[Y],K={attributes:{}};$.listSemantics().forEach((W)=>{let G=$.getAttribute(W);K.attributes[W]=Z.accessorIndexMap.get(G)}),Q.extensions=Q.extensions||{},Q.extensions[GZ]=K}}),this}}Nw.EXTENSION_NAME=GZ;function DZ(){return DZ=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)({}).hasOwnProperty.call(X,$)&&(Z[$]=X[$])}return Z},DZ.apply(null,arguments)}var uG;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(uG||(uG={}));var j3;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(j3||(j3={}));var $8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})($8||($8={}));function GD1(Z){if(!Z.extensions||!Z.extensions[X6])return!1;return!!Z.extensions[X6].fallback}var{BYTE:zD1,SHORT:mn,FLOAT:vD1}=K0.ComponentType,{encodeNormalizedInt:un,decodeNormalizedInt:dR}=I0;function VD1(Z,J,X,$){let{filter:Y,bits:Q}=$,K={array:Z.getArray(),byteStride:Z.getElementSize()*Z.getComponentSize(),componentType:Z.getComponentType(),normalized:Z.getNormalized()};if(X!==j3.ATTRIBUTES)return K;if(Y!==$8.NONE){let W=Z.getNormalized()?HD1(Z):new Float32Array(K.array);switch(Y){case $8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=vD1,K.normalized=!1,K.array=J.encodeFilterExp(W,Z.getCount(),K.byteStride,Q);break;case $8.OCTAHEDRAL:K.byteStride=Q>8?8:4,K.componentType=Q>8?mn:zD1,K.normalized=!0,W=Z.getElementSize()===3?FD1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case $8.QUATERNION:K.byteStride=8,K.componentType=mn,K.normalized=!0,K.array=J.encodeFilterQuat(W,Z.getCount(),K.byteStride,Q);break;default:throw Error("Invalid filter.")}if(K.min=Z.getMin([]),K.max=Z.getMax([]),Z.getNormalized())K.min=K.min.map((G)=>dR(G,Z.getComponentType())),K.max=K.max.map((G)=>dR(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>un(G,K.componentType)),K.max=K.max.map((G)=>un(G,K.componentType))}else if(K.byteStride%4)K.array=qD1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function HD1(Z){let J=Z.getComponentType(),X=Z.getArray(),$=new Float32Array(X.length);for(let Y=0;Y<X.length;Y++)$[Y]=dR(X[Y],J);return $}function qD1(Z,J){let $=E0.padNumber(Z.BYTES_PER_ELEMENT*J)/Z.BYTES_PER_ELEMENT,Y=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*$+W]=Z[K*J+W];return Q}function FD1(Z){let J=new Float32Array(Z.length*4/3);for(let X=0,$=Z.length/3;X<$;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 wD1(Z,J){if(J===w4.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some(($)=>{return $ instanceof g1&&$.getMode()===g1.Mode.TRIANGLES})?j3.TRIANGLES:j3.INDICES;return j3.ATTRIBUTES}function cD1(Z,J){let X=J.getGraph().listParentEdges(Z).filter(($)=>!($.getParent()instanceof W3));for(let $ of X){let Y=$.getName(),Q=$.getAttributes().key||"",K=$.getParent().propertyType===i.PRIMITIVE_TARGET;if(Y==="indices")return{filter:$8.NONE};if(Y==="attributes"){if(Q==="POSITION")return{filter:$8.NONE};if(Q==="TEXCOORD_0")return{filter:$8.NONE};if(Q.startsWith("JOINTS_"))return{filter:$8.NONE};if(Q.startsWith("WEIGHTS_"))return{filter:$8.NONE};if(Q==="NORMAL"||Q==="TANGENT")return K?{filter:$8.NONE}:{filter:$8.OCTAHEDRAL,bits:8}}if(Y==="output"){let W=en(Z);if(W==="rotation")return{filter:$8.QUATERNION,bits:16};if(W==="translation")return{filter:$8.EXPONENTIAL,bits:12};if(W==="scale")return{filter:$8.EXPONENTIAL,bits:12};return{filter:$8.NONE}}if(Y==="input")return{filter:$8.NONE};if(Y==="inverseBindMatrices")return{filter:$8.NONE}}return{filter:$8.NONE}}function en(Z){for(let J of Z.listParents()){if(!(J instanceof AJ))continue;for(let X of J.listParents()){if(!(X instanceof QZ))continue;return X.getTargetPath()}}return null}var ln={method:uG.QUANTIZE};class yG extends T1{constructor(...Z){super(...Z);this.extensionName=X6,this.prereadTypes=[i.BUFFER,i.PRIMITIVE],this.prewriteTypes=[i.BUFFER,i.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=ln,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=DZ({},ln,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw Error(`[${X6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw Error(`[${X6}]: Missing WASM support.`)}if(J===i.BUFFER)this._prereadBuffers(Z);else if(J===i.PRIMITIVE)this._prereadPrimitives(Z);return this}_prereadBuffers(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[X6])return;let Q=$.extensions[X6],K=Q.byteOffset||0,W=Q.byteLength||0,G=Q.count,z=Q.byteStride,v=new Uint8Array(G*z),H=J.json.buffers[Q.buffer],V=H.uri?J.resources[H.uri]:J.resources[E$],q=E0.toView(V,K,W);this._decoder.decodeGltfBuffer(v,G,z,q,Q.mode,Q.filter),Z.bufferViews[Y]=v})}_prereadPrimitives(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach(($)=>{if(!$.extensions||!$.extensions[X6])return;let Y=$.extensions[X6],Q=Z.buffers[Y.buffer],K=Z.buffers[$.buffer],W=J.json.buffers[$.buffer];if(GD1(W))this._decoderFallbackBufferMap.set(K,Q)})}read(Z){if(!this.isRequired())return this;for(let[J,X]of this._decoderFallbackBufferMap){for(let $ of J.listParents())if($ instanceof K0)$.swap(J,X);J.dispose()}return this}prewrite(Z,J){if(J===i.ACCESSOR)this._prewriteAccessors(Z);else if(J===i.BUFFER)this._prewriteBuffers(Z);return this}_prewriteAccessors(Z){let J=Z.jsonDoc.json,X=this._encoder,$=this._encoderOptions,Y=this.document.getGraph(),Q=this.document.createBuffer(),K=this.document.getRoot().listBuffers().indexOf(Q),W=1,G=new Map,z=(v)=>{for(let H of Y.listParents(v)){if(H.propertyType===i.ROOT)continue;let V=G.get(v);if(V===void 0)G.set(v,V=W++);return V}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let v of this.document.getRoot().listAccessors()){if(en(v)==="weights")continue;if(v.getSparse())continue;let H=Z.getAccessorUsage(v),V=Z.accessorUsageGroupedByParent.has(H)?z(v):null,q=wD1(v,H),F=$.method===uG.FILTER?cD1(v,this.document):{filter:$8.NONE},w=VD1(v,X,q,F),{array:c,byteStride:x}=w,j=v.getBuffer();if(!j)throw Error(`${X6}: Missing buffer for accessor.`);let B=this.document.getRoot().listBuffers().indexOf(j),L=[H,V,q,F.filter,x,B].join(":"),R=this._encoderBufferViews[L],M=this._encoderBufferViewData[L],P=this._encoderBufferViewAccessors[L];if(!R||!M)P=this._encoderBufferViewAccessors[L]=[],M=this._encoderBufferViewData[L]=[],R=this._encoderBufferViews[L]={buffer:K,target:w4.USAGE_TO_TARGET[H],byteOffset:0,byteLength:0,byteStride:H===w4.BufferViewUsage.ARRAY_BUFFER?x:void 0,extensions:{[X6]:{buffer:B,byteOffset:0,byteLength:0,mode:q,filter:F.filter!==$8.NONE?F.filter:void 0,byteStride:x,count:0}}};let N=Z.createAccessorDef(v);if(N.componentType=w.componentType,N.normalized=w.normalized,N.byteOffset=R.byteLength,N.min&&w.min)N.min=w.min;if(N.max&&w.max)N.max=w.max;Z.accessorIndexMap.set(v,J.accessors.length),J.accessors.push(N),P.push(N),M.push(new Uint8Array(c.buffer,c.byteOffset,c.byteLength)),R.byteLength+=c.byteLength,R.extensions.EXT_meshopt_compression.count+=v.getCount()}}_prewriteBuffers(Z){let J=this._encoder;for(let X in this._encoderBufferViews){let $=this._encoderBufferViews[X],Y=this._encoderBufferViewData[X],Q=this.document.getRoot().listBuffers()[$.extensions[X6].buffer],K=Z.otherBufferViews.get(Q)||[],{count:W,byteStride:G,mode:z}=$.extensions[X6],v=E0.concat(Y),H=J.encodeGltfBuffer(v,W,G,z),V=E0.pad(H);$.extensions[X6].byteLength=H.byteLength,Y.length=0,Y.push(V),K.push(V),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),z=this._encoderBufferViewAccessors[Q];for(let q of z)q.bufferView=G;let v=Z.jsonDoc.json.bufferViews[G],H=v.byteOffset||0;Object.assign(v,K),v.byteOffset=J;let V=v.extensions[X6];V.byteOffset=H,J+=E0.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,$=Z.bufferIndexMap.get(X),Y=Z.jsonDoc.json.buffers[$];return Y.byteLength=J,Y.extensions={[X6]:{fallback:!0}},X.dispose(),this}}yG.EXTENSION_NAME=X6;yG.EncoderMethod=uG;class Zs{match(Z){return Z.length>=12&&E0.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=yn(J,0);if(!X)return null;let $=X.end;while(X=yn(J,$))if(X.type==="meta")$=X.start+4;else if(X.type==="iprp"||X.type==="ipco")$=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 $=X.end;return null}getChannels(Z){return 4}}class Ow extends T1{constructor(...Z){super(...Z);this.extensionName=AG,this.prereadTypes=[i.TEXTURE]}static register(){_5.registerFormat("image/avif",new Zs)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[AG])X.source=X.extensions[AG].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 $=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===$)Q.extensions=Q.extensions||{},Q.extensions[AG]={source:Q.source},delete Q.source})}}),this}}Ow.EXTENSION_NAME=AG;function yn(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:E0.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}class Js{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=E0.decodeText(Z.slice(0,4)),X=E0.decodeText(Z.slice(8,12));if(J!=="RIFF"||X!=="WEBP")return null;let $=new DataView(Z.buffer,Z.byteOffset),Y=12;while(Y<$.byteLength){let Q=E0.decodeText(new Uint8Array([$.getUint8(Y),$.getUint8(Y+1),$.getUint8(Y+2),$.getUint8(Y+3)])),K=$.getUint32(Y+4,!0);if(Q==="VP8 "){let W=$.getInt16(Y+14,!0)&16383,G=$.getInt16(Y+16,!0)&16383;return[W,G]}else if(Q==="VP8L"){let W=$.getUint8(Y+9),G=$.getUint8(Y+10),z=$.getUint8(Y+11),v=$.getUint8(Y+12),H=1+((G&63)<<8|W),V=1+((v&15)<<10|z<<2|(G&192)>>6);return[H,V]}Y+=8+K+K%2}return null}getChannels(Z){return 4}}class Tw extends T1{constructor(...Z){super(...Z);this.extensionName=bG,this.prereadTypes=[i.TEXTURE]}static register(){_5.registerFormat("image/webp",new Js)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[bG])X.source=X.extensions[bG].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 $=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===$)Q.extensions=Q.extensions||{},Q.extensions[bG]={source:Q.source},delete Q.source})}}),this}}Tw.EXTENSION_NAME=bG;var S8,Xs,$s;function xD1(Z,J){let X=new S8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==S8.TRIANGULAR_MESH)throw Error(`[${s1}] Unknown geometry type.`);let Y=new S8.Mesh;if(!Z.DecodeBufferToMesh(X,Y).ok()||Y.ptr===0)throw Error(`[${s1}] Decoding failure.`);return Y}finally{S8.destroy(X)}}function UD1(Z,J){let $=J.num_faces()*3,Y,Q;if(J.num_points()<=65534){let K=$*Uint16Array.BYTES_PER_ELEMENT;Y=S8._malloc(K),Z.GetTrianglesUInt16Array(J,K,Y),Q=new Uint16Array(S8.HEAPU16.buffer,Y,$).slice()}else{let K=$*Uint32Array.BYTES_PER_ELEMENT;Y=S8._malloc(K),Z.GetTrianglesUInt32Array(J,K,Y),Q=new Uint32Array(S8.HEAPU32.buffer,Y,$).slice()}return S8._free(Y),Q}function jD1(Z,J,X,$){let Y=$s[$.componentType],Q=Xs[$.componentType],K=X.num_components(),G=J.num_points()*K,z=G*Q.BYTES_PER_ELEMENT,v=S8._malloc(z);Z.GetAttributeDataArrayForAllPoints(J,X,Y,z,v);let H=new Q(S8.HEAPF32.buffer,v,G).slice();return S8._free(v),H}function BD1(Z){S8=Z,Xs={[K0.ComponentType.FLOAT]:Float32Array,[K0.ComponentType.UNSIGNED_INT]:Uint32Array,[K0.ComponentType.UNSIGNED_SHORT]:Uint16Array,[K0.ComponentType.UNSIGNED_BYTE]:Uint8Array,[K0.ComponentType.SHORT]:Int16Array,[K0.ComponentType.BYTE]:Int8Array},$s={[K0.ComponentType.FLOAT]:S8.DT_FLOAT32,[K0.ComponentType.UNSIGNED_INT]:S8.DT_UINT32,[K0.ComponentType.UNSIGNED_SHORT]:S8.DT_UINT16,[K0.ComponentType.UNSIGNED_BYTE]:S8.DT_UINT8,[K0.ComponentType.SHORT]:S8.DT_INT16,[K0.ComponentType.BYTE]:S8.DT_INT8}}var x4,lG;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(lG||(lG={}));var B4;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(B4||(B4={}));var Ys={[B4.POSITION]:14,[B4.NORMAL]:10,[B4.COLOR]:8,[B4.TEX_COORD]:12,[B4.GENERIC]:12},pn={decodeSpeed:5,encodeSpeed:5,method:lG.EDGEBREAKER,quantizationBits:Ys,quantizationVolume:"mesh"};function LD1(Z){x4=Z}function DD1(Z,J=pn){let X=DZ({},pn,J);X.quantizationBits=DZ({},Ys,J.quantizationBits);let $=new x4.MeshBuilder,Y=new x4.Mesh,Q=new x4.ExpertEncoder(Y),K={},W=new x4.DracoInt8Array,G=Z.listTargets().length>0,z=!1;for(let w of Z.listSemantics()){let c=Z.getAttribute(w);if(c.getSparse()){z=!0;continue}let x=MD1(w),j=RD1($,c.getComponentType(),Y,x4[x],c.getCount(),c.getElementSize(),c.getArray());if(j===-1)throw Error(`Error compressing "${w}" attribute.`);if(K[w]=j,X.quantizationVolume==="mesh"||w!=="POSITION")Q.SetAttributeQuantization(j,X.quantizationBits[x]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:B}=X,L=Math.max(B.max[0]-B.min[0],B.max[1]-B.min[1],B.max[2]-B.min[2]);Q.SetAttributeExplicitQuantization(j,X.quantizationBits[x],c.getElementSize(),B.min,L)}else throw Error("Invalid quantization volume state.")}let v=Z.getIndices();if(!v)throw new Rw("Primitive must have indices.");if($.AddFacesToMesh(Y,v.getCount()/3,v.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===lG.SEQUENTIAL||G||z)Q.SetEncodingMethod(x4.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(x4.MESH_EDGEBREAKER_ENCODING);let H=Q.EncodeToDracoBuffer(!(G||z),W);if(H<=0)throw new Rw("Error applying Draco compression.");let V=new Uint8Array(H);for(let w=0;w<H;++w)V[w]=W.GetValue(w);let q=Q.GetNumberOfEncodedPoints(),F=Q.GetNumberOfEncodedFaces()*3;return x4.destroy(W),x4.destroy(Y),x4.destroy($),x4.destroy(Q),{numVertices:q,numIndices:F,data:V,attributeIDs:K}}function MD1(Z){if(Z==="POSITION")return B4.POSITION;else if(Z==="NORMAL")return B4.NORMAL;else if(Z.startsWith("COLOR_"))return B4.COLOR;else if(Z.startsWith("TEXCOORD_"))return B4.TEX_COORD;return B4.GENERIC}function RD1(Z,J,X,$,Y,Q,K){switch(J){case K0.ComponentType.UNSIGNED_BYTE:return Z.AddUInt8Attribute(X,$,Y,Q,K);case K0.ComponentType.BYTE:return Z.AddInt8Attribute(X,$,Y,Q,K);case K0.ComponentType.UNSIGNED_SHORT:return Z.AddUInt16Attribute(X,$,Y,Q,K);case K0.ComponentType.SHORT:return Z.AddInt16Attribute(X,$,Y,Q,K);case K0.ComponentType.UNSIGNED_INT:return Z.AddUInt32Attribute(X,$,Y,Q,K);case K0.ComponentType.FLOAT:return Z.AddFloatAttribute(X,$,Y,Q,K);default:throw Error(`Unexpected component type, "${J}".`)}}class Rw extends Error{}class pG extends T1{constructor(...Z){super(...Z);this.extensionName=s1,this.prereadTypes=[i.PRIMITIVE],this.prewriteTypes=[i.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,BD1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,LD1(this._encoderModule);return this}setEncoderOptions(Z){return this._encoderOptions=Z,this}preread(Z){if(!this._decoderModule)throw Error(`[${s1}] Please install extension dependency, "draco3d.decoder".`);let J=this.document.getLogger(),X=Z.jsonDoc,$=new Map;try{let Y=X.json.meshes||[];for(let Q of Y)for(let K of Q.primitives){if(!K.extensions||!K.extensions[s1])continue;let W=K.extensions[s1],[G,z]=$.get(W.bufferView)||[];if(!z||!G){let v=X.json.bufferViews[W.bufferView],H=X.json.buffers[v.buffer],V=H.uri?X.resources[H.uri]:X.resources[E$],q=v.byteOffset||0,F=v.byteLength,w=E0.toView(V,q,F);G=new this._decoderModule.Decoder,z=xD1(G,w),$.set(W.bufferView,[G,z]),J.debug(`[${s1}] Decompressed ${w.byteLength} bytes.`)}for(let v in W.attributes){let H=Z.jsonDoc.json.accessors[K.attributes[v]],V=G.GetAttributeByUniqueId(z,W.attributes[v]),q=jD1(G,z,V,H);Z.accessors[K.attributes[v]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(UD1(G,z))}}finally{for(let[Y,Q]of Array.from($.values()))this._decoderModule.destroy(Y),this._decoderModule.destroy(Q)}return this}read(Z){return this}prewrite(Z,J){if(!this._encoderModule)throw Error(`[${s1}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${s1}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let $=PD1(this.document),Y=new Map,Q="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)X.warn(`[${s1}]: quantizationVolume=scene requires exactly 1 scene.`);else Q=PG(this.document.getRoot().listScenes().pop());for(let K of Array.from($.keys())){let W=$.get(K);if(!W)throw Error("Unexpected primitive.");if(Y.has(W)){Y.set(W,Y.get(W));continue}let G=K.getIndices(),z=Z.jsonDoc.json.accessors,v;try{v=DD1(K,DZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof Rw){X.warn(`[${s1}]: ${q.message} Skipping primitive compression.`);continue}throw q}Y.set(W,v);let H=Z.createAccessorDef(G);if(H.count=v.numIndices,Z.accessorIndexMap.set(G,z.length),z.push(H),v.numVertices>65534&&K0.getComponentSize(H.componentType)<=2)H.componentType=K0.ComponentType.UNSIGNED_INT;else if(v.numVertices>254&&K0.getComponentSize(H.componentType)<=1)H.componentType=K0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let F=K.getAttribute(q);if(v.attributeIDs[q]===void 0)continue;let w=Z.createAccessorDef(F);w.count=v.numVertices,Z.accessorIndexMap.set(F,z.length),z.push(w)}let V=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(V))Z.otherBufferViews.set(V,[]);Z.otherBufferViews.get(V).push(v.data)}return X.debug(`[${s1}] Compressed ${$.size} primitives.`),Z.extensionData[s1]={primitiveHashMap:$,primitiveEncodingMap:Y},this}write(Z){let J=Z.extensionData[s1];for(let X of this.document.getRoot().listMeshes()){let $=Z.jsonDoc.json.meshes[Z.meshIndexMap.get(X)];for(let Y=0;Y<X.listPrimitives().length;Y++){let Q=X.listPrimitives()[Y],K=$.primitives[Y],W=J.primitiveHashMap.get(Q);if(!W)continue;let G=J.primitiveEncodingMap.get(W);if(!G)continue;K.extensions=K.extensions||{},K.extensions[s1]={bufferView:Z.otherBufferViewsIndexMap.get(G.data),attributes:G.attributeIDs}}}if(!J.primitiveHashMap.size){let X=Z.jsonDoc.json;X.extensionsUsed=(X.extensionsUsed||[]).filter(($)=>$!==s1),X.extensionsRequired=(X.extensionsRequired||[]).filter(($)=>$!==s1)}return this}}pG.EXTENSION_NAME=s1;pG.EncoderMethod=lG;function PD1(Z){let J=Z.getLogger(),X=new Set,$=new Set,Y=0,Q=0;for(let H of Z.getRoot().listMeshes())for(let V of H.listPrimitives())if(!V.getIndices())$.add(V),Y++;else if(V.getMode()!==g1.Mode.TRIANGLES)$.add(V),Q++;else X.add(V);if(Y>0)J.warn(`[${s1}] Skipping Draco compression of ${Y} non-indexed primitives.`);if(Q>0)J.warn(`[${s1}] Skipping Draco compression of ${Q} non-TRIANGLES primitives.`);let K=Z.getRoot().listAccessors(),W=new Map;for(let H=0;H<K.length;H++)W.set(K[H],H);let G=new Map,z=new Set,v=new Map;for(let H of Array.from(X)){let V=gn(H,W);if(z.has(V)){v.set(H,V);continue}if(G.has(H.getIndices())){let q=H.getIndices(),F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),H.swap(q,F)}for(let q of H.listAttributes())if(G.has(q)){let F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),H.swap(q,F)}V=gn(H,W),z.add(V),v.set(H,V),G.set(H.getIndices(),V);for(let q of H.listAttributes())G.set(q,V)}for(let H of Array.from(G.keys())){let V=new Set(H.listParents().map((q)=>q.propertyType));if(V.size!==2||!V.has(i.PRIMITIVE)||!V.has(i.ROOT))throw Error(`[${s1}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let H of Array.from(X)){let V=v.get(H),q=H.getIndices();if(G.get(q)!==V||H.listAttributes().some((F)=>G.get(F)!==V))throw Error(`[${s1}] Draco primitives must share all, or no, accessors.`)}for(let H of Array.from($)){let V=H.getIndices();if(G.has(V)||H.listAttributes().some((q)=>G.has(q)))throw Error(`[${s1}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return v}function gn(Z,J){let X=[],$=Z.getIndices();X.push(J.get($));for(let Y of Z.listAttributes())X.push(J.get(Y));return X.sort().join("|")}class B3 extends O1{init(){this.extensionName=U4,this.propertyType="Light",this.parentTypes=[i.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:B3.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)}}B3.EXTENSION_NAME=U4;B3.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};class nR extends T1{constructor(...Z){super(...Z);this.extensionName=U4}createLight(Z=""){return new B3(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[U4])return this;let Y=(J.json.extensions[U4].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[U4])return;let W=Q.extensions[U4];Z.nodes[K].setExtension(U4,Y[W.light])}),this}write(Z){let J=Z.jsonDoc;if(this.properties.size===0)return this;let X=[],$=new Map;for(let Y of this.properties){let Q=Y,K={type:Q.getType()};if(!I0.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()===B3.Type.SPOT)K.spot={innerConeAngle:Q.getInnerConeAngle(),outerConeAngle:Q.getOuterConeAngle()};X.push(K),$.set(Q,X.length-1)}return this.document.getRoot().listNodes().forEach((Y)=>{let Q=Y.getExtension(U4);if(Q){let K=Z.nodeIndexMap.get(Y),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[U4]={light:$.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[U4]={lights:X},this}}nR.EXTENSION_NAME=U4;var{R:ND1,G:OD1,B:TD1}=v5;class sR extends O1{init(){this.extensionName=zZ,this.propertyType="Anisotropy",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new F1(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:ND1|OD1|TD1})}}sR.EXTENSION_NAME=zZ;class oR extends T1{constructor(...Z){super(...Z);this.extensionName=zZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createAnisotropy(){return new sR(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[zZ]){let K=this.createAnisotropy();Z.materials[Q].setExtension(zZ,K);let W=Y.extensions[zZ];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,z=Z.textures[$[G.index].source];K.setAnisotropyTexture(z),Z.setTextureInfo(K.getAnisotropyTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(zZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[zZ]={};if($.getAnisotropyStrength()>0)K.anisotropyStrength=$.getAnisotropyStrength();if($.getAnisotropyRotation()!==0)K.anisotropyRotation=$.getAnisotropyRotation();if($.getAnisotropyTexture()){let W=$.getAnisotropyTexture(),G=$.getAnisotropyTextureInfo();K.anisotropyTexture=Z.createTextureInfoDef(W,G)}}}),this}}oR.EXTENSION_NAME=zZ;var{R:dn,G:an,B:CD1}=v5;class rR extends O1{init(){this.extensionName=vZ,this.propertyType="Clearcoat",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new F1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new F1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new F1(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:dn})}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:an})}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:dn|an|CD1})}}rR.EXTENSION_NAME=vZ;class tR extends T1{constructor(...Z){super(...Z);this.extensionName=vZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createClearcoat(){return new rR(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[vZ]){let K=this.createClearcoat();Z.materials[Q].setExtension(vZ,K);let W=Y.extensions[vZ];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,z=Z.textures[$[G.index].source];K.setClearcoatTexture(z),Z.setTextureInfo(K.getClearcoatTextureInfo(),G)}if(W.clearcoatRoughnessTexture!==void 0){let G=W.clearcoatRoughnessTexture,z=Z.textures[$[G.index].source];K.setClearcoatRoughnessTexture(z),Z.setTextureInfo(K.getClearcoatRoughnessTextureInfo(),G)}if(W.clearcoatNormalTexture!==void 0){let G=W.clearcoatNormalTexture,z=Z.textures[$[G.index].source];if(K.setClearcoatNormalTexture(z),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 $=X.getExtension(vZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[vZ]={clearcoatFactor:$.getClearcoatFactor(),clearcoatRoughnessFactor:$.getClearcoatRoughnessFactor()};if($.getClearcoatTexture()){let W=$.getClearcoatTexture(),G=$.getClearcoatTextureInfo();K.clearcoatTexture=Z.createTextureInfoDef(W,G)}if($.getClearcoatRoughnessTexture()){let W=$.getClearcoatRoughnessTexture(),G=$.getClearcoatRoughnessTextureInfo();K.clearcoatRoughnessTexture=Z.createTextureInfoDef(W,G)}if($.getClearcoatNormalTexture()){let W=$.getClearcoatNormalTexture(),G=$.getClearcoatNormalTextureInfo();if(K.clearcoatNormalTexture=Z.createTextureInfoDef(W,G),$.getClearcoatNormalScale()!==1)K.clearcoatNormalTexture.scale=$.getClearcoatNormalScale()}}}),this}}tR.EXTENSION_NAME=vZ;var{R:fD1,G:kD1,B:ED1,A:ID1}=v5;class eR extends O1{init(){this.extensionName=VZ,this.propertyType="DiffuseTransmission",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new F1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new F1(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:ID1})}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:fD1|kD1|ED1})}}eR.EXTENSION_NAME=VZ;class ZP extends T1{constructor(...Z){super(...Z);this.extensionName=VZ}createDiffuseTransmission(){return new eR(this.document.getGraph())}read(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[VZ]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(VZ,K);let W=Y.extensions[VZ];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,z=Z.textures[$[G.index].source];K.setDiffuseTransmissionTexture(z),Z.setTextureInfo(K.getDiffuseTransmissionTextureInfo(),G)}if(W.diffuseTransmissionColorTexture!==void 0){let G=W.diffuseTransmissionColorTexture,z=Z.textures[$[G.index].source];K.setDiffuseTransmissionColorTexture(z),Z.setTextureInfo(K.getDiffuseTransmissionColorTextureInfo(),G)}}}),this}write(Z){let J=Z.jsonDoc;for(let X of this.document.getRoot().listMaterials()){let $=X.getExtension(VZ);if(!$)continue;let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[VZ]={diffuseTransmissionFactor:$.getDiffuseTransmissionFactor(),diffuseTransmissionColorFactor:$.getDiffuseTransmissionColorFactor()};if($.getDiffuseTransmissionTexture()){let W=$.getDiffuseTransmissionTexture(),G=$.getDiffuseTransmissionTextureInfo();K.diffuseTransmissionTexture=Z.createTextureInfoDef(W,G)}if($.getDiffuseTransmissionColorTexture()){let W=$.getDiffuseTransmissionColorTexture(),G=$.getDiffuseTransmissionColorTextureInfo();K.diffuseTransmissionColorTexture=Z.createTextureInfoDef(W,G)}}return this}}ZP.EXTENSION_NAME=VZ;class JP extends O1{init(){this.extensionName=HZ,this.propertyType="Dispersion",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(Z){return this.set("dispersion",Z)}}JP.EXTENSION_NAME=HZ;class XP extends T1{constructor(...Z){super(...Z);this.extensionName=HZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createDispersion(){return new JP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[HZ]){let Q=this.createDispersion();Z.materials[Y].setExtension(HZ,Q);let K=$.extensions[HZ];if(K.dispersion!==void 0)Q.setDispersion(K.dispersion)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(HZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[HZ]={dispersion:$.getDispersion()}}}),this}}XP.EXTENSION_NAME=HZ;class $P extends O1{init(){this.extensionName=qZ,this.propertyType="EmissiveStrength",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(Z){return this.set("emissiveStrength",Z)}}$P.EXTENSION_NAME=qZ;class YP extends T1{constructor(...Z){super(...Z);this.extensionName=qZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createEmissiveStrength(){return new $P(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[qZ]){let Q=this.createEmissiveStrength();Z.materials[Y].setExtension(qZ,Q);let K=$.extensions[qZ];if(K.emissiveStrength!==void 0)Q.setEmissiveStrength(K.emissiveStrength)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(qZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[qZ]={emissiveStrength:$.getEmissiveStrength()}}}),this}}YP.EXTENSION_NAME=qZ;class QP extends O1{init(){this.extensionName=FZ,this.propertyType="IOR",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(Z){return this.set("ior",Z)}}QP.EXTENSION_NAME=FZ;class Cw extends T1{constructor(...Z){super(...Z);this.extensionName=FZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createIOR(){return new QP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[FZ]){let Q=this.createIOR();Z.materials[Y].setExtension(FZ,Q);let K=$.extensions[FZ];if(K.ior!==void 0)Q.setIOR(K.ior)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(FZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[FZ]={ior:$.getIOR()}}}),this}}Cw.EXTENSION_NAME=FZ;var{R:_D1,G:hD1}=v5;class KP extends O1{init(){this.extensionName=wZ,this.propertyType="Iridescence",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new F1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new F1(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:_D1})}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:hD1})}}KP.EXTENSION_NAME=wZ;class WP extends T1{constructor(...Z){super(...Z);this.extensionName=wZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createIridescence(){return new KP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[wZ]){let K=this.createIridescence();Z.materials[Q].setExtension(wZ,K);let W=Y.extensions[wZ];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,z=Z.textures[$[G.index].source];K.setIridescenceTexture(z),Z.setTextureInfo(K.getIridescenceTextureInfo(),G)}if(W.iridescenceThicknessTexture!==void 0){let G=W.iridescenceThicknessTexture,z=Z.textures[$[G.index].source];K.setIridescenceThicknessTexture(z),Z.setTextureInfo(K.getIridescenceThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(wZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[wZ]={};if($.getIridescenceFactor()>0)K.iridescenceFactor=$.getIridescenceFactor();if($.getIridescenceIOR()!==1.3)K.iridescenceIor=$.getIridescenceIOR();if($.getIridescenceThicknessMinimum()!==100)K.iridescenceThicknessMinimum=$.getIridescenceThicknessMinimum();if($.getIridescenceThicknessMaximum()!==400)K.iridescenceThicknessMaximum=$.getIridescenceThicknessMaximum();if($.getIridescenceTexture()){let W=$.getIridescenceTexture(),G=$.getIridescenceTextureInfo();K.iridescenceTexture=Z.createTextureInfoDef(W,G)}if($.getIridescenceThicknessTexture()){let W=$.getIridescenceThicknessTexture(),G=$.getIridescenceThicknessTextureInfo();K.iridescenceThicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}WP.EXTENSION_NAME=wZ;var{R:nn,G:sn,B:on,A:rn}=v5;class GP extends O1{init(){this.extensionName=cZ,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new F1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new F1(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:nn|sn|on|rn,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:nn|sn|on|rn})}}GP.EXTENSION_NAME=cZ;class fw extends T1{constructor(...Z){super(...Z);this.extensionName=cZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createPBRSpecularGlossiness(){return new GP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[cZ]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(cZ,K);let W=Y.extensions[cZ];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,z=Z.textures[$[G.index].source];K.setDiffuseTexture(z),Z.setTextureInfo(K.getDiffuseTextureInfo(),G)}if(W.specularGlossinessTexture!==void 0){let G=W.specularGlossinessTexture,z=Z.textures[$[G.index].source];K.setSpecularGlossinessTexture(z),Z.setTextureInfo(K.getSpecularGlossinessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(cZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[cZ]={diffuseFactor:$.getDiffuseFactor(),specularFactor:$.getSpecularFactor(),glossinessFactor:$.getGlossinessFactor()};if($.getDiffuseTexture()){let W=$.getDiffuseTexture(),G=$.getDiffuseTextureInfo();K.diffuseTexture=Z.createTextureInfoDef(W,G)}if($.getSpecularGlossinessTexture()){let W=$.getSpecularGlossinessTexture(),G=$.getSpecularGlossinessTextureInfo();K.specularGlossinessTexture=Z.createTextureInfoDef(W,G)}}}),this}}fw.EXTENSION_NAME=cZ;var{R:SD1,G:bD1,B:AD1,A:mD1}=v5;class zP extends O1{init(){this.extensionName=xZ,this.propertyType="Sheen",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new F1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new F1(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:SD1|bD1|AD1,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:mD1})}}zP.EXTENSION_NAME=xZ;class vP extends T1{constructor(...Z){super(...Z);this.extensionName=xZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createSheen(){return new zP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[xZ]){let K=this.createSheen();Z.materials[Q].setExtension(xZ,K);let W=Y.extensions[xZ];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,z=Z.textures[$[G.index].source];K.setSheenColorTexture(z),Z.setTextureInfo(K.getSheenColorTextureInfo(),G)}if(W.sheenRoughnessTexture!==void 0){let G=W.sheenRoughnessTexture,z=Z.textures[$[G.index].source];K.setSheenRoughnessTexture(z),Z.setTextureInfo(K.getSheenRoughnessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(xZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[xZ]={sheenColorFactor:$.getSheenColorFactor(),sheenRoughnessFactor:$.getSheenRoughnessFactor()};if($.getSheenColorTexture()){let W=$.getSheenColorTexture(),G=$.getSheenColorTextureInfo();K.sheenColorTexture=Z.createTextureInfoDef(W,G)}if($.getSheenRoughnessTexture()){let W=$.getSheenRoughnessTexture(),G=$.getSheenRoughnessTextureInfo();K.sheenRoughnessTexture=Z.createTextureInfoDef(W,G)}}}),this}}vP.EXTENSION_NAME=xZ;var{R:uD1,G:lD1,B:yD1,A:pD1}=v5;class VP extends O1{init(){this.extensionName=UZ,this.propertyType="Specular",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new F1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new F1(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:pD1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:uD1|lD1|yD1,isColor:!0})}}VP.EXTENSION_NAME=UZ;class kw extends T1{constructor(...Z){super(...Z);this.extensionName=UZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createSpecular(){return new VP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[UZ]){let K=this.createSpecular();Z.materials[Q].setExtension(UZ,K);let W=Y.extensions[UZ];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,z=Z.textures[$[G.index].source];K.setSpecularTexture(z),Z.setTextureInfo(K.getSpecularTextureInfo(),G)}if(W.specularColorTexture!==void 0){let G=W.specularColorTexture,z=Z.textures[$[G.index].source];K.setSpecularColorTexture(z),Z.setTextureInfo(K.getSpecularColorTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(UZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[UZ]={};if($.getSpecularFactor()!==1)K.specularFactor=$.getSpecularFactor();if(!I0.eq($.getSpecularColorFactor(),[1,1,1]))K.specularColorFactor=$.getSpecularColorFactor();if($.getSpecularTexture()){let W=$.getSpecularTexture(),G=$.getSpecularTextureInfo();K.specularTexture=Z.createTextureInfoDef(W,G)}if($.getSpecularColorTexture()){let W=$.getSpecularColorTexture(),G=$.getSpecularColorTextureInfo();K.specularColorTexture=Z.createTextureInfoDef(W,G)}}}),this}}kw.EXTENSION_NAME=UZ;var{R:iD1}=v5;class HP extends O1{init(){this.extensionName=jZ,this.propertyType="Transmission",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new F1(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:iD1})}}HP.EXTENSION_NAME=jZ;class qP extends T1{constructor(...Z){super(...Z);this.extensionName=jZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createTransmission(){return new HP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[jZ]){let K=this.createTransmission();Z.materials[Q].setExtension(jZ,K);let W=Y.extensions[jZ];if(W.transmissionFactor!==void 0)K.setTransmissionFactor(W.transmissionFactor);if(W.transmissionTexture!==void 0){let G=W.transmissionTexture,z=Z.textures[$[G.index].source];K.setTransmissionTexture(z),Z.setTextureInfo(K.getTransmissionTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(jZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[jZ]={transmissionFactor:$.getTransmissionFactor()};if($.getTransmissionTexture()){let W=$.getTransmissionTexture(),G=$.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(W,G)}}}),this}}qP.EXTENSION_NAME=jZ;class FP extends O1{init(){this.extensionName=iJ,this.propertyType="Unlit",this.parentTypes=[i.MATERIAL]}}FP.EXTENSION_NAME=iJ;class Ew extends T1{constructor(...Z){super(...Z);this.extensionName=iJ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createUnlit(){return new FP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((X,$)=>{if(X.extensions&&X.extensions[iJ])Z.materials[$].setExtension(iJ,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(iJ)){let $=Z.materialIndexMap.get(X),Y=J.json.materials[$];Y.extensions=Y.extensions||{},Y.extensions[iJ]={}}}),this}}Ew.EXTENSION_NAME=iJ;class wP extends O1{init(){this.extensionName=U6,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new w1})}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")}}wP.EXTENSION_NAME=U6;class cP extends O1{init(){this.extensionName=U6,this.propertyType="MappingList",this.parentTypes=[i.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new w1})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}cP.EXTENSION_NAME=U6;class Pw extends O1{init(){this.extensionName=U6,this.propertyType="Variant",this.parentTypes=["MappingList"]}}Pw.EXTENSION_NAME=U6;class xP extends T1{constructor(...Z){super(...Z);this.extensionName=U6}createMappingList(){return new cP(this.document.getGraph())}createVariant(Z=""){return new Pw(this.document.getGraph(),Z)}createMapping(){return new wP(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof Pw)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[U6])return this;let Y=(J.json.extensions[U6].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,W)=>{let G=Z.meshes[W];(K.primitives||[]).forEach((v,H)=>{if(!v.extensions||!v.extensions[U6])return;let V=this.createMappingList(),q=v.extensions[U6];for(let F of q.mappings){let w=this.createMapping();if(F.material!==void 0)w.setMaterial(Z.materials[F.material]);for(let c of F.variants||[])w.addVariant(Y[c]);V.addMapping(w)}G.listPrimitives()[H].setExtension(U6,V)})}),this}write(Z){let J=Z.jsonDoc,X=this.listVariants();if(!X.length)return this;let $=[],Y=new Map;for(let Q of X)Y.set(Q,$.length),$.push(Z.createPropertyDef(Q));for(let Q of this.document.getRoot().listMeshes()){let K=Z.meshIndexMap.get(Q);Q.listPrimitives().forEach((W,G)=>{let z=W.getExtension(U6);if(!z)return;let v=Z.jsonDoc.json.meshes[K].primitives[G],H=z.listMappings().map((V)=>{let q=Z.createPropertyDef(V),F=V.getMaterial();if(F)q.material=Z.materialIndexMap.get(F);return q.variants=V.listVariants().map((w)=>Y.get(w)),q});v.extensions=v.extensions||{},v.extensions[U6]={mappings:H}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[U6]={variants:$},this}}xP.EXTENSION_NAME=U6;var{G:gD1}=v5;class UP extends O1{init(){this.extensionName=BZ,this.propertyType="Volume",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new F1(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:gD1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}UP.EXTENSION_NAME=BZ;class jP extends T1{constructor(...Z){super(...Z);this.extensionName=BZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createVolume(){return new UP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[BZ]){let K=this.createVolume();Z.materials[Q].setExtension(BZ,K);let W=Y.extensions[BZ];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,z=Z.textures[$[G.index].source];K.setThicknessTexture(z),Z.setTextureInfo(K.getThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(BZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[BZ]={};if($.getThicknessFactor()>0)K.thicknessFactor=$.getThicknessFactor();if(Number.isFinite($.getAttenuationDistance()))K.attenuationDistance=$.getAttenuationDistance();if(!I0.eq($.getAttenuationColor(),[1,1,1]))K.attenuationColor=$.getAttenuationColor();if($.getThicknessTexture()){let W=$.getThicknessTexture(),G=$.getThicknessTextureInfo();K.thicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}jP.EXTENSION_NAME=BZ;class iG extends T1{constructor(...Z){super(...Z);this.extensionName=tn}read(Z){return this}write(Z){return this}}iG.EXTENSION_NAME=tn;class Qs{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=Mw(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=Mw(Z).dataFormatDescriptor[0];if(X.colorModel===bn)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===An)return(X.samples[0].channelType&15)===3?4:3;throw Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=Mw(Z),X=this.getChannels(Z)>3,$=0;for(let Y=0;Y<J.levels.length;Y++){let Q=J.levels[Y];if(Q.uncompressedByteLength)$+=Q.uncompressedByteLength;else{let K=Math.max(1,Math.floor(J.pixelWidth/Math.pow(2,Y))),W=Math.max(1,Math.floor(J.pixelHeight/Math.pow(2,Y))),G=X?16:8;$+=K/4*(W/4)*G}}return $}}class BP extends T1{constructor(...Z){super(...Z);this.extensionName=mG,this.prereadTypes=[i.TEXTURE]}static register(){_5.registerFormat("image/ktx2",new Qs)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[mG]){let X=J.extensions[mG];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 $=Z.imageIndexMap.get(X);J.json.textures.forEach((Y)=>{if(Y.source===$)Y.extensions=Y.extensions||{},Y.extensions[mG]={source:Y.source},delete Y.source})}}),this}}BP.EXTENSION_NAME=mG;class LP extends O1{init(){this.extensionName=LZ,this.propertyType="Transform",this.parentTypes=[i.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)}}LP.EXTENSION_NAME=LZ;class DP extends T1{constructor(...Z){super(...Z);this.extensionName=LZ}createTransform(){return new LP(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[LZ])continue;let $=this.createTransform(),Y=X.extensions[LZ];if(Y.offset!==void 0)$.setOffset(Y.offset);if(Y.rotation!==void 0)$.setRotation(Y.rotation);if(Y.scale!==void 0)$.setScale(Y.scale);if(Y.texCoord!==void 0)$.setTexCoord(Y.texCoord);J.setExtension(LZ,$)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,$]of J){let Y=X.getExtension(LZ);if(!Y)continue;$.extensions=$.extensions||{};let Q={},K=I0.eq;if(!K(Y.getOffset(),[0,0]))Q.offset=Y.getOffset();if(Y.getRotation()!==0)Q.rotation=Y.getRotation();if(!K(Y.getScale(),[1,1]))Q.scale=Y.getScale();if(Y.getTexCoord()!=null)Q.texCoord=Y.getTexCoord();$.extensions[LZ]=Q}return this}}DP.EXTENSION_NAME=LZ;var dD1=[i.ROOT,i.SCENE,i.NODE,i.MESH,i.MATERIAL,i.TEXTURE,i.ANIMATION];class MP extends O1{init(){this.extensionName=j4,this.propertyType="Packet",this.parentTypes=dD1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",DZ({},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=DZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=iR(this.get("context")),J=iR(this.get("properties"));return DZ({"@context":Z},J)}fromJSONLD(Z){Z=iR(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 Error(`${j4}: Missing context for term, "${Z}".`)}}MP.EXTENSION_NAME=j4;function iR(Z){return JSON.parse(JSON.stringify(Z))}class RP extends T1{constructor(...Z){super(...Z);this.extensionName=j4}createPacket(){return new MP(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[j4];if(!X||!X.packets)return this;let $=Z.jsonDoc.json,Y=this.document.getRoot(),Q=X.packets.map((G)=>this.createPacket().fromJSONLD(G)),K=[[$.asset],$.scenes,$.nodes,$.meshes,$.materials,$.images,$.animations],W=[[Y],Y.listScenes(),Y.listNodes(),Y.listMeshes(),Y.listMaterials(),Y.listTextures(),Y.listAnimations()];for(let G=0;G<K.length;G++){let z=K[G]||[];for(let v=0;v<z.length;v++){let H=z[v];if(H.extensions&&H.extensions[j4]){let V=H.extensions[j4];W[G][v].setExtension(j4,Q[V.packet])}}}return this}write(Z){let{json:J}=Z.jsonDoc,X=[];for(let $ of this.properties){X.push($.toJSONLD());for(let Y of $.listParents()){let Q;switch(Y.propertyType){case i.ROOT:Q=J.asset;break;case i.SCENE:Q=J.scenes[Z.sceneIndexMap.get(Y)];break;case i.NODE:Q=J.nodes[Z.nodeIndexMap.get(Y)];break;case i.MESH:Q=J.meshes[Z.meshIndexMap.get(Y)];break;case i.MATERIAL:Q=J.materials[Z.materialIndexMap.get(Y)];break;case i.TEXTURE:Q=J.images[Z.imageIndexMap.get(Y)];break;case i.ANIMATION:Q=J.animations[Z.animationIndexMap.get(Y)];break;default:Q=null,this.document.getLogger().warn(`[${j4}]: Unsupported parent property, "${Y.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[j4]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[j4]={packets:X};return this}}RP.EXTENSION_NAME=j4;var aD1=[pG,nR,oR,tR,ZP,XP,YP,Cw,WP,fw,kw,vP,qP,Ew,xP,jP,iG,BP,DP,RP],gN6=[Nw,yG,Ow,Tw,...aD1];var nD1=t(UR(),1);function M3(){return M3=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)({}).hasOwnProperty.call(X,$)&&(Z[$]=X[$])}return Z},M3.apply(null,arguments)}var{POINTS:Ks,LINES:Iw,LINE_STRIP:sD1,LINE_LOOP:oD1,TRIANGLES:_w,TRIANGLE_STRIP:rD1,TRIANGLE_FAN:tD1}=g1.Mode;function u$(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function RZ(Z,J){let X=M3({},Z);for(let $ in J)if(J[$]!==void 0)X[$]=J[$];return X}function Rs(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case g1.Mode.POINTS:return J?J.getCount():X.getCount();case g1.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case g1.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case g1.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case g1.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case g1.Mode.TRIANGLE_STRIP:case g1.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw Error("Unexpected mode: "+Z.getMode())}}var eD1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function OP(Z){return eD1.format(Z)}function ZM1(Z,J,X=2){let $=Z>J?"–":"+",Y="%";return $+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function mw(Z,J){return`${OP(Z)} → ${OP(J)} (${ZM1(Z,J)})`}function uw(Z){let J=[];for(let X of Z.listAttributes())J.push(X);for(let X of Z.listTargets())for(let $ of X.listAttributes())J.push($);return Array.from(new Set(J))}function JM1(Z,J,X){Z.swap(J,X);for(let $ of Z.listTargets())$.swap(J,X)}function Ps(Z){let J=Z.getIndices(),X=uw(Z);if(Z.dispose(),J&&!TP(J))J.dispose();for(let $ of X)if(!TP($))$.dispose()}function MZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function XM1(Z,J=Z){let X=hP(Z,J);for(let $=0;$<X.length;$++)X[$]=$;return X}function hP(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function TP(Z){return Z.listParents().some((J)=>J.propertyType!==i.ROOT)}function Ns(Z){for(let J in Z)return!1;return!0}function Os(Z){let J=c6.fromGraph(Z.getGraph()),X=Z.getMaterial(),$=J.getRoot().listMaterials().indexOf(X),Y=YM1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((G)=>{let z=Z.getAttribute(G),v=z.getElementSize(),H=z.getComponentType();return`${G}:${v}:${H}`}).join("+"),W=Z.listTargets().map((G)=>{return G.listSemantics().sort().map((z)=>{let v=Z.getAttribute(z),H=v.getElementSize(),V=v.getComponentType();return`${z}:${H}:${V}`}).join("+")}).join("~");return`${$}|${Y}|${Q}|${K}|${W}`}function $M1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var YM1={[Ks]:Ks,[Iw]:Iw,[sD1]:Iw,[oD1]:Iw,[_w]:_w,[rD1]:_w,[tD1]:_w},L3="center",Ws={pivot:"center"};function Ts(Z=Ws){let J=RZ(Ws,Z);return u$(L3,(X)=>{let $=X.getLogger(),Y=X.getRoot(),Q=Y.listAnimations().length>0||Y.listSkins().length>0;X.getRoot().listScenes().forEach((K,W)=>{$.debug(`${L3}: Scene ${W+1} / ${Y.listScenes().length}.`);let G;if(typeof J.pivot==="string"){let v=PG(K);if(G=[(v.max[0]-v.min[0])/2+v.min[0],(v.max[1]-v.min[1])/2+v.min[1],(v.max[2]-v.min[2])/2+v.min[2]],J.pivot==="above")G[1]=v.max[1];if(J.pivot==="below")G[1]=v.min[1]}else G=J.pivot;$.debug(`${L3}: Pivot "${G.join(", ")}".`);let z=[-1*G[0],-1*G[1],-1*G[2]];if(Q){$.debug(`${L3}: Model contains animation or skin. Adding a wrapper node.`);let v=X.createNode("Pivot").setTranslation(z);K.listChildren().forEach((H)=>v.addChild(H)),K.addChild(v)}else $.debug(`${L3}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((v)=>{let H=v.getTranslation();v.setTranslation([H[0]+z[0],H[1]+z[1],H[2]+z[2]])})}),$.debug(`${L3}: Complete.`)})}function QM1(Z){let J=new Set,X=Z,$;while($=X.getParentNode()){if(J.has($))throw Error("Circular dependency in scene graph.");J.add($),X=$}return X.listParents().filter((Y)=>Y instanceof K3)}function KM1(Z){let J=QM1(Z),X=Z.getParentNode();if(!X)return Z;Z.setMatrix(Z.getWorldMatrix()),X.removeChild(Z);for(let $ of J)$.addChild(Z);return Z}var R3=typeof Float32Array<"u"?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 WM1(Z,J){var X=J[0],$=J[1],Y=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],z=J[7],v=J[8],H=J[9],V=J[10],q=J[11],F=J[12],w=J[13],c=J[14],x=J[15],j=X*W-$*K,B=X*G-Y*K,L=X*z-Q*K,R=$*G-Y*W,M=$*z-Q*W,P=Y*z-Q*G,N=v*w-H*F,O=v*c-V*F,k=v*x-q*F,E=H*c-V*w,S=H*x-q*w,f=V*x-q*c,C=j*f-B*S+L*E+R*k-M*O+P*N;if(!C)return null;return C=1/C,Z[0]=(W*f-G*S+z*E)*C,Z[1]=(Y*S-$*f-Q*E)*C,Z[2]=(w*P-c*M+x*R)*C,Z[3]=(V*M-H*P-q*R)*C,Z[4]=(G*k-K*f-z*O)*C,Z[5]=(X*f-Y*k+Q*O)*C,Z[6]=(c*L-F*P-x*B)*C,Z[7]=(v*P-V*L+q*B)*C,Z[8]=(K*S-W*k+z*N)*C,Z[9]=($*k-X*S-Q*N)*C,Z[10]=(F*M-w*L+x*j)*C,Z[11]=(H*L-v*M-q*j)*C,Z[12]=(W*O-K*E-G*N)*C,Z[13]=(X*E-$*O+Y*N)*C,Z[14]=(w*B-F*R-c*j)*C,Z[15]=(v*R-H*B+V*j)*C,Z}function GM1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],z=Z[8],v=Z[9],H=Z[10],V=Z[11],q=Z[12],F=Z[13],w=Z[14],c=Z[15],x=J*K-X*Q,j=J*W-$*Q,B=J*G-Y*Q,L=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,P=z*F-v*q,N=z*w-H*q,O=z*c-V*q,k=v*w-H*F,E=v*c-V*F,S=H*c-V*w;return x*S-j*E+B*k+L*O-R*N+M*P}function Cs(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],z=J[6],v=J[7],H=J[8],V=J[9],q=J[10],F=J[11],w=J[12],c=J[13],x=J[14],j=J[15],B=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=B*$+L*W+R*H+M*w,Z[1]=B*Y+L*G+R*V+M*c,Z[2]=B*Q+L*z+R*q+M*x,Z[3]=B*K+L*v+R*F+M*j,B=X[4],L=X[5],R=X[6],M=X[7],Z[4]=B*$+L*W+R*H+M*w,Z[5]=B*Y+L*G+R*V+M*c,Z[6]=B*Q+L*z+R*q+M*x,Z[7]=B*K+L*v+R*F+M*j,B=X[8],L=X[9],R=X[10],M=X[11],Z[8]=B*$+L*W+R*H+M*w,Z[9]=B*Y+L*G+R*V+M*c,Z[10]=B*Q+L*z+R*q+M*x,Z[11]=B*K+L*v+R*F+M*j,B=X[12],L=X[13],R=X[14],M=X[15],Z[12]=B*$+L*W+R*H+M*w,Z[13]=B*Y+L*G+R*V+M*c,Z[14]=B*Q+L*z+R*q+M*x,Z[15]=B*K+L*v+R*F+M*j,Z}var j6;(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"})(j6||(j6={}));function m$(Z,J){let X=Z.getAttribute("POSITION"),$=Z.getIndices();switch(J){case j6.RENDER:return $?$.getCount():X.getCount();case j6.RENDER_CACHED:return $?new Set($.getArray()).size:X.getCount();case j6.UPLOAD_NAIVE:case j6.UPLOAD:return X.getCount();case j6.DISTINCT:case j6.DISTINCT_POSITION:return zM1(J);case j6.UNUSED:return $?X.getCount()-new Set($.getArray()).size:0;default:return vM1(J)}}function zM1(Z){throw Error(`Not implemented: ${Z}`)}function vM1(Z){throw Error(`Unexpected value: ${Z}`)}var gJ=4294967295;class fs{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of uw(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),$=Z.getElementSize()*Z.getComponentSize(),Y=E0.padNumber($);return this.attributes.push({u8:X,byteStride:$,paddedByteStride:Y}),Y}hash(Z){let J=0;for(let{u8:X,byteStride:$,paddedByteStride:Y}of this.attributes){for(let Q=0;Q<Y;Q++)if(Q<$)this.u8[J+Q]=X[Z*$+Q];else this.u8[J+Q]=0;J+=Y}return VM1(0,this.u32)}equal(Z,J){for(let{u8:X,byteStride:$}of this.attributes)for(let Y=0;Y<$;Y++)if(X[Z*$+Y]!==X[J*$+Y])return!1;return!0}}function VM1(Z,J){for(let Y=0,Q=J.length;Y<Q;Y++){let K=J[Y];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 HM1(Z,J,X,$,Y=gJ){let Q=J-1,W=X.hash($)&Q;for(let G=0;G<=Q;G++){let z=Z[W];if(z===Y||X.equal(z,$))return W;W=W+G+1&Q}throw Error("Hash table full.")}function dG(Z,J,X){let $=c6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=qM1(Z);let Y=Z.getIndices(),Q=Y?Y.getArray():null,K=m$(Z,j6.RENDER),W=$.createAccessor(),G=K,z=hP(G,X);for(let H=0;H<G;H++)z[H]=J[Q?Q[H]:H];Z.setIndices(W.setArray(z));let v=uw(Z);for(let H of Z.listAttributes()){let V=MZ($,H);CP(H,Y,J,V,X),Z.swap(H,V)}for(let H of Z.listTargets())for(let V of H.listAttributes()){let q=MZ($,V);CP(V,Y,J,q,X),H.swap(V,q)}if(Y&&Y.listParents().length===1)Y.dispose();for(let H of v)if(H.listParents().length===1)H.dispose();return Z}function CP(Z,J,X,$,Y){let Q=Z.getElementSize(),K=Z.getArray(),W=J?J.getArray():null,G=J?J.getCount():Z.getCount(),z=new K.constructor(Y*Q),v=new Uint8Array(Y);for(let H=0;H<G;H++){let V=W?W[H]:H,q=X[V];if(v[q])continue;for(let F=0;F<Q;F++)z[q*Q+F]=K[V*Q+F];v[q]=1}return $.setArray(z)}function qM1(Z){let J=m$(Z,j6.UPLOAD),X=Z.getIndices(),$=X?X.getArray():null;if(!X||!$)return[XM1(J,1e6),J];let Y=new Uint32Array(J).fill(gJ),Q=0;for(let K=0;K<$.length;K++){let W=$[K];if(Y[W]===gJ)Y[W]=Q++}return[Y,Q]}function FM1(){var Z=new R3(9);if(R3!=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 wM1(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 cM1(Z,J){if(Z===J){var X=J[1],$=J[2],Y=J[5];Z[1]=J[3],Z[2]=J[6],Z[3]=X,Z[5]=J[7],Z[6]=$,Z[7]=Y}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 xM1(Z,J){var X=J[0],$=J[1],Y=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],z=J[7],v=J[8],H=v*K-W*z,V=-v*Q+W*G,q=z*Q-K*G,F=X*H+$*V+Y*q;if(!F)return null;return F=1/F,Z[0]=H*F,Z[1]=(-v*$+Y*z)*F,Z[2]=(W*$-Y*K)*F,Z[3]=V*F,Z[4]=(v*X-Y*G)*F,Z[5]=(-W*X+Y*Q)*F,Z[6]=q*F,Z[7]=(-z*X+$*G)*F,Z[8]=(K*X-$*Q)*F,Z}function lw(){var Z=new R3(3);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function UM1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function ks(Z,J){var X=J[0],$=J[1],Y=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 jM1(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=X[3]*$+X[7]*Y+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*$+X[4]*Y+X[8]*Q+X[12])/K,Z[1]=(X[1]*$+X[5]*Y+X[9]*Q+X[13])/K,Z[2]=(X[2]*$+X[6]*Y+X[10]*Q+X[14])/K,Z}function BM1(Z,J,X){var $=J[0],Y=J[1],Q=J[2];return Z[0]=$*X[0]+Y*X[3]+Q*X[6],Z[1]=$*X[1]+Y*X[4]+Q*X[7],Z[2]=$*X[2]+Y*X[5]+Q*X[8],Z}var LM1=UM1;(function(){var Z=lw();return function(J,X,$,Y,Q,K){var W,G;if(!X)X=3;if(!$)$=0;if(Y)G=Math.min(Y*X+$,J.length);else G=J.length;for(W=$;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 fP="weld",Sw={overwrite:!0};function SP(Z=Sw){let J=RZ(Sw,Z);return u$(fP,async(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes()){for(let Q of Y.listPrimitives())if(yw(Q,J),m$(Q,j6.RENDER)===0)Ps(Q);if(Y.listPrimitives().length===0)Y.dispose()}$.debug(`${fP}: Complete.`)})}function yw(Z,J=Sw){let X=Z.getGraph(),Y=c6.fromGraph(X).getLogger(),Q=M3({},Sw,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===g1.Mode.POINTS)return;let K=Z.getAttribute("POSITION").getCount(),W=Z.getIndices(),G=W==null?void 0:W.getArray(),z=W?W.getCount():K,v=new fs(Z),H=$M1(K+K/4),V=new Uint32Array(H).fill(gJ),q=new Uint32Array(K).fill(gJ),F=0;for(let w=0;w<z;w++){let c=G?G[w]:w;if(q[c]!==gJ)continue;let x=HM1(V,H,v,c,gJ),j=V[x];if(j===gJ)V[x]=c,q[c]=F++;else q[c]=q[j]}Y.debug(`${fP}: ${mw(K,F)} vertices.`),dG(Z,q,F)}var{FLOAT:DM1}=K0.ComponentType;function Es(Z,J){let X=Z.getAttribute("POSITION");if(X)Gs(J,X);let $=Z.getAttribute("NORMAL");if($)zs(J,$);let Y=Z.getAttribute("TANGENT");if(Y)vs(J,Y);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)Gs(J,K);let W=Q.getAttribute("NORMAL");if(W)zs(J,W);let G=Q.getAttribute("TANGENT");if(G)vs(J,G)}if(GM1(J)<0)MM1(Z)}function Gs(Z,J){let X=J.getComponentType(),$=J.getNormalized(),Y=J.getArray(),Q=X===DM1?Y:new Float32Array(Y.length),K=lw();for(let W=0,G=J.getCount();W<G;W++){if($)K[0]=I0.decodeNormalizedInt(Y[W*3],X),K[1]=I0.decodeNormalizedInt(Y[W*3+1],X),K[2]=I0.decodeNormalizedInt(Y[W*3+2],X);else K[0]=Y[W*3],K[1]=Y[W*3+1],K[2]=Y[W*3+2];jM1(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(),$=J.getNormalized(),Y=J.getComponentType(),Q=FM1();wM1(Q,Z),xM1(Q,Q),cM1(Q,Q);let K=lw();for(let W=0,G=J.getCount();W<G;W++){if($)K[0]=I0.decodeNormalizedInt(X[W*3],Y),K[1]=I0.decodeNormalizedInt(X[W*3+1],Y),K[2]=I0.decodeNormalizedInt(X[W*3+2],Y);else K[0]=X[W*3],K[1]=X[W*3+1],K[2]=X[W*3+2];if(BM1(K,K,Q),ks(K,K),$)X[W*3]=I0.decodeNormalizedInt(K[0],Y),X[W*3+1]=I0.decodeNormalizedInt(K[1],Y),X[W*3+2]=I0.decodeNormalizedInt(K[2],Y);else X[W*3]=K[0],X[W*3+1]=K[1],X[W*3+2]=K[2]}}function vs(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=lw();for(let K=0,W=J.getCount();K<W;K++){if($)Q[0]=I0.decodeNormalizedInt(X[K*4],Y),Q[1]=I0.decodeNormalizedInt(X[K*4+1],Y),Q[2]=I0.decodeNormalizedInt(X[K*4+2],Y);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],ks(Q,Q),$)X[K*4]=I0.decodeNormalizedInt(Q[0],Y),X[K*4+1]=I0.decodeNormalizedInt(Q[1],Y),X[K*4+2]=I0.decodeNormalizedInt(Q[2],Y);else X[K*4]=Q[0],X[K*4+1]=Q[1],X[K*4+2]=Q[2]}}function MM1(Z){if(Z.getMode()!==g1.Mode.TRIANGLES)return;if(!Z.getIndices())yw(Z);let J=Z.getIndices();for(let X=0,$=J.getCount();X<$;X+=3){let Y=J.getScalar(X),Q=J.getScalar(X+2);J.setScalar(X,Q),J.setScalar(X+2,Y)}}function RM1(Z,J){for(let X of Z.listPrimitives()){let $=PM1(X,Z);if(X!==$)Z.removePrimitive(X).addPrimitive($)}for(let X of Z.listPrimitives())dG(X),Es(X,J)}function PM1(Z,J){if(Z.listParents().some(($)=>$ instanceof NG&&$!==J))Z=Z.clone();for(let $ of Z.listTargets())if($.listParents().some((Q)=>Q instanceof g1&&Q!==Z))Z.removeTarget($).addTarget($.clone());return Z}var Vs=[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&&!I0.eq(X,Vs))RM1(J,X);for(let $ of Z.listChildren()){let Y=$.getMatrix();Cs(Y,Y,X),$.setMatrix(Y)}return Z.setMatrix(Vs)}var{LINES:NM1,LINE_STRIP:OM1,LINE_LOOP:TM1,TRIANGLES:CM1,TRIANGLE_STRIP:fM1,TRIANGLE_FAN:kM1}=g1.Mode;function EM1(Z){let J=Z.getGraph(),X=c6.fromGraph(J);if(!Z.getIndices())yw(Z);let $=Z.getIndices(),Y=$.getArray(),Q=Rs(Z),W=new bJ[$.getComponentType()](Q*2),G=Z.getMode();if(G===OM1)for(let v=0;v<Q;v++)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else if(G===TM1)for(let v=0;v<Q;v++)if(v<Q-1)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else W[v*2]=Y[v],W[v*2+1]=Y[0];else throw Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(NM1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(MZ(X,$).setArray(W));else $.setArray(W)}function _s(Z){let J=Z.getGraph(),X=c6.fromGraph(J);if(!Z.getIndices())yw(Z);let $=Z.getIndices(),Y=$.getArray(),Q=Rs(Z),W=new bJ[$.getComponentType()](Q*3),G=Z.getMode();if(G===fM1)for(let v=0,H=Y.length;v<H-2;v++)if(v%2)W[v*3]=Y[v+1],W[v*3+1]=Y[v],W[v*3+2]=Y[v+2];else W[v*3]=Y[v],W[v*3+1]=Y[v+1],W[v*3+2]=Y[v+2];else if(G===kM1)for(let v=0;v<Q;v++)W[v*3]=Y[0],W[v*3+1]=Y[v+1],W[v*3+2]=Y[v+2];else throw Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(CM1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(MZ(X,$).setArray(W));else $.setArray(W)}var rN6={keepUniqueNames:!1,propertyTypes:[i.ACCESSOR,i.MESH,i.TEXTURE,i.MATERIAL,i.SKIN]};var Hs="dequantize",bw={pattern:/^((?!JOINTS_).)*$/};function hs(Z=bw){let J=RZ(bw,Z);return u$(Hs,(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes())for(let Q of Y.listPrimitives())IM1(Q,J);X.createExtension(iG).dispose(),$.debug(`${Hs}: Complete.`)})}function IM1(Z,J=bw){let X=RZ(bw,J);for(let $ of Z.listSemantics())if(X.pattern.test($))kP(Z.getAttribute($));for(let $ of Z.listTargets())for(let Y of $.listSemantics())if(X.pattern.test(Y))kP($.getAttribute(Y))}function kP(Z){let J=Z.getArray();if(!J)return;let X=Aw(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function Aw(Z,J,X){let $=new Float32Array(Z.length);for(let Y=0,Q=Z.length;Y<Q;Y++)if(X)$[Y]=I0.decodeNormalizedInt(Z[Y],J);else $[Y]=Z[Y];return $}var{TEXTURE_INFO:Ss,ROOT:tN6}=i;function bs(Z){let J=new c6().setLogger(Z.getLogger()),X=bP(J,Z);return _M1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function _M1(Z,J,X){X||(X=bP(Z,J));for(let $ of J.getRoot().listExtensionsUsed()){let Y=Z.createExtension($.constructor);if($.isRequired())Y.setRequired(!0)}return hM1(Z,J,SM1(J),X)}function hM1(Z,J,X,$){$||($=bP(Z,J));let Y=new Map;for(let Q of X)if(!Y.has(Q)&&Q.propertyType!==Ss)Y.set(Q,$(Q));for(let[Q,K]of Y.entries())K.copy(Q,$);return Y}function bP(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return($)=>{if($.propertyType===Ss)return $;let Y=X.get($);if(!Y)Y=new $.constructor(Z.getGraph()),X.set($,Y);return Y}}function SM1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}function As(){var Z=new R3(4);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function bM1(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 AM1(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 mM1(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 uM1(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 lM1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3];return Math.hypot(J,X,$,Y)}var ms=AM1,yM1=mM1,us=lM1;(function(){var Z=As();return function(J,X,$,Y,Q,K){var W,G;if(!X)X=4;if(!$)$=0;if(Y)G=Math.min(Y*X+$,J.length);else G=J.length;for(W=$;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 pM1=/color|emissive|diffuse/i;function iM1(Z){return Z.getGraph().listParentEdges(Z).some((Y)=>{return Y.getAttributes().isColor||pM1.test(Y.getName())})?"srgb":null}function gM1(Z){let J=Z.getGraph(),X=new Set,$=new Set;function Y(Q){let K=new Set;for(let W of J.listChildEdges(Q))if(W.getChild()instanceof _$)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 F1&&K.has(W.getName()))$.add(G);else if(G instanceof O1)Y(G)}}return Y(Z),Array.from($)}function dM1(Z){let X=c6.fromGraph(Z.getGraph()).getRoot(),$=Z.getGraph().listParentEdges(Z).filter((Y)=>Y.getParent()!==X).map((Y)=>Y.getName());return Array.from(new Set($))}var D3="prune",EP=0.011764705882352941,qs={propertyTypes:[i.NODE,i.SKIN,i.MESH,i.CAMERA,i.PRIMITIVE,i.PRIMITIVE_TARGET,i.ANIMATION,i.MATERIAL,i.TEXTURE,i.ACCESSOR,i.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function ls(Z=qs){let J=RZ(qs,Z),X=new Set(J.propertyTypes),$=J.keepExtras;return u$(D3,async(Y)=>{let Q=Y.getLogger(),K=Y.getRoot(),W=Y.getGraph(),G=new ys,z=(v)=>G.dispose(v.target);if(W.addEventListener("node:dispose",z),X.has(i.MESH))for(let v of K.listMeshes()){if(v.listPrimitives().length>0)continue;v.dispose()}if(X.has(i.NODE)){if(!J.keepLeaves)for(let v of K.listScenes())ps(W,v,$);for(let v of K.listNodes())L4(v,$)}if(X.has(i.SKIN))for(let v of K.listSkins())L4(v,$);if(X.has(i.MESH))for(let v of K.listMeshes())L4(v,$);if(X.has(i.CAMERA))for(let v of K.listCameras())L4(v,$);if(X.has(i.PRIMITIVE))Fs(W,i.PRIMITIVE,$);if(X.has(i.PRIMITIVE_TARGET))Fs(W,i.PRIMITIVE_TARGET,$);if(!J.keepAttributes&&X.has(i.ACCESSOR)){let v=new Map;for(let H of K.listMeshes())for(let V of H.listPrimitives()){let q=V.getMaterial();if(!q)continue;let F=is(Y,V,q),w=aM1(V,F);ws(V,w),V.listTargets().forEach((c)=>ws(c,w)),v.has(q)?v.get(q).add(V):v.set(q,new Set([V]))}for(let[H,V]of v)nM1(H,Array.from(V))}if(X.has(i.ANIMATION))for(let v of K.listAnimations()){for(let H of v.listChannels())if(!H.getTargetNode())H.dispose();if(!v.listChannels().length){let H=v.listSamplers();L4(v,$),H.forEach((V)=>L4(V,$))}else v.listSamplers().forEach((H)=>L4(H,$))}if(X.has(i.MATERIAL))K.listMaterials().forEach((v)=>L4(v,$));if(X.has(i.TEXTURE)){if(K.listTextures().forEach((v)=>L4(v,$)),!J.keepSolidTextures)await sM1(Y)}if(X.has(i.ACCESSOR))K.listAccessors().forEach((v)=>L4(v,$));if(X.has(i.BUFFER))K.listBuffers().forEach((v)=>L4(v,$));if(W.removeEventListener("node:dispose",z),!G.empty()){let v=G.entries().map(([H,V])=>`${H} (${V})`).join(", ");Q.info(`${D3}: Removed types... ${v}`)}else Q.debug(`${D3}: No unused properties found.`);Q.debug(`${D3}: Complete.`)})}class ys{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 L4(Z,J){let X=Z.listParents().filter((Y)=>!(Y instanceof W3||Y instanceof QZ)),$=J&&!Ns(Z.getExtras());if(!X.length&&!$)Z.dispose()}function Fs(Z,J,X){for(let $ of Z.listEdges()){let Y=$.getParent();if(Y.propertyType===J)L4(Y,X)}}function ps(Z,J,X){if(J.listChildren().forEach((K)=>ps(Z,K,X)),J instanceof K3)return;let $=Z.listParentEdges(J).some((K)=>{let W=K.getParent().propertyType;return W!==i.ROOT&&W!==i.SCENE&&W!==i.NODE}),Y=Z.listChildren(J).length===0,Q=X&&!Ns(J.getExtras());if(Y&&!$&&!Q)J.dispose()}function ws(Z,J){for(let X of J)Z.setAttribute(X,null)}function aM1(Z,J){let X=[];for(let $ of Z.listSemantics())if($==="NORMAL"&&!J.has($))X.push($);else if($==="TANGENT"&&!J.has($))X.push($);else if($.startsWith("TEXCOORD_")&&!J.has($))X.push($);else if($.startsWith("COLOR_")&&$!=="COLOR_0")X.push($);return X}function is(Z,J,X,$=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let z of Q)if(z.getChild()instanceof _$)K.add(z.getName());for(let z of Q){let v=z.getName(),H=z.getChild();if(H instanceof F1){if(K.has(v.replace(/Info$/,"")))$.add(`TEXCOORD_${H.getTexCoord()}`)}if(H instanceof _$&&v.match(/normalTexture/i))$.add("TANGENT");if(H instanceof O1)is(Z,J,H,$)}let W=X instanceof K7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===g1.Mode.POINTS;if(W&&!G)$.add("NORMAL");return $}function nM1(Z,J){let X=gM1(Z),$=new Set(X.map((G)=>G.getTexCoord())),Y=Array.from($).sort(),Q=new Map(Y.map((G,z)=>[G,z])),K=new Map(Y.map((G,z)=>[`TEXCOORD_${G}`,`TEXCOORD_${z}`]));for(let G of X){let z=G.getTexCoord();G.setTexCoord(Q.get(z))}for(let G of J){let z=G.listSemantics().filter((v)=>v.startsWith("TEXCOORD_")).sort();W(G,z),G.listTargets().forEach((v)=>W(v,z))}function W(G,z){for(let v of z){let H=G.getAttribute(v);if(!H)continue;let V=K.get(v);if(V===v)continue;G.setAttribute(V,H),G.setAttribute(v,null)}}}async function sM1(Z){let J=Z.getRoot(),X=Z.getGraph(),$=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await rM1(K);if(!G)return;if(iM1(K)==="srgb")HR.convertSRGBToLinear(G,G);let z=K.getName()||K.getURI(),v=(W=K.getSize())==null?void 0:W.join("x"),H=dM1(K);for(let V of X.listParentEdges(K)){let q=V.getParent();if(q!==J&&oM1(q,G,V.getName(),$))V.dispose()}if(K.listParents().length===1)K.dispose(),$.debug(`${D3}: Removed solid-color texture "${z}" (${v}px ${H.join(", ")})`)});await Promise.all(Q)}function oM1(Z,J,X,$){if(Z instanceof K7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(yM1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(LM1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=EP;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return us(ms(As(),J,[0.5,0.5,1,1]))<=EP}return $.warn(`${D3}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function rM1(Z){let J=await tM1(Z);if(!J)return null;let X=[1/0,1/0,1/0,1/0],$=[-1/0,-1/0,-1/0,-1/0],Y=[0,0,0,0],[Q,K]=J.shape;for(let W=0;W<Q;W++){for(let G=0;G<K;G++)for(let z=0;z<4;z++)X[z]=Math.min(X[z],J.get(W,G,z)),$[z]=Math.max($[z],J.get(W,G,z));if(us(ms(Y,$,X))/255>EP)return null}return uM1(Y,bM1(Y,$,X),0.00196078431372549)}async function tM1(Z){try{return await hn(Z.getImage(),Z.getMimeType())}catch(J){return null}}var PP="flatten",cs={cleanup:!0};function gs(Z=cs){let J=RZ(cs,Z);return u$(PP,async(X)=>{let $=X.getRoot(),Y=X.getLogger(),Q=new Set;for(let z of $.listSkins())for(let v of z.listJoints())Q.add(v);let K=new Set;for(let z of $.listAnimations())for(let v of z.listChannels()){let H=v.getTargetNode();if(H&&v.getTargetPath()!=="weights")K.add(H)}let W=new Set,G=new Set;for(let z of $.listScenes())z.traverse((v)=>{let H=v.getParentNode();if(!H)return;if(Q.has(H)||W.has(H))W.add(v);if(K.has(H)||G.has(H))G.add(v)});for(let z of $.listScenes())z.traverse((v)=>{if(K.has(v))return;if(W.has(v))return;if(G.has(v))return;KM1(v)});if(K.size)Y.debug(`${PP}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(ls({propertyTypes:[i.NODE],keepLeaves:!1}));Y.debug(`${PP}: Complete.`)})}function ds(Z){return PG(Z)}var eM1={skipValidation:!1},xs=4294967295,{LINE_STRIP:ZR1,LINE_LOOP:JR1,TRIANGLE_STRIP:XR1,TRIANGLE_FAN:$R1}=g1.Mode;function YR1(Z,J={}){let X=RZ(eM1,J),$=Z[0],Y=c6.fromGraph($.getGraph());if(!X.skipValidation&&new Set(Z.map(Os)).size>1)throw 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 ZR1:case JR1:EM1(q);break;case XR1:case $R1:_s(q);break}let Q=[],K=new Uint32Array(Z.length),W=0,G=0;for(let q=0;q<Z.length;q++){let F=Z[q],w=F.getIndices(),c=F.getAttribute("POSITION").getCount(),x=w?w.getArray():null,j=w?w.getCount():c,B=new Uint32Array(c).fill(xs);for(let L=0;L<j;L++){let R=x?x[L]:L;if(B[R]===xs)B[R]=W++,K[q]++}Q.push(B),G+=j}let z=Y.createPrimitive().setMode($.getMode()).setMaterial($.getMaterial());for(let q of $.listSemantics()){let F=$.getAttribute(q),w=bJ[F.getComponentType()],c=MZ(Y,F).setArray(new w(W*F.getElementSize()));z.setAttribute(q,c)}let v=$.getIndices(),H=v?MZ(Y,v).setArray(hP(G,W)):null;z.setIndices(H);let V=0;for(let q=0;q<Q.length;q++){let F=Z[q],w=F.getIndices(),c=w?w.getCount():-1,x=Q[q];if(w&&H)KR1(w,x,H,V),V+=c;for(let j of z.listSemantics()){let B=F.getAttribute(j),L=z.getAttribute(j);QR1(B,w,x,L)}}return z}function QR1(Z,J,X,$){let Y=Z.getElementSize(),Q=J?J.getArray():null,K=Z.getCount(),W=Z.getArray(),G=$.getArray(),z=new Uint8Array(Z.getCount());for(let v=0,H=J?J.getCount():K;v<H;v++){let V=Q?Q[v]:v,q=X[V];if(z[q])continue;for(let F=0;F<Y;F++)G[q*Y+F]=W[V*Y+F];z[q]=1}}function KR1(Z,J,X,$){let Y=Z.getCount(),Q=Z.getArray(),K=X.getArray();for(let W=0;W<Y;W++){let G=Q[W],z=J[G];K[$+W]=z}}var IP="join",{ROOT:WR1,NODE:GR1,MESH:zR1,PRIMITIVE:vR1,ACCESSOR:VR1}=i,NP=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Us={keepMeshes:!1,keepNamed:!1,cleanup:!0,filter:()=>!0};function as(Z=Us){let J=RZ(Us,Z);return u$(IP,async(X)=>{let $=X.getRoot(),Y=X.getLogger();for(let Q of $.listScenes())js(X,Q,J),Q.traverse((K)=>js(X,K,J));if(J.cleanup)await X.transform(ls({propertyTypes:[GR1,zR1,vR1,VR1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));Y.debug(`${IP}: Complete.`)})}function js(Z,J,X){let $=Z.getLogger(),Y={},Q=J.listChildren();for(let G=0;G<Q.length;G++){let z=Q[G];if(!X.filter(z))continue;if(z.listParents().some((V)=>V instanceof QZ))continue;let H=z.getMesh();if(!H)continue;if(z.getExtension("EXT_mesh_gpu_instancing"))continue;if(z.getSkin())continue;for(let V of H.listPrimitives()){if(V.listTargets().length>0)continue;let q=V.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;dG(V),qR1(V);let F=Os(V),w=H.getName()||z.getName();if(X.keepMeshes||X.keepNamed&&w)F+=`|${G}`;if(!(F in Y))Y[F]={prims:[],primMeshes:[],primNodes:[],dstNode:z,dstMesh:void 0};let c=Y[F];c.prims.push(V),c.primNodes.push(z)}}let K=Object.values(Y).filter(({prims:G})=>G.length>1),W=new Set(K.flatMap((G)=>G.primNodes));for(let G of W){let z=G.getMesh();if(z.listParents().some((H)=>{return H.propertyType!==WR1&&G!==H}))G.setMesh(z.clone())}for(let G of K){let{dstNode:z,primNodes:v}=G;G.dstMesh=z.getMesh(),G.primMeshes=v.map((H)=>H.getMesh())}for(let G of K){let{prims:z,primNodes:v,primMeshes:H,dstNode:V,dstMesh:q}=G,F=V.getMatrix();for(let x=0;x<z.length;x++){let j=v[x],B=H[x],L=z[x];if(B.removePrimitive(L),TP(L))L=z[x]=HR1(z[x]);if(j!==V)Cs(NP,WM1(NP,F),j.getMatrix()),Es(L,NP)}let w=YR1(z),c=w.listAttributes()[0].getCount();q.addPrimitive(w),$.debug(`${IP}: Joined Primitives (${z.length}) containing ${OP(c)} vertices under Node "${V.getName()}".`)}}function HR1(Z){let J=Z.clone();for(let $ of J.listSemantics())J.setAttribute($,J.getAttribute($).clone());let X=J.getIndices();if(X)J.setIndices(X.clone());return J}function qR1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)kP(X)}}var{TRANSLATION:eN6,ROTATION:ZO6,SCALE:JO6,WEIGHTS:XO6}=QZ.TargetPath;var FR1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var $O6=M3({level:"high"},FR1);var wR1="unweld";function cR1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let $=Z.getGraph(),Y=c6.fromGraph($),Q=Y.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,Bs(Y,G,X,J)),G.listParents().length===1)G.dispose();for(let G of Z.listTargets())for(let z of G.listAttributes())if(G.swap(z,Bs(Y,z,X,J)),z.listParents().length===1)z.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${wR1}: ${mw(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function Bs(Z,J,X,$){if($.has(J)&&$.get(J).has(X))return $.get(J).get(X);let Y=J.getArray(),K=new Y.constructor(X.getCount()*J.getElementSize()),W=X.getArray(),G=J.getElementSize();for(let v=0,H=X.getCount();v<H;v++)for(let V=0;V<G;V++)K[v*G+V]=Y[W[v]*G+V];if(!$.has(J))$.set(J,new Map);let z=MZ(Z,J).setArray(K);return $.get(J).set(X,z),z}var Ls;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(Ls||(Ls={}));var xR1=0.000001;function UR1(Z,J,X,$=0.0001){let Y=J.length/Z.length,Q=Array(Y).fill(0),K=Array(Y).fill(0),W=Array(Y).fill(0),G=Array(Y).fill(0),z=Z.length-1,v=1;for(let H=1;H<z;++H){let V=Z[v-1],q=Z[H],F=Z[H+1],w=(q-V)/(F-V),c=!1;if(q!==F&&(H!==1||q!==Z[0])){if(gG(J,v-1,G),gG(J,H,K),gG(J,H+1,W),X==="slerp"){let x=LR1(Q,G,W,w),j=Ms(G,K)+Ms(K,W);c=!hw(K,x,$)||j+Number.EPSILON>=Math.PI}else if(X==="lerp"){let x=BR1(Q,G,W,w);c=!hw(K,x,$)}else if(X==="step")c=!hw(K,G)||!hw(K,W)}if(c){if(H!==v)Z[v]=Z[H],Ds(J,v,gG(J,H,Q));v++}}if(z>0)Z[v]=Z[z],Ds(J,v,gG(J,z,Q)),v++;return v}function gG(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)X[$]=Z[J*Y+$];return X}function Ds(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)Z[J*Y+$]=X[$]}function hw(Z,J,X=0){if(Z.length!==J.length)return!1;for(let $=0;$<Z.length;$++)if(Math.abs(Z[$]-J[$])>X)return!1;return!0}function jR1(Z,J,X){return Z*(1-X)+J*X}function BR1(Z,J,X,$){for(let Y=0;Y<J.length;Y++)Z[Y]=jR1(J[Y],X[Y],$);return Z}function LR1(Z,J,X,$){let Y=J[0],Q=J[1],K=J[2],W=J[3],G=X[0],z=X[1],v=X[2],H=X[3],V,q,F,w,c;if(q=Y*G+Q*z+K*v+W*H,q<0)q=-q,G=-G,z=-z,v=-v,H=-H;if(1-q>xR1)V=Math.acos(q),F=Math.sin(V),w=Math.sin((1-$)*V)/F,c=Math.sin($*V)/F;else w=1-$,c=$;return Z[0]=w*Y+c*G,Z[1]=w*Q+c*z,Z[2]=w*K+c*v,Z[3]=w*W+c*H,Z}function Ms(Z,J){let X=DR1(Z,J);return Math.acos(2*X*X-1)}function DR1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var YO6=new Float32Array(0),QO6={ready:Promise.resolve(),resample:UR1,tolerance:0.0001,cleanup:!0};var A$="simplify",{POINTS:ns,LINES:MR1,LINE_STRIP:RR1,LINE_LOOP:PR1,TRIANGLES:NR1,TRIANGLE_STRIP:ss,TRIANGLE_FAN:os}=g1.Mode,rs={ratio:0,error:0.0001,lockBorder:!1};function ts(Z){let J=RZ(rs,Z),X=J.simplifier;if(!X)throw Error(`${A$}: simplifier dependency required — install "meshoptimizer".`);return u$(A$,async($)=>{let Y=$.getLogger();await X.ready,await $.transform(SP({overwrite:!1}));let Q=0;for(let K of $.getRoot().listMeshes()){for(let W of K.listPrimitives()){let G=W.getMode();if(G!==NR1&&G!==ss&&G!==os&&G!==ns){Q++;continue}if(OR1(W,J),m$(W,j6.RENDER)===0)Ps(W)}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)Y.warn(`${A$}: Skipped ${Q} primitives: Unsupported draw mode.`);Y.debug(`${A$}: Complete.`)})}function OR1(Z,J){let X=M3({},rs,J),$=X.simplifier,Y=Z.getGraph(),Q=c6.fromGraph(Y),K=Q.getLogger();switch(Z.getMode()){case ns:return TR1(Q,Z,X);case MR1:case RR1:case PR1:return K.warn(`${A$}: Skipping primitive simplification: Unsupported draw mode.`),Z;case ss:case os:_s(Z);break}let W=m$(Z,j6.UPLOAD),G=m$(Z,j6.RENDER);if(G<W/2)dG(Z);let z=Z.getAttribute("POSITION"),v=Z.getIndices(),H=z.getArray(),V=v.getArray();if(!(H instanceof Float32Array))H=Aw(H,z.getComponentType(),z.getNormalized());if(!(V instanceof Uint32Array))V=new Uint32Array(V);let q=Math.floor(X.ratio*G/3)*3,F=X.lockBorder?["LockBorder"]:[],[w,c]=$.simplify(V,H,3,q,X.error,F);if(Z.setIndices(MZ(Q,v).setArray(w)),v.listParents().length===1)v.dispose();dG(Z);let x=m$(Z,j6.UPLOAD);if(x<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${A$}: ${mw(W,x)} vertices, error: ${c.toFixed(4)}.`),Z}function TR1(Z,J,X){let $=X.simplifier,Y=Z.getLogger();if(J.getIndices())cR1(J);let K=J.getAttribute("POSITION"),W=J.getAttribute("COLOR_0"),G=K.getCount(),z=K.getArray(),v=W?W.getArray():void 0,H=W?W.getComponentSize():void 0;if(!(z instanceof Float32Array))z=Aw(z,K.getComponentType(),K.getNormalized());if(v&&!(v instanceof Float32Array))v=Aw(v,K.getComponentType(),K.getNormalized());let V=Math.floor(X.ratio*G),q=$.simplifyPoints(z,3,V,v,H),[F,w]=$.compactMesh(q);Y.debug(`${A$}: ${mw(K.getCount(),w)} vertices.`);for(let c of uw(J)){let x=MZ(Z,c);if(CP(c,null,F,x,w),JM1(J,c,x),c.listParents().length===1)c.dispose()}return J}var _P;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(_P||(_P={}));var KO6={resizeFilter:_P.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var Qo=t(Yo(),1);var PZ={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DATA_SCHEMA_VERSION:1,DATA_EXT:".data.json",DIRECTORIES:[(()=>{try{return q5.dirname(g.resolve("@hytopia.com/assets"))}catch{return null}})(),q5.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 B6{static instance=new B6;optimize=!0;optimizeEveryStart=!1;_modelUriAnimationNames=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...`);let J=performance.now();for(let $ of Z){if(this.optimize)await this._resolveOptimizedModelPath($);await this._loadModelData($)}let X=performance.now();console.log(`ModelRegistry.preloadModels(): Preloaded ${Z.length} models in ${X-J}ms!`)}getAnimationNames(Z){let J=this._modelUriAnimationNames.get(Z);if(!J)p.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J}getBoundingBox(Z){let J=this._modelUriBoundingBoxes.get(Z);if(!J)p.fatalError(`ModelRegistry.getBoundingBox(): Model ${Z} not found!`);return J}getDepth(Z){let J=this.getBoundingBox(Z);return J.max.z-J.min.z}getHeight(Z){let J=this.getBoundingBox(Z);return J.max.y-J.min.y}getNodeNames(Z){let J=this._modelUriNodeNames.get(Z);if(!J)p.fatalError(`ModelRegistry.getNodeNames(): Model ${Z} not found!`);return J}getTrimesh(Z,J=1){let X=this._modelUriTrimeshes.get(Z);if(!X){p.error(`ModelRegistry.getTrimesh(): Model ${Z} not found!`);return}let $=X.vertices;if(J!==1){$=new Float32Array($.length);for(let Y=0;Y<$.length;Y++)$[Y]=X.vertices[Y]*J}return{vertices:$,indices:X.indices}}getWidth(Z){let J=this.getBoundingBox(Z);return J.max.x-J.min.x}modelHasNode(Z,J){let X=this._modelUriNodeNames.get(Z);if(!X)p.fatalError(`ModelRegistry.modelHasNode(): Model ${Z} not found!`);return X.includes(J)}_absoluteModelPathToModelUri(Z){let J=q5.normalize(Z);for(let X of PZ.DIRECTORIES){let $=q5.normalize(X);if(J.startsWith($))return q5.relative($,J).replace(/\\/g,"/")}return q5.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of PZ.DIRECTORIES){let X=q5.resolve(process.cwd(),J);if(!D4.existsSync(X))continue;let $=await uF("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let Y of $)Z.push(q5.join(X,Y))}return Z}async _loadModelData(Z){let X=`${this._buildOptimizedModelPath(Z)}${PZ.DATA_EXT}`,$=this._absoluteModelPathToModelUri(Z),Y=this._calculateChecksum(Z),Q;if(D4.existsSync(X))try{let K=D4.readFileSync(X,"utf8"),W=JSON.parse(K);if(W?.schemaVersion!==PZ.DATA_SCHEMA_VERSION)throw Error("ModelRegistry._loadModelData(): Schema version mismatch! Data will be regenerated..");if(W?.source?.sha256!==Y)throw Error("ModelRegistry._loadModelData(): Checksum mismatch! Data will be regenerated..");Q=W}catch{}if(!Q){let K=await new xR().read(Z),W=ds(K.getRoot().listScenes()[0]),G=K.getRoot().listNodes().map((H)=>H.getName()),z=K.getRoot().listAnimations().map((H)=>H.getName()),v=await this._buildTrimesh(K);Q={schemaVersion:PZ.DATA_SCHEMA_VERSION,source:{uri:$,sha256:Y},animationNames:z,boundingBox:{min:{x:W.min[0],y:W.min[1],z:W.min[2]},max:{x:W.max[0],y:W.max[1],z:W.max[2]}},nodeNames:G,trimesh:v?{vertices:Array.from(v.vertices),indices:Array.from(v.indices)}:void 0};try{let H=q5.dirname(X);D4.mkdirSync(H,{recursive:!0}),D4.writeFileSync(X,JSON.stringify(Q))}catch(H){p.warning(`ModelRegistry._loadModelData(): Failed to write data file for ${$}. Error: ${String(H)}`)}}this._modelUriAnimationNames.set($,Q.animationNames),this._modelUriBoundingBoxes.set($,Q.boundingBox),this._modelUriNodeNames.set($,Q.nodeNames),this._modelUriTrimeshes.set($,Q.trimesh?{vertices:new Float32Array(Q.trimesh.vertices),indices:new Uint32Array(Q.trimesh.indices)}:void 0)}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)}${PZ.CHECKSUM_EXT}`;if(!D4.existsSync(J))return!1;let X=this._calculateChecksum(Z),$=D4.readFileSync(J,"utf8");return X===$}_calculateChecksum(Z){if(!D4.existsSync(Z))return"";let J=D4.readFileSync(Z);return IR1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=q5.basename(Z),X=J.replace(/\.[^/.]+$/,""),$=q5.dirname(Z),Y=q5.join($,PZ.OPTIMIZED_DIR,X);return q5.join(Y,J)}async _buildTrimesh(Z,J=1,X=0.001){let $=bs(Z);$.setLogger(new z5(MG.WARN)),await $.transform(Ts({pivot:"center"}),gs(),as(),SP(),ts({simplifier:Qo.MeshoptSimplifier,ratio:J,error:X}),hs());for(let V of $.getRoot().listScenes())for(let q of V.listChildren())Is(q);let Y=[],Q=0,K=0;for(let V of $.getRoot().listMeshes())for(let q of V.listPrimitives()){let F=q.getAttribute("POSITION"),w=q.getIndices();if(!F||!w)continue;let c=F.getArray(),x=w.getArray(),j=x instanceof Uint32Array?x:new Uint32Array(x);if(c.length===0||j.length===0)continue;Y.push({vertices:c,indices:j}),Q+=c.length,K+=j.length}if(Y.length===0){p.error("ModelRegistry._buildTrimesh(): Model has no primitives with POSITION and INDICES!");return}let W=new Float32Array(Q),G=new Uint32Array(K),z=0,v=0,H=0;for(let V of Y){W.set(V.vertices,z);let q=V.vertices.length/3;for(let F=0;F<V.indices.length;F++)G[H+F]=V.indices[F]+v;z+=V.vertices.length,H+=V.indices.length,v+=q}return{vertices:W,indices:G}}async _optimizeModel(Z,J){let X=q5.dirname(J);D4.rmSync(X,{recursive:!0,force:!0}),D4.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let $ of PZ.OPTIMIZER_RUNS){let Y=J.replace(/(\.[^/.]+)$/,`${$.suffix}$1`),{stderr:Q}=await Bi("npx",["@gltf-transform/cli","optimize",Z,Y,...$.options]);if(Q)return p.warning(`ModelRegistry._optimizeModel(): Error optimizing model ${this._absoluteModelPathToModelUri(Z)}, defaulting to unoptimized model. Error: ${Q}`),Z}return D4.writeFileSync(`${J}${PZ.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var rG;((Y)=>{Y.DYNAMIC="dynamic";Y.FIXED="fixed";Y.KINEMATIC_POSITION="kinematic_position";Y.KINEMATIC_VELOCITY="kinematic_velocity"})(rG||={});var yP=0.001,Ko="dynamic";class dJ extends j0{_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??=Ko,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:$}=this.rotation;return{x:-2*(Z*X+$*J),y:-2*(J*X-$*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 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 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:$,principalAngularInertiaLocalFrame:Y}=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"]:X1.RigidBodyType.Dynamic,["fixed"]:X1.RigidBodyType.Fixed,["kinematic_position"]:X1.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:X1.RigidBodyType.KinematicVelocityBased}[Z];if(X===void 0)return p.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 p.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 A5({...Z,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(Z)}createAndAddChildColliders(Z){let J=[];return Z.forEach((X)=>{let $=this.createAndAddChildCollider(X);if($)J.push($)}),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 p.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 p.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 p.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,$])=>{if(X in Z)$(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 A5(Z);return this._colliders.add(J),J}_createAndAddPendingChildColliders(Z){let J=[];return Z.forEach((X)=>{let $=this._createAndAddPendingChildCollider(X);if($)J.push($)}),J}_createRigidBodyDesc(Z){let J=Z.type??Ko;return{["dynamic"]:()=>X1.RigidBodyDesc.dynamic(),["fixed"]:()=>X1.RigidBodyDesc.fixed(),["kinematic_position"]:()=>X1.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>X1.RigidBodyDesc.kinematicVelocityBased()}[J]()}_requireCreated(Z){if(!this._rigidBody||!this._simulation)p.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)p.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)p.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)p.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)p.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)p.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)<yP&&Math.abs(Z.y)<yP&&Math.abs(Z.z)<yP}}var pP;((Y)=>{Y[Y.Average=0]="Average";Y[Y.Min=1]="Min";Y[Y.Multiply=2]="Multiply";Y[Y.Max=3]="Max"})(pP||={});var P3;((v)=>{v.NONE="none";v.BALL="ball";v.BLOCK="block";v.CAPSULE="capsule";v.CONE="cone";v.CYLINDER="cylinder";v.ROUND_CYLINDER="round-cylinder";v.TRIMESH="trimesh";v.VOXELS="voxels";v.WEDGE="wedge"})(P3||={});class A5 extends j0{_collider;_colliderDesc;_onCollision;_parentRigidBody;_relativePosition={x:0,y:0,z:0};_relativeRotation={x:0,y:0,z:0,w:1};_shape;_simulation;_tag;constructor(Z){super();this._colliderDesc=this._createColliderDesc(Z),this._shape=Z.shape,this._applyColliderOptions(Z),this._autoAddToSimulation(Z)}static optionsFromBlockHalfExtents(Z){return{shape:"block",halfExtents:Z}}static optionsFromModelUri(Z,J=1,X){let $=B6.instance.getBoundingBox(Z),Y=$.max.x-$.min.x,Q=$.max.y-$.min.y,K=$.max.z-$.min.z,W=Math.max(Y,K),G=Math.min(Y,K),z=W/G,v=W/Q,H=W*J/2,V=(j)=>Math.max(0.01,j),q=()=>({shape:"block",halfExtents:{x:V(Y*J/2),y:V(Q*J/2),z:V(K*J/2)}}),F=()=>({shape:"round-cylinder",radius:V(H),halfHeight:V(Q*J/2),borderRadius:V(H*0.1)}),w=()=>{let j=B6.instance.getTrimesh(Z,J);if(!j)return;return{shape:"trimesh",vertices:j.vertices,indices:j.indices}},c=()=>({shape:"wedge",extents:{x:Y*J,y:Q*J,z:K*J}}),x=()=>({shape:"capsule",radius:V(H),halfHeight:V(Q*J/2-H)});if(X)switch(X){case"block":return q();case"capsule":return x();case"round-cylinder":return F();case"trimesh":{let j=w();if(!j){p.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return j}case"wedge":return c();default:p.warning(`Collider.optionsFromModelUri(): Preferred shape ${X} is not yet supported with Collider.optionsFromModelUri(), defaulting to generic shape!`)}if(z>2)return q();if(v>1.5)return F();return x()}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?v9.decodeRawCollisionGroups(this._collider.collisionGroups()):v9.decodeRawCollisionGroups(this._colliderDesc.collisionGroups)}get friction(){if(!this._requireNotRemoved("friction"))return 0;return this._collider?this._collider.friction():this._colliderDesc.friction}get frictionCombineRule(){if(!this._requireNotRemoved("frictionCombineRule"))return 0;return this._collider?this._collider.frictionCombineRule():this._colliderDesc.frictionCombineRule}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._collider?this._collider.isEnabled():this._colliderDesc.enabled}get isRemoved(){return!this._collider&&!this._colliderDesc}get isSensor(){if(!this._requireNotRemoved("isSensor"))return!1;return this._collider?this._collider.isSensor():this._colliderDesc.isSensor}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return!!this._collider}get parentRigidBody(){if(!this._requireNotRemoved("parentRigidBody"))return;return this._parentRigidBody}get rawCollider(){if(!this._requireNotRemoved("rawCollider"))return;return this._collider}get rawShape(){if(!this._requireNotRemoved("rawShape"))return;return this._collider?this._collider.shape:this._colliderDesc.shape}get relativePosition(){if(!this._requireNotRemoved("relativePosition"))return{x:0,y:0,z:0};return this._relativePosition}get relativeRotation(){if(!this._requireNotRemoved("relativeRotation"))return{x:0,y:0,z:0,w:1};return this._relativeRotation}get shape(){if(!this._requireNotRemoved("shape"))return"none";return this._shape}get tag(){if(!this._requireNotRemoved("tag"))return;return this._tag}setBounciness(Z){if(!this._requireNotRemoved("setBounciness"))return;this._collider?this._collider.setRestitution(Z):this._colliderDesc.setRestitution(Z)}setBouncinessCombineRule(Z){if(!this._requireNotRemoved("setBouncinessCombineRule"))return;this._collider?this._collider.setRestitutionCombineRule(Z):this._colliderDesc.setRestitutionCombineRule(Z)}setCollisionGroups(Z){if(!this._requireNotRemoved("setCollisionGroups"))return;let J=v9.buildRawCollisionGroups(Z);this._collider?this._collider.setCollisionGroups(J):this._colliderDesc.setCollisionGroups(J)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._collider?this._collider.setEnabled(Z):this._colliderDesc.setEnabled(Z)}setFriction(Z){if(!this._requireNotRemoved("setFriction"))return;this._collider?this._collider.setFriction(Z):this._colliderDesc.setFriction(Z)}setFrictionCombineRule(Z){if(!this._requireNotRemoved("setFrictionCombineRule"))return;this._collider?this._collider.setFrictionCombineRule(Z):this._colliderDesc.setFrictionCombineRule(Z)}setMass(Z){if(!this._requireNotRemoved("setMass"))return;this._collider?this._collider.setMass(Z):this._colliderDesc.setMass(Z)}setOnCollision(Z){if(!this._requireNotRemoved("setOnCollision"))return;if(this._onCollision=Z,this.isSimulated)if(this.enableCollisionEvents(!!Z),Z)this._simulation.colliderMap.setColliderCollisionCallback(this,Z);else this._simulation.colliderMap.removeColliderCollisionCallback(this)}setRelativeRotation(Z){if(!this._requireNotRemoved("setRelativeRotation"))return;this._relativeRotation=Z,this._collider?this._collider.parent()?this._collider.setRotationWrtParent(Z):this._collider.setRotation(Z):this._colliderDesc.setRotation(Z)}setRelativePosition(Z){if(!this._requireNotRemoved("setRelativePosition"))return;this._relativePosition=Z,this._collider?this._collider.parent()?this._collider.setTranslationWrtParent(Z):this._collider.setTranslation(Z):this._colliderDesc.setTranslation(Z.x,Z.y,Z.z)}setSensor(Z){if(!this._requireNotRemoved("setSensor"))return;this._collider?this._collider.setSensor(Z):this._colliderDesc.setSensor(Z)}setTag(Z){if(!this._requireNotRemoved("setTag"))return;this._tag=Z}setVoxel(Z,J){if(!this._requireNotRemoved("setVoxel"))return;if(!this._requireSimulated("setVoxel"))return;if(this.shape!=="voxels")return p.error("Collider.setVoxel(): Collider is not a voxels collider!");this._collider.setVoxel(Z.x,Z.y,Z.z,J)}addToSimulation(Z,J){if(!this._requireNotRemoved("addToSimulation"))return;if(!this._requireUnsimulated("addToSimulation"))return;if(J){if(!J.isSimulated)return p.error("Collider.addToSimulation(): Rigid body must be simulated before adding a collider to it!");if(J.type==="dynamic"&&this.shape==="trimesh")p.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)}combineVoxelStates(Z){if(!this._requireNotRemoved("combineVoxelStates"))return;if(!this._requireSimulated("combineVoxelStates"))return;if(!Z.isSimulated)return p.error("Collider.combineVoxelStates(): Other collider is not simulated!");if(this.shape!=="voxels")return p.error("Collider.combineVoxelStates(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return p.error("Collider.combineVoxelStates(): Other collider is not a voxels collider!");this._collider.combineVoxelStates(Z.rawCollider,0,0,0)}enableCollisionEvents(Z){if(!this._requireNotRemoved("enableCollisionEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|X1.ActiveEvents.COLLISION_EVENTS:J&~X1.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|X1.ActiveEvents.CONTACT_FORCE_EVENTS:J&~X1.ActiveEvents.CONTACT_FORCE_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}propagateVoxelChange(Z,J){if(!this._requireNotRemoved("propagateVoxelChange"))return;if(!this._requireSimulated("propagateVoxelChange"))return;if(!Z.isSimulated)return p.error("Collider.propagateVoxelChange(): Other collider is not simulated!");if(this.shape!=="voxels")return p.error("Collider.propagateVoxelChange(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return p.error("Collider.propagateVoxelChange(): Other collider is not a voxels collider!");this._collider.propagateVoxelChange(Z.rawCollider,J.x,J.y,J.z,0,0,0)}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}scale(Z){if(!this._requireNotRemoved("scale"))return;switch(this.setRelativePosition({x:this.relativePosition.x*Z,y:this.relativePosition.y*Z,z:this.relativePosition.z*Z}),this._shape){case"ball":{if(this._collider)this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.radius*=Z;return}case"block":{if(this._collider){let J=this._collider.halfExtents();this._collider.setHalfExtents({x:J.x*Z,y:J.y*Z,z:J.z*Z})}else this._colliderDesc.shape.halfExtents.x*=Z,this._colliderDesc.shape.halfExtents.y*=Z,this._colliderDesc.shape.halfExtents.z*=Z;return}case"capsule":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cone":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"round-cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRoundRadius(this._collider.roundRadius()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight=this._colliderDesc.shape.halfHeight*Z,this._colliderDesc.shape.borderRadius=this._colliderDesc.shape.borderRadius*Z,this._colliderDesc.shape.radius=this._colliderDesc.shape.radius*Z;return}case"trimesh":{p.error("Collider.setScale(): Trimesh colliders cannot be scaled!");return}case"voxels":{p.error("Collider.setScale(): Voxels colliders cannot be scaled!");return}case"wedge":{p.error("Collider.setScale(): Wedge colliders cannot be scaled!");return}default:p.fatalError(`Collider.setScale(): ${this._shape} is not a valid collider shape!`)}}_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,$])=>{if(Z[X]!==void 0)$.call(this,Z[X])})}_autoAddToSimulation(Z){if(Z.simulation)this.addToSimulation(Z.simulation,Z.parentRigidBody)}_buildWedgeConvexHullVertices(Z){let{x:J,y:X,z:$}=Z,Y=J/2,Q=$/2,K=X/2;return new Float32Array([-Y,0-K,-Q,Y,0-K,-Q,Y,0-K,Q,-Y,0-K,Q,-Y,X-K,-Q,Y,X-K,-Q])}_createColliderDesc(Z){let{shape:J,flags:X}=Z;switch(J){case"ball":{if(!Z.radius)p.fatalError("Ball collider must have a radius!");return X1.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)p.fatalError("Block collider must have halfExtents!");return X1.ColliderDesc.cuboid(Z.halfExtents.x,Z.halfExtents.y,Z.halfExtents.z)}case"capsule":{if(!Z.halfHeight||!Z.radius)p.fatalError("Capsule collider must have halfHeight and radius!");return X1.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)p.fatalError("Cone collider must have radius and halfHeight!");return X1.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)p.fatalError("Cylinder collider must have radius and halfHeight!");return X1.ColliderDesc.cylinder(Z.halfHeight,Z.radius)}case"round-cylinder":{if(!Z.radius||!Z.halfHeight||!Z.borderRadius)p.fatalError("Round cylinder collider must have radius, halfHeight, and borderRadius!");return X1.ColliderDesc.roundCylinder(Z.halfHeight,Z.radius,Z.borderRadius)}case"trimesh":{if(!Z.indices||!Z.vertices)p.fatalError("Trimesh collider must have vertices and indices!");return X1.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"voxels":{if(!Z.coordinates||!Z.size)p.fatalError("Voxels collider must have coordinates and size!");return X1.ColliderDesc.voxels(this._coordinatesToInt32Array(Z.coordinates),Z.size)}case"wedge":{if(!Z.extents)p.fatalError("Wedge collider must have extents!");let $=this._buildWedgeConvexHullVertices(Z.extents),Y=X1.ColliderDesc.convexHull($);if(!Y)throw p.fatalError("Failed to create convex hull for wedge collider!"),Error("Convex hull creation failed");return Y}default:p.fatalError(`Collider._createColliderDesc(): ${J} is not a valid collider shape!`)}}_requireSimulated(Z){if(!this.isSimulated)p.error(`Collider._requireSimulated(): Collider is not simulated, invoked method: ${Z}()`);return this.isSimulated}_requireUnsimulated(Z){if(this.isSimulated)p.error(`Collider._requireUnsimulated(): Collider is already simulated, invoked method: ${Z}()`);return!this.isSimulated}_requireNotRemoved(Z){if(this.isRemoved)p.error(`Collider._requireNotRemoved(): Collider is removed, invoked method: ${Z}()`);return!this.isRemoved}_setActiveCollisionTypes(){(this._collider??this._colliderDesc).setActiveCollisionTypes(X1.ActiveCollisionTypes.DYNAMIC_DYNAMIC|X1.ActiveCollisionTypes.DYNAMIC_KINEMATIC|X1.ActiveCollisionTypes.DYNAMIC_FIXED|X1.ActiveCollisionTypes.KINEMATIC_KINEMATIC|X1.ActiveCollisionTypes.KINEMATIC_FIXED)}_coordinatesToInt32Array(Z){let J=new Int32Array(Z.length*3);for(let X=0;X<Z.length;X++){let $=Z[X],Y=X*3;J[Y]=Math.floor($.x),J[Y+1]=Math.floor($.y),J[Y+2]=Math.floor($.z)}return J}}var _R1={shape:"voxels"},iP;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(iP||={});class m5 extends j0{_id;_customColliderOptions;_halfExtents;_isLiquid;_lightLevel;_name;_textureUri;constructor(Z={id:-1,textureUri:"textures/missing.png",name:"Unknown"}){if(Z.id<0)p.fatalError("BlockType.constructor(): BlockType id not set.");super();this._id=Z.id,this._customColliderOptions=Z.customColliderOptions,this._halfExtents=Z.halfExtents??{x:0.5,y:0.5,z:0.5},this._isLiquid=Z.isLiquid??!1,this._name=Z.name,this._textureUri=Z.textureUri,this._lightLevel=Math.min(Z.lightLevel??0,15)}get id(){return this._id}get colliderOptions(){return{...this._customColliderOptions,..._R1}}get halfExtents(){return this._halfExtents}get isLiquid(){return this._isLiquid}get isMeshable(){return!this._customColliderOptions}get lightLevel(){return this._lightLevel}get name(){return this._name}get size(){return{x:this._halfExtents.x*2,y:this._halfExtents.y*2,z:this._halfExtents.z*2}}get textureUri(){return this._textureUri}createCollider(Z){let J=new A5({...this.colliderOptions,coordinates:Z,size:this.size});if(this.isLiquid)J.setSensor(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_COLLISION")||this.isLiquid)J.enableCollisionEvents(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))J.enableContactForceEvents(!0);if(v9.isDefaultCollisionGroups(J.collisionGroups))J.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return J}serialize(){return T0.serializeBlockType(this)}}var gP;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(gP||={});class tG extends j0{_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)p.fatalError(`BlockTypeRegistry.getBlockType(): BlockType with id ${Z} not found.`);return J}registerGenericBlockType(Z){let X=new class extends m5{constructor($=Z){super($)}};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 T0.serializeBlockTypeRegistry(this)}}var MO={};_Q(MO,{worldSchema:()=>DO,worldPacketDefinition:()=>Z10,vectorSchema:()=>W1,vectorBooleanSchema:()=>ME1,uiSchema:()=>BO,uiPacketDefinition:()=>t00,uiDatasSchema:()=>LO,uiDatasPacketDefinition:()=>e00,uiDataSendPacketDefinition:()=>S00,uiDataSchema:()=>Dz,syncResponseSchema:()=>jO,syncResponsePacketDefinition:()=>r00,syncRequestSchema:()=>dN,syncRequestPacketDefinition:()=>h00,stateRequestSchema:()=>gN,stateRequestPacketDefinition:()=>_00,sceneUIsSchema:()=>UO,sceneUIsPacketDefinition:()=>o00,sceneUISchema:()=>xO,rgbColorSchema:()=>D6,registeredPackets:()=>Ec,quaternionSchema:()=>YO,playersSchema:()=>cO,playersPacketDefinition:()=>s00,playerSchema:()=>wO,physicsDebugRenderSchema:()=>FO,physicsDebugRenderPacketDefinition:()=>a00,physicsDebugRaycastsSchema:()=>qO,physicsDebugRaycastsPacketDefinition:()=>n00,physicsDebugRaycastSchema:()=>HO,particleEmittersSchema:()=>VO,particleEmittersPacketDefinition:()=>d00,particleEmitterSchema:()=>vO,outboundPackets:()=>kc,notificationPermissionRequestSchema:()=>zO,notificationPermissionRequestPacketDefinition:()=>g00,modelNodeOverrideSchema:()=>$O,lightsSchema:()=>GO,lightsPacketDefinition:()=>i00,lightSchema:()=>WO,isValidPacket:()=>PE1,inputSchema:()=>iN,inputPacketDefinition:()=>I00,inboundPackets:()=>fc,hexColorSchema:()=>yN,heartbeatSchema:()=>lN,heartbeatPacketDefinition:()=>f00,entitySchema:()=>QO,entitiesSchema:()=>KO,entitiesPacketDefinition:()=>p00,definePacket:()=>C0,debugConfigSchema:()=>pN,debugConfigPacketDefinition:()=>E00,createPacket:()=>DE1,connectionSchema:()=>uN,connectionPacketDefinition:()=>C00,chunksSchema:()=>XO,chunksPacketDefinition:()=>y00,chunkSchema:()=>JO,chatMessagesSchema:()=>ZO,chatMessagesPacketDefinition:()=>l00,chatMessageSendPacketDefinition:()=>k00,chatMessageSchema:()=>Lz,cameraSchema:()=>eN,cameraPacketDefinition:()=>u00,blocksSchema:()=>oN,blocksPacketDefinition:()=>A00,blockTypesSchema:()=>tN,blockTypesPacketDefinition:()=>m00,blockTypeSchema:()=>rN,blockSchema:()=>sN,bidirectionalPackets:()=>Cc,audiosSchema:()=>nN,audiosPacketDefinition:()=>b00,audioSchema:()=>aN,PacketId:()=>M1});var Cc={};_Q(Cc,{heartbeatPacketDefinition:()=>f00,connectionPacketDefinition:()=>C00});var AN=t(T00(),1);class mN extends AN.default{static instance=new AN.default}var M1;((k)=>{k[k.SYNC_REQUEST=0]="SYNC_REQUEST";k[k.INPUT=1]="INPUT";k[k.STATE_REQUEST=2]="STATE_REQUEST";k[k.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";k[k.UI_DATA_SEND=4]="UI_DATA_SEND";k[k.SYNC_RESPONSE=32]="SYNC_RESPONSE";k[k.AUDIOS=33]="AUDIOS";k[k.BLOCKS=34]="BLOCKS";k[k.BLOCK_TYPES=35]="BLOCK_TYPES";k[k.CHAT_MESSAGES=36]="CHAT_MESSAGES";k[k.CHUNKS=37]="CHUNKS";k[k.ENTITIES=38]="ENTITIES";k[k.WORLD=39]="WORLD";k[k.CAMERA=40]="CAMERA";k[k.UI=41]="UI";k[k.UI_DATAS=42]="UI_DATAS";k[k.SCENE_UIS=43]="SCENE_UIS";k[k.LIGHTS=44]="LIGHTS";k[k.PLAYERS=45]="PLAYERS";k[k.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";k[k.NOTIFICATION_PERMISSION_REQUEST=47]="NOTIFICATION_PERMISSION_REQUEST";k[k.CONNECTION=116]="CONNECTION";k[k.HEARTBEAT=117]="HEARTBEAT";k[k.DEBUG_CONFIG=128]="DEBUG_CONFIG";k[k.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";k[k.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(M1||={});function DE1(Z,J,X){if(!Z.validate(J))throw Error(`Invalid payload for packet with id ${Z.id}. Error: ${mN.instance.errorsText(Z.validate.errors)}`);let $=[Z.id,J];if(typeof X==="number")$.push(X);return $}function C0(Z,J){return{id:Z,schema:J,validate:mN.instance.compile(J)}}var uN={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},ts:{type:"string",nullable:!0}},additionalProperties:!1};var C00=C0(116,uN);var lN={type:"null",nullable:!0};var f00=C0(117,lN);var fc={};_Q(fc,{uiDataSendPacketDefinition:()=>S00,syncRequestPacketDefinition:()=>h00,stateRequestPacketDefinition:()=>_00,inputPacketDefinition:()=>I00,debugConfigPacketDefinition:()=>E00,chatMessageSendPacketDefinition:()=>k00});var yN={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var Lz={type:"object",properties:{m:{type:"string"},c:{...yN,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var k00=C0(3,Lz);var pN={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var E00=C0(128,pN);var iN={type:"object",properties:{"1":{type:"boolean",nullable:!0},"2":{type:"boolean",nullable:!0},"3":{type:"boolean",nullable:!0},"4":{type:"boolean",nullable:!0},"5":{type:"boolean",nullable:!0},"6":{type:"boolean",nullable:!0},"7":{type:"boolean",nullable:!0},"8":{type:"boolean",nullable:!0},"9":{type:"boolean",nullable:!0},"0":{type:"boolean",nullable:!0},w:{type:"boolean",nullable:!0},a:{type:"boolean",nullable:!0},s:{type:"boolean",nullable:!0},d:{type:"boolean",nullable:!0},q:{type:"boolean",nullable:!0},e:{type:"boolean",nullable:!0},r:{type:"boolean",nullable:!0},f:{type:"boolean",nullable:!0},z:{type:"boolean",nullable:!0},x:{type:"boolean",nullable:!0},c:{type:"boolean",nullable:!0},v:{type:"boolean",nullable:!0},u:{type:"boolean",nullable:!0},i:{type:"boolean",nullable:!0},o:{type:"boolean",nullable:!0},j:{type:"boolean",nullable:!0},k:{type:"boolean",nullable:!0},l:{type:"boolean",nullable:!0},n:{type:"boolean",nullable:!0},m:{type:"boolean",nullable:!0},sp:{type:"boolean",nullable:!0},sh:{type:"boolean",nullable:!0},tb:{type:"boolean",nullable:!0},ml:{type:"boolean",nullable:!0},mr:{type:"boolean",nullable:!0},cp:{type:"number",nullable:!0},cy:{type:"number",nullable:!0},sq:{type:"number",nullable:!0}},additionalProperties:!1};var I00=C0(1,iN);var gN={type:"object",properties:{},additionalProperties:!1};var _00=C0(2,gN);var dN={type:"null",nullable:!0};var h00=C0(0,dN);var Dz={type:"object",properties:{},additionalProperties:!0};var S00=C0(4,Dz);var kc={};_Q(kc,{worldPacketDefinition:()=>Z10,uiPacketDefinition:()=>t00,uiDatasPacketDefinition:()=>e00,syncResponsePacketDefinition:()=>r00,sceneUIsPacketDefinition:()=>o00,playersPacketDefinition:()=>s00,physicsDebugRenderPacketDefinition:()=>a00,physicsDebugRaycastsPacketDefinition:()=>n00,particleEmittersPacketDefinition:()=>d00,notificationPermissionRequestPacketDefinition:()=>g00,lightsPacketDefinition:()=>i00,entitiesPacketDefinition:()=>p00,chunksPacketDefinition:()=>y00,chatMessagesPacketDefinition:()=>l00,cameraPacketDefinition:()=>u00,blocksPacketDefinition:()=>A00,blockTypesPacketDefinition:()=>m00,audiosPacketDefinition:()=>b00});var W1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var aN={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:{...W1,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 nN={type:"array",items:{...aN}};var b00=C0(33,nN);var sN={type:"object",properties:{i:{type:"number"},c:W1},required:["i","c"],additionalProperties:!1};var oN={type:"array",items:{...sN}};var A00=C0(34,oN);var rN={type:"object",properties:{i:{type:"number"},l:{type:"boolean",nullable:!0},ll:{type:"number",nullable:!0},n:{type:"string",nullable:!0},t:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var tN={type:"array",items:{...rN}};var m00=C0(35,tN);var eN={type:"object",properties:{m:{type:"number",nullable:!0},e:{type:"number",nullable:!0},et:{type:"number",nullable:!0},fo:{type:"number",nullable:!0},ffo:{type:"number",nullable:!0},fv:{type:"number",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},pt:{...W1,nullable:!0},pl:{...W1,nullable:!0},s:{type:"array",items:{type:"string"},nullable:!0},sa:{type:"number",nullable:!0},z:{type:"number",nullable:!0}},additionalProperties:!1};var ZO={type:"array",items:{...Lz}};var JO={type:"object",properties:{c:W1,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 XO={type:"array",items:{...JO}};var D6={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 $O={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:{...D6,nullable:!0}},required:["n"],additionalProperties:!1};var YO={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var QO={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:{...W1,nullable:!0},bt:{type:"string",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},m:{type:"string",nullable:!0},mo:{type:"array",items:{...$O},nullable:!0},mt:{type:"string",nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{...YO,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sn:{type:"array",items:{type:"string"},nullable:!0},t:{...D6,nullable:!0}},required:["i"],additionalProperties:!1};var KO={type:"array",items:{...QO}};var WO={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...D6,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,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:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var GO={type:"array",items:{...WO}};var zO={type:"null",nullable:!0};var vO={type:"object",properties:{i:{type:"number"},at:{type:"number",nullable:!0},b:{type:"number",nullable:!0},ce:{...D6,nullable:!0},cev:{...D6,nullable:!0},cs:{...D6,nullable:!0},csv:{...D6,nullable:!0},e:{type:"number",nullable:!0},en:{type:"string",nullable:!0},g:{...W1,nullable:!0},l:{type:"number",nullable:!0},lv:{type:"number",nullable:!0},mp:{type:"number",nullable:!0},o:{...W1,nullable:!0},oe:{type:"number",nullable:!0},oev:{type:"number",nullable:!0},os:{type:"number",nullable:!0},osv:{type:"number",nullable:!0},p:{...W1,nullable:!0},pa:{type:"boolean",nullable:!0},pv:{...W1,nullable:!0},r:{type:"number",nullable:!0},rv:{type:"number",nullable:!0},rm:{type:"boolean",nullable:!0},se:{type:"number",nullable:!0},sev:{type:"number",nullable:!0},ss:{type:"number",nullable:!0},ssv:{type:"number",nullable:!0},t:{type:"boolean",nullable:!0},tu:{type:"string",nullable:!0},v:{...W1,nullable:!0},vv:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var VO={type:"array",items:{...vO}};var HO={type:"object",properties:{o:{...W1},d:{...W1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var qO={type:"array",items:{...HO}};var FO={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var wO={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 cO={type:"array",items:{...wO}};var xO={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,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 UO={type:"array",items:{...xO}};var jO={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var BO={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var LO={type:"array",items:{...Dz}};var ME1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var DO={type:"object",properties:{i:{type:"number"},ac:{...D6,nullable:!0},ai:{type:"number",nullable:!0},dc:{...D6,nullable:!0},di:{type:"number",nullable:!0},dp:{...W1,nullable:!0},fc:{...D6,nullable:!0},ff:{type:"number",nullable:!0},fn:{type:"number",nullable:!0},n:{type:"string",nullable:!0},s:{type:"string",nullable:!0},si:{type:"number",nullable:!0},t:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var u00=C0(40,eN);var l00=C0(36,ZO);var y00=C0(37,XO);var p00=C0(38,KO);var i00=C0(44,GO);var g00=C0(47,zO);var d00=C0(46,VO);var a00=C0(192,FO);var n00=C0(193,qO);var s00=C0(45,cO);var o00=C0(43,UO);var r00=C0(32,jO);var t00=C0(41,BO);var e00=C0(42,LO);var Z10=C0(39,DO);var Ec=new Map,RE1={...Cc,...fc,...kc};for(let Z of Object.values(RE1))if("id"in Z&&"schema"in Z){let J=Z;if(Ec.has(J.id))throw Error(`Packet with id ${J.id} is already registered.`);Ec.set(J.id,J)}function PE1(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=Ec.get(Z[0]);return!!J&&J.validate(Z[1])}var Q0=MO;var K60=t(T10(),1);import t$ from"fs";import Y60 from"path";var q_1=t(M80(),1),F_1=t(_O(),1),w_1=t(SO(),1),r$=t(pc(),1),pO=t(f80(),1);var k80=r$.default;function U5(Z){if(Z===null)return"null";if(Array.isArray(Z))return"array";return typeof Z}function $X(Z){return U5(Z)==="object"}function c_1(Z){return Array.isArray(Z)&&Z.length>0&&Z.every((J)=>("message"in J))}function iO(Z,J){return Z.length<124?Z:J}var E80="graphql-transport-ws";var l5=((Z)=>{return Z[Z.InternalServerError=4500]="InternalServerError",Z[Z.InternalClientError=4005]="InternalClientError",Z[Z.BadRequest=4400]="BadRequest",Z[Z.BadResponse=4004]="BadResponse",Z[Z.Unauthorized=4401]="Unauthorized",Z[Z.Forbidden=4403]="Forbidden",Z[Z.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",Z[Z.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",Z[Z.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",Z[Z.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",Z[Z.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",Z})(l5||{}),y5=((Z)=>{return Z.ConnectionInit="connection_init",Z.ConnectionAck="connection_ack",Z.Ping="ping",Z.Pong="pong",Z.Subscribe="subscribe",Z.Next="next",Z.Error="error",Z.Complete="complete",Z})(y5||{});function I80(Z){if(!$X(Z))throw Error(`Message is expected to be an object, but got ${U5(Z)}`);if(!Z.type)throw Error("Message is missing the 'type' property");if(typeof Z.type!=="string")throw Error(`Message is expects the 'type' property to be a string, but got ${U5(Z.type)}`);switch(Z.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(Z.payload!=null&&!$X(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${Z.payload}"`);break}case"subscribe":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!$X(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${U5(Z.payload)}`);if(typeof Z.payload.query!=="string")throw Error(`"${Z.type}" message payload expects the 'query' property to be a string, but got ${U5(Z.payload.query)}`);if(Z.payload.variables!=null&&!$X(Z.payload.variables))throw Error(`"${Z.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${U5(Z.payload.variables)}`);if(Z.payload.operationName!=null&&U5(Z.payload.operationName)!=="string")throw Error(`"${Z.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${U5(Z.payload.operationName)}`);if(Z.payload.extensions!=null&&!$X(Z.payload.extensions))throw Error(`"${Z.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${U5(Z.payload.extensions)}`);break}case"next":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!$X(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${U5(Z.payload)}`);break}case"error":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!c_1(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(Z.payload)}`);break}case"complete":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);break}default:throw Error(`Invalid message 'type' property "${Z.type}"`)}return Z}function _80(Z,J){return I80(typeof Z==="string"?JSON.parse(Z,J):Z)}function i3(Z,J){return I80(Z),JSON.stringify(Z,J)}function dO(Z){let{url:J,connectionParams:X,lazy:$=!0,onNonLazyError:Y=console.error,lazyCloseTimeout:Q=0,keepAlive:K=0,disablePong:W,connectionAckWaitTimeout:G=0,retryAttempts:z=5,retryWait:v=async function(h){let _=Math.pow(2,h);await new Promise((a)=>setTimeout(a,_*1000+Math.floor(Math.random()*2700+300)))},shouldRetry:H=gO,on:V,webSocketImpl:q,generateID:F=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(h)=>{let _=Math.random()*16|0;return(h=="x"?_:_&3|8).toString(16)})},jsonMessageReplacer:w,jsonMessageReviver:c}=Z,x;if(q){if(!U_1(q))throw Error("Invalid WebSocket implementation provided");x=q}else if(typeof WebSocket<"u")x=WebSocket;else if(typeof global<"u")x=global.WebSocket||global.MozWebSocket;else if(typeof window<"u")x=window.WebSocket||window.MozWebSocket;if(!x)throw Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let j=x,B=(()=>{let C=(()=>{let _={};return{on(a,s){return _[a]=s,()=>{delete _[a]}},emit(a){if("id"in a)_[a.id]?.(a)}}})(),h={connecting:V?.connecting?[V.connecting]:[],opened:V?.opened?[V.opened]:[],connected:V?.connected?[V.connected]:[],ping:V?.ping?[V.ping]:[],pong:V?.pong?[V.pong]:[],message:V?.message?[C.emit,V.message]:[C.emit],closed:V?.closed?[V.closed]:[],error:V?.error?[V.error]:[]};return{onMessage:C.on,on(_,a){let s=h[_];return s.push(a),()=>{s.splice(s.indexOf(a),1)}},emit(_,...a){for(let s of[...h[_]])s(...a)}}})();function L(C){let h=[B.on("error",(_)=>{h.forEach((a)=>a()),C(_)}),B.on("closed",(_)=>{h.forEach((a)=>a()),C(_)})]}let R,M=0,P,N=!1,O=0,k=!1;async function E(){clearTimeout(P);let[C,h]=await(R??(R=new Promise((s,Z0)=>(async()=>{if(N){if(await v(O),!M)return R=void 0,Z0({code:1000,reason:"All Subscriptions Gone"});O++}B.emit("connecting",N);let o=new j(typeof J==="function"?await J():J,E80),M0,R0;function m0(){if(isFinite(K)&&K>0)clearTimeout(R0),R0=setTimeout(()=>{if(o.readyState===j.OPEN)o.send(i3({type:y5.Ping})),B.emit("ping",!1,void 0)},K)}L((s0)=>{if(R=void 0,clearTimeout(M0),clearTimeout(R0),Z0(s0),s0 instanceof gc)o.close(4499,"Terminated"),o.onerror=null,o.onclose=null}),o.onerror=(s0)=>B.emit("error",s0),o.onclose=(s0)=>B.emit("closed",s0),o.onopen=async()=>{try{B.emit("opened",o);let s0=typeof X==="function"?await X():X;if(o.readyState!==j.OPEN)return;if(o.send(i3(s0?{type:y5.ConnectionInit,payload:s0}:{type:y5.ConnectionInit},w)),isFinite(G)&&G>0)M0=setTimeout(()=>{o.close(l5.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},G);m0()}catch(s0){B.emit("error",s0),o.close(l5.InternalClientError,iO(s0 instanceof Error?s0.message:String(s0),"Internal client error"))}};let N1=!1;o.onmessage=({data:s0})=>{try{let j1=_80(s0,c);if(B.emit("message",j1),j1.type==="ping"||j1.type==="pong"){if(B.emit(j1.type,!0,j1.payload),j1.type==="pong")m0();else if(!W)o.send(i3(j1.payload?{type:y5.Pong,payload:j1.payload}:{type:y5.Pong})),B.emit("pong",!1,j1.payload);return}if(N1)return;if(j1.type!==y5.ConnectionAck)throw Error(`First message cannot be of type ${j1.type}`);clearTimeout(M0),N1=!0,B.emit("connected",o,j1.payload,N),N=!1,O=0,s([o,new Promise((K4,PJ)=>L(PJ))])}catch(j1){o.onmessage=null,B.emit("error",j1),o.close(l5.BadResponse,iO(j1 instanceof Error?j1.message:String(j1),"Bad response"))}}})())));if(C.readyState===j.CLOSING)await h;let _=()=>{},a=new Promise((s)=>_=s);return[C,_,Promise.race([a.then(()=>{if(!M){let s=()=>C.close(1000,"Normal Closure");if(isFinite(Q)&&Q>0)P=setTimeout(()=>{if(C.readyState===j.OPEN)s()},Q);else s()}}),h])]}function S(C){if(gO(C)&&(x_1(C.code)||[l5.InternalServerError,l5.InternalClientError,l5.BadRequest,l5.BadResponse,l5.Unauthorized,l5.SubprotocolNotAcceptable,l5.SubscriberAlreadyExists,l5.TooManyInitialisationRequests].includes(C.code)))throw C;if(k)return!1;if(gO(C)&&C.code===1000)return M>0;if(!z||O>=z)throw C;if(!H(C))throw C;return N=!0}if(!$)(async()=>{M++;for(;;)try{let[,,C]=await E();await C}catch(C){try{if(!S(C))return}catch(h){return Y?.(h)}}})();function f(C,h){let _=F(C),a=!1,s=!1,Z0=()=>{M--,a=!0};return(async()=>{M++;for(;;)try{let[o,M0,R0]=await E();if(a)return M0();let m0=B.onMessage(_,(N1)=>{switch(N1.type){case y5.Next:{h.next(N1.payload);return}case y5.Error:{s=!0,a=!0,h.error(N1.payload),Z0();return}case y5.Complete:{a=!0,Z0();return}}});o.send(i3({id:_,type:y5.Subscribe,payload:C},w)),Z0=()=>{if(!a&&o.readyState===j.OPEN)o.send(i3({id:_,type:y5.Complete},w));M--,a=!0,M0()},await R0.finally(m0);return}catch(o){if(!S(o))return}})().then(()=>{if(!s)h.complete()}).catch((o)=>{h.error(o)}),()=>{if(!a)Z0()}}return{on:B.on,subscribe:f,iterate(C){let h=[],_={done:!1,error:null,resolve:()=>{}},a=f(C,{next(Z0){h.push(Z0),_.resolve()},error(Z0){_.done=!0,_.error=Z0,_.resolve()},complete(){_.done=!0,_.resolve()}}),s=async function*(){for(;;){if(!h.length)await new Promise((o)=>_.resolve=o);while(h.length)yield h.shift();if(_.error)throw _.error;if(_.done)return}}();return s.throw=async(Z0)=>{if(!_.done)_.done=!0,_.error=Z0,_.resolve();return{done:!0,value:void 0}},s.return=async()=>{return a(),{done:!0,value:void 0}},s},async dispose(){if(k=!0,R){let[C]=await R;C.close(1000,"Normal Closure")}},terminate(){if(R)B.emit("closed",new gc)}}}class gc extends Error{name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1}function gO(Z){return $X(Z)&&"code"in Z&&"reason"in Z}function x_1(Z){if([1000,1001,1006,1005,1012,1013,1014].includes(Z))return!1;return Z>=1000&&Z<=1999}function U_1(Z){return typeof Z==="function"&&"constructor"in Z&&"CLOSED"in Z&&"CLOSING"in Z&&"CONNECTING"in Z&&"OPEN"in Z}var Q60=t($60(),1);var Ez="./dev/persistence",ac=process.env.HYTOPIA_NOTIFICATION_SERVICE_URL||"https://dev.notifications.hytopia.com";class N4{static instance=new N4;creatorApiKey=process.env.HYTOPIA_API_KEY;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;_gqlWs;constructor(){this._gqlWs=dO({url:"wss://prod.gql.hytopia.com/graphql",webSocketImpl:k80});try{this._creativeGateway=new Q60.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(`
399
+ >>> no match, partial?`,Z,H,J,V),H===W)return!0}return!1}let F;if(typeof z==="string")F=v===z,this.debug("string match",z,v,F);else F=z.test(v),this.debug("pattern match",z,v,F);if(!F)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 Error("wtf?")}braceExpand(){return ii(this.pattern,this.options)}parse(Z){KG(Z);let J=this.options;if(Z==="**")return J6;if(Z==="")return"";let X,$=null;if(X=Z.match(Sc1))$=J.dot?Ac1:bc1;else if(X=Z.match(Nc1))$=(J.nocase?J.dot?fc1:Cc1:J.dot?Tc1:Oc1)(X[1]);else if(X=Z.match(mc1))$=(J.nocase?J.dot?lc1:uc1:J.dot?yc1:pc1)(X);else if(X=Z.match(kc1))$=J.dot?Ic1:Ec1;else if(X=Z.match(_c1))$=hc1;let Y=Z6.fromGlob(Z,this.options).toMMPattern();if($&&typeof Y==="object")Reflect.defineProperty(Y,"test",{value:$});return Y}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?dc1:J.dot?ac1:nc1,$=new Set(J.nocase?["i"]:[]),Y=Z.map((W)=>{let G=W.map((z)=>{if(z instanceof RegExp)for(let v of z.flags.split(""))$.add(v);return typeof z==="string"?ec1(z):z===J6?J6:z._src});return G.forEach((z,v)=>{let H=G[v+1],V=G[v-1];if(z!==J6||V===J6)return;if(V===void 0)if(H!==void 0&&H!==J6)G[v+1]="(?:\\/|"+X+"\\/)?"+H;else G[v]=X;else if(H===void 0)G[v-1]=V+"(?:\\/|"+X+")?";else if(H!==J6)G[v-1]=V+"(?:\\/|\\/"+X+"\\/)"+H,G[v+1]=J6}),G.filter((z)=>z!==J6).join("/")}).join("|"),[Q,K]=Z.length>1?["(?:",")"]:["",""];if(Y="^"+Q+Y+K+"$",this.negate)Y="^(?!"+Y+").+$";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 $=this.slashSplit(Z);this.debug(this.pattern,"split",$);let Y=this.set;this.debug(this.pattern,"set",Y);let Q=$[$.length-1];if(!Q)for(let K=$.length-2;!Q&&K>=0;K--)Q=$[K];for(let K=0;K<Y.length;K++){let W=Y[K],G=$;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 h6.defaults(Z).Minimatch}}h6.AST=Z6;h6.Minimatch=V4;h6.escape=Z3;h6.unescape=F9;import{fileURLToPath as kx1}from"node:url";var J3=typeof performance==="object"&&performance&&typeof performance.now==="function"?performance:Date,di=new Set,iM=typeof process==="object"&&!!process?process:{},ai=(Z,J,X,$)=>{typeof iM.emitWarning==="function"?iM.emitWarning(Z,J,X,$):console.error(`[${X}] ${J}: ${Z}`)},NF=globalThis.AbortController,gi=globalThis.AbortSignal;if(typeof NF>"u"){gi=class{onabort;_onabort=[];reason;aborted=!1;addEventListener($,Y){this._onabort.push(Y)}},NF=class{constructor(){J()}signal=new gi;abort($){if(this.signal.aborted)return;this.signal.reason=$,this.signal.aborted=!0;for(let Y of this.signal._onabort)Y($);this.signal.onabort?.($)}};let Z=iM.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",J=()=>{if(!Z)return;Z=!1,ai("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 Zx1=(Z)=>!di.has(Z),nR6=Symbol("type"),IJ=(Z)=>Z&&Z===Math.floor(Z)&&Z>0&&isFinite(Z),ni=(Z)=>!IJ(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?GG:null;class GG extends Array{constructor(Z){super(Z);this.fill(0)}}class X3{heap;length;static#Z=!1;static create(Z){let J=ni(Z);if(!J)return[];X3.#Z=!0;let X=new X3(Z,J);return X3.#Z=!1,X}constructor(Z,J){if(!X3.#Z)throw 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 zG{#Z;#J;#$;#X;#Y;#v;#H;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#z;#V;#Q;#F;#c;#w;#U;#O;#j;#T;#D;#L;#B;#P;#x;#f;static unsafeExposeInternals(Z){return{starts:Z.#D,ttls:Z.#L,sizes:Z.#T,keyMap:Z.#z,keyList:Z.#V,valList:Z.#Q,next:Z.#F,prev:Z.#c,get head(){return Z.#w},get tail(){return Z.#U},free:Z.#O,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,X,$,Y)=>Z.#h(J,X,$,Y),moveToTail:(J)=>Z.#A(J),indexes:(J)=>Z.#N(J),rindexes:(J)=>Z.#C(J),isStale:(J)=>Z.#R(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.#v}get memoMethod(){return this.#H}get dispose(){return this.#$}get onInsert(){return this.#X}get disposeAfter(){return this.#Y}constructor(Z){let{max:J=0,ttl:X,ttlResolution:$=1,ttlAutopurge:Y,updateAgeOnGet:Q,updateAgeOnHas:K,allowStale:W,dispose:G,onInsert:z,disposeAfter:v,noDisposeOnSet:H,noUpdateTTL:V,maxSize:q=0,maxEntrySize:F=0,sizeCalculation:w,fetchMethod:c,memoMethod:x,noDeleteOnFetchRejection:j,noDeleteOnStaleGet:B,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:R,ignoreFetchAbort:M}=Z;if(J!==0&&!IJ(J))throw TypeError("max option must be a nonnegative integer");let P=J?ni(J):Array;if(!P)throw Error("invalid max value: "+J);if(this.#Z=J,this.#J=q,this.maxEntrySize=F||this.#J,this.sizeCalculation=w,this.sizeCalculation){if(!this.#J&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!=="function")throw TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!=="function")throw TypeError("memoMethod must be a function if defined");if(this.#H=x,c!==void 0&&typeof c!=="function")throw TypeError("fetchMethod must be a function if specified");if(this.#v=c,this.#P=!!c,this.#z=new Map,this.#V=Array(J).fill(void 0),this.#Q=Array(J).fill(void 0),this.#F=new P(J),this.#c=new P(J),this.#w=0,this.#U=0,this.#O=X3.create(J),this.#W=0,this.#G=0,typeof G==="function")this.#$=G;if(typeof z==="function")this.#X=z;if(typeof v==="function")this.#Y=v,this.#j=[];else this.#Y=void 0,this.#j=void 0;if(this.#B=!!this.#$,this.#f=!!this.#X,this.#x=!!this.#Y,this.noDisposeOnSet=!!H,this.noUpdateTTL=!!V,this.noDeleteOnFetchRejection=!!j,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!R,this.ignoreFetchAbort=!!M,this.maxEntrySize!==0){if(this.#J!==0){if(!IJ(this.#J))throw TypeError("maxSize must be a positive integer if specified")}if(!IJ(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#u()}if(this.allowStale=!!W,this.noDeleteOnStaleGet=!!B,this.updateAgeOnGet=!!Q,this.updateAgeOnHas=!!K,this.ttlResolution=IJ($)||$===0?$:1,this.ttlAutopurge=!!Y,this.ttl=X||0,this.ttl){if(!IJ(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#K()}if(this.#Z===0&&this.ttl===0&&this.#J===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#Z&&!this.#J){if(Zx1("LRU_CACHE_UNBOUNDED"))di.add("LRU_CACHE_UNBOUNDED"),ai("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning","LRU_CACHE_UNBOUNDED",zG)}}getRemainingTTL(Z){return this.#z.has(Z)?1/0:0}#K(){let Z=new GG(this.#Z),J=new GG(this.#Z);this.#L=Z,this.#D=J,this.#k=(Y,Q,K=J3.now())=>{if(J[Y]=Q!==0?K:0,Z[Y]=Q,Q!==0&&this.ttlAutopurge){let W=setTimeout(()=>{if(this.#R(Y))this.#E(this.#V[Y],"expire")},Q+1);if(W.unref)W.unref()}},this.#I=(Y)=>{J[Y]=Z[Y]!==0?J3.now():0},this.#M=(Y,Q)=>{if(Z[Q]){let K=Z[Q],W=J[Q];if(!K||!W)return;Y.ttl=K,Y.start=W,Y.now=X||$();let G=Y.now-W;Y.remainingTTL=K-G}};let X=0,$=()=>{let Y=J3.now();if(this.ttlResolution>0){X=Y;let Q=setTimeout(()=>X=0,this.ttlResolution);if(Q.unref)Q.unref()}return Y};this.getRemainingTTL=(Y)=>{let Q=this.#z.get(Y);if(Q===void 0)return 0;let K=Z[Q],W=J[Q];if(!K||!W)return 1/0;let G=(X||$())-W;return K-G},this.#R=(Y)=>{let Q=J[Y],K=Z[Y];return!!K&&!!Q&&(X||$())-Q>K}}#I=()=>{};#M=()=>{};#k=()=>{};#R=()=>!1;#u(){let Z=new GG(this.#Z);this.#G=0,this.#T=Z,this.#_=(J)=>{this.#G-=Z[J],Z[J]=0},this.#l=(J,X,$,Y)=>{if(this.#q(X))return 0;if(!IJ($))if(Y){if(typeof Y!=="function")throw TypeError("sizeCalculation must be a function");if($=Y(X,J),!IJ($))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return $},this.#S=(J,X,$)=>{if(Z[J]=X,this.#J){let Y=this.#J-Z[J];while(this.#G>Y)this.#b(!0)}if(this.#G+=Z[J],$)$.entrySize=X,$.totalCalculatedSize=this.#G}}#_=(Z)=>{};#S=(Z,J,X)=>{};#l=(Z,J,X,$)=>{if(X||$)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#N({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#U;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#w)break;else J=this.#c[J]}}*#C({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#w;;){if(!this.#y(J))break;if(Z||!this.#R(J))yield J;if(J===this.#U)break;else J=this.#F[J]}}#y(Z){return Z!==void 0&&this.#z.get(this.#V[Z])===Z}*entries(){for(let Z of this.#N())if(this.#Q[Z]!==void 0&&this.#V[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#V[Z],this.#Q[Z]]}*rentries(){for(let Z of this.#C())if(this.#Q[Z]!==void 0&&this.#V[Z]!==void 0&&!this.#q(this.#Q[Z]))yield[this.#V[Z],this.#Q[Z]]}*keys(){for(let Z of this.#N()){let J=this.#V[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*rkeys(){for(let Z of this.#C()){let J=this.#V[Z];if(J!==void 0&&!this.#q(this.#Q[Z]))yield J}}*values(){for(let Z of this.#N())if(this.#Q[Z]!==void 0&&!this.#q(this.#Q[Z]))yield this.#Q[Z]}*rvalues(){for(let Z of this.#C())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.#N()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;if(Z(Y,this.#V[X],this))return this.get(this.#V[X],J)}}forEach(Z,J=this){for(let X of this.#N()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;Z.call(J,Y,this.#V[X],this)}}rforEach(Z,J=this){for(let X of this.#C()){let $=this.#Q[X],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0)continue;Z.call(J,Y,this.#V[X],this)}}purgeStale(){let Z=!1;for(let J of this.#C({allowStale:!0}))if(this.#R(J))this.#E(this.#V[J],"expire"),Z=!0;return Z}info(Z){let J=this.#z.get(Z);if(J===void 0)return;let X=this.#Q[J],$=this.#q(X)?X.__staleWhileFetching:X;if($===void 0)return;let Y={value:$};if(this.#L&&this.#D){let Q=this.#L[J],K=this.#D[J];if(Q&&K){let W=Q-(J3.now()-K);Y.ttl=W,Y.start=Date.now()}}if(this.#T)Y.size=this.#T[J];return Y}dump(){let Z=[];for(let J of this.#N({allowStale:!0})){let X=this.#V[J],$=this.#Q[J],Y=this.#q($)?$.__staleWhileFetching:$;if(Y===void 0||X===void 0)continue;let Q={value:Y};if(this.#L&&this.#D){Q.ttl=this.#L[J];let K=J3.now()-this.#D[J];Q.start=Math.floor(Date.now()-K)}if(this.#T)Q.size=this.#T[J];Z.unshift([X,Q])}return Z}load(Z){this.clear();for(let[J,X]of Z){if(X.start){let $=Date.now()-X.start;X.start=J3.now()-$}this.set(J,X.value,X)}}set(Z,J,X={}){if(J===void 0)return this.delete(Z),this;let{ttl:$=this.ttl,start:Y,noDisposeOnSet:Q=this.noDisposeOnSet,sizeCalculation:K=this.sizeCalculation,status:W}=X,{noUpdateTTL:G=this.noUpdateTTL}=X,z=this.#l(Z,J,X.size||0,K);if(this.maxEntrySize&&z>this.maxEntrySize){if(W)W.set="miss",W.maxEntrySizeExceeded=!0;return this.#E(Z,"set"),this}let v=this.#W===0?void 0:this.#z.get(Z);if(v===void 0){if(v=this.#W===0?this.#U:this.#O.length!==0?this.#O.pop():this.#W===this.#Z?this.#b(!1):this.#W,this.#V[v]=Z,this.#Q[v]=J,this.#z.set(Z,v),this.#F[this.#U]=v,this.#c[v]=this.#U,this.#U=v,this.#W++,this.#S(v,z,W),W)W.set="add";if(G=!1,this.#f)this.#X?.(J,Z,"add")}else{this.#A(v);let H=this.#Q[v];if(J!==H){if(this.#P&&this.#q(H)){H.__abortController.abort(Error("replaced"));let{__staleWhileFetching:V}=H;if(V!==void 0&&!Q){if(this.#B)this.#$?.(V,Z,"set");if(this.#x)this.#j?.push([V,Z,"set"])}}else if(!Q){if(this.#B)this.#$?.(H,Z,"set");if(this.#x)this.#j?.push([H,Z,"set"])}if(this.#_(v),this.#S(v,z,W),this.#Q[v]=J,W){W.set="replace";let V=H&&this.#q(H)?H.__staleWhileFetching:H;if(V!==void 0)W.oldValue=V}}else if(W)W.set="update";if(this.#f)this.onInsert?.(J,Z,J===H?"update":"replace")}if($!==0&&!this.#L)this.#K();if(this.#L){if(!G)this.#k(v,$,Y);if(W)this.#M(W,v)}if(!Q&&this.#x&&this.#j){let H=this.#j,V;while(V=H?.shift())this.#Y?.(...V)}return this}pop(){try{while(this.#W){let Z=this.#Q[this.#w];if(this.#b(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#x&&this.#j){let Z=this.#j,J;while(J=Z?.shift())this.#Y?.(...J)}}}#b(Z){let J=this.#w,X=this.#V[J],$=this.#Q[J];if(this.#P&&this.#q($))$.__abortController.abort(Error("evicted"));else if(this.#B||this.#x){if(this.#B)this.#$?.($,X,"evict");if(this.#x)this.#j?.push([$,X,"evict"])}if(this.#_(J),Z)this.#V[J]=void 0,this.#Q[J]=void 0,this.#O.push(J);if(this.#W===1)this.#w=this.#U=0,this.#O.length=0;else this.#w=this.#F[J];return this.#z.delete(X),this.#W--,J}has(Z,J={}){let{updateAgeOnHas:X=this.updateAgeOnHas,status:$}=J,Y=this.#z.get(Z);if(Y!==void 0){let Q=this.#Q[Y];if(this.#q(Q)&&Q.__staleWhileFetching===void 0)return!1;if(!this.#R(Y)){if(X)this.#I(Y);if($)$.has="hit",this.#M($,Y);return!0}else if($)$.has="stale",this.#M($,Y)}else if($)$.has="miss";return!1}peek(Z,J={}){let{allowStale:X=this.allowStale}=J,$=this.#z.get(Z);if($===void 0||!X&&this.#R($))return;let Y=this.#Q[$];return this.#q(Y)?Y.__staleWhileFetching:Y}#h(Z,J,X,$){let Y=J===void 0?void 0:this.#Q[J];if(this.#q(Y))return Y;let Q=new NF,{signal:K}=X;K?.addEventListener("abort",()=>Q.abort(K.reason),{signal:Q.signal});let W={signal:Q.signal,options:X,context:$},G=(F,w=!1)=>{let{aborted:c}=Q.signal,x=X.ignoreFetchAbort&&F!==void 0;if(X.status)if(c&&!w){if(X.status.fetchAborted=!0,X.status.fetchError=Q.signal.reason,x)X.status.fetchAbortIgnored=!0}else X.status.fetchResolved=!0;if(c&&!x&&!w)return v(Q.signal.reason);let j=V;if(this.#Q[J]===V)if(F===void 0)if(j.__staleWhileFetching)this.#Q[J]=j.__staleWhileFetching;else this.#E(Z,"fetch");else{if(X.status)X.status.fetchUpdated=!0;this.set(Z,F,W.options)}return F},z=(F)=>{if(X.status)X.status.fetchRejected=!0,X.status.fetchError=F;return v(F)},v=(F)=>{let{aborted:w}=Q.signal,c=w&&X.allowStaleOnFetchAbort,x=c||X.allowStaleOnFetchRejection,j=x||X.noDeleteOnFetchRejection,B=V;if(this.#Q[J]===V){if(!j||B.__staleWhileFetching===void 0)this.#E(Z,"fetch");else if(!c)this.#Q[J]=B.__staleWhileFetching}if(x){if(X.status&&B.__staleWhileFetching!==void 0)X.status.returnedStale=!0;return B.__staleWhileFetching}else if(B.__returned===B)throw F},H=(F,w)=>{let c=this.#v?.(Z,Y,W);if(c&&c instanceof Promise)c.then((x)=>F(x===void 0?void 0:x),w);Q.signal.addEventListener("abort",()=>{if(!X.ignoreFetchAbort||X.allowStaleOnFetchAbort){if(F(void 0),X.allowStaleOnFetchAbort)F=(x)=>G(x,!0)}})};if(X.status)X.status.fetchDispatched=!0;let V=new Promise(H).then(G,z),q=Object.assign(V,{__abortController:Q,__staleWhileFetching:Y,__returned:void 0});if(J===void 0)this.set(Z,q,{...W.options,status:void 0}),J=this.#z.get(Z);else this.#Q[J]=q;return q}#q(Z){if(!this.#P)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof NF}async fetch(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,ttl:Q=this.ttl,noDisposeOnSet:K=this.noDisposeOnSet,size:W=0,sizeCalculation:G=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:v=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:H=this.allowStaleOnFetchRejection,ignoreFetchAbort:V=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:F,forceRefresh:w=!1,status:c,signal:x}=J;if(!this.#P){if(c)c.fetch="get";return this.get(Z,{allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,status:c})}let j={allowStale:X,updateAgeOnGet:$,noDeleteOnStaleGet:Y,ttl:Q,noDisposeOnSet:K,size:W,sizeCalculation:G,noUpdateTTL:z,noDeleteOnFetchRejection:v,allowStaleOnFetchRejection:H,allowStaleOnFetchAbort:q,ignoreFetchAbort:V,status:c,signal:x},B=this.#z.get(Z);if(B===void 0){if(c)c.fetch="miss";let L=this.#h(Z,B,j,F);return L.__returned=L}else{let L=this.#Q[B];if(this.#q(L)){let O=X&&L.__staleWhileFetching!==void 0;if(c){if(c.fetch="inflight",O)c.returnedStale=!0}return O?L.__staleWhileFetching:L.__returned=L}let R=this.#R(B);if(!w&&!R){if(c)c.fetch="hit";if(this.#A(B),$)this.#I(B);if(c)this.#M(c,B);return L}let M=this.#h(Z,B,j,F),N=M.__staleWhileFetching!==void 0&&X;if(c){if(c.fetch=R?"stale":"refresh",N&&R)c.returnedStale=!0}return N?M.__staleWhileFetching:M.__returned=M}}async forceFetch(Z,J={}){let X=await this.fetch(Z,J);if(X===void 0)throw Error("fetch() returned undefined");return X}memo(Z,J={}){let X=this.#H;if(!X)throw Error("no memoMethod provided to constructor");let{context:$,forceRefresh:Y,...Q}=J,K=this.get(Z,Q);if(!Y&&K!==void 0)return K;let W=X(Z,K,{options:Q,context:$});return this.set(Z,W,Q),W}get(Z,J={}){let{allowStale:X=this.allowStale,updateAgeOnGet:$=this.updateAgeOnGet,noDeleteOnStaleGet:Y=this.noDeleteOnStaleGet,status:Q}=J,K=this.#z.get(Z);if(K!==void 0){let W=this.#Q[K],G=this.#q(W);if(Q)this.#M(Q,K);if(this.#R(K)){if(Q)Q.get="stale";if(!G){if(!Y)this.#E(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.#A(K),$)this.#I(K);return W}}else if(Q)Q.get="miss"}#p(Z,J){this.#c[J]=Z,this.#F[Z]=J}#A(Z){if(Z!==this.#U){if(Z===this.#w)this.#w=this.#F[Z];else this.#p(this.#c[Z],this.#F[Z]);this.#p(this.#U,Z),this.#U=Z}}delete(Z){return this.#E(Z,"delete")}#E(Z,J){let X=!1;if(this.#W!==0){let $=this.#z.get(Z);if($!==void 0)if(X=!0,this.#W===1)this.#m(J);else{this.#_($);let Y=this.#Q[$];if(this.#q(Y))Y.__abortController.abort(Error("deleted"));else if(this.#B||this.#x){if(this.#B)this.#$?.(Y,Z,J);if(this.#x)this.#j?.push([Y,Z,J])}if(this.#z.delete(Z),this.#V[$]=void 0,this.#Q[$]=void 0,$===this.#U)this.#U=this.#c[$];else if($===this.#w)this.#w=this.#F[$];else{let Q=this.#c[$];this.#F[Q]=this.#F[$];let K=this.#F[$];this.#c[K]=this.#c[$]}this.#W--,this.#O.push($)}}if(this.#x&&this.#j?.length){let $=this.#j,Y;while(Y=$?.shift())this.#Y?.(...Y)}return X}clear(){return this.#m("delete")}#m(Z){for(let J of this.#C({allowStale:!0})){let X=this.#Q[J];if(this.#q(X))X.__abortController.abort(Error("deleted"));else{let $=this.#V[J];if(this.#B)this.#$?.(X,$,Z);if(this.#x)this.#j?.push([X,$,Z])}}if(this.#z.clear(),this.#Q.fill(void 0),this.#V.fill(void 0),this.#L&&this.#D)this.#L.fill(0),this.#D.fill(0);if(this.#T)this.#T.fill(0);if(this.#w=0,this.#U=0,this.#O.length=0,this.#G=0,this.#W=0,this.#x&&this.#j){let J=this.#j,X;while(X=J?.shift())this.#Y?.(...X)}}}import{posix as Vx1,win32 as ZR}from"node:path";import{fileURLToPath as Hx1}from"node:url";import{lstatSync as qx1,readdir as Fx1,readdirSync as wx1,readlinkSync as cx1,realpathSync as xx1}from"fs";import*as Ux1 from"node:fs";import{lstat as Bx1,readdir as Lx1,readlink as Dx1,realpath as Mx1}from"node:fs/promises";import{EventEmitter as oM}from"node:events";import ei from"node:stream";import{StringDecoder as Jx1}from"node:string_decoder";var si=typeof process==="object"&&process?process:{stdout:null,stderr:null},Xx1=(Z)=>!!Z&&typeof Z==="object"&&(Z instanceof C$||Z instanceof ei||$x1(Z)||Yx1(Z)),$x1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof oM&&typeof Z.pipe==="function"&&Z.pipe!==ei.Writable.prototype.pipe,Yx1=(Z)=>!!Z&&typeof Z==="object"&&Z instanceof oM&&typeof Z.write==="function"&&typeof Z.end==="function",ZZ=Symbol("EOF"),JZ=Symbol("maybeEmitEnd"),_J=Symbol("emittedEnd"),OF=Symbol("emittingEnd"),vG=Symbol("emittedError"),TF=Symbol("closed"),oi=Symbol("read"),CF=Symbol("flush"),ri=Symbol("flushChunk"),w9=Symbol("encoding"),$3=Symbol("decoder"),y8=Symbol("flowing"),VG=Symbol("paused"),Y3=Symbol("resume"),p8=Symbol("buffer"),S6=Symbol("pipes"),i8=Symbol("bufferLength"),gM=Symbol("bufferPush"),fF=Symbol("bufferShift"),w6=Symbol("objectMode"),x8=Symbol("destroyed"),dM=Symbol("error"),aM=Symbol("emitData"),ti=Symbol("emitEnd"),nM=Symbol("emitEnd2"),$7=Symbol("async"),sM=Symbol("abort"),kF=Symbol("aborted"),HG=Symbol("signal"),T$=Symbol("dataListeners"),I5=Symbol("discarded"),qG=(Z)=>Promise.resolve().then(Z),Qx1=(Z)=>Z(),Kx1=(Z)=>Z==="end"||Z==="finish"||Z==="prefinish",Wx1=(Z)=>Z instanceof ArrayBuffer||!!Z&&typeof Z==="object"&&Z.constructor&&Z.constructor.name==="ArrayBuffer"&&Z.byteLength>=0,Gx1=(Z)=>!Buffer.isBuffer(Z)&&ArrayBuffer.isView(Z);class rM{src;dest;opts;ondrain;constructor(Z,J,X){this.src=Z,this.dest=J,this.opts=X,this.ondrain=()=>Z[Y3](),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 Zg extends rM{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(Z,J,X){super(Z,J,X);this.proxyErrors=($)=>J.emit("error",$),Z.on("error",this.proxyErrors)}}var zx1=(Z)=>!!Z.objectMode,vx1=(Z)=>!Z.objectMode&&!!Z.encoding&&Z.encoding!=="buffer";class C$ extends oM{[y8]=!1;[VG]=!1;[S6]=[];[p8]=[];[w6];[w9];[$7];[$3];[ZZ]=!1;[_J]=!1;[OF]=!1;[TF]=!1;[vG]=null;[i8]=0;[x8]=!1;[HG];[kF]=!1;[T$]=0;[I5]=!1;writable=!0;readable=!0;constructor(...Z){let J=Z[0]||{};super();if(J.objectMode&&typeof J.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(zx1(J))this[w6]=!0,this[w9]=null;else if(vx1(J))this[w9]=J.encoding,this[w6]=!1;else this[w6]=!1,this[w9]=null;if(this[$7]=!!J.async,this[$3]=this[w9]?new Jx1(this[w9]):null,J&&J.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[p8]});if(J&&J.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[S6]});let{signal:X}=J;if(X)if(this[HG]=X,X.aborted)this[sM]();else X.addEventListener("abort",()=>this[sM]())}get bufferLength(){return this[i8]}get encoding(){return this[w9]}set encoding(Z){throw Error("Encoding must be set at instantiation time")}setEncoding(Z){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[w6]}set objectMode(Z){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[$7]}set["async"](Z){this[$7]=this[$7]||!!Z}[sM](){this[kF]=!0,this.emit("abort",this[HG]?.reason),this.destroy(this[HG]?.reason)}get aborted(){return this[kF]}set aborted(Z){}write(Z,J,X){if(this[kF])return!1;if(this[ZZ])throw Error("write after end");if(this[x8])return this.emit("error",Object.assign(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 $=this[$7]?qG:Qx1;if(!this[w6]&&!Buffer.isBuffer(Z)){if(Gx1(Z))Z=Buffer.from(Z.buffer,Z.byteOffset,Z.byteLength);else if(Wx1(Z))Z=Buffer.from(Z);else if(typeof Z!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[w6]){if(this[y8]&&this[i8]!==0)this[CF](!0);if(this[y8])this.emit("data",Z);else this[gM](Z);if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}if(!Z.length){if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}if(typeof Z==="string"&&!(J===this[w9]&&!this[$3]?.lastNeed))Z=Buffer.from(Z,J);if(Buffer.isBuffer(Z)&&this[w9])Z=this[$3].write(Z);if(this[y8]&&this[i8]!==0)this[CF](!0);if(this[y8])this.emit("data",Z);else this[gM](Z);if(this[i8]!==0)this.emit("readable");if(X)$(X);return this[y8]}read(Z){if(this[x8])return null;if(this[I5]=!1,this[i8]===0||Z===0||Z&&Z>this[i8])return this[JZ](),null;if(this[w6])Z=null;if(this[p8].length>1&&!this[w6])this[p8]=[this[w9]?this[p8].join(""):Buffer.concat(this[p8],this[i8])];let J=this[oi](Z||null,this[p8][0]);return this[JZ](),J}[oi](Z,J){if(this[w6])this[fF]();else{let X=J;if(Z===X.length||Z===null)this[fF]();else if(typeof X==="string")this[p8][0]=X.slice(Z),J=X.slice(0,Z),this[i8]-=Z;else this[p8][0]=X.subarray(Z),J=X.subarray(0,Z),this[i8]-=Z}if(this.emit("data",J),!this[p8].length&&!this[ZZ])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[ZZ]=!0,this.writable=!1,this[y8]||!this[VG])this[JZ]();return this}[Y3](){if(this[x8])return;if(!this[T$]&&!this[S6].length)this[I5]=!0;if(this[VG]=!1,this[y8]=!0,this.emit("resume"),this[p8].length)this[CF]();else if(this[ZZ])this[JZ]();else this.emit("drain")}resume(){return this[Y3]()}pause(){this[y8]=!1,this[VG]=!0,this[I5]=!1}get destroyed(){return this[x8]}get flowing(){return this[y8]}get paused(){return this[VG]}[gM](Z){if(this[w6])this[i8]+=1;else this[i8]+=Z.length;this[p8].push(Z)}[fF](){if(this[w6])this[i8]-=1;else this[i8]-=this[p8][0].length;return this[p8].shift()}[CF](Z=!1){do;while(this[ri](this[fF]())&&this[p8].length);if(!Z&&!this[p8].length&&!this[ZZ])this.emit("drain")}[ri](Z){return this.emit("data",Z),this[y8]}pipe(Z,J){if(this[x8])return Z;this[I5]=!1;let X=this[_J];if(J=J||{},Z===si.stdout||Z===si.stderr)J.end=!1;else J.end=J.end!==!1;if(J.proxyErrors=!!J.proxyErrors,X){if(J.end)Z.end()}else if(this[S6].push(!J.proxyErrors?new rM(this,Z,J):new Zg(this,Z,J)),this[$7])qG(()=>this[Y3]());else this[Y3]();return Z}unpipe(Z){let J=this[S6].find((X)=>X.dest===Z);if(J){if(this[S6].length===1){if(this[y8]&&this[T$]===0)this[y8]=!1;this[S6]=[]}else this[S6].splice(this[S6].indexOf(J),1);J.unpipe()}}addListener(Z,J){return this.on(Z,J)}on(Z,J){let X=super.on(Z,J);if(Z==="data"){if(this[I5]=!1,this[T$]++,!this[S6].length&&!this[y8])this[Y3]()}else if(Z==="readable"&&this[i8]!==0)super.emit("readable");else if(Kx1(Z)&&this[_J])super.emit(Z),this.removeAllListeners(Z);else if(Z==="error"&&this[vG]){let $=J;if(this[$7])qG(()=>$.call(this,this[vG]));else $.call(this,this[vG])}return X}removeListener(Z,J){return this.off(Z,J)}off(Z,J){let X=super.off(Z,J);if(Z==="data"){if(this[T$]=this.listeners("data").length,this[T$]===0&&!this[I5]&&!this[S6].length)this[y8]=!1}return X}removeAllListeners(Z){let J=super.removeAllListeners(Z);if(Z==="data"||Z===void 0){if(this[T$]=0,!this[I5]&&!this[S6].length)this[y8]=!1}return J}get emittedEnd(){return this[_J]}[JZ](){if(!this[OF]&&!this[_J]&&!this[x8]&&this[p8].length===0&&this[ZZ]){if(this[OF]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[TF])this.emit("close");this[OF]=!1}}emit(Z,...J){let X=J[0];if(Z!=="error"&&Z!=="close"&&Z!==x8&&this[x8])return!1;else if(Z==="data")return!this[w6]&&!X?!1:this[$7]?(qG(()=>this[aM](X)),!0):this[aM](X);else if(Z==="end")return this[ti]();else if(Z==="close"){if(this[TF]=!0,!this[_J]&&!this[x8])return!1;let Y=super.emit("close");return this.removeAllListeners("close"),Y}else if(Z==="error"){this[vG]=X,super.emit(dM,X);let Y=!this[HG]||this.listeners("error").length?super.emit("error",X):!1;return this[JZ](),Y}else if(Z==="resume"){let Y=super.emit("resume");return this[JZ](),Y}else if(Z==="finish"||Z==="prefinish"){let Y=super.emit(Z);return this.removeAllListeners(Z),Y}let $=super.emit(Z,...J);return this[JZ](),$}[aM](Z){for(let X of this[S6])if(X.dest.write(Z)===!1)this.pause();let J=this[I5]?!1:super.emit("data",Z);return this[JZ](),J}[ti](){if(this[_J])return!1;return this[_J]=!0,this.readable=!1,this[$7]?(qG(()=>this[nM]()),!0):this[nM]()}[nM](){if(this[$3]){let J=this[$3].end();if(J){for(let X of this[S6])X.dest.write(J);if(!this[I5])super.emit("data",J)}}for(let J of this[S6])J.end();let Z=super.emit("end");return this.removeAllListeners("end"),Z}async collect(){let Z=Object.assign([],{dataLength:0});if(!this[w6])Z.dataLength=0;let J=this.promise();return this.on("data",(X)=>{if(Z.push(X),!this[w6])Z.dataLength+=X.length}),await J,Z}async concat(){if(this[w6])throw Error("cannot concat in objectMode");let Z=await this.collect();return this[w9]?Z.join(""):Buffer.concat(Z,Z.dataLength)}async promise(){return new Promise((Z,J)=>{this.on(x8,()=>J(Error("stream destroyed"))),this.on("error",(X)=>J(X)),this.on("end",()=>Z())})}[Symbol.asyncIterator](){this[I5]=!1;let Z=!1,J=async()=>{return this.pause(),Z=!0,{value:void 0,done:!0}};return{next:()=>{if(Z)return J();let $=this.read();if($!==null)return Promise.resolve({done:!1,value:$});if(this[ZZ])return J();let Y,Q,K=(v)=>{this.off("data",W),this.off("end",G),this.off(x8,z),J(),Q(v)},W=(v)=>{this.off("error",K),this.off("end",G),this.off(x8,z),this.pause(),Y({value:v,done:!!this[ZZ]})},G=()=>{this.off("error",K),this.off("data",W),this.off(x8,z),J(),Y({done:!0,value:void 0})},z=()=>K(Error("stream destroyed"));return new Promise((v,H)=>{Q=H,Y=v,this.once(x8,z),this.once("error",K),this.once("end",G),this.once("data",W)})},throw:J,return:J,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[I5]=!1;let Z=!1,J=()=>{return this.pause(),this.off(dM,J),this.off(x8,J),this.off("end",J),Z=!0,{done:!0,value:void 0}},X=()=>{if(Z)return J();let $=this.read();return $===null?J():{done:!1,value:$}};return this.once("end",J),this.once(dM,J),this.once(x8,J),{next:X,throw:J,return:J,[Symbol.iterator](){return this}}}destroy(Z){if(this[x8]){if(Z)this.emit("error",Z);else this.emit(x8);return this}this[x8]=!0,this[I5]=!0,this[p8].length=0,this[i8]=0;let J=this;if(typeof J.close==="function"&&!this[TF])J.close();if(Z)this.emit("error",Z);else this.emit(x8);return this}static get isStream(){return Xx1}}var jx1=xx1.native,wG={lstatSync:qx1,readdir:Fx1,readdirSync:wx1,readlinkSync:cx1,realpathSync:jx1,promises:{lstat:Bx1,readdir:Lx1,readlink:Dx1,realpath:Mx1}},Qg=(Z)=>!Z||Z===wG||Z===Ux1?wG:{...wG,...Z,promises:{...wG.promises,...Z.promises||{}}},Kg=/^\\\\\?\\([a-z]:)\\?$/i,Rx1=(Z)=>Z.replace(/\//g,"\\").replace(Kg,"$1\\"),Px1=/[\\\/]/,q4=0,Wg=1,Gg=2,Y7=4,zg=6,vg=8,f$=10,Vg=12,H4=15,FG=~H4,tM=16,Jg=32,cG=64,c9=128,EF=256,_F=512,Xg=cG|c9|_F,Nx1=1023,eM=(Z)=>Z.isFile()?vg:Z.isDirectory()?Y7:Z.isSymbolicLink()?f$:Z.isCharacterDevice()?Gg:Z.isBlockDevice()?zg:Z.isSocket()?Vg:Z.isFIFO()?Wg:q4,$g=new Map,xG=(Z)=>{let J=$g.get(Z);if(J)return J;let X=Z.normalize("NFKD");return $g.set(Z,X),X},Yg=new Map,IF=(Z)=>{let J=Yg.get(Z);if(J)return J;let X=xG(Z.toLowerCase());return Yg.set(Z,X),X};class JR extends zG{constructor(){super({max:256})}}class Hg extends zG{constructor(Z=16384){super({maxSize:Z,sizeCalculation:(J)=>J.length+1})}}var qg=Symbol("PathScurry setAsCwd");class b6{name;root;roots;parent;nocase;isCWD=!1;#Z;#J;get dev(){return this.#J}#$;get mode(){return this.#$}#X;get nlink(){return this.#X}#Y;get uid(){return this.#Y}#v;get gid(){return this.#v}#H;get rdev(){return this.#H}#W;get blksize(){return this.#W}#G;get ino(){return this.#G}#z;get size(){return this.#z}#V;get blocks(){return this.#V}#Q;get atimeMs(){return this.#Q}#F;get mtimeMs(){return this.#F}#c;get ctimeMs(){return this.#c}#w;get birthtimeMs(){return this.#w}#U;get atime(){return this.#U}#O;get mtime(){return this.#O}#j;get ctime(){return this.#j}#T;get birthtime(){return this.#T}#D;#L;#B;#P;#x;#f;#K;#I;#M;#k;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(Z,J=q4,X,$,Y,Q,K){if(this.name=Z,this.#D=Y?IF(Z):xG(Z),this.#K=J&Nx1,this.nocase=Y,this.roots=$,this.root=X||this,this.#I=Q,this.#B=K.fullpath,this.#x=K.relative,this.#f=K.relativePosix,this.parent=K.parent,this.parent)this.#Z=this.parent.#Z;else this.#Z=Qg(K.fs)}depth(){if(this.#L!==void 0)return this.#L;if(!this.parent)return this.#L=0;return this.#L=this.parent.depth()+1}childrenCache(){return this.#I}resolve(Z){if(!Z)return this;let J=this.getRootString(Z),$=Z.substring(J.length).split(this.splitSep);return J?this.getRoot(J).#R($):this.#R($)}#R(Z){let J=this;for(let X of Z)J=J.child(X);return J}children(){let Z=this.#I.get(this);if(Z)return Z;let J=Object.assign([],{provisional:0});return this.#I.set(this,J),this.#K&=~tM,J}child(Z,J){if(Z===""||Z===".")return this;if(Z==="..")return this.parent||this;let X=this.children(),$=this.nocase?IF(Z):xG(Z);for(let W of X)if(W.#D===$)return W;let Y=this.parent?this.sep:"",Q=this.#B?this.#B+Y+Z:void 0,K=this.newChild(Z,q4,{...J,parent:this,fullpath:Q});if(!this.canReaddir())K.#K|=c9;return X.push(K),K}relative(){if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let Z=this.name,J=this.parent;if(!J)return this.#x=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.#f!==void 0)return this.#f;let Z=this.name,J=this.parent;if(!J)return this.#f=this.fullpathPosix();let X=J.relativePosix();return X+(!X||!J.parent?"":"/")+Z}fullpath(){if(this.#B!==void 0)return this.#B;let Z=this.name,J=this.parent;if(!J)return this.#B=this.name;let $=J.fullpath()+(!J.parent?"":this.sep)+Z;return this.#B=$}fullpathPosix(){if(this.#P!==void 0)return this.#P;if(this.sep==="/")return this.#P=this.fullpath();if(!this.parent){let $=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test($))return this.#P=`//?/${$}`;else return this.#P=$}let Z=this.parent,J=Z.fullpathPosix(),X=J+(!J||!Z.parent?"":"/")+this.name;return this.#P=X}isUnknown(){return(this.#K&H4)===q4}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&H4)===vg}isDirectory(){return(this.#K&H4)===Y7}isCharacterDevice(){return(this.#K&H4)===Gg}isBlockDevice(){return(this.#K&H4)===zg}isFIFO(){return(this.#K&H4)===Wg}isSocket(){return(this.#K&H4)===Vg}isSymbolicLink(){return(this.#K&f$)===f$}lstatCached(){return this.#K&Jg?this:void 0}readlinkCached(){return this.#M}realpathCached(){return this.#k}readdirCached(){let Z=this.children();return Z.slice(0,Z.provisional)}canReadlink(){if(this.#M)return!0;if(!this.parent)return!1;let Z=this.#K&H4;return!(Z!==q4&&Z!==f$||this.#K&EF||this.#K&c9)}calledReaddir(){return!!(this.#K&tM)}isENOENT(){return!!(this.#K&c9)}isNamed(Z){return!this.nocase?this.#D===xG(Z):this.#D===IF(Z)}async readlink(){let Z=this.#M;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.#M=X}catch(J){this.#b(J.code);return}}readlinkSync(){let Z=this.#M;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.#M=X}catch(J){this.#b(J.code);return}}#u(Z){this.#K|=tM;for(let J=Z.provisional;J<Z.length;J++){let X=Z[J];if(X)X.#_()}}#_(){if(this.#K&c9)return;this.#K=(this.#K|c9)&FG,this.#S()}#S(){let Z=this.children();Z.provisional=0;for(let J of Z)J.#_()}#l(){this.#K|=_F,this.#N()}#N(){if(this.#K&cG)return;let Z=this.#K;if((Z&H4)===Y7)Z&=FG;this.#K=Z|cG,this.#S()}#C(Z=""){if(Z==="ENOTDIR"||Z==="EPERM")this.#N();else if(Z==="ENOENT")this.#_();else this.children().provisional=0}#y(Z=""){if(Z==="ENOTDIR")this.parent.#N();else if(Z==="ENOENT")this.#_()}#b(Z=""){let J=this.#K;if(J|=EF,Z==="ENOENT")J|=c9;if(Z==="EINVAL"||Z==="UNKNOWN")J&=FG;if(this.#K=J,Z==="ENOTDIR"&&this.parent)this.parent.#N()}#h(Z,J){return this.#p(Z,J)||this.#q(Z,J)}#q(Z,J){let X=eM(Z),$=this.newChild(Z.name,X,{parent:this}),Y=$.#K&H4;if(Y!==Y7&&Y!==f$&&Y!==q4)$.#K|=cG;return J.unshift($),J.provisional++,$}#p(Z,J){for(let X=J.provisional;X<J.length;X++){let $=J[X];if((this.nocase?IF(Z.name):xG(Z.name))!==$.#D)continue;return this.#A(Z,$,X,J)}}#A(Z,J,X,$){let Y=J.name;if(J.#K=J.#K&FG|eM(Z),Y!==Z.name)J.name=Z.name;if(X!==$.provisional){if(X===$.length-1)$.pop();else $.splice(X,1);$.unshift(J)}return $.provisional++,J}async lstat(){if((this.#K&c9)===0)try{return this.#E(await this.#Z.promises.lstat(this.fullpath())),this}catch(Z){this.#y(Z.code)}}lstatSync(){if((this.#K&c9)===0)try{return this.#E(this.#Z.lstatSync(this.fullpath())),this}catch(Z){this.#y(Z.code)}}#E(Z){let{atime:J,atimeMs:X,birthtime:$,birthtimeMs:Y,blksize:Q,blocks:K,ctime:W,ctimeMs:G,dev:z,gid:v,ino:H,mode:V,mtime:q,mtimeMs:F,nlink:w,rdev:c,size:x,uid:j}=Z;this.#U=J,this.#Q=X,this.#T=$,this.#w=Y,this.#W=Q,this.#V=K,this.#j=W,this.#c=G,this.#J=z,this.#v=v,this.#G=H,this.#$=V,this.#O=q,this.#F=F,this.#X=w,this.#H=c,this.#z=x,this.#Y=j;let B=eM(Z);if(this.#K=this.#K&FG|B|Jg,B!==q4&&B!==Y7&&B!==f$)this.#K|=cG}#m=[];#g=!1;#d(Z){this.#g=!1;let J=this.#m.slice();this.#m.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 Y=X.slice(0,X.provisional);if(J)Z(null,Y);else queueMicrotask(()=>Z(null,Y));return}if(this.#m.push(Z),this.#g)return;this.#g=!0;let $=this.fullpath();this.#Z.readdir($,{withFileTypes:!0},(Y,Q)=>{if(Y)this.#C(Y.code),X.provisional=0;else{for(let K of Q)this.#h(K,X);this.#u(X)}this.#d(X.slice(0,X.provisional));return})}#i;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.#i)await this.#i;else{let X=()=>{};this.#i=new Promise(($)=>X=$);try{for(let $ of await this.#Z.promises.readdir(J,{withFileTypes:!0}))this.#h($,Z);this.#u(Z)}catch($){this.#C($.code),Z.provisional=0}this.#i=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.#u(Z)}catch(X){this.#C(X.code),Z.provisional=0}return Z.slice(0,Z.provisional)}canReaddir(){if(this.#K&Xg)return!1;let Z=H4&this.#K;if(!(Z===q4||Z===Y7||Z===f$))return!1;return!0}shouldWalk(Z,J){return(this.#K&Y7)===Y7&&!(this.#K&Xg)&&!Z.has(this)&&(!J||J(this))}async realpath(){if(this.#k)return this.#k;if((_F|EF|c9)&this.#K)return;try{let Z=await this.#Z.promises.realpath(this.fullpath());return this.#k=this.resolve(Z)}catch(Z){this.#l()}}realpathSync(){if(this.#k)return this.#k;if((_F|EF|c9)&this.#K)return;try{let Z=this.#Z.realpathSync(this.fullpath());return this.#k=this.resolve(Z)}catch(Z){this.#l()}}[qg](Z){if(Z===this)return;Z.isCWD=!1,this.isCWD=!0;let J=new Set([]),X=[],$=this;while($&&$.parent)J.add($),$.#x=X.join(this.sep),$.#f=X.join("/"),$=$.parent,X.push("..");$=Z;while($&&$.parent&&!J.has($))$.#x=void 0,$.#f=void 0,$=$.parent}}class hF extends b6{sep="\\";splitSep=Px1;constructor(Z,J=q4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}newChild(Z,J=q4,X={}){return new hF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}getRootString(Z){return ZR.parse(Z).root}getRoot(Z){if(Z=Rx1(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 UG(Z,this).root}sameRoot(Z,J=this.root.name){return Z=Z.toUpperCase().replace(/\//g,"\\").replace(Kg,"$1\\"),Z===J}}class SF extends b6{splitSep="/";sep="/";constructor(Z,J=q4,X,$,Y,Q,K){super(Z,J,X,$,Y,Q,K)}getRootString(Z){return Z.startsWith("/")?"/":""}getRoot(Z){return this.root}newChild(Z,J=q4,X={}){return new SF(Z,J,this.root,this.roots,this.nocase,this.childrenCache(),X)}}class XR{root;rootPath;roots;cwd;#Z;#J;#$;nocase;#X;constructor(Z=process.cwd(),J,X,{nocase:$,childrenCacheSize:Y=16384,fs:Q=wG}={}){if(this.#X=Qg(Q),Z instanceof URL||Z.startsWith("file://"))Z=Hx1(Z);let K=J.resolve(Z);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#Z=new JR,this.#J=new JR,this.#$=new Hg(Y);let W=K.substring(this.rootPath.length).split(X);if(W.length===1&&!W[0])W.pop();if($===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=$,this.root=this.newRoot(this.#X),this.roots[this.rootPath]=this.root;let G=this.root,z=W.length-1,v=J.sep,H=this.rootPath,V=!1;for(let q of W){let F=z--;G=G.child(q,{relative:Array(F).fill("..").join(v),relativePosix:Array(F).fill("..").join("/"),fullpath:H+=(V?"":v)+q}),V=!0}this.cwd=G}depth(Z=this.cwd){if(typeof Z==="string")Z=this.cwd.resolve(Z);return Z.depth()}childrenCache(){return this.#$}resolve(...Z){let J="";for(let Y=Z.length-1;Y>=0;Y--){let Q=Z[Y];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 $=this.cwd.resolve(J).fullpath();return this.#Z.set(J,$),$}resolvePosix(...Z){let J="";for(let Y=Z.length-1;Y>=0;Y--){let Q=Z[Y];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 $=this.cwd.resolve(J).fullpathPosix();return this.#J.set(J,$),$}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 b6))J=Z,Z=this.cwd;let{withFileTypes:X}=J;if(!Z.canReaddir())return[];else{let $=await Z.readdir();return X?$:$.map((Y)=>Y.name)}}readdirSync(Z=this.cwd,J={withFileTypes:!0}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))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(($)=>$.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 b6))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 b6))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 b6))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 b6))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 b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=[];if(!Y||Y(Z))K.push(X?Z:Z.fullpath());let W=new Set,G=(v,H)=>{W.add(v),v.readdirCB((V,q)=>{if(V)return H(V);let F=q.length;if(!F)return H();let w=()=>{if(--F===0)H()};for(let c of q){if(!Y||Y(c))K.push(X?c:c.fullpath());if($&&c.isSymbolicLink())c.realpath().then((x)=>x?.isUnknown()?x.lstat():x).then((x)=>x?.shouldWalk(W,Q)?G(x,w):w());else if(c.shouldWalk(W,Q))G(c,w);else w()}},!0)},z=Z;return new Promise((v,H)=>{G(z,(V)=>{if(V)return H(V);v(K)})})}walkSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=[];if(!Y||Y(Z))K.push(X?Z:Z.fullpath());let W=new Set([Z]);for(let G of W){let z=G.readdirSync();for(let v of z){if(!Y||Y(v))K.push(X?v:v.fullpath());let H=v;if(v.isSymbolicLink()){if(!($&&(H=v.realpathSync())))continue;if(H.isUnknown())H.lstatSync()}if(H.shouldWalk(W,Q))W.add(H)}}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 b6))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 b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J;if(!Y||Y(Z))yield X?Z:Z.fullpath();let K=new Set([Z]);for(let W of K){let G=W.readdirSync();for(let z of G){if(!Y||Y(z))yield X?z:z.fullpath();let v=z;if(z.isSymbolicLink()){if(!($&&(v=z.realpathSync())))continue;if(v.isUnknown())v.lstatSync()}if(v.shouldWalk(K,Q))K.add(v)}}}stream(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new C$({objectMode:!0});if(!Y||Y(Z))K.write(X?Z:Z.fullpath());let W=new Set,G=[Z],z=0,v=()=>{let H=!1;while(!H){let V=G.shift();if(!V){if(z===0)K.end();return}z++,W.add(V);let q=(w,c,x=!1)=>{if(w)return K.emit("error",w);if($&&!x){let j=[];for(let B of c)if(B.isSymbolicLink())j.push(B.realpath().then((L)=>L?.isUnknown()?L.lstat():L));if(j.length){Promise.all(j).then(()=>q(null,c,!0));return}}for(let j of c)if(j&&(!Y||Y(j))){if(!K.write(X?j:j.fullpath()))H=!0}z--;for(let j of c){let B=j.realpathCached()||j;if(B.shouldWalk(W,Q))G.push(B)}if(H&&!K.flowing)K.once("drain",v);else if(!F)v()},F=!0;V.readdirCB(q,!0),F=!1}};return v(),K}streamSync(Z=this.cwd,J={}){if(typeof Z==="string")Z=this.cwd.resolve(Z);else if(!(Z instanceof b6))J=Z,Z=this.cwd;let{withFileTypes:X=!0,follow:$=!1,filter:Y,walkFilter:Q}=J,K=new C$({objectMode:!0}),W=new Set;if(!Y||Y(Z))K.write(X?Z:Z.fullpath());let G=[Z],z=0,v=()=>{let H=!1;while(!H){let V=G.shift();if(!V){if(z===0)K.end();return}z++,W.add(V);let q=V.readdirSync();for(let F of q)if(!Y||Y(F)){if(!K.write(X?F:F.fullpath()))H=!0}z--;for(let F of q){let w=F;if(F.isSymbolicLink()){if(!($&&(w=F.realpathSync())))continue;if(w.isUnknown())w.lstatSync()}if(w.shouldWalk(W,Q))G.push(w)}}if(H&&!K.flowing)K.once("drain",v)};return v(),K}chdir(Z=this.cwd){let J=this.cwd;this.cwd=typeof Z==="string"?this.cwd.resolve(Z):Z,this.cwd[qg](J)}}class UG extends XR{sep="\\";constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,ZR,"\\",{...J,nocase:X});this.nocase=X;for(let $=this.cwd;$;$=$.parent)$.nocase=this.nocase}parseRootPath(Z){return ZR.parse(Z).root.toUpperCase()}newRoot(Z){return new hF(this.rootPath,Y7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")||Z.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(Z)}}class jG extends XR{sep="/";constructor(Z=process.cwd(),J={}){let{nocase:X=!1}=J;super(Z,Vx1,"/",{...J,nocase:X});this.nocase=X}parseRootPath(Z){return"/"}newRoot(Z){return new SF(this.rootPath,Y7,void 0,this.roots,this.nocase,this.childrenCache(),{fs:Z})}isAbsolute(Z){return Z.startsWith("/")}}class bF extends jG{constructor(Z=process.cwd(),J={}){let{nocase:X=!0}=J;super(Z,{...J,nocase:X})}}var KP6=process.platform==="win32"?hF:SF,Fg=process.platform==="win32"?UG:process.platform==="darwin"?bF:jG;var Ox1=(Z)=>Z.length>=1,Tx1=(Z)=>Z.length>=1;class Q3{#Z;#J;#$;length;#X;#Y;#v;#H;#W;#G;#z=!0;constructor(Z,J,X,$){if(!Ox1(Z))throw TypeError("empty pattern list");if(!Tx1(J))throw TypeError("empty glob list");if(J.length!==Z.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=Z.length,X<0||X>=this.length)throw TypeError("index out of range");if(this.#Z=Z,this.#J=J,this.#$=X,this.#X=$,this.#$===0){if(this.isUNC()){let[Y,Q,K,W,...G]=this.#Z,[z,v,H,V,...q]=this.#J;if(G[0]==="")G.shift(),q.shift();let F=[Y,Q,K,W,""].join("/"),w=[z,v,H,V,""].join("/");this.#Z=[F,...G],this.#J=[w,...q],this.length=this.#Z.length}else if(this.isDrive()||this.isAbsolute()){let[Y,...Q]=this.#Z,[K,...W]=this.#J;if(Q[0]==="")Q.shift(),W.shift();let G=Y+"/",z=K+"/";this.#Z=[G,...Q],this.#J=[z,...W],this.length=this.#Z.length}}}pattern(){return this.#Z[this.#$]}isString(){return typeof this.#Z[this.#$]==="string"}isGlobstar(){return this.#Z[this.#$]===J6}isRegExp(){return this.#Z[this.#$]instanceof RegExp}globString(){return this.#v=this.#v||(this.#$===0?this.isAbsolute()?this.#J[0]+this.#J.slice(1).join("/"):this.#J.join("/"):this.#J.slice(this.#$).join("/"))}hasMore(){return this.length>this.#$+1}rest(){if(this.#Y!==void 0)return this.#Y;if(!this.hasMore())return this.#Y=null;return this.#Y=new Q3(this.#Z,this.#J,this.#$+1,this.#X),this.#Y.#G=this.#G,this.#Y.#W=this.#W,this.#Y.#H=this.#H,this.#Y}isUNC(){let Z=this.#Z;return this.#W!==void 0?this.#W:this.#W=this.#X==="win32"&&this.#$===0&&Z[0]===""&&Z[1]===""&&typeof Z[2]==="string"&&!!Z[2]&&typeof Z[3]==="string"&&!!Z[3]}isDrive(){let Z=this.#Z;return this.#H!==void 0?this.#H:this.#H=this.#X==="win32"&&this.#$===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.#$===0?Z:""}checkFollowGlobstar(){return!(this.#$===0||!this.isGlobstar()||!this.#z)}markFollowGlobstar(){if(this.#$===0||!this.isGlobstar()||!this.#z)return!1;return this.#z=!1,!0}}var Cx1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class BG{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(Z,{nobrace:J,nocase:X,noext:$,noglobstar:Y,platform:Q=Cx1}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=Q,this.mmopts={dot:!0,nobrace:J,nocase:X,noext:$,noglobstar:Y,optimizationLevel:2,platform:Q,nocomment:!0,nonegate:!0};for(let K of Z)this.add(K)}add(Z){let J=new V4(Z,this.mmopts);for(let X=0;X<J.set.length;X++){let $=J.set[X],Y=J.globParts[X];if(!$||!Y)throw Error("invalid pattern object");while($[0]==="."&&Y[0]===".")$.shift(),Y.shift();let Q=new Q3($,Y,0,this.platform),K=new V4(Q.globString(),this.mmopts),W=Y[Y.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}/`,$=Z.relative()||".",Y=`${$}/`;for(let Q of this.relative)if(Q.match($)||Q.match(Y))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 $ of this.relativeChildren)if($.match(X))return!0;for(let $ of this.absoluteChildren)if($.match(J))return!0;return!1}}class $R{store;constructor(Z=new Map){this.store=Z}copy(){return new $R(new Map(this.store))}hasWalked(Z,J){return this.store.get(Z.fullpath())?.has(J.globString())}storeWalked(Z,J){let X=Z.fullpath(),$=this.store.get(X);if($)$.add(J.globString());else this.store.set(X,new Set([J.globString()]))}}class wg{store=new Map;add(Z,J,X){let $=(J?2:0)|(X?1:0),Y=this.store.get(Z);this.store.set(Z,Y===void 0?$:$&Y)}entries(){return[...this.store.entries()].map(([Z,J])=>[Z,!!(J&2),!!(J&1)])}}class cg{store=new Map;add(Z,J){if(!Z.canReaddir())return;let X=this.store.get(Z);if(X){if(!X.find(($)=>$.globString()===J.globString()))X.push(J)}else this.store.set(Z,[J])}get(Z){let J=this.store.get(Z);if(!J)throw 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 LG{hasWalkedCache;matches=new wg;subwalks=new cg;patterns;follow;dot;opts;constructor(Z,J){this.opts=Z,this.follow=!!Z.follow,this.dot=!!Z.dot,this.hasWalkedCache=J?J.copy():new $R}processPatterns(Z,J){this.patterns=J;let X=J.map(($)=>[Z,$]);for(let[$,Y]of X){this.hasWalkedCache.storeWalked($,Y);let Q=Y.root(),K=Y.isAbsolute()&&this.opts.absolute!==!1;if(Q){$=$.resolve(Q==="/"&&this.opts.root!==void 0?this.opts.root:Q);let v=Y.rest();if(!v){this.matches.add($,!0,!1);continue}else Y=v}if($.isENOENT())continue;let W,G,z=!1;while(typeof(W=Y.pattern())==="string"&&(G=Y.rest()))$=$.resolve(W),Y=G,z=!0;if(W=Y.pattern(),G=Y.rest(),z){if(this.hasWalkedCache.hasWalked($,Y))continue;this.hasWalkedCache.storeWalked($,Y)}if(typeof W==="string"){let v=W===".."||W===""||W===".";this.matches.add($.resolve(W),K,v);continue}else if(W===J6){if(!$.isSymbolicLink()||this.follow||Y.checkFollowGlobstar())this.subwalks.add($,Y);let v=G?.pattern(),H=G?.rest();if(!G||(v===""||v===".")&&!H)this.matches.add($,K,v===""||v===".");else if(v===".."){let V=$.parent||$;if(!H)this.matches.add(V,K,!0);else if(!this.hasWalkedCache.hasWalked(V,H))this.subwalks.add(V,H)}}else if(W instanceof RegExp)this.subwalks.add($,Y)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new LG(this.opts,this.hasWalkedCache)}filterEntries(Z,J){let X=this.subwalks.get(Z),$=this.child();for(let Y of J)for(let Q of X){let K=Q.isAbsolute(),W=Q.pattern(),G=Q.rest();if(W===J6)$.testGlobstar(Y,Q,G,K);else if(W instanceof RegExp)$.testRegExp(Y,W,G,K);else $.testString(Y,W,G,K)}return $}testGlobstar(Z,J,X,$){if(this.dot||!Z.name.startsWith(".")){if(!J.hasMore())this.matches.add(Z,$,!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 Y=X.pattern();if(typeof Y==="string"&&Y!==".."&&Y!==""&&Y!==".")this.testString(Z,Y,X.rest(),$);else if(Y===".."){let Q=Z.parent||Z;this.subwalks.add(Q,X)}else if(Y instanceof RegExp)this.testRegExp(Z,Y,X.rest(),$)}}testRegExp(Z,J,X,$){if(!J.test(Z.name))return;if(!X)this.matches.add(Z,$,!1);else this.subwalks.add(Z,X)}testString(Z,J,X,$){if(!Z.isNamed(J))return;if(!X)this.matches.add(Z,$,!1);else this.subwalks.add(Z,X)}}var fx1=(Z,J)=>typeof Z==="string"?new BG([Z],J):Array.isArray(Z)?new BG(Z,J):Z;class YR{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#Z=[];#J;#$;signal;maxDepth;includeChildMatches;constructor(Z,J,X){if(this.patterns=Z,this.path=J,this.opts=X,this.#$=!X.posix&&X.platform==="win32"?"\\":"/",this.includeChildMatches=X.includeChildMatches!==!1,X.ignore||!this.includeChildMatches){if(this.#J=fx1(X.ignore??[],X),!this.includeChildMatches&&typeof this.#J.add!=="function")throw 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)}#Y(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 Y=Z.isUnknown()||this.opts.stat?await Z.lstat():Z;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let Q=await Y.realpath();if(Q&&(Q.isUnknown()||this.opts.stat))await Q.lstat()}return this.matchCheckTest(Y,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 Y=Z.isUnknown()||this.opts.stat?Z.lstatSync():Z;if(this.opts.follow&&this.opts.nodir&&Y?.isSymbolicLink()){let Q=Y.realpathSync();if(Q&&(Q?.isUnknown()||this.opts.stat))Q.lstatSync()}return this.matchCheckTest(Y,J)}matchFinish(Z,J){if(this.#X(Z))return;if(!this.includeChildMatches&&this.#J?.add){let Y=`${Z.relativePosix()}/**`;this.#J.add(Y)}let X=this.opts.absolute===void 0?J:this.opts.absolute;this.seen.add(Z);let $=this.opts.mark&&Z.isDirectory()?this.#$:"";if(this.opts.withFileTypes)this.matchEmit(Z);else if(X){let Y=this.opts.posix?Z.fullpathPosix():Z.fullpath();this.matchEmit(Y+$)}else{let Y=this.opts.posix?Z.relativePosix():Z.relative(),Q=this.opts.dotRelative&&!Y.startsWith(".."+this.#$)?"."+this.#$:"";this.matchEmit(!Y?"."+$:Q+Y+$)}}async match(Z,J,X){let $=await this.matchCheck(Z,X);if($)this.matchFinish($,J)}matchSync(Z,J,X){let $=this.matchCheckSync(Z,X);if($)this.matchFinish($,J)}walkCB(Z,J,X){if(this.signal?.aborted)X();this.walkCB2(Z,J,new LG(this.opts),X)}walkCB2(Z,J,X,$){if(this.#Y(Z))return $();if(this.signal?.aborted)$();if(this.paused){this.onResume(()=>this.walkCB2(Z,J,X,$));return}X.processPatterns(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;Y++,this.match(K,W,G).then(()=>Q())}for(let K of X.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;Y++;let W=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,W,X,Q);else K.readdirCB((G,z)=>this.walkCB3(K,z,X,Q),!0)}Q()}walkCB3(Z,J,X,$){X=X.filterEntries(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};for(let[K,W,G]of X.matches.entries()){if(this.#X(K))continue;Y++,this.match(K,W,G).then(()=>Q())}for(let[K,W]of X.subwalks.entries())Y++,this.walkCB2(K,W,X.child(),Q);Q()}walkCBSync(Z,J,X){if(this.signal?.aborted)X();this.walkCB2Sync(Z,J,new LG(this.opts),X)}walkCB2Sync(Z,J,X,$){if(this.#Y(Z))return $();if(this.signal?.aborted)$();if(this.paused){this.onResume(()=>this.walkCB2Sync(Z,J,X,$));return}X.processPatterns(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};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;Y++;let W=K.readdirSync();this.walkCB3Sync(K,W,X,Q)}Q()}walkCB3Sync(Z,J,X,$){X=X.filterEntries(Z,J);let Y=1,Q=()=>{if(--Y===0)$()};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())Y++,this.walkCB2Sync(K,W,X.child(),Q);Q()}}class AF extends YR{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 mF extends YR{results;constructor(Z,J,X){super(Z,J,X);this.results=new C$({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 Ex1=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class Q7{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 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=kx1(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 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 TypeError("base matching requires globstar");Z=Z.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=Z,this.platform=J.platform||Ex1,this.opts={...J,platform:this.platform},J.scurry){if(this.scurry=J.scurry,J.nocase!==void 0&&J.nocase!==J.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=J.platform==="win32"?UG:J.platform==="darwin"?bF:J.platform?jG:Fg;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",$={...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},Y=this.pattern.map((W)=>new V4(W,$)),[Q,K]=Y.reduce((W,G)=>{return W[0].push(...G.set),W[1].push(...G.globParts),W},[[],[]]);this.patterns=Q.map((W,G)=>{let z=K[G];if(!z)throw Error("invalid pattern object");return new Q3(W,z,0,this.platform)})}async walk(){return[...await new AF(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 AF(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 mF(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 mF(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 QR=(Z,J={})=>{if(!Array.isArray(Z))Z=[Z];for(let X of Z)if(new V4(X,J).hasMagic())return!0;return!1};function lF(Z,J={}){return new Q7(Z,J).streamSync()}function Ug(Z,J={}){return new Q7(Z,J).stream()}function jg(Z,J={}){return new Q7(Z,J).walkSync()}async function xg(Z,J={}){return new Q7(Z,J).walk()}function yF(Z,J={}){return new Q7(Z,J).iterateSync()}function Bg(Z,J={}){return new Q7(Z,J).iterate()}var Ix1=lF,_x1=Object.assign(Ug,{sync:lF}),hx1=yF,Sx1=Object.assign(Bg,{sync:yF}),bx1=Object.assign(jg,{stream:lF,iterate:yF}),uF=Object.assign(xg,{glob:xg,globSync:jg,sync:bx1,globStream:Ug,stream:_x1,globStreamSync:lF,streamSync:Ix1,globIterate:Bg,iterate:Sx1,globIterateSync:yF,iterateSync:hx1,Glob:Q7,hasMagic:QR,escape:Z3,unescape:F9});uF.glob=uF;class KR{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 $=this._listeners[Z];if($!==void 0){let Y=$.indexOf(J);if(Y!==-1)$.splice(Y,1)}return this}dispatchEvent(Z){let X=this._listeners[Z.type];if(X!==void 0){let $=X.slice(0);for(let Y=0,Q=$.length;Y<Q;Y++)$[Y].call(this,Z)}return this}dispose(){for(let Z in this._listeners)delete this._listeners[Z]}}class XZ{constructor(Z,J,X,$={}){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=$,!J.isOnGraph(X))throw 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 pF extends KR{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,$){let Y=new XZ(Z,J,X,$);this._edges.add(Y);let Q=Y.getParent();if(!this._parentEdges.has(Q))this._parentEdges.set(Q,new Set);this._parentEdges.get(Q).add(Y);let K=Y.getChild();if(!this._childEdges.has(K))this._childEdges.set(K,new Set);return this._childEdges.get(K).add(Y),Y}_destroyEdge(Z){return this._edges.delete(Z),this._parentEdges.get(Z.getParent()).delete(Z),this._childEdges.get(Z.getChild()).delete(Z),this}}function DG(){return DG=Object.assign||function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)if(Object.prototype.hasOwnProperty.call(X,$))Z[$]=X[$]}return Z},DG.apply(this,arguments)}class x9{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 w1{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 A6{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 H1=Symbol("attributes"),hJ=Symbol("immutableKeys");class iF extends KR{constructor(Z){super();this._disposed=!1,this.graph=void 0,this[H1]=void 0,this[hJ]=void 0,this.graph=Z,this[hJ]=new Set,this[H1]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){let Z=this.getDefaults(),J={};for(let X in Z){let $=Z[X];if($ instanceof iF){let Y=this.graph._createEdge(X,this,$);this[hJ].add(X),J[X]=Y}else J[X]=$}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[H1]){let $=this[H1][X];if($ instanceof XZ){let Y=$;if(Y.getChild()===Z)this.setRef(X,J,Y.getAttributes())}else if($ instanceof x9)for(let Y of $.listRefsByChild(Z)){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}else if($ instanceof w1){let Y=$.getRefByChild(Z);if(Y){let Q=Y.getAttributes();this.removeRef(X,Z),this.addRef(X,J,Q)}}else if($ instanceof A6)for(let Y of $.keys()){let Q=$.get(Y);if(Q.getChild()===Z)this.setRefMap(X,Y,J,Q.getAttributes())}}return this}get(Z){return this[H1][Z]}set(Z,J){return this[H1][Z]=J,this.dispatchEvent({type:"change",attribute:Z})}getRef(Z){let J=this[H1][Z];return J?J.getChild():null}setRef(Z,J,X){if(this[hJ].has(Z))throw Error(`Cannot overwrite immutable attribute, "${Z}".`);let $=this[H1][Z];if($)$.dispose();if(!J)return this;let Y=this.graph._createEdge(Z,this,J,X);return this[H1][Z]=Y,this.dispatchEvent({type:"change",attribute:Z})}listRefs(Z){return this.assertRefList(Z).values().map((X)=>X.getChild())}addRef(Z,J,X){let $=this.graph._createEdge(Z,this,J,X);return this.assertRefList(Z).add($),this.dispatchEvent({type:"change",attribute:Z})}removeRef(Z,J){let X=this.assertRefList(Z);if(X instanceof x9)for(let $ of X.listRefsByChild(J))$.dispose();else{let $=X.getRefByChild(J);if($)$.dispose()}return this}assertRefList(Z){let J=this[H1][Z];if(J instanceof x9||J instanceof w1)return J;throw 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 $=this.assertRefMap(Z).get(J);return $?$.getChild():null}setRefMap(Z,J,X,$){let Y=this.assertRefMap(Z),Q=Y.get(J);if(Q)Q.dispose();if(!X)return this;$=Object.assign($||{},{key:J});let K=this.graph._createEdge(Z,this,X,DG({},$,{key:J}));return Y.set(J,K),this.dispatchEvent({type:"change",attribute:Z,key:J})}assertRefMap(Z){let J=this[H1][Z];if(J instanceof A6)return J;throw Error(`Expected RefMap for attribute "${Z}"`)}dispatchEvent(Z){return super.dispatchEvent(DG({},Z,{target:this})),this.graph.dispatchEvent(DG({},Z,{target:this,type:`node:${Z.type}`})),this}_destroyRef(Z){let J=Z.getName();if(this[H1][J]===Z){if(this[H1][J]=null,this[hJ].has(J))Z.getChild().dispose()}else if(this[H1][J]instanceof x9)this[H1][J].remove(Z);else if(this[H1][J]instanceof w1)this[H1][J].remove(Z);else if(this[H1][J]instanceof A6){let X=this[H1][J];for(let $ of X.keys())if(X.get($)===Z)X.delete($)}else return;this.graph._destroyEdge(Z),this.dispatchEvent({type:"change",attribute:J})}}var Og="v4.2.1",E$="@glb.bin",i;(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"})(i||(i={}));var oF;(function(Z){Z.INTERLEAVED="interleaved",Z.SEPARATE="separate"})(oF||(oF={}));var h5;(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"})(h5||(h5={}));var v5;(function(Z){Z[Z.R=4096]="R",Z[Z.G=256]="G",Z[Z.B=16]="B",Z[Z.A=1]="A"})(v5||(v5={}));var $Z;(function(Z){Z.GLTF="GLTF",Z.GLB="GLB"})($Z||($Z={}));var bJ={"5120":Int8Array,"5121":Uint8Array,"5122":Int16Array,"5123":Uint16Array,"5125":Uint32Array,"5126":Float32Array};class E0{static createBufferFromDataURI(Z){if(typeof Buffer>"u"){let J=atob(Z.split(",")[1]),X=new Uint8Array(J.length);for(let $=0;$<J.length;$++)X[$]=J.charCodeAt($);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 Y of Z)J+=Y.byteLength;let X=new Uint8Array(J),$=0;for(let Y 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 $=new Uint8Array(X);if($.set(Z),J!==0)for(let Y=Z.byteLength;Y<X;Y++)$[Y]=J;return $}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 Error(`Method requires Uint8Array parameter; received "${typeof Z}".`);return Z}}class HR{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^$*255<<8^Y*255<<0}static convertSRGBToLinear(Z,J){let X=Z,$=J;for(let Y=0;Y<3;Y++)$[Y]=X[Y]<0.04045?X[Y]*0.0773993808:Math.pow(X[Y]*0.9478672986+0.0521327014,2.4);return J}static convertLinearToSRGB(Z,J){let X=Z,$=J;for(let Y=0;Y<3;Y++)$[Y]=X[Y]<0.0031308?X[Y]*12.92:1.055*Math.pow(X[Y],0.41666)-0.055;return J}}class Tg{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,$;while(J.byteLength){if(X=J.getUint16(0,!1),Ax1(J,X),$=J.getUint8(X+1),$===192||$===193||$===194)return[J.getUint16(X+7,!1),J.getUint16(X+5,!1)];J=new DataView(Z.buffer,J.byteOffset+X+2)}throw TypeError("Invalid JPG, no size found")}getChannels(Z){return 3}}class eF{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(E0.decodeText(Z.slice(12,16))===eF.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}}eF.PNG_FRIED_CHUNK_NAME="CgBI";class _5{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,$=4,Y=this.getSize(Z,J);if(!Y)return null;while(Y[0]>1||Y[1]>1)X+=Y[0]*Y[1]*$,Y[0]=Math.max(Math.floor(Y[0]/2),1),Y[1]=Math.max(Math.floor(Y[1]/2),1);return X+=1*$,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}`}}_5.impls={"image/jpeg":new Tg,"image/png":new eF};function Ax1(Z,J){if(J>Z.byteLength)throw TypeError("Corrupt JPG, exceeded buffer limits");if(Z.getUint8(J)!==255)throw TypeError("Invalid JPG, marker table corrupted");return Z}class YZ{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 _5.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()}}var GR=typeof Float32Array<"u"?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 mx1(){var Z=new GR(3);if(GR!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function WR(Z){var J=Z[0],X=Z[1],$=Z[2];return Math.hypot(J,X,$)}function ux1(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=X[3]*$+X[7]*Y+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*$+X[4]*Y+X[8]*Q+X[12])/K,Z[1]=(X[1]*$+X[5]*Y+X[9]*Q+X[13])/K,Z[2]=(X[2]*$+X[6]*Y+X[10]*Q+X[14])/K,Z}(function(){var Z=mx1();return function(J,X,$,Y,Q,K){var W,G;if(!X)X=3;if(!$)$=0;if(Y)G=Math.min(Y*X+$,J.length);else G=J.length;for(W=$;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 PG(Z){let J=Cg(),X=Z.propertyType===i.NODE?[Z]:Z.listChildren();for(let $ of X)$.traverse((Y)=>{let Q=Y.getMesh();if(!Q)return;let K=lx1(Q,Y.getWorldMatrix());if(K.min.every(isFinite)&&K.max.every(isFinite))zR(K.min,J),zR(K.max,J)});return J}function lx1(Z,J){let X=Cg();for(let $ of Z.listPrimitives()){let Y=$.getAttribute("POSITION"),Q=$.getIndices();if(!Y)continue;let K=[0,0,0],W=[0,0,0];for(let G=0,z=Q?Q.getCount():Y.getCount();G<z;G++){let v=Q?Q.getScalar(G):G;K=Y.getElement(v,K),W=ux1(W,K,J),zR(W,X)}}return X}function zR(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 Cg(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}var Lg="https://null.example";class F4{static dirname(Z){let J=Z.lastIndexOf("/");if(J===-1)return"./";return Z.substring(0,J+1)}static basename(Z){return YZ.basename(new URL(Z,Lg).pathname)}static extension(Z){return YZ.extension(new URL(Z,Lg).pathname)}static resolve(Z,J){if(!this.isRelativePath(J))return J;let X=Z.split("/"),$=J.split("/");X.pop();for(let Y=0;Y<$.length;Y++){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)}}F4.DEFAULT_INIT={};F4.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;function Dg(Z){return Object.prototype.toString.call(Z)==="[object Object]"}function k$(Z){if(Dg(Z)===!1)return!1;let J=Z.constructor;if(J===void 0)return!0;let X=J.prototype;if(Dg(X)===!1)return!1;if(Object.hasOwn(X,"isPrototypeOf")===!1)return!1;return!0}var vR,MG;(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"})(MG||(MG={}));class z5{constructor(Z){this.verbosity=void 0,this.verbosity=Z}debug(Z){if(this.verbosity<=z5.Verbosity.DEBUG)console.debug(Z)}info(Z){if(this.verbosity<=z5.Verbosity.INFO)console.info(Z)}warn(Z){if(this.verbosity<=z5.Verbosity.WARN)console.warn(Z)}error(Z){if(this.verbosity<=z5.Verbosity.ERROR)console.error(Z)}}vR=z5;z5.Verbosity=MG;z5.DEFAULT_INSTANCE=new vR(vR.Verbosity.INFO);function yx1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],z=Z[8],v=Z[9],H=Z[10],V=Z[11],q=Z[12],F=Z[13],w=Z[14],c=Z[15],x=J*K-X*Q,j=J*W-$*Q,B=J*G-Y*Q,L=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,P=z*F-v*q,N=z*w-H*q,O=z*c-V*q,k=v*w-H*F,E=v*c-V*F,S=H*c-V*w;return x*S-j*E+B*k+L*O-R*N+M*P}function px1(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],z=J[6],v=J[7],H=J[8],V=J[9],q=J[10],F=J[11],w=J[12],c=J[13],x=J[14],j=J[15],B=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=B*$+L*W+R*H+M*w,Z[1]=B*Y+L*G+R*V+M*c,Z[2]=B*Q+L*z+R*q+M*x,Z[3]=B*K+L*v+R*F+M*j,B=X[4],L=X[5],R=X[6],M=X[7],Z[4]=B*$+L*W+R*H+M*w,Z[5]=B*Y+L*G+R*V+M*c,Z[6]=B*Q+L*z+R*q+M*x,Z[7]=B*K+L*v+R*F+M*j,B=X[8],L=X[9],R=X[10],M=X[11],Z[8]=B*$+L*W+R*H+M*w,Z[9]=B*Y+L*G+R*V+M*c,Z[10]=B*Q+L*z+R*q+M*x,Z[11]=B*K+L*v+R*F+M*j,B=X[12],L=X[13],R=X[14],M=X[15],Z[12]=B*$+L*W+R*H+M*w,Z[13]=B*Y+L*G+R*V+M*c,Z[14]=B*Q+L*z+R*q+M*x,Z[15]=B*K+L*v+R*F+M*j,Z}function ix1(Z,J){var X=J[0],$=J[1],Y=J[2],Q=J[4],K=J[5],W=J[6],G=J[8],z=J[9],v=J[10];return Z[0]=Math.hypot(X,$,Y),Z[1]=Math.hypot(Q,K,W),Z[2]=Math.hypot(G,z,v),Z}function gx1(Z,J){var X=new GR(3);ix1(X,J);var $=1/X[0],Y=1/X[1],Q=1/X[2],K=J[0]*$,W=J[1]*Y,G=J[2]*Q,z=J[4]*$,v=J[5]*Y,H=J[6]*Q,V=J[8]*$,q=J[9]*Y,F=J[10]*Q,w=K+v+F,c=0;if(w>0)c=Math.sqrt(w+1)*2,Z[3]=0.25*c,Z[0]=(H-q)/c,Z[1]=(V-G)/c,Z[2]=(W-z)/c;else if(K>v&&K>F)c=Math.sqrt(1+K-v-F)*2,Z[3]=(H-q)/c,Z[0]=0.25*c,Z[1]=(W+z)/c,Z[2]=(V+G)/c;else if(v>F)c=Math.sqrt(1+v-K-F)*2,Z[3]=(V-G)/c,Z[0]=(W+z)/c,Z[1]=0.25*c,Z[2]=(H+q)/c;else c=Math.sqrt(1+F-K-v)*2,Z[3]=(W-z)/c,Z[0]=(V+G)/c,Z[1]=(H+q)/c,Z[2]=0.25*c;return Z}class I0{static identity(Z){return Z}static eq(Z,J,X=0.00001){if(Z.length!==J.length)return!1;for(let $=0;$<Z.length;$++)if(Math.abs(Z[$]-J[$])>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 Error("Invalid component type.")}}static encodeNormalizedInt(Z,J){switch(J){case 5126:return Z;case 5123:return Math.round(I0.clamp(Z,0,1)*65535);case 5121:return Math.round(I0.clamp(Z,0,1)*255);case 5122:return Math.round(I0.clamp(Z,-1,1)*32767);case 5120:return Math.round(I0.clamp(Z,-1,1)*127);default:throw Error("Invalid component type.")}}static decompose(Z,J,X,$){let Y=WR([Z[0],Z[1],Z[2]]),Q=WR([Z[4],Z[5],Z[6]]),K=WR([Z[8],Z[9],Z[10]]);if(yx1(Z)<0)Y=-Y;J[0]=Z[12],J[1]=Z[13],J[2]=Z[14];let G=Z.slice(),z=1/Y,v=1/Q,H=1/K;G[0]*=z,G[1]*=z,G[2]*=z,G[4]*=v,G[5]*=v,G[6]*=v,G[8]*=H,G[9]*=H,G[10]*=H,gx1(X,G),$[0]=Y,$[1]=Q,$[2]=K}static compose(Z,J,X,$){let Y=$,Q=J[0],K=J[1],W=J[2],G=J[3],z=Q+Q,v=K+K,H=W+W,V=Q*z,q=Q*v,F=Q*H,w=K*v,c=K*H,x=W*H,j=G*z,B=G*v,L=G*H,R=X[0],M=X[1],P=X[2];return Y[0]=(1-(w+x))*R,Y[1]=(q+L)*R,Y[2]=(F-B)*R,Y[3]=0,Y[4]=(q-L)*M,Y[5]=(1-(V+x))*M,Y[6]=(c+j)*M,Y[7]=0,Y[8]=(F+B)*P,Y[9]=(c-j)*P,Y[10]=(1-(V+w))*P,Y[11]=0,Y[12]=Z[0],Y[13]=Z[1],Y[14]=Z[2],Y[15]=1,Y}}function dx1(Z,J){if(!!Z!==!!J)return!1;let X=Z.getChild(),$=J.getChild();return X===$||X.equals($)}function ax1(Z,J){if(!!Z!==!!J)return!1;let X=Z.values(),$=J.values();if(X.length!==$.length)return!1;for(let Y=0;Y<X.length;Y++){let Q=X[Y],K=$[Y];if(Q.getChild()===K.getChild())continue;if(!Q.getChild().equals(K.getChild()))return!1}return!0}function nx1(Z,J){if(!!Z!==!!J)return!1;let X=Z.keys(),$=J.keys();if(X.length!==$.length)return!1;for(let Y of X){let Q=Z.get(Y),K=J.get(Y);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 fg(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 kg(Z,J){if(Z===J)return!0;if(!!Z!==!!J)return!1;if(!k$(Z)||!k$(J))return Z===J;let X=Z,$=J,Y=0,Q=0,K;for(K in X)Y++;for(K in $)Q++;if(Y!==Q)return!1;for(K in X){let W=X[K],G=$[K];if(rF(W)&&rF(G)){if(!fg(W,G))return!1}else if(k$(W)&&k$(G)){if(!kg(W,G))return!1}else if(W!==G)return!1}return!0}function rF(Z){return Array.isArray(Z)||ArrayBuffer.isView(Z)}var Mg="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",sx1=999,ox1=6,Rg=new Set,rx1=function(){let J="";for(let X=0;X<ox1;X++)J+=Mg.charAt(Math.floor(Math.random()*Mg.length));return J},Eg=function(){for(let J=0;J<sx1;J++){let X=rx1();if(!Rg.has(X))return Rg.add(X),X}return""},SJ=(Z)=>Z,tx1=new Set;class Zw extends iF{constructor(Z,J=""){super(Z);this[H1].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,SJ)}copy(Z,J=SJ){for(let X in this[H1]){let $=this[H1][X];if($ instanceof XZ){if(!this[hJ].has(X))$.dispose()}else if($ instanceof x9||$ instanceof w1)for(let Y of $.values())Y.dispose();else if($ instanceof A6)for(let Y of $.values())Y.dispose()}for(let X in Z[H1]){let $=this[H1][X],Y=Z[H1][X];if(Y instanceof XZ)if(this[hJ].has(X))$.getChild().copy(J(Y.getChild()),J);else this.setRef(X,J(Y.getChild()),Y.getAttributes());else if(Y instanceof w1||Y instanceof x9)for(let Q of Y.values())this.addRef(X,J(Q.getChild()),Q.getAttributes());else if(Y instanceof A6)for(let Q of Y.keys()){let K=Y.get(Q);this.setRefMap(X,Q,J(K.getChild()),K.getAttributes())}else if(k$(Y))this[H1][X]=JSON.parse(JSON.stringify(Y));else if(Array.isArray(Y)||Y instanceof ArrayBuffer||ArrayBuffer.isView(Y))this[H1][X]=Y.slice();else this[H1][X]=Y}return this}equals(Z,J=tx1){if(this===Z)return!0;if(this.propertyType!==Z.propertyType)return!1;for(let X in this[H1]){if(J.has(X))continue;let $=this[H1][X],Y=Z[H1][X];if($ instanceof XZ||Y instanceof XZ){if(!dx1($,Y))return!1}else if($ instanceof w1||Y instanceof w1||$ instanceof x9||Y instanceof x9){if(!ax1($,Y))return!1}else if($ instanceof A6||Y instanceof A6){if(!nx1($,Y))return!1}else if(k$($)||k$(Y)){if(!kg($,Y))return!1}else if(rF($)||rF(Y)){if(!fg($,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 x6 extends Zw{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new A6})}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 K0 extends x6{init(){this.propertyType=i.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:K0.Type.SCALAR,componentType:K0.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(Z){switch(Z){case K0.Type.SCALAR:return 1;case K0.Type.VEC2:return 2;case K0.Type.VEC3:return 3;case K0.Type.VEC4:return 4;case K0.Type.MAT2:return 4;case K0.Type.MAT3:return 9;case K0.Type.MAT4:return 16;default:throw Error("Unexpected type: "+Z)}}static getComponentSize(Z){switch(Z){case K0.ComponentType.BYTE:return 1;case K0.ComponentType.UNSIGNED_BYTE:return 1;case K0.ComponentType.SHORT:return 2;case K0.ComponentType.UNSIGNED_SHORT:return 2;case K0.ComponentType.UNSIGNED_INT:return 4;case K0.ComponentType.FLOAT:return 4;default:throw Error("Unexpected component type: "+Z)}}getMinNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),$=this.getComponentType();if(this.getMin(Z),J)for(let Y=0;Y<X;Y++)Z[Y]=I0.decodeNormalizedInt(Z[Y],$);return Z}getMin(Z){let J=this.getArray(),X=this.getCount(),$=this.getElementSize();for(let Y=0;Y<$;Y++)Z[Y]=1/0;for(let Y=0;Y<X*$;Y+=$)for(let Q=0;Q<$;Q++){let K=J[Y+Q];if(Number.isFinite(K))Z[Q]=Math.min(Z[Q],K)}return Z}getMaxNormalized(Z){let J=this.getNormalized(),X=this.getElementSize(),$=this.getComponentType();if(this.getMax(Z),J)for(let Y=0;Y<X;Y++)Z[Y]=I0.decodeNormalizedInt(Z[Y],$);return Z}getMax(Z){let J=this.get("array"),X=this.getCount(),$=this.getElementSize();for(let Y=0;Y<$;Y++)Z[Y]=-1/0;for(let Y=0;Y<X*$;Y+=$)for(let Q=0;Q<$;Q++){let K=J[Y+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 K0.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(),$=this.getArray();if(this.getNormalized())return I0.decodeNormalizedInt($[Z*J],X);return $[Z*J]}setScalar(Z,J){let X=this.getElementSize(),$=this.getComponentType(),Y=this.getArray();if(this.getNormalized())Y[Z*X]=I0.encodeNormalizedInt(J,$);else Y[Z*X]=J;return this}getElement(Z,J){let X=this.getNormalized(),$=this.getElementSize(),Y=this.getComponentType(),Q=this.getArray();for(let K=0;K<$;K++)if(X)J[K]=I0.decodeNormalizedInt(Q[Z*$+K],Y);else J[K]=Q[Z*$+K];return J}setElement(Z,J){let X=this.getNormalized(),$=this.getElementSize(),Y=this.getComponentType(),Q=this.getArray();for(let K=0;K<$;K++)if(X)Q[Z*$+K]=I0.encodeNormalizedInt(J[K],Y);else Q[Z*$+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?ex1(Z):K0.ComponentType.FLOAT),this.set("array",Z),this}getByteLength(){let Z=this.get("array");return Z?Z.byteLength:0}}K0.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};K0.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function ex1(Z){switch(Z.constructor){case Float32Array:return K0.ComponentType.FLOAT;case Uint32Array:return K0.ComponentType.UNSIGNED_INT;case Uint16Array:return K0.ComponentType.UNSIGNED_SHORT;case Uint8Array:return K0.ComponentType.UNSIGNED_BYTE;case Int16Array:return K0.ComponentType.SHORT;case Int8Array:return K0.ComponentType.BYTE;default:throw Error("Unknown accessor componentType.")}}class qR extends x6{init(){this.propertyType=i.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new w1,samplers:new w1})}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 QZ extends x6{init(){this.propertyType=i.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)}}QZ.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class AJ extends x6{init(){this.propertyType=i.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:AJ.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:h5.OTHER})}getOutput(){return this.getRef("output")}setOutput(Z){return this.setRef("output",Z,{usage:h5.OTHER})}}AJ.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class FR extends x6{init(){this.propertyType=i.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(Z){return this.set("uri",Z)}}class I$ extends x6{init(){this.propertyType=i.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:I$.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)}}I$.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class O1 extends Zw{_validateParent(Z){if(!this.parentTypes.includes(Z.propertyType))throw Error(`Parent "${Z.propertyType}" invalid for child "${this.propertyType}".`)}}O1.EXTENSION_NAME=void 0;class F1 extends x6{init(){this.propertyType=i.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:F1.WrapMode.REPEAT,wrapT:F1.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)}}F1.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};F1.MagFilter={NEAREST:9728,LINEAR:9729};F1.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var{R:gF,G:dF,B:aF,A:ZU1}=v5;class K7 extends x6{init(){this.propertyType=i.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:K7.AlphaMode.OPAQUE,alphaCutoff:0.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new F1(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new F1(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new F1(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new F1(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new F1(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:gF|dF|aF|ZU1,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:gF|dF|aF,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:gF|dF|aF})}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:gF})}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:dF|aF})}}K7.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class NG extends x6{init(){this.propertyType=i.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new w1})}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 Jw extends x6{init(){this.propertyType=i.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 w1})}copy(Z,J=SJ){if(J===SJ)throw 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 I0.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(Z){let J=this.get("translation").slice(),X=this.get("rotation").slice(),$=this.get("scale").slice();return I0.decompose(Z,J,X,$),this.set("translation",J).set("rotation",X).set("scale",$)}getWorldTranslation(){let Z=[0,0,0];return I0.decompose(this.getWorldMatrix(),Z,[0,0,0,1],[1,1,1]),Z}getWorldRotation(){let Z=[0,0,0,1];return I0.decompose(this.getWorldMatrix(),[0,0,0],Z,[1,1,1]),Z}getWorldScale(){let Z=[1,1,1];return I0.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],Z),Z}getWorldMatrix(){let Z=[];for(let $=this;$!=null;$=$.getParentNode())Z.push($);let J,X=Z.pop().getMatrix();while(J=Z.pop())px1(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===i.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===i.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 g1 extends x6{init(){this.propertyType=i.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:g1.Mode.TRIANGLES,material:null,indices:null,attributes:new A6,targets:new w1})}getIndices(){return this.getRef("indices")}setIndices(Z){return this.setRef("indices",Z,{usage:h5.ELEMENT_ARRAY_BUFFER})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:h5.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)}}g1.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class wR extends Zw{init(){this.propertyType=i.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new A6})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:h5.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function m6(){return m6=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)({}).hasOwnProperty.call(X,$)&&(Z[$]=X[$])}return Z},m6.apply(null,arguments)}class K3 extends x6{init(){this.propertyType=i.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new w1})}copy(Z,J=SJ){if(J===SJ)throw 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 cR extends x6{init(){this.propertyType=i.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new w1})}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:h5.INVERSE_BIND_MATRICES})}addJoint(Z){return this.addRef("joints",Z)}removeJoint(Z){return this.removeRef("joints",Z)}listJoints(){return this.listRefs("joints")}}class _$ extends x6{init(){this.propertyType=i.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||_5.extensionToMimeType(YZ.extension(this.get("uri")))}setMimeType(Z){return this.set("mimeType",Z)}getURI(){return this.get("uri")}setURI(Z){this.set("uri",Z);let J=_5.extensionToMimeType(YZ.extension(Z));if(J)this.set("mimeType",J);return this}getImage(){return this.get("image")}setImage(Z){return this.set("image",E0.assertView(Z))}getSize(){let Z=this.get("image");if(!Z)return null;return _5.getSize(Z,this.getMimeType())}}class W3 extends x6{init(){this.propertyType=i.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Og}`,version:"2.0"},defaultScene:null,accessors:new w1,animations:new w1,buffers:new w1,cameras:new w1,materials:new w1,meshes:new w1,nodes:new w1,scenes:new w1,skins:new w1,textures:new w1})}constructor(Z){super(Z);this._extensions=new Set,Z.addEventListener("node:create",(J)=>{this._addChildOfRoot(J.target)})}clone(){throw Error("Root cannot be cloned.")}copy(Z,J=SJ){if(J===SJ)throw Error("Root cannot be copied.");this.set("asset",m6({},Z.get("asset"))),this.setName(Z.getName()),this.setExtras(m6({},Z.getExtras())),this.setDefaultScene(Z.getDefaultScene()?J(Z.getDefaultScene()):null);for(let X of Z.listRefMapKeys("extensions")){let $=Z.getExtension(X);this.setExtension(X,J($))}return this}_addChildOfRoot(Z){if(Z instanceof K3)this.addRef("scenes",Z);else if(Z instanceof Jw)this.addRef("nodes",Z);else if(Z instanceof I$)this.addRef("cameras",Z);else if(Z instanceof cR)this.addRef("skins",Z);else if(Z instanceof NG)this.addRef("meshes",Z);else if(Z instanceof K7)this.addRef("materials",Z);else if(Z instanceof _$)this.addRef("textures",Z);else if(Z instanceof qR)this.addRef("animations",Z);else if(Z instanceof K0)this.addRef("accessors",Z);else if(Z instanceof FR)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 c6{static fromGraph(Z){return c6._GRAPH_DOCUMENTS.get(Z)||null}constructor(){this._graph=new pF,this._root=new W3(this._graph),this._logger=z5.DEFAULT_INSTANCE,c6._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 Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(Z){throw 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(($)=>$.extensionName===J)||new Z(this)}createScene(Z=""){return new K3(this._graph,Z)}createNode(Z=""){return new Jw(this._graph,Z)}createCamera(Z=""){return new I$(this._graph,Z)}createSkin(Z=""){return new cR(this._graph,Z)}createMesh(Z=""){return new NG(this._graph,Z)}createPrimitive(){return new g1(this._graph)}createPrimitiveTarget(Z=""){return new wR(this._graph,Z)}createMaterial(Z=""){return new K7(this._graph,Z)}createTexture(Z=""){return new _$(this._graph,Z)}createAnimation(Z=""){return new qR(this._graph,Z)}createAnimationChannel(Z=""){return new QZ(this._graph,Z)}createAnimationSampler(Z=""){return new AJ(this._graph,Z)}createAccessor(Z="",J=null){if(!J)J=this.getRoot().listBuffers()[0];return new K0(this._graph,Z).setBuffer(J)}createBuffer(Z=""){return new FR(this._graph,Z)}}c6._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 $=X,Y=$.target;if(Y instanceof O1&&Y.extensionName===this.extensionName){if($.type==="node:create")this._addExtensionProperty(Y);if($.type==="node:dispose")this._removeExtensionProperty(Y)}};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;class Ig{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 $=this.jsonDoc.json.samplers[X.sampler];if($.magFilter!==void 0)Z.setMagFilter($.magFilter);if($.minFilter!==void 0)Z.setMinFilter($.minFilter);if($.wrapS!==void 0)Z.setWrapS($.wrapS);if($.wrapT!==void 0)Z.setWrapT($.wrapT)}}var Pg={logger:z5.DEFAULT_INSTANCE,extensions:[],dependencies:{}},JU1=new Set([i.BUFFER,i.TEXTURE,i.MATERIAL,i.MESH,i.PRIMITIVE,i.NODE,i.SCENE]);class _g{static read(Z,J=Pg){let X=m6({},Pg,J),{json:$}=Z,Y=new c6().setLogger(X.logger);this.validate(Z,X);let Q=new Ig(Z),K=$.asset,W=Y.getRoot().getAsset();if(K.copyright)W.copyright=K.copyright;if(K.extras)W.extras=K.extras;if($.extras!==void 0)Y.getRoot().setExtras(m6({},$.extras));let G=$.extensionsUsed||[],z=$.extensionsRequired||[];X.extensions.sort((M,P)=>M.EXTENSION_NAME>P.EXTENSION_NAME?1:-1);for(let M of X.extensions)if(G.includes(M.EXTENSION_NAME)){let P=Y.createExtension(M).setRequired(z.includes(M.EXTENSION_NAME)),N=P.prereadTypes.filter((O)=>!JU1.has(O));if(N.length)X.logger.warn(`Preread hooks for some types (${N.join()}), requested by extension ${P.extensionName}, are unsupported. Please file an issue or a PR.`);for(let O of P.readDependencies)P.install(O,X.dependencies[O])}let v=$.buffers||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.BUFFER)).forEach((M)=>M.preread(Q,i.BUFFER)),Q.buffers=v.map((M)=>{let P=Y.createBuffer(M.name);if(M.extras)P.setExtras(M.extras);if(M.uri&&M.uri.indexOf("__")!==0)P.setURI(M.uri);return P});let H=$.bufferViews||[];Q.bufferViewBuffers=H.map((M,P)=>{if(!Q.bufferViews[P]){let N=Z.json.buffers[M.buffer],O=N.uri?Z.resources[N.uri]:Z.resources[E$],k=M.byteOffset||0;Q.bufferViews[P]=E0.toView(O,k,M.byteLength)}return Q.buffers[M.buffer]});let V=$.accessors||[];Q.accessors=V.map((M)=>{let P=Q.bufferViewBuffers[M.bufferView],N=Y.createAccessor(M.name,P).setType(M.type);if(M.extras)N.setExtras(M.extras);if(M.normalized!==void 0)N.setNormalized(M.normalized);if(M.bufferView===void 0)return N;return N.setArray(sF(M,Q)),N});let q=$.images||[],F=$.textures||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.TEXTURE)).forEach((M)=>M.preread(Q,i.TEXTURE)),Q.textures=q.map((M)=>{let P=Y.createTexture(M.name);if(M.extras)P.setExtras(M.extras);if(M.bufferView!==void 0){let N=$.bufferViews[M.bufferView],O=Z.json.buffers[N.buffer],k=O.uri?Z.resources[O.uri]:Z.resources[E$],E=N.byteOffset||0,S=N.byteLength,f=k.slice(E,E+S);P.setImage(f)}else if(M.uri!==void 0){if(P.setImage(Z.resources[M.uri]),M.uri.indexOf("__")!==0)P.setURI(M.uri)}if(M.mimeType!==void 0)P.setMimeType(M.mimeType);else if(M.uri){let N=YZ.extension(M.uri);P.setMimeType(_5.extensionToMimeType(N))}return P}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.MATERIAL)).forEach((M)=>M.preread(Q,i.MATERIAL));let w=$.materials||[];Q.materials=w.map((M)=>{let P=Y.createMaterial(M.name);if(M.extras)P.setExtras(M.extras);if(M.alphaMode!==void 0)P.setAlphaMode(M.alphaMode);if(M.alphaCutoff!==void 0)P.setAlphaCutoff(M.alphaCutoff);if(M.doubleSided!==void 0)P.setDoubleSided(M.doubleSided);let N=M.pbrMetallicRoughness||{};if(N.baseColorFactor!==void 0)P.setBaseColorFactor(N.baseColorFactor);if(M.emissiveFactor!==void 0)P.setEmissiveFactor(M.emissiveFactor);if(N.metallicFactor!==void 0)P.setMetallicFactor(N.metallicFactor);if(N.roughnessFactor!==void 0)P.setRoughnessFactor(N.roughnessFactor);if(N.baseColorTexture!==void 0){let O=N.baseColorTexture,k=Q.textures[F[O.index].source];P.setBaseColorTexture(k),Q.setTextureInfo(P.getBaseColorTextureInfo(),O)}if(M.emissiveTexture!==void 0){let O=M.emissiveTexture,k=Q.textures[F[O.index].source];P.setEmissiveTexture(k),Q.setTextureInfo(P.getEmissiveTextureInfo(),O)}if(M.normalTexture!==void 0){let O=M.normalTexture,k=Q.textures[F[O.index].source];if(P.setNormalTexture(k),Q.setTextureInfo(P.getNormalTextureInfo(),O),M.normalTexture.scale!==void 0)P.setNormalScale(M.normalTexture.scale)}if(M.occlusionTexture!==void 0){let O=M.occlusionTexture,k=Q.textures[F[O.index].source];if(P.setOcclusionTexture(k),Q.setTextureInfo(P.getOcclusionTextureInfo(),O),M.occlusionTexture.strength!==void 0)P.setOcclusionStrength(M.occlusionTexture.strength)}if(N.metallicRoughnessTexture!==void 0){let O=N.metallicRoughnessTexture,k=Q.textures[F[O.index].source];P.setMetallicRoughnessTexture(k),Q.setTextureInfo(P.getMetallicRoughnessTextureInfo(),O)}return P}),Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.MESH)).forEach((M)=>M.preread(Q,i.MESH));let c=$.meshes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.PRIMITIVE)).forEach((M)=>M.preread(Q,i.PRIMITIVE)),Q.meshes=c.map((M)=>{let P=Y.createMesh(M.name);if(M.extras)P.setExtras(M.extras);if(M.weights!==void 0)P.setWeights(M.weights);return(M.primitives||[]).forEach((O)=>{let k=Y.createPrimitive();if(O.extras)k.setExtras(O.extras);if(O.material!==void 0)k.setMaterial(Q.materials[O.material]);if(O.mode!==void 0)k.setMode(O.mode);for(let[f,C]of Object.entries(O.attributes||{}))k.setAttribute(f,Q.accessors[C]);if(O.indices!==void 0)k.setIndices(Q.accessors[O.indices]);let E=M.extras&&M.extras.targetNames||[];(O.targets||[]).forEach((f,C)=>{let h=E[C]||C.toString(),_=Y.createPrimitiveTarget(h);for(let[a,s]of Object.entries(f))_.setAttribute(a,Q.accessors[s]);k.addTarget(_)}),P.addPrimitive(k)}),P});let x=$.cameras||[];Q.cameras=x.map((M)=>{let P=Y.createCamera(M.name).setType(M.type);if(M.extras)P.setExtras(M.extras);if(M.type===I$.Type.PERSPECTIVE){let N=M.perspective;if(P.setYFov(N.yfov),P.setZNear(N.znear),N.zfar!==void 0)P.setZFar(N.zfar);if(N.aspectRatio!==void 0)P.setAspectRatio(N.aspectRatio)}else{let N=M.orthographic;P.setZNear(N.znear).setZFar(N.zfar).setXMag(N.xmag).setYMag(N.ymag)}return P});let j=$.nodes||[];Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.NODE)).forEach((M)=>M.preread(Q,i.NODE)),Q.nodes=j.map((M)=>{let P=Y.createNode(M.name);if(M.extras)P.setExtras(M.extras);if(M.translation!==void 0)P.setTranslation(M.translation);if(M.rotation!==void 0)P.setRotation(M.rotation);if(M.scale!==void 0)P.setScale(M.scale);if(M.matrix!==void 0){let N=[0,0,0],O=[0,0,0,1],k=[1,1,1];I0.decompose(M.matrix,N,O,k),P.setTranslation(N),P.setRotation(O),P.setScale(k)}if(M.weights!==void 0)P.setWeights(M.weights);return P});let B=$.skins||[];Q.skins=B.map((M)=>{let P=Y.createSkin(M.name);if(M.extras)P.setExtras(M.extras);if(M.inverseBindMatrices!==void 0)P.setInverseBindMatrices(Q.accessors[M.inverseBindMatrices]);if(M.skeleton!==void 0)P.setSkeleton(Q.nodes[M.skeleton]);for(let N of M.joints)P.addJoint(Q.nodes[N]);return P}),j.map((M,P)=>{let N=Q.nodes[P];if((M.children||[]).forEach((k)=>N.addChild(Q.nodes[k])),M.mesh!==void 0)N.setMesh(Q.meshes[M.mesh]);if(M.camera!==void 0)N.setCamera(Q.cameras[M.camera]);if(M.skin!==void 0)N.setSkin(Q.skins[M.skin])});let L=$.animations||[];Q.animations=L.map((M)=>{let P=Y.createAnimation(M.name);if(M.extras)P.setExtras(M.extras);let O=(M.samplers||[]).map((E)=>{let S=Y.createAnimationSampler().setInput(Q.accessors[E.input]).setOutput(Q.accessors[E.output]).setInterpolation(E.interpolation||AJ.Interpolation.LINEAR);if(E.extras)S.setExtras(E.extras);return P.addSampler(S),S});return(M.channels||[]).forEach((E)=>{let S=Y.createAnimationChannel().setSampler(O[E.sampler]).setTargetPath(E.target.path);if(E.target.node!==void 0)S.setTargetNode(Q.nodes[E.target.node]);if(E.extras)S.setExtras(E.extras);P.addChannel(S)}),P});let R=$.scenes||[];if(Y.getRoot().listExtensionsUsed().filter((M)=>M.prereadTypes.includes(i.SCENE)).forEach((M)=>M.preread(Q,i.SCENE)),Q.scenes=R.map((M)=>{let P=Y.createScene(M.name);if(M.extras)P.setExtras(M.extras);return(M.nodes||[]).map((O)=>Q.nodes[O]).forEach((O)=>P.addChild(O)),P}),$.scene!==void 0)Y.getRoot().setDefaultScene(Q.scenes[$.scene]);return Y.getRoot().listExtensionsUsed().forEach((M)=>M.read(Q)),V.forEach((M,P)=>{let N=Q.accessors[P],O=!!M.sparse,k=!M.bufferView&&!N.getArray();if(O||k)N.setSparse(!0).setArray($U1(M,Q))}),Y}static validate(Z,J){let X=Z.json;if(X.asset.version!=="2.0")throw Error(`Unsupported glTF version, "${X.asset.version}".`);if(X.extensionsRequired){for(let $ of X.extensionsRequired)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))throw Error(`Missing required extension, "${$}".`)}if(X.extensionsUsed){for(let $ of X.extensionsUsed)if(!J.extensions.find((Y)=>Y.EXTENSION_NAME===$))J.logger.warn(`Missing optional extension, "${$}".`)}}}function XU1(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=bJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=Z.byteOffset||0,z=new Q(Z.count*K),v=new DataView($.buffer,$.byteOffset,$.byteLength),H=Y.byteStride;for(let V=0;V<Z.count;V++)for(let q=0;q<K;q++){let F=G+V*H+q*W,w;switch(Z.componentType){case K0.ComponentType.FLOAT:w=v.getFloat32(F,!0);break;case K0.ComponentType.UNSIGNED_INT:w=v.getUint32(F,!0);break;case K0.ComponentType.UNSIGNED_SHORT:w=v.getUint16(F,!0);break;case K0.ComponentType.UNSIGNED_BYTE:w=v.getUint8(F);break;case K0.ComponentType.SHORT:w=v.getInt16(F,!0);break;case K0.ComponentType.BYTE:w=v.getInt8(F);break;default:throw Error(`Unexpected componentType "${Z.componentType}".`)}z[V*K+q]=w}return z}function sF(Z,J){let X=J.jsonDoc,$=J.bufferViews[Z.bufferView],Y=X.json.bufferViews[Z.bufferView],Q=bJ[Z.componentType],K=K0.getElementSize(Z.type),W=Q.BYTES_PER_ELEMENT,G=K*W;if(Y.byteStride!==void 0&&Y.byteStride!==G)return XU1(Z,J);let z=$.byteOffset+(Z.byteOffset||0),v=Z.count*K*W;return new Q($.buffer.slice(z,z+v))}function $U1(Z,J){let X=bJ[Z.componentType],$=K0.getElementSize(Z.type),Y;if(Z.bufferView!==void 0)Y=sF(Z,J);else Y=new X(Z.count*$);let Q=Z.sparse;if(!Q)return Y;let K=Q.count,W=m6({},Z,Q.indices,{count:K,type:"SCALAR"}),G=m6({},Z,Q.values,{count:K}),z=sF(W,J),v=sF(G,J);for(let H=0;H<W.count;H++)for(let V=0;V<$;V++)Y[z[H]*$+V]=v[H*$+V];return Y}var RG;(function(Z){Z[Z.ARRAY_BUFFER=34962]="ARRAY_BUFFER",Z[Z.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(RG||(RG={}));class w4{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 $=Z.getRoot(),Y=$.listBuffers().length,Q=$.listTextures().length;this.bufferURIGenerator=new VR(Y>1,()=>X.basename||"buffer"),this.imageURIGenerator=new VR(Q>1,(K)=>YU1(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()},$=JSON.stringify(X);if(!this.samplerDefIndexMap.has($))this.samplerDefIndexMap.set($,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(X);let Y={source:this.imageIndexMap.get(Z),sampler:this.samplerDefIndexMap.get($)},Q=JSON.stringify(Y);if(!this.textureDefIndexMap.has(Q))this.textureDefIndexMap.set(Q,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(Y);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(($)=>$.getName()==="attributes"&&$.getAttributes().key==="POSITION"||$.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===$Z.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 $=_5.mimeTypeToExtension(X.getMimeType());Z.uri=this.imageURIGenerator.createURI(X,$),this.assignResourceURI(Z.uri,J,!1)}}assignResourceURI(Z,J,X){let $=this.jsonDoc.resources;if(!(Z in $)){$[Z]=J;return}if(J===$[Z]){this.logger.warn(`Duplicate resource URI, "${Z}".`);return}let Y=`Resource URI "${Z}" already assigned to different data.`;if(!X){this.logger.warn(Y);return}throw Error(Y)}getAccessorUsage(Z){let J=this._accessorUsageMap.get(Z);if(J)return J;if(Z.getSparse())return h5.SPARSE;for(let X of this._doc.getGraph().listParentEdges(Z)){let{usage:$}=X.getAttributes();if($)return $;if(X.getParent().propertyType!==i.ROOT)this.logger.warn(`Missing attribute ".usage" on edge, "${X.getName()}".`)}return h5.OTHER}addAccessorToUsageGroup(Z,J){let X=this._accessorUsageMap.get(Z);if(X&&X!==J)throw Error(`Accessor with usage "${X}" cannot be reused as "${J}".`);return this._accessorUsageMap.set(Z,J),this}}w4.BufferViewTarget=RG;w4.BufferViewUsage=h5;w4.USAGE_TO_TARGET={[h5.ARRAY_BUFFER]:RG.ARRAY_BUFFER,[h5.ELEMENT_ARRAY_BUFFER]:RG.ELEMENT_ARRAY_BUFFER};class VR{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 YU1(Z,J){let X=Z.getGraph().listParentEdges(J).find(($)=>$.getParent()!==Z.getRoot());return X?X.getName().replace(/texture$/i,""):""}var{BufferViewUsage:nF}=w4,{UNSIGNED_INT:QU1,UNSIGNED_SHORT:KU1,UNSIGNED_BYTE:WU1}=K0.ComponentType,GU1=new Set([i.ACCESSOR,i.BUFFER,i.MATERIAL,i.MESH]);class hg{static write(Z,J){let X=Z.getGraph(),$=Z.getRoot(),Y={asset:m6({generator:`glTF-Transform ${Og}`},$.getAsset()),extras:m6({},$.getExtras())},Q={json:Y,resources:{}},K=new w4(Z,Q,J),W=J.logger||z5.DEFAULT_INSTANCE,G=new Set(J.extensions.map((c)=>c.EXTENSION_NAME)),z=Z.getRoot().listExtensionsUsed().filter((c)=>G.has(c.extensionName)).sort((c,x)=>c.extensionName>x.extensionName?1:-1),v=Z.getRoot().listExtensionsRequired().filter((c)=>G.has(c.extensionName)).sort((c,x)=>c.extensionName>x.extensionName?1:-1);if(z.length<Z.getRoot().listExtensionsUsed().length)W.warn("Some extensions were not registered for I/O, and will not be written.");for(let c of z){let x=c.prewriteTypes.filter((j)=>!GU1.has(j));if(x.length)W.warn(`Prewrite hooks for some types (${x.join()}), requested by extension ${c.extensionName}, are unsupported. Please file an issue or a PR.`);for(let j of c.writeDependencies)c.install(j,J.dependencies[j])}function H(c,x,j,B){let L=[],R=0;for(let N of c){let O=K.createAccessorDef(N);O.bufferView=Y.bufferViews.length;let k=N.getArray(),E=E0.pad(E0.toView(k));O.byteOffset=R,R+=E.byteLength,L.push(E),K.accessorIndexMap.set(N,Y.accessors.length),Y.accessors.push(O)}let M=E0.concat(L),P={buffer:x,byteOffset:j,byteLength:M.byteLength};if(B)P.target=B;return Y.bufferViews.push(P),{buffers:L,byteLength:R}}function V(c,x,j){let B=c[0].getCount(),L=0;for(let O of c){let k=K.createAccessorDef(O);k.bufferView=Y.bufferViews.length,k.byteOffset=L;let E=O.getElementSize(),S=O.getComponentSize();L+=E0.padNumber(E*S),K.accessorIndexMap.set(O,Y.accessors.length),Y.accessors.push(k)}let R=B*L,M=new ArrayBuffer(R),P=new DataView(M);for(let O=0;O<B;O++){let k=0;for(let E of c){let S=E.getElementSize(),f=E.getComponentSize(),C=E.getComponentType(),h=E.getArray();for(let _=0;_<S;_++){let a=O*L+k+_*f,s=h[O*S+_];switch(C){case K0.ComponentType.FLOAT:P.setFloat32(a,s,!0);break;case K0.ComponentType.BYTE:P.setInt8(a,s);break;case K0.ComponentType.SHORT:P.setInt16(a,s,!0);break;case K0.ComponentType.UNSIGNED_BYTE:P.setUint8(a,s);break;case K0.ComponentType.UNSIGNED_SHORT:P.setUint16(a,s,!0);break;case K0.ComponentType.UNSIGNED_INT:P.setUint32(a,s,!0);break;default:throw Error("Unexpected component type: "+C)}}k+=E0.padNumber(S*f)}}let N={buffer:x,byteOffset:j,byteLength:R,byteStride:L,target:w4.BufferViewTarget.ARRAY_BUFFER};return Y.bufferViews.push(N),{byteLength:R,buffers:[new Uint8Array(M)]}}function q(c,x,j){let B=[],L=0,R=new Map,M=-1/0,P=!1;for(let C of c){let h=K.createAccessorDef(C);Y.accessors.push(h),K.accessorIndexMap.set(C,Y.accessors.length-1);let _=[],a=[],s=[],Z0=Array(C.getElementSize()).fill(0);for(let m0=0,N1=C.getCount();m0<N1;m0++){if(C.getElement(m0,s),I0.eq(s,Z0,0))continue;M=Math.max(m0,M),_.push(m0);for(let s0=0;s0<s.length;s0++)a.push(s[s0])}let o=_.length,M0={accessorDef:h,count:o};if(R.set(C,M0),o===0)continue;if(o>C.getCount()/2)P=!0;let R0=bJ[C.getComponentType()];M0.indices=_,M0.values=new R0(a)}if(!Number.isFinite(M))return{buffers:B,byteLength:L};if(P)W.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let N=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,O=M<255?WU1:M<65535?KU1:QU1,k={buffer:x,byteOffset:j+L,byteLength:0};for(let C of c){let h=R.get(C);if(h.count===0)continue;h.indicesByteOffset=k.byteLength;let _=E0.pad(E0.toView(new N(h.indices)));B.push(_),L+=_.byteLength,k.byteLength+=_.byteLength}Y.bufferViews.push(k);let E=Y.bufferViews.length-1,S={buffer:x,byteOffset:j+L,byteLength:0};for(let C of c){let h=R.get(C);if(h.count===0)continue;h.valuesByteOffset=S.byteLength;let _=E0.pad(E0.toView(h.values));B.push(_),L+=_.byteLength,S.byteLength+=_.byteLength}Y.bufferViews.push(S);let f=Y.bufferViews.length-1;for(let C of c){let h=R.get(C);if(h.count===0)continue;h.accessorDef.sparse={count:h.count,indices:{bufferView:E,byteOffset:h.indicesByteOffset,componentType:O},values:{bufferView:f,byteOffset:h.valuesByteOffset}}}return{buffers:B,byteLength:L}}if(Y.accessors=[],Y.bufferViews=[],Y.samplers=[],Y.textures=[],Y.images=$.listTextures().map((c,x)=>{let j=K.createPropertyDef(c);if(c.getMimeType())j.mimeType=c.getMimeType();let B=c.getImage();if(B)K.createImageData(j,B,c);return K.imageIndexMap.set(c,x),j}),z.filter((c)=>c.prewriteTypes.includes(i.ACCESSOR)).forEach((c)=>c.prewrite(K,i.ACCESSOR)),$.listAccessors().forEach((c)=>{let{accessorUsageGroupedByParent:x,accessorParents:j}=K;if(K.accessorIndexMap.has(c))return;let B=K.getAccessorUsage(c);if(K.addAccessorToUsageGroup(c,B),x.has(B)){let L=X.listParents(c).find((R)=>R.propertyType!==i.ROOT);j.set(c,L)}}),z.filter((c)=>c.prewriteTypes.includes(i.BUFFER)).forEach((c)=>c.prewrite(K,i.BUFFER)),($.listAccessors().length>0||K.otherBufferViews.size>0||$.listTextures().length>0&&J.format===$Z.GLB)&&$.listBuffers().length===0)throw Error("Buffer required for Document resources, but none was found.");if(Y.buffers=[],$.listBuffers().forEach((c,x)=>{let j=K.createPropertyDef(c),B=K.accessorUsageGroupedByParent,L=c.listParents().filter((S)=>S instanceof K0),R=new Set(L.map((S)=>K.accessorParents.get(S))),M=new Map(Array.from(R).map((S,f)=>[S,f])),P={};for(let S of L){var N;if(K.accessorIndexMap.has(S))continue;let f=K.getAccessorUsage(S),C=f;if(B.has(f)){let h=K.accessorParents.get(S);C+=`:${M.get(h)}`}P[N=C]||(P[N]={usage:f,accessors:[]}),P[C].accessors.push(S)}let O=[],k=Y.buffers.length,E=0;for(let{usage:S,accessors:f}of Object.values(P))if(S===nF.ARRAY_BUFFER&&J.vertexLayout===oF.INTERLEAVED){let C=V(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}else if(S===nF.ARRAY_BUFFER)for(let C of f){let h=V([C],k,E);E+=h.byteLength;for(let _ of h.buffers)O.push(_)}else if(S===nF.SPARSE){let C=q(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}else if(S===nF.ELEMENT_ARRAY_BUFFER){let C=w4.BufferViewTarget.ELEMENT_ARRAY_BUFFER,h=H(f,k,E,C);E+=h.byteLength;for(let _ of h.buffers)O.push(_)}else{let C=H(f,k,E);E+=C.byteLength;for(let h of C.buffers)O.push(h)}if(K.imageBufferViews.length&&x===0){for(let S=0;S<K.imageBufferViews.length;S++)if(Y.bufferViews[Y.images[S].bufferView].byteOffset=E,E+=K.imageBufferViews[S].byteLength,O.push(K.imageBufferViews[S]),E%8){let f=8-E%8;E+=f,O.push(new Uint8Array(f))}}if(K.otherBufferViews.has(c))for(let S of K.otherBufferViews.get(c))Y.bufferViews.push({buffer:k,byteOffset:E,byteLength:S.byteLength}),K.otherBufferViewsIndexMap.set(S,Y.bufferViews.length-1),E+=S.byteLength,O.push(S);if(E){let S;if(J.format===$Z.GLB)S=E$;else S=K.bufferURIGenerator.createURI(c,"bin"),j.uri=S;j.byteLength=E,K.assignResourceURI(S,E0.concat(O),!0)}Y.buffers.push(j),K.bufferIndexMap.set(c,x)}),$.listAccessors().find((c)=>!c.getBuffer()))W.warn("Skipped writing one or more Accessors: no Buffer assigned.");z.filter((c)=>c.prewriteTypes.includes(i.MATERIAL)).forEach((c)=>c.prewrite(K,i.MATERIAL)),Y.materials=$.listMaterials().map((c,x)=>{let j=K.createPropertyDef(c);if(c.getAlphaMode()!==K7.AlphaMode.OPAQUE)j.alphaMode=c.getAlphaMode();if(c.getAlphaMode()===K7.AlphaMode.MASK)j.alphaCutoff=c.getAlphaCutoff();if(c.getDoubleSided())j.doubleSided=!0;if(j.pbrMetallicRoughness={},!I0.eq(c.getBaseColorFactor(),[1,1,1,1]))j.pbrMetallicRoughness.baseColorFactor=c.getBaseColorFactor();if(!I0.eq(c.getEmissiveFactor(),[0,0,0]))j.emissiveFactor=c.getEmissiveFactor();if(c.getRoughnessFactor()!==1)j.pbrMetallicRoughness.roughnessFactor=c.getRoughnessFactor();if(c.getMetallicFactor()!==1)j.pbrMetallicRoughness.metallicFactor=c.getMetallicFactor();if(c.getBaseColorTexture()){let B=c.getBaseColorTexture(),L=c.getBaseColorTextureInfo();j.pbrMetallicRoughness.baseColorTexture=K.createTextureInfoDef(B,L)}if(c.getEmissiveTexture()){let B=c.getEmissiveTexture(),L=c.getEmissiveTextureInfo();j.emissiveTexture=K.createTextureInfoDef(B,L)}if(c.getNormalTexture()){let B=c.getNormalTexture(),L=c.getNormalTextureInfo(),R=K.createTextureInfoDef(B,L);if(c.getNormalScale()!==1)R.scale=c.getNormalScale();j.normalTexture=R}if(c.getOcclusionTexture()){let B=c.getOcclusionTexture(),L=c.getOcclusionTextureInfo(),R=K.createTextureInfoDef(B,L);if(c.getOcclusionStrength()!==1)R.strength=c.getOcclusionStrength();j.occlusionTexture=R}if(c.getMetallicRoughnessTexture()){let B=c.getMetallicRoughnessTexture(),L=c.getMetallicRoughnessTextureInfo();j.pbrMetallicRoughness.metallicRoughnessTexture=K.createTextureInfoDef(B,L)}return K.materialIndexMap.set(c,x),j}),z.filter((c)=>c.prewriteTypes.includes(i.MESH)).forEach((c)=>c.prewrite(K,i.MESH)),Y.meshes=$.listMeshes().map((c,x)=>{let j=K.createPropertyDef(c),B=null;if(j.primitives=c.listPrimitives().map((L)=>{let R={attributes:{}};R.mode=L.getMode();let M=L.getMaterial();if(M)R.material=K.materialIndexMap.get(M);if(Object.keys(L.getExtras()).length)R.extras=L.getExtras();let P=L.getIndices();if(P)R.indices=K.accessorIndexMap.get(P);for(let N of L.listSemantics())R.attributes[N]=K.accessorIndexMap.get(L.getAttribute(N));for(let N of L.listTargets()){let O={};for(let k of N.listSemantics())O[k]=K.accessorIndexMap.get(N.getAttribute(k));R.targets=R.targets||[],R.targets.push(O)}if(L.listTargets().length&&!B)B=L.listTargets().map((N)=>N.getName());return R}),c.getWeights().length)j.weights=c.getWeights();if(B)j.extras=j.extras||{},j.extras.targetNames=B;return K.meshIndexMap.set(c,x),j}),Y.cameras=$.listCameras().map((c,x)=>{let j=K.createPropertyDef(c);if(j.type=c.getType(),j.type===I$.Type.PERSPECTIVE){j.perspective={znear:c.getZNear(),zfar:c.getZFar(),yfov:c.getYFov()};let B=c.getAspectRatio();if(B!==null)j.perspective.aspectRatio=B}else j.orthographic={znear:c.getZNear(),zfar:c.getZFar(),xmag:c.getXMag(),ymag:c.getYMag()};return K.cameraIndexMap.set(c,x),j}),Y.nodes=$.listNodes().map((c,x)=>{let j=K.createPropertyDef(c);if(!I0.eq(c.getTranslation(),[0,0,0]))j.translation=c.getTranslation();if(!I0.eq(c.getRotation(),[0,0,0,1]))j.rotation=c.getRotation();if(!I0.eq(c.getScale(),[1,1,1]))j.scale=c.getScale();if(c.getWeights().length)j.weights=c.getWeights();return K.nodeIndexMap.set(c,x),j}),Y.skins=$.listSkins().map((c,x)=>{let j=K.createPropertyDef(c),B=c.getInverseBindMatrices();if(B)j.inverseBindMatrices=K.accessorIndexMap.get(B);let L=c.getSkeleton();if(L)j.skeleton=K.nodeIndexMap.get(L);return j.joints=c.listJoints().map((R)=>K.nodeIndexMap.get(R)),K.skinIndexMap.set(c,x),j}),$.listNodes().forEach((c,x)=>{let j=Y.nodes[x],B=c.getMesh();if(B)j.mesh=K.meshIndexMap.get(B);let L=c.getCamera();if(L)j.camera=K.cameraIndexMap.get(L);let R=c.getSkin();if(R)j.skin=K.skinIndexMap.get(R);if(c.listChildren().length>0)j.children=c.listChildren().map((M)=>K.nodeIndexMap.get(M))}),Y.animations=$.listAnimations().map((c,x)=>{let j=K.createPropertyDef(c),B=new Map;return j.samplers=c.listSamplers().map((L,R)=>{let M=K.createPropertyDef(L);return M.input=K.accessorIndexMap.get(L.getInput()),M.output=K.accessorIndexMap.get(L.getOutput()),M.interpolation=L.getInterpolation(),B.set(L,R),M}),j.channels=c.listChannels().map((L)=>{let R=K.createPropertyDef(L);return R.sampler=B.get(L.getSampler()),R.target={node:K.nodeIndexMap.get(L.getTargetNode()),path:L.getTargetPath()},R}),K.animationIndexMap.set(c,x),j}),Y.scenes=$.listScenes().map((c,x)=>{let j=K.createPropertyDef(c);return j.nodes=c.listChildren().map((B)=>K.nodeIndexMap.get(B)),K.sceneIndexMap.set(c,x),j});let w=$.getDefaultScene();if(w)Y.scene=$.listScenes().indexOf(w);return Y.extensionsUsed=z.map((c)=>c.extensionName),Y.extensionsRequired=v.map((c)=>c.extensionName),z.forEach((c)=>c.write(K)),zU1(Y),Q}}function zU1(Z){let J=[];for(let X in Z){let $=Z[X];if(Array.isArray($)&&$.length===0)J.push(X);else if($===null||$==="")J.push(X);else if($&&typeof $==="object"&&Object.keys($).length===0)J.push(X)}for(let X of J)delete Z[X]}var tF;(function(Z){Z[Z.JSON=1313821514]="JSON",Z[Z.BIN=5130562]="BIN"})(tF||(tF={}));class Sg{constructor(){this._logger=z5.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=oF.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=Ng(J)?this._binaryToJSON(J):{json:JSON.parse(E0.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),_g.read(Z,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(Z){let J=this._binaryToJSON(E0.assertView(Z));this._readResourcesInternal(J);let X=J.json;if(X.buffers&&X.buffers.some(($)=>vU1(J,$)))throw Error("Cannot resolve external buffers with binaryToJSON().");else if(X.images&&X.images.some(($)=>VU1(J,$)))throw Error("Cannot resolve external images with binaryToJSON().");return J}async readBinary(Z){return this.readJSON(await this.binaryToJSON(E0.assertView(Z)))}async writeJSON(Z,J={}){if(J.format===$Z.GLB&&Z.getRoot().listBuffers().length>1)throw Error("GLB must have 0–1 buffers.");return hg.write(Z,{format:J.format||$Z.GLTF,basename:J.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:m6({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(Z){let{json:J,resources:X}=await this.writeJSON(Z,{format:$Z.GLB}),$=new Uint32Array([1179937895,2,12]),Y=JSON.stringify(J),Q=E0.pad(E0.encodeText(Y),32),K=E0.toView(new Uint32Array([Q.byteLength,1313821514])),W=E0.concat([K,Q]);$[$.length-1]+=W.byteLength;let G=Object.values(X)[0];if(!G||!G.byteLength)return E0.concat([E0.toView($),W]);let z=E0.pad(G,0),v=E0.toView(new Uint32Array([z.byteLength,5130562])),H=E0.concat([v,z]);return $[$.length-1]+=H.byteLength,E0.concat([E0.toView($),W,H])}async _readResourcesExternal(Z,J){var X=this;let $=Z.json.images||[],Y=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(Y){if(!Y.uri)return;if(Y.uri in Z.resources){E0.assertView(Z.resources[Y.uri]);return}if(Y.uri.match(/data:/)){let Q=`__${Eg()}.${YZ.extension(Y.uri)}`;Z.resources[Q]=E0.createBufferFromDataURI(Y.uri),Y.uri=Q}}(Z.json.images||[]).forEach((Y)=>{if(Y.bufferView===void 0&&Y.uri===void 0)throw Error("Missing resource URI or buffer view.");J(Y)}),(Z.json.buffers||[]).forEach(J)}_copyJSON(Z){let{images:J,buffers:X}=Z.json;if(Z={json:m6({},Z.json),resources:m6({},Z.resources)},J)Z.json.images=J.map(($)=>m6({},$));if(X)Z.json.buffers=X.map(($)=>m6({},$));return Z}_binaryToJSON(Z){if(!Ng(Z))throw Error("Invalid glTF 2.0 binary.");let J=new Uint32Array(Z.buffer,Z.byteOffset+12,2);if(J[1]!==tF.JSON)throw Error("Missing required GLB JSON chunk.");let X=20,$=J[0],Y=E0.decodeText(E0.toView(Z,X,$)),Q=JSON.parse(Y),K=X+$;if(Z.byteLength<=K)return{json:Q,resources:{}};let W=new Uint32Array(Z.buffer,Z.byteOffset+K,2);if(W[1]!==tF.BIN)return{json:Q,resources:{}};let G=W[0],z=E0.toView(Z,K+8,G);return{json:Q,resources:{[E$]:z}}}}function vU1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)}function VU1(Z,J){return J.uri!==void 0&&!(J.uri in Z.resources)&&J.bufferView===void 0}function Ng(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 xR extends Sg{constructor(Z=null,J=F4.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 Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=Z,this}async readURI(Z,J){if(await this.init(),F4.isAbsoluteURL(Z)){if(!this._fetchEnabled||!this._fetch)throw 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(F4.isAbsoluteURL(Z)||F4.isAbsoluteURL(J))return F4.resolve(Z,J);return this._path.resolve(Z,decodeURIComponent(J))}dirname(Z){if(F4.isAbsoluteURL(Z))return F4.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:$,resources:Y}=await this.writeJSON(J,{format:$Z.GLTF,basename:YZ.basename(Z)}),{_fs:Q,_path:K}=this,W=K.dirname(Z),G=JSON.stringify($,null,2);await Q.writeFile(Z,G),this.lastWriteBytes+=G.length;for(let z of HU1(Object.keys(Y),10))await Promise.all(z.map(async function(v){if(F4.isAbsoluteURL(v)){if(F4.extension(v)==="bin")throw Error(`Cannot write buffer to path "${v}".`);return}let H=K.join(W,decodeURIComponent(v));await Q.mkdir(K.dirname(H),{recursive:!0}),await Q.writeFile(H,Y[v]),X.lastWriteBytes+=Y[v].byteLength}))}async _writeGLB(Z,J){let X=await this.writeBinary(J);await this._fs.writeFile(Z,X),this.lastWriteBytes=X.byteLength}}function HU1(Z,J){let X=[];for(let $=0,Y=Z.length;$<Y;$+=J){let Q=[];for(let K=0;K<J&&$+K<Y;K++)Q.push(Z[$+K]);X.push(Q)}return X}var In=t(UR(),1),_n=t(cn(),1),QD1=t(En(),1);async function KD1(Z,J){if(!(Z instanceof Uint8Array))throw Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");let{data:X,info:$}=await _n.default(Z).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return In.default(new Uint8Array(X),[$.width,$.height,4],[4,4*$.width|0,1],0)}async function hn(Z,J){return KD1(Z)}var bn=163,An=166;function WD1(){return{vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,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 U3{constructor(Z,J,X,$){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(Z.buffer,Z.byteOffset+J,X),this._littleEndian=$,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,$=0;while(this._dataView.getUint8(this._offset)!==J&&$<Z)$++,this._offset++;if($<Z)this._offset++;return new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+X,$)}}var lN6=new Uint8Array([0]),p6=[171,75,84,88,32,50,48,187,13,10,26,10];function Sn(Z){return new TextDecoder().decode(Z)}function Mw(Z){let J=new Uint8Array(Z.buffer,Z.byteOffset,p6.length);if(J[0]!==p6[0]||J[1]!==p6[1]||J[2]!==p6[2]||J[3]!==p6[3]||J[4]!==p6[4]||J[5]!==p6[5]||J[6]!==p6[6]||J[7]!==p6[7]||J[8]!==p6[8]||J[9]!==p6[9]||J[10]!==p6[10]||J[11]!==p6[11])throw Error("Missing KTX 2.0 identifier.");let X=WD1(),$=17*Uint32Array.BYTES_PER_ELEMENT,Y=new U3(Z,p6.length,$,!0);X.vkFormat=Y._nextUint32(),X.typeSize=Y._nextUint32(),X.pixelWidth=Y._nextUint32(),X.pixelHeight=Y._nextUint32(),X.pixelDepth=Y._nextUint32(),X.layerCount=Y._nextUint32(),X.faceCount=Y._nextUint32(),X.levelCount=Y._nextUint32(),X.supercompressionScheme=Y._nextUint32();let Q=Y._nextUint32(),K=Y._nextUint32(),W=Y._nextUint32(),G=Y._nextUint32(),z=Y._nextUint64(),v=Y._nextUint64(),H=Math.max(X.levelCount,1)*3*8,V=new U3(Z,p6.length+$,H,!0);for(let O8=0,q6=Math.max(X.levelCount,1);O8<q6;O8++)X.levels.push({levelData:new Uint8Array(Z.buffer,Z.byteOffset+V._nextUint64(),V._nextUint64()),uncompressedByteLength:V._nextUint64()});let q=new U3(Z,Q,K,!0);q._skip(4);let F=q._nextUint16(),w=q._nextUint16(),c=q._nextUint16(),x=q._nextUint16(),j=q._nextUint8(),B=q._nextUint8(),L=q._nextUint8(),R=q._nextUint8(),M=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],P=[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],O={vendorId:F,descriptorType:w,versionNumber:c,colorModel:j,colorPrimaries:B,transferFunction:L,flags:R,texelBlockDimension:M,bytesPlane:P,samples:[]},k=6,E=4,S=(x/4-k)/E;for(let O8=0;O8<S;O8++){let q6={bitOffset:q._nextUint16(),bitLength:q._nextUint8(),channelType:q._nextUint8(),samplePosition:[q._nextUint8(),q._nextUint8(),q._nextUint8(),q._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};if(q6.channelType&64)q6.sampleLower=q._nextInt32(),q6.sampleUpper=q._nextInt32();else q6.sampleLower=q._nextUint32(),q6.sampleUpper=q._nextUint32();O.samples[O8]=q6}X.dataFormatDescriptor.length=0,X.dataFormatDescriptor.push(O);let f=new U3(Z,W,G,!0);while(f._offset<G){let O8=f._nextUint32(),q6=f._scan(O8),kH=Sn(q6);if(X.keyValue[kH]=f._nextUint8Array(O8-q6.byteLength-1),kH.match(/^ktx/i)){let LA=Sn(X.keyValue[kH]);X.keyValue[kH]=LA.substring(0,LA.lastIndexOf("\x00"))}let MG1=O8%4?4-O8%4:0;f._skip(MG1)}if(v<=0)return X;let C=new U3(Z,z,v,!0),h=C._nextUint16(),_=C._nextUint16(),a=C._nextUint32(),s=C._nextUint32(),Z0=C._nextUint32(),o=C._nextUint32(),M0=[];for(let O8=0,q6=Math.max(X.levelCount,1);O8<q6;O8++)M0.push({imageFlags:C._nextUint32(),rgbSliceByteOffset:C._nextUint32(),rgbSliceByteLength:C._nextUint32(),alphaSliceByteOffset:C._nextUint32(),alphaSliceByteLength:C._nextUint32()});let R0=z+C._offset,m0=R0+a,N1=m0+s,s0=N1+Z0,j1=new Uint8Array(Z.buffer,Z.byteOffset+R0,a),K4=new Uint8Array(Z.buffer,Z.byteOffset+m0,s),PJ=new Uint8Array(Z.buffer,Z.byteOffset+N1,Z0),IQ=new Uint8Array(Z.buffer,Z.byteOffset+s0,o);return X.globalData={endpointCount:h,selectorCount:_,imageDescs:M0,endpointsData:j1,selectorsData:K4,tablesData:PJ,extendedData:IQ},X}var GZ="EXT_mesh_gpu_instancing",X6="EXT_meshopt_compression",bG="EXT_texture_webp",AG="EXT_texture_avif",s1="KHR_draco_mesh_compression",U4="KHR_lights_punctual",zZ="KHR_materials_anisotropy",vZ="KHR_materials_clearcoat",VZ="KHR_materials_diffuse_transmission",HZ="KHR_materials_dispersion",qZ="KHR_materials_emissive_strength",FZ="KHR_materials_ior",wZ="KHR_materials_iridescence",cZ="KHR_materials_pbrSpecularGlossiness",xZ="KHR_materials_sheen",UZ="KHR_materials_specular",jZ="KHR_materials_transmission",iJ="KHR_materials_unlit",BZ="KHR_materials_volume",U6="KHR_materials_variants",tn="KHR_mesh_quantization",mG="KHR_texture_basisu",LZ="KHR_texture_transform",j4="KHR_xmp_json_ld",gR="INSTANCE_ATTRIBUTE";class aR extends O1{init(){this.extensionName=GZ,this.propertyType="InstancedMesh",this.parentTypes=[i.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new A6})}getAttribute(Z){return this.getRefMap("attributes",Z)}setAttribute(Z,J){return this.setRefMap("attributes",Z,J,{usage:gR})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}aR.EXTENSION_NAME=GZ;class Nw extends T1{constructor(...Z){super(...Z);this.extensionName=GZ,this.provideTypes=[i.NODE],this.prewriteTypes=[i.ACCESSOR]}createInstancedMesh(){return new aR(this.document.getGraph())}read(Z){return(Z.jsonDoc.json.nodes||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[GZ])return;let Q=$.extensions[GZ],K=this.createInstancedMesh();for(let W in Q.attributes)K.setAttribute(W,Z.accessors[Q.attributes[W]]);Z.nodes[Y].setExtension(GZ,K)}),this}prewrite(Z){Z.accessorUsageGroupedByParent.add(gR);for(let J of this.properties)for(let X of J.listAttributes())Z.addAccessorToUsageGroup(X,gR);return this}write(Z){let J=Z.jsonDoc;return this.document.getRoot().listNodes().forEach((X)=>{let $=X.getExtension(GZ);if($){let Y=Z.nodeIndexMap.get(X),Q=J.json.nodes[Y],K={attributes:{}};$.listSemantics().forEach((W)=>{let G=$.getAttribute(W);K.attributes[W]=Z.accessorIndexMap.get(G)}),Q.extensions=Q.extensions||{},Q.extensions[GZ]=K}}),this}}Nw.EXTENSION_NAME=GZ;function DZ(){return DZ=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)({}).hasOwnProperty.call(X,$)&&(Z[$]=X[$])}return Z},DZ.apply(null,arguments)}var uG;(function(Z){Z.QUANTIZE="quantize",Z.FILTER="filter"})(uG||(uG={}));var j3;(function(Z){Z.ATTRIBUTES="ATTRIBUTES",Z.TRIANGLES="TRIANGLES",Z.INDICES="INDICES"})(j3||(j3={}));var $8;(function(Z){Z.NONE="NONE",Z.OCTAHEDRAL="OCTAHEDRAL",Z.QUATERNION="QUATERNION",Z.EXPONENTIAL="EXPONENTIAL"})($8||($8={}));function GD1(Z){if(!Z.extensions||!Z.extensions[X6])return!1;return!!Z.extensions[X6].fallback}var{BYTE:zD1,SHORT:mn,FLOAT:vD1}=K0.ComponentType,{encodeNormalizedInt:un,decodeNormalizedInt:dR}=I0;function VD1(Z,J,X,$){let{filter:Y,bits:Q}=$,K={array:Z.getArray(),byteStride:Z.getElementSize()*Z.getComponentSize(),componentType:Z.getComponentType(),normalized:Z.getNormalized()};if(X!==j3.ATTRIBUTES)return K;if(Y!==$8.NONE){let W=Z.getNormalized()?HD1(Z):new Float32Array(K.array);switch(Y){case $8.EXPONENTIAL:K.byteStride=Z.getElementSize()*4,K.componentType=vD1,K.normalized=!1,K.array=J.encodeFilterExp(W,Z.getCount(),K.byteStride,Q);break;case $8.OCTAHEDRAL:K.byteStride=Q>8?8:4,K.componentType=Q>8?mn:zD1,K.normalized=!0,W=Z.getElementSize()===3?FD1(W):W,K.array=J.encodeFilterOct(W,Z.getCount(),K.byteStride,Q);break;case $8.QUATERNION:K.byteStride=8,K.componentType=mn,K.normalized=!0,K.array=J.encodeFilterQuat(W,Z.getCount(),K.byteStride,Q);break;default:throw Error("Invalid filter.")}if(K.min=Z.getMin([]),K.max=Z.getMax([]),Z.getNormalized())K.min=K.min.map((G)=>dR(G,Z.getComponentType())),K.max=K.max.map((G)=>dR(G,Z.getComponentType()));if(K.normalized)K.min=K.min.map((G)=>un(G,K.componentType)),K.max=K.max.map((G)=>un(G,K.componentType))}else if(K.byteStride%4)K.array=qD1(K.array,Z.getElementSize()),K.byteStride=K.array.byteLength/Z.getCount();return K}function HD1(Z){let J=Z.getComponentType(),X=Z.getArray(),$=new Float32Array(X.length);for(let Y=0;Y<X.length;Y++)$[Y]=dR(X[Y],J);return $}function qD1(Z,J){let $=E0.padNumber(Z.BYTES_PER_ELEMENT*J)/Z.BYTES_PER_ELEMENT,Y=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*$+W]=Z[K*J+W];return Q}function FD1(Z){let J=new Float32Array(Z.length*4/3);for(let X=0,$=Z.length/3;X<$;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 wD1(Z,J){if(J===w4.BufferViewUsage.ELEMENT_ARRAY_BUFFER)return Z.listParents().some(($)=>{return $ instanceof g1&&$.getMode()===g1.Mode.TRIANGLES})?j3.TRIANGLES:j3.INDICES;return j3.ATTRIBUTES}function cD1(Z,J){let X=J.getGraph().listParentEdges(Z).filter(($)=>!($.getParent()instanceof W3));for(let $ of X){let Y=$.getName(),Q=$.getAttributes().key||"",K=$.getParent().propertyType===i.PRIMITIVE_TARGET;if(Y==="indices")return{filter:$8.NONE};if(Y==="attributes"){if(Q==="POSITION")return{filter:$8.NONE};if(Q==="TEXCOORD_0")return{filter:$8.NONE};if(Q.startsWith("JOINTS_"))return{filter:$8.NONE};if(Q.startsWith("WEIGHTS_"))return{filter:$8.NONE};if(Q==="NORMAL"||Q==="TANGENT")return K?{filter:$8.NONE}:{filter:$8.OCTAHEDRAL,bits:8}}if(Y==="output"){let W=en(Z);if(W==="rotation")return{filter:$8.QUATERNION,bits:16};if(W==="translation")return{filter:$8.EXPONENTIAL,bits:12};if(W==="scale")return{filter:$8.EXPONENTIAL,bits:12};return{filter:$8.NONE}}if(Y==="input")return{filter:$8.NONE};if(Y==="inverseBindMatrices")return{filter:$8.NONE}}return{filter:$8.NONE}}function en(Z){for(let J of Z.listParents()){if(!(J instanceof AJ))continue;for(let X of J.listParents()){if(!(X instanceof QZ))continue;return X.getTargetPath()}}return null}var ln={method:uG.QUANTIZE};class yG extends T1{constructor(...Z){super(...Z);this.extensionName=X6,this.prereadTypes=[i.BUFFER,i.PRIMITIVE],this.prewriteTypes=[i.BUFFER,i.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=ln,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=DZ({},ln,Z),this}preread(Z,J){if(!this._decoder){if(!this.isRequired())return this;throw Error(`[${X6}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw Error(`[${X6}]: Missing WASM support.`)}if(J===i.BUFFER)this._prereadBuffers(Z);else if(J===i.PRIMITIVE)this._prereadPrimitives(Z);return this}_prereadBuffers(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach(($,Y)=>{if(!$.extensions||!$.extensions[X6])return;let Q=$.extensions[X6],K=Q.byteOffset||0,W=Q.byteLength||0,G=Q.count,z=Q.byteStride,v=new Uint8Array(G*z),H=J.json.buffers[Q.buffer],V=H.uri?J.resources[H.uri]:J.resources[E$],q=E0.toView(V,K,W);this._decoder.decodeGltfBuffer(v,G,z,q,Q.mode,Q.filter),Z.bufferViews[Y]=v})}_prereadPrimitives(Z){let J=Z.jsonDoc;(J.json.bufferViews||[]).forEach(($)=>{if(!$.extensions||!$.extensions[X6])return;let Y=$.extensions[X6],Q=Z.buffers[Y.buffer],K=Z.buffers[$.buffer],W=J.json.buffers[$.buffer];if(GD1(W))this._decoderFallbackBufferMap.set(K,Q)})}read(Z){if(!this.isRequired())return this;for(let[J,X]of this._decoderFallbackBufferMap){for(let $ of J.listParents())if($ instanceof K0)$.swap(J,X);J.dispose()}return this}prewrite(Z,J){if(J===i.ACCESSOR)this._prewriteAccessors(Z);else if(J===i.BUFFER)this._prewriteBuffers(Z);return this}_prewriteAccessors(Z){let J=Z.jsonDoc.json,X=this._encoder,$=this._encoderOptions,Y=this.document.getGraph(),Q=this.document.createBuffer(),K=this.document.getRoot().listBuffers().indexOf(Q),W=1,G=new Map,z=(v)=>{for(let H of Y.listParents(v)){if(H.propertyType===i.ROOT)continue;let V=G.get(v);if(V===void 0)G.set(v,V=W++);return V}return-1};this._encoderFallbackBuffer=Q,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let v of this.document.getRoot().listAccessors()){if(en(v)==="weights")continue;if(v.getSparse())continue;let H=Z.getAccessorUsage(v),V=Z.accessorUsageGroupedByParent.has(H)?z(v):null,q=wD1(v,H),F=$.method===uG.FILTER?cD1(v,this.document):{filter:$8.NONE},w=VD1(v,X,q,F),{array:c,byteStride:x}=w,j=v.getBuffer();if(!j)throw Error(`${X6}: Missing buffer for accessor.`);let B=this.document.getRoot().listBuffers().indexOf(j),L=[H,V,q,F.filter,x,B].join(":"),R=this._encoderBufferViews[L],M=this._encoderBufferViewData[L],P=this._encoderBufferViewAccessors[L];if(!R||!M)P=this._encoderBufferViewAccessors[L]=[],M=this._encoderBufferViewData[L]=[],R=this._encoderBufferViews[L]={buffer:K,target:w4.USAGE_TO_TARGET[H],byteOffset:0,byteLength:0,byteStride:H===w4.BufferViewUsage.ARRAY_BUFFER?x:void 0,extensions:{[X6]:{buffer:B,byteOffset:0,byteLength:0,mode:q,filter:F.filter!==$8.NONE?F.filter:void 0,byteStride:x,count:0}}};let N=Z.createAccessorDef(v);if(N.componentType=w.componentType,N.normalized=w.normalized,N.byteOffset=R.byteLength,N.min&&w.min)N.min=w.min;if(N.max&&w.max)N.max=w.max;Z.accessorIndexMap.set(v,J.accessors.length),J.accessors.push(N),P.push(N),M.push(new Uint8Array(c.buffer,c.byteOffset,c.byteLength)),R.byteLength+=c.byteLength,R.extensions.EXT_meshopt_compression.count+=v.getCount()}}_prewriteBuffers(Z){let J=this._encoder;for(let X in this._encoderBufferViews){let $=this._encoderBufferViews[X],Y=this._encoderBufferViewData[X],Q=this.document.getRoot().listBuffers()[$.extensions[X6].buffer],K=Z.otherBufferViews.get(Q)||[],{count:W,byteStride:G,mode:z}=$.extensions[X6],v=E0.concat(Y),H=J.encodeGltfBuffer(v,W,G,z),V=E0.pad(H);$.extensions[X6].byteLength=H.byteLength,Y.length=0,Y.push(V),K.push(V),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),z=this._encoderBufferViewAccessors[Q];for(let q of z)q.bufferView=G;let v=Z.jsonDoc.json.bufferViews[G],H=v.byteOffset||0;Object.assign(v,K),v.byteOffset=J;let V=v.extensions[X6];V.byteOffset=H,J+=E0.padNumber(K.byteLength)}let X=this._encoderFallbackBuffer,$=Z.bufferIndexMap.get(X),Y=Z.jsonDoc.json.buffers[$];return Y.byteLength=J,Y.extensions={[X6]:{fallback:!0}},X.dispose(),this}}yG.EXTENSION_NAME=X6;yG.EncoderMethod=uG;class Zs{match(Z){return Z.length>=12&&E0.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=yn(J,0);if(!X)return null;let $=X.end;while(X=yn(J,$))if(X.type==="meta")$=X.start+4;else if(X.type==="iprp"||X.type==="ipco")$=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 $=X.end;return null}getChannels(Z){return 4}}class Ow extends T1{constructor(...Z){super(...Z);this.extensionName=AG,this.prereadTypes=[i.TEXTURE]}static register(){_5.registerFormat("image/avif",new Zs)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[AG])X.source=X.extensions[AG].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 $=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===$)Q.extensions=Q.extensions||{},Q.extensions[AG]={source:Q.source},delete Q.source})}}),this}}Ow.EXTENSION_NAME=AG;function yn(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:E0.decodeText(new Uint8Array(Z.buffer,Z.byteOffset+J+4,4)),start:J+8,end:J+X}}class Js{match(Z){return Z.length>=12&&Z[8]===87&&Z[9]===69&&Z[10]===66&&Z[11]===80}getSize(Z){let J=E0.decodeText(Z.slice(0,4)),X=E0.decodeText(Z.slice(8,12));if(J!=="RIFF"||X!=="WEBP")return null;let $=new DataView(Z.buffer,Z.byteOffset),Y=12;while(Y<$.byteLength){let Q=E0.decodeText(new Uint8Array([$.getUint8(Y),$.getUint8(Y+1),$.getUint8(Y+2),$.getUint8(Y+3)])),K=$.getUint32(Y+4,!0);if(Q==="VP8 "){let W=$.getInt16(Y+14,!0)&16383,G=$.getInt16(Y+16,!0)&16383;return[W,G]}else if(Q==="VP8L"){let W=$.getUint8(Y+9),G=$.getUint8(Y+10),z=$.getUint8(Y+11),v=$.getUint8(Y+12),H=1+((G&63)<<8|W),V=1+((v&15)<<10|z<<2|(G&192)>>6);return[H,V]}Y+=8+K+K%2}return null}getChannels(Z){return 4}}class Tw extends T1{constructor(...Z){super(...Z);this.extensionName=bG,this.prereadTypes=[i.TEXTURE]}static register(){_5.registerFormat("image/webp",new Js)}preread(Z){return(Z.jsonDoc.json.textures||[]).forEach((X)=>{if(X.extensions&&X.extensions[bG])X.source=X.extensions[bG].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 $=Z.imageIndexMap.get(X);(J.json.textures||[]).forEach((Q)=>{if(Q.source===$)Q.extensions=Q.extensions||{},Q.extensions[bG]={source:Q.source},delete Q.source})}}),this}}Tw.EXTENSION_NAME=bG;var S8,Xs,$s;function xD1(Z,J){let X=new S8.DecoderBuffer;try{if(X.Init(J,J.length),Z.GetEncodedGeometryType(X)!==S8.TRIANGULAR_MESH)throw Error(`[${s1}] Unknown geometry type.`);let Y=new S8.Mesh;if(!Z.DecodeBufferToMesh(X,Y).ok()||Y.ptr===0)throw Error(`[${s1}] Decoding failure.`);return Y}finally{S8.destroy(X)}}function UD1(Z,J){let $=J.num_faces()*3,Y,Q;if(J.num_points()<=65534){let K=$*Uint16Array.BYTES_PER_ELEMENT;Y=S8._malloc(K),Z.GetTrianglesUInt16Array(J,K,Y),Q=new Uint16Array(S8.HEAPU16.buffer,Y,$).slice()}else{let K=$*Uint32Array.BYTES_PER_ELEMENT;Y=S8._malloc(K),Z.GetTrianglesUInt32Array(J,K,Y),Q=new Uint32Array(S8.HEAPU32.buffer,Y,$).slice()}return S8._free(Y),Q}function jD1(Z,J,X,$){let Y=$s[$.componentType],Q=Xs[$.componentType],K=X.num_components(),G=J.num_points()*K,z=G*Q.BYTES_PER_ELEMENT,v=S8._malloc(z);Z.GetAttributeDataArrayForAllPoints(J,X,Y,z,v);let H=new Q(S8.HEAPF32.buffer,v,G).slice();return S8._free(v),H}function BD1(Z){S8=Z,Xs={[K0.ComponentType.FLOAT]:Float32Array,[K0.ComponentType.UNSIGNED_INT]:Uint32Array,[K0.ComponentType.UNSIGNED_SHORT]:Uint16Array,[K0.ComponentType.UNSIGNED_BYTE]:Uint8Array,[K0.ComponentType.SHORT]:Int16Array,[K0.ComponentType.BYTE]:Int8Array},$s={[K0.ComponentType.FLOAT]:S8.DT_FLOAT32,[K0.ComponentType.UNSIGNED_INT]:S8.DT_UINT32,[K0.ComponentType.UNSIGNED_SHORT]:S8.DT_UINT16,[K0.ComponentType.UNSIGNED_BYTE]:S8.DT_UINT8,[K0.ComponentType.SHORT]:S8.DT_INT16,[K0.ComponentType.BYTE]:S8.DT_INT8}}var x4,lG;(function(Z){Z[Z.EDGEBREAKER=1]="EDGEBREAKER",Z[Z.SEQUENTIAL=0]="SEQUENTIAL"})(lG||(lG={}));var B4;(function(Z){Z.POSITION="POSITION",Z.NORMAL="NORMAL",Z.COLOR="COLOR",Z.TEX_COORD="TEX_COORD",Z.GENERIC="GENERIC"})(B4||(B4={}));var Ys={[B4.POSITION]:14,[B4.NORMAL]:10,[B4.COLOR]:8,[B4.TEX_COORD]:12,[B4.GENERIC]:12},pn={decodeSpeed:5,encodeSpeed:5,method:lG.EDGEBREAKER,quantizationBits:Ys,quantizationVolume:"mesh"};function LD1(Z){x4=Z}function DD1(Z,J=pn){let X=DZ({},pn,J);X.quantizationBits=DZ({},Ys,J.quantizationBits);let $=new x4.MeshBuilder,Y=new x4.Mesh,Q=new x4.ExpertEncoder(Y),K={},W=new x4.DracoInt8Array,G=Z.listTargets().length>0,z=!1;for(let w of Z.listSemantics()){let c=Z.getAttribute(w);if(c.getSparse()){z=!0;continue}let x=MD1(w),j=RD1($,c.getComponentType(),Y,x4[x],c.getCount(),c.getElementSize(),c.getArray());if(j===-1)throw Error(`Error compressing "${w}" attribute.`);if(K[w]=j,X.quantizationVolume==="mesh"||w!=="POSITION")Q.SetAttributeQuantization(j,X.quantizationBits[x]);else if(typeof X.quantizationVolume==="object"){let{quantizationVolume:B}=X,L=Math.max(B.max[0]-B.min[0],B.max[1]-B.min[1],B.max[2]-B.min[2]);Q.SetAttributeExplicitQuantization(j,X.quantizationBits[x],c.getElementSize(),B.min,L)}else throw Error("Invalid quantization volume state.")}let v=Z.getIndices();if(!v)throw new Rw("Primitive must have indices.");if($.AddFacesToMesh(Y,v.getCount()/3,v.getArray()),Q.SetSpeedOptions(X.encodeSpeed,X.decodeSpeed),Q.SetTrackEncodedProperties(!0),X.method===lG.SEQUENTIAL||G||z)Q.SetEncodingMethod(x4.MESH_SEQUENTIAL_ENCODING);else Q.SetEncodingMethod(x4.MESH_EDGEBREAKER_ENCODING);let H=Q.EncodeToDracoBuffer(!(G||z),W);if(H<=0)throw new Rw("Error applying Draco compression.");let V=new Uint8Array(H);for(let w=0;w<H;++w)V[w]=W.GetValue(w);let q=Q.GetNumberOfEncodedPoints(),F=Q.GetNumberOfEncodedFaces()*3;return x4.destroy(W),x4.destroy(Y),x4.destroy($),x4.destroy(Q),{numVertices:q,numIndices:F,data:V,attributeIDs:K}}function MD1(Z){if(Z==="POSITION")return B4.POSITION;else if(Z==="NORMAL")return B4.NORMAL;else if(Z.startsWith("COLOR_"))return B4.COLOR;else if(Z.startsWith("TEXCOORD_"))return B4.TEX_COORD;return B4.GENERIC}function RD1(Z,J,X,$,Y,Q,K){switch(J){case K0.ComponentType.UNSIGNED_BYTE:return Z.AddUInt8Attribute(X,$,Y,Q,K);case K0.ComponentType.BYTE:return Z.AddInt8Attribute(X,$,Y,Q,K);case K0.ComponentType.UNSIGNED_SHORT:return Z.AddUInt16Attribute(X,$,Y,Q,K);case K0.ComponentType.SHORT:return Z.AddInt16Attribute(X,$,Y,Q,K);case K0.ComponentType.UNSIGNED_INT:return Z.AddUInt32Attribute(X,$,Y,Q,K);case K0.ComponentType.FLOAT:return Z.AddFloatAttribute(X,$,Y,Q,K);default:throw Error(`Unexpected component type, "${J}".`)}}class Rw extends Error{}class pG extends T1{constructor(...Z){super(...Z);this.extensionName=s1,this.prereadTypes=[i.PRIMITIVE],this.prewriteTypes=[i.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,BD1(this._decoderModule);if(Z==="draco3d.encoder")this._encoderModule=J,LD1(this._encoderModule);return this}setEncoderOptions(Z){return this._encoderOptions=Z,this}preread(Z){if(!this._decoderModule)throw Error(`[${s1}] Please install extension dependency, "draco3d.decoder".`);let J=this.document.getLogger(),X=Z.jsonDoc,$=new Map;try{let Y=X.json.meshes||[];for(let Q of Y)for(let K of Q.primitives){if(!K.extensions||!K.extensions[s1])continue;let W=K.extensions[s1],[G,z]=$.get(W.bufferView)||[];if(!z||!G){let v=X.json.bufferViews[W.bufferView],H=X.json.buffers[v.buffer],V=H.uri?X.resources[H.uri]:X.resources[E$],q=v.byteOffset||0,F=v.byteLength,w=E0.toView(V,q,F);G=new this._decoderModule.Decoder,z=xD1(G,w),$.set(W.bufferView,[G,z]),J.debug(`[${s1}] Decompressed ${w.byteLength} bytes.`)}for(let v in W.attributes){let H=Z.jsonDoc.json.accessors[K.attributes[v]],V=G.GetAttributeByUniqueId(z,W.attributes[v]),q=jD1(G,z,V,H);Z.accessors[K.attributes[v]].setArray(q)}if(K.indices!==void 0)Z.accessors[K.indices].setArray(UD1(G,z))}}finally{for(let[Y,Q]of Array.from($.values()))this._decoderModule.destroy(Y),this._decoderModule.destroy(Q)}return this}read(Z){return this}prewrite(Z,J){if(!this._encoderModule)throw Error(`[${s1}] Please install extension dependency, "draco3d.encoder".`);let X=this.document.getLogger();X.debug(`[${s1}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let $=PD1(this.document),Y=new Map,Q="mesh";if(this._encoderOptions.quantizationVolume==="scene")if(this.document.getRoot().listScenes().length!==1)X.warn(`[${s1}]: quantizationVolume=scene requires exactly 1 scene.`);else Q=PG(this.document.getRoot().listScenes().pop());for(let K of Array.from($.keys())){let W=$.get(K);if(!W)throw Error("Unexpected primitive.");if(Y.has(W)){Y.set(W,Y.get(W));continue}let G=K.getIndices(),z=Z.jsonDoc.json.accessors,v;try{v=DD1(K,DZ({},this._encoderOptions,{quantizationVolume:Q}))}catch(q){if(q instanceof Rw){X.warn(`[${s1}]: ${q.message} Skipping primitive compression.`);continue}throw q}Y.set(W,v);let H=Z.createAccessorDef(G);if(H.count=v.numIndices,Z.accessorIndexMap.set(G,z.length),z.push(H),v.numVertices>65534&&K0.getComponentSize(H.componentType)<=2)H.componentType=K0.ComponentType.UNSIGNED_INT;else if(v.numVertices>254&&K0.getComponentSize(H.componentType)<=1)H.componentType=K0.ComponentType.UNSIGNED_SHORT;for(let q of K.listSemantics()){let F=K.getAttribute(q);if(v.attributeIDs[q]===void 0)continue;let w=Z.createAccessorDef(F);w.count=v.numVertices,Z.accessorIndexMap.set(F,z.length),z.push(w)}let V=K.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];if(!Z.otherBufferViews.has(V))Z.otherBufferViews.set(V,[]);Z.otherBufferViews.get(V).push(v.data)}return X.debug(`[${s1}] Compressed ${$.size} primitives.`),Z.extensionData[s1]={primitiveHashMap:$,primitiveEncodingMap:Y},this}write(Z){let J=Z.extensionData[s1];for(let X of this.document.getRoot().listMeshes()){let $=Z.jsonDoc.json.meshes[Z.meshIndexMap.get(X)];for(let Y=0;Y<X.listPrimitives().length;Y++){let Q=X.listPrimitives()[Y],K=$.primitives[Y],W=J.primitiveHashMap.get(Q);if(!W)continue;let G=J.primitiveEncodingMap.get(W);if(!G)continue;K.extensions=K.extensions||{},K.extensions[s1]={bufferView:Z.otherBufferViewsIndexMap.get(G.data),attributes:G.attributeIDs}}}if(!J.primitiveHashMap.size){let X=Z.jsonDoc.json;X.extensionsUsed=(X.extensionsUsed||[]).filter(($)=>$!==s1),X.extensionsRequired=(X.extensionsRequired||[]).filter(($)=>$!==s1)}return this}}pG.EXTENSION_NAME=s1;pG.EncoderMethod=lG;function PD1(Z){let J=Z.getLogger(),X=new Set,$=new Set,Y=0,Q=0;for(let H of Z.getRoot().listMeshes())for(let V of H.listPrimitives())if(!V.getIndices())$.add(V),Y++;else if(V.getMode()!==g1.Mode.TRIANGLES)$.add(V),Q++;else X.add(V);if(Y>0)J.warn(`[${s1}] Skipping Draco compression of ${Y} non-indexed primitives.`);if(Q>0)J.warn(`[${s1}] Skipping Draco compression of ${Q} non-TRIANGLES primitives.`);let K=Z.getRoot().listAccessors(),W=new Map;for(let H=0;H<K.length;H++)W.set(K[H],H);let G=new Map,z=new Set,v=new Map;for(let H of Array.from(X)){let V=gn(H,W);if(z.has(V)){v.set(H,V);continue}if(G.has(H.getIndices())){let q=H.getIndices(),F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),H.swap(q,F)}for(let q of H.listAttributes())if(G.has(q)){let F=q.clone();W.set(F,Z.getRoot().listAccessors().length-1),H.swap(q,F)}V=gn(H,W),z.add(V),v.set(H,V),G.set(H.getIndices(),V);for(let q of H.listAttributes())G.set(q,V)}for(let H of Array.from(G.keys())){let V=new Set(H.listParents().map((q)=>q.propertyType));if(V.size!==2||!V.has(i.PRIMITIVE)||!V.has(i.ROOT))throw Error(`[${s1}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let H of Array.from(X)){let V=v.get(H),q=H.getIndices();if(G.get(q)!==V||H.listAttributes().some((F)=>G.get(F)!==V))throw Error(`[${s1}] Draco primitives must share all, or no, accessors.`)}for(let H of Array.from($)){let V=H.getIndices();if(G.has(V)||H.listAttributes().some((q)=>G.has(q)))throw Error(`[${s1}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return v}function gn(Z,J){let X=[],$=Z.getIndices();X.push(J.get($));for(let Y of Z.listAttributes())X.push(J.get(Y));return X.sort().join("|")}class B3 extends O1{init(){this.extensionName=U4,this.propertyType="Light",this.parentTypes=[i.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:B3.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)}}B3.EXTENSION_NAME=U4;B3.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};class nR extends T1{constructor(...Z){super(...Z);this.extensionName=U4}createLight(Z=""){return new B3(this.document.getGraph(),Z)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[U4])return this;let Y=(J.json.extensions[U4].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[U4])return;let W=Q.extensions[U4];Z.nodes[K].setExtension(U4,Y[W.light])}),this}write(Z){let J=Z.jsonDoc;if(this.properties.size===0)return this;let X=[],$=new Map;for(let Y of this.properties){let Q=Y,K={type:Q.getType()};if(!I0.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()===B3.Type.SPOT)K.spot={innerConeAngle:Q.getInnerConeAngle(),outerConeAngle:Q.getOuterConeAngle()};X.push(K),$.set(Q,X.length-1)}return this.document.getRoot().listNodes().forEach((Y)=>{let Q=Y.getExtension(U4);if(Q){let K=Z.nodeIndexMap.get(Y),W=J.json.nodes[K];W.extensions=W.extensions||{},W.extensions[U4]={light:$.get(Q)}}}),J.json.extensions=J.json.extensions||{},J.json.extensions[U4]={lights:X},this}}nR.EXTENSION_NAME=U4;var{R:ND1,G:OD1,B:TD1}=v5;class sR extends O1{init(){this.extensionName=zZ,this.propertyType="Anisotropy",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new F1(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:ND1|OD1|TD1})}}sR.EXTENSION_NAME=zZ;class oR extends T1{constructor(...Z){super(...Z);this.extensionName=zZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createAnisotropy(){return new sR(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[zZ]){let K=this.createAnisotropy();Z.materials[Q].setExtension(zZ,K);let W=Y.extensions[zZ];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,z=Z.textures[$[G.index].source];K.setAnisotropyTexture(z),Z.setTextureInfo(K.getAnisotropyTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(zZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[zZ]={};if($.getAnisotropyStrength()>0)K.anisotropyStrength=$.getAnisotropyStrength();if($.getAnisotropyRotation()!==0)K.anisotropyRotation=$.getAnisotropyRotation();if($.getAnisotropyTexture()){let W=$.getAnisotropyTexture(),G=$.getAnisotropyTextureInfo();K.anisotropyTexture=Z.createTextureInfoDef(W,G)}}}),this}}oR.EXTENSION_NAME=zZ;var{R:dn,G:an,B:CD1}=v5;class rR extends O1{init(){this.extensionName=vZ,this.propertyType="Clearcoat",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new F1(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new F1(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new F1(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:dn})}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:an})}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:dn|an|CD1})}}rR.EXTENSION_NAME=vZ;class tR extends T1{constructor(...Z){super(...Z);this.extensionName=vZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createClearcoat(){return new rR(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[vZ]){let K=this.createClearcoat();Z.materials[Q].setExtension(vZ,K);let W=Y.extensions[vZ];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,z=Z.textures[$[G.index].source];K.setClearcoatTexture(z),Z.setTextureInfo(K.getClearcoatTextureInfo(),G)}if(W.clearcoatRoughnessTexture!==void 0){let G=W.clearcoatRoughnessTexture,z=Z.textures[$[G.index].source];K.setClearcoatRoughnessTexture(z),Z.setTextureInfo(K.getClearcoatRoughnessTextureInfo(),G)}if(W.clearcoatNormalTexture!==void 0){let G=W.clearcoatNormalTexture,z=Z.textures[$[G.index].source];if(K.setClearcoatNormalTexture(z),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 $=X.getExtension(vZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[vZ]={clearcoatFactor:$.getClearcoatFactor(),clearcoatRoughnessFactor:$.getClearcoatRoughnessFactor()};if($.getClearcoatTexture()){let W=$.getClearcoatTexture(),G=$.getClearcoatTextureInfo();K.clearcoatTexture=Z.createTextureInfoDef(W,G)}if($.getClearcoatRoughnessTexture()){let W=$.getClearcoatRoughnessTexture(),G=$.getClearcoatRoughnessTextureInfo();K.clearcoatRoughnessTexture=Z.createTextureInfoDef(W,G)}if($.getClearcoatNormalTexture()){let W=$.getClearcoatNormalTexture(),G=$.getClearcoatNormalTextureInfo();if(K.clearcoatNormalTexture=Z.createTextureInfoDef(W,G),$.getClearcoatNormalScale()!==1)K.clearcoatNormalTexture.scale=$.getClearcoatNormalScale()}}}),this}}tR.EXTENSION_NAME=vZ;var{R:fD1,G:kD1,B:ED1,A:ID1}=v5;class eR extends O1{init(){this.extensionName=VZ,this.propertyType="DiffuseTransmission",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new F1(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new F1(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:ID1})}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:fD1|kD1|ED1})}}eR.EXTENSION_NAME=VZ;class ZP extends T1{constructor(...Z){super(...Z);this.extensionName=VZ}createDiffuseTransmission(){return new eR(this.document.getGraph())}read(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[VZ]){let K=this.createDiffuseTransmission();Z.materials[Q].setExtension(VZ,K);let W=Y.extensions[VZ];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,z=Z.textures[$[G.index].source];K.setDiffuseTransmissionTexture(z),Z.setTextureInfo(K.getDiffuseTransmissionTextureInfo(),G)}if(W.diffuseTransmissionColorTexture!==void 0){let G=W.diffuseTransmissionColorTexture,z=Z.textures[$[G.index].source];K.setDiffuseTransmissionColorTexture(z),Z.setTextureInfo(K.getDiffuseTransmissionColorTextureInfo(),G)}}}),this}write(Z){let J=Z.jsonDoc;for(let X of this.document.getRoot().listMaterials()){let $=X.getExtension(VZ);if(!$)continue;let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[VZ]={diffuseTransmissionFactor:$.getDiffuseTransmissionFactor(),diffuseTransmissionColorFactor:$.getDiffuseTransmissionColorFactor()};if($.getDiffuseTransmissionTexture()){let W=$.getDiffuseTransmissionTexture(),G=$.getDiffuseTransmissionTextureInfo();K.diffuseTransmissionTexture=Z.createTextureInfoDef(W,G)}if($.getDiffuseTransmissionColorTexture()){let W=$.getDiffuseTransmissionColorTexture(),G=$.getDiffuseTransmissionColorTextureInfo();K.diffuseTransmissionColorTexture=Z.createTextureInfoDef(W,G)}}return this}}ZP.EXTENSION_NAME=VZ;class JP extends O1{init(){this.extensionName=HZ,this.propertyType="Dispersion",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(Z){return this.set("dispersion",Z)}}JP.EXTENSION_NAME=HZ;class XP extends T1{constructor(...Z){super(...Z);this.extensionName=HZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createDispersion(){return new JP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[HZ]){let Q=this.createDispersion();Z.materials[Y].setExtension(HZ,Q);let K=$.extensions[HZ];if(K.dispersion!==void 0)Q.setDispersion(K.dispersion)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(HZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[HZ]={dispersion:$.getDispersion()}}}),this}}XP.EXTENSION_NAME=HZ;class $P extends O1{init(){this.extensionName=qZ,this.propertyType="EmissiveStrength",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(Z){return this.set("emissiveStrength",Z)}}$P.EXTENSION_NAME=qZ;class YP extends T1{constructor(...Z){super(...Z);this.extensionName=qZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createEmissiveStrength(){return new $P(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[qZ]){let Q=this.createEmissiveStrength();Z.materials[Y].setExtension(qZ,Q);let K=$.extensions[qZ];if(K.emissiveStrength!==void 0)Q.setEmissiveStrength(K.emissiveStrength)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(qZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[qZ]={emissiveStrength:$.getEmissiveStrength()}}}),this}}YP.EXTENSION_NAME=qZ;class QP extends O1{init(){this.extensionName=FZ,this.propertyType="IOR",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(Z){return this.set("ior",Z)}}QP.EXTENSION_NAME=FZ;class Cw extends T1{constructor(...Z){super(...Z);this.extensionName=FZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createIOR(){return new QP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach(($,Y)=>{if($.extensions&&$.extensions[FZ]){let Q=this.createIOR();Z.materials[Y].setExtension(FZ,Q);let K=$.extensions[FZ];if(K.ior!==void 0)Q.setIOR(K.ior)}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(FZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{},Q.extensions[FZ]={ior:$.getIOR()}}}),this}}Cw.EXTENSION_NAME=FZ;var{R:_D1,G:hD1}=v5;class KP extends O1{init(){this.extensionName=wZ,this.propertyType="Iridescence",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new F1(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new F1(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:_D1})}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:hD1})}}KP.EXTENSION_NAME=wZ;class WP extends T1{constructor(...Z){super(...Z);this.extensionName=wZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createIridescence(){return new KP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[wZ]){let K=this.createIridescence();Z.materials[Q].setExtension(wZ,K);let W=Y.extensions[wZ];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,z=Z.textures[$[G.index].source];K.setIridescenceTexture(z),Z.setTextureInfo(K.getIridescenceTextureInfo(),G)}if(W.iridescenceThicknessTexture!==void 0){let G=W.iridescenceThicknessTexture,z=Z.textures[$[G.index].source];K.setIridescenceThicknessTexture(z),Z.setTextureInfo(K.getIridescenceThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(wZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[wZ]={};if($.getIridescenceFactor()>0)K.iridescenceFactor=$.getIridescenceFactor();if($.getIridescenceIOR()!==1.3)K.iridescenceIor=$.getIridescenceIOR();if($.getIridescenceThicknessMinimum()!==100)K.iridescenceThicknessMinimum=$.getIridescenceThicknessMinimum();if($.getIridescenceThicknessMaximum()!==400)K.iridescenceThicknessMaximum=$.getIridescenceThicknessMaximum();if($.getIridescenceTexture()){let W=$.getIridescenceTexture(),G=$.getIridescenceTextureInfo();K.iridescenceTexture=Z.createTextureInfoDef(W,G)}if($.getIridescenceThicknessTexture()){let W=$.getIridescenceThicknessTexture(),G=$.getIridescenceThicknessTextureInfo();K.iridescenceThicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}WP.EXTENSION_NAME=wZ;var{R:nn,G:sn,B:on,A:rn}=v5;class GP extends O1{init(){this.extensionName=cZ,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new F1(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new F1(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:nn|sn|on|rn,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:nn|sn|on|rn})}}GP.EXTENSION_NAME=cZ;class fw extends T1{constructor(...Z){super(...Z);this.extensionName=cZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createPBRSpecularGlossiness(){return new GP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[cZ]){let K=this.createPBRSpecularGlossiness();Z.materials[Q].setExtension(cZ,K);let W=Y.extensions[cZ];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,z=Z.textures[$[G.index].source];K.setDiffuseTexture(z),Z.setTextureInfo(K.getDiffuseTextureInfo(),G)}if(W.specularGlossinessTexture!==void 0){let G=W.specularGlossinessTexture,z=Z.textures[$[G.index].source];K.setSpecularGlossinessTexture(z),Z.setTextureInfo(K.getSpecularGlossinessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(cZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[cZ]={diffuseFactor:$.getDiffuseFactor(),specularFactor:$.getSpecularFactor(),glossinessFactor:$.getGlossinessFactor()};if($.getDiffuseTexture()){let W=$.getDiffuseTexture(),G=$.getDiffuseTextureInfo();K.diffuseTexture=Z.createTextureInfoDef(W,G)}if($.getSpecularGlossinessTexture()){let W=$.getSpecularGlossinessTexture(),G=$.getSpecularGlossinessTextureInfo();K.specularGlossinessTexture=Z.createTextureInfoDef(W,G)}}}),this}}fw.EXTENSION_NAME=cZ;var{R:SD1,G:bD1,B:AD1,A:mD1}=v5;class zP extends O1{init(){this.extensionName=xZ,this.propertyType="Sheen",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new F1(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new F1(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:SD1|bD1|AD1,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:mD1})}}zP.EXTENSION_NAME=xZ;class vP extends T1{constructor(...Z){super(...Z);this.extensionName=xZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createSheen(){return new zP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[xZ]){let K=this.createSheen();Z.materials[Q].setExtension(xZ,K);let W=Y.extensions[xZ];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,z=Z.textures[$[G.index].source];K.setSheenColorTexture(z),Z.setTextureInfo(K.getSheenColorTextureInfo(),G)}if(W.sheenRoughnessTexture!==void 0){let G=W.sheenRoughnessTexture,z=Z.textures[$[G.index].source];K.setSheenRoughnessTexture(z),Z.setTextureInfo(K.getSheenRoughnessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(xZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[xZ]={sheenColorFactor:$.getSheenColorFactor(),sheenRoughnessFactor:$.getSheenRoughnessFactor()};if($.getSheenColorTexture()){let W=$.getSheenColorTexture(),G=$.getSheenColorTextureInfo();K.sheenColorTexture=Z.createTextureInfoDef(W,G)}if($.getSheenRoughnessTexture()){let W=$.getSheenRoughnessTexture(),G=$.getSheenRoughnessTextureInfo();K.sheenRoughnessTexture=Z.createTextureInfoDef(W,G)}}}),this}}vP.EXTENSION_NAME=xZ;var{R:uD1,G:lD1,B:yD1,A:pD1}=v5;class VP extends O1{init(){this.extensionName=UZ,this.propertyType="Specular",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new F1(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new F1(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:pD1})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(Z){return this.setRef("specularColorTexture",Z,{channels:uD1|lD1|yD1,isColor:!0})}}VP.EXTENSION_NAME=UZ;class kw extends T1{constructor(...Z){super(...Z);this.extensionName=UZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createSpecular(){return new VP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[UZ]){let K=this.createSpecular();Z.materials[Q].setExtension(UZ,K);let W=Y.extensions[UZ];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,z=Z.textures[$[G.index].source];K.setSpecularTexture(z),Z.setTextureInfo(K.getSpecularTextureInfo(),G)}if(W.specularColorTexture!==void 0){let G=W.specularColorTexture,z=Z.textures[$[G.index].source];K.setSpecularColorTexture(z),Z.setTextureInfo(K.getSpecularColorTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(UZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[UZ]={};if($.getSpecularFactor()!==1)K.specularFactor=$.getSpecularFactor();if(!I0.eq($.getSpecularColorFactor(),[1,1,1]))K.specularColorFactor=$.getSpecularColorFactor();if($.getSpecularTexture()){let W=$.getSpecularTexture(),G=$.getSpecularTextureInfo();K.specularTexture=Z.createTextureInfoDef(W,G)}if($.getSpecularColorTexture()){let W=$.getSpecularColorTexture(),G=$.getSpecularColorTextureInfo();K.specularColorTexture=Z.createTextureInfoDef(W,G)}}}),this}}kw.EXTENSION_NAME=UZ;var{R:iD1}=v5;class HP extends O1{init(){this.extensionName=jZ,this.propertyType="Transmission",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new F1(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:iD1})}}HP.EXTENSION_NAME=jZ;class qP extends T1{constructor(...Z){super(...Z);this.extensionName=jZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createTransmission(){return new HP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[jZ]){let K=this.createTransmission();Z.materials[Q].setExtension(jZ,K);let W=Y.extensions[jZ];if(W.transmissionFactor!==void 0)K.setTransmissionFactor(W.transmissionFactor);if(W.transmissionTexture!==void 0){let G=W.transmissionTexture,z=Z.textures[$[G.index].source];K.setTransmissionTexture(z),Z.setTextureInfo(K.getTransmissionTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(jZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[jZ]={transmissionFactor:$.getTransmissionFactor()};if($.getTransmissionTexture()){let W=$.getTransmissionTexture(),G=$.getTransmissionTextureInfo();K.transmissionTexture=Z.createTextureInfoDef(W,G)}}}),this}}qP.EXTENSION_NAME=jZ;class FP extends O1{init(){this.extensionName=iJ,this.propertyType="Unlit",this.parentTypes=[i.MATERIAL]}}FP.EXTENSION_NAME=iJ;class Ew extends T1{constructor(...Z){super(...Z);this.extensionName=iJ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createUnlit(){return new FP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){return(Z.jsonDoc.json.materials||[]).forEach((X,$)=>{if(X.extensions&&X.extensions[iJ])Z.materials[$].setExtension(iJ,this.createUnlit())}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{if(X.getExtension(iJ)){let $=Z.materialIndexMap.get(X),Y=J.json.materials[$];Y.extensions=Y.extensions||{},Y.extensions[iJ]={}}}),this}}Ew.EXTENSION_NAME=iJ;class wP extends O1{init(){this.extensionName=U6,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new w1})}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")}}wP.EXTENSION_NAME=U6;class cP extends O1{init(){this.extensionName=U6,this.propertyType="MappingList",this.parentTypes=[i.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new w1})}addMapping(Z){return this.addRef("mappings",Z)}removeMapping(Z){return this.removeRef("mappings",Z)}listMappings(){return this.listRefs("mappings")}}cP.EXTENSION_NAME=U6;class Pw extends O1{init(){this.extensionName=U6,this.propertyType="Variant",this.parentTypes=["MappingList"]}}Pw.EXTENSION_NAME=U6;class xP extends T1{constructor(...Z){super(...Z);this.extensionName=U6}createMappingList(){return new cP(this.document.getGraph())}createVariant(Z=""){return new Pw(this.document.getGraph(),Z)}createMapping(){return new wP(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter((Z)=>Z instanceof Pw)}read(Z){let J=Z.jsonDoc;if(!J.json.extensions||!J.json.extensions[U6])return this;let Y=(J.json.extensions[U6].variants||[]).map((K)=>this.createVariant().setName(K.name||""));return(J.json.meshes||[]).forEach((K,W)=>{let G=Z.meshes[W];(K.primitives||[]).forEach((v,H)=>{if(!v.extensions||!v.extensions[U6])return;let V=this.createMappingList(),q=v.extensions[U6];for(let F of q.mappings){let w=this.createMapping();if(F.material!==void 0)w.setMaterial(Z.materials[F.material]);for(let c of F.variants||[])w.addVariant(Y[c]);V.addMapping(w)}G.listPrimitives()[H].setExtension(U6,V)})}),this}write(Z){let J=Z.jsonDoc,X=this.listVariants();if(!X.length)return this;let $=[],Y=new Map;for(let Q of X)Y.set(Q,$.length),$.push(Z.createPropertyDef(Q));for(let Q of this.document.getRoot().listMeshes()){let K=Z.meshIndexMap.get(Q);Q.listPrimitives().forEach((W,G)=>{let z=W.getExtension(U6);if(!z)return;let v=Z.jsonDoc.json.meshes[K].primitives[G],H=z.listMappings().map((V)=>{let q=Z.createPropertyDef(V),F=V.getMaterial();if(F)q.material=Z.materialIndexMap.get(F);return q.variants=V.listVariants().map((w)=>Y.get(w)),q});v.extensions=v.extensions||{},v.extensions[U6]={mappings:H}})}return J.json.extensions=J.json.extensions||{},J.json.extensions[U6]={variants:$},this}}xP.EXTENSION_NAME=U6;var{G:gD1}=v5;class UP extends O1{init(){this.extensionName=BZ,this.propertyType="Volume",this.parentTypes=[i.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new F1(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:gD1})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(Z){return this.set("attenuationDistance",Z)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(Z){return this.set("attenuationColor",Z)}}UP.EXTENSION_NAME=BZ;class jP extends T1{constructor(...Z){super(...Z);this.extensionName=BZ,this.prereadTypes=[i.MESH],this.prewriteTypes=[i.MESH]}createVolume(){return new UP(this.document.getGraph())}read(Z){return this}write(Z){return this}preread(Z){let J=Z.jsonDoc,X=J.json.materials||[],$=J.json.textures||[];return X.forEach((Y,Q)=>{if(Y.extensions&&Y.extensions[BZ]){let K=this.createVolume();Z.materials[Q].setExtension(BZ,K);let W=Y.extensions[BZ];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,z=Z.textures[$[G.index].source];K.setThicknessTexture(z),Z.setTextureInfo(K.getThicknessTextureInfo(),G)}}}),this}prewrite(Z){let J=Z.jsonDoc;return this.document.getRoot().listMaterials().forEach((X)=>{let $=X.getExtension(BZ);if($){let Y=Z.materialIndexMap.get(X),Q=J.json.materials[Y];Q.extensions=Q.extensions||{};let K=Q.extensions[BZ]={};if($.getThicknessFactor()>0)K.thicknessFactor=$.getThicknessFactor();if(Number.isFinite($.getAttenuationDistance()))K.attenuationDistance=$.getAttenuationDistance();if(!I0.eq($.getAttenuationColor(),[1,1,1]))K.attenuationColor=$.getAttenuationColor();if($.getThicknessTexture()){let W=$.getThicknessTexture(),G=$.getThicknessTextureInfo();K.thicknessTexture=Z.createTextureInfoDef(W,G)}}}),this}}jP.EXTENSION_NAME=BZ;class iG extends T1{constructor(...Z){super(...Z);this.extensionName=tn}read(Z){return this}write(Z){return this}}iG.EXTENSION_NAME=tn;class Qs{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=Mw(Z);return[J.pixelWidth,J.pixelHeight]}getChannels(Z){let X=Mw(Z).dataFormatDescriptor[0];if(X.colorModel===bn)return X.samples.length===2&&(X.samples[1].channelType&15)===15?4:3;else if(X.colorModel===An)return(X.samples[0].channelType&15)===3?4:3;throw Error(`Unexpected KTX2 colorModel, "${X.colorModel}".`)}getVRAMByteLength(Z){let J=Mw(Z),X=this.getChannels(Z)>3,$=0;for(let Y=0;Y<J.levels.length;Y++){let Q=J.levels[Y];if(Q.uncompressedByteLength)$+=Q.uncompressedByteLength;else{let K=Math.max(1,Math.floor(J.pixelWidth/Math.pow(2,Y))),W=Math.max(1,Math.floor(J.pixelHeight/Math.pow(2,Y))),G=X?16:8;$+=K/4*(W/4)*G}}return $}}class BP extends T1{constructor(...Z){super(...Z);this.extensionName=mG,this.prereadTypes=[i.TEXTURE]}static register(){_5.registerFormat("image/ktx2",new Qs)}preread(Z){return Z.jsonDoc.json.textures.forEach((J)=>{if(J.extensions&&J.extensions[mG]){let X=J.extensions[mG];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 $=Z.imageIndexMap.get(X);J.json.textures.forEach((Y)=>{if(Y.source===$)Y.extensions=Y.extensions||{},Y.extensions[mG]={source:Y.source},delete Y.source})}}),this}}BP.EXTENSION_NAME=mG;class LP extends O1{init(){this.extensionName=LZ,this.propertyType="Transform",this.parentTypes=[i.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)}}LP.EXTENSION_NAME=LZ;class DP extends T1{constructor(...Z){super(...Z);this.extensionName=LZ}createTransform(){return new LP(this.document.getGraph())}read(Z){for(let[J,X]of Array.from(Z.textureInfos.entries())){if(!X.extensions||!X.extensions[LZ])continue;let $=this.createTransform(),Y=X.extensions[LZ];if(Y.offset!==void 0)$.setOffset(Y.offset);if(Y.rotation!==void 0)$.setRotation(Y.rotation);if(Y.scale!==void 0)$.setScale(Y.scale);if(Y.texCoord!==void 0)$.setTexCoord(Y.texCoord);J.setExtension(LZ,$)}return this}write(Z){let J=Array.from(Z.textureInfoDefMap.entries());for(let[X,$]of J){let Y=X.getExtension(LZ);if(!Y)continue;$.extensions=$.extensions||{};let Q={},K=I0.eq;if(!K(Y.getOffset(),[0,0]))Q.offset=Y.getOffset();if(Y.getRotation()!==0)Q.rotation=Y.getRotation();if(!K(Y.getScale(),[1,1]))Q.scale=Y.getScale();if(Y.getTexCoord()!=null)Q.texCoord=Y.getTexCoord();$.extensions[LZ]=Q}return this}}DP.EXTENSION_NAME=LZ;var dD1=[i.ROOT,i.SCENE,i.NODE,i.MESH,i.MATERIAL,i.TEXTURE,i.ANIMATION];class MP extends O1{init(){this.extensionName=j4,this.propertyType="Packet",this.parentTypes=dD1}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(Z){return this.set("context",DZ({},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=DZ({},this.get("properties"));if(J)X[Z]=J;else delete X[Z];return this.set("properties",X)}toJSONLD(){let Z=iR(this.get("context")),J=iR(this.get("properties"));return DZ({"@context":Z},J)}fromJSONLD(Z){Z=iR(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 Error(`${j4}: Missing context for term, "${Z}".`)}}MP.EXTENSION_NAME=j4;function iR(Z){return JSON.parse(JSON.stringify(Z))}class RP extends T1{constructor(...Z){super(...Z);this.extensionName=j4}createPacket(){return new MP(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(Z){var J;let X=(J=Z.jsonDoc.json.extensions)==null?void 0:J[j4];if(!X||!X.packets)return this;let $=Z.jsonDoc.json,Y=this.document.getRoot(),Q=X.packets.map((G)=>this.createPacket().fromJSONLD(G)),K=[[$.asset],$.scenes,$.nodes,$.meshes,$.materials,$.images,$.animations],W=[[Y],Y.listScenes(),Y.listNodes(),Y.listMeshes(),Y.listMaterials(),Y.listTextures(),Y.listAnimations()];for(let G=0;G<K.length;G++){let z=K[G]||[];for(let v=0;v<z.length;v++){let H=z[v];if(H.extensions&&H.extensions[j4]){let V=H.extensions[j4];W[G][v].setExtension(j4,Q[V.packet])}}}return this}write(Z){let{json:J}=Z.jsonDoc,X=[];for(let $ of this.properties){X.push($.toJSONLD());for(let Y of $.listParents()){let Q;switch(Y.propertyType){case i.ROOT:Q=J.asset;break;case i.SCENE:Q=J.scenes[Z.sceneIndexMap.get(Y)];break;case i.NODE:Q=J.nodes[Z.nodeIndexMap.get(Y)];break;case i.MESH:Q=J.meshes[Z.meshIndexMap.get(Y)];break;case i.MATERIAL:Q=J.materials[Z.materialIndexMap.get(Y)];break;case i.TEXTURE:Q=J.images[Z.imageIndexMap.get(Y)];break;case i.ANIMATION:Q=J.animations[Z.animationIndexMap.get(Y)];break;default:Q=null,this.document.getLogger().warn(`[${j4}]: Unsupported parent property, "${Y.propertyType}"`);break}if(!Q)continue;Q.extensions=Q.extensions||{},Q.extensions[j4]={packet:X.length-1}}}if(X.length>0)J.extensions=J.extensions||{},J.extensions[j4]={packets:X};return this}}RP.EXTENSION_NAME=j4;var aD1=[pG,nR,oR,tR,ZP,XP,YP,Cw,WP,fw,kw,vP,qP,Ew,xP,jP,iG,BP,DP,RP],gN6=[Nw,yG,Ow,Tw,...aD1];var nD1=t(UR(),1);function M3(){return M3=Object.assign?Object.assign.bind():function(Z){for(var J=1;J<arguments.length;J++){var X=arguments[J];for(var $ in X)({}).hasOwnProperty.call(X,$)&&(Z[$]=X[$])}return Z},M3.apply(null,arguments)}var{POINTS:Ks,LINES:Iw,LINE_STRIP:sD1,LINE_LOOP:oD1,TRIANGLES:_w,TRIANGLE_STRIP:rD1,TRIANGLE_FAN:tD1}=g1.Mode;function u$(Z,J){return Object.defineProperty(J,"name",{value:Z}),J}function RZ(Z,J){let X=M3({},Z);for(let $ in J)if(J[$]!==void 0)X[$]=J[$];return X}function Rs(Z){let J=Z.getIndices(),X=Z.getAttribute("POSITION");switch(Z.getMode()){case g1.Mode.POINTS:return J?J.getCount():X.getCount();case g1.Mode.LINES:return J?J.getCount()/2:X.getCount()/2;case g1.Mode.LINE_LOOP:return J?J.getCount():X.getCount();case g1.Mode.LINE_STRIP:return J?J.getCount()-1:X.getCount()-1;case g1.Mode.TRIANGLES:return J?J.getCount()/3:X.getCount()/3;case g1.Mode.TRIANGLE_STRIP:case g1.Mode.TRIANGLE_FAN:return J?J.getCount()-2:X.getCount()-2;default:throw Error("Unexpected mode: "+Z.getMode())}}var eD1=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function OP(Z){return eD1.format(Z)}function ZM1(Z,J,X=2){let $=Z>J?"–":"+",Y="%";return $+(Math.abs(Z-J)/Z*100).toFixed(X)+"%"}function mw(Z,J){return`${OP(Z)} → ${OP(J)} (${ZM1(Z,J)})`}function uw(Z){let J=[];for(let X of Z.listAttributes())J.push(X);for(let X of Z.listTargets())for(let $ of X.listAttributes())J.push($);return Array.from(new Set(J))}function JM1(Z,J,X){Z.swap(J,X);for(let $ of Z.listTargets())$.swap(J,X)}function Ps(Z){let J=Z.getIndices(),X=uw(Z);if(Z.dispose(),J&&!TP(J))J.dispose();for(let $ of X)if(!TP($))$.dispose()}function MZ(Z,J){return Z.createAccessor(J.getName()).setArray(J.getArray()).setType(J.getType()).setBuffer(J.getBuffer()).setNormalized(J.getNormalized()).setSparse(J.getSparse())}function XM1(Z,J=Z){let X=hP(Z,J);for(let $=0;$<X.length;$++)X[$]=$;return X}function hP(Z,J=Z){return J<=65534?new Uint16Array(Z):new Uint32Array(Z)}function TP(Z){return Z.listParents().some((J)=>J.propertyType!==i.ROOT)}function Ns(Z){for(let J in Z)return!1;return!0}function Os(Z){let J=c6.fromGraph(Z.getGraph()),X=Z.getMaterial(),$=J.getRoot().listMaterials().indexOf(X),Y=YM1[Z.getMode()],Q=!!Z.getIndices(),K=Z.listSemantics().sort().map((G)=>{let z=Z.getAttribute(G),v=z.getElementSize(),H=z.getComponentType();return`${G}:${v}:${H}`}).join("+"),W=Z.listTargets().map((G)=>{return G.listSemantics().sort().map((z)=>{let v=Z.getAttribute(z),H=v.getElementSize(),V=v.getComponentType();return`${z}:${H}:${V}`}).join("+")}).join("~");return`${$}|${Y}|${Q}|${K}|${W}`}function $M1(Z){return Math.pow(2,Math.ceil(Math.log(Z)/Math.LN2))}var YM1={[Ks]:Ks,[Iw]:Iw,[sD1]:Iw,[oD1]:Iw,[_w]:_w,[rD1]:_w,[tD1]:_w},L3="center",Ws={pivot:"center"};function Ts(Z=Ws){let J=RZ(Ws,Z);return u$(L3,(X)=>{let $=X.getLogger(),Y=X.getRoot(),Q=Y.listAnimations().length>0||Y.listSkins().length>0;X.getRoot().listScenes().forEach((K,W)=>{$.debug(`${L3}: Scene ${W+1} / ${Y.listScenes().length}.`);let G;if(typeof J.pivot==="string"){let v=PG(K);if(G=[(v.max[0]-v.min[0])/2+v.min[0],(v.max[1]-v.min[1])/2+v.min[1],(v.max[2]-v.min[2])/2+v.min[2]],J.pivot==="above")G[1]=v.max[1];if(J.pivot==="below")G[1]=v.min[1]}else G=J.pivot;$.debug(`${L3}: Pivot "${G.join(", ")}".`);let z=[-1*G[0],-1*G[1],-1*G[2]];if(Q){$.debug(`${L3}: Model contains animation or skin. Adding a wrapper node.`);let v=X.createNode("Pivot").setTranslation(z);K.listChildren().forEach((H)=>v.addChild(H)),K.addChild(v)}else $.debug(`${L3}: Skipping wrapper, offsetting all root nodes.`),K.listChildren().forEach((v)=>{let H=v.getTranslation();v.setTranslation([H[0]+z[0],H[1]+z[1],H[2]+z[2]])})}),$.debug(`${L3}: Complete.`)})}function QM1(Z){let J=new Set,X=Z,$;while($=X.getParentNode()){if(J.has($))throw Error("Circular dependency in scene graph.");J.add($),X=$}return X.listParents().filter((Y)=>Y instanceof K3)}function KM1(Z){let J=QM1(Z),X=Z.getParentNode();if(!X)return Z;Z.setMatrix(Z.getWorldMatrix()),X.removeChild(Z);for(let $ of J)$.addChild(Z);return Z}var R3=typeof Float32Array<"u"?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 WM1(Z,J){var X=J[0],$=J[1],Y=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],z=J[7],v=J[8],H=J[9],V=J[10],q=J[11],F=J[12],w=J[13],c=J[14],x=J[15],j=X*W-$*K,B=X*G-Y*K,L=X*z-Q*K,R=$*G-Y*W,M=$*z-Q*W,P=Y*z-Q*G,N=v*w-H*F,O=v*c-V*F,k=v*x-q*F,E=H*c-V*w,S=H*x-q*w,f=V*x-q*c,C=j*f-B*S+L*E+R*k-M*O+P*N;if(!C)return null;return C=1/C,Z[0]=(W*f-G*S+z*E)*C,Z[1]=(Y*S-$*f-Q*E)*C,Z[2]=(w*P-c*M+x*R)*C,Z[3]=(V*M-H*P-q*R)*C,Z[4]=(G*k-K*f-z*O)*C,Z[5]=(X*f-Y*k+Q*O)*C,Z[6]=(c*L-F*P-x*B)*C,Z[7]=(v*P-V*L+q*B)*C,Z[8]=(K*S-W*k+z*N)*C,Z[9]=($*k-X*S-Q*N)*C,Z[10]=(F*M-w*L+x*j)*C,Z[11]=(H*L-v*M-q*j)*C,Z[12]=(W*O-K*E-G*N)*C,Z[13]=(X*E-$*O+Y*N)*C,Z[14]=(w*B-F*R-c*j)*C,Z[15]=(v*R-H*B+V*j)*C,Z}function GM1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3],Q=Z[4],K=Z[5],W=Z[6],G=Z[7],z=Z[8],v=Z[9],H=Z[10],V=Z[11],q=Z[12],F=Z[13],w=Z[14],c=Z[15],x=J*K-X*Q,j=J*W-$*Q,B=J*G-Y*Q,L=X*W-$*K,R=X*G-Y*K,M=$*G-Y*W,P=z*F-v*q,N=z*w-H*q,O=z*c-V*q,k=v*w-H*F,E=v*c-V*F,S=H*c-V*w;return x*S-j*E+B*k+L*O-R*N+M*P}function Cs(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=J[3],W=J[4],G=J[5],z=J[6],v=J[7],H=J[8],V=J[9],q=J[10],F=J[11],w=J[12],c=J[13],x=J[14],j=J[15],B=X[0],L=X[1],R=X[2],M=X[3];return Z[0]=B*$+L*W+R*H+M*w,Z[1]=B*Y+L*G+R*V+M*c,Z[2]=B*Q+L*z+R*q+M*x,Z[3]=B*K+L*v+R*F+M*j,B=X[4],L=X[5],R=X[6],M=X[7],Z[4]=B*$+L*W+R*H+M*w,Z[5]=B*Y+L*G+R*V+M*c,Z[6]=B*Q+L*z+R*q+M*x,Z[7]=B*K+L*v+R*F+M*j,B=X[8],L=X[9],R=X[10],M=X[11],Z[8]=B*$+L*W+R*H+M*w,Z[9]=B*Y+L*G+R*V+M*c,Z[10]=B*Q+L*z+R*q+M*x,Z[11]=B*K+L*v+R*F+M*j,B=X[12],L=X[13],R=X[14],M=X[15],Z[12]=B*$+L*W+R*H+M*w,Z[13]=B*Y+L*G+R*V+M*c,Z[14]=B*Q+L*z+R*q+M*x,Z[15]=B*K+L*v+R*F+M*j,Z}var j6;(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"})(j6||(j6={}));function m$(Z,J){let X=Z.getAttribute("POSITION"),$=Z.getIndices();switch(J){case j6.RENDER:return $?$.getCount():X.getCount();case j6.RENDER_CACHED:return $?new Set($.getArray()).size:X.getCount();case j6.UPLOAD_NAIVE:case j6.UPLOAD:return X.getCount();case j6.DISTINCT:case j6.DISTINCT_POSITION:return zM1(J);case j6.UNUSED:return $?X.getCount()-new Set($.getArray()).size:0;default:return vM1(J)}}function zM1(Z){throw Error(`Not implemented: ${Z}`)}function vM1(Z){throw Error(`Unexpected value: ${Z}`)}var gJ=4294967295;class fs{constructor(Z){this.attributes=[],this.u8=void 0,this.u32=void 0;let J=0;for(let X of uw(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),$=Z.getElementSize()*Z.getComponentSize(),Y=E0.padNumber($);return this.attributes.push({u8:X,byteStride:$,paddedByteStride:Y}),Y}hash(Z){let J=0;for(let{u8:X,byteStride:$,paddedByteStride:Y}of this.attributes){for(let Q=0;Q<Y;Q++)if(Q<$)this.u8[J+Q]=X[Z*$+Q];else this.u8[J+Q]=0;J+=Y}return VM1(0,this.u32)}equal(Z,J){for(let{u8:X,byteStride:$}of this.attributes)for(let Y=0;Y<$;Y++)if(X[Z*$+Y]!==X[J*$+Y])return!1;return!0}}function VM1(Z,J){for(let Y=0,Q=J.length;Y<Q;Y++){let K=J[Y];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 HM1(Z,J,X,$,Y=gJ){let Q=J-1,W=X.hash($)&Q;for(let G=0;G<=Q;G++){let z=Z[W];if(z===Y||X.equal(z,$))return W;W=W+G+1&Q}throw Error("Hash table full.")}function dG(Z,J,X){let $=c6.fromGraph(Z.getGraph());if(!J||!X)[J,X]=qM1(Z);let Y=Z.getIndices(),Q=Y?Y.getArray():null,K=m$(Z,j6.RENDER),W=$.createAccessor(),G=K,z=hP(G,X);for(let H=0;H<G;H++)z[H]=J[Q?Q[H]:H];Z.setIndices(W.setArray(z));let v=uw(Z);for(let H of Z.listAttributes()){let V=MZ($,H);CP(H,Y,J,V,X),Z.swap(H,V)}for(let H of Z.listTargets())for(let V of H.listAttributes()){let q=MZ($,V);CP(V,Y,J,q,X),H.swap(V,q)}if(Y&&Y.listParents().length===1)Y.dispose();for(let H of v)if(H.listParents().length===1)H.dispose();return Z}function CP(Z,J,X,$,Y){let Q=Z.getElementSize(),K=Z.getArray(),W=J?J.getArray():null,G=J?J.getCount():Z.getCount(),z=new K.constructor(Y*Q),v=new Uint8Array(Y);for(let H=0;H<G;H++){let V=W?W[H]:H,q=X[V];if(v[q])continue;for(let F=0;F<Q;F++)z[q*Q+F]=K[V*Q+F];v[q]=1}return $.setArray(z)}function qM1(Z){let J=m$(Z,j6.UPLOAD),X=Z.getIndices(),$=X?X.getArray():null;if(!X||!$)return[XM1(J,1e6),J];let Y=new Uint32Array(J).fill(gJ),Q=0;for(let K=0;K<$.length;K++){let W=$[K];if(Y[W]===gJ)Y[W]=Q++}return[Y,Q]}function FM1(){var Z=new R3(9);if(R3!=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 wM1(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 cM1(Z,J){if(Z===J){var X=J[1],$=J[2],Y=J[5];Z[1]=J[3],Z[2]=J[6],Z[3]=X,Z[5]=J[7],Z[6]=$,Z[7]=Y}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 xM1(Z,J){var X=J[0],$=J[1],Y=J[2],Q=J[3],K=J[4],W=J[5],G=J[6],z=J[7],v=J[8],H=v*K-W*z,V=-v*Q+W*G,q=z*Q-K*G,F=X*H+$*V+Y*q;if(!F)return null;return F=1/F,Z[0]=H*F,Z[1]=(-v*$+Y*z)*F,Z[2]=(W*$-Y*K)*F,Z[3]=V*F,Z[4]=(v*X-Y*G)*F,Z[5]=(-W*X+Y*Q)*F,Z[6]=q*F,Z[7]=(-z*X+$*G)*F,Z[8]=(K*X-$*Q)*F,Z}function lw(){var Z=new R3(3);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0;return Z}function UM1(Z,J,X){return Z[0]=J[0]*X[0],Z[1]=J[1]*X[1],Z[2]=J[2]*X[2],Z}function ks(Z,J){var X=J[0],$=J[1],Y=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 jM1(Z,J,X){var $=J[0],Y=J[1],Q=J[2],K=X[3]*$+X[7]*Y+X[11]*Q+X[15];return K=K||1,Z[0]=(X[0]*$+X[4]*Y+X[8]*Q+X[12])/K,Z[1]=(X[1]*$+X[5]*Y+X[9]*Q+X[13])/K,Z[2]=(X[2]*$+X[6]*Y+X[10]*Q+X[14])/K,Z}function BM1(Z,J,X){var $=J[0],Y=J[1],Q=J[2];return Z[0]=$*X[0]+Y*X[3]+Q*X[6],Z[1]=$*X[1]+Y*X[4]+Q*X[7],Z[2]=$*X[2]+Y*X[5]+Q*X[8],Z}var LM1=UM1;(function(){var Z=lw();return function(J,X,$,Y,Q,K){var W,G;if(!X)X=3;if(!$)$=0;if(Y)G=Math.min(Y*X+$,J.length);else G=J.length;for(W=$;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 fP="weld",Sw={overwrite:!0};function SP(Z=Sw){let J=RZ(Sw,Z);return u$(fP,async(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes()){for(let Q of Y.listPrimitives())if(yw(Q,J),m$(Q,j6.RENDER)===0)Ps(Q);if(Y.listPrimitives().length===0)Y.dispose()}$.debug(`${fP}: Complete.`)})}function yw(Z,J=Sw){let X=Z.getGraph(),Y=c6.fromGraph(X).getLogger(),Q=M3({},Sw,J);if(Z.getIndices()&&!Q.overwrite)return;if(Z.getMode()===g1.Mode.POINTS)return;let K=Z.getAttribute("POSITION").getCount(),W=Z.getIndices(),G=W==null?void 0:W.getArray(),z=W?W.getCount():K,v=new fs(Z),H=$M1(K+K/4),V=new Uint32Array(H).fill(gJ),q=new Uint32Array(K).fill(gJ),F=0;for(let w=0;w<z;w++){let c=G?G[w]:w;if(q[c]!==gJ)continue;let x=HM1(V,H,v,c,gJ),j=V[x];if(j===gJ)V[x]=c,q[c]=F++;else q[c]=q[j]}Y.debug(`${fP}: ${mw(K,F)} vertices.`),dG(Z,q,F)}var{FLOAT:DM1}=K0.ComponentType;function Es(Z,J){let X=Z.getAttribute("POSITION");if(X)Gs(J,X);let $=Z.getAttribute("NORMAL");if($)zs(J,$);let Y=Z.getAttribute("TANGENT");if(Y)vs(J,Y);for(let Q of Z.listTargets()){let K=Q.getAttribute("POSITION");if(K)Gs(J,K);let W=Q.getAttribute("NORMAL");if(W)zs(J,W);let G=Q.getAttribute("TANGENT");if(G)vs(J,G)}if(GM1(J)<0)MM1(Z)}function Gs(Z,J){let X=J.getComponentType(),$=J.getNormalized(),Y=J.getArray(),Q=X===DM1?Y:new Float32Array(Y.length),K=lw();for(let W=0,G=J.getCount();W<G;W++){if($)K[0]=I0.decodeNormalizedInt(Y[W*3],X),K[1]=I0.decodeNormalizedInt(Y[W*3+1],X),K[2]=I0.decodeNormalizedInt(Y[W*3+2],X);else K[0]=Y[W*3],K[1]=Y[W*3+1],K[2]=Y[W*3+2];jM1(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(),$=J.getNormalized(),Y=J.getComponentType(),Q=FM1();wM1(Q,Z),xM1(Q,Q),cM1(Q,Q);let K=lw();for(let W=0,G=J.getCount();W<G;W++){if($)K[0]=I0.decodeNormalizedInt(X[W*3],Y),K[1]=I0.decodeNormalizedInt(X[W*3+1],Y),K[2]=I0.decodeNormalizedInt(X[W*3+2],Y);else K[0]=X[W*3],K[1]=X[W*3+1],K[2]=X[W*3+2];if(BM1(K,K,Q),ks(K,K),$)X[W*3]=I0.decodeNormalizedInt(K[0],Y),X[W*3+1]=I0.decodeNormalizedInt(K[1],Y),X[W*3+2]=I0.decodeNormalizedInt(K[2],Y);else X[W*3]=K[0],X[W*3+1]=K[1],X[W*3+2]=K[2]}}function vs(Z,J){let X=J.getArray(),$=J.getNormalized(),Y=J.getComponentType(),Q=lw();for(let K=0,W=J.getCount();K<W;K++){if($)Q[0]=I0.decodeNormalizedInt(X[K*4],Y),Q[1]=I0.decodeNormalizedInt(X[K*4+1],Y),Q[2]=I0.decodeNormalizedInt(X[K*4+2],Y);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],ks(Q,Q),$)X[K*4]=I0.decodeNormalizedInt(Q[0],Y),X[K*4+1]=I0.decodeNormalizedInt(Q[1],Y),X[K*4+2]=I0.decodeNormalizedInt(Q[2],Y);else X[K*4]=Q[0],X[K*4+1]=Q[1],X[K*4+2]=Q[2]}}function MM1(Z){if(Z.getMode()!==g1.Mode.TRIANGLES)return;if(!Z.getIndices())yw(Z);let J=Z.getIndices();for(let X=0,$=J.getCount();X<$;X+=3){let Y=J.getScalar(X),Q=J.getScalar(X+2);J.setScalar(X,Q),J.setScalar(X+2,Y)}}function RM1(Z,J){for(let X of Z.listPrimitives()){let $=PM1(X,Z);if(X!==$)Z.removePrimitive(X).addPrimitive($)}for(let X of Z.listPrimitives())dG(X),Es(X,J)}function PM1(Z,J){if(Z.listParents().some(($)=>$ instanceof NG&&$!==J))Z=Z.clone();for(let $ of Z.listTargets())if($.listParents().some((Q)=>Q instanceof g1&&Q!==Z))Z.removeTarget($).addTarget($.clone());return Z}var Vs=[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&&!I0.eq(X,Vs))RM1(J,X);for(let $ of Z.listChildren()){let Y=$.getMatrix();Cs(Y,Y,X),$.setMatrix(Y)}return Z.setMatrix(Vs)}var{LINES:NM1,LINE_STRIP:OM1,LINE_LOOP:TM1,TRIANGLES:CM1,TRIANGLE_STRIP:fM1,TRIANGLE_FAN:kM1}=g1.Mode;function EM1(Z){let J=Z.getGraph(),X=c6.fromGraph(J);if(!Z.getIndices())yw(Z);let $=Z.getIndices(),Y=$.getArray(),Q=Rs(Z),W=new bJ[$.getComponentType()](Q*2),G=Z.getMode();if(G===OM1)for(let v=0;v<Q;v++)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else if(G===TM1)for(let v=0;v<Q;v++)if(v<Q-1)W[v*2]=Y[v],W[v*2+1]=Y[v+1];else W[v*2]=Y[v],W[v*2+1]=Y[0];else throw Error("Only LINE_STRIP and LINE_LOOP may be converted to LINES.");Z.setMode(NM1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(MZ(X,$).setArray(W));else $.setArray(W)}function _s(Z){let J=Z.getGraph(),X=c6.fromGraph(J);if(!Z.getIndices())yw(Z);let $=Z.getIndices(),Y=$.getArray(),Q=Rs(Z),W=new bJ[$.getComponentType()](Q*3),G=Z.getMode();if(G===fM1)for(let v=0,H=Y.length;v<H-2;v++)if(v%2)W[v*3]=Y[v+1],W[v*3+1]=Y[v],W[v*3+2]=Y[v+2];else W[v*3]=Y[v],W[v*3+1]=Y[v+1],W[v*3+2]=Y[v+2];else if(G===kM1)for(let v=0;v<Q;v++)W[v*3]=Y[0],W[v*3+1]=Y[v+1],W[v*3+2]=Y[v+2];else throw Error("Only TRIANGLE_STRIP and TRIANGLE_FAN may be converted to TRIANGLES.");Z.setMode(CM1);let z=X.getRoot();if($.listParents().some((v)=>v!==z&&v!==Z))Z.setIndices(MZ(X,$).setArray(W));else $.setArray(W)}var rN6={keepUniqueNames:!1,propertyTypes:[i.ACCESSOR,i.MESH,i.TEXTURE,i.MATERIAL,i.SKIN]};var Hs="dequantize",bw={pattern:/^((?!JOINTS_).)*$/};function hs(Z=bw){let J=RZ(bw,Z);return u$(Hs,(X)=>{let $=X.getLogger();for(let Y of X.getRoot().listMeshes())for(let Q of Y.listPrimitives())IM1(Q,J);X.createExtension(iG).dispose(),$.debug(`${Hs}: Complete.`)})}function IM1(Z,J=bw){let X=RZ(bw,J);for(let $ of Z.listSemantics())if(X.pattern.test($))kP(Z.getAttribute($));for(let $ of Z.listTargets())for(let Y of $.listSemantics())if(X.pattern.test(Y))kP($.getAttribute(Y))}function kP(Z){let J=Z.getArray();if(!J)return;let X=Aw(J,Z.getComponentType(),Z.getNormalized());Z.setArray(X).setNormalized(!1)}function Aw(Z,J,X){let $=new Float32Array(Z.length);for(let Y=0,Q=Z.length;Y<Q;Y++)if(X)$[Y]=I0.decodeNormalizedInt(Z[Y],J);else $[Y]=Z[Y];return $}var{TEXTURE_INFO:Ss,ROOT:tN6}=i;function bs(Z){let J=new c6().setLogger(Z.getLogger()),X=bP(J,Z);return _M1(J,Z,X),J.getRoot().copy(Z.getRoot(),X),J}function _M1(Z,J,X){X||(X=bP(Z,J));for(let $ of J.getRoot().listExtensionsUsed()){let Y=Z.createExtension($.constructor);if($.isRequired())Y.setRequired(!0)}return hM1(Z,J,SM1(J),X)}function hM1(Z,J,X,$){$||($=bP(Z,J));let Y=new Map;for(let Q of X)if(!Y.has(Q)&&Q.propertyType!==Ss)Y.set(Q,$(Q));for(let[Q,K]of Y.entries())K.copy(Q,$);return Y}function bP(Z,J){let X=new Map([[J.getRoot(),Z.getRoot()]]);return($)=>{if($.propertyType===Ss)return $;let Y=X.get($);if(!Y)Y=new $.constructor(Z.getGraph()),X.set($,Y);return Y}}function SM1(Z){let J=new Set;for(let X of Z.getGraph().listEdges())J.add(X.getChild());return Array.from(J)}function As(){var Z=new R3(4);if(R3!=Float32Array)Z[0]=0,Z[1]=0,Z[2]=0,Z[3]=0;return Z}function bM1(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 AM1(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 mM1(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 uM1(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 lM1(Z){var J=Z[0],X=Z[1],$=Z[2],Y=Z[3];return Math.hypot(J,X,$,Y)}var ms=AM1,yM1=mM1,us=lM1;(function(){var Z=As();return function(J,X,$,Y,Q,K){var W,G;if(!X)X=4;if(!$)$=0;if(Y)G=Math.min(Y*X+$,J.length);else G=J.length;for(W=$;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 pM1=/color|emissive|diffuse/i;function iM1(Z){return Z.getGraph().listParentEdges(Z).some((Y)=>{return Y.getAttributes().isColor||pM1.test(Y.getName())})?"srgb":null}function gM1(Z){let J=Z.getGraph(),X=new Set,$=new Set;function Y(Q){let K=new Set;for(let W of J.listChildEdges(Q))if(W.getChild()instanceof _$)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 F1&&K.has(W.getName()))$.add(G);else if(G instanceof O1)Y(G)}}return Y(Z),Array.from($)}function dM1(Z){let X=c6.fromGraph(Z.getGraph()).getRoot(),$=Z.getGraph().listParentEdges(Z).filter((Y)=>Y.getParent()!==X).map((Y)=>Y.getName());return Array.from(new Set($))}var D3="prune",EP=0.011764705882352941,qs={propertyTypes:[i.NODE,i.SKIN,i.MESH,i.CAMERA,i.PRIMITIVE,i.PRIMITIVE_TARGET,i.ANIMATION,i.MATERIAL,i.TEXTURE,i.ACCESSOR,i.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function ls(Z=qs){let J=RZ(qs,Z),X=new Set(J.propertyTypes),$=J.keepExtras;return u$(D3,async(Y)=>{let Q=Y.getLogger(),K=Y.getRoot(),W=Y.getGraph(),G=new ys,z=(v)=>G.dispose(v.target);if(W.addEventListener("node:dispose",z),X.has(i.MESH))for(let v of K.listMeshes()){if(v.listPrimitives().length>0)continue;v.dispose()}if(X.has(i.NODE)){if(!J.keepLeaves)for(let v of K.listScenes())ps(W,v,$);for(let v of K.listNodes())L4(v,$)}if(X.has(i.SKIN))for(let v of K.listSkins())L4(v,$);if(X.has(i.MESH))for(let v of K.listMeshes())L4(v,$);if(X.has(i.CAMERA))for(let v of K.listCameras())L4(v,$);if(X.has(i.PRIMITIVE))Fs(W,i.PRIMITIVE,$);if(X.has(i.PRIMITIVE_TARGET))Fs(W,i.PRIMITIVE_TARGET,$);if(!J.keepAttributes&&X.has(i.ACCESSOR)){let v=new Map;for(let H of K.listMeshes())for(let V of H.listPrimitives()){let q=V.getMaterial();if(!q)continue;let F=is(Y,V,q),w=aM1(V,F);ws(V,w),V.listTargets().forEach((c)=>ws(c,w)),v.has(q)?v.get(q).add(V):v.set(q,new Set([V]))}for(let[H,V]of v)nM1(H,Array.from(V))}if(X.has(i.ANIMATION))for(let v of K.listAnimations()){for(let H of v.listChannels())if(!H.getTargetNode())H.dispose();if(!v.listChannels().length){let H=v.listSamplers();L4(v,$),H.forEach((V)=>L4(V,$))}else v.listSamplers().forEach((H)=>L4(H,$))}if(X.has(i.MATERIAL))K.listMaterials().forEach((v)=>L4(v,$));if(X.has(i.TEXTURE)){if(K.listTextures().forEach((v)=>L4(v,$)),!J.keepSolidTextures)await sM1(Y)}if(X.has(i.ACCESSOR))K.listAccessors().forEach((v)=>L4(v,$));if(X.has(i.BUFFER))K.listBuffers().forEach((v)=>L4(v,$));if(W.removeEventListener("node:dispose",z),!G.empty()){let v=G.entries().map(([H,V])=>`${H} (${V})`).join(", ");Q.info(`${D3}: Removed types... ${v}`)}else Q.debug(`${D3}: No unused properties found.`);Q.debug(`${D3}: Complete.`)})}class ys{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 L4(Z,J){let X=Z.listParents().filter((Y)=>!(Y instanceof W3||Y instanceof QZ)),$=J&&!Ns(Z.getExtras());if(!X.length&&!$)Z.dispose()}function Fs(Z,J,X){for(let $ of Z.listEdges()){let Y=$.getParent();if(Y.propertyType===J)L4(Y,X)}}function ps(Z,J,X){if(J.listChildren().forEach((K)=>ps(Z,K,X)),J instanceof K3)return;let $=Z.listParentEdges(J).some((K)=>{let W=K.getParent().propertyType;return W!==i.ROOT&&W!==i.SCENE&&W!==i.NODE}),Y=Z.listChildren(J).length===0,Q=X&&!Ns(J.getExtras());if(Y&&!$&&!Q)J.dispose()}function ws(Z,J){for(let X of J)Z.setAttribute(X,null)}function aM1(Z,J){let X=[];for(let $ of Z.listSemantics())if($==="NORMAL"&&!J.has($))X.push($);else if($==="TANGENT"&&!J.has($))X.push($);else if($.startsWith("TEXCOORD_")&&!J.has($))X.push($);else if($.startsWith("COLOR_")&&$!=="COLOR_0")X.push($);return X}function is(Z,J,X,$=new Set){let Q=Z.getGraph().listChildEdges(X),K=new Set;for(let z of Q)if(z.getChild()instanceof _$)K.add(z.getName());for(let z of Q){let v=z.getName(),H=z.getChild();if(H instanceof F1){if(K.has(v.replace(/Info$/,"")))$.add(`TEXCOORD_${H.getTexCoord()}`)}if(H instanceof _$&&v.match(/normalTexture/i))$.add("TANGENT");if(H instanceof O1)is(Z,J,H,$)}let W=X instanceof K7&&!X.getExtension("KHR_materials_unlit"),G=J.getMode()===g1.Mode.POINTS;if(W&&!G)$.add("NORMAL");return $}function nM1(Z,J){let X=gM1(Z),$=new Set(X.map((G)=>G.getTexCoord())),Y=Array.from($).sort(),Q=new Map(Y.map((G,z)=>[G,z])),K=new Map(Y.map((G,z)=>[`TEXCOORD_${G}`,`TEXCOORD_${z}`]));for(let G of X){let z=G.getTexCoord();G.setTexCoord(Q.get(z))}for(let G of J){let z=G.listSemantics().filter((v)=>v.startsWith("TEXCOORD_")).sort();W(G,z),G.listTargets().forEach((v)=>W(v,z))}function W(G,z){for(let v of z){let H=G.getAttribute(v);if(!H)continue;let V=K.get(v);if(V===v)continue;G.setAttribute(V,H),G.setAttribute(v,null)}}}async function sM1(Z){let J=Z.getRoot(),X=Z.getGraph(),$=Z.getLogger(),Q=J.listTextures().map(async(K)=>{var W;let G=await rM1(K);if(!G)return;if(iM1(K)==="srgb")HR.convertSRGBToLinear(G,G);let z=K.getName()||K.getURI(),v=(W=K.getSize())==null?void 0:W.join("x"),H=dM1(K);for(let V of X.listParentEdges(K)){let q=V.getParent();if(q!==J&&oM1(q,G,V.getName(),$))V.dispose()}if(K.listParents().length===1)K.dispose(),$.debug(`${D3}: Removed solid-color texture "${z}" (${v}px ${H.join(", ")})`)});await Promise.all(Q)}function oM1(Z,J,X,$){if(Z instanceof K7)switch(X){case"baseColorTexture":return Z.setBaseColorFactor(yM1(J,J,Z.getBaseColorFactor())),!0;case"emissiveTexture":return Z.setEmissiveFactor(LM1([0,0,0],J.slice(0,3),Z.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(J[0]-1)<=EP;case"metallicRoughnessTexture":return Z.setRoughnessFactor(J[1]*Z.getRoughnessFactor()),Z.setMetallicFactor(J[2]*Z.getMetallicFactor()),!0;case"normalTexture":return us(ms(As(),J,[0.5,0.5,1,1]))<=EP}return $.warn(`${D3}: Detected single-color ${X} texture. Pruning ${X} not yet supported.`),!1}async function rM1(Z){let J=await tM1(Z);if(!J)return null;let X=[1/0,1/0,1/0,1/0],$=[-1/0,-1/0,-1/0,-1/0],Y=[0,0,0,0],[Q,K]=J.shape;for(let W=0;W<Q;W++){for(let G=0;G<K;G++)for(let z=0;z<4;z++)X[z]=Math.min(X[z],J.get(W,G,z)),$[z]=Math.max($[z],J.get(W,G,z));if(us(ms(Y,$,X))/255>EP)return null}return uM1(Y,bM1(Y,$,X),0.00196078431372549)}async function tM1(Z){try{return await hn(Z.getImage(),Z.getMimeType())}catch(J){return null}}var PP="flatten",cs={cleanup:!0};function gs(Z=cs){let J=RZ(cs,Z);return u$(PP,async(X)=>{let $=X.getRoot(),Y=X.getLogger(),Q=new Set;for(let z of $.listSkins())for(let v of z.listJoints())Q.add(v);let K=new Set;for(let z of $.listAnimations())for(let v of z.listChannels()){let H=v.getTargetNode();if(H&&v.getTargetPath()!=="weights")K.add(H)}let W=new Set,G=new Set;for(let z of $.listScenes())z.traverse((v)=>{let H=v.getParentNode();if(!H)return;if(Q.has(H)||W.has(H))W.add(v);if(K.has(H)||G.has(H))G.add(v)});for(let z of $.listScenes())z.traverse((v)=>{if(K.has(v))return;if(W.has(v))return;if(G.has(v))return;KM1(v)});if(K.size)Y.debug(`${PP}: Flattening node hierarchies with TRS animation not yet supported.`);if(J.cleanup)await X.transform(ls({propertyTypes:[i.NODE],keepLeaves:!1}));Y.debug(`${PP}: Complete.`)})}function ds(Z){return PG(Z)}var eM1={skipValidation:!1},xs=4294967295,{LINE_STRIP:ZR1,LINE_LOOP:JR1,TRIANGLE_STRIP:XR1,TRIANGLE_FAN:$R1}=g1.Mode;function YR1(Z,J={}){let X=RZ(eM1,J),$=Z[0],Y=c6.fromGraph($.getGraph());if(!X.skipValidation&&new Set(Z.map(Os)).size>1)throw 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 ZR1:case JR1:EM1(q);break;case XR1:case $R1:_s(q);break}let Q=[],K=new Uint32Array(Z.length),W=0,G=0;for(let q=0;q<Z.length;q++){let F=Z[q],w=F.getIndices(),c=F.getAttribute("POSITION").getCount(),x=w?w.getArray():null,j=w?w.getCount():c,B=new Uint32Array(c).fill(xs);for(let L=0;L<j;L++){let R=x?x[L]:L;if(B[R]===xs)B[R]=W++,K[q]++}Q.push(B),G+=j}let z=Y.createPrimitive().setMode($.getMode()).setMaterial($.getMaterial());for(let q of $.listSemantics()){let F=$.getAttribute(q),w=bJ[F.getComponentType()],c=MZ(Y,F).setArray(new w(W*F.getElementSize()));z.setAttribute(q,c)}let v=$.getIndices(),H=v?MZ(Y,v).setArray(hP(G,W)):null;z.setIndices(H);let V=0;for(let q=0;q<Q.length;q++){let F=Z[q],w=F.getIndices(),c=w?w.getCount():-1,x=Q[q];if(w&&H)KR1(w,x,H,V),V+=c;for(let j of z.listSemantics()){let B=F.getAttribute(j),L=z.getAttribute(j);QR1(B,w,x,L)}}return z}function QR1(Z,J,X,$){let Y=Z.getElementSize(),Q=J?J.getArray():null,K=Z.getCount(),W=Z.getArray(),G=$.getArray(),z=new Uint8Array(Z.getCount());for(let v=0,H=J?J.getCount():K;v<H;v++){let V=Q?Q[v]:v,q=X[V];if(z[q])continue;for(let F=0;F<Y;F++)G[q*Y+F]=W[V*Y+F];z[q]=1}}function KR1(Z,J,X,$){let Y=Z.getCount(),Q=Z.getArray(),K=X.getArray();for(let W=0;W<Y;W++){let G=Q[W],z=J[G];K[$+W]=z}}var IP="join",{ROOT:WR1,NODE:GR1,MESH:zR1,PRIMITIVE:vR1,ACCESSOR:VR1}=i,NP=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Us={keepMeshes:!1,keepNamed:!1,cleanup:!0,filter:()=>!0};function as(Z=Us){let J=RZ(Us,Z);return u$(IP,async(X)=>{let $=X.getRoot(),Y=X.getLogger();for(let Q of $.listScenes())js(X,Q,J),Q.traverse((K)=>js(X,K,J));if(J.cleanup)await X.transform(ls({propertyTypes:[GR1,zR1,vR1,VR1],keepAttributes:!0,keepIndices:!0,keepLeaves:!1}));Y.debug(`${IP}: Complete.`)})}function js(Z,J,X){let $=Z.getLogger(),Y={},Q=J.listChildren();for(let G=0;G<Q.length;G++){let z=Q[G];if(!X.filter(z))continue;if(z.listParents().some((V)=>V instanceof QZ))continue;let H=z.getMesh();if(!H)continue;if(z.getExtension("EXT_mesh_gpu_instancing"))continue;if(z.getSkin())continue;for(let V of H.listPrimitives()){if(V.listTargets().length>0)continue;let q=V.getMaterial();if(q&&q.getExtension("KHR_materials_volume"))continue;dG(V),qR1(V);let F=Os(V),w=H.getName()||z.getName();if(X.keepMeshes||X.keepNamed&&w)F+=`|${G}`;if(!(F in Y))Y[F]={prims:[],primMeshes:[],primNodes:[],dstNode:z,dstMesh:void 0};let c=Y[F];c.prims.push(V),c.primNodes.push(z)}}let K=Object.values(Y).filter(({prims:G})=>G.length>1),W=new Set(K.flatMap((G)=>G.primNodes));for(let G of W){let z=G.getMesh();if(z.listParents().some((H)=>{return H.propertyType!==WR1&&G!==H}))G.setMesh(z.clone())}for(let G of K){let{dstNode:z,primNodes:v}=G;G.dstMesh=z.getMesh(),G.primMeshes=v.map((H)=>H.getMesh())}for(let G of K){let{prims:z,primNodes:v,primMeshes:H,dstNode:V,dstMesh:q}=G,F=V.getMatrix();for(let x=0;x<z.length;x++){let j=v[x],B=H[x],L=z[x];if(B.removePrimitive(L),TP(L))L=z[x]=HR1(z[x]);if(j!==V)Cs(NP,WM1(NP,F),j.getMatrix()),Es(L,NP)}let w=YR1(z),c=w.listAttributes()[0].getCount();q.addPrimitive(w),$.debug(`${IP}: Joined Primitives (${z.length}) containing ${OP(c)} vertices under Node "${V.getName()}".`)}}function HR1(Z){let J=Z.clone();for(let $ of J.listSemantics())J.setAttribute($,J.getAttribute($).clone());let X=J.getIndices();if(X)J.setIndices(X.clone());return J}function qR1(Z){for(let J of["POSITION","NORMAL","TANGENT"]){let X=Z.getAttribute(J);if(X)kP(X)}}var{TRANSLATION:eN6,ROTATION:ZO6,SCALE:JO6,WEIGHTS:XO6}=QZ.TargetPath;var FR1={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};var $O6=M3({level:"high"},FR1);var wR1="unweld";function cR1(Z,J=new Map){let X=Z.getIndices();if(!X)return;let $=Z.getGraph(),Y=c6.fromGraph($),Q=Y.getLogger(),K=Z.getAttribute("POSITION").getCount();for(let G of Z.listAttributes())if(Z.swap(G,Bs(Y,G,X,J)),G.listParents().length===1)G.dispose();for(let G of Z.listTargets())for(let z of G.listAttributes())if(G.swap(z,Bs(Y,z,X,J)),z.listParents().length===1)z.dispose();let W=Z.getAttribute("POSITION").getCount();if(Q.debug(`${wR1}: ${mw(K,W)} vertices.`),Z.setIndices(null),X.listParents().length===1)X.dispose()}function Bs(Z,J,X,$){if($.has(J)&&$.get(J).has(X))return $.get(J).get(X);let Y=J.getArray(),K=new Y.constructor(X.getCount()*J.getElementSize()),W=X.getArray(),G=J.getElementSize();for(let v=0,H=X.getCount();v<H;v++)for(let V=0;V<G;V++)K[v*G+V]=Y[W[v]*G+V];if(!$.has(J))$.set(J,new Map);let z=MZ(Z,J).setArray(K);return $.get(J).set(X,z),z}var Ls;(function(Z){Z[Z.STEP=0]="STEP",Z[Z.LERP=1]="LERP",Z[Z.SLERP=2]="SLERP"})(Ls||(Ls={}));var xR1=0.000001;function UR1(Z,J,X,$=0.0001){let Y=J.length/Z.length,Q=Array(Y).fill(0),K=Array(Y).fill(0),W=Array(Y).fill(0),G=Array(Y).fill(0),z=Z.length-1,v=1;for(let H=1;H<z;++H){let V=Z[v-1],q=Z[H],F=Z[H+1],w=(q-V)/(F-V),c=!1;if(q!==F&&(H!==1||q!==Z[0])){if(gG(J,v-1,G),gG(J,H,K),gG(J,H+1,W),X==="slerp"){let x=LR1(Q,G,W,w),j=Ms(G,K)+Ms(K,W);c=!hw(K,x,$)||j+Number.EPSILON>=Math.PI}else if(X==="lerp"){let x=BR1(Q,G,W,w);c=!hw(K,x,$)}else if(X==="step")c=!hw(K,G)||!hw(K,W)}if(c){if(H!==v)Z[v]=Z[H],Ds(J,v,gG(J,H,Q));v++}}if(z>0)Z[v]=Z[z],Ds(J,v,gG(J,z,Q)),v++;return v}function gG(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)X[$]=Z[J*Y+$];return X}function Ds(Z,J,X){for(let $=0,Y=X.length;$<Y;$++)Z[J*Y+$]=X[$]}function hw(Z,J,X=0){if(Z.length!==J.length)return!1;for(let $=0;$<Z.length;$++)if(Math.abs(Z[$]-J[$])>X)return!1;return!0}function jR1(Z,J,X){return Z*(1-X)+J*X}function BR1(Z,J,X,$){for(let Y=0;Y<J.length;Y++)Z[Y]=jR1(J[Y],X[Y],$);return Z}function LR1(Z,J,X,$){let Y=J[0],Q=J[1],K=J[2],W=J[3],G=X[0],z=X[1],v=X[2],H=X[3],V,q,F,w,c;if(q=Y*G+Q*z+K*v+W*H,q<0)q=-q,G=-G,z=-z,v=-v,H=-H;if(1-q>xR1)V=Math.acos(q),F=Math.sin(V),w=Math.sin((1-$)*V)/F,c=Math.sin($*V)/F;else w=1-$,c=$;return Z[0]=w*Y+c*G,Z[1]=w*Q+c*z,Z[2]=w*K+c*v,Z[3]=w*W+c*H,Z}function Ms(Z,J){let X=DR1(Z,J);return Math.acos(2*X*X-1)}function DR1(Z,J){return Z[0]*J[0]+Z[1]*J[1]+Z[2]*J[2]+Z[3]*J[3]}var YO6=new Float32Array(0),QO6={ready:Promise.resolve(),resample:UR1,tolerance:0.0001,cleanup:!0};var A$="simplify",{POINTS:ns,LINES:MR1,LINE_STRIP:RR1,LINE_LOOP:PR1,TRIANGLES:NR1,TRIANGLE_STRIP:ss,TRIANGLE_FAN:os}=g1.Mode,rs={ratio:0,error:0.0001,lockBorder:!1};function ts(Z){let J=RZ(rs,Z),X=J.simplifier;if(!X)throw Error(`${A$}: simplifier dependency required — install "meshoptimizer".`);return u$(A$,async($)=>{let Y=$.getLogger();await X.ready,await $.transform(SP({overwrite:!1}));let Q=0;for(let K of $.getRoot().listMeshes()){for(let W of K.listPrimitives()){let G=W.getMode();if(G!==NR1&&G!==ss&&G!==os&&G!==ns){Q++;continue}if(OR1(W,J),m$(W,j6.RENDER)===0)Ps(W)}if(K.listPrimitives().length===0)K.dispose()}if(Q>0)Y.warn(`${A$}: Skipped ${Q} primitives: Unsupported draw mode.`);Y.debug(`${A$}: Complete.`)})}function OR1(Z,J){let X=M3({},rs,J),$=X.simplifier,Y=Z.getGraph(),Q=c6.fromGraph(Y),K=Q.getLogger();switch(Z.getMode()){case ns:return TR1(Q,Z,X);case MR1:case RR1:case PR1:return K.warn(`${A$}: Skipping primitive simplification: Unsupported draw mode.`),Z;case ss:case os:_s(Z);break}let W=m$(Z,j6.UPLOAD),G=m$(Z,j6.RENDER);if(G<W/2)dG(Z);let z=Z.getAttribute("POSITION"),v=Z.getIndices(),H=z.getArray(),V=v.getArray();if(!(H instanceof Float32Array))H=Aw(H,z.getComponentType(),z.getNormalized());if(!(V instanceof Uint32Array))V=new Uint32Array(V);let q=Math.floor(X.ratio*G/3)*3,F=X.lockBorder?["LockBorder"]:[],[w,c]=$.simplify(V,H,3,q,X.error,F);if(Z.setIndices(MZ(Q,v).setArray(w)),v.listParents().length===1)v.dispose();dG(Z);let x=m$(Z,j6.UPLOAD);if(x<=65534)Z.getIndices().setArray(new Uint16Array(Z.getIndices().getArray()));return K.debug(`${A$}: ${mw(W,x)} vertices, error: ${c.toFixed(4)}.`),Z}function TR1(Z,J,X){let $=X.simplifier,Y=Z.getLogger();if(J.getIndices())cR1(J);let K=J.getAttribute("POSITION"),W=J.getAttribute("COLOR_0"),G=K.getCount(),z=K.getArray(),v=W?W.getArray():void 0,H=W?W.getComponentSize():void 0;if(!(z instanceof Float32Array))z=Aw(z,K.getComponentType(),K.getNormalized());if(v&&!(v instanceof Float32Array))v=Aw(v,K.getComponentType(),K.getNormalized());let V=Math.floor(X.ratio*G),q=$.simplifyPoints(z,3,V,v,H),[F,w]=$.compactMesh(q);Y.debug(`${A$}: ${mw(K.getCount(),w)} vertices.`);for(let c of uw(J)){let x=MZ(Z,c);if(CP(c,null,F,x,w),JM1(J,c,x),c.listParents().length===1)c.dispose()}return J}var _P;(function(Z){Z.LANCZOS3="lanczos3",Z.LANCZOS2="lanczos2"})(_P||(_P={}));var KO6={resizeFilter:_P.LANCZOS3,pattern:void 0,formats:void 0,slots:void 0,quality:void 0,effort:void 0,lossless:!1,nearLossless:!1,limitInputPixels:!0};var Qo=t(Yo(),1);var PZ={OPTIMIZED_DIR:".optimized",CHECKSUM_EXT:".md5",DATA_SCHEMA_VERSION:1,DATA_EXT:".data.json",DIRECTORIES:[(()=>{try{return q5.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js"))}catch{return null}})(),q5.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 B6{static instance=new B6;optimize=!0;optimizeEveryStart=!1;_modelUriAnimationNames=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...`);let J=performance.now();for(let $ of Z){if(this.optimize)await this._resolveOptimizedModelPath($);await this._loadModelData($)}let X=performance.now();console.log(`ModelRegistry.preloadModels(): Preloaded ${Z.length} models in ${X-J}ms!`)}getAnimationNames(Z){let J=this._modelUriAnimationNames.get(Z);if(!J)p.fatalError(`ModelRegistry.getAnimationNames(): Model ${Z} not found!`);return J}getBoundingBox(Z){let J=this._modelUriBoundingBoxes.get(Z);if(!J)p.fatalError(`ModelRegistry.getBoundingBox(): Model ${Z} not found!`);return J}getDepth(Z){let J=this.getBoundingBox(Z);return J.max.z-J.min.z}getHeight(Z){let J=this.getBoundingBox(Z);return J.max.y-J.min.y}getNodeNames(Z){let J=this._modelUriNodeNames.get(Z);if(!J)p.fatalError(`ModelRegistry.getNodeNames(): Model ${Z} not found!`);return J}getTrimesh(Z,J=1){let X=this._modelUriTrimeshes.get(Z);if(!X){p.error(`ModelRegistry.getTrimesh(): Model ${Z} not found!`);return}let $=X.vertices;if(J!==1){$=new Float32Array($.length);for(let Y=0;Y<$.length;Y++)$[Y]=X.vertices[Y]*J}return{vertices:$,indices:X.indices}}getWidth(Z){let J=this.getBoundingBox(Z);return J.max.x-J.min.x}modelHasNode(Z,J){let X=this._modelUriNodeNames.get(Z);if(!X)p.fatalError(`ModelRegistry.modelHasNode(): Model ${Z} not found!`);return X.includes(J)}_absoluteModelPathToModelUri(Z){let J=q5.normalize(Z);for(let X of PZ.DIRECTORIES){let $=q5.normalize(X);if(J.startsWith($))return q5.relative($,J).replace(/\\/g,"/")}return q5.basename(J)}async _getAbsoluteModelPaths(){let Z=[];for(let J of PZ.DIRECTORIES){let X=q5.resolve(process.cwd(),J);if(!D4.existsSync(X))continue;let $=await uF("**/*.{gltf,glb}",{cwd:X,follow:!0});for(let Y of $)Z.push(q5.join(X,Y))}return Z}async _loadModelData(Z){let X=`${this._buildOptimizedModelPath(Z)}${PZ.DATA_EXT}`,$=this._absoluteModelPathToModelUri(Z),Y=this._calculateChecksum(Z),Q;if(D4.existsSync(X))try{let K=D4.readFileSync(X,"utf8"),W=JSON.parse(K);if(W?.schemaVersion!==PZ.DATA_SCHEMA_VERSION)throw Error("ModelRegistry._loadModelData(): Schema version mismatch! Data will be regenerated..");if(W?.source?.sha256!==Y)throw Error("ModelRegistry._loadModelData(): Checksum mismatch! Data will be regenerated..");Q=W}catch{}if(!Q){let K=await new xR().read(Z),W=ds(K.getRoot().listScenes()[0]),G=K.getRoot().listNodes().map((H)=>H.getName()),z=K.getRoot().listAnimations().map((H)=>H.getName()),v=await this._buildTrimesh(K);Q={schemaVersion:PZ.DATA_SCHEMA_VERSION,source:{uri:$,sha256:Y},animationNames:z,boundingBox:{min:{x:W.min[0],y:W.min[1],z:W.min[2]},max:{x:W.max[0],y:W.max[1],z:W.max[2]}},nodeNames:G,trimesh:v?{vertices:Array.from(v.vertices),indices:Array.from(v.indices)}:void 0};try{let H=q5.dirname(X);D4.mkdirSync(H,{recursive:!0}),D4.writeFileSync(X,JSON.stringify(Q))}catch(H){p.warning(`ModelRegistry._loadModelData(): Failed to write data file for ${$}. Error: ${String(H)}`)}}this._modelUriAnimationNames.set($,Q.animationNames),this._modelUriBoundingBoxes.set($,Q.boundingBox),this._modelUriNodeNames.set($,Q.nodeNames),this._modelUriTrimeshes.set($,Q.trimesh?{vertices:new Float32Array(Q.trimesh.vertices),indices:new Uint32Array(Q.trimesh.indices)}:void 0)}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)}${PZ.CHECKSUM_EXT}`;if(!D4.existsSync(J))return!1;let X=this._calculateChecksum(Z),$=D4.readFileSync(J,"utf8");return X===$}_calculateChecksum(Z){if(!D4.existsSync(Z))return"";let J=D4.readFileSync(Z);return IR1.createHash("sha256").update(J.toString("base64")).digest("hex")}_buildOptimizedModelPath(Z){let J=q5.basename(Z),X=J.replace(/\.[^/.]+$/,""),$=q5.dirname(Z),Y=q5.join($,PZ.OPTIMIZED_DIR,X);return q5.join(Y,J)}async _buildTrimesh(Z,J=1,X=0.001){let $=bs(Z);$.setLogger(new z5(MG.WARN)),await $.transform(Ts({pivot:"center"}),gs(),as(),SP(),ts({simplifier:Qo.MeshoptSimplifier,ratio:J,error:X}),hs());for(let V of $.getRoot().listScenes())for(let q of V.listChildren())Is(q);let Y=[],Q=0,K=0;for(let V of $.getRoot().listMeshes())for(let q of V.listPrimitives()){let F=q.getAttribute("POSITION"),w=q.getIndices();if(!F||!w)continue;let c=F.getArray(),x=w.getArray(),j=x instanceof Uint32Array?x:new Uint32Array(x);if(c.length===0||j.length===0)continue;Y.push({vertices:c,indices:j}),Q+=c.length,K+=j.length}if(Y.length===0){p.error("ModelRegistry._buildTrimesh(): Model has no primitives with POSITION and INDICES!");return}let W=new Float32Array(Q),G=new Uint32Array(K),z=0,v=0,H=0;for(let V of Y){W.set(V.vertices,z);let q=V.vertices.length/3;for(let F=0;F<V.indices.length;F++)G[H+F]=V.indices[F]+v;z+=V.vertices.length,H+=V.indices.length,v+=q}return{vertices:W,indices:G}}async _optimizeModel(Z,J){let X=q5.dirname(J);D4.rmSync(X,{recursive:!0,force:!0}),D4.mkdirSync(X,{recursive:!0}),console.log(`ModelRegistry: Optimizing model ${this._absoluteModelPathToModelUri(Z)}...`);for(let $ of PZ.OPTIMIZER_RUNS){let Y=J.replace(/(\.[^/.]+)$/,`${$.suffix}$1`),{stderr:Q}=await Bi("npx",["@gltf-transform/cli","optimize",Z,Y,...$.options]);if(Q)return p.warning(`ModelRegistry._optimizeModel(): Error optimizing model ${this._absoluteModelPathToModelUri(Z)}, defaulting to unoptimized model. Error: ${Q}`),Z}return D4.writeFileSync(`${J}${PZ.CHECKSUM_EXT}`,this._calculateChecksum(Z)),J}}var rG;((Y)=>{Y.DYNAMIC="dynamic";Y.FIXED="fixed";Y.KINEMATIC_POSITION="kinematic_position";Y.KINEMATIC_VELOCITY="kinematic_velocity"})(rG||={});var yP=0.001,Ko="dynamic";class dJ extends j0{_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??=Ko,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:$}=this.rotation;return{x:-2*(Z*X+$*J),y:-2*(J*X-$*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 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 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:$,principalAngularInertiaLocalFrame:Y}=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"]:X1.RigidBodyType.Dynamic,["fixed"]:X1.RigidBodyType.Fixed,["kinematic_position"]:X1.RigidBodyType.KinematicPositionBased,["kinematic_velocity"]:X1.RigidBodyType.KinematicVelocityBased}[Z];if(X===void 0)return p.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 p.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 A5({...Z,parentRigidBody:this,simulation:this._simulation}):this._createAndAddPendingChildCollider(Z)}createAndAddChildColliders(Z){let J=[];return Z.forEach((X)=>{let $=this.createAndAddChildCollider(X);if($)J.push($)}),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 p.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 p.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 p.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,$])=>{if(X in Z)$(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 A5(Z);return this._colliders.add(J),J}_createAndAddPendingChildColliders(Z){let J=[];return Z.forEach((X)=>{let $=this._createAndAddPendingChildCollider(X);if($)J.push($)}),J}_createRigidBodyDesc(Z){let J=Z.type??Ko;return{["dynamic"]:()=>X1.RigidBodyDesc.dynamic(),["fixed"]:()=>X1.RigidBodyDesc.fixed(),["kinematic_position"]:()=>X1.RigidBodyDesc.kinematicPositionBased(),["kinematic_velocity"]:()=>X1.RigidBodyDesc.kinematicVelocityBased()}[J]()}_requireCreated(Z){if(!this._rigidBody||!this._simulation)p.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)p.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)p.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)p.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)p.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)p.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)<yP&&Math.abs(Z.y)<yP&&Math.abs(Z.z)<yP}}var pP;((Y)=>{Y[Y.Average=0]="Average";Y[Y.Min=1]="Min";Y[Y.Multiply=2]="Multiply";Y[Y.Max=3]="Max"})(pP||={});var P3;((v)=>{v.NONE="none";v.BALL="ball";v.BLOCK="block";v.CAPSULE="capsule";v.CONE="cone";v.CYLINDER="cylinder";v.ROUND_CYLINDER="round-cylinder";v.TRIMESH="trimesh";v.VOXELS="voxels";v.WEDGE="wedge"})(P3||={});class A5 extends j0{_collider;_colliderDesc;_onCollision;_parentRigidBody;_relativePosition={x:0,y:0,z:0};_relativeRotation={x:0,y:0,z:0,w:1};_shape;_simulation;_tag;constructor(Z){super();this._colliderDesc=this._createColliderDesc(Z),this._shape=Z.shape,this._applyColliderOptions(Z),this._autoAddToSimulation(Z)}static optionsFromBlockHalfExtents(Z){return{shape:"block",halfExtents:Z}}static optionsFromModelUri(Z,J=1,X){let $=B6.instance.getBoundingBox(Z),Y=$.max.x-$.min.x,Q=$.max.y-$.min.y,K=$.max.z-$.min.z,W=Math.max(Y,K),G=Math.min(Y,K),z=W/G,v=W/Q,H=W*J/2,V=(j)=>Math.max(0.01,j),q=()=>({shape:"block",halfExtents:{x:V(Y*J/2),y:V(Q*J/2),z:V(K*J/2)}}),F=()=>({shape:"round-cylinder",radius:V(H),halfHeight:V(Q*J/2),borderRadius:V(H*0.1)}),w=()=>{let j=B6.instance.getTrimesh(Z,J);if(!j)return;return{shape:"trimesh",vertices:j.vertices,indices:j.indices}},c=()=>({shape:"wedge",extents:{x:Y*J,y:Q*J,z:K*J}}),x=()=>({shape:"capsule",radius:V(H),halfHeight:V(Q*J/2-H)});if(X)switch(X){case"block":return q();case"capsule":return x();case"round-cylinder":return F();case"trimesh":{let j=w();if(!j){p.error(`Collider.optionsFromModelUri(): Failed to create trimesh options for model ${Z}, falling back to generic shape!`);break}return j}case"wedge":return c();default:p.warning(`Collider.optionsFromModelUri(): Preferred shape ${X} is not yet supported with Collider.optionsFromModelUri(), defaulting to generic shape!`)}if(z>2)return q();if(v>1.5)return F();return x()}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?v9.decodeRawCollisionGroups(this._collider.collisionGroups()):v9.decodeRawCollisionGroups(this._colliderDesc.collisionGroups)}get friction(){if(!this._requireNotRemoved("friction"))return 0;return this._collider?this._collider.friction():this._colliderDesc.friction}get frictionCombineRule(){if(!this._requireNotRemoved("frictionCombineRule"))return 0;return this._collider?this._collider.frictionCombineRule():this._colliderDesc.frictionCombineRule}get isEnabled(){if(!this._requireNotRemoved("isEnabled"))return!1;return this._collider?this._collider.isEnabled():this._colliderDesc.enabled}get isRemoved(){return!this._collider&&!this._colliderDesc}get isSensor(){if(!this._requireNotRemoved("isSensor"))return!1;return this._collider?this._collider.isSensor():this._colliderDesc.isSensor}get isSimulated(){if(!this._requireNotRemoved("isSimulated"))return!1;return!!this._collider}get parentRigidBody(){if(!this._requireNotRemoved("parentRigidBody"))return;return this._parentRigidBody}get rawCollider(){if(!this._requireNotRemoved("rawCollider"))return;return this._collider}get rawShape(){if(!this._requireNotRemoved("rawShape"))return;return this._collider?this._collider.shape:this._colliderDesc.shape}get relativePosition(){if(!this._requireNotRemoved("relativePosition"))return{x:0,y:0,z:0};return this._relativePosition}get relativeRotation(){if(!this._requireNotRemoved("relativeRotation"))return{x:0,y:0,z:0,w:1};return this._relativeRotation}get shape(){if(!this._requireNotRemoved("shape"))return"none";return this._shape}get tag(){if(!this._requireNotRemoved("tag"))return;return this._tag}setBounciness(Z){if(!this._requireNotRemoved("setBounciness"))return;this._collider?this._collider.setRestitution(Z):this._colliderDesc.setRestitution(Z)}setBouncinessCombineRule(Z){if(!this._requireNotRemoved("setBouncinessCombineRule"))return;this._collider?this._collider.setRestitutionCombineRule(Z):this._colliderDesc.setRestitutionCombineRule(Z)}setCollisionGroups(Z){if(!this._requireNotRemoved("setCollisionGroups"))return;let J=v9.buildRawCollisionGroups(Z);this._collider?this._collider.setCollisionGroups(J):this._colliderDesc.setCollisionGroups(J)}setEnabled(Z){if(!this._requireNotRemoved("setEnabled"))return;this._collider?this._collider.setEnabled(Z):this._colliderDesc.setEnabled(Z)}setFriction(Z){if(!this._requireNotRemoved("setFriction"))return;this._collider?this._collider.setFriction(Z):this._colliderDesc.setFriction(Z)}setFrictionCombineRule(Z){if(!this._requireNotRemoved("setFrictionCombineRule"))return;this._collider?this._collider.setFrictionCombineRule(Z):this._colliderDesc.setFrictionCombineRule(Z)}setMass(Z){if(!this._requireNotRemoved("setMass"))return;this._collider?this._collider.setMass(Z):this._colliderDesc.setMass(Z)}setOnCollision(Z){if(!this._requireNotRemoved("setOnCollision"))return;if(this._onCollision=Z,this.isSimulated)if(this.enableCollisionEvents(!!Z),Z)this._simulation.colliderMap.setColliderCollisionCallback(this,Z);else this._simulation.colliderMap.removeColliderCollisionCallback(this)}setRelativeRotation(Z){if(!this._requireNotRemoved("setRelativeRotation"))return;this._relativeRotation=Z,this._collider?this._collider.parent()?this._collider.setRotationWrtParent(Z):this._collider.setRotation(Z):this._colliderDesc.setRotation(Z)}setRelativePosition(Z){if(!this._requireNotRemoved("setRelativePosition"))return;this._relativePosition=Z,this._collider?this._collider.parent()?this._collider.setTranslationWrtParent(Z):this._collider.setTranslation(Z):this._colliderDesc.setTranslation(Z.x,Z.y,Z.z)}setSensor(Z){if(!this._requireNotRemoved("setSensor"))return;this._collider?this._collider.setSensor(Z):this._colliderDesc.setSensor(Z)}setTag(Z){if(!this._requireNotRemoved("setTag"))return;this._tag=Z}setVoxel(Z,J){if(!this._requireNotRemoved("setVoxel"))return;if(!this._requireSimulated("setVoxel"))return;if(this.shape!=="voxels")return p.error("Collider.setVoxel(): Collider is not a voxels collider!");this._collider.setVoxel(Z.x,Z.y,Z.z,J)}addToSimulation(Z,J){if(!this._requireNotRemoved("addToSimulation"))return;if(!this._requireUnsimulated("addToSimulation"))return;if(J){if(!J.isSimulated)return p.error("Collider.addToSimulation(): Rigid body must be simulated before adding a collider to it!");if(J.type==="dynamic"&&this.shape==="trimesh")p.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)}combineVoxelStates(Z){if(!this._requireNotRemoved("combineVoxelStates"))return;if(!this._requireSimulated("combineVoxelStates"))return;if(!Z.isSimulated)return p.error("Collider.combineVoxelStates(): Other collider is not simulated!");if(this.shape!=="voxels")return p.error("Collider.combineVoxelStates(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return p.error("Collider.combineVoxelStates(): Other collider is not a voxels collider!");this._collider.combineVoxelStates(Z.rawCollider,0,0,0)}enableCollisionEvents(Z){if(!this._requireNotRemoved("enableCollisionEvents"))return;let J=this._collider?this._collider.activeEvents():this._colliderDesc.activeEvents,X=Z?J|X1.ActiveEvents.COLLISION_EVENTS:J&~X1.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|X1.ActiveEvents.CONTACT_FORCE_EVENTS:J&~X1.ActiveEvents.CONTACT_FORCE_EVENTS;(this._collider??this._colliderDesc).setActiveEvents(X),this._setActiveCollisionTypes()}propagateVoxelChange(Z,J){if(!this._requireNotRemoved("propagateVoxelChange"))return;if(!this._requireSimulated("propagateVoxelChange"))return;if(!Z.isSimulated)return p.error("Collider.propagateVoxelChange(): Other collider is not simulated!");if(this.shape!=="voxels")return p.error("Collider.propagateVoxelChange(): Collider is not a voxels collider!");if(Z.shape!=="voxels")return p.error("Collider.propagateVoxelChange(): Other collider is not a voxels collider!");this._collider.propagateVoxelChange(Z.rawCollider,J.x,J.y,J.z,0,0,0)}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}scale(Z){if(!this._requireNotRemoved("scale"))return;switch(this.setRelativePosition({x:this.relativePosition.x*Z,y:this.relativePosition.y*Z,z:this.relativePosition.z*Z}),this._shape){case"ball":{if(this._collider)this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.radius*=Z;return}case"block":{if(this._collider){let J=this._collider.halfExtents();this._collider.setHalfExtents({x:J.x*Z,y:J.y*Z,z:J.z*Z})}else this._colliderDesc.shape.halfExtents.x*=Z,this._colliderDesc.shape.halfExtents.y*=Z,this._colliderDesc.shape.halfExtents.z*=Z;return}case"capsule":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cone":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight*=Z,this._colliderDesc.shape.radius*=Z;return}case"round-cylinder":{if(this._collider)this._collider.setHalfHeight(this._collider.halfHeight()*Z),this._collider.setRoundRadius(this._collider.roundRadius()*Z),this._collider.setRadius(this._collider.radius()*Z);else this._colliderDesc.shape.halfHeight=this._colliderDesc.shape.halfHeight*Z,this._colliderDesc.shape.borderRadius=this._colliderDesc.shape.borderRadius*Z,this._colliderDesc.shape.radius=this._colliderDesc.shape.radius*Z;return}case"trimesh":{p.error("Collider.setScale(): Trimesh colliders cannot be scaled!");return}case"voxels":{p.error("Collider.setScale(): Voxels colliders cannot be scaled!");return}case"wedge":{p.error("Collider.setScale(): Wedge colliders cannot be scaled!");return}default:p.fatalError(`Collider.setScale(): ${this._shape} is not a valid collider shape!`)}}_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,$])=>{if(Z[X]!==void 0)$.call(this,Z[X])})}_autoAddToSimulation(Z){if(Z.simulation)this.addToSimulation(Z.simulation,Z.parentRigidBody)}_buildWedgeConvexHullVertices(Z){let{x:J,y:X,z:$}=Z,Y=J/2,Q=$/2,K=X/2;return new Float32Array([-Y,0-K,-Q,Y,0-K,-Q,Y,0-K,Q,-Y,0-K,Q,-Y,X-K,-Q,Y,X-K,-Q])}_createColliderDesc(Z){let{shape:J,flags:X}=Z;switch(J){case"ball":{if(!Z.radius)p.fatalError("Ball collider must have a radius!");return X1.ColliderDesc.ball(Z.radius)}case"block":{if(!Z.halfExtents)p.fatalError("Block collider must have halfExtents!");return X1.ColliderDesc.cuboid(Z.halfExtents.x,Z.halfExtents.y,Z.halfExtents.z)}case"capsule":{if(!Z.halfHeight||!Z.radius)p.fatalError("Capsule collider must have halfHeight and radius!");return X1.ColliderDesc.capsule(Z.halfHeight,Z.radius)}case"cone":{if(!Z.radius||!Z.halfHeight)p.fatalError("Cone collider must have radius and halfHeight!");return X1.ColliderDesc.cone(Z.halfHeight,Z.radius)}case"cylinder":{if(!Z.radius||!Z.halfHeight)p.fatalError("Cylinder collider must have radius and halfHeight!");return X1.ColliderDesc.cylinder(Z.halfHeight,Z.radius)}case"round-cylinder":{if(!Z.radius||!Z.halfHeight||!Z.borderRadius)p.fatalError("Round cylinder collider must have radius, halfHeight, and borderRadius!");return X1.ColliderDesc.roundCylinder(Z.halfHeight,Z.radius,Z.borderRadius)}case"trimesh":{if(!Z.indices||!Z.vertices)p.fatalError("Trimesh collider must have vertices and indices!");return X1.ColliderDesc.trimesh(Z.vertices,Z.indices,X)}case"voxels":{if(!Z.coordinates||!Z.size)p.fatalError("Voxels collider must have coordinates and size!");return X1.ColliderDesc.voxels(this._coordinatesToInt32Array(Z.coordinates),Z.size)}case"wedge":{if(!Z.extents)p.fatalError("Wedge collider must have extents!");let $=this._buildWedgeConvexHullVertices(Z.extents),Y=X1.ColliderDesc.convexHull($);if(!Y)throw p.fatalError("Failed to create convex hull for wedge collider!"),Error("Convex hull creation failed");return Y}default:p.fatalError(`Collider._createColliderDesc(): ${J} is not a valid collider shape!`)}}_requireSimulated(Z){if(!this.isSimulated)p.error(`Collider._requireSimulated(): Collider is not simulated, invoked method: ${Z}()`);return this.isSimulated}_requireUnsimulated(Z){if(this.isSimulated)p.error(`Collider._requireUnsimulated(): Collider is already simulated, invoked method: ${Z}()`);return!this.isSimulated}_requireNotRemoved(Z){if(this.isRemoved)p.error(`Collider._requireNotRemoved(): Collider is removed, invoked method: ${Z}()`);return!this.isRemoved}_setActiveCollisionTypes(){(this._collider??this._colliderDesc).setActiveCollisionTypes(X1.ActiveCollisionTypes.DYNAMIC_DYNAMIC|X1.ActiveCollisionTypes.DYNAMIC_KINEMATIC|X1.ActiveCollisionTypes.DYNAMIC_FIXED|X1.ActiveCollisionTypes.KINEMATIC_KINEMATIC|X1.ActiveCollisionTypes.KINEMATIC_FIXED)}_coordinatesToInt32Array(Z){let J=new Int32Array(Z.length*3);for(let X=0;X<Z.length;X++){let $=Z[X],Y=X*3;J[Y]=Math.floor($.x),J[Y+1]=Math.floor($.y),J[Y+2]=Math.floor($.z)}return J}}var _R1={shape:"voxels"},iP;((X)=>{X.ENTITY_COLLISION="BLOCK_TYPE.ENTITY_COLLISION";X.ENTITY_CONTACT_FORCE="BLOCK_TYPE.ENTITY_CONTACT_FORCE"})(iP||={});class m5 extends j0{_id;_customColliderOptions;_halfExtents;_isLiquid;_lightLevel;_name;_textureUri;constructor(Z={id:-1,textureUri:"textures/missing.png",name:"Unknown"}){if(Z.id<0)p.fatalError("BlockType.constructor(): BlockType id not set.");super();this._id=Z.id,this._customColliderOptions=Z.customColliderOptions,this._halfExtents=Z.halfExtents??{x:0.5,y:0.5,z:0.5},this._isLiquid=Z.isLiquid??!1,this._name=Z.name,this._textureUri=Z.textureUri,this._lightLevel=Math.min(Z.lightLevel??0,15)}get id(){return this._id}get colliderOptions(){return{...this._customColliderOptions,..._R1}}get halfExtents(){return this._halfExtents}get isLiquid(){return this._isLiquid}get isMeshable(){return!this._customColliderOptions}get lightLevel(){return this._lightLevel}get name(){return this._name}get size(){return{x:this._halfExtents.x*2,y:this._halfExtents.y*2,z:this._halfExtents.z*2}}get textureUri(){return this._textureUri}createCollider(Z){let J=new A5({...this.colliderOptions,coordinates:Z,size:this.size});if(this.isLiquid)J.setSensor(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_COLLISION")||this.isLiquid)J.enableCollisionEvents(!0);if(this.hasListeners("BLOCK_TYPE.ENTITY_CONTACT_FORCE"))J.enableContactForceEvents(!0);if(v9.isDefaultCollisionGroups(J.collisionGroups))J.setCollisionGroups({belongsTo:[1],collidesWith:[65535&~1]});return J}serialize(){return T0.serializeBlockType(this)}}var gP;((J)=>J.REGISTER_BLOCK_TYPE="BLOCK_TYPE_REGISTRY.REGISTER_BLOCK_TYPE")(gP||={});class tG extends j0{_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)p.fatalError(`BlockTypeRegistry.getBlockType(): BlockType with id ${Z} not found.`);return J}registerGenericBlockType(Z){let X=new class extends m5{constructor($=Z){super($)}};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 T0.serializeBlockTypeRegistry(this)}}var MO={};_Q(MO,{worldSchema:()=>DO,worldPacketDefinition:()=>Z10,vectorSchema:()=>W1,vectorBooleanSchema:()=>ME1,uiSchema:()=>BO,uiPacketDefinition:()=>t00,uiDatasSchema:()=>LO,uiDatasPacketDefinition:()=>e00,uiDataSendPacketDefinition:()=>S00,uiDataSchema:()=>Dz,syncResponseSchema:()=>jO,syncResponsePacketDefinition:()=>r00,syncRequestSchema:()=>dN,syncRequestPacketDefinition:()=>h00,stateRequestSchema:()=>gN,stateRequestPacketDefinition:()=>_00,sceneUIsSchema:()=>UO,sceneUIsPacketDefinition:()=>o00,sceneUISchema:()=>xO,rgbColorSchema:()=>D6,registeredPackets:()=>Ec,quaternionSchema:()=>YO,playersSchema:()=>cO,playersPacketDefinition:()=>s00,playerSchema:()=>wO,physicsDebugRenderSchema:()=>FO,physicsDebugRenderPacketDefinition:()=>a00,physicsDebugRaycastsSchema:()=>qO,physicsDebugRaycastsPacketDefinition:()=>n00,physicsDebugRaycastSchema:()=>HO,particleEmittersSchema:()=>VO,particleEmittersPacketDefinition:()=>d00,particleEmitterSchema:()=>vO,outboundPackets:()=>kc,notificationPermissionRequestSchema:()=>zO,notificationPermissionRequestPacketDefinition:()=>g00,modelNodeOverrideSchema:()=>$O,lightsSchema:()=>GO,lightsPacketDefinition:()=>i00,lightSchema:()=>WO,isValidPacket:()=>PE1,inputSchema:()=>iN,inputPacketDefinition:()=>I00,inboundPackets:()=>fc,hexColorSchema:()=>yN,heartbeatSchema:()=>lN,heartbeatPacketDefinition:()=>f00,entitySchema:()=>QO,entitiesSchema:()=>KO,entitiesPacketDefinition:()=>p00,definePacket:()=>C0,debugConfigSchema:()=>pN,debugConfigPacketDefinition:()=>E00,createPacket:()=>DE1,connectionSchema:()=>uN,connectionPacketDefinition:()=>C00,chunksSchema:()=>XO,chunksPacketDefinition:()=>y00,chunkSchema:()=>JO,chatMessagesSchema:()=>ZO,chatMessagesPacketDefinition:()=>l00,chatMessageSendPacketDefinition:()=>k00,chatMessageSchema:()=>Lz,cameraSchema:()=>eN,cameraPacketDefinition:()=>u00,blocksSchema:()=>oN,blocksPacketDefinition:()=>A00,blockTypesSchema:()=>tN,blockTypesPacketDefinition:()=>m00,blockTypeSchema:()=>rN,blockSchema:()=>sN,bidirectionalPackets:()=>Cc,audiosSchema:()=>nN,audiosPacketDefinition:()=>b00,audioSchema:()=>aN,PacketId:()=>M1});var Cc={};_Q(Cc,{heartbeatPacketDefinition:()=>f00,connectionPacketDefinition:()=>C00});var AN=t(T00(),1);class mN extends AN.default{static instance=new AN.default}var M1;((k)=>{k[k.SYNC_REQUEST=0]="SYNC_REQUEST";k[k.INPUT=1]="INPUT";k[k.STATE_REQUEST=2]="STATE_REQUEST";k[k.CHAT_MESSAGE_SEND=3]="CHAT_MESSAGE_SEND";k[k.UI_DATA_SEND=4]="UI_DATA_SEND";k[k.SYNC_RESPONSE=32]="SYNC_RESPONSE";k[k.AUDIOS=33]="AUDIOS";k[k.BLOCKS=34]="BLOCKS";k[k.BLOCK_TYPES=35]="BLOCK_TYPES";k[k.CHAT_MESSAGES=36]="CHAT_MESSAGES";k[k.CHUNKS=37]="CHUNKS";k[k.ENTITIES=38]="ENTITIES";k[k.WORLD=39]="WORLD";k[k.CAMERA=40]="CAMERA";k[k.UI=41]="UI";k[k.UI_DATAS=42]="UI_DATAS";k[k.SCENE_UIS=43]="SCENE_UIS";k[k.LIGHTS=44]="LIGHTS";k[k.PLAYERS=45]="PLAYERS";k[k.PARTICLE_EMITTERS=46]="PARTICLE_EMITTERS";k[k.NOTIFICATION_PERMISSION_REQUEST=47]="NOTIFICATION_PERMISSION_REQUEST";k[k.CONNECTION=116]="CONNECTION";k[k.HEARTBEAT=117]="HEARTBEAT";k[k.DEBUG_CONFIG=128]="DEBUG_CONFIG";k[k.PHYSICS_DEBUG_RENDER=192]="PHYSICS_DEBUG_RENDER";k[k.PHYSICS_DEBUG_RAYCASTS=193]="PHYSICS_DEBUG_RAYCASTS"})(M1||={});function DE1(Z,J,X){if(!Z.validate(J))throw Error(`Invalid payload for packet with id ${Z.id}. Error: ${mN.instance.errorsText(Z.validate.errors)}`);let $=[Z.id,J];if(typeof X==="number")$.push(X);return $}function C0(Z,J){return{id:Z,schema:J,validate:mN.instance.compile(J)}}var uN={type:"object",properties:{i:{type:"string",nullable:!0},k:{type:"boolean",nullable:!0},ts:{type:"string",nullable:!0}},additionalProperties:!1};var C00=C0(116,uN);var lN={type:"null",nullable:!0};var f00=C0(117,lN);var fc={};_Q(fc,{uiDataSendPacketDefinition:()=>S00,syncRequestPacketDefinition:()=>h00,stateRequestPacketDefinition:()=>_00,inputPacketDefinition:()=>I00,debugConfigPacketDefinition:()=>E00,chatMessageSendPacketDefinition:()=>k00});var yN={type:"string",pattern:"^[0-9A-Fa-f]{6}$"};var Lz={type:"object",properties:{m:{type:"string"},c:{...yN,nullable:!0},p:{type:"string",nullable:!0}},required:["m"],additionalProperties:!1};var k00=C0(3,Lz);var pN={type:"object",properties:{pdr:{type:"boolean",nullable:!0}},additionalProperties:!1};var E00=C0(128,pN);var iN={type:"object",properties:{"1":{type:"boolean",nullable:!0},"2":{type:"boolean",nullable:!0},"3":{type:"boolean",nullable:!0},"4":{type:"boolean",nullable:!0},"5":{type:"boolean",nullable:!0},"6":{type:"boolean",nullable:!0},"7":{type:"boolean",nullable:!0},"8":{type:"boolean",nullable:!0},"9":{type:"boolean",nullable:!0},"0":{type:"boolean",nullable:!0},w:{type:"boolean",nullable:!0},a:{type:"boolean",nullable:!0},s:{type:"boolean",nullable:!0},d:{type:"boolean",nullable:!0},q:{type:"boolean",nullable:!0},e:{type:"boolean",nullable:!0},r:{type:"boolean",nullable:!0},f:{type:"boolean",nullable:!0},z:{type:"boolean",nullable:!0},x:{type:"boolean",nullable:!0},c:{type:"boolean",nullable:!0},v:{type:"boolean",nullable:!0},u:{type:"boolean",nullable:!0},i:{type:"boolean",nullable:!0},o:{type:"boolean",nullable:!0},j:{type:"boolean",nullable:!0},k:{type:"boolean",nullable:!0},l:{type:"boolean",nullable:!0},n:{type:"boolean",nullable:!0},m:{type:"boolean",nullable:!0},sp:{type:"boolean",nullable:!0},sh:{type:"boolean",nullable:!0},tb:{type:"boolean",nullable:!0},ml:{type:"boolean",nullable:!0},mr:{type:"boolean",nullable:!0},cp:{type:"number",nullable:!0},cy:{type:"number",nullable:!0},sq:{type:"number",nullable:!0}},additionalProperties:!1};var I00=C0(1,iN);var gN={type:"object",properties:{},additionalProperties:!1};var _00=C0(2,gN);var dN={type:"null",nullable:!0};var h00=C0(0,dN);var Dz={type:"object",properties:{},additionalProperties:!0};var S00=C0(4,Dz);var kc={};_Q(kc,{worldPacketDefinition:()=>Z10,uiPacketDefinition:()=>t00,uiDatasPacketDefinition:()=>e00,syncResponsePacketDefinition:()=>r00,sceneUIsPacketDefinition:()=>o00,playersPacketDefinition:()=>s00,physicsDebugRenderPacketDefinition:()=>a00,physicsDebugRaycastsPacketDefinition:()=>n00,particleEmittersPacketDefinition:()=>d00,notificationPermissionRequestPacketDefinition:()=>g00,lightsPacketDefinition:()=>i00,entitiesPacketDefinition:()=>p00,chunksPacketDefinition:()=>y00,chatMessagesPacketDefinition:()=>l00,cameraPacketDefinition:()=>u00,blocksPacketDefinition:()=>A00,blockTypesPacketDefinition:()=>m00,audiosPacketDefinition:()=>b00});var W1={type:"array",items:[{type:"number"},{type:"number"},{type:"number"}],minItems:3,maxItems:3};var aN={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:{...W1,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 nN={type:"array",items:{...aN}};var b00=C0(33,nN);var sN={type:"object",properties:{i:{type:"number"},c:W1},required:["i","c"],additionalProperties:!1};var oN={type:"array",items:{...sN}};var A00=C0(34,oN);var rN={type:"object",properties:{i:{type:"number"},l:{type:"boolean",nullable:!0},ll:{type:"number",nullable:!0},n:{type:"string",nullable:!0},t:{type:"string",nullable:!0}},required:["i"],additionalProperties:!1};var tN={type:"array",items:{...rN}};var m00=C0(35,tN);var eN={type:"object",properties:{m:{type:"number",nullable:!0},e:{type:"number",nullable:!0},et:{type:"number",nullable:!0},fo:{type:"number",nullable:!0},ffo:{type:"number",nullable:!0},fv:{type:"number",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},o:{...W1,nullable:!0},p:{...W1,nullable:!0},pt:{...W1,nullable:!0},pl:{...W1,nullable:!0},s:{type:"array",items:{type:"string"},nullable:!0},sa:{type:"number",nullable:!0},z:{type:"number",nullable:!0}},additionalProperties:!1};var ZO={type:"array",items:{...Lz}};var JO={type:"object",properties:{c:W1,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 XO={type:"array",items:{...JO}};var D6={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 $O={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:{...D6,nullable:!0}},required:["n"],additionalProperties:!1};var YO={type:"array",items:[{type:"number"},{type:"number"},{type:"number"},{type:"number"}],minItems:4,maxItems:4};var QO={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:{...W1,nullable:!0},bt:{type:"string",nullable:!0},h:{type:"array",items:{type:"string"},nullable:!0},m:{type:"string",nullable:!0},mo:{type:"array",items:{...$O},nullable:!0},mt:{type:"string",nullable:!0},n:{type:"string",nullable:!0},o:{type:"number",nullable:!0},p:{...W1,nullable:!0},pe:{type:"number",nullable:!0},pn:{type:"string",nullable:!0},r:{...YO,nullable:!0},rm:{type:"boolean",nullable:!0},s:{type:"number",nullable:!0},sn:{type:"array",items:{type:"string"},nullable:!0},t:{...D6,nullable:!0}},required:["i"],additionalProperties:!1};var KO={type:"array",items:{...QO}};var WO={type:"object",properties:{i:{type:"number"},a:{type:"number",nullable:!0},e:{type:"number",nullable:!0},c:{...D6,nullable:!0},d:{type:"number",nullable:!0},n:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,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:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var GO={type:"array",items:{...WO}};var zO={type:"null",nullable:!0};var vO={type:"object",properties:{i:{type:"number"},at:{type:"number",nullable:!0},b:{type:"number",nullable:!0},ce:{...D6,nullable:!0},cev:{...D6,nullable:!0},cs:{...D6,nullable:!0},csv:{...D6,nullable:!0},e:{type:"number",nullable:!0},en:{type:"string",nullable:!0},g:{...W1,nullable:!0},l:{type:"number",nullable:!0},lv:{type:"number",nullable:!0},mp:{type:"number",nullable:!0},o:{...W1,nullable:!0},oe:{type:"number",nullable:!0},oev:{type:"number",nullable:!0},os:{type:"number",nullable:!0},osv:{type:"number",nullable:!0},p:{...W1,nullable:!0},pa:{type:"boolean",nullable:!0},pv:{...W1,nullable:!0},r:{type:"number",nullable:!0},rv:{type:"number",nullable:!0},rm:{type:"boolean",nullable:!0},se:{type:"number",nullable:!0},sev:{type:"number",nullable:!0},ss:{type:"number",nullable:!0},ssv:{type:"number",nullable:!0},t:{type:"boolean",nullable:!0},tu:{type:"string",nullable:!0},v:{...W1,nullable:!0},vv:{...W1,nullable:!0}},required:["i"],additionalProperties:!1};var VO={type:"array",items:{...vO}};var HO={type:"object",properties:{o:{...W1},d:{...W1},l:{type:"number"},h:{type:"boolean"}},required:["o","d","l","h"],additionalProperties:!1};var qO={type:"array",items:{...HO}};var FO={type:"object",properties:{v:{type:"array",items:{type:"number"}},c:{type:"array",items:{type:"number"}}},required:["v","c"],additionalProperties:!1};var wO={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 cO={type:"array",items:{...wO}};var xO={type:"object",properties:{i:{type:"number"},e:{type:"number",nullable:!0},o:{...W1,nullable:!0},p:{...W1,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 UO={type:"array",items:{...xO}};var jO={type:"object",properties:{r:{type:"number"},s:{type:"number"},p:{type:"number"},n:{type:"number"}},required:["r","s","p","n"],additionalProperties:!1};var BO={type:"object",properties:{p:{type:"boolean",nullable:!0},u:{type:"string",nullable:!0}},additionalProperties:!1};var LO={type:"array",items:{...Dz}};var ME1={type:"array",items:[{type:"boolean"},{type:"boolean"},{type:"boolean"}],minItems:3,maxItems:3};var DO={type:"object",properties:{i:{type:"number"},ac:{...D6,nullable:!0},ai:{type:"number",nullable:!0},dc:{...D6,nullable:!0},di:{type:"number",nullable:!0},dp:{...W1,nullable:!0},fc:{...D6,nullable:!0},ff:{type:"number",nullable:!0},fn:{type:"number",nullable:!0},n:{type:"string",nullable:!0},s:{type:"string",nullable:!0},si:{type:"number",nullable:!0},t:{type:"number",nullable:!0}},required:["i"],additionalProperties:!1};var u00=C0(40,eN);var l00=C0(36,ZO);var y00=C0(37,XO);var p00=C0(38,KO);var i00=C0(44,GO);var g00=C0(47,zO);var d00=C0(46,VO);var a00=C0(192,FO);var n00=C0(193,qO);var s00=C0(45,cO);var o00=C0(43,UO);var r00=C0(32,jO);var t00=C0(41,BO);var e00=C0(42,LO);var Z10=C0(39,DO);var Ec=new Map,RE1={...Cc,...fc,...kc};for(let Z of Object.values(RE1))if("id"in Z&&"schema"in Z){let J=Z;if(Ec.has(J.id))throw Error(`Packet with id ${J.id} is already registered.`);Ec.set(J.id,J)}function PE1(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=Ec.get(Z[0]);return!!J&&J.validate(Z[1])}var Q0=MO;var K60=t(T10(),1);import t$ from"fs";import Y60 from"path";var q_1=t(M80(),1),F_1=t(_O(),1),w_1=t(SO(),1),r$=t(pc(),1),pO=t(f80(),1);var k80=r$.default;function U5(Z){if(Z===null)return"null";if(Array.isArray(Z))return"array";return typeof Z}function $X(Z){return U5(Z)==="object"}function c_1(Z){return Array.isArray(Z)&&Z.length>0&&Z.every((J)=>("message"in J))}function iO(Z,J){return Z.length<124?Z:J}var E80="graphql-transport-ws";var l5=((Z)=>{return Z[Z.InternalServerError=4500]="InternalServerError",Z[Z.InternalClientError=4005]="InternalClientError",Z[Z.BadRequest=4400]="BadRequest",Z[Z.BadResponse=4004]="BadResponse",Z[Z.Unauthorized=4401]="Unauthorized",Z[Z.Forbidden=4403]="Forbidden",Z[Z.SubprotocolNotAcceptable=4406]="SubprotocolNotAcceptable",Z[Z.ConnectionInitialisationTimeout=4408]="ConnectionInitialisationTimeout",Z[Z.ConnectionAcknowledgementTimeout=4504]="ConnectionAcknowledgementTimeout",Z[Z.SubscriberAlreadyExists=4409]="SubscriberAlreadyExists",Z[Z.TooManyInitialisationRequests=4429]="TooManyInitialisationRequests",Z})(l5||{}),y5=((Z)=>{return Z.ConnectionInit="connection_init",Z.ConnectionAck="connection_ack",Z.Ping="ping",Z.Pong="pong",Z.Subscribe="subscribe",Z.Next="next",Z.Error="error",Z.Complete="complete",Z})(y5||{});function I80(Z){if(!$X(Z))throw Error(`Message is expected to be an object, but got ${U5(Z)}`);if(!Z.type)throw Error("Message is missing the 'type' property");if(typeof Z.type!=="string")throw Error(`Message is expects the 'type' property to be a string, but got ${U5(Z.type)}`);switch(Z.type){case"connection_init":case"connection_ack":case"ping":case"pong":{if(Z.payload!=null&&!$X(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${Z.payload}"`);break}case"subscribe":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!$X(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${U5(Z.payload)}`);if(typeof Z.payload.query!=="string")throw Error(`"${Z.type}" message payload expects the 'query' property to be a string, but got ${U5(Z.payload.query)}`);if(Z.payload.variables!=null&&!$X(Z.payload.variables))throw Error(`"${Z.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${U5(Z.payload.variables)}`);if(Z.payload.operationName!=null&&U5(Z.payload.operationName)!=="string")throw Error(`"${Z.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${U5(Z.payload.operationName)}`);if(Z.payload.extensions!=null&&!$X(Z.payload.extensions))throw Error(`"${Z.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${U5(Z.payload.extensions)}`);break}case"next":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!$X(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an object, but got ${U5(Z.payload)}`);break}case"error":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);if(!c_1(Z.payload))throw Error(`"${Z.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(Z.payload)}`);break}case"complete":{if(typeof Z.id!=="string")throw Error(`"${Z.type}" message expects the 'id' property to be a string, but got ${U5(Z.id)}`);if(!Z.id)throw Error(`"${Z.type}" message requires a non-empty 'id' property`);break}default:throw Error(`Invalid message 'type' property "${Z.type}"`)}return Z}function _80(Z,J){return I80(typeof Z==="string"?JSON.parse(Z,J):Z)}function i3(Z,J){return I80(Z),JSON.stringify(Z,J)}function dO(Z){let{url:J,connectionParams:X,lazy:$=!0,onNonLazyError:Y=console.error,lazyCloseTimeout:Q=0,keepAlive:K=0,disablePong:W,connectionAckWaitTimeout:G=0,retryAttempts:z=5,retryWait:v=async function(h){let _=Math.pow(2,h);await new Promise((a)=>setTimeout(a,_*1000+Math.floor(Math.random()*2700+300)))},shouldRetry:H=gO,on:V,webSocketImpl:q,generateID:F=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(h)=>{let _=Math.random()*16|0;return(h=="x"?_:_&3|8).toString(16)})},jsonMessageReplacer:w,jsonMessageReviver:c}=Z,x;if(q){if(!U_1(q))throw Error("Invalid WebSocket implementation provided");x=q}else if(typeof WebSocket<"u")x=WebSocket;else if(typeof global<"u")x=global.WebSocket||global.MozWebSocket;else if(typeof window<"u")x=window.WebSocket||window.MozWebSocket;if(!x)throw Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let j=x,B=(()=>{let C=(()=>{let _={};return{on(a,s){return _[a]=s,()=>{delete _[a]}},emit(a){if("id"in a)_[a.id]?.(a)}}})(),h={connecting:V?.connecting?[V.connecting]:[],opened:V?.opened?[V.opened]:[],connected:V?.connected?[V.connected]:[],ping:V?.ping?[V.ping]:[],pong:V?.pong?[V.pong]:[],message:V?.message?[C.emit,V.message]:[C.emit],closed:V?.closed?[V.closed]:[],error:V?.error?[V.error]:[]};return{onMessage:C.on,on(_,a){let s=h[_];return s.push(a),()=>{s.splice(s.indexOf(a),1)}},emit(_,...a){for(let s of[...h[_]])s(...a)}}})();function L(C){let h=[B.on("error",(_)=>{h.forEach((a)=>a()),C(_)}),B.on("closed",(_)=>{h.forEach((a)=>a()),C(_)})]}let R,M=0,P,N=!1,O=0,k=!1;async function E(){clearTimeout(P);let[C,h]=await(R??(R=new Promise((s,Z0)=>(async()=>{if(N){if(await v(O),!M)return R=void 0,Z0({code:1000,reason:"All Subscriptions Gone"});O++}B.emit("connecting",N);let o=new j(typeof J==="function"?await J():J,E80),M0,R0;function m0(){if(isFinite(K)&&K>0)clearTimeout(R0),R0=setTimeout(()=>{if(o.readyState===j.OPEN)o.send(i3({type:y5.Ping})),B.emit("ping",!1,void 0)},K)}L((s0)=>{if(R=void 0,clearTimeout(M0),clearTimeout(R0),Z0(s0),s0 instanceof gc)o.close(4499,"Terminated"),o.onerror=null,o.onclose=null}),o.onerror=(s0)=>B.emit("error",s0),o.onclose=(s0)=>B.emit("closed",s0),o.onopen=async()=>{try{B.emit("opened",o);let s0=typeof X==="function"?await X():X;if(o.readyState!==j.OPEN)return;if(o.send(i3(s0?{type:y5.ConnectionInit,payload:s0}:{type:y5.ConnectionInit},w)),isFinite(G)&&G>0)M0=setTimeout(()=>{o.close(l5.ConnectionAcknowledgementTimeout,"Connection acknowledgement timeout")},G);m0()}catch(s0){B.emit("error",s0),o.close(l5.InternalClientError,iO(s0 instanceof Error?s0.message:String(s0),"Internal client error"))}};let N1=!1;o.onmessage=({data:s0})=>{try{let j1=_80(s0,c);if(B.emit("message",j1),j1.type==="ping"||j1.type==="pong"){if(B.emit(j1.type,!0,j1.payload),j1.type==="pong")m0();else if(!W)o.send(i3(j1.payload?{type:y5.Pong,payload:j1.payload}:{type:y5.Pong})),B.emit("pong",!1,j1.payload);return}if(N1)return;if(j1.type!==y5.ConnectionAck)throw Error(`First message cannot be of type ${j1.type}`);clearTimeout(M0),N1=!0,B.emit("connected",o,j1.payload,N),N=!1,O=0,s([o,new Promise((K4,PJ)=>L(PJ))])}catch(j1){o.onmessage=null,B.emit("error",j1),o.close(l5.BadResponse,iO(j1 instanceof Error?j1.message:String(j1),"Bad response"))}}})())));if(C.readyState===j.CLOSING)await h;let _=()=>{},a=new Promise((s)=>_=s);return[C,_,Promise.race([a.then(()=>{if(!M){let s=()=>C.close(1000,"Normal Closure");if(isFinite(Q)&&Q>0)P=setTimeout(()=>{if(C.readyState===j.OPEN)s()},Q);else s()}}),h])]}function S(C){if(gO(C)&&(x_1(C.code)||[l5.InternalServerError,l5.InternalClientError,l5.BadRequest,l5.BadResponse,l5.Unauthorized,l5.SubprotocolNotAcceptable,l5.SubscriberAlreadyExists,l5.TooManyInitialisationRequests].includes(C.code)))throw C;if(k)return!1;if(gO(C)&&C.code===1000)return M>0;if(!z||O>=z)throw C;if(!H(C))throw C;return N=!0}if(!$)(async()=>{M++;for(;;)try{let[,,C]=await E();await C}catch(C){try{if(!S(C))return}catch(h){return Y?.(h)}}})();function f(C,h){let _=F(C),a=!1,s=!1,Z0=()=>{M--,a=!0};return(async()=>{M++;for(;;)try{let[o,M0,R0]=await E();if(a)return M0();let m0=B.onMessage(_,(N1)=>{switch(N1.type){case y5.Next:{h.next(N1.payload);return}case y5.Error:{s=!0,a=!0,h.error(N1.payload),Z0();return}case y5.Complete:{a=!0,Z0();return}}});o.send(i3({id:_,type:y5.Subscribe,payload:C},w)),Z0=()=>{if(!a&&o.readyState===j.OPEN)o.send(i3({id:_,type:y5.Complete},w));M--,a=!0,M0()},await R0.finally(m0);return}catch(o){if(!S(o))return}})().then(()=>{if(!s)h.complete()}).catch((o)=>{h.error(o)}),()=>{if(!a)Z0()}}return{on:B.on,subscribe:f,iterate(C){let h=[],_={done:!1,error:null,resolve:()=>{}},a=f(C,{next(Z0){h.push(Z0),_.resolve()},error(Z0){_.done=!0,_.error=Z0,_.resolve()},complete(){_.done=!0,_.resolve()}}),s=async function*(){for(;;){if(!h.length)await new Promise((o)=>_.resolve=o);while(h.length)yield h.shift();if(_.error)throw _.error;if(_.done)return}}();return s.throw=async(Z0)=>{if(!_.done)_.done=!0,_.error=Z0,_.resolve();return{done:!0,value:void 0}},s.return=async()=>{return a(),{done:!0,value:void 0}},s},async dispose(){if(k=!0,R){let[C]=await R;C.close(1000,"Normal Closure")}},terminate(){if(R)B.emit("closed",new gc)}}}class gc extends Error{name="TerminatedCloseEvent";message="4499: Terminated";code=4499;reason="Terminated";wasClean=!1}function gO(Z){return $X(Z)&&"code"in Z&&"reason"in Z}function x_1(Z){if([1000,1001,1006,1005,1012,1013,1014].includes(Z))return!1;return Z>=1000&&Z<=1999}function U_1(Z){return typeof Z==="function"&&"constructor"in Z&&"CLOSED"in Z&&"CLOSING"in Z&&"CONNECTING"in Z&&"OPEN"in Z}var Q60=t($60(),1);var Ez="./dev/persistence",ac=process.env.HYTOPIA_NOTIFICATION_SERVICE_URL||"https://prod.notifications.hytopia.com";class N4{static instance=new N4;creatorApiKey=process.env.HYTOPIA_API_KEY;gameId=process.env.HYTOPIA_GAME_ID;lobbyId=process.env.HYTOPIA_LOBBY_ID;_creativeGateway;_gqlWs;constructor(){this._gqlWs=dO({url:"wss://prod.gql.hytopia.com/graphql",webSocketImpl:k80});try{this._creativeGateway=new Q60.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(`
400
400
  `))}}get isGatewayAvailable(){return!!this._creativeGateway}async getGlobalData(Z){if(!this._creativeGateway&&process.env.NODE_ENV==="production")return p.warning("PlatformGateway.getGlobalData(): You are running in production mode, but the Platform Gateway is not initialized! No data will be returned."),{error:{code:"gatewayError",message:"Platform Gateway is not initialized."}};return this._creativeGateway?await this._creativeGateway.kv.get(Z):this._readDevGlobalDataLocally(Z)}async getPlayerCosmetics(Z){let J=this._gqlWs.iterate({query:`{
401
401
  userById(id: "${Z}") {
402
402
  characterSettings { skinTone hairColor eyeColor hairStyle }
@@ -475,7 +475,7 @@ qYGMwU/HBVHkLAn5XvT2a9xM0mzZ558d+ahbw8qAgRxg7BZ+2PW/bf7F2WRBUk1f
475
475
  xauhAoGBALEspoxQozwohGQnP7EMF0/0JoKNpdNv0b0qCVvNiMo0+N297lI2mFQp
476
476
  6xYlW/1l9afLokklF/J2IsyBrTCZoY7SaEk/lMMrQSyra+y0z71ogZ8A4ny9fxsj
477
477
  0dDYJZGllL+3E/MQfd7k+KnOM/+A+cPoAnci76+L3vdkUb2P8SJk
478
- -----END RSA PRIVATE KEY-----`;var $A=process.env.PORT??8080,YA="0.10.38-notifications-prerelease",XA;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(XA||={});class LW extends j0{static instance=new LW;_webserver=lB.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:YA,runtime:"node"})}),this._webserver.use(lB.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(lB.default.static(lX6.dirname(g.resolve("/Users/arkdev/Desktop/HYTOPIA/hytopia/assets/release/index.js")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?mX6.createServer(this._webserver):uX6.createServer({key:uB.existsSync("assets/certs/localhost.key")?uB.readFileSync("assets/certs/localhost.key"):TK1,cert:uB.existsSync("assets/certs/localhost.crt")?uB.readFileSync("assets/certs/localhost.crt"):OK1},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else p.warning("WebServer.start(): server already started!");this._internalHttpServer.listen($A,this._onStarted),console.info(`WebServer.start(): Server running on port ${$A}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return p.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=yX6.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&NQ.instance.isValidConnectionId(Y))Z.connectionId=Y;else{let K=await N4.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
478
+ -----END RSA PRIVATE KEY-----`;var $A=process.env.PORT??8080,YA="0.10.38-notifications-prerelease-2",XA;((Y)=>{Y.READY="WEBSERVER.READY";Y.STOPPED="WEBSERVER.STOPPED";Y.ERROR="WEBSERVER.ERROR";Y.UPGRADE="WEBSERVER.UPGRADE"})(XA||={});class LW extends j0{static instance=new LW;_webserver=lB.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:YA,runtime:"node"})}),this._webserver.use(lB.default.static("assets",{dotfiles:"allow"}));try{this._webserver.use(lB.default.static(lX6.dirname(g.resolve("@hytopia.com/assets")),{dotfiles:"allow"}))}catch{}}start(){if(!this._internalHttpServer)this._internalHttpServer=process.env.NODE_ENV==="production"?mX6.createServer(this._webserver):uX6.createServer({key:uB.existsSync("assets/certs/localhost.key")?uB.readFileSync("assets/certs/localhost.key"):TK1,cert:uB.existsSync("assets/certs/localhost.crt")?uB.readFileSync("assets/certs/localhost.crt"):OK1},this._webserver),this._internalHttpServer.on("upgrade",this._onUpgrade),this._internalHttpServer.on("error",this._onError),this._internalHttpServer.on("close",this._onStopped);else p.warning("WebServer.start(): server already started!");this._internalHttpServer.listen($A,this._onStarted),console.info(`WebServer.start(): Server running on port ${$A}.`)}stop(){if(this._internalHttpServer)return new Promise((Z,J)=>{this._internalHttpServer.close((X)=>{if(X)J(X);else Z(!0)})});else return p.warning("WebServer.stop(): server not started."),Promise.resolve(!1)}_onStarted=()=>{this.emitWithGlobal("WEBSERVER.READY",{})};_onUpgrade=async(Z,J,X)=>{let $=yX6.parse(Z.url??"",!0).query,Y=$.connectionId?.toString(),Q=$.sessionToken?.toString()??"";if(Y&&NQ.instance.isValidConnectionId(Y))Z.connectionId=Y;else{let K=await N4.instance.getPlayerSession(Q);if(K?.error){let W=`${K.error.code}: ${K.error.message}`;J.write(`HTTP/1.1 401 Unauthorized\r
479
479
  Content-Type: text/plain\r
480
480
  Content-Length: ${W.length}\r
481
481
  Connection: close\r