@needle-tools/engine 3.16.2 → 3.16.3

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.
@@ -4305,7 +4305,7 @@ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
4305
4305
  font-family: sans-serif;
4306
4306
  text-align: center;
4307
4307
  user-select: none;
4308
- `;const o=zy?.length>1?zy:"Needle Engine<br/>This application is not allowed to run on this domain!";return n.innerHTML=o,r}let t=e();const s=t.style.cssText;setInterval(()=>{var r;RC===!0&&(t.style.cssText!==s&&(t=e()),"isPaused"in i&&(i.isPaused=!0),t.parentNode!==i.domElement.shadowRoot&&((r=i.domElement.shadowRoot)==null||r.appendChild(t)))},500)}async function oY(i){try{if(Jd()!==!0)return kC(i)}catch(e){return Fo&&console.log("License check failed",e),kC(i)}Fo&&kC(i)}const EL="needle-license-element",PC=1e4,BC=200;async function kC(i){await au?.catch(()=>{}),!Jd()&&(aY(),i.domElement.addEventListener("ready",()=>{setTimeout(()=>{ML(i)},1e3)}))}function ML(i){const e=lY(),t=cY(),s=setInterval(()=>{if(!e)return;const a=i.domElement.shadowRoot||i.domElement;e.parentNode!==a&&(a.appendChild(e),t&&a.appendChild(t))},100),r=`<img class="logo" src="${CL}" style="width: 40px; height: 40px; margin-right: 2px; vertical-align: middle; margin-bottom: 2px;"/>`,n=document.createElement("div");n.innerHTML=r,n.classList.add("logo"),e.appendChild(n);const o=document.createElement("div");if(o.classList.add("text"),e.appendChild(o),e.title="Needle Engine",Jd()||(e.title+=" No active license found - Non Commercial Use"),e.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")}),IC()){const a=PC+BC;setTimeout(()=>{clearInterval(s),e?.remove(),t?.remove();const l=5;setTimeout(()=>{i.domElement.parentNode&&ML(i)},1e3*60*l)},a)}}let TL=0;async function aY(i){const e=Date.now();if(e-TL<2e3)return;TL=e,console.log("%c Needle Engine \u2014 No license active, commercial use is not allowed. Visit https://needle.tools/pricing for more information and licensing options.",`
4308
+ `;const o=zy?.length>1?zy:"Needle Engine<br/>This application is not allowed to run on this domain!";return n.innerHTML=o,r}let t=e();const s=t.style.cssText;setInterval(()=>{var r;RC===!0&&(t.style.cssText!==s&&(t=e()),"isPaused"in i&&(i.isPaused=!0),t.parentNode!==i.domElement.shadowRoot&&((r=i.domElement.shadowRoot)==null||r.appendChild(t)))},500)}async function oY(i){try{if(Jd()!==!0)return kC(i)}catch(e){return Fo&&console.log("License check failed",e),kC(i)}Fo&&kC(i)}const EL="needle-license-element",PC=1e4,BC=1200;async function kC(i){await au?.catch(()=>{}),!Jd()&&(aY(),i.domElement.addEventListener("ready",()=>{ML(i)}))}function ML(i){const e=lY(),t=cY(),s=()=>{if(!e)return;const l=i.domElement.shadowRoot||i.domElement;e.parentNode!==l&&(l.appendChild(e),t&&l.appendChild(t))};s();const r=setInterval(()=>{s()},1e3),n=`<img class="logo" src="${CL}" style="width: 40px; height: 40px; margin-right: 2px; vertical-align: middle; margin-bottom: 2px;"/>`,o=document.createElement("div");o.innerHTML=n,o.classList.add("logo"),e.appendChild(o);const a=document.createElement("div");if(a.classList.add("text"),e.appendChild(a),e.title="Needle Engine",Jd()||(e.title+=" No active license found - Non Commercial Use"),e.addEventListener("click",()=>{globalThis.open("https://needle.tools","_blank")}),IC()){const l=PC+BC;setTimeout(()=>{clearInterval(r),e?.remove(),t?.remove();const c=5;setTimeout(()=>{i.domElement.parentNode&&ML(i)},1e3*60*c)},l)}}let TL=0;async function aY(i){const e=Date.now();if(e-TL<2e3)return;TL=e,console.log("%c Needle Engine \u2014 No license active, commercial use is not allowed. Visit https://needle.tools/pricing for more information and licensing options.",`
4309
4309
  position: relative;
4310
4310
  display: block;
4311
4311
  font-size: 18px;
@@ -4423,9 +4423,27 @@ irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
4423
4423
  transform: scale(1.02) !important;
4424
4424
  cursor: pointer !important;
4425
4425
  }
4426
+
4427
+ @media (prefers-reduced-motion: reduce) {
4428
+ ${e} .text {
4429
+ animation: none !important;
4430
+ transition: none !important;
4431
+ /* animation end state */
4432
+ opacity: 1;
4433
+ }
4434
+
4435
+ ${e} .logo {
4436
+ animation: none !important;
4437
+ transition: none !important;
4438
+ /* animation end state */
4439
+ opacity: 1;
4440
+ pointer-events: all;
4441
+ transform: scale(1)
4442
+ }
4443
+ }
4426
4444
  `,i}async function hY(){try{const i="https://needle-engine-analytics-v2-r26roub2hq-lz.a.run.app";if(i){Fo&&console.log("Analytics backend url",i);const e=window.location.href;let t="api/v2/new/request";i.endsWith("/")||(t="/"+t);const s=`${i}${t}?license=${ou}&url=${encodeURIComponent(e)}&hostname=${encodeURIComponent(window.location.hostname)}&pathname=${encodeURIComponent(window.location.pathname)}&search=${encodeURIComponent(window.location.search)}&hash=${encodeURIComponent(window.location.hash)}&version=${Tc}&generator=${sy}`;Fo&&console.log("Sending non-commercial usage message to analytics backend",s),fetch(s,{mode:"no-cors"}).catch(r=>{Fo&&console.log("Failed to send non-commercial usage message to analytics backend",r)})}}catch(i){Fo&&console.log("Failed to send non-commercial usage message to analytics backend",i)}}const lu=le("debugloading"),jm=le("debugloadingrendering"),IL=le("debuglicense");class uY{constructor(){h(this,"className"),h(this,"additionalClasses")}}let Qm=0,RL;function DC(i){lu&&console.log(i.progress.loaded.toFixed(0)+"/"+i.progress.total.toFixed(0),i);const e=i.count,t=i.progress.total;t===0||t===void 0?(RL!==i.name&&(Qm=0),RL=i.name,Qm+=(1-Qm)*.001,lu&&Nr("Loading "+i.name+" did not report total size")):Qm=i.progress.loaded/t;const s=i.index/e+Qm/e;return tt.clamp01(s)}const OC=class{constructor(i,e){h(this,"loadingProgress",0),h(this,"_element"),h(this,"_progress",0),h(this,"_allowCustomLoadingElement",!0),h(this,"_loadingElement"),h(this,"_loadingTextContainer",null),h(this,"_loadingBar",null),h(this,"_messageContainer",null),h(this,"_loadingElementOptions"),h(this,"_progressLoop"),this._element=i,this._loadingElementOptions=e}async onLoadingBegin(i){const e=this._element.shadowRoot||this._element;if(lu&&console.warn("Begin Loading"),!this._loadingElement){for(let t=0;t<e.children.length;t++){const s=e.children[t];if(s.classList.contains(OC.LoadingContainerClassName)){if(!this._allowCustomLoadingElement){lu&&console.warn("Remove custom loading container"),e.removeChild(s);continue}this._loadingElement=this.createLoadingElement(s)}}this._loadingElement||(this._loadingElement=this.createLoadingElement())}this._progress=0,this.loadingProgress=0,this._loadingElement.style.display="flex",e.appendChild(this._loadingElement),this.smoothProgressLoop(),this.setMessage(i??"")}onLoadingUpdate(i,e){var t;if(!((t=this._loadingElement)!=null&&t.parentNode))return;let s=0;typeof i=="number"?s=i:("index"in i&&(s=DC(i)),!e&&"name"in i&&this.setMessage("loading "+i.name)),this.loadingProgress=s,e&&this.setMessage(e),this.updateDisplay()}onLoadingFinished(){lu&&console.warn("Finished Loading"),jm||(this.loadingProgress=1,this.onDoneLoading())}setMessage(i){this._messageContainer&&(this._messageContainer.innerText=i)}smoothProgressLoop(){if(this._progressLoop)return;let i=1/12;jm&&(i=1/500,typeof jm=="number"&&(i*=jm)),this._progressLoop=setInterval(()=>{this.loadingProgress>=.95&&!jm&&(i=.9),this._progress=tt.lerp(this._progress,this.loadingProgress,i*this.loadingProgress),this.updateDisplay()},i)}onDoneLoading(){this._loadingElement&&(lu&&console.log("Hiding loading element"),this._loadingElement.style.display="none",this._loadingElement.remove()),this._progressLoop&&clearInterval(this._progressLoop),this._progressLoop=null}updateDisplay(){const i=this._progress,e=(i*100).toFixed(0)+"%";this._loadingBar&&(this._loadingBar.style.width=i*100+"%"),this._loadingTextContainer&&(this._loadingTextContainer.textContent=e)}createLoadingElement(i){var e,t;lu&&!i&&console.log("Creating loading element"),this._loadingElement=i||document.createElement("div");let s=this._element.getAttribute("loading-style");s==="auto"&&(window.matchMedia("(prefers-color-scheme: dark)").matches?s="dark":s="light");const r=Kd();if(!i&&(this._loadingElement.style.position="absolute",this._loadingElement.style.width="100%",this._loadingElement.style.height="100%",this._loadingElement.style.left="0",this._loadingElement.style.top="0",s==="light"?this._loadingElement.style.backgroundColor="#ddd":this._loadingElement.style.backgroundColor="#222",this._loadingElement.style.display="flex",this._loadingElement.style.alignItems="center",this._loadingElement.style.justifyContent="center",this._loadingElement.style.zIndex=Number.MAX_SAFE_INTEGER.toString(),this._loadingElement.style.flexDirection="column",this._loadingElement.style.pointerEvents="none",this._loadingElement.style.color="white",s==="light"?this._loadingElement.style.color="rgba(0,0,0,.8)":this._loadingElement.style.color="rgba(255,255,255,.5)",r&&this._element)){const p=this._element.getAttribute("loading-background-color");p&&(this._loadingElement.style.backgroundColor=p);const f=this._element.getAttribute("loading-text-color");f&&(this._loadingElement.style.color=f)}const n=((e=this._loadingElementOptions)==null?void 0:e.className)??OC.LoadingContainerClassName;if(this._loadingElement.classList.add(n),(t=this._loadingElementOptions)!=null&&t.additionalClasses)for(const p of this._loadingElementOptions.additionalClasses)this._loadingElement.classList.add(p);const o=document.createElement("div"),a=30;o.style.display="flex",o.style.width=a+"%",o.style.height="2px",s==="light"?o.style.backgroundColor="rgba(0,0,0,.2)":o.style.backgroundColor="rgba(255,255,255,.2)";const l=document.createElement("img"),c=64;if(l.style.width=`${c}px`,l.style.height=`${c}px`,l.style.marginBottom="20px",l.addEventListener("click",()=>window.open("https://needle.tools","_blank")),l.style.cursor="pointer",l.style.userSelect="none",l.style.pointerEvents="all",l.style.objectFit="contain",l.src=CL,r&&this._element){const p=this._element.getAttribute("loading-logo-src");p&&(l.src=p)}this._loadingElement.appendChild(l),this._loadingElement.appendChild(o),this._loadingBar=document.createElement("div"),o.appendChild(this._loadingBar);const u=function(p){return tt.lerp(a*.5,100-a*.5,p)+"%"};if(this._loadingBar.style.background=`linear-gradient(90deg, #02022B ${u(0)}, #0BA398 ${u(.4)}, #99CC33 ${u(.5)}, #D7DB0A ${u(1)})`,this._loadingBar.style.backgroundAttachment="fixed",this._loadingBar.style.width="0%",this._loadingBar.style.height="100%",r&&this._element){const p=this._element.getAttribute("primary-color"),f=this._element.getAttribute("secondary-color");p&&f?this._loadingBar.style.background=`linear-gradient(90deg, ${p} ${u(0)}, ${f} ${u(1)})`:p?this._loadingBar.style.background=p:f&&(this._loadingBar.style.background=f)}this._loadingTextContainer=document.createElement("div"),this._loadingTextContainer.style.display="flex",this._loadingTextContainer.style.justifyContent="center",this._loadingTextContainer.style.marginTop="1.2em",this._loadingElement.appendChild(this._loadingTextContainer);const d=document.createElement("div");if(this._messageContainer=d,d.style.display="flex",d.style.fontSize=".8em",d.style.paddingTop=".5em",d.style.fontWeight="200",d.style.fontFamily="Roboto, sans-serif, Arial",d.style.justifyContent="center",this._loadingElement.appendChild(d),r&&this._element){const p=this._element.getAttribute("loading-text-color");p&&(d.style.color=p)}return this.handleRuntimeLicense(this._loadingElement),this._loadingElement}async handleRuntimeLicense(i){let e=Jd();if(e||(au&&(IL&&console.log("Waiting for runtime license check"),await au,e=Jd()),e))return;IL&&console.log("Loading UI has commercial license?",e);const t=document.createElement("div");t.style.paddingTop=".6em",t.style.fontSize=".8em",t.innerText="NON COMMERCIAL",i.appendChild(t)}};let LC=OC;h(LC,"LoadingContainerClassName","loading");const UC=new WeakMap;class FC extends Ys{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,s,r){const n=new Ps(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,o=>{this.parse(o,t,r)},s,r)}parse(e,t,s){this.decodeDracoFile(e,t,null,null,et).catch(s)}decodeDracoFile(e,t,s,r,n=ts){const o={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:n};return this.decodeGeometry(e,o).then(t)}decodeGeometry(e,t){const s=JSON.stringify(t);if(UC.has(e)){const l=UC.get(e);if(l.key===s)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const n=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(n,o).then(l=>(r=l,new Promise((c,u)=>{r._callbacks[n]={resolve:c,reject:u},r.postMessage({type:"decode",id:n,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{r&&n&&this._releaseTask(r,n)}),UC.set(e,{key:s,promise:a}),a}_createGeometry(e){const t=new gt;e.index&&t.setIndex(new rt(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const r=e.attributes[s],n=r.name,o=r.array,a=r.itemSize,l=new rt(o,a);n==="color"&&(this._assignVertexColorSpace(l,r.vertexColorSpace),l.normalized=!(o instanceof Float32Array)),t.setAttribute(n,l)}return t}_assignVertexColorSpace(e,t){if(t!==et)return;const s=new _e;for(let r=0,n=e.count;r<n;r++)s.fromBufferAttribute(e,r).convertSRGBToLinear(),e.setXYZ(r,s.r,s.g,s.b)}_loadLibrary(e,t){const s=new Ps(this.manager);return s.setPath(this.decoderPath),s.setResponseType(t),s.setWithCredentials(this.withCredentials),new Promise((r,n)=>{s.load(e,r,void 0,n)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(s=>{const r=s[0];e||(this.decoderConfig.wasmBinary=s[1]);const n=dY.toString(),o=["/* draco decoder */",r,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join(`
4427
4445
  `);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(n){const o=n.data;switch(o.type){case"decode":r._callbacks[o.id].resolve(o);break;case"error":r._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,n){return r._taskLoad>n._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=t,s._taskLoad+=t,s})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function dY(){let i,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":i=a.decoderConfig,e=new Promise(function(u){i.onModuleLoaded=function(d){u({draco:d})},DracoDecoderModule(i)});break;case"decode":const l=a.buffer,c=a.taskConfig;e.then(u=>{const d=u.draco,p=new d.Decoder;try{const f=t(d,p,new Int8Array(l),c),m=f.attributes.map(A=>A.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:a.id,error:f.message})}finally{d.destroy(p)}});break}};function t(o,a,l,c){const u=c.attributeIDs,d=c.attributeTypes;let p,f;const m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)p=new o.Mesh,f=a.DecodeArrayToMesh(l,l.byteLength,p);else if(m===o.POINT_CLOUD)p=new o.PointCloud,f=a.DecodeArrayToPointCloud(l,l.byteLength,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const A={index:null,attributes:[]};for(const v in u){const g=self[d[v]];let b,y;if(c.useUniqueIDs)y=u[v],b=a.GetAttributeByUniqueId(p,y);else{if(y=a.GetAttributeId(p,o[u[v]]),y===-1)continue;b=a.GetAttribute(p,y)}const _=r(o,a,p,v,g,b);v==="color"&&(_.vertexColorSpace=c.vertexColorSpace),A.attributes.push(_)}return m===o.TRIANGULAR_MESH&&(A.index=s(o,a,p)),o.destroy(p),A}function s(o,a,l){const c=l.num_faces()*3,u=c*4,d=o._malloc(u);a.GetTrianglesUInt32Array(l,u,d);const p=new Uint32Array(o.HEAPF32.buffer,d,c).slice();return o._free(d),{array:p,itemSize:1}}function r(o,a,l,c,u,d){const p=d.num_components(),f=l.num_points()*p,m=f*u.BYTES_PER_ELEMENT,A=n(o,u),v=o._malloc(m);a.GetAttributeDataArrayForAllPoints(l,d,A,m,v);const g=new u(o.HEAPF32.buffer,v,f).slice();return o._free(v),{name:c,array:g,itemSize:p}}function n(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}class pY{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const s=this.workersResolve[e];if(s&&s(t),this.queue.length){const{resolve:r,msg:n,transfer:o}=this.queue.shift();this.workersResolve[e]=r,this.workers[e].postMessage(n,o)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise(s=>{const r=this._getIdleWorker();r!==-1?(this._initWorker(r),this.workerStatus|=1<<r,this.workersResolve[r]=s,this.workers[r].postMessage(e,t)):this.queue.push({resolve:s,msg:e,transfer:t})})}dispose(){this.workers.forEach(e=>e.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const fY=0,mY=2,gY=1,vY=2,AY=0,PL=9,NC=15,BL=16,zC=22,kL=37,jC=43,DL=76,OL=83,LL=97,UL=100,FL=103,NL=109;class yY{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize: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:[]}],this.keyValue={},this.globalData=null}}class Gm{constructor(e,t,s,r){this._dataView=new DataView(e.buffer,e.byteOffset+t,s),this._littleEndian=r,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_skip(e){return this._offset+=e,this}_scan(e,t=0){const s=this._offset;let r=0;for(;this._dataView.getUint8(this._offset)!==t&&r<e;)r++,this._offset++;return r<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+s,r)}}const Hr=[171,75,84,88,32,50,48,187,13,10,26,10];function zL(i){return typeof TextDecoder<"u"?new TextDecoder().decode(i):Buffer.from(i).toString("utf8")}function bY(i){const e=new Uint8Array(i.buffer,i.byteOffset,Hr.length);if(e[0]!==Hr[0]||e[1]!==Hr[1]||e[2]!==Hr[2]||e[3]!==Hr[3]||e[4]!==Hr[4]||e[5]!==Hr[5]||e[6]!==Hr[6]||e[7]!==Hr[7]||e[8]!==Hr[8]||e[9]!==Hr[9]||e[10]!==Hr[10]||e[11]!==Hr[11])throw new Error("Missing KTX 2.0 identifier.");const t=new yY,s=17*Uint32Array.BYTES_PER_ELEMENT,r=new Gm(i,Hr.length,s,!0);t.vkFormat=r._nextUint32(),t.typeSize=r._nextUint32(),t.pixelWidth=r._nextUint32(),t.pixelHeight=r._nextUint32(),t.pixelDepth=r._nextUint32(),t.layerCount=r._nextUint32(),t.faceCount=r._nextUint32();const n=r._nextUint32();t.supercompressionScheme=r._nextUint32();const o=r._nextUint32(),a=r._nextUint32(),l=r._nextUint32(),c=r._nextUint32(),u=r._nextUint64(),d=r._nextUint64(),p=new Gm(i,Hr.length+s,3*n*8,!0);for(let L=0;L<n;L++)t.levels.push({levelData:new Uint8Array(i.buffer,i.byteOffset+p._nextUint64(),p._nextUint64()),uncompressedByteLength:p._nextUint64()});const f=new Gm(i,o,a,!0),m={vendorId:f._skip(4)._nextUint16(),descriptorType:f._nextUint16(),versionNumber:f._nextUint16(),descriptorBlockSize:f._nextUint16(),colorModel:f._nextUint8(),colorPrimaries:f._nextUint8(),transferFunction:f._nextUint8(),flags:f._nextUint8(),texelBlockDimension:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],bytesPlane:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],samples:[]},A=(m.descriptorBlockSize/4-6)/4;for(let L=0;L<A;L++){const N={bitOffset:f._nextUint16(),bitLength:f._nextUint8(),channelType:f._nextUint8(),samplePosition:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&N.channelType?(N.sampleLower=f._nextInt32(),N.sampleUpper=f._nextInt32()):(N.sampleLower=f._nextUint32(),N.sampleUpper=f._nextUint32()),m.samples[L]=N}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(m);const v=new Gm(i,l,c,!0);for(;v._offset<c;){const L=v._nextUint32(),N=v._scan(L),re=zL(N),Z=v._scan(L-N.byteLength);t.keyValue[re]=re.match(/^ktx/i)?zL(Z):Z,v._offset%4&&v._skip(4-v._offset%4)}if(d<=0)return t;const g=new Gm(i,u,d,!0),b=g._nextUint16(),y=g._nextUint16(),_=g._nextUint32(),S=g._nextUint32(),M=g._nextUint32(),I=g._nextUint32(),R=[];for(let L=0;L<n;L++)R.push({imageFlags:g._nextUint32(),rgbSliceByteOffset:g._nextUint32(),rgbSliceByteLength:g._nextUint32(),alphaSliceByteOffset:g._nextUint32(),alphaSliceByteLength:g._nextUint32()});const E=u+g._offset,C=E+_,z=C+S,q=z+M,Q=new Uint8Array(i.buffer,i.byteOffset+E,_),G=new Uint8Array(i.buffer,i.byteOffset+C,S),$=new Uint8Array(i.buffer,i.byteOffset+z,M),F=new Uint8Array(i.buffer,i.byteOffset+q,I);return t.globalData={endpointCount:b,selectorCount:y,imageDescs:R,endpointsData:Q,selectorsData:G,tablesData:$,extendedData:F},t}let QC,Cl,GC;const HC={env:{emscripten_notify_memory_growth:function(i){GC=new Uint8Array(Cl.exports.memory.buffer)}}};class _Y{init(){return QC||(QC=typeof fetch<"u"?fetch("data:application/wasm;base64,"+jL).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,HC)).then(this._init):WebAssembly.instantiate(Buffer.from(jL,"base64"),HC).then(this._init),QC)}_init(e){Cl=e.instance,HC.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!Cl)throw new Error("ZSTDDecoder: Await .init() before decoding.");const s=e.byteLength,r=Cl.exports.malloc(s);GC.set(e,r),t=t||Number(Cl.exports.ZSTD_findDecompressedSize(r,s));const n=Cl.exports.malloc(t),o=Cl.exports.ZSTD_decompress(n,t,r,s),a=GC.slice(n,n+o);return Cl.exports.free(r),Cl.exports.free(n),a}}const jL="AGFzbQEAAAABpQEVYAF/AX9gAn9/AGADf39/AX9gBX9/f39/AX9gAX8AYAJ/fwF/YAR/f39/AX9gA39/fwBgBn9/f39/fwF/YAd/f39/f39/AX9gAn9/AX5gAn5+AX5gAABgBX9/f39/AGAGf39/f39/AGAIf39/f39/f38AYAl/f39/f39/f38AYAABf2AIf39/f39/f38Bf2ANf39/f39/f39/f39/fwF/YAF/AX4CJwEDZW52H2Vtc2NyaXB0ZW5fbm90aWZ5X21lbW9yeV9ncm93dGgABANpaAEFAAAFAgEFCwACAQABAgIFBQcAAwABDgsBAQcAEhMHAAUBDAQEAAANBwQCAgYCBAgDAwMDBgEACQkHBgICAAYGAgQUBwYGAwIGAAMCAQgBBwUGCgoEEQAEBAEIAwgDBQgDEA8IAAcABAUBcAECAgUEAQCAAgYJAX8BQaCgwAILB2AHBm1lbW9yeQIABm1hbGxvYwAoBGZyZWUAJgxaU1REX2lzRXJyb3IAaBlaU1REX2ZpbmREZWNvbXByZXNzZWRTaXplAFQPWlNURF9kZWNvbXByZXNzAEoGX3N0YXJ0ACQJBwEAQQELASQKussBaA8AIAAgACgCBCABajYCBAsZACAAKAIAIAAoAgRBH3F0QQAgAWtBH3F2CwgAIABBiH9LC34BBH9BAyEBIAAoAgQiA0EgTQRAIAAoAggiASAAKAIQTwRAIAAQDQ8LIAAoAgwiAiABRgRAQQFBAiADQSBJGw8LIAAgASABIAJrIANBA3YiBCABIARrIAJJIgEbIgJrIgQ2AgggACADIAJBA3RrNgIEIAAgBCgAADYCAAsgAQsUAQF/IAAgARACIQIgACABEAEgAgv3AQECfyACRQRAIABCADcCACAAQQA2AhAgAEIANwIIQbh/DwsgACABNgIMIAAgAUEEajYCECACQQRPBEAgACABIAJqIgFBfGoiAzYCCCAAIAMoAAA2AgAgAUF/ai0AACIBBEAgAEEIIAEQFGs2AgQgAg8LIABBADYCBEF/DwsgACABNgIIIAAgAS0AACIDNgIAIAJBfmoiBEEBTQRAIARBAWtFBEAgACABLQACQRB0IANyIgM2AgALIAAgAS0AAUEIdCADajYCAAsgASACakF/ai0AACIBRQRAIABBADYCBEFsDwsgAEEoIAEQFCACQQN0ams2AgQgAgsWACAAIAEpAAA3AAAgACABKQAINwAICy8BAX8gAUECdEGgHWooAgAgACgCAEEgIAEgACgCBGprQR9xdnEhAiAAIAEQASACCyEAIAFCz9bTvtLHq9lCfiAAfEIfiUKHla+vmLbem55/fgsdAQF/IAAoAgggACgCDEYEfyAAKAIEQSBGBUEACwuCBAEDfyACQYDAAE8EQCAAIAEgAhBnIAAPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAkEBSARAIAAhAgwBCyAAQQNxRQRAIAAhAgwBCyAAIQIDQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADTw0BIAJBA3ENAAsLAkAgA0F8cSIEQcAASQ0AIAIgBEFAaiIFSw0AA0AgAiABKAIANgIAIAIgASgCBDYCBCACIAEoAgg2AgggAiABKAIMNgIMIAIgASgCEDYCECACIAEoAhQ2AhQgAiABKAIYNgIYIAIgASgCHDYCHCACIAEoAiA2AiAgAiABKAIkNgIkIAIgASgCKDYCKCACIAEoAiw2AiwgAiABKAIwNgIwIAIgASgCNDYCNCACIAEoAjg2AjggAiABKAI8NgI8IAFBQGshASACQUBrIgIgBU0NAAsLIAIgBE8NAQNAIAIgASgCADYCACABQQRqIQEgAkEEaiICIARJDQALDAELIANBBEkEQCAAIQIMAQsgA0F8aiIEIABJBEAgACECDAELIAAhAgNAIAIgAS0AADoAACACIAEtAAE6AAEgAiABLQACOgACIAIgAS0AAzoAAyABQQRqIQEgAkEEaiICIARNDQALCyACIANJBEADQCACIAEtAAA6AAAgAUEBaiEBIAJBAWoiAiADRw0ACwsgAAsMACAAIAEpAAA3AAALQQECfyAAKAIIIgEgACgCEEkEQEEDDwsgACAAKAIEIgJBB3E2AgQgACABIAJBA3ZrIgE2AgggACABKAAANgIAQQALDAAgACABKAIANgAAC/cCAQJ/AkAgACABRg0AAkAgASACaiAASwRAIAAgAmoiBCABSw0BCyAAIAEgAhALDwsgACABc0EDcSEDAkACQCAAIAFJBEAgAwRAIAAhAwwDCyAAQQNxRQRAIAAhAwwCCyAAIQMDQCACRQ0EIAMgAS0AADoAACABQQFqIQEgAkF/aiECIANBAWoiA0EDcQ0ACwwBCwJAIAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQhBSAGQQR2IQRBICAAdCIAQQFyIQkgASgCACEPQQAhAiADIQYCQANAIAlBAkggAiAPS3JFBEAgAiEHAkAgCARAA0AgBEH//wNxQf//A0YEQCAHQRhqIQcgBiAQSQR/IAZBAmoiBigAACAFdgUgBUEQaiEFIARBEHYLIQQMAQsLA0AgBEEDcSIIQQNGBEAgBUECaiEFIARBAnYhBCAHQQNqIQcMAQsLIAcgCGoiByAPSw0EIAVBAmohBQNAIAIgB0kEQCANIAJBAXRqQQA7AQAgAkEBaiECDAELCyAGIA5LQQAgBiAFQQN1aiIHIAxLG0UEQCAHKAAAIAVBB3EiBXYhBAwCCyAEQQJ2IQQLIAYhBwsCfyALQX9qIAQgAEF/anEiBiAAQQF0QX9qIgggCWsiEUkNABogBCAIcSIEQQAgESAEIABIG2shBiALCyEIIA0gAkEBdGogBkF/aiIEOwEAIAlBASAGayAEIAZBAUgbayEJA0AgCSAASARAIABBAXUhACALQX9qIQsMAQsLAn8gByAOS0EAIAcgBSAIaiIFQQN1aiIGIAxLG0UEQCAFQQdxDAELIAUgDCIGIAdrQQN0awshBSACQQFqIQIgBEUhCCAGKAAAIAVBH3F2IQQMAQsLQWwgCUEBRyAFQSBKcg0BGiABIAJBf2o2AgAgBiAFQQdqQQN1aiADawwBC0FQCyEAIApBEGokACAACwkAQQFBBSAAGwsMACAAIAEoAAA2AAALqgMBCn8jAEHwAGsiCiQAIAJBAWohDiAAQQhqIQtBgIAEIAVBf2p0QRB1IQxBACECQQEhBkEBIAV0IglBf2oiDyEIA0AgAiAORkUEQAJAIAEgAkEBdCINai8BACIHQf//A0YEQCALIAhBA3RqIAI2AgQgCEF/aiEIQQEhBwwBCyAGQQAgDCAHQRB0QRB1ShshBgsgCiANaiAHOwEAIAJBAWohAgwBCwsgACAFNgIEIAAgBjYCACAJQQN2IAlBAXZqQQNqIQxBACEAQQAhBkEAIQIDQCAGIA5GBEADQAJAIAAgCUYNACAKIAsgAEEDdGoiASgCBCIGQQF0aiICIAIvAQAiAkEBajsBACABIAUgAhAUayIIOgADIAEgAiAIQf8BcXQgCWs7AQAgASAEIAZBAnQiAmooAgA6AAIgASACIANqKAIANgIEIABBAWohAAwBCwsFIAEgBkEBdGouAQAhDUEAIQcDQCAHIA1ORQRAIAsgAkEDdGogBjYCBANAIAIgDGogD3EiAiAISw0ACyAHQQFqIQcMAQsLIAZBAWohBgwBCwsgCkHwAGokAAsjAEIAIAEQCSAAhUKHla+vmLbem55/fkLj3MqV/M7y9YV/fAsQACAAQn43AwggACABNgIACyQBAX8gAARAIAEoAgQiAgRAIAEoAgggACACEQEADwsgABAmCwsfACAAIAEgAi8BABAINgIAIAEQBBogACACQQRqNgIEC0oBAX9BoCAoAgAiASAAaiIAQX9MBEBBiCBBMDYCAEF/DwsCQCAAPwBBEHRNDQAgABBmDQBBiCBBMDYCAEF/DwtBoCAgADYCACABC9cBAQh/Qbp/IQoCQCACKAIEIgggAigCACIJaiIOIAEgAGtLDQBBbCEKIAkgBCADKAIAIgtrSw0AIAAgCWoiBCACKAIIIgxrIQ0gACABQWBqIg8gCyAJQQAQKSADIAkgC2o2AgACQAJAIAwgBCAFa00EQCANIQUMAQsgDCAEIAZrSw0CIAcgDSAFayIAaiIBIAhqIAdNBEAgBCABIAgQDxoMAgsgBCABQQAgAGsQDyEBIAIgACAIaiIINgIEIAEgAGshBAsgBCAPIAUgCEEBECkLIA4hCgsgCgubAgEBfyMAQYABayINJAAgDSADNgJ8AkAgAkEDSwRAQX8hCQwBCwJAAkACQAJAIAJBAWsOAwADAgELIAZFBEBBuH8hCQwEC0FsIQkgBS0AACICIANLDQMgACAHIAJBAnQiAmooAgAgAiAIaigCABA7IAEgADYCAEEBIQkMAwsgASAJNgIAQQAhCQwCCyAKRQRAQWwhCQwCC0EAIQkgC0UgDEEZSHINAUEIIAR0QQhqIQBBACECA0AgAiAATw0CIAJBQGshAgwAAAsAC0FsIQkgDSANQfwAaiANQfgAaiAFIAYQFSICEAMNACANKAJ4IgMgBEsNACAAIA0gDSgCfCAHIAggAxAYIAEgADYCACACIQkLIA1BgAFqJAAgCQsLACAAIAEgAhALGgsQACAALwAAIAAtAAJBEHRyCy8AAn9BuH8gAUEISQ0AGkFyIAAoAAQiAEF3Sw0AGkG4fyAAQQhqIgAgACABSxsLCwkAIAAgATsAAAsDAAELigYBBX8gACAAKAIAIgVBfnE2AgBBACAAIAVBAXZqQYQgKAIAIgQgAEYbIQECQAJAIAAoAgQiAkUNACACKAIAIgNBAXENACACQQhqIgUgA0EBdkF4aiIDQQggA0EISxtnQR9zQQJ0QYAfaiIDKAIARgRAIAMgAigCDDYCAAsgAigCCCIDBEAgAyACKAIMNgIECyACKAIMIgMEQCADIAIoAgg2AgALIAIgAigCACAAKAIAQX5xajYCAEGEICEAAkACQCABRQ0AIAEgAjYCBCABKAIAIgNBAXENASADQQF2QXhqIgNBCCADQQhLG2dBH3NBAnRBgB9qIgMoAgAgAUEIakYEQCADIAEoAgw2AgALIAEoAggiAwRAIAMgASgCDDYCBAsgASgCDCIDBEAgAyABKAIINgIAQYQgKAIAIQQLIAIgAigCACABKAIAQX5xajYCACABIARGDQAgASABKAIAQQF2akEEaiEACyAAIAI2AgALIAIoAgBBAXZBeGoiAEEIIABBCEsbZ0Efc0ECdEGAH2oiASgCACEAIAEgBTYCACACIAA2AgwgAkEANgIIIABFDQEgACAFNgIADwsCQCABRQ0AIAEoAgAiAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAigCACABQQhqRgRAIAIgASgCDDYCAAsgASgCCCICBEAgAiABKAIMNgIECyABKAIMIgIEQCACIAEoAgg2AgBBhCAoAgAhBAsgACAAKAIAIAEoAgBBfnFqIgI2AgACQCABIARHBEAgASABKAIAQQF2aiAANgIEIAAoAgAhAgwBC0GEICAANgIACyACQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgIoAgAhASACIABBCGoiAjYCACAAIAE2AgwgAEEANgIIIAFFDQEgASACNgIADwsgBUEBdkF4aiIBQQggAUEISxtnQR9zQQJ0QYAfaiICKAIAIQEgAiAAQQhqIgI2AgAgACABNgIMIABBADYCCCABRQ0AIAEgAjYCAAsLDgAgAARAIABBeGoQJQsLgAIBA38CQCAAQQ9qQXhxQYQgKAIAKAIAQQF2ayICEB1Bf0YNAAJAQYQgKAIAIgAoAgAiAUEBcQ0AIAFBAXZBeGoiAUEIIAFBCEsbZ0Efc0ECdEGAH2oiASgCACAAQQhqRgRAIAEgACgCDDYCAAsgACgCCCIBBEAgASAAKAIMNgIECyAAKAIMIgFFDQAgASAAKAIINgIAC0EBIQEgACAAKAIAIAJBAXRqIgI2AgAgAkEBcQ0AIAJBAXZBeGoiAkEIIAJBCEsbZ0Efc0ECdEGAH2oiAygCACECIAMgAEEIaiIDNgIAIAAgAjYCDCAAQQA2AgggAkUNACACIAM2AgALIAELtwIBA38CQAJAIABBASAAGyICEDgiAA0AAkACQEGEICgCACIARQ0AIAAoAgAiA0EBcQ0AIAAgA0EBcjYCACADQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgAgAEEIakYEQCABIAAoAgw2AgALIAAoAggiAQRAIAEgACgCDDYCBAsgACgCDCIBBEAgASAAKAIINgIACyACECchAkEAIQFBhCAoAgAhACACDQEgACAAKAIAQX5xNgIAQQAPCyACQQ9qQXhxIgMQHSICQX9GDQIgAkEHakF4cSIAIAJHBEAgACACaxAdQX9GDQMLAkBBhCAoAgAiAUUEQEGAICAANgIADAELIAAgATYCBAtBhCAgADYCACAAIANBAXRBAXI2AgAMAQsgAEUNAQsgAEEIaiEBCyABC7kDAQJ/IAAgA2ohBQJAIANBB0wEQANAIAAgBU8NAiAAIAItAAA6AAAgAEEBaiEAIAJBAWohAgwAAAsACyAEQQFGBEACQCAAIAJrIgZBB00EQCAAIAItAAA6AAAgACACLQABOgABIAAgAi0AAjoAAiAAIAItAAM6AAMgAEEEaiACIAZBAnQiBkHAHmooAgBqIgIQFyACIAZB4B5qKAIAayECDAELIAAgAhAMCyACQQhqIQIgAEEIaiEACwJAAkACQAJAIAUgAU0EQCAAIANqIQEgBEEBRyAAIAJrQQ9Kcg0BA0AgACACEAwgAkEIaiECIABBCGoiACABSQ0ACwwFCyAAIAFLBEAgACEBDAQLIARBAUcgACACa0EPSnINASAAIQMgAiEEA0AgAyAEEAwgBEEIaiEEIANBCGoiAyABSQ0ACwwCCwNAIAAgAhAHIAJBEGohAiAAQRBqIgAgAUkNAAsMAwsgACEDIAIhBANAIAMgBBAHIARBEGohBCADQRBqIgMgAUkNAAsLIAIgASAAa2ohAgsDQCABIAVPDQEgASACLQAAOgAAIAFBAWohASACQQFqIQIMAAALAAsLQQECfyAAIAAoArjgASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigCACACaiAAQQZ2IgFBAnRBsB5qKAIAaiAAQSBxIgBFaiABRSAAQQV2cWoFQbh/CwsdACAAKAKQ4gEQWiAAQQA2AqDiASAAQgA3A5DiAQu1AwEFfyMAQZACayIKJABBuH8hBgJAIAVFDQAgBCwAACIIQf8BcSEHAkAgCEF/TARAIAdBgn9qQQF2IgggBU8NAkFsIQYgB0GBf2oiBUGAAk8NAiAEQQFqIQdBACEGA0AgBiAFTwRAIAUhBiAIIQcMAwUgACAGaiAHIAZBAXZqIgQtAABBBHY6AAAgACAGQQFyaiAELQAAQQ9xOgAAIAZBAmohBgwBCwAACwALIAcgBU8NASAAIARBAWogByAKEFMiBhADDQELIAYhBEEAIQYgAUEAQTQQECEJQQAhBQNAIAQgBkcEQCAAIAZqIggtAAAiAUELSwRAQWwhBgwDBSAJIAFBAnRqIgEgASgCAEEBajYCACAGQQFqIQZBASAILQAAdEEBdSAFaiEFDAILAAsLQWwhBiAFRQ0AIAUQFEEBaiIBQQxLDQAgAyABNgIAQQFBASABdCAFayIDEBQiAXQgA0cNACAAIARqIAFBAWoiADoAACAJIABBAnRqIgAgACgCAEEBajYCACAJKAIEIgBBAkkgAEEBcXINACACIARBAWo2AgAgB0EBaiEGCyAKQZACaiQAIAYLxhEBDH8jAEHwAGsiBSQAQWwhCwJAIANBCkkNACACLwAAIQogAi8AAiEJIAIvAAQhByAFQQhqIAQQDgJAIAMgByAJIApqakEGaiIMSQ0AIAUtAAohCCAFQdgAaiACQQZqIgIgChAGIgsQAw0BIAVBQGsgAiAKaiICIAkQBiILEAMNASAFQShqIAIgCWoiAiAHEAYiCxADDQEgBUEQaiACIAdqIAMgDGsQBiILEAMNASAAIAFqIg9BfWohECAEQQRqIQZBASELIAAgAUEDakECdiIDaiIMIANqIgIgA2oiDiEDIAIhBCAMIQcDQCALIAMgEElxBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgCS0AAyELIAcgBiAFQUBrIAgQAkECdGoiCS8BADsAACAFQUBrIAktAAIQASAJLQADIQogBCAGIAVBKGogCBACQQJ0aiIJLwEAOwAAIAVBKGogCS0AAhABIAktAAMhCSADIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgDS0AAyENIAAgC2oiCyAGIAVB2ABqIAgQAkECdGoiAC8BADsAACAFQdgAaiAALQACEAEgAC0AAyEAIAcgCmoiCiAGIAVBQGsgCBACQQJ0aiIHLwEAOwAAIAVBQGsgBy0AAhABIActAAMhByAEIAlqIgkgBiAFQShqIAgQAkECdGoiBC8BADsAACAFQShqIAQtAAIQASAELQADIQQgAyANaiIDIAYgBUEQaiAIEAJBAnRqIg0vAQA7AAAgBUEQaiANLQACEAEgACALaiEAIAcgCmohByAEIAlqIQQgAyANLQADaiEDIAVB2ABqEA0gBUFAaxANciAFQShqEA1yIAVBEGoQDXJFIQsMAQsLIAQgDksgByACS3INAEFsIQsgACAMSw0BIAxBfWohCQNAQQAgACAJSSAFQdgAahAEGwRAIAAgBiAFQdgAaiAIEAJBAnRqIgovAQA7AAAgBUHYAGogCi0AAhABIAAgCi0AA2oiACAGIAVB2ABqIAgQAkECdGoiCi8BADsAACAFQdgAaiAKLQACEAEgACAKLQADaiEADAEFIAxBfmohCgNAIAVB2ABqEAQgACAKS3JFBEAgACAGIAVB2ABqIAgQAkECdGoiCS8BADsAACAFQdgAaiAJLQACEAEgACAJLQADaiEADAELCwNAIAAgCk0EQCAAIAYgBUHYAGogCBACQQJ0aiIJLwEAOwAAIAVB2ABqIAktAAIQASAAIAktAANqIQAMAQsLAkAgACAMTw0AIAAgBiAFQdgAaiAIEAIiAEECdGoiDC0AADoAACAMLQADQQFGBEAgBUHYAGogDC0AAhABDAELIAUoAlxBH0sNACAFQdgAaiAGIABBAnRqLQACEAEgBSgCXEEhSQ0AIAVBIDYCXAsgAkF9aiEMA0BBACAHIAxJIAVBQGsQBBsEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiIAIAYgBUFAayAIEAJBAnRqIgcvAQA7AAAgBUFAayAHLQACEAEgACAHLQADaiEHDAEFIAJBfmohDANAIAVBQGsQBCAHIAxLckUEQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwNAIAcgDE0EQCAHIAYgBUFAayAIEAJBAnRqIgAvAQA7AAAgBUFAayAALQACEAEgByAALQADaiEHDAELCwJAIAcgAk8NACAHIAYgBUFAayAIEAIiAEECdGoiAi0AADoAACACLQADQQFGBEAgBUFAayACLQACEAEMAQsgBSgCREEfSw0AIAVBQGsgBiAAQQJ0ai0AAhABIAUoAkRBIUkNACAFQSA2AkQLIA5BfWohAgNAQQAgBCACSSAFQShqEAQbBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2oiACAGIAVBKGogCBACQQJ0aiIELwEAOwAAIAVBKGogBC0AAhABIAAgBC0AA2ohBAwBBSAOQX5qIQIDQCAFQShqEAQgBCACS3JFBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsDQCAEIAJNBEAgBCAGIAVBKGogCBACQQJ0aiIALwEAOwAAIAVBKGogAC0AAhABIAQgAC0AA2ohBAwBCwsCQCAEIA5PDQAgBCAGIAVBKGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBKGogAi0AAhABDAELIAUoAixBH0sNACAFQShqIAYgAEECdGotAAIQASAFKAIsQSFJDQAgBUEgNgIsCwNAQQAgAyAQSSAFQRBqEAQbBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2oiACAGIAVBEGogCBACQQJ0aiICLwEAOwAAIAVBEGogAi0AAhABIAAgAi0AA2ohAwwBBSAPQX5qIQIDQCAFQRBqEAQgAyACS3JFBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsDQCADIAJNBEAgAyAGIAVBEGogCBACQQJ0aiIALwEAOwAAIAVBEGogAC0AAhABIAMgAC0AA2ohAwwBCwsCQCADIA9PDQAgAyAGIAVBEGogCBACIgBBAnRqIgItAAA6AAAgAi0AA0EBRgRAIAVBEGogAi0AAhABDAELIAUoAhRBH0sNACAFQRBqIAYgAEECdGotAAIQASAFKAIUQSFJDQAgBUEgNgIUCyABQWwgBUHYAGoQCiAFQUBrEApxIAVBKGoQCnEgBUEQahAKcRshCwwJCwAACwALAAALAAsAAAsACwAACwALQWwhCwsgBUHwAGokACALC7UEAQ5/IwBBEGsiBiQAIAZBBGogABAOQVQhBQJAIARB3AtJDQAgBi0ABCEHIANB8ARqQQBB7AAQECEIIAdBDEsNACADQdwJaiIJIAggBkEIaiAGQQxqIAEgAhAxIhAQA0UEQCAGKAIMIgQgB0sNASADQdwFaiEPIANBpAVqIREgAEEEaiESIANBqAVqIQEgBCEFA0AgBSICQX9qIQUgCCACQQJ0aigCAEUNAAsgAkEBaiEOQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgASALaiAKNgIAIAVBAWohBSAKIAxqIQoMAQsLIAEgCjYCAEEAIQUgBigCCCELA0AgBSALRkUEQCABIAUgCWotAAAiDEECdGoiDSANKAIAIg1BAWo2AgAgDyANQQF0aiINIAw6AAEgDSAFOgAAIAVBAWohBQwBCwtBACEBIANBADYCqAUgBEF/cyAHaiEJQQEhBQNAIAUgDk9FBEAgCCAFQQJ0IgtqKAIAIQwgAyALaiABNgIAIAwgBSAJanQgAWohASAFQQFqIQUMAQsLIAcgBEEBaiIBIAJrIgRrQQFqIQgDQEEBIQUgBCAIT0UEQANAIAUgDk9FBEAgBUECdCIJIAMgBEE0bGpqIAMgCWooAgAgBHY2AgAgBUEBaiEFDAELCyAEQQFqIQQMAQsLIBIgByAPIAogESADIAIgARBkIAZBAToABSAGIAc6AAYgACAGKAIENgIACyAQIQULIAZBEGokACAFC8ENAQt/IwBB8ABrIgUkAEFsIQkCQCADQQpJDQAgAi8AACEKIAIvAAIhDCACLwAEIQYgBUEIaiAEEA4CQCADIAYgCiAMampBBmoiDUkNACAFLQAKIQcgBUHYAGogAkEGaiICIAoQBiIJEAMNASAFQUBrIAIgCmoiAiAMEAYiCRADDQEgBUEoaiACIAxqIgIgBhAGIgkQAw0BIAVBEGogAiAGaiADIA1rEAYiCRADDQEgACABaiIOQX1qIQ8gBEEEaiEGQQEhCSAAIAFBA2pBAnYiAmoiCiACaiIMIAJqIg0hAyAMIQQgCiECA0AgCSADIA9JcQRAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAACAGIAVBQGsgBxACQQF0aiIILQAAIQsgBUFAayAILQABEAEgAiALOgAAIAYgBUEoaiAHEAJBAXRqIggtAAAhCyAFQShqIAgtAAEQASAEIAs6AAAgBiAFQRBqIAcQAkEBdGoiCC0AACELIAVBEGogCC0AARABIAMgCzoAACAGIAVB2ABqIAcQAkEBdGoiCC0AACELIAVB2ABqIAgtAAEQASAAIAs6AAEgBiAFQUBrIAcQAkEBdGoiCC0AACELIAVBQGsgCC0AARABIAIgCzoAASAGIAVBKGogBxACQQF0aiIILQAAIQsgBUEoaiAILQABEAEgBCALOgABIAYgBUEQaiAHEAJBAXRqIggtAAAhCyAFQRBqIAgtAAEQASADIAs6AAEgA0ECaiEDIARBAmohBCACQQJqIQIgAEECaiEAIAkgBUHYAGoQDUVxIAVBQGsQDUVxIAVBKGoQDUVxIAVBEGoQDUVxIQkMAQsLIAQgDUsgAiAMS3INAEFsIQkgACAKSw0BIApBfWohCQNAIAVB2ABqEAQgACAJT3JFBEAgBiAFQdgAaiAHEAJBAXRqIggtAAAhCyAFQdgAaiAILQABEAEgACALOgAAIAYgBUHYAGogBxACQQF0aiIILQAAIQsgBUHYAGogCC0AARABIAAgCzoAASAAQQJqIQAMAQsLA0AgBUHYAGoQBCAAIApPckUEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCwNAIAAgCkkEQCAGIAVB2ABqIAcQAkEBdGoiCS0AACEIIAVB2ABqIAktAAEQASAAIAg6AAAgAEEBaiEADAELCyAMQX1qIQADQCAFQUBrEAQgAiAAT3JFBEAgBiAFQUBrIAcQAkEBdGoiCi0AACEJIAVBQGsgCi0AARABIAIgCToAACAGIAVBQGsgBxACQQF0aiIKLQAAIQkgBUFAayAKLQABEAEgAiAJOgABIAJBAmohAgwBCwsDQCAFQUBrEAQgAiAMT3JFBEAgBiAFQUBrIAcQAkEBdGoiAC0AACEKIAVBQGsgAC0AARABIAIgCjoAACACQQFqIQIMAQsLA0AgAiAMSQRAIAYgBUFAayAHEAJBAXRqIgAtAAAhCiAFQUBrIAAtAAEQASACIAo6AAAgAkEBaiECDAELCyANQX1qIQADQCAFQShqEAQgBCAAT3JFBEAgBiAFQShqIAcQAkEBdGoiAi0AACEKIAVBKGogAi0AARABIAQgCjoAACAGIAVBKGogBxACQQF0aiICLQAAIQogBUEoaiACLQABEAEgBCAKOgABIARBAmohBAwBCwsDQCAFQShqEAQgBCANT3JFBEAgBiAFQShqIAcQAkEBdGoiAC0AACECIAVBKGogAC0AARABIAQgAjoAACAEQQFqIQQMAQsLA0AgBCANSQRAIAYgBUEoaiAHEAJBAXRqIgAtAAAhAiAFQShqIAAtAAEQASAEIAI6AAAgBEEBaiEEDAELCwNAIAVBEGoQBCADIA9PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIAYgBUEQaiAHEAJBAXRqIgAtAAAhAiAFQRBqIAAtAAEQASADIAI6AAEgA0ECaiEDDAELCwNAIAVBEGoQBCADIA5PckUEQCAGIAVBEGogBxACQQF0aiIALQAAIQIgBUEQaiAALQABEAEgAyACOgAAIANBAWohAwwBCwsDQCADIA5JBEAgBiAFQRBqIAcQAkEBdGoiAC0AACECIAVBEGogAC0AARABIAMgAjoAACADQQFqIQMMAQsLIAFBbCAFQdgAahAKIAVBQGsQCnEgBUEoahAKcSAFQRBqEApxGyEJDAELQWwhCQsgBUHwAGokACAJC8oCAQR/IwBBIGsiBSQAIAUgBBAOIAUtAAIhByAFQQhqIAIgAxAGIgIQA0UEQCAEQQRqIQIgACABaiIDQX1qIQQDQCAFQQhqEAQgACAET3JFBEAgAiAFQQhqIAcQAkEBdGoiBi0AACEIIAVBCGogBi0AARABIAAgCDoAACACIAVBCGogBxACQQF0aiIGLQAAIQggBUEIaiAGLQABEAEgACAIOgABIABBAmohAAwBCwsDQCAFQQhqEAQgACADT3JFBEAgAiAFQQhqIAcQAkEBdGoiBC0AACEGIAVBCGogBC0AARABIAAgBjoAACAAQQFqIQAMAQsLA0AgACADT0UEQCACIAVBCGogBxACQQF0aiIELQAAIQYgBUEIaiAELQABEAEgACAGOgAAIABBAWohAAwBCwsgAUFsIAVBCGoQChshAgsgBUEgaiQAIAILtgMBCX8jAEEQayIGJAAgBkEANgIMIAZBADYCCEFUIQQCQAJAIANBQGsiDCADIAZBCGogBkEMaiABIAIQMSICEAMNACAGQQRqIAAQDiAGKAIMIgcgBi0ABEEBaksNASAAQQRqIQogBkEAOgAFIAYgBzoABiAAIAYoAgQ2AgAgB0EBaiEJQQEhBANAIAQgCUkEQCADIARBAnRqIgEoAgAhACABIAU2AgAgACAEQX9qdCAFaiEFIARBAWohBAwBCwsgB0EBaiEHQQAhBSAGKAIIIQkDQCAFIAlGDQEgAyAFIAxqLQAAIgRBAnRqIgBBASAEdEEBdSILIAAoAgAiAWoiADYCACAHIARrIQhBACEEAkAgC0EDTQRAA0AgBCALRg0CIAogASAEakEBdGoiACAIOgABIAAgBToAACAEQQFqIQQMAAALAAsDQCABIABPDQEgCiABQQF0aiIEIAg6AAEgBCAFOgAAIAQgCDoAAyAEIAU6AAIgBCAIOgAFIAQgBToABCAEIAg6AAcgBCAFOgAGIAFBBGohAQwAAAsACyAFQQFqIQUMAAALAAsgAiEECyAGQRBqJAAgBAutAQECfwJAQYQgKAIAIABHIAAoAgBBAXYiAyABa0F4aiICQXhxQQhHcgR/IAIFIAMQJ0UNASACQQhqC0EQSQ0AIAAgACgCACICQQFxIAAgAWpBD2pBeHEiASAAa0EBdHI2AgAgASAANgIEIAEgASgCAEEBcSAAIAJBAXZqIAFrIgJBAXRyNgIAQYQgIAEgAkH/////B3FqQQRqQYQgKAIAIABGGyABNgIAIAEQJQsLygIBBX8CQAJAAkAgAEEIIABBCEsbZ0EfcyAAaUEBR2oiAUEESSAAIAF2cg0AIAFBAnRB/B5qKAIAIgJFDQADQCACQXhqIgMoAgBBAXZBeGoiBSAATwRAIAIgBUEIIAVBCEsbZ0Efc0ECdEGAH2oiASgCAEYEQCABIAIoAgQ2AgALDAMLIARBHksNASAEQQFqIQQgAigCBCICDQALC0EAIQMgAUEgTw0BA0AgAUECdEGAH2ooAgAiAkUEQCABQR5LIQIgAUEBaiEBIAJFDQEMAwsLIAIgAkF4aiIDKAIAQQF2QXhqIgFBCCABQQhLG2dBH3NBAnRBgB9qIgEoAgBGBEAgASACKAIENgIACwsgAigCACIBBEAgASACKAIENgIECyACKAIEIgEEQCABIAIoAgA2AgALIAMgAygCAEEBcjYCACADIAAQNwsgAwvhCwINfwV+IwBB8ABrIgckACAHIAAoAvDhASIINgJcIAEgAmohDSAIIAAoAoDiAWohDwJAAkAgBUUEQCABIQQMAQsgACgCxOABIRAgACgCwOABIREgACgCvOABIQ4gAEEBNgKM4QFBACEIA0AgCEEDRwRAIAcgCEECdCICaiAAIAJqQazQAWooAgA2AkQgCEEBaiEIDAELC0FsIQwgB0EYaiADIAQQBhADDQEgB0EsaiAHQRhqIAAoAgAQEyAHQTRqIAdBGGogACgCCBATIAdBPGogB0EYaiAAKAIEEBMgDUFgaiESIAEhBEEAIQwDQCAHKAIwIAcoAixBA3RqKQIAIhRCEIinQf8BcSEIIAcoAkAgBygCPEEDdGopAgAiFUIQiKdB/wFxIQsgBygCOCAHKAI0QQN0aikCACIWQiCIpyEJIBVCIIghFyAUQiCIpyECAkAgFkIQiKdB/wFxIgNBAk8EQAJAIAZFIANBGUlyRQRAIAkgB0EYaiADQSAgBygCHGsiCiAKIANLGyIKEAUgAyAKayIDdGohCSAHQRhqEAQaIANFDQEgB0EYaiADEAUgCWohCQwBCyAHQRhqIAMQBSAJaiEJIAdBGGoQBBoLIAcpAkQhGCAHIAk2AkQgByAYNwNIDAELAkAgA0UEQCACBEAgBygCRCEJDAMLIAcoAkghCQwBCwJAAkAgB0EYakEBEAUgCSACRWpqIgNBA0YEQCAHKAJEQX9qIgMgA0VqIQkMAQsgA0ECdCAHaigCRCIJIAlFaiEJIANBAUYNAQsgByAHKAJINgJMCwsgByAHKAJENgJIIAcgCTYCRAsgF6chAyALBEAgB0EYaiALEAUgA2ohAwsgCCALakEUTwRAIAdBGGoQBBoLIAgEQCAHQRhqIAgQBSACaiECCyAHQRhqEAQaIAcgB0EYaiAUQhiIp0H/AXEQCCAUp0H//wNxajYCLCAHIAdBGGogFUIYiKdB/wFxEAggFadB//8DcWo2AjwgB0EYahAEGiAHIAdBGGogFkIYiKdB/wFxEAggFqdB//8DcWo2AjQgByACNgJgIAcoAlwhCiAHIAk2AmggByADNgJkAkACQAJAIAQgAiADaiILaiASSw0AIAIgCmoiEyAPSw0AIA0gBGsgC0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdBKGogACgCBBATQQAhBCAHQeAAaiEMIAdB5ABqIQoDQCAHQShqEARBAksgBCAXTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEJIAcoAkggBygCREEDdGopAgAiH0IgiKchCCAeQiCIISAgHUIgiKchAgJAIB9CEIinQf8BcSIDQQJPBEACQCAGRSADQRlJckUEQCAIIAdBKGogA0EgIAcoAixrIg0gDSADSxsiDRAFIAMgDWsiA3RqIQggB0EoahAEGiADRQ0BIAdBKGogAxAFIAhqIQgMAQsgB0EoaiADEAUgCGohCCAHQShqEAQaCyAHKQJUISEgByAINgJUIAcgITcDWAwBCwJAIANFBEAgAgRAIAcoAlQhCAwDCyAHKAJYIQgMAQsCQAJAIAdBKGpBARAFIAggAkVqaiIDQQNGBEAgBygCVEF/aiIDIANFaiEIDAELIANBAnQgB2ooAlQiCCAIRWohCCADQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAg2AlQLICCnIQMgCQRAIAdBKGogCRAFIANqIQMLIAkgC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgAmohAgsgB0EoahAEGiAHIAcoAmggAmoiCSADajYCaCAKIAwgCCAJSxsoAgAhDSAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogB0EoaiAfQhiIp0H/AXEQCCEOIAdB8ABqIARBBHRqIgsgCSANaiAIazYCDCALIAg2AgggCyADNgIEIAsgAjYCACAHIA4gH6dB//8DcWo2AkQgBEEBaiEEDAELCyAEIBdIDQEgEkFgaiEYIAdB4ABqIRogB0HkAGohGyABIQMDQCAHQShqEARBAksgBCAFTnJFBEAgBygCQCAHKAI8QQN0aikCACIdQhCIp0H/AXEhCyAHKAJQIAcoAkxBA3RqKQIAIh5CEIinQf8BcSEIIAcoAkggBygCREEDdGopAgAiH0IgiKchCSAeQiCIISAgHUIgiKchDAJAIB9CEIinQf8BcSICQQJPBEACQCAGRSACQRlJckUEQCAJIAdBKGogAkEgIAcoAixrIgogCiACSxsiChAFIAIgCmsiAnRqIQkgB0EoahAEGiACRQ0BIAdBKGogAhAFIAlqIQkMAQsgB0EoaiACEAUgCWohCSAHQShqEAQaCyAHKQJUISEgByAJNgJUIAcgITcDWAwBCwJAIAJFBEAgDARAIAcoAlQhCQwDCyAHKAJYIQkMAQsCQAJAIAdBKGpBARAFIAkgDEVqaiICQQNGBEAgBygCVEF/aiICIAJFaiEJDAELIAJBAnQgB2ooAlQiCSAJRWohCSACQQFGDQELIAcgBygCWDYCXAsLIAcgBygCVDYCWCAHIAk2AlQLICCnIRQgCARAIAdBKGogCBAFIBRqIRQLIAggC2pBFE8EQCAHQShqEAQaCyALBEAgB0EoaiALEAUgDGohDAsgB0EoahAEGiAHIAcoAmggDGoiGSAUajYCaCAbIBogCSAZSxsoAgAhHCAHIAdBKGogHUIYiKdB/wFxEAggHadB//8DcWo2AjwgByAHQShqIB5CGIinQf8BcRAIIB6nQf//A3FqNgJMIAdBKGoQBBogByAHQShqIB9CGIinQf8BcRAIIB+nQf//A3FqNgJEIAcgB0HwAGogBEEDcUEEdGoiDSkDCCIdNwPIASAHIA0pAwAiHjcDwAECQAJAAkAgBygCvAEiDiAepyICaiIWIBNLDQAgAyAHKALEASIKIAJqIgtqIBhLDQAgEiADayALQSBqTw0BCyAHIAcpA8gBNwMQIAcgBykDwAE3AwggAyASIAdBCGogB0G8AWogEyAPIBUgERAeIQsMAQsgAiADaiEIIAMgDhAHIAJBEU8EQCADQRBqIQIDQCACIA5BEGoiDhAHIAJBEGoiAiAISQ0ACwsgCCAdpyIOayECIAcgFjYCvAEgDiAIIA9rSwRAIA4gCCAVa0sEQEFsIQsMAgsgESACIA9rIgJqIhYgCmogEU0EQCAIIBYgChAPGgwCCyAIIBZBACACaxAPIQggByACIApqIgo2AsQBIAggAmshCCAPIQILIA5BEE8EQCAIIApqIQoDQCAIIAIQByACQRBqIQIgCEEQaiIIIApJDQALDAELAkAgDkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgDkECdCIKQcAeaigCAGoiAhAXIAIgCkHgHmooAgBrIQIgBygCxAEhCgwBCyAIIAIQDAsgCkEJSQ0AIAggCmohCiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAKSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAKSQ0ACwsgCxADBEAgCyEQDAQFIA0gDDYCACANIBkgHGogCWs2AgwgDSAJNgIIIA0gFDYCBCAEQQFqIQQgAyALaiEDDAILAAsLIAQgBUgNASAEIBdrIQtBACEEA0AgCyAFSARAIAcgB0HwAGogC0EDcUEEdGoiAikDCCIdNwPIASAHIAIpAwAiHjcDwAECQAJAAkAgBygCvAEiDCAepyICaiIKIBNLDQAgAyAHKALEASIJIAJqIhBqIBhLDQAgEiADayAQQSBqTw0BCyAHIAcpA8gBNwMgIAcgBykDwAE3AxggAyASIAdBGGogB0G8AWogEyAPIBUgERAeIRAMAQsgAiADaiEIIAMgDBAHIAJBEU8EQCADQRBqIQIDQCACIAxBEGoiDBAHIAJBEGoiAiAISQ0ACwsgCCAdpyIGayECIAcgCjYCvAEgBiAIIA9rSwRAIAYgCCAVa0sEQEFsIRAMAgsgESACIA9rIgJqIgwgCWogEU0EQCAIIAwgCRAPGgwCCyAIIAxBACACaxAPIQggByACIAlqIgk2AsQBIAggAmshCCAPIQILIAZBEE8EQCAIIAlqIQYDQCAIIAIQByACQRBqIQIgCEEQaiIIIAZJDQALDAELAkAgBkEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgBkECdCIGQcAeaigCAGoiAhAXIAIgBkHgHmooAgBrIQIgBygCxAEhCQwBCyAIIAIQDAsgCUEJSQ0AIAggCWohBiAIQQhqIgggAkEIaiICa0EPTARAA0AgCCACEAwgAkEIaiECIAhBCGoiCCAGSQ0ADAIACwALA0AgCCACEAcgAkEQaiECIAhBEGoiCCAGSQ0ACwsgEBADDQMgC0EBaiELIAMgEGohAwwBCwsDQCAEQQNHBEAgACAEQQJ0IgJqQazQAWogAiAHaigCVDYCACAEQQFqIQQMAQsLIAcoArwBIQgLQbp/IRAgEyAIayIAIBIgA2tLDQAgAwR/IAMgCCAAEAsgAGoFQQALIAFrIRALIAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY0AAQMyIFEAMiBg0AIANBHzYCfCADIANB/ABqIANB+ABqIAQgBCAFaiAGGyIEIAEgAmoiAiAEaxAVIgUQAw0AIAMoAnwiBkEfSw0AIAMoAngiB0EJTw0AIABBiCBqIAMgBkGAC0GADCAHEBggA0E0NgJ8IAMgA0H8AGogA0H4AGogBCAFaiIEIAIgBGsQFSIFEAMNACADKAJ8IgZBNEsNACADKAJ4IgdBCk8NACAAQZAwaiADIAZBgA1B4A4gBxAYIANBIzYCfCADIANB/ABqIANB+ABqIAQgBWoiBCACIARrEBUiBRADDQAgAygCfCIGQSNLDQAgAygCeCIHQQpPDQAgACADIAZBwBBB0BEgBxAYIAQgBWoiBEEMaiIFIAJLDQAgAiAFayEFQQAhAgNAIAJBA0cEQCAEKAAAIgZBf2ogBU8NAiAAIAJBAnRqQZzQAWogBjYCACACQQFqIQIgBEEEaiEEDAELCyAEIAFrIQgLIANBgAFqJAAgCAtGAQN/IABBCGohAyAAKAIEIQJBACEAA0AgACACdkUEQCABIAMgAEEDdGotAAJBFktqIQEgAEEBaiEADAELCyABQQggAmt0C4YDAQV/Qbh/IQcCQCADRQ0AIAItAAAiBEUEQCABQQA2AgBBAUG4fyADQQFGGw8LAn8gAkEBaiIFIARBGHRBGHUiBkF/Sg0AGiAGQX9GBEAgA0EDSA0CIAUvAABBgP4BaiEEIAJBA2oMAQsgA0ECSA0BIAItAAEgBEEIdHJBgIB+aiEEIAJBAmoLIQUgASAENgIAIAVBAWoiASACIANqIgNLDQBBbCEHIABBEGogACAFLQAAIgVBBnZBI0EJIAEgAyABa0HAEEHQEUHwEiAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBmCBqIABBCGogBUEEdkEDcUEfQQggASABIAZqIAgbIgEgAyABa0GAC0GADEGAFyAAKAKM4QEgACgCnOIBIAQQHyIGEAMiCA0AIABBoDBqIABBBGogBUECdkEDcUE0QQkgASABIAZqIAgbIgEgAyABa0GADUHgDkGQGSAAKAKM4QEgACgCnOIBIAQQHyIAEAMNACAAIAFqIAJrIQcLIAcLrQMBCn8jAEGABGsiCCQAAn9BUiACQf8BSw0AGkFUIANBDEsNABogAkEBaiELIABBBGohCUGAgAQgA0F/anRBEHUhCkEAIQJBASEEQQEgA3QiB0F/aiIMIQUDQCACIAtGRQRAAkAgASACQQF0Ig1qLwEAIgZB//8DRgRAIAkgBUECdGogAjoAAiAFQX9qIQVBASEGDAELIARBACAKIAZBEHRBEHVKGyEECyAIIA1qIAY7AQAgAkEBaiECDAELCyAAIAQ7AQIgACADOwEAIAdBA3YgB0EBdmpBA2ohBkEAIQRBACECA0AgBCALRkUEQCABIARBAXRqLgEAIQpBACEAA0AgACAKTkUEQCAJIAJBAnRqIAQ6AAIDQCACIAZqIAxxIgIgBUsNAAsgAEEBaiEADAELCyAEQQFqIQQMAQsLQX8gAg0AGkEAIQIDfyACIAdGBH9BAAUgCCAJIAJBAnRqIgAtAAJBAXRqIgEgAS8BACIBQQFqOwEAIAAgAyABEBRrIgU6AAMgACABIAVB/wFxdCAHazsBACACQQFqIQIMAQsLCyEFIAhBgARqJAAgBQvjBgEIf0FsIQcCQCACQQNJDQACQAJAAkACQCABLQAAIgNBA3EiCUEBaw4DAwEAAgsgACgCiOEBDQBBYg8LIAJBBUkNAkEDIQYgASgAACEFAn8CQAJAIANBAnZBA3EiCEF+aiIEQQFNBEAgBEEBaw0BDAILIAVBDnZB/wdxIQQgBUEEdkH/B3EhAyAIRQwCCyAFQRJ2IQRBBCEGIAVBBHZB//8AcSEDQQAMAQsgBUEEdkH//w9xIgNBgIAISw0DIAEtAARBCnQgBUEWdnIhBEEFIQZBAAshBSAEIAZqIgogAksNAgJAIANBgQZJDQAgACgCnOIBRQ0AQQAhAgNAIAJBg4ABSw0BIAJBQGshAgwAAAsACwJ/IAlBA0YEQCABIAZqIQEgAEHw4gFqIQIgACgCDCEGIAUEQCACIAMgASAEIAYQXwwCCyACIAMgASAEIAYQXQwBCyAAQbjQAWohAiABIAZqIQEgAEHw4gFqIQYgAEGo0ABqIQggBQRAIAggBiADIAEgBCACEF4MAQsgCCAGIAMgASAEIAIQXAsQAw0CIAAgAzYCgOIBIABBATYCiOEBIAAgAEHw4gFqNgLw4QEgCUECRgRAIAAgAEGo0ABqNgIMCyAAIANqIgBBiOMBakIANwAAIABBgOMBakIANwAAIABB+OIBakIANwAAIABB8OIBakIANwAAIAoPCwJ/AkACQAJAIANBAnZBA3FBf2oiBEECSw0AIARBAWsOAgACAQtBASEEIANBA3YMAgtBAiEEIAEvAABBBHYMAQtBAyEEIAEQIUEEdgsiAyAEaiIFQSBqIAJLBEAgBSACSw0CIABB8OIBaiABIARqIAMQCyEBIAAgAzYCgOIBIAAgATYC8OEBIAEgA2oiAEIANwAYIABCADcAECAAQgA3AAggAEIANwAAIAUPCyAAIAM2AoDiASAAIAEgBGo2AvDhASAFDwsCfwJAAkACQCADQQJ2QQNxQX9qIgRBAksNACAEQQFrDgIAAgELQQEhByADQQN2DAILQQIhByABLwAAQQR2DAELIAJBBEkgARAhIgJBj4CAAUtyDQFBAyEHIAJBBHYLIQIgAEHw4gFqIAEgB2otAAAgAkEgahAQIQEgACACNgKA4gEgACABNgLw4QEgB0EBaiEHCyAHC0sAIABC+erQ0OfJoeThADcDICAAQgA3AxggAELP1tO+0ser2UI3AxAgAELW64Lu6v2J9eAANwMIIABCADcDACAAQShqQQBBKBAQGgviAgICfwV+IABBKGoiASAAKAJIaiECAn4gACkDACIDQiBaBEAgACkDECIEQgeJIAApAwgiBUIBiXwgACkDGCIGQgyJfCAAKQMgIgdCEol8IAUQGSAEEBkgBhAZIAcQGQwBCyAAKQMYQsXP2bLx5brqJ3wLIAN8IQMDQCABQQhqIgAgAk0EQEIAIAEpAAAQCSADhUIbiUKHla+vmLbem55/fkLj3MqV/M7y9YV/fCEDIAAhAQwBCwsCQCABQQRqIgAgAksEQCABIQAMAQsgASgAAK1Ch5Wvr5i23puef34gA4VCF4lCz9bTvtLHq9lCfkL5893xmfaZqxZ8IQMLA0AgACACSQRAIAAxAABCxc/ZsvHluuonfiADhUILiUKHla+vmLbem55/fiEDIABBAWohAAwBCwsgA0IhiCADhULP1tO+0ser2UJ+IgNCHYggA4VC+fPd8Zn2masWfiIDQiCIIAOFC+8CAgJ/BH4gACAAKQMAIAKtfDcDAAJAAkAgACgCSCIDIAJqIgRBH00EQCABRQ0BIAAgA2pBKGogASACECAgACgCSCACaiEEDAELIAEgAmohAgJ/IAMEQCAAQShqIgQgA2ogAUEgIANrECAgACAAKQMIIAQpAAAQCTcDCCAAIAApAxAgACkAMBAJNwMQIAAgACkDGCAAKQA4EAk3AxggACAAKQMgIABBQGspAAAQCTcDICAAKAJIIQMgAEEANgJIIAEgA2tBIGohAQsgAUEgaiACTQsEQCACQWBqIQMgACkDICEFIAApAxghBiAAKQMQIQcgACkDCCEIA0AgCCABKQAAEAkhCCAHIAEpAAgQCSEHIAYgASkAEBAJIQYgBSABKQAYEAkhBSABQSBqIgEgA00NAAsgACAFNwMgIAAgBjcDGCAAIAc3AxAgACAINwMICyABIAJPDQEgAEEoaiABIAIgAWsiBBAgCyAAIAQ2AkgLCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQEBogAwVBun8LCy8BAX8gAEUEQEG2f0EAIAMbDwtBun8hBCADIAFNBH8gACACIAMQCxogAwVBun8LC6gCAQZ/IwBBEGsiByQAIABB2OABaikDAEKAgIAQViEIQbh/IQUCQCAEQf//B0sNACAAIAMgBBBCIgUQAyIGDQAgACgCnOIBIQkgACAHQQxqIAMgAyAFaiAGGyIKIARBACAFIAYbayIGEEAiAxADBEAgAyEFDAELIAcoAgwhBCABRQRAQbp/IQUgBEEASg0BCyAGIANrIQUgAyAKaiEDAkAgCQRAIABBADYCnOIBDAELAkACQAJAIARBBUgNACAAQdjgAWopAwBCgICACFgNAAwBCyAAQQA2ApziAQwBCyAAKAIIED8hBiAAQQA2ApziASAGQRRPDQELIAAgASACIAMgBSAEIAgQOSEFDAELIAAgASACIAMgBSAEIAgQOiEFCyAHQRBqJAAgBQtnACAAQdDgAWogASACIAAoAuzhARAuIgEQAwRAIAEPC0G4fyECAkAgAQ0AIABB7OABaigCACIBBEBBYCECIAAoApjiASABRw0BC0EAIQIgAEHw4AFqKAIARQ0AIABBkOEBahBDCyACCycBAX8QVyIERQRAQUAPCyAEIAAgASACIAMgBBBLEE8hACAEEFYgAAs/AQF/AkACQAJAIAAoAqDiAUEBaiIBQQJLDQAgAUEBaw4CAAECCyAAEDBBAA8LIABBADYCoOIBCyAAKAKU4gELvAMCB38BfiMAQRBrIgkkAEG4fyEGAkAgBCgCACIIQQVBCSAAKALs4QEiBRtJDQAgAygCACIHQQFBBSAFGyAFEC8iBRADBEAgBSEGDAELIAggBUEDakkNACAAIAcgBRBJIgYQAw0AIAEgAmohCiAAQZDhAWohCyAIIAVrIQIgBSAHaiEHIAEhBQNAIAcgAiAJECwiBhADDQEgAkF9aiICIAZJBEBBuH8hBgwCCyAJKAIAIghBAksEQEFsIQYMAgsgB0EDaiEHAn8CQAJAAkAgCEEBaw4CAgABCyAAIAUgCiAFayAHIAYQSAwCCyAFIAogBWsgByAGEEcMAQsgBSAKIAVrIActAAAgCSgCCBBGCyIIEAMEQCAIIQYMAgsgACgC8OABBEAgCyAFIAgQRQsgAiAGayECIAYgB2ohByAFIAhqIQUgCSgCBEUNAAsgACkD0OABIgxCf1IEQEFsIQYgDCAFIAFrrFINAQsgACgC8OABBEBBaiEGIAJBBEkNASALEEQhDCAHKAAAIAynRw0BIAdBBGohByACQXxqIQILIAMgBzYCACAEIAI2AgAgBSABayEGCyAJQRBqJAAgBgsuACAAECsCf0EAQQAQAw0AGiABRSACRXJFBEBBYiAAIAEgAhA9EAMNARoLQQALCzcAIAEEQCAAIAAoAsTgASABKAIEIAEoAghqRzYCnOIBCyAAECtBABADIAFFckUEQCAAIAEQWwsL0QIBB38jAEEQayIGJAAgBiAENgIIIAYgAzYCDCAFBEAgBSgCBCEKIAUoAgghCQsgASEIAkACQANAIAAoAuzhARAWIQsCQANAIAQgC0kNASADKAAAQXBxQdDUtMIBRgRAIAMgBBAiIgcQAw0EIAQgB2shBCADIAdqIQMMAQsLIAYgAzYCDCAGIAQ2AggCQCAFBEAgACAFEE5BACEHQQAQA0UNAQwFCyAAIAogCRBNIgcQAw0ECyAAIAgQUCAMQQFHQQAgACAIIAIgBkEMaiAGQQhqEEwiByIDa0EAIAMQAxtBCkdyRQRAQbh/IQcMBAsgBxADDQMgAiAHayECIAcgCGohCEEBIQwgBigCDCEDIAYoAgghBAwBCwsgBiADNgIMIAYgBDYCCEG4fyEHIAQNASAIIAFrIQcMAQsgBiADNgIMIAYgBDYCCAsgBkEQaiQAIAcLRgECfyABIAAoArjgASICRwRAIAAgAjYCxOABIAAgATYCuOABIAAoArzgASEDIAAgATYCvOABIAAgASADIAJrajYCwOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEEdCAAbiECCyAAQQh2IgEgAkEYbCIAQYwIaigCAGwgAEGICGooAgBqIgJBA3YgAmogAEGACGooAgAgAEGECGooAgAgAWxqSQs3ACAAIAMgBCAFQYAQEDMiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQMgVBuH8LC78DAQN/IwBBIGsiBSQAIAVBCGogAiADEAYiAhADRQRAIAAgAWoiB0F9aiEGIAUgBBAOIARBBGohAiAFLQACIQMDQEEAIAAgBkkgBUEIahAEGwRAIAAgAiAFQQhqIAMQAkECdGoiBC8BADsAACAFQQhqIAQtAAIQASAAIAQtAANqIgQgAiAFQQhqIAMQAkECdGoiAC8BADsAACAFQQhqIAAtAAIQASAEIAAtAANqIQAMAQUgB0F+aiEEA0AgBUEIahAEIAAgBEtyRQRAIAAgAiAFQQhqIAMQAkECdGoiBi8BADsAACAFQQhqIAYtAAIQASAAIAYtAANqIQAMAQsLA0AgACAES0UEQCAAIAIgBUEIaiADEAJBAnRqIgYvAQA7AAAgBUEIaiAGLQACEAEgACAGLQADaiEADAELCwJAIAAgB08NACAAIAIgBUEIaiADEAIiA0ECdGoiAC0AADoAACAALQADQQFGBEAgBUEIaiAALQACEAEMAQsgBSgCDEEfSw0AIAVBCGogAiADQQJ0ai0AAhABIAUoAgxBIUkNACAFQSA2AgwLIAFBbCAFQQhqEAobIQILCwsgBUEgaiQAIAILkgIBBH8jAEFAaiIJJAAgCSADQTQQCyEDAkAgBEECSA0AIAMgBEECdGooAgAhCSADQTxqIAgQIyADQQE6AD8gAyACOgA+QQAhBCADKAI8IQoDQCAEIAlGDQEgACAEQQJ0aiAKNgEAIARBAWohBAwAAAsAC0EAIQkDQCAGIAlGRQRAIAMgBSAJQQF0aiIKLQABIgtBAnRqIgwoAgAhBCADQTxqIAotAABBCHQgCGpB//8DcRAjIANBAjoAPyADIAcgC2siCiACajoAPiAEQQEgASAKa3RqIQogAygCPCELA0AgACAEQQJ0aiALNgEAIARBAWoiBCAKSQ0ACyAMIAo2AgAgCUEBaiEJDAELCyADQUBrJAALowIBCX8jAEHQAGsiCSQAIAlBEGogBUE0EAsaIAcgBmshDyAHIAFrIRADQAJAIAMgCkcEQEEBIAEgByACIApBAXRqIgYtAAEiDGsiCGsiC3QhDSAGLQAAIQ4gCUEQaiAMQQJ0aiIMKAIAIQYgCyAPTwRAIAAgBkECdGogCyAIIAUgCEE0bGogCCAQaiIIQQEgCEEBShsiCCACIAQgCEECdGooAgAiCEEBdGogAyAIayAHIA4QYyAGIA1qIQgMAgsgCUEMaiAOECMgCUEBOgAPIAkgCDoADiAGIA1qIQggCSgCDCELA0AgBiAITw0CIAAgBkECdGogCzYBACAGQQFqIQYMAAALAAsgCUHQAGokAA8LIAwgCDYCACAKQQFqIQoMAAALAAs0ACAAIAMgBCAFEDYiBRADBEAgBQ8LIAUgBEkEfyABIAIgAyAFaiAEIAVrIAAQNAVBuH8LCyMAIAA/AEEQdGtB//8DakEQdkAAQX9GBEBBAA8LQQAQAEEBCzsBAX8gAgRAA0AgACABIAJBgCAgAkGAIEkbIgMQCyEAIAFBgCBqIQEgAEGAIGohACACIANrIgINAAsLCwYAIAAQAwsLqBUJAEGICAsNAQAAAAEAAAACAAAAAgBBoAgLswYBAAAAAQAAAAIAAAACAAAAJgAAAIIAAAAhBQAASgAAAGcIAAAmAAAAwAEAAIAAAABJBQAASgAAAL4IAAApAAAALAIAAIAAAABJBQAASgAAAL4IAAAvAAAAygIAAIAAAACKBQAASgAAAIQJAAA1AAAAcwMAAIAAAACdBQAASgAAAKAJAAA9AAAAgQMAAIAAAADrBQAASwAAAD4KAABEAAAAngMAAIAAAABNBgAASwAAAKoKAABLAAAAswMAAIAAAADBBgAATQAAAB8NAABNAAAAUwQAAIAAAAAjCAAAUQAAAKYPAABUAAAAmQQAAIAAAABLCQAAVwAAALESAABYAAAA2gQAAIAAAABvCQAAXQAAACMUAABUAAAARQUAAIAAAABUCgAAagAAAIwUAABqAAAArwUAAIAAAAB2CQAAfAAAAE4QAAB8AAAA0gIAAIAAAABjBwAAkQAAAJAHAACSAAAAAAAAAAEAAAABAAAABQAAAA0AAAAdAAAAPQAAAH0AAAD9AAAA/QEAAP0DAAD9BwAA/Q8AAP0fAAD9PwAA/X8AAP3/AAD9/wEA/f8DAP3/BwD9/w8A/f8fAP3/PwD9/38A/f//AP3//wH9//8D/f//B/3//w/9//8f/f//P/3//38AAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAAAMAAAAEAAAABQAAAAYAAAAHAAAACAAAAAkAAAAKAAAACwAAAAwAAAANAAAADgAAAA8AAAAQAAAAEQAAABIAAAATAAAAFAAAABUAAAAWAAAAFwAAABgAAAAZAAAAGgAAABsAAAAcAAAAHQAAAB4AAAAfAAAAIAAAACEAAAAiAAAAIwAAACUAAAAnAAAAKQAAACsAAAAvAAAAMwAAADsAAABDAAAAUwAAAGMAAACDAAAAAwEAAAMCAAADBAAAAwgAAAMQAAADIAAAA0AAAAOAAAADAAEAQeAPC1EBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAEAAAABQAAAAcAAAAIAAAACQAAAAoAAAALAAAADAAAAA0AAAAOAAAADwAAABAAQcQQC4sBAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABIAAAAUAAAAFgAAABgAAAAcAAAAIAAAACgAAAAwAAAAQAAAAIAAAAAAAQAAAAIAAAAEAAAACAAAABAAAAAgAAAAQAAAAIAAAAAAAQBBkBIL5gQBAAAAAQAAAAEAAAABAAAAAgAAAAIAAAADAAAAAwAAAAQAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAAAEAAAAEAAAACAAAAAAAAAABAAEBBgAAAAAAAAQAAAAAEAAABAAAAAAgAAAFAQAAAAAAAAUDAAAAAAAABQQAAAAAAAAFBgAAAAAAAAUHAAAAAAAABQkAAAAAAAAFCgAAAAAAAAUMAAAAAAAABg4AAAAAAAEFEAAAAAAAAQUUAAAAAAABBRYAAAAAAAIFHAAAAAAAAwUgAAAAAAAEBTAAAAAgAAYFQAAAAAAABwWAAAAAAAAIBgABAAAAAAoGAAQAAAAADAYAEAAAIAAABAAAAAAAAAAEAQAAAAAAAAUCAAAAIAAABQQAAAAAAAAFBQAAACAAAAUHAAAAAAAABQgAAAAgAAAFCgAAAAAAAAULAAAAAAAABg0AAAAgAAEFEAAAAAAAAQUSAAAAIAABBRYAAAAAAAIFGAAAACAAAwUgAAAAAAADBSgAAAAAAAYEQAAAABAABgRAAAAAIAAHBYAAAAAAAAkGAAIAAAAACwYACAAAMAAABAAAAAAQAAAEAQAAACAAAAUCAAAAIAAABQMAAAAgAAAFBQAAACAAAAUGAAAAIAAABQgAAAAgAAAFCQAAACAAAAULAAAAIAAABQwAAAAAAAAGDwAAACAAAQUSAAAAIAABBRQAAAAgAAIFGAAAACAAAgUcAAAAIAADBSgAAAAgAAQFMAAAAAAAEAYAAAEAAAAPBgCAAAAAAA4GAEAAAAAADQYAIABBgBcLhwIBAAEBBQAAAAAAAAUAAAAAAAAGBD0AAAAAAAkF/QEAAAAADwX9fwAAAAAVBf3/HwAAAAMFBQAAAAAABwR9AAAAAAAMBf0PAAAAABIF/f8DAAAAFwX9/38AAAAFBR0AAAAAAAgE/QAAAAAADgX9PwAAAAAUBf3/DwAAAAIFAQAAABAABwR9AAAAAAALBf0HAAAAABEF/f8BAAAAFgX9/z8AAAAEBQ0AAAAQAAgE/QAAAAAADQX9HwAAAAATBf3/BwAAAAEFAQAAABAABgQ9AAAAAAAKBf0DAAAAABAF/f8AAAAAHAX9//8PAAAbBf3//wcAABoF/f//AwAAGQX9//8BAAAYBf3//wBBkBkLhgQBAAEBBgAAAAAAAAYDAAAAAAAABAQAAAAgAAAFBQAAAAAAAAUGAAAAAAAABQgAAAAAAAAFCQAAAAAAAAULAAAAAAAABg0AAAAAAAAGEAAAAAAAAAYTAAAAAAAABhYAAAAAAAAGGQAAAAAAAAYcAAAAAAAABh8AAAAAAAAGIgAAAAAAAQYlAAAAAAABBikAAAAAAAIGLwAAAAAAAwY7AAAAAAAEBlMAAAAAAAcGgwAAAAAACQYDAgAAEAAABAQAAAAAAAAEBQAAACAAAAUGAAAAAAAABQcAAAAgAAAFCQAAAAAAAAUKAAAAAAAABgwAAAAAAAAGDwAAAAAAAAYSAAAAAAAABhUAAAAAAAAGGAAAAAAAAAYbAAAAAAAABh4AAAAAAAAGIQAAAAAAAQYjAAAAAAABBicAAAAAAAIGKwAAAAAAAwYzAAAAAAAEBkMAAAAAAAUGYwAAAAAACAYDAQAAIAAABAQAAAAwAAAEBAAAABAAAAQFAAAAIAAABQcAAAAgAAAFCAAAACAAAAUKAAAAIAAABQsAAAAAAAAGDgAAAAAAAAYRAAAAAAAABhQAAAAAAAAGFwAAAAAAAAYaAAAAAAAABh0AAAAAAAAGIAAAAAAAEAYDAAEAAAAPBgOAAAAAAA4GA0AAAAAADQYDIAAAAAAMBgMQAAAAAAsGAwgAAAAACgYDBABBpB0L2QEBAAAAAwAAAAcAAAAPAAAAHwAAAD8AAAB/AAAA/wAAAP8BAAD/AwAA/wcAAP8PAAD/HwAA/z8AAP9/AAD//wAA//8BAP//AwD//wcA//8PAP//HwD//z8A//9/AP///wD///8B////A////wf///8P////H////z////9/AAAAAAEAAAACAAAABAAAAAAAAAACAAAABAAAAAgAAAAAAAAAAQAAAAIAAAABAAAABAAAAAQAAAAEAAAABAAAAAgAAAAIAAAACAAAAAcAAAAIAAAACQAAAAoAAAALAEGgIAsDwBBQ",VC=new WeakMap;let WC=0,XC;class sa extends Ys{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new pY,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),etc1Supported:!1,etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-bc"),bptcSupported:!1,pvrtcSupported:!1}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1)),this}init(){if(!this.transcoderPending){const e=new Ps(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),s=new Ps(this.manager);s.setPath(this.transcoderPath),s.setResponseType("arraybuffer"),s.setWithCredentials(this.withCredentials);const r=s.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,r]).then(([n,o])=>{const a=sa.BasisWorker.toString(),l=["/* constants */","let _EngineFormat = "+JSON.stringify(sa.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(sa.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(sa.BasisFormat),"/* basis_transcoder.js */",n,"/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
4428
- `);this.workerSourceURL=URL.createObjectURL(new Blob([l])),this.transcoderBinary=o,this.workerPool.setWorkerCreator(()=>{const c=new Worker(this.workerSourceURL),u=this.transcoderBinary.slice(0);return c.postMessage({type:"init",config:this.workerConfig,transcoderBinary:u},[u]),c})}),WC>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),WC++}return this.transcoderPending}load(e,t,s,r){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const n=new Ps(this.manager);n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials),n.load(e,o=>{if(VC.has(o))return VC.get(o).promise.then(t).catch(r);this._createTexture(o).then(a=>t?t(a):null).catch(r)},s,r)}_createTextureFrom(e,t){const{faces:s,width:r,height:n,format:o,type:a,error:l,dfdTransferFn:c,dfdFlags:u}=e;if(a==="error")return Promise.reject(l);let d;if(t.faceCount===6)d=new cl,d.image=s,d.format=o,d.type=di;else{const p=s[0].mipmaps;d=t.layerCount>1?new RB(p,r,n,t.layerCount,o,di):new cl(p,r,n,o,di)}return d.minFilter=s[0].mipmaps.length===1?Bt:Jn,d.magFilter=Bt,d.generateMipmaps=!1,d.needsUpdate=!0,d.colorSpace=c===vY?et:rn,d.premultiplyAlpha=!!(u&gY),d}async _createTexture(e,t={}){const s=bY(new Uint8Array(e));if(s.vkFormat!==AY){const o=[],a=[];for(let c=0;c<s.levels.length;c++)a.push(wY(s,c).then(function(u){o[c]=u}));await Promise.all(a);const l=o[0];return l.mipmaps=o.map(c=>({data:c.source.data,width:c.source.data.width,height:c.source.data.height,depth:c.source.data.depth})),l}const r=t,n=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:r},[e])).then(o=>this._createTextureFrom(o.data,s));return VC.set(e,{promise:n}),n}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),WC--,this}}sa.BasisFormat={ETC1S:0,UASTC_4x4:1},sa.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},sa.EngineFormat={RGBAFormat:Ci,RGBA_ASTC_4x4_Format:fA,RGBA_BPTC_Format:If,RGBA_ETC2_EAC_Format:pA,RGBA_PVRTC_4BPPV1_Format:uA,RGBA_S3TC_DXT5_Format:Tf,RGB_ETC1_Format:hw,RGB_ETC2_Format:dA,RGB_PVRTC_4BPPV1_Format:hA,RGB_S3TC_DXT1_Format:Mf},sa.BasisWorker=function(){let i,e,t;const s=_EngineFormat,r=_TranscoderFormat,n=_BasisFormat;self.addEventListener("message",function(m){const A=m.data;switch(A.type){case"init":i=A.config,o(A.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:v,buffers:g,width:b,height:y,hasAlpha:_,format:S,dfdTransferFn:M,dfdFlags:I}=a(A.buffer);self.postMessage({type:"transcode",id:A.id,faces:v,width:b,height:y,hasAlpha:_,format:S,dfdTransferFn:M,dfdFlags:I},g)}catch(v){console.error(v),self.postMessage({type:"error",id:A.id,error:v.message})}});break}});function o(m){e=new Promise(A=>{t={wasmBinary:m,onRuntimeInitialized:A},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function a(m){const A=new t.KTX2File(new Uint8Array(m));function v(){A.close(),A.delete()}if(!A.isValid())throw v(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");const g=A.isUASTC()?n.UASTC_4x4:n.ETC1S,b=A.getWidth(),y=A.getHeight(),_=A.getLayers()||1,S=A.getLevels(),M=A.getFaces(),I=A.getHasAlpha(),R=A.getDFDTransferFunc(),E=A.getDFDFlags(),{transcoderFormat:C,engineFormat:z}=d(g,b,y,I);if(!b||!y||!S)throw v(),new Error("THREE.KTX2Loader: Invalid texture");if(!A.startTranscoding())throw v(),new Error("THREE.KTX2Loader: .startTranscoding failed");const q=[],Q=[];for(let G=0;G<M;G++){const $=[];for(let F=0;F<S;F++){const L=[];let N,re;for(let X=0;X<_;X++){const ne=A.getImageLevelInfo(F,X,G);G===0&&F===0&&X===0&&(ne.origWidth%4!==0||ne.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),S>1?(N=ne.origWidth,re=ne.origHeight):(N=ne.width,re=ne.height);const fe=new Uint8Array(A.getImageTranscodedSizeInBytes(F,X,0,C));if(!A.transcodeImage(fe,F,X,G,C,0,-1,-1))throw v(),new Error("THREE.KTX2Loader: .transcodeImage failed.");L.push(fe)}const Z=f(L);$.push({data:Z,width:N,height:re}),Q.push(Z.buffer)}q.push({mipmaps:$,width:b,height:y,format:z})}return v(),{faces:q,buffers:Q,width:b,height:y,hasAlpha:I,format:z,dfdTransferFn:R,dfdFlags:E}}const l=[{if:"astcSupported",basisFormat:[n.UASTC_4x4],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[s.RGBA_ASTC_4x4_Format,s.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[s.RGBA_BPTC_Format,s.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.BC1,r.BC3],engineFormat:[s.RGB_S3TC_DXT1_Format,s.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[s.RGB_ETC2_Format,s.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.ETC1],engineFormat:[s.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[s.RGB_PVRTC_4BPPV1_Format,s.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],c=l.sort(function(m,A){return m.priorityETC1S-A.priorityETC1S}),u=l.sort(function(m,A){return m.priorityUASTC-A.priorityUASTC});function d(m,A,v,g){let b,y;const _=m===n.ETC1S?c:u;for(let S=0;S<_.length;S++){const M=_[S];if(i[M.if]&&M.basisFormat.includes(m)&&!(g&&M.transcoderFormat.length<2)&&!(M.needsPowerOfTwo&&!(p(A)&&p(v))))return b=M.transcoderFormat[g?1:0],y=M.engineFormat[g?1:0],{transcoderFormat:b,engineFormat:y}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),b=r.RGBA32,y=s.RGBAFormat,{transcoderFormat:b,engineFormat:y}}function p(m){return m<=2?!0:(m&m-1)===0&&m!==0}function f(m){if(m.length===1)return m[0];let A=0;for(let b=0;b<m.length;b++){const y=m[b];A+=y.byteLength}const v=new Uint8Array(A);let g=0;for(let b=0;b<m.length;b++){const y=m[b];v.set(y,g),g+=y.byteLength}return v}};const QL={[NL]:Ci,[LL]:Ci,[kL]:Ci,[jC]:Ci,[FL]:Sh,[OL]:Sh,[BL]:Sh,[zC]:Sh,[UL]:el,[DL]:el,[NC]:el,[PL]:el},qC={[NL]:Xi,[LL]:ds,[kL]:di,[jC]:di,[FL]:Xi,[OL]:ds,[BL]:di,[zC]:di,[UL]:Xi,[DL]:ds,[NC]:di,[PL]:di},xY={[jC]:et,[zC]:et,[NC]:et};async function wY(i,e=0){const{vkFormat:t}=i,s=Math.max(1,i.pixelWidth>>e),r=Math.max(1,i.pixelHeight>>e),n=Math.max(1,i.pixelDepth>>e);if(QL[t]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");const o=i.levels[e];let a,l;if(i.supercompressionScheme===fY)a=o.levelData;else if(i.supercompressionScheme===mY)XC||(XC=new Promise(async u=>{const d=new _Y;await d.init(),u(d)})),a=(await XC).decode(o.levelData,o.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");qC[t]===Xi?l=new Float32Array(a.buffer,a.byteOffset,a.byteLength/Float32Array.BYTES_PER_ELEMENT):qC[t]===ds?l=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/Uint16Array.BYTES_PER_ELEMENT):l=a;const c=n===0?new to(l,s,r):new wA(l,s,r,n);return c.type=qC[t],c.format=QL[t],c.colorSpace=xY[t]||rn,c.needsUpdate=!0,Promise.resolve(c)}var SY=function(){var i="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),s=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var r=WebAssembly.validate(t)?e:i,n,o=WebAssembly.instantiate(a(r),{}).then(function(g){n=g.instance,n.exports.__wasm_call_ctors()});function a(g){for(var b=new Uint8Array(g.length),y=0;y<g.length;++y){var _=g.charCodeAt(y);b[y]=_>96?_-97:_>64?_-39:_+4}for(var S=0,y=0;y<g.length;++y)b[S++]=b[y]<60?s[b[y]]:(b[y]-60)*64+b[++y];return b.buffer.slice(0,S)}function l(g,b,y,_,S,M){var I=n.exports.sbrk,R=y+3&-4,E=I(R*_),C=I(S.length),z=new Uint8Array(n.exports.memory.buffer);z.set(S,C);var q=g(E,y,_,C,S.length);if(q==0&&M&&M(E,R,_),b.set(z.subarray(E,E+y*_)),I(E-I(0)),q!=0)throw new Error("Malformed buffer data: "+q)}var c={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},u={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],p=0;function f(g){var b={object:new Worker(g),pending:0,requests:{}};return b.object.onmessage=function(y){var _=y.data;b.pending-=_.count,b.requests[_.id][_.action](_.value),delete b.requests[_.id]},b}function m(g){for(var b="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(a(r))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+l.toString()+v.toString(),y=new Blob([b],{type:"text/javascript"}),_=URL.createObjectURL(y),S=0;S<g;++S)d[S]=f(_);URL.revokeObjectURL(_)}function A(g,b,y,_,S){for(var M=d[0],I=1;I<d.length;++I)d[I].pending<M.pending&&(M=d[I]);return new Promise(function(R,E){var C=new Uint8Array(y),z=p++;M.pending+=g,M.requests[z]={resolve:R,reject:E},M.object.postMessage({id:z,count:g,size:b,source:C,mode:_,filter:S},[C.buffer])})}function v(g){o.then(function(){var b=g.data;try{var y=new Uint8Array(b.count*b.size);l(n.exports[b.mode],y,b.count,b.size,b.source,n.exports[b.filter]),self.postMessage({id:b.id,count:b.count,action:"resolve",value:y},[y.buffer])}catch(_){self.postMessage({id:b.id,count:b.count,action:"reject",value:_})}})}return{ready:o,supported:!0,useWorkers:function(g){m(g)},decodeVertexBuffer:function(g,b,y,_,S){l(n.exports.meshopt_decodeVertexBuffer,g,b,y,_,n.exports[c[S]])},decodeIndexBuffer:function(g,b,y,_){l(n.exports.meshopt_decodeIndexBuffer,g,b,y,_)},decodeIndexSequence:function(g,b,y,_){l(n.exports.meshopt_decodeIndexSequence,g,b,y,_)},decodeGltfBuffer:function(g,b,y,_,S,M){l(n.exports[u[S]],g,b,y,_,n.exports[c[M]])},decodeGltfBufferAsync:function(g,b,y,_,S){return d.length>0?A(g,b,y,u[_],c[S]):o.then(function(){var M=new Uint8Array(g*b);return l(n.exports[u[_]],M,g,b,y,n.exports[c[S]]),M})}}}();const Zd=le("debugdecoders"),GL="https://www.gstatic.com/draco/versioned/decoders/1.4.1/",HL="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";let No,YC,Lc;function VL(i){i!==void 0&&typeof i=="string"&&(No||(No=new FC),Zd&&console.log("Setting draco decoder path to",i),No.setDecoderPath(i))}function WL(i){i!==void 0&&typeof i=="string"&&(No||(No=new FC),Zd&&console.log("Setting draco decoder type to",i),No.setDecoderConfig({type:i}))}function XL(i){i!==void 0&&typeof i=="string"&&(Lc||(Lc=new sa),Zd&&console.log("Setting ktx2 transcoder path to",i),Lc.setTranscoderPath(i))}function Hm(i,e){No||(No=new FC,No.setDecoderPath(GL),No.setDecoderConfig({type:"js"}),Zd&&console.log("Setting draco decoder path to",GL)),Lc||(Lc=new sa,Lc.setTranscoderPath(HL),Zd&&console.log("Setting ktx2 transcoder path to",HL),e.renderer&&Lc.detectSupport(e.renderer)),YC||(YC=SY,Zd&&console.log("Using the default meshopt decoder")),i.setDRACOLoader(No),i.setKTX2Loader(Lc),i.setMeshoptDecoder(YC)}function CY(i,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},s=i.getIndex(),r=i.getAttribute("position"),n=s?s.count:r.count;let o=0;const a=Object.keys(i.attributes),l={},c={},u=[],d=["getX","getY","getZ","getW"],p=["setX","setY","setZ","setW"];for(let v=0,g=a.length;v<g;v++){const b=a[v],y=i.attributes[b];l[b]=new rt(new y.array.constructor(y.count*y.itemSize),y.itemSize,y.normalized);const _=i.morphAttributes[b];_&&(c[b]=new rt(new _.array.constructor(_.count*_.itemSize),_.itemSize,_.normalized))}const f=Math.log10(1/e),m=Math.pow(10,f);for(let v=0;v<n;v++){const g=s?s.getX(v):v;let b="";for(let y=0,_=a.length;y<_;y++){const S=a[y],M=i.getAttribute(S),I=M.itemSize;for(let R=0;R<I;R++)b+=`${~~(M[d[R]](g)*m)},`}if(b in t)u.push(t[b]);else{for(let y=0,_=a.length;y<_;y++){const S=a[y],M=i.getAttribute(S),I=i.morphAttributes[S],R=M.itemSize,E=l[S],C=c[S];for(let z=0;z<R;z++){const q=d[z],Q=p[z];if(E[Q](o,M[q](g)),I)for(let G=0,$=I.length;G<$;G++)C[G][Q](o,I[G][q](g))}}t[b]=o,u.push(o),o++}}const A=i.clone();for(const v in i.attributes){const g=l[v];if(A.setAttribute(v,new rt(g.array.slice(0,o*g.itemSize),g.itemSize,g.normalized)),v in c)for(let b=0;b<c[v].length;b++){const y=c[v][b];A.morphAttributes[v][b]=new rt(y.array.slice(0,o*y.itemSize),y.itemSize,y.normalized)}}return A.setIndex(u),A}function qL(i,e){if(e===GR)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===vA||e===Iw){let t=i.getIndex();if(t===null){const o=[],a=i.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);i.setIndex(o),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}const s=t.count-2,r=[];if(e===vA)for(let o=1;o<=s;o++)r.push(t.getX(0)),r.push(t.getX(o)),r.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(r.push(t.getX(o)),r.push(t.getX(o+1)),r.push(t.getX(o+2))):(r.push(t.getX(o+2)),r.push(t.getX(o+1)),r.push(t.getX(o)));r.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const n=i.clone();return n.setIndex(r),n.clearGroups(),n}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}class $d extends Ys{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new RY(t)}),this.register(function(t){return new FY(t)}),this.register(function(t){return new NY(t)}),this.register(function(t){return new zY(t)}),this.register(function(t){return new BY(t)}),this.register(function(t){return new kY(t)}),this.register(function(t){return new DY(t)}),this.register(function(t){return new OY(t)}),this.register(function(t){return new IY(t)}),this.register(function(t){return new LY(t)}),this.register(function(t){return new PY(t)}),this.register(function(t){return new UY(t)}),this.register(function(t){return new MY(t)}),this.register(function(t){return new jY(t)}),this.register(function(t){return new QY(t)})}load(e,t,s,r){const n=this;let o;this.resourcePath!==""?o=this.resourcePath:this.path!==""?o=this.path:o=Od.extractUrlBase(e),this.manager.itemStart(e);const a=function(c){r?r(c):console.error(c),n.manager.itemError(e),n.manager.itemEnd(e)},l=new Ps(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{n.parse(c,o,function(u){t(u),n.manager.itemEnd(e)},a)}catch(u){a(u)}},s,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,r){let n;const o={},a={},l=new TextDecoder;if(typeof e=="string")n=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===YL){try{o[$t.KHR_BINARY_GLTF]=new GY(e)}catch(u){r&&r(u);return}n=JSON.parse(o[$t.KHR_BINARY_GLTF].content)}else n=JSON.parse(l.decode(e));else n=e;if(n.asset===void 0||n.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new i7(n,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const d=this.pluginCallbacks[u](c);a[d.name]=d,o[d.name]=!0}if(n.extensionsUsed)for(let u=0;u<n.extensionsUsed.length;++u){const d=n.extensionsUsed[u],p=n.extensionsRequired||[];switch(d){case $t.KHR_MATERIALS_UNLIT:o[d]=new TY;break;case $t.KHR_DRACO_MESH_COMPRESSION:o[d]=new HY(n,this.dracoLoader);break;case $t.KHR_TEXTURE_TRANSFORM:o[d]=new VY;break;case $t.KHR_MESH_QUANTIZATION:o[d]=new WY;break;default:p.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(s,r)}parseAsync(e,t){const s=this;return new Promise(function(r,n){s.parse(e,t,r,n)})}}function EY(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}const $t={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class MY{constructor(e){this.parser=e,this.name=$t.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,r=t.length;s<r;s++){const n=t[s];n.extensions&&n.extensions[this.name]&&n.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let r=t.cache.get(s);if(r)return r;const n=t.json,o=((n.extensions&&n.extensions[this.name]||{}).lights||[])[e];let a;const l=new _e(16777215);o.color!==void 0&&l.fromArray(o.color);const c=o.range!==void 0?o.range:0;switch(o.type){case"directional":a=new _0(l),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new b0(l),a.distance=c;break;case"spot":a=new y0(l),a.distance=c,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),a.decay=2,Fc(a,o),o.intensity!==void 0&&(a.intensity=o.intensity),a.name=t.createUniqueName(o.name||"light_"+e),r=Promise.resolve(a),t.cache.add(s,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,r=s.json.nodes[e],n=(r.extensions&&r.extensions[this.name]||{}).light;return n===void 0?null:this._loadLight(n).then(function(o){return s._getNodeRef(t.cache,n,o)})}}let TY=class{constructor(){this.name=$t.KHR_MATERIALS_UNLIT}getMaterialType(){return li}extendParams(i,e,t){const s=[];i.color=new _e(1,1,1),i.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const n=r.baseColorFactor;i.color.fromArray(n),i.opacity=n[3]}r.baseColorTexture!==void 0&&s.push(t.assignTexture(i,"map",r.baseColorTexture,et))}return Promise.all(s)}},IY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(i,e){const t=this.parser.json.materials[i];if(!t.extensions||!t.extensions[this.name])return Promise.resolve();const s=t.extensions[this.name].emissiveStrength;return s!==void 0&&(e.emissiveIntensity=s),Promise.resolve()}},RY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_CLEARCOAT}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];if(n.clearcoatFactor!==void 0&&(e.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(t.assignTexture(e,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(t.assignTexture(e,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(t.assignTexture(e,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const o=n.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new ee(o,o)}return Promise.all(r)}},PY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_IRIDESCENCE}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return n.iridescenceFactor!==void 0&&(e.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(t.assignTexture(e,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(e.iridescenceIOR=n.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(t.assignTexture(e,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(r)}},BY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_SHEEN}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new _e(0,0,0),e.sheenRoughness=0,e.sheen=1;const n=s.extensions[this.name];return n.sheenColorFactor!==void 0&&e.sheenColor.fromArray(n.sheenColorFactor),n.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(t.assignTexture(e,"sheenColorMap",n.sheenColorTexture,et)),n.sheenRoughnessTexture!==void 0&&r.push(t.assignTexture(e,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(r)}},kY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_TRANSMISSION}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return n.transmissionFactor!==void 0&&(e.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(t.assignTexture(e,"transmissionMap",n.transmissionTexture)),Promise.all(r)}},DY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_VOLUME}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];e.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&r.push(t.assignTexture(e,"thicknessMap",n.thicknessTexture)),e.attenuationDistance=n.attenuationDistance||1/0;const o=n.attenuationColor||[1,1,1];return e.attenuationColor=new _e(o[0],o[1],o[2]),Promise.all(r)}},OY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_IOR}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser.json.materials[i];if(!t.extensions||!t.extensions[this.name])return Promise.resolve();const s=t.extensions[this.name];return e.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}},LY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_SPECULAR}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];e.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&r.push(t.assignTexture(e,"specularIntensityMap",n.specularTexture));const o=n.specularColorFactor||[1,1,1];return e.specularColor=new _e(o[0],o[1],o[2]),n.specularColorTexture!==void 0&&r.push(t.assignTexture(e,"specularColorMap",n.specularColorTexture,et)),Promise.all(r)}},UY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_ANISOTROPY}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return n.anisotropyStrength!==void 0&&(e.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(e.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(t.assignTexture(e,"anisotropyMap",n.anisotropyTexture)),Promise.all(r)}};class FY{constructor(e){this.parser=e,this.name=$t.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,r=s.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const n=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,o)}}class NY{constructor(e){this.parser=e,this.name=$t.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,r=s.json,n=r.textures[e];if(!n.extensions||!n.extensions[t])return null;const o=n.extensions[t],a=r.images[o.source];let l=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(e,o.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class zY{constructor(e){this.parser=e,this.name=$t.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,r=s.json,n=r.textures[e];if(!n.extensions||!n.extensions[t])return null;const o=n.extensions[t],a=r.images[o.source];let l=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(e,o.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class jY{constructor(e){this.name=$t.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const r=s.extensions[this.name],n=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then(function(a){const l=r.byteOffset||0,c=r.byteLength||0,u=r.count,d=r.byteStride,p=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,d,p,r.mode,r.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(u*d);return o.decodeGltfBuffer(new Uint8Array(f),u,d,p,r.mode,r.filter),f})})}else return null}}class QY{constructor(e){this.name=$t.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const r=t.meshes[s.mesh];for(const l of r.primitives)if(l.mode!==oo.TRIANGLES&&l.mode!==oo.TRIANGLE_STRIP&&l.mode!==oo.TRIANGLE_FAN&&l.mode!==void 0)return null;const n=s.extensions[this.name].attributes,o=[],a={};for(const l in n)o.push(this.parser.getDependency("accessor",n[l]).then(c=>(a[l]=c,a[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(l=>{const c=l.pop(),u=c.isGroup?c.children:[c],d=l[0].count,p=[];for(const f of u){const m=new Be,A=new w,v=new Ee,g=new w(1,1,1),b=new i0(f.geometry,f.material,d);for(let y=0;y<d;y++)a.TRANSLATION&&A.fromBufferAttribute(a.TRANSLATION,y),a.ROTATION&&v.fromBufferAttribute(a.ROTATION,y),a.SCALE&&g.fromBufferAttribute(a.SCALE,y),b.setMatrixAt(y,m.compose(A,v,g));for(const y in a)y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&f.geometry.setAttribute(y,a[y]);Re.prototype.copy.call(b,f),this.parser.assignFinalMaterial(b),p.push(b)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]}))}}const YL="glTF",Vm=12,KL={JSON:1313821514,BIN:5130562};class GY{constructor(e){this.name=$t.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Vm),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==YL)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-Vm,n=new DataView(e,Vm);let o=0;for(;o<r;){const a=n.getUint32(o,!0);o+=4;const l=n.getUint32(o,!0);if(o+=4,l===KL.JSON){const c=new Uint8Array(e,Vm+o,a);this.content=s.decode(c)}else if(l===KL.BIN){const c=Vm+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class HY{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=$t.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,r=this.dracoLoader,n=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(const u in o){const d=JC[u]||u.toLowerCase();a[d]=o[u]}for(const u in e.attributes){const d=JC[u]||u.toLowerCase();if(o[u]!==void 0){const p=s.accessors[e.attributes[u]],f=ep[p.componentType];c[d]=f.name,l[d]=p.normalized===!0}}return t.getDependency("bufferView",n).then(function(u){return new Promise(function(d){r.decodeDracoFile(u,function(p){for(const f in p.attributes){const m=p.attributes[f],A=l[f];A!==void 0&&(m.normalized=A)}d(p)},a,c)})})}}class VY{constructor(){this.name=$t.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class WY{constructor(){this.name=$t.KHR_MESH_QUANTIZATION}}class JL extends Bd{constructor(e,t,s,r){super(e,t,s,r)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,r=this.valueSize,n=e*r*3+r;for(let o=0;o!==r;o++)t[o]=s[n+o];return t}interpolate_(e,t,s,r){const n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,u=r-t,d=(s-t)/u,p=d*d,f=p*d,m=e*c,A=m-c,v=-2*f+3*p,g=f-p,b=1-v,y=g-p+d;for(let _=0;_!==a;_++){const S=o[A+_+a],M=o[A+_+l]*u,I=o[m+_+a],R=o[m+_]*u;n[_]=b*S+y*M+v*I+g*R}return n}}const XY=new Ee;class qY extends JL{interpolate_(e,t,s,r){const n=super.interpolate_(e,t,s,r);return XY.fromArray(n).normalize().toArray(n),n}}const oo={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},ep={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ZL={9728:jt,9729:Bt,9984:td,9985:Ef,9986:wh,9987:Jn},$L={33071:Ns,33648:xh,10497:Kn},KC={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},JC={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Uc={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},YY={CUBICSPLINE:void 0,LINEAR:aa,STEP:gc},ZC={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function KY(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new Ro({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:gr})),i.DefaultMaterial}function cu(i,e,t){for(const s in t.extensions)i[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function Fc(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function JY(i,e,t){let s=!1,r=!1,n=!1;for(let c=0,u=e.length;c<u;c++){const d=e[c];if(d.POSITION!==void 0&&(s=!0),d.NORMAL!==void 0&&(r=!0),d.COLOR_0!==void 0&&(n=!0),s&&r&&n)break}if(!s&&!r&&!n)return Promise.resolve(i);const o=[],a=[],l=[];for(let c=0,u=e.length;c<u;c++){const d=e[c];if(s){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):i.attributes.position;o.push(p)}if(r){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):i.attributes.normal;a.push(p)}if(n){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):i.attributes.color;l.push(p)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const u=c[0],d=c[1],p=c[2];return s&&(i.morphAttributes.position=u),r&&(i.morphAttributes.normal=d),n&&(i.morphAttributes.color=p),i.morphTargetsRelative=!0,i})}function ZY(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let s=0,r=t.length;s<r;s++)i.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function $Y(i){let e;const t=i.extensions&&i.extensions[$t.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+$C(t.attributes):e=i.indices+":"+$C(i.attributes)+":"+i.mode,i.targets!==void 0)for(let s=0,r=i.targets.length;s<r;s++)e+=":"+$C(i.targets[s]);return e}function $C(i){let e="";const t=Object.keys(i).sort();for(let s=0,r=t.length;s<r;s++)e+=t[s]+":"+i[t[s]]+";";return e}function eE(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function e7(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const t7=new Be;class i7{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new EY,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,r=!1,n=-1;typeof navigator<"u"&&(s=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,n=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||s||r&&n<98?this.textureLoader=new dl(this.options.manager):this.textureLoader=new hk(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ps(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,r=this.json,n=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const a={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:s,userData:{}};cu(n,a,r),Fc(a,r),Promise.all(s._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let r=0,n=t.length;r<n;r++){const o=t[r].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let r=0,n=e.length;r<n;r++){const o=e[r];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const r=s.clone(),n=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,u]of o.children.entries())n(u,a.children[c])};return n(s,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const r=e(t[s]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let r=0;r<t.length;r++){const n=e(t[r]);n&&s.push(n)}return s}getDependency(e,t){const s=e+":"+t;let r=this.cache.get(s);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(n){return n.loadNode&&n.loadNode(t)});break;case"mesh":r=this._invokeOne(function(n){return n.loadMesh&&n.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(n){return n.loadBufferView&&n.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(n){return n.loadMaterial&&n.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(n){return n.loadTexture&&n.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(n){return n.loadAnimation&&n.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(s,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(n,o){return s.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[$t.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(n,o){s.load(Od.resolveURL(t.uri,r.path),n,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const r=t.byteLength||0,n=t.byteOffset||0;return s.slice(n,n+r)})}loadAccessor(e){const t=this,s=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const o=KC[r.type],a=ep[r.componentType],l=r.normalized===!0,c=new a(r.count*o);return Promise.resolve(new rt(c,o,l))}const n=[];return r.bufferView!==void 0?n.push(this.getDependency("bufferView",r.bufferView)):n.push(null),r.sparse!==void 0&&(n.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(n).then(function(o){const a=o[0],l=KC[r.type],c=ep[r.componentType],u=c.BYTES_PER_ELEMENT,d=u*l,p=r.byteOffset||0,f=r.bufferView!==void 0?s.bufferViews[r.bufferView].byteStride:void 0,m=r.normalized===!0;let A,v;if(f&&f!==d){const g=Math.floor(p/f),b="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+g+":"+r.count;let y=t.cache.get(b);y||(A=new c(a,g*f,r.count*f/u),y=new Wf(A,f/u),t.cache.add(b,y)),v=new ic(y,l,p%f/u,m)}else a===null?A=new c(r.count*l):A=new c(a,p,r.count*l),v=new rt(A,l,m);if(r.sparse!==void 0){const g=KC.SCALAR,b=ep[r.sparse.indices.componentType],y=r.sparse.indices.byteOffset||0,_=r.sparse.values.byteOffset||0,S=new b(o[1],y,r.sparse.count*g),M=new c(o[2],_,r.sparse.count*l);a!==null&&(v=new rt(v.array.slice(),v.itemSize,v.normalized));for(let I=0,R=S.length;I<R;I++){const E=S[I];if(v.setX(E,M[I*l]),l>=2&&v.setY(E,M[I*l+1]),l>=3&&v.setZ(E,M[I*l+2]),l>=4&&v.setW(E,M[I*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){const t=this.json,s=this.options,r=t.textures[e].source,n=t.images[r];let o=this.textureLoader;if(n.uri){const a=s.manager.getHandler(n.uri);a!==null&&(o=a)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,s){const r=this,n=this.json,o=n.textures[e],a=n.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,s).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const d=(n.samplers||{})[o.sampler]||{};return u.magFilter=ZL[d.magFilter]||Bt,u.minFilter=ZL[d.minFilter]||Jn,u.wrapS=$L[d.wrapS]||Kn,u.wrapT=$L[d.wrapT]||Kn,u.anisotropy=4,r.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const s=this,r=this.json,n=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=r.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=s.getDependency("bufferView",o.bufferView).then(function(d){c=!0;const p=new Blob([d],{type:o.mimeType});return l=a.createObjectURL(p),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(d){return new Promise(function(p,f){let m=p;t.isImageBitmapLoader===!0&&(m=function(A){const v=new Pt(A);v.needsUpdate=!0,p(v)}),t.load(Od.resolveURL(d,n.path),m,void 0,f)})}).then(function(d){return c===!0&&a.revokeObjectURL(l),d.userData.mimeType=o.mimeType||e7(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=u,u}assignTexture(e,t,s,r){const n=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),n.extensions[$t.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[$t.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=n.associations.get(o);o=n.extensions[$t.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),n.associations.set(o,l)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const r=t.attributes.tangent===void 0,n=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+s.uuid;let l=this.cache.get(a);l||(l=new r0,kt.prototype.copy.call(l,s),l.color.copy(s.color),l.map=s.map,l.sizeAttenuation=!1,this.cache.add(a,l)),s=l}else if(e.isLine){const a="LineBasicMaterial:"+s.uuid;let l=this.cache.get(a);l||(l=new is,kt.prototype.copy.call(l,s),l.color.copy(s.color),l.map=s.map,this.cache.add(a,l)),s=l}if(r||n||o){let a="ClonedMaterial:"+s.uuid+":";r&&(a+="derivative-tangents:"),n&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=s.clone(),n&&(l.vertexColors=!0),o&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(s))),s=l}e.material=s}getMaterialType(){return Ro}loadMaterial(e){const t=this,s=this.json,r=this.extensions,n=s.materials[e];let o;const a={},l=n.extensions||{},c=[];if(l[$t.KHR_MATERIALS_UNLIT]){const d=r[$t.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),c.push(d.extendParams(a,n,t))}else{const d=n.pbrMetallicRoughness||{};if(a.color=new _e(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;a.color.fromArray(p),a.opacity=p[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,et)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}n.doubleSided===!0&&(a.side=_i);const u=n.alphaMode||ZC.OPAQUE;if(u===ZC.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===ZC.MASK&&(a.alphaTest=n.alphaCutoff!==void 0?n.alphaCutoff:.5)),n.normalTexture!==void 0&&o!==li&&(c.push(t.assignTexture(a,"normalMap",n.normalTexture)),a.normalScale=new ee(1,1),n.normalTexture.scale!==void 0)){const d=n.normalTexture.scale;a.normalScale.set(d,d)}return n.occlusionTexture!==void 0&&o!==li&&(c.push(t.assignTexture(a,"aoMap",n.occlusionTexture)),n.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=n.occlusionTexture.strength)),n.emissiveFactor!==void 0&&o!==li&&(a.emissive=new _e().fromArray(n.emissiveFactor)),n.emissiveTexture!==void 0&&o!==li&&c.push(t.assignTexture(a,"emissiveMap",n.emissiveTexture,et)),Promise.all(c).then(function(){const d=new o(a);return n.name&&(d.name=n.name),Fc(d,n),t.associations.set(d,{materials:e}),n.extensions&&cu(r,d,n),d})}createUniqueName(e){const t=Ot.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,r=this.primitiveCache;function n(a){return s[$t.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return eU(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],u=$Y(c),d=r[u];if(d)o.push(d.promise);else{let p;c.extensions&&c.extensions[$t.KHR_DRACO_MESH_COMPRESSION]?p=n(c):p=eU(new gt,c,t),r[u]={primitive:c,promise:p},o.push(p)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,r=this.extensions,n=s.meshes[e],o=n.primitives,a=[];for(let l=0,c=o.length;l<c;l++){const u=o[l].material===void 0?KY(this.cache):this.getDependency("material",o[l].material);a.push(u)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),u=l[l.length-1],d=[];for(let f=0,m=u.length;f<m;f++){const A=u[f],v=o[f];let g;const b=c[f];if(v.mode===oo.TRIANGLES||v.mode===oo.TRIANGLE_STRIP||v.mode===oo.TRIANGLE_FAN||v.mode===void 0)g=n.isSkinnedMesh===!0?new Uh(A,b):new ye(A,b),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),v.mode===oo.TRIANGLE_STRIP?g.geometry=qL(g.geometry,Iw):v.mode===oo.TRIANGLE_FAN&&(g.geometry=qL(g.geometry,vA));else if(v.mode===oo.LINES)g=new Rn(A,b);else if(v.mode===oo.LINE_STRIP)g=new ss(A,b);else if(v.mode===oo.LINE_LOOP)g=new vS(A,b);else if(v.mode===oo.POINTS)g=new yS(A,b);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(g.geometry.morphAttributes).length>0&&ZY(g,n),g.name=t.createUniqueName(n.name||"mesh_"+e),Fc(g,n),v.extensions&&cu(r,g,v),t.assignFinalMaterial(g),d.push(g)}for(let f=0,m=d.length;f<m;f++)t.associations.set(d[f],{meshes:e,primitives:f});if(d.length===1)return n.extensions&&cu(r,d[0],n),d[0];const p=new Tn;n.extensions&&cu(r,p,n),t.associations.set(p,{meshes:e});for(let f=0,m=d.length;f<m;f++)p.add(d[f]);return p})}loadCamera(e){let t;const s=this.json.cameras[e],r=s[s.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new qt(qs.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):s.type==="orthographic"&&(t=new kh(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),Fc(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let r=0,n=t.joints.length;r<n;r++)s.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(r){const n=r.pop(),o=r,a=[],l=[];for(let c=0,u=o.length;c<u;c++){const d=o[c];if(d){a.push(d);const p=new Be;n!==null&&p.fromArray(n.array,c*16),l.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new pf(a,l)})}loadAnimation(e){const t=this.json,s=this,r=t.animations[e],n=r.name?r.name:"animation_"+e,o=[],a=[],l=[],c=[],u=[];let d=0,p=r.channels.length;for(d=0,p=r.channels.length;d<p;d++){const f=r.channels[d],m=r.samplers[f.sampler],A=f.target,v=A.node,g=r.parameters!==void 0?r.parameters[m.input]:m.input,b=r.parameters!==void 0?r.parameters[m.output]:m.output;A.node!==void 0&&(o.push(this.getDependency("node",v)),a.push(this.getDependency("accessor",g)),l.push(this.getDependency("accessor",b)),c.push(m),u.push(A))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(u)]).then(function(f){const m=f[0],A=f[1],v=f[2],g=f[3],b=f[4],y=[];for(d=0,p=m.length;d<p;d++){const _=m[d],S=A[d],M=v[d],I=g[d],R=b[d];if(_===void 0)continue;_.updateMatrix&&(_.updateMatrix(),_.matrixAutoUpdate=!0);const E=s._createAnimationTracks(_,S,M,I,R);if(E)for(let C=0;C<E.length;C++)y.push(E[C])}return new Fr(n,void 0,y)})}createNodeMesh(e){const t=this.json,s=this,r=t.nodes[e];return r.mesh===void 0?null:s.getDependency("mesh",r.mesh).then(function(n){const o=s._getNodeRef(s.meshCache,r.mesh,n);return r.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let l=0,c=r.weights.length;l<c;l++)a.morphTargetInfluences[l]=r.weights[l]}),o})}loadNode(e){const t=this.json,s=this,r=t.nodes[e],n=s._loadNodeShallow(e),o=[],a=r.children||[];for(let c=0,u=a.length;c<u;c++)o.push(s.getDependency("node",a[c]));const l=r.skin===void 0?Promise.resolve(null):s.getDependency("skin",r.skin);return Promise.all([n,Promise.all(o),l]).then(function(c){const u=c[0],d=c[1],p=c[2];p!==null&&u.traverse(function(f){f.isSkinnedMesh&&f.bind(p,t7)});for(let f=0,m=d.length;f<m;f++)u.add(d[f]);return u})}_loadNodeShallow(e){const t=this.json,s=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const n=t.nodes[e],o=n.name?r.createUniqueName(n.name):"",a=[],l=r._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),n.camera!==void 0&&a.push(r.getDependency("camera",n.camera).then(function(c){return r._getNodeRef(r.cameraCache,n.camera,c)})),r._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let u;if(n.isBone===!0?u=new Kf:c.length>1?u=new Tn:c.length===1?u=c[0]:u=new Re,u!==c[0])for(let d=0,p=c.length;d<p;d++)u.add(c[d]);if(n.name&&(u.userData.name=n.name,u.name=o),Fc(u,n),n.extensions&&cu(s,u,n),n.matrix!==void 0){const d=new Be;d.fromArray(n.matrix),u.applyMatrix4(d)}else n.translation!==void 0&&u.position.fromArray(n.translation),n.rotation!==void 0&&u.quaternion.fromArray(n.rotation),n.scale!==void 0&&u.scale.fromArray(n.scale);return r.associations.has(u)||r.associations.set(u,{}),r.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],r=this,n=new Tn;s.name&&(n.name=r.createUniqueName(s.name)),Fc(n,s),s.extensions&&cu(t,n,s);const o=s.nodes||[],a=[];for(let l=0,c=o.length;l<c;l++)a.push(r.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let u=0,d=l.length;u<d;u++)n.add(l[u]);const c=u=>{const d=new Map;for(const[p,f]of r.associations)(p instanceof kt||p instanceof Pt)&&d.set(p,f);return u.traverse(p=>{const f=r.associations.get(p);f!=null&&d.set(p,f)}),d};return r.associations=c(n),n})}_createAnimationTracks(e,t,s,r,n){const o=[],a=e.name?e.name:e.uuid,l=[];Uc[n.path]===Uc.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(a);let c;switch(Uc[n.path]){case Uc.weights:c=xc;break;case Uc.rotation:c=ua;break;case Uc.position:case Uc.scale:c=hl;break;default:switch(s.itemSize){case 1:c=xc;break;case 2:case 3:default:c=hl;break}break}const u=r.interpolation!==void 0?YY[r.interpolation]:aa,d=this._getArrayFromAccessor(s);for(let p=0,f=l.length;p<f;p++){const m=new c(l[p]+"."+Uc[n.path],t.array,d,u);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=eE(t.constructor),r=new Float32Array(t.length);for(let n=0,o=t.length;n<o;n++)r[n]=t[n]*s;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const s=this instanceof ua?qY:JL;return new s(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function s7(i,e,t){const s=e.attributes,r=new Ts;if(s.POSITION!==void 0){const a=t.json.accessors[s.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(r.set(new w(l[0],l[1],l[2]),new w(c[0],c[1],c[2])),a.normalized){const u=eE(ep[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const n=e.targets;if(n!==void 0){const a=new w,l=new w;for(let c=0,u=n.length;c<u;c++){const d=n[c];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],f=p.min,m=p.max;if(f!==void 0&&m!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),p.normalized){const A=eE(ep[p.componentType]);l.multiplyScalar(A)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}i.boundingBox=r;const o=new Or;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,i.boundingSphere=o}function eU(i,e,t){const s=e.attributes,r=[];function n(o,a){return t.getDependency("accessor",o).then(function(l){i.setAttribute(a,l)})}for(const o in s){const a=JC[o]||o.toLowerCase();a in i.attributes||r.push(n(s[o],a))}if(e.indices!==void 0&&!i.index){const o=t.getDependency("accessor",e.indices).then(function(a){i.setIndex(a)});r.push(o)}return Fc(i,e),s7(i,e,t),Promise.all(r).then(function(){return e.targets!==void 0?JY(i,e.targets,t):i})}var tU=(i=>(i[i.INT=5124]="INT",i[i.FLOAT=5126]="FLOAT",i[i.FLOAT_VEC2=35664]="FLOAT_VEC2",i[i.FLOAT_VEC3=35665]="FLOAT_VEC3",i[i.FLOAT_VEC4=35666]="FLOAT_VEC4",i[i.INT_VEC2=35667]="INT_VEC2",i[i.INT_VEC3=35668]="INT_VEC3",i[i.INT_VEC4=35669]="INT_VEC4",i[i.BOOL=35670]="BOOL",i[i.BOOL_VEC2=35671]="BOOL_VEC2",i[i.BOOL_VEC3=35672]="BOOL_VEC3",i[i.BOOL_VEC4=35673]="BOOL_VEC4",i[i.FLOAT_MAT2=35674]="FLOAT_MAT2",i[i.FLOAT_MAT3=35675]="FLOAT_MAT3",i[i.FLOAT_MAT4=35676]="FLOAT_MAT4",i[i.SAMPLER_2D=35678]="SAMPLER_2D",i[i.SAMPLER_3D=35680]="SAMPLER_3D",i[i.SAMPLER_CUBE=35681]="SAMPLER_CUBE",i[i.UNKNOWN=0]="UNKNOWN",i))(tU||{});const ba=le("debugcustomshader"),tp="NEEDLE_techniques_webgl";class r7{constructor(){h(this,"objectToWorldMatrix",new Be),h(this,"worldToObjectMatrix",new Be),h(this,"objectToWorld",new Array),h(this,"worldToObject",new Array)}updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),My(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),My(this.worldToObjectMatrix,this.worldToObject)}}const Hi=class extends g0{constructor(i,...e){super(...e),h(this,"identifier"),h(this,"onBeforeRenderSceneCallback",this.onBeforeRenderScene.bind(this)),h(this,"_sphericalHarmonicsName","unity_SpecCube0"),h(this,"_objToWorldName","hlslcc_mtx4x4unity_ObjectToWorld"),h(this,"_worldToObjectName","hlslcc_mtx4x4unity_WorldToObject"),h(this,"_viewProjectionName","hlslcc_mtx4x4unity_MatrixVP"),h(this,"_viewMatrixName","hlslcc_mtx4x4unity_MatrixV"),h(this,"_rendererData",new r7),this.identifier=i,ba&&console.log(this),this.type="NEEDLE_CUSTOM_SHADER",this.uniforms[this._objToWorldName]||(this.uniforms[this._objToWorldName]={value:[]}),this.uniforms[this._worldToObjectName]||(this.uniforms[this._worldToObjectName]={value:[]}),this.uniforms[this._viewProjectionName]||(this.uniforms[this._viewProjectionName]={value:[]}),this.uniforms[this._sphericalHarmonicsName]&&this.waitForLighting(),(this.depthTextureUniform||this.opaqueTextureUniform)&&zt.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}clone(){const i=super.clone();return iU(i),i}dispose(){super.dispose();const i=zt.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);i>=0&&zt.Current.pre_render_callbacks.splice(i,1)}async waitForLighting(){const i=zt.Current;if(!i){console.error("Missing context");return}const e=await i.sceneLighting.internalGetSceneLightingData(this.identifier);if(!e||!e.array){console.warn("Missing lighting data for custom shader, getSceneLightingData did not return anything");return}ba&&console.log(e);const t=e.array,s=e.texture;this.uniforms.unity_SpecCube0={value:s},XO(this.uniforms,t);const r=Math.sqrt(Math.PI*.5);this.uniforms.unity_SpecCube0_HDR={value:new it(r,r,r,r)},ba&&console.log("Set environment lighting",this.uniforms)}get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&zt.Current.setRequireColor(!0),this.depthTextureUniform&&zt.Current.setRequireDepth(!0)}onBeforeRender(i,e,t,s,r,n){s.attributes.tangent||s.computeTangents(),this.onUpdateUniforms(t,r)}onUpdateUniforms(i,e){const t=zt.Current;if(i&&(Hi.viewProjection&&this.uniforms[this._viewProjectionName]&&(Hi.viewProjection.copy(i.projectionMatrix).multiply(i.matrixWorldInverse),My(Hi.viewProjection,Hi._viewProjectionValues)),Hi.viewMatrix&&this.uniforms[this._viewMatrixName]&&(Hi.viewMatrix.copy(i.matrixWorldInverse),My(Hi.viewMatrix,Hi._viewMatrixValues)),this.uniforms[Hi._worldSpaceCameraPosName]&&Hi._worldSpaceCameraPos.setFromMatrixPosition(i.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=t.sceneLighting.timeVec4),this.uniforms._Time){const o=this.uniforms._Time.value;o.x=t.sceneLighting.timeVec4.x/20,o.y=t.sceneLighting.timeVec4.x,o.z=t.sceneLighting.timeVec4.x*2,o.w=t.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const o=this.uniforms._SinTime.value;o.x=Math.sin(t.sceneLighting.timeVec4.x/8),o.y=Math.sin(t.sceneLighting.timeVec4.x/4),o.z=Math.sin(t.sceneLighting.timeVec4.x/2),o.w=Math.sin(t.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const o=this.uniforms._CosTime.value;o.x=Math.cos(t.sceneLighting.timeVec4.x/8),o.y=Math.cos(t.sceneLighting.timeVec4.x/4),o.z=Math.cos(t.sceneLighting.timeVec4.x/2),o.w=Math.cos(t.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const o=this.uniforms.unity_DeltaTime.value;o.x=t.time.deltaTime,o.y=1/t.time.deltaTime,o.z=t.time.smoothedDeltaTime,o.w=1/t.time.smoothedDeltaTime}const s=t.mainLight;if(s){const o=At(s.gameObject,Hi._mainLightPosition);this.uniforms._MainLightPosition={value:o.normalize()},Hi._mainLightColor.set(s.color.r,s.color.g,s.color.b,0),this.uniforms._MainLightColor={value:Hi._mainLightColor};const a=s.intensity;Hi._lightData.z=a,this.uniforms.unity_LightData={value:Hi._lightData}}if(i&&(Hi.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=Hi._viewProjectionValues),Hi.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=Hi._viewMatrixValues),this.uniforms[Hi._worldSpaceCameraPosName]&&(this.uniforms[Hi._worldSpaceCameraPosName]={value:Hi._worldSpaceCameraPos}),t.mainCameraComponent)){if(this.uniforms._ProjectionParams){const o=this.uniforms._ProjectionParams.value;o.x=1,o.y=t.mainCameraComponent.nearClipPlane,o.z=t.mainCameraComponent.farClipPlane,o.w=1/o.z,this.uniforms._ProjectionParams.value=o}if(this.uniforms._ZBufferParams){const o=this.uniforms._ZBufferParams.value,a=t.mainCameraComponent;o.x=1-a.farClipPlane/a.nearClipPlane,o.y=a.farClipPlane/a.nearClipPlane,o.z=o.x/a.farClipPlane,o.w=o.y/a.farClipPlane,this.uniforms._ZBufferParams.value=o}if(this.uniforms._ScreenParams){const o=this.uniforms._ScreenParams.value;o.x=t.domWidth,o.y=t.domHeight,o.z=1+1/o.x,o.w=1+1/o.y,this.uniforms._ScreenParams.value=o}}const r=this.depthTextureUniform;r&&(r.value=t.depthTexture);const n=this.opaqueTextureUniform;if(n&&(n.value=t.opaqueColorTexture),e){const o=this._rendererData;o.updateFrom(e),this.uniforms[this._worldToObjectName].value=o.worldToObject,this.uniforms[this._objToWorldName].value=o.objectToWorld}this.uniformsNeedUpdate=!0}};let zo=Hi;h(zo,"viewProjection",new Be),h(zo,"_viewProjectionValues",[]),h(zo,"viewMatrix",new Be),h(zo,"_viewMatrixValues",[]),h(zo,"_worldSpaceCameraPosName","_WorldSpaceCameraPos"),h(zo,"_worldSpaceCameraPos",new w),h(zo,"_mainLightColor",new it),h(zo,"_mainLightPosition",new w),h(zo,"_lightData",new it);class n7{constructor(e,t){h(this,"parser"),h(this,"identifier"),this.parser=e,this.identifier=t}get name(){return tp}loadMaterial(e){const t=this.parser.json.materials[e];if(!t)return ba&&console.log(e,this.parser.json.materials),null;if(!t.extensions||!t.extensions[tp])return ba&&console.log("material "+e+" does not use NEEDLE_techniques_webgl"),null;const s=t.extensions[tp].technique;if(s<0)return null;const r=this.parser.json.extensions[tp];if(!r)return null;ba&&console.log(r);const n=r.techniques[s];return n?new Promise(async(o,a)=>{var l,c,u;const d=await vq(r,n.program),p=d?.fragmentShader,f=d?.vertexShader;if(!p||!f)return a();ba&&console.log("loadMaterial",t,d);const m={},A=n.uniforms;(f.includes("_Time")||p.includes("_Time"))&&(m._Time={value:new it(0,0,0,0)}),(f.includes("_SinTime")||p.includes("_SinTime"))&&(m._SinTime={value:new it(0,0,0,0)}),(f.includes("_CosTime")||p.includes("_CosTime"))&&(m._CosTime={value:new it(0,0,0,0)}),(f.includes("unity_DeltaTime")||p.includes("unity_DeltaTime"))&&(m.unity_DeltaTime={value:new it(0,0,0,0)});for(const b in A){const y=b;switch(y){case"_TimeParameters":const _=new it;m[y]={value:_};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":m[y]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":m[y]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":m[y]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":m[y]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":m[y]={value:null};break}}let v=!1;if(t.extensions&&t.extensions[tp]){const b=t.extensions[tp];if(b.technique===s){ba&&console.log(t.name,"Material Properties",b);for(const y in b.values){const _=b.values[y];if(typeof _=="string"){if(_.startsWith("/textures/")){const S=_.substring(10),M=Number.parseInt(S);if(M>=0){const I=await this.parser.getDependency("texture",M);I instanceof Pt&&(I.colorSpace=ts,I.needsUpdate=!0),m[y]={value:I};continue}}switch(y){case"alphaMode":_==="BLEND"&&(v=!0);continue}}if(Array.isArray(_)&&_.length===4){m[y]={value:new it(_[0],_[1],_[2],_[3])};continue}m[y]={value:_}}}}const g=new zo(this.identifier,{name:t.name??"",uniforms:m,vertexShader:f,fragmentShader:p,lights:!1});switch(g.glslVersion=yA,g.vertexShader=g.vertexShader.replace("#version 300 es",""),g.fragmentShader=g.fragmentShader.replace("#version 300 es",""),(l=m._Cull)==null?void 0:l.value){case 0:g.side=_i;break;case 1:g.side=es;break;case 2:g.side=gr;break;default:g.side=gr;break}switch((c=m._ZTest)==null?void 0:c.value){case 3:g.depthTest=!0,g.depthFunc=Zu;break;case 6:g.depthTest=!0,g.depthFunc=wf;break;case 2:g.depthTest=!0,g.depthFunc=xf;break;case 4:g.depthTest=!0,g.depthFunc=Ju;break;case 5:g.depthTest=!0,g.depthFunc=rA;break;case 7:g.depthTest=!0,g.depthFunc=sA;break;case 8:g.depthTest=!1,g.depthFunc=iA;break}g.transparent=v,v&&(g.depthWrite=!1),XO(m),g.onUpdateUniforms();for(const b in A){const y=b,_=A[b].type;if(((u=m[y])==null?void 0:u.value)===void 0)switch(_){case tU.SAMPLER_2D:m[y]={value:fq},console.warn("Missing/unassigned texture, fallback to white: "+y);break;default:y==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+y,A[b]);break}}ba&&console.log(g.uuid,m),iU(g),o(g)}):null}}function iU(i){if(i.uniforms){ba&&console.log("Uniforms:",i.uniforms);for(const t in i.uniforms)switch(e(t,t),t){case"_Color":e("color",t);break}}function e(t,s){Object.getOwnPropertyDescriptor(i,t)||Object.defineProperty(i,t,{get:()=>i.uniforms[s].value,set:r=>{i.uniforms[s].value=r,i.needsUpdate=!0}})}}const El=_r,jy="$___Export_Components",o7="NEEDLE_components";var sU;class a7{constructor(){h(this,sU)}}sU=$h;class l7{constructor(e,t,s){h(this,"node"),h(this,"nodeIndex"),h(this,"nodeDef"),this.node=e,this.nodeIndex=t,this.nodeDef=s}}class rU{constructor(){h(this,"parser"),h(this,"nodeToObjectMap",{}),h(this,"exportContext"),h(this,"objectToNodeMap",{}),h(this,"context"),h(this,"writer")}get name(){return o7}registerExport(e){e.register(t=>{if("serializeUserData"in t){const s=t.serializeUserData.bind(t);this.writer=t,t.serializeUserData=(r,n)=>{try{this.serializeUserData(r,n),s(r,n)}finally{this.afterSerializeUserData(r,n)}}}return this})}beforeParse(){this.exportContext={},this.objectToNodeMap={}}serializeUserData(e,t){var s;const r=(s=e.userData)==null?void 0:s.components;!r||r.length<=0||(delete e.userData.components,e[jy]=r)}afterSerializeUserData(e,t){if(e.type==="Scene"&&El&&console.log("DONE",JSON.stringify(t)),e[jy]===void 0)return;const s=e[jy];delete e[jy],s!==null&&(e.userData.components=s)}writeNode(e,t){const s=this.writer.json.nodes.length;El&&console.log(e.name,s,e.uuid);const r=new l7(e,s,t);this.exportContext[s]=r,this.objectToNodeMap[e.uuid]=s}afterParse(e){var t;El&&console.log("AFTER",e);for(const s in this.exportContext){const r=this.exportContext[s],n=r.node,o=r.nodeDef,a=r.nodeIndex,l=(t=n.userData)==null?void 0:t.components;if(!l||l.length<=0)continue;const c=new a7;o.extensions=o.extensions||{},o.extensions[this.name]=c,this.context.object=n,this.context.nodeId=a,this.context.objectToNode=this.objectToNodeMap;const u=[];for(const d of l){this.context.target=d;const p=Lo().writeBuiltinComponentData(d,this.context);p!==null&&u.push(p)}u.length>0&&(c[$h]=u,El&&console.log("DID WRITE",n,"nodeIndex",a,u))}}beforeRoot(){return El&&console.log("BEGIN LOAD"),this.nodeToObjectMap={},null}async afterRoot(e){const t=e.parser,s=t?.extensions;if(!s)return;const r=s[this.name];El&&console.log("After root",e,this.parser,s);const n=[];if(r===!0){const o=t.json.nodes;if(o){for(let a=0;a<o.length;a++){const l=await t.getDependency("node",a);this.nodeToObjectMap[a]=l}for(let a=0;a<o.length;a++){const l=o[a],c=a,u=l.extensions;if(!u)continue;const d=u[this.name];if(!d)continue;El&&console.log("NODE",l);const p=this.nodeToObjectMap[c];if(!p){console.error("Could not find object for node index: "+c,l,t);continue}hy(p),n.push(this.createComponents(p,d))}}}await Promise.all(n)}async createComponents(e,t){if(!t)return;const s=t[$h];if(s){const r=new Array;El&&console.log(e.name,s);for(const n in s){const o=s[n];El&&console.log("Serialized data",JSON.parse(JSON.stringify(o))),o&&this.parser&&r.push(l1(this.parser,o).catch(a=>console.error(`Error while resolving references (see console for details)
4446
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([l])),this.transcoderBinary=o,this.workerPool.setWorkerCreator(()=>{const c=new Worker(this.workerSourceURL),u=this.transcoderBinary.slice(0);return c.postMessage({type:"init",config:this.workerConfig,transcoderBinary:u},[u]),c})}),WC>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),WC++}return this.transcoderPending}load(e,t,s,r){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const n=new Ps(this.manager);n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials),n.load(e,o=>{if(VC.has(o))return VC.get(o).promise.then(t).catch(r);this._createTexture(o).then(a=>t?t(a):null).catch(r)},s,r)}_createTextureFrom(e,t){const{faces:s,width:r,height:n,format:o,type:a,error:l,dfdTransferFn:c,dfdFlags:u}=e;if(a==="error")return Promise.reject(l);let d;if(t.faceCount===6)d=new cl,d.image=s,d.format=o,d.type=di;else{const p=s[0].mipmaps;d=t.layerCount>1?new RB(p,r,n,t.layerCount,o,di):new cl(p,r,n,o,di)}return d.minFilter=s[0].mipmaps.length===1?Bt:Jn,d.magFilter=Bt,d.generateMipmaps=!1,d.needsUpdate=!0,d.colorSpace=c===vY?et:rn,d.premultiplyAlpha=!!(u&gY),d}async _createTexture(e,t={}){const s=bY(new Uint8Array(e));if(s.vkFormat!==AY){const o=[],a=[];for(let c=0;c<s.levels.length;c++)a.push(wY(s,c).then(function(u){o[c]=u}));await Promise.all(a);const l=o[0];return l.mipmaps=o.map(c=>({data:c.source.data,width:c.source.data.width,height:c.source.data.height,depth:c.source.data.depth})),l}const r=t,n=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:r},[e])).then(o=>this._createTextureFrom(o.data,s));return VC.set(e,{promise:n}),n}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),WC--,this}}sa.BasisFormat={ETC1S:0,UASTC_4x4:1},sa.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},sa.EngineFormat={RGBAFormat:Ci,RGBA_ASTC_4x4_Format:fA,RGBA_BPTC_Format:If,RGBA_ETC2_EAC_Format:pA,RGBA_PVRTC_4BPPV1_Format:uA,RGBA_S3TC_DXT5_Format:Tf,RGB_ETC1_Format:hw,RGB_ETC2_Format:dA,RGB_PVRTC_4BPPV1_Format:hA,RGB_S3TC_DXT1_Format:Mf},sa.BasisWorker=function(){let i,e,t;const s=_EngineFormat,r=_TranscoderFormat,n=_BasisFormat;self.addEventListener("message",function(m){const A=m.data;switch(A.type){case"init":i=A.config,o(A.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:v,buffers:g,width:b,height:y,hasAlpha:_,format:S,dfdTransferFn:M,dfdFlags:I}=a(A.buffer);self.postMessage({type:"transcode",id:A.id,faces:v,width:b,height:y,hasAlpha:_,format:S,dfdTransferFn:M,dfdFlags:I},g)}catch(v){console.error(v),self.postMessage({type:"error",id:A.id,error:v.message})}});break}});function o(m){e=new Promise(A=>{t={wasmBinary:m,onRuntimeInitialized:A},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function a(m){const A=new t.KTX2File(new Uint8Array(m));function v(){A.close(),A.delete()}if(!A.isValid())throw v(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");const g=A.isUASTC()?n.UASTC_4x4:n.ETC1S,b=A.getWidth(),y=A.getHeight(),_=A.getLayers()||1,S=A.getLevels(),M=A.getFaces(),I=A.getHasAlpha(),R=A.getDFDTransferFunc(),E=A.getDFDFlags(),{transcoderFormat:C,engineFormat:z}=d(g,b,y,I);if(!b||!y||!S)throw v(),new Error("THREE.KTX2Loader: Invalid texture");if(!A.startTranscoding())throw v(),new Error("THREE.KTX2Loader: .startTranscoding failed");const q=[],Q=[];for(let G=0;G<M;G++){const $=[];for(let F=0;F<S;F++){const L=[];let N,re;for(let X=0;X<_;X++){const ne=A.getImageLevelInfo(F,X,G);G===0&&F===0&&X===0&&(ne.origWidth%4!==0||ne.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),S>1?(N=ne.origWidth,re=ne.origHeight):(N=ne.width,re=ne.height);const fe=new Uint8Array(A.getImageTranscodedSizeInBytes(F,X,0,C));if(!A.transcodeImage(fe,F,X,G,C,0,-1,-1))throw v(),new Error("THREE.KTX2Loader: .transcodeImage failed.");L.push(fe)}const Z=f(L);$.push({data:Z,width:N,height:re}),Q.push(Z.buffer)}q.push({mipmaps:$,width:b,height:y,format:z})}return v(),{faces:q,buffers:Q,width:b,height:y,hasAlpha:I,format:z,dfdTransferFn:R,dfdFlags:E}}const l=[{if:"astcSupported",basisFormat:[n.UASTC_4x4],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[s.RGBA_ASTC_4x4_Format,s.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[s.RGBA_BPTC_Format,s.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.BC1,r.BC3],engineFormat:[s.RGB_S3TC_DXT1_Format,s.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[s.RGB_ETC2_Format,s.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.ETC1],engineFormat:[s.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[n.ETC1S,n.UASTC_4x4],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[s.RGB_PVRTC_4BPPV1_Format,s.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],c=l.sort(function(m,A){return m.priorityETC1S-A.priorityETC1S}),u=l.sort(function(m,A){return m.priorityUASTC-A.priorityUASTC});function d(m,A,v,g){let b,y;const _=m===n.ETC1S?c:u;for(let S=0;S<_.length;S++){const M=_[S];if(i[M.if]&&M.basisFormat.includes(m)&&!(g&&M.transcoderFormat.length<2)&&!(M.needsPowerOfTwo&&!(p(A)&&p(v))))return b=M.transcoderFormat[g?1:0],y=M.engineFormat[g?1:0],{transcoderFormat:b,engineFormat:y}}return console.warn("THREE.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),b=r.RGBA32,y=s.RGBAFormat,{transcoderFormat:b,engineFormat:y}}function p(m){return m<=2?!0:(m&m-1)===0&&m!==0}function f(m){if(m.length===1)return m[0];let A=0;for(let b=0;b<m.length;b++){const y=m[b];A+=y.byteLength}const v=new Uint8Array(A);let g=0;for(let b=0;b<m.length;b++){const y=m[b];v.set(y,g),g+=y.byteLength}return v}};const QL={[NL]:Ci,[LL]:Ci,[kL]:Ci,[jC]:Ci,[FL]:Sh,[OL]:Sh,[BL]:Sh,[zC]:Sh,[UL]:el,[DL]:el,[NC]:el,[PL]:el},qC={[NL]:Xi,[LL]:ds,[kL]:di,[jC]:di,[FL]:Xi,[OL]:ds,[BL]:di,[zC]:di,[UL]:Xi,[DL]:ds,[NC]:di,[PL]:di},xY={[jC]:et,[zC]:et,[NC]:et};async function wY(i,e=0){const{vkFormat:t}=i,s=Math.max(1,i.pixelWidth>>e),r=Math.max(1,i.pixelHeight>>e),n=Math.max(1,i.pixelDepth>>e);if(QL[t]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat.");const o=i.levels[e];let a,l;if(i.supercompressionScheme===fY)a=o.levelData;else if(i.supercompressionScheme===mY)XC||(XC=new Promise(async u=>{const d=new _Y;await d.init(),u(d)})),a=(await XC).decode(o.levelData,o.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");qC[t]===Xi?l=new Float32Array(a.buffer,a.byteOffset,a.byteLength/Float32Array.BYTES_PER_ELEMENT):qC[t]===ds?l=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/Uint16Array.BYTES_PER_ELEMENT):l=a;const c=n===0?new to(l,s,r):new wA(l,s,r,n);return c.type=qC[t],c.format=QL[t],c.colorSpace=xY[t]||rn,c.needsUpdate=!0,Promise.resolve(c)}var SY=function(){var i="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),s=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var r=WebAssembly.validate(t)?e:i,n,o=WebAssembly.instantiate(a(r),{}).then(function(g){n=g.instance,n.exports.__wasm_call_ctors()});function a(g){for(var b=new Uint8Array(g.length),y=0;y<g.length;++y){var _=g.charCodeAt(y);b[y]=_>96?_-97:_>64?_-39:_+4}for(var S=0,y=0;y<g.length;++y)b[S++]=b[y]<60?s[b[y]]:(b[y]-60)*64+b[++y];return b.buffer.slice(0,S)}function l(g,b,y,_,S,M){var I=n.exports.sbrk,R=y+3&-4,E=I(R*_),C=I(S.length),z=new Uint8Array(n.exports.memory.buffer);z.set(S,C);var q=g(E,y,_,C,S.length);if(q==0&&M&&M(E,R,_),b.set(z.subarray(E,E+y*_)),I(E-I(0)),q!=0)throw new Error("Malformed buffer data: "+q)}var c={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},u={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],p=0;function f(g){var b={object:new Worker(g),pending:0,requests:{}};return b.object.onmessage=function(y){var _=y.data;b.pending-=_.count,b.requests[_.id][_.action](_.value),delete b.requests[_.id]},b}function m(g){for(var b="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(a(r))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+l.toString()+v.toString(),y=new Blob([b],{type:"text/javascript"}),_=URL.createObjectURL(y),S=0;S<g;++S)d[S]=f(_);URL.revokeObjectURL(_)}function A(g,b,y,_,S){for(var M=d[0],I=1;I<d.length;++I)d[I].pending<M.pending&&(M=d[I]);return new Promise(function(R,E){var C=new Uint8Array(y),z=p++;M.pending+=g,M.requests[z]={resolve:R,reject:E},M.object.postMessage({id:z,count:g,size:b,source:C,mode:_,filter:S},[C.buffer])})}function v(g){o.then(function(){var b=g.data;try{var y=new Uint8Array(b.count*b.size);l(n.exports[b.mode],y,b.count,b.size,b.source,n.exports[b.filter]),self.postMessage({id:b.id,count:b.count,action:"resolve",value:y},[y.buffer])}catch(_){self.postMessage({id:b.id,count:b.count,action:"reject",value:_})}})}return{ready:o,supported:!0,useWorkers:function(g){m(g)},decodeVertexBuffer:function(g,b,y,_,S){l(n.exports.meshopt_decodeVertexBuffer,g,b,y,_,n.exports[c[S]])},decodeIndexBuffer:function(g,b,y,_){l(n.exports.meshopt_decodeIndexBuffer,g,b,y,_)},decodeIndexSequence:function(g,b,y,_){l(n.exports.meshopt_decodeIndexSequence,g,b,y,_)},decodeGltfBuffer:function(g,b,y,_,S,M){l(n.exports[u[S]],g,b,y,_,n.exports[c[M]])},decodeGltfBufferAsync:function(g,b,y,_,S){return d.length>0?A(g,b,y,u[_],c[S]):o.then(function(){var M=new Uint8Array(g*b);return l(n.exports[u[_]],M,g,b,y,n.exports[c[S]]),M})}}}();const Zd=le("debugdecoders"),GL="https://www.gstatic.com/draco/versioned/decoders/1.4.1/",HL="https://www.gstatic.com/basis-universal/versioned/2021-04-15-ba1c3e4/";let No,YC,Lc;function VL(i){i!==void 0&&typeof i=="string"&&(No||(No=new FC),Zd&&console.log("Setting draco decoder path to",i),No.setDecoderPath(i))}function WL(i){i!==void 0&&typeof i=="string"&&(No||(No=new FC),Zd&&console.log("Setting draco decoder type to",i),No.setDecoderConfig({type:i}))}function XL(i){i!==void 0&&typeof i=="string"&&(Lc||(Lc=new sa),Zd&&console.log("Setting ktx2 transcoder path to",i),Lc.setTranscoderPath(i))}function Hm(i,e){No||(No=new FC,No.setDecoderPath(GL),No.setDecoderConfig({type:"js"}),Zd&&console.log("Setting draco decoder path to",GL)),Lc||(Lc=new sa,Lc.setTranscoderPath(HL),Zd&&console.log("Setting ktx2 transcoder path to",HL)),YC||(YC=SY,Zd&&console.log("Using the default meshopt decoder")),e.renderer?Lc.detectSupport(e.renderer):console.warn("No renderer provided to detect ktx2 support - loading KTX2 textures will probably fail"),i.setDRACOLoader(No),i.setKTX2Loader(Lc),i.setMeshoptDecoder(YC)}function CY(i,e=1e-4){e=Math.max(e,Number.EPSILON);const t={},s=i.getIndex(),r=i.getAttribute("position"),n=s?s.count:r.count;let o=0;const a=Object.keys(i.attributes),l={},c={},u=[],d=["getX","getY","getZ","getW"],p=["setX","setY","setZ","setW"];for(let v=0,g=a.length;v<g;v++){const b=a[v],y=i.attributes[b];l[b]=new rt(new y.array.constructor(y.count*y.itemSize),y.itemSize,y.normalized);const _=i.morphAttributes[b];_&&(c[b]=new rt(new _.array.constructor(_.count*_.itemSize),_.itemSize,_.normalized))}const f=Math.log10(1/e),m=Math.pow(10,f);for(let v=0;v<n;v++){const g=s?s.getX(v):v;let b="";for(let y=0,_=a.length;y<_;y++){const S=a[y],M=i.getAttribute(S),I=M.itemSize;for(let R=0;R<I;R++)b+=`${~~(M[d[R]](g)*m)},`}if(b in t)u.push(t[b]);else{for(let y=0,_=a.length;y<_;y++){const S=a[y],M=i.getAttribute(S),I=i.morphAttributes[S],R=M.itemSize,E=l[S],C=c[S];for(let z=0;z<R;z++){const q=d[z],Q=p[z];if(E[Q](o,M[q](g)),I)for(let G=0,$=I.length;G<$;G++)C[G][Q](o,I[G][q](g))}}t[b]=o,u.push(o),o++}}const A=i.clone();for(const v in i.attributes){const g=l[v];if(A.setAttribute(v,new rt(g.array.slice(0,o*g.itemSize),g.itemSize,g.normalized)),v in c)for(let b=0;b<c[v].length;b++){const y=c[v][b];A.morphAttributes[v][b]=new rt(y.array.slice(0,o*y.itemSize),y.itemSize,y.normalized)}}return A.setIndex(u),A}function qL(i,e){if(e===GR)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===vA||e===Iw){let t=i.getIndex();if(t===null){const o=[],a=i.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);i.setIndex(o),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}const s=t.count-2,r=[];if(e===vA)for(let o=1;o<=s;o++)r.push(t.getX(0)),r.push(t.getX(o)),r.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(r.push(t.getX(o)),r.push(t.getX(o+1)),r.push(t.getX(o+2))):(r.push(t.getX(o+2)),r.push(t.getX(o+1)),r.push(t.getX(o)));r.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const n=i.clone();return n.setIndex(r),n.clearGroups(),n}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}class $d extends Ys{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new RY(t)}),this.register(function(t){return new FY(t)}),this.register(function(t){return new NY(t)}),this.register(function(t){return new zY(t)}),this.register(function(t){return new BY(t)}),this.register(function(t){return new kY(t)}),this.register(function(t){return new DY(t)}),this.register(function(t){return new OY(t)}),this.register(function(t){return new IY(t)}),this.register(function(t){return new LY(t)}),this.register(function(t){return new PY(t)}),this.register(function(t){return new UY(t)}),this.register(function(t){return new MY(t)}),this.register(function(t){return new jY(t)}),this.register(function(t){return new QY(t)})}load(e,t,s,r){const n=this;let o;this.resourcePath!==""?o=this.resourcePath:this.path!==""?o=this.path:o=Od.extractUrlBase(e),this.manager.itemStart(e);const a=function(c){r?r(c):console.error(c),n.manager.itemError(e),n.manager.itemEnd(e)},l=new Ps(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{n.parse(c,o,function(u){t(u),n.manager.itemEnd(e)},a)}catch(u){a(u)}},s,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,r){let n;const o={},a={},l=new TextDecoder;if(typeof e=="string")n=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===YL){try{o[$t.KHR_BINARY_GLTF]=new GY(e)}catch(u){r&&r(u);return}n=JSON.parse(o[$t.KHR_BINARY_GLTF].content)}else n=JSON.parse(l.decode(e));else n=e;if(n.asset===void 0||n.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new i7(n,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const d=this.pluginCallbacks[u](c);a[d.name]=d,o[d.name]=!0}if(n.extensionsUsed)for(let u=0;u<n.extensionsUsed.length;++u){const d=n.extensionsUsed[u],p=n.extensionsRequired||[];switch(d){case $t.KHR_MATERIALS_UNLIT:o[d]=new TY;break;case $t.KHR_DRACO_MESH_COMPRESSION:o[d]=new HY(n,this.dracoLoader);break;case $t.KHR_TEXTURE_TRANSFORM:o[d]=new VY;break;case $t.KHR_MESH_QUANTIZATION:o[d]=new WY;break;default:p.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(s,r)}parseAsync(e,t){const s=this;return new Promise(function(r,n){s.parse(e,t,r,n)})}}function EY(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}const $t={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class MY{constructor(e){this.parser=e,this.name=$t.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,r=t.length;s<r;s++){const n=t[s];n.extensions&&n.extensions[this.name]&&n.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let r=t.cache.get(s);if(r)return r;const n=t.json,o=((n.extensions&&n.extensions[this.name]||{}).lights||[])[e];let a;const l=new _e(16777215);o.color!==void 0&&l.fromArray(o.color);const c=o.range!==void 0?o.range:0;switch(o.type){case"directional":a=new _0(l),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new b0(l),a.distance=c;break;case"spot":a=new y0(l),a.distance=c,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),a.decay=2,Fc(a,o),o.intensity!==void 0&&(a.intensity=o.intensity),a.name=t.createUniqueName(o.name||"light_"+e),r=Promise.resolve(a),t.cache.add(s,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,r=s.json.nodes[e],n=(r.extensions&&r.extensions[this.name]||{}).light;return n===void 0?null:this._loadLight(n).then(function(o){return s._getNodeRef(t.cache,n,o)})}}let TY=class{constructor(){this.name=$t.KHR_MATERIALS_UNLIT}getMaterialType(){return li}extendParams(i,e,t){const s=[];i.color=new _e(1,1,1),i.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const n=r.baseColorFactor;i.color.fromArray(n),i.opacity=n[3]}r.baseColorTexture!==void 0&&s.push(t.assignTexture(i,"map",r.baseColorTexture,et))}return Promise.all(s)}},IY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(i,e){const t=this.parser.json.materials[i];if(!t.extensions||!t.extensions[this.name])return Promise.resolve();const s=t.extensions[this.name].emissiveStrength;return s!==void 0&&(e.emissiveIntensity=s),Promise.resolve()}},RY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_CLEARCOAT}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];if(n.clearcoatFactor!==void 0&&(e.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&r.push(t.assignTexture(e,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&r.push(t.assignTexture(e,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(r.push(t.assignTexture(e,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const o=n.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new ee(o,o)}return Promise.all(r)}},PY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_IRIDESCENCE}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return n.iridescenceFactor!==void 0&&(e.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&r.push(t.assignTexture(e,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(e.iridescenceIOR=n.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&r.push(t.assignTexture(e,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(r)}},BY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_SHEEN}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new _e(0,0,0),e.sheenRoughness=0,e.sheen=1;const n=s.extensions[this.name];return n.sheenColorFactor!==void 0&&e.sheenColor.fromArray(n.sheenColorFactor),n.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&r.push(t.assignTexture(e,"sheenColorMap",n.sheenColorTexture,et)),n.sheenRoughnessTexture!==void 0&&r.push(t.assignTexture(e,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(r)}},kY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_TRANSMISSION}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return n.transmissionFactor!==void 0&&(e.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&r.push(t.assignTexture(e,"transmissionMap",n.transmissionTexture)),Promise.all(r)}},DY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_VOLUME}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];e.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&r.push(t.assignTexture(e,"thicknessMap",n.thicknessTexture)),e.attenuationDistance=n.attenuationDistance||1/0;const o=n.attenuationColor||[1,1,1];return e.attenuationColor=new _e(o[0],o[1],o[2]),Promise.all(r)}},OY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_IOR}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser.json.materials[i];if(!t.extensions||!t.extensions[this.name])return Promise.resolve();const s=t.extensions[this.name];return e.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}},LY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_SPECULAR}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];e.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&r.push(t.assignTexture(e,"specularIntensityMap",n.specularTexture));const o=n.specularColorFactor||[1,1,1];return e.specularColor=new _e(o[0],o[1],o[2]),n.specularColorTexture!==void 0&&r.push(t.assignTexture(e,"specularColorMap",n.specularColorTexture,et)),Promise.all(r)}},UY=class{constructor(i){this.parser=i,this.name=$t.KHR_MATERIALS_ANISOTROPY}getMaterialType(i){const e=this.parser.json.materials[i];return!e.extensions||!e.extensions[this.name]?null:Po}extendMaterialParams(i,e){const t=this.parser,s=t.json.materials[i];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],n=s.extensions[this.name];return n.anisotropyStrength!==void 0&&(e.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(e.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&r.push(t.assignTexture(e,"anisotropyMap",n.anisotropyTexture)),Promise.all(r)}};class FY{constructor(e){this.parser=e,this.name=$t.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,r=s.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const n=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,o)}}class NY{constructor(e){this.parser=e,this.name=$t.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,r=s.json,n=r.textures[e];if(!n.extensions||!n.extensions[t])return null;const o=n.extensions[t],a=r.images[o.source];let l=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(e,o.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class zY{constructor(e){this.parser=e,this.name=$t.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,r=s.json,n=r.textures[e];if(!n.extensions||!n.extensions[t])return null;const o=n.extensions[t],a=r.images[o.source];let l=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return s.loadTextureImage(e,o.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class jY{constructor(e){this.name=$t.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const r=s.extensions[this.name],n=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return n.then(function(a){const l=r.byteOffset||0,c=r.byteLength||0,u=r.count,d=r.byteStride,p=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,d,p,r.mode,r.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(u*d);return o.decodeGltfBuffer(new Uint8Array(f),u,d,p,r.mode,r.filter),f})})}else return null}}class QY{constructor(e){this.name=$t.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const r=t.meshes[s.mesh];for(const l of r.primitives)if(l.mode!==oo.TRIANGLES&&l.mode!==oo.TRIANGLE_STRIP&&l.mode!==oo.TRIANGLE_FAN&&l.mode!==void 0)return null;const n=s.extensions[this.name].attributes,o=[],a={};for(const l in n)o.push(this.parser.getDependency("accessor",n[l]).then(c=>(a[l]=c,a[l])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(l=>{const c=l.pop(),u=c.isGroup?c.children:[c],d=l[0].count,p=[];for(const f of u){const m=new Be,A=new w,v=new Ee,g=new w(1,1,1),b=new i0(f.geometry,f.material,d);for(let y=0;y<d;y++)a.TRANSLATION&&A.fromBufferAttribute(a.TRANSLATION,y),a.ROTATION&&v.fromBufferAttribute(a.ROTATION,y),a.SCALE&&g.fromBufferAttribute(a.SCALE,y),b.setMatrixAt(y,m.compose(A,v,g));for(const y in a)y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&f.geometry.setAttribute(y,a[y]);Re.prototype.copy.call(b,f),this.parser.assignFinalMaterial(b),p.push(b)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]}))}}const YL="glTF",Vm=12,KL={JSON:1313821514,BIN:5130562};class GY{constructor(e){this.name=$t.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Vm),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==YL)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-Vm,n=new DataView(e,Vm);let o=0;for(;o<r;){const a=n.getUint32(o,!0);o+=4;const l=n.getUint32(o,!0);if(o+=4,l===KL.JSON){const c=new Uint8Array(e,Vm+o,a);this.content=s.decode(c)}else if(l===KL.BIN){const c=Vm+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class HY{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=$t.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,r=this.dracoLoader,n=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(const u in o){const d=JC[u]||u.toLowerCase();a[d]=o[u]}for(const u in e.attributes){const d=JC[u]||u.toLowerCase();if(o[u]!==void 0){const p=s.accessors[e.attributes[u]],f=ep[p.componentType];c[d]=f.name,l[d]=p.normalized===!0}}return t.getDependency("bufferView",n).then(function(u){return new Promise(function(d){r.decodeDracoFile(u,function(p){for(const f in p.attributes){const m=p.attributes[f],A=l[f];A!==void 0&&(m.normalized=A)}d(p)},a,c)})})}}class VY{constructor(){this.name=$t.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class WY{constructor(){this.name=$t.KHR_MESH_QUANTIZATION}}class JL extends Bd{constructor(e,t,s,r){super(e,t,s,r)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,r=this.valueSize,n=e*r*3+r;for(let o=0;o!==r;o++)t[o]=s[n+o];return t}interpolate_(e,t,s,r){const n=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,u=r-t,d=(s-t)/u,p=d*d,f=p*d,m=e*c,A=m-c,v=-2*f+3*p,g=f-p,b=1-v,y=g-p+d;for(let _=0;_!==a;_++){const S=o[A+_+a],M=o[A+_+l]*u,I=o[m+_+a],R=o[m+_]*u;n[_]=b*S+y*M+v*I+g*R}return n}}const XY=new Ee;class qY extends JL{interpolate_(e,t,s,r){const n=super.interpolate_(e,t,s,r);return XY.fromArray(n).normalize().toArray(n),n}}const oo={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},ep={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ZL={9728:jt,9729:Bt,9984:td,9985:Ef,9986:wh,9987:Jn},$L={33071:Ns,33648:xh,10497:Kn},KC={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},JC={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Uc={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},YY={CUBICSPLINE:void 0,LINEAR:aa,STEP:gc},ZC={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function KY(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new Ro({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:gr})),i.DefaultMaterial}function cu(i,e,t){for(const s in t.extensions)i[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function Fc(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function JY(i,e,t){let s=!1,r=!1,n=!1;for(let c=0,u=e.length;c<u;c++){const d=e[c];if(d.POSITION!==void 0&&(s=!0),d.NORMAL!==void 0&&(r=!0),d.COLOR_0!==void 0&&(n=!0),s&&r&&n)break}if(!s&&!r&&!n)return Promise.resolve(i);const o=[],a=[],l=[];for(let c=0,u=e.length;c<u;c++){const d=e[c];if(s){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):i.attributes.position;o.push(p)}if(r){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):i.attributes.normal;a.push(p)}if(n){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):i.attributes.color;l.push(p)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const u=c[0],d=c[1],p=c[2];return s&&(i.morphAttributes.position=u),r&&(i.morphAttributes.normal=d),n&&(i.morphAttributes.color=p),i.morphTargetsRelative=!0,i})}function ZY(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let s=0,r=t.length;s<r;s++)i.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function $Y(i){let e;const t=i.extensions&&i.extensions[$t.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+$C(t.attributes):e=i.indices+":"+$C(i.attributes)+":"+i.mode,i.targets!==void 0)for(let s=0,r=i.targets.length;s<r;s++)e+=":"+$C(i.targets[s]);return e}function $C(i){let e="";const t=Object.keys(i).sort();for(let s=0,r=t.length;s<r;s++)e+=t[s]+":"+i[t[s]]+";";return e}function eE(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function e7(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const t7=new Be;class i7{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new EY,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,r=!1,n=-1;typeof navigator<"u"&&(s=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,n=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||s||r&&n<98?this.textureLoader=new dl(this.options.manager):this.textureLoader=new hk(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Ps(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,r=this.json,n=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const a={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:s,userData:{}};cu(n,a,r),Fc(a,r),Promise.all(s._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let r=0,n=t.length;r<n;r++){const o=t[r].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let r=0,n=e.length;r<n;r++){const o=e[r];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const r=s.clone(),n=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,u]of o.children.entries())n(u,a.children[c])};return n(s,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const r=e(t[s]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let r=0;r<t.length;r++){const n=e(t[r]);n&&s.push(n)}return s}getDependency(e,t){const s=e+":"+t;let r=this.cache.get(s);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(n){return n.loadNode&&n.loadNode(t)});break;case"mesh":r=this._invokeOne(function(n){return n.loadMesh&&n.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(n){return n.loadBufferView&&n.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(n){return n.loadMaterial&&n.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(n){return n.loadTexture&&n.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(n){return n.loadAnimation&&n.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(s,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(n,o){return s.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[$t.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(n,o){s.load(Od.resolveURL(t.uri,r.path),n,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const r=t.byteLength||0,n=t.byteOffset||0;return s.slice(n,n+r)})}loadAccessor(e){const t=this,s=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const o=KC[r.type],a=ep[r.componentType],l=r.normalized===!0,c=new a(r.count*o);return Promise.resolve(new rt(c,o,l))}const n=[];return r.bufferView!==void 0?n.push(this.getDependency("bufferView",r.bufferView)):n.push(null),r.sparse!==void 0&&(n.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(n).then(function(o){const a=o[0],l=KC[r.type],c=ep[r.componentType],u=c.BYTES_PER_ELEMENT,d=u*l,p=r.byteOffset||0,f=r.bufferView!==void 0?s.bufferViews[r.bufferView].byteStride:void 0,m=r.normalized===!0;let A,v;if(f&&f!==d){const g=Math.floor(p/f),b="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+g+":"+r.count;let y=t.cache.get(b);y||(A=new c(a,g*f,r.count*f/u),y=new Wf(A,f/u),t.cache.add(b,y)),v=new ic(y,l,p%f/u,m)}else a===null?A=new c(r.count*l):A=new c(a,p,r.count*l),v=new rt(A,l,m);if(r.sparse!==void 0){const g=KC.SCALAR,b=ep[r.sparse.indices.componentType],y=r.sparse.indices.byteOffset||0,_=r.sparse.values.byteOffset||0,S=new b(o[1],y,r.sparse.count*g),M=new c(o[2],_,r.sparse.count*l);a!==null&&(v=new rt(v.array.slice(),v.itemSize,v.normalized));for(let I=0,R=S.length;I<R;I++){const E=S[I];if(v.setX(E,M[I*l]),l>=2&&v.setY(E,M[I*l+1]),l>=3&&v.setZ(E,M[I*l+2]),l>=4&&v.setW(E,M[I*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){const t=this.json,s=this.options,r=t.textures[e].source,n=t.images[r];let o=this.textureLoader;if(n.uri){const a=s.manager.getHandler(n.uri);a!==null&&(o=a)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,s){const r=this,n=this.json,o=n.textures[e],a=n.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,s).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const d=(n.samplers||{})[o.sampler]||{};return u.magFilter=ZL[d.magFilter]||Bt,u.minFilter=ZL[d.minFilter]||Jn,u.wrapS=$L[d.wrapS]||Kn,u.wrapT=$L[d.wrapT]||Kn,u.anisotropy=4,r.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const s=this,r=this.json,n=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=r.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=s.getDependency("bufferView",o.bufferView).then(function(d){c=!0;const p=new Blob([d],{type:o.mimeType});return l=a.createObjectURL(p),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(d){return new Promise(function(p,f){let m=p;t.isImageBitmapLoader===!0&&(m=function(A){const v=new Pt(A);v.needsUpdate=!0,p(v)}),t.load(Od.resolveURL(d,n.path),m,void 0,f)})}).then(function(d){return c===!0&&a.revokeObjectURL(l),d.userData.mimeType=o.mimeType||e7(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=u,u}assignTexture(e,t,s,r){const n=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),n.extensions[$t.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[$t.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=n.associations.get(o);o=n.extensions[$t.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),n.associations.set(o,l)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const r=t.attributes.tangent===void 0,n=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+s.uuid;let l=this.cache.get(a);l||(l=new r0,kt.prototype.copy.call(l,s),l.color.copy(s.color),l.map=s.map,l.sizeAttenuation=!1,this.cache.add(a,l)),s=l}else if(e.isLine){const a="LineBasicMaterial:"+s.uuid;let l=this.cache.get(a);l||(l=new is,kt.prototype.copy.call(l,s),l.color.copy(s.color),l.map=s.map,this.cache.add(a,l)),s=l}if(r||n||o){let a="ClonedMaterial:"+s.uuid+":";r&&(a+="derivative-tangents:"),n&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=s.clone(),n&&(l.vertexColors=!0),o&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(s))),s=l}e.material=s}getMaterialType(){return Ro}loadMaterial(e){const t=this,s=this.json,r=this.extensions,n=s.materials[e];let o;const a={},l=n.extensions||{},c=[];if(l[$t.KHR_MATERIALS_UNLIT]){const d=r[$t.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),c.push(d.extendParams(a,n,t))}else{const d=n.pbrMetallicRoughness||{};if(a.color=new _e(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;a.color.fromArray(p),a.opacity=p[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,et)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}n.doubleSided===!0&&(a.side=_i);const u=n.alphaMode||ZC.OPAQUE;if(u===ZC.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===ZC.MASK&&(a.alphaTest=n.alphaCutoff!==void 0?n.alphaCutoff:.5)),n.normalTexture!==void 0&&o!==li&&(c.push(t.assignTexture(a,"normalMap",n.normalTexture)),a.normalScale=new ee(1,1),n.normalTexture.scale!==void 0)){const d=n.normalTexture.scale;a.normalScale.set(d,d)}return n.occlusionTexture!==void 0&&o!==li&&(c.push(t.assignTexture(a,"aoMap",n.occlusionTexture)),n.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=n.occlusionTexture.strength)),n.emissiveFactor!==void 0&&o!==li&&(a.emissive=new _e().fromArray(n.emissiveFactor)),n.emissiveTexture!==void 0&&o!==li&&c.push(t.assignTexture(a,"emissiveMap",n.emissiveTexture,et)),Promise.all(c).then(function(){const d=new o(a);return n.name&&(d.name=n.name),Fc(d,n),t.associations.set(d,{materials:e}),n.extensions&&cu(r,d,n),d})}createUniqueName(e){const t=Ot.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,r=this.primitiveCache;function n(a){return s[$t.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return eU(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],u=$Y(c),d=r[u];if(d)o.push(d.promise);else{let p;c.extensions&&c.extensions[$t.KHR_DRACO_MESH_COMPRESSION]?p=n(c):p=eU(new gt,c,t),r[u]={primitive:c,promise:p},o.push(p)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,r=this.extensions,n=s.meshes[e],o=n.primitives,a=[];for(let l=0,c=o.length;l<c;l++){const u=o[l].material===void 0?KY(this.cache):this.getDependency("material",o[l].material);a.push(u)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),u=l[l.length-1],d=[];for(let f=0,m=u.length;f<m;f++){const A=u[f],v=o[f];let g;const b=c[f];if(v.mode===oo.TRIANGLES||v.mode===oo.TRIANGLE_STRIP||v.mode===oo.TRIANGLE_FAN||v.mode===void 0)g=n.isSkinnedMesh===!0?new Uh(A,b):new ye(A,b),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),v.mode===oo.TRIANGLE_STRIP?g.geometry=qL(g.geometry,Iw):v.mode===oo.TRIANGLE_FAN&&(g.geometry=qL(g.geometry,vA));else if(v.mode===oo.LINES)g=new Rn(A,b);else if(v.mode===oo.LINE_STRIP)g=new ss(A,b);else if(v.mode===oo.LINE_LOOP)g=new vS(A,b);else if(v.mode===oo.POINTS)g=new yS(A,b);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(g.geometry.morphAttributes).length>0&&ZY(g,n),g.name=t.createUniqueName(n.name||"mesh_"+e),Fc(g,n),v.extensions&&cu(r,g,v),t.assignFinalMaterial(g),d.push(g)}for(let f=0,m=d.length;f<m;f++)t.associations.set(d[f],{meshes:e,primitives:f});if(d.length===1)return n.extensions&&cu(r,d[0],n),d[0];const p=new Tn;n.extensions&&cu(r,p,n),t.associations.set(p,{meshes:e});for(let f=0,m=d.length;f<m;f++)p.add(d[f]);return p})}loadCamera(e){let t;const s=this.json.cameras[e],r=s[s.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new qt(qs.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):s.type==="orthographic"&&(t=new kh(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),Fc(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let r=0,n=t.joints.length;r<n;r++)s.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(r){const n=r.pop(),o=r,a=[],l=[];for(let c=0,u=o.length;c<u;c++){const d=o[c];if(d){a.push(d);const p=new Be;n!==null&&p.fromArray(n.array,c*16),l.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new pf(a,l)})}loadAnimation(e){const t=this.json,s=this,r=t.animations[e],n=r.name?r.name:"animation_"+e,o=[],a=[],l=[],c=[],u=[];let d=0,p=r.channels.length;for(d=0,p=r.channels.length;d<p;d++){const f=r.channels[d],m=r.samplers[f.sampler],A=f.target,v=A.node,g=r.parameters!==void 0?r.parameters[m.input]:m.input,b=r.parameters!==void 0?r.parameters[m.output]:m.output;A.node!==void 0&&(o.push(this.getDependency("node",v)),a.push(this.getDependency("accessor",g)),l.push(this.getDependency("accessor",b)),c.push(m),u.push(A))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(u)]).then(function(f){const m=f[0],A=f[1],v=f[2],g=f[3],b=f[4],y=[];for(d=0,p=m.length;d<p;d++){const _=m[d],S=A[d],M=v[d],I=g[d],R=b[d];if(_===void 0)continue;_.updateMatrix&&(_.updateMatrix(),_.matrixAutoUpdate=!0);const E=s._createAnimationTracks(_,S,M,I,R);if(E)for(let C=0;C<E.length;C++)y.push(E[C])}return new Fr(n,void 0,y)})}createNodeMesh(e){const t=this.json,s=this,r=t.nodes[e];return r.mesh===void 0?null:s.getDependency("mesh",r.mesh).then(function(n){const o=s._getNodeRef(s.meshCache,r.mesh,n);return r.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let l=0,c=r.weights.length;l<c;l++)a.morphTargetInfluences[l]=r.weights[l]}),o})}loadNode(e){const t=this.json,s=this,r=t.nodes[e],n=s._loadNodeShallow(e),o=[],a=r.children||[];for(let c=0,u=a.length;c<u;c++)o.push(s.getDependency("node",a[c]));const l=r.skin===void 0?Promise.resolve(null):s.getDependency("skin",r.skin);return Promise.all([n,Promise.all(o),l]).then(function(c){const u=c[0],d=c[1],p=c[2];p!==null&&u.traverse(function(f){f.isSkinnedMesh&&f.bind(p,t7)});for(let f=0,m=d.length;f<m;f++)u.add(d[f]);return u})}_loadNodeShallow(e){const t=this.json,s=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const n=t.nodes[e],o=n.name?r.createUniqueName(n.name):"",a=[],l=r._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),n.camera!==void 0&&a.push(r.getDependency("camera",n.camera).then(function(c){return r._getNodeRef(r.cameraCache,n.camera,c)})),r._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let u;if(n.isBone===!0?u=new Kf:c.length>1?u=new Tn:c.length===1?u=c[0]:u=new Re,u!==c[0])for(let d=0,p=c.length;d<p;d++)u.add(c[d]);if(n.name&&(u.userData.name=n.name,u.name=o),Fc(u,n),n.extensions&&cu(s,u,n),n.matrix!==void 0){const d=new Be;d.fromArray(n.matrix),u.applyMatrix4(d)}else n.translation!==void 0&&u.position.fromArray(n.translation),n.rotation!==void 0&&u.quaternion.fromArray(n.rotation),n.scale!==void 0&&u.scale.fromArray(n.scale);return r.associations.has(u)||r.associations.set(u,{}),r.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],r=this,n=new Tn;s.name&&(n.name=r.createUniqueName(s.name)),Fc(n,s),s.extensions&&cu(t,n,s);const o=s.nodes||[],a=[];for(let l=0,c=o.length;l<c;l++)a.push(r.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let u=0,d=l.length;u<d;u++)n.add(l[u]);const c=u=>{const d=new Map;for(const[p,f]of r.associations)(p instanceof kt||p instanceof Pt)&&d.set(p,f);return u.traverse(p=>{const f=r.associations.get(p);f!=null&&d.set(p,f)}),d};return r.associations=c(n),n})}_createAnimationTracks(e,t,s,r,n){const o=[],a=e.name?e.name:e.uuid,l=[];Uc[n.path]===Uc.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(a);let c;switch(Uc[n.path]){case Uc.weights:c=xc;break;case Uc.rotation:c=ua;break;case Uc.position:case Uc.scale:c=hl;break;default:switch(s.itemSize){case 1:c=xc;break;case 2:case 3:default:c=hl;break}break}const u=r.interpolation!==void 0?YY[r.interpolation]:aa,d=this._getArrayFromAccessor(s);for(let p=0,f=l.length;p<f;p++){const m=new c(l[p]+"."+Uc[n.path],t.array,d,u);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=eE(t.constructor),r=new Float32Array(t.length);for(let n=0,o=t.length;n<o;n++)r[n]=t[n]*s;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const s=this instanceof ua?qY:JL;return new s(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function s7(i,e,t){const s=e.attributes,r=new Ts;if(s.POSITION!==void 0){const a=t.json.accessors[s.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(r.set(new w(l[0],l[1],l[2]),new w(c[0],c[1],c[2])),a.normalized){const u=eE(ep[a.componentType]);r.min.multiplyScalar(u),r.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const n=e.targets;if(n!==void 0){const a=new w,l=new w;for(let c=0,u=n.length;c<u;c++){const d=n[c];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],f=p.min,m=p.max;if(f!==void 0&&m!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),p.normalized){const A=eE(ep[p.componentType]);l.multiplyScalar(A)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}i.boundingBox=r;const o=new Or;r.getCenter(o.center),o.radius=r.min.distanceTo(r.max)/2,i.boundingSphere=o}function eU(i,e,t){const s=e.attributes,r=[];function n(o,a){return t.getDependency("accessor",o).then(function(l){i.setAttribute(a,l)})}for(const o in s){const a=JC[o]||o.toLowerCase();a in i.attributes||r.push(n(s[o],a))}if(e.indices!==void 0&&!i.index){const o=t.getDependency("accessor",e.indices).then(function(a){i.setIndex(a)});r.push(o)}return Fc(i,e),s7(i,e,t),Promise.all(r).then(function(){return e.targets!==void 0?JY(i,e.targets,t):i})}var tU=(i=>(i[i.INT=5124]="INT",i[i.FLOAT=5126]="FLOAT",i[i.FLOAT_VEC2=35664]="FLOAT_VEC2",i[i.FLOAT_VEC3=35665]="FLOAT_VEC3",i[i.FLOAT_VEC4=35666]="FLOAT_VEC4",i[i.INT_VEC2=35667]="INT_VEC2",i[i.INT_VEC3=35668]="INT_VEC3",i[i.INT_VEC4=35669]="INT_VEC4",i[i.BOOL=35670]="BOOL",i[i.BOOL_VEC2=35671]="BOOL_VEC2",i[i.BOOL_VEC3=35672]="BOOL_VEC3",i[i.BOOL_VEC4=35673]="BOOL_VEC4",i[i.FLOAT_MAT2=35674]="FLOAT_MAT2",i[i.FLOAT_MAT3=35675]="FLOAT_MAT3",i[i.FLOAT_MAT4=35676]="FLOAT_MAT4",i[i.SAMPLER_2D=35678]="SAMPLER_2D",i[i.SAMPLER_3D=35680]="SAMPLER_3D",i[i.SAMPLER_CUBE=35681]="SAMPLER_CUBE",i[i.UNKNOWN=0]="UNKNOWN",i))(tU||{});const ba=le("debugcustomshader"),tp="NEEDLE_techniques_webgl";class r7{constructor(){h(this,"objectToWorldMatrix",new Be),h(this,"worldToObjectMatrix",new Be),h(this,"objectToWorld",new Array),h(this,"worldToObject",new Array)}updateFrom(e){this.objectToWorldMatrix.copy(e.matrixWorld),My(this.objectToWorldMatrix,this.objectToWorld),this.worldToObjectMatrix.copy(e.matrixWorld).invert(),My(this.worldToObjectMatrix,this.worldToObject)}}const Hi=class extends g0{constructor(i,...e){super(...e),h(this,"identifier"),h(this,"onBeforeRenderSceneCallback",this.onBeforeRenderScene.bind(this)),h(this,"_sphericalHarmonicsName","unity_SpecCube0"),h(this,"_objToWorldName","hlslcc_mtx4x4unity_ObjectToWorld"),h(this,"_worldToObjectName","hlslcc_mtx4x4unity_WorldToObject"),h(this,"_viewProjectionName","hlslcc_mtx4x4unity_MatrixVP"),h(this,"_viewMatrixName","hlslcc_mtx4x4unity_MatrixV"),h(this,"_rendererData",new r7),this.identifier=i,ba&&console.log(this),this.type="NEEDLE_CUSTOM_SHADER",this.uniforms[this._objToWorldName]||(this.uniforms[this._objToWorldName]={value:[]}),this.uniforms[this._worldToObjectName]||(this.uniforms[this._worldToObjectName]={value:[]}),this.uniforms[this._viewProjectionName]||(this.uniforms[this._viewProjectionName]={value:[]}),this.uniforms[this._sphericalHarmonicsName]&&this.waitForLighting(),(this.depthTextureUniform||this.opaqueTextureUniform)&&zt.Current.pre_render_callbacks.push(this.onBeforeRenderSceneCallback)}clone(){const i=super.clone();return iU(i),i}dispose(){super.dispose();const i=zt.Current.pre_render_callbacks.indexOf(this.onBeforeRenderSceneCallback);i>=0&&zt.Current.pre_render_callbacks.splice(i,1)}async waitForLighting(){const i=zt.Current;if(!i){console.error("Missing context");return}const e=await i.sceneLighting.internalGetSceneLightingData(this.identifier);if(!e||!e.array){console.warn("Missing lighting data for custom shader, getSceneLightingData did not return anything");return}ba&&console.log(e);const t=e.array,s=e.texture;this.uniforms.unity_SpecCube0={value:s},XO(this.uniforms,t);const r=Math.sqrt(Math.PI*.5);this.uniforms.unity_SpecCube0_HDR={value:new it(r,r,r,r)},ba&&console.log("Set environment lighting",this.uniforms)}get depthTextureUniform(){if(this.uniforms)return this.uniforms._CameraDepthTexture}get opaqueTextureUniform(){if(this.uniforms)return this.uniforms._CameraOpaqueTexture}onBeforeRenderScene(){this.opaqueTextureUniform&&zt.Current.setRequireColor(!0),this.depthTextureUniform&&zt.Current.setRequireDepth(!0)}onBeforeRender(i,e,t,s,r,n){s.attributes.tangent||s.computeTangents(),this.onUpdateUniforms(t,r)}onUpdateUniforms(i,e){const t=zt.Current;if(i&&(Hi.viewProjection&&this.uniforms[this._viewProjectionName]&&(Hi.viewProjection.copy(i.projectionMatrix).multiply(i.matrixWorldInverse),My(Hi.viewProjection,Hi._viewProjectionValues)),Hi.viewMatrix&&this.uniforms[this._viewMatrixName]&&(Hi.viewMatrix.copy(i.matrixWorldInverse),My(Hi.viewMatrix,Hi._viewMatrixValues)),this.uniforms[Hi._worldSpaceCameraPosName]&&Hi._worldSpaceCameraPos.setFromMatrixPosition(i.matrixWorld)),this.uniforms._TimeParameters&&(this.uniforms._TimeParameters.value=t.sceneLighting.timeVec4),this.uniforms._Time){const o=this.uniforms._Time.value;o.x=t.sceneLighting.timeVec4.x/20,o.y=t.sceneLighting.timeVec4.x,o.z=t.sceneLighting.timeVec4.x*2,o.w=t.sceneLighting.timeVec4.x*3}if(this.uniforms._SinTime){const o=this.uniforms._SinTime.value;o.x=Math.sin(t.sceneLighting.timeVec4.x/8),o.y=Math.sin(t.sceneLighting.timeVec4.x/4),o.z=Math.sin(t.sceneLighting.timeVec4.x/2),o.w=Math.sin(t.sceneLighting.timeVec4.x)}if(this.uniforms._CosTime){const o=this.uniforms._CosTime.value;o.x=Math.cos(t.sceneLighting.timeVec4.x/8),o.y=Math.cos(t.sceneLighting.timeVec4.x/4),o.z=Math.cos(t.sceneLighting.timeVec4.x/2),o.w=Math.cos(t.sceneLighting.timeVec4.x)}if(this.uniforms.unity_DeltaTime){const o=this.uniforms.unity_DeltaTime.value;o.x=t.time.deltaTime,o.y=1/t.time.deltaTime,o.z=t.time.smoothedDeltaTime,o.w=1/t.time.smoothedDeltaTime}const s=t.mainLight;if(s){const o=At(s.gameObject,Hi._mainLightPosition);this.uniforms._MainLightPosition={value:o.normalize()},Hi._mainLightColor.set(s.color.r,s.color.g,s.color.b,0),this.uniforms._MainLightColor={value:Hi._mainLightColor};const a=s.intensity;Hi._lightData.z=a,this.uniforms.unity_LightData={value:Hi._lightData}}if(i&&(Hi.viewProjection&&this.uniforms[this._viewProjectionName]&&(this.uniforms[this._viewProjectionName].value=Hi._viewProjectionValues),Hi.viewMatrix&&this.uniforms[this._viewMatrixName]&&(this.uniforms[this._viewMatrixName].value=Hi._viewMatrixValues),this.uniforms[Hi._worldSpaceCameraPosName]&&(this.uniforms[Hi._worldSpaceCameraPosName]={value:Hi._worldSpaceCameraPos}),t.mainCameraComponent)){if(this.uniforms._ProjectionParams){const o=this.uniforms._ProjectionParams.value;o.x=1,o.y=t.mainCameraComponent.nearClipPlane,o.z=t.mainCameraComponent.farClipPlane,o.w=1/o.z,this.uniforms._ProjectionParams.value=o}if(this.uniforms._ZBufferParams){const o=this.uniforms._ZBufferParams.value,a=t.mainCameraComponent;o.x=1-a.farClipPlane/a.nearClipPlane,o.y=a.farClipPlane/a.nearClipPlane,o.z=o.x/a.farClipPlane,o.w=o.y/a.farClipPlane,this.uniforms._ZBufferParams.value=o}if(this.uniforms._ScreenParams){const o=this.uniforms._ScreenParams.value;o.x=t.domWidth,o.y=t.domHeight,o.z=1+1/o.x,o.w=1+1/o.y,this.uniforms._ScreenParams.value=o}}const r=this.depthTextureUniform;r&&(r.value=t.depthTexture);const n=this.opaqueTextureUniform;if(n&&(n.value=t.opaqueColorTexture),e){const o=this._rendererData;o.updateFrom(e),this.uniforms[this._worldToObjectName].value=o.worldToObject,this.uniforms[this._objToWorldName].value=o.objectToWorld}this.uniformsNeedUpdate=!0}};let zo=Hi;h(zo,"viewProjection",new Be),h(zo,"_viewProjectionValues",[]),h(zo,"viewMatrix",new Be),h(zo,"_viewMatrixValues",[]),h(zo,"_worldSpaceCameraPosName","_WorldSpaceCameraPos"),h(zo,"_worldSpaceCameraPos",new w),h(zo,"_mainLightColor",new it),h(zo,"_mainLightPosition",new w),h(zo,"_lightData",new it);class n7{constructor(e,t){h(this,"parser"),h(this,"identifier"),this.parser=e,this.identifier=t}get name(){return tp}loadMaterial(e){const t=this.parser.json.materials[e];if(!t)return ba&&console.log(e,this.parser.json.materials),null;if(!t.extensions||!t.extensions[tp])return ba&&console.log("material "+e+" does not use NEEDLE_techniques_webgl"),null;const s=t.extensions[tp].technique;if(s<0)return null;const r=this.parser.json.extensions[tp];if(!r)return null;ba&&console.log(r);const n=r.techniques[s];return n?new Promise(async(o,a)=>{var l,c,u;const d=await vq(r,n.program),p=d?.fragmentShader,f=d?.vertexShader;if(!p||!f)return a();ba&&console.log("loadMaterial",t,d);const m={},A=n.uniforms;(f.includes("_Time")||p.includes("_Time"))&&(m._Time={value:new it(0,0,0,0)}),(f.includes("_SinTime")||p.includes("_SinTime"))&&(m._SinTime={value:new it(0,0,0,0)}),(f.includes("_CosTime")||p.includes("_CosTime"))&&(m._CosTime={value:new it(0,0,0,0)}),(f.includes("unity_DeltaTime")||p.includes("unity_DeltaTime"))&&(m.unity_DeltaTime={value:new it(0,0,0,0)});for(const b in A){const y=b;switch(y){case"_TimeParameters":const _=new it;m[y]={value:_};break;case"hlslcc_mtx4x4unity_MatrixV":case"hlslcc_mtx4x4unity_MatrixVP":m[y]={value:[]};break;case"_MainLightPosition":case"_MainLightColor":case"_WorldSpaceCameraPos":m[y]={value:[0,0,0,1]};break;case"unity_OrthoParams":break;case"unity_SpecCube0":m[y]={value:null};break;default:case"_ScreenParams":case"_ZBufferParams":case"_ProjectionParams":m[y]={value:[0,0,0,0]};break;case"_CameraOpaqueTexture":case"_CameraDepthTexture":m[y]={value:null};break}}let v=!1;if(t.extensions&&t.extensions[tp]){const b=t.extensions[tp];if(b.technique===s){ba&&console.log(t.name,"Material Properties",b);for(const y in b.values){const _=b.values[y];if(typeof _=="string"){if(_.startsWith("/textures/")){const S=_.substring(10),M=Number.parseInt(S);if(M>=0){const I=await this.parser.getDependency("texture",M);I instanceof Pt&&(I.colorSpace=ts,I.needsUpdate=!0),m[y]={value:I};continue}}switch(y){case"alphaMode":_==="BLEND"&&(v=!0);continue}}if(Array.isArray(_)&&_.length===4){m[y]={value:new it(_[0],_[1],_[2],_[3])};continue}m[y]={value:_}}}}const g=new zo(this.identifier,{name:t.name??"",uniforms:m,vertexShader:f,fragmentShader:p,lights:!1});switch(g.glslVersion=yA,g.vertexShader=g.vertexShader.replace("#version 300 es",""),g.fragmentShader=g.fragmentShader.replace("#version 300 es",""),(l=m._Cull)==null?void 0:l.value){case 0:g.side=_i;break;case 1:g.side=es;break;case 2:g.side=gr;break;default:g.side=gr;break}switch((c=m._ZTest)==null?void 0:c.value){case 3:g.depthTest=!0,g.depthFunc=Zu;break;case 6:g.depthTest=!0,g.depthFunc=wf;break;case 2:g.depthTest=!0,g.depthFunc=xf;break;case 4:g.depthTest=!0,g.depthFunc=Ju;break;case 5:g.depthTest=!0,g.depthFunc=rA;break;case 7:g.depthTest=!0,g.depthFunc=sA;break;case 8:g.depthTest=!1,g.depthFunc=iA;break}g.transparent=v,v&&(g.depthWrite=!1),XO(m),g.onUpdateUniforms();for(const b in A){const y=b,_=A[b].type;if(((u=m[y])==null?void 0:u.value)===void 0)switch(_){case tU.SAMPLER_2D:m[y]={value:fq},console.warn("Missing/unassigned texture, fallback to white: "+y);break;default:y==="unity_OrthoParams"||console.warn("TODO: EXPECTED UNIFORM / fallback NOT SET: "+y,A[b]);break}}ba&&console.log(g.uuid,m),iU(g),o(g)}):null}}function iU(i){if(i.uniforms){ba&&console.log("Uniforms:",i.uniforms);for(const t in i.uniforms)switch(e(t,t),t){case"_Color":e("color",t);break}}function e(t,s){Object.getOwnPropertyDescriptor(i,t)||Object.defineProperty(i,t,{get:()=>i.uniforms[s].value,set:r=>{i.uniforms[s].value=r,i.needsUpdate=!0}})}}const El=_r,jy="$___Export_Components",o7="NEEDLE_components";var sU;class a7{constructor(){h(this,sU)}}sU=$h;class l7{constructor(e,t,s){h(this,"node"),h(this,"nodeIndex"),h(this,"nodeDef"),this.node=e,this.nodeIndex=t,this.nodeDef=s}}class rU{constructor(){h(this,"parser"),h(this,"nodeToObjectMap",{}),h(this,"exportContext"),h(this,"objectToNodeMap",{}),h(this,"context"),h(this,"writer")}get name(){return o7}registerExport(e){e.register(t=>{if("serializeUserData"in t){const s=t.serializeUserData.bind(t);this.writer=t,t.serializeUserData=(r,n)=>{try{this.serializeUserData(r,n),s(r,n)}finally{this.afterSerializeUserData(r,n)}}}return this})}beforeParse(){this.exportContext={},this.objectToNodeMap={}}serializeUserData(e,t){var s;const r=(s=e.userData)==null?void 0:s.components;!r||r.length<=0||(delete e.userData.components,e[jy]=r)}afterSerializeUserData(e,t){if(e.type==="Scene"&&El&&console.log("DONE",JSON.stringify(t)),e[jy]===void 0)return;const s=e[jy];delete e[jy],s!==null&&(e.userData.components=s)}writeNode(e,t){const s=this.writer.json.nodes.length;El&&console.log(e.name,s,e.uuid);const r=new l7(e,s,t);this.exportContext[s]=r,this.objectToNodeMap[e.uuid]=s}afterParse(e){var t;El&&console.log("AFTER",e);for(const s in this.exportContext){const r=this.exportContext[s],n=r.node,o=r.nodeDef,a=r.nodeIndex,l=(t=n.userData)==null?void 0:t.components;if(!l||l.length<=0)continue;const c=new a7;o.extensions=o.extensions||{},o.extensions[this.name]=c,this.context.object=n,this.context.nodeId=a,this.context.objectToNode=this.objectToNodeMap;const u=[];for(const d of l){this.context.target=d;const p=Lo().writeBuiltinComponentData(d,this.context);p!==null&&u.push(p)}u.length>0&&(c[$h]=u,El&&console.log("DID WRITE",n,"nodeIndex",a,u))}}beforeRoot(){return El&&console.log("BEGIN LOAD"),this.nodeToObjectMap={},null}async afterRoot(e){const t=e.parser,s=t?.extensions;if(!s)return;const r=s[this.name];El&&console.log("After root",e,this.parser,s);const n=[];if(r===!0){const o=t.json.nodes;if(o){for(let a=0;a<o.length;a++){const l=await t.getDependency("node",a);this.nodeToObjectMap[a]=l}for(let a=0;a<o.length;a++){const l=o[a],c=a,u=l.extensions;if(!u)continue;const d=u[this.name];if(!d)continue;El&&console.log("NODE",l);const p=this.nodeToObjectMap[c];if(!p){console.error("Could not find object for node index: "+c,l,t);continue}hy(p),n.push(this.createComponents(p,d))}}}await Promise.all(n)}async createComponents(e,t){if(!t)return;const s=t[$h];if(s){const r=new Array;El&&console.log(e.name,s);for(const n in s){const o=s[n];El&&console.log("Serialized data",JSON.parse(JSON.stringify(o))),o&&this.parser&&r.push(l1(this.parser,o).catch(a=>console.error(`Error while resolving references (see console for details)
4429
4447
  `,a,e,o))),e.userData=e.userData||{},e.userData[$h]=e.userData[$h]||[],e.userData[$h].push(o)}await Promise.all(r).catch(n=>{console.error("Error while loading components",n)})}}}const tE=le("debugexr");class c7{constructor(e){h(this,"parser"),this.parser=e,tE&&console.log(e)}get name(){return"EXT_texture_exr"}loadTexture(e){const t=this.name,s=this.parser,r=s.json.textures[e];if(tE&&console.log("EXT_texture_exr.loadTexture",e,r),!r.extensions||!r.extensions[t])return null;const n=r.extensions[t],o=new Uy(s.options.manager);return tE&&console.log("EXT_texture_exr.loadTexture",n),s.loadTextureImage(e,n.source,o)}}typeof window<"u"&&window.addEventListener("unhandledrejection",i=>{});const nU="NEEDLE_gameobject_data";class h7{constructor(e){h(this,"parser"),this.parser=e}get name(){return nU}afterRoot(e){var t;const s=[];for(let r=0;r<((t=this.parser.json.nodes)==null?void 0:t.length);r++){const n=this.parser.json.nodes[r];if(n&&n.extensions){const o=n.extensions[nU];if(o){const a=this.findAndApplyExtensionData(r,o);s.push(a)}}}return Promise.all(s).then(()=>{})}async findAndApplyExtensionData(e,t){const s=await this.parser.getDependency("node",e);s&&this.applyExtensionData(s,t)}applyExtensionData(e,t){t.layers===void 0&&(t.layers=0),e.userData.layer=t.layers,e.layers.disableAll(),e.layers.set(t.layers),e.userData.tag=t.tag??"none",e.userData.hideFlags=t.hideFlags??0,e.userData.static=t.static??!1,e.visible=t.activeSelf??!0,e.guid=t.guid}}const oU="NEEDLE_lighting_settings",hu=le("debugenvlight");class u7{constructor(e,t,s){h(this,"parser"),h(this,"sourceId"),h(this,"context"),this.parser=e,this.sourceId=t,this.context=s}get name(){return oU}afterRoot(e){const t=this.parser.json.extensions;if(t){const s=t[oU];if(s){hu&&console.log('Loaded "'+this.name+'", src: "'+this.sourceId+'"',s);let r;if(e.scene.children.length===1){const n=e.scene.children[0];r=se.addNewComponent(n,Qy,!1)}else{const n=new Re;n.name="LightSettings "+this.sourceId,e.scene.add(n),r=se.addNewComponent(n,Qy,!1)}r.sourceId=this.sourceId,r.ambientIntensity=s.ambientIntensity,r.ambientLight=new _e().fromArray(s.ambientLight),Array.isArray(s.ambientTrilight)&&(r.ambientTrilight=s.ambientTrilight.map(n=>new _e().fromArray(n))),r.ambientMode=s.ambientMode,r.environmentReflectionSource=s.environmentReflectionSource}}return null}}Ti.registerCallback(kr.ContextCreated,i=>{const e=i.context,t=se.findObjectOfType(Qy,e);t!=null&&t.sourceId&&(t.enabled=!0)});class Qy extends Ie{constructor(){super(...arguments),h(this,"ambientMode",qd.Skybox),h(this,"ambientLight"),h(this,"ambientTrilight"),h(this,"ambientIntensity",1),h(this,"environmentReflectionSource",Ry.Skybox),h(this,"_hasReflection",!1),h(this,"_ambientLightObj"),h(this,"_hemisphereLightObj"),h(this,"_lightProbeObj")}awake(){var e;if(this.sourceId){const s=this.environmentReflectionSource===Ry.Skybox?Dc.Skybox:Dc.Reflection,r=this.context.lightmaps.tryGet(this.sourceId,s,0);this._hasReflection=r!=null,r&&this.context.sceneLighting.internalRegisterReflection(this.sourceId,r)}this.enabled=!1,this.context.sceneLighting.internalRegisterSceneLightSettings(this),hu&&window.addEventListener("keydown",s=>{if(!this.destroyed)switch(s.key){case"l":this.enabled=!this.enabled;break}});const t=(e=this.gameObject.userData)==null?void 0:e.components;if(t){const s=t.indexOf(this);t.splice(s,1),t.push(this)}}onDestroy(){this.context.sceneLighting.internalUnregisterSceneLightSettings(this)}calculateIntensityFactor(e){const t=Math.max(e.r,e.g,e.b);return 2.2*tt.lerp(0,1.33,t)}onEnable(){if(hu&&console.warn("\u{1F4A1}\u{1F7E1} >>> Enable lighting",this.sourceId,this.enabled,this),this.ambientMode==qd.Flat){if(this.ambientLight&&!this._ambientLightObj){const e=this.calculateIntensityFactor(this.ambientLight);this._ambientLightObj=new HS(this.ambientLight,this.ambientIntensity*e),hu&&console.log("Created ambient light",this.sourceId,this._ambientLightObj,this.ambientIntensity,e)}this._ambientLightObj&&this.gameObject.add(this._ambientLightObj),this._lightProbeObj&&this._lightProbeObj.removeFromParent()}else if(this.ambientMode===qd.Trilight){if(this.ambientTrilight){const e=this.ambientTrilight[0],t=this.ambientTrilight[this.ambientTrilight.length-1],s=this.calculateIntensityFactor(t);this._hemisphereLightObj=new zS(t,e,this.ambientIntensity*s),this.gameObject.add(this._hemisphereLightObj),hu&&console.log("Created hemisphere ambient light",this.sourceId,this._hemisphereLightObj,this.ambientIntensity,s)}}else this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this._lightProbeObj?this.enabled&&this.destroyed&&this._lightProbeObj&&this.gameObject.add(this._lightProbeObj):this.sourceId&&this.context.sceneLighting.internalGetSceneLightingData(this.sourceId).then(e=>{e&&(this._lightProbeObj=e.lightProbe,this.enabled&&!this.destroyed&&this._lightProbeObj&&(hu&&console.log("Add",this.sourceId,e),this.gameObject.add(this._lightProbeObj)))});this.sourceId&&this.context.sceneLighting.internalEnableReflection(this.sourceId)}onDisable(){hu&&console.warn("\u{1F4A1}\u26AB <<< Disable lighting:",this.sourceId,this),this._lightProbeObj&&this._lightProbeObj.removeFromParent(),this._ambientLightObj&&this._ambientLightObj.removeFromParent(),this._hemisphereLightObj&&this._hemisphereLightObj.removeFromParent(),this.sourceId&&this.context.sceneLighting.internalDisableReflection(this.sourceId)}}const iE=le("debugstencil");function d7(i,e){return(i&1<<e.layer)!=0}const p7=Symbol("stencils"),ip=class{constructor(i,e){h(this,"parser"),h(this,"source"),this.parser=i,this.source=e}get name(){return"NEEDLE_render_objects"}static applyStencil(i){if(!i)return;const e=i.sourceId;if(iE&&console.log(e,ip.stencils),!e)return;const t=ip.stencils[e];if(t)for(let s=t.length-1;s>=0;s--){const r=t[s];if(d7(r.layer,i)){iE&&console.log(r),setTimeout(()=>{Br()&&Ay(i.gameObject)&&(Nr("Stencil not supported on instanced objects"),console.warn("Stencil not supported on instanced objects",i))},500);for(let n=0;n<i.sharedMaterials.length;n++){let o=i.sharedMaterials[n];o&&(o=o.clone(),o[p7]=!0,o.stencilWrite=!0,o.stencilWriteMask=255,o.stencilFuncMask=255,o.stencilRef=r.value,o.stencilFunc=r.compareFunc,o.stencilZPass=r.passOp,o.stencilFail=r.failOp,o.stencilZFail=r.zFailOp,i.sharedMaterials[n]=o)}i.gameObject.renderOrder=r.event*1e3+r.index*50;break}}}afterRoot(i){const e=this.parser.json.extensions;if(e){const t=e[m7];if(t){iE&&console.log(t);const s=t.stencil;if(s&&Array.isArray(s))for(const r of s){const n={...r};n.compareFunc=f7(n.compareFunc),n.passOp=rE(n.passOp),n.failOp=rE(n.failOp),n.zFailOp=rE(n.zFailOp),ip.stencils[this.source]||(ip.stencils[this.source]=[]),ip.stencils[this.source].push(n)}}}return null}};let sE=ip;h(sE,"stencils",{});function rE(i){switch(i){case 0:return kf;case 1:return VR;case 2:return WR;case 3:return XR;case 4:return qR;case 6:return YR;case 7:return KR;case 5:return JR}return 0}function f7(i){switch(i){case 1:return Pw;case 2:return ZR;case 3:return $R;case 4:return eP;case 5:return tP;case 6:return iP;case 7:return sP;case 8:return Bw}return Pw}const m7="NEEDLE_render_objects",Gy="NEEDLE_progressive",ks=le("debugprogressive"),nE=Symbol("needle-progressive-texture"),oE=new Map;let aE=!1;ks&&window.addEventListener("keyup",i=>{i.key==="p"&&(oE.forEach((e,t)=>{Object.entries(e).forEach(([s,r])=>{aE?t[s]=r.lod0:t[s]=r.original,t.needsUpdate=!0})}),aE=!aE)});const Hy=class{constructor(i,e,t){h(this,"parser"),h(this,"sourceId"),h(this,"context"),this.parser=i,this.sourceId=e,this.context=t}get name(){return Gy}static assignTextureLOD(i,e,t,s=0){if(!t)return Promise.resolve(null);const r=[];for(const n of Object.keys(t)){const o=t[n];if(o instanceof Pt){const a=this.assignTextureLODForSlot(i,e,t,s,n,o);r.push(a)}}if(t instanceof g0)for(const n of Object.keys(t.uniforms)){const o=t.uniforms[n].value;if(o instanceof Pt){const a=this.assignTextureLODForSlot(i,e,t,s,n,o);r.push(a)}}return Promise.all(r)}static assignTextureLODForSlot(i,e,t,s,r,n){return n?.isTexture!==!0?Promise.resolve(null):(ks&&console.log(`-----------
4430
4448
  `,"FIND",t.name,r,n?.name,n?.userData,n,t),Hy.getOrLoadTexture(i,e,t,r,n,s).then(o=>{if(o?.isTexture===!0){if(ks&&console.warn("Assign LOD",t.name,r,o.name,o.guid,t,"Prev:",n,"Now:",o,`
4431
4449
  --------------`),t[r]=o,o.needsUpdate=!0,t.needsUpdate=!0,ks){let a=oE.get(t);a||(a={},oE.set(t,a));let l=a[r];l||(l=a[r]={original:n,lod0:o}),l.lod0=o}return o}return null}))}afterRoot(i){var e;return ks&&console.log("AFTER",this.sourceId,i),(e=this.parser.json.textures)==null||e.forEach((t,s)=>{if(t!=null&&t.extensions){const r=t?.extensions[Gy];r&&this.parser.getDependency("texture",s).then(n=>{ks&&console.log("> Progressive: register",n.name,n.uuid,r),n.source&&(n.source[nE]=r),Hy.cache.set(n.uuid,r)})}}),null}static async getOrLoadTexture(i,e,t,s,r,n){const o=r.uuid;let a;if(r.source&&r.source[nE]&&(a=r.source[nE]),a||(a=Hy.cache.get(o)),a){ks&&console.log(o,a.uri,a.guid);const l=Ya(e,a.uri);if(l.endsWith(".glb")||l.endsWith(".gltf")){if(!a.guid)return console.warn("missing pointer for glb/gltf texture",a),null;const c=l+"_"+a.guid;if(this.resolved[c]){let d=this.resolved[c];if(d.image&&d.image.data)return ks&&console.log("Texture has already been loaded: "+c,t.name,s,r.name,d),d=this.copySettings(r,d),d;d&&ks&&console.log("Texture has been disposed, will load again: "+c,t.name,s,r.name,d)}const u=this.onProgressiveLoadStart(i,e,l,t,s);try{if(this.currentlyLoading[c]!==void 0){ks&&console.log("Already loading:",t.name+"."+s,c);let f=await this.currentlyLoading[c];return f&&(f=this.copySettings(r,f)),f}const d=a,p=new Promise(async(f,m)=>{var A;const v=new $d;Hm(v,i),ks&&console.warn("Start loading "+l,t.name,s,d.guid),ks&&await bf(Math.random()*1e3);const g=await v.loadAsync(l),b=g.parser;ks&&console.log("Loading finished "+l,t.name,s,d.guid);let y=-1,_=!1;if(!((A=g.parser.json)!=null&&A.textures))return ks&&console.warn("No textures in glTF "+l+" - may be a bug",t.name,s,d.guid),f(null);for(const M of g.parser.json.textures)if(y++,M!=null&&M.extensions){const I=M?.extensions[Gy];if(I!=null&&I.guid&&I.guid===d.guid){_=!0;break}}if(!_)return f(null);let S=await b.getDependency("texture",y);S=this.copySettings(r,S),S&&(S.guid=d.guid),this.resolved[c]=S,ks&&console.log(t.name,s,'change "'+r.name+'" \u2192 "'+S.name+'"',l,y,S,t,c),f(S)});return this.currentlyLoading[c]=p,await p}finally{delete this.currentlyLoading[c],this.onProgressiveLoadEnd(u)}}else{const c=this.onProgressiveLoadStart(i,e,l,t,s);try{ks&&console.log("Load texture from uri: "+l);const u=await new dl().loadAsync(l);return u?(u.guid=a.guid,u.flipY=!1,u.needsUpdate=!0,u.colorSpace=r.colorSpace,ks&&console.log(a,u)):ks&&console.warn("failed loading",l),u}finally{this.onProgressiveLoadEnd(c)}}}else ks&&console.warn("unknown texture",r.name,r.uuid,r);return null}static copySettings(i,e){const t=i.clone(),s=e.source,r=e.mipmaps;return t.copy(i),t.source=s,t.mipmaps=r,t}static beginListenStart(i,e){this._progressiveEventListeners.has(i)||this._progressiveEventListeners.set(i,new lU),this._progressiveEventListeners.get(i).start.push(e)}static stopListenStart(i,e){if(!this._progressiveEventListeners.has(i))return;const t=this._progressiveEventListeners.get(i).start,s=t.indexOf(e);s>=0&&t.splice(s,1)}static beginListenEnd(i,e){this._progressiveEventListeners.has(i)||this._progressiveEventListeners.set(i,new lU),this._progressiveEventListeners.get(i).end.push(e)}static stopListenEnd(i,e){if(!this._progressiveEventListeners.has(i))return;const t=this._progressiveEventListeners.get(i).end,s=t.indexOf(e);s>=0&&t.splice(s,1)}static onProgressiveLoadStart(i,e,t,s,r){this._currentProgressiveLoadingInfo.has(i)||this._currentProgressiveLoadingInfo.set(i,[]);const n=new aU(i,e,t,s,r),o=this._currentProgressiveLoadingInfo.get(i),a=this._progressiveEventListeners.get(i);return a&&a.onStart(n),o.push(n),n}static onProgressiveLoadEnd(i){if(!i)return;const e=i.context;if(!this._currentProgressiveLoadingInfo.has(e))return;const t=this._currentProgressiveLoadingInfo.get(e),s=t.indexOf(i);if(s<0)return;t.splice(s,1);const r=this._progressiveEventListeners.get(e);r&&r.onEnd(i)}};let jo=Hy;h(jo,"cache",new Map),h(jo,"resolved",{}),h(jo,"currentlyLoading",{}),h(jo,"_progressiveEventListeners",new Map),h(jo,"_currentProgressiveLoadingInfo",new Map);class aU{constructor(e,t,s,r,n){h(this,"context"),h(this,"source"),h(this,"uri"),h(this,"material"),h(this,"slot"),this.context=e,this.source=t,this.uri=s,this.material=r,this.slot=n}}class lU{constructor(){h(this,"start",[]),h(this,"end",[])}onStart(e){for(const t of this.start)t(e)}onEnd(e){for(const t of this.end)t(e)}}const g7=le("debugextensions");let Vy;const v7=Promise.resolve().then(()=>Qle).then(async i=>(Vy=i.GLTFAnimationPointerExtension,Vy)).catch(i=>{console.warn("Failed to import GLTFLoaderAnimationPointer. Please use @needle-tools/three for full KHR_animation support",i)}),Wm=new Array;function A7(i){Wm.includes(i)||(i.name||console.warn("Custom extension has no name",i),Wm.push(i))}function y7(i){const e=Wm.indexOf(i);e>=0&&Wm.splice(e,1)}function lE(i){const e=new rU;return i.register(t=>(e.parser=t,e)),e}class b7{resolvePath(e){return e.includes("/extensions/builtin_components/")?e.replace("/extensions/builtin_components/","/userData/components/"):e.includes("extensions/builtin_components/")?e.replace("extensions/builtin_components/","/userData/components/"):e}}async function cU(i,e,t){const s=t.lastIndexOf("?");s>=0&&(t=t.substring(0,s)),i.register(r=>new h7(r)),i.register(r=>new w6(r)),i.register(r=>new Gq(r,e.lightmaps,t)),i.register(r=>new u7(r,t,e)),i.register(r=>new n7(r,t)),i.register(r=>new sE(r,t)),i.register(r=>new jo(r,t,e)),i.register(r=>new c7(r)),sO()&&i.register(r=>new H1(r));for(const r of Wm)i.register(n=>new r(n));await v7.catch(r=>{}),i.register(r=>{if(Vy){const n=new Vy(r);return n.setAnimationPointerResolver.bind(n)(new b7),n}else return(g7||gi())&&console.error("Missing KHR_animation_pointer extension..."),{name:"KHR_animation_pointer_NOT_AVAILABLE"}})}const cE=le("debuglightmaps");class Xm{constructor(e,t){h(this,"lightmapIndex",-1),h(this,"lightmapScaleOffset",new it(1,1,0,0)),h(this,"context"),h(this,"gameObject"),h(this,"lightmapTexture",null),h(this,"lightmapScaleOffsetUniform",{value:new it(1,1,0,0)}),h(this,"lightmapUniform",{value:null}),h(this,"onBeforeCompile",(s,r)=>{cE&&console.log("Lightmaps, before compile",s),s.lightMapUv="uv1",this.lightmapScaleOffsetUniform.value=this.lightmapScaleOffset,this.lightmapUniform.value=this.lightmapTexture,s.uniforms.lightmapScaleOffset=this.lightmapScaleOffsetUniform}),this.gameObject=e,this.context=t}get lightmap(){return this.lightmapTexture}set lightmap(e){e!==this.lightmapTexture&&(this.lightmapTexture=e,this.applyLightmap())}init(e,t,s){console.assert(this.gameObject!==void 0&&this.gameObject!==null,"Missing gameobject",this),this.lightmapIndex=e,!(this.lightmapIndex<0)&&(this.lightmapScaleOffset=t,this.lightmapTexture=s,cE&&this.setLightmapDebugMaterial(),this.applyLightmap())}updateLightmapUniforms(e){const t=e.uniforms;t&&t.lightmap&&(this.lightmapScaleOffsetUniform.value=this.lightmapScaleOffset,t.lightmapScaleOffset=this.lightmapScaleOffsetUniform)}applyLightmap(){if(this.gameObject.type==="Object3D"){cE&&console.warn("Can not add lightmap. Is this object missing a renderer?",this.gameObject.name);return}if(this.gameObject.type==="Group"){console.warn("Lightmap on multimaterial object is not supported yet... please open a feature request on https://github.com/needle-tools/needle-engine-support if your project requires it");return}console.assert(this.gameObject.type==="Mesh","Lightmap only works on meshes",this);const e=this.gameObject;if(e.geometry.getAttribute("uv1")||e.geometry.setAttribute("uv1",e.geometry.getAttribute("uv")),Array.isArray(this.gameObject.material)){const t=this.gameObject.material;for(let s=0;s<t.length;s++){const r=t[s].clone();t[s]=r,r.onBeforeCompile=this.onBeforeCompile}}else{const t=this.gameObject.material.clone();this.gameObject.material=t,this.gameObject.material.onBeforeCompile=this.onBeforeCompile}if(this.lightmapIndex>=0&&this.lightmapTexture){const t=this.gameObject.material;t&&(t.lightMap=this.lightmapTexture,t.needsUpdate=!0)}}setLightmapDebugMaterial(){this.gameObject.material=new Dt({vertexShader:`
@@ -5051,7 +5069,7 @@ void main() {
5051
5069
  justify-content: center;
5052
5070
  align-items: flex-start;
5053
5071
  gap: 10px;
5054
- `,this.context.appendHTMLElement(t);const s=wM;wM&&console.log("ARSupported?",Ag,"VRSupported?",yg),(s||this.createARButton&&this.enableAR&&Ag)&&(i=Os.createARButton(this),this._arButton=i,t.appendChild(i)),(s||this.createVRButton&&this.enableVR&&yg)&&(e=Os.createVRButton(this),this._vrButton=e,t.appendChild(e)),setTimeout(()=>{Os.resetButtonStyles(e),Os.resetButtonStyles(i)},1e3)}get TransformOrientation(){return this._transformOrientation}get HeadPose(){return this._currentHeadPose}onBeforeRender(i){var e;if(!i)return;const t=this.context.renderer.xr.getSession();if(t){const s=i.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!s)return;this._currentHeadPose=s;const r=s?.transform;r&&this._transformOrientation.set(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w),Os._isInXr===!1&&t&&this.onEnterXR(t,i);for(const n of this.controllers)n.onUpdate(t);this._isInAR&&((e=this.webAR)==null||e.onUpdate(t,i))}Os.events.dispatchEvent({type:"xrUpdate",frame:i,xr:this.context.renderer.xr,rig:this.rig})}onClickedARButton(){this._isInAR||(this._requestedAR=!0,this._requestedVR=!1,this.captureStateBeforeXR())}onClickedVRButton(){if(!this._isInVR){if(this._requestedVR){this.onExitXR(null);return}this._requestedAR=!1,this._requestedVR=!0,this.captureStateBeforeXR(),this.ensureRig();for(let i=0;i<2;i++)bs.Create(this,i,this.gameObject,xp.PhysicalDevice);Os.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(At(this.context.mainCamera)),this._originalCameraRotation.copy(Bs(this.context.mainCamera)),this._originalCameraParent=this.context.mainCamera.parent),this.Rig&&(this._originalXRRigParent=this.Rig.parent,this._originalXRRigPosition.copy(this.Rig.position),this._originalXRRigRotation.copy(this.Rig.quaternion))}ensureRig(){if(!this.rig){const i=se.findObjectOfType(Ob,this.context);i?(this.rig=i.gameObject,this.rig.rotateY(Math.PI)):(this.rig=new Tn,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}onEnterXR(i,e){var t,s;console.log("[XR] session begin",i,e),Os._isInXr=!0,this.ensureRig();const r=this.context.renderer.xr.getReferenceSpace();if(r&&this.rig){const a=e.getViewerPose(r),l=a?.transform.orientation;if(l){const c=new Ee(l.x,l.y,l.z,l.w),u=new Es().setFromQuaternion(c);this.rig.rotateY(u.y)}}const n=this.context.renderer.xr;if(this.context.mainCamera){const a=n.getCamera();wM&&console.log("WebXRCamera",a);const l=(t=this.context.mainCameraComponent)==null?void 0:t.cullingMask;if(a&&l!==void 0){for(const c of a.cameras)c.layers.mask=l;a.layers.mask=l}else if(a){for(const c of a.cameras)c.layers.enableAll();a.layers.enableAll()}this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}const o=this._requestedAR?as.AR:as.VR;switch(kn.Global.Set(o),o){case as.AR:this.context.xrSessionMode=Nm.ImmersiveAR,this._isInAR=!0,(s=this.webAR)==null||s.onBegin(i);break;case as.VR:this.context.xrSessionMode=Nm.ImmersiveVR,this._isInVR=!0,this.onEnterVR(i);break}i.addEventListener("end",()=>{console.log("[XR] session end"),Os._isInXr=!1,this.onExitXR(i)}),this.onEnterXR_HandleMirrorWindow(i),Os.events.dispatchEvent({type:"xrStarted",session:i})}onExitXR(i){var e,t,s,r;const n=this._isInAR;i&&(this._isInAR?(e=this.webAR)==null||e.onEnd(i):(t=this.context.mainCameraComponent)==null||t.applyClearFlagsIfIsActiveCamera()),this._isInAR=!1,this._isInVR=!1,this._requestedAR=!1,this._requestedVR=!1,this.context.xrSessionMode=void 0,this.xrMirrorWindow&&(this.xrMirrorWindow.close(),this.xrMirrorWindow=null),this.destroyControllers(),this.context.mainCamera&&((s=this._originalCameraParent)==null||s.add(this.context.mainCamera),ns(this.context.mainCamera,this._originalCameraPosition),ln(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),n&&((r=this._originalXRRigParent)==null||r.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),kn.Global.Set(as.Browser|as.ThirdPerson),Os.events.dispatchEvent({type:"xrStopped",session:i})}onEnterVR(i){}destroyControllers(){var i;for(let e=this.controllers.length-1;e>=0;e-=1)(i=this.controllers[e])==null||i.destroy();this.controllers.length=0}onEnterXR_HandleMirrorWindow(i){le("mirror")&&setTimeout(()=>{if(!Os.IsInWebXR)return;const e=new URL(window.location.href);yf(e.searchParams,ab,1),yf(e.searchParams,"isMirror",1);const t=e.toString();this.xrMirrorWindow=window.open(t,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{Os.IsInWebXR&&i.end()})})},1e3)}},h(Cp,"_isInXr",!1),h(Cp,"events",new Ms),h(Cp,"_optionalFeatures_VR",["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]),h(Cp,"_optionalFeatures_AR",["anchors","local-floor","hand-tracking","layers"]),Cp);let Ct=Os;Sp([x()],Ct.prototype,"enableVR",2),Sp([x()],Ct.prototype,"enableAR",2),Sp([x(er)],Ct.prototype,"defaultAvatar",2),Sp([x()],Ct.prototype,"handModelPath",2),Sp([x()],Ct.prototype,"createVRButton",2),Sp([x()],Ct.prototype,"createARButton",2);const bg=class{constructor(i){h(this,"_webxr"),h(this,"reticle",null),h(this,"reticleParent",null),h(this,"hitTestSource",null),h(this,"reticleActive",!0),h(this,"previousBackground",null),h(this,"previousEnvironment",null),h(this,"sessionRoot",null),h(this,"_previousParent",null),h(this,"arDomOverlay",null),h(this,"arOverlayElement",null),h(this,"noHitTestAvailable",!1),h(this,"didPlaceARSessionRoot",!1),this._webxr=i}get webxr(){return this._webxr}get context(){return this.webxr.context}getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;const i=this.arDomOverlay;return i.getAROverlayContainer?this.arOverlayElement=i.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(i){this.reticleActive=i}async onBegin(i){var e,t,s,r;const n=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();const o=(e=navigator.userAgent)!=null&&e.includes("OculusBrowser")?xp.PhysicalDevice:xp.Touch,a=o===xp.Touch?4:2;for(let c=0;c<a;c++)bs.Create(this.webxr,c,this.webxr.gameObject,o);if((!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=se.findObjectOfType(xa,n)),!this.sessionRoot){const c=this.webxr.gameObject;this.sessionRoot=se.addNewComponent(c,xa),console.warn("WebAR: No ARSessionRoot found, creating one automatically on the WebXR object")}this.previousBackground=n.scene.background,this.previousEnvironment=n.scene.environment,n.scene.background=null,i.requestReferenceSpace("viewer").then(c=>{var u,d;(d=(u=i.requestHitTestSource)==null?void 0:u.call(i,{space:c}))==null||d.then(p=>{this.hitTestSource=p}).catch(p=>{this.noHitTestAvailable=!0,console.warn("WebXR: Hit test not supported",p)})}),!this.reticle&&this.sessionRoot&&(this.reticle=new ye(new Gv(.07,.09,32).rotateX(-Math.PI/2),new li),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new Re,this.reticleParent.name="AR Reticle Parent",this.reticleParent.matrixAutoUpdate=!1,this.reticleParent.add(this.reticle),this.webxr.scene?(this.context.scene.add(this.reticleParent),this.context.scene.visible=!0):console.warn("Could not found WebXR Rig")),this._previousParent=this.webxr.gameObject,bg.tempWebXRObject||(bg.tempWebXRObject=new Re),this.context.scene.add(bg.tempWebXRObject),se.addComponent(bg.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,(t=this.sessionRoot)==null||t.onBegin(i)):console.warn("No WebARSessionRoot found in scene");const l=this.context.domElement;(s=l?.onEnterAR)==null||s.call(l,i,this.arOverlayElement),(r=this.context.mainCameraComponent)==null||r.applyClearFlagsIfIsActiveCamera()}onEnd(i){var e,t;this._previousParent&&(se.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;const s=this.webxr.context;s.scene.background=this.previousBackground,s.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,i);const r=this.context.domElement;(e=r.onExitAR)==null||e.call(r,i),(t=this.context.mainCameraComponent)==null||t.applyClearFlagsIfIsActiveCamera()}onUpdate(i,e){var t,s;if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;const n=this.webxr.Rig,o=Mte.clone();(t=this.sessionRoot)==null||t.placeAt(n,o)}return}if(!this.hitTestSource)return;const r=e.getHitTestResults(this.hitTestSource);if(r.length){const n=r[0],o=this.webxr.context.renderer.xr.getReferenceSpace();if(o){const a=n.getPose(o);if(this.sessionRoot){const l=this.sessionRoot.onUpdate(this.webxr.Rig,i,a);this.didPlaceARSessionRoot=l}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&a)){const l=a.transform.matrix;this.reticle.matrix.fromArray(l),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else(s=this.sessionRoot)==null||s.onUpdate(this.webxr.Rig,i,null),this.reticle&&(this.reticle.visible=!1)}};let _g=bg;h(_g,"tempWebXRObject");const Mte=new Be().identity().makeTranslation(0,0,0);class oc{constructor(e,t){h(this,"used",!1),h(this,"positionDelta",new ee),h(this,"inputSource"),h(this,"object"),h(this,"pointerId"),h(this,"isDown"),h(this,"isUp"),h(this,"isPressed"),h(this,"isClicked"),h(this,"input"),h(this,"event"),this.event=t,this.input=e}use(){this.used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId)}stopPropagation(){var e;(e=this.event)==null||e.stopImmediatePropagation()}Use(){this.use()}StopPropagation(){var e;(e=this.event)==null||e.stopImmediatePropagation()}clone(){const e=new oc(this.input,this.event);return Object.assign(e,this),e}}class Ep extends Ie{awake(){Un.createIfNoneExists(this.context)}onEnable(){var e;(e=Un.get(this.context))==null||e.register(this)}onDisable(){var e;(e=Un.get(this.context))==null||e.unregister(this)}performRaycast(e=null){return null}}class zl extends Ep{constructor(){super(...arguments),h(this,"targets",null),h(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(e=null){return this.targets?(e??(e=new ko),e.targets=this.targets,e.results=this.raycastHits,this.context.physics.raycast(e)):null}}class SM extends zl{}const xg=le("debugeventsystem");var CM=(i=>(i.BeforeHandleInput="BeforeHandleInput",i.AfterHandleInput="AfterHandleInput",i))(CM||{});const jl=class extends Ie{constructor(){super(),h(this,"raycaster",[]),h(this,"_selectStartFn"),h(this,"_selectEndFn"),h(this,"_selectUpdateFn"),h(this,"_handleEventFn"),h(this,"lastPointerEvent",null),h(this,"objectsHoveredThisFrame",[]),h(this,"objectsHoveredLastFrame",[]),h(this,"raisedPointerDownEvents",[]),h(this,"raisedPointerDownObjects",[]),h(this,"_didMove",!1),h(this,"_tempComponentsArray",[]),h(this,"_sortedHits",[]),h(this,"_sortingBuffer",[]),h(this,"_noDepthTestingResults",[]),h(this,"handleEventsArray",[]),h(this,"out",{}),h(this,"currentActiveMeshUIComponents",[]),jl.systems.push(this)}static createIfNoneExists(i){this.didSearchEventSystem||(this.didSearchEventSystem=!0,jl.systems.length<=0&&jl.systems.push(...se.findObjectsOfType(jl,i)));for(const t of jl.systems)if(t.context===i)return;const e=new Re;se.addNewComponent(e,jl),i.scene.add(e)}static get systems(){const i=zt.Current;return this._eventSystemMap.has(i)||this._eventSystemMap.set(i,[]),this._eventSystemMap.get(i)}static get(i){const e=this._eventSystemMap.get(i);return e&&e.length>0?e[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(i,e){Ql.update(i,e)}static markUIDirty(i){Ql.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.objectsHoveredThisFrame.length>0}onDestroy(){jl.systems.splice(jl.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!se.findObjectOfType(Ep,this.context)){const i=se.addNewComponent(this.context.scene,zl);this.raycaster.push(i),gi()&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found",this)}}register(i){var e;i&&this.raycaster&&!this.raycaster.includes(i)&&((e=this.raycaster)==null||e.push(i))}unregister(i){var e,t;const s=(e=this.raycaster)==null?void 0:e.indexOf(i);s!==void 0&&s!==-1&&((t=this.raycaster)==null||t.splice(s,1))}onEnable(){const i=new Map;this._selectStartFn??(this._selectStartFn=(t,s)=>{if(!s.grab)return;Ql.resetLastSelected();const r=new oc(this.context.input);r.inputSource=t,r.pointerId=0,r.isDown=t.selectionDown,r.isUp=t.selectionUp,r.isPressed=t.selectionPressed,r.isClicked=!1,i.set(t,s.grab),s.grab&&!this.handleEvents(s.grab,r)&&(s.grab=null)}),this._selectEndFn??(this._selectEndFn=(t,s)=>{var r;if(!s.grab)return;const n=new oc(this.context.input);n.inputSource=t,n.pointerId=0,n.isDown=t.selectionDown,n.isUp=t.selectionUp,n.isPressed=t.selectionPressed,n.isClicked=t.selectionClick,this.handleEvents(s.grab,n);const o=i.get(t);if(i.set(t,null),o)for(let a=0;a<this.raisedPointerDownEvents.length;a++){const l=this.raisedPointerDownEvents[a];this.raisedPointerDownObjects[a]===o&&l&&((r=l.onPointerUp)==null||r.call(l,n),this.raisedPointerDownEvents.splice(a,1),this.raisedPointerDownObjects.splice(a,1),a--)}});const e=new ko;this._selectUpdateFn??(this._selectUpdateFn=t=>{e.ray=t.getRay();const s=this.performRaycast(e);if(!s)return;const r=new oc(this.context.input);r.inputSource=t,this.handleIntersections(s,r)}),bs.addEventListener(Fl.SelectStart,this._selectStartFn),bs.addEventListener(Fl.SelectEnd,this._selectEndFn),bs.addEventListener(Fl.Update,this._selectUpdateFn),this._handleEventFn??(this._handleEventFn=this.onHandleEvents.bind(this)),this.context.pre_update_callbacks.push(this._handleEventFn)}onDisable(){bs.removeEventListener(Fl.SelectStart,this._selectStartFn),bs.removeEventListener(Fl.SelectEnd,this._selectEndFn),bs.removeEventListener(Fl.Update,this._selectUpdateFn),this.context.pre_update_callbacks.splice(this.context.pre_update_callbacks.indexOf(this._handleEventFn),1)}onHandleEvents(){if(this.objectsHoveredThisFrame.length=0,this.resetMeshUIStates(),Ct.IsInWebXR||this.context.input.isKeyPressed("AltLeft")||this.context.input.isKeyPressed("AltRight"))return;if(!this._didMove){const o=this.context.input.getPointerPositionRC(0);if(o&&o.x===0&&o.y===0)return;this._didMove=!0}let i=0;for(const o of this.context.input.foreachPointerId()){const a=this.context.input.getPointerDown(o),l=this.context.input.getPointerUp(o);if(a||l){i=o;break}}const e=this.context.input.getPointerEvent(i),t=new oc(this.context.input,e);t.inputSource=this.context.input,t.pointerId=i,t.isClicked=this.context.input.getPointerClicked(i),t.isDown=this.context.input.getPointerDown(i),t.isUp=this.context.input.getPointerUp(i),t.isPressed=this.context.input.getPointerPressed(i);const s=this.context.input.getPointerPositionDelta(i);if(s&&t.positionDelta.copy(s),xg&&t.isClicked&&console.log("CLICK",i),!t.isDown&&!t.isUp&&!t.isClicked&&!t.isPressed&&!t.positionDelta.x&&!t.positionDelta.y){this.objectsHoveredThisFrame.length=0,this.objectsHoveredThisFrame.push(...this.objectsHoveredLastFrame);return}const r=this.performRaycast(null);if(!r)return;this.lastPointerEvent=t;const n={sender:this,args:t,hasActiveUI:this.currentActiveMeshUIComponents.length>0};xg&&t.isClicked&&fs("EventSystem: "+t.pointerId+" - "+this.context.time.frame+" - Up:"+t.isUp+", Down:"+t.isDown),this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:n})),this.handleIntersections(r,t),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:n}))}onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(const e of this.raisedPointerDownEvents)e.onPointerUp&&e.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(const e of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(e)<0){this._tempComponentsArray.length=0;const t=se.getComponentsInParent(e,Ie,this._tempComponentsArray);this.lastPointerEvent.object=e;for(let s=0;s<t.length;s++){const r=t[s];if(!r.gameObject||r.destroyed)continue;const n=r;n.onPointerExit&&n.onPointerExit(this.lastPointerEvent)}}const i=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=i}performRaycast(i){if(!this.raycaster)return null;this._sortedHits.length=0;for(const e of this.raycaster){if(!e.activeAndEnabled)continue;const t=e.performRaycast(i);t&&t.length>0&&this._sortedHits.push(...t)}return this._sortedHits.sort((e,t)=>e.distance-t.distance),this._sortedHits}handleIntersections(i,e){if(!i||i.length<=0)return!1;i=this.sortCandidates(i);for(const t of i){const{object:s}=t;if(this.handleEvents(s,e))return!0}return!1}sortCandidates(i){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let e=0;e<i.length;e++){const t=i[e],s=t.object;if(s.material&&s.material.depthTest===!1){this._noDepthTestingResults.push(t);continue}this._sortingBuffer.push(t)}for(const e of this._sortingBuffer)this._noDepthTestingResults.push(e);return this._noDepthTestingResults}handleEvents(i,e){if(!this.testIsVisible(i))return e.isClicked&&xg&&console.log("not allowed",i),!1;const t=i;e.object=i,this.lastPointerEvent=e;const s=i.parent;let r=!1;const n=e.isClicked??!1;let o=null;if(s&&s.isUI){const a=(e.isPressed||e.isClicked)??!1;if(s[Ma]){const l=s[Ma].gameObject;if(l){if(!_p.isInteractable(l,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(i,a),i=l,r=!0}}if(!r&&this.handleMeshUiObjectWithoutShadowDom(s,a))return!0}if(n&&xg&&console.log(this.context.time.frame,i),this.objectsHoveredThisFrame.push(i),o===null||o.interactable){const a=this.objectsHoveredLastFrame.indexOf(i)>=0;this.handleEventsArray.length=0;const l=se.getComponentsInParent(i,Ie,this.handleEventsArray);for(let c=0;c<l.length;c++){if(e.used)return!0;if(l[c].destroyed)continue;const u=l[c];if(u.interactable!==!1){if(u.onPointerEnter&&(a||u.onPointerEnter(e)),u.onPointerMove&&e.positionDelta.x!==0&&e.positionDelta.y!==0&&u.onPointerMove(e),e.isDown&&u.onPointerDown&&!this.raisedPointerDownEvents.includes(u)&&(u.onPointerDown(e),this.raisedPointerDownEvents.push(u),this.raisedPointerDownObjects.push(t)),e.isUp&&u.onPointerUp){const d=this.raisedPointerDownEvents.indexOf(u);d!==-1&&this.raisedPointerDownEvents.splice(d,1),u.onPointerUp(e)}e.isClicked&&u.onPointerClick&&u.onPointerClick(e)}}}return!0}handleMeshUiObjectWithoutShadowDom(i,e){return!i||!i.isUI?!0:this.handleMeshUIIntersection(i,e)}handleMeshUIIntersection(i,e){const t=Ql.updateState(i,e);return t&&this.currentActiveMeshUIComponents.push(t),t!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Ql.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let i=0;i<this.currentActiveMeshUIComponents.length;i++){const e=this.currentActiveMeshUIComponents[i];Ql.resetState(e)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(i){return i?se.isActiveSelf(i)?this.testIsVisible(i.parent):!1:!0}};let Un=jl;h(Un,"_eventSystemMap",new Map),h(Un,"didSearchEventSystem",!1);class Ql{static markDirty(){this.needsUpdate=!0}static update(e,t){const s=t.time.frameCount;for(const r of this.lastUpdateFrame)if(r.context===t){if(s===r.frame)return;r.frame=s;let n=this.needsUpdate||s<1;r.nextUpdate===t.time.frameCount&&(n=!0),n&&(xg&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:s,nextUpdate:s}],e.update()}static updateState(e,t){let s=null;if(e&&(s=this.findBlockInParent(e),s&&s!==this.lastSelected)){if(s.interactable===!1)return null;this.needsUpdate=!0}return s}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}h(Ql,"lastSelected",null),h(Ql,"lastUpdateFrame",[]),h(Ql,"needsUpdate",!1);const Ub=Symbol("cameraController");function Tte(i){return i[Ub]}function VN(i,e,t){t?i[Ub]=e:i[Ub]===e&&(i[Ub]=null)}function Fb(i){return i[Ma]||(i.parent?Fb(i.parent):null)}function Nb(i,e){if(!i)return;const t=i.material;if(t?.isMaterial===!0){const s=i.parent;s&&s.isText,t.side=e.doubleSided??!0?_i:gr,t.shadowSide=e.doubleSided?_i:gr,i.castShadow=e.castShadows?e.castShadows:!1,i.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const s of i.children)Nb(s,e)}function Mp(i,e,t){i[e]===void 0&&console.warn("Field",e,"is undefined on",i);const s=Proxy.revocable(i[e],{set(o,a,l,c){const u=o[a],d=Reflect.set(o,a,l,c);return t(l,u),d}}),r=s.revoke,n=i[e];return s.revoke=()=>{i[e]=n,r()},i[e]=s.proxy,s}const WN=Symbol("Scheduled action");function Ite(i,e,t=dn.OnBeforeRender){let s=i[WN];s||(s=i[WN]={});const r=e.name;s[t]||(s[t]={});const n=s[t];if(n[r])return;function*o(){e?.call(i),n[r]=null}const a=i.startCoroutine(o(),t);n[r]=a}var Rte=Object.defineProperty,Pte=Object.getOwnPropertyDescriptor,Bte=(i,e,t,s)=>{for(var r=s>1?void 0:s?Pte(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Rte(e,t,r),r};const zb=le("freecam"),EM=le("debugcamerafit"),kte={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let MM;class Gl extends Ie{constructor(){super(...arguments),h(this,"autoRotate",!1),h(this,"autoRotateSpeed",1),h(this,"enableKeys",!0),h(this,"enableDamping",!0),h(this,"dampingFactor",.1),h(this,"enableZoom",!0),h(this,"minZoom",0),h(this,"maxZoom",1/0),h(this,"enablePan",!0),h(this,"lookAtConstraint",null),h(this,"lookAtConstraint01",1),h(this,"middleClickToFocus",!0),h(this,"doubleClickToFocus",!0),h(this,"useSlerp",!0),h(this,"debugLog",!1),h(this,"targetLerpSpeed",5),h(this,"autoTarget",!0),h(this,"_lookTargetPosition"),h(this,"_controls",null),h(this,"_cameraObject",null),h(this,"_lerpToTargetPosition",!1),h(this,"_lerpCameraToTarget",!1),h(this,"_cameraTargetPosition",null),h(this,"_inputs",0),h(this,"_enableTime",0),h(this,"_startedListeningToKeyEvents",!1),h(this,"_eventSystem"),h(this,"_afterHandleInputFn"),h(this,"_camera",null),h(this,"_syncedTransform"),h(this,"targetElement",null),h(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),h(this,"_shouldDisable",!1),h(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}awake(){this._lookTargetPosition=new w,this._startedListeningToKeyEvents=!1}start(){if(this.autoTarget){if(this._controls){const e=se.getComponent(this.gameObject,Ri);if(e&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const t=At(e.cam).length(),s=new w(0,0,-t).applyMatrix4(e.cam.matrixWorld);this.setTarget(s,!0)}}this.startCoroutine(this.startRaycastDelayed())}this._eventSystem=Un.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(CM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(CM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=se.getComponent(this.gameObject,Ri);this._camera=e;const t=e?.cam;if(t&&VN(t,this,!0),!this._controls){if(!t){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}t&&(this._cameraObject=t);const s=this.targetElement??this.context.domElement,r=t?.quaternion.clone();this._controls=new TK(t,s),t?.quaternion.copy(r),MM===void 0&&(MM={...this._controls.keys})}this._controls&&(zb&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,Ka()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),t?.type==="PerspectiveCamera"?zb||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):zb||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=se.getComponent(this.gameObject,Yc)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&VN(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}*startRaycastDelayed(){if(yield,this.autoTarget&&!this.setFromTargetPosition()){const e=new ko;e.screenPoint=new ee(0,0),e.lineThreshold=.1;const t=this.context.physics.raycast(e);t.length>0&&this.setTarget(t[0].point,!0)}}onBeforeRender(){var e,t,s;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(0)||this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2))&&(this._inputs+=1),this._inputs>0&&(this.autoRotate=!1,this._controls.autoRotate=!1,this._lerpCameraToTarget=!1,this._lerpToTargetPosition=!1),this._inputs=0;let r=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(r||(r=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),r?this.setTargetFromRaycast():(this.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const n=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const o=(e=this._cameraObject)==null?void 0:e.position;Wk(o,this._cameraTargetPosition,n)}else(t=this._cameraObject)==null||t.position.lerp(this._cameraTargetPosition,n);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,n),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}!zb&&(s=this.lookAtConstraint)!=null&&s.locked&&this.setFromTargetPosition(0,this.lookAtConstraint01),this._controls&&(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.enableDamping=this.enableDamping,this._controls.keys=this.enableKeys?MM:kte,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this.context.isInXR||this._controls.update())}setCameraTarget(e,t=!1){var s;e?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=e.clone(),t&&this._cameraTargetPosition&&((s=this.controllerObject)==null||s.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(e=0,t=1){var s;if(!this._controls)return!1;const r=(s=this.lookAtConstraint)==null?void 0:s.sources;if(r&&r.length>0){const n=r[e];if(n)return n.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,t),!0}return!1}setTarget(e=null,t=!1){this._controls&&(e!==null&&this._lookTargetPosition.copy(e),t?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(e,t){this._controls&&this._controls.target.lerp(e,t)}distanceToTarget(e){return this._controls?this._controls.target.distanceTo(e):-1}setTargetFromRaycast(){var e,t;if(!this.controls)return;const s=this.context.physics.raycast();for(const r of s)if(r.distance>0&&se.isActiveInHierarchy(r.object)){const n=Fb(r.object);if(n){const o=n.canvas;if(o!=null&&o.screenspace)break}if(this._lookTargetPosition.copy(r.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const o=At(this.context.mainCamera);this._cameraTargetPosition=o.clone().sub(this.controls.target).add(this._lookTargetPosition),(t=(e=this._cameraObject)==null?void 0:e.parent)==null||t.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(e,t=1.1){const s=this._cameraObject,r=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0||!s||!r)return;const n=new w,o=new w,a=new Ts;a.makeEmpty();for(const A of e)A instanceof t1||A instanceof e1||(A.updateMatrixWorld(),a.expandByObject(A,!0));if(s.updateMatrixWorld(),s.updateProjectionMatrix(),a.getCenter(o),a.applyMatrix4(s.matrixWorldInverse),a.getSize(n),a.setFromCenterAndSize(o,n),n.length()<=1e-10){EM&&console.warn("Camera fit size is zero",a,[...e]);return}const l=s.fov,c=2*Math.atan(Math.tan(l*Math.PI/360/2)*s.aspect)/Math.PI*360,u=n.y/(2*Math.atan(Math.PI*l/360)),d=n.x/(2*Math.atan(Math.PI*c/360)),p=t*Math.max(u,d)+n.z/2;EM&&console.log("Fit camera to objects",u,d,"distance",p);const f=At(s),m=r.target.clone().sub(f).normalize().multiplyScalar(p);if(r.maxDistance=p*10,r.minDistance=p*.01,this.setTarget(o,!0),this.autoTarget=!1,s.near=p/100,s.far=p*100,s.updateMatrixWorld(),s.updateProjectionMatrix(),ns(s,r.target.clone().sub(m)),EM){const A=new t1(a);this.context.scene.add(A),e2(A,N0(s)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",v=>{v.code==="KeyF"&&this.fitCamera(e)}))}r.update()}}Bte([x($m)],Gl.prototype,"lookAtConstraint",2);var Dte=Object.defineProperty,Ote=Object.getOwnPropertyDescriptor,Fn=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ote(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Dte(e,t,r),r},XN=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(XN||{});const wg=le("debugcam"),qN=le("debugscreenpointtoray");var jb;const Sg=(jb=class extends Ie{constructor(){super(...arguments),h(this,"_nearClipPlane",.1),h(this,"_farClipPlane",1e3),h(this,"orthographic",!1),h(this,"orthographicSize",5),h(this,"ARBackgroundAlpha",0),h(this,"_cullingMask",4294967295),h(this,"_backgroundBlurriness"),h(this,"_backgroundIntensity"),h(this,"_environmentIntensity"),h(this,"_targetTexture",null),h(this,"_backgroundColor"),h(this,"_fov"),h(this,"_cam",null),h(this,"_clearFlags",2),h(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof qt?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof qt?this._cam.fov:this._fov}set fieldOfView(i){const e=this.fieldOfView!=i;if(this._fov=i,e&&this._cam&&this._cam instanceof qt){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(i){const e=this._nearClipPlane!=i;this._nearClipPlane=i,this._cam&&e&&(this._cam.near=i,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(i){const e=this._farClipPlane!=i;this._farClipPlane=i,this._cam&&e&&(this._cam.far=i,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(i){i!==this._clearFlags&&(this._clearFlags=i,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(i){this._cullingMask=i,this._cam&&(this._cam.layers.mask=i)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set backgroundBlurriness(i){i!==this._backgroundBlurriness&&(i===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(i,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(i){i!==this._backgroundIntensity&&(i===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(i,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(i){this._environmentIntensity=i}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(i){if(i){if(this._backgroundColor)this._backgroundColor.copy(i);else{if(!i.clone)return;this._backgroundColor=i.clone()}i.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(i){this._targetTexture=i}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(i,e,t){const s=this.cam,r=Sg._origin;r.set(i,e,-1),this.context.input.convertScreenspaceToRaycastSpace(r),qN&&console.log("screenPointToRay",i.toFixed(2),e.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const n=Sg._direction.set(r.x,r.y,r.z),o=At(s);return n.sub(o),n.normalize(),t?(t.set(o,n),t):new ha(o.clone(),n.clone())}awake(){qN&&window.addEventListener("pointerdown",i=>{const e=i.clientX,t=i.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const s=this.screenPointToRay(e,t),r="#"+Math.floor(Math.random()*16777215).toString(16);Ml.DrawRay(s.origin,s.direction,r,10)})}onEnable(){wg&&console.log(this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),Ute(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&this._targetTexture){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const i=this.context.renderer;if(i){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,i),e?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const i=this.gameObject.isCamera;let e=null;if(i?(e=this.gameObject,e?.layers.enableAll(),e instanceof qt&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof qt&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new qt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new kh(window.innerWidth/-t,window.innerWidth/t,window.innerHeight/t,window.innerHeight/-t,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){wg&&console.log("Camera does not exist (apply clear flags)");return}switch(this.fieldOfView=this._fov,wg&&fs("apply Camera clear flags: "+this._clearFlags),this._clearFlags){case 1:if(Sg.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let i=this._backgroundColor.alpha;Sg.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,i)}break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new Lte(this)),this._skybox.enable()}static backgroundShouldBeTransparent(i){var e,t,s,r;const n=(e=i.renderer.xr)==null?void 0:e.getSession();if(!n)return!1;const o=n.environmentBlendMode;wg&&fs("Environment blend mode: "+o+" on "+navigator.userAgent);const a=o==="additive"||o==="alpha-blend";return i.xrSessionMode===Nm.ImmersiveAR&&o==="opaque"&&((t=navigator.userAgent)!=null&&t.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&(r=navigator.userAgent)!=null&&r.includes("Mobile WebXRViewer/v2"))?!0:a}},h(jb,"_origin",new w),h(jb,"_direction",new w),jb);let Ri=Sg;Fn([x()],Ri.prototype,"fieldOfView",1),Fn([x()],Ri.prototype,"nearClipPlane",1),Fn([x()],Ri.prototype,"farClipPlane",1),Fn([x()],Ri.prototype,"clearFlags",1),Fn([x()],Ri.prototype,"orthographic",2),Fn([x()],Ri.prototype,"orthographicSize",2),Fn([x()],Ri.prototype,"ARBackgroundAlpha",2),Fn([x()],Ri.prototype,"cullingMask",1),Fn([x()],Ri.prototype,"backgroundBlurriness",1),Fn([x()],Ri.prototype,"backgroundIntensity",1),Fn([x()],Ri.prototype,"environmentIntensity",1),Fn([x(Ai)],Ri.prototype,"backgroundColor",1),Fn([x(np)],Ri.prototype,"targetTexture",1);class Lte{constructor(e){h(this,"_camera"),h(this,"_skybox"),this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(wg&&console.log("Set skybox",this._camera,this._skybox),this._skybox.colorSpace=et,this._skybox.mapping=Yn,this.context.scene.background=this._skybox):console.warn("Failed to load/find skybox texture",this._camera.sourceId,this.context.lightmaps)}}function Ute(i){le("freecam")&&i.context.mainCameraComponent===i&&se.getOrAddComponent(i.gameObject,Gl)}class Tp extends Ie{constructor(){super(...arguments),h(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new qS),this._listener}awake(){As.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=this.context.mainCameraComponent||se.getComponentInParent(this.gameObject,Ri);t!=null&&t.cam?t.cam.add(e):this.gameObject.add(e)})}}var Fte=Object.defineProperty,Nte=Object.getOwnPropertyDescriptor,Qb=(i,e,t,s)=>{for(var r=s>1?void 0:s?Nte(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Fte(e,t,r),r};const zte=le("debugsignals");class Cg{constructor(){h(this,"guid")}}Qb([x()],Cg.prototype,"guid",2);class Ip{constructor(){h(this,"signal"),h(this,"reaction")}}Qb([x(Cg)],Ip.prototype,"signal",2),Qb([x(ir)],Ip.prototype,"reaction",2);var TM;const Hl=(TM=class extends Ie{constructor(){super(...arguments),h(this,"events")}static invoke(i){if(Hl.receivers[i]){const e=Hl.receivers[i];if(!e)return;for(const t of e)t.invoke(i)}}awake(){zte&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const i of this.events)Hl.receivers[i.signal.guid]||(Hl.receivers[i.signal.guid]=[]),Hl.receivers[i.signal.guid].push(this)}onDisable(){if(this.events){for(const i of this.events)if(Hl.receivers[i.signal.guid]){const e=Hl.receivers[i.signal.guid].indexOf(this);e>=0&&Hl.receivers[i.signal.guid].splice(e,1)}}}invoke(i){if(!this.events||!Array.isArray(this.events))return;const e=typeof i=="object"?i.guid:i;for(const t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(s){console.error(s)}}},h(TM,"receivers",{}),TM);let Rp=Hl;Qb([x(Ip)],Rp.prototype,"events",2);var Nn=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(Nn||{}),Ia=(i=>(i[i.None=0]="None",i[i.Hold=1]="Hold",i[i.Loop=2]="Loop",i[i.PingPong=3]="PingPong",i[i.Continue=4]="Continue",i))(Ia||{}),IM=(i=>(i.Signal="SignalEmitter",i))(IM||{});const Pp=le("debugtimeline"),RM=class extends Ie{constructor(){super(...arguments),h(this,"playableAsset"),h(this,"playOnAwake"),h(this,"extrapolationMode",1),h(this,"waitForAudio",!0),h(this,"_visibilityChangeEvt"),h(this,"_clonedPlayableAsset",!1),h(this,"_speed",1),h(this,"_guidsMap"),h(this,"_isPlaying",!1),h(this,"_internalUpdateRoutine"),h(this,"_isPaused",!1),h(this,"_isStopping",!1),h(this,"_time",0),h(this,"_duration",0),h(this,"_weight",1),h(this,"_animationTracks",[]),h(this,"_audioTracks",[]),h(this,"_signalTracks",[]),h(this,"_controlTracks",[]),h(this,"_customTracks",[]),h(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),h(this,"animationCallbackReceivers",[])}static registerCreateTrack(i,e){this.createTrackFunctions[i]=e}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(i){typeof i=="number"&&!Number.isNaN(i)?this._time=i:(Pp||Br())&&console.error("INVALID TIMELINE.TIME VALUE",i,this.name)}get duration(){return this._duration}set duration(i){this._duration=i}get weight(){return this._weight}set weight(i){this._weight=i}get speed(){return this._speed}set speed(i){this._speed=i}awake(){var i,e,t;Pp&&console.log(this,(i=this.playableAsset)==null?void 0:i.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(e=this.playableAsset)==null?void 0:e.tracks,Array.isArray((t=this.playableAsset)==null?void 0:t.tracks),this)}onEnable(){var i,e,t;for(const s of this._audioTracks)(i=s.onEnable)==null||i.call(s);for(const s of this._customTracks)(e=s.onEnable)==null||e.call(s);for(const s of this._animationTracks)(t=s.onEnable)==null||t.call(s);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var i,e,t;this.stop();for(const s of this._audioTracks)(i=s.onDisable)==null||i.call(s);for(const s of this._customTracks)(e=s.onDisable)==null||e.call(s);for(const s of this._animationTracks)(t=s.onDisable)==null||t.call(s);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var i;for(const e of this._allTracks)for(const t of e)(i=t.onDestroy)==null||i.call(t)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const i=this._isPaused==!0;if(this._isPaused=!1,i&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const e=[];for(const t of this._audioTracks){const s=t.loadAudio(this._time,1,0);s&&e.push(s)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!As.userInteractionRegistered&&this.waitForAudio;)await bf(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),dn.OnBeforeRender)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.evaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const t of this._audioTracks)t.stop();const i=this._isPaused==!0,e=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),i&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,i&&!e&&this.invokePauseChangedMethodsOnTracks(),e&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){if(!this.isValid())return;let i=this._time;switch(this.extrapolationMode){case 0:this._speed>0?i=Math.min(i,this._duration):this._speed<0&&(i=Math.max(i,0)),this._time=i;break;case 1:i%=this._duration,this._time=i;break;case 2:if(i>this._duration){this.stop();return}break}this.internalEvaluate(i)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const i of this._allTracks)for(const e of i)yield e}get audioTracks(){return this._audioTracks}resolveGuids(i){this._guidsMap=i}invokePauseChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onPauseChanged)==null||i.call(e)}invokeStateChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onStateChanged)==null||i.call(e,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(i){for(const e of this.playableAsset.tracks)if(!e.muted)switch(e.type){case Nn.Activation:if(!this._isPlaying)continue;for(let t=0;t<e.outputs.length;t++){const s=e.outputs[t];if(typeof s=="object"){let r=!1;for(const o of e.clips)o.start<=i&&i<=o.end&&(r=!0);const n=s;n.visible!==void 0&&n.visible!==r&&(n.visible=r,Pp&&console.warn(this.name,"set ActivationTrack-"+t,n.name,r,i))}}break}if(!this._isStopping)for(const e of this._animationTracks)e.evaluate(i);for(const e of this._audioTracks)e.evaluate(i);for(const e of this._signalTracks)e.evaluate(i);for(const e of this._controlTracks)e.evaluate(i);for(const e of this._customTracks)e.evaluate(i)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Zv(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const i=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let t=e.outputs.length-1;t>=0;t--){let s=e.outputs[t];if(typeof s=="string"){this._guidsMap&&this._guidsMap[s]&&(s=this._guidsMap[s]);const r=se.findByGuid(s,i);r===null||typeof r!="object"?(e.outputs.splice(t,1),console.warn("Failed to resolve binding",s,e.name,e.type)):(Pp&&console.log("Resolved binding",s,"to",r),e.outputs[t]=r)}else if(s===null){if(e.outputs.splice(t,1),RM.createTrackFunctions[e.type])continue;e.type!==Nn.Audio&&e.type!==Nn.Control&&e.type!==Nn.Marker&&e.type!==Nn.Signal&&console.warn("Missing binding",s,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===Nn.Control)for(let t=0;t<e.clips.length;t++){const s=e.clips[t];let r=s.asset.sourceObject;if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const n=se.findByGuid(r,i);n===null||typeof n!="object"?console.warn("Failed to resolve sourceObject binding",r,e.name,s):(Pp&&console.log("Resolved binding",r,"to",n),s.asset.sourceObject=n)}}}}findRoot(i){return i.parent?this.findRoot(i.parent):i}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const i of this.playableAsset.tracks)if(i.muted!==!0){for(const e of i.clips)e.end>this._duration&&(this._duration=e.end);for(const e of i.markers)e.time>this._duration&&(this._duration=e.time+.001)}}}setupAndCreateTrackHandlers(){var i,e;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const t=se.findObjectOfType(Tp,this.context);for(const s of this.playableAsset.tracks){const r=s.type,n=RM.createTrackFunctions[r];if(n!=null){const o=n(this,s);if(typeof o.evaluate=="function"){o.director=this,o.track=s,this._customTracks.push(o);continue}}if(s.type===Nn.Animation){if(s.clips.length<=0){Pp&&console.warn("Animation track has no clips",s);continue}for(let o=s.outputs.length-1;o>=0;o--){let a=s.outputs[o];if(a instanceof Re){const c=se.getOrAddComponent(a,Cr);c&&(a=c)}const l=(i=a?.gameObject)==null?void 0:i.animations;if(l){const c=new Gb;c.trackOffset=s.trackOffset,c.director=this,c.track=s;for(let u=0;u<s.clips.length;u++){const d=s.clips[u],p=d.asset;if(!p){console.error("MISSING anim model?","clip#"+u,d,s,this.playableAsset,this.name);continue}const f=p.clip;let m=f;if((typeof m=="string"||typeof m=="number")&&(m=l.find(v=>v.name===f)),!m){console.warn("Could not find animationClip for model",d,s.name,this.name,(e=this.playableAsset)==null?void 0:e.name);continue}a instanceof Cr&&a.runtimeAnimatorController&&(a.__internalDidAwakeAndStart||a.initializeRuntimeAnimatorController(),a.runtimeAnimatorController.mixer||a.runtimeAnimatorController.bind(a),c.mixer=a.runtimeAnimatorController.mixer),c.mixer||(c.mixer=new C0(a.gameObject)),c.clips.push(m),c.mixer.uncacheAction(m),c.createHooks(d.asset,m);const A=c.mixer.clipAction(m);c.actions.push(A),c.models.push(d)}this._animationTracks.push(c)}}}else if(s.type===Nn.Audio){if(s.clips.length<=0)continue;const o=new Tg;if(o.director=this,o.track=s,this._audioTracks.push(o),!t)continue;o.listener=t.listener;for(let a=0;a<s.clips.length;a++){const l=s.clips[a];o.addModel(l)}}else if(s.type===Nn.Marker){const o=new Ig;o.director=this,o.track=s;for(const a of s.markers)switch(a.type){case IM.Signal:o.models.push(a),o.didTrigger.push(!1);break}if(o!==null&&o.models.length>0){const a=se.getComponent(this.gameObject,Rp);a&&(o.receivers.push(a),this._signalTracks.push(o))}}else if(s.type===Nn.Signal){const o=new Ig;o.director=this,o.track=s;for(const a of s.markers)o.models.push(a),o.didTrigger.push(!1);for(const a of s.outputs)o.receivers.push(a);this._signalTracks.push(o)}else if(s.type===Nn.Control){const o=new Hb;o.director=this,o.track=s;for(const a of s.clips)o.models.push(a);o.resolveSourceObjects(this.context),this._controlTracks.push(o)}}}setAudioTracksAllowPlaying(i){for(const e of this._audioTracks)e.onAllowAudioChanged(i)}registerAnimationCallback(i){this.animationCallbackReceivers.push(i)}unregisterAnimationCallback(i){const e=this.animationCallbackReceivers.indexOf(i);e!==-1&&this.animationCallbackReceivers.splice(e,1)}};let Au=RM;h(Au,"createTrackFunctions",{});const Vl=le("debugtimeline");class Eg{constructor(){h(this,"director"),h(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let s=this.track.clips.length-1;s>=0;s--)yield this.track.clips[s];else for(const s of this.track.clips)yield s}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,s,r=!0){if(t<0||t>=s.length)return 0;const n=s[t];if(r||e>=n.start&&e<=n.end){let o=1;const a=!1;if(n.easeInDuration>0){const l=Math.min((e-n.start)/n.easeInDuration,1);o*=l}if(n.easeOutDuration>0&&!a){const l=Math.min((n.end-e)/n.easeOutDuration,1);o*=l}return o}return 0}}class jte{constructor(e){h(this,"clip"),h(this,"rootPositionOffset"),h(this,"rootQuaternionOffset"),h(this,"rootStartPosition"),h(this,"rootEndPosition"),h(this,"rootStartQuaternion"),h(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const s=e.getRoot(),r=s.name+".position",n=s.name+".quaternion";Vl&&console.log(t.name,t.tracks,r);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(r))this.rootStartPosition=new w().fromArray(o.values,0),this.rootEndPosition=new w().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Vl&&console.log(this.rootPositionOffset);else if(o.name.endsWith(n)&&(this.rootStartQuaternion=new Ee().fromArray(o.values,0),this.rootEndQuaternion=new Ee().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Vl)){const a=new Es().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Gb extends Eg{constructor(){super(...arguments),h(this,"models",[]),h(this,"trackOffset"),h(this,"target"),h(this,"mixer"),h(this,"clips",[]),h(this,"actions",[]),h(this,"_actionOffsets",[]),h(this,"_didBind",!1),h(this,"_animator",null),h(this,"_useclipOffsets",!0),h(this,"_totalOffsetPosition",new w),h(this,"_totalOffsetRotation",new Ee),h(this,"_totalOffsetPosition2",new w),h(this,"_totalOffsetRotation2",new Ee),h(this,"_summedPos",new w),h(this,"_tempPos",new w),h(this,"_summedRot",new Ee),h(this,"_tempRot",new Ee),h(this,"_clipRotQuat",new Ee)}onStateChanged(){this._animator&&XU(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var s,r;if(((s=t.tracks)==null?void 0:s.length)<=0){console.warn("No tracks in AnimationClip",t);return}const n=t.tracks[0].name.split("."),o=n[n.length-2],a=o+".position",l=o+".quaternion";let c=!1,u=!1;for(const d of t.tracks)d.name.endsWith(a)?(c=!0,this.createPositionInterpolant(t,e,d)):d.name.endsWith(l)&&(u=!0,this.createRotationInterpolant(t,e,d));if(!c||!u){const d=(r=this.mixer)==null?void 0:r.getRoot(),p=t.tracks[0],f=p.name.lastIndexOf("."),m=p.name.substring(0,f),A=m.substring(m.lastIndexOf(".")+1),v=d.getObjectByName(A);if(v)if(c){if(!u){const g=t.tracks[0].name.substring(0,f)+".quaternion";Vl&&console.warn("Create quaternion track",A,v);const b=v.quaternion,y=new ua(g,[0,t.duration],[b.x,b.y,b.z,b.w,b.x,b.y,b.z,b.w]);t.tracks.push(y),this.createRotationInterpolant(t,e,y)}}else{const g=m+".position";Vl&&console.warn("Create position track",A,v);const b=v.position,y=new hl(g,[0,t.duration],[b.x,b.y,b.z,b.x,b.y,b.z]);t.tracks.push(y),this.createPositionInterpolant(t,e,y)}}}bind(){if(!this._didBind){this._didBind=!0,Vl&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const t=new jte(e);this._actionOffsets.push(t)}this.target&&(this._animator=se.getComponent(this.target,Cr)??null,this._animator&&XU(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,s=t.position,r=t.rotation;s&&s.x!==void 0&&(s.isVector3||(t.position=new w(s.x,s.y,s.z)),r.isQuaternion||(t.rotation=new Ee(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new w(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new Ee(t.x,t.y,t.z,t.w)))}}evaluate(e){var t,s,r,n,o,a,l;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let c=0,u=0,d=!1,p=!1,f=0;for(let m=0;m<this.clips.length;m++){const A=this.models[m],v=this.actions[m],g=A.asset;v.weight=0;const b=e>=A.start&&e<=A.end,y=A.preExtrapolationMode,_=A.postExtrapolationMode,S=m<this.clips.length-1?this.models[m+1]:null;let M=b,I=!1;if(!M&&!d&&A.end<e&&_!==Ia.None?(!S||S.start>e)&&(M=!0,d=!0):m==0&&!M&&!p&&A.start>e&&y!==Ia.None&&(!S||S.start<e)&&(M=!0,I=!0,p=!0),M){let R=1;R*=this.evaluateWeight(e,m,this.models,M),R*=this.director.weight;let E=b;if(I)switch(y){case Ia.Hold:break;case Ia.Loop:e+=A.start,E=!0;break;default:e+=A.start,E=!0;break}let C=this.getClipTime(e,A),z=0;const q=g.duration;if(I&&y===Ia.Hold&&(C=0),E){if(g.loop)for(z+=Math.floor(C/(q+1e-6));C>q;)C-=q}else if(!b&&d)switch(_){case Ia.Hold:C=this.getClipTime(A.end,A);break;case Ia.Loop:C%=q;break;case Ia.PingPong:const G=Math.floor(C/q)%2!==0;C%=q,G&&(C=q-C);break}A.reversed===!0?v.time=v.getClip().duration-C:v.time=C,v.timeScale=0;const Q=Math.max(0,R);if(v.weight=Q,f+=Q,v.clampWhenFinished=!1,v.isRunning()||v.play(),this._useclipOffsets){const G=c==0?this._totalOffsetPosition:this._totalOffsetPosition2,$=c==0?this._totalOffsetRotation:this._totalOffsetRotation2;c<1&&(u=1-R),c+=1;const F=this._summedPos.set(0,0,0),L=this._tempPos.set(0,0,0),N=this._summedRot.identity(),re=this._tempRot.identity(),Z=g.rotation;Z&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(Z,R));const X=this._actionOffsets[m];if(X.hasOffsets)for(let ne=0;ne<z;ne++)X.rootPositionOffset?L.copy(X.rootPositionOffset):L.set(0,0,0),L.applyQuaternion(N),this._clipRotQuat&&L.applyQuaternion(this._clipRotQuat),X.rootQuaternionOffset&&(re.copy(X.rootQuaternionOffset),N.multiply(re)),F.add(L);this._clipRotQuat&&$.multiply(this._clipRotQuat),$.multiply(N),g.position&&F.add(g.position),G.add(F)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,u),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,u)),this.__mixerError===void 0&&(Vl||gi())&&(s=(t=this._animator)==null?void 0:t.runtimeAnimatorController)!=null&&s.mixer&&this.mixer!==((n=(r=this._animator)==null?void 0:r.runtimeAnimatorController)==null?void 0:n.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(o=this._animator)!=null&&o.runtimeAnimatorController){const m=Math.max(0,1-f);(l=(a=this._animator)==null?void 0:a.runtimeAnimatorController)==null||l.update(m)}else this.mixer.update(e)}createRotationInterpolant(e,t,s){var r;const n=s.createInterpolant.bind(s),o=new Ee;this.ensureTrackOffsets();const a=(r=this.trackOffset)==null?void 0:r.rotation;s.createInterpolant=()=>{const l=n(),c=l.evaluate.bind(l);return l.evaluate=u=>{var d;const p=c(u);if(o.set(p[0],p[1],p[2],p[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const f of this.director.animationCallbackReceivers)(d=f?.onTimelineRotation)==null||d.call(f,this.director,this.target,u,o);return p[0]=o.x,p[1]=o.y,p[2]=o.z,p[3]=o.w,p},l}}createPositionInterpolant(e,t,s){var r,n;const o=s.createInterpolant.bind(s),a=new w;this.ensureTrackOffsets();const l=(r=this.trackOffset)==null?void 0:r.rotation,c=(n=this.trackOffset)==null?void 0:n.position;let u;s.createInterpolant=()=>{const d=o(),p=d.evaluate.bind(d);return d.evaluate=f=>{var m,A,v;const g=p(f);if(a.set(g[0],g[1],g[2]),t.removeStartOffset&&(u===void 0?(u=null,u=(A=(m=this._actionOffsets.find(b=>b.clip===e))==null?void 0:m.rootStartPosition)==null?void 0:A.clone()):u!=null&&u.isVector3&&a.sub(u)),a.applyQuaternion(this._totalOffsetRotation),a.add(this._totalOffsetPosition),l&&a.applyQuaternion(l),c&&(a.x-=c.x,a.y+=c.y,a.z+=c.z),this.director.animationCallbackReceivers)for(const b of this.director.animationCallbackReceivers)(v=b?.onTimelinePosition)==null||v.call(b,this.director,this.target,f,a);return g[0]=a.x,g[1]=a.y,g[2]=a.z,g},d}}}const Qte=le("mutetimeline"),Mg=class extends Eg{constructor(){super(...arguments),h(this,"models",[]),h(this,"listener"),h(this,"audio",[]),h(this,"audioContextTimeOffset",[]),h(this,"lastTime",0),h(this,"_audioLoader",null)}getAudioFilePath(i){const e=this.director.sourceId;return Ya(e,i)}onAllowAudioChanged(i){for(let e=0;e<this.models.length;e++){const t=this.models[e];this.audio[e].setVolume(i?t.asset.volume:0)}}addModel(i){const e=new S0(this.listener);this.audio.push(e),this.models.push(i)}onDisable(){for(const i of this.audio)i.isPlaying&&i.stop()}onDestroy(){for(const i of this.audio)i.source&&i?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}stop(){for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}evaluate(i){if(Qte||this.track.muted||this.director.speed<0)return;const e=this.director.context.application.muted,t=e?.1:0;for(let s=0;s<this.models.length;s++){const r=this.models[s],n=this.audio[s];if((!n||!n.buffer)&&this.isInTimeRange(r,i-1,i+1)&&this.handleAudioLoading(r,n),As.userInteractionRegistered!==!1&&!(n===null||!n.buffer))if(n.playbackRate=this.director.context.time.timeScale,n.loop=r.asset.loop,i>=r.start&&i<=r.end&&i<this.director.duration){if(this.director.isPlaying==!1){if(n.isPlaying&&n.stop(),this.lastTime===i)continue}else if(!n.isPlaying)n.offset=r.clipIn+(i-r.start)*r.timeScale,n.play(t);else{const a=r.clipIn+(i-r.start)*r.timeScale,l=n.context.currentTime-n._startedAt+n.offset;Math.abs(a-l)>.3&&(n.offset=a,n.stop(),n.play(t))}let o=r.asset.volume;if(e&&(o=0),r.easeInDuration>0){const a=Math.min((i-r.start)/r.easeInDuration,1);o*=a}if(r.easeOutDuration>0){const a=Math.min((r.end-i)/r.easeOutDuration,1);o*=a}n.setVolume(o*this.director.weight)}else n.isPlaying&&n.stop()}this.lastTime=i}loadAudio(i,e=0,t=0){let s=null;const r=i-t,n=i+e;for(const o of this.models)if(this.isInTimeRange(o,r,n)){const a=this.audio[this.models.indexOf(o)],l=this.handleAudioLoading(o,a);l!==null&&(s===null&&(s=[]),s.push(l))}return s!==null?Promise.all(s):null}isInTimeRange(i,e,t){return e<=i.start&&t>=i.end||e>=i.start&&e<=i.end||t>=i.start&&t<=i.end}static dispose(){Mg._audioBuffers.clear()}handleAudioLoading(i,e){this._audioLoader||(this._audioLoader=new w0);const t=this.getAudioFilePath(i.asset.clip);if(Mg._audioBuffers.get(t)){const r=Mg._audioBuffers.get(t);return r.then(n=>{n&&e.setBuffer(n)}),r}Vl&&console.warn("LOAD audio track",t,this.director.sourceId);const s=new Promise((r,n)=>{this._audioLoader.load(t,o=>{e.setBuffer(o),r(o)},void 0,o=>{console.error("Error loading audio",o),r(null)})});return Mg._audioBuffers.set(t,s),s}};let Tg=Mg;h(Tg,"_audioBuffers",new Map);class Ig extends Eg{constructor(){super(...arguments),h(this,"models",[]),h(this,"didTrigger",[]),h(this,"receivers",[])}evaluate(e){var t;if(this.track.muted)return;const s=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const n=this.models[r],o=this.didTrigger[r],a=n.time-e;let l=!1;if(n.retroActive)l=a<=1e-6;else{const c=Math.abs(a);(c===0||c>=1e-5&&c<s)&&(l=!0)}if(l){if(!o)if(Vl&&console.log("Trigger signal",e,n.time,n),this.didTrigger[r]=!0,((t=this.receivers)==null?void 0:t.length)<=0)Rp.invoke(n.asset);else for(const c of this.receivers)c&&c.invoke(n.asset)}else n.emitOnce||(this.didTrigger[r]=!1)}}}class Hb extends Eg{constructor(){super(...arguments),h(this,"models",[]),h(this,"timelines",[]),h(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const s=this.models[t].asset;if(!s.sourceObject||typeof s.sourceObject!="object"){console.log("no source object, removing model",t,s),this.models.splice(t,1);continue}else{const r=se.getComponent(s.sourceObject,Au);this.timelines.push(r),r&&s.updateDirector&&(r.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],n=r.asset;if(e>=r.start&&e<=r.end){this._previousActiveModel=r;const o=this.getClipTime(e,r);if(n.controlActivation){const a=n.sourceObject;a.visible=!0}if(n.updateDirector){const a=this.timelines[s];a&&(a.isPlaying&&a.pause(),a.time=o,a.evaluate())}}else{const o=(t=this._previousActiveModel)==null?void 0:t.asset;if(n.controlActivation){const a=n.sourceObject;o?.sourceObject!==a&&(a.visible=!1)}}}}}var Gte=Object.defineProperty,Hte=Object.getOwnPropertyDescriptor,YN=(i,e,t,s)=>{for(var r=s>1?void 0:s?Hte(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Gte(e,t,r),r};class Tt{constructor(e){h(this,"_active",!0),h(this,"_value"),h(this,"_valueRaw"),h(this,"_defaultValue"),h(this,"valueProcessor"),h(this,"onValueChanged"),this._value=e,this._defaultValue=e,this._valueRaw=e}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}get value(){return this._valueRaw}set value(e){this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;const s=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,s,this)}testIfValueChanged(e){return this._valueRaw!==e}}YN([x()],Tt.prototype,"overrideState",1),YN([x()],Tt.prototype,"value",1);var Vte=Object.defineProperty,Wte=Object.getOwnPropertyDescriptor,Xte=(i,e,t,s)=>{for(var r=s>1?void 0:s?Wte(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Vte(e,t,r),r};const qte=le("debugpost");class Tr extends Oc{constructor(e=void 0){if(super(),h(this,"active",!0),h(this,"_result"),h(this,"_didCreateVolumeParameters",!1),e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const s=e[t],r=this[t];r instanceof Tt&&(r.value=s)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var e;return this.ensureVolumeParameters(),this._result||(this._result=(e=this.onCreateEffect)==null?void 0:e.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){qte&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const s=this[t];s instanceof Tt&&s.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const s=this.$serializedTypes;if(s){for(const r of Object.keys(s))if(s[r]===Tt){const n=e[r];if(n!==void 0){const o=this[r];o.value=n}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof Tt){const s=e.value;return this[t].value=s,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===Tt&&(this[t]||(this[t]=new Tt))}}Xte([x()],Tr.prototype,"active",2);var Yte=Object.defineProperty,Kte=Object.getOwnPropertyDescriptor,Jte=(i,e,t,s)=>{for(var r=s>1?void 0:s?Kte(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Yte(e,t,r),r};const Zte=le("debugpost"),PM={};function mo(i,e){PM[i]=e}function $te(i){return i.__type in PM?PM[i.__type]:(Zte&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),Tr)}class Rg{constructor(){h(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}Jte([sp([i=>$te(i),Tr])],Rg.prototype,"components",2);var eie=Object.defineProperty,tie=Object.getOwnPropertyDescriptor,iie=(i,e,t,s)=>{for(var r=s>1?void 0:s?tie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&eie(e,t,r),r};class Pg extends Tr{constructor(){super(...arguments),h(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new oq({preset:Vd.HIGH,edgeDetectionMode:sC.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}iie([x(Tt)],Pg.prototype,"preset",2),mo("Antialiasing",Pg);class Vb{constructor(){h(this,"files",[])}get extensionName(){return"Audio"}onExportObject(e,t,s){const r=se.getComponents(e,As);if(r.length)for(const n of r){if(!n.clip||!n.playOnAwake)continue;const o=n.clip.split("/").pop();this.files.includes(n.clip)||this.files.push(n.clip),t.addEventListener("serialize",(a,l)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${t.name}"`),a.appendLine(`uniform asset filePath = @audio/${o}@`),a.appendLine(`uniform token auralMode = "${n.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${n.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${n.volume}`),a.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const s=t.split("/").pop(),r=await(await(await fetch(t)).blob()).arrayBuffer(),n=new Uint8Array(r);e.files["audio/"+s]=n}}}var sie=Object.defineProperty,rie=Object.getOwnPropertyDescriptor,KN=(i,e,t,s)=>{for(var r=s>1?void 0:s?rie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&sie(e,t,r),r};const nie=le("debugmouth");class Bg extends Ie{constructor(){super(...arguments),h(this,"idle",[]),h(this,"talking",[]),h(this,"marker",null),h(this,"voip",null),h(this,"lastMouthChangeTime",0),h(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=se.findObjectOfType(nc,this.context),this.marker||(this.marker=se.getComponentInParent(this.gameObject,Mr))},3e3)}update(){var e;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((e=this.marker)==null?void 0:e.connectionId)??null;if(!t){nie&&(t=null);return}const s=this.voip.getFrequency(t)??0;this.updateLips(s)}updateLips(e){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&e>30){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,t)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,t)}}}setMouthShapeActive(e,t){if(e){e!=this.idle?this.idle.map(s=>s.visible=!1):this.talking.map(s=>s.visible=!1);for(let s=0;s<e.length;s++){const r=e[s];r&&(r.visible=s===t)}}}}KN([x(Re)],Bg.prototype,"idle",2),KN([x(Re)],Bg.prototype,"talking",2);class BM extends Ie{constructor(){super(...arguments),h(this,"voip",null),h(this,"marker",null),h(this,"_startPosition",null)}awake(){this.voip=se.findObjectOfType(nc,this.context),this.marker=se.getComponentInParent(this.gameObject,Mr)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const e=this.marker.connectionId,t=this.voip.getFrequency(e);if(t==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const s=t/100;this.gameObject.position.y=this._startPosition.y+s*.07}}var oie=Object.defineProperty,aie=Object.getOwnPropertyDescriptor,Wb=(i,e,t,s)=>{for(var r=s>1?void 0:s?aie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&oie(e,t,r),r};class yu extends Ie{constructor(){super(...arguments),h(this,"eyes",[]),h(this,"lastBlinkTime",0),h(this,"blinkLength",0),h(this,"eyesOpen",!0),h(this,"state",null)}awake(){this.state=se.getComponentInParent(this.gameObject,Dn)}update(){if(!(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)&&this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const e of this.eyes)e&&(e.visible=this.eyesOpen)}}}Wb([x(Re)],yu.prototype,"eyes",2),Wb([x()],yu.prototype,"lastBlinkTime",2),Wb([x()],yu.prototype,"blinkLength",2),Wb([x()],yu.prototype,"eyesOpen",2);var lie=Object.defineProperty,cie=Object.getOwnPropertyDescriptor,kM=(i,e,t,s)=>{for(var r=s>1?void 0:s?cie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&lie(e,t,r),r},DM;const JN=(DM=class extends Ie{constructor(){super(...arguments),h(this,"head",null),h(this,"eyes",null),h(this,"target",null),h(this,"brain",null),h(this,"vec",new w),h(this,"currentTargetPoint",new w)}awake(){this.brain||(this.brain=se.getComponentInParent(this.gameObject,sg)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=se.addNewComponent(this.gameObject,sg)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const i=this.target;if(i&&this.head){const e=this.eyes;if(e){const t=At(i);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const s=At(this.head),r=this.vec.copy(this.currentTargetPoint).sub(s).normalize();if(r.length()<.1)return;const n=JN.forward;if(n.set(0,0,1),n.applyQuaternion(Bs(this.head)),n.dot(r)>.45)for(let o=0;o<e.length;o++)e[o].lookAt(this.currentTargetPoint)}}}},h(DM,"forward",new w(0,0,1)),DM);let Bp=JN;kM([x(Re)],Bp.prototype,"head",2),kM([x(Re)],Bp.prototype,"eyes",2),kM([x(Re)],Bp.prototype,"target",2);var hie=Object.defineProperty,uie=Object.getOwnPropertyDescriptor,OM=(i,e,t,s)=>{for(var r=s>1?void 0:s?uie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&hie(e,t,r),r};class kp extends Ie{constructor(){super(...arguments),h(this,"length",1),h(this,"depthTest",!0),h(this,"isGizmo",!0),h(this,"_axes",null)}onEnable(){if(this.isGizmo&&!am)return;this._axes||(this._axes=new Ud(this.length)),this.gameObject.add(this._axes);const e=this._axes.material;e&&e.depthTest!==void 0&&(e.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}OM([x()],kp.prototype,"length",2),OM([x()],kp.prototype,"depthTest",2),OM([x()],kp.prototype,"isGizmo",2);class LM extends Ie{constructor(){super(...arguments),h(this,"from"),h(this,"to"),h(this,"hint"),h(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const e=At(this.to).clone(),t=At(this.from).clone(),s=e.distanceTo(t),r=e.clone();r.sub(t);const n=t.clone();n.add(e),n.multiplyScalar(.5);const o=At(this.hint).clone();o.sub(n);const a=new w;a.crossVectors(o,r),a.crossVectors(r,a),a.normalize();const l=s*.5,c=Math.max(this.desiredDistance,l),u=Math.sqrt(c*c-l*l),d=a.clone();d.multiplyScalar(u),d.add(n),ns(this.gameObject,d);const p=n.clone();p.sub(a),this.gameObject.lookAt(p)}}const ZN=le("debugusdz");class Xb{constructor(){h(this,"behaviours",[]),h(this,"behaviourComponents",[]),h(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(e){this.behaviours.push(e)}onBeforeBuildDocument(e){const t=[];return e.root.traverse(s=>{se.foreachComponent(s,r=>{var n;const o=r;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const a=(n=o.beforeCreateDocument)==null?void 0:n.call(o,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,s){var r;for(const n of this.behaviourComponents)(r=n.createBehaviours)==null||r.call(n,this,t,s)}onAfterBuildDocument(e){for(const t of this.behaviourComponents)typeof t.afterCreateDocument=="function"&&t.afterCreateDocument(this,e);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(e,t){var s;if((s=this.behaviours)!=null&&s.length){t.beginBlock('def Scope "Behaviors"');for(const r of this.behaviours)r.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){ZN&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const t of this.behaviourComponentsCopy)typeof t.afterSerialize=="function"&&(ZN&&console.log("behaviour has afterSerialize",t),t.afterSerialize.constructor.name==="AsyncFunction"?await t.afterSerialize(this,e):t.afterSerialize(this,e))}}var die=Object.defineProperty,pie=Object.getOwnPropertyDescriptor,UM=(i,e,t,s)=>{for(var r=s>1?void 0:s?pie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&die(e,t,r),r};class bu extends Tr{constructor(){super(...arguments),h(this,"threshold"),h(this,"intensity"),h(this,"scatter"),h(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>1*Math.PI*(1-e)):(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>100*(1-e))}onCreateEffect(){let e;if(this.selectiveBloom){const t=e=new FO(this.context.scene,this.context.mainCamera,{blendFunction:Nt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new cC;return this.intensity.onValueChanged=t=>{e.intensity=t},this.threshold.onValueChanged=t=>{e.luminanceMaterial.threshold=t},this.scatter.onValueChanged=t=>{e.luminancePass.enabled=!0,e.luminanceMaterial.smoothing=t},e}}UM([x(Tt)],bu.prototype,"threshold",2),UM([x(Tt)],bu.prototype,"intensity",2),UM([x(Tt)],bu.prototype,"scatter",2),mo("Bloom",bu);var fie=Object.defineProperty,mie=Object.getOwnPropertyDescriptor,qo=(i,e,t,s)=>{for(var r=s>1?void 0:s?mie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&fie(e,t,r),r};class Ra extends Ie{constructor(){super(...arguments),h(this,"attachedRigidbody",null),h(this,"isTrigger",!1),h(this,"sharedMaterial")}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Vi))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Vi))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Vi))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}}qo([x(Vi)],Ra.prototype,"attachedRigidbody",2),qo([x()],Ra.prototype,"isTrigger",2),qo([x()],Ra.prototype,"sharedMaterial",2);class kg extends Ra{constructor(){super(...arguments),h(this,"radius",.5),h(this,"center",new w(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this,this.center,this.radius)}}qo([x()],kg.prototype,"radius",2),qo([x(w)],kg.prototype,"center",2);class Dg extends Ra{constructor(){super(...arguments),h(this,"size",new w(1,1,1)),h(this,"center",new w(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.center,this.size)}}qo([x(w)],Dg.prototype,"size",2),qo([x(w)],Dg.prototype,"center",2);class Og extends Ra{constructor(){super(...arguments),h(this,"sharedMesh"),h(this,"convex",!1)}onEnable(){var e,t,s,r,n;if(super.onEnable(),(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof ye&&(this.sharedMesh=this.gameObject),(t=this.sharedMesh)!=null&&t.isMesh)(s=this.context.physics.engine)==null||s.addMeshCollider(this,this.sharedMesh,this.convex,js(this.gameObject));else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${(r=this.sharedMesh)==null?void 0:r.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const a in o.children){const l=o.children[a];l.isMesh&&((n=this.context.physics.engine)==null||n.addMeshCollider(this,l,this.convex,js(this.gameObject)))}}}}}qo([x()],Og.prototype,"convex",2);class Zc extends Ra{constructor(){super(...arguments),h(this,"center",new w(0,0,0)),h(this,"radius",.5),h(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.center,this.height,this.radius)}}qo([x(w)],Zc.prototype,"center",2),qo([x()],Zc.prototype,"radius",2),qo([x()],Zc.prototype,"height",2);var gie=Object.defineProperty,vie=Object.getOwnPropertyDescriptor,Lg=(i,e,t,s)=>{for(var r=s>1?void 0:s?vie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&gie(e,t,r),r};const FM=le("debugui"),NM=le("debuguilayout");class zM{constructor(){h(this,"width"),h(this,"height")}}class jM{constructor(){h(this,"x"),h(this,"y"),h(this,"width"),h(this,"height")}}const Yo=new w,Ug=new Be,qb=new Ee,$N=class extends ia{constructor(){super(),h(this,"_anchoredPosition"),h(this,"sizeDelta",new ee(100,100)),h(this,"pivot",new ee(.5,.5)),h(this,"anchorMin",new ee(0,0)),h(this,"anchorMax",new ee(1,1)),h(this,"lastMatrix"),h(this,"rectBlock"),h(this,"_transformNeedsUpdate",!1),h(this,"_initialPosition"),h(this,"_parentRectTransform"),h(this,"_lastUpdateFrame",-1),h(this,"_lastAnchoring"),h(this,"_createdBlocks",[]),h(this,"_createdTextBlocks",[]),this.lastMatrix=new Be,this.rectBlock=new Re}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new ee),this._anchoredPosition}set anchoredPosition(i){this._anchoredPosition=i}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const i=this._parentRectTransform.width,e=this.anchorMax.x-this.anchorMin.x;let t=i*e;return t+=this.sizeDelta.x,t}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const i=this._parentRectTransform.height,e=this.anchorMax.y-this.anchorMin.y;let t=i*e;return t+=this.sizeDelta.y,t}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new ee),this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Mp(this,"_anchoredPosition",()=>{this.markDirty()}),Mp(this,"sizeDelta",()=>{this.markDirty()}),Mp(this,"pivot",()=>{this.markDirty()}),Mp(this,"anchorMin",()=>{this.markDirty()}),Mp(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var i;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(i=this.Canvas)==null||i.registerTransform(this)}onDisable(){var i;super.onDisable(),this.removeShadowComponent(),(i=this.Canvas)==null||i.unregisterTransform(this)}onParentRectTransformChanged(i){this._transformNeedsUpdate||this.onApplyTransform(NM?`${i.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(NM&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(i){var e;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const t=this.shadowComponent;if(!t)return;this.gameObject.parent?this._parentRectTransform=se.getComponentInParent(this.gameObject.parent,$N):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,NM&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+i),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,Yo.set(0,0,0),this.applyPivot(Yo),t.matrix.setPosition(Yo.x,Yo.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(qb.copy(this.gameObject.quaternion),qb.x*=-1,qb.z*=-1,Ug.makeRotationFromQuaternion(qb),t.matrix.premultiply(Ug)),Yo.set(0,0,0),this.applyAnchoring(Yo),(e=this.Canvas)!=null&&e.screenspace?Yo.z+=.1:Yo.z+=.01,Ug.identity(),Ug.setPosition(Yo.x,Yo.y,Yo.z),t.matrix.premultiply(Ug),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const s=!0;for(const r of J1(this.gameObject,ia,s,1)){if(r===this||!r.activeAndEnabled)continue;const n=r;n.onParentRectTransformChanged&&n.onParentRectTransformChanged(this)}}applyAnchoring(i){this._lastAnchoring||(this._lastAnchoring=new ee);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),i.x+=this._initialPosition.x-this.gameObject.position.x,i.y+=this._initialPosition.y-this.gameObject.position.y,i.z+=this._initialPosition.z-this.gameObject.position.z;const t=this._parentRectTransform;if(t){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=t.height*.5*r,i.y+=s;let n=0;const o=1-this.anchorMax.x-this.anchorMin.x;n-=t.width*.5*o,i.x+=n}}applyPivot(i){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;i.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const t=this.pivot.y-.5;i.y-=t*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const i={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(i),i}ensureValidSize(i,e=1e-4){return i.width<=0&&(i.width=e),i.height<=0&&(i.height=1e-4),i}createNewBlock(i){i={...this.getBasicOptions(),...i},FM&&console.log(this.name,i);const e=new vM(i);return this._createdBlocks.push(e),e}createNewText(i){FM&&console.log(i),i={...this.getBasicOptions(),...i},FM&&console.log(this.name,i);const e=new zN(i);return this._createdTextBlocks.push(e),e}};let Kr=$N;Lg([x(ee)],Kr.prototype,"anchoredPosition",1),Lg([x(ee)],Kr.prototype,"sizeDelta",2),Lg([x(ee)],Kr.prototype,"pivot",2),Lg([x(ee)],Kr.prototype,"anchorMin",2),Lg([x(ee)],Kr.prototype,"anchorMax",2);class Aie extends NN{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const s in t)for(const r in t[s])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(s);for(const s of e._components)e._simpleState__statesProperties[s.id]&&(e._simpleState__normalStyles[s.id]=s.inline?s.inline:s._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;const s=[];for(const r in t)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],s.push(r)),this._simpleState__statesProperties[r].push(e);for(const r of this._components)s.indexOf(r.id)>-1&&(this._simpleState__normalStyles[r.id]=r.inline?r.inline:r._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const s in e)this._simpleState__statesProperties[s]&&(this._simpleState__normalStyles[s]=e[s]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var yie=Object.defineProperty,bie=Object.getOwnPropertyDescriptor,e3=(i,e,t,s)=>{for(var r=s>1?void 0:s?bie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&yie(e,t,r),r};class Dp extends Ie{constructor(){super(...arguments),h(this,"effectColor"),h(this,"effectDistance")}}e3([x(Ai)],Dp.prototype,"effectColor",2),e3([x(ee)],Dp.prototype,"effectDistance",2);var _ie=Object.defineProperty,xie=Object.getOwnPropertyDescriptor,t3=(i,e,t,s)=>{for(var r=s>1?void 0:s?xie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&_ie(e,t,r),r};const Yb={backgroundColor:new _e(1,1,1),backgroundOpacity:1,borderColor:new _e(1,1,1),borderOpacity:1};var QM;const Kb=(QM=class extends ia{constructor(){super(...arguments),h(this,"_alphaFactor",1),h(this,"raycastTarget",!0),h(this,"uiObject",null),h(this,"_color",null),h(this,"_rect",null),h(this,"_stateManager",null),h(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new Ai(1,1,1,1)),this._color}set color(i){(!this._color||this._color.r!==i.r||this._color.g!==i.g||this._color.b!==i.b||this._color.alpha!==i.alpha)&&(this._color||(this._color=new Ai(1,1,1,1)),this._color.copy(i))}setAlphaFactor(i){this._alphaFactor=i,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(Yb.backgroundColor=this._color,Yb.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(Yb,this._alphaFactor),this.uiObject.set(Yb),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=se.getComponent(this.gameObject,Kr)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var i;(i=this.uiObject)==null||i.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(i){this.makePanel(),this.uiObject&&(this.uiObject.setState(i),this==null||this.markDirty())}setupState(i){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new Aie(this.uiObject)),this.uiObject.setupState(i.state,i.attributes))}setOptions(i){this.makePanel(),this.uiObject&&this.uiObject.set(i)}awake(){super.awake(),this.makePanel(),Mp(this,"_color",()=>Ite(this,this.onColorChanged))}onEnable(){var i;super.onEnable(),this.uiObject&&((i=this.rectTransform.shadowComponent)==null||i.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const i=.015,e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:i};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(i){}onCreate(i){this.uiObject=this.rectTransform.createNewBlock(i),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(i,e=1){var t;const s=(t=this.gameObject)==null?void 0:t.getComponent(Dp);s&&(s.effectDistance&&(i.borderWidth=Math.max(Math.abs(s.effectDistance.x),Math.abs(s.effectDistance.y))),s.effectColor&&(i.borderColor=s.effectColor,i.borderOpacity=s.effectColor.alpha*e))}async setTexture(i){if(this.setOptions({backgroundOpacity:0}),i){if(i.colorSpace===et){if(Kb.textureCache.has(i))i=Kb.textureCache.get(i);else if(!i.isRenderTargetTexture){const e=i.clone();e.colorSpace=ts,Kb.textureCache.set(i,e),i=e}}this.setOptions({backgroundImage:i,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},h(QM,"textureCache",new Map),QM);let _u=Kb;t3([x(Ai)],_u.prototype,"color",1),t3([x()],_u.prototype,"raycastTarget",2);class Fg extends _u{constructor(){super(...arguments),h(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var wie=Object.defineProperty,Sie=Object.getOwnPropertyDescriptor,Jb=(i,e,t,s)=>{for(var r=s>1?void 0:s?Sie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&wie(e,t,r),r};let GM=class{constructor(){h(this,"texture",null),h(this,"rect")}};Jb([x(Pt)],GM.prototype,"texture",2);let Op=class extends Fg{constructor(){super(...arguments),h(this,"_sprite"),h(this,"pixelsPerUnitMultiplier",1)}set image(i){this.sprite||(this.sprite=new GM),this.sprite.texture=i,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(i){this._sprite!==i&&(this._sprite=i,this.onAfterCreated())}isBuiltinSprite(){var i,e,t,s,r,n,o,a;switch((e=(i=this.sprite)==null?void 0:i.texture)==null?void 0:e.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((r=(s=(t=this.sprite)==null?void 0:t.texture)==null?void 0:s.image)==null?void 0:r.width)===32&&((a=(o=(n=this.sprite)==null?void 0:n.texture)==null?void 0:o.image)==null?void 0:a.height)===32}onBeforeCreate(i){var e,t;super.onBeforeCreate(i),this.isBuiltinSprite()&&(i.borderRadius=5/this.pixelsPerUnitMultiplier,((t=(e=this.sprite)==null?void 0:e.texture)==null?void 0:t.name)==="Knob"&&(i.borderRadius=999))}onAfterCreated(){var i;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((i=this.sprite)==null?void 0:i.texture))}};Jb([x(GM)],Op.prototype,"sprite",1),Jb([x()],Op.prototype,"pixelsPerUnitMultiplier",2);class Zb extends Fg{constructor(){super(...arguments),h(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Jb([x(Pt)],Zb.prototype,"mainTexture",1);var Cie=Object.defineProperty,Eie=Object.getOwnPropertyDescriptor,zn=(i,e,t,s)=>{for(var r=s>1?void 0:s?Eie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Cie(e,t,r),r};const Lp=le("debugbutton");class xu{constructor(){h(this,"colorMultiplier"),h(this,"disabledColor"),h(this,"fadeDuration"),h(this,"highlightedColor"),h(this,"normalColor"),h(this,"pressedColor"),h(this,"selectedColor")}}zn([x()],xu.prototype,"colorMultiplier",2),zn([x(Ai)],xu.prototype,"disabledColor",2),zn([x()],xu.prototype,"fadeDuration",2),zn([x(Ai)],xu.prototype,"highlightedColor",2),zn([x(Ai)],xu.prototype,"normalColor",2),zn([x(Ai)],xu.prototype,"pressedColor",2),zn([x(Ai)],xu.prototype,"selectedColor",2);class Wl extends Ie{constructor(){super(...arguments),h(this,"onClick"),h(this,"_isHovered",!1),h(this,"colors"),h(this,"transition"),h(this,"animationTriggers"),h(this,"animator"),h(this,"_interactable",!0),h(this,"_requestedAnimatorTrigger"),h(this,"_isInit",!1),h(this,"_image")}onPointerEnter(e){var t,s;Lp&&console.log("Button Enter",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this._isHovered=!0,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var e,t;Lp&&console.log("Button Exit",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this._isHovered=!1,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((t=this._image)==null||t.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(e){var t,s;Lp&&console.log("Button Down",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("pressed")))}onPointerUp(e){var t,s;Lp&&console.warn("Button Up",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){var t;this.interactable&&e.pointerId===0&&(Lp&&(console.warn("Button Click",this.onClick),fs("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(t=this.onClick)==null||t.invoke())}set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(e){this.interactable=e}awake(){super.awake(),Lp&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable)}onEnable(){super.onEnable()}*setAnimatorTriggerAtEndOfFrame(e){var t;this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&((t=this.animator)==null||t.SetTrigger(e))}init(){this._isInit||(this._isInit=!0,this._image=se.getComponent(this.gameObject,Op),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var t,s,r,n,o;e.setInteractable(this.interactable);const a=this.getFinalColor(e.color,(t=this.colors)==null?void 0:t.normalColor),l={state:"normal",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};e.setupState(l);const c=this.getFinalColor(e.color,(s=this.colors)==null?void 0:s.highlightedColor),u={state:"hovered",attributes:{backgroundColor:c,backgroundOpacity:c.alpha}};e.setupState(u);const d=this.getFinalColor(e.color,(r=this.colors)==null?void 0:r.pressedColor),p={state:"pressed",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};e.setupState(p);const f=this.getFinalColor(e.color,(n=this.colors)==null?void 0:n.selectedColor),m={state:"selected",attributes:{backgroundColor:f,backgroundOpacity:f.alpha}};e.setupState(m);const A=this.getFinalColor(e.color,(o=this.colors)==null?void 0:o.disabledColor),v={state:"disabled",attributes:{backgroundColor:A,backgroundOpacity:A.alpha}};e.setupState(v)}getFinalColor(e,t){return t?e.clone().multiply(t):e.clone()}}zn([x(ir)],Wl.prototype,"onClick",2),zn([x()],Wl.prototype,"colors",2),zn([x()],Wl.prototype,"transition",2),zn([x()],Wl.prototype,"animationTriggers",2),zn([x(Cr)],Wl.prototype,"animator",2),zn([x()],Wl.prototype,"interactable",1);var Mie=Object.defineProperty,Tie=Object.getOwnPropertyDescriptor,_s=(i,e,t,s)=>{for(var r=s>1?void 0:s?Tie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Mie(e,t,r),r};const i3=le("debuguilayout");class $c{constructor(){h(this,"left",0),h(this,"right",0),h(this,"top",0),h(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}_s([x()],$c.prototype,"left",2),_s([x()],$c.prototype,"right",2),_s([x()],$c.prototype,"top",2),_s([x()],$c.prototype,"bottom",2);class jn extends Ie{constructor(){super(...arguments),h(this,"_rectTransform",null),h(this,"_needsUpdate",!1),h(this,"childAlignment",0),h(this,"reverseArrangement",!1),h(this,"spacing",0),h(this,"padding"),h(this,"minWidth",0),h(this,"minHeight",0),h(this,"flexibleHeight",0),h(this,"flexibleWidth",0),h(this,"preferredHeight",0),h(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(e){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(i3&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){i3&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(Kr);const e=this.gameObject.getComponentInParent(nr);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(nr);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}_s([x()],jn.prototype,"childAlignment",2),_s([x()],jn.prototype,"reverseArrangement",2),_s([x()],jn.prototype,"spacing",2),_s([x($c)],jn.prototype,"padding",2),_s([x()],jn.prototype,"minWidth",2),_s([x()],jn.prototype,"minHeight",2),_s([x()],jn.prototype,"flexibleHeight",2),_s([x()],jn.prototype,"flexibleWidth",2),_s([x()],jn.prototype,"preferredHeight",2),_s([x()],jn.prototype,"preferredWidth",2);class eh extends jn{constructor(){super(...arguments),h(this,"childControlHeight",!0),h(this,"childControlWidth",!0),h(this,"childForceExpandHeight",!1),h(this,"childForceExpandWidth",!1),h(this,"childScaleHeight",!1),h(this,"childScaleWidth",!1)}onCalculateLayout(e){var t;const s=this.primaryAxis,r=e.width;let n=r;const o=e.height;let a=o;n-=this.padding.horizontal,a-=this.padding.vertical,s==="x"?this.padding.horizontal:this.padding.vertical;const l=s==="x",c=l?"y":"x",u=l?this.childControlWidth:this.childControlHeight,d=l?this.childControlHeight:this.childControlWidth,p=l?this.childForceExpandWidth:this.childForceExpandHeight,f=l?this.childForceExpandHeight:this.childForceExpandWidth,m=l?a:n,A=l?r:o,v=.5*(l?this.childAlignment%3:Math.floor(this.childAlignment/3));let g=0;l?g+=this.padding.left:g+=this.padding.top;let b=0,y=0;for(let R=0;R<this.gameObject.children.length;R++){const E=this.gameObject.children[R],C=se.getComponent(E,Kr);C!=null&&C.activeAndEnabled&&(y+=1,l?b+=C.width:b+=C.height)}let _=0;const S=this.spacing*(y-1);if(p||u){let R=0;l?R=n-=S:R=a-=S,y>0&&(_=R/y)}let M=0;M+=this.padding.left,M-=this.padding.right,v!==0&&(g=A-b,g*=v,g-=S*v,l?(g-=this.padding.right*v,g+=this.padding.left*(1-v),g<this.padding.left&&(g=this.padding.left)):(g-=this.padding.bottom*v,g+=this.padding.top*(1-v),g<this.padding.top&&(g=this.padding.top)));let I=1;for(let R=0;R<this.gameObject.children.length;R++){const E=this.gameObject.children[R],C=se.getComponent(E,Kr);if(C!=null&&C.activeAndEnabled){(t=C.pivot)==null||t.set(.5,.5),C.anchorMin.set(0,1),C.anchorMax.set(0,1);const z=r*.5+M*.5;C.anchoredPosition.x!==z&&(C.anchoredPosition.x=z);const q=o*-.5;C.anchoredPosition.y!==q&&(C.anchoredPosition.y=q),f&&d&&C.sizeDelta[c]!==m&&(C.sizeDelta[c]=m),p&&u&&C.sizeDelta[s]!==_&&(C.sizeDelta[s]=_);const Q=l?C.width:C.height,G=Q*.5;if(g+=G,p){const F=_*I-_*.5;F>g&&(g=F-_*.5+Q+this.padding.left,g-=G)}let $=g;s==="y"&&($=-$),C.anchoredPosition[s]!==$&&(C.anchoredPosition[s]=$),g+=G,g+=this.spacing,I+=1}}}}_s([x()],eh.prototype,"childControlHeight",2),_s([x()],eh.prototype,"childControlWidth",2),_s([x()],eh.prototype,"childForceExpandHeight",2),_s([x()],eh.prototype,"childForceExpandWidth",2),_s([x()],eh.prototype,"childScaleHeight",2),_s([x()],eh.prototype,"childScaleWidth",2);class HM extends eh{get primaryAxis(){return"y"}}class VM extends eh{get primaryAxis(){return"x"}}class WM extends jn{onCalculateLayout(){}}var Iie=Object.defineProperty,Rie=Object.getOwnPropertyDescriptor,Pa=(i,e,t,s)=>{for(var r=s>1?void 0:s?Rie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Iie(e,t,r),r},s3=(i=>(i[i.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",i[i.ScreenSpaceCamera=1]="ScreenSpaceCamera",i[i.WorldSpace=2]="WorldSpace",i[i.Undefined=-1]="Undefined",i))(s3||{});const XM=le("debuguilayout"),r3=class extends fg{constructor(){super(...arguments),h(this,"_renderOnTop"),h(this,"_depthWrite",!1),h(this,"_doubleSided",!0),h(this,"_castShadows",!1),h(this,"_receiveShadows",!1),h(this,"_renderMode",-1),h(this,"_rootCanvas"),h(this,"_scaleFactor",1),h(this,"worldCamera"),h(this,"planeDistance",-1),h(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),h(this,"previousParent",null),h(this,"_lastMatrixWorld",null),h(this,"_rectTransforms",[]),h(this,"_layoutGroups",new Map),h(this,"onBeforeRenderRoutine",()=>{var i,e,t,s;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(e=this.shadowComponent)==null||e.updateWorldMatrix(!0,!0),Un.ensureUpdateMeshUI(yM,this.context);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),Un.ensureUpdateMeshUI(yM,this.context))}),h(this,"onAfterRenderRoutine",()=>{var i,e;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const r=this.context.mainCamera;r?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const t=this.context.renderer.autoClear,s=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),Un.ensureUpdateMeshUI(yM,this.context),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=t,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(e=this._lastMatrixWorld)==null||e.copy(this.gameObject.matrixWorld)}}),h(this,"_updateRenderSettingsRoutine"),h(this,"_activeRenderMode",-1),h(this,"_lastWidth",-1),h(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(i){i!==this._renderOnTop&&(this._renderOnTop=i,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(i){this._depthWrite!==i&&(this._depthWrite=i,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(i){this._doubleSided!==i&&(this._doubleSided=i,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(i){this._castShadows!==i&&(this._castShadows=i,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(i){this._receiveShadows!==i&&(this._receiveShadows=i,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(i){this._renderMode!==i&&(this._renderMode=i,this.onRenderSettingsChanged())}set rootCanvas(i){this._rootCanvas instanceof r3||(this._rootCanvas=i)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(i){this._scaleFactor=i}awake(){var i;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,XM&&console.log("Canvas.Awake()",((i=this.previousParent)==null?void 0:i.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new Be,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const i=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);i!==-1&&this.context.pre_render_callbacks.splice(i,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(i){this._rectTransforms.push(i)}unregisterTransform(i){const e=this._rectTransforms.indexOf(i);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(i){const e=i.gameObject;this._layoutGroups.set(e,i)}unregisterLayoutGroup(i){const e=i.gameObject;this._layoutGroups.delete(e)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new Be);const i=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);XM&&i&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const e=!1;for(const t of this._rectTransforms){i&&t.markDirty();let s=this._layoutGroups.get(t.gameObject);t.isDirty&&!s&&(s=t.gameObject.getComponentInParent(jn)),(t.isDirty||s!=null&&s.isDirty)&&(XM&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),s?.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),dn.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Nb(this.shadowComponent,this);for(const i of se.getComponentsInChildren(this.gameObject,ia))Nb(i.shadowComponent,this)}}onUpdateRenderMode(i=!1){if(!i&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let e=this.context.mainCameraComponent,t=10;switch(e&&e.nearClipPlane>0&&e.farClipPlane>0&&(t=tt.lerp(e.nearClipPlane,e.farClipPlane,.15)),this._renderMode===1&&(this.worldCamera&&(e=this.worldCamera),this.planeDistance>0&&(t=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!e)return;const s=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-s,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(Kr);let n=!1;r.sizeDelta.x!==this.context.domWidth&&(n=!0),r.sizeDelta.y!==this.context.domHeight&&(n=!0);const o=e.fieldOfView*Math.PI/180,a=2*Math.tan(o/2)*Math.abs(s);this.gameObject.scale.x=a/this.context.domHeight,this.gameObject.scale.y=a/this.context.domHeight,this.gameObject.scale.z=.01,n&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let nr=r3;Pa([x()],nr.prototype,"renderOnTop",1),Pa([x()],nr.prototype,"depthWrite",1),Pa([x()],nr.prototype,"doubleSided",1),Pa([x()],nr.prototype,"castShadows",1),Pa([x()],nr.prototype,"receiveShadows",1),Pa([x()],nr.prototype,"renderMode",1),Pa([x(nr)],nr.prototype,"rootCanvas",1),Pa([x()],nr.prototype,"scaleFactor",1),Pa([x(Ri)],nr.prototype,"worldCamera",2),Pa([x()],nr.prototype,"planeDistance",2);var Pie=Object.defineProperty,Bie=Object.getOwnPropertyDescriptor,qM=(i,e,t,s)=>{for(var r=s>1?void 0:s?Bie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Pie(e,t,r),r};class th extends Ie{constructor(){super(...arguments),h(this,"_alpha",1),h(this,"interactable",!0),h(this,"blocksRaycasts",!0),h(this,"_isDirty",!1),h(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(e){e!==this._alpha&&(this._alpha=e,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),dn.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const e of se.getComponentsInChildren(this.gameObject,ia,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}qM([x()],th.prototype,"alpha",1),qM([x()],th.prototype,"interactable",2),qM([x()],th.prototype,"blocksRaycasts",2);var kie=Object.defineProperty,Die=Object.getOwnPropertyDescriptor,Pi=(i,e,t,s)=>{for(var r=s>1?void 0:s?Die(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&kie(e,t,r),r};class wu extends Ie{constructor(){super(...arguments),h(this,"object"),h(this,"target"),h(this,"duration",1),h(this,"relativeMotion",!1),h(this,"coroutine",null),h(this,"targetPos",new w),h(this,"targetRot",new Ee),h(this,"targetScale",new w)}*moveToTarget(){if(!this.target||!this.object)return;const e=At(this.object).clone(),t=At(this.target).clone(),s=Bs(this.object).clone(),r=Bs(this.target).clone(),n=js(this.object).clone(),o=js(this.target).clone(),a=e.distanceTo(t),l=s.angleTo(r),c=n.distanceTo(o);if(a<.01&&l<.01&&c<.01){ns(this.object,t),ln(this.object,r),g1(this.object,o),this.coroutine=null;return}let u=0,d=0;for(;u<1;)u+=this.context.time.deltaTime/this.duration,u>1&&(u=1),d=u<.5?4*u*u*u:1-Math.pow(-2*u+2,3)/2,this.targetPos.lerpVectors(e,t,d),this.targetRot.slerpQuaternions(s,r,d),this.targetScale.lerpVectors(n,o,d),ns(this.object,this.targetPos),ln(this.object,this.targetRot),g1(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),t=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),n=this.target.quaternion.clone(),o=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(n),this.targetScale.copy(this.object.scale).multiply(o);let a=0,l=0;for(;a<1;)a+=this.context.time.deltaTime/this.duration,a>1&&(a=1),l=a<.5?4*a*a*a:1-Math.pow(-2*a+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,l),this.object.quaternion.slerpQuaternions(t,this.targetRot,l),this.object.scale.lerpVectors(s,this.targetScale,l),yield;this.coroutine=null}onPointerClick(){this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const s=new Xr("Move to "+((t=this.target)==null?void 0:t.name),pn.tapTrigger(this.gameObject),ui.transformAction(this.object,this.target,this.duration,this.relativeMotion?gE.Relative:gE.Absolute));e.addBehavior(s)}}}Pi([x(Re)],wu.prototype,"object",2),Pi([x(Re)],wu.prototype,"target",2),Pi([x()],wu.prototype,"duration",2),Pi([x()],wu.prototype,"relativeMotion",2);var $b;const Xl=($b=class extends Ie{constructor(){super(...arguments),h(this,"materialToSwitch"),h(this,"variantMaterial"),h(this,"fadeDuration",0),h(this,"_objectsWithThisMaterial",[]),h(this,"selfModel"),h(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const i=se.findObjectsOfType(Di);for(const e of i)for(let t=0;t<e.sharedMaterials.length;t++){const s=e.sharedMaterials[t];if(s===this.materialToSwitch){if(e.gameObject instanceof ye)this._objectsWithThisMaterial.push(e.gameObject);else if(e.gameObject instanceof Tn)for(const r of e.gameObject.children)r instanceof ye&&r.material===s&&this._objectsWithThisMaterial.push(r);break}}}}onPointerClick(){if(this.variantMaterial)for(let i=0;i<this._objectsWithThisMaterial.length;i++){const e=this._objectsWithThisMaterial[i];e.material=this.variantMaterial}}async beforeCreateDocument(i,e){this.targetModels=[],Xl._materialTriggersPerId={},Xl.variantSwitchIndex=0,this.materialToSwitch&&await jo.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await jo.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(i,e,t){this._objectsWithThisMaterial.find(s=>s.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(Xl._materialTriggersPerId[this.materialToSwitch.uuid]||(Xl._materialTriggersPerId[this.materialToSwitch.uuid]=[]),Xl._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(i,e){if(!this.materialToSwitch)return;const t=Xl._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const s={};for(const n of t){const o=n.createVariants();o&&o.length>0&&(s[n.selfModel.uuid]=o)}const r=[];for(const n of t){for(const o in s)o!==n.selfModel.uuid&&r.push(s[o]);n.createAndAttachBehaviors(i,s[n.selfModel.uuid],r)}}delete Xl._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(i,e,t){const s=[],r=[],n=Math.max(0,this.fadeDuration);for(const o of this.targetModels){const a=ui.fadeAction(o,n,!1);r.push(a)}for(const o of t)r.push(ui.fadeAction(o,n,!1));for(const o of e)s.push(ui.fadeAction(o,n,!1)),r.push(ui.fadeAction(o,n,!0));i.addBehavior(new Xr("Select "+this.selfModel.name,pn.tapTrigger(this.selfModel),ui.parallel(...r))),i.addBehavior(new Xr("Start hidden "+this.selfModel.name,pn.sceneStartTrigger(),ui.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const i=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name+"_"+Xl.variantSwitchIndex++,t.name=t.name.replace(/\s/g,"_"),t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&ao.createEmptyParent(e),e.parent&&e.parent.add(t),i.push(t)}return i}},h($b,"_materialTriggersPerId",{}),h($b,"variantSwitchIndex",0),$b);let Up=Xl;Pi([x(kt)],Up.prototype,"materialToSwitch",2),Pi([x(kt)],Up.prototype,"variantMaterial",2),Pi([x()],Up.prototype,"fadeDuration",2);class Fp extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"toggleOnClick",!1),h(this,"targetState",!0),h(this,"hideSelf",!0),h(this,"selfModel"),h(this,"otherModel"),h(this,"toggleModel"),h(this,"stateBeforeCreatingDocument",!1)}onPointerClick(){!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(e,t,s){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(e,t){if(this.target){if(this.otherModel=t.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let s=this.hideSelf;this.targetState,this.toggleOnClick&&(s=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&TU.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const r=[];if(s&&r.push(ui.fadeAction(this.selfModel,0,!1)),this.toggleModel&&r.push(ui.fadeAction(this.toggleModel,0,!0)),r.push(ui.fadeAction(this.otherModel,0,this.targetState)),e.addBehavior(new Xr("Toggle_"+this.selfModel.name+"_hideSelf",pn.tapTrigger(this.selfModel),ui.sequence(...r))),this.toggleOnClick&&this.toggleModel){const n=[];n.push(ui.fadeAction(this.toggleModel,0,!1)),n.push(ui.fadeAction(this.selfModel,0,!0)),n.push(ui.fadeAction(this.otherModel,0,!this.targetState)),e.addBehavior(new Xr("Toggle_"+this.selfModel.name+"_toggleSelf",pn.tapTrigger(this.toggleModel),ui.sequence(...n))),e.addBehavior(new Xr("HideOnStart_"+this.gameObject.name,pn.sceneStartTrigger(),ui.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}Pi([x(Re)],Fp.prototype,"target",2),Pi([x()],Fp.prototype,"targetState",2),Pi([x()],Fp.prototype,"hideSelf",2);class YM extends Ie{start(){this.gameObject.visible=!1}createBehaviours(e,t,s){t.uuid===this.gameObject.uuid&&e.addBehavior(new Xr("HideOnStart_"+this.gameObject.name,pn.sceneStartTrigger(),ui.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class Np extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"duration",.5),h(this,"motionType",mE.bounce)}beforeCreateDocument(){}createBehaviours(e,t,s){if(this.target&&t.uuid===this.gameObject.uuid){const r=new Xr("emphasize "+this.name,pn.tapTrigger(this.gameObject),ui.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(r)}}afterCreateDocument(e,t){}}Pi([x()],Np.prototype,"target",2),Pi([x()],Np.prototype,"duration",2),Pi([x()],Np.prototype,"motionType",2);class zp extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"clip",""),h(this,"toggleOnClick",!1)}onPointerClick(){if(!(!this.target&&!this.clip)){if(!this.target){const e=this.gameObject.addNewComponent(As);e&&(e.spatialBlend=1,e.volume=1,e.loop=!1,this.target=e)}this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play()))}}createBehaviours(e,t,s){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r)return;const n=this.target?this.target.gameObject:this.gameObject,o=r.split("/").pop(),a=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?AE.NonSpatial:AE.Spatial,c=new Xr("playAudio "+this.name,pn.tapTrigger(this.gameObject),ui.playAudioAction(n,"audio/"+o,jU.Play,a,l));e.addBehavior(c)}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const s=this.clip?this.clip:this.target?this.target.clip:void 0;if(!s)return;const r=s.split("/").pop(),n=await(await(await fetch(this.clip)).blob()).arrayBuffer(),o=new Uint8Array(n);t.files["audio/"+r]=o}}Pi([x(As)],zp.prototype,"target",2),Pi([x(URL)],zp.prototype,"clip",2),Pi([x()],zp.prototype,"toggleOnClick",2);var KM;const jp=(KM=class extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"animator"),h(this,"stateName"),h(this,"stateNameAfterPlaying"),h(this,"loopAfterPlaying",!1),h(this,"selfModel"),h(this,"stateAnimationModel"),h(this,"stateAnimation"),h(this,"stateAfterPlayingAnimationModel"),h(this,"stateAfterPlayingAnimation")}onPointerClick(){var i;this.target&&this.stateName&&((i=this.animator)==null||i.play(this.stateName,0,0,.1))}createBehaviours(i,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}onAfterHierarchy(){jp.animationActions=[]}afterCreateDocument(i,e){!this.stateAnimation||!this.stateAnimationModel||e.document.traverse(t=>{var s,r;if(t.uuid===((s=this.target)==null?void 0:s.uuid)&&this.stateAnimation){const n=[];let o=jp.animationActions.find(l=>l.affectedObjects==t&&l.start==this.stateAnimation.start&&l.duration==this.stateAnimation.duration);if(o||(o=ui.startAnimationAction(t,this.stateAnimation.start,this.stateAnimation.duration),jp.animationActions.push(o)),n.push(o),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let l=jp.animationActions.find(u=>u.affectedObjects==t&&u.start==this.stateAfterPlayingAnimation.start&&u.duration==this.stateAfterPlayingAnimation.duration);l||(l=ui.startAnimationAction(t,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),jp.animationActions.push(l));const c=ui.sequence(l);this.loopAfterPlaying&&c.makeLooping(),n.push(c)}const a=new Xr("tap "+this.name+" for "+this.stateName+" on "+((r=this.target)==null?void 0:r.name),pn.tapTrigger(this.selfModel),ui.sequence(...n));i.addBehavior(a)}})}createAnimation(i,e,t){var s,r,n,o,a;if(this.target&&this.animator){const l=(r=(s=this.animator)==null?void 0:s.runtimeAnimatorController)==null?void 0:r.findState(this.stateName);if(!((n=l?.motion)!=null&&n.clip)){gi()&&console.warn("No clip found for state "+this.stateName);return}this.stateAnimationModel=e,this.stateAnimation=i.registerAnimation(this.target,l?.motion.clip);const c=(a=(o=this.animator)==null?void 0:o.runtimeAnimatorController)==null?void 0:a.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=e,this.stateAfterPlayingAnimation=i.registerAnimation(this.target,c?.motion.clip)}}},h(KM,"animationActions",[]),KM);let ih=jp;Pi([x(Re)],ih.prototype,"target",2),Pi([x(Cr)],ih.prototype,"animator",2),Pi([x()],ih.prototype,"stateName",2),Pi([x()],ih.prototype,"stateNameAfterPlaying",2),Pi([x()],ih.prototype,"loopAfterPlaying",2);class Qp extends Ie{constructor(){super(...arguments),h(this,"target")}getType(){}getDuration(){}}Pi([x(Re)],Qp.prototype,"target",2);class Ng extends Ie{constructor(){super(...arguments),h(this,"target")}}Pi([x(Qp)],Ng.prototype,"target",2);class zg extends Qp{constructor(){super(...arguments),h(this,"type",1),h(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Pi([x()],zg.prototype,"type",2),Pi([x()],zg.prototype,"duration",2);class JM extends Ng{}var Oie=Object.defineProperty,Lie=Object.getOwnPropertyDescriptor,ql=(i,e,t,s)=>{for(var r=s>1?void 0:s?Lie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Oie(e,t,r),r};class Su extends Ie{constructor(){super(...arguments),h(this,"center",new w(0,0,0)),h(this,"radius",.5),h(this,"height",2),h(this,"_rigidbody",null),h(this,"_activeGroundCollisions")}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Vi),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Vi)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let t=this.gameObject.getComponent(Zc);t||(t=this.gameObject.addNewComponent(Zc)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){for(const t of e.contacts)if(t.normal.y>.1){this._activeGroundCollisions.add(e);break}}onCollisionExit(e){this._activeGroundCollisions.delete(e)}get isGrounded(){return this._activeGroundCollisions.size>0}}ql([x(w)],Su.prototype,"center",2),ql([x()],Su.prototype,"radius",2),ql([x()],Su.prototype,"height",2);class Yl extends Ie{constructor(){super(...arguments),h(this,"controller"),h(this,"movementSpeed",2),h(this,"rotationSpeed",2),h(this,"jumpForce",1),h(this,"doubleJumpForce",2),h(this,"animator"),h(this,"lookForward",!0),h(this,"lookInput",new ee(0,0)),h(this,"moveInput",new ee(0,0)),h(this,"jumpInput",!1),h(this,"_currentSpeed",new w(0,0,0)),h(this,"_currentAngularSpeed",new w(0,0,0)),h(this,"_temp",new w(0,0,0)),h(this,"_jumpCount",0),h(this,"_currentRotation"),h(this,"_raycastOptions",new ko)}awake(){this._currentRotation=new Ee}update(){const e=this.context.input;e.isKeyPressed("KeyW")?this.moveInput.y+=1:e.isKeyPressed("KeyS")&&(this.moveInput.y-=1),e.isKeyPressed("KeyD")?this.lookInput.x+=1:e.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=e.isKeyDown("Space"))}move(e){this.moveInput.add(e)}look(e){this.lookInput.add(e)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(e,t,s){var r,n,o,a,l,c,u,d,p,f,m;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((n=this.animator)==null||n.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(o=this.animator)==null||o.setBool("running",e.length()>.01),(l=this.animator)==null||l.setBool("jumping",((a=this.controller)==null?void 0:a.isGrounded)===!0&&s),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=tt.toRadians(-t.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const A=this.context.mainCameraComponent.forward;A.y=0,A.normalize(),this._currentRotation.setFromUnitVectors(new w(0,0,1),A),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&s&&this.jumpForce>0){let A=(c=this.controller)==null?void 0:c.isGrounded;if(this.doubleJumpForce>0&&!((u=this.controller)!=null&&u.isGrounded)&&this._jumpCount===1&&(A=!0,(d=this.animator)==null||d.setBool("doubleJump",!0)),A){this._jumpCount+=1;const v=this.controller.rigidbody,g=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;v.applyImpulse(new w(0,1,0).multiplyScalar(g))}}if(this.controller){const A=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(A<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new ha),this._raycastOptions.ray.origin.copy(At(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const v=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const g=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(v),(g.length&&g[0].distance>2||A<-10)&&((f=this.animator)==null||f.setBool("falling",!0))}else(m=this.animator)==null||m.setBool("falling",!1)}}}ql([x(Su)],Yl.prototype,"controller",2),ql([x()],Yl.prototype,"movementSpeed",2),ql([x()],Yl.prototype,"rotationSpeed",2),ql([x()],Yl.prototype,"jumpForce",2),ql([x()],Yl.prototype,"doubleJumpForce",2),ql([x(Cr)],Yl.prototype,"animator",2);var Uie=Object.defineProperty,Fie=Object.getOwnPropertyDescriptor,Nie=(i,e,t,s)=>{for(var r=s>1?void 0:s?Fie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Uie(e,t,r),r};class jg extends Tr{constructor(){super(...arguments),h(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new DO;return e.offset=new ee(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=t=>t*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}}Nie([x(Tt)],jg.prototype,"intensity",2),mo("ChromaticAberration",jg);var zie=Object.defineProperty,jie=Object.getOwnPropertyDescriptor,e_=(i,e,t,s)=>{for(var r=s>1?void 0:s?jie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&zie(e,t,r),r};class sh extends Tr{constructor(){super(...arguments),h(this,"postExposure"),h(this,"contrast"),h(this,"hueShift"),h(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=e=>(e=Math.pow(2,e),e),this.postExposure.defaultValue=0,this.contrast.valueProcessor=e=>{let t=1;return e>0?t=200:e<0&&(t=100),e/t},this.contrast.defaultValue=0,this.hueShift.valueProcessor=e=>Math.PI*e/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=e=>e<0?e/100:e/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===Dr&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=Cf);const e=new kO;this.postExposure.onValueChanged=s=>{this.context.renderer.toneMapping===Dr&&(this.context.renderer.toneMapping=Cf),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=s)},this.contrast.onValueChanged=s=>{e.contrast=s};const t=new LO;return this.hueShift.onValueChanged=s=>t.hue=s,this.saturation.onValueChanged=s=>t.saturation=s,[t,e]}}e_([x(Tt)],sh.prototype,"postExposure",2),e_([x(Tt)],sh.prototype,"contrast",2),e_([x(Tt)],sh.prototype,"hueShift",2),e_([x(Tt)],sh.prototype,"saturation",2),mo("ColorAdjustments",sh);const Qie=(Math.sqrt(5)-1)/4,or=(5-Math.sqrt(5))/20,t_=i=>Math.floor(i)|0,i_=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function Gie(i=Math.random){const e=Hie(i),t=new Float64Array(e).map(o=>i_[o%32*4]),s=new Float64Array(e).map(o=>i_[o%32*4+1]),r=new Float64Array(e).map(o=>i_[o%32*4+2]),n=new Float64Array(e).map(o=>i_[o%32*4+3]);return function(o,a,l,c){let u,d,p,f,m;const A=(o+a+l+c)*Qie,v=t_(o+A),g=t_(a+A),b=t_(l+A),y=t_(c+A),_=(v+g+b+y)*or,S=v-_,M=g-_,I=b-_,R=y-_,E=o-S,C=a-M,z=l-I,q=c-R;let Q=0,G=0,$=0,F=0;E>C?Q++:G++,E>z?Q++:$++,E>q?Q++:F++,C>z?G++:$++,C>q?G++:F++,z>q?$++:F++;const L=Q>=3?1:0,N=G>=3?1:0,re=$>=3?1:0,Z=F>=3?1:0,X=Q>=2?1:0,ne=G>=2?1:0,fe=$>=2?1:0,be=F>=2?1:0,Pe=Q>=1?1:0,Fe=G>=1?1:0,We=$>=1?1:0,Je=F>=1?1:0,qe=E-L+or,wt=C-N+or,pe=z-re+or,W=q-Z+or,Ue=E-X+2*or,xe=C-ne+2*or,ve=z-fe+2*or,je=q-be+2*or,ge=E-Pe+3*or,Ke=C-Fe+3*or,nt=z-We+3*or,dt=q-Je+3*or,Xt=E-1+4*or,ii=C-1+4*or,U=z-1+4*or,D=q-1+4*or,ue=v&255,De=g&255,Oe=b&255,H=y&255;let Ae=.6-E*E-C*C-z*z-q*q;if(Ae<0)u=0;else{const we=ue+e[De+e[Oe+e[H]]];Ae*=Ae,u=Ae*Ae*(t[we]*E+s[we]*C+r[we]*z+n[we]*q)}let Me=.6-qe*qe-wt*wt-pe*pe-W*W;if(Me<0)d=0;else{const we=ue+L+e[De+N+e[Oe+re+e[H+Z]]];Me*=Me,d=Me*Me*(t[we]*qe+s[we]*wt+r[we]*pe+n[we]*W)}let de=.6-Ue*Ue-xe*xe-ve*ve-je*je;if(de<0)p=0;else{const we=ue+X+e[De+ne+e[Oe+fe+e[H+be]]];de*=de,p=de*de*(t[we]*Ue+s[we]*xe+r[we]*ve+n[we]*je)}let Xe=.6-ge*ge-Ke*Ke-nt*nt-dt*dt;if(Xe<0)f=0;else{const we=ue+Pe+e[De+Fe+e[Oe+We+e[H+Je]]];Xe*=Xe,f=Xe*Xe*(t[we]*ge+s[we]*Ke+r[we]*nt+n[we]*dt)}let Ye=.6-Xt*Xt-ii*ii-U*U-D*D;if(Ye<0)m=0;else{const we=ue+1+e[De+1+e[Oe+1+e[H+1]]];Ye*=Ye,m=Ye*Ye*(t[we]*Xt+s[we]*ii+r[we]*U+n[we]*D)}return 27*(u+d+p+f+m)}}function Hie(i){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const s=t+~~(i()*(256-t)),r=e[t];e[t]=e[s],e[s]=r}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var Vie=Object.defineProperty,Wie=Object.getOwnPropertyDescriptor,ie=(i,e,t,s)=>{for(var r=s>1?void 0:s?Wie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Vie(e,t,r),r};const s_=le("debugparticles");var Ba=(i=>(i[i.Billboard=0]="Billboard",i[i.Stretch=1]="Stretch",i[i.HorizontalBillboard=2]="HorizontalBillboard",i[i.VerticalBillboard=3]="VerticalBillboard",i[i.Mesh=4]="Mesh",i))(Ba||{});let rh=class{constructor(){h(this,"alphaKeys"),h(this,"colorKeys")}get duration(){return 1}evaluate(i,e){let t,s=0,r=null,n=0;for(let o=0;o<this.alphaKeys.length;o++){const a=this.alphaKeys[o];(a.time<i||!t)&&(t=a,s=o)}for(let o=0;o<this.colorKeys.length;o++){const a=this.colorKeys[o];(a.time<i||!r)&&(r=a,n=o)}if(r)if(n+1<this.colorKeys.length){const o=this.colorKeys[n+1],a=tt.remap(i,r.time,o.time,0,1);e.r=tt.lerp(r.color.r,o.color.r,a),e.g=tt.lerp(r.color.g,o.color.g,a),e.b=tt.lerp(r.color.b,o.color.b,a)}else e.r=r.color.r,e.g=r.color.g,e.b=r.color.b;if(t)if(s+1<this.alphaKeys.length){const o=this.alphaKeys[s+1],a=tt.remap(i,t.time,o.time,0,1);e.alpha=tt.lerp(t.alpha,o.alpha,a)}else e.alpha=t.alpha;return e}};ie([x()],rh.prototype,"alphaKeys",2),ie([x()],rh.prototype,"colorKeys",2);var Qg=(i=>(i[i.Local=0]="Local",i[i.World=1]="World",i[i.Custom=2]="Custom",i))(Qg||{}),n3=(i=>(i[i.Sphere=0]="Sphere",i[i.SphereShell=1]="SphereShell",i[i.Hemisphere=2]="Hemisphere",i[i.HemisphereShell=3]="HemisphereShell",i[i.Cone=4]="Cone",i[i.Box=5]="Box",i[i.Mesh=6]="Mesh",i[i.ConeShell=7]="ConeShell",i[i.ConeVolume=8]="ConeVolume",i[i.ConeVolumeShell=9]="ConeVolumeShell",i[i.Circle=10]="Circle",i[i.CircleEdge=11]="CircleEdge",i[i.SingleSidedEdge=12]="SingleSidedEdge",i[i.MeshRenderer=13]="MeshRenderer",i[i.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",i[i.BoxShell=15]="BoxShell",i[i.BoxEdge=16]="BoxEdge",i[i.Donut=17]="Donut",i[i.Rectangle=18]="Rectangle",i[i.Sprite=19]="Sprite",i[i.SpriteRenderer=20]="SpriteRenderer",i))(n3||{});class ct{constructor(){h(this,"mode"),h(this,"constant"),h(this,"constantMin"),h(this,"constantMax"),h(this,"curve"),h(this,"curveMin"),h(this,"curveMax"),h(this,"curveMultiplier")}evaluate(e,t){const s=t===void 0?Math.random():t;switch(this.mode){case 0:return this.constant;case 1:return e=tt.clamp01(e),this.curve.evaluate(e)*this.curveMultiplier;case 2:const r=e*this.curveMin.duration,n=e*this.curveMax.duration;return tt.lerp(this.curveMin.evaluate(r),this.curveMax.evaluate(n),s%1)*this.curveMultiplier;case 3:return tt.lerp(this.constantMin,this.constantMax,s%1);default:this.curveMax.evaluate(e)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(e){if(!e)return 0;let t=Number.MIN_VALUE;for(let s=0;s<e.keys.length;s++){const r=e.keys[s];r.value>t&&(t=r.value)}return t}}ie([x()],ct.prototype,"mode",2),ie([x()],ct.prototype,"constant",2),ie([x()],ct.prototype,"constantMin",2),ie([x()],ct.prototype,"constantMax",2),ie([x(du)],ct.prototype,"curve",2),ie([x(du)],ct.prototype,"curveMin",2),ie([x(du)],ct.prototype,"curveMax",2),ie([x()],ct.prototype,"curveMultiplier",2);var r_;const Ko=(r_=class{constructor(){h(this,"mode"),h(this,"color"),h(this,"colorMin"),h(this,"colorMax"),h(this,"gradient"),h(this,"gradientMin"),h(this,"gradientMax")}evaluate(i,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(i,Ko._temp),Ko._temp;case 2:return Ko._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(i,Ko._temp),this.gradientMax.evaluate(i,Ko._temp2),Ko._temp.lerp(Ko._temp2,t)}return Ko._temp.set(16711935),Ko._temp.alpha=1,Ko._temp}},h(r_,"_temp",new Ai(0,0,0,1)),h(r_,"_temp2",new Ai(0,0,0,1)),r_);let vn=Ko;ie([x(Ai)],vn.prototype,"color",2),ie([x(Ai)],vn.prototype,"colorMin",2),ie([x(Ai)],vn.prototype,"colorMax",2),ie([x(rh)],vn.prototype,"gradient",2),ie([x(rh)],vn.prototype,"gradientMin",2),ie([x(rh)],vn.prototype,"gradientMax",2);var ZM=(i=>(i[i.Hierarchy=0]="Hierarchy",i[i.Local=1]="Local",i[i.Shape=2]="Shape",i))(ZM||{});class ar{constructor(){h(this,"cullingMode"),h(this,"duration"),h(this,"emitterVelocityMode"),h(this,"flipRotation"),h(this,"gravityModifier"),h(this,"gravityModifierMultiplier"),h(this,"loop"),h(this,"maxParticles"),h(this,"playOnAwake"),h(this,"prewarm"),h(this,"ringBufferLoopRange"),h(this,"ringBufferMode"),h(this,"scalingMode"),h(this,"simulationSpace"),h(this,"simulationSpeed"),h(this,"startColor"),h(this,"startDelay"),h(this,"startDelayMultiplier"),h(this,"startLifetime"),h(this,"startLifetimeMultiplier"),h(this,"startRotation"),h(this,"startRotationMultiplier"),h(this,"startRotation3D"),h(this,"startRotationX"),h(this,"startRotationXMultiplier"),h(this,"startRotationY"),h(this,"startRotationYMultiplier"),h(this,"startRotationZ"),h(this,"startRotationZMultiplier"),h(this,"startSize"),h(this,"startSize3D"),h(this,"startSizeMultiplier"),h(this,"startSizeX"),h(this,"startSizeXMultiplier"),h(this,"startSizeY"),h(this,"startSizeYMultiplier"),h(this,"startSizeZ"),h(this,"startSizeZMultiplier"),h(this,"startSpeed"),h(this,"startSpeedMultiplier"),h(this,"stopAction"),h(this,"useUnscaledTime")}}ie([x(ct)],ar.prototype,"gravityModifier",2),ie([x(vn)],ar.prototype,"startColor",2),ie([x(ct)],ar.prototype,"startDelay",2),ie([x(ct)],ar.prototype,"startLifetime",2),ie([x(ct)],ar.prototype,"startRotation",2),ie([x(ct)],ar.prototype,"startRotationX",2),ie([x(ct)],ar.prototype,"startRotationY",2),ie([x(ct)],ar.prototype,"startRotationZ",2),ie([x(ct)],ar.prototype,"startSize",2),ie([x(ct)],ar.prototype,"startSizeX",2),ie([x(ct)],ar.prototype,"startSizeY",2),ie([x(ct)],ar.prototype,"startSizeZ",2),ie([x(ct)],ar.prototype,"startSpeed",2);class Gg{constructor(){h(this,"cycleCount"),h(this,"maxCount"),h(this,"minCount"),h(this,"probability"),h(this,"repeatInterval"),h(this,"time"),h(this,"count"),h(this,"_performed",0)}reset(){this._performed=0}run(e){if(e<=this.time)return 0;let t=0;if(this.cycleCount===0||this._performed<this.cycleCount){const s=this.time+this.repeatInterval*this._performed;if(e>=s&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:t=this.count.constant;break;case 3:t=tt.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:t=this.count.curve.evaluate(Math.random());break;case 2:const r=Math.random();t=tt.lerp(this.count.curveMin.evaluate(r),this.count.curveMax.evaluate(r),Math.random());break}}return t}}class ka{constructor(){h(this,"enabled"),h(this,"bursts"),h(this,"rateOverTime"),h(this,"rateOverTimeMultiplier"),h(this,"rateOverDistance"),h(this,"rateOverDistanceMultiplier"),h(this,"system")}get burstCount(){var e;return((e=this.bursts)==null?void 0:e.length)??0}reset(){var e;(e=this.bursts)==null||e.forEach(t=>t.reset())}getBurst(){let e=0;if(this.burstCount>0)for(let t=0;t<this.burstCount;t++){const s=this.bursts[t];this.system.main.loop&&s.time>=this.system.time&&s.reset(),e+=Math.round(s.run(this.system.time))}return e}}ie([x()],ka.prototype,"enabled",2),ie([x()],ka.prototype,"bursts",2),ie([x(ct)],ka.prototype,"rateOverTime",2),ie([x()],ka.prototype,"rateOverTimeMultiplier",2),ie([x(ct)],ka.prototype,"rateOverDistance",2),ie([x()],ka.prototype,"rateOverDistanceMultiplier",2);class Hg{constructor(){h(this,"enabled"),h(this,"color")}}ie([x(vn)],Hg.prototype,"color",2);class nh{constructor(){h(this,"enabled"),h(this,"separateAxes"),h(this,"size"),h(this,"sizeMultiplier"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier"),h(this,"_time",0),h(this,"_temp",new w)}evaluate(e,t,s){if(t||(t=this._temp),!this.enabled)return t.x=t.y=t.z=1,t;if(this.separateAxes)t.x=this.x.evaluate(e,s)*this.xMultiplier,t.y=this.y.evaluate(e,s)*this.yMultiplier,t.z=this.z.evaluate(e,s)*this.zMultiplier;else{const r=this.size.evaluate(e,s)*this.sizeMultiplier;t.x=r}return t}}ie([x(ct)],nh.prototype,"size",2),ie([x(ct)],nh.prototype,"x",2),ie([x(ct)],nh.prototype,"y",2),ie([x(ct)],nh.prototype,"z",2);var n_;const Vg=(n_=class{constructor(){h(this,"shapeType",5),h(this,"enabled",!0),h(this,"alignToDirection",!1),h(this,"angle",0),h(this,"arc",360),h(this,"arcSpread"),h(this,"arcSpeedMultiplier"),h(this,"arcMode"),h(this,"boxThickness"),h(this,"position"),h(this,"rotation"),h(this,"_rotation",new Es),h(this,"scale"),h(this,"radius"),h(this,"radiusThickness"),h(this,"sphericalDirectionAmount"),h(this,"randomDirectionAmount"),h(this,"randomPositionAmount"),h(this,"system"),h(this,"_space"),h(this,"_worldSpaceMatrix",new Be),h(this,"_worldSpaceMatrixInverse",new Be),h(this,"_vector",new w(0,0,0)),h(this,"_temp",new w(0,0,0)),h(this,"_dir",new w),h(this,"_loopTime",0),h(this,"_loopDirection",1),s_&&console.log(this)}get type(){return n3[this.shapeType]}initialize(i){this.getPosition(),i.position.copy(this._vector)}toJSON(){return this}clone(){return new Vg}update(i,e,t,s){this.system=i,this._space=t,t===1&&(this._worldSpaceMatrix.copy(s.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(i){const e=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return e&&(this._rotation.x=tt.toRadians(this.rotation.x),this._rotation.y=tt.toRadians(this.rotation.y),this._rotation.z=tt.toRadians(this.rotation.z),this._rotation.order="ZYX",i.applyEuler(this._rotation)),e}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const i=this._temp.copy(this.position),e=this._space===1;e&&i.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:s_&&Ml.DrawBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(i);break;case 4:this.randomConePoint(this.position,this.angle,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),e&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),s_&&Ml.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(i){var e;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const t=i.x,s=i.y,r=i.z;this._dir.set(t,s,r),(e=this.system)!=null&&e.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),s_&&(Ml.DrawSphere(i,.01,8925952,.5,!0),Ml.DrawDirection(i,this._dir,8925952,.5,!0)),this._dir}randomizePosition(i,e){if(e<=0)return;const t=Vg._tempVec;t.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),t.x*=e*this.scale.x,t.y*=e*this.scale.y,t.z*=e*this.scale.z,i.add(t)}randomizeDirection(i,e){if(e===0)return;const t=Vg._randomQuat,s=Vg._tempVec;s.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(s,e*Math.random()*Math.PI),i.applyQuaternion(t)}spherizeDirection(i,e){if(e===0)return;const t=Math.random()*Math.PI*2,s=Math.acos(1-Math.random()*2),r=Math.sin(s)*Math.cos(t),n=Math.sin(s)*Math.sin(t),o=Math.cos(s),a=new w(r,n,o);i.lerp(a,e)}randomSpherePoint(i,e,t,s,r){const n=Math.random(),o=Math.random(),a=2*Math.PI*n*(s/360),l=Math.acos(2*o-1),c=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,u=i.x+this.scale.x*(-c*Math.sin(l)*Math.cos(a)),d=i.y+this.scale.y*(c*Math.sin(l)*Math.sin(a)),p=i.z+this.scale.z*(c*Math.cos(l));r.x=u,r.y=d,r.z=p}randomCirclePoint(i,e,t,s,r){const n=Math.random(),o=2*Math.PI*n*(s/360),a=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,l=i.x+this.scale.x*a*Math.cos(o),c=i.y+this.scale.y*a*Math.sin(o),u=i.z;r.x=l,r.y=c,r.z=u}randomConePoint(i,e,t,s,r,n,o){let a=0,l=0;switch(n){case 0:a=Math.random(),l=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:a=.5,l=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let c=2*Math.PI*a*(r/360);switch(n){case 2:case 1:c+=Math.PI+.5,c+=this._loopTime*Math.PI*2,c%=tt.toRadians(r);break}const u=Math.acos(2*l-1),d=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),s)*t,p=i.x+-d*Math.sin(u)*Math.cos(c),f=i.y+d*Math.sin(u)*Math.sin(c),m=i.z;o.x=p*this.scale.x,o.y=f*this.scale.y,o.z=m*this.scale.z}},h(n_,"_randomQuat",new Ee),h(n_,"_tempVec",new w),n_);let cs=Vg;ie([x()],cs.prototype,"shapeType",2),ie([x()],cs.prototype,"enabled",2),ie([x()],cs.prototype,"alignToDirection",2),ie([x()],cs.prototype,"angle",2),ie([x()],cs.prototype,"arc",2),ie([x()],cs.prototype,"arcSpread",2),ie([x()],cs.prototype,"arcSpeedMultiplier",2),ie([x()],cs.prototype,"arcMode",2),ie([x(w)],cs.prototype,"boxThickness",2),ie([x(w)],cs.prototype,"position",2),ie([x(w)],cs.prototype,"rotation",2),ie([x(w)],cs.prototype,"scale",2),ie([x()],cs.prototype,"radius",2),ie([x()],cs.prototype,"radiusThickness",2),ie([x()],cs.prototype,"sphericalDirectionAmount",2),ie([x()],cs.prototype,"randomDirectionAmount",2),ie([x()],cs.prototype,"randomPositionAmount",2);class mi{constructor(){h(this,"damping"),h(this,"enabled"),h(this,"frequency"),h(this,"octaveCount"),h(this,"octaveMultiplier"),h(this,"octaveScale"),h(this,"positionAmount"),h(this,"quality"),h(this,"remap"),h(this,"remapEnabled"),h(this,"remapMultiplier"),h(this,"remapX"),h(this,"remapXMultiplier"),h(this,"remapY"),h(this,"remapYMultiplier"),h(this,"remapZ"),h(this,"remapZMultiplier"),h(this,"scrollSpeedMultiplier"),h(this,"separateAxes"),h(this,"strengthMultiplier"),h(this,"strengthX"),h(this,"strengthXMultiplier"),h(this,"strengthY"),h(this,"strengthYMultiplier"),h(this,"strengthZ"),h(this,"strengthZMultiplier"),h(this,"_noise"),h(this,"_time",0),h(this,"_temp",new w)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,s,r,n,o){if(!this.enabled)return;this._noise||(this._noise=Gie(()=>0));const a=this._temp.set(t.x,t.y,t.z).multiplyScalar(this.frequency),l=this._noise(a.x,a.y,a.z,this._time),c=this._noise(a.x,a.y,a.z,this._time+1e3*this.frequency),u=this._noise(a.x,a.y,a.z,this._time+2e3*this.frequency);this._temp.set(l,c,u).normalize();const d=n/o;let p=this.positionAmount.evaluate(d);this.separateAxes?(this._temp.x*=p*this.strengthXMultiplier,this._temp.y*=p*this.strengthYMultiplier,this._temp.z*=p*this.strengthZMultiplier):(this.strengthX&&(p*=this.strengthX.evaluate(d)*1.5),this._temp.multiplyScalar(p)),s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z}}ie([x()],mi.prototype,"damping",2),ie([x()],mi.prototype,"enabled",2),ie([x()],mi.prototype,"frequency",2),ie([x()],mi.prototype,"octaveCount",2),ie([x()],mi.prototype,"octaveMultiplier",2),ie([x()],mi.prototype,"octaveScale",2),ie([x(ct)],mi.prototype,"positionAmount",2),ie([x()],mi.prototype,"quality",2),ie([x(ct)],mi.prototype,"remap",2),ie([x()],mi.prototype,"remapEnabled",2),ie([x()],mi.prototype,"remapMultiplier",2),ie([x(ct)],mi.prototype,"remapX",2),ie([x()],mi.prototype,"remapXMultiplier",2),ie([x(ct)],mi.prototype,"remapY",2),ie([x()],mi.prototype,"remapYMultiplier",2),ie([x(ct)],mi.prototype,"remapZ",2),ie([x()],mi.prototype,"remapZMultiplier",2),ie([x()],mi.prototype,"scrollSpeedMultiplier",2),ie([x()],mi.prototype,"separateAxes",2),ie([x()],mi.prototype,"strengthMultiplier",2),ie([x(ct)],mi.prototype,"strengthX",2),ie([x()],mi.prototype,"strengthXMultiplier",2),ie([x(ct)],mi.prototype,"strengthY",2),ie([x()],mi.prototype,"strengthYMultiplier",2),ie([x(ct)],mi.prototype,"strengthZ",2),ie([x()],mi.prototype,"strengthZMultiplier",2);class Ui{constructor(){h(this,"enabled"),h(this,"attachRibbonToTransform",!1),h(this,"colorOverLifetime"),h(this,"colorOverTrail"),h(this,"dieWithParticles",!0),h(this,"inheritParticleColor",!0),h(this,"lifetime"),h(this,"lifetimeMultiplier"),h(this,"minVertexDistance",.2),h(this,"mode",0),h(this,"ratio",1),h(this,"ribbonCount",1),h(this,"shadowBias",0),h(this,"sizeAffectsLifetime",!1),h(this,"sizeAffectsWidth",!1),h(this,"splitSubEmitterRibbons",!1),h(this,"textureMode",0),h(this,"widthOverTrail"),h(this,"widthOverTrailMultiplier"),h(this,"worldSpace",!1)}getWidth(e,t,s,r){const n=this.widthOverTrail.evaluate(s,r);return e*=n,e}getColor(e,t,s){const r=this.colorOverTrail.evaluate(s),n=this.colorOverLifetime.evaluate(t);e.x*=r.r*n.r,e.y*=r.g*n.g,e.z*=r.b*n.b,e.w*=r.alpha*n.alpha}}ie([x()],Ui.prototype,"enabled",2),ie([x()],Ui.prototype,"attachRibbonToTransform",2),ie([x(vn)],Ui.prototype,"colorOverLifetime",2),ie([x(vn)],Ui.prototype,"colorOverTrail",2),ie([x()],Ui.prototype,"dieWithParticles",2),ie([x()],Ui.prototype,"inheritParticleColor",2),ie([x(ct)],Ui.prototype,"lifetime",2),ie([x()],Ui.prototype,"lifetimeMultiplier",2),ie([x()],Ui.prototype,"minVertexDistance",2),ie([x()],Ui.prototype,"mode",2),ie([x()],Ui.prototype,"ratio",2),ie([x()],Ui.prototype,"ribbonCount",2),ie([x()],Ui.prototype,"shadowBias",2),ie([x()],Ui.prototype,"sizeAffectsLifetime",2),ie([x()],Ui.prototype,"sizeAffectsWidth",2),ie([x()],Ui.prototype,"splitSubEmitterRibbons",2),ie([x()],Ui.prototype,"textureMode",2),ie([x(ct)],Ui.prototype,"widthOverTrail",2),ie([x()],Ui.prototype,"widthOverTrailMultiplier",2),ie([x()],Ui.prototype,"worldSpace",2);class Wi{constructor(){h(this,"enabled"),h(this,"space",0),h(this,"orbitalX"),h(this,"orbitalY"),h(this,"orbitalZ"),h(this,"orbitalXMultiplier"),h(this,"orbitalYMultiplier"),h(this,"orbitalZMultiplier"),h(this,"orbitalOffsetX"),h(this,"orbitalOffsetY"),h(this,"orbitalOffsetZ"),h(this,"speedModifier"),h(this,"speedModifierMultiplier"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier"),h(this,"_system"),h(this,"_temp",new w),h(this,"_temp2",new w),h(this,"_temp3",new w),h(this,"_hasOrbital",!1),h(this,"_index",0),h(this,"_orbitalMatrix",new Be)}update(e){this._system=e}init(e){this._index==0&&(e.debug=!0),this._index+=1,e.orbitx=this.orbitalX.evaluate(Math.random()),e.orbity=this.orbitalY.evaluate(Math.random()),e.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=e.orbitx!=0||e.orbity!=0||e.orbitz!=0}apply(e,t,s,r,n,o,a){var l;if(!this.enabled)return;const c=o/a,u=this.speedModifier.evaluate(c)*this.speedModifierMultiplier,d=this.x.evaluate(c),p=this.y.evaluate(c),f=this.z.evaluate(c);if(this._temp.set(-d,p,f),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((l=this._system)==null?void 0:l.worldPos)){const m=this._temp2.set(s.x,s.y,s.z),A=this.orbitalXMultiplier,v=this.orbitalYMultiplier,g=this.orbitalZMultiplier,b=u*Math.PI*2*10,y=Math.cos(b*A),_=Math.sin(b*A),S=Math.cos(b*v),M=Math.sin(b*v),I=Math.cos(b*g),R=Math.sin(b*g),E=m.x*(S*I)+m.y*(S*R)+m.z*-M,C=m.x*(_*M*I-y*R)+m.y*(_*M*R+y*I)+m.z*(_*S),z=m.x*(y*M*I+_*R)+m.y*(y*M*R-_*I)+m.z*(y*S),q=this._temp3.set(m.x-E,m.y-C,m.z-z);q.normalize(),q.multiplyScalar(.2/n*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),r.x+=q.x,r.y+=q.y,r.z+=q.z}r.x+=this._temp.x,r.y+=this._temp.y,r.z+=this._temp.z,r.x*=u,r.y*=u,r.z*=u}}ie([x()],Wi.prototype,"enabled",2),ie([x()],Wi.prototype,"space",2),ie([x(ct)],Wi.prototype,"orbitalX",2),ie([x(ct)],Wi.prototype,"orbitalY",2),ie([x(ct)],Wi.prototype,"orbitalZ",2),ie([x()],Wi.prototype,"orbitalXMultiplier",2),ie([x()],Wi.prototype,"orbitalYMultiplier",2),ie([x()],Wi.prototype,"orbitalZMultiplier",2),ie([x()],Wi.prototype,"orbitalOffsetX",2),ie([x()],Wi.prototype,"orbitalOffsetY",2),ie([x()],Wi.prototype,"orbitalOffsetZ",2),ie([x(ct)],Wi.prototype,"speedModifier",2),ie([x()],Wi.prototype,"speedModifierMultiplier",2),ie([x(ct)],Wi.prototype,"x",2),ie([x()],Wi.prototype,"xMultiplier",2),ie([x(ct)],Wi.prototype,"y",2),ie([x()],Wi.prototype,"yMultiplier",2),ie([x(ct)],Wi.prototype,"z",2),ie([x()],Wi.prototype,"zMultiplier",2);class lr{constructor(){h(this,"animation"),h(this,"enabled"),h(this,"cycleCount"),h(this,"frameOverTime"),h(this,"frameOverTimeMultiplier"),h(this,"numTilesX"),h(this,"numTilesY"),h(this,"startFrame"),h(this,"startFrameMultiplier"),h(this,"rowMode"),h(this,"rowIndex"),h(this,"spriteCount"),h(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(e){if(!this.sampleOnceAtStart())return this.getIndex(e)}getIndex(e){const t=this.numTilesX*this.numTilesY;e=e*this.cycleCount;let s=this.frameOverTime.evaluate(e%1);return s*=this.frameOverTimeMultiplier,s*=t,s=s%t,s=Math.floor(s),s}}ie([x()],lr.prototype,"animation",2),ie([x()],lr.prototype,"enabled",2),ie([x()],lr.prototype,"cycleCount",2),ie([x(ct)],lr.prototype,"frameOverTime",2),ie([x()],lr.prototype,"frameOverTimeMultiplier",2),ie([x()],lr.prototype,"numTilesX",2),ie([x()],lr.prototype,"numTilesY",2),ie([x(ct)],lr.prototype,"startFrame",2),ie([x()],lr.prototype,"startFrameMultiplier",2),ie([x()],lr.prototype,"rowMode",2),ie([x()],lr.prototype,"rowIndex",2),ie([x()],lr.prototype,"spriteCount",2),ie([x()],lr.prototype,"timeMode",2);class go{constructor(){h(this,"enabled"),h(this,"separateAxes"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier")}evaluate(e,t){return this.enabled?this.separateAxes?0:this.z.evaluate(e,t)*-1:0}}ie([x()],go.prototype,"enabled",2),ie([x()],go.prototype,"separateAxes",2),ie([x(ct)],go.prototype,"x",2),ie([x()],go.prototype,"xMultiplier",2),ie([x(ct)],go.prototype,"y",2),ie([x()],go.prototype,"yMultiplier",2),ie([x(ct)],go.prototype,"z",2),ie([x()],go.prototype,"zMultiplier",2);class Qn{constructor(){h(this,"enabled"),h(this,"range"),h(this,"separateAxes"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier")}evaluate(e,t){if(!this.enabled)return 0;if(!this.separateAxes){const s=tt.lerp(this.range.x,this.range.y,t);return this.z.evaluate(s)*-1}return 0}}ie([x()],Qn.prototype,"enabled",2),ie([x()],Qn.prototype,"range",2),ie([x()],Qn.prototype,"separateAxes",2),ie([x(ct)],Qn.prototype,"x",2),ie([x()],Qn.prototype,"xMultiplier",2),ie([x(ct)],Qn.prototype,"y",2),ie([x()],Qn.prototype,"yMultiplier",2),ie([x(ct)],Qn.prototype,"z",2),ie([x()],Qn.prototype,"zMultiplier",2);class xs{constructor(){h(this,"enabled"),h(this,"dampen"),h(this,"drag"),h(this,"dragMultiplier"),h(this,"limit"),h(this,"limitMultiplier"),h(this,"separateAxes"),h(this,"limitX"),h(this,"limitXMultiplier"),h(this,"limitY"),h(this,"limitYMultiplier"),h(this,"limitZ"),h(this,"limitZMultiplier"),h(this,"multiplyDragByParticleSize",!1),h(this,"multiplyDragByParticleVelocity",!1),h(this,"space"),h(this,"_temp",new w),h(this,"_temp2",new w)}apply(e,t,s,r,n,o,a){if(this.enabled){const l=this.limit.evaluate(n)*this.limitMultiplier;if(t.length()>l){this._temp.copy(t).normalize().multiplyScalar(l);const c=this.dampen*.5;t.x=tt.lerp(t.x,this._temp.x,c),t.y=tt.lerp(t.y,this._temp.y,c),t.z=tt.lerp(t.z,this._temp.z,c),s.x=tt.lerp(s.x,this._temp.x,c),s.y=tt.lerp(s.y,this._temp.y,c),s.z=tt.lerp(s.z,this._temp.z,c)}}}}ie([x()],xs.prototype,"enabled",2),ie([x()],xs.prototype,"dampen",2),ie([x(ct)],xs.prototype,"drag",2),ie([x()],xs.prototype,"dragMultiplier",2),ie([x(ct)],xs.prototype,"limit",2),ie([x()],xs.prototype,"limitMultiplier",2),ie([x()],xs.prototype,"separateAxes",2),ie([x(ct)],xs.prototype,"limitX",2),ie([x()],xs.prototype,"limitXMultiplier",2),ie([x(ct)],xs.prototype,"limitY",2),ie([x()],xs.prototype,"limitYMultiplier",2),ie([x(ct)],xs.prototype,"limitZ",2),ie([x()],xs.prototype,"limitZMultiplier",2),ie([x()],xs.prototype,"multiplyDragByParticleSize",2),ie([x()],xs.prototype,"multiplyDragByParticleVelocity",2),ie([x()],xs.prototype,"space",2);class oh{constructor(){h(this,"enabled"),h(this,"curve"),h(this,"curveMultiplier"),h(this,"mode"),h(this,"system"),h(this,"_lastWorldPosition"),h(this,"_velocity",new w),h(this,"_temp",new w)}update(e){this.enabled&&this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(e){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const t=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(t),e.add(this._temp)}}applyCurrent(e,t,s){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const r=this.curve.evaluate(t,s);this._temp.copy(this._velocity).multiplyScalar(r),e.add(this._temp)}}}ie([x()],oh.prototype,"enabled",2),ie([x(ct)],oh.prototype,"curve",2),ie([x()],oh.prototype,"curveMultiplier",2),ie([x()],oh.prototype,"mode",2);class Jr{constructor(){h(this,"enabled"),h(this,"range"),h(this,"separateAxes"),h(this,"size"),h(this,"sizeMultiplier"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier")}evaluate(e,t,s,r){const n=e.length(),o=tt.remap(n,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,s);return r*a}}ie([x()],Jr.prototype,"enabled",2),ie([x(ee)],Jr.prototype,"range",2),ie([x()],Jr.prototype,"separateAxes",2),ie([x(ct)],Jr.prototype,"size",2),ie([x()],Jr.prototype,"sizeMultiplier",2),ie([x(ct)],Jr.prototype,"x",2),ie([x()],Jr.prototype,"xMultiplier",2),ie([x(ct)],Jr.prototype,"y",2),ie([x()],Jr.prototype,"yMultiplier",2),ie([x(ct)],Jr.prototype,"z",2),ie([x()],Jr.prototype,"zMultiplier",2);class Cu{constructor(){h(this,"enabled"),h(this,"range"),h(this,"color")}evaluate(e,t,s){const r=e.length(),n=tt.remap(r,this.range.x,this.range.y,0,1),o=this.color.evaluate(n,t);s.x*=o.r,s.y*=o.g,s.z*=o.b,s.w*=o.alpha}}ie([x()],Cu.prototype,"enabled",2),ie([x(ee)],Cu.prototype,"range",2),ie([x(vn)],Cu.prototype,"color",2);function o3(i){const e=i.domElement.shadowRoot.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const s=document.createElement("button");s.id="open-in-ar",s.innerText="Open in QuickLook",t.appendChild(s);const r=document.createElement("a");r.id="needle-usdz-link",r.style.display="none",r.rel="ar",r.href="",t.appendChild(r);const n=document.createElement("img");return n.id="button",r.appendChild(n),i.domElement.shadowRoot.appendChild(t),r}function Xie(){var i=new Date;const e=i.getMonth()+1,t=i.getDate(),s=i.getHours(),r=i.getMinutes(),n=i.getSeconds(),o=(e<10?"0":"")+e,a=(t<10?"0":"")+t,l=(s<10?"0":"")+s,c=(r<10?"0":"")+r,u=(n<10?"0":"")+n;return i.getFullYear()+o+a+"-"+l+c+u}const o_=le("debugusdz");function qie(i,e){const t=[],s=se.getComponentsInChildren(i,Cr),r=se.getComponentsInChildren(i,Bn);let n=!1;const o=new Fr("rest",.01,[]),a=new Map,l=(c,u)=>{if(!n&&u.tracks.length>0&&(n=!0,c.push(o)),u.tracks.length>0)for(const d of u.tracks){const p=Ot.parseTrackName(d.name),f=Ot.findNode(i,p.nodeName);if(f){a.has(f)||a.set(f,[]);const m=a.get(f);switch(p.propertyName){case"position":{if(m.includes("position"))continue;const A=f.position,v=new an(d.name,[0,.01],[A.x,A.y,A.z,A.x,A.y,A.z]);m.push("position"),o.tracks.push(v);break}case"quaternion":{if(m.includes("quaternion"))continue;const A=f.quaternion,v=new an(d.name,[0,.01],[A.x,A.y,A.z,A.w,A.x,A.y,A.z,A.w]);m.push("quaternion"),o.tracks.push(v);break}case"scale":{if(m.includes("scale"))continue;const A=f.scale,v=new an(d.name,[0,.01],[A.x,A.y,A.z,A.x,A.y,A.z]);m.push("scale"),o.tracks.push(v);break}}}}};for(const c of s){if(!c||!c.runtimeAnimatorController)continue;o_&&console.log(c);const u=[];for(const d of c.runtimeAnimatorController.enumerateActions()){o_&&console.log(d);const p=d.getClip();l(u,p),u.includes(p)||u.push(p)}t.push({root:c.gameObject,clips:u})}for(const c of r){o_&&console.log(c);const u=[];for(const d of c.animations)l(u,d),u.includes(d)||u.push(d);t.push({root:c.gameObject,clips:u})}o_&&(console.log("Rest Pose Clip",o),console.log("USDZ Animation Clips",t));for(const c of t)for(const u of c.clips)e.registerAnimation(c.root,u)}var Yie=Object.defineProperty,Kie=Object.getOwnPropertyDescriptor,Kl=(i,e,t,s)=>{for(var r=s>1?void 0:s?Kie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Yie(e,t,r),r};const Eu=le("debugtext");var Ls=(i=>(i[i.UpperLeft=0]="UpperLeft",i[i.UpperCenter=1]="UpperCenter",i[i.UpperRight=2]="UpperRight",i[i.MiddleLeft=3]="MiddleLeft",i[i.MiddleCenter=4]="MiddleCenter",i[i.MiddleRight=5]="MiddleRight",i[i.LowerLeft=6]="LowerLeft",i[i.LowerCenter=7]="LowerCenter",i[i.LowerRight=8]="LowerRight",i))(Ls||{}),a3=(i=>(i[i.Normal=0]="Normal",i[i.Bold=1]="Bold",i[i.Italic=2]="Italic",i[i.BoldAndItalic=3]="BoldAndItalic",i))(a3||{});class Zr extends _u{constructor(){super(...arguments),h(this,"alignment",0),h(this,"verticalOverflow",0),h(this,"horizontalOverflow",0),h(this,"lineSpacing",1),h(this,"supportRichText",!1),h(this,"font"),h(this,"fontStyle",0),h(this,"_text",""),h(this,"_fontSize",12),h(this,"_textMeshUi",null),h(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(e){var t;super.setAlphaFactor(e),(t=this.uiObject)==null||t.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(e){e!==this._text&&(this._text=e,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(e){this.text=e}get fontSize(){return this._fontSize}set fontSize(e){var t;this._fontSize=e,(t=this.uiObject)==null||t.set({fontSize:e})}onColorChanged(){var e;(e=this.uiObject)==null||e.set({color:this.color,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeRender(){var e;this.uiObject&&((e=this.Canvas)!=null&&e.screenspace||this.context.isInVR)&&this.updateOverflow()}updateOverflow(){var e;const t=(e=this.uiObject)==null?void 0:e._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(e){Eu&&console.log(this),this.horizontalOverflow==1&&(e.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,e.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,e.lineHeight=this.lineSpacing,delete e.backgroundOpacity,delete e.backgroundColor,Eu&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),Eu&&(e.backgroundColor=Math.random()*16777215,e.backgroundOpacity=.1),this.uiObject=t.createNewText(e),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const e=this.fontSize,t={color:this.color,fontOpacity:this.color.alpha,fontSize:e,fontKerning:"normal"};return this.setFont(t,this.fontStyle),t}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}getAlignment(e){switch(e.flexDirection="column",this.alignment){case 0:case 3:case 6:e.textAlign="left";break;case 1:case 4:case 7:e.textAlign="center";break;case 2:case 5:case 8:e.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:e.alignItems="start";break;case 3:case 4:case 5:e.alignItems="center";break;case 6:case 7:case 8:e.alignItems="end";break}return e}feedText(e,t){var s,r,n;if(Eu&&console.log("feedText",this.uiObject,e,t),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!t||e.length===0)this.uiObject.textContent=e;else{let o=this.getNextTag(e);if(o){if(o.startIndex>0){for(let c=this.uiObject.children.length-1;c>=0;c--){const u=this.uiObject.children[c];u.isUI&&(this.uiObject.remove(u),u.clear())}const l=new Bb({textContent:e.substring(0,o.startIndex),color:"inherit"});this.uiObject.add(l)}}else{this.uiObject.textContent="",this.setOptions({textContent:e});return}const a=[];for(;o;){const l=this.getNextTag(e,o.endIndex),c={fontFamily:(s=this.uiObject)==null?void 0:s.get("fontFamily"),color:"inherit",textContent:""};if(l){c.textContent=this.getText(e,o,l),this.handleTag(o,c,a);const u=new Bb(c);(r=this.uiObject)==null||r.add(u)}else{c.textContent=e.substring(o.endIndex),this.handleTag(o,c,a);const u=new Bb(c);(n=this.uiObject)==null||n.add(u)}o=l}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const e=[],t=this.canvas,s={renderOnTop:t.renderOnTop,depthWrite:t.depthWrite,doubleSided:t.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let n=0;n<this._textMeshUi.length;n++){if(e[n]===!0)continue;r=!0;const o=this._textMeshUi[n];o.textContent&&(Nb(o,s),e[n]=!0)}if(!r)break;yield}}handleTag(e,t,s){if(!e.isEndTag){if(e.type.includes("color")){const r=new $M(e,{color:t.color});if(s.push(r),e.type.length>6){const n=parseInt("0x"+e.type.substring(7));t.color=n}else t.color=new _e(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const r=new $M(e,{fontWeight:700});s.push(r)}else if(e.type=="i"){this.setFont(t,2);const r=new $M(e,{fontStyle:"italic"});s.push(r)}}}getText(e,t,s){return e.substring(t.endIndex,s.startIndex)}getNextTag(e,t=0){const s=e.indexOf("<",t),r=e.indexOf(">",s);if(s>=0&&r>=0){const n=e.substring(s+1,r);return{type:n,startIndex:s,endIndex:r+1,isEndTag:n.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;const s=this.font,r=this.getFamilyNameWithCorrectSuffix(s,t);Eu&&console.log("Selected font family:"+r);let n=AM.getFontFamily(r);switch(n||(n=AM.addFontFamily(r)),e.fontFamily=n,t){default:case 0:e.fontWeight=400,e.fontStyle="normal";break;case 1:e.fontWeight=700,e.fontStyle="normal";break;case 2:e.fontWeight=400,e.fontStyle="italic";break;case 3:e.fontStyle="italic",e.fontWeight=400}let o=n.getVariant(e.fontWeight,e.fontStyle);if(!o){let a=r;a!=null&&a.endsWith("-msdf.json")||(a+="-msdf.json");let l=r;l!=null&&l.endsWith(".png")||(l+=".png"),o=n.addVariant(e.fontWeight,e.fontStyle,a,l),o?.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(e,t){var s;const r=e.lastIndexOf("-");if(r<0)return e;const n=(s=e.substring(r+1))==null?void 0:s.toLowerCase();if(Jie.includes(n))return Eu&&console.warn("Unsupported font style: "+n),e;const o=e.lastIndexOf("/");let a=e;o>=0&&(a=a.substring(o+1));const l=a[0]===a[0].toUpperCase(),c=e.substring(0,r);switch(Eu&&console.log("Select font: ",e,a3[t],a,l,c),t){case 0:return l?c+"-Regular":c+"-regular";case 1:return l?c+"-Bold":c+"-bold";case 2:return l?c+"-Italic":c+"-italic";case 3:return l?c+"-BoldItalic":c+"-bolditalic";default:return e}}}Kl([x()],Zr.prototype,"alignment",2),Kl([x()],Zr.prototype,"verticalOverflow",2),Kl([x()],Zr.prototype,"horizontalOverflow",2),Kl([x()],Zr.prototype,"lineSpacing",2),Kl([x()],Zr.prototype,"supportRichText",2),Kl([x(URL)],Zr.prototype,"font",2),Kl([x()],Zr.prototype,"fontStyle",2),Kl([x()],Zr.prototype,"text",1),Kl([x()],Zr.prototype,"fontSize",1);class $M{constructor(e,t){h(this,"tag"),h(this,"previousValues"),this.tag=e,this.previousValues=t}}const Jie=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class ah{constructor(e){h(this,"id"),h(this,"content",""),h(this,"font",[]),h(this,"pointSize",144),h(this,"width"),h(this,"height"),h(this,"depth"),h(this,"wrapMode"),h(this,"horizontalAlignment"),h(this,"verticalAlignment"),h(this,"material"),this.id=e}static getId(){return this.global_id++}setDepth(e){return this.depth=e,this}setPointSize(e){return this.pointSize=e,this}setHorizontalAlignment(e){return this.horizontalAlignment=e,this}setVerticalAlignment(e){return this.verticalAlignment=e,this}writeTo(e,t){var s;t.beginBlock(`def Preliminary_Text "${this.id}"`),this.content&&t.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(s=this.font)==null||s.push("sans-serif"));const r=this.font.map(n=>`"${n}"`).join(", ");t.appendLine(`string[] font = [ ${r} ]`),t.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&t.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&t.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&t.appendLine(`double depth = ${this.depth}`),this.wrapMode&&t.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&t.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&t.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&t.appendLine(`rel material:binding = </Materials/Material_${this.material.id}>`),t.closeBlock()}}h(ah,"global_id",0);class a_{static singleLine(e,t,s){const r=new ah("text_"+ah.getId());return r.content=e,t&&(r.pointSize=t),s&&(r.depth=s),r}static multiLine(e,t,s,r,n,o){const a=new ah("text_"+ah.getId());return a.content=e,a.width=t,a.height=s,a.horizontalAlignment=r,a.verticalAlignment=n,o!==void 0&&(a.wrapMode=o),a}}const Zie=new Be().makeRotationY(Math.PI),$ie=new Be().makeScale(-1,1,-1);class Wg{get extensionName(){return"text"}onExportObject(e,t,s){}exportText(e,t,s){const r=se.getComponent(e,Zr);if(!r)return;const n=se.getComponent(e,Kr);let o=100,a=100;n&&(o=n.width,a=n.height),t.matrix=Zie.clone(),n&&t.matrix.premultiply($ie);const l=new _e().copySRGBToLinear(r.color);t.material=new Ro({color:l,emissive:l}),t.addEventListener("serialize",(c,u)=>{let d=r.text;d=d.replace(/\n/g,"\\n");const p=a_.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(p,r.alignment),this.setOverflow(p,r),t.material&&(p.material=t.material),p.pointSize=this.convertToTextSize(r.fontSize),p.depth=.001,p.writeTo(void 0,c)})}convertToTextSize(e){return 1/.0502*144*e}setOverflow(e,t){t.horizontalOverflow?e.wrapMode="singleLine":e.wrapMode="flowing"}setTextAlignment(e,t){switch(t){case Ls.LowerLeft:case Ls.MiddleLeft:case Ls.UpperLeft:e.horizontalAlignment="left";break;case Ls.LowerCenter:case Ls.MiddleCenter:case Ls.UpperCenter:e.horizontalAlignment="center";break;case Ls.LowerRight:case Ls.MiddleRight:case Ls.UpperRight:e.horizontalAlignment="right";break}switch(t){case Ls.LowerLeft:case Ls.LowerCenter:case Ls.LowerRight:e.verticalAlignment="bottom";break;case Ls.MiddleLeft:case Ls.MiddleCenter:case Ls.MiddleRight:e.verticalAlignment="middle";break;case Ls.UpperLeft:case Ls.UpperCenter:case Ls.UpperRight:e.verticalAlignment="top";break}}}class l_{get extensionName(){return"tmui"}onExportObject(e,t,s){const r=se.getComponent(e,nr);if(r&&r.activeAndEnabled&&r.renderMode===s3.WorldSpace){const n=new Wg,o=se.getComponent(e,Kr),a=se.getComponent(e,th);if(o){o.width,o.height;const l=ao.createEmpty(),c=o.shadowComponent;if(t.add(l),c){const u=c.matrix;l.matrix.copy(u);const d=new Map,p=new Map;d.set(c,l),p.set(c,a?a.alpha:1),c.traverse(f=>{if(f===c)return;const m=ao.createEmpty();m.matrix.copy(f.matrix);const A=f.parent,v=A&&typeof A.textContent=="string"&&A.textContent.length;let g=p.get(A)||1;const b=se.getComponent(f,th);if(b&&(g*=b.alpha),f instanceof ye&&v){const _=f[Ma].gameObject;n.exportText(_,m,s)}if(f instanceof ye&&!v){const _=f.geometry.clone();_.scale(1,1,-1),this.flipWindingOrder(_),m.geometry=_;const S=new _e,M=f.material.opacity;S.copy(f.material.color),m.material=new li({color:S,opacity:M*g,map:f.material.map,transparent:!0})}d.set(f,m),p.set(f,g);const y=d.get(A);if(!y){console.error("Error when exporting UI: shadow component parent not found!",f,f.parent);return}y.add(m)})}}}}flipWindingOrder(e){const t=e.index.array;for(let s=0,r=t.length/3;s<r;s++){const n=t[s*3];t[s*3]=t[s*3+2],t[s*3+2]=n}e.index.needsUpdate=!0}}var ese=Object.defineProperty,tse=Object.getOwnPropertyDescriptor,Gn=(i,e,t,s)=>{for(var r=s>1?void 0:s?tse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ese(e,t,r),r};const Us=le("debugusdz");class lh{constructor(){h(this,"callToAction"),h(this,"checkoutTitle"),h(this,"checkoutSubtitle"),h(this,"callToActionURL")}}Gn([x()],lh.prototype,"callToAction",2),Gn([x()],lh.prototype,"checkoutTitle",2),Gn([x()],lh.prototype,"checkoutSubtitle",2),Gn([x()],lh.prototype,"callToActionURL",2);class Hn extends Ie{constructor(){super(...arguments),h(this,"objectToExport"),h(this,"autoExportAnimations",!1),h(this,"exportFileName"),h(this,"customUsdzFile"),h(this,"customBranding"),h(this,"anchoringType","plane"),h(this,"planeAnchoringAlignment","horizontal"),h(this,"interactive",!0),h(this,"extensions",[]),h(this,"allowCreateQuicklookButton",!0),h(this,"link"),h(this,"webxr"),h(this,"onClickedOpenInARElement",e=>{e.preventDefault(),this.exportAsync()}),h(this,"lastCallback"),h(this,"_quicklookButton"),h(this,"_quicklookButtonContainer",null)}start(){var e,t,s;Us&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",r=>{switch(r.key){case"t":this.exportAsync();break}}),Ka()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((t=(e=this.objectToExport)==null?void 0:e.children)!=null&&t.length)&&!((s=this.objectToExport)!=null&&s.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Xb),this.extensions.push(new Vb),this.extensions.push(new Wg),this.extensions.push(new l_))}onEnable(){var e;const t=_f(),s=Ja();(Us||t&&s)&&((Us||this.allowCreateQuicklookButton)&&this.addQuicklookButton(),this.lastCallback=this.quicklookCallback.bind(this),this.link=o3(this.context),this.link.addEventListener("message",this.lastCallback)),Us&&fs("USDZ Exporter enabled: "+this.name),(e=document.getElementById("open-in-ar"))==null||e.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var e,t;(e=this.link)==null||e.removeEventListener("message",this.lastCallback);const s=_f(),r=Ja();(Us||s&&r)&&this.removeQuicklookButton(),Us&&fs("USDZ Exporter disabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var e;let t=this.exportFileName??((e=this.objectToExport)==null?void 0:e.name)??this.name;if(Kd()||(t!==""&&(t+="-"),t+="MadeWithNeedle"),t+="-"+Xie(),this.link||(this.link=o3(this.context)),this.customUsdzFile){Us&&console.log("Exporting custom usdz",this.customUsdzFile);const v=this.buildQuicklookOverlay();Us&&console.log("QuickLook Overlay",v);const g=v.callToAction?encodeURIComponent(v.callToAction):"",b=v.checkoutTitle?encodeURIComponent(v.checkoutTitle):"",y=v.checkoutSubtitle?encodeURIComponent(v.checkoutSubtitle):"";this.link.href=this.customUsdzFile+`#callToAction=${g}&checkoutTitle=${b}&checkoutSubtitle=${y}&callToActionURL=${v.callToActionURL}`,Us&&console.log(this.link.href),this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click();return}if(!this.objectToExport){console.warn("No object to export",this);return}const s=se.getComponentsInChildren(this.objectToExport,Di),r=new Array;for(const v of s)for(const g of v.sharedMaterials)if(g){const b=v.loadProgressiveTextures(g);b instanceof Promise&&r.push(b)}Us&&fs("Load textures: "+r.length),await Promise.all(r),Us&&fs("Load textures: done");const n=kn.Global.Mask;kn.Global.Set(as.AR),this.applyWebARSessionRoot();const o=new q7,a=[...this.extensions],l=new ib;a.push(l),this.autoExportAnimations&&qie(this.objectToExport,l);const c={self:this,exporter:o,extensions:a,object:this.objectToExport};this.dispatchEvent(new CustomEvent("before-export",{detail:c})),o.debug=Us,this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal");const u=await o.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:a,quickLookCompatible:!0}),d=new Blob([u],{type:"application/octet-stream"});this.dispatchEvent(new CustomEvent("after-export",{detail:c}));const p=this.buildQuicklookOverlay();Us&&console.log("QuickLook Overlay",p);const f=p.callToAction?encodeURIComponent(p.callToAction):"",m=p.checkoutTitle?encodeURIComponent(p.checkoutTitle):"",A=p.checkoutSubtitle?encodeURIComponent(p.checkoutSubtitle):"";this.link.href=URL.createObjectURL(d)+`#callToAction=${f}&checkoutTitle=${m}&checkoutSubtitle=${A}&callToActionURL=${p.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click(),Us&&console.log("USDZ generation done. Downloading as "+this.link.download),kn.Global.Set(n)}quicklookCallback(e){if(e?.data=="_apple_ar_quicklook_button_tapped"){Us&&Nr("Quicklook closed via call to action button");var t=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(t),!t.defaultPrevented){const s=new URLSearchParams(this.link.href);if(s){const r=s.get("callToActionURL");Us&&fs("Quicklook url: "+r),r&&(Kd()?globalThis.open(r,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",r))}}}}buildQuicklookOverlay(){var e,t,s,r,n,o;const a={};return this.customBranding&&Object.assign(a,this.customBranding),Kd()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),a.callToAction="Close",a.checkoutTitle="\u{1F335} Made with Needle",a.checkoutSubtitle="_"),(((e=a.callToAction)==null?void 0:e.length)||((t=a.checkoutTitle)==null?void 0:t.length)||((s=a.checkoutSubtitle)==null?void 0:s.length))&&((r=a.callToAction)!=null&&r.length||(a.callToAction="\0"),(n=a.checkoutTitle)!=null&&n.length||(a.checkoutTitle="\0"),(o=a.checkoutSubtitle)!=null&&o.length||(a.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:a})),a}async createQuicklookButton(){var e,t;if(!this.webxr)if(await bf(1),this.webxr=se.findObjectOfType(Ct)??void 0,this.webxr)if(this.webxr.VRButton&&((e=this.webxr.VRButton.parentElement)==null||e.removeChild(this.webxr.VRButton)),this.webxr.ARButton&&this._quicklookButton!==this.webxr.ARButton){this._quicklookButton=this.webxr.ARButton;const s=(t=this.webxr.ARButton.parentElement)==null?void 0:t.querySelector("a");s&&(s.href=""),this.webxr.ARButton.innerText="Open in Quicklook",this.webxr.ARButton.disabled=!1,this.webxr.ARButton.addEventListener("click",r=>{r.preventDefault(),this.exportAsync()}),this.webxr.ARButton.classList.add("quicklook-ar-button"),this._quicklookButtonContainer=this.webxr.ARButton.parentElement,this.dispatchEvent(new CustomEvent("created-button",{detail:this.webxr.ARButton}))}else{this.webxr.createARButton=!1,this.webxr.createVRButton=!1;let s=this.context.domElement.shadowRoot.querySelector(".webxr-buttons");s||(s=document.createElement("div"),s.classList.add("webxr-buttons"));const r=document.createElement("button");r.innerText="Open in Quicklook",r.addEventListener("click",()=>{this.exportAsync()}),r.classList.add("webxr-ar-button"),r.classList.add("webxr-button"),r.classList.add("quicklook-ar-button"),this._quicklookButton=r,s.appendChild(r),this._quicklookButtonContainer=s,this.dispatchEvent(new CustomEvent("created-button",{detail:r}))}else console.warn("Could not find WebXR component: will not create Quicklook button",zt.Current)}async addQuicklookButton(){await this.createQuicklookButton(),this._quicklookButton&&this._quicklookButtonContainer&&this._quicklookButtonContainer.appendChild(this._quicklookButton)}removeQuicklookButton(){var e;(e=this._quicklookButton)==null||e.remove()}applyWebARSessionRoot(){if(!this.objectToExport)return;let e=se.getComponentInParent(this.objectToExport,xa);const t=e!=null;if(e||(e=se.getComponentInChildren(this.objectToExport,xa)),Us&&console.log("applyWebARSessionRoot",e),!e){Us&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const s=t?this.objectToExport:e.gameObject,r=1/e.arScale;Us&&console.log("AR Session Root scale",r,s),s.matrix.makeScale(r,r,r),e.invertForward&&s.matrix.multiply(new Be().makeRotationY(Math.PI))}}Gn([x(Re)],Hn.prototype,"objectToExport",2),Gn([x()],Hn.prototype,"autoExportAnimations",2),Gn([x()],Hn.prototype,"exportFileName",2),Gn([x(URL)],Hn.prototype,"customUsdzFile",2),Gn([x(lh)],Hn.prototype,"customBranding",2),Gn([x()],Hn.prototype,"anchoringType",2),Gn([x()],Hn.prototype,"planeAnchoringAlignment",2),Gn([x()],Hn.prototype,"interactive",2),Gn([x()],Hn.prototype,"allowCreateQuicklookButton",2);const l3=le("debugdeletable");class c_ extends _a{}class eT extends Ie{constructor(){super(...arguments),h(this,"deleteBoxes",[])}awake(){this.deleteBoxes=se.findObjectsOfType(c_,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const s=se.getComponentInParent(this.gameObject,fp);s?l3&&console.warn("Can not delete object with usage marker",this.guid,s):(l3&&console.log("DESTROY",this.gameObject),oy(this.gameObject,this.context.connection))}}}}var ise=Object.defineProperty,sse=Object.getOwnPropertyDescriptor,Mu=(i,e,t,s)=>{for(var r=s>1?void 0:s?sse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ise(e,t,r),r};class Jo extends Tr{constructor(){super(...arguments),h(this,"mode"),h(this,"focusDistance"),h(this,"focalLength"),h(this,"aperture"),h(this,"gaussianMaxRadius"),h(this,"resolutionScale"),h(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=t=>{const s=t/300,r=2;return tt.lerp(r,.01,s)};const e=20;this.aperture.valueProcessor=t=>{const s=1-t/32;return tt.lerp(1,e,s)}}onCreateEffect(){if(this.mode===0)return;const e=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let s=1;Ka()&&(s=.6),this.resolutionScale=new Tt(s*e)}const t=new OO(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=s=>{t.circleOfConfusionMaterial.worldFocusDistance=s},this.focalLength.onValueChanged=s=>t.circleOfConfusionMaterial.worldFocusRange=s,this.aperture.onValueChanged=s=>t.bokehScale=s,this.resolutionScale&&(this.resolutionScale.onValueChanged=s=>t.resolution.scale=s),[t]}unapply(){}}Mu([x()],Jo.prototype,"mode",2),Mu([x(Tt)],Jo.prototype,"focusDistance",2),Mu([x(Tt)],Jo.prototype,"focalLength",2),Mu([x(Tt)],Jo.prototype,"aperture",2),Mu([x(Tt)],Jo.prototype,"gaussianMaxRadius",2),Mu([x(Tt)],Jo.prototype,"resolutionScale",2),Mu([x(Tt)],Jo.prototype,"bokehScale",2),mo("DepthOfField",Jo);var rse=Object.defineProperty,nse=Object.getOwnPropertyDescriptor,ose=(i,e,t,s)=>{for(var r=s>1?void 0:s?nse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&rse(e,t,r),r};class h_ extends Ie{constructor(){super(...arguments),h(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||se.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:Ka()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}ose([x()],h_.prototype,"visibleOn",2);class tT{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var ase=Object.defineProperty,lse=Object.getOwnPropertyDescriptor,c3=(i,e,t,s)=>{for(var r=s>1?void 0:s?lse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ase(e,t,r),r},h3=(i=>(i.SelectStart="selectstart",i.SelectEnd="selectend",i))(h3||{}),u_;const ch=(u_=class extends pp{constructor(){super(),h(this,"showGizmo",!0),h(this,"useViewAngle",!0),h(this,"transformSelf",!0),h(this,"orbit",null),h(this,"selectStartEventListener",[]),h(this,"selectEndEventListener",[]),h(this,"_dragHelper",null),h(this,"_draggingRigidbodies",[]),h(this,"_waitingForDragStart",null),h(this,"_isDragging",!1),h(this,"_marker",null),h(this,"_dragDelta"),h(this,"_didDrag",!1),h(this,"_activePointerId"),this.selectStartEventListener=[],this.selectEndEventListener=[],this._dragDelta=new ee}static get HasAnySelected(){return this._active>0}addDragEventListener(i,e){switch(i){case"selectstart":this.selectStartEventListener.push(e);break;case"selectend":this.selectEndEventListener.push(e);break}}start(){this.orbit=se.findObjectOfType(Gl,this.context),this.gameObject.getComponentInParent(zl)||this.gameObject.addNewComponent(zl)}allowEdit(i=null){return this.context.connection.allowEditing}onPointerEnter(i){if(!this.allowEdit(this.gameObject)||Ct.IsInWebXR)return;const e=se.getComponentInParent(i.object,ch);!e||e!==this||(ch.lastHovered=i.object,this.context.domElement.style.cursor="pointer")}onPointerExit(i){this.allowEdit(this.gameObject)&&(Ct.IsInWebXR||ch.lastHovered===i.object&&(this.context.domElement.style.cursor="auto"))}onPointerDown(i){this.allowEdit(this.gameObject)&&(Ct.IsInWebXR||(ch._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=i.clone(),i.stopPropagation(),this.orbit&&(this.orbit.enabled=!1)))}onPointerUp(i){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(ch._active>0&&(ch._active-=1),!Ct.IsInWebXR&&(this.onDragEnd(i),i.stopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){var i;if(!Ct.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){const t=this.context.input.getPointerPositionDelta(0);if(t&&this._dragDelta.add(t),this._dragDelta.length()>2)this._didDrag=!0;else return}const e=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(e)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),(((i=this._dragHelper)==null?void 0:i.hasSelected)===!1||this._activePointerId!==void 0&&this.context.input.getPointerPressed(this._activePointerId)===!1)&&this.onDragEnd(null)}}onDragStart(i){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new d3(this.context.mainCamera);else return;if(!i||!i.object)return;const e=se.getComponentInParent(i.object,ch);if(!e||e!==this)return;let t=i.object;this.transformSelf&&(t=this.gameObject);const s={selected:t,attached:t};for(const a of this.selectStartEventListener)a(this,s);if(this._activePointerId=i.pointerId,!s.attached)return;s.attached,t=s.attached,this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);const r=se.getComponentInChildren(t,Yc);r&&(r.fastMode=!0,r?.requestOwnership()),this._marker=se.addNewComponent(t,fp),this._draggingRigidbodies.length=0;const n=se.getComponentsInChildren(t,Vi);n&&this._draggingRigidbodies.push(...n);const o=Jv();se.invokeOnChildren(this._dragHelper.selected,o("onDragStart"))}onUpdateDrag(){if(this._dragHelper){this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.useViewAngle=this.useViewAngle,this._dragHelper.onUpdate(this.context);for(const i of this._draggingRigidbodies)i.wakeUp(),i.resetVelocities()}}onDragEnd(i){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const s of this._draggingRigidbodies)s.setVelocity(s.smoothedVelocity);this._draggingRigidbodies.length=0;const e=this._dragHelper.selected;if(this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),i!=null&&i.object){const s=se.getComponentInChildren(i.object,Yc);s&&(s.fastMode=!1)}this._marker&&this._marker.destroy();for(const s of this.selectEndEventListener)s(this);const t=Jv();se.invokeOnChildren(e,t("onDragEnd"))}},h(u_,"_active",0),h(u_,"lastHovered"),u_);let Gp=ch;c3([x()],Gp.prototype,"showGizmo",2),c3([x()],Gp.prototype,"useViewAngle",2);const u3=class{constructor(i){h(this,"showGizmo",!0),h(this,"useViewAngle",!0),h(this,"_selected",null),h(this,"_context",null),h(this,"_camera"),h(this,"_cameraPlane",new eo),h(this,"_hasGroundPlane",!1),h(this,"_groundPlane",new eo),h(this,"_groundOffset",new w),h(this,"_groundOffsetFactor",0),h(this,"_groundDistance",0),h(this,"_groundPlanePoint",new w),h(this,"_raycaster",new Ld),h(this,"_cameraPlaneOffset",new w),h(this,"_intersection",new w),h(this,"_worldPosition",new w),h(this,"_inverseMatrix",new Be),h(this,"_rbs",[]),h(this,"_groundLine"),h(this,"_groundMarker"),h(this,"_groundOffsetVector",new w(0,1,0)),h(this,"_requireUpdateGroundPlane",!0),h(this,"_didDragOnGroundPlaneLastFrame",!1),this._camera=i;const e=new ss(u3.geometry),t=e.material;t.color=new _e(.4,.4,.4),e.layers.set(2),e.name="line",e.scale.y=1,this._groundLine=e;const s=new xo(.5,22,22),r=new li({color:t.color}),n=new ye(s,r);n.visible=!1,n.layers.set(2),this._groundMarker=n}get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}setSelected(i,e){if(this._selected&&e)for(const t of this._rbs)t.wakeUp(),t.setVelocity(0,0,0);if(this._selected&&qr.Remove(e,this._selected),this._selected=i,this._context=e,this._rbs.length=0,i?(e.scene.add(this._groundLine),e.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!e){console.error("DragHelper: no context");return}qr.Add(e,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}onUpdate(i){var e,t,s,r,n;if(!this._context)return;const o="Space",a="KeyD",l=((e=this._context)==null?void 0:e.input.isKeyPressed(o))||((t=this._context)==null?void 0:t.input.isKeyPressed(a)),c=this._context.input.getTouchesPressedCount()>=2||l;if(c){const d=this._context.input.getPointerPositionDelta(0);d&&(this._groundOffsetVector.set(0,1,0),(s=this._selected)==null||s.rotateOnWorldAxis(this._groundOffsetVector,d.x*this._context.time.deltaTime))}const u=this._context.input.getPointerPositionRC(0);if(u&&(this._raycaster.setFromCamera(u,this._camera),this._selected)){this._groundOffsetVector.set(0,1,0);const d=At(this._camera).clone().sub(At(this._selected)).normalize(),p=Math.abs(d.dot(this._groundOffsetVector)),f=((r=this._context)==null?void 0:r.input.isKeyPressed(o))||((n=this._context)==null?void 0:n.input.isKeyPressed(a));let m=!this.useViewAngle||p>.2;(c||f||this._context.input.getPointerPressedCount()>1)&&(m=!1);const A=this._didDragOnGroundPlaneLastFrame!==m;if(this._didDragOnGroundPlaneLastFrame=m,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!m||A)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){const v=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=v,m){this._groundOffsetVector.set(0,1,0);const g=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(g,this._groundPlanePoint,!1),this.onDidUpdate();return}}else this._groundPlanePoint.set(0,99999,0);A&&this.onUpdateScreenSpacePlane(),this._requireUpdateGroundPlane=!0,this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&(this.onUpdateWorldPosition(this._intersection.sub(this._cameraPlaneOffset),this._groundPlanePoint,!0),this.onDidUpdate())}}onUpdateWorldPosition(i,e,t){if(this._selected){if(t){const s=At(this._selected);s.y=i.y,i=s}if(ns(this._selected,i),ns(this._groundLine,i),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundLine.visible=this.showGizmo,this._groundMarker.visible=e!==null&&this.showGizmo,e){const s=At(this._camera).distanceTo(e)*.01;this._groundMarker.scale.set(s,s,s),ns(this._groundMarker,e)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;const i=this._context.input.getPointerPositionRC(0);i&&(this._raycaster.setFromCamera(i,this._camera),this._cameraPlane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._cameraPlane.normal),this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld)),this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._cameraPlaneOffset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))))}onUpdateGroundPlane(){if(!this._selected||!this._context)return;const i=At(this._selected),e=new ha(new w(0,.1,0).add(i),new w(0,-1,0)),t=new ko;t.ignore=[this._selected];const s=this._context.physics.raycastFromRay(e,t);for(let r=0;r<s.length;r++){const n=s[r];if(!n.face||this.contains(this._selected,n.object))continue;const o=new w(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(o,n.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(e.direction.multiplyScalar(-1),e.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(i),this._groundOffset.copy(this._intersection).sub(i)}onDidUpdate(){_n.markDirty(this._selected);for(const i of this._rbs)i.wakeUp(),i.resetForcesAndTorques(),i.setAngularVelocity(0,0,0)}contains(i,e){if(i===e)return!0;if(i.children){for(const t of i.children)if(this.contains(t,e))return!0}return!1}};let d3=u3;h(d3,"geometry",new gt().setFromPoints([new w(0,0,0),new w(0,-1,0)]));function iT(i,e,t){console.warn("Adding components on object has been temporarily disabled")}var p3=(i=>(i.File_Spawned="file-spawned",i))(p3||{});class f3{constructor(e,t,s,r,n,o,a,l){h(this,"guid"),h(this,"file_name"),h(this,"file_hash"),h(this,"file_size"),h(this,"position"),h(this,"seed"),h(this,"sender"),h(this,"serverUrl"),h(this,"parentGuid"),h(this,"boundsSize"),this.seed=t,this.guid=s,this.file_name=r,this.file_hash=n,this.file_size=o,this.position=a,this.sender=e,this.serverUrl=l}}async function m3(i,e,t){const s=i.name;return s.endsWith(".gltf")||s.endsWith(".glb")?new Promise((r,n)=>{const o=new FileReader;o.readAsArrayBuffer(i),o.onloadend=async a=>{const l=o.result,c=ay(),u=new tn(c),d=await Lo().parseSync(e,l,i.name,u);if(d&&d.scene){const p=d.scene;if(!p.guid){const f=new tn(c);p.guid=f.generateUUID()}t&&cse(e.connection,i,c,p,t),iT(),r(d)}}}):(console.warn("Unsupported file type: "+s,i),null)}async function g3(i,e){return new Promise(async(t,s)=>{const r=ay(),n=new tn(r),o=i.toString(),a=await Lo().loadSync(e,o,o,n);a&&a.scene?(a.scene,iT(),t(a)):console.warn("Unsupported file type: "+i.toString())})}Ti.registerCallback(kr.ContextCreated,i=>{v3(i.context)});function v3(i){i.connection.beginListen("file-spawned",async e=>{if(e.sender!==i.connection.connectionId){console.log("received file event",e),hse(e,i);let t=null;try{t=await fC(e.file_name,e.file_hash,e.file_size,e.serverUrl)}finally{use(e)}if(t){const s=new tn(e.seed),r=await Lo().parseSync(i,t,e.file_name,s);if(r&&r.scene){const n=r.scene;if(iT(),e.parentGuid){const o=Im(e.parentGuid,i.scene);o&&"add"in o&&o.add(n)}n.parent||i.scene.add(n),e.position!==null&&n.position.copy(e.position)}}else console.error("download didnt return file")}})}async function cse(i,e,t,s,r){if(!i.connectionId){console.error("Can not upload file - no connection id");return}if(!s.guid){console.error("Can not upload file - no guid",s,s.guid);return}const n=await $O(e,r);if(!n)return;if(!n.filename){console.error("Can not send upload event - no filename",e.name);return}if(!n.hash){console.error("Can not send upload event - no hash",e.name);return}const o=new f3(i.connectionId,t,s.guid,n.filename,n.hash,e.size,s.position,n.url??r);s.parent&&(o.parentGuid=s.parent.guid),i.send("file-spawned",o)}const sT={};function hse(i,e){const t=new yi,s=new ye(t,new li({color:65280})),r=new P0(s,5592405);if(sT[i.guid]=r,e.scene.add(r),i.parentGuid){const n=Im(i.parentGuid,e.scene);n&&n.add(r)}i.position&&r.position.copy(i.position)}function use(i,e){const t=i.guid,s=sT[t];s&&(delete sT[t],s.removeFromParent())}var dse=Object.defineProperty,pse=Object.getOwnPropertyDescriptor,rT=(i,e,t,s)=>{for(var r=s>1?void 0:s?pse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&dse(e,t,r),r};const fse=le("debugnet"),nT=class extends Ie{constructor(){super(...arguments),h(this,"url",null),h(this,"urlParameterName",null),h(this,"localhost",null)}awake(){fse&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let i=this.url?nT.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const t=le(this.urlParameterName);t&&typeof t=="string"&&(i=t)}if(!i)return null;const e=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(i);return e!=null&&e.groups?e?.groups.socket_prefix?i:"wss://"+e?.groups.url:null}static GetUrl(i,e){let t=i;const s=nT.IsLocalNetwork()&&e;if(s&&(t=e),i!=null&&i.startsWith("/")){const r=s?t:window.location.origin;r!=null&&r.endsWith("/")&&i.startsWith("/")&&(i=i.substring(1)),t=r+i}return t}static IsLocalNetwork(i=window.location.hostname){return Br(i)}};let Tu=nT;rT([x()],Tu.prototype,"url",2),rT([x()],Tu.prototype,"urlParameterName",2),rT([x()],Tu.prototype,"localhost",2);var mse=Object.defineProperty,gse=Object.getOwnPropertyDescriptor,A3=(i,e,t,s)=>{for(var r=s>1?void 0:s?gse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&mse(e,t,r),r};const Hp=le("debugdroplistener");class Xg extends Ie{constructor(){super(...arguments),h(this,"filesBackendUrl"),h(this,"localhost"),h(this,"onDrag",e=>{e.preventDefault()}),h(this,"onDrop",async e=>{if(Hp&&console.log(e),!(e!=null&&e.dataTransfer))return;e.preventDefault();const t=e.dataTransfer.items;if(t)for(const s in t){const r=t[s];if(r.kind==="file"){const n=r.getAsFile();if(!n)continue;await this.addFiles(n)}else r.kind==="string"&&r.type=="text/plain"&&r.getAsString(async n=>{Hp&&console.log("dropped url",n);try{const o=new URL(n);if(!o)return;const a=await g3(o,this.context);a&&this.addObject(e,a)}catch{console.log("dropped string is not a valid URL!",n)}})}})}onEnable(){this.filesBackendUrl=Tu.GetUrl(this.filesBackendUrl,this.localhost)??this.filesBackendUrl,Hp&&console.log(this,this.filesBackendUrl),this.context.domElement.addEventListener("dragover",this.onDrag),this.context.domElement.addEventListener("drop",this.onDrop)}onDisable(){this.context.domElement.removeEventListener("dragover",this.onDrag),this.context.domElement.removeEventListener("drop",this.onDrop)}async addFiles(...e){if(Hp&&console.log("Add files",e),!!Array.isArray(e)&&e.length)for(const t of e){if(!t)continue;Hp&&console.log("Register file "+t.name+" to",this.filesBackendUrl,t);const s=await m3(t,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:t})),s&&this.addObject(void 0,s)}}async addObject(e,t){if(Hp&&console.log("Dropped",t),!(t!=null&&t.scene)){console.warn("No object specified to add to scene",t);return}const s=t.scene;if(e!==void 0){const r=new ko;r.setMask(16777215),r.screenPointFromOffset(e.offsetX,e.offsetY);const n=this.context.physics.raycast(r);if(n&&n.length>0)for(const o of n){s.position.copy(o.point);break}}this.gameObject.add(s),this.dispatchEvent(new CustomEvent("object-added",{detail:t}))}}A3([x()],Xg.prototype,"filesBackendUrl",2),A3([x()],Xg.prototype,"localhost",2);var vse=Object.defineProperty,Ase=Object.getOwnPropertyDescriptor,d_=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ase(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&vse(e,t,r),r};class Iu extends pp{constructor(){super(...arguments),h(this,"parent",null),h(this,"object",null),h(this,"limitCount",10),h(this,"limitInterval",60),h(this,"_currentCount",0),h(this,"_startPosition",null),h(this,"_startQuaternion",null)}awake(){var e,t;if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=((e=this.object.position)==null?void 0:e.clone())??new w(0,0,0),this._startQuaternion=((t=this.object.quaternion)==null?void 0:t.clone())??new Ee(0,0,0,1)}const s=se.getComponentInParent(this.gameObject,Gp);s?s.addDragEventListener(h3.SelectStart,(r,n)=>{if(this._currentCount>=this.limitCount){n.attached=null;return}const o=this.handleDuplication(n.selected);o&&(console.assert(o!==n.selected,"Duplicated object is original"),n.attached=o)}):console.warn("Could no find drag controls in parent",this.name),bs.addEventListener(Fl.SelectStart,(r,n)=>{if(this._currentCount>=this.limitCount){n.grab=null;return}const o=this.handleDuplication(n.selected);o&&(n.grab=o)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(e){var t;if(this._currentCount>=this.limitCount||!this.object)return null;if(e===this.gameObject||this.handleMultiObject(e)){if(this.object===this.gameObject)return null;this.object.visible=!0,this._startPosition&&this.object.position.copy(this._startPosition),this._startQuaternion&&this.object.quaternion.copy(this._startQuaternion);const s=new ga;this.parent||(this.parent=this.gameObject.parent),this.parent&&(s.parent=this.parent.guid??((t=this.parent.userData)==null?void 0:t.guid),s.keepWorldPosition=!0),s.position=this.worldPosition,s.rotation=this.worldQuaternion,s.context=this.context,this._currentCount+=1;const r=se.instantiateSynced(this.object,s);return console.assert(r!==this.object,"Duplicated object is original"),this.object.visible=!1,this._startPosition&&this.object.position.clone().copy(this._startPosition),this._startQuaternion&&this.object.quaternion.clone().copy(this._startQuaternion),r}return null}handleMultiObject(e){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,e):!1}isInChildren(e,t){if(!e)return!1;if(e===t)return!0;if(e.children){for(const s of e.children)if(this.isInChildren(s,t))return!0}return!1}}d_([x(Re)],Iu.prototype,"parent",2),d_([x(Re)],Iu.prototype,"object",2),d_([x()],Iu.prototype,"limitCount",2),d_([x()],Iu.prototype,"limitInterval",2);var Vp=(i=>(i[i.PointerEnter=0]="PointerEnter",i[i.PointerExit=1]="PointerExit",i[i.PointerDown=2]="PointerDown",i[i.PointerUp=3]="PointerUp",i[i.PointerClick=4]="PointerClick",i[i.Drag=5]="Drag",i[i.Drop=6]="Drop",i[i.Scroll=7]="Scroll",i[i.UpdateSelected=8]="UpdateSelected",i[i.Select=9]="Select",i[i.Deselect=10]="Deselect",i[i.Move=11]="Move",i[i.InitializePotentialDrag=12]="InitializePotentialDrag",i[i.BeginDrag=13]="BeginDrag",i[i.EndDrag=14]="EndDrag",i[i.Submit=15]="Submit",i[i.Cancel=16]="Cancel",i))(Vp||{}),yse=Object.defineProperty,bse=Object.getOwnPropertyDescriptor,oT=(i,e,t,s)=>{for(var r=s>1?void 0:s?bse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&yse(e,t,r),r};class aT{constructor(){h(this,"eventID"),h(this,"callback")}}oT([x()],aT.prototype,"eventID",2),oT([x(ir)],aT.prototype,"callback",2);class p_ extends Ie{constructor(){super(...arguments),h(this,"triggers")}invoke(e){if(this.triggers)for(const t of this.triggers)t.eventID===e&&t.callback.invoke()}onPointerClick(e){this.invoke(Vp.PointerClick)}onPointerEnter(e){this.invoke(Vp.PointerEnter)}onPointerExit(e){this.invoke(Vp.PointerExit)}onPointerDown(e){this.invoke(Vp.PointerDown)}onPointerUp(e){this.invoke(Vp.PointerUp)}}oT([x(aT)],p_.prototype,"triggers",2);var _se=Object.defineProperty,xse=Object.getOwnPropertyDescriptor,lT=(i,e,t,s)=>{for(var r=s>1?void 0:s?xse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&_se(e,t,r),r};class cT extends Ie{constructor(){super(...arguments),h(this,"connectedBody"),h(this,"_rigidBody",null)}get rigidBody(){return this._rigidBody}onEnable(){this._rigidBody||(this._rigidBody=this.gameObject.getComponent(Vi)),this.rigidBody&&this.connectedBody&&this.startCoroutine(this.create())}*create(){yield,this.rigidBody&&this.connectedBody&&this.createJoint(this.rigidBody,this.connectedBody)}}lT([x(Vi)],cT.prototype,"connectedBody",2);class hT extends cT{createJoint(e,t){var s;(s=this.context.physics.engine)==null||s.addFixedJoint(e,t)}}class qg extends cT{constructor(){super(...arguments),h(this,"anchor"),h(this,"axis")}createJoint(e,t){var s;this.axis&&this.anchor&&((s=this.context.physics.engine)==null||s.addHingeJoint(e,t,this.anchor,this.axis))}}lT([x(w)],qg.prototype,"anchor",2),lT([x(w)],qg.prototype,"axis",2);const wse={type:"change"};let Sse=class extends Ms{constructor(i,e){super(),this.object=i,this.domElement=e,this.enabled=!0,this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1;const t=this,s=1e-6,r=new Ee,n=new w;this.tmpQuaternion=new Ee,this.status=0,this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this.moveVector=new w(0,0,0),this.rotationVector=new w(0,0,0),this.keydown=function(p){if(!(p.altKey||this.enabled===!1)){switch(p.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this.moveState.forward=1;break;case"KeyS":this.moveState.back=1;break;case"KeyA":this.moveState.left=1;break;case"KeyD":this.moveState.right=1;break;case"KeyR":this.moveState.up=1;break;case"KeyF":this.moveState.down=1;break;case"ArrowUp":this.moveState.pitchUp=1;break;case"ArrowDown":this.moveState.pitchDown=1;break;case"ArrowLeft":this.moveState.yawLeft=1;break;case"ArrowRight":this.moveState.yawRight=1;break;case"KeyQ":this.moveState.rollLeft=1;break;case"KeyE":this.moveState.rollRight=1;break}this.updateMovementVector(),this.updateRotationVector()}},this.keyup=function(p){if(this.enabled!==!1){switch(p.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this.moveState.forward=0;break;case"KeyS":this.moveState.back=0;break;case"KeyA":this.moveState.left=0;break;case"KeyD":this.moveState.right=0;break;case"KeyR":this.moveState.up=0;break;case"KeyF":this.moveState.down=0;break;case"ArrowUp":this.moveState.pitchUp=0;break;case"ArrowDown":this.moveState.pitchDown=0;break;case"ArrowLeft":this.moveState.yawLeft=0;break;case"ArrowRight":this.moveState.yawRight=0;break;case"KeyQ":this.moveState.rollLeft=0;break;case"KeyE":this.moveState.rollRight=0;break}this.updateMovementVector(),this.updateRotationVector()}},this.pointerdown=function(p){if(this.enabled!==!1)if(this.dragToLook)this.status++;else{switch(p.button){case 0:this.moveState.forward=1;break;case 2:this.moveState.back=1;break}this.updateMovementVector()}},this.pointermove=function(p){if(this.enabled!==!1&&(!this.dragToLook||this.status>0)){const f=this.getContainerDimensions(),m=f.size[0]/2,A=f.size[1]/2;this.moveState.yawLeft=-(p.pageX-f.offset[0]-m)/m,this.moveState.pitchDown=(p.pageY-f.offset[1]-A)/A,this.updateRotationVector()}},this.pointerup=function(p){if(this.enabled!==!1){if(this.dragToLook)this.status--,this.moveState.yawLeft=this.moveState.pitchDown=0;else{switch(p.button){case 0:this.moveState.forward=0;break;case 2:this.moveState.back=0;break}this.updateMovementVector()}this.updateRotationVector()}},this.contextMenu=function(p){this.enabled!==!1&&p.preventDefault()},this.update=function(p){if(this.enabled===!1)return;const f=p*t.movementSpeed,m=p*t.rollSpeed;t.object.translateX(t.moveVector.x*f),t.object.translateY(t.moveVector.y*f),t.object.translateZ(t.moveVector.z*f),t.tmpQuaternion.set(t.rotationVector.x*m,t.rotationVector.y*m,t.rotationVector.z*m,1).normalize(),t.object.quaternion.multiply(t.tmpQuaternion),(n.distanceToSquared(t.object.position)>s||8*(1-r.dot(t.object.quaternion))>s)&&(t.dispatchEvent(wse),r.copy(t.object.quaternion),n.copy(t.object.position))},this.updateMovementVector=function(){const p=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right,this.moveVector.y=-this.moveState.down+this.moveState.up,this.moveVector.z=-p+this.moveState.back},this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp,this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft,this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft},this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}},this.dispose=function(){this.domElement.removeEventListener("contextmenu",o),this.domElement.removeEventListener("pointerdown",l),this.domElement.removeEventListener("pointermove",a),this.domElement.removeEventListener("pointerup",c),window.removeEventListener("keydown",u),window.removeEventListener("keyup",d)};const o=this.contextMenu.bind(this),a=this.pointermove.bind(this),l=this.pointerdown.bind(this),c=this.pointerup.bind(this),u=this.keydown.bind(this),d=this.keyup.bind(this);this.domElement.addEventListener("contextmenu",o),this.domElement.addEventListener("pointerdown",l),this.domElement.addEventListener("pointermove",a),this.domElement.addEventListener("pointerup",c),window.addEventListener("keydown",u),window.addEventListener("keyup",d),this.updateMovementVector(),this.updateRotationVector()}};class uT extends Ie{constructor(){super(...arguments),h(this,"_controls",null)}onEnable(){var e;const t=(e=se.getComponent(this.gameObject,Ri))==null?void 0:e.cam;if(!t){console.warn("FlyControls: Requires a Camera component on the same object as this component.");return}this._controls=new Sse(t,this.context.renderer.domElement),this._controls.rollSpeed=.5,this._controls.movementSpeed=3,this._controls.dragToLook=!0}onDisable(){var e;(e=this._controls)==null||e.dispose(),this._controls=null}update(){this._controls&&this._controls.update(this.context.time.deltaTime)}}var Cse=Object.defineProperty,Ese=Object.getOwnPropertyDescriptor,dT=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ese(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Cse(e,t,r),r};class Wp extends Ie{constructor(){super(...arguments),h(this,"_fog")}get fog(){return this._fog||(this._fog=new hS(0,0,50)),this._fog}get mode(){return 1}set near(e){this.fog.near=e}get near(){return this.fog.near}set far(e){this.fog.far=e}get far(){return this.fog.far}set color(e){this.fog.color.copy(e)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}dT([x()],Wp.prototype,"near",1),dT([x()],Wp.prototype,"far",1),dT([x(_e)],Wp.prototype,"color",1);let f_,pT,Xp,m_;function fT(i,e=1/0,t=null){pT||(pT=new fr(2,2,1,1)),Xp||(Xp=new Dt({uniforms:{blitTexture:new Ce(i)},vertexShader:`
5072
+ `,this.context.appendHTMLElement(t);const s=wM;wM&&console.log("ARSupported?",Ag,"VRSupported?",yg),(s||this.createARButton&&this.enableAR&&Ag)&&(i=Os.createARButton(this),this._arButton=i,t.appendChild(i)),(s||this.createVRButton&&this.enableVR&&yg)&&(e=Os.createVRButton(this),this._vrButton=e,t.appendChild(e)),setTimeout(()=>{Os.resetButtonStyles(e),Os.resetButtonStyles(i)},1e3)}get TransformOrientation(){return this._transformOrientation}get HeadPose(){return this._currentHeadPose}onBeforeRender(i){var e;if(!i)return;const t=this.context.renderer.xr.getSession();if(t){const s=i.getViewerPose(this.context.renderer.xr.getReferenceSpace());if(!s)return;this._currentHeadPose=s;const r=s?.transform;r&&this._transformOrientation.set(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w),Os._isInXr===!1&&t&&this.onEnterXR(t,i);for(const n of this.controllers)n.onUpdate(t);this._isInAR&&((e=this.webAR)==null||e.onUpdate(t,i))}Os.events.dispatchEvent({type:"xrUpdate",frame:i,xr:this.context.renderer.xr,rig:this.rig})}onClickedARButton(){this._isInAR||(this._requestedAR=!0,this._requestedVR=!1,this.captureStateBeforeXR())}onClickedVRButton(){if(!this._isInVR){if(this._requestedVR){this.onExitXR(null);return}this._requestedAR=!1,this._requestedVR=!0,this.captureStateBeforeXR(),this.ensureRig();for(let i=0;i<2;i++)bs.Create(this,i,this.gameObject,xp.PhysicalDevice);Os.events.dispatchEvent({type:"requestVRSession"})}}captureStateBeforeXR(){this.context.mainCamera&&(this._originalCameraPosition.copy(At(this.context.mainCamera)),this._originalCameraRotation.copy(Bs(this.context.mainCamera)),this._originalCameraParent=this.context.mainCamera.parent),this.Rig&&(this._originalXRRigParent=this.Rig.parent,this._originalXRRigPosition.copy(this.Rig.position),this._originalXRRigRotation.copy(this.Rig.quaternion))}ensureRig(){if(!this.rig){const i=se.findObjectOfType(Ob,this.context);i?(this.rig=i.gameObject,this.rig.rotateY(Math.PI)):(this.rig=new Tn,this.rig.rotateY(Math.PI),this.rig.name="XRRig",this.context.scene.add(this.rig))}}onEnterXR(i,e){var t,s;console.log("[XR] session begin",i,e),Os._isInXr=!0,this.ensureRig();const r=this.context.renderer.xr.getReferenceSpace();if(r&&this.rig){const a=e.getViewerPose(r),l=a?.transform.orientation;if(l){const c=new Ee(l.x,l.y,l.z,l.w),u=new Es().setFromQuaternion(c);this.rig.rotateY(u.y)}}const n=this.context.renderer.xr;if(this.context.mainCamera){const a=n.getCamera();wM&&console.log("WebXRCamera",a);const l=(t=this.context.mainCameraComponent)==null?void 0:t.cullingMask;if(a&&l!==void 0){for(const c of a.cameras)c.layers.mask=l;a.layers.mask=l}else if(a){for(const c of a.cameras)c.layers.enableAll();a.layers.enableAll()}this.rig.add(this.context.mainCamera),this._requestedAR&&this.context.scene.add(this.rig)}const o=this._requestedAR?as.AR:as.VR;switch(kn.Global.Set(o),o){case as.AR:this.context.xrSessionMode=Nm.ImmersiveAR,this._isInAR=!0,(s=this.webAR)==null||s.onBegin(i);break;case as.VR:this.context.xrSessionMode=Nm.ImmersiveVR,this._isInVR=!0,this.onEnterVR(i);break}i.addEventListener("end",()=>{console.log("[XR] session end"),Os._isInXr=!1,this.onExitXR(i)}),this.onEnterXR_HandleMirrorWindow(i),Os.events.dispatchEvent({type:"xrStarted",session:i})}onExitXR(i){var e,t,s,r;const n=this._isInAR;i&&(this._isInAR?(e=this.webAR)==null||e.onEnd(i):(t=this.context.mainCameraComponent)==null||t.applyClearFlagsIfIsActiveCamera()),this._isInAR=!1,this._isInVR=!1,this._requestedAR=!1,this._requestedVR=!1,this.context.xrSessionMode=void 0,this.xrMirrorWindow&&(this.xrMirrorWindow.close(),this.xrMirrorWindow=null),this.destroyControllers(),this.context.mainCamera&&((s=this._originalCameraParent)==null||s.add(this.context.mainCamera),ns(this.context.mainCamera,this._originalCameraPosition),ln(this.context.mainCamera,this._originalCameraRotation),this.context.mainCamera.scale.set(1,1,1)),n&&((r=this._originalXRRigParent)==null||r.add(this.rig),this.rig.position.copy(this._originalXRRigPosition),this.rig.quaternion.copy(this._originalXRRigRotation)),kn.Global.Set(as.Browser|as.ThirdPerson),Os.events.dispatchEvent({type:"xrStopped",session:i})}onEnterVR(i){}destroyControllers(){var i;for(let e=this.controllers.length-1;e>=0;e-=1)(i=this.controllers[e])==null||i.destroy();this.controllers.length=0}onEnterXR_HandleMirrorWindow(i){le("mirror")&&setTimeout(()=>{if(!Os.IsInWebXR)return;const e=new URL(window.location.href);yf(e.searchParams,ab,1),yf(e.searchParams,"isMirror",1);const t=e.toString();this.xrMirrorWindow=window.open(t,"webxr sync","popup=yes"),this.xrMirrorWindow&&(this.xrMirrorWindow.onload=()=>{this.xrMirrorWindow&&(this.xrMirrorWindow.onbeforeunload=()=>{Os.IsInWebXR&&i.end()})})},1e3)}},h(Cp,"_isInXr",!1),h(Cp,"events",new Ms),h(Cp,"_optionalFeatures_VR",["local-floor","bounded-floor","hand-tracking","high-fixed-foveation-level","layers"]),h(Cp,"_optionalFeatures_AR",["anchors","local-floor","hand-tracking","layers"]),Cp);let Ct=Os;Sp([x()],Ct.prototype,"enableVR",2),Sp([x()],Ct.prototype,"enableAR",2),Sp([x(er)],Ct.prototype,"defaultAvatar",2),Sp([x()],Ct.prototype,"handModelPath",2),Sp([x()],Ct.prototype,"createVRButton",2),Sp([x()],Ct.prototype,"createARButton",2);const bg=class{constructor(i){h(this,"_webxr"),h(this,"reticle",null),h(this,"reticleParent",null),h(this,"hitTestSource",null),h(this,"reticleActive",!0),h(this,"previousBackground",null),h(this,"previousEnvironment",null),h(this,"sessionRoot",null),h(this,"_previousParent",null),h(this,"arDomOverlay",null),h(this,"arOverlayElement",null),h(this,"noHitTestAvailable",!1),h(this,"didPlaceARSessionRoot",!1),this._webxr=i}get webxr(){return this._webxr}get context(){return this.webxr.context}getAROverlayContainer(){this.arDomOverlay=this.webxr.context.domElement;const i=this.arDomOverlay;return i.getAROverlayContainer?this.arOverlayElement=i.getAROverlayContainer():this.arOverlayElement=this.arDomOverlay,this.arOverlayElement}setReticleActive(i){this.reticleActive=i}async onBegin(i){var e,t,s,r;const n=this.webxr.context;this.reticleActive=!0,this.didPlaceARSessionRoot=!1,this.getAROverlayContainer();const o=(e=navigator.userAgent)!=null&&e.includes("OculusBrowser")?xp.PhysicalDevice:xp.Touch,a=o===xp.Touch?4:2;for(let c=0;c<a;c++)bs.Create(this.webxr,c,this.webxr.gameObject,o);if((!this.sessionRoot||this.sessionRoot.destroyed||!this.sessionRoot.activeAndEnabled)&&(this.sessionRoot=se.findObjectOfType(xa,n)),!this.sessionRoot){const c=this.webxr.gameObject;this.sessionRoot=se.addNewComponent(c,xa),console.warn("WebAR: No ARSessionRoot found, creating one automatically on the WebXR object")}this.previousBackground=n.scene.background,this.previousEnvironment=n.scene.environment,n.scene.background=null,i.requestReferenceSpace("viewer").then(c=>{var u,d;(d=(u=i.requestHitTestSource)==null?void 0:u.call(i,{space:c}))==null||d.then(p=>{this.hitTestSource=p}).catch(p=>{this.noHitTestAvailable=!0,console.warn("WebXR: Hit test not supported",p)})}),!this.reticle&&this.sessionRoot&&(this.reticle=new ye(new Gv(.07,.09,32).rotateX(-Math.PI/2),new li),this.reticle.name="AR Placement reticle",this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.reticleParent=new Re,this.reticleParent.name="AR Reticle Parent",this.reticleParent.matrixAutoUpdate=!1,this.reticleParent.add(this.reticle),this.webxr.scene?(this.context.scene.add(this.reticleParent),this.context.scene.visible=!0):console.warn("Could not found WebXR Rig")),this._previousParent=this.webxr.gameObject,bg.tempWebXRObject||(bg.tempWebXRObject=new Re),this.context.scene.add(bg.tempWebXRObject),se.addComponent(bg.tempWebXRObject,this.webxr),this.sessionRoot?(this.sessionRoot.webAR=this,(t=this.sessionRoot)==null||t.onBegin(i)):console.warn("No WebARSessionRoot found in scene");const l=this.context.domElement;(s=l?.onEnterAR)==null||s.call(l,i,this.arOverlayElement),(r=this.context.mainCameraComponent)==null||r.applyClearFlagsIfIsActiveCamera()}onEnd(i){var e,t;this._previousParent&&(se.addComponent(this._previousParent,this.webxr),this._previousParent=null),this.hitTestSource=null;const s=this.webxr.context;s.scene.background=this.previousBackground,s.scene.environment=this.previousEnvironment,this.sessionRoot&&this.sessionRoot.onEnd(this.webxr.Rig,i);const r=this.context.domElement;(e=r.onExitAR)==null||e.call(r,i),(t=this.context.mainCameraComponent)==null||t.applyClearFlagsIfIsActiveCamera()}onUpdate(i,e){var t,s;if(this.noHitTestAvailable===!0){if(this.reticle&&(this.reticle.visible=!1),!this.didPlaceARSessionRoot){this.didPlaceARSessionRoot=!0;const n=this.webxr.Rig,o=Mte.clone();(t=this.sessionRoot)==null||t.placeAt(n,o)}return}if(!this.hitTestSource)return;const r=e.getHitTestResults(this.hitTestSource);if(r.length){const n=r[0],o=this.webxr.context.renderer.xr.getReferenceSpace();if(o){const a=n.getPose(o);if(this.sessionRoot){const l=this.sessionRoot.onUpdate(this.webxr.Rig,i,a);this.didPlaceARSessionRoot=l}if(this.reticle&&(this.reticle.visible=this.reticleActive,this.reticleActive&&a)){const l=a.transform.matrix;this.reticle.matrix.fromArray(l),this.webxr.Rig&&this.reticle.matrix.premultiply(this.webxr.Rig.matrix)}}}else(s=this.sessionRoot)==null||s.onUpdate(this.webxr.Rig,i,null),this.reticle&&(this.reticle.visible=!1)}};let _g=bg;h(_g,"tempWebXRObject");const Mte=new Be().identity().makeTranslation(0,0,0);class oc{constructor(e,t){h(this,"used",!1),h(this,"positionDelta",new ee),h(this,"inputSource"),h(this,"object"),h(this,"pointerId"),h(this,"isDown"),h(this,"isUp"),h(this,"isPressed"),h(this,"isClicked"),h(this,"input"),h(this,"event"),this.event=t,this.input=e}use(){this.used=!0,this.pointerId!==void 0&&this.input.setPointerUsed(this.pointerId)}stopPropagation(){var e;(e=this.event)==null||e.stopImmediatePropagation()}Use(){this.use()}StopPropagation(){var e;(e=this.event)==null||e.stopImmediatePropagation()}clone(){const e=new oc(this.input,this.event);return Object.assign(e,this),e}}class Ep extends Ie{awake(){Un.createIfNoneExists(this.context)}onEnable(){var e;(e=Un.get(this.context))==null||e.register(this)}onDisable(){var e;(e=Un.get(this.context))==null||e.unregister(this)}performRaycast(e=null){return null}}class zl extends Ep{constructor(){super(...arguments),h(this,"targets",null),h(this,"raycastHits",[])}start(){this.targets=[this.gameObject]}performRaycast(e=null){return this.targets?(e??(e=new ko),e.targets=this.targets,e.results=this.raycastHits,this.context.physics.raycast(e)):null}}class SM extends zl{}const xg=le("debugeventsystem");var CM=(i=>(i.BeforeHandleInput="BeforeHandleInput",i.AfterHandleInput="AfterHandleInput",i))(CM||{});const jl=class extends Ie{constructor(){super(),h(this,"raycaster",[]),h(this,"_selectStartFn"),h(this,"_selectEndFn"),h(this,"_selectUpdateFn"),h(this,"_handleEventFn"),h(this,"lastPointerEvent",null),h(this,"objectsHoveredThisFrame",[]),h(this,"objectsHoveredLastFrame",[]),h(this,"raisedPointerDownEvents",[]),h(this,"raisedPointerDownObjects",[]),h(this,"_didMove",!1),h(this,"_tempComponentsArray",[]),h(this,"_sortedHits",[]),h(this,"_sortingBuffer",[]),h(this,"_noDepthTestingResults",[]),h(this,"handleEventsArray",[]),h(this,"out",{}),h(this,"currentActiveMeshUIComponents",[]),jl.systems.push(this)}static createIfNoneExists(i){this.didSearchEventSystem||(this.didSearchEventSystem=!0,jl.systems.length<=0&&jl.systems.push(...se.findObjectsOfType(jl,i)));for(const t of jl.systems)if(t.context===i)return;const e=new Re;se.addNewComponent(e,jl),i.scene.add(e)}static get systems(){const i=zt.Current;return this._eventSystemMap.has(i)||this._eventSystemMap.set(i,[]),this._eventSystemMap.get(i)}static get(i){const e=this._eventSystemMap.get(i);return e&&e.length>0?e[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(i,e){Ql.update(i,e)}static markUIDirty(i){Ql.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.objectsHoveredThisFrame.length>0}onDestroy(){jl.systems.splice(jl.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!se.findObjectOfType(Ep,this.context)){const i=se.addNewComponent(this.context.scene,zl);this.raycaster.push(i),gi()&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found",this)}}register(i){var e;i&&this.raycaster&&!this.raycaster.includes(i)&&((e=this.raycaster)==null||e.push(i))}unregister(i){var e,t;const s=(e=this.raycaster)==null?void 0:e.indexOf(i);s!==void 0&&s!==-1&&((t=this.raycaster)==null||t.splice(s,1))}onEnable(){const i=new Map;this._selectStartFn??(this._selectStartFn=(t,s)=>{if(!s.grab)return;Ql.resetLastSelected();const r=new oc(this.context.input);r.inputSource=t,r.pointerId=0,r.isDown=t.selectionDown,r.isUp=t.selectionUp,r.isPressed=t.selectionPressed,r.isClicked=!1,i.set(t,s.grab),s.grab&&!this.handleEvents(s.grab,r)&&(s.grab=null)}),this._selectEndFn??(this._selectEndFn=(t,s)=>{var r;if(!s.grab)return;const n=new oc(this.context.input);n.inputSource=t,n.pointerId=0,n.isDown=t.selectionDown,n.isUp=t.selectionUp,n.isPressed=t.selectionPressed,n.isClicked=t.selectionClick,this.handleEvents(s.grab,n);const o=i.get(t);if(i.set(t,null),o)for(let a=0;a<this.raisedPointerDownEvents.length;a++){const l=this.raisedPointerDownEvents[a];this.raisedPointerDownObjects[a]===o&&l&&((r=l.onPointerUp)==null||r.call(l,n),this.raisedPointerDownEvents.splice(a,1),this.raisedPointerDownObjects.splice(a,1),a--)}});const e=new ko;this._selectUpdateFn??(this._selectUpdateFn=t=>{e.ray=t.getRay();const s=this.performRaycast(e);if(!s)return;const r=new oc(this.context.input);r.inputSource=t,this.handleIntersections(s,r)}),bs.addEventListener(Fl.SelectStart,this._selectStartFn),bs.addEventListener(Fl.SelectEnd,this._selectEndFn),bs.addEventListener(Fl.Update,this._selectUpdateFn),this._handleEventFn??(this._handleEventFn=this.onHandleEvents.bind(this)),this.context.pre_update_callbacks.push(this._handleEventFn)}onDisable(){bs.removeEventListener(Fl.SelectStart,this._selectStartFn),bs.removeEventListener(Fl.SelectEnd,this._selectEndFn),bs.removeEventListener(Fl.Update,this._selectUpdateFn),this.context.pre_update_callbacks.splice(this.context.pre_update_callbacks.indexOf(this._handleEventFn),1)}onHandleEvents(){if(this.objectsHoveredThisFrame.length=0,this.resetMeshUIStates(),Ct.IsInWebXR||this.context.input.isKeyPressed("AltLeft")||this.context.input.isKeyPressed("AltRight"))return;if(!this._didMove){const o=this.context.input.getPointerPositionRC(0);if(o&&o.x===0&&o.y===0)return;this._didMove=!0}let i=0;for(const o of this.context.input.foreachPointerId()){const a=this.context.input.getPointerDown(o),l=this.context.input.getPointerUp(o);if(a||l){i=o;break}}const e=this.context.input.getPointerEvent(i),t=new oc(this.context.input,e);t.inputSource=this.context.input,t.pointerId=i,t.isClicked=this.context.input.getPointerClicked(i),t.isDown=this.context.input.getPointerDown(i),t.isUp=this.context.input.getPointerUp(i),t.isPressed=this.context.input.getPointerPressed(i);const s=this.context.input.getPointerPositionDelta(i);if(s&&t.positionDelta.copy(s),xg&&t.isClicked&&console.log("CLICK",i),!t.isDown&&!t.isUp&&!t.isClicked&&!t.isPressed&&!t.positionDelta.x&&!t.positionDelta.y){this.objectsHoveredThisFrame.length=0,this.objectsHoveredThisFrame.push(...this.objectsHoveredLastFrame);return}const r=this.performRaycast(null);if(!r)return;this.lastPointerEvent=t;const n={sender:this,args:t,hasActiveUI:this.currentActiveMeshUIComponents.length>0};xg&&t.isClicked&&fs("EventSystem: "+t.pointerId+" - "+this.context.time.frame+" - Up:"+t.isUp+", Down:"+t.isDown),this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:n})),this.handleIntersections(r,t),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:n}))}onBeforeRender(){if(this.lastPointerEvent)this.lastPointerEvent.used=!1;else return;if(this.lastPointerEvent.isUp){for(const e of this.raisedPointerDownEvents)e.onPointerUp&&e.onPointerUp(this.lastPointerEvent);this.raisedPointerDownEvents.length=0,this.raisedPointerDownObjects.length=0}for(const e of this.objectsHoveredLastFrame)if(this.objectsHoveredThisFrame.indexOf(e)<0){this._tempComponentsArray.length=0;const t=se.getComponentsInParent(e,Ie,this._tempComponentsArray);this.lastPointerEvent.object=e;for(let s=0;s<t.length;s++){const r=t[s];if(!r.gameObject||r.destroyed)continue;const n=r;n.onPointerExit&&n.onPointerExit(this.lastPointerEvent)}}const i=this.objectsHoveredLastFrame;this.objectsHoveredLastFrame=this.objectsHoveredThisFrame,this.objectsHoveredThisFrame=i}performRaycast(i){if(!this.raycaster)return null;this._sortedHits.length=0;for(const e of this.raycaster){if(!e.activeAndEnabled)continue;const t=e.performRaycast(i);t&&t.length>0&&this._sortedHits.push(...t)}return this._sortedHits.sort((e,t)=>e.distance-t.distance),this._sortedHits}handleIntersections(i,e){if(!i||i.length<=0)return!1;i=this.sortCandidates(i);for(const t of i){const{object:s}=t;if(this.handleEvents(s,e))return!0}return!1}sortCandidates(i){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let e=0;e<i.length;e++){const t=i[e],s=t.object;if(s.material&&s.material.depthTest===!1){this._noDepthTestingResults.push(t);continue}this._sortingBuffer.push(t)}for(const e of this._sortingBuffer)this._noDepthTestingResults.push(e);return this._noDepthTestingResults}handleEvents(i,e){if(!this.testIsVisible(i))return e.isClicked&&xg&&console.log("not allowed",i),!1;const t=i;e.object=i,this.lastPointerEvent=e;const s=i.parent;let r=!1;const n=e.isClicked??!1;let o=null;if(s&&s.isUI){const a=(e.isPressed||e.isClicked)??!1;if(s[Ma]){const l=s[Ma].gameObject;if(l){if(!_p.isInteractable(l,this.out))return!1;o=this.out.canvasGroup??null,this.handleMeshUIIntersection(i,a),i=l,r=!0}}if(!r&&this.handleMeshUiObjectWithoutShadowDom(s,a))return!0}if(n&&xg&&console.log(this.context.time.frame,i),this.objectsHoveredThisFrame.push(i),o===null||o.interactable){const a=this.objectsHoveredLastFrame.indexOf(i)>=0;this.handleEventsArray.length=0;const l=se.getComponentsInParent(i,Ie,this.handleEventsArray);for(let c=0;c<l.length;c++){if(e.used)return!0;if(l[c].destroyed)continue;const u=l[c];if(u.interactable!==!1){if(u.onPointerEnter&&(a||u.onPointerEnter(e)),u.onPointerMove&&e.positionDelta.x!==0&&e.positionDelta.y!==0&&u.onPointerMove(e),e.isDown&&u.onPointerDown&&!this.raisedPointerDownEvents.includes(u)&&(u.onPointerDown(e),this.raisedPointerDownEvents.push(u),this.raisedPointerDownObjects.push(t)),e.isUp&&u.onPointerUp){const d=this.raisedPointerDownEvents.indexOf(u);d!==-1&&this.raisedPointerDownEvents.splice(d,1),u.onPointerUp(e)}e.isClicked&&u.onPointerClick&&u.onPointerClick(e)}}}return!0}handleMeshUiObjectWithoutShadowDom(i,e){return!i||!i.isUI?!0:this.handleMeshUIIntersection(i,e)}handleMeshUIIntersection(i,e){const t=Ql.updateState(i,e);return t&&this.currentActiveMeshUIComponents.push(t),t!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&Ql.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let i=0;i<this.currentActiveMeshUIComponents.length;i++){const e=this.currentActiveMeshUIComponents[i];Ql.resetState(e)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(i){return i?se.isActiveSelf(i)?this.testIsVisible(i.parent):!1:!0}};let Un=jl;h(Un,"_eventSystemMap",new Map),h(Un,"didSearchEventSystem",!1);class Ql{static markDirty(){this.needsUpdate=!0}static update(e,t){const s=t.time.frameCount;for(const r of this.lastUpdateFrame)if(r.context===t){if(s===r.frame)return;r.frame=s;let n=this.needsUpdate||s<1;r.nextUpdate===t.time.frameCount&&(n=!0),n&&(xg&&console.log("Update threemeshui"),this.needsUpdate=!1,e.update());return}this.lastUpdateFrame=[{context:t,frame:s,nextUpdate:s}],e.update()}static updateState(e,t){let s=null;if(e&&(s=this.findBlockInParent(e),s&&s!==this.lastSelected)){if(s.interactable===!1)return null;this.needsUpdate=!0}return s}static resetLastSelected(){const e=this.lastSelected;e&&(this.lastSelected=null,this.resetState(e))}static resetState(e){e&&(this.needsUpdate=!0)}static findBlockInParent(e){return e?e.isBlock?e:this.findBlockInParent(e.parent):null}}h(Ql,"lastSelected",null),h(Ql,"lastUpdateFrame",[]),h(Ql,"needsUpdate",!1);const Ub=Symbol("cameraController");function Tte(i){return i[Ub]}function VN(i,e,t){t?i[Ub]=e:i[Ub]===e&&(i[Ub]=null)}function Fb(i){return i[Ma]||(i.parent?Fb(i.parent):null)}function Nb(i,e){if(!i)return;const t=i.material;if(t?.isMaterial===!0){const s=i.parent;s&&s.isText,t.side=e.doubleSided??!0?_i:gr,t.shadowSide=e.doubleSided?_i:gr,i.castShadow=e.castShadows?e.castShadows:!1,i.receiveShadow=e.receiveShadows?e.receiveShadows:!1}for(const s of i.children)Nb(s,e)}function Mp(i,e,t){i[e]===void 0&&console.warn("Field",e,"is undefined on",i);const s=Proxy.revocable(i[e],{set(o,a,l,c){const u=o[a],d=Reflect.set(o,a,l,c);return t(l,u),d}}),r=s.revoke,n=i[e];return s.revoke=()=>{i[e]=n,r()},i[e]=s.proxy,s}const WN=Symbol("Scheduled action");function Ite(i,e,t=dn.OnBeforeRender){let s=i[WN];s||(s=i[WN]={});const r=e.name;s[t]||(s[t]={});const n=s[t];if(n[r])return;function*o(){e?.call(i),n[r]=null}const a=i.startCoroutine(o(),t);n[r]=a}var Rte=Object.defineProperty,Pte=Object.getOwnPropertyDescriptor,Bte=(i,e,t,s)=>{for(var r=s>1?void 0:s?Pte(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Rte(e,t,r),r};const zb=le("freecam"),EM=le("debugcamerafit"),kte={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let MM;class Gl extends Ie{constructor(){super(...arguments),h(this,"autoRotate",!1),h(this,"autoRotateSpeed",1),h(this,"enableKeys",!0),h(this,"enableDamping",!0),h(this,"dampingFactor",.1),h(this,"enableZoom",!0),h(this,"minZoom",0),h(this,"maxZoom",1/0),h(this,"enablePan",!0),h(this,"lookAtConstraint",null),h(this,"lookAtConstraint01",1),h(this,"middleClickToFocus",!0),h(this,"doubleClickToFocus",!0),h(this,"useSlerp",!0),h(this,"debugLog",!1),h(this,"targetLerpSpeed",5),h(this,"autoTarget",!0),h(this,"_lookTargetPosition"),h(this,"_controls",null),h(this,"_cameraObject",null),h(this,"_lerpToTargetPosition",!1),h(this,"_lerpCameraToTarget",!1),h(this,"_cameraTargetPosition",null),h(this,"_inputs",0),h(this,"_enableTime",0),h(this,"_startedListeningToKeyEvents",!1),h(this,"_eventSystem"),h(this,"_afterHandleInputFn"),h(this,"_camera",null),h(this,"_syncedTransform"),h(this,"targetElement",null),h(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),h(this,"_shouldDisable",!1),h(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}awake(){this._lookTargetPosition=new w,this._startedListeningToKeyEvents=!1}start(){if(this.autoTarget){if(this._controls){const e=se.getComponent(this.gameObject,Ri);if(e&&!this.setFromTargetPosition()){this.debugLog&&console.log("NO TARGET");const t=At(e.cam).length(),s=new w(0,0,-t).applyMatrix4(e.cam.matrixWorld);this.setTarget(s,!0)}}this.startCoroutine(this.startRaycastDelayed())}this._eventSystem=Un.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(CM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(CM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=se.getComponent(this.gameObject,Ri);this._camera=e;const t=e?.cam;if(t&&VN(t,this,!0),!this._controls){if(!t){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}t&&(this._cameraObject=t);const s=this.targetElement??this.context.domElement,r=t?.quaternion.clone();this._controls=new TK(t,s),t?.quaternion.copy(r),MM===void 0&&(MM={...this._controls.keys})}this._controls&&(zb&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,Ka()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),t?.type==="PerspectiveCamera"?zb||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):zb||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=se.getComponent(this.gameObject,Yc)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&VN(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(e){e.detail.args.pointerId===0&&(e.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!e.detail.args.isPressed||e.detail.args.isUp)&&(this._shouldDisable=!1))}*startRaycastDelayed(){if(yield,this.autoTarget&&!this.setFromTargetPosition()){const e=new ko;e.screenPoint=new ee(0,0),e.lineThreshold=.1;const t=this.context.physics.raycast(e);t.length>0&&this.setTarget(t[0].point,!0)}}onBeforeRender(){var e,t,s;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(0)||this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2))&&(this._inputs+=1),this._inputs>0&&(this.autoRotate=!1,this._controls.autoRotate=!1,this._lerpCameraToTarget=!1,this._lerpToTargetPosition=!1),this._inputs=0;let r=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(r||(r=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),r?this.setTargetFromRaycast():(this.context.input.getPointerDown(0)||this.context.input.mouseWheelChanged)&&(this._lerpToTargetPosition=!1,this._lerpCameraToTarget=!1),this._lerpToTargetPosition||this._lerpCameraToTarget){const n=this.context.time.deltaTime*this.targetLerpSpeed;if(this._lerpCameraToTarget&&this._cameraTargetPosition&&this._cameraObject){if(this.useSlerp){const o=(e=this._cameraObject)==null?void 0:e.position;Wk(o,this._cameraTargetPosition,n)}else(t=this._cameraObject)==null||t.position.lerp(this._cameraTargetPosition,n);this._cameraObject.position.distanceTo(this._cameraTargetPosition)<1e-4&&(this._lerpCameraToTarget=!1)}this._lerpToTargetPosition&&(this.lerpTarget(this._lookTargetPosition,n),this._lookTargetPosition.distanceTo(this._controls.target)<1e-5&&(this._lerpToTargetPosition=!1))}!zb&&(s=this.lookAtConstraint)!=null&&s.locked&&this.setFromTargetPosition(0,this.lookAtConstraint01),this._controls&&(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.enableDamping=this.enableDamping,this._controls.keys=this.enableKeys?MM:kte,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this.context.isInXR||this._controls.update())}setCameraTarget(e,t=!1){var s;e?(this._lerpCameraToTarget=!0,this._cameraTargetPosition=e.clone(),t&&this._cameraTargetPosition&&((s=this.controllerObject)==null||s.position.copy(this._cameraTargetPosition))):this._lerpCameraToTarget=!1}setFromTargetPosition(e=0,t=1){var s;if(!this._controls)return!1;const r=(s=this.lookAtConstraint)==null?void 0:s.sources;if(r&&r.length>0){const n=r[e];if(n)return n.getWorldPosition(this._lookTargetPosition),this.lerpTarget(this._lookTargetPosition,t),!0}return!1}setTarget(e=null,t=!1){this._controls&&(e!==null&&this._lookTargetPosition.copy(e),t?this._controls.target.copy(this._lookTargetPosition):this._lerpToTargetPosition=!0)}lerpTarget(e,t){this._controls&&this._controls.target.lerp(e,t)}distanceToTarget(e){return this._controls?this._controls.target.distanceTo(e):-1}setTargetFromRaycast(){var e,t;if(!this.controls)return;const s=this.context.physics.raycast();for(const r of s)if(r.distance>0&&se.isActiveInHierarchy(r.object)){const n=Fb(r.object);if(n){const o=n.canvas;if(o!=null&&o.screenspace)break}if(this._lookTargetPosition.copy(r.point),this._lerpToTargetPosition=!0,this._cameraTargetPosition=null,this.context.mainCamera){this._lerpCameraToTarget=!0;const o=At(this.context.mainCamera);this._cameraTargetPosition=o.clone().sub(this.controls.target).add(this._lookTargetPosition),(t=(e=this._cameraObject)==null?void 0:e.parent)==null||t.worldToLocal(this._cameraTargetPosition)}break}}fitCamera(e,t=1.1){const s=this._cameraObject,r=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0||!s||!r)return;const n=new w,o=new w,a=new Ts;a.makeEmpty();for(const A of e)A instanceof t1||A instanceof e1||(A.updateMatrixWorld(),a.expandByObject(A,!0));if(s.updateMatrixWorld(),s.updateProjectionMatrix(),a.getCenter(o),a.applyMatrix4(s.matrixWorldInverse),a.getSize(n),a.setFromCenterAndSize(o,n),n.length()<=1e-10){EM&&console.warn("Camera fit size is zero",a,[...e]);return}const l=s.fov,c=2*Math.atan(Math.tan(l*Math.PI/360/2)*s.aspect)/Math.PI*360,u=n.y/(2*Math.atan(Math.PI*l/360)),d=n.x/(2*Math.atan(Math.PI*c/360)),p=t*Math.max(u,d)+n.z/2;EM&&console.log("Fit camera to objects",u,d,"distance",p);const f=At(s),m=r.target.clone().sub(f).normalize().multiplyScalar(p);if(r.maxDistance=p*10,r.minDistance=p*.01,this.setTarget(o,!0),this.autoTarget=!1,s.near=p/100,s.far=p*100,s.updateMatrixWorld(),s.updateProjectionMatrix(),ns(s,r.target.clone().sub(m)),EM){const A=new t1(a);this.context.scene.add(A),e2(A,N0(s)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",v=>{v.code==="KeyF"&&this.fitCamera(e)}))}r.update()}}Bte([x($m)],Gl.prototype,"lookAtConstraint",2);var Dte=Object.defineProperty,Ote=Object.getOwnPropertyDescriptor,Fn=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ote(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Dte(e,t,r),r},XN=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(XN||{});const wg=le("debugcam"),qN=le("debugscreenpointtoray");var jb;const Sg=(jb=class extends Ie{constructor(){super(...arguments),h(this,"_nearClipPlane",.1),h(this,"_farClipPlane",1e3),h(this,"orthographic",!1),h(this,"orthographicSize",5),h(this,"ARBackgroundAlpha",0),h(this,"_cullingMask",4294967295),h(this,"_backgroundBlurriness"),h(this,"_backgroundIntensity"),h(this,"_environmentIntensity"),h(this,"_targetTexture",null),h(this,"_backgroundColor"),h(this,"_fov"),h(this,"_cam",null),h(this,"_clearFlags",2),h(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof qt?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof qt?this._cam.fov:this._fov}set fieldOfView(i){const e=this.fieldOfView!=i;if(this._fov=i,e&&this._cam&&this._cam instanceof qt){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(i){const e=this._nearClipPlane!=i;this._nearClipPlane=i,this._cam&&e&&(this._cam.near=i,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(i){const e=this._farClipPlane!=i;this._farClipPlane=i,this._cam&&e&&(this._cam.far=i,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(i){i!==this._clearFlags&&(this._clearFlags=i,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(i){this._cullingMask=i,this._cam&&(this._cam.layers.mask=i)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set backgroundBlurriness(i){i!==this._backgroundBlurriness&&(i===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(i,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(i){i!==this._backgroundIntensity&&(i===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(i,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(i){this._environmentIntensity=i}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(i){if(i){if(this._backgroundColor)this._backgroundColor.copy(i);else{if(!i.clone)return;this._backgroundColor=i.clone()}i.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(i){this._targetTexture=i}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(i,e,t){const s=this.cam,r=Sg._origin;r.set(i,e,-1),this.context.input.convertScreenspaceToRaycastSpace(r),qN&&console.log("screenPointToRay",i.toFixed(2),e.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const n=Sg._direction.set(r.x,r.y,r.z),o=At(s);return n.sub(o),n.normalize(),t?(t.set(o,n),t):new ha(o.clone(),n.clone())}awake(){qN&&window.addEventListener("pointerdown",i=>{const e=i.clientX,t=i.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const s=this.screenPointToRay(e,t),r="#"+Math.floor(Math.random()*16777215).toString(16);Ml.DrawRay(s.origin,s.direction,r,10)})}onEnable(){wg&&console.log(this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),Ute(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&this._targetTexture){this.context.isManagedExternally&&(this._warnedAboutExternalRenderer||(this._warnedAboutExternalRenderer=!0,console.warn("Rendering with external renderer is not supported yet. This may not work or throw errors. Please remove the the target texture from your camera: "+this.name,this.targetTexture))),this.context.composer;const i=this.context.renderer;if(i){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,i),e?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const i=this.gameObject.isCamera;let e=null;if(i?(e=this.gameObject,e?.layers.enableAll(),e instanceof qt&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof qt&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new qt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new kh(window.innerWidth/-t,window.innerWidth/t,window.innerHeight/t,window.innerHeight/-t,this._nearClipPlane,this._farClipPlane),this.gameObject.add(e)}this._cam=e,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){wg&&console.log("Camera does not exist (apply clear flags)");return}switch(this.fieldOfView=this._fov,wg&&fs("apply Camera clear flags: "+this._clearFlags),this._clearFlags){case 1:if(Sg.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let i=this._backgroundColor.alpha;Sg.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,i)}break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new Lte(this)),this._skybox.enable()}static backgroundShouldBeTransparent(i){var e,t,s,r;const n=(e=i.renderer.xr)==null?void 0:e.getSession();if(!n)return!1;const o=n.environmentBlendMode;wg&&fs("Environment blend mode: "+o+" on "+navigator.userAgent);const a=o==="additive"||o==="alpha-blend";return i.xrSessionMode===Nm.ImmersiveAR&&o==="opaque"&&((t=navigator.userAgent)!=null&&t.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&(r=navigator.userAgent)!=null&&r.includes("Mobile WebXRViewer/v2"))?!0:a}},h(jb,"_origin",new w),h(jb,"_direction",new w),jb);let Ri=Sg;Fn([x()],Ri.prototype,"fieldOfView",1),Fn([x()],Ri.prototype,"nearClipPlane",1),Fn([x()],Ri.prototype,"farClipPlane",1),Fn([x()],Ri.prototype,"clearFlags",1),Fn([x()],Ri.prototype,"orthographic",2),Fn([x()],Ri.prototype,"orthographicSize",2),Fn([x()],Ri.prototype,"ARBackgroundAlpha",2),Fn([x()],Ri.prototype,"cullingMask",1),Fn([x()],Ri.prototype,"backgroundBlurriness",1),Fn([x()],Ri.prototype,"backgroundIntensity",1),Fn([x()],Ri.prototype,"environmentIntensity",1),Fn([x(Ai)],Ri.prototype,"backgroundColor",1),Fn([x(np)],Ri.prototype,"targetTexture",1);class Lte{constructor(e){h(this,"_camera"),h(this,"_skybox"),this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(wg&&console.log("Set skybox",this._camera,this._skybox),this._skybox.colorSpace=et,this._skybox.mapping=Yn,this.context.scene.background=this._skybox):console.warn("Failed to load/find skybox texture",this._camera.sourceId,this.context.lightmaps)}}function Ute(i){le("freecam")&&i.context.mainCameraComponent===i&&se.getOrAddComponent(i.gameObject,Gl)}class Tp extends Ie{constructor(){super(...arguments),h(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new qS),this._listener}awake(){As.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=this.context.mainCameraComponent||se.getComponentInParent(this.gameObject,Ri);t!=null&&t.cam?t.cam.add(e):this.gameObject.add(e)})}}var Fte=Object.defineProperty,Nte=Object.getOwnPropertyDescriptor,Qb=(i,e,t,s)=>{for(var r=s>1?void 0:s?Nte(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Fte(e,t,r),r};const zte=le("debugsignals");class Cg{constructor(){h(this,"guid")}}Qb([x()],Cg.prototype,"guid",2);class Ip{constructor(){h(this,"signal"),h(this,"reaction")}}Qb([x(Cg)],Ip.prototype,"signal",2),Qb([x(ir)],Ip.prototype,"reaction",2);var TM;const Hl=(TM=class extends Ie{constructor(){super(...arguments),h(this,"events")}static invoke(i){if(Hl.receivers[i]){const e=Hl.receivers[i];if(!e)return;for(const t of e)t.invoke(i)}}awake(){zte&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const i of this.events)Hl.receivers[i.signal.guid]||(Hl.receivers[i.signal.guid]=[]),Hl.receivers[i.signal.guid].push(this)}onDisable(){if(this.events){for(const i of this.events)if(Hl.receivers[i.signal.guid]){const e=Hl.receivers[i.signal.guid].indexOf(this);e>=0&&Hl.receivers[i.signal.guid].splice(e,1)}}}invoke(i){if(!this.events||!Array.isArray(this.events))return;const e=typeof i=="object"?i.guid:i;for(const t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(s){console.error(s)}}},h(TM,"receivers",{}),TM);let Rp=Hl;Qb([x(Ip)],Rp.prototype,"events",2);var Nn=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(Nn||{}),Ia=(i=>(i[i.None=0]="None",i[i.Hold=1]="Hold",i[i.Loop=2]="Loop",i[i.PingPong=3]="PingPong",i[i.Continue=4]="Continue",i))(Ia||{}),IM=(i=>(i.Signal="SignalEmitter",i))(IM||{});const Pp=le("debugtimeline"),RM=class extends Ie{constructor(){super(...arguments),h(this,"playableAsset"),h(this,"playOnAwake"),h(this,"extrapolationMode",1),h(this,"waitForAudio",!0),h(this,"_visibilityChangeEvt"),h(this,"_clonedPlayableAsset",!1),h(this,"_speed",1),h(this,"_guidsMap"),h(this,"_isPlaying",!1),h(this,"_internalUpdateRoutine"),h(this,"_isPaused",!1),h(this,"_isStopping",!1),h(this,"_time",0),h(this,"_duration",0),h(this,"_weight",1),h(this,"_animationTracks",[]),h(this,"_audioTracks",[]),h(this,"_signalTracks",[]),h(this,"_controlTracks",[]),h(this,"_customTracks",[]),h(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),h(this,"animationCallbackReceivers",[])}static registerCreateTrack(i,e){this.createTrackFunctions[i]=e}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(i){typeof i=="number"&&!Number.isNaN(i)?this._time=i:(Pp||Br())&&console.error("INVALID TIMELINE.TIME VALUE",i,this.name)}get duration(){return this._duration}set duration(i){this._duration=i}get weight(){return this._weight}set weight(i){this._weight=i}get speed(){return this._speed}set speed(i){this._speed=i}awake(){var i,e,t;Pp&&console.log(this,(i=this.playableAsset)==null?void 0:i.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(e=this.playableAsset)==null?void 0:e.tracks,Array.isArray((t=this.playableAsset)==null?void 0:t.tracks),this)}onEnable(){var i,e,t;for(const s of this._audioTracks)(i=s.onEnable)==null||i.call(s);for(const s of this._customTracks)(e=s.onEnable)==null||e.call(s);for(const s of this._animationTracks)(t=s.onEnable)==null||t.call(s);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var i,e,t;this.stop();for(const s of this._audioTracks)(i=s.onDisable)==null||i.call(s);for(const s of this._customTracks)(e=s.onDisable)==null||e.call(s);for(const s of this._animationTracks)(t=s.onDisable)==null||t.call(s);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var i;for(const e of this._allTracks)for(const t of e)(i=t.onDestroy)==null||i.call(t)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const i=this._isPaused==!0;if(this._isPaused=!1,i&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const e=[];for(const t of this._audioTracks){const s=t.loadAudio(this._time,1,0);s&&e.push(s)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!As.userInteractionRegistered&&this.waitForAudio;)await bf(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),dn.OnBeforeRender)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.evaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const t of this._audioTracks)t.stop();const i=this._isPaused==!0,e=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.evaluate(),i&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,i&&!e&&this.invokePauseChangedMethodsOnTracks(),e&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){if(!this.isValid())return;let i=this._time;switch(this.extrapolationMode){case 0:this._speed>0?i=Math.min(i,this._duration):this._speed<0&&(i=Math.max(i,0)),this._time=i;break;case 1:i%=this._duration,this._time=i;break;case 2:if(i>this._duration){this.stop();return}break}this.internalEvaluate(i)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const i of this._allTracks)for(const e of i)yield e}get audioTracks(){return this._audioTracks}resolveGuids(i){this._guidsMap=i}invokePauseChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onPauseChanged)==null||i.call(e)}invokeStateChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onStateChanged)==null||i.call(e,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.evaluate()),yield}internalEvaluate(i){for(const e of this.playableAsset.tracks)if(!e.muted)switch(e.type){case Nn.Activation:if(!this._isPlaying)continue;for(let t=0;t<e.outputs.length;t++){const s=e.outputs[t];if(typeof s=="object"){let r=!1;for(const o of e.clips)o.start<=i&&i<=o.end&&(r=!0);const n=s;n.visible!==void 0&&n.visible!==r&&(n.visible=r,Pp&&console.warn(this.name,"set ActivationTrack-"+t,n.name,r,i))}}break}if(!this._isStopping)for(const e of this._animationTracks)e.evaluate(i);for(const e of this._audioTracks)e.evaluate(i);for(const e of this._signalTracks)e.evaluate(i);for(const e of this._controlTracks)e.evaluate(i);for(const e of this._customTracks)e.evaluate(i)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Zv(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const i=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let t=e.outputs.length-1;t>=0;t--){let s=e.outputs[t];if(typeof s=="string"){this._guidsMap&&this._guidsMap[s]&&(s=this._guidsMap[s]);const r=se.findByGuid(s,i);r===null||typeof r!="object"?(e.outputs.splice(t,1),console.warn("Failed to resolve binding",s,e.name,e.type)):(Pp&&console.log("Resolved binding",s,"to",r),e.outputs[t]=r)}else if(s===null){if(e.outputs.splice(t,1),RM.createTrackFunctions[e.type])continue;e.type!==Nn.Audio&&e.type!==Nn.Control&&e.type!==Nn.Marker&&e.type!==Nn.Signal&&console.warn("Missing binding",s,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===Nn.Control)for(let t=0;t<e.clips.length;t++){const s=e.clips[t];let r=s.asset.sourceObject;if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const n=se.findByGuid(r,i);n===null||typeof n!="object"?console.warn("Failed to resolve sourceObject binding",r,e.name,s):(Pp&&console.log("Resolved binding",r,"to",n),s.asset.sourceObject=n)}}}}findRoot(i){return i.parent?this.findRoot(i.parent):i}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const i of this.playableAsset.tracks)if(i.muted!==!0){for(const e of i.clips)e.end>this._duration&&(this._duration=e.end);for(const e of i.markers)e.time>this._duration&&(this._duration=e.time+.001)}}}setupAndCreateTrackHandlers(){var i,e;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;const t=se.findObjectOfType(Tp,this.context);for(const s of this.playableAsset.tracks){const r=s.type,n=RM.createTrackFunctions[r];if(n!=null){const o=n(this,s);if(typeof o.evaluate=="function"){o.director=this,o.track=s,this._customTracks.push(o);continue}}if(s.type===Nn.Animation){if(s.clips.length<=0){Pp&&console.warn("Animation track has no clips",s);continue}for(let o=s.outputs.length-1;o>=0;o--){let a=s.outputs[o];if(a instanceof Re){const c=se.getOrAddComponent(a,Cr);c&&(a=c)}const l=(i=a?.gameObject)==null?void 0:i.animations;if(l){const c=new Gb;c.trackOffset=s.trackOffset,c.director=this,c.track=s;for(let u=0;u<s.clips.length;u++){const d=s.clips[u],p=d.asset;if(!p){console.error("MISSING anim model?","clip#"+u,d,s,this.playableAsset,this.name);continue}const f=p.clip;let m=f;if((typeof m=="string"||typeof m=="number")&&(m=l.find(v=>v.name===f)),!m){console.warn("Could not find animationClip for model",d,s.name,this.name,(e=this.playableAsset)==null?void 0:e.name);continue}a instanceof Cr&&a.runtimeAnimatorController&&(a.__internalDidAwakeAndStart||a.initializeRuntimeAnimatorController(),a.runtimeAnimatorController.mixer||a.runtimeAnimatorController.bind(a),c.mixer=a.runtimeAnimatorController.mixer),c.mixer||(c.mixer=new C0(a.gameObject)),c.clips.push(m),c.mixer.uncacheAction(m),c.createHooks(d.asset,m);const A=c.mixer.clipAction(m);c.actions.push(A),c.models.push(d)}this._animationTracks.push(c)}}}else if(s.type===Nn.Audio){if(s.clips.length<=0)continue;const o=new Tg;if(o.director=this,o.track=s,this._audioTracks.push(o),!t)continue;o.listener=t.listener;for(let a=0;a<s.clips.length;a++){const l=s.clips[a];o.addModel(l)}}else if(s.type===Nn.Marker){const o=new Ig;o.director=this,o.track=s;for(const a of s.markers)switch(a.type){case IM.Signal:o.models.push(a),o.didTrigger.push(!1);break}if(o!==null&&o.models.length>0){const a=se.getComponent(this.gameObject,Rp);a&&(o.receivers.push(a),this._signalTracks.push(o))}}else if(s.type===Nn.Signal){const o=new Ig;o.director=this,o.track=s;for(const a of s.markers)o.models.push(a),o.didTrigger.push(!1);for(const a of s.outputs)o.receivers.push(a);this._signalTracks.push(o)}else if(s.type===Nn.Control){const o=new Hb;o.director=this,o.track=s;for(const a of s.clips)o.models.push(a);o.resolveSourceObjects(this.context),this._controlTracks.push(o)}}}setAudioTracksAllowPlaying(i){for(const e of this._audioTracks)e.onAllowAudioChanged(i)}registerAnimationCallback(i){this.animationCallbackReceivers.push(i)}unregisterAnimationCallback(i){const e=this.animationCallbackReceivers.indexOf(i);e!==-1&&this.animationCallbackReceivers.splice(e,1)}};let Au=RM;h(Au,"createTrackFunctions",{});const Vl=le("debugtimeline");class Eg{constructor(){h(this,"director"),h(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let s=this.track.clips.length-1;s>=0;s--)yield this.track.clips[s];else for(const s of this.track.clips)yield s}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,s,r=!0){if(t<0||t>=s.length)return 0;const n=s[t];if(r||e>=n.start&&e<=n.end){let o=1;const a=!1;if(n.easeInDuration>0){const l=Math.min((e-n.start)/n.easeInDuration,1);o*=l}if(n.easeOutDuration>0&&!a){const l=Math.min((n.end-e)/n.easeOutDuration,1);o*=l}return o}return 0}}class jte{constructor(e){h(this,"clip"),h(this,"rootPositionOffset"),h(this,"rootQuaternionOffset"),h(this,"rootStartPosition"),h(this,"rootEndPosition"),h(this,"rootStartQuaternion"),h(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const s=e.getRoot(),r=s.name+".position",n=s.name+".quaternion";Vl&&console.log(t.name,t.tracks,r);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(r))this.rootStartPosition=new w().fromArray(o.values,0),this.rootEndPosition=new w().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),Vl&&console.log(this.rootPositionOffset);else if(o.name.endsWith(n)&&(this.rootStartQuaternion=new Ee().fromArray(o.values,0),this.rootEndQuaternion=new Ee().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),Vl)){const a=new Es().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Gb extends Eg{constructor(){super(...arguments),h(this,"models",[]),h(this,"trackOffset"),h(this,"target"),h(this,"mixer"),h(this,"clips",[]),h(this,"actions",[]),h(this,"_actionOffsets",[]),h(this,"_didBind",!1),h(this,"_animator",null),h(this,"_useclipOffsets",!0),h(this,"_totalOffsetPosition",new w),h(this,"_totalOffsetRotation",new Ee),h(this,"_totalOffsetPosition2",new w),h(this,"_totalOffsetRotation2",new Ee),h(this,"_summedPos",new w),h(this,"_tempPos",new w),h(this,"_summedRot",new Ee),h(this,"_tempRot",new Ee),h(this,"_clipRotQuat",new Ee)}onStateChanged(){this._animator&&XU(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var s,r;if(((s=t.tracks)==null?void 0:s.length)<=0){console.warn("No tracks in AnimationClip",t);return}const n=t.tracks[0].name.split("."),o=n[n.length-2],a=o+".position",l=o+".quaternion";let c=!1,u=!1;for(const d of t.tracks)d.name.endsWith(a)?(c=!0,this.createPositionInterpolant(t,e,d)):d.name.endsWith(l)&&(u=!0,this.createRotationInterpolant(t,e,d));if(!c||!u){const d=(r=this.mixer)==null?void 0:r.getRoot(),p=t.tracks[0],f=p.name.lastIndexOf("."),m=p.name.substring(0,f),A=m.substring(m.lastIndexOf(".")+1),v=d.getObjectByName(A);if(v)if(c){if(!u){const g=t.tracks[0].name.substring(0,f)+".quaternion";Vl&&console.warn("Create quaternion track",A,v);const b=v.quaternion,y=new ua(g,[0,t.duration],[b.x,b.y,b.z,b.w,b.x,b.y,b.z,b.w]);t.tracks.push(y),this.createRotationInterpolant(t,e,y)}}else{const g=m+".position";Vl&&console.warn("Create position track",A,v);const b=v.position,y=new hl(g,[0,t.duration],[b.x,b.y,b.z,b.x,b.y,b.z]);t.tracks.push(y),this.createPositionInterpolant(t,e,y)}}}bind(){if(!this._didBind){this._didBind=!0,Vl&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const e of this.actions){const t=new jte(e);this._actionOffsets.push(t)}this.target&&(this._animator=se.getComponent(this.target,Cr)??null,this._animator&&XU(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,s=t.position,r=t.rotation;s&&s.x!==void 0&&(s.isVector3||(t.position=new w(s.x,s.y,s.z)),r.isQuaternion||(t.rotation=new Ee(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new w(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new Ee(t.x,t.y,t.z,t.w)))}}evaluate(e){var t,s,r,n,o,a,l;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let c=0,u=0,d=!1,p=!1,f=0;for(let m=0;m<this.clips.length;m++){const A=this.models[m],v=this.actions[m],g=A.asset;v.weight=0;const b=e>=A.start&&e<=A.end,y=A.preExtrapolationMode,_=A.postExtrapolationMode,S=m<this.clips.length-1?this.models[m+1]:null;let M=b,I=!1;if(!M&&!d&&A.end<e&&_!==Ia.None?(!S||S.start>e)&&(M=!0,d=!0):m==0&&!M&&!p&&A.start>e&&y!==Ia.None&&(!S||S.start<e)&&(M=!0,I=!0,p=!0),M){let R=1;R*=this.evaluateWeight(e,m,this.models,M),R*=this.director.weight;let E=b;if(I)switch(y){case Ia.Hold:break;case Ia.Loop:e+=A.start,E=!0;break;default:e+=A.start,E=!0;break}let C=this.getClipTime(e,A),z=0;const q=g.duration;if(I&&y===Ia.Hold&&(C=0),E){if(g.loop)for(z+=Math.floor(C/(q+1e-6));C>q;)C-=q}else if(!b&&d)switch(_){case Ia.Hold:C=this.getClipTime(A.end,A);break;case Ia.Loop:C%=q;break;case Ia.PingPong:const G=Math.floor(C/q)%2!==0;C%=q,G&&(C=q-C);break}A.reversed===!0?v.time=v.getClip().duration-C:v.time=C,v.timeScale=0;const Q=Math.max(0,R);if(v.weight=Q,f+=Q,v.clampWhenFinished=!1,v.isRunning()||v.play(),this._useclipOffsets){const G=c==0?this._totalOffsetPosition:this._totalOffsetPosition2,$=c==0?this._totalOffsetRotation:this._totalOffsetRotation2;c<1&&(u=1-R),c+=1;const F=this._summedPos.set(0,0,0),L=this._tempPos.set(0,0,0),N=this._summedRot.identity(),re=this._tempRot.identity(),Z=g.rotation;Z&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(Z,R));const X=this._actionOffsets[m];if(X.hasOffsets)for(let ne=0;ne<z;ne++)X.rootPositionOffset?L.copy(X.rootPositionOffset):L.set(0,0,0),L.applyQuaternion(N),this._clipRotQuat&&L.applyQuaternion(this._clipRotQuat),X.rootQuaternionOffset&&(re.copy(X.rootQuaternionOffset),N.multiply(re)),F.add(L);this._clipRotQuat&&$.multiply(this._clipRotQuat),$.multiply(N),g.position&&F.add(g.position),G.add(F)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,u),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,u)),this.__mixerError===void 0&&(Vl||gi())&&(s=(t=this._animator)==null?void 0:t.runtimeAnimatorController)!=null&&s.mixer&&this.mixer!==((n=(r=this._animator)==null?void 0:r.runtimeAnimatorController)==null?void 0:n.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(o=this._animator)!=null&&o.runtimeAnimatorController){const m=Math.max(0,1-f);(l=(a=this._animator)==null?void 0:a.runtimeAnimatorController)==null||l.update(m)}else this.mixer.update(e)}createRotationInterpolant(e,t,s){var r;const n=s.createInterpolant.bind(s),o=new Ee;this.ensureTrackOffsets();const a=(r=this.trackOffset)==null?void 0:r.rotation;s.createInterpolant=()=>{const l=n(),c=l.evaluate.bind(l);return l.evaluate=u=>{var d;const p=c(u);if(o.set(p[0],p[1],p[2],p[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const f of this.director.animationCallbackReceivers)(d=f?.onTimelineRotation)==null||d.call(f,this.director,this.target,u,o);return p[0]=o.x,p[1]=o.y,p[2]=o.z,p[3]=o.w,p},l}}createPositionInterpolant(e,t,s){var r,n;const o=s.createInterpolant.bind(s),a=new w;this.ensureTrackOffsets();const l=(r=this.trackOffset)==null?void 0:r.rotation,c=(n=this.trackOffset)==null?void 0:n.position;let u;s.createInterpolant=()=>{const d=o(),p=d.evaluate.bind(d);return d.evaluate=f=>{var m,A,v;const g=p(f);if(a.set(g[0],g[1],g[2]),t.removeStartOffset&&(u===void 0?(u=null,u=(A=(m=this._actionOffsets.find(b=>b.clip===e))==null?void 0:m.rootStartPosition)==null?void 0:A.clone()):u!=null&&u.isVector3&&a.sub(u)),a.applyQuaternion(this._totalOffsetRotation),a.add(this._totalOffsetPosition),l&&a.applyQuaternion(l),c&&(a.x-=c.x,a.y+=c.y,a.z+=c.z),this.director.animationCallbackReceivers)for(const b of this.director.animationCallbackReceivers)(v=b?.onTimelinePosition)==null||v.call(b,this.director,this.target,f,a);return g[0]=a.x,g[1]=a.y,g[2]=a.z,g},d}}}const Qte=le("mutetimeline"),Mg=class extends Eg{constructor(){super(...arguments),h(this,"models",[]),h(this,"listener"),h(this,"audio",[]),h(this,"audioContextTimeOffset",[]),h(this,"lastTime",0),h(this,"_audioLoader",null)}getAudioFilePath(i){const e=this.director.sourceId;return Ya(e,i)}onAllowAudioChanged(i){for(let e=0;e<this.models.length;e++){const t=this.models[e];this.audio[e].setVolume(i?t.asset.volume:0)}}addModel(i){const e=new S0(this.listener);this.audio.push(e),this.models.push(i)}onDisable(){for(const i of this.audio)i.isPlaying&&i.stop()}onDestroy(){for(const i of this.audio)i.source&&i?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}stop(){for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}evaluate(i){if(Qte||this.track.muted||this.director.speed<0)return;const e=this.director.context.application.muted,t=e?.1:0;for(let s=0;s<this.models.length;s++){const r=this.models[s],n=this.audio[s];if((!n||!n.buffer)&&this.isInTimeRange(r,i-1,i+1)&&this.handleAudioLoading(r,n),As.userInteractionRegistered!==!1&&!(n===null||!n.buffer))if(n.playbackRate=this.director.context.time.timeScale,n.loop=r.asset.loop,i>=r.start&&i<=r.end&&i<this.director.duration){if(this.director.isPlaying==!1){if(n.isPlaying&&n.stop(),this.lastTime===i)continue}else if(!n.isPlaying)n.offset=r.clipIn+(i-r.start)*r.timeScale,n.play(t);else{const a=r.clipIn+(i-r.start)*r.timeScale,l=n.context.currentTime-n._startedAt+n.offset;Math.abs(a-l)>.3&&(n.offset=a,n.stop(),n.play(t))}let o=r.asset.volume;if(e&&(o=0),r.easeInDuration>0){const a=Math.min((i-r.start)/r.easeInDuration,1);o*=a}if(r.easeOutDuration>0){const a=Math.min((r.end-i)/r.easeOutDuration,1);o*=a}n.setVolume(o*this.director.weight)}else n.isPlaying&&n.stop()}this.lastTime=i}loadAudio(i,e=0,t=0){let s=null;const r=i-t,n=i+e;for(const o of this.models)if(this.isInTimeRange(o,r,n)){const a=this.audio[this.models.indexOf(o)],l=this.handleAudioLoading(o,a);l!==null&&(s===null&&(s=[]),s.push(l))}return s!==null?Promise.all(s):null}isInTimeRange(i,e,t){return e<=i.start&&t>=i.end||e>=i.start&&e<=i.end||t>=i.start&&t<=i.end}static dispose(){Mg._audioBuffers.clear()}handleAudioLoading(i,e){this._audioLoader||(this._audioLoader=new w0);const t=this.getAudioFilePath(i.asset.clip);if(Mg._audioBuffers.get(t)){const r=Mg._audioBuffers.get(t);return r.then(n=>{n&&e.setBuffer(n)}),r}Vl&&console.warn("LOAD audio track",t,this.director.sourceId);const s=new Promise((r,n)=>{this._audioLoader.load(t,o=>{e.setBuffer(o),r(o)},void 0,o=>{console.error("Error loading audio",o),r(null)})});return Mg._audioBuffers.set(t,s),s}};let Tg=Mg;h(Tg,"_audioBuffers",new Map);class Ig extends Eg{constructor(){super(...arguments),h(this,"models",[]),h(this,"didTrigger",[]),h(this,"receivers",[])}evaluate(e){var t;if(this.track.muted)return;const s=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const n=this.models[r],o=this.didTrigger[r],a=n.time-e;let l=!1;if(n.retroActive)l=a<=1e-6;else{const c=Math.abs(a);(c===0||c>=1e-5&&c<s)&&(l=!0)}if(l){if(!o)if(Vl&&console.log("Trigger signal",e,n.time,n),this.didTrigger[r]=!0,((t=this.receivers)==null?void 0:t.length)<=0)Rp.invoke(n.asset);else for(const c of this.receivers)c&&c.invoke(n.asset)}else n.emitOnce||(this.didTrigger[r]=!1)}}}class Hb extends Eg{constructor(){super(...arguments),h(this,"models",[]),h(this,"timelines",[]),h(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const s=this.models[t].asset;if(!s.sourceObject||typeof s.sourceObject!="object"){console.log("no source object, removing model",t,s),this.models.splice(t,1);continue}else{const r=se.getComponent(s.sourceObject,Au);this.timelines.push(r),r&&s.updateDirector&&(r.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],n=r.asset;if(e>=r.start&&e<=r.end){this._previousActiveModel=r;const o=this.getClipTime(e,r);if(n.controlActivation){const a=n.sourceObject;a.visible=!0}if(n.updateDirector){const a=this.timelines[s];a&&(a.isPlaying&&a.pause(),a.time=o,a.evaluate())}}else{const o=(t=this._previousActiveModel)==null?void 0:t.asset;if(n.controlActivation){const a=n.sourceObject;o?.sourceObject!==a&&(a.visible=!1)}}}}}var Gte=Object.defineProperty,Hte=Object.getOwnPropertyDescriptor,YN=(i,e,t,s)=>{for(var r=s>1?void 0:s?Hte(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Gte(e,t,r),r};class Tt{constructor(e){h(this,"_active",!0),h(this,"_value"),h(this,"_valueRaw"),h(this,"_defaultValue"),h(this,"valueProcessor"),h(this,"onValueChanged"),this._value=e,this._defaultValue=e,this._valueRaw=e}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}get value(){return this._valueRaw}set value(e){this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;const s=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,s,this)}testIfValueChanged(e){return this._valueRaw!==e}}YN([x()],Tt.prototype,"overrideState",1),YN([x()],Tt.prototype,"value",1);var Vte=Object.defineProperty,Wte=Object.getOwnPropertyDescriptor,Xte=(i,e,t,s)=>{for(var r=s>1?void 0:s?Wte(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Vte(e,t,r),r};const qte=le("debugpost");class Tr extends Oc{constructor(e=void 0){if(super(),h(this,"active",!0),h(this,"_result"),h(this,"_didCreateVolumeParameters",!1),e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const s=e[t],r=this[t];r instanceof Tt&&(r.value=s)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var e;return this.ensureVolumeParameters(),this._result||(this._result=(e=this.onCreateEffect)==null?void 0:e.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){qte&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const s=this[t];s instanceof Tt&&s.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const s=this.$serializedTypes;if(s){for(const r of Object.keys(s))if(s[r]===Tt){const n=e[r];if(n!==void 0){const o=this[r];o.value=n}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof Tt){const s=e.value;return this[t].value=s,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===Tt&&(this[t]||(this[t]=new Tt))}}Xte([x()],Tr.prototype,"active",2);var Yte=Object.defineProperty,Kte=Object.getOwnPropertyDescriptor,Jte=(i,e,t,s)=>{for(var r=s>1?void 0:s?Kte(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Yte(e,t,r),r};const Zte=le("debugpost"),PM={};function mo(i,e){PM[i]=e}function $te(i){return i.__type in PM?PM[i.__type]:(Zte&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),Tr)}class Rg{constructor(){h(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}Jte([sp([i=>$te(i),Tr])],Rg.prototype,"components",2);var eie=Object.defineProperty,tie=Object.getOwnPropertyDescriptor,iie=(i,e,t,s)=>{for(var r=s>1?void 0:s?tie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&eie(e,t,r),r};class Pg extends Tr{constructor(){super(...arguments),h(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new oq({preset:Vd.HIGH,edgeDetectionMode:sC.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}iie([x(Tt)],Pg.prototype,"preset",2),mo("Antialiasing",Pg);class Vb{constructor(){h(this,"files",[])}get extensionName(){return"Audio"}onExportObject(e,t,s){const r=se.getComponents(e,As);if(r.length)for(const n of r){if(!n.clip||!n.playOnAwake)continue;const o=n.clip.split("/").pop();this.files.includes(n.clip)||this.files.push(n.clip),t.addEventListener("serialize",(a,l)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${t.name}"`),a.appendLine(`uniform asset filePath = @audio/${o}@`),a.appendLine(`uniform token auralMode = "${n.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${n.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${n.volume}`),a.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const s=t.split("/").pop(),r=await(await(await fetch(t)).blob()).arrayBuffer(),n=new Uint8Array(r);e.files["audio/"+s]=n}}}var sie=Object.defineProperty,rie=Object.getOwnPropertyDescriptor,KN=(i,e,t,s)=>{for(var r=s>1?void 0:s?rie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&sie(e,t,r),r};const nie=le("debugmouth");class Bg extends Ie{constructor(){super(...arguments),h(this,"idle",[]),h(this,"talking",[]),h(this,"marker",null),h(this,"voip",null),h(this,"lastMouthChangeTime",0),h(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=se.findObjectOfType(nc,this.context),this.marker||(this.marker=se.getComponentInParent(this.gameObject,Mr))},3e3)}update(){var e;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((e=this.marker)==null?void 0:e.connectionId)??null;if(!t){nie&&(t=null);return}const s=this.voip.getFrequency(t)??0;this.updateLips(s)}updateLips(e){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&e>30){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,t)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,t)}}}setMouthShapeActive(e,t){if(e){e!=this.idle?this.idle.map(s=>s.visible=!1):this.talking.map(s=>s.visible=!1);for(let s=0;s<e.length;s++){const r=e[s];r&&(r.visible=s===t)}}}}KN([x(Re)],Bg.prototype,"idle",2),KN([x(Re)],Bg.prototype,"talking",2);class BM extends Ie{constructor(){super(...arguments),h(this,"voip",null),h(this,"marker",null),h(this,"_startPosition",null)}awake(){this.voip=se.findObjectOfType(nc,this.context),this.marker=se.getComponentInParent(this.gameObject,Mr)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const e=this.marker.connectionId,t=this.voip.getFrequency(e);if(t==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const s=t/100;this.gameObject.position.y=this._startPosition.y+s*.07}}var oie=Object.defineProperty,aie=Object.getOwnPropertyDescriptor,Wb=(i,e,t,s)=>{for(var r=s>1?void 0:s?aie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&oie(e,t,r),r};class yu extends Ie{constructor(){super(...arguments),h(this,"eyes",[]),h(this,"lastBlinkTime",0),h(this,"blinkLength",0),h(this,"eyesOpen",!0),h(this,"state",null)}awake(){this.state=se.getComponentInParent(this.gameObject,Dn)}update(){if(!(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)&&this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const e of this.eyes)e&&(e.visible=this.eyesOpen)}}}Wb([x(Re)],yu.prototype,"eyes",2),Wb([x()],yu.prototype,"lastBlinkTime",2),Wb([x()],yu.prototype,"blinkLength",2),Wb([x()],yu.prototype,"eyesOpen",2);var lie=Object.defineProperty,cie=Object.getOwnPropertyDescriptor,kM=(i,e,t,s)=>{for(var r=s>1?void 0:s?cie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&lie(e,t,r),r},DM;const JN=(DM=class extends Ie{constructor(){super(...arguments),h(this,"head",null),h(this,"eyes",null),h(this,"target",null),h(this,"brain",null),h(this,"vec",new w),h(this,"currentTargetPoint",new w)}awake(){this.brain||(this.brain=se.getComponentInParent(this.gameObject,sg)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=se.addNewComponent(this.gameObject,sg)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const i=this.target;if(i&&this.head){const e=this.eyes;if(e){const t=At(i);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const s=At(this.head),r=this.vec.copy(this.currentTargetPoint).sub(s).normalize();if(r.length()<.1)return;const n=JN.forward;if(n.set(0,0,1),n.applyQuaternion(Bs(this.head)),n.dot(r)>.45)for(let o=0;o<e.length;o++)e[o].lookAt(this.currentTargetPoint)}}}},h(DM,"forward",new w(0,0,1)),DM);let Bp=JN;kM([x(Re)],Bp.prototype,"head",2),kM([x(Re)],Bp.prototype,"eyes",2),kM([x(Re)],Bp.prototype,"target",2);var hie=Object.defineProperty,uie=Object.getOwnPropertyDescriptor,OM=(i,e,t,s)=>{for(var r=s>1?void 0:s?uie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&hie(e,t,r),r};class kp extends Ie{constructor(){super(...arguments),h(this,"length",1),h(this,"depthTest",!0),h(this,"isGizmo",!0),h(this,"_axes",null)}onEnable(){if(this.isGizmo&&!am)return;this._axes||(this._axes=new Ud(this.length)),this.gameObject.add(this._axes);const e=this._axes.material;e&&e.depthTest!==void 0&&(e.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}OM([x()],kp.prototype,"length",2),OM([x()],kp.prototype,"depthTest",2),OM([x()],kp.prototype,"isGizmo",2);class LM extends Ie{constructor(){super(...arguments),h(this,"from"),h(this,"to"),h(this,"hint"),h(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const e=At(this.to).clone(),t=At(this.from).clone(),s=e.distanceTo(t),r=e.clone();r.sub(t);const n=t.clone();n.add(e),n.multiplyScalar(.5);const o=At(this.hint).clone();o.sub(n);const a=new w;a.crossVectors(o,r),a.crossVectors(r,a),a.normalize();const l=s*.5,c=Math.max(this.desiredDistance,l),u=Math.sqrt(c*c-l*l),d=a.clone();d.multiplyScalar(u),d.add(n),ns(this.gameObject,d);const p=n.clone();p.sub(a),this.gameObject.lookAt(p)}}const ZN=le("debugusdz");class Xb{constructor(){h(this,"behaviours",[]),h(this,"behaviourComponents",[]),h(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(e){this.behaviours.push(e)}onBeforeBuildDocument(e){const t=[];return e.root.traverse(s=>{se.foreachComponent(s,r=>{var n;const o=r;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const a=(n=o.beforeCreateDocument)==null?void 0:n.call(o,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,s){var r;for(const n of this.behaviourComponents)(r=n.createBehaviours)==null||r.call(n,this,t,s)}onAfterBuildDocument(e){for(const t of this.behaviourComponents)typeof t.afterCreateDocument=="function"&&t.afterCreateDocument(this,e);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(e,t){var s;if((s=this.behaviours)!=null&&s.length){t.beginBlock('def Scope "Behaviors"');for(const r of this.behaviours)r.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){ZN&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const t of this.behaviourComponentsCopy)typeof t.afterSerialize=="function"&&(ZN&&console.log("behaviour has afterSerialize",t),t.afterSerialize.constructor.name==="AsyncFunction"?await t.afterSerialize(this,e):t.afterSerialize(this,e))}}var die=Object.defineProperty,pie=Object.getOwnPropertyDescriptor,UM=(i,e,t,s)=>{for(var r=s>1?void 0:s?pie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&die(e,t,r),r};class bu extends Tr{constructor(){super(...arguments),h(this,"threshold"),h(this,"intensity"),h(this,"scatter"),h(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>1*Math.PI*(1-e)):(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>100*(1-e))}onCreateEffect(){let e;if(this.selectiveBloom){const t=e=new FO(this.context.scene,this.context.mainCamera,{blendFunction:Nt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new cC;return this.intensity.onValueChanged=t=>{e.intensity=t},this.threshold.onValueChanged=t=>{e.luminanceMaterial.threshold=t},this.scatter.onValueChanged=t=>{e.luminancePass.enabled=!0,e.luminanceMaterial.smoothing=t},e}}UM([x(Tt)],bu.prototype,"threshold",2),UM([x(Tt)],bu.prototype,"intensity",2),UM([x(Tt)],bu.prototype,"scatter",2),mo("Bloom",bu);var fie=Object.defineProperty,mie=Object.getOwnPropertyDescriptor,qo=(i,e,t,s)=>{for(var r=s>1?void 0:s?mie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&fie(e,t,r),r};class Ra extends Ie{constructor(){super(...arguments),h(this,"attachedRigidbody",null),h(this,"isTrigger",!1),h(this,"sharedMaterial")}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Vi))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Vi))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Vi))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}}qo([x(Vi)],Ra.prototype,"attachedRigidbody",2),qo([x()],Ra.prototype,"isTrigger",2),qo([x()],Ra.prototype,"sharedMaterial",2);class kg extends Ra{constructor(){super(...arguments),h(this,"radius",.5),h(this,"center",new w(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this,this.center,this.radius)}}qo([x()],kg.prototype,"radius",2),qo([x(w)],kg.prototype,"center",2);class Dg extends Ra{constructor(){super(...arguments),h(this,"size",new w(1,1,1)),h(this,"center",new w(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.center,this.size)}}qo([x(w)],Dg.prototype,"size",2),qo([x(w)],Dg.prototype,"center",2);class Og extends Ra{constructor(){super(...arguments),h(this,"sharedMesh"),h(this,"convex",!1)}onEnable(){var e,t,s,r,n;if(super.onEnable(),(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof ye&&(this.sharedMesh=this.gameObject),(t=this.sharedMesh)!=null&&t.isMesh)(s=this.context.physics.engine)==null||s.addMeshCollider(this,this.sharedMesh,this.convex,js(this.gameObject));else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${(r=this.sharedMesh)==null?void 0:r.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const a in o.children){const l=o.children[a];l.isMesh&&((n=this.context.physics.engine)==null||n.addMeshCollider(this,l,this.convex,js(this.gameObject)))}}}}}qo([x()],Og.prototype,"convex",2);class Zc extends Ra{constructor(){super(...arguments),h(this,"center",new w(0,0,0)),h(this,"radius",.5),h(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.center,this.height,this.radius)}}qo([x(w)],Zc.prototype,"center",2),qo([x()],Zc.prototype,"radius",2),qo([x()],Zc.prototype,"height",2);var gie=Object.defineProperty,vie=Object.getOwnPropertyDescriptor,Lg=(i,e,t,s)=>{for(var r=s>1?void 0:s?vie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&gie(e,t,r),r};const FM=le("debugui"),NM=le("debuguilayout");class zM{constructor(){h(this,"width"),h(this,"height")}}class jM{constructor(){h(this,"x"),h(this,"y"),h(this,"width"),h(this,"height")}}const Yo=new w,Ug=new Be,qb=new Ee,$N=class extends ia{constructor(){super(...arguments),h(this,"_anchoredPosition"),h(this,"sizeDelta",new ee(100,100)),h(this,"pivot",new ee(.5,.5)),h(this,"anchorMin",new ee(0,0)),h(this,"anchorMax",new ee(1,1)),h(this,"lastMatrix"),h(this,"rectBlock"),h(this,"_transformNeedsUpdate",!1),h(this,"_initialPosition"),h(this,"_parentRectTransform"),h(this,"_lastUpdateFrame",-1),h(this,"_lastAnchoring"),h(this,"_createdBlocks",[]),h(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new ee),this._anchoredPosition}set anchoredPosition(i){this._anchoredPosition=i}get width(){if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const i=this._parentRectTransform.width,e=this.anchorMax.x-this.anchorMin.x;let t=i*e;return t+=this.sizeDelta.x,t}return this.sizeDelta.x}get height(){if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const i=this._parentRectTransform.height,e=this.anchorMax.y-this.anchorMin.y;let t=i*e;return t+=this.sizeDelta.y,t}return this.sizeDelta.y}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new ee),this.lastMatrix=new Be,this.rectBlock=new Re,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Mp(this,"_anchoredPosition",()=>{this.markDirty()}),Mp(this,"sizeDelta",()=>{this.markDirty()}),Mp(this,"pivot",()=>{this.markDirty()}),Mp(this,"anchorMin",()=>{this.markDirty()}),Mp(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var i;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(i=this.Canvas)==null||i.registerTransform(this)}onDisable(){var i;super.onDisable(),this.removeShadowComponent(),(i=this.Canvas)==null||i.unregisterTransform(this)}onParentRectTransformChanged(i){this._transformNeedsUpdate||this.onApplyTransform(NM?`${i.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(NM&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(i){var e;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const t=this.shadowComponent;if(!t)return;this.gameObject.parent?this._parentRectTransform=se.getComponentInParent(this.gameObject.parent,$N):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,NM&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+i),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,Yo.set(0,0,0),this.applyPivot(Yo),t.matrix.setPosition(Yo.x,Yo.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(qb.copy(this.gameObject.quaternion),qb.x*=-1,qb.z*=-1,Ug.makeRotationFromQuaternion(qb),t.matrix.premultiply(Ug)),Yo.set(0,0,0),this.applyAnchoring(Yo),(e=this.Canvas)!=null&&e.screenspace?Yo.z+=.1:Yo.z+=.01,Ug.identity(),Ug.setPosition(Yo.x,Yo.y,Yo.z),t.matrix.premultiply(Ug),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const s=!0;for(const r of J1(this.gameObject,ia,s,1)){if(r===this||!r.activeAndEnabled)continue;const n=r;n.onParentRectTransformChanged&&n.onParentRectTransformChanged(this)}}applyAnchoring(i){this._lastAnchoring||(this._lastAnchoring=new ee);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),i.x+=this._initialPosition.x-this.gameObject.position.x,i.y+=this._initialPosition.y-this.gameObject.position.y,i.z+=this._initialPosition.z-this.gameObject.position.z;const t=this._parentRectTransform;if(t){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=t.height*.5*r,i.y+=s;let n=0;const o=1-this.anchorMax.x-this.anchorMin.x;n-=t.width*.5*o,i.x+=n}}applyPivot(i){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;i.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const t=this.pivot.y-.5;i.y-=t*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const i={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(i),i}ensureValidSize(i,e=1e-4){return i.width<=0&&(i.width=e),i.height<=0&&(i.height=1e-4),i}createNewBlock(i){i={...this.getBasicOptions(),...i},FM&&console.log(this.name,i);const e=new vM(i);return this._createdBlocks.push(e),e}createNewText(i){FM&&console.log(i),i={...this.getBasicOptions(),...i},FM&&console.log(this.name,i);const e=new zN(i);return this._createdTextBlocks.push(e),e}};let Kr=$N;Lg([x(ee)],Kr.prototype,"anchoredPosition",1),Lg([x(ee)],Kr.prototype,"sizeDelta",2),Lg([x(ee)],Kr.prototype,"pivot",2),Lg([x(ee)],Kr.prototype,"anchorMin",2),Lg([x(ee)],Kr.prototype,"anchorMax",2);class Aie extends NN{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const s in t)for(const r in t[s])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(s);for(const s of e._components)e._simpleState__statesProperties[s.id]&&(e._simpleState__normalStyles[s.id]=s.inline?s.inline:s._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;const s=[];for(const r in t)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],s.push(r)),this._simpleState__statesProperties[r].push(e);for(const r of this._components)s.indexOf(r.id)>-1&&(this._simpleState__normalStyles[r.id]=r.inline?r.inline:r._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const s in e)this._simpleState__statesProperties[s]&&(this._simpleState__normalStyles[s]=e[s]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var yie=Object.defineProperty,bie=Object.getOwnPropertyDescriptor,e3=(i,e,t,s)=>{for(var r=s>1?void 0:s?bie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&yie(e,t,r),r};class Dp extends Ie{constructor(){super(...arguments),h(this,"effectColor"),h(this,"effectDistance")}}e3([x(Ai)],Dp.prototype,"effectColor",2),e3([x(ee)],Dp.prototype,"effectDistance",2);var _ie=Object.defineProperty,xie=Object.getOwnPropertyDescriptor,t3=(i,e,t,s)=>{for(var r=s>1?void 0:s?xie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&_ie(e,t,r),r};const Yb={backgroundColor:new _e(1,1,1),backgroundOpacity:1,borderColor:new _e(1,1,1),borderOpacity:1};var QM;const Kb=(QM=class extends ia{constructor(){super(...arguments),h(this,"_alphaFactor",1),h(this,"raycastTarget",!0),h(this,"uiObject",null),h(this,"_color",null),h(this,"_rect",null),h(this,"_stateManager",null),h(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new Ai(1,1,1,1)),this._color}set color(i){(!this._color||this._color.r!==i.r||this._color.g!==i.g||this._color.b!==i.b||this._color.alpha!==i.alpha)&&(this._color||(this._color=new Ai(1,1,1,1)),this._color.copy(i))}setAlphaFactor(i){this._alphaFactor=i,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(Yb.backgroundColor=this._color,Yb.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(Yb,this._alphaFactor),this.uiObject.set(Yb),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=se.getComponent(this.gameObject,Kr)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var i;(i=this.uiObject)==null||i.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(i){this.makePanel(),this.uiObject&&(this.uiObject.setState(i),this==null||this.markDirty())}setupState(i){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new Aie(this.uiObject)),this.uiObject.setupState(i.state,i.attributes))}setOptions(i){this.makePanel(),this.uiObject&&this.uiObject.set(i)}awake(){super.awake(),this.makePanel(),Mp(this,"_color",()=>Ite(this,this.onColorChanged))}onEnable(){var i;super.onEnable(),this.uiObject&&((i=this.rectTransform.shadowComponent)==null||i.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const i=.015,e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:i};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated()}onBeforeCreate(i){}onCreate(i){this.uiObject=this.rectTransform.createNewBlock(i),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(i,e=1){var t;const s=(t=this.gameObject)==null?void 0:t.getComponent(Dp);s&&(s.effectDistance&&(i.borderWidth=Math.max(Math.abs(s.effectDistance.x),Math.abs(s.effectDistance.y))),s.effectColor&&(i.borderColor=s.effectColor,i.borderOpacity=s.effectColor.alpha*e))}async setTexture(i){if(this.setOptions({backgroundOpacity:0}),i){if(i.colorSpace===et){if(Kb.textureCache.has(i))i=Kb.textureCache.get(i);else if(!i.isRenderTargetTexture){const e=i.clone();e.colorSpace=ts,Kb.textureCache.set(i,e),i=e}}this.setOptions({backgroundImage:i,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},h(QM,"textureCache",new Map),QM);let _u=Kb;t3([x(Ai)],_u.prototype,"color",1),t3([x()],_u.prototype,"raycastTarget",2);class Fg extends _u{constructor(){super(...arguments),h(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var wie=Object.defineProperty,Sie=Object.getOwnPropertyDescriptor,Jb=(i,e,t,s)=>{for(var r=s>1?void 0:s?Sie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&wie(e,t,r),r};let GM=class{constructor(){h(this,"texture",null),h(this,"rect")}};Jb([x(Pt)],GM.prototype,"texture",2);let Op=class extends Fg{constructor(){super(...arguments),h(this,"_sprite"),h(this,"pixelsPerUnitMultiplier",1)}set image(i){this.sprite||(this.sprite=new GM),this.sprite.texture=i,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(i){this._sprite!==i&&(this._sprite=i,this.onAfterCreated())}isBuiltinSprite(){var i,e,t,s,r,n,o,a;switch((e=(i=this.sprite)==null?void 0:i.texture)==null?void 0:e.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((r=(s=(t=this.sprite)==null?void 0:t.texture)==null?void 0:s.image)==null?void 0:r.width)===32&&((a=(o=(n=this.sprite)==null?void 0:n.texture)==null?void 0:o.image)==null?void 0:a.height)===32}onBeforeCreate(i){var e,t;super.onBeforeCreate(i),this.isBuiltinSprite()&&(i.borderRadius=5/this.pixelsPerUnitMultiplier,((t=(e=this.sprite)==null?void 0:e.texture)==null?void 0:t.name)==="Knob"&&(i.borderRadius=999))}onAfterCreated(){var i;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((i=this.sprite)==null?void 0:i.texture))}};Jb([x(GM)],Op.prototype,"sprite",1),Jb([x()],Op.prototype,"pixelsPerUnitMultiplier",2);class Zb extends Fg{constructor(){super(...arguments),h(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}Jb([x(Pt)],Zb.prototype,"mainTexture",1);var Cie=Object.defineProperty,Eie=Object.getOwnPropertyDescriptor,zn=(i,e,t,s)=>{for(var r=s>1?void 0:s?Eie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Cie(e,t,r),r};const Lp=le("debugbutton");class xu{constructor(){h(this,"colorMultiplier"),h(this,"disabledColor"),h(this,"fadeDuration"),h(this,"highlightedColor"),h(this,"normalColor"),h(this,"pressedColor"),h(this,"selectedColor")}}zn([x()],xu.prototype,"colorMultiplier",2),zn([x(Ai)],xu.prototype,"disabledColor",2),zn([x()],xu.prototype,"fadeDuration",2),zn([x(Ai)],xu.prototype,"highlightedColor",2),zn([x(Ai)],xu.prototype,"normalColor",2),zn([x(Ai)],xu.prototype,"pressedColor",2),zn([x(Ai)],xu.prototype,"selectedColor",2);class Wl extends Ie{constructor(){super(...arguments),h(this,"onClick"),h(this,"_isHovered",!1),h(this,"colors"),h(this,"transition"),h(this,"animationTriggers"),h(this,"animator"),h(this,"_interactable",!0),h(this,"_requestedAnimatorTrigger"),h(this,"_isInit",!1),h(this,"_image")}onPointerEnter(e){var t,s;Lp&&console.log("Button Enter",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this._isHovered=!0,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var e,t;Lp&&console.log("Button Exit",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this._isHovered=!1,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((t=this._image)==null||t.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(e){var t,s;Lp&&console.log("Button Down",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("pressed")))}onPointerUp(e){var t,s;Lp&&console.warn("Button Up",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){var t;this.interactable&&e.pointerId===0&&(Lp&&(console.warn("Button Click",this.onClick),fs("CLICKED button "+this.name+" at "+this.context.time.frameCount)),(t=this.onClick)==null||t.invoke())}set interactable(e){this._interactable=e,this._image&&(this._image.setInteractable(e),e?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(e){this.interactable=e}awake(){super.awake(),Lp&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable)}onEnable(){super.onEnable()}*setAnimatorTriggerAtEndOfFrame(e){var t;this._requestedAnimatorTrigger=e,yield,yield,this._requestedAnimatorTrigger==e&&((t=this.animator)==null||t.SetTrigger(e))}init(){this._isInit||(this._isInit=!0,this._image=se.getComponent(this.gameObject,Op),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var t,s,r,n,o;e.setInteractable(this.interactable);const a=this.getFinalColor(e.color,(t=this.colors)==null?void 0:t.normalColor),l={state:"normal",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};e.setupState(l);const c=this.getFinalColor(e.color,(s=this.colors)==null?void 0:s.highlightedColor),u={state:"hovered",attributes:{backgroundColor:c,backgroundOpacity:c.alpha}};e.setupState(u);const d=this.getFinalColor(e.color,(r=this.colors)==null?void 0:r.pressedColor),p={state:"pressed",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};e.setupState(p);const f=this.getFinalColor(e.color,(n=this.colors)==null?void 0:n.selectedColor),m={state:"selected",attributes:{backgroundColor:f,backgroundOpacity:f.alpha}};e.setupState(m);const A=this.getFinalColor(e.color,(o=this.colors)==null?void 0:o.disabledColor),v={state:"disabled",attributes:{backgroundColor:A,backgroundOpacity:A.alpha}};e.setupState(v)}getFinalColor(e,t){return t?e.clone().multiply(t):e.clone()}}zn([x(ir)],Wl.prototype,"onClick",2),zn([x()],Wl.prototype,"colors",2),zn([x()],Wl.prototype,"transition",2),zn([x()],Wl.prototype,"animationTriggers",2),zn([x(Cr)],Wl.prototype,"animator",2),zn([x()],Wl.prototype,"interactable",1);var Mie=Object.defineProperty,Tie=Object.getOwnPropertyDescriptor,_s=(i,e,t,s)=>{for(var r=s>1?void 0:s?Tie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Mie(e,t,r),r};const i3=le("debuguilayout");class $c{constructor(){h(this,"left",0),h(this,"right",0),h(this,"top",0),h(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}_s([x()],$c.prototype,"left",2),_s([x()],$c.prototype,"right",2),_s([x()],$c.prototype,"top",2),_s([x()],$c.prototype,"bottom",2);class jn extends Ie{constructor(){super(...arguments),h(this,"_rectTransform",null),h(this,"_needsUpdate",!1),h(this,"childAlignment",0),h(this,"reverseArrangement",!1),h(this,"spacing",0),h(this,"padding"),h(this,"minWidth",0),h(this,"minHeight",0),h(this,"flexibleHeight",0),h(this,"flexibleWidth",0),h(this,"preferredHeight",0),h(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(e){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(i3&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){i3&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(Kr);const e=this.gameObject.getComponentInParent(nr);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(nr);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}_s([x()],jn.prototype,"childAlignment",2),_s([x()],jn.prototype,"reverseArrangement",2),_s([x()],jn.prototype,"spacing",2),_s([x($c)],jn.prototype,"padding",2),_s([x()],jn.prototype,"minWidth",2),_s([x()],jn.prototype,"minHeight",2),_s([x()],jn.prototype,"flexibleHeight",2),_s([x()],jn.prototype,"flexibleWidth",2),_s([x()],jn.prototype,"preferredHeight",2),_s([x()],jn.prototype,"preferredWidth",2);class eh extends jn{constructor(){super(...arguments),h(this,"childControlHeight",!0),h(this,"childControlWidth",!0),h(this,"childForceExpandHeight",!1),h(this,"childForceExpandWidth",!1),h(this,"childScaleHeight",!1),h(this,"childScaleWidth",!1)}onCalculateLayout(e){var t;const s=this.primaryAxis,r=e.width;let n=r;const o=e.height;let a=o;n-=this.padding.horizontal,a-=this.padding.vertical,s==="x"?this.padding.horizontal:this.padding.vertical;const l=s==="x",c=l?"y":"x",u=l?this.childControlWidth:this.childControlHeight,d=l?this.childControlHeight:this.childControlWidth,p=l?this.childForceExpandWidth:this.childForceExpandHeight,f=l?this.childForceExpandHeight:this.childForceExpandWidth,m=l?a:n,A=l?r:o,v=.5*(l?this.childAlignment%3:Math.floor(this.childAlignment/3));let g=0;l?g+=this.padding.left:g+=this.padding.top;let b=0,y=0;for(let R=0;R<this.gameObject.children.length;R++){const E=this.gameObject.children[R],C=se.getComponent(E,Kr);C!=null&&C.activeAndEnabled&&(y+=1,l?b+=C.width:b+=C.height)}let _=0;const S=this.spacing*(y-1);if(p||u){let R=0;l?R=n-=S:R=a-=S,y>0&&(_=R/y)}let M=0;M+=this.padding.left,M-=this.padding.right,v!==0&&(g=A-b,g*=v,g-=S*v,l?(g-=this.padding.right*v,g+=this.padding.left*(1-v),g<this.padding.left&&(g=this.padding.left)):(g-=this.padding.bottom*v,g+=this.padding.top*(1-v),g<this.padding.top&&(g=this.padding.top)));let I=1;for(let R=0;R<this.gameObject.children.length;R++){const E=this.gameObject.children[R],C=se.getComponent(E,Kr);if(C!=null&&C.activeAndEnabled){(t=C.pivot)==null||t.set(.5,.5),C.anchorMin.set(0,1),C.anchorMax.set(0,1);const z=r*.5+M*.5;C.anchoredPosition.x!==z&&(C.anchoredPosition.x=z);const q=o*-.5;C.anchoredPosition.y!==q&&(C.anchoredPosition.y=q),f&&d&&C.sizeDelta[c]!==m&&(C.sizeDelta[c]=m),p&&u&&C.sizeDelta[s]!==_&&(C.sizeDelta[s]=_);const Q=l?C.width:C.height,G=Q*.5;if(g+=G,p){const F=_*I-_*.5;F>g&&(g=F-_*.5+Q+this.padding.left,g-=G)}let $=g;s==="y"&&($=-$),C.anchoredPosition[s]!==$&&(C.anchoredPosition[s]=$),g+=G,g+=this.spacing,I+=1}}}}_s([x()],eh.prototype,"childControlHeight",2),_s([x()],eh.prototype,"childControlWidth",2),_s([x()],eh.prototype,"childForceExpandHeight",2),_s([x()],eh.prototype,"childForceExpandWidth",2),_s([x()],eh.prototype,"childScaleHeight",2),_s([x()],eh.prototype,"childScaleWidth",2);class HM extends eh{get primaryAxis(){return"y"}}class VM extends eh{get primaryAxis(){return"x"}}class WM extends jn{onCalculateLayout(){}}var Iie=Object.defineProperty,Rie=Object.getOwnPropertyDescriptor,Pa=(i,e,t,s)=>{for(var r=s>1?void 0:s?Rie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Iie(e,t,r),r},s3=(i=>(i[i.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",i[i.ScreenSpaceCamera=1]="ScreenSpaceCamera",i[i.WorldSpace=2]="WorldSpace",i[i.Undefined=-1]="Undefined",i))(s3||{});const XM=le("debuguilayout"),r3=class extends fg{constructor(){super(...arguments),h(this,"_renderOnTop"),h(this,"_depthWrite",!1),h(this,"_doubleSided",!0),h(this,"_castShadows",!1),h(this,"_receiveShadows",!1),h(this,"_renderMode",-1),h(this,"_rootCanvas"),h(this,"_scaleFactor",1),h(this,"worldCamera"),h(this,"planeDistance",-1),h(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),h(this,"previousParent",null),h(this,"_lastMatrixWorld",null),h(this,"_rectTransforms",[]),h(this,"_layoutGroups",new Map),h(this,"onBeforeRenderRoutine",()=>{var i,e,t,s;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(e=this.shadowComponent)==null||e.updateWorldMatrix(!0,!0),Un.ensureUpdateMeshUI(yM,this.context);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),Un.ensureUpdateMeshUI(yM,this.context))}),h(this,"onAfterRenderRoutine",()=>{var i,e;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const r=this.context.mainCamera;r?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const t=this.context.renderer.autoClear,s=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),Un.ensureUpdateMeshUI(yM,this.context),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=t,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(e=this._lastMatrixWorld)==null||e.copy(this.gameObject.matrixWorld)}}),h(this,"_updateRenderSettingsRoutine"),h(this,"_activeRenderMode",-1),h(this,"_lastWidth",-1),h(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(i){i!==this._renderOnTop&&(this._renderOnTop=i,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(i){this._depthWrite!==i&&(this._depthWrite=i,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(i){this._doubleSided!==i&&(this._doubleSided=i,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(i){this._castShadows!==i&&(this._castShadows=i,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(i){this._receiveShadows!==i&&(this._receiveShadows=i,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(i){this._renderMode!==i&&(this._renderMode=i,this.onRenderSettingsChanged())}set rootCanvas(i){this._rootCanvas instanceof r3||(this._rootCanvas=i)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(i){this._scaleFactor=i}awake(){var i;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,XM&&console.log("Canvas.Awake()",((i=this.previousParent)==null?void 0:i.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new Be,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const i=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);i!==-1&&this.context.pre_render_callbacks.splice(i,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(i){this._rectTransforms.push(i)}unregisterTransform(i){const e=this._rectTransforms.indexOf(i);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(i){const e=i.gameObject;this._layoutGroups.set(e,i)}unregisterLayoutGroup(i){const e=i.gameObject;this._layoutGroups.delete(e)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new Be);const i=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);XM&&i&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const e=!1;for(const t of this._rectTransforms){i&&t.markDirty();let s=this._layoutGroups.get(t.gameObject);t.isDirty&&!s&&(s=t.gameObject.getComponentInParent(jn)),(t.isDirty||s!=null&&s.isDirty)&&(XM&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),s?.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),dn.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Nb(this.shadowComponent,this);for(const i of se.getComponentsInChildren(this.gameObject,ia))Nb(i.shadowComponent,this)}}onUpdateRenderMode(i=!1){if(!i&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let e=this.context.mainCameraComponent,t=10;switch(e&&e.nearClipPlane>0&&e.farClipPlane>0&&(t=tt.lerp(e.nearClipPlane,e.farClipPlane,.15)),this._renderMode===1&&(this.worldCamera&&(e=this.worldCamera),this.planeDistance>0&&(t=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!e)return;const s=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-s,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(Kr);let n=!1;r.sizeDelta.x!==this.context.domWidth&&(n=!0),r.sizeDelta.y!==this.context.domHeight&&(n=!0);const o=e.fieldOfView*Math.PI/180,a=2*Math.tan(o/2)*Math.abs(s);this.gameObject.scale.x=a/this.context.domHeight,this.gameObject.scale.y=a/this.context.domHeight,this.gameObject.scale.z=.01,n&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let nr=r3;Pa([x()],nr.prototype,"renderOnTop",1),Pa([x()],nr.prototype,"depthWrite",1),Pa([x()],nr.prototype,"doubleSided",1),Pa([x()],nr.prototype,"castShadows",1),Pa([x()],nr.prototype,"receiveShadows",1),Pa([x()],nr.prototype,"renderMode",1),Pa([x(nr)],nr.prototype,"rootCanvas",1),Pa([x()],nr.prototype,"scaleFactor",1),Pa([x(Ri)],nr.prototype,"worldCamera",2),Pa([x()],nr.prototype,"planeDistance",2);var Pie=Object.defineProperty,Bie=Object.getOwnPropertyDescriptor,qM=(i,e,t,s)=>{for(var r=s>1?void 0:s?Bie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Pie(e,t,r),r};class th extends Ie{constructor(){super(...arguments),h(this,"_alpha",1),h(this,"interactable",!0),h(this,"blocksRaycasts",!0),h(this,"_isDirty",!1),h(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(e){e!==this._alpha&&(this._alpha=e,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),dn.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const e of se.getComponentsInChildren(this.gameObject,ia,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}qM([x()],th.prototype,"alpha",1),qM([x()],th.prototype,"interactable",2),qM([x()],th.prototype,"blocksRaycasts",2);var kie=Object.defineProperty,Die=Object.getOwnPropertyDescriptor,Pi=(i,e,t,s)=>{for(var r=s>1?void 0:s?Die(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&kie(e,t,r),r};class wu extends Ie{constructor(){super(...arguments),h(this,"object"),h(this,"target"),h(this,"duration",1),h(this,"relativeMotion",!1),h(this,"coroutine",null),h(this,"targetPos",new w),h(this,"targetRot",new Ee),h(this,"targetScale",new w)}*moveToTarget(){if(!this.target||!this.object)return;const e=At(this.object).clone(),t=At(this.target).clone(),s=Bs(this.object).clone(),r=Bs(this.target).clone(),n=js(this.object).clone(),o=js(this.target).clone(),a=e.distanceTo(t),l=s.angleTo(r),c=n.distanceTo(o);if(a<.01&&l<.01&&c<.01){ns(this.object,t),ln(this.object,r),g1(this.object,o),this.coroutine=null;return}let u=0,d=0;for(;u<1;)u+=this.context.time.deltaTime/this.duration,u>1&&(u=1),d=u<.5?4*u*u*u:1-Math.pow(-2*u+2,3)/2,this.targetPos.lerpVectors(e,t,d),this.targetRot.slerpQuaternions(s,r,d),this.targetScale.lerpVectors(n,o,d),ns(this.object,this.targetPos),ln(this.object,this.targetRot),g1(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),t=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),n=this.target.quaternion.clone(),o=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(n),this.targetScale.copy(this.object.scale).multiply(o);let a=0,l=0;for(;a<1;)a+=this.context.time.deltaTime/this.duration,a>1&&(a=1),l=a<.5?4*a*a*a:1-Math.pow(-2*a+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,l),this.object.quaternion.slerpQuaternions(t,this.targetRot,l),this.object.scale.lerpVectors(s,this.targetScale,l),yield;this.coroutine=null}onPointerClick(){this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const s=new Xr("Move to "+((t=this.target)==null?void 0:t.name),pn.tapTrigger(this.gameObject),ui.transformAction(this.object,this.target,this.duration,this.relativeMotion?gE.Relative:gE.Absolute));e.addBehavior(s)}}}Pi([x(Re)],wu.prototype,"object",2),Pi([x(Re)],wu.prototype,"target",2),Pi([x()],wu.prototype,"duration",2),Pi([x()],wu.prototype,"relativeMotion",2);var $b;const Xl=($b=class extends Ie{constructor(){super(...arguments),h(this,"materialToSwitch"),h(this,"variantMaterial"),h(this,"fadeDuration",0),h(this,"_objectsWithThisMaterial",[]),h(this,"selfModel"),h(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const i=se.findObjectsOfType(Di);for(const e of i)for(let t=0;t<e.sharedMaterials.length;t++){const s=e.sharedMaterials[t];if(s===this.materialToSwitch){if(e.gameObject instanceof ye)this._objectsWithThisMaterial.push(e.gameObject);else if(e.gameObject instanceof Tn)for(const r of e.gameObject.children)r instanceof ye&&r.material===s&&this._objectsWithThisMaterial.push(r);break}}}}onPointerClick(){if(this.variantMaterial)for(let i=0;i<this._objectsWithThisMaterial.length;i++){const e=this._objectsWithThisMaterial[i];e.material=this.variantMaterial}}async beforeCreateDocument(i,e){this.targetModels=[],Xl._materialTriggersPerId={},Xl.variantSwitchIndex=0,this.materialToSwitch&&await jo.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await jo.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(i,e,t){this._objectsWithThisMaterial.find(s=>s.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(Xl._materialTriggersPerId[this.materialToSwitch.uuid]||(Xl._materialTriggersPerId[this.materialToSwitch.uuid]=[]),Xl._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(i,e){if(!this.materialToSwitch)return;const t=Xl._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const s={};for(const n of t){const o=n.createVariants();o&&o.length>0&&(s[n.selfModel.uuid]=o)}const r=[];for(const n of t){for(const o in s)o!==n.selfModel.uuid&&r.push(s[o]);n.createAndAttachBehaviors(i,s[n.selfModel.uuid],r)}}delete Xl._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(i,e,t){const s=[],r=[],n=Math.max(0,this.fadeDuration);for(const o of this.targetModels){const a=ui.fadeAction(o,n,!1);r.push(a)}for(const o of t)r.push(ui.fadeAction(o,n,!1));for(const o of e)s.push(ui.fadeAction(o,n,!1)),r.push(ui.fadeAction(o,n,!0));i.addBehavior(new Xr("Select "+this.selfModel.name,pn.tapTrigger(this.selfModel),ui.parallel(...r))),i.addBehavior(new Xr("Start hidden "+this.selfModel.name,pn.sceneStartTrigger(),ui.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const i=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name+"_"+Xl.variantSwitchIndex++,t.name=t.name.replace(/\s/g,"_"),t.material=this.variantMaterial,t.geometry=e.geometry,t.matrix=e.matrix,(!e.parent||!e.parent.isEmpty())&&ao.createEmptyParent(e),e.parent&&e.parent.add(t),i.push(t)}return i}},h($b,"_materialTriggersPerId",{}),h($b,"variantSwitchIndex",0),$b);let Up=Xl;Pi([x(kt)],Up.prototype,"materialToSwitch",2),Pi([x(kt)],Up.prototype,"variantMaterial",2),Pi([x()],Up.prototype,"fadeDuration",2);class Fp extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"toggleOnClick",!1),h(this,"targetState",!0),h(this,"hideSelf",!0),h(this,"selfModel"),h(this,"otherModel"),h(this,"toggleModel"),h(this,"stateBeforeCreatingDocument",!1)}onPointerClick(){!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(e,t,s){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(e,t){if(this.target){if(this.otherModel=t.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let s=this.hideSelf;this.targetState,this.toggleOnClick&&(s=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&TU.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const r=[];if(s&&r.push(ui.fadeAction(this.selfModel,0,!1)),this.toggleModel&&r.push(ui.fadeAction(this.toggleModel,0,!0)),r.push(ui.fadeAction(this.otherModel,0,this.targetState)),e.addBehavior(new Xr("Toggle_"+this.selfModel.name+"_hideSelf",pn.tapTrigger(this.selfModel),ui.sequence(...r))),this.toggleOnClick&&this.toggleModel){const n=[];n.push(ui.fadeAction(this.toggleModel,0,!1)),n.push(ui.fadeAction(this.selfModel,0,!0)),n.push(ui.fadeAction(this.otherModel,0,!this.targetState)),e.addBehavior(new Xr("Toggle_"+this.selfModel.name+"_toggleSelf",pn.tapTrigger(this.toggleModel),ui.sequence(...n))),e.addBehavior(new Xr("HideOnStart_"+this.gameObject.name,pn.sceneStartTrigger(),ui.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}Pi([x(Re)],Fp.prototype,"target",2),Pi([x()],Fp.prototype,"targetState",2),Pi([x()],Fp.prototype,"hideSelf",2);class YM extends Ie{start(){this.gameObject.visible=!1}createBehaviours(e,t,s){t.uuid===this.gameObject.uuid&&e.addBehavior(new Xr("HideOnStart_"+this.gameObject.name,pn.sceneStartTrigger(),ui.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class Np extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"duration",.5),h(this,"motionType",mE.bounce)}beforeCreateDocument(){}createBehaviours(e,t,s){if(this.target&&t.uuid===this.gameObject.uuid){const r=new Xr("emphasize "+this.name,pn.tapTrigger(this.gameObject),ui.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(r)}}afterCreateDocument(e,t){}}Pi([x()],Np.prototype,"target",2),Pi([x()],Np.prototype,"duration",2),Pi([x()],Np.prototype,"motionType",2);class zp extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"clip",""),h(this,"toggleOnClick",!1)}onPointerClick(){if(!(!this.target&&!this.clip)){if(!this.target){const e=this.gameObject.addNewComponent(As);e&&(e.spatialBlend=1,e.volume=1,e.loop=!1,this.target=e)}this.target&&(this.target.isPlaying&&this.toggleOnClick?this.target.stop():(!this.toggleOnClick&&this.target.isPlaying&&this.target.stop(),this.clip?this.target.play(this.clip):this.target.play()))}}createBehaviours(e,t,s){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r)return;const n=this.target?this.target.gameObject:this.gameObject,o=r.split("/").pop(),a=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?AE.NonSpatial:AE.Spatial,c=new Xr("playAudio "+this.name,pn.tapTrigger(this.gameObject),ui.playAudioAction(n,"audio/"+o,jU.Play,a,l));e.addBehavior(c)}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const s=this.clip?this.clip:this.target?this.target.clip:void 0;if(!s)return;const r=s.split("/").pop(),n=await(await(await fetch(this.clip)).blob()).arrayBuffer(),o=new Uint8Array(n);t.files["audio/"+r]=o}}Pi([x(As)],zp.prototype,"target",2),Pi([x(URL)],zp.prototype,"clip",2),Pi([x()],zp.prototype,"toggleOnClick",2);var KM;const jp=(KM=class extends Ie{constructor(){super(...arguments),h(this,"target"),h(this,"animator"),h(this,"stateName"),h(this,"stateNameAfterPlaying"),h(this,"loopAfterPlaying",!1),h(this,"selfModel"),h(this,"stateAnimationModel"),h(this,"stateAnimation"),h(this,"stateAfterPlayingAnimationModel"),h(this,"stateAfterPlayingAnimation")}onPointerClick(){var i;this.target&&this.stateName&&((i=this.animator)==null||i.play(this.stateName,0,0,.1))}createBehaviours(i,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}onAfterHierarchy(){jp.animationActions=[]}afterCreateDocument(i,e){!this.stateAnimation||!this.stateAnimationModel||e.document.traverse(t=>{var s,r;if(t.uuid===((s=this.target)==null?void 0:s.uuid)&&this.stateAnimation){const n=[];let o=jp.animationActions.find(l=>l.affectedObjects==t&&l.start==this.stateAnimation.start&&l.duration==this.stateAnimation.duration);if(o||(o=ui.startAnimationAction(t,this.stateAnimation.start,this.stateAnimation.duration),jp.animationActions.push(o)),n.push(o),this.stateAfterPlayingAnimation&&this.stateAfterPlayingAnimationModel){let l=jp.animationActions.find(u=>u.affectedObjects==t&&u.start==this.stateAfterPlayingAnimation.start&&u.duration==this.stateAfterPlayingAnimation.duration);l||(l=ui.startAnimationAction(t,this.stateAfterPlayingAnimation.start,this.stateAfterPlayingAnimation.duration),jp.animationActions.push(l));const c=ui.sequence(l);this.loopAfterPlaying&&c.makeLooping(),n.push(c)}const a=new Xr("tap "+this.name+" for "+this.stateName+" on "+((r=this.target)==null?void 0:r.name),pn.tapTrigger(this.selfModel),ui.sequence(...n));i.addBehavior(a)}})}createAnimation(i,e,t){var s,r,n,o,a;if(this.target&&this.animator){const l=(r=(s=this.animator)==null?void 0:s.runtimeAnimatorController)==null?void 0:r.findState(this.stateName);if(!((n=l?.motion)!=null&&n.clip)){gi()&&console.warn("No clip found for state "+this.stateName);return}this.stateAnimationModel=e,this.stateAnimation=i.registerAnimation(this.target,l?.motion.clip);const c=(a=(o=this.animator)==null?void 0:o.runtimeAnimatorController)==null?void 0:a.findState(this.stateNameAfterPlaying);this.stateAfterPlayingAnimationModel=e,this.stateAfterPlayingAnimation=i.registerAnimation(this.target,c?.motion.clip)}}},h(KM,"animationActions",[]),KM);let ih=jp;Pi([x(Re)],ih.prototype,"target",2),Pi([x(Cr)],ih.prototype,"animator",2),Pi([x()],ih.prototype,"stateName",2),Pi([x()],ih.prototype,"stateNameAfterPlaying",2),Pi([x()],ih.prototype,"loopAfterPlaying",2);class Qp extends Ie{constructor(){super(...arguments),h(this,"target")}getType(){}getDuration(){}}Pi([x(Re)],Qp.prototype,"target",2);class Ng extends Ie{constructor(){super(...arguments),h(this,"target")}}Pi([x(Qp)],Ng.prototype,"target",2);class zg extends Qp{constructor(){super(...arguments),h(this,"type",1),h(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}Pi([x()],zg.prototype,"type",2),Pi([x()],zg.prototype,"duration",2);class JM extends Ng{}var Oie=Object.defineProperty,Lie=Object.getOwnPropertyDescriptor,ql=(i,e,t,s)=>{for(var r=s>1?void 0:s?Lie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Oie(e,t,r),r};class Su extends Ie{constructor(){super(...arguments),h(this,"center",new w(0,0,0)),h(this,"radius",.5),h(this,"height",2),h(this,"_rigidbody",null),h(this,"_activeGroundCollisions")}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Vi),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Vi)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let t=this.gameObject.getComponent(Zc);t||(t=this.gameObject.addNewComponent(Zc)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height,this.gameObject.rotation.x=0,this.gameObject.rotation.z=0,e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){for(const t of e.contacts)if(t.normal.y>.1){this._activeGroundCollisions.add(e);break}}onCollisionExit(e){this._activeGroundCollisions.delete(e)}get isGrounded(){return this._activeGroundCollisions.size>0}}ql([x(w)],Su.prototype,"center",2),ql([x()],Su.prototype,"radius",2),ql([x()],Su.prototype,"height",2);class Yl extends Ie{constructor(){super(...arguments),h(this,"controller"),h(this,"movementSpeed",2),h(this,"rotationSpeed",2),h(this,"jumpForce",1),h(this,"doubleJumpForce",2),h(this,"animator"),h(this,"lookForward",!0),h(this,"lookInput",new ee(0,0)),h(this,"moveInput",new ee(0,0)),h(this,"jumpInput",!1),h(this,"_currentSpeed",new w(0,0,0)),h(this,"_currentAngularSpeed",new w(0,0,0)),h(this,"_temp",new w(0,0,0)),h(this,"_jumpCount",0),h(this,"_currentRotation"),h(this,"_raycastOptions",new ko)}awake(){this._currentRotation=new Ee}update(){const e=this.context.input;e.isKeyPressed("KeyW")?this.moveInput.y+=1:e.isKeyPressed("KeyS")&&(this.moveInput.y-=1),e.isKeyPressed("KeyD")?this.lookInput.x+=1:e.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=e.isKeyDown("Space"))}move(e){this.moveInput.add(e)}look(e){this.lookInput.add(e)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(e,t,s){var r,n,o,a,l,c,u,d,p,f,m;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((n=this.animator)==null||n.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(o=this.animator)==null||o.setBool("running",e.length()>.01),(l=this.animator)==null||l.setBool("jumping",((a=this.controller)==null?void 0:a.isGrounded)===!0&&s),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=tt.toRadians(-t.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const A=this.context.mainCameraComponent.forward;A.y=0,A.normalize(),this._currentRotation.setFromUnitVectors(new w(0,0,1),A),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&s&&this.jumpForce>0){let A=(c=this.controller)==null?void 0:c.isGrounded;if(this.doubleJumpForce>0&&!((u=this.controller)!=null&&u.isGrounded)&&this._jumpCount===1&&(A=!0,(d=this.animator)==null||d.setBool("doubleJump",!0)),A){this._jumpCount+=1;const v=this.controller.rigidbody,g=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;v.applyImpulse(new w(0,1,0).multiplyScalar(g))}}if(this.controller){const A=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(A<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new ha),this._raycastOptions.ray.origin.copy(At(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const v=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const g=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(v),(g.length&&g[0].distance>2||A<-10)&&((f=this.animator)==null||f.setBool("falling",!0))}else(m=this.animator)==null||m.setBool("falling",!1)}}}ql([x(Su)],Yl.prototype,"controller",2),ql([x()],Yl.prototype,"movementSpeed",2),ql([x()],Yl.prototype,"rotationSpeed",2),ql([x()],Yl.prototype,"jumpForce",2),ql([x()],Yl.prototype,"doubleJumpForce",2),ql([x(Cr)],Yl.prototype,"animator",2);var Uie=Object.defineProperty,Fie=Object.getOwnPropertyDescriptor,Nie=(i,e,t,s)=>{for(var r=s>1?void 0:s?Fie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Uie(e,t,r),r};class jg extends Tr{constructor(){super(...arguments),h(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new DO;return e.offset=new ee(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=t=>t*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}}Nie([x(Tt)],jg.prototype,"intensity",2),mo("ChromaticAberration",jg);var zie=Object.defineProperty,jie=Object.getOwnPropertyDescriptor,e_=(i,e,t,s)=>{for(var r=s>1?void 0:s?jie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&zie(e,t,r),r};class sh extends Tr{constructor(){super(...arguments),h(this,"postExposure"),h(this,"contrast"),h(this,"hueShift"),h(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=e=>(e=Math.pow(2,e),e),this.postExposure.defaultValue=0,this.contrast.valueProcessor=e=>{let t=1;return e>0?t=200:e<0&&(t=100),e/t},this.contrast.defaultValue=0,this.hueShift.valueProcessor=e=>Math.PI*e/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=e=>e<0?e/100:e/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===Dr&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=Cf);const e=new kO;this.postExposure.onValueChanged=s=>{this.context.renderer.toneMapping===Dr&&(this.context.renderer.toneMapping=Cf),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=s)},this.contrast.onValueChanged=s=>{e.contrast=s};const t=new LO;return this.hueShift.onValueChanged=s=>t.hue=s,this.saturation.onValueChanged=s=>t.saturation=s,[t,e]}}e_([x(Tt)],sh.prototype,"postExposure",2),e_([x(Tt)],sh.prototype,"contrast",2),e_([x(Tt)],sh.prototype,"hueShift",2),e_([x(Tt)],sh.prototype,"saturation",2),mo("ColorAdjustments",sh);const Qie=(Math.sqrt(5)-1)/4,or=(5-Math.sqrt(5))/20,t_=i=>Math.floor(i)|0,i_=new Float64Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);function Gie(i=Math.random){const e=Hie(i),t=new Float64Array(e).map(o=>i_[o%32*4]),s=new Float64Array(e).map(o=>i_[o%32*4+1]),r=new Float64Array(e).map(o=>i_[o%32*4+2]),n=new Float64Array(e).map(o=>i_[o%32*4+3]);return function(o,a,l,c){let u,d,p,f,m;const A=(o+a+l+c)*Qie,v=t_(o+A),g=t_(a+A),b=t_(l+A),y=t_(c+A),_=(v+g+b+y)*or,S=v-_,M=g-_,I=b-_,R=y-_,E=o-S,C=a-M,z=l-I,q=c-R;let Q=0,G=0,$=0,F=0;E>C?Q++:G++,E>z?Q++:$++,E>q?Q++:F++,C>z?G++:$++,C>q?G++:F++,z>q?$++:F++;const L=Q>=3?1:0,N=G>=3?1:0,re=$>=3?1:0,Z=F>=3?1:0,X=Q>=2?1:0,ne=G>=2?1:0,fe=$>=2?1:0,be=F>=2?1:0,Pe=Q>=1?1:0,Fe=G>=1?1:0,We=$>=1?1:0,Je=F>=1?1:0,qe=E-L+or,wt=C-N+or,pe=z-re+or,W=q-Z+or,Ue=E-X+2*or,xe=C-ne+2*or,ve=z-fe+2*or,je=q-be+2*or,ge=E-Pe+3*or,Ke=C-Fe+3*or,nt=z-We+3*or,dt=q-Je+3*or,Xt=E-1+4*or,ii=C-1+4*or,U=z-1+4*or,D=q-1+4*or,ue=v&255,De=g&255,Oe=b&255,H=y&255;let Ae=.6-E*E-C*C-z*z-q*q;if(Ae<0)u=0;else{const we=ue+e[De+e[Oe+e[H]]];Ae*=Ae,u=Ae*Ae*(t[we]*E+s[we]*C+r[we]*z+n[we]*q)}let Me=.6-qe*qe-wt*wt-pe*pe-W*W;if(Me<0)d=0;else{const we=ue+L+e[De+N+e[Oe+re+e[H+Z]]];Me*=Me,d=Me*Me*(t[we]*qe+s[we]*wt+r[we]*pe+n[we]*W)}let de=.6-Ue*Ue-xe*xe-ve*ve-je*je;if(de<0)p=0;else{const we=ue+X+e[De+ne+e[Oe+fe+e[H+be]]];de*=de,p=de*de*(t[we]*Ue+s[we]*xe+r[we]*ve+n[we]*je)}let Xe=.6-ge*ge-Ke*Ke-nt*nt-dt*dt;if(Xe<0)f=0;else{const we=ue+Pe+e[De+Fe+e[Oe+We+e[H+Je]]];Xe*=Xe,f=Xe*Xe*(t[we]*ge+s[we]*Ke+r[we]*nt+n[we]*dt)}let Ye=.6-Xt*Xt-ii*ii-U*U-D*D;if(Ye<0)m=0;else{const we=ue+1+e[De+1+e[Oe+1+e[H+1]]];Ye*=Ye,m=Ye*Ye*(t[we]*Xt+s[we]*ii+r[we]*U+n[we]*D)}return 27*(u+d+p+f+m)}}function Hie(i){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const s=t+~~(i()*(256-t)),r=e[t];e[t]=e[s],e[s]=r}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var Vie=Object.defineProperty,Wie=Object.getOwnPropertyDescriptor,ie=(i,e,t,s)=>{for(var r=s>1?void 0:s?Wie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Vie(e,t,r),r};const s_=le("debugparticles");var Ba=(i=>(i[i.Billboard=0]="Billboard",i[i.Stretch=1]="Stretch",i[i.HorizontalBillboard=2]="HorizontalBillboard",i[i.VerticalBillboard=3]="VerticalBillboard",i[i.Mesh=4]="Mesh",i))(Ba||{});let rh=class{constructor(){h(this,"alphaKeys"),h(this,"colorKeys")}get duration(){return 1}evaluate(i,e){let t,s=0,r=null,n=0;for(let o=0;o<this.alphaKeys.length;o++){const a=this.alphaKeys[o];(a.time<i||!t)&&(t=a,s=o)}for(let o=0;o<this.colorKeys.length;o++){const a=this.colorKeys[o];(a.time<i||!r)&&(r=a,n=o)}if(r)if(n+1<this.colorKeys.length){const o=this.colorKeys[n+1],a=tt.remap(i,r.time,o.time,0,1);e.r=tt.lerp(r.color.r,o.color.r,a),e.g=tt.lerp(r.color.g,o.color.g,a),e.b=tt.lerp(r.color.b,o.color.b,a)}else e.r=r.color.r,e.g=r.color.g,e.b=r.color.b;if(t)if(s+1<this.alphaKeys.length){const o=this.alphaKeys[s+1],a=tt.remap(i,t.time,o.time,0,1);e.alpha=tt.lerp(t.alpha,o.alpha,a)}else e.alpha=t.alpha;return e}};ie([x()],rh.prototype,"alphaKeys",2),ie([x()],rh.prototype,"colorKeys",2);var Qg=(i=>(i[i.Local=0]="Local",i[i.World=1]="World",i[i.Custom=2]="Custom",i))(Qg||{}),n3=(i=>(i[i.Sphere=0]="Sphere",i[i.SphereShell=1]="SphereShell",i[i.Hemisphere=2]="Hemisphere",i[i.HemisphereShell=3]="HemisphereShell",i[i.Cone=4]="Cone",i[i.Box=5]="Box",i[i.Mesh=6]="Mesh",i[i.ConeShell=7]="ConeShell",i[i.ConeVolume=8]="ConeVolume",i[i.ConeVolumeShell=9]="ConeVolumeShell",i[i.Circle=10]="Circle",i[i.CircleEdge=11]="CircleEdge",i[i.SingleSidedEdge=12]="SingleSidedEdge",i[i.MeshRenderer=13]="MeshRenderer",i[i.SkinnedMeshRenderer=14]="SkinnedMeshRenderer",i[i.BoxShell=15]="BoxShell",i[i.BoxEdge=16]="BoxEdge",i[i.Donut=17]="Donut",i[i.Rectangle=18]="Rectangle",i[i.Sprite=19]="Sprite",i[i.SpriteRenderer=20]="SpriteRenderer",i))(n3||{});class ct{constructor(){h(this,"mode"),h(this,"constant"),h(this,"constantMin"),h(this,"constantMax"),h(this,"curve"),h(this,"curveMin"),h(this,"curveMax"),h(this,"curveMultiplier")}evaluate(e,t){const s=t===void 0?Math.random():t;switch(this.mode){case 0:return this.constant;case 1:return e=tt.clamp01(e),this.curve.evaluate(e)*this.curveMultiplier;case 2:const r=e*this.curveMin.duration,n=e*this.curveMax.duration;return tt.lerp(this.curveMin.evaluate(r),this.curveMax.evaluate(n),s%1)*this.curveMultiplier;case 3:return tt.lerp(this.constantMin,this.constantMax,s%1);default:this.curveMax.evaluate(e)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(e){if(!e)return 0;let t=Number.MIN_VALUE;for(let s=0;s<e.keys.length;s++){const r=e.keys[s];r.value>t&&(t=r.value)}return t}}ie([x()],ct.prototype,"mode",2),ie([x()],ct.prototype,"constant",2),ie([x()],ct.prototype,"constantMin",2),ie([x()],ct.prototype,"constantMax",2),ie([x(du)],ct.prototype,"curve",2),ie([x(du)],ct.prototype,"curveMin",2),ie([x(du)],ct.prototype,"curveMax",2),ie([x()],ct.prototype,"curveMultiplier",2);var r_;const Ko=(r_=class{constructor(){h(this,"mode"),h(this,"color"),h(this,"colorMin"),h(this,"colorMax"),h(this,"gradient"),h(this,"gradientMin"),h(this,"gradientMax")}evaluate(i,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(i,Ko._temp),Ko._temp;case 2:return Ko._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(i,Ko._temp),this.gradientMax.evaluate(i,Ko._temp2),Ko._temp.lerp(Ko._temp2,t)}return Ko._temp.set(16711935),Ko._temp.alpha=1,Ko._temp}},h(r_,"_temp",new Ai(0,0,0,1)),h(r_,"_temp2",new Ai(0,0,0,1)),r_);let vn=Ko;ie([x(Ai)],vn.prototype,"color",2),ie([x(Ai)],vn.prototype,"colorMin",2),ie([x(Ai)],vn.prototype,"colorMax",2),ie([x(rh)],vn.prototype,"gradient",2),ie([x(rh)],vn.prototype,"gradientMin",2),ie([x(rh)],vn.prototype,"gradientMax",2);var ZM=(i=>(i[i.Hierarchy=0]="Hierarchy",i[i.Local=1]="Local",i[i.Shape=2]="Shape",i))(ZM||{});class ar{constructor(){h(this,"cullingMode"),h(this,"duration"),h(this,"emitterVelocityMode"),h(this,"flipRotation"),h(this,"gravityModifier"),h(this,"gravityModifierMultiplier"),h(this,"loop"),h(this,"maxParticles"),h(this,"playOnAwake"),h(this,"prewarm"),h(this,"ringBufferLoopRange"),h(this,"ringBufferMode"),h(this,"scalingMode"),h(this,"simulationSpace"),h(this,"simulationSpeed"),h(this,"startColor"),h(this,"startDelay"),h(this,"startDelayMultiplier"),h(this,"startLifetime"),h(this,"startLifetimeMultiplier"),h(this,"startRotation"),h(this,"startRotationMultiplier"),h(this,"startRotation3D"),h(this,"startRotationX"),h(this,"startRotationXMultiplier"),h(this,"startRotationY"),h(this,"startRotationYMultiplier"),h(this,"startRotationZ"),h(this,"startRotationZMultiplier"),h(this,"startSize"),h(this,"startSize3D"),h(this,"startSizeMultiplier"),h(this,"startSizeX"),h(this,"startSizeXMultiplier"),h(this,"startSizeY"),h(this,"startSizeYMultiplier"),h(this,"startSizeZ"),h(this,"startSizeZMultiplier"),h(this,"startSpeed"),h(this,"startSpeedMultiplier"),h(this,"stopAction"),h(this,"useUnscaledTime")}}ie([x(ct)],ar.prototype,"gravityModifier",2),ie([x(vn)],ar.prototype,"startColor",2),ie([x(ct)],ar.prototype,"startDelay",2),ie([x(ct)],ar.prototype,"startLifetime",2),ie([x(ct)],ar.prototype,"startRotation",2),ie([x(ct)],ar.prototype,"startRotationX",2),ie([x(ct)],ar.prototype,"startRotationY",2),ie([x(ct)],ar.prototype,"startRotationZ",2),ie([x(ct)],ar.prototype,"startSize",2),ie([x(ct)],ar.prototype,"startSizeX",2),ie([x(ct)],ar.prototype,"startSizeY",2),ie([x(ct)],ar.prototype,"startSizeZ",2),ie([x(ct)],ar.prototype,"startSpeed",2);class Gg{constructor(){h(this,"cycleCount"),h(this,"maxCount"),h(this,"minCount"),h(this,"probability"),h(this,"repeatInterval"),h(this,"time"),h(this,"count"),h(this,"_performed",0)}reset(){this._performed=0}run(e){if(e<=this.time)return 0;let t=0;if(this.cycleCount===0||this._performed<this.cycleCount){const s=this.time+this.repeatInterval*this._performed;if(e>=s&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:t=this.count.constant;break;case 3:t=tt.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:t=this.count.curve.evaluate(Math.random());break;case 2:const r=Math.random();t=tt.lerp(this.count.curveMin.evaluate(r),this.count.curveMax.evaluate(r),Math.random());break}}return t}}class ka{constructor(){h(this,"enabled"),h(this,"bursts"),h(this,"rateOverTime"),h(this,"rateOverTimeMultiplier"),h(this,"rateOverDistance"),h(this,"rateOverDistanceMultiplier"),h(this,"system")}get burstCount(){var e;return((e=this.bursts)==null?void 0:e.length)??0}reset(){var e;(e=this.bursts)==null||e.forEach(t=>t.reset())}getBurst(){let e=0;if(this.burstCount>0)for(let t=0;t<this.burstCount;t++){const s=this.bursts[t];this.system.main.loop&&s.time>=this.system.time&&s.reset(),e+=Math.round(s.run(this.system.time))}return e}}ie([x()],ka.prototype,"enabled",2),ie([x()],ka.prototype,"bursts",2),ie([x(ct)],ka.prototype,"rateOverTime",2),ie([x()],ka.prototype,"rateOverTimeMultiplier",2),ie([x(ct)],ka.prototype,"rateOverDistance",2),ie([x()],ka.prototype,"rateOverDistanceMultiplier",2);class Hg{constructor(){h(this,"enabled"),h(this,"color")}}ie([x(vn)],Hg.prototype,"color",2);class nh{constructor(){h(this,"enabled"),h(this,"separateAxes"),h(this,"size"),h(this,"sizeMultiplier"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier"),h(this,"_time",0),h(this,"_temp",new w)}evaluate(e,t,s){if(t||(t=this._temp),!this.enabled)return t.x=t.y=t.z=1,t;if(this.separateAxes)t.x=this.x.evaluate(e,s)*this.xMultiplier,t.y=this.y.evaluate(e,s)*this.yMultiplier,t.z=this.z.evaluate(e,s)*this.zMultiplier;else{const r=this.size.evaluate(e,s)*this.sizeMultiplier;t.x=r}return t}}ie([x(ct)],nh.prototype,"size",2),ie([x(ct)],nh.prototype,"x",2),ie([x(ct)],nh.prototype,"y",2),ie([x(ct)],nh.prototype,"z",2);var n_;const Vg=(n_=class{constructor(){h(this,"shapeType",5),h(this,"enabled",!0),h(this,"alignToDirection",!1),h(this,"angle",0),h(this,"arc",360),h(this,"arcSpread"),h(this,"arcSpeedMultiplier"),h(this,"arcMode"),h(this,"boxThickness"),h(this,"position"),h(this,"rotation"),h(this,"_rotation",new Es),h(this,"scale"),h(this,"radius"),h(this,"radiusThickness"),h(this,"sphericalDirectionAmount"),h(this,"randomDirectionAmount"),h(this,"randomPositionAmount"),h(this,"system"),h(this,"_space"),h(this,"_worldSpaceMatrix",new Be),h(this,"_worldSpaceMatrixInverse",new Be),h(this,"_vector",new w(0,0,0)),h(this,"_temp",new w(0,0,0)),h(this,"_dir",new w),h(this,"_loopTime",0),h(this,"_loopDirection",1),s_&&console.log(this)}get type(){return n3[this.shapeType]}initialize(i){this.getPosition(),i.position.copy(this._vector)}toJSON(){return this}clone(){return new Vg}update(i,e,t,s){this.system=i,this._space=t,t===1&&(this._worldSpaceMatrix.copy(s.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(i){const e=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return e&&(this._rotation.x=tt.toRadians(this.rotation.x),this._rotation.y=tt.toRadians(this.rotation.y),this._rotation.z=tt.toRadians(this.rotation.z),this._rotation.order="ZYX",i.applyEuler(this._rotation)),e}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const i=this._temp.copy(this.position),e=this._space===1;e&&i.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:s_&&Ml.DrawBox(this.position,this.scale,14540253,1),this._vector.x=Math.random()*this.scale.x-this.scale.x/2,this._vector.y=Math.random()*this.scale.y-this.scale.y/2,this._vector.z=Math.random()*this.scale.z-this.scale.z/2,this._vector.add(i);break;case 4:this.randomConePoint(this.position,this.angle,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),e&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),s_&&Ml.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(i){var e;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const t=i.x,s=i.y,r=i.z;this._dir.set(t,s,r),(e=this.system)!=null&&e.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),s_&&(Ml.DrawSphere(i,.01,8925952,.5,!0),Ml.DrawDirection(i,this._dir,8925952,.5,!0)),this._dir}randomizePosition(i,e){if(e<=0)return;const t=Vg._tempVec;t.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),t.x*=e*this.scale.x,t.y*=e*this.scale.y,t.z*=e*this.scale.z,i.add(t)}randomizeDirection(i,e){if(e===0)return;const t=Vg._randomQuat,s=Vg._tempVec;s.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(s,e*Math.random()*Math.PI),i.applyQuaternion(t)}spherizeDirection(i,e){if(e===0)return;const t=Math.random()*Math.PI*2,s=Math.acos(1-Math.random()*2),r=Math.sin(s)*Math.cos(t),n=Math.sin(s)*Math.sin(t),o=Math.cos(s),a=new w(r,n,o);i.lerp(a,e)}randomSpherePoint(i,e,t,s,r){const n=Math.random(),o=Math.random(),a=2*Math.PI*n*(s/360),l=Math.acos(2*o-1),c=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,u=i.x+this.scale.x*(-c*Math.sin(l)*Math.cos(a)),d=i.y+this.scale.y*(c*Math.sin(l)*Math.sin(a)),p=i.z+this.scale.z*(c*Math.cos(l));r.x=u,r.y=d,r.z=p}randomCirclePoint(i,e,t,s,r){const n=Math.random(),o=2*Math.PI*n*(s/360),a=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,l=i.x+this.scale.x*a*Math.cos(o),c=i.y+this.scale.y*a*Math.sin(o),u=i.z;r.x=l,r.y=c,r.z=u}randomConePoint(i,e,t,s,r,n,o){let a=0,l=0;switch(n){case 0:a=Math.random(),l=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:a=.5,l=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let c=2*Math.PI*a*(r/360);switch(n){case 2:case 1:c+=Math.PI+.5,c+=this._loopTime*Math.PI*2,c%=tt.toRadians(r);break}const u=Math.acos(2*l-1),d=tt.lerp(1,1-Math.pow(1-Math.random(),Math.PI),s)*t,p=i.x+-d*Math.sin(u)*Math.cos(c),f=i.y+d*Math.sin(u)*Math.sin(c),m=i.z;o.x=p*this.scale.x,o.y=f*this.scale.y,o.z=m*this.scale.z}},h(n_,"_randomQuat",new Ee),h(n_,"_tempVec",new w),n_);let cs=Vg;ie([x()],cs.prototype,"shapeType",2),ie([x()],cs.prototype,"enabled",2),ie([x()],cs.prototype,"alignToDirection",2),ie([x()],cs.prototype,"angle",2),ie([x()],cs.prototype,"arc",2),ie([x()],cs.prototype,"arcSpread",2),ie([x()],cs.prototype,"arcSpeedMultiplier",2),ie([x()],cs.prototype,"arcMode",2),ie([x(w)],cs.prototype,"boxThickness",2),ie([x(w)],cs.prototype,"position",2),ie([x(w)],cs.prototype,"rotation",2),ie([x(w)],cs.prototype,"scale",2),ie([x()],cs.prototype,"radius",2),ie([x()],cs.prototype,"radiusThickness",2),ie([x()],cs.prototype,"sphericalDirectionAmount",2),ie([x()],cs.prototype,"randomDirectionAmount",2),ie([x()],cs.prototype,"randomPositionAmount",2);class mi{constructor(){h(this,"damping"),h(this,"enabled"),h(this,"frequency"),h(this,"octaveCount"),h(this,"octaveMultiplier"),h(this,"octaveScale"),h(this,"positionAmount"),h(this,"quality"),h(this,"remap"),h(this,"remapEnabled"),h(this,"remapMultiplier"),h(this,"remapX"),h(this,"remapXMultiplier"),h(this,"remapY"),h(this,"remapYMultiplier"),h(this,"remapZ"),h(this,"remapZMultiplier"),h(this,"scrollSpeedMultiplier"),h(this,"separateAxes"),h(this,"strengthMultiplier"),h(this,"strengthX"),h(this,"strengthXMultiplier"),h(this,"strengthY"),h(this,"strengthYMultiplier"),h(this,"strengthZ"),h(this,"strengthZMultiplier"),h(this,"_noise"),h(this,"_time",0),h(this,"_temp",new w)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,s,r,n,o){if(!this.enabled)return;this._noise||(this._noise=Gie(()=>0));const a=this._temp.set(t.x,t.y,t.z).multiplyScalar(this.frequency),l=this._noise(a.x,a.y,a.z,this._time),c=this._noise(a.x,a.y,a.z,this._time+1e3*this.frequency),u=this._noise(a.x,a.y,a.z,this._time+2e3*this.frequency);this._temp.set(l,c,u).normalize();const d=n/o;let p=this.positionAmount.evaluate(d);this.separateAxes?(this._temp.x*=p*this.strengthXMultiplier,this._temp.y*=p*this.strengthYMultiplier,this._temp.z*=p*this.strengthZMultiplier):(this.strengthX&&(p*=this.strengthX.evaluate(d)*1.5),this._temp.multiplyScalar(p)),s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z}}ie([x()],mi.prototype,"damping",2),ie([x()],mi.prototype,"enabled",2),ie([x()],mi.prototype,"frequency",2),ie([x()],mi.prototype,"octaveCount",2),ie([x()],mi.prototype,"octaveMultiplier",2),ie([x()],mi.prototype,"octaveScale",2),ie([x(ct)],mi.prototype,"positionAmount",2),ie([x()],mi.prototype,"quality",2),ie([x(ct)],mi.prototype,"remap",2),ie([x()],mi.prototype,"remapEnabled",2),ie([x()],mi.prototype,"remapMultiplier",2),ie([x(ct)],mi.prototype,"remapX",2),ie([x()],mi.prototype,"remapXMultiplier",2),ie([x(ct)],mi.prototype,"remapY",2),ie([x()],mi.prototype,"remapYMultiplier",2),ie([x(ct)],mi.prototype,"remapZ",2),ie([x()],mi.prototype,"remapZMultiplier",2),ie([x()],mi.prototype,"scrollSpeedMultiplier",2),ie([x()],mi.prototype,"separateAxes",2),ie([x()],mi.prototype,"strengthMultiplier",2),ie([x(ct)],mi.prototype,"strengthX",2),ie([x()],mi.prototype,"strengthXMultiplier",2),ie([x(ct)],mi.prototype,"strengthY",2),ie([x()],mi.prototype,"strengthYMultiplier",2),ie([x(ct)],mi.prototype,"strengthZ",2),ie([x()],mi.prototype,"strengthZMultiplier",2);class Ui{constructor(){h(this,"enabled"),h(this,"attachRibbonToTransform",!1),h(this,"colorOverLifetime"),h(this,"colorOverTrail"),h(this,"dieWithParticles",!0),h(this,"inheritParticleColor",!0),h(this,"lifetime"),h(this,"lifetimeMultiplier"),h(this,"minVertexDistance",.2),h(this,"mode",0),h(this,"ratio",1),h(this,"ribbonCount",1),h(this,"shadowBias",0),h(this,"sizeAffectsLifetime",!1),h(this,"sizeAffectsWidth",!1),h(this,"splitSubEmitterRibbons",!1),h(this,"textureMode",0),h(this,"widthOverTrail"),h(this,"widthOverTrailMultiplier"),h(this,"worldSpace",!1)}getWidth(e,t,s,r){const n=this.widthOverTrail.evaluate(s,r);return e*=n,e}getColor(e,t,s){const r=this.colorOverTrail.evaluate(s),n=this.colorOverLifetime.evaluate(t);e.x*=r.r*n.r,e.y*=r.g*n.g,e.z*=r.b*n.b,e.w*=r.alpha*n.alpha}}ie([x()],Ui.prototype,"enabled",2),ie([x()],Ui.prototype,"attachRibbonToTransform",2),ie([x(vn)],Ui.prototype,"colorOverLifetime",2),ie([x(vn)],Ui.prototype,"colorOverTrail",2),ie([x()],Ui.prototype,"dieWithParticles",2),ie([x()],Ui.prototype,"inheritParticleColor",2),ie([x(ct)],Ui.prototype,"lifetime",2),ie([x()],Ui.prototype,"lifetimeMultiplier",2),ie([x()],Ui.prototype,"minVertexDistance",2),ie([x()],Ui.prototype,"mode",2),ie([x()],Ui.prototype,"ratio",2),ie([x()],Ui.prototype,"ribbonCount",2),ie([x()],Ui.prototype,"shadowBias",2),ie([x()],Ui.prototype,"sizeAffectsLifetime",2),ie([x()],Ui.prototype,"sizeAffectsWidth",2),ie([x()],Ui.prototype,"splitSubEmitterRibbons",2),ie([x()],Ui.prototype,"textureMode",2),ie([x(ct)],Ui.prototype,"widthOverTrail",2),ie([x()],Ui.prototype,"widthOverTrailMultiplier",2),ie([x()],Ui.prototype,"worldSpace",2);class Wi{constructor(){h(this,"enabled"),h(this,"space",0),h(this,"orbitalX"),h(this,"orbitalY"),h(this,"orbitalZ"),h(this,"orbitalXMultiplier"),h(this,"orbitalYMultiplier"),h(this,"orbitalZMultiplier"),h(this,"orbitalOffsetX"),h(this,"orbitalOffsetY"),h(this,"orbitalOffsetZ"),h(this,"speedModifier"),h(this,"speedModifierMultiplier"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier"),h(this,"_system"),h(this,"_temp",new w),h(this,"_temp2",new w),h(this,"_temp3",new w),h(this,"_hasOrbital",!1),h(this,"_index",0),h(this,"_orbitalMatrix",new Be)}update(e){this._system=e}init(e){this._index==0&&(e.debug=!0),this._index+=1,e.orbitx=this.orbitalX.evaluate(Math.random()),e.orbity=this.orbitalY.evaluate(Math.random()),e.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=e.orbitx!=0||e.orbity!=0||e.orbitz!=0}apply(e,t,s,r,n,o,a){var l;if(!this.enabled)return;const c=o/a,u=this.speedModifier.evaluate(c)*this.speedModifierMultiplier,d=this.x.evaluate(c),p=this.y.evaluate(c),f=this.z.evaluate(c);if(this._temp.set(-d,p,f),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((l=this._system)==null?void 0:l.worldPos)){const m=this._temp2.set(s.x,s.y,s.z),A=this.orbitalXMultiplier,v=this.orbitalYMultiplier,g=this.orbitalZMultiplier,b=u*Math.PI*2*10,y=Math.cos(b*A),_=Math.sin(b*A),S=Math.cos(b*v),M=Math.sin(b*v),I=Math.cos(b*g),R=Math.sin(b*g),E=m.x*(S*I)+m.y*(S*R)+m.z*-M,C=m.x*(_*M*I-y*R)+m.y*(_*M*R+y*I)+m.z*(_*S),z=m.x*(y*M*I+_*R)+m.y*(y*M*R-_*I)+m.z*(y*S),q=this._temp3.set(m.x-E,m.y-C,m.z-z);q.normalize(),q.multiplyScalar(.2/n*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),r.x+=q.x,r.y+=q.y,r.z+=q.z}r.x+=this._temp.x,r.y+=this._temp.y,r.z+=this._temp.z,r.x*=u,r.y*=u,r.z*=u}}ie([x()],Wi.prototype,"enabled",2),ie([x()],Wi.prototype,"space",2),ie([x(ct)],Wi.prototype,"orbitalX",2),ie([x(ct)],Wi.prototype,"orbitalY",2),ie([x(ct)],Wi.prototype,"orbitalZ",2),ie([x()],Wi.prototype,"orbitalXMultiplier",2),ie([x()],Wi.prototype,"orbitalYMultiplier",2),ie([x()],Wi.prototype,"orbitalZMultiplier",2),ie([x()],Wi.prototype,"orbitalOffsetX",2),ie([x()],Wi.prototype,"orbitalOffsetY",2),ie([x()],Wi.prototype,"orbitalOffsetZ",2),ie([x(ct)],Wi.prototype,"speedModifier",2),ie([x()],Wi.prototype,"speedModifierMultiplier",2),ie([x(ct)],Wi.prototype,"x",2),ie([x()],Wi.prototype,"xMultiplier",2),ie([x(ct)],Wi.prototype,"y",2),ie([x()],Wi.prototype,"yMultiplier",2),ie([x(ct)],Wi.prototype,"z",2),ie([x()],Wi.prototype,"zMultiplier",2);class lr{constructor(){h(this,"animation"),h(this,"enabled"),h(this,"cycleCount"),h(this,"frameOverTime"),h(this,"frameOverTimeMultiplier"),h(this,"numTilesX"),h(this,"numTilesY"),h(this,"startFrame"),h(this,"startFrameMultiplier"),h(this,"rowMode"),h(this,"rowIndex"),h(this,"spriteCount"),h(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(e){if(!this.sampleOnceAtStart())return this.getIndex(e)}getIndex(e){const t=this.numTilesX*this.numTilesY;e=e*this.cycleCount;let s=this.frameOverTime.evaluate(e%1);return s*=this.frameOverTimeMultiplier,s*=t,s=s%t,s=Math.floor(s),s}}ie([x()],lr.prototype,"animation",2),ie([x()],lr.prototype,"enabled",2),ie([x()],lr.prototype,"cycleCount",2),ie([x(ct)],lr.prototype,"frameOverTime",2),ie([x()],lr.prototype,"frameOverTimeMultiplier",2),ie([x()],lr.prototype,"numTilesX",2),ie([x()],lr.prototype,"numTilesY",2),ie([x(ct)],lr.prototype,"startFrame",2),ie([x()],lr.prototype,"startFrameMultiplier",2),ie([x()],lr.prototype,"rowMode",2),ie([x()],lr.prototype,"rowIndex",2),ie([x()],lr.prototype,"spriteCount",2),ie([x()],lr.prototype,"timeMode",2);class go{constructor(){h(this,"enabled"),h(this,"separateAxes"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier")}evaluate(e,t){return this.enabled?this.separateAxes?0:this.z.evaluate(e,t)*-1:0}}ie([x()],go.prototype,"enabled",2),ie([x()],go.prototype,"separateAxes",2),ie([x(ct)],go.prototype,"x",2),ie([x()],go.prototype,"xMultiplier",2),ie([x(ct)],go.prototype,"y",2),ie([x()],go.prototype,"yMultiplier",2),ie([x(ct)],go.prototype,"z",2),ie([x()],go.prototype,"zMultiplier",2);class Qn{constructor(){h(this,"enabled"),h(this,"range"),h(this,"separateAxes"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier")}evaluate(e,t){if(!this.enabled)return 0;if(!this.separateAxes){const s=tt.lerp(this.range.x,this.range.y,t);return this.z.evaluate(s)*-1}return 0}}ie([x()],Qn.prototype,"enabled",2),ie([x()],Qn.prototype,"range",2),ie([x()],Qn.prototype,"separateAxes",2),ie([x(ct)],Qn.prototype,"x",2),ie([x()],Qn.prototype,"xMultiplier",2),ie([x(ct)],Qn.prototype,"y",2),ie([x()],Qn.prototype,"yMultiplier",2),ie([x(ct)],Qn.prototype,"z",2),ie([x()],Qn.prototype,"zMultiplier",2);class xs{constructor(){h(this,"enabled"),h(this,"dampen"),h(this,"drag"),h(this,"dragMultiplier"),h(this,"limit"),h(this,"limitMultiplier"),h(this,"separateAxes"),h(this,"limitX"),h(this,"limitXMultiplier"),h(this,"limitY"),h(this,"limitYMultiplier"),h(this,"limitZ"),h(this,"limitZMultiplier"),h(this,"multiplyDragByParticleSize",!1),h(this,"multiplyDragByParticleVelocity",!1),h(this,"space"),h(this,"_temp",new w),h(this,"_temp2",new w)}apply(e,t,s,r,n,o,a){if(this.enabled){const l=this.limit.evaluate(n)*this.limitMultiplier;if(t.length()>l){this._temp.copy(t).normalize().multiplyScalar(l);const c=this.dampen*.5;t.x=tt.lerp(t.x,this._temp.x,c),t.y=tt.lerp(t.y,this._temp.y,c),t.z=tt.lerp(t.z,this._temp.z,c),s.x=tt.lerp(s.x,this._temp.x,c),s.y=tt.lerp(s.y,this._temp.y,c),s.z=tt.lerp(s.z,this._temp.z,c)}}}}ie([x()],xs.prototype,"enabled",2),ie([x()],xs.prototype,"dampen",2),ie([x(ct)],xs.prototype,"drag",2),ie([x()],xs.prototype,"dragMultiplier",2),ie([x(ct)],xs.prototype,"limit",2),ie([x()],xs.prototype,"limitMultiplier",2),ie([x()],xs.prototype,"separateAxes",2),ie([x(ct)],xs.prototype,"limitX",2),ie([x()],xs.prototype,"limitXMultiplier",2),ie([x(ct)],xs.prototype,"limitY",2),ie([x()],xs.prototype,"limitYMultiplier",2),ie([x(ct)],xs.prototype,"limitZ",2),ie([x()],xs.prototype,"limitZMultiplier",2),ie([x()],xs.prototype,"multiplyDragByParticleSize",2),ie([x()],xs.prototype,"multiplyDragByParticleVelocity",2),ie([x()],xs.prototype,"space",2);class oh{constructor(){h(this,"enabled"),h(this,"curve"),h(this,"curveMultiplier"),h(this,"mode"),h(this,"system"),h(this,"_lastWorldPosition"),h(this,"_velocity",new w),h(this,"_temp",new w)}update(e){this.enabled&&this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(e){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const t=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(t),e.add(this._temp)}}applyCurrent(e,t,s){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const r=this.curve.evaluate(t,s);this._temp.copy(this._velocity).multiplyScalar(r),e.add(this._temp)}}}ie([x()],oh.prototype,"enabled",2),ie([x(ct)],oh.prototype,"curve",2),ie([x()],oh.prototype,"curveMultiplier",2),ie([x()],oh.prototype,"mode",2);class Jr{constructor(){h(this,"enabled"),h(this,"range"),h(this,"separateAxes"),h(this,"size"),h(this,"sizeMultiplier"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier")}evaluate(e,t,s,r){const n=e.length(),o=tt.remap(n,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,s);return r*a}}ie([x()],Jr.prototype,"enabled",2),ie([x(ee)],Jr.prototype,"range",2),ie([x()],Jr.prototype,"separateAxes",2),ie([x(ct)],Jr.prototype,"size",2),ie([x()],Jr.prototype,"sizeMultiplier",2),ie([x(ct)],Jr.prototype,"x",2),ie([x()],Jr.prototype,"xMultiplier",2),ie([x(ct)],Jr.prototype,"y",2),ie([x()],Jr.prototype,"yMultiplier",2),ie([x(ct)],Jr.prototype,"z",2),ie([x()],Jr.prototype,"zMultiplier",2);class Cu{constructor(){h(this,"enabled"),h(this,"range"),h(this,"color")}evaluate(e,t,s){const r=e.length(),n=tt.remap(r,this.range.x,this.range.y,0,1),o=this.color.evaluate(n,t);s.x*=o.r,s.y*=o.g,s.z*=o.b,s.w*=o.alpha}}ie([x()],Cu.prototype,"enabled",2),ie([x(ee)],Cu.prototype,"range",2),ie([x(vn)],Cu.prototype,"color",2);function o3(i){const e=i.domElement.shadowRoot.querySelector("link[rel='ar']");if(e)return e;const t=document.createElement("div");t.classList.add("menu"),t.classList.add("quicklook-menu"),t.style.display="none",t.style.visibility="hidden";const s=document.createElement("button");s.id="open-in-ar",s.innerText="Open in QuickLook",t.appendChild(s);const r=document.createElement("a");r.id="needle-usdz-link",r.style.display="none",r.rel="ar",r.href="",t.appendChild(r);const n=document.createElement("img");return n.id="button",r.appendChild(n),i.domElement.shadowRoot.appendChild(t),r}function Xie(){var i=new Date;const e=i.getMonth()+1,t=i.getDate(),s=i.getHours(),r=i.getMinutes(),n=i.getSeconds(),o=(e<10?"0":"")+e,a=(t<10?"0":"")+t,l=(s<10?"0":"")+s,c=(r<10?"0":"")+r,u=(n<10?"0":"")+n;return i.getFullYear()+o+a+"-"+l+c+u}const o_=le("debugusdz");function qie(i,e){const t=[],s=se.getComponentsInChildren(i,Cr),r=se.getComponentsInChildren(i,Bn);let n=!1;const o=new Fr("rest",.01,[]),a=new Map,l=(c,u)=>{if(!n&&u.tracks.length>0&&(n=!0,c.push(o)),u.tracks.length>0)for(const d of u.tracks){const p=Ot.parseTrackName(d.name),f=Ot.findNode(i,p.nodeName);if(f){a.has(f)||a.set(f,[]);const m=a.get(f);switch(p.propertyName){case"position":{if(m.includes("position"))continue;const A=f.position,v=new an(d.name,[0,.01],[A.x,A.y,A.z,A.x,A.y,A.z]);m.push("position"),o.tracks.push(v);break}case"quaternion":{if(m.includes("quaternion"))continue;const A=f.quaternion,v=new an(d.name,[0,.01],[A.x,A.y,A.z,A.w,A.x,A.y,A.z,A.w]);m.push("quaternion"),o.tracks.push(v);break}case"scale":{if(m.includes("scale"))continue;const A=f.scale,v=new an(d.name,[0,.01],[A.x,A.y,A.z,A.x,A.y,A.z]);m.push("scale"),o.tracks.push(v);break}}}}};for(const c of s){if(!c||!c.runtimeAnimatorController)continue;o_&&console.log(c);const u=[];for(const d of c.runtimeAnimatorController.enumerateActions()){o_&&console.log(d);const p=d.getClip();l(u,p),u.includes(p)||u.push(p)}t.push({root:c.gameObject,clips:u})}for(const c of r){o_&&console.log(c);const u=[];for(const d of c.animations)l(u,d),u.includes(d)||u.push(d);t.push({root:c.gameObject,clips:u})}o_&&(console.log("Rest Pose Clip",o),console.log("USDZ Animation Clips",t));for(const c of t)for(const u of c.clips)e.registerAnimation(c.root,u)}var Yie=Object.defineProperty,Kie=Object.getOwnPropertyDescriptor,Kl=(i,e,t,s)=>{for(var r=s>1?void 0:s?Kie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Yie(e,t,r),r};const Eu=le("debugtext");var Ls=(i=>(i[i.UpperLeft=0]="UpperLeft",i[i.UpperCenter=1]="UpperCenter",i[i.UpperRight=2]="UpperRight",i[i.MiddleLeft=3]="MiddleLeft",i[i.MiddleCenter=4]="MiddleCenter",i[i.MiddleRight=5]="MiddleRight",i[i.LowerLeft=6]="LowerLeft",i[i.LowerCenter=7]="LowerCenter",i[i.LowerRight=8]="LowerRight",i))(Ls||{}),a3=(i=>(i[i.Normal=0]="Normal",i[i.Bold=1]="Bold",i[i.Italic=2]="Italic",i[i.BoldAndItalic=3]="BoldAndItalic",i))(a3||{});class Zr extends _u{constructor(){super(...arguments),h(this,"alignment",0),h(this,"verticalOverflow",0),h(this,"horizontalOverflow",0),h(this,"lineSpacing",1),h(this,"supportRichText",!1),h(this,"font"),h(this,"fontStyle",0),h(this,"_text",""),h(this,"_fontSize",12),h(this,"_textMeshUi",null),h(this,"_didHandleTextRenderOnTop",!1)}setAlphaFactor(e){var t;super.setAlphaFactor(e),(t=this.uiObject)==null||t.set({fontOpacity:this.color.alpha*this.alphaFactor}),this.markDirty()}get text(){return this._text}set text(e){e!==this._text&&(this._text=e,this.feedText(this.text,this.supportRichText),this.markDirty())}set_text(e){this.text=e}get fontSize(){return this._fontSize}set fontSize(e){var t;this._fontSize=e,(t=this.uiObject)==null||t.set({fontSize:e})}onColorChanged(){var e;(e=this.uiObject)==null||e.set({color:this.color,fontOpacity:this.color.alpha})}onParentRectTransformChanged(){super.onParentRectTransformChanged(),this.uiObject&&this.updateOverflow()}onBeforeRender(){var e;this.uiObject&&((e=this.Canvas)!=null&&e.screenspace||this.context.isInVR)&&this.updateOverflow()}updateOverflow(){var e;const t=(e=this.uiObject)==null?void 0:e._overflow;t&&(t._needsUpdate=!0,this.markDirty())}onCreate(e){Eu&&console.log(this),this.horizontalOverflow==1&&(e.whiteSpace="pre"),this.verticalOverflow==0&&(this.context.renderer.localClippingEnabled=!0,e.overflow="hidden"),this.horizontalOverflow==1&&this.verticalOverflow==0,e.lineHeight=this.lineSpacing,delete e.backgroundOpacity,delete e.backgroundColor,Eu&&(e.backgroundColor=16750848,e.backgroundOpacity=.5);const t=this.rectTransform;e={...e,...this.getTextOpts()},this.getAlignment(e),Eu&&(e.backgroundColor=Math.random()*16777215,e.backgroundOpacity=.1),this.uiObject=t.createNewText(e),this.feedText(this.text,this.supportRichText)}onAfterAddedToScene(){super.onAfterAddedToScene(),this.handleTextRenderOnTop()}getTextOpts(){const e=this.fontSize,t={color:this.color,fontOpacity:this.color.alpha,fontSize:e,fontKerning:"normal"};return this.setFont(t,this.fontStyle),t}onEnable(){super.onEnable(),this._didHandleTextRenderOnTop=!1,this.uiObject&&this.uiObject.addAfterUpdate(()=>{this.setShadowComponentOwner(this.uiObject),this.markDirty()}),setTimeout(()=>this.markDirty(),10)}getAlignment(e){switch(e.flexDirection="column",this.alignment){case 0:case 3:case 6:e.textAlign="left";break;case 1:case 4:case 7:e.textAlign="center";break;case 2:case 5:case 8:e.textAlign="right";break}switch(this.alignment){default:case 0:case 1:case 2:e.alignItems="start";break;case 3:case 4:case 5:e.alignItems="center";break;case 6:case 7:case 8:e.alignItems="end";break}return e}feedText(e,t){var s,r,n;if(Eu&&console.log("feedText",this.uiObject,e,t),!!this.uiObject)if(this._textMeshUi||(this._textMeshUi=[]),this.uiObject.children.length=0,!t||e.length===0)this.uiObject.textContent=e;else{let o=this.getNextTag(e);if(o){if(o.startIndex>0){for(let c=this.uiObject.children.length-1;c>=0;c--){const u=this.uiObject.children[c];u.isUI&&(this.uiObject.remove(u),u.clear())}const l=new Bb({textContent:e.substring(0,o.startIndex),color:"inherit"});this.uiObject.add(l)}}else{this.uiObject.textContent="",this.setOptions({textContent:e});return}const a=[];for(;o;){const l=this.getNextTag(e,o.endIndex),c={fontFamily:(s=this.uiObject)==null?void 0:s.get("fontFamily"),color:"inherit",textContent:""};if(l){c.textContent=this.getText(e,o,l),this.handleTag(o,c,a);const u=new Bb(c);(r=this.uiObject)==null||r.add(u)}else{c.textContent=e.substring(o.endIndex),this.handleTag(o,c,a);const u=new Bb(c);(n=this.uiObject)==null||n.add(u)}o=l}}}handleTextRenderOnTop(){this._didHandleTextRenderOnTop||(this._didHandleTextRenderOnTop=!0,this.startCoroutine(this.renderOnTopCoroutine()))}*renderOnTopCoroutine(){if(!this.canvas)return;const e=[],t=this.canvas,s={renderOnTop:t.renderOnTop,depthWrite:t.depthWrite,doubleSided:t.doubleSided};for(;;){let r=!1;if(this._textMeshUi)for(let n=0;n<this._textMeshUi.length;n++){if(e[n]===!0)continue;r=!0;const o=this._textMeshUi[n];o.textContent&&(Nb(o,s),e[n]=!0)}if(!r)break;yield}}handleTag(e,t,s){if(!e.isEndTag){if(e.type.includes("color")){const r=new $M(e,{color:t.color});if(s.push(r),e.type.length>6){const n=parseInt("0x"+e.type.substring(7));t.color=n}else t.color=new _e(1,1,1)}else if(e.type=="b"){this.setFont(t,1);const r=new $M(e,{fontWeight:700});s.push(r)}else if(e.type=="i"){this.setFont(t,2);const r=new $M(e,{fontStyle:"italic"});s.push(r)}}}getText(e,t,s){return e.substring(t.endIndex,s.startIndex)}getNextTag(e,t=0){const s=e.indexOf("<",t),r=e.indexOf(">",s);if(s>=0&&r>=0){const n=e.substring(s+1,r);return{type:n,startIndex:s,endIndex:r+1,isEndTag:n.startsWith("/")}}return null}setFont(e,t){if(!this.font)return;const s=this.font,r=this.getFamilyNameWithCorrectSuffix(s,t);Eu&&console.log("Selected font family:"+r);let n=AM.getFontFamily(r);switch(n||(n=AM.addFontFamily(r)),e.fontFamily=n,t){default:case 0:e.fontWeight=400,e.fontStyle="normal";break;case 1:e.fontWeight=700,e.fontStyle="normal";break;case 2:e.fontWeight=400,e.fontStyle="italic";break;case 3:e.fontStyle="italic",e.fontWeight=400}let o=n.getVariant(e.fontWeight,e.fontStyle);if(!o){let a=r;a!=null&&a.endsWith("-msdf.json")||(a+="-msdf.json");let l=r;l!=null&&l.endsWith(".png")||(l+=".png"),o=n.addVariant(e.fontWeight,e.fontStyle,a,l),o?.addEventListener("ready",()=>{this.markDirty()})}}getFamilyNameWithCorrectSuffix(e,t){var s;const r=e.lastIndexOf("-");if(r<0)return e;const n=(s=e.substring(r+1))==null?void 0:s.toLowerCase();if(Jie.includes(n))return Eu&&console.warn("Unsupported font style: "+n),e;const o=e.lastIndexOf("/");let a=e;o>=0&&(a=a.substring(o+1));const l=a[0]===a[0].toUpperCase(),c=e.substring(0,r);switch(Eu&&console.log("Select font: ",e,a3[t],a,l,c),t){case 0:return l?c+"-Regular":c+"-regular";case 1:return l?c+"-Bold":c+"-bold";case 2:return l?c+"-Italic":c+"-italic";case 3:return l?c+"-BoldItalic":c+"-bolditalic";default:return e}}}Kl([x()],Zr.prototype,"alignment",2),Kl([x()],Zr.prototype,"verticalOverflow",2),Kl([x()],Zr.prototype,"horizontalOverflow",2),Kl([x()],Zr.prototype,"lineSpacing",2),Kl([x()],Zr.prototype,"supportRichText",2),Kl([x(URL)],Zr.prototype,"font",2),Kl([x()],Zr.prototype,"fontStyle",2),Kl([x()],Zr.prototype,"text",1),Kl([x()],Zr.prototype,"fontSize",1);class $M{constructor(e,t){h(this,"tag"),h(this,"previousValues"),this.tag=e,this.previousValues=t}}const Jie=["medium","mediumitalic","black","blackitalic","thin","thinitalic","extrabold","light","lightitalic","semibold"];class ah{constructor(e){h(this,"id"),h(this,"content",""),h(this,"font",[]),h(this,"pointSize",144),h(this,"width"),h(this,"height"),h(this,"depth"),h(this,"wrapMode"),h(this,"horizontalAlignment"),h(this,"verticalAlignment"),h(this,"material"),this.id=e}static getId(){return this.global_id++}setDepth(e){return this.depth=e,this}setPointSize(e){return this.pointSize=e,this}setHorizontalAlignment(e){return this.horizontalAlignment=e,this}setVerticalAlignment(e){return this.verticalAlignment=e,this}writeTo(e,t){var s;t.beginBlock(`def Preliminary_Text "${this.id}"`),this.content&&t.appendLine(`string content = "${this.content}"`),(!this.font||this.font.length<=0)&&(this.font||(this.font=[]),(s=this.font)==null||s.push("sans-serif"));const r=this.font.map(n=>`"${n}"`).join(", ");t.appendLine(`string[] font = [ ${r} ]`),t.appendLine(`double pointSize = ${this.pointSize}`),typeof this.width=="number"&&t.appendLine(`double width = ${this.width}`),typeof this.height=="number"&&t.appendLine(`double height = ${this.height}`),typeof this.depth=="number"&&t.appendLine(`double depth = ${this.depth}`),this.wrapMode&&t.appendLine(`token wrapMode = "${this.wrapMode}"`),this.horizontalAlignment&&t.appendLine(`token horizontalAlignment = "${this.horizontalAlignment}"`),this.verticalAlignment&&t.appendLine(`token verticalAlignment = "${this.verticalAlignment}"`),this.material!==void 0&&t.appendLine(`rel material:binding = </Materials/Material_${this.material.id}>`),t.closeBlock()}}h(ah,"global_id",0);class a_{static singleLine(e,t,s){const r=new ah("text_"+ah.getId());return r.content=e,t&&(r.pointSize=t),s&&(r.depth=s),r}static multiLine(e,t,s,r,n,o){const a=new ah("text_"+ah.getId());return a.content=e,a.width=t,a.height=s,a.horizontalAlignment=r,a.verticalAlignment=n,o!==void 0&&(a.wrapMode=o),a}}const Zie=new Be().makeRotationY(Math.PI),$ie=new Be().makeScale(-1,1,-1);class Wg{get extensionName(){return"text"}onExportObject(e,t,s){}exportText(e,t,s){const r=se.getComponent(e,Zr);if(!r)return;const n=se.getComponent(e,Kr);let o=100,a=100;n&&(o=n.width,a=n.height),t.matrix=Zie.clone(),n&&t.matrix.premultiply($ie);const l=new _e().copySRGBToLinear(r.color);t.material=new Ro({color:l,emissive:l}),t.addEventListener("serialize",(c,u)=>{let d=r.text;d=d.replace(/\n/g,"\\n");const p=a_.multiLine(d,o,a,"center","bottom","flowing");this.setTextAlignment(p,r.alignment),this.setOverflow(p,r),t.material&&(p.material=t.material),p.pointSize=this.convertToTextSize(r.fontSize),p.depth=.001,p.writeTo(void 0,c)})}convertToTextSize(e){return 1/.0502*144*e}setOverflow(e,t){t.horizontalOverflow?e.wrapMode="singleLine":e.wrapMode="flowing"}setTextAlignment(e,t){switch(t){case Ls.LowerLeft:case Ls.MiddleLeft:case Ls.UpperLeft:e.horizontalAlignment="left";break;case Ls.LowerCenter:case Ls.MiddleCenter:case Ls.UpperCenter:e.horizontalAlignment="center";break;case Ls.LowerRight:case Ls.MiddleRight:case Ls.UpperRight:e.horizontalAlignment="right";break}switch(t){case Ls.LowerLeft:case Ls.LowerCenter:case Ls.LowerRight:e.verticalAlignment="bottom";break;case Ls.MiddleLeft:case Ls.MiddleCenter:case Ls.MiddleRight:e.verticalAlignment="middle";break;case Ls.UpperLeft:case Ls.UpperCenter:case Ls.UpperRight:e.verticalAlignment="top";break}}}class l_{get extensionName(){return"tmui"}onExportObject(e,t,s){const r=se.getComponent(e,nr);if(r&&r.activeAndEnabled&&r.renderMode===s3.WorldSpace){const n=new Wg,o=se.getComponent(e,Kr),a=se.getComponent(e,th);if(o){o.width,o.height;const l=ao.createEmpty(),c=o.shadowComponent;if(t.add(l),c){const u=c.matrix;l.matrix.copy(u);const d=new Map,p=new Map;d.set(c,l),p.set(c,a?a.alpha:1),c.traverse(f=>{if(f===c)return;const m=ao.createEmpty();m.matrix.copy(f.matrix);const A=f.parent,v=A&&typeof A.textContent=="string"&&A.textContent.length;let g=p.get(A)||1;const b=se.getComponent(f,th);if(b&&(g*=b.alpha),f instanceof ye&&v){const _=f[Ma].gameObject;n.exportText(_,m,s)}if(f instanceof ye&&!v){const _=f.geometry.clone();_.scale(1,1,-1),this.flipWindingOrder(_),m.geometry=_;const S=new _e,M=f.material.opacity;S.copy(f.material.color),m.material=new li({color:S,opacity:M*g,map:f.material.map,transparent:!0})}d.set(f,m),p.set(f,g);const y=d.get(A);if(!y){console.error("Error when exporting UI: shadow component parent not found!",f,f.parent);return}y.add(m)})}}}}flipWindingOrder(e){const t=e.index.array;for(let s=0,r=t.length/3;s<r;s++){const n=t[s*3];t[s*3]=t[s*3+2],t[s*3+2]=n}e.index.needsUpdate=!0}}var ese=Object.defineProperty,tse=Object.getOwnPropertyDescriptor,Gn=(i,e,t,s)=>{for(var r=s>1?void 0:s?tse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ese(e,t,r),r};const Us=le("debugusdz");class lh{constructor(){h(this,"callToAction"),h(this,"checkoutTitle"),h(this,"checkoutSubtitle"),h(this,"callToActionURL")}}Gn([x()],lh.prototype,"callToAction",2),Gn([x()],lh.prototype,"checkoutTitle",2),Gn([x()],lh.prototype,"checkoutSubtitle",2),Gn([x()],lh.prototype,"callToActionURL",2);class Hn extends Ie{constructor(){super(...arguments),h(this,"objectToExport"),h(this,"autoExportAnimations",!1),h(this,"exportFileName"),h(this,"customUsdzFile"),h(this,"customBranding"),h(this,"anchoringType","plane"),h(this,"planeAnchoringAlignment","horizontal"),h(this,"interactive",!0),h(this,"extensions",[]),h(this,"allowCreateQuicklookButton",!0),h(this,"link"),h(this,"webxr"),h(this,"onClickedOpenInARElement",e=>{e.preventDefault(),this.exportAsync()}),h(this,"lastCallback"),h(this,"_quicklookButton"),h(this,"_quicklookButtonContainer",null)}start(){var e,t,s;Us&&(console.log("USDZExporter",this),console.log("Debug USDZ Mode. Press 'T' to export"),window.addEventListener("keydown",r=>{switch(r.key){case"t":this.exportAsync();break}}),Ka()&&setTimeout(()=>{this.exportAsync()},2e3)),this.objectToExport||(this.objectToExport=this.gameObject),!((t=(e=this.objectToExport)==null?void 0:e.children)!=null&&t.length)&&!((s=this.objectToExport)!=null&&s.isMesh)&&(this.objectToExport=this.context.scene),this.interactive&&(this.extensions.push(new Xb),this.extensions.push(new Vb),this.extensions.push(new Wg),this.extensions.push(new l_))}onEnable(){var e;const t=_f(),s=Ja();(Us||t&&s)&&((Us||this.allowCreateQuicklookButton)&&this.addQuicklookButton(),this.lastCallback=this.quicklookCallback.bind(this),this.link=o3(this.context),this.link.addEventListener("message",this.lastCallback)),Us&&fs("USDZ Exporter enabled: "+this.name),(e=document.getElementById("open-in-ar"))==null||e.addEventListener("click",this.onClickedOpenInARElement)}onDisable(){var e,t;(e=this.link)==null||e.removeEventListener("message",this.lastCallback);const s=_f(),r=Ja();(Us||s&&r)&&this.removeQuicklookButton(),Us&&fs("USDZ Exporter disabled: "+this.name),(t=document.getElementById("open-in-ar"))==null||t.removeEventListener("click",this.onClickedOpenInARElement)}async exportAsync(){var e;let t=this.exportFileName??((e=this.objectToExport)==null?void 0:e.name)??this.name;if(Kd()||(t!==""&&(t+="-"),t+="MadeWithNeedle"),t+="-"+Xie(),this.link||(this.link=o3(this.context)),this.customUsdzFile){Us&&console.log("Exporting custom usdz",this.customUsdzFile);const v=this.buildQuicklookOverlay();Us&&console.log("QuickLook Overlay",v);const g=v.callToAction?encodeURIComponent(v.callToAction):"",b=v.checkoutTitle?encodeURIComponent(v.checkoutTitle):"",y=v.checkoutSubtitle?encodeURIComponent(v.checkoutSubtitle):"";this.link.href=this.customUsdzFile+`#callToAction=${g}&checkoutTitle=${b}&checkoutSubtitle=${y}&callToActionURL=${v.callToActionURL}`,Us&&console.log(this.link.href),this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click();return}if(!this.objectToExport){console.warn("No object to export",this);return}const s=se.getComponentsInChildren(this.objectToExport,Di),r=new Array;for(const v of s)for(const g of v.sharedMaterials)if(g){const b=v.loadProgressiveTextures(g);b instanceof Promise&&r.push(b)}Us&&fs("Load textures: "+r.length),await Promise.all(r),Us&&fs("Load textures: done");const n=kn.Global.Mask;kn.Global.Set(as.AR),this.applyWebARSessionRoot();const o=new q7,a=[...this.extensions],l=new ib;a.push(l),this.autoExportAnimations&&qie(this.objectToExport,l);const c={self:this,exporter:o,extensions:a,object:this.objectToExport};this.dispatchEvent(new CustomEvent("before-export",{detail:c})),o.debug=Us,this.anchoringType!=="plane"&&this.anchoringType!=="none"&&this.anchoringType!=="image"&&this.anchoringType!=="face"&&(this.anchoringType="plane"),this.planeAnchoringAlignment!=="horizontal"&&this.planeAnchoringAlignment!=="vertical"&&this.planeAnchoringAlignment!=="any"&&(this.planeAnchoringAlignment="horizontal");const u=await o.parse(this.objectToExport,{ar:{anchoring:{type:this.anchoringType},planeAnchoring:{alignment:this.planeAnchoringAlignment}},extensions:a,quickLookCompatible:!0}),d=new Blob([u],{type:"application/octet-stream"});this.dispatchEvent(new CustomEvent("after-export",{detail:c}));const p=this.buildQuicklookOverlay();Us&&console.log("QuickLook Overlay",p);const f=p.callToAction?encodeURIComponent(p.callToAction):"",m=p.checkoutTitle?encodeURIComponent(p.checkoutTitle):"",A=p.checkoutSubtitle?encodeURIComponent(p.checkoutSubtitle):"";this.link.href=URL.createObjectURL(d)+`#callToAction=${f}&checkoutTitle=${m}&checkoutSubtitle=${A}&callToActionURL=${p.callToActionURL}`,this.lastCallback||(this.lastCallback=this.quicklookCallback.bind(this),this.link.addEventListener("message",this.lastCallback)),this.link.download=t+".usdz",this.link.click(),Us&&console.log("USDZ generation done. Downloading as "+this.link.download),kn.Global.Set(n)}quicklookCallback(e){if(e?.data=="_apple_ar_quicklook_button_tapped"){Us&&Nr("Quicklook closed via call to action button");var t=new CustomEvent("quicklook-button-tapped",{detail:this});if(this.dispatchEvent(t),!t.defaultPrevented){const s=new URLSearchParams(this.link.href);if(s){const r=s.get("callToActionURL");Us&&fs("Quicklook url: "+r),r&&(Kd()?globalThis.open(r,"_blank"):console.warn("Quicklook closed: custom redirects require a Needle Engine Pro license: https://needle.tools/pricing",r))}}}}buildQuicklookOverlay(){var e,t,s,r,n,o;const a={};return this.customBranding&&Object.assign(a,this.customBranding),Kd()||(console.log("Custom Quicklook banner text requires pro license: https://needle.tools/pricing"),a.callToAction="Close",a.checkoutTitle="\u{1F335} Made with Needle",a.checkoutSubtitle="_"),(((e=a.callToAction)==null?void 0:e.length)||((t=a.checkoutTitle)==null?void 0:t.length)||((s=a.checkoutSubtitle)==null?void 0:s.length))&&((r=a.callToAction)!=null&&r.length||(a.callToAction="\0"),(n=a.checkoutTitle)!=null&&n.length||(a.checkoutTitle="\0"),(o=a.checkoutSubtitle)!=null&&o.length||(a.checkoutSubtitle="\0")),this.dispatchEvent(new CustomEvent("quicklook-overlay",{detail:a})),a}async createQuicklookButton(){var e,t;if(!this.webxr)if(await bf(1),this.webxr=se.findObjectOfType(Ct)??void 0,this.webxr)if(this.webxr.VRButton&&((e=this.webxr.VRButton.parentElement)==null||e.removeChild(this.webxr.VRButton)),this.webxr.ARButton&&this._quicklookButton!==this.webxr.ARButton){this._quicklookButton=this.webxr.ARButton;const s=(t=this.webxr.ARButton.parentElement)==null?void 0:t.querySelector("a");s&&(s.href=""),this.webxr.ARButton.innerText="Open in Quicklook",this.webxr.ARButton.disabled=!1,this.webxr.ARButton.addEventListener("click",r=>{r.preventDefault(),this.exportAsync()}),this.webxr.ARButton.classList.add("quicklook-ar-button"),this._quicklookButtonContainer=this.webxr.ARButton.parentElement,this.dispatchEvent(new CustomEvent("created-button",{detail:this.webxr.ARButton}))}else{this.webxr.createARButton=!1,this.webxr.createVRButton=!1;let s=this.context.domElement.shadowRoot.querySelector(".webxr-buttons");s||(s=document.createElement("div"),s.classList.add("webxr-buttons"));const r=document.createElement("button");r.innerText="Open in Quicklook",r.addEventListener("click",()=>{this.exportAsync()}),r.classList.add("webxr-ar-button"),r.classList.add("webxr-button"),r.classList.add("quicklook-ar-button"),this._quicklookButton=r,s.appendChild(r),this._quicklookButtonContainer=s,this.dispatchEvent(new CustomEvent("created-button",{detail:r}))}else console.warn("Could not find WebXR component: will not create Quicklook button",zt.Current)}async addQuicklookButton(){await this.createQuicklookButton(),this._quicklookButton&&this._quicklookButtonContainer&&this._quicklookButtonContainer.appendChild(this._quicklookButton)}removeQuicklookButton(){var e;(e=this._quicklookButton)==null||e.remove()}applyWebARSessionRoot(){if(!this.objectToExport)return;let e=se.getComponentInParent(this.objectToExport,xa);const t=e!=null;if(e||(e=se.getComponentInChildren(this.objectToExport,xa)),Us&&console.log("applyWebARSessionRoot",e),!e){Us&&console.warn("No WebARSessionRoot found in parent hierarchy",this.objectToExport);return}const s=t?this.objectToExport:e.gameObject,r=1/e.arScale;Us&&console.log("AR Session Root scale",r,s),s.matrix.makeScale(r,r,r),e.invertForward&&s.matrix.multiply(new Be().makeRotationY(Math.PI))}}Gn([x(Re)],Hn.prototype,"objectToExport",2),Gn([x()],Hn.prototype,"autoExportAnimations",2),Gn([x()],Hn.prototype,"exportFileName",2),Gn([x(URL)],Hn.prototype,"customUsdzFile",2),Gn([x(lh)],Hn.prototype,"customBranding",2),Gn([x()],Hn.prototype,"anchoringType",2),Gn([x()],Hn.prototype,"planeAnchoringAlignment",2),Gn([x()],Hn.prototype,"interactive",2),Gn([x()],Hn.prototype,"allowCreateQuicklookButton",2);const l3=le("debugdeletable");class c_ extends _a{}class eT extends Ie{constructor(){super(...arguments),h(this,"deleteBoxes",[])}awake(){this.deleteBoxes=se.findObjectsOfType(c_,this.context)}update(){for(const e of this.deleteBoxes){const t=this.gameObject;if(e.isInBox(t)===!0){const s=se.getComponentInParent(this.gameObject,fp);s?l3&&console.warn("Can not delete object with usage marker",this.guid,s):(l3&&console.log("DESTROY",this.gameObject),oy(this.gameObject,this.context.connection))}}}}var ise=Object.defineProperty,sse=Object.getOwnPropertyDescriptor,Mu=(i,e,t,s)=>{for(var r=s>1?void 0:s?sse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ise(e,t,r),r};class Jo extends Tr{constructor(){super(...arguments),h(this,"mode"),h(this,"focusDistance"),h(this,"focalLength"),h(this,"aperture"),h(this,"gaussianMaxRadius"),h(this,"resolutionScale"),h(this,"bokehScale")}get typeName(){return"DepthOfField"}init(){this.focalLength.valueProcessor=t=>{const s=t/300,r=2;return tt.lerp(r,.01,s)};const e=20;this.aperture.valueProcessor=t=>{const s=1-t/32;return tt.lerp(1,e,s)}}onCreateEffect(){if(this.mode===0)return;const e=1/window.devicePixelRatio;if(this.resolutionScale===void 0){let s=1;Ka()&&(s=.6),this.resolutionScale=new Tt(s*e)}const t=new OO(this.context.mainCamera,{worldFocusRange:.2,focalLength:1,bokehScale:20,resolutionScale:this.resolutionScale.value});return this.focusDistance.onValueChanged=s=>{t.circleOfConfusionMaterial.worldFocusDistance=s},this.focalLength.onValueChanged=s=>t.circleOfConfusionMaterial.worldFocusRange=s,this.aperture.onValueChanged=s=>t.bokehScale=s,this.resolutionScale&&(this.resolutionScale.onValueChanged=s=>t.resolution.scale=s),[t]}unapply(){}}Mu([x()],Jo.prototype,"mode",2),Mu([x(Tt)],Jo.prototype,"focusDistance",2),Mu([x(Tt)],Jo.prototype,"focalLength",2),Mu([x(Tt)],Jo.prototype,"aperture",2),Mu([x(Tt)],Jo.prototype,"gaussianMaxRadius",2),Mu([x(Tt)],Jo.prototype,"resolutionScale",2),Mu([x(Tt)],Jo.prototype,"bokehScale",2),mo("DepthOfField",Jo);var rse=Object.defineProperty,nse=Object.getOwnPropertyDescriptor,ose=(i,e,t,s)=>{for(var r=s>1?void 0:s?nse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&rse(e,t,r),r};class h_ extends Ie{constructor(){super(...arguments),h(this,"visibleOn")}onEnable(){this.apply()}apply(){this.test()||se.setActive(this.gameObject,!1)}test(){return this.visibleOn<0?!0:Ka()?(this.visibleOn&2)!==0:(this.visibleOn&1)!==0}}ose([x()],h_.prototype,"visibleOn",2);class tT{get extensionName(){return"DocumentExtension"}onAfterBuildDocument(e){}}var ase=Object.defineProperty,lse=Object.getOwnPropertyDescriptor,c3=(i,e,t,s)=>{for(var r=s>1?void 0:s?lse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ase(e,t,r),r},h3=(i=>(i.SelectStart="selectstart",i.SelectEnd="selectend",i))(h3||{}),u_;const ch=(u_=class extends pp{constructor(){super(),h(this,"showGizmo",!0),h(this,"useViewAngle",!0),h(this,"transformSelf",!0),h(this,"orbit",null),h(this,"selectStartEventListener",[]),h(this,"selectEndEventListener",[]),h(this,"_dragHelper",null),h(this,"_draggingRigidbodies",[]),h(this,"_waitingForDragStart",null),h(this,"_isDragging",!1),h(this,"_marker",null),h(this,"_dragDelta"),h(this,"_didDrag",!1),h(this,"_activePointerId"),this.selectStartEventListener=[],this.selectEndEventListener=[],this._dragDelta=new ee}static get HasAnySelected(){return this._active>0}addDragEventListener(i,e){switch(i){case"selectstart":this.selectStartEventListener.push(e);break;case"selectend":this.selectEndEventListener.push(e);break}}start(){this.orbit=se.findObjectOfType(Gl,this.context),this.gameObject.getComponentInParent(zl)||this.gameObject.addNewComponent(zl)}allowEdit(i=null){return this.context.connection.allowEditing}onPointerEnter(i){if(!this.allowEdit(this.gameObject)||Ct.IsInWebXR)return;const e=se.getComponentInParent(i.object,ch);!e||e!==this||(ch.lastHovered=i.object,this.context.domElement.style.cursor="pointer")}onPointerExit(i){this.allowEdit(this.gameObject)&&(Ct.IsInWebXR||ch.lastHovered===i.object&&(this.context.domElement.style.cursor="auto"))}onPointerDown(i){this.allowEdit(this.gameObject)&&(Ct.IsInWebXR||(ch._active+=1,this._dragDelta.set(0,0),this._didDrag=!1,this._waitingForDragStart=i.clone(),i.stopPropagation(),this.orbit&&(this.orbit.enabled=!1)))}onPointerUp(i){this._waitingForDragStart=null,this.allowEdit(this.gameObject)&&(ch._active>0&&(ch._active-=1),!Ct.IsInWebXR&&(this.onDragEnd(i),i.stopPropagation(),this.orbit&&(this.orbit.enabled=!0)))}update(){var i;if(!Ct.IsInWebXR){if(this._waitingForDragStart){if(!this._didDrag){const t=this.context.input.getPointerPositionDelta(0);if(t&&this._dragDelta.add(t),this._dragDelta.length()>2)this._didDrag=!0;else return}const e=this._waitingForDragStart;this._waitingForDragStart=null,this.onDragStart(e)}this._dragHelper&&this._dragHelper.hasSelected&&this.onUpdateDrag(),(((i=this._dragHelper)==null?void 0:i.hasSelected)===!1||this._activePointerId!==void 0&&this.context.input.getPointerPressed(this._activePointerId)===!1)&&this.onDragEnd(null)}}onDragStart(i){if(!this._dragHelper)if(this.context.mainCamera)this._dragHelper=new d3(this.context.mainCamera);else return;if(!i||!i.object)return;const e=se.getComponentInParent(i.object,ch);if(!e||e!==this)return;let t=i.object;this.transformSelf&&(t=this.gameObject);const s={selected:t,attached:t};for(const a of this.selectStartEventListener)a(this,s);if(this._activePointerId=i.pointerId,!s.attached)return;s.attached,t=s.attached,this._isDragging=!0,this._dragHelper.setSelected(t,this.context),this.orbit&&(this.orbit.enabled=!1);const r=se.getComponentInChildren(t,Yc);r&&(r.fastMode=!0,r?.requestOwnership()),this._marker=se.addNewComponent(t,fp),this._draggingRigidbodies.length=0;const n=se.getComponentsInChildren(t,Vi);n&&this._draggingRigidbodies.push(...n);const o=Jv();se.invokeOnChildren(this._dragHelper.selected,o("onDragStart"))}onUpdateDrag(){if(this._dragHelper){this._dragHelper.showGizmo=this.showGizmo,this._dragHelper.useViewAngle=this.useViewAngle,this._dragHelper.onUpdate(this.context);for(const i of this._draggingRigidbodies)i.wakeUp(),i.resetVelocities()}}onDragEnd(i){if(!this||!this._isDragging||(this._isDragging=!1,!this._dragHelper))return;for(const s of this._draggingRigidbodies)s.setVelocity(s.smoothedVelocity);this._draggingRigidbodies.length=0;const e=this._dragHelper.selected;if(this._dragHelper.setSelected(null,this.context),this.orbit&&(this.orbit.enabled=!0),i!=null&&i.object){const s=se.getComponentInChildren(i.object,Yc);s&&(s.fastMode=!1)}this._marker&&this._marker.destroy();for(const s of this.selectEndEventListener)s(this);const t=Jv();se.invokeOnChildren(e,t("onDragEnd"))}},h(u_,"_active",0),h(u_,"lastHovered"),u_);let Gp=ch;c3([x()],Gp.prototype,"showGizmo",2),c3([x()],Gp.prototype,"useViewAngle",2);const u3=class{constructor(i){h(this,"showGizmo",!0),h(this,"useViewAngle",!0),h(this,"_selected",null),h(this,"_context",null),h(this,"_camera"),h(this,"_cameraPlane",new eo),h(this,"_hasGroundPlane",!1),h(this,"_groundPlane",new eo),h(this,"_groundOffset",new w),h(this,"_groundOffsetFactor",0),h(this,"_groundDistance",0),h(this,"_groundPlanePoint",new w),h(this,"_raycaster",new Ld),h(this,"_cameraPlaneOffset",new w),h(this,"_intersection",new w),h(this,"_worldPosition",new w),h(this,"_inverseMatrix",new Be),h(this,"_rbs",[]),h(this,"_groundLine"),h(this,"_groundMarker"),h(this,"_groundOffsetVector",new w(0,1,0)),h(this,"_requireUpdateGroundPlane",!0),h(this,"_didDragOnGroundPlaneLastFrame",!1),this._camera=i;const e=new ss(u3.geometry),t=e.material;t.color=new _e(.4,.4,.4),e.layers.set(2),e.name="line",e.scale.y=1,this._groundLine=e;const s=new xo(.5,22,22),r=new li({color:t.color}),n=new ye(s,r);n.visible=!1,n.layers.set(2),this._groundMarker=n}get hasSelected(){return this._selected!==null&&this._selected!==void 0}get selected(){return this._selected}setSelected(i,e){if(this._selected&&e)for(const t of this._rbs)t.wakeUp(),t.setVelocity(0,0,0);if(this._selected&&qr.Remove(e,this._selected),this._selected=i,this._context=e,this._rbs.length=0,i?(e.scene.add(this._groundLine),e.scene.add(this._groundMarker)):(this._groundLine.removeFromParent(),this._groundMarker.removeFromParent()),this._selected){if(!e){console.error("DragHelper: no context");return}qr.Add(e,this._selected,null),this._groundOffsetFactor=0,this._hasGroundPlane=!0,this._groundOffset.set(0,0,0),this._requireUpdateGroundPlane=!0,this.onUpdateScreenSpacePlane()}}onUpdate(i){var e,t,s,r,n;if(!this._context)return;const o="Space",a="KeyD",l=((e=this._context)==null?void 0:e.input.isKeyPressed(o))||((t=this._context)==null?void 0:t.input.isKeyPressed(a)),c=this._context.input.getTouchesPressedCount()>=2||l;if(c){const d=this._context.input.getPointerPositionDelta(0);d&&(this._groundOffsetVector.set(0,1,0),(s=this._selected)==null||s.rotateOnWorldAxis(this._groundOffsetVector,d.x*this._context.time.deltaTime))}const u=this._context.input.getPointerPositionRC(0);if(u&&(this._raycaster.setFromCamera(u,this._camera),this._selected)){this._groundOffsetVector.set(0,1,0);const d=At(this._camera).clone().sub(At(this._selected)).normalize(),p=Math.abs(d.dot(this._groundOffsetVector)),f=((r=this._context)==null?void 0:r.input.isKeyPressed(o))||((n=this._context)==null?void 0:n.input.isKeyPressed(a));let m=!this.useViewAngle||p>.2;(c||f||this._context.input.getPointerPressedCount()>1)&&(m=!1);const A=this._didDragOnGroundPlaneLastFrame!==m;if(this._didDragOnGroundPlaneLastFrame=m,this._hasGroundPlane||(this._requireUpdateGroundPlane=!0),(this._requireUpdateGroundPlane||!m||A)&&this.onUpdateGroundPlane(),this._requireUpdateGroundPlane=!1,this._hasGroundPlane)if(this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection)){const v=this._intersection.y;if(this._groundPlanePoint.copy(this._intersection).sub(this._groundOffset),this._groundPlanePoint.y=v,m){this._groundOffsetVector.set(0,1,0);const g=this._intersection.sub(this._groundOffset).add(this._groundOffsetVector.multiplyScalar(this._groundOffsetFactor));this.onUpdateWorldPosition(g,this._groundPlanePoint,!1),this.onDidUpdate();return}}else this._groundPlanePoint.set(0,99999,0);A&&this.onUpdateScreenSpacePlane(),this._requireUpdateGroundPlane=!0,this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&(this.onUpdateWorldPosition(this._intersection.sub(this._cameraPlaneOffset),this._groundPlanePoint,!0),this.onDidUpdate())}}onUpdateWorldPosition(i,e,t){if(this._selected){if(t){const s=At(this._selected);s.y=i.y,i=s}if(ns(this._selected,i),ns(this._groundLine,i),this._hasGroundPlane?this._groundLine.scale.y=this._groundDistance:this._groundLine.scale.y=1e3,this._groundLine.visible=this.showGizmo,this._groundMarker.visible=e!==null&&this.showGizmo,e){const s=At(this._camera).distanceTo(e)*.01;this._groundMarker.scale.set(s,s,s),ns(this._groundMarker,e)}}}onUpdateScreenSpacePlane(){if(!this._selected||!this._context)return;const i=this._context.input.getPointerPositionRC(0);i&&(this._raycaster.setFromCamera(i,this._camera),this._cameraPlane.setFromNormalAndCoplanarPoint(this._camera.getWorldDirection(this._cameraPlane.normal),this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld)),this._raycaster.ray.intersectPlane(this._cameraPlane,this._intersection)&&this._selected.parent&&(this._inverseMatrix.copy(this._selected.parent.matrixWorld).invert(),this._cameraPlaneOffset.copy(this._intersection).sub(this._worldPosition.setFromMatrixPosition(this._selected.matrixWorld))))}onUpdateGroundPlane(){if(!this._selected||!this._context)return;const i=At(this._selected),e=new ha(new w(0,.1,0).add(i),new w(0,-1,0)),t=new ko;t.ignore=[this._selected];const s=this._context.physics.raycastFromRay(e,t);for(let r=0;r<s.length;r++){const n=s[r];if(!n.face||this.contains(this._selected,n.object))continue;const o=new w(0,1,0);this._groundPlane.setFromNormalAndCoplanarPoint(o,n.point);break}this._hasGroundPlane=!0,this._groundPlane.setFromNormalAndCoplanarPoint(e.direction.multiplyScalar(-1),e.origin),this._raycaster.ray.intersectPlane(this._groundPlane,this._intersection),this._groundDistance=this._intersection.distanceTo(i),this._groundOffset.copy(this._intersection).sub(i)}onDidUpdate(){_n.markDirty(this._selected);for(const i of this._rbs)i.wakeUp(),i.resetForcesAndTorques(),i.setAngularVelocity(0,0,0)}contains(i,e){if(i===e)return!0;if(i.children){for(const t of i.children)if(this.contains(t,e))return!0}return!1}};let d3=u3;h(d3,"geometry",new gt().setFromPoints([new w(0,0,0),new w(0,-1,0)]));function iT(i,e,t){console.warn("Adding components on object has been temporarily disabled")}var p3=(i=>(i.File_Spawned="file-spawned",i))(p3||{});class f3{constructor(e,t,s,r,n,o,a,l){h(this,"guid"),h(this,"file_name"),h(this,"file_hash"),h(this,"file_size"),h(this,"position"),h(this,"seed"),h(this,"sender"),h(this,"serverUrl"),h(this,"parentGuid"),h(this,"boundsSize"),this.seed=t,this.guid=s,this.file_name=r,this.file_hash=n,this.file_size=o,this.position=a,this.sender=e,this.serverUrl=l}}async function m3(i,e,t){const s=i.name;return s.endsWith(".gltf")||s.endsWith(".glb")?new Promise((r,n)=>{const o=new FileReader;o.readAsArrayBuffer(i),o.onloadend=async a=>{const l=o.result,c=ay(),u=new tn(c),d=await Lo().parseSync(e,l,i.name,u);if(d&&d.scene){const p=d.scene;if(!p.guid){const f=new tn(c);p.guid=f.generateUUID()}t&&cse(e.connection,i,c,p,t),iT(),r(d)}}}):(console.warn("Unsupported file type: "+s,i),null)}async function g3(i,e){return new Promise(async(t,s)=>{const r=ay(),n=new tn(r),o=i.toString(),a=await Lo().loadSync(e,o,o,n);a&&a.scene?(a.scene,iT(),t(a)):console.warn("Unsupported file type: "+i.toString())})}Ti.registerCallback(kr.ContextCreated,i=>{v3(i.context)});function v3(i){i.connection.beginListen("file-spawned",async e=>{if(e.sender!==i.connection.connectionId){console.log("received file event",e),hse(e,i);let t=null;try{t=await fC(e.file_name,e.file_hash,e.file_size,e.serverUrl)}finally{use(e)}if(t){const s=new tn(e.seed),r=await Lo().parseSync(i,t,e.file_name,s);if(r&&r.scene){const n=r.scene;if(iT(),e.parentGuid){const o=Im(e.parentGuid,i.scene);o&&"add"in o&&o.add(n)}n.parent||i.scene.add(n),e.position!==null&&n.position.copy(e.position)}}else console.error("download didnt return file")}})}async function cse(i,e,t,s,r){if(!i.connectionId){console.error("Can not upload file - no connection id");return}if(!s.guid){console.error("Can not upload file - no guid",s,s.guid);return}const n=await $O(e,r);if(!n)return;if(!n.filename){console.error("Can not send upload event - no filename",e.name);return}if(!n.hash){console.error("Can not send upload event - no hash",e.name);return}const o=new f3(i.connectionId,t,s.guid,n.filename,n.hash,e.size,s.position,n.url??r);s.parent&&(o.parentGuid=s.parent.guid),i.send("file-spawned",o)}const sT={};function hse(i,e){const t=new yi,s=new ye(t,new li({color:65280})),r=new P0(s,5592405);if(sT[i.guid]=r,e.scene.add(r),i.parentGuid){const n=Im(i.parentGuid,e.scene);n&&n.add(r)}i.position&&r.position.copy(i.position)}function use(i,e){const t=i.guid,s=sT[t];s&&(delete sT[t],s.removeFromParent())}var dse=Object.defineProperty,pse=Object.getOwnPropertyDescriptor,rT=(i,e,t,s)=>{for(var r=s>1?void 0:s?pse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&dse(e,t,r),r};const fse=le("debugnet"),nT=class extends Ie{constructor(){super(...arguments),h(this,"url",null),h(this,"urlParameterName",null),h(this,"localhost",null)}awake(){fse&&console.log(this),this.context.connection.registerProvider(this)}getWebsocketUrl(){let i=this.url?nT.GetUrl(this.url,this.localhost):null;if(this.urlParameterName){const t=le(this.urlParameterName);t&&typeof t=="string"&&(i=t)}if(!i)return null;const e=new RegExp("(((https?)|(?<socket_prefix>wss?))://)?(www.)?(?<url>.+)","gm").exec(i);return e!=null&&e.groups?e?.groups.socket_prefix?i:"wss://"+e?.groups.url:null}static GetUrl(i,e){let t=i;const s=nT.IsLocalNetwork()&&e;if(s&&(t=e),i!=null&&i.startsWith("/")){const r=s?t:window.location.origin;r!=null&&r.endsWith("/")&&i.startsWith("/")&&(i=i.substring(1)),t=r+i}return t}static IsLocalNetwork(i=window.location.hostname){return Br(i)}};let Tu=nT;rT([x()],Tu.prototype,"url",2),rT([x()],Tu.prototype,"urlParameterName",2),rT([x()],Tu.prototype,"localhost",2);var mse=Object.defineProperty,gse=Object.getOwnPropertyDescriptor,A3=(i,e,t,s)=>{for(var r=s>1?void 0:s?gse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&mse(e,t,r),r};const Hp=le("debugdroplistener");class Xg extends Ie{constructor(){super(...arguments),h(this,"filesBackendUrl"),h(this,"localhost"),h(this,"onDrag",e=>{e.preventDefault()}),h(this,"onDrop",async e=>{if(Hp&&console.log(e),!(e!=null&&e.dataTransfer))return;e.preventDefault();const t=e.dataTransfer.items;if(t)for(const s in t){const r=t[s];if(r.kind==="file"){const n=r.getAsFile();if(!n)continue;await this.addFiles(n)}else r.kind==="string"&&r.type=="text/plain"&&r.getAsString(async n=>{Hp&&console.log("dropped url",n);try{const o=new URL(n);if(!o)return;const a=await g3(o,this.context);a&&this.addObject(e,a)}catch{console.log("dropped string is not a valid URL!",n)}})}})}onEnable(){this.filesBackendUrl=Tu.GetUrl(this.filesBackendUrl,this.localhost)??this.filesBackendUrl,Hp&&console.log(this,this.filesBackendUrl),this.context.domElement.addEventListener("dragover",this.onDrag),this.context.domElement.addEventListener("drop",this.onDrop)}onDisable(){this.context.domElement.removeEventListener("dragover",this.onDrag),this.context.domElement.removeEventListener("drop",this.onDrop)}async addFiles(...e){if(Hp&&console.log("Add files",e),!!Array.isArray(e)&&e.length)for(const t of e){if(!t)continue;Hp&&console.log("Register file "+t.name+" to",this.filesBackendUrl,t);const s=await m3(t,this.context,this.filesBackendUrl);this.dispatchEvent(new CustomEvent("file-dropped",{detail:t})),s&&this.addObject(void 0,s)}}async addObject(e,t){if(Hp&&console.log("Dropped",t),!(t!=null&&t.scene)){console.warn("No object specified to add to scene",t);return}const s=t.scene;if(e!==void 0){const r=new ko;r.setMask(16777215),r.screenPointFromOffset(e.offsetX,e.offsetY);const n=this.context.physics.raycast(r);if(n&&n.length>0)for(const o of n){s.position.copy(o.point);break}}this.gameObject.add(s),this.dispatchEvent(new CustomEvent("object-added",{detail:t}))}}A3([x()],Xg.prototype,"filesBackendUrl",2),A3([x()],Xg.prototype,"localhost",2);var vse=Object.defineProperty,Ase=Object.getOwnPropertyDescriptor,d_=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ase(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&vse(e,t,r),r};class Iu extends pp{constructor(){super(...arguments),h(this,"parent",null),h(this,"object",null),h(this,"limitCount",10),h(this,"limitInterval",60),h(this,"_currentCount",0),h(this,"_startPosition",null),h(this,"_startQuaternion",null)}awake(){var e,t;if(this.object){if(this.object===this.gameObject){console.error("Can not duplicate self");return}this.object.visible=!1,this._startPosition=((e=this.object.position)==null?void 0:e.clone())??new w(0,0,0),this._startQuaternion=((t=this.object.quaternion)==null?void 0:t.clone())??new Ee(0,0,0,1)}const s=se.getComponentInParent(this.gameObject,Gp);s?s.addDragEventListener(h3.SelectStart,(r,n)=>{if(this._currentCount>=this.limitCount){n.attached=null;return}const o=this.handleDuplication(n.selected);o&&(console.assert(o!==n.selected,"Duplicated object is original"),n.attached=o)}):console.warn("Could no find drag controls in parent",this.name),bs.addEventListener(Fl.SelectStart,(r,n)=>{if(this._currentCount>=this.limitCount){n.grab=null;return}const o=this.handleDuplication(n.selected);o&&(n.grab=o)}),this.cloneLimitIntervalFn()}cloneLimitIntervalFn(){this.destroyed||(this._currentCount>0&&(this._currentCount-=1),setTimeout(()=>{this.cloneLimitIntervalFn()},this.limitInterval/this.limitCount*1e3))}handleDuplication(e){var t;if(this._currentCount>=this.limitCount||!this.object)return null;if(e===this.gameObject||this.handleMultiObject(e)){if(this.object===this.gameObject)return null;this.object.visible=!0,this._startPosition&&this.object.position.copy(this._startPosition),this._startQuaternion&&this.object.quaternion.copy(this._startQuaternion);const s=new ga;this.parent||(this.parent=this.gameObject.parent),this.parent&&(s.parent=this.parent.guid??((t=this.parent.userData)==null?void 0:t.guid),s.keepWorldPosition=!0),s.position=this.worldPosition,s.rotation=this.worldQuaternion,s.context=this.context,this._currentCount+=1;const r=se.instantiateSynced(this.object,s);return console.assert(r!==this.object,"Duplicated object is original"),this.object.visible=!1,this._startPosition&&this.object.position.clone().copy(this._startPosition),this._startQuaternion&&this.object.quaternion.clone().copy(this._startQuaternion),r}return null}handleMultiObject(e){return this.gameObject.type==="Group"||this.gameObject.type==="Object3D"?this.isInChildren(this.gameObject,e):!1}isInChildren(e,t){if(!e)return!1;if(e===t)return!0;if(e.children){for(const s of e.children)if(this.isInChildren(s,t))return!0}return!1}}d_([x(Re)],Iu.prototype,"parent",2),d_([x(Re)],Iu.prototype,"object",2),d_([x()],Iu.prototype,"limitCount",2),d_([x()],Iu.prototype,"limitInterval",2);var Vp=(i=>(i[i.PointerEnter=0]="PointerEnter",i[i.PointerExit=1]="PointerExit",i[i.PointerDown=2]="PointerDown",i[i.PointerUp=3]="PointerUp",i[i.PointerClick=4]="PointerClick",i[i.Drag=5]="Drag",i[i.Drop=6]="Drop",i[i.Scroll=7]="Scroll",i[i.UpdateSelected=8]="UpdateSelected",i[i.Select=9]="Select",i[i.Deselect=10]="Deselect",i[i.Move=11]="Move",i[i.InitializePotentialDrag=12]="InitializePotentialDrag",i[i.BeginDrag=13]="BeginDrag",i[i.EndDrag=14]="EndDrag",i[i.Submit=15]="Submit",i[i.Cancel=16]="Cancel",i))(Vp||{}),yse=Object.defineProperty,bse=Object.getOwnPropertyDescriptor,oT=(i,e,t,s)=>{for(var r=s>1?void 0:s?bse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&yse(e,t,r),r};class aT{constructor(){h(this,"eventID"),h(this,"callback")}}oT([x()],aT.prototype,"eventID",2),oT([x(ir)],aT.prototype,"callback",2);class p_ extends Ie{constructor(){super(...arguments),h(this,"triggers")}invoke(e){if(this.triggers)for(const t of this.triggers)t.eventID===e&&t.callback.invoke()}onPointerClick(e){this.invoke(Vp.PointerClick)}onPointerEnter(e){this.invoke(Vp.PointerEnter)}onPointerExit(e){this.invoke(Vp.PointerExit)}onPointerDown(e){this.invoke(Vp.PointerDown)}onPointerUp(e){this.invoke(Vp.PointerUp)}}oT([x(aT)],p_.prototype,"triggers",2);var _se=Object.defineProperty,xse=Object.getOwnPropertyDescriptor,lT=(i,e,t,s)=>{for(var r=s>1?void 0:s?xse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&_se(e,t,r),r};class cT extends Ie{constructor(){super(...arguments),h(this,"connectedBody"),h(this,"_rigidBody",null)}get rigidBody(){return this._rigidBody}onEnable(){this._rigidBody||(this._rigidBody=this.gameObject.getComponent(Vi)),this.rigidBody&&this.connectedBody&&this.startCoroutine(this.create())}*create(){yield,this.rigidBody&&this.connectedBody&&this.createJoint(this.rigidBody,this.connectedBody)}}lT([x(Vi)],cT.prototype,"connectedBody",2);class hT extends cT{createJoint(e,t){var s;(s=this.context.physics.engine)==null||s.addFixedJoint(e,t)}}class qg extends cT{constructor(){super(...arguments),h(this,"anchor"),h(this,"axis")}createJoint(e,t){var s;this.axis&&this.anchor&&((s=this.context.physics.engine)==null||s.addHingeJoint(e,t,this.anchor,this.axis))}}lT([x(w)],qg.prototype,"anchor",2),lT([x(w)],qg.prototype,"axis",2);const wse={type:"change"};let Sse=class extends Ms{constructor(i,e){super(),this.object=i,this.domElement=e,this.enabled=!0,this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1;const t=this,s=1e-6,r=new Ee,n=new w;this.tmpQuaternion=new Ee,this.status=0,this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this.moveVector=new w(0,0,0),this.rotationVector=new w(0,0,0),this.keydown=function(p){if(!(p.altKey||this.enabled===!1)){switch(p.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this.moveState.forward=1;break;case"KeyS":this.moveState.back=1;break;case"KeyA":this.moveState.left=1;break;case"KeyD":this.moveState.right=1;break;case"KeyR":this.moveState.up=1;break;case"KeyF":this.moveState.down=1;break;case"ArrowUp":this.moveState.pitchUp=1;break;case"ArrowDown":this.moveState.pitchDown=1;break;case"ArrowLeft":this.moveState.yawLeft=1;break;case"ArrowRight":this.moveState.yawRight=1;break;case"KeyQ":this.moveState.rollLeft=1;break;case"KeyE":this.moveState.rollRight=1;break}this.updateMovementVector(),this.updateRotationVector()}},this.keyup=function(p){if(this.enabled!==!1){switch(p.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this.moveState.forward=0;break;case"KeyS":this.moveState.back=0;break;case"KeyA":this.moveState.left=0;break;case"KeyD":this.moveState.right=0;break;case"KeyR":this.moveState.up=0;break;case"KeyF":this.moveState.down=0;break;case"ArrowUp":this.moveState.pitchUp=0;break;case"ArrowDown":this.moveState.pitchDown=0;break;case"ArrowLeft":this.moveState.yawLeft=0;break;case"ArrowRight":this.moveState.yawRight=0;break;case"KeyQ":this.moveState.rollLeft=0;break;case"KeyE":this.moveState.rollRight=0;break}this.updateMovementVector(),this.updateRotationVector()}},this.pointerdown=function(p){if(this.enabled!==!1)if(this.dragToLook)this.status++;else{switch(p.button){case 0:this.moveState.forward=1;break;case 2:this.moveState.back=1;break}this.updateMovementVector()}},this.pointermove=function(p){if(this.enabled!==!1&&(!this.dragToLook||this.status>0)){const f=this.getContainerDimensions(),m=f.size[0]/2,A=f.size[1]/2;this.moveState.yawLeft=-(p.pageX-f.offset[0]-m)/m,this.moveState.pitchDown=(p.pageY-f.offset[1]-A)/A,this.updateRotationVector()}},this.pointerup=function(p){if(this.enabled!==!1){if(this.dragToLook)this.status--,this.moveState.yawLeft=this.moveState.pitchDown=0;else{switch(p.button){case 0:this.moveState.forward=0;break;case 2:this.moveState.back=0;break}this.updateMovementVector()}this.updateRotationVector()}},this.contextMenu=function(p){this.enabled!==!1&&p.preventDefault()},this.update=function(p){if(this.enabled===!1)return;const f=p*t.movementSpeed,m=p*t.rollSpeed;t.object.translateX(t.moveVector.x*f),t.object.translateY(t.moveVector.y*f),t.object.translateZ(t.moveVector.z*f),t.tmpQuaternion.set(t.rotationVector.x*m,t.rotationVector.y*m,t.rotationVector.z*m,1).normalize(),t.object.quaternion.multiply(t.tmpQuaternion),(n.distanceToSquared(t.object.position)>s||8*(1-r.dot(t.object.quaternion))>s)&&(t.dispatchEvent(wse),r.copy(t.object.quaternion),n.copy(t.object.position))},this.updateMovementVector=function(){const p=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right,this.moveVector.y=-this.moveState.down+this.moveState.up,this.moveVector.z=-p+this.moveState.back},this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp,this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft,this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft},this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}},this.dispose=function(){this.domElement.removeEventListener("contextmenu",o),this.domElement.removeEventListener("pointerdown",l),this.domElement.removeEventListener("pointermove",a),this.domElement.removeEventListener("pointerup",c),window.removeEventListener("keydown",u),window.removeEventListener("keyup",d)};const o=this.contextMenu.bind(this),a=this.pointermove.bind(this),l=this.pointerdown.bind(this),c=this.pointerup.bind(this),u=this.keydown.bind(this),d=this.keyup.bind(this);this.domElement.addEventListener("contextmenu",o),this.domElement.addEventListener("pointerdown",l),this.domElement.addEventListener("pointermove",a),this.domElement.addEventListener("pointerup",c),window.addEventListener("keydown",u),window.addEventListener("keyup",d),this.updateMovementVector(),this.updateRotationVector()}};class uT extends Ie{constructor(){super(...arguments),h(this,"_controls",null)}onEnable(){var e;const t=(e=se.getComponent(this.gameObject,Ri))==null?void 0:e.cam;if(!t){console.warn("FlyControls: Requires a Camera component on the same object as this component.");return}this._controls=new Sse(t,this.context.renderer.domElement),this._controls.rollSpeed=.5,this._controls.movementSpeed=3,this._controls.dragToLook=!0}onDisable(){var e;(e=this._controls)==null||e.dispose(),this._controls=null}update(){this._controls&&this._controls.update(this.context.time.deltaTime)}}var Cse=Object.defineProperty,Ese=Object.getOwnPropertyDescriptor,dT=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ese(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Cse(e,t,r),r};class Wp extends Ie{constructor(){super(...arguments),h(this,"_fog")}get fog(){return this._fog||(this._fog=new hS(0,0,50)),this._fog}get mode(){return 1}set near(e){this.fog.near=e}get near(){return this.fog.near}set far(e){this.fog.far=e}get far(){return this.fog.far}set color(e){this.fog.color.copy(e)}get color(){return this.fog.color}onEnable(){this.scene.fog=this.fog}onDisable(){this.scene.fog===this._fog&&(this.scene.fog=null)}}dT([x()],Wp.prototype,"near",1),dT([x()],Wp.prototype,"far",1),dT([x(_e)],Wp.prototype,"color",1);let f_,pT,Xp,m_;function fT(i,e=1/0,t=null){pT||(pT=new fr(2,2,1,1)),Xp||(Xp=new Dt({uniforms:{blitTexture:new Ce(i)},vertexShader:`
5055
5073
  varying vec2 vUv;
5056
5074
  void main(){
5057
5075
  vUv = uv;
@@ -6591,4 +6609,4 @@ This could mean you forgot to add a npmdef to your ExportInfo
6591
6609
  <div class="content">
6592
6610
  <slot class="overlay-content"></slot>
6593
6611
  </div>
6594
- `,this.shadowRoot&&this.shadowRoot.appendChild(e.content.cloneNode(!0)),this._context=new zt({domElement:this}),this.addEventListener("error",this.onError)}static get observedAttributes(){return ole}get loadingProgress01(){return this._loadingProgress01}get loadingFinished(){return this.loadingProgress01>.999}get cameraControls(){const e=this.getAttribute("camera-controls");return!(e===null||e==="False"||e==="false"||e==="0")}getContext(){return new Promise((e,t)=>{if(this._context&&this.loadingFinished)e(this._context);else{const s=()=>{this.removeEventListener("loadfinished",s),this._context&&this.loadingFinished&&e(this._context)};this.addEventListener("loadfinished",s)}})}get context(){return this._context}get Context(){return this._context}async connectedCallback(){if(dr&&console.log("<needle-engine> connected"),this.onSetupDesktop(),!this.getAttribute("src")){const t=globalThis["needle:codegen_files"];t&&(dr&&console.log('globalThis["needle:codegen_files"]',t),this.setAttribute("src",t))}const e=this._loadId;setTimeout(()=>{this.isConnected!==!1&&e===this._loadId&&this.onLoad()},1),Tc!=null&&Tc.length&&this.setAttribute("version",Tc)}disconnectedCallback(){var e;this._didFullyLoad=!1;const t=this.getAttribute("keep-alive");dr&&console.warn("<needle-engine> disconnected, keep-alive:",t),(t===void 0||t!=="true")&&(console.warn("<needle-engine> dispose!"),(e=this._context)==null||e.dispose(),this._context=null,this._lastSourceFiles=null,this._loadId+=1)}attributeChangedCallback(e,t,s){switch(dr&&console.log("attributeChangedCallback",e,t,s),e){case"src":dr&&console.warn("src changed to type:",typeof s,', from "',t,'" to "',s,'"'),this.onLoad();break;case"hash":this._context&&(this._context.hash=s);break;case"loadstart":case"progress":case"loadfinished":typeof s=="string"&&s.length>0&&(dr&&console.log(e+" attribute changed",s),this.registerEventFromAttribute(e,s));break;case"dracoDecoderPath":dr&&console.log("dracoDecoderPath",s),VL(s);break;case"dracoDecoderType":s==="wasm"||s==="js"?(dr&&console.log("dracoDecoderType",s),WL(s)):console.error("Invalid dracoDecoderType",s,"expected js or wasm");break;case"ktx2DecoderPath":dr&&console.log("ktx2DecoderPath",s),XL(s);break}}async onLoad(){var e,t;if(!this.isConnected)return;if(this._context||(dr&&console.warn("Create new context"),this._context=new zt({domElement:this})),!this._context){console.error("Needle Engine: Context not initialized");return}const s=this.getSourceFiles();if(s==null||s.length<=0)dr&&console.warn("Clear scene",s),this._context.clear();else if(!this.checkIfSourceHasChanged(s,this._lastSourceFiles))return;this._lastSourceFiles=s;const r=++this._loadId,n=this.getAttribute("alias");this.classList.add("loading");const o=Jd();this.ensureLoadStartIsRegistered();let a=this.dispatchEvent(new CustomEvent("loadstart",{detail:{context:this._context,alias:n},cancelable:!0}));a===!1&&!o&&(gi()||(a=!0),console.warn("Needle Engine: You need a commercial license to override the default loading view. Visit https://needle.tools/pricing"),gi()&&Nr('You need a <a target="_blank" href="https://needle.tools/pricing">commercial license</a> to override the default loading view. This will not work in production.')),!this._loadingView&&a&&(this._loadingView=new LC(this)),a&&(this._didFullyLoad!==!0?(e=this._loadingView)==null||e.onLoadingBegin("begin load"):setTimeout(()=>{this._loadingView&&this._loadingProgress01<.3&&this._loadId===r&&this._loadingView.onLoadingBegin("begin load")},300)),dr&&console.warn("--------------",r,"Needle Engine: Begin loading",n??"",s),this.onBeforeBeginLoading();const l=[],c={context:this._context,name:"",progress:{},index:0,count:s.length,totalProgress01:this._loadingProgress01},u=new CustomEvent("progress",{detail:c}),d={files:s,onLoadingProgress:f=>{var m;f.name=ale(f.name),a&&((m=this._loadingView)==null||m.onLoadingUpdate(f)),c.name=f.name,c.progress=f.progress,this._loadingProgress01=DC(f),c.totalProgress01=this._loadingProgress01,this.dispatchEvent(u)},onLoadingFinished:(f,m,A)=>{A&&l.push({src:m,file:A})}},p=this.getAttribute("hash");p!=null&&(this._context.hash=p),this._context.alias=n,await this._context.create(d),this._loadId===r&&(dr&&console.warn("--------------",r,"Needle Engine: finished loading",n??"",s),this._loadingProgress01=1,a&&((t=this._loadingView)==null||t.onLoadingUpdate(1,"creating scene")),this._didFullyLoad=!0,this.classList.remove("loading"),this.classList.add("loading-finished"),this.dispatchEvent(new CustomEvent("loadfinished",{detail:{context:this._context,src:n,loadedFiles:l}})))}getSourceFiles(){const e=this.getAttribute("src");if(!e)return[];let t;Array.isArray(e)?t=e:e.startsWith("[")&&e.endsWith("]")?t=JSON.parse(e):e.includes(",")?t=e.split(","):t=[e];for(let s=t.length-1;s>=0;s--){const r=t[s];(r==="null"||r==="undefined"||r?.length<=0)&&t.splice(s,1)}return t}checkIfSourceHasChanged(e,t){if(e?.length!==t?.length||e==null&&t!==null||e!==null&&t==null)return!0;if(e!==null&&t!==null){for(let s=0;s<e?.length;s++)if(e[s]!==t[s])return!0}return!1}ensureLoadStartIsRegistered(){const e=this.getAttribute("loadstart");e&&this.registerEventFromAttribute("loadstart",e)}registerEventFromAttribute(e,t){const s=this._previouslyRegisteredMap.get(e);if(s&&(this._previouslyRegisteredMap.delete(e),this.removeEventListener(e,s)),typeof t=="string"&&t.length>0){const r=(0,eval)(t);typeof r=="function"&&(this._previouslyRegisteredMap.set(e,r),this.addEventListener(e,n=>r?.call(globalThis,this._context,n)))}}getAROverlayContainer(){return this._overlay_ar.createOverlayContainer(this)}getVROverlayContainer(){for(let e=0;e<this.children.length;e++){const t=this.children[e];if(t.classList.contains("vr"))return t}return null}onEnterAR(e,t){var s;this.onSetupAR(),this._overlay_ar.onBegin(this._context,t,e),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:e,context:this._context,htmlContainer:(s=this._overlay_ar)==null?void 0:s.ARContainer}}))}onExitAR(e){var t;this._overlay_ar.onEnd(this._context),this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-ar",{detail:{session:e,context:this._context,htmlContainer:(t=this._overlay_ar)==null?void 0:t.ARContainer}}))}onEnterVR(e){this.onSetupVR(),this.dispatchEvent(new CustomEvent("enter-vr",{detail:{session:e,context:this._context}}))}onExitVR(e){this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-vr",{detail:{session:e,context:this._context}}))}onSetupAR(){this.classList.add(Bv),this.classList.remove(kv);const e=this.getAROverlayContainer();dr&&console.warn("onSetupAR:",e),e&&(e.classList.add(Bv),e.classList.remove(kv)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,SL))}onSetupVR(){this.classList.remove(Bv),this.classList.remove(kv),this.foreachHtmlElement(e=>this.setupElementsForMode(e,Kz))}onSetupDesktop(){this.classList.remove(Bv),this.classList.add(kv);const e=this.getAROverlayContainer();e&&(e.classList.remove(Bv),e.classList.add(kv)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,Jz))}setupElementsForMode(e,t,s=null){var r;if(!(e===((r=this._context)==null?void 0:r.renderer.domElement)||e.id==="VRButton"||e.id==="ARButton"))if(e.classList.contains(t))e.style.visibility="visible",e.style.display==="none"&&(e.style.display="block");else for(const n of nle)e.classList.contains(n)&&(e.style.visibility="hidden",e.style.display="none")}foreachHtmlElement(e){for(let t=0;t<this.children.length;t++){const s=this.children[t];s.style&&e(s)}}onBeforeBeginLoading(){const e=this.getAttribute("dracoDecoderPath");e&&(dr&&console.log("using custom draco decoder path",e),VL(e));const t=this.getAttribute("dracoDecoderType");t&&(dr&&console.log("using custom draco decoder type",t),WL(t));const s=this.getAttribute("ktx2DecoderPath");s&&(dr&&console.log("using custom ktx2 decoder path",s),XL(s))}}typeof window<"u"&&!window.customElements.get(Yz)&&window.customElements.define(Yz,BI);function ale(i){const e=i.split("/");let t=e[e.length-1];const s=t.indexOf("?");return s>0&&(t=t.substring(0,s)),decodeURIComponent(t)}const lle=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:BI},Symbol.toStringTag,{value:"Module"})),nx=le("debughotreload");let Dv=!1;const Ov=new Map;function cle(){return Dv}function hle(i){var e;if(Dv)return;const t=i.constructor.name;Ov.has(t)?(e=Ov.get(t))==null||e.push(i):Ov.set(t,[i])}function ule(i){if(Dv)return;const e=i.constructor.name,t=Ov.get(e);if(!t)return;const s=t.indexOf(i);s!==-1&&t.splice(s,1)}let Zz=!1;function dle(){if(nx||Zz)return;Zz=!0;const i=console.error;console.error=(...e)=>{if(e.length){const t=e[0];if(typeof t=="string"&&t.includes("[hmr] Failed to reload ")){console.log("[Needle Engine] Hot reloading failed"),window.location.reload();return}}i.apply(console,e)}}function ple(i){nx&&console.log("[HMR] Apply changes",i,Object.keys(i)),dle();for(const e of Object.keys(i))try{Dv=!0;const t=Y.get(e);if(!t){nx&&console.log("[HMR] Type not found: "+e);continue}const s=i[e],r=Ov.get(s.name);let n="[Needle Engine] Updating type: "+e;const o=r?.length??-1;o>0?n+=" x"+o:n+=" - no instances",console.log(n);const a=Object.getOwnPropertyNames(t.prototype),l=Object.getOwnPropertyDescriptors(s.prototype);for(const c in l)l[c].writable&&(t.prototype[c]=i[e].prototype[c]);for(const c of a)l[c]||delete t.prototype[c];if(r){const c=new s,u=Object.getOwnPropertyDescriptors(c);for(const d of r){const p=d,f=p.isComponent===!0,m=f?p.activeAndEnabled:!0,A=f?p.context:void 0;try{if(f&&bl(p,A),f&&m&&(p.enabled=!1),d.onBeforeHotReloadFields&&d.onBeforeHotReloadFields()===!1)continue;for(const v in u)if(u[v].writable){if(d[v]===void 0)d[v]=c[v];else if(typeof d[v]=="function"&&!d[v].prototype){const g=d[v],b=g.name,y="bound ";if(b===y)continue;const _=g.name.substring(y.length),S=s.prototype[_];S&&(d[v]=S.bind(d))}}d.onAfterHotReloadFields&&d.onAfterHotReloadFields()}finally{f&&Z1(p,A),f&&m&&(p.enabled=!0)}}}}catch(t){if(nx)console.error(t);else return!1}finally{Dv=!1,Za(Co.Log,"Script changes applied (HMR)")}return!0}const fle=Symbol("object"),$z=new ra(()=>new w,20);class ej{constructor(e,t,s,r,n){h(this,"_point"),h(this,"_normal"),h(this,"distance"),h(this,"impulse"),h(this,"friction"),this._point=e,this.distance=t,this._normal=s,this.impulse=r,this.friction=n}get point(){return $z.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return $z.get().set(this._normal.x,this._normal.y,this._normal.z)}}class tj{constructor(e,t,s){h(this,"contacts"),h(this,"me"),h(this,"_collider"),h(this,"_gameObject"),this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=s}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class ij{constructor(e,t){h(this,"object"),h(this,"collider"),this.object=e,this.collider=t}}let ze;const Lv=new Array(32).fill(void 0);Lv.push(void 0,null,!0,!1);let sj;Lv.length;function rj(){return sj.byteLength,sj}const mle=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function mt(i,e){if(!(i instanceof e))throw new Error(`expected instance of ${e.name}`);return i.ptr}mle.decode();let nj,oj,Uv=32;function aj(i){if(Uv==1)throw new Error("out of js stack");return Lv[--Uv]=i,Uv}function gle(){return nj.byteLength,nj}function vle(){return oj.byteLength,oj}let qn=0;function Hu(i,e){const t=e(4*i.length);return gle().set(i,t/4),qn=i.length,t}function ox(i,e){const t=e(4*i.length);return vle().set(i,t/4),qn=i.length,t}class Ix{static __wrap(e){const t=Object.create(Ix.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_raweventqueue_free(e)}constructor(e){const t=ze.raweventqueue_new(e);return Ix.__wrap(t)}drainCollisionEvents(e){try{ze.raweventqueue_drainCollisionEvents(this.ptr,aj(e))}finally{Lv[Uv++]=void 0}}drainContactForceEvents(e){try{ze.raweventqueue_drainContactForceEvents(this.ptr,aj(e))}finally{Lv[Uv++]=void 0}}clear(){ze.raweventqueue_clear(this.ptr)}}class Xa{static __wrap(e){const t=Object.create(Xa.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawgenericjoint_free(e)}static spherical(e,t){mt(e,ut),mt(t,ut);const s=ze.rawgenericjoint_spherical(e.ptr,t.ptr);return Xa.__wrap(s)}static prismatic(e,t,s,r,n,o){mt(e,ut),mt(t,ut),mt(s,ut);const a=ze.rawgenericjoint_prismatic(e.ptr,t.ptr,s.ptr,r,n,o);return a===0?void 0:Xa.__wrap(a)}static fixed(e,t,s,r){mt(e,ut),mt(t,Ws),mt(s,ut),mt(r,Ws);const n=ze.rawgenericjoint_fixed(e.ptr,t.ptr,s.ptr,r.ptr);return Xa.__wrap(n)}static revolute(e,t,s){mt(e,ut),mt(t,ut),mt(s,ut);const r=ze.rawgenericjoint_revolute(e.ptr,t.ptr,s.ptr);return r===0?void 0:Xa.__wrap(r)}}class WI{static __wrap(e){const t=Object.create(WI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawpointprojection_free(e)}point(){const e=ze.rawpointprojection_point(this.ptr);return ut.__wrap(e)}isInside(){return ze.rawpointprojection_isInside(this.ptr)!==0}}class XI{static __wrap(e){const t=Object.create(XI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawrayintersection_free(e)}normal(){const e=ze.rawrayintersection_normal(this.ptr);return ut.__wrap(e)}toi(){return ze.rawintegrationparameters_dt(this.ptr)}featureType(){return ze.rawrayintersection_featureType(this.ptr)>>>0}featureId(){try{const s=ze.__wbindgen_add_to_stack_pointer(-16);ze.rawrayintersection_featureId(s,this.ptr);var e=rj()[s/4+0],t=rj()[s/4+1];return e===0?void 0:t>>>0}finally{ze.__wbindgen_add_to_stack_pointer(16)}}}class Ws{static __wrap(e){const t=Object.create(Ws.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawrotation_free(e)}constructor(e,t,s,r){const n=ze.rawrotation_new(e,t,s,r);return Ws.__wrap(n)}static identity(){const e=ze.rawrotation_identity();return Ws.__wrap(e)}get x(){return ze.rawintegrationparameters_dt(this.ptr)}get y(){return ze.rawrotation_y(this.ptr)}get z(){return ze.rawintegrationparameters_erp(this.ptr)}get w(){return ze.rawrotation_w(this.ptr)}}class Qt{static __wrap(e){const t=Object.create(Qt.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawshape_free(e)}static cuboid(e,t,s){const r=ze.rawshape_cuboid(e,t,s);return Qt.__wrap(r)}static roundCuboid(e,t,s,r){const n=ze.rawshape_roundCuboid(e,t,s,r);return Qt.__wrap(n)}static ball(e){const t=ze.rawshape_ball(e);return Qt.__wrap(t)}static capsule(e,t){const s=ze.rawshape_capsule(e,t);return Qt.__wrap(s)}static cylinder(e,t){const s=ze.rawshape_cylinder(e,t);return Qt.__wrap(s)}static roundCylinder(e,t,s){const r=ze.rawshape_roundCylinder(e,t,s);return Qt.__wrap(r)}static cone(e,t){const s=ze.rawshape_cone(e,t);return Qt.__wrap(s)}static roundCone(e,t,s){const r=ze.rawshape_roundCone(e,t,s);return Qt.__wrap(r)}static polyline(e,t){const s=Hu(e,ze.__wbindgen_malloc),r=qn,n=ox(t,ze.__wbindgen_malloc),o=qn,a=ze.rawshape_polyline(s,r,n,o);return Qt.__wrap(a)}static trimesh(e,t){const s=Hu(e,ze.__wbindgen_malloc),r=qn,n=ox(t,ze.__wbindgen_malloc),o=qn,a=ze.rawshape_trimesh(s,r,n,o);return Qt.__wrap(a)}static heightfield(e,t,s,r){const n=Hu(s,ze.__wbindgen_malloc),o=qn;mt(r,ut);const a=ze.rawshape_heightfield(e,t,n,o,r.ptr);return Qt.__wrap(a)}static segment(e,t){mt(e,ut),mt(t,ut);const s=ze.rawshape_segment(e.ptr,t.ptr);return Qt.__wrap(s)}static triangle(e,t,s){mt(e,ut),mt(t,ut),mt(s,ut);const r=ze.rawshape_triangle(e.ptr,t.ptr,s.ptr);return Qt.__wrap(r)}static roundTriangle(e,t,s,r){mt(e,ut),mt(t,ut),mt(s,ut);const n=ze.rawshape_roundTriangle(e.ptr,t.ptr,s.ptr,r);return Qt.__wrap(n)}static convexHull(e){const t=Hu(e,ze.__wbindgen_malloc),s=qn,r=ze.rawshape_convexHull(t,s);return r===0?void 0:Qt.__wrap(r)}static roundConvexHull(e,t){const s=Hu(e,ze.__wbindgen_malloc),r=qn,n=ze.rawshape_roundConvexHull(s,r,t);return n===0?void 0:Qt.__wrap(n)}static convexMesh(e,t){const s=Hu(e,ze.__wbindgen_malloc),r=qn,n=ox(t,ze.__wbindgen_malloc),o=qn,a=ze.rawshape_convexMesh(s,r,n,o);return a===0?void 0:Qt.__wrap(a)}static roundConvexMesh(e,t,s){const r=Hu(e,ze.__wbindgen_malloc),n=qn,o=ox(t,ze.__wbindgen_malloc),a=qn,l=ze.rawshape_roundConvexMesh(r,n,o,a,s);return l===0?void 0:Qt.__wrap(l)}castShape(e,t,s,r,n,o,a,l){mt(e,ut),mt(t,Ws),mt(s,ut),mt(r,Qt),mt(n,ut),mt(o,Ws),mt(a,ut);const c=ze.rawshape_castShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr,o.ptr,a.ptr,l);return c===0?void 0:YI.__wrap(c)}intersectsShape(e,t,s,r,n){return mt(e,ut),mt(t,Ws),mt(s,Qt),mt(r,ut),mt(n,Ws),ze.rawshape_intersectsShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr)!==0}contactShape(e,t,s,r,n,o){mt(e,ut),mt(t,Ws),mt(s,Qt),mt(r,ut),mt(n,Ws);const a=ze.rawshape_contactShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr,o);return a===0?void 0:qI.__wrap(a)}containsPoint(e,t,s){return mt(e,ut),mt(t,Ws),mt(s,ut),ze.rawshape_containsPoint(this.ptr,e.ptr,t.ptr,s.ptr)!==0}projectPoint(e,t,s,r){mt(e,ut),mt(t,Ws),mt(s,ut);const n=ze.rawshape_projectPoint(this.ptr,e.ptr,t.ptr,s.ptr,r);return WI.__wrap(n)}intersectsRay(e,t,s,r,n){return mt(e,ut),mt(t,Ws),mt(s,ut),mt(r,ut),ze.rawshape_intersectsRay(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n)!==0}castRay(e,t,s,r,n,o){return mt(e,ut),mt(t,Ws),mt(s,ut),mt(r,ut),ze.rawshape_castRay(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n,o)}castRayAndGetNormal(e,t,s,r,n,o){mt(e,ut),mt(t,Ws),mt(s,ut),mt(r,ut);const a=ze.rawshape_castRayAndGetNormal(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n,o);return a===0?void 0:XI.__wrap(a)}}class qI{static __wrap(e){const t=Object.create(qI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawshapecontact_free(e)}distance(){return ze.rawshapecontact_distance(this.ptr)}point1(){const e=ze.rawpointprojection_point(this.ptr);return ut.__wrap(e)}point2(){const e=ze.rawshapecontact_point2(this.ptr);return ut.__wrap(e)}normal1(){const e=ze.rawshapecontact_normal1(this.ptr);return ut.__wrap(e)}normal2(){const e=ze.rawshapecontact_normal2(this.ptr);return ut.__wrap(e)}}class YI{static __wrap(e){const t=Object.create(YI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawshapetoi_free(e)}toi(){return ze.rawintegrationparameters_dt(this.ptr)}witness1(){const e=ze.rawrayintersection_normal(this.ptr);return ut.__wrap(e)}witness2(){const e=ze.rawshapetoi_witness2(this.ptr);return ut.__wrap(e)}normal1(){const e=ze.rawshapetoi_normal1(this.ptr);return ut.__wrap(e)}normal2(){const e=ze.rawshapetoi_normal2(this.ptr);return ut.__wrap(e)}}class ut{static __wrap(e){const t=Object.create(ut.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawvector_free(e)}static zero(){const e=ze.rawvector_zero();return ut.__wrap(e)}constructor(e,t,s){const r=ze.rawvector_new(e,t,s);return ut.__wrap(r)}get x(){return ze.rawintegrationparameters_dt(this.ptr)}set x(e){ze.rawintegrationparameters_set_dt(this.ptr,e)}get y(){return ze.rawrotation_y(this.ptr)}set y(e){ze.rawvector_set_y(this.ptr,e)}get z(){return ze.rawintegrationparameters_erp(this.ptr)}set z(e){ze.rawintegrationparameters_set_erp(this.ptr,e)}xyz(){const e=ze.rawvector_xyz(this.ptr);return ut.__wrap(e)}yxz(){const e=ze.rawvector_yxz(this.ptr);return ut.__wrap(e)}zxy(){const e=ze.rawvector_zxy(this.ptr);return ut.__wrap(e)}xzy(){const e=ze.rawvector_xzy(this.ptr);return ut.__wrap(e)}yzx(){const e=ze.rawvector_yzx(this.ptr);return ut.__wrap(e)}zyx(){const e=ze.rawvector_zyx(this.ptr);return ut.__wrap(e)}}class Ale{constructor(e,t,s){this.x=e,this.y=t,this.z=s}}class ke{static new(e,t,s){return new Ale(e,t,s)}static intoRaw(e){return new ut(e.x,e.y,e.z)}static zeros(){return ke.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=ke.new(e.x,e.y,e.z);return e.free(),t}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z}}class lj{constructor(e,t,s,r){this.x=e,this.y=t,this.z=s,this.w=r}}class Bi{static identity(){return new lj(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new lj(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new Ws(e.x,e.y,e.z,e.w)}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w}}var Fv,Qa,cj,Ao,kI,ri,ax,af,DI,OI,hj,uj;(function(i){i[i.Dynamic=0]="Dynamic",i[i.Fixed=1]="Fixed",i[i.KinematicPositionBased=2]="KinematicPositionBased",i[i.KinematicVelocityBased=3]="KinematicVelocityBased"})(Fv||(Fv={}));class yle{constructor(e,t,s){this.rawSet=e,this.colliderSet=t,this.handle=s}finalizeDeserialization(e){this.colliderSet=e}isValid(){return this.rawSet.contains(this.handle)}lockTranslations(e,t){return this.rawSet.rbLockTranslations(this.handle,e,t)}lockRotations(e,t){return this.rawSet.rbLockRotations(this.handle,e,t)}setEnabledTranslations(e,t,s,r){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,s,r)}restrictTranslations(e,t,s,r){this.setEnabledTranslations(e,t,s,r)}setEnabledRotations(e,t,s,r){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,s,r)}restrictRotations(e,t,s,r){this.setEnabledRotations(e,t,s,r)}dominanceGroup(){return this.rawSet.rbDominanceGroup(this.handle)}setDominanceGroup(e){this.rawSet.rbSetDominanceGroup(this.handle,e)}enableCcd(e){this.rawSet.rbEnableCcd(this.handle,e)}translation(){let e=this.rawSet.rbTranslation(this.handle);return ke.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Bi.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return ke.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Bi.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let s=ke.intoRaw(e);this.rawSet.rbSetLinvel(this.handle,s,t),s.free()}gravityScale(){return this.rawSet.rbGravityScale(this.handle)}setGravityScale(e,t){this.rawSet.rbSetGravityScale(this.handle,e,t)}setRotation(e,t){this.rawSet.rbSetRotation(this.handle,e.x,e.y,e.z,e.w,t)}setAngvel(e,t){let s=ke.intoRaw(e);this.rawSet.rbSetAngvel(this.handle,s,t),s.free()}setNextKinematicTranslation(e){this.rawSet.rbSetNextKinematicTranslation(this.handle,e.x,e.y,e.z)}setNextKinematicRotation(e){this.rawSet.rbSetNextKinematicRotation(this.handle,e.x,e.y,e.z,e.w)}linvel(){return ke.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return ke.fromRaw(this.rawSet.rbAngvel(this.handle))}mass(){return this.rawSet.rbMass(this.handle)}sleep(){this.rawSet.rbSleep(this.handle)}wakeUp(){this.rawSet.rbWakeUp(this.handle)}isCcdEnabled(){this.rawSet.rbIsCcdEnabled(this.handle)}numColliders(){return this.rawSet.rbNumColliders(this.handle)}collider(e){return this.colliderSet.get(this.rawSet.rbCollider(this.handle,e))}bodyType(){return this.rawSet.rbBodyType(this.handle)}setBodyType(e){return this.rawSet.rbSetBodyType(this.handle,e)}isSleeping(){return this.rawSet.rbIsSleeping(this.handle)}isMoving(){return this.rawSet.rbIsMoving(this.handle)}isFixed(){return this.rawSet.rbIsFixed(this.handle)}isKinematic(){return this.rawSet.rbIsKinematic(this.handle)}isDynamic(){return this.rawSet.rbIsDynamic(this.handle)}linearDamping(){return this.rawSet.rbLinearDamping(this.handle)}angularDamping(){return this.rawSet.rbAngularDamping(this.handle)}setLinearDamping(e){this.rawSet.rbSetLinearDamping(this.handle,e)}recomputeMassPropertiesFromColliders(){this.rawSet.rbRecomputeMassPropertiesFromColliders(this.handle,this.colliderSet.raw)}setAdditionalMass(e,t){this.rawSet.rbSetAdditionalMass(this.handle,e,t)}setAdditionalMassProperties(e,t,s,r,n){let o=ke.intoRaw(t),a=ke.intoRaw(s),l=Bi.intoRaw(r);this.rawSet.rbSetAdditionalMassProperties(this.handle,e,o,a,l,n),o.free(),a.free(),l.free()}setAngularDamping(e){this.rawSet.rbSetAngularDamping(this.handle,e)}resetForces(e){this.rawSet.rbResetForces(this.handle,e)}resetTorques(e){this.rawSet.rbResetTorques(this.handle,e)}addForce(e,t){const s=ke.intoRaw(e);this.rawSet.rbAddForce(this.handle,s,t),s.free()}applyImpulse(e,t){const s=ke.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,s,t),s.free()}addTorque(e,t){const s=ke.intoRaw(e);this.rawSet.rbAddTorque(this.handle,s,t),s.free()}applyTorqueImpulse(e,t){const s=ke.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,s,t),s.free()}addForceAtPoint(e,t,s){const r=ke.intoRaw(e),n=ke.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,r,n,s),r.free(),n.free()}applyImpulseAtPoint(e,t,s){const r=ke.intoRaw(e),n=ke.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,r,n,s),r.free(),n.free()}}(function(i){i[i.Revolute=0]="Revolute",i[i.Fixed=1]="Fixed",i[i.Prismatic=2]="Prismatic",i[i.Spherical=3]="Spherical"})(Qa||(Qa={})),function(i){i[i.AccelerationBased=0]="AccelerationBased",i[i.ForceBased=1]="ForceBased"}(cj||(cj={}));class mf{constructor(){}static fixed(e,t,s,r){let n=new mf;return n.anchor1=e,n.anchor2=s,n.frame1=t,n.frame2=r,n.jointType=Qa.Fixed,n}static spherical(e,t){let s=new mf;return s.anchor1=e,s.anchor2=t,s.jointType=Qa.Spherical,s}static prismatic(e,t,s){let r=new mf;return r.anchor1=e,r.anchor2=t,r.axis=s,r.jointType=Qa.Prismatic,r}static revolute(e,t,s){let r=new mf;return r.anchor1=e,r.anchor2=t,r.axis=s,r.jointType=Qa.Revolute,r}intoRaw(){let e,t,s=ke.intoRaw(this.anchor1),r=ke.intoRaw(this.anchor2),n=!1,o=0,a=0;switch(this.jointType){case Qa.Fixed:let l=Bi.intoRaw(this.frame1),c=Bi.intoRaw(this.frame2);t=Xa.fixed(s,l,r,c),l.free(),c.free();break;case Qa.Prismatic:e=ke.intoRaw(this.axis),this.limitsEnabled&&(n=!0,o=this.limits[0],a=this.limits[1]),t=Xa.prismatic(s,r,e,n,o,a),e.free();break;case Qa.Spherical:t=Xa.spherical(s,r);break;case Qa.Revolute:e=ke.intoRaw(this.axis),t=Xa.revolute(s,r,e),e.free()}return s.free(),r.free(),t}}(function(i){i[i.Average=0]="Average",i[i.Min=1]="Min",i[i.Multiply=2]="Multiply",i[i.Max=3]="Max"})(Ao||(Ao={}));class Vv{constructor(e,t,s,r,n){this.distance=e,this.point1=t,this.point2=s,this.normal1=r,this.normal2=n}static fromRaw(e){if(!e)return null;const t=new Vv(e.distance(),ke.fromRaw(e.point1()),ke.fromRaw(e.point2()),ke.fromRaw(e.normal1()),ke.fromRaw(e.normal2()));return e.free(),t}}(function(i){i[i.Vertex=0]="Vertex",i[i.Edge=1]="Edge",i[i.Face=2]="Face",i[i.Unknown=3]="Unknown"})(kI||(kI={}));class Rx{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new Rx(ke.fromRaw(e.point()),e.isInside());return e.free(),t}}class ble{constructor(e,t){this.origin=e,this.dir=t}pointAt(e){return{x:this.origin.x+this.dir.x*e,y:this.origin.y+this.dir.y*e,z:this.origin.z+this.dir.z*e}}}class Px{constructor(e,t,s,r){this.featureType=kI.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,r!==void 0&&(this.featureId=r),s!==void 0&&(this.featureType=s)}static fromRaw(e){if(!e)return null;const t=new Px(e.toi(),ke.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class Wv{constructor(e,t,s,r,n){this.toi=e,this.witness1=t,this.witness2=s,this.normal1=r,this.normal2=n}static fromRaw(e,t){if(!t)return null;const s=new Wv(t.toi(),ke.fromRaw(t.witness1()),ke.fromRaw(t.witness2()),ke.fromRaw(t.normal1()),ke.fromRaw(t.normal2()));return t.free(),s}}class KI extends Wv{constructor(e,t,s,r,n,o){super(t,s,r,n,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const s=new KI(e.get(t.colliderHandle()),t.toi(),ke.fromRaw(t.witness1()),ke.fromRaw(t.witness2()),ke.fromRaw(t.normal1()),ke.fromRaw(t.normal2()));return t.free(),s}}class pr{static fromRaw(e,t){const s=e.coShapeType(t);let r,n,o,a,l,c;switch(s){case ri.Ball:return new LI(e.coRadius(t));case ri.Cuboid:return r=e.coHalfExtents(t),new dj(r.x,r.y,r.z);case ri.RoundCuboid:return r=e.coHalfExtents(t),n=e.coRoundRadius(t),new pj(r.x,r.y,r.z,n);case ri.Capsule:return l=e.coHalfHeight(t),c=e.coRadius(t),new fj(l,c);case ri.Segment:return o=e.coVertices(t),new mj(ke.new(o[0],o[1],o[2]),ke.new(o[3],o[4],o[5]));case ri.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new Aj(o,a);case ri.Triangle:return o=e.coVertices(t),new gj(ke.new(o[0],o[1],o[2]),ke.new(o[3],o[4],o[5]),ke.new(o[6],o[7],o[8]));case ri.RoundTriangle:return o=e.coVertices(t),n=e.coRoundRadius(t),new vj(ke.new(o[0],o[1],o[2]),ke.new(o[3],o[4],o[5]),ke.new(o[6],o[7],o[8]),n);case ri.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new yj(o,a);case ri.HeightField:const u=e.coHeightfieldScale(t),d=e.coHeightfieldHeights(t),p=e.coHeightfieldNRows(t),f=e.coHeightfieldNCols(t);return new bj(p,f,d,u);case ri.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new UI(o,a);case ri.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),n=e.coRoundRadius(t),new FI(o,a,n);case ri.Cylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),new _j(l,c);case ri.RoundCylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),n=e.coRoundRadius(t),new xj(l,c,n);case ri.Cone:return l=e.coHalfHeight(t),c=e.coRadius(t),new wj(l,c);case ri.RoundCone:return l=e.coHalfHeight(t),c=e.coRadius(t),n=e.coRoundRadius(t),new Sj(l,c,n);default:throw new Error("unknown shape type: "+s)}}castShape(e,t,s,r,n,o,a,l){let c=ke.intoRaw(e),u=Bi.intoRaw(t),d=ke.intoRaw(s),p=ke.intoRaw(n),f=Bi.intoRaw(o),m=ke.intoRaw(a),A=this.intoRaw(),v=r.intoRaw(),g=Wv.fromRaw(null,A.castShape(c,u,d,v,p,f,m,l));return c.free(),u.free(),d.free(),p.free(),f.free(),m.free(),A.free(),v.free(),g}intersectsShape(e,t,s,r,n){let o=ke.intoRaw(e),a=Bi.intoRaw(t),l=ke.intoRaw(r),c=Bi.intoRaw(n),u=this.intoRaw(),d=s.intoRaw(),p=u.intersectsShape(o,a,d,l,c);return o.free(),a.free(),l.free(),c.free(),u.free(),d.free(),p}contactShape(e,t,s,r,n,o){let a=ke.intoRaw(e),l=Bi.intoRaw(t),c=ke.intoRaw(r),u=Bi.intoRaw(n),d=this.intoRaw(),p=s.intoRaw(),f=Vv.fromRaw(d.contactShape(a,l,p,c,u,o));return a.free(),l.free(),c.free(),u.free(),d.free(),p.free(),f}containsPoint(e,t,s){let r=ke.intoRaw(e),n=Bi.intoRaw(t),o=ke.intoRaw(s),a=this.intoRaw(),l=a.containsPoint(r,n,o);return r.free(),n.free(),o.free(),a.free(),l}projectPoint(e,t,s,r){let n=ke.intoRaw(e),o=Bi.intoRaw(t),a=ke.intoRaw(s),l=this.intoRaw(),c=Rx.fromRaw(l.projectPoint(n,o,a,r));return n.free(),o.free(),a.free(),l.free(),c}intersectsRay(e,t,s,r){let n=ke.intoRaw(t),o=Bi.intoRaw(s),a=ke.intoRaw(e.origin),l=ke.intoRaw(e.dir),c=this.intoRaw(),u=c.intersectsRay(n,o,a,l,r);return n.free(),o.free(),a.free(),l.free(),c.free(),u}castRay(e,t,s,r,n){let o=ke.intoRaw(t),a=Bi.intoRaw(s),l=ke.intoRaw(e.origin),c=ke.intoRaw(e.dir),u=this.intoRaw(),d=u.castRay(o,a,l,c,r,n);return o.free(),a.free(),l.free(),c.free(),u.free(),d}castRayAndGetNormal(e,t,s,r,n){let o=ke.intoRaw(t),a=Bi.intoRaw(s),l=ke.intoRaw(e.origin),c=ke.intoRaw(e.dir),u=this.intoRaw(),d=Px.fromRaw(u.castRayAndGetNormal(o,a,l,c,r,n));return o.free(),a.free(),l.free(),c.free(),u.free(),d}}(function(i){i[i.Ball=0]="Ball",i[i.Cuboid=1]="Cuboid",i[i.Capsule=2]="Capsule",i[i.Segment=3]="Segment",i[i.Polyline=4]="Polyline",i[i.Triangle=5]="Triangle",i[i.TriMesh=6]="TriMesh",i[i.HeightField=7]="HeightField",i[i.ConvexPolyhedron=9]="ConvexPolyhedron",i[i.Cylinder=10]="Cylinder",i[i.Cone=11]="Cone",i[i.RoundCuboid=12]="RoundCuboid",i[i.RoundTriangle=13]="RoundTriangle",i[i.RoundCylinder=14]="RoundCylinder",i[i.RoundCone=15]="RoundCone",i[i.RoundConvexPolyhedron=16]="RoundConvexPolyhedron"})(ri||(ri={}));class LI extends pr{constructor(e){super(),this.type=ri.Ball,this.radius=e}intoRaw(){return Qt.ball(this.radius)}}class dj extends pr{constructor(e,t,s){super(),this.type=ri.Cuboid,this.halfExtents=ke.new(e,t,s)}intoRaw(){return Qt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class pj extends pr{constructor(e,t,s,r){super(),this.type=ri.RoundCuboid,this.halfExtents=ke.new(e,t,s),this.borderRadius=r}intoRaw(){return Qt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class fj extends pr{constructor(e,t){super(),this.type=ri.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.capsule(this.halfHeight,this.radius)}}class mj extends pr{constructor(e,t){super(),this.type=ri.Segment,this.a=e,this.b=t}intoRaw(){let e=ke.intoRaw(this.a),t=ke.intoRaw(this.b),s=Qt.segment(e,t);return e.free(),t.free(),s}}class gj extends pr{constructor(e,t,s){super(),this.type=ri.Triangle,this.a=e,this.b=t,this.c=s}intoRaw(){let e=ke.intoRaw(this.a),t=ke.intoRaw(this.b),s=ke.intoRaw(this.c),r=Qt.triangle(e,t,s);return e.free(),t.free(),s.free(),r}}class vj extends pr{constructor(e,t,s,r){super(),this.type=ri.RoundTriangle,this.a=e,this.b=t,this.c=s,this.borderRadius=r}intoRaw(){let e=ke.intoRaw(this.a),t=ke.intoRaw(this.b),s=ke.intoRaw(this.c),r=Qt.roundTriangle(e,t,s,this.borderRadius);return e.free(),t.free(),s.free(),r}}class Aj extends pr{constructor(e,t){super(),this.type=ri.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return Qt.polyline(this.vertices,this.indices)}}class yj extends pr{constructor(e,t){super(),this.type=ri.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return Qt.trimesh(this.vertices,this.indices)}}class UI extends pr{constructor(e,t){super(),this.type=ri.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?Qt.convexMesh(this.vertices,this.indices):Qt.convexHull(this.vertices)}}class FI extends pr{constructor(e,t,s){super(),this.type=ri.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=s}intoRaw(){return this.indices?Qt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):Qt.roundConvexHull(this.vertices,this.borderRadius)}}class bj extends pr{constructor(e,t,s,r){super(),this.type=ri.HeightField,this.nrows=e,this.ncols=t,this.heights=s,this.scale=r}intoRaw(){let e=ke.intoRaw(this.scale),t=Qt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class _j extends pr{constructor(e,t){super(),this.type=ri.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.cylinder(this.halfHeight,this.radius)}}class xj extends pr{constructor(e,t,s){super(),this.type=ri.RoundCylinder,this.borderRadius=s,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class wj extends pr{constructor(e,t){super(),this.type=ri.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.cone(this.halfHeight,this.radius)}}class Sj extends pr{constructor(e,t,s){super(),this.type=ri.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=s}intoRaw(){return Qt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(i){i[i.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",i[i.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",i[i.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",i[i.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",i[i.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",i[i.FIXED_FIXED=32]="FIXED_FIXED",i[i.DEFAULT=15]="DEFAULT",i[i.ALL=60943]="ALL"})(ax||(ax={}));class _le{constructor(e,t,s,r){this.colliderSet=e,this.handle=t,this._parent=s,this._shape=r}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=pr.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return ke.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Bi.fromRaw(this.colliderSet.raw.coRotation(this.handle))}isSensor(){return this.colliderSet.raw.coIsSensor(this.handle)}setSensor(e){this.colliderSet.raw.coSetSensor(this.handle,e)}setShape(e){let t=e.intoRaw();this.colliderSet.raw.coSetShape(this.handle,t),t.free(),this._shape=e}setRestitution(e){this.colliderSet.raw.coSetRestitution(this.handle,e)}setFriction(e){this.colliderSet.raw.coSetFriction(this.handle,e)}frictionCombineRule(){return this.colliderSet.raw.coFrictionCombineRule(this.handle)}setFrictionCombineRule(e){this.colliderSet.raw.coSetFrictionCombineRule(this.handle,e)}restitutionCombineRule(){return this.colliderSet.raw.coRestitutionCombineRule(this.handle)}setRestitutionCombineRule(e){this.colliderSet.raw.coSetRestitutionCombineRule(this.handle,e)}setCollisionGroups(e){this.colliderSet.raw.coSetCollisionGroups(this.handle,e)}setSolverGroups(e){this.colliderSet.raw.coSetSolverGroups(this.handle,e)}activeHooks(){return this.colliderSet.raw.coActiveHooks(this.handle)}setActiveHooks(e){this.colliderSet.raw.coSetActiveHooks(this.handle,e)}activeEvents(){return this.colliderSet.raw.coActiveEvents(this.handle)}setActiveEvents(e){this.colliderSet.raw.coSetActiveEvents(this.handle,e)}activeCollisionTypes(){return this.colliderSet.raw.coActiveCollisionTypes(this.handle)}setContactForceEventThreshold(e){return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle,e)}contactForceEventThreshold(){return this.colliderSet.raw.coContactForceEventThreshold(this.handle)}setActiveCollisionTypes(e){this.colliderSet.raw.coSetActiveCollisionTypes(this.handle,e)}setDensity(e){this.colliderSet.raw.coSetDensity(this.handle,e)}setMass(e){this.colliderSet.raw.coSetMass(this.handle,e)}setMassProperties(e,t,s,r){let n=ke.intoRaw(t),o=ke.intoRaw(s),a=Bi.intoRaw(r);this.colliderSet.raw.coSetMassProperties(this.handle,e,n,o,a),n.free(),o.free(),a.free()}setTranslation(e){this.colliderSet.raw.coSetTranslation(this.handle,e.x,e.y,e.z)}setTranslationWrtParent(e){this.colliderSet.raw.coSetTranslationWrtParent(this.handle,e.x,e.y,e.z)}setRotation(e){this.colliderSet.raw.coSetRotation(this.handle,e.x,e.y,e.z,e.w)}setRotationWrtParent(e){this.colliderSet.raw.coSetRotationWrtParent(this.handle,e.x,e.y,e.z,e.w)}shapeType(){return this.colliderSet.raw.coShapeType(this.handle)}halfExtents(){return ke.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle))}radius(){return this.colliderSet.raw.coRadius(this.handle)}roundRadius(){return this.colliderSet.raw.coRoundRadius(this.handle)}halfHeight(){return this.colliderSet.raw.coHalfHeight(this.handle)}vertices(){return this.colliderSet.raw.coVertices(this.handle)}indices(){return this.colliderSet.raw.coIndices(this.handle)}heightfieldHeights(){return this.colliderSet.raw.coHeightfieldHeights(this.handle)}heightfieldScale(){let e=this.colliderSet.raw.coHeightfieldScale(this.handle);return ke.fromRaw(e)}heightfieldNRows(){return this.colliderSet.raw.coHeightfieldNRows(this.handle)}heightfieldNCols(){return this.colliderSet.raw.coHeightfieldNCols(this.handle)}parent(){return this._parent}friction(){return this.colliderSet.raw.coFriction(this.handle)}restitution(){return this.colliderSet.raw.coRestitution(this.handle)}density(){return this.colliderSet.raw.coDensity(this.handle)}mass(){return this.colliderSet.raw.coMass(this.handle)}volume(){return this.colliderSet.raw.coVolume(this.handle)}collisionGroups(){return this.colliderSet.raw.coCollisionGroups(this.handle)}solverGroups(){return this.colliderSet.raw.coSolverGroups(this.handle)}containsPoint(e){let t=ke.intoRaw(e),s=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),s}projectPoint(e,t){let s=ke.intoRaw(e),r=Rx.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,s,t));return s.free(),r}intersectsRay(e,t){let s=ke.intoRaw(e.origin),r=ke.intoRaw(e.dir),n=this.colliderSet.raw.coIntersectsRay(this.handle,s,r,t);return s.free(),r.free(),n}castShape(e,t,s,r,n,o){let a=ke.intoRaw(e),l=ke.intoRaw(s),c=Bi.intoRaw(r),u=ke.intoRaw(n),d=t.intoRaw(),p=Wv.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,a,d,l,c,u,o));return a.free(),l.free(),c.free(),u.free(),d.free(),p}castCollider(e,t,s,r){let n=ke.intoRaw(e),o=ke.intoRaw(s),a=KI.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,n,t.handle,o,r));return n.free(),o.free(),a}intersectsShape(e,t,s){let r=ke.intoRaw(t),n=Bi.intoRaw(s),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,r,n);return r.free(),n.free(),o.free(),a}contactShape(e,t,s,r){let n=ke.intoRaw(t),o=Bi.intoRaw(s),a=e.intoRaw(),l=Vv.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,n,o,r));return n.free(),o.free(),a.free(),l}contactCollider(e,t){return Vv.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,s){let r=ke.intoRaw(e.origin),n=ke.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,r,n,t,s);return r.free(),n.free(),o}castRayAndGetNormal(e,t,s){let r=ke.intoRaw(e.origin),n=ke.intoRaw(e.dir),o=Px.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,r,n,t,s));return r.free(),n.free(),o}}(function(i){i[i.Density=0]="Density",i[i.Mass=1]="Mass",i[i.MassProps=2]="MassProps"})(af||(af={}));class zi{constructor(e){this.shape=e,this.massPropsMode=af.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Bi.identity(),this.translation=ke.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=Ao.Average,this.restitutionCombineRule=Ao.Average,this.activeCollisionTypes=ax.DEFAULT,this.activeEvents=0,this.activeHooks=0,this.mass=0,this.centerOfMass=ke.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=ke.zeros(),this.angularInertiaLocalFrame=Bi.identity()}static ball(e){const t=new LI(e);return new zi(t)}static capsule(e,t){const s=new fj(e,t);return new zi(s)}static segment(e,t){const s=new mj(e,t);return new zi(s)}static triangle(e,t,s){const r=new gj(e,t,s);return new zi(r)}static roundTriangle(e,t,s,r){const n=new vj(e,t,s,r);return new zi(n)}static polyline(e,t){const s=new Aj(e,t);return new zi(s)}static trimesh(e,t){const s=new yj(e,t);return new zi(s)}static cuboid(e,t,s){const r=new dj(e,t,s);return new zi(r)}static roundCuboid(e,t,s,r){const n=new pj(e,t,s,r);return new zi(n)}static heightfield(e,t,s,r){const n=new bj(e,t,s,r);return new zi(n)}static cylinder(e,t){const s=new _j(e,t);return new zi(s)}static roundCylinder(e,t,s){const r=new xj(e,t,s);return new zi(r)}static cone(e,t){const s=new wj(e,t);return new zi(s)}static roundCone(e,t,s){const r=new Sj(e,t,s);return new zi(r)}static convexHull(e){const t=new UI(e,null);return new zi(t)}static convexMesh(e,t){const s=new UI(e,t);return new zi(s)}static roundConvexHull(e,t){const s=new FI(e,null,t);return new zi(s)}static roundConvexMesh(e,t,s){const r=new FI(e,t,s);return new zi(r)}setTranslation(e,t,s){if(typeof e!="number"||typeof t!="number"||typeof s!="number")throw TypeError("The translation components must be numbers.");return this.translation={x:e,y:t,z:s},this}setRotation(e){return Bi.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setDensity(e){return this.massPropsMode=af.Density,this.density=e,this}setMass(e){return this.massPropsMode=af.Mass,this.mass=e,this}setMassProperties(e,t,s,r){return this.massPropsMode=af.MassProps,this.mass=e,ke.copy(this.centerOfMass,t),ke.copy(this.principalAngularInertia,s),Bi.copy(this.angularInertiaLocalFrame,r),this}setRestitution(e){return this.restitution=e,this}setFriction(e){return this.friction=e,this}setFrictionCombineRule(e){return this.frictionCombineRule=e,this}setRestitutionCombineRule(e){return this.restitutionCombineRule=e,this}setCollisionGroups(e){return this.collisionGroups=e,this}setSolverGroups(e){return this.solverGroups=e,this}setActiveHooks(e){return this.activeHooks=e,this}setActiveEvents(e){return this.activeEvents=e,this}setActiveCollisionTypes(e){return this.activeCollisionTypes=e,this}setContactForceEventThreshold(e){return this.contactForceEventThreshold=e,this}}(function(i){i[i.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",i[i.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",i[i.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",i[i.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",i[i.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",i[i.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",i[i.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",i[i.ONLY_FIXED=6]="ONLY_FIXED"})(DI||(DI={})),function(i){i[i.COLLISION_EVENTS=1]="COLLISION_EVENTS",i[i.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"}(OI||(OI={}));class xle{free(){this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return ke.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return ke.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class wle{constructor(e,t){this.raw=t||new Ix(e)}free(){this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new xle;this.raw.drainContactForceEvents(s=>{t.raw=s,e(t),t.free()})}clear(){this.raw.clear()}}(function(i){i[i.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",i[i.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(hj||(hj={})),function(i){i[i.EMPTY=0]="EMPTY",i[i.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(uj||(uj={}));for(var Gle={byteLength:function(i){var e=Cj(i),t=e[0],s=e[1];return 3*(t+s)/4-s},toByteArray:function(i){var e,t,s=Cj(i),r=s[0],n=s[1],o=new Sle(function(c,u,d){return 3*(u+d)/4-d}(0,r,n)),a=0,l=n>0?r-4:r;for(t=0;t<l;t+=4)e=yo[i.charCodeAt(t)]<<18|yo[i.charCodeAt(t+1)]<<12|yo[i.charCodeAt(t+2)]<<6|yo[i.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return n===2&&(e=yo[i.charCodeAt(t)]<<2|yo[i.charCodeAt(t+1)]>>4,o[a++]=255&e),n===1&&(e=yo[i.charCodeAt(t)]<<10|yo[i.charCodeAt(t+1)]<<4|yo[i.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(i){for(var e,t=i.length,s=t%3,r=[],n=16383,o=0,a=t-s;o<a;o+=n)r.push(Ele(i,o,o+n>a?a:o+n));return s===1?(e=i[t-1],r.push(Ga[e>>2]+Ga[e<<4&63]+"==")):s===2&&(e=(i[t-2]<<8)+i[t-1],r.push(Ga[e>>10]+Ga[e>>4&63]+Ga[e<<2&63]+"=")),r.join("")}},Ga=[],yo=[],Sle=typeof Uint8Array<"u"?Uint8Array:Array,NI="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lf=0,Cle=NI.length;lf<Cle;++lf)Ga[lf]=NI[lf],yo[NI.charCodeAt(lf)]=lf;function Cj(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function Ele(i,e,t){for(var s,r,n=[],o=e;o<t;o+=3)s=(i[o]<<16&16711680)+(i[o+1]<<8&65280)+(255&i[o+2]),n.push(Ga[(r=s)>>18&63]+Ga[r>>12&63]+Ga[r>>6&63]+Ga[63&r]);return n.join("")}yo["-".charCodeAt(0)]=62,yo["_".charCodeAt(0)]=63;const en=le("debugphysics"),zI=le("debugcolliderplacement"),jI=le("debugcollisions"),Mle=le("showcolliders"),bo=Symbol("needle component"),ta=Symbol("physics body"),Tle=Symbol("rigidbody");let cf;globalThis.false=globalThis.false!==void 0?globalThis.false:!0,en&&console.log("Use Rapier",!1,globalThis.false);const lx=class{constructor(){h(this,"debugRenderColliders",!1),h(this,"context"),h(this,"_initializePromise"),h(this,"_isInitialized",!1),h(this,"rapierRay",new ble({x:0,y:0,z:0},{x:0,y:0,z:1})),h(this,"raycastVectorsBuffer",new ra(()=>new w,10)),h(this,"rapierSphere",null),h(this,"rapierColliderArray",[]),h(this,"rapierIdentityRotation",{x:0,y:0,z:0,w:1}),h(this,"rapierForwardVector",{x:0,y:0,z:1}),h(this,"enabled",!1),h(this,"_tempPosition",new w),h(this,"_tempQuaternion",new Ee),h(this,"_tempScale",new w),h(this,"_tempMatrix",new Be),h(this,"_isUpdatingPhysicsWorld",!1),h(this,"world"),h(this,"_hasCreatedWorld",!1),h(this,"eventQueue"),h(this,"collisionHandler"),h(this,"objects",[]),h(this,"bodies",[]),h(this,"_meshCache",new Map),h(this,"_gravity",{x:0,y:-9.81,z:0}),h(this,"lines")}removeBody(i){var e,t;if(!i)return;this.validate();const s=i[ta];if(i[ta]=null,s&&this.world){const r=this.objects.findIndex(n=>n===i);if(r>=0){const n=this.bodies[r];if(this.bodies.splice(r,1),this.objects.splice(r,1),n instanceof _le){const o=n;(e=this.world)==null||e.removeCollider(o,!0);const a=o.parent();if(a&&a.numColliders()<=0){const l=a[bo];this.removeBody(l)}}else n instanceof yle&&(n.numColliders()<=0?(t=this.world)==null||t.removeRigidBody(n):gi()&&(n.did_log_removing||setTimeout(()=>{n.numColliders()>0&&(n.did_log_removing=!0,console.warn("RapierPhysics: removing rigidbody with colliders from the physics world is not possible right now, please remove the colliders first"))},1)))}}}updateBody(i,e,t){if(this.validate(),!!this.enabled&&!(i.destroyed||!i.gameObject)&&!(!e&&!t))if(i.isCollider===!0)console.warn("TODO: implement updating collider position");else{const s=i,r=s[ta];r&&this.syncPhysicsBody(s.gameObject,r,e,t)}}updateProperties(i){this.validate();const e=this.internal_getRigidbody(i);e&&this.internalUpdateProperties(i,e)}addForce(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.addForce(e,t)}addImpulse(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.applyImpulse(e,t)}getLinearVelocity(i){this.validate();const e=this.internal_getRigidbody(i);return e?e.linvel():null}getAngularVelocity(i){this.validate();const e=this.internal_getRigidbody(i);return e?e.angvel():null}resetForces(i,e){this.validate();const t=this.internal_getRigidbody(i);t?.resetForces(e)}resetTorques(i,e){this.validate();const t=this.internal_getRigidbody(i);t?.resetTorques(e)}applyImpulse(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.applyImpulse(e,t)}wakeup(i){this.validate();const e=this.internal_getRigidbody(i);e?.wakeUp()}setAngularVelocity(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.setAngvel(e,t)}setLinearVelocity(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.setLinvel(e,t)}async initialize(i){return this.context=i,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return en&&console.log("Initialize rapier physics engine"),"env"in import.meta&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&en&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||en&&(this._lastWarnTime=this._lastWarnTime??0,Date.now()-this._lastWarnTime>1e3&&(this._lastWarnTime=Date.now(),console.warn("Physics engine is not initialized")))}raycast(i,e,t,s){var r;t===void 0&&(t=1/0),s===void 0&&(s=!0);const n=this.getPhysicsRay(this.rapierRay,i,e);if(!n)return null;const o=(r=this.world)==null?void 0:r.castRay(n,t,s,void 0,void 0,void 0,void 0,a=>{var l;return!((l=a[bo])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const a=n.pointAt(o.toi),l=this.raycastVectorsBuffer.get();return l.set(a.x,a.y,a.z),{point:l,collider:o.collider[bo]}}return null}raycastAndGetNormal(i,e,t,s){var r;t===void 0&&(t=1/0),s===void 0&&(s=!0);const n=this.getPhysicsRay(this.rapierRay,i,e);if(!n)return null;const o=(r=this.world)==null?void 0:r.castRayAndGetNormal(n,t,s,void 0,void 0,void 0,void 0,a=>{var l;return!((l=a[bo])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const a=n.pointAt(o.toi),l=o.normal,c=this.raycastVectorsBuffer.get(),u=this.raycastVectorsBuffer.get();return c.set(a.x,a.y,a.z),u.set(l.x,l.y,l.z),{point:c,normal:u,collider:o.collider[bo]}}return null}getPhysicsRay(i,e,t){var s,r,n;const o=(s=this.context)==null?void 0:s.mainCamera;if(e===void 0){const c=(r=this.context)==null?void 0:r.input.getPointerPosition(0);if(c)e=c;else return null}if(e.z===void 0){if(!o)return console.error("Can not perform raycast from 2d point - no main camera found"),null;const c=this.raycastVectorsBuffer.get();c.x=e.x,c.y=e.y,c.z=0,(c.x>1||c.y>1||c.y<-1||c.x<-1)&&(en&&console.warn("Converting screenspace to raycast space",c),(n=this.context)==null||n.input.convertScreenspaceToRaycastSpace(c)),c.unproject(o),e=c}const a=e;i.origin.x=a.x,i.origin.y=a.y,i.origin.z=a.z;const l=this.raycastVectorsBuffer.get();if(t)l.set(t.x,t.y,t.z);else{if(!o)return console.error("Can not perform raycast - no camera found"),null;l.set(i.origin.x,i.origin.y,i.origin.z);const c=At(o);l.sub(c)}return l.normalize(),i.dir.x=l.x,i.dir.y=l.y,i.dir.z=l.z,i}sphereOverlap(i,e){return this.rapierColliderArray.length=0,this.world?(this.rapierSphere||(this.rapierSphere=new LI(e)),this.rapierSphere.radius=e,this.world.intersectionsWithShape(i,this.rapierIdentityRotation,this.rapierSphere,t=>{const s=t[bo],r=new ij(s.gameObject,s);return this.rapierColliderArray.push(r),!0},DI.EXCLUDE_SENSORS,void 0,void 0,void 0,t=>t[bo].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}get isUpdating(){return this._isUpdatingPhysicsWorld}get gravity(){var i;return((i=this.world)==null?void 0:i.gravity)??this._gravity}set gravity(i){this.world?this.world.gravity=i:this._gravity=i}clearCaches(){var i,e,t,s;this._meshCache.clear(),(i=this.eventQueue)!=null&&i.raw&&((e=this.eventQueue)==null||e.free()),(t=this.world)!=null&&t.bodies&&((s=this.world)==null||s.free())}async addBoxCollider(i,e,t){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){en&&console.warn("Physics are disabled");return}const s=i.gameObject,r=js(s,this._tempPosition).multiply(t);r.multiplyScalar(.5),r.x<0&&(r.x=Math.abs(r.x)),r.y<0&&(r.y=Math.abs(r.y)),r.z<0&&(r.z=Math.abs(r.z)),r.x==0&&(r.x=1e-7),r.y==0&&(r.y=1e-7),r.z==0&&(r.z=1e-7);const n=zi.cuboid(r.x,r.y,r.z);this.createCollider(i,n,e)}async addSphereCollider(i,e,t){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){en&&console.warn("Physics are disabled");return}const s=i.gameObject,r=js(s,this._tempPosition).multiplyScalar(t);r.x=Math.abs(r.x);const n=zi.ball(r.x);this.createCollider(i,n,e)}async addCapsuleCollider(i,e,t,s){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){en&&console.warn("Physics are disabled");return}const r=i.gameObject,n=js(r,this._tempPosition);n.x=Math.abs(n.x),n.y=Math.abs(n.y);const o=zi.capsule(t*.5*n.y-s,s*n.x);this.createCollider(i,o,e)}async addMeshCollider(i,e,t,s){var r,n,o;if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){en&&console.warn("Physics are disabled");return}let a=e.geometry;if(!a){en&&console.warn("Missing mesh geometry",e.name);return}(n=(r=a.index)==null?void 0:r.array)!=null&&n.length||(console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh "${e.name}". Consider providing an indexed geometry.`),a=CY(a));let l=a.getAttribute("position").array;const c=(o=a.index)==null?void 0:o.array;if(Math.abs(s.x-1)>1e-4||Math.abs(s.y-1)>1e-4||Math.abs(s.z-1)>1e-4){const d=a.uuid+"_"+s.x+"_"+s.y+"_"+s.z+"_"+t;if(this._meshCache.has(d))en&&console.warn("Use cached mesh collider"),l=this._meshCache.get(d);else{console.warn("Your model is using scaled mesh colliders which is not optimal for performance",e.name,Object.assign({},s));const p=new Float32Array(l.length);for(let f=0;f<l.length;f+=3)p[f]=l[f]*s.x,p[f+1]=l[f+1]*s.y,p[f+2]=l[f+2]*s.z;l=p,this._meshCache.set(d,p)}}const u=t?zi.convexMesh(l):zi.trimesh(l,c);u&&this.createCollider(i,u).setMassProperties(1,{x:0,y:0,z:0},{x:0,y:0,z:0},{x:0,y:0,z:0,w:1})}createCollider(i,e,t){if(!this.world)throw new Error("Physics world not initialized");const s=this._tempMatrix,{rigidBody:r,useExplicitMassProperties:n}=this.getRigidbody(i,this._tempMatrix);s.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),js(i.gameObject,this._tempScale),t&&(t.multiply(this._tempScale),this._tempPosition.x-=t.x,this._tempPosition.y+=t.y,this._tempPosition.z+=t.z),e.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),e.setRotation(this._tempQuaternion),e.setSensor(i.isTrigger);const o=i.sharedMaterial;if(o){switch(e.setRestitution(o.bounciness),o.bounceCombine){case Sa.Average:e.setRestitutionCombineRule(Ao.Average);break;case Sa.Maximum:e.setRestitutionCombineRule(Ao.Max);break;case Sa.Minimum:e.setRestitutionCombineRule(Ao.Min);break;case Sa.Multiply:e.setRestitutionCombineRule(Ao.Multiply);break}switch(e.setFriction(o.dynamicFriction),o.frictionCombine){case Sa.Average:e.setFrictionCombineRule(Ao.Average);break;case Sa.Maximum:e.setFrictionCombineRule(Ao.Max);break;case Sa.Minimum:e.setFrictionCombineRule(Ao.Min);break;case Sa.Multiply:e.setFrictionCombineRule(Ao.Multiply);break}}const a=this.world.createCollider(e,r);return a[bo]=i,i[ta]=a,a.setActiveEvents(OI.COLLISION_EVENTS),a.setActiveCollisionTypes(ax.ALL),this.objects.push(i),this.bodies.push(a),a}getRigidbody(i,e){if(!this.world)throw new Error("Physics world not initialized");let t=null,s=!1;if(i.attachedRigidbody){const r=i.attachedRigidbody;if(t=r[ta],s=!0,!t){const n=r.isKinematic&&!zI;en&&console.log("Create rigidbody",n);const o=n?cf.RigidBodyDesc.kinematicPositionBased():cf.RigidBodyDesc.dynamic(),a=At(i.attachedRigidbody.gameObject);o.setTranslation(a.x,a.y,a.z),o.setRotation(Bs(i.attachedRigidbody.gameObject)),t=this.world.createRigidBody(o),this.bodies.push(t),this.objects.push(r)}t[bo]=r,r[ta]=t,this.internalUpdateProperties(r,t),this.getRigidbodyRelativeMatrix(i.gameObject,r.gameObject,e)}else{const r=cf.RigidBodyDesc.kinematicPositionBased(),n=At(i.gameObject);r.setTranslation(n.x,n.y,n.z),r.setRotation(Bs(i.gameObject)),t=this.world.createRigidBody(r),e.identity(),t[bo]=null}return i[Tle]=t,{rigidBody:t,useExplicitMassProperties:s}}internal_getRigidbody(i){return i[ta]}internalUpdateProperties(i,e){e.enableCcd(i.collisionDetectionMode!==pb.Discrete),e.setLinearDamping(i.drag),e.setAngularDamping(i.angularDrag),e.setGravityScale(i.useGravity?i.gravityScale:0,!0),e.setEnabledRotations(!i.lockRotationX,!i.lockRotationY,!i.lockRotationZ,!0),e.setEnabledTranslations(!i.lockPositionX,!i.lockPositionY,!i.lockPositionZ,!0),i.isKinematic?e.setBodyType(cf.RigidBodyType.KinematicPositionBased):e.setBodyType(cf.RigidBodyType.Dynamic)}step(i){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new wle(!1)),i&&(this.world.timestep=tt.lerp(this.world.timestep,i,.8)),this.world.step(this.eventQueue),this._isUpdatingPhysicsWorld=!1,this.updateDebugRendering(this.world))}updateDebugRendering(i){var e,t,s;if(en||zI||Mle||this.debugRenderColliders===!0){if(!this.lines){const n=new is({color:2258688,fog:!1}),o=new gt;this.lines=new Rn(o,n)}this.lines.parent!==((e=this.context)==null?void 0:e.scene)&&((t=this.context)==null||t.scene.add(this.lines));const r=i.debugRender();this.lines.geometry.setAttribute("position",new rt(r.vertices,3)),this.lines.geometry.setAttribute("color",new rt(r.colors,4))}else this.lines&&((s=this.context)==null||s.scene.remove(this.lines))}postStep(){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.syncObjects(),this._isUpdatingPhysicsWorld=!1,this.eventQueue&&!this.collisionHandler&&(this.collisionHandler=new Ile(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()))}syncObjects(){if(!zI)for(let i=0;i<this.bodies.length;i++){const e=this.objects[i],t=this.bodies[i],s=e;if(s?.isCollider===!0&&!s.attachedRigidbody){const a=t.parent();a&&this.syncPhysicsBody(e.gameObject,a,!0,!0);continue}const r=t.translation(),n=t.rotation(),o=e.center;if(o&&o.isVector3){this._tempQuaternion.set(n.x,n.y,n.z,n.w);const a=this._tempPosition.copy(o).applyQuaternion(this._tempQuaternion),l=js(e.gameObject);a.multiply(l),r.x-=a.x,r.y-=a.y,r.z-=a.z}Fd(e.gameObject,r.x,r.y,r.z),Xk(e.gameObject,n.x,n.y,n.z,n.w)}}syncPhysicsBody(i,e,t,s){const r=At(i,this._tempPosition),n=Bs(i,this._tempQuaternion);switch(e.bodyType()){case Fv.Fixed:case Fv.KinematicPositionBased:case Fv.KinematicVelocityBased:t&&e.setNextKinematicTranslation(r),s&&e.setNextKinematicRotation(n);break;default:t&&e.setTranslation(r,!1),s&&e.setRotation(n,!1);break}e.wakeUp()}getRigidbodyRelativeMatrix(i,e,t,s){if(s===void 0&&(s=lx._matricesBuffer,s.length=0),i===e){const r=js(i,this._tempPosition);t.makeScale(r.x,r.y,r.z);for(let n=s.length-1;n>=0;n--)t.multiply(s[n]);return t}return s.push(i.matrix),i.parent&&this.getRigidbodyRelativeMatrix(i.parent,e,t,s),t}addFixedJoint(i,e){if(!this.world){console.error("Physics world not initialized");return}const t=i[ta],s=e[ta];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=mf.fixed(lx.centerConnectionPos,lx.centerConnectionRot,this._tempPosition,this._tempQuaternion),n=this.world.createImpulseJoint(r,t,s,!0);en&&console.log("ADD FIXED JOINT",n)}addHingeJoint(i,e,t,s){if(!this.world){console.error("Physics world not initialized");return}const r=i[ta],n=e[ta];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const o=cf.JointData.revolute(t,this._tempPosition,s),a=this.world.createImpulseJoint(o,r,n,!0);en&&console.log("ADD HINGE JOINT",a)}calculateJointRelativeMatrices(i,e,t){i.updateWorldMatrix(!0,!1),e.updateWorldMatrix(!0,!1);const s=i.matrixWorld,r=e.matrixWorld;s.elements[0]=1,s.elements[5]=1,s.elements[10]=1,r.elements[0]=1,r.elements[5]=1,r.elements[10]=1,t.copy(r).premultiply(s.invert()).invert()}};let Nv=lx;h(Nv,"_didLoadPhysicsEngine",!1),h(Nv,"_matricesBuffer",[]),h(Nv,"centerConnectionPos",{x:0,y:0,z:0}),h(Nv,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Ile{constructor(e,t){h(this,"world"),h(this,"eventQueue"),h(this,"activeCollisions",[]),h(this,"activeCollisionsStay",[]),h(this,"activeTriggers",[]),this.world=e,this.eventQueue=t}handleCollisionEvents(){this.eventQueue&&this.world&&this.eventQueue.drainCollisionEvents((e,t,s)=>{const r=this.world.getCollider(e),n=this.world.getCollider(t),o=r[bo],a=n[bo];jI&&console.log("EVT",o.name,a.name,s,r,n),o&&a&&(s?(this.onCollisionStarted(o,r,a,n),this.onCollisionStarted(a,n,o,r)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,s,r){let n=null;if(e.isTrigger||s.isTrigger)su(e.gameObject,o=>{o.onTriggerEnter&&!o.destroyed&&o.onTriggerEnter(s),this.activeTriggers.push({collider:e,component:o,otherCollider:s})});else{const o=e.gameObject;this.world.contactPair(t,r,(a,l)=>{su(o,c=>{var u;if(c.destroyed)return;const d=c.onCollisionEnter||c.onCollisionStay||c.onCollisionExit;if(d||jI){if(!n){const p=[],f=a.normal();for(let m=0;m<a.numSolverContacts();m++){const A=a.solverContactPoint(m),v=a.contactImpulse(m);if(A){const g=a.contactDist(m),b=a.solverContactFriction(m),y=new ej(A,g,f,v,b);p.push(y),jI&&Ml.DrawDirection(A,f,16711680,3,!0)}}n=new tj(o,s,p)}if(d){const p={collider:e,component:c,collision:n};this.activeCollisions.push(p),c.onCollisionStay&&this.activeCollisionsStay.push(p),(u=c.onCollisionEnter)==null||u.call(c,n)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){const s=e.collision;t.onCollisionStay(s)}}for(const e of this.activeTriggers){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onTriggerStay){const s=e.otherCollider;t.onTriggerStay(s)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let s=0;s<this.activeCollisions.length;s++){const r=this.activeCollisions[s],n=r.collider;if(n.destroyed){this.activeCollisions.splice(s,1),s--;continue}if(n===e&&r.collision.collider===t){const o=r.component;if(this.activeCollisions.splice(s,1),s--,o.activeAndEnabled&&o.onCollisionExit){const a=r.collision;o.onCollisionExit(a)}}}for(let s=0;s<this.activeCollisionsStay.length;s++){const r=this.activeCollisionsStay[s],n=r.collider;if(n.destroyed){this.activeCollisionsStay.splice(s,1),s--;continue}if(n===e&&r.collision.collider===t){const o=r.component;if(this.activeCollisionsStay.splice(s,1),s--,o.activeAndEnabled&&o.onCollisionExit){const a=r.collision;o.onCollisionExit(a)}}}for(let s=0;s<this.activeTriggers.length;s++){const r=this.activeTriggers[s],n=r.collider;if(n.destroyed){this.activeTriggers.splice(s,1),s--;continue}if(n===e&&r.otherCollider===t){const o=r.component;if(this.activeTriggers.splice(s,1),s--,o.activeAndEnabled&&o.onTriggerExit){const a=r.otherCollider;o.onTriggerExit(a)}}}}}}Object.defineProperty(qt.prototype,"fov",{get:function(){return this._fov},set:function(i){const e=i!==this._fov;this._fov=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}}),Object.defineProperty(qt.prototype,"near",{get:function(){return this._near},set:function(i){const e=i!==this._near;this._near=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}}),Object.defineProperty(qt.prototype,"far",{get:function(){return this._far},set:function(i){const e=i!==this._far;this._far=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}});function Rle(i,e,t,s="image/webp",r){if(!i&&(i=Ti.Current,!i))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!r&&(r=i.mainCamera,!r))return console.error("No camera found"),null;const n=i.renderer.domElement.width,o=i.renderer.domElement.height;e||(e=n),t||(t=o);try{const a=i.renderer.domElement;return i.renderer.setSize(e,t,!1),r instanceof qt&&i.updateAspect(r,e,t),i.renderNow(),a.toDataURL(s)}finally{i.renderer.setSize(n,o,!1),i.updateSize()}return null}let zv=null;function Ple(i,e){if(i){if(!i.startsWith("data:image")){console.error("Can not save image: Data url is not an image",i);return}zv||(zv=document.createElement("a")),zv.href=i,zv.download=e,zv.click()}}const cx=le("debugmissingcamera");Ti.registerCallback(kr.MissingCamera,i=>{var e,t;cx&&console.warn("Creating missing camera");const s=i.context.scene,r=new Re;r.name="Default Fallback Camera",s.add(r);const n=new Ri;n.sourceId=((t=(e=i.files)==null?void 0:e[0])==null?void 0:t.src)??"unknown",n.clearFlags=1,n.backgroundColor=new Ai(.5,.5,.5,1),n.fieldOfView=35,n.backgroundBlurriness=.125;const o=eu(r,n,!0);return r.position.x=0,r.position.y=1,r.position.z=2,Ej(i.context,o),o}),Ti.registerCallback(kr.ContextCreated,i=>{if(!i.context.mainCamera){cx&&console.log("Will not auto-fit because a default camera exists");return}const e=i.context.domElement;if(e?.cameraControls===!0){const t=Tte(i.context.mainCamera);if(t?.isCameraController===!0){cx&&console.log("Will not auto-fit because a camera controller exists");return}Ej(i.context)}});function Ej(i,e){e=e??i.mainCameraComponent;const t=e?.gameObject;if(cx&&console.log("Creating default camera controls",e?.name),t){const s=ly(t,Gl);s.sourceId=e?.sourceId??"unknown";const r=i.domElement.getAttribute("auto-rotate");s.autoRotate=r!==void 0&&(r===""||r==="true"),s.autoRotateSpeed=.5;const n=i,o=()=>{n.pre_render_callbacks.splice(n.pre_render_callbacks.indexOf(o),1),s.fitCamera()};n.pre_render_callbacks.push(o)}else console.warn("Missing camera object, can not add orbit controls")}Zj();const QI={Context:zt,glTF:{loadFromURL:PI}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported"),globalThis.Needle=QI;function Mj(i){for(const e in i)QI[e]=i[e]}Mj(eY),Mj(Wae);for(const i of Object.getOwnPropertyNames(se))switch(i){case"prototype":case"constructor":case"length":case"name":continue;default:QI[i]=se[i];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=o6;var GI={},Tj={};Object.defineProperty(Tj,"__esModule",{value:!0});var hx={};Object.defineProperty(hx,"__esModule",{value:!0}),hx.ConstantBackoff=void 0;var Ble=function(){function i(e){this.reset=function(){},this.backoff=e}return i.prototype.next=function(){return this.backoff},i}();hx.ConstantBackoff=Ble;var ux={};Object.defineProperty(ux,"__esModule",{value:!0}),ux.ExponentialBackoff=void 0;var kle=function(){function i(e,t){this.initial=e,this.expMax=t,this.expCurrent=1,this.current=this.initial}return i.prototype.next=function(){var e=this.current;return this.expMax>this.expCurrent++&&(this.current=this.current*2),e},i.prototype.reset=function(){this.expCurrent=1,this.current=this.initial},i}();ux.ExponentialBackoff=kle;var dx={};Object.defineProperty(dx,"__esModule",{value:!0}),dx.LinearBackoff=void 0;var Dle=function(){function i(e,t,s){this.initial=e,this.increment=t,this.maximum=s,this.current=this.initial}return i.prototype.next=function(){var e=this.current,t=this.current+this.increment;return this.maximum===void 0?this.current=t:t<=this.maximum&&(this.current=t),e},i.prototype.reset=function(){this.current=this.initial},i}();dx.LinearBackoff=Dle;var Ij={};Object.defineProperty(Ij,"__esModule",{value:!0});var px={};Object.defineProperty(px,"__esModule",{value:!0}),px.LRUBuffer=void 0;var Ole=function(){function i(e){this.writePtr=0,this.wrapped=!1,this.buffer=Array(e)}return i.prototype.len=function(){return this.wrapped?this.buffer.length:this.writePtr},i.prototype.cap=function(){return this.buffer.length},i.prototype.read=function(e){if(e==null||e.length===0||this.buffer.length===0||this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,s=t-1<0?this.buffer.length-1:t-1,r=0;r<e.length;r++){var n=(t+r)%this.buffer.length;if(e[r]=this.buffer[n],n===s)return r+1}return e.length},i.prototype.write=function(e){if(e==null||e.length===0||this.buffer.length===0)return 0;for(var t=e.length>this.buffer.length?e.length-this.buffer.length:0,s=0;s<e.length-t;s++)this.buffer[this.writePtr]=e[t+s],this.writePtr=(this.writePtr+1)%this.buffer.length,this.writePtr===0&&(this.wrapped=!0);return e.length},i.prototype.forEach=function(e){if(this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,s=this.wrapped?t-1<0?this.buffer.length-1:t-1:this.writePtr-1,r=this.len();e(this.buffer[t]),t!==s;)t=(t+1)%this.buffer.length;return r},i.prototype.clear=function(){this.writePtr=0,this.wrapped=!1},i}();px.LRUBuffer=Ole;var fx={};Object.defineProperty(fx,"__esModule",{value:!0}),fx.TimeBuffer=void 0;var Lle=function(){function i(e){this.maxAge=e}return i.prototype.cap=function(){return Number.POSITIVE_INFINITY},i.prototype.len=function(){this.forwardTail();for(var e=this.tail,t=0;e!==void 0;)t++,e=e.n;return t},i.prototype.read=function(e){if(this.forwardTail(),e.length===0)return 0;for(var t=this.tail,s=0;t!==void 0&&(e[s++]=t.e,s!==e.length);)t=t.n;return s},i.prototype.write=function(e){for(var t=0;t<e.length;t++)this.putElement(e[t]);return e.length},i.prototype.forEach=function(e){this.forwardTail();for(var t=this.tail,s=0;t!==void 0;)e(t.e),s++,t=t.n;return s},i.prototype.putElement=function(e){var t={e,t:Date.now(),n:void 0};this.tail===void 0&&(this.tail=t),this.head===void 0?this.head=t:(this.head.n=t,this.head=t)},i.prototype.forwardTail=function(){if(this.tail!==void 0)for(var e=Date.now();e-this.tail.t>this.maxAge&&(this.tail===this.head?(this.tail=void 0,this.head=void 0):this.tail=this.tail.n,this.tail!==void 0););},i.prototype.clear=function(){},i}();fx.TimeBuffer=Lle;var HI={};(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Websocket=i.WebsocketEvents=void 0;var e;(function(s){s.open="open",s.close="close",s.error="error",s.message="message",s.retry="retry"})(e=i.WebsocketEvents||(i.WebsocketEvents={}));var t=function(){function s(r,n,o,a){var l=this;this.eventListeners={open:[],close:[],error:[],message:[],retry:[]},this.closedByUser=!1,this.retries=0,this.handleOpenEvent=function(c){return l.handleEvent(e.open,c)},this.handleCloseEvent=function(c){return l.handleEvent(e.close,c)},this.handleErrorEvent=function(c){return l.handleEvent(e.error,c)},this.handleMessageEvent=function(c){return l.handleEvent(e.message,c)},this.url=r,this.protocols=n,this.buffer=o,this.backoff=a,this.tryConnect()}return Object.defineProperty(s.prototype,"underlyingWebsocket",{get:function(){return this.websocket},enumerable:!1,configurable:!0}),s.prototype.send=function(r){var n;this.closedByUser||(this.websocket===void 0||this.websocket.readyState!==this.websocket.OPEN?(n=this.buffer)===null||n===void 0||n.write([r]):this.websocket.send(r))},s.prototype.close=function(r,n){var o;this.closedByUser=!0,(o=this.websocket)===null||o===void 0||o.close(r,n)},s.prototype.addEventListener=function(r,n,o){var a={listener:n,options:o},l=this.eventListeners[r];l.push(a)},s.prototype.removeEventListener=function(r,n,o){this.eventListeners[r]=this.eventListeners[r].filter(function(a){return a.listener!==n&&(a.options===void 0||a.options!==o)})},s.prototype.dispatchEvent=function(r,n){var o=this,a=this.eventListeners[r],l=[];a.forEach(function(c){c.listener(o,n),c.options!==void 0&&c.options.once&&l.push(c)}),l.forEach(function(c){return o.removeEventListener(r,c.listener,c.options)})},s.prototype.tryConnect=function(){this.websocket!==void 0&&(this.websocket.removeEventListener(e.open,this.handleOpenEvent),this.websocket.removeEventListener(e.close,this.handleCloseEvent),this.websocket.removeEventListener(e.error,this.handleErrorEvent),this.websocket.removeEventListener(e.message,this.handleMessageEvent),this.websocket.close()),this.websocket=new WebSocket(this.url,this.protocols),this.websocket.addEventListener(e.open,this.handleOpenEvent),this.websocket.addEventListener(e.close,this.handleCloseEvent),this.websocket.addEventListener(e.error,this.handleErrorEvent),this.websocket.addEventListener(e.message,this.handleMessageEvent)},s.prototype.handleEvent=function(r,n){var o,a,l;switch(r){case e.close:this.closedByUser||this.reconnect();break;case e.open:this.retries=0,(o=this.backoff)===null||o===void 0||o.reset(),(a=this.buffer)===null||a===void 0||a.forEach(this.send.bind(this)),(l=this.buffer)===null||l===void 0||l.clear();break}this.dispatchEvent(r,n)},s.prototype.reconnect=function(){var r=this;if(this.backoff!==void 0){var n=this.backoff.next();setTimeout(function(){r.dispatchEvent(e.retry,new CustomEvent(e.retry,{detail:{retries:++r.retries,backoff:n}})),r.tryConnect()},n)}},s}();i.Websocket=t})(HI);var mx={};Object.defineProperty(mx,"__esModule",{value:!0}),mx.WebsocketBuilder=void 0;var hf=HI,Ule=function(){function i(e){this.ws=null,this.onOpenListeners=[],this.onCloseListeners=[],this.onErrorListeners=[],this.onMessageListeners=[],this.onRetryListeners=[],this.url=e}return i.prototype.withProtocols=function(e){return this.protocols=e,this},i.prototype.withBackoff=function(e){return this.backoff=e,this},i.prototype.withBuffer=function(e){return this.buffer=e,this},i.prototype.onOpen=function(e,t){return this.onOpenListeners.push({listener:e,options:t}),this},i.prototype.onClose=function(e,t){return this.onCloseListeners.push({listener:e,options:t}),this},i.prototype.onError=function(e,t){return this.onErrorListeners.push({listener:e,options:t}),this},i.prototype.onMessage=function(e,t){return this.onMessageListeners.push({listener:e,options:t}),this},i.prototype.onRetry=function(e,t){return this.onRetryListeners.push({listener:e,options:t}),this},i.prototype.build=function(){var e=this;return this.ws!==null?this.ws:(this.ws=new hf.Websocket(this.url,this.protocols,this.buffer,this.backoff),this.onOpenListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(hf.WebsocketEvents.open,t.listener,t.options)}),this.onCloseListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(hf.WebsocketEvents.close,t.listener,t.options)}),this.onErrorListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(hf.WebsocketEvents.error,t.listener,t.options)}),this.onMessageListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(hf.WebsocketEvents.message,t.listener,t.options)}),this.onRetryListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(hf.WebsocketEvents.retry,t.listener,t.options)}),this.ws)},i}();mx.WebsocketBuilder=Ule,function(i){var e=V0&&V0.__createBinding||(Object.create?function(s,r,n,o){o===void 0&&(o=n),Object.defineProperty(s,o,{enumerable:!0,get:function(){return r[n]}})}:function(s,r,n,o){o===void 0&&(o=n),s[o]=r[n]}),t=V0&&V0.__exportStar||function(s,r){for(var n in s)n!=="default"&&!Object.prototype.hasOwnProperty.call(r,n)&&e(r,s,n)};Object.defineProperty(i,"__esModule",{value:!0}),t(Tj,i),t(hx,i),t(ux,i),t(dx,i),t(Ij,i),t(px,i),t(fx,i),t(HI,i),t(mx,i)}(GI);const Fle=lm(GI),Nle=Uj({__proto__:null,default:Fle},[GI]),_o={node:"node",material:"material",camera:"camera",light:"light"},Vu="KHR_animation_pointer",zle={CUBICSPLINE:void 0,LINEAR:aa,STEP:gc},Rj=Ot.findNode;let Pj=!1;class jle{constructor(e){this.parser=e,this.name=Vu,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){Pj||(Pj=!0,Ot.findNode=function(e,t){if(t.startsWith(".materials.")){const s=t.substring(11).substring(t.indexOf(".")),r=s.indexOf("."),n=r<0?s:s.substring(0,r);let o=null;return e.traverse(a=>{o!==null||a.type!=="Mesh"&&a.type!=="SkinnedMesh"||a.material&&(a.material.uuid===n||a.material.name===n)&&(o=a.material,o!==null&&(s.endsWith(".map")?o=o.map:s.endsWith(".emissiveMap")&&(o=o.emissiveMap)))}),o}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const s=t.split(".");let r;for(let n=1;n<s.length;n++){const o=s[n];if(o.length==36)r=e.getObjectByProperty("uuid",o);else if(r&&r[o]){const a=Number.parseInt(o);let l=o;a>=0&&(l=a),r=r[l]}else{const a=e.getObjectByName(o);a&&(r=a)}}if(!r){const n=Rj(e,s[2]);return n||console.warn(Vu+": Property binding not found",t,e,e.name,s),n}return r}return Rj(e,t)})}loadAnimationTargetFromChannel(e){const t=e.target,s=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",s)}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const t=e.target,s=t.extensions&&t.extensions[Vu]&&t.path&&t.path==="pointer";if(!s)return null;let r,n=_o.node,o;if(s){const l=t.extensions[Vu];let c=l.pointer;if(!c){console.warn("Invalid path",l,t);return}if(c.startsWith("/materials/")?n=_o.material:c.startsWith("/extensions/KHR_lights_punctual/lights/")?n=_o.light:c.startsWith("/cameras/")&&(n=_o.camera),o=this._tryResolveTargetId(c,n),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,c);return}switch(n){case _o.material:const d=("/materials/"+o.toString()+"/").length,p=c.substring(0,d);switch(r=c.substring(d),r){case"pbrMetallicRoughness/baseColorFactor":r="color";break;case"pbrMetallicRoughness/roughnessFactor":r="roughness";break;case"pbrMetallicRoughness/metallicFactor":r="metalness";break;case"emissiveFactor":r="emissive";break;case"alphaCutoff":r="alphaTest";break;case"occlusionTexture/strength":r="aoMapIntensity";break;case"normalTexture/scale":r="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":r="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":r="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":r="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":r="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":r="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":r="transmission";break;case"extensions/KHR_materials_ior/ior":r="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":r="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":r="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":r="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":r="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":r="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":r="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":r="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":r="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":r="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":r="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":r="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":r="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":r="specularColor";break}c=p+r;break;case _o.node:const f=("/nodes/"+o.toString()+"/").length,m=c.substring(0,f);switch(r=c.substring(f),r){case"translation":r="position";break;case"rotation":r="quaternion";break;case"scale":r="scale";break;case"weights":r="morphTargetInfluences";break}c=m+r;break;case _o.light:const A=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(r=c.substring(A),r){case"color":break;case"intensity":break;case"spot/innerConeAngle":r="penumbra";break;case"spot/outerConeAngle":r="angle";break;case"range":r="distance";break}c="/lights/"+o.toString()+"/"+r;break;case _o.camera:const v=("/cameras/"+o.toString()+"/").length,g=c.substring(0,v);switch(r=c.substring(v),r){case"perspective/yfov":r="fov";break;case"perspective/znear":case"orthographic/znear":r="near";break;case"perspective/zfar":case"orthographic/zfar":r="far";break;case"perspective/aspect":r="aspect";break;case"orthographic/xmag":r="zoom";break;case"orthographic/ymag":r="zoom";break}c=g+r;break}const u=this.animationPointerResolver;u&&u.resolvePath&&(c=u.resolvePath(c)),t.extensions[Vu].pointer=c}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return n===_o.node?a=this.parser.getDependency("node",o):n===_o.material?a=this.parser.getDependency("material",o):n===_o.light?a=this.parser.getDependency("light",o):n===_o.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",n),a}createAnimationTracksWithAnimationPointer(e,t,s,r,n){if(!(n.extensions&&n.extensions[Vu]&&n.path&&n.path==="pointer"))return null;let o=n.extensions[Vu].pointer;if(!o)return null;const a=[];o=o.replaceAll("/",".");const l=o.split(".");var c=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=c,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const d of e.children)d instanceof Uh&&d.morphTargetInfluences&&(l[3]=d.name,l[4]="morphTargetInfluences",u(this.parser));return a}u(this.parser);function u(d){o=l.join(".");let p;switch(s.itemSize){case 1:p=xc;break;case 2:case 3:p=hl;break;case 4:o.endsWith(".quaternion")?p=ua:p=v0;break}const f=r.interpolation!==void 0?zle[r.interpolation]:aa;let m=d._getArrayFromAccessor(s);o.endsWith(".fov")&&(m=m.map(v=>v/Math.PI*180));const A=new p(o,t.array,m,f);if(f==="CUBICSPLINE"&&d._createCubicSplineTrackInterpolant(A),a.push(A),o&&s.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const v=new Float32Array(m.length/4);for(let b=0,y=m.length/4;b<y;b+=1)v[b]=m[b*4+3];const g=new p(o.replace(".color",".opacity"),t.array,v,f);f==="CUBICSPLINE"&&d._createCubicSplineTrackInterpolant(A),a.push(g)}}return a}_tryResolveTargetId(e,t){let s="";return t==="node"?s=e.substring(7):t==="material"?s=e.substring(11):t==="light"?s=e.substring(39):t==="camera"&&(s=e.substring(9)),s=s.substring(0,s.indexOf("/")),Number.parseInt(s)}loadAnimation(e){const t=this,s=this.parser.json,r=this.parser,n=s.animations[e],o=n.name?n.name:"animation_"+e,a=[],l=[],c=[],u=[],d=[];for(let p=0,f=n.channels.length;p<f;p++){const m=n.channels[p],A=n.samplers[m.sampler],v=m.target,g=n.parameters!==void 0?n.parameters[A.input]:A.input,b=n.parameters!==void 0?n.parameters[A.output]:A.output;let y=t.loadAnimationTargetFromChannelWithAnimationPointer(m);y||(y=t.loadAnimationTargetFromChannel(m)),a.push(y),l.push(r.getDependency("accessor",g)),c.push(r.getDependency("accessor",b)),u.push(A),d.push(v)}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(u),Promise.all(d)]).then(function(p){const f=p[0],m=p[1],A=p[2],v=p[3],g=p[4],b=[];for(let y=0,_=f.length;y<_;y++){const S=f[y],M=m[y],I=A[y],R=v[y],E=g[y];if(S===void 0)continue;S.updateMatrix&&(S.updateMatrix(),S.matrixAutoUpdate=!0);let C=t.createAnimationTracksWithAnimationPointer(S,M,I,R,E);if(C||(C=r._createAnimationTracks(S,M,I,R,E)),C)for(let z=0;z<C.length;z++)b.push(C[z])}return new Fr(o,void 0,b)})}}const Qle=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:jle},Symbol.toStringTag,{value:"Module"}));export{fle as $physicsKey,ui as ActionBuilder,bE as ActionCollection,Go as ActionModel,sL as Addressables,Km as AlignmentConstraint,qd as AmbientMode,Bn as Animation,du as AnimationCurve,ib as AnimationExtension,Gb as AnimationTrackHandler,Cr as Animator,Hc as AnimatorConditionMode,Wu as AnimatorController,xE as AnimatorControllerParameterType,sb as AnimatorStateInfo,Pg as Antialiasing,aL as Application,Py as ApplicationEvents,tO as AssetDatabase,er as AssetReference,Ta as AttachedObject,Db as AttachedObjectEvents,Vb as AudioExtension,Tp as AudioListener,As as AudioSource,Tg as AudioTrackHandler,yu as AvatarBlink_Simple,Bp as AvatarEyeLook_Rotation,ub as AvatarLoader,Mr as AvatarMarker,hb as AvatarModel,sg as Avatar_Brain_LookAt,Bg as Avatar_MouthShapes,BM as Avatar_MustacheShake,qr as Avatar_POI,mp as Axes,kp as AxesHelper,ia as BaseUIComponent,LM as BasicIKConstraint,Xb as BehaviorExtension,Xr as BehaviorModel,Ie as Behaviour,bu as Bloom,Dg as BoxCollider,vu as BoxGizmo,_a as BoxHelperComponent,Wl as Button,rp as CallInfo,Ri as Camera,nr as Canvas,th as CanvasGroup,Zc as CapsuleCollider,Up as ChangeMaterialOnClick,wu as ChangeTransformOnClick,Su as CharacterController,Yl as CharacterControllerInput,jg as ChromaticAberration,ra as CircularBuffer,XN as ClearFlags,Ia as ClipExtrapolation,Ra as Collider,tj as Collision,pb as CollisionDetectionMode,sh as ColorAdjustments,Cu as ColorBySpeedModule,Hg as ColorOverLifetimeModule,Oc as Component,ym as ComponentEvents,bm as ComponentLifecycleEvents,MD as ConnectionEvents,ej as ContactPoint,zt as Context,Jq as ContextArgs,kr as ContextEvent,Ti as ContextRegistry,Hb as ControlTrackHandler,Fl as ControllerEvents,xp as ControllerType,lh as CustomBranding,zo as CustomShader,Ry as DefaultReflectionMode,eT as Deletable,c_ as DeleteBox,Jo as DepthOfField,h_ as DeviceFlag,tT as DocumentExtension,Gp as DragControls,Xg as DropListener,Iu as Duplicatable,Gy as EXTENSION_NAME,ka as EmissionModule,Np as EmphasizeOnClick,LC as EngineLoadingView,ir as EventList,Wy as EventListEvent,Un as EventSystem,p_ as EventTrigger,uE as FieldWithDefault,f3 as FileSpawnModel,p3 as File_Event,hT as FixedJoint,uT as FlyControls,Wp as Fog,dn as FrameEvent,sy as GENERATOR,se as GameObject,Ml as Gizmos,lc as GltfExport,yT as GltfExportBox,Gu as GltfLoadEvent,Vz as GltfLoadEventType,rh as Gradient,_u as Graphic,SM as GraphicRaycaster,Bo as Graphics,qp as GridHelper,WM as GridLayoutGroup,Ru as GroundProjectedEnv,zc as GroupActionModel,aO as HideFlags,YM as HideOnStart,qg as HingeJoint,VM as HorizontalLayoutGroup,H8 as HostData,Op as Image,Iy as ImageReference,rL as ImageReferenceSerializer,oh as InheritVelocityModule,Vk as Input,pa as InputEvents,Bu as InputField,_n as InstancingUtil,kD as InstantiateEvent,tn as InstantiateIdProvider,ga as InstantiateOptions,pp as Interactable,R8 as JoinedRoomResponse,U0 as KeyEventArgs,$g as LODGroup,ku as LODModel,P8 as LeftRoomResponse,An as Light,oL as LightData,xs as LimitVelocityOverLifetimeModule,uY as LoadingElementOptions,xT as LogStats,Co as LogType,Du as LookAt,$m as LookAtConstraint,ar as MainModule,IM as MarkerType,Fg as MaskableGraphic,tt as Mathf,Og as MeshCollider,Ky as MeshRenderer,ct as MinMaxCurve,vn as MinMaxGradient,jo as NEEDLE_progressive,Ti as NeedleEngine,BI as NeedleEngineHTMLElement,II as NeedleGltfLoader,py as NeedlePatchesKey,y_ as NestedGltf,ID as NetworkConnection,Tu as Networking,mi as NoiseModule,zl as ObjectRaycaster,xz as ObjectUtils,Ou as OffsetConstraint,Yp as OpenURL,Gl as OrbitControls,Dp as Outline,TD as OwnershipEvent,iy as OwnershipModel,$c as Padding,Gg as ParticleBurst,D_ as ParticleSubEmitter,Cs as ParticleSystem,Jl as ParticleSystemRenderer,CD as PeerNetworking,n2 as Physics,Sa as PhysicsMaterialCombine,cv as PixelationEffect,ih as PlayAnimationOnClick,zp as PlayAudioOnClick,Au as PlayableDirector,Xu as PlayerColor,Qu as PlayerState,Gz as PlayerStateEvent,rx as PlayerSync,xL as PlayerView,wL as PlayerViewManager,oc as PointerEventData,Hk as PointerType,Tr as PostProcessingEffect,L_ as PostProcessingHandler,Qp as PreliminaryAction,Ng as PreliminaryTrigger,iI as PrimitiveType,aU as ProgressiveLoadingInfo,hR as PromiseAllWithErrors,cR as PromiseErrorResult,Ai as RGBAColor,Nv as RapierPhysics,Zb as RawImage,ko as RaycastOptions,Ep as Raycaster,jM as Rect,Kr as RectTransform,op as ReflectionProbe,tb as RegisteredAnimationInfo,Zl as RemoteSkybox,np as RenderTexture,pU as RenderTextureSerializer,Di as Renderer,nL as RendererData,Xm as RendererLightmap,Vi as Rigidbody,ls as RigidbodyConstraints,Ki as RoomEvents,Qn as RotationBySpeedModule,go as RotationOverLifetimeModule,Qy as SceneLightSettings,yn as SceneSwitcher,dv as ScreenCapture,$l as ScreenSpaceAmbientOcclusion,ea as ScreenSpaceAmbientOcclusionN8,hn as SendQueue,Fp as SetActiveOnClick,vv as ShadowCatcher,cs as ShapeModule,Cg as SignalAsset,Rp as SignalReceiver,Ip as SignalReceiverEvent,Ig as SignalTrackHandler,zM as Size,Jr as SizeBySpeedModule,nh as SizeOverLifetimeModule,dE as SkinnedMeshRenderer,dh as SmoothFollow,oI as SpatialHtml,bv as SpatialTrigger,Fa as SpatialTriggerReceiver,G_ as SpectatorCamera,kg as SphereCollider,r2 as SphereIntersection,ij as SphereOverlapResult,ec as Sprite,sf as SpriteData,Na as SpriteRenderer,_v as SpriteSheet,gK as StateMachineBehaviour,lv as SubEmitterSystem,V_ as SyncedCamera,ph as SyncedRoom,Yc as SyncedTransform,JM as TapGestureTrigger,kb as TeleportTarget,gI as TestRunner,vI as TestSimulateUserData,Zr as Text,a_ as TextBuilder,Wg as TextExtension,lr as TextureSheetAnimationModule,za as TiltShiftEffect,a2 as Time,wv as ToneMapping,Eg as TrackHandler,Nn as TrackType,Ui as TrailModule,hp as TransformData,Nu as TransformGizmo,pn as TriggerBuilder,uu as TriggerModel,Y as TypeStore,_p as UIRaycastUtils,fg as UIRootComponent,ao as USDObject,Hn as USDZExporter,ah as USDZText,l_ as USDZUIExtension,dC as Upload_Result,fU as UriSerializer,fp as UsageMarker,B8 as UserJoinedOrLeftRoomModel,Tc as VERSION,Nl as VRUserState,yE as VariantAction,Wi as VelocityOverLifetimeModule,HM as VerticalLayoutGroup,hr as VideoPlayer,ya as ViewDevice,zu as Vignette,zg as VisibilityAction,nc as Voip,J_ as Volume,Tt as VolumeParameter,Rg as VolumeProfile,$ne as WaitForFrames,Az as WaitForSeconds,df as Watch,_g as WebAR,$_ as WebARCameraBackground,xa as WebARSessionRoot,Ct as WebXR,Xc as WebXRAvatar,bs as WebXRController,Ei as WebXREvent,tx as WebXRImageTracking,tc as WebXRImageTrackingModel,Iv as WebXRPlaneTracking,vg as WebXRSync,ju as WebXRTrackedImage,Dn as XRFlag,ix as XRGrabModel,wI as XRGrabRendering,Ob as XRRig,Nm as XRSessionMode,kn as XRState,as as XRStateFlag,SI as __Ignore,oO as __internalNotifyObjectDestroyed,Al as activeInHierarchyFieldName,aR as addAttributeChangeCallback,A7 as addCustomExtension,m3 as addFile,g3 as addFileFromUrl,ile as addGltfLoadEventListener,eu as addNewComponent,dy as addPatch,hy as apply,ple as applyHMRChanges,LD as beginListenDestroy,v3 as beginListenFileSpawn,UD as beginListenInstantiate,b1 as binaryIdentifierCasts,Kq as build_scene_functions,$h as builtinComponentKeyName,DC as calculateProgress01,w7 as colorSerializer,Xy as componentSerializer,i2 as copyTexture,RI as createGLTFLoader,VU as createMotion,jr as debugNet,vm as debugOwner,Zv as deepClone,bf as delay,L0 as deserializeObject,yl as destroy,HD as destroyComponentInstance,GN as detectARSupport,HN as detectVRSupport,Ii as disposeObjectResources,eL as download,fC as download_file,Am as editorGuidKeyName,JT as effectsOrder,T7 as eventListSerializer,Im as findByGuid,XD as findObjectOfType,qD as findObjectsOfType,q1 as findResourceUsers,su as foreachComponent,J1 as foreachComponentEnumerator,F6 as forward,ay as generateSeed,jd as getComponent,xm as getComponentInChildren,Sm as getComponentInParent,_m as getComponents,wm as getComponentsInChildren,cy as getComponentsInParent,qj as getIp,Yj as getIpAndLocation,Xj as getIpCloudflare,Lo as getLoader,ly as getOrAddComponent,le as getParam,Qj as getPath,E8 as getPeerOptions,F1 as getPeerjsInstance,o9 as getResourceUserCount,Af as getUrlParams,z6 as getWorldDirection,Zk as getWorldEuler,At as getWorldPosition,Bs as getWorldQuaternion,N0 as getWorldRotation,js as getWorldScale,IC as hasIndieLicense,Kd as hasProLicense,pC as hash,Rm as instantiate,lO as isActiveInHierarchy,Gd as isActiveSelf,t2 as isAnimationAction,Nj as isDebugMode,K1 as isDestroyed,gi as isDevEnvironment,r9 as isDisposed,uR as isHostedOnGlitch,cle as isHotReloading,Br as isLocalNetwork,Ka as isMobileDevice,eA as isMozillaXR,Vj as isQuest,sO as isResourceTrackingEnabled,Ja as isSafari,Ay as isUsingInstancing,_f as isiOS,PI as loadSync,j0 as logHierarchy,D6 as lookAtInverse,jj as makeId,rR as makeIdFromRandomWords,cO as markAsInstancedRendered,G1 as moveComponentInstance,Fj as nameof,Jv as nameofFactory,dU as objectSerializer,Xz as parseSync,uJ as prefix,eR as pushState,tR as randomNumber,H0 as registerBinaryType,Ny as registerComponent,lE as registerComponentExtension,mo as registerCustomEffectType,cU as registerExtensions,hle as registerHotReloadType,mC as registerLoader,ND as registerPrefabProvider,_6 as registerType,oR as relativePathPrefix,lR as removeAttributeChangeCallback,Q1 as removeComponent,y7 as removeCustomExtension,sle as removeGltfLoadEventListener,t9 as removePatch,Ya as resolveUrl,nR as sanitizeString,Ple as saveImage,Rle as screenshot,OD as sendDestroyed,x as serializable,jk as serializeObject,sp as serializeable,Tm as setActive,Jj as setAllowOverlayMessages,uO as setDestroyed,m6 as setDevEnvironment,X1 as setDisposable,yf as setOrAddParamsToUrl,zj as setParam,$I as setParamWithoutReload,M8 as setPeerOptions,s9 as setResourceTrackingEnabled,Nx as setState,$k as setWorldEuler,ns as setWorldPosition,Fd as setWorldPositionXYZ,ln as setWorldQuaternion,Xk as setWorldQuaternionXYZW,e2 as setWorldRotation,z0 as setWorldRotationXYZ,g1 as setWorldScale,fs as showBalloonMessage,Nr as showBalloonWarning,o1 as showDebugConsole,Wk as slerp,oy as syncDestroy,eI as syncField,z1 as syncInstantiate,Q6 as textureToCanvas,h2 as tryCastBinary,qu as tryFindObject,qz as tryFindObjectByName,rle as tryFindScript,u2 as tryGetGuid,ule as unregisterHotReloadType,$O as upload_file,On as validate};
6612
+ `,this.shadowRoot&&this.shadowRoot.appendChild(e.content.cloneNode(!0)),this._context=new zt({domElement:this}),this.addEventListener("error",this.onError)}static get observedAttributes(){return ole}get loadingProgress01(){return this._loadingProgress01}get loadingFinished(){return this.loadingProgress01>.999}get cameraControls(){const e=this.getAttribute("camera-controls");return!(e===null||e==="False"||e==="false"||e==="0")}getContext(){return new Promise((e,t)=>{if(this._context&&this.loadingFinished)e(this._context);else{const s=()=>{this.removeEventListener("loadfinished",s),this._context&&this.loadingFinished&&e(this._context)};this.addEventListener("loadfinished",s)}})}get context(){return this._context}get Context(){return this._context}async connectedCallback(){if(dr&&console.log("<needle-engine> connected"),this.onSetupDesktop(),!this.getAttribute("src")){const t=globalThis["needle:codegen_files"];t&&(dr&&console.log('globalThis["needle:codegen_files"]',t),this.setAttribute("src",t))}const e=this._loadId;setTimeout(()=>{this.isConnected!==!1&&e===this._loadId&&this.onLoad()},1),Tc!=null&&Tc.length&&this.setAttribute("version",Tc)}disconnectedCallback(){var e;this._didFullyLoad=!1;const t=this.getAttribute("keep-alive");dr&&console.warn("<needle-engine> disconnected, keep-alive:",t),(t===void 0||t!=="true")&&(console.warn("<needle-engine> dispose!"),(e=this._context)==null||e.dispose(),this._context=null,this._lastSourceFiles=null,this._loadId+=1)}attributeChangedCallback(e,t,s){switch(dr&&console.log("attributeChangedCallback",e,t,s),e){case"src":dr&&console.warn("src changed to type:",typeof s,', from "',t,'" to "',s,'"'),this.onLoad();break;case"hash":this._context&&(this._context.hash=s);break;case"loadstart":case"progress":case"loadfinished":typeof s=="string"&&s.length>0&&(dr&&console.log(e+" attribute changed",s),this.registerEventFromAttribute(e,s));break;case"dracoDecoderPath":dr&&console.log("dracoDecoderPath",s),VL(s);break;case"dracoDecoderType":s==="wasm"||s==="js"?(dr&&console.log("dracoDecoderType",s),WL(s)):console.error("Invalid dracoDecoderType",s,"expected js or wasm");break;case"ktx2DecoderPath":dr&&console.log("ktx2DecoderPath",s),XL(s);break}}async onLoad(){var e,t;if(!this.isConnected)return;if(this._context||(dr&&console.warn("Create new context"),this._context=new zt({domElement:this})),!this._context){console.error("Needle Engine: Context not initialized");return}const s=this.getSourceFiles();if(s==null||s.length<=0)dr&&console.warn("Clear scene",s),this._context.clear();else if(!this.checkIfSourceHasChanged(s,this._lastSourceFiles))return;this._lastSourceFiles=s;const r=++this._loadId,n=this.getAttribute("alias");this.classList.add("loading");const o=Jd();this.ensureLoadStartIsRegistered();let a=this.dispatchEvent(new CustomEvent("loadstart",{detail:{context:this._context,alias:n},cancelable:!0}));a===!1&&!o&&(gi()||(a=!0),console.warn("Needle Engine: You need a commercial license to override the default loading view. Visit https://needle.tools/pricing"),gi()&&Nr('You need a <a target="_blank" href="https://needle.tools/pricing">commercial license</a> to override the default loading view. This will not work in production.')),!this._loadingView&&a&&(this._loadingView=new LC(this)),a&&(this._didFullyLoad!==!0?(e=this._loadingView)==null||e.onLoadingBegin("begin load"):setTimeout(()=>{this._loadingView&&this._loadingProgress01<.3&&this._loadId===r&&this._loadingView.onLoadingBegin("begin load")},300)),dr&&console.warn("--------------",r,"Needle Engine: Begin loading",n??"",s),this.onBeforeBeginLoading();const l=[],c={context:this._context,name:"",progress:{},index:0,count:s.length,totalProgress01:this._loadingProgress01},u=new CustomEvent("progress",{detail:c}),d={files:s,onLoadingProgress:f=>{var m;f.name=ale(f.name),a&&((m=this._loadingView)==null||m.onLoadingUpdate(f)),c.name=f.name,c.progress=f.progress,this._loadingProgress01=DC(f),c.totalProgress01=this._loadingProgress01,this.dispatchEvent(u)},onLoadingFinished:(f,m,A)=>{A&&l.push({src:m,file:A})}},p=this.getAttribute("hash");p!=null&&(this._context.hash=p),this._context.alias=n,await this._context.create(d),this._loadId===r&&(dr&&console.warn("--------------",r,"Needle Engine: finished loading",n??"",s),this._loadingProgress01=1,a&&((t=this._loadingView)==null||t.onLoadingUpdate(1,"creating scene")),this._didFullyLoad=!0,this.classList.remove("loading"),this.classList.add("loading-finished"),this.dispatchEvent(new CustomEvent("loadfinished",{detail:{context:this._context,src:n,loadedFiles:l}})))}getSourceFiles(){const e=this.getAttribute("src");if(!e)return[];let t;Array.isArray(e)?t=e:e.startsWith("[")&&e.endsWith("]")?t=JSON.parse(e):e.includes(",")?t=e.split(","):t=[e];for(let s=t.length-1;s>=0;s--){const r=t[s];(r==="null"||r==="undefined"||r?.length<=0)&&t.splice(s,1)}return t}checkIfSourceHasChanged(e,t){if(e?.length!==t?.length||e==null&&t!==null||e!==null&&t==null)return!0;if(e!==null&&t!==null){for(let s=0;s<e?.length;s++)if(e[s]!==t[s])return!0}return!1}ensureLoadStartIsRegistered(){const e=this.getAttribute("loadstart");e&&this.registerEventFromAttribute("loadstart",e)}registerEventFromAttribute(e,t){const s=this._previouslyRegisteredMap.get(e);if(s&&(this._previouslyRegisteredMap.delete(e),this.removeEventListener(e,s)),typeof t=="string"&&t.length>0){const r=(0,eval)(t);typeof r=="function"&&(this._previouslyRegisteredMap.set(e,r),this.addEventListener(e,n=>r?.call(globalThis,this._context,n)))}}getAROverlayContainer(){return this._overlay_ar.createOverlayContainer(this)}getVROverlayContainer(){for(let e=0;e<this.children.length;e++){const t=this.children[e];if(t.classList.contains("vr"))return t}return null}onEnterAR(e,t){var s;this.onSetupAR(),this._overlay_ar.onBegin(this._context,t,e),this.dispatchEvent(new CustomEvent("enter-ar",{detail:{session:e,context:this._context,htmlContainer:(s=this._overlay_ar)==null?void 0:s.ARContainer}}))}onExitAR(e){var t;this._overlay_ar.onEnd(this._context),this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-ar",{detail:{session:e,context:this._context,htmlContainer:(t=this._overlay_ar)==null?void 0:t.ARContainer}}))}onEnterVR(e){this.onSetupVR(),this.dispatchEvent(new CustomEvent("enter-vr",{detail:{session:e,context:this._context}}))}onExitVR(e){this.onSetupDesktop(),this.dispatchEvent(new CustomEvent("exit-vr",{detail:{session:e,context:this._context}}))}onSetupAR(){this.classList.add(Bv),this.classList.remove(kv);const e=this.getAROverlayContainer();dr&&console.warn("onSetupAR:",e),e&&(e.classList.add(Bv),e.classList.remove(kv)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,SL))}onSetupVR(){this.classList.remove(Bv),this.classList.remove(kv),this.foreachHtmlElement(e=>this.setupElementsForMode(e,Kz))}onSetupDesktop(){this.classList.remove(Bv),this.classList.add(kv);const e=this.getAROverlayContainer();e&&(e.classList.remove(Bv),e.classList.add(kv)),this.foreachHtmlElement(t=>this.setupElementsForMode(t,Jz))}setupElementsForMode(e,t,s=null){var r;if(!(e===((r=this._context)==null?void 0:r.renderer.domElement)||e.id==="VRButton"||e.id==="ARButton"))if(e.classList.contains(t))e.style.visibility="visible",e.style.display==="none"&&(e.style.display="block");else for(const n of nle)e.classList.contains(n)&&(e.style.visibility="hidden",e.style.display="none")}foreachHtmlElement(e){for(let t=0;t<this.children.length;t++){const s=this.children[t];s.style&&e(s)}}onBeforeBeginLoading(){const e=this.getAttribute("dracoDecoderPath");e&&(dr&&console.log("using custom draco decoder path",e),VL(e));const t=this.getAttribute("dracoDecoderType");t&&(dr&&console.log("using custom draco decoder type",t),WL(t));const s=this.getAttribute("ktx2DecoderPath");s&&(dr&&console.log("using custom ktx2 decoder path",s),XL(s))}}typeof window<"u"&&!window.customElements.get(Yz)&&window.customElements.define(Yz,BI);function ale(i){const e=i.split("/");let t=e[e.length-1];const s=t.indexOf("?");return s>0&&(t=t.substring(0,s)),decodeURIComponent(t)}const lle=Object.freeze(Object.defineProperty({__proto__:null,NeedleEngineHTMLElement:BI},Symbol.toStringTag,{value:"Module"})),nx=le("debughotreload");let Dv=!1;const Ov=new Map;function cle(){return Dv}function hle(i){var e;if(Dv)return;const t=i.constructor.name;Ov.has(t)?(e=Ov.get(t))==null||e.push(i):Ov.set(t,[i])}function ule(i){if(Dv)return;const e=i.constructor.name,t=Ov.get(e);if(!t)return;const s=t.indexOf(i);s!==-1&&t.splice(s,1)}let Zz=!1;function dle(){if(nx||Zz)return;Zz=!0;const i=console.error;console.error=(...e)=>{if(e.length){const t=e[0];if(typeof t=="string"&&t.includes("[hmr] Failed to reload ")){console.log("[Needle Engine] Hot reloading failed"),window.location.reload();return}}i.apply(console,e)}}function ple(i){nx&&console.log("[HMR] Apply changes",i,Object.keys(i)),dle();for(const e of Object.keys(i))try{Dv=!0;const t=Y.get(e);if(!t){nx&&console.log("[HMR] Type not found: "+e);continue}const s=i[e],r=Ov.get(s.name);let n="[Needle Engine] Updating type: "+e;const o=r?.length??-1;o>0?n+=" x"+o:n+=" - no instances",console.log(n);const a=Object.getOwnPropertyNames(t.prototype),l=Object.getOwnPropertyDescriptors(s.prototype);for(const c in l)l[c].writable&&(t.prototype[c]=i[e].prototype[c]);for(const c of a)l[c]||delete t.prototype[c];if(r){const c=new s,u=Object.getOwnPropertyDescriptors(c);for(const d of r){const p=d,f=p.isComponent===!0,m=f?p.activeAndEnabled:!0,A=f?p.context:void 0;try{if(f&&bl(p,A),f&&m&&(p.enabled=!1),d.onBeforeHotReloadFields&&d.onBeforeHotReloadFields()===!1)continue;for(const v in u)if(u[v].writable){if(d[v]===void 0)d[v]=c[v];else if(typeof d[v]=="function"&&!d[v].prototype){const g=d[v],b=g.name,y="bound ";if(b===y)continue;const _=g.name.substring(y.length),S=s.prototype[_];S&&(d[v]=S.bind(d))}}d.onAfterHotReloadFields&&d.onAfterHotReloadFields()}finally{f&&Z1(p,A),f&&m&&(p.enabled=!0)}}}}catch(t){if(nx)console.error(t);else return!1}finally{Dv=!1,Za(Co.Log,"Script changes applied (HMR)")}return!0}const fle=Symbol("object"),$z=new ra(()=>new w,20);class ej{constructor(e,t,s,r,n){h(this,"_point"),h(this,"_normal"),h(this,"distance"),h(this,"impulse"),h(this,"friction"),this._point=e,this.distance=t,this._normal=s,this.impulse=r,this.friction=n}get point(){return $z.get().set(this._point.x,this._point.y,this._point.z)}get normal(){return $z.get().set(this._normal.x,this._normal.y,this._normal.z)}}class tj{constructor(e,t,s){h(this,"contacts"),h(this,"me"),h(this,"_collider"),h(this,"_gameObject"),this.me=e,this._collider=t,this._gameObject=t.gameObject,this.contacts=s}get collider(){return this._collider}get gameObject(){return this._gameObject}get rigidBody(){var e;return(e=this.collider)==null?void 0:e.attachedRigidbody}}class ij{constructor(e,t){h(this,"object"),h(this,"collider"),this.object=e,this.collider=t}}let ze;const Lv=new Array(32).fill(void 0);Lv.push(void 0,null,!0,!1);let sj;Lv.length;function rj(){return sj.byteLength,sj}const mle=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});function mt(i,e){if(!(i instanceof e))throw new Error(`expected instance of ${e.name}`);return i.ptr}mle.decode();let nj,oj,Uv=32;function aj(i){if(Uv==1)throw new Error("out of js stack");return Lv[--Uv]=i,Uv}function gle(){return nj.byteLength,nj}function vle(){return oj.byteLength,oj}let qn=0;function Hu(i,e){const t=e(4*i.length);return gle().set(i,t/4),qn=i.length,t}function ox(i,e){const t=e(4*i.length);return vle().set(i,t/4),qn=i.length,t}class Ix{static __wrap(e){const t=Object.create(Ix.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_raweventqueue_free(e)}constructor(e){const t=ze.raweventqueue_new(e);return Ix.__wrap(t)}drainCollisionEvents(e){try{ze.raweventqueue_drainCollisionEvents(this.ptr,aj(e))}finally{Lv[Uv++]=void 0}}drainContactForceEvents(e){try{ze.raweventqueue_drainContactForceEvents(this.ptr,aj(e))}finally{Lv[Uv++]=void 0}}clear(){ze.raweventqueue_clear(this.ptr)}}class Xa{static __wrap(e){const t=Object.create(Xa.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawgenericjoint_free(e)}static spherical(e,t){mt(e,ut),mt(t,ut);const s=ze.rawgenericjoint_spherical(e.ptr,t.ptr);return Xa.__wrap(s)}static prismatic(e,t,s,r,n,o){mt(e,ut),mt(t,ut),mt(s,ut);const a=ze.rawgenericjoint_prismatic(e.ptr,t.ptr,s.ptr,r,n,o);return a===0?void 0:Xa.__wrap(a)}static fixed(e,t,s,r){mt(e,ut),mt(t,Ws),mt(s,ut),mt(r,Ws);const n=ze.rawgenericjoint_fixed(e.ptr,t.ptr,s.ptr,r.ptr);return Xa.__wrap(n)}static revolute(e,t,s){mt(e,ut),mt(t,ut),mt(s,ut);const r=ze.rawgenericjoint_revolute(e.ptr,t.ptr,s.ptr);return r===0?void 0:Xa.__wrap(r)}}class WI{static __wrap(e){const t=Object.create(WI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawpointprojection_free(e)}point(){const e=ze.rawpointprojection_point(this.ptr);return ut.__wrap(e)}isInside(){return ze.rawpointprojection_isInside(this.ptr)!==0}}class XI{static __wrap(e){const t=Object.create(XI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawrayintersection_free(e)}normal(){const e=ze.rawrayintersection_normal(this.ptr);return ut.__wrap(e)}toi(){return ze.rawintegrationparameters_dt(this.ptr)}featureType(){return ze.rawrayintersection_featureType(this.ptr)>>>0}featureId(){try{const s=ze.__wbindgen_add_to_stack_pointer(-16);ze.rawrayintersection_featureId(s,this.ptr);var e=rj()[s/4+0],t=rj()[s/4+1];return e===0?void 0:t>>>0}finally{ze.__wbindgen_add_to_stack_pointer(16)}}}class Ws{static __wrap(e){const t=Object.create(Ws.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawrotation_free(e)}constructor(e,t,s,r){const n=ze.rawrotation_new(e,t,s,r);return Ws.__wrap(n)}static identity(){const e=ze.rawrotation_identity();return Ws.__wrap(e)}get x(){return ze.rawintegrationparameters_dt(this.ptr)}get y(){return ze.rawrotation_y(this.ptr)}get z(){return ze.rawintegrationparameters_erp(this.ptr)}get w(){return ze.rawrotation_w(this.ptr)}}class Qt{static __wrap(e){const t=Object.create(Qt.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawshape_free(e)}static cuboid(e,t,s){const r=ze.rawshape_cuboid(e,t,s);return Qt.__wrap(r)}static roundCuboid(e,t,s,r){const n=ze.rawshape_roundCuboid(e,t,s,r);return Qt.__wrap(n)}static ball(e){const t=ze.rawshape_ball(e);return Qt.__wrap(t)}static capsule(e,t){const s=ze.rawshape_capsule(e,t);return Qt.__wrap(s)}static cylinder(e,t){const s=ze.rawshape_cylinder(e,t);return Qt.__wrap(s)}static roundCylinder(e,t,s){const r=ze.rawshape_roundCylinder(e,t,s);return Qt.__wrap(r)}static cone(e,t){const s=ze.rawshape_cone(e,t);return Qt.__wrap(s)}static roundCone(e,t,s){const r=ze.rawshape_roundCone(e,t,s);return Qt.__wrap(r)}static polyline(e,t){const s=Hu(e,ze.__wbindgen_malloc),r=qn,n=ox(t,ze.__wbindgen_malloc),o=qn,a=ze.rawshape_polyline(s,r,n,o);return Qt.__wrap(a)}static trimesh(e,t){const s=Hu(e,ze.__wbindgen_malloc),r=qn,n=ox(t,ze.__wbindgen_malloc),o=qn,a=ze.rawshape_trimesh(s,r,n,o);return Qt.__wrap(a)}static heightfield(e,t,s,r){const n=Hu(s,ze.__wbindgen_malloc),o=qn;mt(r,ut);const a=ze.rawshape_heightfield(e,t,n,o,r.ptr);return Qt.__wrap(a)}static segment(e,t){mt(e,ut),mt(t,ut);const s=ze.rawshape_segment(e.ptr,t.ptr);return Qt.__wrap(s)}static triangle(e,t,s){mt(e,ut),mt(t,ut),mt(s,ut);const r=ze.rawshape_triangle(e.ptr,t.ptr,s.ptr);return Qt.__wrap(r)}static roundTriangle(e,t,s,r){mt(e,ut),mt(t,ut),mt(s,ut);const n=ze.rawshape_roundTriangle(e.ptr,t.ptr,s.ptr,r);return Qt.__wrap(n)}static convexHull(e){const t=Hu(e,ze.__wbindgen_malloc),s=qn,r=ze.rawshape_convexHull(t,s);return r===0?void 0:Qt.__wrap(r)}static roundConvexHull(e,t){const s=Hu(e,ze.__wbindgen_malloc),r=qn,n=ze.rawshape_roundConvexHull(s,r,t);return n===0?void 0:Qt.__wrap(n)}static convexMesh(e,t){const s=Hu(e,ze.__wbindgen_malloc),r=qn,n=ox(t,ze.__wbindgen_malloc),o=qn,a=ze.rawshape_convexMesh(s,r,n,o);return a===0?void 0:Qt.__wrap(a)}static roundConvexMesh(e,t,s){const r=Hu(e,ze.__wbindgen_malloc),n=qn,o=ox(t,ze.__wbindgen_malloc),a=qn,l=ze.rawshape_roundConvexMesh(r,n,o,a,s);return l===0?void 0:Qt.__wrap(l)}castShape(e,t,s,r,n,o,a,l){mt(e,ut),mt(t,Ws),mt(s,ut),mt(r,Qt),mt(n,ut),mt(o,Ws),mt(a,ut);const c=ze.rawshape_castShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr,o.ptr,a.ptr,l);return c===0?void 0:YI.__wrap(c)}intersectsShape(e,t,s,r,n){return mt(e,ut),mt(t,Ws),mt(s,Qt),mt(r,ut),mt(n,Ws),ze.rawshape_intersectsShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr)!==0}contactShape(e,t,s,r,n,o){mt(e,ut),mt(t,Ws),mt(s,Qt),mt(r,ut),mt(n,Ws);const a=ze.rawshape_contactShape(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n.ptr,o);return a===0?void 0:qI.__wrap(a)}containsPoint(e,t,s){return mt(e,ut),mt(t,Ws),mt(s,ut),ze.rawshape_containsPoint(this.ptr,e.ptr,t.ptr,s.ptr)!==0}projectPoint(e,t,s,r){mt(e,ut),mt(t,Ws),mt(s,ut);const n=ze.rawshape_projectPoint(this.ptr,e.ptr,t.ptr,s.ptr,r);return WI.__wrap(n)}intersectsRay(e,t,s,r,n){return mt(e,ut),mt(t,Ws),mt(s,ut),mt(r,ut),ze.rawshape_intersectsRay(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n)!==0}castRay(e,t,s,r,n,o){return mt(e,ut),mt(t,Ws),mt(s,ut),mt(r,ut),ze.rawshape_castRay(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n,o)}castRayAndGetNormal(e,t,s,r,n,o){mt(e,ut),mt(t,Ws),mt(s,ut),mt(r,ut);const a=ze.rawshape_castRayAndGetNormal(this.ptr,e.ptr,t.ptr,s.ptr,r.ptr,n,o);return a===0?void 0:XI.__wrap(a)}}class qI{static __wrap(e){const t=Object.create(qI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawshapecontact_free(e)}distance(){return ze.rawshapecontact_distance(this.ptr)}point1(){const e=ze.rawpointprojection_point(this.ptr);return ut.__wrap(e)}point2(){const e=ze.rawshapecontact_point2(this.ptr);return ut.__wrap(e)}normal1(){const e=ze.rawshapecontact_normal1(this.ptr);return ut.__wrap(e)}normal2(){const e=ze.rawshapecontact_normal2(this.ptr);return ut.__wrap(e)}}class YI{static __wrap(e){const t=Object.create(YI.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawshapetoi_free(e)}toi(){return ze.rawintegrationparameters_dt(this.ptr)}witness1(){const e=ze.rawrayintersection_normal(this.ptr);return ut.__wrap(e)}witness2(){const e=ze.rawshapetoi_witness2(this.ptr);return ut.__wrap(e)}normal1(){const e=ze.rawshapetoi_normal1(this.ptr);return ut.__wrap(e)}normal2(){const e=ze.rawshapetoi_normal2(this.ptr);return ut.__wrap(e)}}class ut{static __wrap(e){const t=Object.create(ut.prototype);return t.ptr=e,t}__destroy_into_raw(){const e=this.ptr;return this.ptr=0,e}free(){const e=this.__destroy_into_raw();ze.__wbg_rawvector_free(e)}static zero(){const e=ze.rawvector_zero();return ut.__wrap(e)}constructor(e,t,s){const r=ze.rawvector_new(e,t,s);return ut.__wrap(r)}get x(){return ze.rawintegrationparameters_dt(this.ptr)}set x(e){ze.rawintegrationparameters_set_dt(this.ptr,e)}get y(){return ze.rawrotation_y(this.ptr)}set y(e){ze.rawvector_set_y(this.ptr,e)}get z(){return ze.rawintegrationparameters_erp(this.ptr)}set z(e){ze.rawintegrationparameters_set_erp(this.ptr,e)}xyz(){const e=ze.rawvector_xyz(this.ptr);return ut.__wrap(e)}yxz(){const e=ze.rawvector_yxz(this.ptr);return ut.__wrap(e)}zxy(){const e=ze.rawvector_zxy(this.ptr);return ut.__wrap(e)}xzy(){const e=ze.rawvector_xzy(this.ptr);return ut.__wrap(e)}yzx(){const e=ze.rawvector_yzx(this.ptr);return ut.__wrap(e)}zyx(){const e=ze.rawvector_zyx(this.ptr);return ut.__wrap(e)}}class Ale{constructor(e,t,s){this.x=e,this.y=t,this.z=s}}class ke{static new(e,t,s){return new Ale(e,t,s)}static intoRaw(e){return new ut(e.x,e.y,e.z)}static zeros(){return ke.new(0,0,0)}static fromRaw(e){if(!e)return null;let t=ke.new(e.x,e.y,e.z);return e.free(),t}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z}}class lj{constructor(e,t,s,r){this.x=e,this.y=t,this.z=s,this.w=r}}class Bi{static identity(){return new lj(0,0,0,1)}static fromRaw(e){if(!e)return null;let t=new lj(e.x,e.y,e.z,e.w);return e.free(),t}static intoRaw(e){return new Ws(e.x,e.y,e.z,e.w)}static copy(e,t){e.x=t.x,e.y=t.y,e.z=t.z,e.w=t.w}}var Fv,Qa,cj,Ao,kI,ri,ax,af,DI,OI,hj,uj;(function(i){i[i.Dynamic=0]="Dynamic",i[i.Fixed=1]="Fixed",i[i.KinematicPositionBased=2]="KinematicPositionBased",i[i.KinematicVelocityBased=3]="KinematicVelocityBased"})(Fv||(Fv={}));class yle{constructor(e,t,s){this.rawSet=e,this.colliderSet=t,this.handle=s}finalizeDeserialization(e){this.colliderSet=e}isValid(){return this.rawSet.contains(this.handle)}lockTranslations(e,t){return this.rawSet.rbLockTranslations(this.handle,e,t)}lockRotations(e,t){return this.rawSet.rbLockRotations(this.handle,e,t)}setEnabledTranslations(e,t,s,r){return this.rawSet.rbSetEnabledTranslations(this.handle,e,t,s,r)}restrictTranslations(e,t,s,r){this.setEnabledTranslations(e,t,s,r)}setEnabledRotations(e,t,s,r){return this.rawSet.rbSetEnabledRotations(this.handle,e,t,s,r)}restrictRotations(e,t,s,r){this.setEnabledRotations(e,t,s,r)}dominanceGroup(){return this.rawSet.rbDominanceGroup(this.handle)}setDominanceGroup(e){this.rawSet.rbSetDominanceGroup(this.handle,e)}enableCcd(e){this.rawSet.rbEnableCcd(this.handle,e)}translation(){let e=this.rawSet.rbTranslation(this.handle);return ke.fromRaw(e)}rotation(){let e=this.rawSet.rbRotation(this.handle);return Bi.fromRaw(e)}nextTranslation(){let e=this.rawSet.rbNextTranslation(this.handle);return ke.fromRaw(e)}nextRotation(){let e=this.rawSet.rbNextRotation(this.handle);return Bi.fromRaw(e)}setTranslation(e,t){this.rawSet.rbSetTranslation(this.handle,e.x,e.y,e.z,t)}setLinvel(e,t){let s=ke.intoRaw(e);this.rawSet.rbSetLinvel(this.handle,s,t),s.free()}gravityScale(){return this.rawSet.rbGravityScale(this.handle)}setGravityScale(e,t){this.rawSet.rbSetGravityScale(this.handle,e,t)}setRotation(e,t){this.rawSet.rbSetRotation(this.handle,e.x,e.y,e.z,e.w,t)}setAngvel(e,t){let s=ke.intoRaw(e);this.rawSet.rbSetAngvel(this.handle,s,t),s.free()}setNextKinematicTranslation(e){this.rawSet.rbSetNextKinematicTranslation(this.handle,e.x,e.y,e.z)}setNextKinematicRotation(e){this.rawSet.rbSetNextKinematicRotation(this.handle,e.x,e.y,e.z,e.w)}linvel(){return ke.fromRaw(this.rawSet.rbLinvel(this.handle))}angvel(){return ke.fromRaw(this.rawSet.rbAngvel(this.handle))}mass(){return this.rawSet.rbMass(this.handle)}sleep(){this.rawSet.rbSleep(this.handle)}wakeUp(){this.rawSet.rbWakeUp(this.handle)}isCcdEnabled(){this.rawSet.rbIsCcdEnabled(this.handle)}numColliders(){return this.rawSet.rbNumColliders(this.handle)}collider(e){return this.colliderSet.get(this.rawSet.rbCollider(this.handle,e))}bodyType(){return this.rawSet.rbBodyType(this.handle)}setBodyType(e){return this.rawSet.rbSetBodyType(this.handle,e)}isSleeping(){return this.rawSet.rbIsSleeping(this.handle)}isMoving(){return this.rawSet.rbIsMoving(this.handle)}isFixed(){return this.rawSet.rbIsFixed(this.handle)}isKinematic(){return this.rawSet.rbIsKinematic(this.handle)}isDynamic(){return this.rawSet.rbIsDynamic(this.handle)}linearDamping(){return this.rawSet.rbLinearDamping(this.handle)}angularDamping(){return this.rawSet.rbAngularDamping(this.handle)}setLinearDamping(e){this.rawSet.rbSetLinearDamping(this.handle,e)}recomputeMassPropertiesFromColliders(){this.rawSet.rbRecomputeMassPropertiesFromColliders(this.handle,this.colliderSet.raw)}setAdditionalMass(e,t){this.rawSet.rbSetAdditionalMass(this.handle,e,t)}setAdditionalMassProperties(e,t,s,r,n){let o=ke.intoRaw(t),a=ke.intoRaw(s),l=Bi.intoRaw(r);this.rawSet.rbSetAdditionalMassProperties(this.handle,e,o,a,l,n),o.free(),a.free(),l.free()}setAngularDamping(e){this.rawSet.rbSetAngularDamping(this.handle,e)}resetForces(e){this.rawSet.rbResetForces(this.handle,e)}resetTorques(e){this.rawSet.rbResetTorques(this.handle,e)}addForce(e,t){const s=ke.intoRaw(e);this.rawSet.rbAddForce(this.handle,s,t),s.free()}applyImpulse(e,t){const s=ke.intoRaw(e);this.rawSet.rbApplyImpulse(this.handle,s,t),s.free()}addTorque(e,t){const s=ke.intoRaw(e);this.rawSet.rbAddTorque(this.handle,s,t),s.free()}applyTorqueImpulse(e,t){const s=ke.intoRaw(e);this.rawSet.rbApplyTorqueImpulse(this.handle,s,t),s.free()}addForceAtPoint(e,t,s){const r=ke.intoRaw(e),n=ke.intoRaw(t);this.rawSet.rbAddForceAtPoint(this.handle,r,n,s),r.free(),n.free()}applyImpulseAtPoint(e,t,s){const r=ke.intoRaw(e),n=ke.intoRaw(t);this.rawSet.rbApplyImpulseAtPoint(this.handle,r,n,s),r.free(),n.free()}}(function(i){i[i.Revolute=0]="Revolute",i[i.Fixed=1]="Fixed",i[i.Prismatic=2]="Prismatic",i[i.Spherical=3]="Spherical"})(Qa||(Qa={})),function(i){i[i.AccelerationBased=0]="AccelerationBased",i[i.ForceBased=1]="ForceBased"}(cj||(cj={}));class mf{constructor(){}static fixed(e,t,s,r){let n=new mf;return n.anchor1=e,n.anchor2=s,n.frame1=t,n.frame2=r,n.jointType=Qa.Fixed,n}static spherical(e,t){let s=new mf;return s.anchor1=e,s.anchor2=t,s.jointType=Qa.Spherical,s}static prismatic(e,t,s){let r=new mf;return r.anchor1=e,r.anchor2=t,r.axis=s,r.jointType=Qa.Prismatic,r}static revolute(e,t,s){let r=new mf;return r.anchor1=e,r.anchor2=t,r.axis=s,r.jointType=Qa.Revolute,r}intoRaw(){let e,t,s=ke.intoRaw(this.anchor1),r=ke.intoRaw(this.anchor2),n=!1,o=0,a=0;switch(this.jointType){case Qa.Fixed:let l=Bi.intoRaw(this.frame1),c=Bi.intoRaw(this.frame2);t=Xa.fixed(s,l,r,c),l.free(),c.free();break;case Qa.Prismatic:e=ke.intoRaw(this.axis),this.limitsEnabled&&(n=!0,o=this.limits[0],a=this.limits[1]),t=Xa.prismatic(s,r,e,n,o,a),e.free();break;case Qa.Spherical:t=Xa.spherical(s,r);break;case Qa.Revolute:e=ke.intoRaw(this.axis),t=Xa.revolute(s,r,e),e.free()}return s.free(),r.free(),t}}(function(i){i[i.Average=0]="Average",i[i.Min=1]="Min",i[i.Multiply=2]="Multiply",i[i.Max=3]="Max"})(Ao||(Ao={}));class Vv{constructor(e,t,s,r,n){this.distance=e,this.point1=t,this.point2=s,this.normal1=r,this.normal2=n}static fromRaw(e){if(!e)return null;const t=new Vv(e.distance(),ke.fromRaw(e.point1()),ke.fromRaw(e.point2()),ke.fromRaw(e.normal1()),ke.fromRaw(e.normal2()));return e.free(),t}}(function(i){i[i.Vertex=0]="Vertex",i[i.Edge=1]="Edge",i[i.Face=2]="Face",i[i.Unknown=3]="Unknown"})(kI||(kI={}));class Rx{constructor(e,t){this.point=e,this.isInside=t}static fromRaw(e){if(!e)return null;const t=new Rx(ke.fromRaw(e.point()),e.isInside());return e.free(),t}}class ble{constructor(e,t){this.origin=e,this.dir=t}pointAt(e){return{x:this.origin.x+this.dir.x*e,y:this.origin.y+this.dir.y*e,z:this.origin.z+this.dir.z*e}}}class Px{constructor(e,t,s,r){this.featureType=kI.Unknown,this.featureId=void 0,this.toi=e,this.normal=t,r!==void 0&&(this.featureId=r),s!==void 0&&(this.featureType=s)}static fromRaw(e){if(!e)return null;const t=new Px(e.toi(),ke.fromRaw(e.normal()),e.featureType(),e.featureId());return e.free(),t}}class Wv{constructor(e,t,s,r,n){this.toi=e,this.witness1=t,this.witness2=s,this.normal1=r,this.normal2=n}static fromRaw(e,t){if(!t)return null;const s=new Wv(t.toi(),ke.fromRaw(t.witness1()),ke.fromRaw(t.witness2()),ke.fromRaw(t.normal1()),ke.fromRaw(t.normal2()));return t.free(),s}}class KI extends Wv{constructor(e,t,s,r,n,o){super(t,s,r,n,o),this.collider=e}static fromRaw(e,t){if(!t)return null;const s=new KI(e.get(t.colliderHandle()),t.toi(),ke.fromRaw(t.witness1()),ke.fromRaw(t.witness2()),ke.fromRaw(t.normal1()),ke.fromRaw(t.normal2()));return t.free(),s}}class pr{static fromRaw(e,t){const s=e.coShapeType(t);let r,n,o,a,l,c;switch(s){case ri.Ball:return new LI(e.coRadius(t));case ri.Cuboid:return r=e.coHalfExtents(t),new dj(r.x,r.y,r.z);case ri.RoundCuboid:return r=e.coHalfExtents(t),n=e.coRoundRadius(t),new pj(r.x,r.y,r.z,n);case ri.Capsule:return l=e.coHalfHeight(t),c=e.coRadius(t),new fj(l,c);case ri.Segment:return o=e.coVertices(t),new mj(ke.new(o[0],o[1],o[2]),ke.new(o[3],o[4],o[5]));case ri.Polyline:return o=e.coVertices(t),a=e.coIndices(t),new Aj(o,a);case ri.Triangle:return o=e.coVertices(t),new gj(ke.new(o[0],o[1],o[2]),ke.new(o[3],o[4],o[5]),ke.new(o[6],o[7],o[8]));case ri.RoundTriangle:return o=e.coVertices(t),n=e.coRoundRadius(t),new vj(ke.new(o[0],o[1],o[2]),ke.new(o[3],o[4],o[5]),ke.new(o[6],o[7],o[8]),n);case ri.TriMesh:return o=e.coVertices(t),a=e.coIndices(t),new yj(o,a);case ri.HeightField:const u=e.coHeightfieldScale(t),d=e.coHeightfieldHeights(t),p=e.coHeightfieldNRows(t),f=e.coHeightfieldNCols(t);return new bj(p,f,d,u);case ri.ConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),new UI(o,a);case ri.RoundConvexPolyhedron:return o=e.coVertices(t),a=e.coIndices(t),n=e.coRoundRadius(t),new FI(o,a,n);case ri.Cylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),new _j(l,c);case ri.RoundCylinder:return l=e.coHalfHeight(t),c=e.coRadius(t),n=e.coRoundRadius(t),new xj(l,c,n);case ri.Cone:return l=e.coHalfHeight(t),c=e.coRadius(t),new wj(l,c);case ri.RoundCone:return l=e.coHalfHeight(t),c=e.coRadius(t),n=e.coRoundRadius(t),new Sj(l,c,n);default:throw new Error("unknown shape type: "+s)}}castShape(e,t,s,r,n,o,a,l){let c=ke.intoRaw(e),u=Bi.intoRaw(t),d=ke.intoRaw(s),p=ke.intoRaw(n),f=Bi.intoRaw(o),m=ke.intoRaw(a),A=this.intoRaw(),v=r.intoRaw(),g=Wv.fromRaw(null,A.castShape(c,u,d,v,p,f,m,l));return c.free(),u.free(),d.free(),p.free(),f.free(),m.free(),A.free(),v.free(),g}intersectsShape(e,t,s,r,n){let o=ke.intoRaw(e),a=Bi.intoRaw(t),l=ke.intoRaw(r),c=Bi.intoRaw(n),u=this.intoRaw(),d=s.intoRaw(),p=u.intersectsShape(o,a,d,l,c);return o.free(),a.free(),l.free(),c.free(),u.free(),d.free(),p}contactShape(e,t,s,r,n,o){let a=ke.intoRaw(e),l=Bi.intoRaw(t),c=ke.intoRaw(r),u=Bi.intoRaw(n),d=this.intoRaw(),p=s.intoRaw(),f=Vv.fromRaw(d.contactShape(a,l,p,c,u,o));return a.free(),l.free(),c.free(),u.free(),d.free(),p.free(),f}containsPoint(e,t,s){let r=ke.intoRaw(e),n=Bi.intoRaw(t),o=ke.intoRaw(s),a=this.intoRaw(),l=a.containsPoint(r,n,o);return r.free(),n.free(),o.free(),a.free(),l}projectPoint(e,t,s,r){let n=ke.intoRaw(e),o=Bi.intoRaw(t),a=ke.intoRaw(s),l=this.intoRaw(),c=Rx.fromRaw(l.projectPoint(n,o,a,r));return n.free(),o.free(),a.free(),l.free(),c}intersectsRay(e,t,s,r){let n=ke.intoRaw(t),o=Bi.intoRaw(s),a=ke.intoRaw(e.origin),l=ke.intoRaw(e.dir),c=this.intoRaw(),u=c.intersectsRay(n,o,a,l,r);return n.free(),o.free(),a.free(),l.free(),c.free(),u}castRay(e,t,s,r,n){let o=ke.intoRaw(t),a=Bi.intoRaw(s),l=ke.intoRaw(e.origin),c=ke.intoRaw(e.dir),u=this.intoRaw(),d=u.castRay(o,a,l,c,r,n);return o.free(),a.free(),l.free(),c.free(),u.free(),d}castRayAndGetNormal(e,t,s,r,n){let o=ke.intoRaw(t),a=Bi.intoRaw(s),l=ke.intoRaw(e.origin),c=ke.intoRaw(e.dir),u=this.intoRaw(),d=Px.fromRaw(u.castRayAndGetNormal(o,a,l,c,r,n));return o.free(),a.free(),l.free(),c.free(),u.free(),d}}(function(i){i[i.Ball=0]="Ball",i[i.Cuboid=1]="Cuboid",i[i.Capsule=2]="Capsule",i[i.Segment=3]="Segment",i[i.Polyline=4]="Polyline",i[i.Triangle=5]="Triangle",i[i.TriMesh=6]="TriMesh",i[i.HeightField=7]="HeightField",i[i.ConvexPolyhedron=9]="ConvexPolyhedron",i[i.Cylinder=10]="Cylinder",i[i.Cone=11]="Cone",i[i.RoundCuboid=12]="RoundCuboid",i[i.RoundTriangle=13]="RoundTriangle",i[i.RoundCylinder=14]="RoundCylinder",i[i.RoundCone=15]="RoundCone",i[i.RoundConvexPolyhedron=16]="RoundConvexPolyhedron"})(ri||(ri={}));class LI extends pr{constructor(e){super(),this.type=ri.Ball,this.radius=e}intoRaw(){return Qt.ball(this.radius)}}class dj extends pr{constructor(e,t,s){super(),this.type=ri.Cuboid,this.halfExtents=ke.new(e,t,s)}intoRaw(){return Qt.cuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z)}}class pj extends pr{constructor(e,t,s,r){super(),this.type=ri.RoundCuboid,this.halfExtents=ke.new(e,t,s),this.borderRadius=r}intoRaw(){return Qt.roundCuboid(this.halfExtents.x,this.halfExtents.y,this.halfExtents.z,this.borderRadius)}}class fj extends pr{constructor(e,t){super(),this.type=ri.Capsule,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.capsule(this.halfHeight,this.radius)}}class mj extends pr{constructor(e,t){super(),this.type=ri.Segment,this.a=e,this.b=t}intoRaw(){let e=ke.intoRaw(this.a),t=ke.intoRaw(this.b),s=Qt.segment(e,t);return e.free(),t.free(),s}}class gj extends pr{constructor(e,t,s){super(),this.type=ri.Triangle,this.a=e,this.b=t,this.c=s}intoRaw(){let e=ke.intoRaw(this.a),t=ke.intoRaw(this.b),s=ke.intoRaw(this.c),r=Qt.triangle(e,t,s);return e.free(),t.free(),s.free(),r}}class vj extends pr{constructor(e,t,s,r){super(),this.type=ri.RoundTriangle,this.a=e,this.b=t,this.c=s,this.borderRadius=r}intoRaw(){let e=ke.intoRaw(this.a),t=ke.intoRaw(this.b),s=ke.intoRaw(this.c),r=Qt.roundTriangle(e,t,s,this.borderRadius);return e.free(),t.free(),s.free(),r}}class Aj extends pr{constructor(e,t){super(),this.type=ri.Polyline,this.vertices=e,this.indices=t??new Uint32Array(0)}intoRaw(){return Qt.polyline(this.vertices,this.indices)}}class yj extends pr{constructor(e,t){super(),this.type=ri.TriMesh,this.vertices=e,this.indices=t}intoRaw(){return Qt.trimesh(this.vertices,this.indices)}}class UI extends pr{constructor(e,t){super(),this.type=ri.ConvexPolyhedron,this.vertices=e,this.indices=t}intoRaw(){return this.indices?Qt.convexMesh(this.vertices,this.indices):Qt.convexHull(this.vertices)}}class FI extends pr{constructor(e,t,s){super(),this.type=ri.RoundConvexPolyhedron,this.vertices=e,this.indices=t,this.borderRadius=s}intoRaw(){return this.indices?Qt.roundConvexMesh(this.vertices,this.indices,this.borderRadius):Qt.roundConvexHull(this.vertices,this.borderRadius)}}class bj extends pr{constructor(e,t,s,r){super(),this.type=ri.HeightField,this.nrows=e,this.ncols=t,this.heights=s,this.scale=r}intoRaw(){let e=ke.intoRaw(this.scale),t=Qt.heightfield(this.nrows,this.ncols,this.heights,e);return e.free(),t}}class _j extends pr{constructor(e,t){super(),this.type=ri.Cylinder,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.cylinder(this.halfHeight,this.radius)}}class xj extends pr{constructor(e,t,s){super(),this.type=ri.RoundCylinder,this.borderRadius=s,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.roundCylinder(this.halfHeight,this.radius,this.borderRadius)}}class wj extends pr{constructor(e,t){super(),this.type=ri.Cone,this.halfHeight=e,this.radius=t}intoRaw(){return Qt.cone(this.halfHeight,this.radius)}}class Sj extends pr{constructor(e,t,s){super(),this.type=ri.RoundCone,this.halfHeight=e,this.radius=t,this.borderRadius=s}intoRaw(){return Qt.roundCone(this.halfHeight,this.radius,this.borderRadius)}}(function(i){i[i.DYNAMIC_DYNAMIC=1]="DYNAMIC_DYNAMIC",i[i.DYNAMIC_KINEMATIC=12]="DYNAMIC_KINEMATIC",i[i.DYNAMIC_FIXED=2]="DYNAMIC_FIXED",i[i.KINEMATIC_KINEMATIC=52224]="KINEMATIC_KINEMATIC",i[i.KINEMATIC_FIXED=8704]="KINEMATIC_FIXED",i[i.FIXED_FIXED=32]="FIXED_FIXED",i[i.DEFAULT=15]="DEFAULT",i[i.ALL=60943]="ALL"})(ax||(ax={}));class _le{constructor(e,t,s,r){this.colliderSet=e,this.handle=t,this._parent=s,this._shape=r}finalizeDeserialization(e){this.handle!=null&&(this._parent=e.get(this.colliderSet.raw.coParent(this.handle)))}ensureShapeIsCached(){this._shape||(this._shape=pr.fromRaw(this.colliderSet.raw,this.handle))}get shape(){return this.ensureShapeIsCached(),this._shape}isValid(){return this.colliderSet.raw.contains(this.handle)}translation(){return ke.fromRaw(this.colliderSet.raw.coTranslation(this.handle))}rotation(){return Bi.fromRaw(this.colliderSet.raw.coRotation(this.handle))}isSensor(){return this.colliderSet.raw.coIsSensor(this.handle)}setSensor(e){this.colliderSet.raw.coSetSensor(this.handle,e)}setShape(e){let t=e.intoRaw();this.colliderSet.raw.coSetShape(this.handle,t),t.free(),this._shape=e}setRestitution(e){this.colliderSet.raw.coSetRestitution(this.handle,e)}setFriction(e){this.colliderSet.raw.coSetFriction(this.handle,e)}frictionCombineRule(){return this.colliderSet.raw.coFrictionCombineRule(this.handle)}setFrictionCombineRule(e){this.colliderSet.raw.coSetFrictionCombineRule(this.handle,e)}restitutionCombineRule(){return this.colliderSet.raw.coRestitutionCombineRule(this.handle)}setRestitutionCombineRule(e){this.colliderSet.raw.coSetRestitutionCombineRule(this.handle,e)}setCollisionGroups(e){this.colliderSet.raw.coSetCollisionGroups(this.handle,e)}setSolverGroups(e){this.colliderSet.raw.coSetSolverGroups(this.handle,e)}activeHooks(){return this.colliderSet.raw.coActiveHooks(this.handle)}setActiveHooks(e){this.colliderSet.raw.coSetActiveHooks(this.handle,e)}activeEvents(){return this.colliderSet.raw.coActiveEvents(this.handle)}setActiveEvents(e){this.colliderSet.raw.coSetActiveEvents(this.handle,e)}activeCollisionTypes(){return this.colliderSet.raw.coActiveCollisionTypes(this.handle)}setContactForceEventThreshold(e){return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle,e)}contactForceEventThreshold(){return this.colliderSet.raw.coContactForceEventThreshold(this.handle)}setActiveCollisionTypes(e){this.colliderSet.raw.coSetActiveCollisionTypes(this.handle,e)}setDensity(e){this.colliderSet.raw.coSetDensity(this.handle,e)}setMass(e){this.colliderSet.raw.coSetMass(this.handle,e)}setMassProperties(e,t,s,r){let n=ke.intoRaw(t),o=ke.intoRaw(s),a=Bi.intoRaw(r);this.colliderSet.raw.coSetMassProperties(this.handle,e,n,o,a),n.free(),o.free(),a.free()}setTranslation(e){this.colliderSet.raw.coSetTranslation(this.handle,e.x,e.y,e.z)}setTranslationWrtParent(e){this.colliderSet.raw.coSetTranslationWrtParent(this.handle,e.x,e.y,e.z)}setRotation(e){this.colliderSet.raw.coSetRotation(this.handle,e.x,e.y,e.z,e.w)}setRotationWrtParent(e){this.colliderSet.raw.coSetRotationWrtParent(this.handle,e.x,e.y,e.z,e.w)}shapeType(){return this.colliderSet.raw.coShapeType(this.handle)}halfExtents(){return ke.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle))}radius(){return this.colliderSet.raw.coRadius(this.handle)}roundRadius(){return this.colliderSet.raw.coRoundRadius(this.handle)}halfHeight(){return this.colliderSet.raw.coHalfHeight(this.handle)}vertices(){return this.colliderSet.raw.coVertices(this.handle)}indices(){return this.colliderSet.raw.coIndices(this.handle)}heightfieldHeights(){return this.colliderSet.raw.coHeightfieldHeights(this.handle)}heightfieldScale(){let e=this.colliderSet.raw.coHeightfieldScale(this.handle);return ke.fromRaw(e)}heightfieldNRows(){return this.colliderSet.raw.coHeightfieldNRows(this.handle)}heightfieldNCols(){return this.colliderSet.raw.coHeightfieldNCols(this.handle)}parent(){return this._parent}friction(){return this.colliderSet.raw.coFriction(this.handle)}restitution(){return this.colliderSet.raw.coRestitution(this.handle)}density(){return this.colliderSet.raw.coDensity(this.handle)}mass(){return this.colliderSet.raw.coMass(this.handle)}volume(){return this.colliderSet.raw.coVolume(this.handle)}collisionGroups(){return this.colliderSet.raw.coCollisionGroups(this.handle)}solverGroups(){return this.colliderSet.raw.coSolverGroups(this.handle)}containsPoint(e){let t=ke.intoRaw(e),s=this.colliderSet.raw.coContainsPoint(this.handle,t);return t.free(),s}projectPoint(e,t){let s=ke.intoRaw(e),r=Rx.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle,s,t));return s.free(),r}intersectsRay(e,t){let s=ke.intoRaw(e.origin),r=ke.intoRaw(e.dir),n=this.colliderSet.raw.coIntersectsRay(this.handle,s,r,t);return s.free(),r.free(),n}castShape(e,t,s,r,n,o){let a=ke.intoRaw(e),l=ke.intoRaw(s),c=Bi.intoRaw(r),u=ke.intoRaw(n),d=t.intoRaw(),p=Wv.fromRaw(this.colliderSet,this.colliderSet.raw.coCastShape(this.handle,a,d,l,c,u,o));return a.free(),l.free(),c.free(),u.free(),d.free(),p}castCollider(e,t,s,r){let n=ke.intoRaw(e),o=ke.intoRaw(s),a=KI.fromRaw(this.colliderSet,this.colliderSet.raw.coCastCollider(this.handle,n,t.handle,o,r));return n.free(),o.free(),a}intersectsShape(e,t,s){let r=ke.intoRaw(t),n=Bi.intoRaw(s),o=e.intoRaw(),a=this.colliderSet.raw.coIntersectsShape(this.handle,o,r,n);return r.free(),n.free(),o.free(),a}contactShape(e,t,s,r){let n=ke.intoRaw(t),o=Bi.intoRaw(s),a=e.intoRaw(),l=Vv.fromRaw(this.colliderSet.raw.coContactShape(this.handle,a,n,o,r));return n.free(),o.free(),a.free(),l}contactCollider(e,t){return Vv.fromRaw(this.colliderSet.raw.coContactCollider(this.handle,e.handle,t))}castRay(e,t,s){let r=ke.intoRaw(e.origin),n=ke.intoRaw(e.dir),o=this.colliderSet.raw.coCastRay(this.handle,r,n,t,s);return r.free(),n.free(),o}castRayAndGetNormal(e,t,s){let r=ke.intoRaw(e.origin),n=ke.intoRaw(e.dir),o=Px.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle,r,n,t,s));return r.free(),n.free(),o}}(function(i){i[i.Density=0]="Density",i[i.Mass=1]="Mass",i[i.MassProps=2]="MassProps"})(af||(af={}));class zi{constructor(e){this.shape=e,this.massPropsMode=af.Density,this.density=1,this.friction=.5,this.restitution=0,this.rotation=Bi.identity(),this.translation=ke.zeros(),this.isSensor=!1,this.collisionGroups=4294967295,this.solverGroups=4294967295,this.frictionCombineRule=Ao.Average,this.restitutionCombineRule=Ao.Average,this.activeCollisionTypes=ax.DEFAULT,this.activeEvents=0,this.activeHooks=0,this.mass=0,this.centerOfMass=ke.zeros(),this.contactForceEventThreshold=0,this.principalAngularInertia=ke.zeros(),this.angularInertiaLocalFrame=Bi.identity()}static ball(e){const t=new LI(e);return new zi(t)}static capsule(e,t){const s=new fj(e,t);return new zi(s)}static segment(e,t){const s=new mj(e,t);return new zi(s)}static triangle(e,t,s){const r=new gj(e,t,s);return new zi(r)}static roundTriangle(e,t,s,r){const n=new vj(e,t,s,r);return new zi(n)}static polyline(e,t){const s=new Aj(e,t);return new zi(s)}static trimesh(e,t){const s=new yj(e,t);return new zi(s)}static cuboid(e,t,s){const r=new dj(e,t,s);return new zi(r)}static roundCuboid(e,t,s,r){const n=new pj(e,t,s,r);return new zi(n)}static heightfield(e,t,s,r){const n=new bj(e,t,s,r);return new zi(n)}static cylinder(e,t){const s=new _j(e,t);return new zi(s)}static roundCylinder(e,t,s){const r=new xj(e,t,s);return new zi(r)}static cone(e,t){const s=new wj(e,t);return new zi(s)}static roundCone(e,t,s){const r=new Sj(e,t,s);return new zi(r)}static convexHull(e){const t=new UI(e,null);return new zi(t)}static convexMesh(e,t){const s=new UI(e,t);return new zi(s)}static roundConvexHull(e,t){const s=new FI(e,null,t);return new zi(s)}static roundConvexMesh(e,t,s){const r=new FI(e,t,s);return new zi(r)}setTranslation(e,t,s){if(typeof e!="number"||typeof t!="number"||typeof s!="number")throw TypeError("The translation components must be numbers.");return this.translation={x:e,y:t,z:s},this}setRotation(e){return Bi.copy(this.rotation,e),this}setSensor(e){return this.isSensor=e,this}setDensity(e){return this.massPropsMode=af.Density,this.density=e,this}setMass(e){return this.massPropsMode=af.Mass,this.mass=e,this}setMassProperties(e,t,s,r){return this.massPropsMode=af.MassProps,this.mass=e,ke.copy(this.centerOfMass,t),ke.copy(this.principalAngularInertia,s),Bi.copy(this.angularInertiaLocalFrame,r),this}setRestitution(e){return this.restitution=e,this}setFriction(e){return this.friction=e,this}setFrictionCombineRule(e){return this.frictionCombineRule=e,this}setRestitutionCombineRule(e){return this.restitutionCombineRule=e,this}setCollisionGroups(e){return this.collisionGroups=e,this}setSolverGroups(e){return this.solverGroups=e,this}setActiveHooks(e){return this.activeHooks=e,this}setActiveEvents(e){return this.activeEvents=e,this}setActiveCollisionTypes(e){return this.activeCollisionTypes=e,this}setContactForceEventThreshold(e){return this.contactForceEventThreshold=e,this}}(function(i){i[i.EXCLUDE_FIXED=1]="EXCLUDE_FIXED",i[i.EXCLUDE_KINEMATIC=2]="EXCLUDE_KINEMATIC",i[i.EXCLUDE_DYNAMIC=4]="EXCLUDE_DYNAMIC",i[i.EXCLUDE_SENSORS=8]="EXCLUDE_SENSORS",i[i.EXCLUDE_SOLIDS=16]="EXCLUDE_SOLIDS",i[i.ONLY_DYNAMIC=3]="ONLY_DYNAMIC",i[i.ONLY_KINEMATIC=5]="ONLY_KINEMATIC",i[i.ONLY_FIXED=6]="ONLY_FIXED"})(DI||(DI={})),function(i){i[i.COLLISION_EVENTS=1]="COLLISION_EVENTS",i[i.CONTACT_FORCE_EVENTS=2]="CONTACT_FORCE_EVENTS"}(OI||(OI={}));class xle{free(){this.raw.free(),this.raw=void 0}collider1(){return this.raw.collider1()}collider2(){return this.raw.collider2()}totalForce(){return ke.fromRaw(this.raw.total_force())}totalForceMagnitude(){return this.raw.total_force_magnitude()}maxForceDirection(){return ke.fromRaw(this.raw.max_force_direction())}maxForceMagnitude(){return this.raw.max_force_magnitude()}}class wle{constructor(e,t){this.raw=t||new Ix(e)}free(){this.raw.free(),this.raw=void 0}drainCollisionEvents(e){this.raw.drainCollisionEvents(e)}drainContactForceEvents(e){let t=new xle;this.raw.drainContactForceEvents(s=>{t.raw=s,e(t),t.free()})}clear(){this.raw.clear()}}(function(i){i[i.FILTER_CONTACT_PAIRS=1]="FILTER_CONTACT_PAIRS",i[i.FILTER_INTERSECTION_PAIRS=2]="FILTER_INTERSECTION_PAIRS"})(hj||(hj={})),function(i){i[i.EMPTY=0]="EMPTY",i[i.COMPUTE_IMPULSE=1]="COMPUTE_IMPULSE"}(uj||(uj={}));for(var Gle={byteLength:function(i){var e=Cj(i),t=e[0],s=e[1];return 3*(t+s)/4-s},toByteArray:function(i){var e,t,s=Cj(i),r=s[0],n=s[1],o=new Sle(function(c,u,d){return 3*(u+d)/4-d}(0,r,n)),a=0,l=n>0?r-4:r;for(t=0;t<l;t+=4)e=yo[i.charCodeAt(t)]<<18|yo[i.charCodeAt(t+1)]<<12|yo[i.charCodeAt(t+2)]<<6|yo[i.charCodeAt(t+3)],o[a++]=e>>16&255,o[a++]=e>>8&255,o[a++]=255&e;return n===2&&(e=yo[i.charCodeAt(t)]<<2|yo[i.charCodeAt(t+1)]>>4,o[a++]=255&e),n===1&&(e=yo[i.charCodeAt(t)]<<10|yo[i.charCodeAt(t+1)]<<4|yo[i.charCodeAt(t+2)]>>2,o[a++]=e>>8&255,o[a++]=255&e),o},fromByteArray:function(i){for(var e,t=i.length,s=t%3,r=[],n=16383,o=0,a=t-s;o<a;o+=n)r.push(Ele(i,o,o+n>a?a:o+n));return s===1?(e=i[t-1],r.push(Ga[e>>2]+Ga[e<<4&63]+"==")):s===2&&(e=(i[t-2]<<8)+i[t-1],r.push(Ga[e>>10]+Ga[e>>4&63]+Ga[e<<2&63]+"=")),r.join("")}},Ga=[],yo=[],Sle=typeof Uint8Array<"u"?Uint8Array:Array,NI="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lf=0,Cle=NI.length;lf<Cle;++lf)Ga[lf]=NI[lf],yo[NI.charCodeAt(lf)]=lf;function Cj(i){var e=i.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=i.indexOf("=");return t===-1&&(t=e),[t,t===e?0:4-t%4]}function Ele(i,e,t){for(var s,r,n=[],o=e;o<t;o+=3)s=(i[o]<<16&16711680)+(i[o+1]<<8&65280)+(255&i[o+2]),n.push(Ga[(r=s)>>18&63]+Ga[r>>12&63]+Ga[r>>6&63]+Ga[63&r]);return n.join("")}yo["-".charCodeAt(0)]=62,yo["_".charCodeAt(0)]=63;const en=le("debugphysics"),zI=le("debugcolliderplacement"),jI=le("debugcollisions"),Mle=le("showcolliders"),bo=Symbol("needle component"),ta=Symbol("physics body"),Tle=Symbol("rigidbody");let cf;globalThis.false=globalThis.false!==void 0?globalThis.false:!0,en&&console.log("Use Rapier",!1,globalThis.false);const lx=class{constructor(){h(this,"debugRenderColliders",!1),h(this,"context"),h(this,"_initializePromise"),h(this,"_isInitialized",!1),h(this,"rapierRay",new ble({x:0,y:0,z:0},{x:0,y:0,z:1})),h(this,"raycastVectorsBuffer",new ra(()=>new w,10)),h(this,"rapierSphere",null),h(this,"rapierColliderArray",[]),h(this,"rapierIdentityRotation",{x:0,y:0,z:0,w:1}),h(this,"rapierForwardVector",{x:0,y:0,z:1}),h(this,"enabled",!1),h(this,"_tempPosition",new w),h(this,"_tempQuaternion",new Ee),h(this,"_tempScale",new w),h(this,"_tempMatrix",new Be),h(this,"_isUpdatingPhysicsWorld",!1),h(this,"world"),h(this,"_hasCreatedWorld",!1),h(this,"eventQueue"),h(this,"collisionHandler"),h(this,"objects",[]),h(this,"bodies",[]),h(this,"_meshCache",new Map),h(this,"_gravity",{x:0,y:-9.81,z:0}),h(this,"lines")}removeBody(i){var e,t;if(!i)return;this.validate();const s=i[ta];if(i[ta]=null,s&&this.world){const r=this.objects.findIndex(n=>n===i);if(r>=0){const n=this.bodies[r];if(this.bodies.splice(r,1),this.objects.splice(r,1),n instanceof _le){const o=n;(e=this.world)==null||e.removeCollider(o,!0);const a=o.parent();if(a&&a.numColliders()<=0){const l=a[bo];this.removeBody(l)}}else n instanceof yle&&(n.numColliders()<=0?(t=this.world)==null||t.removeRigidBody(n):gi()&&(n.did_log_removing||setTimeout(()=>{n.numColliders()>0&&(n.did_log_removing=!0,console.warn("RapierPhysics: removing rigidbody with colliders from the physics world is not possible right now, please remove the colliders first"))},1)))}}}updateBody(i,e,t){if(this.validate(),!!this.enabled&&!(i.destroyed||!i.gameObject)&&!(!e&&!t))if(i.isCollider===!0)console.warn("TODO: implement updating collider position");else{const s=i,r=s[ta];r&&this.syncPhysicsBody(s.gameObject,r,e,t)}}updateProperties(i){this.validate();const e=this.internal_getRigidbody(i);e&&this.internalUpdateProperties(i,e)}addForce(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.addForce(e,t)}addImpulse(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.applyImpulse(e,t)}getLinearVelocity(i){this.validate();const e=this.internal_getRigidbody(i);return e?e.linvel():null}getAngularVelocity(i){this.validate();const e=this.internal_getRigidbody(i);return e?e.angvel():null}resetForces(i,e){this.validate();const t=this.internal_getRigidbody(i);t?.resetForces(e)}resetTorques(i,e){this.validate();const t=this.internal_getRigidbody(i);t?.resetTorques(e)}applyImpulse(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.applyImpulse(e,t)}wakeup(i){this.validate();const e=this.internal_getRigidbody(i);e?.wakeUp()}setAngularVelocity(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.setAngvel(e,t)}setLinearVelocity(i,e,t){this.validate();const s=this.internal_getRigidbody(i);s?.setLinvel(e,t)}async initialize(i){return this.context=i,this._initializePromise||(this._initializePromise=this.internalInitialization()),this._initializePromise}async internalInitialization(){return en&&console.log("Initialize rapier physics engine"),"env"in import.meta&&{}.VITE_NEEDLE_USE_RAPIER==="false"&&en&&console.log("Rapier disabled"),!1}validate(){this._isInitialized||en&&(this._lastWarnTime=this._lastWarnTime??0,Date.now()-this._lastWarnTime>1e3&&(this._lastWarnTime=Date.now(),console.warn("Physics engine is not initialized")))}raycast(i,e,t,s){var r;t===void 0&&(t=1/0),s===void 0&&(s=!0);const n=this.getPhysicsRay(this.rapierRay,i,e);if(!n)return null;const o=(r=this.world)==null?void 0:r.castRay(n,t,s,void 0,void 0,void 0,void 0,a=>{var l;return!((l=a[bo])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const a=n.pointAt(o.toi),l=this.raycastVectorsBuffer.get();return l.set(a.x,a.y,a.z),{point:l,collider:o.collider[bo]}}return null}raycastAndGetNormal(i,e,t,s){var r;t===void 0&&(t=1/0),s===void 0&&(s=!0);const n=this.getPhysicsRay(this.rapierRay,i,e);if(!n)return null;const o=(r=this.world)==null?void 0:r.castRayAndGetNormal(n,t,s,void 0,void 0,void 0,void 0,a=>{var l;return!((l=a[bo])!=null&&l.gameObject.layers.isEnabled(2))});if(o){const a=n.pointAt(o.toi),l=o.normal,c=this.raycastVectorsBuffer.get(),u=this.raycastVectorsBuffer.get();return c.set(a.x,a.y,a.z),u.set(l.x,l.y,l.z),{point:c,normal:u,collider:o.collider[bo]}}return null}getPhysicsRay(i,e,t){var s,r,n;const o=(s=this.context)==null?void 0:s.mainCamera;if(e===void 0){const c=(r=this.context)==null?void 0:r.input.getPointerPosition(0);if(c)e=c;else return null}if(e.z===void 0){if(!o)return console.error("Can not perform raycast from 2d point - no main camera found"),null;const c=this.raycastVectorsBuffer.get();c.x=e.x,c.y=e.y,c.z=0,(c.x>1||c.y>1||c.y<-1||c.x<-1)&&(en&&console.warn("Converting screenspace to raycast space",c),(n=this.context)==null||n.input.convertScreenspaceToRaycastSpace(c)),c.unproject(o),e=c}const a=e;i.origin.x=a.x,i.origin.y=a.y,i.origin.z=a.z;const l=this.raycastVectorsBuffer.get();if(t)l.set(t.x,t.y,t.z);else{if(!o)return console.error("Can not perform raycast - no camera found"),null;l.set(i.origin.x,i.origin.y,i.origin.z);const c=At(o);l.sub(c)}return l.normalize(),i.dir.x=l.x,i.dir.y=l.y,i.dir.z=l.z,i}sphereOverlap(i,e){return this.rapierColliderArray.length=0,this.world?(this.rapierSphere||(this.rapierSphere=new LI(e)),this.rapierSphere.radius=e,this.world.intersectionsWithShape(i,this.rapierIdentityRotation,this.rapierSphere,t=>{const s=t[bo],r=new ij(s.gameObject,s);return this.rapierColliderArray.push(r),!0},DI.EXCLUDE_SENSORS,void 0,void 0,void 0,t=>t[bo].gameObject.layers.isEnabled(2)==!1),this.rapierColliderArray):this.rapierColliderArray}get isUpdating(){return this._isUpdatingPhysicsWorld}get gravity(){var i;return((i=this.world)==null?void 0:i.gravity)??this._gravity}set gravity(i){this.world?this.world.gravity=i:this._gravity=i}clearCaches(){var i,e,t,s;this._meshCache.clear(),(i=this.eventQueue)!=null&&i.raw&&((e=this.eventQueue)==null||e.free()),(t=this.world)!=null&&t.bodies&&((s=this.world)==null||s.free())}async addBoxCollider(i,e,t){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){en&&console.warn("Physics are disabled");return}const s=i.gameObject,r=js(s,this._tempPosition).multiply(t);r.multiplyScalar(.5),r.x<0&&(r.x=Math.abs(r.x)),r.y<0&&(r.y=Math.abs(r.y)),r.z<0&&(r.z=Math.abs(r.z)),r.x==0&&(r.x=1e-7),r.y==0&&(r.y=1e-7),r.z==0&&(r.z=1e-7);const n=zi.cuboid(r.x,r.y,r.z);this.createCollider(i,n,e)}async addSphereCollider(i,e,t){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){en&&console.warn("Physics are disabled");return}const s=i.gameObject,r=js(s,this._tempPosition).multiplyScalar(t);r.x=Math.abs(r.x);const n=zi.ball(r.x);this.createCollider(i,n,e)}async addCapsuleCollider(i,e,t,s){if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){en&&console.warn("Physics are disabled");return}const r=i.gameObject,n=js(r,this._tempPosition);n.x=Math.abs(n.x),n.y=Math.abs(n.y);const o=zi.capsule(t*.5*n.y-s,s*n.x);this.createCollider(i,o,e)}async addMeshCollider(i,e,t,s){var r,n,o;if(this._isInitialized||await this.initialize(i.context),!i.activeAndEnabled)return;if(!this.enabled){en&&console.warn("Physics are disabled");return}let a=e.geometry;if(!a){en&&console.warn("Missing mesh geometry",e.name);return}(n=(r=a.index)==null?void 0:r.array)!=null&&n.length||(console.warn(`Your MeshCollider is missing vertices or indices in the assined mesh "${e.name}". Consider providing an indexed geometry.`),a=CY(a));let l=a.getAttribute("position").array;const c=(o=a.index)==null?void 0:o.array;if(Math.abs(s.x-1)>1e-4||Math.abs(s.y-1)>1e-4||Math.abs(s.z-1)>1e-4){const d=a.uuid+"_"+s.x+"_"+s.y+"_"+s.z+"_"+t;if(this._meshCache.has(d))en&&console.warn("Use cached mesh collider"),l=this._meshCache.get(d);else{console.warn("Your model is using scaled mesh colliders which is not optimal for performance",e.name,Object.assign({},s));const p=new Float32Array(l.length);for(let f=0;f<l.length;f+=3)p[f]=l[f]*s.x,p[f+1]=l[f+1]*s.y,p[f+2]=l[f+2]*s.z;l=p,this._meshCache.set(d,p)}}const u=t?zi.convexMesh(l):zi.trimesh(l,c);u&&this.createCollider(i,u).setMassProperties(1,{x:0,y:0,z:0},{x:0,y:0,z:0},{x:0,y:0,z:0,w:1})}createCollider(i,e,t){if(!this.world)throw new Error("Physics world not initialized");const s=this._tempMatrix,{rigidBody:r,useExplicitMassProperties:n}=this.getRigidbody(i,this._tempMatrix);s.decompose(this._tempPosition,this._tempQuaternion,this._tempScale),js(i.gameObject,this._tempScale),t&&(t.multiply(this._tempScale),this._tempPosition.x-=t.x,this._tempPosition.y+=t.y,this._tempPosition.z+=t.z),e.setTranslation(this._tempPosition.x,this._tempPosition.y,this._tempPosition.z),e.setRotation(this._tempQuaternion),e.setSensor(i.isTrigger);const o=i.sharedMaterial;if(o){switch(e.setRestitution(o.bounciness),o.bounceCombine){case Sa.Average:e.setRestitutionCombineRule(Ao.Average);break;case Sa.Maximum:e.setRestitutionCombineRule(Ao.Max);break;case Sa.Minimum:e.setRestitutionCombineRule(Ao.Min);break;case Sa.Multiply:e.setRestitutionCombineRule(Ao.Multiply);break}switch(e.setFriction(o.dynamicFriction),o.frictionCombine){case Sa.Average:e.setFrictionCombineRule(Ao.Average);break;case Sa.Maximum:e.setFrictionCombineRule(Ao.Max);break;case Sa.Minimum:e.setFrictionCombineRule(Ao.Min);break;case Sa.Multiply:e.setFrictionCombineRule(Ao.Multiply);break}}const a=this.world.createCollider(e,r);return a[bo]=i,i[ta]=a,a.setActiveEvents(OI.COLLISION_EVENTS),a.setActiveCollisionTypes(ax.ALL),this.objects.push(i),this.bodies.push(a),a}getRigidbody(i,e){if(!this.world)throw new Error("Physics world not initialized");let t=null,s=!1;if(i.attachedRigidbody){const r=i.attachedRigidbody;if(t=r[ta],s=!0,!t){const n=r.isKinematic&&!zI;en&&console.log("Create rigidbody",n);const o=n?cf.RigidBodyDesc.kinematicPositionBased():cf.RigidBodyDesc.dynamic(),a=At(i.attachedRigidbody.gameObject);o.setTranslation(a.x,a.y,a.z),o.setRotation(Bs(i.attachedRigidbody.gameObject)),t=this.world.createRigidBody(o),this.bodies.push(t),this.objects.push(r)}t[bo]=r,r[ta]=t,this.internalUpdateProperties(r,t),this.getRigidbodyRelativeMatrix(i.gameObject,r.gameObject,e)}else{const r=cf.RigidBodyDesc.kinematicPositionBased(),n=At(i.gameObject);r.setTranslation(n.x,n.y,n.z),r.setRotation(Bs(i.gameObject)),t=this.world.createRigidBody(r),e.identity(),t[bo]=null}return i[Tle]=t,{rigidBody:t,useExplicitMassProperties:s}}internal_getRigidbody(i){return i[ta]}internalUpdateProperties(i,e){e.enableCcd(i.collisionDetectionMode!==pb.Discrete),e.setLinearDamping(i.drag),e.setAngularDamping(i.angularDrag),e.setGravityScale(i.useGravity?i.gravityScale:0,!0),e.setEnabledRotations(!i.lockRotationX,!i.lockRotationY,!i.lockRotationZ,!0),e.setEnabledTranslations(!i.lockPositionX,!i.lockPositionY,!i.lockPositionZ,!0),i.isKinematic?e.setBodyType(cf.RigidBodyType.KinematicPositionBased):e.setBodyType(cf.RigidBodyType.Dynamic)}step(i){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.eventQueue||(this.eventQueue=new wle(!1)),i&&(this.world.timestep=tt.lerp(this.world.timestep,i,.8)),this.world.step(this.eventQueue),this._isUpdatingPhysicsWorld=!1,this.updateDebugRendering(this.world))}updateDebugRendering(i){var e,t,s;if(en||zI||Mle||this.debugRenderColliders===!0){if(!this.lines){const n=new is({color:2258688,fog:!1}),o=new gt;this.lines=new Rn(o,n)}this.lines.parent!==((e=this.context)==null?void 0:e.scene)&&((t=this.context)==null||t.scene.add(this.lines));const r=i.debugRender();this.lines.geometry.setAttribute("position",new rt(r.vertices,3)),this.lines.geometry.setAttribute("color",new rt(r.colors,4))}else this.lines&&((s=this.context)==null||s.scene.remove(this.lines))}postStep(){this.world&&this.enabled&&(this._isUpdatingPhysicsWorld=!0,this.syncObjects(),this._isUpdatingPhysicsWorld=!1,this.eventQueue&&!this.collisionHandler&&(this.collisionHandler=new Ile(this.world,this.eventQueue)),this.collisionHandler&&(this.collisionHandler.handleCollisionEvents(),this.collisionHandler.update()))}syncObjects(){if(!zI)for(let i=0;i<this.bodies.length;i++){const e=this.objects[i],t=this.bodies[i],s=e;if(s?.isCollider===!0&&!s.attachedRigidbody){const a=t.parent();a&&this.syncPhysicsBody(e.gameObject,a,!0,!0);continue}const r=t.translation(),n=t.rotation(),o=e.center;if(o&&o.isVector3){this._tempQuaternion.set(n.x,n.y,n.z,n.w);const a=this._tempPosition.copy(o).applyQuaternion(this._tempQuaternion),l=js(e.gameObject);a.multiply(l),r.x-=a.x,r.y-=a.y,r.z-=a.z}Fd(e.gameObject,r.x,r.y,r.z),Xk(e.gameObject,n.x,n.y,n.z,n.w)}}syncPhysicsBody(i,e,t,s){const r=At(i,this._tempPosition),n=Bs(i,this._tempQuaternion);switch(e.bodyType()){case Fv.Fixed:case Fv.KinematicPositionBased:case Fv.KinematicVelocityBased:t&&e.setNextKinematicTranslation(r),s&&e.setNextKinematicRotation(n);break;default:t&&e.setTranslation(r,!1),s&&e.setRotation(n,!1);break}e.wakeUp()}getRigidbodyRelativeMatrix(i,e,t,s){if(s===void 0&&(s=lx._matricesBuffer,s.length=0),i===e){const r=js(i,this._tempPosition);t.makeScale(r.x,r.y,r.z);for(let n=s.length-1;n>=0;n--)t.multiply(s[n]);return t}return s.push(i.matrix),i.parent&&this.getRigidbodyRelativeMatrix(i.parent,e,t,s),t}addFixedJoint(i,e){if(!this.world){console.error("Physics world not initialized");return}const t=i[ta],s=e[ta];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const r=mf.fixed(lx.centerConnectionPos,lx.centerConnectionRot,this._tempPosition,this._tempQuaternion),n=this.world.createImpulseJoint(r,t,s,!0);en&&console.log("ADD FIXED JOINT",n)}addHingeJoint(i,e,t,s){if(!this.world){console.error("Physics world not initialized");return}const r=i[ta],n=e[ta];this.calculateJointRelativeMatrices(i.gameObject,e.gameObject,this._tempMatrix),this._tempMatrix.decompose(this._tempPosition,this._tempQuaternion,this._tempScale);const o=cf.JointData.revolute(t,this._tempPosition,s),a=this.world.createImpulseJoint(o,r,n,!0);en&&console.log("ADD HINGE JOINT",a)}calculateJointRelativeMatrices(i,e,t){i.updateWorldMatrix(!0,!1),e.updateWorldMatrix(!0,!1);const s=i.matrixWorld,r=e.matrixWorld;s.elements[0]=1,s.elements[5]=1,s.elements[10]=1,r.elements[0]=1,r.elements[5]=1,r.elements[10]=1,t.copy(r).premultiply(s.invert()).invert()}};let Nv=lx;h(Nv,"_didLoadPhysicsEngine",!1),h(Nv,"_matricesBuffer",[]),h(Nv,"centerConnectionPos",{x:0,y:0,z:0}),h(Nv,"centerConnectionRot",{x:0,y:0,z:0,w:1});class Ile{constructor(e,t){h(this,"world"),h(this,"eventQueue"),h(this,"activeCollisions",[]),h(this,"activeCollisionsStay",[]),h(this,"activeTriggers",[]),this.world=e,this.eventQueue=t}handleCollisionEvents(){this.eventQueue&&this.world&&this.eventQueue.drainCollisionEvents((e,t,s)=>{const r=this.world.getCollider(e),n=this.world.getCollider(t),o=r[bo],a=n[bo];jI&&console.log("EVT",o.name,a.name,s,r,n),o&&a&&(s?(this.onCollisionStarted(o,r,a,n),this.onCollisionStarted(a,n,o,r)):(this.onCollisionEnded(o,a),this.onCollisionEnded(a,o)))})}update(){this.onHandleCollisionStay()}onCollisionStarted(e,t,s,r){let n=null;if(e.isTrigger||s.isTrigger)su(e.gameObject,o=>{o.onTriggerEnter&&!o.destroyed&&o.onTriggerEnter(s),this.activeTriggers.push({collider:e,component:o,otherCollider:s})});else{const o=e.gameObject;this.world.contactPair(t,r,(a,l)=>{su(o,c=>{var u;if(c.destroyed)return;const d=c.onCollisionEnter||c.onCollisionStay||c.onCollisionExit;if(d||jI){if(!n){const p=[],f=a.normal();for(let m=0;m<a.numSolverContacts();m++){const A=a.solverContactPoint(m),v=a.contactImpulse(m);if(A){const g=a.contactDist(m),b=a.solverContactFriction(m),y=new ej(A,g,f,v,b);p.push(y),jI&&Ml.DrawDirection(A,f,16711680,3,!0)}}n=new tj(o,s,p)}if(d){const p={collider:e,component:c,collision:n};this.activeCollisions.push(p),c.onCollisionStay&&this.activeCollisionsStay.push(p),(u=c.onCollisionEnter)==null||u.call(c,n)}}})})}}onHandleCollisionStay(){for(const e of this.activeCollisionsStay){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onCollisionStay){const s=e.collision;t.onCollisionStay(s)}}for(const e of this.activeTriggers){const t=e.component;if(!t.destroyed&&t.activeAndEnabled&&t.onTriggerStay){const s=e.otherCollider;t.onTriggerStay(s)}}}onCollisionEnded(e,t){if(!(e.destroyed||t.destroyed)){for(let s=0;s<this.activeCollisions.length;s++){const r=this.activeCollisions[s],n=r.collider;if(n.destroyed){this.activeCollisions.splice(s,1),s--;continue}if(n===e&&r.collision.collider===t){const o=r.component;if(this.activeCollisions.splice(s,1),s--,o.activeAndEnabled&&o.onCollisionExit){const a=r.collision;o.onCollisionExit(a)}}}for(let s=0;s<this.activeCollisionsStay.length;s++){const r=this.activeCollisionsStay[s],n=r.collider;if(n.destroyed){this.activeCollisionsStay.splice(s,1),s--;continue}if(n===e&&r.collision.collider===t){const o=r.component;if(this.activeCollisionsStay.splice(s,1),s--,o.activeAndEnabled&&o.onCollisionExit){const a=r.collision;o.onCollisionExit(a)}}}for(let s=0;s<this.activeTriggers.length;s++){const r=this.activeTriggers[s],n=r.collider;if(n.destroyed){this.activeTriggers.splice(s,1),s--;continue}if(n===e&&r.otherCollider===t){const o=r.component;if(this.activeTriggers.splice(s,1),s--,o.activeAndEnabled&&o.onTriggerExit){const a=r.otherCollider;o.onTriggerExit(a)}}}}}}Object.defineProperty(qt.prototype,"fov",{get:function(){return this._fov},set:function(i){const e=i!==this._fov;this._fov=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}}),Object.defineProperty(qt.prototype,"near",{get:function(){return this._near},set:function(i){const e=i!==this._near;this._near=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}}),Object.defineProperty(qt.prototype,"far",{get:function(){return this._far},set:function(i){const e=i!==this._far;this._far=i,e&&this.view!==void 0&&this.updateProjectionMatrix()}});function Rle(i,e,t,s="image/webp",r){if(!i&&(i=Ti.Current,!i))return console.error("Can not save screenshot: No needle-engine context found or provided."),null;if(!r&&(r=i.mainCamera,!r))return console.error("No camera found"),null;const n=i.renderer.domElement.width,o=i.renderer.domElement.height;e||(e=n),t||(t=o);try{const a=i.renderer.domElement;return i.renderer.setSize(e,t,!1),r instanceof qt&&i.updateAspect(r,e,t),i.renderNow(),a.toDataURL(s)}finally{i.renderer.setSize(n,o,!1),i.updateSize()}return null}let zv=null;function Ple(i,e){if(i){if(!i.startsWith("data:image")){console.error("Can not save image: Data url is not an image",i);return}zv||(zv=document.createElement("a")),zv.href=i,zv.download=e,zv.click()}}const cx=le("debugmissingcamera");Ti.registerCallback(kr.MissingCamera,i=>{var e,t;cx&&console.warn("Creating missing camera");const s=i.context.scene,r=new Re;r.name="Default Fallback Camera",s.add(r);const n=new Ri;n.sourceId=((t=(e=i.files)==null?void 0:e[0])==null?void 0:t.src)??"unknown",i.context.lightmaps.tryGetSkybox(n.sourceId)?n.clearFlags=1:n.clearFlags=2,n.backgroundColor=new Ai(.5,.5,.5,1),n.fieldOfView=35,n.backgroundBlurriness=.2;const o=eu(r,n,!0);return r.position.x=0,r.position.y=1,r.position.z=2,Ej(i.context,o),o}),Ti.registerCallback(kr.ContextCreated,i=>{if(!i.context.mainCamera){cx&&console.log("Will not auto-fit because a default camera exists");return}const e=i.context.domElement;if(e?.cameraControls===!0){const t=Tte(i.context.mainCamera);if(t?.isCameraController===!0){cx&&console.log("Will not auto-fit because a camera controller exists");return}Ej(i.context)}});function Ej(i,e){e=e??i.mainCameraComponent;const t=e?.gameObject;if(cx&&console.log("Creating default camera controls",e?.name),t){const s=ly(t,Gl);s.sourceId=e?.sourceId??"unknown";const r=i.domElement.getAttribute("auto-rotate");s.autoRotate=r!==void 0&&(r===""||r==="true"),s.autoRotateSpeed=.5;const n=i,o=()=>{n.pre_render_callbacks.splice(n.pre_render_callbacks.indexOf(o),1),s.fitCamera()};n.pre_render_callbacks.push(o)}else console.warn("Missing camera object, can not add orbit controls")}Zj();const QI={Context:zt,glTF:{loadFromURL:PI}};globalThis.Needle!==void 0&&console.warn("Needle Engine is already imported"),globalThis.Needle=QI;function Mj(i){for(const e in i)QI[e]=i[e]}Mj(eY),Mj(Wae);for(const i of Object.getOwnPropertyNames(se))switch(i){case"prototype":case"constructor":case"length":case"name":continue;default:QI[i]=se[i];break}globalThis.THREE?console.warn("Threejs is already imported"):globalThis.THREE=o6;var GI={},Tj={};Object.defineProperty(Tj,"__esModule",{value:!0});var hx={};Object.defineProperty(hx,"__esModule",{value:!0}),hx.ConstantBackoff=void 0;var Ble=function(){function i(e){this.reset=function(){},this.backoff=e}return i.prototype.next=function(){return this.backoff},i}();hx.ConstantBackoff=Ble;var ux={};Object.defineProperty(ux,"__esModule",{value:!0}),ux.ExponentialBackoff=void 0;var kle=function(){function i(e,t){this.initial=e,this.expMax=t,this.expCurrent=1,this.current=this.initial}return i.prototype.next=function(){var e=this.current;return this.expMax>this.expCurrent++&&(this.current=this.current*2),e},i.prototype.reset=function(){this.expCurrent=1,this.current=this.initial},i}();ux.ExponentialBackoff=kle;var dx={};Object.defineProperty(dx,"__esModule",{value:!0}),dx.LinearBackoff=void 0;var Dle=function(){function i(e,t,s){this.initial=e,this.increment=t,this.maximum=s,this.current=this.initial}return i.prototype.next=function(){var e=this.current,t=this.current+this.increment;return this.maximum===void 0?this.current=t:t<=this.maximum&&(this.current=t),e},i.prototype.reset=function(){this.current=this.initial},i}();dx.LinearBackoff=Dle;var Ij={};Object.defineProperty(Ij,"__esModule",{value:!0});var px={};Object.defineProperty(px,"__esModule",{value:!0}),px.LRUBuffer=void 0;var Ole=function(){function i(e){this.writePtr=0,this.wrapped=!1,this.buffer=Array(e)}return i.prototype.len=function(){return this.wrapped?this.buffer.length:this.writePtr},i.prototype.cap=function(){return this.buffer.length},i.prototype.read=function(e){if(e==null||e.length===0||this.buffer.length===0||this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,s=t-1<0?this.buffer.length-1:t-1,r=0;r<e.length;r++){var n=(t+r)%this.buffer.length;if(e[r]=this.buffer[n],n===s)return r+1}return e.length},i.prototype.write=function(e){if(e==null||e.length===0||this.buffer.length===0)return 0;for(var t=e.length>this.buffer.length?e.length-this.buffer.length:0,s=0;s<e.length-t;s++)this.buffer[this.writePtr]=e[t+s],this.writePtr=(this.writePtr+1)%this.buffer.length,this.writePtr===0&&(this.wrapped=!0);return e.length},i.prototype.forEach=function(e){if(this.writePtr===0&&!this.wrapped)return 0;for(var t=this.wrapped?this.writePtr:0,s=this.wrapped?t-1<0?this.buffer.length-1:t-1:this.writePtr-1,r=this.len();e(this.buffer[t]),t!==s;)t=(t+1)%this.buffer.length;return r},i.prototype.clear=function(){this.writePtr=0,this.wrapped=!1},i}();px.LRUBuffer=Ole;var fx={};Object.defineProperty(fx,"__esModule",{value:!0}),fx.TimeBuffer=void 0;var Lle=function(){function i(e){this.maxAge=e}return i.prototype.cap=function(){return Number.POSITIVE_INFINITY},i.prototype.len=function(){this.forwardTail();for(var e=this.tail,t=0;e!==void 0;)t++,e=e.n;return t},i.prototype.read=function(e){if(this.forwardTail(),e.length===0)return 0;for(var t=this.tail,s=0;t!==void 0&&(e[s++]=t.e,s!==e.length);)t=t.n;return s},i.prototype.write=function(e){for(var t=0;t<e.length;t++)this.putElement(e[t]);return e.length},i.prototype.forEach=function(e){this.forwardTail();for(var t=this.tail,s=0;t!==void 0;)e(t.e),s++,t=t.n;return s},i.prototype.putElement=function(e){var t={e,t:Date.now(),n:void 0};this.tail===void 0&&(this.tail=t),this.head===void 0?this.head=t:(this.head.n=t,this.head=t)},i.prototype.forwardTail=function(){if(this.tail!==void 0)for(var e=Date.now();e-this.tail.t>this.maxAge&&(this.tail===this.head?(this.tail=void 0,this.head=void 0):this.tail=this.tail.n,this.tail!==void 0););},i.prototype.clear=function(){},i}();fx.TimeBuffer=Lle;var HI={};(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.Websocket=i.WebsocketEvents=void 0;var e;(function(s){s.open="open",s.close="close",s.error="error",s.message="message",s.retry="retry"})(e=i.WebsocketEvents||(i.WebsocketEvents={}));var t=function(){function s(r,n,o,a){var l=this;this.eventListeners={open:[],close:[],error:[],message:[],retry:[]},this.closedByUser=!1,this.retries=0,this.handleOpenEvent=function(c){return l.handleEvent(e.open,c)},this.handleCloseEvent=function(c){return l.handleEvent(e.close,c)},this.handleErrorEvent=function(c){return l.handleEvent(e.error,c)},this.handleMessageEvent=function(c){return l.handleEvent(e.message,c)},this.url=r,this.protocols=n,this.buffer=o,this.backoff=a,this.tryConnect()}return Object.defineProperty(s.prototype,"underlyingWebsocket",{get:function(){return this.websocket},enumerable:!1,configurable:!0}),s.prototype.send=function(r){var n;this.closedByUser||(this.websocket===void 0||this.websocket.readyState!==this.websocket.OPEN?(n=this.buffer)===null||n===void 0||n.write([r]):this.websocket.send(r))},s.prototype.close=function(r,n){var o;this.closedByUser=!0,(o=this.websocket)===null||o===void 0||o.close(r,n)},s.prototype.addEventListener=function(r,n,o){var a={listener:n,options:o},l=this.eventListeners[r];l.push(a)},s.prototype.removeEventListener=function(r,n,o){this.eventListeners[r]=this.eventListeners[r].filter(function(a){return a.listener!==n&&(a.options===void 0||a.options!==o)})},s.prototype.dispatchEvent=function(r,n){var o=this,a=this.eventListeners[r],l=[];a.forEach(function(c){c.listener(o,n),c.options!==void 0&&c.options.once&&l.push(c)}),l.forEach(function(c){return o.removeEventListener(r,c.listener,c.options)})},s.prototype.tryConnect=function(){this.websocket!==void 0&&(this.websocket.removeEventListener(e.open,this.handleOpenEvent),this.websocket.removeEventListener(e.close,this.handleCloseEvent),this.websocket.removeEventListener(e.error,this.handleErrorEvent),this.websocket.removeEventListener(e.message,this.handleMessageEvent),this.websocket.close()),this.websocket=new WebSocket(this.url,this.protocols),this.websocket.addEventListener(e.open,this.handleOpenEvent),this.websocket.addEventListener(e.close,this.handleCloseEvent),this.websocket.addEventListener(e.error,this.handleErrorEvent),this.websocket.addEventListener(e.message,this.handleMessageEvent)},s.prototype.handleEvent=function(r,n){var o,a,l;switch(r){case e.close:this.closedByUser||this.reconnect();break;case e.open:this.retries=0,(o=this.backoff)===null||o===void 0||o.reset(),(a=this.buffer)===null||a===void 0||a.forEach(this.send.bind(this)),(l=this.buffer)===null||l===void 0||l.clear();break}this.dispatchEvent(r,n)},s.prototype.reconnect=function(){var r=this;if(this.backoff!==void 0){var n=this.backoff.next();setTimeout(function(){r.dispatchEvent(e.retry,new CustomEvent(e.retry,{detail:{retries:++r.retries,backoff:n}})),r.tryConnect()},n)}},s}();i.Websocket=t})(HI);var mx={};Object.defineProperty(mx,"__esModule",{value:!0}),mx.WebsocketBuilder=void 0;var hf=HI,Ule=function(){function i(e){this.ws=null,this.onOpenListeners=[],this.onCloseListeners=[],this.onErrorListeners=[],this.onMessageListeners=[],this.onRetryListeners=[],this.url=e}return i.prototype.withProtocols=function(e){return this.protocols=e,this},i.prototype.withBackoff=function(e){return this.backoff=e,this},i.prototype.withBuffer=function(e){return this.buffer=e,this},i.prototype.onOpen=function(e,t){return this.onOpenListeners.push({listener:e,options:t}),this},i.prototype.onClose=function(e,t){return this.onCloseListeners.push({listener:e,options:t}),this},i.prototype.onError=function(e,t){return this.onErrorListeners.push({listener:e,options:t}),this},i.prototype.onMessage=function(e,t){return this.onMessageListeners.push({listener:e,options:t}),this},i.prototype.onRetry=function(e,t){return this.onRetryListeners.push({listener:e,options:t}),this},i.prototype.build=function(){var e=this;return this.ws!==null?this.ws:(this.ws=new hf.Websocket(this.url,this.protocols,this.buffer,this.backoff),this.onOpenListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(hf.WebsocketEvents.open,t.listener,t.options)}),this.onCloseListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(hf.WebsocketEvents.close,t.listener,t.options)}),this.onErrorListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(hf.WebsocketEvents.error,t.listener,t.options)}),this.onMessageListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(hf.WebsocketEvents.message,t.listener,t.options)}),this.onRetryListeners.forEach(function(t){var s;return(s=e.ws)===null||s===void 0?void 0:s.addEventListener(hf.WebsocketEvents.retry,t.listener,t.options)}),this.ws)},i}();mx.WebsocketBuilder=Ule,function(i){var e=V0&&V0.__createBinding||(Object.create?function(s,r,n,o){o===void 0&&(o=n),Object.defineProperty(s,o,{enumerable:!0,get:function(){return r[n]}})}:function(s,r,n,o){o===void 0&&(o=n),s[o]=r[n]}),t=V0&&V0.__exportStar||function(s,r){for(var n in s)n!=="default"&&!Object.prototype.hasOwnProperty.call(r,n)&&e(r,s,n)};Object.defineProperty(i,"__esModule",{value:!0}),t(Tj,i),t(hx,i),t(ux,i),t(dx,i),t(Ij,i),t(px,i),t(fx,i),t(HI,i),t(mx,i)}(GI);const Fle=lm(GI),Nle=Uj({__proto__:null,default:Fle},[GI]),_o={node:"node",material:"material",camera:"camera",light:"light"},Vu="KHR_animation_pointer",zle={CUBICSPLINE:void 0,LINEAR:aa,STEP:gc},Rj=Ot.findNode;let Pj=!1;class jle{constructor(e){this.parser=e,this.name=Vu,this.animationPointerResolver=null}setAnimationPointerResolver(e){return this.animationPointerResolver=e,this}_patchPropertyBindingFindNode(){Pj||(Pj=!0,Ot.findNode=function(e,t){if(t.startsWith(".materials.")){const s=t.substring(11).substring(t.indexOf(".")),r=s.indexOf("."),n=r<0?s:s.substring(0,r);let o=null;return e.traverse(a=>{o!==null||a.type!=="Mesh"&&a.type!=="SkinnedMesh"||a.material&&(a.material.uuid===n||a.material.name===n)&&(o=a.material,o!==null&&(s.endsWith(".map")?o=o.map:s.endsWith(".emissiveMap")&&(o=o.emissiveMap)))}),o}else if(t.startsWith(".nodes.")||t.startsWith(".lights.")||t.startsWith(".cameras.")){const s=t.split(".");let r;for(let n=1;n<s.length;n++){const o=s[n];if(o.length==36)r=e.getObjectByProperty("uuid",o);else if(r&&r[o]){const a=Number.parseInt(o);let l=o;a>=0&&(l=a),r=r[l]}else{const a=e.getObjectByName(o);a&&(r=a)}}if(!r){const n=Rj(e,s[2]);return n||console.warn(Vu+": Property binding not found",t,e,e.name,s),n}return r}return Rj(e,t)})}loadAnimationTargetFromChannel(e){const t=e.target,s=t.node!==void 0?t.node:t.id;return this.parser.getDependency("node",s)}loadAnimationTargetFromChannelWithAnimationPointer(e){this._havePatchedPropertyBindings||this._patchPropertyBindingFindNode();const t=e.target,s=t.extensions&&t.extensions[Vu]&&t.path&&t.path==="pointer";if(!s)return null;let r,n=_o.node,o;if(s){const l=t.extensions[Vu];let c=l.pointer;if(!c){console.warn("Invalid path",l,t);return}if(c.startsWith("/materials/")?n=_o.material:c.startsWith("/extensions/KHR_lights_punctual/lights/")?n=_o.light:c.startsWith("/cameras/")&&(n=_o.camera),o=this._tryResolveTargetId(c,n),o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,c);return}switch(n){case _o.material:const d=("/materials/"+o.toString()+"/").length,p=c.substring(0,d);switch(r=c.substring(d),r){case"pbrMetallicRoughness/baseColorFactor":r="color";break;case"pbrMetallicRoughness/roughnessFactor":r="roughness";break;case"pbrMetallicRoughness/metallicFactor":r="metalness";break;case"emissiveFactor":r="emissive";break;case"alphaCutoff":r="alphaTest";break;case"occlusionTexture/strength":r="aoMapIntensity";break;case"normalTexture/scale":r="normalScale";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale":r="map/repeat";break;case"pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset":r="map/offset";break;case"emissiveTexture/extensions/KHR_texture_transform/scale":r="emissiveMap/repeat";break;case"emissiveTexture/extensions/KHR_texture_transform/offset":r="emissiveMap/offset";break;case"extensions/KHR_materials_emissive_strength/emissiveStrength":r="emissiveIntensity";break;case"extensions/KHR_materials_transmission/transmissionFactor":r="transmission";break;case"extensions/KHR_materials_ior/ior":r="ior";break;case"extensions/KHR_materials_volume/thicknessFactor":r="thickness";break;case"extensions/KHR_materials_volume/attenuationColor":r="attenuationColor";break;case"extensions/KHR_materials_volume/attenuationDistance":r="attenuationDistance";break;case"extensions/KHR_materials_iridescence/iridescenceFactor":r="iridescence";break;case"extensions/KHR_materials_iridescence/iridescenceIor":r="iridescenceIOR";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMinimum":r="iridescenceThicknessRange[0]";break;case"extensions/KHR_materials_iridescence/iridescenceThicknessMaximum":r="iridescenceThicknessRange[1]";break;case"extensions/KHR_materials_clearcoat/clearcoatFactor":r="clearcoat";break;case"extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor":r="clearcoatRoughness";break;case"extensions/KHR_materials_sheen/sheenColorFactor":r="sheenColor";break;case"extensions/KHR_materials_sheen/sheenRoughnessFactor":r="sheenRoughness";break;case"extensions/KHR_materials_specular/specularFactor":r="specularIntensity";break;case"extensions/KHR_materials_specular/specularColorFactor":r="specularColor";break}c=p+r;break;case _o.node:const f=("/nodes/"+o.toString()+"/").length,m=c.substring(0,f);switch(r=c.substring(f),r){case"translation":r="position";break;case"rotation":r="quaternion";break;case"scale":r="scale";break;case"weights":r="morphTargetInfluences";break}c=m+r;break;case _o.light:const A=("/extensions/KHR_lights_punctual/lights/"+o.toString()+"/").length;switch(r=c.substring(A),r){case"color":break;case"intensity":break;case"spot/innerConeAngle":r="penumbra";break;case"spot/outerConeAngle":r="angle";break;case"range":r="distance";break}c="/lights/"+o.toString()+"/"+r;break;case _o.camera:const v=("/cameras/"+o.toString()+"/").length,g=c.substring(0,v);switch(r=c.substring(v),r){case"perspective/yfov":r="fov";break;case"perspective/znear":case"orthographic/znear":r="near";break;case"perspective/zfar":case"orthographic/zfar":r="far";break;case"perspective/aspect":r="aspect";break;case"orthographic/xmag":r="zoom";break;case"orthographic/ymag":r="zoom";break}c=g+r;break}const u=this.animationPointerResolver;u&&u.resolvePath&&(c=u.resolvePath(c)),t.extensions[Vu].pointer=c}if(o===null||isNaN(o)){console.warn("Failed resolving animation node id: "+o,t);return}let a;return n===_o.node?a=this.parser.getDependency("node",o):n===_o.material?a=this.parser.getDependency("material",o):n===_o.light?a=this.parser.getDependency("light",o):n===_o.camera?a=this.parser.getDependency("camera",o):console.error("Unhandled type",n),a}createAnimationTracksWithAnimationPointer(e,t,s,r,n){if(!(n.extensions&&n.extensions[Vu]&&n.path&&n.path==="pointer"))return null;let o=n.extensions[Vu].pointer;if(!o)return null;const a=[];o=o.replaceAll("/",".");const l=o.split(".");var c=e.name!==void 0&&e.name!==null?e.name:e.uuid;if(l[2]=c,l[3]==="morphTargetInfluences"&&e.type==="Group"){for(const d of e.children)d instanceof Uh&&d.morphTargetInfluences&&(l[3]=d.name,l[4]="morphTargetInfluences",u(this.parser));return a}u(this.parser);function u(d){o=l.join(".");let p;switch(s.itemSize){case 1:p=xc;break;case 2:case 3:p=hl;break;case 4:o.endsWith(".quaternion")?p=ua:p=v0;break}const f=r.interpolation!==void 0?zle[r.interpolation]:aa;let m=d._getArrayFromAccessor(s);o.endsWith(".fov")&&(m=m.map(v=>v/Math.PI*180));const A=new p(o,t.array,m,f);if(f==="CUBICSPLINE"&&d._createCubicSplineTrackInterpolant(A),a.push(A),o&&s.itemSize===4&&o.startsWith(".materials.")&&o.endsWith(".color")){const v=new Float32Array(m.length/4);for(let b=0,y=m.length/4;b<y;b+=1)v[b]=m[b*4+3];const g=new p(o.replace(".color",".opacity"),t.array,v,f);f==="CUBICSPLINE"&&d._createCubicSplineTrackInterpolant(A),a.push(g)}}return a}_tryResolveTargetId(e,t){let s="";return t==="node"?s=e.substring(7):t==="material"?s=e.substring(11):t==="light"?s=e.substring(39):t==="camera"&&(s=e.substring(9)),s=s.substring(0,s.indexOf("/")),Number.parseInt(s)}loadAnimation(e){const t=this,s=this.parser.json,r=this.parser,n=s.animations[e],o=n.name?n.name:"animation_"+e,a=[],l=[],c=[],u=[],d=[];for(let p=0,f=n.channels.length;p<f;p++){const m=n.channels[p],A=n.samplers[m.sampler],v=m.target,g=n.parameters!==void 0?n.parameters[A.input]:A.input,b=n.parameters!==void 0?n.parameters[A.output]:A.output;let y=t.loadAnimationTargetFromChannelWithAnimationPointer(m);y||(y=t.loadAnimationTargetFromChannel(m)),a.push(y),l.push(r.getDependency("accessor",g)),c.push(r.getDependency("accessor",b)),u.push(A),d.push(v)}return Promise.all([Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(u),Promise.all(d)]).then(function(p){const f=p[0],m=p[1],A=p[2],v=p[3],g=p[4],b=[];for(let y=0,_=f.length;y<_;y++){const S=f[y],M=m[y],I=A[y],R=v[y],E=g[y];if(S===void 0)continue;S.updateMatrix&&(S.updateMatrix(),S.matrixAutoUpdate=!0);let C=t.createAnimationTracksWithAnimationPointer(S,M,I,R,E);if(C||(C=r._createAnimationTracks(S,M,I,R,E)),C)for(let z=0;z<C.length;z++)b.push(C[z])}return new Fr(o,void 0,b)})}}const Qle=Object.freeze(Object.defineProperty({__proto__:null,GLTFAnimationPointerExtension:jle},Symbol.toStringTag,{value:"Module"}));export{fle as $physicsKey,ui as ActionBuilder,bE as ActionCollection,Go as ActionModel,sL as Addressables,Km as AlignmentConstraint,qd as AmbientMode,Bn as Animation,du as AnimationCurve,ib as AnimationExtension,Gb as AnimationTrackHandler,Cr as Animator,Hc as AnimatorConditionMode,Wu as AnimatorController,xE as AnimatorControllerParameterType,sb as AnimatorStateInfo,Pg as Antialiasing,aL as Application,Py as ApplicationEvents,tO as AssetDatabase,er as AssetReference,Ta as AttachedObject,Db as AttachedObjectEvents,Vb as AudioExtension,Tp as AudioListener,As as AudioSource,Tg as AudioTrackHandler,yu as AvatarBlink_Simple,Bp as AvatarEyeLook_Rotation,ub as AvatarLoader,Mr as AvatarMarker,hb as AvatarModel,sg as Avatar_Brain_LookAt,Bg as Avatar_MouthShapes,BM as Avatar_MustacheShake,qr as Avatar_POI,mp as Axes,kp as AxesHelper,ia as BaseUIComponent,LM as BasicIKConstraint,Xb as BehaviorExtension,Xr as BehaviorModel,Ie as Behaviour,bu as Bloom,Dg as BoxCollider,vu as BoxGizmo,_a as BoxHelperComponent,Wl as Button,rp as CallInfo,Ri as Camera,nr as Canvas,th as CanvasGroup,Zc as CapsuleCollider,Up as ChangeMaterialOnClick,wu as ChangeTransformOnClick,Su as CharacterController,Yl as CharacterControllerInput,jg as ChromaticAberration,ra as CircularBuffer,XN as ClearFlags,Ia as ClipExtrapolation,Ra as Collider,tj as Collision,pb as CollisionDetectionMode,sh as ColorAdjustments,Cu as ColorBySpeedModule,Hg as ColorOverLifetimeModule,Oc as Component,ym as ComponentEvents,bm as ComponentLifecycleEvents,MD as ConnectionEvents,ej as ContactPoint,zt as Context,Jq as ContextArgs,kr as ContextEvent,Ti as ContextRegistry,Hb as ControlTrackHandler,Fl as ControllerEvents,xp as ControllerType,lh as CustomBranding,zo as CustomShader,Ry as DefaultReflectionMode,eT as Deletable,c_ as DeleteBox,Jo as DepthOfField,h_ as DeviceFlag,tT as DocumentExtension,Gp as DragControls,Xg as DropListener,Iu as Duplicatable,Gy as EXTENSION_NAME,ka as EmissionModule,Np as EmphasizeOnClick,LC as EngineLoadingView,ir as EventList,Wy as EventListEvent,Un as EventSystem,p_ as EventTrigger,uE as FieldWithDefault,f3 as FileSpawnModel,p3 as File_Event,hT as FixedJoint,uT as FlyControls,Wp as Fog,dn as FrameEvent,sy as GENERATOR,se as GameObject,Ml as Gizmos,lc as GltfExport,yT as GltfExportBox,Gu as GltfLoadEvent,Vz as GltfLoadEventType,rh as Gradient,_u as Graphic,SM as GraphicRaycaster,Bo as Graphics,qp as GridHelper,WM as GridLayoutGroup,Ru as GroundProjectedEnv,zc as GroupActionModel,aO as HideFlags,YM as HideOnStart,qg as HingeJoint,VM as HorizontalLayoutGroup,H8 as HostData,Op as Image,Iy as ImageReference,rL as ImageReferenceSerializer,oh as InheritVelocityModule,Vk as Input,pa as InputEvents,Bu as InputField,_n as InstancingUtil,kD as InstantiateEvent,tn as InstantiateIdProvider,ga as InstantiateOptions,pp as Interactable,R8 as JoinedRoomResponse,U0 as KeyEventArgs,$g as LODGroup,ku as LODModel,P8 as LeftRoomResponse,An as Light,oL as LightData,xs as LimitVelocityOverLifetimeModule,uY as LoadingElementOptions,xT as LogStats,Co as LogType,Du as LookAt,$m as LookAtConstraint,ar as MainModule,IM as MarkerType,Fg as MaskableGraphic,tt as Mathf,Og as MeshCollider,Ky as MeshRenderer,ct as MinMaxCurve,vn as MinMaxGradient,jo as NEEDLE_progressive,Ti as NeedleEngine,BI as NeedleEngineHTMLElement,II as NeedleGltfLoader,py as NeedlePatchesKey,y_ as NestedGltf,ID as NetworkConnection,Tu as Networking,mi as NoiseModule,zl as ObjectRaycaster,xz as ObjectUtils,Ou as OffsetConstraint,Yp as OpenURL,Gl as OrbitControls,Dp as Outline,TD as OwnershipEvent,iy as OwnershipModel,$c as Padding,Gg as ParticleBurst,D_ as ParticleSubEmitter,Cs as ParticleSystem,Jl as ParticleSystemRenderer,CD as PeerNetworking,n2 as Physics,Sa as PhysicsMaterialCombine,cv as PixelationEffect,ih as PlayAnimationOnClick,zp as PlayAudioOnClick,Au as PlayableDirector,Xu as PlayerColor,Qu as PlayerState,Gz as PlayerStateEvent,rx as PlayerSync,xL as PlayerView,wL as PlayerViewManager,oc as PointerEventData,Hk as PointerType,Tr as PostProcessingEffect,L_ as PostProcessingHandler,Qp as PreliminaryAction,Ng as PreliminaryTrigger,iI as PrimitiveType,aU as ProgressiveLoadingInfo,hR as PromiseAllWithErrors,cR as PromiseErrorResult,Ai as RGBAColor,Nv as RapierPhysics,Zb as RawImage,ko as RaycastOptions,Ep as Raycaster,jM as Rect,Kr as RectTransform,op as ReflectionProbe,tb as RegisteredAnimationInfo,Zl as RemoteSkybox,np as RenderTexture,pU as RenderTextureSerializer,Di as Renderer,nL as RendererData,Xm as RendererLightmap,Vi as Rigidbody,ls as RigidbodyConstraints,Ki as RoomEvents,Qn as RotationBySpeedModule,go as RotationOverLifetimeModule,Qy as SceneLightSettings,yn as SceneSwitcher,dv as ScreenCapture,$l as ScreenSpaceAmbientOcclusion,ea as ScreenSpaceAmbientOcclusionN8,hn as SendQueue,Fp as SetActiveOnClick,vv as ShadowCatcher,cs as ShapeModule,Cg as SignalAsset,Rp as SignalReceiver,Ip as SignalReceiverEvent,Ig as SignalTrackHandler,zM as Size,Jr as SizeBySpeedModule,nh as SizeOverLifetimeModule,dE as SkinnedMeshRenderer,dh as SmoothFollow,oI as SpatialHtml,bv as SpatialTrigger,Fa as SpatialTriggerReceiver,G_ as SpectatorCamera,kg as SphereCollider,r2 as SphereIntersection,ij as SphereOverlapResult,ec as Sprite,sf as SpriteData,Na as SpriteRenderer,_v as SpriteSheet,gK as StateMachineBehaviour,lv as SubEmitterSystem,V_ as SyncedCamera,ph as SyncedRoom,Yc as SyncedTransform,JM as TapGestureTrigger,kb as TeleportTarget,gI as TestRunner,vI as TestSimulateUserData,Zr as Text,a_ as TextBuilder,Wg as TextExtension,lr as TextureSheetAnimationModule,za as TiltShiftEffect,a2 as Time,wv as ToneMapping,Eg as TrackHandler,Nn as TrackType,Ui as TrailModule,hp as TransformData,Nu as TransformGizmo,pn as TriggerBuilder,uu as TriggerModel,Y as TypeStore,_p as UIRaycastUtils,fg as UIRootComponent,ao as USDObject,Hn as USDZExporter,ah as USDZText,l_ as USDZUIExtension,dC as Upload_Result,fU as UriSerializer,fp as UsageMarker,B8 as UserJoinedOrLeftRoomModel,Tc as VERSION,Nl as VRUserState,yE as VariantAction,Wi as VelocityOverLifetimeModule,HM as VerticalLayoutGroup,hr as VideoPlayer,ya as ViewDevice,zu as Vignette,zg as VisibilityAction,nc as Voip,J_ as Volume,Tt as VolumeParameter,Rg as VolumeProfile,$ne as WaitForFrames,Az as WaitForSeconds,df as Watch,_g as WebAR,$_ as WebARCameraBackground,xa as WebARSessionRoot,Ct as WebXR,Xc as WebXRAvatar,bs as WebXRController,Ei as WebXREvent,tx as WebXRImageTracking,tc as WebXRImageTrackingModel,Iv as WebXRPlaneTracking,vg as WebXRSync,ju as WebXRTrackedImage,Dn as XRFlag,ix as XRGrabModel,wI as XRGrabRendering,Ob as XRRig,Nm as XRSessionMode,kn as XRState,as as XRStateFlag,SI as __Ignore,oO as __internalNotifyObjectDestroyed,Al as activeInHierarchyFieldName,aR as addAttributeChangeCallback,A7 as addCustomExtension,m3 as addFile,g3 as addFileFromUrl,ile as addGltfLoadEventListener,eu as addNewComponent,dy as addPatch,hy as apply,ple as applyHMRChanges,LD as beginListenDestroy,v3 as beginListenFileSpawn,UD as beginListenInstantiate,b1 as binaryIdentifierCasts,Kq as build_scene_functions,$h as builtinComponentKeyName,DC as calculateProgress01,w7 as colorSerializer,Xy as componentSerializer,i2 as copyTexture,RI as createGLTFLoader,VU as createMotion,jr as debugNet,vm as debugOwner,Zv as deepClone,bf as delay,L0 as deserializeObject,yl as destroy,HD as destroyComponentInstance,GN as detectARSupport,HN as detectVRSupport,Ii as disposeObjectResources,eL as download,fC as download_file,Am as editorGuidKeyName,JT as effectsOrder,T7 as eventListSerializer,Im as findByGuid,XD as findObjectOfType,qD as findObjectsOfType,q1 as findResourceUsers,su as foreachComponent,J1 as foreachComponentEnumerator,F6 as forward,ay as generateSeed,jd as getComponent,xm as getComponentInChildren,Sm as getComponentInParent,_m as getComponents,wm as getComponentsInChildren,cy as getComponentsInParent,qj as getIp,Yj as getIpAndLocation,Xj as getIpCloudflare,Lo as getLoader,ly as getOrAddComponent,le as getParam,Qj as getPath,E8 as getPeerOptions,F1 as getPeerjsInstance,o9 as getResourceUserCount,Af as getUrlParams,z6 as getWorldDirection,Zk as getWorldEuler,At as getWorldPosition,Bs as getWorldQuaternion,N0 as getWorldRotation,js as getWorldScale,IC as hasIndieLicense,Kd as hasProLicense,pC as hash,Rm as instantiate,lO as isActiveInHierarchy,Gd as isActiveSelf,t2 as isAnimationAction,Nj as isDebugMode,K1 as isDestroyed,gi as isDevEnvironment,r9 as isDisposed,uR as isHostedOnGlitch,cle as isHotReloading,Br as isLocalNetwork,Ka as isMobileDevice,eA as isMozillaXR,Vj as isQuest,sO as isResourceTrackingEnabled,Ja as isSafari,Ay as isUsingInstancing,_f as isiOS,PI as loadSync,j0 as logHierarchy,D6 as lookAtInverse,jj as makeId,rR as makeIdFromRandomWords,cO as markAsInstancedRendered,G1 as moveComponentInstance,Fj as nameof,Jv as nameofFactory,dU as objectSerializer,Xz as parseSync,uJ as prefix,eR as pushState,tR as randomNumber,H0 as registerBinaryType,Ny as registerComponent,lE as registerComponentExtension,mo as registerCustomEffectType,cU as registerExtensions,hle as registerHotReloadType,mC as registerLoader,ND as registerPrefabProvider,_6 as registerType,oR as relativePathPrefix,lR as removeAttributeChangeCallback,Q1 as removeComponent,y7 as removeCustomExtension,sle as removeGltfLoadEventListener,t9 as removePatch,Ya as resolveUrl,nR as sanitizeString,Ple as saveImage,Rle as screenshot,OD as sendDestroyed,x as serializable,jk as serializeObject,sp as serializeable,Tm as setActive,Jj as setAllowOverlayMessages,uO as setDestroyed,m6 as setDevEnvironment,X1 as setDisposable,yf as setOrAddParamsToUrl,zj as setParam,$I as setParamWithoutReload,M8 as setPeerOptions,s9 as setResourceTrackingEnabled,Nx as setState,$k as setWorldEuler,ns as setWorldPosition,Fd as setWorldPositionXYZ,ln as setWorldQuaternion,Xk as setWorldQuaternionXYZW,e2 as setWorldRotation,z0 as setWorldRotationXYZ,g1 as setWorldScale,fs as showBalloonMessage,Nr as showBalloonWarning,o1 as showDebugConsole,Wk as slerp,oy as syncDestroy,eI as syncField,z1 as syncInstantiate,Q6 as textureToCanvas,h2 as tryCastBinary,qu as tryFindObject,qz as tryFindObjectByName,rle as tryFindScript,u2 as tryGetGuid,ule as unregisterHotReloadType,$O as upload_file,On as validate};