@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);}`,XL=class extends Zo{constructor({blendFu
4252
4252
  *
4253
4253
  * @author Feross Aboukhadijeh <https://feross.org>
4254
4254
  * @license MIT
4255
- */var jY=function(i){return i!=null&&(iU(i)||GY(i)||!!i._isBuffer)};function iU(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function GY(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&iU(i.slice(0,0))}(function(){var i=zY,e=tU.utf8,t=jY,s=tU.bin,r=function(n,o){n.constructor==String?o&&o.encoding==="binary"?n=s.stringToBytes(n):n=e.stringToBytes(n):t(n)?n=Array.prototype.slice.call(n,0):!Array.isArray(n)&&n.constructor!==Uint8Array&&(n=n.toString());for(var a=i.bytesToWords(n),l=n.length*8,c=1732584193,u=-271733879,d=-1732584194,p=271733878,f=0;f<a.length;f++)a[f]=(a[f]<<8|a[f]>>>24)&16711935|(a[f]<<24|a[f]>>>8)&4278255360;a[l>>>5]|=128<<l%32,a[(l+64>>>9<<4)+14]=l;for(var m=r._ff,A=r._gg,v=r._hh,g=r._ii,f=0;f<a.length;f+=16){var b=c,y=u,_=d,S=p;c=m(c,u,d,p,a[f+0],7,-680876936),p=m(p,c,u,d,a[f+1],12,-389564586),d=m(d,p,c,u,a[f+2],17,606105819),u=m(u,d,p,c,a[f+3],22,-1044525330),c=m(c,u,d,p,a[f+4],7,-176418897),p=m(p,c,u,d,a[f+5],12,1200080426),d=m(d,p,c,u,a[f+6],17,-1473231341),u=m(u,d,p,c,a[f+7],22,-45705983),c=m(c,u,d,p,a[f+8],7,1770035416),p=m(p,c,u,d,a[f+9],12,-1958414417),d=m(d,p,c,u,a[f+10],17,-42063),u=m(u,d,p,c,a[f+11],22,-1990404162),c=m(c,u,d,p,a[f+12],7,1804603682),p=m(p,c,u,d,a[f+13],12,-40341101),d=m(d,p,c,u,a[f+14],17,-1502002290),u=m(u,d,p,c,a[f+15],22,1236535329),c=A(c,u,d,p,a[f+1],5,-165796510),p=A(p,c,u,d,a[f+6],9,-1069501632),d=A(d,p,c,u,a[f+11],14,643717713),u=A(u,d,p,c,a[f+0],20,-373897302),c=A(c,u,d,p,a[f+5],5,-701558691),p=A(p,c,u,d,a[f+10],9,38016083),d=A(d,p,c,u,a[f+15],14,-660478335),u=A(u,d,p,c,a[f+4],20,-405537848),c=A(c,u,d,p,a[f+9],5,568446438),p=A(p,c,u,d,a[f+14],9,-1019803690),d=A(d,p,c,u,a[f+3],14,-187363961),u=A(u,d,p,c,a[f+8],20,1163531501),c=A(c,u,d,p,a[f+13],5,-1444681467),p=A(p,c,u,d,a[f+2],9,-51403784),d=A(d,p,c,u,a[f+7],14,1735328473),u=A(u,d,p,c,a[f+12],20,-1926607734),c=v(c,u,d,p,a[f+5],4,-378558),p=v(p,c,u,d,a[f+8],11,-2022574463),d=v(d,p,c,u,a[f+11],16,1839030562),u=v(u,d,p,c,a[f+14],23,-35309556),c=v(c,u,d,p,a[f+1],4,-1530992060),p=v(p,c,u,d,a[f+4],11,1272893353),d=v(d,p,c,u,a[f+7],16,-155497632),u=v(u,d,p,c,a[f+10],23,-1094730640),c=v(c,u,d,p,a[f+13],4,681279174),p=v(p,c,u,d,a[f+0],11,-358537222),d=v(d,p,c,u,a[f+3],16,-722521979),u=v(u,d,p,c,a[f+6],23,76029189),c=v(c,u,d,p,a[f+9],4,-640364487),p=v(p,c,u,d,a[f+12],11,-421815835),d=v(d,p,c,u,a[f+15],16,530742520),u=v(u,d,p,c,a[f+2],23,-995338651),c=g(c,u,d,p,a[f+0],6,-198630844),p=g(p,c,u,d,a[f+7],10,1126891415),d=g(d,p,c,u,a[f+14],15,-1416354905),u=g(u,d,p,c,a[f+5],21,-57434055),c=g(c,u,d,p,a[f+12],6,1700485571),p=g(p,c,u,d,a[f+3],10,-1894986606),d=g(d,p,c,u,a[f+10],15,-1051523),u=g(u,d,p,c,a[f+1],21,-2054922799),c=g(c,u,d,p,a[f+8],6,1873313359),p=g(p,c,u,d,a[f+15],10,-30611744),d=g(d,p,c,u,a[f+6],15,-1560198380),u=g(u,d,p,c,a[f+13],21,1309151649),c=g(c,u,d,p,a[f+4],6,-145523070),p=g(p,c,u,d,a[f+11],10,-1120210379),d=g(d,p,c,u,a[f+2],15,718787259),u=g(u,d,p,c,a[f+9],21,-343485551),c=c+b>>>0,u=u+y>>>0,d=d+_>>>0,p=p+S>>>0}return i.endian([c,u,d,p])};r._ff=function(n,o,a,l,c,u,d){var p=n+(o&a|~o&l)+(c>>>0)+d;return(p<<u|p>>>32-u)+o},r._gg=function(n,o,a,l,c,u,d){var p=n+(o&l|a&~l)+(c>>>0)+d;return(p<<u|p>>>32-u)+o},r._hh=function(n,o,a,l,c,u,d){var p=n+(o^a^l)+(c>>>0)+d;return(p<<u|p>>>32-u)+o},r._ii=function(n,o,a,l,c,u,d){var p=n+(a^(o|~l))+(c>>>0)+d;return(p<<u|p>>>32-u)+o},r._blocksize=16,r._digestsize=16,$L.exports=function(n,o){if(n==null)throw new Error("Illegal argument "+n);var a=i.wordsToBytes(r(n,o));return o&&o.asBytes?a:o&&o.asString?s.bytesToString(a):i.bytesToHex(a)}})();var QY=$L.exports;const HY=km(QY);class cE{constructor(e,t,s,r){h(this,"success"),h(this,"filename"),h(this,"hash"),h(this,"size"),h(this,"url"),this.success=e,this.filename=t,this.hash=s,this.size=r}}async function sU(i,e){const t=await i.arrayBuffer(),s=hE(t),r=i.name.split(".").pop(),n=s+"."+r,o=i.name.split(".").shift();console.assert(o!==void 0);const a={alias:o,filename:n},l=await(await fetch(e+"/exists",{method:"POST",body:JSON.stringify(a)})).json();if(l.success||console.warn("exists check did fail"),l.exists)return console.log("file already exists",s),new cE(!0,n,s,i.size);console.log("begin uploading file",o,i.size);const c=new FormData;c.append("file",i);const u={};u.filesize=i.size,o&&(u.alias=o);const d=await(await fetch(e+"/upload/file",{method:"POST",body:c,headers:u})).json();if(d?.success===!1)return d.message!==void 0?console.error("Upload failed:",d.message):console.error("Upload failed"),null;console.assert(d.hash_sum===s,"hash sum did not match","received:",d.hash_sum,"expected:",s),d.success&&console.log("successfully uploaded",s,d.id);const p=new cE(d.success,n,s,i.size);return p.url=e,p}function hE(i){return HY(new Uint8Array(i))}async function uE(i,e,t,s,r=!1){try{const n=await fetch(s+"/download/file",{method:"POST",body:i});if(n.status!==200)return console.error("download failed",n),null;const o=await n.blob(),a=await o.arrayBuffer();r||console.assert(o.size===t,"size mismatch","expected:",t,"got:",o.size);const l=hE(a);return r||console.assert(l===e,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(n){console.error(n)}return null}async function rU(i,e){var t;const s=await fetch(i),r=(t=s.body)==null?void 0:t.getReader(),n=s.headers.get("Content-Length"),o=n?parseInt(n):0;if(!r)return null;let a=0;const l=[];for(;;){const{done:d,value:p}=await r.read();if(p&&(l.push(p),a+=p.length,e.call(null,new ProgressEvent("progress",{loaded:a,total:o}))),d)break}const c=new Uint8Array(a);let u=0;for(const d of l)c.set(d,u),u+=d.length;return c}let nU,oU=null;function $o(){return nU}function dE(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}oU!==i&&(oU=i,nU=new i)}const Qc=oe("debugaddressables");class aU{constructor(e){h(this,"_context"),h(this,"_assetReferences",{}),this._context=e,this._context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){}findAssetReference(e){return this._assetReferences[e]||null}registerAssetReference(e){return e.uri&&(this._assetReferences[e.uri]?console.warn("Asset reference already registered",e):this._assetReferences[e.uri]=e),e}dispose(){for(const e in this._assetReferences){const t=this._assetReferences[e];t?.unload()}this._assetReferences={}}unregisterAssetReference(e){e.uri&&delete this._assetReferences[e.uri]}}const pE=Symbol("assetReference"),dg=class{constructor(i,e,t=null){h(this,"_loading"),h(this,"_asset"),h(this,"_glbRoot"),h(this,"_url"),h(this,"_progressListeners",[]),h(this,"_hash"),h(this,"_hashedUri"),h(this,"_isLoadingRawBinary",!1),h(this,"_rawBinary"),this._url=i,this._hash=e,i.includes("?v=")?this._hashedUri=i:this._hashedUri=e?i+"?v="+e:i,t!==null&&(this.asset=t),PO(this._url,this.onResolvePrefab.bind(this))}static getOrCreate(i,e,t){if(typeof i=="string"){if(!t&&(t=Ot.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=i.context,i=i.sourceId;const s=yl(i,e);Qc&&console.log("GetOrCreate Addressable from",i,e,"FinalPath=",s);const r=t.addressables,n=r.findAssetReference(s);if(n)return n;const o=new dg(s,t.hash);return r.registerAssetReference(o),o}get asset(){return this._glbRoot??this._asset}set asset(i){this._asset=i}get uri(){return this._url}get rawAsset(){return this._asset}async onResolvePrefab(i){return i===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||J0(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(Qc&&console.log("Unload",this.asset),this.asset.scene&&Ia(this.asset.scene,!0,!0),Ia(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,Ot.Current&&Ot.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,Qc&&console.log("Preload",this._hashedUri);const i=await rU(this._hashedUri,e=>{this.raiseProgressEvent(e)});return this._rawBinary=i?.buffer??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(i){if(Qc&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(i&&this._progressListeners.push(i),this._loading!==void 0)return this._loading;const e=Ot.Current;this._rawBinary?(this._loading=$o().parseSync(e,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(Qc&&console.log("Load async",this.uri),this._loading=$o().loadSync(e,this._hashedUri,this.uri,null,s=>{this.raiseProgressEvent(s)}));const t=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(t),this._loading=void 0,t)return t[pE]=this,this._glbRoot&&(this._glbRoot[pE]=this),this.asset&&(this.asset[pE]=this),Z0(e),t.scene!==void 0&&(this.asset=t),this.asset}async instantiate(i){return this.onInstantiate(i,!1)}async instantiateSynced(i,e=!0){return this.onInstantiate(i,!0,e)}beginListenDownload(i){this._progressListeners.indexOf(i)<0&&this._progressListeners.push(i)}endListenDownload(i){const e=this._progressListeners.indexOf(i);e>=0&&this._progressListeners.splice(e,1)}raiseProgressEvent(i){for(const e of this._progressListeners)e(this,i)}async onInstantiate(i,e=!1,t){const s=Ot.Current;if(this.mustLoad&&await this.loadAssetAsync(),Qc&&console.log("Instantiate",this.uri,"parent:",i),this.asset){Qc&&console.log("Add to scene",this.asset);let r=i instanceof Ta?i:null;r||(r=new Ta),typeof i=="object"&&(i instanceof _e?r.parent=i:Object.assign(r,i)),r.parent||(r.parent=s.scene);let n=dg.currentlyInstantiating.get(this.uri);if(n!==void 0&&n>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+n+")"),null;try{if(n===void 0&&(n=0),n+=1,dg.currentlyInstantiating.set(this.uri,n),e){r.context=s;const o=this.asset;o.guid=this.uri;const a=TC(o,r,void 0,t);if(a)return a}else{const o=ag(this.asset,r);if(o)return o}}finally{s.post_render_callbacks.push(()=>{n===void 0||n<0?n=0:n-=1,dg.currentlyInstantiating.set(this.uri,n)})}}else Qc&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(i){if(i&&i.scene){const e=i.scene;return e.isGroup&&e.children.length===1&&e.children[0].name+"glb"===e.name?e.children[0]:e}return null}};let Fs=dg;h(Fs,"currentlyInstantiating",new Map);class VY extends Rl{constructor(){super([Fs])}onSerialize(e,t){if(e&&e.uri!==void 0&&typeof e.uri=="string")return e.uri}onDeserialize(e,t){if(typeof e=="string")return t.context?t.gltfId?Fs.getOrCreate(t.gltfId,e,t.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(e instanceof _e){if(!t.context)return console.error("Missing context"),null;if(!t.gltfId)return console.error("Missing source id"),null;const s=e,r=t.context,n=s.guid??s.uuid,o=r.addressables.findAssetReference(n);if(o)return o;const a=new Fs(n,void 0,s);return r.addressables.registerAssetReference(a),a}return null}}new VY;const WY=Promise.resolve(null),ab=class{constructor(i){h(this,"url"),h(this,"_bitmap"),h(this,"_bitmapObject"),h(this,"loader",null),this.url=i}static getOrCreate(i){let e=ab.imageReferences.get(i);return e||(e=new ab(i),ab.imageReferences.set(i,e)),e}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const i=new Image;return i.src=this.url,i}createTexture(){return this.url?(this.loader||(this.loader=new Al),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):WY}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((i,e)=>{const t=document.createElement("img");t.addEventListener("load",()=>{this._bitmap=createImageBitmap(t).then(s=>(this._bitmapObject=s,i(s),s))}),t.addEventListener("error",s=>{console.error("Failed to load image:"+this.url,s),i(null)}),t.src=this.url}),this._bitmap)}};let lb=ab;h(lb,"imageReferences",new Map);class lU extends Rl{constructor(){super([lb])}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"){const s=yl(t.gltfId,e);return lb.getOrCreate(s)}}}new lU;const go=oe("debugenvlight");var cp=(i=>(i[i.Skybox=0]="Skybox",i[i.Trilight=1]="Trilight",i[i.Flat=3]="Flat",i[i.Custom=4]="Custom",i))(cp||{}),cb=(i=>(i[i.Skybox=0]="Skybox",i[i.Custom=1]="Custom",i))(cb||{});class cU{constructor(e){h(this,"context"),h(this,"_currentLightSettingsId"),h(this,"_sceneLightSettings"),h(this,"_timevec4",new it),h(this,"__currentReflectionId",null),h(this,"_waitPromise"),h(this,"_lighting",{}),this.context=e,this.context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){const e=this.context.time;this._timevec4.x=e.time,this._timevec4.y=Math.sin(e.time),this._timevec4.z=Math.cos(e.time),this._timevec4.w=e.deltaTime}get timeVec4(){return this._timevec4}get environmentIntensity(){if(!this._sceneLightSettings||!this._currentLightSettingsId)return 1;const e=this._sceneLightSettings.get(this._currentLightSettingsId);return e?e.ambientIntensity:1}get sceneLightSettings(){var e;return(e=this._sceneLightSettings)==null?void 0:e.values()}enable(e){var t;e instanceof Fs&&(e=e.uri);const s=(t=this._sceneLightSettings)==null?void 0:t.get(e);return s?(go&&console.log("Enable scene light settings",e,s),e!==this._currentLightSettingsId&&this._currentLightSettingsId&&this.disable(this._currentLightSettingsId),this._currentLightSettingsId=e,s.enabled=!0,!0):!1}disable(e){var t;if(e instanceof Fs&&(e=e.uri),e==null)return!1;const s=(t=this._sceneLightSettings)==null?void 0:t.get(e);return s?(go&&console.log("Disable scene light settings",e,s),s.enabled=!1,!0):!1}disableCurrent(){if(this._currentLightSettingsId){const e=this._currentLightSettingsId;return this.disable(this._currentLightSettingsId),e}return null}internalRegisterSceneLightSettings(e){const t=e.sourceId;if(!t){console.error("Missing source id for scene light settings, can not register:",e);return}go&&console.log("Register "+e?.sourceId+" lighting",e),this._sceneLightSettings||(this._sceneLightSettings=new Map),this._sceneLightSettings.set(t,e)}internalUnregisterSceneLightSettings(e){const t=e.sourceId;if(!t){console.error("Missing source id for scene light settings, can not unregister:",e);return}go&&console.log("Unregister "+e?.sourceId+" lighting",e),this._sceneLightSettings&&this._sceneLightSettings.delete(t)}internalRegisterReflection(e,t){go&&console.log("Register reflection",e,t);const s=new hU(this.context,t,1);this._lighting[e]=s}internalGetReflection(e){return this._lighting[e]}internalEnableReflection(e){var t;this.__currentReflectionId=e;const s=(t=this._sceneLightSettings)==null?void 0:t.get(e);switch(go&&console.log("Enable reflection",e,s?cp[s.ambientMode]:"Unknown ambient mode"),s?.ambientMode){case 0:case 4:const r=this.internalGetReflection(e);if(r&&r.Source){go&&console.log("Setting environment reflection",r);const n=this.context.scene,o=r.Source;o.colorSpace=st,o.mapping=ro,n.environment=o;return}else go&&console.warn("Could not find reflection for source",e);break}if(s?.environmentReflectionSource===1)switch(s?.ambientMode){case 1:if(s.ambientTrilight){const r=s.ambientTrilight,n=LY(r[0],r[1],r[2],64,64);n.colorSpace=st,n.mapping=ro,this.context.scene.environment=n}else console.error("Missing ambient trilight",s.sourceId);return;case 3:if(s.ambientLight){const r=YL(s.ambientLight,64);r.colorSpace=st,r.mapping=ro,this.context.scene.environment=r}else console.error("Missing ambientlight",s.sourceId);return;default:return}}internalDisableReflection(e){if(e&&e!==this.__currentReflectionId){go&&console.log("Not disabling reflection for",e,"because it is not the current light settings id",this.__currentReflectionId);return}go&&console.log("Disable reflection",e);const t=this.context.scene;t.environment=null}async internalGetSceneLightingData(e){return go&&console.log("GET SCENE LIGHT DATA",e),this._waitPromise?this._waitPromise:(this._waitPromise=new Promise((t,s)=>{const r=setInterval(async()=>{const n=this.internalGetReflection(e);n&&(clearInterval(r),t(n.getSphericalHarmonicsArray(this.environmentIntensity??1)))},10)}),this._waitPromise)}}class hU{constructor(e,t,s=1){h(this,"_context"),h(this,"_source"),h(this,"_sphericalHarmonics",null),h(this,"_sphericalHarmonicsArray"),h(this,"_ambientScale",1),h(this,"_lightProbe"),this._context=e,this._source=t,this._ambientScale=s,t.mapping=ro,t.colorSpace=st}get Source(){return this._source}get Array(){return this._sphericalHarmonicsArray}getSphericalHarmonicsArray(e=1){var t;if((t=this._sphericalHarmonicsArray)!=null&&t.length&&this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:this._lightProbe};try{const s=this._source;let r=null;if(s){go&&console.log("GENERATING LIGHT PROBE",s,this.Source);const n=Math.min(s.image.width,512);r=new uy(n).fromEquirectangularTexture(this._context.renderer,s)}if(this._sphericalHarmonicsArray=[],r){const n=kY.fromCubeRenderTarget(this._context.renderer,r);this._lightProbe=n;const o=this._ambientScale*(e*e*Math.PI*.5)-1;if(this._sphericalHarmonics=n.sh,this._sphericalHarmonicsArray=this._sphericalHarmonics.toArray(),this._sphericalHarmonicsArray){const a=e/(Math.PI*.5);for(let l=0;l<this._sphericalHarmonicsArray.length;l++)this._sphericalHarmonicsArray[l]*=a;if(n.sh.scale(o),this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:n}}}}catch(s){console.error(s)}return null}}var hb=(i=>(i.Visible="application-visible",i.Hidden="application-hidden",i.MuteChanged="application-mutechanged",i))(hb||{});class uU extends EventTarget{constructor(e){super(),h(this,"_mute",!1),h(this,"context"),h(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 jY=function(i){return i!=null&&(iU(i)||GY(i)||!!i._isBuffer)};function iU(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function GY(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&iU(i.slice(0,0))}(function(){var i=zY,e=tU.utf8,t=jY,s=tU.bin,r=function(n,o){n.constructor==String?o&&o.encoding==="binary"?n=s.stringToBytes(n):n=e.stringToBytes(n):t(n)?n=Array.prototype.slice.call(n,0):!Array.isArray(n)&&n.constructor!==Uint8Array&&(n=n.toString());for(var a=i.bytesToWords(n),l=n.length*8,c=1732584193,u=-271733879,d=-1732584194,p=271733878,f=0;f<a.length;f++)a[f]=(a[f]<<8|a[f]>>>24)&16711935|(a[f]<<24|a[f]>>>8)&4278255360;a[l>>>5]|=128<<l%32,a[(l+64>>>9<<4)+14]=l;for(var m=r._ff,A=r._gg,v=r._hh,g=r._ii,f=0;f<a.length;f+=16){var b=c,y=u,_=d,S=p;c=m(c,u,d,p,a[f+0],7,-680876936),p=m(p,c,u,d,a[f+1],12,-389564586),d=m(d,p,c,u,a[f+2],17,606105819),u=m(u,d,p,c,a[f+3],22,-1044525330),c=m(c,u,d,p,a[f+4],7,-176418897),p=m(p,c,u,d,a[f+5],12,1200080426),d=m(d,p,c,u,a[f+6],17,-1473231341),u=m(u,d,p,c,a[f+7],22,-45705983),c=m(c,u,d,p,a[f+8],7,1770035416),p=m(p,c,u,d,a[f+9],12,-1958414417),d=m(d,p,c,u,a[f+10],17,-42063),u=m(u,d,p,c,a[f+11],22,-1990404162),c=m(c,u,d,p,a[f+12],7,1804603682),p=m(p,c,u,d,a[f+13],12,-40341101),d=m(d,p,c,u,a[f+14],17,-1502002290),u=m(u,d,p,c,a[f+15],22,1236535329),c=A(c,u,d,p,a[f+1],5,-165796510),p=A(p,c,u,d,a[f+6],9,-1069501632),d=A(d,p,c,u,a[f+11],14,643717713),u=A(u,d,p,c,a[f+0],20,-373897302),c=A(c,u,d,p,a[f+5],5,-701558691),p=A(p,c,u,d,a[f+10],9,38016083),d=A(d,p,c,u,a[f+15],14,-660478335),u=A(u,d,p,c,a[f+4],20,-405537848),c=A(c,u,d,p,a[f+9],5,568446438),p=A(p,c,u,d,a[f+14],9,-1019803690),d=A(d,p,c,u,a[f+3],14,-187363961),u=A(u,d,p,c,a[f+8],20,1163531501),c=A(c,u,d,p,a[f+13],5,-1444681467),p=A(p,c,u,d,a[f+2],9,-51403784),d=A(d,p,c,u,a[f+7],14,1735328473),u=A(u,d,p,c,a[f+12],20,-1926607734),c=v(c,u,d,p,a[f+5],4,-378558),p=v(p,c,u,d,a[f+8],11,-2022574463),d=v(d,p,c,u,a[f+11],16,1839030562),u=v(u,d,p,c,a[f+14],23,-35309556),c=v(c,u,d,p,a[f+1],4,-1530992060),p=v(p,c,u,d,a[f+4],11,1272893353),d=v(d,p,c,u,a[f+7],16,-155497632),u=v(u,d,p,c,a[f+10],23,-1094730640),c=v(c,u,d,p,a[f+13],4,681279174),p=v(p,c,u,d,a[f+0],11,-358537222),d=v(d,p,c,u,a[f+3],16,-722521979),u=v(u,d,p,c,a[f+6],23,76029189),c=v(c,u,d,p,a[f+9],4,-640364487),p=v(p,c,u,d,a[f+12],11,-421815835),d=v(d,p,c,u,a[f+15],16,530742520),u=v(u,d,p,c,a[f+2],23,-995338651),c=g(c,u,d,p,a[f+0],6,-198630844),p=g(p,c,u,d,a[f+7],10,1126891415),d=g(d,p,c,u,a[f+14],15,-1416354905),u=g(u,d,p,c,a[f+5],21,-57434055),c=g(c,u,d,p,a[f+12],6,1700485571),p=g(p,c,u,d,a[f+3],10,-1894986606),d=g(d,p,c,u,a[f+10],15,-1051523),u=g(u,d,p,c,a[f+1],21,-2054922799),c=g(c,u,d,p,a[f+8],6,1873313359),p=g(p,c,u,d,a[f+15],10,-30611744),d=g(d,p,c,u,a[f+6],15,-1560198380),u=g(u,d,p,c,a[f+13],21,1309151649),c=g(c,u,d,p,a[f+4],6,-145523070),p=g(p,c,u,d,a[f+11],10,-1120210379),d=g(d,p,c,u,a[f+2],15,718787259),u=g(u,d,p,c,a[f+9],21,-343485551),c=c+b>>>0,u=u+y>>>0,d=d+_>>>0,p=p+S>>>0}return i.endian([c,u,d,p])};r._ff=function(n,o,a,l,c,u,d){var p=n+(o&a|~o&l)+(c>>>0)+d;return(p<<u|p>>>32-u)+o},r._gg=function(n,o,a,l,c,u,d){var p=n+(o&l|a&~l)+(c>>>0)+d;return(p<<u|p>>>32-u)+o},r._hh=function(n,o,a,l,c,u,d){var p=n+(o^a^l)+(c>>>0)+d;return(p<<u|p>>>32-u)+o},r._ii=function(n,o,a,l,c,u,d){var p=n+(a^(o|~l))+(c>>>0)+d;return(p<<u|p>>>32-u)+o},r._blocksize=16,r._digestsize=16,$L.exports=function(n,o){if(n==null)throw new Error("Illegal argument "+n);var a=i.wordsToBytes(r(n,o));return o&&o.asBytes?a:o&&o.asString?s.bytesToString(a):i.bytesToHex(a)}})();var QY=$L.exports;const HY=km(QY);class cE{constructor(e,t,s,r){h(this,"success"),h(this,"filename"),h(this,"hash"),h(this,"size"),h(this,"url"),this.success=e,this.filename=t,this.hash=s,this.size=r}}async function sU(i,e){const t=await i.arrayBuffer(),s=hE(t),r=i.name.split(".").pop(),n=s+"."+r,o=i.name.split(".").shift();console.assert(o!==void 0);const a={alias:o,filename:n},l=await(await fetch(e+"/exists",{method:"POST",body:JSON.stringify(a)})).json();if(l.success||console.warn("exists check did fail"),l.exists)return console.log("file already exists",s),new cE(!0,n,s,i.size);console.log("begin uploading file",o,i.size);const c=new FormData;c.append("file",i);const u={};u.filesize=i.size,o&&(u.alias=o);const d=await(await fetch(e+"/upload/file",{method:"POST",body:c,headers:u})).json();if(d?.success===!1)return d.message!==void 0?console.error("Upload failed:",d.message):console.error("Upload failed"),null;console.assert(d.hash_sum===s,"hash sum did not match","received:",d.hash_sum,"expected:",s),d.success&&console.log("successfully uploaded",s,d.id);const p=new cE(d.success,n,s,i.size);return p.url=e,p}function hE(i){return HY(new Uint8Array(i))}async function uE(i,e,t,s,r=!1){try{const n=await fetch(s+"/download/file",{method:"POST",body:i});if(n.status!==200)return console.error("download failed",n),null;const o=await n.blob(),a=await o.arrayBuffer();r||console.assert(o.size===t,"size mismatch","expected:",t,"got:",o.size);const l=hE(a);return r||console.assert(l===e,"hash mismatch, downloaded file is invalid"),o.arrayBuffer()}catch(n){console.error(n)}return null}async function rU(i,e){var t;const s=await fetch(i),r=(t=s.body)==null?void 0:t.getReader(),n=s.headers.get("Content-Length"),o=n?parseInt(n):0;if(!r)return null;let a=0;const l=[];for(;;){const{done:d,value:p}=await r.read();if(p&&(l.push(p),a+=p.length,e.call(null,new ProgressEvent("progress",{loaded:a,total:o}))),d)break}const c=new Uint8Array(a);let u=0;for(const d of l)c.set(d,u),u+=d.length;return c}let nU,oU=null;function $o(){return nU}function dE(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}oU!==i&&(oU=i,nU=new i)}const Qc=oe("debugaddressables");class aU{constructor(e){h(this,"_context"),h(this,"_assetReferences",{}),this._context=e,this._context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){}findAssetReference(e){return this._assetReferences[e]||null}registerAssetReference(e){return e.uri&&(this._assetReferences[e.uri]?console.warn("Asset reference already registered",e):this._assetReferences[e.uri]=e),e}dispose(){for(const e in this._assetReferences){const t=this._assetReferences[e];t?.unload()}this._assetReferences={}}unregisterAssetReference(e){e.uri&&delete this._assetReferences[e.uri]}}const pE=Symbol("assetReference"),dg=class{constructor(i,e,t=null){h(this,"_loading"),h(this,"_asset"),h(this,"_glbRoot"),h(this,"_url"),h(this,"_progressListeners",[]),h(this,"_hash"),h(this,"_hashedUri"),h(this,"_isLoadingRawBinary",!1),h(this,"_rawBinary"),this._url=i,this._hash=e,i.includes("?v=")?this._hashedUri=i:this._hashedUri=e?i+"?v="+e:i,t!==null&&(this.asset=t),PO(this._url,this.onResolvePrefab.bind(this))}static getOrCreate(i,e,t){if(typeof i=="string"){if(!t&&(t=Ot.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=i.context,i=i.sourceId;const s=yl(i,e);Qc&&console.log("GetOrCreate Addressable from",i,e,"FinalPath=",s);const r=t.addressables,n=r.findAssetReference(s);if(n)return n;const o=new dg(s,t.hash);return r.registerAssetReference(o),o}get asset(){return this._glbRoot??this._asset}set asset(i){this._asset=i}get uri(){return this._url}get rawAsset(){return this._asset}async onResolvePrefab(i){return i===this.uri&&(this.mustLoad&&await this.loadAssetAsync(),this.asset)?this.asset:null}get mustLoad(){return!this.asset||this.asset.__destroyed===!0||J0(this.asset)===!0}isLoaded(){return this._rawBinary||this.asset!==void 0}unload(){this.asset&&(Qc&&console.log("Unload",this.asset),this.asset.scene&&Ia(this.asset.scene,!0,!0),Ia(this.asset,!0,!0)),this.asset=null,this._rawBinary=void 0,this._glbRoot=null,this._loading=void 0,Ot.Current&&Ot.Current.addressables.unregisterAssetReference(this)}async preload(){if(!this.mustLoad||this._isLoadingRawBinary)return null;if(this._rawBinary!==void 0)return this._rawBinary;this._isLoadingRawBinary=!0,Qc&&console.log("Preload",this._hashedUri);const i=await rU(this._hashedUri,e=>{this.raiseProgressEvent(e)});return this._rawBinary=i?.buffer??null,this._isLoadingRawBinary=!1,this._rawBinary}async loadAssetAsync(i){if(Qc&&console.log("loadAssetAsync",this.uri),!this.mustLoad)return this.asset;if(i&&this._progressListeners.push(i),this._loading!==void 0)return this._loading.then(s=>this.asset);const e=Ot.Current;this._rawBinary?(this._loading=$o().parseSync(e,this._rawBinary,this.uri,null),this.raiseProgressEvent(new ProgressEvent("progress",{loaded:this._rawBinary.byteLength,total:this._rawBinary.byteLength}))):(Qc&&console.log("Load async",this.uri),this._loading=$o().loadSync(e,this._hashedUri,this.uri,null,s=>{this.raiseProgressEvent(s)}));const t=await this._loading;if(this._progressListeners.length=0,this._glbRoot=this.tryGetActualGameObjectRoot(t),this._loading=void 0,t)return t[pE]=this,this._glbRoot&&(this._glbRoot[pE]=this),this.asset&&(this.asset[pE]=this),Z0(e),t.scene!==void 0&&(this.asset=t),this.asset}async instantiate(i){return this.onInstantiate(i,!1)}async instantiateSynced(i,e=!0){return this.onInstantiate(i,!0,e)}beginListenDownload(i){this._progressListeners.indexOf(i)<0&&this._progressListeners.push(i)}endListenDownload(i){const e=this._progressListeners.indexOf(i);e>=0&&this._progressListeners.splice(e,1)}raiseProgressEvent(i){for(const e of this._progressListeners)e(this,i)}async onInstantiate(i,e=!1,t){const s=Ot.Current;if(this.mustLoad&&await this.loadAssetAsync(),Qc&&console.log("Instantiate",this.uri,"parent:",i),this.asset){Qc&&console.log("Add to scene",this.asset);let r=i instanceof Ta?i:null;r||(r=new Ta),typeof i=="object"&&(i instanceof _e?r.parent=i:Object.assign(r,i)),r.parent||(r.parent=s.scene);let n=dg.currentlyInstantiating.get(this.uri);if(n!==void 0&&n>=1e4)return console.error("Recursive or too many instantiations of "+this.uri+" in the same frame ("+n+")"),null;try{if(n===void 0&&(n=0),n+=1,dg.currentlyInstantiating.set(this.uri,n),e){r.context=s;const o=this.asset;o.guid=this.uri;const a=TC(o,r,void 0,t);if(a)return a}else{const o=ag(this.asset,r);if(o)return o}}finally{s.post_render_callbacks.push(()=>{n===void 0||n<0?n=0:n-=1,dg.currentlyInstantiating.set(this.uri,n)})}}else Qc&&console.warn("Failed to load asset",this.uri);return null}tryGetActualGameObjectRoot(i){if(i&&i.scene){const e=i.scene;return e.isGroup&&e.children.length===1&&e.children[0].name+"glb"===e.name?e.children[0]:e}return null}};let Fs=dg;h(Fs,"currentlyInstantiating",new Map);class VY extends Rl{constructor(){super([Fs])}onSerialize(e,t){if(e&&e.uri!==void 0&&typeof e.uri=="string")return e.uri}onDeserialize(e,t){if(typeof e=="string")return t.context?t.gltfId?Fs.getOrCreate(t.gltfId,e,t.context):(console.error("Missing source id"),null):(console.error("Missing context"),null);if(e instanceof _e){if(!t.context)return console.error("Missing context"),null;if(!t.gltfId)return console.error("Missing source id"),null;const s=e,r=t.context,n=s.guid??s.uuid,o=r.addressables.findAssetReference(n);if(o)return o;const a=new Fs(n,void 0,s);return r.addressables.registerAssetReference(a),a}return null}}new VY;const WY=Promise.resolve(null),ab=class{constructor(i){h(this,"url"),h(this,"_bitmap"),h(this,"_bitmapObject"),h(this,"loader",null),this.url=i}static getOrCreate(i){let e=ab.imageReferences.get(i);return e||(e=new ab(i),ab.imageReferences.set(i,e)),e}dispose(){this._bitmapObject&&this._bitmapObject.close(),this._bitmap=void 0}createHTMLImage(){const i=new Image;return i.src=this.url,i}createTexture(){return this.url?(this.loader||(this.loader=new Al),this.loader.setCrossOrigin("anonymous"),this.loader.loadAsync(this.url)):WY}getBitmap(){return this._bitmap?this._bitmap:(this._bitmap=new Promise((i,e)=>{const t=document.createElement("img");t.addEventListener("load",()=>{this._bitmap=createImageBitmap(t).then(s=>(this._bitmapObject=s,i(s),s))}),t.addEventListener("error",s=>{console.error("Failed to load image:"+this.url,s),i(null)}),t.src=this.url}),this._bitmap)}};let lb=ab;h(lb,"imageReferences",new Map);class lU extends Rl{constructor(){super([lb])}onSerialize(e,t){return null}onDeserialize(e,t){if(typeof e=="string"){const s=yl(t.gltfId,e);return lb.getOrCreate(s)}}}new lU;const go=oe("debugenvlight");var cp=(i=>(i[i.Skybox=0]="Skybox",i[i.Trilight=1]="Trilight",i[i.Flat=3]="Flat",i[i.Custom=4]="Custom",i))(cp||{}),cb=(i=>(i[i.Skybox=0]="Skybox",i[i.Custom=1]="Custom",i))(cb||{});class cU{constructor(e){h(this,"context"),h(this,"_currentLightSettingsId"),h(this,"_sceneLightSettings"),h(this,"_timevec4",new it),h(this,"__currentReflectionId",null),h(this,"_waitPromise"),h(this,"_lighting",{}),this.context=e,this.context.pre_update_callbacks.push(this.preUpdate.bind(this))}preUpdate(){const e=this.context.time;this._timevec4.x=e.time,this._timevec4.y=Math.sin(e.time),this._timevec4.z=Math.cos(e.time),this._timevec4.w=e.deltaTime}get timeVec4(){return this._timevec4}get environmentIntensity(){if(!this._sceneLightSettings||!this._currentLightSettingsId)return 1;const e=this._sceneLightSettings.get(this._currentLightSettingsId);return e?e.ambientIntensity:1}get sceneLightSettings(){var e;return(e=this._sceneLightSettings)==null?void 0:e.values()}enable(e){var t;e instanceof Fs&&(e=e.uri);const s=(t=this._sceneLightSettings)==null?void 0:t.get(e);return s?(go&&console.log("Enable scene light settings",e,s),e!==this._currentLightSettingsId&&this._currentLightSettingsId&&this.disable(this._currentLightSettingsId),this._currentLightSettingsId=e,s.enabled=!0,!0):!1}disable(e){var t;if(e instanceof Fs&&(e=e.uri),e==null)return!1;const s=(t=this._sceneLightSettings)==null?void 0:t.get(e);return s?(go&&console.log("Disable scene light settings",e,s),s.enabled=!1,!0):!1}disableCurrent(){if(this._currentLightSettingsId){const e=this._currentLightSettingsId;return this.disable(this._currentLightSettingsId),e}return null}internalRegisterSceneLightSettings(e){const t=e.sourceId;if(!t){console.error("Missing source id for scene light settings, can not register:",e);return}go&&console.log("Register "+e?.sourceId+" lighting",e),this._sceneLightSettings||(this._sceneLightSettings=new Map),this._sceneLightSettings.set(t,e)}internalUnregisterSceneLightSettings(e){const t=e.sourceId;if(!t){console.error("Missing source id for scene light settings, can not unregister:",e);return}go&&console.log("Unregister "+e?.sourceId+" lighting",e),this._sceneLightSettings&&this._sceneLightSettings.delete(t)}internalRegisterReflection(e,t){go&&console.log("Register reflection",e,t);const s=new hU(this.context,t,1);this._lighting[e]=s}internalGetReflection(e){return this._lighting[e]}internalEnableReflection(e){var t;this.__currentReflectionId=e;const s=(t=this._sceneLightSettings)==null?void 0:t.get(e);switch(go&&console.log("Enable reflection",e,s?cp[s.ambientMode]:"Unknown ambient mode"),s?.ambientMode){case 0:case 4:const r=this.internalGetReflection(e);if(r&&r.Source){go&&console.log("Setting environment reflection",r);const n=this.context.scene,o=r.Source;o.colorSpace=st,o.mapping=ro,n.environment=o;return}else go&&console.warn("Could not find reflection for source",e);break}if(s?.environmentReflectionSource===1)switch(s?.ambientMode){case 1:if(s.ambientTrilight){const r=s.ambientTrilight,n=LY(r[0],r[1],r[2],64,64);n.colorSpace=st,n.mapping=ro,this.context.scene.environment=n}else console.error("Missing ambient trilight",s.sourceId);return;case 3:if(s.ambientLight){const r=YL(s.ambientLight,64);r.colorSpace=st,r.mapping=ro,this.context.scene.environment=r}else console.error("Missing ambientlight",s.sourceId);return;default:return}}internalDisableReflection(e){if(e&&e!==this.__currentReflectionId){go&&console.log("Not disabling reflection for",e,"because it is not the current light settings id",this.__currentReflectionId);return}go&&console.log("Disable reflection",e);const t=this.context.scene;t.environment=null}async internalGetSceneLightingData(e){return go&&console.log("GET SCENE LIGHT DATA",e),this._waitPromise?this._waitPromise:(this._waitPromise=new Promise((t,s)=>{const r=setInterval(async()=>{const n=this.internalGetReflection(e);n&&(clearInterval(r),t(n.getSphericalHarmonicsArray(this.environmentIntensity??1)))},10)}),this._waitPromise)}}class hU{constructor(e,t,s=1){h(this,"_context"),h(this,"_source"),h(this,"_sphericalHarmonics",null),h(this,"_sphericalHarmonicsArray"),h(this,"_ambientScale",1),h(this,"_lightProbe"),this._context=e,this._source=t,this._ambientScale=s,t.mapping=ro,t.colorSpace=st}get Source(){return this._source}get Array(){return this._sphericalHarmonicsArray}getSphericalHarmonicsArray(e=1){var t;if((t=this._sphericalHarmonicsArray)!=null&&t.length&&this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:this._lightProbe};try{const s=this._source;let r=null;if(s){go&&console.log("GENERATING LIGHT PROBE",s,this.Source);const n=Math.min(s.image.width,512);r=new uy(n).fromEquirectangularTexture(this._context.renderer,s)}if(this._sphericalHarmonicsArray=[],r){const n=kY.fromCubeRenderTarget(this._context.renderer,r);this._lightProbe=n;const o=this._ambientScale*(e*e*Math.PI*.5)-1;if(this._sphericalHarmonics=n.sh,this._sphericalHarmonicsArray=this._sphericalHarmonics.toArray(),this._sphericalHarmonicsArray){const a=e/(Math.PI*.5);for(let l=0;l<this._sphericalHarmonicsArray.length;l++)this._sphericalHarmonicsArray[l]*=a;if(n.sh.scale(o),this._source)return{array:this._sphericalHarmonicsArray,texture:this._source,lightProbe:n}}}}catch(s){console.error(s)}return null}}var hb=(i=>(i.Visible="application-visible",i.Hidden="application-hidden",i.MuteChanged="application-mutechanged",i))(hb||{});class uU extends EventTarget{constructor(e){super(),h(this,"_mute",!1),h(this,"context"),h(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),i=this.clip);let s=!this.sound||i&&
5186
5186
  #include <colorspace_fragment>
5187
5187
 
5188
5188
  }
5189
- `,o={map:{value:e},height:{value:t.height||15},radius:{value:t.radius||100}},a=new fA(1,16),l=new It({uniforms:o,fragmentShader:n,vertexShader:r,side:yi});super(a,l)}set radius(e){this.material.uniforms.radius.value=e}get radius(){return this.material.uniforms.radius.value}set height(e){this.material.uniforms.height.value=e}get height(){return this.material.uniforms.height.value}}var jie=Object.defineProperty,Gie=Object.getOwnPropertyDescriptor,fr=(i,e,t,s)=>{for(var r=s>1?void 0:s?Gie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&jie(e,t,r),r};const __=oe("freecam"),Wg=oe("debugcamerafit"),x_=oe("smoothcam"),Qie={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let vT;class Xg extends CustomEvent{constructor(e,t){super("target-reached",{detail:{controls:e,type:t}})}}class ki extends Pe{constructor(){super(...arguments),h(this,"autoFit",!1),h(this,"enableRotate",!0),h(this,"autoRotate",!1),h(this,"autoRotateSpeed",1),h(this,"enableKeys",!0),h(this,"enableDamping",!0),h(this,"dampingFactor",.1),h(this,"enableZoom",!0),h(this,"minZoom",0),h(this,"maxZoom",1/0),h(this,"enablePan",!0),h(this,"lookAtConstraint",null),h(this,"lookAtConstraint01",1),h(this,"allowInterrupt",!0),h(this,"middleClickToFocus",!0),h(this,"doubleClickToFocus",!0),h(this,"useSlerp",!0),h(this,"debugLog",!1),h(this,"targetLerpDuration",1),h(this,"autoTarget",!0),h(this,"_controls",null),h(this,"_cameraObject",null),h(this,"_lookTargetLerpActive",!1),h(this,"_lookTargetStartPosition",new w),h(this,"_lookTargetEndPosition",new w),h(this,"_lookTargetLerp01",0),h(this,"_lookTargetLerpDuration",0),h(this,"_cameraLerpActive",!1),h(this,"_cameraStartPosition",new w),h(this,"_cameraEndPosition",new w),h(this,"_cameraLerp01",0),h(this,"_cameraLerpDuration",0),h(this,"_inputs",0),h(this,"_enableTime",0),h(this,"_startedListeningToKeyEvents",!1),h(this,"_eventSystem"),h(this,"_afterHandleInputFn"),h(this,"_camera",null),h(this,"_syncedTransform"),h(this,"_didStart",!1),h(this,"targetElement",null),h(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),h(this,"_shouldDisable",!1),h(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}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=te.getComponent(this.gameObject,Oi);if(e&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const t=ft(e.cam).length(),s=new w(0,0,-t).applyMatrix4(e.cam.matrixWorld);this.setLookTargetPosition(s,!0)}if(this.autoTarget&&!this.setLookTargetFromConstraint()){const t=new Nn;t.screenPoint=new ee(0,0),t.lineThreshold=.1;const s=this.context.physics.raycast(t);s.length>0&&this.setLookTargetPosition(s[0].point,!0),Wg&&console.log("OrbitControls hits",...s)}this.autoFit&&this.fitCamera()}this._eventSystem=Xn.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(gT.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(gT.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=te.getComponent(this.gameObject,Oi);this._camera=e;const t=e?.cam;if(t&&W3(t,this,!0),!this._controls){if(!t){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}t&&(this._cameraObject=t);const s=this.targetElement??this.context.domElement,r=t?.quaternion.clone();this._controls=new $te(t,s),t?.quaternion.copy(r),vT===void 0&&(vT={...this._controls.keys})}this._controls&&(__&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,bl()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),t?.type==="PerspectiveCamera"?__||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):__||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=te.getComponent(this.gameObject,lh)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&W3(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 e,t;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)&&(e=this.context.input.getPointerPositionDelta(0))!=null&&e.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 s=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(s||(s=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),s&&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 Xg(this,"camera"));else{const r=Je.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,r)}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 Xg(this,"lookat"));else{const r=Je.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,r)}}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?vT:Qie,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 x_=="number"||x_===!0){this._controls.enableDamping=!0;const r=typeof x_=="number"?x_:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,r))}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||(!__&&(t=this.lookAtConstraint)!=null&&t.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update())}}setCameraAndLookTarget(e){if(!e||!(e instanceof _e))return;const t=ft(e),s=rC(e);this.setTargetFromRaycast(new Go(t,s)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var s,r;e&&(e instanceof _e&&(e=ft(e)),this._cameraEndPosition||(this._cameraEndPosition=new w),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,(s=this.controllerObject)==null||s.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((r=this._cameraObject)==null?void 0:r.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 _e&&(e=ft(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 s;if(!this._controls)return!1;const r=(s=this.lookAtConstraint)==null?void 0:s.sources;if(r&&r.length>0){const n=r[e];if(n)return n.getWorldPosition(this._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 t,s;if(!this.controls)return;const r=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const n of r)if(n.distance>0&&te.isActiveInHierarchy(n.object)){const o=A_(n.object);if(o){const a=o.canvas;if(a!=null&&a.screenspace)break}if(this.setLookTargetPosition(n.point),this.context.mainCamera){const a=ft(this.context.mainCamera).clone().sub(this.controls.target).add(this._lookTargetEndPosition);(s=(t=this._cameraObject)==null?void 0:t.parent)==null||s.worldToLocal(a),this.setCameraTargetPosition(a)}break}}fitCamera(e,t=1.1,s=!0){const r=this._cameraObject,n=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0||!r||!n)return;const o=new w,a=new w,l=new xs;l.makeEmpty();const c=[];function u(b){let y=!0;if(b.visible&&zie(b)!==!1&&!(b.type==="TransformControlsGizmo"||b.type==="TransformControlsPlane")&&(b instanceof US&&(y=!1),b instanceof LS&&(y=!1),b instanceof q3&&(y=!1),b.material instanceof Uy&&(y=!1),b instanceof ge||(y=!1),b!==r&&b.isUI!==!0)){if(y){Wg&&console.log(b.name,b.type,b);const _=b.children;b.children=c;const S=b.position,T=b.scale;if(Number.isNaN(S.x)||Number.isNaN(S.y)||Number.isNaN(S.z)){console.warn(`Object "${b.name}" has NaN values in position or scale.... will ignore it`,S,T);return}l.expandByObject(b,!0),b.children=_}for(const _ of b.children)u(_)}}for(const b of e)b.updateMatrixWorld(),u(b);if(r.updateMatrixWorld(),r.updateProjectionMatrix(),l.getCenter(a),l.applyMatrix4(r.matrixWorldInverse),l.getSize(o),l.setFromCenterAndSize(a,o),Number.isNaN(o.x)||Number.isNaN(o.y)||Number.isNaN(o.z)){console.warn("Camera fit size resultet in NaN",r,l,[...e]);return}if(o.length()<=1e-10){Wg&&console.warn("Camera fit size is zero",l,[...e]);return}const d=r.fov,p=2*Math.atan(Math.tan(d*Math.PI/360/2)*r.aspect)/Math.PI*360,f=o.y/(2*Math.atan(Math.PI*d/360)),m=o.x/(2*Math.atan(Math.PI*p/360)),A=t*Math.max(f,m)+o.z/2;Wg&&console.log("Fit camera to objects",f,m,"distance",A);const v=ft(r),g=n.target.clone().sub(v).normalize().multiplyScalar(A);if(n.maxDistance=A*10,n.minDistance=A*.01,this.setLookTargetPosition(a,s),this.autoTarget=!1,r.near=A/100,r.far=A*100,r.updateMatrixWorld(),r.updateProjectionMatrix(),r.parent){const b=r.parent.worldToLocal(n.target.clone().sub(g));this.setCameraTargetPosition(b,s)}else console.error(`Can not fit camera ${r.name} because it has no parent`);if(Wg){const b=new US(l);this.context.scene.add(b),nC(b,Dm(r)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",y=>{y.code==="KeyF"&&this.fitCamera(e)}))}n.update()}}fr([x()],ki.prototype,"autoFit",2),fr([x()],ki.prototype,"enableRotate",2),fr([x()],ki.prototype,"autoRotate",2),fr([x()],ki.prototype,"autoRotateSpeed",2),fr([x()],ki.prototype,"enableKeys",2),fr([x()],ki.prototype,"enableDamping",2),fr([x()],ki.prototype,"dampingFactor",2),fr([x()],ki.prototype,"enableZoom",2),fr([x()],ki.prototype,"minZoom",2),fr([x()],ki.prototype,"maxZoom",2),fr([x()],ki.prototype,"enablePan",2),fr([x(Fg)],ki.prototype,"lookAtConstraint",2),fr([x()],ki.prototype,"lookAtConstraint01",2),fr([x()],ki.prototype,"allowInterrupt",2),fr([x()],ki.prototype,"middleClickToFocus",2),fr([x()],ki.prototype,"doubleClickToFocus",2),fr([x()],ki.prototype,"targetLerpDuration",2);var Hie=Object.defineProperty,Vie=Object.getOwnPropertyDescriptor,qn=(i,e,t,s)=>{for(var r=s>1?void 0:s?Vie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Hie(e,t,r),r},Iu=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(Iu||{});const Ru=oe("debugcam"),Y3=oe("debugscreenpointtoray");var w_;const qg=(w_=class extends Pe{constructor(){super(...arguments),h(this,"_nearClipPlane",.1),h(this,"_farClipPlane",1e3),h(this,"orthographic",!1),h(this,"orthographicSize",5),h(this,"ARBackgroundAlpha",0),h(this,"_cullingMask",4294967295),h(this,"_backgroundBlurriness"),h(this,"_backgroundIntensity"),h(this,"_environmentIntensity"),h(this,"_targetTexture",null),h(this,"_backgroundColor"),h(this,"_fov"),h(this,"_cam",null),h(this,"_clearFlags",2),h(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof qt?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof qt?this._cam.fov:this._fov}set fieldOfView(i){const e=this.fieldOfView!=i;if(this._fov=i,e&&this._cam&&this._cam instanceof qt){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(i){const e=this._nearClipPlane!=i;this._nearClipPlane=i,this._cam&&e&&(this._cam.near=i,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(i){const e=this._farClipPlane!=i;this._farClipPlane=i,this._cam&&e&&(this._cam.far=i,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(i){i!==this._clearFlags&&(this._clearFlags=i,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(i){this._cullingMask=i,this._cam&&(this._cam.layers.mask=i)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(i){this.cullingMask=(1<<i|0)>>>0}set backgroundBlurriness(i){i!==this._backgroundBlurriness&&(i===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(i,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(i){i!==this._backgroundIntensity&&(i===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(i,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(i){this._environmentIntensity=i}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(i){if(i){if(this._backgroundColor)this._backgroundColor.copy(i);else{if(!i.clone)return;this._backgroundColor=i.clone()}i.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(i){this._targetTexture=i}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(i,e,t){const s=this.cam,r=qg._origin;r.set(i,e,-1),this.context.input.convertScreenspaceToRaycastSpace(r),Y3&&console.log("screenPointToRay",i.toFixed(2),e.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const n=qg._direction.set(r.x,r.y,r.z),o=ft(s);return n.sub(o),n.normalize(),t?(t.set(o,n),t):new Go(o.clone(),n.clone())}awake(){Y3&&window.addEventListener("pointerdown",i=>{const e=i.clientX,t=i.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const s=this.screenPointToRay(e,t),r="#"+Math.floor(Math.random()*16777215).toString(16);Oa.DrawRay(s.origin,s.direction,r,10)})}onEnable(){Ru&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Iu[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),Xie(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 i=this.context.renderer;if(i){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,i),e?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const i=this.gameObject.isCamera;let e=null;if(i?(e=this.gameObject,e?.layers.enableAll(),e instanceof qt&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof qt&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new qt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new fl(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){Ru&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,Ru){const i=`Camera "${this.name}" clear flags: ${Iu[this._clearFlags]}`;console.log(i)}switch(this._clearFlags){case 1:if(qg.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let i=this._backgroundColor.alpha;qg.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,i)}else Ru&&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 Wie(this)),this._skybox.enable()}static backgroundShouldBeTransparent(i){var e,t,s,r;const n=(e=i.renderer.xr)==null?void 0:e.getSession();if(!n)return!1;if(typeof n._transparent=="boolean")return n._transparent;const o=n.environmentBlendMode;Ru&&cs("Environment blend mode: "+o+" on "+navigator.userAgent);let a=o==="additive"||o==="alpha-blend";return i.xrSessionMode===vg.ImmersiveAR&&o==="opaque"&&((t=navigator.userAgent)!=null&&t.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&(r=navigator.userAgent)!=null&&r.includes("Mobile WebXRViewer/v2"))&&(a=!0),n._transparent=a,a}},h(w_,"_origin",new w),h(w_,"_direction",new w),w_);let Oi=qg;qn([x()],Oi.prototype,"fieldOfView",1),qn([x()],Oi.prototype,"nearClipPlane",1),qn([x()],Oi.prototype,"farClipPlane",1),qn([x()],Oi.prototype,"clearFlags",1),qn([x()],Oi.prototype,"orthographic",2),qn([x()],Oi.prototype,"orthographicSize",2),qn([x()],Oi.prototype,"ARBackgroundAlpha",2),qn([x()],Oi.prototype,"cullingMask",1),qn([x()],Oi.prototype,"backgroundBlurriness",1),qn([x()],Oi.prototype,"backgroundIntensity",1),qn([x()],Oi.prototype,"environmentIntensity",1),qn([x(vi)],Oi.prototype,"backgroundColor",1),qn([x(_p)],Oi.prototype,"targetTexture",1);class Wie{constructor(e){h(this,"_camera"),h(this,"_skybox"),this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(Ru&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.colorSpace=st,this._skybox.mapping=ro,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)),(Ru||Gt())&&Vs(`Camera "${this._camera.name}" has no skybox texture`))}}function Xie(i){oe("freecam")&&i.context.mainCameraComponent===i&&te.getOrAddComponent(i.gameObject,ki)}class hh extends Pe{constructor(){super(...arguments),h(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new XD),this._listener}awake(){ms.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=this.context.mainCameraComponent||te.getComponentInParent(this.gameObject,Oi);t!=null&&t.cam?t.cam.add(e):this.gameObject.add(e)})}}var qie=Object.defineProperty,Yie=Object.getOwnPropertyDescriptor,S_=(i,e,t,s)=>{for(var r=s>1?void 0:s?Yie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&qie(e,t,r),r};const Kie=oe("debugsignals");class Yg{constructor(){h(this,"guid")}}S_([x()],Yg.prototype,"guid",2);class Vp{constructor(){h(this,"signal"),h(this,"reaction")}}S_([x(Yg)],Vp.prototype,"signal",2),S_([x(hr)],Vp.prototype,"reaction",2);var AT;const Zl=(AT=class extends Pe{constructor(){super(...arguments),h(this,"events")}static invoke(i){if(Zl.receivers[i]){const e=Zl.receivers[i];if(!e)return;for(const t of e)t.invoke(i)}}awake(){Kie&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const i of this.events)Zl.receivers[i.signal.guid]||(Zl.receivers[i.signal.guid]=[]),Zl.receivers[i.signal.guid].push(this)}onDisable(){if(this.events){for(const i of this.events)if(Zl.receivers[i.signal.guid]){const e=Zl.receivers[i.signal.guid].indexOf(this);e>=0&&Zl.receivers[i.signal.guid].splice(e,1)}}}invoke(i){if(!this.events||!Array.isArray(this.events))return;const e=typeof i=="object"?i.guid:i;for(const t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(s){console.error(s)}}},h(AT,"receivers",{}),AT);let Wp=Zl;S_([x(Vp)],Wp.prototype,"events",2);var Yn=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(Yn||{}),za=(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))(za||{}),yT=(i=>(i.Signal="SignalEmitter",i))(yT||{});const $l=oe("debugtimeline");class Kg{constructor(){h(this,"director"),h(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let s=this.track.clips.length-1;s>=0;s--)yield this.track.clips[s];else for(const s of this.track.clips)yield s}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,s,r=!0){if(t<0||t>=s.length)return 0;const n=s[t];if(r||e>=n.start&&e<=n.end){let o=1;const a=!1;if(n.easeInDuration>0){const l=Math.min((e-n.start)/n.easeInDuration,1);o*=l}if(n.easeOutDuration>0&&!a){const l=Math.min((n.end-e)/n.easeOutDuration,1);o*=l}return o}return 0}}class Jie{constructor(e){h(this,"clip"),h(this,"rootPositionOffset"),h(this,"rootQuaternionOffset"),h(this,"rootStartPosition"),h(this,"rootEndPosition"),h(this,"rootStartQuaternion"),h(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const s=e.getRoot(),r=s.name+".position",n=s.name+".quaternion";$l&&console.log(t.name,t.tracks,r);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(r))this.rootStartPosition=new w().fromArray(o.values,0),this.rootEndPosition=new w().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),$l&&console.log(this.rootPositionOffset);else if(o.name.endsWith(n)&&(this.rootStartQuaternion=new Ce().fromArray(o.values,0),this.rootEndQuaternion=new Ce().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),$l)){const a=new ys().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class C_ extends Kg{constructor(){super(...arguments),h(this,"models",[]),h(this,"trackOffset"),h(this,"target"),h(this,"mixer"),h(this,"clips",[]),h(this,"actions",[]),h(this,"_actionOffsets",[]),h(this,"_didBind",!1),h(this,"_animator",null),h(this,"_useclipOffsets",!0),h(this,"_totalOffsetPosition",new w),h(this,"_totalOffsetRotation",new Ce),h(this,"_totalOffsetPosition2",new w),h(this,"_totalOffsetRotation2",new Ce),h(this,"_summedPos",new w),h(this,"_tempPos",new w),h(this,"_summedRot",new Ce),h(this,"_tempRot",new Ce),h(this,"_clipRotQuat",new Ce)}onStateChanged(){this._animator&&K3(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var s,r;if(((s=t.tracks)==null?void 0:s.length)<=0){console.warn("No tracks in AnimationClip",t);return}const n=t.tracks[0].name.split("."),o=n[n.length-2],a=o+".position",l=o+".quaternion";let c=!1,u=!1;for(const d of t.tracks)d.name.endsWith(a)?(c=!0,this.createPositionInterpolant(t,e,d)):d.name.endsWith(l)&&(u=!0,this.createRotationInterpolant(t,e,d));if(!c||!u){const d=(r=this.mixer)==null?void 0:r.getRoot(),p=t.tracks[0],f=p.name.lastIndexOf("."),m=p.name.substring(0,f),A=m.substring(m.lastIndexOf(".")+1),v=d.getObjectByName(A);if(v)if(c){if(!u){const g=t.tracks[0].name.substring(0,f)+".quaternion";$l&&console.warn("Create quaternion track",A,v);const b=v.quaternion,y=new wa(g,[0,t.duration],[b.x,b.y,b.z,b.w,b.x,b.y,b.z,b.w]);t.tracks.push(y),this.createRotationInterpolant(t,e,y)}}else{const g=m+".position";$l&&console.warn("Create position track",A,v);const b=v.position,y=new gl(g,[0,t.duration],[b.x,b.y,b.z,b.x,b.y,b.z]);t.tracks.push(y),this.createPositionInterpolant(t,e,y)}}}bind(){if(!this._didBind){this._didBind=!0,$l&&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 Jie(e);this._actionOffsets.push(t)}this.target&&(this._animator=te.getComponent(this.target,mr)??null,this._animator&&K3(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,s=t.position,r=t.rotation;s&&s.x!==void 0&&(s.isVector3||(t.position=new w(s.x,s.y,s.z)),r.isQuaternion||(t.rotation=new Ce(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new w(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new Ce(t.x,t.y,t.z,t.w)))}}evaluate(e){var t,s,r,n,o,a,l;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let c=0,u=0,d=!1,p=!1,f=0;for(let m=0;m<this.clips.length;m++){const A=this.models[m],v=this.actions[m],g=A.asset;v.weight=0;const b=e>=A.start&&e<=A.end,y=A.preExtrapolationMode,_=A.postExtrapolationMode,S=m<this.clips.length-1?this.models[m+1]:null;let T=b,M=!1;if(!T&&!d&&A.end<e&&_!==za.None?(!S||S.start>e)&&(T=!0,d=!0):m==0&&!T&&!p&&A.start>e&&y!==za.None&&(!S||S.start<e)&&(T=!0,M=!0,p=!0),T){let R=1;R*=this.evaluateWeight(e,m,this.models,T),R*=this.director.weight;let E=b;if(M)switch(y){case za.Hold:break;case za.Loop:e+=A.start,E=!0;break;default:e+=A.start,E=!0;break}let C=this.getClipTime(e,A),U=0;const G=g.duration;if(M&&y===za.Hold&&(C=0),E){if(g.loop)for(U+=Math.floor(C/(G+1e-6));C>G;)C-=G}else if(!b&&d)switch(_){case za.Hold:C=this.getClipTime(A.end,A);break;case za.Loop:C%=G;break;case za.PingPong:const Q=Math.floor(C/G)%2!==0;C%=G,Q&&(C=G-C);break}A.reversed===!0?v.time=v.getClip().duration-C:v.time=C,v.timeScale=0;const F=Math.max(0,R);if(v.weight=F,f+=F,v.clampWhenFinished=!1,v.isRunning()||v.play(),this._useclipOffsets){const Q=c==0?this._totalOffsetPosition:this._totalOffsetPosition2,K=c==0?this._totalOffsetRotation:this._totalOffsetRotation2;c<1&&(u=1-R),c+=1;const z=this._summedPos.set(0,0,0),O=this._tempPos.set(0,0,0),j=this._summedRot.identity(),se=this._tempRot.identity(),$=g.rotation;$&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp($,R));const X=this._actionOffsets[m];if(X.hasOffsets)for(let ie=0;ie<U;ie++)X.rootPositionOffset?O.copy(X.rootPositionOffset):O.set(0,0,0),O.applyQuaternion(j),this._clipRotQuat&&O.applyQuaternion(this._clipRotQuat),X.rootQuaternionOffset&&(se.copy(X.rootQuaternionOffset),j.multiply(se)),z.add(O);this._clipRotQuat&&K.multiply(this._clipRotQuat),K.multiply(j),g.position&&z.add(g.position),Q.add(z)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,u),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,u)),this.__mixerError===void 0&&($l||Gt())&&(s=(t=this._animator)==null?void 0:t.runtimeAnimatorController)!=null&&s.mixer&&this.mixer!==((n=(r=this._animator)==null?void 0:r.runtimeAnimatorController)==null?void 0:n.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(o=this._animator)!=null&&o.runtimeAnimatorController){const m=Math.max(0,1-f);(l=(a=this._animator)==null?void 0:a.runtimeAnimatorController)==null||l.update(m)}else this.mixer.update(e)}createRotationInterpolant(e,t,s){var r;const n=s.createInterpolant.bind(s),o=new Ce;this.ensureTrackOffsets();const a=(r=this.trackOffset)==null?void 0:r.rotation;s.createInterpolant=()=>{const l=n(),c=l.evaluate.bind(l);return l.evaluate=u=>{var d;const p=c(u);if(o.set(p[0],p[1],p[2],p[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const f of this.director.animationCallbackReceivers)(d=f?.onTimelineRotation)==null||d.call(f,this.director,this.target,u,o);return p[0]=o.x,p[1]=o.y,p[2]=o.z,p[3]=o.w,p},l}}createPositionInterpolant(e,t,s){var r,n;const o=s.createInterpolant.bind(s),a=new w;this.ensureTrackOffsets();const l=(r=this.trackOffset)==null?void 0:r.rotation,c=(n=this.trackOffset)==null?void 0:n.position;let u;s.createInterpolant=()=>{const d=o(),p=d.evaluate.bind(d);return d.evaluate=f=>{var m,A,v;const g=p(f);if(a.set(g[0],g[1],g[2]),t.removeStartOffset&&(u===void 0?(u=null,u=(A=(m=this._actionOffsets.find(b=>b.clip===e))==null?void 0:m.rootStartPosition)==null?void 0:A.clone()):u!=null&&u.isVector3&&a.sub(u)),a.applyQuaternion(this._totalOffsetRotation),a.add(this._totalOffsetPosition),l&&a.applyQuaternion(l),c&&(a.x-=c.x,a.y+=c.y,a.z+=c.z),this.director.animationCallbackReceivers)for(const b of this.director.animationCallbackReceivers)(v=b?.onTimelinePosition)==null||v.call(b,this.director,this.target,f,a);return g[0]=a.x,g[1]=a.y,g[2]=a.z,g},d}}}const Zie=oe("mutetimeline"),Jg=class extends Kg{constructor(){super(...arguments),h(this,"models",[]),h(this,"listener"),h(this,"audio",[]),h(this,"audioContextTimeOffset",[]),h(this,"lastTime",0),h(this,"audioSource"),h(this,"_audioLoader",null)}getAudioFilePath(i){const e=this.director.sourceId;return yl(e,i)}onAllowAudioChanged(i){for(let e=0;e<this.models.length;e++){const t=this.models[e];this.audio[e].setVolume(i?t.asset.volume:0)}}addModel(i){const e=new RS(this.listener);this.audio.push(e),this.models.push(i)}onDisable(){for(const i of this.audio)i.isPlaying&&i.stop()}onDestroy(){for(const i of this.audio)i.source&&i?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}stop(){for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}evaluate(i){if(Zie||this.track.muted||this.director.speed<0)return;const e=this.director.context.application.muted,t=e?.1:0;for(let s=0;s<this.models.length;s++){const r=this.models[s],n=this.audio[s],o=r.asset;if((!n||!n.buffer)&&this.isInTimeRange(r,i-1,i+1)&&this.handleAudioLoading(r,n),ms.userInteractionRegistered!==!1&&!(n===null||!n.buffer))if(n.playbackRate=this.director.context.time.timeScale*this.director.speed,n.loop=o.loop,i>=r.start&&i<=r.end&&i<this.director.duration){if(this.director.isPlaying==!1){if(n.isPlaying&&n.stop(),this.lastTime===i)continue}else if(!n.isPlaying)n.offset=r.clipIn+(i-r.start)*r.timeScale,n.play(t);else{const l=r.clipIn+(i-r.start)*r.timeScale,c=n.context.currentTime-n._startedAt+n.offset;Math.abs(l-c)>.3&&(n.offset=l,n.stop(),n.play(t))}let a=o.volume;if(this.track.volume!==void 0&&(a*=this.track.volume),e&&(a=0),r.easeInDuration>0){const l=Math.min((i-r.start)/r.easeInDuration,1);a*=l}if(r.easeOutDuration>0){const l=Math.min((r.end-i)/r.easeOutDuration,1);a*=l}n.setVolume(a*this.director.weight)}else n.isPlaying&&n.stop()}this.lastTime=i}loadAudio(i,e=0,t=0){let s=null;const r=i-t,n=i+e;for(const o of this.models)if(this.isInTimeRange(o,r,n)){const a=this.audio[this.models.indexOf(o)],l=this.handleAudioLoading(o,a);l!==null&&(s===null&&(s=[]),s.push(l))}return s!==null?Promise.all(s):null}isInTimeRange(i,e,t){return e<=i.start&&t>=i.end||e>=i.start&&e<=i.end||t>=i.start&&t<=i.end}static dispose(){Jg._audioBuffers.clear()}handleAudioLoading(i,e){this._audioLoader||(this._audioLoader=new Vy);const t=this.getAudioFilePath(i.asset.clip);if(Jg._audioBuffers.get(t)){const r=Jg._audioBuffers.get(t);return r.then(n=>{n&&e.setBuffer(n)}),r}$l&&console.warn("LOAD audio track",t,this.director.sourceId);const s=new Promise((r,n)=>{this._audioLoader.load(t,o=>{e.setBuffer(o),r(o)},void 0,o=>{console.error("Error loading audio",o),r(null)})});return Jg._audioBuffers.set(t,s),s}};let Zg=Jg;h(Zg,"_audioBuffers",new Map);class $g extends Kg{constructor(){super(...arguments),h(this,"models",[]),h(this,"didTrigger",[]),h(this,"receivers",[])}evaluate(e){var t;if(this.track.muted)return;const s=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const n=this.models[r],o=this.didTrigger[r],a=n.time-e;let l=!1;if(n.retroActive)l=a<=1e-6;else{const c=Math.abs(a);(c===0||c>=1e-5&&c<s)&&(l=!0)}if(l){if(!o)if($l&&console.log("Trigger signal",e,n.time,n),this.didTrigger[r]=!0,((t=this.receivers)==null?void 0:t.length)<=0)Wp.invoke(n.asset);else for(const c of this.receivers)c&&c.invoke(n.asset)}else n.emitOnce||(this.didTrigger[r]=!1)}}}class E_ extends Kg{constructor(){super(...arguments),h(this,"models",[]),h(this,"timelines",[]),h(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const s=this.models[t].asset;if(!s.sourceObject||typeof s.sourceObject!="object"){console.log("no source object, removing model",t,s),this.models.splice(t,1);continue}else{const r=te.getComponent(s.sourceObject,Pu);this.timelines.push(r),r&&s.updateDirector&&(r.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],n=r.asset;if(e>=r.start&&e<=r.end){this._previousActiveModel=r;const o=this.getClipTime(e,r);if(n.controlActivation){const a=n.sourceObject;a.visible=!0}if(n.updateDirector){const a=this.timelines[s];a&&(a.isPlaying&&a.pause(),a.time=o,a.evaluate())}}else{const o=(t=this._previousActiveModel)==null?void 0:t.asset;if(n.controlActivation){const a=n.sourceObject;o?.sourceObject!==a&&(a.visible=!1)}}}}}const Xp=oe("debugtimeline"),bT=class extends Pe{constructor(){super(...arguments),h(this,"playableAsset"),h(this,"playOnAwake"),h(this,"extrapolationMode",1),h(this,"waitForAudio",!0),h(this,"_visibilityChangeEvt"),h(this,"_clonedPlayableAsset",!1),h(this,"_speed",1),h(this,"_guidsMap"),h(this,"_isPlaying",!1),h(this,"_internalUpdateRoutine"),h(this,"_isPaused",!1),h(this,"_isStopping",!1),h(this,"_time",0),h(this,"_duration",0),h(this,"_weight",1),h(this,"_animationTracks",[]),h(this,"_audioTracks",[]),h(this,"_signalTracks",[]),h(this,"_controlTracks",[]),h(this,"_customTracks",[]),h(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),h(this,"animationCallbackReceivers",[])}static registerCreateTrack(i,e){this.createTrackFunctions[i]=e}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(i){typeof i=="number"&&!Number.isNaN(i)?this._time=i:(Xp||qr())&&console.error("INVALID TIMELINE.TIME VALUE",i,this.name)}get duration(){return this._duration}set duration(i){this._duration=i}get weight(){return this._weight}set weight(i){this._weight=i}get speed(){return this._speed}set speed(i){this._speed=i}awake(){var i,e,t;Xp&&console.log(this,(i=this.playableAsset)==null?void 0:i.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(e=this.playableAsset)==null?void 0:e.tracks,Array.isArray((t=this.playableAsset)==null?void 0:t.tracks),this)}onEnable(){var i,e,t;for(const s of this._audioTracks)(i=s.onEnable)==null||i.call(s);for(const s of this._customTracks)(e=s.onEnable)==null||e.call(s);for(const s of this._animationTracks)(t=s.onEnable)==null||t.call(s);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var i,e,t;this.stop();for(const s of this._audioTracks)(i=s.onDisable)==null||i.call(s);for(const s of this._customTracks)(e=s.onDisable)==null||e.call(s);for(const s of this._animationTracks)(t=s.onDisable)==null||t.call(s);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var i;for(const e of this._allTracks)for(const t of e)(i=t.onDestroy)==null||i.call(t)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const i=this._isPaused==!0;if(this._isPaused=!1,i&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const e=[];for(const t of this._audioTracks){const s=t.loadAudio(this._time,1,0);s&&e.push(s)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!ms.userInteractionRegistered&&this.waitForAudio;)await kc(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Xs.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const t of this._audioTracks)t.stop();const i=this._isPaused==!0,e=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),i&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,i&&!e&&this.invokePauseChangedMethodsOnTracks(),e&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const i of this._allTracks)for(const e of i)yield e}get audioTracks(){return this._audioTracks}resolveGuids(i){this._guidsMap=i}invokePauseChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onPauseChanged)==null||i.call(e)}invokeStateChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onStateChanged)==null||i.call(e,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(i=!1){if(!this.isValid())return;let e=this._time;switch(this.extrapolationMode){case 0:this._speed>0?e=Math.min(e,this._duration):this._speed<0&&(e=Math.max(e,0)),this._time=e;break;case 1:e%=this._duration,this._time=e;break;case 2:if(e>this._duration){this.stop();return}break}const t=this._time;for(const s of this.playableAsset.tracks)if(!s.muted)switch(s.type){case Yn.Activation:if(!i&&!this._isPlaying)continue;for(let r=0;r<s.outputs.length;r++){const n=s.outputs[r];if(typeof n=="object"){let o=!1;if(s.clips)for(const l of s.clips)l.start<=t&&t<=l.end&&(o=!0);const a=n;a.visible!==void 0&&a.visible!==o&&(a.visible=o,Xp&&console.warn(this.name,"set ActivationTrack-"+r,a.name,o,t))}}break}if(!this._isStopping)for(const s of this._animationTracks)s.evaluate(t);for(const s of this._audioTracks)s.evaluate(t);for(const s of this._signalTracks)s.evaluate(t);for(const s of this._controlTracks)s.evaluate(t);for(const s of this._customTracks)s.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=t0(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const i=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let t=e.outputs.length-1;t>=0;t--){let s=e.outputs[t];if(typeof s=="string"){this._guidsMap&&this._guidsMap[s]&&(s=this._guidsMap[s]);const r=te.findByGuid(s,i);r===null||typeof r!="object"?(e.outputs.splice(t,1),console.warn("Failed to resolve binding",s,e.name,e.type)):(Xp&&console.log("Resolved binding",s,"to",r),e.outputs[t]=r)}else if(s===null){if(e.outputs.splice(t,1),bT.createTrackFunctions[e.type])continue;e.type!==Yn.Audio&&e.type!==Yn.Control&&e.type!==Yn.Marker&&e.type!==Yn.Signal&&console.warn("Missing binding",s,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===Yn.Control&&e.clips)for(let t=0;t<e.clips.length;t++){const s=e.clips[t];let r=s.asset.sourceObject;if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const n=te.findByGuid(r,i);n===null||typeof n!="object"?console.warn("Failed to resolve sourceObject binding",r,e.name,s):(Xp&&console.log("Resolved binding",r,"to",n),s.asset.sourceObject=n)}}}}findRoot(i){return i.parent?this.findRoot(i.parent):i}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const i of this.playableAsset.tracks)if(i.muted!==!0){if(i.clips)for(const e of i.clips)e.end>this._duration&&(this._duration=e.end);if(i.markers)for(const e of i.markers)e.time>this._duration&&(this._duration=e.time+.001)}}}setupAndCreateTrackHandlers(){var i,e,t;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let s=te.findObjectOfType(hh,this.context);for(const r of this.playableAsset.tracks){const n=r.type,o=bT.createTrackFunctions[n];if(o!=null){const a=o(this,r);if(typeof a.evaluate=="function"){a.director=this,a.track=r,this._customTracks.push(a);continue}}if(r.type===Yn.Animation){if(!r.clips||r.clips.length<=0){Xp&&console.warn("Animation track has no clips",r);continue}for(let a=r.outputs.length-1;a>=0;a--){let l=r.outputs[a];if(l instanceof _e){const u=te.getOrAddComponent(l,mr);u&&(l=u)}const c=(i=l?.gameObject)==null?void 0:i.animations;if(c){const u=new C_;u.trackOffset=r.trackOffset,u.director=this,u.track=r;for(let d=0;d<r.clips.length;d++){const p=r.clips[d],f=p.asset;if(!f){console.error("MISSING anim model?","clip#"+d,p,r,this.playableAsset,this.name);continue}const m=f.clip;let A=m;if((typeof A=="string"||typeof A=="number")&&(A=c.find(g=>g.name===m)),!A){console.warn("Could not find animationClip for model",p,r.name,this.name,(e=this.playableAsset)==null?void 0:e.name);continue}l instanceof mr&&l.runtimeAnimatorController&&(l.__internalDidAwakeAndStart||l.initializeRuntimeAnimatorController(),l.runtimeAnimatorController.mixer||l.runtimeAnimatorController.bind(l),u.mixer=l.runtimeAnimatorController.mixer),u.mixer||(u.mixer=new Wy(l.gameObject)),u.clips.push(A),u.mixer.uncacheAction(A),u.createHooks(p.asset,A);const v=u.mixer.clipAction(A);u.actions.push(v),u.models.push(p)}this._animationTracks.push(u)}}}else if(r.type===Yn.Audio){if(!r.clips||r.clips.length<=0)continue;const a=new Zg;a.director=this,a.track=r,a.audioSource=r.outputs.find(l=>l instanceof ms),this._audioTracks.push(a),s||(s=(t=this.context.mainCameraComponent)==null?void 0:t.gameObject.addNewComponent(hh)),a.listener=s.listener;for(let l=0;l<r.clips.length;l++){const c=r.clips[l];a.addModel(c)}}else if(r.type===Yn.Marker){const a=new $g;if(a.director=this,a.track=r,r.markers)for(const l of r.markers)switch(l.type){case yT.Signal:a.models.push(l),a.didTrigger.push(!1);break}if(a!==null&&a.models.length>0){const l=te.getComponent(this.gameObject,Wp);l&&(a.receivers.push(l),this._signalTracks.push(a))}}else if(r.type===Yn.Signal){const a=new $g;if(a.director=this,a.track=r,r.markers)for(const l of r.markers)a.models.push(l),a.didTrigger.push(!1);for(const l of r.outputs)a.receivers.push(l);this._signalTracks.push(a)}else if(r.type===Yn.Control){const a=new E_;if(a.director=this,a.track=r,r.clips)for(const l of r.clips)a.models.push(l);a.resolveSourceObjects(this.context),this._controlTracks.push(a)}}}setAudioTracksAllowPlaying(i){for(const e of this._audioTracks)e.onAllowAudioChanged(i)}registerAnimationCallback(i){this.animationCallbackReceivers.push(i)}unregisterAnimationCallback(i){const e=this.animationCallbackReceivers.indexOf(i);e!==-1&&this.animationCallbackReceivers.splice(e,1)}};let Pu=bT;h(Pu,"createTrackFunctions",{});const M_=Symbol("objectIsAnimatedData");function K3(i,e,t){if(!i)return;if(i[M_]===void 0){if(!t)return;i[M_]=new Set}const s=i[M_];t?s.add(e):s.has(e)&&s.delete(e)}function $ie(i){if(!i)return!1;const e=i[M_];return e!==void 0&&e.size>0}Mi.registerCallback(Hs.ContextCreated,i=>{const e=i.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true")&&i.files)for(const t of i.files)te.foreachComponent(t.file.scene,s=>{if(s.enabled!==!1){if(s instanceof Qn&&s.playAutomatically||s instanceof mr||s instanceof Pu&&s.playOnAwake===!0)return!0;if(s instanceof Qn)return s.playAutomatically=!0,!0;if(s instanceof Pu)return s.playOnAwake=!0,!0}},!0)!==!0&&ese(t.file)});function ese(i){if(!i||!i.animations)return;for(let t=0;t<i.animations.length;t++){const s=i.animations[t];if(!(!s.tracks||s.tracks.length<=0))for(const r in s.tracks){const n=s.tracks[r],o=n.__objectName??n.name.substring(0,n.name.indexOf("."));let a=i.scene.getObjectByName(o);if(!a&&(a=i.scene.getObjectByProperty("uuid",o),!a))continue;let l=e(a);l||(l=Nc(i.scene,new Qn));const c=l.animations=l.animations||[];s.name_animator=l.name,c.indexOf(s)<0&&c.push(s)}}function e(t){var s;if(!t)return;const r=(s=t.userData)==null?void 0:s.components;if(r&&r.length>0)for(let n=0;n<r.length;n++){const o=r[n];if(o instanceof mr||o instanceof Qn)return t}return e(t.parent)}}var tse=Object.defineProperty,ise=Object.getOwnPropertyDescriptor,T_=(i,e,t,s)=>{for(var r=s>1?void 0:s?ise(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&tse(e,t,r),r};const J3=oe("debuganimator");class mr extends Pe{constructor(){super(...arguments),h(this,"applyRootMotion",!1),h(this,"hasRootMotion",!1),h(this,"keepAnimatorControllerStateOnDisable",!1),h(this,"_parametersAreDirty",!1),h(this,"_isDirty",!1),h(this,"speed",1),h(this,"normalizedStartOffset",0),h(this,"_animatorController",null),h(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(e){var t;this._animatorController&&this._animatorController.model===e||(e?e instanceof Fo?(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 Fo(e.model)),this._animatorController=e,this._animatorController.bind(this)):(J3&&console.log("Assign animator controller",e,this),this._animatorController=new Fo(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,s=Number.NEGATIVE_INFINITY,r=0){this.play(e,t,s,r)}play(e,t=-1,s=Number.NEGATIVE_INFINITY,r=0){var n;(n=this.runtimeAnimatorController)==null||n.play(e,t,s,r),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 s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getBool(e))!==t&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.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 s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getFloat(e))!==t&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.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 s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getInteger(e))!==t&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.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=Je.lerp(e.x,e.y,Math.random())}set minMaxOffsetNormalized(e){this.normalizedStartOffset=Je.lerp(e.x,e.y,Math.random()),this.runtimeAnimatorController&&(this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset)}awake(){J3&&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 s=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=s,s?(console.assert(this.runtimeAnimatorController!==s),this.runtimeAnimatorController=s,console.assert(this.runtimeAnimatorController===s),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,!$ie(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}T_([x()],mr.prototype,"applyRootMotion",2),T_([x()],mr.prototype,"hasRootMotion",2),T_([x()],mr.prototype,"keepAnimatorControllerStateOnDisable",2),T_([x()],mr.prototype,"runtimeAnimatorController",1);const qp=oe("debugusdzanimation"),_T=oe("debugusdzanimationserialization");class I_{constructor(e,t,s){h(this,"_start"),h(this,"ext"),h(this,"root"),h(this,"clip"),this.ext=e,this.root=t,this.clip=s}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 To{constructor(e,t,s){h(this,"clip"),h(this,"pos"),h(this,"rot"),h(this,"scale"),h(this,"root"),h(this,"target"),h(this,"duration",0),h(this,"useRootMotion",!1),this.root=e,this.target=t,this.clip=s,s?this.duration=s.duration:this.duration=1/this.frameRate;const r=te.getComponent(e,mr);r&&(this.useRootMotion=r.applyRootMotion)}get frameRate(){return 60}addTrack(e){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it \u2013 this is likely a bug");return}e.name.endsWith("position")&&(this.pos=e),e.name.endsWith("quaternion")&&(this.rot=e),e.name.endsWith("scale")&&(this.scale=e)}getFrames(){var e,t,s,r,n,o;return this.clip?Math.max(((t=(e=this.pos)==null?void 0:e.times)==null?void 0:t.length)??0,((r=(s=this.rot)==null?void 0:s.times)==null?void 0:r.length)??0,((o=(n=this.scale)==null?void 0:n.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(e=!0,t=!0,s=!0){var r,n,o;if(!this.clip)return[0,this.duration];const a=(r=this.pos)==null?void 0:r.times,l=(n=this.rot)==null?void 0:n.times,c=(o=this.scale)==null?void 0:o.times,u=[];if(e&&a)for(const d of a)u.push(d);if(t&&l)for(const d of l)u.push(d);if(s&&c)for(const d of c)u.push(d);return u.includes(0)||u.push(0),u.sort((d,p)=>d-p),[...new Set(u)]}*getValues(e,t=!0,s=!0,r=!0){var n,o,a;const l=new w,c=new Ce,u=new w(1,1,1),d=this.target,p=t?(n=this.pos)==null?void 0:n.createInterpolant():void 0,f=s?(o=this.rot)==null?void 0:o.createInterpolant():void 0,m=r?(a=this.scale)==null?void 0:a.createInterpolant():void 0;p||l.set(d.position.x,d.position.y,d.position.z),f||c.set(d.quaternion.x,d.quaternion.y,d.quaternion.z,d.quaternion.w),m||u.set(d.scale.x,d.scale.y,d.scale.z);for(let A=0;A<e.length;A++){const v=e[A];if(p){const g=p.evaluate(v);l.set(g[0],g[1],g[2])}if(f){const g=f.evaluate(v);c.set(g[0],g[1],g[2],g[3])}if(m){const g=m.evaluate(v);u.set(g[0],g[1],g[2])}if(this.useRootMotion&&d===this.root){const g=new Te;g.compose(l,c,u),g.multiply(d.matrix),g.decompose(l,c,u)}yield{time:v,translation:l,rotation:c,scale:u,index:A}}}}h(To,"animationDurationPadding",1);class ev{constructor(e){h(this,"dict",new Map),h(this,"rootTargetMap",new Map),h(this,"rootAndClipToRegisteredAnimationMap",new Map),h(this,"rootToRegisteredClipCount",new Map),h(this,"serializers",[]),h(this,"injectRestPoses",!1),h(this,"injectImplicitBehaviours",!1),this.injectRestPoses=e,this.injectImplicitBehaviours=e}get extensionName(){return"animation"}getClipCount(e){let t=this.rootToRegisteredClipCount.get(e);return this.injectRestPoses&&(t=t?t-1:0),t??0}getStartTime01(e,t){const s=this.rootTargetMap.get(e);if(!s)return 0;const r=this.dict.get(s[0]);if(!r)return console.error("Trying to get start time for root that has no animation data",e,t,...this.dict),0;let n=0;for(let o=0;o<r.length&&r[o].clip!==t;o++)n+=r[o].getDuration()+To.animationDurationPadding;return n}registerAnimation(e,t){if(!t||!e)return null;this.rootTargetMap.has(e)||this.rootTargetMap.set(e,[]);const s=e.uuid+t.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(s))return this.rootAndClipToRegisteredAnimationMap.get(s);qp&&console.log("registerAnimation",e,t);const r=this.injectRestPoses?1:0,n=this.rootToRegisteredClipCount.get(e)??r,o=this.rootTargetMap.get(e),a=new Set(o);if(t.tracks)for(const c of t.tracks){const u=jt.parseTrackName(c.name),d=jt.findNode(e,u.nodeName);if(!d){console.warn("no object found for track",c.name,"using "+e.name+" instead");continue}this.dict.has(d)||this.dict.set(d,[]);const p=this.dict.get(d);if(!p)continue;if(a.delete(d),this.injectRestPoses&&!p[0]){const m=new To(null,d,void 0);p[0]=m}let f=p[n];f||(f=new To(e,d,t),p[n]=f),f.addTrack(c),o!=null&&o.includes(d)||o==null||o.push(d)}for(const c of a){const u=this.dict.get(c);if(!u)continue;if(this.injectRestPoses&&!u[0]){const p=new To(null,c,void 0);u[0]=p}let d=u[n];d||(qp&&console.log("Adding padding clip for ",c,t),d=new To(e,c,t),u[n]=d)}const l=new I_(this,e,t);return this.rootAndClipToRegisteredAnimationMap.set(s,l),this.rootToRegisteredClipCount.set(e,n+1),l}onAfterHierarchy(e){qp&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(e){var t,s;for(const r of this.serializers){const n=(t=r.model)==null?void 0:t.parent,o=n?.isDynamic===!0;_T&&console.log(o,(s=r.model)==null?void 0:s.parent),o&&r.registerCallback(n)}}onExportObject(e,t,s){te.foreachComponent(e,n=>{const o=n;typeof o.createAnimation=="function"&&o.createAnimation(this,t,s)},!1);const r=new sse(e,this.dict);this.serializers.push(r),r.registerCallback(t)}}class sse{constructor(e,t){h(this,"object"),h(this,"dict"),h(this,"model"),h(this,"callback"),this.object=e,this.dict=t}registerCallback(e){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),_T&&console.log("REPARENT",e),this.model=e,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(e,t){const s=this.model,r=this.dict;if(s&&s.skinnedMesh){let n=function(M){const R=[];for(const[E,C]of M){let U=`${E} : [`;const G=[];for(const F of C)G.push(`(${Ys(F.x)}, ${Ys(F.y)}, ${Ys(F.z)})`);U=U.concat(G.join(", ")),U=U.concat("],"),R.push(U)}return R},o=function(M){const R=[];for(const[E,C]of M){let U=`${E} : [`;const G=[];for(const F of C)G.push(`(${Ys(F.w)}, ${Ys(F.x)}, ${Ys(F.y)}, ${Ys(F.z)})`);U=U.concat(G.join(", ")),U=U.concat("],"),R.push(U)}return R},a=function(M){let R=!0,E;for(const[U,G]of M)if(E===void 0&&(E=G.length),E!==G.length){R=!1;break}qp&&console.log("Bone count: ",M.size,"TransformData entries per bone: ",E),console.assert(R,"All bones should have the same number of TransformData entries",M);const C=[];for(const[U,G]of M){const F=new Array;let Q=0;for(let K=0;K<G.length;K++)F.push(Q),Q+=G[K].getDuration()+To.animationDurationPadding;for(let K=0;K<G.length;K++){const z=G[K],O=F[K];C.length<=K&&C.push({pos:[],rot:[],scale:[],timeOffset:O});const j=C[K];j.pos.push(...z.getSortedTimesArray(!0,!1,!1)),j.rot.push(...z.getSortedTimesArray(!1,!0,!1)),j.scale.push(...z.getSortedTimesArray(!1,!1,!0))}}for(const U of C)U.pos.sort((G,F)=>G-F),U.rot.sort((G,F)=>G-F),U.scale.sort((G,F)=>G-F),U.pos=[...new Set(U.pos)],U.rot=[...new Set(U.rot)],U.scale=[...new Set(U.scale)];return C},l=function(M,R,E){const C=new Map,U=new Map,G=new Map,F=R.length;for(const Q of E){const K=M.get(Q);let z;K?console.assert(K.length===F,"We should have the same number of TransformData entries for each bone",K,R):z=new To(null,Q,void 0);for(let O=0;O<F;O++){const j=K?K[O]:z,se=R[O];for(const{time:$,translation:X}of j.getValues(se.pos,!0,!1,!1)){const ie=($+se.timeOffset)*60;C.has(ie)||C.set(ie,new Array),C.get(ie).push(X.clone())}for(const{time:$,rotation:X}of j.getValues(se.rot,!1,!0,!1)){const ie=($+se.timeOffset)*60;U.has(ie)||U.set(ie,new Array),U.get(ie).push(X.clone())}for(const{time:$,scale:X}of j.getValues(se.scale,!1,!1,!0)){const ie=($+se.timeOffset)*60;G.has(ie)||G.set(ie,new Array),G.get(ie).push(X.clone())}}}return{position:C.size==0?void 0:C,quaternion:U.size==0?void 0:U,scale:G.size==0?void 0:G}},c=function(M){const R=[];for(const E of M)R.push(`(${Ys(E.x)}, ${Ys(E.y)}, ${Ys(E.z)})`);return R.join(", ")},u=function(M){const R=[];for(const E of M)R.push(`(${Ys(E.w)}, ${Ys(E.x)}, ${Ys(E.y)}, ${Ys(E.z)})`);return R.join(", ")},d=function(M){const R=new Map;if(qp){const E=new Array;for(const[C,U]of r)E.push(C.uuid+": "+U.length+" "+U.map(G=>{var F;return(F=G.clip)==null?void 0:F.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
5189
+ `,o={map:{value:e},height:{value:t.height||15},radius:{value:t.radius||100}},a=new fA(1,16),l=new It({uniforms:o,fragmentShader:n,vertexShader:r,side:yi});super(a,l)}set radius(e){this.material.uniforms.radius.value=e}get radius(){return this.material.uniforms.radius.value}set height(e){this.material.uniforms.height.value=e}get height(){return this.material.uniforms.height.value}}var jie=Object.defineProperty,Gie=Object.getOwnPropertyDescriptor,fr=(i,e,t,s)=>{for(var r=s>1?void 0:s?Gie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&jie(e,t,r),r};const __=oe("freecam"),Wg=oe("debugcamerafit"),x_=oe("smoothcam"),Qie={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let vT;class Xg extends CustomEvent{constructor(e,t){super("target-reached",{detail:{controls:e,type:t}})}}class ki extends Pe{constructor(){super(...arguments),h(this,"autoFit",!1),h(this,"enableRotate",!0),h(this,"autoRotate",!1),h(this,"autoRotateSpeed",1),h(this,"enableKeys",!0),h(this,"enableDamping",!0),h(this,"dampingFactor",.1),h(this,"enableZoom",!0),h(this,"minZoom",0),h(this,"maxZoom",1/0),h(this,"enablePan",!0),h(this,"lookAtConstraint",null),h(this,"lookAtConstraint01",1),h(this,"allowInterrupt",!0),h(this,"middleClickToFocus",!0),h(this,"doubleClickToFocus",!0),h(this,"useSlerp",!0),h(this,"debugLog",!1),h(this,"targetLerpDuration",1),h(this,"autoTarget",!0),h(this,"_controls",null),h(this,"_cameraObject",null),h(this,"_lookTargetLerpActive",!1),h(this,"_lookTargetStartPosition",new w),h(this,"_lookTargetEndPosition",new w),h(this,"_lookTargetLerp01",0),h(this,"_lookTargetLerpDuration",0),h(this,"_cameraLerpActive",!1),h(this,"_cameraStartPosition",new w),h(this,"_cameraEndPosition",new w),h(this,"_cameraLerp01",0),h(this,"_cameraLerpDuration",0),h(this,"_inputs",0),h(this,"_enableTime",0),h(this,"_startedListeningToKeyEvents",!1),h(this,"_eventSystem"),h(this,"_afterHandleInputFn"),h(this,"_camera",null),h(this,"_syncedTransform"),h(this,"_didStart",!1),h(this,"targetElement",null),h(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),h(this,"_shouldDisable",!1),h(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(e){var t;(t=this.controls)==null||t.addEventListener("start",e)}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=te.getComponent(this.gameObject,Oi);if(e&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const t=ft(e.cam).length(),s=new w(0,0,-t).applyMatrix4(e.cam.matrixWorld);this.setLookTargetPosition(s,!0)}if(this.autoTarget&&!this.setLookTargetFromConstraint()){const t=new Nn;t.screenPoint=new ee(0,0),t.lineThreshold=.1;const s=this.context.physics.raycast(t);s.length>0&&this.setLookTargetPosition(s[0].point,!0),Wg&&console.log("OrbitControls hits",...s)}this.autoFit&&this.fitCamera()}this._eventSystem=Xn.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(gT.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var e,t;(e=this._controls)==null||e.dispose(),(t=this._eventSystem)==null||t.removeEventListener(gT.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const e=te.getComponent(this.gameObject,Oi);this._camera=e;const t=e?.cam;if(t&&W3(t,this,!0),!this._controls){if(!t){console.warn("OrbitControls: Requires a Camera component on the same object as this component.");return}t&&(this._cameraObject=t);const s=this.targetElement??this.context.renderer.domElement,r=t?.quaternion.clone();this._controls=new $te(t,s),t?.quaternion.copy(r),vT===void 0&&(vT={...this._controls.keys})}this._controls&&(__&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,bl()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),t?.type==="PerspectiveCamera"?__||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):__||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=te.getComponent(this.gameObject,lh)??void 0}onDisable(){var e;(e=this._camera)!=null&&e.cam&&W3(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 e,t;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)&&(e=this.context.input.getPointerPositionDelta(0))!=null&&e.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 s=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(s||(s=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),s&&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 Xg(this,"camera"));else{const r=Je.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,r)}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 Xg(this,"lookat"));else{const r=Je.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,r)}}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?vT:Qie,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 x_=="number"||x_===!0){this._controls.enableDamping=!0;const r=typeof x_=="number"?x_:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,r))}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||(!__&&(t=this.lookAtConstraint)!=null&&t.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update())}}setCameraAndLookTarget(e){if(!e||!(e instanceof _e))return;const t=ft(e),s=rC(e);this.setTargetFromRaycast(new Go(t,s)),this.setCameraTargetPosition(t)}setCameraTargetPosition(e,t=!1){var s,r;e&&(e instanceof _e&&(e=ft(e)),this._cameraEndPosition||(this._cameraEndPosition=new w),this._cameraEndPosition.copy(e),t===!0?(this._cameraLerpActive=!1,(s=this.controllerObject)==null||s.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((r=this._cameraObject)==null?void 0:r.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 _e&&(e=ft(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 s;if(!this._controls)return!1;const r=(s=this.lookAtConstraint)==null?void 0:s.sources;if(r&&r.length>0){const n=r[e];if(n)return n.getWorldPosition(this._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 t,s;if(!this.controls)return;const r=e?this.context.physics.raycastFromRay(e):this.context.physics.raycast();for(const n of r)if(n.distance>0&&te.isActiveInHierarchy(n.object)){const o=A_(n.object);if(o){const a=o.canvas;if(a!=null&&a.screenspace)break}if(this.setLookTargetPosition(n.point),this.context.mainCamera){const a=ft(this.context.mainCamera).clone().sub(this.controls.target).add(this._lookTargetEndPosition);(s=(t=this._cameraObject)==null?void 0:t.parent)==null||s.worldToLocal(a),this.setCameraTargetPosition(a)}break}}fitCamera(e,t=1.1,s=!0){const r=this._cameraObject,n=this._controls;if(e!=null&&e.length||(e=this.context.scene.children),e.length<=0||!r||!n)return;const o=new w,a=new w,l=new xs;l.makeEmpty();const c=[];function u(b){let y=!0;if(b.visible&&zie(b)!==!1&&!(b.type==="TransformControlsGizmo"||b.type==="TransformControlsPlane")&&(b instanceof US&&(y=!1),b instanceof LS&&(y=!1),b instanceof q3&&(y=!1),b.material instanceof Uy&&(y=!1),b instanceof ge||(y=!1),b!==r&&b.isUI!==!0)){if(y){Wg&&console.log(b.name,b.type,b);const _=b.children;b.children=c;const S=b.position,T=b.scale;if(Number.isNaN(S.x)||Number.isNaN(S.y)||Number.isNaN(S.z)){console.warn(`Object "${b.name}" has NaN values in position or scale.... will ignore it`,S,T);return}l.expandByObject(b,!0),b.children=_}for(const _ of b.children)u(_)}}for(const b of e)b.updateMatrixWorld(),u(b);if(r.updateMatrixWorld(),r.updateProjectionMatrix(),l.getCenter(a),l.applyMatrix4(r.matrixWorldInverse),l.getSize(o),l.setFromCenterAndSize(a,o),Number.isNaN(o.x)||Number.isNaN(o.y)||Number.isNaN(o.z)){console.warn("Camera fit size resultet in NaN",r,l,[...e]);return}if(o.length()<=1e-10){Wg&&console.warn("Camera fit size is zero",l,[...e]);return}const d=r.fov,p=2*Math.atan(Math.tan(d*Math.PI/360/2)*r.aspect)/Math.PI*360,f=o.y/(2*Math.atan(Math.PI*d/360)),m=o.x/(2*Math.atan(Math.PI*p/360)),A=t*Math.max(f,m)+o.z/2;Wg&&console.log("Fit camera to objects",f,m,"distance",A);const v=ft(r),g=n.target.clone().sub(v).normalize().multiplyScalar(A);if(n.maxDistance=A*10,n.minDistance=A*.01,this.setLookTargetPosition(a,s),this.autoTarget=!1,r.near=A/100,r.far=A*100,r.updateMatrixWorld(),r.updateProjectionMatrix(),r.parent){const b=r.parent.worldToLocal(n.target.clone().sub(g));this.setCameraTargetPosition(b,s)}else console.error(`Can not fit camera ${r.name} because it has no parent`);if(Wg){const b=new US(l);this.context.scene.add(b),nC(b,Dm(r)),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",y=>{y.code==="KeyF"&&this.fitCamera(e)}))}n.update()}}fr([x()],ki.prototype,"autoFit",2),fr([x()],ki.prototype,"enableRotate",2),fr([x()],ki.prototype,"autoRotate",2),fr([x()],ki.prototype,"autoRotateSpeed",2),fr([x()],ki.prototype,"enableKeys",2),fr([x()],ki.prototype,"enableDamping",2),fr([x()],ki.prototype,"dampingFactor",2),fr([x()],ki.prototype,"enableZoom",2),fr([x()],ki.prototype,"minZoom",2),fr([x()],ki.prototype,"maxZoom",2),fr([x()],ki.prototype,"enablePan",2),fr([x(Fg)],ki.prototype,"lookAtConstraint",2),fr([x()],ki.prototype,"lookAtConstraint01",2),fr([x()],ki.prototype,"allowInterrupt",2),fr([x()],ki.prototype,"middleClickToFocus",2),fr([x()],ki.prototype,"doubleClickToFocus",2),fr([x()],ki.prototype,"targetLerpDuration",2);var Hie=Object.defineProperty,Vie=Object.getOwnPropertyDescriptor,qn=(i,e,t,s)=>{for(var r=s>1?void 0:s?Vie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Hie(e,t,r),r},Iu=(i=>(i[i.Skybox=1]="Skybox",i[i.SolidColor=2]="SolidColor",i[i.Uninitialized=4]="Uninitialized",i))(Iu||{});const Ru=oe("debugcam"),Y3=oe("debugscreenpointtoray");var w_;const qg=(w_=class extends Pe{constructor(){super(...arguments),h(this,"_nearClipPlane",.1),h(this,"_farClipPlane",1e3),h(this,"orthographic",!1),h(this,"orthographicSize",5),h(this,"ARBackgroundAlpha",0),h(this,"_cullingMask",4294967295),h(this,"_backgroundBlurriness"),h(this,"_backgroundIntensity"),h(this,"_environmentIntensity"),h(this,"_targetTexture",null),h(this,"_backgroundColor"),h(this,"_fov"),h(this,"_cam",null),h(this,"_clearFlags",2),h(this,"_skybox")}get isCamera(){return!0}get aspect(){return this._cam instanceof qt?this._cam.aspect:this.context.domWidth/this.context.domHeight}get fieldOfView(){return this._cam instanceof qt?this._cam.fov:this._fov}set fieldOfView(i){const e=this.fieldOfView!=i;if(this._fov=i,e&&this._cam&&this._cam instanceof qt){if(this._fov===void 0){console.warn("Can not set undefined fov on PerspectiveCamera");return}this._cam.fov=this._fov,this._cam.updateProjectionMatrix()}}get nearClipPlane(){return this._nearClipPlane}set nearClipPlane(i){const e=this._nearClipPlane!=i;this._nearClipPlane=i,this._cam&&e&&(this._cam.near=i,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(i){const e=this._farClipPlane!=i;this._farClipPlane=i,this._cam&&e&&(this._cam.far=i,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(i){i!==this._clearFlags&&(this._clearFlags=i,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(i){this._cullingMask=i,this._cam&&(this._cam.layers.mask=i)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(i){this.cullingMask=(1<<i|0)>>>0}set backgroundBlurriness(i){i!==this._backgroundBlurriness&&(i===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(i,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(i){i!==this._backgroundIntensity&&(i===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(i,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(i){this._environmentIntensity=i}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(i){if(i){if(this._backgroundColor)this._backgroundColor.copy(i);else{if(!i.clone)return;this._backgroundColor=i.clone()}i.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(i){this._targetTexture=i}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(i,e,t){const s=this.cam,r=qg._origin;r.set(i,e,-1),this.context.input.convertScreenspaceToRaycastSpace(r),Y3&&console.log("screenPointToRay",i.toFixed(2),e.toFixed(2),"now:",r.x.toFixed(2),r.y.toFixed(2),"isInXR:"+this.context.isInXR),r.z=-1,r.unproject(s);const n=qg._direction.set(r.x,r.y,r.z),o=ft(s);return n.sub(o),n.normalize(),t?(t.set(o,n),t):new Go(o.clone(),n.clone())}awake(){Y3&&window.addEventListener("pointerdown",i=>{const e=i.clientX,t=i.clientY;console.log("touch",e.toFixed(2),t.toFixed(2));const s=this.screenPointToRay(e,t),r="#"+Math.floor(Math.random()*16777215).toString(16);Oa.DrawRay(s.origin,s.direction,r,10)})}onEnable(){Ru&&console.log(`Camera enabled: "${this.name}". ClearFlags=${Iu[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),Xie(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 i=this.context.renderer;if(i){const e=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,i),e?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const i=this.gameObject.isCamera;let e=null;if(i?(e=this.gameObject,e?.layers.enableAll(),e instanceof qt&&(this._fov=e.fov)):e=this.gameObject.children[0],e&&e.isCamera)e instanceof qt&&(this._fov&&(e.fov=this._fov),e.near=this._nearClipPlane,e.far=this._farClipPlane,e.updateProjectionMatrix());else if(!this.orthographic)e=new qt(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(e.fov=this.fieldOfView),this.gameObject.add(e);else{const t=this.orthographicSize*100;e=new fl(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){Ru&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,Ru){const i=`Camera "${this.name}" clear flags: ${Iu[this._clearFlags]}`;console.log(i)}switch(this._clearFlags){case 1:if(qg.backgroundShouldBeTransparent(this.context)&&(!this.ARBackgroundAlpha||this.ARBackgroundAlpha<.001)){this.context.scene.background=null,this.context.renderer.setClearColor(0,0);return}this.enableSkybox(),this._backgroundBlurriness!==void 0&&(this.context.scene.backgroundBlurriness=this._backgroundBlurriness),this._backgroundIntensity!==void 0&&(this.context.scene.backgroundIntensity=this._backgroundIntensity);break;case 2:if(this._backgroundColor){let i=this._backgroundColor.alpha;qg.backgroundShouldBeTransparent(this.context)&&(i=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,i)}else Ru&&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 Wie(this)),this._skybox.enable()}static backgroundShouldBeTransparent(i){var e,t,s,r;const n=(e=i.renderer.xr)==null?void 0:e.getSession();if(!n)return!1;if(typeof n._transparent=="boolean")return n._transparent;const o=n.environmentBlendMode;Ru&&cs("Environment blend mode: "+o+" on "+navigator.userAgent);let a=o==="additive"||o==="alpha-blend";return i.xrSessionMode===vg.ImmersiveAR&&o==="opaque"&&((t=navigator.userAgent)!=null&&t.includes("OculusBrowser")||(s=navigator.userAgent)!=null&&s.includes("Mozilla")&&(r=navigator.userAgent)!=null&&r.includes("Mobile WebXRViewer/v2"))&&(a=!0),n._transparent=a,a}},h(w_,"_origin",new w),h(w_,"_direction",new w),w_);let Oi=qg;qn([x()],Oi.prototype,"fieldOfView",1),qn([x()],Oi.prototype,"nearClipPlane",1),qn([x()],Oi.prototype,"farClipPlane",1),qn([x()],Oi.prototype,"clearFlags",1),qn([x()],Oi.prototype,"orthographic",2),qn([x()],Oi.prototype,"orthographicSize",2),qn([x()],Oi.prototype,"ARBackgroundAlpha",2),qn([x()],Oi.prototype,"cullingMask",1),qn([x()],Oi.prototype,"backgroundBlurriness",1),qn([x()],Oi.prototype,"backgroundIntensity",1),qn([x()],Oi.prototype,"environmentIntensity",1),qn([x(vi)],Oi.prototype,"backgroundColor",1),qn([x(_p)],Oi.prototype,"targetTexture",1);class Wie{constructor(e){h(this,"_camera"),h(this,"_skybox"),this._camera=e}get context(){var e;return(e=this._camera)==null?void 0:e.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(Ru&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.colorSpace=st,this._skybox.mapping=ro,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)),(Ru||Gt())&&Vs(`Camera "${this._camera.name}" has no skybox texture`))}}function Xie(i){oe("freecam")&&i.context.mainCameraComponent===i&&te.getOrAddComponent(i.gameObject,ki)}class hh extends Pe{constructor(){super(...arguments),h(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new XD),this._listener}awake(){ms.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const e=this.listener;if(e==null||e.parent)return;const t=this.context.mainCameraComponent||te.getComponentInParent(this.gameObject,Oi);t!=null&&t.cam?t.cam.add(e):this.gameObject.add(e)})}}var qie=Object.defineProperty,Yie=Object.getOwnPropertyDescriptor,S_=(i,e,t,s)=>{for(var r=s>1?void 0:s?Yie(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&qie(e,t,r),r};const Kie=oe("debugsignals");class Yg{constructor(){h(this,"guid")}}S_([x()],Yg.prototype,"guid",2);class Vp{constructor(){h(this,"signal"),h(this,"reaction")}}S_([x(Yg)],Vp.prototype,"signal",2),S_([x(hr)],Vp.prototype,"reaction",2);var AT;const Zl=(AT=class extends Pe{constructor(){super(...arguments),h(this,"events")}static invoke(i){if(Zl.receivers[i]){const e=Zl.receivers[i];if(!e)return;for(const t of e)t.invoke(i)}}awake(){Kie&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const i of this.events)Zl.receivers[i.signal.guid]||(Zl.receivers[i.signal.guid]=[]),Zl.receivers[i.signal.guid].push(this)}onDisable(){if(this.events){for(const i of this.events)if(Zl.receivers[i.signal.guid]){const e=Zl.receivers[i.signal.guid].indexOf(this);e>=0&&Zl.receivers[i.signal.guid].splice(e,1)}}}invoke(i){if(!this.events||!Array.isArray(this.events))return;const e=typeof i=="object"?i.guid:i;for(const t of this.events)if(t.signal.guid===e)try{if(t.reaction){if(!t.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",t,this);continue}}else{console.warn("Missing reaction for signal",t,this);continue}t.reaction.invoke()}catch(s){console.error(s)}}},h(AT,"receivers",{}),AT);let Wp=Zl;S_([x(Vp)],Wp.prototype,"events",2);var Yn=(i=>(i.Activation="ActivationTrack",i.Animation="AnimationTrack",i.Audio="AudioTrack",i.Control="ControlTrack",i.Marker="MarkerTrack",i.Signal="SignalTrack",i))(Yn||{}),za=(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))(za||{}),yT=(i=>(i.Signal="SignalEmitter",i))(yT||{});const $l=oe("debugtimeline");class Kg{constructor(){h(this,"director"),h(this,"track")}get muted(){return this.track.muted}set muted(e){var t;e!==this.track.muted&&(this.track.muted=e,(t=this.onMuteChanged)==null||t.call(this))}*forEachClip(e=!1){var t;if((t=this.track)!=null&&t.clips)if(e)for(let s=this.track.clips.length-1;s>=0;s--)yield this.track.clips[s];else for(const s of this.track.clips)yield s}getClipTime(e,t){return t.clipIn+(e-t.start)*t.timeScale}getClipTimeNormalized(e,t){return(e-t.start)/t.duration}evaluateWeight(e,t,s,r=!0){if(t<0||t>=s.length)return 0;const n=s[t];if(r||e>=n.start&&e<=n.end){let o=1;const a=!1;if(n.easeInDuration>0){const l=Math.min((e-n.start)/n.easeInDuration,1);o*=l}if(n.easeOutDuration>0&&!a){const l=Math.min((n.end-e)/n.easeOutDuration,1);o*=l}return o}return 0}}class Jie{constructor(e){h(this,"clip"),h(this,"rootPositionOffset"),h(this,"rootQuaternionOffset"),h(this,"rootStartPosition"),h(this,"rootEndPosition"),h(this,"rootStartQuaternion"),h(this,"rootEndQuaternion");const t=e.getClip();this.clip=t;const s=e.getRoot(),r=s.name+".position",n=s.name+".quaternion";$l&&console.log(t.name,t.tracks,r);for(const o of t.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(r))this.rootStartPosition=new w().fromArray(o.values,0),this.rootEndPosition=new w().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),$l&&console.log(this.rootPositionOffset);else if(o.name.endsWith(n)&&(this.rootStartQuaternion=new Ce().fromArray(o.values,0),this.rootEndQuaternion=new Ce().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),$l)){const a=new ys().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",a)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class C_ extends Kg{constructor(){super(...arguments),h(this,"models",[]),h(this,"trackOffset"),h(this,"target"),h(this,"mixer"),h(this,"clips",[]),h(this,"actions",[]),h(this,"_actionOffsets",[]),h(this,"_didBind",!1),h(this,"_animator",null),h(this,"_useclipOffsets",!0),h(this,"_totalOffsetPosition",new w),h(this,"_totalOffsetRotation",new Ce),h(this,"_totalOffsetPosition2",new w),h(this,"_totalOffsetRotation2",new Ce),h(this,"_summedPos",new w),h(this,"_tempPos",new w),h(this,"_summedRot",new Ce),h(this,"_tempRot",new Ce),h(this,"_clipRotQuat",new Ce)}onStateChanged(){this._animator&&K3(this._animator.gameObject,this,this.director.isPlaying)}createHooks(e,t){var s,r;if(((s=t.tracks)==null?void 0:s.length)<=0){console.warn("No tracks in AnimationClip",t);return}const n=t.tracks[0].name.split("."),o=n[n.length-2],a=o+".position",l=o+".quaternion";let c=!1,u=!1;for(const d of t.tracks)d.name.endsWith(a)?(c=!0,this.createPositionInterpolant(t,e,d)):d.name.endsWith(l)&&(u=!0,this.createRotationInterpolant(t,e,d));if(!c||!u){const d=(r=this.mixer)==null?void 0:r.getRoot(),p=t.tracks[0],f=p.name.lastIndexOf("."),m=p.name.substring(0,f),A=m.substring(m.lastIndexOf(".")+1),v=d.getObjectByName(A);if(v)if(c){if(!u){const g=t.tracks[0].name.substring(0,f)+".quaternion";$l&&console.warn("Create quaternion track",A,v);const b=v.quaternion,y=new wa(g,[0,t.duration],[b.x,b.y,b.z,b.w,b.x,b.y,b.z,b.w]);t.tracks.push(y),this.createRotationInterpolant(t,e,y)}}else{const g=m+".position";$l&&console.warn("Create position track",A,v);const b=v.position,y=new gl(g,[0,t.duration],[b.x,b.y,b.z,b.x,b.y,b.z]);t.tracks.push(y),this.createPositionInterpolant(t,e,y)}}}bind(){if(!this._didBind){this._didBind=!0,$l&&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 Jie(e);this._actionOffsets.push(t)}this.target&&(this._animator=te.getComponent(this.target,mr)??null,this._animator&&K3(this._animator.gameObject,this,!0));for(const e of this.models){const t=e.asset,s=t.position,r=t.rotation;s&&s.x!==void 0&&(s.isVector3||(t.position=new w(s.x,s.y,s.z)),r.isQuaternion||(t.rotation=new Ce(r.x,r.y,r.z,r.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const e=this.trackOffset.position;e&&(e.isVector3||(this.trackOffset.position=new w(e.x,e.y,e.z)));const t=this.trackOffset.rotation;t&&(t.isQuaternion||(this.trackOffset.rotation=new Ce(t.x,t.y,t.z,t.w)))}}evaluate(e){var t,s,r,n,o,a,l;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let c=0,u=0,d=!1,p=!1,f=0;for(let m=0;m<this.clips.length;m++){const A=this.models[m],v=this.actions[m],g=A.asset;v.weight=0;const b=e>=A.start&&e<=A.end,y=A.preExtrapolationMode,_=A.postExtrapolationMode,S=m<this.clips.length-1?this.models[m+1]:null;let T=b,M=!1;if(!T&&!d&&A.end<e&&_!==za.None?(!S||S.start>e)&&(T=!0,d=!0):m==0&&!T&&!p&&A.start>e&&y!==za.None&&(!S||S.start<e)&&(T=!0,M=!0,p=!0),T){let R=1;R*=this.evaluateWeight(e,m,this.models,T),R*=this.director.weight;let E=b;if(M)switch(y){case za.Hold:break;case za.Loop:e+=A.start,E=!0;break;default:e+=A.start,E=!0;break}let C=this.getClipTime(e,A),U=0;const G=g.duration;if(M&&y===za.Hold&&(C=0),E){if(g.loop)for(U+=Math.floor(C/(G+1e-6));C>G;)C-=G}else if(!b&&d)switch(_){case za.Hold:C=this.getClipTime(A.end,A);break;case za.Loop:C%=G;break;case za.PingPong:const Q=Math.floor(C/G)%2!==0;C%=G,Q&&(C=G-C);break}A.reversed===!0?v.time=v.getClip().duration-C:v.time=C,v.timeScale=0;const F=Math.max(0,R);if(v.weight=F,f+=F,v.clampWhenFinished=!1,v.isRunning()||v.play(),this._useclipOffsets){const Q=c==0?this._totalOffsetPosition:this._totalOffsetPosition2,K=c==0?this._totalOffsetRotation:this._totalOffsetRotation2;c<1&&(u=1-R),c+=1;const z=this._summedPos.set(0,0,0),O=this._tempPos.set(0,0,0),j=this._summedRot.identity(),se=this._tempRot.identity(),$=g.rotation;$&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp($,R));const X=this._actionOffsets[m];if(X.hasOffsets)for(let ie=0;ie<U;ie++)X.rootPositionOffset?O.copy(X.rootPositionOffset):O.set(0,0,0),O.applyQuaternion(j),this._clipRotQuat&&O.applyQuaternion(this._clipRotQuat),X.rootQuaternionOffset&&(se.copy(X.rootQuaternionOffset),j.multiply(se)),z.add(O);this._clipRotQuat&&K.multiply(this._clipRotQuat),K.multiply(j),g.position&&z.add(g.position),Q.add(z)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,u),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,u)),this.__mixerError===void 0&&($l||Gt())&&(s=(t=this._animator)==null?void 0:t.runtimeAnimatorController)!=null&&s.mixer&&this.mixer!==((n=(r=this._animator)==null?void 0:r.runtimeAnimatorController)==null?void 0:n.mixer)&&(this.__mixerError=!0,console.error("AnimationTrack mixer is not shared with the animator controller - this might result in the timeline to not animate properly. Please report a bug to the Needle Engine team!",this)),(o=this._animator)!=null&&o.runtimeAnimatorController){const m=Math.max(0,1-f);(l=(a=this._animator)==null?void 0:a.runtimeAnimatorController)==null||l.update(m)}else this.mixer.update(e)}createRotationInterpolant(e,t,s){var r;const n=s.createInterpolant.bind(s),o=new Ce;this.ensureTrackOffsets();const a=(r=this.trackOffset)==null?void 0:r.rotation;s.createInterpolant=()=>{const l=n(),c=l.evaluate.bind(l);return l.evaluate=u=>{var d;const p=c(u);if(o.set(p[0],p[1],p[2],p[3]),o.premultiply(this._totalOffsetRotation),a&&o.premultiply(a),this.director.animationCallbackReceivers)for(const f of this.director.animationCallbackReceivers)(d=f?.onTimelineRotation)==null||d.call(f,this.director,this.target,u,o);return p[0]=o.x,p[1]=o.y,p[2]=o.z,p[3]=o.w,p},l}}createPositionInterpolant(e,t,s){var r,n;const o=s.createInterpolant.bind(s),a=new w;this.ensureTrackOffsets();const l=(r=this.trackOffset)==null?void 0:r.rotation,c=(n=this.trackOffset)==null?void 0:n.position;let u;s.createInterpolant=()=>{const d=o(),p=d.evaluate.bind(d);return d.evaluate=f=>{var m,A,v;const g=p(f);if(a.set(g[0],g[1],g[2]),t.removeStartOffset&&(u===void 0?(u=null,u=(A=(m=this._actionOffsets.find(b=>b.clip===e))==null?void 0:m.rootStartPosition)==null?void 0:A.clone()):u!=null&&u.isVector3&&a.sub(u)),a.applyQuaternion(this._totalOffsetRotation),a.add(this._totalOffsetPosition),l&&a.applyQuaternion(l),c&&(a.x-=c.x,a.y+=c.y,a.z+=c.z),this.director.animationCallbackReceivers)for(const b of this.director.animationCallbackReceivers)(v=b?.onTimelinePosition)==null||v.call(b,this.director,this.target,f,a);return g[0]=a.x,g[1]=a.y,g[2]=a.z,g},d}}}const Zie=oe("mutetimeline"),Jg=class extends Kg{constructor(){super(...arguments),h(this,"models",[]),h(this,"listener"),h(this,"audio",[]),h(this,"audioContextTimeOffset",[]),h(this,"lastTime",0),h(this,"audioSource"),h(this,"_audioLoader",null)}getAudioFilePath(i){const e=this.director.sourceId;return yl(e,i)}onAllowAudioChanged(i){for(let e=0;e<this.models.length;e++){const t=this.models[e];this.audio[e].setVolume(i?t.asset.volume:0)}}addModel(i){const e=new RS(this.listener);this.audio.push(e),this.models.push(i)}onDisable(){for(const i of this.audio)i.isPlaying&&i.stop()}onDestroy(){for(const i of this.audio)i.source&&i?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}stop(){for(let i=0;i<this.audio.length;i++){const e=this.audio[i];e!=null&&e.isPlaying&&e.stop()}}evaluate(i){if(Zie||this.track.muted||this.director.speed<0)return;const e=this.director.context.application.muted,t=e?.1:0;for(let s=0;s<this.models.length;s++){const r=this.models[s],n=this.audio[s],o=r.asset;if((!n||!n.buffer)&&this.isInTimeRange(r,i-1,i+1)&&this.handleAudioLoading(r,n),ms.userInteractionRegistered!==!1&&!(n===null||!n.buffer))if(n.playbackRate=this.director.context.time.timeScale*this.director.speed,n.loop=o.loop,i>=r.start&&i<=r.end&&i<this.director.duration){if(this.director.isPlaying==!1){if(n.isPlaying&&n.stop(),this.lastTime===i)continue}else if(!n.isPlaying)n.offset=r.clipIn+(i-r.start)*r.timeScale,n.play(t);else{const l=r.clipIn+(i-r.start)*r.timeScale,c=n.context.currentTime-n._startedAt+n.offset;Math.abs(l-c)>.3&&(n.offset=l,n.stop(),n.play(t))}let a=o.volume;if(this.track.volume!==void 0&&(a*=this.track.volume),e&&(a=0),r.easeInDuration>0){const l=Math.min((i-r.start)/r.easeInDuration,1);a*=l}if(r.easeOutDuration>0){const l=Math.min((r.end-i)/r.easeOutDuration,1);a*=l}n.setVolume(a*this.director.weight)}else n.isPlaying&&n.stop()}this.lastTime=i}loadAudio(i,e=0,t=0){let s=null;const r=i-t,n=i+e;for(const o of this.models)if(this.isInTimeRange(o,r,n)){const a=this.audio[this.models.indexOf(o)],l=this.handleAudioLoading(o,a);l!==null&&(s===null&&(s=[]),s.push(l))}return s!==null?Promise.all(s):null}isInTimeRange(i,e,t){return e<=i.start&&t>=i.end||e>=i.start&&e<=i.end||t>=i.start&&t<=i.end}static dispose(){Jg._audioBuffers.clear()}handleAudioLoading(i,e){this._audioLoader||(this._audioLoader=new Vy);const t=this.getAudioFilePath(i.asset.clip);if(Jg._audioBuffers.get(t)){const r=Jg._audioBuffers.get(t);return r.then(n=>{n&&e.setBuffer(n)}),r}$l&&console.warn("LOAD audio track",t,this.director.sourceId);const s=new Promise((r,n)=>{this._audioLoader.load(t,o=>{e.setBuffer(o),r(o)},void 0,o=>{console.error("Error loading audio",o),r(null)})});return Jg._audioBuffers.set(t,s),s}};let Zg=Jg;h(Zg,"_audioBuffers",new Map);class $g extends Kg{constructor(){super(...arguments),h(this,"models",[]),h(this,"didTrigger",[]),h(this,"receivers",[])}evaluate(e){var t;if(this.track.muted)return;const s=this.director.context.time.deltaTime*1.5;for(let r=0;r<this.models.length;r++){const n=this.models[r],o=this.didTrigger[r],a=n.time-e;let l=!1;if(n.retroActive)l=a<=1e-6;else{const c=Math.abs(a);(c===0||c>=1e-5&&c<s)&&(l=!0)}if(l){if(!o)if($l&&console.log("Trigger signal",e,n.time,n),this.didTrigger[r]=!0,((t=this.receivers)==null?void 0:t.length)<=0)Wp.invoke(n.asset);else for(const c of this.receivers)c&&c.invoke(n.asset)}else n.emitOnce||(this.didTrigger[r]=!1)}}}class E_ extends Kg{constructor(){super(...arguments),h(this,"models",[]),h(this,"timelines",[]),h(this,"_previousActiveModel",null)}resolveSourceObjects(e){for(let t=this.models.length-1;t>=0;t--){const s=this.models[t].asset;if(!s.sourceObject||typeof s.sourceObject!="object"){console.log("no source object, removing model",t,s),this.models.splice(t,1);continue}else{const r=te.getComponent(s.sourceObject,Pu);this.timelines.push(r),r&&s.updateDirector&&(r.playOnAwake=!1)}}}evaluate(e){var t;this._previousActiveModel=null;for(let s=0;s<this.models.length;s++){const r=this.models[s],n=r.asset;if(e>=r.start&&e<=r.end){this._previousActiveModel=r;const o=this.getClipTime(e,r);if(n.controlActivation){const a=n.sourceObject;a.visible=!0}if(n.updateDirector){const a=this.timelines[s];a&&(a.isPlaying&&a.pause(),a.time=o,a.evaluate())}}else{const o=(t=this._previousActiveModel)==null?void 0:t.asset;if(n.controlActivation){const a=n.sourceObject;o?.sourceObject!==a&&(a.visible=!1)}}}}}const Xp=oe("debugtimeline"),bT=class extends Pe{constructor(){super(...arguments),h(this,"playableAsset"),h(this,"playOnAwake"),h(this,"extrapolationMode",1),h(this,"waitForAudio",!0),h(this,"_visibilityChangeEvt"),h(this,"_clonedPlayableAsset",!1),h(this,"_speed",1),h(this,"_guidsMap"),h(this,"_isPlaying",!1),h(this,"_internalUpdateRoutine"),h(this,"_isPaused",!1),h(this,"_isStopping",!1),h(this,"_time",0),h(this,"_duration",0),h(this,"_weight",1),h(this,"_animationTracks",[]),h(this,"_audioTracks",[]),h(this,"_signalTracks",[]),h(this,"_controlTracks",[]),h(this,"_customTracks",[]),h(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),h(this,"animationCallbackReceivers",[])}static registerCreateTrack(i,e){this.createTrackFunctions[i]=e}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(i){typeof i=="number"&&!Number.isNaN(i)?this._time=i:(Xp||qr())&&console.error("INVALID TIMELINE.TIME VALUE",i,this.name)}get duration(){return this._duration}set duration(i){this._duration=i}get weight(){return this._weight}set weight(i){this._weight=i}get speed(){return this._speed}set speed(i){this._speed=i}awake(){var i,e,t;Xp&&console.log(this,(i=this.playableAsset)==null?void 0:i.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(e=this.playableAsset)==null?void 0:e.tracks,Array.isArray((t=this.playableAsset)==null?void 0:t.tracks),this)}onEnable(){var i,e,t;for(const s of this._audioTracks)(i=s.onEnable)==null||i.call(s);for(const s of this._customTracks)(e=s.onEnable)==null||e.call(s);for(const s of this._animationTracks)(t=s.onEnable)==null||t.call(s);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var i,e,t;this.stop();for(const s of this._audioTracks)(i=s.onDisable)==null||i.call(s);for(const s of this._customTracks)(e=s.onDisable)==null||e.call(s);for(const s of this._animationTracks)(t=s.onDisable)==null||t.call(s);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var i;for(const e of this._allTracks)for(const t of e)(i=t.onDestroy)==null||i.call(t)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const i=this._isPaused==!0;if(this._isPaused=!1,i&&this.invokePauseChangedMethodsOnTracks(),!this._isPlaying){if(this._isPlaying=!0,this.waitForAudio){const e=[];for(const t of this._audioTracks){const s=t.loadAudio(this._time,1,0);s&&e.push(s)}if(e.length>0&&(await Promise.all(e),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!ms.userInteractionRegistered&&this.waitForAudio;)await kc(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Xs.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const t of this._audioTracks)t.stop();const i=this._isPaused==!0,e=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),i&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,i&&!e&&this.invokePauseChangedMethodsOnTracks(),e&&this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine&&this.stopCoroutine(this._internalUpdateRoutine),this._internalUpdateRoutine=null,this._isStopping=!1}evaluate(){this.internalEvaluate(!0)}isValid(){return this.playableAsset&&this.playableAsset.tracks&&Array.isArray(this.playableAsset.tracks)}*forEachTrack(){for(const i of this._allTracks)for(const e of i)yield e}get audioTracks(){return this._audioTracks}resolveGuids(i){this._guidsMap=i}invokePauseChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onPauseChanged)==null||i.call(e)}invokeStateChangedMethodsOnTracks(){var i;for(const e of this.forEachTrack())(i=e.onStateChanged)==null||i.call(e,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(i=!1){if(!this.isValid())return;let e=this._time;switch(this.extrapolationMode){case 0:this._speed>0?e=Math.min(e,this._duration):this._speed<0&&(e=Math.max(e,0)),this._time=e;break;case 1:e%=this._duration,this._time=e;break;case 2:if(e>this._duration){this.stop();return}break}const t=this._time;for(const s of this.playableAsset.tracks)if(!s.muted)switch(s.type){case Yn.Activation:if(!i&&!this._isPlaying)continue;for(let r=0;r<s.outputs.length;r++){const n=s.outputs[r];if(typeof n=="object"){let o=!1;if(s.clips)for(const l of s.clips)l.start<=t&&t<=l.end&&(o=!0);const a=n;a.visible!==void 0&&a.visible!==o&&(a.visible=o,Xp&&console.warn(this.name,"set ActivationTrack-"+r,a.name,o,t))}}break}if(!this._isStopping)for(const s of this._animationTracks)s.evaluate(t);for(const s of this._audioTracks)s.evaluate(t);for(const s of this._signalTracks)s.evaluate(t);for(const s of this._controlTracks)s.evaluate(t);for(const s of this._customTracks)s.evaluate(t)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=t0(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const i=this.findRoot(this.gameObject);for(const e of this.playableAsset.tracks){for(let t=e.outputs.length-1;t>=0;t--){let s=e.outputs[t];if(typeof s=="string"){this._guidsMap&&this._guidsMap[s]&&(s=this._guidsMap[s]);const r=te.findByGuid(s,i);r===null||typeof r!="object"?(e.outputs.splice(t,1),console.warn("Failed to resolve binding",s,e.name,e.type)):(Xp&&console.log("Resolved binding",s,"to",r),e.outputs[t]=r)}else if(s===null){if(e.outputs.splice(t,1),bT.createTrackFunctions[e.type])continue;e.type!==Yn.Audio&&e.type!==Yn.Control&&e.type!==Yn.Marker&&e.type!==Yn.Signal&&console.warn("Missing binding",s,e.name,e.type,this.name,this.playableAsset.name)}}if(e.type===Yn.Control&&e.clips)for(let t=0;t<e.clips.length;t++){const s=e.clips[t];let r=s.asset.sourceObject;if(typeof r=="string"){this._guidsMap&&this._guidsMap[r]&&(r=this._guidsMap[r]);const n=te.findByGuid(r,i);n===null||typeof n!="object"?console.warn("Failed to resolve sourceObject binding",r,e.name,s):(Xp&&console.log("Resolved binding",r,"to",n),s.asset.sourceObject=n)}}}}findRoot(i){return i.parent?this.findRoot(i.parent):i}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const i of this.playableAsset.tracks)if(i.muted!==!0){if(i.clips)for(const e of i.clips)e.end>this._duration&&(this._duration=e.end);if(i.markers)for(const e of i.markers)e.time>this._duration&&(this._duration=e.time+.001)}}}setupAndCreateTrackHandlers(){var i,e,t;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let s=te.findObjectOfType(hh,this.context);for(const r of this.playableAsset.tracks){const n=r.type,o=bT.createTrackFunctions[n];if(o!=null){const a=o(this,r);if(typeof a.evaluate=="function"){a.director=this,a.track=r,this._customTracks.push(a);continue}}if(r.type===Yn.Animation){if(!r.clips||r.clips.length<=0){Xp&&console.warn("Animation track has no clips",r);continue}for(let a=r.outputs.length-1;a>=0;a--){let l=r.outputs[a];if(l instanceof _e){const u=te.getOrAddComponent(l,mr);u&&(l=u)}const c=(i=l?.gameObject)==null?void 0:i.animations;if(c){const u=new C_;u.trackOffset=r.trackOffset,u.director=this,u.track=r;for(let d=0;d<r.clips.length;d++){const p=r.clips[d],f=p.asset;if(!f){console.error("MISSING anim model?","clip#"+d,p,r,this.playableAsset,this.name);continue}const m=f.clip;let A=m;if((typeof A=="string"||typeof A=="number")&&(A=c.find(g=>g.name===m)),!A){console.warn("Could not find animationClip for model",p,r.name,this.name,(e=this.playableAsset)==null?void 0:e.name);continue}l instanceof mr&&l.runtimeAnimatorController&&(l.__internalDidAwakeAndStart||l.initializeRuntimeAnimatorController(),l.runtimeAnimatorController.mixer||l.runtimeAnimatorController.bind(l),u.mixer=l.runtimeAnimatorController.mixer),u.mixer||(u.mixer=new Wy(l.gameObject)),u.clips.push(A),u.mixer.uncacheAction(A),u.createHooks(p.asset,A);const v=u.mixer.clipAction(A);u.actions.push(v),u.models.push(p)}this._animationTracks.push(u)}}}else if(r.type===Yn.Audio){if(!r.clips||r.clips.length<=0)continue;const a=new Zg;a.director=this,a.track=r,a.audioSource=r.outputs.find(l=>l instanceof ms),this._audioTracks.push(a),s||(s=(t=this.context.mainCameraComponent)==null?void 0:t.gameObject.addNewComponent(hh)),a.listener=s.listener;for(let l=0;l<r.clips.length;l++){const c=r.clips[l];a.addModel(c)}}else if(r.type===Yn.Marker){const a=new $g;if(a.director=this,a.track=r,r.markers)for(const l of r.markers)switch(l.type){case yT.Signal:a.models.push(l),a.didTrigger.push(!1);break}if(a!==null&&a.models.length>0){const l=te.getComponent(this.gameObject,Wp);l&&(a.receivers.push(l),this._signalTracks.push(a))}}else if(r.type===Yn.Signal){const a=new $g;if(a.director=this,a.track=r,r.markers)for(const l of r.markers)a.models.push(l),a.didTrigger.push(!1);for(const l of r.outputs)a.receivers.push(l);this._signalTracks.push(a)}else if(r.type===Yn.Control){const a=new E_;if(a.director=this,a.track=r,r.clips)for(const l of r.clips)a.models.push(l);a.resolveSourceObjects(this.context),this._controlTracks.push(a)}}}setAudioTracksAllowPlaying(i){for(const e of this._audioTracks)e.onAllowAudioChanged(i)}registerAnimationCallback(i){this.animationCallbackReceivers.push(i)}unregisterAnimationCallback(i){const e=this.animationCallbackReceivers.indexOf(i);e!==-1&&this.animationCallbackReceivers.splice(e,1)}};let Pu=bT;h(Pu,"createTrackFunctions",{});const M_=Symbol("objectIsAnimatedData");function K3(i,e,t){if(!i)return;if(i[M_]===void 0){if(!t)return;i[M_]=new Set}const s=i[M_];t?s.add(e):s.has(e)&&s.delete(e)}function $ie(i){if(!i)return!1;const e=i[M_];return e!==void 0&&e.size>0}Mi.registerCallback(Hs.ContextCreated,i=>{const e=i.context.domElement.getAttribute("autoplay");if(e!==void 0&&(e===""||e==="true")&&i.files)for(const t of i.files)te.foreachComponent(t.file.scene,s=>{if(s.enabled!==!1){if(s instanceof Qn&&s.playAutomatically||s instanceof mr||s instanceof Pu&&s.playOnAwake===!0)return!0;if(s instanceof Qn)return s.playAutomatically=!0,!0;if(s instanceof Pu)return s.playOnAwake=!0,!0}},!0)!==!0&&ese(t.file)});function ese(i){if(!i||!i.animations)return;for(let t=0;t<i.animations.length;t++){const s=i.animations[t];if(!(!s.tracks||s.tracks.length<=0))for(const r in s.tracks){const n=s.tracks[r],o=n.__objectName??n.name.substring(0,n.name.indexOf("."));let a=i.scene.getObjectByName(o);if(!a&&(a=i.scene.getObjectByProperty("uuid",o),!a))continue;let l=e(a);l||(l=Nc(i.scene,new Qn));const c=l.animations=l.animations||[];s.name_animator=l.name,c.indexOf(s)<0&&c.push(s)}}function e(t){var s;if(!t)return;const r=(s=t.userData)==null?void 0:s.components;if(r&&r.length>0)for(let n=0;n<r.length;n++){const o=r[n];if(o instanceof mr||o instanceof Qn)return t}return e(t.parent)}}var tse=Object.defineProperty,ise=Object.getOwnPropertyDescriptor,T_=(i,e,t,s)=>{for(var r=s>1?void 0:s?ise(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&tse(e,t,r),r};const J3=oe("debuganimator");class mr extends Pe{constructor(){super(...arguments),h(this,"applyRootMotion",!1),h(this,"hasRootMotion",!1),h(this,"keepAnimatorControllerStateOnDisable",!1),h(this,"_parametersAreDirty",!1),h(this,"_isDirty",!1),h(this,"speed",1),h(this,"normalizedStartOffset",0),h(this,"_animatorController",null),h(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(e){var t;this._animatorController&&this._animatorController.model===e||(e?e instanceof Fo?(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 Fo(e.model)),this._animatorController=e,this._animatorController.bind(this)):(J3&&console.log("Assign animator controller",e,this),this._animatorController=new Fo(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,s=Number.NEGATIVE_INFINITY,r=0){this.play(e,t,s,r)}play(e,t=-1,s=Number.NEGATIVE_INFINITY,r=0){var n;(n=this.runtimeAnimatorController)==null||n.play(e,t,s,r),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 s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getBool(e))!==t&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.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 s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getFloat(e))!==t&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.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 s,r;((s=this.runtimeAnimatorController)==null?void 0:s.getInteger(e))!==t&&(this._parametersAreDirty=!0),(r=this.runtimeAnimatorController)==null||r.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=Je.lerp(e.x,e.y,Math.random())}set minMaxOffsetNormalized(e){this.normalizedStartOffset=Je.lerp(e.x,e.y,Math.random()),this.runtimeAnimatorController&&(this.runtimeAnimatorController.normalizedStartOffset=this.normalizedStartOffset)}awake(){J3&&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 s=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=s,s?(console.assert(this.runtimeAnimatorController!==s),this.runtimeAnimatorController=s,console.assert(this.runtimeAnimatorController===s),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,!$ie(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}T_([x()],mr.prototype,"applyRootMotion",2),T_([x()],mr.prototype,"hasRootMotion",2),T_([x()],mr.prototype,"keepAnimatorControllerStateOnDisable",2),T_([x()],mr.prototype,"runtimeAnimatorController",1);const qp=oe("debugusdzanimation"),_T=oe("debugusdzanimationserialization");class I_{constructor(e,t,s){h(this,"_start"),h(this,"ext"),h(this,"root"),h(this,"clip"),this.ext=e,this.root=t,this.clip=s}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 To{constructor(e,t,s){h(this,"clip"),h(this,"pos"),h(this,"rot"),h(this,"scale"),h(this,"root"),h(this,"target"),h(this,"duration",0),h(this,"useRootMotion",!1),this.root=e,this.target=t,this.clip=s,s?this.duration=s.duration:this.duration=1/this.frameRate;const r=te.getComponent(e,mr);r&&(this.useRootMotion=r.applyRootMotion)}get frameRate(){return 60}addTrack(e){if(!this.clip){console.error("This is a rest clip but you're trying to add tracks to it \u2013 this is likely a bug");return}e.name.endsWith("position")&&(this.pos=e),e.name.endsWith("quaternion")&&(this.rot=e),e.name.endsWith("scale")&&(this.scale=e)}getFrames(){var e,t,s,r,n,o;return this.clip?Math.max(((t=(e=this.pos)==null?void 0:e.times)==null?void 0:t.length)??0,((r=(s=this.rot)==null?void 0:s.times)==null?void 0:r.length)??0,((o=(n=this.scale)==null?void 0:n.times)==null?void 0:o.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(e=!0,t=!0,s=!0){var r,n,o;if(!this.clip)return[0,this.duration];const a=(r=this.pos)==null?void 0:r.times,l=(n=this.rot)==null?void 0:n.times,c=(o=this.scale)==null?void 0:o.times,u=[];if(e&&a)for(const d of a)u.push(d);if(t&&l)for(const d of l)u.push(d);if(s&&c)for(const d of c)u.push(d);return u.includes(0)||u.push(0),u.sort((d,p)=>d-p),[...new Set(u)]}*getValues(e,t=!0,s=!0,r=!0){var n,o,a;const l=new w,c=new Ce,u=new w(1,1,1),d=this.target,p=t?(n=this.pos)==null?void 0:n.createInterpolant():void 0,f=s?(o=this.rot)==null?void 0:o.createInterpolant():void 0,m=r?(a=this.scale)==null?void 0:a.createInterpolant():void 0;p||l.set(d.position.x,d.position.y,d.position.z),f||c.set(d.quaternion.x,d.quaternion.y,d.quaternion.z,d.quaternion.w),m||u.set(d.scale.x,d.scale.y,d.scale.z);for(let A=0;A<e.length;A++){const v=e[A];if(p){const g=p.evaluate(v);l.set(g[0],g[1],g[2])}if(f){const g=f.evaluate(v);c.set(g[0],g[1],g[2],g[3])}if(m){const g=m.evaluate(v);u.set(g[0],g[1],g[2])}if(this.useRootMotion&&d===this.root){const g=new Te;g.compose(l,c,u),g.multiply(d.matrix),g.decompose(l,c,u)}yield{time:v,translation:l,rotation:c,scale:u,index:A}}}}h(To,"animationDurationPadding",1);class ev{constructor(e){h(this,"dict",new Map),h(this,"rootTargetMap",new Map),h(this,"rootAndClipToRegisteredAnimationMap",new Map),h(this,"rootToRegisteredClipCount",new Map),h(this,"serializers",[]),h(this,"injectRestPoses",!1),h(this,"injectImplicitBehaviours",!1),this.injectRestPoses=e,this.injectImplicitBehaviours=e}get extensionName(){return"animation"}getClipCount(e){let t=this.rootToRegisteredClipCount.get(e);return this.injectRestPoses&&(t=t?t-1:0),t??0}getStartTime01(e,t){const s=this.rootTargetMap.get(e);if(!s)return 0;const r=this.dict.get(s[0]);if(!r)return console.error("Trying to get start time for root that has no animation data",e,t,...this.dict),0;let n=0;for(let o=0;o<r.length&&r[o].clip!==t;o++)n+=r[o].getDuration()+To.animationDurationPadding;return n}registerAnimation(e,t){if(!t||!e)return null;this.rootTargetMap.has(e)||this.rootTargetMap.set(e,[]);const s=e.uuid+t.uuid;if(this.rootAndClipToRegisteredAnimationMap.has(s))return this.rootAndClipToRegisteredAnimationMap.get(s);qp&&console.log("registerAnimation",e,t);const r=this.injectRestPoses?1:0,n=this.rootToRegisteredClipCount.get(e)??r,o=this.rootTargetMap.get(e),a=new Set(o);if(t.tracks)for(const c of t.tracks){const u=jt.parseTrackName(c.name),d=jt.findNode(e,u.nodeName);if(!d){console.warn("no object found for track",c.name,"using "+e.name+" instead");continue}this.dict.has(d)||this.dict.set(d,[]);const p=this.dict.get(d);if(!p)continue;if(a.delete(d),this.injectRestPoses&&!p[0]){const m=new To(null,d,void 0);p[0]=m}let f=p[n];f||(f=new To(e,d,t),p[n]=f),f.addTrack(c),o!=null&&o.includes(d)||o==null||o.push(d)}for(const c of a){const u=this.dict.get(c);if(!u)continue;if(this.injectRestPoses&&!u[0]){const p=new To(null,c,void 0);u[0]=p}let d=u[n];d||(qp&&console.log("Adding padding clip for ",c,t),d=new To(e,c,t),u[n]=d)}const l=new I_(this,e,t);return this.rootAndClipToRegisteredAnimationMap.set(s,l),this.rootToRegisteredClipCount.set(e,n+1),l}onAfterHierarchy(e){qp&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(e){var t,s;for(const r of this.serializers){const n=(t=r.model)==null?void 0:t.parent,o=n?.isDynamic===!0;_T&&console.log(o,(s=r.model)==null?void 0:s.parent),o&&r.registerCallback(n)}}onExportObject(e,t,s){te.foreachComponent(e,n=>{const o=n;typeof o.createAnimation=="function"&&o.createAnimation(this,t,s)},!1);const r=new sse(e,this.dict);this.serializers.push(r),r.registerCallback(t)}}class sse{constructor(e,t){h(this,"object"),h(this,"dict"),h(this,"model"),h(this,"callback"),this.object=e,this.dict=t}registerCallback(e){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),_T&&console.log("REPARENT",e),this.model=e,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(e,t){const s=this.model,r=this.dict;if(s&&s.skinnedMesh){let n=function(M){const R=[];for(const[E,C]of M){let U=`${E} : [`;const G=[];for(const F of C)G.push(`(${Ys(F.x)}, ${Ys(F.y)}, ${Ys(F.z)})`);U=U.concat(G.join(", ")),U=U.concat("],"),R.push(U)}return R},o=function(M){const R=[];for(const[E,C]of M){let U=`${E} : [`;const G=[];for(const F of C)G.push(`(${Ys(F.w)}, ${Ys(F.x)}, ${Ys(F.y)}, ${Ys(F.z)})`);U=U.concat(G.join(", ")),U=U.concat("],"),R.push(U)}return R},a=function(M){let R=!0,E;for(const[U,G]of M)if(E===void 0&&(E=G.length),E!==G.length){R=!1;break}qp&&console.log("Bone count: ",M.size,"TransformData entries per bone: ",E),console.assert(R,"All bones should have the same number of TransformData entries",M);const C=[];for(const[U,G]of M){const F=new Array;let Q=0;for(let K=0;K<G.length;K++)F.push(Q),Q+=G[K].getDuration()+To.animationDurationPadding;for(let K=0;K<G.length;K++){const z=G[K],O=F[K];C.length<=K&&C.push({pos:[],rot:[],scale:[],timeOffset:O});const j=C[K];j.pos.push(...z.getSortedTimesArray(!0,!1,!1)),j.rot.push(...z.getSortedTimesArray(!1,!0,!1)),j.scale.push(...z.getSortedTimesArray(!1,!1,!0))}}for(const U of C)U.pos.sort((G,F)=>G-F),U.rot.sort((G,F)=>G-F),U.scale.sort((G,F)=>G-F),U.pos=[...new Set(U.pos)],U.rot=[...new Set(U.rot)],U.scale=[...new Set(U.scale)];return C},l=function(M,R,E){const C=new Map,U=new Map,G=new Map,F=R.length;for(const Q of E){const K=M.get(Q);let z;K?console.assert(K.length===F,"We should have the same number of TransformData entries for each bone",K,R):z=new To(null,Q,void 0);for(let O=0;O<F;O++){const j=K?K[O]:z,se=R[O];for(const{time:$,translation:X}of j.getValues(se.pos,!0,!1,!1)){const ie=($+se.timeOffset)*60;C.has(ie)||C.set(ie,new Array),C.get(ie).push(X.clone())}for(const{time:$,rotation:X}of j.getValues(se.rot,!1,!0,!1)){const ie=($+se.timeOffset)*60;U.has(ie)||U.set(ie,new Array),U.get(ie).push(X.clone())}for(const{time:$,scale:X}of j.getValues(se.scale,!1,!1,!0)){const ie=($+se.timeOffset)*60;G.has(ie)||G.set(ie,new Array),G.get(ie).push(X.clone())}}}return{position:C.size==0?void 0:C,quaternion:U.size==0?void 0:U,scale:G.size==0?void 0:G}},c=function(M){const R=[];for(const E of M)R.push(`(${Ys(E.x)}, ${Ys(E.y)}, ${Ys(E.z)})`);return R.join(", ")},u=function(M){const R=[];for(const E of M)R.push(`(${Ys(E.w)}, ${Ys(E.x)}, ${Ys(E.y)}, ${Ys(E.z)})`);return R.join(", ")},d=function(M){const R=new Map;if(qp){const E=new Array;for(const[C,U]of r)E.push(C.uuid+": "+U.length+" "+U.map(G=>{var F;return(F=G.clip)==null?void 0:F.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
5190
5190
  `+E.join(`
5191
5191
  `))}for(const E of M){const C=r.get(E);C&&R.set(E,C)}return R},p=function(M){const R=d(M),E=a(R);return l(R,E,M)};const f=s.skinnedMesh.skeleton,m=new Array;for(const M in f.bones){const R=f.bones[M],E=f.boneInverses[M];m.push({bone:R,inverse:E})}for(const M of f3(f.bones))m.push({bone:M,inverse:M.matrixWorld.clone().invert()});const A=m[0].bone.parent;A||console.error("No bone parent found for skinned mesh during USDZ export",s.skinnedMesh),m.sort((M,R)=>Bp(M.bone,A)>Bp(R.bone,A)?1:-1);const v=[],g=[],b=[],y=[];for(const{bone:M}of m)v.push(M.matrix.clone()),g.push(M.position),b.push(M.quaternion),y.push(M.scale);const _=m.map(M=>'"'+Bp(M.bone,A)+'"').join(", "),S=m.map(M=>Dp(M.inverse.clone().invert())).join(", ");e.beginBlock('def Skeleton "Rig"'),e.appendLine(`uniform matrix4d[] bindTransforms = [${S}]`),e.appendLine(`uniform token[] joints = [${_}]`),e.appendLine('uniform token purpose = "guide"'),e.appendLine(`uniform matrix4d[] restTransforms = [${v.map(M=>Dp(M)).join(", ")}]`),e.appendLine(`matrix4d xformOp:transform = ${Dp(new Te)}`),e.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const T=p(m.map(M=>M.bone));if(e.beginBlock('def SkelAnimation "_anim"'),e.appendLine(`uniform token[] joints = [${_}]`),e.appendLine(`quatf[] rotations = [${u(b)}]`),T&&T.quaternion){e.beginBlock("quatf[] rotations.timeSamples = {","");const M=o(T.quaternion);for(const R of M)e.appendLine(R);e.closeBlock()}if(e.appendLine(`half3[] scales = [${c(y)}]`),T&&T.scale){e.beginBlock("half3[] scales.timeSamples = {","");const M=n(T.scale);for(const R of M)e.appendLine(R);e.closeBlock()}if(e.appendLine(`float3[] translations = [${c(g)}]`),T&&T.position){e.beginBlock("float3[] translations.timeSamples = {","");const M=n(T.position);for(const R of M)e.appendLine(R);e.closeBlock()}e.closeBlock(),e.closeBlock()}}onSerialize(e,t){var s;if(!this.model)return;this.skinnedMeshExport(e,t);const r=this.object,n=this.dict.get(r);if(!n||r.isSkinnedMesh)return;_T&&console.log("SERIALIZE",this.model.name,this.object.type,n);const o=new Te;e.appendLine("matrix4d xformOp:transform.timeSamples = {"),e.indent++;const a=new Array;let l=0;for(let c=0;c<n.length;c++)a.push(l),l+=n[c].getDuration()+To.animationDurationPadding;for(let c=0;c<n.length;c++){const u=n[c];if(!u)continue;const d=a[c];{const p=u.getSortedTimesArray();if(!p||p.length===0){console.error("got an animated object but no time values?",r,u);continue}if(qp){const f=((s=u.clip)==null?void 0:s.name)??"rest",m=u.getDuration();console.log("Write .timeSamples:",f,d,m,n),e.appendLine("# "+f+": start="+(d*u.frameRate).toFixed(3)+", length="+(m*u.frameRate).toFixed(3)+", frames="+u.getFrames())}for(const{time:f,translation:m,rotation:A,scale:v}of u.getValues(p)){o.compose(m,A,v);const g=`${(d+f)*u.frameRate}: ${Dp(o)},`;e.appendLine(g)}}}e.indent--,e.appendLine("}")}}var rse=Object.defineProperty,nse=Object.getOwnPropertyDescriptor,Z3=(i,e,t,s)=>{for(var r=s>1?void 0:s?nse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&rse(e,t,r),r};class Tt{constructor(e){h(this,"_active",!0),h(this,"_value"),h(this,"_valueRaw"),h(this,"_defaultValue"),h(this,"valueProcessor"),h(this,"onValueChanged"),this._value=e,this._defaultValue=e,this._valueRaw=e}get overrideState(){return this._active}set overrideState(e){if(this._active===e)return;this._active=e;const t=e?this._valueRaw:this._defaultValue;this.processValue(t,!0)}get value(){return this._valueRaw}set value(e){this.processValue(e,!1)}set defaultValue(e){this._defaultValue=e}__init(){this.processValue(this._valueRaw,!0)}processValue(e,t){if(e==null||!t&&this.testIfValueChanged(e)===!1)return;const s=this._value;!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,e=this._defaultValue,this._valueRaw=e):(this._valueRaw=e,this._active&&this.valueProcessor&&(e=this.valueProcessor(e)),this._value=e),this.onValueChanged&&this.onValueChanged(e,s,this)}testIfValueChanged(e){return this._valueRaw!==e}}Z3([x()],Tt.prototype,"overrideState",1),Z3([x()],Tt.prototype,"value",1);var ose=Object.defineProperty,ase=Object.getOwnPropertyDescriptor,lse=(i,e,t,s)=>{for(var r=s>1?void 0:s?ase(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ose(e,t,r),r};const cse=oe("debugpost");class Lr extends qc{constructor(e=void 0){if(super(),h(this,"active",!0),h(this,"_result"),h(this,"_didCreateVolumeParameters",!1),e){this.ensureVolumeParameters();for(const t of Object.keys(e)){const s=e[t],r=this[t];r instanceof Tt&&(r.value=s)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var e;return this.ensureVolumeParameters(),this._result||(this._result=(e=this.onCreateEffect)==null?void 0:e.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){cse&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(e=>e.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const e=Object.keys(this);for(const t of e){const s=this[t];s instanceof Tt&&s.__init()}}onAfterDeserialize(e,t){if(typeof e=="object"){const s=this.$serializedTypes;if(s){for(const r of Object.keys(s))if(s[r]===Tt){const n=e[r];if(n!==void 0){const o=this[r];o.value=n}}}}}onEditorModification(e){const t=e.propertyName;if(this[t]instanceof Tt){const s=e.value;return this[t].value=s,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const e=this.$serializedTypes;if(e)for(const t of Object.keys(e))e[t]===Tt&&(this[t]||(this[t]=new Tt))}}lse([x()],Lr.prototype,"active",2);var hse=Object.defineProperty,use=Object.getOwnPropertyDescriptor,dse=(i,e,t,s)=>{for(var r=s>1?void 0:s?use(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&hse(e,t,r),r};const pse=oe("debugpost"),xT={};function Io(i,e){xT[i]=e}function fse(i){return i.__type in xT?xT[i.__type]:(pse&&i.__type&&console.warn("Unknown postprocessing type",i.__type,i),Lr)}class tv{constructor(){h(this,"components",[])}init(){var e;(e=this.components)==null||e.forEach(t=>t.init())}}dse([yp([i=>fse(i),Lr])],tv.prototype,"components",2);var mse=Object.defineProperty,gse=Object.getOwnPropertyDescriptor,vse=(i,e,t,s)=>{for(var r=s>1?void 0:s?gse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&mse(e,t,r),r};class iv extends Lr{constructor(){super(...arguments),h(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const e=new MY({preset:op.HIGH,edgeDetectionMode:eE.DEPTH});return this.preset.onValueChanged=t=>{e.applyPreset(t)},e}}vse([x(Tt)],iv.prototype,"preset",2),Io("Antialiasing",iv);class R_{constructor(){h(this,"files",[])}get extensionName(){return"Audio"}onExportObject(e,t,s){const r=te.getComponents(e,ms);if(r.length)for(const n of r){if(!n.clip||typeof n.clip!="string"||!n.playOnAwake)continue;const o=n.clip.split("/").pop();this.files.includes(n.clip)||this.files.push(n.clip),t.addEventListener("serialize",(a,l)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${t.name}"`),a.appendLine(`uniform asset filePath = @audio/${o}@`),a.appendLine(`uniform token auralMode = "${n.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${n.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${n.volume}`),a.closeBlock()})}}async onAfterSerialize(e){for(const t of this.files){const s=t.split("/").pop(),r=await(await(await fetch(t)).blob()).arrayBuffer(),n=new Uint8Array(r);e.files["audio/"+s]=n}}}const Yp=oe("debugnetworkingstreams");var ja=(i=>(i.Connected="peer-user-connected",i.StreamReceived="receive-stream",i.StreamEnded="call-ended",i.Disconnected="peer-user-disconnected",i.UserJoined="user-joined",i))(ja||{});class $3{constructor(e,t){h(this,"type","call-ended"),h(this,"userId"),h(this,"direction"),this.userId=e,this.direction=t}}class ez{constructor(e,t){h(this,"type","receive-stream"),h(this,"stream"),h(this,"target"),this.stream=e,this.target=t}}class Ase{constructor(e,t){h(this,"guid"),h(this,"peerId"),h(this,"dontSave",!0),this.guid=e.id,this.peerId=t}}var tz=(i=>(i.Incoming="incoming",i.Outgoing="outgoing",i))(tz||{});class yse extends ks{constructor(e,t,s){super(),h(this,"userId"),h(this,"direction"),h(this,"call"),h(this,"_stream",null),h(this,"_isDisposed",!1),this.userId=e,this.call=t,this.direction=s,this._stream=null,t.on("stream",r=>{if(Yp&&console.log("Receive video",r.getAudioTracks(),r.getVideoTracks()),this._stream=r,s==="incoming"){const n=new ez(r,this);this.dispatchEvent(n)}}),t.on("close",()=>{this.dispatchEvent(new $3(e,s))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),ec(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 sv=class extends ks{constructor(i,e){super(),h(this,"id"),h(this,"context"),h(this,"_peer"),h(this,"_incomingCalls",[]),h(this,"_outgoingCalls",[]),h(this,"_enabled",!1),h(this,"_enabledPeer",!1),h(this,"onConnectRoomFn",this.onConnectRoom.bind(this)),h(this,"onPeerConnectFn",this.onPeerConnect.bind(this)),h(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this)),this.context=i,this.id=e,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(i,e){if(sv.instances.has(e))return sv.instances.get(e);const t=new sv(i,e);return sv.instances.set(e,t),t}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(i){return this.id+"-"+i}getUserIdFromPeerId(i){return i.substring(this.id.length+1)}makeCall(i,e){var t;const s={metadata:{userId:this.context.connection.connectionId}},r=(t=this._peer)==null?void 0:t.call(i,e,s);if(r)return this.registerCall(r,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(Di.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(Di.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const i=this.getMyPeerId();i?this._peer=mO(i):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(i){Yp&&console.log("Peer connected as",i),this.context.connection.send("peer-user-connected",new Ase(this,i))}onPeerReceivingCall(i){i.answer(),this.registerCall(i,"incoming")}registerCall(i,e){const t=i.metadata;(!t||!t.userId)&&console.error("Missing call metadata",i);const s=t.userId;e==="incoming"&&Yp?console.log("Receive call from",i.metadata):Yp&&console.log("Make call to",i.metadata);const r=e==="incoming"?this._incomingCalls:this._outgoingCalls,n=new yse(s,i,e);return r.push(n),i.on("error",o=>{console.error("Call error",o)}),i.on("close",()=>{Yp&&console.log("Call ended",i.metadata),i.close();const o=r.indexOf(n);o!==-1&&r.splice(o,1)}),n.addEventListener("call-ended",o=>{this.dispatchEvent(o)}),e==="incoming"&&(n.addEventListener("receive-stream",o=>{this.dispatchEvent(o)}),i.on("stream",()=>{let o=0;const a=setInterval(()=>{const l=o===0;!n.isOpen&&l&&(o+=1,clearInterval(a),n.close())},2e3)})),n}};let P_=sv;h(P_,"instances",new Map);class vA extends ks{constructor(e,t){super(),h(this,"context"),h(this,"peer"),h(this,"_sendingStreams",new Map),h(this,"debug",!1),h(this,"onJoinedRoom",s=>{this.debug&&console.log(`${s.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()}),h(this,"onReceiveStream",s=>{this.debug&&console.log("RECEIVE STREAM",s),this.dispatchEvent({type:"receive-stream",target:this,stream:s.stream,userId:s.userId})}),h(this,"onCallEnded",s=>{this.dispatchEvent(s)}),h(this,"onUserConnected",s=>{if(this.peer.id===s.guid){this.debug&&console.log("USER CONNECTED",s.guid,s);const r=this._sendingStreams.keys().next().value;this.peer.makeCall(s.peerId,r)}}),h(this,"onUserLeft",s=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()}),this.context=e,this.peer=t,Yp&&(this.debug=!0)}static create(e){const t=P_.getOrCreate(e.context,e.context.connection.connectionId);return new vA(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 s of t)s.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(Di.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Di.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(Di.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(Di.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Di.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(Di.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var e;let t=!1;const s=this.context.connection.connectionId;for(const r of this._sendingStreams.keys()){const n=this._sendingStreams.get(r)||[];for(const o of this.context.connection.usersInRoom()){if(o===s)continue;const a=n.find(l=>l.userId===o);if(!a||((e=a.stream)==null?void 0:e.active)===!1){this.debug&&console.log("Starting call to",o,s);const l=this.peer.makeCall(this.peer.getPeerIdFromUserId(o),r);l&&(t=!0,n.push(l))}}this._sendingStreams.set(r,n)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),t&&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 s=t.length-1;s>=0;s--){const r=t[s];this.context.connection.userIsInRoom(r.userId)||(r.close(),t.splice(s,1))}}}}function ec(i){if(i&&i instanceof MediaStream)for(const e of i.getTracks())e.stop()}var bse=Object.defineProperty,_se=Object.getOwnPropertyDescriptor,iz=(i,e,t,s)=>{for(var r=s>1?void 0:s?_se(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&bse(e,t,r),r};const sz="noVoip",xse=oe("debugvoip");class uh extends Pe{constructor(){super(...arguments),h(this,"autoConnect",!1),h(this,"runInBackground",!0),h(this,"debug",!1),h(this,"_net"),h(this,"_outputStream",null),h(this,"onJoinedRoom",async()=>{await kc(300),this.autoConnect&&!this.isSending&&this.connect()}),h(this,"_incomingStreams",new Map),h(this,"onReceiveStream",e=>{const t=e.target.userId,s=e.stream,r=this._incomingStreams.get(t);if(r)r.srcObject=s,r.setAttribute("autoplay","true");else{const n=new Audio;this._incomingStreams.set(t,n),n.setAttribute("autoplay","true"),n.srcObject=s}}),h(this,"onStreamEnded",e=>{const t=this._incomingStreams.get(e.userId);ec(t?.srcObject),this._incomingStreams.delete(e.userId)}),h(this,"onEnabledChanged",()=>{for(const e of this._incomingStreams){const t=e[1];t.muted=!this.enabled}}),h(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const e=document.visibilityState!=="visible";this.setMuted(e);for(const t of this._incomingStreams){const s=t[1];s.muted=e}})}awake(){xse&&(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=vA.create(this)),this._net.addEventListener(ja.StreamReceived,this.onReceiveStream),this._net.addEventListener(ja.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(Di.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var e;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(ja.StreamReceived,this.onReceiveStream),this._net.removeEventListener(ja.StreamEnded,this.onStreamEnded),(e=this._net)==null||e.disable(),this.context.connection.stopListen(Di.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 HS())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),ec(this._outputStream),this._outputStream=await this.getAudioStream(e),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await HS()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):O2("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),ec(this._outputStream),this._outputStream=null}setMuted(e){var t;const s=(t=this._outputStream)==null?void 0:t.getAudioTracks();if(s)for(const r of s)r.enabled=!e}get isMuted(){var e;if(this._outputStream===null)return!1;const t=(e=this._outputStream)==null?void 0:e.getAudioTracks();if(t){for(const s of t)if(!s.enabled)return!0}return!1}getFrequency(e){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,Gt()&&Vs("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(t=>(console.warn("VOIP failed getting audio stream",t),null)):(console.error("No getDisplayMedia support"),null)}}iz([x()],uh.prototype,"autoConnect",2),iz([x()],uh.prototype,"runInBackground",2);var wse=Object.defineProperty,Sse=Object.getOwnPropertyDescriptor,rz=(i,e,t,s)=>{for(var r=s>1?void 0:s?Sse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&wse(e,t,r),r};const Cse=oe("debugmouth");class rv extends Pe{constructor(){super(...arguments),h(this,"idle",[]),h(this,"talking",[]),h(this,"marker",null),h(this,"voip",null),h(this,"lastMouthChangeTime",0),h(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=te.findObjectOfType(uh,this.context),this.marker||(this.marker=te.getComponentInParent(this.gameObject,Or))},3e3)}update(){var e;if(!this.voip||this.context.time.frameCount%10!==0)return;let t=((e=this.marker)==null?void 0:e.connectionId)??null;if(!t){Cse&&(t=null);return}const s=this.voip.getFrequency(t)??0;this.updateLips(s)}updateLips(e){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&e>30){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,t)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const t=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,t)}}}setMouthShapeActive(e,t){if(e){e!=this.idle?this.idle.map(s=>s.visible=!1):this.talking.map(s=>s.visible=!1);for(let s=0;s<e.length;s++){const r=e[s];r&&(r.visible=s===t)}}}}rz([x(_e)],rv.prototype,"idle",2),rz([x(_e)],rv.prototype,"talking",2);class wT extends Pe{constructor(){super(...arguments),h(this,"voip",null),h(this,"marker",null),h(this,"_startPosition",null)}awake(){this.voip=te.findObjectOfType(uh,this.context),this.marker=te.getComponentInParent(this.gameObject,Or)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const e=this.marker.connectionId,t=this.voip.getFrequency(e);if(t==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const s=t/100;this.gameObject.position.y=this._startPosition.y+s*.07}}var Ese=Object.defineProperty,Mse=Object.getOwnPropertyDescriptor,B_=(i,e,t,s)=>{for(var r=s>1?void 0:s?Mse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Ese(e,t,r),r};class Bu extends Pe{constructor(){super(...arguments),h(this,"eyes",[]),h(this,"lastBlinkTime",0),h(this,"blinkLength",0),h(this,"eyesOpen",!0),h(this,"state",null)}awake(){this.state=te.getComponentInParent(this.gameObject,Vn)}update(){if(!(!this.gameObject||!this.gameObject.visible||!this.eyes||!Array.isArray(this.eyes)||this.eyes.length===0)&&this.context.time.time-this.lastBlinkTime>this.blinkLength){if(this.lastBlinkTime=this.context.time.time,this.state&&!this.state.isOn||!this.activeAndEnabled)return;if(this.eyesOpen=!this.eyesOpen,this.blinkLength=Math.random(),this.eyesOpen?(this.blinkLength*=3,this.blinkLength+=.5,Math.random()<.1&&(this.blinkLength=.1+Math.random()*.2)):(this.blinkLength*=Math.random()*.2,this.blinkLength+=.1),Math.random()<.1&&(this.blinkLength*=3),this.blinkLength=Math.max(.2,this.blinkLength),this.blinkLength=Math.min(3,this.blinkLength),this.eyes)for(const e of this.eyes)e&&(e.visible=this.eyesOpen)}}}B_([x(_e)],Bu.prototype,"eyes",2),B_([x()],Bu.prototype,"lastBlinkTime",2),B_([x()],Bu.prototype,"blinkLength",2),B_([x()],Bu.prototype,"eyesOpen",2);var Tse=Object.defineProperty,Ise=Object.getOwnPropertyDescriptor,ST=(i,e,t,s)=>{for(var r=s>1?void 0:s?Ise(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Tse(e,t,r),r},CT;const nz=(CT=class extends Pe{constructor(){super(...arguments),h(this,"head",null),h(this,"eyes",null),h(this,"target",null),h(this,"brain",null),h(this,"vec",new w),h(this,"currentTargetPoint",new w)}awake(){this.brain||(this.brain=te.getComponentInParent(this.gameObject,Gg)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=te.addNewComponent(this.gameObject,Gg)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const i=this.target;if(i&&this.head){const e=this.eyes;if(e){const t=ft(i);this.currentTargetPoint.lerp(t,this.context.time.deltaTime/.1);const s=ft(this.head),r=this.vec.copy(this.currentTargetPoint).sub(s).normalize();if(r.length()<.1)return;const n=nz.forward;if(n.set(0,0,1),n.applyQuaternion(wi(this.head)),n.dot(r)>.45)for(let o=0;o<e.length;o++)e[o].lookAt(this.currentTargetPoint)}}}},h(CT,"forward",new w(0,0,1)),CT);let Kp=nz;ST([x(_e)],Kp.prototype,"head",2),ST([x(_e)],Kp.prototype,"eyes",2),ST([x(_e)],Kp.prototype,"target",2);var Rse=Object.defineProperty,Pse=Object.getOwnPropertyDescriptor,ET=(i,e,t,s)=>{for(var r=s>1?void 0:s?Pse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Rse(e,t,r),r};class Jp extends Pe{constructor(){super(...arguments),h(this,"length",1),h(this,"depthTest",!0),h(this,"isGizmo",!0),h(this,"_axes",null)}onEnable(){if(this.isGizmo&&!ig)return;this._axes||(this._axes=new qd(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)}}ET([x()],Jp.prototype,"length",2),ET([x()],Jp.prototype,"depthTest",2),ET([x()],Jp.prototype,"isGizmo",2);class MT extends Pe{constructor(){super(...arguments),h(this,"from"),h(this,"to"),h(this,"hint"),h(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const e=ft(this.to).clone(),t=ft(this.from).clone(),s=e.distanceTo(t),r=e.clone();r.sub(t);const n=t.clone();n.add(e),n.multiplyScalar(.5);const o=ft(this.hint).clone();o.sub(n);const a=new w;a.crossVectors(o,r),a.crossVectors(r,a),a.normalize();const l=s*.5,c=Math.max(this.desiredDistance,l),u=Math.sqrt(c*c-l*l),d=a.clone();d.multiplyScalar(u),d.add(n),us(this.gameObject,d);const p=n.clone();p.sub(a),this.gameObject.lookAt(p)}}const Bse=oe("debugusdz");class D_{constructor(){h(this,"behaviours",[]),h(this,"behaviourComponents",[]),h(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(e){this.behaviours.push(e)}onBeforeBuildDocument(e){const t=[];return e.root.traverse(s=>{te.foreachComponent(s,r=>{var n;const o=r;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const a=(n=o.beforeCreateDocument)==null?void 0:n.call(o,this,e);a instanceof Promise&&t.push(a)}},!1)}),Promise.all(t)}onExportObject(e,t,s){var r;for(const n of this.behaviourComponents)(r=n.createBehaviours)==null||r.call(n,this,t,s)}onAfterBuildDocument(e){for(const t of this.behaviourComponents)typeof t.afterCreateDocument=="function"&&t.afterCreateDocument(this,e);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(e,t){var s;if((s=this.behaviours)!=null&&s.length){t.beginBlock('def Scope "Behaviors"');for(const r of this.behaviours)r.writeTo(this,e.document,t);t.closeBlock()}}async onAfterSerialize(e){Bse&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const t of this.behaviourComponentsCopy)typeof t.afterSerialize=="function"&&(t.afterSerialize.constructor.name==="AsyncFunction"?await t.afterSerialize(this,e):t.afterSerialize(this,e));this.behaviours.length=0}}var Dse=Object.defineProperty,kse=Object.getOwnPropertyDescriptor,TT=(i,e,t,s)=>{for(var r=s>1?void 0:s?kse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Dse(e,t,r),r};class Du extends Lr{constructor(){super(...arguments),h(this,"threshold"),h(this,"intensity"),h(this,"scatter"),h(this,"selectiveBloom",!0)}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>1*Math.PI*(1-e)):(this.threshold.valueProcessor=e=>e,this.intensity.valueProcessor=e=>e,this.scatter.valueProcessor=e=>100*(1-e))}onCreateEffect(){let e;if(this.selectiveBloom){const t=e=new GL(this.context.scene,this.context.mainCamera,{blendFunction:zt.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});t.inverted=!0}else e=new oE;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}}TT([x(Tt)],Du.prototype,"threshold",2),TT([x(Tt)],Du.prototype,"intensity",2),TT([x(Tt)],Du.prototype,"scatter",2),Io("Bloom",Du);var Ose=Object.defineProperty,Lse=Object.getOwnPropertyDescriptor,Ro=(i,e,t,s)=>{for(var r=s>1?void 0:s?Lse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Ose(e,t,r),r};class Ga extends Pe{constructor(){super(...arguments),h(this,"attachedRigidbody",null),h(this,"isTrigger",!1),h(this,"sharedMaterial"),h(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(Ii))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ii))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ii))}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)}}Ro([x(Ii)],Ga.prototype,"attachedRigidbody",2),Ro([x()],Ga.prototype,"isTrigger",2),Ro([x()],Ga.prototype,"sharedMaterial",2);class nv extends Ga{constructor(){super(...arguments),h(this,"radius",.5),h(this,"center",new w(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addSphereCollider(this),GS(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),y2(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}Ro([dr(),x()],nv.prototype,"radius",2),Ro([x(w)],nv.prototype,"center",2);class ov extends Ga{constructor(){super(...arguments),h(this,"size",new w(1,1,1)),h(this,"center",new w(0,0,0))}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addBoxCollider(this,this.size)}onValidate(){this.updateProperties()}}Ro([dr(),x(w)],ov.prototype,"size",2),Ro([x(w)],ov.prototype,"center",2);class Zp extends Ga{constructor(){super(...arguments),h(this,"sharedMesh"),h(this,"convex",!1)}onEnable(){var e,t,s,r,n;if(super.onEnable(),(e=this.sharedMesh)!=null&&e.isMesh||this.gameObject instanceof ge&&(this.sharedMesh=this.gameObject),(t=this.sharedMesh)!=null&&t.isMesh)(s=this.context.physics.engine)==null||s.addMeshCollider(this,this.sharedMesh,this.convex,Ws(this.gameObject));else{const o=this.sharedMesh;if(o!=null&&o.isGroup){console.warn(`MeshCollider mesh is a group "${((r=this.sharedMesh)==null?void 0:r.name)||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 a in o.children){const l=o.children[a];l.isMesh&&((n=this.context.physics.engine)==null||n.addMeshCollider(this,l,this.convex,Ws(this.gameObject)))}}}}}Ro([x()],Zp.prototype,"sharedMesh",2),Ro([x()],Zp.prototype,"convex",2);class dh extends Ga{constructor(){super(...arguments),h(this,"center",new w(0,0,0)),h(this,"radius",.5),h(this,"height",2)}onEnable(){var e;super.onEnable(),(e=this.context.physics.engine)==null||e.addCapsuleCollider(this,this.height,this.radius)}}Ro([x(w)],dh.prototype,"center",2),Ro([x()],dh.prototype,"radius",2),Ro([x()],dh.prototype,"height",2);var Use=Object.defineProperty,Fse=Object.getOwnPropertyDescriptor,IT=(i,e,t,s)=>{for(var r=s>1?void 0:s?Fse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Use(e,t,r),r};class ku extends Pe{constructor(){super(...arguments),h(this,"objectBounds",!1),h(this,"color"),h(this,"isGizmo",!0),h(this,"_gizmoObject",null),h(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!ig||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new Zy(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=i3(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Xs.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){for(var e;this._boxHelper;)(e=this._boxHelper)==null||e.update(),yield}}IT([x()],ku.prototype,"objectBounds",2),IT([x(be)],ku.prototype,"color",2),IT([x()],ku.prototype,"isGizmo",2);var Nse=Object.defineProperty,zse=Object.getOwnPropertyDescriptor,av=(i,e,t,s)=>{for(var r=s>1?void 0:s?zse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Nse(e,t,r),r};const RT=oe("debugui"),PT=oe("debuguilayout");class BT{constructor(){h(this,"width"),h(this,"height")}}class DT{constructor(){h(this,"x"),h(this,"y"),h(this,"width"),h(this,"height")}}const ua=new w,lv=new Te,k_=new Ce,oz=class extends va{constructor(){super(...arguments),h(this,"_anchoredPosition"),h(this,"sizeDelta",new ee(100,100)),h(this,"pivot",new ee(.5,.5)),h(this,"anchorMin",new ee(0,0)),h(this,"anchorMax",new ee(1,1)),h(this,"minWidth"),h(this,"minHeight"),h(this,"lastMatrix"),h(this,"rectBlock"),h(this,"_transformNeedsUpdate",!1),h(this,"_initialPosition"),h(this,"_parentRectTransform"),h(this,"_lastUpdateFrame",-1),h(this,"_lastAnchoring"),h(this,"_createdBlocks",[]),h(this,"_createdTextBlocks",[])}get parent(){return this._parentRectTransform}get translation(){return this.gameObject.position}get rotation(){return this.gameObject.quaternion}get scale(){return this.gameObject.scale}get anchoredPosition(){return this._anchoredPosition||(this._anchoredPosition=new ee),this._anchoredPosition}set anchoredPosition(i){this._anchoredPosition=i}get width(){let i=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const e=this._parentRectTransform.width,t=this.anchorMax.x-this.anchorMin.x;i=e*t,i+=this.sizeDelta.x}return this.minWidth!==void 0&&i<this.minWidth?this.minWidth:i}get height(){let i=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const e=this._parentRectTransform.height,t=this.anchorMax.y-this.anchorMin.y;i=e*t,i+=this.sizeDelta.y}return this.minHeight!==void 0&&i<this.minHeight?this.minHeight:i}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new ee),this.lastMatrix=new Te,this.rectBlock=new _e,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,Qp(this,"_anchoredPosition",()=>{this.markDirty()}),Qp(this,"sizeDelta",()=>{this.markDirty()}),Qp(this,"pivot",()=>{this.markDirty()}),Qp(this,"anchorMin",()=>{this.markDirty()}),Qp(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var i;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(i=this.Canvas)==null||i.registerTransform(this)}onDisable(){var i;super.onDisable(),this.removeShadowComponent(),(i=this.Canvas)==null||i.unregisterTransform(this)}onParentRectTransformChanged(i){this._transformNeedsUpdate||this.onApplyTransform(PT?`${i.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(PT&&console.warn("RectTransform markDirty()",this.name),this._transformNeedsUpdate=!0,this._lastUpdateFrame=-1)}updateTransform(){(this._transformNeedsUpdate||!this.lastMatrix.equals(this.gameObject.matrix))&&this.canUpdate()&&this.onApplyTransform(this._transformNeedsUpdate?"Marked dirty":"Matrix changed")}canUpdate(){return this._transformNeedsUpdate&&this.activeAndEnabled&&this._lastUpdateFrame!==this.context.time.frame}onApplyTransform(i){var e;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const t=this.shadowComponent;if(!t)return;this.gameObject.parent?this._parentRectTransform=te.getComponentInParent(this.gameObject.parent,oz):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,PT&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+i),this.isRoot()?this.Root.screenspace||(t.rotation.y=Math.PI):(t.matrix.identity(),t.matrixAutoUpdate=!1,ua.set(0,0,0),this.applyPivot(ua),t.matrix.setPosition(ua.x,ua.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(k_.copy(this.gameObject.quaternion),k_.x*=-1,k_.z*=-1,lv.makeRotationFromQuaternion(k_),t.matrix.premultiply(lv)),ua.set(0,0,0),this.applyAnchoring(ua),(e=this.Canvas)!=null&&e.screenspace?ua.z+=.1:ua.z+=.01,lv.identity(),lv.setPosition(ua.x,ua.y,ua.z),t.matrix.premultiply(lv),t.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const s=!0;for(const r of XC(this.gameObject,va,s,1)){if(r===this||!r.activeAndEnabled)continue;const n=r;n.onParentRectTransformChanged&&n.onParentRectTransformChanged(this)}}applyAnchoring(i){this._lastAnchoring||(this._lastAnchoring=new ee);const e=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=e.x,this.gameObject.position.y+=e.y,this._lastAnchoring.copy(this._anchoredPosition),i.x+=this._initialPosition.x-this.gameObject.position.x,i.y+=this._initialPosition.y-this.gameObject.position.y,i.z+=this._initialPosition.z-this.gameObject.position.z;const t=this._parentRectTransform;if(t){let s=0;const r=1-this.anchorMax.y-this.anchorMin.y;s-=t.height*.5*r,i.y+=s;let n=0;const o=1-this.anchorMax.x-this.anchorMin.x;n-=t.width*.5*o,i.x+=n}}applyPivot(i){if(this.pivot&&!this.isRoot()){const e=this.pivot.x-.5;i.x-=e*this.sizeDelta.x*this.gameObject.scale.x;const t=this.pivot.y-.5;i.y-=t*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const i={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(i),i}ensureValidSize(i,e=1e-4){return i.width<=0&&(i.width=e),i.height<=0&&(i.height=1e-4),i}createNewBlock(i){i={...this.getBasicOptions(),...i},RT&&console.log(this.name,i);const e=new YM(i);return this._createdBlocks.push(e),e}createNewText(i){RT&&console.log(i),i={...this.getBasicOptions(),...i},RT&&console.log(this.name,i);const e=new JM(i);return this._createdTextBlocks.push(e),e}};let an=oz;av([x(ee)],an.prototype,"anchoredPosition",1),av([x(ee)],an.prototype,"sizeDelta",2),av([x(ee)],an.prototype,"pivot",2),av([x(ee)],an.prototype,"anchorMin",2),av([x(ee)],an.prototype,"anchorMax",2);class jse extends ZN{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(const s in t)for(const r in t[s])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(s);for(const s of e._components)e._simpleState__statesProperties[s.id]&&(e._simpleState__normalStyles[s.id]=s.inline?s.inline:s._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;const s=[];for(const r in t)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],s.push(r)),this._simpleState__statesProperties[r].push(e);for(const r of this._components)s.indexOf(r.id)>-1&&(this._simpleState__normalStyles[r.id]=r.inline?r.inline:r._value)}renderStates(){let e={...this._simpleState__normalStyles};for(const t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(const s in e)this._simpleState__statesProperties[s]&&(this._simpleState__normalStyles[s]=e[s]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){const t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}}var Gse=Object.defineProperty,Qse=Object.getOwnPropertyDescriptor,az=(i,e,t,s)=>{for(var r=s>1?void 0:s?Qse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Gse(e,t,r),r};class $p extends Pe{constructor(){super(...arguments),h(this,"effectColor"),h(this,"effectDistance")}}az([x(vi)],$p.prototype,"effectColor",2),az([x(ee)],$p.prototype,"effectDistance",2);var Hse=Object.defineProperty,Vse=Object.getOwnPropertyDescriptor,lz=(i,e,t,s)=>{for(var r=s>1?void 0:s?Vse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Hse(e,t,r),r};const O_={backgroundColor:new be(1,1,1),backgroundOpacity:1,borderColor:new be(1,1,1),borderOpacity:1};var kT;const L_=(kT=class extends va{constructor(){super(...arguments),h(this,"_alphaFactor",1),h(this,"sRGBColor",new be(1,0,1)),h(this,"raycastTarget",!0),h(this,"uiObject",null),h(this,"_color",null),h(this,"_rect",null),h(this,"_stateManager",null),h(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new vi(1,1,1,1)),this._color}set color(i){(!this._color||this._color.r!==i.r||this._color.g!==i.g||this._color.b!==i.b||this._color.alpha!==i.alpha)&&(this._color||(this._color=new vi(1,1,1,1)),this._color.copy(i),this.onColorChanged())}setAlphaFactor(i){this._alphaFactor=i,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),O_.backgroundColor=this.sRGBColor,O_.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(O_,this._alphaFactor),this.uiObject.set(O_),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=te.getComponent(this.gameObject,an)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var i;(i=this.uiObject)==null||i.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(){super.__internalNewInstanceCreated(),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone())}setState(i){this.makePanel(),this.uiObject&&(this.uiObject.setState(i),this==null||this.markDirty())}setupState(i){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new jse(this.uiObject)),this.uiObject.setupState(i.state,i.attributes))}setOptions(i){this.makePanel(),this.uiObject&&this.uiObject.set(i)}awake(){super.awake(),this.makePanel(),Qp(this,"_color",()=>Fie(this,this.onColorChanged))}onEnable(){var i;super.onEnable(),this.uiObject&&((i=this.rectTransform.shadowComponent)==null||i.add(this.uiObject),this.addShadowComponent(this.uiObject,this.rectTransform))}onDisable(){super.onDisable(),this.uiObject&&this.removeShadowComponent()}makePanel(){if(this.uiObject||this._currentlyCreatingPanel)return;this._currentlyCreatingPanel=!0;const i=.015,e={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:i};this.onBeforeCreate(e),this.applyEffects(e),this.onCreate(e),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(i){}onCreate(i){this.uiObject=this.rectTransform.createNewBlock(i),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(i,e=1){var t;const s=(t=this.gameObject)==null?void 0:t.getComponent($p);s&&(s.effectDistance&&(i.borderWidth=Math.max(Math.abs(s.effectDistance.x),Math.abs(s.effectDistance.y))),s.effectColor&&(i.borderColor=s.effectColor,i.borderOpacity=s.effectColor.alpha*e))}async setTexture(i){if(this.setOptions({backgroundOpacity:0}),i){if(L_.textureCache.has(i))i=L_.textureCache.get(i);else if(!i.isRenderTargetTexture){const e=i.clone();e.colorSpace=ns,L_.textureCache.set(i,e),i=e}this.setOptions({backgroundImage:i,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"})}else this.setOptions({backgroundImage:null,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},h(kT,"textureCache",new Map),kT);let Ou=L_;lz([x(vi)],Ou.prototype,"color",1),lz([x()],Ou.prototype,"raycastTarget",2);class cv extends Ou{constructor(){super(...arguments),h(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var Wse=Object.defineProperty,Xse=Object.getOwnPropertyDescriptor,U_=(i,e,t,s)=>{for(var r=s>1?void 0:s?Xse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Wse(e,t,r),r};let OT=class{constructor(){h(this,"texture",null),h(this,"rect")}};U_([x(Dt)],OT.prototype,"texture",2);let ef=class extends cv{constructor(){super(...arguments),h(this,"_sprite"),h(this,"pixelsPerUnitMultiplier",1)}set image(i){this.sprite||(this.sprite=new OT),this.sprite.texture=i,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(i){this._sprite!==i&&(this._sprite=i,this.onAfterCreated())}isBuiltinSprite(){var i,e,t,s,r,n,o,a;switch((e=(i=this.sprite)==null?void 0:i.texture)==null?void 0:e.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return((r=(s=(t=this.sprite)==null?void 0:t.texture)==null?void 0:s.image)==null?void 0:r.width)===32&&((a=(o=(n=this.sprite)==null?void 0:n.texture)==null?void 0:o.image)==null?void 0:a.height)===32}onBeforeCreate(i){var e,t;super.onBeforeCreate(i),this.isBuiltinSprite()&&(i.borderRadius=5/this.pixelsPerUnitMultiplier,((t=(e=this.sprite)==null?void 0:e.texture)==null?void 0:t.name)==="Knob"&&(i.borderRadius=999))}onAfterCreated(){var i;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((i=this.sprite)==null?void 0:i.texture))}};U_([x(OT)],ef.prototype,"sprite",1),U_([x()],ef.prototype,"pixelsPerUnitMultiplier",2);class F_ extends cv{constructor(){super(...arguments),h(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(e){this._mainTexture!==e&&(this._mainTexture=e,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}U_([x(Dt)],F_.prototype,"mainTexture",1);var qse=Object.defineProperty,Yse=Object.getOwnPropertyDescriptor,Kn=(i,e,t,s)=>{for(var r=s>1?void 0:s?Yse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&qse(e,t,r),r};const tf=oe("debugbutton");class Lu{constructor(){h(this,"colorMultiplier"),h(this,"disabledColor"),h(this,"fadeDuration"),h(this,"highlightedColor"),h(this,"normalColor"),h(this,"pressedColor"),h(this,"selectedColor")}}Kn([x()],Lu.prototype,"colorMultiplier",2),Kn([x(vi)],Lu.prototype,"disabledColor",2),Kn([x()],Lu.prototype,"fadeDuration",2),Kn([x(vi)],Lu.prototype,"highlightedColor",2),Kn([x(vi)],Lu.prototype,"normalColor",2),Kn([x(vi)],Lu.prototype,"pressedColor",2),Kn([x(vi)],Lu.prototype,"selectedColor",2);class tc extends Pe{constructor(){super(...arguments),h(this,"onClick"),h(this,"_isHovered",!1),h(this,"colors"),h(this,"transition"),h(this,"animationTriggers"),h(this,"animator"),h(this,"_interactable",!0),h(this,"_requestedAnimatorTrigger"),h(this,"_isInit",!1),h(this,"_image")}onPointerEnter(e){var t,s;tf&&console.log("Button Enter",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this._isHovered=!0,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("hovered")),this.context.input.setCursorPointer())}onPointerExit(){var e,t;tf&&console.log("Button Exit",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this._isHovered=!1,this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((t=this._image)==null||t.setState("normal")),this.context.input.setCursorNormal())}onPointerDown(e){var t,s;tf&&console.log("Button Down",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState("pressed")))}onPointerUp(e){var t,s;tf&&console.warn("Button Up",(t=this.animationTriggers)==null?void 0:t.highlightedTrigger,this.animator,this._isHovered),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this._isHovered?this.animationTriggers.highlightedTrigger:this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((s=this._image)==null||s.setState(this._isHovered?"hovered":"normal")))}onPointerClick(e){!this.interactable||e.pointerId!==0||e.pointerId!==0&&this.context.input.getIsMouse(e.pointerId)||(tf&&(console.warn("Button Click",this.onClick),cs("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(),tf&&console.log(this),this._isInit=!1,this.init()}start(){var e;(e=this._image)==null||e.setInteractable(this.interactable),this.gameObject.getComponentInParent(ch)||this.gameObject.addComponent(v_)}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=te.getComponent(this.gameObject,ef),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(e){var t,s,r,n,o;e.setInteractable(this.interactable);const a=this.getFinalColor(e.color,(t=this.colors)==null?void 0:t.normalColor),l={state:"normal",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};e.setupState(l);const c=this.getFinalColor(e.color,(s=this.colors)==null?void 0:s.highlightedColor),u={state:"hovered",attributes:{backgroundColor:c,backgroundOpacity:c.alpha}};e.setupState(u);const d=this.getFinalColor(e.color,(r=this.colors)==null?void 0:r.pressedColor),p={state:"pressed",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};e.setupState(p);const f=this.getFinalColor(e.color,(n=this.colors)==null?void 0:n.selectedColor),m={state:"selected",attributes:{backgroundColor:f,backgroundOpacity:f.alpha}};e.setupState(m);const A=this.getFinalColor(e.color,(o=this.colors)==null?void 0:o.disabledColor),v={state:"disabled",attributes:{backgroundColor:A,backgroundOpacity:A.alpha}};e.setupState(v)}getFinalColor(e,t){return t?e.clone().multiply(t).convertLinearToSRGB():e.clone().convertLinearToSRGB()}}Kn([x(hr)],tc.prototype,"onClick",2),Kn([x()],tc.prototype,"colors",2),Kn([x()],tc.prototype,"transition",2),Kn([x()],tc.prototype,"animationTriggers",2),Kn([x(mr)],tc.prototype,"animator",2),Kn([x()],tc.prototype,"interactable",1);var Kse=Object.defineProperty,Jse=Object.getOwnPropertyDescriptor,Is=(i,e,t,s)=>{for(var r=s>1?void 0:s?Jse(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Kse(e,t,r),r};const cz=oe("debuguilayout");class ph{constructor(){h(this,"left",0),h(this,"right",0),h(this,"top",0),h(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}Is([x()],ph.prototype,"left",2),Is([x()],ph.prototype,"right",2),Is([x()],ph.prototype,"top",2),Is([x()],ph.prototype,"bottom",2);class Jn extends Pe{constructor(){super(...arguments),h(this,"_rectTransform",null),h(this,"_needsUpdate",!1),h(this,"childAlignment",0),h(this,"reverseArrangement",!1),h(this,"spacing",0),h(this,"padding"),h(this,"minWidth",0),h(this,"minHeight",0),h(this,"flexibleHeight",0),h(this,"flexibleWidth",0),h(this,"preferredHeight",0),h(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(e){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(cz&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){cz&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(an);const e=this.gameObject.getComponentInParent(gr);e&&e.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const e=this.gameObject.getComponentInParent(gr);e&&e.unregisterLayoutGroup(this)}set m_Spacing(e){e!==this.spacing&&(this._needsUpdate=!0,this.spacing=e)}get m_Spacing(){return this.spacing}}Is([x()],Jn.prototype,"childAlignment",2),Is([x()],Jn.prototype,"reverseArrangement",2),Is([x()],Jn.prototype,"spacing",2),Is([x(ph)],Jn.prototype,"padding",2),Is([x()],Jn.prototype,"minWidth",2),Is([x()],Jn.prototype,"minHeight",2),Is([x()],Jn.prototype,"flexibleHeight",2),Is([x()],Jn.prototype,"flexibleWidth",2),Is([x()],Jn.prototype,"preferredHeight",2),Is([x()],Jn.prototype,"preferredWidth",2);class fh extends Jn{constructor(){super(...arguments),h(this,"childControlHeight",!0),h(this,"childControlWidth",!0),h(this,"childForceExpandHeight",!1),h(this,"childForceExpandWidth",!1),h(this,"childScaleHeight",!1),h(this,"childScaleWidth",!1)}onCalculateLayout(e){var t;const s=this.primaryAxis,r=e.width;let n=r;const o=e.height;let a=o;n-=this.padding.horizontal,a-=this.padding.vertical,s==="x"?this.padding.horizontal:this.padding.vertical;const l=s==="x",c=l?"y":"x",u=l?this.childControlWidth:this.childControlHeight,d=l?this.childControlHeight:this.childControlWidth,p=l?this.childForceExpandWidth:this.childForceExpandHeight,f=l?this.childForceExpandHeight:this.childForceExpandWidth,m=l?a:n,A=l?r:o,v=.5*(l?this.childAlignment%3:Math.floor(this.childAlignment/3));let g=0;l?g+=this.padding.left:g+=this.padding.top;let b=0,y=0;for(let R=0;R<this.gameObject.children.length;R++){const E=this.gameObject.children[R],C=te.getComponent(E,an);C!=null&&C.activeAndEnabled&&(y+=1,l?b+=C.width:b+=C.height)}let _=0;const S=this.spacing*(y-1);if(p||u){let R=0;l?R=n-=S:R=a-=S,y>0&&(_=R/y)}let T=0;T+=this.padding.left,T-=this.padding.right,v!==0&&(g=A-b,g*=v,g-=S*v,l?(g-=this.padding.right*v,g+=this.padding.left*(1-v),g<this.padding.left&&(g=this.padding.left)):(g-=this.padding.bottom*v,g+=this.padding.top*(1-v),g<this.padding.top&&(g=this.padding.top)));let M=1;for(let R=0;R<this.gameObject.children.length;R++){const E=this.gameObject.children[R],C=te.getComponent(E,an);if(C!=null&&C.activeAndEnabled){(t=C.pivot)==null||t.set(.5,.5),C.anchorMin.set(0,1),C.anchorMax.set(0,1);const U=r*.5+T*.5;C.anchoredPosition.x!==U&&(C.anchoredPosition.x=U);const G=o*-.5;C.anchoredPosition.y!==G&&(C.anchoredPosition.y=G),f&&d&&C.sizeDelta[c]!==m&&(C.sizeDelta[c]=m),p&&u&&C.sizeDelta[s]!==_&&(C.sizeDelta[s]=_);const F=l?C.width:C.height,Q=F*.5;if(g+=Q,p){const z=_*M-_*.5;z>g&&(g=z-_*.5+F+this.padding.left,g-=Q)}let K=g;s==="y"&&(K=-K),C.anchoredPosition[s]!==K&&(C.anchoredPosition[s]=K),g+=Q,g+=this.spacing,M+=1}}}}Is([x()],fh.prototype,"childControlHeight",2),Is([x()],fh.prototype,"childControlWidth",2),Is([x()],fh.prototype,"childForceExpandHeight",2),Is([x()],fh.prototype,"childForceExpandWidth",2),Is([x()],fh.prototype,"childScaleHeight",2),Is([x()],fh.prototype,"childScaleWidth",2);class LT extends fh{get primaryAxis(){return"y"}}class UT extends fh{get primaryAxis(){return"x"}}class FT extends Jn{onCalculateLayout(){}}var Zse=Object.defineProperty,$se=Object.getOwnPropertyDescriptor,Qa=(i,e,t,s)=>{for(var r=s>1?void 0:s?$se(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&Zse(e,t,r),r},hz=(i=>(i[i.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",i[i.ScreenSpaceCamera=1]="ScreenSpaceCamera",i[i.WorldSpace=2]="WorldSpace",i[i.Undefined=-1]="Undefined",i))(hz||{});const NT=oe("debuguilayout"),uz=class extends Hg{constructor(){super(...arguments),h(this,"_renderOnTop"),h(this,"_depthWrite",!1),h(this,"_doubleSided",!0),h(this,"_castShadows",!1),h(this,"_receiveShadows",!1),h(this,"_renderMode",-1),h(this,"_rootCanvas"),h(this,"_scaleFactor",1),h(this,"worldCamera"),h(this,"planeDistance",-1),h(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),h(this,"previousParent",null),h(this,"_lastMatrixWorld",null),h(this,"_rectTransforms",[]),h(this,"_layoutGroups",new Map),h(this,"_receivers",[]),h(this,"onBeforeRenderRoutine",()=>{var i,e,t,s;if(this.context.isInVR){this.onUpdateRenderMode(),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),(e=this.shadowComponent)==null||e.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),Xn.ensureUpdateMeshUI(ZM,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),(s=this.shadowComponent)==null||s.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),Xn.ensureUpdateMeshUI(ZM,this.context))}),h(this,"onAfterRenderRoutine",()=>{var i,e;if(!this.context.isInVR){if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const r=this.context.mainCamera;r?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const t=this.context.renderer.autoClear,s=this.context.renderer.autoClearColor;this.context.renderer.autoClear=!1,this.context.renderer.autoClearColor=!1,this.context.renderer.clearDepth(),this.onUpdateRenderMode(!0),this.handleLayoutUpdates(),(i=this.shadowComponent)==null||i.updateMatrixWorld(!0),this.invokeBeforeRenderEvents(),Xn.ensureUpdateMeshUI(ZM,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=t,this.context.renderer.autoClearColor=s,this.previousParent.add(this.gameObject)}(e=this._lastMatrixWorld)==null||e.copy(this.gameObject.matrixWorld)}}),h(this,"_updateRenderSettingsRoutine"),h(this,"_activeRenderMode",-1),h(this,"_lastWidth",-1),h(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(i){i!==this._renderOnTop&&(this._renderOnTop=i,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(i){this._depthWrite!==i&&(this._depthWrite=i,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(i){this._doubleSided!==i&&(this._doubleSided=i,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(i){this._castShadows!==i&&(this._castShadows=i,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(i){this._receiveShadows!==i&&(this._receiveShadows=i,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(i){this._renderMode!==i&&(this._renderMode=i,this.onRenderSettingsChanged())}set rootCanvas(i){this._rootCanvas instanceof uz||(this._rootCanvas=i)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(i){this._scaleFactor=i}awake(){var i;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,NT&&console.log("Canvas.Awake()",((i=this.previousParent)==null?void 0:i.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new Te,this.onUpdateRenderMode(),document.addEventListener("resize",this._boundRenderSettingsChanged),this.context.pre_render_callbacks.push(this.onBeforeRenderRoutine),this.context.post_render_callbacks.push(this.onAfterRenderRoutine)}onDisable(){super.onDisable(),document.removeEventListener("resize",this._boundRenderSettingsChanged);const i=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);i!==-1&&this.context.pre_render_callbacks.splice(i,1);const e=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);e!==-1&&this.context.post_render_callbacks.splice(e,1)}registerTransform(i){this._rectTransforms.push(i)}unregisterTransform(i){const e=this._rectTransforms.indexOf(i);e!==-1&&this._rectTransforms.splice(e,1)}registerLayoutGroup(i){const e=i.gameObject;this._layoutGroups.set(e,i)}unregisterLayoutGroup(i){const e=i.gameObject;this._layoutGroups.delete(e)}registerEventReceiver(i){this._receivers.push(i)}unregisterEventReceiver(i){const e=this._receivers.indexOf(i);e!==-1&&this._receivers.splice(e,1)}invokeBeforeRenderEvents(){var i;for(const e of this._receivers)(i=e.onBeforeCanvasRender)==null||i.call(e,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new Te);const i=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);NT&&i&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const e=!1;for(const t of this._rectTransforms){i&&t.markDirty();let s=this._layoutGroups.get(t.gameObject);t.isDirty&&!s&&(s=t.gameObject.getComponentInParent(Jn)),(t.isDirty||s!=null&&s.isDirty)&&(NT&&!e&&console.log("CANVAS UPDATE ### "+t.name+" ##################################### "+this.context.time.frame),s?.updateLayout(),t.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Xs.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),y_(this.shadowComponent,this);for(const i of te.getComponentsInChildren(this.gameObject,va))y_(i.shadowComponent,this)}}onUpdateRenderMode(i=!1){if(!i&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let e=this.context.mainCameraComponent,t=10;switch(e&&e.nearClipPlane>0&&e.farClipPlane>0&&(t=Je.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 s=t+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-s,this.gameObject.quaternion.identity();const r=this.gameObject.getComponent(an);let n=!1;r.sizeDelta.x!==this.context.domWidth&&(n=!0),r.sizeDelta.y!==this.context.domHeight&&(n=!0);const o=e.fieldOfView*Math.PI/180,a=2*Math.tan(o/2)*Math.abs(s);this.gameObject.scale.x=a/this.context.domHeight,this.gameObject.scale.y=a/this.context.domHeight,this.gameObject.scale.z=.01,n&&(r.sizeDelta.x=this.context.domWidth,r.sizeDelta.y=this.context.domHeight,r?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let gr=uz;Qa([x()],gr.prototype,"renderOnTop",1),Qa([x()],gr.prototype,"depthWrite",1),Qa([x()],gr.prototype,"doubleSided",1),Qa([x()],gr.prototype,"castShadows",1),Qa([x()],gr.prototype,"receiveShadows",1),Qa([x()],gr.prototype,"renderMode",1),Qa([x(gr)],gr.prototype,"rootCanvas",1),Qa([x()],gr.prototype,"scaleFactor",1),Qa([x(Oi)],gr.prototype,"worldCamera",2),Qa([x()],gr.prototype,"planeDistance",2);var ere=Object.defineProperty,tre=Object.getOwnPropertyDescriptor,zT=(i,e,t,s)=>{for(var r=s>1?void 0:s?tre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ere(e,t,r),r};class mh extends Pe{constructor(){super(...arguments),h(this,"_alpha",1),h(this,"interactable",!0),h(this,"blocksRaycasts",!0),h(this,"_isDirty",!1),h(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(e){e!==this._alpha&&(this._alpha=e,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Xs.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){for(const e of te.getComponentsInChildren(this.gameObject,va,this._buffer)){const t=e;t.setAlphaFactor&&t.setAlphaFactor(this._alpha)}}}zT([x()],mh.prototype,"alpha",1),zT([x()],mh.prototype,"interactable",2),zT([x()],mh.prototype,"blocksRaycasts",2);var ire=Object.defineProperty,sre=Object.getOwnPropertyDescriptor,ts=(i,e,t,s)=>{for(var r=s>1?void 0:s?sre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ire(e,t,r),r};function hv(i){i&&(i.getComponentInParent(ch)||(Gt()&&console.warn("Create Raycaster on "+i.name+" because no raycaster was found in the hierarchy"),i.addNewComponent(ha)))}class Uu extends Pe{constructor(){super(...arguments),h(this,"object"),h(this,"target"),h(this,"duration",1),h(this,"relativeMotion",!1),h(this,"coroutine",null),h(this,"targetPos",new w),h(this,"targetRot",new Ce),h(this,"targetScale",new w)}start(){hv(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=ft(this.object).clone(),t=ft(this.target).clone(),s=wi(this.object).clone(),r=wi(this.target).clone(),n=Ws(this.object).clone(),o=Ws(this.target).clone(),a=e.distanceTo(t),l=s.angleTo(r),c=n.distanceTo(o);if(a<.01&&l<.01&&c<.01){us(this.object,t),Yr(this.object,r),c0(this.object,o),this.coroutine=null;return}let u=0,d=0;for(;u<1;)u+=this.context.time.deltaTime/this.duration,u>1&&(u=1),d=u<.5?4*u*u*u:1-Math.pow(-2*u+2,3)/2,this.targetPos.lerpVectors(e,t,d),this.targetRot.slerpQuaternions(s,r,d),this.targetScale.lerpVectors(n,o,d),us(this.object,this.targetPos),Yr(this.object,this.targetRot),c0(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const e=this.object.position.clone(),t=this.object.quaternion.clone(),s=this.object.scale.clone(),r=this.target.position.clone(),n=this.target.quaternion.clone(),o=this.target.scale.clone();r.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(r),this.targetRot.copy(this.object.quaternion).multiply(n),this.targetScale.copy(this.object.scale).multiply(o);let a=0,l=0;for(;a<1;)a+=this.context.time.deltaTime/this.duration,a>1&&(a=1),l=a<.5?4*a*a*a:1-Math.pow(-2*a+2,3)/2,this.object.position.lerpVectors(e,this.targetPos,l),this.object.quaternion.slerpQuaternions(t,this.targetRot,l),this.object.scale.lerpVectors(s,this.targetScale,l),yield;this.coroutine=null}beforeCreateDocument(e){var t;if(this.target&&this.object&&this.gameObject){const s=new rn("Move to "+((t=this.target)==null?void 0:t.name),nn.tapTrigger(this.gameObject),Ai.transformAction(this.object,this.target,this.duration,this.relativeMotion?nT.Relative:nT.Absolute));e.addBehavior(s)}}}ts([x(_e)],Uu.prototype,"object",2),ts([x(_e)],Uu.prototype,"target",2),ts([x()],Uu.prototype,"duration",2),ts([x()],Uu.prototype,"relativeMotion",2);var N_;const ic=(N_=class extends Pe{constructor(){super(...arguments),h(this,"materialToSwitch"),h(this,"variantMaterial"),h(this,"fadeDuration",0),h(this,"_objectsWithThisMaterial",[]),h(this,"selfModel"),h(this,"targetModels")}awake(){if(this.variantMaterial&&this.materialToSwitch){const i=te.findObjectsOfType(ps);for(const e of i)for(let t=0;t<e.sharedMaterials.length;t++){const s=e.sharedMaterials[t];if(s===this.materialToSwitch){if(e.gameObject instanceof ge)this._objectsWithThisMaterial.push(e.gameObject);else if(e.gameObject instanceof Wr)for(const r of e.gameObject.children)r instanceof ge&&r.material===s&&this._objectsWithThisMaterial.push(r);break}}}}start(){hv(this.gameObject)}onPointerClick(i){if(i.use(),!!this.variantMaterial)for(let e=0;e<this._objectsWithThisMaterial.length;e++){const t=this._objectsWithThisMaterial[e];t.material=this.variantMaterial}}async beforeCreateDocument(i,e){this.targetModels=[],ic._materialTriggersPerId={},ic.variantSwitchIndex=0,this.materialToSwitch&&await ra.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await ra.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(i,e,t){this._objectsWithThisMaterial.find(s=>s.uuid===e.uuid)&&this.targetModels.push(e),this.gameObject.uuid===e.uuid&&(this.selfModel=e,this.materialToSwitch&&(ic._materialTriggersPerId[this.materialToSwitch.uuid]||(ic._materialTriggersPerId[this.materialToSwitch.uuid]=[]),ic._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(i,e){if(!this.materialToSwitch)return;const t=ic._materialTriggersPerId[this.materialToSwitch.uuid];if(t){const s={};for(const r of t){const n=r.createVariants();n&&n.length>0&&(s[r.selfModel.uuid]=n)}for(const r of t){const n=[];for(const o in s)o!==r.selfModel.uuid&&n.push(...s[o]);r.createAndAttachBehaviors(i,s[r.selfModel.uuid],n)}}delete ic._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(i,e,t){const s=[],r=[],n=Math.max(0,this.fadeDuration);r.push(Ai.fadeAction([...this.targetModels,...t],n,!1)),s.push(Ai.fadeAction(e,n,!1)),r.push(Ai.fadeAction(e,n,!0)),i.addBehavior(new rn("Select_"+this.selfModel.name,nn.tapTrigger(this.selfModel),Ai.parallel(...r))),i.addBehavior(new rn("StartHidden_"+this.selfModel.name,nn.sceneStartTrigger(),Ai.parallel(...s)))}createVariants(){if(!this.variantMaterial)return null;const i=[];for(const e of this.targetModels){const t=e.clone();t.name+=" variant_"+this.variantMaterial.name+"_"+ic.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())&&wo.createEmptyParent(e),e.parent&&e.parent.add(t),i.push(t)}return i}},h(N_,"_materialTriggersPerId",{}),h(N_,"variantSwitchIndex",0),N_);let sf=ic;ts([x(kt)],sf.prototype,"materialToSwitch",2),ts([x(kt)],sf.prototype,"variantMaterial",2),ts([x()],sf.prototype,"fadeDuration",2);class rf extends Pe{constructor(){super(...arguments),h(this,"target"),h(this,"toggleOnClick",!1),h(this,"targetState",!0),h(this,"hideSelf",!0),h(this,"selfModel"),h(this,"otherModel"),h(this,"toggleModel"),h(this,"stateBeforeCreatingDocument",!1)}start(){hv(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,s){t.uuid===this.gameObject.uuid&&(this.selfModel=t)}beforeCreateDocument(){this.stateBeforeCreatingDocument=this.gameObject.visible,this.gameObject.visible=!0}afterCreateDocument(e,t){if(this.target){if(this.otherModel=t.document.findById(this.target.uuid),this.selfModel&&this.otherModel){let s=this.hideSelf;this.targetState,this.toggleOnClick&&(s=!0,this.target.visible,(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&m3.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.clone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel));const r=[];if(s&&r.push(Ai.fadeAction(this.selfModel,0,!1)),this.toggleModel&&r.push(Ai.fadeAction(this.toggleModel,0,!0)),r.push(Ai.fadeAction(this.otherModel,0,this.targetState)),e.addBehavior(new rn("Toggle_"+this.selfModel.name+"_hideSelf",nn.tapTrigger(this.selfModel),Ai.sequence(...r))),this.toggleOnClick&&this.toggleModel){const n=[];n.push(Ai.fadeAction(this.toggleModel,0,!1)),n.push(Ai.fadeAction(this.selfModel,0,!0)),n.push(Ai.fadeAction(this.otherModel,0,!this.targetState)),e.addBehavior(new rn("Toggle_"+this.selfModel.name+"_toggleSelf",nn.tapTrigger(this.toggleModel),Ai.sequence(...n))),e.addBehavior(new rn("HideOnStart_"+this.gameObject.name,nn.sceneStartTrigger(),Ai.fadeAction(this.toggleModel,0,!1)))}}this.gameObject.visible=this.stateBeforeCreatingDocument}}}ts([x(_e)],rf.prototype,"target",2),ts([x()],rf.prototype,"targetState",2),ts([x()],rf.prototype,"hideSelf",2);class jT extends Pe{start(){this.gameObject.visible=!1}createBehaviours(e,t,s){t.uuid===this.gameObject.uuid&&e.addBehavior(new rn("HideOnStart_"+this.gameObject.name,nn.sceneStartTrigger(),Ai.fadeAction(t,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class nf extends Pe{constructor(){super(...arguments),h(this,"target"),h(this,"duration",.5),h(this,"motionType",rT.bounce)}beforeCreateDocument(){}createBehaviours(e,t,s){if(this.target&&t.uuid===this.gameObject.uuid){const r=new rn("emphasize "+this.name,nn.tapTrigger(this.gameObject),Ai.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));e.addBehavior(r)}}afterCreateDocument(e,t){}}ts([x()],nf.prototype,"target",2),ts([x()],nf.prototype,"duration",2),ts([x()],nf.prototype,"motionType",2);class of extends Pe{constructor(){super(...arguments),h(this,"target"),h(this,"clip",""),h(this,"toggleOnClick",!1)}start(){hv(this.gameObject)}onPointerClick(e){if(e.use(),!!this.clip){if(!this.target){const t=this.gameObject.addNewComponent(ms);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,s){if(!(!this.target&&!this.clip)&&t.uuid===this.gameObject.uuid){const r=this.clip?this.clip:this.target?this.target.clip:void 0;if(!r||typeof r!="string")return;const n=this.target?this.target.gameObject:this.gameObject,o=r.split("/").pop(),a=this.target?this.target.volume:1,l=this.target&&this.target.spatialBlend==0?aT.NonSpatial:aT.Spatial,c=new rn("playAudio "+this.name,nn.tapTrigger(this.gameObject),Ai.playAudioAction(n,"audio/"+o,I3.Play,a,l));e.addBehavior(c)}}async afterSerialize(e,t){if(!this.target&&!this.clip)return;const s=this.clip?this.clip:this.target?this.target.clip:void 0;if(!s||typeof s!="string")return;const r=s.split("/").pop(),n=await(await(await fetch(this.clip)).blob()).arrayBuffer(),o=new Uint8Array(n);t.files["audio/"+r]=o}}ts([x(ms)],of.prototype,"target",2),ts([x(URL)],of.prototype,"clip",2),ts([x()],of.prototype,"toggleOnClick",2);var z_;const gh=(z_=class extends Pe{constructor(){super(...arguments),h(this,"animator"),h(this,"stateName"),h(this,"trigger","tap"),h(this,"selfModel"),h(this,"stateAnimationModel"),h(this,"animationSequence",new Array),h(this,"animationLoopAfterSequence",new Array)}get target(){var i;return(i=this.animator)==null?void 0:i.gameObject}start(){hv(this.gameObject)}onPointerClick(i){var e;i.use(),this.target&&this.stateName&&((e=this.animator)==null||e.play(this.stateName,0,0,.1))}createBehaviours(i,e,t){e.uuid===this.gameObject.uuid&&(this.selfModel=e)}afterSerialize(){if(gh.rootsWithExclusivePlayback.size>1){const i='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.';Gt()&&Vs(i),console.warn(i,...gh.rootsWithExclusivePlayback)}gh.animationActions=[],gh.rootsWithExclusivePlayback=new Set}afterCreateDocument(i,e){if(!this.animationSequence||!this.stateAnimationModel||!this.target)return;const t=e.document,s=e.extensions.find(o=>o instanceof ev);if(!s)return;const r=s.getClipCount(this.target)>1;r&&(Gt()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+s.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),gh.rootsWithExclusivePlayback.add(this.target));const n=(o,a)=>{let l=gh.animationActions.find(c=>c.affectedObjects==o&&c.start==a.start&&c.duration==a.duration);return l||(l=Ai.startAnimationAction(o,a.start,a.duration),gh.animationActions.push(l)),l};t.traverse(o=>{var a,l;if(o.uuid===((a=this.target)==null?void 0:a.uuid)){const c=Ai.sequence();if(this.animationSequence!==void 0)for(const d of this.animationSequence)c.addAction(n(o,d));if(this.animationLoopAfterSequence!==void 0){const d=c.actions.length==0?c:Ai.sequence();for(const p of this.animationLoopAfterSequence)d.addAction(n(o,p));d.makeLooping(),c!==d&&c.addAction(d)}const u=new rn("tap "+this.name+" for "+this.stateName+" on "+((l=this.target)==null?void 0:l.name),this.trigger=="tap"?nn.tapTrigger(this.selfModel):nn.sceneStartTrigger(),c);r&&u.makeExclusive(!0),i.addBehavior(u)}})}createAnimation(i,e,t){var s,r,n,o;if(!this.target||!this.animator)return;const a=(s=this.animator)==null?void 0:s.runtimeAnimatorController;let l=a?.findState(this.stateName),c=[],u=[];if(a&&l){const d=new Array;d.push(l);let p=!1;for(;d.length<100;){if(!l||l===null||!l.transitions||l.transitions.length===0){(r=l.motion)!=null&&r.isLooping&&(p=!0);break}const f=l.transitions.find(A=>A.conditions.length===0),m=f?a.getState(f.destinationState,0):null;if(m&&d.includes(m)){l=m,p=!0;break}else if(f){if(l=m,!l)break;d.push(l)}else{p=((n=l.motion)==null?void 0:n.isLooping)??!1;break}}if(p&&l){const f=d.indexOf(l);c=d.slice(0,f),u=d.slice(f),console.log("found loop from "+this.stateName,"states until loop",c,"states looping",u)}else c=d,u=[],console.log("found no loop from "+this.stateName,"states",c)}if(c=c.filter(d=>{var p,f,m;return((p=d.motion)==null?void 0:p.clip)&&((m=(f=d.motion)==null?void 0:f.clip.tracks)==null?void 0:m.length)>0}),u=u.filter(d=>{var p,f,m;return((p=d.motion)==null?void 0:p.clip)&&((m=(f=d.motion)==null?void 0:f.clip.tracks)==null?void 0:m.length)>0}),c.length===0&&u.length===0){console.warn("No clips found for state "+this.stateName+" on "+((o=this.animator)==null?void 0:o.name)+", can't export animation data");return}if(this.stateAnimationModel=e,c.length>0){this.animationSequence=new Array;for(const d of c)this.animationSequence.push(i.registerAnimation(this.target,d.motion.clip))}if(u.length>0){this.animationLoopAfterSequence=new Array;for(const d of u)this.animationLoopAfterSequence.push(i.registerAnimation(this.target,d.motion.clip))}}},h(z_,"animationActions",[]),h(z_,"rootsWithExclusivePlayback",new Set),z_);let af=gh;ts([x(mr)],af.prototype,"animator",2),ts([x()],af.prototype,"stateName",2);class lf extends Pe{constructor(){super(...arguments),h(this,"target")}getType(){}getDuration(){}}ts([x(_e)],lf.prototype,"target",2);class uv extends Pe{constructor(){super(...arguments),h(this,"target")}}ts([x(lf)],uv.prototype,"target",2);class dv extends lf{constructor(){super(...arguments),h(this,"type",1),h(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}ts([x()],dv.prototype,"type",2),ts([x()],dv.prototype,"duration",2);class GT extends uv{}var rre=Object.defineProperty,nre=Object.getOwnPropertyDescriptor,sc=(i,e,t,s)=>{for(var r=s>1?void 0:s?nre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&rre(e,t,r),r};const dz=oe("debugcharactercontroller");class Fu extends Pe{constructor(){super(...arguments),h(this,"center",new w(0,0,0)),h(this,"radius",.5),h(this,"height",2),h(this,"_rigidbody",null),h(this,"_activeGroundCollisions"),h(this,"_contactVelocity",new w)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Ii),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Ii)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const e=this.rigidbody;let t=this.gameObject.getComponent(dh);t||(t=this.gameObject.addNewComponent(dh)),t.center.copy(this.center),t.radius=this.radius,t.height=this.height;const s=new w(0,0,1),r=new w(1,0,0),n=new w(0,1,0),o=this.gameObject.getWorldDirection(new w);o.y=0;const a=r.dot(o)<0?-1:1,l=s.angleTo(o)*a;this.gameObject.setRotationFromAxisAngle(n,l),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),dz&&console.log(`Collision(${this._activeGroundCollisions.size}): ${e.contacts.map(t=>t.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(e){this._activeGroundCollisions.delete(e),dz&&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 s=(e=this.context.physics.engine)==null?void 0:e.getLinearVelocity(t.collider);s&&(this._contactVelocity.x+=s.x,this._contactVelocity.y+=s.y,this._contactVelocity.z+=s.z)}return this._contactVelocity}}sc([x(w)],Fu.prototype,"center",2),sc([x()],Fu.prototype,"radius",2),sc([x()],Fu.prototype,"height",2);class rc extends Pe{constructor(){super(...arguments),h(this,"controller"),h(this,"movementSpeed",2),h(this,"rotationSpeed",2),h(this,"jumpForce",1),h(this,"doubleJumpForce",2),h(this,"animator"),h(this,"lookForward",!0),h(this,"lookInput",new ee(0,0)),h(this,"moveInput",new ee(0,0)),h(this,"jumpInput",!1),h(this,"_currentSpeed",new w(0,0,0)),h(this,"_currentAngularSpeed",new w(0,0,0)),h(this,"_temp",new w(0,0,0)),h(this,"_jumpCount",0),h(this,"_currentRotation"),h(this,"_raycastOptions",new Nn)}awake(){this._currentRotation=new Ce}update(){const e=this.context.input;e.isKeyPressed("KeyW")?this.moveInput.y+=1:e.isKeyPressed("KeyS")&&(this.moveInput.y-=1),e.isKeyPressed("KeyD")?this.lookInput.x+=1:e.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=e.isKeyDown("Space"))}move(e){this.moveInput.add(e)}look(e){this.lookInput.add(e)}jump(){this.jumpInput=!0}onBeforeRender(){this.handleInput(this.moveInput,this.lookInput,this.jumpInput),this.lookInput.set(0,0),this.moveInput.set(0,0),this.jumpInput=!1}handleInput(e,t,s){var r,n,o,a,l,c,u,d,p,f,m;if((r=this.controller)!=null&&r.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((n=this.animator)==null||n.setBool("doubleJump",!1))),this._currentSpeed.z+=e.y*this.movementSpeed*this.context.time.deltaTime,(o=this.animator)==null||o.setBool("running",e.length()>.01),(l=this.animator)==null||l.setBool("jumping",((a=this.controller)==null?void 0:a.isGrounded)===!0&&s),this._temp.copy(this._currentSpeed),this._temp.applyQuaternion(this.gameObject.quaternion),this.controller?this.controller.move(this._temp):this.gameObject.position.add(this._temp),this._currentAngularSpeed.y+=Je.toRadians(-t.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const A=this.context.mainCameraComponent.forward;A.y=0,A.normalize(),this._currentRotation.setFromUnitVectors(new w(0,0,1),A),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&s&&this.jumpForce>0){let A=(c=this.controller)==null?void 0:c.isGrounded;if(this.doubleJumpForce>0&&!((u=this.controller)!=null&&u.isGrounded)&&this._jumpCount===1&&(A=!0,(d=this.animator)==null||d.setBool("doubleJump",!0)),A){this._jumpCount+=1;const v=this.controller.rigidbody,g=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;v.applyImpulse(new w(0,1,0).multiplyScalar(g))}}if(this.controller){const A=(p=this.controller)==null?void 0:p.rigidbody.getVelocity().y;if(A<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new Go),this._raycastOptions.ray.origin.copy(ft(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const v=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const g=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(v),(g.length&&g[0].distance>2||A<-10)&&((f=this.animator)==null||f.setBool("falling",!0))}else(m=this.animator)==null||m.setBool("falling",!1)}}}sc([x(Fu)],rc.prototype,"controller",2),sc([x()],rc.prototype,"movementSpeed",2),sc([x()],rc.prototype,"rotationSpeed",2),sc([x()],rc.prototype,"jumpForce",2),sc([x()],rc.prototype,"doubleJumpForce",2),sc([x(mr)],rc.prototype,"animator",2);var ore=Object.defineProperty,are=Object.getOwnPropertyDescriptor,lre=(i,e,t,s)=>{for(var r=s>1?void 0:s?are(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&ore(e,t,r),r};class pv extends Lr{constructor(){super(...arguments),h(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const e=new FL;return e.offset=new ee(0,0),e.radialModulation=!0,e.modulationOffset=.15,this.intensity.valueProcessor=t=>t*.02,this.intensity.onValueChanged=t=>{e.offset.x=-t,e.offset.y=t},e}}lre([x(Tt)],pv.prototype,"intensity",2),Io("ChromaticAberration",pv);var cre=Object.defineProperty,hre=Object.getOwnPropertyDescriptor,j_=(i,e,t,s)=>{for(var r=s>1?void 0:s?hre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&cre(e,t,r),r};class vh extends Lr{constructor(){super(...arguments),h(this,"postExposure"),h(this,"contrast"),h(this,"hueShift"),h(this,"saturation")}get typeName(){return"ColorAdjustments"}init(){this.postExposure.valueProcessor=e=>(e=Math.pow(2,e),e),this.postExposure.defaultValue=0,this.contrast.valueProcessor=e=>{let t=1;return e>0?t=200:e<0&&(t=100),e/t},this.contrast.defaultValue=0,this.hueShift.valueProcessor=e=>Math.PI*e/180,this.hueShift.defaultValue=0,this.saturation.valueProcessor=e=>e<0?e/100:e/(100*Math.PI),this.saturation.defaultValue=0}unapply(){this.context.renderer.toneMappingExposure=1}onCreateEffect(){this.context.renderer.toneMapping===Qr&&this.postExposure.overrideState&&(this.context.renderer.toneMapping=Vf);const e=new UL;this.postExposure.onValueChanged=s=>{this.context.renderer.toneMapping===Qr&&(this.context.renderer.toneMapping=Vf),this.postExposure.overrideState&&(this.context.renderer.toneMappingExposure=s)},this.contrast.onValueChanged=s=>{e.contrast=s};const t=new zL;return this.hueShift.onValueChanged=s=>t.hue=s,this.saturation.onValueChanged=s=>t.saturation=s,[t,e]}}j_([x(Tt)],vh.prototype,"postExposure",2),j_([x(Tt)],vh.prototype,"contrast",2),j_([x(Tt)],vh.prototype,"hueShift",2),j_([x(Tt)],vh.prototype,"saturation",2),Io("ColorAdjustments",vh);const ure=(Math.sqrt(5)-1)/4,vr=(5-Math.sqrt(5))/20,G_=i=>Math.floor(i)|0,Q_=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 dre(i=Math.random){const e=pre(i),t=new Float64Array(e).map(o=>Q_[o%32*4]),s=new Float64Array(e).map(o=>Q_[o%32*4+1]),r=new Float64Array(e).map(o=>Q_[o%32*4+2]),n=new Float64Array(e).map(o=>Q_[o%32*4+3]);return function(o,a,l,c){let u,d,p,f,m;const A=(o+a+l+c)*ure,v=G_(o+A),g=G_(a+A),b=G_(l+A),y=G_(c+A),_=(v+g+b+y)*vr,S=v-_,T=g-_,M=b-_,R=y-_,E=o-S,C=a-T,U=l-M,G=c-R;let F=0,Q=0,K=0,z=0;E>C?F++:Q++,E>U?F++:K++,E>G?F++:z++,C>U?Q++:K++,C>G?Q++:z++,U>G?K++:z++;const O=F>=3?1:0,j=Q>=3?1:0,se=K>=3?1:0,$=z>=3?1:0,X=F>=2?1:0,ie=Q>=2?1:0,fe=K>=2?1:0,xe=z>=2?1:0,Be=F>=1?1:0,Fe=Q>=1?1:0,We=K>=1?1:0,Ze=z>=1?1:0,qe=E-O+vr,wt=C-j+vr,pe=U-se+vr,q=G-$+vr,Ue=E-X+2*vr,we=C-ie+2*vr,Ae=U-fe+2*vr,je=G-xe+2*vr,ve=E-Be+3*vr,Ke=C-Fe+3*vr,ot=U-We+3*vr,pt=G-Ze+3*vr,Yt=E-1+4*vr,ni=C-1+4*vr,N=U-1+4*vr,k=G-1+4*vr,ue=v&255,ke=g&255,Oe=b&255,V=y&255;let ye=.6-E*E-C*C-U*U-G*G;if(ye<0)u=0;else{const Se=ue+e[ke+e[Oe+e[V]]];ye*=ye,u=ye*ye*(t[Se]*E+s[Se]*C+r[Se]*U+n[Se]*G)}let Ie=.6-qe*qe-wt*wt-pe*pe-q*q;if(Ie<0)d=0;else{const Se=ue+O+e[ke+j+e[Oe+se+e[V+$]]];Ie*=Ie,d=Ie*Ie*(t[Se]*qe+s[Se]*wt+r[Se]*pe+n[Se]*q)}let de=.6-Ue*Ue-we*we-Ae*Ae-je*je;if(de<0)p=0;else{const Se=ue+X+e[ke+ie+e[Oe+fe+e[V+xe]]];de*=de,p=de*de*(t[Se]*Ue+s[Se]*we+r[Se]*Ae+n[Se]*je)}let Xe=.6-ve*ve-Ke*Ke-ot*ot-pt*pt;if(Xe<0)f=0;else{const Se=ue+Be+e[ke+Fe+e[Oe+We+e[V+Ze]]];Xe*=Xe,f=Xe*Xe*(t[Se]*ve+s[Se]*Ke+r[Se]*ot+n[Se]*pt)}let Ye=.6-Yt*Yt-ni*ni-N*N-k*k;if(Ye<0)m=0;else{const Se=ue+1+e[ke+1+e[Oe+1+e[V+1]]];Ye*=Ye,m=Ye*Ye*(t[Se]*Yt+s[Se]*ni+r[Se]*N+n[Se]*k)}return 27*(u+d+p+f+m)}}function pre(i){const e=new Uint8Array(512);for(let t=0;t<512/2;t++)e[t]=t;for(let t=0;t<512/2-1;t++){const s=t+~~(i()*(256-t)),r=e[t];e[t]=e[s],e[s]=r}for(let t=256;t<512;t++)e[t]=e[t-256];return e}var fre=Object.defineProperty,mre=Object.getOwnPropertyDescriptor,ne=(i,e,t,s)=>{for(var r=s>1?void 0:s?mre(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(e,t,r):o(r))||r);return s&&r&&fre(e,t,r),r};const H_=oe("debugparticles");var nc=(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))(nc||{});let Ah=class{constructor(){h(this,"alphaKeys"),h(this,"colorKeys")}get duration(){return 1}evaluate(i,e){let t,s=0,r=null,n=0;for(let o=0;o<this.alphaKeys.length;o++){const a=this.alphaKeys[o];(a.time<i||!t)&&(t=a,s=o)}for(let o=0;o<this.colorKeys.length;o++){const a=this.colorKeys[o];(a.time<i||!r)&&(r=a,n=o)}if(r)if(n+1<this.colorKeys.length){const o=this.colorKeys[n+1],a=Je.remap(i,r.time,o.time,0,1);e.r=Je.lerp(r.color.r,o.color.r,a),e.g=Je.lerp(r.color.g,o.color.g,a),e.b=Je.lerp(r.color.b,o.color.b,a)}else e.r=r.color.r,e.g=r.color.g,e.b=r.color.b;if(t)if(s+1<this.alphaKeys.length){const o=this.alphaKeys[s+1],a=Je.remap(i,t.time,o.time,0,1);e.alpha=Je.lerp(t.alpha,o.alpha,a)}else e.alpha=t.alpha;return e}};ne([x()],Ah.prototype,"alphaKeys",2),ne([x()],Ah.prototype,"colorKeys",2);var fv=(i=>(i[i.Local=0]="Local",i[i.World=1]="World",i[i.Custom=2]="Custom",i))(fv||{}),pz=(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))(pz||{});class ht{constructor(){h(this,"mode"),h(this,"constant"),h(this,"constantMin"),h(this,"constantMax"),h(this,"curve"),h(this,"curveMin"),h(this,"curveMax"),h(this,"curveMultiplier")}evaluate(e,t){const s=t===void 0?Math.random():t;switch(this.mode){case 0:return this.constant;case 1:return e=Je.clamp01(e),this.curve.evaluate(e)*this.curveMultiplier;case 2:const r=e*this.curveMin.duration,n=e*this.curveMax.duration;return Je.lerp(this.curveMin.evaluate(r),this.curveMax.evaluate(n),s%1)*this.curveMultiplier;case 3:return Je.lerp(this.constantMin,this.constantMax,s%1);default:this.curveMax.evaluate(e)*this.curveMultiplier;break}return 0}getMax(){switch(this.mode){case 0:return this.constant;case 1:return this.getMaxFromCurve(this.curve)*this.curveMultiplier;case 2:return Math.max(this.getMaxFromCurve(this.curveMin),this.getMaxFromCurve(this.curveMax))*this.curveMultiplier;case 3:return Math.max(this.constantMin,this.constantMax);default:return 0}}getMaxFromCurve(e){if(!e)return 0;let t=Number.MIN_VALUE;for(let s=0;s<e.keys.length;s++){const r=e.keys[s];r.value>t&&(t=r.value)}return t}}ne([x()],ht.prototype,"mode",2),ne([x()],ht.prototype,"constant",2),ne([x()],ht.prototype,"constantMin",2),ne([x()],ht.prototype,"constantMax",2),ne([x(Tu)],ht.prototype,"curve",2),ne([x(Tu)],ht.prototype,"curveMin",2),ne([x(Tu)],ht.prototype,"curveMax",2),ne([x()],ht.prototype,"curveMultiplier",2);var V_;const da=(V_=class{constructor(){h(this,"mode"),h(this,"color"),h(this,"colorMin"),h(this,"colorMax"),h(this,"gradient"),h(this,"gradientMin"),h(this,"gradientMax")}evaluate(i,e){const t=e===void 0?Math.random():e;switch(this.mode){case 0:return this.color;case 1:return this.gradient.evaluate(i,da._temp),da._temp;case 2:return da._temp.lerpColors(this.colorMin,this.colorMax,t);case 3:return this.gradientMin.evaluate(i,da._temp),this.gradientMax.evaluate(i,da._temp2),da._temp.lerp(da._temp2,t)}return da._temp.set(16711935),da._temp.alpha=1,da._temp}},h(V_,"_temp",new vi(0,0,0,1)),h(V_,"_temp2",new vi(0,0,0,1)),V_);let wn=da;ne([x(vi)],wn.prototype,"color",2),ne([x(vi)],wn.prototype,"colorMin",2),ne([x(vi)],wn.prototype,"colorMax",2),ne([x(Ah)],wn.prototype,"gradient",2),ne([x(Ah)],wn.prototype,"gradientMin",2),ne([x(Ah)],wn.prototype,"gradientMax",2);var QT=(i=>(i[i.Hierarchy=0]="Hierarchy",i[i.Local=1]="Local",i[i.Shape=2]="Shape",i))(QT||{});class Ar{constructor(){h(this,"cullingMode"),h(this,"duration"),h(this,"emitterVelocityMode"),h(this,"flipRotation"),h(this,"gravityModifier"),h(this,"gravityModifierMultiplier"),h(this,"loop"),h(this,"maxParticles"),h(this,"playOnAwake"),h(this,"prewarm"),h(this,"ringBufferLoopRange"),h(this,"ringBufferMode"),h(this,"scalingMode"),h(this,"simulationSpace"),h(this,"simulationSpeed"),h(this,"startColor"),h(this,"startDelay"),h(this,"startDelayMultiplier"),h(this,"startLifetime"),h(this,"startLifetimeMultiplier"),h(this,"startRotation"),h(this,"startRotationMultiplier"),h(this,"startRotation3D"),h(this,"startRotationX"),h(this,"startRotationXMultiplier"),h(this,"startRotationY"),h(this,"startRotationYMultiplier"),h(this,"startRotationZ"),h(this,"startRotationZMultiplier"),h(this,"startSize"),h(this,"startSize3D"),h(this,"startSizeMultiplier"),h(this,"startSizeX"),h(this,"startSizeXMultiplier"),h(this,"startSizeY"),h(this,"startSizeYMultiplier"),h(this,"startSizeZ"),h(this,"startSizeZMultiplier"),h(this,"startSpeed"),h(this,"startSpeedMultiplier"),h(this,"stopAction"),h(this,"useUnscaledTime")}}ne([x(ht)],Ar.prototype,"gravityModifier",2),ne([x(wn)],Ar.prototype,"startColor",2),ne([x(ht)],Ar.prototype,"startDelay",2),ne([x(ht)],Ar.prototype,"startLifetime",2),ne([x(ht)],Ar.prototype,"startRotation",2),ne([x(ht)],Ar.prototype,"startRotationX",2),ne([x(ht)],Ar.prototype,"startRotationY",2),ne([x(ht)],Ar.prototype,"startRotationZ",2),ne([x(ht)],Ar.prototype,"startSize",2),ne([x(ht)],Ar.prototype,"startSizeX",2),ne([x(ht)],Ar.prototype,"startSizeY",2),ne([x(ht)],Ar.prototype,"startSizeZ",2),ne([x(ht)],Ar.prototype,"startSpeed",2);class mv{constructor(){h(this,"cycleCount"),h(this,"maxCount"),h(this,"minCount"),h(this,"probability"),h(this,"repeatInterval"),h(this,"time"),h(this,"count"),h(this,"_performed",0)}reset(){this._performed=0}run(e){if(e<=this.time)return 0;let t=0;if(this.cycleCount===0||this._performed<this.cycleCount){const s=this.time+this.repeatInterval*this._performed;if(e>=s&&(this._performed+=1,Math.random()<this.probability))switch(this.count.mode){case 0:t=this.count.constant;break;case 3:t=Je.lerp(this.count.constantMin,this.count.constantMax,Math.random());break;case 1:t=this.count.curve.evaluate(Math.random());break;case 2:const r=Math.random();t=Je.lerp(this.count.curveMin.evaluate(r),this.count.curveMax.evaluate(r),Math.random());break}}return t}}class Ha{constructor(){h(this,"enabled"),h(this,"bursts"),h(this,"rateOverTime"),h(this,"rateOverTimeMultiplier"),h(this,"rateOverDistance"),h(this,"rateOverDistanceMultiplier"),h(this,"system")}get burstCount(){var e;return((e=this.bursts)==null?void 0:e.length)??0}reset(){var e;(e=this.bursts)==null||e.forEach(t=>t.reset())}getBurst(){let e=0;if(this.burstCount>0)for(let t=0;t<this.burstCount;t++){const s=this.bursts[t];this.system.main.loop&&s.time>=this.system.time&&s.reset(),e+=Math.round(s.run(this.system.time))}return e}}ne([x()],Ha.prototype,"enabled",2),ne([x()],Ha.prototype,"bursts",2),ne([x(ht)],Ha.prototype,"rateOverTime",2),ne([x()],Ha.prototype,"rateOverTimeMultiplier",2),ne([x(ht)],Ha.prototype,"rateOverDistance",2),ne([x()],Ha.prototype,"rateOverDistanceMultiplier",2);class gv{constructor(){h(this,"enabled"),h(this,"color")}}ne([x(wn)],gv.prototype,"color",2);class yh{constructor(){h(this,"enabled"),h(this,"separateAxes"),h(this,"size"),h(this,"sizeMultiplier"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier"),h(this,"_time",0),h(this,"_temp",new w)}evaluate(e,t,s){if(t||(t=this._temp),!this.enabled)return t.x=t.y=t.z=1,t;if(this.separateAxes)t.x=this.x.evaluate(e,s)*this.xMultiplier,t.y=this.y.evaluate(e,s)*this.yMultiplier,t.z=this.z.evaluate(e,s)*this.zMultiplier;else{const r=this.size.evaluate(e,s)*this.sizeMultiplier;t.x=r}return t}}ne([x(ht)],yh.prototype,"size",2),ne([x(ht)],yh.prototype,"x",2),ne([x(ht)],yh.prototype,"y",2),ne([x(ht)],yh.prototype,"z",2);var W_;const vv=(W_=class{constructor(){h(this,"shapeType",5),h(this,"enabled",!0),h(this,"alignToDirection",!1),h(this,"angle",0),h(this,"arc",360),h(this,"arcSpread"),h(this,"arcSpeedMultiplier"),h(this,"arcMode"),h(this,"boxThickness"),h(this,"position"),h(this,"rotation"),h(this,"_rotation",new ys),h(this,"scale"),h(this,"radius"),h(this,"radiusThickness"),h(this,"sphericalDirectionAmount"),h(this,"randomDirectionAmount"),h(this,"randomPositionAmount"),h(this,"system"),h(this,"_space"),h(this,"_worldSpaceMatrix",new Te),h(this,"_worldSpaceMatrixInverse",new Te),h(this,"_vector",new w(0,0,0)),h(this,"_temp",new w(0,0,0)),h(this,"_dir",new w),h(this,"_loopTime",0),h(this,"_loopDirection",1),H_&&console.log(this)}get type(){return pz[this.shapeType]}initialize(i){this.getPosition(),i.position.copy(this._vector)}toJSON(){return this}clone(){return new vv}update(i,e,t,s){this.system=i,this._space=t,t===1&&(this._worldSpaceMatrix.copy(s.matrixWorld),this._worldSpaceMatrix.elements[0]=1,this._worldSpaceMatrix.elements[5]=1,this._worldSpaceMatrix.elements[10]=1,this._worldSpaceMatrixInverse.copy(this._worldSpaceMatrix).invert())}applyRotation(i){const e=this.rotation.x!==0||this.rotation.y!==0||this.rotation.z!==0;return e&&(this._rotation.x=Je.toRadians(this.rotation.x),this._rotation.y=Je.toRadians(this.rotation.y),this._rotation.z=Je.toRadians(this.rotation.z),this._rotation.order="ZYX",i.applyEuler(this._rotation)),e}get vector(){return this._vector}getPosition(){this._vector.set(0,0,0);const i=this._temp.copy(this.position),e=this._space===1;e&&i.applyQuaternion(this.system.worldQuaternion);let t=this.radius;if(e&&(t*=this.system.worldScale.x),this.enabled){switch(this.shapeType){case 5:H_&&Oa.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,t,this.radiusThickness,this.arc,this.arcMode,this._vector);break;case 0:this.randomSpherePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;case 10:this.randomCirclePoint(this.position,t,this.radiusThickness,this.arc,this._vector);break;default:this._vector.set(0,0,0);break}this.randomizePosition(this._vector,this.randomPositionAmount)}this.applyRotation(this._vector),e&&(this._vector.applyQuaternion(this.system.worldQuaternion),this._vector.add(this.system.worldPos)),H_&&Oa.DrawSphere(this._vector,.03,16711680,.5,!0)}getDirection(i){var e;if(!this.enabled)return this._dir.set(0,0,1),this._dir;switch(this.shapeType){case 5:this._dir.set(0,0,1);break;case 4:this._dir.set(0,0,1);break;case 10:case 0:const t=i.x,s=i.y,r=i.z;this._dir.set(t,s,r),(e=this.system)!=null&&e.worldspace?this._dir.sub(this.system.worldPos):this._dir.sub(this.position);break;default:this._dir.set(0,0,1);break}return this._space===1&&this._dir.applyQuaternion(this.system.worldQuaternion),this.applyRotation(this._dir),this._dir.normalize(),this.spherizeDirection(this._dir,this.sphericalDirectionAmount),this.randomizeDirection(this._dir,this.randomDirectionAmount),H_&&(Oa.DrawSphere(i,.01,8925952,.5,!0),Oa.DrawDirection(i,this._dir,8925952,.5,!0)),this._dir}randomizePosition(i,e){if(e<=0)return;const t=vv._tempVec;t.set(Math.random()*2-1,Math.random()*2-1,Math.random()*2-1),t.x*=e*this.scale.x,t.y*=e*this.scale.y,t.z*=e*this.scale.z,i.add(t)}randomizeDirection(i,e){if(e===0)return;const t=vv._randomQuat,s=vv._tempVec;s.set(Math.random()-.5,Math.random()-.5,Math.random()-.5).normalize(),t.setFromAxisAngle(s,e*Math.random()*Math.PI),i.applyQuaternion(t)}spherizeDirection(i,e){if(e===0)return;const t=Math.random()*Math.PI*2,s=Math.acos(1-Math.random()*2),r=Math.sin(s)*Math.cos(t),n=Math.sin(s)*Math.sin(t),o=Math.cos(s),a=new w(r,n,o);i.lerp(a,e)}randomSpherePoint(i,e,t,s,r){const n=Math.random(),o=Math.random(),a=2*Math.PI*n*(s/360),l=Math.acos(2*o-1),c=Je.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,u=i.x+this.scale.x*(-c*Math.sin(l)*Math.cos(a)),d=i.y+this.scale.y*(c*Math.sin(l)*Math.sin(a)),p=i.z+this.scale.z*(c*Math.cos(l));r.x=u,r.y=d,r.z=p}randomCirclePoint(i,e,t,s,r){const n=Math.random(),o=2*Math.PI*n*(s/360),a=Je.lerp(1,1-Math.pow(1-Math.random(),Math.PI),t)*e,l=i.x+this.scale.x*a*Math.cos(o),c=i.y+this.scale.y*a*Math.sin(o),u=i.z;r.x=l,r.y=c,r.z=u}randomConePoint(i,e,t,s,r,n,o){let a=0,l=0;switch(n){case 0:a=Math.random(),l=Math.random();break;case 2:this._loopTime>1&&(this._loopDirection=-1),this._loopTime<0&&(this._loopDirection=1);case 1:a=.5,l=Math.random(),this._loopTime+=this.system.deltaTime*this._loopDirection;break}let c=2*Math.PI*a*(r/360);switch(n){case 2:case 1:c+=Math.PI+.5,c+=this._loopTime*Math.PI*2,c%=Je.toRadians(r);break}const u=Math.acos(2*l-1),d=Je.lerp(1,1-Math.pow(1-Math.random(),Math.PI),s)*t,p=i.x+-d*Math.sin(u)*Math.cos(c),f=i.y+d*Math.sin(u)*Math.sin(c),m=i.z;o.x=p*this.scale.x,o.y=f*this.scale.y,o.z=m*this.scale.z}},h(W_,"_randomQuat",new Ce),h(W_,"_tempVec",new w),W_);let As=vv;ne([x()],As.prototype,"shapeType",2),ne([x()],As.prototype,"enabled",2),ne([x()],As.prototype,"alignToDirection",2),ne([x()],As.prototype,"angle",2),ne([x()],As.prototype,"arc",2),ne([x()],As.prototype,"arcSpread",2),ne([x()],As.prototype,"arcSpeedMultiplier",2),ne([x()],As.prototype,"arcMode",2),ne([x(w)],As.prototype,"boxThickness",2),ne([x(w)],As.prototype,"position",2),ne([x(w)],As.prototype,"rotation",2),ne([x(w)],As.prototype,"scale",2),ne([x()],As.prototype,"radius",2),ne([x()],As.prototype,"radiusThickness",2),ne([x()],As.prototype,"sphericalDirectionAmount",2),ne([x()],As.prototype,"randomDirectionAmount",2),ne([x()],As.prototype,"randomPositionAmount",2);class mi{constructor(){h(this,"damping"),h(this,"enabled"),h(this,"frequency"),h(this,"octaveCount"),h(this,"octaveMultiplier"),h(this,"octaveScale"),h(this,"positionAmount"),h(this,"quality"),h(this,"remap"),h(this,"remapEnabled"),h(this,"remapMultiplier"),h(this,"remapX"),h(this,"remapXMultiplier"),h(this,"remapY"),h(this,"remapYMultiplier"),h(this,"remapZ"),h(this,"remapZMultiplier"),h(this,"scrollSpeedMultiplier"),h(this,"separateAxes"),h(this,"strengthMultiplier"),h(this,"strengthX"),h(this,"strengthXMultiplier"),h(this,"strengthY"),h(this,"strengthYMultiplier"),h(this,"strengthZ"),h(this,"strengthZMultiplier"),h(this,"_noise"),h(this,"_time",0),h(this,"_temp",new w)}update(e){this._time+=e.time.deltaTime*this.scrollSpeedMultiplier}apply(e,t,s,r,n,o){if(!this.enabled)return;this._noise||(this._noise=dre(()=>0));const a=this._temp.set(t.x,t.y,t.z).multiplyScalar(this.frequency),l=this._noise(a.x,a.y,a.z,this._time),c=this._noise(a.x,a.y,a.z,this._time+1e3*this.frequency),u=this._noise(a.x,a.y,a.z,this._time+2e3*this.frequency);this._temp.set(l,c,u).normalize();const d=n/o;let p=this.positionAmount.evaluate(d);this.separateAxes?(this._temp.x*=p*this.strengthXMultiplier,this._temp.y*=p*this.strengthYMultiplier,this._temp.z*=p*this.strengthZMultiplier):(this.strengthX&&(p*=this.strengthX.evaluate(d)*1.5),this._temp.multiplyScalar(p)),s.x+=this._temp.x,s.y+=this._temp.y,s.z+=this._temp.z}}ne([x()],mi.prototype,"damping",2),ne([x()],mi.prototype,"enabled",2),ne([x()],mi.prototype,"frequency",2),ne([x()],mi.prototype,"octaveCount",2),ne([x()],mi.prototype,"octaveMultiplier",2),ne([x()],mi.prototype,"octaveScale",2),ne([x(ht)],mi.prototype,"positionAmount",2),ne([x()],mi.prototype,"quality",2),ne([x(ht)],mi.prototype,"remap",2),ne([x()],mi.prototype,"remapEnabled",2),ne([x()],mi.prototype,"remapMultiplier",2),ne([x(ht)],mi.prototype,"remapX",2),ne([x()],mi.prototype,"remapXMultiplier",2),ne([x(ht)],mi.prototype,"remapY",2),ne([x()],mi.prototype,"remapYMultiplier",2),ne([x(ht)],mi.prototype,"remapZ",2),ne([x()],mi.prototype,"remapZMultiplier",2),ne([x()],mi.prototype,"scrollSpeedMultiplier",2),ne([x()],mi.prototype,"separateAxes",2),ne([x()],mi.prototype,"strengthMultiplier",2),ne([x(ht)],mi.prototype,"strengthX",2),ne([x()],mi.prototype,"strengthXMultiplier",2),ne([x(ht)],mi.prototype,"strengthY",2),ne([x()],mi.prototype,"strengthYMultiplier",2),ne([x(ht)],mi.prototype,"strengthZ",2),ne([x()],mi.prototype,"strengthZMultiplier",2);class Gi{constructor(){h(this,"enabled"),h(this,"attachRibbonToTransform",!1),h(this,"colorOverLifetime"),h(this,"colorOverTrail"),h(this,"dieWithParticles",!0),h(this,"inheritParticleColor",!0),h(this,"lifetime"),h(this,"lifetimeMultiplier"),h(this,"minVertexDistance",.2),h(this,"mode",0),h(this,"ratio",1),h(this,"ribbonCount",1),h(this,"shadowBias",0),h(this,"sizeAffectsLifetime",!1),h(this,"sizeAffectsWidth",!1),h(this,"splitSubEmitterRibbons",!1),h(this,"textureMode",0),h(this,"widthOverTrail"),h(this,"widthOverTrailMultiplier"),h(this,"worldSpace",!1)}getWidth(e,t,s,r){const n=this.widthOverTrail.evaluate(s,r);return e*=n,e}getColor(e,t,s){const r=this.colorOverTrail.evaluate(s),n=this.colorOverLifetime.evaluate(t);e.x*=r.r*n.r,e.y*=r.g*n.g,e.z*=r.b*n.b,e.w*=r.alpha*n.alpha}}ne([x()],Gi.prototype,"enabled",2),ne([x()],Gi.prototype,"attachRibbonToTransform",2),ne([x(wn)],Gi.prototype,"colorOverLifetime",2),ne([x(wn)],Gi.prototype,"colorOverTrail",2),ne([x()],Gi.prototype,"dieWithParticles",2),ne([x()],Gi.prototype,"inheritParticleColor",2),ne([x(ht)],Gi.prototype,"lifetime",2),ne([x()],Gi.prototype,"lifetimeMultiplier",2),ne([x()],Gi.prototype,"minVertexDistance",2),ne([x()],Gi.prototype,"mode",2),ne([x()],Gi.prototype,"ratio",2),ne([x()],Gi.prototype,"ribbonCount",2),ne([x()],Gi.prototype,"shadowBias",2),ne([x()],Gi.prototype,"sizeAffectsLifetime",2),ne([x()],Gi.prototype,"sizeAffectsWidth",2),ne([x()],Gi.prototype,"splitSubEmitterRibbons",2),ne([x()],Gi.prototype,"textureMode",2),ne([x(ht)],Gi.prototype,"widthOverTrail",2),ne([x()],Gi.prototype,"widthOverTrailMultiplier",2),ne([x()],Gi.prototype,"worldSpace",2);class Xi{constructor(){h(this,"enabled"),h(this,"space",0),h(this,"orbitalX"),h(this,"orbitalY"),h(this,"orbitalZ"),h(this,"orbitalXMultiplier"),h(this,"orbitalYMultiplier"),h(this,"orbitalZMultiplier"),h(this,"orbitalOffsetX"),h(this,"orbitalOffsetY"),h(this,"orbitalOffsetZ"),h(this,"speedModifier"),h(this,"speedModifierMultiplier"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier"),h(this,"_system"),h(this,"_temp",new w),h(this,"_temp2",new w),h(this,"_temp3",new w),h(this,"_hasOrbital",!1),h(this,"_index",0),h(this,"_orbitalMatrix",new Te)}update(e){this._system=e}init(e){this._index==0&&(e.debug=!0),this._index+=1,e.orbitx=this.orbitalX.evaluate(Math.random()),e.orbity=this.orbitalY.evaluate(Math.random()),e.orbitz=this.orbitalZ.evaluate(Math.random()),this._hasOrbital=e.orbitx!=0||e.orbity!=0||e.orbitz!=0}apply(e,t,s,r,n,o,a){var l;if(!this.enabled)return;const c=o/a,u=this.speedModifier.evaluate(c)*this.speedModifierMultiplier,d=this.x.evaluate(c),p=this.y.evaluate(c),f=this.z.evaluate(c);if(this._temp.set(-d,p,f),this._system&&this._system.main.simulationSpace===1&&this._temp.applyQuaternion(this._system.worldQuaternion),this._hasOrbital&&((l=this._system)==null?void 0:l.worldPos)){const m=this._temp2.set(s.x,s.y,s.z),A=this.orbitalXMultiplier,v=this.orbitalYMultiplier,g=this.orbitalZMultiplier,b=u*Math.PI*2*10,y=Math.cos(b*A),_=Math.sin(b*A),S=Math.cos(b*v),T=Math.sin(b*v),M=Math.cos(b*g),R=Math.sin(b*g),E=m.x*(S*M)+m.y*(S*R)+m.z*-T,C=m.x*(_*T*M-y*R)+m.y*(_*T*R+y*M)+m.z*(_*S),U=m.x*(y*T*M+_*R)+m.y*(y*T*R-_*M)+m.z*(y*S),G=this._temp3.set(m.x-E,m.y-C,m.z-U);G.normalize(),G.multiplyScalar(.2/n*Math.max(this.orbitalXMultiplier,this.orbitalYMultiplier,this.orbitalZMultiplier)),r.x+=G.x,r.y+=G.y,r.z+=G.z}r.x+=this._temp.x,r.y+=this._temp.y,r.z+=this._temp.z,r.x*=u,r.y*=u,r.z*=u}}ne([x()],Xi.prototype,"enabled",2),ne([x()],Xi.prototype,"space",2),ne([x(ht)],Xi.prototype,"orbitalX",2),ne([x(ht)],Xi.prototype,"orbitalY",2),ne([x(ht)],Xi.prototype,"orbitalZ",2),ne([x()],Xi.prototype,"orbitalXMultiplier",2),ne([x()],Xi.prototype,"orbitalYMultiplier",2),ne([x()],Xi.prototype,"orbitalZMultiplier",2),ne([x()],Xi.prototype,"orbitalOffsetX",2),ne([x()],Xi.prototype,"orbitalOffsetY",2),ne([x()],Xi.prototype,"orbitalOffsetZ",2),ne([x(ht)],Xi.prototype,"speedModifier",2),ne([x()],Xi.prototype,"speedModifierMultiplier",2),ne([x(ht)],Xi.prototype,"x",2),ne([x()],Xi.prototype,"xMultiplier",2),ne([x(ht)],Xi.prototype,"y",2),ne([x()],Xi.prototype,"yMultiplier",2),ne([x(ht)],Xi.prototype,"z",2),ne([x()],Xi.prototype,"zMultiplier",2);class yr{constructor(){h(this,"animation"),h(this,"enabled"),h(this,"cycleCount"),h(this,"frameOverTime"),h(this,"frameOverTimeMultiplier"),h(this,"numTilesX"),h(this,"numTilesY"),h(this,"startFrame"),h(this,"startFrameMultiplier"),h(this,"rowMode"),h(this,"rowIndex"),h(this,"spriteCount"),h(this,"timeMode")}sampleOnceAtStart(){if(this.timeMode===0)switch(this.frameOverTime.mode){case 0:case 3:case 2:case 1:return!0}return!1}getStartIndex(){return this.sampleOnceAtStart()?Math.random()*(this.numTilesX*this.numTilesY):0}evaluate(e){if(!this.sampleOnceAtStart())return this.getIndex(e)}getIndex(e){const t=this.numTilesX*this.numTilesY;e=e*this.cycleCount;let s=this.frameOverTime.evaluate(e%1);return s*=this.frameOverTimeMultiplier,s*=t,s=s%t,s=Math.floor(s),s}}ne([x()],yr.prototype,"animation",2),ne([x()],yr.prototype,"enabled",2),ne([x()],yr.prototype,"cycleCount",2),ne([x(ht)],yr.prototype,"frameOverTime",2),ne([x()],yr.prototype,"frameOverTimeMultiplier",2),ne([x()],yr.prototype,"numTilesX",2),ne([x()],yr.prototype,"numTilesY",2),ne([x(ht)],yr.prototype,"startFrame",2),ne([x()],yr.prototype,"startFrameMultiplier",2),ne([x()],yr.prototype,"rowMode",2),ne([x()],yr.prototype,"rowIndex",2),ne([x()],yr.prototype,"spriteCount",2),ne([x()],yr.prototype,"timeMode",2);class Po{constructor(){h(this,"enabled"),h(this,"separateAxes"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier")}evaluate(e,t){return this.enabled?this.separateAxes?0:this.z.evaluate(e,t)*-1:0}}ne([x()],Po.prototype,"enabled",2),ne([x()],Po.prototype,"separateAxes",2),ne([x(ht)],Po.prototype,"x",2),ne([x()],Po.prototype,"xMultiplier",2),ne([x(ht)],Po.prototype,"y",2),ne([x()],Po.prototype,"yMultiplier",2),ne([x(ht)],Po.prototype,"z",2),ne([x()],Po.prototype,"zMultiplier",2);class Zn{constructor(){h(this,"enabled"),h(this,"range"),h(this,"separateAxes"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier")}evaluate(e,t){if(!this.enabled)return 0;if(!this.separateAxes){const s=Je.lerp(this.range.x,this.range.y,t);return this.z.evaluate(s)*-1}return 0}}ne([x()],Zn.prototype,"enabled",2),ne([x()],Zn.prototype,"range",2),ne([x()],Zn.prototype,"separateAxes",2),ne([x(ht)],Zn.prototype,"x",2),ne([x()],Zn.prototype,"xMultiplier",2),ne([x(ht)],Zn.prototype,"y",2),ne([x()],Zn.prototype,"yMultiplier",2),ne([x(ht)],Zn.prototype,"z",2),ne([x()],Zn.prototype,"zMultiplier",2);class Rs{constructor(){h(this,"enabled"),h(this,"dampen"),h(this,"drag"),h(this,"dragMultiplier"),h(this,"limit"),h(this,"limitMultiplier"),h(this,"separateAxes"),h(this,"limitX"),h(this,"limitXMultiplier"),h(this,"limitY"),h(this,"limitYMultiplier"),h(this,"limitZ"),h(this,"limitZMultiplier"),h(this,"multiplyDragByParticleSize",!1),h(this,"multiplyDragByParticleVelocity",!1),h(this,"space"),h(this,"_temp",new w),h(this,"_temp2",new w)}apply(e,t,s,r,n,o,a){if(this.enabled){const l=this.limit.evaluate(n)*this.limitMultiplier;if(t.length()>l){this._temp.copy(t).normalize().multiplyScalar(l);const c=this.dampen*.5;t.x=Je.lerp(t.x,this._temp.x,c),t.y=Je.lerp(t.y,this._temp.y,c),t.z=Je.lerp(t.z,this._temp.z,c),s.x=Je.lerp(s.x,this._temp.x,c),s.y=Je.lerp(s.y,this._temp.y,c),s.z=Je.lerp(s.z,this._temp.z,c)}}}}ne([x()],Rs.prototype,"enabled",2),ne([x()],Rs.prototype,"dampen",2),ne([x(ht)],Rs.prototype,"drag",2),ne([x()],Rs.prototype,"dragMultiplier",2),ne([x(ht)],Rs.prototype,"limit",2),ne([x()],Rs.prototype,"limitMultiplier",2),ne([x()],Rs.prototype,"separateAxes",2),ne([x(ht)],Rs.prototype,"limitX",2),ne([x()],Rs.prototype,"limitXMultiplier",2),ne([x(ht)],Rs.prototype,"limitY",2),ne([x()],Rs.prototype,"limitYMultiplier",2),ne([x(ht)],Rs.prototype,"limitZ",2),ne([x()],Rs.prototype,"limitZMultiplier",2),ne([x()],Rs.prototype,"multiplyDragByParticleSize",2),ne([x()],Rs.prototype,"multiplyDragByParticleVelocity",2),ne([x()],Rs.prototype,"space",2);class bh{constructor(){h(this,"enabled"),h(this,"curve"),h(this,"curveMultiplier"),h(this,"mode"),h(this,"system"),h(this,"_lastWorldPosition"),h(this,"_velocity",new w),h(this,"_temp",new w)}update(e){this.enabled&&this.system.worldspace!==!1&&(this._lastWorldPosition?(this._velocity.copy(this.system.worldPos).sub(this._lastWorldPosition).multiplyScalar(1/this.system.deltaTime),this._lastWorldPosition.copy(this.system.worldPos)):(this._velocity.set(0,0,0),this._lastWorldPosition=this.system.worldPos.clone()))}applyInitial(e){if(this.enabled&&this.system.worldspace!==!1&&this.mode===0){const t=this.curve.evaluate(Math.random(),Math.random());this._temp.copy(this._velocity).multiplyScalar(t),e.add(this._temp)}}applyCurrent(e,t,s){if(this.enabled&&this.system.worldspace!==!1&&this.mode===1){const r=this.curve.evaluate(t,s);this._temp.copy(this._velocity).multiplyScalar(r),e.add(this._temp)}}}ne([x()],bh.prototype,"enabled",2),ne([x(ht)],bh.prototype,"curve",2),ne([x()],bh.prototype,"curveMultiplier",2),ne([x()],bh.prototype,"mode",2);class ln{constructor(){h(this,"enabled"),h(this,"range"),h(this,"separateAxes"),h(this,"size"),h(this,"sizeMultiplier"),h(this,"x"),h(this,"xMultiplier"),h(this,"y"),h(this,"yMultiplier"),h(this,"z"),h(this,"zMultiplier")}evaluate(e,t,s,r){const n=e.length(),o=Je.remap(n,this.range.x,this.range.y,0,1),a=this.size.evaluate(o,s);return r*a}}ne([x()],ln.prototype,"enabled",2),ne([x(ee)],ln.prototype,"range",2),ne([x()],ln.prototype,"separateAxes",2),ne([x(ht)],ln.prototype,"size",2),ne([x()],ln.prototype,"sizeMultiplier",2),ne([x(ht)],ln.prototype,"x",2),ne([x()],ln.prototype,"xMultiplier",2),ne([x(ht)],ln.prototype,"y",2),ne([x()],ln.prototype,"yMultiplier",2),ne([x(ht)],ln.prototype,"z",2),ne([x()],ln.prototype,"zMultiplier",2);class Nu{constructor(){h(this,"enabled"),h(this,"range"),h(this,"color")}evaluate(e,t,s){const r=e.length(),n=Je.remap(r,this.range.x,this.range.y,0,1),o=this.color.evaluate(n,t);s.x*=o.r,s.y*=o.g,s.z*=o.b,s.w*=o.alpha}}ne([x()],Nu.prototype,"enabled",2),ne([x(ee)],Nu.prototype,"range",2),ne([x(wn)],Nu.prototype,"color",2);const gre={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%;