@needle-tools/engine 3.37.7-beta → 3.37.7-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/dist/needle-engine.js +9 -8
- package/dist/needle-engine.light.js +9 -8
- package/dist/needle-engine.light.min.js +2 -2
- package/dist/needle-engine.light.umd.cjs +2 -2
- package/dist/needle-engine.min.js +2 -2
- package/dist/needle-engine.umd.cjs +2 -2
- package/lib/engine-components/export/usdz/extensions/Animation.js +3 -2
- package/lib/engine-components/export/usdz/extensions/Animation.js.map +1 -1
- package/package.json +1 -1
- package/src/engine-components/export/usdz/extensions/Animation.ts +3 -2
|
@@ -4340,7 +4340,7 @@ void main() {
|
|
|
4340
4340
|
}`),n(Ss,"blipMaterial"),n(Ss,"mesh");function bx(t){return Ss.copyTexture(t)}function X9(t,A=!1){return Ss.textureToCanvas(t,A)}function $9(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&t instanceof ImageBitmap}let sw=!1;j5((...t)=>{var A;re()&&(A=et.Current)!=null&&A.isInXR&&(IE(!0),qx("error",...t))});function IE(t){if(t){if(sw)return;sw=!0,e6()}else{if(!sw)return;sw=!1,t6()}}const zc={log:void 0,warn:void 0,error:void 0};class A6{constructor(){n(this,"familyName","needle-xr"),n(this,"root",null),n(this,"context",null),n(this,"defaultFontSize",.06),n(this,"targetObject",new uA),n(this,"userForwardViewPoint",new S),n(this,"oneEuroFilter",new JG(90,.8)),n(this,"_lastElementRemoveTime",0),n(this,"onBeforeRender",()=>{var A,e;const i=(A=this.context)==null?void 0:A.mainCamera;if(this.context&&i instanceof xe){const g=this.getRoot();Number.isNaN(g.position.x)&&g.position.set(0,0,0),Number.isNaN(g.quaternion.x)&&g.quaternion.set(0,0,0,1),this.context.scene.add(this.targetObject);const I=((e=this.context.xr)==null?void 0:e.rigScale)??1,o=3.5*I,s=i.worldForward;s.y=0,s.normalize().multiplyScalar(o),this.userForwardViewPoint.copy(i.worldPosition).sub(s),this.targetObject.position.distanceTo(this.userForwardViewPoint)>2*I&&(this.targetObject.position.copy(this.userForwardViewPoint),jc(this.targetObject,i,!0,!0),this.targetObject.rotateY(Math.PI)),this.oneEuroFilter.filter(this.targetObject.position,g.position,this.context.time.time);const C=this.context.time.deltaTime;if(g.quaternion.slerp(this.targetObject.quaternion,C*5),g.scale.setScalar(I),this.targetObject.removeFromParent(),this.context.scene.add(g),this.context.time.time-this._lastElementRemoveTime>.1){this._lastElementRemoveTime=this.context.time.time;const a=Date.now();for(let r=0;r<this._activeTexts.length;r++){const B=this._activeTexts[r];if(B instanceof Ft.Text&&a-B._activatedTime>2e4){B.removeFromParent(),this._textBuffer.push(B),this._activeTexts.splice(r,1);break}}}}}),n(this,"textOptions",{fontSize:this.defaultFontSize,fontFamily:this.familyName,padding:.03,margin:.005,color:0,backgroundColor:16777215,backgroundOpacity:.4,borderRadius:.03,offset:.025}),n(this,"_textBuffer",[]),n(this,"_activeTexts",[]),this.ensureFont()}onEnable(){this.context=et.Current||et.All[0],this.context.pre_render_callbacks.push(this.onBeforeRender)}onDisable(){var A,e,i;(e=this.context)==null||e.pre_render_callbacks.splice((A=this.context)==null?void 0:A.pre_render_callbacks.indexOf(this.onBeforeRender),1),(i=this.root)==null||i.removeFromParent()}addLog(A,e){const i=this.getRoot(),g=this.getText();let I=16777215,o=0;switch(A){case"log":I=16777215,o=0;break;case"warn":I=16772761,o=4465152;break;case"error":I=16755370,o=7798784;break}e.length>1e3&&(e=e.substring(0,1e3)+"...");const s=new Date().toISOString().split("T")[1].split(".")[0];g.textContent="["+s+"] "+e,g.visible=!0,g._activatedTime=Date.now(),i.add(g),this._activeTexts.push(g),this.context&&this.context.scene.add(i),g.set({backgroundColor:I,color:o}),Ft.update()}ensureFont(){let A=Ft.FontLibrary.getFontFamily(this.familyName);if(!A){A=Ft.FontLibrary.addFontFamily(this.familyName);const e=A.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");e?.addEventListener("ready",()=>{Ft.update()})}}getText(){const A=this.getRoot();if(this._textBuffer.length>0){const i=this._textBuffer.pop();return i.visible=!0,setTimeout(()=>this.disableDepthTestRecursive(i),100),i}if(A.children.length>20&&this._activeTexts.length>0)return this._activeTexts.shift();const e=new Ft.Text(this.textOptions);return setTimeout(()=>this.disableDepthTestRecursive(e),500),setTimeout(()=>this.disableDepthTestRecursive(e),1500),e}disableDepthTestRecursive(A,e=0){for(let g=0;g<A.children.length;g++){const I=A.children[g];I instanceof uA&&this.disableDepthTestRecursive(I,e+1)}A.renderOrder=10*e,A.layers.set(2);const i=A.material;i&&(i.depthWrite=!1,i.depthTest=!1,i.transparent=!0),e===0&&Ft.update()}getRoot(){if(this.root)return this.root;const A=this.defaultFontSize,e={boxSizing:"border-box",fontFamily:this.familyName,width:"2.6",fontSize:A,color:0,lineHeight:1,backgroundColor:16777215,backgroundOpacity:0,whiteSpace:"pre-wrap",flexDirection:"column-reverse"};return this.root=new Ft.Block(e),this.root}}let fs=null;function e6(){fs||(fs=new A6),fs.onEnable();for(const t in zc){zc[t]=console[t];let A=!1;console[t]=function(){var e;if((e=zc[t])==null||e.apply(console,arguments),!A)try{A=!0,qx(t,...arguments)}finally{A=!1}}}}function t6(){fs?.onDisable();for(const t in zc)console[t]=zc[t]}const Xc=new Map;function qx(t,...A){try{switch(Xc.clear(),t){case"log":fs?.addLog("log",e());break;case"warn":fs?.addLog("warn",e());break;case"error":fs?.addLog("error",e());break}}catch(I){console.error("Error in spatial console",I)}finally{Xc.clear()}function e(){let I="";for(let o=0;o<A.length;o++){const s=A[o];I+=i(s),o<A.length-1&&(I+=", ")}return I}function i(I,o=0){if(typeof I=="string")return'"'+I+'"';if(typeof I=="number"){if(I%1!==0){const s=I.toFixed(5),C=s.indexOf(".");let a=s.length-1;for(;a>C&&s[a]==="0";)a--;return s.substring(0,a+1)}return I.toString()}else if(Array.isArray(I)){let s="[";for(let C=0;C<I.length;C++){const a=I[C];s+=i(a,o+1),C<I.length-1&&(s+=", ")}return s+="]",s}else{if(I===null)return"null";if(I===void 0)return"undefined";if(typeof I=="function")return I.name+"()"}if(I instanceof eA)return`(${i(I.x)}, ${i(I.y)})`;if(I instanceof S)return`(${i(I.x)}, ${i(I.y)}, ${i(I.z)})`;if(I instanceof zA)return`(${i(I.x)}, ${i(I.y)}, ${i(I.z)}, ${i(I.w)})`;if(I instanceof RA)return`(${i(I.x)}, ${i(I.y)}, ${i(I.z)}, ${i(I.w)})`;if(I instanceof Re||I instanceof le)return I.name;if(I instanceof Je)return`[${I.elements.join(", ")}]`;if(I instanceof MA)return`[${I.elements.join(", ")}]`;if(I instanceof AI)return I.mask.toString();if(typeof I=="object"){if(Xc.has(I))return"*";let s=`{
|
|
4341
4341
|
`;s+=g(o);const C=Object.keys(I);let a="";for(let r=0;r<C.length;r++){const B=C[r],Q=I[B];if(Xc.has(Q)){a+="";continue}Xc.set(Q,!0),a+=B+":"+i(Q,o+1),r<C.length-1&&(a+=", "),a.length>=60&&(a+=`
|
|
4342
4342
|
`,a+=g(o),s+=a,a="")}return s+=a,s+=`
|
|
4343
|
-
}`,s}return I}function g(I){let o="";for(let s=0;s<I;s++)o+=" ";return o}}const i6=tA("nodevlogs");function Xt(t,A=so.Log){AC(A,t)}function Ci(t){Xt(t,so.Warn)}function HG(t){Xt(t,so.Error)}let TG;function re(){return i6?!1:TG!==void 0?TG:$I()}function g6(t){TG=t}const xx=tA("debugdefines");oE('if(!globalThis[""3.37.7-beta""]) globalThis[""3.37.7-beta""] = "0.0.0";'),oE('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),oE('if(!globalThis[""Mon Apr 29 2024
|
|
4343
|
+
}`,s}return I}function g(I){let o="";for(let s=0;s<I;s++)o+=" ";return o}}const i6=tA("nodevlogs");function Xt(t,A=so.Log){AC(A,t)}function Ci(t){Xt(t,so.Warn)}function HG(t){Xt(t,so.Error)}let TG;function re(){return i6?!1:TG!==void 0?TG:$I()}function g6(t){TG=t}const xx=tA("debugdefines");oE('if(!globalThis[""3.37.7-beta.1""]) globalThis[""3.37.7-beta.1""] = "0.0.0";'),oE('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),oE('if(!globalThis[""Mon Apr 29 2024 17:15:43 GMT+0200 (Central European Summer Time)""]) globalThis[""Mon Apr 29 2024 17:15:43 GMT+0200 (Central European Summer Time)""] = "unknown";'),oE('globalThis["__NEEDLE_ENGINE_VERSION__"] = "3.37.7-beta.1";'),oE('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),oE('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Apr 29 2024 17:15:43 GMT+0200 (Central European Summer Time)";');const ga="3.37.7-beta.1",Cw="undefined",OG="Mon Apr 29 2024 17:15:43 GMT+0200 (Central European Summer Time)";xx&&console.log(`Engine version: ${ga} (generator: ${Cw})
|
|
4344
4344
|
Project built at ${OG}`);const Ia="needle_isActiveInHierarchy",Xr="builtin_components",$c="needle_editor_guid";function oE(t){try{(0,eval)(t)}catch(A){xx&&console.error(A)}}const I6='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98z"/><path style="fill:url(#c)" d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z"/><path style="fill:url(#d)" d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04z"/><path style="fill:#9c3" d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5z"/><path style="fill:url(#e)" d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59z"/><path style="fill:url(#f)" d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z"/><path style="fill:#ffe113" d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1z"/><path style="fill:#f3e600" d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75z"/></symbol></defs><use width="160" height="187.74" xlink:href="#g"/></svg>',o6=btoa(I6),s6="data:image/svg+xml;base64,"+o6,C6=s6,a6=`<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'> <svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" version="1.1" viewBox="0 0 1014 282" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m665.95 132.73v44.88l-10.56-8.4c-0.8-0.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18 0.4-6.06 1.2s-3.54 1.8-4.98 3-2.56 2.5-3.36 3.9-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c0.32 0.24 0.56 0.44 0.72 0.6s0.36 0.32 0.6 0.48c0.96-1.2 2.14-2.28 3.54-3.24s2.92-1.76 4.56-2.4 3.34-1.14 5.1-1.5 3.44-0.54 5.04-0.54c1.44 0 2.92 0.04 4.44 0.12s2.84 0.28 3.96 0.6c4.56 1.12 7.8 3.12 9.72 6s2.88 6.56 2.88 11.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m732.38 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m795.93 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m858.57 97.21c0.64 0.48 0.96 1.16 0.96 2.04v74.88c-0.08 1.04-0.12 2.12-0.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18s-2.06-1.66-2.46-1.98c-1.76 2.48-4.26 4.44-7.5 5.88s-7.02 2.16-11.34 2.16c-3.84 0-7.4-0.7-10.68-2.1s-6.14-3.44-8.58-6.12-4.34-5.94-5.7-9.78-2.04-8.16-2.04-12.96c0-4.32 0.78-8.34 2.34-12.06s3.6-6.92 6.12-9.6 5.38-4.78 8.58-6.3 6.48-2.28 9.84-2.28c2.56 0 4.82 0.22 6.78 0.66s3.68 1.06 5.16 1.86 2.78 1.74 3.9 2.82 2.16 2.22 3.12 3.42v-35.04l10.68 8.64zm-27.96 67.92c3.6 0 6.52-0.68 8.76-2.04s3.98-3.06 5.22-5.1 2.1-4.22 2.58-6.54 0.72-4.44 0.72-6.36v-1.2c0-1.12-0.22-2.7-0.66-4.74s-1.28-4.06-2.52-6.06-3-3.7-5.28-5.1-5.22-2.02-8.82-1.86c-3.44 0-6.26 0.74-8.46 2.22s-3.96 3.26-5.28 5.34-2.24 4.2-2.76 6.36-0.78 3.92-0.78 5.28c0 1.84 0.24 3.92 0.72 6.24s1.36 4.48 2.64 6.48 3.04 3.68 5.28 5.04 5.12 2.04 8.64 2.04z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m882.81 97.09c0.64 0.48 0.96 1.12 0.96 1.92l-0.12 41.04v37.08l-10.56-8.4c-0.72-0.64-1.08-1.44-1.08-2.4v-77.88l10.8 8.64z" fill-rule="nonzero"/> </g> <g transform="matrix(1.008 0 0 1.008 -2.239 .61874)"> <path d="m950.36 146.05c0 0.88 0.02 1.5 0.06 1.86s-0.02 0.98-0.18 1.86h-7.08c-2.08 0-4.44-0.02-7.08-0.06s-5.36-0.06-8.16-0.06h-22.08c0 2.88 0.56 5.36 1.68 7.44s2.6 3.8 4.44 5.16 3.94 2.36 6.3 3 4.74 0.96 7.14 0.96c3.04 0 5.9-0.76 8.58-2.28s4.94-3.52 6.78-6c0.64 0.56 1.54 1.48 2.7 2.76s2.94 3.2 5.34 5.76c-2.8 3.36-6.22 6.02-10.26 7.98s-8.42 2.94-13.14 2.94-8.92-0.64-12.84-1.92-7.32-3.24-10.2-5.88-5.12-5.98-6.72-10.02-2.4-8.82-2.4-14.34c0-4.96 0.66-9.42 1.98-13.38s3.22-7.32 5.7-10.08 5.44-4.9 8.88-6.42 7.32-2.28 11.64-2.28c5.76 0 10.52 0.88 14.28 2.64s6.72 4.16 8.88 7.2 3.66 6.54 4.5 10.5 1.26 8.18 1.26 12.66zm-29.4-22.8c-2.16 0.16-4.16 0.72-6 1.68s-3.42 2.2-4.74 3.72-2.36 3.28-3.12 5.28-1.14 4.12-1.14 6.36h33.12c0-2-0.22-4.06-0.66-6.18s-1.3-4.02-2.58-5.7-3.1-3.02-5.46-4.02-5.5-1.38-9.42-1.14z" fill-rule="nonzero"/> </g> <g transform="matrix(1.8559 0 0 .7642 45.348 36.475)"> <g transform="translate(2.7114)"> <path d="m3.935 173.02c-0.331 0-0.497-0.402-0.497-1.207v-51.002c0-0.738 0.138-1.107 0.414-1.107h1.781c0.277 0 0.415 0.335 0.415 1.006v5.935c0 0.336 0.027 0.553 0.083 0.654 0.055 0.101 0.151-0.017 0.289-0.352 0.912-1.744 1.754-3.236 2.527-4.477 0.773-1.24 1.554-2.179 2.341-2.816s1.65-0.956 2.588-0.956c1.685 0 3.011 0.922 3.977 2.766 0.967 1.845 1.602 3.84 1.905 5.986 0.056 0.268 0.139 0.369 0.249 0.302s0.221-0.235 0.331-0.503c0.939-1.811 1.802-3.353 2.589-4.628 0.787-1.274 1.581-2.246 2.382-2.917s1.671-1.006 2.61-1.006c2.016 0 3.569 1.392 4.66 4.175 1.09 2.783 1.636 6.421 1.636 10.915v37.925c0 0.871-0.18 1.307-0.539 1.307h-1.739c-0.138 0-0.249-0.1-0.332-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.338-6.321-1.015-8.3-0.676-1.978-1.76-2.967-3.251-2.967-0.884 0-1.726 0.386-2.527 1.157s-1.519 1.727-2.154 2.867-1.201 2.213-1.699 3.219c-0.248 0.469-0.421 0.905-0.517 1.308-0.097 0.402-0.145 0.972-0.145 1.71v37.221c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.166 0-0.29-0.1-0.373-0.301-0.083-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.332-6.321-0.994-8.3-0.663-1.978-1.754-2.967-3.273-2.967-1.242 0-2.375 0.704-3.396 2.112-1.022 1.409-2.223 3.555-3.604 6.439v39.031c0 0.805-0.18 1.207-0.539 1.207h-1.698z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m53.642 166.28c-1.077 2.549-2.237 4.477-3.479 5.785-1.243 1.307-2.61 1.961-4.101 1.961-2.154 0-3.853-1.324-5.095-3.973-1.243-2.649-1.864-6.187-1.864-10.613 0-3.488 0.4-6.489 1.201-9.004s1.988-4.51 3.562-5.985c1.574-1.476 3.521-2.414 5.841-2.817l3.686-0.704c0.221-0.067 0.394-0.218 0.518-0.453 0.124-0.234 0.187-0.587 0.187-1.056v-2.917c0-3.89-0.504-6.975-1.512-9.255s-2.354-3.42-4.039-3.42c-1.298 0-2.472 0.72-3.521 2.162s-2.002 3.572-2.858 6.388c-0.083 0.268-0.159 0.453-0.228 0.554-0.069 0.1-0.172 0.083-0.311-0.051l-1.698-1.71c-0.083-0.134-0.138-0.285-0.166-0.453-0.027-0.167 0.014-0.452 0.125-0.855 0.856-3.353 2.009-6.052 3.459-8.098 1.449-2.045 3.224-3.068 5.322-3.068 1.74 0 3.211 0.687 4.412 2.062s2.112 3.37 2.734 5.986c0.621 2.615 0.932 5.7 0.932 9.255v35.712c0 0.536-0.035 0.888-0.104 1.056s-0.2 0.251-0.393 0.251h-1.533c-0.166 0-0.29-0.117-0.373-0.352-0.083-0.234-0.124-0.553-0.124-0.955l-0.083-5.231c-0.055-0.939-0.221-1.006-0.497-0.202zm0.456-19.314c0-1.14-0.194-1.643-0.58-1.509l-3.107 0.603c-1.436 0.202-2.686 0.638-3.749 1.308-1.063 0.671-1.953 1.543-2.671 2.616s-1.257 2.33-1.616 3.772-0.538 3.102-0.538 4.98c0 3.152 0.455 5.616 1.367 7.393 0.911 1.778 2.14 2.666 3.686 2.666 0.939 0 1.85-0.419 2.734-1.257s1.671-1.895 2.361-3.169c0.663-1.408 1.181-2.85 1.553-4.326 0.373-1.475 0.56-2.883 0.56-4.225v-8.852z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m79.034 173.02c-0.166 0-0.297-0.117-0.394-0.352-0.096-0.234-0.145-0.553-0.145-0.955v-4.628c0-0.536-0.041-0.838-0.124-0.905s-0.207 0.1-0.373 0.503c-0.276 0.67-0.69 1.593-1.242 2.766-0.553 1.174-1.271 2.23-2.154 3.169-0.884 0.939-1.961 1.408-3.231 1.408-1.74 0-3.314-0.989-4.722-2.967-1.409-1.979-2.534-4.963-3.376-8.953-0.843-3.991-1.264-8.937-1.264-14.838 0-5.701 0.415-10.68 1.243-14.939s1.988-7.595 3.479-10.009c1.492-2.415 3.204-3.622 5.137-3.622 1.436 0 2.616 0.57 3.541 1.71 0.926 1.14 1.719 2.381 2.382 3.722 0.249 0.47 0.414 0.637 0.497 0.503s0.125-0.536 0.125-1.207v-23.841c0-0.805 0.151-1.208 0.455-1.208h1.864c0.276 0 0.414 0.369 0.414 1.107v72.128c0 0.537-0.041 0.905-0.124 1.107-0.083 0.201-0.235 0.301-0.455 0.301h-1.533zm-0.621-42.049c-0.939-2.213-1.885-3.94-2.838-5.181s-2.009-1.861-3.169-1.861c-1.463 0-2.768 0.889-3.914 2.666s-2.044 4.376-2.693 7.796-0.973 7.578-0.973 12.474c0 5.097 0.338 9.272 1.015 12.524 0.676 3.253 1.567 5.651 2.672 7.193 1.104 1.543 2.305 2.314 3.603 2.314 1.188 0 2.258-0.704 3.211-2.113 0.952-1.408 1.705-3.118 2.257-5.13s0.829-3.957 0.829-5.835v-24.847z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m89.514 149.38c0 3.42 0.345 6.606 1.035 9.557 0.691 2.951 1.609 5.315 2.755 7.092s2.437 2.666 3.873 2.666c1.519 0 2.837-0.738 3.956-2.213 1.118-1.476 2.064-3.655 2.837-6.539 0.083-0.336 0.166-0.52 0.249-0.554 0.083-0.033 0.179 0.017 0.29 0.151l1.408 1.912c0.221 0.268 0.235 0.67 0.041 1.207-0.69 2.548-1.47 4.661-2.34 6.337-0.87 1.677-1.857 2.935-2.962 3.773-1.104 0.838-2.319 1.257-3.645 1.257-2.043 0-3.838-1.14-5.385-3.42-1.546-2.28-2.761-5.482-3.645-9.607-0.884-4.124-1.325-8.836-1.325-14.134 0-5.901 0.455-10.931 1.367-15.089 0.911-4.158 2.14-7.377 3.686-9.658 1.547-2.28 3.3-3.42 5.261-3.42 1.988 0 3.714 1.073 5.178 3.219 1.463 2.146 2.595 5.231 3.396 9.255s1.201 8.886 1.201 14.587c0 0.469-0.02 0.939-0.062 1.408-0.041 0.469-0.214 0.704-0.517 0.704h-16.362c-0.083 0-0.152 0.151-0.207 0.453-0.056 0.302-0.083 0.654-0.083 1.056zm13.752-6.237c0.304 0 0.497-0.1 0.58-0.302 0.083-0.201 0.124-0.57 0.124-1.106 0-3.219-0.283-6.187-0.849-8.903s-1.367-4.896-2.402-6.539c-1.036-1.643-2.272-2.464-3.708-2.464-1.629 0-2.996 0.955-4.101 2.867-1.104 1.911-1.94 4.342-2.506 7.293s-0.849 6.002-0.849 9.154h13.711z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m148.54 119.7c0.165 0 0.283 0.117 0.352 0.352s0.076 0.52 0.02 0.855l-6.254 50.902c-0.028 0.47-0.104 0.788-0.228 0.956s-0.297 0.251-0.518 0.251h-1.615c-0.442 0-0.718-0.402-0.829-1.207l-5.26-40.138c-0.111-0.604-0.201-0.905-0.27-0.905s-0.131 0.301-0.186 0.905l-5.012 40.138c-0.028 0.47-0.097 0.788-0.207 0.956-0.111 0.168-0.277 0.251-0.497 0.251h-1.74c-0.442 0-0.718-0.402-0.829-1.207l-6.503-50.801c-0.055-0.403-0.048-0.721 0.021-0.956s0.2-0.352 0.393-0.352h1.823c0.166 0 0.297 0.067 0.393 0.201 0.097 0.134 0.159 0.403 0.187 0.805l5.302 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.219-41.949c0.055-0.268 0.124-0.47 0.207-0.604s0.193-0.201 0.331-0.201h1.533c0.138 0 0.262 0.067 0.373 0.201 0.11 0.134 0.179 0.403 0.207 0.805l5.468 41.848c0.083 0.671 0.179 0.989 0.29 0.956 0.11-0.034 0.207-0.386 0.29-1.056l5.053-41.849c0.055-0.335 0.138-0.57 0.249-0.704 0.11-0.134 0.234-0.201 0.373-0.201h1.284z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m156.49 171.51c0 0.604-0.042 1.006-0.125 1.208-0.082 0.201-0.262 0.301-0.538 0.301h-1.533c-0.221 0-0.366-0.083-0.435-0.251s-0.103-0.486-0.103-0.956v-50.902c0-0.805 0.152-1.207 0.456-1.207h1.822c0.304 0 0.456 0.402 0.456 1.207v50.6zm0.165-63.979c0 1.207-0.207 1.811-0.621 1.811h-1.905c-0.221 0-0.366-0.135-0.435-0.403s-0.104-0.67-0.104-1.207v-7.847c0-1.006 0.18-1.509 0.539-1.509h1.988c0.359 0 0.538 0.47 0.538 1.409v7.746z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m168.3 124.83c-0.221 0-0.331 0.269-0.331 0.805v33.801c0 3.42 0.221 5.667 0.663 6.74 0.441 1.073 1.09 1.609 1.946 1.609h3.024c0.138 0 0.242 0.084 0.311 0.252 0.069 0.167 0.103 0.419 0.103 0.754v2.716c0 0.537-0.138 0.906-0.414 1.107-0.248 0.067-0.614 0.134-1.098 0.201-0.483 0.067-0.959 0.118-1.429 0.151-0.469 0.034-0.828 0.05-1.077 0.05-1.712 0-2.934-0.955-3.665-2.867-0.732-1.911-1.098-5.013-1.098-9.305v-35.108c0-0.604-0.124-0.906-0.373-0.906h-3.521c-0.248 0-0.373-0.268-0.373-0.804v-3.521c0-0.537 0.111-0.805 0.332-0.805h3.686c0.166 0 0.263-0.268 0.29-0.805l0.415-16.095c0-0.805 0.124-1.207 0.372-1.207h1.492c0.303 0 0.455 0.436 0.455 1.307v15.995c0 0.537 0.097 0.805 0.29 0.805h5.468c0.221 0 0.331 0.268 0.331 0.805v3.521c0 0.536-0.124 0.804-0.373 0.804h-5.426z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> <g transform="translate(2.7114)"> <path d="m179.4 173.02c-0.331 0-0.497-0.402-0.497-1.207v-72.329c0-0.738 0.138-1.107 0.414-1.107h1.782c0.276 0 0.414 0.336 0.414 1.006v27.162c0 0.335 0.034 0.536 0.103 0.603s0.159-0.033 0.27-0.302c0.994-1.81 1.898-3.319 2.713-4.526 0.814-1.208 1.629-2.113 2.444-2.717 0.814-0.603 1.691-0.905 2.63-0.905 2.182 0 3.839 1.375 4.971 4.125 1.132 2.749 1.698 6.404 1.698 10.965v37.925c0 0.871-0.166 1.307-0.497 1.307h-1.74c-0.165 0-0.29-0.1-0.373-0.301-0.082-0.202-0.124-0.503-0.124-0.906v-36.315c0-3.555-0.366-6.321-1.097-8.3-0.732-1.978-1.899-2.967-3.501-2.967-0.883 0-1.705 0.318-2.464 0.956-0.76 0.637-1.526 1.576-2.299 2.816-0.773 1.241-1.643 2.834-2.61 4.779v39.031c0 0.805-0.179 1.207-0.538 1.207h-1.699z" fill-rule="nonzero" stroke="#000" stroke-width=".7px"/> </g> </g> <g transform="matrix(.80638 0 0 .80638 452.53 65.421)" fill-rule="nonzero"> <path d="m79.32 36.98v150.76l15.68-13.2 6.59-156.31-22.27 18.75z" fill="url(#f)"/> <path d="m79.32 36.98-22.27-18.75 6.59 156.31 15.68 13.2v-150.76z" fill="url(#e)"/> <path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33z" fill="url(#d)"/> <path d="m25.19 104.83-25.19-14.59 16.97 53.86 16.85 9.77-8.63-49.04z" fill="url(#c)"/> <path d="M43.86,82.5L18.69,67.98L0,90.24L25.18,104.83L43.86,82.5Z" fill="#9c3"/> <path d="m134.82 78.69-9.97 56.5 15.58-9.04 19.57-62.05-25.18 14.59z" fill="url(#b)"/> <path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5z" fill="url(#a)"/> <path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33 25.19-14.59z" fill="#ffe113"/> <path d="M101.59,18.23L79.32,0L57.05,18.23L79.32,36.98L101.59,18.23Z" fill="#f3e600"/> </g> <defs> <linearGradient id="f" x2="1" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)" gradientUnits="userSpaceOnUse"><stop stop-color="#62d399" offset="0"/><stop stop-color="#acd842" offset=".51"/><stop stop-color="#d7db0a" offset=".9"/><stop stop-color="#d7db0a" offset="1"/></linearGradient> <linearGradient id="e" x2="1" gradientTransform="matrix(-1.6,-162.13,162.13,-1.6,69.68,178.9)" gradientUnits="userSpaceOnUse"><stop stop-color="#0ba398" offset="0"/><stop stop-color="#4ca352" offset=".5"/><stop stop-color="#76a30a" offset="1"/></linearGradient> <linearGradient id="d" x2="1" gradientTransform="matrix(-1.9,-67.98,67.98,-1.9,36.6,152.17)" gradientUnits="userSpaceOnUse"><stop stop-color="#36a382" offset="0"/><stop stop-color="#36a382" offset=".19"/><stop stop-color="#49a459" offset=".54"/><stop stop-color="#76a30b" offset="1"/></linearGradient> <linearGradient id="c" x2="1" gradientTransform="matrix(2.18,-62.38,62.38,2.18,15.82,153.24)" gradientUnits="userSpaceOnUse"><stop stop-color="#267880" offset="0"/><stop stop-color="#457a5c" offset=".51"/><stop stop-color="#717516" offset="1"/></linearGradient> <linearGradient id="b" x2="1" gradientTransform="matrix(13.85,-71.96,71.96,13.85,135.08,135.43)" gradientUnits="userSpaceOnUse"><stop stop-color="#b0d939" offset="0"/><stop stop-color="#eadb04" offset="1"/></linearGradient> <linearGradient id="a" x2="1" gradientTransform="matrix(26.159 -64.737 64.737 26.159 107.42 128.14)" gradientUnits="userSpaceOnUse"><stop stop-color="#74af52" offset="0"/><stop stop-color="#74af52" offset=".17"/><stop stop-color="#99be32" offset=".48"/><stop stop-color="#c0c40a" offset="1"/></linearGradient> </defs> </svg>`;btoa(a6);const n6='<svg viewBox="0 0 509 154" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M665.95 132.73v44.88l-10.56-8.4c-.8-.64-1.2-1.44-1.2-2.4v-32.4c0-6.48-4.12-9.72-12.36-9.72-2.16 0-4.18.4-6.06 1.2-1.88.8-3.54 1.8-4.98 3-1.44 1.2-2.56 2.5-3.36 3.9-.8 1.4-1.2 2.7-1.2 3.9v40.92l-10.68-8.4c-.72-.64-1.08-1.44-1.08-2.4v-53.76l10.92 8.52c.32.24.56.44.72.6.16.16.36.32.6.48.96-1.2 2.14-2.28 3.54-3.24 1.4-.96 2.92-1.76 4.56-2.4 1.64-.64 3.34-1.14 5.1-1.5 1.76-.36 3.44-.54 5.04-.54 1.44 0 2.92.04 4.44.12 1.52.08 2.84.28 3.96.6 4.56 1.12 7.8 3.12 9.72 6 1.92 2.88 2.88 6.56 2.88 11.04ZM732.38 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM795.93 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14ZM858.57 97.21c.64.48.96 1.16.96 2.04v74.88c-.08 1.04-.12 2.12-.12 3.24-1.84-1.52-3.56-2.92-5.16-4.2-1.36-1.12-2.66-2.18-3.9-3.18-1.24-1-2.06-1.66-2.46-1.98-1.76 2.48-4.26 4.44-7.5 5.88-3.24 1.44-7.02 2.16-11.34 2.16-3.84 0-7.4-.7-10.68-2.1-3.28-1.4-6.14-3.44-8.58-6.12-2.44-2.68-4.34-5.94-5.7-9.78-1.36-3.84-2.04-8.16-2.04-12.96 0-4.32.78-8.34 2.34-12.06 1.56-3.72 3.6-6.92 6.12-9.6 2.52-2.68 5.38-4.78 8.58-6.3 3.2-1.52 6.48-2.28 9.84-2.28 2.56 0 4.82.22 6.78.66 1.96.44 3.68 1.06 5.16 1.86s2.78 1.74 3.9 2.82a35.92 35.92 0 0 1 3.12 3.42V88.57l10.68 8.64Zm-27.96 67.92c3.6 0 6.52-.68 8.76-2.04 2.24-1.36 3.98-3.06 5.22-5.1a20.5 20.5 0 0 0 2.58-6.54c.48-2.32.72-4.44.72-6.36v-1.2c0-1.12-.22-2.7-.66-4.74-.44-2.04-1.28-4.06-2.52-6.06s-3-3.7-5.28-5.1c-2.28-1.4-5.22-2.02-8.82-1.86-3.44 0-6.26.74-8.46 2.22-2.2 1.48-3.96 3.26-5.28 5.34-1.32 2.08-2.24 4.2-2.76 6.36-.52 2.16-.78 3.92-.78 5.28 0 1.84.24 3.92.72 6.24.48 2.32 1.36 4.48 2.64 6.48s3.04 3.68 5.28 5.04c2.24 1.36 5.12 2.04 8.64 2.04ZM882.81 97.09c.64.48.96 1.12.96 1.92l-.12 41.04v37.08l-10.56-8.4c-.72-.64-1.08-1.44-1.08-2.4V88.45l10.8 8.64ZM950.36 146.05c0 .88.02 1.5.06 1.86.04.36-.02.98-.18 1.86h-7.08c-2.08 0-4.44-.02-7.08-.06-2.64-.04-5.36-.06-8.16-.06h-22.08c0 2.88.56 5.36 1.68 7.44 1.12 2.08 2.6 3.8 4.44 5.16 1.84 1.36 3.94 2.36 6.3 3 2.36.64 4.74.96 7.14.96 3.04 0 5.9-.76 8.58-2.28 2.68-1.52 4.94-3.52 6.78-6 .64.56 1.54 1.48 2.7 2.76 1.16 1.28 2.94 3.2 5.34 5.76-2.8 3.36-6.22 6.02-10.26 7.98-4.04 1.96-8.42 2.94-13.14 2.94-4.72 0-8.92-.64-12.84-1.92-3.92-1.28-7.32-3.24-10.2-5.88-2.88-2.64-5.12-5.98-6.72-10.02-1.6-4.04-2.4-8.82-2.4-14.34 0-4.96.66-9.42 1.98-13.38 1.32-3.96 3.22-7.32 5.7-10.08s5.44-4.9 8.88-6.42c3.44-1.52 7.32-2.28 11.64-2.28 5.76 0 10.52.88 14.28 2.64 3.76 1.76 6.72 4.16 8.88 7.2 2.16 3.04 3.66 6.54 4.5 10.5.84 3.96 1.26 8.18 1.26 12.66Zm-29.4-22.8c-2.16.16-4.16.72-6 1.68-1.84.96-3.42 2.2-4.74 3.72-1.32 1.52-2.36 3.28-3.12 5.28-.76 2-1.14 4.12-1.14 6.36h33.12c0-2-.22-4.06-.66-6.18-.44-2.12-1.3-4.02-2.58-5.7-1.28-1.68-3.1-3.02-5.46-4.02-2.36-1-5.5-1.38-9.42-1.14Z" style="fill-rule:nonzero" transform="translate(-452.406 -63.709) scale(1.00797)"/><path d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75Z" style="fill:url(#a);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M79.32 36.98 57.05 18.23l6.59 156.31 15.68 13.2V36.98Z" style="fill:url(#b);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m25.19 104.83 8.63 49.04 12.5-14.95-2.46-56.42-18.67 22.33Z" style="fill:url(#c);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M25.19 104.83 0 90.24l16.97 53.86 16.85 9.77-8.63-49.04Z" style="fill:url(#d);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M43.86 82.5 18.69 67.98 0 90.24l25.18 14.59L43.86 82.5Z" style="fill:#9c3;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-9.97 56.5 15.58-9.04L160 64.1l-25.18 14.59Z" style="fill:url(#e);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m134.82 78.69-18.68-22.33-2.86 65 11.57 13.83 9.97-56.5Z" style="fill:url(#f);fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="m160 64.1-18.69-22.26-25.17 14.52 18.67 22.33L160 64.1Z" style="fill:#ffe113;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><path d="M101.59 18.23 79.32 0 57.05 18.23l22.27 18.75 22.27-18.75Z" style="fill:#f3e600;fill-rule:nonzero" transform="matrix(.80638 0 0 .80638 2.361 1.094)"/><defs><linearGradient id="a" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(.84 -162.96 162.96 .84 89.64 184.81)"><stop offset="0" style="stop-color:#62d399;stop-opacity:1"/><stop offset=".51" style="stop-color:#acd842;stop-opacity:1"/><stop offset=".9" style="stop-color:#d7db0a;stop-opacity:1"/><stop offset="1" style="stop-color:#d7db0a;stop-opacity:1"/></linearGradient><linearGradient id="b" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-90.565 123.412 54.953) scale(162.14)"><stop offset="0" style="stop-color:#0ba398;stop-opacity:1"/><stop offset=".5" style="stop-color:#4ca352;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30a;stop-opacity:1"/></linearGradient><linearGradient id="c" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="scale(-68) rotate(88.4 .881 -1.396)"><stop offset="0" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".19" style="stop-color:#36a382;stop-opacity:1"/><stop offset=".54" style="stop-color:#49a459;stop-opacity:1"/><stop offset="1" style="stop-color:#76a30b;stop-opacity:1"/></linearGradient><linearGradient id="d" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-88 87.255 68.431) scale(62.42)"><stop offset="0" style="stop-color:#267880;stop-opacity:1"/><stop offset=".51" style="stop-color:#457a5c;stop-opacity:1"/><stop offset="1" style="stop-color:#717516;stop-opacity:1"/></linearGradient><linearGradient id="e" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-79.1 149.53 -14.065) scale(73.28)"><stop offset="0" style="stop-color:#b0d939;stop-opacity:1"/><stop offset="1" style="stop-color:#eadb04;stop-opacity:1"/></linearGradient><linearGradient id="f" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="rotate(-67.997 148.705 -15.558) scale(69.8226)"><stop offset="0" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".17" style="stop-color:#74af52;stop-opacity:1"/><stop offset=".48" style="stop-color:#99be32;stop-opacity:1"/><stop offset="1" style="stop-color:#c0c40a;stop-opacity:1"/></linearGradient></defs></svg>',r6=btoa(n6),B6="data:image/svg+xml;charset=utf-8;base64,"+r6,Q6=B6,To=tA("debuglicense");let $r="basic";To&&console.log("License Type: "+$r);function ms(){switch($r){case"pro":case"enterprise":return!0}return!1}function PG(){switch($r){case"indie":return!0}return!1}function sE(){return ms()||PG()}const Lx=[];function E6(t){if(ms()||PG())return t(!0);Lx.push(t)}function h6(t){for(const A of Lx)try{A(t)}catch{}}et.registerCallback(si.ContextRegistered,t=>{d6(t.context),u6(),l6(t.context)});let AB,jG=!1,aw="";async function c6(){if(AB)return AB;if($r==="basic")try{const t="https://engine.needle.tools/licensing/check?location="+encodeURIComponent(window.location.href)+"&version="+ga+"&generator="+encodeURIComponent(Cw),A=await fetch(t,{method:"GET"}).catch(e=>{To&&console.error("License check failed",e)});A?.status===200?(jG=!1,To&&console.log("License check succeeded"),$r="pro",h6(!0)):A?.status===403?(jG=!0,aw=await A.text()):To&&console.log("License check failed with status "+A?.status)}catch(t){To&&console.error("License check failed",t)}else To&&console.log('Runtime license check is skipped because license is already applied as "'+$r+'"')}AB=c6();async function l6(t){function A(){const g=document.createElement("div");g.className="needle-forbidden",g.style.cssText=`
|
|
4345
4345
|
position: fixed;
|
|
4346
4346
|
top: 0;
|
|
@@ -5505,7 +5505,7 @@ Could not find method ${r.method} on object ${Q.name}. Please rename ${r.method}
|
|
|
5505
5505
|
in script: `,Q),Ci("EventList methods must start with lowercase letter, see console for details");return}else console.warn(`EventList method:
|
|
5506
5506
|
Could not find method ${r.method} on object ${Q.name}`,Q,typeof Q[r.method])};if(typeof Q[r.method]!="function"){let p=!1,u=Q;for(;u;){const D=Object.getOwnPropertyDescriptor(u,r.method);if(D&&(D.writable===!0||D.set)){p=!0;break}u=Object.getPrototypeOf(u)}!p&&(re()||Ng)&&c()}}let h=r.argument;h!==void 0?h=B(h):r.arguments!==void 0&&(h=r.arguments.map(B));const d=E?this.createEventMethod(Q,r.method,h):void 0,l=new xE(d,r.enabled);if(l.method||(l[rgA]=(o=e.object)==null?void 0:o.name),!Q||!l.method){const c=e.object?"Current object: "+e.object.name+", "+e.object.guid:null;Q?console.warn('EventList method not found: "'+r.method+'" on',Q):console.warn("EventList is missing target - will be ignored",r.target,c,A)}else s.push(l)}const C=new tg(s);Ng&&console.log(C);const a=e.target;return a!==void 0&&e.path!==void 0&&C.setEventTarget(e.path,a),C}}createEventMethod(A,e,i){return(...g)=>{const I=A[e];typeof I=="function"?i!==void 0?Array.isArray(i)?I?.call(A,...i):I?.call(A,i):I?.call(A,...g):A[e]=i}}}const QgA=new BgA;class XT extends IC{constructor(){super([bE,Pe])}onSerialize(A,e){}onDeserialize(A,e){if(A instanceof le&&e.type===bE){const i=A,g=new bE(i.image.width,i.image.height,{colorSpace:lt});return g.texture=i,i.isRenderTargetTexture=!0,i.flipY=!0,i.offset.y=1,i.repeat.y=-1,i.needsUpdate=!0,i.mipmaps=[],i instanceof Vs&&(i.isCompressedTexture=!1,i.format=RGBAFormat),g}}}new XT;class $T extends IC{constructor(){super([URL])}onSerialize(A,e){return null}onDeserialize(A,e){if(typeof A=="string"&&A.length>0)return ea(e.gltfId,A)}}new $T;var EgA=Object.defineProperty,hgA=Object.getOwnPropertyDescriptor,cgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?hgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&EgA(A,e,g),g};class ed extends FA{awake(){As.createIfNoneExists(this.context)}onEnable(){var A;(A=As.get(this.context))==null||A.register(this)}onDisable(){var A;(A=As.get(this.context))==null||A.unregister(this)}}class Qo extends ed{constructor(){super(...arguments),n(this,"targets",null),n(this,"raycastHits",[]),n(this,"ignoreSkinnedMeshes",!1)}start(){this.targets=[this.gameObject]}performRaycast(A=null){if(!this.targets)return null;A??(A=new zo),A.targets=this.targets,A.results=this.raycastHits;const e=A.testObject;this.ignoreSkinnedMeshes&&(A.testObject=g=>g instanceof io?"continue in children":e?e(g):!0);const i=this.context.physics.raycast(A);return A.testObject=e,i}}cgA([w()],Qo.prototype,"ignoreSkinnedMeshes",2);class Fy extends Qo{constructor(){super(),this.ignoreSkinnedMeshes=!0}}class td extends ed{performRaycast(A){if(!we.active||!(A!=null&&A.ray))return null;const e=A.ray.origin,i=.01;return this.context.physics.sphereOverlap(e,i)}}class Ky{static getObject(A){const e=A[$o];return e&&(e.isComponent===!0?A=e.gameObject:A=e),A}static isInteractable(A,e){if(e&&(e.canvasGroup=void 0,e.graphic=void 0),A==null||!A.visible||(A=this.getObject(A),!A.visible))return!1;const i=this.tryFindCanvasGroup(A);if(i?.isCanvasGroup===!0&&(e&&(e.canvasGroup=i),i.blocksRaycasts===!1||i.interactable===!1))return!1;const g=cB(A,I=>{if(I.isGraphic===!0)return I},!1);return e&&g?.isGraphic===!0&&(e.graphic=g),!(g?.raycastTarget===!1||g?.layer===2)}static tryFindCanvasGroup(A){if(!A)return null;const e=cB(A,i=>{const g=i;if(g.blocksRaycasts!==void 0&&g.interactable!==void 0)return g},!1);return e!==void 0?e:this.tryFindCanvasGroup(A.parent)}}function hR(t){return t[$o]||(t.parent?hR(t.parent):null)}function lgA(t){return t.isUI===!0||typeof t[$o]=="object"}function Jy(t,A){if(!t)return;const e=t.material;if(e?.isMaterial===!0){const i=t.parent;i&&i.isText,e.side=A.doubleSided??!0?Qt:wg,e.shadowSide=A.doubleSided?Qt:wg,t.castShadow=A.castShadows?A.castShadows:!1,t.receiveShadow=A.receiveShadows?A.receiveShadows:!1}for(const i of t.children)Jy(i,A)}function LE(t,A,e){t[A]===void 0&&console.warn("Field",A,"is undefined on",t);const i=Proxy.revocable(t[A],{set(o,s,C,a){const r=o[s],B=Reflect.set(o,s,C,a);return e(C,r),B}}),g=i.revoke,I=t[A];return i.revoke=()=>{t[A]=I,g()},t[A]=i.proxy,i}const A2=Symbol("Scheduled action");function dgA(t,A,e=Ot.OnBeforeRender){let i=t[A2];i||(i=t[A2]={});const g=A.name;i[e]||(i[e]={});const I=i[e];if(I[g])return;function*o(){A?.call(t),I[g]=null}const s=t.startCoroutine(o(),e);I[g]=s}const la=tA("debugeventsystem");var cR=(t=>(t.BeforeHandleInput="BeforeHandleInput",t.AfterHandleInput="AfterHandleInput",t))(cR||{});const da=class extends FA{constructor(){super(),n(this,"raycaster",[]),n(this,"_handleInputFn"),n(this,"pressedByID",new Map),n(this,"hoveredByID",new Map),n(this,"_sortedHits",[]),n(this,"_testObjectsCache",new Map),n(this,"_currentlyActiveRaycaster",null),n(this,"_currentPointerEventName",null),n(this,"shouldRaycastObject",t=>{var A;let e=null;if(lgA(t)&&(e=(A=t[$o])==null?void 0:A.gameObject),this._testObjectsCache.has(t)||e&&this._testObjectsCache.has(e))return this._testObjectsCache.get(t)===!1?"continue in children":!0;{let i=ER(t,this._currentPointerEventName);if(!i&&e&&(i=ER(e,this._currentPointerEventName)),i){this._testObjectsCache.set(t,!0);for(const g of t.children)this.shouldRaycastObject_AddToYesCache(g);return!0}return this._testObjectsCache.set(t,!1),"continue in children"}}),n(this,"_sortingBuffer",[]),n(this,"_noDepthTestingResults",[]),n(this,"out",{}),n(this,"_capturedPointer",{}),n(this,"pointerEnterSymbol",Symbol("pointerEnter")),n(this,"pointerExitSymbol",Symbol("pointerExit")),n(this,"currentActiveMeshUIComponents",[]),da.systems.push(this)}static createIfNoneExists(t){this.didSearchEventSystem||(this.didSearchEventSystem=!0,da.systems.length<=0&&da.systems.push(...CA.findObjectsOfType(da,t)));for(const e of da.systems)if(e.context===t)return;const A=new uA;CA.addNewComponent(A,da),t.scene.add(A)}static get systems(){const t=be.Current;return this._eventSystemMap.has(t)||this._eventSystemMap.set(t,[]),this._eventSystemMap.get(t)}static get(t){const A=this._eventSystemMap.get(t);return A&&A.length>0?A[0]:null}static get instance(){return this.systems[0]}static ensureUpdateMeshUI(t,A,e=!1){qn.update(t,A,e)}static markUIDirty(t){qn.markDirty()}get hasActiveUI(){return this.currentActiveMeshUIComponents.length>0}get isHoveringObjects(){return this.hoveredByID.size>0}onDestroy(){da.systems.splice(da.systems.indexOf(this),1)}start(){if(this.raycaster.length<=0&&!CA.findObjectOfType(ed,this.context)){const t=CA.addNewComponent(this.context.scene,Qo);this.raycaster.push(t),(re()||la)&&console.warn("Added an ObjectRaycaster to the scene because no raycaster was found.")}}register(t){var A;t&&this.raycaster&&!this.raycaster.includes(t)&&((A=this.raycaster)==null||A.push(t))}unregister(t){var A,e;const i=(A=this.raycaster)==null?void 0:A.indexOf(t);i!==void 0&&i!==-1&&((e=this.raycaster)==null||e.splice(i,1))}onEnable(){this._handleInputFn??(this._handleInputFn=this.onPointerEvent.bind(this)),this.context.input.addEventListener(ei.PointerDown,this._handleInputFn),this.context.input.addEventListener(ei.PointerUp,this._handleInputFn),this.context.input.addEventListener(ei.PointerMove,this._handleInputFn)}onDisable(){this.context.input.removeEventListener(ei.PointerDown,this._handleInputFn),this.context.input.removeEventListener(ei.PointerUp,this._handleInputFn),this.context.input.removeEventListener(ei.PointerMove,this._handleInputFn)}onBeforeRender(){this.resetMeshUIStates()}onPointerEvent(t){if(t===void 0||t.propagationStopped)return;const A=new Lh(this.context.input,t);this._currentPointerEventName=t.type,A.inputSource=this.context.input,A.isClick=t.isClick,A.isDoubleClick=t.isDoubleClick,A.isDown=t.type==ei.PointerDown,A.isUp=t.type==ei.PointerUp,A.isPressed=this.context.input.getPointerPressed(t.pointerId),la&&(A.isDown?console.log("DOWN",A.pointerId):A.isUp&&console.log("UP",A.pointerId),A.isClick&&console.log("CLICK",A.pointerId));const e=new zo;t.hasRay?e.ray=t.ray:e.screenPoint=this.context.input.getPointerPositionRC(t.pointerId);const i=this.performRaycast(e);if(i)for(const I of i)I.event=t,t.intersections.push(I);la&&A.isClick&&Xt("EventSystem: "+A.pointerId+" - "+this.context.time.frame+" - Up:"+A.isUp+", Down:"+A.isDown);const g={sender:this,args:A,hasActiveUI:this.currentActiveMeshUIComponents.length>0};this.dispatchEvent(new CustomEvent("BeforeHandleInput",{detail:g})),this.handleIntersections(i,A),this.dispatchEvent(new CustomEvent("AfterHandleInput",{detail:g}))}shouldRaycastObject_AddToYesCache(t){this._testObjectsCache.set(t,!0);for(const A of t.children)this.shouldRaycastObject_AddToYesCache(A)}performRaycast(t){if(!this.raycaster)return null;this._testObjectsCache.clear(),this._sortedHits.length=0,t||(t=new zo),t.testObject=this.shouldRaycastObject;for(const A of this.raycaster){if(!A.activeAndEnabled)continue;this._currentlyActiveRaycaster=A;const e=A.performRaycast(t);this._currentlyActiveRaycaster=null,e&&e.length>0&&this._sortedHits.push(...e)}return this._sortedHits.sort((A,e)=>A.distance-e.distance),this._sortedHits}assignHitInformation(t,A){A?(t.intersection=A,t.point=A.point,t.normal=A.normal,t.face=A.face,t.distance=A.distance,t.instanceId=A.instanceId):(t.intersection=void 0,t.point=void 0,t.normal=void 0,t.face=void 0,t.distance=void 0,t.instanceId=void 0)}handleIntersections(t,A){var e;if(t!=null&&t.length){t=this.sortCandidates(t);for(const g of t){if(A.event.immediatePropagationStopped)return!1;if(this.assignHitInformation(A,g),this.handleEventOnObject(g.object,A))return!0}}this.assignHitInformation(A,t?.[0]),this.invokePointerCapture(A);const i=this.hoveredByID.get(A.pointerId);return i&&this.propagatePointerExit(i.obj,i.data,null),this.hoveredByID.delete(A.pointerId),A.isUp&&((e=this.pressedByID.get(A.pointerId))==null||e.handlers.forEach(g=>this.invokeOnPointerUp(A,g)),this.pressedByID.delete(A.pointerId)),!1}sortCandidates(t){this._sortingBuffer.length=0,this._noDepthTestingResults.length=0;for(let A=0;A<t.length;A++){const e=t[A],i=e.object;if(i.material&&i.material.depthTest===!1){this._noDepthTestingResults.push(e);continue}this._sortingBuffer.push(e)}for(const A of this._sortingBuffer)this._noDepthTestingResults.push(A);return this._noDepthTestingResults}handleEventOnObject(t,A){if(!this.testIsVisible(t))return A.isClick&&la&&console.log("not allowed",t),!1;if(A.pointerId===void 0)return la&&console.error("Event without pointer can't be handled",A),!1;A.object=t;const e=t.parent,i=A.isClick??!1;let g=null;if(e&&e.isUI){const C=(A.isPressed||A.isClick)??!1;if(e[$o]){const a=e[$o].gameObject;if(a){if(!Ky.isInteractable(a,this.out))return!1;g=this.out.canvasGroup??null,this.handleMeshUIIntersection(t,C),t=a}}}i&&la&&console.log(this.context.time.frame,t);const I=this.hoveredByID.get(A.pointerId),o=I?.obj;o!==t&&o&&this.propagatePointerExit(o,I.data,t);const s=this.hoveredByID.get(A.pointerId);if(s?(s.obj=t,s.data=A):this.hoveredByID.set(A.pointerId,{obj:t,data:A}),A.isDown){const C=this.pressedByID.get(A.pointerId);C?(C.obj=t,C.data=A):this.pressedByID.set(A.pointerId,{obj:t,data:A,handlers:new Set})}return(g===null||g.interactable)&&this.handleMainInteraction(t,A,o??null),!0}propagate(t,A){for(;t;)CA.foreachComponent(t,e=>{A(e)},!1),t=t.parent}handleMainInteraction(t,A,e){const i=this.pressedByID.get(A.pointerId),g=e!==t;let I=!0;switch(A.event.pointerType){case"mouse":case"touch":const o=this.context.input.getPointerPositionLastFrame(A.pointerId),s=this.context.input.getPointerPosition(A.pointerId);I=o&&!Ae.approximately(o,s);break}this.propagate(t,o=>{var s;const C=o;C.interactable!==!1&&(!C.activeAndEnabled||!C.enabled||(C.onPointerEnter&&g&&this.handlePointerEnter(C,A),A.isDown&&C.onPointerDown&&(C.onPointerDown(A),i?.handlers.add(C),this.handlePointerCapture(A,C)),C.onPointerMove&&(I&&C.onPointerMove(A),this.handlePointerCapture(A,C)),A.isUp&&(C.onPointerUp&&(this.invokeOnPointerUp(A,C),i?.handlers.delete(C)),C.onPointerExit&&((s=A.event)==null?void 0:s.pointerType)===Pw.Touch&&(this.handlePointerExit(C,A),this.hoveredByID.delete(A.pointerId))),A.isClick&&C.onPointerClick&&C.onPointerClick(A)))}),A.isUp&&(i?.handlers.forEach(o=>{this.invokeOnPointerUp(A,o)}),this.pressedByID.delete(A.pointerId))}propagatePointerExit(t,A,e){this.propagate(t,i=>{if(!i.gameObject||i.destroyed)return;const g=i;if(g.onPointerExit){if(e&&this.isChild(e,i.gameObject))return;this.handlePointerExit(g,A)}})}invokeOnPointerUp(t,A){var e;(e=A.onPointerUp)==null||e.call(A,t),this.releasePointerCapture(t,A)}handlePointerEnter(t,A){t.onPointerEnter&&this.updatePointerState(t,A.pointerId,this.pointerEnterSymbol,!0)&&t.onPointerEnter(A),this.updatePointerState(t,A.pointerId,this.pointerExitSymbol,!1)}handlePointerExit(t,A){t.onPointerExit&&this.updatePointerState(t,A.pointerId,this.pointerExitSymbol,!0)&&t.onPointerExit(A),this.updatePointerState(t,A.pointerId,this.pointerEnterSymbol,!1)}updatePointerState(t,A,e,i){let g=t[e];if(i)return g&&g.includes(A)?!1:(g=g||[],g.push(A),t[e]=g,!0);{if(!g||!g.includes(A))return!1;const I=g.indexOf(A);return I!==-1&&g.splice(I,1),!0}}handlePointerCapture(t,A){if(t.z__pointer_ctured){t.z__pointer_ctured=!1;const e=t.pointerId;if(A.onPointerMove){const i=this._capturedPointer[e]||[];i.push(A),this._capturedPointer[e]=i}else re()&&!A.z__warned_no_pointermove&&(A.z__warned_no_pointermove=!0,console.warn("PointerCapture was requested but the component doesn't implement onPointerMove. It will not receive any pointer events"))}else t.z__pointer_cture_rleased&&(t.z__pointer_cture_rleased=!1,this.releasePointerCapture(t,A))}releasePointerCapture(t,A){const e=t.pointerId;if(this._capturedPointer[e]){const i=this._capturedPointer[e].indexOf(A);i!==-1&&(this._capturedPointer[e].splice(i,1),la&&console.log("released pointer capture",e,A,this._capturedPointer))}}invokePointerCapture(t){var A;if(t.event.type===ei.PointerMove){const e=t.pointerId,i=this._capturedPointer[e];if(i){la&&console.log("Captured",e,i);for(let g=0;g<i.length;g++){const I=i[g];if(I.destroyed){i.splice(g,1),g--;continue}(A=I.onPointerMove)==null||A.call(I,t)}}}}isChild(t,A){return!t||!A?!1:t===A?!0:t.parent?this.isChild(t.parent,A):!1}handleMeshUiObjectWithoutShadowDom(t,A){return!t||!t.isUI?!0:this.handleMeshUIIntersection(t,A)}handleMeshUIIntersection(t,A){const e=qn.updateState(t,A);return e&&this.currentActiveMeshUIComponents.push(e),e!==null}resetMeshUIStates(){if(this.context.input.getPointerPressedCount()>0&&qn.resetLastSelected(),!(!this.currentActiveMeshUIComponents||this.currentActiveMeshUIComponents.length<=0)){for(let t=0;t<this.currentActiveMeshUIComponents.length;t++){const A=this.currentActiveMeshUIComponents[t];qn.resetState(A)}this.currentActiveMeshUIComponents.length=0}}testIsVisible(t){return t?CA.isActiveSelf(t)?this.testIsVisible(t.parent):!1:!0}};let As=da;n(As,"_eventSystemMap",new Map),n(As,"didSearchEventSystem",!1);class qn{static markDirty(){this.needsUpdate=!0}static update(A,e,i=!1){if(i){A.update();return}const g=e.time.frameCount;for(const I of this.lastUpdateFrame)if(I.context===e){if(g===I.frame)return;I.frame=g;let o=this.needsUpdate||g<1;I.nextUpdate===e.time.frameCount&&(o=!0),o&&(la&&console.log("Update threemeshui"),this.needsUpdate=!1,A.update());return}this.lastUpdateFrame=[{context:e,frame:g,nextUpdate:g}],A.update()}static updateState(A,e){let i=null;if(A&&(i=this.findBlockInParent(A),i&&i!==this.lastSelected)){if(i.interactable===!1)return null;this.needsUpdate=!0}return i}static resetLastSelected(){const A=this.lastSelected;A&&(this.lastSelected=null,this.resetState(A))}static resetState(A){A&&(this.needsUpdate=!0)}static findBlockInParent(A){return A?A.isBlock?A:this.findBlockInParent(A.parent):null}}n(qn,"lastSelected",null),n(qn,"lastUpdateFrame",[]),n(qn,"needsUpdate",!1);var pgA=Object.defineProperty,ugA=Object.getOwnPropertyDescriptor,yi=(t,A,e,i)=>{for(var g=i>1?void 0:i?ugA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&pgA(A,e,g),g};const DgA=tA("debugorbit"),vy=tA("freecam"),id=tA("debugcamerafit"),by=tA("smoothcam"),wgA={LEFT:"",UP:"",RIGHT:"",BOTTOM:""};let lR;class gd extends CustomEvent{constructor(A,e){super("target-reached",{detail:{controls:A,type:e}})}}class ft extends FA{constructor(){super(...arguments),n(this,"autoTarget",!0),n(this,"autoFit",!1),n(this,"enableRotate",!0),n(this,"autoRotate",!1),n(this,"autoRotateSpeed",1),n(this,"minAzimuthAngle",1/0),n(this,"maxAzimuthAngle",1/0),n(this,"minPolarAngle",0),n(this,"maxPolarAngle",Math.PI),n(this,"enableKeys",!0),n(this,"enableDamping",!0),n(this,"dampingFactor",.1),n(this,"enableZoom",!0),n(this,"minZoom",0),n(this,"maxZoom",1/0),n(this,"enablePan",!0),n(this,"lookAtConstraint",null),n(this,"lookAtConstraint01",1),n(this,"allowInterrupt",!0),n(this,"middleClickToFocus",!0),n(this,"doubleClickToFocus",!0),n(this,"useSlerp",!0),n(this,"debugLog",!1),n(this,"targetLerpDuration",1),n(this,"_controls",null),n(this,"_cameraObject",null),n(this,"_lookTargetLerpActive",!1),n(this,"_lookTargetStartPosition",new S),n(this,"_lookTargetEndPosition",new S),n(this,"_lookTargetLerp01",0),n(this,"_lookTargetLerpDuration",0),n(this,"_cameraLerpActive",!1),n(this,"_cameraStartPosition",new S),n(this,"_cameraEndPosition",new S),n(this,"_cameraLerp01",0),n(this,"_cameraLerpDuration",0),n(this,"_inputs",0),n(this,"_enableTime",0),n(this,"_startedListeningToKeyEvents",!1),n(this,"_eventSystem"),n(this,"_afterHandleInputFn"),n(this,"_camera",null),n(this,"_syncedTransform"),n(this,"_didStart",!1),n(this,"_didSetTarget",!1),n(this,"targetElement",null),n(this,"onControlsChangeStarted",()=>{this._syncedTransform&&this._syncedTransform.requestOwnership()}),n(this,"_shouldDisable",!1),n(this,"_haveAttachedKeyboardEvents",!1)}get isCameraController(){return!0}get controls(){return this._controls}get controllerObject(){return this._cameraObject}onStartInteraction(A){var e;(e=this.controls)==null||e.addEventListener("start",A)}get targetLerpSpeed(){return 5}set targetLerpSpeed(A){this.targetLerpDuration=1/A}awake(){this._didStart=!1,this._didSetTarget=!1,this._startedListeningToKeyEvents=!1}start(){this._didStart=!0,this._eventSystem=As.get(this.context)??void 0,this._eventSystem&&(this._afterHandleInputFn=this.afterHandleInput.bind(this),this._eventSystem.addEventListener(cR.AfterHandleInput,this._afterHandleInputFn))}onDestroy(){var A,e;(A=this._controls)==null||A.dispose(),(e=this._eventSystem)==null||e.removeEventListener(cR.AfterHandleInput,this._afterHandleInputFn)}onEnable(){this._enableTime=this.context.time.time;const A=CA.getComponent(this.gameObject,xt);this._camera=A;let e=A?.cam;if(!e&&this.gameObject instanceof xe&&(e=this.gameObject),e&&CR(e,this,!0),!this._controls&&e instanceof xe){this._cameraObject=e;const i=this.targetElement??this.context.renderer.domElement,g=e?.quaternion.clone();this._controls=new jiA(e,i),e?.quaternion.copy(g),lR===void 0&&(lR={...this._controls.keys})}this._controls&&(vy&&(this.enablePan=!0,this.enableZoom=!0,this.middleClickToFocus=!0,oo()&&(this.doubleClickToFocus=!0)),this._controls.addEventListener("start",this.onControlsChangeStarted),e?.type==="PerspectiveCamera"?vy||(this._controls.minDistance=this.minZoom,this._controls.maxDistance=this.maxZoom):vy||(this._controls.minZoom=this.minZoom,this._controls.maxZoom=this.maxZoom),this._startedListeningToKeyEvents||(this._startedListeningToKeyEvents=!0,this._controls.listenToKeyEvents(window.document.body))),this._syncedTransform=CA.getComponent(this.gameObject,bn)??void 0}onDisable(){var A;(A=this._camera)!=null&&A.cam&&CR(this._camera.cam,this,!1),this._controls&&(this._controls.enabled=!1,this._controls.autoRotate=!1,this._controls.removeEventListener("start",this.onControlsChangeStarted))}afterHandleInput(A){A.detail.args.pointerId===0&&(A.detail.args.isDown?this._controls&&this._eventSystem&&(this._shouldDisable=this._eventSystem.hasActiveUI):(!A.detail.args.isPressed||A.detail.args.isUp)&&(this._shouldDisable=!1))}onBeforeRender(){var A,e;if(!this._controls)return;if(this._cameraObject!==this.context.mainCamera){this._controls.enabled=!1;return}this._controls.enabled=!0,this.__handleSetTargetWhenBecomingActiveTheFirstTime(),(this.context.input.getPointerDown(1)||this.context.input.getPointerDown(2)||this.context.input.mouseWheelChanged||this.context.input.getPointerPressed(0)&&(A=this.context.input.getPointerPositionDelta(0))!=null&&A.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 i=this.middleClickToFocus&&this.context.input.getPointerClicked(1);if(i||(i=this.doubleClickToFocus&&this.context.input.getPointerDoubleClicked(0)&&this.context.time.time-this._enableTime>.3),i&&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 gd(this,"camera"));else{const g=Ae.easeInOutCubic(this._cameraLerp01);this._cameraObject.position.lerpVectors(this._cameraStartPosition,this._cameraEndPosition,g)}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 gd(this,"lookat"));else{const g=Ae.easeInOutCubic(this._lookTargetLerp01);this._controls.target.lerpVectors(this._lookTargetStartPosition,this._lookTargetEndPosition,g)}}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?lR:wgA,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,this._controls.minAzimuthAngle=this.minAzimuthAngle,this._controls.maxAzimuthAngle=this.maxAzimuthAngle,this._controls.minPolarAngle=this.minPolarAngle,this._controls.maxPolarAngle=this.maxPolarAngle,typeof by=="number"||by===!0){this._controls.enableDamping=!0;const g=typeof by=="number"?by:.99;this._controls.dampingFactor=Math.max(.001,1-Math.min(1,g))}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||(!vy&&(e=this.lookAtConstraint)!=null&&e.locked&&this.setLookTargetFromConstraint(0,this.lookAtConstraint01),this._controls.update(),DgA&&ue.DrawWireSphere(this._controls.target,.1,65280))}}__handleSetTargetWhenBecomingActiveTheFirstTime(){if(!this._didSetTarget&&(this._didSetTarget=!0,this.autoTarget)){const A=CA.getComponent(this.gameObject,xt);if(A&&!this.setLookTargetFromConstraint()){this.debugLog&&console.log("NO TARGET");const e=Fe(A.cam).length(),i=new S(0,0,-e).applyMatrix4(A.cam.matrixWorld);this.setLookTargetPosition(i,!0)}if(!this.autoFit&&!this.setLookTargetFromConstraint()){const e=new zo;e.screenPoint=new eA(0,0),e.lineThreshold=.1;const i=this.context.physics.raycast(e);i.length>0&&this.setLookTargetPosition(i[0].point,!0),id&&console.log("OrbitControls hits",...i)}this.autoFit&&this.fitCamera()}}setCameraAndLookTarget(A){if(!A||!(A instanceof uA))return;const e=Fe(A),i=xG(A);this.setTargetFromRaycast(new HI(e,i)),this.setCameraTargetPosition(e)}setCameraTargetPosition(A,e=!1){var i,g;A&&(A instanceof uA&&(A=Fe(A)),this._cameraEndPosition||(this._cameraEndPosition=new S),this._cameraEndPosition.copy(A),e===!0?(this._cameraLerpActive=!1,(i=this.controllerObject)==null||i.position.copy(this._cameraEndPosition)):this._cameraObject&&(this._cameraLerpActive=!0,this._cameraLerp01=0,this._cameraStartPosition.copy((g=this._cameraObject)==null?void 0:g.position),typeof e=="number"?this._cameraLerpDuration=e:this._cameraLerpDuration=this.targetLerpDuration))}get cameraLerpActive(){return this._cameraLerpActive}stopCameraLerp(){this._cameraLerpActive=!1}setLookTargetPosition(A=null,e=!1){this._controls&&A&&(A instanceof uA&&(A=Fe(A)),this._lookTargetEndPosition.copy(A),e===!0?this._controls.target.copy(this._lookTargetEndPosition):(this._lookTargetLerpActive=!0,this._lookTargetLerp01=0,this._lookTargetStartPosition.copy(this._controls.target),typeof e=="number"?this._lookTargetLerpDuration=e:this._lookTargetLerpDuration=this.targetLerpDuration))}get lookTargetLerpActive(){return this._lookTargetLerpActive}stopLookTargetLerp(){this._lookTargetLerpActive=!1}setLookTargetFromConstraint(A=0,e=1){var i;if(!this._controls)return!1;const g=(i=this.lookAtConstraint)==null?void 0:i.sources;if(g&&g.length>0){const I=g[A];if(I)return I.getWorldPosition(this._lookTargetEndPosition),this.lerpLookTarget(this._lookTargetEndPosition,e),!0}return!1}lerpTarget(A,e){return this.lerpLookTarget(A,e)}lerpLookTarget(A,e){this._controls&&(e>=1?this._controls.target.copy(A):this._controls.target.lerp(A,e))}setTargetFromRaycast(A){if(!this.controls)return;const e=A?this.context.physics.raycastFromRay(A):this.context.physics.raycast();for(const i of e)if(i.distance>0&&CA.isActiveInHierarchy(i.object)){const g=hR(i.object);if(g){const I=g.canvas;if(I!=null&&I.screenspace)break}this.setLookTargetPosition(i.point);break}}fitCamera(A,e=void 0,i=!0){if(this.context.isInXR)return;e==null&&(e=1.1);const g=this._cameraObject,I=this._controls;if(A!=null&&A.length||(A=this.context.scene.children),A.length<=0){console.warn("No objects to fit camera to...");return}if(!g||!I){console.warn("No camera or controls found to fit camera to objects...");return}const o=new S,s=new S,C=new pt;C.makeEmpty();const a=[];function r(k){let U=!0;if(k.visible&&PT(k)!==!1&&!(k.type==="TransformControlsGizmo"||k.type==="TransformControlsPlane")&&(k instanceof xk&&(U=!1),k instanceof vD&&(U=!1),k instanceof TT&&(U=!1),k.material instanceof yD&&(U=!1),k instanceof hA||(U=!1),k!==g&&k.isUI!==!0)){if(U){id&&console.log(k.name,k.type,k);const M=k.children;k.children=a;const G=k.position,K=k.scale;if(Number.isNaN(G.x)||Number.isNaN(G.y)||Number.isNaN(G.z)){console.warn(`Object "${k.name}" has NaN values in position or scale.... will ignore it`,G,K);return}C.expandByObject(k,!0),k.children=M}for(const M of k.children)r(M)}}let B=!1;for(const k of A)k&&(B=!0,k.updateMatrixWorld(),r(k));if(!B){console.warn("No objects to fit camera to...");return}if(g.updateMatrixWorld(),g.updateProjectionMatrix(),C.getCenter(s),C.applyMatrix4(g.matrixWorldInverse),C.getSize(o),C.setFromCenterAndSize(s,o),Number.isNaN(o.x)||Number.isNaN(o.y)||Number.isNaN(o.z)){console.warn("Camera fit size resultet in NaN",g,C,[...A]);return}if(o.length()<=1e-10){id&&console.warn("Camera fit size is zero",C,[...A]);return}const Q=g.fov,E=2*Math.atan(Math.tan(Q*Math.PI/360/2)*g.aspect)/Math.PI*360,h=o.y/(2*Math.atan(Math.PI*Q/360)),d=o.x/(2*Math.atan(Math.PI*E/360)),l=e*Math.max(h,d)+o.z/2;id&&console.log("Fit camera to objects",h,d,"distance",l),I.maxDistance=l*10,I.minDistance=l*.01;const c=.05,p=s.clone();p.y-=o.y*c,this.setLookTargetPosition(p,i),this.autoTarget=!1,g.near=l/1e3,g.far=l*100,g.updateMatrixWorld(),g.updateProjectionMatrix();const u=Fe(g),D=s.clone();if(D.sub(u),D.y=0,D.normalize(),D.multiplyScalar(l),D.y+=-c*4*o.y,g.parent){const k=g.parent.worldToLocal(s.clone().sub(D));this.setCameraTargetPosition(k,i)}else console.error(`Can not fit camera ${g.name} because it has no parent`);if(id){const k=new xk(C);this.context.scene.add(k),_G(k,Zc(g)),setTimeout(()=>{this.context.scene.remove(k)},1e4),this._haveAttachedKeyboardEvents||(this._haveAttachedKeyboardEvents=!0,document.body.addEventListener("keydown",U=>{U.code==="KeyF"&&this.fitCamera(A,e,i)}))}I.update()}}yi([w()],ft.prototype,"autoTarget",2),yi([w()],ft.prototype,"autoFit",2),yi([w()],ft.prototype,"enableRotate",2),yi([w()],ft.prototype,"autoRotate",2),yi([w()],ft.prototype,"autoRotateSpeed",2),yi([w()],ft.prototype,"minAzimuthAngle",2),yi([w()],ft.prototype,"maxAzimuthAngle",2),yi([w()],ft.prototype,"minPolarAngle",2),yi([w()],ft.prototype,"maxPolarAngle",2),yi([w()],ft.prototype,"enableKeys",2),yi([w()],ft.prototype,"enableDamping",2),yi([w()],ft.prototype,"dampingFactor",2),yi([w()],ft.prototype,"enableZoom",2),yi([w()],ft.prototype,"minZoom",2),yi([w()],ft.prototype,"maxZoom",2),yi([w()],ft.prototype,"enablePan",2),yi([w(DB)],ft.prototype,"lookAtConstraint",2),yi([w()],ft.prototype,"lookAtConstraint01",2),yi([w()],ft.prototype,"allowInterrupt",2),yi([w()],ft.prototype,"middleClickToFocus",2),yi([w()],ft.prototype,"doubleClickToFocus",2),yi([w()],ft.prototype,"targetLerpDuration",2);var ygA=Object.defineProperty,SgA=Object.getOwnPropertyDescriptor,WI=(t,A,e,i)=>{for(var g=i>1?void 0:i?SgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ygA(A,e,g),g},yB=(t=>(t[t.Skybox=1]="Skybox",t[t.SolidColor=2]="SolidColor",t[t.Uninitialized=4]="Uninitialized",t))(yB||{});const pa=tA("debugcam"),e2=tA("debugscreenpointtoray");var qy;const Id=(qy=class extends FA{constructor(){super(...arguments),n(this,"_nearClipPlane",.1),n(this,"_farClipPlane",1e3),n(this,"orthographic",!1),n(this,"orthographicSize",5),n(this,"ARBackgroundAlpha",0),n(this,"_cullingMask",4294967295),n(this,"_backgroundBlurriness",0),n(this,"_backgroundIntensity",1),n(this,"_environmentIntensity"),n(this,"_targetTexture",null),n(this,"_backgroundColor"),n(this,"_fov"),n(this,"_cam",null),n(this,"_clearFlags",2),n(this,"_skybox"),n(this,"_frustum"),n(this,"_projScreenMatrix",new MA)}get isCamera(){return!0}get aspect(){return this._cam instanceof xe?this._cam.aspect:this.context.domWidth/this.context.domHeight}set aspect(t){this._cam instanceof xe&&this._cam.aspect!==t&&(this._cam.aspect=t,this._cam.updateProjectionMatrix())}get fieldOfView(){return this._cam instanceof xe?this._cam.fov:this._fov}set fieldOfView(t){const A=this.fieldOfView!=t;if(this._fov=t,A&&this._cam&&this._cam instanceof xe){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(t){const A=this._nearClipPlane!=t;this._nearClipPlane=t,this._cam&&A&&(this._cam.near=t,this._cam.updateProjectionMatrix())}get farClipPlane(){return this._farClipPlane}set farClipPlane(t){const A=this._farClipPlane!=t;this._farClipPlane=t,this._cam&&A&&(this._cam.far=t,this._cam.updateProjectionMatrix())}get clearFlags(){return this._clearFlags}set clearFlags(t){t!==this._clearFlags&&(this._clearFlags=t,this.applyClearFlagsIfIsActiveCamera())}set cullingMask(t){this._cullingMask=t,this._cam&&(this._cam.layers.mask=t)}get cullingMask(){return this._cam?this._cam.layers.mask:this._cullingMask}set cullingLayer(t){this.cullingMask=(1<<t|0)>>>0}set backgroundBlurriness(t){t!==this._backgroundBlurriness&&(t===void 0?this._backgroundBlurriness=void 0:this._backgroundBlurriness=Math.min(Math.max(t,0),1),this.applyClearFlagsIfIsActiveCamera())}get backgroundBlurriness(){return this._backgroundBlurriness}set backgroundIntensity(t){t!==this._backgroundIntensity&&(t===void 0?this._backgroundIntensity=void 0:this._backgroundIntensity=Math.min(Math.max(t,0),10),this.applyClearFlagsIfIsActiveCamera())}get backgroundIntensity(){return this._backgroundIntensity}set environmentIntensity(t){this._environmentIntensity=t}get environmentIntensity(){return this._environmentIntensity}get backgroundColor(){return this._backgroundColor??null}set backgroundColor(t){if(t){if(this._backgroundColor)this._backgroundColor.copy(t);else{if(!t.clone)return;this._backgroundColor=t.clone()}t.alpha===void 0&&(this._backgroundColor.alpha=1),this.applyClearFlagsIfIsActiveCamera()}}set targetTexture(t){this._targetTexture=t}get targetTexture(){return this._targetTexture}get cam(){return this.activeAndEnabled&&this.buildCamera(),this._cam}screenPointToRay(t,A,e){const i=this.cam,g=Id._origin;g.set(t,A,-1),this.context.input.convertScreenspaceToRaycastSpace(g),e2&&console.log("screenPointToRay",t.toFixed(2),A.toFixed(2),"now:",g.x.toFixed(2),g.y.toFixed(2),"isInXR:"+this.context.isInXR),g.z=-1,g.unproject(i);const I=Id._direction.set(g.x,g.y,g.z),o=Fe(i);return I.sub(o),I.normalize(),e?(e.set(o,I),e):new HI(o.clone(),I.clone())}getFrustum(){return this._frustum||(this._frustum=new Mr,this.updateFrustum()),this._frustum}updateFrustum(){this._frustum||(this._frustum=new Mr),this._frustum.setFromProjectionMatrix(this.getProjectionScreenMatrix(this._projScreenMatrix,!0),this.context.renderer.coordinateSystem)}getProjectionScreenMatrix(t,A){return A&&this._projScreenMatrix.multiplyMatrices(this.cam.projectionMatrix,this.cam.matrixWorldInverse),t===this._projScreenMatrix?t:t.copy(this._projScreenMatrix)}awake(){e2&&window.addEventListener("pointerdown",t=>{const A=t.clientX,e=t.clientY;console.log("touch",A.toFixed(2),e.toFixed(2));const i=this.screenPointToRay(A,e),g="#"+Math.floor(Math.random()*16777215).toString(16);ue.DrawRay(i.origin,i.direction,g,10)})}onEnable(){pa&&console.log(`Camera enabled: "${this.name}". ClearFlags=${yB[this._clearFlags]}`,this),this.buildCamera(),(this.tag=="MainCamera"||!this.context.mainCameraComponent)&&(this.context.setCurrentCamera(this),mgA(this)),this.applyClearFlagsIfIsActiveCamera()}onDisable(){this.context.removeCamera(this)}onBeforeRender(){if(this._cam&&(this._frustum&&this.updateFrustum(),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 t=this.context.renderer;if(t){const A=this.context.mainCameraComponent;this.applyClearFlags(),this._targetTexture.render(this.context.scene,this._cam,t),A?.applyClearFlags()}}}buildCamera(){if(this._cam)return;const t=this.gameObject.isCamera;let A=null;if(t?(A=this.gameObject,A?.layers.enableAll(),A instanceof xe&&(this._fov=A.fov)):A=this.gameObject.children[0],A&&A.isCamera)A instanceof xe&&(this._fov&&(A.fov=this._fov),A.near=this._nearClipPlane,A.far=this._farClipPlane,A.updateProjectionMatrix());else if(!this.orthographic)A=new xe(this.fieldOfView,window.innerWidth/window.innerHeight,this._nearClipPlane,this._farClipPlane),this.fieldOfView&&(A.fov=this.fieldOfView),this.gameObject.add(A);else{const e=this.orthographicSize*100;A=new VC(window.innerWidth/-e,window.innerWidth/e,window.innerHeight/e,window.innerHeight/-e,this._nearClipPlane,this._farClipPlane),this.gameObject.add(A)}this._cam=A,this._cam.layers.mask=this._cullingMask,this.tag=="MainCamera"&&this.context.setCurrentCamera(this)}applyClearFlagsIfIsActiveCamera(){this.context.mainCameraComponent===this&&this.applyClearFlags()}applyClearFlags(){if(!this._cam){pa&&console.log("Camera does not exist (apply clear flags)");return}if(this.fieldOfView=this._fov,pa){const t=`Camera "${this.name}" clear flags: ${yB[this._clearFlags]}`;console.debug(t)}switch(this._clearFlags){case 1:if(Id.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:pa&&console.warn(`Camera "${this.name}" has no background blurriness`),this._backgroundIntensity!==void 0?this.context.scene.backgroundIntensity=this._backgroundIntensity:pa&&console.warn(`Camera "${this.name}" has no background intensity`);break;case 2:if(this._backgroundColor){let t=this._backgroundColor.alpha;Id.backgroundShouldBeTransparent(this.context)&&(t=this.ARBackgroundAlpha??0),this.context.scene.background=null,this.context.renderer.setClearColor(this._backgroundColor,t)}else pa&&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 fgA(this)),this._skybox.enable()}static backgroundShouldBeTransparent(t){var A,e,i,g;const I=(A=t.renderer.xr)==null?void 0:A.getSession();if(!I)return!1;if(typeof I._transparent=="boolean")return I._transparent;const o=I.environmentBlendMode;pa&&Xt("Environment blend mode: "+o+" on "+navigator.userAgent);let s=o==="additive"||o==="alpha-blend";return t.isInAR&&o==="opaque"&&((e=navigator.userAgent)!=null&&e.includes("OculusBrowser")||(i=navigator.userAgent)!=null&&i.includes("Mozilla")&&(g=navigator.userAgent)!=null&&g.includes("Mobile WebXRViewer/v2"))&&(s=!0),I._transparent=s,s}},n(qy,"_origin",new S),n(qy,"_direction",new S),qy);let xt=Id;WI([w()],xt.prototype,"aspect",1),WI([w()],xt.prototype,"fieldOfView",1),WI([w()],xt.prototype,"nearClipPlane",1),WI([w()],xt.prototype,"farClipPlane",1),WI([w()],xt.prototype,"clearFlags",1),WI([w()],xt.prototype,"orthographic",2),WI([w()],xt.prototype,"orthographicSize",2),WI([w()],xt.prototype,"ARBackgroundAlpha",2),WI([w()],xt.prototype,"cullingMask",1),WI([w()],xt.prototype,"backgroundBlurriness",1),WI([w()],xt.prototype,"backgroundIntensity",1),WI([w()],xt.prototype,"environmentIntensity",1),WI([w(St)],xt.prototype,"backgroundColor",1),WI([w(bE)],xt.prototype,"targetTexture",1);class fgA{constructor(A){n(this,"_camera"),n(this,"_skybox"),this._camera=A}get context(){var A;return(A=this._camera)==null?void 0:A.context}enable(){this._skybox=this.context.lightmaps.tryGetSkybox(this._camera.sourceId),this._skybox?this.context.scene.background!==this._skybox&&(pa&&console.log(`Camera "${this._camera.name}" set skybox`,this._camera,this._skybox),this._skybox.mapping=Jo,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)),(pa||re())&&Ci(`Camera "${this._camera.name}" has no skybox texture`))}}function mgA(t){tA("freecam")&&t.context.mainCameraComponent===t&&CA.getOrAddComponent(t.gameObject,ft)}class xn extends FA{constructor(){super(...arguments),n(this,"_listener",null)}get listener(){return this._listener==null&&(this._listener=new Pb),this._listener}awake(){ai.registerWaitForAllowAudio(()=>{if(this.destroyed)return;const A=this.listener;if(A==null||A.parent)return;const e=this.context.mainCameraComponent||CA.getComponentInParent(this.gameObject,xt);e!=null&&e.cam?e.cam.add(A):this.gameObject.add(A)})}}var kgA=Object.defineProperty,GgA=Object.getOwnPropertyDescriptor,xy=(t,A,e,i)=>{for(var g=i>1?void 0:i?GgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&kgA(A,e,g),g};const MgA=tA("debugsignals");class od{constructor(){n(this,"guid")}}xy([w()],od.prototype,"guid",2);class YE{constructor(){n(this,"signal"),n(this,"reaction")}}xy([w(od)],YE.prototype,"signal",2),xy([w(tg)],YE.prototype,"reaction",2);var dR;const ua=(dR=class extends FA{constructor(){super(...arguments),n(this,"events")}static invoke(t){if(ua.receivers[t]){const A=ua.receivers[t];if(!A)return;for(const e of A)e.invoke(t)}}awake(){MgA&&console.log("SignalReceiver awake",this)}onEnable(){if(this.events)for(const t of this.events)ua.receivers[t.signal.guid]||(ua.receivers[t.signal.guid]=[]),ua.receivers[t.signal.guid].push(this)}onDisable(){if(this.events){for(const t of this.events)if(ua.receivers[t.signal.guid]){const A=ua.receivers[t.signal.guid].indexOf(this);A>=0&&ua.receivers[t.signal.guid].splice(A,1)}}}invoke(t){if(!this.events||!Array.isArray(this.events))return;const A=typeof t=="object"?t.guid:t;for(const e of this.events)if(e.signal.guid===A)try{if(e.reaction){if(!e.reaction.invoke){console.warn("Missing invoke - possibly a serialization error",e,this);continue}}else{console.warn("Missing reaction for signal",e,this);continue}e.reaction.invoke()}catch(i){console.error(i)}}},n(dR,"receivers",{}),dR);let _E=ua;xy([w(YE)],_E.prototype,"events",2);var Eo=(t=>(t.Activation="ActivationTrack",t.Animation="AnimationTrack",t.Audio="AudioTrack",t.Control="ControlTrack",t.Marker="MarkerTrack",t.Signal="SignalTrack",t))(Eo||{}),BC=(t=>(t[t.None=0]="None",t[t.Hold=1]="Hold",t[t.Loop=2]="Loop",t[t.PingPong=3]="PingPong",t[t.Continue=4]="Continue",t))(BC||{}),pR=(t=>(t.Signal="SignalEmitter",t))(pR||{});const QC=tA("debugtimeline");class sd{constructor(){n(this,"director"),n(this,"track")}get muted(){return this.track.muted}set muted(A){var e;A!==this.track.muted&&(this.track.muted=A,(e=this.onMuteChanged)==null||e.call(this))}*forEachClip(A=!1){var e;if((e=this.track)!=null&&e.clips)if(A)for(let i=this.track.clips.length-1;i>=0;i--)yield this.track.clips[i];else for(const i of this.track.clips)yield i}getClipTime(A,e){return e.clipIn+(A-e.start)*e.timeScale}getClipTimeNormalized(A,e){return(A-e.start)/e.duration}evaluateWeight(A,e,i,g=!0){if(e<0||e>=i.length)return 0;const I=i[e];if(g||A>=I.start&&A<=I.end){let o=1;const s=!1;if(I.easeInDuration>0){const C=Math.min((A-I.start)/I.easeInDuration,1);o*=C}if(I.easeOutDuration>0&&!s){const C=Math.min((I.end-A)/I.easeOutDuration,1);o*=C}return o}return 0}}class UgA{constructor(A){n(this,"clip"),n(this,"rootPositionOffset"),n(this,"rootQuaternionOffset"),n(this,"rootStartPosition"),n(this,"rootEndPosition"),n(this,"rootStartQuaternion"),n(this,"rootEndQuaternion");const e=A.getClip();this.clip=e;const i=A.getRoot(),g=i.name+".position",I=i.name+".quaternion";QC&&console.log(e.name,e.tracks,g);for(const o of e.tracks)if(!(o.times.length<=0)){if(o.name.endsWith(g))this.rootStartPosition=new S().fromArray(o.values,0),this.rootEndPosition=new S().fromArray(o.values,o.values.length-3),this.rootPositionOffset=this.rootEndPosition.clone().sub(this.rootStartPosition),QC&&console.log(this.rootPositionOffset);else if(o.name.endsWith(I)&&(this.rootStartQuaternion=new RA().fromArray(o.values,0),this.rootEndQuaternion=new RA().fromArray(o.values,o.values.length-4),this.rootQuaternionOffset=this.rootEndQuaternion.clone().multiply(this.rootStartQuaternion),QC)){const s=new jt().setFromQuaternion(this.rootQuaternionOffset);console.log("ROT",s)}}}get hasOffsets(){return this.rootPositionOffset!==void 0||this.rootQuaternionOffset!==void 0}}class Ly extends sd{constructor(){super(...arguments),n(this,"models",[]),n(this,"trackOffset"),n(this,"target"),n(this,"mixer"),n(this,"clips",[]),n(this,"actions",[]),n(this,"_actionOffsets",[]),n(this,"_didBind",!1),n(this,"_animator",null),n(this,"_useclipOffsets",!0),n(this,"_totalOffsetPosition",new S),n(this,"_totalOffsetRotation",new RA),n(this,"_totalOffsetPosition2",new S),n(this,"_totalOffsetRotation2",new RA),n(this,"_summedPos",new S),n(this,"_tempPos",new S),n(this,"_summedRot",new RA),n(this,"_tempRot",new RA),n(this,"_clipRotQuat",new RA)}onDisable(){var A;(A=this.mixer)==null||A.stopAllAction()}onStateChanged(){this._animator&&t2(this._animator.gameObject,this,this.director.isPlaying)}createHooks(A,e){var i,g;if(((i=e.tracks)==null?void 0:i.length)<=0){console.warn("No tracks in AnimationClip",e);return}const I=e.tracks[0].name.split("."),o=I[I.length-2],s=o+".position",C=o+".quaternion";let a=!1,r=!1;for(const B of e.tracks)B.name.endsWith(s)?(a=!0,this.createPositionInterpolant(e,A,B)):B.name.endsWith(C)&&(r=!0,this.createRotationInterpolant(e,A,B));if(!a||!r){const B=(g=this.mixer)==null?void 0:g.getRoot(),Q=e.tracks[0],E=Q.name.lastIndexOf("."),h=Q.name.substring(0,E),d=h.substring(h.lastIndexOf(".")+1),l=B.getObjectByName(d);if(l)if(a){if(!r){const c=e.tracks[0].name.substring(0,E)+".quaternion";QC&&console.warn("Create quaternion track",d,l);const p=l.quaternion,u=new zs(c,[0,e.duration],[p.x,p.y,p.z,p.w,p.x,p.y,p.z,p.w]);e.tracks.push(u),this.createRotationInterpolant(e,A,u)}}else{const c=h+".position";QC&&console.warn("Create position track",d,l);const p=l.position,u=new XC(c,[0,e.duration],[p.x,p.y,p.z,p.x,p.y,p.z]);e.tracks.push(u),this.createPositionInterpolant(e,A,u)}}}bind(){if(!this._didBind){this._didBind=!0,QC&&console.log(this.models),this.mixer?this.target=this.mixer.getRoot():console.warn("No mixer was assigned to animation track");for(const A of this.actions){const e=new UgA(A);this._actionOffsets.push(e)}this.target&&(this._animator=CA.getComponent(this.target,qg)??null,this._animator&&t2(this._animator.gameObject,this,!0));for(const A of this.models){const e=A.asset,i=e.position,g=e.rotation;i&&i.x!==void 0&&(i.isVector3||(e.position=new S(i.x,i.y,i.z)),g.isQuaternion||(e.rotation=new RA(g.x,g.y,g.z,g.w)))}this.ensureTrackOffsets()}}ensureTrackOffsets(){if(this.trackOffset){const A=this.trackOffset.position;A&&(A.isVector3||(this.trackOffset.position=new S(A.x,A.y,A.z)));const e=this.trackOffset.rotation;e&&(e.isQuaternion||(this.trackOffset.rotation=new RA(e.x,e.y,e.z,e.w)))}}evaluate(A){var e,i,g,I,o,s,C;if(this.track.muted||!this.mixer)return;this.bind(),this._totalOffsetPosition.set(0,0,0),this._totalOffsetRotation.set(0,0,0,1),this._totalOffsetPosition2.set(0,0,0),this._totalOffsetRotation2.set(0,0,0,1);let a=0,r=0,B=!1,Q=!1,E=0;for(let h=0;h<this.clips.length;h++){const d=this.models[h],l=this.actions[h],c=d.asset;l.weight=0;const p=A>=d.start&&A<=d.end,u=d.preExtrapolationMode,D=d.postExtrapolationMode,k=h<this.clips.length-1?this.models[h+1]:null;let U=p,M=!1;if(!U&&!B&&d.end<A&&D!==BC.None?(!k||k.start>A)&&(U=!0,B=!0):h==0&&!U&&!Q&&d.start>A&&u!==BC.None&&(!k||k.start<A)&&(U=!0,M=!0,Q=!0),U){let G=1;G*=this.evaluateWeight(A,h,this.models,U),G*=this.director.weight;let K=p;if(M)switch(u){case BC.Hold:break;case BC.Loop:A+=d.start,K=!0;break;default:A+=d.start,K=!0;break}let f=this.getClipTime(A,d),N=0;const _=c.duration;if(M&&u===BC.Hold&&(f=0),K){if(c.loop)for(N+=Math.floor(f/(_+1e-6));f>_;)f-=_}else if(!p&&B)switch(D){case BC.Hold:f=this.getClipTime(d.end,d);break;case BC.Loop:f%=_;break;case BC.PingPong:const v=Math.floor(f/_)%2!==0;f%=_,v&&(f=_-f);break}d.reversed===!0?l.time=l.getClip().duration-f:l.time=f,l.timeScale=0;const T=Math.max(0,G);if(l.weight=T,E+=T,l.clampWhenFinished=!1,l.isRunning()||l.play(),this._useclipOffsets){const v=a==0?this._totalOffsetPosition:this._totalOffsetPosition2,j=a==0?this._totalOffsetRotation:this._totalOffsetRotation2;a<1&&(r=1-G),a+=1;const b=this._summedPos.set(0,0,0),x=this._tempPos.set(0,0,0),Y=this._summedRot.identity(),AA=this._tempRot.identity(),$=c.rotation;$&&(this._clipRotQuat.identity(),this._clipRotQuat.slerp($,G));const aA=this._actionOffsets[h];if(aA.hasOffsets)for(let wA=0;wA<N;wA++)aA.rootPositionOffset?x.copy(aA.rootPositionOffset):x.set(0,0,0),x.applyQuaternion(Y),this._clipRotQuat&&x.applyQuaternion(this._clipRotQuat),aA.rootQuaternionOffset&&(AA.copy(aA.rootQuaternionOffset),Y.multiply(AA)),b.add(x);this._clipRotQuat&&j.multiply(this._clipRotQuat),j.multiply(Y),c.position&&b.add(c.position),v.add(b)}}}if(this._useclipOffsets&&(this._totalOffsetPosition.lerp(this._totalOffsetPosition2,r),this._totalOffsetRotation.slerp(this._totalOffsetRotation2,r)),this.__mixerError===void 0&&(QC||re())&&(i=(e=this._animator)==null?void 0:e.runtimeAnimatorController)!=null&&i.mixer&&this.mixer!==((I=(g=this._animator)==null?void 0:g.runtimeAnimatorController)==null?void 0:I.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 h=Math.max(0,1-E);(C=(s=this._animator)==null?void 0:s.runtimeAnimatorController)==null||C.update(h)}else this.mixer.update(A)}createRotationInterpolant(A,e,i){var g;const I=i.createInterpolant.bind(i),o=new RA;this.ensureTrackOffsets();const s=(g=this.trackOffset)==null?void 0:g.rotation;i.createInterpolant=()=>{const C=I(),a=C.evaluate.bind(C);return C.evaluate=r=>{var B;const Q=a(r);if(o.set(Q[0],Q[1],Q[2],Q[3]),o.premultiply(this._totalOffsetRotation),s&&o.premultiply(s),this.director.animationCallbackReceivers)for(const E of this.director.animationCallbackReceivers)(B=E?.onTimelineRotation)==null||B.call(E,this.director,this.target,r,o);return Q[0]=o.x,Q[1]=o.y,Q[2]=o.z,Q[3]=o.w,Q},C}}createPositionInterpolant(A,e,i){var g,I;const o=i.createInterpolant.bind(i),s=new S;this.ensureTrackOffsets();const C=(g=this.trackOffset)==null?void 0:g.rotation,a=(I=this.trackOffset)==null?void 0:I.position;let r;i.createInterpolant=()=>{const B=o(),Q=B.evaluate.bind(B);return B.evaluate=E=>{var h,d,l;const c=Q(E);if(s.set(c[0],c[1],c[2]),e.removeStartOffset&&(r===void 0?(r=null,r=(d=(h=this._actionOffsets.find(p=>p.clip===A))==null?void 0:h.rootStartPosition)==null?void 0:d.clone()):r!=null&&r.isVector3&&s.sub(r)),s.applyQuaternion(this._totalOffsetRotation),s.add(this._totalOffsetPosition),C&&s.applyQuaternion(C),a&&(s.x-=a.x,s.y+=a.y,s.z+=a.z),this.director.animationCallbackReceivers)for(const p of this.director.animationCallbackReceivers)(l=p?.onTimelinePosition)==null||l.call(p,this.director,this.target,E,s);return c[0]=s.x,c[1]=s.y,c[2]=s.z,c},B}}}const RgA=tA("mutetimeline"),Cd=class extends sd{constructor(){super(...arguments),n(this,"models",[]),n(this,"listener"),n(this,"audio",[]),n(this,"audioContextTimeOffset",[]),n(this,"lastTime",0),n(this,"audioSource"),n(this,"_audioLoader",null),n(this,"_playableDirectorResumed",!1)}getAudioFilePath(t){const A=this.director.sourceId;return ea(A,t)}onAllowAudioChanged(t){for(let A=0;A<this.models.length;A++){const e=this.models[A];this.audio[A].setVolume(t?e.asset.volume:0)}}addModel(t){const A=new Rk(this.listener);this.audio.push(A);const e=t;e._didTriggerPlay=!1,this.models.push(e)}onDisable(){for(const t of this.audio)t.isPlaying&&t.stop();for(const t of this.models)t._didTriggerPlay=!1}onDestroy(){for(const t of this.audio)t.source&&t?.disconnect();this.audio.length=0}onMuteChanged(){if(this.muted)for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}}stop(){for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}for(const t of this.models)t._didTriggerPlay=!1}onPauseChanged(){for(let t=0;t<this.audio.length;t++){const A=this.audio[t];A!=null&&A.isPlaying&&A.stop()}this._playableDirectorResumed=this.director.isPlaying}evaluate(t){if(RgA||this.track.muted||this.director.speed<0)return;const A=this.director.context.application.muted,e=this._playableDirectorResumed;this._playableDirectorResumed=!1;const i=A?.1:0;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=this.audio[g],s=I.asset;if((!o||!o.buffer)&&this.isInTimeRange(I,t-1,t+1)&&this.handleAudioLoading(I,o),ai.userInteractionRegistered!==!1&&!(o===null||!o.buffer))if(o.playbackRate=this.director.context.time.timeScale*this.director.speed,o.loop=s.loop,t>=I.start&&t<=I.end&&t<this.director.duration){if(!o.isPlaying||!this.director.isPlaying)(e||!I._didTriggerPlay&&this.lastTime<t)&&(I.duration*I.timeScale>.3?o.offset=I.clipIn+(t-I.start)*I.timeScale:o.offset=0,QC&&console.log("Timeline Audio ("+this.track.name+") play with offset "+o.offset+" - "+I.asset.clip),o.play(i),I._didTriggerPlay=!0);else{const a=I.clipIn+(t-I.start)*I.timeScale,r=o.context.currentTime-o._startedAt+o.offset;Math.abs(a-r)>.3&&(o.offset=a,o.stop(),o.play(i))}let C=s.volume;if(this.track.volume!==void 0&&(C*=this.track.volume),A&&(C=0),I.easeInDuration>0){const a=Math.min((t-I.start)/I.easeInDuration,1);C*=a}if(I.easeOutDuration>0){const a=Math.min((I.end-t)/I.easeOutDuration,1);C*=a}o.setVolume(C*this.director.weight)}else I._didTriggerPlay=!1,this.director.isPlaying&&o.isPlaying&&o.stop()}this.lastTime=t}loadAudio(t,A=0,e=0){let i=null;const g=t-e,I=t+A;for(const o of this.models)if(this.isInTimeRange(o,g,I)){const s=this.audio[this.models.indexOf(o)],C=this.handleAudioLoading(o,s);C!==null&&(i===null&&(i=[]),i.push(C))}return i!==null?Promise.all(i):null}isInTimeRange(t,A,e){return A<=t.start&&e>=t.end||A>=t.start&&A<=t.end||e>=t.start&&e<=t.end}static dispose(){Cd._audioBuffers.clear()}handleAudioLoading(t,A){this._audioLoader||(this._audioLoader=new RD);const e=this.getAudioFilePath(t.asset.clip);if(Cd._audioBuffers.get(e)){const g=Cd._audioBuffers.get(e);return g.then(I=>{I&&A.setBuffer(I)}),g}QC&&console.warn("LOAD audio track",e,this.director.sourceId);const i=new Promise((g,I)=>{this._audioLoader.load(e,o=>{A.setBuffer(o),g(o)},void 0,o=>{console.error("Error loading audio",o),g(null)})});return Cd._audioBuffers.set(e,i),i}};let ad=Cd;n(ad,"_audioBuffers",new Map);class nd extends sd{constructor(){super(...arguments),n(this,"models",[]),n(this,"didTrigger",[]),n(this,"receivers",[])}evaluate(A){var e;if(this.track.muted)return;const i=this.director.context.time.deltaTime*1.5;for(let g=0;g<this.models.length;g++){const I=this.models[g],o=this.didTrigger[g],s=I.time-A;let C=!1;if(I.retroActive)C=s<=1e-6;else{const a=Math.abs(s);(a===0||a>=1e-5&&a<i)&&(C=!0)}if(C){if(!o)if(QC&&console.log("Trigger signal",A,I.time,I),this.didTrigger[g]=!0,((e=this.receivers)==null?void 0:e.length)<=0)_E.invoke(I.asset);else for(const a of this.receivers)a&&a.invoke(I.asset)}else I.emitOnce||(this.didTrigger[g]=!1)}}}class Yy extends sd{constructor(){super(...arguments),n(this,"models",[]),n(this,"timelines",[]),n(this,"_previousActiveModel",null)}resolveSourceObjects(A){for(let e=this.models.length-1;e>=0;e--){const i=this.models[e].asset;if(!i.sourceObject||typeof i.sourceObject!="object"){console.log("no source object, removing model",e,i),this.models.splice(e,1);continue}else{const g=CA.getComponent(i.sourceObject,SB);this.timelines.push(g),g&&i.updateDirector&&(g.playOnAwake=!1)}}}evaluate(A){var e;this._previousActiveModel=null;for(let i=0;i<this.models.length;i++){const g=this.models[i],I=g.asset;if(A>=g.start&&A<=g.end){this._previousActiveModel=g;const o=this.getClipTime(A,g);if(I.controlActivation){const s=I.sourceObject;s.visible=!0}if(I.updateDirector){const s=this.timelines[i];s&&(s.isPlaying&&s.pause(),s.time=o,s.evaluate())}}else{const o=(e=this._previousActiveModel)==null?void 0:e.asset;if(I.controlActivation){const s=I.sourceObject;o?.sourceObject!==s&&(s.visible=!1)}}}}}const HE=tA("debugtimeline"),uR=class extends FA{constructor(){super(...arguments),n(this,"playableAsset"),n(this,"playOnAwake"),n(this,"extrapolationMode",1),n(this,"waitForAudio",!0),n(this,"_visibilityChangeEvt"),n(this,"_clonedPlayableAsset",!1),n(this,"_speed",1),n(this,"_guidsMap"),n(this,"_isPlaying",!1),n(this,"_internalUpdateRoutine"),n(this,"_isPaused",!1),n(this,"_isStopping",!1),n(this,"_time",0),n(this,"_duration",0),n(this,"_weight",1),n(this,"_animationTracks",[]),n(this,"_audioTracks",[]),n(this,"_signalTracks",[]),n(this,"_controlTracks",[]),n(this,"_customTracks",[]),n(this,"_allTracks",[this._animationTracks,this._audioTracks,this._signalTracks,this._controlTracks,this._customTracks]),n(this,"animationCallbackReceivers",[])}static registerCreateTrack(t,A){this.createTrackFunctions[t]=A}get isPlaying(){return this._isPlaying}get isPaused(){return this._isPaused}get time(){return this._time}set time(t){typeof t=="number"&&!Number.isNaN(t)?this._time=t:(HE||$I())&&console.error("INVALID TIMELINE.TIME VALUE",t,this.name)}get duration(){return this._duration}set duration(t){this._duration=t}get weight(){return this._weight}set weight(t){this._weight=t}get speed(){return this._speed}set speed(t){this._speed=t}awake(){var t,A,e;HE&&console.log(this,(t=this.playableAsset)==null?void 0:t.tracks),this.rebuildGraph(),this.isValid()||console.warn("PlayableDirector is not valid",this.playableAsset,(A=this.playableAsset)==null?void 0:A.tracks,Array.isArray((e=this.playableAsset)==null?void 0:e.tracks),this)}onEnable(){var t,A,e;for(const i of this._audioTracks)(t=i.onEnable)==null||t.call(i);for(const i of this._customTracks)(A=i.onEnable)==null||A.call(i);for(const i of this._animationTracks)(e=i.onEnable)==null||e.call(i);this.playOnAwake&&this.play(),this._visibilityChangeEvt||(this._visibilityChangeEvt=()=>{switch(document.visibilityState){case"hidden":this.setAudioTracksAllowPlaying(!1);break;case"visible":this.setAudioTracksAllowPlaying(!0);break}}),window.addEventListener("visibilitychange",this._visibilityChangeEvt)}onDisable(){var t,A,e;this.stop();for(const i of this._audioTracks)(t=i.onDisable)==null||t.call(i);for(const i of this._customTracks)(A=i.onDisable)==null||A.call(i);for(const i of this._animationTracks)(e=i.onDisable)==null||e.call(i);this._visibilityChangeEvt&&window.removeEventListener("visibilitychange",this._visibilityChangeEvt)}onDestroy(){var t;for(const A of this._allTracks)for(const e of A)(t=e.onDestroy)==null||t.call(e)}rebuildGraph(){this.isValid()&&(this.resolveBindings(),this.updateTimelineDuration(),this.setupAndCreateTrackHandlers())}async play(){if(!this.isValid())return;const t=this._isPaused==!0;if(this._isPaused=!1,!this._isPlaying){if(this._isPlaying=!0,t&&this.invokePauseChangedMethodsOnTracks(),this.waitForAudio){const A=[];for(const e of this._audioTracks){const i=e.loadAudio(this._time,1,0);i&&A.push(i)}if(A.length>0&&(await Promise.all(A),!this._isPlaying))return;for(;this._audioTracks.length>0&&this._isPlaying&&!ai.userInteractionRegistered&&this.waitForAudio;)await ws(200)}this.invokeStateChangedMethodsOnTracks(),this._internalUpdateRoutine=this.startCoroutine(this.internalUpdate(),Ot.LateUpdate)}}pause(){this.isValid()&&(this._isPlaying=!1,!this._isPaused&&(this._isPaused=!0,this.internalEvaluate(),this.invokePauseChangedMethodsOnTracks(),this.invokeStateChangedMethodsOnTracks()))}stop(){this._isStopping=!0;for(const e of this._audioTracks)e.stop();const t=this._isPaused==!0,A=this._isPlaying;this._isPlaying&&(this._time=0,this._isPlaying=!1,this._isPaused=!1,this.internalEvaluate(),t&&this.invokePauseChangedMethodsOnTracks()),this._isPlaying=!1,this._isPaused=!1,t&&!A&&this.invokePauseChangedMethodsOnTracks(),A&&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 t of this._allTracks)for(const A of t)yield A}get audioTracks(){return this._audioTracks}resolveGuids(t){this._guidsMap=t}invokePauseChangedMethodsOnTracks(){var t;for(const A of this.forEachTrack())(t=A.onPauseChanged)==null||t.call(A)}invokeStateChangedMethodsOnTracks(){var t;for(const A of this.forEachTrack())(t=A.onStateChanged)==null||t.call(A,this._isPlaying)}*internalUpdate(){for(;this._isPlaying&&this.activeAndEnabled;)!this._isPaused&&this._isPlaying&&(this._time+=this.context.time.deltaTime*this.speed,this.internalEvaluate()),yield}internalEvaluate(t=!1){if(!this.isValid())return;let A=this._time;switch(this.extrapolationMode){case 0:this._speed>0?A=Math.min(A,this._duration):this._speed<0&&(A=Math.max(A,0)),this._time=A;break;case 1:A%=this._duration,this._time=A;break;case 2:if(A>this._duration){this.stop();return}break}const e=this._time;for(const i of this.playableAsset.tracks)if(!i.muted)switch(i.type){case Eo.Activation:if(!t&&!this._isPlaying)continue;for(let g=0;g<i.outputs.length;g++){const I=i.outputs[g];if(typeof I=="object"){let o=!1;if(i.clips)for(const C of i.clips)C.start<=e&&e<=C.end&&(o=!0);const s=I;s.visible!==void 0&&s.visible!==o&&(s.visible=o,HE&&console.warn(this.name,"set ActivationTrack-"+g,s.name,o,e))}}break}if(!this._isStopping)for(const i of this._animationTracks)i.evaluate(e);for(const i of this._audioTracks)i.evaluate(e);for(const i of this._signalTracks)i.evaluate(e);for(const i of this._controlTracks)i.evaluate(e);for(const i of this._customTracks)i.evaluate(e)}resolveBindings(){if(this._clonedPlayableAsset||(this._clonedPlayableAsset=!0,this.playableAsset=Lc(this.playableAsset)),!this.playableAsset||!this.playableAsset.tracks)return;const t=this.findRoot(this.gameObject);for(const A of this.playableAsset.tracks){for(let e=A.outputs.length-1;e>=0;e--){let i=A.outputs[e];if(typeof i=="string"){this._guidsMap&&this._guidsMap[i]&&(i=this._guidsMap[i]);const g=CA.findByGuid(i,t);g===null||typeof g!="object"?(A.outputs.splice(e,1),console.warn("Failed to resolve binding",i,A.name,A.type)):(HE&&console.log("Resolved binding",i,"to",g),A.outputs[e]=g)}else if(i===null){if(A.outputs.splice(e,1),uR.createTrackFunctions[A.type])continue;A.type!==Eo.Audio&&A.type!==Eo.Control&&A.type!==Eo.Marker&&A.type!==Eo.Signal&&console.warn("Missing binding",i,A.name,A.type,this.name,this.playableAsset.name)}}if(A.type===Eo.Control&&A.clips)for(let e=0;e<A.clips.length;e++){const i=A.clips[e];let g=i.asset.sourceObject;if(typeof g=="string"){this._guidsMap&&this._guidsMap[g]&&(g=this._guidsMap[g]);const I=CA.findByGuid(g,t);I===null||typeof I!="object"?console.warn("Failed to resolve sourceObject binding",g,A.name,i):(HE&&console.log("Resolved binding",g,"to",I),i.asset.sourceObject=I)}}}}findRoot(t){return t.parent?this.findRoot(t.parent):t}updateTimelineDuration(){if(this._duration=0,!(!this.playableAsset||!this.playableAsset.tracks)){for(const t of this.playableAsset.tracks)if(t.muted!==!0){if(t.clips)for(const A of t.clips)A.end>this._duration&&(this._duration=A.end);if(t.markers)for(const A of t.markers)A.time>this._duration&&(this._duration=A.time+.001)}}}setupAndCreateTrackHandlers(){var t,A,e;if(this._animationTracks.length=0,this._audioTracks.length=0,this._signalTracks.length=0,!this.playableAsset)return;let i=CA.findObjectOfType(xn,this.context);for(const g of this.playableAsset.tracks){const I=g.type,o=uR.createTrackFunctions[I];if(o!=null){const s=o(this,g);if(typeof s.evaluate=="function"){s.director=this,s.track=g,this._customTracks.push(s);continue}}if(g.type===Eo.Animation){if(!g.clips||g.clips.length<=0){HE&&console.warn("Animation track has no clips",g);continue}for(let s=g.outputs.length-1;s>=0;s--){let C=g.outputs[s];if(C instanceof uA){const r=CA.getOrAddComponent(C,qg);r&&(C=r)}const a=(t=C?.gameObject)==null?void 0:t.animations;if(a){const r=new Ly;r.trackOffset=g.trackOffset,r.director=this,r.track=g;for(let B=0;B<g.clips.length;B++){const Q=g.clips[B],E=Q.asset;if(!E){console.error(`Timeline ${this.name}: clip #${B} on track "${g.name}" has no animation data`);continue}const h=E.clip;let d=h;if((typeof d=="string"||typeof d=="number")&&(d=a.find(c=>c.name===h)),!d){console.warn("Could not find animationClip for model",Q,g.name,this.name,(A=this.playableAsset)==null?void 0:A.name);continue}C instanceof qg&&C.runtimeAnimatorController&&(C.__internalDidAwakeAndStart||C.initializeRuntimeAnimatorController(),C.runtimeAnimatorController.mixer||C.runtimeAnimatorController.bind(C),r.mixer=C.runtimeAnimatorController.mixer),r.mixer||(r.mixer=new ND(C.gameObject)),r.clips.push(d),r.mixer.uncacheAction(d),r.createHooks(Q.asset,d);const l=r.mixer.clipAction(d);r.actions.push(l),r.models.push(Q)}this._animationTracks.push(r)}}}else if(g.type===Eo.Audio){if(!g.clips||g.clips.length<=0)continue;const s=new ad;s.director=this,s.track=g,s.audioSource=g.outputs.find(C=>C instanceof ai),this._audioTracks.push(s),i||(i=(e=this.context.mainCameraComponent)==null?void 0:e.gameObject.addNewComponent(xn)),s.listener=i.listener;for(let C=0;C<g.clips.length;C++){const a=g.clips[C];s.addModel(a)}}else if(g.type===Eo.Marker){const s=new nd;if(s.director=this,s.track=g,g.markers)for(const C of g.markers)switch(C.type){case pR.Signal:s.models.push(C),s.didTrigger.push(!1);break}if(s!==null&&s.models.length>0){const C=CA.getComponent(this.gameObject,_E);C&&(s.receivers.push(C),this._signalTracks.push(s))}}else if(g.type===Eo.Signal){const s=new nd;if(s.director=this,s.track=g,g.markers)for(const C of g.markers)s.models.push(C),s.didTrigger.push(!1);for(const C of g.outputs)s.receivers.push(C);this._signalTracks.push(s)}else if(g.type===Eo.Control){const s=new Yy;if(s.director=this,s.track=g,g.clips)for(const C of g.clips)s.models.push(C);s.resolveSourceObjects(this.context),this._controlTracks.push(s)}}}setAudioTracksAllowPlaying(t){for(const A of this._audioTracks)A.onAllowAudioChanged(t)}registerAnimationCallback(t){this.animationCallbackReceivers.push(t)}unregisterAnimationCallback(t){const A=this.animationCallbackReceivers.indexOf(t);A!==-1&&this.animationCallbackReceivers.splice(A,1)}};let SB=uR;n(SB,"createTrackFunctions",{});const _y=Symbol("objectIsAnimatedData");function t2(t,A,e){if(!t)return;if(t[_y]===void 0){if(!e)return;t[_y]=new Set}const i=t[_y];e?i.add(A):i.has(A)&&i.delete(A)}function NgA(t){if(!t)return!1;const A=t[_y];return A!==void 0&&A.size>0}et.registerCallback(si.ContextCreated,t=>{const A=t.context.domElement.getAttribute("autoplay");if(A!==void 0&&(A===""||A==="true")&&t.files)for(const e of t.files)CA.foreachComponent(e.file.scene,i=>{if(i.enabled!==!1){if(i instanceof UI&&i.playAutomatically||i instanceof qg||i instanceof SB&&i.playOnAwake===!0)return!0;if(i instanceof UI)return i.playAutomatically=!0,!0;if(i instanceof SB)return i.playOnAwake=!0,!0}},!0)!==!0&&FgA(e.file)});function FgA(t){if(!t||!t.animations)return;for(let e=0;e<t.animations.length;e++){const i=t.animations[e];if(!(!i.tracks||i.tracks.length<=0))for(const g in i.tracks){const I=i.tracks[g],o=I.__objectName??I.name.substring(0,I.name.indexOf("."));let s=t.scene.getObjectByName(o);if(!s&&(s=t.scene.getObjectByProperty("uuid",o),!s))continue;let C=A(s);C||(C=Nn(t.scene,new UI));const a=C.animations=C.animations||[];i.name_animator=C.name,a.indexOf(i)<0&&a.push(i)}}function A(e){var i;if(!e)return;const g=(i=e.userData)==null?void 0:i.components;if(g&&g.length>0)for(let I=0;I<g.length;I++){const o=g[I];if(o instanceof qg||o instanceof UI)return e}return A(e.parent)}}class KgA{constructor(){n(this,"_context")}get context(){return this._context??be.Current}get isStateMachineBehaviour(){return!0}}class rd{constructor(A,e,i,g){n(this,"name"),n(this,"nameHash"),n(this,"normalizedTime"),n(this,"length"),n(this,"speed"),n(this,"action"),n(this,"hasTransitions");var I;this.name=A.name,this.nameHash=A.hash,this.normalizedTime=e,this.length=i,this.speed=g,this.action=A.motion.action||null,this.hasTransitions=((I=A.transitions)==null?void 0:I.length)>0||!1}}function i2(t,A){return{name:"",isLooping:!1,guid:A?.generateUUID()??zi.generateUUID(),index:-1,clip:new wI(t,1,[])}}var Ln=(t=>(t[t.If=1]="If",t[t.IfNot=2]="IfNot",t[t.Greater=3]="Greater",t[t.Less=4]="Less",t[t.Equals=6]="Equals",t[t.NotEqual=7]="NotEqual",t))(Ln||{}),DR=(t=>(t[t.Float=1]="Float",t[t.Int=3]="Int",t[t.Bool=4]="Bool",t[t.Trigger=9]="Trigger",t))(DR||{});const RI=tA("debuganimatorcontroller"),Hy=tA("debugrootmotion");class No{constructor(A){n(this,"_speed",1),n(this,"normalizedStartOffset",0),n(this,"animator"),n(this,"model"),n(this,"_mixer"),n(this,"_activeState"),n(this,"_activeStates",[]),n(this,"rootMotionHandler"),this.model=A,RI&&console.log(this)}static createFromClips(A,e={looping:!1,autoTransition:!0,transitionDuration:0}){const i=[];for(let I=0;I<A.length;I++){const o=A[I],s=[];if(e.autoTransition!==!1){const a=e.transitionDuration??0,r=a/o.duration;let B=I;(e.autoTransition===void 0||e.autoTransition===!0)&&(B=(I+1)%A.length),s.push({exitTime:1-r,offset:0,duration:a,hasExitTime:!0,destinationState:B,conditions:[]})}const C={name:o.name,hash:I,motion:{name:o.name,clip:o,isLooping:e?.looping??!1},transitions:s,behaviours:[]};i.push(C)}const g={name:"AnimatorController",guid:new ug(Date.now()).generateUUID(),parameters:[],layers:[{name:"Base Layer",stateMachine:{defaultState:0,states:i}}]};return new No(g)}play(A,e=-1,i=Number.NEGATIVE_INFINITY,g=0){if(e<0)e=0;else if(e>=this.model.layers.length){console.warn("invalid layer");return}const I=this.model.layers[e].stateMachine;for(const o of I.states)if(o.name===A||o.hash===A){RI&&console.log("transition to ",o),this.transitionTo(o,g,i);return}console.warn("Could not find "+A+" to play")}reset(){this.setStartTransition()}setBool(A,e){var i,g;const I=typeof A=="string"?"name":"hash";return(g=(i=this.model)==null?void 0:i.parameters)==null?void 0:g.filter(o=>o[I]===A).forEach(o=>o.value=e)}getBool(A){var e,i,g;const I=typeof A=="string"?"name":"hash";return((g=(i=(e=this.model)==null?void 0:e.parameters)==null?void 0:i.find(o=>o[I]===A))==null?void 0:g.value)??!1}setFloat(A,e){var i,g;const I=typeof A=="string"?"name":"hash",o=(g=(i=this.model)==null?void 0:i.parameters)==null?void 0:g.filter(s=>s[I]===A);return o.forEach(s=>s.value=e),o?.length>0}getFloat(A){var e,i,g;const I=typeof A=="string"?"name":"hash";return((g=(i=(e=this.model)==null?void 0:e.parameters)==null?void 0:i.find(o=>o[I]===A))==null?void 0:g.value)??0}setInteger(A,e){var i,g;const I=typeof A=="string"?"name":"hash";return(g=(i=this.model)==null?void 0:i.parameters)==null?void 0:g.filter(o=>o[I]===A).forEach(o=>o.value=e)}getInteger(A){var e,i,g;const I=typeof A=="string"?"name":"hash";return((g=(i=(e=this.model)==null?void 0:e.parameters)==null?void 0:i.find(o=>o[I]===A))==null?void 0:g.value)??0}setTrigger(A){var e,i;RI&&console.log("SET TRIGGER",A);const g=typeof A=="string"?"name":"hash";return(i=(e=this.model)==null?void 0:e.parameters)==null?void 0:i.filter(I=>I[g]===A).forEach(I=>I.value=!0)}resetTrigger(A){var e,i;const g=typeof A=="string"?"name":"hash";return(i=(e=this.model)==null?void 0:e.parameters)==null?void 0:i.filter(I=>I[g]===A).forEach(I=>I.value=!1)}getTrigger(A){var e,i,g;const I=typeof A=="string"?"name":"hash";return((g=(i=(e=this.model)==null?void 0:e.parameters)==null?void 0:i.find(o=>o[I]===A))==null?void 0:g.value)??!1}isInTransition(){return this._activeStates.length>1}setSpeed(A){this._speed=A}FindState(A){return this.findState(A)}findState(A){if(!A)return null;if(Array.isArray(this.model.layers)){for(const e of this.model.layers)for(const i of e.stateMachine.states)if(i.name===A||i.hash==A)return i}return null}getCurrentStateInfo(){if(!this._activeState)return null;const A=this._activeState.motion.action;if(!A)return null;const e=this._activeState.motion.clip.duration,i=e<=0?0:Math.abs(A.time/e);return new rd(this._activeState,i,e,this._speed)}get currentAction(){return this._activeState&&this._activeState.motion.action||null}get context(){var A;return(A=this.animator)==null?void 0:A.context}get mixer(){return this._mixer}bind(A){A?this.animator!==A&&(this.animator=A,this._mixer=new ND(this.animator.gameObject),this.createActions(this.animator)):console.error("AnimatorController.bind: animator is null")}clone(){if(typeof this.model=="string")return console.warn("AnimatorController has not been resolved, can not create model from string",this.model),null;RI&&console.warn("AnimatorController clone()",this.model);const A=Lc(this.model,(e,i,g)=>g==null?!0:!(g.type==="Object3D"||g.isObject3D===!0||vx(g)||g.tracks!==void 0||g instanceof No));return console.assert(A!==this.model),new No(A)}update(A){var e,i;if(!this.animator)return;this.evaluateTransitions(),this.updateActiveStates(A);const g=this.animator.context.time.deltaTime;this.animator.applyRootMotion&&((e=this.rootMotionHandler)==null||e.onBeforeUpdate(A)),this._mixer.update(g),this.animator.applyRootMotion&&((i=this.rootMotionHandler)==null||i.onAfterUpdate(A))}get activeState(){return this._activeState}updateActiveStates(A){for(let e=0;e<this._activeStates.length;e++){const i=this._activeStates[e],g=i.motion;if(!g.action)this._activeStates.splice(e,1),e--;else{const I=g.action;I.weight=A,I.getEffectiveWeight()<=0&&!I.isRunning()&&(RI&&console.debug("REMOVE",i.name,I.getEffectiveWeight(),I.isRunning(),I.isScheduled()),this._activeStates.splice(e,1),e--)}}}setStartTransition(){for(const A of this.model.layers){const e=A.stateMachine;e.defaultState===void 0&&(RI&&console.warn("AnimatorController default state is undefined, will assign state 0 as default",A),e.defaultState=0);const i=e.states[e.defaultState];this.transitionTo(i,0,this.normalizedStartOffset)}}evaluateTransitions(){var A;let e=!1;if(!this._activeState){if(this.setStartTransition(),!this._activeState)return;e=!0}const i=this._activeState,g=i.motion.action;for(const o of i.transitions){if(!o.hasExitTime&&o.conditions.length<=0)continue;let s=!0;for(const C of o.conditions)if(!this.evaluateCondition(C)){s=!1;break}if(s)if(g){const C=i.motion.clip.duration,a=C<=0?1:Math.abs(g.time/C);let r=!1;if(o.hasExitTime?g.timeScale>0?r=a>=o.exitTime:g.timeScale<0&&(r=1-a>=o.exitTime):r=!0,r){for(const B of o.conditions){const Q=this.model.parameters.find(E=>E.name===B.parameter);Q?.type===DR.Trigger&&Q.value&&(Q.value=!1)}g.clampWhenFinished=!0,RI&&console.log("transition to "+o.destinationState,o,a,o.exitTime,o.hasExitTime),this.transitionTo(o.destinationState,o.duration,o.offset);return}}else{this.transitionTo(o.destinationState,o.duration,o.offset);return}}if(g){let o=i.speed??1;i.speedParameter&&(o*=this.getFloat(i.speedParameter)),o!==void 0&&(g.timeScale=o*this._speed)}let I=!1;if(i.motion.isLooping&&g&&(g.time>=g.getClip().duration?(I=!0,g.reset(),g.time=0,g.play()):g.time<=0&&g.timeScale<0&&(I=!0,g.reset(),g.time=g.getClip().duration,g.play())),!I&&i&&!e&&g&&this.animator&&i.behaviours){const o=g?.getClip().duration,s=g.time/o,C=new rd(this._activeState,s,o,this._speed);for(const a of i.behaviours)a.instance&&((A=a.instance.onStateUpdate)==null||A.call(a.instance,this.animator,C,0))}}getState(A,e){return typeof A=="number"&&(A==-1&&(A=this.model.layers[e].stateMachine.defaultState,A===void 0&&(RI&&console.warn("AnimatorController default state is undefined: ",this.model,"Layer: "+e),A=0)),A=this.model.layers[e].stateMachine.states[A]),A}transitionTo(A,e,i){var g,I,o,s,C,a,r,B;if(!this.animator)return;const Q=0;if(A=this.getState(A,Q),!(A!=null&&A.motion)||!A.motion.clip||!(A.motion.clip instanceof wI))return;const E=this._activeState===A;if(E){const c=A.motion;if(!c.action_loopback&&c.clip){const p=this.rootMotionHandler?this.animator.gameObject.matrix.clone():null;this._mixer.uncacheAction(c.clip,this.animator.gameObject),p&&p.decompose(this.animator.gameObject.position,this.animator.gameObject.quaternion,this.animator.gameObject.scale),c.action_loopback=this.createAction(c.clip)}}if((g=this._activeState)!=null&&g.behaviours&&this._activeState.motion.action){const c=(I=this._activeState)==null?void 0:I.motion.clip.duration,p=this._activeState.motion.action.time/c,u=new rd(this._activeState,p,c,this._speed);for(const D of this._activeState.behaviours)(s=(o=D.instance)==null?void 0:o.onStateExit)==null||s.call(D.instance,this.animator,u,Q)}const h=(C=this._activeState)==null?void 0:C.motion.action;h&&h.fadeOut(e),E&&(A.motion.action=A.motion.action_loopback,A.motion.action_loopback=h);const d=this._activeState;this._activeState=A;const l=(a=A.motion)==null?void 0:a.action;if(l){if(i=Math.max(0,Math.min(1,i)),A.cycleOffsetParameter){let p=this.getFloat(A.cycleOffsetParameter);typeof p=="number"?(p<0&&(p+=1),i+=p,i%=1):RI&&console.warn("AnimatorController cycle offset parameter is not a number",A.cycleOffsetParameter)}else typeof A.cycleOffset=="number"&&(i+=A.cycleOffset,i%=1);l.isRunning()&&l.stop(),l.reset(),l.enabled=!0;const c=A.motion.clip.duration;if(l.time=E?0:i*c,l.timeScale<0&&(l.time=c-l.time),l.clampWhenFinished=!0,l.setLoop(ic,0),e>0?l.fadeIn(e):l.weight=1,l.play(),this.rootMotionHandler&&this.rootMotionHandler.onStart(l),this._activeStates.includes(A)||this._activeStates.push(A),this._activeState.behaviours){const p=new rd(A,i,c,this._speed);for(const u of this._activeState.behaviours)(B=(r=u.instance)==null?void 0:r.onStateEnter)==null||B.call(u.instance,this.animator,p,Q)}}else RI&&(A.__warned_no_motion||(A.__warned_no_motion=!0,console.warn("No action",A.motion,this)));RI&&console.log("TRANSITION FROM "+d?.name+" TO "+A.name,e,h,l,l?.getEffectiveTimeScale(),l?.getEffectiveWeight(),l?.isRunning(),l?.isScheduled(),l?.paused)}createAction(A){var e,i;if(this._mixer.existingAction(A)&&this._mixer.uncacheAction(A,(e=this.animator)==null?void 0:e.gameObject),(i=this.animator)!=null&&i.applyRootMotion){this.rootMotionHandler||(this.rootMotionHandler=new JgA(this));const g=this.animator.gameObject;return this.rootMotionHandler.createClip(this._mixer,g,A)}else return this._mixer.clipAction(A)}evaluateCondition(A){const e=this.model.parameters.find(i=>i.name===A.parameter);if(!e)return!1;switch(A.mode){case Ln.If:return e.value===!0;case Ln.IfNot:return e.value===!1;case Ln.Greater:return e.value>A.threshold;case Ln.Less:return e.value<A.threshold;case Ln.Equals:return e.value===A.threshold;case Ln.NotEqual:return e.value!==A.threshold}return!1}createActions(A){var e,i,g,I;RI&&console.log("AnimatorController createActions",this.model);for(const o of this.model.layers){const s=o.stateMachine;for(let C=0;C<s.states.length;C++){const a=s.states[C];a.transitions||(a.transitions=[]);for(const r of a.transitions)r.conditions||(r.conditions=[]);if(a.motion||(a.motion=i2(a.name)),this.animator&&a.motion.clips){const r=(e=a.motion.clips)==null?void 0:e.find(B=>{var Q,E;return B.node.name===((E=(Q=this.animator)==null?void 0:Q.gameObject)==null?void 0:E.name)});r?a.motion.clip=r.clip:(RI||re())&&console.warn('Could not find clip for animator "'+((g=(i=this.animator)==null?void 0:i.gameObject)==null?void 0:g.name)+'"',a.motion.clips.map(B=>B.node.name))}if(!a.motion.clip){const r=new wI(void 0,void 0,[]);a.motion.clip=r}if((I=a.motion)!=null&&I.clip){const r=a.motion.clip;if(r instanceof wI){const B=this.createAction(r);a.motion.action=B}else(RI||re())&&console.warn("No valid animationclip assigned",a)}if(a.behaviours&&Array.isArray(a.behaviours))for(const r of a.behaviours){if(!(r!=null&&r.typeName))continue;const B=W.get(r.typeName),Q=new B;Q.isStateMachineBehaviour&&(Q._context=this.context??void 0,wE(Q,r.properties),r.instance=Q),RI&&console.log("Created animator controller behaviour",a.name,r.typeName,r.properties,Q)}}}}*enumerateActions(){if(this.model.layers)for(const A of this.model.layers){const e=A.stateMachine;for(let i=0;i<e.states.length;i++){const g=e.states[i];g!=null&&g.motion&&(g.motion.action&&(yield g.motion.action),g.motion.action_loopback&&(yield g.motion.action_loopback))}}}}class g2{constructor(A,e){n(this,"track"),n(this,"createdInterpolant"),n(this,"originalEvaluate"),n(this,"customEvaluate"),this.track=A;const i=A,g=i.createInterpolant.bind(A);i.createInterpolant=()=>(i.createInterpolant=g,this.createdInterpolant=g(),this.originalEvaluate=this.createdInterpolant.evaluate.bind(this.createdInterpolant),this.customEvaluate=I=>{if(!this.originalEvaluate)return;const o=this.originalEvaluate(I);return e(I,o)},this.createdInterpolant.evaluate=this.customEvaluate,this.createdInterpolant)}dispose(){this.createdInterpolant&&this.originalEvaluate&&(this.createdInterpolant.evaluate=this.originalEvaluate),this.track=void 0,this.createdInterpolant=null,this.originalEvaluate=void 0,this.customEvaluate=void 0}}const hg=class{constructor(t,A,e,i,g){if(n(this,"_action"),n(this,"root"),n(this,"clip"),n(this,"positionWrapper",null),n(this,"rotationWrapper",null),n(this,"context"),n(this,"positionChange",new S),n(this,"rotationChange",new RA),n(this,"_prevTime",0),this.context=t,this.root=A,this.clip=e,hg.firstKeyframeRotation[this.cacheId]||(hg.firstKeyframeRotation[this.cacheId]=new RA),g){const I=g.values;hg.firstKeyframeRotation[this.cacheId].set(I[0],I[1],I[2],I[3])}hg.spaceRotation[this.cacheId]||(hg.spaceRotation[this.cacheId]=new RA),hg.effectiveSpaceRotation[this.cacheId]||(hg.effectiveSpaceRotation[this.cacheId]=new RA),hg.clipOffsetRotation[this.cacheId]=new RA,g&&hg.clipOffsetRotation[this.cacheId].set(g.values[0],g.values[1],g.values[2],g.values[3]).invert(),this.handlePosition(e,i),this.handleRotation(e,g)}set action(t){this._action=t}get action(){return this._action}get cacheId(){return this.root.uuid}onStart(t){if(t.getClip()!==this.clip)return;hg.lastObjRotation[this.cacheId]||(hg.lastObjRotation[this.cacheId]=this.root.quaternion.clone());const A=hg.lastObjRotation[this.cacheId];if(hg.spaceRotation[this.cacheId].copy(A),Hy){const e=new jt().setFromQuaternion(A);console.log("START",this.clip.name,Ae.toDegrees(e.y),this.root.position.z)}}getClipRotationOffset(){return hg.clipOffsetRotation[this.cacheId]}handlePosition(t,A){if(A){const e=this.root;Hy&&e.add(new qo),hg.lastObjPosition[this.cacheId]||(hg.lastObjPosition[this.cacheId]=this.root.position.clone());const i=new S,g=new S;this.positionWrapper=new g2(A,(I,o)=>{const s=this.action.getEffectiveWeight();return Hy&&e.position.length()>8&&e.position.set(0,e.position.y,0),I>this._prevTime&&(i.set(o[0],o[1],o[2]),i.sub(g),i.multiplyScalar(s),i.applyQuaternion(this.getClipRotationOffset()),i.applyQuaternion(e.quaternion),this.positionChange.copy(i)),g.fromArray(o),this._prevTime=I,o[0]=0,o[1]=0,o[2]=0,o})}}handleRotation(t,A){if(A){if(Hy){const I=A.values,o=new jt().setFromQuaternion(new RA(I[0],I[1],I[2],I[3]));console.log(t.name,A.name,"FIRST ROTATION IN TRACK",Ae.toDegrees(o.y));const s=A.values.length-4,C=new RA().set(I[s],I[s+1],I[s+2],I[s+3]),a=new jt().setFromQuaternion(C);console.log(t.name,A.name,"LAST ROTATION IN TRACK",Ae.toDegrees(a.y))}let e=0;const i=new RA,g=new RA;this.rotationWrapper=new g2(A,(I,o)=>(I>e&&(g.set(o[0],o[1],o[2],o[3]),i.invert(),g.multiply(i),this.rotationChange.copy(g)),i.fromArray(o),e=I,o[0]=0,o[1]=0,o[2]=0,o[3]=1,o))}}onBeforeUpdate(t){this.positionChange.set(0,0,0),this.rotationChange.set(0,0,0,1)}onAfterUpdate(t){return!this.action||(t*=this.action.getEffectiveWeight(),t<=0)?!1:(this.positionChange.multiplyScalar(t),this.rotationChange.slerp(hg.identityQuaternion,1-t),!0)}};let Yn=hg;n(Yn,"lastObjPosition",{}),n(Yn,"lastObjRotation",{}),n(Yn,"firstKeyframeRotation",{}),n(Yn,"spaceRotation",{}),n(Yn,"effectiveSpaceRotation",{}),n(Yn,"clipOffsetRotation",{}),n(Yn,"identityQuaternion",new RA);class JgA{constructor(A){n(this,"controller"),n(this,"handler",[]),n(this,"root"),n(this,"basePosition",new S),n(this,"baseQuaternion",new RA),n(this,"baseRotation",new jt),n(this,"summedPosition",new S),n(this,"summedRotation",new RA),this.controller=A}createClip(A,e,i){this.root=e,e&&"name"in e&&e.name;const g=this.findRootTrack(i,".position"),I=this.findRootTrack(i,".quaternion"),o=new Yn(this.controller.context,e,i,g,I);this.handler.push(o);const s=A.clipAction(i);return o.action=s,s}onStart(A){for(const e of this.handler)e.onStart(A)}onBeforeUpdate(A){this.basePosition.copy(this.root.position),this.baseQuaternion.copy(this.root.quaternion);for(const e of this.handler)e.onBeforeUpdate(A)}onAfterUpdate(A){if(!(A<=0)){this.root.position.copy(this.basePosition),this.root.quaternion.copy(this.baseQuaternion),this.summedPosition.set(0,0,0),this.summedRotation.set(0,0,0,1);for(const e of this.handler)e.onAfterUpdate(A)&&(this.summedPosition.add(e.positionChange),this.summedRotation.multiply(e.rotationChange));this.root.position.add(this.summedPosition),this.root.quaternion.multiply(this.summedRotation)}}findRootTrack(A,e){const i=A.tracks;if(!i)return null;for(const g of i)if(g.name.endsWith(e))return g;return null}}class vgA extends IC{onSerialize(A,e){}onDeserialize(A,e){if(e.type===No&&A?.__type==="AnimatorController")return new No(A)}}new vgA(No);var bgA=Object.defineProperty,qgA=Object.getOwnPropertyDescriptor,Ty=(t,A,e,i)=>{for(var g=i>1?void 0:i?qgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&bgA(A,e,g),g};const es=tA("debuganimator");class qg extends FA{constructor(){super(...arguments),n(this,"applyRootMotion",!1),n(this,"hasRootMotion",!1),n(this,"keepAnimatorControllerStateOnDisable",!1),n(this,"_parametersAreDirty",!1),n(this,"_isDirty",!1),n(this,"_speed",1),n(this,"_normalizedStartOffset",0),n(this,"_animatorController",null),n(this,"_initializeWithRuntimeAnimatorController")}set runtimeAnimatorController(A){var e;this._animatorController&&this._animatorController.model===A||(A?A instanceof No?(A.animator&&A.animator!==this&&(console.warn("AnimatorController can not be bound to multiple animators",(e=A.model)==null?void 0:e.name),A.model||console.error("AnimatorController has no model"),A=new No(A.model)),this._animatorController=A,this._animatorController.bind(this)):(es&&console.log("Assign animator controller",A,this),this._animatorController=new No(A),this.__didAwake&&this._animatorController.bind(this)):this._animatorController=null)}get runtimeAnimatorController(){return this._animatorController}getCurrentStateInfo(){var A;return(A=this.runtimeAnimatorController)==null?void 0:A.getCurrentStateInfo()}get currentAction(){var A;return((A=this.runtimeAnimatorController)==null?void 0:A.currentAction)||null}get parametersAreDirty(){return this._parametersAreDirty}get isDirty(){return this._isDirty}Play(A,e=-1,i=Number.NEGATIVE_INFINITY,g=0){this.play(A,e,i,g)}play(A,e=-1,i=Number.NEGATIVE_INFINITY,g=0){var I;(I=this.runtimeAnimatorController)==null||I.play(A,e,i,g),this._isDirty=!0}Reset(){this.reset()}reset(){var A;(A=this._animatorController)==null||A.reset(),this._isDirty=!0}SetBool(A,e){this.setBool(A,e)}setBool(A,e){var i,g;es&&console.log("setBool",A,e),((i=this.runtimeAnimatorController)==null?void 0:i.getBool(A))!==e&&(this._parametersAreDirty=!0),(g=this.runtimeAnimatorController)==null||g.setBool(A,e)}GetBool(A){return this.getBool(A)}getBool(A){var e;const i=((e=this.runtimeAnimatorController)==null?void 0:e.getBool(A))??!1;return es&&console.log("getBool",A,i),i}toggleBool(A){this.setBool(A,!this.getBool(A))}SetFloat(A,e){this.setFloat(A,e)}setFloat(A,e){var i,g;((i=this.runtimeAnimatorController)==null?void 0:i.getFloat(A))!==e&&(this._parametersAreDirty=!0),es&&console.log("setFloat",A,e),(g=this.runtimeAnimatorController)==null||g.setFloat(A,e)}GetFloat(A){return this.getFloat(A)}getFloat(A){var e;const i=((e=this.runtimeAnimatorController)==null?void 0:e.getFloat(A))??-1;return es&&console.log("getFloat",A,i),i}SetInteger(A,e){this.setInteger(A,e)}setInteger(A,e){var i,g;((i=this.runtimeAnimatorController)==null?void 0:i.getInteger(A))!==e&&(this._parametersAreDirty=!0),es&&console.log("setInteger",A,e),(g=this.runtimeAnimatorController)==null||g.setInteger(A,e)}GetInteger(A){return this.getInteger(A)}getInteger(A){var e;const i=((e=this.runtimeAnimatorController)==null?void 0:e.getInteger(A))??-1;return es&&console.log("getInteger",A,i),i}SetTrigger(A){this.setTrigger(A)}setTrigger(A){var e;this._parametersAreDirty=!0,es&&console.log("setTrigger",A),(e=this.runtimeAnimatorController)==null||e.setTrigger(A)}ResetTrigger(A){this.resetTrigger(A)}resetTrigger(A){var e;this._parametersAreDirty=!0,es&&console.log("resetTrigger",A),(e=this.runtimeAnimatorController)==null||e.resetTrigger(A)}GetTrigger(A){this.getTrigger(A)}getTrigger(A){var e;const i=(e=this.runtimeAnimatorController)==null?void 0:e.getTrigger(A);return es&&console.log("getTrigger",A,i),i}IsInTransition(){return this.isInTransition()}isInTransition(){var A;return((A=this.runtimeAnimatorController)==null?void 0:A.isInTransition())??!1}SetSpeed(A){return this.setSpeed(A)}setSpeed(A){var e;A!==this._speed&&(es&&console.log("setSpeed",A),this._speed=A,((e=this._animatorController)==null?void 0:e.animator)==this&&this._animatorController.setSpeed(A))}set minMaxSpeed(A){var e;this._speed=Ae.lerp(A.x,A.y,Math.random()),((e=this._animatorController)==null?void 0:e.animator)==this&&this._animatorController.setSpeed(this._speed)}set minMaxOffsetNormalized(A){var e;this._normalizedStartOffset=Ae.lerp(A.x,A.y,Math.random()),((e=this.runtimeAnimatorController)==null?void 0:e.animator)==this&&(this.runtimeAnimatorController.normalizedStartOffset=this._normalizedStartOffset)}awake(){es&&console.log("ANIMATOR",this.name,this),this.gameObject&&this.initializeRuntimeAnimatorController()}initializeRuntimeAnimatorController(A=!1){const e=A||this.runtimeAnimatorController!==this._initializeWithRuntimeAnimatorController;if(this.runtimeAnimatorController&&e){const i=this.runtimeAnimatorController.clone();this._initializeWithRuntimeAnimatorController=i,i?(console.assert(this.runtimeAnimatorController!==i),this.runtimeAnimatorController=i,console.assert(this.runtimeAnimatorController===i),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 A;this.keepAnimatorControllerStateOnDisable||(A=this._animatorController)==null||A.reset()}onBeforeRender(){this._isDirty=!1,this._parametersAreDirty=!1,!NgA(this.gameObject)&&this._animatorController&&this._animatorController.update(1)}}Ty([w()],qg.prototype,"applyRootMotion",2),Ty([w()],qg.prototype,"hasRootMotion",2),Ty([w()],qg.prototype,"keepAnimatorControllerStateOnDisable",2),Ty([w()],qg.prototype,"runtimeAnimatorController",1);const EC=tA("debugusdzanimation"),wR=tA("debugusdzanimationserialization");class Oy{constructor(A,e,i){n(this,"_start"),n(this,"ext"),n(this,"root"),n(this,"clip"),this.ext=A,this.root=e,this.clip=i}get start(){return this._start===void 0&&(this._start=this.ext.getStartTime01(this.root,this.clip)),this._start}get duration(){var A;return((A=this.clip)==null?void 0:A.duration)??cg.restPoseClipDuration}}const I2=class{constructor(t,A,e){n(this,"clip"),n(this,"pos"),n(this,"rot"),n(this,"scale"),n(this,"root"),n(this,"target"),n(this,"duration",0),n(this,"useRootMotion",!1),this.root=t,this.target=A,this.clip=e,e?this.duration=e.duration:this.duration=I2.restPoseClipDuration;const i=CA.getComponent(t,qg);i&&(this.useRootMotion=i.applyRootMotion)}get frameRate(){return 60}addTrack(t){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}t.name.endsWith("position")&&(this.pos=t),t.name.endsWith("quaternion")&&(this.rot=t),t.name.endsWith("scale")&&(this.scale=t)}getFrames(){var t,A,e,i,g,I;return this.clip?Math.max(((A=(t=this.pos)==null?void 0:t.times)==null?void 0:A.length)??0,((i=(e=this.rot)==null?void 0:e.times)==null?void 0:i.length)??0,((I=(g=this.scale)==null?void 0:g.times)==null?void 0:I.length)??0):2}getDuration(){return this.duration}getSortedTimesArray(t=!0,A=!0,e=!0){var i,g,I;if(!this.clip)return[0,this.duration];const o=(i=this.pos)==null?void 0:i.times,s=(g=this.rot)==null?void 0:g.times,C=(I=this.scale)==null?void 0:I.times,a=[];if(t&&o)for(const r of o)a.push(r);if(A&&s)for(const r of s)a.push(r);if(e&&C)for(const r of C)a.push(r);return a.includes(0)||a.push(0),a.sort((r,B)=>r-B),[...new Set(a)]}*getValues(t,A=!0,e=!0,i=!0){var g,I,o;const s=new S,C=new RA,a=new S(1,1,1),r=this.target,B=A?(g=this.pos)==null?void 0:g.createInterpolant():void 0,Q=e?(I=this.rot)==null?void 0:I.createInterpolant():void 0,E=i?(o=this.scale)==null?void 0:o.createInterpolant():void 0;B||s.set(r.position.x,r.position.y,r.position.z),Q||C.set(r.quaternion.x,r.quaternion.y,r.quaternion.z,r.quaternion.w),E||a.set(r.scale.x,r.scale.y,r.scale.z);for(let h=0;h<t.length;h++){const d=t[h];if(B){const l=B.evaluate(d);s.set(l[0],l[1],l[2])}if(Q){const l=Q.evaluate(d);C.set(l[0],l[1],l[2],l[3])}if(E){const l=E.evaluate(d);a.set(l[0],l[1],l[2])}if(this.useRootMotion&&r===this.root){const l=new MA;l.compose(s,C,a),l.multiply(r.matrix),l.decompose(s,C,a)}yield{time:d,translation:s,rotation:C,scale:a,index:h}}}};let cg=I2;n(cg,"animationDurationPadding",1/60),n(cg,"restPoseClipDuration",1/60);class Bd{constructor(A){n(this,"dict",new Map),n(this,"rootTargetMap",new Map),n(this,"rootAndClipToRegisteredAnimationMap",new Map),n(this,"rootToRegisteredClip",new Map),n(this,"serializers",[]),n(this,"injectRestPoses",!1),n(this,"injectImplicitBehaviours",!1),this.injectRestPoses=A,this.injectImplicitBehaviours=A}get extensionName(){return"animation"}getStartTimeCode(){return!this.injectRestPoses||this.rootAndClipToRegisteredAnimationMap.size===0?0:(cg.restPoseClipDuration+cg.animationDurationPadding)*60}getEndTimeCode(){let A=0;for(const[e,i]of this.rootAndClipToRegisteredAnimationMap){const g=i.start+i.duration;g>A&&(A=g)}return A*60}getClipCount(A){var e;let i=((e=this.rootToRegisteredClip.get(A))==null?void 0:e.length)??0;return this.injectRestPoses&&(i=i?i-1:0),i??0}getStartTime01(A,e){if(!e)return 0;const i=this.rootTargetMap.get(A);if(!i)return 0;const g=this.dict.get(i[0]);if(!g)return console.error("Trying to get start time for root that has no animation data",A,e,...this.dict),0;let I=0;for(let o=0;o<g.length&&g[o].clip!==e;o++)I+=g[o].getDuration()+cg.animationDurationPadding;return I}registerAnimation(A,e){var i;if(!A)return null;this.rootTargetMap.has(A)||this.rootTargetMap.set(A,[]);const g=A.uuid+(e?.uuid??"-rest");if(this.rootAndClipToRegisteredAnimationMap.has(g))return this.rootAndClipToRegisteredAnimationMap.get(g);EC&&console.log("registerAnimation",A,e);const I=this.injectRestPoses?1:0,o=(((i=this.rootToRegisteredClip.get(A))==null?void 0:i.length)??0)+I,s=this.rootTargetMap.get(A),C=new Set(s);if(e&&e.tracks)for(const r of e.tracks){const B=Oe.parseTrackName(r.name),Q=Oe.findNode(A,B.nodeName);if(!Q){console.warn("no object found for track",r.name,"using "+A.name+" instead");continue}this.dict.has(Q)||this.dict.set(Q,[]);const E=this.dict.get(Q);if(!E){console.warn("no transform data found for target ",Q,"at slot "+o+", this is likely a bug");continue}C.delete(Q),this.injectRestPoses&&!E[0]&&(E[0]=new cg(null,Q,null));let h=E[o];h||(h=new cg(A,Q,e),E[o]=h),h.addTrack(r),s!=null&&s.includes(Q)||s==null||s.push(Q)}EC&&console.log("Unregistered nodes for this clip",C,"clip",e,"at slot",o,"for root",A,"targets",s);for(const r of C){const B=this.dict.get(r);if(!B)continue;if(this.injectRestPoses&&!B[0]){console.warn("Adding rest pose for ",r,e,"at slot",o,"This is likely a bug, should have been added earlier.");const E=new cg(null,r,null);B[0]=E}let Q=B[o];Q||(EC&&console.log("Adding padding clip for ",r,e,"at slot",o),Q=new cg(A,r,e),B[o]=Q)}const a=new Oy(this,A,e);if(this.rootAndClipToRegisteredAnimationMap.set(g,a),EC&&console.log({root:A,clip:e,info:a}),e){const r=this.rootToRegisteredClip.get(A);r?r.push(e):this.rootToRegisteredClip.set(A,[e])}return a}onAfterHierarchy(A){EC&&console.log("Animation clips per animation target node",this.dict)}onAfterBuildDocument(A){var e,i;EC&&console.log("Animation data",{dict:this.dict,rootTargetMap:this.rootTargetMap,rootToRegisteredClip:this.rootToRegisteredClip});for(const g of this.rootTargetMap.keys()){const I=this.rootTargetMap.get(g);if(!I)continue;let o;const s=[];for(const C of I){const a=this.dict.get(C);if(!a){console.error("No data found for target on USDZ export \u2013 please report a bug!",C);continue}o===void 0&&(o=a?.length),o!==a?.length&&console.error("Different array lengths for targets \u2013 please report a bug!",a);for(let r=0;r<a.length;r++){let B=a[r];if(!B){const Q=r-(this.injectRestPoses?1:0);a[r]=new cg(null,C,this.rootToRegisteredClip.get(g)[Q]),B=a[r]}if(!s[r])s[r]=B.getDuration();else if(s[r]!==B.getDuration()){console.error("Different durations for targets \u2013 please report a bug!",a);continue}}}}for(const g of this.serializers){const I=(e=g.model)==null?void 0:e.parent,o=I?.isDynamic===!0;wR&&console.log(o,(i=g.model)==null?void 0:i.parent),o&&g.registerCallback(I)}}onExportObject(A,e,i){CA.foreachComponent(A,I=>{const o=I;typeof o.createAnimation=="function"&&o.createAnimation(this,e,i)},!1);const g=new xgA(A,this.dict);this.serializers.push(g),g.registerCallback(e)}}class xgA{constructor(A,e){n(this,"object"),n(this,"dict"),n(this,"model"),n(this,"callback"),this.object=A,this.dict=e}registerCallback(A){this.model&&this.callback&&this.model.removeEventListener("serialize",this.callback),this.callback||(this.callback=this.onSerialize.bind(this)),wR&&console.log("REPARENT",A),this.model=A,this.model.addEventListener("serialize",this.callback)}skinnedMeshExport(A,e){var i;const g=this.model,I=this.dict;if(g&&g.skinnedMesh){let o=function(G){const K=[];for(const[f,N]of G){let _=`${f} : [`;const T=[];for(const v of N)T.push(`(${rg(v.x)}, ${rg(v.y)}, ${rg(v.z)})`);_=_.concat(T.join(", ")),_=_.concat("],"),K.push(_)}return K},s=function(G){const K=[];for(const[f,N]of G){let _=`${f} : [`;const T=[];for(const v of N)T.push(`(${rg(v.w)}, ${rg(v.x)}, ${rg(v.y)}, ${rg(v.z)})`);_=_.concat(T.join(", ")),_=_.concat("],"),K.push(_)}return K},C=function(G){let K,f=!0;const N=new Map;for(const[T,v]of G){K===void 0&&(K=v.length),K!==v.length&&(f=!1);let j=0;for(const b of v)j++,b||(N.has(T)||N.set(T,[]),N.get(T).push(j))}EC&&console.log("Bone count: ",G.size,"TransformData entries per bone: ",K,"Undefined bone entries: ",N),console.assert(f,"All bones should have the same number of TransformData entries",G),console.assert(N.size===0,"All TransformData entries should be set",N);const _=[];for(const[T,v]of G){const j=new Array;let b=0;for(let x=0;x<v.length;x++)j.push(b),b+=v[x].getDuration()+cg.animationDurationPadding;for(let x=0;x<v.length;x++){const Y=v[x],AA=j[x];_.length<=x&&_.push({pos:[],rot:[],scale:[],timeOffset:AA});const $=_[x];$.pos.push(...Y.getSortedTimesArray(!0,!1,!1)),$.rot.push(...Y.getSortedTimesArray(!1,!0,!1)),$.scale.push(...Y.getSortedTimesArray(!1,!1,!0))}}for(const T of _)T.pos.sort((v,j)=>v-j),T.rot.sort((v,j)=>v-j),T.scale.sort((v,j)=>v-j),T.pos=[...new Set(T.pos)],T.rot=[...new Set(T.rot)],T.scale=[...new Set(T.scale)];return _},a=function(G,K,f){const N=new Map,_=new Map,T=new Map,v=K.length;for(const j of f){const b=G.get(j);let x;b?console.assert(b.length===v,"We should have the same number of TransformData entries for each bone",b,K):x=new cg(null,j,null);for(let Y=0;Y<v;Y++){const AA=b?b[Y]:x,$=K[Y];for(const{time:aA,translation:wA}of AA.getValues($.pos,!0,!1,!1)){const KA=(aA+$.timeOffset)*60;N.has(KA)||N.set(KA,new Array),N.get(KA).push(wA.clone())}for(const{time:aA,rotation:wA}of AA.getValues($.rot,!1,!0,!1)){const KA=(aA+$.timeOffset)*60;_.has(KA)||_.set(KA,new Array),_.get(KA).push(wA.clone())}for(const{time:aA,scale:wA}of AA.getValues($.scale,!1,!1,!0)){const KA=(aA+$.timeOffset)*60;T.has(KA)||T.set(KA,new Array),T.get(KA).push(wA.clone())}}}return{position:N.size==0?void 0:N,quaternion:_.size==0?void 0:_,scale:T.size==0?void 0:T}},r=function(G){const K=[];for(const f of G)K.push(`(${rg(f.x)}, ${rg(f.y)}, ${rg(f.z)})`);return K.join(", ")},B=function(G){const K=[];for(const f of G)K.push(`(${rg(f.w)}, ${rg(f.x)}, ${rg(f.y)}, ${rg(f.z)})`);return K.join(", ")},Q=function(G){const K=new Map;if(EC){const f=new Array;for(const[N,_]of I)f.push(N.uuid+": "+_.length+" "+_.map(T=>{var v;return(v=T.clip)==null?void 0:v.uuid.substring(0,6)}).join(" "));console.log(`getPerBoneTransformData
|
|
5507
5507
|
`+f.join(`
|
|
5508
|
-
`))}for(const f of G){const N=I.get(f);N&&K.set(f,N)}return K},E=function(G){const K=Q(G),f=C(K);return a(K,f,G)};const h=g.skinnedMesh.skeleton,d=new Array;for(const G in h.bones){const K=h.bones[G],f=h.boneInverses[G];d.push({bone:K,inverse:f})}for(const G of KL(h.bones))d.push({bone:G,inverse:G.matrixWorld.clone().invert()});const l=d[0].bone.parent;l||console.error("No bone parent found for skinned mesh during USDZ export",g.skinnedMesh),d.sort((G,K)=>hE(G.bone,l)>hE(K.bone,l)?1:-1);const c=[],p=[],u=[],D=[];for(const{bone:G}of d)c.push(G.matrix.clone()),p.push(G.position),u.push(G.quaternion),D.push(G.scale);const k=d.map(G=>'"'+hE(G.bone,l)+'"').join(", "),U=d.map(G=>cE(G.inverse.clone().invert())).join(", ");A.beginBlock('def Skeleton "Rig"'),A.appendLine(`uniform matrix4d[] bindTransforms = [${U}]`),A.appendLine(`uniform token[] joints = [${k}]`),A.appendLine('uniform token purpose = "guide"'),A.appendLine(`uniform matrix4d[] restTransforms = [${c.map(G=>cE(G)).join(", ")}]`),A.appendLine(`matrix4d xformOp:transform = ${cE(new MA)}`),A.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const M=E(d.map(G=>G.bone));if(EC){let G=1e7,K=0;for(const f of((i=M.position)==null?void 0:i.keys())??[])G=Math.min(G,f),K=Math.max(K,f);console.log("Time samples",G,K,M)}if(A.beginBlock('def SkelAnimation "_anim"'),A.appendLine(`uniform token[] joints = [${k}]`),A.appendLine(`quatf[] rotations = [${B(u)}]`),M&&M.quaternion){A.beginBlock("quatf[] rotations.timeSamples = {","");const G=s(M.quaternion);for(const K of G)A.appendLine(K);A.closeBlock()}if(A.appendLine(`half3[] scales = [${r(D)}]`),M&&M.scale){A.beginBlock("half3[] scales.timeSamples = {","");const G=o(M.scale);for(const K of G)A.appendLine(K);A.closeBlock()}if(A.appendLine(`float3[] translations = [${r(p)}]`),M&&M.position){A.beginBlock("float3[] translations.timeSamples = {","");const G=o(M.position);for(const K of G)A.appendLine(K);A.closeBlock()}A.closeBlock(),A.closeBlock()}}onSerialize(A,e){var i;if(!this.model)return;const g=this.dict.get(this.object);if(g)for(let B=0;B<g.length;B++)g[B]===void 0&&(g[B]=new cg(null,this.object,null));this.skinnedMeshExport(A,e);const I=this.object,o=this.dict.get(I);if(!o||I.isSkinnedMesh)return;wR&&console.log("SERIALIZE",this.model.name,this.object.type,o);const s=new MA;A.appendLine("matrix4d xformOp:transform.timeSamples = {"),A.indent++;const C=new Array;let a=0;for(let B=0;B<o.length;B++){if(C.push(a),o[B]===void 0){console.error("Got an undefined transform data, this is likely a bug.",I,o);continue}a+=o[B].getDuration()+cg.animationDurationPadding}const r=Intl.NumberFormat("en",{maximumFractionDigits:2,minimumFractionDigits:0});for(let B=0;B<o.length;B++){const Q=o[B];if(!Q)continue;const E=C[B];{const h=Q.getSortedTimesArray();if(!h||h.length===0){console.error("got an animated object but no time values?",I,Q);continue}{const d=((i=Q.clip)==null?void 0:i.name)??"rest",l=Q.getDuration();EC&&console.log("Write .timeSamples:",d,E,l,o),A.appendLine("# "+d+": start="+r.format(E*Q.frameRate)+", length="+r.format(l*Q.frameRate)+", frames="+Q.getFrames())}for(const{time:d,translation:l,rotation:c,scale:p}of Q.getValues(h)){s.compose(l,c,p);const u=`${r.format((E+d)*Q.frameRate)}: ${cE(s)},`;A.appendLine(u)}}}A.indent--,A.appendLine("}")}}var LgA=Object.defineProperty,YgA=Object.getOwnPropertyDescriptor,o2=(t,A,e,i)=>{for(var g=i>1?void 0:i?YgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&LgA(A,e,g),g};const s2=tA("debugpost");class Ne{constructor(A){n(this,"_active",!0),n(this,"_value"),n(this,"_valueRaw"),n(this,"_defaultValue"),n(this,"valueProcessor"),n(this,"onValueChanged"),this._value=A,this._defaultValue=A,this._valueRaw=A}get overrideState(){return this._active}set overrideState(A){if(this._active===A)return;this._active=A;const e=A?this._valueRaw:this._defaultValue;this.processValue(e,!0)}get value(){return this._valueRaw}set value(A){this.processValue(A,!1)}set defaultValue(A){this._defaultValue=A}__init(){this.processValue(this._valueRaw,!0)}processValue(A,e){if(A==null||!e&&this.testIfValueChanged(A)===!1)return;const i=this._value;if(s2){let g=!0;if(typeof i=="number"&&typeof A=="number"){const I=i?.toFixed(4),o=A?.toFixed(4);I!=o?g=!0:g=!1}g&&console.log("VolumeParameter: value changed from",i,"to",A)}!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,A=this._defaultValue,this._valueRaw=A):(this._valueRaw=A,this._active&&this.valueProcessor&&(A=this.valueProcessor(A)),this._value=A),this.onValueChanged?this.onValueChanged(A,i,this):s2&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(A){return this._valueRaw!==A}}o2([w()],Ne.prototype,"overrideState",1),o2([w()],Ne.prototype,"value",1);var _gA=Object.defineProperty,HgA=Object.getOwnPropertyDescriptor,TgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?HgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&_gA(A,e,g),g};const OgA=tA("debugpost");class aI extends FA{constructor(A=void 0){if(super(),n(this,"active",!0),n(this,"_result"),n(this,"_didCreateVolumeParameters",!1),A){this.ensureVolumeParameters();for(const e of Object.keys(A)){const i=A[e],g=this[e];g instanceof Ne&&(g.value=i)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var A;return this.ensureVolumeParameters(),this._result||(this._result=(A=this.onCreateEffect)==null?void 0:A.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){OgA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(A=>A.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const A=Object.keys(this);for(const e of A){const i=this[e];i instanceof Ne&&i.__init()}}onAfterDeserialize(A,e){if(typeof A=="object"){const i=this.$serializedTypes;if(i){for(const g of Object.keys(i))if(i[g]===Ne){const I=A[g];if(I!==void 0){const o=this[g];o.value=I}}}}}onEditorModification(A){const e=A.propertyName;if(this[e]instanceof Ne){const i=A.value;return this[e].value=i,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const A=this.$serializedTypes;if(A)for(const e of Object.keys(A))A[e]===Ne&&(this[e]||(this[e]=new Ne))}}TgA([w()],aI.prototype,"active",2);var PgA=Object.defineProperty,jgA=Object.getOwnPropertyDescriptor,WgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?jgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&PgA(A,e,g),g};const ZgA=tA("debugpost"),yR={};function ts(t,A){yR[t]=A}function VgA(t){return t.__type in yR?yR[t.__type]:(ZgA&&t.__type&&console.warn("Unknown postprocessing type",t.__type,t),aI)}class Qd{constructor(){n(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}WgA([dE([t=>VgA(t),aI])],Qd.prototype,"components",2);var zgA=Object.defineProperty,XgA=Object.getOwnPropertyDescriptor,$gA=(t,A,e,i)=>{for(var g=i>1?void 0:i?XgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&zgA(A,e,g),g};class Ed extends aI{constructor(){super(...arguments),n(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const A=new HY({preset:DE.HIGH,edgeDetectionMode:$M.DEPTH});return this.preset.onValueChanged=e=>{A.applyPreset(e)},A}}$gA([w(Ne)],Ed.prototype,"preset",2),ts("Antialiasing",Ed);const AIA=tA("debugusdz");class rr{constructor(){n(this,"files",new Array)}static getName(A){var e;const i=A.split(".").pop();let g=(e=A.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:e.replace(".","_");return g||(g="Audio_"+Math.random().toString(36).substring(2,15)),Ms(g)+"."+i}get extensionName(){return"Audio"}onExportObject(A,e,i){const g=CA.getComponents(A,ai);if(g.length)for(const I of g){if(!I.clip||typeof I.clip!="string"||!I.playOnAwake)continue;const o=I.clip.split("/").pop()||"Audio",s=rr.getName(I.clip),C=Ms(s);this.files.some(a=>a.path===I.clip)||this.files.push({path:I.clip,name:s}),i.quickLookCompatible||e.addEventListener("serialize",(a,r)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${C}"`,"(",!1),a.appendLine(`displayName = "${o}"`),a.closeBlock(")"),a.beginBlock(),a.appendLine(`uniform asset filePath = @audio/${s}@`),a.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${I.volume}`),a.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const i="audio/"+e.name;if(A.files[i]){AIA&&console.warn("Audio file with name "+i+" already exists in the context. Skipping.");continue}const g=await(await(await fetch(e.path)).blob()).arrayBuffer(),I=new Uint8Array(g);A.files[i]=I}}}const fB=tA("debugautosync"),SR=Symbol("syncerId");class eIA{constructor(){n(this,"_syncers",{})}getOrCreateSyncer(A){if(!A.guid)return null;if(this._syncers[A.guid])return this._syncers[A.guid];const e=new tIA(A);return e[SR]=A.guid,this._syncers[e[SR]]=e,e}removeSyncer(A){delete this._syncers[A[SR]]}}const fR=new eIA;class tIA{constructor(A){n(this,"comp"),n(this,"hasChanges",!1),n(this,"changedProperties",{}),n(this,"data",{}),n(this,"_isReceiving",!1),n(this,"_isInit",!1),n(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const e=this.comp.context.connection;if(!e||!e.isConnected||!e.isInRoom){for(const i in this.changedProperties)delete this.changedProperties[i];return}for(const i in this.data)delete this.data[i];this.data.guid=this.comp.guid;for(const i in this.changedProperties){const g=this.changedProperties[i];delete this.changedProperties[i],this.data[i]=g}e.send(this.networkingKey,this.data,Wo.Queued)}),n(this,"onHandleReceiving",e=>{if(fB&&console.log("RECEIVE",this.comp.name,this.comp.guid,e),!this._isInit||!this.comp)return;const i=e.guid;if(!(i&&i!==this.comp.guid)){fB&&console.log("RECEIVED",this.comp.name,this.comp.guid,e);try{this._isReceiving=!0;for(const g in e){if(g==="guid")continue;const I=e[g];this.comp[g]=I,fB&&console.log("SET",g,I)}}catch(g){console.error(g)}finally{this._isReceiving=!1}}}),this.comp=A}get networkingKey(){return this.comp.guid}init(A){if(this._isInit)return;this._isInit=!0,this.comp=A,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const e=this.comp.context.connection.tryGetState(this.comp.guid);e&&this.onHandleReceiving(e)}destroy(){this._isInit&&(this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this.onHandleSending),1),this.comp.context.connection.stopListen(this.networkingKey,this.onHandleReceiving),this.comp=null,this._isInit=!1)}notifyChanged(A,e){this._isReceiving||(fB&&console.log("Property changed: "+A,e),this.hasChanges=!0,this.changedProperties[A]=e)}}function iIA(t,A){let e=A!==t;return!e&&t&&A&&(Array.isArray(t)&&Array.isArray(A)||typeof t=="object"&&typeof A=="object")&&(e=!0),e}const hd=Symbol("AutoSyncHandler");function gIA(t){if(t[hd])return t[hd];const A=fR.getOrCreateSyncer(t);return A?.init(t),t[hd]=A,A}function IIA(t){const A=t[hd];A&&(fR.removeSyncer(A),A.destroy(),delete t[hd])}const mR=function(t){return function(A,e){var i;let g="";typeof e=="string"?g=e:g=e.name;let I=null,o;typeof t=="string"?o=A[t]:typeof t=="function"&&(o=t);const s=A,C=s.__internalAwake;if(typeof C!="function"){(fB||re())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((i=A?.constructor)==null?void 0:i.name)+'" is not supported',A);return}fB&&console.log(g);const a=Symbol(g);s.__internalAwake=function(){if(this[a]!==void 0)return;this[a]=this[g],I=fR.getOrCreateSyncer(this);const B=Object.getOwnPropertyDescriptor(this,g);if(B?.set===void 0){let Q=!1;Object.defineProperty(this,g,{set:function(E){var h;const d=this[a];if(this[a]=E,Q){re()&&console.warn("Recursive call detected",g);return}Q=!0;try{const l=iIA(E,d);fB&&console.log("SyncField assignment",g,"changed?",l,E),l&&o?.call(this,E,d)!==!1&&((h=gIA(this))==null||h.notifyChanged(g,E))}finally{Q=!1}},get:function(){return this[a]},configurable:!0,enumerable:!0})}I?.init(this),C.call(this)};const r=s.__internalDestroy;s.__internalDestroy=function(){IIA(this),r.call(this)}}};var oIA=Object.defineProperty,sIA=Object.getOwnPropertyDescriptor,Py=(t,A,e,i)=>{for(var g=i>1?void 0:i?sIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&oIA(A,e,g),g};const ho=tA("debugplayersync");class TE extends FA{constructor(){super(...arguments),n(this,"autoSync",!0),n(this,"asset"),n(this,"onPlayerSpawned"),n(this,"_localInstance"),n(this,"onJoinedRoom",()=>{ho&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new tg)}onEnable(){this.context.connection.beginListen(At.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(At.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(At.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(At.JoinedRoom,this.onJoinedRoom)}async getInstance(){var A,e,i,g,I,o;if(this._localInstance)return this._localInstance;if(ho&&console.log("PlayerSync.createInstance",(A=this.asset)==null?void 0:A.uri),!((e=this.asset)!=null&&e.asset)&&!((i=this.asset)!=null&&i.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(g=this.asset)==null?void 0:g.instantiateSynced({parent:this.gameObject},!0);const s=await this._localInstance;if(s){const C=CA.getComponent(s,is);C?(C.owner=this.context.connection.connectionId,(I=this.onPlayerSpawned)==null||I.invoke(s)):(this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((o=this.asset)==null?void 0:o.uri)+"</strong>: please make sure the asset has a PlayerState component!"),CA.destroySynced(s))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var A;(A=this._localInstance)==null||A.then(e=>(ho&&console.log("PlayerSync.destroyInstance",e),CA.destroySynced(e))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",A=>{if(document.visibilityState==="visible")for(let e=is.all.length-1;e>=0;e--){const i=is.all[e];(!i.owner||!this.context.connection.userIsInRoom(i.owner))&&i.doDestroy()}})}}Py([w()],TE.prototype,"autoSync",2),Py([w(tt)],TE.prototype,"asset",2),Py([w(tg)],TE.prototype,"onPlayerSpawned",2);var C2=(t=>(t.OwnerChanged="ownerChanged",t))(C2||{}),cd;const xg=(cd=class extends FA{constructor(){super(...arguments),n(this,"onOwnerChangeEvent",new tg),n(this,"onFirstOwnerChangeEvent",new tg),n(this,"hasOwner",!1),n(this,"owner"),n(this,"dontDestroy",!1),n(this,"onUserLeftRoom",t=>{if(t.userId===this.owner){ho&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return xg._all}static get local(){return xg._local}static getFor(t){if(t instanceof uA)return CA.getComponentInParent(t,xg);if(t instanceof FA)return CA.getComponentInParent(t.gameObject,xg)}static isLocalPlayer(t){const A=xg.getFor(t);return A?.isLocalPlayer??!1}static addEventListener(t,A){return this._callbacks[t]||(this._callbacks[t]=[]),this._callbacks[t].push(A),A}static removeEventListener(t,A){if(!this._callbacks[t])return;const e=this._callbacks[t].indexOf(A);e>=0&&this._callbacks[t].splice(e,1)}static dispatchEvent(t,A){if(this._callbacks[t])for(const e of this._callbacks[t])e(A)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(t,A){var e,i;ho&&console.log("PlayerSync.onOwnerChange",this,"newOwner",t,"oldOwner",A);const g=xg._local.indexOf(this);g>=0&&xg._local.splice(g,1);const I={playerState:this,oldValue:A,newValue:t};if(this.hasOwner||(this.hasOwner=!0,(e=this.onFirstOwnerChangeEvent)==null||e.invoke(I)),(i=this.onOwnerChangeEvent)==null||i.invoke(I),this.owner===this.context.connection.connectionId){xg._local.push(this);const s=new CustomEvent("local-owner-changed",{detail:I});this.dispatchEvent(s)}const o=new CustomEvent("owner-changed",{detail:I});this.dispatchEvent(o),xg.dispatchEvent("ownerChanged",o)}awake(){xg.all.push(this),ho&&console.log("Registered new PlayerState",this.guid,xg.all.length-1,xg.all),this.context.connection.beginListen(At.UserLeftRoom,this.onUserLeftRoom)}async start(){ho&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await ws(300),this.context.connection.userIsInRoom(this.owner)==!1&&(ho&&console.log(`PlayerSync.start \u2192 doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(ho&&console.warn("PlayerState.start \u2192 owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?ho&&console.warn("PlayerState.start \u2192 owner is still undefined but dontDestroy is set to true",this.name):(ho&&console.warn(`PlayerState.start \u2192 owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):ho&&console.log("PlayerState.start \u2192 owner is assigned",this.owner)},2e3))}doDestroy(){ho&&console.log("PlayerSync.doDestroy \u2192 syncDestroy",this.name),py(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(At.UserLeftRoom,this.onUserLeftRoom),xg.all.splice(xg.all.indexOf(this),1),this.isLocalPlayer){const t=xg._local.indexOf(this);t>=0&&xg._local.splice(t,1)}}},n(cd,"_all",[]),n(cd,"_local",[]),n(cd,"_callbacks",{}),cd);let is=xg;Py([mR(is.prototype.onOwnerChange)],is.prototype,"owner",2);const CIA=tA("debugavatar"),hC=class extends FA{constructor(){super(...arguments),n(this,"connectionId"),n(this,"avatar")}static getAvatar(t){return t>=0&&t<hC.instances.length?hC.instances[t]:null}static onAvatarMarkerCreated(t){return hC._onNewAvatarMarkerAdded.push(t),t}static onAvatarMarkerDestroyed(t){return hC._onAvatarMarkerDestroyed.push(t),t}awake(){hC.instances.push(this),CIA&&console.log(this);for(const t of hC._onNewAvatarMarkerAdded)t({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){hC.instances.splice(hC.instances.indexOf(this),1);for(const t of hC._onAvatarMarkerDestroyed)t({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let Lg=hC;n(Lg,"instances",[]),n(Lg,"_onNewAvatarMarkerAdded",[]),n(Lg,"_onAvatarMarkerDestroyed",[]);var aIA=Object.defineProperty,nIA=Object.getOwnPropertyDescriptor,rIA=(t,A,e,i)=>{for(var g=i>1?void 0:i?nIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&aIA(A,e,g),g};const OE=tA("debugxrflags"),a2=tA("disablexrflags");a2&&console.warn("XRFlags are disabled");var cC=(t=>(t[t.Never=0]="Never",t[t.Browser=1]="Browser",t[t.AR=2]="AR",t[t.VR=4]="VR",t[t.FirstPerson=8]="FirstPerson",t[t.ThirdPerson=16]="ThirdPerson",t[t.All=4294967295]="All",t))(cC||{});const n2=class{constructor(){n(this,"Mask",17)}Has(t){return(this.Mask&t)!==0}Set(t){OE&&console.warn("Set XR flag state to",t),this.Mask=t,co.Apply()}Enable(t){this.Mask|=t,co.Apply()}Disable(t){this.Mask&=~t,co.Apply()}Toggle(t){this.Mask^=t,co.Apply()}EnableAll(){this.Mask=-1,co.Apply()}DisableAll(){this.Mask=0,co.Apply()}};let NI=n2;n(NI,"Global",new n2);var ld;const Da=(ld=class extends FA{constructor(){super(...arguments),n(this,"visibleIn")}static Apply(){for(const t of this.registry)t.UpdateVisible(NI.Global)}awake(){Da.registry.push(this)}onEnable(){Da.firstApply?this.UpdateVisible(NI.Global):(Da.firstApply=!0,Da.Apply())}onDestroy(){const t=Da.registry.indexOf(this);t>=0&&Da.registry.splice(t,1)}get isOn(){return this.gameObject.visible}UpdateVisible(t=null){if(a2)return;let A;const e=t;if(e&&typeof e=="number"&&(console.assert(typeof e=="number","XRFlag.UpdateVisible: state must be a number",e),OE&&console.log(e),Da.buffer.Mask=e,t=Da.buffer),t instanceof NI?(OE&&console.warn(this.name,"use passed in mask",t.Mask,this.visibleIn),A=t.Has(this.visibleIn)):(OE&&console.log(this.name,"use global mask"),NI.Global.Has(this.visibleIn)),A!==void 0)if(A)OE&&console.log(this.name,"is visible",this.gameObject.uuid),CA.setActive(this.gameObject,!0);else{if(OE&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},n(ld,"registry",[]),n(ld,"firstApply"),n(ld,"buffer",new NI),ld);let co=Da;rIA([w()],co.prototype,"visibleIn",2);var BIA=Object.defineProperty,QIA=Object.getOwnPropertyDescriptor,kR=(t,A,e,i)=>{for(var g=i>1?void 0:i?QIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&BIA(A,e,g),g};const dd=tA("debugwebxr"),r2=new RA().setFromAxisAngle(new S(0,1,0),Math.PI);class mB extends FA{constructor(){super(...arguments),n(this,"head"),n(this,"leftHand"),n(this,"rightHand"),n(this,"_syncTransforms")}async onEnterXR(A){if(!this.activeAndEnabled)return;dd&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const e=is.getFor(this);if(e!=null&&e.owner){const i=this.gameObject.addNewComponent(Lg);i.avatar=this.gameObject,i.connectionId=e.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):e&&!this.context.connection.isConnected&&(e.dontDestroy=!0)}onLeaveXR(A){const e=this.gameObject.getComponent(Lg);e&&e.destroy()}onUpdateXR(A){var e,i;if(!this.activeAndEnabled)return;const g=is.isLocalPlayer(this);if(!g)return;const I=A.xr;if(I.rig&&I.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),I.rig.gameObject.add(this.gameObject)),this._syncTransforms&&g)for(const a of this._syncTransforms)a.fastMode=!0,a.isOwned()||a.requestOwnership();if(this.head&&this.context.mainCamera){const a=this.head.asset;if(a.position.copy(this.context.mainCamera.position),a.quaternion.copy(this.context.mainCamera.quaternion),a.quaternion.x*=-1,this.context.time.frameCount%10===0){const r=CA.getComponentsInChildren(this.head.asset,co);for(const B of r)B.enabled=!1,B.gameObject.visible=!1}}const o=A.xr.leftController,s=(e=this.leftHand)==null?void 0:e.asset;o&&s&&(s.position.copy(o.gripPosition),s.quaternion.copy(o.gripQuaternion),s.quaternion.multiply(r2),s.visible=o.isTracking);const C=A.xr.rightController;if(C&&(i=this.rightHand)!=null&&i.asset){const a=this.rightHand.asset;a.position.copy(C.gripPosition),a.quaternion.copy(C.gripQuaternion),a.quaternion.multiply(r2),a.visible=C.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var A,e,i;if(this.context.connection.isConnected){const g=is.getFor(this);if(g&&g.isLocalPlayer==!1){const I=we.getXRSync(this.context);if(I&&I.hasState(g.owner)){this.tryFindAvatarObjectsIfMissing();const o=(A=this.leftHand)==null?void 0:A.asset;o&&(o.visible=I?.isTracking(g.owner,"left")??!1);const s=(e=this.rightHand)==null?void 0:e.asset;s&&(s.visible=I?.isTracking(g.owner,"right")??!1)}if((i=this.head)!=null&&i.asset){const o=CA.getComponentsInChildren(this.head.asset,co);for(const s of o)s.enabled=!1,s.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const A={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};HH.tryFindAvatarObjects(this.gameObject,this.sourceId||"",A),A.head&&(this.head=A.head),A.leftHand&&(this.leftHand=A.leftHand),A.rightHand&&(this.rightHand=A.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof uA&&(this.head=new tt("",this.sourceId,this.head));else{const A=new uA;A.name="Head";const e=ql.createPrimitive(EB.Cube);A.add(e),this.gameObject.add(A),this.head=new tt("",this.sourceId,A),dd&&console.log("Create head",A)}if(this.rightHand)this.rightHand instanceof uA&&(this.rightHand=new tt("",this.sourceId,this.rightHand));else{const A=new uA;A.name="Right Hand",this.gameObject.add(A),this.rightHand=new tt("",this.sourceId,A),dd&&console.log("Create right hand",A)}if(this.leftHand)this.leftHand instanceof uA&&(this.leftHand=new tt("",this.sourceId,this.leftHand));else{const A=new uA;A.name="Left Hand",this.gameObject.add(A),this.leftHand=new tt("",this.sourceId,A),dd&&console.log("Create left hand",A)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),is.isLocalPlayer(this.gameObject)&&(this._syncTransforms=CA.getComponentsInChildren(this.gameObject,bn))}async loadAvatarObjects(A,e,i){const g=A.loadAssetAsync(),I=e.loadAssetAsync(),o=i.loadAssetAsync(),s=new Array;g&&s.push(g),I&&s.push(I),o&&s.push(o);const C=await Yc(s);dd&&console.log("Avatar loaded results:",C)}}kR([w(tt)],mB.prototype,"head",2),kR([w(tt)],mB.prototype,"leftHand",2),kR([w(tt)],mB.prototype,"rightHand",2);class lC{static Add(A,e,i=null){if(e){for(const g of this.Pois)if(g.obj===e)return;this.Pois.push({obj:e,avatar:i}),this.LastChangeTime=A.time.time}}static Remove(A,e){var i;if(e){for(const g of this.Pois)if(g.obj===e){this.Pois.splice(this.Pois.indexOf(g),1),this.LastChangeTime=A?.time.time??((i=be.Current)==null?void 0:i.time.time);return}}}}n(lC,"Pois",[]),n(lC,"LastChangeTime",0);class EIA{constructor(){n(this,"guid"),n(this,"position",new S)}}class pd extends FA{constructor(){super(...arguments),n(this,"target",null),n(this,"avatar",null),n(this,"_model",null),n(this,"_targetModel",new EIA),n(this,"_currentTargetObject",null),n(this,"_lastUpdateTime",0),n(this,"_lookDuration",0),n(this,"_lastPoiChangedTime",0)}set controlledTarget(A){this.target=A;const e=W.get("MoveRandom");if(e&&this.target){const i=CA.getComponent(this.target,e);i&&i.destroy()}}awake(){if(this.avatar=CA.getComponentInParent(this.gameObject,Lg),this.avatar){const A=CA.getComponentInParent(this.gameObject,Lg);this._model=new HU(this.context.connection,this.guid),A!=null&&A.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",A=>{var e;this.target&&A&&A.guid===((e=this.avatar)==null?void 0:e.guid)&&gI(this.target,A.position)})}update(){var A;if((!this.context.connection.isConnected||(A=this._model)!=null&&A.hasOwnership)&&(lC.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=lC.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const e=Fe(this._currentTargetObject);gI(this.target,e),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(e))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const A=lC.Pois;if(A.length>0){const e=A[Math.floor(Math.random()*A.length)];if(e&&e.obj){if(e.avatar&&e.avatar===this.avatar)return;this._currentTargetObject=e.obj}}}}}const PE=tA("debugnetworkingstreams");var dC=(t=>(t.Connected="peer-user-connected",t.StreamReceived="receive-stream",t.StreamEnded="call-ended",t.Disconnected="peer-user-disconnected",t.UserJoined="user-joined",t))(dC||{});class B2{constructor(A,e){n(this,"type","call-ended"),n(this,"userId"),n(this,"direction"),this.userId=A,this.direction=e}}class Q2{constructor(A,e){n(this,"type","receive-stream"),n(this,"stream"),n(this,"target"),this.stream=A,this.target=e}}class hIA{constructor(A,e){n(this,"guid"),n(this,"peerId"),n(this,"dontSave",!0),this.guid=A.id,this.peerId=e}}var E2=(t=>(t.Incoming="incoming",t.Outgoing="outgoing",t))(E2||{});class cIA extends ag{constructor(A,e,i){super(),n(this,"userId"),n(this,"direction"),n(this,"call"),n(this,"_stream",null),n(this,"_isDisposed",!1),this.userId=A,this.call=e,this.direction=i,this._stream=null,e.on("stream",g=>{if(PE&&console.log("Receive video",g.getAudioTracks(),g.getVideoTracks()),this._stream=g,i==="incoming"){const I=new Q2(g,this);this.dispatchEvent(I)}}),e.on("close",()=>{this.dispatchEvent(new B2(A,i))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),wa(this._stream))}get isOpen(){var A;return((A=this.call.peerConnection)==null?void 0:A.connectionState)==="connected"}get isOpening(){var A;return((A=this.call.peerConnection)==null?void 0:A.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const ud=class extends ag{constructor(t,A){super(),n(this,"id"),n(this,"context"),n(this,"_peer"),n(this,"_incomingCalls",[]),n(this,"_outgoingCalls",[]),n(this,"_enabled",!1),n(this,"_enabledPeer",!1),n(this,"onConnectRoomFn",this.onConnectRoom.bind(this)),n(this,"onPeerConnectFn",this.onPeerConnect.bind(this)),n(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this)),this.context=t,this.id=A,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(t,A){if(ud.instances.has(A))return ud.instances.get(A);const e=new ud(t,A);return ud.instances.set(A,e),e}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(t){return this.id+"-"+t}getUserIdFromPeerId(t){return t.substring(this.id.length+1)}makeCall(t,A){var e;const i={metadata:{userId:this.context.connection.connectionId}},g=(e=this._peer)==null?void 0:e.call(t,A,i);if(g)return this.registerCall(g,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(At.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(At.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const t=this.getMyPeerId();t?this._peer=RH(t):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(t){PE&&console.log("Peer connected as",t),this.context.connection.send("peer-user-connected",new hIA(this,t))}onPeerReceivingCall(t){t.answer(),this.registerCall(t,"incoming")}registerCall(t,A){const e=t.metadata;(!e||!e.userId)&&console.error("Missing call metadata",t);const i=e.userId;A==="incoming"&&PE?console.log("Receive call from",t.metadata):PE&&console.log("Make call to",t.metadata);const g=A==="incoming"?this._incomingCalls:this._outgoingCalls,I=new cIA(i,t,A);return g.push(I),t.on("error",o=>{console.error("Call error",o)}),t.on("close",()=>{PE&&console.log("Call ended",t.metadata),t.close();const o=g.indexOf(I);o!==-1&&g.splice(o,1)}),I.addEventListener("call-ended",o=>{this.dispatchEvent(o)}),A==="incoming"&&(I.addEventListener("receive-stream",o=>{this.dispatchEvent(o)}),t.on("stream",()=>{let o=0;const s=setInterval(()=>{const C=o===0;!I.isOpen&&C&&(o+=1,clearInterval(s),I.close())},2e3)})),I}};let jy=ud;n(jy,"instances",new Map);class Wp extends ag{constructor(A,e){super(),n(this,"context"),n(this,"peer"),n(this,"_sendingStreams",new Map),n(this,"debug",!1),n(this,"onJoinedRoom",i=>{this.debug&&console.log(`${i.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()}),n(this,"onReceiveStream",i=>{this.debug&&console.log("RECEIVE STREAM",i),this.dispatchEvent({type:"receive-stream",target:this,stream:i.stream,userId:i.userId})}),n(this,"onCallEnded",i=>{this.dispatchEvent(i)}),n(this,"onUserConnected",i=>{if(this.peer.id===i.guid){this.debug&&console.log("USER CONNECTED",i.guid,i);const g=this._sendingStreams.keys().next().value;this.peer.makeCall(i.peerId,g)}}),n(this,"onUserLeft",i=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()}),this.context=A,this.peer=e,PE&&(this.debug=!0)}static create(A){const e=jy.getOrCreate(A.context,A.context.connection.connectionId);return new Wp(A.context,e)}startSendingStream(A){this._sendingStreams.has(A)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(A,[]),this.updateSendingCalls())}stopSendingStream(A){if(A){const e=this._sendingStreams.get(A);if(e){this.debug&&console.log("Closing calls",e);for(const i of e)i.close()}this._sendingStreams.delete(A),e&&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(At.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(At.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(At.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(At.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(At.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(At.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var A;let e=!1;const i=this.context.connection.connectionId;for(const g of this._sendingStreams.keys()){const I=this._sendingStreams.get(g)||[];for(const o of this.context.connection.usersInRoom()){if(o===i)continue;const s=I.find(C=>C.userId===o);if(!s||((A=s.stream)==null?void 0:A.active)===!1){this.debug&&console.log("Starting call to",o,i);const C=this.peer.makeCall(this.peer.getPeerIdFromUserId(o),g);C&&(e=!0,I.push(C))}}this._sendingStreams.set(g,I)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),e&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const A of this._sendingStreams.keys()){const e=this._sendingStreams.get(A);if(e)for(let i=e.length-1;i>=0;i--){const g=e[i];this.context.connection.userIsInRoom(g.userId)||(g.close(),e.splice(i,1))}}}}function wa(t){if(t&&t instanceof MediaStream)for(const A of t.getTracks())A.stop()}var lIA=Object.defineProperty,dIA=Object.getOwnPropertyDescriptor,h2=(t,A,e,i)=>{for(var g=i>1?void 0:i?dIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&lIA(A,e,g),g};const pIA="noVoip",uIA=tA("debugvoip");class kB extends FA{constructor(){super(...arguments),n(this,"autoConnect",!1),n(this,"runInBackground",!0),n(this,"debug",!1),n(this,"_net"),n(this,"_outputStream",null),n(this,"onJoinedRoom",async()=>{await ws(300),this.autoConnect&&!this.isSending&&this.connect()}),n(this,"_incomingStreams",new Map),n(this,"onReceiveStream",A=>{const e=A.target.userId,i=A.stream,g=this._incomingStreams.get(e);if(g)g.srcObject=i,g.setAttribute("autoplay","true");else{const I=new Audio;this._incomingStreams.set(e,I),I.setAttribute("autoplay","true"),I.srcObject=i}}),n(this,"onStreamEnded",A=>{const e=this._incomingStreams.get(A.userId);wa(e?.srcObject),this._incomingStreams.delete(A.userId)}),n(this,"onEnabledChanged",()=>{for(const A of this._incomingStreams){const e=A[1];e.muted=!this.enabled}}),n(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const A=document.visibilityState!=="visible";this.setMuted(A);for(const e of this._incomingStreams){const i=e[1];i.muted=A}})}awake(){uIA&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async A=>{A.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=Wp.create(this)),this._net.addEventListener(dC.StreamReceived,this.onReceiveStream),this._net.addEventListener(dC.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(At.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var A;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(dC.StreamReceived,this.onReceiveStream),this._net.removeEventListener(dC.StreamEnded,this.onStreamEnded),(A=this._net)==null||A.disable(),this.context.connection.stopListen(At.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(A){if(this.context.connection.isConnected){if(!await jk())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),wa(this._outputStream),this._outputStream=await this.getAudioStream(A),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await jk()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):HG("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),wa(this._outputStream),this._outputStream=null}setMuted(A){var e;const i=(e=this._outputStream)==null?void 0:e.getAudioTracks();if(i)for(const g of i)g.enabled=!A}get isMuted(){var A;if(this._outputStream===null)return!1;const e=(A=this._outputStream)==null?void 0:A.getAudioTracks();if(e){for(const i of e)if(!i.enabled)return!0}return!1}getFrequency(A){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,re()&&Ci("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(A){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:A??!0,video:!1}).catch(e=>(console.warn("VOIP failed getting audio stream",e),null)):(console.error("No getDisplayMedia support"),null)}}h2([w()],kB.prototype,"autoConnect",2),h2([w()],kB.prototype,"runInBackground",2);var DIA=Object.defineProperty,wIA=Object.getOwnPropertyDescriptor,c2=(t,A,e,i)=>{for(var g=i>1?void 0:i?wIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&DIA(A,e,g),g};const yIA=tA("debugmouth");class Dd extends FA{constructor(){super(...arguments),n(this,"idle",[]),n(this,"talking",[]),n(this,"marker",null),n(this,"voip",null),n(this,"lastMouthChangeTime",0),n(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=CA.findObjectOfType(kB,this.context),this.marker||(this.marker=CA.getComponentInParent(this.gameObject,Lg))},3e3)}update(){var A;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((A=this.marker)==null?void 0:A.connectionId)??null;if(!e){yIA&&(e=null);return}const i=this.voip.getFrequency(e)??0;this.updateLips(i)}updateLips(A){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&A>30){this.lastMouthChangeTime=this.context.time.time;const e=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,e)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const e=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,e)}}}setMouthShapeActive(A,e){if(A){A!=this.idle?this.idle.map(i=>i.visible=!1):this.talking.map(i=>i.visible=!1);for(let i=0;i<A.length;i++){const g=A[i];g&&(g.visible=i===e)}}}}c2([w(uA)],Dd.prototype,"idle",2),c2([w(uA)],Dd.prototype,"talking",2);class GR extends FA{constructor(){super(...arguments),n(this,"voip",null),n(this,"marker",null),n(this,"_startPosition",null)}awake(){this.voip=CA.findObjectOfType(kB,this.context),this.marker=CA.getComponentInParent(this.gameObject,Lg)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const A=this.marker.connectionId,e=this.voip.getFrequency(A);if(e==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const i=e/100;this.gameObject.position.y=this._startPosition.y+i*.07}}var SIA=Object.defineProperty,fIA=Object.getOwnPropertyDescriptor,Wy=(t,A,e,i)=>{for(var g=i>1?void 0:i?fIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&SIA(A,e,g),g};class GB extends FA{constructor(){super(...arguments),n(this,"eyes",[]),n(this,"lastBlinkTime",0),n(this,"blinkLength",0),n(this,"eyesOpen",!0),n(this,"state",null)}awake(){this.state=CA.getComponentInParent(this.gameObject,co)}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 A of this.eyes)A&&(A.visible=this.eyesOpen)}}}Wy([w(uA)],GB.prototype,"eyes",2),Wy([w()],GB.prototype,"lastBlinkTime",2),Wy([w()],GB.prototype,"blinkLength",2),Wy([w()],GB.prototype,"eyesOpen",2);var mIA=Object.defineProperty,kIA=Object.getOwnPropertyDescriptor,MR=(t,A,e,i)=>{for(var g=i>1?void 0:i?kIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&mIA(A,e,g),g},UR;const l2=(UR=class extends FA{constructor(){super(...arguments),n(this,"head",null),n(this,"eyes",null),n(this,"target",null),n(this,"brain",null),n(this,"vec",new S),n(this,"currentTargetPoint",new S)}awake(){this.brain||(this.brain=CA.getComponentInParent(this.gameObject,pd)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=CA.addNewComponent(this.gameObject,pd)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const t=this.target;if(t&&this.head){const A=this.eyes;if(A){const e=Fe(t);this.currentTargetPoint.lerp(e,this.context.time.deltaTime/.1);const i=Fe(this.head),g=this.vec.copy(this.currentTargetPoint).sub(i).normalize();if(g.length()<.1)return;const I=l2.forward;if(I.set(0,0,1),I.applyQuaternion(Gt(this.head)),I.dot(g)>.45)for(let o=0;o<A.length;o++)A[o].lookAt(this.currentTargetPoint)}}}},n(UR,"forward",new S(0,0,1)),UR);let jE=l2;MR([w(uA)],jE.prototype,"head",2),MR([w(uA)],jE.prototype,"eyes",2),MR([w(uA)],jE.prototype,"target",2);const wd=tA("debugavatar");class Zy{constructor(A,e,i,g){n(this,"root"),n(this,"head"),n(this,"leftHand"),n(this,"rigthHand");var I;this.root=A,this.head=e,this.leftHand=i,this.rigthHand=g,(I=this.root)==null||I.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class RR{constructor(){n(this,"avatarRegistryUrl",null)}async getOrCreateNewAvatarInstance(A,e){if(!e)return console.error("Can not create avatar: failed to provide id or root object"),null;let i=null;if(typeof e=="string"){if(i=await this.loadAvatar(A,e),!i){const I=new _s;i=CA.instantiate(AE(e,A.scene),I)}}else i=e;if(!i)return null;const g=this.findAvatar(i);return g.isValid?(wd&&console.log("[Custom Avatar] valid config",e,wd?g:""),g):(console.warn("[Custom Avatar] config isn't valid",e,wd?g:""),null)}async loadAvatar(A,e){if(console.assert(e!=null&&typeof e=="string","Avatar id must not be null"),e.length<=0||!e)return null;if(wd&&console.log("[Custom Avatar] "+e+", loading..."),e.endsWith(".glb")||(e+=".glb"),this.avatarRegistryUrl===null){const g=await fetch("./"+e);let I=null;if(g.ok){const s=await g.blob();s&&(I=await s.arrayBuffer())}if(!I&&(I=await hU(e,e,0,"no url here go away",!0),!I))return null;const o=await Es().parseSync(A,I,null,0);return o?.scene??null}const i=new aE;return Il(i,A),new Promise((g,I)=>{const o=this.avatarRegistryUrl+"/"+e;i.load(o,async s=>{await Es().createBuiltinComponents(A,o,s,null,void 0),g(s.scene)},s=>{wd&&console.log("[Custom Avatar] "+s.loaded/s.total*100+"% loaded of "+s.total/1024+"kB")},s=>{console.error("[Custom Avatar] Error when loading: "+s),g(null)})})}cacheModel(A,e){}findAvatar(A){const e=A;let i=e;i.children.length==1&&(i=A.children[0]);let g=this.findAvatarPart(i,["head"]);const I=this.findAvatarPart(i,["left","hand"]),o=this.findAvatarPart(i,["right","hand"]);if(!g){g=e;const s=new S;new pt().setFromObject(g).getSize(s);const C=Math.max(s.x,s.y,s.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+C+" meters! Should be < 0.3m"),C>.3&&g.scale.multiplyScalar(1/C*.3)}return new Zy(e,g,I,o)}findAvatarPart(A,e){const i=A.name.toLowerCase();let g=!0;for(const I of e){if(!g)break;i.indexOf(I)===-1&&(g=!1)}if(g)return A;if(A.children)for(const I of A.children){const o=this.findAvatarPart(I,e);if(o)return o}return null}handleCustomAvatarErrors(A){if(!A.ok)throw Error(A.statusText);return A}}var GIA=Object.defineProperty,MIA=Object.getOwnPropertyDescriptor,NR=(t,A,e,i)=>{for(var g=i>1?void 0:i?MIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&GIA(A,e,g),g};class WE extends FA{constructor(){super(...arguments),n(this,"length",1),n(this,"depthTest",!0),n(this,"isGizmo",!0),n(this,"_axes",null)}onEnable(){if(this.isGizmo&&!fl)return;this._axes||(this._axes=new qo(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const A=this._axes.material;A&&A.depthTest!==void 0&&(A.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}NR([w()],WE.prototype,"length",2),NR([w()],WE.prototype,"depthTest",2),NR([w()],WE.prototype,"isGizmo",2);class FR extends FA{constructor(){super(...arguments),n(this,"from"),n(this,"to"),n(this,"hint"),n(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const A=Fe(this.to).clone(),e=Fe(this.from).clone(),i=A.distanceTo(e),g=A.clone();g.sub(e);const I=e.clone();I.add(A),I.multiplyScalar(.5);const o=Fe(this.hint).clone();o.sub(I);const s=new S;s.crossVectors(o,g),s.crossVectors(g,s),s.normalize();const C=i*.5,a=Math.max(this.desiredDistance,C),r=Math.sqrt(a*a-C*C),B=s.clone();B.multiplyScalar(r),B.add(I),gI(this.gameObject,B);const Q=I.clone();Q.sub(s),this.gameObject.lookAt(Q)}}const KR=tA("debugusdzbehaviours");class Vy{constructor(){n(this,"behaviours",[]),n(this,"behaviourComponents",[]),n(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(i=>{CA.foreachComponent(i,g=>{var I;const o=g;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const s=(I=o.beforeCreateDocument)==null?void 0:I.call(o,this,A);s instanceof Promise&&e.push(s)}},!1)}),KR&&console.log("onBeforeBuildDocument: all components",this.behaviourComponents),Promise.all(e)}onExportObject(A,e,i){var g;for(const I of this.behaviourComponents)KR&&console.log("onExportObject: createBehaviours",I),(g=I.createBehaviours)==null||g.call(I,this,e,i)}onAfterBuildDocument(A){for(const e of this.behaviourComponents)typeof e.afterCreateDocument=="function"&&e.afterCreateDocument(this,A);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(A,e){var i;if((i=this.behaviours)!=null&&i.length){e.beginBlock('def Scope "Behaviors"');for(const g of this.behaviours)g.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){KR&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)typeof e.afterSerialize=="function"&&(e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A));this.behaviours.length=0}}var UIA=Object.defineProperty,RIA=Object.getOwnPropertyDescriptor,JR=(t,A,e,i)=>{for(var g=i>1?void 0:i?RIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&UIA(A,e,g),g},vR;const d2=(vR=class extends aI{constructor(){super(...arguments),n(this,"threshold"),n(this,"intensity"),n(this,"scatter"),n(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>1*Math.PI*(1-t)):(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>100*(1-t))}onCreateEffect(){let t;if(this.selectiveBloom==null&&(this.selectiveBloom=d2.useSelectiveBloom),this.selectiveBloom){const A=t=new LY(this.context.scene,this.context.mainCamera,{blendFunction:He.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});A.inverted=!0}else t=new gU({blendFunction:He.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});return this.intensity.onValueChanged=A=>{t.intensity=A},this.threshold.onValueChanged=A=>{t.luminanceMaterial.threshold=A},this.scatter.onValueChanged=A=>{t.luminancePass.enabled=!0,t.luminanceMaterial.smoothing=A},t}},n(vR,"useSelectiveBloom",!1),vR);let MB=d2;JR([w(Ne)],MB.prototype,"threshold",2),JR([w(Ne)],MB.prototype,"intensity",2),JR([w(Ne)],MB.prototype,"scatter",2),ts("Bloom",MB);const ZE="NEEDLE_progressive",nI=tA("debugprogressive"),bR=Symbol("needle-progressive-texture"),VE=new Map;if(nI){let t=function(){A+=1,Xt(`Toggle LOD level: ${A}<br/>Registered objects: ${VE.size}`),console.log("Toggle LOD level",A,VE);const i=et.Current;VE.forEach((g,I)=>{for(const o of g.keys){const s=I[o];if(s instanceof he){const C=Jt.getMeshLODInformation(s),a=C?Math.min(A,C.lods.length):0;I["DEBUG:LOD"]=a,Jt.assignMeshLOD(i,g.sourceId,I,a),C&&(e=Math.max(e,C.lods.length-1))}else if(I instanceof Re){Jt.assignTextureLOD(i,g.sourceId,I,A);break}}}),A>=e&&(A=-1)},A=-1,e=2;window.addEventListener("keyup",i=>{i.key==="p"&&t()}),et.registerCallback(si.ContextCreated,i=>{const g=document.createElement("button");g.innerText="Toggle Progressive",g.onclick=t,i.context.menu.appendChild(g)})}function p2(t,A,e){var i;if(!nI)return;VE.has(t)||VE.set(t,{keys:[],sourceId:e});const g=VE.get(t);((i=g?.keys)==null?void 0:i.includes(A))==!1&&g.keys.push(A)}const lo=class{constructor(t,A,e){n(this,"parser"),n(this,"sourceId"),n(this,"context"),this.parser=t,this.sourceId=A,this.context=e}get name(){return ZE}static getMeshLODInformation(t){const A=this.getAssignedLODInformation(t);return A!=null&&A.key?this.lodInfos.get(A.key):null}static hasLODLevelAvailable(t,A){var e;if(t instanceof Re){for(const I of Object.keys(t)){const o=t[I];if(o instanceof le&&this.hasLODLevelAvailable(o,A))return!0}return!1}else if(t instanceof pI){for(const I of t.children)if(I instanceof hA&&this.hasLODLevelAvailable(I,A))return!0}let i,g;if(t instanceof hA?i=t.geometry:t instanceof le&&(i=t),i&&(e=i?.userData)!=null&&e.LODS){const I=i.userData.LODS;if(g=this.lodInfos.get(I.key),A===void 0)return g!=null;if(g)return Array.isArray(g.lods)?A<g.lods.length:A===0}return!1}static assignMeshLOD(t,A,e,i){if(!e)return Promise.resolve(null);if(e instanceof hA){const g=e.geometry,I=this.getAssignedLODInformation(g);if(!I)return Promise.resolve(null);Yl(e)||ry(e,e.geometry);const o=this.onProgressiveLoadStart(t,A,e,null);return e["LOD:requested level"]=i,lo.getOrLoadLOD(t,A,g,i).then(s=>{if(e["LOD:requested level"]===i){if(delete e["LOD:requested level"],Array.isArray(s)){const C=I.index||0;s=s[C]}s&&g!=s&&(nI=="verbose"&&console.log("Progressive Mesh "+e.name+" loaded",g,"\u2192",s,`
|
|
5508
|
+
`))}for(const f of G){const N=I.get(f);N&&K.set(f,N)}return K},E=function(G){const K=Q(G),f=C(K);return a(K,f,G)};const h=g.skinnedMesh.skeleton,d=new Array;for(const G in h.bones){const K=h.bones[G],f=h.boneInverses[G];d.push({bone:K,inverse:f})}for(const G of KL(h.bones))d.push({bone:G,inverse:G.matrixWorld.clone().invert()});const l=d[0].bone.parent;l||console.error("No bone parent found for skinned mesh during USDZ export",g.skinnedMesh),d.sort((G,K)=>hE(G.bone,l)>hE(K.bone,l)?1:-1);const c=[],p=[],u=[],D=[];for(const{bone:G}of d)c.push(G.matrix.clone()),p.push(G.position),u.push(G.quaternion),D.push(G.scale);const k=d.map(G=>'"'+hE(G.bone,l)+'"').join(", "),U=d.map(G=>cE(G.inverse.clone().invert())).join(", ");A.beginBlock('def Skeleton "Rig"'),A.appendLine(`uniform matrix4d[] bindTransforms = [${U}]`),A.appendLine(`uniform token[] joints = [${k}]`),A.appendLine('uniform token purpose = "guide"'),A.appendLine(`uniform matrix4d[] restTransforms = [${c.map(G=>cE(G)).join(", ")}]`),A.appendLine(`matrix4d xformOp:transform = ${cE(new MA)}`),A.appendLine('uniform token[] xformOpOrder = ["xformOp:transform"]');const M=E(d.map(G=>G.bone));if(EC){let G=1e7,K=0;for(const f of((i=M.position)==null?void 0:i.keys())??[])G=Math.min(G,f),K=Math.max(K,f);console.log("Time samples",G,K,M)}if(A.beginBlock('def SkelAnimation "_anim"'),A.appendLine(`uniform token[] joints = [${k}]`),A.appendLine(`quatf[] rotations = [${B(u)}]`),M&&M.quaternion){A.beginBlock("quatf[] rotations.timeSamples = {","");const G=s(M.quaternion);for(const K of G)A.appendLine(K);A.closeBlock()}if(A.appendLine(`half3[] scales = [${r(D)}]`),M&&M.scale){A.beginBlock("half3[] scales.timeSamples = {","");const G=o(M.scale);for(const K of G)A.appendLine(K);A.closeBlock()}if(A.appendLine(`float3[] translations = [${r(p)}]`),M&&M.position){A.beginBlock("float3[] translations.timeSamples = {","");const G=o(M.position);for(const K of G)A.appendLine(K);A.closeBlock()}A.closeBlock(),A.closeBlock()}}onSerialize(A,e){var i;if(!this.model)return;const g=this.dict.get(this.object);if(g)for(let B=0;B<g.length;B++)g[B]===void 0&&(g[B]=new cg(null,this.object,null));this.skinnedMeshExport(A,e);const I=this.object,o=this.dict.get(I);if(!o||I.isSkinnedMesh)return;wR&&console.log("SERIALIZE",this.model.name,this.object.type,o);const s=new MA;A.appendLine("matrix4d xformOp:transform.timeSamples = {"),A.indent++;const C=new Array;let a=0;for(let B=0;B<o.length;B++){if(C.push(a),o[B]===void 0){console.error("Got an undefined transform data, this is likely a bug.",I,o);continue}a+=o[B].getDuration()+cg.animationDurationPadding}const r=Intl.NumberFormat("en-US",{maximumFractionDigits:3,minimumFractionDigits:0,useGrouping:!1});for(let B=0;B<o.length;B++){const Q=o[B];if(!Q)continue;const E=C[B];{const h=Q.getSortedTimesArray();if(!h||h.length===0){console.error("got an animated object but no time values?",I,Q);continue}{const d=((i=Q.clip)==null?void 0:i.name)??"rest",l=Q.getDuration();EC&&console.log("Write .timeSamples:",d,E,l,o),A.appendLine("# "+d+": start="+r.format(E*Q.frameRate)+", length="+r.format(l*Q.frameRate)+", frames="+Q.getFrames())}for(const{time:d,translation:l,rotation:c,scale:p}of Q.getValues(h)){s.compose(l,c,p);const u=`${r.format((E+d)*Q.frameRate)}: ${cE(s)},`;A.appendLine(u)}}}A.indent--,A.appendLine("}")}}var LgA=Object.defineProperty,YgA=Object.getOwnPropertyDescriptor,o2=(t,A,e,i)=>{for(var g=i>1?void 0:i?YgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&LgA(A,e,g),g};const s2=tA("debugpost");class Ne{constructor(A){n(this,"_active",!0),n(this,"_value"),n(this,"_valueRaw"),n(this,"_defaultValue"),n(this,"valueProcessor"),n(this,"onValueChanged"),this._value=A,this._defaultValue=A,this._valueRaw=A}get overrideState(){return this._active}set overrideState(A){if(this._active===A)return;this._active=A;const e=A?this._valueRaw:this._defaultValue;this.processValue(e,!0)}get value(){return this._valueRaw}set value(A){this.processValue(A,!1)}set defaultValue(A){this._defaultValue=A}__init(){this.processValue(this._valueRaw,!0)}processValue(A,e){if(A==null||!e&&this.testIfValueChanged(A)===!1)return;const i=this._value;if(s2){let g=!0;if(typeof i=="number"&&typeof A=="number"){const I=i?.toFixed(4),o=A?.toFixed(4);I!=o?g=!0:g=!1}g&&console.log("VolumeParameter: value changed from",i,"to",A)}!this._active&&this._defaultValue!==void 0?(this._value=this._defaultValue,A=this._defaultValue,this._valueRaw=A):(this._valueRaw=A,this._active&&this.valueProcessor&&(A=this.valueProcessor(A)),this._value=A),this.onValueChanged?this.onValueChanged(A,i,this):s2&&console.log("VolumeParameter: onValueChanged not set")}testIfValueChanged(A){return this._valueRaw!==A}}o2([w()],Ne.prototype,"overrideState",1),o2([w()],Ne.prototype,"value",1);var _gA=Object.defineProperty,HgA=Object.getOwnPropertyDescriptor,TgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?HgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&_gA(A,e,g),g};const OgA=tA("debugpost");class aI extends FA{constructor(A=void 0){if(super(),n(this,"active",!0),n(this,"_result"),n(this,"_didCreateVolumeParameters",!1),A){this.ensureVolumeParameters();for(const e of Object.keys(A)){const i=A[e],g=this[e];g instanceof Ne&&(g.value=i)}}}onEnable(){this.__internalDidAwakeAndStart&&(this.active=!0)}onDisable(){this.active=!1}init(){}apply(){var A;return this.ensureVolumeParameters(),this._result||(this._result=(A=this.onCreateEffect)==null?void 0:A.call(this)),this._result&&this.initParameters(),this._result}unapply(){}dispose(){OgA&&console.warn("DISPOSE",this),this._result&&(Array.isArray(this._result)?this._result.forEach(A=>A.dispose()):this._result.dispose()),this._result=void 0}initParameters(){const A=Object.keys(this);for(const e of A){const i=this[e];i instanceof Ne&&i.__init()}}onAfterDeserialize(A,e){if(typeof A=="object"){const i=this.$serializedTypes;if(i){for(const g of Object.keys(i))if(i[g]===Ne){const I=A[g];if(I!==void 0){const o=this[g];o.value=I}}}}}onEditorModification(A){const e=A.propertyName;if(this[e]instanceof Ne){const i=A.value;return this[e].value=i,!0}}ensureVolumeParameters(){if(this._didCreateVolumeParameters)return;this._didCreateVolumeParameters=!0;const A=this.$serializedTypes;if(A)for(const e of Object.keys(A))A[e]===Ne&&(this[e]||(this[e]=new Ne))}}TgA([w()],aI.prototype,"active",2);var PgA=Object.defineProperty,jgA=Object.getOwnPropertyDescriptor,WgA=(t,A,e,i)=>{for(var g=i>1?void 0:i?jgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&PgA(A,e,g),g};const ZgA=tA("debugpost"),yR={};function ts(t,A){yR[t]=A}function VgA(t){return t.__type in yR?yR[t.__type]:(ZgA&&t.__type&&console.warn("Unknown postprocessing type",t.__type,t),aI)}class Qd{constructor(){n(this,"components",[])}init(){var A;(A=this.components)==null||A.forEach(e=>e.init())}}WgA([dE([t=>VgA(t),aI])],Qd.prototype,"components",2);var zgA=Object.defineProperty,XgA=Object.getOwnPropertyDescriptor,$gA=(t,A,e,i)=>{for(var g=i>1?void 0:i?XgA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&zgA(A,e,g),g};class Ed extends aI{constructor(){super(...arguments),n(this,"preset")}get typeName(){return"Antialiasing"}onCreateEffect(){const A=new HY({preset:DE.HIGH,edgeDetectionMode:$M.DEPTH});return this.preset.onValueChanged=e=>{A.applyPreset(e)},A}}$gA([w(Ne)],Ed.prototype,"preset",2),ts("Antialiasing",Ed);const AIA=tA("debugusdz");class rr{constructor(){n(this,"files",new Array)}static getName(A){var e;const i=A.split(".").pop();let g=(e=A.split(".").slice(0,-1).join(".").split("/").pop())==null?void 0:e.replace(".","_");return g||(g="Audio_"+Math.random().toString(36).substring(2,15)),Ms(g)+"."+i}get extensionName(){return"Audio"}onExportObject(A,e,i){const g=CA.getComponents(A,ai);if(g.length)for(const I of g){if(!I.clip||typeof I.clip!="string"||!I.playOnAwake)continue;const o=I.clip.split("/").pop()||"Audio",s=rr.getName(I.clip),C=Ms(s);this.files.some(a=>a.path===I.clip)||this.files.push({path:I.clip,name:s}),i.quickLookCompatible||e.addEventListener("serialize",(a,r)=>{a.appendLine(),a.beginBlock(`def SpatialAudio "${C}"`,"(",!1),a.appendLine(`displayName = "${o}"`),a.closeBlock(")"),a.beginBlock(),a.appendLine(`uniform asset filePath = @audio/${s}@`),a.appendLine(`uniform token auralMode = "${I.spatialBlend>0?"spatial":"nonSpatial"}"`),a.appendLine(`uniform token playbackMode = "${I.loop?"loopFromStage":"onceFromStart"}"`),a.appendLine(`uniform float gain = ${I.volume}`),a.closeBlock()})}}async onAfterSerialize(A){for(const e of this.files){const i="audio/"+e.name;if(A.files[i]){AIA&&console.warn("Audio file with name "+i+" already exists in the context. Skipping.");continue}const g=await(await(await fetch(e.path)).blob()).arrayBuffer(),I=new Uint8Array(g);A.files[i]=I}}}const fB=tA("debugautosync"),SR=Symbol("syncerId");class eIA{constructor(){n(this,"_syncers",{})}getOrCreateSyncer(A){if(!A.guid)return null;if(this._syncers[A.guid])return this._syncers[A.guid];const e=new tIA(A);return e[SR]=A.guid,this._syncers[e[SR]]=e,e}removeSyncer(A){delete this._syncers[A[SR]]}}const fR=new eIA;class tIA{constructor(A){n(this,"comp"),n(this,"hasChanges",!1),n(this,"changedProperties",{}),n(this,"data",{}),n(this,"_isReceiving",!1),n(this,"_isInit",!1),n(this,"onHandleSending",()=>{if(!this.hasChanges)return;this.hasChanges=!1;const e=this.comp.context.connection;if(!e||!e.isConnected||!e.isInRoom){for(const i in this.changedProperties)delete this.changedProperties[i];return}for(const i in this.data)delete this.data[i];this.data.guid=this.comp.guid;for(const i in this.changedProperties){const g=this.changedProperties[i];delete this.changedProperties[i],this.data[i]=g}e.send(this.networkingKey,this.data,Wo.Queued)}),n(this,"onHandleReceiving",e=>{if(fB&&console.log("RECEIVE",this.comp.name,this.comp.guid,e),!this._isInit||!this.comp)return;const i=e.guid;if(!(i&&i!==this.comp.guid)){fB&&console.log("RECEIVED",this.comp.name,this.comp.guid,e);try{this._isReceiving=!0;for(const g in e){if(g==="guid")continue;const I=e[g];this.comp[g]=I,fB&&console.log("SET",g,I)}}catch(g){console.error(g)}finally{this._isReceiving=!1}}}),this.comp=A}get networkingKey(){return this.comp.guid}init(A){if(this._isInit)return;this._isInit=!0,this.comp=A,this.comp.context.post_render_callbacks.push(this.onHandleSending),this.comp.context.connection.beginListen(this.networkingKey,this.onHandleReceiving);const e=this.comp.context.connection.tryGetState(this.comp.guid);e&&this.onHandleReceiving(e)}destroy(){this._isInit&&(this.comp.context.post_render_callbacks.splice(this.comp.context.post_render_callbacks.indexOf(this.onHandleSending),1),this.comp.context.connection.stopListen(this.networkingKey,this.onHandleReceiving),this.comp=null,this._isInit=!1)}notifyChanged(A,e){this._isReceiving||(fB&&console.log("Property changed: "+A,e),this.hasChanges=!0,this.changedProperties[A]=e)}}function iIA(t,A){let e=A!==t;return!e&&t&&A&&(Array.isArray(t)&&Array.isArray(A)||typeof t=="object"&&typeof A=="object")&&(e=!0),e}const hd=Symbol("AutoSyncHandler");function gIA(t){if(t[hd])return t[hd];const A=fR.getOrCreateSyncer(t);return A?.init(t),t[hd]=A,A}function IIA(t){const A=t[hd];A&&(fR.removeSyncer(A),A.destroy(),delete t[hd])}const mR=function(t){return function(A,e){var i;let g="";typeof e=="string"?g=e:g=e.name;let I=null,o;typeof t=="string"?o=A[t]:typeof t=="function"&&(o=t);const s=A,C=s.__internalAwake;if(typeof C!="function"){(fB||re())&&console.error('@syncField can currently only used on Needle Engine Components, custom object of type "'+((i=A?.constructor)==null?void 0:i.name)+'" is not supported',A);return}fB&&console.log(g);const a=Symbol(g);s.__internalAwake=function(){if(this[a]!==void 0)return;this[a]=this[g],I=fR.getOrCreateSyncer(this);const B=Object.getOwnPropertyDescriptor(this,g);if(B?.set===void 0){let Q=!1;Object.defineProperty(this,g,{set:function(E){var h;const d=this[a];if(this[a]=E,Q){re()&&console.warn("Recursive call detected",g);return}Q=!0;try{const l=iIA(E,d);fB&&console.log("SyncField assignment",g,"changed?",l,E),l&&o?.call(this,E,d)!==!1&&((h=gIA(this))==null||h.notifyChanged(g,E))}finally{Q=!1}},get:function(){return this[a]},configurable:!0,enumerable:!0})}I?.init(this),C.call(this)};const r=s.__internalDestroy;s.__internalDestroy=function(){IIA(this),r.call(this)}}};var oIA=Object.defineProperty,sIA=Object.getOwnPropertyDescriptor,Py=(t,A,e,i)=>{for(var g=i>1?void 0:i?sIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&oIA(A,e,g),g};const ho=tA("debugplayersync");class TE extends FA{constructor(){super(...arguments),n(this,"autoSync",!0),n(this,"asset"),n(this,"onPlayerSpawned"),n(this,"_localInstance"),n(this,"onJoinedRoom",()=>{ho&&console.log("PlayerSync.joinedRoom. autoSync is set to "+this.autoSync),this.autoSync&&this.getInstance()})}awake(){this.watchTabVisible(),this.onPlayerSpawned||(this.onPlayerSpawned=new tg)}onEnable(){this.context.connection.beginListen(At.RoomStateSent,this.onJoinedRoom),this.context.connection.beginListen(At.JoinedRoom,this.onJoinedRoom),this.context.connection.isInRoom&&this.onJoinedRoom()}onDisable(){this.context.connection.stopListen(At.RoomStateSent,this.onJoinedRoom),this.context.connection.stopListen(At.JoinedRoom,this.onJoinedRoom)}async getInstance(){var A,e,i,g,I,o;if(this._localInstance)return this._localInstance;if(ho&&console.log("PlayerSync.createInstance",(A=this.asset)==null?void 0:A.uri),!((e=this.asset)!=null&&e.asset)&&!((i=this.asset)!=null&&i.uri))return console.error('PlayerSync: can not create an instance because "asset" is not set!'),null;this._localInstance=(g=this.asset)==null?void 0:g.instantiateSynced({parent:this.gameObject},!0);const s=await this._localInstance;if(s){const C=CA.getComponent(s,is);C?(C.owner=this.context.connection.connectionId,(I=this.onPlayerSpawned)==null||I.invoke(s)):(this._localInstance=void 0,console.error("<strong>Failed finding PlayerState on "+((o=this.asset)==null?void 0:o.uri)+"</strong>: please make sure the asset has a PlayerState component!"),CA.destroySynced(s))}else this._localInstance=void 0,console.warn("PlayerSync: failed instantiating asset!");return this._localInstance}destroyInstance(){var A;(A=this._localInstance)==null||A.then(e=>(ho&&console.log("PlayerSync.destroyInstance",e),CA.destroySynced(e))),this._localInstance=void 0}watchTabVisible(){window.addEventListener("visibilitychange",A=>{if(document.visibilityState==="visible")for(let e=is.all.length-1;e>=0;e--){const i=is.all[e];(!i.owner||!this.context.connection.userIsInRoom(i.owner))&&i.doDestroy()}})}}Py([w()],TE.prototype,"autoSync",2),Py([w(tt)],TE.prototype,"asset",2),Py([w(tg)],TE.prototype,"onPlayerSpawned",2);var C2=(t=>(t.OwnerChanged="ownerChanged",t))(C2||{}),cd;const xg=(cd=class extends FA{constructor(){super(...arguments),n(this,"onOwnerChangeEvent",new tg),n(this,"onFirstOwnerChangeEvent",new tg),n(this,"hasOwner",!1),n(this,"owner"),n(this,"dontDestroy",!1),n(this,"onUserLeftRoom",t=>{if(t.userId===this.owner){ho&&console.log("PLAYERSYNC LEFT",this.owner),this.doDestroy();return}})}static get all(){return xg._all}static get local(){return xg._local}static getFor(t){if(t instanceof uA)return CA.getComponentInParent(t,xg);if(t instanceof FA)return CA.getComponentInParent(t.gameObject,xg)}static isLocalPlayer(t){const A=xg.getFor(t);return A?.isLocalPlayer??!1}static addEventListener(t,A){return this._callbacks[t]||(this._callbacks[t]=[]),this._callbacks[t].push(A),A}static removeEventListener(t,A){if(!this._callbacks[t])return;const e=this._callbacks[t].indexOf(A);e>=0&&this._callbacks[t].splice(e,1)}static dispatchEvent(t,A){if(this._callbacks[t])for(const e of this._callbacks[t])e(A)}get isLocalPlayer(){return this.owner===this.context.connection.connectionId}onOwnerChange(t,A){var e,i;ho&&console.log("PlayerSync.onOwnerChange",this,"newOwner",t,"oldOwner",A);const g=xg._local.indexOf(this);g>=0&&xg._local.splice(g,1);const I={playerState:this,oldValue:A,newValue:t};if(this.hasOwner||(this.hasOwner=!0,(e=this.onFirstOwnerChangeEvent)==null||e.invoke(I)),(i=this.onOwnerChangeEvent)==null||i.invoke(I),this.owner===this.context.connection.connectionId){xg._local.push(this);const s=new CustomEvent("local-owner-changed",{detail:I});this.dispatchEvent(s)}const o=new CustomEvent("owner-changed",{detail:I});this.dispatchEvent(o),xg.dispatchEvent("ownerChanged",o)}awake(){xg.all.push(this),ho&&console.log("Registered new PlayerState",this.guid,xg.all.length-1,xg.all),this.context.connection.beginListen(At.UserLeftRoom,this.onUserLeftRoom)}async start(){ho&&console.log("PLAYERSTATE.START, owner: "+this.owner,this.context.connection.usersInRoom([])),this.owner?(this.context.connection.isInRoom||await ws(300),this.context.connection.userIsInRoom(this.owner)==!1&&(ho&&console.log(`PlayerSync.start \u2192 doDestroy "${this.name}" because user "${this.owner}" is not in room anymore...`,"Currently in room:",...this.context.connection.usersInRoom()),this.doDestroy())):this.owner||(ho&&console.warn("PlayerState.start \u2192 owner is undefined!",this.name),setTimeout(()=>{!this.destroyed&&!this.owner?this.dontDestroy?ho&&console.warn("PlayerState.start \u2192 owner is still undefined but dontDestroy is set to true",this.name):(ho&&console.warn(`PlayerState.start \u2192 owner is still undefined: destroying "${this.name}" instance now`),this.doDestroy()):ho&&console.log("PlayerState.start \u2192 owner is assigned",this.owner)},2e3))}doDestroy(){ho&&console.log("PlayerSync.doDestroy \u2192 syncDestroy",this.name),py(this.gameObject,this.context.connection)}onDestroy(){if(this.context.connection.stopListen(At.UserLeftRoom,this.onUserLeftRoom),xg.all.splice(xg.all.indexOf(this),1),this.isLocalPlayer){const t=xg._local.indexOf(this);t>=0&&xg._local.splice(t,1)}}},n(cd,"_all",[]),n(cd,"_local",[]),n(cd,"_callbacks",{}),cd);let is=xg;Py([mR(is.prototype.onOwnerChange)],is.prototype,"owner",2);const CIA=tA("debugavatar"),hC=class extends FA{constructor(){super(...arguments),n(this,"connectionId"),n(this,"avatar")}static getAvatar(t){return t>=0&&t<hC.instances.length?hC.instances[t]:null}static onAvatarMarkerCreated(t){return hC._onNewAvatarMarkerAdded.push(t),t}static onAvatarMarkerDestroyed(t){return hC._onAvatarMarkerDestroyed.push(t),t}awake(){hC.instances.push(this),CIA&&console.log(this);for(const t of hC._onNewAvatarMarkerAdded)t({avatarMarker:this,gameObject:this.gameObject})}onDestroy(){hC.instances.splice(hC.instances.indexOf(this),1);for(const t of hC._onAvatarMarkerDestroyed)t({avatarMarker:this,gameObject:this.gameObject})}isLocalAvatar(){return this.connectionId===this.context.connection.connectionId}};let Lg=hC;n(Lg,"instances",[]),n(Lg,"_onNewAvatarMarkerAdded",[]),n(Lg,"_onAvatarMarkerDestroyed",[]);var aIA=Object.defineProperty,nIA=Object.getOwnPropertyDescriptor,rIA=(t,A,e,i)=>{for(var g=i>1?void 0:i?nIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&aIA(A,e,g),g};const OE=tA("debugxrflags"),a2=tA("disablexrflags");a2&&console.warn("XRFlags are disabled");var cC=(t=>(t[t.Never=0]="Never",t[t.Browser=1]="Browser",t[t.AR=2]="AR",t[t.VR=4]="VR",t[t.FirstPerson=8]="FirstPerson",t[t.ThirdPerson=16]="ThirdPerson",t[t.All=4294967295]="All",t))(cC||{});const n2=class{constructor(){n(this,"Mask",17)}Has(t){return(this.Mask&t)!==0}Set(t){OE&&console.warn("Set XR flag state to",t),this.Mask=t,co.Apply()}Enable(t){this.Mask|=t,co.Apply()}Disable(t){this.Mask&=~t,co.Apply()}Toggle(t){this.Mask^=t,co.Apply()}EnableAll(){this.Mask=-1,co.Apply()}DisableAll(){this.Mask=0,co.Apply()}};let NI=n2;n(NI,"Global",new n2);var ld;const Da=(ld=class extends FA{constructor(){super(...arguments),n(this,"visibleIn")}static Apply(){for(const t of this.registry)t.UpdateVisible(NI.Global)}awake(){Da.registry.push(this)}onEnable(){Da.firstApply?this.UpdateVisible(NI.Global):(Da.firstApply=!0,Da.Apply())}onDestroy(){const t=Da.registry.indexOf(this);t>=0&&Da.registry.splice(t,1)}get isOn(){return this.gameObject.visible}UpdateVisible(t=null){if(a2)return;let A;const e=t;if(e&&typeof e=="number"&&(console.assert(typeof e=="number","XRFlag.UpdateVisible: state must be a number",e),OE&&console.log(e),Da.buffer.Mask=e,t=Da.buffer),t instanceof NI?(OE&&console.warn(this.name,"use passed in mask",t.Mask,this.visibleIn),A=t.Has(this.visibleIn)):(OE&&console.log(this.name,"use global mask"),NI.Global.Has(this.visibleIn)),A!==void 0)if(A)OE&&console.log(this.name,"is visible",this.gameObject.uuid),CA.setActive(this.gameObject,!0);else{if(OE&&console.log(this.name,"is not visible",this.gameObject.uuid),!this.gameObject.visible)return;this.gameObject.visible=!1}}},n(ld,"registry",[]),n(ld,"firstApply"),n(ld,"buffer",new NI),ld);let co=Da;rIA([w()],co.prototype,"visibleIn",2);var BIA=Object.defineProperty,QIA=Object.getOwnPropertyDescriptor,kR=(t,A,e,i)=>{for(var g=i>1?void 0:i?QIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&BIA(A,e,g),g};const dd=tA("debugwebxr"),r2=new RA().setFromAxisAngle(new S(0,1,0),Math.PI);class mB extends FA{constructor(){super(...arguments),n(this,"head"),n(this,"leftHand"),n(this,"rightHand"),n(this,"_syncTransforms")}async onEnterXR(A){if(!this.activeAndEnabled)return;dd&&console.warn("AVATAR ENTER XR",this.guid,this.sourceId,this,this.activeAndEnabled),this._syncTransforms&&(this._syncTransforms.length=0),await this.prepareAvatar();const e=is.getFor(this);if(e!=null&&e.owner){const i=this.gameObject.addNewComponent(Lg);i.avatar=this.gameObject,i.connectionId=e.owner}else this.context.connection.isConnected?console.error("No player state found for avatar",this):e&&!this.context.connection.isConnected&&(e.dontDestroy=!0)}onLeaveXR(A){const e=this.gameObject.getComponent(Lg);e&&e.destroy()}onUpdateXR(A){var e,i;if(!this.activeAndEnabled)return;const g=is.isLocalPlayer(this);if(!g)return;const I=A.xr;if(I.rig&&I.rig.gameObject!==this.gameObject.parent&&(this.gameObject.position.set(0,0,0),this.gameObject.rotation.set(0,0,0),this.gameObject.scale.set(1,1,1),I.rig.gameObject.add(this.gameObject)),this._syncTransforms&&g)for(const a of this._syncTransforms)a.fastMode=!0,a.isOwned()||a.requestOwnership();if(this.head&&this.context.mainCamera){const a=this.head.asset;if(a.position.copy(this.context.mainCamera.position),a.quaternion.copy(this.context.mainCamera.quaternion),a.quaternion.x*=-1,this.context.time.frameCount%10===0){const r=CA.getComponentsInChildren(this.head.asset,co);for(const B of r)B.enabled=!1,B.gameObject.visible=!1}}const o=A.xr.leftController,s=(e=this.leftHand)==null?void 0:e.asset;o&&s&&(s.position.copy(o.gripPosition),s.quaternion.copy(o.gripQuaternion),s.quaternion.multiply(r2),s.visible=o.isTracking);const C=A.xr.rightController;if(C&&(i=this.rightHand)!=null&&i.asset){const a=this.rightHand.asset;a.position.copy(C.gripPosition),a.quaternion.copy(C.gripQuaternion),a.quaternion.multiply(r2),a.visible=C.isTracking}}onBeforeRender(){this.context.time.frame%10===0&&this.updateRemoteAvatarVisibility()}updateRemoteAvatarVisibility(){var A,e,i;if(this.context.connection.isConnected){const g=is.getFor(this);if(g&&g.isLocalPlayer==!1){const I=we.getXRSync(this.context);if(I&&I.hasState(g.owner)){this.tryFindAvatarObjectsIfMissing();const o=(A=this.leftHand)==null?void 0:A.asset;o&&(o.visible=I?.isTracking(g.owner,"left")??!1);const s=(e=this.rightHand)==null?void 0:e.asset;s&&(s.visible=I?.isTracking(g.owner,"right")??!1)}if((i=this.head)!=null&&i.asset){const o=CA.getComponentsInChildren(this.head.asset,co);for(const s of o)s.enabled=!1,s.gameObject.visible=!0}}}}tryFindAvatarObjectsIfMissing(){if(!this.head||!this.leftHand||!this.rightHand){const A={head:this.head,leftHand:this.leftHand,rightHand:this.rightHand};HH.tryFindAvatarObjects(this.gameObject,this.sourceId||"",A),A.head&&(this.head=A.head),A.leftHand&&(this.leftHand=A.leftHand),A.rightHand&&(this.rightHand=A.rightHand)}}async prepareAvatar(){if(this.tryFindAvatarObjectsIfMissing(),this.head)this.head instanceof uA&&(this.head=new tt("",this.sourceId,this.head));else{const A=new uA;A.name="Head";const e=ql.createPrimitive(EB.Cube);A.add(e),this.gameObject.add(A),this.head=new tt("",this.sourceId,A),dd&&console.log("Create head",A)}if(this.rightHand)this.rightHand instanceof uA&&(this.rightHand=new tt("",this.sourceId,this.rightHand));else{const A=new uA;A.name="Right Hand",this.gameObject.add(A),this.rightHand=new tt("",this.sourceId,A),dd&&console.log("Create right hand",A)}if(this.leftHand)this.leftHand instanceof uA&&(this.leftHand=new tt("",this.sourceId,this.leftHand));else{const A=new uA;A.name="Left Hand",this.gameObject.add(A),this.leftHand=new tt("",this.sourceId,A),dd&&console.log("Create left hand",A)}await this.loadAvatarObjects(this.head,this.leftHand,this.rightHand),is.isLocalPlayer(this.gameObject)&&(this._syncTransforms=CA.getComponentsInChildren(this.gameObject,bn))}async loadAvatarObjects(A,e,i){const g=A.loadAssetAsync(),I=e.loadAssetAsync(),o=i.loadAssetAsync(),s=new Array;g&&s.push(g),I&&s.push(I),o&&s.push(o);const C=await Yc(s);dd&&console.log("Avatar loaded results:",C)}}kR([w(tt)],mB.prototype,"head",2),kR([w(tt)],mB.prototype,"leftHand",2),kR([w(tt)],mB.prototype,"rightHand",2);class lC{static Add(A,e,i=null){if(e){for(const g of this.Pois)if(g.obj===e)return;this.Pois.push({obj:e,avatar:i}),this.LastChangeTime=A.time.time}}static Remove(A,e){var i;if(e){for(const g of this.Pois)if(g.obj===e){this.Pois.splice(this.Pois.indexOf(g),1),this.LastChangeTime=A?.time.time??((i=be.Current)==null?void 0:i.time.time);return}}}}n(lC,"Pois",[]),n(lC,"LastChangeTime",0);class EIA{constructor(){n(this,"guid"),n(this,"position",new S)}}class pd extends FA{constructor(){super(...arguments),n(this,"target",null),n(this,"avatar",null),n(this,"_model",null),n(this,"_targetModel",new EIA),n(this,"_currentTargetObject",null),n(this,"_lastUpdateTime",0),n(this,"_lookDuration",0),n(this,"_lastPoiChangedTime",0)}set controlledTarget(A){this.target=A;const e=W.get("MoveRandom");if(e&&this.target){const i=CA.getComponent(this.target,e);i&&i.destroy()}}awake(){if(this.avatar=CA.getComponentInParent(this.gameObject,Lg),this.avatar){const A=CA.getComponentInParent(this.gameObject,Lg);this._model=new HU(this.context.connection,this.guid),A!=null&&A.isLocalAvatar&&this._model.requestOwnership()}this.context.connection.beginListen("avatar-look-target-changed",A=>{var e;this.target&&A&&A.guid===((e=this.avatar)==null?void 0:e.guid)&&gI(this.target,A.position)})}update(){var A;if((!this.context.connection.isConnected||(A=this._model)!=null&&A.hasOwnership)&&(lC.LastChangeTime!==this._lastPoiChangedTime&&(this._lastPoiChangedTime=lC.LastChangeTime,this._lookDuration=0),this.selectTarget(),this._currentTargetObject&&this.context.time.frameCount%10===0&&this.target)){const e=Fe(this._currentTargetObject);gI(this.target,e),this.context.connection.isConnected&&this.avatar&&(this.context.connection.send("avatar-look-target-changed",this._targetModel),this._targetModel.guid=this.avatar.guid,this._targetModel.position.copy(e))}}selectTarget(){if(this.context.time.time-this._lastUpdateTime>this._lookDuration){this._lastUpdateTime=this.context.time.time,this._lookDuration=Math.random()*.5+.2;const A=lC.Pois;if(A.length>0){const e=A[Math.floor(Math.random()*A.length)];if(e&&e.obj){if(e.avatar&&e.avatar===this.avatar)return;this._currentTargetObject=e.obj}}}}}const PE=tA("debugnetworkingstreams");var dC=(t=>(t.Connected="peer-user-connected",t.StreamReceived="receive-stream",t.StreamEnded="call-ended",t.Disconnected="peer-user-disconnected",t.UserJoined="user-joined",t))(dC||{});class B2{constructor(A,e){n(this,"type","call-ended"),n(this,"userId"),n(this,"direction"),this.userId=A,this.direction=e}}class Q2{constructor(A,e){n(this,"type","receive-stream"),n(this,"stream"),n(this,"target"),this.stream=A,this.target=e}}class hIA{constructor(A,e){n(this,"guid"),n(this,"peerId"),n(this,"dontSave",!0),this.guid=A.id,this.peerId=e}}var E2=(t=>(t.Incoming="incoming",t.Outgoing="outgoing",t))(E2||{});class cIA extends ag{constructor(A,e,i){super(),n(this,"userId"),n(this,"direction"),n(this,"call"),n(this,"_stream",null),n(this,"_isDisposed",!1),this.userId=A,this.call=e,this.direction=i,this._stream=null,e.on("stream",g=>{if(PE&&console.log("Receive video",g.getAudioTracks(),g.getVideoTracks()),this._stream=g,i==="incoming"){const I=new Q2(g,this);this.dispatchEvent(I)}}),e.on("close",()=>{this.dispatchEvent(new B2(A,i))})}get stream(){return this._stream}close(){this._isDisposed||(this._isDisposed=!0,this.call.close(),wa(this._stream))}get isOpen(){var A;return((A=this.call.peerConnection)==null?void 0:A.connectionState)==="connected"}get isOpening(){var A;return((A=this.call.peerConnection)==null?void 0:A.connectionState)==="connecting"}get isClosed(){return!this.isOpen}}const ud=class extends ag{constructor(t,A){super(),n(this,"id"),n(this,"context"),n(this,"_peer"),n(this,"_incomingCalls",[]),n(this,"_outgoingCalls",[]),n(this,"_enabled",!1),n(this,"_enabledPeer",!1),n(this,"onConnectRoomFn",this.onConnectRoom.bind(this)),n(this,"onPeerConnectFn",this.onPeerConnect.bind(this)),n(this,"onPeerReceiveCallFn",this.onPeerReceivingCall.bind(this)),this.context=t,this.id=A,this.setupPeer(),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia}static getOrCreate(t,A){if(ud.instances.has(A))return ud.instances.get(A);const e=new ud(t,A);return ud.instances.set(A,e),e}getMyPeerId(){if(this.context.connection.connectionId)return this.getPeerIdFromUserId(this.context.connection.connectionId)}getPeerIdFromUserId(t){return this.id+"-"+t}getUserIdFromPeerId(t){return t.substring(this.id.length+1)}makeCall(t,A){var e;const i={metadata:{userId:this.context.connection.connectionId}},g=(e=this._peer)==null?void 0:e.call(t,A,i);if(g)return this.registerCall(g,"outgoing")}get peer(){return this._peer}enable(){this._enabled||(this._enabled=!0,this.context.connection.beginListen(At.JoinedRoom,this.onConnectRoomFn),this.subscribePeerEvents())}disable(){this._enabled&&(this._enabled=!1,this.context.connection.stopListen(At.JoinedRoom,this.onConnectRoomFn),this.unsubscribePeerEvents())}onConnectRoom(){this.setupPeer()}setupPeer(){if(this.context.connection.connectionId&&!this._enabledPeer){if(this._enabledPeer=!0,!this._peer){const t=this.getMyPeerId();t?this._peer=RH(t):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(t){PE&&console.log("Peer connected as",t),this.context.connection.send("peer-user-connected",new hIA(this,t))}onPeerReceivingCall(t){t.answer(),this.registerCall(t,"incoming")}registerCall(t,A){const e=t.metadata;(!e||!e.userId)&&console.error("Missing call metadata",t);const i=e.userId;A==="incoming"&&PE?console.log("Receive call from",t.metadata):PE&&console.log("Make call to",t.metadata);const g=A==="incoming"?this._incomingCalls:this._outgoingCalls,I=new cIA(i,t,A);return g.push(I),t.on("error",o=>{console.error("Call error",o)}),t.on("close",()=>{PE&&console.log("Call ended",t.metadata),t.close();const o=g.indexOf(I);o!==-1&&g.splice(o,1)}),I.addEventListener("call-ended",o=>{this.dispatchEvent(o)}),A==="incoming"&&(I.addEventListener("receive-stream",o=>{this.dispatchEvent(o)}),t.on("stream",()=>{let o=0;const s=setInterval(()=>{const C=o===0;!I.isOpen&&C&&(o+=1,clearInterval(s),I.close())},2e3)})),I}};let jy=ud;n(jy,"instances",new Map);class Wp extends ag{constructor(A,e){super(),n(this,"context"),n(this,"peer"),n(this,"_sendingStreams",new Map),n(this,"debug",!1),n(this,"onJoinedRoom",i=>{this.debug&&console.log(`${i.userId} joined room and I'm currently sending ${this._sendingStreams.size} streams`),this._sendingStreams.size>0&&this.updateSendingCalls()}),n(this,"onReceiveStream",i=>{this.debug&&console.log("RECEIVE STREAM",i),this.dispatchEvent({type:"receive-stream",target:this,stream:i.stream,userId:i.userId})}),n(this,"onCallEnded",i=>{this.dispatchEvent(i)}),n(this,"onUserConnected",i=>{if(this.peer.id===i.guid){this.debug&&console.log("USER CONNECTED",i.guid,i);const g=this._sendingStreams.keys().next().value;this.peer.makeCall(i.peerId,g)}}),n(this,"onUserLeft",i=>{this.stopCallsToUsersThatAreNotInTheRoomAnymore()}),this.context=A,this.peer=e,PE&&(this.debug=!0)}static create(A){const e=jy.getOrCreate(A.context,A.context.connection.connectionId);return new Wp(A.context,e)}startSendingStream(A){this._sendingStreams.has(A)?console.warn("Received start sending stream with stream that is already being sent"):(this._sendingStreams.set(A,[]),this.updateSendingCalls())}stopSendingStream(A){if(A){const e=this._sendingStreams.get(A);if(e){this.debug&&console.log("Closing calls",e);for(const i of e)i.close()}this._sendingStreams.delete(A),e&&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(At.JoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(At.UserJoinedRoom,this.onJoinedRoom),this.context.connection.beginListen(At.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(At.JoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(At.UserJoinedRoom,this.onJoinedRoom),this.context.connection.stopListen(At.UserLeftRoom,this.onUserLeft)}updateSendingCalls(){var A;let e=!1;const i=this.context.connection.connectionId;for(const g of this._sendingStreams.keys()){const I=this._sendingStreams.get(g)||[];for(const o of this.context.connection.usersInRoom()){if(o===i)continue;const s=I.find(C=>C.userId===o);if(!s||((A=s.stream)==null?void 0:A.active)===!1){this.debug&&console.log("Starting call to",o,i);const C=this.peer.makeCall(this.peer.getPeerIdFromUserId(o),g);C&&(e=!0,I.push(C))}}this._sendingStreams.set(g,I)}this.stopCallsToUsersThatAreNotInTheRoomAnymore(),e&&this.debug&&console.log("Currently sending",this._sendingStreams)}stopCallsToUsersThatAreNotInTheRoomAnymore(){for(const A of this._sendingStreams.keys()){const e=this._sendingStreams.get(A);if(e)for(let i=e.length-1;i>=0;i--){const g=e[i];this.context.connection.userIsInRoom(g.userId)||(g.close(),e.splice(i,1))}}}}function wa(t){if(t&&t instanceof MediaStream)for(const A of t.getTracks())A.stop()}var lIA=Object.defineProperty,dIA=Object.getOwnPropertyDescriptor,h2=(t,A,e,i)=>{for(var g=i>1?void 0:i?dIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&lIA(A,e,g),g};const pIA="noVoip",uIA=tA("debugvoip");class kB extends FA{constructor(){super(...arguments),n(this,"autoConnect",!1),n(this,"runInBackground",!0),n(this,"debug",!1),n(this,"_net"),n(this,"_outputStream",null),n(this,"onJoinedRoom",async()=>{await ws(300),this.autoConnect&&!this.isSending&&this.connect()}),n(this,"_incomingStreams",new Map),n(this,"onReceiveStream",A=>{const e=A.target.userId,i=A.stream,g=this._incomingStreams.get(e);if(g)g.srcObject=i,g.setAttribute("autoplay","true");else{const I=new Audio;this._incomingStreams.set(e,I),I.setAttribute("autoplay","true"),I.srcObject=i}}),n(this,"onStreamEnded",A=>{const e=this._incomingStreams.get(A.userId);wa(e?.srcObject),this._incomingStreams.delete(A.userId)}),n(this,"onEnabledChanged",()=>{for(const A of this._incomingStreams){const e=A[1];e.muted=!this.enabled}}),n(this,"onVisibilityChanged",()=>{if(this.runInBackground)return;const A=document.visibilityState!=="visible";this.setMuted(A);for(const e of this._incomingStreams){const i=e[1];i.muted=A}})}awake(){uIA&&(this.debug=!0),this.debug&&window.addEventListener("keydown",async A=>{A.key==="v"&&(console.log("MUTE?",!this.isMuted),this.setMuted(!this.isMuted))})}onEnable(){this._net||(this._net=Wp.create(this)),this._net.addEventListener(dC.StreamReceived,this.onReceiveStream),this._net.addEventListener(dC.StreamEnded,this.onStreamEnded),this._net.enable(),this.autoConnect&&(this.context.connection.isConnected?this.connect():this.context.connection.beginListen(At.JoinedRoom,this.onJoinedRoom)),this.onEnabledChanged(),window.addEventListener("visibilitychange",this.onVisibilityChanged)}onDisable(){var A;this._net.stopSendingStream(this._outputStream),this._net.removeEventListener(dC.StreamReceived,this.onReceiveStream),this._net.removeEventListener(dC.StreamEnded,this.onStreamEnded),(A=this._net)==null||A.disable(),this.context.connection.stopListen(At.JoinedRoom,this.onJoinedRoom),this.onEnabledChanged(),window.removeEventListener("visibilitychange",this.onVisibilityChanged)}get isSending(){return this._outputStream!=null&&this._outputStream.active}async connect(A){if(this.context.connection.isConnected){if(!await jk())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),wa(this._outputStream),this._outputStream=await this.getAudioStream(A),this._outputStream?(this._net.startSendingStream(this._outputStream),!0):(await jk()?console.error("VOIP: Could not get audio stream - please make sure to connect an audio device and grant microphone permissions"):HG("Microphone permissions not granted: Please grant microphone permissions to use voice chat"),!1)}disconnect(){this._net.stopSendingStream(this._outputStream),wa(this._outputStream),this._outputStream=null}setMuted(A){var e;const i=(e=this._outputStream)==null?void 0:e.getAudioTracks();if(i)for(const g of i)g.enabled=!A}get isMuted(){var A;if(this._outputStream===null)return!1;const e=(A=this._outputStream)==null?void 0:A.getAudioTracks();if(e){for(const i of e)if(!i.enabled)return!0}return!1}getFrequency(A){return this.unsupported_getfrequency||(this.unsupported_getfrequency=!0,re()&&Ci("VOIP: getFrequency is currently not supported"),console.warn("VOIP: getFrequency is currently not supported")),null}async getAudioStream(A){return navigator.mediaDevices.getUserMedia?await navigator.mediaDevices.getUserMedia({audio:A??!0,video:!1}).catch(e=>(console.warn("VOIP failed getting audio stream",e),null)):(console.error("No getDisplayMedia support"),null)}}h2([w()],kB.prototype,"autoConnect",2),h2([w()],kB.prototype,"runInBackground",2);var DIA=Object.defineProperty,wIA=Object.getOwnPropertyDescriptor,c2=(t,A,e,i)=>{for(var g=i>1?void 0:i?wIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&DIA(A,e,g),g};const yIA=tA("debugmouth");class Dd extends FA{constructor(){super(...arguments),n(this,"idle",[]),n(this,"talking",[]),n(this,"marker",null),n(this,"voip",null),n(this,"lastMouthChangeTime",0),n(this,"mouthChangeLength",0)}awake(){setTimeout(()=>{this.voip=CA.findObjectOfType(kB,this.context),this.marker||(this.marker=CA.getComponentInParent(this.gameObject,Lg))},3e3)}update(){var A;if(!this.voip||this.context.time.frameCount%10!==0)return;let e=((A=this.marker)==null?void 0:A.connectionId)??null;if(!e){yIA&&(e=null);return}const i=this.voip.getFrequency(e)??0;this.updateLips(i)}updateLips(A){if(this.context.time.time-this.lastMouthChangeTime>this.mouthChangeLength){if(this.mouthChangeLength=.05+Math.random()*.1,this.talking&&this.talking.length>0&&A>30){this.lastMouthChangeTime=this.context.time.time;const e=Math.floor(Math.random()*this.talking.length);this.setMouthShapeActive(this.talking,e)}else if(this.idle.length>0&&this.context.time.time-this.lastMouthChangeTime>.5){this.lastMouthChangeTime=this.context.time.time;const e=Math.floor(Math.random()*this.idle.length);this.setMouthShapeActive(this.idle,e)}}}setMouthShapeActive(A,e){if(A){A!=this.idle?this.idle.map(i=>i.visible=!1):this.talking.map(i=>i.visible=!1);for(let i=0;i<A.length;i++){const g=A[i];g&&(g.visible=i===e)}}}}c2([w(uA)],Dd.prototype,"idle",2),c2([w(uA)],Dd.prototype,"talking",2);class GR extends FA{constructor(){super(...arguments),n(this,"voip",null),n(this,"marker",null),n(this,"_startPosition",null)}awake(){this.voip=CA.findObjectOfType(kB,this.context),this.marker=CA.getComponentInParent(this.gameObject,Lg)}update(){if(!this.voip||!this.marker||this.context.time.frameCount%10!==0)return;const A=this.marker.connectionId,e=this.voip.getFrequency(A);if(e==null)return;this._startPosition||(this._startPosition=this.gameObject.position.clone());const i=e/100;this.gameObject.position.y=this._startPosition.y+i*.07}}var SIA=Object.defineProperty,fIA=Object.getOwnPropertyDescriptor,Wy=(t,A,e,i)=>{for(var g=i>1?void 0:i?fIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&SIA(A,e,g),g};class GB extends FA{constructor(){super(...arguments),n(this,"eyes",[]),n(this,"lastBlinkTime",0),n(this,"blinkLength",0),n(this,"eyesOpen",!0),n(this,"state",null)}awake(){this.state=CA.getComponentInParent(this.gameObject,co)}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 A of this.eyes)A&&(A.visible=this.eyesOpen)}}}Wy([w(uA)],GB.prototype,"eyes",2),Wy([w()],GB.prototype,"lastBlinkTime",2),Wy([w()],GB.prototype,"blinkLength",2),Wy([w()],GB.prototype,"eyesOpen",2);var mIA=Object.defineProperty,kIA=Object.getOwnPropertyDescriptor,MR=(t,A,e,i)=>{for(var g=i>1?void 0:i?kIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&mIA(A,e,g),g},UR;const l2=(UR=class extends FA{constructor(){super(...arguments),n(this,"head",null),n(this,"eyes",null),n(this,"target",null),n(this,"brain",null),n(this,"vec",new S),n(this,"currentTargetPoint",new S)}awake(){this.brain||(this.brain=CA.getComponentInParent(this.gameObject,pd)),this.brain||(console.log("No look at brain found, adding it now"),this.brain=CA.addNewComponent(this.gameObject,pd)),this.brain&&this.target&&(this.brain.controlledTarget=this.target)}update(){const t=this.target;if(t&&this.head){const A=this.eyes;if(A){const e=Fe(t);this.currentTargetPoint.lerp(e,this.context.time.deltaTime/.1);const i=Fe(this.head),g=this.vec.copy(this.currentTargetPoint).sub(i).normalize();if(g.length()<.1)return;const I=l2.forward;if(I.set(0,0,1),I.applyQuaternion(Gt(this.head)),I.dot(g)>.45)for(let o=0;o<A.length;o++)A[o].lookAt(this.currentTargetPoint)}}}},n(UR,"forward",new S(0,0,1)),UR);let jE=l2;MR([w(uA)],jE.prototype,"head",2),MR([w(uA)],jE.prototype,"eyes",2),MR([w(uA)],jE.prototype,"target",2);const wd=tA("debugavatar");class Zy{constructor(A,e,i,g){n(this,"root"),n(this,"head"),n(this,"leftHand"),n(this,"rigthHand");var I;this.root=A,this.head=e,this.leftHand=i,this.rigthHand=g,(I=this.root)==null||I.traverse(o=>o.layers.set(2))}get isValid(){return this.head!==null&&this.head!==void 0}}class RR{constructor(){n(this,"avatarRegistryUrl",null)}async getOrCreateNewAvatarInstance(A,e){if(!e)return console.error("Can not create avatar: failed to provide id or root object"),null;let i=null;if(typeof e=="string"){if(i=await this.loadAvatar(A,e),!i){const I=new _s;i=CA.instantiate(AE(e,A.scene),I)}}else i=e;if(!i)return null;const g=this.findAvatar(i);return g.isValid?(wd&&console.log("[Custom Avatar] valid config",e,wd?g:""),g):(console.warn("[Custom Avatar] config isn't valid",e,wd?g:""),null)}async loadAvatar(A,e){if(console.assert(e!=null&&typeof e=="string","Avatar id must not be null"),e.length<=0||!e)return null;if(wd&&console.log("[Custom Avatar] "+e+", loading..."),e.endsWith(".glb")||(e+=".glb"),this.avatarRegistryUrl===null){const g=await fetch("./"+e);let I=null;if(g.ok){const s=await g.blob();s&&(I=await s.arrayBuffer())}if(!I&&(I=await hU(e,e,0,"no url here go away",!0),!I))return null;const o=await Es().parseSync(A,I,null,0);return o?.scene??null}const i=new aE;return Il(i,A),new Promise((g,I)=>{const o=this.avatarRegistryUrl+"/"+e;i.load(o,async s=>{await Es().createBuiltinComponents(A,o,s,null,void 0),g(s.scene)},s=>{wd&&console.log("[Custom Avatar] "+s.loaded/s.total*100+"% loaded of "+s.total/1024+"kB")},s=>{console.error("[Custom Avatar] Error when loading: "+s),g(null)})})}cacheModel(A,e){}findAvatar(A){const e=A;let i=e;i.children.length==1&&(i=A.children[0]);let g=this.findAvatarPart(i,["head"]);const I=this.findAvatarPart(i,["left","hand"]),o=this.findAvatarPart(i,["right","hand"]);if(!g){g=e;const s=new S;new pt().setFromObject(g).getSize(s);const C=Math.max(s.x,s.y,s.z);console.warn("[Custom Avatar] Normalizing head scale, it's too big: "+C+" meters! Should be < 0.3m"),C>.3&&g.scale.multiplyScalar(1/C*.3)}return new Zy(e,g,I,o)}findAvatarPart(A,e){const i=A.name.toLowerCase();let g=!0;for(const I of e){if(!g)break;i.indexOf(I)===-1&&(g=!1)}if(g)return A;if(A.children)for(const I of A.children){const o=this.findAvatarPart(I,e);if(o)return o}return null}handleCustomAvatarErrors(A){if(!A.ok)throw Error(A.statusText);return A}}var GIA=Object.defineProperty,MIA=Object.getOwnPropertyDescriptor,NR=(t,A,e,i)=>{for(var g=i>1?void 0:i?MIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&GIA(A,e,g),g};class WE extends FA{constructor(){super(...arguments),n(this,"length",1),n(this,"depthTest",!0),n(this,"isGizmo",!0),n(this,"_axes",null)}onEnable(){if(this.isGizmo&&!fl)return;this._axes||(this._axes=new qo(this.length)),this._axes.layers.disableAll(),this._axes.layers.set(this.layer),this.gameObject.add(this._axes);const A=this._axes.material;A&&A.depthTest!==void 0&&(A.depthTest=this.depthTest)}onDisable(){this._axes&&this.gameObject.remove(this._axes)}}NR([w()],WE.prototype,"length",2),NR([w()],WE.prototype,"depthTest",2),NR([w()],WE.prototype,"isGizmo",2);class FR extends FA{constructor(){super(...arguments),n(this,"from"),n(this,"to"),n(this,"hint"),n(this,"desiredDistance",1)}onEnable(){}update(){if(!this.from||!this.to||!this.hint)return;const A=Fe(this.to).clone(),e=Fe(this.from).clone(),i=A.distanceTo(e),g=A.clone();g.sub(e);const I=e.clone();I.add(A),I.multiplyScalar(.5);const o=Fe(this.hint).clone();o.sub(I);const s=new S;s.crossVectors(o,g),s.crossVectors(g,s),s.normalize();const C=i*.5,a=Math.max(this.desiredDistance,C),r=Math.sqrt(a*a-C*C),B=s.clone();B.multiplyScalar(r),B.add(I),gI(this.gameObject,B);const Q=I.clone();Q.sub(s),this.gameObject.lookAt(Q)}}const KR=tA("debugusdzbehaviours");class Vy{constructor(){n(this,"behaviours",[]),n(this,"behaviourComponents",[]),n(this,"behaviourComponentsCopy",[])}get extensionName(){return"Behaviour"}addBehavior(A){this.behaviours.push(A)}onBeforeBuildDocument(A){const e=[];return A.root.traverse(i=>{CA.foreachComponent(i,g=>{var I;const o=g;if(typeof o.createBehaviours=="function"||typeof o.beforeCreateDocument=="function"||typeof o.afterCreateDocument=="function"||typeof o.afterSerialize=="function"){this.behaviourComponents.push(o);const s=(I=o.beforeCreateDocument)==null?void 0:I.call(o,this,A);s instanceof Promise&&e.push(s)}},!1)}),KR&&console.log("onBeforeBuildDocument: all components",this.behaviourComponents),Promise.all(e)}onExportObject(A,e,i){var g;for(const I of this.behaviourComponents)KR&&console.log("onExportObject: createBehaviours",I),(g=I.createBehaviours)==null||g.call(I,this,e,i)}onAfterBuildDocument(A){for(const e of this.behaviourComponents)typeof e.afterCreateDocument=="function"&&e.afterCreateDocument(this,A);this.behaviourComponentsCopy=this.behaviourComponents.slice(),this.behaviourComponents.length=0}onAfterHierarchy(A,e){var i;if((i=this.behaviours)!=null&&i.length){e.beginBlock('def Scope "Behaviors"');for(const g of this.behaviours)g.writeTo(this,A.document,e);e.closeBlock()}}async onAfterSerialize(A){KR&&console.log("onAfterSerialize behaviours",this.behaviourComponentsCopy);for(const e of this.behaviourComponentsCopy)typeof e.afterSerialize=="function"&&(e.afterSerialize.constructor.name==="AsyncFunction"?await e.afterSerialize(this,A):e.afterSerialize(this,A));this.behaviours.length=0}}var UIA=Object.defineProperty,RIA=Object.getOwnPropertyDescriptor,JR=(t,A,e,i)=>{for(var g=i>1?void 0:i?RIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&UIA(A,e,g),g},vR;const d2=(vR=class extends aI{constructor(){super(...arguments),n(this,"threshold"),n(this,"intensity"),n(this,"scatter"),n(this,"selectiveBloom")}get typeName(){return"Bloom"}init(){this.threshold.defaultValue=1,this.intensity.defaultValue=0,this.scatter.defaultValue=.2,this.selectiveBloom?(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>1*Math.PI*(1-t)):(this.threshold.valueProcessor=t=>t,this.intensity.valueProcessor=t=>t,this.scatter.valueProcessor=t=>100*(1-t))}onCreateEffect(){let t;if(this.selectiveBloom==null&&(this.selectiveBloom=d2.useSelectiveBloom),this.selectiveBloom){const A=t=new LY(this.context.scene,this.context.mainCamera,{blendFunction:He.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});A.inverted=!0}else t=new gU({blendFunction:He.ADD,mipmapBlur:!0,luminanceThreshold:this.threshold.value,luminanceSmoothing:this.scatter.value,intensity:this.intensity.value});return this.intensity.onValueChanged=A=>{t.intensity=A},this.threshold.onValueChanged=A=>{t.luminanceMaterial.threshold=A},this.scatter.onValueChanged=A=>{t.luminancePass.enabled=!0,t.luminanceMaterial.smoothing=A},t}},n(vR,"useSelectiveBloom",!1),vR);let MB=d2;JR([w(Ne)],MB.prototype,"threshold",2),JR([w(Ne)],MB.prototype,"intensity",2),JR([w(Ne)],MB.prototype,"scatter",2),ts("Bloom",MB);const ZE="NEEDLE_progressive",nI=tA("debugprogressive"),bR=Symbol("needle-progressive-texture"),VE=new Map;if(nI){let t=function(){A+=1,Xt(`Toggle LOD level: ${A}<br/>Registered objects: ${VE.size}`),console.log("Toggle LOD level",A,VE);const i=et.Current;VE.forEach((g,I)=>{for(const o of g.keys){const s=I[o];if(s instanceof he){const C=Jt.getMeshLODInformation(s),a=C?Math.min(A,C.lods.length):0;I["DEBUG:LOD"]=a,Jt.assignMeshLOD(i,g.sourceId,I,a),C&&(e=Math.max(e,C.lods.length-1))}else if(I instanceof Re){Jt.assignTextureLOD(i,g.sourceId,I,A);break}}}),A>=e&&(A=-1)},A=-1,e=2;window.addEventListener("keyup",i=>{i.key==="p"&&t()}),et.registerCallback(si.ContextCreated,i=>{const g=document.createElement("button");g.innerText="Toggle Progressive",g.onclick=t,i.context.menu.appendChild(g)})}function p2(t,A,e){var i;if(!nI)return;VE.has(t)||VE.set(t,{keys:[],sourceId:e});const g=VE.get(t);((i=g?.keys)==null?void 0:i.includes(A))==!1&&g.keys.push(A)}const lo=class{constructor(t,A,e){n(this,"parser"),n(this,"sourceId"),n(this,"context"),this.parser=t,this.sourceId=A,this.context=e}get name(){return ZE}static getMeshLODInformation(t){const A=this.getAssignedLODInformation(t);return A!=null&&A.key?this.lodInfos.get(A.key):null}static hasLODLevelAvailable(t,A){var e;if(t instanceof Re){for(const I of Object.keys(t)){const o=t[I];if(o instanceof le&&this.hasLODLevelAvailable(o,A))return!0}return!1}else if(t instanceof pI){for(const I of t.children)if(I instanceof hA&&this.hasLODLevelAvailable(I,A))return!0}let i,g;if(t instanceof hA?i=t.geometry:t instanceof le&&(i=t),i&&(e=i?.userData)!=null&&e.LODS){const I=i.userData.LODS;if(g=this.lodInfos.get(I.key),A===void 0)return g!=null;if(g)return Array.isArray(g.lods)?A<g.lods.length:A===0}return!1}static assignMeshLOD(t,A,e,i){if(!e)return Promise.resolve(null);if(e instanceof hA){const g=e.geometry,I=this.getAssignedLODInformation(g);if(!I)return Promise.resolve(null);Yl(e)||ry(e,e.geometry);const o=this.onProgressiveLoadStart(t,A,e,null);return e["LOD:requested level"]=i,lo.getOrLoadLOD(t,A,g,i).then(s=>{if(e["LOD:requested level"]===i){if(delete e["LOD:requested level"],Array.isArray(s)){const C=I.index||0;s=s[C]}s&&g!=s&&(nI=="verbose"&&console.log("Progressive Mesh "+e.name+" loaded",g,"\u2192",s,`
|
|
5509
5509
|
`,e),s instanceof he&&(e.geometry=s,nI&&p2(e,"geometry",A)))}return this.onProgressiveLoadEnd(o),s}).catch(s=>(this.onProgressiveLoadEnd(o),console.error("Error loading mesh LOD",e,s),null))}else nI&&console.error("Invalid call to assignMeshLOD: Request mesh LOD but the object is not a mesh",e);return Promise.resolve(null)}static assignTextureLOD(t,A,e,i=0){if(!e)return Promise.resolve(null);if(e instanceof Re){const g=e,I=[],o=new Array;if(g instanceof Jc)for(const s of Object.keys(g.uniforms)){const C=g.uniforms[s].value;if(C instanceof le){const a=this.assignTextureLODForSlot(t,A,C,i,g,s);I.push(a),o.push(s)}}else for(const s of Object.keys(g)){const C=g[s];if(C instanceof le){const a=this.assignTextureLODForSlot(t,A,C,i,g,s);I.push(a),o.push(s)}}return Yc(I).then(s=>{const C=new Array;for(let a=0;a<s.results.length;a++){const r=s.results[a],B=o[a];r instanceof le?C.push({material:g,slot:B,texture:r,level:i}):C.push({material:g,slot:B,texture:null,level:i})}return C})}if(e instanceof le){const g=e;return this.assignTextureLODForSlot(t,A,g,i,null,null)}return Promise.resolve(null)}static assignTextureLODForSlot(t,A,e,i,g,I){if(e?.isTexture!==!0)return Promise.resolve(null);const o=this.onProgressiveLoadStart(t,A,g,I);return lo.getOrLoadLOD(t,A,e,i).then(s=>Array.isArray(s)?null:s?.isTexture===!0?(s!=e&&(g&&I&&(g[I]=s),nI&&I&&g&&p2(g,I,A)),this.onProgressiveLoadEnd(o),s):(nI=="verbose"&&console.warn("No LOD found for",e,i),this.onProgressiveLoadEnd(o),null)).catch(s=>(this.onProgressiveLoadEnd(o),console.error("Error loading LOD",e,s),null))}afterRoot(t){var A,e;nI&&console.log("AFTER",this.sourceId,t),(A=this.parser.json.textures)==null||A.forEach((g,I)=>{if(g!=null&&g.extensions){const o=g?.extensions[ZE];if(o){for(const s of this.parser.associations.keys())if(s instanceof le&&this.parser.associations.get(s).textures===I){const C=s;nI&&console.log("> Progressive: register texture",I,C.name,C.uuid,C,o),C.source&&(C.source[bR]=o);const a=C.uuid;lo.assignLODInformation(C,a,0,0,void 0),lo.lodInfos.set(a,o),lo.lowresCache.set(a,C)}}}});const i=(g,I,o,s,C)=>{const a=I.geometry;a["needle:raycast-mesh"]=!0,a&&!Yl(I)&&(nI&&console.log("Set raycast mesh",I.name,I.uuid,a),ry(I,a),Gw(a,!0).forEach(r=>{r instanceof hA&&ry(r,a)})),a.userData||(a.userData={}),lo.assignLODInformation(a,g,o,s,C.density),lo.lodInfos.set(g,C)};return(e=this.parser.json.meshes)==null||e.forEach((g,I)=>{if(g!=null&&g.extensions){const o=g?.extensions[ZE];if(o&&o.lods){for(const s of this.parser.associations.keys())if(s instanceof hA){const C=this.parser.associations.get(s);if(C.meshes===I){const a=s;nI&&console.log("> Progressive: register mesh",I,a.name,o,a.uuid,a);const r=a.uuid,B=o.lods.length;if(a instanceof hA){i(r,a,B,C.primitives,o);let Q=lo.lowresCache.get(r);Q?Q.push(a.geometry):Q=[a.geometry],lo.lowresCache.set(r,Q)}}}}}}),null}static async getOrLoadLOD(t,A,e,i){var g,I,o;const s=nI=="verbose",C=e.userData.LODS;if(!C)return null;const a=C?.key;let r;if(e instanceof le&&e.source&&e.source[bR]&&(r=e.source[bR]),r||(r=lo.lodInfos.get(a)),r){if(i>0){let E=!1;const h=Array.isArray(r.lods);if(h&&i>=r.lods.length?E=!0:h||(E=!0),E)return this.lowresCache.get(a)}const B=Array.isArray(r.lods)?r.lods[i].path:r.lods;if(!B)return nI&&!r["missing:uri"]&&(r["missing:uri"]=!0,console.warn("Missing uri for progressive asset for LOD "+i,r)),null;let Q=ea(A,B);if(Q.endsWith(".glb")||Q.endsWith(".gltf")){if(!r.guid)return console.warn("missing pointer for glb/gltf texture",r),null;const E=Q+"_"+r.guid,h=this.previouslyLoaded.get(E);if(h!==void 0){s&&console.log(`LOD ${i} was already loading/loaded: ${E}`);let c=await h.catch(u=>(console.error(`Error loading LOD ${i} from ${Q}
|
|
5510
5510
|
`,u),null)),p=!1;if(c==null||(c instanceof le&&e instanceof le?(g=c.image)!=null&&g.data||(I=c.source)!=null&&I.data?c=this.copySettings(e,c):(p=!0,this.previouslyLoaded.delete(E)):c instanceof he&&e instanceof he&&((o=c.attributes.position)!=null&&o.array||(p=!0,this.previouslyLoaded.delete(E)))),!p)return c}const d=r,l=new Promise(async(c,p)=>{const u=new aE;if(Il(u,t),r&&Array.isArray(r.lods)){const M=r.lods[i];M.hash&&(Q+="?v="+M.hash)}nI&&(await ws(Math.random()*1e3),s&&console.warn("Start loading (delayed) "+Q,d.guid));const D=await u.loadAsync(Q).catch(M=>(console.error(`Error loading LOD ${i} from ${Q}
|
|
5511
5511
|
`,M),null));if(!D)return null;const k=D.parser;s&&console.log("Loading finished "+Q,d.guid);let U=0;if(D.parser.json.textures){let M=!1;for(const G of D.parser.json.textures){if(G!=null&&G.extensions){const K=G?.extensions[ZE];if(K!=null&&K.guid&&K.guid===d.guid){M=!0;break}}U++}if(M){let G=await k.getDependency("texture",U);return s&&console.log('change "'+e.name+'" \u2192 "'+G.name+'"',Q,U,G,E),e instanceof le&&(G=this.copySettings(e,G)),G&&(G.guid=d.guid),c(G)}}if(U=0,D.parser.json.meshes){let M=!1;for(const G of D.parser.json.meshes){if(G!=null&&G.extensions){const K=G?.extensions[ZE];if(K!=null&&K.guid&&K.guid===d.guid){M=!0;break}}U++}if(M){const G=await k.getDependency("mesh",U),K=d;if(s&&console.log(`Loaded Mesh "${G.name}"`,Q,U,G,E),G instanceof hA){const f=G.geometry;return lo.assignLODInformation(f,a,i,void 0,K.density),c(f)}else{const f=new Array;for(let N=0;N<G.children.length;N++){const _=G.children[N];if(_ instanceof hA){const T=_.geometry;lo.assignLODInformation(T,a,i,N,K.density),f.push(T)}}return c(f)}}}return c(null)});return this.previouslyLoaded.set(E,l),await l}else if(e instanceof le){s&&console.log("Load texture from uri: "+Q);const E=await new Xs().loadAsync(Q);return E?(E.guid=r.guid,E.flipY=!1,E.needsUpdate=!0,E.colorSpace=e.colorSpace,s&&console.log(r,E)):nI&&console.warn("failed loading",Q),E}}else nI&&console.warn(`Can not load LOD ${i}: no LOD info found for "${a}" ${e.name}`,e.type);return null}static assignLODInformation(t,A,e,i,g){if(!t)return;t.userData||(t.userData={});const I=new NIA(A,e,i,g);t.userData.LODS=I,t.userData.LOD=e}static getAssignedLODInformation(t){var A;return((A=t?.userData)==null?void 0:A.LODS)||null}static copySettings(t,A){return this._copiedTextures.get(t)||(A=A.clone(),this._copiedTextures.set(t,A),A.offset=t.offset,A.repeat=t.repeat,A.colorSpace=t.colorSpace,A)}static beginListenStart(t,A){this._progressiveEventListeners.has(t)||this._progressiveEventListeners.set(t,new D2),this._progressiveEventListeners.get(t).start.push(A)}static stopListenStart(t,A){if(!this._progressiveEventListeners.has(t))return;const e=this._progressiveEventListeners.get(t).start,i=e.indexOf(A);i>=0&&e.splice(i,1)}static beginListenEnd(t,A){this._progressiveEventListeners.has(t)||this._progressiveEventListeners.set(t,new D2),this._progressiveEventListeners.get(t).end.push(A)}static stopListenEnd(t,A){if(!this._progressiveEventListeners.has(t))return;const e=this._progressiveEventListeners.get(t).end,i=e.indexOf(A);i>=0&&e.splice(i,1)}static onProgressiveLoadStart(t,A,e,i){this._currentProgressiveLoadingInfo.has(t)||this._currentProgressiveLoadingInfo.set(t,[]);const g=new u2(t,A,e,i),I=this._currentProgressiveLoadingInfo.get(t),o=this._progressiveEventListeners.get(t);return o&&o.onStart(g),I.push(g),g}static onProgressiveLoadEnd(t){if(!t)return;const A=t.context;if(!this._currentProgressiveLoadingInfo.has(A))return;const e=this._currentProgressiveLoadingInfo.get(A),i=e.indexOf(t);if(i<0)return;e.splice(i,1);const g=this._progressiveEventListeners.get(A);g&&g.onEnd(t)}};let Jt=lo;n(Jt,"lodInfos",new Map),n(Jt,"previouslyLoaded",new Map),n(Jt,"lowresCache",new Map),n(Jt,"_copiedTextures",new Map),n(Jt,"_progressiveEventListeners",new Map),n(Jt,"_currentProgressiveLoadingInfo",new Map);class NIA{constructor(A,e,i,g){n(this,"key"),n(this,"level"),n(this,"index"),n(this,"density"),this.key=A,this.level=e,i!=null&&(this.index=i),g!=null&&(this.density=g)}}class u2{constructor(A,e,i,g){n(this,"context"),n(this,"source"),n(this,"material"),n(this,"slot"),n(this,"mesh"),this.context=A,this.source=e,i instanceof hA?this.mesh=i:this.material=i,this.slot=g}}class D2{constructor(){n(this,"start",[]),n(this,"end",[])}onStart(A){for(const e of this.start)e(A)}onEnd(A){for(const e of this.end)e(A)}}var FIA=Object.defineProperty,KIA=Object.getOwnPropertyDescriptor,ZI=(t,A,e,i)=>{for(var g=i>1?void 0:i?KIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&FIA(A,e,g),g};class po extends FA{constructor(){super(...arguments),n(this,"attachedRigidbody",null),n(this,"isTrigger",!1),n(this,"sharedMaterial"),n(this,"membership",[0]),n(this,"filter"),n(this,"updateProperties",()=>{var A;(A=this.context.physics.engine)==null||A.updateProperties(this)})}get isCollider(){return!0}awake(){super.awake(),this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ut))}start(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ut))}onEnable(){this.attachedRigidbody||(this.attachedRigidbody=this.gameObject.getComponentInParent(Ut))}onDisable(){var A;(A=this.context.physics.engine)==null||A.removeBody(this)}get body(){var A;return(A=this.context.physics.engine)==null?void 0:A.getBody(this)}updatePhysicsMaterial(){var A;(A=this.context.physics.engine)==null||A.updatePhysicsMaterial(this)}}ZI([w(Ut)],po.prototype,"attachedRigidbody",2),ZI([w()],po.prototype,"isTrigger",2),ZI([w()],po.prototype,"sharedMaterial",2),ZI([w()],po.prototype,"membership",2),ZI([w()],po.prototype,"filter",2);class zE extends po{constructor(){super(...arguments),n(this,"radius",.5),n(this,"center",new S(0,0,0))}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addSphereCollider(this),HD(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),Pk(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}ZI([bg(),w()],zE.prototype,"radius",2),ZI([w(S)],zE.prototype,"center",2);class XE extends po{constructor(){super(...arguments),n(this,"size",new S(1,1,1)),n(this,"center",new S(0,0,0))}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addBoxCollider(this,this.size),HD(this.gameObject.scale,this.updateProperties)}onDisable(){super.onDisable(),Pk(this.gameObject.scale,this.updateProperties)}onValidate(){this.updateProperties()}}ZI([bg(),w(S)],XE.prototype,"size",2),ZI([w(S)],XE.prototype,"center",2);class UB extends po{constructor(){super(...arguments),n(this,"sharedMesh"),n(this,"convex",!1)}onEnable(){var A,e,i;if(super.onEnable(),!this.context.physics.engine)return;(A=this.sharedMesh)!=null&&A.isMesh||this.gameObject instanceof hA&&(this.sharedMesh=this.gameObject);const g=0;if((e=this.sharedMesh)!=null&&e.isMesh)this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Tt(this.gameObject)),Jt.assignMeshLOD(this.context,this.sourceId,this.sharedMesh,g).then(I=>{I&&this.activeAndEnabled&&this.context.physics.engine&&this.sharedMesh&&(this.context.physics.engine.removeBody(this),this.sharedMesh.geometry=I,this.context.physics.engine.addMeshCollider(this,this.sharedMesh,this.convex,Tt(this.gameObject)))});else{const I=this.sharedMesh;if(I!=null&&I.isGroup){console.warn(`MeshCollider mesh is a group "${((i=this.sharedMesh)==null?void 0:i.name)||this.gameObject.name}", adding all children as colliders. This is currently not fully supported (colliders can not be removed from world again)`,this);const o=new Array;for(const s in I.children){const C=I.children[s];C.isMesh&&(this.context.physics.engine.addMeshCollider(this,C,this.convex,Tt(this.gameObject)),o.push(Jt.assignMeshLOD(this.context,this.sourceId,C,g)))}Promise.all(o).then(s=>{var C,a;if(s.some(B=>B)==!1)return;(C=this.context.physics.engine)==null||C.removeBody(this);const r=new hA;for(const B of s)B&&this.activeAndEnabled&&(r.geometry=B,(a=this.context.physics.engine)==null||a.addMeshCollider(this,r,this.convex,Tt(this.gameObject)))})}}}}ZI([w(hA)],UB.prototype,"sharedMesh",2),ZI([w()],UB.prototype,"convex",2);class ya extends po{constructor(){super(...arguments),n(this,"center",new S(0,0,0)),n(this,"radius",.5),n(this,"height",2)}onEnable(){var A;super.onEnable(),(A=this.context.physics.engine)==null||A.addCapsuleCollider(this,this.height,this.radius)}}ZI([w(S)],ya.prototype,"center",2),ZI([w()],ya.prototype,"radius",2),ZI([w()],ya.prototype,"height",2);var JIA=Object.defineProperty,vIA=Object.getOwnPropertyDescriptor,qR=(t,A,e,i)=>{for(var g=i>1?void 0:i?vIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&JIA(A,e,g),g};class RB extends FA{constructor(){super(...arguments),n(this,"objectBounds",!1),n(this,"color"),n(this,"isGizmo",!0),n(this,"_gizmoObject",null),n(this,"_boxHelper",null)}onEnable(){this.isGizmo&&!fl||(this._gizmoObject||(this.objectBounds?this._gizmoObject=new qk(this.gameObject,this.color??16776960):(this.objectBounds=!1,this._gizmoObject=dU(this.color??16776960))),this.objectBounds?(this.scene.add(this._gizmoObject),this._boxHelper=this._gizmoObject,this.startCoroutine(this.syncObjectBounds(),Ot.OnBeforeRender)):this.gameObject.add(this._gizmoObject))}onDisable(){this._gizmoObject&&this.gameObject.remove(this._gizmoObject)}*syncObjectBounds(){for(var A;this._boxHelper;)(A=this._boxHelper)==null||A.update(),yield}}qR([w()],RB.prototype,"objectBounds",2),qR([w(GA)],RB.prototype,"color",2),qR([w()],RB.prototype,"isGizmo",2);const bIA=tA("gizmos"),qIA=tA("debugboxhelper"),Fs=class extends FA{constructor(){super(...arguments),n(this,"box",null),n(this,"_lastMatrixUpdateFrame",-1),n(this,"_helper",null),n(this,"_color",null)}isInBox(t,A){var e;if(!t)return;if(this.box||(this.box=new pt),t.type==="Mesh")Fs.testBox.setFromObject(t);else if(t.type==="Group"){if(Fs.testBox.makeEmpty(),t.children.length>0)for(let g=0;g<t.children.length;g++)t.children[g].type==="Mesh"&&Fs.testBox.expandByObject(t)}else{const g=Fe(t,Fs._position),I=Tt(t,Fs._size);A!==void 0&&I.multiplyScalar(A),Fs.testBox.setFromCenterAndSize(g,I)}this.updateBox();const i=(e=this.box)==null?void 0:e.intersectsBox(Fs.testBox);return i&&qIA&&ue.DrawWireBox3(Fs.testBox,16711680,5),i}intersects(t){return t?this.updateBox(!1).intersectsBox(t):!1}updateBox(t=!1){if(this.box||(this.box=new pt),t||this.context.time.frameCount!=this._lastMatrixUpdateFrame){const A=this._lastMatrixUpdateFrame<0;this._lastMatrixUpdateFrame=this.context.time.frameCount;const e=A,i=Fe(this.gameObject,Fs._position,e),g=Tt(this.gameObject,Fs._size);this.box.setFromCenterAndSize(i,g)}return this.box}awake(){this._helper=null,this._color=null,this.box=null}showHelper(t=null,A=!1){var e;if(!(!bIA&&!A)){if(this._helper){t&&((e=this._color)==null||e.set(t)),this.gameObject.add(this._helper);return}this._helper=dU(t),this.gameObject.add(this._helper)}}};let pC=Fs;n(pC,"testBox",new pt),n(pC,"_position",new S),n(pC,"_size",new S(.01,.01,.01));class xIA extends kx{constructor(A,e={}){super(A),A._simpleState__activeStates=[],A._simpleState__normalStyles={},A._simpleState__states=e,A._simpleState__statesProperties={};for(const i in e)for(const g in e[i])A._simpleState__statesProperties[g]||(A._simpleState__statesProperties[g]=[]),A._simpleState__statesProperties[g].push(i);for(const i of A._components)A._simpleState__statesProperties[i.id]&&(A._simpleState__normalStyles[i.id]=i.inline?i.inline:i._value);A.__overridedSet=A.set,A.set=this.storeSet.bind(A),A.renderStates=this.renderStates.bind(A),A.setupState=this.setupState.bind(A),A.setState=this.setState.bind(A),A.activatePseudoState=this.activatePseudoState.bind(A),A.deactivatePseudoState=this.deactivatePseudoState.bind(A),A.togglePseudoState=this.togglePseudoState.bind(A)}act(){}attach(){}detach(){}setupState(A,e){this._simpleState__states[A]=e;const i=[];for(const g in e)this._simpleState__statesProperties[g]||(this._simpleState__statesProperties[g]=[],i.push(g)),this._simpleState__statesProperties[g].push(A);for(const g of this._components)i.indexOf(g.id)>-1&&(this._simpleState__normalStyles[g.id]=g.inline?g.inline:g._value)}renderStates(){let A={...this._simpleState__normalStyles};for(const e in this._simpleState__states)this._simpleState__activeStates.indexOf(e)>-1&&(A={...A,...this._simpleState__states[e]});this.set(A,!1)}storeSet(A,e=!0){if(e)for(const i in A)this._simpleState__statesProperties[i]&&(this._simpleState__normalStyles[i]=A[i]);this.__overridedSet(A)}activatePseudoState(A){this._simpleState__activeStates.indexOf(A)===-1&&(this._simpleState__activeStates.push(A),this.renderStates())}deactivatePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1&&(this._simpleState__activeStates.splice(e,1),this.renderStates())}togglePseudoState(A){const e=this._simpleState__activeStates.indexOf(A);e>-1?this._simpleState__activeStates.splice(e,1):this._simpleState__activeStates.push(A),this.renderStates()}setState(A){Array.isArray(A)?this._simpleState__activeStates=A:this._simpleState__activeStates=[A],this.renderStates()}}var LIA=Object.defineProperty,YIA=Object.getOwnPropertyDescriptor,w2=(t,A,e,i)=>{for(var g=i>1?void 0:i?YIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&LIA(A,e,g),g};class $E extends FA{constructor(){super(...arguments),n(this,"effectColor"),n(this,"effectDistance")}}w2([w(St)],$E.prototype,"effectColor",2),w2([w(eA)],$E.prototype,"effectDistance",2);var _IA=Object.defineProperty,HIA=Object.getOwnPropertyDescriptor,yd=(t,A,e,i)=>{for(var g=i>1?void 0:i?HIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&_IA(A,e,g),g};const xR=tA("debugui"),LR=tA("debuguilayout");class YR{constructor(){n(this,"width"),n(this,"height")}}class _R{constructor(){n(this,"x"),n(this,"y"),n(this,"width"),n(this,"height")}}const Ks=new S,Sd=new MA,zy=new RA,y2=class extends Hs{constructor(){super(...arguments),n(this,"_anchoredPosition"),n(this,"sizeDelta",new eA(100,100)),n(this,"pivot",new eA(.5,.5)),n(this,"anchorMin",new eA(0,0)),n(this,"anchorMax",new eA(1,1)),n(this,"minWidth"),n(this,"minHeight"),n(this,"lastMatrix"),n(this,"rectBlock"),n(this,"_transformNeedsUpdate",!1),n(this,"_initialPosition"),n(this,"_parentRectTransform"),n(this,"_lastUpdateFrame",-1),n(this,"_lastAnchoring"),n(this,"_createdBlocks",[]),n(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 eA),this._anchoredPosition}set anchoredPosition(t){this._anchoredPosition=t}get width(){let t=this.sizeDelta.x;if(this.anchorMin.x!==this.anchorMax.x&&this._parentRectTransform){const A=this._parentRectTransform.width,e=this.anchorMax.x-this.anchorMin.x;t=A*e,t+=this.sizeDelta.x}return this.minWidth!==void 0&&t<this.minWidth?this.minWidth:t}get height(){let t=this.sizeDelta.y;if(this.anchorMin.y!==this.anchorMax.y&&this._parentRectTransform){const A=this._parentRectTransform.height,e=this.anchorMax.y-this.anchorMin.y;t=A*e,t+=this.sizeDelta.y}return this.minHeight!==void 0&&t<this.minHeight?this.minHeight:t}awake(){super.awake(),this._anchoredPosition||(this._anchoredPosition=new eA),this.lastMatrix=new MA,this.rectBlock=new uA,this.rectBlock.name=this.name,this._initialPosition=this.gameObject.position.clone(),this._initialPosition.z=0,LE(this,"_anchoredPosition",()=>{this.markDirty()}),LE(this,"sizeDelta",()=>{this.markDirty()}),LE(this,"pivot",()=>{this.markDirty()}),LE(this,"anchorMin",()=>{this.markDirty()}),LE(this,"anchorMax",()=>{this.markDirty()})}onEnable(){var t;super.onEnable(),this.addShadowComponent(this.rectBlock),this._transformNeedsUpdate=!0,(t=this.Canvas)==null||t.registerTransform(this)}onDisable(){var t;super.onDisable(),this.removeShadowComponent(),(t=this.Canvas)==null||t.unregisterTransform(this)}onParentRectTransformChanged(t){this._transformNeedsUpdate||this.onApplyTransform(LR?`${t.name} changed`:void 0)}get isDirty(){return this._transformNeedsUpdate||(this._transformNeedsUpdate=!this.lastMatrix.equals(this.gameObject.matrix)),this._transformNeedsUpdate}markDirty(){this._transformNeedsUpdate||(LR&&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(t){var A;if(this.context.time.frameCount===this._lastUpdateFrame)return;this._lastUpdateFrame=this.context.time.frameCount;const e=this.shadowComponent;if(!e)return;this.gameObject.parent?this._parentRectTransform=CA.getComponentInParent(this.gameObject.parent,y2):this._parentRectTransform=void 0,this._transformNeedsUpdate=!1,LR&&console.warn("RectTransform \u2192 ApplyTransform",this.name+" because "+t),this.isRoot()?this.Root.screenspace||(e.rotation.y=Math.PI):(e.matrix.identity(),e.matrixAutoUpdate=!1,Ks.set(0,0,0),this.applyPivot(Ks),e.matrix.setPosition(Ks.x,Ks.y,0),(this.gameObject.quaternion.x||this.gameObject.quaternion.y||this.gameObject.quaternion.z)&&(zy.copy(this.gameObject.quaternion),zy.x*=-1,zy.z*=-1,Sd.makeRotationFromQuaternion(zy),e.matrix.premultiply(Sd)),Ks.set(0,0,0),this.applyAnchoring(Ks),(A=this.Canvas)!=null&&A.screenspace?Ks.z+=.1:Ks.z+=.01,Sd.identity(),Sd.setPosition(Ks.x,Ks.y,Ks.z),e.matrix.premultiply(Sd),e.matrix.scale(this.gameObject.scale)),this.lastMatrix.copy(this.gameObject.matrix);const i=!0;for(const g of gR(this.gameObject,Hs,i,1)){if(g===this||!g.activeAndEnabled)continue;const I=g;I.onParentRectTransformChanged&&I.onParentRectTransformChanged(this)}}applyAnchoring(t){this._lastAnchoring||(this._lastAnchoring=new eA);const A=this._lastAnchoring.sub(this._anchoredPosition);this.gameObject.position.x+=A.x,this.gameObject.position.y+=A.y,this._lastAnchoring.copy(this._anchoredPosition),t.x+=this._initialPosition.x-this.gameObject.position.x,t.y+=this._initialPosition.y-this.gameObject.position.y,t.z+=this._initialPosition.z-this.gameObject.position.z;const e=this._parentRectTransform;if(e){let i=0;const g=1-this.anchorMax.y-this.anchorMin.y;i-=e.height*.5*g,t.y+=i;let I=0;const o=1-this.anchorMax.x-this.anchorMin.x;I-=e.width*.5*o,t.x+=I}}applyPivot(t){if(this.pivot&&!this.isRoot()){const A=this.pivot.x-.5;t.x-=A*this.sizeDelta.x*this.gameObject.scale.x;const e=this.pivot.y-.5;t.y-=e*this.sizeDelta.y*this.gameObject.scale.y}}getBasicOptions(){const t={width:this.sizeDelta.x,height:this.sizeDelta.y,offset:0,backgroundOpacity:0,borderWidth:0,borderRadius:0,borderOpacity:0,letterSpacing:-.03};return this.ensureValidSize(t),t}ensureValidSize(t,A=1e-4){return t.width<=0&&(t.width=A),t.height<=0&&(t.height=1e-4),t}createNewBlock(t){t={...this.getBasicOptions(),...t},xR&&console.log(this.name,t);const A=new NG(t);return this._createdBlocks.push(A),A}createNewText(t){xR&&console.log(t),t={...this.getBasicOptions(),...t},xR&&console.log(this.name,t);const A=new KG(t);return this._createdTextBlocks.push(A),A}};let FI=y2;yd([w(eA)],FI.prototype,"anchoredPosition",1),yd([w(eA)],FI.prototype,"sizeDelta",2),yd([w(eA)],FI.prototype,"pivot",2),yd([w(eA)],FI.prototype,"anchorMin",2),yd([w(eA)],FI.prototype,"anchorMax",2);var TIA=Object.defineProperty,OIA=Object.getOwnPropertyDescriptor,S2=(t,A,e,i)=>{for(var g=i>1?void 0:i?OIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&TIA(A,e,g),g};const Xy={backgroundColor:new GA(1,1,1),backgroundOpacity:1,borderColor:new GA(1,1,1),borderOpacity:1};var HR;const $y=(HR=class extends Hs{constructor(){super(...arguments),n(this,"_alphaFactor",1),n(this,"sRGBColor",new GA(1,0,1)),n(this,"raycastTarget",!0),n(this,"uiObject",null),n(this,"_color",null),n(this,"_rect",null),n(this,"_stateManager",null),n(this,"_currentlyCreatingPanel",!1)}get isGraphic(){return!0}get color(){return this._color||(this._color=new St(1,1,1,1)),this._color}set color(t){(!this._color||this._color.r!==t.r||this._color.g!==t.g||this._color.b!==t.b||this._color.alpha!==t.alpha)&&(this._color||(this._color=new St(1,1,1,1)),this._color.copy(t),this.onColorChanged())}setAlphaFactor(t){this._alphaFactor=t,this.onColorChanged()}get alphaFactor(){return this._alphaFactor}onColorChanged(){this.uiObject&&(this.sRGBColor.copy(this._color),this.sRGBColor.convertLinearToSRGB(),Xy.backgroundColor=this.sRGBColor,Xy.backgroundOpacity=this._color.alpha*this._alphaFactor,this.applyEffects(Xy,this._alphaFactor),this.uiObject.set(Xy),this.markDirty())}get m_Color(){return this._color}get rectTransform(){if(this._rect||(this._rect=CA.getComponent(this.gameObject,FI)),!this._rect)throw new Error("Not Supported: Make sure to add a RectTransform component before adding a UI Graphic component.");return this._rect}onParentRectTransformChanged(){var t;(t=this.uiObject)==null||t.set({width:this.rectTransform.width,height:this.rectTransform.height}),this.markDirty()}__internalNewInstanceCreated(t){return super.__internalNewInstanceCreated(t),this._rect=null,this.uiObject=null,this._color&&(this._color=this._color.clone()),this}setState(t){this.makePanel(),this.uiObject&&(this.uiObject.setState(t),this==null||this.markDirty())}setupState(t){this.makePanel(),this.uiObject&&(this._stateManager||(this._stateManager=new xIA(this.uiObject)),this.uiObject.setupState(t.state,t.attributes))}setOptions(t){this.makePanel(),this.uiObject&&this.uiObject.set(t)}awake(){super.awake(),this.makePanel(),LE(this,"_color",()=>dgA(this,this.onColorChanged))}onEnable(){var t;super.onEnable(),this.uiObject&&((t=this.rectTransform.shadowComponent)==null||t.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 t=.015,A={backgroundColor:this.color,backgroundOpacity:this.color.alpha,offset:t};this.onBeforeCreate(A),this.applyEffects(A),this.onCreate(A),this.controlsChildLayout=!1,this._currentlyCreatingPanel=!1,this.onAfterCreated(),this.onColorChanged()}onBeforeCreate(t){}onCreate(t){this.uiObject=this.rectTransform.createNewBlock(t),this.uiObject.name=this.name}onAfterCreated(){}applyEffects(t,A=1){var e;const i=(e=this.gameObject)==null?void 0:e.getComponent($E);i&&(i.effectDistance&&(t.borderWidth=Math.max(Math.abs(i.effectDistance.x),Math.abs(i.effectDistance.y))),i.effectColor&&(t.borderColor=i.effectColor,t.borderOpacity=i.effectColor.alpha*A))}async setTexture(t){if(this.setOptions({backgroundOpacity:0}),t){if($y.textureCache.has(t))t=$y.textureCache.get(t);else if(!t.isRenderTargetTexture){const A=t.clone();A.colorSpace=lt,$y.textureCache.set(t,A),t=A}this.setOptions({backgroundImage:t,borderRadius:0,backgroundOpacity:this.color.alpha,backgroundSize:"stretch"}),Jt.assignTextureLOD(this.context,this.sourceId,t,0).then(A=>{A instanceof le&&this.setOptions({backgroundImage:A})})}else this.setOptions({backgroundImage:void 0,borderRadius:0,backgroundOpacity:this.color.alpha});this.markDirty()}onAfterAddedToScene(){super.onAfterAddedToScene(),this.shadowComponent&&(this.shadowComponent.offset=this.shadowComponent.position.z)}},n(HR,"textureCache",new Map),HR);let NB=$y;S2([w(St)],NB.prototype,"color",1),S2([w()],NB.prototype,"raycastTarget",2);class fd extends NB{constructor(){super(...arguments),n(this,"_flippedObject",!1)}onAfterCreated(){this.uiObject&&!this._flippedObject&&(this._flippedObject=!0,this.uiObject.scale.y*=-1)}}var PIA=Object.defineProperty,jIA=Object.getOwnPropertyDescriptor,A0=(t,A,e,i)=>{for(var g=i>1?void 0:i?jIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&PIA(A,e,g),g};let TR=class{constructor(){n(this,"texture",null),n(this,"rect")}};A0([w(le)],TR.prototype,"texture",2);let Ah=class extends fd{constructor(){super(...arguments),n(this,"_sprite"),n(this,"pixelsPerUnitMultiplier",1)}set image(t){this.sprite||(this.sprite=new TR),this.sprite.texture=t,this.onAfterCreated()}get image(){return this.sprite?this.sprite.texture:null}get sprite(){return this._sprite}set sprite(t){this._sprite!==t&&(this._sprite=t,this.onAfterCreated())}isBuiltinSprite(){var t,A,e,i,g,I,o;const s=this.sprite;switch((t=s?.texture)==null?void 0:t.name){case"InputFieldBackground":case"UISprite":case"Background":case"Knob":return!0}return!((e=(A=s?.texture)==null?void 0:A.name)!=null&&e.length)&&((g=(i=s?.texture)==null?void 0:i.image)==null?void 0:g.width)===32&&((o=(I=s?.texture)==null?void 0:I.image)==null?void 0:o.height)===32}onBeforeCreate(t){var A,e;super.onBeforeCreate(t),this.isBuiltinSprite()&&(t.borderRadius=5/this.pixelsPerUnitMultiplier,((e=(A=this.sprite)==null?void 0:A.texture)==null?void 0:e.name)==="Knob"&&(t.borderRadius=999))}onAfterCreated(){var t;this.__didAwake&&(super.onAfterCreated(),!this.isBuiltinSprite()&&this.setTexture((t=this.sprite)==null?void 0:t.texture))}};A0([w(TR)],Ah.prototype,"sprite",1),A0([w()],Ah.prototype,"pixelsPerUnitMultiplier",2);class e0 extends fd{constructor(){super(...arguments),n(this,"_mainTexture")}get mainTexture(){return this._mainTexture}set mainTexture(A){this._mainTexture!==A&&(this._mainTexture=A,this.onAfterCreated())}onAfterCreated(){this.__didAwake&&(super.onAfterCreated(),this.setTexture(this.mainTexture))}}A0([w(le)],e0.prototype,"mainTexture",1);var WIA=Object.defineProperty,ZIA=Object.getOwnPropertyDescriptor,uo=(t,A,e,i)=>{for(var g=i>1?void 0:i?ZIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&WIA(A,e,g),g};const FB=tA("debugbutton");class _n{constructor(){n(this,"colorMultiplier"),n(this,"disabledColor"),n(this,"fadeDuration"),n(this,"highlightedColor"),n(this,"normalColor"),n(this,"pressedColor"),n(this,"selectedColor")}}uo([w()],_n.prototype,"colorMultiplier",2),uo([w(St)],_n.prototype,"disabledColor",2),uo([w()],_n.prototype,"fadeDuration",2),uo([w(St)],_n.prototype,"highlightedColor",2),uo([w(St)],_n.prototype,"normalColor",2),uo([w(St)],_n.prototype,"pressedColor",2),uo([w(St)],_n.prototype,"selectedColor",2);class VIA{constructor(){n(this,"disabledTrigger"),n(this,"highlightedTrigger"),n(this,"normalTrigger"),n(this,"pressedTrigger"),n(this,"selectedTrigger")}}class Sa extends FA{constructor(){super(...arguments),n(this,"onClick"),n(this,"_isHovered",0),n(this,"colors"),n(this,"transition"),n(this,"animationTriggers"),n(this,"animator"),n(this,"_interactable",!0),n(this,"_requestedAnimatorTrigger"),n(this,"_isInit",!1),n(this,"_image")}onPointerEnter(A){var e,i;const g=A.event.pointerType==="mouse"&&A.button===0;g&&(this._isHovered+=1),FB&&console.warn("Button Enter",g,this._isHovered,(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.highlightedTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("hovered")),g&&this.context.input.setCursorPointer())}onPointerExit(){var A,e;this._isHovered-=1,this._isHovered<0&&(this._isHovered=0),FB&&console.log("Button Exit",this._isHovered,(A=this.animationTriggers)==null?void 0:A.highlightedTrigger,this.animator),this.interactable&&(this._isHovered>0||(this._isHovered=0,this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.normalTrigger):this.transition===1&&this.colors&&((e=this._image)==null||e.setState("normal")),this.context.input.setCursorNormal()))}onPointerDown(A){var e,i;FB&&console.log("Button Down",(e=this.animationTriggers)==null?void 0:e.highlightedTrigger,this.animator),this.interactable&&(this.transition==3&&this.animationTriggers&&this.animator?this.animator.setTrigger(this.animationTriggers.pressedTrigger):this.transition===1&&this.colors&&((i=this._image)==null||i.setState("pressed")))}onPointerUp(A){var e,i;FB&&console.warn("Button Up",(e=this.animationTriggers)==null?void 0:e.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&&((i=this._image)==null||i.setState(this._isHovered?"hovered":"normal")))}onPointerClick(A){if(this.interactable&&!(A.button!==0&&A.event.pointerType===Pw.Mouse)&&(FB&&(console.warn("Button Click",this.onClick),Xt("CLICKED button "+this.name+" at "+this.context.time.frameCount)),this.onClick&&this.onClick.listenerCount>0&&(this.onClick.invoke(),A.use(),FB))){const e=this.gameObject.worldPosition;e.add(this.gameObject.worldUp.multiplyScalar(1+Math.random()*.5)),ue.DrawLabel(e,"CLICK:"+Date.now(),.1,1+Math.random()*.5)}}set interactable(A){this._interactable=A,this._image&&(this._image.setInteractable(A),A?this._image.setState("normal"):this._image.setState("disabled"))}get interactable(){return this._interactable}set_interactable(A){this.interactable=A}awake(){super.awake(),FB&&console.log(this),this._isInit=!1,this.init()}start(){var A;(A=this._image)==null||A.setInteractable(this.interactable),this.gameObject.getComponentInParent(ed)||this.gameObject.addComponent(Fy)}onEnable(){super.onEnable()}onDestroy(){this._isHovered&&this.context.input.setCursorNormal()}*setAnimatorTriggerAtEndOfFrame(A){var e;this._requestedAnimatorTrigger=A,yield,yield,this._requestedAnimatorTrigger==A&&((e=this.animator)==null||e.SetTrigger(A))}init(){this._isInit||(this._isInit=!0,this._image=CA.getComponent(this.gameObject,Ah),this._image&&(this.stateSetup(this._image),this.interactable?this._image.setState("normal"):this._image.setState("disabled")))}stateSetup(A){var e,i,g,I,o;A.setInteractable(this.interactable);const s=this.getFinalColor(A.color,(e=this.colors)==null?void 0:e.normalColor),C={state:"normal",attributes:{backgroundColor:s,backgroundOpacity:s.alpha}};A.setupState(C);const a=this.getFinalColor(A.color,(i=this.colors)==null?void 0:i.highlightedColor),r={state:"hovered",attributes:{backgroundColor:a,backgroundOpacity:a.alpha}};A.setupState(r);const B=this.getFinalColor(A.color,(g=this.colors)==null?void 0:g.pressedColor),Q={state:"pressed",attributes:{backgroundColor:B,backgroundOpacity:B.alpha}};A.setupState(Q);const E=this.getFinalColor(A.color,(I=this.colors)==null?void 0:I.selectedColor),h={state:"selected",attributes:{backgroundColor:E,backgroundOpacity:E.alpha}};A.setupState(h);const d=this.getFinalColor(A.color,(o=this.colors)==null?void 0:o.disabledColor),l={state:"disabled",attributes:{backgroundColor:d,backgroundOpacity:d.alpha}};A.setupState(l)}getFinalColor(A,e){return e?A.clone().multiply(e).convertLinearToSRGB():A.clone().convertLinearToSRGB()}}uo([w(tg)],Sa.prototype,"onClick",2),uo([w(_n)],Sa.prototype,"colors",2),uo([w()],Sa.prototype,"transition",2),uo([w(VIA)],Sa.prototype,"animationTriggers",2),uo([w(qg)],Sa.prototype,"animator",2),uo([w()],Sa.prototype,"interactable",1);var zIA=Object.defineProperty,XIA=Object.getOwnPropertyDescriptor,Hi=(t,A,e,i)=>{for(var g=i>1?void 0:i?XIA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&zIA(A,e,g),g};const f2=tA("debuguilayout");class Hn{constructor(){n(this,"left",0),n(this,"right",0),n(this,"top",0),n(this,"bottom",0)}get vertical(){return this.top+this.bottom}get horizontal(){return this.left+this.right}}Hi([w()],Hn.prototype,"left",2),Hi([w()],Hn.prototype,"right",2),Hi([w()],Hn.prototype,"top",2),Hi([w()],Hn.prototype,"bottom",2);class Do extends FA{constructor(){super(...arguments),n(this,"_rectTransform",null),n(this,"_needsUpdate",!1),n(this,"childAlignment",0),n(this,"reverseArrangement",!1),n(this,"spacing",0),n(this,"padding"),n(this,"minWidth",0),n(this,"minHeight",0),n(this,"flexibleHeight",0),n(this,"flexibleWidth",0),n(this,"preferredHeight",0),n(this,"preferredWidth",0)}get rectTransform(){return this._rectTransform}onParentRectTransformChanged(A){this._needsUpdate=!0}get isDirty(){return this._needsUpdate}get isLayoutGroup(){return!0}updateLayout(){this._rectTransform&&(f2&&console.warn("Layout Update",this.context.time.frame,this.name),this._needsUpdate=!1,this.onCalculateLayout(this._rectTransform))}start(){this._needsUpdate=!0}onEnable(){f2&&console.log(this.name,this),this._rectTransform=this.gameObject.getComponent(FI);const A=this.gameObject.getComponentInParent(Yg);A&&A.registerLayoutGroup(this),this._needsUpdate=!0}onDisable(){const A=this.gameObject.getComponentInParent(Yg);A&&A.unregisterLayoutGroup(this)}set m_Spacing(A){A!==this.spacing&&(this._needsUpdate=!0,this.spacing=A)}get m_Spacing(){return this.spacing}}Hi([w()],Do.prototype,"childAlignment",2),Hi([w()],Do.prototype,"reverseArrangement",2),Hi([w()],Do.prototype,"spacing",2),Hi([w(Hn)],Do.prototype,"padding",2),Hi([w()],Do.prototype,"minWidth",2),Hi([w()],Do.prototype,"minHeight",2),Hi([w()],Do.prototype,"flexibleHeight",2),Hi([w()],Do.prototype,"flexibleWidth",2),Hi([w()],Do.prototype,"preferredHeight",2),Hi([w()],Do.prototype,"preferredWidth",2);class Tn extends Do{constructor(){super(...arguments),n(this,"childControlHeight",!0),n(this,"childControlWidth",!0),n(this,"childForceExpandHeight",!1),n(this,"childForceExpandWidth",!1),n(this,"childScaleHeight",!1),n(this,"childScaleWidth",!1)}onCalculateLayout(A){var e;const i=this.primaryAxis,g=A.width;let I=g;const o=A.height;let s=o;I-=this.padding.horizontal,s-=this.padding.vertical,i==="x"?this.padding.horizontal:this.padding.vertical;const C=i==="x",a=C?"y":"x",r=C?this.childControlWidth:this.childControlHeight,B=C?this.childControlHeight:this.childControlWidth,Q=C?this.childForceExpandWidth:this.childForceExpandHeight,E=C?this.childForceExpandHeight:this.childForceExpandWidth,h=C?s:I,d=C?g:o,l=.5*(C?this.childAlignment%3:Math.floor(this.childAlignment/3));let c=0;C?c+=this.padding.left:c+=this.padding.top;let p=0,u=0;for(let G=0;G<this.gameObject.children.length;G++){const K=this.gameObject.children[G],f=CA.getComponent(K,FI);f!=null&&f.activeAndEnabled&&(u+=1,C?p+=f.width:p+=f.height)}let D=0;const k=this.spacing*(u-1);if(Q||r){let G=0;C?G=I-=k:G=s-=k,u>0&&(D=G/u)}let U=0;U+=this.padding.left,U-=this.padding.right,l!==0&&(c=d-p,c*=l,c-=k*l,C?(c-=this.padding.right*l,c+=this.padding.left*(1-l),c<this.padding.left&&(c=this.padding.left)):(c-=this.padding.bottom*l,c+=this.padding.top*(1-l),c<this.padding.top&&(c=this.padding.top)));let M=1;for(let G=0;G<this.gameObject.children.length;G++){const K=this.gameObject.children[G],f=CA.getComponent(K,FI);if(f!=null&&f.activeAndEnabled){(e=f.pivot)==null||e.set(.5,.5),f.anchorMin.set(0,1),f.anchorMax.set(0,1);const N=g*.5+U*.5;f.anchoredPosition.x!==N&&(f.anchoredPosition.x=N);const _=o*-.5;f.anchoredPosition.y!==_&&(f.anchoredPosition.y=_),E&&B&&f.sizeDelta[a]!==h&&(f.sizeDelta[a]=h),Q&&r&&f.sizeDelta[i]!==D&&(f.sizeDelta[i]=D);const T=C?f.width:f.height,v=T*.5;if(c+=v,Q){const b=D*M-D*.5;b>c&&(c=b-D*.5+T+this.padding.left,c-=v)}let j=c;i==="y"&&(j=-j),f.anchoredPosition[i]!==j&&(f.anchoredPosition[i]=j),c+=v,c+=this.spacing,M+=1}}}}Hi([w()],Tn.prototype,"childControlHeight",2),Hi([w()],Tn.prototype,"childControlWidth",2),Hi([w()],Tn.prototype,"childForceExpandHeight",2),Hi([w()],Tn.prototype,"childForceExpandWidth",2),Hi([w()],Tn.prototype,"childScaleHeight",2),Hi([w()],Tn.prototype,"childScaleWidth",2);class OR extends Tn{get primaryAxis(){return"y"}}class PR extends Tn{get primaryAxis(){return"x"}}class jR extends Do{onCalculateLayout(){}}var $IA=Object.defineProperty,AoA=Object.getOwnPropertyDescriptor,uC=(t,A,e,i)=>{for(var g=i>1?void 0:i?AoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&$IA(A,e,g),g},m2=(t=>(t[t.ScreenSpaceOverlay=0]="ScreenSpaceOverlay",t[t.ScreenSpaceCamera=1]="ScreenSpaceCamera",t[t.WorldSpace=2]="WorldSpace",t[t.Undefined=-1]="Undefined",t))(m2||{});const WR=tA("debuguilayout"),k2=class extends Ad{constructor(){super(...arguments),n(this,"_renderOnTop"),n(this,"_depthWrite",!1),n(this,"_doubleSided",!0),n(this,"_castShadows",!1),n(this,"_receiveShadows",!1),n(this,"_renderMode",-1),n(this,"_rootCanvas"),n(this,"_scaleFactor",1),n(this,"worldCamera"),n(this,"planeDistance",-1),n(this,"_boundRenderSettingsChanged",this.onRenderSettingsChanged.bind(this)),n(this,"previousParent",null),n(this,"_lastMatrixWorld",null),n(this,"_rectTransforms",[]),n(this,"_layoutGroups",new Map),n(this,"_receivers",[]),n(this,"onBeforeRenderRoutine",()=>{var t,A,e,i;if(this.previousParent=this.gameObject.parent,((t=this.context.xr)!=null&&t.isVR||(A=this.context.xr)!=null&&A.isPassThrough)&&this.screenspace){this.gameObject.visible=!1,this.gameObject.removeFromParent();return}this.renderOnTop||this.screenspace?this.gameObject.removeFromParent():(this.onUpdateRenderMode(),this.handleLayoutUpdates(),(e=this.shadowComponent)==null||e.updateMatrixWorld(!0),(i=this.shadowComponent)==null||i.updateWorldMatrix(!0,!0),this.invokeBeforeRenderEvents(),As.ensureUpdateMeshUI(Mx,this.context))}),n(this,"onAfterRenderRoutine",()=>{var t,A,e,i,g;if(((t=this.context.xr)!=null&&t.isVR||(A=this.context.xr)!=null&&A.isPassThrough)&&this.screenspace){(e=this.previousParent)==null||e.add(this.gameObject);return}if((this.screenspace||this.renderOnTop)&&this.previousParent&&this.context.mainCamera){if(this.screenspace){const s=this.context.mainCamera;s?.add(this.gameObject)}else this.previousParent.add(this.gameObject);const I=this.context.renderer.autoClear,o=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(),As.ensureUpdateMeshUI(Mx,this.context,!0),this.context.renderer.render(this.gameObject,this.context.mainCamera),this.context.renderer.autoClear=I,this.context.renderer.autoClearColor=o,this.previousParent.add(this.gameObject)}(g=this._lastMatrixWorld)==null||g.copy(this.gameObject.matrixWorld)}),n(this,"_updateRenderSettingsRoutine"),n(this,"_activeRenderMode",-1),n(this,"_lastWidth",-1),n(this,"_lastHeight",-1)}get isCanvas(){return!0}get screenspace(){return this.renderMode!==2}set renderOnTop(t){t!==this._renderOnTop&&(this._renderOnTop=t,this.onRenderSettingsChanged())}get renderOnTop(){return this._renderOnTop!==void 0?this._renderOnTop:!!(this.screenspace&&this._renderMode===0)}set depthWrite(t){this._depthWrite!==t&&(this._depthWrite=t,this.onRenderSettingsChanged())}get depthWrite(){return this._depthWrite}set doubleSided(t){this._doubleSided!==t&&(this._doubleSided=t,this.onRenderSettingsChanged())}get doubleSided(){return this._doubleSided}set castShadows(t){this._castShadows!==t&&(this._castShadows=t,this.onRenderSettingsChanged())}get castShadows(){return this._castShadows}set receiveShadows(t){this._receiveShadows!==t&&(this._receiveShadows=t,this.onRenderSettingsChanged())}get receiveShadows(){return this._receiveShadows}get renderMode(){return this._renderMode}set renderMode(t){this._renderMode!==t&&(this._renderMode=t,this.onRenderSettingsChanged())}set rootCanvas(t){this._rootCanvas instanceof k2||(this._rootCanvas=t)}get rootCanvas(){return this._rootCanvas}get scaleFactor(){return this._scaleFactor}set scaleFactor(t){this._scaleFactor=t}awake(){var t;this.shadowComponent=this.gameObject,this.previousParent=this.gameObject.parent,WR&&console.log("Canvas.Awake()",((t=this.previousParent)==null?void 0:t.name)+"/"+this.gameObject.name),super.awake()}start(){this.onUpdateRenderMode()}onEnable(){super.onEnable(),this._updateRenderSettingsRoutine=void 0,this._lastMatrixWorld=new MA,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 t=this.context.pre_render_callbacks.indexOf(this.onBeforeRenderRoutine);t!==-1&&this.context.pre_render_callbacks.splice(t,1);const A=this.context.post_render_callbacks.indexOf(this.onAfterRenderRoutine);A!==-1&&this.context.post_render_callbacks.splice(A,1)}registerTransform(t){this._rectTransforms.push(t)}unregisterTransform(t){const A=this._rectTransforms.indexOf(t);A!==-1&&this._rectTransforms.splice(A,1)}registerLayoutGroup(t){const A=t.gameObject;this._layoutGroups.set(A,t)}unregisterLayoutGroup(t){const A=t.gameObject;this._layoutGroups.delete(A)}registerEventReceiver(t){this._receivers.push(t)}unregisterEventReceiver(t){const A=this._receivers.indexOf(t);A!==-1&&this._receivers.splice(A,1)}async onEnterXR(t){this.screenspace?(t.xr.isVR||t.xr.isPassThrough)&&(this.gameObject.visible=!1):(this.gameObject.visible=!1,await cq(1).then(()=>{this.gameObject.visible=!0}))}onLeaveXR(t){this.screenspace&&(t.xr.isVR||t.xr.isPassThrough)&&(this.gameObject.visible=!0)}invokeBeforeRenderEvents(){var t;for(const A of this._receivers)(t=A.onBeforeCanvasRender)==null||t.call(A,this)}handleLayoutUpdates(){this._lastMatrixWorld===null&&(this._lastMatrixWorld=new MA);const t=!this._lastMatrixWorld.equals(this.gameObject.matrixWorld);WR&&t&&console.log("Canvas Layout changed",this.context.time.frameCount,this.name);const A=!1;for(const e of this._rectTransforms){t&&e.markDirty();let i=this._layoutGroups.get(e.gameObject);e.isDirty&&!i&&(i=e.gameObject.getComponentInParent(Do)),(e.isDirty||i!=null&&i.isDirty)&&(WR&&!A&&console.log("CANVAS UPDATE ### "+e.name+" ##################################### "+this.context.time.frame),i?.updateLayout(),e.updateTransform())}}applyRenderSettings(){this.onRenderSettingsChanged()}onRenderSettingsChanged(){this._updateRenderSettingsRoutine||(this._updateRenderSettingsRoutine=this.startCoroutine(this._updateRenderSettingsDelayed(),Ot.OnBeforeRender))}*_updateRenderSettingsDelayed(){if(yield,this._updateRenderSettingsRoutine=void 0,this.shadowComponent){this.onUpdateRenderMode(),Jy(this.shadowComponent,this);for(const t of CA.getComponentsInChildren(this.gameObject,Hs))Jy(t.shadowComponent,this)}}onUpdateRenderMode(t=!1){if(!t&&this._renderMode===this._activeRenderMode&&this._lastWidth===this.context.domWidth&&this._lastHeight===this.context.domHeight)return;this._activeRenderMode=this._renderMode;let A=this.context.mainCameraComponent,e=10;switch(A&&A.nearClipPlane>0&&A.farClipPlane>0&&(e=Ae.lerp(A.nearClipPlane,A.farClipPlane,.01)),this._renderMode===1&&(this.worldCamera&&(A=this.worldCamera),this.planeDistance>0&&(e=this.planeDistance)),this._renderMode){case 0:case 1:if(this._lastWidth=this.context.domWidth,this._lastHeight=this.context.domHeight,!A)return;const i=e+.01;this.gameObject.position.x=0,this.gameObject.position.y=0,this.gameObject.position.z=-i,this.gameObject.quaternion.identity();const g=this.gameObject.getComponent(FI);let I=!1;g.sizeDelta.x!==this.context.domWidth&&(I=!0),g.sizeDelta.y!==this.context.domHeight&&(I=!0);const o=A.fieldOfView*Math.PI/180,s=2*Math.tan(o/2)*Math.abs(i);this.gameObject.scale.x=s/this.context.domHeight,this.gameObject.scale.y=s/this.context.domHeight,this.gameObject.scale.z=.01,I&&(g.sizeDelta.x=this.context.domWidth,g.sizeDelta.y=this.context.domHeight,g?.markDirty());break;case 2:this._lastWidth=-1,this._lastHeight=-1;break}}};let Yg=k2;uC([w()],Yg.prototype,"renderOnTop",1),uC([w()],Yg.prototype,"depthWrite",1),uC([w()],Yg.prototype,"doubleSided",1),uC([w()],Yg.prototype,"castShadows",1),uC([w()],Yg.prototype,"receiveShadows",1),uC([w()],Yg.prototype,"renderMode",1),uC([w(Yg)],Yg.prototype,"rootCanvas",1),uC([w()],Yg.prototype,"scaleFactor",1),uC([w(xt)],Yg.prototype,"worldCamera",2),uC([w()],Yg.prototype,"planeDistance",2);var eoA=Object.defineProperty,toA=Object.getOwnPropertyDescriptor,ZR=(t,A,e,i)=>{for(var g=i>1?void 0:i?toA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&eoA(A,e,g),g};class On extends FA{constructor(){super(...arguments),n(this,"_alpha",1),n(this,"interactable",!0),n(this,"blocksRaycasts",!0),n(this,"_isDirty",!1),n(this,"_buffer",[])}get alpha(){return this._alpha}set alpha(A){A!==this._alpha&&(this._alpha=A,this.markDirty())}get isCanvasGroup(){return!0}markDirty(){this._isDirty||(this._isDirty=!0,this.startCoroutine(this.applyChangesDelayed(),Ot.OnBeforeRender))}*applyChangesDelayed(){this._isDirty=!1,this.applyChangesNow()}applyChangesNow(){this._buffer.length=0;for(const A of CA.getComponentsInChildren(this.gameObject,Hs,this._buffer)){const e=A;e.setAlphaFactor&&e.setAlphaFactor(this._alpha)}}}ZR([w()],On.prototype,"alpha",1),ZR([w()],On.prototype,"interactable",2),ZR([w()],On.prototype,"blocksRaycasts",2);var ioA=Object.defineProperty,goA=Object.getOwnPropertyDescriptor,ni=(t,A,e,i)=>{for(var g=i>1?void 0:i?goA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&ioA(A,e,g),g};const G2=tA("debugusdzbehaviours");function md(t){t&&(t.getComponentInParent(ed)||(re()&&console.warn("Create Raycaster on "+t.name+" because no raycaster was found in the hierarchy"),t.addNewComponent(Qo)))}class KB extends FA{constructor(){super(...arguments),n(this,"object"),n(this,"target"),n(this,"duration",1),n(this,"relativeMotion",!1),n(this,"coroutine",null),n(this,"targetPos",new S),n(this,"targetRot",new RA),n(this,"targetScale",new S)}start(){md(this.gameObject)}onPointerClick(A){A.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 A=Fe(this.object).clone(),e=Fe(this.target).clone(),i=Gt(this.object).clone(),g=Gt(this.target).clone(),I=Tt(this.object).clone(),o=Tt(this.target).clone(),s=A.distanceTo(e),C=i.angleTo(g),a=I.distanceTo(o);if(s<.01&&C<.01&&a<.01){gI(this.object,e),Ho(this.object,g),Wc(this.object,o),this.coroutine=null;return}let r=0,B=0;for(;r<1;)r+=this.context.time.deltaTime/this.duration,r>1&&(r=1),B=r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2,this.targetPos.lerpVectors(A,e,B),this.targetRot.slerpQuaternions(i,g,B),this.targetScale.lerpVectors(I,o,B),gI(this.object,this.targetPos),Ho(this.object,this.targetRot),Wc(this.object,this.targetScale),yield;this.coroutine=null}*moveRelative(){if(!this.target||!this.object)return;const A=this.object.position.clone(),e=this.object.quaternion.clone(),i=this.object.scale.clone(),g=this.target.position.clone(),I=this.target.quaternion.clone(),o=this.target.scale.clone();g.applyQuaternion(this.object.quaternion),this.targetPos.copy(this.object.position).add(g),this.targetRot.copy(this.object.quaternion).multiply(I),this.targetScale.copy(this.object.scale).multiply(o);let s=0,C=0;for(;s<1;)s+=this.context.time.deltaTime/this.duration,s>1&&(s=1),C=s<.5?4*s*s*s:1-Math.pow(-2*s+2,3)/2,this.object.position.lerpVectors(A,this.targetPos,C),this.object.quaternion.slerpQuaternions(e,this.targetRot,C),this.object.scale.lerpVectors(i,this.targetScale,C),yield;this.coroutine=null}beforeCreateDocument(A){var e;if(this.target&&this.object&&this.gameObject){const i=new kg("Move to "+((e=this.target)==null?void 0:e.name),Gg.tapTrigger(this.gameObject),rt.transformAction(this.object,this.target,this.duration,this.relativeMotion?"relative":"absolute"));A.addBehavior(i)}}}ni([w(uA)],KB.prototype,"object",2),ni([w(uA)],KB.prototype,"target",2),ni([w()],KB.prototype,"duration",2),ni([w()],KB.prototype,"relativeMotion",2);var t0;const DC=(t0=class extends FA{constructor(){super(...arguments),n(this,"materialToSwitch"),n(this,"variantMaterial"),n(this,"fadeDuration",0),n(this,"_objectsWithThisMaterial",null),n(this,"selfModel"),n(this,"targetModels")}start(){this._objectsWithThisMaterial=this.objectsWithThisMaterial,md(this.gameObject)}onPointerClick(t){if(t.use(),!!this.variantMaterial)for(let A=0;A<this.objectsWithThisMaterial.length;A++){const e=this.objectsWithThisMaterial[A];e.material=this.variantMaterial}}get objectsWithThisMaterial(){return this._objectsWithThisMaterial!=null?this._objectsWithThisMaterial:(this._objectsWithThisMaterial=[],this.variantMaterial&&this.materialToSwitch&&this.context.scene.traverse(t=>{if(t instanceof hA)if(Array.isArray(t.material)){for(const A of t.material)if(A===this.materialToSwitch){this.objectsWithThisMaterial.push(t);break}}else t.material===this.materialToSwitch&&this.objectsWithThisMaterial.push(t)}),this._objectsWithThisMaterial)}async beforeCreateDocument(t,A){this.targetModels=[],DC._materialTriggersPerId={},DC.variantSwitchIndex=0,this.materialToSwitch&&await Jt.assignTextureLOD(this.context,this.sourceId,this.materialToSwitch,0),this.variantMaterial&&await Jt.assignTextureLOD(this.context,this.sourceId,this.variantMaterial,0)}createBehaviours(t,A,e){this.objectsWithThisMaterial.find(i=>i.uuid===A.uuid)&&this.targetModels.push(A),this.gameObject.uuid===A.uuid&&(this.selfModel=A,this.materialToSwitch&&(DC._materialTriggersPerId[this.materialToSwitch.uuid]||(DC._materialTriggersPerId[this.materialToSwitch.uuid]=[]),DC._materialTriggersPerId[this.materialToSwitch.uuid].push(this)))}afterCreateDocument(t,A){if(!this.materialToSwitch)return;const e=DC._materialTriggersPerId[this.materialToSwitch.uuid];if(e){const i={};for(const g of e){const I=g.createVariants();I&&I.length>0&&(i[g.selfModel.uuid]=I)}for(const g of e){const I=[];for(const o in i)o!==g.selfModel.uuid&&I.push(...i[o]);g.createAndAttachBehaviors(t,i[g.selfModel.uuid],I)}}delete DC._materialTriggersPerId[this.materialToSwitch.uuid]}createAndAttachBehaviors(t,A,e){const i=[],g=[],I=Math.max(0,this.fadeDuration);g.push(rt.fadeAction([...this.targetModels,...e],I,!1)),i.push(rt.fadeAction(A,I,!1)),g.push(rt.fadeAction(A,I,!0)),t.addBehavior(new kg("Select_"+this.selfModel.name,Gg.tapTrigger(this.selfModel),rt.parallel(...g))),t.addBehavior(new kg("StartHidden_"+this.selfModel.name,Gg.sceneStartTrigger(),rt.parallel(...i)))}static getMaterialName(t){return Ms(t.name||"Material")+"_"+t.id}createVariants(){if(!this.variantMaterial)return null;const t=[];for(const A of this.targetModels){const e=A.clone();e.name+="_Variant_"+DC.variantSwitchIndex+++"_"+DC.getMaterialName(this.variantMaterial),e.displayName=e.displayName+": Variant with material "+this.variantMaterial.name,e.material=this.variantMaterial,e.geometry=A.geometry,e.matrix=A.matrix,(!A.parent||!A.parent.isEmpty())&&Co.createEmptyParent(A),A.parent&&A.parent.add(e),t.push(e)}return t}},n(t0,"_materialTriggersPerId",{}),n(t0,"variantSwitchIndex",0),t0);let eh=DC;ni([w(Re)],eh.prototype,"materialToSwitch",2),ni([w(Re)],eh.prototype,"variantMaterial",2),ni([w()],eh.prototype,"fadeDuration",2);var th;const ri=(th=class extends FA{constructor(){super(...arguments),n(this,"target"),n(this,"toggleOnClick",!1),n(this,"targetState",!0),n(this,"hideSelf",!0),n(this,"selfModel"),n(this,"selfModelClone"),n(this,"targetModel"),n(this,"toggleModel"),n(this,"stateBeforeCreatingDocument",!1),n(this,"targetStateBeforeCreatingDocument",!1)}start(){md(this.gameObject)}onPointerClick(t){t.use(),!this.toggleOnClick&&this.hideSelf&&(this.gameObject.visible=!1),this.target&&(this.target.visible=this.toggleOnClick?!this.target.visible:this.targetState)}createBehaviours(t,A,e){A.uuid===this.gameObject.uuid&&(this.selfModel=A,this.selfModelClone=A.clone())}beforeCreateDocument(){this.target&&(this.gameObject[ri.wasVisible]===void 0&&(this.gameObject[ri.wasVisible]=this.gameObject.activeSelf),this.target[ri.wasVisible]===void 0&&(this.target[ri.wasVisible]=this.target.activeSelf),this.stateBeforeCreatingDocument=this.gameObject[ri.wasVisible],this.targetStateBeforeCreatingDocument=this.target[ri.wasVisible],this.gameObject.visible=!0,this.target.visible=!0)}afterCreateDocument(t,A){if(!this.target)return;this.targetModel=A.document.findById(this.target.uuid);const e=this.selfModel;if(this.selfModel&&this.targetModel){let i=this.selfModel,g=this.targetState;if(this.toggleOnClick)if(g=!this.targetStateBeforeCreatingDocument,!this.selfModelClone.geometry)(!this.selfModel.parent||this.selfModel.parent.isEmpty())&&JL.createEmptyParent(this.selfModel),this.toggleModel=this.selfModel.deepClone(),this.toggleModel.name+="_toggle",this.selfModel.parent.add(this.toggleModel);else{if(!this.gameObject[ri.toggleClone]){const C=this.selfModelClone.clone();C.matrix.identity(),C.name+="_toggle"+ri.clonedToggleIndex++,e.add(C),this.gameObject[ri.toggleClone]=C,console.warn("USDZExport: Toggle "+this.gameObject.name+" doesn't have geometry. It will be deep cloned and nested behaviours will likely not work.")}const s=this.gameObject[ri.toggleClone];if(!this.gameObject[ri.reverseToggleClone]){const C=this.selfModelClone.clone();C.matrix.identity(),C.name+="_toggleReverse"+ri.clonedToggleIndex++,e.add(C),this.gameObject[ri.reverseToggleClone]=C}this.toggleModel=this.gameObject[ri.reverseToggleClone],(!this.toggleModel.geometry||!s.geometry)&&console.error("triggers without childs and without geometry won't work!",this,e.geometry),i=s,e.geometry=null,e.material=null}if(this.toggleModel){if(this.toggleOnClick){const s=[];s.push(rt.fadeAction(i,0,!1)),s.push(rt.fadeAction(this.toggleModel,0,!0)),s.push(rt.fadeAction(this.targetModel,0,g)),t.addBehavior(new kg("Toggle_"+i.name+"_toggleTo"+(g?"On":"Off"),Gg.tapTrigger(i),rt.parallel(...s)));const C=[];C.push(rt.fadeAction(this.toggleModel,0,!1)),C.push(rt.fadeAction(i,0,!0)),C.push(rt.fadeAction(this.targetModel,0,!g)),t.addBehavior(new kg("Toggle_"+i.name+"_toggleTo"+(g?"Off":"On"),Gg.tapTrigger(this.toggleModel),rt.parallel(...C)))}}else{const s=[];this.hideSelf&&s.push(rt.fadeAction(i,0,!1)),s.push(rt.fadeAction(this.targetModel,0,g)),t.addBehavior(new kg("Toggle_"+i.name+"_toggleTo"+(g?"On":"Off"),Gg.tapTrigger(i),rt.parallel(...s)))}const I=s=>{const C=Co.createEmpty();C.name="InputTarget",C.displayName=void 0,C.type="RealityKitComponent",C.onSerialize=a=>{a.appendLine("bool allowsDirectInput = 1"),a.appendLine("bool allowsIndirectInput = 1"),a.appendLine('uniform token info:id = "RealityKit.InputTarget"')},s.add(C)};I(i),this.toggleModel&&I(this.toggleModel);const o=new Array;this.targetStateBeforeCreatingDocument||o.push(this.targetModel),this.stateBeforeCreatingDocument||o.push(e),this.toggleModel&&o.push(this.toggleModel),t.addBehavior(new kg("HideOnStart_"+this.gameObject.name,Gg.sceneStartTrigger(),rt.fadeAction(o,0,!1)))}}afterSerialize(t,A){this.gameObject[ri.wasVisible]!==void 0&&(this.gameObject.visible=this.gameObject[ri.wasVisible],delete this.gameObject[ri.wasVisible]),this.target&&this.target[ri.wasVisible]!==void 0&&(this.target.visible=this.target[ri.wasVisible],delete this.target[ri.wasVisible]),delete this.gameObject[ri.toggleClone],delete this.gameObject[ri.reverseToggleClone]}},n(th,"clonedToggleIndex",0),n(th,"wasVisible",Symbol("usdz_SetActiveOnClick_wasVisible")),n(th,"toggleClone",Symbol("clone for toggling")),n(th,"reverseToggleClone",Symbol("clone for reverse toggling")),th);let JB=ri;ni([w(uA)],JB.prototype,"target",2),ni([w()],JB.prototype,"toggleOnClick",2),ni([w()],JB.prototype,"targetState",2),ni([w()],JB.prototype,"hideSelf",2);class VR extends FA{start(){this.gameObject.visible=!1}createBehaviours(A,e,i){e.uuid===this.gameObject.uuid&&A.addBehavior(new kg("HideOnStart_"+this.gameObject.name,Gg.sceneStartTrigger(),rt.fadeAction(e,0,!1)))}beforeCreateDocument(){this.gameObject.visible=!0}afterCreateDocument(){this.gameObject.visible=!1}}class ih extends FA{constructor(){super(...arguments),n(this,"target"),n(this,"duration",.5),n(this,"motionType","bounce")}beforeCreateDocument(){}createBehaviours(A,e,i){if(this.target&&e.uuid===this.gameObject.uuid){const g=new kg("emphasize "+this.name,Gg.tapTrigger(this.gameObject),rt.emphasize(this.target,this.duration,this.motionType,void 0,"basic"));A.addBehavior(g)}}afterCreateDocument(A,e){}}ni([w()],ih.prototype,"target",2),ni([w()],ih.prototype,"duration",2),ni([w()],ih.prototype,"motionType",2);class Pn extends FA{constructor(){super(...arguments),n(this,"target"),n(this,"clip",""),n(this,"toggleOnClick",!1)}start(){md(this.gameObject)}ensureAudioSource(){if(!this.target){const A=this.gameObject.addNewComponent(ai);A&&(this.target=A,A.spatialBlend=1,A.volume=1,A.loop=!1)}}onPointerClick(A){var e;A.use(),!(!((e=this.target)!=null&&e.clip)&&!this.clip)&&(this.ensureAudioSource(),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(A,e,i){if(!(!this.target&&!this.clip)&&e.uuid===this.gameObject.uuid){const g=this.clip?this.clip:this.target?this.target.clip:void 0;if(!g||typeof g!="string")return;const I=this.target?this.target.gameObject:this.gameObject,o=rr.getName(g),s=this.target?this.target.volume:1,C=this.target&&this.target.spatialBlend==0?"nonSpatial":"spatial";let a=!1;if(this.gameObject.traverse(r=>{r instanceof hA&&r.visible&&(a=!0)}),a=!0,a){let r=rt.playAudioAction(I,"audio/"+o,"play",s,C);this.toggleOnClick&&(r.multiplePerformOperation="stop"),this.target&&this.target.loop&&(r=rt.sequence(r).makeLooping());const B=new kg("playAudio "+this.name,Gg.tapTrigger(this.gameObject),r);A.addBehavior(B)}if(this.target&&this.target.playOnAwake&&this.target.enabled){let r=rt.playAudioAction(I,"audio/"+o,"play",s,C);this.target.loop&&(r=rt.sequence(r).makeLooping());const B=new kg("playAudioOnStart"+(this.name?"_"+this.name:""),Gg.sceneStartTrigger(),r);A.addBehavior(B)}}}async afterSerialize(A,e){if(!this.target&&!this.clip)return;const i=this.clip?this.clip:this.target?this.target.clip:void 0;if(!i||typeof i!="string")return;const g="audio/"+rr.getName(i);if(e.files[g])return;const I=await(await(await fetch(i)).blob()).arrayBuffer(),o=new Uint8Array(I);e.files[g]=o}}ni([w(ai)],Pn.prototype,"target",2),ni([w(URL)],Pn.prototype,"clip",2),ni([w()],Pn.prototype,"toggleOnClick",2);var i0;const jn=(i0=class extends FA{constructor(){super(...arguments),n(this,"animator"),n(this,"stateName"),n(this,"trigger","tap"),n(this,"animation"),n(this,"selfModel"),n(this,"stateAnimationModel"),n(this,"animationSequence",new Array),n(this,"animationLoopAfterSequence",new Array)}get target(){var t,A;return((t=this.animator)==null?void 0:t.gameObject)||((A=this.animation)==null?void 0:A.gameObject)}start(){md(this.gameObject)}onPointerClick(t){var A;t.use(),this.target&&this.stateName&&((A=this.animator)==null||A.play(this.stateName,0,0,.1))}createBehaviours(t,A,e){A.uuid===this.gameObject.uuid&&(this.selfModel=A)}afterSerialize(){if(jn.rootsWithExclusivePlayback.size>1){const t='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.';re()&&Ci(t),console.warn(t,...jn.rootsWithExclusivePlayback)}jn.animationActions=[],jn.rootsWithExclusivePlayback=new Set}afterCreateDocument(t,A){if(this.animationSequence===void 0&&this.animationLoopAfterSequence===void 0||!this.stateAnimationModel||!this.target)return;const e=A.document,i=A.extensions.find(o=>o instanceof Bd);if(!i)return;const g=i.getClipCount(this.target)>1;g&&(re()&&console.warn("Setting exclusive playback for "+this.target.name+"@"+this.stateName+" because it has "+i.getClipCount(this.target)+" animations. This works around QuickLook bug FB13410767."),jn.rootsWithExclusivePlayback.add(this.target));const I=(o,s)=>{let C=jn.animationActions.find(a=>a.affectedObjects==o&&a.start==s.start&&a.duration==s.duration);return C||(C=rt.startAnimationAction(o,s.start,s.duration),jn.animationActions.push(C)),C};e.traverse(o=>{var s,C;if(o.uuid===((s=this.target)==null?void 0:s.uuid)){const a=rt.sequence();if(this.animationSequence&&this.animationSequence.length>0)for(const B of this.animationSequence)a.addAction(I(o,B));if(this.animationLoopAfterSequence&&this.animationLoopAfterSequence.length>0){const B=a.actions.length==0?a:rt.sequence();for(const Q of this.animationLoopAfterSequence)B.addAction(I(o,Q));B.makeLooping(),a!==B&&a.addAction(B)}const r=new kg("_tap_"+this.name+"_toPlayClip_"+this.stateName+"_on_"+((C=this.target)==null?void 0:C.name),this.trigger=="tap"?Gg.tapTrigger(this.selfModel):Gg.sceneStartTrigger(),a);g&&r.makeExclusive(!0),t.addBehavior(r)}})}createAnimation(t,A,e){var i,g,I,o,s,C,a;if(!this.target||!this.animator&&!this.animation)return;if(this.stateAnimationModel=A,this.animation){this.animationSequence=new Array,this.animationLoopAfterSequence=new Array;const d=t.registerAnimation(this.target,this.animation.clip);d&&this.animationLoopAfterSequence.push(d);return}const r=(i=this.animator)==null?void 0:i.runtimeAnimatorController;let B=r?.findState(this.stateName),Q=[],E=[];if(r&&B){const d=new Array;d.push(B);let l=!1;for(;d.length<100;){if(!B||B===null||!B.transitions||B.transitions.length===0){(g=B.motion)!=null&&g.isLooping&&(l=!0);break}const c=B.transitions.find(u=>u.conditions.length===0),p=c?r.getState(c.destinationState,0):null;if(p&&d.includes(p)){B=p,l=!0;break}else if(c){if(B=p,!B)break;d.push(B)}else{l=((I=B.motion)==null?void 0:I.isLooping)??!1;break}}if(l&&B){const c=d.indexOf(B);Q=d.slice(0,c),E=d.slice(c),G2&&console.log("found loop from "+this.stateName,"states until loop",Q,"states looping",E)}else Q=d,E=[],G2&&console.log("found no loop from "+this.stateName,"states",Q)}if(Q.length===1&&(!((o=Q[0].motion)!=null&&o.clip)||((C=(s=Q[0].motion)==null?void 0:s.clip.tracks)==null?void 0:C.length)===0)){this.animationSequence=new Array;const d=t.registerAnimation(this.target,null);d&&this.animationSequence.push(d);return}if(Q=Q.filter(d=>{var l,c,p;return((l=d.motion)==null?void 0:l.clip)&&((p=(c=d.motion)==null?void 0:c.clip.tracks)==null?void 0:p.length)>0}),E=E.filter(d=>{var l,c,p;return((l=d.motion)==null?void 0:l.clip)&&((p=(c=d.motion)==null?void 0:c.clip.tracks)==null?void 0:p.length)>0}),Q.length===0&&E.length===0){console.warn("No clips found for state "+this.stateName+" on "+((a=this.animator)==null?void 0:a.name)+", can't export animation data");return}const h=(d,l)=>{var c;if(!this.target)return;const p=t.registerAnimation(this.target,d.motion.clip??null);p?l.push(p):console.warn("Couldn't register animation for state "+d.name+" on "+((c=this.animator)==null?void 0:c.name))};if(Q.length>0){this.animationSequence=new Array;for(const d of Q)h(d,this.animationSequence)}if(E.length>0){this.animationLoopAfterSequence=new Array;for(const d of E)h(d,this.animationLoopAfterSequence)}}},n(i0,"animationActions",[]),n(i0,"rootsWithExclusivePlayback",new Set),i0);let vB=jn;ni([w(qg)],vB.prototype,"animator",2),ni([w()],vB.prototype,"stateName",2);class gh extends FA{constructor(){super(...arguments),n(this,"target")}getType(){}getDuration(){}}ni([w(uA)],gh.prototype,"target",2);class kd extends FA{constructor(){super(...arguments),n(this,"target")}}ni([w(gh)],kd.prototype,"target",2);class Gd extends gh{constructor(){super(...arguments),n(this,"type",1),n(this,"duration",1)}getType(){switch(this.type){case 1:return"hide";case 0:return"show"}}getDuration(){return this.duration}}ni([w()],Gd.prototype,"type",2),ni([w()],Gd.prototype,"duration",2);class zR extends kd{}var IoA=Object.defineProperty,ooA=Object.getOwnPropertyDescriptor,fa=(t,A,e,i)=>{for(var g=i>1?void 0:i?ooA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&IoA(A,e,g),g};const M2=tA("debugcharactercontroller");class bB extends FA{constructor(){super(...arguments),n(this,"center",new S(0,0,0)),n(this,"radius",.5),n(this,"height",2),n(this,"_rigidbody",null),n(this,"_activeGroundCollisions"),n(this,"_contactVelocity",new S)}get rigidbody(){return this._rigidbody?this._rigidbody:(this._rigidbody=this.gameObject.getComponent(Ut),this._rigidbody||(this._rigidbody=this.gameObject.addNewComponent(Ut)),this.rigidbody)}awake(){this._activeGroundCollisions=new Set}onEnable(){const A=this.rigidbody;let e=this.gameObject.getComponent(ya);e||(e=this.gameObject.addNewComponent(ya)),e.center.copy(this.center),e.radius=this.radius,e.height=this.height;const i=new S(0,0,1),g=new S(1,0,0),I=new S(0,1,0),o=this.gameObject.getWorldDirection(new S);o.y=0;const s=g.dot(o)<0?-1:1,C=i.angleTo(o)*s;this.gameObject.setRotationFromAxisAngle(I,C),A.lockRotationX=!0,A.lockRotationY=!0,A.lockRotationZ=!0}move(A){this.gameObject.position.add(A)}onCollisionEnter(A){(A.contacts.length==0||A.contacts.some(e=>e.normal.y>.2))&&(this._activeGroundCollisions.add(A),M2&&console.log(`Collision(${this._activeGroundCollisions.size}): ${A.contacts.map(e=>e.normal.y.toFixed(2)).join(", ")} - ${this.isGrounded}`))}onCollisionExit(A){this._activeGroundCollisions.delete(A),M2&&console.log(`Collision(${this._activeGroundCollisions.size}) - ${this.isGrounded}`)}get isGrounded(){return this._activeGroundCollisions.size>0}get contactVelocity(){var A;this._contactVelocity.set(0,0,0);for(const e of this._activeGroundCollisions){const i=(A=this.context.physics.engine)==null?void 0:A.getLinearVelocity(e.collider);i&&(this._contactVelocity.x+=i.x,this._contactVelocity.y+=i.y,this._contactVelocity.z+=i.z)}return this._contactVelocity}}fa([w(S)],bB.prototype,"center",2),fa([w()],bB.prototype,"radius",2),fa([w()],bB.prototype,"height",2);class ma extends FA{constructor(){super(...arguments),n(this,"controller"),n(this,"movementSpeed",2),n(this,"rotationSpeed",2),n(this,"jumpForce",1),n(this,"doubleJumpForce",2),n(this,"animator"),n(this,"lookForward",!0),n(this,"lookInput",new eA(0,0)),n(this,"moveInput",new eA(0,0)),n(this,"jumpInput",!1),n(this,"_currentSpeed",new S(0,0,0)),n(this,"_currentAngularSpeed",new S(0,0,0)),n(this,"_temp",new S(0,0,0)),n(this,"_jumpCount",0),n(this,"_currentRotation"),n(this,"_raycastOptions",new zo)}awake(){this._currentRotation=new RA}update(){const A=this.context.input;A.isKeyPressed("KeyW")?this.moveInput.y+=1:A.isKeyPressed("KeyS")&&(this.moveInput.y-=1),A.isKeyPressed("KeyD")?this.lookInput.x+=1:A.isKeyPressed("KeyA")&&(this.lookInput.x-=1),this.jumpInput||(this.jumpInput=A.isKeyDown("Space"))}move(A){this.moveInput.add(A)}look(A){this.lookInput.add(A)}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(A,e,i){var g,I,o,s,C,a,r,B,Q,E,h;if((g=this.controller)!=null&&g.isGrounded&&(this._jumpCount=0,this.doubleJumpForce>0&&((I=this.animator)==null||I.setBool("doubleJump",!1))),this._currentSpeed.z+=A.y*this.movementSpeed*this.context.time.deltaTime,(o=this.animator)==null||o.setBool("running",A.length()>.01),(C=this.animator)==null||C.setBool("jumping",((s=this.controller)==null?void 0:s.isGrounded)===!0&&i),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+=Ae.toRadians(-e.x*this.rotationSpeed)*this.context.time.deltaTime,this.lookForward&&Math.abs(this._currentAngularSpeed.y)<.01){const d=this.context.mainCameraComponent.forward;d.y=0,d.normalize(),this._currentRotation.setFromUnitVectors(new S(0,0,1),d),this.gameObject.quaternion.slerp(this._currentRotation,this.context.time.deltaTime*10)}if(this.gameObject.rotateY(this._currentAngularSpeed.y),this._currentSpeed.multiplyScalar(1-this.context.time.deltaTime*10),this._currentAngularSpeed.y*=1-this.context.time.deltaTime*10,this.controller&&i&&this.jumpForce>0){let d=(a=this.controller)==null?void 0:a.isGrounded;if(this.doubleJumpForce>0&&!((r=this.controller)!=null&&r.isGrounded)&&this._jumpCount===1&&(d=!0,(B=this.animator)==null||B.setBool("doubleJump",!0)),d){this._jumpCount+=1;const l=this.controller.rigidbody,c=this._jumpCount===2?this.doubleJumpForce:this.jumpForce;l.applyImpulse(new S(0,1,0).multiplyScalar(c))}}if(this.controller){const d=(Q=this.controller)==null?void 0:Q.rigidbody.getVelocity().y;if(d<-1){this._raycastOptions.ray||(this._raycastOptions.ray=new HI),this._raycastOptions.ray.origin.copy(Fe(this.gameObject)),this._raycastOptions.ray.direction.set(0,-1,0);const l=this.layer;this.gameObject.layers.disableAll(),this.gameObject.layers.set(2);const c=this.context.physics.raycast(this._raycastOptions);this.gameObject.layers.set(l),(c.length&&c[0].distance>2||d<-10)&&((E=this.animator)==null||E.setBool("falling",!0))}else(h=this.animator)==null||h.setBool("falling",!1)}}}fa([w(bB)],ma.prototype,"controller",2),fa([w()],ma.prototype,"movementSpeed",2),fa([w()],ma.prototype,"rotationSpeed",2),fa([w()],ma.prototype,"jumpForce",2),fa([w()],ma.prototype,"doubleJumpForce",2),fa([w(qg)],ma.prototype,"animator",2);var soA=Object.defineProperty,CoA=Object.getOwnPropertyDescriptor,aoA=(t,A,e,i)=>{for(var g=i>1?void 0:i?CoA(A,e):A,I=t.length-1,o;I>=0;I--)(o=t[I])&&(g=(i?o(A,e,g):o(g))||g);return i&&g&&soA(A,e,g),g};class Md extends aI{constructor(){super(...arguments),n(this,"intensity")}get typeName(){return"ChromaticAberration"}init(){this.intensity.defaultValue=0}onCreateEffect(){const A=new vY;return A.offset=new eA(0,0),A.radialModulation=!0,A.modulationOffset=.15,this.intensity.valueProcessor=e=>e*.02,this.intensity.onValueChanged=e=>{A.offset.x=-e,A.offset.y=e},A}}aoA([w(Ne)],Md.prototype,"intensity",2),ts("ChromaticAberration",Md);const Ud=new he;Ud.setAttribute("position",new ee(new Float32Array([-1,-1,3,-1,-1,3]),2)),Ud.setAttribute("uv",new ee(new Float32Array([0,0,2,0,0,2]),2)),Ud.boundingSphere=new Di,Ud.computeBoundingSphere=function(){};const noA=new VC;class qB{constructor(A){this._mesh=new hA(Ud,A),this._mesh.frustumCulled=!1}render(A){A.render(this._mesh,noA)}get material(){return this._mesh.material}set material(A){this._mesh.material=A}dispose(){this._mesh.material.dispose(),this._mesh.geometry.dispose()}}const roA={uniforms:{sceneDiffuse:{value:null},sceneDepth:{value:null},sceneNormal:{value:null},projMat:{value:new MA},viewMat:{value:new MA},projViewMat:{value:new MA},projectionMatrixInv:{value:new MA},viewMatrixInv:{value:new MA},cameraPos:{value:new S},resolution:{value:new eA},time:{value:0},samples:{value:[]},bluenoise:{value:null},distanceFalloff:{value:1},radius:{value:5},near:{value:.1},far:{value:1e3},logDepth:{value:!1},ortho:{value:!1},screenSpaceRadius:{value:!1},frame:{value:0}},depthWrite:!1,depthTest:!1,vertexShader:`
|