@needle-tools/engine 3.27.1-beta → 3.27.2-beta

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.
@@ -4252,7 +4252,7 @@ outputColor=vec4(color,inputColor.a);}`,dH=class extends Ks{constructor({blendFu
4252
4252
  *
4253
4253
  * @author Feross Aboukhadijeh <https://feross.org>
4254
4254
  * @license MIT
4255
- */var a9=function(i){return i!=null&&(wH(i)||r9(i)||!!i._isBuffer)};function wH(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function r9(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&wH(i.slice(0,0))}(function(){var i=C9,A=Jq.utf8,e=a9,t=Jq.bin,g=function(I,o){I.constructor==String?o&&o.encoding==="binary"?I=t.stringToBytes(I):I=A.stringToBytes(I):e(I)?I=Array.prototype.slice.call(I,0):!Array.isArray(I)&&I.constructor!==Uint8Array&&(I=I.toString());for(var s=i.bytesToWords(I),n=I.length*8,C=1732584193,a=-271733879,B=-1732584194,Q=271733878,E=0;E<s.length;E++)s[E]=(s[E]<<8|s[E]>>>24)&16711935|(s[E]<<24|s[E]>>>8)&4278255360;s[n>>>5]|=128<<n%32,s[(n+64>>>9<<4)+14]=n;for(var c=g._ff,l=g._gg,d=g._hh,h=g._ii,E=0;E<s.length;E+=16){var p=C,u=a,f=B,k=Q;C=c(C,a,B,Q,s[E+0],7,-680876936),Q=c(Q,C,a,B,s[E+1],12,-389564586),B=c(B,Q,C,a,s[E+2],17,606105819),a=c(a,B,Q,C,s[E+3],22,-1044525330),C=c(C,a,B,Q,s[E+4],7,-176418897),Q=c(Q,C,a,B,s[E+5],12,1200080426),B=c(B,Q,C,a,s[E+6],17,-1473231341),a=c(a,B,Q,C,s[E+7],22,-45705983),C=c(C,a,B,Q,s[E+8],7,1770035416),Q=c(Q,C,a,B,s[E+9],12,-1958414417),B=c(B,Q,C,a,s[E+10],17,-42063),a=c(a,B,Q,C,s[E+11],22,-1990404162),C=c(C,a,B,Q,s[E+12],7,1804603682),Q=c(Q,C,a,B,s[E+13],12,-40341101),B=c(B,Q,C,a,s[E+14],17,-1502002290),a=c(a,B,Q,C,s[E+15],22,1236535329),C=l(C,a,B,Q,s[E+1],5,-165796510),Q=l(Q,C,a,B,s[E+6],9,-1069501632),B=l(B,Q,C,a,s[E+11],14,643717713),a=l(a,B,Q,C,s[E+0],20,-373897302),C=l(C,a,B,Q,s[E+5],5,-701558691),Q=l(Q,C,a,B,s[E+10],9,38016083),B=l(B,Q,C,a,s[E+15],14,-660478335),a=l(a,B,Q,C,s[E+4],20,-405537848),C=l(C,a,B,Q,s[E+9],5,568446438),Q=l(Q,C,a,B,s[E+14],9,-1019803690),B=l(B,Q,C,a,s[E+3],14,-187363961),a=l(a,B,Q,C,s[E+8],20,1163531501),C=l(C,a,B,Q,s[E+13],5,-1444681467),Q=l(Q,C,a,B,s[E+2],9,-51403784),B=l(B,Q,C,a,s[E+7],14,1735328473),a=l(a,B,Q,C,s[E+12],20,-1926607734),C=d(C,a,B,Q,s[E+5],4,-378558),Q=d(Q,C,a,B,s[E+8],11,-2022574463),B=d(B,Q,C,a,s[E+11],16,1839030562),a=d(a,B,Q,C,s[E+14],23,-35309556),C=d(C,a,B,Q,s[E+1],4,-1530992060),Q=d(Q,C,a,B,s[E+4],11,1272893353),B=d(B,Q,C,a,s[E+7],16,-155497632),a=d(a,B,Q,C,s[E+10],23,-1094730640),C=d(C,a,B,Q,s[E+13],4,681279174),Q=d(Q,C,a,B,s[E+0],11,-358537222),B=d(B,Q,C,a,s[E+3],16,-722521979),a=d(a,B,Q,C,s[E+6],23,76029189),C=d(C,a,B,Q,s[E+9],4,-640364487),Q=d(Q,C,a,B,s[E+12],11,-421815835),B=d(B,Q,C,a,s[E+15],16,530742520),a=d(a,B,Q,C,s[E+2],23,-995338651),C=h(C,a,B,Q,s[E+0],6,-198630844),Q=h(Q,C,a,B,s[E+7],10,1126891415),B=h(B,Q,C,a,s[E+14],15,-1416354905),a=h(a,B,Q,C,s[E+5],21,-57434055),C=h(C,a,B,Q,s[E+12],6,1700485571),Q=h(Q,C,a,B,s[E+3],10,-1894986606),B=h(B,Q,C,a,s[E+10],15,-1051523),a=h(a,B,Q,C,s[E+1],21,-2054922799),C=h(C,a,B,Q,s[E+8],6,1873313359),Q=h(Q,C,a,B,s[E+15],10,-30611744),B=h(B,Q,C,a,s[E+6],15,-1560198380),a=h(a,B,Q,C,s[E+13],21,1309151649),C=h(C,a,B,Q,s[E+4],6,-145523070),Q=h(Q,C,a,B,s[E+11],10,-1120210379),B=h(B,Q,C,a,s[E+2],15,718787259),a=h(a,B,Q,C,s[E+9],21,-343485551),C=C+p>>>0,a=a+u>>>0,B=B+f>>>0,Q=Q+k>>>0}return i.endian([C,a,B,Q])};g._ff=function(I,o,s,n,C,a,B){var Q=I+(o&s|~o&n)+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._gg=function(I,o,s,n,C,a,B){var Q=I+(o&n|s&~n)+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._hh=function(I,o,s,n,C,a,B){var Q=I+(o^s^n)+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._ii=function(I,o,s,n,C,a,B){var Q=I+(s^(o|~n))+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._blocksize=16,g._digestsize=16,fH.exports=function(I,o){if(I==null)throw new Error("Illegal argument "+I);var s=i.wordsToBytes(g(I,o));return o&&o.asBytes?s:o&&o.asString?t.bytesToString(s):i.bytesToHex(s)}})();var B9=fH.exports;const Q9=yd(B9);class JG{constructor(A,e,t,g){r(this,"success");r(this,"filename");r(this,"hash");r(this,"size");r(this,"url");this.success=A,this.filename=e,this.hash=t,this.size=g}}async function yH(i,A){const e=await i.arrayBuffer(),t=oU(e),g=i.name.split(".").pop(),I=t+"."+g,o=i.name.split(".").shift();console.assert(o!==void 0);const s={alias:o,filename:I},C=await(await fetch(A+"/exists",{method:"POST",body:JSON.stringify(s)})).json();if(C.success||console.warn("exists check did fail"),C.exists)return console.log("file already exists",t),new JG(!0,I,t,i.size);console.log("begin uploading file",o,i.size);const a=new FormData;a.append("file",i);const B={};B.filesize=i.size,o&&(B.alias=o);const E=await(await fetch(A+"/upload/file",{method:"POST",body:a,headers:B})).json();if((E==null?void 0:E.success)===!1)return E.message!==void 0?console.error("Upload failed:",E.message):console.error("Upload failed"),null;console.assert(E.hash_sum===t,"hash sum did not match","received:",E.hash_sum,"expected:",t),E.success&&console.log("successfully uploaded",t,E.id);const c=new JG(E.success,I,t,i.size);return c.url=A,c}function oU(i){return Q9(new Uint8Array(i))}async function sU(i,A,e,t,g=!1){try{const I=await fetch(t+"/download/file",{method:"POST",body:i});if(I.status!==200)return console.error("download failed",I),null;const o=await I.blob(),s=await o.arrayBuffer();g||console.assert(o.size===e,"size mismatch","expected:",e,"got:",o.size);const n=oU(s);return g||console.assert(n===A,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(I){console.error(I)}return null}async function SH(i,A){var a;const e=await fetch(i),t=(a=e.body)==null?void 0:a.getReader(),g=e.headers.get("Content-Length"),I=g?parseInt(g):0;if(!t)return null;let o=0;const s=[];for(;;){const{done:B,value:Q}=await t.read();if(Q&&(s.push(Q),o+=Q.length,A.call(null,new ProgressEvent("progress",{loaded:o,total:I}))),B)break}const n=new Uint8Array(o);let C=0;for(const B of s)n.set(B,C),C+=B.length;return n}let kH,qq=null;function ks(){return kH}function nU(i){if(i==null){console.warn("Oh no: someone tried registering a non-existend gltf-loader. When you see this log it might mean that needle-engine is being imported multiple times. Please check your project setup.");return}qq!==i&&(qq=i,kH=new i)}const Aa=sA("debugaddressables");class mH{constructor(A){r(this,"_context");r(this,"_assetReferences",{});this._context=A,this._context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){}findAssetReference(A){return this._assetReferences[A]||null}registerAssetReference(A){return A.uri&&(this._assetReferences[A.uri]?console.warn("Asset reference already registered",A):this._assetReferences[A.uri]=A),A}dispose(){for(const A in this._assetReferences){const e=this._assetReferences[A];e==null||e.unload()}this._assetReferences={}}unregisterAssetReference(A){A.uri&&delete this._assetReferences[A.uri]}}const ik=Symbol("assetReference"),jQ=class{constructor(A,e,t=null){r(this,"_loading");r(this,"_asset");r(this,"_glbRoot");r(this,"_url");r(this,"_progressListeners",[]);r(this,"_hash");r(this,"_hashedUri");r(this,"_isLoadingRawBinary",!1);r(this,"_rawBinary");this._url=A,this._hash=e,A.includes("?v=")?this._hashedUri=A:this._hashedUri=e?A+"?v="+e:A,t!==null&&(this.asset=t),yY(this._url,this.onResolvePrefab.bind(this))}static getOrCreate(A,e,t){if(typeof A=="string"){if(!t&&(t=be.Current,!t))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else t=A.context,A=A.sourceId;const g=UC(A,e);Aa&&console.log("GetOrCreate Addressable from",A,e,"FinalPath=",g);const I=t.addressables,o=I.findAssetReference(g);if(o)return o;const s=new jQ(g,t.hash);return I.registerAssetReference(s),s}get asset(){return this._glbRoot??this._asset}set asset(A){this._asset=A}get uri(){return this._url}get rawAsset(){return this._asset}async onResolvePrefab(A){return A===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||dy(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(Aa&&console.log("Unload",this.asset),this.asset.scene&&cn(this.asset.scene,!0,!0),cn(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,be.Current&&be.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,Aa&&console.log("Preload",this._hashedUri);const A=await SH(this._hashedUri,e=>{this.raiseProgressEvent(e)});return this._rawBinary=(A==null?void 0:A.buffer)??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(A){if(Aa&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(A&&this._progressListeners.push(A),this._loading!==void 0)return this._loading;const e=be.Current;this._rawBinary?(this._loading=ks().parseSync(e,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(Aa&&console.log("Load async",this.uri),this._loading=ks().loadSync(e,this._hashedUri,this.uri,null,g=>{this.raiseProgressEvent(g)}));const t=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(t),this._loading=void 0,t)return t[ik]=this,this._glbRoot&&(this._glbRoot[ik]=this),this.asset&&(this.asset[ik]=this),GD(e),t.scene!==void 0&&(this.asset=t),this.asset}async instantiate(A){return this.onInstantiate(A,!1)}async instantiateSynced(A,e=!0){return this.onInstantiate(A,!0,e)}beginListenDownload(A){this._progressListeners.indexOf(A)<0&&this._progressListeners.push(A)}endListenDownload(A){const e=this._progressListeners.indexOf(A);e>=0&&this._progressListeners.splice(e,1)}raiseProgressEvent(A){for(const e of this._progressListeners)e(this,A)}async onInstantiate(A,e=!1,t){const g=be.Current;if(this.mustLoad&&await this.loadAssetAsync(),Aa&&console.log("Instantiate",this.uri,"parent:",A),this.asset){Aa&&console.log("Add to scene",this.asset);let I=A instanceof En?A:null;I||(I=new En),typeof A=="object"&&(A instanceof SA?I.parent=A:Object.assign(I,A)),I.parent||(I.parent=g.scene);let o=jQ.currentlyInstantiating.get(this.uri);if(o!==void 0&&o>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+o+")"),null;try{if(o===void 0&&(o=0),o+=1,jQ.currentlyInstantiating.set(this.uri,o),e){I.context=g;const s=this.asset;s.guid=this.uri;const n=OR(s,I,void 0,t);if(n)return n}else{const s=Nd(this.asset,I);if(s)return s}}finally{g.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,jQ.currentlyInstantiating.set(this.uri,o)})}}else Aa&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(A){if(A&&A.scene){const e=A.scene;return e.isGroup&&e.children.length===1&&e.children[0].name+"glb"===e.name?e.children[0]:e}return null}};let Ui=jQ;r(Ui,"currentlyInstantiating",new Map);class E9 extends NC{constructor(){super([Ui])}onSerialize(A,e){if(A&&A.uri!==void 0&&typeof A.uri=="string")return A.uri}onDeserialize(A,e){if(typeof A=="string")return e.context?e.gltfId?Ui.getOrCreate(e.gltfId,A,e.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(A instanceof SA){if(!e.context)return console.error("Missing context"),null;if(!e.gltfId)return console.error("Missing source id"),null;const t=A,g=e.context,I=t.guid??t.uuid,o=g.addressables.findAssetReference(I);if(o)return o;const s=new Ui(I,void 0,t);return g.addressables.registerAssetReference(s),s}return null}}new E9;const c9=Promise.resolve(null),nl=class{constructor(A){r(this,"url");r(this,"_bitmap");r(this,"_bitmapObject");r(this,"loader",null);this.url=A}static getOrCreate(A){let e=nl.imageReferences.get(A);return e||(e=new nl(A),nl.imageReferences.set(A,e)),e}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const A=new Image;return A.src=this.url,A}createTexture(){return this.url?(this.loader||(this.loader=new QC),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):c9}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((A,e)=>{const t=document.createElement("img");t.addEventListener("load",()=>{this._bitmap=createImageBitmap(t).then(g=>(this._bitmapObject=g,A(g),g))}),t.addEventListener("error",g=>{console.error("Failed to load image:"+this.url,g),A(null)}),t.src=this.url}),this._bitmap)}};let iE=nl;r(iE,"imageReferences",new Map);class GH extends NC{constructor(){super([iE])}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"){const t=UC(e.gltfId,A);return iE.getOrCreate(t)}}}new GH;const No=sA("debugenvlight");var gE=(i=>(i[i.Skybox=0]="Skybox",i[i.Trilight=1]="Trilight",i[i.Flat=3]="Flat",i[i.Custom=4]="Custom",i))(gE||{}),RD=(i=>(i[i.Skybox=0]="Skybox",i[i.Custom=1]="Custom",i))(RD||{});class MH{constructor(A){r(this,"context");r(this,"_currentLightSettingsId");r(this,"_sceneLightSettings");r(this,"_timevec4",new te);r(this,"__currentReflectionId",null);r(this,"_waitPromise");r(this,"_lighting",{});this.context=A,this.context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){const A=this.context.time;this._timevec4.x=A.time,this._timevec4.y=Math.sin(A.time),this._timevec4.z=Math.cos(A.time),this._timevec4.w=A.deltaTime}get timeVec4(){return this._timevec4}get environmentIntensity(){if(!this._sceneLightSettings||!this._currentLightSettingsId)return 1;const A=this._sceneLightSettings.get(this._currentLightSettingsId);return A?A.ambientIntensity:1}get sceneLightSettings(){var A;return(A=this._sceneLightSettings)==null?void 0:A.values()}enable(A){var t;A instanceof Ui&&(A=A.uri);const e=(t=this._sceneLightSettings)==null?void 0:t.get(A);return e?(No&&console.log("Enable scene light settings",A,e),A!==this._currentLightSettingsId&&this._currentLightSettingsId&&this.disable(this._currentLightSettingsId),this._currentLightSettingsId=A,e.enabled=!0,!0):!1}disable(A){var t;if(A instanceof Ui&&(A=A.uri),A==null)return!1;const e=(t=this._sceneLightSettings)==null?void 0:t.get(A);return e?(No&&console.log("Disable scene light settings",A,e),e.enabled=!1,!0):!1}disableCurrent(){if(this._currentLightSettingsId){const A=this._currentLightSettingsId;return this.disable(this._currentLightSettingsId),A}return null}internalRegisterSceneLightSettings(A){const e=A.sourceId;if(!e){console.error("Missing source id for scene light settings, can not register:",A);return}No&&console.log("Register "+(A==null?void 0:A.sourceId)+" lighting",A),this._sceneLightSettings||(this._sceneLightSettings=new Map),this._sceneLightSettings.set(e,A)}internalUnregisterSceneLightSettings(A){const e=A.sourceId;if(!e){console.error("Missing source id for scene light settings, can not unregister:",A);return}No&&console.log("Unregister "+(A==null?void 0:A.sourceId)+" lighting",A),this._sceneLightSettings&&this._sceneLightSettings.delete(e)}internalRegisterReflection(A,e){No&&console.log("Register reflection",A,e);const t=new RH(this.context,e,1);this._lighting[A]=t}internalGetReflection(A){return this._lighting[A]}internalEnableReflection(A){var t;this.__currentReflectionId=A;const e=(t=this._sceneLightSettings)==null?void 0:t.get(A);switch(No&&console.log("Enable reflection",A,e?gE[e.ambientMode]:"Unknown ambient mode"),e==null?void 0:e.ambientMode){case 0:case 4:const g=this.internalGetReflection(A);if(g&&g.Source){No&&console.log("Setting environment reflection",g);const I=this.context.scene,o=g.Source;o.colorSpace=Ie,o.mapping=Po,I.environment=o;return}else No&&console.warn("Could not find reflection for source",A);break}if((e==null?void 0:e.environmentReflectionSource)===1)switch(e==null?void 0:e.ambientMode){case 1:if(e.ambientTrilight){const g=e.ambientTrilight,I=I9(g[0],g[1],g[2],64,64);I.colorSpace=Ie,I.mapping=Po,this.context.scene.environment=I}else console.error("Missing ambient trilight",e.sourceId);return;case 3:if(e.ambientLight){const g=uH(e.ambientLight,64);g.colorSpace=Ie,g.mapping=Po,this.context.scene.environment=g}else console.error("Missing ambientlight",e.sourceId);return;default:return}}internalDisableReflection(A){if(A&&A!==this.__currentReflectionId){No&&console.log("Not disabling reflection for",A,"because it is not the current light settings id",this.__currentReflectionId);return}No&&console.log("Disable reflection",A);const e=this.context.scene;e.environment=null}async internalGetSceneLightingData(A){return No&&console.log("GET SCENE LIGHT DATA",A),this._waitPromise?this._waitPromise:(this._waitPromise=new Promise((e,t)=>{const g=setInterval(async()=>{const I=this.internalGetReflection(A);I&&(clearInterval(g),e(I.getSphericalHarmonicsArray(this.environmentIntensity??1)))},10)}),this._waitPromise)}}class RH{constructor(A,e,t=1){r(this,"_context");r(this,"_source");r(this,"_sphericalHarmonics",null);r(this,"_sphericalHarmonicsArray");r(this,"_ambientScale",1);r(this,"_lightProbe");this._context=A,this._source=e,this._ambientScale=t,e.mapping=Po,e.colorSpace=Ie}get Source(){return this._source}get Array(){return this._sphericalHarmonicsArray}getSphericalHarmonicsArray(A=1){var e;if((e=this._sphericalHarmonicsArray)!=null&&e.length&&this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:this._lightProbe};try{const t=this._source;let g=null;if(t){No&&console.log("GENERATING LIGHT PROBE",t,this.Source);const I=Math.min(t.image.width,512);g=new mw(I).fromEquirectangularTexture(this._context.renderer,t)}if(this._sphericalHarmonicsArray=[],g){const I=i9.fromCubeRenderTarget(this._context.renderer,g);this._lightProbe=I;const o=this._ambientScale*(A*A*Math.PI*.5)-1;if(this._sphericalHarmonics=I.sh,this._sphericalHarmonicsArray=this._sphericalHarmonics.toArray(),this._sphericalHarmonicsArray){const s=A/(Math.PI*.5);for(let n=0;n<this._sphericalHarmonicsArray.length;n++)this._sphericalHarmonicsArray[n]*=s;if(I.sh.scale(o),this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:I}}}}catch(t){console.error(t)}return null}}var UD=(i=>(i.Visible="application-visible",i.Hidden="application-hidden",i.MuteChanged="application-mutechanged",i))(UD||{});class UH extends EventTarget{constructor(e){super();r(this,"_mute",!1);r(this,"context");r(this,"_isVisible",!0);this.context=e,window.addEventListener("visibilitychange",this.onVisiblityChanged.bind(this),!1)}get muted(){return this._mute}set muted(e){e!==this._mute&&(this._mute=e,this.dispatchEvent(new Event("application-mutechanged")))}get hasFocus(){return document.hasFocus()}get isVisible(){return this._isVisible}onVisiblityChanged(e){switch(e.target.visibilityState){case"hidden":this._isVisible=!1,this.dispatchEvent(new Event("application-hidden"));break;case"visible":this._isVisible=!0,this.dispatchEvent(new Event("application-visible"));break}}}/*!
4255
+ */var a9=function(i){return i!=null&&(wH(i)||r9(i)||!!i._isBuffer)};function wH(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function r9(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&wH(i.slice(0,0))}(function(){var i=C9,A=Jq.utf8,e=a9,t=Jq.bin,g=function(I,o){I.constructor==String?o&&o.encoding==="binary"?I=t.stringToBytes(I):I=A.stringToBytes(I):e(I)?I=Array.prototype.slice.call(I,0):!Array.isArray(I)&&I.constructor!==Uint8Array&&(I=I.toString());for(var s=i.bytesToWords(I),n=I.length*8,C=1732584193,a=-271733879,B=-1732584194,Q=271733878,E=0;E<s.length;E++)s[E]=(s[E]<<8|s[E]>>>24)&16711935|(s[E]<<24|s[E]>>>8)&4278255360;s[n>>>5]|=128<<n%32,s[(n+64>>>9<<4)+14]=n;for(var c=g._ff,l=g._gg,d=g._hh,h=g._ii,E=0;E<s.length;E+=16){var p=C,u=a,f=B,k=Q;C=c(C,a,B,Q,s[E+0],7,-680876936),Q=c(Q,C,a,B,s[E+1],12,-389564586),B=c(B,Q,C,a,s[E+2],17,606105819),a=c(a,B,Q,C,s[E+3],22,-1044525330),C=c(C,a,B,Q,s[E+4],7,-176418897),Q=c(Q,C,a,B,s[E+5],12,1200080426),B=c(B,Q,C,a,s[E+6],17,-1473231341),a=c(a,B,Q,C,s[E+7],22,-45705983),C=c(C,a,B,Q,s[E+8],7,1770035416),Q=c(Q,C,a,B,s[E+9],12,-1958414417),B=c(B,Q,C,a,s[E+10],17,-42063),a=c(a,B,Q,C,s[E+11],22,-1990404162),C=c(C,a,B,Q,s[E+12],7,1804603682),Q=c(Q,C,a,B,s[E+13],12,-40341101),B=c(B,Q,C,a,s[E+14],17,-1502002290),a=c(a,B,Q,C,s[E+15],22,1236535329),C=l(C,a,B,Q,s[E+1],5,-165796510),Q=l(Q,C,a,B,s[E+6],9,-1069501632),B=l(B,Q,C,a,s[E+11],14,643717713),a=l(a,B,Q,C,s[E+0],20,-373897302),C=l(C,a,B,Q,s[E+5],5,-701558691),Q=l(Q,C,a,B,s[E+10],9,38016083),B=l(B,Q,C,a,s[E+15],14,-660478335),a=l(a,B,Q,C,s[E+4],20,-405537848),C=l(C,a,B,Q,s[E+9],5,568446438),Q=l(Q,C,a,B,s[E+14],9,-1019803690),B=l(B,Q,C,a,s[E+3],14,-187363961),a=l(a,B,Q,C,s[E+8],20,1163531501),C=l(C,a,B,Q,s[E+13],5,-1444681467),Q=l(Q,C,a,B,s[E+2],9,-51403784),B=l(B,Q,C,a,s[E+7],14,1735328473),a=l(a,B,Q,C,s[E+12],20,-1926607734),C=d(C,a,B,Q,s[E+5],4,-378558),Q=d(Q,C,a,B,s[E+8],11,-2022574463),B=d(B,Q,C,a,s[E+11],16,1839030562),a=d(a,B,Q,C,s[E+14],23,-35309556),C=d(C,a,B,Q,s[E+1],4,-1530992060),Q=d(Q,C,a,B,s[E+4],11,1272893353),B=d(B,Q,C,a,s[E+7],16,-155497632),a=d(a,B,Q,C,s[E+10],23,-1094730640),C=d(C,a,B,Q,s[E+13],4,681279174),Q=d(Q,C,a,B,s[E+0],11,-358537222),B=d(B,Q,C,a,s[E+3],16,-722521979),a=d(a,B,Q,C,s[E+6],23,76029189),C=d(C,a,B,Q,s[E+9],4,-640364487),Q=d(Q,C,a,B,s[E+12],11,-421815835),B=d(B,Q,C,a,s[E+15],16,530742520),a=d(a,B,Q,C,s[E+2],23,-995338651),C=h(C,a,B,Q,s[E+0],6,-198630844),Q=h(Q,C,a,B,s[E+7],10,1126891415),B=h(B,Q,C,a,s[E+14],15,-1416354905),a=h(a,B,Q,C,s[E+5],21,-57434055),C=h(C,a,B,Q,s[E+12],6,1700485571),Q=h(Q,C,a,B,s[E+3],10,-1894986606),B=h(B,Q,C,a,s[E+10],15,-1051523),a=h(a,B,Q,C,s[E+1],21,-2054922799),C=h(C,a,B,Q,s[E+8],6,1873313359),Q=h(Q,C,a,B,s[E+15],10,-30611744),B=h(B,Q,C,a,s[E+6],15,-1560198380),a=h(a,B,Q,C,s[E+13],21,1309151649),C=h(C,a,B,Q,s[E+4],6,-145523070),Q=h(Q,C,a,B,s[E+11],10,-1120210379),B=h(B,Q,C,a,s[E+2],15,718787259),a=h(a,B,Q,C,s[E+9],21,-343485551),C=C+p>>>0,a=a+u>>>0,B=B+f>>>0,Q=Q+k>>>0}return i.endian([C,a,B,Q])};g._ff=function(I,o,s,n,C,a,B){var Q=I+(o&s|~o&n)+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._gg=function(I,o,s,n,C,a,B){var Q=I+(o&n|s&~n)+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._hh=function(I,o,s,n,C,a,B){var Q=I+(o^s^n)+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._ii=function(I,o,s,n,C,a,B){var Q=I+(s^(o|~n))+(C>>>0)+B;return(Q<<a|Q>>>32-a)+o},g._blocksize=16,g._digestsize=16,fH.exports=function(I,o){if(I==null)throw new Error("Illegal argument "+I);var s=i.wordsToBytes(g(I,o));return o&&o.asBytes?s:o&&o.asString?t.bytesToString(s):i.bytesToHex(s)}})();var B9=fH.exports;const Q9=yd(B9);class JG{constructor(A,e,t,g){r(this,"success");r(this,"filename");r(this,"hash");r(this,"size");r(this,"url");this.success=A,this.filename=e,this.hash=t,this.size=g}}async function yH(i,A){const e=await i.arrayBuffer(),t=oU(e),g=i.name.split(".").pop(),I=t+"."+g,o=i.name.split(".").shift();console.assert(o!==void 0);const s={alias:o,filename:I},C=await(await fetch(A+"/exists",{method:"POST",body:JSON.stringify(s)})).json();if(C.success||console.warn("exists check did fail"),C.exists)return console.log("file already exists",t),new JG(!0,I,t,i.size);console.log("begin uploading file",o,i.size);const a=new FormData;a.append("file",i);const B={};B.filesize=i.size,o&&(B.alias=o);const E=await(await fetch(A+"/upload/file",{method:"POST",body:a,headers:B})).json();if((E==null?void 0:E.success)===!1)return E.message!==void 0?console.error("Upload failed:",E.message):console.error("Upload failed"),null;console.assert(E.hash_sum===t,"hash sum did not match","received:",E.hash_sum,"expected:",t),E.success&&console.log("successfully uploaded",t,E.id);const c=new JG(E.success,I,t,i.size);return c.url=A,c}function oU(i){return Q9(new Uint8Array(i))}async function sU(i,A,e,t,g=!1){try{const I=await fetch(t+"/download/file",{method:"POST",body:i});if(I.status!==200)return console.error("download failed",I),null;const o=await I.blob(),s=await o.arrayBuffer();g||console.assert(o.size===e,"size mismatch","expected:",e,"got:",o.size);const n=oU(s);return g||console.assert(n===A,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(I){console.error(I)}return null}async function SH(i,A){var a;const e=await fetch(i),t=(a=e.body)==null?void 0:a.getReader(),g=e.headers.get("Content-Length"),I=g?parseInt(g):0;if(!t)return null;let o=0;const s=[];for(;;){const{done:B,value:Q}=await t.read();if(Q&&(s.push(Q),o+=Q.length,A.call(null,new ProgressEvent("progress",{loaded:o,total:I}))),B)break}const n=new Uint8Array(o);let C=0;for(const B of s)n.set(B,C),C+=B.length;return n}let kH,qq=null;function ks(){return kH}function nU(i){if(i==null){console.warn("Oh no: someone tried registering a non-existend gltf-loader. When you see this log it might mean that needle-engine is being imported multiple times. Please check your project setup.");return}qq!==i&&(qq=i,kH=new i)}const Aa=sA("debugaddressables");class mH{constructor(A){r(this,"_context");r(this,"_assetReferences",{});this._context=A,this._context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){}findAssetReference(A){return this._assetReferences[A]||null}registerAssetReference(A){return A.uri&&(this._assetReferences[A.uri]?console.warn("Asset reference already registered",A):this._assetReferences[A.uri]=A),A}dispose(){for(const A in this._assetReferences){const e=this._assetReferences[A];e==null||e.unload()}this._assetReferences={}}unregisterAssetReference(A){A.uri&&delete this._assetReferences[A.uri]}}const ik=Symbol("assetReference"),jQ=class{constructor(A,e,t=null){r(this,"_loading");r(this,"_asset");r(this,"_glbRoot");r(this,"_url");r(this,"_progressListeners",[]);r(this,"_hash");r(this,"_hashedUri");r(this,"_isLoadingRawBinary",!1);r(this,"_rawBinary");this._url=A,this._hash=e,A.includes("?v=")?this._hashedUri=A:this._hashedUri=e?A+"?v="+e:A,t!==null&&(this.asset=t),yY(this._url,this.onResolvePrefab.bind(this))}static getOrCreate(A,e,t){if(typeof A=="string"){if(!t&&(t=be.Current,!t))throw new Error('Context is required when sourceId is a string. When you call this method from a component you can call it with "getOrCreate(this, url)" where "this" is the component.')}else t=A.context,A=A.sourceId;const g=UC(A,e);Aa&&console.log("GetOrCreate Addressable from",A,e,"FinalPath=",g);const I=t.addressables,o=I.findAssetReference(g);if(o)return o;const s=new jQ(g,t.hash);return I.registerAssetReference(s),s}get asset(){return this._glbRoot??this._asset}set asset(A){this._asset=A}get uri(){return this._url}get rawAsset(){return this._asset}async onResolvePrefab(A){return A===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||dy(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(Aa&&console.log("Unload",this.asset),this.asset.scene&&cn(this.asset.scene,!0,!0),cn(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,be.Current&&be.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,Aa&&console.log("Preload",this._hashedUri);const A=await SH(this._hashedUri,e=>{this.raiseProgressEvent(e)});return this._rawBinary=(A==null?void 0:A.buffer)??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(A){if(Aa&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(A&&this._progressListeners.push(A),this._loading!==void 0)return this._loading.then(g=>this.asset);const e=be.Current;this._rawBinary?(this._loading=ks().parseSync(e,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(Aa&&console.log("Load async",this.uri),this._loading=ks().loadSync(e,this._hashedUri,this.uri,null,g=>{this.raiseProgressEvent(g)}));const t=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(t),this._loading=void 0,t)return t[ik]=this,this._glbRoot&&(this._glbRoot[ik]=this),this.asset&&(this.asset[ik]=this),GD(e),t.scene!==void 0&&(this.asset=t),this.asset}async instantiate(A){return this.onInstantiate(A,!1)}async instantiateSynced(A,e=!0){return this.onInstantiate(A,!0,e)}beginListenDownload(A){this._progressListeners.indexOf(A)<0&&this._progressListeners.push(A)}endListenDownload(A){const e=this._progressListeners.indexOf(A);e>=0&&this._progressListeners.splice(e,1)}raiseProgressEvent(A){for(const e of this._progressListeners)e(this,A)}async onInstantiate(A,e=!1,t){const g=be.Current;if(this.mustLoad&&await this.loadAssetAsync(),Aa&&console.log("Instantiate",this.uri,"parent:",A),this.asset){Aa&&console.log("Add to scene",this.asset);let I=A instanceof En?A:null;I||(I=new En),typeof A=="object"&&(A instanceof SA?I.parent=A:Object.assign(I,A)),I.parent||(I.parent=g.scene);let o=jQ.currentlyInstantiating.get(this.uri);if(o!==void 0&&o>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+o+")"),null;try{if(o===void 0&&(o=0),o+=1,jQ.currentlyInstantiating.set(this.uri,o),e){I.context=g;const s=this.asset;s.guid=this.uri;const n=OR(s,I,void 0,t);if(n)return n}else{const s=Nd(this.asset,I);if(s)return s}}finally{g.post_render_callbacks.push(()=>{o===void 0||o<0?o=0:o-=1,jQ.currentlyInstantiating.set(this.uri,o)})}}else Aa&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(A){if(A&&A.scene){const e=A.scene;return e.isGroup&&e.children.length===1&&e.children[0].name+"glb"===e.name?e.children[0]:e}return null}};let Ui=jQ;r(Ui,"currentlyInstantiating",new Map);class E9 extends NC{constructor(){super([Ui])}onSerialize(A,e){if(A&&A.uri!==void 0&&typeof A.uri=="string")return A.uri}onDeserialize(A,e){if(typeof A=="string")return e.context?e.gltfId?Ui.getOrCreate(e.gltfId,A,e.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(A instanceof SA){if(!e.context)return console.error("Missing context"),null;if(!e.gltfId)return console.error("Missing source id"),null;const t=A,g=e.context,I=t.guid??t.uuid,o=g.addressables.findAssetReference(I);if(o)return o;const s=new Ui(I,void 0,t);return g.addressables.registerAssetReference(s),s}return null}}new E9;const c9=Promise.resolve(null),nl=class{constructor(A){r(this,"url");r(this,"_bitmap");r(this,"_bitmapObject");r(this,"loader",null);this.url=A}static getOrCreate(A){let e=nl.imageReferences.get(A);return e||(e=new nl(A),nl.imageReferences.set(A,e)),e}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const A=new Image;return A.src=this.url,A}createTexture(){return this.url?(this.loader||(this.loader=new QC),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):c9}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((A,e)=>{const t=document.createElement("img");t.addEventListener("load",()=>{this._bitmap=createImageBitmap(t).then(g=>(this._bitmapObject=g,A(g),g))}),t.addEventListener("error",g=>{console.error("Failed to load image:"+this.url,g),A(null)}),t.src=this.url}),this._bitmap)}};let iE=nl;r(iE,"imageReferences",new Map);class GH extends NC{constructor(){super([iE])}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"){const t=UC(e.gltfId,A);return iE.getOrCreate(t)}}}new GH;const No=sA("debugenvlight");var gE=(i=>(i[i.Skybox=0]="Skybox",i[i.Trilight=1]="Trilight",i[i.Flat=3]="Flat",i[i.Custom=4]="Custom",i))(gE||{}),RD=(i=>(i[i.Skybox=0]="Skybox",i[i.Custom=1]="Custom",i))(RD||{});class MH{constructor(A){r(this,"context");r(this,"_currentLightSettingsId");r(this,"_sceneLightSettings");r(this,"_timevec4",new te);r(this,"__currentReflectionId",null);r(this,"_waitPromise");r(this,"_lighting",{});this.context=A,this.context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){const A=this.context.time;this._timevec4.x=A.time,this._timevec4.y=Math.sin(A.time),this._timevec4.z=Math.cos(A.time),this._timevec4.w=A.deltaTime}get timeVec4(){return this._timevec4}get environmentIntensity(){if(!this._sceneLightSettings||!this._currentLightSettingsId)return 1;const A=this._sceneLightSettings.get(this._currentLightSettingsId);return A?A.ambientIntensity:1}get sceneLightSettings(){var A;return(A=this._sceneLightSettings)==null?void 0:A.values()}enable(A){var t;A instanceof Ui&&(A=A.uri);const e=(t=this._sceneLightSettings)==null?void 0:t.get(A);return e?(No&&console.log("Enable scene light settings",A,e),A!==this._currentLightSettingsId&&this._currentLightSettingsId&&this.disable(this._currentLightSettingsId),this._currentLightSettingsId=A,e.enabled=!0,!0):!1}disable(A){var t;if(A instanceof Ui&&(A=A.uri),A==null)return!1;const e=(t=this._sceneLightSettings)==null?void 0:t.get(A);return e?(No&&console.log("Disable scene light settings",A,e),e.enabled=!1,!0):!1}disableCurrent(){if(this._currentLightSettingsId){const A=this._currentLightSettingsId;return this.disable(this._currentLightSettingsId),A}return null}internalRegisterSceneLightSettings(A){const e=A.sourceId;if(!e){console.error("Missing source id for scene light settings, can not register:",A);return}No&&console.log("Register "+(A==null?void 0:A.sourceId)+" lighting",A),this._sceneLightSettings||(this._sceneLightSettings=new Map),this._sceneLightSettings.set(e,A)}internalUnregisterSceneLightSettings(A){const e=A.sourceId;if(!e){console.error("Missing source id for scene light settings, can not unregister:",A);return}No&&console.log("Unregister "+(A==null?void 0:A.sourceId)+" lighting",A),this._sceneLightSettings&&this._sceneLightSettings.delete(e)}internalRegisterReflection(A,e){No&&console.log("Register reflection",A,e);const t=new RH(this.context,e,1);this._lighting[A]=t}internalGetReflection(A){return this._lighting[A]}internalEnableReflection(A){var t;this.__currentReflectionId=A;const e=(t=this._sceneLightSettings)==null?void 0:t.get(A);switch(No&&console.log("Enable reflection",A,e?gE[e.ambientMode]:"Unknown ambient mode"),e==null?void 0:e.ambientMode){case 0:case 4:const g=this.internalGetReflection(A);if(g&&g.Source){No&&console.log("Setting environment reflection",g);const I=this.context.scene,o=g.Source;o.colorSpace=Ie,o.mapping=Po,I.environment=o;return}else No&&console.warn("Could not find reflection for source",A);break}if((e==null?void 0:e.environmentReflectionSource)===1)switch(e==null?void 0:e.ambientMode){case 1:if(e.ambientTrilight){const g=e.ambientTrilight,I=I9(g[0],g[1],g[2],64,64);I.colorSpace=Ie,I.mapping=Po,this.context.scene.environment=I}else console.error("Missing ambient trilight",e.sourceId);return;case 3:if(e.ambientLight){const g=uH(e.ambientLight,64);g.colorSpace=Ie,g.mapping=Po,this.context.scene.environment=g}else console.error("Missing ambientlight",e.sourceId);return;default:return}}internalDisableReflection(A){if(A&&A!==this.__currentReflectionId){No&&console.log("Not disabling reflection for",A,"because it is not the current light settings id",this.__currentReflectionId);return}No&&console.log("Disable reflection",A);const e=this.context.scene;e.environment=null}async internalGetSceneLightingData(A){return No&&console.log("GET SCENE LIGHT DATA",A),this._waitPromise?this._waitPromise:(this._waitPromise=new Promise((e,t)=>{const g=setInterval(async()=>{const I=this.internalGetReflection(A);I&&(clearInterval(g),e(I.getSphericalHarmonicsArray(this.environmentIntensity??1)))},10)}),this._waitPromise)}}class RH{constructor(A,e,t=1){r(this,"_context");r(this,"_source");r(this,"_sphericalHarmonics",null);r(this,"_sphericalHarmonicsArray");r(this,"_ambientScale",1);r(this,"_lightProbe");this._context=A,this._source=e,this._ambientScale=t,e.mapping=Po,e.colorSpace=Ie}get Source(){return this._source}get Array(){return this._sphericalHarmonicsArray}getSphericalHarmonicsArray(A=1){var e;if((e=this._sphericalHarmonicsArray)!=null&&e.length&&this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:this._lightProbe};try{const t=this._source;let g=null;if(t){No&&console.log("GENERATING LIGHT PROBE",t,this.Source);const I=Math.min(t.image.width,512);g=new mw(I).fromEquirectangularTexture(this._context.renderer,t)}if(this._sphericalHarmonicsArray=[],g){const I=i9.fromCubeRenderTarget(this._context.renderer,g);this._lightProbe=I;const o=this._ambientScale*(A*A*Math.PI*.5)-1;if(this._sphericalHarmonics=I.sh,this._sphericalHarmonicsArray=this._sphericalHarmonics.toArray(),this._sphericalHarmonicsArray){const s=A/(Math.PI*.5);for(let n=0;n<this._sphericalHarmonicsArray.length;n++)this._sphericalHarmonicsArray[n]*=s;if(I.sh.scale(o),this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:I}}}}catch(t){console.error(t)}return null}}var UD=(i=>(i.Visible="application-visible",i.Hidden="application-hidden",i.MuteChanged="application-mutechanged",i))(UD||{});class UH extends EventTarget{constructor(e){super();r(this,"_mute",!1);r(this,"context");r(this,"_isVisible",!0);this.context=e,window.addEventListener("visibilitychange",this.onVisiblityChanged.bind(this),!1)}get muted(){return this._mute}set muted(e){e!==this._mute&&(this._mute=e,this.dispatchEvent(new Event("application-mutechanged")))}get hasFocus(){return document.hasFocus()}get isVisible(){return this._isVisible}onVisiblityChanged(e){switch(e.target.visibilityState){case"hidden":this._isVisible=!1,this.dispatchEvent(new Event("application-hidden"));break;case"visible":this._isVisible=!0,this.dispatchEvent(new Event("application-visible"));break}}}/*!
4256
4256
  fflate - fast JavaScript compression/decompression
4257
4257
  <https://101arrowz.github.io/fflate>
4258
4258
  Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
@@ -5186,7 +5186,7 @@ Using the assigned clip instead:`,this.clip),A=this.clip);let e=!this.sound||A&&
5186
5186
  #include <colorspace_fragment>
5187
5187
 
5188
5188
  }
5189
- `,s={map:{value:A},height:{value:e.height||15},radius:{value:e.radius||100}},n=new ud(1,16),C=new Ke({uniforms:s,fragmentShader:o,vertexShader:I,side:kt});super(n,C)}set radius(A){this.material.uniforms.radius.value=A}get radius(){return this.material.uniforms.radius.value}set height(A){this.material.uniforms.height.value=A}get height(){return this.material.uniforms.height.value}}var agA=Object.defineProperty,rgA=Object.getOwnPropertyDescriptor,vg=(i,A,e,t)=>{for(var g=t>1?void 0:t?rgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&agA(A,e,g),g};const Tp=sA("freecam"),oh=sA("debugcamerafit"),Yp=sA("smoothcam"),BgA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let vk;class _l extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class Pt extends NA{constructor(){super(...arguments);r(this,"autoFit",!1);r(this,"enableRotate",!0);r(this,"autoRotate",!1);r(this,"autoRotateSpeed",1);r(this,"enableKeys",!0);r(this,"enableDamping",!0);r(this,"dampingFactor",.1);r(this,"enableZoom",!0);r(this,"minZoom",0);r(this,"maxZoom",1/0);r(this,"enablePan",!0);r(this,"lookAtConstraint",null);r(this,"lookAtConstraint01",1);r(this,"allowInterrupt",!0);r(this,"middleClickToFocus",!0);r(this,"doubleClickToFocus",!0);r(this,"useSlerp",!0);r(this,"debugLog",!1);r(this,"targetLerpDuration",1);r(this,"autoTarget",!0);r(this,"_controls",null);r(this,"_cameraObject",null);r(this,"_lookTargetLerpActive",!1);r(this,"_lookTargetStartPosition",new w);r(this,"_lookTargetEndPosition",new w);r(this,"_lookTargetLerp01",0);r(this,"_lookTargetLerpDuration",0);r(this,"_cameraLerpActive",!1);r(this,"_cameraStartPosition",new w);r(this,"_cameraEndPosition",new w);r(this,"_cameraLerp01",0);r(this,"_cameraLerpDuration",0);r(this,"_inputs",0);r(this,"_enableTime",0);r(this,"_startedListeningToKeyEvents",!1);r(this,"_eventSystem");r(this,"_afterHandleInputFn");r(this,"_camera",null);r(this,"_syncedTransform");r(this,"_didStart",!1);r(this,"targetElement",null);r(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});r(this,"_shouldDisable",!1);r(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)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){this._didStart=!1,this._startedListeningToKeyEvents=!1}start(){if(this._didStart=!0,this.autoTarget&&this._controls){const e=IA.getComponent(this.gameObject,Ot);if(e&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const g=ce(e.cam).length(),I=new w(0,0,-g).applyMatrix4(e.cam.matrixWorld);this.setLookTargetPosition(I,!0)}if(this.autoTarget&&!this.setLookTargetFromConstraint()){const t=new ro;t.screenPoint=new tA(0,0),t.lineThreshold=.1;const g=this.context.physics.raycast(t);g.length>0&&this.setLookTargetPosition(g[0].point,!0),oh&&console.log("OrbitControls hits",...g)}this.autoFit&&this.fitCamera()}this._eventSystem=QI.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(oM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(oM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=IA.getComponent(this.gameObject,Ot);this._camera=e;const t=e==null?void 0:e.cam;if(t&&Pv(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 g=this.targetElement??this.context.domElement,I=t==null?void 0:t.quaternion.clone();this._controls=new DiA(t,g),t==null||t.quaternion.copy(I),vk===void 0&&(vk={...this._controls.keys})}this._controls&&(Tp&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,FC()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(t==null?void 0:t.type)==="PerspectiveCamera"?Tp||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):Tp||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=IA.getComponent(this.gameObject,va)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&Pv(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))}onBeforeRender(){var t,g;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&((t=this.context.input.getPointerPositionDelta(0))!=null&&t.length())||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0;let e=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(e||(e=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),e&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new _l(this,"camera"));else{const I=ZA.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,I)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new _l(this,"lookat"));else{const I=ZA.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,I)}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?vk:BgA,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,typeof Yp=="number"||Yp===!0){this._controls.enableDamping=!0;const I=typeof Yp=="number"?Yp:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,I))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!Tp&&((g=this.lookAtConstraint)!=null&&g.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update())}}setCameraAndLookTarget(e){if(!e||!(e instanceof SA))return;const t=ce(e),g=vR(e);this.setTargetFromRaycast(new Us(t,g)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var g,I;e&&(e instanceof SA&&(e=ce(e)),this._cameraEndPosition||(this._cameraEndPosition=new w),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,(g=this.controllerObject)==null||g.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((I=this._cameraObject)==null?void 0:I.position),typeof t=="number"?this._cameraLerpDuration=t:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(e=null,t=!1){this._controls&&e&&(e instanceof SA&&(e=ce(e)),this._lookTargetEndPosition.copy(e),t===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof t=="number"?this._lookTargetLerpDuration=t:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,t=1){var I;if(!this._controls)return!1;const g=(I=this.lookAtConstraint)==null?void 0:I.sources;if(g&&g.length>0){const o=g[e];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,t),!0}return!1}lerpTarget(e,t){return this.lerpLookTarget(e,t)}lerpLookTarget(e,t){this._controls&&(t>=1?this._controls.target.copy(e):this._controls.target.lerp(e,t))}setTargetFromRaycast(e){var g,I;if(!this.controls)return;const t=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const o of t)if(o.distance>0&&IA.isActiveInHierarchy(o.object)){const s=Hy(o.object);if(s){const n=s.canvas;if(n!=null&&n.screenspace)break}if(this.setLookTargetPosition(o.point),this.context.mainCamera){const C=ce(this.context.mainCamera).clone().sub(this.controls.target).add(this._lookTargetEndPosition);(I=(g=this._cameraObject)==null?void 0:g.parent)==null||I.worldToLocal(C),this.setCameraTargetPosition(C)}break}}fitCamera(e,t=1.1,g=!0){const I=this._cameraObject,o=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0||!I||!o)return;const s=new w,n=new w,C=new _i;C.makeEmpty();const a=[];function B(u){let f=!0;if(u.visible&&CgA(u)!==!1&&!(u.type==="TransformControlsGizmo"||u.type==="TransformControlsPlane")&&(u instanceof IG&&(f=!1),u instanceof MR&&(f=!1),u instanceof Z2&&(f=!1),u.material instanceof Ow&&(f=!1),u instanceof pA||(f=!1),u!==I&&u.isUI!==!0)){if(f){oh&&console.log(u.name,u.type,u);const k=u.children;u.children=a;const m=u.position,G=u.scale;if(Number.isNaN(m.x)||Number.isNaN(m.y)||Number.isNaN(m.z)){console.warn(`Object "${u.name}" has NaN values in position or scale.... will ignore it`,m,G);return}C.expandByObject(u,!0),u.children=k}for(const k of u.children)B(k)}}for(const u of e)u.updateMatrixWorld(),B(u);if(I.updateMatrixWorld(),I.updateProjectionMatrix(),C.getCenter(n),C.applyMatrix4(I.matrixWorldInverse),C.getSize(s),C.setFromCenterAndSize(n,s),Number.isNaN(s.x)||Number.isNaN(s.y)||Number.isNaN(s.z)){console.warn("Camera fit size resultet in NaN",I,C,[...e]);return}if(s.length()<=1e-10){oh&&console.warn("Camera fit size is zero",C,[...e]);return}const Q=I.fov,E=2*Math.atan(Math.tan(Q*Math.PI/360/2)*I.aspect)/Math.PI*360,c=s.y/(2*Math.atan(Math.PI*Q/360)),l=s.x/(2*Math.atan(Math.PI*E/360)),d=t*Math.max(c,l)+s.z/2;oh&&console.log("Fit camera to objects",c,l,"distance",d);const h=ce(I),p=o.target.clone().sub(h).normalize().multiplyScalar(d);if(o.maxDistance=d*10,o.minDistance=d*.01,this.setLookTargetPosition(n,g),this.autoTarget=!1,I.near=d/100,I.far=d*100,I.updateMatrixWorld(),I.updateProjectionMatrix(),I.parent){const u=I.parent.worldToLocal(o.target.clone().sub(p));this.setCameraTargetPosition(u,g)}else console.error(`Can not fit camera ${I.name} because it has no parent`);if(oh){const u=new IG(C);this.context.scene.add(u),bR(u,wd(I)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",f=>{f.code==="KeyF"&&this.fitCamera(e)}))}o.update()}}vg([D()],Pt.prototype,"autoFit",2);vg([D()],Pt.prototype,"enableRotate",2);vg([D()],Pt.prototype,"autoRotate",2);vg([D()],Pt.prototype,"autoRotateSpeed",2);vg([D()],Pt.prototype,"enableKeys",2);vg([D()],Pt.prototype,"enableDamping",2);vg([D()],Pt.prototype,"dampingFactor",2);vg([D()],Pt.prototype,"enableZoom",2);vg([D()],Pt.prototype,"minZoom",2);vg([D()],Pt.prototype,"maxZoom",2);vg([D()],Pt.prototype,"enablePan",2);vg([D(Hd)],Pt.prototype,"lookAtConstraint",2);vg([D()],Pt.prototype,"lookAtConstraint01",2);vg([D()],Pt.prototype,"allowInterrupt",2);vg([D()],Pt.prototype,"middleClickToFocus",2);vg([D()],Pt.prototype,"doubleClickToFocus",2);vg([D()],Pt.prototype,"targetLerpDuration",2);var QgA=Object.defineProperty,EgA=Object.getOwnPropertyDescriptor,ho=(i,A,e,t)=>{for(var g=t>1?void 0:t?EgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&QgA(A,e,g),g},BB=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(BB||{});const xr=sA("debugcam"),Vv=sA("debugscreenpointtoray");var Cf;const Gh=(Cf=class extends NA{constructor(){super(...arguments);r(this,"_nearClipPlane",.1);r(this,"_farClipPlane",1e3);r(this,"orthographic",!1);r(this,"orthographicSize",5);r(this,"ARBackgroundAlpha",0);r(this,"_cullingMask",4294967295);r(this,"_backgroundBlurriness");r(this,"_backgroundIntensity");r(this,"_environmentIntensity");r(this,"_targetTexture",null);r(this,"_backgroundColor");r(this,"_fov");r(this,"_cam",null);r(this,"_clearFlags",2);r(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof je?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof je?this._cam.fov:this._fov}set fieldOfView(A){const e=this.fieldOfView!=A;if(this._fov=A,e&&this._cam&&this._cam instanceof je){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(A){const e=this._nearClipPlane!=A;this._nearClipPlane=A,this._cam&&e&&(this._cam.near=A,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(A){const e=this._farClipPlane!=A;this._farClipPlane=A,this._cam&&e&&(this._cam.far=A,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(A){A!==this._clearFlags&&(this._clearFlags=A,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(A){this._cullingMask=A,this._cam&&(this._cam.layers.mask=A)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(A){this.cullingMask=(1<<A|0)>>>0}set backgroundBlurriness(A){A!==this._backgroundBlurriness&&(A===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(A,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(A){A!==this._backgroundIntensity&&(A===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(A,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(A){this._environmentIntensity=A}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(A){if(A){if(this._backgroundColor)this._backgroundColor.copy(A);else{if(!A.clone)return;this._backgroundColor=A.clone()}A.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(A){this._targetTexture=A}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(A,e,t){const g=this.cam,I=Gh._origin;I.set(A,e,-1),this.context.input.convertScreenspaceToRaycastSpace(I),Vv&&console.log("screenPointToRay",A.toFixed(2),e.toFixed(2),"now:",I.x.toFixed(2),I.y.toFixed(2),"isInXR:"+this.context.isInXR),I.z=-1,I.unproject(g);const o=Gh._direction.set(I.x,I.y,I.z),s=ce(g);return o.sub(s),o.normalize(),t?(t.set(s,o),t):new Us(s.clone(),o.clone())}awake(){Vv&&window.addEventListener("pointerdown",A=>{const e=A.clientX,t=A.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const g=this.screenPointToRay(e,t),I="#"+Math.floor(Math.random()*16777215).toString(16);tn.DrawRay(g.origin,g.direction,I,10)})}onEnable(){xr&&console.log(`Camera enabled: "${this.name}". ClearFlags=${BB[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),hgA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),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 A=this.context.renderer;if(A){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,A),e==null||e.applyClearFlags()}}}buildCamera(){if(this._cam)return;const A=this.gameObject.isCamera;let e=null;if(A?(e=this.gameObject,e==null||e.layers.enableAll(),e instanceof je&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof je&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new je(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 RC(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){xr&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,xr){const A=`Camera "${this.name}" clear flags: ${BB[this._clearFlags]}`;console.log(A)}switch(this._clearFlags){case 1:if(Gh.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 A=this._backgroundColor.alpha;Gh.backgroundShouldBeTransparent(this.context)&&(A=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,A)}else xr&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new cgA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(A){var I,o,s,n;const e=(I=A.renderer.xr)==null?void 0:I.getSession();if(!e)return!1;if(typeof e._transparent=="boolean")return e._transparent;const t=e.environmentBlendMode;xr&&mi("Environment blend mode: "+t+" on "+navigator.userAgent);let g=t==="additive"||t==="alpha-blend";return A.xrSessionMode===Nl.ImmersiveAR&&t==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&((n=navigator.userAgent)!=null&&n.includes("Mobile WebXRViewer/v2")))&&(g=!0),e._transparent=g,g}},r(Cf,"_origin",new w),r(Cf,"_direction",new w),Cf);let Ot=Gh;ho([D()],Ot.prototype,"fieldOfView",1);ho([D()],Ot.prototype,"nearClipPlane",1);ho([D()],Ot.prototype,"farClipPlane",1);ho([D()],Ot.prototype,"clearFlags",1);ho([D()],Ot.prototype,"orthographic",2);ho([D()],Ot.prototype,"orthographicSize",2);ho([D()],Ot.prototype,"ARBackgroundAlpha",2);ho([D()],Ot.prototype,"cullingMask",1);ho([D()],Ot.prototype,"backgroundBlurriness",1);ho([D()],Ot.prototype,"backgroundIntensity",1);ho([D()],Ot.prototype,"environmentIntensity",1);ho([D(St)],Ot.prototype,"backgroundColor",1);ho([D(ka)],Ot.prototype,"targetTexture",1);class cgA{constructor(A){r(this,"_camera");r(this,"_skybox");this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(xr&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.colorSpace=Ie,this._skybox.mapping=Po,this.context.scene.background=this._skybox):(this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background)),(xr||_e())&&hg(`Camera "${this._camera.name}" has no skybox texture`))}}function hgA(i){sA("freecam")&&i.context.mainCameraComponent===i&&IA.getOrAddComponent(i.gameObject,Pt)}class ma extends NA{constructor(){super(...arguments);r(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new Lx),this._listener}awake(){Ji.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=this.context.mainCameraComponent||IA.getComponentInParent(this.gameObject,Ot);t!=null&&t.cam?t.cam.add(e):this.gameObject.add(e)})}}var lgA=Object.defineProperty,dgA=Object.getOwnPropertyDescriptor,_y=(i,A,e,t)=>{for(var g=t>1?void 0:t?dgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&lgA(A,e,g),g};const ugA=sA("debugsignals");class Od{constructor(){r(this,"guid")}}_y([D()],Od.prototype,"guid",2);class sc{constructor(){r(this,"signal");r(this,"reaction")}}_y([D(Od)],sc.prototype,"signal",2);_y([D(mg)],sc.prototype,"reaction",2);var dm;const _n=(dm=class extends NA{constructor(){super(...arguments);r(this,"events")}static invoke(A){if(_n.receivers[A]){const e=_n.receivers[A];if(!e)return;for(const t of e)t.invoke(A)}}awake(){ugA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const A of this.events)_n.receivers[A.signal.guid]||(_n.receivers[A.signal.guid]=[]),_n.receivers[A.signal.guid].push(this)}onDisable(){if(this.events){for(const A of this.events)if(_n.receivers[A.signal.guid]){const e=_n.receivers[A.signal.guid].indexOf(this);e>=0&&_n.receivers[A.signal.guid].splice(e,1)}}}invoke(A){if(!this.events||!Array.isArray(this.events))return;const e=typeof A=="object"?A.guid:A;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(g){console.error(g)}}},r(dm,"receivers",{}),dm);let nc=_n;_y([D(sc)],nc.prototype,"events",2);var zI=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(zI||{}),Os=(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))(Os||{}),gF=(i=>(i.Signal="SignalEmitter",i))(gF||{});const CC=sA("debugtimeline");class Pd{constructor(){r(this,"director");r(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let t=this.track.clips.length-1;t>=0;t--)yield this.track.clips[t];else for(const t of this.track.clips)yield t}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,t,g=!0){if(e<0||e>=t.length)return 0;const I=t[e];if(g||A>=I.start&&A<=I.end){let o=1;const s=!1;if(I.easeInDuration>0){const n=Math.min((A-I.start)/I.easeInDuration,1);o*=n}if(I.easeOutDuration>0&&!s){const n=Math.min((I.end-A)/I.easeOutDuration,1);o*=n}return o}return 0}}class pgA{constructor(A){r(this,"clip");r(this,"rootPositionOffset");r(this,"rootQuaternionOffset");r(this,"rootStartPosition");r(this,"rootEndPosition");r(this,"rootStartQuaternion");r(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const t=A.getRoot(),g=t.name+".position",I=t.name+".quaternion";CC&&console.log(e.name,e.tracks,g);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(g))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),CC&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new GA().fromArray(o.values,0),this.rootEndQuaternion=new GA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),CC)){const s=new Mi().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Oy extends Pd{constructor(){super(...arguments);r(this,"models",[]);r(this,"trackOffset");r(this,"target");r(this,"mixer");r(this,"clips",[]);r(this,"actions",[]);r(this,"_actionOffsets",[]);r(this,"_didBind",!1);r(this,"_animator",null);r(this,"_useclipOffsets",!0);r(this,"_totalOffsetPosition",new w);r(this,"_totalOffsetRotation",new GA);r(this,"_totalOffsetPosition2",new w);r(this,"_totalOffsetRotation2",new GA);r(this,"_summedPos",new w);r(this,"_tempPos",new w);r(this,"_summedRot",new GA);r(this,"_tempRot",new GA);r(this,"_clipRotQuat",new GA)}onStateChanged(){this._animator&&zv(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var a,B;if(((a=t.tracks)==null?void 0:a.length)<=0){console.warn("No tracks in AnimationClip",t);return}const g=t.tracks[0].name.split("."),I=g[g.length-2],o=I+".position",s=I+".quaternion";let n=!1,C=!1;for(const Q of t.tracks)Q.name.endsWith(o)?(n=!0,this.createPositionInterpolant(t,e,Q)):Q.name.endsWith(s)&&(C=!0,this.createRotationInterpolant(t,e,Q));if(!n||!C){const Q=(B=this.mixer)==null?void 0:B.getRoot(),E=t.tracks[0],c=E.name.lastIndexOf("."),l=E.name.substring(0,c),d=l.substring(l.lastIndexOf(".")+1),h=Q.getObjectByName(d);if(h)if(n){if(!C){const p=t.tracks[0].name.substring(0,c)+".quaternion";CC&&console.warn("Create quaternion track",d,h);const u=h.quaternion,f=new Qn(p,[0,t.duration],[u.x,u.y,u.z,u.w,u.x,u.y,u.z,u.w]);t.tracks.push(f),this.createRotationInterpolant(t,e,f)}}else{const p=l+".position";CC&&console.warn("Create position track",d,h);const u=h.position,f=new DC(p,[0,t.duration],[u.x,u.y,u.z,u.x,u.y,u.z]);t.tracks.push(f),this.createPositionInterpolant(t,e,f)}}}bind(){if(!this._didBind){this._didBind=!0,CC&&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 pgA(e);this._actionOffsets.push(t)}this.target&&(this._animator=IA.getComponent(this.target,Rg)??null,this._animator&&zv(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,g=t.position,I=t.rotation;g&&g.x!==void 0&&(g.isVector3||(t.position=new w(g.x,g.y,g.z)),I.isQuaternion||(t.rotation=new GA(I.x,I.y,I.z,I.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 GA(t.x,t.y,t.z,t.w)))}}evaluate(e){var n,C,a,B,Q,E,c;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 t=0,g=0,I=!1,o=!1,s=0;for(let l=0;l<this.clips.length;l++){const d=this.models[l],h=this.actions[l],p=d.asset;h.weight=0;const u=e>=d.start&&e<=d.end,f=d.preExtrapolationMode,k=d.postExtrapolationMode,m=l<this.clips.length-1?this.models[l+1]:null;let G=u,R=!1;if(!G&&!I&&d.end<e&&k!==Os.None?(!m||m.start>e)&&(G=!0,I=!0):l==0&&!G&&!o&&d.start>e&&f!==Os.None&&(!m||m.start<e)&&(G=!0,R=!0,o=!0),G){let S=1;S*=this.evaluateWeight(e,l,this.models,G),S*=this.director.weight;let M=u;if(R)switch(f){case Os.Hold:break;case Os.Loop:e+=d.start,M=!0;break;default:e+=d.start,M=!0;break}let K=this.getClipTime(e,d),P=0;const b=p.duration;if(R&&f===Os.Hold&&(K=0),M){if(p.loop)for(P+=Math.floor(K/(b+1e-6));K>b;)K-=b}else if(!u&&I)switch(k){case Os.Hold:K=this.getClipTime(d.end,d);break;case Os.Loop:K%=b;break;case Os.PingPong:const T=Math.floor(K/b)%2!==0;K%=b,T&&(K=b-K);break}d.reversed===!0?h.time=h.getClip().duration-K:h.time=K,h.timeScale=0;const H=Math.max(0,S);if(h.weight=H,s+=H,h.clampWhenFinished=!1,h.isRunning()||h.play(),this._useclipOffsets){const W=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,T=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(g=1-S),t+=1;const v=this._summedPos.set(0,0,0),Y=this._tempPos.set(0,0,0),AA=this._summedRot.identity(),$=this._tempRot.identity(),V=p.rotation;V&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(V,S));const gA=this._actionOffsets[l];if(gA.hasOffsets)for(let dA=0;dA<P;dA++)gA.rootPositionOffset?Y.copy(gA.rootPositionOffset):Y.set(0,0,0),Y.applyQuaternion(AA),this._clipRotQuat&&Y.applyQuaternion(this._clipRotQuat),gA.rootQuaternionOffset&&($.copy(gA.rootQuaternionOffset),AA.multiply($)),v.add(Y);this._clipRotQuat&&T.multiply(this._clipRotQuat),T.multiply(AA),p.position&&v.add(p.position),W.add(v)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,g),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,g)),this.__mixerError===void 0&&(CC||_e())&&((C=(n=this._animator)==null?void 0:n.runtimeAnimatorController)!=null&&C.mixer)&&this.mixer!==((B=(a=this._animator)==null?void 0:a.runtimeAnimatorController)==null?void 0:B.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)),(Q=this._animator)!=null&&Q.runtimeAnimatorController){const l=Math.max(0,1-s);(c=(E=this._animator)==null?void 0:E.runtimeAnimatorController)==null||c.update(l)}else this.mixer.update(e)}createRotationInterpolant(e,t,g){var n;const I=g.createInterpolant.bind(g),o=new GA;this.ensureTrackOffsets();const s=(n=this.trackOffset)==null?void 0:n.rotation;g.createInterpolant=()=>{const C=I(),a=C.evaluate.bind(C);return C.evaluate=B=>{var E;const Q=a(B);if(o.set(Q[0],Q[1],Q[2],Q[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),this.director.animationCallbackReceivers)for(const c of this.director.animationCallbackReceivers)(E=c==null?void 0:c.onTimelineRotation)==null||E.call(c,this.director,this.target,B,o);return Q[0]=o.x,Q[1]=o.y,Q[2]=o.z,Q[3]=o.w,Q},C}}createPositionInterpolant(e,t,g){var a,B;const I=g.createInterpolant.bind(g),o=new w;this.ensureTrackOffsets();const s=(a=this.trackOffset)==null?void 0:a.rotation,n=(B=this.trackOffset)==null?void 0:B.position;let C;g.createInterpolant=()=>{const Q=I(),E=Q.evaluate.bind(Q);return Q.evaluate=c=>{var d,h,p;const l=E(c);if(o.set(l[0],l[1],l[2]),t.removeStartOffset&&(C===void 0?(C=null,C=(h=(d=this._actionOffsets.find(u=>u.clip===e))==null?void 0:d.rootStartPosition)==null?void 0:h.clone()):C!=null&&C.isVector3&&o.sub(C)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),s&&o.applyQuaternion(s),n&&(o.x-=n.x,o.y+=n.y,o.z+=n.z),this.director.animationCallbackReceivers)for(const u of this.director.animationCallbackReceivers)(p=u==null?void 0:u.onTimelinePosition)==null||p.call(u,this.director,this.target,c,o);return l[0]=o.x,l[1]=o.y,l[2]=o.z,l},Q}}}const fgA=sA("mutetimeline"),XQ=class extends Pd{constructor(){super(...arguments);r(this,"models",[]);r(this,"listener");r(this,"audio",[]);r(this,"audioContextTimeOffset",[]);r(this,"lastTime",0);r(this,"audioSource");r(this,"_audioLoader",null)}getAudioFilePath(e){const t=this.director.sourceId;return UC(t,e)}onAllowAudioChanged(e){for(let t=0;t<this.models.length;t++){const g=this.models[t];this.audio[t].setVolume(e?g.asset.volume:0)}}addModel(e){const t=new kR(this.listener);this.audio.push(t),this.models.push(e)}onDisable(){for(const e of this.audio)e.isPlaying&&e.stop()}onDestroy(){for(const e of this.audio)e.source&&(e==null||e.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}}stop(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}}evaluate(e){if(fgA||this.track.muted||this.director.speed<0)return;const t=this.director.context.application.muted,g=t?.1:0;for(let I=0;I<this.models.length;I++){const o=this.models[I],s=this.audio[I],n=o.asset;if((!s||!s.buffer)&&this.isInTimeRange(o,e-1,e+1)&&this.handleAudioLoading(o,s),Ji.userInteractionRegistered!==!1&&!(s===null||!s.buffer))if(s.playbackRate=this.director.context.time.timeScale*this.director.speed,s.loop=n.loop,e>=o.start&&e<=o.end&&e<this.director.duration){if(this.director.isPlaying==!1){if(s.isPlaying&&s.stop(),this.lastTime===e)continue}else if(!s.isPlaying)s.offset=o.clipIn+(e-o.start)*o.timeScale,s.play(g);else{const a=o.clipIn+(e-o.start)*o.timeScale,B=s.context.currentTime-s._startedAt+s.offset;Math.abs(a-B)>.3&&(s.offset=a,s.stop(),s.play(g))}let C=n.volume;if(this.track.volume!==void 0&&(C*=this.track.volume),t&&(C=0),o.easeInDuration>0){const a=Math.min((e-o.start)/o.easeInDuration,1);C*=a}if(o.easeOutDuration>0){const a=Math.min((o.end-e)/o.easeOutDuration,1);C*=a}s.setVolume(C*this.director.weight)}else s.isPlaying&&s.stop()}this.lastTime=e}loadAudio(e,t=0,g=0){let I=null;const o=e-g,s=e+t;for(const n of this.models)if(this.isInTimeRange(n,o,s)){const C=this.audio[this.models.indexOf(n)],a=this.handleAudioLoading(n,C);a!==null&&(I===null&&(I=[]),I.push(a))}return I!==null?Promise.all(I):null}isInTimeRange(e,t,g){return t<=e.start&&g>=e.end||t>=e.start&&t<=e.end||g>=e.start&&g<=e.end}static dispose(){XQ._audioBuffers.clear()}handleAudioLoading(e,t){this._audioLoader||(this._audioLoader=new QD);const g=this.getAudioFilePath(e.asset.clip);if(XQ._audioBuffers.get(g)){const o=XQ._audioBuffers.get(g);return o.then(s=>{s&&t.setBuffer(s)}),o}CC&&console.warn("LOAD audio track",g,this.director.sourceId);const I=new Promise((o,s)=>{this._audioLoader.load(g,n=>{t.setBuffer(n),o(n)},void 0,n=>{console.error("Error loading audio",n),o(null)})});return XQ._audioBuffers.set(g,I),I}};let iB=XQ;r(iB,"_audioBuffers",new Map);class Ol extends Pd{constructor(){super(...arguments);r(this,"models",[]);r(this,"didTrigger",[]);r(this,"receivers",[])}evaluate(e){var g;if(this.track.muted)return;const t=this.director.context.time.deltaTime*1.5;for(let I=0;I<this.models.length;I++){const o=this.models[I],s=this.didTrigger[I],n=o.time-e;let C=!1;if(o.retroActive)C=n<=1e-6;else{const a=Math.abs(n);(a===0||a>=1e-5&&a<t)&&(C=!0)}if(C){if(!s)if(CC&&console.log("Trigger signal",e,o.time,o),this.didTrigger[I]=!0,((g=this.receivers)==null?void 0:g.length)<=0)nc.invoke(o.asset);else for(const a of this.receivers)a&&a.invoke(o.asset)}else o.emitOnce||(this.didTrigger[I]=!1)}}}class Py extends Pd{constructor(){super(...arguments);r(this,"models",[]);r(this,"timelines",[]);r(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const I=this.models[t].asset;if(!I.sourceObject||typeof I.sourceObject!="object"){console.log("no source object, removing model",t,I),this.models.splice(t,1);continue}else{const o=IA.getComponent(I.sourceObject,pC);this.timelines.push(o),o&&I.updateDirector&&(o.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=I.asset;if(e>=I.start&&e<=I.end){this._previousActiveModel=I;const s=this.getClipTime(e,I);if(o.controlActivation){const n=o.sourceObject;n.visible=!0}if(o.updateDirector){const n=this.timelines[g];n&&(n.isPlaying&&n.pause(),n.time=s,n.evaluate())}}else{const s=(t=this._previousActiveModel)==null?void 0:t.asset;if(o.controlActivation){const n=o.sourceObject;(s==null?void 0:s.sourceObject)!==n&&(n.visible=!1)}}}}}const pQ=sA("debugtimeline"),Bw=class extends NA{constructor(){super(...arguments);r(this,"playableAsset");r(this,"playOnAwake");r(this,"extrapolationMode",1);r(this,"waitForAudio",!0);r(this,"_visibilityChangeEvt");r(this,"_clonedPlayableAsset",!1);r(this,"_speed",1);r(this,"_guidsMap");r(this,"_isPlaying",!1);r(this,"_internalUpdateRoutine");r(this,"_isPaused",!1);r(this,"_isStopping",!1);r(this,"_time",0);r(this,"_duration",0);r(this,"_weight",1);r(this,"_animationTracks",[]);r(this,"_audioTracks",[]);r(this,"_signalTracks",[]);r(this,"_controlTracks",[]);r(this,"_customTracks",[]);r(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);r(this,"animationCallbackReceivers",[])}static registerCreateTrack(e,t){this.createTrackFunctions[e]=t}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(e){typeof e=="number"&&!Number.isNaN(e)?this._time=e:(pQ||dI())&&console.error("INVALID TIMELINE.TIME VALUE",e,this.name)}get duration(){return this._duration}set duration(e){this._duration=e}get weight(){return this._weight}set weight(e){this._weight=e}get speed(){return this._speed}set speed(e){this._speed=e}awake(){var e,t,g;pQ&&console.log(this,(e=this.playableAsset)==null?void 0:e.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(t=this.playableAsset)==null?void 0:t.tracks,Array.isArray((g=this.playableAsset)==null?void 0:g.tracks),this)}onEnable(){var e,t,g;for(const I of this._audioTracks)(e=I.onEnable)==null||e.call(I);for(const I of this._customTracks)(t=I.onEnable)==null||t.call(I);for(const I of this._animationTracks)(g=I.onEnable)==null||g.call(I);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 e,t,g;this.stop();for(const I of this._audioTracks)(e=I.onDisable)==null||e.call(I);for(const I of this._customTracks)(t=I.onDisable)==null||t.call(I);for(const I of this._animationTracks)(g=I.onDisable)==null||g.call(I);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var e;for(const t of this._allTracks)for(const g of t)(e=g.onDestroy)==null||e.call(g)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const e=this._isPaused==!0;if(this._isPaused=!1,e&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const t=[];for(const g of this._audioTracks){const I=g.loadAudio(this._time,1,0);I&&t.push(I)}if(t.length>0&&(await Promise.all(t),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!Ji.userInteractionRegistered&&this.waitForAudio;)await Ka(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Qg.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const g of this._audioTracks)g.stop();const e=this._isPaused==!0,t=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),e&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,e&&!t&&this.invokePauseChangedMethodsOnTracks(),t&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const e of this._allTracks)for(const t of e)yield t}get audioTracks(){return this._audioTracks}resolveGuids(e){this._guidsMap=e}invokePauseChangedMethodsOnTracks(){var e;for(const t of this.forEachTrack())(e=t.onPauseChanged)==null||e.call(t)}invokeStateChangedMethodsOnTracks(){var e;for(const t of this.forEachTrack())(e=t.onStateChanged)==null||e.call(t,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(e=!1){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}const g=this._time;for(const I of this.playableAsset.tracks)if(!I.muted)switch(I.type){case zI.Activation:if(!e&&!this._isPlaying)continue;for(let o=0;o<I.outputs.length;o++){const s=I.outputs[o];if(typeof s=="object"){let n=!1;if(I.clips)for(const a of I.clips)a.start<=g&&g<=a.end&&(n=!0);const C=s;C.visible!==void 0&&C.visible!==n&&(C.visible=n,pQ&&console.warn(this.name,"set ActivationTrack-"+o,C.name,n,g))}}break}if(!this._isStopping)for(const I of this._animationTracks)I.evaluate(g);for(const I of this._audioTracks)I.evaluate(g);for(const I of this._signalTracks)I.evaluate(g);for(const I of this._controlTracks)I.evaluate(g);for(const I of this._customTracks)I.evaluate(g)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=ey(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const e=this.findRoot(this.gameObject);for(const t of this.playableAsset.tracks){for(let g=t.outputs.length-1;g>=0;g--){let I=t.outputs[g];if(typeof I=="string"){this._guidsMap&&this._guidsMap[I]&&(I=this._guidsMap[I]);const o=IA.findByGuid(I,e);o===null||typeof o!="object"?(t.outputs.splice(g,1),console.warn("Failed to resolve binding",I,t.name,t.type)):(pQ&&console.log("Resolved binding",I,"to",o),t.outputs[g]=o)}else if(I===null){if(t.outputs.splice(g,1),Bw.createTrackFunctions[t.type])continue;t.type!==zI.Audio&&t.type!==zI.Control&&t.type!==zI.Marker&&t.type!==zI.Signal&&console.warn("Missing binding",I,t.name,t.type,this.name,this.playableAsset.name)}}if(t.type===zI.Control&&t.clips)for(let g=0;g<t.clips.length;g++){const I=t.clips[g];let o=I.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const s=IA.findByGuid(o,e);s===null||typeof s!="object"?console.warn("Failed to resolve sourceObject binding",o,t.name,I):(pQ&&console.log("Resolved binding",o,"to",s),I.asset.sourceObject=s)}}}}findRoot(e){return e.parent?this.findRoot(e.parent):e}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const e of this.playableAsset.tracks)if(e.muted!==!0){if(e.clips)for(const t of e.clips)t.end>this._duration&&(this._duration=t.end);if(e.markers)for(const t of e.markers)t.time>this._duration&&(this._duration=t.time+.001)}}}setupAndCreateTrackHandlers(){var t,g,I;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let e=IA.findObjectOfType(ma,this.context);for(const o of this.playableAsset.tracks){const s=o.type,n=Bw.createTrackFunctions[s];if(n!=null){const C=n(this,o);if(typeof C.evaluate=="function"){C.director=this,C.track=o,this._customTracks.push(C);continue}}if(o.type===zI.Animation){if(!o.clips||o.clips.length<=0){pQ&&console.warn("Animation track has no clips",o);continue}for(let C=o.outputs.length-1;C>=0;C--){let a=o.outputs[C];if(a instanceof SA){const Q=IA.getOrAddComponent(a,Rg);Q&&(a=Q)}const B=(t=a==null?void 0:a.gameObject)==null?void 0:t.animations;if(B){const Q=new Oy;Q.trackOffset=o.trackOffset,Q.director=this,Q.track=o;for(let E=0;E<o.clips.length;E++){const c=o.clips[E],l=c.asset;if(!l){console.error("MISSING anim model?","clip#"+E,c,o,this.playableAsset,this.name);continue}const d=l.clip;let h=d;if((typeof h=="string"||typeof h=="number")&&(h=B.find(u=>u.name===d)),!h){console.warn("Could not find animationClip for model",c,o.name,this.name,(g=this.playableAsset)==null?void 0:g.name);continue}a instanceof Rg&&a.runtimeAnimatorController&&(a.__internalDidAwakeAndStart||a.initializeRuntimeAnimatorController(),a.runtimeAnimatorController.mixer||a.runtimeAnimatorController.bind(a),Q.mixer=a.runtimeAnimatorController.mixer),Q.mixer||(Q.mixer=new $w(a.gameObject)),Q.clips.push(h),Q.mixer.uncacheAction(h),Q.createHooks(c.asset,h);const p=Q.mixer.clipAction(h);Q.actions.push(p),Q.models.push(c)}this._animationTracks.push(Q)}}}else if(o.type===zI.Audio){if(!o.clips||o.clips.length<=0)continue;const C=new iB;C.director=this,C.track=o,C.audioSource=o.outputs.find(a=>a instanceof Ji),this._audioTracks.push(C),e||(e=(I=this.context.mainCameraComponent)==null?void 0:I.gameObject.addNewComponent(ma)),C.listener=e.listener;for(let a=0;a<o.clips.length;a++){const B=o.clips[a];C.addModel(B)}}else if(o.type===zI.Marker){const C=new Ol;if(C.director=this,C.track=o,o.markers)for(const a of o.markers)switch(a.type){case gF.Signal:C.models.push(a),C.didTrigger.push(!1);break}if(C!==null&&C.models.length>0){const a=IA.getComponent(this.gameObject,nc);a&&(C.receivers.push(a),this._signalTracks.push(C))}}else if(o.type===zI.Signal){const C=new Ol;if(C.director=this,C.track=o,o.markers)for(const a of o.markers)C.models.push(a),C.didTrigger.push(!1);for(const a of o.outputs)C.receivers.push(a);this._signalTracks.push(C)}else if(o.type===zI.Control){const C=new Py;if(C.director=this,C.track=o,o.clips)for(const a of o.clips)C.models.push(a);C.resolveSourceObjects(this.context),this._controlTracks.push(C)}}}setAudioTracksAllowPlaying(e){for(const t of this._audioTracks)t.onAllowAudioChanged(e)}registerAnimationCallback(e){this.animationCallbackReceivers.push(e)}unregisterAnimationCallback(e){const t=this.animationCallbackReceivers.indexOf(e);t!==-1&&this.animationCallbackReceivers.splice(t,1)}};let pC=Bw;r(pC,"createTrackFunctions",{});const _f=Symbol("objectIsAnimatedData");function zv(i,A,e){if(!i)return;if(i[_f]===void 0){if(!e)return;i[_f]=new Set}const t=i[_f];e?t.add(A):t.has(A)&&t.delete(A)}function DgA(i){if(!i)return!1;const A=i[_f];return A!==void 0&&A.size>0}Ut.registerCallback(Xi.ContextCreated,i=>{const A=i.context.domElement.getAttribute("autoplay");if(A!==void 0&&(A===""||A==="true")&&i.files)for(const e of i.files)IA.foreachComponent(e.file.scene,g=>{if(g.enabled!==!1){if(g instanceof Eo&&g.playAutomatically||g instanceof Rg||g instanceof pC&&g.playOnAwake===!0)return!0;if(g instanceof Eo)return g.playAutomatically=!0,!0;if(g instanceof pC)return g.playOnAwake=!0,!0}},!0)!==!0&&wgA(e.file)});function wgA(i){if(!i||!i.animations)return;for(let e=0;e<i.animations.length;e++){const t=i.animations[e];if(!(!t.tracks||t.tracks.length<=0))for(const g in t.tracks){const I=t.tracks[g],o=I.__objectName??I.name.substring(0,I.name.indexOf("."));let s=i.scene.getObjectByName(o);if(!s&&(s=i.scene.getObjectByProperty("uuid",o),!s))continue;let n=A(s);n||(n=Wa(i.scene,new Eo));const C=n.animations=n.animations||[];t.name_animator=n.name,C.indexOf(t)<0&&C.push(t)}}function A(e){var g;if(!e)return;const t=(g=e.userData)==null?void 0:g.components;if(t&&t.length>0)for(let I=0;I<t.length;I++){const o=t[I];if(o instanceof Rg||o instanceof Eo)return e}return A(e.parent)}}var ygA=Object.defineProperty,SgA=Object.getOwnPropertyDescriptor,Wy=(i,A,e,t)=>{for(var g=t>1?void 0:t?SgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&ygA(A,e,g),g};const jv=sA("debuganimator");class Rg extends NA{constructor(){super(...arguments);r(this,"applyRootMotion",!1);r(this,"hasRootMotion",!1);r(this,"keepAnimatorControllerStateOnDisable",!1);r(this,"_parametersAreDirty",!1);r(this,"_isDirty",!1);r(this,"speed",1);r(this,"normalizedStartOffset",0);r(this,"_animatorController",null);r(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(e){var t;this._animatorController&&this._animatorController.model===e||(e?e instanceof zo?(e.animator&&e.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(t=e.model)==null?void 0:t.name),e.model||console.error("AnimatorController has no model"),e=new zo(e.model)),this._animatorController=e,this._animatorController.bind(this)):(jv&&console.log("Assign animator controller",e,this),this._animatorController=new zo(e),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(e,t=-1,g=Number.NEGATIVE_INFINITY,I=0){this.play(e,t,g,I)}play(e,t=-1,g=Number.NEGATIVE_INFINITY,I=0){var o;(o=this.runtimeAnimatorController)==null||o.play(e,t,g,I),this._isDirty=!0}Reset(){this.reset()}reset(){var e;(e=this._animatorController)==null||e.reset(),this._isDirty=!0}SetBool(e,t){this.setBool(e,t)}setBool(e,t){var g,I;((g=this.runtimeAnimatorController)==null?void 0:g.getBool(e))!==t&&(this._parametersAreDirty=!0),(I=this.runtimeAnimatorController)==null||I.setBool(e,t)}GetBool(e){return this.getBool(e)}getBool(e){var t;return((t=this.runtimeAnimatorController)==null?void 0:t.getBool(e))??!1}SetFloat(e,t){this.setFloat(e,t)}setFloat(e,t){var g,I;((g=this.runtimeAnimatorController)==null?void 0:g.getFloat(e))!==t&&(this._parametersAreDirty=!0),(I=this.runtimeAnimatorController)==null||I.setFloat(e,t)}GetFloat(e){return this.getFloat(e)}getFloat(e){var t;return((t=this.runtimeAnimatorController)==null?void 0:t.getFloat(e))??-1}SetInteger(e,t){this.setInteger(e,t)}setInteger(e,t){var g,I;((g=this.runtimeAnimatorController)==null?void 0:g.getInteger(e))!==t&&(this._parametersAreDirty=!0),(I=this.runtimeAnimatorController)==null||I.setInteger(e,t)}GetInteger(e){return this.getInteger(e)}getInteger(e){var t;return((t=this.runtimeAnimatorController)==null?void 0:t.getInteger(e))??-1}SetTrigger(e){this.setTrigger(e)}setTrigger(e){var t;(t=this.runtimeAnimatorController)==null||t.setTrigger(e),this._parametersAreDirty=!0}ResetTrigger(e){this.resetTrigger(e)}resetTrigger(e){var t;(t=this.runtimeAnimatorController)==null||t.resetTrigger(e),this._parametersAreDirty=!0}GetTrigger(e){this.getTrigger(e)}getTrigger(e){var t;(t=this.runtimeAnimatorController)==null||t.getTrigger(e)}IsInTransition(){return this.isInTransition()}isInTransition(){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.isInTransition())??!1}SetSpeed(e){return this.setSpeed(e)}setSpeed(e){var t;e!==this.speed&&(this.speed=e,(t=this._animatorController)==null||t.setSpeed(e))}set minMaxSpeed(e){this.speed=ZA.lerp(e.x,e.y,Math.random())}set minMaxOffsetNormalized(e){this.normalizedStartOffset=ZA.lerp(e.x,e.y,Math.random()),this.runtimeAnimatorController&&(this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset)}awake(){jv&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(e=!1){const t=e||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&t){const g=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=g,g?(console.assert(this.runtimeAnimatorController!==g),this.runtimeAnimatorController=g,console.assert(this.runtimeAnimatorController===g),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this.speed),this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){var e;this.keepAnimatorControllerStateOnDisable||(e=this._animatorController)==null||e.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!DgA(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}Wy([D()],Rg.prototype,"applyRootMotion",2);Wy([D()],Rg.prototype,"hasRootMotion",2);Wy([D()],Rg.prototype,"keepAnimatorControllerStateOnDisable",2);Wy([D()],Rg.prototype,"runtimeAnimatorController",1);const aE=sA("debugusdzanimation"),sM=sA("debugusdzanimationserialization");class Vy{constructor(A,e,t){r(this,"_start");r(this,"ext");r(this,"root");r(this,"clip");this.ext=A,this.root=e,this.clip=t}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){return this.clip.duration}}class Ho{constructor(A,e,t){r(this,"clip");r(this,"pos");r(this,"rot");r(this,"scale");r(this,"root");r(this,"target");r(this,"duration",0);r(this,"useRootMotion",!1);this.root=A,this.target=e,this.clip=t,t?this.duration=t.duration:this.duration=1/this.frameRate;const g=IA.getComponent(A,Rg);g&&(this.useRootMotion=g.applyRootMotion)}get frameRate(){return 60}addTrack(A){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it – this is likely a bug");return}A.name.endsWith("position")&&(this.pos=A),A.name.endsWith("quaternion")&&(this.rot=A),A.name.endsWith("scale")&&(this.scale=A)}getFrames(){var A,e,t,g,I,o;return this.clip?Math.max(((e=(A=this.pos)==null?void 0:A.times)==null?void 0:e.length)??0,((g=(t=this.rot)==null?void 0:t.times)==null?void 0:g.length)??0,((o=(I=this.scale)==null?void 0:I.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(A=!0,e=!0,t=!0){var n,C,a;if(!this.clip)return[0,this.duration];const g=(n=this.pos)==null?void 0:n.times,I=(C=this.rot)==null?void 0:C.times,o=(a=this.scale)==null?void 0:a.times,s=[];if(A&&g)for(const B of g)s.push(B);if(e&&I)for(const B of I)s.push(B);if(t&&o)for(const B of o)s.push(B);return s.includes(0)||s.push(0),s.sort((B,Q)=>B-Q),[...new Set(s)]}*getValues(A,e=!0,t=!0,g=!0){var Q,E,c;const I=new w,o=new GA,s=new w(1,1,1),n=this.target,C=e?(Q=this.pos)==null?void 0:Q.createInterpolant():void 0,a=t?(E=this.rot)==null?void 0:E.createInterpolant():void 0,B=g?(c=this.scale)==null?void 0:c.createInterpolant():void 0;C||I.set(n.position.x,n.position.y,n.position.z),a||o.set(n.quaternion.x,n.quaternion.y,n.quaternion.z,n.quaternion.w),B||s.set(n.scale.x,n.scale.y,n.scale.z);for(let l=0;l<A.length;l++){const d=A[l];if(C){const h=C.evaluate(d);I.set(h[0],h[1],h[2])}if(a){const h=a.evaluate(d);o.set(h[0],h[1],h[2],h[3])}if(B){const h=B.evaluate(d);s.set(h[0],h[1],h[2])}if(this.useRootMotion&&n===this.root){const h=new FA;h.compose(I,o,s),h.multiply(n.matrix),h.decompose(I,o,s)}yield{time:d,translation:I,rotation:o,scale:s,index:l}}}}r(Ho,"animationDurationPadding",1);class Wd{constructor(A){r(this,"dict",new Map);r(this,"rootTargetMap",new Map);r(this,"rootAndClipToRegisteredAnimationMap",new Map);r(this,"rootToRegisteredClipCount",new Map);r(this,"serializers",[]);r(this,"injectRestPoses",!1);r(this,"injectImplicitBehaviours",!1);this.injectRestPoses=A,this.injectImplicitBehaviours=A}get extensionName(){return"animation"}getClipCount(A){let e=this.rootToRegisteredClipCount.get(A);return this.injectRestPoses&&(e=e?e-1:0),e??0}getStartTime01(A,e){const t=this.rootTargetMap.get(A);if(!t)return 0;const g=this.dict.get(t[0]);if(!g)return console.error("Trying to get start time for root that has no animation data",A,e,...this.dict),0;let I=0;for(let o=0;o<g.length&&g[o].clip!==e;o++)I+=g[o].getDuration()+Ho.animationDurationPadding;return I}registerAnimation(A,e){if(!e||!A)return null;this.rootTargetMap.has(A)||this.rootTargetMap.set(A,[]);const t=A.uuid+e.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(t))return this.rootAndClipToRegisteredAnimationMap.get(t);aE&&console.log("registerAnimation",A,e);const g=this.injectRestPoses?1:0,I=this.rootToRegisteredClipCount.get(A)??g,o=this.rootTargetMap.get(A),s=new Set(o);if(e.tracks)for(const C of e.tracks){const a=He.parseTrackName(C.name),B=He.findNode(A,a.nodeName);if(!B){console.warn("no object found for track",C.name,"using "+A.name+" instead");continue}this.dict.has(B)||this.dict.set(B,[]);const Q=this.dict.get(B);if(!Q)continue;if(s.delete(B),this.injectRestPoses&&!Q[0]){const c=new Ho(null,B,void 0);Q[0]=c}let E=Q[I];E||(E=new Ho(A,B,e),Q[I]=E),E.addTrack(C),o!=null&&o.includes(B)||o==null||o.push(B)}for(const C of s){const a=this.dict.get(C);if(!a)continue;if(this.injectRestPoses&&!a[0]){const Q=new Ho(null,C,void 0);a[0]=Q}let B=a[I];B||(aE&&console.log("Adding padding clip for ",C,e),B=new Ho(A,C,e),a[I]=B)}const n=new Vy(this,A,e);return this.rootAndClipToRegisteredAnimationMap.set(t,n),this.rootToRegisteredClipCount.set(A,I+1),n}onAfterHierarchy(A){aE&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(A){var e,t;for(const g of this.serializers){const I=(e=g.model)==null?void 0:e.parent,o=(I==null?void 0:I.isDynamic)===!0;sM&&console.log(o,(t=g.model)==null?void 0:t.parent),o&&g.registerCallback(I)}}onExportObject(A,e,t){IA.foreachComponent(A,I=>{const o=I;typeof o.createAnimation=="function"&&o.createAnimation(this,e,t)},!1);const g=new kgA(A,this.dict);this.serializers.push(g),g.registerCallback(e)}}class kgA{constructor(A,e){r(this,"object");r(this,"dict");r(this,"model");r(this,"callback");this.object=A,this.dict=e}registerCallback(A){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),sM&&console.log("REPARENT",A),this.model=A,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(A,e){const t=this.model,g=this.dict;if(t&&t.skinnedMesh){let I=function(G){const R=[];for(const[S,M]of G){let K=`${S} : [`;const P=[];for(const b of M)P.push(`(${Cg(b.x)}, ${Cg(b.y)}, ${Cg(b.z)})`);K=K.concat(P.join(", ")),K=K.concat("],"),R.push(K)}return R},o=function(G){const R=[];for(const[S,M]of G){let K=`${S} : [`;const P=[];for(const b of M)P.push(`(${Cg(b.w)}, ${Cg(b.x)}, ${Cg(b.y)}, ${Cg(b.z)})`);K=K.concat(P.join(", ")),K=K.concat("],"),R.push(K)}return R},s=function(G){let R=!0,S;for(const[K,P]of G)if(S===void 0&&(S=P.length),S!==P.length){R=!1;break}aE&&console.log("Bone count: ",G.size,"TransformData entries per bone: ",S),console.assert(R,"All bones should have the same number of TransformData entries",G);const M=[];for(const[K,P]of G){const b=new Array;let H=0;for(let W=0;W<P.length;W++)b.push(H),H+=P[W].getDuration()+Ho.animationDurationPadding;for(let W=0;W<P.length;W++){const T=P[W],v=b[W];M.length<=W&&M.push({pos:[],rot:[],scale:[],timeOffset:v});const Y=M[W];Y.pos.push(...T.getSortedTimesArray(!0,!1,!1)),Y.rot.push(...T.getSortedTimesArray(!1,!0,!1)),Y.scale.push(...T.getSortedTimesArray(!1,!1,!0))}}for(const K of M)K.pos.sort((P,b)=>P-b),K.rot.sort((P,b)=>P-b),K.scale.sort((P,b)=>P-b),K.pos=[...new Set(K.pos)],K.rot=[...new Set(K.rot)],K.scale=[...new Set(K.scale)];return M},n=function(G,R,S){const M=new Map,K=new Map,P=new Map,b=R.length;for(const H of S){const W=G.get(H);let T;W?console.assert(W.length===b,"We should have the same number of TransformData entries for each bone",W,R):T=new Ho(null,H,void 0);for(let v=0;v<b;v++){const Y=W?W[v]:T,AA=R[v];for(const{time:$,translation:V}of Y.getValues(AA.pos,!0,!1,!1)){const dA=($+AA.timeOffset)*60;M.has(dA)||M.set(dA,new Array),M.get(dA).push(V.clone())}for(const{time:$,rotation:V}of Y.getValues(AA.rot,!1,!0,!1)){const dA=($+AA.timeOffset)*60;K.has(dA)||K.set(dA,new Array),K.get(dA).push(V.clone())}for(const{time:$,scale:V}of Y.getValues(AA.scale,!1,!1,!0)){const dA=($+AA.timeOffset)*60;P.has(dA)||P.set(dA,new Array),P.get(dA).push(V.clone())}}}return{position:M.size==0?void 0:M,quaternion:K.size==0?void 0:K,scale:P.size==0?void 0:P}},C=function(G){const R=[];for(const S of G)R.push(`(${Cg(S.x)}, ${Cg(S.y)}, ${Cg(S.z)})`);return R.join(", ")},a=function(G){const R=[];for(const S of G)R.push(`(${Cg(S.w)}, ${Cg(S.x)}, ${Cg(S.y)}, ${Cg(S.z)})`);return R.join(", ")},B=function(G){const R=new Map;if(aE){const S=new Array;for(const[M,K]of g)S.push(M.uuid+": "+K.length+" "+K.map(P=>{var b;return(b=P.clip)==null?void 0:b.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
5189
+ `,s={map:{value:A},height:{value:e.height||15},radius:{value:e.radius||100}},n=new ud(1,16),C=new Ke({uniforms:s,fragmentShader:o,vertexShader:I,side:kt});super(n,C)}set radius(A){this.material.uniforms.radius.value=A}get radius(){return this.material.uniforms.radius.value}set height(A){this.material.uniforms.height.value=A}get height(){return this.material.uniforms.height.value}}var agA=Object.defineProperty,rgA=Object.getOwnPropertyDescriptor,vg=(i,A,e,t)=>{for(var g=t>1?void 0:t?rgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&agA(A,e,g),g};const Tp=sA("freecam"),oh=sA("debugcamerafit"),Yp=sA("smoothcam"),BgA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let vk;class _l extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class Pt extends NA{constructor(){super(...arguments);r(this,"autoFit",!1);r(this,"enableRotate",!0);r(this,"autoRotate",!1);r(this,"autoRotateSpeed",1);r(this,"enableKeys",!0);r(this,"enableDamping",!0);r(this,"dampingFactor",.1);r(this,"enableZoom",!0);r(this,"minZoom",0);r(this,"maxZoom",1/0);r(this,"enablePan",!0);r(this,"lookAtConstraint",null);r(this,"lookAtConstraint01",1);r(this,"allowInterrupt",!0);r(this,"middleClickToFocus",!0);r(this,"doubleClickToFocus",!0);r(this,"useSlerp",!0);r(this,"debugLog",!1);r(this,"targetLerpDuration",1);r(this,"autoTarget",!0);r(this,"_controls",null);r(this,"_cameraObject",null);r(this,"_lookTargetLerpActive",!1);r(this,"_lookTargetStartPosition",new w);r(this,"_lookTargetEndPosition",new w);r(this,"_lookTargetLerp01",0);r(this,"_lookTargetLerpDuration",0);r(this,"_cameraLerpActive",!1);r(this,"_cameraStartPosition",new w);r(this,"_cameraEndPosition",new w);r(this,"_cameraLerp01",0);r(this,"_cameraLerpDuration",0);r(this,"_inputs",0);r(this,"_enableTime",0);r(this,"_startedListeningToKeyEvents",!1);r(this,"_eventSystem");r(this,"_afterHandleInputFn");r(this,"_camera",null);r(this,"_syncedTransform");r(this,"_didStart",!1);r(this,"targetElement",null);r(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()});r(this,"_shouldDisable",!1);r(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)}get targetLerpSpeed(){return 5}set targetLerpSpeed(e){this.targetLerpDuration=1/e}awake(){this._didStart=!1,this._startedListeningToKeyEvents=!1}start(){if(this._didStart=!0,this.autoTarget&&this._controls){const e=IA.getComponent(this.gameObject,Ot);if(e&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const g=ce(e.cam).length(),I=new w(0,0,-g).applyMatrix4(e.cam.matrixWorld);this.setLookTargetPosition(I,!0)}if(this.autoTarget&&!this.setLookTargetFromConstraint()){const t=new ro;t.screenPoint=new tA(0,0),t.lineThreshold=.1;const g=this.context.physics.raycast(t);g.length>0&&this.setLookTargetPosition(g[0].point,!0),oh&&console.log("OrbitControls hits",...g)}this.autoFit&&this.fitCamera()}this._eventSystem=QI.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(oM.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(oM.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=IA.getComponent(this.gameObject,Ot);this._camera=e;const t=e==null?void 0:e.cam;if(t&&Pv(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 g=this.targetElement??this.context.renderer.domElement,I=t==null?void 0:t.quaternion.clone();this._controls=new DiA(t,g),t==null||t.quaternion.copy(I),vk===void 0&&(vk={...this._controls.keys})}this._controls&&(Tp&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,FC()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),(t==null?void 0:t.type)==="PerspectiveCamera"?Tp||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):Tp||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=IA.getComponent(this.gameObject,va)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&Pv(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))}onBeforeRender(){var t,g;if(!this._controls||this._cameraObject!==this.context.mainCamera)return;(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&((t=this.context.input.getPointerPositionDelta(0))!=null&&t.length())||0>.1)&&(this._inputs+=1),this._inputs>0&&this.allowInterrupt&&(this.enableRotate&&(this.autoRotate=!1),this._cameraLerpActive=!1,this._lookTargetLerpActive=!1),this._inputs=0;let e=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(e||(e=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),e&&this.setTargetFromRaycast(),this._lookTargetLerpActive||this._cameraLerpActive){if(this._cameraLerpActive&&this._cameraObject)if(this._cameraLerp01+=this.context.time.deltaTime/this._cameraLerpDuration,this._cameraLerp01>=1)this._cameraObject.position.copy(this._cameraEndPosition),this._cameraLerpActive=!1,this.dispatchEvent(new _l(this,"camera"));else{const I=ZA.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,I)}if(this._lookTargetLerpActive)if(this._lookTargetLerp01+=this.context.time.deltaTime/this._lookTargetLerpDuration,this._lookTargetLerp01>=1)this._controls.target.copy(this._lookTargetEndPosition),this._lookTargetLerpActive=!1,this.dispatchEvent(new _l(this,"lookat"));else{const I=ZA.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,I)}}if(this._controls){if(this.debugLog&&(this._controls.domElement=this.context.renderer.domElement),this._controls.enabled=!this._shouldDisable&&this._camera===this.context.mainCameraComponent&&!this.context.isInXR,this._controls.keys=this.enableKeys?vk:BgA,this._controls.autoRotate=this.autoRotate,this._controls.autoRotateSpeed=this.autoRotateSpeed,this._controls.enableZoom=this.enableZoom,this._controls.enableDamping=this.enableDamping,this._controls.dampingFactor=this.dampingFactor,this._controls.enablePan=this.enablePan,this._controls.enableRotate=this.enableRotate,typeof Yp=="number"||Yp===!0){this._controls.enableDamping=!0;const I=typeof Yp=="number"?Yp:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,I))}this.allowInterrupt||(this._lookTargetLerpActive&&(this._controls.enablePan=!1),this._cameraLerpActive&&(this._controls.enableRotate=!1,this._controls.autoRotate=!1),(this._lookTargetLerpActive||this._cameraLerpActive)&&(this._controls.enableZoom=!1)),this.context.isInXR||(!Tp&&((g=this.lookAtConstraint)!=null&&g.locked)&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update())}}setCameraAndLookTarget(e){if(!e||!(e instanceof SA))return;const t=ce(e),g=vR(e);this.setTargetFromRaycast(new Us(t,g)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var g,I;e&&(e instanceof SA&&(e=ce(e)),this._cameraEndPosition||(this._cameraEndPosition=new w),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,(g=this.controllerObject)==null||g.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((I=this._cameraObject)==null?void 0:I.position),typeof t=="number"?this._cameraLerpDuration=t:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(e=null,t=!1){this._controls&&e&&(e instanceof SA&&(e=ce(e)),this._lookTargetEndPosition.copy(e),t===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof t=="number"?this._lookTargetLerpDuration=t:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(e=0,t=1){var I;if(!this._controls)return!1;const g=(I=this.lookAtConstraint)==null?void 0:I.sources;if(g&&g.length>0){const o=g[e];if(o)return o.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,t),!0}return!1}lerpTarget(e,t){return this.lerpLookTarget(e,t)}lerpLookTarget(e,t){this._controls&&(t>=1?this._controls.target.copy(e):this._controls.target.lerp(e,t))}setTargetFromRaycast(e){var g,I;if(!this.controls)return;const t=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const o of t)if(o.distance>0&&IA.isActiveInHierarchy(o.object)){const s=Hy(o.object);if(s){const n=s.canvas;if(n!=null&&n.screenspace)break}if(this.setLookTargetPosition(o.point),this.context.mainCamera){const C=ce(this.context.mainCamera).clone().sub(this.controls.target).add(this._lookTargetEndPosition);(I=(g=this._cameraObject)==null?void 0:g.parent)==null||I.worldToLocal(C),this.setCameraTargetPosition(C)}break}}fitCamera(e,t=1.1,g=!0){const I=this._cameraObject,o=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0||!I||!o)return;const s=new w,n=new w,C=new _i;C.makeEmpty();const a=[];function B(u){let f=!0;if(u.visible&&CgA(u)!==!1&&!(u.type==="TransformControlsGizmo"||u.type==="TransformControlsPlane")&&(u instanceof IG&&(f=!1),u instanceof MR&&(f=!1),u instanceof Z2&&(f=!1),u.material instanceof Ow&&(f=!1),u instanceof pA||(f=!1),u!==I&&u.isUI!==!0)){if(f){oh&&console.log(u.name,u.type,u);const k=u.children;u.children=a;const m=u.position,G=u.scale;if(Number.isNaN(m.x)||Number.isNaN(m.y)||Number.isNaN(m.z)){console.warn(`Object "${u.name}" has NaN values in position or scale.... will ignore it`,m,G);return}C.expandByObject(u,!0),u.children=k}for(const k of u.children)B(k)}}for(const u of e)u.updateMatrixWorld(),B(u);if(I.updateMatrixWorld(),I.updateProjectionMatrix(),C.getCenter(n),C.applyMatrix4(I.matrixWorldInverse),C.getSize(s),C.setFromCenterAndSize(n,s),Number.isNaN(s.x)||Number.isNaN(s.y)||Number.isNaN(s.z)){console.warn("Camera fit size resultet in NaN",I,C,[...e]);return}if(s.length()<=1e-10){oh&&console.warn("Camera fit size is zero",C,[...e]);return}const Q=I.fov,E=2*Math.atan(Math.tan(Q*Math.PI/360/2)*I.aspect)/Math.PI*360,c=s.y/(2*Math.atan(Math.PI*Q/360)),l=s.x/(2*Math.atan(Math.PI*E/360)),d=t*Math.max(c,l)+s.z/2;oh&&console.log("Fit camera to objects",c,l,"distance",d);const h=ce(I),p=o.target.clone().sub(h).normalize().multiplyScalar(d);if(o.maxDistance=d*10,o.minDistance=d*.01,this.setLookTargetPosition(n,g),this.autoTarget=!1,I.near=d/100,I.far=d*100,I.updateMatrixWorld(),I.updateProjectionMatrix(),I.parent){const u=I.parent.worldToLocal(o.target.clone().sub(p));this.setCameraTargetPosition(u,g)}else console.error(`Can not fit camera ${I.name} because it has no parent`);if(oh){const u=new IG(C);this.context.scene.add(u),bR(u,wd(I)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",f=>{f.code==="KeyF"&&this.fitCamera(e)}))}o.update()}}vg([D()],Pt.prototype,"autoFit",2);vg([D()],Pt.prototype,"enableRotate",2);vg([D()],Pt.prototype,"autoRotate",2);vg([D()],Pt.prototype,"autoRotateSpeed",2);vg([D()],Pt.prototype,"enableKeys",2);vg([D()],Pt.prototype,"enableDamping",2);vg([D()],Pt.prototype,"dampingFactor",2);vg([D()],Pt.prototype,"enableZoom",2);vg([D()],Pt.prototype,"minZoom",2);vg([D()],Pt.prototype,"maxZoom",2);vg([D()],Pt.prototype,"enablePan",2);vg([D(Hd)],Pt.prototype,"lookAtConstraint",2);vg([D()],Pt.prototype,"lookAtConstraint01",2);vg([D()],Pt.prototype,"allowInterrupt",2);vg([D()],Pt.prototype,"middleClickToFocus",2);vg([D()],Pt.prototype,"doubleClickToFocus",2);vg([D()],Pt.prototype,"targetLerpDuration",2);var QgA=Object.defineProperty,EgA=Object.getOwnPropertyDescriptor,ho=(i,A,e,t)=>{for(var g=t>1?void 0:t?EgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&QgA(A,e,g),g},BB=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(BB||{});const xr=sA("debugcam"),Vv=sA("debugscreenpointtoray");var Cf;const Gh=(Cf=class extends NA{constructor(){super(...arguments);r(this,"_nearClipPlane",.1);r(this,"_farClipPlane",1e3);r(this,"orthographic",!1);r(this,"orthographicSize",5);r(this,"ARBackgroundAlpha",0);r(this,"_cullingMask",4294967295);r(this,"_backgroundBlurriness");r(this,"_backgroundIntensity");r(this,"_environmentIntensity");r(this,"_targetTexture",null);r(this,"_backgroundColor");r(this,"_fov");r(this,"_cam",null);r(this,"_clearFlags",2);r(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof je?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof je?this._cam.fov:this._fov}set fieldOfView(A){const e=this.fieldOfView!=A;if(this._fov=A,e&&this._cam&&this._cam instanceof je){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(A){const e=this._nearClipPlane!=A;this._nearClipPlane=A,this._cam&&e&&(this._cam.near=A,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(A){const e=this._farClipPlane!=A;this._farClipPlane=A,this._cam&&e&&(this._cam.far=A,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(A){A!==this._clearFlags&&(this._clearFlags=A,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(A){this._cullingMask=A,this._cam&&(this._cam.layers.mask=A)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(A){this.cullingMask=(1<<A|0)>>>0}set backgroundBlurriness(A){A!==this._backgroundBlurriness&&(A===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(A,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(A){A!==this._backgroundIntensity&&(A===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(A,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(A){this._environmentIntensity=A}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(A){if(A){if(this._backgroundColor)this._backgroundColor.copy(A);else{if(!A.clone)return;this._backgroundColor=A.clone()}A.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(A){this._targetTexture=A}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(A,e,t){const g=this.cam,I=Gh._origin;I.set(A,e,-1),this.context.input.convertScreenspaceToRaycastSpace(I),Vv&&console.log("screenPointToRay",A.toFixed(2),e.toFixed(2),"now:",I.x.toFixed(2),I.y.toFixed(2),"isInXR:"+this.context.isInXR),I.z=-1,I.unproject(g);const o=Gh._direction.set(I.x,I.y,I.z),s=ce(g);return o.sub(s),o.normalize(),t?(t.set(s,o),t):new Us(s.clone(),o.clone())}awake(){Vv&&window.addEventListener("pointerdown",A=>{const e=A.clientX,t=A.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const g=this.screenPointToRay(e,t),I="#"+Math.floor(Math.random()*16777215).toString(16);tn.DrawRay(g.origin,g.direction,I,10)})}onEnable(){xr&&console.log(`Camera enabled: "${this.name}". ClearFlags=${BB[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),hgA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._clearFlags===2&&this.applyClearFlagsIfIsActiveCamera(),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 A=this.context.renderer;if(A){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,A),e==null||e.applyClearFlags()}}}buildCamera(){if(this._cam)return;const A=this.gameObject.isCamera;let e=null;if(A?(e=this.gameObject,e==null||e.layers.enableAll(),e instanceof je&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof je&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new je(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 RC(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){xr&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,xr){const A=`Camera "${this.name}" clear flags: ${BB[this._clearFlags]}`;console.log(A)}switch(this._clearFlags){case 1:if(Gh.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 A=this._backgroundColor.alpha;Gh.backgroundShouldBeTransparent(this.context)&&(A=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,A)}else xr&&console.warn(`Camera "${this.name}" has no background color`,this);break;case 4:this.context.scene.background=null,this.context.renderer.setClearColor(0,0);break}}enableSkybox(){this._skybox||(this._skybox=new cgA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(A){var I,o,s,n;const e=(I=A.renderer.xr)==null?void 0:I.getSession();if(!e)return!1;if(typeof e._transparent=="boolean")return e._transparent;const t=e.environmentBlendMode;xr&&mi("Environment blend mode: "+t+" on "+navigator.userAgent);let g=t==="additive"||t==="alpha-blend";return A.xrSessionMode===Nl.ImmersiveAR&&t==="opaque"&&((o=navigator.userAgent)!=null&&o.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&((n=navigator.userAgent)!=null&&n.includes("Mobile WebXRViewer/v2")))&&(g=!0),e._transparent=g,g}},r(Cf,"_origin",new w),r(Cf,"_direction",new w),Cf);let Ot=Gh;ho([D()],Ot.prototype,"fieldOfView",1);ho([D()],Ot.prototype,"nearClipPlane",1);ho([D()],Ot.prototype,"farClipPlane",1);ho([D()],Ot.prototype,"clearFlags",1);ho([D()],Ot.prototype,"orthographic",2);ho([D()],Ot.prototype,"orthographicSize",2);ho([D()],Ot.prototype,"ARBackgroundAlpha",2);ho([D()],Ot.prototype,"cullingMask",1);ho([D()],Ot.prototype,"backgroundBlurriness",1);ho([D()],Ot.prototype,"backgroundIntensity",1);ho([D()],Ot.prototype,"environmentIntensity",1);ho([D(St)],Ot.prototype,"backgroundColor",1);ho([D(ka)],Ot.prototype,"targetTexture",1);class cgA{constructor(A){r(this,"_camera");r(this,"_skybox");this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(xr&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.colorSpace=Ie,this._skybox.mapping=Po,this.context.scene.background=this._skybox):(this._did_log_failed_to_find_skybox||(this._did_log_failed_to_find_skybox=!0,console.warn(`Camera "${this._camera.name}" failed to load/find skybox texture`,this._camera.sourceId,this.context.lightmaps,"Current background: ",this.context.scene.background)),(xr||_e())&&hg(`Camera "${this._camera.name}" has no skybox texture`))}}function hgA(i){sA("freecam")&&i.context.mainCameraComponent===i&&IA.getOrAddComponent(i.gameObject,Pt)}class ma extends NA{constructor(){super(...arguments);r(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new Lx),this._listener}awake(){Ji.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=this.context.mainCameraComponent||IA.getComponentInParent(this.gameObject,Ot);t!=null&&t.cam?t.cam.add(e):this.gameObject.add(e)})}}var lgA=Object.defineProperty,dgA=Object.getOwnPropertyDescriptor,_y=(i,A,e,t)=>{for(var g=t>1?void 0:t?dgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&lgA(A,e,g),g};const ugA=sA("debugsignals");class Od{constructor(){r(this,"guid")}}_y([D()],Od.prototype,"guid",2);class sc{constructor(){r(this,"signal");r(this,"reaction")}}_y([D(Od)],sc.prototype,"signal",2);_y([D(mg)],sc.prototype,"reaction",2);var dm;const _n=(dm=class extends NA{constructor(){super(...arguments);r(this,"events")}static invoke(A){if(_n.receivers[A]){const e=_n.receivers[A];if(!e)return;for(const t of e)t.invoke(A)}}awake(){ugA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const A of this.events)_n.receivers[A.signal.guid]||(_n.receivers[A.signal.guid]=[]),_n.receivers[A.signal.guid].push(this)}onDisable(){if(this.events){for(const A of this.events)if(_n.receivers[A.signal.guid]){const e=_n.receivers[A.signal.guid].indexOf(this);e>=0&&_n.receivers[A.signal.guid].splice(e,1)}}}invoke(A){if(!this.events||!Array.isArray(this.events))return;const e=typeof A=="object"?A.guid:A;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(g){console.error(g)}}},r(dm,"receivers",{}),dm);let nc=_n;_y([D(sc)],nc.prototype,"events",2);var zI=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(zI||{}),Os=(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))(Os||{}),gF=(i=>(i.Signal="SignalEmitter",i))(gF||{});const CC=sA("debugtimeline");class Pd{constructor(){r(this,"director");r(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let t=this.track.clips.length-1;t>=0;t--)yield this.track.clips[t];else for(const t of this.track.clips)yield t}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,t,g=!0){if(e<0||e>=t.length)return 0;const I=t[e];if(g||A>=I.start&&A<=I.end){let o=1;const s=!1;if(I.easeInDuration>0){const n=Math.min((A-I.start)/I.easeInDuration,1);o*=n}if(I.easeOutDuration>0&&!s){const n=Math.min((I.end-A)/I.easeOutDuration,1);o*=n}return o}return 0}}class pgA{constructor(A){r(this,"clip");r(this,"rootPositionOffset");r(this,"rootQuaternionOffset");r(this,"rootStartPosition");r(this,"rootEndPosition");r(this,"rootStartQuaternion");r(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const t=A.getRoot(),g=t.name+".position",I=t.name+".quaternion";CC&&console.log(e.name,e.tracks,g);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(g))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),CC&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new GA().fromArray(o.values,0),this.rootEndQuaternion=new GA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),CC)){const s=new Mi().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Oy extends Pd{constructor(){super(...arguments);r(this,"models",[]);r(this,"trackOffset");r(this,"target");r(this,"mixer");r(this,"clips",[]);r(this,"actions",[]);r(this,"_actionOffsets",[]);r(this,"_didBind",!1);r(this,"_animator",null);r(this,"_useclipOffsets",!0);r(this,"_totalOffsetPosition",new w);r(this,"_totalOffsetRotation",new GA);r(this,"_totalOffsetPosition2",new w);r(this,"_totalOffsetRotation2",new GA);r(this,"_summedPos",new w);r(this,"_tempPos",new w);r(this,"_summedRot",new GA);r(this,"_tempRot",new GA);r(this,"_clipRotQuat",new GA)}onStateChanged(){this._animator&&zv(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var a,B;if(((a=t.tracks)==null?void 0:a.length)<=0){console.warn("No tracks in AnimationClip",t);return}const g=t.tracks[0].name.split("."),I=g[g.length-2],o=I+".position",s=I+".quaternion";let n=!1,C=!1;for(const Q of t.tracks)Q.name.endsWith(o)?(n=!0,this.createPositionInterpolant(t,e,Q)):Q.name.endsWith(s)&&(C=!0,this.createRotationInterpolant(t,e,Q));if(!n||!C){const Q=(B=this.mixer)==null?void 0:B.getRoot(),E=t.tracks[0],c=E.name.lastIndexOf("."),l=E.name.substring(0,c),d=l.substring(l.lastIndexOf(".")+1),h=Q.getObjectByName(d);if(h)if(n){if(!C){const p=t.tracks[0].name.substring(0,c)+".quaternion";CC&&console.warn("Create quaternion track",d,h);const u=h.quaternion,f=new Qn(p,[0,t.duration],[u.x,u.y,u.z,u.w,u.x,u.y,u.z,u.w]);t.tracks.push(f),this.createRotationInterpolant(t,e,f)}}else{const p=l+".position";CC&&console.warn("Create position track",d,h);const u=h.position,f=new DC(p,[0,t.duration],[u.x,u.y,u.z,u.x,u.y,u.z]);t.tracks.push(f),this.createPositionInterpolant(t,e,f)}}}bind(){if(!this._didBind){this._didBind=!0,CC&&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 pgA(e);this._actionOffsets.push(t)}this.target&&(this._animator=IA.getComponent(this.target,Rg)??null,this._animator&&zv(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,g=t.position,I=t.rotation;g&&g.x!==void 0&&(g.isVector3||(t.position=new w(g.x,g.y,g.z)),I.isQuaternion||(t.rotation=new GA(I.x,I.y,I.z,I.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 GA(t.x,t.y,t.z,t.w)))}}evaluate(e){var n,C,a,B,Q,E,c;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 t=0,g=0,I=!1,o=!1,s=0;for(let l=0;l<this.clips.length;l++){const d=this.models[l],h=this.actions[l],p=d.asset;h.weight=0;const u=e>=d.start&&e<=d.end,f=d.preExtrapolationMode,k=d.postExtrapolationMode,m=l<this.clips.length-1?this.models[l+1]:null;let G=u,R=!1;if(!G&&!I&&d.end<e&&k!==Os.None?(!m||m.start>e)&&(G=!0,I=!0):l==0&&!G&&!o&&d.start>e&&f!==Os.None&&(!m||m.start<e)&&(G=!0,R=!0,o=!0),G){let S=1;S*=this.evaluateWeight(e,l,this.models,G),S*=this.director.weight;let M=u;if(R)switch(f){case Os.Hold:break;case Os.Loop:e+=d.start,M=!0;break;default:e+=d.start,M=!0;break}let K=this.getClipTime(e,d),P=0;const b=p.duration;if(R&&f===Os.Hold&&(K=0),M){if(p.loop)for(P+=Math.floor(K/(b+1e-6));K>b;)K-=b}else if(!u&&I)switch(k){case Os.Hold:K=this.getClipTime(d.end,d);break;case Os.Loop:K%=b;break;case Os.PingPong:const T=Math.floor(K/b)%2!==0;K%=b,T&&(K=b-K);break}d.reversed===!0?h.time=h.getClip().duration-K:h.time=K,h.timeScale=0;const H=Math.max(0,S);if(h.weight=H,s+=H,h.clampWhenFinished=!1,h.isRunning()||h.play(),this._useclipOffsets){const W=t==0?this._totalOffsetPosition:this._totalOffsetPosition2,T=t==0?this._totalOffsetRotation:this._totalOffsetRotation2;t<1&&(g=1-S),t+=1;const v=this._summedPos.set(0,0,0),Y=this._tempPos.set(0,0,0),AA=this._summedRot.identity(),$=this._tempRot.identity(),V=p.rotation;V&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp(V,S));const gA=this._actionOffsets[l];if(gA.hasOffsets)for(let dA=0;dA<P;dA++)gA.rootPositionOffset?Y.copy(gA.rootPositionOffset):Y.set(0,0,0),Y.applyQuaternion(AA),this._clipRotQuat&&Y.applyQuaternion(this._clipRotQuat),gA.rootQuaternionOffset&&($.copy(gA.rootQuaternionOffset),AA.multiply($)),v.add(Y);this._clipRotQuat&&T.multiply(this._clipRotQuat),T.multiply(AA),p.position&&v.add(p.position),W.add(v)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,g),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,g)),this.__mixerError===void 0&&(CC||_e())&&((C=(n=this._animator)==null?void 0:n.runtimeAnimatorController)!=null&&C.mixer)&&this.mixer!==((B=(a=this._animator)==null?void 0:a.runtimeAnimatorController)==null?void 0:B.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)),(Q=this._animator)!=null&&Q.runtimeAnimatorController){const l=Math.max(0,1-s);(c=(E=this._animator)==null?void 0:E.runtimeAnimatorController)==null||c.update(l)}else this.mixer.update(e)}createRotationInterpolant(e,t,g){var n;const I=g.createInterpolant.bind(g),o=new GA;this.ensureTrackOffsets();const s=(n=this.trackOffset)==null?void 0:n.rotation;g.createInterpolant=()=>{const C=I(),a=C.evaluate.bind(C);return C.evaluate=B=>{var E;const Q=a(B);if(o.set(Q[0],Q[1],Q[2],Q[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),this.director.animationCallbackReceivers)for(const c of this.director.animationCallbackReceivers)(E=c==null?void 0:c.onTimelineRotation)==null||E.call(c,this.director,this.target,B,o);return Q[0]=o.x,Q[1]=o.y,Q[2]=o.z,Q[3]=o.w,Q},C}}createPositionInterpolant(e,t,g){var a,B;const I=g.createInterpolant.bind(g),o=new w;this.ensureTrackOffsets();const s=(a=this.trackOffset)==null?void 0:a.rotation,n=(B=this.trackOffset)==null?void 0:B.position;let C;g.createInterpolant=()=>{const Q=I(),E=Q.evaluate.bind(Q);return Q.evaluate=c=>{var d,h,p;const l=E(c);if(o.set(l[0],l[1],l[2]),t.removeStartOffset&&(C===void 0?(C=null,C=(h=(d=this._actionOffsets.find(u=>u.clip===e))==null?void 0:d.rootStartPosition)==null?void 0:h.clone()):C!=null&&C.isVector3&&o.sub(C)),o.applyQuaternion(this._totalOffsetRotation),o.add(this._totalOffsetPosition),s&&o.applyQuaternion(s),n&&(o.x-=n.x,o.y+=n.y,o.z+=n.z),this.director.animationCallbackReceivers)for(const u of this.director.animationCallbackReceivers)(p=u==null?void 0:u.onTimelinePosition)==null||p.call(u,this.director,this.target,c,o);return l[0]=o.x,l[1]=o.y,l[2]=o.z,l},Q}}}const fgA=sA("mutetimeline"),XQ=class extends Pd{constructor(){super(...arguments);r(this,"models",[]);r(this,"listener");r(this,"audio",[]);r(this,"audioContextTimeOffset",[]);r(this,"lastTime",0);r(this,"audioSource");r(this,"_audioLoader",null)}getAudioFilePath(e){const t=this.director.sourceId;return UC(t,e)}onAllowAudioChanged(e){for(let t=0;t<this.models.length;t++){const g=this.models[t];this.audio[t].setVolume(e?g.asset.volume:0)}}addModel(e){const t=new kR(this.listener);this.audio.push(t),this.models.push(e)}onDisable(){for(const e of this.audio)e.isPlaying&&e.stop()}onDestroy(){for(const e of this.audio)e.source&&(e==null||e.disconnect());this.audio.length=0}onMuteChanged(){if(this.muted)for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}}stop(){for(let e=0;e<this.audio.length;e++){const t=this.audio[e];t!=null&&t.isPlaying&&t.stop()}}evaluate(e){if(fgA||this.track.muted||this.director.speed<0)return;const t=this.director.context.application.muted,g=t?.1:0;for(let I=0;I<this.models.length;I++){const o=this.models[I],s=this.audio[I],n=o.asset;if((!s||!s.buffer)&&this.isInTimeRange(o,e-1,e+1)&&this.handleAudioLoading(o,s),Ji.userInteractionRegistered!==!1&&!(s===null||!s.buffer))if(s.playbackRate=this.director.context.time.timeScale*this.director.speed,s.loop=n.loop,e>=o.start&&e<=o.end&&e<this.director.duration){if(this.director.isPlaying==!1){if(s.isPlaying&&s.stop(),this.lastTime===e)continue}else if(!s.isPlaying)s.offset=o.clipIn+(e-o.start)*o.timeScale,s.play(g);else{const a=o.clipIn+(e-o.start)*o.timeScale,B=s.context.currentTime-s._startedAt+s.offset;Math.abs(a-B)>.3&&(s.offset=a,s.stop(),s.play(g))}let C=n.volume;if(this.track.volume!==void 0&&(C*=this.track.volume),t&&(C=0),o.easeInDuration>0){const a=Math.min((e-o.start)/o.easeInDuration,1);C*=a}if(o.easeOutDuration>0){const a=Math.min((o.end-e)/o.easeOutDuration,1);C*=a}s.setVolume(C*this.director.weight)}else s.isPlaying&&s.stop()}this.lastTime=e}loadAudio(e,t=0,g=0){let I=null;const o=e-g,s=e+t;for(const n of this.models)if(this.isInTimeRange(n,o,s)){const C=this.audio[this.models.indexOf(n)],a=this.handleAudioLoading(n,C);a!==null&&(I===null&&(I=[]),I.push(a))}return I!==null?Promise.all(I):null}isInTimeRange(e,t,g){return t<=e.start&&g>=e.end||t>=e.start&&t<=e.end||g>=e.start&&g<=e.end}static dispose(){XQ._audioBuffers.clear()}handleAudioLoading(e,t){this._audioLoader||(this._audioLoader=new QD);const g=this.getAudioFilePath(e.asset.clip);if(XQ._audioBuffers.get(g)){const o=XQ._audioBuffers.get(g);return o.then(s=>{s&&t.setBuffer(s)}),o}CC&&console.warn("LOAD audio track",g,this.director.sourceId);const I=new Promise((o,s)=>{this._audioLoader.load(g,n=>{t.setBuffer(n),o(n)},void 0,n=>{console.error("Error loading audio",n),o(null)})});return XQ._audioBuffers.set(g,I),I}};let iB=XQ;r(iB,"_audioBuffers",new Map);class Ol extends Pd{constructor(){super(...arguments);r(this,"models",[]);r(this,"didTrigger",[]);r(this,"receivers",[])}evaluate(e){var g;if(this.track.muted)return;const t=this.director.context.time.deltaTime*1.5;for(let I=0;I<this.models.length;I++){const o=this.models[I],s=this.didTrigger[I],n=o.time-e;let C=!1;if(o.retroActive)C=n<=1e-6;else{const a=Math.abs(n);(a===0||a>=1e-5&&a<t)&&(C=!0)}if(C){if(!s)if(CC&&console.log("Trigger signal",e,o.time,o),this.didTrigger[I]=!0,((g=this.receivers)==null?void 0:g.length)<=0)nc.invoke(o.asset);else for(const a of this.receivers)a&&a.invoke(o.asset)}else o.emitOnce||(this.didTrigger[I]=!1)}}}class Py extends Pd{constructor(){super(...arguments);r(this,"models",[]);r(this,"timelines",[]);r(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const I=this.models[t].asset;if(!I.sourceObject||typeof I.sourceObject!="object"){console.log("no source object, removing model",t,I),this.models.splice(t,1);continue}else{const o=IA.getComponent(I.sourceObject,pC);this.timelines.push(o),o&&I.updateDirector&&(o.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=I.asset;if(e>=I.start&&e<=I.end){this._previousActiveModel=I;const s=this.getClipTime(e,I);if(o.controlActivation){const n=o.sourceObject;n.visible=!0}if(o.updateDirector){const n=this.timelines[g];n&&(n.isPlaying&&n.pause(),n.time=s,n.evaluate())}}else{const s=(t=this._previousActiveModel)==null?void 0:t.asset;if(o.controlActivation){const n=o.sourceObject;(s==null?void 0:s.sourceObject)!==n&&(n.visible=!1)}}}}}const pQ=sA("debugtimeline"),Bw=class extends NA{constructor(){super(...arguments);r(this,"playableAsset");r(this,"playOnAwake");r(this,"extrapolationMode",1);r(this,"waitForAudio",!0);r(this,"_visibilityChangeEvt");r(this,"_clonedPlayableAsset",!1);r(this,"_speed",1);r(this,"_guidsMap");r(this,"_isPlaying",!1);r(this,"_internalUpdateRoutine");r(this,"_isPaused",!1);r(this,"_isStopping",!1);r(this,"_time",0);r(this,"_duration",0);r(this,"_weight",1);r(this,"_animationTracks",[]);r(this,"_audioTracks",[]);r(this,"_signalTracks",[]);r(this,"_controlTracks",[]);r(this,"_customTracks",[]);r(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]);r(this,"animationCallbackReceivers",[])}static registerCreateTrack(e,t){this.createTrackFunctions[e]=t}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(e){typeof e=="number"&&!Number.isNaN(e)?this._time=e:(pQ||dI())&&console.error("INVALID TIMELINE.TIME VALUE",e,this.name)}get duration(){return this._duration}set duration(e){this._duration=e}get weight(){return this._weight}set weight(e){this._weight=e}get speed(){return this._speed}set speed(e){this._speed=e}awake(){var e,t,g;pQ&&console.log(this,(e=this.playableAsset)==null?void 0:e.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(t=this.playableAsset)==null?void 0:t.tracks,Array.isArray((g=this.playableAsset)==null?void 0:g.tracks),this)}onEnable(){var e,t,g;for(const I of this._audioTracks)(e=I.onEnable)==null||e.call(I);for(const I of this._customTracks)(t=I.onEnable)==null||t.call(I);for(const I of this._animationTracks)(g=I.onEnable)==null||g.call(I);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 e,t,g;this.stop();for(const I of this._audioTracks)(e=I.onDisable)==null||e.call(I);for(const I of this._customTracks)(t=I.onDisable)==null||t.call(I);for(const I of this._animationTracks)(g=I.onDisable)==null||g.call(I);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var e;for(const t of this._allTracks)for(const g of t)(e=g.onDestroy)==null||e.call(g)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const e=this._isPaused==!0;if(this._isPaused=!1,e&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const t=[];for(const g of this._audioTracks){const I=g.loadAudio(this._time,1,0);I&&t.push(I)}if(t.length>0&&(await Promise.all(t),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!Ji.userInteractionRegistered&&this.waitForAudio;)await Ka(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Qg.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const g of this._audioTracks)g.stop();const e=this._isPaused==!0,t=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),e&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,e&&!t&&this.invokePauseChangedMethodsOnTracks(),t&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const e of this._allTracks)for(const t of e)yield t}get audioTracks(){return this._audioTracks}resolveGuids(e){this._guidsMap=e}invokePauseChangedMethodsOnTracks(){var e;for(const t of this.forEachTrack())(e=t.onPauseChanged)==null||e.call(t)}invokeStateChangedMethodsOnTracks(){var e;for(const t of this.forEachTrack())(e=t.onStateChanged)==null||e.call(t,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(e=!1){if(!this.isValid())return;let t=this._time;switch(this.extrapolationMode){case 0:this._speed>0?t=Math.min(t,this._duration):this._speed<0&&(t=Math.max(t,0)),this._time=t;break;case 1:t%=this._duration,this._time=t;break;case 2:if(t>this._duration){this.stop();return}break}const g=this._time;for(const I of this.playableAsset.tracks)if(!I.muted)switch(I.type){case zI.Activation:if(!e&&!this._isPlaying)continue;for(let o=0;o<I.outputs.length;o++){const s=I.outputs[o];if(typeof s=="object"){let n=!1;if(I.clips)for(const a of I.clips)a.start<=g&&g<=a.end&&(n=!0);const C=s;C.visible!==void 0&&C.visible!==n&&(C.visible=n,pQ&&console.warn(this.name,"set ActivationTrack-"+o,C.name,n,g))}}break}if(!this._isStopping)for(const I of this._animationTracks)I.evaluate(g);for(const I of this._audioTracks)I.evaluate(g);for(const I of this._signalTracks)I.evaluate(g);for(const I of this._controlTracks)I.evaluate(g);for(const I of this._customTracks)I.evaluate(g)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=ey(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const e=this.findRoot(this.gameObject);for(const t of this.playableAsset.tracks){for(let g=t.outputs.length-1;g>=0;g--){let I=t.outputs[g];if(typeof I=="string"){this._guidsMap&&this._guidsMap[I]&&(I=this._guidsMap[I]);const o=IA.findByGuid(I,e);o===null||typeof o!="object"?(t.outputs.splice(g,1),console.warn("Failed to resolve binding",I,t.name,t.type)):(pQ&&console.log("Resolved binding",I,"to",o),t.outputs[g]=o)}else if(I===null){if(t.outputs.splice(g,1),Bw.createTrackFunctions[t.type])continue;t.type!==zI.Audio&&t.type!==zI.Control&&t.type!==zI.Marker&&t.type!==zI.Signal&&console.warn("Missing binding",I,t.name,t.type,this.name,this.playableAsset.name)}}if(t.type===zI.Control&&t.clips)for(let g=0;g<t.clips.length;g++){const I=t.clips[g];let o=I.asset.sourceObject;if(typeof o=="string"){this._guidsMap&&this._guidsMap[o]&&(o=this._guidsMap[o]);const s=IA.findByGuid(o,e);s===null||typeof s!="object"?console.warn("Failed to resolve sourceObject binding",o,t.name,I):(pQ&&console.log("Resolved binding",o,"to",s),I.asset.sourceObject=s)}}}}findRoot(e){return e.parent?this.findRoot(e.parent):e}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const e of this.playableAsset.tracks)if(e.muted!==!0){if(e.clips)for(const t of e.clips)t.end>this._duration&&(this._duration=t.end);if(e.markers)for(const t of e.markers)t.time>this._duration&&(this._duration=t.time+.001)}}}setupAndCreateTrackHandlers(){var t,g,I;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let e=IA.findObjectOfType(ma,this.context);for(const o of this.playableAsset.tracks){const s=o.type,n=Bw.createTrackFunctions[s];if(n!=null){const C=n(this,o);if(typeof C.evaluate=="function"){C.director=this,C.track=o,this._customTracks.push(C);continue}}if(o.type===zI.Animation){if(!o.clips||o.clips.length<=0){pQ&&console.warn("Animation track has no clips",o);continue}for(let C=o.outputs.length-1;C>=0;C--){let a=o.outputs[C];if(a instanceof SA){const Q=IA.getOrAddComponent(a,Rg);Q&&(a=Q)}const B=(t=a==null?void 0:a.gameObject)==null?void 0:t.animations;if(B){const Q=new Oy;Q.trackOffset=o.trackOffset,Q.director=this,Q.track=o;for(let E=0;E<o.clips.length;E++){const c=o.clips[E],l=c.asset;if(!l){console.error("MISSING anim model?","clip#"+E,c,o,this.playableAsset,this.name);continue}const d=l.clip;let h=d;if((typeof h=="string"||typeof h=="number")&&(h=B.find(u=>u.name===d)),!h){console.warn("Could not find animationClip for model",c,o.name,this.name,(g=this.playableAsset)==null?void 0:g.name);continue}a instanceof Rg&&a.runtimeAnimatorController&&(a.__internalDidAwakeAndStart||a.initializeRuntimeAnimatorController(),a.runtimeAnimatorController.mixer||a.runtimeAnimatorController.bind(a),Q.mixer=a.runtimeAnimatorController.mixer),Q.mixer||(Q.mixer=new $w(a.gameObject)),Q.clips.push(h),Q.mixer.uncacheAction(h),Q.createHooks(c.asset,h);const p=Q.mixer.clipAction(h);Q.actions.push(p),Q.models.push(c)}this._animationTracks.push(Q)}}}else if(o.type===zI.Audio){if(!o.clips||o.clips.length<=0)continue;const C=new iB;C.director=this,C.track=o,C.audioSource=o.outputs.find(a=>a instanceof Ji),this._audioTracks.push(C),e||(e=(I=this.context.mainCameraComponent)==null?void 0:I.gameObject.addNewComponent(ma)),C.listener=e.listener;for(let a=0;a<o.clips.length;a++){const B=o.clips[a];C.addModel(B)}}else if(o.type===zI.Marker){const C=new Ol;if(C.director=this,C.track=o,o.markers)for(const a of o.markers)switch(a.type){case gF.Signal:C.models.push(a),C.didTrigger.push(!1);break}if(C!==null&&C.models.length>0){const a=IA.getComponent(this.gameObject,nc);a&&(C.receivers.push(a),this._signalTracks.push(C))}}else if(o.type===zI.Signal){const C=new Ol;if(C.director=this,C.track=o,o.markers)for(const a of o.markers)C.models.push(a),C.didTrigger.push(!1);for(const a of o.outputs)C.receivers.push(a);this._signalTracks.push(C)}else if(o.type===zI.Control){const C=new Py;if(C.director=this,C.track=o,o.clips)for(const a of o.clips)C.models.push(a);C.resolveSourceObjects(this.context),this._controlTracks.push(C)}}}setAudioTracksAllowPlaying(e){for(const t of this._audioTracks)t.onAllowAudioChanged(e)}registerAnimationCallback(e){this.animationCallbackReceivers.push(e)}unregisterAnimationCallback(e){const t=this.animationCallbackReceivers.indexOf(e);t!==-1&&this.animationCallbackReceivers.splice(t,1)}};let pC=Bw;r(pC,"createTrackFunctions",{});const _f=Symbol("objectIsAnimatedData");function zv(i,A,e){if(!i)return;if(i[_f]===void 0){if(!e)return;i[_f]=new Set}const t=i[_f];e?t.add(A):t.has(A)&&t.delete(A)}function DgA(i){if(!i)return!1;const A=i[_f];return A!==void 0&&A.size>0}Ut.registerCallback(Xi.ContextCreated,i=>{const A=i.context.domElement.getAttribute("autoplay");if(A!==void 0&&(A===""||A==="true")&&i.files)for(const e of i.files)IA.foreachComponent(e.file.scene,g=>{if(g.enabled!==!1){if(g instanceof Eo&&g.playAutomatically||g instanceof Rg||g instanceof pC&&g.playOnAwake===!0)return!0;if(g instanceof Eo)return g.playAutomatically=!0,!0;if(g instanceof pC)return g.playOnAwake=!0,!0}},!0)!==!0&&wgA(e.file)});function wgA(i){if(!i||!i.animations)return;for(let e=0;e<i.animations.length;e++){const t=i.animations[e];if(!(!t.tracks||t.tracks.length<=0))for(const g in t.tracks){const I=t.tracks[g],o=I.__objectName??I.name.substring(0,I.name.indexOf("."));let s=i.scene.getObjectByName(o);if(!s&&(s=i.scene.getObjectByProperty("uuid",o),!s))continue;let n=A(s);n||(n=Wa(i.scene,new Eo));const C=n.animations=n.animations||[];t.name_animator=n.name,C.indexOf(t)<0&&C.push(t)}}function A(e){var g;if(!e)return;const t=(g=e.userData)==null?void 0:g.components;if(t&&t.length>0)for(let I=0;I<t.length;I++){const o=t[I];if(o instanceof Rg||o instanceof Eo)return e}return A(e.parent)}}var ygA=Object.defineProperty,SgA=Object.getOwnPropertyDescriptor,Wy=(i,A,e,t)=>{for(var g=t>1?void 0:t?SgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&ygA(A,e,g),g};const jv=sA("debuganimator");class Rg extends NA{constructor(){super(...arguments);r(this,"applyRootMotion",!1);r(this,"hasRootMotion",!1);r(this,"keepAnimatorControllerStateOnDisable",!1);r(this,"_parametersAreDirty",!1);r(this,"_isDirty",!1);r(this,"speed",1);r(this,"normalizedStartOffset",0);r(this,"_animatorController",null);r(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(e){var t;this._animatorController&&this._animatorController.model===e||(e?e instanceof zo?(e.animator&&e.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(t=e.model)==null?void 0:t.name),e.model||console.error("AnimatorController has no model"),e=new zo(e.model)),this._animatorController=e,this._animatorController.bind(this)):(jv&&console.log("Assign animator controller",e,this),this._animatorController=new zo(e),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(e,t=-1,g=Number.NEGATIVE_INFINITY,I=0){this.play(e,t,g,I)}play(e,t=-1,g=Number.NEGATIVE_INFINITY,I=0){var o;(o=this.runtimeAnimatorController)==null||o.play(e,t,g,I),this._isDirty=!0}Reset(){this.reset()}reset(){var e;(e=this._animatorController)==null||e.reset(),this._isDirty=!0}SetBool(e,t){this.setBool(e,t)}setBool(e,t){var g,I;((g=this.runtimeAnimatorController)==null?void 0:g.getBool(e))!==t&&(this._parametersAreDirty=!0),(I=this.runtimeAnimatorController)==null||I.setBool(e,t)}GetBool(e){return this.getBool(e)}getBool(e){var t;return((t=this.runtimeAnimatorController)==null?void 0:t.getBool(e))??!1}SetFloat(e,t){this.setFloat(e,t)}setFloat(e,t){var g,I;((g=this.runtimeAnimatorController)==null?void 0:g.getFloat(e))!==t&&(this._parametersAreDirty=!0),(I=this.runtimeAnimatorController)==null||I.setFloat(e,t)}GetFloat(e){return this.getFloat(e)}getFloat(e){var t;return((t=this.runtimeAnimatorController)==null?void 0:t.getFloat(e))??-1}SetInteger(e,t){this.setInteger(e,t)}setInteger(e,t){var g,I;((g=this.runtimeAnimatorController)==null?void 0:g.getInteger(e))!==t&&(this._parametersAreDirty=!0),(I=this.runtimeAnimatorController)==null||I.setInteger(e,t)}GetInteger(e){return this.getInteger(e)}getInteger(e){var t;return((t=this.runtimeAnimatorController)==null?void 0:t.getInteger(e))??-1}SetTrigger(e){this.setTrigger(e)}setTrigger(e){var t;(t=this.runtimeAnimatorController)==null||t.setTrigger(e),this._parametersAreDirty=!0}ResetTrigger(e){this.resetTrigger(e)}resetTrigger(e){var t;(t=this.runtimeAnimatorController)==null||t.resetTrigger(e),this._parametersAreDirty=!0}GetTrigger(e){this.getTrigger(e)}getTrigger(e){var t;(t=this.runtimeAnimatorController)==null||t.getTrigger(e)}IsInTransition(){return this.isInTransition()}isInTransition(){var e;return((e=this.runtimeAnimatorController)==null?void 0:e.isInTransition())??!1}SetSpeed(e){return this.setSpeed(e)}setSpeed(e){var t;e!==this.speed&&(this.speed=e,(t=this._animatorController)==null||t.setSpeed(e))}set minMaxSpeed(e){this.speed=ZA.lerp(e.x,e.y,Math.random())}set minMaxOffsetNormalized(e){this.normalizedStartOffset=ZA.lerp(e.x,e.y,Math.random()),this.runtimeAnimatorController&&(this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset)}awake(){jv&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(e=!1){const t=e||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&t){const g=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=g,g?(console.assert(this.runtimeAnimatorController!==g),this.runtimeAnimatorController=g,console.assert(this.runtimeAnimatorController===g),this.runtimeAnimatorController.bind(this),this.runtimeAnimatorController.setSpeed(this.speed),this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset):console.warn("Could not clone animator controller",this.runtimeAnimatorController)}}onDisable(){var e;this.keepAnimatorControllerStateOnDisable||(e=this._animatorController)==null||e.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!DgA(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}Wy([D()],Rg.prototype,"applyRootMotion",2);Wy([D()],Rg.prototype,"hasRootMotion",2);Wy([D()],Rg.prototype,"keepAnimatorControllerStateOnDisable",2);Wy([D()],Rg.prototype,"runtimeAnimatorController",1);const aE=sA("debugusdzanimation"),sM=sA("debugusdzanimationserialization");class Vy{constructor(A,e,t){r(this,"_start");r(this,"ext");r(this,"root");r(this,"clip");this.ext=A,this.root=e,this.clip=t}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){return this.clip.duration}}class Ho{constructor(A,e,t){r(this,"clip");r(this,"pos");r(this,"rot");r(this,"scale");r(this,"root");r(this,"target");r(this,"duration",0);r(this,"useRootMotion",!1);this.root=A,this.target=e,this.clip=t,t?this.duration=t.duration:this.duration=1/this.frameRate;const g=IA.getComponent(A,Rg);g&&(this.useRootMotion=g.applyRootMotion)}get frameRate(){return 60}addTrack(A){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it – this is likely a bug");return}A.name.endsWith("position")&&(this.pos=A),A.name.endsWith("quaternion")&&(this.rot=A),A.name.endsWith("scale")&&(this.scale=A)}getFrames(){var A,e,t,g,I,o;return this.clip?Math.max(((e=(A=this.pos)==null?void 0:A.times)==null?void 0:e.length)??0,((g=(t=this.rot)==null?void 0:t.times)==null?void 0:g.length)??0,((o=(I=this.scale)==null?void 0:I.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(A=!0,e=!0,t=!0){var n,C,a;if(!this.clip)return[0,this.duration];const g=(n=this.pos)==null?void 0:n.times,I=(C=this.rot)==null?void 0:C.times,o=(a=this.scale)==null?void 0:a.times,s=[];if(A&&g)for(const B of g)s.push(B);if(e&&I)for(const B of I)s.push(B);if(t&&o)for(const B of o)s.push(B);return s.includes(0)||s.push(0),s.sort((B,Q)=>B-Q),[...new Set(s)]}*getValues(A,e=!0,t=!0,g=!0){var Q,E,c;const I=new w,o=new GA,s=new w(1,1,1),n=this.target,C=e?(Q=this.pos)==null?void 0:Q.createInterpolant():void 0,a=t?(E=this.rot)==null?void 0:E.createInterpolant():void 0,B=g?(c=this.scale)==null?void 0:c.createInterpolant():void 0;C||I.set(n.position.x,n.position.y,n.position.z),a||o.set(n.quaternion.x,n.quaternion.y,n.quaternion.z,n.quaternion.w),B||s.set(n.scale.x,n.scale.y,n.scale.z);for(let l=0;l<A.length;l++){const d=A[l];if(C){const h=C.evaluate(d);I.set(h[0],h[1],h[2])}if(a){const h=a.evaluate(d);o.set(h[0],h[1],h[2],h[3])}if(B){const h=B.evaluate(d);s.set(h[0],h[1],h[2])}if(this.useRootMotion&&n===this.root){const h=new FA;h.compose(I,o,s),h.multiply(n.matrix),h.decompose(I,o,s)}yield{time:d,translation:I,rotation:o,scale:s,index:l}}}}r(Ho,"animationDurationPadding",1);class Wd{constructor(A){r(this,"dict",new Map);r(this,"rootTargetMap",new Map);r(this,"rootAndClipToRegisteredAnimationMap",new Map);r(this,"rootToRegisteredClipCount",new Map);r(this,"serializers",[]);r(this,"injectRestPoses",!1);r(this,"injectImplicitBehaviours",!1);this.injectRestPoses=A,this.injectImplicitBehaviours=A}get extensionName(){return"animation"}getClipCount(A){let e=this.rootToRegisteredClipCount.get(A);return this.injectRestPoses&&(e=e?e-1:0),e??0}getStartTime01(A,e){const t=this.rootTargetMap.get(A);if(!t)return 0;const g=this.dict.get(t[0]);if(!g)return console.error("Trying to get start time for root that has no animation data",A,e,...this.dict),0;let I=0;for(let o=0;o<g.length&&g[o].clip!==e;o++)I+=g[o].getDuration()+Ho.animationDurationPadding;return I}registerAnimation(A,e){if(!e||!A)return null;this.rootTargetMap.has(A)||this.rootTargetMap.set(A,[]);const t=A.uuid+e.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(t))return this.rootAndClipToRegisteredAnimationMap.get(t);aE&&console.log("registerAnimation",A,e);const g=this.injectRestPoses?1:0,I=this.rootToRegisteredClipCount.get(A)??g,o=this.rootTargetMap.get(A),s=new Set(o);if(e.tracks)for(const C of e.tracks){const a=He.parseTrackName(C.name),B=He.findNode(A,a.nodeName);if(!B){console.warn("no object found for track",C.name,"using "+A.name+" instead");continue}this.dict.has(B)||this.dict.set(B,[]);const Q=this.dict.get(B);if(!Q)continue;if(s.delete(B),this.injectRestPoses&&!Q[0]){const c=new Ho(null,B,void 0);Q[0]=c}let E=Q[I];E||(E=new Ho(A,B,e),Q[I]=E),E.addTrack(C),o!=null&&o.includes(B)||o==null||o.push(B)}for(const C of s){const a=this.dict.get(C);if(!a)continue;if(this.injectRestPoses&&!a[0]){const Q=new Ho(null,C,void 0);a[0]=Q}let B=a[I];B||(aE&&console.log("Adding padding clip for ",C,e),B=new Ho(A,C,e),a[I]=B)}const n=new Vy(this,A,e);return this.rootAndClipToRegisteredAnimationMap.set(t,n),this.rootToRegisteredClipCount.set(A,I+1),n}onAfterHierarchy(A){aE&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(A){var e,t;for(const g of this.serializers){const I=(e=g.model)==null?void 0:e.parent,o=(I==null?void 0:I.isDynamic)===!0;sM&&console.log(o,(t=g.model)==null?void 0:t.parent),o&&g.registerCallback(I)}}onExportObject(A,e,t){IA.foreachComponent(A,I=>{const o=I;typeof o.createAnimation=="function"&&o.createAnimation(this,e,t)},!1);const g=new kgA(A,this.dict);this.serializers.push(g),g.registerCallback(e)}}class kgA{constructor(A,e){r(this,"object");r(this,"dict");r(this,"model");r(this,"callback");this.object=A,this.dict=e}registerCallback(A){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),sM&&console.log("REPARENT",A),this.model=A,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(A,e){const t=this.model,g=this.dict;if(t&&t.skinnedMesh){let I=function(G){const R=[];for(const[S,M]of G){let K=`${S} : [`;const P=[];for(const b of M)P.push(`(${Cg(b.x)}, ${Cg(b.y)}, ${Cg(b.z)})`);K=K.concat(P.join(", ")),K=K.concat("],"),R.push(K)}return R},o=function(G){const R=[];for(const[S,M]of G){let K=`${S} : [`;const P=[];for(const b of M)P.push(`(${Cg(b.w)}, ${Cg(b.x)}, ${Cg(b.y)}, ${Cg(b.z)})`);K=K.concat(P.join(", ")),K=K.concat("],"),R.push(K)}return R},s=function(G){let R=!0,S;for(const[K,P]of G)if(S===void 0&&(S=P.length),S!==P.length){R=!1;break}aE&&console.log("Bone count: ",G.size,"TransformData entries per bone: ",S),console.assert(R,"All bones should have the same number of TransformData entries",G);const M=[];for(const[K,P]of G){const b=new Array;let H=0;for(let W=0;W<P.length;W++)b.push(H),H+=P[W].getDuration()+Ho.animationDurationPadding;for(let W=0;W<P.length;W++){const T=P[W],v=b[W];M.length<=W&&M.push({pos:[],rot:[],scale:[],timeOffset:v});const Y=M[W];Y.pos.push(...T.getSortedTimesArray(!0,!1,!1)),Y.rot.push(...T.getSortedTimesArray(!1,!0,!1)),Y.scale.push(...T.getSortedTimesArray(!1,!1,!0))}}for(const K of M)K.pos.sort((P,b)=>P-b),K.rot.sort((P,b)=>P-b),K.scale.sort((P,b)=>P-b),K.pos=[...new Set(K.pos)],K.rot=[...new Set(K.rot)],K.scale=[...new Set(K.scale)];return M},n=function(G,R,S){const M=new Map,K=new Map,P=new Map,b=R.length;for(const H of S){const W=G.get(H);let T;W?console.assert(W.length===b,"We should have the same number of TransformData entries for each bone",W,R):T=new Ho(null,H,void 0);for(let v=0;v<b;v++){const Y=W?W[v]:T,AA=R[v];for(const{time:$,translation:V}of Y.getValues(AA.pos,!0,!1,!1)){const dA=($+AA.timeOffset)*60;M.has(dA)||M.set(dA,new Array),M.get(dA).push(V.clone())}for(const{time:$,rotation:V}of Y.getValues(AA.rot,!1,!0,!1)){const dA=($+AA.timeOffset)*60;K.has(dA)||K.set(dA,new Array),K.get(dA).push(V.clone())}for(const{time:$,scale:V}of Y.getValues(AA.scale,!1,!1,!0)){const dA=($+AA.timeOffset)*60;P.has(dA)||P.set(dA,new Array),P.get(dA).push(V.clone())}}}return{position:M.size==0?void 0:M,quaternion:K.size==0?void 0:K,scale:P.size==0?void 0:P}},C=function(G){const R=[];for(const S of G)R.push(`(${Cg(S.x)}, ${Cg(S.y)}, ${Cg(S.z)})`);return R.join(", ")},a=function(G){const R=[];for(const S of G)R.push(`(${Cg(S.w)}, ${Cg(S.x)}, ${Cg(S.y)}, ${Cg(S.z)})`);return R.join(", ")},B=function(G){const R=new Map;if(aE){const S=new Array;for(const[M,K]of g)S.push(M.uuid+": "+K.length+" "+K.map(P=>{var b;return(b=P.clip)==null?void 0:b.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
5190
5190
  `+S.join(`
5191
5191
  `))}for(const S of G){const M=g.get(S);M&&R.set(S,M)}return R},Q=function(G){const R=B(G),S=s(R);return n(R,S,G)};const E=t.skinnedMesh.skeleton,c=new Array;for(const G in E.bones){const R=E.bones[G],S=E.boneInverses[G];c.push({bone:R,inverse:S})}for(const G of b2(E.bones))c.push({bone:G,inverse:G.matrixWorld.clone().invert()});const l=c[0].bone.parent;l||console.error("No bone parent found for skinned mesh during USDZ export",t.skinnedMesh),c.sort((G,R)=>nE(G.bone,l)>nE(R.bone,l)?1:-1);const d=[],h=[],p=[],u=[];for(const{bone:G}of c)d.push(G.matrix.clone()),h.push(G.position),p.push(G.quaternion),u.push(G.scale);const f=c.map(G=>'"'+nE(G.bone,l)+'"').join(", "),k=c.map(G=>OQ(G.inverse.clone().invert())).join(", ");A.beginBlock('def Skeleton "Rig"'),A.appendLine(`uniform matrix4d[] bindTransforms = [${k}]`),A.appendLine(`uniform token[] joints = [${f}]`),A.appendLine('uniform token purpose = "guide"'),A.appendLine(`uniform matrix4d[] restTransforms = [${d.map(G=>OQ(G)).join(", ")}]`),A.appendLine(`matrix4d xformOp:transform = ${OQ(new FA)}`),A.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const m=Q(c.map(G=>G.bone));if(A.beginBlock('def SkelAnimation "_anim"'),A.appendLine(`uniform token[] joints = [${f}]`),A.appendLine(`quatf[] rotations = [${a(p)}]`),m&&m.quaternion){A.beginBlock("quatf[] rotations.timeSamples = {","");const G=o(m.quaternion);for(const R of G)A.appendLine(R);A.closeBlock()}if(A.appendLine(`half3[] scales = [${C(u)}]`),m&&m.scale){A.beginBlock("half3[] scales.timeSamples = {","");const G=I(m.scale);for(const R of G)A.appendLine(R);A.closeBlock()}if(A.appendLine(`float3[] translations = [${C(h)}]`),m&&m.position){A.beginBlock("float3[] translations.timeSamples = {","");const G=I(m.position);for(const R of G)A.appendLine(R);A.closeBlock()}A.closeBlock(),A.closeBlock()}}onSerialize(A,e){var n;if(!this.model)return;this.skinnedMeshExport(A,e);const t=this.object,g=this.dict.get(t);if(!g||t.isSkinnedMesh)return;sM&&console.log("SERIALIZE",this.model.name,this.object.type,g);const I=new FA;A.appendLine("matrix4d xformOp:transform.timeSamples = {"),A.indent++;const o=new Array;let s=0;for(let C=0;C<g.length;C++)o.push(s),s+=g[C].getDuration()+Ho.animationDurationPadding;for(let C=0;C<g.length;C++){const a=g[C];if(!a)continue;const B=o[C];{const Q=a.getSortedTimesArray();if(!Q||Q.length===0){console.error("got an animated object but no time values?",t,a);continue}if(aE){const E=((n=a.clip)==null?void 0:n.name)??"rest",c=a.getDuration();console.log("Write .timeSamples:",E,B,c,g),A.appendLine("# "+E+": start="+(B*a.frameRate).toFixed(3)+", length="+(c*a.frameRate).toFixed(3)+", frames="+a.getFrames())}for(const{time:E,translation:c,rotation:l,scale:d}of a.getValues(Q)){I.compose(c,l,d);const h=`${(B+E)*a.frameRate}: ${OQ(I)},`;A.appendLine(h)}}}A.indent--,A.appendLine("}")}}var mgA=Object.defineProperty,GgA=Object.getOwnPropertyDescriptor,X2=(i,A,e,t)=>{for(var g=t>1?void 0:t?GgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&mgA(A,e,g),g};class Fe{constructor(A){r(this,"_active",!0);r(this,"_value");r(this,"_valueRaw");r(this,"_defaultValue");r(this,"valueProcessor");r(this,"onValueChanged");this._value=A,this._defaultValue=A,this._valueRaw=A}get overrideState(){return this._active}set overrideState(A){if(this._active===A)return;this._active=A;const e=A?this._valueRaw:this._defaultValue;this.processValue(e,!0)}get value(){return this._valueRaw}set value(A){this.processValue(A,!1)}set defaultValue(A){this._defaultValue=A}__init(){this.processValue(this._valueRaw,!0)}processValue(A,e){if(A==null||!e&&this.testIfValueChanged(A)===!1)return;const t=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,A=this._defaultValue,this._valueRaw=A):(this._valueRaw=A,this._active&&this.valueProcessor&&(A=this.valueProcessor(A)),this._value=A),this.onValueChanged&&this.onValueChanged(A,t,this)}testIfValueChanged(A){return this._valueRaw!==A}}X2([D()],Fe.prototype,"overrideState",1);X2([D()],Fe.prototype,"value",1);var MgA=Object.defineProperty,RgA=Object.getOwnPropertyDescriptor,UgA=(i,A,e,t)=>{for(var g=t>1?void 0:t?RgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&MgA(A,e,g),g};const FgA=sA("debugpost");class AI extends Va{constructor(e=void 0){super();r(this,"active",!0);r(this,"_result");r(this,"_didCreateVolumeParameters",!1);if(e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const g=e[t],I=this[t];I instanceof Fe&&(I.value=g)}}}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(){FgA&&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 g=this[t];g instanceof Fe&&g.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const g=this.$serializedTypes;if(g){for(const I of Object.keys(g))if(g[I]===Fe){const s=e[I];if(s!==void 0){const n=this[I];n.value=s}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof Fe){const g=e.value;return this[t].value=g,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===Fe&&(this[t]||(this[t]=new Fe))}}UgA([D()],AI.prototype,"active",2);var NgA=Object.defineProperty,KgA=Object.getOwnPropertyDescriptor,JgA=(i,A,e,t)=>{for(var g=t>1?void 0:t?KgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&NgA(A,e,g),g};const qgA=sA("debugpost"),nM={};function ts(i,A){nM[i]=A}function vgA(i){return i.__type in nM?nM[i.__type]:(qgA&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),AI)}class Vd{constructor(){r(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}JgA([Ac([i=>vgA(i),AI])],Vd.prototype,"components",2);var bgA=Object.defineProperty,LgA=Object.getOwnPropertyDescriptor,xgA=(i,A,e,t)=>{for(var g=t>1?void 0:t?LgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&bgA(A,e,g),g};class zd extends AI{constructor(){super(...arguments);r(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new jX({preset:RQ.HIGH,edgeDetectionMode:eU.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}xgA([D(Fe)],zd.prototype,"preset",2);ts("Antialiasing",zd);class zy{constructor(){r(this,"files",[])}get extensionName(){return"Audio"}onExportObject(A,e,t){const g=IA.getComponents(A,Ji);if(g.length)for(const I of g){if(!I.clip||typeof I.clip!="string"||!I.playOnAwake)continue;const o=I.clip.split("/").pop();this.files.includes(I.clip)||this.files.push(I.clip),e.addEventListener("serialize",(s,n)=>{s.appendLine(),s.beginBlock(`def SpatialAudio "${e.name}"`),s.appendLine(`uniform asset filePath = @audio/${o}@`),s.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),s.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),s.appendLine(`uniform float gain = ${I.volume}`),s.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const t=e.split("/").pop(),o=await(await(await fetch(e)).blob()).arrayBuffer(),s=new Uint8Array(o);A.files["audio/"+t]=s}}}const VQ=sA("debugnetworkingstreams");var In=(i=>(i.Connected="peer-user-connected",i.StreamReceived="receive-stream",i.StreamEnded="call-ended",i.Disconnected="peer-user-disconnected",i.UserJoined="user-joined",i))(In||{});class $2{constructor(A,e){r(this,"type","call-ended");r(this,"userId");r(this,"direction");this.userId=A,this.direction=e}}class AO{constructor(A,e){r(this,"type","receive-stream");r(this,"stream");r(this,"target");this.stream=A,this.target=e}}class TgA{constructor(A,e){r(this,"guid");r(this,"peerId");r(this,"dontSave",!0);this.guid=A.id,this.peerId=e}}var eO=(i=>(i.Incoming="incoming",i.Outgoing="outgoing",i))(eO||{});class YgA extends tg{constructor(e,t,g){super();r(this,"userId");r(this,"direction");r(this,"call");r(this,"_stream",null);r(this,"_isDisposed",!1);this.userId=e,this.call=t,this.direction=g,this._stream=null,t.on("stream",I=>{if(VQ&&console.log("Receive video",I.getAudioTracks(),I.getVideoTracks()),this._stream=I,g==="incoming"){const o=new AO(I,this);this.dispatchEvent(o)}}),t.on("close",()=>{this.dispatchEvent(new $2(e,g))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),aC(this._stream))}get isOpen(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connected"}get isOpening(){var e;return((e=this.call.peerConnection)==null?void 0:e.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const $Q=class extends tg{constructor(e,t){super();r(this,"id");r(this,"context");r(this,"_peer");r(this,"_incomingCalls",[]);r(this,"_outgoingCalls",[]);r(this,"_enabled",!1);r(this,"_enabledPeer",!1);r(this,"onConnectRoomFn",this.onConnectRoom.bind(this));r(this,"onPeerConnectFn",this.onPeerConnect.bind(this));r(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this));this.context=e,this.id=t,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(e,t){if($Q.instances.has(t))return $Q.instances.get(t);const g=new $Q(e,t);return $Q.instances.set(t,g),g}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(e){return this.id+"-"+e}getUserIdFromPeerId(e){return e.substring(this.id.length+1)}makeCall(e,t){var o;const g={metadata:{userId:this.context.connection.connectionId}},I=(o=this._peer)==null?void 0:o.call(e,t,g);if(I)return this.registerCall(I,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(Ht.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(Ht.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const e=this.getMyPeerId();e?this._peer=BY(e):console.error("Failed to setup peerjs because we dont have a connection id",this.context.connection.connectionId)}this._enabled&&this.subscribePeerEvents()}}subscribePeerEvents(){this._peer&&(this._peer.on("open",this.onPeerConnectFn),this._peer.on("call",this.onPeerReceiveCallFn))}unsubscribePeerEvents(){this._peer&&(this._peer.off("open",this.onPeerConnectFn),this._peer.off("call",this.onPeerReceiveCallFn))}onPeerConnect(e){VQ&&console.log("Peer connected as",e),this.context.connection.send("peer-user-connected",new TgA(this,e))}onPeerReceivingCall(e){e.answer(),this.registerCall(e,"incoming")}registerCall(e,t){const g=e.metadata;(!g||!g.userId)&&console.error("Missing call metadata",e);const I=g.userId;t==="incoming"&&VQ?console.log("Receive call from",e.metadata):VQ&&console.log("Make call to",e.metadata);const o=t==="incoming"?this._incomingCalls:this._outgoingCalls,s=new YgA(I,e,t);return o.push(s),e.on("error",n=>{console.error("Call error",n)}),e.on("close",()=>{VQ&&console.log("Call ended",e.metadata),e.close();const n=o.indexOf(s);n!==-1&&o.splice(n,1)}),s.addEventListener("call-ended",n=>{this.dispatchEvent(n)}),t==="incoming"&&(s.addEventListener("receive-stream",n=>{this.dispatchEvent(n)}),e.on("stream",()=>{let n=0;const C=setInterval(()=>{const a=n===0;!s.isOpen&&a&&(n+=1,clearInterval(C),s.close())},2e3)})),s}};let rE=$Q;r(rE,"instances",new Map);class jd extends tg{constructor(e,t){super();r(this,"context");r(this,"peer");r(this,"_sendingStreams",new Map);r(this,"debug",!1);r(this,"onJoinedRoom",e=>{this.debug&&console.log(`${e.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()});r(this,"onReceiveStream",e=>{this.debug&&console.log("RECEIVE STREAM",e),this.dispatchEvent({type:"receive-stream",target:this,stream:e.stream,userId:e.userId})});r(this,"onCallEnded",e=>{this.dispatchEvent(e)});r(this,"onUserConnected",e=>{if(this.peer.id===e.guid){this.debug&&console.log("USER CONNECTED",e.guid,e);const t=this._sendingStreams.keys().next().value;this.peer.makeCall(e.peerId,t)}});r(this,"onUserLeft",e=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()});this.context=e,this.peer=t,VQ&&(this.debug=!0)}static create(e){const t=rE.getOrCreate(e.context,e.context.connection.connectionId);return new jd(e.context,t)}startSendingStream(e){this._sendingStreams.has(e)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(e,[]),this.updateSendingCalls())}stopSendingStream(e){if(e){const t=this._sendingStreams.get(e);if(t){this.debug&&console.log("Closing calls",t);for(const g of t)g.close()}this._sendingStreams.delete(e),t&&this.debug&&console.log("Currently sending",this._sendingStreams)}}enable(){this.peer.enable(),this.peer.addEventListener("receive-stream",this.onReceiveStream),this.peer.addEventListener("call-ended",this.onCallEnded),this.context.connection.beginListen("peer-user-connected",this.onUserConnected),this.context.connection.beginListen(Ht.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Ht.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Ht.UserLeftRoom,this.onUserLeft)}disable(){this.peer.disable(),this.peer.removeEventListener("receive-stream",this.onReceiveStream),this.peer.removeEventListener("call-ended",this.onCallEnded),this.context.connection.stopListen("peer-user-connected",this.onUserConnected),this.context.connection.stopListen(Ht.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Ht.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Ht.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var g;let e=!1;const t=this.context.connection.connectionId;for(const I of this._sendingStreams.keys()){const o=this._sendingStreams.get(I)||[];for(const s of this.context.connection.usersInRoom()){if(s===t)continue;const n=o.find(C=>C.userId===s);if(!n||((g=n.stream)==null?void 0:g.active)===!1){this.debug&&console.log("Starting call to",s,t);const C=this.peer.makeCall(this.peer.getPeerIdFromUserId(s),I);C&&(e=!0,o.push(C))}}this._sendingStreams.set(I,o)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),e&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const e of this._sendingStreams.keys()){const t=this._sendingStreams.get(e);if(t)for(let g=t.length-1;g>=0;g--){const I=t[g];this.context.connection.userIsInRoom(I.userId)||(I.close(),t.splice(g,1))}}}}function aC(i){if(i&&i instanceof MediaStream)for(const A of i.getTracks())A.stop()}var HgA=Object.defineProperty,_gA=Object.getOwnPropertyDescriptor,tO=(i,A,e,t)=>{for(var g=t>1?void 0:t?_gA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&HgA(A,e,g),g};const iO="noVoip",OgA=sA("debugvoip");class $a extends NA{constructor(){super(...arguments);r(this,"autoConnect",!1);r(this,"runInBackground",!0);r(this,"debug",!1);r(this,"_net");r(this,"_outputStream",null);r(this,"onJoinedRoom",async()=>{await Ka(300),this.autoConnect&&!this.isSending&&this.connect()});r(this,"_incomingStreams",new Map);r(this,"onReceiveStream",e=>{const t=e.target.userId,g=e.stream,I=this._incomingStreams.get(t);if(I)I.srcObject=g,I.setAttribute("autoplay","true");else{const o=new Audio;this._incomingStreams.set(t,o),o.setAttribute("autoplay","true"),o.srcObject=g}});r(this,"onStreamEnded",e=>{const t=this._incomingStreams.get(e.userId);aC(t==null?void 0:t.srcObject),this._incomingStreams.delete(e.userId)});r(this,"onEnabledChanged",()=>{for(const e of this._incomingStreams){const t=e[1];t.muted=!this.enabled}});r(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const t=!(document.visibilityState==="visible");this.setMuted(t);for(const g of this._incomingStreams){const I=g[1];I.muted=t}})}awake(){OgA&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async e=>{e.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=jd.create(this)),this._net.addEventListener(In.StreamReceived,this.onReceiveStream),this._net.addEventListener(In.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(Ht.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var e;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(In.StreamReceived,this.onReceiveStream),this._net.removeEventListener(In.StreamEnded,this.onStreamEnded),(e=this._net)==null||e.disable(),this.context.connection.stopListen(Ht.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(e){if(this.context.connection.isConnected){if(!await sG())return console.error("Cannot connect to voice chat - microphone permissions not granted"),!1}else return console.error("Cannot connect to voice chat - not connected to server"),!1;return this._net.stopSendingStream(this._outputStream),aC(this._outputStream),this._outputStream=await this.getAudioStream(e),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await sG()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):rT("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),aC(this._outputStream),this._outputStream=null}setMuted(e){var g;const t=(g=this._outputStream)==null?void 0:g.getAudioTracks();if(t)for(const I of t)I.enabled=!e}get isMuted(){var t;if(this._outputStream===null)return!1;const e=(t=this._outputStream)==null?void 0:t.getAudioTracks();if(e){for(const g of e)if(!g.enabled)return!0}return!1}getFrequency(e){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,_e()&&hg("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(e){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:e??!0,video:!1}).catch(g=>(console.warn("VOIP failed getting audio stream",g),null)):(console.error("No getDisplayMedia support"),null)}}tO([D()],$a.prototype,"autoConnect",2);tO([D()],$a.prototype,"runInBackground",2);var PgA=Object.defineProperty,WgA=Object.getOwnPropertyDescriptor,gO=(i,A,e,t)=>{for(var g=t>1?void 0:t?WgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&PgA(A,e,g),g};const VgA=sA("debugmouth");class Zd extends NA{constructor(){super(...arguments);r(this,"idle",[]);r(this,"talking",[]);r(this,"marker",null);r(this,"voip",null);r(this,"lastMouthChangeTime",0);r(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=IA.findObjectOfType($a,this.context),this.marker||(this.marker=IA.getComponentInParent(this.gameObject,Bg))},3e3)}update(){var g;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((g=this.marker)==null?void 0:g.connectionId)??null;if(!e){VgA&&(e=null);return}const t=this.voip.getFrequency(e)??0;this.updateLips(t)}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(g=>g.visible=!1):this.talking.map(g=>g.visible=!1);for(let g=0;g<e.length;g++){const I=e[g];I&&(I.visible=g===t)}}}}gO([D(SA)],Zd.prototype,"idle",2);gO([D(SA)],Zd.prototype,"talking",2);class IF extends NA{constructor(){super(...arguments);r(this,"voip",null);r(this,"marker",null);r(this,"_startPosition",null)}awake(){this.voip=IA.findObjectOfType($a,this.context),this.marker=IA.getComponentInParent(this.gameObject,Bg)}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 g=t/100;this.gameObject.position.y=this._startPosition.y+g*.07}}var zgA=Object.defineProperty,jgA=Object.getOwnPropertyDescriptor,jy=(i,A,e,t)=>{for(var g=t>1?void 0:t?jgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&zgA(A,e,g),g};class DB extends NA{constructor(){super(...arguments);r(this,"eyes",[]);r(this,"lastBlinkTime",0);r(this,"blinkLength",0);r(this,"eyesOpen",!0);r(this,"state",null)}awake(){this.state=IA.getComponentInParent(this.gameObject,Io)}update(){if(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)return;if(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 t of this.eyes)t&&(t.visible=this.eyesOpen)}}}jy([D(SA)],DB.prototype,"eyes",2);jy([D()],DB.prototype,"lastBlinkTime",2);jy([D()],DB.prototype,"blinkLength",2);jy([D()],DB.prototype,"eyesOpen",2);var ZgA=Object.defineProperty,XgA=Object.getOwnPropertyDescriptor,oF=(i,A,e,t)=>{for(var g=t>1?void 0:t?XgA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&ZgA(A,e,g),g},um;const IO=(um=class extends NA{constructor(){super(...arguments);r(this,"head",null);r(this,"eyes",null);r(this,"target",null);r(this,"brain",null);r(this,"vec",new w);r(this,"currentTargetPoint",new w)}awake(){this.brain||(this.brain=IA.getComponentInParent(this.gameObject,Yl)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=IA.addNewComponent(this.gameObject,Yl)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const A=this.target;if(A&&this.head){const e=this.eyes;if(e){const t=ce(A);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const g=ce(this.head),I=this.vec.copy(this.currentTargetPoint).sub(g).normalize();if(I.length()<.1)return;const o=IO.forward;if(o.set(0,0,1),o.applyQuaternion(Ft(this.head)),o.dot(I)>.45)for(let n=0;n<e.length;n++)e[n].lookAt(this.currentTargetPoint)}}}},r(um,"forward",new w(0,0,1)),um);let Cc=IO;oF([D(SA)],Cc.prototype,"head",2);oF([D(SA)],Cc.prototype,"eyes",2);oF([D(SA)],Cc.prototype,"target",2);var $gA=Object.defineProperty,AIA=Object.getOwnPropertyDescriptor,sF=(i,A,e,t)=>{for(var g=t>1?void 0:t?AIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&$gA(A,e,g),g};class ac extends NA{constructor(){super(...arguments);r(this,"length",1);r(this,"depthTest",!0);r(this,"isGizmo",!0);r(this,"_axes",null)}onEnable(){if(this.isGizmo&&!Ud)return;this._axes||(this._axes=new PE(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),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)}}sF([D()],ac.prototype,"length",2);sF([D()],ac.prototype,"depthTest",2);sF([D()],ac.prototype,"isGizmo",2);class nF extends NA{constructor(){super(...arguments);r(this,"from");r(this,"to");r(this,"hint");r(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const e=ce(this.to).clone(),t=ce(this.from).clone(),g=e.distanceTo(t),I=e.clone();I.sub(t);const o=t.clone();o.add(e),o.multiplyScalar(.5);const s=ce(this.hint).clone();s.sub(o);const n=new w;n.crossVectors(s,I),n.crossVectors(I,n),n.normalize();const C=g*.5,a=Math.max(this.desiredDistance,C),B=Math.sqrt(a*a-C*C),Q=n.clone();Q.multiplyScalar(B),Q.add(o),Ri(this.gameObject,Q);const E=o.clone();E.sub(n),this.gameObject.lookAt(E)}}const eIA=sA("debugusdz");class Zy{constructor(){r(this,"behaviours",[]);r(this,"behaviourComponents",[]);r(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(t=>{IA.foreachComponent(t,g=>{var o;const I=g;if(typeof I.createBehaviours=="function"||typeof I.beforeCreateDocument=="function"||typeof I.afterCreateDocument=="function"||typeof I.afterSerialize=="function"){this.behaviourComponents.push(I);const s=(o=I.beforeCreateDocument)==null?void 0:o.call(I,this,A);s instanceof Promise&&e.push(s)}},!1)}),Promise.all(e)}onExportObject(A,e,t){var g;for(const I of this.behaviourComponents)(g=I.createBehaviours)==null||g.call(I,this,e,t)}onAfterBuildDocument(A){for(const e of this.behaviourComponents)typeof e.afterCreateDocument=="function"&&e.afterCreateDocument(this,A);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(A,e){var t;if((t=this.behaviours)!=null&&t.length){e.beginBlock('def Scope "Behaviors"');for(const g of this.behaviours)g.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){eIA&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)typeof e.afterSerialize=="function"&&(e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A));this.behaviours.length=0}}var tIA=Object.defineProperty,iIA=Object.getOwnPropertyDescriptor,CF=(i,A,e,t)=>{for(var g=t>1?void 0:t?iIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&tIA(A,e,g),g};class wB extends AI{constructor(){super(...arguments);r(this,"threshold");r(this,"intensity");r(this,"scatter");r(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 hH(this.context.scene,this.context.mainCamera,{blendFunction:Ye.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new IU;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}}CF([D(Fe)],wB.prototype,"threshold",2);CF([D(Fe)],wB.prototype,"intensity",2);CF([D(Fe)],wB.prototype,"scatter",2);ts("Bloom",wB);var gIA=Object.defineProperty,IIA=Object.getOwnPropertyDescriptor,is=(i,A,e,t)=>{for(var g=t>1?void 0:t?IIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&gIA(A,e,g),g};class pn extends NA{constructor(){super(...arguments);r(this,"attachedRigidbody",null);r(this,"isTrigger",!1);r(this,"sharedMaterial");r(this,"updateProperties",()=>{var e;(e=this.context.physics.engine)==null||e.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(vt))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(vt))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(vt))}onDisable(){var e;(e=this.context.physics.engine)==null||e.removeBody(this)}get body(){var e;return(e=this.context.physics.engine)==null?void 0:e.getBody(this)}updatePhysicsMaterial(){var e;(e=this.context.physics.engine)==null||e.updatePhysicsMaterial(this)}}is([D(vt)],pn.prototype,"attachedRigidbody",2);is([D()],pn.prototype,"isTrigger",2);is([D()],pn.prototype,"sharedMaterial",2);class Xd extends pn{constructor(){super(...arguments);r(this,"radius",.5);r(this,"center",new w(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this),FR(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),$x(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}is([qg(),D()],Xd.prototype,"radius",2);is([D(w)],Xd.prototype,"center",2);class $d extends pn{constructor(){super(...arguments);r(this,"size",new w(1,1,1));r(this,"center",new w(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.size)}onValidate(){this.updateProperties()}}is([qg(),D(w)],$d.prototype,"size",2);is([D(w)],$d.prototype,"center",2);class rc extends pn{constructor(){super(...arguments);r(this,"sharedMesh");r(this,"convex",!1)}onEnable(){var e,t,g,I,o;if(super.onEnable(),(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof pA&&(this.sharedMesh=this.gameObject),(t=this.sharedMesh)!=null&&t.isMesh)(g=this.context.physics.engine)==null||g.addMeshCollider(this,this.sharedMesh,this.convex,rg(this.gameObject));else{const s=this.sharedMesh;if(s!=null&&s.isGroup){console.warn(`MeshCollider mesh is a group "${((I=this.sharedMesh)==null?void 0:I.name)||this.gameObject.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);for(const n in s.children){const C=s.children[n];C.isMesh&&((o=this.context.physics.engine)==null||o.addMeshCollider(this,C,this.convex,rg(this.gameObject)))}}}}}is([D()],rc.prototype,"sharedMesh",2);is([D()],rc.prototype,"convex",2);class ba extends pn{constructor(){super(...arguments);r(this,"center",new w(0,0,0));r(this,"radius",.5);r(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.height,this.radius)}}is([D(w)],ba.prototype,"center",2);is([D()],ba.prototype,"radius",2);is([D()],ba.prototype,"height",2);var oIA=Object.defineProperty,sIA=Object.getOwnPropertyDescriptor,aF=(i,A,e,t)=>{for(var g=t>1?void 0:t?sIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&oIA(A,e,g),g};class yB extends NA{constructor(){super(...arguments);r(this,"objectBounds",!1);r(this,"color");r(this,"isGizmo",!0);r(this,"_gizmoObject",null);r(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!Ud||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new Ay(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=F2(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Qg.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){var e;for(;this._boxHelper;)(e=this._boxHelper)==null||e.update(),yield}}aF([D()],yB.prototype,"objectBounds",2);aF([D(yA)],yB.prototype,"color",2);aF([D()],yB.prototype,"isGizmo",2);var nIA=Object.defineProperty,CIA=Object.getOwnPropertyDescriptor,Au=(i,A,e,t)=>{for(var g=t>1?void 0:t?CIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&nIA(A,e,g),g};const bk=sA("debugui"),Lk=sA("debuguilayout");class rF{constructor(){r(this,"width");r(this,"height")}}class BF{constructor(){r(this,"x");r(this,"y");r(this,"width");r(this,"height")}}const rs=new w,sh=new FA,Hp=new GA,oO=class extends ms{constructor(){super(...arguments);r(this,"_anchoredPosition");r(this,"sizeDelta",new tA(100,100));r(this,"pivot",new tA(.5,.5));r(this,"anchorMin",new tA(0,0));r(this,"anchorMax",new tA(1,1));r(this,"minWidth");r(this,"minHeight");r(this,"lastMatrix");r(this,"rectBlock");r(this,"_transformNeedsUpdate",!1);r(this,"_initialPosition");r(this,"_parentRectTransform");r(this,"_lastUpdateFrame",-1);r(this,"_lastAnchoring");r(this,"_createdBlocks",[]);r(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 tA),this._anchoredPosition}set anchoredPosition(A){this._anchoredPosition=A}get width(){let A=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;A=e*t,A+=this.sizeDelta.x}return this.minWidth!==void 0&&A<this.minWidth?this.minWidth:A}get height(){let A=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;A=e*t,A+=this.sizeDelta.y}return this.minHeight!==void 0&&A<this.minHeight?this.minHeight:A}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new tA),this.lastMatrix=new FA,this.rectBlock=new SA,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,KQ(this,"_anchoredPosition",()=>{this.markDirty()}),KQ(this,"sizeDelta",()=>{this.markDirty()}),KQ(this,"pivot",()=>{this.markDirty()}),KQ(this,"anchorMin",()=>{this.markDirty()}),KQ(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var A;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(A=this.Canvas)==null||A.registerTransform(this)}onDisable(){var A;super.onDisable(),this.removeShadowComponent(),(A=this.Canvas)==null||A.unregisterTransform(this)}onParentRectTransformChanged(A){this._transformNeedsUpdate||this.onApplyTransform(Lk?`${A.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(Lk&&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(A){var g;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const e=this.shadowComponent;if(!e)return;this.gameObject.parent?this._parentRectTransform=IA.getComponentInParent(this.gameObject.parent,oO):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,Lk&&console.warn("RectTransform → ApplyTransform",this.name+" because "+A),this.isRoot()?this.Root.screenspace||(e.rotation.y=Math.PI):(e.matrix.identity(),e.matrixAutoUpdate=!1,rs.set(0,0,0),this.applyPivot(rs),e.matrix.setPosition(rs.x,rs.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(Hp.copy(this.gameObject.quaternion),Hp.x*=-1,Hp.z*=-1,sh.makeRotationFromQuaternion(Hp),e.matrix.premultiply(sh)),rs.set(0,0,0),this.applyAnchoring(rs),(g=this.Canvas)!=null&&g.screenspace?rs.z+=.1:rs.z+=.01,sh.identity(),sh.setPosition(rs.x,rs.y,rs.z),e.matrix.premultiply(sh),e.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const t=!0;for(const I of $R(this.gameObject,ms,t,1)){if(I===this||!I.activeAndEnabled)continue;const o=I;o.onParentRectTransformChanged&&o.onParentRectTransformChanged(this)}}applyAnchoring(A){this._lastAnchoring||(this._lastAnchoring=new tA);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),A.x+=this._initialPosition.x-this.gameObject.position.x,A.y+=this._initialPosition.y-this.gameObject.position.y,A.z+=this._initialPosition.z-this.gameObject.position.z;const t=this._parentRectTransform;if(t){let g=0;const I=1-this.anchorMax.y-this.anchorMin.y;g-=t.height*.5*I,A.y+=g;let o=0;const s=1-this.anchorMax.x-this.anchorMin.x;o-=t.width*.5*s,A.x+=o}}applyPivot(A){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;A.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const t=this.pivot.y-.5;A.y-=t*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const A={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(A),A}ensureValidSize(A,e=1e-4){return A.width<=0&&(A.width=e),A.height<=0&&(A.height=1e-4),A}createNewBlock(A){A={...this.getBasicOptions(),...A},bk&&console.log(this.name,A);const e=new zU(A);return this._createdBlocks.push(e),e}createNewText(A){bk&&console.log(A),A={...this.getBasicOptions(),...A},bk&&console.log(this.name,A);const e=new jU(A);return this._createdTextBlocks.push(e),e}};let fI=oO;Au([D(tA)],fI.prototype,"anchoredPosition",1);Au([D(tA)],fI.prototype,"sizeDelta",2);Au([D(tA)],fI.prototype,"pivot",2);Au([D(tA)],fI.prototype,"anchorMin",2);Au([D(tA)],fI.prototype,"anchorMax",2);class aIA extends R2{constructor(A,e={}){super(A),A._simpleState__activeStates=[],A._simpleState__normalStyles={},A._simpleState__states=e,A._simpleState__statesProperties={};for(const t in e)for(const g in e[t])A._simpleState__statesProperties[g]||(A._simpleState__statesProperties[g]=[]),A._simpleState__statesProperties[g].push(t);for(const t of A._components)A._simpleState__statesProperties[t.id]&&(A._simpleState__normalStyles[t.id]=t.inline?t.inline:t._value);A.__overridedSet=A.set,A.set=this.storeSet.bind(A),A.renderStates=this.renderStates.bind(A),A.setupState=this.setupState.bind(A),A.setState=this.setState.bind(A),A.activatePseudoState=this.activatePseudoState.bind(A),A.deactivatePseudoState=this.deactivatePseudoState.bind(A),A.togglePseudoState=this.togglePseudoState.bind(A)}act(){}attach(){}detach(){}setupState(A,e){this._simpleState__states[A]=e;const t=[];for(const g in e)this._simpleState__statesProperties[g]||(this._simpleState__statesProperties[g]=[],t.push(g)),this._simpleState__statesProperties[g].push(A);for(const g of this._components)t.indexOf(g.id)>-1&&(this._simpleState__normalStyles[g.id]=g.inline?g.inline:g._value)}renderStates(){let A={...this._simpleState__normalStyles};for(const e in this._simpleState__states)this._simpleState__activeStates.indexOf(e)>-1&&(A={...A,...this._simpleState__states[e]});this.set(A,!1)}storeSet(A,e=!0){if(e)for(const t in A)this._simpleState__statesProperties[t]&&(this._simpleState__normalStyles[t]=A[t]);this.__overridedSet(A)}activatePseudoState(A){this._simpleState__activeStates.indexOf(A)===-1&&(this._simpleState__activeStates.push(A),this.renderStates())}deactivatePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1&&(this._simpleState__activeStates.splice(e,1),this.renderStates())}togglePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1?this._simpleState__activeStates.splice(e,1):this._simpleState__activeStates.push(A),this.renderStates()}setState(A){Array.isArray(A)?this._simpleState__activeStates=A:this._simpleState__activeStates=[A],this.renderStates()}}var rIA=Object.defineProperty,BIA=Object.getOwnPropertyDescriptor,sO=(i,A,e,t)=>{for(var g=t>1?void 0:t?BIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&rIA(A,e,g),g};class Bc extends NA{constructor(){super(...arguments);r(this,"effectColor");r(this,"effectDistance")}}sO([D(St)],Bc.prototype,"effectColor",2);sO([D(tA)],Bc.prototype,"effectDistance",2);var QIA=Object.defineProperty,EIA=Object.getOwnPropertyDescriptor,nO=(i,A,e,t)=>{for(var g=t>1?void 0:t?EIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&QIA(A,e,g),g};const _p={backgroundColor:new yA(1,1,1),backgroundOpacity:1,borderColor:new yA(1,1,1),borderOpacity:1};var pm;const Of=(pm=class extends ms{constructor(){super(...arguments);r(this,"_alphaFactor",1);r(this,"sRGBColor",new yA(1,0,1));r(this,"raycastTarget",!0);r(this,"uiObject",null);r(this,"_color",null);r(this,"_rect",null);r(this,"_stateManager",null);r(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new St(1,1,1,1)),this._color}set color(A){(!this._color||this._color.r!==A.r||this._color.g!==A.g||this._color.b!==A.b||this._color.alpha!==A.alpha)&&(this._color||(this._color=new St(1,1,1,1)),this._color.copy(A),this.onColorChanged())}setAlphaFactor(A){this._alphaFactor=A,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),_p.backgroundColor=this.sRGBColor,_p.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(_p,this._alphaFactor),this.uiObject.set(_p),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=IA.getComponent(this.gameObject,fI)),!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 A;(A=this.uiObject)==null||A.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(A){this.makePanel(),this.uiObject&&(this.uiObject.setState(A),this==null||this.markDirty())}setupState(A){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new aIA(this.uiObject)),this.uiObject.setupState(A.state,A.attributes))}setOptions(A){this.makePanel(),this.uiObject&&this.uiObject.set(A)}awake(){super.awake(),this.makePanel(),KQ(this,"_color",()=>sgA(this,this.onColorChanged))}onEnable(){var A;super.onEnable(),this.uiObject&&((A=this.rectTransform.shadowComponent)==null||A.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 A=.015,e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:A};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(A){}onCreate(A){this.uiObject=this.rectTransform.createNewBlock(A),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(A,e=1){var g;const t=(g=this.gameObject)==null?void 0:g.getComponent(Bc);t&&(t.effectDistance&&(A.borderWidth=Math.max(Math.abs(t.effectDistance.x),Math.abs(t.effectDistance.y))),t.effectColor&&(A.borderColor=t.effectColor,A.borderOpacity=t.effectColor.alpha*e))}async setTexture(A){if(this.setOptions({backgroundOpacity:0}),A){if(Of.textureCache.has(A))A=Of.textureCache.get(A);else if(!A.isRenderTargetTexture){const e=A.clone();e.colorSpace=Fi,Of.textureCache.set(A,e),A=e}this.setOptions({backgroundImage:A,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)}},r(pm,"textureCache",new Map),pm);let SB=Of;nO([D(St)],SB.prototype,"color",1);nO([D()],SB.prototype,"raycastTarget",2);class eu extends SB{constructor(){super(...arguments);r(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var cIA=Object.defineProperty,hIA=Object.getOwnPropertyDescriptor,Xy=(i,A,e,t)=>{for(var g=t>1?void 0:t?hIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&cIA(A,e,g),g};let QF=class{constructor(){r(this,"texture",null);r(this,"rect")}};Xy([D(Le)],QF.prototype,"texture",2);let Qc=class extends eu{constructor(){super(...arguments);r(this,"_sprite");r(this,"pixelsPerUnitMultiplier",1)}set image(e){this.sprite||(this.sprite=new QF),this.sprite.texture=e,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(e){this._sprite!==e&&(this._sprite=e,this.onAfterCreated())}isBuiltinSprite(){var e,t,g,I,o,s,n,C;switch((t=(e=this.sprite)==null?void 0:e.texture)==null?void 0:t.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((o=(I=(g=this.sprite)==null?void 0:g.texture)==null?void 0:I.image)==null?void 0:o.width)===32&&((C=(n=(s=this.sprite)==null?void 0:s.texture)==null?void 0:n.image)==null?void 0:C.height)===32}onBeforeCreate(e){var t,g;super.onBeforeCreate(e),this.isBuiltinSprite()&&(e.borderRadius=5/this.pixelsPerUnitMultiplier,((g=(t=this.sprite)==null?void 0:t.texture)==null?void 0:g.name)==="Knob"&&(e.borderRadius=999))}onAfterCreated(){var e;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((e=this.sprite)==null?void 0:e.texture))}};Xy([D(QF)],Qc.prototype,"sprite",1);Xy([D()],Qc.prototype,"pixelsPerUnitMultiplier",2);class $y extends eu{constructor(){super(...arguments);r(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))}}Xy([D(Le)],$y.prototype,"mainTexture",1);var lIA=Object.defineProperty,dIA=Object.getOwnPropertyDescriptor,lo=(i,A,e,t)=>{for(var g=t>1?void 0:t?dIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&lIA(A,e,g),g};const fQ=sA("debugbutton");class kB{constructor(){r(this,"colorMultiplier");r(this,"disabledColor");r(this,"fadeDuration");r(this,"highlightedColor");r(this,"normalColor");r(this,"pressedColor");r(this,"selectedColor")}}lo([D()],kB.prototype,"colorMultiplier",2);lo([D(St)],kB.prototype,"disabledColor",2);lo([D()],kB.prototype,"fadeDuration",2);lo([D(St)],kB.prototype,"highlightedColor",2);lo([D(St)],kB.prototype,"normalColor",2);lo([D(St)],kB.prototype,"pressedColor",2);lo([D(St)],kB.prototype,"selectedColor",2);class vC extends NA{constructor(){super(...arguments);r(this,"onClick");r(this,"_isHovered",!1);r(this,"colors");r(this,"transition");r(this,"animationTriggers");r(this,"animator");r(this,"_interactable",!0);r(this,"_requestedAnimatorTrigger");r(this,"_isInit",!1);r(this,"_image")}onPointerEnter(e){var t,g;fQ&&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&&((g=this._image)==null||g.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var e,t;fQ&&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,g;fQ&&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&&((g=this._image)==null||g.setState("pressed")))}onPointerUp(e){var t,g;fQ&&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&&((g=this._image)==null||g.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){!this.interactable||e.pointerId!==0||e.pointerId!==0&&this.context.input.getIsMouse(e.pointerId)||(fQ&&(console.warn("Button Click",this.onClick),mi("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),e.use()))}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(),fQ&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable),this.gameObject.getComponentInParent(Xa)||this.gameObject.addComponent(Yy)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*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=IA.getComponent(this.gameObject,Qc),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var E,c,l,d,h;e.setInteractable(this.interactable);const t=this.getFinalColor(e.color,(E=this.colors)==null?void 0:E.normalColor),g={state:"normal",attributes:{backgroundColor:t,backgroundOpacity:t.alpha}};e.setupState(g);const I=this.getFinalColor(e.color,(c=this.colors)==null?void 0:c.highlightedColor),o={state:"hovered",attributes:{backgroundColor:I,backgroundOpacity:I.alpha}};e.setupState(o);const s=this.getFinalColor(e.color,(l=this.colors)==null?void 0:l.pressedColor),n={state:"pressed",attributes:{backgroundColor:s,backgroundOpacity:s.alpha}};e.setupState(n);const C=this.getFinalColor(e.color,(d=this.colors)==null?void 0:d.selectedColor),a={state:"selected",attributes:{backgroundColor:C,backgroundOpacity:C.alpha}};e.setupState(a);const B=this.getFinalColor(e.color,(h=this.colors)==null?void 0:h.disabledColor),Q={state:"disabled",attributes:{backgroundColor:B,backgroundOpacity:B.alpha}};e.setupState(Q)}getFinalColor(e,t){return t?e.clone().multiply(t).convertLinearToSRGB():e.clone().convertLinearToSRGB()}}lo([D(mg)],vC.prototype,"onClick",2);lo([D()],vC.prototype,"colors",2);lo([D()],vC.prototype,"transition",2);lo([D()],vC.prototype,"animationTriggers",2);lo([D(Rg)],vC.prototype,"animator",2);lo([D()],vC.prototype,"interactable",1);var uIA=Object.defineProperty,pIA=Object.getOwnPropertyDescriptor,Wi=(i,A,e,t)=>{for(var g=t>1?void 0:t?pIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&uIA(A,e,g),g};const Zv=sA("debuguilayout");class Ar{constructor(){r(this,"left",0);r(this,"right",0);r(this,"top",0);r(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}Wi([D()],Ar.prototype,"left",2);Wi([D()],Ar.prototype,"right",2);Wi([D()],Ar.prototype,"top",2);Wi([D()],Ar.prototype,"bottom",2);class uo extends NA{constructor(){super(...arguments);r(this,"_rectTransform",null);r(this,"_needsUpdate",!1);r(this,"childAlignment",0);r(this,"reverseArrangement",!1);r(this,"spacing",0);r(this,"padding");r(this,"minWidth",0);r(this,"minHeight",0);r(this,"flexibleHeight",0);r(this,"flexibleWidth",0);r(this,"preferredHeight",0);r(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&&(Zv&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){Zv&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(fI);const e=this.gameObject.getComponentInParent(Ug);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(Ug);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}Wi([D()],uo.prototype,"childAlignment",2);Wi([D()],uo.prototype,"reverseArrangement",2);Wi([D()],uo.prototype,"spacing",2);Wi([D(Ar)],uo.prototype,"padding",2);Wi([D()],uo.prototype,"minWidth",2);Wi([D()],uo.prototype,"minHeight",2);Wi([D()],uo.prototype,"flexibleHeight",2);Wi([D()],uo.prototype,"flexibleWidth",2);Wi([D()],uo.prototype,"preferredHeight",2);Wi([D()],uo.prototype,"preferredWidth",2);class er extends uo{constructor(){super(...arguments);r(this,"childControlHeight",!0);r(this,"childControlWidth",!0);r(this,"childForceExpandHeight",!1);r(this,"childForceExpandWidth",!1);r(this,"childScaleHeight",!1);r(this,"childScaleWidth",!1)}onCalculateLayout(e){var R;const t=this.primaryAxis,g=e.width;let I=g;const o=e.height;let s=o;I-=this.padding.horizontal,s-=this.padding.vertical,t==="x"?this.padding.horizontal:this.padding.vertical;const n=t==="x",C=n?"y":"x",a=n?this.childControlWidth:this.childControlHeight,B=n?this.childControlHeight:this.childControlWidth,Q=n?this.childForceExpandWidth:this.childForceExpandHeight,E=n?this.childForceExpandHeight:this.childForceExpandWidth,c=n?s:I,l=n?g:o,d=.5*(n?this.childAlignment%3:Math.floor(this.childAlignment/3));let h=0;n?h+=this.padding.left:h+=this.padding.top;let p=0,u=0;for(let S=0;S<this.gameObject.children.length;S++){const M=this.gameObject.children[S],K=IA.getComponent(M,fI);K!=null&&K.activeAndEnabled&&(u+=1,n?p+=K.width:p+=K.height)}let f=0;const k=this.spacing*(u-1);if(Q||a){let S=0;n?S=I-=k:S=s-=k,u>0&&(f=S/u)}let m=0;m+=this.padding.left,m-=this.padding.right,d!==0&&(h=l-p,h*=d,h-=k*d,n?(h-=this.padding.right*d,h+=this.padding.left*(1-d),h<this.padding.left&&(h=this.padding.left)):(h-=this.padding.bottom*d,h+=this.padding.top*(1-d),h<this.padding.top&&(h=this.padding.top)));let G=1;for(let S=0;S<this.gameObject.children.length;S++){const M=this.gameObject.children[S],K=IA.getComponent(M,fI);if(K!=null&&K.activeAndEnabled){(R=K.pivot)==null||R.set(.5,.5),K.anchorMin.set(0,1),K.anchorMax.set(0,1);const P=g*.5+m*.5;K.anchoredPosition.x!==P&&(K.anchoredPosition.x=P);const b=o*-.5;K.anchoredPosition.y!==b&&(K.anchoredPosition.y=b),E&&B&&K.sizeDelta[C]!==c&&(K.sizeDelta[C]=c),Q&&a&&K.sizeDelta[t]!==f&&(K.sizeDelta[t]=f);const H=n?K.width:K.height,W=H*.5;if(h+=W,Q){const v=f*G-f*.5;v>h&&(h=v-f*.5+H+this.padding.left,h-=W)}let T=h;t==="y"&&(T=-T),K.anchoredPosition[t]!==T&&(K.anchoredPosition[t]=T),h+=W,h+=this.spacing,G+=1}}}}Wi([D()],er.prototype,"childControlHeight",2);Wi([D()],er.prototype,"childControlWidth",2);Wi([D()],er.prototype,"childForceExpandHeight",2);Wi([D()],er.prototype,"childForceExpandWidth",2);Wi([D()],er.prototype,"childScaleHeight",2);Wi([D()],er.prototype,"childScaleWidth",2);class EF extends er{get primaryAxis(){return"y"}}class cF extends er{get primaryAxis(){return"x"}}class hF extends uo{onCalculateLayout(){}}var fIA=Object.defineProperty,DIA=Object.getOwnPropertyDescriptor,fn=(i,A,e,t)=>{for(var g=t>1?void 0:t?DIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&fIA(A,e,g),g},CO=(i=>(i[i.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",i[i.ScreenSpaceCamera=1]="ScreenSpaceCamera",i[i.WorldSpace=2]="WorldSpace",i[i.Undefined=-1]="Undefined",i))(CO||{});const xk=sA("debuguilayout"),aO=class extends _d{constructor(){super(...arguments);r(this,"_renderOnTop");r(this,"_depthWrite",!1);r(this,"_doubleSided",!0);r(this,"_castShadows",!1);r(this,"_receiveShadows",!1);r(this,"_renderMode",-1);r(this,"_rootCanvas");r(this,"_scaleFactor",1);r(this,"worldCamera");r(this,"planeDistance",-1);r(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this));r(this,"previousParent",null);r(this,"_lastMatrixWorld",null);r(this,"_rectTransforms",[]);r(this,"_layoutGroups",new Map);r(this,"_receivers",[]);r(this,"onBeforeRenderRoutine",()=>{var A,e,t,g;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(A=this.shadowComponent)==null||A.updateMatrixWorld(!0),(e=this.shadowComponent)==null||e.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),QI.ensureUpdateMeshUI(Nk,this.context,!0);return}this.previousParent=this.gameObject.parent,this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(t=this.shadowComponent)==null||t.updateMatrixWorld(!0),(g=this.shadowComponent)==null||g.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),QI.ensureUpdateMeshUI(Nk,this.context))});r(this,"onAfterRenderRoutine",()=>{var A,e;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const I=this.context.mainCamera;I==null||I.add(this.gameObject)}else this.previousParent.add(this.gameObject);const t=this.context.renderer.autoClear,g=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(A=this.shadowComponent)==null||A.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),QI.ensureUpdateMeshUI(Nk,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=t,this.context.renderer.autoClearColor=g,this.previousParent.add(this.gameObject)}(e=this._lastMatrixWorld)==null||e.copy(this.gameObject.matrixWorld)}});r(this,"_updateRenderSettingsRoutine");r(this,"_activeRenderMode",-1);r(this,"_lastWidth",-1);r(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(A){A!==this._renderOnTop&&(this._renderOnTop=A,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(A){this._depthWrite!==A&&(this._depthWrite=A,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(A){this._doubleSided!==A&&(this._doubleSided=A,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(A){this._castShadows!==A&&(this._castShadows=A,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(A){this._receiveShadows!==A&&(this._receiveShadows=A,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(A){this._renderMode!==A&&(this._renderMode=A,this.onRenderSettingsChanged())}set rootCanvas(A){this._rootCanvas instanceof aO||(this._rootCanvas=A)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(A){this._scaleFactor=A}awake(){var A;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,xk&&console.log("Canvas.Awake()",((A=this.previousParent)==null?void 0:A.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new FA,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 A=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);A!==-1&&this.context.pre_render_callbacks.splice(A,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(A){this._rectTransforms.push(A)}unregisterTransform(A){const e=this._rectTransforms.indexOf(A);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(A){const e=A.gameObject;this._layoutGroups.set(e,A)}unregisterLayoutGroup(A){const e=A.gameObject;this._layoutGroups.delete(e)}registerEventReceiver(A){this._receivers.push(A)}unregisterEventReceiver(A){const e=this._receivers.indexOf(A);e!==-1&&this._receivers.splice(e,1)}invokeBeforeRenderEvents(){var A;for(const e of this._receivers)(A=e.onBeforeCanvasRender)==null||A.call(e,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new FA);const A=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);xk&&A&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const e=!1;for(const t of this._rectTransforms){A&&t.markDirty();let g=this._layoutGroups.get(t.gameObject);t.isDirty&&!g&&(g=t.gameObject.getComponentInParent(uo)),(t.isDirty||g!=null&&g.isDirty)&&(xk&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),g==null||g.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Qg.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),PD(this.shadowComponent,this);for(const A of IA.getComponentsInChildren(this.gameObject,ms))PD(A.shadowComponent,this)}}onUpdateRenderMode(A=!1){if(!A&&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=ZA.lerp(e.nearClipPlane,e.farClipPlane,.01)),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 g=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-g,this.gameObject.quaternion.identity();const I=this.gameObject.getComponent(fI);let o=!1;I.sizeDelta.x!==this.context.domWidth&&(o=!0),I.sizeDelta.y!==this.context.domHeight&&(o=!0);const s=e.fieldOfView*Math.PI/180,n=2*Math.tan(s/2)*Math.abs(g);this.gameObject.scale.x=n/this.context.domHeight,this.gameObject.scale.y=n/this.context.domHeight,this.gameObject.scale.z=.01,o&&(I.sizeDelta.x=this.context.domWidth,I.sizeDelta.y=this.context.domHeight,I==null||I.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let Ug=aO;fn([D()],Ug.prototype,"renderOnTop",1);fn([D()],Ug.prototype,"depthWrite",1);fn([D()],Ug.prototype,"doubleSided",1);fn([D()],Ug.prototype,"castShadows",1);fn([D()],Ug.prototype,"receiveShadows",1);fn([D()],Ug.prototype,"renderMode",1);fn([D(Ug)],Ug.prototype,"rootCanvas",1);fn([D()],Ug.prototype,"scaleFactor",1);fn([D(Ot)],Ug.prototype,"worldCamera",2);fn([D()],Ug.prototype,"planeDistance",2);var wIA=Object.defineProperty,yIA=Object.getOwnPropertyDescriptor,lF=(i,A,e,t)=>{for(var g=t>1?void 0:t?yIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&wIA(A,e,g),g};class La extends NA{constructor(){super(...arguments);r(this,"_alpha",1);r(this,"interactable",!0);r(this,"blocksRaycasts",!0);r(this,"_isDirty",!1);r(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(),Qg.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const e of IA.getComponentsInChildren(this.gameObject,ms,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}lF([D()],La.prototype,"alpha",1);lF([D()],La.prototype,"interactable",2);lF([D()],La.prototype,"blocksRaycasts",2);var SIA=Object.defineProperty,kIA=Object.getOwnPropertyDescriptor,ci=(i,A,e,t)=>{for(var g=t>1?void 0:t?kIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&SIA(A,e,g),g};function tu(i){i&&(i.getComponentInParent(Xa)||(_e()&&console.warn("Create Raycaster on "+i.name+" because no raycaster was found in the hierarchy"),i.addNewComponent(Gs)))}class mB extends NA{constructor(){super(...arguments);r(this,"object");r(this,"target");r(this,"duration",1);r(this,"relativeMotion",!1);r(this,"coroutine",null);r(this,"targetPos",new w);r(this,"targetRot",new GA);r(this,"targetScale",new w)}start(){tu(this.gameObject)}onPointerClick(e){e.use(),this.coroutine&&this.stopCoroutine(this.coroutine),this.relativeMotion?this.coroutine=this.startCoroutine(this.moveRelative()):this.coroutine=this.startCoroutine(this.moveToTarget())}*moveToTarget(){if(!this.target||!this.object)return;const e=ce(this.object).clone(),t=ce(this.target).clone(),g=Ft(this.object).clone(),I=Ft(this.target).clone(),o=rg(this.object).clone(),s=rg(this.target).clone(),n=e.distanceTo(t),C=g.angleTo(I),a=o.distanceTo(s);if(n<.01&&C<.01&&a<.01){Ri(this.object,t),uI(this.object,I),uD(this.object,s),this.coroutine=null;return}let B=0,Q=0;for(;B<1;)B+=this.context.time.deltaTime/this.duration,B>1&&(B=1),Q=B<.5?4*B*B*B:1-Math.pow(-2*B+2,3)/2,this.targetPos.lerpVectors(e,t,Q),this.targetRot.slerpQuaternions(g,I,Q),this.targetScale.lerpVectors(o,s,Q),Ri(this.object,this.targetPos),uI(this.object,this.targetRot),uD(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(),g=this.object.scale.clone(),I=this.target.position.clone(),o=this.target.quaternion.clone(),s=this.target.scale.clone();I.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(I),this.targetRot.copy(this.object.quaternion).multiply(o),this.targetScale.copy(this.object.scale).multiply(s);let n=0,C=0;for(;n<1;)n+=this.context.time.deltaTime/this.duration,n>1&&(n=1),C=n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,C),this.object.quaternion.slerpQuaternions(t,this.targetRot,C),this.object.scale.lerpVectors(g,this.targetScale,C),yield;this.coroutine=null}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const g=new Gg("Move to "+((t=this.target)==null?void 0:t.name),hI.tapTrigger(this.gameObject),yt.transformAction(this.object,this.target,this.duration,this.relativeMotion?tM.Relative:tM.Absolute));e.addBehavior(g)}}}ci([D(SA)],mB.prototype,"object",2);ci([D(SA)],mB.prototype,"target",2);ci([D()],mB.prototype,"duration",2);ci([D()],mB.prototype,"relativeMotion",2);var af;const On=(af=class extends NA{constructor(){super(...arguments);r(this,"materialToSwitch");r(this,"variantMaterial");r(this,"fadeDuration",0);r(this,"_objectsWithThisMaterial",[]);r(this,"selfModel");r(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const A=IA.findObjectsOfType(Ki);for(const e of A)for(let t=0;t<e.sharedMaterials.length;t++){const g=e.sharedMaterials[t];if(g===this.materialToSwitch){if(e.gameObject instanceof pA)this._objectsWithThisMaterial.push(e.gameObject);else if(e.gameObject instanceof aI)for(const I of e.gameObject.children)I instanceof pA&&I.material===g&&this._objectsWithThisMaterial.push(I);break}}}}start(){tu(this.gameObject)}onPointerClick(A){if(A.use(),!!this.variantMaterial)for(let e=0;e<this._objectsWithThisMaterial.length;e++){const t=this._objectsWithThisMaterial[e];t.material=this.variantMaterial}}async beforeCreateDocument(A,e){this.targetModels=[],On._materialTriggersPerId={},On.variantSwitchIndex=0,this.materialToSwitch&&await eo.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await eo.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(A,e,t){this._objectsWithThisMaterial.find(I=>I.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(On._materialTriggersPerId[this.materialToSwitch.uuid]||(On._materialTriggersPerId[this.materialToSwitch.uuid]=[]),On._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(A,e){if(!this.materialToSwitch)return;const t=On._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const g={};for(const I of t){const o=I.createVariants();o&&o.length>0&&(g[I.selfModel.uuid]=o)}for(const I of t){const o=[];for(const s in g)s!==I.selfModel.uuid&&o.push(...g[s]);I.createAndAttachBehaviors(A,g[I.selfModel.uuid],o)}}delete On._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(A,e,t){const g=[],I=[],o=Math.max(0,this.fadeDuration);I.push(yt.fadeAction([...this.targetModels,...t],o,!1)),g.push(yt.fadeAction(e,o,!1)),I.push(yt.fadeAction(e,o,!0)),A.addBehavior(new Gg("Select_"+this.selfModel.name,hI.tapTrigger(this.selfModel),yt.parallel(...I))),A.addBehavior(new Gg("StartHidden_"+this.selfModel.name,hI.sceneStartTrigger(),yt.parallel(...g)))}createVariants(){if(!this.variantMaterial)return null;const A=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name+"_"+On.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())&&qI.createEmptyParent(e),e.parent&&e.parent.add(t),A.push(t)}return A}},r(af,"_materialTriggersPerId",{}),r(af,"variantSwitchIndex",0),af);let Ec=On;ci([D(xe)],Ec.prototype,"materialToSwitch",2);ci([D(xe)],Ec.prototype,"variantMaterial",2);ci([D()],Ec.prototype,"fadeDuration",2);class cc extends NA{constructor(){super(...arguments);r(this,"target");r(this,"toggleOnClick",!1);r(this,"targetState",!0);r(this,"hideSelf",!0);r(this,"selfModel");r(this,"otherModel");r(this,"toggleModel");r(this,"stateBeforeCreatingDocument",!1)}start(){tu(this.gameObject)}onPointerClick(e){e.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(e,t,g){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 g=this.hideSelf;this.targetState,this.toggleOnClick&&(g=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&L2.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const I=[];if(g&&I.push(yt.fadeAction(this.selfModel,0,!1)),this.toggleModel&&I.push(yt.fadeAction(this.toggleModel,0,!0)),I.push(yt.fadeAction(this.otherModel,0,this.targetState)),e.addBehavior(new Gg("Toggle_"+this.selfModel.name+"_hideSelf",hI.tapTrigger(this.selfModel),yt.sequence(...I))),this.toggleOnClick&&this.toggleModel){const o=[];o.push(yt.fadeAction(this.toggleModel,0,!1)),o.push(yt.fadeAction(this.selfModel,0,!0)),o.push(yt.fadeAction(this.otherModel,0,!this.targetState)),e.addBehavior(new Gg("Toggle_"+this.selfModel.name+"_toggleSelf",hI.tapTrigger(this.toggleModel),yt.sequence(...o))),e.addBehavior(new Gg("HideOnStart_"+this.gameObject.name,hI.sceneStartTrigger(),yt.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}ci([D(SA)],cc.prototype,"target",2);ci([D()],cc.prototype,"targetState",2);ci([D()],cc.prototype,"hideSelf",2);class dF extends NA{start(){this.gameObject.visible=!1}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&A.addBehavior(new Gg("HideOnStart_"+this.gameObject.name,hI.sceneStartTrigger(),yt.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class hc extends NA{constructor(){super(...arguments);r(this,"target");r(this,"duration",.5);r(this,"motionType",AF.bounce)}beforeCreateDocument(){}createBehaviours(e,t,g){if(this.target&&t.uuid===this.gameObject.uuid){const I=new Gg("emphasize "+this.name,hI.tapTrigger(this.gameObject),yt.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(I)}}afterCreateDocument(e,t){}}ci([D()],hc.prototype,"target",2);ci([D()],hc.prototype,"duration",2);ci([D()],hc.prototype,"motionType",2);class lc extends NA{constructor(){super(...arguments);r(this,"target");r(this,"clip","");r(this,"toggleOnClick",!1)}start(){tu(this.gameObject)}onPointerClick(e){if(e.use(),!!this.clip){if(!this.target){const t=this.gameObject.addNewComponent(Ji);t&&(this.target=t,t.spatialBlend=1,t.volume=1,t.loop=!1)}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,g){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const I=this.clip?this.clip:this.target?this.target.clip:void 0;if(!I||typeof I!="string")return;const o=this.target?this.target.gameObject:this.gameObject,s=I.split("/").pop(),n=this.target?this.target.volume:1,C=this.target&&this.target.spatialBlend==0?iM.NonSpatial:iM.Spatial,a=new Gg("playAudio "+this.name,hI.tapTrigger(this.gameObject),yt.playAudioAction(o,"audio/"+s,_2.Play,n,C));e.addBehavior(a)}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const g=this.clip?this.clip:this.target?this.target.clip:void 0;if(!g||typeof g!="string")return;const I=g.split("/").pop(),n=await(await(await fetch(this.clip)).blob()).arrayBuffer(),C=new Uint8Array(n);t.files["audio/"+I]=C}}ci([D(Ji)],lc.prototype,"target",2);ci([D(URL)],lc.prototype,"clip",2);ci([D()],lc.prototype,"toggleOnClick",2);var rf;const Ca=(rf=class extends NA{constructor(){super(...arguments);r(this,"animator");r(this,"stateName");r(this,"trigger","tap");r(this,"selfModel");r(this,"stateAnimationModel");r(this,"animationSequence",new Array);r(this,"animationLoopAfterSequence",new Array)}get target(){var A;return(A=this.animator)==null?void 0:A.gameObject}start(){tu(this.gameObject)}onPointerClick(A){var e;A.use(),this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(A,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}afterSerialize(){if(Ca.rootsWithExclusivePlayback.size>1){const A='Multiple root objects targeted by more than one animation. To work around QuickLook bug FB13410767, animations will be set as "exclusive" and activating them will stop other animations being marked as exclusive.';_e()&&hg(A),console.warn(A,...Ca.rootsWithExclusivePlayback)}Ca.animationActions=[],Ca.rootsWithExclusivePlayback=new Set}afterCreateDocument(A,e){if(!this.animationSequence||!this.stateAnimationModel||!this.target)return;const t=e.document,g=e.extensions.find(s=>s instanceof Wd);if(!g)return;const I=g.getClipCount(this.target)>1;I&&(_e()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+g.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),Ca.rootsWithExclusivePlayback.add(this.target));const o=(s,n)=>{let C=Ca.animationActions.find(a=>a.affectedObjects==s&&a.start==n.start&&a.duration==n.duration);return C||(C=yt.startAnimationAction(s,n.start,n.duration),Ca.animationActions.push(C)),C};t.traverse(s=>{var n,C;if(s.uuid===((n=this.target)==null?void 0:n.uuid)){const a=yt.sequence();if(this.animationSequence!==void 0)for(const Q of this.animationSequence)a.addAction(o(s,Q));if(this.animationLoopAfterSequence!==void 0){const Q=a.actions.length==0?a:yt.sequence();for(const E of this.animationLoopAfterSequence)Q.addAction(o(s,E));Q.makeLooping(),a!==Q&&a.addAction(Q)}const B=new Gg("tap "+this.name+" for "+this.stateName+" on "+((C=this.target)==null?void 0:C.name),this.trigger=="tap"?hI.tapTrigger(this.selfModel):hI.sceneStartTrigger(),a);I&&B.makeExclusive(!0),A.addBehavior(B)}})}createAnimation(A,e,t){var n,C,a,B;if(!this.target||!this.animator)return;const g=(n=this.animator)==null?void 0:n.runtimeAnimatorController;let I=g==null?void 0:g.findState(this.stateName),o=[],s=[];if(g&&I){const Q=new Array;Q.push(I);let E=!1;for(;Q.length<100;){if(!I||I===null||!I.transitions||I.transitions.length===0){(C=I.motion)!=null&&C.isLooping&&(E=!0);break}const c=I.transitions.find(d=>d.conditions.length===0),l=c?g.getState(c.destinationState,0):null;if(l&&Q.includes(l)){I=l,E=!0;break}else if(c){if(I=l,!I)break;Q.push(I)}else{E=((a=I.motion)==null?void 0:a.isLooping)??!1;break}}if(E&&I){const c=Q.indexOf(I);o=Q.slice(0,c),s=Q.slice(c),console.log("found loop from "+this.stateName,"states until loop",o,"states looping",s)}else o=Q,s=[],console.log("found no loop from "+this.stateName,"states",o)}if(o=o.filter(Q=>{var E,c,l;return((E=Q.motion)==null?void 0:E.clip)&&((l=(c=Q.motion)==null?void 0:c.clip.tracks)==null?void 0:l.length)>0}),s=s.filter(Q=>{var E,c,l;return((E=Q.motion)==null?void 0:E.clip)&&((l=(c=Q.motion)==null?void 0:c.clip.tracks)==null?void 0:l.length)>0}),o.length===0&&s.length===0){console.warn("No clips found for state "+this.stateName+" on "+((B=this.animator)==null?void 0:B.name)+", can't export animation data");return}if(this.stateAnimationModel=e,o.length>0){this.animationSequence=new Array;for(const Q of o)this.animationSequence.push(A.registerAnimation(this.target,Q.motion.clip))}if(s.length>0){this.animationLoopAfterSequence=new Array;for(const Q of s)this.animationLoopAfterSequence.push(A.registerAnimation(this.target,Q.motion.clip))}}},r(rf,"animationActions",[]),r(rf,"rootsWithExclusivePlayback",new Set),rf);let dc=Ca;ci([D(Rg)],dc.prototype,"animator",2);ci([D()],dc.prototype,"stateName",2);class uc extends NA{constructor(){super(...arguments);r(this,"target")}getType(){}getDuration(){}}ci([D(SA)],uc.prototype,"target",2);class iu extends NA{constructor(){super(...arguments);r(this,"target")}}ci([D(uc)],iu.prototype,"target",2);class gu extends uc{constructor(){super(...arguments);r(this,"type",1);r(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}ci([D()],gu.prototype,"type",2);ci([D()],gu.prototype,"duration",2);class uF extends iu{}var mIA=Object.defineProperty,GIA=Object.getOwnPropertyDescriptor,bC=(i,A,e,t)=>{for(var g=t>1?void 0:t?GIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&mIA(A,e,g),g};const Xv=sA("debugcharactercontroller");class GB extends NA{constructor(){super(...arguments);r(this,"center",new w(0,0,0));r(this,"radius",.5);r(this,"height",2);r(this,"_rigidbody",null);r(this,"_activeGroundCollisions");r(this,"_contactVelocity",new w)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(vt),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(vt)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let t=this.gameObject.getComponent(ba);t||(t=this.gameObject.addNewComponent(ba)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height;const g=new w(0,0,1),I=new w(1,0,0),o=new w(0,1,0),s=this.gameObject.getWorldDirection(new w);s.y=0;const n=I.dot(s)<0?-1:1,C=g.angleTo(s)*n;this.gameObject.setRotationFromAxisAngle(o,C),e.lockRotationX=!0,e.lockRotationY=!0,e.lockRotationZ=!0}move(e){this.gameObject.position.add(e)}onCollisionEnter(e){(e.contacts.length==0||e.contacts.some(t=>t.normal.y>.2))&&(this._activeGroundCollisions.add(e),Xv&&console.log(`Collision(${this._activeGroundCollisions.size}): ${e.contacts.map(t=>t.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(e){this._activeGroundCollisions.delete(e),Xv&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var e;this._contactVelocity.set(0,0,0);for(const t of this._activeGroundCollisions){const g=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(t.collider);g&&(this._contactVelocity.x+=g.x,this._contactVelocity.y+=g.y,this._contactVelocity.z+=g.z)}return this._contactVelocity}}bC([D(w)],GB.prototype,"center",2);bC([D()],GB.prototype,"radius",2);bC([D()],GB.prototype,"height",2);class LC extends NA{constructor(){super(...arguments);r(this,"controller");r(this,"movementSpeed",2);r(this,"rotationSpeed",2);r(this,"jumpForce",1);r(this,"doubleJumpForce",2);r(this,"animator");r(this,"lookForward",!0);r(this,"lookInput",new tA(0,0));r(this,"moveInput",new tA(0,0));r(this,"jumpInput",!1);r(this,"_currentSpeed",new w(0,0,0));r(this,"_currentAngularSpeed",new w(0,0,0));r(this,"_temp",new w(0,0,0));r(this,"_jumpCount",0);r(this,"_currentRotation");r(this,"_raycastOptions",new ro)}awake(){this._currentRotation=new GA}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,g){var I,o,s,n,C,a,B,Q,E,c,l;if((I=this.controller)!=null&&I.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((o=this.animator)==null||o.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(s=this.animator)==null||s.setBool("running",e.length()>.01),(C=this.animator)==null||C.setBool("jumping",((n=this.controller)==null?void 0:n.isGrounded)===!0&&g),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+=ZA.toRadians(-t.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const d=this.context.mainCameraComponent.forward;d.y=0,d.normalize(),this._currentRotation.setFromUnitVectors(new w(0,0,1),d),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&&g&&this.jumpForce>0){let d=(a=this.controller)==null?void 0:a.isGrounded;if(this.doubleJumpForce>0&&!((B=this.controller)!=null&&B.isGrounded)&&this._jumpCount===1&&(d=!0,(Q=this.animator)==null||Q.setBool("doubleJump",!0)),d){this._jumpCount+=1;const h=this.controller.rigidbody,p=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;h.applyImpulse(new w(0,1,0).multiplyScalar(p))}}if(this.controller){const d=(E=this.controller)==null?void 0:E.rigidbody.getVelocity().y;if(d<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new Us),this._raycastOptions.ray.origin.copy(ce(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const h=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const p=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(h),(p.length&&p[0].distance>2||d<-10)&&((c=this.animator)==null||c.setBool("falling",!0))}else(l=this.animator)==null||l.setBool("falling",!1)}}}bC([D(GB)],LC.prototype,"controller",2);bC([D()],LC.prototype,"movementSpeed",2);bC([D()],LC.prototype,"rotationSpeed",2);bC([D()],LC.prototype,"jumpForce",2);bC([D()],LC.prototype,"doubleJumpForce",2);bC([D(Rg)],LC.prototype,"animator",2);var MIA=Object.defineProperty,RIA=Object.getOwnPropertyDescriptor,UIA=(i,A,e,t)=>{for(var g=t>1?void 0:t?RIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&MIA(A,e,g),g};class Iu extends AI{constructor(){super(...arguments);r(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new BH;return e.offset=new tA(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}}UIA([D(Fe)],Iu.prototype,"intensity",2);ts("ChromaticAberration",Iu);var FIA=Object.defineProperty,NIA=Object.getOwnPropertyDescriptor,AS=(i,A,e,t)=>{for(var g=t>1?void 0:t?NIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&FIA(A,e,g),g};class tr extends AI{constructor(){super(...arguments);r(this,"postExposure");r(this,"contrast");r(this,"hueShift");r(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===EI&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=cl);const e=new rH;this.postExposure.onValueChanged=g=>{this.context.renderer.toneMapping===EI&&(this.context.renderer.toneMapping=cl),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=g)},this.contrast.onValueChanged=g=>{e.contrast=g};const t=new EH;return this.hueShift.onValueChanged=g=>t.hue=g,this.saturation.onValueChanged=g=>t.saturation=g,[t,e]}}AS([D(Fe)],tr.prototype,"postExposure",2);AS([D(Fe)],tr.prototype,"contrast",2);AS([D(Fe)],tr.prototype,"hueShift",2);AS([D(Fe)],tr.prototype,"saturation",2);ts("ColorAdjustments",tr);const KIA=(Math.sqrt(5)-1)/4,ug=(5-Math.sqrt(5))/20,Op=i=>Math.floor(i)|0,Pp=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 JIA(i=Math.random){const A=qIA(i),e=new Float64Array(A).map(o=>Pp[o%32*4]),t=new Float64Array(A).map(o=>Pp[o%32*4+1]),g=new Float64Array(A).map(o=>Pp[o%32*4+2]),I=new Float64Array(A).map(o=>Pp[o%32*4+3]);return function(s,n,C,a){let B,Q,E,c,l;const d=(s+n+C+a)*KIA,h=Op(s+d),p=Op(n+d),u=Op(C+d),f=Op(a+d),k=(h+p+u+f)*ug,m=h-k,G=p-k,R=u-k,S=f-k,M=s-m,K=n-G,P=C-R,b=a-S;let H=0,W=0,T=0,v=0;M>K?H++:W++,M>P?H++:T++,M>b?H++:v++,K>P?W++:T++,K>b?W++:v++,P>b?T++:v++;const Y=H>=3?1:0,AA=W>=3?1:0,$=T>=3?1:0,V=v>=3?1:0,gA=H>=2?1:0,dA=W>=2?1:0,fA=T>=2?1:0,RA=v>=2?1:0,UA=H>=1?1:0,HA=W>=1?1:0,PA=T>=1?1:0,Qe=v>=1?1:0,Ge=M-Y+ug,oe=K-AA+ug,z=P-$+ug,xA=b-V+ug,DA=M-gA+2*ug,LA=K-dA+2*ug,MA=P-fA+2*ug,ie=b-RA+2*ug,zA=M-UA+3*ug,XA=K-HA+3*ug,ue=P-PA+3*ug,Me=b-Qe+3*ug,et=M-1+4*ug,_=K-1+4*ug,q=P-1+4*ug,EA=b-1+4*ug,KA=h&255,JA=p&255,TA=u&255,Z=f&255;let hA=.6-M*M-K*K-P*P-b*b;if(hA<0)B=0;else{const bA=KA+A[JA+A[TA+A[Z]]];hA*=hA,B=hA*hA*(e[bA]*M+t[bA]*K+g[bA]*P+I[bA]*b)}let rA=.6-Ge*Ge-oe*oe-z*z-xA*xA;if(rA<0)Q=0;else{const bA=KA+Y+A[JA+AA+A[TA+$+A[Z+V]]];rA*=rA,Q=rA*rA*(e[bA]*Ge+t[bA]*oe+g[bA]*z+I[bA]*xA)}let VA=.6-DA*DA-LA*LA-MA*MA-ie*ie;if(VA<0)E=0;else{const bA=KA+gA+A[JA+dA+A[TA+fA+A[Z+RA]]];VA*=VA,E=VA*VA*(e[bA]*DA+t[bA]*LA+g[bA]*MA+I[bA]*ie)}let jA=.6-zA*zA-XA*XA-ue*ue-Me*Me;if(jA<0)c=0;else{const bA=KA+UA+A[JA+HA+A[TA+PA+A[Z+Qe]]];jA*=jA,c=jA*jA*(e[bA]*zA+t[bA]*XA+g[bA]*ue+I[bA]*Me)}let OA=.6-et*et-_*_-q*q-EA*EA;if(OA<0)l=0;else{const bA=KA+1+A[JA+1+A[TA+1+A[Z+1]]];OA*=OA,l=OA*OA*(e[bA]*et+t[bA]*_+g[bA]*q+I[bA]*EA)}return 27*(B+Q+E+c+l)}}function qIA(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 g=t+~~(i()*(256-t)),I=e[t];e[t]=e[g],e[g]=I}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var vIA=Object.defineProperty,bIA=Object.getOwnPropertyDescriptor,oA=(i,A,e,t)=>{for(var g=t>1?void 0:t?bIA(A,e):A,I=i.length-1,o;I>=0;I--)(o=i[I])&&(g=(t?o(A,e,g):o(g))||g);return t&&g&&vIA(A,e,g),g};const Wp=sA("debugparticles");var Zn=(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))(Zn||{});let ir=class{constructor(){r(this,"alphaKeys");r(this,"colorKeys")}get duration(){return 1}evaluate(A,e){let t,g=0,I=null,o=0;for(let s=0;s<this.alphaKeys.length;s++){const n=this.alphaKeys[s];(n.time<A||!t)&&(t=n,g=s)}for(let s=0;s<this.colorKeys.length;s++){const n=this.colorKeys[s];(n.time<A||!I)&&(I=n,o=s)}if(I)if(o+1<this.colorKeys.length){const n=this.colorKeys[o+1],C=ZA.remap(A,I.time,n.time,0,1);e.r=ZA.lerp(I.color.r,n.color.r,C),e.g=ZA.lerp(I.color.g,n.color.g,C),e.b=ZA.lerp(I.color.b,n.color.b,C)}else e.r=I.color.r,e.g=I.color.g,e.b=I.color.b;if(t)if(g+1<this.alphaKeys.length){const n=this.alphaKeys[g+1],C=ZA.remap(A,t.time,n.time,0,1);e.alpha=ZA.lerp(t.alpha,n.alpha,C)}else e.alpha=t.alpha;return e}};oA([D()],ir.prototype,"alphaKeys",2);oA([D()],ir.prototype,"colorKeys",2);var Pl=(i=>(i[i.Local=0]="Local",i[i.World=1]="World",i[i.Custom=2]="Custom",i))(Pl||{}),rO=(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))(rO||{});class Be{constructor(){r(this,"mode");r(this,"constant");r(this,"constantMin");r(this,"constantMax");r(this,"curve");r(this,"curveMin");r(this,"curveMax");r(this,"curveMultiplier")}evaluate(A,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.constant;case 1:return A=ZA.clamp01(A),this.curve.evaluate(A)*this.curveMultiplier;case 2:const g=A*this.curveMin.duration,I=A*this.curveMax.duration;return ZA.lerp(this.curveMin.evaluate(g),this.curveMax.evaluate(I),t%1)*this.curveMultiplier;case 3:return ZA.lerp(this.constantMin,this.constantMax,t%1);default:this.curveMax.evaluate(A)*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(A){if(!A)return 0;let e=Number.MIN_VALUE;for(let t=0;t<A.keys.length;t++){const g=A.keys[t];g.value>e&&(e=g.value)}return e}}oA([D()],Be.prototype,"mode",2);oA([D()],Be.prototype,"constant",2);oA([D()],Be.prototype,"constantMin",2);oA([D()],Be.prototype,"constantMax",2);oA([D(fB)],Be.prototype,"curve",2);oA([D(fB)],Be.prototype,"curveMin",2);oA([D(fB)],Be.prototype,"curveMax",2);oA([D()],Be.prototype,"curveMultiplier",2);var Bf;const Qs=(Bf=class{constructor(){r(this,"mode");r(this,"color");r(this,"colorMin");r(this,"colorMax");r(this,"gradient");r(this,"gradientMin");r(this,"gradientMax")}evaluate(i,A){const e=A===void 0?Math.random():A;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(i,Qs._temp),Qs._temp;case 2:return Qs._temp.lerpColors(this.colorMin,this.colorMax,e);case 3:return this.gradientMin.evaluate(i,Qs._temp),this.gradientMax.evaluate(i,Qs._temp2),Qs._temp.lerp(Qs._temp2,e)}return Qs._temp.set(16711935),Qs._temp.alpha=1,Qs._temp}},r(Bf,"_temp",new St(0,0,0,1)),r(Bf,"_temp2",new St(0,0,0,1)),Bf);let xI=Qs;oA([D(St)],xI.prototype,"color",2);oA([D(St)],xI.prototype,"colorMin",2);oA([D(St)],xI.prototype,"colorMax",2);oA([D(ir)],xI.prototype,"gradient",2);oA([D(ir)],xI.prototype,"gradientMin",2);oA([D(ir)],xI.prototype,"gradientMax",2);var CM=(i=>(i[i.Hierarchy=0]="Hierarchy",i[i.Local=1]="Local",i[i.Shape=2]="Shape",i))(CM||{});class bg{constructor(){r(this,"cullingMode");r(this,"duration");r(this,"emitterVelocityMode");r(this,"flipRotation");r(this,"gravityModifier");r(this,"gravityModifierMultiplier");r(this,"loop");r(this,"maxParticles");r(this,"playOnAwake");r(this,"prewarm");r(this,"ringBufferLoopRange");r(this,"ringBufferMode");r(this,"scalingMode");r(this,"simulationSpace");r(this,"simulationSpeed");r(this,"startColor");r(this,"startDelay");r(this,"startDelayMultiplier");r(this,"startLifetime");r(this,"startLifetimeMultiplier");r(this,"startRotation");r(this,"startRotationMultiplier");r(this,"startRotation3D");r(this,"startRotationX");r(this,"startRotationXMultiplier");r(this,"startRotationY");r(this,"startRotationYMultiplier");r(this,"startRotationZ");r(this,"startRotationZMultiplier");r(this,"startSize");r(this,"startSize3D");r(this,"startSizeMultiplier");r(this,"startSizeX");r(this,"startSizeXMultiplier");r(this,"startSizeY");r(this,"startSizeYMultiplier");r(this,"startSizeZ");r(this,"startSizeZMultiplier");r(this,"startSpeed");r(this,"startSpeedMultiplier");r(this,"stopAction");r(this,"useUnscaledTime")}}oA([D(Be)],bg.prototype,"gravityModifier",2);oA([D(xI)],bg.prototype,"startColor",2);oA([D(Be)],bg.prototype,"startDelay",2);oA([D(Be)],bg.prototype,"startLifetime",2);oA([D(Be)],bg.prototype,"startRotation",2);oA([D(Be)],bg.prototype,"startRotationX",2);oA([D(Be)],bg.prototype,"startRotationY",2);oA([D(Be)],bg.prototype,"startRotationZ",2);oA([D(Be)],bg.prototype,"startSize",2);oA([D(Be)],bg.prototype,"startSizeX",2);oA([D(Be)],bg.prototype,"startSizeY",2);oA([D(Be)],bg.prototype,"startSizeZ",2);oA([D(Be)],bg.prototype,"startSpeed",2);class Wl{constructor(){r(this,"cycleCount");r(this,"maxCount");r(this,"minCount");r(this,"probability");r(this,"repeatInterval");r(this,"time");r(this,"count");r(this,"_performed",0)}reset(){this._performed=0}run(A){if(A<=this.time)return 0;let e=0;if(this.cycleCount===0||this._performed<this.cycleCount){const t=this.time+this.repeatInterval*this._performed;if(A>=t&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:e=this.count.constant;break;case 3:e=ZA.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:e=this.count.curve.evaluate(Math.random());break;case 2:const g=Math.random();e=ZA.lerp(this.count.curveMin.evaluate(g),this.count.curveMax.evaluate(g),Math.random());break}}return e}}class Dn{constructor(){r(this,"enabled");r(this,"bursts");r(this,"rateOverTime");r(this,"rateOverTimeMultiplier");r(this,"rateOverDistance");r(this,"rateOverDistanceMultiplier");r(this,"system")}get burstCount(){var A;return((A=this.bursts)==null?void 0:A.length)??0}reset(){var A;(A=this.bursts)==null||A.forEach(e=>e.reset())}getBurst(){let A=0;if(this.burstCount>0)for(let e=0;e<this.burstCount;e++){const t=this.bursts[e];this.system.main.loop&&t.time>=this.system.time&&t.reset(),A+=Math.round(t.run(this.system.time))}return A}}oA([D()],Dn.prototype,"enabled",2);oA([D()],Dn.prototype,"bursts",2);oA([D(Be)],Dn.prototype,"rateOverTime",2);oA([D()],Dn.prototype,"rateOverTimeMultiplier",2);oA([D(Be)],Dn.prototype,"rateOverDistance",2);oA([D()],Dn.prototype,"rateOverDistanceMultiplier",2);class ou{constructor(){r(this,"enabled");r(this,"color")}}oA([D(xI)],ou.prototype,"color",2);class gr{constructor(){r(this,"enabled");r(this,"separateAxes");r(this,"size");r(this,"sizeMultiplier");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier");r(this,"_time",0);r(this,"_temp",new w)}evaluate(A,e,t){if(e||(e=this._temp),!this.enabled)return e.x=e.y=e.z=1,e;if(this.separateAxes)e.x=this.x.evaluate(A,t)*this.xMultiplier,e.y=this.y.evaluate(A,t)*this.yMultiplier,e.z=this.z.evaluate(A,t)*this.zMultiplier;else{const g=this.size.evaluate(A,t)*this.sizeMultiplier;e.x=g}return e}}oA([D(Be)],gr.prototype,"size",2);oA([D(Be)],gr.prototype,"x",2);oA([D(Be)],gr.prototype,"y",2);oA([D(Be)],gr.prototype,"z",2);var Qf;const Mh=(Qf=class{constructor(){r(this,"shapeType",5);r(this,"enabled",!0);r(this,"alignToDirection",!1);r(this,"angle",0);r(this,"arc",360);r(this,"arcSpread");r(this,"arcSpeedMultiplier");r(this,"arcMode");r(this,"boxThickness");r(this,"position");r(this,"rotation");r(this,"_rotation",new Mi);r(this,"scale");r(this,"radius");r(this,"radiusThickness");r(this,"sphericalDirectionAmount");r(this,"randomDirectionAmount");r(this,"randomPositionAmount");r(this,"system");r(this,"_space");r(this,"_worldSpaceMatrix",new FA);r(this,"_worldSpaceMatrixInverse",new FA);r(this,"_vector",new w(0,0,0));r(this,"_temp",new w(0,0,0));r(this,"_dir",new w);r(this,"_loopTime",0);r(this,"_loopDirection",1);Wp&&console.log(this)}get type(){return rO[this.shapeType]}initialize(i){this.getPosition(),i.position.copy(this._vector)}toJSON(){return this}clone(){return new Mh}update(i,A,e,t){this.system=i,this._space=e,e===1&&(this._worldSpaceMatrix.copy(t.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 A=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return A&&(this._rotation.x=ZA.toRadians(this.rotation.x),this._rotation.y=ZA.toRadians(this.rotation.y),this._rotation.z=ZA.toRadians(this.rotation.z),this._rotation.order="ZYX",i.applyEuler(this._rotation)),A}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const i=this._temp.copy(this.position),A=this._space===1;A&&i.applyQuaternion(this.system.worldQuaternion);let e=this.radius;if(A&&(e*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:Wp&&tn.DrawWireBox(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,e,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,e,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,e,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),A&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),Wp&&tn.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(i){var A;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 e=i.x,t=i.y,g=i.z;this._dir.set(e,t,g),(A=this.system)!=null&&A.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),Wp&&(tn.DrawSphere(i,.01,8925952,.5,!0),tn.DrawDirection(i,this._dir,8925952,.5,!0)),this._dir}randomizePosition(i,A){if(A<=0)return;const e=Mh._tempVec;e.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),e.x*=A*this.scale.x,e.y*=A*this.scale.y,e.z*=A*this.scale.z,i.add(e)}randomizeDirection(i,A){if(A===0)return;const e=Mh._randomQuat,t=Mh._tempVec;t.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),e.setFromAxisAngle(t,A*Math.random()*Math.PI),i.applyQuaternion(e)}spherizeDirection(i,A){if(A===0)return;const e=Math.random()*Math.PI*2,t=Math.acos(1-Math.random()*2),g=Math.sin(t)*Math.cos(e),I=Math.sin(t)*Math.sin(e),o=Math.cos(t),s=new w(g,I,o);i.lerp(s,A)}randomSpherePoint(i,A,e,t,g){const I=Math.random(),o=Math.random(),s=2*Math.PI*I*(t/360),n=Math.acos(2*o-1),C=ZA.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,a=i.x+this.scale.x*(-C*Math.sin(n)*Math.cos(s)),B=i.y+this.scale.y*(C*Math.sin(n)*Math.sin(s)),Q=i.z+this.scale.z*(C*Math.cos(n));g.x=a,g.y=B,g.z=Q}randomCirclePoint(i,A,e,t,g){const I=Math.random(),o=2*Math.PI*I*(t/360),s=ZA.lerp(1,1-Math.pow(1-Math.random(),Math.PI),e)*A,n=i.x+this.scale.x*s*Math.cos(o),C=i.y+this.scale.y*s*Math.sin(o),a=i.z;g.x=n,g.y=C,g.z=a}randomConePoint(i,A,e,t,g,I,o){let s=0,n=0;switch(I){case 0:s=Math.random(),n=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:s=.5,n=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let C=2*Math.PI*s*(g/360);switch(I){case 2:case 1:C+=Math.PI+.5,C+=this._loopTime*Math.PI*2,C%=ZA.toRadians(g);break}const a=Math.acos(2*n-1),B=ZA.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,Q=i.x+-B*Math.sin(a)*Math.cos(C),E=i.y+B*Math.sin(a)*Math.sin(C),c=i.z;o.x=Q*this.scale.x,o.y=E*this.scale.y,o.z=c*this.scale.z}},r(Qf,"_randomQuat",new GA),r(Qf,"_tempVec",new w),Qf);let qi=Mh;oA([D()],qi.prototype,"shapeType",2);oA([D()],qi.prototype,"enabled",2);oA([D()],qi.prototype,"alignToDirection",2);oA([D()],qi.prototype,"angle",2);oA([D()],qi.prototype,"arc",2);oA([D()],qi.prototype,"arcSpread",2);oA([D()],qi.prototype,"arcSpeedMultiplier",2);oA([D()],qi.prototype,"arcMode",2);oA([D(w)],qi.prototype,"boxThickness",2);oA([D(w)],qi.prototype,"position",2);oA([D(w)],qi.prototype,"rotation",2);oA([D(w)],qi.prototype,"scale",2);oA([D()],qi.prototype,"radius",2);oA([D()],qi.prototype,"radiusThickness",2);oA([D()],qi.prototype,"sphericalDirectionAmount",2);oA([D()],qi.prototype,"randomDirectionAmount",2);oA([D()],qi.prototype,"randomPositionAmount",2);class wt{constructor(){r(this,"damping");r(this,"enabled");r(this,"frequency");r(this,"octaveCount");r(this,"octaveMultiplier");r(this,"octaveScale");r(this,"positionAmount");r(this,"quality");r(this,"remap");r(this,"remapEnabled");r(this,"remapMultiplier");r(this,"remapX");r(this,"remapXMultiplier");r(this,"remapY");r(this,"remapYMultiplier");r(this,"remapZ");r(this,"remapZMultiplier");r(this,"scrollSpeedMultiplier");r(this,"separateAxes");r(this,"strengthMultiplier");r(this,"strengthX");r(this,"strengthXMultiplier");r(this,"strengthY");r(this,"strengthYMultiplier");r(this,"strengthZ");r(this,"strengthZMultiplier");r(this,"_noise");r(this,"_time",0);r(this,"_temp",new w)}update(A){this._time+=A.time.deltaTime*this.scrollSpeedMultiplier}apply(A,e,t,g,I,o){if(!this.enabled)return;this._noise||(this._noise=JIA(()=>0));const s=this._temp.set(e.x,e.y,e.z).multiplyScalar(this.frequency),n=this._noise(s.x,s.y,s.z,this._time),C=this._noise(s.x,s.y,s.z,this._time+1e3*this.frequency),a=this._noise(s.x,s.y,s.z,this._time+2e3*this.frequency);this._temp.set(n,C,a).normalize();const B=I/o;let Q=this.positionAmount.evaluate(B);this.separateAxes?(this._temp.x*=Q*this.strengthXMultiplier,this._temp.y*=Q*this.strengthYMultiplier,this._temp.z*=Q*this.strengthZMultiplier):(this.strengthX&&(Q*=this.strengthX.evaluate(B)*1.5),this._temp.multiplyScalar(Q)),t.x+=this._temp.x,t.y+=this._temp.y,t.z+=this._temp.z}}oA([D()],wt.prototype,"damping",2);oA([D()],wt.prototype,"enabled",2);oA([D()],wt.prototype,"frequency",2);oA([D()],wt.prototype,"octaveCount",2);oA([D()],wt.prototype,"octaveMultiplier",2);oA([D()],wt.prototype,"octaveScale",2);oA([D(Be)],wt.prototype,"positionAmount",2);oA([D()],wt.prototype,"quality",2);oA([D(Be)],wt.prototype,"remap",2);oA([D()],wt.prototype,"remapEnabled",2);oA([D()],wt.prototype,"remapMultiplier",2);oA([D(Be)],wt.prototype,"remapX",2);oA([D()],wt.prototype,"remapXMultiplier",2);oA([D(Be)],wt.prototype,"remapY",2);oA([D()],wt.prototype,"remapYMultiplier",2);oA([D(Be)],wt.prototype,"remapZ",2);oA([D()],wt.prototype,"remapZMultiplier",2);oA([D()],wt.prototype,"scrollSpeedMultiplier",2);oA([D()],wt.prototype,"separateAxes",2);oA([D()],wt.prototype,"strengthMultiplier",2);oA([D(Be)],wt.prototype,"strengthX",2);oA([D()],wt.prototype,"strengthXMultiplier",2);oA([D(Be)],wt.prototype,"strengthY",2);oA([D()],wt.prototype,"strengthYMultiplier",2);oA([D(Be)],wt.prototype,"strengthZ",2);oA([D()],wt.prototype,"strengthZMultiplier",2);class $t{constructor(){r(this,"enabled");r(this,"attachRibbonToTransform",!1);r(this,"colorOverLifetime");r(this,"colorOverTrail");r(this,"dieWithParticles",!0);r(this,"inheritParticleColor",!0);r(this,"lifetime");r(this,"lifetimeMultiplier");r(this,"minVertexDistance",.2);r(this,"mode",0);r(this,"ratio",1);r(this,"ribbonCount",1);r(this,"shadowBias",0);r(this,"sizeAffectsLifetime",!1);r(this,"sizeAffectsWidth",!1);r(this,"splitSubEmitterRibbons",!1);r(this,"textureMode",0);r(this,"widthOverTrail");r(this,"widthOverTrailMultiplier");r(this,"worldSpace",!1)}getWidth(A,e,t,g){const I=this.widthOverTrail.evaluate(t,g);return A*=I,A}getColor(A,e,t){const g=this.colorOverTrail.evaluate(t),I=this.colorOverLifetime.evaluate(e);A.x*=g.r*I.r,A.y*=g.g*I.g,A.z*=g.b*I.b,A.w*=g.alpha*I.alpha}}oA([D()],$t.prototype,"enabled",2);oA([D()],$t.prototype,"attachRibbonToTransform",2);oA([D(xI)],$t.prototype,"colorOverLifetime",2);oA([D(xI)],$t.prototype,"colorOverTrail",2);oA([D()],$t.prototype,"dieWithParticles",2);oA([D()],$t.prototype,"inheritParticleColor",2);oA([D(Be)],$t.prototype,"lifetime",2);oA([D()],$t.prototype,"lifetimeMultiplier",2);oA([D()],$t.prototype,"minVertexDistance",2);oA([D()],$t.prototype,"mode",2);oA([D()],$t.prototype,"ratio",2);oA([D()],$t.prototype,"ribbonCount",2);oA([D()],$t.prototype,"shadowBias",2);oA([D()],$t.prototype,"sizeAffectsLifetime",2);oA([D()],$t.prototype,"sizeAffectsWidth",2);oA([D()],$t.prototype,"splitSubEmitterRibbons",2);oA([D()],$t.prototype,"textureMode",2);oA([D(Be)],$t.prototype,"widthOverTrail",2);oA([D()],$t.prototype,"widthOverTrailMultiplier",2);oA([D()],$t.prototype,"worldSpace",2);class gi{constructor(){r(this,"enabled");r(this,"space",0);r(this,"orbitalX");r(this,"orbitalY");r(this,"orbitalZ");r(this,"orbitalXMultiplier");r(this,"orbitalYMultiplier");r(this,"orbitalZMultiplier");r(this,"orbitalOffsetX");r(this,"orbitalOffsetY");r(this,"orbitalOffsetZ");r(this,"speedModifier");r(this,"speedModifierMultiplier");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier");r(this,"_system");r(this,"_temp",new w);r(this,"_temp2",new w);r(this,"_temp3",new w);r(this,"_hasOrbital",!1);r(this,"_index",0);r(this,"_orbitalMatrix",new FA)}update(A){this._system=A}init(A){this._index==0&&(A.debug=!0),this._index+=1,A.orbitx=this.orbitalX.evaluate(Math.random()),A.orbity=this.orbitalY.evaluate(Math.random()),A.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=A.orbitx!=0||A.orbity!=0||A.orbitz!=0}apply(A,e,t,g,I,o,s){var E;if(!this.enabled)return;const n=o/s,C=this.speedModifier.evaluate(n)*this.speedModifierMultiplier,a=this.x.evaluate(n),B=this.y.evaluate(n),Q=this.z.evaluate(n);if(this._temp.set(-a,B,Q),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((E=this._system)==null?void 0:E.worldPos)){const l=this._temp2.set(t.x,t.y,t.z),d=this.orbitalXMultiplier,h=this.orbitalYMultiplier,p=this.orbitalZMultiplier,u=C*Math.PI*2*10,f=Math.cos(u*d),k=Math.sin(u*d),m=Math.cos(u*h),G=Math.sin(u*h),R=Math.cos(u*p),S=Math.sin(u*p),M=l.x*(m*R)+l.y*(m*S)+l.z*-G,K=l.x*(k*G*R-f*S)+l.y*(k*G*S+f*R)+l.z*(k*m),P=l.x*(f*G*R+k*S)+l.y*(f*G*S-k*R)+l.z*(f*m),b=this._temp3.set(l.x-M,l.y-K,l.z-P);b.normalize(),b.multiplyScalar(.2/I*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),g.x+=b.x,g.y+=b.y,g.z+=b.z}g.x+=this._temp.x,g.y+=this._temp.y,g.z+=this._temp.z,g.x*=C,g.y*=C,g.z*=C}}oA([D()],gi.prototype,"enabled",2);oA([D()],gi.prototype,"space",2);oA([D(Be)],gi.prototype,"orbitalX",2);oA([D(Be)],gi.prototype,"orbitalY",2);oA([D(Be)],gi.prototype,"orbitalZ",2);oA([D()],gi.prototype,"orbitalXMultiplier",2);oA([D()],gi.prototype,"orbitalYMultiplier",2);oA([D()],gi.prototype,"orbitalZMultiplier",2);oA([D()],gi.prototype,"orbitalOffsetX",2);oA([D()],gi.prototype,"orbitalOffsetY",2);oA([D()],gi.prototype,"orbitalOffsetZ",2);oA([D(Be)],gi.prototype,"speedModifier",2);oA([D()],gi.prototype,"speedModifierMultiplier",2);oA([D(Be)],gi.prototype,"x",2);oA([D()],gi.prototype,"xMultiplier",2);oA([D(Be)],gi.prototype,"y",2);oA([D()],gi.prototype,"yMultiplier",2);oA([D(Be)],gi.prototype,"z",2);oA([D()],gi.prototype,"zMultiplier",2);class Lg{constructor(){r(this,"animation");r(this,"enabled");r(this,"cycleCount");r(this,"frameOverTime");r(this,"frameOverTimeMultiplier");r(this,"numTilesX");r(this,"numTilesY");r(this,"startFrame");r(this,"startFrameMultiplier");r(this,"rowMode");r(this,"rowIndex");r(this,"spriteCount");r(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(A){if(!this.sampleOnceAtStart())return this.getIndex(A)}getIndex(A){const e=this.numTilesX*this.numTilesY;A=A*this.cycleCount;let t=this.frameOverTime.evaluate(A%1);return t*=this.frameOverTimeMultiplier,t*=e,t=t%e,t=Math.floor(t),t}}oA([D()],Lg.prototype,"animation",2);oA([D()],Lg.prototype,"enabled",2);oA([D()],Lg.prototype,"cycleCount",2);oA([D(Be)],Lg.prototype,"frameOverTime",2);oA([D()],Lg.prototype,"frameOverTimeMultiplier",2);oA([D()],Lg.prototype,"numTilesX",2);oA([D()],Lg.prototype,"numTilesY",2);oA([D(Be)],Lg.prototype,"startFrame",2);oA([D()],Lg.prototype,"startFrameMultiplier",2);oA([D()],Lg.prototype,"rowMode",2);oA([D()],Lg.prototype,"rowIndex",2);oA([D()],Lg.prototype,"spriteCount",2);oA([D()],Lg.prototype,"timeMode",2);class gs{constructor(){r(this,"enabled");r(this,"separateAxes");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier")}evaluate(A,e){return this.enabled?this.separateAxes?0:this.z.evaluate(A,e)*-1:0}}oA([D()],gs.prototype,"enabled",2);oA([D()],gs.prototype,"separateAxes",2);oA([D(Be)],gs.prototype,"x",2);oA([D()],gs.prototype,"xMultiplier",2);oA([D(Be)],gs.prototype,"y",2);oA([D()],gs.prototype,"yMultiplier",2);oA([D(Be)],gs.prototype,"z",2);oA([D()],gs.prototype,"zMultiplier",2);class po{constructor(){r(this,"enabled");r(this,"range");r(this,"separateAxes");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier")}evaluate(A,e){if(!this.enabled)return 0;if(!this.separateAxes){const t=ZA.lerp(this.range.x,this.range.y,e);return this.z.evaluate(t)*-1}return 0}}oA([D()],po.prototype,"enabled",2);oA([D()],po.prototype,"range",2);oA([D()],po.prototype,"separateAxes",2);oA([D(Be)],po.prototype,"x",2);oA([D()],po.prototype,"xMultiplier",2);oA([D(Be)],po.prototype,"y",2);oA([D()],po.prototype,"yMultiplier",2);oA([D(Be)],po.prototype,"z",2);oA([D()],po.prototype,"zMultiplier",2);class Vi{constructor(){r(this,"enabled");r(this,"dampen");r(this,"drag");r(this,"dragMultiplier");r(this,"limit");r(this,"limitMultiplier");r(this,"separateAxes");r(this,"limitX");r(this,"limitXMultiplier");r(this,"limitY");r(this,"limitYMultiplier");r(this,"limitZ");r(this,"limitZMultiplier");r(this,"multiplyDragByParticleSize",!1);r(this,"multiplyDragByParticleVelocity",!1);r(this,"space");r(this,"_temp",new w);r(this,"_temp2",new w)}apply(A,e,t,g,I,o,s){if(this.enabled){const n=this.limit.evaluate(I)*this.limitMultiplier;if(e.length()>n){this._temp.copy(e).normalize().multiplyScalar(n);const a=this.dampen*.5;e.x=ZA.lerp(e.x,this._temp.x,a),e.y=ZA.lerp(e.y,this._temp.y,a),e.z=ZA.lerp(e.z,this._temp.z,a),t.x=ZA.lerp(t.x,this._temp.x,a),t.y=ZA.lerp(t.y,this._temp.y,a),t.z=ZA.lerp(t.z,this._temp.z,a)}}}}oA([D()],Vi.prototype,"enabled",2);oA([D()],Vi.prototype,"dampen",2);oA([D(Be)],Vi.prototype,"drag",2);oA([D()],Vi.prototype,"dragMultiplier",2);oA([D(Be)],Vi.prototype,"limit",2);oA([D()],Vi.prototype,"limitMultiplier",2);oA([D()],Vi.prototype,"separateAxes",2);oA([D(Be)],Vi.prototype,"limitX",2);oA([D()],Vi.prototype,"limitXMultiplier",2);oA([D(Be)],Vi.prototype,"limitY",2);oA([D()],Vi.prototype,"limitYMultiplier",2);oA([D(Be)],Vi.prototype,"limitZ",2);oA([D()],Vi.prototype,"limitZMultiplier",2);oA([D()],Vi.prototype,"multiplyDragByParticleSize",2);oA([D()],Vi.prototype,"multiplyDragByParticleVelocity",2);oA([D()],Vi.prototype,"space",2);class Ir{constructor(){r(this,"enabled");r(this,"curve");r(this,"curveMultiplier");r(this,"mode");r(this,"system");r(this,"_lastWorldPosition");r(this,"_velocity",new w);r(this,"_temp",new w)}update(A){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(A){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const e=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(e),A.add(this._temp)}}applyCurrent(A,e,t){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const g=this.curve.evaluate(e,t);this._temp.copy(this._velocity).multiplyScalar(g),A.add(this._temp)}}}oA([D()],Ir.prototype,"enabled",2);oA([D(Be)],Ir.prototype,"curve",2);oA([D()],Ir.prototype,"curveMultiplier",2);oA([D()],Ir.prototype,"mode",2);class yI{constructor(){r(this,"enabled");r(this,"range");r(this,"separateAxes");r(this,"size");r(this,"sizeMultiplier");r(this,"x");r(this,"xMultiplier");r(this,"y");r(this,"yMultiplier");r(this,"z");r(this,"zMultiplier")}evaluate(A,e,t,g){const I=A.length(),o=ZA.remap(I,this.range.x,this.range.y,0,1),s=this.size.evaluate(o,t);return g*s}}oA([D()],yI.prototype,"enabled",2);oA([D(tA)],yI.prototype,"range",2);oA([D()],yI.prototype,"separateAxes",2);oA([D(Be)],yI.prototype,"size",2);oA([D()],yI.prototype,"sizeMultiplier",2);oA([D(Be)],yI.prototype,"x",2);oA([D()],yI.prototype,"xMultiplier",2);oA([D(Be)],yI.prototype,"y",2);oA([D()],yI.prototype,"yMultiplier",2);oA([D(Be)],yI.prototype,"z",2);oA([D()],yI.prototype,"zMultiplier",2);class MB{constructor(){r(this,"enabled");r(this,"range");r(this,"color")}evaluate(A,e,t){const g=A.length(),I=ZA.remap(g,this.range.x,this.range.y,0,1),o=this.color.evaluate(I,e);t.x*=o.r,t.y*=o.g,t.z*=o.b,t.w*=o.alpha}}oA([D()],MB.prototype,"enabled",2);oA([D(tA)],MB.prototype,"range",2);oA([D(xI)],MB.prototype,"color",2);const LIA={name:"HorizontalBlurShader",uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
5192
5192
 
@@ -6663,8 +6663,8 @@ Please refer to the documentation on <a href="https://fwd.needle.tools/needle-en
6663
6663
  display: block;
6664
6664
  width: max(600px, 100%);
6665
6665
  height: max(300px, 100%);
6666
- font-family: 'Roboto', sans-serif;
6667
6666
  }
6667
+
6668
6668
  @media (max-width: 600px) {
6669
6669
  :host {
6670
6670
  width: 100%;